allow to create new database using the wizard again (fdo#62937)
[LibreOffice.git] / linguistic / source / spelldsp.hxx
blobc2e591afd54f723a1a5fa0c7389010fa6b8475ba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _LINGUISTIC_SPELLDSP_HXX_
21 #define _LINGUISTIC_SPELLDSP_HXX_
23 #include "lngopt.hxx"
24 #include "linguistic/misc.hxx"
25 #include "iprcache.hxx"
27 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
28 #include <cppuhelper/implbase1.hxx>
29 #include <cppuhelper/implbase2.hxx>
30 #include <cppuhelper/implbase7.hxx>
31 #include <com/sun/star/lang/XComponent.hpp>
32 #include <com/sun/star/lang/XInitialization.hpp>
33 #include <com/sun/star/lang/XServiceDisplayName.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/beans/PropertyValues.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
38 #include <com/sun/star/linguistic2/XSpellChecker.hpp>
39 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
40 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
42 #include <boost/shared_ptr.hpp>
43 #include <map>
44 #include <unotools/charclass.hxx>
46 class LngSvcMgr;
49 class SpellCheckerDispatcher :
50 public cppu::WeakImplHelper2
52 ::com::sun::star::linguistic2::XSpellChecker1,
53 ::com::sun::star::linguistic2::XSpellChecker
55 public LinguDispatcher
57 typedef boost::shared_ptr< LangSvcEntries_Spell > LangSvcEntries_Spell_Ptr_t;
58 typedef std::map< LanguageType, LangSvcEntries_Spell_Ptr_t > SpellSvcByLangMap_t;
59 SpellSvcByLangMap_t aSvcMap;
60 LinguOptions aOpt;
62 ::com::sun::star::uno::Reference<
63 ::com::sun::star::linguistic2::XLinguProperties > xPropSet;
64 ::com::sun::star::uno::Reference<
65 ::com::sun::star::linguistic2::XSearchableDictionaryList > xDicList;
67 LngSvcMgr &rMgr;
68 mutable linguistic::SpellCache *pCache; // Spell Cache (holds known words)
69 CharClass * pCharClass;
71 // disallow copy-constructor and assignment-operator for now
72 SpellCheckerDispatcher(const SpellCheckerDispatcher &);
73 SpellCheckerDispatcher & operator = (const SpellCheckerDispatcher &);
75 inline linguistic::SpellCache & GetCache() const;
77 inline ::com::sun::star::uno::Reference<
78 ::com::sun::star::linguistic2::XLinguProperties >
79 GetPropSet();
80 inline ::com::sun::star::uno::Reference<
81 ::com::sun::star::linguistic2::XSearchableDictionaryList >
82 GetDicList();
84 void ClearSvcList();
86 sal_Bool isValid_Impl(const OUString& aWord, LanguageType nLanguage,
87 const ::com::sun::star::beans::PropertyValues& aProperties,
88 sal_Bool bCheckDics)
89 throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
91 ::com::sun::star::uno::Reference<
92 ::com::sun::star::linguistic2::XSpellAlternatives >
93 spell_Impl(const OUString& aWord, LanguageType nLanguage,
94 const ::com::sun::star::beans::PropertyValues& aProperties,
95 sal_Bool bCheckDics)
96 throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
98 public:
99 SpellCheckerDispatcher( LngSvcMgr &rLngSvcMgr );
100 virtual ~SpellCheckerDispatcher();
102 // XSupportedLocales (for XSpellChecker)
103 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getLocales() throw(::com::sun::star::uno::RuntimeException);
104 virtual sal_Bool SAL_CALL hasLocale( const ::com::sun::star::lang::Locale& aLocale ) throw(::com::sun::star::uno::RuntimeException);
106 // XSpellChecker
107 virtual sal_Bool SAL_CALL isValid( const 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);
108 virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellAlternatives > SAL_CALL spell( const 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);
110 // XSupportedLanguages
111 virtual ::com::sun::star::uno::Sequence< ::sal_Int16 > SAL_CALL getLanguages( ) throw (::com::sun::star::uno::RuntimeException);
112 virtual ::sal_Bool SAL_CALL hasLanguage( ::sal_Int16 nLanguage ) throw (::com::sun::star::uno::RuntimeException);
114 // XSpellChecker1
115 virtual ::sal_Bool SAL_CALL isValid( const 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);
116 virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellAlternatives > SAL_CALL spell( const 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);
118 // LinguDispatcher
119 virtual void SetServiceList( const ::com::sun::star::lang::Locale &rLocale, const ::com::sun::star::uno::Sequence< OUString > &rSvcImplNames );
120 virtual ::com::sun::star::uno::Sequence< OUString > GetServiceList( const ::com::sun::star::lang::Locale &rLocale ) const;
121 virtual DspType GetDspType() const;
123 void FlushSpellCache();
125 private:
126 void setCharClass(const LanguageTag& rLanguageTag);
127 OUString SAL_CALL makeLowerCase(const OUString&, CharClass *);
131 inline linguistic::SpellCache & SpellCheckerDispatcher::GetCache() const
133 if (!pCache)
134 pCache = new linguistic::SpellCache();
135 return *pCache;
139 inline ::com::sun::star::uno::Reference<
140 ::com::sun::star::linguistic2::XLinguProperties >
141 SpellCheckerDispatcher::GetPropSet()
143 return xPropSet.is() ?
144 xPropSet : xPropSet = linguistic::GetLinguProperties();
148 inline ::com::sun::star::uno::Reference<
149 ::com::sun::star::linguistic2::XSearchableDictionaryList >
150 SpellCheckerDispatcher::GetDicList()
152 return xDicList.is() ?
153 xDicList : xDicList = linguistic::GetDictionaryList();
157 #endif
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */