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 <tools/shl.hxx>
21 #include <unotools/searchopt.hxx>
22 #include <com/sun/star/i18n/TransliterationModules.hpp>
24 #include <dialmgr.hxx>
25 #include <optjsearch.hxx>
26 #include "optjsearch.hrc"
28 using namespace com::sun::star::i18n
;
30 //////////////////////////////////////////////////////////////////////
32 SvxJSearchOptionsPage::SvxJSearchOptionsPage( Window
* pParent
, const SfxItemSet
& rSet
) :
33 SfxTabPage( pParent
, CUI_RES( RID_SVXPAGE_JSEARCH_OPTIONS
), rSet
),
35 aTreatAsEqual ( this, CUI_RES( FL_TREAT_AS_EQUAL
) ),
36 aMatchCase ( this, CUI_RES( CB_MATCH_CASE
) ),
37 aMatchFullHalfWidth ( this, CUI_RES( CB_MATCH_FULL_HALF_WIDTH
) ),
38 aMatchHiraganaKatakana ( this, CUI_RES( CB_MATCH_HIRAGANA_KATAKANA
) ),
39 aMatchContractions ( this, CUI_RES( CB_MATCH_CONTRACTIONS
) ),
40 aMatchMinusDashChoon ( this, CUI_RES( CB_MATCH_MINUS_DASH_CHOON
) ),
41 aMatchRepeatCharMarks ( this, CUI_RES( CB_MATCH_REPEAT_CHAR_MARKS
) ),
42 aMatchVariantFormKanji ( this, CUI_RES( CB_MATCH_VARIANT_FORM_KANJI
) ),
43 aMatchOldKanaForms ( this, CUI_RES( CB_MATCH_OLD_KANA_FORMS
) ),
44 aMatchDiziDuzu ( this, CUI_RES( CB_MATCH_DIZI_DUZU
) ),
45 aMatchBavaHafa ( this, CUI_RES( CB_MATCH_BAVA_HAFA
) ),
46 aMatchTsithichiDhizi ( this, CUI_RES( CB_MATCH_TSITHICHI_DHIZI
) ),
47 aMatchHyuiyuByuvyu ( this, CUI_RES( CB_MATCH_HYUFYU_BYUVYU
) ),
48 aMatchSesheZeje ( this, CUI_RES( CB_MATCH_SESHE_ZEJE
) ),
49 aMatchIaiya ( this, CUI_RES( CB_MATCH_IAIYA
) ),
50 aMatchKiku ( this, CUI_RES( CB_MATCH_KIKU
) ),
51 aMatchProlongedSoundMark ( this, CUI_RES( CB_MATCH_PROLONGED_SOUNDMARK
) ),
52 aIgnore ( this, CUI_RES( FL_IGNORE
) ),
53 aIgnorePunctuation ( this, CUI_RES( CB_IGNORE_PUNCTUATION
) ),
54 aIgnoreWhitespace ( this, CUI_RES( CB_IGNORE_WHITESPACES
) ),
55 aIgnoreMiddleDot ( this, CUI_RES( CB_IGNORE_MIDDLE_DOT
) )
58 bSaveOptions
= sal_True
;
59 nTransliterationFlags
= 0x00000000;
63 SvxJSearchOptionsPage::~SvxJSearchOptionsPage()
68 SfxTabPage
* SvxJSearchOptionsPage::Create( Window
* pParent
, const SfxItemSet
& rSet
)
70 return new SvxJSearchOptionsPage( pParent
, rSet
);
74 void SvxJSearchOptionsPage::SetTransliterationFlags( sal_Int32 nSettings
)
76 sal_Bool bVal
= 0 != (nSettings
& TransliterationModules_IGNORE_CASE
);
77 aMatchCase
.Check( bVal
); //! treat as equal uppercase/lowercase
78 bVal
= 0 != (nSettings
& TransliterationModules_IGNORE_WIDTH
);
79 aMatchFullHalfWidth
.Check( bVal
);
80 bVal
= 0 != (nSettings
& TransliterationModules_IGNORE_KANA
);
81 aMatchHiraganaKatakana
.Check( bVal
);
82 bVal
= 0 != (nSettings
& TransliterationModules_ignoreSize_ja_JP
);
83 aMatchContractions
.Check( bVal
);
84 bVal
= 0 != (nSettings
& TransliterationModules_ignoreMinusSign_ja_JP
);
85 aMatchMinusDashChoon
.Check( bVal
);
86 bVal
= 0 != (nSettings
& TransliterationModules_ignoreIterationMark_ja_JP
);
87 aMatchRepeatCharMarks
.Check( bVal
);
88 bVal
= 0 != (nSettings
& TransliterationModules_ignoreTraditionalKanji_ja_JP
);
89 aMatchVariantFormKanji
.Check( bVal
);
90 bVal
= 0 != (nSettings
& TransliterationModules_ignoreTraditionalKana_ja_JP
);
91 aMatchOldKanaForms
.Check( bVal
);
92 bVal
= 0 != (nSettings
& TransliterationModules_ignoreZiZu_ja_JP
);
93 aMatchDiziDuzu
.Check( bVal
);
94 bVal
= 0 != (nSettings
& TransliterationModules_ignoreBaFa_ja_JP
);
95 aMatchBavaHafa
.Check( bVal
);
96 bVal
= 0 != (nSettings
& TransliterationModules_ignoreTiJi_ja_JP
);
97 aMatchTsithichiDhizi
.Check( bVal
);
98 bVal
= 0 != (nSettings
& TransliterationModules_ignoreHyuByu_ja_JP
);
99 aMatchHyuiyuByuvyu
.Check( bVal
);
100 bVal
= 0 != (nSettings
& TransliterationModules_ignoreSeZe_ja_JP
);
101 aMatchSesheZeje
.Check( bVal
);
102 bVal
= 0 != (nSettings
& TransliterationModules_ignoreIandEfollowedByYa_ja_JP
);
103 aMatchIaiya
.Check( bVal
);
104 bVal
= 0 != (nSettings
& TransliterationModules_ignoreKiKuFollowedBySa_ja_JP
);
105 aMatchKiku
.Check( bVal
);
106 bVal
= 0 != (nSettings
& TransliterationModules_ignoreSeparator_ja_JP
);
107 aIgnorePunctuation
.Check( bVal
);
108 bVal
= 0 != (nSettings
& TransliterationModules_ignoreSpace_ja_JP
);
109 aIgnoreWhitespace
.Check( bVal
);
110 bVal
= 0 != (nSettings
& TransliterationModules_ignoreProlongedSoundMark_ja_JP
);
111 aMatchProlongedSoundMark
.Check( bVal
);
112 bVal
= 0 != (nSettings
& TransliterationModules_ignoreMiddleDot_ja_JP
);
113 aIgnoreMiddleDot
.Check( bVal
);
115 nTransliterationFlags
= nSettings
;
119 sal_Int32
SvxJSearchOptionsPage::GetTransliterationFlags_Impl()
122 if (aMatchCase
.IsChecked()) //! treat as equal uppercase/lowercase
123 nTmp
|= TransliterationModules_IGNORE_CASE
;
124 if (aMatchFullHalfWidth
.IsChecked())
125 nTmp
|= TransliterationModules_IGNORE_WIDTH
;
126 if (aMatchHiraganaKatakana
.IsChecked())
127 nTmp
|= TransliterationModules_IGNORE_KANA
;
128 if (aMatchContractions
.IsChecked())
129 nTmp
|= TransliterationModules_ignoreSize_ja_JP
;
130 if (aMatchMinusDashChoon
.IsChecked())
131 nTmp
|= TransliterationModules_ignoreMinusSign_ja_JP
;
132 if (aMatchRepeatCharMarks
.IsChecked())
133 nTmp
|= TransliterationModules_ignoreIterationMark_ja_JP
;
134 if (aMatchVariantFormKanji
.IsChecked())
135 nTmp
|= TransliterationModules_ignoreTraditionalKanji_ja_JP
;
136 if (aMatchOldKanaForms
.IsChecked())
137 nTmp
|= TransliterationModules_ignoreTraditionalKana_ja_JP
;
138 if (aMatchDiziDuzu
.IsChecked())
139 nTmp
|= TransliterationModules_ignoreZiZu_ja_JP
;
140 if (aMatchBavaHafa
.IsChecked())
141 nTmp
|= TransliterationModules_ignoreBaFa_ja_JP
;
142 if (aMatchTsithichiDhizi
.IsChecked())
143 nTmp
|= TransliterationModules_ignoreTiJi_ja_JP
;
144 if (aMatchHyuiyuByuvyu
.IsChecked())
145 nTmp
|= TransliterationModules_ignoreHyuByu_ja_JP
;
146 if (aMatchSesheZeje
.IsChecked())
147 nTmp
|= TransliterationModules_ignoreSeZe_ja_JP
;
148 if (aMatchIaiya
.IsChecked())
149 nTmp
|= TransliterationModules_ignoreIandEfollowedByYa_ja_JP
;
150 if (aMatchKiku
.IsChecked())
151 nTmp
|= TransliterationModules_ignoreKiKuFollowedBySa_ja_JP
;
152 if (aIgnorePunctuation
.IsChecked())
153 nTmp
|= TransliterationModules_ignoreSeparator_ja_JP
;
154 if (aIgnoreWhitespace
.IsChecked())
155 nTmp
|= TransliterationModules_ignoreSpace_ja_JP
;
156 if (aMatchProlongedSoundMark
.IsChecked())
157 nTmp
|= TransliterationModules_ignoreProlongedSoundMark_ja_JP
;
158 if (aIgnoreMiddleDot
.IsChecked())
159 nTmp
|= TransliterationModules_ignoreMiddleDot_ja_JP
;
161 nTransliterationFlags
= nTmp
;
162 return nTransliterationFlags
;
166 void SvxJSearchOptionsPage::Reset( const SfxItemSet
& )
168 SvtSearchOptions aOpt
;
170 // read settings from configuration
171 aMatchCase
.Check(!aOpt
.IsMatchCase() ); //! treat as equal uppercase/lowercase
172 aMatchFullHalfWidth
.Check( aOpt
.IsMatchFullHalfWidthForms() );
173 aMatchHiraganaKatakana
.Check( aOpt
.IsMatchHiraganaKatakana() );
174 aMatchContractions
.Check( aOpt
.IsMatchContractions() );
175 aMatchMinusDashChoon
.Check( aOpt
.IsMatchMinusDashChoon() );
176 aMatchRepeatCharMarks
.Check( aOpt
.IsMatchRepeatCharMarks() );
177 aMatchVariantFormKanji
.Check( aOpt
.IsMatchVariantFormKanji() );
178 aMatchOldKanaForms
.Check( aOpt
.IsMatchOldKanaForms() );
179 aMatchDiziDuzu
.Check( aOpt
.IsMatchDiziDuzu() );
180 aMatchBavaHafa
.Check( aOpt
.IsMatchBavaHafa() );
181 aMatchTsithichiDhizi
.Check( aOpt
.IsMatchTsithichiDhizi() );
182 aMatchHyuiyuByuvyu
.Check( aOpt
.IsMatchHyuiyuByuvyu() );
183 aMatchSesheZeje
.Check( aOpt
.IsMatchSesheZeje() );
184 aMatchIaiya
.Check( aOpt
.IsMatchIaiya() );
185 aMatchKiku
.Check( aOpt
.IsMatchKiku() );
186 aIgnorePunctuation
.Check( aOpt
.IsIgnorePunctuation() );
187 aIgnoreWhitespace
.Check( aOpt
.IsIgnoreWhitespace() );
188 aMatchProlongedSoundMark
.Check( aOpt
.IsIgnoreProlongedSoundMark() );
189 aIgnoreMiddleDot
.Check( aOpt
.IsIgnoreMiddleDot() );
191 nTransliterationFlags
= GetTransliterationFlags_Impl();
192 DBG_ASSERT( nTransliterationFlags
== aOpt
.GetTransliterationFlags(),
193 "Transliteration settings different" );
195 aMatchCase
.SaveValue();
196 aMatchFullHalfWidth
.SaveValue();
197 aMatchHiraganaKatakana
.SaveValue();
198 aMatchContractions
.SaveValue();
199 aMatchMinusDashChoon
.SaveValue();
200 aMatchRepeatCharMarks
.SaveValue();
201 aMatchVariantFormKanji
.SaveValue();
202 aMatchOldKanaForms
.SaveValue();
203 aMatchDiziDuzu
.SaveValue();
204 aMatchBavaHafa
.SaveValue();
205 aMatchTsithichiDhizi
.SaveValue();
206 aMatchHyuiyuByuvyu
.SaveValue();
207 aMatchSesheZeje
.SaveValue();
208 aMatchIaiya
.SaveValue();
209 aMatchKiku
.SaveValue();
210 aIgnorePunctuation
.SaveValue();
211 aIgnoreWhitespace
.SaveValue();
212 aMatchProlongedSoundMark
.SaveValue();
213 aIgnoreMiddleDot
.SaveValue();
217 sal_Bool
SvxJSearchOptionsPage::FillItemSet( SfxItemSet
& )
219 sal_Bool bModified
= sal_False
;
221 sal_Int32 nOldVal
= nTransliterationFlags
;
222 nTransliterationFlags
= GetTransliterationFlags_Impl();
223 bModified
= nOldVal
!= nTransliterationFlags
;
225 if (!IsSaveOptions())
228 bModified
= sal_False
;
229 SvtSearchOptions aOpt
;
230 sal_Bool bNewVal
, bChanged
;
232 bNewVal
= aMatchCase
.IsChecked(); //! treat as equal uppercase/lowercase
233 bChanged
= bNewVal
!= aMatchCase
.GetSavedValue();
236 aOpt
.SetMatchCase(!bNewVal
);
237 bModified
= sal_True
;
239 bNewVal
= aMatchFullHalfWidth
.IsChecked();
240 bChanged
= bNewVal
!= aMatchFullHalfWidth
.GetSavedValue();
243 aOpt
.SetMatchFullHalfWidthForms( bNewVal
);
244 bModified
= sal_True
;
246 bNewVal
= aMatchHiraganaKatakana
.IsChecked();
247 bChanged
= bNewVal
!= aMatchHiraganaKatakana
.GetSavedValue();
250 aOpt
.SetMatchHiraganaKatakana( bNewVal
);
251 bModified
= sal_True
;
253 bNewVal
= aMatchContractions
.IsChecked();
254 bChanged
= bNewVal
!= aMatchContractions
.GetSavedValue();
257 aOpt
.SetMatchContractions( bNewVal
);
258 bModified
= sal_True
;
260 bNewVal
= aMatchMinusDashChoon
.IsChecked();
261 bChanged
= bNewVal
!= aMatchMinusDashChoon
.GetSavedValue();
264 aOpt
.SetMatchMinusDashChoon( bNewVal
);
265 bModified
= sal_True
;
267 bNewVal
= aMatchRepeatCharMarks
.IsChecked();
268 bChanged
= bNewVal
!= aMatchRepeatCharMarks
.GetSavedValue();
271 aOpt
.SetMatchRepeatCharMarks( bNewVal
);
272 bModified
= sal_True
;
274 bNewVal
= aMatchVariantFormKanji
.IsChecked();
275 bChanged
= bNewVal
!= aMatchVariantFormKanji
.GetSavedValue();
278 aOpt
.SetMatchVariantFormKanji( bNewVal
);
279 bModified
= sal_True
;
281 bNewVal
= aMatchOldKanaForms
.IsChecked();
282 bChanged
= bNewVal
!= aMatchOldKanaForms
.GetSavedValue();
285 aOpt
.SetMatchOldKanaForms( bNewVal
);
286 bModified
= sal_True
;
288 bNewVal
= aMatchDiziDuzu
.IsChecked();
289 bChanged
= bNewVal
!= aMatchDiziDuzu
.GetSavedValue();
292 aOpt
.SetMatchDiziDuzu( bNewVal
);
293 bModified
= sal_True
;
295 bNewVal
= aMatchBavaHafa
.IsChecked();
296 bChanged
= bNewVal
!= aMatchBavaHafa
.GetSavedValue();
299 aOpt
.SetMatchBavaHafa( bNewVal
);
300 bModified
= sal_True
;
302 bNewVal
= aMatchTsithichiDhizi
.IsChecked();
303 bChanged
= bNewVal
!= aMatchTsithichiDhizi
.GetSavedValue();
306 aOpt
.SetMatchTsithichiDhizi( bNewVal
);
307 bModified
= sal_True
;
309 bNewVal
= aMatchHyuiyuByuvyu
.IsChecked();
310 bChanged
= bNewVal
!= aMatchHyuiyuByuvyu
.GetSavedValue();
313 aOpt
.SetMatchHyuiyuByuvyu( bNewVal
);
314 bModified
= sal_True
;
316 bNewVal
= aMatchSesheZeje
.IsChecked();
317 bChanged
= bNewVal
!= aMatchSesheZeje
.GetSavedValue();
320 aOpt
.SetMatchSesheZeje( bNewVal
);
321 bModified
= sal_True
;
323 bNewVal
= aMatchIaiya
.IsChecked();
324 bChanged
= bNewVal
!= aMatchIaiya
.GetSavedValue();
327 aOpt
.SetMatchIaiya( bNewVal
);
328 bModified
= sal_True
;
330 bNewVal
= aMatchKiku
.IsChecked();
331 bChanged
= bNewVal
!= aMatchKiku
.GetSavedValue();
334 aOpt
.SetMatchKiku( bNewVal
);
335 bModified
= sal_True
;
337 bNewVal
= aIgnorePunctuation
.IsChecked();
338 bChanged
= bNewVal
!= aIgnorePunctuation
.GetSavedValue();
341 aOpt
.SetIgnorePunctuation( bNewVal
);
342 bModified
= sal_True
;
344 bNewVal
= aIgnoreWhitespace
.IsChecked();
345 bChanged
= bNewVal
!= aIgnoreWhitespace
.GetSavedValue();
348 aOpt
.SetIgnoreWhitespace( bNewVal
);
349 bModified
= sal_True
;
351 bNewVal
= aMatchProlongedSoundMark
.IsChecked();
352 bChanged
= bNewVal
!= aMatchProlongedSoundMark
.GetSavedValue();
355 aOpt
.SetIgnoreProlongedSoundMark( bNewVal
);
356 bModified
= sal_True
;
358 bNewVal
= aIgnoreMiddleDot
.IsChecked();
359 bChanged
= bNewVal
!= aIgnoreMiddleDot
.GetSavedValue();
362 aOpt
.SetIgnoreMiddleDot( bNewVal
);
363 bModified
= sal_True
;
370 //////////////////////////////////////////////////////////////////////
372 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */