1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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
42 ONLY_KNOWN
= 0x0100, // list only locales provided by I18N
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.
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
62 SvxLanguageBoxBase(const SvxLanguageBoxBase
&) = delete;
63 SvxLanguageBoxBase
& operator=(const SvxLanguageBoxBase
&) = delete;
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
,
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();
88 sal_Int32
GetSelectEntryPosLBB() const;
89 void* GetEntryDataLBB( sal_Int32 nPos
) const;
90 sal_Int32
GetSavedValueLBB() const;
93 Image m_aNotCheckedImage
;
94 Image m_aCheckedImage
;
95 OUString m_aAllString
;
96 std::unique_ptr
<css::uno::Sequence
< sal_Int16
>>
98 SvxLanguageListFlags m_nLangList
;
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
129 SvxLanguageBox( vcl::Window
* pParent
, WinBits nBits
);
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
154 SvxLanguageComboBox( vcl::Window
* pParent
, WinBits nBits
);
156 enum class EditedAndValid
163 EditedAndValid
GetEditedAndValid() const { return meEditedAndValid
;}
164 sal_Int32
SaveEditedAsEntry();
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 );
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */