bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / svx / langbox.hxx
blob48efdc26db81b183678d64fbe6ef39ec85823ad8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SVX_LANGBOX_HXX
20 #define INCLUDED_SVX_LANGBOX_HXX
22 #include <memory>
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <svx/svxdllapi.h>
25 #include <vcl/image.hxx>
26 #include <vcl/lstbox.hxx>
27 #include <vcl/combobox.hxx>
28 #include <vcl/weld.hxx>
29 #include <o3tl/typed_flags_set.hxx>
32 enum class SvxLanguageListFlags
34 EMPTY = 0x0000,
35 ALL = 0x0001,
36 WESTERN = 0x0002,
37 CTL = 0x0004,
38 CJK = 0x0008,
39 FBD_CHARS = 0x0010,
40 ONLY_KNOWN = 0x0020, // list only locales provided by I18N
41 SPELL_USED = 0x0040,
43 namespace o3tl
45 template<> struct typed_flags<SvxLanguageListFlags> : is_typed_flags<SvxLanguageListFlags, 0x007f> {};
48 // load language strings from resource
49 SVX_DLLPUBLIC OUString GetDicInfoStr( const OUString& rName, const LanguageType nLang, bool bNeg );
51 class SVX_DLLPUBLIC SvxLanguageBoxBase
53 private:
54 SvxLanguageBoxBase(const SvxLanguageBoxBase&) = delete;
55 SvxLanguageBoxBase& operator=(const SvxLanguageBoxBase&) = delete;
56 public:
57 explicit SvxLanguageBoxBase();
58 virtual ~SvxLanguageBoxBase();
60 void SetLanguageList( SvxLanguageListFlags nLangList,
61 bool bHasLangNone,
62 bool bCheckSpellAvail );
64 void AddLanguages( const std::vector< LanguageType >& rLanguageTypes, SvxLanguageListFlags nLangList );
66 sal_Int32 InsertLanguage( const LanguageType eLangType );
67 void InsertDefaultLanguage( sal_Int16 nType );
68 void InsertSystemLanguage();
69 void InsertLanguage( const LanguageType eLangType,
70 bool bCheckEntry );
71 void SelectLanguage( const LanguageType eLangType );
72 LanguageType GetSelectedLanguage() const;
73 bool IsLanguageSelected( const LanguageType eLangType ) const;
75 protected:
76 Image m_aNotCheckedImage;
77 Image m_aCheckedImage;
78 std::unique_ptr<css::uno::Sequence< sal_Int16 >>
79 m_pSpellUsedLang;
80 bool m_bWithCheckmark;
82 SVX_DLLPRIVATE void ImplLanguageBoxBaseInit();
83 SVX_DLLPRIVATE sal_Int32 ImplInsertLanguage(LanguageType, sal_Int32 nPos, sal_Int16 nType);
84 SVX_DLLPRIVATE sal_Int32 ImplTypeToPos( LanguageType eType ) const;
86 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertImgEntry( const OUString& rEntry, sal_Int32 nPos, bool bChecked ) = 0;
88 SVX_DLLPRIVATE virtual void ImplClear() = 0;
89 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertEntry( const OUString& rEntry, sal_Int32 nPos ) = 0;
90 SVX_DLLPRIVATE virtual void ImplSetEntryData( sal_Int32 nPos, void* pData ) = 0;
91 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSelectedEntryPos() const = 0;
92 SVX_DLLPRIVATE virtual void* ImplGetEntryData( sal_Int32 nPos ) const = 0;
93 SVX_DLLPRIVATE virtual void ImplSelectEntryPos( sal_Int32 nPos, bool bSelect ) = 0;
94 SVX_DLLPRIVATE virtual bool ImplIsEntryPosSelected( sal_Int32 nPos ) const = 0;
95 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryPos( const void* pData ) const = 0;
99 class SVX_DLLPUBLIC SvxLanguageBox : public ListBox, public SvxLanguageBoxBase
101 public:
102 SvxLanguageBox( vcl::Window* pParent, WinBits nBits );
104 private:
105 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertImgEntry( const OUString& rEntry, sal_Int32 nPos, bool bChecked ) override;
107 SVX_DLLPRIVATE virtual void ImplClear() override;
108 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertEntry( const OUString& rEntry, sal_Int32 nPos ) override;
109 SVX_DLLPRIVATE virtual void ImplSetEntryData( sal_Int32 nPos, void* pData ) override;
110 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSelectedEntryPos() const override;
111 SVX_DLLPRIVATE virtual void* ImplGetEntryData( sal_Int32 nPos ) const override;
112 SVX_DLLPRIVATE virtual void ImplSelectEntryPos( sal_Int32 nPos, bool bSelect ) override;
113 SVX_DLLPRIVATE virtual bool ImplIsEntryPosSelected( sal_Int32 nPos ) const override;
114 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryPos( const void* pData ) const override;
117 class SVX_DLLPUBLIC LanguageBox
119 public:
120 enum class EditedAndValid
123 Valid,
124 Invalid
127 private:
128 std::unique_ptr<weld::ComboBox> m_xControl;
129 Link<weld::ComboBox&, void> m_aChangeHdl;
130 OUString const m_aAllString;
131 std::unique_ptr<css::uno::Sequence<sal_Int16>> m_xSpellUsedLang;
132 LanguageType m_eSavedLanguage;
133 EditedAndValid m_eEditedAndValid;
134 bool m_bHasLangNone;
135 bool m_bLangNoneIsLangAll;
136 bool m_bWithCheckmark;
138 SVX_DLLPRIVATE weld::ComboBoxEntry BuildEntry(const LanguageType nLangType);
139 SVX_DLLPRIVATE void AddLanguages(const std::vector< LanguageType >& rLanguageTypes, SvxLanguageListFlags nLangList,
140 std::vector<weld::ComboBoxEntry>& rEntries);
142 SVX_DLLPRIVATE int ImplTypeToPos(LanguageType eType) const;
143 SVX_DLLPRIVATE void ImplClear();
144 DECL_LINK(ChangeHdl, weld::ComboBox&, void);
145 public:
146 LanguageBox(std::unique_ptr<weld::ComboBox> pControl);
147 void SetLanguageList( SvxLanguageListFlags nLangList,
148 bool bHasLangNone, bool bLangNoneIsLangAll = false,
149 bool bCheckSpellAvail = false );
150 void InsertLanguage(const LanguageType nLangType);
152 EditedAndValid GetEditedAndValid() const { return m_eEditedAndValid;}
153 sal_Int32 SaveEditedAsEntry();
155 void connect_changed(const Link<weld::ComboBox&, void>& rLink) { m_aChangeHdl = rLink; }
156 void connect_focus_in(const Link<weld::Widget&, void>& rLink) { m_xControl->connect_focus_in(rLink); }
157 void save_active_id() { m_eSavedLanguage = get_active_id(); }
158 LanguageType get_saved_active_id() const { return m_eSavedLanguage; }
159 bool get_active_id_changed_from_saved() const { return m_eSavedLanguage != get_active_id(); }
160 void show() { m_xControl->show(); }
161 void hide() { m_xControl->hide(); }
162 void set_visible(bool bShow) { m_xControl->set_visible(bShow); }
163 void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
164 void set_active(int nPos) { m_xControl->set_active(nPos); }
165 int get_active() const { return m_xControl->get_active(); }
166 void set_active_id(const LanguageType eLangType);
167 OUString get_active_text() const { return m_xControl->get_active_text(); }
168 bool get_visible() const { return m_xControl->get_visible(); }
169 LanguageType get_active_id() const;
170 int find_id(const LanguageType eLangType) const;
171 LanguageType get_id(int nPos) const;
172 void set_id(int nPos, const LanguageType eLangType);
173 void remove_id(const LanguageType eLangType);
174 void append(const LanguageType eLangType, const OUString& rStr);
175 int find_text(const OUString& rStr) const { return m_xControl->find_text(rStr); }
176 OUString get_text(int nPos) const { return m_xControl->get_text(nPos); }
177 int get_count() const { return m_xControl->get_count(); }
178 const weld::ComboBox* get_widget() const { return m_xControl.get(); }
181 class SVX_DLLPUBLIC SvxLanguageComboBox : public ComboBox, public SvxLanguageBoxBase
183 public:
184 SvxLanguageComboBox( vcl::Window* pParent, WinBits nBits );
186 enum class EditedAndValid
189 Valid,
190 Invalid
193 private:
194 EditedAndValid meEditedAndValid;
196 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertImgEntry( const OUString& rEntry, sal_Int32 nPos, bool bChecked ) override;
198 SVX_DLLPRIVATE virtual void ImplClear() override;
199 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertEntry( const OUString& rEntry, sal_Int32 nPos ) override;
200 SVX_DLLPRIVATE virtual void ImplSetEntryData( sal_Int32 nPos, void* pData ) override;
201 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSelectedEntryPos() const override;
202 SVX_DLLPRIVATE virtual void* ImplGetEntryData( sal_Int32 nPos ) const override;
203 SVX_DLLPRIVATE virtual void ImplSelectEntryPos( sal_Int32 nPos, bool bSelect ) override;
204 SVX_DLLPRIVATE virtual bool ImplIsEntryPosSelected( sal_Int32 nPos ) const override;
205 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryPos( const void* pData ) const override;
207 DECL_LINK( EditModifyHdl, Edit&, void );
210 #endif
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */