Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <tools/shl.hxx>
21 : #include <unotools/searchopt.hxx>
22 : #include <com/sun/star/i18n/TransliterationModules.hpp>
23 : #include <cuires.hrc>
24 : #include <dialmgr.hxx>
25 : #include <optjsearch.hxx>
26 :
27 : using namespace com::sun::star::i18n;
28 :
29 :
30 :
31 0 : SvxJSearchOptionsPage::SvxJSearchOptionsPage( Window* pParent, const SfxItemSet& rSet ) :
32 0 : SfxTabPage( pParent, "OptJSearchPage", "cui/ui/optjsearchpage.ui", rSet )
33 : {
34 0 : get( m_pMatchCase, "matchcase");
35 0 : get( m_pMatchFullHalfWidth, "matchfullhalfwidth");
36 0 : get( m_pMatchHiraganaKatakana, "matchhiraganakatakana");
37 0 : get( m_pMatchContractions, "matchcontractions");
38 0 : get( m_pMatchMinusDashChoon, "matchminusdashchoon");
39 0 : get( m_pMatchRepeatCharMarks, "matchrepeatcharmarks");
40 0 : get( m_pMatchVariantFormKanji, "matchvariantformkanji");
41 0 : get( m_pMatchOldKanaForms, "matcholdkanaforms");
42 0 : get( m_pMatchDiziDuzu, "matchdiziduzu");
43 0 : get( m_pMatchBavaHafa, "matchbavahafa");
44 0 : get( m_pMatchTsithichiDhizi, "matchtsithichidhizi");
45 0 : get( m_pMatchHyuiyuByuvyu, "matchhyuiyubyuvyu");
46 0 : get( m_pMatchSesheZeje, "matchseshezeje");
47 0 : get( m_pMatchIaiya, "matchiaiya");
48 0 : get( m_pMatchKiku, "matchkiku");
49 0 : get( m_pMatchProlongedSoundMark, "matchprolongedsoundmark");
50 :
51 0 : get( m_pIgnorePunctuation, "ignorepunctuation");
52 0 : get( m_pIgnoreWhitespace, "ignorewhitespace");
53 0 : get( m_pIgnoreMiddleDot, "ignoremiddledot");
54 :
55 0 : bSaveOptions = sal_True;
56 0 : nTransliterationFlags = 0x00000000;
57 0 : }
58 :
59 :
60 0 : SvxJSearchOptionsPage::~SvxJSearchOptionsPage()
61 : {
62 0 : }
63 :
64 :
65 0 : SfxTabPage* SvxJSearchOptionsPage::Create( Window* pParent, const SfxItemSet& rSet )
66 : {
67 0 : return new SvxJSearchOptionsPage( pParent, rSet );
68 : }
69 :
70 :
71 0 : void SvxJSearchOptionsPage::SetTransliterationFlags( sal_Int32 nSettings )
72 : {
73 0 : sal_Bool bVal = 0 != (nSettings & TransliterationModules_IGNORE_CASE);
74 0 : m_pMatchCase ->Check( bVal ); //! treat as equal uppercase/lowercase
75 0 : bVal = 0 != (nSettings & TransliterationModules_IGNORE_WIDTH);
76 0 : m_pMatchFullHalfWidth ->Check( bVal );
77 0 : bVal = 0 != (nSettings & TransliterationModules_IGNORE_KANA);
78 0 : m_pMatchHiraganaKatakana ->Check( bVal );
79 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreSize_ja_JP);
80 0 : m_pMatchContractions ->Check( bVal );
81 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreMinusSign_ja_JP);
82 0 : m_pMatchMinusDashChoon ->Check( bVal );
83 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreIterationMark_ja_JP);
84 0 : m_pMatchRepeatCharMarks ->Check( bVal );
85 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreTraditionalKanji_ja_JP);
86 0 : m_pMatchVariantFormKanji ->Check( bVal );
87 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreTraditionalKana_ja_JP);
88 0 : m_pMatchOldKanaForms ->Check( bVal );
89 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreZiZu_ja_JP);
90 0 : m_pMatchDiziDuzu ->Check( bVal );
91 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreBaFa_ja_JP);
92 0 : m_pMatchBavaHafa ->Check( bVal );
93 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreTiJi_ja_JP);
94 0 : m_pMatchTsithichiDhizi ->Check( bVal );
95 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreHyuByu_ja_JP);
96 0 : m_pMatchHyuiyuByuvyu ->Check( bVal );
97 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreSeZe_ja_JP);
98 0 : m_pMatchSesheZeje ->Check( bVal );
99 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreIandEfollowedByYa_ja_JP);
100 0 : m_pMatchIaiya ->Check( bVal );
101 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreKiKuFollowedBySa_ja_JP);
102 0 : m_pMatchKiku ->Check( bVal );
103 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreSeparator_ja_JP);
104 0 : m_pIgnorePunctuation ->Check( bVal );
105 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreSpace_ja_JP);
106 0 : m_pIgnoreWhitespace ->Check( bVal );
107 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreProlongedSoundMark_ja_JP);
108 0 : m_pMatchProlongedSoundMark->Check( bVal );
109 0 : bVal = 0 != (nSettings & TransliterationModules_ignoreMiddleDot_ja_JP);
110 0 : m_pIgnoreMiddleDot ->Check( bVal );
111 :
112 0 : nTransliterationFlags = nSettings;
113 0 : }
114 :
115 :
116 0 : sal_Int32 SvxJSearchOptionsPage::GetTransliterationFlags_Impl()
117 : {
118 0 : sal_Int32 nTmp = 0;
119 0 : if (m_pMatchCase->IsChecked()) //! treat as equal uppercase/lowercase
120 0 : nTmp |= TransliterationModules_IGNORE_CASE;
121 0 : if (m_pMatchFullHalfWidth->IsChecked())
122 0 : nTmp |= TransliterationModules_IGNORE_WIDTH;
123 0 : if (m_pMatchHiraganaKatakana->IsChecked())
124 0 : nTmp |= TransliterationModules_IGNORE_KANA;
125 0 : if (m_pMatchContractions->IsChecked())
126 0 : nTmp |= TransliterationModules_ignoreSize_ja_JP;
127 0 : if (m_pMatchMinusDashChoon->IsChecked())
128 0 : nTmp |= TransliterationModules_ignoreMinusSign_ja_JP;
129 0 : if (m_pMatchRepeatCharMarks->IsChecked())
130 0 : nTmp |= TransliterationModules_ignoreIterationMark_ja_JP;
131 0 : if (m_pMatchVariantFormKanji->IsChecked())
132 0 : nTmp |= TransliterationModules_ignoreTraditionalKanji_ja_JP;
133 0 : if (m_pMatchOldKanaForms->IsChecked())
134 0 : nTmp |= TransliterationModules_ignoreTraditionalKana_ja_JP;
135 0 : if (m_pMatchDiziDuzu->IsChecked())
136 0 : nTmp |= TransliterationModules_ignoreZiZu_ja_JP;
137 0 : if (m_pMatchBavaHafa->IsChecked())
138 0 : nTmp |= TransliterationModules_ignoreBaFa_ja_JP;
139 0 : if (m_pMatchTsithichiDhizi->IsChecked())
140 0 : nTmp |= TransliterationModules_ignoreTiJi_ja_JP;
141 0 : if (m_pMatchHyuiyuByuvyu->IsChecked())
142 0 : nTmp |= TransliterationModules_ignoreHyuByu_ja_JP;
143 0 : if (m_pMatchSesheZeje->IsChecked())
144 0 : nTmp |= TransliterationModules_ignoreSeZe_ja_JP;
145 0 : if (m_pMatchIaiya->IsChecked())
146 0 : nTmp |= TransliterationModules_ignoreIandEfollowedByYa_ja_JP;
147 0 : if (m_pMatchKiku->IsChecked())
148 0 : nTmp |= TransliterationModules_ignoreKiKuFollowedBySa_ja_JP;
149 0 : if (m_pIgnorePunctuation->IsChecked())
150 0 : nTmp |= TransliterationModules_ignoreSeparator_ja_JP;
151 0 : if (m_pIgnoreWhitespace->IsChecked())
152 0 : nTmp |= TransliterationModules_ignoreSpace_ja_JP;
153 0 : if (m_pMatchProlongedSoundMark->IsChecked())
154 0 : nTmp |= TransliterationModules_ignoreProlongedSoundMark_ja_JP;
155 0 : if (m_pIgnoreMiddleDot->IsChecked())
156 0 : nTmp |= TransliterationModules_ignoreMiddleDot_ja_JP;
157 :
158 0 : nTransliterationFlags = nTmp;
159 0 : return nTransliterationFlags;
160 : }
161 :
162 :
163 0 : void SvxJSearchOptionsPage::Reset( const SfxItemSet& )
164 : {
165 0 : SvtSearchOptions aOpt;
166 :
167 : // read settings from configuration
168 0 : m_pMatchCase ->Check(!aOpt.IsMatchCase() ); //! treat as equal uppercase/lowercase
169 0 : m_pMatchFullHalfWidth ->Check( aOpt.IsMatchFullHalfWidthForms() );
170 0 : m_pMatchHiraganaKatakana ->Check( aOpt.IsMatchHiraganaKatakana() );
171 0 : m_pMatchContractions ->Check( aOpt.IsMatchContractions() );
172 0 : m_pMatchMinusDashChoon ->Check( aOpt.IsMatchMinusDashChoon() );
173 0 : m_pMatchRepeatCharMarks ->Check( aOpt.IsMatchRepeatCharMarks() );
174 0 : m_pMatchVariantFormKanji ->Check( aOpt.IsMatchVariantFormKanji() );
175 0 : m_pMatchOldKanaForms ->Check( aOpt.IsMatchOldKanaForms() );
176 0 : m_pMatchDiziDuzu ->Check( aOpt.IsMatchDiziDuzu() );
177 0 : m_pMatchBavaHafa ->Check( aOpt.IsMatchBavaHafa() );
178 0 : m_pMatchTsithichiDhizi ->Check( aOpt.IsMatchTsithichiDhizi() );
179 0 : m_pMatchHyuiyuByuvyu ->Check( aOpt.IsMatchHyuiyuByuvyu() );
180 0 : m_pMatchSesheZeje ->Check( aOpt.IsMatchSesheZeje() );
181 0 : m_pMatchIaiya ->Check( aOpt.IsMatchIaiya() );
182 0 : m_pMatchKiku ->Check( aOpt.IsMatchKiku() );
183 0 : m_pIgnorePunctuation ->Check( aOpt.IsIgnorePunctuation() );
184 0 : m_pIgnoreWhitespace ->Check( aOpt.IsIgnoreWhitespace() );
185 0 : m_pMatchProlongedSoundMark ->Check( aOpt.IsIgnoreProlongedSoundMark() );
186 0 : m_pIgnoreMiddleDot ->Check( aOpt.IsIgnoreMiddleDot() );
187 :
188 0 : nTransliterationFlags = GetTransliterationFlags_Impl();
189 : DBG_ASSERT( nTransliterationFlags == aOpt.GetTransliterationFlags(),
190 : "Transliteration settings different" );
191 :
192 0 : m_pMatchCase ->SaveValue();
193 0 : m_pMatchFullHalfWidth ->SaveValue();
194 0 : m_pMatchHiraganaKatakana ->SaveValue();
195 0 : m_pMatchContractions ->SaveValue();
196 0 : m_pMatchMinusDashChoon ->SaveValue();
197 0 : m_pMatchRepeatCharMarks ->SaveValue();
198 0 : m_pMatchVariantFormKanji ->SaveValue();
199 0 : m_pMatchOldKanaForms ->SaveValue();
200 0 : m_pMatchDiziDuzu ->SaveValue();
201 0 : m_pMatchBavaHafa ->SaveValue();
202 0 : m_pMatchTsithichiDhizi ->SaveValue();
203 0 : m_pMatchHyuiyuByuvyu ->SaveValue();
204 0 : m_pMatchSesheZeje ->SaveValue();
205 0 : m_pMatchIaiya ->SaveValue();
206 0 : m_pMatchKiku ->SaveValue();
207 0 : m_pIgnorePunctuation ->SaveValue();
208 0 : m_pIgnoreWhitespace ->SaveValue();
209 0 : m_pMatchProlongedSoundMark ->SaveValue();
210 0 : m_pIgnoreMiddleDot ->SaveValue();
211 0 : }
212 :
213 :
214 0 : bool SvxJSearchOptionsPage::FillItemSet( SfxItemSet& )
215 : {
216 0 : sal_Int32 nOldVal = nTransliterationFlags;
217 0 : nTransliterationFlags = GetTransliterationFlags_Impl();
218 0 : bool bModified = nOldVal != nTransliterationFlags;
219 :
220 0 : if (!IsSaveOptions())
221 0 : return bModified;
222 :
223 0 : bModified = false;
224 0 : SvtSearchOptions aOpt;
225 : sal_Bool bNewVal, bChanged;
226 :
227 0 : bNewVal = m_pMatchCase->IsChecked(); //! treat as equal uppercase/lowercase
228 0 : bChanged = bNewVal != m_pMatchCase->GetSavedValue();
229 0 : if (bChanged)
230 : {
231 0 : aOpt.SetMatchCase(!bNewVal );
232 0 : bModified = true;
233 : }
234 0 : bNewVal = m_pMatchFullHalfWidth->IsChecked();
235 0 : bChanged = bNewVal != m_pMatchFullHalfWidth->GetSavedValue();
236 0 : if (bChanged)
237 : {
238 0 : aOpt.SetMatchFullHalfWidthForms( bNewVal );
239 0 : bModified = true;
240 : }
241 0 : bNewVal = m_pMatchHiraganaKatakana->IsChecked();
242 0 : bChanged = bNewVal != m_pMatchHiraganaKatakana->GetSavedValue();
243 0 : if (bChanged)
244 : {
245 0 : aOpt.SetMatchHiraganaKatakana( bNewVal );
246 0 : bModified = true;
247 : }
248 0 : bNewVal = m_pMatchContractions->IsChecked();
249 0 : bChanged = bNewVal != m_pMatchContractions->GetSavedValue();
250 0 : if (bChanged)
251 : {
252 0 : aOpt.SetMatchContractions( bNewVal );
253 0 : bModified = true;
254 : }
255 0 : bNewVal = m_pMatchMinusDashChoon->IsChecked();
256 0 : bChanged = bNewVal != m_pMatchMinusDashChoon->GetSavedValue();
257 0 : if (bChanged)
258 : {
259 0 : aOpt.SetMatchMinusDashChoon( bNewVal );
260 0 : bModified = true;
261 : }
262 0 : bNewVal = m_pMatchRepeatCharMarks->IsChecked();
263 0 : bChanged = bNewVal != m_pMatchRepeatCharMarks->GetSavedValue();
264 0 : if (bChanged)
265 : {
266 0 : aOpt.SetMatchRepeatCharMarks( bNewVal );
267 0 : bModified = true;
268 : }
269 0 : bNewVal = m_pMatchVariantFormKanji->IsChecked();
270 0 : bChanged = bNewVal != m_pMatchVariantFormKanji->GetSavedValue();
271 0 : if (bChanged)
272 : {
273 0 : aOpt.SetMatchVariantFormKanji( bNewVal );
274 0 : bModified = true;
275 : }
276 0 : bNewVal = m_pMatchOldKanaForms->IsChecked();
277 0 : bChanged = bNewVal != m_pMatchOldKanaForms->GetSavedValue();
278 0 : if (bChanged)
279 : {
280 0 : aOpt.SetMatchOldKanaForms( bNewVal );
281 0 : bModified = true;
282 : }
283 0 : bNewVal = m_pMatchDiziDuzu->IsChecked();
284 0 : bChanged = bNewVal != m_pMatchDiziDuzu->GetSavedValue();
285 0 : if (bChanged)
286 : {
287 0 : aOpt.SetMatchDiziDuzu( bNewVal );
288 0 : bModified = true;
289 : }
290 0 : bNewVal = m_pMatchBavaHafa->IsChecked();
291 0 : bChanged = bNewVal != m_pMatchBavaHafa->GetSavedValue();
292 0 : if (bChanged)
293 : {
294 0 : aOpt.SetMatchBavaHafa( bNewVal );
295 0 : bModified = true;
296 : }
297 0 : bNewVal = m_pMatchTsithichiDhizi->IsChecked();
298 0 : bChanged = bNewVal != m_pMatchTsithichiDhizi->GetSavedValue();
299 0 : if (bChanged)
300 : {
301 0 : aOpt.SetMatchTsithichiDhizi( bNewVal );
302 0 : bModified = true;
303 : }
304 0 : bNewVal = m_pMatchHyuiyuByuvyu->IsChecked();
305 0 : bChanged = bNewVal != m_pMatchHyuiyuByuvyu->GetSavedValue();
306 0 : if (bChanged)
307 : {
308 0 : aOpt.SetMatchHyuiyuByuvyu( bNewVal );
309 0 : bModified = true;
310 : }
311 0 : bNewVal = m_pMatchSesheZeje->IsChecked();
312 0 : bChanged = bNewVal != m_pMatchSesheZeje->GetSavedValue();
313 0 : if (bChanged)
314 : {
315 0 : aOpt.SetMatchSesheZeje( bNewVal );
316 0 : bModified = true;
317 : }
318 0 : bNewVal = m_pMatchIaiya->IsChecked();
319 0 : bChanged = bNewVal != m_pMatchIaiya->GetSavedValue();
320 0 : if (bChanged)
321 : {
322 0 : aOpt.SetMatchIaiya( bNewVal );
323 0 : bModified = true;
324 : }
325 0 : bNewVal = m_pMatchKiku->IsChecked();
326 0 : bChanged = bNewVal != m_pMatchKiku->GetSavedValue();
327 0 : if (bChanged)
328 : {
329 0 : aOpt.SetMatchKiku( bNewVal );
330 0 : bModified = true;
331 : }
332 0 : bNewVal = m_pIgnorePunctuation->IsChecked();
333 0 : bChanged = bNewVal != m_pIgnorePunctuation->GetSavedValue();
334 0 : if (bChanged)
335 : {
336 0 : aOpt.SetIgnorePunctuation( bNewVal );
337 0 : bModified = true;
338 : }
339 0 : bNewVal = m_pIgnoreWhitespace->IsChecked();
340 0 : bChanged = bNewVal != m_pIgnoreWhitespace->GetSavedValue();
341 0 : if (bChanged)
342 : {
343 0 : aOpt.SetIgnoreWhitespace( bNewVal );
344 0 : bModified = true;
345 : }
346 0 : bNewVal = m_pMatchProlongedSoundMark->IsChecked();
347 0 : bChanged = bNewVal != m_pMatchProlongedSoundMark->GetSavedValue();
348 0 : if (bChanged)
349 : {
350 0 : aOpt.SetIgnoreProlongedSoundMark( bNewVal );
351 0 : bModified = true;
352 : }
353 0 : bNewVal = m_pIgnoreMiddleDot->IsChecked();
354 0 : bChanged = bNewVal != m_pIgnoreMiddleDot->GetSavedValue();
355 0 : if (bChanged)
356 : {
357 0 : aOpt.SetIgnoreMiddleDot( bNewVal );
358 0 : bModified = true;
359 : }
360 :
361 0 : return bModified;
362 0 : }
363 :
364 :
365 :
366 :
367 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|