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 93267 : 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 3010 : 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 197613337 : 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 : SvtLinguConfig( const SvtLinguConfig & ) SAL_DELETED_FUNCTION;
158 : SvtLinguConfig & operator = ( const SvtLinguConfig & ) SAL_DELETED_FUNCTION;
159 :
160 : public:
161 : SvtLinguConfig();
162 : virtual ~SvtLinguConfig();
163 :
164 : // borrowed from utl::ConfigItem
165 :
166 : com::sun::star::uno::Sequence< OUString >
167 : GetNodeNames( const OUString &rNode );
168 :
169 : com::sun::star::uno::Sequence< com::sun::star::uno::Any >
170 : GetProperties(
171 : const com::sun::star::uno::Sequence< OUString > &rNames );
172 :
173 : bool
174 : ReplaceSetProperties(
175 : const OUString &rNode,
176 : const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rValues );
177 :
178 : com::sun::star::uno::Any
179 : GetProperty( const OUString &rPropertyName ) const;
180 : com::sun::star::uno::Any
181 : GetProperty( sal_Int32 nPropertyHandle ) const;
182 :
183 : bool SetProperty( const OUString &rPropertyName,
184 : const com::sun::star::uno::Any &rValue );
185 : bool SetProperty( sal_Int32 nPropertyHandle,
186 : const com::sun::star::uno::Any &rValue );
187 :
188 : bool GetOptions( SvtLinguOptions &rOptions ) const;
189 :
190 : bool IsReadOnly( const OUString &rPropertyName ) const;
191 :
192 : //!
193 : //! the following functions work on the 'ServiceManager' sub node of the
194 : //! linguistic configuration only
195 : //!
196 : bool GetElementNamesFor( const OUString &rNodeName, com::sun::star::uno::Sequence< OUString > &rElementNames ) const;
197 :
198 : bool GetSupportedDictionaryFormatsFor( const OUString &rSetName, const OUString &rSetEntry, com::sun::star::uno::Sequence< OUString > &rFormatList ) const;
199 :
200 : bool GetDictionaryEntry( const OUString &rNodeName, SvtLinguConfigDictionaryEntry &rDicEntry ) const;
201 :
202 : com::sun::star::uno::Sequence< OUString > GetDisabledDictionaries() const;
203 :
204 : std::vector< SvtLinguConfigDictionaryEntry > GetActiveDictionariesByFormat( const OUString &rFormatName );
205 :
206 : // functions returning file URLs to the respective images (if found) and empty string otherwise
207 : OUString GetSpellAndGrammarContextSuggestionImage( const OUString &rServiceImplName ) const;
208 : OUString GetSpellAndGrammarContextDictionaryImage( const OUString &rServiceImplName ) const;
209 : OUString GetSynonymsContextImage( const OUString &rServiceImplName ) const;
210 :
211 : bool HasGrammarChecker() const;
212 : };
213 :
214 : #endif
215 :
216 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|