Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / langbox.hxx
blobd7a7f26e9a4060fbc0f2bc2a41848a2aeac2b5a3
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 <o3tl/typed_flags_set.hxx>
31 enum class SvxLanguageListFlags
33 EMPTY = 0x0000,
34 ALL = 0x0001,
35 WESTERN = 0x0002,
36 CTL = 0x0004,
37 CJK = 0x0008,
38 FBD_CHARS = 0x0010,
39 SPELL_AVAIL = 0x0020,
40 HYPH_AVAIL = 0x0040,
41 THES_AVAIL = 0x0080,
42 ONLY_KNOWN = 0x0100, // list only locales provided by I18N
43 SPELL_USED = 0x0200,
44 HYPH_USED = 0x0400,
45 THES_USED = 0x0800,
46 ALSO_PRIMARY_ONLY = 0x1000, // Do not exclude primary-only
47 // languages that do not form a
48 // locale, such as Arabic as
49 // opposed to Arabic-Egypt.
51 namespace o3tl
53 template<> struct typed_flags<SvxLanguageListFlags> : is_typed_flags<SvxLanguageListFlags, 0x1fff> {};
56 // load language strings from resource
57 SVX_DLLPUBLIC OUString GetDicInfoStr( const OUString& rName, const LanguageType nLang, bool bNeg );
59 class SVX_DLLPUBLIC SvxLanguageBoxBase
61 private:
62 SvxLanguageBoxBase(const SvxLanguageBoxBase&) = delete;
63 SvxLanguageBoxBase& operator=(const SvxLanguageBoxBase&) = delete;
64 public:
65 explicit SvxLanguageBoxBase();
66 virtual ~SvxLanguageBoxBase();
68 void SetLanguageList( SvxLanguageListFlags nLangList,
69 bool bHasLangNone, bool bLangNoneIsLangAll = false,
70 bool bCheckSpellAvail = false );
72 void AddLanguages( const std::vector< LanguageType >& rLanguageTypes, SvxLanguageListFlags nLangList );
74 sal_Int32 InsertLanguage( const LanguageType eLangType );
75 void InsertDefaultLanguage( sal_Int16 nType );
76 void InsertSystemLanguage();
77 void InsertLanguage( const LanguageType eLangType,
78 bool bCheckEntry );
79 void RemoveLanguage( const LanguageType eLangType );
80 void SelectLanguage( const LanguageType eLangType );
81 LanguageType GetSelectLanguage() const;
82 bool IsLanguageSelected( const LanguageType eLangType ) const;
84 void SetNoSelectionLBB();
85 void HideLBB();
86 void DisableLBB();
87 void SaveValueLBB();
88 sal_Int32 GetSelectEntryPosLBB() const;
89 void* GetEntryDataLBB( sal_Int32 nPos ) const;
90 sal_Int32 GetSavedValueLBB() const;
92 protected:
93 Image m_aNotCheckedImage;
94 Image m_aCheckedImage;
95 OUString m_aAllString;
96 std::unique_ptr<css::uno::Sequence< sal_Int16 >>
97 m_pSpellUsedLang;
98 SvxLanguageListFlags m_nLangList;
99 bool m_bHasLangNone;
100 bool m_bLangNoneIsLangAll;
101 bool m_bWithCheckmark;
103 SVX_DLLPRIVATE void ImplLanguageBoxBaseInit();
104 SVX_DLLPRIVATE sal_Int32 ImplInsertLanguage(LanguageType, sal_Int32 nPos, sal_Int16 nType);
105 SVX_DLLPRIVATE sal_Int32 ImplTypeToPos( LanguageType eType ) const;
107 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertImgEntry( const OUString& rEntry, sal_Int32 nPos, bool bChecked ) = 0;
108 SVX_DLLPRIVATE virtual void ImplRemoveEntryAt( sal_Int32 nPos ) = 0;
110 SVX_DLLPRIVATE virtual void ImplClear() = 0;
111 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertEntry( const OUString& rEntry, sal_Int32 nPos ) = 0;
112 SVX_DLLPRIVATE virtual void ImplSetEntryData( sal_Int32 nPos, void* pData ) = 0;
113 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSelectEntryPos() const = 0;
114 SVX_DLLPRIVATE virtual void* ImplGetEntryData( sal_Int32 nPos ) const = 0;
115 SVX_DLLPRIVATE virtual void ImplSelectEntryPos( sal_Int32 nPos, bool bSelect ) = 0;
116 SVX_DLLPRIVATE virtual bool ImplIsEntryPosSelected( sal_Int32 nPos ) const = 0;
117 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryPos( const void* pData ) const = 0;
118 SVX_DLLPRIVATE virtual void ImplSetNoSelection() = 0;
119 SVX_DLLPRIVATE virtual void ImplHide() = 0;
120 SVX_DLLPRIVATE virtual void ImplDisable() = 0;
121 SVX_DLLPRIVATE virtual void ImplSaveValue() = 0;
122 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSavedValue() const = 0;
126 class SVX_DLLPUBLIC SvxLanguageBox : public ListBox, public SvxLanguageBoxBase
128 public:
129 SvxLanguageBox( vcl::Window* pParent, WinBits nBits );
131 private:
132 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertImgEntry( const OUString& rEntry, sal_Int32 nPos, bool bChecked ) override;
133 SVX_DLLPRIVATE virtual void ImplRemoveEntryAt( sal_Int32 nPos ) override;
135 SVX_DLLPRIVATE virtual void ImplClear() override;
136 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertEntry( const OUString& rEntry, sal_Int32 nPos ) override;
137 SVX_DLLPRIVATE virtual void ImplSetEntryData( sal_Int32 nPos, void* pData ) override;
138 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSelectEntryPos() const override;
139 SVX_DLLPRIVATE virtual void* ImplGetEntryData( sal_Int32 nPos ) const override;
140 SVX_DLLPRIVATE virtual void ImplSelectEntryPos( sal_Int32 nPos, bool bSelect ) override;
141 SVX_DLLPRIVATE virtual bool ImplIsEntryPosSelected( sal_Int32 nPos ) const override;
142 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryPos( const void* pData ) const override;
143 SVX_DLLPRIVATE virtual void ImplSetNoSelection() override;
144 SVX_DLLPRIVATE virtual void ImplHide() override;
145 SVX_DLLPRIVATE virtual void ImplDisable() override;
146 SVX_DLLPRIVATE virtual void ImplSaveValue() override;
147 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSavedValue() const override;
151 class SVX_DLLPUBLIC SvxLanguageComboBox : public ComboBox, public SvxLanguageBoxBase
153 public:
154 SvxLanguageComboBox( vcl::Window* pParent, WinBits nBits );
156 enum class EditedAndValid
159 Valid,
160 Invalid
163 EditedAndValid GetEditedAndValid() const { return meEditedAndValid;}
164 sal_Int32 SaveEditedAsEntry();
167 private:
168 sal_Int32 mnSavedValuePos;
169 EditedAndValid meEditedAndValid;
171 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertImgEntry( const OUString& rEntry, sal_Int32 nPos, bool bChecked ) override;
172 SVX_DLLPRIVATE virtual void ImplRemoveEntryAt( sal_Int32 nPos ) override;
174 SVX_DLLPRIVATE virtual void ImplClear() override;
175 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertEntry( const OUString& rEntry, sal_Int32 nPos ) override;
176 SVX_DLLPRIVATE virtual void ImplSetEntryData( sal_Int32 nPos, void* pData ) override;
177 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSelectEntryPos() const override;
178 SVX_DLLPRIVATE virtual void* ImplGetEntryData( sal_Int32 nPos ) const override;
179 SVX_DLLPRIVATE virtual void ImplSelectEntryPos( sal_Int32 nPos, bool bSelect ) override;
180 SVX_DLLPRIVATE virtual bool ImplIsEntryPosSelected( sal_Int32 nPos ) const override;
181 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryPos( const void* pData ) const override;
182 SVX_DLLPRIVATE virtual void ImplSetNoSelection() override;
183 SVX_DLLPRIVATE virtual void ImplHide() override;
184 SVX_DLLPRIVATE virtual void ImplDisable() override;
185 SVX_DLLPRIVATE virtual void ImplSaveValue() override;
186 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSavedValue() const override;
188 DECL_LINK( EditModifyHdl, Edit&, void );
191 #endif
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */