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 #include <unotools/searchopt.hxx>
21 #include <com/sun/star/i18n/TransliterationModules.hpp>
23 #include <dialmgr.hxx>
24 #include <optjsearch.hxx>
26 using namespace com::sun::star::i18n
;
30 SvxJSearchOptionsPage::SvxJSearchOptionsPage( vcl::Window
* pParent
, const SfxItemSet
& rSet
) :
31 SfxTabPage( pParent
, "OptJSearchPage", "cui/ui/optjsearchpage.ui", &rSet
)
33 get( m_pMatchCase
, "matchcase");
34 get( m_pMatchFullHalfWidth
, "matchfullhalfwidth");
35 get( m_pMatchHiraganaKatakana
, "matchhiraganakatakana");
36 get( m_pMatchContractions
, "matchcontractions");
37 get( m_pMatchMinusDashChoon
, "matchminusdashchoon");
38 get( m_pMatchRepeatCharMarks
, "matchrepeatcharmarks");
39 get( m_pMatchVariantFormKanji
, "matchvariantformkanji");
40 get( m_pMatchOldKanaForms
, "matcholdkanaforms");
41 get( m_pMatchDiziDuzu
, "matchdiziduzu");
42 get( m_pMatchBavaHafa
, "matchbavahafa");
43 get( m_pMatchTsithichiDhizi
, "matchtsithichidhizi");
44 get( m_pMatchHyuiyuByuvyu
, "matchhyuiyubyuvyu");
45 get( m_pMatchSesheZeje
, "matchseshezeje");
46 get( m_pMatchIaiya
, "matchiaiya");
47 get( m_pMatchKiku
, "matchkiku");
48 get( m_pMatchProlongedSoundMark
, "matchprolongedsoundmark");
50 get( m_pIgnorePunctuation
, "ignorepunctuation");
51 get( m_pIgnoreWhitespace
, "ignorewhitespace");
52 get( m_pIgnoreMiddleDot
, "ignoremiddledot");
55 nTransliterationFlags
= 0x00000000;
58 SvxJSearchOptionsPage::~SvxJSearchOptionsPage()
63 void SvxJSearchOptionsPage::dispose()
66 m_pMatchFullHalfWidth
.clear();
67 m_pMatchHiraganaKatakana
.clear();
68 m_pMatchContractions
.clear();
69 m_pMatchMinusDashChoon
.clear();
70 m_pMatchRepeatCharMarks
.clear();
71 m_pMatchVariantFormKanji
.clear();
72 m_pMatchOldKanaForms
.clear();
73 m_pMatchDiziDuzu
.clear();
74 m_pMatchBavaHafa
.clear();
75 m_pMatchTsithichiDhizi
.clear();
76 m_pMatchHyuiyuByuvyu
.clear();
77 m_pMatchSesheZeje
.clear();
78 m_pMatchIaiya
.clear();
80 m_pMatchProlongedSoundMark
.clear();
81 m_pIgnorePunctuation
.clear();
82 m_pIgnoreWhitespace
.clear();
83 m_pIgnoreMiddleDot
.clear();
84 SfxTabPage::dispose();
87 VclPtr
<SfxTabPage
> SvxJSearchOptionsPage::Create( vcl::Window
* pParent
, const SfxItemSet
* rSet
)
89 return VclPtr
<SvxJSearchOptionsPage
>::Create( pParent
, *rSet
);
93 void SvxJSearchOptionsPage::SetTransliterationFlags( sal_Int32 nSettings
)
95 bool bVal
= 0 != (nSettings
& TransliterationModules_IGNORE_CASE
);
96 m_pMatchCase
->Check( bVal
); //! treat as equal uppercase/lowercase
97 bVal
= 0 != (nSettings
& TransliterationModules_IGNORE_WIDTH
);
98 m_pMatchFullHalfWidth
->Check( bVal
);
99 bVal
= 0 != (nSettings
& TransliterationModules_IGNORE_KANA
);
100 m_pMatchHiraganaKatakana
->Check( bVal
);
101 bVal
= 0 != (nSettings
& TransliterationModules_ignoreSize_ja_JP
);
102 m_pMatchContractions
->Check( bVal
);
103 bVal
= 0 != (nSettings
& TransliterationModules_ignoreMinusSign_ja_JP
);
104 m_pMatchMinusDashChoon
->Check( bVal
);
105 bVal
= 0 != (nSettings
& TransliterationModules_ignoreIterationMark_ja_JP
);
106 m_pMatchRepeatCharMarks
->Check( bVal
);
107 bVal
= 0 != (nSettings
& TransliterationModules_ignoreTraditionalKanji_ja_JP
);
108 m_pMatchVariantFormKanji
->Check( bVal
);
109 bVal
= 0 != (nSettings
& TransliterationModules_ignoreTraditionalKana_ja_JP
);
110 m_pMatchOldKanaForms
->Check( bVal
);
111 bVal
= 0 != (nSettings
& TransliterationModules_ignoreZiZu_ja_JP
);
112 m_pMatchDiziDuzu
->Check( bVal
);
113 bVal
= 0 != (nSettings
& TransliterationModules_ignoreBaFa_ja_JP
);
114 m_pMatchBavaHafa
->Check( bVal
);
115 bVal
= 0 != (nSettings
& TransliterationModules_ignoreTiJi_ja_JP
);
116 m_pMatchTsithichiDhizi
->Check( bVal
);
117 bVal
= 0 != (nSettings
& TransliterationModules_ignoreHyuByu_ja_JP
);
118 m_pMatchHyuiyuByuvyu
->Check( bVal
);
119 bVal
= 0 != (nSettings
& TransliterationModules_ignoreSeZe_ja_JP
);
120 m_pMatchSesheZeje
->Check( bVal
);
121 bVal
= 0 != (nSettings
& TransliterationModules_ignoreIandEfollowedByYa_ja_JP
);
122 m_pMatchIaiya
->Check( bVal
);
123 bVal
= 0 != (nSettings
& TransliterationModules_ignoreKiKuFollowedBySa_ja_JP
);
124 m_pMatchKiku
->Check( bVal
);
125 bVal
= 0 != (nSettings
& TransliterationModules_ignoreSeparator_ja_JP
);
126 m_pIgnorePunctuation
->Check( bVal
);
127 bVal
= 0 != (nSettings
& TransliterationModules_ignoreSpace_ja_JP
);
128 m_pIgnoreWhitespace
->Check( bVal
);
129 bVal
= 0 != (nSettings
& TransliterationModules_ignoreProlongedSoundMark_ja_JP
);
130 m_pMatchProlongedSoundMark
->Check( bVal
);
131 bVal
= 0 != (nSettings
& TransliterationModules_ignoreMiddleDot_ja_JP
);
132 m_pIgnoreMiddleDot
->Check( bVal
);
134 nTransliterationFlags
= nSettings
;
138 sal_Int32
SvxJSearchOptionsPage::GetTransliterationFlags_Impl()
141 if (m_pMatchCase
->IsChecked()) //! treat as equal uppercase/lowercase
142 nTmp
|= TransliterationModules_IGNORE_CASE
;
143 if (m_pMatchFullHalfWidth
->IsChecked())
144 nTmp
|= TransliterationModules_IGNORE_WIDTH
;
145 if (m_pMatchHiraganaKatakana
->IsChecked())
146 nTmp
|= TransliterationModules_IGNORE_KANA
;
147 if (m_pMatchContractions
->IsChecked())
148 nTmp
|= TransliterationModules_ignoreSize_ja_JP
;
149 if (m_pMatchMinusDashChoon
->IsChecked())
150 nTmp
|= TransliterationModules_ignoreMinusSign_ja_JP
;
151 if (m_pMatchRepeatCharMarks
->IsChecked())
152 nTmp
|= TransliterationModules_ignoreIterationMark_ja_JP
;
153 if (m_pMatchVariantFormKanji
->IsChecked())
154 nTmp
|= TransliterationModules_ignoreTraditionalKanji_ja_JP
;
155 if (m_pMatchOldKanaForms
->IsChecked())
156 nTmp
|= TransliterationModules_ignoreTraditionalKana_ja_JP
;
157 if (m_pMatchDiziDuzu
->IsChecked())
158 nTmp
|= TransliterationModules_ignoreZiZu_ja_JP
;
159 if (m_pMatchBavaHafa
->IsChecked())
160 nTmp
|= TransliterationModules_ignoreBaFa_ja_JP
;
161 if (m_pMatchTsithichiDhizi
->IsChecked())
162 nTmp
|= TransliterationModules_ignoreTiJi_ja_JP
;
163 if (m_pMatchHyuiyuByuvyu
->IsChecked())
164 nTmp
|= TransliterationModules_ignoreHyuByu_ja_JP
;
165 if (m_pMatchSesheZeje
->IsChecked())
166 nTmp
|= TransliterationModules_ignoreSeZe_ja_JP
;
167 if (m_pMatchIaiya
->IsChecked())
168 nTmp
|= TransliterationModules_ignoreIandEfollowedByYa_ja_JP
;
169 if (m_pMatchKiku
->IsChecked())
170 nTmp
|= TransliterationModules_ignoreKiKuFollowedBySa_ja_JP
;
171 if (m_pIgnorePunctuation
->IsChecked())
172 nTmp
|= TransliterationModules_ignoreSeparator_ja_JP
;
173 if (m_pIgnoreWhitespace
->IsChecked())
174 nTmp
|= TransliterationModules_ignoreSpace_ja_JP
;
175 if (m_pMatchProlongedSoundMark
->IsChecked())
176 nTmp
|= TransliterationModules_ignoreProlongedSoundMark_ja_JP
;
177 if (m_pIgnoreMiddleDot
->IsChecked())
178 nTmp
|= TransliterationModules_ignoreMiddleDot_ja_JP
;
180 nTransliterationFlags
= nTmp
;
181 return nTransliterationFlags
;
185 void SvxJSearchOptionsPage::Reset( const SfxItemSet
* )
187 SvtSearchOptions aOpt
;
189 // read settings from configuration
190 m_pMatchCase
->Check(!aOpt
.IsMatchCase() ); //! treat as equal uppercase/lowercase
191 m_pMatchFullHalfWidth
->Check( aOpt
.IsMatchFullHalfWidthForms() );
192 m_pMatchHiraganaKatakana
->Check( aOpt
.IsMatchHiraganaKatakana() );
193 m_pMatchContractions
->Check( aOpt
.IsMatchContractions() );
194 m_pMatchMinusDashChoon
->Check( aOpt
.IsMatchMinusDashChoon() );
195 m_pMatchRepeatCharMarks
->Check( aOpt
.IsMatchRepeatCharMarks() );
196 m_pMatchVariantFormKanji
->Check( aOpt
.IsMatchVariantFormKanji() );
197 m_pMatchOldKanaForms
->Check( aOpt
.IsMatchOldKanaForms() );
198 m_pMatchDiziDuzu
->Check( aOpt
.IsMatchDiziDuzu() );
199 m_pMatchBavaHafa
->Check( aOpt
.IsMatchBavaHafa() );
200 m_pMatchTsithichiDhizi
->Check( aOpt
.IsMatchTsithichiDhizi() );
201 m_pMatchHyuiyuByuvyu
->Check( aOpt
.IsMatchHyuiyuByuvyu() );
202 m_pMatchSesheZeje
->Check( aOpt
.IsMatchSesheZeje() );
203 m_pMatchIaiya
->Check( aOpt
.IsMatchIaiya() );
204 m_pMatchKiku
->Check( aOpt
.IsMatchKiku() );
205 m_pIgnorePunctuation
->Check( aOpt
.IsIgnorePunctuation() );
206 m_pIgnoreWhitespace
->Check( aOpt
.IsIgnoreWhitespace() );
207 m_pMatchProlongedSoundMark
->Check( aOpt
.IsIgnoreProlongedSoundMark() );
208 m_pIgnoreMiddleDot
->Check( aOpt
.IsIgnoreMiddleDot() );
210 nTransliterationFlags
= GetTransliterationFlags_Impl();
211 DBG_ASSERT( nTransliterationFlags
== aOpt
.GetTransliterationFlags(),
212 "Transliteration settings different" );
214 m_pMatchCase
->SaveValue();
215 m_pMatchFullHalfWidth
->SaveValue();
216 m_pMatchHiraganaKatakana
->SaveValue();
217 m_pMatchContractions
->SaveValue();
218 m_pMatchMinusDashChoon
->SaveValue();
219 m_pMatchRepeatCharMarks
->SaveValue();
220 m_pMatchVariantFormKanji
->SaveValue();
221 m_pMatchOldKanaForms
->SaveValue();
222 m_pMatchDiziDuzu
->SaveValue();
223 m_pMatchBavaHafa
->SaveValue();
224 m_pMatchTsithichiDhizi
->SaveValue();
225 m_pMatchHyuiyuByuvyu
->SaveValue();
226 m_pMatchSesheZeje
->SaveValue();
227 m_pMatchIaiya
->SaveValue();
228 m_pMatchKiku
->SaveValue();
229 m_pIgnorePunctuation
->SaveValue();
230 m_pIgnoreWhitespace
->SaveValue();
231 m_pMatchProlongedSoundMark
->SaveValue();
232 m_pIgnoreMiddleDot
->SaveValue();
236 bool SvxJSearchOptionsPage::FillItemSet( SfxItemSet
* )
238 sal_Int32 nOldVal
= nTransliterationFlags
;
239 nTransliterationFlags
= GetTransliterationFlags_Impl();
240 bool bModified
= nOldVal
!= nTransliterationFlags
;
242 if (!IsSaveOptions())
246 SvtSearchOptions aOpt
;
247 bool bNewVal
, bChanged
;
249 bNewVal
= m_pMatchCase
->IsChecked(); //! treat as equal uppercase/lowercase
250 bChanged
= m_pMatchCase
->IsValueChangedFromSaved();
253 aOpt
.SetMatchCase(!bNewVal
);
256 bNewVal
= m_pMatchFullHalfWidth
->IsChecked();
257 bChanged
= m_pMatchFullHalfWidth
->IsValueChangedFromSaved();
260 aOpt
.SetMatchFullHalfWidthForms( bNewVal
);
263 bNewVal
= m_pMatchHiraganaKatakana
->IsChecked();
264 bChanged
= m_pMatchHiraganaKatakana
->IsValueChangedFromSaved();
267 aOpt
.SetMatchHiraganaKatakana( bNewVal
);
270 bNewVal
= m_pMatchContractions
->IsChecked();
271 bChanged
= m_pMatchContractions
->IsValueChangedFromSaved();
274 aOpt
.SetMatchContractions( bNewVal
);
277 bNewVal
= m_pMatchMinusDashChoon
->IsChecked();
278 bChanged
= m_pMatchMinusDashChoon
->IsValueChangedFromSaved();
281 aOpt
.SetMatchMinusDashChoon( bNewVal
);
284 bNewVal
= m_pMatchRepeatCharMarks
->IsChecked();
285 bChanged
= m_pMatchRepeatCharMarks
->IsValueChangedFromSaved();
288 aOpt
.SetMatchRepeatCharMarks( bNewVal
);
291 bNewVal
= m_pMatchVariantFormKanji
->IsChecked();
292 bChanged
= m_pMatchVariantFormKanji
->IsValueChangedFromSaved();
295 aOpt
.SetMatchVariantFormKanji( bNewVal
);
298 bNewVal
= m_pMatchOldKanaForms
->IsChecked();
299 bChanged
= m_pMatchOldKanaForms
->IsValueChangedFromSaved();
302 aOpt
.SetMatchOldKanaForms( bNewVal
);
305 bNewVal
= m_pMatchDiziDuzu
->IsChecked();
306 bChanged
= m_pMatchDiziDuzu
->IsValueChangedFromSaved();
309 aOpt
.SetMatchDiziDuzu( bNewVal
);
312 bNewVal
= m_pMatchBavaHafa
->IsChecked();
313 bChanged
= m_pMatchBavaHafa
->IsValueChangedFromSaved();
316 aOpt
.SetMatchBavaHafa( bNewVal
);
319 bNewVal
= m_pMatchTsithichiDhizi
->IsChecked();
320 bChanged
= m_pMatchTsithichiDhizi
->IsValueChangedFromSaved();
323 aOpt
.SetMatchTsithichiDhizi( bNewVal
);
326 bNewVal
= m_pMatchHyuiyuByuvyu
->IsChecked();
327 bChanged
= m_pMatchHyuiyuByuvyu
->IsValueChangedFromSaved();
330 aOpt
.SetMatchHyuiyuByuvyu( bNewVal
);
333 bNewVal
= m_pMatchSesheZeje
->IsChecked();
334 bChanged
= m_pMatchSesheZeje
->IsValueChangedFromSaved();
337 aOpt
.SetMatchSesheZeje( bNewVal
);
340 bNewVal
= m_pMatchIaiya
->IsChecked();
341 bChanged
= m_pMatchIaiya
->IsValueChangedFromSaved();
344 aOpt
.SetMatchIaiya( bNewVal
);
347 bNewVal
= m_pMatchKiku
->IsChecked();
348 bChanged
= m_pMatchKiku
->IsValueChangedFromSaved();
351 aOpt
.SetMatchKiku( bNewVal
);
354 bNewVal
= m_pIgnorePunctuation
->IsChecked();
355 bChanged
= m_pIgnorePunctuation
->IsValueChangedFromSaved();
358 aOpt
.SetIgnorePunctuation( bNewVal
);
361 bNewVal
= m_pIgnoreWhitespace
->IsChecked();
362 bChanged
= m_pIgnoreWhitespace
->IsValueChangedFromSaved();
365 aOpt
.SetIgnoreWhitespace( bNewVal
);
368 bNewVal
= m_pMatchProlongedSoundMark
->IsChecked();
369 bChanged
= m_pMatchProlongedSoundMark
->IsValueChangedFromSaved();
372 aOpt
.SetIgnoreProlongedSoundMark( bNewVal
);
375 bNewVal
= m_pIgnoreMiddleDot
->IsChecked();
376 bChanged
= m_pIgnoreMiddleDot
->IsValueChangedFromSaved();
379 aOpt
.SetIgnoreMiddleDot( bNewVal
);
389 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */