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 .
20 #ifndef INCLUDED_LINGUISTIC_SOURCE_LNGOPT_HXX
21 #define INCLUDED_LINGUISTIC_SOURCE_LNGOPT_HXX
23 #include <cppuhelper/implbase.hxx>
24 #include <cppuhelper/interfacecontainer.hxx>
25 #include <comphelper/interfacecontainer2.hxx>
26 #include <com/sun/star/beans/XFastPropertySet.hpp>
27 #include <com/sun/star/beans/XPropertyAccess.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XComponent.hpp>
30 #include <com/sun/star/linguistic2/XLinguProperties.hpp>
31 #include <unotools/lingucfg.hxx>
32 #include <svl/itemprop.hxx>
33 #include <unotools/linguprops.hxx>
34 #include <com/sun/star/uno/Any.h>
36 namespace com
{ namespace sun
{ namespace star
{
38 struct PropertyChangeEvent
;
44 // This class represents all Linguistik relevant options.
48 static SvtLinguOptions
*pData
;
49 static oslInterlockedCount nRefCount
; // number of objects of this class
53 LinguOptions(const LinguOptions
&rOpt
);
56 static OUString
GetName( sal_Int32 nWID
);
58 const css::uno::Sequence
< OUString
>&
59 GetActiveDics() const { return pData
->aActiveDics
; }
62 typedef cppu::OMultiTypeInterfaceContainerHelperVar
<sal_Int32
>
63 OPropertyListenerContainerHelper
;
66 public cppu::WeakImplHelper
68 css::linguistic2::XLinguProperties
,
69 css::beans::XFastPropertySet
,
70 css::beans::XPropertyAccess
,
71 css::lang::XComponent
,
72 css::lang::XServiceInfo
75 ::comphelper::OInterfaceContainerHelper2 aEvtListeners
;
76 OPropertyListenerContainerHelper aPropListeners
;
78 SfxItemPropertyMap aPropertyMap
;
79 SvtLinguConfig aConfig
;
83 LinguProps(const LinguProps
&) = delete;
84 LinguProps
& operator = (const LinguProps
&) = delete;
86 void launchEvent( const css::beans::PropertyChangeEvent
&rEvt
) const;
88 /// @throws css::uno::RuntimeException
89 bool getPropertyBool(const OUString
& aPropertyName
);
90 /// @throws css::uno::RuntimeException
91 sal_Int16
getPropertyInt16(const OUString
& aPropertyName
);
92 /// @throws css::uno::RuntimeException
93 css::lang::Locale
getPropertyLocale(const OUString
& aPropertyName
);
94 /// @throws css::uno::RuntimeException
95 void setProperty(const OUString
& aPropertyName
, bool p1
)
96 { setPropertyValue( aPropertyName
, css::uno::Any(p1
) ); }
97 /// @throws css::uno::RuntimeException
98 void setProperty(const OUString
& aPropertyName
, sal_Int16 p1
)
99 { setPropertyValue( aPropertyName
, css::uno::Any(p1
) ); }
100 /// @throws css::uno::RuntimeException
101 void setProperty(const OUString
& aPropertyName
, css::lang::Locale p1
)
102 { setPropertyValue( aPropertyName
, css::uno::Any(p1
) ); }
107 virtual sal_Bool SAL_CALL
getIsUseDictionaryList() override
108 { return getPropertyBool(UPN_IS_USE_DICTIONARY_LIST
); }
109 virtual void SAL_CALL
setIsUseDictionaryList(sal_Bool p1
) override
110 { setProperty(UPN_IS_USE_DICTIONARY_LIST
, static_cast<bool>(p1
)); }
111 virtual sal_Bool SAL_CALL
getIsIgnoreControlCharacters() override
112 { return getPropertyBool(UPN_IS_IGNORE_CONTROL_CHARACTERS
); }
113 virtual void SAL_CALL
setIsIgnoreControlCharacters(sal_Bool p1
) override
114 { setProperty(UPN_IS_IGNORE_CONTROL_CHARACTERS
, static_cast<bool>(p1
)); }
115 virtual sal_Bool SAL_CALL
getIsSpellUpperCase() override
116 { return getPropertyBool(UPN_IS_SPELL_UPPER_CASE
); }
117 virtual void SAL_CALL
setIsSpellUpperCase(sal_Bool p1
) override
118 { setProperty(UPN_IS_SPELL_UPPER_CASE
, static_cast<bool>(p1
)); }
119 virtual sal_Bool SAL_CALL
getIsSpellWithDigits() override
120 { return getPropertyBool(UPN_IS_SPELL_WITH_DIGITS
); }
121 virtual void SAL_CALL
setIsSpellWithDigits(sal_Bool p1
) override
122 { setProperty(UPN_IS_SPELL_WITH_DIGITS
, static_cast<bool>(p1
)); }
123 virtual sal_Bool SAL_CALL
getIsSpellCapitalization() override
124 { return getPropertyBool(UPN_IS_SPELL_CAPITALIZATION
); }
125 virtual void SAL_CALL
setIsSpellCapitalization(sal_Bool p1
) override
126 { setProperty(UPN_IS_SPELL_CAPITALIZATION
, static_cast<bool>(p1
)); }
127 virtual sal_Int16 SAL_CALL
getHyphMinLeading() override
128 { return getPropertyInt16(UPN_HYPH_MIN_LEADING
); }
129 virtual void SAL_CALL
setHyphMinLeading(sal_Int16 p1
) override
130 { setProperty(UPN_HYPH_MIN_LEADING
, p1
); }
131 virtual sal_Int16 SAL_CALL
getHyphMinTrailing() override
132 { return getPropertyInt16(UPN_HYPH_MIN_TRAILING
); }
133 virtual void SAL_CALL
setHyphMinTrailing(sal_Int16 p1
) override
134 { setProperty(UPN_HYPH_MIN_TRAILING
, p1
); }
135 virtual sal_Int16 SAL_CALL
getHyphMinWordLength() override
136 { return getPropertyInt16(UPN_HYPH_MIN_WORD_LENGTH
); }
137 virtual void SAL_CALL
setHyphMinWordLength(sal_Int16 p1
) override
138 { setProperty(UPN_HYPH_MIN_WORD_LENGTH
, p1
); }
139 virtual css::lang::Locale SAL_CALL
getDefaultLocale() override
140 { return getPropertyLocale(UPN_DEFAULT_LOCALE
); }
141 virtual void SAL_CALL
setDefaultLocale(const css::lang::Locale
& p1
) override
142 { setProperty(UPN_DEFAULT_LOCALE
, p1
); }
143 virtual sal_Bool SAL_CALL
getIsHyphAuto() override
144 { return getPropertyBool(UPN_IS_HYPH_AUTO
); }
145 virtual void SAL_CALL
setIsHyphAuto(sal_Bool p1
) override
146 { setProperty(UPN_IS_HYPH_AUTO
, static_cast<bool>(p1
)); }
147 virtual sal_Bool SAL_CALL
getIsHyphSpecial() override
148 { return getPropertyBool(UPN_IS_HYPH_SPECIAL
); }
149 virtual void SAL_CALL
setIsHyphSpecial(sal_Bool p1
) override
150 { setProperty(UPN_IS_HYPH_SPECIAL
, static_cast<bool>(p1
)); }
151 virtual sal_Bool SAL_CALL
getIsSpellAuto() override
152 { return getPropertyBool(UPN_IS_SPELL_AUTO
); }
153 virtual void SAL_CALL
setIsSpellAuto(sal_Bool p1
) override
154 { setProperty(UPN_IS_SPELL_AUTO
, static_cast<bool>(p1
)); }
155 virtual sal_Bool SAL_CALL
getIsSpellSpecial() override
156 { return getPropertyBool(UPN_IS_SPELL_SPECIAL
); }
157 virtual void SAL_CALL
setIsSpellSpecial(sal_Bool p1
) override
158 { setProperty(UPN_IS_SPELL_SPECIAL
, static_cast<bool>(p1
)); }
159 virtual sal_Bool SAL_CALL
getIsWrapReverse() override
160 { return getPropertyBool(UPN_IS_WRAP_REVERSE
); }
161 virtual void SAL_CALL
setIsWrapReverse(sal_Bool p1
) override
162 { setProperty(UPN_IS_WRAP_REVERSE
, static_cast<bool>(p1
)); }
163 virtual css::lang::Locale SAL_CALL
getDefaultLocale_CJK() override
164 { return getPropertyLocale(UPN_DEFAULT_LOCALE_CJK
); }
165 virtual void SAL_CALL
setDefaultLocale_CJK(const css::lang::Locale
& p1
) override
166 { setProperty(UPN_DEFAULT_LOCALE_CJK
, p1
); }
167 virtual css::lang::Locale SAL_CALL
getDefaultLocale_CTL() override
168 { return getPropertyLocale(UPN_DEFAULT_LOCALE_CTL
); }
169 virtual void SAL_CALL
setDefaultLocale_CTL(const css::lang::Locale
& p1
) override
170 { setProperty(UPN_DEFAULT_LOCALE_CTL
, p1
); }
173 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() override
;
174 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
175 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
176 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& rxListener
) override
;
177 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& rxListener
) override
;
178 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& rxListener
) override
;
179 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& rxListener
) override
;
182 virtual void SAL_CALL
setFastPropertyValue( sal_Int32 nHandle
, const css::uno::Any
& aValue
) override
;
183 virtual css::uno::Any SAL_CALL
getFastPropertyValue( sal_Int32 nHandle
) override
;
186 virtual css::uno::Sequence
< css::beans::PropertyValue
> SAL_CALL
getPropertyValues() override
;
187 virtual void SAL_CALL
setPropertyValues( const css::uno::Sequence
< css::beans::PropertyValue
>& aProps
) override
;
190 virtual void SAL_CALL
dispose() override
;
191 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& rxListener
) override
;
192 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& rxListener
) override
;
195 virtual OUString SAL_CALL
getImplementationName() override
;
196 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
197 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
200 static inline OUString
getImplementationName_Static() throw();
201 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static() throw();
204 inline OUString
LinguProps::getImplementationName_Static() throw()
206 return "com.sun.star.lingu2.LinguProps";
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */