nss: upgrade to release 3.73
[LibreOffice.git] / editeng / source / misc / unolingu.cxx
blobaf32538f9702e463b306d77c52e16f456d113641
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <memory>
22 #include <editeng/unolingu.hxx>
23 #include <com/sun/star/frame/Desktop.hpp>
24 #include <com/sun/star/frame/XStorable.hpp>
25 #include <com/sun/star/lang/XEventListener.hpp>
26 #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
27 #include <com/sun/star/linguistic2/DictionaryList.hpp>
28 #include <com/sun/star/linguistic2/LinguServiceManager.hpp>
29 #include <com/sun/star/linguistic2/LinguProperties.hpp>
30 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
32 #include <comphelper/processfactory.hxx>
33 #include <cppuhelper/implbase.hxx>
34 #include <i18nlangtag/languagetag.hxx>
35 #include <unotools/lingucfg.hxx>
36 #include <vcl/svapp.hxx>
37 #include <vcl/weld.hxx>
38 #include <linguistic/misc.hxx>
39 #include <editeng/eerdll.hxx>
40 #include <editeng/editrids.hrc>
41 #include <svtools/strings.hrc>
42 #include <unotools/resmgr.hxx>
43 #include <sal/log.hxx>
44 #include <osl/diagnose.h>
46 using namespace ::comphelper;
47 using namespace ::linguistic;
48 using namespace ::com::sun::star;
49 using namespace ::com::sun::star::util;
50 using namespace ::com::sun::star::uno;
51 using namespace ::com::sun::star::lang;
52 using namespace ::com::sun::star::beans;
53 using namespace ::com::sun::star::frame;
54 using namespace ::com::sun::star::linguistic2;
56 static uno::Reference< XLinguServiceManager2 > GetLngSvcMgr_Impl()
58 uno::Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
59 uno::Reference< XLinguServiceManager2 > xRes = LinguServiceManager::create(xContext);
60 return xRes;
63 namespace {
65 //! Dummy implementation in order to avoid loading of lingu DLL
66 //! when only the XSupportedLocales interface is used.
67 //! The dummy accesses the real implementation (and thus loading the DLL)
68 //! when "real" work needs to be done only.
69 class ThesDummy_Impl :
70 public cppu::WeakImplHelper< XThesaurus >
72 uno::Reference< XThesaurus > xThes; // the real one...
73 std::unique_ptr<Sequence< lang::Locale >> pLocaleSeq;
75 void GetCfgLocales();
77 void GetThes_Impl();
79 public:
80 ThesDummy_Impl() {}
82 // XSupportedLocales
83 virtual css::uno::Sequence< css::lang::Locale > SAL_CALL
84 getLocales() override;
85 virtual sal_Bool SAL_CALL
86 hasLocale( const css::lang::Locale& rLocale ) override;
88 // XThesaurus
89 virtual css::uno::Sequence<
90 css::uno::Reference< css::linguistic2::XMeaning > > SAL_CALL
91 queryMeanings( const OUString& rTerm,
92 const css::lang::Locale& rLocale,
93 const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override;
98 void ThesDummy_Impl::GetCfgLocales()
100 if (pLocaleSeq)
101 return;
103 SvtLinguConfig aCfg;
104 Sequence < OUString > aNodeNames( aCfg.GetNodeNames( "ServiceManager/ThesaurusList" ) );
105 const OUString *pNodeNames = aNodeNames.getConstArray();
106 sal_Int32 nLen = aNodeNames.getLength();
107 pLocaleSeq.reset( new Sequence< lang::Locale >( nLen ) );
108 lang::Locale *pLocale = pLocaleSeq->getArray();
109 for (sal_Int32 i = 0; i < nLen; ++i)
111 pLocale[i] = LanguageTag::convertToLocaleWithFallback( pNodeNames[i] );
116 void ThesDummy_Impl::GetThes_Impl()
118 if (!xThes.is())
120 uno::Reference< XLinguServiceManager2 > xLngSvcMgr( GetLngSvcMgr_Impl() );
121 xThes = xLngSvcMgr->getThesaurus();
123 if (xThes.is())
125 // no longer needed...
126 pLocaleSeq.reset();
132 uno::Sequence< lang::Locale > SAL_CALL
133 ThesDummy_Impl::getLocales()
135 GetThes_Impl();
136 if (xThes.is())
137 return xThes->getLocales();
138 else if (!pLocaleSeq) // if not already loaded save startup time by avoiding loading them now
139 GetCfgLocales();
140 return *pLocaleSeq;
144 sal_Bool SAL_CALL
145 ThesDummy_Impl::hasLocale( const lang::Locale& rLocale )
147 GetThes_Impl();
148 if (xThes.is())
149 return xThes->hasLocale( rLocale );
150 else if (!pLocaleSeq) // if not already loaded save startup time by avoiding loading them now
151 GetCfgLocales();
152 bool bFound = false;
153 sal_Int32 nLen = pLocaleSeq->getLength();
154 const lang::Locale *pLocale = pLocaleSeq->getConstArray();
155 const lang::Locale *pEnd = pLocale + nLen;
156 for ( ; pLocale < pEnd && !bFound; ++pLocale)
158 bFound = pLocale->Language == rLocale.Language &&
159 pLocale->Country == rLocale.Country &&
160 pLocale->Variant == rLocale.Variant;
162 return bFound;
166 uno::Sequence< uno::Reference< linguistic2::XMeaning > > SAL_CALL
167 ThesDummy_Impl::queryMeanings(
168 const OUString& rTerm,
169 const lang::Locale& rLocale,
170 const css::uno::Sequence< css::beans::PropertyValue >& rProperties )
172 GetThes_Impl();
173 uno::Sequence< uno::Reference< linguistic2::XMeaning > > aRes;
174 OSL_ENSURE( xThes.is(), "Thesaurus missing" );
175 if (xThes.is())
176 aRes = xThes->queryMeanings( rTerm, rLocale, rProperties );
177 return aRes;
180 namespace {
182 //! Dummy implementation in order to avoid loading of lingu DLL.
183 //! The dummy accesses the real implementation (and thus loading the DLL)
184 //! when it needs to be done only.
185 class SpellDummy_Impl :
186 public cppu::WeakImplHelper< XSpellChecker1 >
188 uno::Reference< XSpellChecker1 > xSpell; // the real one...
190 void GetSpell_Impl();
192 public:
194 // XSupportedLanguages (for XSpellChecker1)
195 virtual css::uno::Sequence< sal_Int16 > SAL_CALL
196 getLanguages() override;
197 virtual sal_Bool SAL_CALL
198 hasLanguage( sal_Int16 nLanguage ) override;
200 // XSpellChecker1 (same as XSpellChecker but sal_Int16 for language)
201 virtual sal_Bool SAL_CALL
202 isValid( const OUString& rWord, sal_Int16 nLanguage,
203 const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override;
204 virtual css::uno::Reference< css::linguistic2::XSpellAlternatives > SAL_CALL
205 spell( const OUString& rWord, sal_Int16 nLanguage,
206 const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override;
211 void SpellDummy_Impl::GetSpell_Impl()
213 if (!xSpell.is())
215 uno::Reference< XLinguServiceManager2 > xLngSvcMgr( GetLngSvcMgr_Impl() );
216 xSpell.set( xLngSvcMgr->getSpellChecker(), UNO_QUERY );
221 uno::Sequence< sal_Int16 > SAL_CALL
222 SpellDummy_Impl::getLanguages()
224 GetSpell_Impl();
225 if (xSpell.is())
226 return xSpell->getLanguages();
227 else
228 return uno::Sequence< sal_Int16 >();
232 sal_Bool SAL_CALL
233 SpellDummy_Impl::hasLanguage( sal_Int16 nLanguage )
235 GetSpell_Impl();
236 bool bRes = false;
237 if (xSpell.is())
238 bRes = xSpell->hasLanguage( nLanguage );
239 return bRes;
243 sal_Bool SAL_CALL
244 SpellDummy_Impl::isValid( const OUString& rWord, sal_Int16 nLanguage,
245 const css::uno::Sequence< css::beans::PropertyValue >& rProperties )
247 GetSpell_Impl();
248 bool bRes = true;
249 if (xSpell.is())
250 bRes = xSpell->isValid( rWord, nLanguage, rProperties );
251 return bRes;
255 uno::Reference< linguistic2::XSpellAlternatives > SAL_CALL
256 SpellDummy_Impl::spell( const OUString& rWord, sal_Int16 nLanguage,
257 const css::uno::Sequence< css::beans::PropertyValue >& rProperties )
259 GetSpell_Impl();
260 uno::Reference< linguistic2::XSpellAlternatives > xRes;
261 if (xSpell.is())
262 xRes = xSpell->spell( rWord, nLanguage, rProperties );
263 return xRes;
266 namespace {
268 //! Dummy implementation in order to avoid loading of lingu DLL.
269 //! The dummy accesses the real implementation (and thus loading the DLL)
270 //! when it needs to be done only.
271 class HyphDummy_Impl :
272 public cppu::WeakImplHelper< XHyphenator >
274 uno::Reference< XHyphenator > xHyph; // the real one...
276 void GetHyph_Impl();
278 public:
280 // XSupportedLocales
281 virtual css::uno::Sequence<
282 css::lang::Locale > SAL_CALL
283 getLocales() override;
284 virtual sal_Bool SAL_CALL
285 hasLocale( const css::lang::Locale& rLocale ) override;
287 // XHyphenator
288 virtual css::uno::Reference<
289 css::linguistic2::XHyphenatedWord > SAL_CALL
290 hyphenate( const OUString& rWord,
291 const css::lang::Locale& rLocale,
292 sal_Int16 nMaxLeading,
293 const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override;
294 virtual css::uno::Reference<
295 css::linguistic2::XHyphenatedWord > SAL_CALL
296 queryAlternativeSpelling( const OUString& rWord,
297 const css::lang::Locale& rLocale,
298 sal_Int16 nIndex,
299 const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override;
300 virtual css::uno::Reference<
301 css::linguistic2::XPossibleHyphens > SAL_CALL
302 createPossibleHyphens(
303 const OUString& rWord,
304 const css::lang::Locale& rLocale,
305 const css::uno::Sequence< css::beans::PropertyValue >& rProperties ) override;
310 void HyphDummy_Impl::GetHyph_Impl()
312 if (!xHyph.is())
314 uno::Reference< XLinguServiceManager2 > xLngSvcMgr( GetLngSvcMgr_Impl() );
315 xHyph = xLngSvcMgr->getHyphenator();
320 uno::Sequence< lang::Locale > SAL_CALL
321 HyphDummy_Impl::getLocales()
323 GetHyph_Impl();
324 if (xHyph.is())
325 return xHyph->getLocales();
326 else
327 return uno::Sequence< lang::Locale >();
331 sal_Bool SAL_CALL
332 HyphDummy_Impl::hasLocale( const lang::Locale& rLocale )
334 GetHyph_Impl();
335 bool bRes = false;
336 if (xHyph.is())
337 bRes = xHyph->hasLocale( rLocale );
338 return bRes;
342 uno::Reference< linguistic2::XHyphenatedWord > SAL_CALL
343 HyphDummy_Impl::hyphenate(
344 const OUString& rWord,
345 const lang::Locale& rLocale,
346 sal_Int16 nMaxLeading,
347 const css::uno::Sequence< css::beans::PropertyValue >& rProperties )
349 GetHyph_Impl();
350 uno::Reference< linguistic2::XHyphenatedWord > xRes;
351 if (xHyph.is())
352 xRes = xHyph->hyphenate( rWord, rLocale, nMaxLeading, rProperties );
353 return xRes;
357 uno::Reference< linguistic2::XHyphenatedWord > SAL_CALL
358 HyphDummy_Impl::queryAlternativeSpelling(
359 const OUString& rWord,
360 const lang::Locale& rLocale,
361 sal_Int16 nIndex,
362 const css::uno::Sequence< css::beans::PropertyValue >& rProperties )
364 GetHyph_Impl();
365 uno::Reference< linguistic2::XHyphenatedWord > xRes;
366 if (xHyph.is())
367 xRes = xHyph->queryAlternativeSpelling( rWord, rLocale, nIndex, rProperties );
368 return xRes;
372 uno::Reference< linguistic2::XPossibleHyphens > SAL_CALL
373 HyphDummy_Impl::createPossibleHyphens(
374 const OUString& rWord,
375 const lang::Locale& rLocale,
376 const css::uno::Sequence< css::beans::PropertyValue >& rProperties )
378 GetHyph_Impl();
379 uno::Reference< linguistic2::XPossibleHyphens > xRes;
380 if (xHyph.is())
381 xRes = xHyph->createPossibleHyphens( rWord, rLocale, rProperties );
382 return xRes;
385 class LinguMgrExitLstnr : public cppu::WeakImplHelper<XEventListener>
387 uno::Reference< XDesktop2 > xDesktop;
389 static void AtExit();
391 public:
392 LinguMgrExitLstnr();
393 virtual ~LinguMgrExitLstnr() override;
395 // lang::XEventListener
396 virtual void SAL_CALL disposing(const EventObject& rSource) override;
399 LinguMgrExitLstnr::LinguMgrExitLstnr()
401 // add object to frame::Desktop EventListeners in order to properly call
402 // the AtExit function at application exit.
404 uno::Reference< XComponentContext > xContext = getProcessComponentContext();
405 xDesktop = Desktop::create( xContext );
406 xDesktop->addEventListener( this );
409 LinguMgrExitLstnr::~LinguMgrExitLstnr()
411 if (xDesktop.is())
413 xDesktop->removeEventListener( this );
414 xDesktop = nullptr; //! release reference to desktop
416 OSL_ENSURE(!xDesktop.is(), "reference to desktop should be released");
419 void LinguMgrExitLstnr::disposing(const EventObject& rSource)
421 if (xDesktop.is() && rSource.Source == xDesktop)
423 xDesktop->removeEventListener( this );
424 xDesktop = nullptr; //! release reference to desktop
426 AtExit();
430 void LinguMgrExitLstnr::AtExit()
432 SolarMutexGuard g;
434 // release references
435 LinguMgr::xLngSvcMgr = nullptr;
436 LinguMgr::xSpell = nullptr;
437 LinguMgr::xHyph = nullptr;
438 LinguMgr::xThes = nullptr;
439 LinguMgr::xDicList = nullptr;
440 LinguMgr::xProp = nullptr;
441 LinguMgr::xIgnoreAll = nullptr;
442 LinguMgr::xChangeAll = nullptr;
444 LinguMgr::bExiting = true;
446 LinguMgr::pExitLstnr = nullptr;
450 LinguMgrExitLstnr * LinguMgr::pExitLstnr = nullptr;
451 bool LinguMgr::bExiting = false;
452 uno::Reference< XLinguServiceManager2 > LinguMgr::xLngSvcMgr;
453 uno::Reference< XSpellChecker1 > LinguMgr::xSpell;
454 uno::Reference< XHyphenator > LinguMgr::xHyph;
455 uno::Reference< XThesaurus > LinguMgr::xThes;
456 uno::Reference< XSearchableDictionaryList > LinguMgr::xDicList;
457 uno::Reference< XLinguProperties > LinguMgr::xProp;
458 uno::Reference< XDictionary > LinguMgr::xIgnoreAll;
459 uno::Reference< XDictionary > LinguMgr::xChangeAll;
462 uno::Reference< XLinguServiceManager2 > LinguMgr::GetLngSvcMgr()
464 if (bExiting)
465 return nullptr;
467 if (!pExitLstnr)
468 pExitLstnr = new LinguMgrExitLstnr;
470 if (!xLngSvcMgr.is())
471 xLngSvcMgr = GetLngSvcMgr_Impl();
473 return xLngSvcMgr;
477 uno::Reference< XSpellChecker1 > LinguMgr::GetSpellChecker()
479 return xSpell.is() ? xSpell : GetSpell();
482 uno::Reference< XHyphenator > LinguMgr::GetHyphenator()
484 return xHyph.is() ? xHyph : GetHyph();
487 uno::Reference< XThesaurus > LinguMgr::GetThesaurus()
489 return xThes.is() ? xThes : GetThes();
492 uno::Reference< XSearchableDictionaryList > LinguMgr::GetDictionaryList()
494 return xDicList.is() ? xDicList : GetDicList();
497 uno::Reference< linguistic2::XLinguProperties > LinguMgr::GetLinguPropertySet()
499 return xProp.is() ? xProp : GetProp();
502 uno::Reference< XDictionary > LinguMgr::GetStandardDic()
504 //! don't hold reference to this
505 //! (it may be removed from dictionary list and needs to be
506 //! created empty if accessed again)
507 return GetStandard();
510 uno::Reference< XDictionary > LinguMgr::GetIgnoreAllList()
512 return xIgnoreAll.is() ? xIgnoreAll : GetIgnoreAll();
515 uno::Reference< XDictionary > LinguMgr::GetChangeAllList()
517 return xChangeAll.is() ? xChangeAll : GetChangeAll();
520 uno::Reference< XSpellChecker1 > LinguMgr::GetSpell()
522 if (bExiting)
523 return nullptr;
525 if (!pExitLstnr)
526 pExitLstnr = new LinguMgrExitLstnr;
528 //! use dummy implementation in order to avoid loading of lingu DLL
529 xSpell = new SpellDummy_Impl;
530 return xSpell;
533 uno::Reference< XHyphenator > LinguMgr::GetHyph()
535 if (bExiting)
536 return nullptr;
538 if (!pExitLstnr)
539 pExitLstnr = new LinguMgrExitLstnr;
541 //! use dummy implementation in order to avoid loading of lingu DLL
542 xHyph = new HyphDummy_Impl;
543 return xHyph;
546 uno::Reference< XThesaurus > LinguMgr::GetThes()
548 if (bExiting)
549 return nullptr;
551 if (!pExitLstnr)
552 pExitLstnr = new LinguMgrExitLstnr;
554 //! use dummy implementation in order to avoid loading of lingu DLL
555 //! when only the XSupportedLocales interface is used.
556 //! The dummy accesses the real implementation (and thus loading the DLL)
557 //! when "real" work needs to be done only.
558 xThes = new ThesDummy_Impl;
559 return xThes;
562 uno::Reference< XSearchableDictionaryList > LinguMgr::GetDicList()
564 if (bExiting)
565 return nullptr;
567 if (!pExitLstnr)
568 pExitLstnr = new LinguMgrExitLstnr;
570 xDicList = linguistic2::DictionaryList::create( getProcessComponentContext() );
571 return xDicList;
574 uno::Reference< linguistic2::XLinguProperties > LinguMgr::GetProp()
576 if (bExiting)
577 return nullptr;
579 if (!pExitLstnr)
580 pExitLstnr = new LinguMgrExitLstnr;
582 xProp = linguistic2::LinguProperties::create( getProcessComponentContext() );
583 return xProp;
586 uno::Reference< XDictionary > LinguMgr::GetIgnoreAll()
588 if (bExiting)
589 return nullptr;
591 if (!pExitLstnr)
592 pExitLstnr = new LinguMgrExitLstnr;
594 uno::Reference< XSearchableDictionaryList > xTmpDicList( GetDictionaryList() );
595 if (xTmpDicList.is())
597 std::locale loc(Translate::Create("svt"));
598 xIgnoreAll = xTmpDicList->getDictionaryByName(
599 Translate::get(STR_DESCRIPTION_IGNOREALLLIST, loc) );
601 return xIgnoreAll;
604 uno::Reference< XDictionary > LinguMgr::GetChangeAll()
606 if (bExiting)
607 return nullptr;
609 if (!pExitLstnr)
610 pExitLstnr = new LinguMgrExitLstnr;
612 uno::Reference< XSearchableDictionaryList > _xDicList = GetDictionaryList();
613 if (_xDicList.is())
615 xChangeAll = _xDicList->createDictionary(
616 "ChangeAllList",
617 LanguageTag::convertToLocale( LANGUAGE_NONE ),
618 DictionaryType_NEGATIVE, OUString() );
620 return xChangeAll;
623 uno::Reference< XDictionary > LinguMgr::GetStandard()
625 // Tries to return a dictionary which may hold positive entries is
626 // persistent and not read-only.
628 if (bExiting)
629 return nullptr;
631 uno::Reference< XSearchableDictionaryList > xTmpDicList( GetDictionaryList() );
632 if (!xTmpDicList.is())
633 return nullptr;
635 const OUString aDicName( "standard.dic" );
636 uno::Reference< XDictionary > xDic = xTmpDicList->getDictionaryByName( aDicName );
637 if (!xDic.is())
639 // try to create standard dictionary
640 uno::Reference< XDictionary > xTmp;
643 xTmp = xTmpDicList->createDictionary( aDicName,
644 LanguageTag::convertToLocale( LANGUAGE_NONE ),
645 DictionaryType_POSITIVE,
646 linguistic::GetWritableDictionaryURL( aDicName ) );
648 catch(const css::uno::Exception &)
652 // add new dictionary to list
653 if (xTmp.is())
655 xTmpDicList->addDictionary( xTmp );
656 xTmp->setActive( true );
658 xDic = xTmp;
660 #if OSL_DEBUG_LEVEL > 1
661 uno::Reference< XStorable > xStor( xDic, UNO_QUERY );
662 OSL_ENSURE( xDic.is() && xDic->getDictionaryType() == DictionaryType_POSITIVE,
663 "wrong dictionary type");
664 OSL_ENSURE( xDic.is() && LanguageTag( xDic->getLocale() ).getLanguageType() == LANGUAGE_NONE,
665 "wrong dictionary language");
666 OSL_ENSURE( !xStor.is() || (xStor->hasLocation() && !xStor->isReadonly()),
667 "dictionary not editable" );
668 #endif
670 return xDic;
673 SvxAlternativeSpelling SvxGetAltSpelling(
674 const css::uno::Reference< css::linguistic2::XHyphenatedWord > & rHyphWord )
676 SvxAlternativeSpelling aRes;
677 if (rHyphWord.is() && rHyphWord->isAlternativeSpelling())
679 OUString aWord( rHyphWord->getWord() ),
680 aAltWord( rHyphWord->getHyphenatedWord() );
681 sal_Int16 nHyphenationPos = rHyphWord->getHyphenationPos(),
682 nHyphenPos = rHyphWord->getHyphenPos();
683 sal_Int16 nLen = static_cast<sal_Int16>(aWord.getLength());
684 sal_Int16 nAltLen = static_cast<sal_Int16>(aAltWord.getLength());
685 const sal_Unicode *pWord = aWord.getStr(),
686 *pAltWord = aAltWord.getStr();
688 // count number of chars from the left to the
689 // hyphenation pos / hyphen pos that are equal
690 sal_Int16 nL = 0;
691 while (nL <= nHyphenationPos && nL <= nHyphenPos
692 && pWord[ nL ] == pAltWord[ nL ])
693 ++nL;
694 // count number of chars from the right to the
695 // hyphenation pos / hyphen pos that are equal
696 sal_Int16 nR = 0;
697 sal_Int32 nIdx = nLen - 1;
698 sal_Int32 nAltIdx = nAltLen - 1;
699 while (nIdx > nHyphenationPos && nAltIdx > nHyphenPos
700 && pWord[ nIdx-- ] == pAltWord[ nAltIdx-- ])
701 ++nR;
703 aRes.aReplacement = aAltWord.copy( nL, nAltLen - nL - nR );
704 aRes.nChangedPos = nL;
705 aRes.nChangedLength = nLen - nL - nR;
706 aRes.bIsAltSpelling = true;
708 return aRes;
712 SvxDicListChgClamp::SvxDicListChgClamp( uno::Reference< XSearchableDictionaryList > const &rxDicList ) :
713 xDicList ( rxDicList )
715 if (xDicList.is())
717 xDicList->beginCollectEvents();
721 SvxDicListChgClamp::~SvxDicListChgClamp()
723 if (xDicList.is())
725 xDicList->endCollectEvents();
729 short SvxDicError(weld::Window *pParent, linguistic::DictionaryError nError)
731 short nRes = 0;
732 if (linguistic::DictionaryError::NONE != nError)
734 const char* pRid;
735 switch (nError)
737 case linguistic::DictionaryError::FULL : pRid = RID_SVXSTR_DIC_ERR_FULL; break;
738 case linguistic::DictionaryError::READONLY : pRid = RID_SVXSTR_DIC_ERR_READONLY; break;
739 default:
740 pRid = RID_SVXSTR_DIC_ERR_UNKNOWN;
741 SAL_WARN("editeng", "unexpected case");
743 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pParent,
744 VclMessageType::Info, VclButtonsType::Ok,
745 EditResId(pRid)));
746 nRes = xInfoBox->run();
749 return nRes;
753 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */