Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_LINGUISTIC_SOURCE_LNGOPT_HXX
21 : #define INCLUDED_LINGUISTIC_SOURCE_LNGOPT_HXX
22 :
23 : #include <cppuhelper/implbase5.hxx>
24 : #include <cppuhelper/interfacecontainer.hxx>
25 : #include <com/sun/star/beans/XPropertySet.hpp>
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/configitem.hxx>
34 : #include <unotools/linguprops.hxx>
35 : #include <com/sun/star/uno/Any.h>
36 : #include "linguistic/misc.hxx"
37 : #include "defs.hxx"
38 :
39 : namespace com { namespace sun { namespace star {
40 : namespace beans {
41 : struct PropertyChangeEvent;
42 : }
43 : }}}
44 :
45 :
46 :
47 : // LinguOptions
48 : // This class represents all Linguistik relevant options.
49 :
50 : class LinguOptions
51 : {
52 : static SvtLinguOptions *pData;
53 : static oslInterlockedCount nRefCount; // number of objects of this class
54 :
55 : public:
56 : LinguOptions();
57 : LinguOptions(const LinguOptions &rOpt);
58 : ~LinguOptions();
59 :
60 : static OUString GetName( sal_Int32 nWID );
61 :
62 : const ::com::sun::star::uno::Sequence< OUString >
63 30 : GetActiveDics() const { return pData->aActiveDics; }
64 :
65 : const ::com::sun::star::uno::Sequence< OUString >
66 : GetActiveConvDics() const { return pData->aActiveConvDics; }
67 : };
68 :
69 : typedef cppu::OMultiTypeInterfaceContainerHelperVar<sal_Int32>
70 : OPropertyListenerContainerHelper;
71 :
72 100 : class LinguProps :
73 : public cppu::WeakImplHelper5
74 : <
75 : com::sun::star::linguistic2::XLinguProperties,
76 : com::sun::star::beans::XFastPropertySet,
77 : com::sun::star::beans::XPropertyAccess,
78 : com::sun::star::lang::XComponent,
79 : com::sun::star::lang::XServiceInfo
80 : >
81 : {
82 : ::cppu::OInterfaceContainerHelper aEvtListeners;
83 : OPropertyListenerContainerHelper aPropListeners;
84 :
85 : SfxItemPropertyMap aPropertyMap;
86 : SvtLinguConfig aConfig;
87 :
88 : bool bDisposing;
89 :
90 : LinguProps(const LinguProps &) SAL_DELETED_FUNCTION;
91 : LinguProps & operator = (const LinguProps &) SAL_DELETED_FUNCTION;
92 :
93 : void launchEvent( const ::com::sun::star::beans::PropertyChangeEvent &rEvt ) const;
94 :
95 : bool getPropertyBool(const OUString& aPropertyName) throw (css::uno::RuntimeException);
96 : sal_Int16 getPropertyInt16(const OUString& aPropertyName) throw (css::uno::RuntimeException);
97 : css::lang::Locale getPropertyLocale(const OUString& aPropertyName) throw (css::uno::RuntimeException);
98 0 : void setProperty(const OUString& aPropertyName, bool p1) throw (css::uno::RuntimeException)
99 0 : { setPropertyValue( aPropertyName, css::uno::Any(p1) ); }
100 0 : void setProperty(const OUString& aPropertyName, sal_Int16 p1) throw (css::uno::RuntimeException)
101 0 : { setPropertyValue( aPropertyName, css::uno::Any(p1) ); }
102 0 : void setProperty(const OUString& aPropertyName, css::lang::Locale p1) throw (css::uno::RuntimeException)
103 0 : { setPropertyValue( aPropertyName, css::uno::Any(p1) ); }
104 :
105 : public:
106 : LinguProps();
107 :
108 0 : virtual sal_Bool SAL_CALL getIsUseDictionaryList() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
109 0 : { return getPropertyBool(UPN_IS_USE_DICTIONARY_LIST); }
110 0 : virtual void SAL_CALL setIsUseDictionaryList(sal_Bool p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
111 0 : { setProperty(UPN_IS_USE_DICTIONARY_LIST, (bool) p1); }
112 0 : virtual sal_Bool SAL_CALL getIsIgnoreControlCharacters() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
113 0 : { return getPropertyBool(UPN_IS_IGNORE_CONTROL_CHARACTERS); }
114 0 : virtual void SAL_CALL setIsIgnoreControlCharacters(sal_Bool p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
115 0 : { setProperty(UPN_IS_IGNORE_CONTROL_CHARACTERS, (bool) p1); }
116 0 : virtual sal_Bool SAL_CALL getIsSpellUpperCase() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
117 0 : { return getPropertyBool(UPN_IS_SPELL_UPPER_CASE); }
118 0 : virtual void SAL_CALL setIsSpellUpperCase(sal_Bool p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
119 0 : { setProperty(UPN_IS_SPELL_UPPER_CASE, (bool) p1); }
120 0 : virtual sal_Bool SAL_CALL getIsSpellWithDigits() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
121 0 : { return getPropertyBool(UPN_IS_SPELL_WITH_DIGITS); }
122 0 : virtual void SAL_CALL setIsSpellWithDigits(sal_Bool p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
123 0 : { setProperty(UPN_IS_SPELL_WITH_DIGITS, (bool) p1); }
124 0 : virtual sal_Bool SAL_CALL getIsSpellCapitalization() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
125 0 : { return getPropertyBool(UPN_IS_SPELL_CAPITALIZATION); }
126 0 : virtual void SAL_CALL setIsSpellCapitalization(sal_Bool p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
127 0 : { setProperty(UPN_IS_SPELL_CAPITALIZATION, (bool) p1); }
128 0 : virtual sal_Int16 SAL_CALL getHyphMinLeading() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
129 0 : { return getPropertyInt16(UPN_HYPH_MIN_LEADING); }
130 0 : virtual void SAL_CALL setHyphMinLeading(sal_Int16 p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
131 0 : { setProperty(UPN_HYPH_MIN_LEADING, p1); }
132 0 : virtual sal_Int16 SAL_CALL getHyphMinTrailing() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
133 0 : { return getPropertyInt16(UPN_HYPH_MIN_TRAILING); }
134 0 : virtual void SAL_CALL setHyphMinTrailing(sal_Int16 p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
135 0 : { setProperty(UPN_HYPH_MIN_TRAILING, p1); }
136 0 : virtual sal_Int16 SAL_CALL getHyphMinWordLength() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
137 0 : { return getPropertyInt16(UPN_HYPH_MIN_WORD_LENGTH); }
138 0 : virtual void SAL_CALL setHyphMinWordLength(sal_Int16 p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
139 0 : { setProperty(UPN_HYPH_MIN_WORD_LENGTH, p1); }
140 0 : virtual com::sun::star::lang::Locale SAL_CALL getDefaultLocale() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
141 0 : { return getPropertyLocale(UPN_DEFAULT_LOCALE); }
142 0 : virtual void SAL_CALL setDefaultLocale(const com::sun::star::lang::Locale& p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
143 0 : { setProperty(UPN_DEFAULT_LOCALE, p1); }
144 0 : virtual sal_Bool SAL_CALL getIsHyphAuto() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
145 0 : { return getPropertyBool(UPN_IS_HYPH_AUTO); }
146 0 : virtual void SAL_CALL setIsHyphAuto(sal_Bool p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
147 0 : { setProperty(UPN_IS_HYPH_AUTO, (bool) p1); }
148 0 : virtual sal_Bool SAL_CALL getIsHyphSpecial() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
149 0 : { return getPropertyBool(UPN_IS_HYPH_SPECIAL); }
150 0 : virtual void SAL_CALL setIsHyphSpecial(sal_Bool p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
151 0 : { setProperty(UPN_IS_HYPH_SPECIAL, (bool) p1); }
152 0 : virtual sal_Bool SAL_CALL getIsSpellAuto() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
153 0 : { return getPropertyBool(UPN_IS_SPELL_AUTO); }
154 0 : virtual void SAL_CALL setIsSpellAuto(sal_Bool p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
155 0 : { setProperty(UPN_IS_SPELL_AUTO, (bool) p1); }
156 84 : virtual sal_Bool SAL_CALL getIsSpellSpecial() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
157 84 : { return getPropertyBool(UPN_IS_SPELL_SPECIAL); }
158 0 : virtual void SAL_CALL setIsSpellSpecial(sal_Bool p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
159 0 : { setProperty(UPN_IS_SPELL_SPECIAL, (bool) p1); }
160 168 : virtual sal_Bool SAL_CALL getIsWrapReverse() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
161 168 : { return getPropertyBool(UPN_IS_WRAP_REVERSE); }
162 0 : virtual void SAL_CALL setIsWrapReverse(sal_Bool p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
163 0 : { setProperty(UPN_IS_WRAP_REVERSE, (bool) p1); }
164 0 : virtual com::sun::star::lang::Locale SAL_CALL getDefaultLocale_CJK() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
165 0 : { return getPropertyLocale(UPN_DEFAULT_LOCALE_CJK); }
166 0 : virtual void SAL_CALL setDefaultLocale_CJK(const com::sun::star::lang::Locale& p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
167 0 : { setProperty(UPN_DEFAULT_LOCALE_CJK, p1); }
168 0 : virtual css::lang::Locale SAL_CALL getDefaultLocale_CTL() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
169 0 : { return getPropertyLocale(UPN_DEFAULT_LOCALE_CTL); }
170 0 : virtual void SAL_CALL setDefaultLocale_CTL(const com::sun::star::lang::Locale& p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
171 0 : { setProperty(UPN_DEFAULT_LOCALE_CTL, p1); }
172 :
173 : // XPropertySet
174 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
175 : virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
176 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 : virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
178 : virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
179 : virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 : virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
181 :
182 : // XFastPropertySet
183 : virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
184 : virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
185 :
186 : // XPropertyAccess
187 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPropertyValues() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
188 : virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
189 :
190 : // XComponent
191 : virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
192 : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
193 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
194 :
195 : // XServiceInfo
196 : virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
197 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
198 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
199 :
200 :
201 : static inline OUString getImplementationName_Static() throw();
202 : static com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static() throw();
203 : };
204 :
205 171 : inline OUString LinguProps::getImplementationName_Static() throw()
206 : {
207 171 : return OUString( "com.sun.star.lingu2.LinguProps" );
208 : }
209 :
210 :
211 : #endif
212 :
213 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|