Update to m13
[ooovba.git] / sc / source / ui / dbgui / filtdlg.cxx
blobdc4fb13da20def137ab4ef08888ccc0fa9853d84
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: filtdlg.cxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 // System - Includes ---------------------------------------------------------
38 // INCLUDE -------------------------------------------------------------------
39 #include <rangelst.hxx>
40 #include <sfx2/dispatch.hxx>
41 #include <vcl/waitobj.hxx>
43 #include "uiitems.hxx"
44 #include "dbcolect.hxx"
45 #include "reffact.hxx"
46 #include "viewdata.hxx"
47 #include "document.hxx"
48 #include "docsh.hxx"
49 #include "scresid.hxx"
51 #include "foptmgr.hxx"
53 #include "globstr.hrc"
54 #include "filter.hrc"
56 #define _FILTDLG_CXX
57 #include "filtdlg.hxx"
58 #undef _FILTDLG_CXX
59 #include <vcl/msgbox.hxx>
61 // DEFINE --------------------------------------------------------------------
63 #define ERRORBOX(rid) ErrorBox( this, WinBits( WB_OK|WB_DEF_OK), \
64 ScGlobal::GetRscString(rid) ).Execute()
67 //============================================================================
68 // class ScFilterDlg
70 //----------------------------------------------------------------------------
72 ScFilterDlg::ScFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
73 const SfxItemSet& rArgSet )
75 : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_FILTER ),
77 aFlCriteria ( this, ScResId( FL_CRITERIA ) ),
78 aLbField1 ( this, ScResId( LB_FIELD1 ) ),
79 aLbCond1 ( this, ScResId( LB_COND1 ) ),
80 aEdVal1 ( this, ScResId( ED_VAL1 ) ),
81 aLbConnect1 ( this, ScResId( LB_OP1 ) ),
82 aLbField2 ( this, ScResId( LB_FIELD2 ) ),
83 aLbCond2 ( this, ScResId( LB_COND2 ) ),
84 aEdVal2 ( this, ScResId( ED_VAL2 ) ),
85 aLbConnect2 ( this, ScResId( LB_OP2 ) ),
86 aLbField3 ( this, ScResId( LB_FIELD3 ) ),
87 aLbCond3 ( this, ScResId( LB_COND3 ) ),
88 aEdVal3 ( this, ScResId( ED_VAL3 ) ),
89 aFtConnect ( this, ScResId( FT_OP ) ),
90 aFtField ( this, ScResId( FT_FIELD ) ),
91 aFtCond ( this, ScResId( FT_COND ) ),
92 aFtVal ( this, ScResId( FT_VAL ) ),
93 _INIT_COMMON_FILTER_RSCOBJS
94 aStrEmpty ( ScResId( SCSTR_EMPTY ) ),
95 aStrNotEmpty ( ScResId( SCSTR_NOTEMPTY ) ),
96 aStrRow ( ScResId( SCSTR_ROW ) ),
97 aStrColumn ( ScResId( SCSTR_COLUMN ) ),
99 pOptionsMgr ( NULL ),
100 nWhichQuery ( rArgSet.GetPool()->GetWhich( SID_QUERY ) ),
101 theQueryData ( ((const ScQueryItem&)
102 rArgSet.Get( nWhichQuery )).GetQueryData() ),
103 pOutItem ( NULL ),
104 pViewData ( NULL ),
105 pDoc ( NULL ),
106 nSrcTab ( 0 ),
107 nFieldCount ( 0 ),
108 bRefInputMode ( FALSE ),
109 pTimer ( NULL )
111 for (USHORT i=0; i<=MAXCOL; i++)
112 pEntryLists[i] = NULL;
114 Init( rArgSet );
115 FreeResource();
117 // Hack: RefInput-Kontrolle
118 pTimer = new Timer;
119 pTimer->SetTimeout( 50 ); // 50ms warten
120 pTimer->SetTimeoutHdl( LINK( this, ScFilterDlg, TimeOutHdl ) );
124 //----------------------------------------------------------------------------
126 __EXPORT ScFilterDlg::~ScFilterDlg()
128 for (USHORT i=0; i<=MAXCOL; i++)
129 delete pEntryLists[i];
131 delete pOptionsMgr;
132 delete pOutItem;
134 // Hack: RefInput-Kontrolle
135 pTimer->Stop();
136 delete pTimer;
140 //----------------------------------------------------------------------------
142 void __EXPORT ScFilterDlg::Init( const SfxItemSet& rArgSet )
144 const ScQueryItem& rQueryItem = (const ScQueryItem&)
145 rArgSet.Get( nWhichQuery );
147 aBtnOk.SetClickHdl ( LINK( this, ScFilterDlg, EndDlgHdl ) );
148 aBtnCancel.SetClickHdl ( LINK( this, ScFilterDlg, EndDlgHdl ) );
149 aBtnMore.SetClickHdl ( LINK( this, ScFilterDlg, MoreClickHdl ) );
150 aBtnHeader.SetClickHdl ( LINK( this, ScFilterDlg, CheckBoxHdl ) );
151 aBtnCase.SetClickHdl ( LINK( this, ScFilterDlg, CheckBoxHdl ) );
153 aLbField1.SetSelectHdl ( LINK( this, ScFilterDlg, LbSelectHdl ) );
154 aLbField2.SetSelectHdl ( LINK( this, ScFilterDlg, LbSelectHdl ) );
155 aLbField3.SetSelectHdl ( LINK( this, ScFilterDlg, LbSelectHdl ) );
156 aLbConnect1.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
157 aLbConnect2.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
159 pViewData = rQueryItem.GetViewData();
160 pDoc = pViewData ? pViewData->GetDocument() : NULL;
161 nSrcTab = pViewData ? pViewData->GetTabNo() : static_cast<SCTAB>(0);
163 // fuer leichteren Zugriff:
164 aFieldLbArr [0] = &aLbField1;
165 aFieldLbArr [1] = &aLbField2;
166 aFieldLbArr [2] = &aLbField3;
167 aValueEdArr [0] = &aEdVal1;
168 aValueEdArr [1] = &aEdVal2;
169 aValueEdArr [2] = &aEdVal3;
170 aCondLbArr [0] = &aLbCond1;
171 aCondLbArr [1] = &aLbCond2;
172 aCondLbArr [2] = &aLbCond3;
174 // Optionen initialisieren lassen:
176 pOptionsMgr = new ScFilterOptionsMgr(
177 this,
178 pViewData,
179 theQueryData,
180 aBtnMore,
181 aBtnCase,
182 aBtnRegExp,
183 aBtnHeader,
184 aBtnUnique,
185 aBtnCopyResult,
186 aBtnDestPers,
187 aLbCopyArea,
188 aEdCopyArea,
189 aRbCopyArea,
190 aFtDbAreaLabel,
191 aFtDbArea,
192 aFlOptions,
193 aStrNoName,
194 aStrUndefined );
196 // Feldlisten einlesen und Eintraege selektieren:
198 FillFieldLists();
200 for ( SCSIZE i=0; i<3; i++ )
202 String aValStr;
203 USHORT nCondPos = 0;
204 USHORT nFieldSelPos = 0;
206 ScQueryEntry& rEntry = theQueryData.GetEntry(i);
207 if ( rEntry.bDoQuery )
209 nCondPos = (USHORT)rEntry.eOp;
210 nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) );
212 if ( rEntry.nVal == SC_EMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
214 aValStr = aStrEmpty;
215 aCondLbArr[i]->Disable();
217 else if ( rEntry.nVal == SC_NONEMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
219 aValStr = aStrNotEmpty;
220 aCondLbArr[i]->Disable();
222 else
223 aValStr = *rEntry.pStr;
225 else if ( i == 0 )
226 nFieldSelPos = GetFieldSelPos( pViewData->GetCurX() );
228 aFieldLbArr[i]->SelectEntryPos( nFieldSelPos );
229 aCondLbArr [i]->SelectEntryPos( nCondPos );
230 aValueEdArr[i]->SetText( aValStr );
231 aValueEdArr[i]->SetModifyHdl( LINK( this, ScFilterDlg, ValModifyHdl ) );
232 UpdateValueList( static_cast<USHORT>(i+1) );
235 // Disable/Enable Logik:
237 (aLbField1.GetSelectEntryPos() != 0)
238 && (aLbField2.GetSelectEntryPos() != 0)
239 ? aLbConnect1.SelectEntryPos( (USHORT)theQueryData.GetEntry(1).eConnect )
240 : aLbConnect1.SetNoSelection();
242 (aLbField2.GetSelectEntryPos() != 0)
243 && (aLbField3.GetSelectEntryPos() != 0)
244 ? aLbConnect2.SelectEntryPos( (USHORT)theQueryData.GetEntry(2).eConnect )
245 : aLbConnect2.SetNoSelection();
247 if ( aLbField1.GetSelectEntryPos() == 0 )
249 aLbConnect1.Disable();
250 aLbField2.Disable();
251 aLbCond2.Disable();
252 aEdVal2.Disable();
254 else if ( aLbConnect1.GetSelectEntryCount() == 0 )
256 aLbField2.Disable();
257 aLbCond2.Disable();
258 aEdVal2.Disable();
261 if ( aLbField2.GetSelectEntryPos() == 0 )
263 aLbConnect2.Disable();
264 aLbField3.Disable();
265 aLbCond3.Disable();
266 aEdVal3.Disable();
268 else if ( aLbConnect2.GetSelectEntryCount() == 0 )
270 aLbField3.Disable();
271 aLbCond3.Disable();
272 aEdVal3.Disable();
275 if(pDoc!=NULL &&
276 pDoc->GetChangeTrack()!=NULL) aBtnCopyResult.Disable();
277 // Modal-Modus einschalten
278 // SetDispatcherLock( TRUE );
279 //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
280 // SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
284 //----------------------------------------------------------------------------
286 BOOL __EXPORT ScFilterDlg::Close()
288 if (pViewData)
289 pViewData->GetDocShell()->CancelAutoDBRange();
291 return DoClose( ScFilterDlgWrapper::GetChildWindowId() );
295 //----------------------------------------------------------------------------
296 // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
297 // neue Selektion im Referenz-Edit angezeigt wird.
299 void ScFilterDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
301 if ( bRefInputMode ) // Nur moeglich, wenn im Referenz-Editmodus
303 if ( rRef.aStart != rRef.aEnd )
304 RefInputStart( &aEdCopyArea );
305 String aRefStr;
306 rRef.aStart.Format( aRefStr, SCA_ABS_3D, pDocP, pDocP->GetAddressConvention() );
307 aEdCopyArea.SetRefString( aRefStr );
312 //----------------------------------------------------------------------------
314 void ScFilterDlg::SetActive()
316 if ( bRefInputMode )
318 aEdCopyArea.GrabFocus();
319 if ( aEdCopyArea.GetModifyHdl().IsSet() )
320 ((Link&)aEdCopyArea.GetModifyHdl()).Call( &aEdCopyArea );
322 else
323 GrabFocus();
325 RefInputDone();
328 //----------------------------------------------------------------------------
330 void ScFilterDlg::FillFieldLists()
332 aLbField1.Clear();
333 aLbField2.Clear();
334 aLbField3.Clear();
335 aLbField1.InsertEntry( aStrNone, 0 );
336 aLbField2.InsertEntry( aStrNone, 0 );
337 aLbField3.InsertEntry( aStrNone, 0 );
339 if ( pDoc )
341 String aFieldName;
342 SCTAB nTab = nSrcTab;
343 SCCOL nFirstCol = theQueryData.nCol1;
344 SCROW nFirstRow = theQueryData.nRow1;
345 SCCOL nMaxCol = theQueryData.nCol2;
346 SCCOL col = 0;
347 USHORT i=1;
349 for ( col=nFirstCol; col<=nMaxCol; col++ )
351 pDoc->GetString( col, nFirstRow, nTab, aFieldName );
352 if ( !aBtnHeader.IsChecked() || (aFieldName.Len() == 0) )
354 aFieldName = aStrColumn;
355 aFieldName += ' ';
356 aFieldName += ScColToAlpha( col );
358 aLbField1.InsertEntry( aFieldName, i );
359 aLbField2.InsertEntry( aFieldName, i );
360 aLbField3.InsertEntry( aFieldName, i );
361 i++;
363 nFieldCount = i;
368 //----------------------------------------------------------------------------
370 void ScFilterDlg::UpdateValueList( USHORT nList )
372 if ( pDoc && nList>0 && nList<=3 )
374 ComboBox* pValList = aValueEdArr[nList-1];
375 USHORT nFieldSelPos = aFieldLbArr[nList-1]->GetSelectEntryPos();
376 USHORT nListPos = 0;
377 String aCurValue = pValList->GetText();
379 pValList->Clear();
380 pValList->InsertEntry( aStrNotEmpty, 0 );
381 pValList->InsertEntry( aStrEmpty, 1 );
382 nListPos = 2;
384 if ( nFieldSelPos )
386 WaitObject aWaiter( this ); // auch wenn nur die ListBox gefuellt wird
388 SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1;
389 if (!pEntryLists[nColumn])
391 SCTAB nTab = nSrcTab;
392 SCROW nFirstRow = theQueryData.nRow1;
393 SCROW nLastRow = theQueryData.bUseDynamicRange ? theQueryData.nDynamicEndRow : theQueryData.nRow2;
395 // erstmal ohne die erste Zeile
397 pEntryLists[nColumn] = new TypedScStrCollection( 128, 128 );
398 pEntryLists[nColumn]->SetCaseSensitive( aBtnCase.IsChecked() );
399 pDoc->GetFilterEntriesArea( nColumn, nFirstRow+1, nLastRow,
400 nTab, *pEntryLists[nColumn] );
402 // Eintrag fuer die erste Zeile
403 //! Eintrag (pHdrEntry) ohne Collection erzeugen?
405 nHeaderPos[nColumn] = USHRT_MAX;
406 TypedScStrCollection aHdrColl( 1, 1 );
407 pDoc->GetFilterEntriesArea( nColumn, nFirstRow, nFirstRow,
408 nTab, aHdrColl );
409 TypedStrData* pHdrEntry = aHdrColl[0];
410 if ( pHdrEntry )
412 TypedStrData* pNewEntry = new TypedStrData(*pHdrEntry);
413 if ( pEntryLists[nColumn]->Insert( pNewEntry ) )
415 nHeaderPos[nColumn] = pEntryLists[nColumn]->IndexOf( pNewEntry );
416 DBG_ASSERT( nHeaderPos[nColumn] != USHRT_MAX,
417 "Header-Eintrag nicht wiedergefunden" );
419 else
420 delete pNewEntry; // war schon drin
424 TypedScStrCollection* pColl = pEntryLists[nColumn];
425 USHORT nValueCount = pColl->GetCount();
426 if ( nValueCount > 0 )
428 for ( USHORT i=0; i<nValueCount; i++ )
430 pValList->InsertEntry( (*pColl)[i]->GetString(), nListPos );
431 nListPos++;
435 pValList->SetText( aCurValue );
438 UpdateHdrInValueList( nList );
441 void ScFilterDlg::UpdateHdrInValueList( USHORT nList )
443 //! GetText / SetText ??
445 if ( pDoc && nList>0 && nList<=3 )
447 USHORT nFieldSelPos = aFieldLbArr[nList-1]->GetSelectEntryPos();
448 if ( nFieldSelPos )
450 SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1;
451 if ( pEntryLists[nColumn] )
453 USHORT nPos = nHeaderPos[nColumn];
454 if ( nPos != USHRT_MAX )
456 ComboBox* pValList = aValueEdArr[nList-1];
457 USHORT nListPos = nPos + 2; // nach "leer" und "nicht leer"
459 TypedStrData* pHdrEntry = (*pEntryLists[nColumn])[nPos];
460 if ( pHdrEntry )
462 String aHdrStr = pHdrEntry->GetString();
463 BOOL bWasThere = ( pValList->GetEntry(nListPos) == aHdrStr );
464 BOOL bInclude = !aBtnHeader.IsChecked();
466 if (bInclude) // Eintrag aufnehmen
468 if (!bWasThere)
469 pValList->InsertEntry(aHdrStr, nListPos);
471 else // Eintrag weglassen
473 if (bWasThere)
474 pValList->RemoveEntry(nListPos);
477 else
479 DBG_ERROR("Eintag in Liste nicht gefunden");
483 else
485 DBG_ERROR("Spalte noch nicht initialisiert");
491 //----------------------------------------------------------------------------
493 void ScFilterDlg::ClearValueList( USHORT nList )
495 if ( nList>0 && nList<=3 )
497 ComboBox* pValList = aValueEdArr[nList-1];
498 pValList->Clear();
499 pValList->InsertEntry( aStrNotEmpty, 0 );
500 pValList->InsertEntry( aStrEmpty, 1 );
501 pValList->SetText( EMPTY_STRING );
506 //----------------------------------------------------------------------------
508 USHORT ScFilterDlg::GetFieldSelPos( SCCOL nField )
510 if ( nField >= theQueryData.nCol1 && nField <= theQueryData.nCol2 )
511 return static_cast<USHORT>(nField - theQueryData.nCol1 + 1);
512 else
513 return 0;
516 //----------------------------------------------------------------------------
518 ScQueryItem* ScFilterDlg::GetOutputItem()
520 ScAddress theCopyPos;
521 ScQueryParam theParam( theQueryData );
522 USHORT nConnect1 = aLbConnect1.GetSelectEntryPos();
523 USHORT nConnect2 = aLbConnect2.GetSelectEntryPos();
524 BOOL bCopyPosOk = FALSE;
525 SCSIZE i;
527 if ( aBtnCopyResult.IsChecked() )
529 String theCopyStr( aEdCopyArea.GetText() );
530 xub_StrLen nColonPos = theCopyStr.Search( ':' );
532 if ( STRING_NOTFOUND != nColonPos )
533 theCopyStr.Erase( nColonPos );
535 USHORT nResult = theCopyPos.Parse( theCopyStr, pDoc, pDoc->GetAddressConvention() );
536 bCopyPosOk = ( SCA_VALID == (nResult & SCA_VALID) );
539 for ( i = 0; i < 3; i++ )
541 USHORT nField = aFieldLbArr[i]->GetSelectEntryPos();
542 ScQueryOp eOp = (ScQueryOp)aCondLbArr[i]->GetSelectEntryPos();
544 BOOL bDoThis = (aFieldLbArr[i]->GetSelectEntryPos() != 0);
545 theParam.GetEntry(i).bDoQuery = bDoThis;
547 if ( bDoThis )
549 ScQueryEntry& rEntry = theParam.GetEntry(i);
551 String aStrVal( aValueEdArr[i]->GetText() );
554 * Dialog liefert die ausgezeichneten Feldwerte "leer"/"nicht leer"
555 * als Konstanten in nVal in Verbindung mit dem Schalter
556 * bQueryByString auf FALSE.
558 if ( aStrVal == aStrEmpty )
560 rEntry.pStr->Erase();
561 rEntry.nVal = SC_EMPTYFIELDS;
562 rEntry.bQueryByString = FALSE;
564 else if ( aStrVal == aStrNotEmpty )
566 rEntry.pStr->Erase();
567 rEntry.nVal = SC_NONEMPTYFIELDS;
568 rEntry.bQueryByString = FALSE;
570 else
572 *rEntry.pStr = aStrVal;
573 rEntry.nVal = 0;
574 rEntry.bQueryByString = TRUE;
577 rEntry.nField = nField ? (theQueryData.nCol1 +
578 static_cast<SCCOL>(nField) - 1) : static_cast<SCCOL>(0);
579 rEntry.eOp = eOp;
583 theParam.GetEntry(1).eConnect = (nConnect1 != LISTBOX_ENTRY_NOTFOUND)
584 ? (ScQueryConnect)nConnect1
585 : SC_AND;
586 theParam.GetEntry(2).eConnect = (nConnect2 != LISTBOX_ENTRY_NOTFOUND)
587 ? (ScQueryConnect)nConnect2
588 : SC_AND;
590 if ( aBtnCopyResult.IsChecked() && bCopyPosOk )
592 theParam.bInplace = FALSE;
593 theParam.nDestTab = theCopyPos.Tab();
594 theParam.nDestCol = theCopyPos.Col();
595 theParam.nDestRow = theCopyPos.Row();
597 else
599 theParam.bInplace = TRUE;
600 theParam.nDestTab = 0;
601 theParam.nDestCol = 0;
602 theParam.nDestRow = 0;
605 theParam.bHasHeader = aBtnHeader.IsChecked();
606 theParam.bByRow = TRUE;
607 theParam.bDuplicate = !aBtnUnique.IsChecked();
608 theParam.bCaseSens = aBtnCase.IsChecked();
609 theParam.bRegExp = aBtnRegExp.IsChecked();
610 theParam.bDestPers = aBtnDestPers.IsChecked();
612 // nur die drei eingestellten - alles andere zuruecksetzen
614 SCSIZE nEC = theParam.GetEntryCount();
615 for (i=3; i<nEC; i++) // alles ueber 3
616 theParam.GetEntry(i).bDoQuery = FALSE; // zuruecksetzen
618 DELETEZ( pOutItem );
619 pOutItem = new ScQueryItem( nWhichQuery, &theParam );
621 return pOutItem;
625 //----------------------------------------------------------------------------
627 BOOL ScFilterDlg::IsRefInputMode() const
629 return bRefInputMode;
633 //----------------------------------------------------------------------------
634 // Handler:
635 // ========
637 IMPL_LINK( ScFilterDlg, EndDlgHdl, Button*, pBtn )
639 if ( pBtn == &aBtnOk )
641 BOOL bAreaInputOk = TRUE;
643 if ( aBtnCopyResult.IsChecked() )
645 if ( !pOptionsMgr->VerifyPosStr( aEdCopyArea.GetText() ) )
647 if ( !aBtnMore.GetState() )
648 aBtnMore.SetState( TRUE );
650 ERRORBOX( STR_INVALID_TABREF );
651 aEdCopyArea.GrabFocus();
652 bAreaInputOk = FALSE;
656 if ( bAreaInputOk )
658 SetDispatcherLock( FALSE );
659 SwitchToDocument();
660 GetBindings().GetDispatcher()->Execute( FID_FILTER_OK,
661 SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
662 GetOutputItem(), 0L, 0L );
663 Close();
666 else if ( pBtn == &aBtnCancel )
668 Close();
671 return 0;
675 //----------------------------------------------------------------------------
677 IMPL_LINK( ScFilterDlg, MoreClickHdl, MoreButton*, EMPTYARG )
679 if ( aBtnMore.GetState() )
680 pTimer->Start();
681 else
683 pTimer->Stop();
684 bRefInputMode = FALSE;
685 //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
686 //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
688 return 0;
692 //----------------------------------------------------------------------------
694 IMPL_LINK( ScFilterDlg, TimeOutHdl, Timer*, _pTimer )
696 // alle 50ms nachschauen, ob RefInputMode noch stimmt
698 if( _pTimer == pTimer && IsActive() )
699 bRefInputMode = (aEdCopyArea.HasFocus() || aRbCopyArea.HasFocus());
701 if ( aBtnMore.GetState() )
702 pTimer->Start();
704 return 0;
708 //----------------------------------------------------------------------------
710 IMPL_LINK( ScFilterDlg, LbSelectHdl, ListBox*, pLb )
713 * Behandlung der Enable/Disable-Logik,
714 * abhaengig davon, welche ListBox angefasst wurde:
717 if ( pLb == &aLbConnect1 )
719 if ( !aLbField2.IsEnabled() )
721 aLbField2.Enable();
722 aLbCond2.Enable();
723 aEdVal2.Enable();
726 else if ( pLb == &aLbConnect2 )
728 if ( !aLbField3.IsEnabled() )
730 aLbField3.Enable();
731 aLbCond3.Enable();
732 aEdVal3.Enable();
735 else if ( pLb == &aLbField1 )
737 if ( aLbField1.GetSelectEntryPos() == 0 )
739 aLbConnect1.SetNoSelection();
740 aLbConnect2.SetNoSelection();
741 aLbField2.SelectEntryPos( 0 );
742 aLbField3.SelectEntryPos( 0 );
743 aLbCond2.SelectEntryPos( 0 );
744 aLbCond3.SelectEntryPos( 0 );
745 ClearValueList( 1 );
746 ClearValueList( 2 );
747 ClearValueList( 3 );
749 aLbConnect1.Disable();
750 aLbConnect2.Disable();
751 aLbField2.Disable();
752 aLbField3.Disable();
753 aLbCond2.Disable();
754 aLbCond3.Disable();
755 aEdVal2.Disable();
756 aEdVal3.Disable();
758 else
760 UpdateValueList( 1 );
761 if ( !aLbConnect1.IsEnabled() )
763 aLbConnect1.Enable();
767 else if ( pLb == &aLbField2 )
769 if ( aLbField2.GetSelectEntryPos() == 0 )
771 aLbConnect2.SetNoSelection();
772 aLbField3.SelectEntryPos( 0 );
773 aLbCond3.SelectEntryPos( 0 );
774 ClearValueList( 2 );
775 ClearValueList( 3 );
777 aLbConnect2.Disable();
778 aLbField3.Disable();
779 aLbCond3.Disable();
780 aEdVal3.Disable();
782 else
784 UpdateValueList( 2 );
785 if ( !aLbConnect2.IsEnabled() )
787 aLbConnect2.Enable();
791 else if ( pLb == &aLbField3 )
793 ( aLbField3.GetSelectEntryPos() == 0 )
794 ? ClearValueList( 3 )
795 : UpdateValueList( 3 );
798 return 0;
802 //----------------------------------------------------------------------------
804 IMPL_LINK( ScFilterDlg, CheckBoxHdl, CheckBox*, pBox )
806 // Spaltenkoepfe:
807 // FeldListen: Spaltexx <-> Spaltenkopf-String
808 // WertListen: Spaltenkopf-Wert entfaellt.
809 // Gross-/Kleinschreibung:
810 // WertListen: komplett neu
812 if ( pBox == &aBtnHeader ) // Feldlisten und Wertlisten
814 USHORT nCurSel1 = aLbField1.GetSelectEntryPos();
815 USHORT nCurSel2 = aLbField2.GetSelectEntryPos();
816 USHORT nCurSel3 = aLbField3.GetSelectEntryPos();
817 FillFieldLists();
818 aLbField1.SelectEntryPos( nCurSel1 );
819 aLbField2.SelectEntryPos( nCurSel2 );
820 aLbField3.SelectEntryPos( nCurSel3 );
822 UpdateHdrInValueList( 1 );
823 UpdateHdrInValueList( 2 );
824 UpdateHdrInValueList( 3 );
827 if ( pBox == &aBtnCase ) // Wertlisten komplett
829 for (USHORT i=0; i<=MAXCOL; i++)
830 DELETEZ( pEntryLists[i] );
832 UpdateValueList( 1 ); // aktueller Text wird gemerkt
833 UpdateValueList( 2 );
834 UpdateValueList( 3 );
837 return 0;
841 //----------------------------------------------------------------------------
843 IMPL_LINK( ScFilterDlg, ValModifyHdl, ComboBox*, pEd )
845 if ( pEd )
847 String aStrVal = pEd->GetText();
848 ListBox* pLb = &aLbCond1;
850 if ( pEd == &aEdVal2 ) pLb = &aLbCond2;
851 else if ( pEd == &aEdVal3 ) pLb = &aLbCond3;
853 // wenn einer der Sonderwerte leer/nicht-leer
854 // gewaehlt wird, so macht nur der =-Operator Sinn:
856 if ( aStrEmpty == aStrVal || aStrNotEmpty == aStrVal )
858 pLb->SelectEntry( '=' );
859 pLb->Disable();
861 else
862 pLb->Enable();
865 return 0;