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