LibreOffice Module cui (master)  1
optjsearch.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <tools/debug.hxx>
21 #include <unotools/searchopt.hxx>
23 #include "optjsearch.hxx"
24 
25 using namespace com::sun::star::i18n;
26 
27 
29  : SfxTabPage(pParent, "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 {
50  bSaveOptions = true;
51  nTransliterationFlags = TransliterationFlags::NONE;
52 }
53 
55 {
56  disposeOnce();
57 }
58 
60 {
61  return VclPtr<SvxJSearchOptionsPage>::Create(pParent, *rSet);
62 }
63 
65 {
66  bool bVal(nSettings & TransliterationFlags::IGNORE_CASE);
67  m_xMatchCase ->set_active( bVal );
68  bVal = bool(nSettings & TransliterationFlags::IGNORE_WIDTH);
69  m_xMatchFullHalfWidth ->set_active( bVal );
70  bVal = bool(nSettings & TransliterationFlags::IGNORE_KANA);
71  m_xMatchHiraganaKatakana ->set_active( bVal );
72  bVal = bool(nSettings & TransliterationFlags::ignoreSize_ja_JP);
73  m_xMatchContractions ->set_active( bVal );
74  bVal = bool(nSettings & TransliterationFlags::ignoreMinusSign_ja_JP);
75  m_xMatchMinusDashChoon ->set_active( bVal );
76  bVal = bool(nSettings & TransliterationFlags::ignoreIterationMark_ja_JP);
77  m_xMatchRepeatCharMarks ->set_active( bVal );
78  bVal = bool(nSettings & TransliterationFlags::ignoreTraditionalKanji_ja_JP);
79  m_xMatchVariantFormKanji ->set_active( bVal );
80  bVal = bool(nSettings & TransliterationFlags::ignoreTraditionalKana_ja_JP);
81  m_xMatchOldKanaForms ->set_active( bVal );
82  bVal = bool(nSettings & TransliterationFlags::ignoreZiZu_ja_JP);
83  m_xMatchDiziDuzu ->set_active( bVal );
84  bVal = bool(nSettings & TransliterationFlags::ignoreBaFa_ja_JP);
85  m_xMatchBavaHafa ->set_active( bVal );
86  bVal = bool(nSettings & TransliterationFlags::ignoreTiJi_ja_JP);
87  m_xMatchTsithichiDhizi ->set_active( bVal );
88  bVal = bool(nSettings & TransliterationFlags::ignoreHyuByu_ja_JP);
89  m_xMatchHyuiyuByuvyu ->set_active( bVal );
90  bVal = bool(nSettings & TransliterationFlags::ignoreSeZe_ja_JP);
91  m_xMatchSesheZeje ->set_active( bVal );
92  bVal = bool(nSettings & TransliterationFlags::ignoreIandEfollowedByYa_ja_JP);
93  m_xMatchIaiya ->set_active( bVal );
94  bVal = bool(nSettings & TransliterationFlags::ignoreKiKuFollowedBySa_ja_JP);
95  m_xMatchKiku ->set_active( bVal );
96  bVal = bool(nSettings & TransliterationFlags::ignoreSeparator_ja_JP);
97  m_xIgnorePunctuation ->set_active( bVal );
98  bVal = bool(nSettings & TransliterationFlags::ignoreSpace_ja_JP);
99  m_xIgnoreWhitespace ->set_active( bVal );
100  bVal = bool(nSettings & TransliterationFlags::ignoreProlongedSoundMark_ja_JP);
101  m_xMatchProlongedSoundMark->set_active( bVal );
102  bVal = bool(nSettings & TransliterationFlags::ignoreMiddleDot_ja_JP);
103  m_xIgnoreMiddleDot ->set_active( bVal );
104 
105  nTransliterationFlags = nSettings;
106 }
107 
109 {
110  TransliterationFlags nTmp = TransliterationFlags::NONE;
111  if (m_xMatchCase->get_active())
112  nTmp |= TransliterationFlags::IGNORE_CASE;
113  if (m_xMatchFullHalfWidth->get_active())
114  nTmp |= TransliterationFlags::IGNORE_WIDTH;
115  if (m_xMatchHiraganaKatakana->get_active())
116  nTmp |= TransliterationFlags::IGNORE_KANA;
117  if (m_xMatchContractions->get_active())
118  nTmp |= TransliterationFlags::ignoreSize_ja_JP;
119  if (m_xMatchMinusDashChoon->get_active())
120  nTmp |= TransliterationFlags::ignoreMinusSign_ja_JP;
121  if (m_xMatchRepeatCharMarks->get_active())
122  nTmp |= TransliterationFlags::ignoreIterationMark_ja_JP;
123  if (m_xMatchVariantFormKanji->get_active())
124  nTmp |= TransliterationFlags::ignoreTraditionalKanji_ja_JP;
125  if (m_xMatchOldKanaForms->get_active())
126  nTmp |= TransliterationFlags::ignoreTraditionalKana_ja_JP;
127  if (m_xMatchDiziDuzu->get_active())
128  nTmp |= TransliterationFlags::ignoreZiZu_ja_JP;
129  if (m_xMatchBavaHafa->get_active())
130  nTmp |= TransliterationFlags::ignoreBaFa_ja_JP;
131  if (m_xMatchTsithichiDhizi->get_active())
132  nTmp |= TransliterationFlags::ignoreTiJi_ja_JP;
133  if (m_xMatchHyuiyuByuvyu->get_active())
134  nTmp |= TransliterationFlags::ignoreHyuByu_ja_JP;
135  if (m_xMatchSesheZeje->get_active())
136  nTmp |= TransliterationFlags::ignoreSeZe_ja_JP;
137  if (m_xMatchIaiya->get_active())
138  nTmp |= TransliterationFlags::ignoreIandEfollowedByYa_ja_JP;
139  if (m_xMatchKiku->get_active())
140  nTmp |= TransliterationFlags::ignoreKiKuFollowedBySa_ja_JP;
141  if (m_xIgnorePunctuation->get_active())
142  nTmp |= TransliterationFlags::ignoreSeparator_ja_JP;
143  if (m_xIgnoreWhitespace->get_active())
144  nTmp |= TransliterationFlags::ignoreSpace_ja_JP;
145  if (m_xMatchProlongedSoundMark->get_active())
146  nTmp |= TransliterationFlags::ignoreProlongedSoundMark_ja_JP;
147  if (m_xIgnoreMiddleDot->get_active())
148  nTmp |= TransliterationFlags::ignoreMiddleDot_ja_JP;
149 
150  nTransliterationFlags = nTmp;
151  return nTransliterationFlags;
152 }
153 
154 
156 {
157  SvtSearchOptions aOpt;
158 
159  // read settings from configuration
160  m_xMatchCase ->set_active(!aOpt.IsMatchCase() );
161  m_xMatchFullHalfWidth ->set_active( aOpt.IsMatchFullHalfWidthForms() );
162  m_xMatchHiraganaKatakana ->set_active( aOpt.IsMatchHiraganaKatakana() );
163  m_xMatchContractions ->set_active( aOpt.IsMatchContractions() );
164  m_xMatchMinusDashChoon ->set_active( aOpt.IsMatchMinusDashChoon() );
165  m_xMatchRepeatCharMarks ->set_active( aOpt.IsMatchRepeatCharMarks() );
166  m_xMatchVariantFormKanji ->set_active( aOpt.IsMatchVariantFormKanji() );
167  m_xMatchOldKanaForms ->set_active( aOpt.IsMatchOldKanaForms() );
168  m_xMatchDiziDuzu ->set_active( aOpt.IsMatchDiziDuzu() );
169  m_xMatchBavaHafa ->set_active( aOpt.IsMatchBavaHafa() );
170  m_xMatchTsithichiDhizi ->set_active( aOpt.IsMatchTsithichiDhizi() );
171  m_xMatchHyuiyuByuvyu ->set_active( aOpt.IsMatchHyuiyuByuvyu() );
172  m_xMatchSesheZeje ->set_active( aOpt.IsMatchSesheZeje() );
173  m_xMatchIaiya ->set_active( aOpt.IsMatchIaiya() );
174  m_xMatchKiku ->set_active( aOpt.IsMatchKiku() );
175  m_xIgnorePunctuation ->set_active( aOpt.IsIgnorePunctuation() );
176  m_xIgnoreWhitespace ->set_active( aOpt.IsIgnoreWhitespace() );
178  m_xIgnoreMiddleDot ->set_active( aOpt.IsIgnoreMiddleDot() );
179 
182  "Transliteration settings different" );
183 
184  m_xMatchCase ->save_state();
185  m_xMatchFullHalfWidth ->save_state();
186  m_xMatchHiraganaKatakana ->save_state();
187  m_xMatchContractions ->save_state();
188  m_xMatchMinusDashChoon ->save_state();
189  m_xMatchRepeatCharMarks ->save_state();
190  m_xMatchVariantFormKanji ->save_state();
191  m_xMatchOldKanaForms ->save_state();
192  m_xMatchDiziDuzu ->save_state();
193  m_xMatchBavaHafa ->save_state();
194  m_xMatchTsithichiDhizi ->save_state();
195  m_xMatchHyuiyuByuvyu ->save_state();
196  m_xMatchSesheZeje ->save_state();
197  m_xMatchIaiya ->save_state();
198  m_xMatchKiku ->save_state();
199  m_xIgnorePunctuation ->save_state();
200  m_xIgnoreWhitespace ->save_state();
201  m_xMatchProlongedSoundMark ->save_state();
202  m_xIgnoreMiddleDot ->save_state();
203 }
204 
205 
207 {
210  bool bModified = nOldVal != nTransliterationFlags;
211 
212  if (!bSaveOptions)
213  return bModified;
214 
215  bModified = false;
216  SvtSearchOptions aOpt;
217  bool bNewVal, bChanged;
218 
219  bNewVal = m_xMatchCase->get_active();
220  bChanged = m_xMatchCase->get_state_changed_from_saved();
221  if (bChanged)
222  {
223  aOpt.SetMatchCase(!bNewVal );
224  bModified = true;
225  }
226  bNewVal = m_xMatchFullHalfWidth->get_active();
227  bChanged = m_xMatchFullHalfWidth->get_state_changed_from_saved();
228  if (bChanged)
229  {
230  aOpt.SetMatchFullHalfWidthForms( bNewVal );
231  bModified = true;
232  }
233  bNewVal = m_xMatchHiraganaKatakana->get_active();
234  bChanged = m_xMatchHiraganaKatakana->get_state_changed_from_saved();
235  if (bChanged)
236  {
237  aOpt.SetMatchHiraganaKatakana( bNewVal );
238  bModified = true;
239  }
240  bNewVal = m_xMatchContractions->get_active();
241  bChanged = m_xMatchContractions->get_state_changed_from_saved();
242  if (bChanged)
243  {
244  aOpt.SetMatchContractions( bNewVal );
245  bModified = true;
246  }
247  bNewVal = m_xMatchMinusDashChoon->get_active();
248  bChanged = m_xMatchMinusDashChoon->get_state_changed_from_saved();
249  if (bChanged)
250  {
251  aOpt.SetMatchMinusDashChoon( bNewVal );
252  bModified = true;
253  }
254  bNewVal = m_xMatchRepeatCharMarks->get_active();
255  bChanged = m_xMatchRepeatCharMarks->get_state_changed_from_saved();
256  if (bChanged)
257  {
258  aOpt.SetMatchRepeatCharMarks( bNewVal );
259  bModified = true;
260  }
261  bNewVal = m_xMatchVariantFormKanji->get_active();
262  bChanged = m_xMatchVariantFormKanji->get_state_changed_from_saved();
263  if (bChanged)
264  {
265  aOpt.SetMatchVariantFormKanji( bNewVal );
266  bModified = true;
267  }
268  bNewVal = m_xMatchOldKanaForms->get_active();
269  bChanged = m_xMatchOldKanaForms->get_state_changed_from_saved();
270  if (bChanged)
271  {
272  aOpt.SetMatchOldKanaForms( bNewVal );
273  bModified = true;
274  }
275  bNewVal = m_xMatchDiziDuzu->get_active();
276  bChanged = m_xMatchDiziDuzu->get_state_changed_from_saved();
277  if (bChanged)
278  {
279  aOpt.SetMatchDiziDuzu( bNewVal );
280  bModified = true;
281  }
282  bNewVal = m_xMatchBavaHafa->get_active();
283  bChanged = m_xMatchBavaHafa->get_state_changed_from_saved();
284  if (bChanged)
285  {
286  aOpt.SetMatchBavaHafa( bNewVal );
287  bModified = true;
288  }
289  bNewVal = m_xMatchTsithichiDhizi->get_active();
290  bChanged = m_xMatchTsithichiDhizi->get_state_changed_from_saved();
291  if (bChanged)
292  {
293  aOpt.SetMatchTsithichiDhizi( bNewVal );
294  bModified = true;
295  }
296  bNewVal = m_xMatchHyuiyuByuvyu->get_active();
297  bChanged = m_xMatchHyuiyuByuvyu->get_state_changed_from_saved();
298  if (bChanged)
299  {
300  aOpt.SetMatchHyuiyuByuvyu( bNewVal );
301  bModified = true;
302  }
303  bNewVal = m_xMatchSesheZeje->get_active();
304  bChanged = m_xMatchSesheZeje->get_state_changed_from_saved();
305  if (bChanged)
306  {
307  aOpt.SetMatchSesheZeje( bNewVal );
308  bModified = true;
309  }
310  bNewVal = m_xMatchIaiya->get_active();
311  bChanged = m_xMatchIaiya->get_state_changed_from_saved();
312  if (bChanged)
313  {
314  aOpt.SetMatchIaiya( bNewVal );
315  bModified = true;
316  }
317  bNewVal = m_xMatchKiku->get_active();
318  bChanged = m_xMatchKiku->get_state_changed_from_saved();
319  if (bChanged)
320  {
321  aOpt.SetMatchKiku( bNewVal );
322  bModified = true;
323  }
324  bNewVal = m_xIgnorePunctuation->get_active();
325  bChanged = m_xIgnorePunctuation->get_state_changed_from_saved();
326  if (bChanged)
327  {
328  aOpt.SetIgnorePunctuation( bNewVal );
329  bModified = true;
330  }
331  bNewVal = m_xIgnoreWhitespace->get_active();
332  bChanged = m_xIgnoreWhitespace->get_state_changed_from_saved();
333  if (bChanged)
334  {
335  aOpt.SetIgnoreWhitespace( bNewVal );
336  bModified = true;
337  }
338  bNewVal = m_xMatchProlongedSoundMark->get_active();
339  bChanged = m_xMatchProlongedSoundMark->get_state_changed_from_saved();
340  if (bChanged)
341  {
342  aOpt.SetIgnoreProlongedSoundMark( bNewVal );
343  bModified = true;
344  }
345  bNewVal = m_xIgnoreMiddleDot->get_active();
346  bChanged = m_xIgnoreMiddleDot->get_state_changed_from_saved();
347  if (bChanged)
348  {
349  aOpt.SetIgnoreMiddleDot( bNewVal );
350  bModified = true;
351  }
352 
353  if (bModified)
354  aOpt.Commit();
355 
356  return bModified;
357 }
358 
359 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::CheckButton > m_xIgnoreWhitespace
Definition: optjsearch.hxx:50
std::unique_ptr< weld::CheckButton > m_xMatchContractions
Definition: optjsearch.hxx:35
TransliterationFlags GetTransliterationFlags_Impl()
Definition: optjsearch.cxx:108
std::unique_ptr< weld::CheckButton > m_xMatchFullHalfWidth
Definition: optjsearch.hxx:33
std::unique_ptr< weld::CheckButton > m_xIgnorePunctuation
Definition: optjsearch.hxx:49
std::unique_ptr< weld::CheckButton > m_xMatchBavaHafa
Definition: optjsearch.hxx:41
std::unique_ptr< weld::CheckButton > m_xMatchHiraganaKatakana
Definition: optjsearch.hxx:34
std::unique_ptr< weld::CheckButton > m_xMatchVariantFormKanji
Definition: optjsearch.hxx:38
bool IsMatchFullHalfWidthForms() const
bool IsMatchMinusDashChoon() const
void SetMatchTsithichiDhizi(bool bVal)
bool IsMatchContractions() const
void SetMatchMinusDashChoon(bool bVal)
bool IsMatchVariantFormKanji() const
std::unique_ptr< weld::CheckButton > m_xMatchTsithichiDhizi
Definition: optjsearch.hxx:42
virtual void Reset(const SfxItemSet *rSet) override
Definition: optjsearch.cxx:155
void SetMatchSesheZeje(bool bVal)
void SetIgnoreWhitespace(bool bVal)
void SetMatchContractions(bool bVal)
void SetMatchHyuiyuByuvyu(bool bVal)
bool IsMatchDiziDuzu() const
std::unique_ptr< weld::CheckButton > m_xMatchCase
Definition: optjsearch.hxx:32
bool IsIgnorePunctuation() const
bool IsMatchSesheZeje() const
std::unique_ptr< weld::CheckButton > m_xMatchProlongedSoundMark
Definition: optjsearch.hxx:47
bool IsIgnoreMiddleDot() const
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optjsearch.cxx:206
static VclPtr< SfxTabPage > Create(TabPageParent pParent, const SfxItemSet *rSet)
Definition: optjsearch.cxx:59
void SetIgnoreProlongedSoundMark(bool bVal)
TransliterationFlags
std::unique_ptr< weld::CheckButton > m_xMatchSesheZeje
Definition: optjsearch.hxx:44
std::unique_ptr< weld::CheckButton > m_xMatchOldKanaForms
Definition: optjsearch.hxx:39
bool IsMatchIaiya() const
bool IsMatchCase() const
bool IsMatchTsithichiDhizi() const
#define DBG_ASSERT(sCon, aError)
std::unique_ptr< weld::CheckButton > m_xIgnoreMiddleDot
Definition: optjsearch.hxx:51
std::unique_ptr< weld::CheckButton > m_xMatchIaiya
Definition: optjsearch.hxx:45
virtual ~SvxJSearchOptionsPage() override
Definition: optjsearch.cxx:54
bool IsIgnoreProlongedSoundMark() const
void SetMatchDiziDuzu(bool bVal)
bool IsIgnoreWhitespace() const
void SetMatchFullHalfWidthForms(bool bVal)
std::unique_ptr< weld::CheckButton > m_xMatchKiku
Definition: optjsearch.hxx:46
bool IsMatchRepeatCharMarks() const
void SetMatchRepeatCharMarks(bool bVal)
void SetMatchHiraganaKatakana(bool bVal)
TransliterationFlags nTransliterationFlags
Definition: optjsearch.hxx:53
void SetMatchKiku(bool bVal)
void SetMatchIaiya(bool bVal)
void SetTransliterationFlags(TransliterationFlags nSettings)
Definition: optjsearch.cxx:64
void SetMatchVariantFormKanji(bool bVal)
bool IsMatchHyuiyuByuvyu() const
void SetIgnoreMiddleDot(bool bVal)
std::unique_ptr< weld::CheckButton > m_xMatchDiziDuzu
Definition: optjsearch.hxx:40
static VclPtr< reference_type > Create(Arg &&...arg)
void SetMatchCase(bool bVal)
std::unique_ptr< weld::CheckButton > m_xMatchMinusDashChoon
Definition: optjsearch.hxx:36
bool IsMatchBavaHafa() const
std::unique_ptr< weld::CheckButton > m_xMatchHyuiyuByuvyu
Definition: optjsearch.hxx:43
bool IsMatchOldKanaForms() const
SvxJSearchOptionsPage(TabPageParent pParent, const SfxItemSet &rSet)
Definition: optjsearch.cxx:28
void SetMatchOldKanaForms(bool bVal)
bool IsMatchKiku() const
bool IsMatchHiraganaKatakana() const
void SetIgnorePunctuation(bool bVal)
std::unique_ptr< weld::CheckButton > m_xMatchRepeatCharMarks
Definition: optjsearch.hxx:37
void SetMatchBavaHafa(bool bVal)
TransliterationFlags GetTransliterationFlags() const