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
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
41 ONLY_KNOWN
= 0x0100, // list only locales provided by I18N
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.
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
61 SvxLanguageBoxBase(const SvxLanguageBoxBase
&) SAL_DELETED_FUNCTION
;
62 SvxLanguageBoxBase
& operator=(const SvxLanguageBoxBase
&) SAL_DELETED_FUNCTION
;
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();
85 sal_Int32
GetSelectEntryPosLBB( sal_Int32 nSelIndex
= 0 ) const;
86 void* GetEntryDataLBB( sal_Int32 nPos
) const;
87 sal_Int32
GetSavedValueLBB() const;
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
;
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
126 SvxLanguageBox( vcl::Window
* pParent
, WinBits nBits
, bool bCheck
= false );
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
152 SvxLanguageComboBox( vcl::Window
* pParent
, WinBits nBits
, bool bCheck
= false );
161 EditedAndValid
GetEditedAndValid() const { return meEditedAndValid
;}
162 sal_Int32
SaveEditedAsEntry();
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
* );
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */