bump product version to 5.0.4.1
[LibreOffice.git] / include / svx / langbox.hxx
blob4c0dc57abf8a41a6c52a8bebd7b8bdb4ee1b816e
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 <com/sun/star/uno/Sequence.hxx>
23 #include <svx/svxdllapi.h>
24 #include <vcl/image.hxx>
25 #include <vcl/lstbox.hxx>
26 #include <vcl/combobox.hxx>
27 #include <o3tl/typed_flags_set.hxx>
30 enum class SvxLanguageListFlags
32 EMPTY = 0x0000,
33 ALL = 0x0001,
34 WESTERN = 0x0002,
35 CTL = 0x0004,
36 CJK = 0x0008,
37 FBD_CHARS = 0x0010,
38 SPELL_AVAIL = 0x0020,
39 HYPH_AVAIL = 0x0040,
40 THES_AVAIL = 0x0080,
41 ONLY_KNOWN = 0x0100, // list only locales provided by I18N
42 SPELL_USED = 0x0200,
43 HYPH_USED = 0x0400,
44 THES_USED = 0x0800,
45 ALSO_PRIMARY_ONLY = 0x1000, // Do not exclude primary-only
46 // languages that do not form a
47 // locale, such as Arabic as
48 // opposed to Arabic-Egypt.
50 namespace o3tl
52 template<> struct typed_flags<SvxLanguageListFlags> : is_typed_flags<SvxLanguageListFlags, 0x1fff> {};
55 // load language strings from resource
56 SVX_DLLPUBLIC OUString GetDicInfoStr( const OUString& rName, const sal_uInt16 nLang, bool bNeg );
58 class SVX_DLLPUBLIC SvxLanguageBoxBase
60 private:
61 SvxLanguageBoxBase(const SvxLanguageBoxBase&) SAL_DELETED_FUNCTION;
62 SvxLanguageBoxBase& operator=(const SvxLanguageBoxBase&) SAL_DELETED_FUNCTION;
63 public:
64 explicit SvxLanguageBoxBase( bool bCheck );
65 virtual ~SvxLanguageBoxBase();
67 void SetLanguageList( SvxLanguageListFlags nLangList,
68 bool bHasLangNone, bool bLangNoneIsLangAll = false,
69 bool bCheckSpellAvail = false );
71 sal_Int32 InsertLanguage( const LanguageType eLangType, sal_Int32 nPos = LISTBOX_APPEND );
72 sal_Int32 InsertDefaultLanguage( sal_Int16 nType, sal_Int32 nPos = LISTBOX_APPEND );
73 sal_Int32 InsertSystemLanguage( sal_Int32 nPos = LISTBOX_APPEND );
74 sal_Int32 InsertLanguage( const LanguageType eLangType,
75 bool bCheckEntry, sal_Int32 nPos = LISTBOX_APPEND );
76 void RemoveLanguage( const LanguageType eLangType );
77 void SelectLanguage( const LanguageType eLangType, bool bSelect = true );
78 LanguageType GetSelectLanguage() const;
79 bool IsLanguageSelected( const LanguageType eLangType ) const;
81 void SetNoSelectionLBB();
82 void HideLBB();
83 void DisableLBB();
84 void SaveValueLBB();
85 sal_Int32 GetSelectEntryPosLBB( sal_Int32 nSelIndex = 0 ) const;
86 void* GetEntryDataLBB( sal_Int32 nPos ) const;
87 sal_Int32 GetSavedValueLBB() const;
89 protected:
90 Image m_aNotCheckedImage;
91 Image m_aCheckedImage;
92 OUString m_aAllString;
93 com::sun::star::uno::Sequence< sal_Int16 > *m_pSpellUsedLang;
94 SvxLanguageListFlags m_nLangList;
95 bool m_bHasLangNone;
96 bool m_bLangNoneIsLangAll;
97 bool m_bWithCheckmark;
99 SVX_DLLPRIVATE void ImplLanguageBoxBaseInit();
100 SVX_DLLPRIVATE sal_Int32 ImplInsertLanguage(LanguageType, sal_Int32 nPos, sal_Int16 nType);
101 SVX_DLLPRIVATE sal_Int32 ImplTypeToPos( LanguageType eType ) const;
103 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertImgEntry( const OUString& rEntry, sal_Int32 nPos, bool bChecked ) = 0;
104 SVX_DLLPRIVATE virtual void ImplRemoveEntryAt( sal_Int32 nPos ) = 0;
106 SVX_DLLPRIVATE virtual void ImplClear() = 0;
107 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertEntry( const OUString& rEntry, sal_Int32 nPos ) = 0;
108 SVX_DLLPRIVATE virtual void ImplSetEntryData( sal_Int32 nPos, void* pData ) = 0;
109 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSelectEntryPos( sal_Int32 nSelIndex = 0 ) const = 0;
110 SVX_DLLPRIVATE virtual void* ImplGetEntryData( sal_Int32 nPos ) const = 0;
111 SVX_DLLPRIVATE virtual void ImplSelectEntryPos( sal_Int32 nPos, bool bSelect ) = 0;
112 SVX_DLLPRIVATE virtual bool ImplIsEntryPosSelected( sal_Int32 nPos ) const = 0;
113 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryPos( const void* pData ) const = 0;
114 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryCount() const = 0;
115 SVX_DLLPRIVATE virtual void ImplSetNoSelection() = 0;
116 SVX_DLLPRIVATE virtual void ImplHide() = 0;
117 SVX_DLLPRIVATE virtual void ImplDisable() = 0;
118 SVX_DLLPRIVATE virtual void ImplSaveValue() = 0;
119 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSavedValue() const = 0;
123 class SVX_DLLPUBLIC SvxLanguageBox : public ListBox, public SvxLanguageBoxBase
125 public:
126 SvxLanguageBox( vcl::Window* pParent, WinBits nBits, bool bCheck = false );
128 private:
129 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertImgEntry( const OUString& rEntry, sal_Int32 nPos, bool bChecked ) SAL_OVERRIDE;
130 SVX_DLLPRIVATE virtual void ImplRemoveEntryAt( sal_Int32 nPos ) SAL_OVERRIDE;
132 SVX_DLLPRIVATE virtual void ImplClear() SAL_OVERRIDE;
133 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertEntry( const OUString& rEntry, sal_Int32 nPos ) SAL_OVERRIDE;
134 SVX_DLLPRIVATE virtual void ImplSetEntryData( sal_Int32 nPos, void* pData ) SAL_OVERRIDE;
135 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSelectEntryPos( sal_Int32 nSelIndex = 0 ) const SAL_OVERRIDE;
136 SVX_DLLPRIVATE virtual void* ImplGetEntryData( sal_Int32 nPos ) const SAL_OVERRIDE;
137 SVX_DLLPRIVATE virtual void ImplSelectEntryPos( sal_Int32 nPos, bool bSelect ) SAL_OVERRIDE;
138 SVX_DLLPRIVATE virtual bool ImplIsEntryPosSelected( sal_Int32 nPos ) const SAL_OVERRIDE;
139 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryPos( const void* pData ) const SAL_OVERRIDE;
140 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryCount() const SAL_OVERRIDE;
141 SVX_DLLPRIVATE virtual void ImplSetNoSelection() SAL_OVERRIDE;
142 SVX_DLLPRIVATE virtual void ImplHide() SAL_OVERRIDE;
143 SVX_DLLPRIVATE virtual void ImplDisable() SAL_OVERRIDE;
144 SVX_DLLPRIVATE virtual void ImplSaveValue() SAL_OVERRIDE;
145 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSavedValue() const SAL_OVERRIDE;
149 class SVX_DLLPUBLIC SvxLanguageComboBox : public ComboBox, public SvxLanguageBoxBase
151 public:
152 SvxLanguageComboBox( vcl::Window* pParent, WinBits nBits, bool bCheck = false );
154 enum EditedAndValid
156 EDITED_NO,
157 EDITED_VALID,
158 EDITED_INVALID
161 EditedAndValid GetEditedAndValid() const { return meEditedAndValid;}
162 sal_Int32 SaveEditedAsEntry();
165 private:
166 sal_Int32 mnSavedValuePos;
167 EditedAndValid meEditedAndValid;
169 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertImgEntry( const OUString& rEntry, sal_Int32 nPos, bool bChecked ) SAL_OVERRIDE;
170 SVX_DLLPRIVATE virtual void ImplRemoveEntryAt( sal_Int32 nPos ) SAL_OVERRIDE;
172 SVX_DLLPRIVATE virtual void ImplClear() SAL_OVERRIDE;
173 SVX_DLLPRIVATE virtual sal_Int32 ImplInsertEntry( const OUString& rEntry, sal_Int32 nPos ) SAL_OVERRIDE;
174 SVX_DLLPRIVATE virtual void ImplSetEntryData( sal_Int32 nPos, void* pData ) SAL_OVERRIDE;
175 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSelectEntryPos( sal_Int32 nSelIndex = 0 ) const SAL_OVERRIDE;
176 SVX_DLLPRIVATE virtual void* ImplGetEntryData( sal_Int32 nPos ) const SAL_OVERRIDE;
177 SVX_DLLPRIVATE virtual void ImplSelectEntryPos( sal_Int32 nPos, bool bSelect ) SAL_OVERRIDE;
178 SVX_DLLPRIVATE virtual bool ImplIsEntryPosSelected( sal_Int32 nPos ) const SAL_OVERRIDE;
179 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryPos( const void* pData ) const SAL_OVERRIDE;
180 SVX_DLLPRIVATE virtual sal_Int32 ImplGetEntryCount() const SAL_OVERRIDE;
181 SVX_DLLPRIVATE virtual void ImplSetNoSelection() SAL_OVERRIDE;
182 SVX_DLLPRIVATE virtual void ImplHide() SAL_OVERRIDE;
183 SVX_DLLPRIVATE virtual void ImplDisable() SAL_OVERRIDE;
184 SVX_DLLPRIVATE virtual void ImplSaveValue() SAL_OVERRIDE;
185 SVX_DLLPRIVATE virtual sal_Int32 ImplGetSavedValue() const SAL_OVERRIDE;
187 DECL_LINK( EditModifyHdl, SvxLanguageComboBox* );
190 #endif
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */