summaryrefslogtreecommitdiff
path: root/linguistic
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2008-12-15 12:01:46 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2008-12-15 12:01:46 +0000
commit4cd49d0d3f71d2162bcf50d0beecba2bc67a8e48 (patch)
tree8597e76338a51b35ce0555f8e7954e4dbffbbfdf /linguistic
parent308739bd5b6f8c59c84d00c71a139aced75035fa (diff)
CWS-TOOLING: integrate CWS tl56_DEV300
Diffstat (limited to 'linguistic')
-rw-r--r--linguistic/inc/iprcache.hxx67
-rw-r--r--linguistic/inc/lngprops.hxx6
-rw-r--r--linguistic/inc/misc.hxx3
-rw-r--r--linguistic/inc/spelldta.hxx32
-rw-r--r--linguistic/inc/supplang.hxx115
-rw-r--r--linguistic/qa/unoapi/knownissues.xcl3
-rw-r--r--linguistic/source/defs.hxx93
-rw-r--r--linguistic/source/dicimp.cxx19
-rw-r--r--linguistic/source/dicimp.hxx19
-rw-r--r--linguistic/source/dlistimp.cxx89
-rw-r--r--linguistic/source/dlistimp.hxx140
-rw-r--r--linguistic/source/gciterator.cxx536
-rw-r--r--linguistic/source/gciterator.hxx57
-rw-r--r--linguistic/source/hyphdsp.cxx189
-rw-r--r--linguistic/source/hyphdsp.hxx32
-rw-r--r--linguistic/source/iprcache.cxx294
-rw-r--r--linguistic/source/lngopt.cxx62
-rw-r--r--linguistic/source/lngopt.hxx128
-rw-r--r--linguistic/source/lngsvcmgr.cxx972
-rw-r--r--linguistic/source/lngsvcmgr.hxx116
-rw-r--r--linguistic/source/makefile.mk4
-rw-r--r--linguistic/source/misc.cxx28
-rw-r--r--linguistic/source/misc2.cxx2
-rw-r--r--linguistic/source/prophelp.cxx20
-rw-r--r--linguistic/source/spelldsp.cxx361
-rw-r--r--linguistic/source/spelldsp.hxx151
-rw-r--r--linguistic/source/spelldta.cxx21
-rw-r--r--linguistic/source/supplang.cxx161
-rw-r--r--linguistic/source/thesdsp.cxx77
-rw-r--r--linguistic/source/thesdsp.hxx42
30 files changed, 1638 insertions, 2201 deletions
diff --git a/linguistic/inc/iprcache.hxx b/linguistic/inc/iprcache.hxx
index 3e7ee03824..4305d7234a 100644
--- a/linguistic/inc/iprcache.hxx
+++ b/linguistic/inc/iprcache.hxx
@@ -32,24 +32,25 @@
#define _LINGUISTIC_IPRCACHE_HXX_
-#include <com/sun/star/uno/Reference.h>
-
#include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
#include <cppuhelper/implbase2.hxx> // helper for implementations
+
+#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/document/XEventListener.hpp>
#include <com/sun/star/beans/XPropertyChangeListener.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
-
#include <com/sun/star/linguistic2/XDictionaryListEventListener.hpp>
#include <com/sun/star/linguistic2/XDictionaryList.hpp>
-#include <tools/string.hxx>
+#include <rtl/string.hxx>
+#include <i18npool/lang.h>
+
+#include <set>
+#include <map>
namespace linguistic
{
-class IPRCachedWord;
-
///////////////////////////////////////////////////////////////////////////
class Flushable
@@ -83,33 +84,22 @@ public:
inline void SetFlushObj( Flushable *pFO) { pFlushObj = pFO; }
- void SetDicList(
- ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XDictionaryList > &rDL );
- void SetPropSet(
- ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > &rPS );
+ void SetDicList( ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryList > &rDL );
+ void SetPropSet( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &rPS );
//XEventListener
- virtual void SAL_CALL
- disposing( const ::com::sun::star::lang::EventObject& rSource )
- throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rSource ) throw(::com::sun::star::uno::RuntimeException);
// XDictionaryListEventListener
- virtual void SAL_CALL
- processDictionaryListEvent(
- const ::com::sun::star::linguistic2::DictionaryListEvent& rDicListEvent )
- throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL processDictionaryListEvent( const ::com::sun::star::linguistic2::DictionaryListEvent& rDicListEvent ) throw(::com::sun::star::uno::RuntimeException);
// XPropertyChangeListener
- virtual void SAL_CALL
- propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
- throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) throw(::com::sun::star::uno::RuntimeException);
};
///////////////////////////////////////////////////////////////////////////
-class IPRSpellCache :
+class SpellCache :
public Flushable
{
::com::sun::star::uno::Reference<
@@ -117,36 +107,23 @@ class IPRSpellCache :
xFlushLstnr;
FlushListener *pFlushLstnr;
- IPRCachedWord **ppHash;
- IPRCachedWord *pFirst;
- IPRCachedWord *pLast;
- IPRCachedWord *pRun;
- IPRCachedWord *pInput;
- ULONG nIndex;
- ULONG nCount;
- ULONG nInputPos;
- ULONG nInputValue;
- ULONG nTblSize;
-#ifdef DBG_STATISTIC
- ULONG nMaxInput;
- ULONG nMax;
- ULONG nFound;
- ULONG nLost;
-#endif
+ typedef std::set< ::rtl::OUString > WordList_t;
+ typedef std::map< LanguageType, WordList_t > LangWordList_t;
+ LangWordList_t aWordLists;
// don't allow to use copy-constructor and assignment-operator
- IPRSpellCache(const IPRSpellCache &);
- IPRSpellCache & operator = (const IPRSpellCache &);
+ SpellCache(const SpellCache &);
+ SpellCache & operator = (const SpellCache &);
public:
- IPRSpellCache( ULONG nSize );
- virtual ~IPRSpellCache();
+ SpellCache();
+ virtual ~SpellCache();
// Flushable
virtual void Flush();
- void AddWord( const String& rWord, INT16 nLang );
- BOOL CheckWord( const String& rWord, INT16 nLang, BOOL bAllLang );
+ void AddWord( const ::rtl::OUString& rWord, LanguageType nLang );
+ bool CheckWord( const ::rtl::OUString& rWord, LanguageType nLang );
};
///////////////////////////////////////////////////////////////////////////
diff --git a/linguistic/inc/lngprops.hxx b/linguistic/inc/lngprops.hxx
index 22bb62ec64..41052f9eb1 100644
--- a/linguistic/inc/lngprops.hxx
+++ b/linguistic/inc/lngprops.hxx
@@ -40,7 +40,7 @@
// WIDs for property names
//!! Don't change values! They are used as the property handles in
//!! the service description
-#define WID_IS_GERMAN_PRE_REFORM UPH_IS_GERMAN_PRE_REFORM
+#define WID_IS_GERMAN_PRE_REFORM UPH_IS_GERMAN_PRE_REFORM /*! deprecated !*/
#define WID_IS_USE_DICTIONARY_LIST UPH_IS_USE_DICTIONARY_LIST
#define WID_IS_IGNORE_CONTROL_CHARACTERS UPH_IS_IGNORE_CONTROL_CHARACTERS
#define WID_IS_SPELL_UPPER_CASE UPH_IS_SPELL_UPPER_CASE
@@ -51,8 +51,8 @@
#define WID_HYPH_MIN_WORD_LENGTH UPH_HYPH_MIN_WORD_LENGTH
#define WID_DEFAULT_LOCALE UPH_DEFAULT_LOCALE
#define WID_IS_SPELL_AUTO UPH_IS_SPELL_AUTO
-#define WID_IS_SPELL_HIDE UPH_IS_SPELL_HIDE
-#define WID_IS_SPELL_IN_ALL_LANGUAGES UPH_IS_SPELL_IN_ALL_LANGUAGES
+#define WID_IS_SPELL_HIDE UPH_IS_SPELL_HIDE /*! deprecated !*/
+#define WID_IS_SPELL_IN_ALL_LANGUAGES UPH_IS_SPELL_IN_ALL_LANGUAGES /*! deprecated !*/
#define WID_IS_SPELL_SPECIAL UPH_IS_SPELL_SPECIAL
#define WID_IS_HYPH_AUTO UPH_IS_HYPH_AUTO
#define WID_IS_HYPH_SPECIAL UPH_IS_HYPH_SPECIAL
diff --git a/linguistic/inc/misc.hxx b/linguistic/inc/misc.hxx
index c00c7b8721..9dfec44d94 100644
--- a/linguistic/inc/misc.hxx
+++ b/linguistic/inc/misc.hxx
@@ -64,7 +64,8 @@ namespace com { namespace sun { namespace star { namespace frame {
class LocaleDataWrapper;
///////////////////////////////////////////////////////////////////////////
-#define SN_GRAMMARCHECKER "com.sun.star.linguistic2.GrammarChecker"
+#define SN_GRAMMARCHECKER "com.sun.star.linguistic2.Proofreader"
+#define SN_GRAMMARCHECKINGITERATOR "com.sun.star.linguistic2.ProofreadingIterator"
#define SN_SPELLCHECKER "com.sun.star.linguistic2.SpellChecker"
#define SN_HYPHENATOR "com.sun.star.linguistic2.Hyphenator"
#define SN_THESAURUS "com.sun.star.linguistic2.Thesaurus"
diff --git a/linguistic/inc/spelldta.hxx b/linguistic/inc/spelldta.hxx
index cc445f3540..0d3022db7d 100644
--- a/linguistic/inc/spelldta.hxx
+++ b/linguistic/inc/spelldta.hxx
@@ -33,11 +33,12 @@
#include <vector>
#include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
+#include <com/sun/star/linguistic2/XSetSpellAlternatives.hpp>
#include <tools/solar.h>
#include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
-#include <cppuhelper/implbase1.hxx> // helper for implementations
+#include <cppuhelper/implbase2.hxx>
namespace com { namespace sun { namespace star {
namespace linguistic2 {
@@ -86,9 +87,10 @@ void SearchSimilarText( const rtl::OUString &rText, INT16 nLanguage,
class SpellAlternatives :
- public cppu::WeakImplHelper1
+ public cppu::WeakImplHelper2
<
- ::com::sun::star::linguistic2::XSpellAlternatives
+ ::com::sun::star::linguistic2::XSpellAlternatives,
+ ::com::sun::star::linguistic2::XSetSpellAlternatives
>
{
::com::sun::star::uno::Sequence< ::rtl::OUString > aAlt; // list of alternatives, may be empty.
@@ -109,21 +111,15 @@ public:
virtual ~SpellAlternatives();
// XSpellAlternatives
- virtual ::rtl::OUString SAL_CALL
- getWord()
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::lang::Locale SAL_CALL
- getLocale()
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int16 SAL_CALL
- getFailureType()
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int16 SAL_CALL
- getAlternativesCount()
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
- getAlternatives()
- throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getWord( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL getFailureType( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL getAlternativesCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAlternatives( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XSetSpellAlternatives
+ virtual void SAL_CALL setAlternatives( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aAlternatives ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFailureType( ::sal_Int16 nFailureType ) throw (::com::sun::star::uno::RuntimeException);
// non-interface specific functions
void SetWordLanguage(const ::rtl::OUString &rWord, INT16 nLang);
diff --git a/linguistic/inc/supplang.hxx b/linguistic/inc/supplang.hxx
deleted file mode 100644
index d421d74549..0000000000
--- a/linguistic/inc/supplang.hxx
+++ /dev/null
@@ -1,115 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: supplang.hxx,v $
- * $Revision: 1.5 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _LINGUISTIC_SUPPLANG_HXX_
-#define _LINGUISTIC_SUPPLANG_HXX_
-
-#include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
-#include <cppuhelper/implbase1.hxx> // helper for implementations
-
-
-#include <osl/mutex.hxx>
-#include <tools/string.hxx>
-#include <tools/table.hxx>
-#include <vcl/svapp.hxx>
-#include <osl/thread.h>
-#include <unotools/charclass.hxx>
-
-#include <com/sun/star/uno/Sequence.h>
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/beans/PropertyValues.hpp>
-#include <com/sun/star/frame/XTerminateListener.hpp>
-#include <com/sun/star/beans/PropertyValues.hpp>
-#include <com/sun/star/lang/Locale.hpp>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/linguistic2/XDictionaryEntry.hpp>
-#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
-
-namespace com { namespace sun { namespace star { namespace beans {
- class XPropertySet;
- class XFastPropertySet;
-}}}}
-
-namespace com { namespace sun { namespace star { namespace frame {
- class XDesktop;
-}}}}
-
-
-namespace linguistic
-{
-
-///////////////////////////////////////////////////////////////////////////
-
-// defines for actual state (availability) of languages
-#define LANG_NOT_AVAIL ((short) 0x0303)
-#define LANG_QUERY ((short) 0x5555)
-#define LANG_FAILED ((short) 0)
-#define LANG_OK ((short) 1)
-
-enum ModuleName { MOD_SPELL, MOD_HYPH, MOD_THES };
-
-struct LanguageState
-{
- INT16 nLanguage;
- INT16 nSpellState;
- INT16 nHyphState;
- INT16 nThesState;
-
- INT16 & GetState( ModuleName eModule );
-};
-
-LanguageState * GetLanguageState( INT16 nLanguage, LanguageState *pArray );
-
-///////////////////////////////////////////////////////////////////////////
-
-DECLARE_TABLE( SuppLangTable, INT16 * )
-
-class SuppLanguages
-{
- SuppLangTable aLanguages;
-
-protected:
- virtual INT16 CheckLanguage( INT16 nLanguage ) const = 0;
-
-public:
- SuppLanguages( LanguageState *pState, USHORT nCount );
- virtual ~SuppLanguages();
-
- BOOL HasLanguage( INT16 nLanguage ) const;
- const com::sun::star::uno::Sequence< INT16 >
- GetLanguages() const;
-};
-
-///////////////////////////////////////////////////////////////////////////
-
-} // namespace linguistic
-
-#endif
-
diff --git a/linguistic/qa/unoapi/knownissues.xcl b/linguistic/qa/unoapi/knownissues.xcl
index da4b986e54..a809c0f155 100644
--- a/linguistic/qa/unoapi/knownissues.xcl
+++ b/linguistic/qa/unoapi/knownissues.xcl
@@ -5,4 +5,5 @@ lng.LngSvcMgr
### i88538 ###
lng.DicList::com::sun::star::linguistic2::XSearchableDictionaryList
-
+### i96846 ###
+lng.LinguProperties::com::sun::star::linguistic2::LinguProperties
diff --git a/linguistic/source/defs.hxx b/linguistic/source/defs.hxx
index 601eee0a12..7068faae25 100644
--- a/linguistic/source/defs.hxx
+++ b/linguistic/source/defs.hxx
@@ -31,42 +31,99 @@
#ifndef _LINGUISTIC_DEFS_HXX_
#define _LINGUISTIC_DEFS_HXX_
+#include <com/sun/star/linguistic2/XSpellChecker.hpp>
+#include <com/sun/star/linguistic2/XProofreader.hpp>
+#include <com/sun/star/linguistic2/XHyphenator.hpp>
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+
///////////////////////////////////////////////////////////////////////////
#define A2OU(x) ::rtl::OUString::createFromAscii( x )
+namespace css = ::com::sun::star;
+
///////////////////////////////////////////////////////////////////////////
-struct SvcFlags
+struct LangSvcEntries
{
- INT16 nLastTriedSvcIndex; // index in sequence of the last
- // service tried to instantiate
- // (used for cascading)
- BOOL bAlreadyWarned : 1;
- BOOL bDoWarnAgain : 1;
-
- SvcFlags() :
- nLastTriedSvcIndex(-1), bAlreadyWarned(FALSE), bDoWarnAgain(FALSE)
+ css::uno::Sequence< ::rtl::OUString > aSvcImplNames;
+
+ sal_Int16 nLastTriedSvcIndex;
+ bool bAlreadyWarned;
+ bool bDoWarnAgain;
+
+ LangSvcEntries() : nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false) {}
+
+ inline LangSvcEntries( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) :
+ aSvcImplNames(rSvcImplNames),
+ nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false)
{
}
+
+ inline LangSvcEntries( const ::rtl::OUString &rSvcImplName ) :
+ nLastTriedSvcIndex(-1), bAlreadyWarned(false), bDoWarnAgain(false)
+ {
+ aSvcImplNames.realloc(1);
+ aSvcImplNames[0] = rSvcImplName;
+ }
+
+ bool IsAlreadyWarned() const { return bAlreadyWarned != 0; }
+ void SetAlreadyWarned( bool bVal ) { bAlreadyWarned = 0 != bVal; }
+ bool IsDoWarnAgain() const { return bDoWarnAgain != 0; }
+ void SetDoWarnAgain( bool bVal ) { bDoWarnAgain = 0 != bVal; }
+
+ inline void Clear()
+ {
+ aSvcImplNames.realloc(0);
+ nLastTriedSvcIndex = -1;
+ bAlreadyWarned = false;
+ bDoWarnAgain = false;
+ }
};
+struct LangSvcEntries_Spell : public LangSvcEntries
+{
+ css::uno::Sequence< css::uno::Reference< css::linguistic2::XSpellChecker > > aSvcRefs;
+
+ LangSvcEntries_Spell() : LangSvcEntries() {}
+ LangSvcEntries_Spell( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) : LangSvcEntries( rSvcImplNames ) {}
+};
+
+struct LangSvcEntries_Grammar : public LangSvcEntries
+{
+ css::uno::Sequence< css::uno::Reference< css::linguistic2::XProofreader > > aSvcRefs;
+
+ LangSvcEntries_Grammar() : LangSvcEntries() {}
+ LangSvcEntries_Grammar( const ::rtl::OUString &rSvcImplName ) : LangSvcEntries( rSvcImplName ) {}
+};
+
+struct LangSvcEntries_Hyph : public LangSvcEntries
+{
+ css::uno::Sequence< css::uno::Reference< css::linguistic2::XHyphenator > > aSvcRefs;
+
+ LangSvcEntries_Hyph() : LangSvcEntries() {}
+ LangSvcEntries_Hyph( const ::rtl::OUString &rSvcImplName ) : LangSvcEntries( rSvcImplName ) {}
+};
+
+struct LangSvcEntries_Thes : public LangSvcEntries
+{
+ css::uno::Sequence< css::uno::Reference< css::linguistic2::XThesaurus > > aSvcRefs;
+
+ LangSvcEntries_Thes() : LangSvcEntries() {}
+ LangSvcEntries_Thes( const css::uno::Sequence< ::rtl::OUString > &rSvcImplNames ) : LangSvcEntries( rSvcImplNames ) {}
+};
+
///////////////////////////////////////////////////////////////////////////
// virtual base class for the different dispatchers
class LinguDispatcher
{
public:
- enum DspType { DSP_SPELL, DSP_HYPH, DSP_THES };
+ enum DspType { DSP_SPELL, DSP_HYPH, DSP_THES, DSP_GRAMMAR };
- virtual void
- SetServiceList( const ::com::sun::star::lang::Locale &rLocale,
- const ::com::sun::star::uno::Sequence<
- rtl::OUString > &rSvcImplNames ) = 0;
- virtual ::com::sun::star::uno::Sequence< rtl::OUString >
- GetServiceList( const ::com::sun::star::lang::Locale &rLocale ) const = 0;
- virtual DspType
- GetDspType() const = 0;
+ virtual void SetServiceList( const css::lang::Locale &rLocale, const css::uno::Sequence< rtl::OUString > &rSvcImplNames ) = 0;
+ virtual css::uno::Sequence< rtl::OUString > GetServiceList( const css::lang::Locale &rLocale ) const = 0;
+ virtual DspType GetDspType() const = 0;
};
///////////////////////////////////////////////////////////////////////////
diff --git a/linguistic/source/dicimp.cxx b/linguistic/source/dicimp.cxx
index 2481c29406..e894e7e80c 100644
--- a/linguistic/source/dicimp.cxx
+++ b/linguistic/source/dicimp.cxx
@@ -805,7 +805,7 @@ sal_Bool SAL_CALL DictionaryNeo::isActive( )
return bIsActive;
}
-sal_Int16 SAL_CALL DictionaryNeo::getCount( )
+sal_Int32 SAL_CALL DictionaryNeo::getCount( )
throw(RuntimeException)
{
MutexGuard aGuard( GetLinguMutex() );
@@ -827,21 +827,7 @@ void SAL_CALL DictionaryNeo::setLocale( const Locale& aLocale )
throw(RuntimeException)
{
MutexGuard aGuard( GetLinguMutex() );
- setLanguage( LocaleToLanguage( aLocale ) );
-}
-
-sal_Int16 SAL_CALL DictionaryNeo::getLanguage( )
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
- return nLanguage;
-}
-
-void SAL_CALL DictionaryNeo::setLanguage( sal_Int16 nLanguageP )
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
+ INT16 nLanguageP = LocaleToLanguage( aLocale );
if (!bIsReadonly && nLanguage != nLanguageP)
{
nLanguage = nLanguageP;
@@ -851,7 +837,6 @@ void SAL_CALL DictionaryNeo::setLanguage( sal_Int16 nLanguageP )
}
}
-
uno::Reference< XDictionaryEntry > SAL_CALL DictionaryNeo::getEntry(
const OUString& aWord )
throw(RuntimeException)
diff --git a/linguistic/source/dicimp.hxx b/linguistic/source/dicimp.hxx
index 763e29067d..ab60c94f97 100644
--- a/linguistic/source/dicimp.hxx
+++ b/linguistic/source/dicimp.hxx
@@ -31,13 +31,12 @@
#ifndef _LINGUISTIC_DICIMP_HXX_
#define _LINGUISTIC_DICIMP_HXX_
-#include <com/sun/star/linguistic2/XDictionary1.hpp>
#include <com/sun/star/linguistic2/XDictionary.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
-#include <cppuhelper/implbase3.hxx> // helper for implementations
+#include <cppuhelper/implbase2.hxx> // helper for implementations
#include <cppuhelper/implbase1.hxx> // helper for implementations
#include <cppuhelper/interfacecontainer.h>
#include <tools/string.hxx>
@@ -48,7 +47,7 @@
///////////////////////////////////////////////////////////////////////////
-#define DIC_MAX_ENTRIES 2000
+#define DIC_MAX_ENTRIES 30000
INT16 ReadDicVersion( SvStream *pStream, USHORT &nLng, BOOL &bNeg );
const String GetDicExtension();
@@ -56,9 +55,8 @@ const String GetDicExtension();
///////////////////////////////////////////////////////////////////////////
class DictionaryNeo :
- public ::cppu::WeakImplHelper3
+ public ::cppu::WeakImplHelper2
<
- ::com::sun::star::linguistic2::XDictionary1,
::com::sun::star::linguistic2::XDictionary,
::com::sun::star::frame::XStorable
>
@@ -116,15 +114,6 @@ public:
setName( const ::rtl::OUString& aName )
throw(::com::sun::star::uno::RuntimeException);
- // XDictionary1 (same as XDictionary but for sal_Int16 as language)
- // only the different ones are listed
- virtual sal_Int16 SAL_CALL
- getLanguage()
- throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- setLanguage( sal_Int16 nLang )
- throw(::com::sun::star::uno::RuntimeException);
-
// XDictionary
virtual ::com::sun::star::linguistic2::DictionaryType SAL_CALL
getDictionaryType()
@@ -135,7 +124,7 @@ public:
virtual sal_Bool SAL_CALL
isActive()
throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int16 SAL_CALL
+ virtual sal_Int32 SAL_CALL
getCount()
throw(::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::lang::Locale SAL_CALL
diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx
index ab81c5813b..0436504c2b 100644
--- a/linguistic/source/dlistimp.cxx
+++ b/linguistic/source/dlistimp.cxx
@@ -63,10 +63,6 @@ using namespace linguistic;
///////////////////////////////////////////////////////////////////////////
-SV_IMPL_OBJARR(ActDicArray, ActDic);
-
-///////////////////////////////////////////////////////////////////////////
-
static BOOL IsVers2OrNewer( const String& rFileURL, USHORT& nLng, BOOL& bNeg );
static void AddInternal( const uno::Reference< XDictionary > &rDic,
@@ -303,12 +299,12 @@ void DicList::MyAppExitListener::AtExit()
DicList::DicList() :
- aEvtListeners ( GetLinguMutex() ),
- pDicList( 0 )
+ aEvtListeners ( GetLinguMutex() )
{
pDicEvtLstnrHelper = new DicEvtListenerHelper( this );
xDicEvtLstnrHelper = pDicEvtLstnrHelper;
bDisposing = FALSE;
+ bInCreation = FALSE;
pExitListener = new MyAppExitListener( *this );
xExitListener = pExitListener;
@@ -318,12 +314,11 @@ DicList::DicList() :
DicList::~DicList()
{
pExitListener->Deactivate();
- delete pDicList;
}
-void DicList::searchForDictionaries(
- ActDicArray &rDicList,
+void DicList::SearchForDictionaries(
+ DictionaryVec_t&rDicList,
const String &rDicDirURL,
BOOL bIsWriteablePath )
{
@@ -366,11 +361,11 @@ void DicList::searchForDictionaries(
if (STRING_NOTFOUND != nPos)
aTmp1 = aTmp1.Copy( nPos + 1 );
String aTmp2;
- USHORT j;
- USHORT nCount = rDicList.Count();
+ size_t j;
+ size_t nCount = rDicList.size();
for(j = 0; j < nCount; j++)
{
- aTmp2 = rDicList.GetObject( j ).xDic->getName().getStr();
+ aTmp2 = rDicList[j]->getName().getStr();
aTmp2 = ToLower( aTmp2, nSystemLanguage );
if(aTmp1 == aTmp2)
break;
@@ -394,16 +389,16 @@ void DicList::searchForDictionaries(
}
-INT32 DicList::getDicPos(const uno::Reference< XDictionary > &xDic)
+INT32 DicList::GetDicPos(const uno::Reference< XDictionary > &xDic)
{
osl::MutexGuard aGuard( GetLinguMutex() );
INT32 nPos = -1;
- ActDicArray& rDicList = GetDicList();
- USHORT n = rDicList.Count();
- for (USHORT i = 0; i < n; i++)
+ DictionaryVec_t& rDicList = GetOrCreateDicList();
+ size_t n = rDicList.size();
+ for (size_t i = 0; i < n; i++)
{
- if ( rDicList.GetObject(i).xDic == xDic )
+ if ( rDicList[i] == xDic )
return i;
}
return nPos;
@@ -421,7 +416,7 @@ uno::Reference< XInterface > SAL_CALL
sal_Int16 SAL_CALL DicList::getCount() throw(RuntimeException)
{
osl::MutexGuard aGuard( GetLinguMutex() );
- return GetDicList().Count();
+ return static_cast< sal_Int16 >(GetOrCreateDicList().size());
}
uno::Sequence< uno::Reference< XDictionary > > SAL_CALL
@@ -430,14 +425,14 @@ uno::Sequence< uno::Reference< XDictionary > > SAL_CALL
{
osl::MutexGuard aGuard( GetLinguMutex() );
- ActDicArray& rDicList = GetDicList();
+ DictionaryVec_t& rDicList = GetOrCreateDicList();
- uno::Sequence< uno::Reference< XDictionary > > aDics( rDicList.Count() );
+ uno::Sequence< uno::Reference< XDictionary > > aDics( rDicList.size() );
uno::Reference< XDictionary > *pDic = aDics.getArray();
- USHORT n = (USHORT) aDics.getLength();
- for (USHORT i = 0; i < n; i++)
- pDic[i] = rDicList.GetObject(i).xDic;
+ INT32 n = (USHORT) aDics.getLength();
+ for (INT32 i = 0; i < n; i++)
+ pDic[i] = rDicList[i];
return aDics;
}
@@ -449,11 +444,11 @@ uno::Reference< XDictionary > SAL_CALL
osl::MutexGuard aGuard( GetLinguMutex() );
uno::Reference< XDictionary > xDic;
- ActDicArray& rDicList = GetDicList();
- USHORT nCount = rDicList.Count();
- for (USHORT i = 0; i < nCount; i++)
+ DictionaryVec_t& rDicList = GetOrCreateDicList();
+ size_t nCount = rDicList.size();
+ for (size_t i = 0; i < nCount; i++)
{
- const uno::Reference< XDictionary > &rDic = rDicList.GetObject(i).xDic;
+ const uno::Reference< XDictionary > &rDic = rDicList[i];
if (rDic.is() && rDic->getName() == aDictionaryName)
{
xDic = rDic;
@@ -476,8 +471,8 @@ sal_Bool SAL_CALL DicList::addDictionary(
BOOL bRes = FALSE;
if (xDictionary.is())
{
- ActDicArray& rDicList = GetDicList();
- rDicList.Insert( ActDic(xDictionary), rDicList.Count() );
+ DictionaryVec_t& rDicList = GetOrCreateDicList();
+ rDicList.push_back( xDictionary );
bRes = TRUE;
// add listener helper to the dictionaries listener lists
@@ -496,12 +491,12 @@ sal_Bool SAL_CALL
return FALSE;
BOOL bRes = FALSE;
- INT32 nPos = getDicPos( xDictionary );
+ INT32 nPos = GetDicPos( xDictionary );
if (nPos >= 0)
{
// remove dictionary list from the dictionaries listener lists
- ActDicArray& rDicList = GetDicList();
- uno::Reference< XDictionary > xDic( rDicList.GetObject( (USHORT) nPos ).xDic );
+ DictionaryVec_t& rDicList = GetOrCreateDicList();
+ uno::Reference< XDictionary > xDic( rDicList[ nPos ] );
DBG_ASSERT(xDic.is(), "lng : empty reference");
if (xDic.is())
{
@@ -511,7 +506,8 @@ sal_Bool SAL_CALL
xDic->removeDictionaryEventListener( xDicEvtLstnrHelper );
}
- rDicList.Remove( (USHORT) nPos );
+ // remove element at nPos
+ rDicList.erase( rDicList.begin() + nPos );
bRes = TRUE;
}
return bRes;
@@ -613,13 +609,13 @@ void SAL_CALL
pDicEvtLstnrHelper->DisposeAndClear( aEvtObj );
//! avoid creation of dictionaries if not already done
- if (pDicList)
+ if (aDicList.size() > 0)
{
- ActDicArray& rDicList = GetDicList();
- INT16 nCount = rDicList.Count();
- for (INT16 i = 0; i < nCount; i++)
+ DictionaryVec_t& rDicList = GetOrCreateDicList();
+ size_t nCount = rDicList.size();
+ for (size_t i = 0; i < nCount; i++)
{
- uno::Reference< XDictionary > xDic( rDicList.GetObject(i).xDic , UNO_QUERY );
+ uno::Reference< XDictionary > xDic( rDicList[i], UNO_QUERY );
// save (modified) dictionaries
uno::Reference< frame::XStorable > xStor( xDic , UNO_QUERY );
@@ -666,7 +662,7 @@ void SAL_CALL
void DicList::_CreateDicList()
{
- pDicList = new ActDicArray;
+ bInCreation = TRUE;
// look for dictionaries
const rtl::OUString aWriteablePath( GetDictionaryWriteablePath() );
@@ -675,7 +671,7 @@ void DicList::_CreateDicList()
for (sal_Int32 i = 0; i < aPaths.getLength(); ++i)
{
const BOOL bIsWriteablePath = (pPaths[i] == aWriteablePath);
- searchForDictionaries( *pDicList, pPaths[i], bIsWriteablePath );
+ SearchForDictionaries( aDicList, pPaths[i], bIsWriteablePath );
}
// create IgnoreAllList dictionary with empty URL (non persistent)
@@ -717,6 +713,8 @@ void DicList::_CreateDicList()
pDicEvtLstnrHelper->ClearEvents();
pDicEvtLstnrHelper->EndCollectEvents();
+
+ bInCreation = FALSE;
}
@@ -724,16 +722,15 @@ void DicList::SaveDics()
{
// save dics only if they have already been used/created.
//! don't create them just for the purpose of saving them !
- if (pDicList)
+ if (aDicList.size() > 0)
{
// save (modified) dictionaries
- ActDicArray& rDicList = GetDicList();
- USHORT nCount = rDicList.Count();;
- for (USHORT i = 0; i < nCount; i++)
+ DictionaryVec_t& rDicList = GetOrCreateDicList();
+ size_t nCount = rDicList.size();;
+ for (size_t i = 0; i < nCount; i++)
{
// save (modified) dictionaries
- uno::Reference< frame::XStorable > xStor( rDicList.GetObject(i).xDic,
- UNO_QUERY );
+ uno::Reference< frame::XStorable > xStor( rDicList[i], UNO_QUERY );
if (xStor.is())
{
try
diff --git a/linguistic/source/dlistimp.hxx b/linguistic/source/dlistimp.hxx
index d42520be0c..2ef1544629 100644
--- a/linguistic/source/dlistimp.hxx
+++ b/linguistic/source/dlistimp.hxx
@@ -39,9 +39,11 @@
#include <cppuhelper/implbase1.hxx> // helper for implementations
#include <cppuhelper/implbase3.hxx> // helper for implementations
#include <cppuhelper/interfacecontainer.h>
-#include <svtools/svarray.hxx>
#include <tools/debug.hxx>
+#include <vector>
+#include <memory>
+
#include "misc.hxx"
#include "lngopt.hxx"
@@ -49,18 +51,6 @@ class DicEvtListenerHelper;
///////////////////////////////////////////////////////////////////////////
-class ActDic
-{
-public:
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XDictionary > xDic;
-
- ActDic() {}
- ActDic(const ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XDictionary > &rDic) : xDic(rDic) {}
-};
-SV_DECL_OBJARR( ActDicArray, ActDic, 16, 16 )
-
class DicList :
public cppu::WeakImplHelper3
<
@@ -81,7 +71,9 @@ class DicList :
LinguOptions aOpt;
::cppu::OInterfaceContainerHelper aEvtListeners;
- ActDicArray* pDicList;
+
+ typedef std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > > DictionaryVec_t;
+ DictionaryVec_t aDicList;
::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::
XDictionaryEventListener > xDicEvtLstnrHelper;
@@ -92,24 +84,25 @@ class DicList :
MyAppExitListener *pExitListener;
BOOL bDisposing;
+ BOOL bInCreation;
// disallow copy-constructor and assignment-operator for now
DicList( const DicList & );
DicList & operator = (const DicList &);
- void _CreateDicList();
- ActDicArray& GetDicList()
+ void _CreateDicList();
+ DictionaryVec_t & GetOrCreateDicList()
{
- if( !pDicList )
+ if (!bInCreation && aDicList.size() == 0)
_CreateDicList();
- return *pDicList;
+ return aDicList;
}
- void launchEvent(INT16 nEvent, com::sun::star::uno::Sequence<
+ void LaunchEvent(INT16 nEvent, com::sun::star::uno::Sequence<
::com::sun::star::linguistic2::XDictionary > xDic);
- void searchForDictionaries( ActDicArray &rDicList,
+ void SearchForDictionaries( DictionaryVec_t &rDicList,
const String &rDicDir, BOOL bIsWritePath );
- INT32 getDicPos(const com::sun::star::uno::Reference<
+ INT32 GetDicPos(const com::sun::star::uno::Reference<
::com::sun::star::linguistic2::XDictionary > &xDic);
public:
@@ -117,95 +110,34 @@ public:
virtual ~DicList();
// XDictionaryList
- virtual sal_Int16 SAL_CALL
- getCount()
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XDictionary > > SAL_CALL
- getDictionaries()
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XDictionary > SAL_CALL
- getDictionaryByName( const ::rtl::OUString& aDictionaryName )
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL
- addDictionary( const ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XDictionary >& xDictionary )
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL
- removeDictionary( const ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XDictionary >& xDictionary )
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL
- addDictionaryListEventListener( const ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XDictionaryListEventListener >& xListener,
- sal_Bool bReceiveVerbose )
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL
- removeDictionaryListEventListener(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XDictionaryListEventListener >& xListener )
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int16 SAL_CALL
- beginCollectEvents()
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int16 SAL_CALL
- endCollectEvents()
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Int16 SAL_CALL
- flushEvents()
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XDictionary > SAL_CALL
- createDictionary( const ::rtl::OUString& aName,
- const ::com::sun::star::lang::Locale& aLocale,
- ::com::sun::star::linguistic2::DictionaryType eDicType,
- const ::rtl::OUString& aURL )
- throw(::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > > SAL_CALL getDictionaries( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > SAL_CALL getDictionaryByName( const ::rtl::OUString& aDictionaryName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL addDictionary( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary >& xDictionary ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL removeDictionary( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary >& xDictionary ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL addDictionaryListEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryListEventListener >& xListener, ::sal_Bool bReceiveVerbose ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL removeDictionaryListEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryListEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL beginCollectEvents( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL endCollectEvents( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL flushEvents( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > SAL_CALL createDictionary( const ::rtl::OUString& aName, const ::com::sun::star::lang::Locale& aLocale, ::com::sun::star::linguistic2::DictionaryType eDicType, const ::rtl::OUString& aURL ) throw (::com::sun::star::uno::RuntimeException);
// XSearchableDictionaryList
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XDictionaryEntry > SAL_CALL
- queryDictionaryEntry( const ::rtl::OUString& aWord,
- const ::com::sun::star::lang::Locale& aLocale,
- sal_Bool bSearchPosDics, sal_Bool bSpellEntry )
- throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryEntry > SAL_CALL queryDictionaryEntry( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, sal_Bool bSearchPosDics, sal_Bool bSpellEntry ) throw(::com::sun::star::uno::RuntimeException);
// XComponent
- virtual void SAL_CALL
- dispose()
- throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- addEventListener( const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >& xListener )
- throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- removeEventListener( const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >& aListener )
- throw(::com::sun::star::uno::RuntimeException);
-
-
- ////////////////////////////////////////////////////////////
- // Service specific part
- //
+ virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
// XServiceInfo
- virtual ::rtl::OUString SAL_CALL
- getImplementationName()
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL
- supportsService( const ::rtl::OUString& ServiceName )
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
- getSupportedServiceNames()
- throw(::com::sun::star::uno::RuntimeException);
-
-
- static inline ::rtl::OUString
- getImplementationName_Static() throw();
- static com::sun::star::uno::Sequence< ::rtl::OUString >
- getSupportedServiceNames_Static() throw();
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+
+ static inline ::rtl::OUString getImplementationName_Static() throw();
+ static com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
// non UNO-specific
void SaveDics();
diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 4d70a84429..4f555aeef8 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -39,15 +39,17 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/linguistic2/XSupportedLocales.hpp>
-#include <com/sun/star/linguistic2/XGrammarChecker.hpp>
-#include <com/sun/star/linguistic2/XGrammarCheckingIterator.hpp>
-#include <com/sun/star/linguistic2/SingleGrammarError.hpp>
-#include <com/sun/star/linguistic2/GrammarCheckingResult.hpp>
+#include <com/sun/star/linguistic2/XProofreader.hpp>
+#include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
+#include <com/sun/star/linguistic2/SingleProofreadingError.hpp>
+#include <com/sun/star/linguistic2/ProofreadingResult.hpp>
#include <com/sun/star/linguistic2/LinguServiceEvent.hpp>
#include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp>
#include <com/sun/star/registry/XRegistryKey.hpp>
#include <com/sun/star/text/TextMarkupType.hpp>
+#include <com/sun/star/text/TextMarkupDescriptor.hpp>
#include <com/sun/star/text/XTextMarkup.hpp>
+#include <com/sun/star/text/XMultiTextMarkup.hpp>
#include <com/sun/star/text/XFlatParagraph.hpp>
#include <com/sun/star/text/XFlatParagraphIterator.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -76,6 +78,7 @@
#include "gciterator.hxx"
using ::rtl::OUString;
+using namespace linguistic;
using namespace ::com::sun::star;
// forward declarations
@@ -85,6 +88,149 @@ static uno::Sequence< OUString > GrammarCheckingIterator_getSupportedServiceName
//////////////////////////////////////////////////////////////////////
+// white space list: obtained from the fonts.config.txt of a Linux system.
+static sal_Unicode aWhiteSpaces[] =
+{
+ 0x0020, /* SPACE */
+ 0x00a0, /* NO-BREAK SPACE */
+ 0x00ad, /* SOFT HYPHEN */
+ 0x115f, /* HANGUL CHOSEONG FILLER */
+ 0x1160, /* HANGUL JUNGSEONG FILLER */
+ 0x1680, /* OGHAM SPACE MARK */
+ 0x2000, /* EN QUAD */
+ 0x2001, /* EM QUAD */
+ 0x2002, /* EN SPACE */
+ 0x2003, /* EM SPACE */
+ 0x2004, /* THREE-PER-EM SPACE */
+ 0x2005, /* FOUR-PER-EM SPACE */
+ 0x2006, /* SIX-PER-EM SPACE */
+ 0x2007, /* FIGURE SPACE */
+ 0x2008, /* PUNCTUATION SPACE */
+ 0x2009, /* THIN SPACE */
+ 0x200a, /* HAIR SPACE */
+ 0x200b, /* ZERO WIDTH SPACE */
+ 0x200c, /* ZERO WIDTH NON-JOINER */
+ 0x200d, /* ZERO WIDTH JOINER */
+ 0x200e, /* LEFT-TO-RIGHT MARK */
+ 0x200f, /* RIGHT-TO-LEFT MARK */
+ 0x2028, /* LINE SEPARATOR */
+ 0x2029, /* PARAGRAPH SEPARATOR */
+ 0x202a, /* LEFT-TO-RIGHT EMBEDDING */
+ 0x202b, /* RIGHT-TO-LEFT EMBEDDING */
+ 0x202c, /* POP DIRECTIONAL FORMATTING */
+ 0x202d, /* LEFT-TO-RIGHT OVERRIDE */
+ 0x202e, /* RIGHT-TO-LEFT OVERRIDE */
+ 0x202f, /* NARROW NO-BREAK SPACE */
+ 0x205f, /* MEDIUM MATHEMATICAL SPACE */
+ 0x2060, /* WORD JOINER */
+ 0x2061, /* FUNCTION APPLICATION */
+ 0x2062, /* INVISIBLE TIMES */
+ 0x2063, /* INVISIBLE SEPARATOR */
+ 0x206A, /* INHIBIT SYMMETRIC SWAPPING */
+ 0x206B, /* ACTIVATE SYMMETRIC SWAPPING */
+ 0x206C, /* INHIBIT ARABIC FORM SHAPING */
+ 0x206D, /* ACTIVATE ARABIC FORM SHAPING */
+ 0x206E, /* NATIONAL DIGIT SHAPES */
+ 0x206F, /* NOMINAL DIGIT SHAPES */
+ 0x3000, /* IDEOGRAPHIC SPACE */
+ 0x3164, /* HANGUL FILLER */
+ 0xfeff, /* ZERO WIDTH NO-BREAK SPACE */
+ 0xffa0, /* HALFWIDTH HANGUL FILLER */
+ 0xfff9, /* INTERLINEAR ANNOTATION ANCHOR */
+ 0xfffa, /* INTERLINEAR ANNOTATION SEPARATOR */
+ 0xfffb /* INTERLINEAR ANNOTATION TERMINATOR */
+};
+
+static int nWhiteSpaces = sizeof( aWhiteSpaces ) / sizeof( aWhiteSpaces[0] );
+
+static bool lcl_IsWhiteSpace( sal_Unicode cChar )
+{
+ bool bFound = false;
+ for (int i = 0; i < nWhiteSpaces && !bFound; ++i)
+ {
+ if (cChar == aWhiteSpaces[i])
+ bFound = true;
+ }
+ return bFound;
+}
+
+static sal_Int32 lcl_SkipWhiteSpaces( const OUString &rText, sal_Int32 nStartPos )
+{
+ // note having nStartPos point right behind the string is OK since that one
+ // is a correct end-of-sentence position to be returned from a grammar checker...
+
+ const sal_Int32 nLen = rText.getLength();
+ bool bIllegalArgument = false;
+ if (nStartPos < 0)
+ {
+ bIllegalArgument = true;
+ nStartPos = 0;
+ }
+ if (nStartPos > nLen)
+ {
+ bIllegalArgument = true;
+ nStartPos = nLen;
+ }
+ if (bIllegalArgument)
+ {
+ DBG_ASSERT( 0, "lcl_SkipWhiteSpaces: illegal arguments" );
+ }
+
+ sal_Int32 nRes = nStartPos;
+ if (0 <= nStartPos && nStartPos < nLen)
+ {
+ const sal_Unicode *pText = rText.getStr() + nStartPos;
+ while (nStartPos < nLen && lcl_IsWhiteSpace( *pText ))
+ ++pText;
+ nRes = pText - rText.getStr();
+ }
+
+ DBG_ASSERT( 0 <= nRes && nRes <= nLen, "lcl_SkipWhiteSpaces return value out of range" );
+ return nRes;
+}
+
+static sal_Int32 lcl_BacktraceWhiteSpaces( const OUString &rText, sal_Int32 nStartPos )
+{
+ // note having nStartPos point right behind the string is OK since that one
+ // is a correct end-of-sentence position to be returned from a grammar checker...
+
+ const sal_Int32 nLen = rText.getLength();
+ bool bIllegalArgument = false;
+ if (nStartPos < 0)
+ {
+ bIllegalArgument = true;
+ nStartPos = 0;
+ }
+ if (nStartPos > nLen)
+ {
+ bIllegalArgument = true;
+ nStartPos = nLen;
+ }
+ if (bIllegalArgument)
+ {
+ DBG_ASSERT( 0, "lcl_BacktraceWhiteSpaces: illegal arguments" );
+ }
+
+ sal_Int32 nRes = nStartPos;
+ sal_Int32 nPosBefore = nStartPos - 1;
+ const sal_Unicode *pStart = rText.getStr();
+ if (0 <= nPosBefore && nPosBefore < nLen && lcl_IsWhiteSpace( pStart[ nPosBefore ] ))
+ nStartPos = nPosBefore;
+ if (0 <= nStartPos && nStartPos < nLen)
+ {
+ const sal_Unicode *pText = rText.getStr() + nStartPos;
+ while (pText > pStart && lcl_IsWhiteSpace( *pText ))
+ --pText;
+ // now add 1 since we wnat to point to the first char after the last char in the sentence...
+ nRes = pText - pStart + 1;
+ }
+
+ DBG_ASSERT( 0 <= nRes && nRes <= nLen, "lcl_BacktraceWhiteSpaces return value out of range" );
+ return nRes;
+}
+
+//////////////////////////////////////////////////////////////////////
+
extern "C" void workerfunc (void * gci)
{
((GrammarCheckingIterator*)gci)->DequeueAndCheck();
@@ -133,13 +279,12 @@ void stopGrammarChecking ()
GrammarCheckingIterator::GrammarCheckingIterator( const uno::Reference< lang::XMultiServiceFactory > & rxMgr ) :
m_xMSF( rxMgr ),
m_bEnd( sal_False ),
+ m_aCurCheckedDocId(),
m_bGCServicesChecked( sal_False ),
m_nDocIdCounter( 0 ),
- m_nCurCheckedDocId( - 1 ),
m_nLastEndOfSentencePos( -1 ),
- m_aMutex(),
- m_aEventListeners( m_aMutex ),
- m_aNotifyListeners( m_aMutex )
+ m_aEventListeners( MyMutex::get() ),
+ m_aNotifyListeners( MyMutex::get() )
{
osl_createThread( workerfunc, this );
}
@@ -147,46 +292,47 @@ GrammarCheckingIterator::GrammarCheckingIterator( const uno::Reference< lang::XM
GrammarCheckingIterator::~GrammarCheckingIterator()
{
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
}
sal_Int32 GrammarCheckingIterator::NextDocId()
{
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
m_nDocIdCounter += 1;
return m_nDocIdCounter;
}
-sal_Int32 GrammarCheckingIterator::GetOrCreateDocId(
+OUString GrammarCheckingIterator::GetOrCreateDocId(
const uno::Reference< lang::XComponent > &xComponent )
{
// internal method; will always be called with locked mutex
- sal_Int32 nRes = -1;
+ OUString aRes;
if (xComponent.is())
{
- if (m_aDocIdMap.find( xComponent ) != m_aDocIdMap.end())
+ if (m_aDocIdMap.find( xComponent.get() ) != m_aDocIdMap.end())
{
- // add new entry
- nRes = m_aDocIdMap[ xComponent ];
- xComponent->addEventListener( this );
+ // return already existing entry
+ aRes = m_aDocIdMap[ xComponent.get() ];
}
- else // return already existing entry
+ else // add new entry
{
- nRes = NextDocId();
- m_aDocIdMap[ xComponent ] = nRes;
+ sal_Int32 nRes = NextDocId();
+ aRes = OUString::valueOf( nRes );
+ m_aDocIdMap[ xComponent.get() ] = aRes;
+ xComponent->addEventListener( this );
}
}
- return nRes;
+ return aRes;
}
void GrammarCheckingIterator::AddEntry(
uno::WeakReference< text::XFlatParagraphIterator > xFlatParaIterator,
uno::WeakReference< text::XFlatParagraph > xFlatPara,
- sal_Int32 nDocId,
+ const OUString & rDocId,
sal_Int32 nStartIndex,
sal_Bool bAutomatic )
{
@@ -198,12 +344,12 @@ void GrammarCheckingIterator::AddEntry(
FPEntry aNewFPEntry;
aNewFPEntry.m_xParaIterator = xFlatParaIterator;
aNewFPEntry.m_xPara = xFlatPara;
- aNewFPEntry.m_nDocId = nDocId;
+ aNewFPEntry.m_aDocId = rDocId;
aNewFPEntry.m_nStartIndex = nStartIndex;
aNewFPEntry.m_bAutomatic = bAutomatic;
// add new entry to the end of this queue
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
m_aFPEntriesQueue.push_back( aNewFPEntry );
// wake up the thread in order to do grammar checking
@@ -213,13 +359,12 @@ void GrammarCheckingIterator::AddEntry(
void GrammarCheckingIterator::ProcessResult(
- const linguistic2::GrammarCheckingResult &rRes,
- sal_Int32 nSentenceStartPos,
+ const linguistic2::ProofreadingResult &rRes,
const uno::Reference< text::XFlatParagraphIterator > &rxFlatParagraphIterator,
bool bIsAutomaticChecking )
{
DBG_ASSERT( rRes.xFlatParagraph.is(), "xFlatParagraph is missing" );
-
+ //no guard necessary as no members are used
sal_Bool bContinueWithNextPara = sal_False;
if (!rRes.xFlatParagraph.is() || rRes.xFlatParagraph->isModified())
{
@@ -228,38 +373,73 @@ void GrammarCheckingIterator::ProcessResult(
}
else // paragraph is still unchanged...
{
+ //
// mark found errors...
- bool bBoundariesOk = 0 <= nSentenceStartPos && nSentenceStartPos <= rRes.nEndOfSentencePos;
+ //
+
+ sal_Int32 nTextLen = rRes.aText.getLength();
+ bool bBoundariesOk = 0 <= rRes.nStartOfSentencePosition && rRes.nStartOfSentencePosition <= nTextLen &&
+ 0 <= rRes.nBehindEndOfSentencePosition && rRes.nBehindEndOfSentencePosition <= nTextLen &&
+ 0 <= rRes.nStartOfNextSentencePosition && rRes.nStartOfNextSentencePosition <= nTextLen &&
+ rRes.nStartOfSentencePosition <= rRes.nBehindEndOfSentencePosition &&
+ rRes.nBehindEndOfSentencePosition <= rRes.nStartOfNextSentencePosition;
+ (void) bBoundariesOk;
DBG_ASSERT( bBoundariesOk, "inconsistent sentence boundaries" );
- uno::Sequence< linguistic2::SingleGrammarError > aErrors = rRes.aGrammarErrors;
- if (aErrors.getLength() > 0 && bBoundariesOk)
+ uno::Sequence< linguistic2::SingleProofreadingError > aErrors = rRes.aErrors;
+
+ uno::Reference< text::XMultiTextMarkup > xMulti( rRes.xFlatParagraph, uno::UNO_QUERY );
+ if (xMulti.is()) // use new API for markups
{
- for (sal_Int16 i = 0; i < aErrors.getLength(); ++i)
+ try
{
- linguistic2::SingleGrammarError aError = aErrors[aErrors.getLength() - 1 - i];
+ // length = number of found errors + 1 sentence markup
+ sal_Int32 nErrors = rRes.aErrors.getLength();
+ uno::Sequence< text::TextMarkupDescriptor > aDescriptors( nErrors + 1 );
+ text::TextMarkupDescriptor * pDescriptors = aDescriptors.getArray();
- OUString aIdentifier;
- uno::Reference< container::XStringKeyMap > xStringKeyMap;
-
- // display the grammar error mark
- rRes.xFlatParagraph->commitTextMarkup( aError.nErrorType, aIdentifier, aError.nErrorStart, aError.nErrorLength, xStringKeyMap );
-
- // commit sentence markup to identify sentence boundaries
- const sal_Int32 nSentenceLength = rRes.nEndOfSentencePos - nSentenceStartPos;
- rRes.xFlatParagraph->commitTextMarkup( text::TextMarkupType::SENTENCE, aIdentifier, nSentenceStartPos, nSentenceLength, xStringKeyMap );
+ // at pos 0 .. nErrors-1 -> all grammar errors
+ for (sal_Int32 i = 0; i < nErrors; ++i)
+ {
+ const linguistic2::SingleProofreadingError &rError = rRes.aErrors[i];
+ text::TextMarkupDescriptor &rDesc = aDescriptors[i];
+
+ rDesc.nType = rError.nErrorType;
+ rDesc.nOffset = rError.nErrorStart;
+ rDesc.nLength = rError.nErrorLength;
+
+ // the proofreader may return SPELLING but right now our core
+ // does only handle PROOFREADING if the result is from the proofreader...
+ // (later on we may wish to color spelling errors found by the proofreader
+ // differently for example. But no special handling right now.
+ if (rDesc.nType == text::TextMarkupType::SPELLCHECK)
+ rDesc.nType = text::TextMarkupType::PROOFREADING;
+ }
+
+ // at pos nErrors -> sentence markup
+ // nSentenceLength: includes the white-spaces following the sentence end...
+ const sal_Int32 nSentenceLength = rRes.nStartOfNextSentencePosition - rRes.nStartOfSentencePosition;
+ pDescriptors[ nErrors ].nType = text::TextMarkupType::SENTENCE;
+ pDescriptors[ nErrors ].nOffset = rRes.nStartOfSentencePosition;
+ pDescriptors[ nErrors ].nLength = nSentenceLength;
+
+ xMulti->commitMultiTextMarkup( aDescriptors ) ;
}
- }
+ catch (lang::IllegalArgumentException &)
+ {
+ DBG_ERROR( "commitMultiTextMarkup: IllegalArgumentException exception caught" );
+ }
+ }
// other sentences left to be checked in this paragraph?
- if (rRes.nEndOfSentencePos < rRes.aText.getLength())
+ if (rRes.nStartOfNextSentencePosition < rRes.aText.getLength())
{
- AddEntry( rxFlatParagraphIterator, rRes.xFlatParagraph, rRes.nDocumentId, rRes.nEndOfSentencePos, bIsAutomaticChecking );
+ AddEntry( rxFlatParagraphIterator, rRes.xFlatParagraph, rRes.aDocumentIdentifier, rRes.nStartOfNextSentencePosition, bIsAutomaticChecking );
}
else // current paragraph finished
{
// set "already checked" flag for the current flat paragraph
if (rRes.xFlatParagraph.is())
- rRes.xFlatParagraph->setChecked( text::TextMarkupType::GRAMMAR, true );
+ rRes.xFlatParagraph->setChecked( text::TextMarkupType::PROOFREADING, true );
bContinueWithNextPara = sal_True;
}
@@ -272,27 +452,27 @@ void GrammarCheckingIterator::ProcessResult(
if (rxFlatParagraphIterator.is())
xFlatParaNext = rxFlatParagraphIterator->getNextPara();
{
- AddEntry( rxFlatParagraphIterator, xFlatParaNext, rRes.nDocumentId, 0, bIsAutomaticChecking );
+ AddEntry( rxFlatParagraphIterator, xFlatParaNext, rRes.aDocumentIdentifier, 0, bIsAutomaticChecking );
}
}
}
-uno::Reference< linguistic2::XGrammarChecker > GrammarCheckingIterator::GetGrammarChecker(
+uno::Reference< linguistic2::XProofreader > GrammarCheckingIterator::GetGrammarChecker(
const lang::Locale &rLocale )
{
(void) rLocale;
- uno::Reference< linguistic2::XGrammarChecker > xRes;
+ uno::Reference< linguistic2::XProofreader > xRes;
// ---- THREAD SAFE START ----
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
// check supported locales for each grammarchecker if not already done
if (!m_bGCServicesChecked)
{
//GetAvailableGCSvcs_Impl();
- //GetConfiguredGCSvcs_Impl();
- GetMatchingGCSvcs_Impl();
+ GetConfiguredGCSvcs_Impl();
+ //GetMatchingGCSvcs_Impl();
m_bGCServicesChecked = sal_True;
}
@@ -312,7 +492,7 @@ uno::Reference< linguistic2::XGrammarChecker > GrammarCheckingIterator::GetGramm
{
uno::Reference< lang::XMultiServiceFactory > xMgr(
utl::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
- uno::Reference< linguistic2::XGrammarChecker > xGC(
+ uno::Reference< linguistic2::XProofreader > xGC(
xMgr->createInstance( aSvcImplName ), uno::UNO_QUERY_THROW );
uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xGC, uno::UNO_QUERY_THROW );
@@ -350,7 +530,7 @@ void GrammarCheckingIterator::DequeueAndCheck()
// ---- THREAD SAFE START ----
bool bEnd = false;
{
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
bEnd = m_bEnd;
}
// ---- THREAD SAFE END ----
@@ -359,7 +539,7 @@ void GrammarCheckingIterator::DequeueAndCheck()
// ---- THREAD SAFE START ----
bool bQueueEmpty = false;
{
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
bQueueEmpty = m_aFPEntriesQueue.empty();
}
// ---- THREAD SAFE END ----
@@ -369,16 +549,16 @@ void GrammarCheckingIterator::DequeueAndCheck()
uno::Reference< text::XFlatParagraphIterator > xFPIterator;
uno::Reference< text::XFlatParagraph > xFlatPara;
FPEntry aFPEntryItem;
- sal_Int32 nCurDocId = - 1;
+ OUString aCurDocId;
sal_Bool bModified = sal_False;
// ---- THREAD SAFE START ----
{
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
aFPEntryItem = m_aFPEntriesQueue.front();
xFPIterator = aFPEntryItem.m_xParaIterator;
xFlatPara = aFPEntryItem.m_xPara;
- m_nCurCheckedDocId = aFPEntryItem.m_nDocId;
- nCurDocId = m_nCurCheckedDocId;
+ m_aCurCheckedDocId = aFPEntryItem.m_aDocId;
+ aCurDocId = m_aCurCheckedDocId;
m_aFPEntriesQueue.pop_front();
}
@@ -393,33 +573,39 @@ void GrammarCheckingIterator::DequeueAndCheck()
if (!bModified)
{
// ---- THREAD SAFE START ----
- ::osl::ClearableGuard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::ClearableGuard< ::osl::Mutex > aGuard( MyMutex::get() );
sal_Int32 nStartPos = aFPEntryItem.m_nStartIndex;
sal_Int32 nSuggestedEnd = GetSuggestedEndOfSentence( aCurTxt, nStartPos, aCurLocale );
- linguistic2::GrammarCheckingResult aRes;
+ linguistic2::ProofreadingResult aRes;
- uno::Reference< linguistic2::XGrammarChecker > xGC( GetGrammarChecker( aCurLocale ), uno::UNO_QUERY );
+ uno::Reference< linguistic2::XProofreader > xGC( GetGrammarChecker( aCurLocale ), uno::UNO_QUERY );
if (xGC.is())
{
aGuard.clear();
- aRes = xGC->doGrammarChecking( nCurDocId, aCurTxt, aCurLocale, nStartPos, nSuggestedEnd, aLangPortions, aLangPortionsLocale );
+ uno::Sequence< beans::PropertyValue > aEmptyProps;
+ aRes = xGC->doProofreading( aCurDocId, aCurTxt, aCurLocale, nStartPos, nSuggestedEnd, aEmptyProps );
aRes.xFlatParagraph = xFlatPara;
- aRes.nStartOfSentencePos = nStartPos;
+ aRes.nStartOfSentencePosition = nStartPos;
}
else
{
// no grammar checker -> no error
// but we need to provide the data below in order to continue with the next sentence
- aRes.nDocumentId = nCurDocId;
+ aRes.aDocumentIdentifier = aCurDocId;
aRes.xFlatParagraph = xFlatPara;
aRes.aText = aCurTxt;
aRes.aLocale = aCurLocale;
- aRes.nStartOfSentencePos = nStartPos;
- aRes.nEndOfSentencePos = nSuggestedEnd;
- }
- ProcessResult( aRes, nStartPos, xFPIterator, aFPEntryItem.m_bAutomatic );
+ aRes.nStartOfSentencePosition = nStartPos;
+ aRes.nBehindEndOfSentencePosition = nSuggestedEnd;
+ }
+ aRes.nStartOfNextSentencePosition = lcl_SkipWhiteSpaces( aCurTxt, aRes.nBehindEndOfSentencePosition );
+ aRes.nBehindEndOfSentencePosition = lcl_BacktraceWhiteSpaces( aCurTxt, aRes.nStartOfNextSentencePosition );
+
+ //guard has to be cleared as ProcessResult calls out of this class
+ aGuard.clear();
+ ProcessResult( aRes, xFPIterator, aFPEntryItem.m_bAutomatic );
// ---- THREAD SAFE END ----
}
else
@@ -427,14 +613,14 @@ void GrammarCheckingIterator::DequeueAndCheck()
// the paragraph changed meanwhile... (and maybe is still edited)
// thus we simply continue to ask for the next to be checked.
uno::Reference< text::XFlatParagraph > xFlatParaNext( xFPIterator->getNextPara() );
- AddEntry( xFPIterator, xFlatParaNext, nCurDocId, 0, aFPEntryItem.m_bAutomatic );
+ AddEntry( xFPIterator, xFlatParaNext, aCurDocId, 0, aFPEntryItem.m_bAutomatic );
}
}
// ---- THREAD SAFE START ----
{
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
- m_nCurCheckedDocId = -1;
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
+ m_aCurCheckedDocId = OUString();
}
// ---- THREAD SAFE END ----
}
@@ -442,7 +628,7 @@ void GrammarCheckingIterator::DequeueAndCheck()
{
// ---- THREAD SAFE START ----
{
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
// Check queue state again
if (m_aFPEntriesQueue.empty())
m_aWakeUpThread.reset();
@@ -459,7 +645,7 @@ void GrammarCheckingIterator::DequeueAndCheck()
// ---- THREAD SAFE START ----
{
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
bEnd = m_bEnd;
}
// ---- THREAD SAFE END ----
@@ -470,32 +656,32 @@ void GrammarCheckingIterator::DequeueAndCheck()
}
-void SAL_CALL GrammarCheckingIterator::startGrammarChecking(
+void SAL_CALL GrammarCheckingIterator::startProofreading(
const uno::Reference< ::uno::XInterface > & xDoc,
- const uno::Reference< text::XFlatParagraphIteratorProvider > & xIteratorProvider,
- sal_Bool bAutomatic)
+ const uno::Reference< text::XFlatParagraphIteratorProvider > & xIteratorProvider )
throw (uno::RuntimeException, lang::IllegalArgumentException)
{
// get paragraph to start checking with
+ const bool bAutomatic = true;
uno::Reference<text::XFlatParagraphIterator> xFPIterator = xIteratorProvider->getFlatParagraphIterator(
- text::TextMarkupType::GRAMMAR, bAutomatic );
+ text::TextMarkupType::PROOFREADING, bAutomatic );
uno::Reference< text::XFlatParagraph > xPara( xFPIterator.is()? xFPIterator->getFirstPara() : NULL );
uno::Reference< lang::XComponent > xComponent( xDoc, uno::UNO_QUERY );
// ---- THREAD SAFE START ----
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
if (xPara.is() && xComponent.is())
{
- sal_Int32 nDocId = GetOrCreateDocId( xComponent );
+ OUString aDocId = GetOrCreateDocId( xComponent );
// create new entry and add it to queue
- AddEntry( xFPIterator, xPara, nDocId, 0, bAutomatic );
+ AddEntry( xFPIterator, xPara, aDocId, 0, bAutomatic );
}
// ---- THREAD SAFE END ----
}
-linguistic2::GrammarCheckingResult SAL_CALL GrammarCheckingIterator::checkGrammarAtPos(
+linguistic2::ProofreadingResult SAL_CALL GrammarCheckingIterator::checkSentenceAtPosition(
const uno::Reference< uno::XInterface >& xDoc,
const uno::Reference< text::XFlatParagraph >& xFlatPara,
const OUString& rText,
@@ -509,30 +695,28 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
// for the context menu...
- linguistic2::GrammarCheckingResult aRes;
+ linguistic2::ProofreadingResult aRes;
uno::Reference< lang::XComponent > xComponent( xDoc, uno::UNO_QUERY );
if (xFlatPara.is() && xComponent.is() &&
( nErrorPosInPara < 0 || nErrorPosInPara < rText.getLength()))
{
- uno::Sequence< sal_Int32 > aLangPortions;
- uno::Sequence< lang::Locale > aLangPortionsLocale;
-
// iterate through paragraph until we find the sentence we are interested in
- linguistic2::GrammarCheckingResult aTmpRes;
- sal_Int32 nStartPos = nErrorPosInPara > 0 ? 0 : nStartOfSentencePos;
+ linguistic2::ProofreadingResult aTmpRes;
+ sal_Int32 nStartPos = nStartOfSentencePos >= 0 ? nStartOfSentencePos : 0;
+
bool bFound = false;
do
{
lang::Locale aCurLocale = lcl_GetPrimaryLanguageOfSentence( xFlatPara, nStartPos );
sal_Int32 nOldStartOfSentencePos = nStartPos;
- uno::Reference< linguistic2::XGrammarChecker > xGC;
- sal_Int32 nDocId = -1;
+ uno::Reference< linguistic2::XProofreader > xGC;
+ OUString aDocId;
// ---- THREAD SAFE START ----
{
- ::osl::ClearableGuard< ::osl::Mutex > aGuard( m_aMutex );
- nDocId = GetOrCreateDocId( xComponent );
+ ::osl::ClearableGuard< ::osl::Mutex > aGuard( MyMutex::get() );
+ aDocId = GetOrCreateDocId( xComponent );
nSuggestedEndOfSentencePos = GetSuggestedEndOfSentence( rText, nStartPos, aCurLocale );
xGC = GetGrammarChecker( aCurLocale );
@@ -541,17 +725,21 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
sal_Int32 nEndPos = -1;
if (xGC.is())
{
- aTmpRes = xGC->doGrammarChecking( nDocId, rText, aCurLocale, nStartPos, nSuggestedEndOfSentencePos, aLangPortions, aLangPortionsLocale );
- aTmpRes.xFlatParagraph = xFlatPara;
- aTmpRes.nStartOfSentencePos = nStartPos;
- nEndPos = aTmpRes.nEndOfSentencePos;
+ uno::Sequence< beans::PropertyValue > aEmptyProps;
+ aTmpRes = xGC->doProofreading( aDocId, rText, aCurLocale, nStartPos, nSuggestedEndOfSentencePos, aEmptyProps );
+ aTmpRes.xFlatParagraph = xFlatPara;
+ aTmpRes.nStartOfSentencePosition = nStartPos;
+ nEndPos = aTmpRes.nBehindEndOfSentencePosition;
if ((nErrorPosInPara< 0 || nStartPos <= nErrorPosInPara) && nErrorPosInPara < nEndPos)
bFound = true;
}
if (nEndPos == -1) // no result from grammar checker
nEndPos = nSuggestedEndOfSentencePos;
- nStartPos = nEndPos;
+ nStartPos = lcl_SkipWhiteSpaces( rText, nEndPos );
+ aTmpRes.nBehindEndOfSentencePosition = nEndPos;
+ aTmpRes.nStartOfNextSentencePosition = nStartPos;
+ aTmpRes.nBehindEndOfSentencePosition = lcl_BacktraceWhiteSpaces( rText, aTmpRes.nStartOfNextSentencePosition );
// prevent endless loop by forcefully advancing if needs be...
if (nStartPos <= nOldStartOfSentencePos)
@@ -592,6 +780,9 @@ sal_Int32 GrammarCheckingIterator::GetSuggestedEndOfSentence(
nEndPosition = nTextLen;
if (nTmpStartPos < nTextLen)
nEndPosition = m_xBreakIterator->endOfSentence( rText, nTmpStartPos, rLocale );
+ if (nEndPosition < 0)
+ nEndPosition = nTextLen;
+
++nTmpStartPos;
}
while (nEndPosition <= nSentenceStartPos && nEndPosition < nTextLen);
@@ -602,44 +793,59 @@ sal_Int32 GrammarCheckingIterator::GetSuggestedEndOfSentence(
}
-sal_Int32 SAL_CALL GrammarCheckingIterator::getEndOfSentence(
- const uno::Reference< text::XFlatParagraph >& xFlatPara,
- sal_Int32 nSentenceStartPos )
-throw (lang::IllegalArgumentException, uno::RuntimeException)
+void SAL_CALL GrammarCheckingIterator::resetIgnoreRules( )
+throw (uno::RuntimeException)
{
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
- (void) xFlatPara;
- (void)nSentenceStartPos;
- return 0;
+ GCReferences_t::iterator aIt( m_aGCReferencesByService.begin() );
+ while (aIt != m_aGCReferencesByService.end())
+ {
+ uno::Reference< linguistic2::XProofreader > xGC( aIt->second );
+ if (xGC.is())
+ xGC->resetIgnoreRules();
+ ++aIt;
+ }
}
+
-
-sal_Bool SAL_CALL GrammarCheckingIterator::isGrammarChecking(
- const uno::Reference< uno::XInterface >& xDoc,
- sal_Bool bAutomatic )
+sal_Bool SAL_CALL GrammarCheckingIterator::isProofreading(
+ const uno::Reference< uno::XInterface >& xDoc )
throw (uno::RuntimeException)
{
// ---- THREAD SAFE START ----
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
- (void) bAutomatic;
sal_Bool bRes = sal_False;
uno::Reference< lang::XComponent > xComponent( xDoc, uno::UNO_QUERY );
if (xComponent.is())
{
- sal_Int32 nDocId = m_aDocIdMap[ xComponent ];
- if (m_nCurCheckedDocId >= 0 && m_nCurCheckedDocId == nDocId)
- bRes = sal_True;
- else if (m_aDocIdMap.find( xComponent ) != m_aDocIdMap.end())
+ // if the component was already used in one of the two calls to check text
+ // i.e. in startGrammarChecking or checkGrammarAtPos it will be found in the
+ // m_aDocIdMap unless the document already disposed.
+ // If it is not found then it is not yet being checked (or requested to being checked)
+ const DocMap_t::const_iterator aIt( m_aDocIdMap.find( xComponent.get() ) );
+ if (aIt != m_aDocIdMap.end())
{
- sal_Int32 nSize = m_aFPEntriesQueue.size();
- for (sal_Int32 i = 0; i < nSize && !bRes; ++i)
+ // check in document is checked automatically in the background...
+ OUString aDocId = aIt->second;
+ if (m_aCurCheckedDocId.getLength() > 0 && m_aCurCheckedDocId == aDocId)
{
- if (nDocId == m_aFPEntriesQueue[i].m_nDocId /*&& m_aFPEntriesQueue[i].m_bAutomatic == bAutomatic*/)
- bRes = sal_True;
+ // an entry for that document was dequed and is currently being checked.
+ bRes = sal_True;
}
- }
+ else
+ {
+ // we need to check if there is an entry for that document in the queue...
+ // That is the document is going to be checked sooner or later.
+
+ sal_Int32 nSize = m_aFPEntriesQueue.size();
+ for (sal_Int32 i = 0; i < nSize && !bRes; ++i)
+ {
+ if (aDocId == m_aFPEntriesQueue[i].m_aDocId)
+ bRes = sal_True;
+ }
+ }
+ }
}
// ---- THREAD SAFE END ----
@@ -651,12 +857,12 @@ void SAL_CALL GrammarCheckingIterator::processLinguServiceEvent(
const linguistic2::LinguServiceEvent& rLngSvcEvent )
throw (uno::RuntimeException)
{
- if (rLngSvcEvent.nEvent == linguistic2::LinguServiceEventFlags::GRAMMAR_CHECK_AGAIN)
+ if (rLngSvcEvent.nEvent == linguistic2::LinguServiceEventFlags::PROOFREAD_AGAIN)
{
try
{
- uno::Reference< uno::XInterface > xThis(*this);
- linguistic2::LinguServiceEvent aEvent( xThis, linguistic2::LinguServiceEventFlags::GRAMMAR_CHECK_AGAIN );
+ uno::Reference< uno::XInterface > xThis( dynamic_cast< XLinguServiceEventBroadcaster * >(this) );
+ linguistic2::LinguServiceEvent aEvent( xThis, linguistic2::LinguServiceEventFlags::PROOFREAD_AGAIN );
m_aNotifyListeners.notifyEach(
&linguistic2::XLinguServiceEventListener::processLinguServiceEvent,
aEvent);
@@ -682,7 +888,7 @@ throw (uno::RuntimeException)
{
if (xListener.is())
{
-// ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+// ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
m_aNotifyListeners.addInterface( xListener );
}
return sal_True;
@@ -695,7 +901,7 @@ throw (uno::RuntimeException)
{
if (xListener.is())
{
-// ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+// ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
m_aNotifyListeners.removeInterface( xListener );
}
return sal_True;
@@ -705,7 +911,7 @@ throw (uno::RuntimeException)
void SAL_CALL GrammarCheckingIterator::dispose()
throw (uno::RuntimeException)
{
- lang::EventObject aEvt( (linguistic2::XGrammarCheckingIterator *) this );
+ lang::EventObject aEvt( (linguistic2::XProofreadingIterator *) this );
m_aEventListeners.disposeAndClear( aEvt );
//
@@ -714,7 +920,7 @@ throw (uno::RuntimeException)
m_aRequestEndThread.reset();
// ---- THREAD SAFE START ----
{
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
m_bEnd = sal_True;
}
// ---- THREAD SAFE END ----
@@ -726,7 +932,7 @@ throw (uno::RuntimeException)
// ---- THREAD SAFE START ----
{
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
// releaase all UNO references
@@ -751,7 +957,7 @@ throw (uno::RuntimeException)
{
if (xListener.is())
{
-// ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+// ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
m_aEventListeners.addInterface( xListener );
}
}
@@ -763,7 +969,7 @@ throw (uno::RuntimeException)
{
if (xListener.is())
{
-// ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+// ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
m_aEventListeners.removeInterface( xListener );
}
}
@@ -778,13 +984,14 @@ throw (uno::RuntimeException)
//!! and the call to xFlatParagraphIterator->getNextPara() will result in an empty reference.
//!! And if an entry is currently checked by a grammar checker upon return the results
//!! should be ignored.
- //!! All of the above resulting in that we only have to get rid of all references here.
+ //!! Also GetOrCreateDocId will not use that very same Id again...
+ //!! All of the above resulting in that we only have to get rid of the implementation pointer here.
uno::Reference< lang::XComponent > xDoc( rSource.Source, uno::UNO_QUERY );
if (xDoc.is())
{
// ---- THREAD SAFE START ----
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
- m_aDocIdMap.erase( xDoc );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
+ m_aDocIdMap.erase( xDoc.get() );
// ---- THREAD SAFE END ----
}
}
@@ -826,7 +1033,7 @@ uno::Reference< util::XChangesBatch > GrammarCheckingIterator::GetUpdateAccess()
return m_xUpdateAccess;
}
-/*
+
void GrammarCheckingIterator::GetConfiguredGCSvcs_Impl()
{
GCImplNames_t aTmpGCImplNamesByLang;
@@ -867,13 +1074,13 @@ void GrammarCheckingIterator::GetConfiguredGCSvcs_Impl()
{
// ---- THREAD SAFE START ----
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
m_aGCImplNamesByLang = aTmpGCImplNamesByLang;
// ---- THREAD SAFE END ----
}
}
-*/
+/*
void GrammarCheckingIterator::GetMatchingGCSvcs_Impl()
{
GCImplNames_t aTmpGCImplNamesByLang;
@@ -916,12 +1123,12 @@ void GrammarCheckingIterator::GetMatchingGCSvcs_Impl()
{
// ---- THREAD SAFE START ----
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
m_aGCImplNamesByLang = aTmpGCImplNamesByLang;
// ---- THREAD SAFE END ----
}
}
-
+*/
/*
void GrammarCheckingIterator::GetAvailableGCSvcs_Impl()
@@ -952,7 +1159,7 @@ void GrammarCheckingIterator::GetAvailableGCSvcs_Impl()
{
try
{
- uno::Reference< linguistic2::XGrammarChecker > xSvc( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY );
+ uno::Reference< linguistic2::XProofreader > xSvc( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY );
if (xSvc.is())
{
OUString aImplName;
@@ -966,7 +1173,7 @@ void GrammarCheckingIterator::GetAvailableGCSvcs_Impl()
{
uno::Sequence< lang::Locale > aLocaleSequence( xSuppLoc->getLocales() );
// ---- THREAD SAFE START ----
- ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
m_aGCLocalesByService[ aImplName ] = aLocaleSequence;
m_aGCReferencesByService[ aImplName ] = xSvc;
// ---- THREAD SAFE END ----
@@ -1009,20 +1216,69 @@ uno::Sequence< OUString > SAL_CALL GrammarCheckingIterator::getSupportedServiceN
return GrammarCheckingIterator_getSupportedServiceNames();
}
+
+void GrammarCheckingIterator::SetServiceList(
+ const lang::Locale &rLocale,
+ const uno::Sequence< OUString > &rSvcImplNames )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
+
+ LanguageType nLanguage = LocaleToLanguage( rLocale );
+ OUString aImplName;
+ if (rSvcImplNames.getLength() > 0)
+ aImplName = rSvcImplNames[0]; // there is only one grammar checker per language
+
+ if (nLanguage != LANGUAGE_NONE && nLanguage != LANGUAGE_DONTKNOW)
+ {
+ if (aImplName.getLength() > 0)
+ m_aGCImplNamesByLang[ nLanguage ] = aImplName;
+ else
+ m_aGCImplNamesByLang.erase( nLanguage );
+ }
+}
+
+
+uno::Sequence< OUString > GrammarCheckingIterator::GetServiceList(
+ const lang::Locale &rLocale ) const
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( MyMutex::get() );
+
+ uno::Sequence< OUString > aRes(1);
+
+ OUString aImplName; // there is only one grammar checker per language
+ LanguageType nLang = LocaleToLanguage( rLocale );
+ GCImplNames_t::const_iterator aIt( m_aGCImplNamesByLang.find( nLang ) );
+ if (aIt != m_aGCImplNamesByLang.end())
+ aImplName = aIt->second;
+
+ if (aImplName.getLength() > 0)
+ aRes[0] = aImplName;
+ else
+ aRes.realloc(0);
+
+ return aRes;
+}
+
+
+LinguDispatcher::DspType GrammarCheckingIterator::GetDspType() const
+{
+ return DSP_GRAMMAR;
+}
+
///////////////////////////////////////////////////////////////////////////
static OUString GrammarCheckingIterator_getImplementationName() throw()
{
- return A2OU( "com.sun.star.lingu2.GrammarCheckingIterator" );
+ return A2OU( "com.sun.star.lingu2.ProofreadingIterator" );
}
static uno::Sequence< OUString > GrammarCheckingIterator_getSupportedServiceNames() throw()
{
uno::Sequence< OUString > aSNS( 1 );
- aSNS.getArray()[0] = A2OU( "com.sun.star.linguistic2.GrammarCheckingIterator" );
+ aSNS.getArray()[0] = A2OU( SN_GRAMMARCHECKINGITERATOR );
return aSNS;
}
diff --git a/linguistic/source/gciterator.hxx b/linguistic/source/gciterator.hxx
index ca714da4a2..6697b8e704 100644
--- a/linguistic/source/gciterator.hxx
+++ b/linguistic/source/gciterator.hxx
@@ -31,10 +31,11 @@
#ifndef _LINGUISTIC_GRAMMARCHECKINGITERATOR_HXX_
#define _LINGUISTIC_GRAMMARCHECKINGITERATOR_HXX_
+#include <com/sun/star/i18n/XBreakIterator.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XEventListener.hpp>
-#include <com/sun/star/linguistic2/XGrammarCheckingIterator.hpp>
+#include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
#include <com/sun/star/linguistic2/XLinguServiceEventListener.hpp>
#include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -43,10 +44,13 @@
#include <cppuhelper/implbase5.hxx>
#include <cppuhelper/weakref.hxx>
#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+#include <rtl/instance.hxx>
#include <map>
#include <deque>
+#include "defs.hxx"
//////////////////////////////////////////////////////////////////////
@@ -60,16 +64,16 @@ struct FPEntry
::com::sun::star::uno::WeakReference< ::com::sun::star::text::XFlatParagraph > m_xPara;
// document ID to identify different documents
- sal_Int32 m_nDocId;
+ ::rtl::OUString m_aDocId;
// the starting position to be checked
- sal_Int32 m_nStartIndex;
+ sal_Int32 m_nStartIndex;
// the flag to identify whether the document does automatical grammar checking
- sal_Bool m_bAutomatic;
+ sal_Bool m_bAutomatic;
FPEntry()
- : m_nDocId( 0 )
+ : m_aDocId()
, m_nStartIndex( 0 )
, m_bAutomatic( 0 )
{
@@ -83,12 +87,13 @@ struct FPEntry
class GrammarCheckingIterator:
public cppu::WeakImplHelper5
<
- ::com::sun::star::linguistic2::XGrammarCheckingIterator,
+ ::com::sun::star::linguistic2::XProofreadingIterator,
::com::sun::star::linguistic2::XLinguServiceEventListener,
::com::sun::star::linguistic2::XLinguServiceEventBroadcaster,
::com::sun::star::lang::XComponent,
::com::sun::star::lang::XServiceInfo
- >
+ >,
+ public LinguDispatcher
{
com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMSF;
@@ -103,9 +108,8 @@ class GrammarCheckingIterator:
// the flag to end the endless loop
sal_Bool m_bEnd;
- // parameter ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponen > --> the document
- // parameter sal_Int32 --> DocId to indentify the document
- typedef std::map< ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >, sal_Int32 > DocMap_t;
+ // Note that it must be the pointer and not the uno-reference to check if it is the same implementation object
+ typedef std::map< XComponent *, ::rtl::OUString > DocMap_t;
DocMap_t m_aDocIdMap;
// parameter ::rtl::OUString --> implementation name
@@ -118,18 +122,19 @@ class GrammarCheckingIterator:
GCImplNames_t m_aGCImplNamesByLang;
// implname -> UNO reference mapping
- typedef std::map< ::rtl::OUString, ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XGrammarChecker > > GCReferences_t;
+ typedef std::map< ::rtl::OUString, ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XProofreader > > GCReferences_t;
GCReferences_t m_aGCReferencesByService;
+ ::rtl::OUString m_aCurCheckedDocId;
sal_Bool m_bGCServicesChecked;
sal_Int32 m_nDocIdCounter;
- sal_Int32 m_nCurCheckedDocId;
sal_Int32 m_nLastEndOfSentencePos;
osl::Condition m_aWakeUpThread;
osl::Condition m_aRequestEndThread;
//! beware of initilization order !
- osl::Mutex m_aMutex;
+ struct MyMutex : public rtl::Static< osl::Mutex, MyMutex > {};
+ //
cppu::OInterfaceContainerHelper m_aEventListeners;
cppu::OInterfaceContainerHelper m_aNotifyListeners;
@@ -137,23 +142,23 @@ class GrammarCheckingIterator:
mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesBatch > m_xUpdateAccess;
sal_Int32 NextDocId();
- sal_Int32 GetOrCreateDocId( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > &xComp );
+ ::rtl::OUString GetOrCreateDocId( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > &xComp );
void AddEntry(
::com::sun::star::uno::WeakReference< ::com::sun::star::text::XFlatParagraphIterator > xFlatParaIterator,
::com::sun::star::uno::WeakReference< ::com::sun::star::text::XFlatParagraph > xFlatPara,
- sal_Int32 nDocId, sal_Int32 nStartIndex, sal_Bool bAutomatic );
+ const ::rtl::OUString &rDocId, sal_Int32 nStartIndex, sal_Bool bAutomatic );
- void ProcessResult( const ::com::sun::star::linguistic2::GrammarCheckingResult &rRes, sal_Int32 nSentenceStartPos,
+ void ProcessResult( const ::com::sun::star::linguistic2::ProofreadingResult &rRes,
const ::com::sun::star::uno::Reference< ::com::sun::star::text::XFlatParagraphIterator > &rxFlatParagraphIterator,
bool bIsAutomaticChecking );
sal_Int32 GetSuggestedEndOfSentence( const ::rtl::OUString &rText, sal_Int32 nSentenceStartPos, const ::com::sun::star::lang::Locale &rLocale );
-// void GetConfiguredGCSvcs_Impl();
- void GetMatchingGCSvcs_Impl();
+ void GetConfiguredGCSvcs_Impl();
+// void GetMatchingGCSvcs_Impl();
// void GetAvailableGCSvcs_Impl();
- ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XGrammarChecker > GetGrammarChecker( const ::com::sun::star::lang::Locale & rLocale );
+ ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XProofreader > GetGrammarChecker( const ::com::sun::star::lang::Locale & rLocale );
::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesBatch > GetUpdateAccess() const;
@@ -168,11 +173,11 @@ public:
explicit GrammarCheckingIterator( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rxMgr );
virtual ~GrammarCheckingIterator();
- // XGrammarCheckingIterator
- virtual void SAL_CALL startGrammarChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xDoc, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XFlatParagraphIteratorProvider >& xIteratorProvider, ::sal_Bool bAutomatic ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::linguistic2::GrammarCheckingResult SAL_CALL checkGrammarAtPos( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xDoc, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XFlatParagraph >& xFlatPara, const ::rtl::OUString& aText, const ::com::sun::star::lang::Locale& aLocale, ::sal_Int32 nStartOfSentencePos, ::sal_Int32 nSuggestedEndOfSentencePos, ::sal_Int32 nErrorPosInPara ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::sal_Int32 SAL_CALL getEndOfSentence( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XFlatParagraph >& xFlatPara, ::sal_Int32 nSentenceStartPos ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual ::sal_Bool SAL_CALL isGrammarChecking( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xDoc, ::sal_Bool bAutomatic ) throw (::com::sun::star::uno::RuntimeException);
+ // XProofreadingIterator
+ virtual void SAL_CALL startProofreading( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xDocument, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XFlatParagraphIteratorProvider >& xIteratorProvider ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::linguistic2::ProofreadingResult SAL_CALL checkSentenceAtPosition( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xDocument, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XFlatParagraph >& xFlatParagraph, const ::rtl::OUString& aText, const ::com::sun::star::lang::Locale& aLocale, ::sal_Int32 nStartOfSentencePosition, ::sal_Int32 nSuggestedBehindEndOfSentencePosition, ::sal_Int32 nErrorPositionInParagraph ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL resetIgnoreRules( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isProofreading( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xDocument ) throw (::com::sun::star::uno::RuntimeException);
// XLinguServiceEventListener
virtual void SAL_CALL processLinguServiceEvent( const ::com::sun::star::linguistic2::LinguServiceEvent& aLngSvcEvent ) throw (::com::sun::star::uno::RuntimeException);
@@ -194,6 +199,10 @@ public:
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+ // LinguDispatcher
+ virtual void SetServiceList( const ::com::sun::star::lang::Locale &rLocale, const ::com::sun::star::uno::Sequence< rtl::OUString > &rSvcImplNames );
+ virtual ::com::sun::star::uno::Sequence< rtl::OUString > GetServiceList( const ::com::sun::star::lang::Locale &rLocale ) const;
+ virtual DspType GetDspType() const;
};
diff --git a/linguistic/source/hyphdsp.cxx b/linguistic/source/hyphdsp.cxx
index c1a239536c..7bc8c343af 100644
--- a/linguistic/source/hyphdsp.cxx
+++ b/linguistic/source/hyphdsp.cxx
@@ -1,3 +1,4 @@
+
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -62,18 +63,6 @@ using namespace linguistic;
///////////////////////////////////////////////////////////////////////////
-LangSvcEntry_Hyph::~LangSvcEntry_Hyph()
-{
-}
-
-
-LangSvcEntry_Hyph::LangSvcEntry_Hyph( const ::rtl::OUString &rSvcImplName ) :
- aSvcImplName( rSvcImplName )
-{
-}
-
-///////////////////////////////////////////////////////////////////////////
-
HyphenatorDispatcher::HyphenatorDispatcher( LngSvcMgr &rLngSvcMgr ) :
rMgr (rLngSvcMgr)
{
@@ -89,13 +78,8 @@ HyphenatorDispatcher::~HyphenatorDispatcher()
void HyphenatorDispatcher::ClearSvcList()
{
// release memory for each table entry
- LangSvcEntry_Hyph *pItem = aSvcList.First();
- while (pItem)
- {
- LangSvcEntry_Hyph *pTmp = pItem;
- pItem = aSvcList.Next();
- delete pTmp;
- }
+ HyphSvcByLangMap_t aTmp;
+ aSvcMap.swap( aTmp );
}
@@ -254,16 +238,13 @@ Sequence< Locale > SAL_CALL HyphenatorDispatcher::getLocales()
{
MutexGuard aGuard( GetLinguMutex() );
- ULONG nCnt = aSvcList.Count();
- Sequence< Locale > aLocales( nCnt );
- Locale *pItem = aLocales.getArray();
- LangSvcEntry_Hyph *pEntry = aSvcList.First();
- for (ULONG i = 0; i < nCnt; i++)
+ Sequence< Locale > aLocales( static_cast< sal_Int32 >(aSvcMap.size()) );
+ Locale *pLocales = aLocales.getArray();
+ HyphSvcByLangMap_t::const_iterator aIt;
+ for (aIt = aSvcMap.begin(); aIt != aSvcMap.end(); ++aIt)
{
- DBG_ASSERT( pEntry, "lng : pEntry is NULL pointer" );
- pItem[i] = CreateLocale( (LanguageType) aSvcList.GetKey( pEntry ) );
- pEntry = aSvcList.Next();
- }
+ *pLocales++ = CreateLocale( aIt->first );
+ }
return aLocales;
}
@@ -272,7 +253,8 @@ BOOL SAL_CALL HyphenatorDispatcher::hasLocale(const Locale& rLocale)
throw(RuntimeException)
{
MutexGuard aGuard( GetLinguMutex() );
- return 0 != aSvcList.Get( LocaleToLanguage( rLocale ) );
+ HyphSvcByLangMap_t::const_iterator aIt( aSvcMap.find( LocaleToLanguage( rLocale ) ) );
+ return aIt != aSvcMap.end();
}
@@ -293,7 +275,7 @@ Reference< XHyphenatedWord > SAL_CALL
return xRes;
// search for entry with that language
- LangSvcEntry_Hyph *pEntry = aSvcList.Get( nLanguage );
+ LangSvcEntries_Hyph *pEntry = aSvcMap[ nLanguage ].get();
BOOL bWordModified = FALSE;
if (!pEntry || (nMaxLeading < 0 || nMaxLeading > nWordLen))
@@ -339,24 +321,29 @@ Reference< XHyphenatedWord > SAL_CALL
}
else
{
- INT32 nLen = pEntry->aSvcImplName.getLength() ? 1 : 0;
- DBG_ASSERT( pEntry->aFlags.nLastTriedSvcIndex < nLen,
+ INT32 nLen = pEntry->aSvcImplNames.getLength() > 0 ? 1 : 0;
+ DBG_ASSERT( pEntry->nLastTriedSvcIndex < nLen,
"lng : index out of range");
INT32 i = 0;
- Reference< XHyphenator > &rHyph = pEntry->aSvcRef;
+ Reference< XHyphenator > xHyph;
+ if (pEntry->aSvcRefs.getLength() > 0)
+ xHyph = pEntry->aSvcRefs[0];
// try already instantiated service
- if (i <= pEntry->aFlags.nLastTriedSvcIndex)
+ if (i <= pEntry->nLastTriedSvcIndex)
{
- if (rHyph.is() && rHyph->hasLocale( rLocale ))
- xRes = rHyph->hyphenate( aChkWord, rLocale, nChkMaxLeading,
+ if (xHyph.is() && xHyph->hasLocale( rLocale ))
+ xRes = xHyph->hyphenate( aChkWord, rLocale, nChkMaxLeading,
rProperties );
++i;
}
- else if (pEntry->aFlags.nLastTriedSvcIndex < nLen - 1)
+ else if (pEntry->nLastTriedSvcIndex < nLen - 1)
// instantiate services and try it
{
+// const OUString *pImplNames = pEntry->aSvcImplNames.getConstArray();
+ Reference< XHyphenator > *pRef = pEntry->aSvcRefs.getArray();
+
Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() );
if (xMgr.is())
{
@@ -368,35 +355,34 @@ Reference< XHyphenatedWord > SAL_CALL
//aArgs.getArray()[1] <<= GetDicList();
// create specific service via it's implementation name
- Reference< XHyphenator > xHyph;
try
{
xHyph = Reference< XHyphenator >(
xMgr->createInstanceWithArguments(
- pEntry->aSvcImplName, aArgs ), UNO_QUERY );
+ pEntry->aSvcImplNames[0], aArgs ), UNO_QUERY );
}
catch (uno::Exception &)
{
- DBG_ERROR( "createInstanceWithArguments failed" );
+ DBG_ASSERT( 0, "createInstanceWithArguments failed" );
}
- rHyph = xHyph;
+ pRef [i] = xHyph;
Reference< XLinguServiceEventBroadcaster >
xBroadcaster( xHyph, UNO_QUERY );
if (xBroadcaster.is())
rMgr.AddLngSvcEvtBroadcaster( xBroadcaster );
- if (rHyph.is() && rHyph->hasLocale( rLocale ))
- xRes = rHyph->hyphenate( aChkWord, rLocale, nChkMaxLeading,
+ if (xHyph.is() && xHyph->hasLocale( rLocale ))
+ xRes = xHyph->hyphenate( aChkWord, rLocale, nChkMaxLeading,
rProperties );
- pEntry->aFlags.nLastTriedSvcIndex = (INT16) i;
+ pEntry->nLastTriedSvcIndex = (INT16) i;
++i;
// if language is not supported by the services
// remove it from the list.
- if (rHyph.is() && !rHyph->hasLocale( rLocale ))
- aSvcList.Remove( nLanguage );
+ if (xHyph.is() && !xHyph->hasLocale( rLocale ))
+ aSvcMap.erase( nLanguage );
}
}
} // if (xEntry.is())
@@ -432,7 +418,7 @@ Reference< XHyphenatedWord > SAL_CALL
return xRes;
// search for entry with that language
- LangSvcEntry_Hyph *pEntry = aSvcList.Get( nLanguage );
+ LangSvcEntries_Hyph *pEntry = aSvcMap[ nLanguage ].get();
BOOL bWordModified = FALSE;
if (!pEntry || !(0 <= nIndex && nIndex <= nWordLen - 2))
@@ -473,24 +459,29 @@ Reference< XHyphenatedWord > SAL_CALL
}
else
{
- INT32 nLen = pEntry->aSvcImplName.getLength() ? 1 : 0;
- DBG_ASSERT( pEntry->aFlags.nLastTriedSvcIndex < nLen,
+ INT32 nLen = pEntry->aSvcImplNames.getLength() > 0 ? 1 : 0;
+ DBG_ASSERT( pEntry->nLastTriedSvcIndex < nLen,
"lng : index out of range");
INT32 i = 0;
- Reference< XHyphenator > &rHyph = pEntry->aSvcRef;
+ Reference< XHyphenator > xHyph;
+ if (pEntry->aSvcRefs.getLength() > 0)
+ xHyph = pEntry->aSvcRefs[0];
// try already instantiated service
- if (i <= pEntry->aFlags.nLastTriedSvcIndex)
+ if (i <= pEntry->nLastTriedSvcIndex)
{
- if (rHyph.is() && rHyph->hasLocale( rLocale ))
- xRes = rHyph->queryAlternativeSpelling( aChkWord, rLocale,
+ if (xHyph.is() && xHyph->hasLocale( rLocale ))
+ xRes = xHyph->queryAlternativeSpelling( aChkWord, rLocale,
nChkIndex, rProperties );
++i;
}
- else if (pEntry->aFlags.nLastTriedSvcIndex < nLen - 1)
+ else if (pEntry->nLastTriedSvcIndex < nLen - 1)
// instantiate services and try it
{
+// const OUString *pImplNames = pEntry->aSvcImplNames.getConstArray();
+ Reference< XHyphenator > *pRef = pEntry->aSvcRefs.getArray();
+
Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() );
if (xMgr.is())
{
@@ -502,35 +493,34 @@ Reference< XHyphenatedWord > SAL_CALL
//aArgs.getArray()[1] <<= GetDicList();
// create specific service via it's implementation name
- Reference< XHyphenator > xHyph;
try
{
xHyph = Reference< XHyphenator >(
xMgr->createInstanceWithArguments(
- pEntry->aSvcImplName, aArgs ), UNO_QUERY );
+ pEntry->aSvcImplNames[0], aArgs ), UNO_QUERY );
}
catch (uno::Exception &)
{
- DBG_ERROR( "createInstanceWithArguments failed" );
+ DBG_ASSERT( 0, "createInstanceWithArguments failed" );
}
- rHyph = xHyph;
+ pRef [i] = xHyph;
Reference< XLinguServiceEventBroadcaster >
xBroadcaster( xHyph, UNO_QUERY );
if (xBroadcaster.is())
rMgr.AddLngSvcEvtBroadcaster( xBroadcaster );
- if (rHyph.is() && rHyph->hasLocale( rLocale ))
- xRes = rHyph->queryAlternativeSpelling( aChkWord, rLocale,
+ if (xHyph.is() && xHyph->hasLocale( rLocale ))
+ xRes = xHyph->queryAlternativeSpelling( aChkWord, rLocale,
nChkIndex, rProperties );
- pEntry->aFlags.nLastTriedSvcIndex = (INT16) i;
+ pEntry->nLastTriedSvcIndex = (INT16) i;
++i;
// if language is not supported by the services
// remove it from the list.
- if (rHyph.is() && !rHyph->hasLocale( rLocale ))
- aSvcList.Remove( nLanguage );
+ if (xHyph.is() && !xHyph->hasLocale( rLocale ))
+ aSvcMap.erase( nLanguage );
}
}
} // if (xEntry.is())
@@ -565,7 +555,7 @@ Reference< XPossibleHyphens > SAL_CALL
return xRes;
// search for entry with that language
- LangSvcEntry_Hyph *pEntry = aSvcList.Get( nLanguage );
+ LangSvcEntries_Hyph *pEntry = aSvcMap[ nLanguage ].get();
if (!pEntry)
{
@@ -602,24 +592,29 @@ Reference< XPossibleHyphens > SAL_CALL
}
else
{
- INT32 nLen = pEntry->aSvcImplName.getLength() ? 1 : 0;
- DBG_ASSERT( pEntry->aFlags.nLastTriedSvcIndex < nLen,
+ INT32 nLen = pEntry->aSvcImplNames.getLength() > 0 ? 1 : 0;
+ DBG_ASSERT( pEntry->nLastTriedSvcIndex < nLen,
"lng : index out of range");
INT32 i = 0;
- Reference< XHyphenator > &rHyph = pEntry->aSvcRef;
+ Reference< XHyphenator > xHyph;
+ if (pEntry->aSvcRefs.getLength() > 0)
+ xHyph = pEntry->aSvcRefs[0];
// try already instantiated service
- if (i <= pEntry->aFlags.nLastTriedSvcIndex)
+ if (i <= pEntry->nLastTriedSvcIndex)
{
- if (rHyph.is() && rHyph->hasLocale( rLocale ))
- xRes = rHyph->createPossibleHyphens( aChkWord, rLocale,
+ if (xHyph.is() && xHyph->hasLocale( rLocale ))
+ xRes = xHyph->createPossibleHyphens( aChkWord, rLocale,
rProperties );
++i;
}
- else if (pEntry->aFlags.nLastTriedSvcIndex < nLen - 1)
+ else if (pEntry->nLastTriedSvcIndex < nLen - 1)
// instantiate services and try it
{
+// const OUString *pImplNames = pEntry->aSvcImplNames.getConstArray();
+ Reference< XHyphenator > *pRef = pEntry->aSvcRefs.getArray();
+
Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() );
if (xMgr.is())
{
@@ -631,35 +626,34 @@ Reference< XPossibleHyphens > SAL_CALL
//aArgs.getArray()[1] <<= GetDicList();
// create specific service via it's implementation name
- Reference< XHyphenator > xHyph;
try
{
xHyph = Reference< XHyphenator >(
xMgr->createInstanceWithArguments(
- pEntry->aSvcImplName, aArgs ), UNO_QUERY );
+ pEntry->aSvcImplNames[0], aArgs ), UNO_QUERY );
}
catch (uno::Exception &)
{
- DBG_ERROR( "createWithArguments failed" );
+ DBG_ASSERT( 0, "createWithArguments failed" );
}
- rHyph = xHyph;
+ pRef [i] = xHyph;
Reference< XLinguServiceEventBroadcaster >
xBroadcaster( xHyph, UNO_QUERY );
if (xBroadcaster.is())
rMgr.AddLngSvcEvtBroadcaster( xBroadcaster );
- if (rHyph.is() && rHyph->hasLocale( rLocale ))
- xRes = rHyph->createPossibleHyphens( aChkWord, rLocale,
+ if (xHyph.is() && xHyph->hasLocale( rLocale ))
+ xRes = xHyph->createPossibleHyphens( aChkWord, rLocale,
rProperties );
- pEntry->aFlags.nLastTriedSvcIndex = (INT16) i;
+ pEntry->nLastTriedSvcIndex = (INT16) i;
++i;
// if language is not supported by the services
// remove it from the list.
- if (rHyph.is() && !rHyph->hasLocale( rLocale ))
- aSvcList.Remove( nLanguage );
+ if (xHyph.is() && !xHyph->hasLocale( rLocale ))
+ aSvcMap.erase( nLanguage );
}
}
} // if (xEntry.is())
@@ -684,27 +678,27 @@ void HyphenatorDispatcher::SetServiceList( const Locale &rLocale,
INT16 nLanguage = LocaleToLanguage( rLocale );
INT32 nLen = rSvcImplNames.getLength();
-
if (0 == nLen)
// remove entry
- aSvcList.Remove( nLanguage );
+ aSvcMap.erase( nLanguage );
else
{
// modify/add entry
- LangSvcEntry_Hyph *pEntry = aSvcList.Get( nLanguage );
+ LangSvcEntries_Hyph *pEntry = aSvcMap[ nLanguage ].get();
// only one hypenator can be in use for a language...
- const OUString &rSvcImplName = rSvcImplNames.getConstArray()[0];
+ //const OUString &rSvcImplName = rSvcImplNames.getConstArray()[0];
if (pEntry)
{
- pEntry->aSvcImplName = rSvcImplName;
- pEntry->aSvcRef = NULL;
- pEntry->aFlags = SvcFlags();
+ pEntry->Clear();
+ pEntry->aSvcImplNames = rSvcImplNames;
+ pEntry->aSvcImplNames.realloc(1);
+ pEntry->aSvcRefs = Sequence< Reference < XHyphenator > > ( 1 );
}
else
{
- pEntry = new LangSvcEntry_Hyph( rSvcImplName );
- aSvcList.Insert( nLanguage, pEntry );
- DBG_ASSERT( aSvcList.Get( nLanguage ), "lng : Insert failed" );
+ boost::shared_ptr< LangSvcEntries_Hyph > pTmpEntry( new LangSvcEntries_Hyph( rSvcImplNames[0] ) );
+ pTmpEntry->aSvcRefs = Sequence< Reference < XHyphenator > >( 1 );
+ aSvcMap[ nLanguage ] = pTmpEntry;
}
}
}
@@ -715,23 +709,24 @@ Sequence< OUString >
{
MutexGuard aGuard( GetLinguMutex() );
- Sequence< OUString > aRes(1);
+ Sequence< OUString > aRes;
// search for entry with that language and use data from that
INT16 nLanguage = LocaleToLanguage( rLocale );
HyphenatorDispatcher *pThis = (HyphenatorDispatcher *) this;
- const LangSvcEntry_Hyph *pEntry = pThis->aSvcList.Get( nLanguage );
+ const LangSvcEntries_Hyph *pEntry = pThis->aSvcMap[ nLanguage ].get();
if (pEntry)
- aRes.getArray()[0] = pEntry->aSvcImplName;
- else
- aRes.realloc(0);
+ {
+ aRes = pEntry->aSvcImplNames;
+ if (aRes.getLength() > 0)
+ aRes.realloc(1);
+ }
return aRes;
}
-HyphenatorDispatcher::DspType
- HyphenatorDispatcher::GetDspType() const
+LinguDispatcher::DspType HyphenatorDispatcher::GetDspType() const
{
return DSP_HYPH;
}
diff --git a/linguistic/source/hyphdsp.hxx b/linguistic/source/hyphdsp.hxx
index 8d9ef04458..364244a3a0 100644
--- a/linguistic/source/hyphdsp.hxx
+++ b/linguistic/source/hyphdsp.hxx
@@ -40,11 +40,12 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
#include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
-#include <tools/table.hxx>
#include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
#include <cppuhelper/implbase1.hxx> // helper for implementations
+#include <boost/shared_ptr.hpp>
+#include <map>
#include "lngopt.hxx"
#include "misc.hxx"
@@ -54,31 +55,6 @@ class LngSvcMgr;
///////////////////////////////////////////////////////////////////////////
-class LangSvcEntry_Hyph
-{
- friend class HyphenatorDispatcher;
-
- ::rtl::OUString aSvcImplName;
- ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XHyphenator > aSvcRef;
-
-// INT16 nLang; //used as key in the table
- SvcFlags aFlags;
-
-public:
- LangSvcEntry_Hyph() {}
- LangSvcEntry_Hyph( const ::rtl::OUString &rSvcImplName );
- ~LangSvcEntry_Hyph();
-
- BOOL IsAlreadyWarned() const { return aFlags.bAlreadyWarned != 0; }
- void SetAlreadyWarned(BOOL bVal) { aFlags.bAlreadyWarned = 0 != bVal; }
- BOOL IsDoWarnAgain() const { return aFlags.bDoWarnAgain != 0; }
- void SetDoWarnAgain(BOOL bVal) { aFlags.bDoWarnAgain = 0 != bVal; }
-};
-
-DECLARE_TABLE( HyphSvcList, LangSvcEntry_Hyph * )
-
-
class HyphenatorDispatcher :
public cppu::WeakImplHelper1
<
@@ -86,7 +62,9 @@ class HyphenatorDispatcher :
>,
public LinguDispatcher
{
- HyphSvcList aSvcList;
+ typedef boost::shared_ptr< LangSvcEntries_Hyph > LangSvcEntries_Hyph_Ptr_t;
+ typedef std::map< LanguageType, LangSvcEntries_Hyph_Ptr_t > HyphSvcByLangMap_t;
+ HyphSvcByLangMap_t aSvcMap;
::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet > xPropSet;
diff --git a/linguistic/source/iprcache.cxx b/linguistic/source/iprcache.cxx
index 87054b3f1b..12ea41250f 100644
--- a/linguistic/source/iprcache.cxx
+++ b/linguistic/source/iprcache.cxx
@@ -85,7 +85,7 @@ static const struct
INT32 nPropHdl;
} aFlushProperties[ NUM_FLUSH_PROPS ] =
{
- { UPN_IS_GERMAN_PRE_REFORM, UPH_IS_GERMAN_PRE_REFORM },
+ { UPN_IS_GERMAN_PRE_REFORM, UPH_IS_GERMAN_PRE_REFORM }, /* deprecated */
{ UPN_IS_USE_DICTIONARY_LIST, UPH_IS_USE_DICTIONARY_LIST },
{ UPN_IS_IGNORE_CONTROL_CHARACTERS, UPH_IS_IGNORE_CONTROL_CHARACTERS },
{ UPN_IS_SPELL_UPPER_CASE, UPH_IS_SPELL_UPPER_CASE },
@@ -239,62 +239,7 @@ void SAL_CALL FlushListener::propertyChange(
///////////////////////////////////////////////////////////////////////////
-class IPRCachedWord
-{
- String aWord;
- IPRCachedWord *pNext;
- IPRCachedWord *pPrev;
- IPRCachedWord *pFollow;
- INT16 nLanguage;
- ULONG nFound;
-
- // don't allow to use copy-constructor and assignment-operator
- IPRCachedWord(const IPRCachedWord &);
- IPRCachedWord & operator = (const IPRCachedWord &);
-
-public:
- IPRCachedWord( const String& rWord, IPRCachedWord* pFollowPtr, INT16 nLang )
- : aWord( rWord ), pNext( 0 ), pPrev( 0 ), pFollow( pFollowPtr ),
- nLanguage( nLang ), nFound( 0 ) {}
- ~IPRCachedWord(){}
-
- const String& GetWord() { return aWord; }
- void SetWord( const String& aNew ) { aWord = aNew; }
-
- USHORT GetLang() { return nLanguage; }
- void SetLang( INT16 nNew ) { nLanguage = nNew; }
-
- IPRCachedWord* GetNext() { return pNext; }
- void SetNext( IPRCachedWord* pNew ) { pNext = pNew; }
-
- IPRCachedWord* GetPrev() { return pPrev; }
- void SetPrev( IPRCachedWord* pNew ) { pPrev = pNew; }
-
- IPRCachedWord* GetFollow() { return pFollow; }
- void SetFollow( IPRCachedWord* pNew ){ pFollow = pNew; }
-
- void IncFound() { ++nFound; }
- ULONG GetFound() { return nFound; }
- void SetFound( ULONG nNew ) { nFound = nNew; }
-};
-
-///////////////////////////////////////////////////////////////////////////
-
-IPRSpellCache::IPRSpellCache( ULONG nSize ) :
- ppHash ( NULL ),
- pFirst ( NULL ),
- pLast ( NULL ),
- nIndex ( 0 ),
- nCount ( 0 ),
- nInputPos ( 0 ),
- nInputValue ( 0 ),
- nTblSize ( nSize )
-#ifdef DBG_STATISTIC
- ,nMax ( IPR_DEF_CACHE_MAX ),
- nMaxInput ( IPR_DEF_CACHE_MAXINPUT ),
- nFound ( 0 ),
- nLost ( 0 )
-#endif
+SpellCache::SpellCache()
{
pFlushLstnr = new FlushListener( this );
xFlushLstnr = pFlushLstnr;
@@ -304,236 +249,39 @@ IPRSpellCache::IPRSpellCache( ULONG nSize ) :
pFlushLstnr->SetPropSet( aPropertySet ); //! after reference is established
}
-IPRSpellCache::~IPRSpellCache()
+SpellCache::~SpellCache()
{
- MutexGuard aGuard( GetLinguMutex() );
-
- Reference<XDictionaryList> aDictionaryList;
- pFlushLstnr->SetDicList( aDictionaryList );
- Reference<XPropertySet> aPropertySet;
- pFlushLstnr->SetPropSet( aPropertySet );
-
-#ifdef DBG_STATISTIC
- // Binary File oeffnen
- String aOutTmp( String::CreateFromAscii( "iprcache.stk" ) )
- SvFileStream aOut( aOutTmp, STREAM_STD_WRITE );
-
- if( aOut.IsOpen() && !aOut.GetError() && ppHash )
- {
- ByteString aStr( "Gefunden: ");
- aStr += nFound;
- aStr += " Verloren: ";
- aStr += nLost;
- ULONG nSumSum = 0;
- aOut << aStr.GetBuffer() << endl;
- for( ULONG i = 0; i < nTblSize; ++i )
- {
- aStr = "Index: ";
- aStr += i;
- aStr += " Tiefe: ";
- ULONG nDeep = 0;
- ULONG nSum = 0;
- IPRCachedWord* pTmp = *( ppHash + i );
- while( pTmp )
- {
- ++nDeep;
- nSum += pTmp->GetFound();
- pTmp = pTmp->GetNext();
- }
- aStr += nDeep;
- aStr += " Anzahl: ";
- aStr += nSum;
- nSumSum += nSum;
- aOut << aStr.GetBuffer() << endl;
- pTmp = *( ppHash + i );
- aStr = " Found: ";
- while( pTmp )
- {
- aStr += pTmp->GetFound();
- aStr += " ";
- pTmp = pTmp->GetNext();
- }
- aOut << aStr.GetBuffer() << endl;
- }
- aStr = "Summe: ";
- aStr += nSumSum;
- aOut << aStr.GetBuffer() << endl;
- }
-#endif
-
- while( pFirst )
- {
- pLast = pFirst->GetNext();
- delete pFirst;
- pFirst = pLast;
- }
- delete ppHash;
+ Reference<XDictionaryList> aEmptyList;
+ Reference<XPropertySet> aEmptySet;
+ pFlushLstnr->SetDicList( aEmptyList );
+ pFlushLstnr->SetPropSet( aEmptySet );
}
-void IPRSpellCache::Flush()
+void SpellCache::Flush()
{
MutexGuard aGuard( GetLinguMutex() );
-
- if( ppHash )
- {
- while( pFirst )
- {
- pLast = pFirst->GetNext();
- delete pFirst;
- pFirst = pLast;
- }
- delete ppHash;
- ppHash = NULL;
- nIndex = 0;
- nCount = 0;
- nInputPos = 0;
- nInputValue = 0;
-#ifdef DBG_STATISTIC
- nFound = 0;
- nLost = 0;
-#endif
- }
+ // clear word list
+ LangWordList_t aEmpty;
+ aWordLists.swap( aEmpty );
}
-BOOL IPRSpellCache::CheckWord( const String& rWord, INT16 nLang, BOOL bAllLang )
+bool SpellCache::CheckWord( const OUString& rWord, LanguageType nLang )
{
MutexGuard aGuard( GetLinguMutex() );
-
- BOOL bRet = FALSE;
- // Hash-Index-Berechnung
- nIndex = 0;
- const sal_Unicode* pp = rWord.GetBuffer();
- while( *pp )
- nIndex = nIndex << 1 ^ *pp++;
- nIndex %= nTblSize;
-
- if( ppHash )
- {
- pRun = *(ppHash + nIndex);
-
- if( pRun && FALSE == ( bRet = (rWord == pRun->GetWord() &&
- (nLang == pRun->GetLang() || bAllLang)) ) )
- {
- IPRCachedWord* pTmp = pRun->GetNext();
- while( pTmp && FALSE ==( bRet = ( rWord == pTmp->GetWord() &&
- (nLang == pTmp->GetLang() || bAllLang) ) ) )
- {
- pRun = pTmp;
- pTmp = pTmp->GetNext();
- }
- if ( bRet )
- { // Gefunden: Umsortieren in der Hash-Liste
- pRun->SetNext( pTmp->GetNext() );
- pTmp->SetNext( *( ppHash + nIndex ) );
- *( ppHash + nIndex ) = pTmp;
- pRun = pTmp;
- }
- }
- if( bRet )
- {
- if ( pRun->GetPrev() )
- { // Wenn wir noch nicht erster sind, werden wir es jetzt:
- if (
- ((pRun->GetFound() <= nInputValue) && (++nInputPos > IPR_CACHE_MAXINPUT)) ||
- ((pInput == pRun) && NULL == (pInput = pRun->GetFollow()))
- )
-
- { // Wenn die Input-Stelle am Maximum anlangt, erhoehen
- ++nInputValue; // wir den InputValue und gehen wieder
- nInputPos = 0; // an den Anfang
- pInput = pFirst;
- }
- IPRCachedWord* pTmp = pRun->GetFollow();
- pRun->GetPrev()->SetFollow( pTmp ); //Unser Ex-Prev -> Ex-Follow
- pRun->SetFollow( pFirst ); // Wir selbst -> Ex-First
- pFirst->SetPrev( pRun ); // Wir selbst <- Ex-First
- if( pTmp )
- pTmp->SetPrev( pRun->GetPrev() ); // Ex-Prev <- Ex-Follow
- else
- pLast = pRun->GetPrev(); // falls wir letzter waren
- pRun->SetPrev( NULL ); // Erste haben keinen Prev
- pFirst = pRun; // Wir sind Erster!
- }
- pRun->IncFound(); // Mitzaehlen, wie oft wiedergefunden
- }
- }
- return bRet;
+ WordList_t &rList = aWordLists[ nLang ];
+ const WordList_t::const_iterator aIt = rList.find( rWord );
+ return aIt != rList.end();
}
-void IPRSpellCache::AddWord( const String& rWord, INT16 nLang )
+void SpellCache::AddWord( const OUString& rWord, LanguageType nLang )
{
MutexGuard aGuard( GetLinguMutex() );
-
- if( !ppHash )
- {
- ppHash = new IPRCachedWord* [ nTblSize ];
- memset( (void *)ppHash, 0, ( sizeof( IPRCachedWord* ) * nTblSize ) );
- }
- IPRCachedWord* pTmp;
- if( nCount == IPR_CACHE_MAX-1 )
- {
- ULONG nDel = 0;
- pRun = pLast; // Der letzte wird ueberschrieben
- const sal_Unicode* pp = pRun->GetWord().GetBuffer();
- while( *pp )
- nDel = nDel << 1 ^ *pp++;
- nDel %= nTblSize; // Hash-Index des letzten
- // Der letzte wird aus seiner alten Hash-Liste entfernt
- if( ( pTmp = *( ppHash + nDel ) ) == pRun )
- *( ppHash + nDel ) = pRun->GetNext();
- else
- {
- while( pTmp->GetNext() != pRun )
- pTmp = pTmp->GetNext();
- pTmp->SetNext( pRun->GetNext() );
- }
- pRun->SetWord( rWord ); // Ueberschreiben des alten Inhalts
- pRun->SetLang( nLang );
- pRun->SetFound( 0 );
- }
- else
- {
- ++nCount;
- pRun = new IPRCachedWord( rWord, pFirst, nLang );
- if( pFirst )
- pFirst->SetPrev( pRun );
- pFirst = pRun; // Ganz Neue kommen erstmal nach vorne
- if ( !pLast )
- {
- pLast = pRun;
- pInput = pRun;
- }
- }
-
- pRun->SetNext( *( ppHash + nIndex ) ); // In der Hash-Liste
- *(ppHash + nIndex ) = pRun; // vorne einsortieren
-
- // In der LRU-Kette umsortieren ...
- if ( pRun != pInput && pRun != pInput->GetPrev() )
- {
- pTmp = pRun->GetPrev();
- IPRCachedWord* pFoll = pRun->GetFollow();
- // Entfernen aus der alten Position
- if( pTmp )
- pTmp->SetFollow( pFoll );
- else
- pFirst = pFoll; // wir waren erster
- if( pFoll )
- pFoll->SetPrev( pTmp );
- else
- pLast = pTmp; // wir waren letzter
- // Einfuegen vor pInput
- if( NULL != (pTmp = pInput->GetPrev()) )
- pTmp->SetFollow( pRun );
- else
- pFirst = pRun; // pInput war erster
- pRun->SetPrev( pTmp );
- pRun->SetFollow( pInput );
- pInput->SetPrev( pRun );
- }
- pInput = pRun; // pInput zeigt auf den zuletzt einsortierten
+ WordList_t & rList = aWordLists[ nLang ];
+ // occasional clean-up...
+ if (rList.size() > 500)
+ rList.clear();
+ rList.insert( rWord );
}
-
///////////////////////////////////////////////////////////////////////////
} // namespace linguistic
diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx
index afec81a4f0..692122ea9b 100644
--- a/linguistic/source/lngopt.cxx
+++ b/linguistic/source/lngopt.cxx
@@ -130,14 +130,14 @@ BOOL LinguOptions::SetValue( Any &rOld, const Any &rVal, INT32 nWID )
switch( nWID )
{
- case WID_IS_GERMAN_PRE_REFORM : pbVal = &pData->bIsGermanPreReform; break;
+ case WID_IS_GERMAN_PRE_REFORM : /*! deprecated !*/ break;
case WID_IS_USE_DICTIONARY_LIST : pbVal = &pData->bIsUseDictionaryList; break;
case WID_IS_IGNORE_CONTROL_CHARACTERS : pbVal = &pData->bIsIgnoreControlCharacters; break;
case WID_IS_HYPH_AUTO : pbVal = &pData->bIsHyphAuto; break;
case WID_IS_HYPH_SPECIAL : pbVal = &pData->bIsHyphSpecial; break;
case WID_IS_SPELL_AUTO : pbVal = &pData->bIsSpellAuto; break;
- case WID_IS_SPELL_HIDE : pbVal = &pData->bIsSpellHideMarkings; break;
- case WID_IS_SPELL_IN_ALL_LANGUAGES :pbVal = &pData->bIsSpellInAllLanguages; break;
+ case WID_IS_SPELL_HIDE : /*! deprecated !*/ break;
+ case WID_IS_SPELL_IN_ALL_LANGUAGES :/*! deprecated !*/ break;
case WID_IS_SPELL_SPECIAL : pbVal = &pData->bIsSpellSpecial; break;
case WID_IS_WRAP_REVERSE : pbVal = &pData->bIsSpellReverse; break;
case WID_DEFAULT_LANGUAGE : pnVal = &pData->nDefaultLanguage; break;
@@ -164,7 +164,7 @@ BOOL LinguOptions::SetValue( Any &rOld, const Any &rVal, INT32 nWID )
}
default :
{
- DBG_ERROR("lng : unknown WID");
+ DBG_ASSERT( 0,"lng : unknown WID");
bRes = FALSE;
}
}
@@ -207,14 +207,14 @@ void LinguOptions::GetValue( Any &rVal, INT32 nWID ) const
switch( nWID )
{
- case WID_IS_GERMAN_PRE_REFORM : pbVal = &pData->bIsGermanPreReform; break;
+ case WID_IS_GERMAN_PRE_REFORM : /*! deprecated !*/ break;
case WID_IS_USE_DICTIONARY_LIST : pbVal = &pData->bIsUseDictionaryList; break;
case WID_IS_IGNORE_CONTROL_CHARACTERS : pbVal = &pData->bIsIgnoreControlCharacters; break;
case WID_IS_HYPH_AUTO : pbVal = &pData->bIsHyphAuto; break;
case WID_IS_HYPH_SPECIAL : pbVal = &pData->bIsHyphSpecial; break;
case WID_IS_SPELL_AUTO : pbVal = &pData->bIsSpellAuto; break;
- case WID_IS_SPELL_HIDE : pbVal = &pData->bIsSpellHideMarkings; break;
- case WID_IS_SPELL_IN_ALL_LANGUAGES :pbVal = &pData->bIsSpellInAllLanguages; break;
+ case WID_IS_SPELL_HIDE : /*! deprecated !*/ break;
+ case WID_IS_SPELL_IN_ALL_LANGUAGES :/*! deprecated !*/ break;
case WID_IS_SPELL_SPECIAL : pbVal = &pData->bIsSpellSpecial; break;
case WID_IS_WRAP_REVERSE : pbVal = &pData->bIsSpellReverse; break;
case WID_DEFAULT_LANGUAGE : pnVal = &pData->nDefaultLanguage; break;
@@ -244,7 +244,7 @@ void LinguOptions::GetValue( Any &rVal, INT32 nWID ) const
}
default :
{
- DBG_ERROR("lng : unknown WID");
+ DBG_ASSERT( 0,"lng : unknown WID");
}
}
@@ -265,7 +265,7 @@ struct WID_Name
//! since the WID is used as index in this table!
WID_Name aWID_Name[] =
{
- { WID_IS_GERMAN_PRE_REFORM, UPN_IS_GERMAN_PRE_REFORM },
+ { 0, 0 },
{ WID_IS_USE_DICTIONARY_LIST, UPN_IS_USE_DICTIONARY_LIST },
{ WID_IS_IGNORE_CONTROL_CHARACTERS, UPN_IS_IGNORE_CONTROL_CHARACTERS },
{ WID_IS_SPELL_UPPER_CASE, UPN_IS_SPELL_UPPER_CASE },
@@ -276,8 +276,8 @@ WID_Name aWID_Name[] =
{ WID_HYPH_MIN_WORD_LENGTH, UPN_HYPH_MIN_WORD_LENGTH },
{ WID_DEFAULT_LOCALE, UPN_DEFAULT_LOCALE },
{ WID_IS_SPELL_AUTO, UPN_IS_SPELL_AUTO },
- { WID_IS_SPELL_HIDE, UPN_IS_SPELL_HIDE },
- { WID_IS_SPELL_IN_ALL_LANGUAGES, UPN_IS_SPELL_IN_ALL_LANGUAGES },
+ { 0, 0 },
+ { 0, 0 },
{ WID_IS_SPELL_SPECIAL, UPN_IS_SPELL_SPECIAL },
{ WID_IS_HYPH_AUTO, UPN_IS_HYPH_AUTO },
{ WID_IS_HYPH_SPECIAL, UPN_IS_HYPH_SPECIAL },
@@ -292,7 +292,7 @@ WID_Name aWID_Name[] =
};
-OUString LinguOptions::GetName( INT32 nWID ) const
+OUString LinguOptions::GetName( INT32 nWID )
{
MutexGuard aGuard( GetLinguMutex() );
@@ -307,7 +307,7 @@ OUString LinguOptions::GetName( INT32 nWID ) const
}
else
{
- DBG_ERROR("lng : unknown WID");
+ DBG_ASSERT( 0,"lng : unknown WID");
}
return aRes;
@@ -333,7 +333,7 @@ static SfxItemPropertyMap aLinguProps[] =
&::getCppuType( (sal_Int16*)0 ), 0, 0 },
{ MAP_CHAR_LEN(UPN_HYPH_MIN_WORD_LENGTH), WID_HYPH_MIN_WORD_LENGTH,
&::getCppuType( (sal_Int16*)0 ), 0, 0 },
- { MAP_CHAR_LEN(UPN_IS_GERMAN_PRE_REFORM), WID_IS_GERMAN_PRE_REFORM,
+ { MAP_CHAR_LEN(UPN_IS_GERMAN_PRE_REFORM), WID_IS_GERMAN_PRE_REFORM, /*! deprecated !*/
&::getBooleanCppuType(), 0, 0 },
{ MAP_CHAR_LEN(UPN_IS_HYPH_AUTO), WID_IS_HYPH_AUTO,
&::getBooleanCppuType(), 0, 0 },
@@ -345,9 +345,9 @@ static SfxItemPropertyMap aLinguProps[] =
&::getBooleanCppuType(), 0, 0 },
{ MAP_CHAR_LEN(UPN_IS_SPELL_CAPITALIZATION), WID_IS_SPELL_CAPITALIZATION,
&::getBooleanCppuType(), 0, 0 },
- { MAP_CHAR_LEN(UPN_IS_SPELL_HIDE), WID_IS_SPELL_HIDE,
+ { MAP_CHAR_LEN(UPN_IS_SPELL_HIDE), WID_IS_SPELL_HIDE, /*! deprecated !*/
&::getBooleanCppuType(), 0, 0 },
- { MAP_CHAR_LEN(UPN_IS_SPELL_IN_ALL_LANGUAGES), WID_IS_SPELL_IN_ALL_LANGUAGES,
+ { MAP_CHAR_LEN(UPN_IS_SPELL_IN_ALL_LANGUAGES), WID_IS_SPELL_IN_ALL_LANGUAGES, /*! deprecated !*/
&::getBooleanCppuType(), 0, 0 },
{ MAP_CHAR_LEN(UPN_IS_SPELL_SPECIAL), WID_IS_SPELL_SPECIAL,
&::getBooleanCppuType(), 0, 0 },
@@ -405,7 +405,7 @@ Reference< XPropertySetInfo > SAL_CALL LinguProps::getPropertySetInfo()
}
void SAL_CALL LinguProps::setPropertyValue(
- const OUString& rPropertyName, const Any& aValue )
+ const OUString& rPropertyName, const Any& rValue )
throw(UnknownPropertyException, PropertyVetoException,
IllegalArgumentException, WrappedTargetException, RuntimeException)
{
@@ -415,11 +415,11 @@ void SAL_CALL LinguProps::setPropertyValue(
SfxItemPropertyMap::GetByName(pMap, rPropertyName);
if (pCur)
{
- Any aOld;
- if (aOpt.SetValue( aOld, aValue, pCur->nWID ))
+ Any aOld( aConfig.GetProperty( pCur->nWID ) );
+ if (aOld != rValue && aConfig.SetProperty( pCur->nWID, rValue ))
{
PropertyChangeEvent aChgEvt( (XPropertySet *) this, rPropertyName,
- FALSE, pCur->nWID, aOld, aValue );
+ FALSE, pCur->nWID, aOld, rValue );
launchEvent( aChgEvt );
}
}
@@ -441,7 +441,7 @@ Any SAL_CALL LinguProps::getPropertyValue( const OUString& rPropertyName )
const SfxItemPropertyMap* pCur = SfxItemPropertyMap::GetByName(pMap, rPropertyName);
if(pCur)
{
- aOpt.GetValue( aRet, pCur->nWID );
+ aRet = aConfig.GetProperty( pCur->nWID );
}
#ifdef LINGU_EXCEPTIONS
else
@@ -520,11 +520,11 @@ void SAL_CALL LinguProps::setFastPropertyValue( sal_Int32 nHandle, const Any& rV
{
MutexGuard aGuard( GetLinguMutex() );
- Any aOld;
- if (aOpt.SetValue( aOld, rValue, nHandle ))
+ Any aOld( aConfig.GetProperty( nHandle ) );
+ if (aOld != rValue && aConfig.SetProperty( nHandle, rValue ))
{
PropertyChangeEvent aChgEvt( (XPropertySet *) this,
- aOpt.GetName( nHandle ), FALSE, nHandle, aOld, rValue );
+ LinguOptions::GetName( nHandle ), FALSE, nHandle, aOld, rValue );
launchEvent( aChgEvt );
}
}
@@ -535,8 +535,7 @@ Any SAL_CALL LinguProps::getFastPropertyValue( sal_Int32 nHandle )
{
MutexGuard aGuard( GetLinguMutex() );
- Any aRes;
- aOpt.GetValue( aRes, nHandle );
+ Any aRes( aConfig.GetProperty( nHandle ) );
return aRes;
}
@@ -554,8 +553,7 @@ Sequence< PropertyValue > SAL_CALL
{
PropertyValue &rVal = pProp[i];
SfxItemPropertyMap &rItem = aLinguProps[i];
- Any aAny;
- aOpt.GetValue( aAny, rItem.nWID );
+ Any aAny( aConfig.GetProperty( rItem.nWID ) );
rVal.Name = OUString( rItem.pName, rItem.nNameLen, RTL_TEXTENCODING_ASCII_US );
rVal.Handle = rItem.nWID;
@@ -576,14 +574,8 @@ void SAL_CALL
const PropertyValue *pVal = rProps.getConstArray();
for (INT32 i = 0; i < nLen; ++i)
{
- Any aOld;
const PropertyValue &rVal = pVal[i];
- if (aOpt.SetValue( aOld, rVal.Value, rVal.Handle ))
- {
- PropertyChangeEvent aChgEvt( (XPropertySet *) this,
- rVal.Name, FALSE, rVal.Handle, aOld, rVal.Value );
- launchEvent( aChgEvt );
- }
+ setPropertyValue( rVal.Name, rVal.Value );
}
}
diff --git a/linguistic/source/lngopt.hxx b/linguistic/source/lngopt.hxx
index ba9b238c68..2c5ee719ae 100644
--- a/linguistic/source/lngopt.hxx
+++ b/linguistic/source/lngopt.hxx
@@ -87,9 +87,8 @@ public:
BOOL SetValue( ::com::sun::star::uno::Any &rOld,
const ::com::sun::star::uno::Any &rVal, INT32 nWID );
void GetValue( ::com::sun::star::uno::Any &rVal, INT32 nWID ) const;
- ::rtl::OUString GetName( INT32 nWID ) const;
-
- BOOL IsSpellInAllLanguages() const { return pData->bIsSpellInAllLanguages; }
+
+ static ::rtl::OUString GetName( INT32 nWID );
const ::com::sun::star::uno::Sequence< rtl::OUString >
GetActiveDics() const { return pData->aActiveDics; }
@@ -134,7 +133,7 @@ class LinguProps :
OPropertyListenerContainerHelper aPropListeners;
SfxItemPropertyMap *pMap;
- LinguOptions aOpt;
+ SvtLinguConfig aConfig;
BOOL bDisposing;
@@ -148,114 +147,35 @@ public:
LinguProps();
// XPropertySet
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
- getPropertySetInfo()
- throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- setPropertyValue( const ::rtl::OUString& aPropertyName,
- const ::com::sun::star::uno::Any& aValue )
- throw(::com::sun::star::beans::UnknownPropertyException,
- ::com::sun::star::beans::PropertyVetoException,
- ::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::lang::WrappedTargetException,
- ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Any SAL_CALL
- getPropertyValue( const ::rtl::OUString& PropertyName )
- throw(::com::sun::star::beans::UnknownPropertyException,
- ::com::sun::star::lang::WrappedTargetException,
- ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- addPropertyChangeListener( const ::rtl::OUString& aPropertyName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertyChangeListener >& rxListener )
- throw(::com::sun::star::beans::UnknownPropertyException,
- ::com::sun::star::lang::WrappedTargetException,
- ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- removePropertyChangeListener( const ::rtl::OUString& aPropertyName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertyChangeListener >& rxListener )
- throw(::com::sun::star::beans::UnknownPropertyException,
- ::com::sun::star::lang::WrappedTargetException,
- ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- addVetoableChangeListener( const ::rtl::OUString& PropertyName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XVetoableChangeListener >& rxListener )
- throw(::com::sun::star::beans::UnknownPropertyException,
- ::com::sun::star::lang::WrappedTargetException,
- ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- removeVetoableChangeListener( const ::rtl::OUString& PropertyName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XVetoableChangeListener >& rxListener )
- throw(::com::sun::star::beans::UnknownPropertyException,
- ::com::sun::star::lang::WrappedTargetException,
- ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
// XFastPropertySet
- virtual void SAL_CALL
- setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue )
- throw(::com::sun::star::beans::UnknownPropertyException,
- ::com::sun::star::beans::PropertyVetoException,
- ::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::lang::WrappedTargetException,
- ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Any SAL_CALL
- getFastPropertyValue( sal_Int32 nHandle )
- throw(::com::sun::star::beans::UnknownPropertyException,
- ::com::sun::star::lang::WrappedTargetException,
- ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
// XPropertyAccess
- virtual ::com::sun::star::uno::Sequence<
- ::com::sun::star::beans::PropertyValue > SAL_CALL
- getPropertyValues()
- throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- setPropertyValues( const ::com::sun::star::uno::Sequence<
- ::com::sun::star::beans::PropertyValue >& aProps )
- throw(::com::sun::star::beans::UnknownPropertyException,
- ::com::sun::star::beans::PropertyVetoException,
- ::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::lang::WrappedTargetException,
- ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getPropertyValues() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
// XComponent
- virtual void SAL_CALL
- dispose()
- throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- addEventListener( const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >& rxListener )
- throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- removeEventListener( const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >& rxListener )
- throw(::com::sun::star::uno::RuntimeException);
-
-
- ////////////////////////////////////////////////////////////
- // Service specific part
- //
+ virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException);
// XServiceInfo
- virtual ::rtl::OUString SAL_CALL
- getImplementationName()
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL
- supportsService( const ::rtl::OUString& ServiceName )
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
- getSupportedServiceNames()
- throw(::com::sun::star::uno::RuntimeException);
-
-
- static inline ::rtl::OUString
- getImplementationName_Static() throw();
- static com::sun::star::uno::Sequence< ::rtl::OUString >
- getSupportedServiceNames_Static() throw();
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+
+ static inline ::rtl::OUString getImplementationName_Static() throw();
+ static com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
};
inline ::rtl::OUString LinguProps::getImplementationName_Static() throw()
diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx
index 26787164bf..630593c48f 100644
--- a/linguistic/source/lngsvcmgr.cxx
+++ b/linguistic/source/lngsvcmgr.cxx
@@ -31,21 +31,21 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_linguistic.hxx"
-#include <cppuhelper/factory.hxx> // helper for factories
#include <com/sun/star/registry/XRegistryKey.hpp>
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/linguistic2/XSupportedLocales.hpp>
-
#include <com/sun/star/linguistic2/DictionaryListEventFlags.hpp>
#include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp>
+
#include <tools/solar.h>
-#include <i18npool/mslangid.hxx>
-#include <svtools/svarray.hxx>
#include <svtools/lingucfg.hxx>
-#include <cppuhelper/extract.hxx>
#include <unotools/processfactory.hxx>
+#include <i18npool/lang.h>
+#include <i18npool/mslangid.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/extract.hxx>
#include <rtl/logfile.hxx>
#include "lngsvcmgr.hxx"
@@ -54,30 +54,20 @@
#include "spelldsp.hxx"
#include "hyphdsp.hxx"
#include "thesdsp.hxx"
+#include "gciterator.hxx"
-using namespace utl;
-using namespace osl;
-using namespace rtl;
using namespace com::sun::star;
-using namespace com::sun::star::container;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::linguistic2;
using namespace linguistic;
-
-
-SV_DECL_VARARR_SORT( SortedINT16Array, INT16, 32, 32)
-SV_IMPL_VARARR_SORT( SortedINT16Array, INT16 );
+using ::rtl::OUString;
// forward declarations
-Sequence< OUString > static GetLangSvcList( const Any &rVal );
-Sequence< OUString > static GetLangSvc( const Any &rVal );
+uno::Sequence< OUString > static GetLangSvcList( const uno::Any &rVal );
+uno::Sequence< OUString > static GetLangSvc( const uno::Any &rVal );
///////////////////////////////////////////////////////////////////////////
-static BOOL lcl_SeqHasString( const Sequence< OUString > &rSeq, const OUString &rText )
+static BOOL lcl_SeqHasString( const uno::Sequence< OUString > &rSeq, const OUString &rText )
{
BOOL bRes = FALSE;
@@ -96,20 +86,20 @@ static BOOL lcl_SeqHasString( const Sequence< OUString > &rSeq, const OUString &
///////////////////////////////////////////////////////////////////////////
-static Sequence< Locale > GetAvailLocales(
- const Sequence< OUString > &rSvcImplNames )
+static uno::Sequence< lang::Locale > GetAvailLocales(
+ const uno::Sequence< OUString > &rSvcImplNames )
{
- Sequence< Locale > aRes;
+ uno::Sequence< lang::Locale > aRes;
- Reference< XMultiServiceFactory > xFac( getProcessServiceFactory() );
+ uno::Reference< lang::XMultiServiceFactory > xFac( utl::getProcessServiceFactory() );
INT32 nNames = rSvcImplNames.getLength();
if (nNames && xFac.is())
{
- SortedINT16Array aLanguages;
+ std::set< LanguageType > aLanguages;
//! since we're going to create one-instance services we have to
//! supply their arguments even if we would not need them here...
- Sequence< Any > aArgs(2);
+ uno::Sequence< uno::Any > aArgs(2);
aArgs.getArray()[0] <<= GetLinguProperties();
// check all services for the supported languages and new
@@ -119,43 +109,45 @@ static Sequence< Locale > GetAvailLocales(
for (i = 0; i < nNames; ++i)
{
- Reference< XSupportedLocales > xSuppLoc;
+ uno::Reference< linguistic2::XSupportedLocales > xSuppLoc;
try
{
- xSuppLoc = Reference< XSupportedLocales >(
- xFac->createInstanceWithArguments( pImplNames[i], aArgs ), UNO_QUERY );
+ xSuppLoc = uno::Reference< linguistic2::XSupportedLocales >(
+ xFac->createInstanceWithArguments( pImplNames[i], aArgs ), uno::UNO_QUERY );
}
catch (uno::Exception &)
{
- DBG_ERROR( "createInstanceWithArguments failed" );
+ DBG_ASSERT( 0, "createInstanceWithArguments failed" );
}
if (xSuppLoc.is())
{
- Sequence< Locale > aLoc( xSuppLoc->getLocales() );
+ uno::Sequence< lang::Locale > aLoc( xSuppLoc->getLocales() );
INT32 nLoc = aLoc.getLength();
for (INT32 k = 0; k < nLoc; ++k)
{
- const Locale *pLoc = aLoc.getConstArray();
- INT16 nLang = LocaleToLanguage( pLoc[k] );
+ const lang::Locale *pLoc = aLoc.getConstArray();
+ LanguageType nLang = LocaleToLanguage( pLoc[k] );
// language not already added?
- if (!aLanguages.Seek_Entry( nLang ))
- aLanguages.Insert( nLang );
+ if (aLanguages.find( nLang ) == aLanguages.end())
+ aLanguages.insert( nLang );
}
}
- else {
- DBG_ERROR( "interface not supported by service" );
+ else
+ {
+ DBG_ASSERT( 0, "interface not supported by service" );
}
}
// build return sequence
- INT16 nLanguages = aLanguages.Count();
+ INT32 nLanguages = static_cast< INT32 >(aLanguages.size());
aRes.realloc( nLanguages );
- Locale *pRes = aRes.getArray();
- for (i = 0; i < nLanguages; ++i)
+ lang::Locale *pRes = aRes.getArray();
+ std::set< LanguageType >::const_iterator aIt( aLanguages.begin() );
+ for (i = 0; aIt != aLanguages.end(); ++aIt, ++i)
{
- INT16 nLang = aLanguages[(USHORT) i];
+ LanguageType nLang = *aIt;
pRes[i] = CreateLocale( nLang );
}
}
@@ -167,17 +159,17 @@ static Sequence< Locale > GetAvailLocales(
struct SvcInfo
{
- const ::rtl::OUString aSvcImplName;
- const ::com::sun::star::uno::Sequence< INT16 > aSuppLanguages;
+ const OUString aSvcImplName;
+ const uno::Sequence< INT16 > aSuppLanguages;
- SvcInfo( const ::rtl::OUString &rSvcImplName,
- const ::com::sun::star::uno::Sequence< INT16 > &rSuppLanguages ) :
+ SvcInfo( const OUString &rSvcImplName,
+ const uno::Sequence< INT16 > &rSuppLanguages ) :
aSvcImplName (rSvcImplName),
aSuppLanguages (rSuppLanguages)
{
}
- BOOL HasLanguage( INT16 nLanguage ) const;
+ BOOL HasLanguage( INT16 nLanguage ) const;
};
@@ -196,92 +188,39 @@ BOOL SvcInfo::HasLanguage( INT16 nLanguage ) const
}
-typedef SvcInfo * PTR_SVCINFO;
-SV_DECL_PTRARR_DEL( SvcInfoArray, PTR_SVCINFO, 16, 16 )
-SV_IMPL_PTRARR( SvcInfoArray, PTR_SVCINFO * );
-
-
///////////////////////////////////////////////////////////////////////////
-#ifdef NEVER
-
-// not used anymore (see SetAvailableCfgServiceLists)
-
-static void SetAvailableServiceLists( LinguDispatcher &rDispatcher,
- const SvcInfoArray &rInfoArray )
-{
- USHORT nSvcs = rInfoArray.Count();
-
- // build list of all available languages
- SortedINT16Array aLanguages;
- USHORT i;
- for (i = 0; i < nSvcs; ++i)
- {
- const Sequence< INT16 > &rSuppLang = rInfoArray[i]->aSuppLanguages;
- INT32 nLang = rSuppLang.getLength();
- const INT16 *pSuppLang = rSuppLang.getConstArray();
- for (INT32 j = 0; j < nLang; ++j)
- {
- // language not already added?
- if (!aLanguages.Seek_Entry( pSuppLang[j] ))
- aLanguages.Insert( pSuppLang[j] );
- }
- }
-
- // set service list per language to all available services supporting
- // that language
- INT16 nLanguages = aLanguages.Count();
- for (i = 0; i < nLanguages; ++i)
- {
- INT16 nActLang = aLanguages[i];
- Sequence< OUString > aSvcImplNames( nSvcs );
- OUString *pSvcImplName = aSvcImplNames.getArray();
- INT32 nSeqCnt = 0;
- for (USHORT j = 0; j < nSvcs; ++j)
- {
- const SvcInfo &rSvcInfo = *rInfoArray[j];
- if (rSvcInfo.HasLanguage( nActLang ))
- pSvcImplName[ nSeqCnt++ ] = rSvcInfo.aSvcImplName;
- }
- aSvcImplNames.realloc( nSeqCnt );
-
- rDispatcher.SetServiceList( CreateLocale( nActLang ), aSvcImplNames );
- }
-}
-
-#endif
-
-
void LngSvcMgr::SetAvailableCfgServiceLists( LinguDispatcher &rDispatcher,
const SvcInfoArray &rAvailSvcs )
{
- //SvtLinguConfig aCfg;
-
// get list of nodenames to look at for their service list
const char *pEntryName = 0;
BOOL bHasLangSvcList = TRUE;
switch (rDispatcher.GetDspType())
{
- case LinguDispatcher::DSP_SPELL : pEntryName = "ServiceManager/SpellCheckerList"; break;
- case LinguDispatcher::DSP_HYPH : pEntryName = "ServiceManager/HyphenatorList";
- bHasLangSvcList = FALSE;
- break;
- case LinguDispatcher::DSP_THES : pEntryName = "ServiceManager/ThesaurusList"; break;
+ case LinguDispatcher::DSP_SPELL : pEntryName = "ServiceManager/SpellCheckerList"; break;
+ case LinguDispatcher::DSP_GRAMMAR : pEntryName = "ServiceManager/GrammarCheckerList";
+ bHasLangSvcList = FALSE;
+ break;
+ case LinguDispatcher::DSP_HYPH : pEntryName = "ServiceManager/HyphenatorList";
+ bHasLangSvcList = FALSE;
+ break;
+ case LinguDispatcher::DSP_THES : pEntryName = "ServiceManager/ThesaurusList"; break;
default :
- DBG_ERROR( "unexpected case" );
+ DBG_ASSERT( 0, "unexpected case" );
}
String aNode( String::CreateFromAscii( pEntryName ) );
- Sequence < OUString > aNodeNames( /*aCfg.*/GetNodeNames( aNode ) );
+ uno::Sequence < OUString > aNodeNames( /*aCfg.*/GetNodeNames( aNode ) );
INT32 nLen = aNodeNames.getLength();
const OUString *pNodeNames = aNodeNames.getConstArray();
for (INT32 i = 0; i < nLen; ++i)
{
- Sequence< OUString > aSvcImplNames;
+ uno::Sequence< OUString > aSvcImplNames;
- Sequence< OUString > aNames( 1 );
+ uno::Sequence< OUString > aNames( 1 );
OUString *pNames = aNames.getArray();
OUString aPropName( aNode );
@@ -289,12 +228,12 @@ void LngSvcMgr::SetAvailableCfgServiceLists( LinguDispatcher &rDispatcher,
aPropName += pNodeNames[i];
pNames[0] = aPropName;
- Sequence< Any > aValues = /*aCfg.*/GetProperties( aNames );
+ uno::Sequence< uno::Any > aValues = /*aCfg.*/GetProperties( aNames );
if (aValues.getLength())
{
// get list of configured service names for the
// current node (language)
- const Any &rValue = aValues.getConstArray()[0];
+ const uno::Any &rValue = aValues.getConstArray()[0];
if (bHasLangSvcList)
aSvcImplNames = GetLangSvcList( rValue );
else
@@ -305,17 +244,17 @@ void LngSvcMgr::SetAvailableCfgServiceLists( LinguDispatcher &rDispatcher,
{
const OUString *pImplNames = aSvcImplNames.getConstArray();
- INT16 nLang = MsLangId::convertIsoStringToLanguage( pNodeNames[i] );
+ LanguageType nLang = MsLangId::convertIsoStringToLanguage( pNodeNames[i] );
// build list of available services from those
INT32 nCnt = 0;
- Sequence< OUString > aAvailSvcs( nSvcs );
+ uno::Sequence< OUString > aAvailSvcs( nSvcs );
OUString *pAvailSvcs = aAvailSvcs.getArray();
for (INT32 k = 0; k < nSvcs; ++k)
{
// check for availability of the service
- USHORT nAvailSvcs = rAvailSvcs.Count();
- for (USHORT m = 0; m < nAvailSvcs; ++m)
+ size_t nAvailSvcs = rAvailSvcs.size();
+ for (size_t m = 0; m < nAvailSvcs; ++m)
{
const SvcInfo &rSvcInfo = *rAvailSvcs[m];
if (rSvcInfo.aSvcImplName == pImplNames[k] &&
@@ -344,17 +283,18 @@ void LngSvcMgr::SetAvailableCfgServiceLists( LinguDispatcher &rDispatcher,
class LngSvcMgrListenerHelper :
public cppu::WeakImplHelper2
<
- XLinguServiceEventListener,
- XDictionaryListEventListener
+ linguistic2::XLinguServiceEventListener,
+ linguistic2::XDictionaryListEventListener
>
{
- Timer aLaunchTimer;
+ LngSvcMgr &rMyManager;
+ Timer aLaunchTimer;
//cppu::OMultiTypeInterfaceContainerHelper aListeners;
::cppu::OInterfaceContainerHelper aLngSvcMgrListeners;
::cppu::OInterfaceContainerHelper aLngSvcEvtBroadcasters;
- Reference< XDictionaryList > xDicList;
- Reference< XInterface > xMyEvtObj;
+ uno::Reference< linguistic2::XDictionaryList > xDicList;
+ uno::Reference< uno::XInterface > xMyEvtObj;
INT16 nCombinedLngSvcEvt;
@@ -367,42 +307,45 @@ class LngSvcMgrListenerHelper :
DECL_LINK( TimeOut, Timer* );
public:
- LngSvcMgrListenerHelper( const Reference< XInterface > &rxSource,
- const Reference< XDictionaryList > &rxDicList );
+ LngSvcMgrListenerHelper( LngSvcMgr &rLngSvcMgr,
+ const uno::Reference< uno::XInterface > &rxSource,
+ const uno::Reference< linguistic2::XDictionaryList > &rxDicList );
- // XEventListener
+ // lang::XEventListener
virtual void SAL_CALL
- disposing( const EventObject& rSource )
- throw(RuntimeException);
+ disposing( const lang::EventObject& rSource )
+ throw(uno::RuntimeException);
- // XLinguServiceEventListener
+ // linguistic2::XLinguServiceEventListener
virtual void SAL_CALL
- processLinguServiceEvent( const LinguServiceEvent& aLngSvcEvent )
- throw(RuntimeException);
+ processLinguServiceEvent( const linguistic2::LinguServiceEvent& aLngSvcEvent )
+ throw(uno::RuntimeException);
- // XDictionaryListEventListener
+ // linguistic2::XDictionaryListEventListener
virtual void SAL_CALL
processDictionaryListEvent(
- const DictionaryListEvent& rDicListEvent )
- throw(RuntimeException);
+ const linguistic2::DictionaryListEvent& rDicListEvent )
+ throw(uno::RuntimeException);
inline BOOL AddLngSvcMgrListener(
- const Reference< XEventListener >& rxListener );
+ const uno::Reference< lang::XEventListener >& rxListener );
inline BOOL RemoveLngSvcMgrListener(
- const Reference< XEventListener >& rxListener );
- void DisposeAndClear( const EventObject &rEvtObj );
+ const uno::Reference< lang::XEventListener >& rxListener );
+ void DisposeAndClear( const lang::EventObject &rEvtObj );
BOOL AddLngSvcEvtBroadcaster(
- const Reference< XLinguServiceEventBroadcaster > &rxBroadcaster );
+ const uno::Reference< linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster );
BOOL RemoveLngSvcEvtBroadcaster(
- const Reference< XLinguServiceEventBroadcaster > &rxBroadcaster );
+ const uno::Reference< linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster );
void AddLngSvcEvt( INT16 nLngSvcEvt );
};
LngSvcMgrListenerHelper::LngSvcMgrListenerHelper(
- const Reference< XInterface > &rxSource,
- const Reference< XDictionaryList > &rxDicList ) :
+ LngSvcMgr &rLngSvcMgr,
+ const uno::Reference< uno::XInterface > &rxSource,
+ const uno::Reference< linguistic2::XDictionaryList > &rxDicList ) :
+ rMyManager ( rLngSvcMgr ),
aLngSvcMgrListeners ( GetLinguMutex() ),
aLngSvcEvtBroadcasters ( GetLinguMutex() ),
xDicList ( rxDicList ),
@@ -411,7 +354,7 @@ LngSvcMgrListenerHelper::LngSvcMgrListenerHelper(
if (xDicList.is())
{
xDicList->addDictionaryListEventListener(
- (XDictionaryListEventListener *) this, FALSE );
+ (linguistic2::XDictionaryListEventListener *) this, FALSE );
}
//! The timer is used to 'sum up' different events in order to reduce the
@@ -426,12 +369,12 @@ LngSvcMgrListenerHelper::LngSvcMgrListenerHelper(
}
-void SAL_CALL LngSvcMgrListenerHelper::disposing( const EventObject& rSource )
- throw(RuntimeException)
+void SAL_CALL LngSvcMgrListenerHelper::disposing( const lang::EventObject& rSource )
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
- Reference< XInterface > xRef( rSource.Source );
+ uno::Reference< uno::XInterface > xRef( rSource.Source );
if ( xRef.is() )
{
aLngSvcMgrListeners .removeInterface( xRef );
@@ -444,21 +387,24 @@ void SAL_CALL LngSvcMgrListenerHelper::disposing( const EventObject& rSource )
IMPL_LINK( LngSvcMgrListenerHelper, TimeOut, Timer*, pTimer )
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
if (&aLaunchTimer == pTimer)
{
// change event source to LinguServiceManager since the listeners
// probably do not know (and need not to know) about the specific
// SpellChecker's or Hyphenator's.
- LinguServiceEvent aEvtObj( xMyEvtObj, nCombinedLngSvcEvt );
+ linguistic2::LinguServiceEvent aEvtObj( xMyEvtObj, nCombinedLngSvcEvt );
nCombinedLngSvcEvt = 0;
- // pass event on to XLinguServiceEventListener's
+ if (rMyManager.pSpellDsp)
+ rMyManager.pSpellDsp->FlushSpellCache();
+
+ // pass event on to linguistic2::XLinguServiceEventListener's
cppu::OInterfaceIteratorHelper aIt( aLngSvcMgrListeners );
while (aIt.hasMoreElements())
{
- Reference< XLinguServiceEventListener > xRef( aIt.next(), UNO_QUERY );
+ uno::Reference< linguistic2::XLinguServiceEventListener > xRef( aIt.next(), uno::UNO_QUERY );
if (xRef.is())
xRef->processLinguServiceEvent( aEvtObj );
}
@@ -476,20 +422,20 @@ void LngSvcMgrListenerHelper::AddLngSvcEvt( INT16 nLngSvcEvt )
void SAL_CALL
LngSvcMgrListenerHelper::processLinguServiceEvent(
- const LinguServiceEvent& rLngSvcEvent )
- throw(RuntimeException)
+ const linguistic2::LinguServiceEvent& rLngSvcEvent )
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
AddLngSvcEvt( rLngSvcEvent.nEvent );
}
void SAL_CALL
LngSvcMgrListenerHelper::processDictionaryListEvent(
- const DictionaryListEvent& rDicListEvent )
- throw(RuntimeException)
+ const linguistic2::DictionaryListEvent& rDicListEvent )
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
INT16 nDlEvt = rDicListEvent.nCondensedEvent;
if (0 == nDlEvt)
@@ -497,44 +443,46 @@ void SAL_CALL
// we do keep the original event source here though...
- // pass event on to XDictionaryListEventListener's
+ // pass event on to linguistic2::XDictionaryListEventListener's
cppu::OInterfaceIteratorHelper aIt( aLngSvcMgrListeners );
while (aIt.hasMoreElements())
{
- Reference< XDictionaryListEventListener > xRef( aIt.next(), UNO_QUERY );
+ uno::Reference< linguistic2::XDictionaryListEventListener > xRef( aIt.next(), uno::UNO_QUERY );
if (xRef.is())
xRef->processDictionaryListEvent( rDicListEvent );
}
//
- // "translate" DictionaryList event into LinguServiceEvent
+ // "translate" DictionaryList event into linguistic2::LinguServiceEvent
//
INT16 nLngSvcEvt = 0;
//
INT16 nSpellCorrectFlags =
- DictionaryListEventFlags::ADD_NEG_ENTRY |
- DictionaryListEventFlags::DEL_POS_ENTRY |
- DictionaryListEventFlags::ACTIVATE_NEG_DIC |
- DictionaryListEventFlags::DEACTIVATE_POS_DIC;
+ linguistic2::DictionaryListEventFlags::ADD_NEG_ENTRY |
+ linguistic2::DictionaryListEventFlags::DEL_POS_ENTRY |
+ linguistic2::DictionaryListEventFlags::ACTIVATE_NEG_DIC |
+ linguistic2::DictionaryListEventFlags::DEACTIVATE_POS_DIC;
if (0 != (nDlEvt & nSpellCorrectFlags))
- nLngSvcEvt |= LinguServiceEventFlags::SPELL_CORRECT_WORDS_AGAIN;
+ nLngSvcEvt |= linguistic2::LinguServiceEventFlags::SPELL_CORRECT_WORDS_AGAIN;
//
INT16 nSpellWrongFlags =
- DictionaryListEventFlags::ADD_POS_ENTRY |
- DictionaryListEventFlags::DEL_NEG_ENTRY |
- DictionaryListEventFlags::ACTIVATE_POS_DIC |
- DictionaryListEventFlags::DEACTIVATE_NEG_DIC;
+ linguistic2::DictionaryListEventFlags::ADD_POS_ENTRY |
+ linguistic2::DictionaryListEventFlags::DEL_NEG_ENTRY |
+ linguistic2::DictionaryListEventFlags::ACTIVATE_POS_DIC |
+ linguistic2::DictionaryListEventFlags::DEACTIVATE_NEG_DIC;
if (0 != (nDlEvt & nSpellWrongFlags))
- nLngSvcEvt |= LinguServiceEventFlags::SPELL_WRONG_WORDS_AGAIN;
+ nLngSvcEvt |= linguistic2::LinguServiceEventFlags::SPELL_WRONG_WORDS_AGAIN;
//
INT16 nHyphenateFlags =
- DictionaryListEventFlags::ADD_POS_ENTRY |
- DictionaryListEventFlags::DEL_POS_ENTRY |
- DictionaryListEventFlags::ACTIVATE_POS_DIC |
- DictionaryListEventFlags::ACTIVATE_NEG_DIC;
+ linguistic2::DictionaryListEventFlags::ADD_POS_ENTRY |
+ linguistic2::DictionaryListEventFlags::DEL_POS_ENTRY |
+ linguistic2::DictionaryListEventFlags::ACTIVATE_POS_DIC |
+ linguistic2::DictionaryListEventFlags::ACTIVATE_NEG_DIC;
if (0 != (nDlEvt & nHyphenateFlags))
- nLngSvcEvt |= LinguServiceEventFlags::HYPHENATE_AGAIN;
- //
+ nLngSvcEvt |= linguistic2::LinguServiceEventFlags::HYPHENATE_AGAIN;
+
+ if (rMyManager.pSpellDsp)
+ rMyManager.pSpellDsp->FlushSpellCache();
if (nLngSvcEvt)
LaunchEvent( nLngSvcEvt );
}
@@ -542,13 +490,13 @@ void SAL_CALL
void LngSvcMgrListenerHelper::LaunchEvent( INT16 nLngSvcEvtFlags )
{
- LinguServiceEvent aEvt( xMyEvtObj, nLngSvcEvtFlags );
+ linguistic2::LinguServiceEvent aEvt( xMyEvtObj, nLngSvcEvtFlags );
- // pass event on to XLinguServiceEventListener's
+ // pass event on to linguistic2::XLinguServiceEventListener's
cppu::OInterfaceIteratorHelper aIt( aLngSvcMgrListeners );
while (aIt.hasMoreElements())
{
- Reference< XLinguServiceEventListener > xRef( aIt.next(), UNO_QUERY );
+ uno::Reference< linguistic2::XLinguServiceEventListener > xRef( aIt.next(), uno::UNO_QUERY );
if (xRef.is())
xRef->processLinguServiceEvent( aEvt );
}
@@ -556,28 +504,22 @@ void LngSvcMgrListenerHelper::LaunchEvent( INT16 nLngSvcEvtFlags )
inline BOOL LngSvcMgrListenerHelper::AddLngSvcMgrListener(
- const Reference< XEventListener >& rxListener )
+ const uno::Reference< lang::XEventListener >& rxListener )
{
- aLngSvcMgrListeners.addInterface(
- /*::getCppuType((const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >*)0), */
- rxListener );
+ aLngSvcMgrListeners.addInterface( rxListener );
return TRUE;
}
inline BOOL LngSvcMgrListenerHelper::RemoveLngSvcMgrListener(
- const Reference< XEventListener >& rxListener )
+ const uno::Reference< lang::XEventListener >& rxListener )
{
- aLngSvcMgrListeners.removeInterface(
- /*::getCppuType((const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >*)0), */
- rxListener );
+ aLngSvcMgrListeners.removeInterface( rxListener );
return TRUE;
}
-void LngSvcMgrListenerHelper::DisposeAndClear( const EventObject &rEvtObj )
+void LngSvcMgrListenerHelper::DisposeAndClear( const lang::EventObject &rEvtObj )
{
// call "disposing" for all listeners and clear list
aLngSvcMgrListeners .disposeAndClear( rEvtObj );
@@ -586,7 +528,7 @@ void LngSvcMgrListenerHelper::DisposeAndClear( const EventObject &rEvtObj )
cppu::OInterfaceIteratorHelper aIt( aLngSvcEvtBroadcasters );
while (aIt.hasMoreElements())
{
- Reference< XLinguServiceEventBroadcaster > xRef( aIt.next(), UNO_QUERY );
+ uno::Reference< linguistic2::XLinguServiceEventBroadcaster > xRef( aIt.next(), uno::UNO_QUERY );
if (xRef.is())
RemoveLngSvcEvtBroadcaster( xRef );
}
@@ -595,35 +537,35 @@ void LngSvcMgrListenerHelper::DisposeAndClear( const EventObject &rEvtObj )
if (xDicList.is())
{
xDicList->removeDictionaryListEventListener(
- (XDictionaryListEventListener *) this );
+ (linguistic2::XDictionaryListEventListener *) this );
xDicList = 0;
}
}
BOOL LngSvcMgrListenerHelper::AddLngSvcEvtBroadcaster(
- const Reference< XLinguServiceEventBroadcaster > &rxBroadcaster )
+ const uno::Reference< linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster )
{
BOOL bRes = FALSE;
if (rxBroadcaster.is())
{
aLngSvcEvtBroadcasters.addInterface( rxBroadcaster );
rxBroadcaster->addLinguServiceEventListener(
- (XLinguServiceEventListener *) this );
+ (linguistic2::XLinguServiceEventListener *) this );
}
return bRes;
}
BOOL LngSvcMgrListenerHelper::RemoveLngSvcEvtBroadcaster(
- const Reference< XLinguServiceEventBroadcaster > &rxBroadcaster )
+ const uno::Reference< linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster )
{
BOOL bRes = FALSE;
if (rxBroadcaster.is())
{
aLngSvcEvtBroadcasters.removeInterface( rxBroadcaster );
rxBroadcaster->removeLinguServiceEventListener(
- (XLinguServiceEventListener *) this );
+ (linguistic2::XLinguServiceEventListener *) this );
}
return bRes;
}
@@ -637,25 +579,29 @@ LngSvcMgr::LngSvcMgr() :
aEvtListeners ( GetLinguMutex() )
{
bHasAvailSpellLocales =
+ bHasAvailGrammarLocales =
bHasAvailHyphLocales =
bHasAvailThesLocales =
bDisposing = FALSE;
pSpellDsp = 0;
+ pGrammarDsp = 0;
pHyphDsp = 0;
pThesDsp = 0;
- pAvailSpellSvcs = 0;
- pAvailHyphSvcs = 0;
- pAvailThesSvcs = 0;
- pListenerHelper = 0;
+ pAvailSpellSvcs = 0;
+ pAvailGrammarSvcs = 0;
+ pAvailHyphSvcs = 0;
+ pAvailThesSvcs = 0;
+ pListenerHelper = 0;
// request notify events when properties (i.e. something in the subtree) changes
- Sequence< OUString > aNames(3);
+ uno::Sequence< OUString > aNames(4);
OUString *pNames = aNames.getArray();
pNames[0] = A2OU( "ServiceManager/SpellCheckerList" );
- pNames[1] = A2OU( "ServiceManager/HyphenatorList" );
- pNames[2] = A2OU( "ServiceManager/ThesaurusList" );
+ pNames[1] = A2OU( "ServiceManager/GrammarCheckerList" );
+ pNames[2] = A2OU( "ServiceManager/HyphenatorList" );
+ pNames[3] = A2OU( "ServiceManager/ThesaurusList" );
EnableNotification( aNames );
}
@@ -664,26 +610,29 @@ LngSvcMgr::~LngSvcMgr()
{
// memory for pSpellDsp, pHyphDsp, pThesDsp, pListenerHelper
// will be freed in the destructor of the respective Reference's
- // xSpellDsp, xHyphDsp, xThesDsp
+ // xSpellDsp, xGrammarDsp, xHyphDsp, xThesDsp
delete pAvailSpellSvcs;
+ delete pAvailGrammarSvcs;
delete pAvailHyphSvcs;
delete pAvailThesSvcs;
}
-void LngSvcMgr::Notify( const Sequence< OUString > &rPropertyNames )
+void LngSvcMgr::Notify( const uno::Sequence< OUString > &rPropertyNames )
{
const OUString aSpellCheckerList( A2OU("ServiceManager/SpellCheckerList") );
+ const OUString aGrammarCheckerList( A2OU("ServiceManager/GrammarCheckerList") );
const OUString aHyphenatorList( A2OU("ServiceManager/HyphenatorList") );
const OUString aThesaurusList( A2OU("ServiceManager/ThesaurusList") );
- const Sequence< OUString > aSpellCheckerListEntries( GetNodeNames( aSpellCheckerList ) );
- const Sequence< OUString > aHyphenatorListEntries( GetNodeNames( aHyphenatorList ) );
- const Sequence< OUString > aThesaurusListEntries( GetNodeNames( aThesaurusList ) );
+ const uno::Sequence< OUString > aSpellCheckerListEntries( GetNodeNames( aSpellCheckerList ) );
+ const uno::Sequence< OUString > aGrammarCheckerListEntries( GetNodeNames( aGrammarCheckerList ) );
+ const uno::Sequence< OUString > aHyphenatorListEntries( GetNodeNames( aHyphenatorList ) );
+ const uno::Sequence< OUString > aThesaurusListEntries( GetNodeNames( aThesaurusList ) );
- Sequence< Any > aValues;
- Sequence< OUString > aNames( 1 );
+ uno::Sequence< uno::Any > aValues;
+ uno::Sequence< OUString > aNames( 1 );
OUString *pNames = aNames.getArray();
sal_Int32 nLen = rPropertyNames.getLength();
@@ -700,7 +649,7 @@ void LngSvcMgr::Notify( const Sequence< OUString > &rPropertyNames )
OUString aKeyText;
if (nKeyStart != -1 && nKeyEnd != -1)
aKeyText = rName.copy( nKeyStart + 2, nKeyEnd - nKeyStart - 2);
- DBG_ASSERT( aKeyText.getLength() != 0, "unexpected key (Locale) string" );
+ DBG_ASSERT( aKeyText.getLength() != 0, "unexpected key (lang::Locale) string" );
if (0 == rName.compareTo( aSpellCheckerList, aSpellCheckerList.getLength() ))
{
// delete old cached data, needs to be acquired new on demand
@@ -714,7 +663,7 @@ void LngSvcMgr::Notify( const Sequence< OUString > &rPropertyNames )
aPropName += aKeyText;
pNames[0] = aPropName;
aValues = /*aCfg.*/GetProperties( aNames );
- Sequence< OUString > aSvcImplNames;
+ uno::Sequence< OUString > aSvcImplNames;
if (aValues.getLength())
aSvcImplNames = GetLangSvcList( aValues.getConstArray()[0] );
@@ -726,6 +675,34 @@ void LngSvcMgr::Notify( const Sequence< OUString > &rPropertyNames )
pSpellDsp->SetServiceList( CreateLocale(nLang), aSvcImplNames );
}
}
+ else if (0 == rName.compareTo( aGrammarCheckerList, aGrammarCheckerList.getLength() ))
+ {
+ // delete old cached data, needs to be acquired new on demand
+ delete pAvailGrammarSvcs; pAvailGrammarSvcs = 0;
+
+ OUString aNode( aGrammarCheckerList );
+ if (lcl_SeqHasString( aGrammarCheckerListEntries, aKeyText ))
+ {
+ OUString aPropName( aNode );
+ aPropName += OUString::valueOf( (sal_Unicode) '/' );
+ aPropName += aKeyText;
+ pNames[0] = aPropName;
+ aValues = /*aCfg.*/GetProperties( aNames );
+ uno::Sequence< OUString > aSvcImplNames;
+ if (aValues.getLength())
+ aSvcImplNames = GetLangSvc( aValues.getConstArray()[0] );
+
+ LanguageType nLang = LANGUAGE_NONE;
+ if (0 != aKeyText.getLength())
+ nLang = MsLangId::convertIsoStringToLanguage( aKeyText );
+
+ if (SvtLinguConfig().HasGrammarChecker())
+ {
+ GetGrammarCheckerDsp_Impl( sal_False ); // don't set service list, it will be done below
+ pGrammarDsp->SetServiceList( CreateLocale(nLang), aSvcImplNames );
+ }
+ }
+ }
else if (0 == rName.compareTo( aHyphenatorList, aHyphenatorList.getLength() ))
{
// delete old cached data, needs to be acquired new on demand
@@ -739,7 +716,7 @@ void LngSvcMgr::Notify( const Sequence< OUString > &rPropertyNames )
aPropName += aKeyText;
pNames[0] = aPropName;
aValues = /*aCfg.*/GetProperties( aNames );
- Sequence< OUString > aSvcImplNames;
+ uno::Sequence< OUString > aSvcImplNames;
if (aValues.getLength())
aSvcImplNames = GetLangSvc( aValues.getConstArray()[0] );
@@ -764,7 +741,7 @@ void LngSvcMgr::Notify( const Sequence< OUString > &rPropertyNames )
aPropName += aKeyText;
pNames[0] = aPropName;
aValues = /*aCfg.*/GetProperties( aNames );
- Sequence< OUString > aSvcImplNames;
+ uno::Sequence< OUString > aSvcImplNames;
if (aValues.getLength())
aSvcImplNames = GetLangSvcList( aValues.getConstArray()[0] );
@@ -776,8 +753,9 @@ void LngSvcMgr::Notify( const Sequence< OUString > &rPropertyNames )
pThesDsp->SetServiceList( CreateLocale(nLang), aSvcImplNames );
}
}
- else {
- DBG_ERROR( "nofified for unexpected property" );
+ else
+ {
+ DBG_ASSERT( 0, "nofified for unexpected property" );
}
}
}
@@ -795,9 +773,9 @@ void LngSvcMgr::GetListenerHelper_Impl()
{
if (!pListenerHelper)
{
- pListenerHelper = new LngSvcMgrListenerHelper(
+ pListenerHelper = new LngSvcMgrListenerHelper( *this,
(XLinguServiceManager *) this, linguistic::GetDictionaryList() );
- xListenerHelper = (XLinguServiceEventListener *) pListenerHelper;
+ xListenerHelper = (linguistic2::XLinguServiceEventListener *) pListenerHelper;
}
}
@@ -814,6 +792,37 @@ void LngSvcMgr::GetSpellCheckerDsp_Impl( sal_Bool bSetSvcList )
}
+void LngSvcMgr::GetGrammarCheckerDsp_Impl( sal_Bool bSetSvcList )
+{
+ if (!pGrammarDsp && SvtLinguConfig().HasGrammarChecker())
+ {
+ //! since the grammar checking iterator needs to be a one instance service
+ //! we need to create it the correct way!
+ uno::Reference< linguistic2::XProofreadingIterator > xGCI;
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMgr(
+ utl::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+ xGCI = uno::Reference< linguistic2::XProofreadingIterator >(
+ xMgr->createInstance( A2OU( SN_GRAMMARCHECKINGITERATOR ) ), uno::UNO_QUERY_THROW );
+ }
+ catch (uno::Exception &)
+ {
+ }
+ DBG_ASSERT( xGCI.is(), "instantiating grammar checking iterator failed" );
+
+ if (xGCI.is())
+ {
+ pGrammarDsp = dynamic_cast< GrammarCheckingIterator * >(xGCI.get());
+ xGrammarDsp = xGCI;
+ DBG_ASSERT( pGrammarDsp, "failed to get implementation" );
+ if (bSetSvcList)
+ SetCfgServiceLists( *pGrammarDsp );
+ }
+ }
+}
+
+
void LngSvcMgr::GetHyphenatorDsp_Impl( sal_Bool bSetSvcList )
{
if (!pHyphDsp)
@@ -844,11 +853,11 @@ void LngSvcMgr::GetAvailableSpellSvcs_Impl()
{
pAvailSpellSvcs = new SvcInfoArray;
- Reference< XMultiServiceFactory > xFac( getProcessServiceFactory() );
+ uno::Reference< lang::XMultiServiceFactory > xFac( utl::getProcessServiceFactory() );
if (xFac.is())
{
- Reference< XContentEnumerationAccess > xEnumAccess( xFac, UNO_QUERY );
- Reference< XEnumeration > xEnum;
+ uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xFac, uno::UNO_QUERY );
+ uno::Reference< container::XEnumeration > xEnum;
if (xEnumAccess.is())
xEnum = xEnumAccess->createContentEnumeration(
A2OU( SN_SPELLCHECKER ) );
@@ -857,45 +866,109 @@ void LngSvcMgr::GetAvailableSpellSvcs_Impl()
{
while (xEnum->hasMoreElements())
{
- Any aCurrent = xEnum->nextElement();
- Reference< XSingleComponentFactory > xCompFactory;
- Reference< XSingleServiceFactory > xFactory;
+ uno::Any aCurrent = xEnum->nextElement();
+ uno::Reference< lang::XSingleComponentFactory > xCompFactory;
+ uno::Reference< lang::XSingleServiceFactory > xFactory;
- Reference< XSpellChecker > xSvc;
+ uno::Reference< linguistic2::XSpellChecker > xSvc;
if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) )
{
try
{
- Reference < XComponentContext > xContext;
- Reference< XPropertySet > xProps( xFac, UNO_QUERY );
+ uno::Reference < uno::XComponentContext > xContext;
+ uno::Reference< beans::XPropertySet > xProps( xFac, uno::UNO_QUERY );
- xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext;
- xSvc = Reference< XSpellChecker >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), UNO_QUERY );
+ xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext;
+ xSvc = uno::Reference< linguistic2::XSpellChecker >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY );
}
catch (uno::Exception &)
{
- DBG_ERROR( "createInstance failed" );
+ DBG_ASSERT( 0, "createInstance failed" );
}
}
if (xSvc.is())
{
OUString aImplName;
- Sequence< INT16 > aLanguages;
- Reference< XServiceInfo > xInfo( xSvc, UNO_QUERY );
+ uno::Sequence< INT16 > aLanguages;
+ uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY );
+ if (xInfo.is())
+ aImplName = xInfo->getImplementationName();
+ DBG_ASSERT( aImplName.getLength(),
+ "empty implementation name" );
+ uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY );
+ DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" );
+ if (xSuppLoc.is()) {
+ uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales());
+ aLanguages = LocaleSeqToLangSeq( aLocaleSequence );
+ }
+
+ pAvailSpellSvcs->push_back( new SvcInfo( aImplName, aLanguages ) );
+ }
+ }
+ }
+ }
+ }
+}
+
+
+void LngSvcMgr::GetAvailableGrammarSvcs_Impl()
+{
+ if (!pAvailGrammarSvcs)
+ {
+ pAvailGrammarSvcs = new SvcInfoArray;
+
+ uno::Reference< lang::XMultiServiceFactory > xFac( utl::getProcessServiceFactory() );
+ if (xFac.is())
+ {
+ uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xFac, uno::UNO_QUERY );
+ uno::Reference< container::XEnumeration > xEnum;
+ if (xEnumAccess.is())
+ xEnum = xEnumAccess->createContentEnumeration(
+ A2OU( SN_GRAMMARCHECKER ) );
+
+ if (xEnum.is())
+ {
+ while (xEnum->hasMoreElements())
+ {
+ uno::Any aCurrent = xEnum->nextElement();
+ uno::Reference< lang::XSingleComponentFactory > xCompFactory;
+ uno::Reference< lang::XSingleServiceFactory > xFactory;
+
+ uno::Reference< linguistic2::XProofreader > xSvc;
+ if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) )
+ {
+ try
+ {
+ uno::Reference < uno::XComponentContext > xContext;
+ uno::Reference< beans::XPropertySet > xProps( xFac, uno::UNO_QUERY );
+
+ xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext;
+ xSvc = uno::Reference< linguistic2::XProofreader >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY );
+ }
+ catch (uno::Exception &)
+ {
+ DBG_ASSERT( 0, "createInstance failed" );
+ }
+ }
+
+ if (xSvc.is())
+ {
+ OUString aImplName;
+ uno::Sequence< INT16 > aLanguages;
+ uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY );
if (xInfo.is())
aImplName = xInfo->getImplementationName();
DBG_ASSERT( aImplName.getLength(),
"empty implementation name" );
- Reference< XSupportedLocales > xSuppLoc( xSvc, UNO_QUERY );
+ uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY );
DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" );
if (xSuppLoc.is()) {
- Sequence<Locale> aLocaleSequence(xSuppLoc->getLocales());
+ uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales());
aLanguages = LocaleSeqToLangSeq( aLocaleSequence );
}
- pAvailSpellSvcs->Insert( new SvcInfo( aImplName, aLanguages ),
- pAvailSpellSvcs->Count() );
+ pAvailGrammarSvcs->push_back( new SvcInfo( aImplName, aLanguages ) );
}
}
}
@@ -909,11 +982,11 @@ void LngSvcMgr::GetAvailableHyphSvcs_Impl()
if (!pAvailHyphSvcs)
{
pAvailHyphSvcs = new SvcInfoArray;
- Reference< XMultiServiceFactory > xFac( getProcessServiceFactory() );
+ uno::Reference< lang::XMultiServiceFactory > xFac( utl::getProcessServiceFactory() );
if (xFac.is())
{
- Reference< XContentEnumerationAccess > xEnumAccess( xFac, UNO_QUERY );
- Reference< XEnumeration > xEnum;
+ uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xFac, uno::UNO_QUERY );
+ uno::Reference< container::XEnumeration > xEnum;
if (xEnumAccess.is())
xEnum = xEnumAccess->createContentEnumeration( A2OU( SN_HYPHENATOR ) );
@@ -921,46 +994,45 @@ void LngSvcMgr::GetAvailableHyphSvcs_Impl()
{
while (xEnum->hasMoreElements())
{
- Any aCurrent = xEnum->nextElement();
- Reference< XSingleComponentFactory > xCompFactory;
- Reference< XSingleServiceFactory > xFactory;
+ uno::Any aCurrent = xEnum->nextElement();
+ uno::Reference< lang::XSingleComponentFactory > xCompFactory;
+ uno::Reference< lang::XSingleServiceFactory > xFactory;
- Reference< XHyphenator > xSvc;
+ uno::Reference< linguistic2::XHyphenator > xSvc;
if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) )
{
try
{
- Reference < XComponentContext > xContext;
- Reference< XPropertySet > xProps( xFac, UNO_QUERY );
+ uno::Reference < uno::XComponentContext > xContext;
+ uno::Reference< beans::XPropertySet > xProps( xFac, uno::UNO_QUERY );
- xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext;
- xSvc = Reference< XHyphenator >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), UNO_QUERY );
+ xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext;
+ xSvc = uno::Reference< linguistic2::XHyphenator >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY );
}
catch (uno::Exception &)
{
- DBG_ERROR( "createInstance failed" );
+ DBG_ASSERT( 0, "createInstance failed" );
}
}
if (xSvc.is())
{
OUString aImplName;
- Sequence< INT16 > aLanguages;
- Reference< XServiceInfo > xInfo( xSvc, UNO_QUERY );
+ uno::Sequence< INT16 > aLanguages;
+ uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY );
if (xInfo.is())
aImplName = xInfo->getImplementationName();
DBG_ASSERT( aImplName.getLength(),
"empty implementation name" );
- Reference< XSupportedLocales > xSuppLoc( xSvc, UNO_QUERY );
+ uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY );
DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" );
if (xSuppLoc.is()) {
- Sequence<Locale> aLocaleSequence(xSuppLoc->getLocales());
+ uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales());
aLanguages = LocaleSeqToLangSeq( aLocaleSequence );
}
- pAvailHyphSvcs->Insert( new SvcInfo( aImplName, aLanguages ),
- pAvailHyphSvcs->Count() );
+ pAvailHyphSvcs->push_back( new SvcInfo( aImplName, aLanguages ) );
}
}
}
@@ -975,11 +1047,11 @@ void LngSvcMgr::GetAvailableThesSvcs_Impl()
{
pAvailThesSvcs = new SvcInfoArray;
- Reference< XMultiServiceFactory > xFac( getProcessServiceFactory() );
+ uno::Reference< lang::XMultiServiceFactory > xFac( utl::getProcessServiceFactory() );
if (xFac.is())
{
- Reference< XContentEnumerationAccess > xEnumAccess( xFac, UNO_QUERY );
- Reference< XEnumeration > xEnum;
+ uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xFac, uno::UNO_QUERY );
+ uno::Reference< container::XEnumeration > xEnum;
if (xEnumAccess.is())
xEnum = xEnumAccess->createContentEnumeration(
A2OU( SN_THESAURUS ) );
@@ -988,46 +1060,45 @@ void LngSvcMgr::GetAvailableThesSvcs_Impl()
{
while (xEnum->hasMoreElements())
{
- Any aCurrent = xEnum->nextElement();
+ uno::Any aCurrent = xEnum->nextElement();
- Reference< XSingleComponentFactory > xCompFactory;
- Reference< XSingleServiceFactory > xFactory;
+ uno::Reference< lang::XSingleComponentFactory > xCompFactory;
+ uno::Reference< lang::XSingleServiceFactory > xFactory;
- Reference< XThesaurus > xSvc;
+ uno::Reference< linguistic2::XThesaurus > xSvc;
if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) )
{
try
{
- Reference < XComponentContext > xContext;
- Reference< XPropertySet > xProps( xFac, UNO_QUERY );
+ uno::Reference < uno::XComponentContext > xContext;
+ uno::Reference< beans::XPropertySet > xProps( xFac, uno::UNO_QUERY );
- xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext;
- xSvc = Reference< XThesaurus >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), UNO_QUERY );
+ xProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext;
+ xSvc = uno::Reference< linguistic2::XThesaurus >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY );
}
catch (uno::Exception &)
{
- DBG_ERROR( "createInstance failed" );
+ DBG_ASSERT( 0, "createInstance failed" );
}
}
if (xSvc.is())
{
OUString aImplName;
- Sequence< INT16 > aLanguages;
- Reference< XServiceInfo > xInfo( xSvc, UNO_QUERY );
+ uno::Sequence< INT16 > aLanguages;
+ uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY );
if (xInfo.is())
aImplName = xInfo->getImplementationName();
DBG_ASSERT( aImplName.getLength(),
"empty implementation name" );
- Reference< XSupportedLocales > xSuppLoc( xSvc, UNO_QUERY );
+ uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY );
DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" );
if (xSuppLoc.is()) {
- Sequence<Locale> aLocaleSequence(xSuppLoc->getLocales());
+ uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales());
aLanguages = LocaleSeqToLangSeq( aLocaleSequence );
}
- pAvailThesSvcs->Insert( new SvcInfo( aImplName, aLanguages ),
- pAvailThesSvcs->Count() );
+ pAvailThesSvcs->push_back( new SvcInfo( aImplName, aLanguages ) );
}
}
}
@@ -1040,10 +1111,8 @@ void LngSvcMgr::SetCfgServiceLists( SpellCheckerDispatcher &rSpellDsp )
{
RTL_LOGFILE_CONTEXT( aLog, "linguistic: LngSvcMgr::SetCfgServiceLists - Spell" );
- //SvtLinguConfig aCfg;
-
String aNode( String::CreateFromAscii( "ServiceManager/SpellCheckerList" ) );
- Sequence< OUString > aNames( /*aCfg.*/GetNodeNames( aNode ) );
+ uno::Sequence< OUString > aNames( /*aCfg.*/GetNodeNames( aNode ) );
OUString *pNames = aNames.getArray();
INT32 nLen = aNames.getLength();
@@ -1057,13 +1126,13 @@ void LngSvcMgr::SetCfgServiceLists( SpellCheckerDispatcher &rSpellDsp )
pNames[i] = aTmp;
}
- Sequence< Any > aValues( /*aCfg.*/GetProperties( aNames ) );
+ uno::Sequence< uno::Any > aValues( /*aCfg.*/GetProperties( aNames ) );
if (nLen && nLen == aValues.getLength())
{
- const Any *pValues = aValues.getConstArray();
+ const uno::Any *pValues = aValues.getConstArray();
for (INT32 i = 0; i < nLen; ++i)
{
- Sequence< OUString > aSvcImplNames;
+ uno::Sequence< OUString > aSvcImplNames;
if (pValues[i] >>= aSvcImplNames)
{
#if OSL_DEBUG_LEVEL > 1
@@ -1073,7 +1142,7 @@ void LngSvcMgr::SetCfgServiceLists( SpellCheckerDispatcher &rSpellDsp )
String aLocaleStr( pNames[i] );
xub_StrLen nSeperatorPos = aLocaleStr.SearchBackward( sal_Unicode( '/' ) );
aLocaleStr = aLocaleStr.Copy( nSeperatorPos + 1 );
- Locale aLocale( CreateLocale( MsLangId::convertIsoStringToLanguage(aLocaleStr) ) );
+ lang::Locale aLocale( CreateLocale( MsLangId::convertIsoStringToLanguage(aLocaleStr) ) );
rSpellDsp.SetServiceList( aLocale, aSvcImplNames );
}
}
@@ -1081,14 +1150,59 @@ void LngSvcMgr::SetCfgServiceLists( SpellCheckerDispatcher &rSpellDsp )
}
+void LngSvcMgr::SetCfgServiceLists( GrammarCheckingIterator &rGrammarDsp )
+{
+ RTL_LOGFILE_CONTEXT( aLog, "linguistic: LngSvcMgr::SetCfgServiceLists - Grammar" );
+
+ String aNode( String::CreateFromAscii( "ServiceManager/GrammarCheckerList" ) );
+ uno::Sequence< OUString > aNames( /*aCfg.*/GetNodeNames( aNode ) );
+ OUString *pNames = aNames.getArray();
+ INT32 nLen = aNames.getLength();
+
+ // append path prefix need for 'GetProperties' call below
+ String aPrefix( aNode );
+ aPrefix.Append( (sal_Unicode) '/' );
+ for (int i = 0; i < nLen; ++i)
+ {
+ OUString aTmp( aPrefix );
+ aTmp += pNames[i];
+ pNames[i] = aTmp;
+ }
+
+ uno::Sequence< uno::Any > aValues( /*aCfg.*/GetProperties( aNames ) );
+ if (nLen && nLen == aValues.getLength())
+ {
+ const uno::Any *pValues = aValues.getConstArray();
+ for (INT32 i = 0; i < nLen; ++i)
+ {
+ uno::Sequence< OUString > aSvcImplNames;
+ if (pValues[i] >>= aSvcImplNames)
+ {
+ // there should only be one grammar checker in use per language...
+ if (aSvcImplNames.getLength() > 1)
+ aSvcImplNames.realloc(1);
+
+#if OSL_DEBUG_LEVEL > 1
+// INT32 nSvcs = aSvcImplNames.getLength();
+// const OUString *pSvcImplNames = aSvcImplNames.getConstArray();
+#endif
+ String aLocaleStr( pNames[i] );
+ xub_StrLen nSeperatorPos = aLocaleStr.SearchBackward( sal_Unicode( '/' ) );
+ aLocaleStr = aLocaleStr.Copy( nSeperatorPos + 1 );
+ lang::Locale aLocale( CreateLocale( MsLangId::convertIsoStringToLanguage(aLocaleStr) ) );
+ rGrammarDsp.SetServiceList( aLocale, aSvcImplNames );
+ }
+ }
+ }
+}
+
+
void LngSvcMgr::SetCfgServiceLists( HyphenatorDispatcher &rHyphDsp )
{
RTL_LOGFILE_CONTEXT( aLog, "linguistic: LngSvcMgr::SetCfgServiceLists - Hyph" );
- //SvtLinguConfig aCfg;
-
String aNode( String::CreateFromAscii( "ServiceManager/HyphenatorList" ) );
- Sequence< OUString > aNames( /*aCfg.*/GetNodeNames( aNode ) );
+ uno::Sequence< OUString > aNames( /*aCfg.*/GetNodeNames( aNode ) );
OUString *pNames = aNames.getArray();
INT32 nLen = aNames.getLength();
@@ -1102,13 +1216,13 @@ void LngSvcMgr::SetCfgServiceLists( HyphenatorDispatcher &rHyphDsp )
pNames[i] = aTmp;
}
- Sequence< Any > aValues( /*aCfg.*/GetProperties( aNames ) );
+ uno::Sequence< uno::Any > aValues( /*aCfg.*/GetProperties( aNames ) );
if (nLen && nLen == aValues.getLength())
{
- const Any *pValues = aValues.getConstArray();
+ const uno::Any *pValues = aValues.getConstArray();
for (INT32 i = 0; i < nLen; ++i)
{
- Sequence< OUString > aSvcImplNames;
+ uno::Sequence< OUString > aSvcImplNames;
if (pValues[i] >>= aSvcImplNames)
{
// there should only be one hyphenator in use per language...
@@ -1122,7 +1236,7 @@ void LngSvcMgr::SetCfgServiceLists( HyphenatorDispatcher &rHyphDsp )
String aLocaleStr( pNames[i] );
xub_StrLen nSeperatorPos = aLocaleStr.SearchBackward( sal_Unicode( '/' ) );
aLocaleStr = aLocaleStr.Copy( nSeperatorPos + 1 );
- Locale aLocale( CreateLocale( MsLangId::convertIsoStringToLanguage(aLocaleStr) ) );
+ lang::Locale aLocale( CreateLocale( MsLangId::convertIsoStringToLanguage(aLocaleStr) ) );
rHyphDsp.SetServiceList( aLocale, aSvcImplNames );
}
}
@@ -1134,10 +1248,8 @@ void LngSvcMgr::SetCfgServiceLists( ThesaurusDispatcher &rThesDsp )
{
RTL_LOGFILE_CONTEXT( aLog, "linguistic: LngSvcMgr::SetCfgServiceLists - Thes" );
- //SvtLinguConfig aCfg;
-
String aNode( String::CreateFromAscii( "ServiceManager/ThesaurusList" ) );
- Sequence< OUString > aNames( /*aCfg.*/GetNodeNames( aNode ) );
+ uno::Sequence< OUString > aNames( /*aCfg.*/GetNodeNames( aNode ) );
OUString *pNames = aNames.getArray();
INT32 nLen = aNames.getLength();
@@ -1151,13 +1263,13 @@ void LngSvcMgr::SetCfgServiceLists( ThesaurusDispatcher &rThesDsp )
pNames[i] = aTmp;
}
- Sequence< Any > aValues( /*aCfg.*/GetProperties( aNames ) );
+ uno::Sequence< uno::Any > aValues( /*aCfg.*/GetProperties( aNames ) );
if (nLen && nLen == aValues.getLength())
{
- const Any *pValues = aValues.getConstArray();
+ const uno::Any *pValues = aValues.getConstArray();
for (INT32 i = 0; i < nLen; ++i)
{
- Sequence< OUString > aSvcImplNames;
+ uno::Sequence< OUString > aSvcImplNames;
if (pValues[i] >>= aSvcImplNames)
{
#if OSL_DEBUG_LEVEL > 1
@@ -1167,7 +1279,7 @@ void LngSvcMgr::SetCfgServiceLists( ThesaurusDispatcher &rThesDsp )
String aLocaleStr( pNames[i] );
xub_StrLen nSeperatorPos = aLocaleStr.SearchBackward( sal_Unicode( '/' ) );
aLocaleStr = aLocaleStr.Copy( nSeperatorPos + 1 );
- Locale aLocale( CreateLocale( MsLangId::convertIsoStringToLanguage(aLocaleStr) ) );
+ lang::Locale aLocale( CreateLocale( MsLangId::convertIsoStringToLanguage(aLocaleStr) ) );
rThesDsp.SetServiceList( aLocale, aSvcImplNames );
}
}
@@ -1175,16 +1287,16 @@ void LngSvcMgr::SetCfgServiceLists( ThesaurusDispatcher &rThesDsp )
}
-Reference< XSpellChecker > SAL_CALL
+uno::Reference< linguistic2::XSpellChecker > SAL_CALL
LngSvcMgr::getSpellChecker()
- throw(RuntimeException)
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
#if OSL_DEBUG_LEVEL > 1
getAvailableLocales( A2OU( SN_SPELLCHECKER ));
#endif
- Reference< XSpellChecker > xRes;
+ uno::Reference< linguistic2::XSpellChecker > xRes;
if (!bDisposing)
{
if (!xSpellDsp.is())
@@ -1195,16 +1307,16 @@ Reference< XSpellChecker > SAL_CALL
}
-Reference< XHyphenator > SAL_CALL
+uno::Reference< linguistic2::XHyphenator > SAL_CALL
LngSvcMgr::getHyphenator()
- throw(RuntimeException)
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
#if OSL_DEBUG_LEVEL > 1
getAvailableLocales( A2OU( SN_HYPHENATOR ));
#endif
- Reference< XHyphenator > xRes;
+ uno::Reference< linguistic2::XHyphenator > xRes;
if (!bDisposing)
{
if (!xHyphDsp.is())
@@ -1215,16 +1327,16 @@ Reference< XHyphenator > SAL_CALL
}
-Reference< XThesaurus > SAL_CALL
+uno::Reference< linguistic2::XThesaurus > SAL_CALL
LngSvcMgr::getThesaurus()
- throw(RuntimeException)
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
#if OSL_DEBUG_LEVEL > 1
getAvailableLocales( A2OU( SN_THESAURUS ));
#endif
- Reference< XThesaurus > xRes;
+ uno::Reference< linguistic2::XThesaurus > xRes;
if (!bDisposing)
{
if (!xThesDsp.is())
@@ -1237,10 +1349,10 @@ Reference< XThesaurus > SAL_CALL
sal_Bool SAL_CALL
LngSvcMgr::addLinguServiceManagerListener(
- const Reference< XEventListener >& xListener )
- throw(RuntimeException)
+ const uno::Reference< lang::XEventListener >& xListener )
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
BOOL bRes = FALSE;
if (!bDisposing && xListener.is())
@@ -1255,10 +1367,10 @@ sal_Bool SAL_CALL
sal_Bool SAL_CALL
LngSvcMgr::removeLinguServiceManagerListener(
- const Reference< XEventListener >& xListener )
- throw(RuntimeException)
+ const uno::Reference< lang::XEventListener >& xListener )
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
BOOL bRes = FALSE;
if (!bDisposing && xListener.is())
@@ -1272,15 +1384,15 @@ sal_Bool SAL_CALL
}
-Sequence< OUString > SAL_CALL
+uno::Sequence< OUString > SAL_CALL
LngSvcMgr::getAvailableServices(
const OUString& rServiceName,
- const Locale& rLocale )
- throw(RuntimeException)
+ const lang::Locale& rLocale )
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
- Sequence< OUString > aRes;
+ uno::Sequence< OUString > aRes;
const SvcInfoArray *pInfoArray = 0;
if (0 == rServiceName.compareToAscii( SN_SPELLCHECKER ))
@@ -1288,16 +1400,22 @@ Sequence< OUString > SAL_CALL
// don't used cached data here (force re-evaluation in order to have downloaded dictionaries
// already found without the need to restart the office
delete pAvailSpellSvcs; pAvailSpellSvcs = 0;
-// if (!pAvailSpellSvcs)
GetAvailableSpellSvcs_Impl();
pInfoArray = pAvailSpellSvcs;
}
+ else if (0 == rServiceName.compareToAscii( SN_GRAMMARCHECKER ))
+ {
+ // don't used cached data here (force re-evaluation in order to have downloaded dictionaries
+ // already found without the need to restart the office
+ delete pAvailGrammarSvcs; pAvailGrammarSvcs = 0;
+ GetAvailableGrammarSvcs_Impl();
+ pInfoArray = pAvailGrammarSvcs;
+ }
else if (0 == rServiceName.compareToAscii( SN_HYPHENATOR ))
{
// don't used cached data here (force re-evaluation in order to have downloaded dictionaries
// already found without the need to restart the office
delete pAvailHyphSvcs; pAvailHyphSvcs = 0;
-// if (!pAvailHyphSvcs)
GetAvailableHyphSvcs_Impl();
pInfoArray = pAvailHyphSvcs;
}
@@ -1306,7 +1424,6 @@ Sequence< OUString > SAL_CALL
// don't used cached data here (force re-evaluation in order to have downloaded dictionaries
// already found without the need to restart the office
delete pAvailThesSvcs; pAvailThesSvcs = 0;
-// if (!pAvailThesSvcs)
GetAvailableThesSvcs_Impl();
pInfoArray = pAvailThesSvcs;
}
@@ -1314,15 +1431,15 @@ Sequence< OUString > SAL_CALL
if (pInfoArray)
{
// resize to max number of entries
- USHORT nMaxCnt = pInfoArray->Count();
+ size_t nMaxCnt = pInfoArray->size();
aRes.realloc( nMaxCnt );
OUString *pImplName = aRes.getArray();
USHORT nCnt = 0;
- INT16 nLanguage = LocaleToLanguage( rLocale );
- for (USHORT i = 0; i < nMaxCnt; ++i)
+ LanguageType nLanguage = LocaleToLanguage( rLocale );
+ for (size_t i = 0; i < nMaxCnt; ++i)
{
- const SvcInfo *pInfo = pInfoArray->GetObject(i);
+ const SvcInfo *pInfo = (*pInfoArray)[i];
if (LANGUAGE_NONE == nLanguage
|| (pInfo && pInfo->HasLanguage( nLanguage )))
{
@@ -1339,22 +1456,27 @@ Sequence< OUString > SAL_CALL
}
-Sequence< Locale > SAL_CALL
+uno::Sequence< lang::Locale > SAL_CALL
LngSvcMgr::getAvailableLocales(
const OUString& rServiceName )
- throw(RuntimeException)
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
- Sequence< Locale > aRes;
+ uno::Sequence< lang::Locale > aRes;
- Sequence< Locale > *pAvailLocales = NULL;
+ uno::Sequence< lang::Locale > *pAvailLocales = NULL;
BOOL *pHasAvailLocales = NULL;
if (0 == rServiceName.compareToAscii( SN_SPELLCHECKER ))
{
pAvailLocales = &aAvailSpellLocales;
pHasAvailLocales = &bHasAvailSpellLocales;
}
+ else if (0 == rServiceName.compareToAscii( SN_GRAMMARCHECKER ))
+ {
+ pAvailLocales = &aAvailGrammarLocales;
+ pHasAvailLocales = &bHasAvailGrammarLocales;
+ }
else if (0 == rServiceName.compareToAscii( SN_HYPHENATOR ))
{
pAvailLocales = &aAvailHyphLocales;
@@ -1374,7 +1496,7 @@ Sequence< Locale > SAL_CALL
// if (!*pHasAvailLocales)
// {
*pAvailLocales = GetAvailLocales(
- getAvailableServices( rServiceName, Locale() ) );
+ getAvailableServices( rServiceName, lang::Locale() ) );
// *pHasAvailLocales = TRUE;
// }
aRes = *pAvailLocales;
@@ -1383,8 +1505,8 @@ Sequence< Locale > SAL_CALL
return aRes;
}
-static BOOL IsEqSvcList( const Sequence< OUString > &rList1,
- const Sequence< OUString > &rList2 )
+static BOOL IsEqSvcList( const uno::Sequence< OUString > &rList1,
+ const uno::Sequence< OUString > &rList2 )
{
// returns TRUE iff both sequences are equal
@@ -1408,19 +1530,19 @@ static BOOL IsEqSvcList( const Sequence< OUString > &rList1,
void SAL_CALL
LngSvcMgr::setConfiguredServices(
const OUString& rServiceName,
- const Locale& rLocale,
- const Sequence< OUString >& rServiceImplNames )
- throw(RuntimeException)
+ const lang::Locale& rLocale,
+ const uno::Sequence< OUString >& rServiceImplNames )
+ throw(uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT( aLog, "linguistic: LngSvcMgr::setConfiguredServices" );
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
#if OSL_DEBUG_LEVEL > 1
// const OUString *pImplNames = rServiceImplNames.getConstArray();
#endif
- INT16 nLanguage = LocaleToLanguage( rLocale );
+ LanguageType nLanguage = LocaleToLanguage( rLocale );
if (LANGUAGE_NONE != nLanguage)
{
if (0 == rServiceName.compareToAscii( SN_SPELLCHECKER ))
@@ -1436,8 +1558,24 @@ void SAL_CALL
if (pListenerHelper && bChanged)
pListenerHelper->AddLngSvcEvt(
- LinguServiceEventFlags::SPELL_CORRECT_WORDS_AGAIN |
- LinguServiceEventFlags::SPELL_WRONG_WORDS_AGAIN );
+ linguistic2::LinguServiceEventFlags::SPELL_CORRECT_WORDS_AGAIN |
+ linguistic2::LinguServiceEventFlags::SPELL_WRONG_WORDS_AGAIN );
+ }
+ }
+ else if (0 == rServiceName.compareToAscii( SN_GRAMMARCHECKER ))
+ {
+ if (!xGrammarDsp.is())
+ GetGrammarCheckerDsp_Impl();
+ BOOL bChanged = !IsEqSvcList( rServiceImplNames,
+ pGrammarDsp->GetServiceList( rLocale ) );
+ if (bChanged)
+ {
+ pGrammarDsp->SetServiceList( rLocale, rServiceImplNames );
+ SaveCfgSvcs( A2OU( SN_GRAMMARCHECKER ) );
+
+ if (pListenerHelper && bChanged)
+ pListenerHelper->AddLngSvcEvt(
+ linguistic2::LinguServiceEventFlags::PROOFREAD_AGAIN );
}
}
else if (0 == rServiceName.compareToAscii( SN_HYPHENATOR ))
@@ -1453,7 +1591,7 @@ void SAL_CALL
if (pListenerHelper && bChanged)
pListenerHelper->AddLngSvcEvt(
- LinguServiceEventFlags::HYPHENATE_AGAIN );
+ linguistic2::LinguServiceEventFlags::HYPHENATE_AGAIN );
}
}
else if (0 == rServiceName.compareToAscii( SN_THESAURUS ))
@@ -1479,22 +1617,27 @@ BOOL LngSvcMgr::SaveCfgSvcs( const String &rServiceName )
BOOL bRes = FALSE;
LinguDispatcher *pDsp = 0;
- Sequence< Locale > aLocales;
+ uno::Sequence< lang::Locale > aLocales;
if (0 == rServiceName.CompareToAscii( SN_SPELLCHECKER ))
{
if (!pSpellDsp)
GetSpellCheckerDsp_Impl();
pDsp = pSpellDsp;
-// aLocales = xSpellDsp->getLocales();
aLocales = getAvailableLocales( A2OU( SN_SPELLCHECKER ) );
}
+ else if (0 == rServiceName.CompareToAscii( SN_GRAMMARCHECKER ))
+ {
+ if (!pGrammarDsp)
+ GetGrammarCheckerDsp_Impl();
+ pDsp = pGrammarDsp;
+ aLocales = getAvailableLocales( A2OU( SN_GRAMMARCHECKER ) );
+ }
else if (0 == rServiceName.CompareToAscii( SN_HYPHENATOR ))
{
if (!pHyphDsp)
GetHyphenatorDsp_Impl();
pDsp = pHyphDsp;
-// aLocales = xHyphDsp->getLocales();
aLocales = getAvailableLocales( A2OU( SN_HYPHENATOR ) );
}
else if (0 == rServiceName.CompareToAscii( SN_THESAURUS ))
@@ -1502,37 +1645,37 @@ BOOL LngSvcMgr::SaveCfgSvcs( const String &rServiceName )
if (!pThesDsp)
GetThesaurusDsp_Impl();
pDsp = pThesDsp;
-// aLocales = xThesDsp->getLocales();
aLocales = getAvailableLocales( A2OU( SN_THESAURUS ) );
}
if (pDsp && aLocales.getLength())
{
- //SvtLinguConfig aCfg;
-
INT32 nLen = aLocales.getLength();
- const Locale *pLocale = aLocales.getConstArray();
+ const lang::Locale *pLocale = aLocales.getConstArray();
- Sequence< PropertyValue > aValues( nLen );
- PropertyValue *pValues = aValues.getArray();
- PropertyValue *pValue = pValues;
+ uno::Sequence< beans::PropertyValue > aValues( nLen );
+ beans::PropertyValue *pValues = aValues.getArray();
+ beans::PropertyValue *pValue = pValues;
// get node name to be used
const char *pNodeName = NULL;
if (pDsp == pSpellDsp)
pNodeName = "ServiceManager/SpellCheckerList";
- else if (pDsp == pThesDsp)
- pNodeName = "ServiceManager/ThesaurusList";
+ else if (pDsp == pGrammarDsp)
+ pNodeName = "ServiceManager/GrammarCheckerList";
else if (pDsp == pHyphDsp)
pNodeName = "ServiceManager/HyphenatorList";
- else {
- DBG_ERROR( "node name missing" );
+ else if (pDsp == pThesDsp)
+ pNodeName = "ServiceManager/ThesaurusList";
+ else
+ {
+ DBG_ASSERT( 0, "node name missing" );
}
OUString aNodeName( A2OU(pNodeName) );
for (INT32 i = 0; i < nLen; ++i)
{
- Sequence< OUString > aSvcImplNames;
+ uno::Sequence< OUString > aSvcImplNames;
aSvcImplNames = pDsp->GetServiceList( pLocale[i] );
#if OSL_DEBUG_LEVEL > 1
@@ -1544,9 +1687,9 @@ BOOL LngSvcMgr::SaveCfgSvcs( const String &rServiceName )
}
#endif
// build value to be written back to configuration
- Any aCfgAny;
- if (pDsp == pHyphDsp && aSvcImplNames.getLength() > 1)
- aSvcImplNames.realloc(1); // there should be only one entry for hyphenators (because they are not chained)
+ uno::Any aCfgAny;
+ if ((pDsp == pHyphDsp || pDsp == pGrammarDsp) && aSvcImplNames.getLength() > 1)
+ aSvcImplNames.realloc(1); // there should be only one entry for hyphenators or grammar checkers (because they are not chained)
aCfgAny <<= aSvcImplNames;
DBG_ASSERT( aCfgAny.hasValue(), "missing value for 'Any' type" );
@@ -1569,9 +1712,9 @@ BOOL LngSvcMgr::SaveCfgSvcs( const String &rServiceName )
}
-static Sequence< OUString > GetLangSvcList( const Any &rVal )
+static uno::Sequence< OUString > GetLangSvcList( const uno::Any &rVal )
{
- Sequence< OUString > aRes;
+ uno::Sequence< OUString > aRes;
if (rVal.hasValue())
{
@@ -1594,9 +1737,9 @@ static Sequence< OUString > GetLangSvcList( const Any &rVal )
}
-static Sequence< OUString > GetLangSvc( const Any &rVal )
+static uno::Sequence< OUString > GetLangSvc( const uno::Any &rVal )
{
- Sequence< OUString > aRes;
+ uno::Sequence< OUString > aRes;
if (!rVal.hasValue())
return aRes;
@@ -1618,8 +1761,9 @@ static Sequence< OUString > GetLangSvc( const Any &rVal )
aRes.realloc(1);
aRes.getArray()[0] = aImplName;
}
- else {
- DBG_ERROR( "GetLangSvc: unexpected type encountered" );
+ else
+ {
+ DBG_ASSERT( 0, "GetLangSvc: unexpected type encountered" );
}
}
@@ -1629,28 +1773,26 @@ static Sequence< OUString > GetLangSvc( const Any &rVal )
///////////////////////////////////////////////////////////////////////////
-Sequence< OUString > SAL_CALL
+uno::Sequence< OUString > SAL_CALL
LngSvcMgr::getConfiguredServices(
const OUString& rServiceName,
- const Locale& rLocale )
- throw(RuntimeException)
+ const lang::Locale& rLocale )
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
- Sequence< OUString > aSvcImplNames;
+ uno::Sequence< OUString > aSvcImplNames;
- INT16 nLanguage = LocaleToLanguage( rLocale );
+ LanguageType nLanguage = LocaleToLanguage( rLocale );
OUString aCfgLocale( MsLangId::convertLanguageToIsoString( nLanguage ) );
- //SvtLinguConfig aCfg;
-
- Sequence< Any > aValues;
- Sequence< OUString > aNames( 1 );
+ uno::Sequence< uno::Any > aValues;
+ uno::Sequence< OUString > aNames( 1 );
OUString *pNames = aNames.getArray();
if ( 0 == rServiceName.compareToAscii( SN_SPELLCHECKER ) )
{
OUString aNode( OUString::createFromAscii( "ServiceManager/SpellCheckerList" ));
- const Sequence< OUString > aNodeEntries( GetNodeNames( aNode ) );
+ const uno::Sequence< OUString > aNodeEntries( GetNodeNames( aNode ) );
if (lcl_SeqHasString( aNodeEntries, aCfgLocale ))
{
OUString aPropName( aNode );
@@ -1662,10 +1804,25 @@ Sequence< OUString > SAL_CALL
aSvcImplNames = GetLangSvcList( aValues.getConstArray()[0] );
}
}
+ else if ( 0 == rServiceName.compareToAscii( SN_GRAMMARCHECKER ) )
+ {
+ OUString aNode( OUString::createFromAscii( "ServiceManager/GrammarCheckerList" ));
+ const uno::Sequence< OUString > aNodeEntries( GetNodeNames( aNode ) );
+ if (lcl_SeqHasString( aNodeEntries, aCfgLocale ))
+ {
+ OUString aPropName( aNode );
+ aPropName += OUString::valueOf( (sal_Unicode) '/' );
+ aPropName += aCfgLocale;
+ pNames[0] = aPropName;
+ aValues = /*aCfg.*/GetProperties( aNames );
+ if (aValues.getLength())
+ aSvcImplNames = GetLangSvc( aValues.getConstArray()[0] );
+ }
+ }
else if ( 0 == rServiceName.compareToAscii( SN_HYPHENATOR ) )
{
OUString aNode( OUString::createFromAscii( "ServiceManager/HyphenatorList" ));
- const Sequence< OUString > aNodeEntries( GetNodeNames( aNode ) );
+ const uno::Sequence< OUString > aNodeEntries( GetNodeNames( aNode ) );
if (lcl_SeqHasString( aNodeEntries, aCfgLocale ))
{
OUString aPropName( aNode );
@@ -1680,7 +1837,7 @@ Sequence< OUString > SAL_CALL
else if ( 0 == rServiceName.compareToAscii( SN_THESAURUS ) )
{
OUString aNode( OUString::createFromAscii( "ServiceManager/ThesaurusList" ));
- const Sequence< OUString > aNodeEntries( GetNodeNames( aNode ) );
+ const uno::Sequence< OUString > aNodeEntries( GetNodeNames( aNode ) );
if (lcl_SeqHasString( aNodeEntries, aCfgLocale ))
{
OUString aPropName( aNode );
@@ -1694,7 +1851,8 @@ Sequence< OUString > SAL_CALL
}
#if OSL_DEBUG_LEVEL > 1
-// const OUString *pImplNames = aSvcImplNames.getConstArray();
+ const OUString *pImplNames = aSvcImplNames.getConstArray();
+ (void) pImplNames;
#endif
return aSvcImplNames;
}
@@ -1702,16 +1860,16 @@ Sequence< OUString > SAL_CALL
void SAL_CALL
LngSvcMgr::dispose()
- throw(RuntimeException)
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
if (!bDisposing)
{
bDisposing = TRUE;
// require listeners to release this object
- EventObject aEvtObj( (XLinguServiceManager *) this );
+ lang::EventObject aEvtObj( (XLinguServiceManager *) this );
aEvtListeners.disposeAndClear( aEvtObj );
if (pListenerHelper)
@@ -1722,40 +1880,34 @@ void SAL_CALL
void SAL_CALL
LngSvcMgr::addEventListener(
- const Reference< XEventListener >& xListener )
- throw(RuntimeException)
+ const uno::Reference< lang::XEventListener >& xListener )
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
if (!bDisposing && xListener.is())
{
- aEvtListeners.addInterface(
- /*::getCppuType((const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >*)0), */
- xListener );
+ aEvtListeners.addInterface( xListener );
}
}
void SAL_CALL
LngSvcMgr::removeEventListener(
- const Reference< XEventListener >& xListener )
- throw(RuntimeException)
+ const uno::Reference< lang::XEventListener >& xListener )
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
if (xListener.is())
{
- aEvtListeners.removeInterface(
- /*::getCppuType((const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >*)0), */
- xListener );
+ aEvtListeners.removeInterface( xListener );
}
}
BOOL LngSvcMgr::AddLngSvcEvtBroadcaster(
- const Reference< XLinguServiceEventBroadcaster > &rxBroadcaster )
+ const uno::Reference< linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster )
{
BOOL bRes = FALSE;
if (rxBroadcaster.is())
@@ -1769,7 +1921,7 @@ BOOL LngSvcMgr::AddLngSvcEvtBroadcaster(
BOOL LngSvcMgr::RemoveLngSvcEvtBroadcaster(
- const Reference< XLinguServiceEventBroadcaster > &rxBroadcaster )
+ const uno::Reference< linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster )
{
BOOL bRes = FALSE;
if (rxBroadcaster.is())
@@ -1785,18 +1937,18 @@ BOOL LngSvcMgr::RemoveLngSvcEvtBroadcaster(
OUString SAL_CALL
LngSvcMgr::getImplementationName()
- throw(RuntimeException)
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
return getImplementationName_Static();
}
sal_Bool SAL_CALL
LngSvcMgr::supportsService( const OUString& ServiceName )
- throw(RuntimeException)
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
uno::Sequence< OUString > aSNL = getSupportedServiceNames();
const OUString * pArray = aSNL.getConstArray();
@@ -1807,11 +1959,11 @@ sal_Bool SAL_CALL
}
-Sequence< OUString > SAL_CALL
+uno::Sequence< OUString > SAL_CALL
LngSvcMgr::getSupportedServiceNames()
- throw(RuntimeException)
+ throw(uno::RuntimeException)
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
return getSupportedServiceNames_Static();
}
@@ -1819,7 +1971,7 @@ Sequence< OUString > SAL_CALL
uno::Sequence< OUString > LngSvcMgr::getSupportedServiceNames_Static()
throw()
{
- MutexGuard aGuard( GetLinguMutex() );
+ osl::MutexGuard aGuard( GetLinguMutex() );
uno::Sequence< OUString > aSNS( 1 ); // auch mehr als 1 Service moeglich
aSNS.getArray()[0] = A2OU( SN_LINGU_SERVCICE_MANAGER );
@@ -1827,11 +1979,11 @@ uno::Sequence< OUString > LngSvcMgr::getSupportedServiceNames_Static()
}
-Reference< XInterface > SAL_CALL LngSvcMgr_CreateInstance(
- const Reference< XMultiServiceFactory > & /*rSMgr*/ )
- throw(Exception)
+uno::Reference< uno::XInterface > SAL_CALL LngSvcMgr_CreateInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & /*rSMgr*/ )
+ throw(uno::Exception)
{
- Reference< XInterface > xService = (cppu::OWeakObject*) new LngSvcMgr;
+ uno::Reference< uno::XInterface > xService = (cppu::OWeakObject*) new LngSvcMgr;
return xService;
}
@@ -1846,7 +1998,7 @@ sal_Bool SAL_CALL LngSvcMgr_writeInfo(
String aImpl( '/' );
aImpl += LngSvcMgr::getImplementationName_Static().getStr();
aImpl.AppendAscii( "/UNO/SERVICES" );
- Reference< registry::XRegistryKey > xNewKey =
+ uno::Reference< registry::XRegistryKey > xNewKey =
pRegistryKey->createKey( aImpl );
uno::Sequence< OUString > aServices = LngSvcMgr::getSupportedServiceNames_Static();
for( INT32 i = 0; i < aServices.getLength(); i++ )
@@ -1854,7 +2006,7 @@ sal_Bool SAL_CALL LngSvcMgr_writeInfo(
return sal_True;
}
- catch(Exception &)
+ catch(uno::Exception &)
{
return sal_False;
}
@@ -1862,14 +2014,14 @@ sal_Bool SAL_CALL LngSvcMgr_writeInfo(
void * SAL_CALL LngSvcMgr_getFactory(
const sal_Char * pImplName,
- XMultiServiceFactory * pServiceManager,
+ lang::XMultiServiceFactory * pServiceManager,
void * /*pRegistryKey*/ )
{
void * pRet = 0;
if ( !LngSvcMgr::getImplementationName_Static().compareToAscii( pImplName ) )
{
- Reference< XSingleServiceFactory > xFactory =
+ uno::Reference< lang::XSingleServiceFactory > xFactory =
cppu::createOneInstanceFactory(
pServiceManager,
LngSvcMgr::getImplementationName_Static(),
diff --git a/linguistic/source/lngsvcmgr.hxx b/linguistic/source/lngsvcmgr.hxx
index 4f8971dcd7..1c96adea46 100644
--- a/linguistic/source/lngsvcmgr.hxx
+++ b/linguistic/source/lngsvcmgr.hxx
@@ -51,12 +51,15 @@
class SpellCheckerDispatcher;
class HyphenatorDispatcher;
class ThesaurusDispatcher;
-class SvcInfoArray;
+class GrammarCheckingIterator;
class LngSvcMgrListenerHelper;
+struct SvcInfo;
namespace com { namespace sun { namespace star { namespace linguistic2 {
class XLinguServiceEventBroadcaster;
class XSpellChecker;
+ class XProofreader;
+ class XProofreadingIterator;
class XHyphenator;
class XThesaurus;
} } } }
@@ -74,14 +77,18 @@ class LngSvcMgr :
>,
private utl::ConfigItem
{
+ friend class LngSvcMgrListenerHelper;
+
::cppu::OInterfaceContainerHelper aEvtListeners;
com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XSpellChecker > xSpellDsp;
+ ::com::sun::star::linguistic2::XSpellChecker > xSpellDsp;
+ com::sun::star::uno::Reference<
+ ::com::sun::star::linguistic2::XProofreadingIterator > xGrammarDsp;
com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XHyphenator > xHyphDsp;
+ ::com::sun::star::linguistic2::XHyphenator > xHyphDsp;
com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XThesaurus > xThesDsp;
+ ::com::sun::star::linguistic2::XThesaurus > xThesDsp;
com::sun::star::uno::Reference<
::com::sun::star::lang::XEventListener > xListenerHelper;
@@ -89,22 +96,28 @@ class LngSvcMgr :
com::sun::star::uno::Sequence<
com::sun::star::lang::Locale > aAvailSpellLocales;
com::sun::star::uno::Sequence<
+ com::sun::star::lang::Locale > aAvailGrammarLocales;
+ com::sun::star::uno::Sequence<
com::sun::star::lang::Locale > aAvailHyphLocales;
com::sun::star::uno::Sequence<
com::sun::star::lang::Locale > aAvailThesLocales;
SpellCheckerDispatcher * pSpellDsp;
+ GrammarCheckingIterator * pGrammarDsp;
HyphenatorDispatcher * pHyphDsp;
ThesaurusDispatcher * pThesDsp;
LngSvcMgrListenerHelper * pListenerHelper;
+ typedef std::vector< SvcInfo * > SvcInfoArray;
SvcInfoArray * pAvailSpellSvcs;
+ SvcInfoArray * pAvailGrammarSvcs;
SvcInfoArray * pAvailHyphSvcs;
SvcInfoArray * pAvailThesSvcs;
BOOL bDisposing;
BOOL bHasAvailSpellLocales;
+ BOOL bHasAvailGrammarLocales;
BOOL bHasAvailHyphLocales;
BOOL bHasAvailThesLocales;
@@ -113,14 +126,18 @@ class LngSvcMgr :
LngSvcMgr & operator = (const LngSvcMgr &);
void GetAvailableSpellSvcs_Impl();
+ void GetAvailableGrammarSvcs_Impl();
void GetAvailableHyphSvcs_Impl();
void GetAvailableThesSvcs_Impl();
void GetListenerHelper_Impl();
+
void GetSpellCheckerDsp_Impl( sal_Bool bSetSvcList = sal_True );
+ void GetGrammarCheckerDsp_Impl( sal_Bool bSetSvcList = sal_True );
void GetHyphenatorDsp_Impl( sal_Bool bSetSvcList = sal_True );
void GetThesaurusDsp_Impl( sal_Bool bSetSvcList = sal_True );
void SetCfgServiceLists( SpellCheckerDispatcher &rSpellDsp );
+ void SetCfgServiceLists( GrammarCheckingIterator &rGrammarDsp );
void SetCfgServiceLists( HyphenatorDispatcher &rHyphDsp );
void SetCfgServiceLists( ThesaurusDispatcher &rThesDsp );
@@ -138,84 +155,31 @@ public:
virtual ~LngSvcMgr();
// XLinguServiceManager
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XSpellChecker > SAL_CALL
- getSpellChecker()
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XHyphenator > SAL_CALL
- getHyphenator()
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XThesaurus > SAL_CALL
- getThesaurus()
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL
- addLinguServiceManagerListener(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >& xListener )
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL
- removeLinguServiceManagerListener(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >& xListener )
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
- getAvailableServices(
- const ::rtl::OUString& rServiceName,
- const ::com::sun::star::lang::Locale& rLocale )
- throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- setConfiguredServices(
- const ::rtl::OUString& rServiceName,
- const ::com::sun::star::lang::Locale& rLocale,
- const ::com::sun::star::uno::Sequence<
- ::rtl::OUString >& rServiceImplNames )
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
- getConfiguredServices(
- const ::rtl::OUString& rServiceName,
- const ::com::sun::star::lang::Locale& rLocale )
- throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellChecker > SAL_CALL getSpellChecker( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenator > SAL_CALL getHyphenator( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XThesaurus > SAL_CALL getThesaurus( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL addLinguServiceManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL removeLinguServiceManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServices( const ::rtl::OUString& aServiceName, const ::com::sun::star::lang::Locale& aLocale ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setConfiguredServices( const ::rtl::OUString& aServiceName, const ::com::sun::star::lang::Locale& aLocale, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aServiceImplNames ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getConfiguredServices( const ::rtl::OUString& aServiceName, const ::com::sun::star::lang::Locale& aLocale ) throw (::com::sun::star::uno::RuntimeException);
// XAvailableLocales
- virtual ::com::sun::star::uno::Sequence<
- ::com::sun::star::lang::Locale > SAL_CALL
- getAvailableLocales(
- const ::rtl::OUString& rServiceName )
- throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getAvailableLocales( const ::rtl::OUString& aServiceName ) throw (::com::sun::star::uno::RuntimeException);
// XComponent
- virtual void SAL_CALL
- dispose()
- throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- addEventListener(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >& xListener )
- throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL
- removeEventListener(
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XEventListener >& xListener )
- throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
// XServiceInfo
- virtual ::rtl::OUString SAL_CALL
- getImplementationName()
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL
- supportsService( const ::rtl::OUString& ServiceName )
- throw(::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
- getSupportedServiceNames()
- throw(::com::sun::star::uno::RuntimeException);
-
-
- static inline ::rtl::OUString
- getImplementationName_Static();
- static ::com::sun::star::uno::Sequence< ::rtl::OUString >
- getSupportedServiceNames_Static() throw();
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+
+ static inline ::rtl::OUString getImplementationName_Static();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
BOOL AddLngSvcEvtBroadcaster(
const ::com::sun::star::uno::Reference<
diff --git a/linguistic/source/makefile.mk b/linguistic/source/makefile.mk
index dc48a9f67d..36b8c8c131 100644
--- a/linguistic/source/makefile.mk
+++ b/linguistic/source/makefile.mk
@@ -59,11 +59,9 @@ SLOFILES = \
$(SLO)$/prophelp.obj\
$(SLO)$/spelldsp.obj\
$(SLO)$/spelldta.obj\
- $(SLO)$/supplang.obj\
$(SLO)$/thesdsp.obj\
$(SLO)$/thesdta.obj\
- $(SLO)$/gciterator.obj\
- $(SLO)$/grammarchecker.obj
+ $(SLO)$/gciterator.obj
SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx
index 3a45feac83..7353ec1bef 100644
--- a/linguistic/source/misc.cxx
+++ b/linguistic/source/misc.cxx
@@ -48,16 +48,17 @@
#include <com/sun/star/beans/PropertyValues.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/linguistic2/XDictionary1.hpp>
#include <com/sun/star/linguistic2/DictionaryType.hpp>
#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
#include <unotools/processfactory.hxx>
#include <unotools/localedatawrapper.hxx>
+#include <rtl/instance.hxx>
+
#include "misc.hxx"
#include "defs.hxx"
#include "lngprops.hxx"
-#include <hyphdta.hxx>
+#include "hyphdta.hxx"
using namespace utl;
@@ -75,10 +76,14 @@ namespace linguistic
///////////////////////////////////////////////////////////////////////////
+//!! multi-thread safe mutex for all platforms !!
+struct LinguMutex : public rtl::Static< osl::Mutex, LinguMutex >
+{
+};
+
osl::Mutex & GetLinguMutex()
{
- static osl::Mutex aMutex;
- return aMutex;
+ return LinguMutex::get();
}
///////////////////////////////////////////////////////////////////////////
@@ -163,7 +168,7 @@ rtl_TextEncoding GetTextEncoding( INT16 nLanguage )
nEncoding = RTL_TEXTENCODING_ISO_8859_7; break;
#endif
default:
- DBG_ERROR( "unexpected language" );
+ DBG_ASSERT( 0, "unexpected language" );
}
}
@@ -353,10 +358,10 @@ uno::Reference< XDictionaryEntry > SearchDicList(
INT32 i;
for (i = 0; i < nDics; i++)
{
- uno::Reference< XDictionary1 > axDic( pDic[i], UNO_QUERY );
+ uno::Reference< XDictionary > axDic( pDic[i], UNO_QUERY );
DictionaryType eType = axDic->getDictionaryType();
- INT16 nLang = axDic->getLanguage();
+ INT16 nLang = LocaleToLanguage( axDic->getLocale() );
if ( axDic.is() && axDic->isActive()
&& (nLang == nLanguage || nLang == LANGUAGE_NONE) )
@@ -503,12 +508,11 @@ uno::Sequence< INT16 >
const Locale *pLocale = rLocaleSeq.getConstArray();
INT32 nCount = rLocaleSeq.getLength();
- uno::Sequence< INT16 > aLangs( nCount );
+ uno::Sequence< INT16 > aLangs( nCount );
INT16 *pLang = aLangs.getArray();
for (INT32 i = 0; i < nCount; ++i)
{
pLang[i] = LocaleToLanguage( pLocale[i] );
-
}
return aLangs;
@@ -687,7 +691,7 @@ uno::Reference< XHyphenatedWord > RebuildHyphensAndControlChars(
if (nOrigHyphenPos == -1 || nOrigHyphenationPos == -1)
{
- DBG_ERROR( "failed to get nOrigHyphenPos or nOrigHyphenationPos" );
+ DBG_ASSERT( 0, "failed to get nOrigHyphenPos or nOrigHyphenationPos" );
}
else
{
@@ -847,7 +851,7 @@ uno::Reference< XInterface > GetOneInstanceService( const char *pServiceName )
}
catch (uno::Exception &)
{
- DBG_ERROR( "createInstance failed" );
+ DBG_ASSERT( 0, "createInstance failed" );
}
}
}
@@ -890,7 +894,7 @@ AppExitListener::AppExitListener()
}
catch (uno::Exception &)
{
- DBG_ERROR( "createInstance failed" );
+ DBG_ASSERT( 0, "createInstance failed" );
}
}
}
diff --git a/linguistic/source/misc2.cxx b/linguistic/source/misc2.cxx
index 76f67bae8d..297366322f 100644
--- a/linguistic/source/misc2.cxx
+++ b/linguistic/source/misc2.cxx
@@ -121,7 +121,7 @@ String GetModulePath( SvtPathOptions::Pathes ePath, BOOL bAddAccessDelim )
}
*/
default:
- DBG_ERROR( "unexpected argument (path)" );
+ DBG_ASSERT( 0, "unexpected argument (path)" );
}
if (bAddAccessDelim && aRes.Len())
{
diff --git a/linguistic/source/prophelp.cxx b/linguistic/source/prophelp.cxx
index b888dff261..778239577a 100644
--- a/linguistic/source/prophelp.cxx
+++ b/linguistic/source/prophelp.cxx
@@ -60,7 +60,7 @@ namespace linguistic
static const char *aCH[] =
{
- UPN_IS_GERMAN_PRE_REFORM,
+ UPN_IS_GERMAN_PRE_REFORM, /* deprectaed */
UPN_IS_IGNORE_CONTROL_CHARACTERS,
UPN_IS_USE_DICTIONARY_LIST,
};
@@ -144,7 +144,7 @@ void PropertyChgHelper::GetCurrentValues()
BOOL *pbVal = NULL,
*pbResVal = NULL;
- if (pPropName[i].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( UPN_IS_GERMAN_PRE_REFORM ) ))
+ if (pPropName[i].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( UPN_IS_GERMAN_PRE_REFORM ) )) /* deprecated */
{
pbVal = &bIsGermanPreReform;
pbResVal = &bResIsGermanPreReform;
@@ -188,14 +188,14 @@ void PropertyChgHelper::SetTmpPropVals( const PropertyValues &rPropVals )
switch (pVal[i].Handle)
{
case UPH_IS_GERMAN_PRE_REFORM :
- pbResVal = &bResIsGermanPreReform; break;
+ pbResVal = &bResIsGermanPreReform; break; /* deprecated */
case UPH_IS_IGNORE_CONTROL_CHARACTERS :
pbResVal = &bResIsIgnoreControlCharacters; break;
case UPH_IS_USE_DICTIONARY_LIST :
pbResVal = &bResIsUseDictionaryList; break;
default:
;
- //DBG_ERROR( "unknown property" );
+ //DBG_ASSERT( 0, "unknown property" );
}
if (pbResVal)
pVal[i].Value >>= *pbResVal;
@@ -224,7 +224,7 @@ BOOL PropertyChgHelper::propertyChange_Impl( const PropertyChangeEvent& rEvt )
nLngSvcFlags = 0;
break;
}
- case UPH_IS_GERMAN_PRE_REFORM :
+ case UPH_IS_GERMAN_PRE_REFORM : /* deprecated */
{
pbVal = &bIsGermanPreReform;
bSCWA = bSWWA = TRUE;
@@ -239,7 +239,7 @@ BOOL PropertyChgHelper::propertyChange_Impl( const PropertyChangeEvent& rEvt )
default:
{
bRes = FALSE;
- //DBG_ERROR( "unknown property" );
+ //DBG_ASSERT( 0, "unknown property" );
}
}
if (pbVal)
@@ -502,7 +502,7 @@ BOOL PropertyHelper_Spell::propertyChange_Impl( const PropertyChangeEvent& rEvt
break;
}
default:
- DBG_ERROR( "unknown property" );
+ DBG_ASSERT( 0, "unknown property" );
}
if (pbVal)
rEvt.NewValue >>= *pbVal;
@@ -564,7 +564,7 @@ void PropertyHelper_Spell::SetTmpPropVals( const PropertyValues &rPropVals )
case UPH_IS_SPELL_WITH_DIGITS : pbResVal = &bResIsSpellWithDigits; break;
case UPH_IS_SPELL_CAPITALIZATION : pbResVal = &bResIsSpellCapitalization; break;
default:
- DBG_ERROR( "unknown property" );
+ DBG_ASSERT( 0, "unknown property" );
}
if (pbResVal)
pVal[i].Value >>= *pbResVal;
@@ -668,7 +668,7 @@ BOOL PropertyHelper_Hyph::propertyChange_Impl( const PropertyChangeEvent& rEvt )
case UPH_HYPH_MIN_TRAILING : pnVal = &nHyphMinTrailing; break;
case UPH_HYPH_MIN_WORD_LENGTH : pnVal = &nHyphMinWordLength; break;
default:
- DBG_ERROR( "unknown property" );
+ DBG_ASSERT( 0, "unknown property" );
}
if (pnVal)
rEvt.NewValue >>= *pnVal;
@@ -720,7 +720,7 @@ void PropertyHelper_Hyph::SetTmpPropVals( const PropertyValues &rPropVals )
case UPH_HYPH_MIN_TRAILING : pnResVal = &nResHyphMinTrailing; break;
case UPH_HYPH_MIN_WORD_LENGTH : pnResVal = &nResHyphMinWordLength; break;
default:
- DBG_ERROR( "unknown property" );
+ DBG_ASSERT( 0, "unknown property" );
}
if (pnResVal)
pVal[i].Value >>= *pnResVal;
diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx
index 373ce9a520..3f84fe0937 100644
--- a/linguistic/source/spelldsp.cxx
+++ b/linguistic/source/spelldsp.cxx
@@ -188,22 +188,17 @@ void ProposalList::Remove( const OUString &rText )
///////////////////////////////////////////////////////////////////////////
BOOL SvcListHasLanguage(
- const SeqLangSvcEntry_Spell &rEntry,
- INT16 nLanguage )
+ const LangSvcEntries_Spell &rEntry,
+ LanguageType nLanguage )
{
BOOL bHasLanguage = FALSE;
Locale aTmpLocale;
const Reference< XSpellChecker > *pRef = rEntry.aSvcRefs .getConstArray();
- const Reference< XSpellChecker1 > *pRef1 = rEntry.aSvc1Refs.getConstArray();
sal_Int32 nLen = rEntry.aSvcRefs.getLength();
- DBG_ASSERT( nLen == rEntry.aSvc1Refs.getLength(),
- "sequence length mismatch" );
for (INT32 k = 0; k < nLen && !bHasLanguage; ++k)
{
- if (pRef1[k].is())
- bHasLanguage = pRef1[k]->hasLanguage( nLanguage );
- else if (pRef[k].is())
+ if (pRef[k].is())
{
if (0 == aTmpLocale.Language.getLength())
aTmpLocale = CreateLocale( nLanguage );
@@ -217,45 +212,25 @@ BOOL SvcListHasLanguage(
///////////////////////////////////////////////////////////////////////////
-SeqLangSvcEntry_Spell::~SeqLangSvcEntry_Spell()
-{
-}
-
-
-SeqLangSvcEntry_Spell::SeqLangSvcEntry_Spell(
- const Sequence< OUString > &rSvcImplNames ) :
- aSvcImplNames ( rSvcImplNames ),
- aSvcRefs ( rSvcImplNames.getLength() ),
- aSvc1Refs ( rSvcImplNames.getLength() )
-{
-}
-
-///////////////////////////////////////////////////////////////////////////
-
SpellCheckerDispatcher::SpellCheckerDispatcher( LngSvcMgr &rLngSvcMgr ) :
rMgr (rLngSvcMgr)
{
- pExtCache = NULL;
+ pCache = NULL;
}
SpellCheckerDispatcher::~SpellCheckerDispatcher()
{
ClearSvcList();
- delete pExtCache;
+ delete pCache;
}
void SpellCheckerDispatcher::ClearSvcList()
{
// release memory for each table entry
- SeqLangSvcEntry_Spell *pItem = aSvcList.First();
- while (pItem)
- {
- SeqLangSvcEntry_Spell *pTmp = pItem;
- pItem = aSvcList.Next();
- delete pTmp;
- }
+ SpellSvcByLangMap_t aTmp;
+ aSvcMap.swap( aTmp );
}
@@ -263,7 +238,15 @@ Sequence< Locale > SAL_CALL SpellCheckerDispatcher::getLocales()
throw(RuntimeException)
{
MutexGuard aGuard( GetLinguMutex() );
- return LangSeqToLocaleSeq( getLanguages() );
+
+ Sequence< Locale > aLocales( static_cast< sal_Int32 >(aSvcMap.size()) );
+ Locale *pLocales = aLocales.getArray();
+ SpellSvcByLangMap_t::const_iterator aIt;
+ for (aIt = aSvcMap.begin(); aIt != aSvcMap.end(); ++aIt)
+ {
+ *pLocales++ = CreateLocale( aIt->first );
+ }
+ return aLocales;
}
@@ -271,7 +254,8 @@ sal_Bool SAL_CALL SpellCheckerDispatcher::hasLocale( const Locale& rLocale )
throw(RuntimeException)
{
MutexGuard aGuard( GetLinguMutex() );
- return hasLanguage( LocaleToLanguage(rLocale) );
+ SpellSvcByLangMap_t::const_iterator aIt( aSvcMap.find( LocaleToLanguage( rLocale ) ) );
+ return aIt != aSvcMap.end();
}
@@ -281,7 +265,7 @@ sal_Bool SAL_CALL
throw(IllegalArgumentException, RuntimeException)
{
MutexGuard aGuard( GetLinguMutex() );
- return isValid( rWord, LocaleToLanguage(rLocale), rProperties );
+ return isValid_Impl( rWord, LocaleToLanguage( rLocale ), rProperties, TRUE );
}
@@ -291,84 +275,13 @@ Reference< XSpellAlternatives > SAL_CALL
throw(IllegalArgumentException, RuntimeException)
{
MutexGuard aGuard( GetLinguMutex() );
- return spell( rWord, LocaleToLanguage(rLocale), rProperties );
-}
-
-
-Sequence< sal_Int16 > SAL_CALL SpellCheckerDispatcher::getLanguages()
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- ULONG nCnt = aSvcList.Count();
- Sequence< INT16 > aLanguages( nCnt );
- INT16 *pLang = aLanguages.getArray();
- SeqLangSvcEntry_Spell *pEntry = aSvcList.First();
- for (ULONG i = 0; i < nCnt; i++)
- {
- DBG_ASSERT( pEntry, "lng : pEntry is NULL pointer" );
- pLang[i] = (INT16) aSvcList.GetKey( pEntry );
- pEntry = aSvcList.Next();
- }
- return aLanguages;
-}
-
-
-sal_Bool SAL_CALL SpellCheckerDispatcher::hasLanguage( sal_Int16 nLanguage )
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
- return 0 != aSvcList.Get( nLanguage );
-}
-
-
-sal_Bool SAL_CALL
- SpellCheckerDispatcher::isValid( const OUString& rWord, sal_Int16 nLanguage,
- const PropertyValues& rProperties )
- throw(IllegalArgumentException, RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- BOOL bRes = TRUE;
- if (LANGUAGE_NONE != nLanguage && rWord.getLength())
- {
- if (aOpt.IsSpellInAllLanguages())
- bRes = isValidInAny( rWord, getLanguages(), rProperties );
- else
- bRes = isValid_Impl( rWord, nLanguage, rProperties, TRUE );
- }
- return bRes;
-}
-
-
-BOOL SpellCheckerDispatcher::isValidInAny(
- const OUString& rWord,
- const Sequence< INT16 >& aLanguages,
- const PropertyValues& rProperties )
- throw( RuntimeException, IllegalArgumentException )
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- BOOL bRes = TRUE;
-
- INT32 nNumLang = aLanguages.getLength();
- const INT16 *pLang = aLanguages.getConstArray();
- for (int i = 0; i < nNumLang; i++)
- {
- if( LANGUAGE_NONE != pLang[i] )
- {
- if (sal_True == (bRes = isValid_Impl( rWord, pLang[i], rProperties, TRUE )))
- break;
- }
- }
-
- return bRes;
+ return spell_Impl( rWord, LocaleToLanguage( rLocale ), rProperties, TRUE );
}
BOOL SpellCheckerDispatcher::isValid_Impl(
const OUString& rWord,
- INT16 nLanguage,
+ LanguageType nLanguage,
const PropertyValues& rProperties,
BOOL bCheckDics)
throw( RuntimeException, IllegalArgumentException )
@@ -381,7 +294,7 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
return bRes;
// search for entry with that language
- SeqLangSvcEntry_Spell *pEntry = aSvcList.Get( nLanguage );
+ LangSvcEntries_Spell *pEntry = aSvcMap[ nLanguage ].get();
if (!pEntry)
{
@@ -407,7 +320,7 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
INT32 nLen = pEntry->aSvcRefs.getLength();
DBG_ASSERT( nLen == pEntry->aSvcImplNames.getLength(),
"lng : sequence length mismatch");
- DBG_ASSERT( pEntry->aFlags.nLastTriedSvcIndex < nLen,
+ DBG_ASSERT( pEntry->nLastTriedSvcIndex < nLen,
"lng : index out of range");
INT32 i = 0;
@@ -416,19 +329,15 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
// try already instantiated services first
{
- const Reference< XSpellChecker1 > *pRef1 =
- pEntry->aSvc1Refs.getConstArray();
const Reference< XSpellChecker > *pRef =
pEntry->aSvcRefs.getConstArray();
- while (i <= pEntry->aFlags.nLastTriedSvcIndex
+ while (i <= pEntry->nLastTriedSvcIndex
&& (!bTmpResValid || FALSE == bTmpRes))
{
bTmpResValid = TRUE;
- if (pRef1[i].is() && pRef1[i]->hasLanguage( nLanguage ))
- bTmpRes = pRef1[i]->isValid( aChkWord, nLanguage, rProperties );
- else if (pRef[i].is() && pRef[i]->hasLocale( aLocale ))
+ if (pRef[i].is() && pRef[i]->hasLocale( aLocale ))
{
- bTmpRes = GetExtCache().CheckWord( aChkWord, nLanguage, FALSE );
+ bTmpRes = GetCache().CheckWord( aChkWord, nLanguage );
if (!bTmpRes)
{
bTmpRes = pRef[i]->isValid( aChkWord, aLocale, rProperties );
@@ -437,7 +346,7 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
// But not those that are correct only because of
// the temporary supplied settings.
if (bTmpRes && 0 == rProperties.getLength())
- GetExtCache().AddWord( aChkWord, nLanguage );
+ GetCache().AddWord( aChkWord, nLanguage );
}
}
else
@@ -452,10 +361,9 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
// if still no result instantiate new services and try those
if ((!bTmpResValid || FALSE == bTmpRes)
- && pEntry->aFlags.nLastTriedSvcIndex < nLen - 1)
+ && pEntry->nLastTriedSvcIndex < nLen - 1)
{
const OUString *pImplNames = pEntry->aSvcImplNames.getConstArray();
- Reference< XSpellChecker1 > *pRef1 = pEntry->aSvc1Refs.getArray();
Reference< XSpellChecker > *pRef = pEntry->aSvcRefs .getArray();
Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() );
@@ -480,11 +388,9 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
}
catch (uno::Exception &)
{
- DBG_ERROR( "createInstanceWithArguments failed" );
+ DBG_ASSERT( 0, "createInstanceWithArguments failed" );
}
- Reference< XSpellChecker1 > xSpell1( xSpell, UNO_QUERY );
pRef [i] = xSpell;
- pRef1[i] = xSpell1;
Reference< XLinguServiceEventBroadcaster >
xBroadcaster( xSpell, UNO_QUERY );
@@ -492,11 +398,9 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
rMgr.AddLngSvcEvtBroadcaster( xBroadcaster );
bTmpResValid = TRUE;
- if (xSpell1.is() && xSpell1->hasLanguage( nLanguage ))
- bTmpRes = xSpell1->isValid( aChkWord, nLanguage, rProperties );
- else if (xSpell.is() && xSpell->hasLocale( aLocale ))
+ if (xSpell.is() && xSpell->hasLocale( aLocale ))
{
- bTmpRes = GetExtCache().CheckWord( aChkWord, nLanguage, FALSE );
+ bTmpRes = GetCache().CheckWord( aChkWord, nLanguage );
if (!bTmpRes)
{
bTmpRes = xSpell->isValid( aChkWord, aLocale, rProperties );
@@ -505,7 +409,7 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
// But not those that are correct only because of
// the temporary supplied settings.
if (bTmpRes && 0 == rProperties.getLength())
- GetExtCache().AddWord( aChkWord, nLanguage );
+ GetCache().AddWord( aChkWord, nLanguage );
}
}
else
@@ -514,7 +418,7 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
if (bTmpResValid)
bRes = bTmpRes;
- pEntry->aFlags.nLastTriedSvcIndex = (INT16) i;
+ pEntry->nLastTriedSvcIndex = (INT16) i;
++i;
}
@@ -523,7 +427,7 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
if (i == nLen)
{
if (!SvcListHasLanguage( *pEntry, nLanguage ))
- aSvcList.Remove( nLanguage );
+ aSvcMap.erase( nLanguage );
}
}
}
@@ -551,83 +455,9 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
}
-Reference< XSpellAlternatives > SAL_CALL
- SpellCheckerDispatcher::spell( const OUString& rWord, sal_Int16 nLanguage,
- const PropertyValues& rProperties )
- throw(IllegalArgumentException, RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- Reference< XSpellAlternatives > xAlt;
- if (LANGUAGE_NONE != nLanguage && rWord.getLength())
- {
- if (aOpt.IsSpellInAllLanguages())
- xAlt = spellInAny( rWord, getLanguages(), rProperties, nLanguage );
- else
- xAlt = spell_Impl( rWord, nLanguage, rProperties, TRUE );
- }
- return xAlt;
-}
-
-
-Reference< XSpellAlternatives > SpellCheckerDispatcher::spellInAny(
- const OUString& aWord,
- const Sequence< INT16 >& aLanguages,
- const PropertyValues& rProperties,
- INT16 nPreferredResultLang)
- throw( RuntimeException, IllegalArgumentException )
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- Reference< XSpellAlternatives > xAlt;
-
- // check preferred language first
- BOOL bPrefLangChecked = FALSE;
- if ( LANGUAGE_NONE != nPreferredResultLang
- && hasLanguage( nPreferredResultLang ) )
- {
- xAlt = spell_Impl( aWord, nPreferredResultLang, rProperties, TRUE );
- bPrefLangChecked = TRUE;
- }
-
- // if word is incorrect (or not checked) try the other languages
- if (xAlt.is() || !bPrefLangChecked)
- {
- INT32 nNumLang = aLanguages.getLength();
- const INT16 *pLang = aLanguages.getConstArray();
- for (int i = 0; i < nNumLang; ++i)
- {
- INT16 nLang = pLang[i];
- if (nLang == nPreferredResultLang) // already checked!
- continue;
-
- // Bug 71632
- if( LANGUAGE_NONE != nLang && hasLanguage( nLang ) )
- {
- Reference< XSpellAlternatives >
- xLast( spell_Impl( aWord, nLang, rProperties, TRUE ));
-
- // remember first spelling alternatives found
- if (xLast.is() && !xAlt.is())
- xAlt = xLast;
-
- // did we finally find a language in which the word is correct?
- if (!xLast.is())
- {
- xAlt = NULL; // don't return any spelling alternatives
- break;
- }
- }
- }
- }
-
- return xAlt;
-}
-
-
Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
const OUString& rWord,
- sal_Int16 nLanguage,
+ LanguageType nLanguage,
const PropertyValues& rProperties,
BOOL bCheckDics )
throw(IllegalArgumentException, RuntimeException)
@@ -640,7 +470,7 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
return xRes;
// search for entry with that language
- SeqLangSvcEntry_Spell *pEntry = aSvcList.Get( nLanguage );
+ LangSvcEntries_Spell *pEntry = aSvcMap[ nLanguage ].get();
if (!pEntry)
{
@@ -666,7 +496,7 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
INT32 nLen = pEntry->aSvcRefs.getLength();
DBG_ASSERT( nLen == pEntry->aSvcImplNames.getLength(),
"lng : sequence length mismatch");
- DBG_ASSERT( pEntry->aFlags.nLastTriedSvcIndex < nLen,
+ DBG_ASSERT( pEntry->nLastTriedSvcIndex < nLen,
"lng : index out of range");
INT32 i = 0;
@@ -675,19 +505,15 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
// try already instantiated services first
{
- const Reference< XSpellChecker1 > *pRef1 =
- pEntry->aSvc1Refs.getConstArray();
const Reference< XSpellChecker > *pRef =
pEntry->aSvcRefs.getConstArray();
- while (i <= pEntry->aFlags.nLastTriedSvcIndex
+ while (i <= pEntry->nLastTriedSvcIndex
&& (!bTmpResValid || xTmpRes.is()) )
{
bTmpResValid = TRUE;
- if (pRef1[i].is() && pRef1[i]->hasLanguage( nLanguage ))
- xTmpRes = pRef1[i]->spell( aChkWord, nLanguage, rProperties );
- else if (pRef[i].is() && pRef[i]->hasLocale( aLocale ))
+ if (pRef[i].is() && pRef[i]->hasLocale( aLocale ))
{
- BOOL bOK = GetExtCache().CheckWord( aChkWord, nLanguage, FALSE );
+ BOOL bOK = GetCache().CheckWord( aChkWord, nLanguage );
if (bOK)
xTmpRes = NULL;
else
@@ -698,7 +524,7 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
// But not those that are correct only because of
// the temporary supplied settings.
if (!xTmpRes.is() && 0 == rProperties.getLength())
- GetExtCache().AddWord( aChkWord, nLanguage );
+ GetCache().AddWord( aChkWord, nLanguage );
}
}
else
@@ -714,10 +540,9 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
// if still no result instantiate new services and try those
if ((!bTmpResValid || xTmpRes.is())
- && pEntry->aFlags.nLastTriedSvcIndex < nLen - 1)
+ && pEntry->nLastTriedSvcIndex < nLen - 1)
{
const OUString *pImplNames = pEntry->aSvcImplNames.getConstArray();
- Reference< XSpellChecker1 > *pRef1 = pEntry->aSvc1Refs.getArray();
Reference< XSpellChecker > *pRef = pEntry->aSvcRefs .getArray();
Reference< XMultiServiceFactory > xMgr( getProcessServiceFactory() );
@@ -742,11 +567,9 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
}
catch (uno::Exception &)
{
- DBG_ERROR( "createInstanceWithArguments failed" );
+ DBG_ASSERT( 0, "createInstanceWithArguments failed" );
}
- Reference< XSpellChecker1 > xSpell1( xSpell, UNO_QUERY );
pRef [i] = xSpell;
- pRef1[i] = xSpell1;
Reference< XLinguServiceEventBroadcaster >
xBroadcaster( xSpell, UNO_QUERY );
@@ -754,11 +577,9 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
rMgr.AddLngSvcEvtBroadcaster( xBroadcaster );
bTmpResValid = TRUE;
- if (xSpell1.is() && xSpell1->hasLanguage( nLanguage ))
- xTmpRes = xSpell1->spell( aChkWord, nLanguage, rProperties );
- else if (xSpell.is() && xSpell->hasLocale( aLocale ))
+ if (xSpell.is() && xSpell->hasLocale( aLocale ))
{
- BOOL bOK = GetExtCache().CheckWord( aChkWord, nLanguage, FALSE );
+ BOOL bOK = GetCache().CheckWord( aChkWord, nLanguage );
if (bOK)
xTmpRes = NULL;
else
@@ -769,7 +590,7 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
// But not those that are correct only because of
// the temporary supplied settings.
if (!xTmpRes.is() && 0 == rProperties.getLength())
- GetExtCache().AddWord( aChkWord, nLanguage );
+ GetCache().AddWord( aChkWord, nLanguage );
}
}
else
@@ -779,7 +600,7 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
if (!xRes.is() && bTmpResValid)
xRes = xTmpRes;
- pEntry->aFlags.nLastTriedSvcIndex = (INT16) i;
+ pEntry->nLastTriedSvcIndex = (INT16) i;
++i;
}
@@ -788,7 +609,7 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
if (i == nLen)
{
if (!SvcListHasLanguage( *pEntry, nLanguage ))
- aSvcList.Remove( nLanguage );
+ aSvcMap.erase( nLanguage );
}
}
}
@@ -865,45 +686,93 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
if (bCheckDics && xDList.is())
SeqRemoveNegEntries( aProposals, xDList, nLanguage );
- xRes = new SpellAlternatives( aChkWord, nLanguage,
- eFailureType, aProposals );
+ uno::Reference< linguistic2::XSetSpellAlternatives > xSetAlt( xRes, uno::UNO_QUERY );
+ if (xSetAlt.is())
+ {
+ xSetAlt->setAlternatives( aProposals );
+ xSetAlt->setFailureType( eFailureType );
+ }
+ else
+ DBG_ASSERT( 0, "XSetSpellAlternatives not implemented!" );
}
}
return xRes;
}
+uno::Sequence< sal_Int16 > SAL_CALL SpellCheckerDispatcher::getLanguages( )
+throw (uno::RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+ uno::Sequence< Locale > aTmp( getLocales() );
+ uno::Sequence< INT16 > aRes( LocaleSeqToLangSeq( aTmp ) );
+ return aRes;
+}
+
+sal_Bool SAL_CALL SpellCheckerDispatcher::hasLanguage(
+ sal_Int16 nLanguage )
+throw (uno::RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+ Locale aLocale( CreateLocale( nLanguage ) );
+ return hasLocale( aLocale );
+}
+
+
+sal_Bool SAL_CALL SpellCheckerDispatcher::isValid(
+ const OUString& rWord,
+ sal_Int16 nLanguage,
+ const uno::Sequence< beans::PropertyValue >& rProperties )
+throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+ Locale aLocale( CreateLocale( nLanguage ) );
+ return isValid( rWord, aLocale, rProperties);
+}
+
+
+uno::Reference< linguistic2::XSpellAlternatives > SAL_CALL SpellCheckerDispatcher::spell(
+ const OUString& rWord,
+ sal_Int16 nLanguage,
+ const uno::Sequence< beans::PropertyValue >& rProperties )
+throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+ Locale aLocale( CreateLocale( nLanguage ) );
+ return spell( rWord, aLocale, rProperties);
+}
+
+
void SpellCheckerDispatcher::SetServiceList( const Locale &rLocale,
const Sequence< OUString > &rSvcImplNames )
{
MutexGuard aGuard( GetLinguMutex() );
- if (pExtCache)
- pExtCache->Flush(); // new services may spell differently...
+ if (pCache)
+ pCache->Flush(); // new services may spell differently...
INT16 nLanguage = LocaleToLanguage( rLocale );
- if (0 == rSvcImplNames.getLength())
+ INT32 nLen = rSvcImplNames.getLength();
+ if (0 == nLen)
// remove entry
- aSvcList.Remove( nLanguage );
+ aSvcMap.erase( nLanguage );
else
{
// modify/add entry
- SeqLangSvcEntry_Spell *pEntry = aSvcList.Get( nLanguage );
+ LangSvcEntries_Spell *pEntry = aSvcMap[ nLanguage ].get();
if (pEntry)
{
- INT32 nLen = rSvcImplNames.getLength();
+ pEntry->Clear();
pEntry->aSvcImplNames = rSvcImplNames;
- pEntry->aSvcRefs = Sequence< Reference < XSpellChecker > > ( nLen );
- pEntry->aSvc1Refs = Sequence< Reference < XSpellChecker1 > >( nLen );
- pEntry->aFlags = SvcFlags();
+ pEntry->aSvcRefs = Sequence< Reference < XSpellChecker > > ( nLen );
}
else
{
- pEntry = new SeqLangSvcEntry_Spell( rSvcImplNames );
- aSvcList.Insert( nLanguage, pEntry );
- DBG_ASSERT( aSvcList.Get( nLanguage ), "lng : Insert failed" );
+ boost::shared_ptr< LangSvcEntries_Spell > pTmpEntry( new LangSvcEntries_Spell( rSvcImplNames ) );
+ pTmpEntry->aSvcRefs = Sequence< Reference < XSpellChecker > >( nLen );
+ aSvcMap[ nLanguage ] = pTmpEntry;
}
}
}
@@ -919,7 +788,7 @@ Sequence< OUString >
// search for entry with that language and use data from that
INT16 nLanguage = LocaleToLanguage( rLocale );
SpellCheckerDispatcher *pThis = (SpellCheckerDispatcher *) this;
- const SeqLangSvcEntry_Spell *pEntry = pThis->aSvcList.Get( nLanguage );
+ const LangSvcEntries_Spell *pEntry = pThis->aSvcMap[ nLanguage ].get();
if (pEntry)
aRes = pEntry->aSvcImplNames;
@@ -927,12 +796,16 @@ Sequence< OUString >
}
-SpellCheckerDispatcher::DspType
- SpellCheckerDispatcher::GetDspType() const
+LinguDispatcher::DspType SpellCheckerDispatcher::GetDspType() const
{
return DSP_SPELL;
}
+void SpellCheckerDispatcher::FlushSpellCache()
+{
+ if (pCache)
+ pCache->Flush();
+}
///////////////////////////////////////////////////////////////////////////
diff --git a/linguistic/source/spelldsp.hxx b/linguistic/source/spelldsp.hxx
index b826f30ba5..53e5be5d17 100644
--- a/linguistic/source/spelldsp.hxx
+++ b/linguistic/source/spelldsp.hxx
@@ -36,69 +36,39 @@
#include "iprcache.hxx"
#include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
-#include <cppuhelper/implbase1.hxx> // helper for implementations
-#include <cppuhelper/implbase2.hxx> // helper for implementations
-#include <cppuhelper/implbase7.hxx> // helper for implementations
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase7.hxx>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceDisplayName.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyValues.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/linguistic2/XSpellChecker.hpp>
#include <com/sun/star/linguistic2/XSpellChecker1.hpp>
+#include <com/sun/star/linguistic2/XSpellChecker.hpp>
#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
#include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
-#include <tools/table.hxx>
+#include <boost/shared_ptr.hpp>
+#include <map>
class LngSvcMgr;
///////////////////////////////////////////////////////////////////////////
-class SeqLangSvcEntry_Spell
-{
- friend class SpellCheckerDispatcher;
- friend BOOL SvcListHasLanguage(
- const SeqLangSvcEntry_Spell &rEntry,
- INT16 nLanguage );
-
- ::com::sun::star::uno::Sequence< ::rtl::OUString > aSvcImplNames;
- ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XSpellChecker > > aSvcRefs;
- ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XSpellChecker1 > > aSvc1Refs;
-
-// INT16 nLang; //used as key in the table
- SvcFlags aFlags;
-
-public:
- SeqLangSvcEntry_Spell() {}
- SeqLangSvcEntry_Spell( const ::com::sun::star::uno::Sequence<
- ::rtl::OUString > &rSvcImplNames );
- ~SeqLangSvcEntry_Spell();
-
- BOOL IsAlreadyWarned() const { return aFlags.bAlreadyWarned != 0; }
- void SetAlreadyWarned(BOOL bVal) { aFlags.bAlreadyWarned = 0 != bVal; }
- BOOL IsDoWarnAgain() const { return aFlags.bDoWarnAgain != 0; }
- void SetDoWarnAgain(BOOL bVal) { aFlags.bDoWarnAgain = 0 != bVal; }
-};
-
-DECLARE_TABLE( SpellSvcList, SeqLangSvcEntry_Spell * )
-
-
class SpellCheckerDispatcher :
public cppu::WeakImplHelper2
<
- ::com::sun::star::linguistic2::XSpellChecker,
- ::com::sun::star::linguistic2::XSpellChecker1
+ ::com::sun::star::linguistic2::XSpellChecker1,
+ ::com::sun::star::linguistic2::XSpellChecker
>,
public LinguDispatcher
{
- SpellSvcList aSvcList;
- LinguOptions aOpt;
+ typedef boost::shared_ptr< LangSvcEntries_Spell > LangSvcEntries_Spell_Ptr_t;
+ typedef std::map< LanguageType, LangSvcEntries_Spell_Ptr_t > SpellSvcByLangMap_t;
+ SpellSvcByLangMap_t aSvcMap;
+ LinguOptions aOpt;
::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet > xPropSet;
@@ -106,15 +76,13 @@ class SpellCheckerDispatcher :
::com::sun::star::linguistic2::XSearchableDictionaryList > xDicList;
LngSvcMgr &rMgr;
- linguistic::IPRSpellCache *pExtCache; // SpellCache for external SpellCheckers
- // (usually those not called via XSpellChecker1)
- // One for all of them.
+ linguistic::SpellCache *pCache; // Spell Cache (holds known words)
// disallow copy-constructor and assignment-operator for now
SpellCheckerDispatcher(const SpellCheckerDispatcher &);
SpellCheckerDispatcher & operator = (const SpellCheckerDispatcher &);
- inline linguistic::IPRSpellCache & GetExtCache() const;
+ inline linguistic::SpellCache & GetCache() const;
inline ::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet >
@@ -125,97 +93,52 @@ class SpellCheckerDispatcher :
void ClearSvcList();
- BOOL isValid_Impl(const ::rtl::OUString& aWord, INT16 nLanguage,
+ BOOL isValid_Impl(const ::rtl::OUString& aWord, LanguageType nLanguage,
const ::com::sun::star::beans::PropertyValues& aProperties,
BOOL bCheckDics)
throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
::com::sun::star::uno::Reference<
::com::sun::star::linguistic2::XSpellAlternatives >
- spell_Impl(const ::rtl::OUString& aWord, INT16 nLanguage,
+ spell_Impl(const ::rtl::OUString& aWord, LanguageType nLanguage,
const ::com::sun::star::beans::PropertyValues& aProperties,
BOOL bCheckDics)
throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
- BOOL isValidInAny(const ::rtl::OUString& aWord,
- const ::com::sun::star::uno::Sequence< INT16 >& aLanguages,
- const ::com::sun::star::beans::PropertyValues& aProperties)
- throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
-
- com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XSpellAlternatives >
- spellInAny(const ::rtl::OUString& aWord,
- const ::com::sun::star::uno::Sequence< INT16 >& aLanguages,
- const ::com::sun::star::beans::PropertyValues& aProperties,
- INT16 nPreferredResultLang)
- throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
-
public:
SpellCheckerDispatcher( LngSvcMgr &rLngSvcMgr );
virtual ~SpellCheckerDispatcher();
// XSupportedLocales (for XSpellChecker)
- virtual ::com::sun::star::uno::Sequence<
- ::com::sun::star::lang::Locale > SAL_CALL
- getLocales()
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL
- hasLocale( const ::com::sun::star::lang::Locale& aLocale )
- throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasLocale( const ::com::sun::star::lang::Locale& aLocale ) throw(::com::sun::star::uno::RuntimeException);
// XSpellChecker
- virtual sal_Bool SAL_CALL
- isValid( const ::rtl::OUString& aWord,
- const ::com::sun::star::lang::Locale& aLocale,
- const ::com::sun::star::beans::PropertyValues& aProperties )
- throw(::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XSpellAlternatives > SAL_CALL
- spell( const ::rtl::OUString& aWord,
- const ::com::sun::star::lang::Locale& aLocale,
- const ::com::sun::star::beans::PropertyValues& aProperties )
- throw(::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException);
-
- // XSupportedLanguages (for XSpellChecker1)
- virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL
- getLanguages()
- throw(::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL
- hasLanguage( sal_Int16 nLanguage )
- throw(::com::sun::star::uno::RuntimeException);
-
- // XSpellChecker1 (same as XSpellChecker but sal_Int16 for language)
- virtual sal_Bool SAL_CALL
- isValid( const ::rtl::OUString& aWord, sal_Int16 nLanguage,
- const ::com::sun::star::beans::PropertyValues& aProperties )
- throw(::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XSpellAlternatives > SAL_CALL
- spell( const ::rtl::OUString& aWord, sal_Int16 nLanguage,
- const ::com::sun::star::beans::PropertyValues& aProperties )
- throw(::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isValid( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellAlternatives > SAL_CALL spell( const ::rtl::OUString& aWord, const ::com::sun::star::lang::Locale& aLocale, const ::com::sun::star::beans::PropertyValues& aProperties ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ // XSupportedLanguages
+ virtual ::com::sun::star::uno::Sequence< ::sal_Int16 > SAL_CALL getLanguages( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasLanguage( ::sal_Int16 nLanguage ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XSpellChecker1
+ virtual ::sal_Bool SAL_CALL isValid( const ::rtl::OUString& aWord, ::sal_Int16 nLanguage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellAlternatives > SAL_CALL spell( const ::rtl::OUString& aWord, ::sal_Int16 nLanguage, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
// LinguDispatcher
- virtual void
- SetServiceList( const ::com::sun::star::lang::Locale &rLocale,
- const ::com::sun::star::uno::Sequence<
- rtl::OUString > &rSvcImplNames );
- virtual ::com::sun::star::uno::Sequence< rtl::OUString >
- GetServiceList( const ::com::sun::star::lang::Locale &rLocale ) const;
- virtual DspType
- GetDspType() const;
+ virtual void SetServiceList( const ::com::sun::star::lang::Locale &rLocale, const ::com::sun::star::uno::Sequence< rtl::OUString > &rSvcImplNames );
+ virtual ::com::sun::star::uno::Sequence< rtl::OUString > GetServiceList( const ::com::sun::star::lang::Locale &rLocale ) const;
+ virtual DspType GetDspType() const;
+
+ void FlushSpellCache();
};
-inline linguistic::IPRSpellCache & SpellCheckerDispatcher::GetExtCache() const
+inline linguistic::SpellCache & SpellCheckerDispatcher::GetCache() const
{
- if (!pExtCache)
- ((SpellCheckerDispatcher *) this)->pExtCache = new linguistic::IPRSpellCache( 997 );
- return *pExtCache;
+ if (!pCache)
+ ((SpellCheckerDispatcher *) this)->pCache = new linguistic::SpellCache();
+ return *pCache;
}
diff --git a/linguistic/source/spelldta.cxx b/linguistic/source/spelldta.cxx
index 31699ee49c..f4e98899ad 100644
--- a/linguistic/source/spelldta.cxx
+++ b/linguistic/source/spelldta.cxx
@@ -34,7 +34,6 @@
#include <com/sun/star/linguistic2/SpellFailure.hpp>
#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
-#include <com/sun/star/linguistic2/XDictionary1.hpp>
#include <tools/debug.hxx>
#include <unotools/processfactory.hxx>
#include <osl/mutex.hxx>
@@ -143,9 +142,9 @@ void SearchSimilarText( const OUString &rText, INT16 nLanguage,
for (INT32 i = 0; i < nDics; i++)
{
- Reference< XDictionary1 > xDic( pDic[i], UNO_QUERY );
+ Reference< XDictionary > xDic( pDic[i], UNO_QUERY );
- INT16 nLang = xDic->getLanguage();
+ INT16 nLang = LocaleToLanguage( xDic->getLocale() );
if ( xDic.is() && xDic->isActive()
&& (nLang == nLanguage || nLang == LANGUAGE_NONE) )
@@ -326,6 +325,22 @@ Sequence< OUString > SAL_CALL SpellAlternatives::getAlternatives()
}
+void SAL_CALL SpellAlternatives::setAlternatives( const uno::Sequence< OUString >& rAlternatives )
+throw (uno::RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+ aAlt = rAlternatives;
+}
+
+
+void SAL_CALL SpellAlternatives::setFailureType( sal_Int16 nFailureType )
+throw (uno::RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+ nType = nFailureType;
+}
+
+
void SpellAlternatives::SetWordLanguage(const OUString &rWord, INT16 nLang)
{
MutexGuard aGuard( GetLinguMutex() );
diff --git a/linguistic/source/supplang.cxx b/linguistic/source/supplang.cxx
deleted file mode 100644
index 36e86742ea..0000000000
--- a/linguistic/source/supplang.cxx
+++ /dev/null
@@ -1,161 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: supplang.cxx,v $
- * $Revision: 1.9 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_linguistic.hxx"
-#include <tools/string.hxx>
-#include <tools/fsys.hxx>
-#include <tools/urlobj.hxx>
-#include <ucbhelper/content.hxx>
-#include <tools/debug.hxx>
-#include <svtools/pathoptions.hxx>
-#include <unotools/processfactory.hxx>
-#include <unotools/localfilehelper.hxx>
-#include <unotools/localedatawrapper.hxx>
-#include <unotools/ucbhelper.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/beans/XFastPropertySet.hpp>
-#include <com/sun/star/beans/XPropertyChangeListener.hpp>
-#include <com/sun/star/frame/XTerminateListener.hpp>
-#include <com/sun/star/frame/XDesktop.hpp>
-
-#include <com/sun/star/beans/PropertyValues.hpp>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/linguistic2/XDictionary1.hpp>
-#include <com/sun/star/linguistic2/DictionaryType.hpp>
-#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
-
-#include "misc.hxx"
-#include "lngprops.hxx"
-#include "supplang.hxx"
-
-using namespace utl;
-using namespace osl;
-using namespace rtl;
-using namespace com::sun::star;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::linguistic2;
-using namespace linguistic;
-
-namespace linguistic
-{
-
-///////////////////////////////////////////////////////////////////////////
-
-INT16 & LanguageState::GetState( ModuleName eModule )
-{
- if ( MOD_SPELL == eModule )
- return nSpellState;
- else if ( MOD_HYPH == eModule )
- return nHyphState;
- else
- {
- DBG_ASSERT( MOD_THES == eModule, "unexpected argument" );
- return nThesState;
- }
-}
-
-
-LanguageState * GetLanguageState( INT16 nLanguage, LanguageState *pArray )
-{
- if (!pArray)
- return 0;
-
- LanguageState *pState = pArray;
- INT16 nLang;
- while ((nLang = pState->nLanguage) != LANGUAGE_NONE && nLang != nLanguage)
- ++pState;
- return nLang == LANGUAGE_NONE ? 0 : pState;
-}
-
-///////////////////////////////////////////////////////////////////////////
-
-SuppLanguages::SuppLanguages( LanguageState *pState, USHORT nCount)
-{
- for (USHORT i = 0; i < nCount; ++i)
- aLanguages.Insert( pState[i].nLanguage, new INT16( LANG_QUERY ) );
-}
-
-
-SuppLanguages::~SuppLanguages()
-{
- INT16 *pItem = aLanguages.First();
- while (pItem)
- {
- INT16 *pTmp = pItem;
- pItem = aLanguages.Next();
- delete pTmp;
- }
-}
-
-
-BOOL SuppLanguages::HasLanguage( INT16 nLanguage ) const
-{
- BOOL bRes = FALSE;
- SuppLanguages *pThis = (SuppLanguages *) this;
- INT16 *pEntry = pThis->aLanguages.Seek( nLanguage );
- if (pEntry)
- {
- INT16 nState = *pEntry;
- if (LANG_QUERY == nState)
- {
- nState = CheckLanguage( nLanguage );
- pThis->aLanguages.Replace( nLanguage, new INT16( nState ) );
- }
- bRes = LANG_OK == nState;
- }
- return bRes;
-}
-
-
-const Sequence< INT16 > SuppLanguages::GetLanguages() const
-{
- INT32 nLen = aLanguages.Count();
- Sequence< INT16 > aRes( nLen );
- INT16 *pRes = aRes.getArray();
- USHORT nCnt = 0;
- for (INT32 i = 0; i < nLen; ++i)
- {
- INT16 nLanguage = sal::static_int_cast< INT16 >(aLanguages.GetObjectKey( i ));
- if (HasLanguage( nLanguage ))
- pRes[ nCnt++ ] = nLanguage;
- }
- aRes.realloc( nCnt );
- return aRes;
-}
-
-///////////////////////////////////////////////////////////////////////////
-
-} // namespace linguistic
-
-
diff --git a/linguistic/source/thesdsp.cxx b/linguistic/source/thesdsp.cxx
index b6a7d65e3c..9ba9f9f9ce 100644
--- a/linguistic/source/thesdsp.cxx
+++ b/linguistic/source/thesdsp.cxx
@@ -74,19 +74,6 @@ static BOOL SvcListHasLanguage(
///////////////////////////////////////////////////////////////////////////
-SeqLangSvcEntry_Thes::~SeqLangSvcEntry_Thes()
-{
-}
-
-
-SeqLangSvcEntry_Thes::SeqLangSvcEntry_Thes(
- const Sequence< OUString > &rSvcImplNames ) :
- aSvcImplNames ( rSvcImplNames ),
- aSvcRefs ( rSvcImplNames.getLength() )
-{
-}
-
-///////////////////////////////////////////////////////////////////////////
ThesaurusDispatcher::ThesaurusDispatcher()
{
@@ -102,13 +89,8 @@ ThesaurusDispatcher::~ThesaurusDispatcher()
void ThesaurusDispatcher::ClearSvcList()
{
// release memory for each table entry
- SeqLangSvcEntry_Thes *pItem = aSvcList.First();
- while (pItem)
- {
- SeqLangSvcEntry_Thes *pTmp = pItem;
- pItem = aSvcList.Next();
- delete pTmp;
- }
+ ThesSvcByLangMap_t aTmp;
+ aSvcMap.swap( aTmp );
}
@@ -118,16 +100,13 @@ Sequence< Locale > SAL_CALL
{
MutexGuard aGuard( GetLinguMutex() );
- ULONG nCnt = aSvcList.Count();
- Sequence< Locale > aLocales( nCnt );
- Locale *pItem = aLocales.getArray();
- SeqLangSvcEntry_Thes *pEntry = aSvcList.First();
- for (ULONG i = 0; i < nCnt; i++)
+ Sequence< Locale > aLocales( static_cast< sal_Int32 >(aSvcMap.size()) );
+ Locale *pLocales = aLocales.getArray();
+ ThesSvcByLangMap_t::const_iterator aIt;
+ for (aIt = aSvcMap.begin(); aIt != aSvcMap.end(); ++aIt)
{
- DBG_ASSERT( pEntry, "lng : pEntry is NULL pointer" );
- pItem[i] = CreateLocale( (LanguageType) aSvcList.GetKey( pEntry ) );
- pEntry = aSvcList.Next();
- }
+ *pLocales++ = CreateLocale( aIt->first );
+ }
return aLocales;
}
@@ -137,7 +116,8 @@ sal_Bool SAL_CALL
throw(RuntimeException)
{
MutexGuard aGuard( GetLinguMutex() );
- return 0 != aSvcList.Get( LocaleToLanguage( rLocale ) );
+ ThesSvcByLangMap_t::const_iterator aIt( aSvcMap.find( LocaleToLanguage( rLocale ) ) );
+ return aIt != aSvcMap.end();
}
@@ -156,7 +136,7 @@ Sequence< Reference< XMeaning > > SAL_CALL
return aMeanings;
// search for entry with that language
- SeqLangSvcEntry_Thes *pEntry = aSvcList.Get( nLanguage );
+ LangSvcEntries_Thes *pEntry = aSvcMap[ nLanguage ].get();
if (!pEntry)
{
@@ -175,7 +155,7 @@ Sequence< Reference< XMeaning > > SAL_CALL
INT32 nLen = pEntry->aSvcRefs.getLength();
DBG_ASSERT( nLen == pEntry->aSvcImplNames.getLength(),
"lng : sequence length mismatch");
- DBG_ASSERT( pEntry->aFlags.nLastTriedSvcIndex < nLen,
+ DBG_ASSERT( pEntry->nLastTriedSvcIndex < nLen,
"lng : index out of range");
INT32 i = 0;
@@ -183,7 +163,7 @@ Sequence< Reference< XMeaning > > SAL_CALL
// try already instantiated services first
{
const Reference< XThesaurus > *pRef = pEntry->aSvcRefs.getConstArray();
- while (i <= pEntry->aFlags.nLastTriedSvcIndex
+ while (i <= pEntry->nLastTriedSvcIndex
&& aMeanings.getLength() == 0)
{
if (pRef[i].is() && pRef[i]->hasLocale( rLocale ))
@@ -194,7 +174,7 @@ Sequence< Reference< XMeaning > > SAL_CALL
// if still no result instantiate new services and try those
if (aMeanings.getLength() == 0
- && pEntry->aFlags.nLastTriedSvcIndex < nLen - 1)
+ && pEntry->nLastTriedSvcIndex < nLen - 1)
{
const OUString *pImplNames = pEntry->aSvcImplNames.getConstArray();
Reference< XThesaurus > *pRef = pEntry->aSvcRefs.getArray();
@@ -218,14 +198,14 @@ Sequence< Reference< XMeaning > > SAL_CALL
}
catch (uno::Exception &)
{
- DBG_ERROR( "createInstanceWithArguments failed" );
+ DBG_ASSERT( 0, "createInstanceWithArguments failed" );
}
pRef[i] = xThes;
if (xThes.is() && xThes->hasLocale( rLocale ))
aMeanings = xThes->queryMeanings( aChkWord, rLocale, rProperties );
- pEntry->aFlags.nLastTriedSvcIndex = (INT16) i;
+ pEntry->nLastTriedSvcIndex = (INT16) i;
++i;
}
@@ -234,7 +214,7 @@ Sequence< Reference< XMeaning > > SAL_CALL
if (i == nLen && aMeanings.getLength() == 0)
{
if (!SvcListHasLanguage( pEntry->aSvcRefs, rLocale ))
- aSvcList.Remove( nLanguage );
+ aSvcMap.erase( nLanguage );
}
}
}
@@ -251,25 +231,25 @@ void ThesaurusDispatcher::SetServiceList( const Locale &rLocale,
INT16 nLanguage = LocaleToLanguage( rLocale );
- if (0 == rSvcImplNames.getLength())
+ INT32 nLen = rSvcImplNames.getLength();
+ if (0 == nLen)
// remove entry
- aSvcList.Remove( nLanguage );
+ aSvcMap.erase( nLanguage );
else
{
// modify/add entry
- SeqLangSvcEntry_Thes *pEntry = aSvcList.Get( nLanguage );
+ LangSvcEntries_Thes *pEntry = aSvcMap[ nLanguage ].get();
if (pEntry)
{
+ pEntry->Clear();
pEntry->aSvcImplNames = rSvcImplNames;
- pEntry->aSvcRefs = Sequence< Reference < XThesaurus > >(
- rSvcImplNames.getLength() );
- pEntry->aFlags = SvcFlags();
+ pEntry->aSvcRefs = Sequence< Reference < XThesaurus > >( nLen );
}
else
{
- pEntry = new SeqLangSvcEntry_Thes( rSvcImplNames );
- aSvcList.Insert( nLanguage, pEntry );
- DBG_ASSERT( aSvcList.Get( nLanguage ), "lng : Insert failed" );
+ boost::shared_ptr< LangSvcEntries_Thes > pTmpEntry( new LangSvcEntries_Thes( rSvcImplNames ) );
+ pTmpEntry->aSvcRefs = Sequence< Reference < XThesaurus > >( nLen );
+ aSvcMap[ nLanguage ] = pTmpEntry;
}
}
}
@@ -285,7 +265,7 @@ Sequence< OUString >
// search for entry with that language and use data from that
INT16 nLanguage = LocaleToLanguage( rLocale );
ThesaurusDispatcher *pThis = (ThesaurusDispatcher *) this;
- const SeqLangSvcEntry_Thes *pEntry = pThis->aSvcList.Get( nLanguage );
+ const LangSvcEntries_Thes *pEntry = pThis->aSvcMap[ nLanguage ].get();
if (pEntry)
aRes = pEntry->aSvcImplNames;
@@ -293,8 +273,7 @@ Sequence< OUString >
}
-ThesaurusDispatcher::DspType
- ThesaurusDispatcher::GetDspType() const
+LinguDispatcher::DspType ThesaurusDispatcher::GetDspType() const
{
return DSP_THES;
}
diff --git a/linguistic/source/thesdsp.hxx b/linguistic/source/thesdsp.hxx
index 443358a18e..baa3756b13 100644
--- a/linguistic/source/thesdsp.hxx
+++ b/linguistic/source/thesdsp.hxx
@@ -33,6 +33,7 @@
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertyAccess.hpp>
#include <com/sun/star/beans/XPropertyChangeListener.hpp>
#include <com/sun/star/lang/XComponent.hpp>
@@ -48,46 +49,15 @@
#include <cppuhelper/interfacecontainer.h>
#include <vos/mutex.hxx>
-#include <tools/table.hxx>
-
-#include "lngopt.hxx"
+#include <boost/shared_ptr.hpp>
+#include <map>
-class LinguOptions;
+#include "lngopt.hxx"
-namespace com { namespace sun { namespace star { namespace beans {
- class XPropertySet;
-}}}}
///////////////////////////////////////////////////////////////////////////
-class SeqLangSvcEntry_Thes
-{
- friend class ThesaurusDispatcher;
-
- ::com::sun::star::uno::Sequence< ::rtl::OUString > aSvcImplNames;
- ::com::sun::star::uno::Sequence<
- ::com::sun::star::uno::Reference<
- ::com::sun::star::linguistic2::XThesaurus > > aSvcRefs;
-// INT16 nLang; //used as key in the table
- SvcFlags aFlags;
-
-public:
- SeqLangSvcEntry_Thes() {}
- SeqLangSvcEntry_Thes( const ::com::sun::star::uno::Sequence<
- ::rtl::OUString > &rSvcImplNames );
- ~SeqLangSvcEntry_Thes();
-
- BOOL IsAlreadyWarned() const { return aFlags.bAlreadyWarned != 0; }
- void SetAlreadyWarned(BOOL bVal) { aFlags.bAlreadyWarned = 0 != bVal; }
- BOOL IsDoWarnAgain() const { return aFlags.bDoWarnAgain != 0; }
- void SetDoWarnAgain(BOOL bVal) { aFlags.bDoWarnAgain = 0 != bVal; }
-};
-
-
-
-DECLARE_TABLE( ThesSvcList, SeqLangSvcEntry_Thes * )
-
class ThesaurusDispatcher :
public cppu::WeakImplHelper1
<
@@ -95,7 +65,9 @@ class ThesaurusDispatcher :
>,
public LinguDispatcher
{
- ThesSvcList aSvcList;
+ typedef boost::shared_ptr< LangSvcEntries_Thes > LangSvcEntries_Thes_Ptr_t;
+ typedef std::map< LanguageType, LangSvcEntries_Thes_Ptr_t > ThesSvcByLangMap_t;
+ ThesSvcByLangMap_t aSvcMap;
::com::sun::star::uno::Reference<
::com::sun::star::beans::XPropertySet > xPropSet;