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