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/debug.hxx>
21 #include <unotools/searchopt.hxx>
22 #include <i18nutil/transliteration.hxx>
23 #include "optjsearch.hxx"
25 using namespace com::sun::star::i18n
;
28 SvxJSearchOptionsPage::SvxJSearchOptionsPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rSet
)
29 : SfxTabPage(pPage
, pController
, "cui/ui/optjsearchpage.ui", "OptJSearchPage", &rSet
)
30 , m_xMatchCase(m_xBuilder
->weld_check_button("matchcase"))
31 , m_xMatchFullHalfWidth(m_xBuilder
->weld_check_button("matchfullhalfwidth"))
32 , m_xMatchHiraganaKatakana(m_xBuilder
->weld_check_button("matchhiraganakatakana"))
33 , m_xMatchContractions(m_xBuilder
->weld_check_button("matchcontractions"))
34 , m_xMatchMinusDashChoon(m_xBuilder
->weld_check_button("matchminusdashchoon"))
35 , m_xMatchRepeatCharMarks(m_xBuilder
->weld_check_button("matchrepeatcharmarks"))
36 , m_xMatchVariantFormKanji(m_xBuilder
->weld_check_button("matchvariantformkanji"))
37 , m_xMatchOldKanaForms(m_xBuilder
->weld_check_button("matcholdkanaforms"))
38 , m_xMatchDiziDuzu(m_xBuilder
->weld_check_button("matchdiziduzu"))
39 , m_xMatchBavaHafa(m_xBuilder
->weld_check_button("matchbavahafa"))
40 , m_xMatchTsithichiDhizi(m_xBuilder
->weld_check_button("matchtsithichidhizi"))
41 , m_xMatchHyuiyuByuvyu(m_xBuilder
->weld_check_button("matchhyuiyubyuvyu"))
42 , m_xMatchSesheZeje(m_xBuilder
->weld_check_button("matchseshezeje"))
43 , m_xMatchIaiya(m_xBuilder
->weld_check_button("matchiaiya"))
44 , m_xMatchKiku(m_xBuilder
->weld_check_button("matchkiku"))
45 , m_xMatchProlongedSoundMark(m_xBuilder
->weld_check_button("matchprolongedsoundmark"))
46 , m_xIgnorePunctuation(m_xBuilder
->weld_check_button("ignorepunctuation"))
47 , m_xIgnoreWhitespace(m_xBuilder
->weld_check_button("ignorewhitespace"))
48 , m_xIgnoreMiddleDot(m_xBuilder
->weld_check_button("ignoremiddledot"))
49 , nTransliterationFlags(TransliterationFlags::NONE
)
54 SvxJSearchOptionsPage::~SvxJSearchOptionsPage()
58 std::unique_ptr
<SfxTabPage
> SvxJSearchOptionsPage::Create(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
* rSet
)
60 return std::make_unique
<SvxJSearchOptionsPage
>(pPage
, pController
, *rSet
);
63 void SvxJSearchOptionsPage::SetTransliterationFlags( TransliterationFlags nSettings
)
65 bool bVal(nSettings
& TransliterationFlags::IGNORE_CASE
);
66 m_xMatchCase
->set_active( bVal
); //! treat as equal uppercase/lowercase
67 bVal
= bool(nSettings
& TransliterationFlags::IGNORE_WIDTH
);
68 m_xMatchFullHalfWidth
->set_active( bVal
);
69 bVal
= bool(nSettings
& TransliterationFlags::IGNORE_KANA
);
70 m_xMatchHiraganaKatakana
->set_active( bVal
);
71 bVal
= bool(nSettings
& TransliterationFlags::ignoreSize_ja_JP
);
72 m_xMatchContractions
->set_active( bVal
);
73 bVal
= bool(nSettings
& TransliterationFlags::ignoreMinusSign_ja_JP
);
74 m_xMatchMinusDashChoon
->set_active( bVal
);
75 bVal
= bool(nSettings
& TransliterationFlags::ignoreIterationMark_ja_JP
);
76 m_xMatchRepeatCharMarks
->set_active( bVal
);
77 bVal
= bool(nSettings
& TransliterationFlags::ignoreTraditionalKanji_ja_JP
);
78 m_xMatchVariantFormKanji
->set_active( bVal
);
79 bVal
= bool(nSettings
& TransliterationFlags::ignoreTraditionalKana_ja_JP
);
80 m_xMatchOldKanaForms
->set_active( bVal
);
81 bVal
= bool(nSettings
& TransliterationFlags::ignoreZiZu_ja_JP
);
82 m_xMatchDiziDuzu
->set_active( bVal
);
83 bVal
= bool(nSettings
& TransliterationFlags::ignoreBaFa_ja_JP
);
84 m_xMatchBavaHafa
->set_active( bVal
);
85 bVal
= bool(nSettings
& TransliterationFlags::ignoreTiJi_ja_JP
);
86 m_xMatchTsithichiDhizi
->set_active( bVal
);
87 bVal
= bool(nSettings
& TransliterationFlags::ignoreHyuByu_ja_JP
);
88 m_xMatchHyuiyuByuvyu
->set_active( bVal
);
89 bVal
= bool(nSettings
& TransliterationFlags::ignoreSeZe_ja_JP
);
90 m_xMatchSesheZeje
->set_active( bVal
);
91 bVal
= bool(nSettings
& TransliterationFlags::ignoreIandEfollowedByYa_ja_JP
);
92 m_xMatchIaiya
->set_active( bVal
);
93 bVal
= bool(nSettings
& TransliterationFlags::ignoreKiKuFollowedBySa_ja_JP
);
94 m_xMatchKiku
->set_active( bVal
);
95 bVal
= bool(nSettings
& TransliterationFlags::ignoreSeparator_ja_JP
);
96 m_xIgnorePunctuation
->set_active( bVal
);
97 bVal
= bool(nSettings
& TransliterationFlags::ignoreSpace_ja_JP
);
98 m_xIgnoreWhitespace
->set_active( bVal
);
99 bVal
= bool(nSettings
& TransliterationFlags::ignoreProlongedSoundMark_ja_JP
);
100 m_xMatchProlongedSoundMark
->set_active( bVal
);
101 bVal
= bool(nSettings
& TransliterationFlags::ignoreMiddleDot_ja_JP
);
102 m_xIgnoreMiddleDot
->set_active( bVal
);
104 nTransliterationFlags
= nSettings
;
107 TransliterationFlags
SvxJSearchOptionsPage::GetTransliterationFlags_Impl()
109 TransliterationFlags nTmp
= TransliterationFlags::NONE
;
110 if (m_xMatchCase
->get_active()) //! treat as equal uppercase/lowercase
111 nTmp
|= TransliterationFlags::IGNORE_CASE
;
112 if (m_xMatchFullHalfWidth
->get_active())
113 nTmp
|= TransliterationFlags::IGNORE_WIDTH
;
114 if (m_xMatchHiraganaKatakana
->get_active())
115 nTmp
|= TransliterationFlags::IGNORE_KANA
;
116 if (m_xMatchContractions
->get_active())
117 nTmp
|= TransliterationFlags::ignoreSize_ja_JP
;
118 if (m_xMatchMinusDashChoon
->get_active())
119 nTmp
|= TransliterationFlags::ignoreMinusSign_ja_JP
;
120 if (m_xMatchRepeatCharMarks
->get_active())
121 nTmp
|= TransliterationFlags::ignoreIterationMark_ja_JP
;
122 if (m_xMatchVariantFormKanji
->get_active())
123 nTmp
|= TransliterationFlags::ignoreTraditionalKanji_ja_JP
;
124 if (m_xMatchOldKanaForms
->get_active())
125 nTmp
|= TransliterationFlags::ignoreTraditionalKana_ja_JP
;
126 if (m_xMatchDiziDuzu
->get_active())
127 nTmp
|= TransliterationFlags::ignoreZiZu_ja_JP
;
128 if (m_xMatchBavaHafa
->get_active())
129 nTmp
|= TransliterationFlags::ignoreBaFa_ja_JP
;
130 if (m_xMatchTsithichiDhizi
->get_active())
131 nTmp
|= TransliterationFlags::ignoreTiJi_ja_JP
;
132 if (m_xMatchHyuiyuByuvyu
->get_active())
133 nTmp
|= TransliterationFlags::ignoreHyuByu_ja_JP
;
134 if (m_xMatchSesheZeje
->get_active())
135 nTmp
|= TransliterationFlags::ignoreSeZe_ja_JP
;
136 if (m_xMatchIaiya
->get_active())
137 nTmp
|= TransliterationFlags::ignoreIandEfollowedByYa_ja_JP
;
138 if (m_xMatchKiku
->get_active())
139 nTmp
|= TransliterationFlags::ignoreKiKuFollowedBySa_ja_JP
;
140 if (m_xIgnorePunctuation
->get_active())
141 nTmp
|= TransliterationFlags::ignoreSeparator_ja_JP
;
142 if (m_xIgnoreWhitespace
->get_active())
143 nTmp
|= TransliterationFlags::ignoreSpace_ja_JP
;
144 if (m_xMatchProlongedSoundMark
->get_active())
145 nTmp
|= TransliterationFlags::ignoreProlongedSoundMark_ja_JP
;
146 if (m_xIgnoreMiddleDot
->get_active())
147 nTmp
|= TransliterationFlags::ignoreMiddleDot_ja_JP
;
149 nTransliterationFlags
= nTmp
;
150 return nTransliterationFlags
;
154 void SvxJSearchOptionsPage::Reset( const SfxItemSet
* )
156 SvtSearchOptions aOpt
;
158 // read settings from configuration
159 m_xMatchCase
->set_active(!aOpt
.IsMatchCase() ); //! treat as equal uppercase/lowercase
160 m_xMatchFullHalfWidth
->set_active( aOpt
.IsMatchFullHalfWidthForms() );
161 m_xMatchHiraganaKatakana
->set_active( aOpt
.IsMatchHiraganaKatakana() );
162 m_xMatchContractions
->set_active( aOpt
.IsMatchContractions() );
163 m_xMatchMinusDashChoon
->set_active( aOpt
.IsMatchMinusDashChoon() );
164 m_xMatchRepeatCharMarks
->set_active( aOpt
.IsMatchRepeatCharMarks() );
165 m_xMatchVariantFormKanji
->set_active( aOpt
.IsMatchVariantFormKanji() );
166 m_xMatchOldKanaForms
->set_active( aOpt
.IsMatchOldKanaForms() );
167 m_xMatchDiziDuzu
->set_active( aOpt
.IsMatchDiziDuzu() );
168 m_xMatchBavaHafa
->set_active( aOpt
.IsMatchBavaHafa() );
169 m_xMatchTsithichiDhizi
->set_active( aOpt
.IsMatchTsithichiDhizi() );
170 m_xMatchHyuiyuByuvyu
->set_active( aOpt
.IsMatchHyuiyuByuvyu() );
171 m_xMatchSesheZeje
->set_active( aOpt
.IsMatchSesheZeje() );
172 m_xMatchIaiya
->set_active( aOpt
.IsMatchIaiya() );
173 m_xMatchKiku
->set_active( aOpt
.IsMatchKiku() );
174 m_xIgnorePunctuation
->set_active( aOpt
.IsIgnorePunctuation() );
175 m_xIgnoreWhitespace
->set_active( aOpt
.IsIgnoreWhitespace() );
176 m_xMatchProlongedSoundMark
->set_active( aOpt
.IsIgnoreProlongedSoundMark() );
177 m_xIgnoreMiddleDot
->set_active( aOpt
.IsIgnoreMiddleDot() );
179 nTransliterationFlags
= GetTransliterationFlags_Impl();
180 DBG_ASSERT( nTransliterationFlags
== aOpt
.GetTransliterationFlags(),
181 "Transliteration settings different" );
183 m_xMatchCase
->save_state();
184 m_xMatchFullHalfWidth
->save_state();
185 m_xMatchHiraganaKatakana
->save_state();
186 m_xMatchContractions
->save_state();
187 m_xMatchMinusDashChoon
->save_state();
188 m_xMatchRepeatCharMarks
->save_state();
189 m_xMatchVariantFormKanji
->save_state();
190 m_xMatchOldKanaForms
->save_state();
191 m_xMatchDiziDuzu
->save_state();
192 m_xMatchBavaHafa
->save_state();
193 m_xMatchTsithichiDhizi
->save_state();
194 m_xMatchHyuiyuByuvyu
->save_state();
195 m_xMatchSesheZeje
->save_state();
196 m_xMatchIaiya
->save_state();
197 m_xMatchKiku
->save_state();
198 m_xIgnorePunctuation
->save_state();
199 m_xIgnoreWhitespace
->save_state();
200 m_xMatchProlongedSoundMark
->save_state();
201 m_xIgnoreMiddleDot
->save_state();
205 bool SvxJSearchOptionsPage::FillItemSet( SfxItemSet
* )
207 TransliterationFlags nOldVal
= nTransliterationFlags
;
208 nTransliterationFlags
= GetTransliterationFlags_Impl();
209 bool bModified
= nOldVal
!= nTransliterationFlags
;
215 SvtSearchOptions aOpt
;
216 bool bNewVal
, bChanged
;
218 bNewVal
= m_xMatchCase
->get_active(); //! treat as equal uppercase/lowercase
219 bChanged
= m_xMatchCase
->get_state_changed_from_saved();
222 aOpt
.SetMatchCase(!bNewVal
);
225 bNewVal
= m_xMatchFullHalfWidth
->get_active();
226 bChanged
= m_xMatchFullHalfWidth
->get_state_changed_from_saved();
229 aOpt
.SetMatchFullHalfWidthForms( bNewVal
);
232 bNewVal
= m_xMatchHiraganaKatakana
->get_active();
233 bChanged
= m_xMatchHiraganaKatakana
->get_state_changed_from_saved();
236 aOpt
.SetMatchHiraganaKatakana( bNewVal
);
239 bNewVal
= m_xMatchContractions
->get_active();
240 bChanged
= m_xMatchContractions
->get_state_changed_from_saved();
243 aOpt
.SetMatchContractions( bNewVal
);
246 bNewVal
= m_xMatchMinusDashChoon
->get_active();
247 bChanged
= m_xMatchMinusDashChoon
->get_state_changed_from_saved();
250 aOpt
.SetMatchMinusDashChoon( bNewVal
);
253 bNewVal
= m_xMatchRepeatCharMarks
->get_active();
254 bChanged
= m_xMatchRepeatCharMarks
->get_state_changed_from_saved();
257 aOpt
.SetMatchRepeatCharMarks( bNewVal
);
260 bNewVal
= m_xMatchVariantFormKanji
->get_active();
261 bChanged
= m_xMatchVariantFormKanji
->get_state_changed_from_saved();
264 aOpt
.SetMatchVariantFormKanji( bNewVal
);
267 bNewVal
= m_xMatchOldKanaForms
->get_active();
268 bChanged
= m_xMatchOldKanaForms
->get_state_changed_from_saved();
271 aOpt
.SetMatchOldKanaForms( bNewVal
);
274 bNewVal
= m_xMatchDiziDuzu
->get_active();
275 bChanged
= m_xMatchDiziDuzu
->get_state_changed_from_saved();
278 aOpt
.SetMatchDiziDuzu( bNewVal
);
281 bNewVal
= m_xMatchBavaHafa
->get_active();
282 bChanged
= m_xMatchBavaHafa
->get_state_changed_from_saved();
285 aOpt
.SetMatchBavaHafa( bNewVal
);
288 bNewVal
= m_xMatchTsithichiDhizi
->get_active();
289 bChanged
= m_xMatchTsithichiDhizi
->get_state_changed_from_saved();
292 aOpt
.SetMatchTsithichiDhizi( bNewVal
);
295 bNewVal
= m_xMatchHyuiyuByuvyu
->get_active();
296 bChanged
= m_xMatchHyuiyuByuvyu
->get_state_changed_from_saved();
299 aOpt
.SetMatchHyuiyuByuvyu( bNewVal
);
302 bNewVal
= m_xMatchSesheZeje
->get_active();
303 bChanged
= m_xMatchSesheZeje
->get_state_changed_from_saved();
306 aOpt
.SetMatchSesheZeje( bNewVal
);
309 bNewVal
= m_xMatchIaiya
->get_active();
310 bChanged
= m_xMatchIaiya
->get_state_changed_from_saved();
313 aOpt
.SetMatchIaiya( bNewVal
);
316 bNewVal
= m_xMatchKiku
->get_active();
317 bChanged
= m_xMatchKiku
->get_state_changed_from_saved();
320 aOpt
.SetMatchKiku( bNewVal
);
323 bNewVal
= m_xIgnorePunctuation
->get_active();
324 bChanged
= m_xIgnorePunctuation
->get_state_changed_from_saved();
327 aOpt
.SetIgnorePunctuation( bNewVal
);
330 bNewVal
= m_xIgnoreWhitespace
->get_active();
331 bChanged
= m_xIgnoreWhitespace
->get_state_changed_from_saved();
334 aOpt
.SetIgnoreWhitespace( bNewVal
);
337 bNewVal
= m_xMatchProlongedSoundMark
->get_active();
338 bChanged
= m_xMatchProlongedSoundMark
->get_state_changed_from_saved();
341 aOpt
.SetIgnoreProlongedSoundMark( bNewVal
);
344 bNewVal
= m_xIgnoreMiddleDot
->get_active();
345 bChanged
= m_xIgnoreMiddleDot
->get_state_changed_from_saved();
348 aOpt
.SetIgnoreMiddleDot( bNewVal
);
358 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */