xref: /aoo42x/main/cui/source/dialogs/cuifmsearch.cxx (revision ae4d94bc)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26 
27 #include <tools/debug.hxx>
28 #include <vcl/msgbox.hxx>
29 #include <vcl/svapp.hxx>
30 #include <tools/shl.hxx>
31 #include <dialmgr.hxx>
32 #include <sfx2/tabdlg.hxx>
33 #include <osl/mutex.hxx>
34 #include <sfx2/app.hxx>
35 #include <cuires.hrc>
36 #include <svl/filerec.hxx>
37 #include <svx/fmsrccfg.hxx>
38 #include <svx/fmsrcimp.hxx>
39 #include "fmsearch.hrc"
40 #include "cuifmsearch.hxx"
41 #include <svx/srchdlg.hxx>
42 #include <svl/cjkoptions.hxx>
43 #include <com/sun/star/i18n/TransliterationModules.hpp>
44 #include <comphelper/processfactory.hxx>
45 #include <svx/svxdlg.hxx>
46 
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::i18n;
49 using namespace ::svxform;
50 using namespace ::com::sun::star::sdbc;
51 using namespace ::com::sun::star::util;
52 
53 #define MAX_HISTORY_ENTRIES		50
54 
55 //------------------------------------------------------------------------
56 void FmSearchDialog::initCommon( const Reference< XResultSet >& _rxCursor )
57 {
58 	// init the engine
59 	DBG_ASSERT( m_pSearchEngine, "FmSearchDialog::initCommon: have no engine!" );
60 	m_pSearchEngine->SetProgressHandler(LINK(this, FmSearchDialog, OnSearchProgress));
61 
62 	// some layout changes according to available CJK options
63 	SvtCJKOptions aCJKOptions;
64 	if (!aCJKOptions.IsJapaneseFindEnabled())
65 	{
66 		sal_Int32 nUpper = m_cbApprox.GetPosPixel().Y();
67 		sal_Int32 nDifference = m_aSoundsLikeCJKSettings.GetPosPixel().Y() - nUpper;
68 
69 		// hide the options for the japanese search
70         Control* pFieldsToMove[] = { &m_flState, &m_ftRecordLabel, &m_ftRecord, &m_ftHint };
71         implMoveControls(pFieldsToMove, sizeof(pFieldsToMove)/sizeof(pFieldsToMove[0]), nDifference, &m_flOptions);
72 
73 		m_aSoundsLikeCJK.Hide();
74 		m_aSoundsLikeCJKSettings.Hide();
75 	}
76 
77 	if (!aCJKOptions.IsCJKFontEnabled())
78 	{
79 		m_aHalfFullFormsCJK.Hide();
80 
81 		// never ignore the width (ignoring is expensive) if the option is not available at all
82 		// 04.12.2001 - 91973 - fs@openoffice.org
83 		m_pSearchEngine->SetIgnoreWidthCJK( sal_False );
84 	}
85 
86 	// some initial record texts
87 	m_ftRecord.SetText( String::CreateFromInt32( _rxCursor->getRow() ) );
88 	m_pbClose.SetHelpText(String());
89 }
90 
91 //------------------------------------------------------------------------
92 FmSearchDialog::FmSearchDialog(Window* pParent, const UniString& sInitialText, const ::std::vector< String >& _rContexts, sal_Int16 nInitialContext,
93 	const Link& lnkContextSupplier)
94 	:ModalDialog(pParent, CUI_RES(RID_SVXDLG_SEARCHFORM))
95     ,m_flSearchFor              (this, CUI_RES(FL_SEARCHFOR))
96     ,m_rbSearchForText          (this, CUI_RES(RB_SEARCHFORTEXT))
97     ,m_rbSearchForNull          (this, CUI_RES(RB_SEARCHFORNULL))
98     ,m_rbSearchForNotNull       (this, CUI_RES(RB_SEARCHFORNOTNULL))
99     ,m_cmbSearchText            (this, CUI_RES(CMB_SEARCHTEXT))
100     ,m_flWhere                  (this, CUI_RES(FL_WHERE))
101     ,m_ftForm                   (this, CUI_RES(FT_FORM))
102     ,m_lbForm                   (this, CUI_RES(LB_FORM))
103     ,m_rbAllFields              (this, CUI_RES(RB_ALLFIELDS))
104     ,m_rbSingleField            (this, CUI_RES(RB_SINGLEFIELD))
105     ,m_lbField                  (this, CUI_RES(LB_FIELD))
106     ,m_flOptions                (this, CUI_RES(FL_OPTIONS))
107     ,m_ftPosition               (this, CUI_RES(FT_POSITION))
108     ,m_lbPosition               (this, CUI_RES(LB_POSITION))
109     ,m_cbUseFormat              (this, CUI_RES(CB_USEFORMATTER))
110     ,m_cbCase                   (this, CUI_RES(CB_CASE))
111     ,m_cbBackwards              (this, CUI_RES(CB_BACKWARD))
112     ,m_cbStartOver              (this, CUI_RES(CB_STARTOVER))
113     ,m_cbWildCard               (this, CUI_RES(CB_WILDCARD))
114     ,m_cbRegular                (this, CUI_RES(CB_REGULAR))
115     ,m_cbApprox                 (this, CUI_RES(CB_APPROX))
116     ,m_pbApproxSettings         (this, CUI_RES(PB_APPROXSETTINGS))
117     ,m_aHalfFullFormsCJK        (this, CUI_RES(CB_HALFFULLFORMS))
118     ,m_aSoundsLikeCJK           (this, CUI_RES(CB_SOUNDSLIKECJK))
119     ,m_aSoundsLikeCJKSettings   (this, CUI_RES(PB_SOUNDSLIKESETTINGS))
120     ,m_flState                  (this, CUI_RES(FL_STATE))
121     ,m_ftRecordLabel            (this, CUI_RES(FT_RECORDLABEL))
122     ,m_ftRecord                 (this, CUI_RES(FT_RECORD))
123     ,m_ftHint                   (this, CUI_RES(FT_HINT))
124     ,m_pbSearchAgain            (this, CUI_RES(PB_SEARCH))
125     ,m_pbClose                  (this, CUI_RES(1))
126     ,m_pbHelp                   (this, CUI_RES(1))
127     ,m_sSearch                  ( m_pbSearchAgain.GetText() )
128     ,m_sCancel                  ( Button::GetStandardText( BUTTON_CANCEL ) )
129     ,m_pPreSearchFocus( NULL )
130 	,m_lnkContextSupplier(lnkContextSupplier)
131     ,m_pConfig( NULL )
132 {
133 	DBG_ASSERT(m_lnkContextSupplier.IsSet(), "FmSearchDialog::FmSearchDialog : have no ContextSupplier !");
134 
135 	// erst mal die Informationen fuer den initialen Kontext
136 	FmSearchContext fmscInitial;
137 	fmscInitial.nContext = nInitialContext;
138 	m_lnkContextSupplier.Call(&fmscInitial);
139 	DBG_ASSERT(fmscInitial.xCursor.is(), "FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplier !");
140 	DBG_ASSERT(fmscInitial.strUsedFields.GetTokenCount(';') == (xub_StrLen)fmscInitial.arrFields.size(),
141 		"FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplied !");
142 #if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
143 	for (sal_Int32 i=0; i<(sal_Int32)fmscInitial.arrFields.size(); ++i)
144 		DBG_ASSERT(fmscInitial.arrFields.at(i).is(), "FmSearchDialog::FmSearchDialog : invalid data supplied by ContextSupplier !");
145 #endif // (OSL_DEBUG_LEVEL > 1) || DBG_UTIL
146 
147     for (   ::std::vector< String >::const_iterator context = _rContexts.begin();
148             context != _rContexts.end();
149             ++context
150         )
151 	{
152 		m_arrContextFields.push_back(String());
153 		m_lbForm.InsertEntry(*context);
154 	}
155 	m_lbForm.SelectEntryPos(nInitialContext);
156 
157 	m_lbForm.SetSelectHdl(LINK(this, FmSearchDialog, OnContextSelection));
158 
159 	if (m_arrContextFields.size() == 1)
160 	{	// remove the context selection listbox and rearrange the controls accordingly
161 		sal_Int32 nUpper = m_lbForm.GetPosPixel().Y();
162 		sal_Int32 nDifference = m_rbAllFields.GetPosPixel().Y() - nUpper;
163 
164 		// move all controls below the affected ones up
165         Control* pFieldsToMove[] = { &m_rbAllFields, &m_rbSingleField, &m_lbField, &m_flOptions, &m_ftPosition, &m_lbPosition,
166 				&m_cbUseFormat, &m_cbCase, &m_cbBackwards, &m_cbStartOver, &m_cbWildCard, &m_cbRegular, &m_cbApprox,
167 				&m_pbApproxSettings, &m_aHalfFullFormsCJK, &m_aSoundsLikeCJK, &m_aSoundsLikeCJKSettings,
168                 &m_flState, &m_ftRecordLabel, &m_ftRecord, &m_ftHint };
169 
170         implMoveControls(pFieldsToMove, sizeof(pFieldsToMove)/sizeof(pFieldsToMove[0]), nDifference, &m_flWhere);
171 
172         Point pt = m_rbAllFields.GetPosPixel();
173         pt.X() = m_ftForm.GetPosPixel().X();
174         m_rbAllFields.SetPosPixel( pt );
175         pt = m_rbSingleField.GetPosPixel();
176         pt.X() = m_ftForm.GetPosPixel().X();
177         m_rbSingleField.SetPosPixel( pt );
178 
179         // hide dispensable controls
180 		m_ftForm.Hide();
181 		m_lbForm.Hide();
182 	}
183 
184 	m_pSearchEngine = new FmSearchEngine(
185 		::comphelper::getProcessServiceFactory(), fmscInitial.xCursor, fmscInitial.strUsedFields, fmscInitial.arrFields, SM_ALLOWSCHEDULE );
186 	initCommon( fmscInitial.xCursor );
187 
188 	if (fmscInitial.sFieldDisplayNames.Len() != 0)
189 	{	// use the display names if supplied
190 		DBG_ASSERT(fmscInitial.sFieldDisplayNames.GetTokenCount() == fmscInitial.strUsedFields.GetTokenCount(),
191 			"FmSearchDialog::FmSearchDialog : invalid initial context description !");
192 		Init(fmscInitial.sFieldDisplayNames, sInitialText);
193 	}
194 	else
195 		Init(fmscInitial.strUsedFields, sInitialText);
196 }
197 
198 //------------------------------------------------------------------------
199 void FmSearchDialog::implMoveControls(
200             Control** _ppControls,
201             sal_Int32 _nControls,
202             sal_Int32 _nUp,
203             Control* /*_pToResize*/)
204 {
205 	for (sal_Int32 i=0; i<_nControls; ++i)
206 	{
207 		Point pt = _ppControls[i]->GetPosPixel();
208 		pt.Y() -= _nUp;
209 		_ppControls[i]->SetPosPixel(pt);
210 	}
211 
212 	// resize myself
213     Size sz = GetSizePixel();
214 	sz.Height() -= _nUp;
215 	SetSizePixel(sz);
216 }
217 
218 //------------------------------------------------------------------------
219 FmSearchDialog::~FmSearchDialog()
220 {
221 	if (m_aDelayedPaint.IsActive())
222 		m_aDelayedPaint.Stop();
223 
224 	SaveParams();
225 
226 	if (m_pConfig)
227 	{
228 		delete m_pConfig;
229 		m_pConfig = NULL;
230 	}
231 
232 	delete m_pSearchEngine;
233 }
234 
235 //------------------------------------------------------------------------
236 void FmSearchDialog::Init(const UniString& strVisibleFields, const UniString& sInitialText)
237 {
238 	// die Initialisierung all der Controls
239 	m_rbSearchForText.SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
240 	m_rbSearchForNull.SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
241 	m_rbSearchForNotNull.SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
242 
243 	m_rbAllFields.SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
244 	m_rbSingleField.SetClickHdl(LINK(this, FmSearchDialog, OnClickedFieldRadios));
245 
246 	m_pbSearchAgain.SetClickHdl(LINK(this, FmSearchDialog, OnClickedSearchAgain));
247 	m_pbApproxSettings.SetClickHdl(LINK(this, FmSearchDialog, OnClickedSpecialSettings));
248 	m_aSoundsLikeCJKSettings.SetClickHdl(LINK(this, FmSearchDialog, OnClickedSpecialSettings));
249 
250 	m_lbPosition.SetSelectHdl(LINK(this, FmSearchDialog, OnPositionSelected));
251 	m_lbField.SetSelectHdl(LINK(this, FmSearchDialog, OnFieldSelected));
252 
253 	m_cmbSearchText.SetModifyHdl(LINK(this, FmSearchDialog, OnSearchTextModified));
254 	m_cmbSearchText.EnableAutocomplete(sal_False);
255 	m_cmbSearchText.SetGetFocusHdl(LINK(this, FmSearchDialog, OnFocusGrabbed));
256 
257 	m_cbUseFormat.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
258 	m_cbBackwards.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
259 	m_cbStartOver.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
260 	m_cbCase.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
261 	m_cbWildCard.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
262 	m_cbRegular.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
263 	m_cbApprox.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
264 	m_aHalfFullFormsCJK.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
265 	m_aSoundsLikeCJK.SetToggleHdl(LINK(this, FmSearchDialog, OnCheckBoxToggled));
266 
267 	// die Listboxen fuellen
268 	// die Methoden des Feldvergleiches
269     sal_uInt16 nResIds[] = {
270         RID_STR_SEARCH_ANYWHERE,
271         RID_STR_SEARCH_BEGINNING,
272         RID_STR_SEARCH_END,
273         RID_STR_SEARCH_WHOLE
274     };
275     for ( size_t i=0; i<sizeof(nResIds)/sizeof(nResIds[0]); ++i )
276 		m_lbPosition.InsertEntry( String( CUI_RES( nResIds[i] ) ) );
277 	m_lbPosition.SelectEntryPos(MATCHING_ANYWHERE);
278 
279 	// die Feld-Listbox
280 	for (sal_uInt16 i=0; i<strVisibleFields.GetTokenCount(';'); ++i)
281 		m_lbField.InsertEntry(strVisibleFields.GetToken(i, ';'));
282 
283 
284 	m_pConfig = new FmSearchConfigItem;
285 	LoadParams();
286 
287 	m_cmbSearchText.SetText(sInitialText);
288 	// wenn die Edit-Zeile den Text veraendert hat (weil er zum Beispiel Steuerzeichen enthielt, wie das bei Memofeldern der Fall
289 	// sein kann), nehme ich einen leeren UniString
290 	UniString sRealSetText = m_cmbSearchText.GetText();
291 	if (!sRealSetText.Equals(sInitialText))
292 		m_cmbSearchText.SetText(UniString());
293 	LINK(this, FmSearchDialog, OnSearchTextModified).Call(&m_cmbSearchText);
294 
295 	// initial die ganzen UI-Elemente fuer die Suche an
296 	m_aDelayedPaint.SetTimeoutHdl(LINK(this, FmSearchDialog, OnDelayedPaint));
297 	m_aDelayedPaint.SetTimeout(500);
298 	EnableSearchUI(sal_True);
299 
300 	if ( m_rbSearchForText.IsChecked() )
301 		m_cmbSearchText.GrabFocus();
302 
303 	FreeResource();
304 }
305 
306 //------------------------------------------------------------------------
307 sal_Bool FmSearchDialog::Close()
308 {
309 	// Wenn der Close-Button disabled ist und man im Dialog ESC drueckt, dann wird irgendwo vom Frame trotzdem Close aufgerufen,
310 	// was ich allerdings nicht will, wenn ich gerade mitten in einer (eventuell in einem extra Thread laufenden) Suche bin
311 	if (!m_pbClose.IsEnabled())
312 		return sal_False;
313 	return ModalDialog::Close();
314 }
315 
316 //------------------------------------------------------------------------
317 IMPL_LINK(FmSearchDialog, OnClickedFieldRadios, Button*, pButton)
318 {
319 	if ((pButton == &m_rbSearchForText) || (pButton == &m_rbSearchForNull) || (pButton == &m_rbSearchForNotNull))
320 	{
321 		EnableSearchForDependees(sal_True);
322 	}
323 	else
324 		// die Feldlistbox entsprechend en- oder disablen
325 		if (pButton == &m_rbSingleField)
326 		{
327 			m_lbField.Enable();
328 			m_pSearchEngine->RebuildUsedFields(m_lbField.GetSelectEntryPos());
329 		}
330 		else
331 		{
332 			m_lbField.Disable();
333 			m_pSearchEngine->RebuildUsedFields(-1);
334 		}
335 
336 	return 0;
337 }
338 
339 //------------------------------------------------------------------------
340 IMPL_LINK(FmSearchDialog, OnClickedSearchAgain, Button*, EMPTYARG)
341 {
342 	if (m_pbClose.IsEnabled())
343 	{	// der Button hat die Funktion 'Suchen'
344 		UniString strThisRoundText = m_cmbSearchText.GetText();
345 		// zur History dazu
346 		m_cmbSearchText.RemoveEntry(strThisRoundText);
347 		m_cmbSearchText.InsertEntry(strThisRoundText, 0);
348 			// das Remove/Insert stellt a) sicher, dass der UniString nicht zweimal auftaucht, b), dass die zuletzt gesuchten Strings am
349 			// Anfang stehen
350 		// und die Listenlaenge beschraenken
351 		while (m_cmbSearchText.GetEntryCount() > MAX_HISTORY_ENTRIES)
352 			m_cmbSearchText.RemoveEntry(m_cmbSearchText.GetEntryCount()-1);
353 
354 		// den 'Ueberlauf'-Hint rausnehmen
355 		m_ftHint.SetText(UniString());
356 		m_ftHint.Invalidate();
357 
358 		if (m_cbStartOver.IsChecked())
359 		{
360 			m_cbStartOver.Check(sal_False);
361 			EnableSearchUI(sal_False);
362 			if (m_rbSearchForText.IsChecked())
363 				m_pSearchEngine->StartOver(strThisRoundText);
364 			else
365 				m_pSearchEngine->StartOverSpecial(m_rbSearchForNull.IsChecked());
366 		}
367 		else
368 		{
369 			EnableSearchUI(sal_False);
370 			if (m_rbSearchForText.IsChecked())
371 				m_pSearchEngine->SearchNext(strThisRoundText);
372 			else
373 				m_pSearchEngine->SearchNextSpecial(m_rbSearchForNull.IsChecked());
374 		}
375 	}
376 	else
377 	{	// der Button hat die Fukntion 'Abbrechen'
378 		DBG_ASSERT(m_pSearchEngine->GetSearchMode() != SM_BRUTE, "FmSearchDialog, OnClickedSearchAgain : falscher Modus !");
379 			// der CancelButton wird normalerweise nur disabled, wenn ich in einem Thread oder mit Reschedule arbeite
380 		m_pSearchEngine->CancelSearch();
381 			// mein ProgressHandler wird gerufen, wenn es wirklich zu Ende ist, das hier war nur eine Anforderung
382 	}
383 	return 0;
384 }
385 
386 //------------------------------------------------------------------------
387 IMPL_LINK(FmSearchDialog, OnClickedSpecialSettings, Button*, pButton )
388 {
389 	if (&m_pbApproxSettings == pButton)
390 	{
391         AbstractSvxSearchSimilarityDialog* pDlg = NULL;
392 
393         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
394 		if ( pFact )
395 		    pDlg = pFact->CreateSvxSearchSimilarityDialog( this, m_pSearchEngine->GetLevRelaxed(), m_pSearchEngine->GetLevOther(),
396 						m_pSearchEngine->GetLevShorter(), m_pSearchEngine->GetLevLonger() );
397         DBG_ASSERT( pDlg, "FmSearchDialog, OnClickedSpecialSettings: could not load the dialog!" );
398 
399         if ( pDlg && pDlg->Execute() == RET_OK )
400 		{
401 			m_pSearchEngine->SetLevRelaxed( pDlg->IsRelaxed() );
402 			m_pSearchEngine->SetLevOther( pDlg->GetOther() );
403 			m_pSearchEngine->SetLevShorter(pDlg->GetShorter() );
404 			m_pSearchEngine->SetLevLonger( pDlg->GetLonger() );
405 		}
406 		delete pDlg;
407 	}
408 	else if (&m_aSoundsLikeCJKSettings == pButton)
409 	{
410 		SfxItemSet aSet( SFX_APP()->GetPool() );
411 		//CHINA001 SvxJSearchOptionsDialog aDlg( this, aSet, RID_SVXPAGE_JSEARCH_OPTIONS, m_pSearchEngine->GetTransliterationFlags() );
412 		SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
413 		if(pFact)
414 		{
415 			AbstractSvxJSearchOptionsDialog* aDlg = pFact->CreateSvxJSearchOptionsDialog( this, aSet, m_pSearchEngine->GetTransliterationFlags() );
416 			DBG_ASSERT(aDlg, "Dialogdiet fail!");//CHINA001
417 			aDlg->Execute(); //CHINA001 aDlg.Execute();
418 
419 
420 			sal_Int32 nFlags = aDlg->GetTransliterationFlags(); //CHINA001 sal_Int32 nFlags = aDlg.GetTransliterationFlags();
421 			m_pSearchEngine->SetTransliterationFlags(nFlags);
422 
423 			m_cbCase.Check(m_pSearchEngine->GetCaseSensitive());
424 			OnCheckBoxToggled( &m_cbCase );
425 			m_aHalfFullFormsCJK.Check( !m_pSearchEngine->GetIgnoreWidthCJK() );
426 			OnCheckBoxToggled( &m_aHalfFullFormsCJK );
427 			delete aDlg; //add for CHINA001
428 		}
429 	}
430 
431 	return 0;
432 }
433 
434 //------------------------------------------------------------------------
435 IMPL_LINK(FmSearchDialog, OnSearchTextModified, ComboBox*, EMPTYARG)
436 {
437 	if ((m_cmbSearchText.GetText().Len() != 0) || !m_rbSearchForText.IsChecked())
438 		m_pbSearchAgain.Enable();
439 	else
440 		m_pbSearchAgain.Disable();
441 
442 	m_pSearchEngine->InvalidatePreviousLoc();
443 	return 0;
444 }
445 
446 //------------------------------------------------------------------------
447 IMPL_LINK(FmSearchDialog, OnFocusGrabbed, ComboBox*, EMPTYARG)
448 {
449     m_cmbSearchText.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
450 }
451 
452 //------------------------------------------------------------------------
453 IMPL_LINK(FmSearchDialog, OnPositionSelected, ListBox*, pBox)
454 {
455     (void) pBox; // avoid warning
456 	DBG_ASSERT(pBox->GetSelectEntryCount() == 1, "FmSearchDialog::OnMethodSelected : unerwartet : nicht genau ein Eintrag selektiert !");
457 
458 	m_pSearchEngine->SetPosition(m_lbPosition.GetSelectEntryPos());
459 	return 0;
460 }
461 
462 //------------------------------------------------------------------------
463 IMPL_LINK(FmSearchDialog, OnFieldSelected, ListBox*, pBox)
464 {
465     (void) pBox; // avoid warning
466 	DBG_ASSERT(pBox->GetSelectEntryCount() == 1, "FmSearchDialog::OnFieldSelected : unerwartet : nicht genau ein Eintrag selektiert !");
467 
468 	m_pSearchEngine->RebuildUsedFields(m_rbAllFields.IsChecked() ? -1 : (sal_Int16)m_lbField.GetSelectEntryPos());
469 		// ruft auch m_pSearchEngine->InvalidatePreviousLoc auf
470 
471     sal_Int32 nCurrentContext = m_lbForm.GetSelectEntryPos();
472 	if (nCurrentContext != LISTBOX_ENTRY_NOTFOUND)
473 		m_arrContextFields[nCurrentContext] = UniString(m_lbField.GetSelectEntry());
474 	return 0;
475 }
476 
477 //------------------------------------------------------------------------
478 IMPL_LINK(FmSearchDialog, OnCheckBoxToggled, CheckBox*, pBox)
479 {
480 	sal_Bool bChecked = pBox->IsChecked();
481 
482 	// Formatter oder case -> an die Engine weiterreichen
483 	if (pBox == &m_cbUseFormat)
484 		m_pSearchEngine->SetFormatterUsing(bChecked);
485 	else if (pBox == &m_cbCase)
486 		m_pSearchEngine->SetCaseSensitive(bChecked);
487 	// Richtung -> weiterreichen und Checkbox-Text fuer StartOver neu setzen
488 	else if (pBox == &m_cbBackwards)
489 	{
490         m_cbStartOver.SetText( String( CUI_RES( bChecked ? RID_STR_FROM_BOTTOM : RID_STR_FROM_TOP ) ) );
491 		m_pSearchEngine->SetDirection(!bChecked);
492 	}
493 	// Aehnlichkeitssuche oder regulaerer Ausdruck
494 	else if ((pBox == &m_cbApprox) || (pBox == &m_cbRegular) || (pBox == &m_cbWildCard))
495 	{
496 		// die beiden jeweils anderen Boxes disablen oder enablen
497 		CheckBox* pBoxes[] = { &m_cbWildCard, &m_cbRegular, &m_cbApprox };
498         for (sal_uInt32 i=0; i<sizeof(pBoxes)/sizeof(CheckBox*); ++i)
499         {
500 			if (pBoxes[i] != pBox)
501 			{
502 				if (bChecked)
503 					pBoxes[i]->Disable();
504 				else
505 					pBoxes[i]->Enable();
506 			}
507         }
508 
509 		// an die Engine weiterreichen
510 		m_pSearchEngine->SetWildcard(m_cbWildCard.IsEnabled() ? m_cbWildCard.IsChecked() : sal_False);
511 		m_pSearchEngine->SetRegular(m_cbRegular.IsEnabled() ? m_cbRegular.IsChecked() : sal_False);
512 		m_pSearchEngine->SetLevenshtein(m_cbApprox.IsEnabled() ? m_cbApprox.IsChecked() : sal_False);
513 			// (Boxes, die disabled sind, muessen als sal_False an die Engine gehen)
514 
515 		// die Position-Listbox anpassen (ist bei Wildcard-Suche nicht erlaubt)
516 		if (pBox == &m_cbWildCard)
517 		{
518 			if (bChecked)
519 			{
520 				m_ftPosition.Disable();
521 				m_lbPosition.Disable();
522 			}
523 			else
524 			{
525 				m_ftPosition.Enable();
526 				m_lbPosition.Enable();
527 			}
528 		}
529 
530 		// und den Button fuer die Aehnlichkeitssuche
531 		if (pBox == &m_cbApprox)
532 		{
533 			if (bChecked)
534 				m_pbApproxSettings.Enable();
535 			else
536 				m_pbApproxSettings.Disable();
537 		}
538 	}
539 	else if (pBox == &m_aHalfFullFormsCJK)
540 	{
541 		// forward to the search engine
542 		m_pSearchEngine->SetIgnoreWidthCJK( !bChecked );
543 	}
544 	else if (pBox == &m_aSoundsLikeCJK)
545 	{
546 		m_aSoundsLikeCJKSettings.Enable(bChecked);
547 
548 		// two other buttons which depend on this one
549 		sal_Bool bEnable =	(	m_rbSearchForText.IsChecked()
550 							&&	!m_aSoundsLikeCJK.IsChecked()
551 							)
552 						 ||	!SvtCJKOptions().IsJapaneseFindEnabled();
553 		m_cbCase.Enable(bEnable);
554 		m_aHalfFullFormsCJK.Enable(bEnable);
555 
556 		// forward to the search engine
557 		m_pSearchEngine->SetTransliteration( bChecked );
558 	}
559 
560 	return 0;
561 }
562 
563 //------------------------------------------------------------------------
564 void FmSearchDialog::InitContext(sal_Int16 nContext)
565 {
566 	FmSearchContext fmscContext;
567 	fmscContext.nContext = nContext;
568 
569 #ifdef DBG_UTIL
570 	sal_uInt32 nResult =
571 #endif
572     m_lnkContextSupplier.Call(&fmscContext);
573 	DBG_ASSERT(nResult > 0, "FmSearchDialog::InitContext : ContextSupplier didn't give me any controls !");
574 
575 	// packen wir zuerst die Feld-Namen in die entsprechende Listbox
576 	m_lbField.Clear();
577 
578 	if (fmscContext.sFieldDisplayNames.Len() != 0)
579 	{
580 		// use the display names if supplied
581 		DBG_ASSERT(fmscContext.sFieldDisplayNames.GetTokenCount() == fmscContext.strUsedFields.GetTokenCount(),
582 			"FmSearchDialog::InitContext : invalid context description supplied !");
583 		for (xub_StrLen i=0; i<fmscContext.sFieldDisplayNames.GetTokenCount(); ++i)
584 			m_lbField.InsertEntry(fmscContext.sFieldDisplayNames.GetToken(i));
585 	}
586 	else
587 		// else use the field names
588 		for (xub_StrLen i=0; i<fmscContext.strUsedFields.GetTokenCount(); ++i)
589 			m_lbField.InsertEntry(fmscContext.strUsedFields.GetToken(i));
590 
591 	if (nContext < (sal_Int32)m_arrContextFields.size() && m_arrContextFields[nContext].Len())
592 	{
593 		m_lbField.SelectEntry(m_arrContextFields[nContext]);
594 	}
595 	else
596 	{
597 		m_lbField.SelectEntryPos(0);
598 		if (m_rbSingleField.IsChecked() && (m_lbField.GetEntryCount() > 1))
599 			m_lbField.GrabFocus();
600 	}
601 
602 	// dann geben wir der Engine Bescheid
603 	m_pSearchEngine->SwitchToContext(fmscContext.xCursor, fmscContext.strUsedFields, fmscContext.arrFields,
604 		m_rbAllFields.IsChecked() ? -1 : 0);
605 
606 	// und die Position des neuen Cursors anzeigen
607 	m_ftRecord.SetText(String::CreateFromInt32(fmscContext.xCursor->getRow()));
608 }
609 
610 //------------------------------------------------------------------------
611 IMPL_LINK( FmSearchDialog, OnContextSelection, ListBox*, pBox)
612 {
613 	InitContext(pBox->GetSelectEntryPos());
614 	return 0L;
615 }
616 
617 //------------------------------------------------------------------------
618 void FmSearchDialog::EnableSearchUI(sal_Bool bEnable)
619 {
620 	// wenn die Controls disabled werden sollen, schalte ich mal eben kurz ihr Paint aus und verzoegert wieder an
621 	if (!bEnable)
622 		EnableControlPaint(sal_False);
623 	else
624 	{	// beim Enablen teste ich, ob der Timer fuer das delayed paint aktiv ist und stoppe ihn wenn noetig
625 		if (m_aDelayedPaint.IsActive())
626 			m_aDelayedPaint.Stop();
627 	}
628 	// (das ganze geht unten noch weiter)
629 	// diese kleine Verrenkung fuehrt hoffentlich dazu, dass es nicht flackert, wenn man die SearchUI schnell hintereinander
630 	// aus- und wieder einschaltet (wie das bei einem kurzen Suchvorgang zwangslaeufig der Fall ist)
631 
632 	if ( !bEnable )
633 	{
634 		// if one of my children has the focus, remember it
635 		// 104332 - 2002-10-17 - fs@openoffice.org
636 		Window* pFocusWindow = Application::GetFocusWindow( );
637 		if ( pFocusWindow && IsChild( pFocusWindow ) )
638 			m_pPreSearchFocus = pFocusWindow;
639 		else
640 			m_pPreSearchFocus = NULL;
641 	}
642 
643 	// der Suchen-Button hat einen Doppelfunktion, seinen Text entsprechend anpassen
644     String sButtonText( bEnable ? m_sSearch : m_sCancel );
645 	m_pbSearchAgain.SetText( sButtonText );
646 
647 	// jetzt Controls en- oder disablen
648 	if (m_pSearchEngine->GetSearchMode() != SM_BRUTE)
649 	{
650         m_flSearchFor.Enable        (bEnable);
651 		m_rbSearchForText.Enable	(bEnable);
652 		m_rbSearchForNull.Enable	(bEnable);
653 		m_rbSearchForNotNull.Enable	(bEnable);
654         m_flWhere.Enable            (bEnable);
655 		m_ftForm.Enable				(bEnable);
656 		m_lbForm.Enable				(bEnable);
657 		m_rbAllFields.Enable		(bEnable);
658 		m_rbSingleField.Enable		(bEnable);
659 		m_lbField.Enable			(bEnable && m_rbSingleField.IsChecked());
660         m_flOptions.Enable          (bEnable);
661 		m_cbBackwards.Enable		(bEnable);
662 		m_cbStartOver.Enable		(bEnable);
663 		m_pbClose.Enable			(bEnable);
664 		EnableSearchForDependees	(bEnable);
665 
666 		if ( !bEnable )
667 		{	// this means we're preparing for starting a search
668 			// In this case, EnableSearchForDependees disabled the search button
669 			// But as we're about to use it for cancelling the search, we really need to enable it, again
670 			// 07.12.2001 - 95246 - fs@openoffice.org
671 			m_pbSearchAgain.Enable( sal_True );
672 		}
673 	}
674 
675 	// und den Rest fuer das delayed paint
676 	if (!bEnable)
677 		m_aDelayedPaint.Start();
678 	else
679 		EnableControlPaint(sal_True);
680 
681 	if ( bEnable )
682 	{	// restore focus
683 		// 104332 - 2002-10-17 - fs@openoffice.org
684 		if ( m_pPreSearchFocus )
685 		{
686 			m_pPreSearchFocus->GrabFocus();
687 			if ( WINDOW_EDIT == m_pPreSearchFocus->GetType() )
688 			{
689 				Edit* pEdit = static_cast< Edit* >( m_pPreSearchFocus );
690 				pEdit->SetSelection( Selection( 0, pEdit->GetText().Len() ) );
691 			}
692 		}
693 		m_pPreSearchFocus = NULL;
694 	}
695 
696 }
697 
698 //------------------------------------------------------------------------
699 void FmSearchDialog::EnableSearchForDependees(sal_Bool bEnable)
700 {
701 	sal_Bool bSearchingForText = m_rbSearchForText.IsChecked();
702 	m_pbSearchAgain.Enable(bEnable && (!bSearchingForText || (m_cmbSearchText.GetText().Len() != 0)));
703 
704 	bEnable = bEnable && bSearchingForText;
705 
706 	sal_Bool bEnableRedundants = !m_aSoundsLikeCJK.IsChecked() || !SvtCJKOptions().IsJapaneseFindEnabled();
707 
708 	m_cmbSearchText.Enable			(bEnable);
709 	m_ftPosition.Enable				(bEnable && !m_cbWildCard.IsChecked());
710 	m_cbWildCard.Enable				(bEnable && !m_cbRegular.IsChecked() && !m_cbApprox.IsChecked());
711 	m_cbRegular.Enable				(bEnable && !m_cbWildCard.IsChecked() && !m_cbApprox.IsChecked());
712 	m_cbApprox.Enable				(bEnable && !m_cbWildCard.IsChecked() && !m_cbRegular.IsChecked());
713 	m_pbApproxSettings.Enable		(bEnable && m_cbApprox.IsChecked());
714 	m_aHalfFullFormsCJK.Enable		(bEnable && bEnableRedundants);
715 	m_aSoundsLikeCJK.Enable			(bEnable);
716 	m_aSoundsLikeCJKSettings.Enable	(bEnable && m_aSoundsLikeCJK.IsChecked());
717 	m_lbPosition.Enable				(bEnable && !m_cbWildCard.IsChecked());
718 	m_cbUseFormat.Enable			(bEnable);
719 	m_cbCase.Enable					(bEnable && bEnableRedundants);
720 }
721 
722 //------------------------------------------------------------------------
723 void FmSearchDialog::EnableControlPaint(sal_Bool bEnable)
724 {
725     Control* pAffectedControls[] = { &m_flSearchFor, &m_rbSearchForText, &m_cmbSearchText, &m_rbSearchForNull, &m_rbSearchForNotNull,
726         &m_rbSearchForText, &m_flWhere, &m_rbAllFields, &m_rbSingleField, &m_lbField, &m_flOptions, &m_ftPosition, &m_lbPosition,
727 		&m_cbUseFormat, &m_cbCase, &m_cbBackwards, &m_cbStartOver, &m_cbWildCard, &m_cbRegular, &m_cbApprox, &m_pbApproxSettings,
728 		&m_pbSearchAgain, &m_pbClose };
729 
730 	if (!bEnable)
731         for (sal_uInt32 i=0; i<sizeof(pAffectedControls)/sizeof(pAffectedControls[0]); ++i)
732 		{
733 			pAffectedControls[i]->SetUpdateMode(bEnable);
734 			pAffectedControls[i]->EnablePaint(bEnable);
735 		}
736 	else
737         for (sal_uInt32 i=0; i<sizeof(pAffectedControls)/sizeof(pAffectedControls[0]); ++i)
738 		{
739 			pAffectedControls[i]->EnablePaint(bEnable);
740 			pAffectedControls[i]->SetUpdateMode(bEnable);
741 		}
742 }
743 
744 //------------------------------------------------------------------------
745 IMPL_LINK(FmSearchDialog, OnDelayedPaint, void*, EMPTYARG)
746 {
747 	EnableControlPaint(sal_True);
748 	return 0L;
749 }
750 
751 //------------------------------------------------------------------------
752 void FmSearchDialog::OnFound(const ::com::sun::star::uno::Any& aCursorPos, sal_Int16 nFieldPos)
753 {
754 	FmFoundRecordInformation friInfo;
755 	friInfo.nContext = m_lbForm.GetSelectEntryPos();
756 		// wenn ich keine Suche in Kontexten mache, steht hier was ungueltiges drin, aber dann ist es auch egal
757 	friInfo.aPosition = aCursorPos;
758 	if (m_rbAllFields.IsChecked())
759 		friInfo.nFieldPos = nFieldPos;
760 	else
761 		friInfo.nFieldPos = m_lbField.GetSelectEntryPos();
762 		// das setzt natuerlich voraus, dass ich wirklich in dem Feld gesucht habe, dass in der Listbox ausgewaehlt ist,
763 		// genau das wird auch in RebuildUsedFields sichergestellt
764 
765 	// dem Handler Bescheid sagen
766     m_lnkFoundHandler.Call(&friInfo);
767 
768 	// und wieder Focus auf mich
769 	m_cmbSearchText.GrabFocus();
770 }
771 
772 //------------------------------------------------------------------------
773 IMPL_LINK(FmSearchDialog, OnSearchProgress, FmSearchProgress*, pProgress)
774 {
775 	::vos::OGuard aGuard( Application::GetSolarMutex() );
776 		// diese eine Methode Thread-sicher machen (das ist ein Overkill, die ganze restliche Applikation dafuer zu blockieren,
777 		// aber im Augenblick haben wir kein anderes Sicherheitskonpzept)
778 
779 	switch (pProgress->aSearchState)
780 	{
781 		case FmSearchProgress::STATE_PROGRESS:
782 			if (pProgress->bOverflow)
783 			{
784                 String sHint( CUI_RES( m_cbBackwards.IsChecked() ? RID_STR_OVERFLOW_BACKWARD : RID_STR_OVERFLOW_FORWARD ) );
785 				m_ftHint.SetText( sHint );
786 				m_ftHint.Invalidate();
787 			}
788 
789 			m_ftRecord.SetText(String::CreateFromInt32(1 + pProgress->nCurrentRecord));
790 			m_ftRecord.Invalidate();
791 			break;
792 
793 		case FmSearchProgress::STATE_PROGRESS_COUNTING:
794 			m_ftHint.SetText(CUI_RESSTR(RID_STR_SEARCH_COUNTING));
795 			m_ftHint.Invalidate();
796 
797 			m_ftRecord.SetText(String::CreateFromInt32(pProgress->nCurrentRecord));
798 			m_ftRecord.Invalidate();
799 			break;
800 
801 		case FmSearchProgress::STATE_SUCCESSFULL:
802 			OnFound(pProgress->aBookmark, (sal_Int16)pProgress->nFieldIndex);
803 			EnableSearchUI(sal_True);
804 			break;
805 
806 		case FmSearchProgress::STATE_ERROR:
807 		case FmSearchProgress::STATE_NOTHINGFOUND:
808 		{
809 			sal_uInt16 nErrorId = (FmSearchProgress::STATE_ERROR == pProgress->aSearchState)
810 				? RID_SVXERR_SEARCH_GENERAL_ERROR
811 				: RID_SVXERR_SEARCH_NORECORD;
812 			ErrorBox(this, CUI_RES(nErrorId)).Execute();
813 		}
814 			// KEIN break !
815 		case FmSearchProgress::STATE_CANCELED:
816 			EnableSearchUI(sal_True);
817 			if (m_lnkCanceledNotFoundHdl.IsSet())
818 			{
819 				FmFoundRecordInformation friInfo;
820 				friInfo.nContext = m_lbForm.GetSelectEntryPos();
821 					// wenn ich keine Suche in Kontexten mache, steht hier was ungueltiges drin, aber dann ist es auch egal
822 				friInfo.aPosition = pProgress->aBookmark;
823 				m_lnkCanceledNotFoundHdl.Call(&friInfo);
824 			}
825 			break;
826 	}
827 
828 	m_ftRecord.SetText(String::CreateFromInt32(1 + pProgress->nCurrentRecord));
829 
830 	return 0L;
831 }
832 
833 //------------------------------------------------------------------------
834 void FmSearchDialog::LoadParams()
835 {
836 	FmSearchParams aParams(m_pConfig->getParams());
837 
838 	const ::rtl::OUString* pHistory		=					aParams.aHistory.getConstArray();
839 	const ::rtl::OUString* pHistoryEnd	=	pHistory	+	aParams.aHistory.getLength();
840 	for (; pHistory != pHistoryEnd; ++pHistory)
841 		m_cmbSearchText.InsertEntry( *pHistory );
842 
843 	// die Einstellungen nehme ich an meinen UI-Elementen vor und rufe dann einfach den entsprechenden Change-Handler auf,
844 	// dadurch werden die Daten an die SearchEngine weitergereicht und alle abhaengigen Enstellungen vorgenommen
845 
846 	// aktuelles Feld
847 	sal_uInt16 nInitialField = m_lbField.GetEntryPos( String( aParams.sSingleSearchField ) );
848 	if (nInitialField == COMBOBOX_ENTRY_NOTFOUND)
849 		nInitialField = 0;
850 	m_lbField.SelectEntryPos(nInitialField);
851 	LINK(this, FmSearchDialog, OnFieldSelected).Call(&m_lbField);
852 	// alle/einzelnes Feld (NACH dem Selektieren des Feldes, da OnClickedFieldRadios dort einen gueltigen Eintrag erwartet)
853 	if (aParams.bAllFields)
854 	{
855 		m_rbSingleField.Check(sal_False);
856 		m_rbAllFields.Check(sal_True);
857 		LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(&m_rbAllFields);
858 		// OnClickedFieldRadios ruft auch um RebuildUsedFields
859 	}
860 	else
861 	{
862 		m_rbAllFields.Check(sal_False);
863 		m_rbSingleField.Check(sal_True);
864 		LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(&m_rbSingleField);
865 	}
866 
867 	// Position im Feld
868 	m_lbPosition.SelectEntryPos(aParams.nPosition);
869 	LINK(this, FmSearchDialog, OnPositionSelected).Call(&m_lbPosition);
870 
871 	// Feld-Formatierung/Case-Sensitivitaet/Richtung
872 	m_cbUseFormat.Check(aParams.bUseFormatter);
873 	m_cbCase.Check( aParams.isCaseSensitive() );
874 	m_cbBackwards.Check(aParams.bBackwards);
875 	LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbUseFormat);
876 	LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbCase);
877 	LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbBackwards);
878 
879 	m_aHalfFullFormsCJK.Check( !aParams.isIgnoreWidthCJK( ) );	// BEWARE: this checkbox has a inverse semantics!
880 	m_aSoundsLikeCJK.Check( aParams.bSoundsLikeCJK );
881 	LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_aHalfFullFormsCJK);
882 	LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_aSoundsLikeCJK);
883 
884 	// die drei Checkboxen fuer spezielle Sucharten
885 	// erst mal alle ruecksetzen
886 	m_cbWildCard.Check(sal_False);
887 	m_cbRegular.Check(sal_False);
888 	m_cbApprox.Check(sal_False);
889 	LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbWildCard);
890 	LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbRegular);
891 	LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(&m_cbApprox);
892 
893 	// dann die richtige setzen
894 	CheckBox* pToCheck = NULL;
895 	if (aParams.bWildcard)
896 		pToCheck = &m_cbWildCard;
897 	if (aParams.bRegular)
898 		pToCheck = &m_cbRegular;
899 	if (aParams.bApproxSearch)
900 		pToCheck = &m_cbApprox;
901 	if (aParams.bSoundsLikeCJK)
902 		pToCheck = &m_aSoundsLikeCJK;
903 	if (pToCheck)
904 	{
905 		pToCheck->Check(sal_True);
906 		LINK(this, FmSearchDialog, OnCheckBoxToggled).Call(pToCheck);
907 	}
908 
909 	// die Levenshtein-Parameter direkt an der SearchEngine setzen
910 	m_pSearchEngine->SetLevRelaxed(aParams.bLevRelaxed);
911 	m_pSearchEngine->SetLevOther(aParams.nLevOther);
912 	m_pSearchEngine->SetLevShorter(aParams.nLevShorter);
913 	m_pSearchEngine->SetLevLonger(aParams.nLevLonger);
914 
915 	m_pSearchEngine->SetTransliterationFlags( aParams.getTransliterationFlags( ) );
916 
917 	m_rbSearchForText.Check(sal_False);
918 	m_rbSearchForNull.Check(sal_False);
919 	m_rbSearchForNotNull.Check(sal_False);
920 	switch (aParams.nSearchForType)
921 	{
922 		case 1: m_rbSearchForNull.Check(sal_True); break;
923 		case 2: m_rbSearchForNotNull.Check(sal_True); break;
924 		default: m_rbSearchForText.Check(sal_True); break;
925 	}
926 	LINK(this, FmSearchDialog, OnClickedFieldRadios).Call(&m_rbSearchForText);
927 }
928 
929 //------------------------------------------------------------------------
930 void FmSearchDialog::SaveParams() const
931 {
932 	if (!m_pConfig)
933 		return;
934 
935 	FmSearchParams aCurrentSettings;
936 
937 	aCurrentSettings.aHistory.realloc( m_cmbSearchText.GetEntryCount() );
938 	::rtl::OUString* pHistory = aCurrentSettings.aHistory.getArray();
939 	for (sal_uInt16 i=0; i<m_cmbSearchText.GetEntryCount(); ++i, ++pHistory)
940 		*pHistory = m_cmbSearchText.GetEntry(i);
941 
942 	aCurrentSettings.sSingleSearchField			= m_lbField.GetSelectEntry();
943 	aCurrentSettings.bAllFields					= m_rbAllFields.IsChecked();
944 	aCurrentSettings.nPosition					= m_pSearchEngine->GetPosition();
945 	aCurrentSettings.bUseFormatter				= m_pSearchEngine->GetFormatterUsing();
946 	aCurrentSettings.setCaseSensitive			( m_pSearchEngine->GetCaseSensitive() );
947 	aCurrentSettings.bBackwards					= !m_pSearchEngine->GetDirection();
948 	aCurrentSettings.bWildcard					= m_pSearchEngine->GetWildcard();
949 	aCurrentSettings.bRegular					= m_pSearchEngine->GetRegular();
950 	aCurrentSettings.bApproxSearch				= m_pSearchEngine->GetLevenshtein();
951 	aCurrentSettings.bLevRelaxed				= m_pSearchEngine->GetLevRelaxed();
952 	aCurrentSettings.nLevOther					= m_pSearchEngine->GetLevOther();
953 	aCurrentSettings.nLevShorter				= m_pSearchEngine->GetLevShorter();
954 	aCurrentSettings.nLevLonger					= m_pSearchEngine->GetLevLonger();
955 
956 	aCurrentSettings.bSoundsLikeCJK				= m_pSearchEngine->GetTransliteration();
957 	aCurrentSettings.setTransliterationFlags	( m_pSearchEngine->GetTransliterationFlags() );
958 
959 	if (m_rbSearchForNull.IsChecked())
960 		aCurrentSettings.nSearchForType = 1;
961 	else if (m_rbSearchForNotNull.IsChecked())
962 		aCurrentSettings.nSearchForType = 2;
963 	else
964 		aCurrentSettings.nSearchForType = 0;
965 
966 	m_pConfig->setParams( aCurrentSettings );
967 }
968 
969