calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / linguistic / source / dicimp.hxx
blob4ab0025799eade6f461400105daac8a9f7da859c
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 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>
31 #include "defs.hxx"
33 #define DIC_MAX_ENTRIES 30000
35 sal_Int16 ReadDicVersion( SvStream& rStream, LanguageType &nLng, bool &bNeg, OUString &aDicName );
37 class DictionaryNeo :
38 public ::cppu::WeakImplHelper
40 css::linguistic2::XDictionary,
41 css::frame::XStorable
45 ::comphelper::OInterfaceContainerHelper3<css::linguistic2::XDictionaryEventListener> aDicEvtListeners;
46 std::vector< css::uno::Reference< css::linguistic2::XDictionaryEntry > >
47 aEntries;
48 OUString aDicName;
49 OUString aMainURL;
50 css::linguistic2::DictionaryType eDicType;
51 LanguageType nLanguage;
52 sal_Int16 nDicVersion;
53 bool bNeedEntries;
54 bool bIsModified;
55 bool bIsActive;
56 bool bIsReadonly;
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);
71 bool isSorted();
73 bool addEntry_Impl(const css::uno::Reference< css::linguistic2::XDictionaryEntry >& rDicEntry,
74 bool bIsLoadEntries = false);
76 public:
77 DictionaryNeo(OUString aName, LanguageType nLang,
78 css::linguistic2::DictionaryType eType,
79 const OUString &rMainURL,
80 bool bWriteable );
81 virtual ~DictionaryNeo() override;
83 // XNamed
84 virtual OUString SAL_CALL
85 getName() override;
86 virtual void SAL_CALL
87 setName( const OUString& aName ) override;
89 // XDictionary
90 virtual css::linguistic2::DictionaryType SAL_CALL
91 getDictionaryType() override;
92 virtual void SAL_CALL
93 setActive( sal_Bool bActivate ) override;
94 virtual sal_Bool SAL_CALL
95 isActive() override;
96 virtual sal_Int32 SAL_CALL
97 getCount() override;
98 virtual css::lang::Locale SAL_CALL
99 getLocale() override;
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
114 isFull() override;
115 virtual css::uno::Sequence< css::uno::Reference< css::linguistic2::XDictionaryEntry > > SAL_CALL
116 getEntries() override;
117 virtual void SAL_CALL
118 clear() override;
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;
124 // XStorable
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
132 store() override;
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;
142 class DicEntry :
143 public cppu::WeakImplHelper< css::linguistic2::XDictionaryEntry >
145 OUString aDicWord, // including hyphen positions represented by "="
146 aReplacement; // including hyphen positions represented by "="
147 bool bIsNegativ;
149 DicEntry(const DicEntry &) = delete;
150 DicEntry & operator = (const DicEntry &) = delete;
152 static void splitDicFileWord(const OUString &rDicFileWord,
153 OUString &rDicWord,
154 OUString &rReplacement);
156 public:
157 DicEntry(const OUString &rDicFileWord, bool bIsNegativ);
158 DicEntry(OUString aDicWord, bool bIsNegativ,
159 OUString aRplcText);
160 virtual ~DicEntry() override;
162 // XDictionaryEntry
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;
172 #endif
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */