Line data Source code
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 <vcl/msgbox.hxx>
22 : #include <vcl/svapp.hxx>
23 : #include <tools/shl.hxx>
24 : #include <dialmgr.hxx>
25 : #include <sfx2/tabdlg.hxx>
26 : #include <osl/mutex.hxx>
27 : #include <sfx2/app.hxx>
28 : #include <cuires.hrc>
29 : #include <svl/filerec.hxx>
30 : #include <svx/fmsrccfg.hxx>
31 : #include <svx/fmsrcimp.hxx>
32 : #include "fmsearch.hrc"
33 : #include "cuifmsearch.hxx"
34 : #include <svx/srchdlg.hxx>
35 : #include <svl/cjkoptions.hxx>
36 : #include <com/sun/star/i18n/TransliterationModules.hpp>
37 : #include <comphelper/processfactory.hxx>
38 : #include <comphelper/string.hxx>
39 : #include <svx/svxdlg.hxx>
40 : #include <sal/macros.h>
41 :
42 : using namespace ::com::sun::star::uno;
43 : using namespace ::com::sun::star::i18n;
44 : using namespace ::svxform;
45 : using namespace ::com::sun::star::sdbc;
46 : using namespace ::com::sun::star::util;
47 :
48 : #define MAX_HISTORY_ENTRIES 50
49 :
50 : //------------------------------------------------------------------------
51 0 : void FmSearchDialog::initCommon( const Reference< XResultSet >& _rxCursor )
52 : {
53 : // init the engine
54 : DBG_ASSERT( m_pSearchEngine, "FmSearchDialog::initCommon: have no engine!" );
55 0 : m_pSearchEngine->SetProgressHandler(LINK(this, FmSearchDialog, OnSearchProgress));
56 :
57 : // some layout changes according to available CJK options
58 0 : SvtCJKOptions aCJKOptions;
59 0 : if (!aCJKOptions.IsJapaneseFindEnabled())
60 : {
61 0 : sal_Int32 nUpper = m_cbApprox.GetPosPixel().Y();
62 0 : sal_Int32 nDifference = m_aSoundsLikeCJKSettings.GetPosPixel().Y() - nUpper;
63 :
64 : // hide the options for the japanese search
65 0 : Control* pFieldsToMove[] = { &m_flState, &m_ftRecordLabel, &m_ftRecord, &m_ftHint };
66 0 : implMoveControls(pFieldsToMove, SAL_N_ELEMENTS(pFieldsToMove), nDifference, &m_flOptions);
67 :
68 0 : m_aSoundsLikeCJK.Hide();
69 0 : m_aSoundsLikeCJKSettings.Hide();
70 : }
71 :
72 0 : if (!aCJKOptions.IsCJKFontEnabled())
73 : {
74 0 : m_aHalfFullFormsCJK.Hide();
75 :
76 : // never ignore the width (ignoring is expensive) if the option is not available at all
77 0 : m_pSearchEngine->SetIgnoreWidthCJK( sal_False );
78 : }
79 :
80 : // some initial record texts
81 0 : m_ftRecord.SetText( String::CreateFromInt32( _rxCursor->getRow() ) );
82 0 : m_pbClose.SetHelpText(String());
83 0 : }
84 :
85 : //------------------------------------------------------------------------
86 0 : FmSearchDialog::FmSearchDialog(Window* pParent, const OUString& sInitialText, const ::std::vector< String >& _rContexts, sal_Int16 nInitialContext,
87 : const Link& lnkContextSupplier)
88 0 : :ModalDialog(pParent, CUI_RES(RID_SVXDLG_SEARCHFORM))
89 0 : ,m_flSearchFor (this, CUI_RES(FL_SEARCHFOR))
90 0 : ,m_rbSearchForText (this, CUI_RES(RB_SEARCHFORTEXT))
91 0 : ,m_rbSearchForNull (this, CUI_RES(RB_SEARCHFORNULL))
92 0 : ,m_rbSearchForNotNull (this, CUI_RES(RB_SEARCHFORNOTNULL))
93 0 : ,m_cmbSearchText (this, CUI_RES(CMB_SEARCHTEXT))
94 0 : ,m_flWhere (this, CUI_RES(FL_WHERE))
95 0 : ,m_ftForm (this, CUI_RES(FT_FORM))
96 0 : ,m_lbForm (this, CUI_RES(LB_FORM))
97 0 : ,m_rbAllFields (this, CUI_RES(RB_ALLFIELDS))
98 0 : ,m_rbSingleField (this, CUI_RES(RB_SINGLEFIELD))
99 0 : ,m_lbField (this, CUI_RES(LB_FIELD))
100 0 : ,m_flOptions (this, CUI_RES(FL_OPTIONS))
101 0 : ,m_ftPosition (this, CUI_RES(FT_POSITION))
102 0 : ,m_lbPosition (this, CUI_RES(LB_POSITION))
103 0 : ,m_cbUseFormat (this, CUI_RES(CB_USEFORMATTER))
104 0 : ,m_cbCase (this, CUI_RES(CB_CASE))
105 0 : ,m_cbBackwards (this, CUI_RES(CB_BACKWARD))
106 0 : ,m_cbStartOver (this, CUI_RES(CB_STARTOVER))
107 0 : ,m_cbWildCard (this, CUI_RES(CB_WILDCARD))
108 0 : ,m_cbRegular (this, CUI_RES(CB_REGULAR))
109 0 : ,m_cbApprox (this, CUI_RES(CB_APPROX))
110 0 : ,m_pbApproxSettings (this, CUI_RES(PB_APPROXSETTINGS))
111 0 : ,m_aHalfFullFormsCJK (this, CUI_RES(CB_HALFFULLFORMS))
112 0 : ,m_aSoundsLikeCJK (this, CUI_RES(CB_SOUNDSLIKECJK))
113 0 : ,m_aSoundsLikeCJKSettings (this, CUI_RES(PB_SOUNDSLIKESETTINGS))
114 0 : ,m_flState (this, CUI_RES(FL_STATE))
115 0 : ,m_ftRecordLabel (this, CUI_RES(FT_RECORDLABEL))
116 0 : ,m_ftRecord (this, CUI_RES(FT_RECORD))
117 0 : ,m_ftHint (this, CUI_RES(FT_HINT))
118 0 : ,m_pbSearchAgain (this, CUI_RES(PB_SEARCH))
119 0 : ,m_pbClose (this, CUI_RES(1))
120 0 : ,m_pbHelp (this, CUI_RES(1))
121 : ,m_sSearch ( m_pbSearchAgain.GetText() )
122 : ,m_sCancel ( Button::GetStandardText( BUTTON_CANCEL ) )
123 : ,m_pPreSearchFocus( NULL )
124 : ,m_lnkContextSupplier(lnkContextSupplier)
125 0 : ,m_pConfig( NULL )
126 : {
127 : DBG_ASSERT(m_lnkContextSupplier.IsSet(), "FmSearchDialog::FmSearchDialog : have no ContextSupplier !");
128 :
129 0 : FmSearchContext fmscInitial;
130 0 : fmscInitial.nContext = nInitialContext;
131 0 : m_lnkContextSupplier.Call(&fmscInitial);
132 : DBG_ASSERT(fmscInitial.xCursor.is(), "FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplier !");
133 : DBG_ASSERT(comphelper::string::getTokenCount(fmscInitial.strUsedFields, ';') == (xub_StrLen)fmscInitial.arrFields.size(),
134 : "FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplied !");
135 : #if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
136 : for (sal_Int32 i=0; i<(sal_Int32)fmscInitial.arrFields.size(); ++i)
137 : DBG_ASSERT(fmscInitial.arrFields.at(i).is(), "FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplier !");
138 : #endif // (OSL_DEBUG_LEVEL > 1) || DBG_UTIL
139 :
140 0 : for ( ::std::vector< String >::const_iterator context = _rContexts.begin();
141 0 : context != _rContexts.end();
142 : ++context
143 : )
144 : {
145 0 : m_arrContextFields.push_back(String());
146 0 : m_lbForm.InsertEntry(*context);
147 : }
148 0 : m_lbForm.SelectEntryPos(nInitialContext);
149 :
150 0 : m_lbForm.SetSelectHdl(LINK(this, FmSearchDialog, OnContextSelection));
151 :
152 0 : if (m_arrContextFields.size() == 1)
153 : { // remove the context selection listbox and rearrange the controls accordingly
154 0 : sal_Int32 nUpper = m_lbForm.GetPosPixel().Y();
155 0 : sal_Int32 nDifference = m_rbAllFields.GetPosPixel().Y() - nUpper;
156 :
157 : // move all controls below the affected ones up
158 : Control* pFieldsToMove[] = { &m_rbAllFields, &m_rbSingleField, &m_lbField, &m_flOptions, &m_ftPosition, &m_lbPosition,
159 : &m_cbUseFormat, &m_cbCase, &m_cbBackwards, &m_cbStartOver, &m_cbWildCard, &m_cbRegular, &m_cbApprox,
160 : &m_pbApproxSettings, &m_aHalfFullFormsCJK, &m_aSoundsLikeCJK, &m_aSoundsLikeCJKSettings,
161 0 : &m_flState, &m_ftRecordLabel, &m_ftRecord, &m_ftHint };
162 :
163 0 : implMoveControls(pFieldsToMove, SAL_N_ELEMENTS(pFieldsToMove), nDifference, &m_flWhere);
164 :
165 0 : Point pt = m_rbAllFields.GetPosPixel();
166 0 : pt.X() = m_ftForm.GetPosPixel().X();
167 0 : m_rbAllFields.SetPosPixel( pt );
168 0 : pt = m_rbSingleField.GetPosPixel();
169 0 : pt.X() = m_ftForm.GetPosPixel().X();
170 0 : m_rbSingleField.SetPosPixel( pt );
171 :
172 : // hide dispensable controls
173 0 : m_ftForm.Hide();
174 0 : m_lbForm.Hide();
175 : }
176 :
177 : m_pSearchEngine = new FmSearchEngine(
178 0 : ::comphelper::getProcessComponentContext(), fmscInitial.xCursor, fmscInitial.strUsedFields, fmscInitial.arrFields, SM_ALLOWSCHEDULE );
179 0 : initCommon( fmscInitial.xCursor );
180 :
181 0 : if (fmscInitial.sFieldDisplayNames.Len() != 0)
182 : { // use the display names if supplied
183 : DBG_ASSERT(comphelper::string::getTokenCount(fmscInitial.sFieldDisplayNames, ';') == comphelper::string::getTokenCount(fmscInitial.strUsedFields, ';'),
184 : "FmSearchDialog::FmSearchDialog : invalid initial context description !");
185 0 : Init(fmscInitial.sFieldDisplayNames, sInitialText);
186 : }
187 : else
188 0 : Init(fmscInitial.strUsedFields, sInitialText);
189 0 : }
190 :
191 : //------------------------------------------------------------------------
192 0 : void FmSearchDialog::implMoveControls(
193 : Control** _ppControls,
194 : sal_Int32 _nControls,
195 : sal_Int32 _nUp,
196 : Control* /*_pToResize*/)
197 : {
198 0 : for (sal_Int32 i=0; i<_nControls; ++i)
199 : {
200 0 : Point pt = _ppControls[i]->GetPosPixel();
201 0 : pt.Y() -= _nUp;
202 0 : _ppControls[i]->SetPosPixel(pt);
203 : }
204 :
205 : // resize myself
206 0 : Size sz = GetSizePixel();
207 0 : sz.Height() -= _nUp;
208 0 : SetSizePixel(sz);
209 0 : }
210 :
211 : //------------------------------------------------------------------------
212 0 : FmSearchDialog::~FmSearchDialog()
213 : {
214 0 : if (m_aDelayedPaint.IsActive())
215 0 : m_aDelayedPaint.Stop();
216 :
217 0 : SaveParams();
218 :
219 0 : if (m_pConfig)
220 : {
221 0 : delete m_pConfig;
222 0 : m_pConfig = NULL;
223 : }
224 :
225 0 : delete m_pSearchEngine;
226 0 : }
227 :
228 : //------------------------------------------------------------------------
229 0 : void FmSearchDialog::Init(const OUString& strVisibleFields, const OUString& sInitialText)
230 : {
231 : //the initialization of all the Controls
232 0 : m_rbSearchForText.SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
233 0 : m_rbSearchForNull.SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
234 0 : m_rbSearchForNotNull.SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
235 :
236 0 : m_rbAllFields.SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
237 0 : m_rbSingleField.SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
238 :
239 0 : m_pbSearchAgain.SetClickHdl(LINK(this, FmSearchDialog, OnClickedSearchAgain));
240 0 : m_pbApproxSettings.SetClickHdl(LINK(this, FmSearchDialog, OnClickedSpecialSettings));
241 0 : m_aSoundsLikeCJKSettings.SetClickHdl(LINK(this, FmSearchDialog, OnClickedSpecialSettings));
242 :
243 0 : m_lbPosition.SetSelectHdl(LINK(this, FmSearchDialog, OnPositionSelected));
244 0 : m_lbField.SetSelectHdl(LINK(this, FmSearchDialog, OnFieldSelected));
245 :
246 0 : m_cmbSearchText.SetModifyHdl(LINK(this, FmSearchDialog, OnSearchTextModified));
247 0 : m_cmbSearchText.EnableAutocomplete(sal_False);
248 :
249 0 : m_cbUseFormat.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
250 0 : m_cbBackwards.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
251 0 : m_cbStartOver.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
252 0 : m_cbCase.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
253 0 : m_cbWildCard.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
254 0 : m_cbRegular.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
255 0 : m_cbApprox.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
256 0 : m_aHalfFullFormsCJK.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
257 0 : m_aSoundsLikeCJK.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
258 :
259 : // fill the listboxes
260 : // method of field comparison
261 : sal_uInt16 nResIds[] = {
262 : RID_STR_SEARCH_ANYWHERE,
263 : RID_STR_SEARCH_BEGINNING,
264 : RID_STR_SEARCH_END,
265 : RID_STR_SEARCH_WHOLE
266 0 : };
267 0 : for ( size_t i=0; i<SAL_N_ELEMENTS(nResIds); ++i )
268 0 : m_lbPosition.InsertEntry( String( CUI_RES( nResIds[i] ) ) );
269 0 : m_lbPosition.SelectEntryPos(MATCHING_ANYWHERE);
270 :
271 : // the field listbox
272 0 : for (sal_Int32 i=0; i < comphelper::string::getTokenCount(strVisibleFields, ';'); ++i)
273 0 : m_lbField.InsertEntry(comphelper::string::getToken(strVisibleFields, i, ';'));
274 :
275 :
276 0 : m_pConfig = new FmSearchConfigItem;
277 0 : LoadParams();
278 :
279 0 : m_cmbSearchText.SetText(sInitialText);
280 : // if the Edit-line has changed the text (e.g. because it contains
281 : // control characters, as can be the case with memo fields), I use
282 : // an empty OUString.
283 0 : OUString sRealSetText = m_cmbSearchText.GetText();
284 0 : if (!sRealSetText.equals(sInitialText))
285 0 : m_cmbSearchText.SetText(OUString());
286 0 : LINK(this, FmSearchDialog, OnSearchTextModified).Call(&m_cmbSearchText);
287 :
288 : // initial
289 0 : m_aDelayedPaint.SetTimeoutHdl(LINK(this, FmSearchDialog, OnDelayedPaint));
290 0 : m_aDelayedPaint.SetTimeout(500);
291 0 : EnableSearchUI(sal_True);
292 :
293 0 : if ( m_rbSearchForText.IsChecked() )
294 0 : m_cmbSearchText.GrabFocus();
295 :
296 0 : FreeResource();
297 0 : }
298 :
299 : //------------------------------------------------------------------------
300 0 : sal_Bool FmSearchDialog::Close()
301 : {
302 : // If the close button is disabled and ESC is pressed in a dialog,
303 : // then Frame will call Close anyway, which I don't want to happen
304 : // while I'm in the middle of a search (maybe one that's running
305 : // in its own thread)
306 0 : if (!m_pbClose.IsEnabled())
307 0 : return sal_False;
308 0 : return ModalDialog::Close();
309 : }
310 :
311 : //------------------------------------------------------------------------
312 0 : IMPL_LINK(FmSearchDialog, OnClickedFieldRadios, Button*, pButton)
313 : {
314 0 : if ((pButton == &m_rbSearchForText) || (pButton == &m_rbSearchForNull) || (pButton == &m_rbSearchForNotNull))
315 : {
316 0 : EnableSearchForDependees(sal_True);
317 : }
318 : else
319 : // en- or disable field list box accordingly
320 0 : if (pButton == &m_rbSingleField)
321 : {
322 0 : m_lbField.Enable();
323 0 : m_pSearchEngine->RebuildUsedFields(m_lbField.GetSelectEntryPos());
324 : }
325 : else
326 : {
327 0 : m_lbField.Disable();
328 0 : m_pSearchEngine->RebuildUsedFields(-1);
329 : }
330 :
331 0 : return 0;
332 : }
333 :
334 : //------------------------------------------------------------------------
335 0 : IMPL_LINK_NOARG(FmSearchDialog, OnClickedSearchAgain)
336 : {
337 0 : if (m_pbClose.IsEnabled())
338 : { // the button has the function 'search'
339 0 : OUString strThisRoundText = m_cmbSearchText.GetText();
340 : // to history
341 0 : m_cmbSearchText.RemoveEntry(strThisRoundText);
342 0 : m_cmbSearchText.InsertEntry(strThisRoundText, 0);
343 : // the remove/insert makes sure that a) the OUString does not appear twice and
344 : // that b) the last searched strings are at the beginning and limit the list length
345 0 : while (m_cmbSearchText.GetEntryCount() > MAX_HISTORY_ENTRIES)
346 0 : m_cmbSearchText.RemoveEntry(m_cmbSearchText.GetEntryCount()-1);
347 :
348 : // take out the 'overflow' hint
349 0 : m_ftHint.SetText(OUString());
350 0 : m_ftHint.Invalidate();
351 :
352 0 : if (m_cbStartOver.IsChecked())
353 : {
354 0 : m_cbStartOver.Check(sal_False);
355 0 : EnableSearchUI(sal_False);
356 0 : if (m_rbSearchForText.IsChecked())
357 0 : m_pSearchEngine->StartOver(strThisRoundText);
358 : else
359 0 : m_pSearchEngine->StartOverSpecial(m_rbSearchForNull.IsChecked());
360 : }
361 : else
362 : {
363 0 : EnableSearchUI(sal_False);
364 0 : if (m_rbSearchForText.IsChecked())
365 0 : m_pSearchEngine->SearchNext(strThisRoundText);
366 : else
367 0 : m_pSearchEngine->SearchNextSpecial(m_rbSearchForNull.IsChecked());
368 0 : }
369 : }
370 : else
371 : { // the button has the function 'cancel'
372 : DBG_ASSERT(m_pSearchEngine->GetSearchMode() != SM_BRUTE, "FmSearchDialog, OnClickedSearchAgain : falscher Modus !");
373 : // the CancelButton is usually only disabled, when working in a thread or with reschedule
374 0 : m_pSearchEngine->CancelSearch();
375 : // the ProgressHandler is called when it's really finished, here it's only a demand
376 : }
377 0 : return 0;
378 : }
379 :
380 : //------------------------------------------------------------------------
381 0 : IMPL_LINK(FmSearchDialog, OnClickedSpecialSettings, Button*, pButton )
382 : {
383 0 : if (&m_pbApproxSettings == pButton)
384 : {
385 0 : AbstractSvxSearchSimilarityDialog* pDlg = NULL;
386 :
387 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
388 0 : if ( pFact )
389 0 : pDlg = pFact->CreateSvxSearchSimilarityDialog( this, m_pSearchEngine->GetLevRelaxed(), m_pSearchEngine->GetLevOther(),
390 0 : m_pSearchEngine->GetLevShorter(), m_pSearchEngine->GetLevLonger() );
391 : DBG_ASSERT( pDlg, "FmSearchDialog, OnClickedSpecialSettings: could not load the dialog!" );
392 :
393 0 : if ( pDlg && pDlg->Execute() == RET_OK )
394 : {
395 0 : m_pSearchEngine->SetLevRelaxed( pDlg->IsRelaxed() );
396 0 : m_pSearchEngine->SetLevOther( pDlg->GetOther() );
397 0 : m_pSearchEngine->SetLevShorter(pDlg->GetShorter() );
398 0 : m_pSearchEngine->SetLevLonger( pDlg->GetLonger() );
399 : }
400 0 : delete pDlg;
401 : }
402 0 : else if (&m_aSoundsLikeCJKSettings == pButton)
403 : {
404 0 : SfxItemSet aSet( SFX_APP()->GetPool() );
405 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
406 0 : if(pFact)
407 : {
408 0 : AbstractSvxJSearchOptionsDialog* aDlg = pFact->CreateSvxJSearchOptionsDialog( this, aSet, m_pSearchEngine->GetTransliterationFlags() );
409 : DBG_ASSERT(aDlg, "Dialogdiet fail!");
410 0 : aDlg->Execute();
411 :
412 :
413 0 : sal_Int32 nFlags = aDlg->GetTransliterationFlags();
414 0 : m_pSearchEngine->SetTransliterationFlags(nFlags);
415 :
416 0 : m_cbCase.Check(m_pSearchEngine->GetCaseSensitive());
417 0 : OnCheckBoxToggled( &m_cbCase );
418 0 : m_aHalfFullFormsCJK.Check( !m_pSearchEngine->GetIgnoreWidthCJK() );
419 0 : OnCheckBoxToggled( &m_aHalfFullFormsCJK );
420 0 : delete aDlg;
421 0 : }
422 : }
423 :
424 0 : return 0;
425 : }
426 :
427 : //------------------------------------------------------------------------
428 0 : IMPL_LINK_NOARG(FmSearchDialog, OnSearchTextModified)
429 : {
430 0 : if ((m_cmbSearchText.GetText().Len() != 0) || !m_rbSearchForText.IsChecked())
431 0 : m_pbSearchAgain.Enable();
432 : else
433 0 : m_pbSearchAgain.Disable();
434 :
435 0 : m_pSearchEngine->InvalidatePreviousLoc();
436 0 : return 0;
437 : }
438 :
439 : //------------------------------------------------------------------------
440 0 : IMPL_LINK(FmSearchDialog, OnPositionSelected, ListBox*, pBox)
441 : {
442 : (void) pBox; // avoid warning
443 : DBG_ASSERT(pBox->GetSelectEntryCount() == 1, "FmSearchDialog::OnMethodSelected : unerwartet : nicht genau ein Eintrag selektiert !");
444 :
445 0 : m_pSearchEngine->SetPosition(m_lbPosition.GetSelectEntryPos());
446 0 : return 0;
447 : }
448 :
449 : //------------------------------------------------------------------------
450 0 : IMPL_LINK(FmSearchDialog, OnFieldSelected, ListBox*, pBox)
451 : {
452 : (void) pBox; // avoid warning
453 : DBG_ASSERT(pBox->GetSelectEntryCount() == 1, "FmSearchDialog::OnFieldSelected : unerwartet : nicht genau ein Eintrag selektiert !");
454 :
455 0 : m_pSearchEngine->RebuildUsedFields(m_rbAllFields.IsChecked() ? -1 : (sal_Int16)m_lbField.GetSelectEntryPos());
456 : // calls m_pSearchEngine->InvalidatePreviousLoc too
457 :
458 0 : sal_Int32 nCurrentContext = m_lbForm.GetSelectEntryPos();
459 0 : if (nCurrentContext != LISTBOX_ENTRY_NOTFOUND)
460 0 : m_arrContextFields[nCurrentContext] = OUString(m_lbField.GetSelectEntry());
461 0 : return 0;
462 : }
463 :
464 : //------------------------------------------------------------------------
465 0 : IMPL_LINK(FmSearchDialog, OnCheckBoxToggled, CheckBox*, pBox)
466 : {
467 0 : sal_Bool bChecked = pBox->IsChecked();
468 :
469 : // formatter or case -> pass on to the engine
470 0 : if (pBox == &m_cbUseFormat)
471 0 : m_pSearchEngine->SetFormatterUsing(bChecked);
472 0 : else if (pBox == &m_cbCase)
473 0 : m_pSearchEngine->SetCaseSensitive(bChecked);
474 : // direction -> pass on and reset the checkbox-text for StartOver
475 0 : else if (pBox == &m_cbBackwards)
476 : {
477 0 : m_cbStartOver.SetText( String( CUI_RES( bChecked ? RID_STR_FROM_BOTTOM : RID_STR_FROM_TOP ) ) );
478 0 : m_pSearchEngine->SetDirection(!bChecked);
479 : }
480 : // similarity-search or regular expression
481 0 : else if ((pBox == &m_cbApprox) || (pBox == &m_cbRegular) || (pBox == &m_cbWildCard))
482 : {
483 0 : CheckBox* pBoxes[] = { &m_cbWildCard, &m_cbRegular, &m_cbApprox };
484 0 : for (sal_uInt32 i=0; i< SAL_N_ELEMENTS(pBoxes); ++i)
485 : {
486 0 : if (pBoxes[i] != pBox)
487 : {
488 0 : if (bChecked)
489 0 : pBoxes[i]->Disable();
490 : else
491 0 : pBoxes[i]->Enable();
492 : }
493 : }
494 :
495 : // pass on to the engine
496 0 : m_pSearchEngine->SetWildcard(m_cbWildCard.IsEnabled() ? m_cbWildCard.IsChecked() : sal_False);
497 0 : m_pSearchEngine->SetRegular(m_cbRegular.IsEnabled() ? m_cbRegular.IsChecked() : sal_False);
498 0 : m_pSearchEngine->SetLevenshtein(m_cbApprox.IsEnabled() ? m_cbApprox.IsChecked() : sal_False);
499 : // (disabled boxes have to be passed to the engine as sal_False)
500 :
501 : // adjust the Position-Listbox (which is not allowed during Wildcard-search)
502 0 : if (pBox == &m_cbWildCard)
503 : {
504 0 : if (bChecked)
505 : {
506 0 : m_ftPosition.Disable();
507 0 : m_lbPosition.Disable();
508 : }
509 : else
510 : {
511 0 : m_ftPosition.Enable();
512 0 : m_lbPosition.Enable();
513 : }
514 : }
515 :
516 : // and the button for similarity-search
517 0 : if (pBox == &m_cbApprox)
518 : {
519 0 : if (bChecked)
520 0 : m_pbApproxSettings.Enable();
521 : else
522 0 : m_pbApproxSettings.Disable();
523 0 : }
524 : }
525 0 : else if (pBox == &m_aHalfFullFormsCJK)
526 : {
527 : // forward to the search engine
528 0 : m_pSearchEngine->SetIgnoreWidthCJK( !bChecked );
529 : }
530 0 : else if (pBox == &m_aSoundsLikeCJK)
531 : {
532 0 : m_aSoundsLikeCJKSettings.Enable(bChecked);
533 :
534 : // two other buttons which depend on this one
535 0 : sal_Bool bEnable = ( m_rbSearchForText.IsChecked()
536 0 : && !m_aSoundsLikeCJK.IsChecked()
537 : )
538 0 : || !SvtCJKOptions().IsJapaneseFindEnabled();
539 0 : m_cbCase.Enable(bEnable);
540 0 : m_aHalfFullFormsCJK.Enable(bEnable);
541 :
542 : // forward to the search engine
543 0 : m_pSearchEngine->SetTransliteration( bChecked );
544 : }
545 :
546 0 : return 0;
547 : }
548 :
549 : //------------------------------------------------------------------------
550 0 : void FmSearchDialog::InitContext(sal_Int16 nContext)
551 : {
552 0 : FmSearchContext fmscContext;
553 0 : fmscContext.nContext = nContext;
554 :
555 : #ifdef DBG_UTIL
556 : sal_uInt32 nResult =
557 : #endif
558 0 : m_lnkContextSupplier.Call(&fmscContext);
559 : DBG_ASSERT(nResult > 0, "FmSearchDialog::InitContext : ContextSupplier didn't give me any controls !");
560 :
561 : // put teh field names into the respective listbox
562 0 : m_lbField.Clear();
563 :
564 0 : if (fmscContext.sFieldDisplayNames.Len() != 0)
565 : {
566 : // use the display names if supplied
567 : DBG_ASSERT(comphelper::string::getTokenCount(fmscContext.sFieldDisplayNames, ';') == comphelper::string::getTokenCount(fmscContext.strUsedFields, ';'),
568 : "FmSearchDialog::InitContext : invalid context description supplied !");
569 0 : for (sal_Int32 i=0; i < comphelper::string::getTokenCount(fmscContext.sFieldDisplayNames, ';'); ++i)
570 0 : m_lbField.InsertEntry(comphelper::string::getToken(fmscContext.sFieldDisplayNames, i, ';'));
571 : }
572 : else
573 : {
574 : // else use the field names
575 0 : for (sal_Int32 i=0; i < comphelper::string::getTokenCount(fmscContext.strUsedFields, ';'); ++i)
576 0 : m_lbField.InsertEntry(comphelper::string::getToken(fmscContext.strUsedFields, i, ';'));
577 : }
578 :
579 0 : if (nContext < (sal_Int32)m_arrContextFields.size() && m_arrContextFields[nContext].Len())
580 : {
581 0 : m_lbField.SelectEntry(m_arrContextFields[nContext]);
582 : }
583 : else
584 : {
585 0 : m_lbField.SelectEntryPos(0);
586 0 : if (m_rbSingleField.IsChecked() && (m_lbField.GetEntryCount() > 1))
587 0 : m_lbField.GrabFocus();
588 : }
589 :
590 : m_pSearchEngine->SwitchToContext(fmscContext.xCursor, fmscContext.strUsedFields, fmscContext.arrFields,
591 0 : m_rbAllFields.IsChecked() ? -1 : 0);
592 :
593 0 : m_ftRecord.SetText(String::CreateFromInt32(fmscContext.xCursor->getRow()));
594 0 : }
595 :
596 : //------------------------------------------------------------------------
597 0 : IMPL_LINK( FmSearchDialog, OnContextSelection, ListBox*, pBox)
598 : {
599 0 : InitContext(pBox->GetSelectEntryPos());
600 0 : return 0L;
601 : }
602 :
603 : //------------------------------------------------------------------------
604 0 : void FmSearchDialog::EnableSearchUI(sal_Bool bEnable)
605 : {
606 : // when the controls shall be disabled their paint is turned off and then turned on again after a delay
607 0 : if (!bEnable)
608 0 : EnableControlPaint(sal_False);
609 : else
610 : {
611 0 : if (m_aDelayedPaint.IsActive())
612 0 : m_aDelayedPaint.Stop();
613 : }
614 : // (the whole thing goes on below)
615 : // this small intricateness hopfully leads to no flickering when turning the SearchUI off
616 : // and on again shortly after (like it's the case during a short search process)
617 :
618 0 : if ( !bEnable )
619 : {
620 : // if one of my children has the focus, remember it
621 0 : Window* pFocusWindow = Application::GetFocusWindow( );
622 0 : if ( pFocusWindow && IsChild( pFocusWindow ) )
623 0 : m_pPreSearchFocus = pFocusWindow;
624 : else
625 0 : m_pPreSearchFocus = NULL;
626 : }
627 :
628 : // the search button has two functions -> adjust its text accordingly
629 0 : String sButtonText( bEnable ? m_sSearch : m_sCancel );
630 0 : m_pbSearchAgain.SetText( sButtonText );
631 :
632 0 : if (m_pSearchEngine->GetSearchMode() != SM_BRUTE)
633 : {
634 0 : m_flSearchFor.Enable (bEnable);
635 0 : m_rbSearchForText.Enable (bEnable);
636 0 : m_rbSearchForNull.Enable (bEnable);
637 0 : m_rbSearchForNotNull.Enable (bEnable);
638 0 : m_flWhere.Enable (bEnable);
639 0 : m_ftForm.Enable (bEnable);
640 0 : m_lbForm.Enable (bEnable);
641 0 : m_rbAllFields.Enable (bEnable);
642 0 : m_rbSingleField.Enable (bEnable);
643 0 : m_lbField.Enable (bEnable && m_rbSingleField.IsChecked());
644 0 : m_flOptions.Enable (bEnable);
645 0 : m_cbBackwards.Enable (bEnable);
646 0 : m_cbStartOver.Enable (bEnable);
647 0 : m_pbClose.Enable (bEnable);
648 0 : EnableSearchForDependees (bEnable);
649 :
650 0 : if ( !bEnable )
651 : { // this means we're preparing for starting a search
652 : // In this case, EnableSearchForDependees disabled the search button
653 : // But as we're about to use it for cancelling the search, we really need to enable it, again
654 0 : m_pbSearchAgain.Enable( sal_True );
655 : }
656 : }
657 :
658 0 : if (!bEnable)
659 0 : m_aDelayedPaint.Start();
660 : else
661 0 : EnableControlPaint(sal_True);
662 :
663 0 : if ( bEnable )
664 : { // restore focus
665 0 : if ( m_pPreSearchFocus )
666 : {
667 0 : m_pPreSearchFocus->GrabFocus();
668 0 : if ( WINDOW_EDIT == m_pPreSearchFocus->GetType() )
669 : {
670 0 : Edit* pEdit = static_cast< Edit* >( m_pPreSearchFocus );
671 0 : pEdit->SetSelection( Selection( 0, pEdit->GetText().Len() ) );
672 : }
673 : }
674 0 : m_pPreSearchFocus = NULL;
675 0 : }
676 :
677 0 : }
678 :
679 : //------------------------------------------------------------------------
680 0 : void FmSearchDialog::EnableSearchForDependees(sal_Bool bEnable)
681 : {
682 0 : sal_Bool bSearchingForText = m_rbSearchForText.IsChecked();
683 0 : m_pbSearchAgain.Enable(bEnable && (!bSearchingForText || (m_cmbSearchText.GetText().Len() != 0)));
684 :
685 0 : bEnable = bEnable && bSearchingForText;
686 :
687 0 : sal_Bool bEnableRedundants = !m_aSoundsLikeCJK.IsChecked() || !SvtCJKOptions().IsJapaneseFindEnabled();
688 :
689 0 : m_cmbSearchText.Enable (bEnable);
690 0 : m_ftPosition.Enable (bEnable && !m_cbWildCard.IsChecked());
691 0 : m_cbWildCard.Enable (bEnable && !m_cbRegular.IsChecked() && !m_cbApprox.IsChecked());
692 0 : m_cbRegular.Enable (bEnable && !m_cbWildCard.IsChecked() && !m_cbApprox.IsChecked());
693 0 : m_cbApprox.Enable (bEnable && !m_cbWildCard.IsChecked() && !m_cbRegular.IsChecked());
694 0 : m_pbApproxSettings.Enable (bEnable && m_cbApprox.IsChecked());
695 0 : m_aHalfFullFormsCJK.Enable (bEnable && bEnableRedundants);
696 0 : m_aSoundsLikeCJK.Enable (bEnable);
697 0 : m_aSoundsLikeCJKSettings.Enable (bEnable && m_aSoundsLikeCJK.IsChecked());
698 0 : m_lbPosition.Enable (bEnable && !m_cbWildCard.IsChecked());
699 0 : m_cbUseFormat.Enable (bEnable);
700 0 : m_cbCase.Enable (bEnable && bEnableRedundants);
701 0 : }
702 :
703 : //------------------------------------------------------------------------
704 0 : void FmSearchDialog::EnableControlPaint(sal_Bool bEnable)
705 : {
706 : Control* pAffectedControls[] = { &m_flSearchFor, &m_rbSearchForText, &m_cmbSearchText, &m_rbSearchForNull, &m_rbSearchForNotNull,
707 : &m_rbSearchForText, &m_flWhere, &m_rbAllFields, &m_rbSingleField, &m_lbField, &m_flOptions, &m_ftPosition, &m_lbPosition,
708 : &m_cbUseFormat, &m_cbCase, &m_cbBackwards, &m_cbStartOver, &m_cbWildCard, &m_cbRegular, &m_cbApprox, &m_pbApproxSettings,
709 0 : &m_pbSearchAgain, &m_pbClose };
710 :
711 0 : if (!bEnable)
712 0 : for (sal_uInt32 i=0; i<SAL_N_ELEMENTS(pAffectedControls); ++i)
713 : {
714 0 : pAffectedControls[i]->SetUpdateMode(bEnable);
715 0 : pAffectedControls[i]->EnablePaint(bEnable);
716 : }
717 : else
718 0 : for (sal_uInt32 i=0; i<SAL_N_ELEMENTS(pAffectedControls); ++i)
719 : {
720 0 : pAffectedControls[i]->EnablePaint(bEnable);
721 0 : pAffectedControls[i]->SetUpdateMode(bEnable);
722 : }
723 0 : }
724 :
725 : //------------------------------------------------------------------------
726 0 : IMPL_LINK_NOARG(FmSearchDialog, OnDelayedPaint)
727 : {
728 0 : EnableControlPaint(sal_True);
729 0 : return 0L;
730 : }
731 :
732 : //------------------------------------------------------------------------
733 0 : void FmSearchDialog::OnFound(const ::com::sun::star::uno::Any& aCursorPos, sal_Int16 nFieldPos)
734 : {
735 0 : FmFoundRecordInformation friInfo;
736 0 : friInfo.nContext = m_lbForm.GetSelectEntryPos();
737 : // if I don't do a search in a context, this has an invalid value - but then it doesn't matter anyway
738 0 : friInfo.aPosition = aCursorPos;
739 0 : if (m_rbAllFields.IsChecked())
740 0 : friInfo.nFieldPos = nFieldPos;
741 : else
742 0 : friInfo.nFieldPos = m_lbField.GetSelectEntryPos();
743 : // this of course implies that I have really searched in the field that is selected in the listbox,
744 : // which is made sure in RebuildUsedFields
745 :
746 0 : m_lnkFoundHandler.Call(&friInfo);
747 :
748 0 : m_cmbSearchText.GrabFocus();
749 0 : }
750 :
751 : //------------------------------------------------------------------------
752 0 : IMPL_LINK(FmSearchDialog, OnSearchProgress, FmSearchProgress*, pProgress)
753 : {
754 0 : SolarMutexGuard aGuard;
755 : // make this single method thread-safe (it's an overkill to block the whole application for this,
756 : // but we don't have another safety concept at the moment)
757 :
758 0 : switch (pProgress->aSearchState)
759 : {
760 : case FmSearchProgress::STATE_PROGRESS:
761 0 : if (pProgress->bOverflow)
762 : {
763 0 : String sHint( CUI_RES( m_cbBackwards.IsChecked() ? RID_STR_OVERFLOW_BACKWARD : RID_STR_OVERFLOW_FORWARD ) );
764 0 : m_ftHint.SetText( sHint );
765 0 : m_ftHint.Invalidate();
766 : }
767 :
768 0 : m_ftRecord.SetText(String::CreateFromInt32(1 + pProgress->nCurrentRecord));
769 0 : m_ftRecord.Invalidate();
770 0 : break;
771 :
772 : case FmSearchProgress::STATE_PROGRESS_COUNTING:
773 0 : m_ftHint.SetText(CUI_RESSTR(RID_STR_SEARCH_COUNTING));
774 0 : m_ftHint.Invalidate();
775 :
776 0 : m_ftRecord.SetText(String::CreateFromInt32(pProgress->nCurrentRecord));
777 0 : m_ftRecord.Invalidate();
778 0 : break;
779 :
780 : case FmSearchProgress::STATE_SUCCESSFULL:
781 0 : OnFound(pProgress->aBookmark, (sal_Int16)pProgress->nFieldIndex);
782 0 : EnableSearchUI(sal_True);
783 0 : break;
784 :
785 : case FmSearchProgress::STATE_ERROR:
786 : case FmSearchProgress::STATE_NOTHINGFOUND:
787 : {
788 : sal_uInt16 nErrorId = (FmSearchProgress::STATE_ERROR == pProgress->aSearchState)
789 : ? RID_SVXERR_SEARCH_GENERAL_ERROR
790 0 : : RID_SVXERR_SEARCH_NORECORD;
791 0 : ErrorBox(this, CUI_RES(nErrorId)).Execute();
792 : }
793 : // NO break !
794 : case FmSearchProgress::STATE_CANCELED:
795 0 : EnableSearchUI(sal_True);
796 0 : if (m_lnkCanceledNotFoundHdl.IsSet())
797 : {
798 0 : FmFoundRecordInformation friInfo;
799 0 : friInfo.nContext = m_lbForm.GetSelectEntryPos();
800 : // if I don't do a search in a context, this has an invalid value - but then it doesn't matter anyway
801 0 : friInfo.aPosition = pProgress->aBookmark;
802 0 : m_lnkCanceledNotFoundHdl.Call(&friInfo);
803 : }
804 0 : break;
805 : }
806 :
807 0 : m_ftRecord.SetText(String::CreateFromInt32(1 + pProgress->nCurrentRecord));
808 :
809 0 : return 0L;
810 : }
811 :
812 : //------------------------------------------------------------------------
813 0 : void FmSearchDialog::LoadParams()
814 : {
815 0 : FmSearchParams aParams(m_pConfig->getParams());
816 :
817 0 : const ::rtl::OUString* pHistory = aParams.aHistory.getConstArray();
818 0 : const ::rtl::OUString* pHistoryEnd = pHistory + aParams.aHistory.getLength();
819 0 : for (; pHistory != pHistoryEnd; ++pHistory)
820 0 : m_cmbSearchText.InsertEntry( *pHistory );
821 :
822 : // I do the settings at my UI-elements and then I simply call the respective change-handler,
823 : // that way the data is handed on to the SearchEngine and all dependent settings are done
824 :
825 : // current field
826 0 : sal_uInt16 nInitialField = m_lbField.GetEntryPos( String( aParams.sSingleSearchField ) );
827 0 : if (nInitialField == COMBOBOX_ENTRY_NOTFOUND)
828 0 : nInitialField = 0;
829 0 : m_lbField.SelectEntryPos(nInitialField);
830 0 : LINK(this, FmSearchDialog, OnFieldSelected).Call(&m_lbField);
831 : // all fields/single field (AFTER selcting the field because OnClickedFieldRadios expects a valid value there)
832 0 : if (aParams.bAllFields)
833 : {
834 0 : m_rbSingleField.Check(sal_False);
835 0 : m_rbAllFields.Check(sal_True);
836 0 : LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(&m_rbAllFields);
837 : // OnClickedFieldRadios also calls to RebuildUsedFields
838 : }
839 : else
840 : {
841 0 : m_rbAllFields.Check(sal_False);
842 0 : m_rbSingleField.Check(sal_True);
843 0 : LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(&m_rbSingleField);
844 : }
845 :
846 0 : m_lbPosition.SelectEntryPos(aParams.nPosition);
847 0 : LINK(this, FmSearchDialog, OnPositionSelected).Call(&m_lbPosition);
848 :
849 : // field formatting/case sensitivity/direction
850 0 : m_cbUseFormat.Check(aParams.bUseFormatter);
851 0 : m_cbCase.Check( aParams.isCaseSensitive() );
852 0 : m_cbBackwards.Check(aParams.bBackwards);
853 0 : LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbUseFormat);
854 0 : LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbCase);
855 0 : LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbBackwards);
856 :
857 0 : m_aHalfFullFormsCJK.Check( !aParams.isIgnoreWidthCJK( ) ); // BEWARE: this checkbox has a inverse semantics!
858 0 : m_aSoundsLikeCJK.Check( aParams.bSoundsLikeCJK );
859 0 : LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_aHalfFullFormsCJK);
860 0 : LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_aSoundsLikeCJK);
861 :
862 0 : m_cbWildCard.Check(sal_False);
863 0 : m_cbRegular.Check(sal_False);
864 0 : m_cbApprox.Check(sal_False);
865 0 : LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbWildCard);
866 0 : LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbRegular);
867 0 : LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbApprox);
868 :
869 0 : CheckBox* pToCheck = NULL;
870 0 : if (aParams.bWildcard)
871 0 : pToCheck = &m_cbWildCard;
872 0 : if (aParams.bRegular)
873 0 : pToCheck = &m_cbRegular;
874 0 : if (aParams.bApproxSearch)
875 0 : pToCheck = &m_cbApprox;
876 0 : if (aParams.bSoundsLikeCJK)
877 0 : pToCheck = &m_aSoundsLikeCJK;
878 0 : if (pToCheck)
879 : {
880 0 : pToCheck->Check(sal_True);
881 0 : LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(pToCheck);
882 : }
883 :
884 : // set Levenshtein-parameters directly at the SearchEngine
885 0 : m_pSearchEngine->SetLevRelaxed(aParams.bLevRelaxed);
886 0 : m_pSearchEngine->SetLevOther(aParams.nLevOther);
887 0 : m_pSearchEngine->SetLevShorter(aParams.nLevShorter);
888 0 : m_pSearchEngine->SetLevLonger(aParams.nLevLonger);
889 :
890 0 : m_pSearchEngine->SetTransliterationFlags( aParams.getTransliterationFlags( ) );
891 :
892 0 : m_rbSearchForText.Check(sal_False);
893 0 : m_rbSearchForNull.Check(sal_False);
894 0 : m_rbSearchForNotNull.Check(sal_False);
895 0 : switch (aParams.nSearchForType)
896 : {
897 0 : case 1: m_rbSearchForNull.Check(sal_True); break;
898 0 : case 2: m_rbSearchForNotNull.Check(sal_True); break;
899 0 : default: m_rbSearchForText.Check(sal_True); break;
900 : }
901 0 : LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(&m_rbSearchForText);
902 0 : }
903 :
904 : //------------------------------------------------------------------------
905 0 : void FmSearchDialog::SaveParams() const
906 : {
907 0 : if (!m_pConfig)
908 0 : return;
909 :
910 0 : FmSearchParams aCurrentSettings;
911 :
912 0 : aCurrentSettings.aHistory.realloc( m_cmbSearchText.GetEntryCount() );
913 0 : ::rtl::OUString* pHistory = aCurrentSettings.aHistory.getArray();
914 0 : for (sal_uInt16 i=0; i<m_cmbSearchText.GetEntryCount(); ++i, ++pHistory)
915 0 : *pHistory = m_cmbSearchText.GetEntry(i);
916 :
917 0 : aCurrentSettings.sSingleSearchField = m_lbField.GetSelectEntry();
918 0 : aCurrentSettings.bAllFields = m_rbAllFields.IsChecked();
919 0 : aCurrentSettings.nPosition = m_pSearchEngine->GetPosition();
920 0 : aCurrentSettings.bUseFormatter = m_pSearchEngine->GetFormatterUsing();
921 0 : aCurrentSettings.setCaseSensitive ( m_pSearchEngine->GetCaseSensitive() );
922 0 : aCurrentSettings.bBackwards = !m_pSearchEngine->GetDirection();
923 0 : aCurrentSettings.bWildcard = m_pSearchEngine->GetWildcard();
924 0 : aCurrentSettings.bRegular = m_pSearchEngine->GetRegular();
925 0 : aCurrentSettings.bApproxSearch = m_pSearchEngine->GetLevenshtein();
926 0 : aCurrentSettings.bLevRelaxed = m_pSearchEngine->GetLevRelaxed();
927 0 : aCurrentSettings.nLevOther = m_pSearchEngine->GetLevOther();
928 0 : aCurrentSettings.nLevShorter = m_pSearchEngine->GetLevShorter();
929 0 : aCurrentSettings.nLevLonger = m_pSearchEngine->GetLevLonger();
930 :
931 0 : aCurrentSettings.bSoundsLikeCJK = m_pSearchEngine->GetTransliteration();
932 0 : aCurrentSettings.setTransliterationFlags ( m_pSearchEngine->GetTransliterationFlags() );
933 :
934 0 : if (m_rbSearchForNull.IsChecked())
935 0 : aCurrentSettings.nSearchForType = 1;
936 0 : else if (m_rbSearchForNotNull.IsChecked())
937 0 : aCurrentSettings.nSearchForType = 2;
938 : else
939 0 : aCurrentSettings.nSearchForType = 0;
940 :
941 0 : m_pConfig->setParams( aCurrentSettings );
942 3 : }
943 :
944 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|