1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_LINGUISTIC_SOURCE_DICIMP_HXX
21 #define INCLUDED_LINGUISTIC_SOURCE_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 <cppuhelper/implbase2.hxx>
28 #include <cppuhelper/implbase1.hxx>
29 #include <cppuhelper/interfacecontainer.h>
30 #include <tools/stream.hxx>
33 #include "linguistic/misc.hxx"
35 #define DIC_MAX_ENTRIES 30000
37 sal_Int16
ReadDicVersion( SvStreamPtr
&rpStream
, sal_uInt16
&nLng
, bool &bNeg
);
40 public ::cppu::WeakImplHelper2
42 ::com::sun::star::linguistic2::XDictionary
,
43 ::com::sun::star::frame::XStorable
47 ::cppu::OInterfaceContainerHelper aDicEvtListeners
;
48 ::com::sun::star::uno::Sequence
<
49 ::com::sun::star::uno::Reference
<
50 ::com::sun::star::linguistic2::XDictionaryEntry
> > aEntries
;
53 ::com::sun::star::linguistic2::DictionaryType eDicType
;
56 sal_Int16 nDicVersion
;
62 DictionaryNeo(const DictionaryNeo
&) SAL_DELETED_FUNCTION
;
63 DictionaryNeo
& operator = (const DictionaryNeo
&) SAL_DELETED_FUNCTION
;
65 void launchEvent(sal_Int16 nEvent
,
66 ::com::sun::star::uno::Reference
<
67 ::com::sun::star::linguistic2::XDictionaryEntry
> xEntry
);
69 sal_uLong
loadEntries(const OUString
&rMainURL
);
70 sal_uLong
saveEntries(const OUString
&rMainURL
);
71 static int cmpDicEntry(const OUString
&rWord1
,
72 const OUString
&rWord2
,
73 bool bSimilarOnly
= false);
74 bool seekEntry(const OUString
&rWord
, sal_Int32
*pPos
,
75 bool bSimilarOnly
= false);
78 bool addEntry_Impl(const ::com::sun::star::uno::Reference
<
79 ::com::sun::star::linguistic2::XDictionaryEntry
>& rDicEntry
,
80 bool bIsLoadEntries
= false);
83 DictionaryNeo(const OUString
&rName
, sal_Int16 nLang
,
84 ::com::sun::star::linguistic2::DictionaryType eType
,
85 const OUString
&rMainURL
,
87 virtual ~DictionaryNeo();
90 virtual OUString SAL_CALL
92 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
94 setName( const OUString
& aName
)
95 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
98 virtual ::com::sun::star::linguistic2::DictionaryType SAL_CALL
100 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
101 virtual void SAL_CALL
102 setActive( sal_Bool bActivate
)
103 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
104 virtual sal_Bool SAL_CALL
106 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
107 virtual sal_Int32 SAL_CALL
109 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
110 virtual ::com::sun::star::lang::Locale SAL_CALL
112 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
113 virtual void SAL_CALL
114 setLocale( const ::com::sun::star::lang::Locale
& aLocale
)
115 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
116 virtual ::com::sun::star::uno::Reference
<
117 ::com::sun::star::linguistic2::XDictionaryEntry
> SAL_CALL
118 getEntry( const OUString
& aWord
)
119 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
120 virtual sal_Bool SAL_CALL
121 addEntry( const ::com::sun::star::uno::Reference
<
122 ::com::sun::star::linguistic2::XDictionaryEntry
>& xDicEntry
)
123 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
124 virtual sal_Bool SAL_CALL
125 add( const OUString
& aWord
, sal_Bool bIsNegative
,
126 const OUString
& aRplcText
)
127 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
128 virtual sal_Bool SAL_CALL
129 remove( const OUString
& aWord
)
130 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
131 virtual sal_Bool SAL_CALL
133 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
134 virtual ::com::sun::star::uno::Sequence
<
135 ::com::sun::star::uno::Reference
<
136 ::com::sun::star::linguistic2::XDictionaryEntry
> > SAL_CALL
138 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
139 virtual void SAL_CALL
141 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
142 virtual sal_Bool SAL_CALL
143 addDictionaryEventListener( const ::com::sun::star::uno::Reference
<
144 ::com::sun::star::linguistic2::XDictionaryEventListener
>& xListener
)
145 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
146 virtual sal_Bool SAL_CALL
147 removeDictionaryEventListener( const ::com::sun::star::uno::Reference
<
148 ::com::sun::star::linguistic2::XDictionaryEventListener
>& xListener
)
149 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
152 virtual sal_Bool SAL_CALL
154 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
155 virtual OUString SAL_CALL
157 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
158 virtual sal_Bool SAL_CALL
160 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
161 virtual void SAL_CALL
163 throw(::com::sun::star::io::IOException
,
164 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
165 virtual void SAL_CALL
166 storeAsURL( const OUString
& aURL
,
167 const ::com::sun::star::uno::Sequence
<
168 ::com::sun::star::beans::PropertyValue
>& aArgs
)
169 throw(::com::sun::star::io::IOException
,
170 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
171 virtual void SAL_CALL
172 storeToURL( const OUString
& aURL
,
173 const ::com::sun::star::uno::Sequence
<
174 ::com::sun::star::beans::PropertyValue
>& aArgs
)
175 throw(::com::sun::star::io::IOException
,
176 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
182 public cppu::WeakImplHelper1
184 ::com::sun::star::linguistic2::XDictionaryEntry
187 OUString aDicWord
, // including hyphen positions represented by "="
188 aReplacement
; // including hyphen positions represented by "="
191 DicEntry(const DicEntry
&) SAL_DELETED_FUNCTION
;
192 DicEntry
& operator = (const DicEntry
&) SAL_DELETED_FUNCTION
;
194 static void splitDicFileWord(const OUString
&rDicFileWord
,
196 OUString
&rReplacement
);
199 DicEntry(const OUString
&rDicFileWord
, bool bIsNegativ
);
200 DicEntry(const OUString
&rDicWord
, bool bIsNegativ
,
201 const OUString
&rRplcText
);
205 virtual OUString SAL_CALL
206 getDictionaryWord() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
207 virtual sal_Bool SAL_CALL
208 isNegative() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
209 virtual OUString SAL_CALL
210 getReplacementText() throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */