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>
26 #include <cppuhelper/implbase.hxx>
27 #include <comphelper/interfacecontainer3.hxx>
28 #include <i18nlangtag/lang.h>
29 #include <comphelper/errcode.hxx>
33 #define DIC_MAX_ENTRIES 30000
35 sal_Int16
ReadDicVersion( SvStream
& rStream
, LanguageType
&nLng
, bool &bNeg
, OUString
&aDicName
);
38 public ::cppu::WeakImplHelper
40 css::linguistic2::XDictionary
,
45 ::comphelper::OInterfaceContainerHelper3
<css::linguistic2::XDictionaryEventListener
> aDicEvtListeners
;
46 std::vector
< css::uno::Reference
< css::linguistic2::XDictionaryEntry
> >
50 css::linguistic2::DictionaryType eDicType
;
51 LanguageType nLanguage
;
52 sal_Int16 nDicVersion
;
58 DictionaryNeo(const DictionaryNeo
&) = delete;
59 DictionaryNeo
& operator = (const DictionaryNeo
&) = delete;
61 void launchEvent(sal_Int16 nEvent
,
62 const css::uno::Reference
< css::linguistic2::XDictionaryEntry
>& xEntry
);
64 ErrCode
loadEntries(const OUString
&rMainURL
);
65 ErrCode
saveEntries(const OUString
&rMainURL
);
66 static int cmpDicEntry(std::u16string_view rWord1
,
67 std::u16string_view rWord2
,
68 bool bSimilarOnly
= false);
69 bool seekEntry(std::u16string_view rWord
, sal_Int32
*pPos
,
70 bool bSimilarOnly
= false);
73 bool addEntry_Impl(const css::uno::Reference
< css::linguistic2::XDictionaryEntry
>& rDicEntry
,
74 bool bIsLoadEntries
= false);
77 DictionaryNeo(OUString aName
, LanguageType nLang
,
78 css::linguistic2::DictionaryType eType
,
79 const OUString
&rMainURL
,
81 virtual ~DictionaryNeo() override
;
84 virtual OUString SAL_CALL
87 setName( const OUString
& aName
) override
;
90 virtual css::linguistic2::DictionaryType SAL_CALL
91 getDictionaryType() override
;
93 setActive( sal_Bool bActivate
) override
;
94 virtual sal_Bool SAL_CALL
96 virtual sal_Int32 SAL_CALL
98 virtual css::lang::Locale SAL_CALL
100 virtual void SAL_CALL
101 setLocale( const css::lang::Locale
& aLocale
) override
;
102 virtual css::uno::Reference
<
103 css::linguistic2::XDictionaryEntry
> SAL_CALL
104 getEntry( const OUString
& aWord
) override
;
105 virtual sal_Bool SAL_CALL
106 addEntry( const css::uno::Reference
<
107 css::linguistic2::XDictionaryEntry
>& xDicEntry
) override
;
108 virtual sal_Bool SAL_CALL
109 add( const OUString
& aWord
, sal_Bool bIsNegative
,
110 const OUString
& aRplcText
) override
;
111 virtual sal_Bool SAL_CALL
112 remove( const OUString
& aWord
) override
;
113 virtual sal_Bool SAL_CALL
115 virtual css::uno::Sequence
< css::uno::Reference
< css::linguistic2::XDictionaryEntry
> > SAL_CALL
116 getEntries() override
;
117 virtual void SAL_CALL
119 virtual sal_Bool SAL_CALL
120 addDictionaryEventListener( const css::uno::Reference
< css::linguistic2::XDictionaryEventListener
>& xListener
) override
;
121 virtual sal_Bool SAL_CALL
122 removeDictionaryEventListener( const css::uno::Reference
< css::linguistic2::XDictionaryEventListener
>& xListener
) override
;
125 virtual sal_Bool SAL_CALL
126 hasLocation() override
;
127 virtual OUString SAL_CALL
128 getLocation() override
;
129 virtual sal_Bool SAL_CALL
130 isReadonly() override
;
131 virtual void SAL_CALL
133 virtual void SAL_CALL
134 storeAsURL( const OUString
& aURL
,
135 const css::uno::Sequence
< css::beans::PropertyValue
>& aArgs
) override
;
136 virtual void SAL_CALL
137 storeToURL( const OUString
& aURL
,
138 const css::uno::Sequence
< css::beans::PropertyValue
>& aArgs
) override
;
143 public cppu::WeakImplHelper
< css::linguistic2::XDictionaryEntry
>
145 OUString aDicWord
, // including hyphen positions represented by "="
146 aReplacement
; // including hyphen positions represented by "="
149 DicEntry(const DicEntry
&) = delete;
150 DicEntry
& operator = (const DicEntry
&) = delete;
152 static void splitDicFileWord(const OUString
&rDicFileWord
,
154 OUString
&rReplacement
);
157 DicEntry(const OUString
&rDicFileWord
, bool bIsNegativ
);
158 DicEntry(OUString aDicWord
, bool bIsNegativ
,
160 virtual ~DicEntry() override
;
163 virtual OUString SAL_CALL
164 getDictionaryWord() override
;
165 virtual sal_Bool SAL_CALL
166 isNegative() override
;
167 virtual OUString SAL_CALL
168 getReplacementText() override
;
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */