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
36class SvtLinguConfigItem;
37
38struct UNOTOOLS_DLLPUBLIC SvtLinguOptions
39{
40 ::com::sun::star::uno::Sequence< OUString > aActiveDics;
41 ::com::sun::star::uno::Sequence< OUString > aActiveConvDics;
42
43 sal_Bool bROActiveDics;
44 sal_Bool bROActiveConvDics;
45
46 // Hyphenator service specific options
47 sal_Int16 nHyphMinLeading,
48 nHyphMinTrailing,
49 nHyphMinWordLength;
50
51 sal_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 sal_Bool bRODefaultLanguage;
61 sal_Bool bRODefaultLanguage_CJK;
62 sal_Bool bRODefaultLanguage_CTL;
63
64 // spelling options (non-service specific)
65 sal_Bool bIsSpellSpecial;
66 sal_Bool bIsSpellAuto;
67 sal_Bool bIsSpellReverse;
68
69 sal_Bool bROIsSpellSpecial;
70 sal_Bool bROIsSpellAuto;
71 sal_Bool bROIsSpellReverse;
72
73 // hyphenation options (non-service specific)
74 sal_Bool bIsHyphSpecial;
75 sal_Bool bIsHyphAuto;
76
77 sal_Bool bROIsHyphSpecial;
78 sal_Bool bROIsHyphAuto;
79
80 // common to SpellChecker, Hyphenator and Thesaurus service
81 sal_Bool bIsUseDictionaryList;
82 sal_Bool bIsIgnoreControlCharacters;
83
84 sal_Bool bROIsUseDictionaryList;
85 sal_Bool bROIsIgnoreControlCharacters;
86
87 // SpellChecker service specific options
88 sal_Bool bIsSpellWithDigits,
89 bIsSpellUpperCase,
90 bIsSpellCapitalization;
91
92 sal_Bool bROIsSpellWithDigits,
93 bROIsSpellUpperCase,
94 bROIsSpellCapitalization;
95
96 // text conversion specific options
97 sal_Bool bIsIgnorePostPositionalWord;
98 sal_Bool bIsAutoCloseDialog;
99 sal_Bool bIsShowEntriesRecentlyUsedFirst;
100 sal_Bool bIsAutoReplaceUniqueEntries;
101 sal_Bool bIsDirectionToSimplified;
102 sal_Bool bIsUseCharacterVariants;
103 sal_Bool bIsTranslateCommonTerms;
104 sal_Bool bIsReverseMapping;
105
106 sal_Bool bROIsIgnorePostPositionalWord;
107 sal_Bool bROIsAutoCloseDialog;
108 sal_Bool bROIsShowEntriesRecentlyUsedFirst;
109 sal_Bool bROIsAutoReplaceUniqueEntries;
110 sal_Bool bROIsDirectionToSimplified;
111 sal_Bool bROIsUseCharacterVariants;
112 sal_Bool bROIsTranslateCommonTerms;
113 sal_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 sal_Bool bRODataFilesChangedCheckValue;
120
121 sal_Bool bIsGrammarAuto;
122 sal_Bool bIsGrammarInteractive;
123
124 sal_Bool bROIsGrammarAuto;
125 sal_Bool bROIsGrammarInteractive;
126
127 SvtLinguOptions();
128};
129
130struct 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
140class UNOTOOLS_DLLPUBLIC SvtLinguConfig: public utl::detail::Options
141{
142 // returns static object
143 UNOTOOLS_DLLPRIVATE SvtLinguConfigItem & GetConfigItem();
144
145 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
161public:
162 SvtLinguConfig();
163 virtual ~SvtLinguConfig();
164
165 //
166 // borrowed from utl::ConfigItem
167 //
168 com::sun::star::uno::Sequence< OUString >
169 GetNodeNames( const OUString &rNode );
170 //
171 com::sun::star::uno::Sequence< com::sun::star::uno::Any >
172 GetProperties(
173 const com::sun::star::uno::Sequence< OUString > &rNames );
174 //
175 sal_Bool
176 ReplaceSetProperties(
177 const OUString &rNode,
178 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > rValues );
179
180 com::sun::star::uno::Any
181 GetProperty( const OUString &rPropertyName ) const;
182 com::sun::star::uno::Any
183 GetProperty( sal_Int32 nPropertyHandle ) const;
184
185 sal_Bool SetProperty( const OUString &rPropertyName,
186 const com::sun::star::uno::Any &rValue );
187 sal_Bool SetProperty( sal_Int32 nPropertyHandle,
188 const com::sun::star::uno::Any &rValue );
189
190 sal_Bool GetOptions( SvtLinguOptions &rOptions ) const;
191
192 sal_Bool IsReadOnly( const OUString &rPropertyName ) const;
193
194 //!
195 //! the following functions work on the 'ServiceManager' sub node of the
196 //! linguistic configuration only
197 //!
198 sal_Bool GetElementNamesFor( const OUString &rNodeName, com::sun::star::uno::Sequence< OUString > &rElementNames ) const;
199 //
200 sal_Bool GetSupportedDictionaryFormatsFor( const OUString &rSetName, const OUString &rSetEntry, com::sun::star::uno::Sequence< OUString > &rFormatList ) const;
201
202 sal_Bool GetDictionaryEntry( const OUString &rNodeName, SvtLinguConfigDictionaryEntry &rDicEntry ) const;
203
204 com::sun::star::uno::Sequence< OUString > GetDisabledDictionaries() const;
205
206 std::vector< SvtLinguConfigDictionaryEntry > GetActiveDictionariesByFormat( const OUString &rFormatName );
207
208 // functions returning file URLs to the respective images (if found) and empty string otherwise
209 OUString GetSpellAndGrammarContextSuggestionImage( const OUString &rServiceImplName ) const;
210 OUString GetSpellAndGrammarContextDictionaryImage( const OUString &rServiceImplName ) const;
211 OUString GetSynonymsContextImage( const OUString &rServiceImplName ) const;
212
213 bool HasGrammarChecker() const;
214};
215
216#endif
217
218/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
219