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 INCLUDED_LINGUISTIC_INC_IPRCACHE_HXX
21 : #define INCLUDED_LINGUISTIC_INC_IPRCACHE_HXX
22 :
23 : #include <cppuhelper/implbase2.hxx>
24 :
25 : #include <com/sun/star/uno/Reference.h>
26 : #include <com/sun/star/document/XEventListener.hpp>
27 : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
28 : #include <com/sun/star/beans/XPropertySet.hpp>
29 : #include <com/sun/star/linguistic2/XDictionaryListEventListener.hpp>
30 : #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
31 : #include <com/sun/star/linguistic2/XLinguProperties.hpp>
32 :
33 : #include <rtl/string.hxx>
34 : #include <i18nlangtag/lang.h>
35 :
36 : #include <set>
37 : #include <map>
38 :
39 : namespace linguistic
40 : {
41 :
42 :
43 27 : class Flushable
44 : {
45 : public:
46 : virtual void Flush() = 0;
47 :
48 : protected:
49 24 : ~Flushable() {}
50 : };
51 :
52 :
53 : class FlushListener :
54 : public cppu::WeakImplHelper2
55 : <
56 : ::com::sun::star::linguistic2::XDictionaryListEventListener,
57 : ::com::sun::star::beans::XPropertyChangeListener
58 : >
59 : {
60 : ::com::sun::star::uno::Reference<
61 : ::com::sun::star::linguistic2::XSearchableDictionaryList > xDicList;
62 : ::com::sun::star::uno::Reference<
63 : ::com::sun::star::linguistic2::XLinguProperties > xPropSet;
64 : Flushable *pFlushObj;
65 :
66 : FlushListener(const FlushListener &) SAL_DELETED_FUNCTION;
67 : FlushListener & operator = (const FlushListener &) SAL_DELETED_FUNCTION;
68 :
69 : public:
70 : FlushListener( Flushable *pFO );
71 : virtual ~FlushListener();
72 :
73 27 : inline void SetFlushObj( Flushable *pFO) { pFlushObj = pFO; }
74 :
75 : void SetDicList( ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSearchableDictionaryList > &rDL );
76 : void SetPropSet( ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XLinguProperties > &rPS );
77 :
78 : //XEventListener
79 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rSource ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 :
81 : // XDictionaryListEventListener
82 : virtual void SAL_CALL processDictionaryListEvent( const ::com::sun::star::linguistic2::DictionaryListEvent& rDicListEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 :
84 : // XPropertyChangeListener
85 : virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
86 : };
87 :
88 :
89 : class SpellCache :
90 : public Flushable
91 : {
92 : ::com::sun::star::uno::Reference<
93 : ::com::sun::star::linguistic2::XDictionaryListEventListener >
94 : xFlushLstnr;
95 : FlushListener *pFlushLstnr;
96 :
97 : typedef std::set< OUString > WordList_t;
98 : typedef std::map< LanguageType, WordList_t > LangWordList_t;
99 : LangWordList_t aWordLists;
100 :
101 : SpellCache(const SpellCache &) SAL_DELETED_FUNCTION;
102 : SpellCache & operator = (const SpellCache &) SAL_DELETED_FUNCTION;
103 :
104 : public:
105 : SpellCache();
106 : virtual ~SpellCache();
107 :
108 : // Flushable
109 : virtual void Flush() SAL_OVERRIDE;
110 :
111 : void AddWord( const OUString& rWord, LanguageType nLang );
112 : bool CheckWord( const OUString& rWord, LanguageType nLang );
113 : };
114 :
115 :
116 : } // namespace linguistic
117 :
118 : #endif
119 :
120 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|