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