1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <editeng/unolingu.hxx>
22 #include <unotools/pathoptions.hxx>
23 #include <com/sun/star/frame/Desktop.hpp>
24 #include <com/sun/star/frame/XModel.hpp>
25 #include <com/sun/star/frame/XStorable.hpp>
26 #include <com/sun/star/lang/XEventListener.hpp>
27 #include <com/sun/star/linguistic2/DictionaryList.hpp>
28 #include <com/sun/star/linguistic2/XAvailableLocales.hpp>
29 #include <com/sun/star/linguistic2/LinguServiceManager.hpp>
30 #include <com/sun/star/linguistic2/LinguProperties.hpp>
31 #include <com/sun/star/ucb/XAnyCompareFactory.hpp>
32 #include <com/sun/star/ucb/XContentAccess.hpp>
33 #include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
34 #include <com/sun/star/ucb/NumberedSortingInfo.hpp>
35 #include <com/sun/star/sdbc/XResultSet.hpp>
36 #include <com/sun/star/sdbc/XRow.hpp>
37 #include <com/sun/star/util/DateTime.hpp>
39 #include <comphelper/processfactory.hxx>
40 #include <cppuhelper/implbase1.hxx>
41 #include <i18nlangtag/languagetag.hxx>
42 #include <unotools/lingucfg.hxx>
43 #include <unotools/ucbhelper.hxx>
44 #include <unotools/localfilehelper.hxx>
45 #include <ucbhelper/commandenvironment.hxx>
46 #include <ucbhelper/content.hxx>
47 #include <vcl/msgbox.hxx>
48 #include <vcl/svapp.hxx>
49 #include <linguistic/misc.hxx>
50 #include <editeng/eerdll.hxx>
51 #include <editeng/editrids.hrc>
53 using namespace ::comphelper
;
54 using namespace ::linguistic
;
55 using namespace ::com::sun::star
;
56 using namespace ::com::sun::star::util
;
57 using namespace ::com::sun::star::uno
;
58 using namespace ::com::sun::star::lang
;
59 using namespace ::com::sun::star::beans
;
60 using namespace ::com::sun::star::frame
;
61 using namespace ::com::sun::star::linguistic2
;
63 static uno::Reference
< XLinguServiceManager2
> GetLngSvcMgr_Impl()
65 uno::Reference
< XComponentContext
> xContext
= comphelper::getProcessComponentContext();
66 uno::Reference
< XLinguServiceManager2
> xRes
= LinguServiceManager::create(xContext
);
70 //! Dummy implementation in order to avoid loading of lingu DLL
71 //! when only the XSupportedLocales interface is used.
72 //! The dummy accesses the real implementation (and thus loading the DLL)
73 //! when "real" work needs to be done only.
74 class ThesDummy_Impl
:
75 public cppu::WeakImplHelper1
< XThesaurus
>
77 uno::Reference
< XThesaurus
> xThes
; // the real one...
78 Sequence
< lang::Locale
> *pLocaleSeq
;
85 ThesDummy_Impl() : pLocaleSeq(0) {}
86 virtual ~ThesDummy_Impl();
89 virtual ::com::sun::star::uno::Sequence
<
90 ::com::sun::star::lang::Locale
> SAL_CALL
92 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
93 virtual sal_Bool SAL_CALL
94 hasLocale( const ::com::sun::star::lang::Locale
& rLocale
)
95 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
98 virtual ::com::sun::star::uno::Sequence
<
99 ::com::sun::star::uno::Reference
<
100 ::com::sun::star::linguistic2::XMeaning
> > SAL_CALL
101 queryMeanings( const OUString
& rTerm
,
102 const ::com::sun::star::lang::Locale
& rLocale
,
103 const ::com::sun::star::beans::PropertyValues
& rProperties
)
104 throw(::com::sun::star::lang::IllegalArgumentException
,
105 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
109 ThesDummy_Impl::~ThesDummy_Impl()
115 void ThesDummy_Impl::GetCfgLocales()
120 OUString
aNode("ServiceManager/ThesaurusList");
121 Sequence
< OUString
> aNodeNames( aCfg
.GetNodeNames( aNode
) );
122 const OUString
*pNodeNames
= aNodeNames
.getConstArray();
123 sal_Int32 nLen
= aNodeNames
.getLength();
124 pLocaleSeq
= new Sequence
< lang::Locale
>( nLen
);
125 lang::Locale
*pLocale
= pLocaleSeq
->getArray();
126 for (sal_Int32 i
= 0; i
< nLen
; ++i
)
128 pLocale
[i
] = LanguageTag::convertToLocaleWithFallback( pNodeNames
[i
] );
134 void ThesDummy_Impl::GetThes_Impl()
138 uno::Reference
< XLinguServiceManager2
> xLngSvcMgr( GetLngSvcMgr_Impl() );
139 xThes
= xLngSvcMgr
->getThesaurus();
143 // no longer needed...
144 delete pLocaleSeq
; pLocaleSeq
= 0;
150 uno::Sequence
< lang::Locale
> SAL_CALL
151 ThesDummy_Impl::getLocales()
152 throw(uno::RuntimeException
, std::exception
)
156 return xThes
->getLocales();
157 else if (!pLocaleSeq
) // if not already loaded save startup time by avoiding loading them now
164 ThesDummy_Impl::hasLocale( const lang::Locale
& rLocale
)
165 throw(uno::RuntimeException
, std::exception
)
169 return xThes
->hasLocale( rLocale
);
170 else if (!pLocaleSeq
) // if not already loaded save startup time by avoiding loading them now
173 sal_Int32 nLen
= pLocaleSeq
->getLength();
174 const lang::Locale
*pLocale
= pLocaleSeq
->getConstArray();
175 const lang::Locale
*pEnd
= pLocale
+ nLen
;
176 for ( ; pLocale
< pEnd
&& !bFound
; ++pLocale
)
178 bFound
= pLocale
->Language
== rLocale
.Language
&&
179 pLocale
->Country
== rLocale
.Country
&&
180 pLocale
->Variant
== rLocale
.Variant
;
186 uno::Sequence
< uno::Reference
< linguistic2::XMeaning
> > SAL_CALL
187 ThesDummy_Impl::queryMeanings(
188 const OUString
& rTerm
,
189 const lang::Locale
& rLocale
,
190 const beans::PropertyValues
& rProperties
)
191 throw(lang::IllegalArgumentException
,
192 uno::RuntimeException
, std::exception
)
195 uno::Sequence
< uno::Reference
< linguistic2::XMeaning
> > aRes
;
196 OSL_ENSURE( xThes
.is(), "Thesaurus missing" );
198 aRes
= xThes
->queryMeanings( rTerm
, rLocale
, rProperties
);
203 //! Dummy implementation in order to avoid loading of lingu DLL.
204 //! The dummy accesses the real implementation (and thus loading the DLL)
205 //! when it needs to be done only.
206 class SpellDummy_Impl
:
207 public cppu::WeakImplHelper1
< XSpellChecker1
>
209 uno::Reference
< XSpellChecker1
> xSpell
; // the real one...
211 void GetSpell_Impl();
215 // XSupportedLanguages (for XSpellChecker1)
216 virtual ::com::sun::star::uno::Sequence
< sal_Int16
> SAL_CALL
218 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
219 virtual sal_Bool SAL_CALL
220 hasLanguage( sal_Int16 nLanguage
)
221 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
223 // XSpellChecker1 (same as XSpellChecker but sal_Int16 for language)
224 virtual sal_Bool SAL_CALL
225 isValid( const OUString
& rWord
, sal_Int16 nLanguage
,
226 const ::com::sun::star::beans::PropertyValues
& rProperties
)
227 throw(::com::sun::star::lang::IllegalArgumentException
,
228 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
229 virtual ::com::sun::star::uno::Reference
<
230 ::com::sun::star::linguistic2::XSpellAlternatives
> SAL_CALL
231 spell( const OUString
& rWord
, sal_Int16 nLanguage
,
232 const ::com::sun::star::beans::PropertyValues
& rProperties
)
233 throw(::com::sun::star::lang::IllegalArgumentException
,
234 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
238 void SpellDummy_Impl::GetSpell_Impl()
242 uno::Reference
< XLinguServiceManager2
> xLngSvcMgr( GetLngSvcMgr_Impl() );
243 xSpell
= uno::Reference
< XSpellChecker1
>( xLngSvcMgr
->getSpellChecker(), UNO_QUERY
);
248 uno::Sequence
< sal_Int16
> SAL_CALL
249 SpellDummy_Impl::getLanguages()
250 throw(uno::RuntimeException
, std::exception
)
254 return xSpell
->getLanguages();
256 return uno::Sequence
< sal_Int16
>();
261 SpellDummy_Impl::hasLanguage( sal_Int16 nLanguage
)
262 throw(uno::RuntimeException
, std::exception
)
267 bRes
= xSpell
->hasLanguage( nLanguage
);
273 SpellDummy_Impl::isValid( const OUString
& rWord
, sal_Int16 nLanguage
,
274 const beans::PropertyValues
& rProperties
)
275 throw(lang::IllegalArgumentException
,
276 uno::RuntimeException
, std::exception
)
281 bRes
= xSpell
->isValid( rWord
, nLanguage
, rProperties
);
286 uno::Reference
< linguistic2::XSpellAlternatives
> SAL_CALL
287 SpellDummy_Impl::spell( const OUString
& rWord
, sal_Int16 nLanguage
,
288 const beans::PropertyValues
& rProperties
)
289 throw(lang::IllegalArgumentException
,
290 uno::RuntimeException
, std::exception
)
293 uno::Reference
< linguistic2::XSpellAlternatives
> xRes
;
295 xRes
= xSpell
->spell( rWord
, nLanguage
, rProperties
);
300 //! Dummy implementation in order to avoid loading of lingu DLL.
301 //! The dummy accesses the real implementation (and thus loading the DLL)
302 //! when it needs to be done only.
303 class HyphDummy_Impl
:
304 public cppu::WeakImplHelper1
< XHyphenator
>
306 uno::Reference
< XHyphenator
> xHyph
; // the real one...
313 virtual ::com::sun::star::uno::Sequence
<
314 ::com::sun::star::lang::Locale
> SAL_CALL
316 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
317 virtual sal_Bool SAL_CALL
318 hasLocale( const ::com::sun::star::lang::Locale
& rLocale
)
319 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
322 virtual ::com::sun::star::uno::Reference
<
323 ::com::sun::star::linguistic2::XHyphenatedWord
> SAL_CALL
324 hyphenate( const OUString
& rWord
,
325 const ::com::sun::star::lang::Locale
& rLocale
,
326 sal_Int16 nMaxLeading
,
327 const ::com::sun::star::beans::PropertyValues
& rProperties
)
328 throw(::com::sun::star::lang::IllegalArgumentException
,
329 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
330 virtual ::com::sun::star::uno::Reference
<
331 ::com::sun::star::linguistic2::XHyphenatedWord
> SAL_CALL
332 queryAlternativeSpelling( const OUString
& rWord
,
333 const ::com::sun::star::lang::Locale
& rLocale
,
335 const ::com::sun::star::beans::PropertyValues
& rProperties
)
336 throw(::com::sun::star::lang::IllegalArgumentException
,
337 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
338 virtual ::com::sun::star::uno::Reference
<
339 ::com::sun::star::linguistic2::XPossibleHyphens
> SAL_CALL
340 createPossibleHyphens(
341 const OUString
& rWord
,
342 const ::com::sun::star::lang::Locale
& rLocale
,
343 const ::com::sun::star::beans::PropertyValues
& rProperties
)
344 throw(::com::sun::star::lang::IllegalArgumentException
,
345 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
349 void HyphDummy_Impl::GetHyph_Impl()
353 uno::Reference
< XLinguServiceManager2
> xLngSvcMgr( GetLngSvcMgr_Impl() );
354 xHyph
= xLngSvcMgr
->getHyphenator();
359 uno::Sequence
< lang::Locale
> SAL_CALL
360 HyphDummy_Impl::getLocales()
361 throw(uno::RuntimeException
, std::exception
)
365 return xHyph
->getLocales();
367 return uno::Sequence
< lang::Locale
>();
372 HyphDummy_Impl::hasLocale( const lang::Locale
& rLocale
)
373 throw(uno::RuntimeException
, std::exception
)
378 bRes
= xHyph
->hasLocale( rLocale
);
383 uno::Reference
< linguistic2::XHyphenatedWord
> SAL_CALL
384 HyphDummy_Impl::hyphenate(
385 const OUString
& rWord
,
386 const lang::Locale
& rLocale
,
387 sal_Int16 nMaxLeading
,
388 const beans::PropertyValues
& rProperties
)
389 throw(lang::IllegalArgumentException
,
390 uno::RuntimeException
, std::exception
)
393 uno::Reference
< linguistic2::XHyphenatedWord
> xRes
;
395 xRes
= xHyph
->hyphenate( rWord
, rLocale
, nMaxLeading
, rProperties
);
400 uno::Reference
< linguistic2::XHyphenatedWord
> SAL_CALL
401 HyphDummy_Impl::queryAlternativeSpelling(
402 const OUString
& rWord
,
403 const lang::Locale
& rLocale
,
405 const PropertyValues
& rProperties
)
406 throw(lang::IllegalArgumentException
,
407 uno::RuntimeException
, std::exception
)
410 uno::Reference
< linguistic2::XHyphenatedWord
> xRes
;
412 xRes
= xHyph
->queryAlternativeSpelling( rWord
, rLocale
, nIndex
, rProperties
);
417 uno::Reference
< linguistic2::XPossibleHyphens
> SAL_CALL
418 HyphDummy_Impl::createPossibleHyphens(
419 const OUString
& rWord
,
420 const lang::Locale
& rLocale
,
421 const beans::PropertyValues
& rProperties
)
422 throw(lang::IllegalArgumentException
,
423 uno::RuntimeException
, std::exception
)
426 uno::Reference
< linguistic2::XPossibleHyphens
> xRes
;
428 xRes
= xHyph
->createPossibleHyphens( rWord
, rLocale
, rProperties
);
432 class LinguMgrExitLstnr
: public cppu::WeakImplHelper1
<XEventListener
>
434 uno::Reference
< XDesktop2
> xDesktop
;
436 static void AtExit();
440 virtual ~LinguMgrExitLstnr();
442 // lang::XEventListener
443 virtual void SAL_CALL
disposing(const EventObject
& rSource
)
444 throw( RuntimeException
, std::exception
) SAL_OVERRIDE
;
447 LinguMgrExitLstnr::LinguMgrExitLstnr()
449 // add object to frame::Desktop EventListeners in order to properly call
450 // the AtExit function at appliction exit.
452 uno::Reference
< XComponentContext
> xContext
= getProcessComponentContext();
453 xDesktop
= Desktop::create( xContext
);
454 xDesktop
->addEventListener( this );
457 LinguMgrExitLstnr::~LinguMgrExitLstnr()
461 xDesktop
->removeEventListener( this );
462 xDesktop
= NULL
; //! release reference to desktop
464 OSL_ENSURE(!xDesktop
.is(), "reference to desktop should be realeased");
467 void LinguMgrExitLstnr::disposing(const EventObject
& rSource
)
468 throw( RuntimeException
, std::exception
)
470 if (xDesktop
.is() && rSource
.Source
== xDesktop
)
472 xDesktop
->removeEventListener( this );
473 xDesktop
= NULL
; //! release reference to desktop
479 void LinguMgrExitLstnr::AtExit()
483 // release references
484 LinguMgr::xLngSvcMgr
= 0;
485 LinguMgr::xSpell
= 0;
488 LinguMgr::xDicList
= 0;
490 LinguMgr::xIgnoreAll
= 0;
491 LinguMgr::xChangeAll
= 0;
493 LinguMgr::bExiting
= true;
495 LinguMgr::pExitLstnr
= 0;
499 LinguMgrExitLstnr
* LinguMgr::pExitLstnr
= 0;
500 bool LinguMgr::bExiting
= false;
501 uno::Reference
< XLinguServiceManager2
> LinguMgr::xLngSvcMgr
= 0;
502 uno::Reference
< XSpellChecker1
> LinguMgr::xSpell
= 0;
503 uno::Reference
< XHyphenator
> LinguMgr::xHyph
= 0;
504 uno::Reference
< XThesaurus
> LinguMgr::xThes
= 0;
505 uno::Reference
< XSearchableDictionaryList
> LinguMgr::xDicList
= 0;
506 uno::Reference
< XLinguProperties
> LinguMgr::xProp
= 0;
507 uno::Reference
< XDictionary
> LinguMgr::xIgnoreAll
= 0;
508 uno::Reference
< XDictionary
> LinguMgr::xChangeAll
= 0;
511 uno::Reference
< XLinguServiceManager2
> LinguMgr::GetLngSvcMgr()
517 pExitLstnr
= new LinguMgrExitLstnr
;
519 if (!xLngSvcMgr
.is())
520 xLngSvcMgr
= GetLngSvcMgr_Impl();
526 uno::Reference
< XSpellChecker1
> LinguMgr::GetSpellChecker()
528 return xSpell
.is() ? xSpell
: GetSpell();
531 uno::Reference
< XHyphenator
> LinguMgr::GetHyphenator()
533 return xHyph
.is() ? xHyph
: GetHyph();
536 uno::Reference
< XThesaurus
> LinguMgr::GetThesaurus()
538 return xThes
.is() ? xThes
: GetThes();
541 uno::Reference
< XSearchableDictionaryList
> LinguMgr::GetDictionaryList()
543 return xDicList
.is() ? xDicList
: GetDicList();
546 uno::Reference
< linguistic2::XLinguProperties
> LinguMgr::GetLinguPropertySet()
548 return xProp
.is() ? xProp
: GetProp();
551 uno::Reference
< XDictionary
> LinguMgr::GetStandardDic()
553 //! don't hold reference to this
554 //! (it may be removed from dictionary list and needs to be
555 //! created empty if accessed again)
556 return GetStandard();
559 uno::Reference
< XDictionary
> LinguMgr::GetIgnoreAllList()
561 return xIgnoreAll
.is() ? xIgnoreAll
: GetIgnoreAll();
564 uno::Reference
< XDictionary
> LinguMgr::GetChangeAllList()
566 return xChangeAll
.is() ? xChangeAll
: GetChangeAll();
569 uno::Reference
< XSpellChecker1
> LinguMgr::GetSpell()
575 pExitLstnr
= new LinguMgrExitLstnr
;
577 //! use dummy implementation in order to avoid loading of lingu DLL
578 xSpell
= new SpellDummy_Impl
;
582 uno::Reference
< XHyphenator
> LinguMgr::GetHyph()
588 pExitLstnr
= new LinguMgrExitLstnr
;
590 //! use dummy implementation in order to avoid loading of lingu DLL
591 xHyph
= new HyphDummy_Impl
;
595 uno::Reference
< XThesaurus
> LinguMgr::GetThes()
601 pExitLstnr
= new LinguMgrExitLstnr
;
603 //! use dummy implementation in order to avoid loading of lingu DLL
604 //! when only the XSupportedLocales interface is used.
605 //! The dummy accesses the real implementation (and thus loading the DLL)
606 //! when "real" work needs to be done only.
607 xThes
= new ThesDummy_Impl
;
611 uno::Reference
< XSearchableDictionaryList
> LinguMgr::GetDicList()
617 pExitLstnr
= new LinguMgrExitLstnr
;
619 xDicList
= linguistic2::DictionaryList::create( getProcessComponentContext() );
623 uno::Reference
< linguistic2::XLinguProperties
> LinguMgr::GetProp()
629 pExitLstnr
= new LinguMgrExitLstnr
;
631 xProp
= linguistic2::LinguProperties::create( getProcessComponentContext() );
635 uno::Reference
< XDictionary
> LinguMgr::GetIgnoreAll()
641 pExitLstnr
= new LinguMgrExitLstnr
;
643 uno::Reference
< XSearchableDictionaryList
> xTmpDicList( GetDictionaryList() );
644 if (xTmpDicList
.is())
646 xIgnoreAll
= uno::Reference
< XDictionary
> ( xTmpDicList
->getDictionaryByName(
647 "IgnoreAllList" ), UNO_QUERY
);
652 uno::Reference
< XDictionary
> LinguMgr::GetChangeAll()
658 pExitLstnr
= new LinguMgrExitLstnr
;
660 uno::Reference
< XSearchableDictionaryList
> _xDicList( GetDictionaryList() , UNO_QUERY
);
663 xChangeAll
= uno::Reference
< XDictionary
> (
664 _xDicList
->createDictionary(
666 LanguageTag::convertToLocale( LANGUAGE_NONE
),
667 DictionaryType_NEGATIVE
, OUString() ), UNO_QUERY
);
672 uno::Reference
< XDictionary
> LinguMgr::GetStandard()
674 // Tries to return a dictionary which may hold positive entries is
675 // persistent and not read-only.
680 uno::Reference
< XSearchableDictionaryList
> xTmpDicList( GetDictionaryList() );
681 if (!xTmpDicList
.is())
684 const OUString
aDicName( "standard.dic" );
685 uno::Reference
< XDictionary
> xDic( xTmpDicList
->getDictionaryByName( aDicName
),
689 // try to create standard dictionary
690 uno::Reference
< XDictionary
> xTmp
;
693 xTmp
= xTmpDicList
->createDictionary( aDicName
,
694 LanguageTag::convertToLocale( LANGUAGE_NONE
),
695 DictionaryType_POSITIVE
,
696 linguistic::GetWritableDictionaryURL( aDicName
) );
698 catch(const com::sun::star::uno::Exception
&)
702 // add new dictionary to list
705 xTmpDicList
->addDictionary( xTmp
);
706 xTmp
->setActive( sal_True
);
708 xDic
= uno::Reference
< XDictionary
> ( xTmp
, UNO_QUERY
);
710 #if OSL_DEBUG_LEVEL > 1
711 uno::Reference
< XStorable
> xStor( xDic
, UNO_QUERY
);
712 OSL_ENSURE( xDic
.is() && xDic
->getDictionaryType() == DictionaryType_POSITIVE
,
713 "wrong dictionary type");
714 OSL_ENSURE( xDic
.is() && LanguageTag( xDic
->getLocale() ).getLanguageType() == LANGUAGE_NONE
,
715 "wrong dictionary language");
716 OSL_ENSURE( !xStor
.is() || (xStor
->hasLocation() && !xStor
->isReadonly()),
717 "dictionary not editable" );
723 uno::Reference
< XSpellChecker1
> SvxGetSpellChecker()
725 return LinguMgr::GetSpellChecker();
728 uno::Reference
< XHyphenator
> SvxGetHyphenator()
730 return LinguMgr::GetHyphenator();
733 uno::Reference
< XThesaurus
> SvxGetThesaurus()
735 return LinguMgr::GetThesaurus();
738 uno::Reference
< XSearchableDictionaryList
> SvxGetDictionaryList()
740 return LinguMgr::GetDictionaryList();
743 uno::Reference
< XLinguProperties
> SvxGetLinguPropertySet()
745 return LinguMgr::GetLinguPropertySet();
748 //TODO: remove argument or provide SvxGetIgnoreAllList with the same one
749 uno::Reference
< XDictionary
> SvxGetOrCreatePosDic(
750 uno::Reference
< XSearchableDictionaryList
> /* xDicList */ )
752 return LinguMgr::GetStandardDic();
755 uno::Reference
< XDictionary
> SvxGetIgnoreAllList()
757 return LinguMgr::GetIgnoreAllList();
760 uno::Reference
< XDictionary
> SvxGetChangeAllList()
762 return LinguMgr::GetChangeAllList();
765 #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
767 SvxAlternativeSpelling
SvxGetAltSpelling(
768 const ::com::sun::star::uno::Reference
<
769 ::com::sun::star::linguistic2::XHyphenatedWord
> & rHyphWord
)
771 SvxAlternativeSpelling aRes
;
772 if (rHyphWord
.is() && rHyphWord
->isAlternativeSpelling())
774 OUString
aWord( rHyphWord
->getWord() ),
775 aAltWord( rHyphWord
->getHyphenatedWord() );
776 sal_Int16 nHyphenationPos
= rHyphWord
->getHyphenationPos(),
777 nHyphenPos
= rHyphWord
->getHyphenPos();
778 sal_Int16 nLen
= (sal_Int16
)aWord
.getLength();
779 sal_Int16 nAltLen
= (sal_Int16
)aAltWord
.getLength();
780 const sal_Unicode
*pWord
= aWord
.getStr(),
781 *pAltWord
= aAltWord
.getStr();
783 // count number of chars from the left to the
784 // hyphenation pos / hyphen pos that are equal
786 while (nL
<= nHyphenationPos
&& nL
<= nHyphenPos
787 && pWord
[ nL
] == pAltWord
[ nL
])
789 // count number of chars from the right to the
790 // hyphenation pos / hyphen pos that are equal
792 sal_Int32 nIdx
= nLen
- 1;
793 sal_Int32 nAltIdx
= nAltLen
- 1;
794 while (nIdx
> nHyphenationPos
&& nAltIdx
> nHyphenPos
795 && pWord
[ nIdx
-- ] == pAltWord
[ nAltIdx
-- ])
798 aRes
.aReplacement
= OUString( aAltWord
.copy( nL
, nAltLen
- nL
- nR
) );
799 aRes
.nChangedPos
= (sal_Int16
) nL
;
800 aRes
.nChangedLength
= nLen
- nL
- nR
;
801 aRes
.bIsAltSpelling
= true;
802 aRes
.xHyphWord
= rHyphWord
;
808 SvxDicListChgClamp::SvxDicListChgClamp( uno::Reference
< XSearchableDictionaryList
> &rxDicList
) :
809 xDicList ( rxDicList
)
813 xDicList
->beginCollectEvents();
817 SvxDicListChgClamp::~SvxDicListChgClamp()
821 xDicList
->endCollectEvents();
825 short SvxDicError( vcl::Window
*pParent
, linguistic::DictionaryError nError
)
828 if (linguistic::DictionaryError::NONE
!= nError
)
833 case linguistic::DictionaryError::FULL
: nRid
= RID_SVXSTR_DIC_ERR_FULL
; break;
834 case linguistic::DictionaryError::READONLY
: nRid
= RID_SVXSTR_DIC_ERR_READONLY
; break;
836 nRid
= RID_SVXSTR_DIC_ERR_UNKNOWN
;
837 SAL_WARN("editeng", "unexpected case");
839 nRes
= ScopedVclPtr
<InfoBox
>::Create( pParent
, EE_RESSTR( nRid
) )->Execute();
845 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */