Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _LINGUISTIC_IPRCACHE_HXX_
21 : #define _LINGUISTIC_IPRCACHE_HXX_
22 :
23 :
24 : #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
25 : #include <cppuhelper/implbase2.hxx> // helper for implementations
26 :
27 : #include <com/sun/star/uno/Reference.h>
28 : #include <com/sun/star/document/XEventListener.hpp>
29 : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
30 : #include <com/sun/star/beans/XPropertySet.hpp>
31 : #include <com/sun/star/linguistic2/XDictionaryListEventListener.hpp>
32 : #include <com/sun/star/linguistic2/XDictionaryList.hpp>
33 :
34 : #include <rtl/string.hxx>
35 : #include <i18npool/lang.h>
36 :
37 : #include <set>
38 : #include <map>
39 :
40 : namespace linguistic
41 : {
42 :
43 :
44 0 : class Flushable
45 : {
46 : public:
47 : virtual void Flush() = 0;
48 :
49 : protected:
50 0 : ~Flushable() {}
51 : };
52 :
53 :
54 : class FlushListener :
55 : public cppu::WeakImplHelper2
56 : <
57 : ::com::sun::star::linguistic2::XDictionaryListEventListener,
58 : ::com::sun::star::beans::XPropertyChangeListener
59 : >
60 : {
61 : ::com::sun::star::uno::Reference<
62 : ::com::sun::star::linguistic2::XDictionaryList > xDicList;
63 : ::com::sun::star::uno::Reference<
64 : ::com::sun::star::beans::XPropertySet > xPropSet;
65 : Flushable *pFlushObj;
66 :
67 : // don't allow to use copy-constructor and assignment-operator
68 : FlushListener(const FlushListener &);
69 : FlushListener & operator = (const FlushListener &);
70 :
71 : public:
72 : FlushListener( Flushable *pFO );
73 : virtual ~FlushListener();
74 :
75 0 : inline void SetFlushObj( Flushable *pFO) { pFlushObj = pFO; }
76 :
77 : void SetDicList( ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionaryList > &rDL );
78 : void SetPropSet( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > &rPS );
79 :
80 : //XEventListener
81 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rSource ) throw(::com::sun::star::uno::RuntimeException);
82 :
83 : // XDictionaryListEventListener
84 : virtual void SAL_CALL processDictionaryListEvent( const ::com::sun::star::linguistic2::DictionaryListEvent& rDicListEvent ) throw(::com::sun::star::uno::RuntimeException);
85 :
86 : // XPropertyChangeListener
87 : virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) throw(::com::sun::star::uno::RuntimeException);
88 : };
89 :
90 :
91 : class SpellCache :
92 : public Flushable
93 : {
94 : ::com::sun::star::uno::Reference<
95 : ::com::sun::star::linguistic2::XDictionaryListEventListener >
96 : xFlushLstnr;
97 : FlushListener *pFlushLstnr;
98 :
99 : typedef std::set< ::rtl::OUString > WordList_t;
100 : typedef std::map< LanguageType, WordList_t > LangWordList_t;
101 : LangWordList_t aWordLists;
102 :
103 : // don't allow to use copy-constructor and assignment-operator
104 : SpellCache(const SpellCache &);
105 : SpellCache & operator = (const SpellCache &);
106 :
107 : public:
108 : SpellCache();
109 : virtual ~SpellCache();
110 :
111 : // Flushable
112 : virtual void Flush();
113 :
114 : void AddWord( const ::rtl::OUString& rWord, LanguageType nLang );
115 : bool CheckWord( const ::rtl::OUString& rWord, LanguageType nLang );
116 : };
117 :
118 :
119 : } // namespace linguistic
120 :
121 : #endif
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|