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_UNOTOOLS_LINGUCFG_HXX
21 : #define INCLUDED_UNOTOOLS_LINGUCFG_HXX
22 :
23 : #include <unotools/unotoolsdllapi.h>
24 : #include <com/sun/star/beans/PropertyValues.hpp>
25 : #include <com/sun/star/uno/Sequence.hxx>
26 : #include <com/sun/star/uno/Any.h>
27 : #include <com/sun/star/lang/Locale.hpp>
28 : #include <com/sun/star/util/XChangesBatch.hpp>
29 : #include <rtl/ustring.hxx>
30 : #include <unotools/configitem.hxx>
31 : #include <osl/mutex.hxx>
32 : #include <unotools/options.hxx>
33 : #include <i18nlangtag/lang.h>
34 : #include <vector>
35 :
36 : class SvtLinguConfigItem;
37 :
38 0 : struct UNOTOOLS_DLLPUBLIC SvtLinguOptions
39 : {
40 : ::com::sun::star::uno::Sequence< OUString > aActiveDics;
41 : ::com::sun::star::uno::Sequence< OUString > aActiveConvDics;
42 :
43 : bool bROActiveDics;
44 : bool bROActiveConvDics;
45 :
46 : // Hyphenator service specific options
47 : sal_Int16 nHyphMinLeading,
48 : nHyphMinTrailing,
49 : nHyphMinWordLength;
50 :
51 : bool bROHyphMinLeading,
52 : bROHyphMinTrailing,
53 : bROHyphMinWordLength;
54 :
55 : // misc options (non-service specific)
56 : sal_Int16 nDefaultLanguage;
57 : sal_Int16 nDefaultLanguage_CJK;
58 : sal_Int16 nDefaultLanguage_CTL;
59 :
60 : bool bRODefaultLanguage;
61 : bool bRODefaultLanguage_CJK;
62 : bool bRODefaultLanguage_CTL;
63 :
64 : // spelling options (non-service specific)
65 : bool bIsSpellSpecial;
66 : bool bIsSpellAuto;
67 : bool bIsSpellReverse;
68 :
69 : bool bROIsSpellSpecial;
70 : bool bROIsSpellAuto;
71 : bool bROIsSpellReverse;
72 :
73 : // hyphenation options (non-service specific)
74 : bool bIsHyphSpecial;
75 : bool bIsHyphAuto;
76 :
77 : bool bROIsHyphSpecial;
78 : bool bROIsHyphAuto;
79 :
80 : // common to SpellChecker, Hyphenator and Thesaurus service
81 : bool bIsUseDictionaryList;
82 : bool bIsIgnoreControlCharacters;
83 :
84 : bool bROIsUseDictionaryList;
85 : bool bROIsIgnoreControlCharacters;
86 :
87 : // SpellChecker service specific options
88 : bool bIsSpellWithDigits,
89 : bIsSpellUpperCase,
90 : bIsSpellCapitalization;
91 :
92 : bool bROIsSpellWithDigits,
93 : bROIsSpellUpperCase,
94 : bROIsSpellCapitalization;
95 :
96 : // text conversion specific options
97 : bool bIsIgnorePostPositionalWord;
98 : bool bIsAutoCloseDialog;
99 : bool bIsShowEntriesRecentlyUsedFirst;
100 : bool bIsAutoReplaceUniqueEntries;
101 : bool bIsDirectionToSimplified;
102 : bool bIsUseCharacterVariants;
103 : bool bIsTranslateCommonTerms;
104 : bool bIsReverseMapping;
105 :
106 : bool bROIsIgnorePostPositionalWord;
107 : bool bROIsAutoCloseDialog;
108 : bool bROIsShowEntriesRecentlyUsedFirst;
109 : bool bROIsAutoReplaceUniqueEntries;
110 : bool bROIsDirectionToSimplified;
111 : bool bROIsUseCharacterVariants;
112 : bool bROIsTranslateCommonTerms;
113 : bool bROIsReverseMapping;
114 :
115 : // check value need to determine if the configuration needs to updatet
116 : // or not (used for a quick check if data files have been changed/added
117 : // or deleted
118 : sal_Int32 nDataFilesChangedCheckValue;
119 : bool bRODataFilesChangedCheckValue;
120 :
121 : bool bIsGrammarAuto;
122 : bool bIsGrammarInteractive;
123 :
124 : bool bROIsGrammarAuto;
125 : bool bROIsGrammarInteractive;
126 :
127 : SvtLinguOptions();
128 : };
129 :
130 0 : struct UNOTOOLS_DLLPUBLIC SvtLinguConfigDictionaryEntry
131 : {
132 : // the URL's pointing to the location of the files the dictionary consists of
133 : com::sun::star::uno::Sequence< OUString > aLocations;
134 : // the name of the dictionary format implement
135 : OUString aFormatName;
136 : // the list of languages (ISO names) the dictionary can be used for
137 : com::sun::star::uno::Sequence< OUString > aLocaleNames;
138 : };
139 :
140 : class UNOTOOLS_DLLPUBLIC SvtLinguConfig: public utl::detail::Options
141 : {
142 : // returns static object
143 : UNOTOOLS_DLLPRIVATE SvtLinguConfigItem & GetConfigItem();
144 :
145 0 : SvtLinguConfigItem & GetConfigItem() const { return const_cast< SvtLinguConfig * >( this )->GetConfigItem(); }
146 :
147 : // configuration update access for the 'Linguistic' main node
148 : mutable com::sun::star::uno::Reference< com::sun::star::util::XChangesBatch > m_xMainUpdateAccess;
149 :
150 : com::sun::star::uno::Reference< com::sun::star::util::XChangesBatch > GetMainUpdateAccess() const;
151 :
152 : com::sun::star::uno::Sequence< OUString > GetCurrentOrLastActiveDicts_Impl( const OUString &rPropName ) const;
153 : void SetCurrentOrLastActiveDicts_Impl( const OUString &rPropName, const com::sun::star::uno::Sequence< OUString > &rDictionaries ) const;
154 :
155 : OUString GetVendorImageUrl_Impl( const OUString &rServiceImplName, const OUString &rImageName ) const;
156 :
157 : // disallow copy-constructor and assignment-operator for now
158 : SvtLinguConfig( const SvtLinguConfig & );
159 : SvtLinguConfig & operator = ( const SvtLinguConfig & );
160 :
161 : public:
162 : SvtLinguConfig();
163 : virtual ~SvtLinguConfig();
164 :
165 : // borrowed from utl::ConfigItem
166 :
167 : com::sun::star::uno::Sequence< OUString >
168 : GetNodeNames( const OUString &rNode );
169 :
170 : com::sun::star::uno::Sequence< com::sun::star::uno::Any >
171 : GetProperties(
172 : const com::sun::star::uno::Sequence< OUString > &rNames );
173 :
174 : bool
175 : ReplaceSetProperties(
176 : const OUString &rNode,
177 : com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > rValues );
178 :
179 : com::sun::star::uno::Any
180 : GetProperty( const OUString &rPropertyName ) const;
181 : com::sun::star::uno::Any
182 : GetProperty( sal_Int32 nPropertyHandle ) const;
183 :
184 : bool SetProperty( const OUString &rPropertyName,
185 : const com::sun::star::uno::Any &rValue );
186 : bool SetProperty( sal_Int32 nPropertyHandle,
187 : const com::sun::star::uno::Any &rValue );
188 :
189 : bool GetOptions( SvtLinguOptions &rOptions ) const;
190 :
191 : bool IsReadOnly( const OUString &rPropertyName ) const;
192 :
193 : //!
194 : //! the following functions work on the 'ServiceManager' sub node of the
195 : //! linguistic configuration only
196 : //!
197 : bool GetElementNamesFor( const OUString &rNodeName, com::sun::star::uno::Sequence< OUString > &rElementNames ) const;
198 :
199 : bool GetSupportedDictionaryFormatsFor( const OUString &rSetName, const OUString &rSetEntry, com::sun::star::uno::Sequence< OUString > &rFormatList ) const;
200 :
201 : bool GetDictionaryEntry( const OUString &rNodeName, SvtLinguConfigDictionaryEntry &rDicEntry ) const;
202 :
203 : com::sun::star::uno::Sequence< OUString > GetDisabledDictionaries() const;
204 :
205 : std::vector< SvtLinguConfigDictionaryEntry > GetActiveDictionariesByFormat( const OUString &rFormatName );
206 :
207 : // functions returning file URLs to the respective images (if found) and empty string otherwise
208 : OUString GetSpellAndGrammarContextSuggestionImage( const OUString &rServiceImplName ) const;
209 : OUString GetSpellAndGrammarContextDictionaryImage( const OUString &rServiceImplName ) const;
210 : OUString GetSynonymsContextImage( const OUString &rServiceImplName ) const;
211 :
212 : bool HasGrammarChecker() const;
213 : };
214 :
215 : #endif
216 :
217 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|