Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / linguistic / source / lngopt.hxx
blobd466acd320044feaaa14efc5fe83b0a7397c6b56
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 .
20 #pragma once
22 #include <cppuhelper/implbase.hxx>
23 #include <comphelper/interfacecontainer3.hxx>
24 #include <comphelper/multiinterfacecontainer3.hxx>
25 #include <com/sun/star/beans/XFastPropertySet.hpp>
26 #include <com/sun/star/beans/XPropertyAccess.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/lang/XComponent.hpp>
29 #include <com/sun/star/linguistic2/XLinguProperties.hpp>
30 #include <unotools/lingucfg.hxx>
31 #include <svl/itemprop.hxx>
32 #include <unotools/linguprops.hxx>
33 #include <com/sun/star/uno/Any.h>
35 namespace com::sun::star {
36 namespace beans {
37 struct PropertyChangeEvent;
42 // LinguOptions
43 // This class represents all Linguistik relevant options.
45 class LinguOptions
47 static SvtLinguOptions *pData;
48 static oslInterlockedCount nRefCount; // number of objects of this class
50 public:
51 LinguOptions();
52 LinguOptions(const LinguOptions &rOpt);
53 ~LinguOptions();
55 static OUString GetName( sal_Int32 nWID );
57 const css::uno::Sequence< OUString >&
58 GetActiveDics() const { return pData->aActiveDics; }
61 typedef comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XPropertyChangeListener, sal_Int32>
62 OPropertyListenerContainerHelper;
64 class LinguProps :
65 public cppu::WeakImplHelper
67 css::linguistic2::XLinguProperties,
68 css::beans::XFastPropertySet,
69 css::beans::XPropertyAccess,
70 css::lang::XComponent,
71 css::lang::XServiceInfo
74 ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> aEvtListeners;
75 OPropertyListenerContainerHelper aPropListeners;
77 SfxItemPropertyMap aPropertyMap;
78 SvtLinguConfig aConfig;
80 bool bDisposing;
82 LinguProps(const LinguProps &) = delete;
83 LinguProps & operator = (const LinguProps &) = delete;
85 void launchEvent( const css::beans::PropertyChangeEvent &rEvt ) const;
87 /// @throws css::uno::RuntimeException
88 bool getPropertyBool(const OUString& aPropertyName);
89 /// @throws css::uno::RuntimeException
90 sal_Int16 getPropertyInt16(const OUString& aPropertyName);
91 /// @throws css::uno::RuntimeException
92 css::lang::Locale getPropertyLocale(const OUString& aPropertyName);
93 /// @throws css::uno::RuntimeException
94 void setProperty(const OUString& aPropertyName, bool p1)
95 { setPropertyValue( aPropertyName, css::uno::Any(p1) ); }
96 /// @throws css::uno::RuntimeException
97 void setProperty(const OUString& aPropertyName, sal_Int16 p1)
98 { setPropertyValue( aPropertyName, css::uno::Any(p1) ); }
99 /// @throws css::uno::RuntimeException
100 void setProperty(const OUString& aPropertyName, css::lang::Locale p1)
101 { setPropertyValue( aPropertyName, css::uno::Any(p1) ); }
103 public:
104 LinguProps();
106 virtual sal_Bool SAL_CALL getIsUseDictionaryList() override
107 { return getPropertyBool(UPN_IS_USE_DICTIONARY_LIST); }
108 virtual void SAL_CALL setIsUseDictionaryList(sal_Bool p1) override
109 { setProperty(UPN_IS_USE_DICTIONARY_LIST, static_cast<bool>(p1)); }
110 virtual sal_Bool SAL_CALL getIsIgnoreControlCharacters() override
111 { return getPropertyBool(UPN_IS_IGNORE_CONTROL_CHARACTERS); }
112 virtual void SAL_CALL setIsIgnoreControlCharacters(sal_Bool p1) override
113 { setProperty(UPN_IS_IGNORE_CONTROL_CHARACTERS, static_cast<bool>(p1)); }
114 virtual sal_Bool SAL_CALL getIsSpellUpperCase() override
115 { return getPropertyBool(UPN_IS_SPELL_UPPER_CASE); }
116 virtual void SAL_CALL setIsSpellUpperCase(sal_Bool p1) override
117 { setProperty(UPN_IS_SPELL_UPPER_CASE, static_cast<bool>(p1)); }
118 virtual sal_Bool SAL_CALL getIsSpellWithDigits() override
119 { return getPropertyBool(UPN_IS_SPELL_WITH_DIGITS); }
120 virtual void SAL_CALL setIsSpellWithDigits(sal_Bool p1) override
121 { setProperty(UPN_IS_SPELL_WITH_DIGITS, static_cast<bool>(p1)); }
122 virtual sal_Bool SAL_CALL getIsSpellCapitalization() override
123 { return getPropertyBool(UPN_IS_SPELL_CAPITALIZATION); }
124 virtual void SAL_CALL setIsSpellCapitalization(sal_Bool p1) override
125 { setProperty(UPN_IS_SPELL_CAPITALIZATION, static_cast<bool>(p1)); }
126 virtual sal_Int16 SAL_CALL getHyphMinLeading() override
127 { return getPropertyInt16(UPN_HYPH_MIN_LEADING); }
128 virtual void SAL_CALL setHyphMinLeading(sal_Int16 p1) override
129 { setProperty(UPN_HYPH_MIN_LEADING, p1); }
130 virtual sal_Int16 SAL_CALL getHyphMinTrailing() override
131 { return getPropertyInt16(UPN_HYPH_MIN_TRAILING); }
132 virtual void SAL_CALL setHyphMinTrailing(sal_Int16 p1) override
133 { setProperty(UPN_HYPH_MIN_TRAILING, p1); }
134 virtual sal_Int16 SAL_CALL getHyphMinWordLength() override
135 { return getPropertyInt16(UPN_HYPH_MIN_WORD_LENGTH); }
136 virtual void SAL_CALL setHyphMinWordLength(sal_Int16 p1) override
137 { setProperty(UPN_HYPH_MIN_WORD_LENGTH, p1); }
138 virtual css::lang::Locale SAL_CALL getDefaultLocale() override
139 { return getPropertyLocale(UPN_DEFAULT_LOCALE); }
140 virtual void SAL_CALL setDefaultLocale(const css::lang::Locale& p1) override
141 { setProperty(UPN_DEFAULT_LOCALE, p1); }
142 virtual sal_Bool SAL_CALL getIsHyphAuto() override
143 { return getPropertyBool(UPN_IS_HYPH_AUTO); }
144 virtual void SAL_CALL setIsHyphAuto(sal_Bool p1) override
145 { setProperty(UPN_IS_HYPH_AUTO, static_cast<bool>(p1)); }
146 virtual sal_Bool SAL_CALL getIsHyphSpecial() override
147 { return getPropertyBool(UPN_IS_HYPH_SPECIAL); }
148 virtual void SAL_CALL setIsHyphSpecial(sal_Bool p1) override
149 { setProperty(UPN_IS_HYPH_SPECIAL, static_cast<bool>(p1)); }
150 virtual sal_Bool SAL_CALL getIsSpellAuto() override
151 { return getPropertyBool(UPN_IS_SPELL_AUTO); }
152 virtual void SAL_CALL setIsSpellAuto(sal_Bool p1) override
153 { setProperty(UPN_IS_SPELL_AUTO, static_cast<bool>(p1)); }
154 virtual sal_Bool SAL_CALL getIsSpellSpecial() override
155 { return getPropertyBool(UPN_IS_SPELL_SPECIAL); }
156 virtual void SAL_CALL setIsSpellSpecial(sal_Bool p1) override
157 { setProperty(UPN_IS_SPELL_SPECIAL, static_cast<bool>(p1)); }
158 virtual sal_Bool SAL_CALL getIsWrapReverse() override
159 { return getPropertyBool(UPN_IS_WRAP_REVERSE); }
160 virtual void SAL_CALL setIsWrapReverse(sal_Bool p1) override
161 { setProperty(UPN_IS_WRAP_REVERSE, static_cast<bool>(p1)); }
162 virtual css::lang::Locale SAL_CALL getDefaultLocale_CJK() override
163 { return getPropertyLocale(UPN_DEFAULT_LOCALE_CJK); }
164 virtual void SAL_CALL setDefaultLocale_CJK(const css::lang::Locale& p1) override
165 { setProperty(UPN_DEFAULT_LOCALE_CJK, p1); }
166 virtual css::lang::Locale SAL_CALL getDefaultLocale_CTL() override
167 { return getPropertyLocale(UPN_DEFAULT_LOCALE_CTL); }
168 virtual void SAL_CALL setDefaultLocale_CTL(const css::lang::Locale& p1) override
169 { setProperty(UPN_DEFAULT_LOCALE_CTL, p1); }
171 // XPropertySet
172 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
173 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
174 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
175 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override;
176 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override;
177 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override;
178 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override;
180 // XFastPropertySet
181 virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& aValue ) override;
182 virtual css::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) override;
184 // XPropertyAccess
185 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override;
186 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< css::beans::PropertyValue >& aProps ) override;
188 // XComponent
189 virtual void SAL_CALL dispose() override;
190 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) override;
191 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) override;
193 // XServiceInfo
194 virtual OUString SAL_CALL getImplementationName() override;
195 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
196 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */