merge the formfield patch from ooo-build
[ooovba.git] / svx / source / cui / optjsearch.cxx
blob720fa6eec5533025c1a329f1ae65436d7c520f22
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: optjsearch.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
36 #endif
39 #include <tools/shl.hxx>
40 #include <svtools/searchopt.hxx>
41 #include <com/sun/star/i18n/TransliterationModules.hpp>
43 #ifndef _SVX_DIALOGS_HRC
44 #include <svx/dialogs.hrc>
45 #endif
46 #include <svx/dialmgr.hxx>
47 #include <optjsearch.hxx>
48 #include "optjsearch.hrc"
50 using namespace com::sun::star::i18n;
52 //////////////////////////////////////////////////////////////////////
54 SvxJSearchOptionsPage::SvxJSearchOptionsPage( Window* pParent, const SfxItemSet& rSet ) :
55 SfxTabPage( pParent, SVX_RES( RID_SVXPAGE_JSEARCH_OPTIONS ), rSet ),
57 aTreatAsEqual ( this, SVX_RES( FL_TREAT_AS_EQUAL ) ),
58 aMatchCase ( this, SVX_RES( CB_MATCH_CASE ) ),
59 aMatchFullHalfWidth ( this, SVX_RES( CB_MATCH_FULL_HALF_WIDTH ) ),
60 aMatchHiraganaKatakana ( this, SVX_RES( CB_MATCH_HIRAGANA_KATAKANA ) ),
61 aMatchContractions ( this, SVX_RES( CB_MATCH_CONTRACTIONS ) ),
62 aMatchMinusDashChoon ( this, SVX_RES( CB_MATCH_MINUS_DASH_CHOON ) ),
63 aMatchRepeatCharMarks ( this, SVX_RES( CB_MATCH_REPEAT_CHAR_MARKS ) ),
64 aMatchVariantFormKanji ( this, SVX_RES( CB_MATCH_VARIANT_FORM_KANJI ) ),
65 aMatchOldKanaForms ( this, SVX_RES( CB_MATCH_OLD_KANA_FORMS ) ),
66 aMatchDiziDuzu ( this, SVX_RES( CB_MATCH_DIZI_DUZU ) ),
67 aMatchBavaHafa ( this, SVX_RES( CB_MATCH_BAVA_HAFA ) ),
68 aMatchTsithichiDhizi ( this, SVX_RES( CB_MATCH_TSITHICHI_DHIZI ) ),
69 aMatchHyuiyuByuvyu ( this, SVX_RES( CB_MATCH_HYUFYU_BYUVYU ) ),
70 aMatchSesheZeje ( this, SVX_RES( CB_MATCH_SESHE_ZEJE ) ),
71 aMatchIaiya ( this, SVX_RES( CB_MATCH_IAIYA ) ),
72 aMatchKiku ( this, SVX_RES( CB_MATCH_KIKU ) ),
73 aMatchProlongedSoundMark ( this, SVX_RES( CB_MATCH_PROLONGED_SOUNDMARK ) ),
74 aIgnore ( this, SVX_RES( FL_IGNORE ) ),
75 aIgnorePunctuation ( this, SVX_RES( CB_IGNORE_PUNCTUATION ) ),
76 aIgnoreWhitespace ( this, SVX_RES( CB_IGNORE_WHITESPACES ) ),
77 aIgnoreMiddleDot ( this, SVX_RES( CB_IGNORE_MIDDLE_DOT ) )
79 FreeResource();
80 bSaveOptions = TRUE;
81 nTransliterationFlags = 0x00000000;
85 SvxJSearchOptionsPage::~SvxJSearchOptionsPage()
90 SfxTabPage* SvxJSearchOptionsPage::Create( Window* pParent, const SfxItemSet& rSet )
92 return new SvxJSearchOptionsPage( pParent, rSet );
96 void SvxJSearchOptionsPage::SetTransliterationFlags( INT32 nSettings )
98 BOOL bVal = 0 != (nSettings & TransliterationModules_IGNORE_CASE);
99 aMatchCase .Check( bVal ); //! treat as equal uppercase/lowercase
100 bVal = 0 != (nSettings & TransliterationModules_IGNORE_WIDTH);
101 aMatchFullHalfWidth .Check( bVal );
102 bVal = 0 != (nSettings & TransliterationModules_IGNORE_KANA);
103 aMatchHiraganaKatakana .Check( bVal );
104 bVal = 0 != (nSettings & TransliterationModules_ignoreSize_ja_JP);
105 aMatchContractions .Check( bVal );
106 bVal = 0 != (nSettings & TransliterationModules_ignoreMinusSign_ja_JP);
107 aMatchMinusDashChoon .Check( bVal );
108 bVal = 0 != (nSettings & TransliterationModules_ignoreIterationMark_ja_JP);
109 aMatchRepeatCharMarks .Check( bVal );
110 bVal = 0 != (nSettings & TransliterationModules_ignoreTraditionalKanji_ja_JP);
111 aMatchVariantFormKanji .Check( bVal );
112 bVal = 0 != (nSettings & TransliterationModules_ignoreTraditionalKana_ja_JP);
113 aMatchOldKanaForms .Check( bVal );
114 bVal = 0 != (nSettings & TransliterationModules_ignoreZiZu_ja_JP);
115 aMatchDiziDuzu .Check( bVal );
116 bVal = 0 != (nSettings & TransliterationModules_ignoreBaFa_ja_JP);
117 aMatchBavaHafa .Check( bVal );
118 bVal = 0 != (nSettings & TransliterationModules_ignoreTiJi_ja_JP);
119 aMatchTsithichiDhizi .Check( bVal );
120 bVal = 0 != (nSettings & TransliterationModules_ignoreHyuByu_ja_JP);
121 aMatchHyuiyuByuvyu .Check( bVal );
122 bVal = 0 != (nSettings & TransliterationModules_ignoreSeZe_ja_JP);
123 aMatchSesheZeje .Check( bVal );
124 bVal = 0 != (nSettings & TransliterationModules_ignoreIandEfollowedByYa_ja_JP);
125 aMatchIaiya .Check( bVal );
126 bVal = 0 != (nSettings & TransliterationModules_ignoreKiKuFollowedBySa_ja_JP);
127 aMatchKiku .Check( bVal );
128 bVal = 0 != (nSettings & TransliterationModules_ignoreSeparator_ja_JP);
129 aIgnorePunctuation .Check( bVal );
130 bVal = 0 != (nSettings & TransliterationModules_ignoreSpace_ja_JP);
131 aIgnoreWhitespace .Check( bVal );
132 bVal = 0 != (nSettings & TransliterationModules_ignoreProlongedSoundMark_ja_JP);
133 aMatchProlongedSoundMark.Check( bVal );
134 bVal = 0 != (nSettings & TransliterationModules_ignoreMiddleDot_ja_JP);
135 aIgnoreMiddleDot .Check( bVal );
137 nTransliterationFlags = nSettings;
141 INT32 SvxJSearchOptionsPage::GetTransliterationFlags_Impl()
143 INT32 nTmp = 0;
144 if (aMatchCase.IsChecked()) //! treat as equal uppercase/lowercase
145 nTmp |= TransliterationModules_IGNORE_CASE;
146 if (aMatchFullHalfWidth.IsChecked())
147 nTmp |= TransliterationModules_IGNORE_WIDTH;
148 if (aMatchHiraganaKatakana.IsChecked())
149 nTmp |= TransliterationModules_IGNORE_KANA;
150 if (aMatchContractions.IsChecked())
151 nTmp |= TransliterationModules_ignoreSize_ja_JP;
152 if (aMatchMinusDashChoon.IsChecked())
153 nTmp |= TransliterationModules_ignoreMinusSign_ja_JP;
154 if (aMatchRepeatCharMarks.IsChecked())
155 nTmp |= TransliterationModules_ignoreIterationMark_ja_JP;
156 if (aMatchVariantFormKanji.IsChecked())
157 nTmp |= TransliterationModules_ignoreTraditionalKanji_ja_JP;
158 if (aMatchOldKanaForms.IsChecked())
159 nTmp |= TransliterationModules_ignoreTraditionalKana_ja_JP;
160 if (aMatchDiziDuzu.IsChecked())
161 nTmp |= TransliterationModules_ignoreZiZu_ja_JP;
162 if (aMatchBavaHafa.IsChecked())
163 nTmp |= TransliterationModules_ignoreBaFa_ja_JP;
164 if (aMatchTsithichiDhizi.IsChecked())
165 nTmp |= TransliterationModules_ignoreTiJi_ja_JP;
166 if (aMatchHyuiyuByuvyu.IsChecked())
167 nTmp |= TransliterationModules_ignoreHyuByu_ja_JP;
168 if (aMatchSesheZeje.IsChecked())
169 nTmp |= TransliterationModules_ignoreSeZe_ja_JP;
170 if (aMatchIaiya.IsChecked())
171 nTmp |= TransliterationModules_ignoreIandEfollowedByYa_ja_JP;
172 if (aMatchKiku.IsChecked())
173 nTmp |= TransliterationModules_ignoreKiKuFollowedBySa_ja_JP;
174 if (aIgnorePunctuation.IsChecked())
175 nTmp |= TransliterationModules_ignoreSeparator_ja_JP;
176 if (aIgnoreWhitespace.IsChecked())
177 nTmp |= TransliterationModules_ignoreSpace_ja_JP;
178 if (aMatchProlongedSoundMark.IsChecked())
179 nTmp |= TransliterationModules_ignoreProlongedSoundMark_ja_JP;
180 if (aIgnoreMiddleDot.IsChecked())
181 nTmp |= TransliterationModules_ignoreMiddleDot_ja_JP;
183 nTransliterationFlags = nTmp;
184 return nTransliterationFlags;
188 void SvxJSearchOptionsPage::Reset( const SfxItemSet& )
190 SvtSearchOptions aOpt;
192 // read settings from configuration
193 aMatchCase .Check(!aOpt.IsMatchCase() ); //! treat as equal uppercase/lowercase
194 aMatchFullHalfWidth .Check( aOpt.IsMatchFullHalfWidthForms() );
195 aMatchHiraganaKatakana .Check( aOpt.IsMatchHiraganaKatakana() );
196 aMatchContractions .Check( aOpt.IsMatchContractions() );
197 aMatchMinusDashChoon .Check( aOpt.IsMatchMinusDashChoon() );
198 aMatchRepeatCharMarks .Check( aOpt.IsMatchRepeatCharMarks() );
199 aMatchVariantFormKanji .Check( aOpt.IsMatchVariantFormKanji() );
200 aMatchOldKanaForms .Check( aOpt.IsMatchOldKanaForms() );
201 aMatchDiziDuzu .Check( aOpt.IsMatchDiziDuzu() );
202 aMatchBavaHafa .Check( aOpt.IsMatchBavaHafa() );
203 aMatchTsithichiDhizi .Check( aOpt.IsMatchTsithichiDhizi() );
204 aMatchHyuiyuByuvyu .Check( aOpt.IsMatchHyuiyuByuvyu() );
205 aMatchSesheZeje .Check( aOpt.IsMatchSesheZeje() );
206 aMatchIaiya .Check( aOpt.IsMatchIaiya() );
207 aMatchKiku .Check( aOpt.IsMatchKiku() );
208 aIgnorePunctuation .Check( aOpt.IsIgnorePunctuation() );
209 aIgnoreWhitespace .Check( aOpt.IsIgnoreWhitespace() );
210 aMatchProlongedSoundMark .Check( aOpt.IsIgnoreProlongedSoundMark() );
211 aIgnoreMiddleDot .Check( aOpt.IsIgnoreMiddleDot() );
213 nTransliterationFlags = GetTransliterationFlags_Impl();
214 DBG_ASSERT( nTransliterationFlags == aOpt.GetTransliterationFlags(),
215 "Transliteration settings different" );
217 aMatchCase .SaveValue();
218 aMatchFullHalfWidth .SaveValue();
219 aMatchHiraganaKatakana .SaveValue();
220 aMatchContractions .SaveValue();
221 aMatchMinusDashChoon .SaveValue();
222 aMatchRepeatCharMarks .SaveValue();
223 aMatchVariantFormKanji .SaveValue();
224 aMatchOldKanaForms .SaveValue();
225 aMatchDiziDuzu .SaveValue();
226 aMatchBavaHafa .SaveValue();
227 aMatchTsithichiDhizi .SaveValue();
228 aMatchHyuiyuByuvyu .SaveValue();
229 aMatchSesheZeje .SaveValue();
230 aMatchIaiya .SaveValue();
231 aMatchKiku .SaveValue();
232 aIgnorePunctuation .SaveValue();
233 aIgnoreWhitespace .SaveValue();
234 aMatchProlongedSoundMark .SaveValue();
235 aIgnoreMiddleDot .SaveValue();
239 BOOL SvxJSearchOptionsPage::FillItemSet( SfxItemSet& )
241 BOOL bModified = FALSE;
243 INT32 nOldVal = nTransliterationFlags;
244 nTransliterationFlags = GetTransliterationFlags_Impl();
245 bModified = nOldVal != nTransliterationFlags;
247 if (!IsSaveOptions())
248 return bModified;
250 bModified = FALSE;
251 SvtSearchOptions aOpt;
252 BOOL bNewVal, bChanged;
254 bNewVal = aMatchCase.IsChecked(); //! treat as equal uppercase/lowercase
255 bChanged = bNewVal != aMatchCase.GetSavedValue();
256 if (bChanged)
258 aOpt.SetMatchCase(!bNewVal );
259 bModified = TRUE;
261 bNewVal = aMatchFullHalfWidth.IsChecked();
262 bChanged = bNewVal != aMatchFullHalfWidth.GetSavedValue();
263 if (bChanged)
265 aOpt.SetMatchFullHalfWidthForms( bNewVal );
266 bModified = TRUE;
268 bNewVal = aMatchHiraganaKatakana.IsChecked();
269 bChanged = bNewVal != aMatchHiraganaKatakana.GetSavedValue();
270 if (bChanged)
272 aOpt.SetMatchHiraganaKatakana( bNewVal );
273 bModified = TRUE;
275 bNewVal = aMatchContractions.IsChecked();
276 bChanged = bNewVal != aMatchContractions.GetSavedValue();
277 if (bChanged)
279 aOpt.SetMatchContractions( bNewVal );
280 bModified = TRUE;
282 bNewVal = aMatchMinusDashChoon.IsChecked();
283 bChanged = bNewVal != aMatchMinusDashChoon.GetSavedValue();
284 if (bChanged)
286 aOpt.SetMatchMinusDashChoon( bNewVal );
287 bModified = TRUE;
289 bNewVal = aMatchRepeatCharMarks.IsChecked();
290 bChanged = bNewVal != aMatchRepeatCharMarks.GetSavedValue();
291 if (bChanged)
293 aOpt.SetMatchRepeatCharMarks( bNewVal );
294 bModified = TRUE;
296 bNewVal = aMatchVariantFormKanji.IsChecked();
297 bChanged = bNewVal != aMatchVariantFormKanji.GetSavedValue();
298 if (bChanged)
300 aOpt.SetMatchVariantFormKanji( bNewVal );
301 bModified = TRUE;
303 bNewVal = aMatchOldKanaForms.IsChecked();
304 bChanged = bNewVal != aMatchOldKanaForms.GetSavedValue();
305 if (bChanged)
307 aOpt.SetMatchOldKanaForms( bNewVal );
308 bModified = TRUE;
310 bNewVal = aMatchDiziDuzu.IsChecked();
311 bChanged = bNewVal != aMatchDiziDuzu.GetSavedValue();
312 if (bChanged)
314 aOpt.SetMatchDiziDuzu( bNewVal );
315 bModified = TRUE;
317 bNewVal = aMatchBavaHafa.IsChecked();
318 bChanged = bNewVal != aMatchBavaHafa.GetSavedValue();
319 if (bChanged)
321 aOpt.SetMatchBavaHafa( bNewVal );
322 bModified = TRUE;
324 bNewVal = aMatchTsithichiDhizi.IsChecked();
325 bChanged = bNewVal != aMatchTsithichiDhizi.GetSavedValue();
326 if (bChanged)
328 aOpt.SetMatchTsithichiDhizi( bNewVal );
329 bModified = TRUE;
331 bNewVal = aMatchHyuiyuByuvyu.IsChecked();
332 bChanged = bNewVal != aMatchHyuiyuByuvyu.GetSavedValue();
333 if (bChanged)
335 aOpt.SetMatchHyuiyuByuvyu( bNewVal );
336 bModified = TRUE;
338 bNewVal = aMatchSesheZeje.IsChecked();
339 bChanged = bNewVal != aMatchSesheZeje.GetSavedValue();
340 if (bChanged)
342 aOpt.SetMatchSesheZeje( bNewVal );
343 bModified = TRUE;
345 bNewVal = aMatchIaiya.IsChecked();
346 bChanged = bNewVal != aMatchIaiya.GetSavedValue();
347 if (bChanged)
349 aOpt.SetMatchIaiya( bNewVal );
350 bModified = TRUE;
352 bNewVal = aMatchKiku.IsChecked();
353 bChanged = bNewVal != aMatchKiku.GetSavedValue();
354 if (bChanged)
356 aOpt.SetMatchKiku( bNewVal );
357 bModified = TRUE;
359 bNewVal = aIgnorePunctuation.IsChecked();
360 bChanged = bNewVal != aIgnorePunctuation.GetSavedValue();
361 if (bChanged)
363 aOpt.SetIgnorePunctuation( bNewVal );
364 bModified = TRUE;
366 bNewVal = aIgnoreWhitespace.IsChecked();
367 bChanged = bNewVal != aIgnoreWhitespace.GetSavedValue();
368 if (bChanged)
370 aOpt.SetIgnoreWhitespace( bNewVal );
371 bModified = TRUE;
373 bNewVal = aMatchProlongedSoundMark.IsChecked();
374 bChanged = bNewVal != aMatchProlongedSoundMark.GetSavedValue();
375 if (bChanged)
377 aOpt.SetIgnoreProlongedSoundMark( bNewVal );
378 bModified = TRUE;
380 bNewVal = aIgnoreMiddleDot.IsChecked();
381 bChanged = bNewVal != aIgnoreMiddleDot.GetSavedValue();
382 if (bChanged)
384 aOpt.SetIgnoreMiddleDot( bNewVal );
385 bModified = TRUE;
388 return bModified;
392 //////////////////////////////////////////////////////////////////////