xref: /AOO41X/main/unotools/inc/unotools/lingucfg.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _unotools_LINGUCFG_HXX_
29 #define _unotools_LINGUCFG_HXX_
30 
31 #include "unotools/unotoolsdllapi.h"
32 #include <com/sun/star/beans/PropertyValues.hpp>
33 #include <com/sun/star/uno/Sequence.hxx>
34 #include <com/sun/star/uno/Any.h>
35 #include <com/sun/star/lang/Locale.hpp>
36 #include <com/sun/star/util/XChangesBatch.hpp>
37 #include <tools/solar.h>
38 #include <rtl/ustring.hxx>
39 #include <unotools/configitem.hxx>
40 #include <osl/mutex.hxx>
41 #include <unotools/options.hxx>
42 #include <i18npool/lang.h>
43 
44 #include <vector>
45 
46 class SvtLinguConfigItem;
47 
48 //////////////////////////////////////////////////////////////////////
49 
50 struct UNOTOOLS_DLLPUBLIC SvtLinguOptions
51 {
52 	::com::sun::star::uno::Sequence< rtl::OUString >	aActiveDics;
53     ::com::sun::star::uno::Sequence< rtl::OUString >    aActiveConvDics;
54 
55     sal_Bool                                                bROActiveDics;
56     sal_Bool                                                bROActiveConvDics;
57 
58 	// Hyphenator service specific options
59 	sal_Int16	nHyphMinLeading,
60 			nHyphMinTrailing,
61 			nHyphMinWordLength;
62 
63     sal_Bool    bROHyphMinLeading,
64             bROHyphMinTrailing,
65             bROHyphMinWordLength;
66 
67 	// misc options (non-service specific)
68 	sal_Int16	nDefaultLanguage;
69 	sal_Int16	nDefaultLanguage_CJK;
70 	sal_Int16	nDefaultLanguage_CTL;
71 
72     sal_Bool    bRODefaultLanguage;
73     sal_Bool    bRODefaultLanguage_CJK;
74     sal_Bool    bRODefaultLanguage_CTL;
75 
76 	// spelling options (non-service specific)
77 	sal_Bool	bIsSpellSpecial;
78 	sal_Bool	bIsSpellAuto;
79 	sal_Bool	bIsSpellReverse;
80 
81     sal_Bool    bROIsSpellSpecial;
82     sal_Bool    bROIsSpellAuto;
83     sal_Bool    bROIsSpellReverse;
84 
85 	// hyphenation options (non-service specific)
86 	sal_Bool	bIsHyphSpecial;
87 	sal_Bool	bIsHyphAuto;
88 
89     sal_Bool    bROIsHyphSpecial;
90     sal_Bool    bROIsHyphAuto;
91 
92 	// common to SpellChecker, Hyphenator and Thesaurus service
93 	sal_Bool	bIsUseDictionaryList;
94 	sal_Bool	bIsIgnoreControlCharacters;
95 
96     sal_Bool    bROIsUseDictionaryList;
97     sal_Bool    bROIsIgnoreControlCharacters;
98 
99 	// SpellChecker service specific options
100 	sal_Bool	bIsSpellWithDigits,
101 			bIsSpellUpperCase,
102 			bIsSpellCapitalization;
103 
104     sal_Bool    bROIsSpellWithDigits,
105             bROIsSpellUpperCase,
106             bROIsSpellCapitalization;
107 
108     // text conversion specific options
109     sal_Bool    bIsIgnorePostPositionalWord;
110     sal_Bool    bIsAutoCloseDialog;
111     sal_Bool    bIsShowEntriesRecentlyUsedFirst;
112     sal_Bool    bIsAutoReplaceUniqueEntries;
113     sal_Bool    bIsDirectionToSimplified;
114     sal_Bool    bIsUseCharacterVariants;
115     sal_Bool    bIsTranslateCommonTerms;
116     sal_Bool    bIsReverseMapping;
117 
118     sal_Bool    bROIsIgnorePostPositionalWord;
119     sal_Bool    bROIsAutoCloseDialog;
120     sal_Bool    bROIsShowEntriesRecentlyUsedFirst;
121     sal_Bool    bROIsAutoReplaceUniqueEntries;
122     sal_Bool    bROIsDirectionToSimplified;
123     sal_Bool    bROIsUseCharacterVariants;
124     sal_Bool    bROIsTranslateCommonTerms;
125     sal_Bool    bROIsReverseMapping;
126 
127     // check value need to determine if the configuration needs to updatet
128     // or not (used for a quick check if data files have been changed/added
129     // or deleted
130     sal_Int32   nDataFilesChangedCheckValue;
131     sal_Bool    bRODataFilesChangedCheckValue;
132 
133     sal_Bool    bIsGrammarAuto;
134     sal_Bool    bIsGrammarInteractive;
135 
136     sal_Bool    bROIsGrammarAuto;
137     sal_Bool    bROIsGrammarInteractive;
138 
139 	SvtLinguOptions();
140 };
141 
142 //////////////////////////////////////////////////////////////////////
143 
144 struct UNOTOOLS_DLLPUBLIC SvtLinguConfigDictionaryEntry
145 {
146 	// the URL's pointing to the location of the files the dictionary consists of
147     com::sun::star::uno::Sequence< rtl::OUString >	aLocations;
148     // the name of the dictionary format implement
149 	rtl::OUString									aFormatName;
150     // the list of languages (ISO names) the dictionary can be used for
151 	com::sun::star::uno::Sequence< rtl::OUString >	aLocaleNames;
152 };
153 
154 //////////////////////////////////////////////////////////////////////
155 
156 class UNOTOOLS_DLLPUBLIC SvtLinguConfig: public utl::detail::Options
157 {
158     // returns static object
159     UNOTOOLS_DLLPRIVATE SvtLinguConfigItem &   GetConfigItem();
160 
161     SvtLinguConfigItem &   GetConfigItem() const    { return const_cast< SvtLinguConfig * >( this )->GetConfigItem(); }
162 
163     // configuration update access for the 'Linguistic' main node
164     mutable com::sun::star::uno::Reference< com::sun::star::util::XChangesBatch > m_xMainUpdateAccess;
165 
166     com::sun::star::uno::Reference< com::sun::star::util::XChangesBatch > GetMainUpdateAccess() const;
167 
168     com::sun::star::uno::Sequence< rtl::OUString > GetCurrentOrLastActiveDicts_Impl( const rtl::OUString &rPropName ) const;
169     void SetCurrentOrLastActiveDicts_Impl( const rtl::OUString &rPropName, const com::sun::star::uno::Sequence< rtl::OUString > &rDictionaries ) const;
170 
171     rtl::OUString GetVendorImageUrl_Impl( const rtl::OUString &rServiceImplName, const rtl::OUString &rImageName ) const;
172 
173     // disallow copy-constructor and assignment-operator for now
174     SvtLinguConfig( const SvtLinguConfig & );
175     SvtLinguConfig & operator = ( const SvtLinguConfig & );
176 
177 public:
178     SvtLinguConfig();
179     virtual ~SvtLinguConfig();
180 
181     //
182     // borrowed from utl::ConfigItem
183     //
184     com::sun::star::uno::Sequence< rtl::OUString >
185         GetNodeNames( const rtl::OUString &rNode );
186     //
187     com::sun::star::uno::Sequence< com::sun::star::uno::Any >
188         GetProperties(
189             const com::sun::star::uno::Sequence< rtl::OUString > &rNames );
190     //
191     sal_Bool
192         ReplaceSetProperties(
193             const rtl::OUString &rNode,
194             com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > rValues );
195 
196 	com::sun::star::uno::Any
197             GetProperty( const rtl::OUString &rPropertyName ) const;
198     com::sun::star::uno::Any
199             GetProperty( sal_Int32 nPropertyHandle ) const;
200 
201 	sal_Bool    SetProperty( const rtl::OUString &rPropertyName,
202                          const com::sun::star::uno::Any &rValue );
203     sal_Bool    SetProperty( sal_Int32 nPropertyHandle,
204                          const com::sun::star::uno::Any &rValue );
205 
206     sal_Bool    GetOptions( SvtLinguOptions &rOptions ) const;
207     sal_Bool    SetOptions( const SvtLinguOptions &rOptions );
208 
209     sal_Bool    IsReadOnly( const rtl::OUString &rPropertyName ) const;
210     sal_Bool    IsReadOnly( sal_Int32 nPropertyHandle ) const;
211 
212     //!
213     //! the following functions work on the 'ServiceManager' sub node of the
214     //! linguistic configuration only
215     //!
216     sal_Bool GetElementNamesFor( const rtl::OUString &rNodeName, com::sun::star::uno::Sequence< rtl::OUString > &rElementNames ) const;
217     //
218     sal_Bool GetSupportedDictionaryFormatsFor( const rtl::OUString &rSetName, const rtl::OUString &rSetEntry, com::sun::star::uno::Sequence< rtl::OUString > &rFormatList ) const;
219     void SetOrCreateSupportedDictionaryFormatsFor( const rtl::OUString &rSetName, const rtl::OUString &rSetEntry, const com::sun::star::uno::Sequence< rtl::OUString > &rFormatList  ) const;
220     //
221     sal_Bool GetDictionaryEntry( const rtl::OUString &rNodeName, SvtLinguConfigDictionaryEntry &rDicEntry ) const;
222     void SetOrCreateDictionaryEntry( const rtl::OUString &rNodeName, const SvtLinguConfigDictionaryEntry &rDicEntry ) const;
223     //
224     com::sun::star::uno::Sequence< rtl::OUString > GetDisabledDictionaries() const;
225     void SetDisabledDictionaries( const com::sun::star::uno::Sequence< rtl::OUString > &rDictionaries ) const;
226 	//
227     std::vector< SvtLinguConfigDictionaryEntry > GetActiveDictionariesByFormat( const rtl::OUString &rFormatName );
228 
229     // functions returning file URLs to the respective images (if found) and empty string otherwise
230     ::rtl::OUString     GetSpellAndGrammarDialogImage( const ::rtl::OUString &rServiceImplName, bool bHighContrast = false ) const;
231     ::rtl::OUString     GetSpellAndGrammarContextSuggestionImage( const ::rtl::OUString &rServiceImplName, bool bHighContrast = false ) const;
232     ::rtl::OUString     GetSpellAndGrammarContextDictionaryImage( const ::rtl::OUString &rServiceImplName, bool bHighContrast = false ) const;
233     ::rtl::OUString     GetThesaurusDialogImage( const ::rtl::OUString &rServiceImplName, bool bHighContrast = false ) const;
234     ::rtl::OUString     GetSynonymsContextImage( const ::rtl::OUString &rServiceImplName, bool bHighContrast = false ) const;
235 
236     bool                HasVendorImages( const char *pImageName ) const;
237     bool                HasGrammarChecker() const;
238 };
239 
240 //////////////////////////////////////////////////////////////////////
241 
242 #endif
243 
244