1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: spelldsp.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _LINGUISTIC_SPELLDSP_HXX_
32 #define _LINGUISTIC_SPELLDSP_HXX_
36 #include "iprcache.hxx"
38 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
39 #include <cppuhelper/implbase1.hxx>
40 #include <cppuhelper/implbase2.hxx>
41 #include <cppuhelper/implbase7.hxx>
42 #include <com/sun/star/lang/XComponent.hpp>
43 #include <com/sun/star/lang/XInitialization.hpp>
44 #include <com/sun/star/lang/XServiceDisplayName.hpp>
45 #include <com/sun/star/beans/XPropertySet.hpp>
46 #include <com/sun/star/beans/PropertyValues.hpp>
47 #include <com/sun/star/lang/XServiceInfo.hpp>
48 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
49 #include <com/sun/star/linguistic2/XSpellChecker.hpp>
50 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
51 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
53 #include <boost/shared_ptr.hpp>
58 ///////////////////////////////////////////////////////////////////////////
60 class SpellCheckerDispatcher
:
61 public cppu::WeakImplHelper2
63 ::com::sun::star::linguistic2::XSpellChecker1
,
64 ::com::sun::star::linguistic2::XSpellChecker
66 public LinguDispatcher
68 typedef boost::shared_ptr
< LangSvcEntries_Spell
> LangSvcEntries_Spell_Ptr_t
;
69 typedef std::map
< LanguageType
, LangSvcEntries_Spell_Ptr_t
> SpellSvcByLangMap_t
;
70 SpellSvcByLangMap_t aSvcMap
;
73 ::com::sun::star::uno::Reference
<
74 ::com::sun::star::beans::XPropertySet
> xPropSet
;
75 ::com::sun::star::uno::Reference
<
76 ::com::sun::star::linguistic2::XSearchableDictionaryList
> xDicList
;
79 linguistic::SpellCache
*pCache
; // Spell Cache (holds known words)
81 // disallow copy-constructor and assignment-operator for now
82 SpellCheckerDispatcher(const SpellCheckerDispatcher
&);
83 SpellCheckerDispatcher
& operator = (const SpellCheckerDispatcher
&);
85 inline linguistic::SpellCache
& GetCache() const;
87 inline ::com::sun::star::uno::Reference
<
88 ::com::sun::star::beans::XPropertySet
>
90 inline ::com::sun::star::uno::Reference
<
91 ::com::sun::star::linguistic2::XSearchableDictionaryList
>
96 BOOL
isValid_Impl(const ::rtl::OUString
& aWord
, LanguageType nLanguage
,
97 const ::com::sun::star::beans::PropertyValues
& aProperties
,
99 throw( ::com::sun::star::uno::RuntimeException
, ::com::sun::star::lang::IllegalArgumentException
);
101 ::com::sun::star::uno::Reference
<
102 ::com::sun::star::linguistic2::XSpellAlternatives
>
103 spell_Impl(const ::rtl::OUString
& aWord
, LanguageType nLanguage
,
104 const ::com::sun::star::beans::PropertyValues
& aProperties
,
106 throw( ::com::sun::star::uno::RuntimeException
, ::com::sun::star::lang::IllegalArgumentException
);
109 SpellCheckerDispatcher( LngSvcMgr
&rLngSvcMgr
);
110 virtual ~SpellCheckerDispatcher();
112 // XSupportedLocales (for XSpellChecker)
113 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::lang::Locale
> SAL_CALL
getLocales() throw(::com::sun::star::uno::RuntimeException
);
114 virtual sal_Bool SAL_CALL
hasLocale( const ::com::sun::star::lang::Locale
& aLocale
) throw(::com::sun::star::uno::RuntimeException
);
117 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
);
118 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
);
120 // XSupportedLanguages
121 virtual ::com::sun::star::uno::Sequence
< ::sal_Int16
> SAL_CALL
getLanguages( ) throw (::com::sun::star::uno::RuntimeException
);
122 virtual ::sal_Bool SAL_CALL
hasLanguage( ::sal_Int16 nLanguage
) throw (::com::sun::star::uno::RuntimeException
);
125 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
);
126 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
);
129 virtual void SetServiceList( const ::com::sun::star::lang::Locale
&rLocale
, const ::com::sun::star::uno::Sequence
< rtl::OUString
> &rSvcImplNames
);
130 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> GetServiceList( const ::com::sun::star::lang::Locale
&rLocale
) const;
131 virtual DspType
GetDspType() const;
133 void FlushSpellCache();
137 inline linguistic::SpellCache
& SpellCheckerDispatcher::GetCache() const
140 ((SpellCheckerDispatcher
*) this)->pCache
= new linguistic::SpellCache();
145 inline ::com::sun::star::uno::Reference
<
146 ::com::sun::star::beans::XPropertySet
>
147 SpellCheckerDispatcher::GetPropSet()
149 return xPropSet
.is() ?
150 xPropSet
: xPropSet
= linguistic::GetLinguProperties();
154 inline ::com::sun::star::uno::Reference
<
155 ::com::sun::star::linguistic2::XSearchableDictionaryList
>
156 SpellCheckerDispatcher::GetDicList()
158 return xDicList
.is() ?
159 xDicList
: xDicList
= linguistic::GetSearchableDictionaryList();
163 ///////////////////////////////////////////////////////////////////////////