xref: /AOO42X/main/editeng/inc/editeng/unolingu.hxx (revision 9bce9b0d387299c68bd81d539e1478357a103de5)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _UNO_LINGU_HXX
25 #define _UNO_LINGU_HXX
26 
27 #include <i18npool/lang.h>
28 #include <tools/string.hxx>
29 #include <vos/refernce.hxx>
30 #include <com/sun/star/util/Language.hpp>
31 #include <com/sun/star/lang/Locale.hpp>
32 #include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
33 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
34 #include <com/sun/star/linguistic2/XHyphenator.hpp>
35 #include <com/sun/star/linguistic2/XThesaurus.hpp>
36 #include <com/sun/star/linguistic2/XDictionaryList.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include "editeng/editengdllapi.h"
39 
40 class LinguMgrExitLstnr;
41 
42 class Window;
43 
44 ///////////////////////////////////////////////////////////////////////////
45 // SvxLinguConfigUpdate
46 // class to update configuration items when (before!) the linguistic is used.
47 //
48 // This class is called by all the dummy implementations to update all of the
49 // configuration (list of used/available services) when the linguistic is
50 // accessed for the first time.
51 
52 class SvxLinguConfigUpdate
53 {
54     static sal_Int32    nCurrentDataFilesChangedCheckValue;
55     static sal_Int16    nNeedUpdating;  // n == -1 => needs to be checked
56                                     // n ==  0 => already updated, nothing to be done
57                                     // n ==  1 => needs to be updated
58 
59     static sal_Int32 CalcDataFilesChangedCheckValue();
60 
61 public:
62 
63     EDITENG_DLLPUBLIC static void UpdateAll( sal_Bool bForceCheck = sal_False );
64     static sal_Bool IsNeedUpdateAll( sal_Bool bForceCheck = sal_False );
65 };
66 
67 ///////////////////////////////////////////////////////////////////////////
68 
69 class EDITENG_DLLPUBLIC LinguMgr
70 {
71     friend class LinguMgrExitLstnr;
72 
73     //static ::VOS::ORefCount aRefCount;
74 
75     static ::com::sun::star::uno::Reference<
76         ::com::sun::star::linguistic2::XLinguServiceManager > xLngSvcMgr;
77     static ::com::sun::star::uno::Reference<
78         ::com::sun::star::linguistic2::XSpellChecker1 > xSpell;
79     static ::com::sun::star::uno::Reference<
80         ::com::sun::star::linguistic2::XHyphenator >    xHyph;
81     static ::com::sun::star::uno::Reference<
82         ::com::sun::star::linguistic2::XThesaurus >     xThes;
83     static ::com::sun::star::uno::Reference<
84         ::com::sun::star::linguistic2::XDictionaryList > xDicList;
85     static ::com::sun::star::uno::Reference<
86         ::com::sun::star::beans::XPropertySet >         xProp;
87 
88     static ::com::sun::star::uno::Reference<
89         ::com::sun::star::linguistic2::XDictionary >    xIgnoreAll;
90     static ::com::sun::star::uno::Reference<
91         ::com::sun::star::linguistic2::XDictionary >    xChangeAll;
92 
93     static LinguMgrExitLstnr                           *pExitLstnr;
94     static sal_Bool                                     bExiting;
95 
96     static ::com::sun::star::uno::Reference<
97         ::com::sun::star::linguistic2::XSpellChecker1 > GetSpell();
98     static ::com::sun::star::uno::Reference<
99         ::com::sun::star::linguistic2::XHyphenator >    GetHyph();
100     static ::com::sun::star::uno::Reference<
101         ::com::sun::star::linguistic2::XThesaurus >     GetThes();
102     static ::com::sun::star::uno::Reference<
103         ::com::sun::star::linguistic2::XDictionaryList > GetDicList();
104     static ::com::sun::star::uno::Reference<
105         ::com::sun::star::beans::XPropertySet >         GetProp();
106     static ::com::sun::star::uno::Reference<
107         ::com::sun::star::linguistic2::XDictionary >    GetStandard();
108     static ::com::sun::star::uno::Reference<
109         ::com::sun::star::linguistic2::XDictionary >    GetIgnoreAll();
110     static ::com::sun::star::uno::Reference<
111         ::com::sun::star::linguistic2::XDictionary >    GetChangeAll();
112 
113     // disallow access to copy-constructor and assignment-operator
114     LinguMgr(const LinguMgr &);
115     LinguMgr & operator = (const LinguMgr &);
116 
117 public:
118 
119     static ::com::sun::star::uno::Reference<
120         ::com::sun::star::linguistic2::XSpellChecker1 > GetSpellChecker();
121     static ::com::sun::star::uno::Reference<
122         ::com::sun::star::linguistic2::XHyphenator >    GetHyphenator();
123     static ::com::sun::star::uno::Reference<
124         ::com::sun::star::linguistic2::XThesaurus >     GetThesaurus();
125     static ::com::sun::star::uno::Reference<
126         ::com::sun::star::linguistic2::XDictionaryList > GetDictionaryList();
127     static ::com::sun::star::uno::Reference<
128         ::com::sun::star::beans::XPropertySet >         GetLinguPropertySet();
129 
130     static ::com::sun::star::uno::Reference<
131         ::com::sun::star::linguistic2::XLinguServiceManager > GetLngSvcMgr();
132 
133     static ::com::sun::star::uno::Reference<
134         ::com::sun::star::linguistic2::XDictionary >    GetStandardDic();
135     static ::com::sun::star::uno::Reference<
136         ::com::sun::star::linguistic2::XDictionary >    GetIgnoreAllList();
137     static ::com::sun::star::uno::Reference<
138         ::com::sun::star::linguistic2::XDictionary >    GetChangeAllList();
139 
140     // update all configuration entries
141     static void UpdateAll();
142 };
143 
144 ///////////////////////////////////////////////////////////////////////////
145 
146 namespace com { namespace sun { namespace star { namespace linguistic2 {
147     class XHyphenatedWord;
148 }}}}
149 
150 
151 struct SvxAlternativeSpelling
152 {
153     String      aReplacement;
154     ::com::sun::star::uno::Reference<
155         ::com::sun::star::linguistic2::XHyphenatedWord >    xHyphWord;
156     sal_Int16       nChangedPos,
157                 nChangedLength;
158     sal_Bool        bIsAltSpelling;
159 
160     inline SvxAlternativeSpelling();
161 };
162 
SvxAlternativeSpelling()163 inline SvxAlternativeSpelling::SvxAlternativeSpelling() :
164     nChangedPos(-1), nChangedLength(-1), bIsAltSpelling(sal_False)
165 {
166 }
167 
168 
169 EDITENG_DLLPUBLIC SvxAlternativeSpelling SvxGetAltSpelling(
170         const ::com::sun::star::uno::Reference<
171             ::com::sun::star::linguistic2::XHyphenatedWord > & rHyphWord );
172 
173 
174 ///////////////////////////////////////////////////////////////////////////
175 
176 class EDITENG_DLLPUBLIC SvxDicListChgClamp
177 {
178 private:
179     ::com::sun::star::uno::Reference<
180         ::com::sun::star::linguistic2::XDictionaryList >    xDicList;
181 
182     // disallow access to copy-constructor and assignment-operator
183     EDITENG_DLLPRIVATE SvxDicListChgClamp(const SvxDicListChgClamp &);
184     EDITENG_DLLPRIVATE SvxDicListChgClamp & operator = (const SvxDicListChgClamp &);
185 
186 public:
187     SvxDicListChgClamp( ::com::sun::star::uno::Reference<
188         ::com::sun::star::linguistic2::XDictionaryList >  &rxDicList );
189     ~SvxDicListChgClamp();
190 };
191 
192 ///////////////////////////////////////////////////////////////////////////
193 
194 //TL:TODO: remove those functions or make them inline
195 EDITENG_DLLPUBLIC ::com::sun::star::uno::Reference<
196     ::com::sun::star::linguistic2::XSpellChecker1 > SvxGetSpellChecker();
197 EDITENG_DLLPUBLIC ::com::sun::star::uno::Reference<
198     ::com::sun::star::linguistic2::XHyphenator >    SvxGetHyphenator();
199 EDITENG_DLLPUBLIC ::com::sun::star::uno::Reference<
200     ::com::sun::star::linguistic2::XThesaurus >     SvxGetThesaurus();
201 EDITENG_DLLPUBLIC ::com::sun::star::uno::Reference<
202     ::com::sun::star::linguistic2::XDictionaryList > SvxGetDictionaryList();
203 EDITENG_DLLPUBLIC ::com::sun::star::uno::Reference<
204     ::com::sun::star::beans::XPropertySet >         SvxGetLinguPropertySet();
205 //TL:TODO: remove argument or provide SvxGetIgnoreAllList with the same one
206 EDITENG_DLLPUBLIC ::com::sun::star::uno::Reference<
207     ::com::sun::star::linguistic2::XDictionary >    SvxGetOrCreatePosDic(
208             ::com::sun::star::uno::Reference<
209                 ::com::sun::star::linguistic2::XDictionaryList >  xDicList );
210 EDITENG_DLLPUBLIC ::com::sun::star::uno::Reference<
211     ::com::sun::star::linguistic2::XDictionary >    SvxGetIgnoreAllList();
212 EDITENG_DLLPUBLIC ::com::sun::star::uno::Reference<
213     ::com::sun::star::linguistic2::XDictionary >    SvxGetChangeAllList();
214 
215 ///////////////////////////////////////////////////////////////////////////
216 // misc functions
217 //
218 
219 EDITENG_DLLPUBLIC LanguageType                      SvxLocaleToLanguage(
220         const ::com::sun::star::lang::Locale& rLocale );
221 EDITENG_DLLPUBLIC ::com::sun::star::lang::Locale&   SvxLanguageToLocale(
222         ::com::sun::star::lang::Locale& rLocale, LanguageType eLang );
223 EDITENG_DLLPUBLIC ::com::sun::star::lang::Locale    SvxCreateLocale( LanguageType eLang );
224 
225 
226 EDITENG_DLLPUBLIC short SvxDicError( Window *pParent, sal_Int16 nError );
227 
228 
229 #endif
230