Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / linguistic / source / dicimp.hxx
blob012f3fdd656ceff88a841b0b55b326124a1d04d5
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_DICIMP_HXX_
21 #define _LINGUISTIC_DICIMP_HXX_
23 #include <com/sun/star/linguistic2/XDictionary.hpp>
24 #include <com/sun/star/frame/XStorable.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
28 #include <cppuhelper/implbase2.hxx> // helper for implementations
29 #include <cppuhelper/implbase1.hxx> // helper for implementations
30 #include <cppuhelper/interfacecontainer.h>
31 #include <tools/string.hxx>
32 #include <tools/stream.hxx>
34 #include "defs.hxx"
35 #include "linguistic/misc.hxx"
37 #define DIC_MAX_ENTRIES 30000
39 sal_Int16 ReadDicVersion( SvStreamPtr &rpStream, sal_uInt16 &nLng, sal_Bool &bNeg );
41 class DictionaryNeo :
42 public ::cppu::WeakImplHelper2
44 ::com::sun::star::linguistic2::XDictionary,
45 ::com::sun::star::frame::XStorable
49 ::cppu::OInterfaceContainerHelper aDicEvtListeners;
50 ::com::sun::star::uno::Sequence<
51 ::com::sun::star::uno::Reference<
52 ::com::sun::star::linguistic2::XDictionaryEntry > > aEntries;
53 ::rtl::OUString aDicName;
54 ::rtl::OUString aMainURL;
55 ::com::sun::star::linguistic2::DictionaryType eDicType;
56 sal_Int16 nCount;
57 sal_Int16 nLanguage;
58 sal_Int16 nDicVersion;
59 sal_Bool bNeedEntries;
60 sal_Bool bIsModified;
61 sal_Bool bIsActive;
62 sal_Bool bIsReadonly;
64 // disallow copy-constructor and assignment-operator for now
65 DictionaryNeo(const DictionaryNeo &);
66 DictionaryNeo & operator = (const DictionaryNeo &);
68 void launchEvent(sal_Int16 nEvent,
69 ::com::sun::star::uno::Reference<
70 ::com::sun::star::linguistic2::XDictionaryEntry > xEntry);
72 sal_uLong loadEntries(const ::rtl::OUString &rMainURL);
73 sal_uLong saveEntries(const ::rtl::OUString &rMainURL);
74 int cmpDicEntry(const ::rtl::OUString &rWord1,
75 const ::rtl::OUString &rWord2,
76 sal_Bool bSimilarOnly = sal_False);
77 sal_Bool seekEntry(const ::rtl::OUString &rWord, sal_Int32 *pPos,
78 sal_Bool bSimilarOnly = sal_False);
79 sal_Bool isSorted();
81 sal_Bool addEntry_Impl(const ::com::sun::star::uno::Reference<
82 ::com::sun::star::linguistic2::XDictionaryEntry > xDicEntry,
83 sal_Bool bIsLoadEntries = sal_False);
85 public:
86 DictionaryNeo();
87 DictionaryNeo(const ::rtl::OUString &rName, sal_Int16 nLang,
88 ::com::sun::star::linguistic2::DictionaryType eType,
89 const ::rtl::OUString &rMainURL,
90 sal_Bool bWriteable );
91 virtual ~DictionaryNeo();
93 // XNamed
94 virtual ::rtl::OUString SAL_CALL
95 getName()
96 throw(::com::sun::star::uno::RuntimeException);
97 virtual void SAL_CALL
98 setName( const ::rtl::OUString& aName )
99 throw(::com::sun::star::uno::RuntimeException);
101 // XDictionary
102 virtual ::com::sun::star::linguistic2::DictionaryType SAL_CALL
103 getDictionaryType()
104 throw(::com::sun::star::uno::RuntimeException);
105 virtual void SAL_CALL
106 setActive( sal_Bool bActivate )
107 throw(::com::sun::star::uno::RuntimeException);
108 virtual sal_Bool SAL_CALL
109 isActive()
110 throw(::com::sun::star::uno::RuntimeException);
111 virtual sal_Int32 SAL_CALL
112 getCount()
113 throw(::com::sun::star::uno::RuntimeException);
114 virtual ::com::sun::star::lang::Locale SAL_CALL
115 getLocale()
116 throw(::com::sun::star::uno::RuntimeException);
117 virtual void SAL_CALL
118 setLocale( const ::com::sun::star::lang::Locale& aLocale )
119 throw(::com::sun::star::uno::RuntimeException);
120 virtual ::com::sun::star::uno::Reference<
121 ::com::sun::star::linguistic2::XDictionaryEntry > SAL_CALL
122 getEntry( const ::rtl::OUString& aWord )
123 throw(::com::sun::star::uno::RuntimeException);
124 virtual sal_Bool SAL_CALL
125 addEntry( const ::com::sun::star::uno::Reference<
126 ::com::sun::star::linguistic2::XDictionaryEntry >& xDicEntry )
127 throw(::com::sun::star::uno::RuntimeException);
128 virtual sal_Bool SAL_CALL
129 add( const ::rtl::OUString& aWord, sal_Bool bIsNegative,
130 const ::rtl::OUString& aRplcText )
131 throw(::com::sun::star::uno::RuntimeException);
132 virtual sal_Bool SAL_CALL
133 remove( const ::rtl::OUString& aWord )
134 throw(::com::sun::star::uno::RuntimeException);
135 virtual sal_Bool SAL_CALL
136 isFull()
137 throw(::com::sun::star::uno::RuntimeException);
138 virtual ::com::sun::star::uno::Sequence<
139 ::com::sun::star::uno::Reference<
140 ::com::sun::star::linguistic2::XDictionaryEntry > > SAL_CALL
141 getEntries()
142 throw(::com::sun::star::uno::RuntimeException);
143 virtual void SAL_CALL
144 clear()
145 throw(::com::sun::star::uno::RuntimeException);
146 virtual sal_Bool SAL_CALL
147 addDictionaryEventListener( const ::com::sun::star::uno::Reference<
148 ::com::sun::star::linguistic2::XDictionaryEventListener >& xListener )
149 throw(::com::sun::star::uno::RuntimeException);
150 virtual sal_Bool SAL_CALL
151 removeDictionaryEventListener( const ::com::sun::star::uno::Reference<
152 ::com::sun::star::linguistic2::XDictionaryEventListener >& xListener )
153 throw(::com::sun::star::uno::RuntimeException);
155 // XStorable
156 virtual sal_Bool SAL_CALL
157 hasLocation()
158 throw(::com::sun::star::uno::RuntimeException);
159 virtual ::rtl::OUString SAL_CALL
160 getLocation()
161 throw(::com::sun::star::uno::RuntimeException);
162 virtual sal_Bool SAL_CALL
163 isReadonly()
164 throw(::com::sun::star::uno::RuntimeException);
165 virtual void SAL_CALL
166 store()
167 throw(::com::sun::star::io::IOException,
168 ::com::sun::star::uno::RuntimeException);
169 virtual void SAL_CALL
170 storeAsURL( const ::rtl::OUString& aURL,
171 const ::com::sun::star::uno::Sequence<
172 ::com::sun::star::beans::PropertyValue >& aArgs )
173 throw(::com::sun::star::io::IOException,
174 ::com::sun::star::uno::RuntimeException);
175 virtual void SAL_CALL
176 storeToURL( const ::rtl::OUString& aURL,
177 const ::com::sun::star::uno::Sequence<
178 ::com::sun::star::beans::PropertyValue >& aArgs )
179 throw(::com::sun::star::io::IOException,
180 ::com::sun::star::uno::RuntimeException);
185 class DicEntry :
186 public cppu::WeakImplHelper1
188 ::com::sun::star::linguistic2::XDictionaryEntry
191 ::rtl::OUString aDicWord, // including hyphen positions represented by "="
192 aReplacement; // including hyphen positions represented by "="
193 sal_Bool bIsNegativ;
195 // disallow copy-constructor and assignment-operator for now
196 DicEntry(const DicEntry &);
197 DicEntry & operator = (const DicEntry &);
199 void splitDicFileWord(const ::rtl::OUString &rDicFileWord,
200 ::rtl::OUString &rDicWord,
201 ::rtl::OUString &rReplacement);
203 public:
204 DicEntry(const ::rtl::OUString &rDicFileWord, sal_Bool bIsNegativ);
205 DicEntry(const ::rtl::OUString &rDicWord, sal_Bool bIsNegativ,
206 const ::rtl::OUString &rRplcText);
207 virtual ~DicEntry();
209 // XDictionaryEntry
210 virtual ::rtl::OUString SAL_CALL
211 getDictionaryWord() throw(::com::sun::star::uno::RuntimeException);
212 virtual sal_Bool SAL_CALL
213 isNegative() throw(::com::sun::star::uno::RuntimeException);
214 virtual ::rtl::OUString SAL_CALL
215 getReplacementText() throw(::com::sun::star::uno::RuntimeException);
220 #endif
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */