1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: optjsearch.cxx,v $
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
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>
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
) )
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()
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())
251 SvtSearchOptions aOpt
;
252 BOOL bNewVal
, bChanged
;
254 bNewVal
= aMatchCase
.IsChecked(); //! treat as equal uppercase/lowercase
255 bChanged
= bNewVal
!= aMatchCase
.GetSavedValue();
258 aOpt
.SetMatchCase(!bNewVal
);
261 bNewVal
= aMatchFullHalfWidth
.IsChecked();
262 bChanged
= bNewVal
!= aMatchFullHalfWidth
.GetSavedValue();
265 aOpt
.SetMatchFullHalfWidthForms( bNewVal
);
268 bNewVal
= aMatchHiraganaKatakana
.IsChecked();
269 bChanged
= bNewVal
!= aMatchHiraganaKatakana
.GetSavedValue();
272 aOpt
.SetMatchHiraganaKatakana( bNewVal
);
275 bNewVal
= aMatchContractions
.IsChecked();
276 bChanged
= bNewVal
!= aMatchContractions
.GetSavedValue();
279 aOpt
.SetMatchContractions( bNewVal
);
282 bNewVal
= aMatchMinusDashChoon
.IsChecked();
283 bChanged
= bNewVal
!= aMatchMinusDashChoon
.GetSavedValue();
286 aOpt
.SetMatchMinusDashChoon( bNewVal
);
289 bNewVal
= aMatchRepeatCharMarks
.IsChecked();
290 bChanged
= bNewVal
!= aMatchRepeatCharMarks
.GetSavedValue();
293 aOpt
.SetMatchRepeatCharMarks( bNewVal
);
296 bNewVal
= aMatchVariantFormKanji
.IsChecked();
297 bChanged
= bNewVal
!= aMatchVariantFormKanji
.GetSavedValue();
300 aOpt
.SetMatchVariantFormKanji( bNewVal
);
303 bNewVal
= aMatchOldKanaForms
.IsChecked();
304 bChanged
= bNewVal
!= aMatchOldKanaForms
.GetSavedValue();
307 aOpt
.SetMatchOldKanaForms( bNewVal
);
310 bNewVal
= aMatchDiziDuzu
.IsChecked();
311 bChanged
= bNewVal
!= aMatchDiziDuzu
.GetSavedValue();
314 aOpt
.SetMatchDiziDuzu( bNewVal
);
317 bNewVal
= aMatchBavaHafa
.IsChecked();
318 bChanged
= bNewVal
!= aMatchBavaHafa
.GetSavedValue();
321 aOpt
.SetMatchBavaHafa( bNewVal
);
324 bNewVal
= aMatchTsithichiDhizi
.IsChecked();
325 bChanged
= bNewVal
!= aMatchTsithichiDhizi
.GetSavedValue();
328 aOpt
.SetMatchTsithichiDhizi( bNewVal
);
331 bNewVal
= aMatchHyuiyuByuvyu
.IsChecked();
332 bChanged
= bNewVal
!= aMatchHyuiyuByuvyu
.GetSavedValue();
335 aOpt
.SetMatchHyuiyuByuvyu( bNewVal
);
338 bNewVal
= aMatchSesheZeje
.IsChecked();
339 bChanged
= bNewVal
!= aMatchSesheZeje
.GetSavedValue();
342 aOpt
.SetMatchSesheZeje( bNewVal
);
345 bNewVal
= aMatchIaiya
.IsChecked();
346 bChanged
= bNewVal
!= aMatchIaiya
.GetSavedValue();
349 aOpt
.SetMatchIaiya( bNewVal
);
352 bNewVal
= aMatchKiku
.IsChecked();
353 bChanged
= bNewVal
!= aMatchKiku
.GetSavedValue();
356 aOpt
.SetMatchKiku( bNewVal
);
359 bNewVal
= aIgnorePunctuation
.IsChecked();
360 bChanged
= bNewVal
!= aIgnorePunctuation
.GetSavedValue();
363 aOpt
.SetIgnorePunctuation( bNewVal
);
366 bNewVal
= aIgnoreWhitespace
.IsChecked();
367 bChanged
= bNewVal
!= aIgnoreWhitespace
.GetSavedValue();
370 aOpt
.SetIgnoreWhitespace( bNewVal
);
373 bNewVal
= aMatchProlongedSoundMark
.IsChecked();
374 bChanged
= bNewVal
!= aMatchProlongedSoundMark
.GetSavedValue();
377 aOpt
.SetIgnoreProlongedSoundMark( bNewVal
);
380 bNewVal
= aIgnoreMiddleDot
.IsChecked();
381 bChanged
= bNewVal
!= aIgnoreMiddleDot
.GetSavedValue();
384 aOpt
.SetIgnoreMiddleDot( bNewVal
);
392 //////////////////////////////////////////////////////////////////////