LibreOffice Module svx (master) 1
langbox.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_SVX_LANGBOX_HXX
20#define INCLUDED_SVX_LANGBOX_HXX
21
22#include <memory>
23#include <com/sun/star/uno/Sequence.hxx>
24#include <com/sun/star/i18n/ScriptType.hpp>
25#include <svx/svxdllapi.h>
26#include <vcl/weld.hxx>
28
30{
31 EMPTY = 0x0000,
32 ALL = 0x0001,
33 WESTERN = 0x0002,
34 CTL = 0x0004,
35 CJK = 0x0008,
36 FBD_CHARS = 0x0010,
37 ONLY_KNOWN = 0x0020, // list only locales provided by I18N
38 SPELL_USED = 0x0040,
39};
40namespace o3tl
41{
42 template<> struct typed_flags<SvxLanguageListFlags> : is_typed_flags<SvxLanguageListFlags, 0x007f> {};
43}
44
45// load language strings from resource
46SVXCORE_DLLPUBLIC OUString GetDicInfoStr( std::u16string_view rName, const LanguageType nLang, bool bNeg );
47
50{
51public:
52 enum class EditedAndValid
53 {
54 No,
55 Valid,
57 };
58
59private:
60 std::unique_ptr<weld::ComboBox> m_xControl;
62 OUString m_aAllString;
63 std::unique_ptr<css::uno::Sequence<sal_Int16>> m_xSpellUsedLang;
69
70 SVX_DLLPRIVATE weld::ComboBoxEntry BuildEntry(const LanguageType nLangType, sal_Int16 nType = css::i18n::ScriptType::WEAK);
71 SVX_DLLPRIVATE void AddLanguages(const std::vector< LanguageType >& rLanguageTypes, SvxLanguageListFlags nLangList,
72 std::vector<weld::ComboBoxEntry>& rEntries);
73 SVX_DLLPRIVATE void InsertLanguage(const LanguageType nLangType, sal_Int16 nType);
74
75 SVX_DLLPRIVATE int ImplTypeToPos(LanguageType eType) const;
77public:
78 SvxLanguageBox(std::unique_ptr<weld::ComboBox> pControl);
79 void SetLanguageList( SvxLanguageListFlags nLangList,
80 bool bHasLangNone, bool bLangNoneIsLangAll = false,
81 bool bCheckSpellAvail = false, bool bDefaultLangExist = false,
82 LanguageType eDefaultLangType = LANGUAGE_NONE,
83 sal_Int16 nDefaultType = 0 );
84 void InsertLanguage(const LanguageType nLangType);
85
86 EditedAndValid GetEditedAndValid() const { return m_eEditedAndValid;}
87 sal_Int32 SaveEditedAsEntry();
88
89 void connect_changed(const Link<weld::ComboBox&, void>& rLink) { m_aChangeHdl = rLink; }
90 void connect_focus_in(const Link<weld::Widget&, void>& rLink) { m_xControl->connect_focus_in(rLink); }
91 void grab_focus() { m_xControl->grab_focus(); }
92 void save_active_id() { m_eSavedLanguage = get_active_id(); }
93 LanguageType get_saved_active_id() const { return m_eSavedLanguage; }
94 bool get_active_id_changed_from_saved() const { return m_eSavedLanguage != get_active_id(); }
95 void hide() { m_xControl->hide(); }
96 void set_visible(bool bShow) { m_xControl->set_visible(bShow); }
97 void set_size_request(int nWidth, int nHeight) { m_xControl->set_size_request(nWidth, nHeight); }
98 void set_width_chars(int nChars) { m_xControl->set_entry_width_chars(nChars); }
99 void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
100 void set_active(int nPos) { m_xControl->set_active(nPos); }
101 int get_active() const { return m_xControl->get_active(); }
102 void set_active_id(const LanguageType eLangType);
103 OUString get_active_text() const { return m_xControl->get_active_text(); }
104 bool get_visible() const { return m_xControl->get_visible(); }
105 LanguageType get_active_id() const;
106 int find_id(const LanguageType eLangType) const;
107 LanguageType get_id(int nPos) const;
108 void set_id(int nPos, const LanguageType eLangType);
109 void remove_id(const LanguageType eLangType);
110 void append(const LanguageType eLangType, const OUString& rStr);
111 int find_text(const OUString& rStr) const { return m_xControl->find_text(rStr); }
112 OUString get_text(int nPos) const { return m_xControl->get_text(nPos); }
113 int get_count() const { return m_xControl->get_count(); }
115};
116
117#endif
118
119/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define WESTERN
void set_size_request(int nWidth, int nHeight)
Definition: langbox.hxx:97
LanguageType get_saved_active_id() const
Definition: langbox.hxx:93
bool m_bLangNoneIsLangAll
Definition: langbox.hxx:67
bool get_visible() const
Definition: langbox.hxx:104
int get_count() const
Definition: langbox.hxx:113
int get_active() const
Definition: langbox.hxx:101
OUString get_active_text() const
Definition: langbox.hxx:103
bool m_bWithCheckmark
Definition: langbox.hxx:68
void grab_focus()
Definition: langbox.hxx:91
void save_active_id()
Definition: langbox.hxx:92
void set_sensitive(bool bSensitive)
Definition: langbox.hxx:99
int find_text(const OUString &rStr) const
Definition: langbox.hxx:111
weld::ComboBox * get_widget()
Definition: langbox.hxx:114
DECL_DLLPRIVATE_LINK(ChangeHdl, weld::ComboBox &, void)
EditedAndValid m_eEditedAndValid
Definition: langbox.hxx:65
Link< weld::ComboBox &, void > m_aChangeHdl
Definition: langbox.hxx:61
void set_visible(bool bShow)
Definition: langbox.hxx:96
bool m_bHasLangNone
Definition: langbox.hxx:66
bool get_active_id_changed_from_saved() const
Definition: langbox.hxx:94
std::unique_ptr< weld::ComboBox > m_xControl
Definition: langbox.hxx:60
LanguageType m_eSavedLanguage
Definition: langbox.hxx:64
void connect_focus_in(const Link< weld::Widget &, void > &rLink)
Definition: langbox.hxx:90
EditedAndValid GetEditedAndValid() const
Definition: langbox.hxx:86
OUString get_text(int nPos) const
Definition: langbox.hxx:112
void set_active(int nPos)
Definition: langbox.hxx:100
void hide()
Definition: langbox.hxx:95
void connect_changed(const Link< weld::ComboBox &, void > &rLink)
Definition: langbox.hxx:89
std::unique_ptr< css::uno::Sequence< sal_Int16 > > m_xSpellUsedLang
Definition: langbox.hxx:63
OUString m_aAllString
Definition: langbox.hxx:62
void set_width_chars(int nChars)
Definition: langbox.hxx:98
DocumentType eType
SVXCORE_DLLPUBLIC OUString GetDicInfoStr(std::u16string_view rName, const LanguageType nLang, bool bNeg)
Definition: langbox.cxx:47
SvxLanguageListFlags
Definition: langbox.hxx:30
sal_uInt16 nPos
No
constexpr OUStringLiteral EMPTY
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
Reference< XControl > m_xControl