xref: /trunk/main/sc/source/ui/dbgui/filtdlg.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 // System - Includes ---------------------------------------------------------
32 
33 
34 
35 // INCLUDE -------------------------------------------------------------------
36 #include <rangelst.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <vcl/waitobj.hxx>
39 
40 #include "uiitems.hxx"
41 #include "dbcolect.hxx"
42 #include "reffact.hxx"
43 #include "viewdata.hxx"
44 #include "document.hxx"
45 #include "docsh.hxx"
46 #include "scresid.hxx"
47 
48 #include "foptmgr.hxx"
49 
50 #include "globstr.hrc"
51 #include "filter.hrc"
52 
53 #define _FILTDLG_CXX
54 #include "filtdlg.hxx"
55 #undef _FILTDLG_CXX
56 #include <vcl/msgbox.hxx>
57 
58 // DEFINE --------------------------------------------------------------------
59 
60 #define ERRORBOX(rid)	ErrorBox( this, WinBits( WB_OK|WB_DEF_OK), \
61 				 				  ScGlobal::GetRscString(rid) ).Execute()
62 
63 
64 //============================================================================
65 //	class ScFilterDlg
66 
67 //----------------------------------------------------------------------------
68 
69 ScFilterDlg::ScFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
70 						  const SfxItemSet&	rArgSet )
71 
72 	:	ScAnyRefDlg	( pB, pCW, pParent, RID_SCDLG_FILTER ),
73 		//
74         aFlCriteria     ( this, ScResId( FL_CRITERIA ) ),
75 		aLbConnect1		( this, ScResId( LB_OP1 ) ),
76 		aLbField1		( this, ScResId( LB_FIELD1 ) ),
77 		aLbCond1		( this, ScResId( LB_COND1 ) ),
78 		aEdVal1			( this, ScResId( ED_VAL1 ) ),
79 		aLbConnect2		( this, ScResId( LB_OP2 ) ),
80 		aLbField2		( this, ScResId( LB_FIELD2 ) ),
81 		aLbCond2		( this, ScResId( LB_COND2 ) ),
82 		aEdVal2			( this, ScResId( ED_VAL2 ) ),
83 		aLbConnect3		( this, ScResId( LB_OP3 ) ),
84 		aLbField3		( this, ScResId( LB_FIELD3 ) ),
85 		aLbCond3		( this, ScResId( LB_COND3 ) ),
86 		aEdVal3			( this, ScResId( ED_VAL3 ) ),
87 		aLbConnect4		( this, ScResId( LB_OP4 ) ),
88 		aLbField4		( this, ScResId( LB_FIELD4 ) ),
89 		aLbCond4		( this, ScResId( LB_COND4 ) ),
90 		aEdVal4			( this, ScResId( ED_VAL4 ) ),
91 		aFtConnect		( this, ScResId( FT_OP ) ),
92 		aFtField		( this, ScResId( FT_FIELD ) ),
93 		aFtCond			( this, ScResId( FT_COND ) ),
94 		aFtVal			( this, ScResId( FT_VAL ) ),
95 		aFlSeparator    ( this, ScResId( FL_SEPARATOR ) ),
96 		aScrollBar      ( this, ScResId( LB_SCROLL ) ),
97         aFlOptions      ( this, ScResId( FL_OPTIONS ) ),
98         aBtnMore        ( this, ScResId( BTN_MORE ) ),
99         aBtnHelp        ( this, ScResId( BTN_HELP ) ),
100         aBtnOk          ( this, ScResId( BTN_OK ) ),
101         aBtnCancel      ( this, ScResId( BTN_CANCEL ) ),
102 		_INIT_COMMON_FILTER_RSCOBJS
103 		aStrEmpty		( ScResId( SCSTR_EMPTY ) ),
104 		aStrNotEmpty	( ScResId( SCSTR_NOTEMPTY ) ),
105 		aStrRow			( ScResId( SCSTR_ROW ) ),
106 		aStrColumn		( ScResId( SCSTR_COLUMN ) ),
107 		//
108 		pOptionsMgr		( NULL ),
109 		nWhichQuery		( rArgSet.GetPool()->GetWhich( SID_QUERY ) ),
110 		theQueryData	( ((const ScQueryItem&)
111 						   rArgSet.Get( nWhichQuery )).GetQueryData() ),
112 		pOutItem		( NULL ),
113 		pViewData		( NULL ),
114 		pDoc			( NULL ),
115 		nSrcTab			( 0 ),
116 		nFieldCount		( 0 ),
117 		bRefInputMode	( sal_False ),
118 		pTimer			( NULL )
119 {
120 	for (sal_uInt16 i=0; i<=MAXCOL; i++)
121 		pEntryLists[i] = NULL;
122 	for (SCSIZE i=0;i<MAXQUERY;i++)
123 	{
124 		 bRefreshExceptQuery[i]=sal_False;
125 	}
126 	aBtnMore.SetMoreText( String(ScResId( SCSTR_MOREBTN_MOREOPTIONS )) );
127 	aBtnMore.SetLessText( String(ScResId( SCSTR_MOREBTN_FEWEROPTIONS )) );
128 	Init( rArgSet );
129 	FreeResource();
130 
131 	// Hack: RefInput-Kontrolle
132 	pTimer = new Timer;
133 	pTimer->SetTimeout( 50 ); // 50ms warten
134 	pTimer->SetTimeoutHdl( LINK( this, ScFilterDlg, TimeOutHdl ) );
135 
136 	String sAccName (ScResId(RID_FILTER_OPERATOR));
137 	String sIndexName(sAccName);
138 	sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
139 	aLbConnect1.SetAccessibleName(sIndexName);
140 	sIndexName = sAccName;
141 	sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
142 	aLbConnect2.SetAccessibleName(sIndexName);
143 
144 	sAccName = String(ScResId(RID_FILTER_FIELDNAME));
145 	sIndexName = sAccName;
146 	sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
147 	aLbField1.SetAccessibleName(sIndexName);
148 	sIndexName = sAccName;
149 	sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
150 	aLbField2.SetAccessibleName(sIndexName);
151 	sIndexName = sAccName;
152 	sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
153 	aLbField3.SetAccessibleName(sIndexName);
154 
155 
156 	sAccName = String(ScResId(RID_FILTER_CONDITION));
157 	sIndexName = sAccName;
158 	sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
159 	aLbCond1.SetAccessibleName(sIndexName);
160 	sIndexName = sAccName;
161 	sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
162 	aLbCond2.SetAccessibleName(sIndexName);
163 	sIndexName = sAccName;
164 	sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
165 	aLbCond3.SetAccessibleName(sIndexName);
166 
167 	sAccName = String(ScResId(RID_FILTER_VALUE));
168 	sIndexName = sAccName;
169 	sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
170 	aEdVal1.SetAccessibleName(sIndexName);
171 	sIndexName = sAccName;
172 	sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
173 	aEdVal2.SetAccessibleName(sIndexName);
174 	sIndexName = sAccName;
175 	sIndexName.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
176 	aEdVal3.SetAccessibleName(sIndexName);
177 
178 	aLbCopyArea.SetAccessibleName(ScResId(STR_COPY_AREA_TO));
179 	aEdCopyArea.SetAccessibleName(ScResId(STR_COPY_AREA_TO));
180 	aLbCopyArea.SetAccessibleRelationLabeledBy(&aBtnCopyResult);
181 	aEdCopyArea.SetAccessibleRelationLabeledBy(&aBtnCopyResult);
182 
183 	aLbConnect1.SetAccessibleRelationLabeledBy(&aFtConnect);
184 	aLbConnect2.SetAccessibleRelationLabeledBy(&aFtConnect);
185 	aLbField1.SetAccessibleRelationLabeledBy(&aFtField);
186 	aLbField2.SetAccessibleRelationLabeledBy(&aFtField);
187 	aLbField3.SetAccessibleRelationLabeledBy(&aFtField);
188 	aLbCond1.SetAccessibleRelationLabeledBy(&aFtCond);
189 	aLbCond2.SetAccessibleRelationLabeledBy(&aFtCond);
190 	aLbCond3.SetAccessibleRelationLabeledBy(&aFtCond);
191 	aEdVal1.SetAccessibleRelationLabeledBy(&aFtVal);
192 	aEdVal2.SetAccessibleRelationLabeledBy(&aFtVal);
193 	aEdVal3.SetAccessibleRelationLabeledBy(&aFtVal);
194 }
195 
196 
197 //----------------------------------------------------------------------------
198 
199 __EXPORT ScFilterDlg::~ScFilterDlg()
200 {
201 	for (sal_uInt16 i=0; i<=MAXCOL; i++)
202 		delete pEntryLists[i];
203 
204 	delete pOptionsMgr;
205 	delete pOutItem;
206 
207 	// Hack: RefInput-Kontrolle
208 	pTimer->Stop();
209 	delete pTimer;
210 }
211 
212 
213 //----------------------------------------------------------------------------
214 
215 void __EXPORT ScFilterDlg::Init( const SfxItemSet& rArgSet )
216 {
217 	const ScQueryItem& rQueryItem = (const ScQueryItem&)
218 									rArgSet.Get( nWhichQuery );
219 
220 	aBtnOk.SetClickHdl		( LINK( this, ScFilterDlg, EndDlgHdl ) );
221 	aBtnCancel.SetClickHdl	( LINK( this, ScFilterDlg, EndDlgHdl ) );
222 	aBtnMore.SetClickHdl	( LINK( this, ScFilterDlg, MoreClickHdl ) );
223 	aBtnHeader.SetClickHdl	( LINK( this, ScFilterDlg, CheckBoxHdl ) );
224 	aBtnCase.SetClickHdl	( LINK( this, ScFilterDlg, CheckBoxHdl ) );
225 	//
226 	aLbField1.SetSelectHdl	( LINK( this, ScFilterDlg, LbSelectHdl ) );
227 	aLbField2.SetSelectHdl	( LINK( this, ScFilterDlg, LbSelectHdl ) );
228 	aLbField3.SetSelectHdl	( LINK( this, ScFilterDlg, LbSelectHdl ) );
229 	aLbField4.SetSelectHdl	( LINK( this, ScFilterDlg, LbSelectHdl ) );
230 	aLbConnect1.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
231 	aLbConnect2.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
232 	aLbConnect3.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
233 	aLbConnect4.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
234 
235 	aLbCond1.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
236 	aLbCond2.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
237 	aLbCond3.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
238 	aLbCond4.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
239 
240 	pViewData 	= rQueryItem.GetViewData();
241 	pDoc	  	= pViewData ? pViewData->GetDocument() : NULL;
242 	nSrcTab		= pViewData ? pViewData->GetTabNo() : static_cast<SCTAB>(0);
243 
244 	// fuer leichteren Zugriff:
245 	aFieldLbArr	 [0] = &aLbField1;
246 	aFieldLbArr	 [1] = &aLbField2;
247 	aFieldLbArr	 [2] = &aLbField3;
248 	aFieldLbArr	 [3] = &aLbField4;
249 	aValueEdArr	 [0] = &aEdVal1;
250 	aValueEdArr	 [1] = &aEdVal2;
251 	aValueEdArr	 [2] = &aEdVal3;
252 	aValueEdArr	 [3] = &aEdVal4;
253 	aCondLbArr	 [0] = &aLbCond1;
254 	aCondLbArr	 [1] = &aLbCond2;
255 	aCondLbArr 	 [2] = &aLbCond3;
256 	aCondLbArr 	 [3] = &aLbCond4;
257 	aConnLbArr   [0] = &aLbConnect1;
258 	aConnLbArr   [1] = &aLbConnect2;
259 	aConnLbArr   [2] = &aLbConnect3;
260 	aConnLbArr   [3] = &aLbConnect4;
261 
262 	// Optionen initialisieren lassen:
263 
264 	pOptionsMgr	 = new ScFilterOptionsMgr(
265 							this,
266 							pViewData,
267 							theQueryData,
268 							aBtnMore,
269 							aBtnCase,
270 							aBtnRegExp,
271 							aBtnHeader,
272 							aBtnUnique,
273 							aBtnCopyResult,
274 							aBtnDestPers,
275 							aLbCopyArea,
276 							aEdCopyArea,
277 							aRbCopyArea,
278 							aFtDbAreaLabel,
279 							aFtDbArea,
280                             aFlOptions,
281 							aStrNoName,
282 							aStrUndefined );
283 
284 	// Feldlisten einlesen und Eintraege selektieren:
285 
286 	FillFieldLists();
287 
288 	for ( SCSIZE i=0; i<4; i++ )
289 	{
290 		String	aValStr;
291 		sal_uInt16	nCondPos	 = 0;
292 		sal_uInt16	nFieldSelPos = 0;
293 
294 		ScQueryEntry& rEntry = theQueryData.GetEntry(i);
295 		if ( rEntry.bDoQuery )
296 		{
297 			nCondPos	 = (sal_uInt16)rEntry.eOp;
298 			nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) );
299 			if ( rEntry.nVal == SC_EMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
300 			{
301 				aValStr = aStrEmpty;
302 				aCondLbArr[i]->Disable();
303 			}
304 			else if ( rEntry.nVal == SC_NONEMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
305 			{
306 				aValStr = aStrNotEmpty;
307 				aCondLbArr[i]->Disable();
308 			}
309 			else
310 				aValStr = *rEntry.pStr;
311 		}
312 		else if ( i == 0 )
313 		{
314 			nFieldSelPos = GetFieldSelPos( pViewData->GetCurX() );
315 			rEntry.nField = nFieldSelPos ? (theQueryData.nCol1 +
316 				static_cast<SCCOL>(nFieldSelPos) - 1) : static_cast<SCCOL>(0);
317 			rEntry.bDoQuery=sal_True;
318 			bRefreshExceptQuery[i]=sal_True;
319 
320 		}
321 		aFieldLbArr[i]->SelectEntryPos( nFieldSelPos );
322 		aCondLbArr [i]->SelectEntryPos( nCondPos );
323 		aValueEdArr[i]->SetText( aValStr );
324 		aValueEdArr[i]->SetModifyHdl( LINK( this, ScFilterDlg, ValModifyHdl ) );
325 		UpdateValueList( static_cast<sal_uInt16>(i+1) );
326 	}
327 
328 	aScrollBar.SetEndScrollHdl( LINK( this, ScFilterDlg, ScrollHdl ) );
329 	aScrollBar.SetScrollHdl( LINK( this, ScFilterDlg, ScrollHdl ) );
330 
331 	aScrollBar.SetRange( Range( 0, 4 ) );
332 	aScrollBar.SetLineSize( 1 );
333 	aLbConnect1.Hide();
334 	// Disable/Enable Logik:
335 
336 	   (aLbField1.GetSelectEntryPos() != 0)
337 	&& (aLbField2.GetSelectEntryPos() != 0)
338 		? aLbConnect2.SelectEntryPos( (sal_uInt16)theQueryData.GetEntry(1).eConnect )
339 		: aLbConnect2.SetNoSelection();
340 
341 	   (aLbField2.GetSelectEntryPos() != 0)
342 	&& (aLbField3.GetSelectEntryPos() != 0)
343 		? aLbConnect3.SelectEntryPos( (sal_uInt16)theQueryData.GetEntry(2).eConnect )
344 		: aLbConnect3.SetNoSelection();
345 
346 	   (aLbField3.GetSelectEntryPos() != 0)
347 	&& (aLbField4.GetSelectEntryPos() != 0)
348 		? aLbConnect4.SelectEntryPos( (sal_uInt16)theQueryData.GetEntry(3).eConnect )
349 		: aLbConnect4.SetNoSelection();
350 	if ( aLbField1.GetSelectEntryPos() == 0 )
351 	{
352 		aLbConnect2.Disable();
353 		aLbField2.Disable();
354 		aLbCond2.Disable();
355 		aEdVal2.Disable();
356 	}
357 	else if ( aLbConnect2.GetSelectEntryCount() == 0 )
358 	{
359 		aLbField2.Disable();
360 		aLbCond2.Disable();
361 		aEdVal2.Disable();
362 	}
363 
364 	if ( aLbField2.GetSelectEntryPos() == 0 )
365 	{
366 		aLbConnect3.Disable();
367 		aLbField3.Disable();
368 		aLbCond3.Disable();
369 		aEdVal3.Disable();
370 	}
371 	else if ( aLbConnect3.GetSelectEntryCount() == 0 )
372 	{
373 		aLbField3.Disable();
374 		aLbCond3.Disable();
375 		aEdVal3.Disable();
376 	}
377 	if ( aLbField3.GetSelectEntryPos() == 0 )
378 	{
379 		aLbConnect4.Disable();
380 		aLbField4.Disable();
381 		aLbCond4.Disable();
382 		aEdVal4.Disable();
383 	}
384 	else if ( aLbConnect4.GetSelectEntryCount() == 0 )
385 	{
386 		aLbField4.Disable();
387 		aLbCond4.Disable();
388 		aEdVal4.Disable();
389 	}
390 
391 	if(pDoc!=NULL &&
392 		pDoc->GetChangeTrack()!=NULL) aBtnCopyResult.Disable();
393 	// Modal-Modus einschalten
394 //	SetDispatcherLock( sal_True );
395 	//@BugID 54702 Enablen/Disablen nur noch in Basisklasse
396 //	SFX_APPWINDOW->Disable(sal_False);		//! allgemeine Methode im ScAnyRefDlg
397 }
398 
399 
400 //----------------------------------------------------------------------------
401 
402 sal_Bool __EXPORT ScFilterDlg::Close()
403 {
404     if (pViewData)
405         pViewData->GetDocShell()->CancelAutoDBRange();
406 
407 	return DoClose( ScFilterDlgWrapper::GetChildWindowId() );
408 }
409 
410 
411 //----------------------------------------------------------------------------
412 // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
413 // neue Selektion im Referenz-Edit angezeigt wird.
414 
415 void ScFilterDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
416 {
417 	if ( bRefInputMode )	// Nur moeglich, wenn im Referenz-Editmodus
418 	{
419 		if ( rRef.aStart != rRef.aEnd )
420 			RefInputStart( &aEdCopyArea );
421 		String aRefStr;
422         rRef.aStart.Format( aRefStr, SCA_ABS_3D, pDocP, pDocP->GetAddressConvention() );
423 		aEdCopyArea.SetRefString( aRefStr );
424 	}
425 }
426 
427 
428 //----------------------------------------------------------------------------
429 
430 void ScFilterDlg::SetActive()
431 {
432 	if ( bRefInputMode )
433 	{
434 		aEdCopyArea.GrabFocus();
435 		if ( aEdCopyArea.GetModifyHdl().IsSet() )
436 			((Link&)aEdCopyArea.GetModifyHdl()).Call( &aEdCopyArea );
437 	}
438 	else
439 		GrabFocus();
440 
441 	RefInputDone();
442 }
443 
444 //----------------------------------------------------------------------------
445 
446 void ScFilterDlg::FillFieldLists()
447 {
448 	aLbField1.Clear();
449 	aLbField2.Clear();
450 	aLbField3.Clear();
451 	aLbField4.Clear();
452 	aLbField1.InsertEntry( aStrNone, 0 );
453 	aLbField2.InsertEntry( aStrNone, 0 );
454 	aLbField3.InsertEntry( aStrNone, 0 );
455 	aLbField4.InsertEntry( aStrNone, 0 );
456 
457 	if ( pDoc )
458 	{
459 		String	aFieldName;
460 		SCTAB	nTab		= nSrcTab;
461 		SCCOL	nFirstCol	= theQueryData.nCol1;
462 		SCROW	nFirstRow	= theQueryData.nRow1;
463 		SCCOL	nMaxCol		= theQueryData.nCol2;
464 		SCCOL	col = 0;
465 		sal_uInt16	i=1;
466 
467 		for ( col=nFirstCol; col<=nMaxCol; col++ )
468 		{
469 			pDoc->GetString( col, nFirstRow, nTab, aFieldName );
470 			if ( !aBtnHeader.IsChecked() || (aFieldName.Len() == 0) )
471 			{
472 				aFieldName  = aStrColumn;
473 				aFieldName += ' ';
474                 aFieldName += ScColToAlpha( col );
475 			}
476 			aLbField1.InsertEntry( aFieldName, i );
477 			aLbField2.InsertEntry( aFieldName, i );
478 			aLbField3.InsertEntry( aFieldName, i );
479 			aLbField4.InsertEntry( aFieldName, i );
480 			i++;
481 		}
482 		nFieldCount = i;
483 	}
484 }
485 
486 
487 //----------------------------------------------------------------------------
488 
489 void ScFilterDlg::UpdateValueList( sal_uInt16 nList )
490 {
491 	if ( pDoc && nList>0 && nList<=4 )
492 	{
493 		ComboBox*	pValList		= aValueEdArr[nList-1];
494 		sal_uInt16		nFieldSelPos	= aFieldLbArr[nList-1]->GetSelectEntryPos();
495 		sal_uInt16		nListPos		= 0;
496 		String		aCurValue  		= pValList->GetText();
497 
498 		pValList->Clear();
499 		pValList->InsertEntry( aStrNotEmpty, 0 );
500 		pValList->InsertEntry( aStrEmpty, 1 );
501 		nListPos = 2;
502 
503 		if ( nFieldSelPos )
504 		{
505 			WaitObject aWaiter( this );		// auch wenn nur die ListBox gefuellt wird
506 
507 			SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1;
508 			if (!pEntryLists[nColumn])
509 			{
510                 sal_uInt16 nOffset = GetSliderPos();
511 				SCTAB nTab		 = nSrcTab;
512 				SCROW nFirstRow = theQueryData.nRow1;
513 				SCROW nLastRow	 = theQueryData.nRow2;
514                 mbHasDates[nOffset+nList-1] = false;
515 
516 				//	erstmal ohne die erste Zeile
517 
518 				pEntryLists[nColumn] = new TypedScStrCollection( 128, 128 );
519 				pEntryLists[nColumn]->SetCaseSensitive( aBtnCase.IsChecked() );
520 				pDoc->GetFilterEntriesArea( nColumn, nFirstRow+1, nLastRow,
521                                             nTab, *pEntryLists[nColumn], mbHasDates[nOffset+nList-1] );
522 
523 				//	Eintrag fuer die erste Zeile
524 				//!	Eintrag (pHdrEntry) ohne Collection erzeugen?
525 
526 				nHeaderPos[nColumn] = USHRT_MAX;
527 				TypedScStrCollection aHdrColl( 1, 1 );
528                 bool bDummy = false;
529 				pDoc->GetFilterEntriesArea( nColumn, nFirstRow, nFirstRow,
530                                             nTab, aHdrColl, bDummy );
531 				TypedStrData* pHdrEntry = aHdrColl[0];
532 				if ( pHdrEntry )
533 				{
534 					TypedStrData* pNewEntry = new TypedStrData(*pHdrEntry);
535 					if ( pEntryLists[nColumn]->Insert( pNewEntry ) )
536 					{
537 						nHeaderPos[nColumn] = pEntryLists[nColumn]->IndexOf( pNewEntry );
538 						DBG_ASSERT( nHeaderPos[nColumn] != USHRT_MAX,
539 									"Header-Eintrag nicht wiedergefunden" );
540 					}
541 					else
542 						delete pNewEntry;			// war schon drin
543 				}
544 			}
545 
546 			TypedScStrCollection* pColl = pEntryLists[nColumn];
547 			sal_uInt16 nValueCount = pColl->GetCount();
548 			if ( nValueCount > 0 )
549 			{
550 				for ( sal_uInt16 i=0; i<nValueCount; i++ )
551 				{
552 					pValList->InsertEntry( (*pColl)[i]->GetString(), nListPos );
553 					nListPos++;
554 				}
555 			}
556 		}
557 		pValList->SetText( aCurValue );
558 	}
559 
560 	UpdateHdrInValueList( nList );
561 }
562 
563 void ScFilterDlg::UpdateHdrInValueList( sal_uInt16 nList )
564 {
565 	//!	GetText / SetText ??
566 
567 	if ( pDoc && nList>0 && nList<=4 )
568 	{
569 		sal_uInt16 nFieldSelPos = aFieldLbArr[nList-1]->GetSelectEntryPos();
570 		if ( nFieldSelPos )
571 		{
572 			SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1;
573 			if ( pEntryLists[nColumn] )
574 			{
575 				sal_uInt16 nPos = nHeaderPos[nColumn];
576 				if ( nPos != USHRT_MAX )
577 				{
578 					ComboBox* pValList = aValueEdArr[nList-1];
579 					sal_uInt16 nListPos = nPos + 2;					// nach "leer" und "nicht leer"
580 
581 					TypedStrData* pHdrEntry = (*pEntryLists[nColumn])[nPos];
582 					if ( pHdrEntry )
583 					{
584 						String aHdrStr = pHdrEntry->GetString();
585 						sal_Bool bWasThere = ( pValList->GetEntry(nListPos) == aHdrStr );
586 						sal_Bool bInclude = !aBtnHeader.IsChecked();
587 
588 						if (bInclude)			// Eintrag aufnehmen
589 						{
590 							if (!bWasThere)
591 								pValList->InsertEntry(aHdrStr, nListPos);
592 						}
593 						else					// Eintrag weglassen
594 						{
595 							if (bWasThere)
596 								pValList->RemoveEntry(nListPos);
597 						}
598 					}
599 					else
600 					{
601 						DBG_ERROR("Eintag in Liste nicht gefunden");
602 					}
603 				}
604 			}
605 			else
606 			{
607 				DBG_ERROR("Spalte noch nicht initialisiert");
608 			}
609 		}
610 	}
611 }
612 
613 //----------------------------------------------------------------------------
614 
615 void ScFilterDlg::ClearValueList( sal_uInt16 nList )
616 {
617 	if ( nList>0 && nList<=4 )
618 	{
619 		ComboBox* pValList = aValueEdArr[nList-1];
620 		pValList->Clear();
621 		pValList->InsertEntry( aStrNotEmpty, 0 );
622 		pValList->InsertEntry( aStrEmpty, 1 );
623 		pValList->SetText( EMPTY_STRING );
624 	}
625 }
626 
627 
628 //----------------------------------------------------------------------------
629 
630 sal_uInt16 ScFilterDlg::GetFieldSelPos( SCCOL nField )
631 {
632 	if ( nField >= theQueryData.nCol1 && nField <= theQueryData.nCol2 )
633 		return static_cast<sal_uInt16>(nField - theQueryData.nCol1 + 1);
634 	else
635 		return 0;
636 }
637 
638 //----------------------------------------------------------------------------
639 
640 ScQueryItem* ScFilterDlg::GetOutputItem()
641 {
642 	ScAddress		theCopyPos;
643 	ScQueryParam 	theParam( theQueryData );
644     sal_Bool            bCopyPosOk = sal_False;
645 
646 	if ( aBtnCopyResult.IsChecked() )
647 	{
648 		String theCopyStr( aEdCopyArea.GetText() );
649 		xub_StrLen nColonPos = theCopyStr.Search( ':' );
650 
651 		if ( STRING_NOTFOUND != nColonPos )
652 			theCopyStr.Erase( nColonPos );
653 
654 		sal_uInt16 nResult = theCopyPos.Parse( theCopyStr, pDoc, pDoc->GetAddressConvention() );
655 		bCopyPosOk = ( SCA_VALID == (nResult & SCA_VALID) );
656 	}
657 
658 	if ( aBtnCopyResult.IsChecked() && bCopyPosOk )
659 	{
660 		theParam.bInplace   = sal_False;
661 		theParam.nDestTab	= theCopyPos.Tab();
662 		theParam.nDestCol	= theCopyPos.Col();
663 		theParam.nDestRow	= theCopyPos.Row();
664 	}
665 	else
666 	{
667 		theParam.bInplace   = sal_True;
668 		theParam.nDestTab	= 0;
669 		theParam.nDestCol	= 0;
670 		theParam.nDestRow	= 0;
671 	}
672 
673 	theParam.bHasHeader		= aBtnHeader.IsChecked();
674 	theParam.bByRow			= sal_True;
675 	theParam.bDuplicate		= !aBtnUnique.IsChecked();
676 	theParam.bCaseSens 		= aBtnCase.IsChecked();
677 	theParam.bRegExp		= aBtnRegExp.IsChecked();
678 	theParam.bDestPers		= aBtnDestPers.IsChecked();
679 
680 	//	nur die drei eingestellten - alles andere zuruecksetzen
681 
682 	DELETEZ( pOutItem );
683 	pOutItem = new ScQueryItem( nWhichQuery, &theParam );
684 
685 	return pOutItem;
686 }
687 
688 
689 //----------------------------------------------------------------------------
690 
691 sal_Bool ScFilterDlg::IsRefInputMode() const
692 {
693 	return bRefInputMode;
694 }
695 
696 
697 //----------------------------------------------------------------------------
698 // Handler:
699 // ========
700 
701 IMPL_LINK( ScFilterDlg, EndDlgHdl, Button*, pBtn )
702 {
703 	if ( pBtn == &aBtnOk )
704 	{
705 		sal_Bool bAreaInputOk = sal_True;
706 
707 		if ( aBtnCopyResult.IsChecked() )
708 		{
709 			if ( !pOptionsMgr->VerifyPosStr( aEdCopyArea.GetText() ) )
710 			{
711 				if ( !aBtnMore.GetState() )
712 					aBtnMore.SetState( sal_True );
713 
714 				ERRORBOX( STR_INVALID_TABREF );
715 				aEdCopyArea.GrabFocus();
716 				bAreaInputOk = sal_False;
717 			}
718 		}
719 
720 		if ( bAreaInputOk )
721 		{
722 			SetDispatcherLock( sal_False );
723 			SwitchToDocument();
724 			GetBindings().GetDispatcher()->Execute( FID_FILTER_OK,
725 									  SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
726 									  GetOutputItem(), 0L, 0L );
727 			Close();
728 		}
729 	}
730 	else if ( pBtn == &aBtnCancel )
731 	{
732 		Close();
733 	}
734 
735 	return 0;
736 }
737 
738 
739 //----------------------------------------------------------------------------
740 
741 IMPL_LINK( ScFilterDlg, MoreClickHdl, MoreButton*, EMPTYARG )
742 {
743 	if ( aBtnMore.GetState() )
744 		pTimer->Start();
745 	else
746 	{
747 		pTimer->Stop();
748 		bRefInputMode = sal_False;
749 		//@BugID 54702 Enablen/Disablen nur noch in Basisklasse
750 		//SFX_APPWINDOW->Disable(sal_False);		//! allgemeine Methode im ScAnyRefDlg
751 	}
752 	return 0;
753 }
754 
755 
756 //----------------------------------------------------------------------------
757 
758 IMPL_LINK( ScFilterDlg, TimeOutHdl, Timer*, _pTimer )
759 {
760     // alle 50ms nachschauen, ob RefInputMode noch stimmt
761 
762     if( _pTimer == pTimer && IsActive() )
763         bRefInputMode = (aEdCopyArea.HasFocus() || aRbCopyArea.HasFocus());
764 
765     if ( aBtnMore.GetState() )
766         pTimer->Start();
767 
768     return 0;
769 }
770 
771 
772 //----------------------------------------------------------------------------
773 
774 IMPL_LINK( ScFilterDlg, LbSelectHdl, ListBox*, pLb )
775 {
776 	/*
777 	 * Behandlung der Enable/Disable-Logik,
778 	 * abhaengig davon, welche ListBox angefasst wurde:
779 	 */
780 	sal_uInt16 nOffset = GetSliderPos();
781 
782 	if ( pLb == &aLbConnect1 )
783 	{
784 		aLbField1.Enable();
785 		aLbCond1.Enable();
786 		aEdVal1.Enable();
787 
788 		sal_uInt16 	nConnect1 = aLbConnect1.GetSelectEntryPos();
789 		sal_uInt16 nQE = nOffset;
790 		theQueryData.GetEntry(nQE).eConnect =(ScQueryConnect)nConnect1;
791 		bRefreshExceptQuery[nQE]=sal_True;
792 	}
793 
794 	else if ( pLb == &aLbConnect2 )
795 	{
796 		aLbField2.Enable();
797 		aLbCond2.Enable();
798 		aEdVal2.Enable();
799 
800 		sal_uInt16 	nConnect2 = aLbConnect2.GetSelectEntryPos();
801 		sal_uInt16 nQE = 1+nOffset;
802 		theQueryData.GetEntry(nQE).eConnect =(ScQueryConnect)nConnect2;
803 		 bRefreshExceptQuery[nQE]=sal_True;
804 	}
805 	else if ( pLb == &aLbConnect3 )
806 	{
807 		aLbField3.Enable();
808 		aLbCond3.Enable();
809 		aEdVal3.Enable();
810 
811 		sal_uInt16 	nConnect3 = aLbConnect3.GetSelectEntryPos();
812 		sal_uInt16 nQE = 2+nOffset;
813 		theQueryData.GetEntry(nQE).eConnect = (ScQueryConnect)nConnect3;
814 		bRefreshExceptQuery[nQE]=sal_True;
815 
816 	}
817 	else if ( pLb == &aLbConnect4 )
818 	{
819 		aLbField4.Enable();
820 		aLbCond4.Enable();
821 		aEdVal4.Enable();
822 
823 		sal_uInt16 	nConnect4 = aLbConnect4.GetSelectEntryPos();
824 		sal_uInt16 nQE = 3+nOffset;
825 		theQueryData.GetEntry(nQE).eConnect = (ScQueryConnect)nConnect4;
826 		bRefreshExceptQuery[nQE]=sal_True;
827 
828 	}
829 	else if ( pLb == &aLbField1 )
830 	{
831 		if ( aLbField1.GetSelectEntryPos() == 0 )
832 		{
833 			aLbConnect2.SetNoSelection();
834 			aLbConnect3.SetNoSelection();
835 			aLbConnect4.SetNoSelection();
836 			aLbField2.SelectEntryPos( 0 );
837 			aLbField3.SelectEntryPos( 0 );
838 			aLbField4.SelectEntryPos( 0 );
839 			aLbCond2.SelectEntryPos( 0 );
840 			aLbCond3.SelectEntryPos( 0 );
841 			aLbCond4.SelectEntryPos( 0 );
842 			ClearValueList( 1 );
843 			ClearValueList( 2 );
844 			ClearValueList( 3 );
845 			ClearValueList( 4 );
846 
847 			aLbConnect2.Disable();
848 			aLbConnect3.Disable();
849 			aLbConnect4.Disable();
850 			aLbField2.Disable();
851 			aLbField3.Disable();
852 			aLbField4.Disable();
853 			aLbCond2.Disable();
854 			aLbCond3.Disable();
855 			aLbCond4.Disable();
856 			aEdVal2.Disable();
857 			aEdVal3.Disable();
858 			aEdVal4.Disable();
859 			for (sal_uInt16 i= nOffset; i< MAXQUERY; i++)
860 			{
861 				theQueryData.GetEntry(i).bDoQuery = sal_False;
862 				bRefreshExceptQuery[i]=sal_False;
863 				theQueryData.GetEntry(i).nField =  static_cast<SCCOL>(0);
864 			}
865 			bRefreshExceptQuery[nOffset] =sal_True;
866 		}
867 		else
868 		{
869 			UpdateValueList( 1 );
870 			if ( !aLbConnect2.IsEnabled() )
871 			{
872 				aLbConnect2.Enable();
873 			}
874 			theQueryData.GetEntry(nOffset).bDoQuery = sal_True;
875 			sal_uInt16 	nField	= pLb->GetSelectEntryPos();
876 			theQueryData.GetEntry(nOffset).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
877 		}
878 	}
879 	else if ( pLb == &aLbField2 )
880 	{
881 		if ( aLbField2.GetSelectEntryPos() == 0 )
882 		{
883             aLbConnect3.SetNoSelection();
884 			aLbConnect4.SetNoSelection();
885 			aLbField3.SelectEntryPos( 0 );
886 			aLbField4.SelectEntryPos( 0 );
887 			aLbCond3.SelectEntryPos( 0 );
888 			aLbCond4.SelectEntryPos( 0 );
889 			ClearValueList( 2 );
890 			ClearValueList( 3 );
891 			ClearValueList( 4 );
892 
893 			aLbConnect3.Disable();
894 			aLbConnect4.Disable();
895 			aLbField3.Disable();
896 			aLbField4.Disable();
897 			aLbCond3.Disable();
898 			aLbCond4.Disable();
899 			aEdVal3.Disable();
900 			aEdVal4.Disable();
901 
902 			sal_uInt16 nTemp=nOffset+1;
903 			for (sal_uInt16 i= nTemp; i< MAXQUERY; i++)
904 			{
905 				theQueryData.GetEntry(i).bDoQuery = sal_False;
906 				bRefreshExceptQuery[i]=sal_False;
907 				theQueryData.GetEntry(i).nField =  static_cast<SCCOL>(0);
908 			}
909 			bRefreshExceptQuery[nTemp]=sal_True;
910 		}
911 		else
912 		{
913 			UpdateValueList( 2 );
914 			if ( !aLbConnect3.IsEnabled() )
915 			{
916 				aLbConnect3.Enable();
917 			}
918 			sal_uInt16 	nField	= pLb->GetSelectEntryPos();
919 			sal_uInt16 nQ=1+nOffset;
920 			theQueryData.GetEntry(nQ).bDoQuery = sal_True;
921 			theQueryData.GetEntry(nQ).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
922 		}
923 	}
924 	else if ( pLb == &aLbField3 )
925 	{
926 		if ( aLbField3.GetSelectEntryPos() == 0 )
927 		{
928 			aLbConnect4.SetNoSelection();
929 			aLbField4.SelectEntryPos( 0 );
930 			aLbCond4.SelectEntryPos( 0 );
931 			ClearValueList( 3 );
932 			ClearValueList( 4 );
933 
934 			aLbConnect4.Disable();
935 			aLbField4.Disable();
936 			aLbCond4.Disable();
937 			aEdVal4.Disable();
938 
939 			sal_uInt16 nTemp=nOffset+2;
940 			for (sal_uInt16 i= nTemp; i< MAXQUERY; i++)
941 			{
942 				theQueryData.GetEntry(i).bDoQuery = sal_False;
943 				bRefreshExceptQuery[i]=sal_False;
944 				theQueryData.GetEntry(i).nField =  static_cast<SCCOL>(0);
945 			}
946 			bRefreshExceptQuery[nTemp]=sal_True;
947 		}
948 		else
949 		{
950 			UpdateValueList( 3 );
951 			if ( !aLbConnect4.IsEnabled() )
952 			{
953 				aLbConnect4.Enable();
954 			}
955 
956 			sal_uInt16 	nField	= pLb->GetSelectEntryPos();
957 			sal_uInt16 nQ=2+nOffset;
958 			theQueryData.GetEntry(nQ).bDoQuery = sal_True;
959 			theQueryData.GetEntry(nQ).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
960 
961 		}
962 	}
963 	else if ( pLb == &aLbField4 )
964 	{
965 		if ( aLbField4.GetSelectEntryPos() == 0 )
966 		{
967 			ClearValueList( 4 );
968 			sal_uInt16 nTemp=nOffset+3;
969 			for (sal_uInt16 i= nTemp; i< MAXQUERY; i++)
970 			{
971 				theQueryData.GetEntry(i).bDoQuery = sal_False;
972 				bRefreshExceptQuery[i]=sal_False;
973 				theQueryData.GetEntry(i).nField =  static_cast<SCCOL>(0);
974 			}
975 			bRefreshExceptQuery[nTemp]=sal_True;
976 		}
977 		else
978 		{
979 			UpdateValueList( 4 );
980 			sal_uInt16 	nField	= pLb->GetSelectEntryPos();
981 			sal_uInt16 nQ=3+nOffset;
982 			theQueryData.GetEntry(nQ).bDoQuery = sal_True;
983 			theQueryData.GetEntry(nQ).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
984 		}
985 
986 	}
987 	else if ( pLb == &aLbCond1)
988 	{
989 		theQueryData.GetEntry(nOffset).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
990 	}
991 	else if ( pLb == &aLbCond2)
992 	{
993 		sal_uInt16 nQ=1+nOffset;
994 		theQueryData.GetEntry(nQ).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
995 	}
996 	else if ( pLb == &aLbCond3)
997 	{
998 		sal_uInt16 nQ=2+nOffset;
999 		theQueryData.GetEntry(nQ).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
1000 	}
1001 	else
1002 	{
1003 		sal_uInt16 nQ=3+nOffset;
1004 		theQueryData.GetEntry(nQ).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
1005 	}
1006 
1007 	return 0;
1008 }
1009 
1010 
1011 //----------------------------------------------------------------------------
1012 
1013 IMPL_LINK( ScFilterDlg, CheckBoxHdl, CheckBox*, pBox )
1014 {
1015 	//	Spaltenkoepfe:
1016 	//		FeldListen: Spaltexx <-> Spaltenkopf-String
1017 	//		WertListen: Spaltenkopf-Wert entfaellt.
1018 	//	Gross-/Kleinschreibung:
1019 	//		WertListen: komplett neu
1020 
1021 	if ( pBox == &aBtnHeader )				// Feldlisten und Wertlisten
1022 	{
1023 		sal_uInt16 nCurSel1 = aLbField1.GetSelectEntryPos();
1024 		sal_uInt16 nCurSel2 = aLbField2.GetSelectEntryPos();
1025 		sal_uInt16 nCurSel3 = aLbField3.GetSelectEntryPos();
1026 		sal_uInt16 nCurSel4 = aLbField4.GetSelectEntryPos();
1027 		FillFieldLists();
1028 		aLbField1.SelectEntryPos( nCurSel1 );
1029 		aLbField2.SelectEntryPos( nCurSel2 );
1030 		aLbField3.SelectEntryPos( nCurSel3 );
1031 		aLbField4.SelectEntryPos( nCurSel4 );
1032 
1033 		UpdateHdrInValueList( 1 );
1034 		UpdateHdrInValueList( 2 );
1035 		UpdateHdrInValueList( 3 );
1036 		UpdateHdrInValueList( 4 );
1037 	}
1038 
1039 	if ( pBox == &aBtnCase )			// Wertlisten komplett
1040 	{
1041 		for (sal_uInt16 i=0; i<=MAXCOL; i++)
1042 			DELETEZ( pEntryLists[i] );
1043 
1044 		UpdateValueList( 1 );		// aktueller Text wird gemerkt
1045 		UpdateValueList( 2 );
1046 		UpdateValueList( 3 );
1047 		UpdateValueList( 4 );
1048 	}
1049 
1050 	return 0;
1051 }
1052 
1053 
1054 //----------------------------------------------------------------------------
1055 
1056 IMPL_LINK( ScFilterDlg, ValModifyHdl, ComboBox*, pEd )
1057 {
1058 	sal_uInt16   nOffset = GetSliderPos();
1059 	sal_uInt16   i=0;
1060 	sal_uInt16   nQE =i + nOffset;
1061 	if ( pEd )
1062 	{
1063 		String    aStrVal	= pEd->GetText();
1064 		ListBox*  pLbCond	= &aLbCond1;
1065 		ListBox*  pLbField	= &aLbField1;
1066 		if ( pEd == &aEdVal2 )
1067 		{
1068 			pLbCond  = &aLbCond2;
1069 			pLbField = &aLbField2;
1070 			i=1;
1071 			nQE=i+nOffset;
1072 		}
1073 		if ( pEd == &aEdVal3 )
1074 		{
1075 			pLbCond = &aLbCond3;
1076 			pLbField = &aLbField3;
1077 			i=2;
1078 			nQE=i+nOffset;
1079 		}
1080 		if ( pEd == &aEdVal4 )
1081 		{
1082 			pLbCond = &aLbCond4;
1083 			pLbField = &aLbField4;
1084 			i=3;
1085 			nQE=i+nOffset;
1086 		}
1087 
1088 		if ( aStrEmpty == aStrVal || aStrNotEmpty == aStrVal )
1089 		{
1090 			pLbCond->SelectEntry( '=' );
1091 			pLbCond->Disable();
1092 		}
1093 		else
1094 			pLbCond->Enable();
1095 
1096 		ScQueryEntry& rEntry = theQueryData.GetEntry( nQE );
1097 		sal_Bool bDoThis = (pLbField->GetSelectEntryPos() != 0);
1098 		rEntry.bDoQuery = bDoThis;
1099 
1100 		if ( rEntry.bDoQuery || bRefreshExceptQuery[nQE] )
1101 		{
1102 			if ( aStrVal == aStrEmpty )
1103 			{
1104 				rEntry.pStr->Erase();
1105 				rEntry.nVal = SC_EMPTYFIELDS;
1106 				rEntry.bQueryByString = sal_False;
1107 			}
1108 			else if ( aStrVal == aStrNotEmpty )
1109 			{
1110 				rEntry.pStr->Erase();
1111 				rEntry.nVal = SC_NONEMPTYFIELDS;
1112 				rEntry.bQueryByString = sal_False;
1113 			}
1114 			else
1115 			{
1116 				*rEntry.pStr		  = aStrVal;
1117 				rEntry.nVal			  = 0;
1118 				rEntry.bQueryByString = sal_True;
1119 			}
1120 
1121 			sal_uInt16 	nField	= pLbField->GetSelectEntryPos();
1122 			rEntry.nField = nField ? (theQueryData.nCol1 +
1123 				static_cast<SCCOL>(nField) - 1) : static_cast<SCCOL>(0);
1124 
1125 			ScQueryOp eOp  = (ScQueryOp)pLbCond->GetSelectEntryPos();
1126             rEntry.eOp	   = eOp;
1127             rEntry.bQueryByDate = mbHasDates[nQE];
1128 
1129 		}
1130 	}
1131 	return 0;
1132 }
1133 
1134 //----------------------------------------------------------------------------
1135 IMPL_LINK( ScFilterDlg, ScrollHdl, ScrollBar*, EMPTYARG )
1136 {
1137 	SliderMoved();
1138 	return 0;
1139 }
1140 
1141 void ScFilterDlg::SliderMoved()
1142 {
1143 	sal_uInt16 nOffset = GetSliderPos();
1144 	RefreshEditRow( nOffset);
1145 }
1146 sal_uInt16 ScFilterDlg::GetSliderPos()
1147 {
1148 	return (sal_uInt16) aScrollBar.GetThumbPos();
1149 }
1150 void ScFilterDlg::RefreshEditRow( sal_uInt16 nOffset )
1151 {
1152 	if (nOffset==0)
1153 		aConnLbArr[0]->Hide();
1154 	else
1155 		aConnLbArr[0]->Show();
1156 
1157 	for ( sal_uInt16 i=0; i<4; i++ )
1158 	{
1159 		String	aValStr;
1160 		sal_uInt16	nCondPos	 = 0;
1161 		sal_uInt16	nFieldSelPos = 0;
1162 		sal_uInt16  nQE = i+nOffset;
1163 
1164 		ScQueryEntry& rEntry = theQueryData.GetEntry( nQE);
1165 		if ( rEntry.bDoQuery || bRefreshExceptQuery[nQE] )
1166 		{
1167 			nCondPos	 = (sal_uInt16)rEntry.eOp;
1168 			if(rEntry.bDoQuery)
1169 			   nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) );
1170 
1171 			if ( rEntry.nVal == SC_EMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
1172 			{
1173 				aValStr = aStrEmpty;
1174 				aCondLbArr[i]->Disable();
1175 			}
1176 			else if ( rEntry.nVal == SC_NONEMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
1177 			{
1178 				aValStr = aStrNotEmpty;
1179 				aCondLbArr[i]->Disable();
1180 			}
1181 			else
1182 			{
1183 				aValStr = *rEntry.pStr;
1184 				aCondLbArr[i]->Enable();
1185 			}
1186 			aFieldLbArr[i]->Enable();
1187 			aValueEdArr[i]->Enable();
1188 
1189 			if (nOffset==0)
1190 			{
1191 				if (i<3)
1192 				{
1193 					if(rEntry.bDoQuery)
1194 						aConnLbArr[i+1]->Enable();
1195 					else
1196 						aConnLbArr[i+1]->Disable();
1197 					sal_uInt16 nQENext = nQE+1;
1198 					if(theQueryData.GetEntry(nQENext).bDoQuery || bRefreshExceptQuery[nQENext])
1199 						aConnLbArr[i+1]->SelectEntryPos( (sal_uInt16) theQueryData.GetEntry(nQENext).eConnect );
1200 					else
1201 						aConnLbArr[i+1]->SetNoSelection();
1202 				}
1203 			}
1204 			else
1205 			{
1206 				if(theQueryData.GetEntry( nQE-1).bDoQuery)
1207 					aConnLbArr[i]->Enable();
1208 				else
1209 					aConnLbArr[i]->Disable();
1210 
1211 				if(rEntry.bDoQuery || bRefreshExceptQuery[nQE])
1212 					aConnLbArr[i]->SelectEntryPos( (sal_uInt16) rEntry.eConnect );
1213 				else
1214 					aConnLbArr[i]->SetNoSelection();
1215 			}
1216 
1217 		}
1218 		else
1219 		{
1220 			if (nOffset==0)
1221 			{
1222 				if(i<3)
1223 				{
1224 					aConnLbArr[i+1]->SetNoSelection();
1225 					aConnLbArr[i+1]->Disable();
1226 				}
1227 			}
1228 			else
1229 			{
1230 				if(theQueryData.GetEntry( nQE-1).bDoQuery)
1231 					aConnLbArr[i]->Enable();
1232 				else
1233 					aConnLbArr[i]->Disable();
1234 				aConnLbArr[i]->SetNoSelection();
1235 			}
1236 			aFieldLbArr[i]->Disable();
1237 			aCondLbArr[i]->Disable();
1238 			aValueEdArr[i]->Disable();
1239 		}
1240 		aFieldLbArr[i]->SelectEntryPos( nFieldSelPos );
1241 		aCondLbArr [i]->SelectEntryPos( nCondPos );
1242 		aValueEdArr[i]->SetText( aValStr );
1243 		UpdateValueList( static_cast<sal_uInt16>(i+1) );
1244 	}
1245 }
1246