update dev300-m58
[ooovba.git] / svx / source / dialog / ctredlin.cxx
blob7a695c550c8c56d7492d74a86ea2d4bc29c6350b
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: ctredlin.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_svx.hxx"
34 // System - Includes ---------------------------------------------------------
35 #include <vcl/svapp.hxx>
36 #include <tools/shl.hxx>
37 #include <sfx2/app.hxx>
38 #include <sfx2/module.hxx>
39 #include <svtools/txtcmp.hxx>
40 #include <unotools/charclass.hxx>
41 // INCLUDE -------------------------------------------------------------------
42 #include <unolingu.hxx>
43 #include <svx/dialmgr.hxx>
44 #include "ctredlin.hrc"
45 #include <svx/ctredlin.hxx>
46 #include "helpid.hrc"
48 //============================================================================
49 // Local Defines and Function
50 //----------------------------------------------------------------------------
52 inline void EnableDisable( Window& rWin, BOOL bEnable )
54 if (bEnable)
55 rWin.Enable();
56 else
57 rWin.Disable();
60 static long nStaticTabs[]=
62 5,10,65,120,170,220
65 #define MIN_DISTANCE 6
66 #define WRITER_AUTHOR 1
67 #define WRITER_DATE 2
68 #define CALC_AUTHOR 2
69 #define CALC_DATE 3
71 RedlinData::RedlinData()
73 bDisabled=FALSE;
74 pData=NULL;
76 RedlinData::~RedlinData()
80 //============================================================================
81 // class SvxRedlinEntry (Eintraege fuer Liste)
82 //----------------------------------------------------------------------------
84 SvxRedlinEntry::SvxRedlinEntry()
85 :SvLBoxEntry()
89 SvxRedlinEntry::~SvxRedlinEntry()
91 RedlinData* pRedDat=(RedlinData*) GetUserData();
92 if(pRedDat!=NULL)
94 delete pRedDat;
98 /*************************************************************************
99 #* Funktionen der in den SvxRedlinTable eingefuegten Items
100 #************************************************************************/
102 DBG_NAME(SvLBoxColorString);
104 /*************************************************************************
105 #* Member: SvLBoxColorString Datum:23.10.97
106 #*------------------------------------------------------------------------
108 #* Klasse: SvLBoxColorString
110 #* Funktion: Konstruktor der Klasse SvLBoxColorString
112 #* Input: Box- Entry,Flags, Text fuer Anzeige, Schrift
114 #* Output: ---
116 #************************************************************************/
118 SvLBoxColorString::SvLBoxColorString( SvLBoxEntry*pEntry,USHORT nFlags,const XubString& rStr,
119 const Color& rCol)
121 : SvLBoxString( pEntry, nFlags, rStr )
123 DBG_CTOR(SvLBoxColorString,0);
124 aPrivColor=rCol;
125 SetText( pEntry, rStr );
128 /*************************************************************************
129 #* Member: SvLBoxColorString Datum:23.10.97
130 #*------------------------------------------------------------------------
132 #* Klasse: SvLBoxColorString
134 #* Funktion: Default Konstruktor der Klasse SvLBoxColorString
136 #* Input: ---
138 #* Output: ---
140 #************************************************************************/
142 SvLBoxColorString::SvLBoxColorString()
143 : SvLBoxString()
145 DBG_CTOR(SvLBoxColorString,0);
148 /*************************************************************************
149 #* Member: ~SvLBoxColorString Datum:23.10.97
150 #*------------------------------------------------------------------------
152 #* Klasse: SvLBoxColorString
154 #* Funktion: Destruktor der Klasse SvLBoxColorString
156 #* Input: ---
158 #* Output: ---
160 #************************************************************************/
162 SvLBoxColorString::~SvLBoxColorString()
164 DBG_DTOR(SvLBoxColorString,0);
168 /*************************************************************************
169 #* Member: SvLBoxColorString Datum:23.10.97
170 #*------------------------------------------------------------------------
172 #* Klasse: SvLBoxColorString
174 #* Funktion: Erzeugt einen neuen SvLBoxColorString
176 #* Input: ---
178 #* Output: SvLBoxColorString
180 #************************************************************************/
182 SvLBoxItem* SvLBoxColorString::Create() const
184 DBG_CHKTHIS(SvLBoxColorString,0);
185 return new SvLBoxColorString;
190 /*************************************************************************
191 #* Member: SvLBoxColorString Datum:23.10.97
192 #*------------------------------------------------------------------------
194 #* Klasse: SvLBoxColorString
196 #* Funktion: Zeichenroutine des SvLBoxColorString. Gezeichnet wird
197 #* der entsprechende Text mit der eingestellten Farbe
198 #* im Ausgabe- Device.
200 #* Input: Position, Ausgabe- Device, Flag fuer Selection,
201 #* Zeiger auf den Eintrag
203 #* Output: ---
205 #************************************************************************/
207 void SvLBoxColorString::Paint( const Point& rPos, SvLBox& rDev,
208 USHORT nFlags, SvLBoxEntry* pEntry )
210 Color aColor=rDev.GetTextColor();
211 Color a2Color=aColor;
212 if(!(nFlags & SVLISTENTRYFLAG_SELECTED))
214 rDev.SetTextColor(aPrivColor);
216 SvLBoxString::Paint(rPos,rDev,nFlags,pEntry );
217 rDev.SetTextColor(a2Color);
220 //============================================================================
221 // class SvxRedlinTable
222 //----------------------------------------------------------------------------
224 SvxRedlinTable::SvxRedlinTable( Window* pParent,WinBits nBits ):
225 SvxSimpleTable(pParent,nBits )
227 bAuthor=FALSE;
228 bDate=FALSE;
229 bIsCalc=FALSE;
230 bComment=FALSE;
231 nDatePos=WRITER_DATE;
232 pCommentSearcher=NULL;
233 SetNodeDefaultImages();
236 SvxRedlinTable::SvxRedlinTable( Window* pParent,const ResId& rResId):
237 SvxSimpleTable(pParent,rResId)
239 bAuthor=FALSE;
240 bDate=FALSE;
241 bIsCalc=FALSE;
242 bComment=FALSE;
243 nDatePos=WRITER_DATE;
244 pCommentSearcher=NULL;
245 SetNodeDefaultImages();
248 SvxRedlinTable::~SvxRedlinTable()
250 if(pCommentSearcher!=NULL)
251 delete pCommentSearcher;
254 StringCompare SvxRedlinTable::ColCompare(SvLBoxEntry* pLeft,SvLBoxEntry* pRight)
256 StringCompare eCompare=COMPARE_EQUAL;
258 if(aColCompareLink.IsSet())
260 SvSortData aRedlinCompare;
261 aRedlinCompare.pLeft=pLeft;
262 aRedlinCompare.pRight=pRight;
263 eCompare=(StringCompare) aColCompareLink.Call(&aRedlinCompare);
265 else
267 if(nDatePos==GetSortedCol())
269 RedlinData *pLeftData=(RedlinData *)(pLeft->GetUserData());
270 RedlinData *pRightData=(RedlinData *)(pRight->GetUserData());
272 if(pLeftData!=NULL && pRightData!=NULL)
274 if(pLeftData->aDateTime < pRightData->aDateTime)
276 eCompare=COMPARE_LESS;
278 else if(pLeftData->aDateTime > pRightData->aDateTime)
280 eCompare=COMPARE_GREATER;
283 else
284 eCompare=SvxSimpleTable::ColCompare(pLeft,pRight);
286 else
288 eCompare=SvxSimpleTable::ColCompare(pLeft,pRight);
293 return eCompare;
295 void SvxRedlinTable::SetCalcView(BOOL bFlag)
297 bIsCalc=bFlag;
298 if(bFlag)
300 nDatePos=CALC_DATE;
302 else
304 nDatePos=WRITER_DATE;
309 void SvxRedlinTable::UpdateFilterTest()
311 Date aDateMax;
312 USHORT nYEAR=aDateMax.GetYear()+100;
313 aDateMax.SetYear(nYEAR);
314 Date aDateMin(1,1,1989);
315 Time aTMin(0);
316 Time aTMax(23,59,59);
319 DateTime aDTMin(aDateMin);
320 DateTime aDTMax(aDateMax);
322 switch(nDaTiMode)
324 case FLT_DATE_BEFORE:
325 aDaTiFilterFirst=aDTMin;
326 aDaTiFilterLast=aDaTiFirst;
327 break;
328 case FLT_DATE_SAVE:
329 case FLT_DATE_SINCE:
330 aDaTiFilterFirst=aDaTiFirst;
331 aDaTiFilterLast=aDTMax;
332 break;
333 case FLT_DATE_EQUAL:
334 aDaTiFilterFirst=aDaTiFirst;
335 aDaTiFilterLast=aDaTiFirst;
336 aDaTiFilterFirst.SetTime(aTMin.GetTime());
337 aDaTiFilterLast.SetTime(aTMax.GetTime());
338 break;
339 case FLT_DATE_NOTEQUAL:
340 aDaTiFilterFirst=aDaTiFirst;
341 aDaTiFilterLast=aDaTiFirst;
342 aDaTiFilterFirst.SetTime(aTMin.GetTime());
343 aDaTiFilterLast.SetTime(aTMax.GetTime());
344 break;
345 case FLT_DATE_BETWEEN:
346 aDaTiFilterFirst=aDaTiFirst;
347 aDaTiFilterLast=aDaTiLast;
348 break;
353 void SvxRedlinTable::SetFilterDate(BOOL bFlag)
355 bDate=bFlag;
358 void SvxRedlinTable::SetDateTimeMode(USHORT nMode)
360 nDaTiMode=nMode;
363 void SvxRedlinTable::SetFirstDate(const Date& aDate)
365 aDaTiFirst.SetDate(aDate.GetDate());
368 void SvxRedlinTable::SetLastDate(const Date& aDate)
370 aDaTiLast.SetDate(aDate.GetDate());
373 void SvxRedlinTable::SetFirstTime(const Time& aTime)
375 aDaTiFirst.SetTime(aTime.GetTime());
378 void SvxRedlinTable::SetLastTime(const Time& aTime)
380 aDaTiLast.SetTime(aTime.GetTime());
383 void SvxRedlinTable::SetFilterAuthor(BOOL bFlag)
385 bAuthor=bFlag;
388 void SvxRedlinTable::SetAuthor(const String &aString)
390 aAuthor=aString;
393 void SvxRedlinTable::SetFilterComment(BOOL bFlag)
395 bComment=bFlag;
398 void SvxRedlinTable::SetCommentParams( const utl::SearchParam* pSearchPara )
400 if(pSearchPara!=NULL)
402 if(pCommentSearcher!=NULL) delete pCommentSearcher;
404 pCommentSearcher=new utl::TextSearch(*pSearchPara, LANGUAGE_SYSTEM );
408 BOOL SvxRedlinTable::IsValidWriterEntry(const String& rString,RedlinData *pUserData)
410 BOOL nTheFlag=TRUE;
411 String aString=rString.GetToken(WRITER_AUTHOR,'\t');
412 if(pUserData==NULL)
414 if(bAuthor)
416 if(aAuthor.CompareTo(aString)==COMPARE_EQUAL)
417 nTheFlag=TRUE;
418 else
419 nTheFlag=FALSE;
422 else
424 DateTime aDateTime=pUserData->aDateTime;
425 nTheFlag=IsValidEntry(&aString,&aDateTime);
427 return nTheFlag;
430 BOOL SvxRedlinTable::IsValidCalcEntry(const String& rString,RedlinData *pUserData)
432 BOOL nTheFlag=TRUE;
433 String aString=rString.GetToken(CALC_AUTHOR,'\t');
434 if(pUserData==NULL)
436 if(bAuthor)
438 if(aAuthor.CompareTo(aString)==COMPARE_EQUAL)
439 nTheFlag=TRUE;
440 else
441 nTheFlag=FALSE;
444 else
446 DateTime aDateTime=pUserData->aDateTime;
447 nTheFlag=IsValidEntry(&aString,&aDateTime);
449 return nTheFlag;
452 BOOL SvxRedlinTable::IsValidEntry(const String* pAuthorStr,
453 const DateTime *pDateTime,const String* pCommentStr)
455 bool nTheFlag=true;
456 if(bAuthor)
458 nTheFlag = aAuthor.CompareTo(*pAuthorStr)==COMPARE_EQUAL;
460 if(bDate && nTheFlag)
462 if(nDaTiMode!=FLT_DATE_NOTEQUAL)
464 nTheFlag=pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast);
466 else
468 nTheFlag=!(pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast));
471 if(bComment && nTheFlag)
473 xub_StrLen nStartPos = 0;
474 xub_StrLen nEndPos = pCommentStr->Len();
476 nTheFlag=pCommentSearcher->SearchFrwrd( *pCommentStr, &nStartPos, &nEndPos);
478 return nTheFlag;
481 BOOL SvxRedlinTable::IsValidEntry(const String* pAuthorStr,const DateTime *pDateTime)
483 BOOL nTheFlag=TRUE;
484 if(bAuthor)
486 if(aAuthor.CompareTo(*pAuthorStr)==COMPARE_EQUAL)
487 nTheFlag=TRUE;
488 else
489 nTheFlag=FALSE;
491 if(bDate && nTheFlag)
493 if(nDaTiMode!=FLT_DATE_NOTEQUAL)
495 nTheFlag=pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast);
497 else
499 nTheFlag=!(pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast));
502 return nTheFlag;
505 BOOL SvxRedlinTable::IsValidComment(const String* pCommentStr)
507 bool nTheFlag=true;
509 if(bComment)
511 xub_StrLen nStartPos = 0;
512 xub_StrLen nEndPos = pCommentStr->Len();
514 nTheFlag=pCommentSearcher->SearchFrwrd( *pCommentStr, &nStartPos, &nEndPos);
516 return nTheFlag;
519 SvLBoxEntry* SvxRedlinTable::InsertEntry(const String& rStr,RedlinData *pUserData,
520 SvLBoxEntry* pParent,ULONG nPos)
522 aEntryColor=GetTextColor();
523 if(pUserData!=NULL)
525 if(pUserData->bDisabled)
526 aEntryColor=Color(COL_GRAY);
529 XubString aStr= rStr;
531 XubString aFirstStr( aStr );
532 xub_StrLen nEnd = aFirstStr.Search( sal_Unicode( '\t' ) );
533 if( nEnd != STRING_NOTFOUND )
535 aFirstStr.Erase( nEnd );
536 aCurEntry = aStr;
537 aCurEntry.Erase( 0, ++nEnd );
539 else
540 aCurEntry.Erase();
542 return SvTreeListBox::InsertEntry( aFirstStr, pParent, FALSE, nPos, pUserData );
546 SvLBoxEntry* SvxRedlinTable::InsertEntry(const String& rStr,RedlinData *pUserData,const Color& aColor,
547 SvLBoxEntry* pParent,ULONG nPos)
549 aEntryColor=aColor;
551 XubString aStr= rStr;
553 XubString aFirstStr( aStr );
554 xub_StrLen nEnd = aFirstStr.Search( sal_Unicode ( '\t' ) );
555 if( nEnd != STRING_NOTFOUND )
557 aFirstStr.Erase( nEnd );
558 aCurEntry = aStr;
559 aCurEntry.Erase( 0, ++nEnd );
561 else
562 aCurEntry.Erase();
564 return SvTreeListBox::InsertEntry( aFirstStr, pParent, FALSE, nPos, pUserData );
567 SvLBoxEntry* SvxRedlinTable::CreateEntry() const
569 return new SvxRedlinEntry;
572 void SvxRedlinTable::InitEntry( SvLBoxEntry* pEntry, const XubString& rStr,
573 const Image& rColl, const Image& rExp, SvLBoxButtonKind eButtonKind )
575 SvLBoxButton* pButton;
576 SvLBoxString* pString;
577 SvLBoxContextBmp* pContextBmp;
579 if( nTreeFlags & TREEFLAG_CHKBTN )
581 pButton= new SvLBoxButton( pEntry,eButtonKind,0,pCheckButtonData );
582 pEntry->AddItem( pButton );
585 pContextBmp= new SvLBoxContextBmp( pEntry,0, rColl,rExp,
586 SVLISTENTRYFLAG_EXPANDED);
587 pEntry->AddItem( pContextBmp );
589 pString = new SvLBoxColorString( pEntry, 0, rStr ,aEntryColor);
590 pEntry->AddItem( pString );
592 XubString aToken;
594 xub_Unicode* pCurToken = (xub_Unicode*)aCurEntry.GetBuffer();
595 USHORT nCurTokenLen;
596 xub_Unicode* pNextToken = (xub_Unicode*)GetToken( pCurToken, nCurTokenLen );
597 USHORT nCount = TabCount(); nCount--;
599 for( USHORT nToken = 0; nToken < nCount; nToken++ )
601 if( pCurToken && nCurTokenLen )
602 // aToken.Assign( pCurToken, nCurTokenLen );
603 aToken = XubString( pCurToken, nCurTokenLen );
604 else
605 aToken.Erase();
607 SvLBoxColorString* pStr = new SvLBoxColorString( pEntry, 0, aToken ,aEntryColor);
608 pEntry->AddItem( pStr );
610 pCurToken = pNextToken;
611 if( pCurToken )
612 pNextToken = (xub_Unicode*)GetToken( pCurToken, nCurTokenLen );
613 else
614 nCurTokenLen = 0;
621 //============================================================================
622 // class SvxTPView
623 //----------------------------------------------------------------------------
625 SvxTPView::SvxTPView( Window * pParent)
626 : TabPage( pParent, SVX_RES(SID_REDLIN_VIEW_PAGE)),
627 aViewData ( this, SVX_RES( DG_VIEW) ),
628 PbAccept ( this, SVX_RES(PB_ACCEPT ) ),
629 PbReject ( this, SVX_RES(PB_REJECT ) ),
630 PbAcceptAll ( this, SVX_RES(PB_ACCEPTALL ) ),
631 PbRejectAll ( this, SVX_RES(PB_REJECTALL ) ),
632 PbUndo ( this, SVX_RES(PB_UNDO ) ),
633 aTitle1 ( SVX_RES( STR_TITLE1 ) ), // lokale Resource
634 aTitle2 ( SVX_RES( STR_TITLE2 ) ),
635 aTitle3 ( SVX_RES( STR_TITLE3 ) ),
636 aTitle4 ( SVX_RES( STR_TITLE4 ) ),
637 aTitle5 ( SVX_RES( STR_TITLE5 ) ),
638 aStrMyName ( SVX_RES( STR_VIEW) )
640 FreeResource();
642 aViewData.SetHelpId(HID_REDLINING_VIEW_DG_VIEW_TABLE);
643 aViewData.SetHeaderBarHelpId(HID_REDLINING_VIEW_DG_VIEW_HEADER);
645 aMinSize=GetSizePixel();
647 Link aLink=LINK( this, SvxTPView, PbClickHdl);
649 PbAccept.SetClickHdl(aLink);
650 PbAcceptAll.SetClickHdl(aLink);
651 PbReject.SetClickHdl(aLink);
652 PbRejectAll.SetClickHdl(aLink);
653 PbUndo.SetClickHdl(aLink);
655 nDistance=PbAccept.GetSizePixel().Height()+2*MIN_DISTANCE;
656 aViewData.SetTabs(nStaticTabs);
659 String SvxTPView::GetMyName() const
661 return aStrMyName;
664 void SvxTPView::Resize()
666 Size aSize=GetOutputSizePixel();
667 Point aPos=aViewData.GetPosPixel();
668 aSize.Height()-=aPos.Y()+nDistance;
669 aSize.Width()-=2*aPos.X();
671 long newY=aPos.Y()+aSize.Height()+MIN_DISTANCE;
672 aPos=PbAccept.GetPosPixel();
673 aPos.Y()=newY;
674 PbAccept.SetPosPixel(aPos);
675 aPos=PbAcceptAll.GetPosPixel();
676 aPos.Y()=newY;
677 PbAcceptAll.SetPosPixel(aPos);
678 aPos=PbReject.GetPosPixel();
679 aPos.Y()=newY;
680 PbReject.SetPosPixel(aPos);
681 aPos=PbRejectAll.GetPosPixel();
682 aPos.Y()=newY;
683 PbRejectAll.SetPosPixel(aPos);
685 if(PbUndo.IsVisible())
687 aPos=PbUndo.GetPosPixel();
688 aPos.Y()=newY;
689 PbUndo.SetPosPixel(aPos);
691 aViewData.SetSizePixel(aSize);
694 void SvxTPView::InsertWriterHeader()
696 String aStrTab(sal_Unicode('\t'));
697 String aString(aTitle1);
698 aString+=aStrTab;
699 aString+=aTitle3;
700 aString+=aStrTab;
701 aString+=aTitle4;
702 aString+=aStrTab;
703 aString+=aTitle5;
704 aViewData.ClearHeader();
705 aViewData.InsertHeaderEntry(aString);
708 void SvxTPView::InsertCalcHeader()
710 String aStrTab(sal_Unicode('\t'));
711 String aString(aTitle1);
712 aString+=aStrTab;
713 aString+=aTitle2;
714 aString+=aStrTab;
715 aString+=aTitle3;
716 aString+=aStrTab;
717 aString+=aTitle4;
718 aString+=aStrTab;
719 aString+=aTitle5;
720 aViewData.ClearHeader();
721 aViewData.InsertHeaderEntry(aString);
724 void SvxTPView::EnableAccept(BOOL nFlag)
726 PbAccept.Enable(nFlag);
729 void SvxTPView::EnableAcceptAll(BOOL nFlag)
731 PbAcceptAll.Enable(nFlag);
734 void SvxTPView::EnableReject(BOOL nFlag)
736 PbReject.Enable(nFlag);
739 void SvxTPView::EnableRejectAll(BOOL nFlag)
741 PbRejectAll.Enable(nFlag);
744 void SvxTPView::ShowUndo(BOOL nFlag)
746 PbUndo.Show(nFlag);
749 void SvxTPView::EnableUndo(BOOL nFlag)
751 PbUndo.Enable(nFlag);
754 Size SvxTPView::GetMinSizePixel()
756 Size aSize=aMinSize;
757 if(PbUndo.IsVisible())
759 ULONG nSize=PbUndo.GetSizePixel().Width()
760 +PbUndo.GetPosPixel().X()
761 +PbAccept.GetPosPixel().X();
763 aSize.Width()=nSize;
766 return aSize;
770 SvxRedlinTable* SvxTPView::GetTableControl()
772 return &aViewData;
775 IMPL_LINK( SvxTPView, PbClickHdl, PushButton*, pPushB )
777 if(pPushB==&PbAccept)
779 AcceptClickLk.Call(this);
781 else if(pPushB==&PbAcceptAll)
783 AcceptAllClickLk.Call(this);
785 else if(pPushB==&PbReject)
787 RejectClickLk.Call(this);
789 else if(pPushB==&PbRejectAll)
791 RejectAllClickLk.Call(this);
793 else if(pPushB==&PbUndo)
795 UndoClickLk.Call(this);
798 return 0;
804 //============================================================================
805 // class SvxTPFilter
806 //----------------------------------------------------------------------------
808 SvxTPFilter::SvxTPFilter( Window * pParent)
809 : TabPage( pParent, SVX_RES(SID_REDLIN_FILTER_PAGE)),
810 pRedlinTable(NULL),
811 aCbDate ( this, SVX_RES( CB_DATE ) ),
812 aLbDate ( this, SVX_RES( LB_DATE ) ),
813 aDfDate ( this, SVX_RES( DF_DATE ) ),
814 aTfDate ( this, SVX_RES( TF_DATE ) ),
815 aIbClock ( this, SVX_RES( IB_CLOCK ) ),
816 aFtDate2 ( this, SVX_RES( FT_DATE2 ) ),
817 aDfDate2 ( this, SVX_RES( DF_DATE2 ) ),
818 aTfDate2 ( this, SVX_RES( TF_DATE2 ) ),
819 aIbClock2 ( this, SVX_RES( IB_CLOCK2) ),
820 aCbAuthor ( this, SVX_RES( CB_AUTOR ) ),
821 aLbAuthor ( this, SVX_RES( LB_AUTOR ) ),
822 aCbRange ( this, SVX_RES( CB_RANGE ) ),
823 aEdRange ( this, SVX_RES( ED_RANGE ) ),
824 aBtnRange ( this, SVX_RES( BTN_REF ) ),
825 aLbAction ( this, SVX_RES( LB_ACTION ) ),
826 aCbComment ( this, SVX_RES( CB_COMMENT) ),
827 aEdComment ( this, SVX_RES( ED_COMMENT) ),
828 aActionStr ( SVX_RES( STR_ACTION) ),
829 aStrMyName ( SVX_RES( STR_FILTER) ),
830 bModified (FALSE)
832 Image aImgTimeHC( SVX_RES( IMG_TIME_H ) );
833 FreeResource();
835 aIbClock.SetModeImage( aImgTimeHC, BMP_COLOR_HIGHCONTRAST );
836 aIbClock2.SetModeImage( aImgTimeHC, BMP_COLOR_HIGHCONTRAST );
838 aDfDate.SetShowDateCentury( TRUE );
839 aDfDate2.SetShowDateCentury( TRUE );
841 aRangeStr=aCbRange.GetText();
842 aLbDate.SelectEntryPos(0);
843 aLbDate.SetSelectHdl( LINK( this, SvxTPFilter, SelDateHdl ) );
844 aIbClock.SetClickHdl( LINK( this, SvxTPFilter, TimeHdl) );
845 aIbClock2.SetClickHdl( LINK( this, SvxTPFilter,TimeHdl) );
846 aBtnRange.SetClickHdl( LINK( this, SvxTPFilter, RefHandle));
848 Link aLink=LINK( this, SvxTPFilter, RowEnableHdl) ;
849 aCbDate.SetClickHdl(aLink);
850 aCbAuthor.SetClickHdl(aLink);
851 aCbRange.SetClickHdl(aLink);
852 aCbComment.SetClickHdl(aLink);
854 Link a2Link=LINK( this, SvxTPFilter, ModifyDate);
855 aDfDate.SetModifyHdl(a2Link);
856 aTfDate.SetModifyHdl(a2Link);
857 aDfDate2.SetModifyHdl(a2Link);
858 aTfDate2.SetModifyHdl(a2Link);
860 Link a3Link=LINK( this, SvxTPFilter, ModifyHdl);
861 aEdRange.SetModifyHdl(a3Link);
862 aEdComment.SetModifyHdl(a3Link);
863 aLbAction.SetSelectHdl(a3Link);
864 aLbAuthor.SetSelectHdl(a3Link);
866 RowEnableHdl(&aCbDate);
867 RowEnableHdl(&aCbAuthor);
868 RowEnableHdl(&aCbRange);
869 RowEnableHdl(&aCbComment);
871 Date aDate;
872 Time aTime;
873 aDfDate.SetDate(aDate);
874 aTfDate.SetTime(aTime);
875 aDfDate2.SetDate(aDate);
876 aTfDate2.SetTime(aTime);
877 HideRange();
878 ShowAction();
879 bModified=FALSE;
882 void SvxTPFilter::SetRedlinTable(SvxRedlinTable* pTable)
884 pRedlinTable=pTable;
887 String SvxTPFilter::GetMyName() const
889 return aStrMyName;
892 void SvxTPFilter::DisableRange(BOOL bFlag)
894 if(bFlag)
896 aCbRange.Disable();
897 aEdRange.Disable();
898 aBtnRange.Disable();
900 else
902 aCbRange.Enable();
903 aEdRange.Enable();
904 aBtnRange.Enable();
908 void SvxTPFilter::ShowDateFields(USHORT nKind)
910 String aEmpty;
911 switch(nKind)
913 case FLT_DATE_BEFORE:
914 EnableDateLine1(TRUE);
915 EnableDateLine2(FALSE);
916 break;
917 case FLT_DATE_SINCE:
918 EnableDateLine1(TRUE);
919 EnableDateLine2(FALSE);
920 break;
921 case FLT_DATE_EQUAL:
922 EnableDateLine1(TRUE);
923 aTfDate.Disable();
924 aTfDate.SetText(aEmpty);
925 EnableDateLine2(FALSE);
926 break;
927 case FLT_DATE_NOTEQUAL:
928 EnableDateLine1(TRUE);
929 aTfDate.Disable();
930 aTfDate.SetText(aEmpty);
931 EnableDateLine2(FALSE);
932 break;
933 case FLT_DATE_BETWEEN:
934 EnableDateLine1(TRUE);
935 EnableDateLine2(TRUE);
936 break;
937 case FLT_DATE_SAVE:
938 EnableDateLine1(FALSE);
939 EnableDateLine2(FALSE);
940 break;
944 void SvxTPFilter::EnableDateLine1(BOOL bFlag)
946 if(bFlag && aCbDate.IsChecked())
948 aDfDate.Enable();
949 aTfDate.Enable();
950 aIbClock.Enable();
952 else
954 aDfDate.Disable();
955 aTfDate.Disable();
956 aIbClock.Disable();
959 void SvxTPFilter::EnableDateLine2(BOOL bFlag)
961 String aEmpty;
962 if(bFlag && aCbDate.IsChecked())
964 aFtDate2.Enable();
965 aDfDate2.Enable();
966 aTfDate2.Enable();
967 aIbClock2.Enable();
969 else
971 aFtDate2.Disable();
972 aDfDate2.Disable();
973 aDfDate2.SetText(aEmpty);
974 aTfDate2.Disable();
975 aTfDate2.SetText(aEmpty);
976 aIbClock2.Disable();
980 Date SvxTPFilter::GetFirstDate() const
982 return aDfDate.GetDate();
985 void SvxTPFilter::SetFirstDate(const Date &aDate)
987 aDfDate.SetDate(aDate);
990 Time SvxTPFilter::GetFirstTime() const
992 return aTfDate.GetTime();
995 void SvxTPFilter::SetFirstTime(const Time &aTime)
997 aTfDate.SetTime(aTime);
1001 Date SvxTPFilter::GetLastDate() const
1003 return aDfDate2.GetDate();
1006 void SvxTPFilter::SetLastDate(const Date &aDate)
1008 aDfDate2.SetDate(aDate);
1011 Time SvxTPFilter::GetLastTime() const
1013 return aTfDate2.GetTime();
1016 void SvxTPFilter::SetLastTime(const Time &aTime)
1018 aTfDate2.SetTime(aTime);
1021 void SvxTPFilter::SetDateMode(USHORT nMode)
1023 aLbDate.SelectEntryPos(nMode);
1024 SelDateHdl(&aLbDate);
1027 USHORT SvxTPFilter::GetDateMode()
1029 return (USHORT) aLbDate.GetSelectEntryPos();
1031 void SvxTPFilter::ClearAuthors()
1033 aLbAuthor.Clear();
1036 void SvxTPFilter::InsertAuthor( const String& rString, USHORT nPos)
1038 aLbAuthor.InsertEntry(rString,nPos);
1041 String SvxTPFilter::GetSelectedAuthor() const
1043 return aLbAuthor.GetSelectEntry();
1046 USHORT SvxTPFilter::GetSelectedAuthorPos()
1048 return (USHORT) aLbAuthor.GetSelectEntryPos();
1051 void SvxTPFilter::SelectedAuthorPos(USHORT nPos)
1053 aLbAuthor.SelectEntryPos(nPos);
1056 USHORT SvxTPFilter::SelectAuthor(const String& aString)
1058 aLbAuthor.SelectEntry(aString);
1059 return aLbAuthor.GetSelectEntryPos();
1062 void SvxTPFilter::SetRange(const String& rString)
1064 aEdRange.SetText(rString);
1067 String SvxTPFilter::GetRange() const
1069 return aEdRange.GetText();
1072 void SvxTPFilter::SetFocusToRange()
1074 aEdRange.GrabFocus();
1077 void SvxTPFilter::HideRange(BOOL bHide)
1079 if(bHide)
1081 aCbRange.Hide();
1082 aEdRange.Hide();
1083 aBtnRange.Hide();
1085 else
1087 ShowAction(FALSE);
1088 aCbRange.SetText(aRangeStr);
1089 aCbRange.Show();
1090 aEdRange.Show();
1091 aBtnRange.Show();
1095 void SvxTPFilter::HideClocks(BOOL bHide)
1097 if(bHide)
1099 aIbClock. Hide();
1100 aIbClock2.Hide();
1102 else
1104 aIbClock. Show();
1105 aIbClock2.Show();
1109 void SvxTPFilter::SetComment(const String &rComment)
1111 aEdComment.SetText(rComment);
1113 String SvxTPFilter::GetComment()const
1115 return aEdComment.GetText();
1118 BOOL SvxTPFilter::IsDate()
1120 return aCbDate.IsChecked();
1123 BOOL SvxTPFilter::IsAuthor()
1125 return aCbAuthor.IsChecked();
1128 BOOL SvxTPFilter::IsRange()
1130 return aCbRange.IsChecked();
1132 BOOL SvxTPFilter::IsAction()
1134 return aCbRange.IsChecked();
1137 BOOL SvxTPFilter::IsComment()
1139 return aCbComment.IsChecked();
1142 void SvxTPFilter::CheckDate(BOOL bFlag)
1144 aCbDate.Check(bFlag);
1145 RowEnableHdl(&aCbDate);
1146 bModified=FALSE;
1149 void SvxTPFilter::CheckAuthor(BOOL bFlag)
1151 aCbAuthor.Check(bFlag);
1152 RowEnableHdl(&aCbAuthor);
1153 bModified=FALSE;
1156 void SvxTPFilter::CheckRange(BOOL bFlag)
1158 aCbRange.Check(bFlag);
1159 RowEnableHdl(&aCbRange);
1160 bModified=FALSE;
1163 void SvxTPFilter::CheckAction(BOOL bFlag)
1165 aCbRange.Check(bFlag);
1166 RowEnableHdl(&aCbRange);
1167 bModified=FALSE;
1170 void SvxTPFilter::CheckComment(BOOL bFlag)
1172 aCbComment.Check(bFlag);
1173 RowEnableHdl(&aCbComment);
1174 bModified=FALSE;
1177 void SvxTPFilter::ShowAction(BOOL bShow)
1179 if(!bShow)
1181 aCbRange.Hide();
1182 aLbAction.Hide();
1183 aCbRange.SetHelpId(HID_REDLINING_FILTER_CB_RANGE);
1185 else
1187 HideRange();
1188 aCbRange.SetText(aActionStr);
1189 aCbRange.SetHelpId(HID_REDLINING_FILTER_CB_ACTION);
1190 aCbRange.Show();
1191 aLbAction.Show();
1196 ListBox* SvxTPFilter::GetLbAction()
1198 return &aLbAction;
1201 IMPL_LINK( SvxTPFilter, SelDateHdl, ListBox*, pLb )
1203 ShowDateFields((USHORT)aLbDate.GetSelectEntryPos());
1204 ModifyHdl(pLb);
1205 return 0;
1208 IMPL_LINK( SvxTPFilter, RowEnableHdl, CheckBox*, pCB )
1210 if(pCB==&aCbDate)
1212 aLbDate.Enable(aCbDate.IsChecked());
1213 aLbDate.Invalidate();
1214 EnableDateLine1(FALSE);
1215 EnableDateLine2(FALSE);
1216 if(aCbDate.IsChecked()) SelDateHdl(&aLbDate);
1218 else if(pCB==&aCbAuthor)
1220 aLbAuthor.Enable(aCbAuthor.IsChecked());
1221 aLbAuthor.Invalidate();
1223 else if(pCB==&aCbRange)
1225 aLbAction.Enable(aCbRange.IsChecked());
1226 aLbAction.Invalidate();
1227 aEdRange.Enable(aCbRange.IsChecked());
1228 aBtnRange.Enable(aCbRange.IsChecked());
1230 else if(pCB==&aCbComment)
1232 aEdComment.Enable(aCbComment.IsChecked());
1233 aEdComment.Invalidate();
1236 ModifyHdl(pCB);
1237 return 0;
1240 IMPL_LINK( SvxTPFilter, TimeHdl, ImageButton*,pIB )
1242 Date aDate;
1243 Time aTime;
1244 if(pIB==&aIbClock)
1246 aDfDate.SetDate(aDate);
1247 aTfDate.SetTime(aTime);
1249 else if(pIB==&aIbClock2)
1251 aDfDate2.SetDate(aDate);
1252 aTfDate2.SetTime(aTime);
1254 ModifyHdl(&aDfDate);
1255 return 0;
1258 IMPL_LINK( SvxTPFilter, ModifyHdl, void*, pCtr)
1260 if(pCtr!=NULL)
1262 if(pCtr==&aCbDate || pCtr==&aLbDate ||
1263 pCtr==&aDfDate || pCtr==&aTfDate ||
1264 pCtr==&aIbClock || pCtr==&aFtDate2||
1265 pCtr==&aDfDate2 || pCtr==&aTfDate2||
1266 pCtr==&aIbClock2)
1268 aModifyDateLink.Call(this);
1270 else if(pCtr==&aCbAuthor || pCtr==&aLbAuthor)
1272 aModifyAuthorLink.Call(this);
1274 else if(pCtr==&aCbRange || pCtr==&aEdRange ||
1275 pCtr==&aBtnRange )
1277 aModifyRefLink.Call(this);
1279 else if(pCtr==&aCbComment || pCtr==&aEdComment)
1281 aModifyComLink.Call(this);
1284 bModified=TRUE;
1285 aModifyLink.Call(this);
1287 return 0;
1290 void SvxTPFilter::DeactivatePage()
1292 if(bModified)
1294 if(pRedlinTable!=NULL)
1296 pRedlinTable->SetFilterDate(IsDate());
1297 pRedlinTable->SetDateTimeMode(GetDateMode());
1298 pRedlinTable->SetFirstDate(aDfDate.GetDate());
1299 pRedlinTable->SetLastDate(aDfDate2.GetDate());
1300 pRedlinTable->SetFirstTime(aTfDate.GetTime());
1301 pRedlinTable->SetLastTime(aTfDate2.GetTime());
1302 pRedlinTable->SetFilterAuthor(IsAuthor());
1303 pRedlinTable->SetAuthor(GetSelectedAuthor());
1305 pRedlinTable->SetFilterComment(IsComment());
1307 utl::SearchParam aSearchParam( aEdComment.GetText(),
1308 utl::SearchParam::SRCH_REGEXP,FALSE,FALSE,FALSE );
1310 pRedlinTable->SetCommentParams(&aSearchParam);
1312 pRedlinTable->UpdateFilterTest();
1315 aReadyLink.Call(this);
1317 bModified=FALSE;
1318 TabPage::DeactivatePage();
1321 void SvxTPFilter::Enable( bool bEnable, bool bChild)
1323 TabPage::Enable(bEnable,bChild);
1324 if(aCbDate.IsEnabled())
1326 RowEnableHdl(&aCbDate);
1327 RowEnableHdl(&aCbAuthor);
1328 RowEnableHdl(&aCbRange);
1329 RowEnableHdl(&aCbComment);
1332 void SvxTPFilter::Disable( bool bChild)
1334 Enable( false, bChild );
1337 IMPL_LINK( SvxTPFilter, ModifyDate, void*,pTF)
1340 Date aDate;
1341 Time aTime(0);
1342 if(&aDfDate==pTF)
1344 if(aDfDate.GetText().Len()==0)
1345 aDfDate.SetDate(aDate);
1347 if(pRedlinTable!=NULL)
1348 pRedlinTable->SetFirstDate(aDfDate.GetDate());
1350 else if(&aDfDate2==pTF)
1352 if(aDfDate2.GetText().Len()==0)
1353 aDfDate2.SetDate(aDate);
1355 if(pRedlinTable!=NULL)
1356 pRedlinTable->SetLastDate(aDfDate2.GetDate());
1358 else if(&aTfDate==pTF)
1360 if(aTfDate.GetText().Len()==0)
1361 aTfDate.SetTime(aTime);
1363 if(pRedlinTable!=NULL)
1364 pRedlinTable->SetFirstTime(aTfDate.GetTime());
1366 else if(&aTfDate2==pTF)
1368 if(aTfDate2.GetText().Len()==0)
1369 aTfDate2.SetTime(aTime);
1371 if(pRedlinTable!=NULL)
1372 pRedlinTable->SetLastTime(aTfDate2.GetTime());
1375 ModifyHdl(&aDfDate);
1376 return 0;
1379 IMPL_LINK( SvxTPFilter, RefHandle, PushButton*, pRef )
1381 if(pRef!=NULL)
1383 aRefLink.Call(this);
1385 return 0;
1388 static Size gDiffSize;
1389 //============================================================================
1390 // class SvxAcceptChgCtr
1391 //----------------------------------------------------------------------------
1393 SvxAcceptChgCtr::SvxAcceptChgCtr( Window* pParent, WinBits nWinStyle)
1394 : Control(pParent,nWinStyle |WB_DIALOGCONTROL),
1395 aTCAccept(this,WB_TABSTOP |WB_DIALOGCONTROL)
1397 pTPFilter=new SvxTPFilter(&aTCAccept);
1398 pTPView=new SvxTPView(&aTCAccept);
1399 aMinSize=pTPView->GetMinSizePixel();
1401 aTCAccept.InsertPage( TP_VIEW, pTPView->GetMyName());
1402 aTCAccept.InsertPage( TP_FILTER, pTPFilter->GetMyName());
1403 aTCAccept.SetTabPage( TP_VIEW, pTPView);
1404 aTCAccept.SetTabPage( TP_FILTER, pTPFilter);
1405 aTCAccept.SetHelpId(HID_REDLINING_TABCONTROL);
1407 aTCAccept.SetTabPageSizePixel(aMinSize);
1408 Size aSize=aTCAccept.GetSizePixel();
1410 gDiffSize.Height()=aSize.Height()-aMinSize.Height();
1411 gDiffSize.Width()=aSize.Width()-aMinSize.Width();
1414 pTPFilter->SetRedlinTable(GetViewTable());
1416 aTCAccept.Show();
1417 ShowViewPage();
1420 SvxAcceptChgCtr::SvxAcceptChgCtr( Window* pParent, const ResId& rResId )
1421 : Control(pParent,rResId ),
1422 aTCAccept(this,WB_TABSTOP |WB_DIALOGCONTROL)
1424 pTPFilter=new SvxTPFilter(&aTCAccept);
1425 pTPView=new SvxTPView(&aTCAccept);
1426 aMinSize=pTPView->GetMinSizePixel();
1428 aTCAccept.InsertPage( TP_VIEW, pTPView->GetMyName());
1429 aTCAccept.InsertPage( TP_FILTER, pTPFilter->GetMyName());
1430 aTCAccept.SetTabPage( TP_VIEW, pTPView);
1431 aTCAccept.SetTabPage( TP_FILTER, pTPFilter);
1432 aTCAccept.SetHelpId(HID_REDLINING_TABCONTROL);
1434 aTCAccept.SetTabPageSizePixel(aMinSize);
1435 Size aSize=aTCAccept.GetSizePixel();
1437 gDiffSize.Height()=aSize.Height()-aMinSize.Height();
1438 gDiffSize.Width()=aSize.Width()-aMinSize.Width();
1441 pTPFilter->SetRedlinTable(GetViewTable());
1442 WinBits nWinStyle=GetStyle()|WB_DIALOGCONTROL;
1443 SetStyle(nWinStyle);
1445 aTCAccept.Show();
1446 ShowViewPage();
1447 Resize();
1450 SvxAcceptChgCtr::~SvxAcceptChgCtr()
1452 delete pTPView;
1453 delete pTPFilter;
1456 void SvxAcceptChgCtr::Resize()
1458 aMinSize=pTPView->GetMinSizePixel();
1459 Size aSize=GetOutputSizePixel();
1460 BOOL bFlag=FALSE;
1462 if(aMinSize.Height()>aSize.Height())
1464 aSize.Height()=aMinSize.Height();
1465 bFlag=TRUE;
1467 if(aMinSize.Width()>aSize.Width())
1469 aSize.Width()=aMinSize.Width();
1470 bFlag=TRUE;
1473 if(bFlag)
1475 SetOutputSizePixel(aSize);
1476 aMinSizeLink.Call(this);
1479 aSize.Height()-=2;
1480 aSize.Width()-=2;
1481 aTCAccept.SetSizePixel(aSize);
1484 Size SvxAcceptChgCtr::GetMinSizePixel() const
1486 Size aSize=pTPView->GetMinSizePixel();
1487 aSize.Height()+=gDiffSize.Height();
1488 aSize.Width()+=gDiffSize.Width();
1489 return aSize;
1492 void SvxAcceptChgCtr::ShowFilterPage()
1494 aTCAccept.SetCurPageId(TP_FILTER);
1497 void SvxAcceptChgCtr::ShowViewPage()
1499 aTCAccept.SetCurPageId(TP_VIEW);
1502 BOOL SvxAcceptChgCtr::IsFilterPageVisible()
1504 return (aTCAccept.GetCurPageId()==TP_FILTER);
1507 BOOL SvxAcceptChgCtr::IsViewPageVisible()
1509 return (aTCAccept.GetCurPageId()==TP_VIEW);
1512 SvxTPFilter* SvxAcceptChgCtr::GetFilterPage()
1514 return pTPFilter;
1517 SvxTPView* SvxAcceptChgCtr::GetViewPage()
1519 return pTPView;
1522 SvxRedlinTable* SvxAcceptChgCtr::GetViewTable()
1524 if(pTPView!=NULL)
1526 return pTPView->GetTableControl();
1528 else
1530 return NULL;