1*63ce064aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*63ce064aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*63ce064aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*63ce064aSAndrew Rist * distributed with this work for additional information 6*63ce064aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*63ce064aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*63ce064aSAndrew Rist * "License"); you may not use this file except in compliance 9*63ce064aSAndrew Rist * with the License. You may obtain a copy of the License at 10*63ce064aSAndrew Rist * 11*63ce064aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*63ce064aSAndrew Rist * 13*63ce064aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*63ce064aSAndrew Rist * software distributed under the License is distributed on an 15*63ce064aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*63ce064aSAndrew Rist * KIND, either express or implied. See the License for the 17*63ce064aSAndrew Rist * specific language governing permissions and limitations 18*63ce064aSAndrew Rist * under the License. 19*63ce064aSAndrew Rist * 20*63ce064aSAndrew Rist *************************************************************/ 21*63ce064aSAndrew Rist 22*63ce064aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _LINGUISTIC_IPRCACHE_HXX_ 25cdf0e10cSrcweir #define _LINGUISTIC_IPRCACHE_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type 29cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> // helper for implementations 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 32cdf0e10cSrcweir #include <com/sun/star/document/XEventListener.hpp> 33cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyChangeListener.hpp> 34cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 35cdf0e10cSrcweir #include <com/sun/star/linguistic2/XDictionaryListEventListener.hpp> 36cdf0e10cSrcweir #include <com/sun/star/linguistic2/XDictionaryList.hpp> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <rtl/string.hxx> 39cdf0e10cSrcweir #include <i18npool/lang.h> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <set> 42cdf0e10cSrcweir #include <map> 43cdf0e10cSrcweir 44cdf0e10cSrcweir namespace linguistic 45cdf0e10cSrcweir { 46cdf0e10cSrcweir 47cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////// 48cdf0e10cSrcweir 49cdf0e10cSrcweir class Flushable 50cdf0e10cSrcweir { 51cdf0e10cSrcweir public: 52cdf0e10cSrcweir virtual void Flush() = 0; 53cdf0e10cSrcweir }; 54cdf0e10cSrcweir 55cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////// 56cdf0e10cSrcweir 57cdf0e10cSrcweir class FlushListener : 58cdf0e10cSrcweir public cppu::WeakImplHelper2 59cdf0e10cSrcweir < 60cdf0e10cSrcweir ::com::sun::star::linguistic2::XDictionaryListEventListener, 61cdf0e10cSrcweir ::com::sun::star::beans::XPropertyChangeListener 62cdf0e10cSrcweir > 63cdf0e10cSrcweir { 64cdf0e10cSrcweir ::com::sun::star::uno::Reference< 65cdf0e10cSrcweir ::com::sun::star::linguistic2::XDictionaryList > xDicList; 66cdf0e10cSrcweir ::com::sun::star::uno::Reference< 67cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet > xPropSet; 68cdf0e10cSrcweir Flushable *pFlushObj; 69cdf0e10cSrcweir 70cdf0e10cSrcweir // don't allow to use copy-constructor and assignment-operator 71cdf0e10cSrcweir FlushListener(const FlushListener &); 72cdf0e10cSrcweir FlushListener & operator = (const FlushListener &); 73cdf0e10cSrcweir 74cdf0e10cSrcweir public: 75cdf0e10cSrcweir FlushListener( Flushable *pFO ); 76cdf0e10cSrcweir virtual ~FlushListener(); 77cdf0e10cSrcweir SetFlushObj(Flushable * pFO)78cdf0e10cSrcweir inline void SetFlushObj( Flushable *pFO) { pFlushObj = pFO; } 79cdf0e10cSrcweir 80cdf0e10cSrcweir void SetDicList( ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryList > &rDL ); 81cdf0e10cSrcweir void SetPropSet( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &rPS ); 82cdf0e10cSrcweir 83cdf0e10cSrcweir //XEventListener 84cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rSource ) throw(::com::sun::star::uno::RuntimeException); 85cdf0e10cSrcweir 86cdf0e10cSrcweir // XDictionaryListEventListener 87cdf0e10cSrcweir virtual void SAL_CALL processDictionaryListEvent( const ::com::sun::star::linguistic2::DictionaryListEvent& rDicListEvent ) throw(::com::sun::star::uno::RuntimeException); 88cdf0e10cSrcweir 89cdf0e10cSrcweir // XPropertyChangeListener 90cdf0e10cSrcweir virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) throw(::com::sun::star::uno::RuntimeException); 91cdf0e10cSrcweir }; 92cdf0e10cSrcweir 93cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////// 94cdf0e10cSrcweir 95cdf0e10cSrcweir class SpellCache : 96cdf0e10cSrcweir public Flushable 97cdf0e10cSrcweir { 98cdf0e10cSrcweir ::com::sun::star::uno::Reference< 99cdf0e10cSrcweir ::com::sun::star::linguistic2::XDictionaryListEventListener > 100cdf0e10cSrcweir xFlushLstnr; 101cdf0e10cSrcweir FlushListener *pFlushLstnr; 102cdf0e10cSrcweir 103cdf0e10cSrcweir typedef std::set< ::rtl::OUString > WordList_t; 104cdf0e10cSrcweir typedef std::map< LanguageType, WordList_t > LangWordList_t; 105cdf0e10cSrcweir LangWordList_t aWordLists; 106cdf0e10cSrcweir 107cdf0e10cSrcweir // don't allow to use copy-constructor and assignment-operator 108cdf0e10cSrcweir SpellCache(const SpellCache &); 109cdf0e10cSrcweir SpellCache & operator = (const SpellCache &); 110cdf0e10cSrcweir 111cdf0e10cSrcweir public: 112cdf0e10cSrcweir SpellCache(); 113cdf0e10cSrcweir virtual ~SpellCache(); 114cdf0e10cSrcweir 115cdf0e10cSrcweir // Flushable 116cdf0e10cSrcweir virtual void Flush(); 117cdf0e10cSrcweir 118cdf0e10cSrcweir void AddWord( const ::rtl::OUString& rWord, LanguageType nLang ); 119cdf0e10cSrcweir bool CheckWord( const ::rtl::OUString& rWord, LanguageType nLang ); 120cdf0e10cSrcweir }; 121cdf0e10cSrcweir 122cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////// 123cdf0e10cSrcweir 124cdf0e10cSrcweir } // namespace linguistic 125cdf0e10cSrcweir 126cdf0e10cSrcweir #endif 127cdf0e10cSrcweir 128