Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _LINGUISTIC_IPRCACHE_HXX_
30 : : #define _LINGUISTIC_IPRCACHE_HXX_
31 : :
32 : :
33 : : #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
34 : : #include <cppuhelper/implbase2.hxx> // helper for implementations
35 : :
36 : : #include <com/sun/star/uno/Reference.h>
37 : : #include <com/sun/star/document/XEventListener.hpp>
38 : : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
39 : : #include <com/sun/star/beans/XPropertySet.hpp>
40 : : #include <com/sun/star/linguistic2/XDictionaryListEventListener.hpp>
41 : : #include <com/sun/star/linguistic2/XDictionaryList.hpp>
42 : :
43 : : #include <rtl/string.hxx>
44 : : #include <i18npool/lang.h>
45 : :
46 : : #include <set>
47 : : #include <map>
48 : :
49 : : namespace linguistic
50 : : {
51 : :
52 : :
53 : 40 : class Flushable
54 : : {
55 : : public:
56 : : virtual void Flush() = 0;
57 : :
58 : : protected:
59 : 38 : ~Flushable() {}
60 : : };
61 : :
62 : :
63 : : class FlushListener :
64 : : public cppu::WeakImplHelper2
65 : : <
66 : : ::com::sun::star::linguistic2::XDictionaryListEventListener,
67 : : ::com::sun::star::beans::XPropertyChangeListener
68 : : >
69 : : {
70 : : ::com::sun::star::uno::Reference<
71 : : ::com::sun::star::linguistic2::XDictionaryList > xDicList;
72 : : ::com::sun::star::uno::Reference<
73 : : ::com::sun::star::beans::XPropertySet > xPropSet;
74 : : Flushable *pFlushObj;
75 : :
76 : : // don't allow to use copy-constructor and assignment-operator
77 : : FlushListener(const FlushListener &);
78 : : FlushListener & operator = (const FlushListener &);
79 : :
80 : : public:
81 : : FlushListener( Flushable *pFO );
82 : : virtual ~FlushListener();
83 : :
84 : 40 : inline void SetFlushObj( Flushable *pFO) { pFlushObj = pFO; }
85 : :
86 : : void SetDicList( ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryList > &rDL );
87 : : void SetPropSet( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &rPS );
88 : :
89 : : //XEventListener
90 : : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rSource ) throw(::com::sun::star::uno::RuntimeException);
91 : :
92 : : // XDictionaryListEventListener
93 : : virtual void SAL_CALL processDictionaryListEvent( const ::com::sun::star::linguistic2::DictionaryListEvent& rDicListEvent ) throw(::com::sun::star::uno::RuntimeException);
94 : :
95 : : // XPropertyChangeListener
96 : : virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) throw(::com::sun::star::uno::RuntimeException);
97 : : };
98 : :
99 : :
100 : : class SpellCache :
101 : : public Flushable
102 : : {
103 : : ::com::sun::star::uno::Reference<
104 : : ::com::sun::star::linguistic2::XDictionaryListEventListener >
105 : : xFlushLstnr;
106 : : FlushListener *pFlushLstnr;
107 : :
108 : : typedef std::set< ::rtl::OUString > WordList_t;
109 : : typedef std::map< LanguageType, WordList_t > LangWordList_t;
110 : : LangWordList_t aWordLists;
111 : :
112 : : // don't allow to use copy-constructor and assignment-operator
113 : : SpellCache(const SpellCache &);
114 : : SpellCache & operator = (const SpellCache &);
115 : :
116 : : public:
117 : : SpellCache();
118 : : virtual ~SpellCache();
119 : :
120 : : // Flushable
121 : : virtual void Flush();
122 : :
123 : : void AddWord( const ::rtl::OUString& rWord, LanguageType nLang );
124 : : bool CheckWord( const ::rtl::OUString& rWord, LanguageType nLang );
125 : : };
126 : :
127 : :
128 : : } // namespace linguistic
129 : :
130 : : #endif
131 : :
132 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|