Update ooo320-m1
[ooovba.git] / linguistic / source / dicimp.hxx
blobab60c94f97310bb5f4ef780e9b78fa7b4f9e633e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dicimp.hxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _LINGUISTIC_DICIMP_HXX_
32 #define _LINGUISTIC_DICIMP_HXX_
34 #include <com/sun/star/linguistic2/XDictionary.hpp>
35 #include <com/sun/star/frame/XStorable.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
39 #include <cppuhelper/implbase2.hxx> // helper for implementations
40 #include <cppuhelper/implbase1.hxx> // helper for implementations
41 #include <cppuhelper/interfacecontainer.h>
42 #include <tools/string.hxx>
43 #include <tools/stream.hxx>
45 #include "misc.hxx"
48 ///////////////////////////////////////////////////////////////////////////
50 #define DIC_MAX_ENTRIES 30000
52 INT16 ReadDicVersion( SvStream *pStream, USHORT &nLng, BOOL &bNeg );
53 const String GetDicExtension();
55 ///////////////////////////////////////////////////////////////////////////
57 class DictionaryNeo :
58 public ::cppu::WeakImplHelper2
60 ::com::sun::star::linguistic2::XDictionary,
61 ::com::sun::star::frame::XStorable
65 ::cppu::OInterfaceContainerHelper aDicEvtListeners;
66 ::com::sun::star::uno::Sequence<
67 ::com::sun::star::uno::Reference<
68 ::com::sun::star::linguistic2::XDictionaryEntry > > aEntries;
69 ::rtl::OUString aDicName;
70 ::rtl::OUString aMainURL;
71 ::com::sun::star::linguistic2::DictionaryType eDicType;
72 INT16 nCount;
73 INT16 nLanguage;
74 INT16 nDicVersion;
75 BOOL bNeedEntries;
76 BOOL bIsModified;
77 BOOL bIsActive;
78 BOOL bIsReadonly;
80 // disallow copy-constructor and assignment-operator for now
81 DictionaryNeo(const DictionaryNeo &);
82 DictionaryNeo & operator = (const DictionaryNeo &);
84 void launchEvent(INT16 nEvent,
85 ::com::sun::star::uno::Reference<
86 ::com::sun::star::linguistic2::XDictionaryEntry > xEntry);
88 ULONG loadEntries(const ::rtl::OUString &rMainURL);
89 ULONG saveEntries(const ::rtl::OUString &rMainURL);
90 int cmpDicEntry(const ::rtl::OUString &rWord1,
91 const ::rtl::OUString &rWord2,
92 BOOL bSimilarOnly = FALSE);
93 BOOL seekEntry(const ::rtl::OUString &rWord, INT32 *pPos,
94 BOOL bSimilarOnly = FALSE);
95 BOOL isSorted();
97 BOOL addEntry_Impl(const ::com::sun::star::uno::Reference<
98 ::com::sun::star::linguistic2::XDictionaryEntry > xDicEntry,
99 BOOL bIsLoadEntries = FALSE);
101 public:
102 DictionaryNeo();
103 DictionaryNeo(const ::rtl::OUString &rName, INT16 nLang,
104 ::com::sun::star::linguistic2::DictionaryType eType,
105 const ::rtl::OUString &rMainURL,
106 BOOL bWriteable );
107 virtual ~DictionaryNeo();
109 // XNamed
110 virtual ::rtl::OUString SAL_CALL
111 getName()
112 throw(::com::sun::star::uno::RuntimeException);
113 virtual void SAL_CALL
114 setName( const ::rtl::OUString& aName )
115 throw(::com::sun::star::uno::RuntimeException);
117 // XDictionary
118 virtual ::com::sun::star::linguistic2::DictionaryType SAL_CALL
119 getDictionaryType()
120 throw(::com::sun::star::uno::RuntimeException);
121 virtual void SAL_CALL
122 setActive( sal_Bool bActivate )
123 throw(::com::sun::star::uno::RuntimeException);
124 virtual sal_Bool SAL_CALL
125 isActive()
126 throw(::com::sun::star::uno::RuntimeException);
127 virtual sal_Int32 SAL_CALL
128 getCount()
129 throw(::com::sun::star::uno::RuntimeException);
130 virtual ::com::sun::star::lang::Locale SAL_CALL
131 getLocale()
132 throw(::com::sun::star::uno::RuntimeException);
133 virtual void SAL_CALL
134 setLocale( const ::com::sun::star::lang::Locale& aLocale )
135 throw(::com::sun::star::uno::RuntimeException);
136 virtual ::com::sun::star::uno::Reference<
137 ::com::sun::star::linguistic2::XDictionaryEntry > SAL_CALL
138 getEntry( const ::rtl::OUString& aWord )
139 throw(::com::sun::star::uno::RuntimeException);
140 virtual sal_Bool SAL_CALL
141 addEntry( const ::com::sun::star::uno::Reference<
142 ::com::sun::star::linguistic2::XDictionaryEntry >& xDicEntry )
143 throw(::com::sun::star::uno::RuntimeException);
144 virtual sal_Bool SAL_CALL
145 add( const ::rtl::OUString& aWord, sal_Bool bIsNegative,
146 const ::rtl::OUString& aRplcText )
147 throw(::com::sun::star::uno::RuntimeException);
148 virtual sal_Bool SAL_CALL
149 remove( const ::rtl::OUString& aWord )
150 throw(::com::sun::star::uno::RuntimeException);
151 virtual sal_Bool SAL_CALL
152 isFull()
153 throw(::com::sun::star::uno::RuntimeException);
154 virtual ::com::sun::star::uno::Sequence<
155 ::com::sun::star::uno::Reference<
156 ::com::sun::star::linguistic2::XDictionaryEntry > > SAL_CALL
157 getEntries()
158 throw(::com::sun::star::uno::RuntimeException);
159 virtual void SAL_CALL
160 clear()
161 throw(::com::sun::star::uno::RuntimeException);
162 virtual sal_Bool SAL_CALL
163 addDictionaryEventListener( const ::com::sun::star::uno::Reference<
164 ::com::sun::star::linguistic2::XDictionaryEventListener >& xListener )
165 throw(::com::sun::star::uno::RuntimeException);
166 virtual sal_Bool SAL_CALL
167 removeDictionaryEventListener( const ::com::sun::star::uno::Reference<
168 ::com::sun::star::linguistic2::XDictionaryEventListener >& xListener )
169 throw(::com::sun::star::uno::RuntimeException);
171 // XStorable
172 virtual sal_Bool SAL_CALL
173 hasLocation()
174 throw(::com::sun::star::uno::RuntimeException);
175 virtual ::rtl::OUString SAL_CALL
176 getLocation()
177 throw(::com::sun::star::uno::RuntimeException);
178 virtual sal_Bool SAL_CALL
179 isReadonly()
180 throw(::com::sun::star::uno::RuntimeException);
181 virtual void SAL_CALL
182 store()
183 throw(::com::sun::star::io::IOException,
184 ::com::sun::star::uno::RuntimeException);
185 virtual void SAL_CALL
186 storeAsURL( const ::rtl::OUString& aURL,
187 const ::com::sun::star::uno::Sequence<
188 ::com::sun::star::beans::PropertyValue >& aArgs )
189 throw(::com::sun::star::io::IOException,
190 ::com::sun::star::uno::RuntimeException);
191 virtual void SAL_CALL
192 storeToURL( const ::rtl::OUString& aURL,
193 const ::com::sun::star::uno::Sequence<
194 ::com::sun::star::beans::PropertyValue >& aArgs )
195 throw(::com::sun::star::io::IOException,
196 ::com::sun::star::uno::RuntimeException);
200 ///////////////////////////////////////////////////////////////////////////
202 class DicEntry :
203 public cppu::WeakImplHelper1
205 ::com::sun::star::linguistic2::XDictionaryEntry
208 ::rtl::OUString aDicWord, // including hyphen positions represented by "="
209 aReplacement; // including hyphen positions represented by "="
210 BOOL bIsNegativ;
212 // disallow copy-constructor and assignment-operator for now
213 DicEntry(const DicEntry &);
214 DicEntry & operator = (const DicEntry &);
216 void splitDicFileWord(const ::rtl::OUString &rDicFileWord,
217 ::rtl::OUString &rDicWord,
218 ::rtl::OUString &rReplacement);
220 public:
221 DicEntry();
222 DicEntry(const ::rtl::OUString &rDicFileWord, BOOL bIsNegativ);
223 DicEntry(const ::rtl::OUString &rDicWord, BOOL bIsNegativ,
224 const ::rtl::OUString &rRplcText);
225 virtual ~DicEntry();
227 // XDictionaryEntry
228 virtual ::rtl::OUString SAL_CALL
229 getDictionaryWord() throw(::com::sun::star::uno::RuntimeException);
230 virtual sal_Bool SAL_CALL
231 isNegative() throw(::com::sun::star::uno::RuntimeException);
232 virtual ::rtl::OUString SAL_CALL
233 getReplacementText() throw(::com::sun::star::uno::RuntimeException);
237 ///////////////////////////////////////////////////////////////////////////
239 #endif