masterfix DEV300: #i10000# build fix
[LibreOffice.git] / cui / source / options / optjsearch.cxx
blob71d902719e557e1b7ca9f103de0b089347d68da9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 #include <tools/shl.hxx>
32 #include <unotools/searchopt.hxx>
33 #include <com/sun/star/i18n/TransliterationModules.hpp>
34 #include <cuires.hrc>
35 #include <dialmgr.hxx>
36 #include <optjsearch.hxx>
37 #include "optjsearch.hrc"
39 using namespace com::sun::star::i18n;
41 //////////////////////////////////////////////////////////////////////
43 SvxJSearchOptionsPage::SvxJSearchOptionsPage( Window* pParent, const SfxItemSet& rSet ) :
44 SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_JSEARCH_OPTIONS ), rSet ),
46 aTreatAsEqual ( this, CUI_RES( FL_TREAT_AS_EQUAL ) ),
47 aMatchCase ( this, CUI_RES( CB_MATCH_CASE ) ),
48 aMatchFullHalfWidth ( this, CUI_RES( CB_MATCH_FULL_HALF_WIDTH ) ),
49 aMatchHiraganaKatakana ( this, CUI_RES( CB_MATCH_HIRAGANA_KATAKANA ) ),
50 aMatchContractions ( this, CUI_RES( CB_MATCH_CONTRACTIONS ) ),
51 aMatchMinusDashChoon ( this, CUI_RES( CB_MATCH_MINUS_DASH_CHOON ) ),
52 aMatchRepeatCharMarks ( this, CUI_RES( CB_MATCH_REPEAT_CHAR_MARKS ) ),
53 aMatchVariantFormKanji ( this, CUI_RES( CB_MATCH_VARIANT_FORM_KANJI ) ),
54 aMatchOldKanaForms ( this, CUI_RES( CB_MATCH_OLD_KANA_FORMS ) ),
55 aMatchDiziDuzu ( this, CUI_RES( CB_MATCH_DIZI_DUZU ) ),
56 aMatchBavaHafa ( this, CUI_RES( CB_MATCH_BAVA_HAFA ) ),
57 aMatchTsithichiDhizi ( this, CUI_RES( CB_MATCH_TSITHICHI_DHIZI ) ),
58 aMatchHyuiyuByuvyu ( this, CUI_RES( CB_MATCH_HYUFYU_BYUVYU ) ),
59 aMatchSesheZeje ( this, CUI_RES( CB_MATCH_SESHE_ZEJE ) ),
60 aMatchIaiya ( this, CUI_RES( CB_MATCH_IAIYA ) ),
61 aMatchKiku ( this, CUI_RES( CB_MATCH_KIKU ) ),
62 aMatchProlongedSoundMark ( this, CUI_RES( CB_MATCH_PROLONGED_SOUNDMARK ) ),
63 aIgnore ( this, CUI_RES( FL_IGNORE ) ),
64 aIgnorePunctuation ( this, CUI_RES( CB_IGNORE_PUNCTUATION ) ),
65 aIgnoreWhitespace ( this, CUI_RES( CB_IGNORE_WHITESPACES ) ),
66 aIgnoreMiddleDot ( this, CUI_RES( CB_IGNORE_MIDDLE_DOT ) )
68 FreeResource();
69 bSaveOptions = sal_True;
70 nTransliterationFlags = 0x00000000;
74 SvxJSearchOptionsPage::~SvxJSearchOptionsPage()
79 SfxTabPage* SvxJSearchOptionsPage::Create( Window* pParent, const SfxItemSet& rSet )
81 return new SvxJSearchOptionsPage( pParent, rSet );
85 void SvxJSearchOptionsPage::SetTransliterationFlags( sal_Int32 nSettings )
87 sal_Bool bVal = 0 != (nSettings & TransliterationModules_IGNORE_CASE);
88 aMatchCase .Check( bVal ); //! treat as equal uppercase/lowercase
89 bVal = 0 != (nSettings & TransliterationModules_IGNORE_WIDTH);
90 aMatchFullHalfWidth .Check( bVal );
91 bVal = 0 != (nSettings & TransliterationModules_IGNORE_KANA);
92 aMatchHiraganaKatakana .Check( bVal );
93 bVal = 0 != (nSettings & TransliterationModules_ignoreSize_ja_JP);
94 aMatchContractions .Check( bVal );
95 bVal = 0 != (nSettings & TransliterationModules_ignoreMinusSign_ja_JP);
96 aMatchMinusDashChoon .Check( bVal );
97 bVal = 0 != (nSettings & TransliterationModules_ignoreIterationMark_ja_JP);
98 aMatchRepeatCharMarks .Check( bVal );
99 bVal = 0 != (nSettings & TransliterationModules_ignoreTraditionalKanji_ja_JP);
100 aMatchVariantFormKanji .Check( bVal );
101 bVal = 0 != (nSettings & TransliterationModules_ignoreTraditionalKana_ja_JP);
102 aMatchOldKanaForms .Check( bVal );
103 bVal = 0 != (nSettings & TransliterationModules_ignoreZiZu_ja_JP);
104 aMatchDiziDuzu .Check( bVal );
105 bVal = 0 != (nSettings & TransliterationModules_ignoreBaFa_ja_JP);
106 aMatchBavaHafa .Check( bVal );
107 bVal = 0 != (nSettings & TransliterationModules_ignoreTiJi_ja_JP);
108 aMatchTsithichiDhizi .Check( bVal );
109 bVal = 0 != (nSettings & TransliterationModules_ignoreHyuByu_ja_JP);
110 aMatchHyuiyuByuvyu .Check( bVal );
111 bVal = 0 != (nSettings & TransliterationModules_ignoreSeZe_ja_JP);
112 aMatchSesheZeje .Check( bVal );
113 bVal = 0 != (nSettings & TransliterationModules_ignoreIandEfollowedByYa_ja_JP);
114 aMatchIaiya .Check( bVal );
115 bVal = 0 != (nSettings & TransliterationModules_ignoreKiKuFollowedBySa_ja_JP);
116 aMatchKiku .Check( bVal );
117 bVal = 0 != (nSettings & TransliterationModules_ignoreSeparator_ja_JP);
118 aIgnorePunctuation .Check( bVal );
119 bVal = 0 != (nSettings & TransliterationModules_ignoreSpace_ja_JP);
120 aIgnoreWhitespace .Check( bVal );
121 bVal = 0 != (nSettings & TransliterationModules_ignoreProlongedSoundMark_ja_JP);
122 aMatchProlongedSoundMark.Check( bVal );
123 bVal = 0 != (nSettings & TransliterationModules_ignoreMiddleDot_ja_JP);
124 aIgnoreMiddleDot .Check( bVal );
126 nTransliterationFlags = nSettings;
130 sal_Int32 SvxJSearchOptionsPage::GetTransliterationFlags_Impl()
132 sal_Int32 nTmp = 0;
133 if (aMatchCase.IsChecked()) //! treat as equal uppercase/lowercase
134 nTmp |= TransliterationModules_IGNORE_CASE;
135 if (aMatchFullHalfWidth.IsChecked())
136 nTmp |= TransliterationModules_IGNORE_WIDTH;
137 if (aMatchHiraganaKatakana.IsChecked())
138 nTmp |= TransliterationModules_IGNORE_KANA;
139 if (aMatchContractions.IsChecked())
140 nTmp |= TransliterationModules_ignoreSize_ja_JP;
141 if (aMatchMinusDashChoon.IsChecked())
142 nTmp |= TransliterationModules_ignoreMinusSign_ja_JP;
143 if (aMatchRepeatCharMarks.IsChecked())
144 nTmp |= TransliterationModules_ignoreIterationMark_ja_JP;
145 if (aMatchVariantFormKanji.IsChecked())
146 nTmp |= TransliterationModules_ignoreTraditionalKanji_ja_JP;
147 if (aMatchOldKanaForms.IsChecked())
148 nTmp |= TransliterationModules_ignoreTraditionalKana_ja_JP;
149 if (aMatchDiziDuzu.IsChecked())
150 nTmp |= TransliterationModules_ignoreZiZu_ja_JP;
151 if (aMatchBavaHafa.IsChecked())
152 nTmp |= TransliterationModules_ignoreBaFa_ja_JP;
153 if (aMatchTsithichiDhizi.IsChecked())
154 nTmp |= TransliterationModules_ignoreTiJi_ja_JP;
155 if (aMatchHyuiyuByuvyu.IsChecked())
156 nTmp |= TransliterationModules_ignoreHyuByu_ja_JP;
157 if (aMatchSesheZeje.IsChecked())
158 nTmp |= TransliterationModules_ignoreSeZe_ja_JP;
159 if (aMatchIaiya.IsChecked())
160 nTmp |= TransliterationModules_ignoreIandEfollowedByYa_ja_JP;
161 if (aMatchKiku.IsChecked())
162 nTmp |= TransliterationModules_ignoreKiKuFollowedBySa_ja_JP;
163 if (aIgnorePunctuation.IsChecked())
164 nTmp |= TransliterationModules_ignoreSeparator_ja_JP;
165 if (aIgnoreWhitespace.IsChecked())
166 nTmp |= TransliterationModules_ignoreSpace_ja_JP;
167 if (aMatchProlongedSoundMark.IsChecked())
168 nTmp |= TransliterationModules_ignoreProlongedSoundMark_ja_JP;
169 if (aIgnoreMiddleDot.IsChecked())
170 nTmp |= TransliterationModules_ignoreMiddleDot_ja_JP;
172 nTransliterationFlags = nTmp;
173 return nTransliterationFlags;
177 void SvxJSearchOptionsPage::Reset( const SfxItemSet& )
179 SvtSearchOptions aOpt;
181 // read settings from configuration
182 aMatchCase .Check(!aOpt.IsMatchCase() ); //! treat as equal uppercase/lowercase
183 aMatchFullHalfWidth .Check( aOpt.IsMatchFullHalfWidthForms() );
184 aMatchHiraganaKatakana .Check( aOpt.IsMatchHiraganaKatakana() );
185 aMatchContractions .Check( aOpt.IsMatchContractions() );
186 aMatchMinusDashChoon .Check( aOpt.IsMatchMinusDashChoon() );
187 aMatchRepeatCharMarks .Check( aOpt.IsMatchRepeatCharMarks() );
188 aMatchVariantFormKanji .Check( aOpt.IsMatchVariantFormKanji() );
189 aMatchOldKanaForms .Check( aOpt.IsMatchOldKanaForms() );
190 aMatchDiziDuzu .Check( aOpt.IsMatchDiziDuzu() );
191 aMatchBavaHafa .Check( aOpt.IsMatchBavaHafa() );
192 aMatchTsithichiDhizi .Check( aOpt.IsMatchTsithichiDhizi() );
193 aMatchHyuiyuByuvyu .Check( aOpt.IsMatchHyuiyuByuvyu() );
194 aMatchSesheZeje .Check( aOpt.IsMatchSesheZeje() );
195 aMatchIaiya .Check( aOpt.IsMatchIaiya() );
196 aMatchKiku .Check( aOpt.IsMatchKiku() );
197 aIgnorePunctuation .Check( aOpt.IsIgnorePunctuation() );
198 aIgnoreWhitespace .Check( aOpt.IsIgnoreWhitespace() );
199 aMatchProlongedSoundMark .Check( aOpt.IsIgnoreProlongedSoundMark() );
200 aIgnoreMiddleDot .Check( aOpt.IsIgnoreMiddleDot() );
202 nTransliterationFlags = GetTransliterationFlags_Impl();
203 DBG_ASSERT( nTransliterationFlags == aOpt.GetTransliterationFlags(),
204 "Transliteration settings different" );
206 aMatchCase .SaveValue();
207 aMatchFullHalfWidth .SaveValue();
208 aMatchHiraganaKatakana .SaveValue();
209 aMatchContractions .SaveValue();
210 aMatchMinusDashChoon .SaveValue();
211 aMatchRepeatCharMarks .SaveValue();
212 aMatchVariantFormKanji .SaveValue();
213 aMatchOldKanaForms .SaveValue();
214 aMatchDiziDuzu .SaveValue();
215 aMatchBavaHafa .SaveValue();
216 aMatchTsithichiDhizi .SaveValue();
217 aMatchHyuiyuByuvyu .SaveValue();
218 aMatchSesheZeje .SaveValue();
219 aMatchIaiya .SaveValue();
220 aMatchKiku .SaveValue();
221 aIgnorePunctuation .SaveValue();
222 aIgnoreWhitespace .SaveValue();
223 aMatchProlongedSoundMark .SaveValue();
224 aIgnoreMiddleDot .SaveValue();
228 sal_Bool SvxJSearchOptionsPage::FillItemSet( SfxItemSet& )
230 sal_Bool bModified = sal_False;
232 sal_Int32 nOldVal = nTransliterationFlags;
233 nTransliterationFlags = GetTransliterationFlags_Impl();
234 bModified = nOldVal != nTransliterationFlags;
236 if (!IsSaveOptions())
237 return bModified;
239 bModified = sal_False;
240 SvtSearchOptions aOpt;
241 sal_Bool bNewVal, bChanged;
243 bNewVal = aMatchCase.IsChecked(); //! treat as equal uppercase/lowercase
244 bChanged = bNewVal != aMatchCase.GetSavedValue();
245 if (bChanged)
247 aOpt.SetMatchCase(!bNewVal );
248 bModified = sal_True;
250 bNewVal = aMatchFullHalfWidth.IsChecked();
251 bChanged = bNewVal != aMatchFullHalfWidth.GetSavedValue();
252 if (bChanged)
254 aOpt.SetMatchFullHalfWidthForms( bNewVal );
255 bModified = sal_True;
257 bNewVal = aMatchHiraganaKatakana.IsChecked();
258 bChanged = bNewVal != aMatchHiraganaKatakana.GetSavedValue();
259 if (bChanged)
261 aOpt.SetMatchHiraganaKatakana( bNewVal );
262 bModified = sal_True;
264 bNewVal = aMatchContractions.IsChecked();
265 bChanged = bNewVal != aMatchContractions.GetSavedValue();
266 if (bChanged)
268 aOpt.SetMatchContractions( bNewVal );
269 bModified = sal_True;
271 bNewVal = aMatchMinusDashChoon.IsChecked();
272 bChanged = bNewVal != aMatchMinusDashChoon.GetSavedValue();
273 if (bChanged)
275 aOpt.SetMatchMinusDashChoon( bNewVal );
276 bModified = sal_True;
278 bNewVal = aMatchRepeatCharMarks.IsChecked();
279 bChanged = bNewVal != aMatchRepeatCharMarks.GetSavedValue();
280 if (bChanged)
282 aOpt.SetMatchRepeatCharMarks( bNewVal );
283 bModified = sal_True;
285 bNewVal = aMatchVariantFormKanji.IsChecked();
286 bChanged = bNewVal != aMatchVariantFormKanji.GetSavedValue();
287 if (bChanged)
289 aOpt.SetMatchVariantFormKanji( bNewVal );
290 bModified = sal_True;
292 bNewVal = aMatchOldKanaForms.IsChecked();
293 bChanged = bNewVal != aMatchOldKanaForms.GetSavedValue();
294 if (bChanged)
296 aOpt.SetMatchOldKanaForms( bNewVal );
297 bModified = sal_True;
299 bNewVal = aMatchDiziDuzu.IsChecked();
300 bChanged = bNewVal != aMatchDiziDuzu.GetSavedValue();
301 if (bChanged)
303 aOpt.SetMatchDiziDuzu( bNewVal );
304 bModified = sal_True;
306 bNewVal = aMatchBavaHafa.IsChecked();
307 bChanged = bNewVal != aMatchBavaHafa.GetSavedValue();
308 if (bChanged)
310 aOpt.SetMatchBavaHafa( bNewVal );
311 bModified = sal_True;
313 bNewVal = aMatchTsithichiDhizi.IsChecked();
314 bChanged = bNewVal != aMatchTsithichiDhizi.GetSavedValue();
315 if (bChanged)
317 aOpt.SetMatchTsithichiDhizi( bNewVal );
318 bModified = sal_True;
320 bNewVal = aMatchHyuiyuByuvyu.IsChecked();
321 bChanged = bNewVal != aMatchHyuiyuByuvyu.GetSavedValue();
322 if (bChanged)
324 aOpt.SetMatchHyuiyuByuvyu( bNewVal );
325 bModified = sal_True;
327 bNewVal = aMatchSesheZeje.IsChecked();
328 bChanged = bNewVal != aMatchSesheZeje.GetSavedValue();
329 if (bChanged)
331 aOpt.SetMatchSesheZeje( bNewVal );
332 bModified = sal_True;
334 bNewVal = aMatchIaiya.IsChecked();
335 bChanged = bNewVal != aMatchIaiya.GetSavedValue();
336 if (bChanged)
338 aOpt.SetMatchIaiya( bNewVal );
339 bModified = sal_True;
341 bNewVal = aMatchKiku.IsChecked();
342 bChanged = bNewVal != aMatchKiku.GetSavedValue();
343 if (bChanged)
345 aOpt.SetMatchKiku( bNewVal );
346 bModified = sal_True;
348 bNewVal = aIgnorePunctuation.IsChecked();
349 bChanged = bNewVal != aIgnorePunctuation.GetSavedValue();
350 if (bChanged)
352 aOpt.SetIgnorePunctuation( bNewVal );
353 bModified = sal_True;
355 bNewVal = aIgnoreWhitespace.IsChecked();
356 bChanged = bNewVal != aIgnoreWhitespace.GetSavedValue();
357 if (bChanged)
359 aOpt.SetIgnoreWhitespace( bNewVal );
360 bModified = sal_True;
362 bNewVal = aMatchProlongedSoundMark.IsChecked();
363 bChanged = bNewVal != aMatchProlongedSoundMark.GetSavedValue();
364 if (bChanged)
366 aOpt.SetIgnoreProlongedSoundMark( bNewVal );
367 bModified = sal_True;
369 bNewVal = aIgnoreMiddleDot.IsChecked();
370 bChanged = bNewVal != aIgnoreMiddleDot.GetSavedValue();
371 if (bChanged)
373 aOpt.SetIgnoreMiddleDot( bNewVal );
374 bModified = sal_True;
377 return bModified;
381 //////////////////////////////////////////////////////////////////////