/[packages]/cauldron/libreoffice/releases/3.6.3.2/5.mga3/SOURCES/0001-Resolves-rhbz-836937-insanely-slow-with-Zemberek-ins.patch
ViewVC logotype

Contents of /cauldron/libreoffice/releases/3.6.3.2/5.mga3/SOURCES/0001-Resolves-rhbz-836937-insanely-slow-with-Zemberek-ins.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 389214 - (show annotations) (download)
Thu Jan 17 21:30:27 2013 UTC (11 years, 3 months ago) by pterjan
File size: 38563 byte(s)
oops
1 diff -ru libreoffice-3.5.5.3.orig/cui/source/options/optlingu.cxx libreoffice-3.5.5.3/cui/source/options/optlingu.cxx
2 --- libreoffice-3.5.5.3.orig/cui/source/options/optlingu.cxx 2012-07-13 12:37:15.032259144 +0100
3 +++ libreoffice-3.5.5.3/cui/source/options/optlingu.cxx 2012-07-16 08:49:26.294209540 +0100
4 @@ -1150,12 +1150,6 @@
5 aLinguDicsEditPB.SetAccessibleName(sAccessibleNameDicsEdit);
6 aLinguOptionsEditPB.SetAccessibleName(sAccessibleNameOptionEdit);
7
8 - // force recalculation of hash value used for checking the need of updating
9 - // because new dictionaries might be installed / downloaded.
10 - //! Thus it needs to be called now since it may infuence the supported languages
11 - //! to be reported AND the found user-dictionaries(!) as well.
12 - SvxLinguConfigUpdate::UpdateAll( sal_True );
13 -
14 xProp = uno::Reference< XPropertySet >( SvxGetLinguPropertySet(), UNO_QUERY );
15 xDicList = uno::Reference< XDictionaryList >( SvxGetDictionaryList(), UNO_QUERY );
16 if (xDicList.is())
17 diff -ru libreoffice-3.5.5.3.orig/editeng/inc/editeng/unolingu.hxx libreoffice-3.5.5.3/editeng/inc/editeng/unolingu.hxx
18 --- libreoffice-3.5.5.3.orig/editeng/inc/editeng/unolingu.hxx 2012-07-13 12:37:16.109269892 +0100
19 +++ libreoffice-3.5.5.3/editeng/inc/editeng/unolingu.hxx 2012-07-16 08:49:26.294209540 +0100
20 @@ -46,29 +46,6 @@
21 class Window;
22
23 ///////////////////////////////////////////////////////////////////////////
24 -// SvxLinguConfigUpdate
25 -// class to update configuration items when (before!) the linguistic is used.
26 -//
27 -// This class is called by all the dummy implementations to update all of the
28 -// configuration (list of used/available services) when the linguistic is
29 -// accessed for the first time.
30 -
31 -class SvxLinguConfigUpdate
32 -{
33 - static sal_Int32 nCurrentDataFilesChangedCheckValue;
34 - static sal_Int16 nNeedUpdating; // n == -1 => needs to be checked
35 - // n == 0 => already updated, nothing to be done
36 - // n == 1 => needs to be updated
37 -
38 - static sal_Int32 CalcDataFilesChangedCheckValue();
39 -
40 -public:
41 -
42 - EDITENG_DLLPUBLIC static void UpdateAll( sal_Bool bForceCheck = sal_False );
43 - static sal_Bool IsNeedUpdateAll( sal_Bool bForceCheck = sal_False );
44 -};
45 -
46 -///////////////////////////////////////////////////////////////////////////
47
48 class EDITENG_DLLPUBLIC LinguMgr
49 {
50 diff -ru libreoffice-3.5.5.3.orig/editeng/source/misc/unolingu.cxx libreoffice-3.5.5.3/editeng/source/misc/unolingu.cxx
51 --- libreoffice-3.5.5.3.orig/editeng/source/misc/unolingu.cxx 2012-07-13 12:37:15.900267806 +0100
52 +++ libreoffice-3.5.5.3/editeng/source/misc/unolingu.cxx 2012-07-16 08:52:53.919596778 +0100
53 @@ -90,365 +90,6 @@
54 return xRes;
55 }
56
57 -sal_Bool lcl_FindEntry( const OUString &rEntry, const Sequence< OUString > &rCfgSvcs )
58 -{
59 - sal_Int32 nRes = -1;
60 - sal_Int32 nEntries = rCfgSvcs.getLength();
61 - const OUString *pEntry = rCfgSvcs.getConstArray();
62 - for (sal_Int32 i = 0; i < nEntries && nRes == -1; ++i)
63 - {
64 - if (rEntry == pEntry[i])
65 - nRes = i;
66 - }
67 - return nRes != -1;
68 -}
69 -
70 -
71 -Sequence< OUString > lcl_RemoveMissingEntries(
72 - const Sequence< OUString > &rCfgSvcs,
73 - const Sequence< OUString > &rAvailSvcs )
74 -{
75 - Sequence< OUString > aRes( rCfgSvcs.getLength() );
76 - OUString *pRes = aRes.getArray();
77 - sal_Int32 nCnt = 0;
78 -
79 - sal_Int32 nEntries = rCfgSvcs.getLength();
80 - const OUString *pEntry = rCfgSvcs.getConstArray();
81 - for (sal_Int32 i = 0; i < nEntries; ++i)
82 - {
83 - if (!pEntry[i].isEmpty() && lcl_FindEntry( pEntry[i], rAvailSvcs ))
84 - pRes[ nCnt++ ] = pEntry[i];
85 - }
86 -
87 - aRes.realloc( nCnt );
88 - return aRes;
89 -}
90 -
91 -
92 -Sequence< OUString > lcl_GetLastFoundSvcs(
93 - SvtLinguConfig &rCfg,
94 - const OUString &rLastFoundList ,
95 - const Locale &rAvailLocale )
96 -{
97 - Sequence< OUString > aRes;
98 -
99 - OUString aCfgLocaleStr( MsLangId::convertLanguageToIsoString(
100 - SvxLocaleToLanguage( rAvailLocale ) ) );
101 -
102 - Sequence< OUString > aNodeNames( rCfg.GetNodeNames(rLastFoundList) );
103 - sal_Bool bFound = lcl_FindEntry( aCfgLocaleStr, aNodeNames);
104 -
105 - if (bFound)
106 - {
107 - Sequence< OUString > aNames(1);
108 - OUString &rNodeName = aNames.getArray()[0];
109 - rNodeName = rLastFoundList;
110 - rNodeName += OUString::valueOf( (sal_Unicode)'/' );
111 - rNodeName += aCfgLocaleStr;
112 - Sequence< Any > aValues( rCfg.GetProperties( aNames ) );
113 - if (aValues.getLength())
114 - {
115 - OSL_ENSURE( aValues.getLength() == 1, "unexpected length of sequence" );
116 - Sequence< OUString > aSvcImplNames;
117 - if (aValues.getConstArray()[0] >>= aSvcImplNames)
118 - aRes = aSvcImplNames;
119 - else
120 - {
121 - OSL_FAIL( "type mismatch" );
122 - }
123 - }
124 - }
125 -
126 - return aRes;
127 -}
128 -
129 -
130 -Sequence< OUString > lcl_GetNewEntries(
131 - const Sequence< OUString > &rLastFoundSvcs,
132 - const Sequence< OUString > &rAvailSvcs )
133 -{
134 - sal_Int32 nLen = rAvailSvcs.getLength();
135 - Sequence< OUString > aRes( nLen );
136 - OUString *pRes = aRes.getArray();
137 - sal_Int32 nCnt = 0;
138 -
139 - const OUString *pEntry = rAvailSvcs.getConstArray();
140 - for (sal_Int32 i = 0; i < nLen; ++i)
141 - {
142 - if (!pEntry[i].isEmpty() && !lcl_FindEntry( pEntry[i], rLastFoundSvcs ))
143 - pRes[ nCnt++ ] = pEntry[i];
144 - }
145 -
146 - aRes.realloc( nCnt );
147 - return aRes;
148 -}
149 -
150 -
151 -Sequence< OUString > lcl_MergeSeq(
152 - const Sequence< OUString > &rCfgSvcs,
153 - const Sequence< OUString > &rNewSvcs )
154 -{
155 - Sequence< OUString > aRes( rCfgSvcs.getLength() + rNewSvcs.getLength() );
156 - OUString *pRes = aRes.getArray();
157 - sal_Int32 nCnt = 0;
158 -
159 - for (sal_Int32 k = 0; k < 2; ++k)
160 - {
161 - // add previously configuerd service first and append
162 - // new found services at the end
163 - const Sequence< OUString > &rSeq = k == 0 ? rCfgSvcs : rNewSvcs;
164 -
165 - sal_Int32 nLen = rSeq.getLength();
166 - const OUString *pEntry = rSeq.getConstArray();
167 - for (sal_Int32 i = 0; i < nLen; ++i)
168 - {
169 - if (!pEntry[i].isEmpty() && !lcl_FindEntry( pEntry[i], aRes ))
170 - pRes[ nCnt++ ] = pEntry[i];
171 - }
172 - }
173 -
174 - aRes.realloc( nCnt );
175 - return aRes;
176 -}
177 -
178 -sal_Int16 SvxLinguConfigUpdate::nNeedUpdating = -1;
179 -sal_Int32 SvxLinguConfigUpdate::nCurrentDataFilesChangedCheckValue = -1;
180 -
181 -void SvxLinguConfigUpdate::UpdateAll( sal_Bool bForceCheck )
182 -{
183 - RTL_LOGFILE_CONTEXT( aLog, "svx: SvxLinguConfigUpdate::UpdateAll" );
184 -
185 - if (IsNeedUpdateAll( bForceCheck ))
186 - {
187 - typedef OUString OUstring_t;
188 - typedef Sequence< OUString > Sequence_OUString_t;
189 - typedef std::map< OUstring_t, Sequence_OUString_t > list_entry_map_t;
190 -
191 - RTL_LOGFILE_CONTEXT( aLog, "svx: SvxLinguConfigUpdate::UpdateAll - updating..." );
192 -
193 - OSL_ENSURE( nNeedUpdating == 1, "SvxLinguConfigUpdate::UpdateAll already updated!" );
194 -
195 - uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() );
196 - OSL_ENSURE( xLngSvcMgr.is(), "service manager missing");
197 - if (!xLngSvcMgr.is())
198 - return;
199 -
200 - SvtLinguConfig aCfg;
201 -
202 - const int nNumServices = 4;
203 - const sal_Char * apServices[nNumServices] = { SN_SPELLCHECKER, SN_GRAMMARCHECKER, SN_HYPHENATOR, SN_THESAURUS };
204 - const sal_Char * apCurLists[nNumServices] = { "ServiceManager/SpellCheckerList", "ServiceManager/GrammarCheckerList", "ServiceManager/HyphenatorList", "ServiceManager/ThesaurusList" };
205 - const sal_Char * apLastFoundLists[nNumServices] = { "ServiceManager/LastFoundSpellCheckers", "ServiceManager/LastFoundGrammarCheckers", "ServiceManager/LastFoundHyphenators", "ServiceManager/LastFoundThesauri" };
206 -
207 - // usage of indices as above: 0 = spell checker, 1 = grammar checker, 2 = hyphenator, 3 = thesaurus
208 - std::vector< list_entry_map_t > aLastFoundSvcs(nNumServices);
209 - std::vector< list_entry_map_t > aCurSvcs(nNumServices);
210 -
211 - for (int k = 0; k < nNumServices; ++k)
212 - {
213 - OUString aService( ::rtl::OUString::createFromAscii( apServices[k] ) );
214 - OUString aActiveList( ::rtl::OUString::createFromAscii( apCurLists[k] ) );
215 - OUString aLastFoundList( ::rtl::OUString::createFromAscii( apLastFoundLists[k] ) );
216 - sal_Int32 i;
217 -
218 - //
219 - // remove configured but not available language/services entries
220 - //
221 - Sequence< OUString > aNodeNames( aCfg.GetNodeNames( aActiveList ) ); // list of configured locales
222 - sal_Int32 nNodeNames = aNodeNames.getLength();
223 - const OUString *pNodeName = aNodeNames.getConstArray();
224 - for (i = 0; i < nNodeNames; ++i)
225 - {
226 - Locale aLocale( SvxCreateLocale( MsLangId::convertIsoStringToLanguage(pNodeName[i]) ) );
227 - Sequence< OUString > aCfgSvcs(
228 - xLngSvcMgr->getConfiguredServices( aService, aLocale ));
229 - Sequence< OUString > aAvailSvcs(
230 - xLngSvcMgr->getAvailableServices( aService, aLocale ));
231 -#if OSL_DEBUG_LEVEL > 1
232 - const OUString * pCfgSvcs = aCfgSvcs.getConstArray();
233 - const OUString * pAvailSvcs = aAvailSvcs.getConstArray();
234 - (void) pCfgSvcs;
235 - (void) pAvailSvcs;
236 -#endif
237 - aCfgSvcs = lcl_RemoveMissingEntries( aCfgSvcs, aAvailSvcs );
238 -
239 - aCurSvcs[k][ pNodeName[i] ] = aCfgSvcs;
240 - }
241 -
242 - //
243 - // add new available language/servcice entries
244 - //
245 - uno::Reference< XAvailableLocales > xAvail( xLngSvcMgr, UNO_QUERY );
246 - Sequence< Locale > aAvailLocales( xAvail->getAvailableLocales(aService) );
247 - sal_Int32 nAvailLocales = aAvailLocales.getLength();
248 - const Locale *pAvailLocale = aAvailLocales.getConstArray();
249 - for (i = 0; i < nAvailLocales; ++i)
250 - {
251 - Sequence< OUString > aAvailSvcs(
252 - xLngSvcMgr->getAvailableServices( aService, pAvailLocale[i] ));
253 - Sequence< OUString > aLastSvcs(
254 - lcl_GetLastFoundSvcs( aCfg, aLastFoundList , pAvailLocale[i] ));
255 - Sequence< OUString > aNewSvcs =
256 - lcl_GetNewEntries( aLastSvcs, aAvailSvcs );
257 -#if OSL_DEBUG_LEVEL > 1
258 - const OUString * pAvailSvcs = aAvailSvcs.getConstArray();
259 - const OUString * pLastSvcs = aLastSvcs.getConstArray();
260 - const OUString * pNewSvcs = aNewSvcs.getConstArray();
261 - (void) pAvailSvcs;
262 - (void) pLastSvcs;
263 - (void) pNewSvcs;
264 -#endif
265 -
266 - OUString aCfgLocaleStr( MsLangId::convertLanguageToIsoString(
267 - SvxLocaleToLanguage( pAvailLocale[i] ) ) );
268 - Sequence< OUString > aCfgSvcs( aCurSvcs[k][ aCfgLocaleStr ] );
269 -
270 - // merge services list (previously configured to be listed first).
271 - aCfgSvcs = lcl_MergeSeq( aCfgSvcs, aNewSvcs );
272 -
273 -/*
274 - // there is at most one Hyphenator per language allowed
275 - // to be configured, thus we only use the first one found.
276 - if (k == 2 && aCfgSvcs.getLength() > 1)
277 - aCfgSvcs.realloc(1);
278 -*/
279 - aCurSvcs[k][ aCfgLocaleStr ] = aCfgSvcs;
280 - }
281 -
282 - //
283 - // set last found services to currently available ones
284 - //
285 - for (i = 0; i < nAvailLocales; ++i)
286 - {
287 - Sequence< OUString > aSvcImplNames(
288 - xLngSvcMgr->getAvailableServices( aService, pAvailLocale[i] ) );
289 -
290 -#if OSL_DEBUG_LEVEL > 1
291 - sal_Int32 nSvcs = aSvcImplNames.getLength();
292 - const OUString *pSvcImplName = aSvcImplNames.getConstArray();
293 - for (sal_Int32 j = 0; j < nSvcs; ++j)
294 - {
295 - OUString aImplName( pSvcImplName[j] );
296 - }
297 -#endif
298 -
299 - OUString aCfgLocaleStr( MsLangId::convertLanguageToIsoString(
300 - SvxLocaleToLanguage( pAvailLocale[i] ) ) );
301 - aLastFoundSvcs[k][ aCfgLocaleStr ] = aSvcImplNames;
302 - }
303 - }
304 -
305 - //
306 - // write new data back to configuration
307 - //
308 - for (int k = 0; k < nNumServices; ++k)
309 - {
310 - for (int i = 0; i < 2; ++i)
311 - {
312 - const sal_Char *pSubNodeName = (i == 0) ? apCurLists[k] : apLastFoundLists[k];
313 - OUString aSubNodeName( ::rtl::OUString::createFromAscii(pSubNodeName) );
314 -
315 - list_entry_map_t &rCurMap = (i == 0) ? aCurSvcs[k] : aLastFoundSvcs[k];
316 - list_entry_map_t::const_iterator aIt( rCurMap.begin() );
317 - sal_Int32 nVals = static_cast< sal_Int32 >( rCurMap.size() );
318 - Sequence< PropertyValue > aNewValues( nVals );
319 - PropertyValue *pNewValue = aNewValues.getArray();
320 - while (aIt != rCurMap.end())
321 - {
322 - OUString aCfgEntryName( aSubNodeName );
323 - aCfgEntryName += OUString::valueOf( (sal_Unicode) '/' );
324 - aCfgEntryName += (*aIt).first;
325 -
326 -#if OSL_DEBUG_LEVEL > 1
327 - Sequence< OUString > aSvcImplNames( (*aIt).second );
328 - sal_Int32 nSvcs = aSvcImplNames.getLength();
329 - const OUString *pSvcImplName = aSvcImplNames.getConstArray();
330 - for (sal_Int32 j = 0; j < nSvcs; ++j)
331 - {
332 - OUString aImplName( pSvcImplName[j] );
333 - }
334 -#endif
335 - pNewValue->Name = aCfgEntryName;
336 - pNewValue->Value <<= (*aIt).second;
337 - ++pNewValue;
338 - ++aIt;
339 - }
340 - OSL_ENSURE( pNewValue - aNewValues.getArray() == nVals,
341 - "possible mismatch of sequence size and property number" );
342 -
343 - {
344 - RTL_LOGFILE_CONTEXT( aLog, "svx: SvxLinguConfigUpdate::UpdateAll - ReplaceSetProperties" );
345 - // add new or replace existing entries.
346 - sal_Bool bRes = aCfg.ReplaceSetProperties( aSubNodeName, aNewValues );
347 - if (!bRes)
348 - {
349 -#if OSL_DEBUG_LEVEL > 1
350 - OSL_FAIL( "failed to set new configuration values" );
351 -#endif
352 - }
353 - }
354 - }
355 - }
356 - OSL_ENSURE( nCurrentDataFilesChangedCheckValue != -1, "SvxLinguConfigUpdate::UpdateAll DataFilesChangedCheckValue not yet calculated!" );
357 - Any aAny;
358 -
359 - // for the time being (developer builds until OOo 3.0)
360 - // we should always check for everything available
361 - // otherwise we may miss a new installed extension dicitonary
362 - // just because e.g. the spellchecker is not asked what
363 - // languages it does support currently...
364 - // Since the check is on-demand occuring and executed once it should
365 - // not be too troublesome.
366 - // In OOo 3.0 we will not need the respective code anymore at all.
367 -// aAny <<= nCurrentDataFilesChangedCheckValue;
368 - aAny <<= (sal_Int32) -1; // keep the value set to 'need to check'
369 -
370 - aCfg.SetProperty( A2OU( "DataFilesChangedCheckValue" ), aAny );
371 -
372 - //! Note 1: the new values are commited when the 'aCfg' object
373 - //! gets destroyed.
374 - //! Note 2: the new settings in the configuration get applied
375 - //! because the 'LngSvcMgr' (in linguistic/source/lngsvcmgr.hxx)
376 - //! listens to the configuration for changes of the relevant
377 - //! properties and then applies the new settings.
378 -
379 - // nothing needs to be done anymore
380 - nNeedUpdating = 0;
381 - }
382 -}
383 -
384 -
385 -sal_Int32 SvxLinguConfigUpdate::CalcDataFilesChangedCheckValue()
386 -{
387 - RTL_LOGFILE_CONTEXT( aLog, "svx: SvxLinguConfigUpdate::CalcDataFilesChangedCheckValue" );
388 -
389 - sal_Int32 nHashVal = 0;
390 - // nothing to be checked anymore since those old directory paths are gone by now
391 - return nHashVal;
392 -}
393 -
394 -
395 -sal_Bool SvxLinguConfigUpdate::IsNeedUpdateAll( sal_Bool bForceCheck )
396 -{
397 - RTL_LOGFILE_CONTEXT( aLog, "svx: SvxLinguConfigUpdate::IsNeedUpdateAll" );
398 - if (nNeedUpdating == -1 || bForceCheck ) // need to check if updating is necessary
399 - {
400 - // calculate hash value for current data files
401 - nCurrentDataFilesChangedCheckValue = CalcDataFilesChangedCheckValue();
402 -
403 - // compare hash value and check value to see if anything has changed
404 - // and thus the configuration needs to be updated
405 - SvtLinguOptions aLinguOpt;
406 - SvtLinguConfig aCfg;
407 - aCfg.GetOptions( aLinguOpt );
408 - nNeedUpdating = (nCurrentDataFilesChangedCheckValue == aLinguOpt.nDataFilesChangedCheckValue) ? 0 : 1;
409 - }
410 - OSL_ENSURE( nNeedUpdating != -1,
411 - "need for linguistic configuration update should have been already checked." );
412 -
413 - return nNeedUpdating == 1;
414 -}
415 -
416
417 //! Dummy implementation in order to avoid loading of lingu DLL
418 //! when only the XSupportedLocales interface is used.
419 @@ -520,10 +158,6 @@
420
421 void ThesDummy_Impl::GetThes_Impl()
422 {
423 - // update configuration before accessing the service
424 - if (SvxLinguConfigUpdate::IsNeedUpdateAll())
425 - SvxLinguConfigUpdate::UpdateAll();
426 -
427 if (!xThes.is())
428 {
429 uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() );
430 @@ -543,8 +177,7 @@
431 ThesDummy_Impl::getLocales()
432 throw(uno::RuntimeException)
433 {
434 - if (!SvxLinguConfigUpdate::IsNeedUpdateAll()) // configuration already update and thus lingu DLL's already loaded ?
435 - GetThes_Impl();
436 + GetThes_Impl();
437 if (xThes.is())
438 return xThes->getLocales();
439 else if (!pLocaleSeq) // if not already loaded save startup time by avoiding loading them now
440 @@ -557,8 +190,7 @@
441 ThesDummy_Impl::hasLocale( const lang::Locale& rLocale )
442 throw(uno::RuntimeException)
443 {
444 - if (!SvxLinguConfigUpdate::IsNeedUpdateAll()) // configuration already update and thus lingu DLL's already loaded ?
445 - GetThes_Impl();
446 + GetThes_Impl();
447 if (xThes.is())
448 return xThes->hasLocale( rLocale );
449 else if (!pLocaleSeq) // if not already loaded save startup time by avoiding loading them now
450 @@ -632,10 +264,6 @@
451
452 void SpellDummy_Impl::GetSpell_Impl()
453 {
454 - // update configuration before accessing the service
455 - if (SvxLinguConfigUpdate::IsNeedUpdateAll())
456 - SvxLinguConfigUpdate::UpdateAll();
457 -
458 if (!xSpell.is())
459 {
460 uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() );
461 @@ -748,10 +376,6 @@
462
463 void HyphDummy_Impl::GetHyph_Impl()
464 {
465 - // update configuration before accessing the service
466 - if (SvxLinguConfigUpdate::IsNeedUpdateAll())
467 - SvxLinguConfigUpdate::UpdateAll();
468 -
469 if (!xHyph.is())
470 {
471 uno::Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() );
472 diff -ru libreoffice-3.5.5.3.orig/linguistic/Library_lng.mk libreoffice-3.5.5.3/linguistic/Library_lng.mk
473 --- libreoffice-3.5.5.3.orig/linguistic/Library_lng.mk 2012-07-13 12:23:35.568866084 +0100
474 +++ libreoffice-3.5.5.3/linguistic/Library_lng.mk 2012-07-16 08:49:27.810226966 +0100
475 @@ -56,6 +56,7 @@
476 tl \
477 ucbhelper \
478 utl \
479 + vcl \
480 xo \
481 $(gb_STDLIBS) \
482 ))
483 diff -ru libreoffice-3.5.5.3.orig/linguistic/prj/build.lst libreoffice-3.5.5.3/linguistic/prj/build.lst
484 --- libreoffice-3.5.5.3.orig/linguistic/prj/build.lst 2012-07-13 12:23:35.611866523 +0100
485 +++ libreoffice-3.5.5.3/linguistic/prj/build.lst 2012-07-16 08:49:27.820227082 +0100
486 @@ -1,2 +1,2 @@
487 -lg linguistic : svl xmloff ucbhelper comphelper ICU:icu LIBXSLT:libxslt NULL
488 +lg linguistic : svl vcl xmloff ucbhelper comphelper ICU:icu LIBXSLT:libxslt NULL
489 lg linguistic\prj nmake - all lg_prj NULL
490 diff -ru libreoffice-3.5.5.3.orig/linguistic/source/lngsvcmgr.cxx libreoffice-3.5.5.3/linguistic/source/lngsvcmgr.cxx
491 --- libreoffice-3.5.5.3.orig/linguistic/source/lngsvcmgr.cxx 2012-07-13 12:23:35.585866257 +0100
492 +++ libreoffice-3.5.5.3/linguistic/source/lngsvcmgr.cxx 2012-07-16 08:49:27.829227184 +0100
493 @@ -27,6 +27,7 @@
494 ************************************************************************/
495
496
497 +#include <com/sun/star/deployment/ExtensionManager.hpp>
498 #include <com/sun/star/registry/XRegistryKey.hpp>
499 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
500 #include <com/sun/star/container/XEnumeration.hpp>
501 @@ -270,8 +271,6 @@
502 }
503 }
504
505 -
506 -//IMPL_LINK( LngSvcMgrListenerHelper, TimeOut, Timer*, pTimer )
507 long LngSvcMgrListenerHelper::Timeout()
508 {
509 osl::MutexGuard aGuard( GetLinguMutex() );
510 @@ -483,11 +482,98 @@
511 pNames[2] = "ServiceManager/HyphenatorList";
512 pNames[3] = "ServiceManager/ThesaurusList";
513 EnableNotification( aNames );
514 +
515 + UpdateAll();
516 +
517 + aUpdateTimer.SetTimeout(500);
518 + aUpdateTimer.SetTimeoutHdl(LINK(this, LngSvcMgr, updateAndBroadcast));
519 +
520 + // request to be notified if an extension has been added/removed
521 + uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
522 +
523 + uno::Reference<deployment::XExtensionManager> xExtensionManager(
524 + deployment::ExtensionManager::get(xContext));
525 + if (xExtensionManager.is())
526 + {
527 + xMB = uno::Reference<util::XModifyBroadcaster>(xExtensionManager, uno::UNO_QUERY_THROW);
528 +
529 + uno::Reference<util::XModifyListener> xListener(this);
530 + xMB->addModifyListener( xListener );
531 + }
532 +}
533 +
534 +// ::com::sun::star::util::XModifyListener
535 +void LngSvcMgr::modified(const lang::EventObject&)
536 + throw(uno::RuntimeException)
537 +{
538 + osl::MutexGuard aGuard(GetLinguMutex());
539 + //assume that if an extension has been added/removed that
540 + //it might be a dictionary extension, so drop our cache
541 +
542 + delete pAvailSpellSvcs;
543 + pAvailSpellSvcs = NULL;
544 + delete pAvailGrammarSvcs;
545 + pAvailGrammarSvcs = NULL;
546 + delete pAvailHyphSvcs;
547 + pAvailHyphSvcs = NULL;
548 + delete pAvailThesSvcs;
549 + pAvailThesSvcs = NULL;
550 +
551 + //schedule in an update to execute in the main thread
552 + aUpdateTimer.Start();
553 +}
554 +
555 +//run update, and inform everyone that dictionaries (may) have changed, this
556 +//needs to be run in the main thread because
557 +//utl::ConfigChangeListener_Impl::changesOccurred grabs the SolarMutex and we
558 +//get notified that an extension was added from an extension manager thread
559 +IMPL_LINK_NOARG(LngSvcMgr, updateAndBroadcast)
560 +{
561 + osl::MutexGuard aGuard( GetLinguMutex() );
562 +
563 + UpdateAll();
564 +
565 + if (pListenerHelper)
566 + {
567 + pListenerHelper->AddLngSvcEvt(
568 + linguistic2::LinguServiceEventFlags::SPELL_CORRECT_WORDS_AGAIN |
569 + linguistic2::LinguServiceEventFlags::SPELL_WRONG_WORDS_AGAIN |
570 + linguistic2::LinguServiceEventFlags::PROOFREAD_AGAIN |
571 + linguistic2::LinguServiceEventFlags::HYPHENATE_AGAIN );
572 + }
573 +
574 + return 0;
575 }
576
577 +void LngSvcMgr::stopListening()
578 +{
579 + osl::MutexGuard aGuard(GetLinguMutex());
580 +
581 + if (xMB.is())
582 + {
583 + try
584 + {
585 + uno::Reference<util::XModifyListener> xListener(this);
586 + xMB->removeModifyListener(xListener);
587 + }
588 + catch (const uno::Exception&)
589 + {
590 + }
591 +
592 + xMB.clear();
593 + }
594 +}
595 +
596 +void LngSvcMgr::disposing(const lang::EventObject&)
597 + throw (uno::RuntimeException)
598 +{
599 + stopListening();
600 +}
601
602 LngSvcMgr::~LngSvcMgr()
603 {
604 + stopListening();
605 +
606 // memory for pSpellDsp, pHyphDsp, pThesDsp, pListenerHelper
607 // will be freed in the destructor of the respective Reference's
608 // xSpellDsp, xGrammarDsp, xHyphDsp, xThesDsp
609 @@ -498,6 +584,252 @@
610 delete pAvailThesSvcs;
611 }
612
613 +namespace
614 +{
615 + using lang::Locale;
616 + using uno::Any;
617 + using uno::Sequence;
618 +
619 + sal_Bool lcl_FindEntry( const OUString &rEntry, const Sequence< OUString > &rCfgSvcs )
620 + {
621 + sal_Int32 nRes = -1;
622 + sal_Int32 nEntries = rCfgSvcs.getLength();
623 + const OUString *pEntry = rCfgSvcs.getConstArray();
624 + for (sal_Int32 i = 0; i < nEntries && nRes == -1; ++i)
625 + {
626 + if (rEntry == pEntry[i])
627 + nRes = i;
628 + }
629 + return nRes != -1;
630 + }
631 +
632 + Sequence< OUString > lcl_GetLastFoundSvcs(
633 + SvtLinguConfig &rCfg,
634 + const OUString &rLastFoundList ,
635 + const Locale &rAvailLocale )
636 + {
637 + Sequence< OUString > aRes;
638 +
639 + OUString aCfgLocaleStr( MsLangId::convertLanguageToIsoString(
640 + LocaleToLanguage( rAvailLocale ) ) );
641 +
642 + Sequence< OUString > aNodeNames( rCfg.GetNodeNames(rLastFoundList) );
643 + sal_Bool bFound = lcl_FindEntry( aCfgLocaleStr, aNodeNames);
644 +
645 + if (bFound)
646 + {
647 + Sequence< OUString > aNames(1);
648 + OUString &rNodeName = aNames.getArray()[0];
649 + rNodeName = rLastFoundList;
650 + rNodeName += OUString::valueOf( (sal_Unicode)'/' );
651 + rNodeName += aCfgLocaleStr;
652 + Sequence< Any > aValues( rCfg.GetProperties( aNames ) );
653 + if (aValues.getLength())
654 + {
655 + OSL_ENSURE( aValues.getLength() == 1, "unexpected length of sequence" );
656 + Sequence< OUString > aSvcImplNames;
657 + if (aValues.getConstArray()[0] >>= aSvcImplNames)
658 + aRes = aSvcImplNames;
659 + else
660 + {
661 + OSL_FAIL( "type mismatch" );
662 + }
663 + }
664 + }
665 +
666 + return aRes;
667 + }
668 +
669 + Sequence< OUString > lcl_RemoveMissingEntries(
670 + const Sequence< OUString > &rCfgSvcs,
671 + const Sequence< OUString > &rAvailSvcs )
672 + {
673 + Sequence< OUString > aRes( rCfgSvcs.getLength() );
674 + OUString *pRes = aRes.getArray();
675 + sal_Int32 nCnt = 0;
676 +
677 + sal_Int32 nEntries = rCfgSvcs.getLength();
678 + const OUString *pEntry = rCfgSvcs.getConstArray();
679 + for (sal_Int32 i = 0; i < nEntries; ++i)
680 + {
681 + if (!pEntry[i].isEmpty() && lcl_FindEntry( pEntry[i], rAvailSvcs ))
682 + pRes[ nCnt++ ] = pEntry[i];
683 + }
684 +
685 + aRes.realloc( nCnt );
686 + return aRes;
687 + }
688 +
689 + Sequence< OUString > lcl_GetNewEntries(
690 + const Sequence< OUString > &rLastFoundSvcs,
691 + const Sequence< OUString > &rAvailSvcs )
692 + {
693 + sal_Int32 nLen = rAvailSvcs.getLength();
694 + Sequence< OUString > aRes( nLen );
695 + OUString *pRes = aRes.getArray();
696 + sal_Int32 nCnt = 0;
697 +
698 + const OUString *pEntry = rAvailSvcs.getConstArray();
699 + for (sal_Int32 i = 0; i < nLen; ++i)
700 + {
701 + if (!pEntry[i].isEmpty() && !lcl_FindEntry( pEntry[i], rLastFoundSvcs ))
702 + pRes[ nCnt++ ] = pEntry[i];
703 + }
704 +
705 + aRes.realloc( nCnt );
706 + return aRes;
707 + }
708 +
709 + Sequence< OUString > lcl_MergeSeq(
710 + const Sequence< OUString > &rCfgSvcs,
711 + const Sequence< OUString > &rNewSvcs )
712 + {
713 + Sequence< OUString > aRes( rCfgSvcs.getLength() + rNewSvcs.getLength() );
714 + OUString *pRes = aRes.getArray();
715 + sal_Int32 nCnt = 0;
716 +
717 + for (sal_Int32 k = 0; k < 2; ++k)
718 + {
719 + // add previously configuerd service first and append
720 + // new found services at the end
721 + const Sequence< OUString > &rSeq = k == 0 ? rCfgSvcs : rNewSvcs;
722 +
723 + sal_Int32 nLen = rSeq.getLength();
724 + const OUString *pEntry = rSeq.getConstArray();
725 + for (sal_Int32 i = 0; i < nLen; ++i)
726 + {
727 + if (!pEntry[i].isEmpty() && !lcl_FindEntry( pEntry[i], aRes ))
728 + pRes[ nCnt++ ] = pEntry[i];
729 + }
730 + }
731 +
732 + aRes.realloc( nCnt );
733 + return aRes;
734 + }
735 +}
736 +
737 +void LngSvcMgr::UpdateAll()
738 +{
739 + using beans::PropertyValue;
740 + using lang::Locale;
741 + using uno::Sequence;
742 +
743 + typedef OUString OUstring_t;
744 + typedef Sequence< OUString > Sequence_OUString_t;
745 + typedef std::map< OUstring_t, Sequence_OUString_t > list_entry_map_t;
746 +
747 + SvtLinguConfig aCfg;
748 +
749 + const int nNumServices = 4;
750 + const sal_Char * apServices[nNumServices] = { SN_SPELLCHECKER, SN_GRAMMARCHECKER, SN_HYPHENATOR, SN_THESAURUS };
751 + const sal_Char * apCurLists[nNumServices] = { "ServiceManager/SpellCheckerList", "ServiceManager/GrammarCheckerList", "ServiceManager/HyphenatorList", "ServiceManager/ThesaurusList" };
752 + const sal_Char * apLastFoundLists[nNumServices] = { "ServiceManager/LastFoundSpellCheckers", "ServiceManager/LastFoundGrammarCheckers", "ServiceManager/LastFoundHyphenators", "ServiceManager/LastFoundThesauri" };
753 +
754 + // usage of indices as above: 0 = spell checker, 1 = grammar checker, 2 = hyphenator, 3 = thesaurus
755 + std::vector< list_entry_map_t > aLastFoundSvcs(nNumServices);
756 + std::vector< list_entry_map_t > aCurSvcs(nNumServices);
757 +
758 + for (int k = 0; k < nNumServices; ++k)
759 + {
760 + OUString aService( ::rtl::OUString::createFromAscii( apServices[k] ) );
761 + OUString aActiveList( ::rtl::OUString::createFromAscii( apCurLists[k] ) );
762 + OUString aLastFoundList( ::rtl::OUString::createFromAscii( apLastFoundLists[k] ) );
763 + sal_Int32 i;
764 +
765 + //
766 + // remove configured but not available language/services entries
767 + //
768 + Sequence< OUString > aNodeNames( aCfg.GetNodeNames( aActiveList ) ); // list of configured locales
769 + sal_Int32 nNodeNames = aNodeNames.getLength();
770 + const OUString *pNodeName = aNodeNames.getConstArray();
771 + for (i = 0; i < nNodeNames; ++i)
772 + {
773 + Locale aLocale( CreateLocale( MsLangId::convertIsoStringToLanguage(pNodeName[i]) ) );
774 + Sequence< OUString > aCfgSvcs( getConfiguredServices( aService, aLocale ));
775 + Sequence< OUString > aAvailSvcs( getAvailableServices( aService, aLocale ));
776 +
777 + aCfgSvcs = lcl_RemoveMissingEntries( aCfgSvcs, aAvailSvcs );
778 +
779 + aCurSvcs[k][ pNodeName[i] ] = aCfgSvcs;
780 + }
781 +
782 + //
783 + // add new available language/service entries
784 + // and
785 + // set last found services to currently available ones
786 + //
787 + Sequence< Locale > aAvailLocales( getAvailableLocales(aService) );
788 + sal_Int32 nAvailLocales = aAvailLocales.getLength();
789 + const Locale *pAvailLocale = aAvailLocales.getConstArray();
790 + for (i = 0; i < nAvailLocales; ++i)
791 + {
792 + OUString aCfgLocaleStr( MsLangId::convertLanguageToIsoString(
793 + LocaleToLanguage( pAvailLocale[i] ) ) );
794 +
795 + Sequence< OUString > aAvailSvcs( getAvailableServices( aService, pAvailLocale[i] ));
796 +
797 + aLastFoundSvcs[k][ aCfgLocaleStr ] = aAvailSvcs;
798 +
799 + Sequence< OUString > aLastSvcs(
800 + lcl_GetLastFoundSvcs( aCfg, aLastFoundList , pAvailLocale[i] ));
801 + Sequence< OUString > aNewSvcs =
802 + lcl_GetNewEntries( aLastSvcs, aAvailSvcs );
803 +
804 + Sequence< OUString > aCfgSvcs( aCurSvcs[k][ aCfgLocaleStr ] );
805 +
806 + // merge services list (previously configured to be listed first).
807 + aCfgSvcs = lcl_MergeSeq( aCfgSvcs, aNewSvcs );
808 +
809 + aCurSvcs[k][ aCfgLocaleStr ] = aCfgSvcs;
810 + }
811 + }
812 +
813 + //
814 + // write new data back to configuration
815 + //
816 + for (int k = 0; k < nNumServices; ++k)
817 + {
818 + for (int i = 0; i < 2; ++i)
819 + {
820 + const sal_Char *pSubNodeName = (i == 0) ? apCurLists[k] : apLastFoundLists[k];
821 + OUString aSubNodeName( ::rtl::OUString::createFromAscii(pSubNodeName) );
822 +
823 + list_entry_map_t &rCurMap = (i == 0) ? aCurSvcs[k] : aLastFoundSvcs[k];
824 + list_entry_map_t::const_iterator aIt( rCurMap.begin() );
825 + sal_Int32 nVals = static_cast< sal_Int32 >( rCurMap.size() );
826 + Sequence< PropertyValue > aNewValues( nVals );
827 + PropertyValue *pNewValue = aNewValues.getArray();
828 + while (aIt != rCurMap.end())
829 + {
830 + OUString aCfgEntryName( aSubNodeName );
831 + aCfgEntryName += OUString::valueOf( (sal_Unicode) '/' );
832 + aCfgEntryName += (*aIt).first;
833 +
834 + pNewValue->Name = aCfgEntryName;
835 + pNewValue->Value <<= (*aIt).second;
836 + ++pNewValue;
837 + ++aIt;
838 + }
839 + OSL_ENSURE( pNewValue - aNewValues.getArray() == nVals,
840 + "possible mismatch of sequence size and property number" );
841 +
842 + {
843 + // add new or replace existing entries.
844 + sal_Bool bRes = aCfg.ReplaceSetProperties( aSubNodeName, aNewValues );
845 + if (!bRes)
846 + {
847 +#if OSL_DEBUG_LEVEL > 1
848 + OSL_FAIL( "failed to set new configuration values" );
849 +#endif
850 + }
851 + }
852 + }
853 + }
854 +
855 + //The new settings in the configuration get applied ! because we are
856 + //listening to the configuration for changes of the relevant ! properties
857 + //and Notify applies the new settings.
858 +}
859
860 void LngSvcMgr::Notify( const uno::Sequence< OUString > &rPropertyNames )
861 {
862 @@ -1263,32 +1595,21 @@
863
864 if (0 == rServiceName.compareToAscii( SN_SPELLCHECKER ))
865 {
866 - // don't used cached data here (force re-evaluation in order to have downloaded dictionaries
867 - // already found without the need to restart the office
868 - delete pAvailSpellSvcs; pAvailSpellSvcs = 0;
869 GetAvailableSpellSvcs_Impl();
870 pInfoArray = pAvailSpellSvcs;
871 }
872 else if (0 == rServiceName.compareToAscii( SN_GRAMMARCHECKER ))
873 {
874 -// disable force re-loading of the cache - re-start needed for new grammer checkers: fdo#35270
875 -// delete pAvailGrammarSvcs; pAvailGrammarSvcs = 0;
876 GetAvailableGrammarSvcs_Impl();
877 pInfoArray = pAvailGrammarSvcs;
878 }
879 else if (0 == rServiceName.compareToAscii( SN_HYPHENATOR ))
880 {
881 - // don't used cached data here (force re-evaluation in order to have downloaded dictionaries
882 - // already found without the need to restart the office
883 - delete pAvailHyphSvcs; pAvailHyphSvcs = 0;
884 GetAvailableHyphSvcs_Impl();
885 pInfoArray = pAvailHyphSvcs;
886 }
887 else if (0 == rServiceName.compareToAscii( SN_THESAURUS ))
888 {
889 - // don't used cached data here (force re-evaluation in order to have downloaded dictionaries
890 - // already found without the need to restart the office
891 - delete pAvailThesSvcs; pAvailThesSvcs = 0;
892 GetAvailableThesSvcs_Impl();
893 pInfoArray = pAvailThesSvcs;
894 }
895 diff -ru libreoffice-3.5.5.3.orig/linguistic/source/lngsvcmgr.hxx libreoffice-3.5.5.3/linguistic/source/lngsvcmgr.hxx
896 --- libreoffice-3.5.5.3.orig/linguistic/source/lngsvcmgr.hxx 2012-07-13 12:23:35.598866391 +0100
897 +++ libreoffice-3.5.5.3/linguistic/source/lngsvcmgr.hxx 2012-07-16 08:49:27.833227231 +0100
898 @@ -30,7 +30,7 @@
899 #define _LINGUISTIC_LNGSVCMGR_HXX_
900
901 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
902 -#include <cppuhelper/implbase4.hxx> // helper for implementations
903 +#include <cppuhelper/implbase5.hxx> // helper for implementations
904 #include <cppuhelper/interfacecontainer.h> //OMultiTypeInterfaceContainerHelper
905
906
907 @@ -39,8 +39,10 @@
908 #include <com/sun/star/lang/XComponent.hpp>
909 #include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
910 #include <com/sun/star/linguistic2/XAvailableLocales.hpp>
911 +#include <com/sun/star/util/XModifyBroadcaster.hpp>
912 +#include <com/sun/star/util/XModifyListener.hpp>
913 #include <unotools/configitem.hxx>
914 -
915 +#include <vcl/timer.hxx>
916 #include <boost/ptr_container/ptr_vector.hpp>
917
918 #include "linguistic/misc.hxx"
919 @@ -65,12 +67,13 @@
920
921
922 class LngSvcMgr :
923 - public cppu::WeakImplHelper4
924 + public cppu::WeakImplHelper5
925 <
926 com::sun::star::linguistic2::XLinguServiceManager,
927 com::sun::star::linguistic2::XAvailableLocales,
928 com::sun::star::lang::XComponent,
929 - com::sun::star::lang::XServiceInfo
930 + com::sun::star::lang::XServiceInfo,
931 + com::sun::star::util::XModifyListener
932 >,
933 private utl::ConfigItem
934 {
935 @@ -90,6 +93,12 @@
936 com::sun::star::uno::Reference<
937 ::com::sun::star::lang::XEventListener > xListenerHelper;
938
939 + com::sun::star::uno::Reference<
940 + ::com::sun::star::util::XModifyBroadcaster> xMB;
941 +
942 + Timer aUpdateTimer;
943 +
944 +
945 com::sun::star::uno::Sequence<
946 com::sun::star::lang::Locale > aAvailSpellLocales;
947 com::sun::star::uno::Sequence<
948 @@ -140,6 +149,10 @@
949 virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames );
950 virtual void Commit();
951
952 + void UpdateAll();
953 + void stopListening();
954 + DECL_LINK( updateAndBroadcast, void* );
955 +
956 public:
957 LngSvcMgr();
958 virtual ~LngSvcMgr();
959 @@ -167,6 +180,11 @@
960 virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
961 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
962
963 + // XEventListener
964 + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rSource ) throw(::com::sun::star::uno::RuntimeException);
965 +
966 + // XModifyListener
967 + virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& rEvent ) throw(::com::sun::star::uno::RuntimeException);
968
969 static inline ::rtl::OUString getImplementationName_Static();
970 static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();

  ViewVC Help
Powered by ViewVC 1.1.30