1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dicimp.hxx,v $
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>
48 ///////////////////////////////////////////////////////////////////////////
50 #define DIC_MAX_ENTRIES 30000
52 INT16
ReadDicVersion( SvStream
*pStream
, USHORT
&nLng
, BOOL
&bNeg
);
53 const String
GetDicExtension();
55 ///////////////////////////////////////////////////////////////////////////
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
;
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
);
97 BOOL
addEntry_Impl(const ::com::sun::star::uno::Reference
<
98 ::com::sun::star::linguistic2::XDictionaryEntry
> xDicEntry
,
99 BOOL bIsLoadEntries
= FALSE
);
103 DictionaryNeo(const ::rtl::OUString
&rName
, INT16 nLang
,
104 ::com::sun::star::linguistic2::DictionaryType eType
,
105 const ::rtl::OUString
&rMainURL
,
107 virtual ~DictionaryNeo();
110 virtual ::rtl::OUString SAL_CALL
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
);
118 virtual ::com::sun::star::linguistic2::DictionaryType SAL_CALL
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
126 throw(::com::sun::star::uno::RuntimeException
);
127 virtual sal_Int32 SAL_CALL
129 throw(::com::sun::star::uno::RuntimeException
);
130 virtual ::com::sun::star::lang::Locale SAL_CALL
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
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
158 throw(::com::sun::star::uno::RuntimeException
);
159 virtual void SAL_CALL
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
);
172 virtual sal_Bool SAL_CALL
174 throw(::com::sun::star::uno::RuntimeException
);
175 virtual ::rtl::OUString SAL_CALL
177 throw(::com::sun::star::uno::RuntimeException
);
178 virtual sal_Bool SAL_CALL
180 throw(::com::sun::star::uno::RuntimeException
);
181 virtual void SAL_CALL
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 ///////////////////////////////////////////////////////////////////////////
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 "="
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
);
222 DicEntry(const ::rtl::OUString
&rDicFileWord
, BOOL bIsNegativ
);
223 DicEntry(const ::rtl::OUString
&rDicWord
, BOOL bIsNegativ
,
224 const ::rtl::OUString
&rRplcText
);
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 ///////////////////////////////////////////////////////////////////////////