xref: /aoo41x/main/svx/source/dialog/ctredlin.cxx (revision 4d7c9de0)
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_svx.hxx"
26 
27 // System - Includes ---------------------------------------------------------
28 #include <vcl/svapp.hxx>
29 #include <tools/shl.hxx>
30 #include <sfx2/app.hxx>
31 #include <sfx2/module.hxx>
32 #include <svtools/txtcmp.hxx>
33 #include <unotools/charclass.hxx>
34 // INCLUDE -------------------------------------------------------------------
35 #include <editeng/unolingu.hxx>
36 #include <svx/dialmgr.hxx>
37 #include "ctredlin.hrc"
38 #include <svx/ctredlin.hxx>
39 #include "helpid.hrc"
40 
41 //============================================================================
42 //	Local Defines and Function
43 //----------------------------------------------------------------------------
44 
EnableDisable(Window & rWin,sal_Bool bEnable)45 inline void EnableDisable( Window& rWin, sal_Bool bEnable )
46 {
47 	if (bEnable)
48 		rWin.Enable();
49 	else
50 		rWin.Disable();
51 }
52 
53 static long nStaticTabs[]=
54 {
55 	5,10,65,120,170,220
56 };
57 
58 #define	MIN_DISTANCE	6
59 #define WRITER_AUTHOR   1
60 #define WRITER_DATE		2
61 #define CALC_AUTHOR		2
62 #define CALC_DATE		3
63 
RedlinData()64 RedlinData::RedlinData()
65 {
66 	bDisabled=sal_False;
67 	pData=NULL;
68 }
~RedlinData()69 RedlinData::~RedlinData()
70 {
71 }
72 
73 //============================================================================
74 //	class SvxRedlinEntry (Eintraege fuer Liste)
75 //----------------------------------------------------------------------------
76 
SvxRedlinEntry()77 SvxRedlinEntry::SvxRedlinEntry()
78 	:SvLBoxEntry()
79 {
80 }
81 
~SvxRedlinEntry()82 SvxRedlinEntry::~SvxRedlinEntry()
83 {
84 	RedlinData* pRedDat=(RedlinData*) GetUserData();
85 	if(pRedDat!=NULL)
86 	{
87 		delete pRedDat;
88 	}
89 }
90 
91 /*************************************************************************
92 #* Funktionen der in den SvxRedlinTable eingefuegten Items
93 #************************************************************************/
94 
95 DBG_NAME(SvLBoxColorString);
96 
97 /*************************************************************************
98 #*	Member:		SvLBoxColorString							Datum:23.10.97
99 #*------------------------------------------------------------------------
100 #*
101 #*  Klasse:		SvLBoxColorString
102 #*
103 #*  Funktion:	Konstruktor der Klasse SvLBoxColorString
104 #*
105 #*  Input:		Box- Entry,Flags, Text fuer Anzeige, Schrift
106 #*
107 #*	Output:		---
108 #*
109 #************************************************************************/
110 
SvLBoxColorString(SvLBoxEntry * pEntry,sal_uInt16 nFlags,const XubString & rStr,const Color & rCol)111 SvLBoxColorString::SvLBoxColorString( SvLBoxEntry*pEntry,sal_uInt16 nFlags,const XubString& rStr,
112 									const Color& rCol)
113 
114 : SvLBoxString( pEntry, nFlags, rStr )
115 {
116 	DBG_CTOR(SvLBoxColorString,0);
117 	aPrivColor=rCol;
118 	SetText( pEntry, rStr );
119 }
120 
121 /*************************************************************************
122 #*	Member:		SvLBoxColorString							Datum:23.10.97
123 #*------------------------------------------------------------------------
124 #*
125 #*  Klasse:		SvLBoxColorString
126 #*
127 #*  Funktion:	Default Konstruktor der Klasse SvLBoxColorString
128 #*
129 #*  Input:		---
130 #*
131 #*	Output:		---
132 #*
133 #************************************************************************/
134 
SvLBoxColorString()135 SvLBoxColorString::SvLBoxColorString()
136 : SvLBoxString()
137 {
138 	DBG_CTOR(SvLBoxColorString,0);
139 }
140 
141 /*************************************************************************
142 #*	Member:		~SvLBoxColorString							Datum:23.10.97
143 #*------------------------------------------------------------------------
144 #*
145 #*  Klasse:		SvLBoxColorString
146 #*
147 #*  Funktion:	Destruktor der Klasse SvLBoxColorString
148 #*
149 #*  Input:		---
150 #*
151 #*	Output:		---
152 #*
153 #************************************************************************/
154 
~SvLBoxColorString()155 SvLBoxColorString::~SvLBoxColorString()
156 {
157 	DBG_DTOR(SvLBoxColorString,0);
158 }
159 
160 
161 /*************************************************************************
162 #*	Member:		SvLBoxColorString							Datum:23.10.97
163 #*------------------------------------------------------------------------
164 #*
165 #*  Klasse:		SvLBoxColorString
166 #*
167 #*  Funktion:	Erzeugt einen neuen SvLBoxColorString
168 #*
169 #*  Input:		---
170 #*
171 #*	Output:		SvLBoxColorString
172 #*
173 #************************************************************************/
174 
Create() const175 SvLBoxItem* SvLBoxColorString::Create() const
176 {
177 	DBG_CHKTHIS(SvLBoxColorString,0);
178 	return new SvLBoxColorString;
179 }
180 
181 
182 
183 /*************************************************************************
184 #*	Member:		SvLBoxColorString							Datum:23.10.97
185 #*------------------------------------------------------------------------
186 #*
187 #*  Klasse:		SvLBoxColorString
188 #*
189 #*  Funktion:	Zeichenroutine des SvLBoxColorString. Gezeichnet wird
190 #*				der entsprechende Text mit der eingestellten Farbe
191 #*				im Ausgabe- Device.
192 #*
193 #*  Input:		Position, Ausgabe- Device, Flag fuer Selection,
194 #*				Zeiger auf den Eintrag
195 #*
196 #*	Output:		---
197 #*
198 #************************************************************************/
199 
Paint(const Point & rPos,SvLBox & rDev,sal_uInt16 nFlags,SvLBoxEntry * pEntry)200 void SvLBoxColorString::Paint( const Point& rPos, SvLBox& rDev,
201 							 sal_uInt16 nFlags,	SvLBoxEntry* pEntry )
202 {
203 	Color aColor=rDev.GetTextColor();
204 	Color a2Color=aColor;
205 	if(!(nFlags & SVLISTENTRYFLAG_SELECTED))
206 	{
207 		rDev.SetTextColor(aPrivColor);
208 	}
209 	SvLBoxString::Paint(rPos,rDev,nFlags,pEntry );
210 	rDev.SetTextColor(a2Color);
211 }
212 
213 //============================================================================
214 //	class SvxRedlinTable
215 //----------------------------------------------------------------------------
216 
SvxRedlinTable(Window * pParent,WinBits nBits)217 SvxRedlinTable::SvxRedlinTable( Window* pParent,WinBits nBits ):
218 		SvxSimpleTable(pParent,nBits )
219 {
220 	bAuthor=sal_False;
221 	bDate=sal_False;
222 	bIsCalc=sal_False;
223 	bComment=sal_False;
224 	nDatePos=WRITER_DATE;
225 	pCommentSearcher=NULL;
226     SetNodeDefaultImages();
227 }
228 
SvxRedlinTable(Window * pParent,const ResId & rResId)229 SvxRedlinTable::SvxRedlinTable( Window* pParent,const ResId& rResId):
230 		SvxSimpleTable(pParent,rResId)
231 {
232 	bAuthor=sal_False;
233 	bDate=sal_False;
234 	bIsCalc=sal_False;
235 	bComment=sal_False;
236 	nDatePos=WRITER_DATE;
237 	pCommentSearcher=NULL;
238     SetNodeDefaultImages();
239 }
240 
~SvxRedlinTable()241 SvxRedlinTable::~SvxRedlinTable()
242 {
243 	if(pCommentSearcher!=NULL)
244 		delete pCommentSearcher;
245 }
246 
ColCompare(SvLBoxEntry * pLeft,SvLBoxEntry * pRight)247 StringCompare SvxRedlinTable::ColCompare(SvLBoxEntry* pLeft,SvLBoxEntry* pRight)
248 {
249 	StringCompare eCompare=COMPARE_EQUAL;
250 
251 	if(aColCompareLink.IsSet())
252 	{
253 		SvSortData aRedlinCompare;
254 		aRedlinCompare.pLeft=pLeft;
255 		aRedlinCompare.pRight=pRight;
256 		eCompare=(StringCompare) aColCompareLink.Call(&aRedlinCompare);
257 	}
258 	else
259 	{
260 		if(nDatePos==GetSortedCol())
261 		{
262 			RedlinData *pLeftData=(RedlinData *)(pLeft->GetUserData());
263 			RedlinData *pRightData=(RedlinData *)(pRight->GetUserData());
264 
265 			if(pLeftData!=NULL && pRightData!=NULL)
266 			{
267 				if(pLeftData->aDateTime < pRightData->aDateTime)
268 				{
269 					eCompare=COMPARE_LESS;
270 				}
271 				else if(pLeftData->aDateTime > pRightData->aDateTime)
272 				{
273 					eCompare=COMPARE_GREATER;
274 				}
275 			}
276 			else
277 				eCompare=SvxSimpleTable::ColCompare(pLeft,pRight);
278 		}
279 		else
280 		{
281 			eCompare=SvxSimpleTable::ColCompare(pLeft,pRight);
282 		}
283 
284 	}
285 
286 	return eCompare;
287 }
SetCalcView(sal_Bool bFlag)288 void SvxRedlinTable::SetCalcView(sal_Bool bFlag)
289 {
290 	bIsCalc=bFlag;
291 	if(bFlag)
292 	{
293 		nDatePos=CALC_DATE;
294 	}
295 	else
296 	{
297 		nDatePos=WRITER_DATE;
298 	}
299 }
300 
301 
UpdateFilterTest()302 void SvxRedlinTable::UpdateFilterTest()
303 {
304 	Date aDateMax;
305 	sal_uInt16 nYEAR=aDateMax.GetYear()+100;
306 	aDateMax.SetYear(nYEAR);
307 	Date aDateMin(1,1,1989);
308 	Time aTMin(0);
309 	Time aTMax(23,59,59);
310 
311 
312 	DateTime aDTMin(aDateMin);
313 	DateTime aDTMax(aDateMax);
314 
315 	switch(nDaTiMode)
316 	{
317 		case FLT_DATE_BEFORE:
318 								aDaTiFilterFirst=aDTMin;
319 								aDaTiFilterLast=aDaTiFirst;
320 								break;
321 		case FLT_DATE_SAVE:
322 		case FLT_DATE_SINCE:
323 								aDaTiFilterFirst=aDaTiFirst;
324 								aDaTiFilterLast=aDTMax;
325 								break;
326 		case FLT_DATE_EQUAL:
327 								aDaTiFilterFirst=aDaTiFirst;
328 								aDaTiFilterLast=aDaTiFirst;
329 								aDaTiFilterFirst.SetTime(aTMin.GetTime());
330 								aDaTiFilterLast.SetTime(aTMax.GetTime());
331 								break;
332 		case FLT_DATE_NOTEQUAL:
333 								aDaTiFilterFirst=aDaTiFirst;
334 								aDaTiFilterLast=aDaTiFirst;
335 								aDaTiFilterFirst.SetTime(aTMin.GetTime());
336 								aDaTiFilterLast.SetTime(aTMax.GetTime());
337 								break;
338 		case FLT_DATE_BETWEEN:
339 								aDaTiFilterFirst=aDaTiFirst;
340 								aDaTiFilterLast=aDaTiLast;
341 								break;
342 	}
343 }
344 
345 
SetFilterDate(sal_Bool bFlag)346 void SvxRedlinTable::SetFilterDate(sal_Bool bFlag)
347 {
348 	bDate=bFlag;
349 }
350 
SetDateTimeMode(sal_uInt16 nMode)351 void SvxRedlinTable::SetDateTimeMode(sal_uInt16 nMode)
352 {
353 	nDaTiMode=nMode;
354 }
355 
SetFirstDate(const Date & aDate)356 void SvxRedlinTable::SetFirstDate(const Date& aDate)
357 {
358 	aDaTiFirst.SetDate(aDate.GetDate());
359 }
360 
SetLastDate(const Date & aDate)361 void SvxRedlinTable::SetLastDate(const Date& aDate)
362 {
363 	aDaTiLast.SetDate(aDate.GetDate());
364 }
365 
SetFirstTime(const Time & aTime)366 void SvxRedlinTable::SetFirstTime(const Time& aTime)
367 {
368 	aDaTiFirst.SetTime(aTime.GetTime());
369 }
370 
SetLastTime(const Time & aTime)371 void SvxRedlinTable::SetLastTime(const Time& aTime)
372 {
373 	aDaTiLast.SetTime(aTime.GetTime());
374 }
375 
SetFilterAuthor(sal_Bool bFlag)376 void SvxRedlinTable::SetFilterAuthor(sal_Bool bFlag)
377 {
378 	bAuthor=bFlag;
379 }
380 
SetAuthor(const String & aString)381 void SvxRedlinTable::SetAuthor(const String &aString)
382 {
383 	aAuthor=aString;
384 }
385 
SetFilterComment(sal_Bool bFlag)386 void SvxRedlinTable::SetFilterComment(sal_Bool bFlag)
387 {
388 	bComment=bFlag;
389 }
390 
SetCommentParams(const utl::SearchParam * pSearchPara)391 void SvxRedlinTable::SetCommentParams( const utl::SearchParam* pSearchPara )
392 {
393 	if(pSearchPara!=NULL)
394 	{
395 		if(pCommentSearcher!=NULL) delete pCommentSearcher;
396 
397 		pCommentSearcher=new utl::TextSearch(*pSearchPara, LANGUAGE_SYSTEM );
398 	}
399 }
400 
IsValidWriterEntry(const String & rString,RedlinData * pUserData)401 sal_Bool SvxRedlinTable::IsValidWriterEntry(const String& rString,RedlinData *pUserData)
402 {
403 	sal_Bool nTheFlag=sal_True;
404 	String aString=rString.GetToken(WRITER_AUTHOR,'\t');
405 	if(pUserData==NULL)
406 	{
407 		if(bAuthor)
408 		{
409 			if(aAuthor.CompareTo(aString)==COMPARE_EQUAL)
410 				nTheFlag=sal_True;
411 			else
412 				nTheFlag=sal_False;
413 		}
414 	}
415 	else
416 	{
417 		DateTime aDateTime=pUserData->aDateTime;
418 		nTheFlag=IsValidEntry(&aString,&aDateTime);
419 	}
420 	return nTheFlag;
421 }
422 
IsValidCalcEntry(const String & rString,RedlinData * pUserData)423 sal_Bool SvxRedlinTable::IsValidCalcEntry(const String& rString,RedlinData *pUserData)
424 {
425 	sal_Bool nTheFlag=sal_True;
426 	String aString=rString.GetToken(CALC_AUTHOR,'\t');
427 	if(pUserData==NULL)
428 	{
429 		if(bAuthor)
430 		{
431 			if(aAuthor.CompareTo(aString)==COMPARE_EQUAL)
432 				nTheFlag=sal_True;
433 			else
434 				nTheFlag=sal_False;
435 		}
436 	}
437 	else
438 	{
439 		DateTime aDateTime=pUserData->aDateTime;
440 		nTheFlag=IsValidEntry(&aString,&aDateTime);
441 	}
442 	return nTheFlag;
443 }
444 
IsValidEntry(const String * pAuthorStr,const DateTime * pDateTime,const String * pCommentStr)445 sal_Bool SvxRedlinTable::IsValidEntry(const String* pAuthorStr,
446 								  const DateTime *pDateTime,const String* pCommentStr)
447 {
448 	bool nTheFlag=true;
449 	if(bAuthor)
450 	{
451 		nTheFlag = aAuthor.CompareTo(*pAuthorStr)==COMPARE_EQUAL;
452 	}
453 	if(bDate && nTheFlag)
454 	{
455 		if(nDaTiMode!=FLT_DATE_NOTEQUAL)
456 		{
457 			nTheFlag=pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast);
458 		}
459 		else
460 		{
461 			nTheFlag=!(pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast));
462 		}
463 	}
464 	if(bComment && nTheFlag)
465 	{
466 		xub_StrLen nStartPos = 0;
467 		xub_StrLen nEndPos = pCommentStr->Len();
468 
469 		nTheFlag=pCommentSearcher->SearchFrwrd( *pCommentStr, &nStartPos, &nEndPos);
470 	}
471 	return nTheFlag;
472 }
473 
IsValidEntry(const String * pAuthorStr,const DateTime * pDateTime)474 sal_Bool SvxRedlinTable::IsValidEntry(const String* pAuthorStr,const DateTime *pDateTime)
475 {
476 	sal_Bool nTheFlag=sal_True;
477 	if(bAuthor)
478 	{
479 		if(aAuthor.CompareTo(*pAuthorStr)==COMPARE_EQUAL)
480 			nTheFlag=sal_True;
481 		else
482 			nTheFlag=sal_False;
483 	}
484 	if(bDate && nTheFlag)
485 	{
486 		if(nDaTiMode!=FLT_DATE_NOTEQUAL)
487 		{
488 			nTheFlag=pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast);
489 		}
490 		else
491 		{
492 			nTheFlag=!(pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast));
493 		}
494 	}
495 	return nTheFlag;
496 }
497 
IsValidComment(const String * pCommentStr)498 sal_Bool SvxRedlinTable::IsValidComment(const String* pCommentStr)
499 {
500 	bool nTheFlag=true;
501 
502 	if(bComment)
503 	{
504 		xub_StrLen nStartPos = 0;
505 		xub_StrLen nEndPos = pCommentStr->Len();
506 
507 		nTheFlag=pCommentSearcher->SearchFrwrd( *pCommentStr, &nStartPos, &nEndPos);
508 	}
509 	return nTheFlag;
510 }
511 
InsertEntry(const String & rStr,RedlinData * pUserData,SvLBoxEntry * pParent,sal_uIntPtr nPos)512 SvLBoxEntry* SvxRedlinTable::InsertEntry(const String& rStr,RedlinData *pUserData,
513 								SvLBoxEntry* pParent,sal_uIntPtr nPos)
514 {
515 	aEntryColor=GetTextColor();
516 	if(pUserData!=NULL)
517 	{
518 		if(pUserData->bDisabled)
519 			aEntryColor=Color(COL_GRAY);
520 	}
521 
522 	XubString aStr= rStr;
523 
524 	XubString aFirstStr( aStr );
525 	xub_StrLen nEnd = aFirstStr.Search( sal_Unicode( '\t' ) );
526 	if( nEnd != STRING_NOTFOUND )
527 	{
528 		aFirstStr.Erase( nEnd );
529 		aCurEntry = aStr;
530 		aCurEntry.Erase( 0, ++nEnd );
531 	}
532 	else
533 		aCurEntry.Erase();
534 
535 	return SvTreeListBox::InsertEntry( aFirstStr, pParent, sal_False, nPos, pUserData );
536 
537 }
538 
InsertEntry(const String & rStr,RedlinData * pUserData,const Color & aColor,SvLBoxEntry * pParent,sal_uIntPtr nPos)539 SvLBoxEntry* SvxRedlinTable::InsertEntry(const String& rStr,RedlinData *pUserData,const Color& aColor,
540 								SvLBoxEntry* pParent,sal_uIntPtr nPos)
541 {
542 	aEntryColor=aColor;
543 
544 	XubString aStr= rStr;
545 
546 	XubString aFirstStr( aStr );
547 	xub_StrLen nEnd = aFirstStr.Search( sal_Unicode ( '\t' ) );
548 	if( nEnd != STRING_NOTFOUND )
549 	{
550 		aFirstStr.Erase( nEnd );
551 		aCurEntry = aStr;
552 		aCurEntry.Erase( 0, ++nEnd );
553 	}
554 	else
555 		aCurEntry.Erase();
556 
557 	return SvTreeListBox::InsertEntry( aFirstStr, pParent, sal_False, nPos, pUserData );
558 }
559 
CreateEntry() const560 SvLBoxEntry* SvxRedlinTable::CreateEntry() const
561 {
562 	return new SvxRedlinEntry;
563 }
564 
InitEntry(SvLBoxEntry * pEntry,const XubString & rStr,const Image & rColl,const Image & rExp,SvLBoxButtonKind eButtonKind)565 void SvxRedlinTable::InitEntry( SvLBoxEntry* pEntry, const XubString& rStr,
566 	const Image& rColl, const Image& rExp, SvLBoxButtonKind eButtonKind )
567 {
568 	SvLBoxButton* pButton;
569 	SvLBoxString* pString;
570 	SvLBoxContextBmp* pContextBmp;
571 
572 	if( nTreeFlags & TREEFLAG_CHKBTN )
573 	{
574 		pButton= new SvLBoxButton( pEntry,eButtonKind,0,pCheckButtonData );
575 		pEntry->AddItem( pButton );
576 	}
577 
578 	pContextBmp= new SvLBoxContextBmp( pEntry,0, rColl,rExp,
579 									 SVLISTENTRYFLAG_EXPANDED);
580 	pEntry->AddItem( pContextBmp );
581 
582 	pString = new SvLBoxColorString( pEntry, 0, rStr ,aEntryColor);
583 	pEntry->AddItem( pString );
584 
585 	XubString aToken;
586 
587 	xub_Unicode* pCurToken = (xub_Unicode*)aCurEntry.GetBuffer();
588 	sal_uInt16 nCurTokenLen;
589 	xub_Unicode* pNextToken = (xub_Unicode*)GetToken( pCurToken, nCurTokenLen );
590 	sal_uInt16 nCount = TabCount(); nCount--;
591 
592 	for( sal_uInt16 nToken = 0; nToken < nCount; nToken++ )
593 	{
594 		if( pCurToken && nCurTokenLen )
595 			// aToken.Assign( pCurToken, nCurTokenLen );
596 			aToken = XubString( pCurToken, nCurTokenLen );
597 		else
598 			aToken.Erase();
599 
600 		SvLBoxColorString* pStr = new SvLBoxColorString( pEntry, 0, aToken ,aEntryColor);
601 		pEntry->AddItem( pStr );
602 
603 		pCurToken = pNextToken;
604 		if( pCurToken )
605 			pNextToken = (xub_Unicode*)GetToken( pCurToken, nCurTokenLen );
606 		else
607 			nCurTokenLen = 0;
608 	}
609 }
610 
611 
612 
613 
614 //============================================================================
615 //	class SvxTPView
616 //----------------------------------------------------------------------------
617 
SvxTPView(Window * pParent)618 SvxTPView::SvxTPView( Window * pParent)
619 	: TabPage( pParent, SVX_RES(SID_REDLIN_VIEW_PAGE)),
620 	aViewData	( this, SVX_RES( DG_VIEW) ),
621 	PbAccept	( this, SVX_RES(PB_ACCEPT	 ) ),
622     PbReject    ( this, SVX_RES(PB_REJECT  ) ),
623     PbAcceptAll ( this, SVX_RES(PB_ACCEPTALL  ) ),
624     PbRejectAll ( this, SVX_RES(PB_REJECTALL  ) ),
625 	PbUndo		( this, SVX_RES(PB_UNDO  ) ),
626 	aTitle1		( SVX_RES( STR_TITLE1 ) ),		// lokale Resource
627 	aTitle2		( SVX_RES( STR_TITLE2 ) ),
628 	aTitle3		( SVX_RES( STR_TITLE3 ) ),
629 	aTitle4		( SVX_RES( STR_TITLE4 ) ),
630 	aTitle5		( SVX_RES( STR_TITLE5 ) ),
631 	aStrMyName	( SVX_RES( STR_VIEW) )
632 {
633 	aViewData.SetAccessibleName(String(SVX_RES(STR_TREE)));
634 	FreeResource();
635 
636     aViewData.SetHelpId(HID_REDLINING_VIEW_DG_VIEW_TABLE);
637     aViewData.SetHeaderBarHelpId(HID_REDLINING_VIEW_DG_VIEW_HEADER);
638 
639 	aMinSize=GetSizePixel();
640 
641 	Link aLink=LINK( this, SvxTPView, PbClickHdl);
642 
643 	PbAccept.SetClickHdl(aLink);
644 	PbAcceptAll.SetClickHdl(aLink);
645 	PbReject.SetClickHdl(aLink);
646 	PbRejectAll.SetClickHdl(aLink);
647 	PbUndo.SetClickHdl(aLink);
648 
649 	nDistance=PbAccept.GetSizePixel().Height()+2*MIN_DISTANCE;
650 	aViewData.SetTabs(nStaticTabs);
651 }
652 
GetMyName() const653 String SvxTPView::GetMyName() const
654 {
655 	return aStrMyName;
656 }
657 
Resize()658 void SvxTPView::Resize()
659 {
660 	Size aSize=GetOutputSizePixel();
661 	Point aPos=aViewData.GetPosPixel();
662 	aSize.Height()-=aPos.Y()+nDistance;
663 	aSize.Width()-=2*aPos.X();
664 
665 	long newY=aPos.Y()+aSize.Height()+MIN_DISTANCE;
666 	aPos=PbAccept.GetPosPixel();
667 	aPos.Y()=newY;
668 	PbAccept.SetPosPixel(aPos);
669 	aPos=PbAcceptAll.GetPosPixel();
670 	aPos.Y()=newY;
671 	PbAcceptAll.SetPosPixel(aPos);
672 	aPos=PbReject.GetPosPixel();
673 	aPos.Y()=newY;
674 	PbReject.SetPosPixel(aPos);
675 	aPos=PbRejectAll.GetPosPixel();
676 	aPos.Y()=newY;
677 	PbRejectAll.SetPosPixel(aPos);
678 
679 	if(PbUndo.IsVisible())
680 	{
681 		aPos=PbUndo.GetPosPixel();
682 		aPos.Y()=newY;
683 		PbUndo.SetPosPixel(aPos);
684 	}
685 	aViewData.SetSizePixel(aSize);
686 }
687 
InsertWriterHeader()688 void SvxTPView::InsertWriterHeader()
689 {
690 	String aStrTab(sal_Unicode('\t'));
691 	String aString(aTitle1);
692 	aString+=aStrTab;
693 	aString+=aTitle3;
694 	aString+=aStrTab;
695 	aString+=aTitle4;
696 	aString+=aStrTab;
697 	aString+=aTitle5;
698 	aViewData.ClearHeader();
699 	aViewData.InsertHeaderEntry(aString);
700 }
701 
InsertCalcHeader()702 void SvxTPView::InsertCalcHeader()
703 {
704 	String aStrTab(sal_Unicode('\t'));
705 	String aString(aTitle1);
706 	aString+=aStrTab;
707 	aString+=aTitle2;
708 	aString+=aStrTab;
709 	aString+=aTitle3;
710 	aString+=aStrTab;
711 	aString+=aTitle4;
712 	aString+=aStrTab;
713 	aString+=aTitle5;
714 	aViewData.ClearHeader();
715 	aViewData.InsertHeaderEntry(aString);
716 }
717 
EnableAccept(sal_Bool nFlag)718 void SvxTPView::EnableAccept(sal_Bool nFlag)
719 {
720 	PbAccept.Enable(nFlag);
721 }
722 
EnableAcceptAll(sal_Bool nFlag)723 void SvxTPView::EnableAcceptAll(sal_Bool nFlag)
724 {
725 	PbAcceptAll.Enable(nFlag);
726 }
727 
EnableReject(sal_Bool nFlag)728 void SvxTPView::EnableReject(sal_Bool nFlag)
729 {
730 	PbReject.Enable(nFlag);
731 }
732 
EnableRejectAll(sal_Bool nFlag)733 void SvxTPView::EnableRejectAll(sal_Bool nFlag)
734 {
735 	PbRejectAll.Enable(nFlag);
736 }
737 
ShowUndo(sal_Bool nFlag)738 void SvxTPView::ShowUndo(sal_Bool nFlag)
739 {
740 	PbUndo.Show(nFlag);
741 }
742 
EnableUndo(sal_Bool nFlag)743 void SvxTPView::EnableUndo(sal_Bool nFlag)
744 {
745 	PbUndo.Enable(nFlag);
746 }
747 
GetMinSizePixel()748 Size SvxTPView::GetMinSizePixel()
749 {
750 	Size aSize=aMinSize;
751 	if(PbUndo.IsVisible())
752 	{
753 		sal_uIntPtr nSize=PbUndo.GetSizePixel().Width()
754 					+PbUndo.GetPosPixel().X()
755 					+PbAccept.GetPosPixel().X();
756 
757 		aSize.Width()=nSize;
758 	}
759 
760 	return aSize;
761 }
762 
763 
GetTableControl()764 SvxRedlinTable* SvxTPView::GetTableControl()
765 {
766 	return &aViewData;
767 }
768 
IMPL_LINK(SvxTPView,PbClickHdl,PushButton *,pPushB)769 IMPL_LINK( SvxTPView, PbClickHdl, PushButton*, pPushB )
770 {
771 	if(pPushB==&PbAccept)
772 	{
773 		AcceptClickLk.Call(this);
774 	}
775 	else if(pPushB==&PbAcceptAll)
776 	{
777 		AcceptAllClickLk.Call(this);
778 	}
779 	else if(pPushB==&PbReject)
780 	{
781 		RejectClickLk.Call(this);
782 	}
783 	else if(pPushB==&PbRejectAll)
784 	{
785 		RejectAllClickLk.Call(this);
786 	}
787 	else if(pPushB==&PbUndo)
788 	{
789 		UndoClickLk.Call(this);
790 	}
791 
792 	return 0;
793 }
794 
795 
796 
797 
798 //============================================================================
799 //	class SvxTPFilter
800 //----------------------------------------------------------------------------
801 
SvxTPFilter(Window * pParent)802 SvxTPFilter::SvxTPFilter( Window * pParent)
803 	: TabPage( pParent, SVX_RES(SID_REDLIN_FILTER_PAGE)),
804     pRedlinTable(NULL),
805     aCbDate     ( this, SVX_RES( CB_DATE ) ),
806 	aLbDate		( this, SVX_RES( LB_DATE ) ),
807 	aDfDate		( this, SVX_RES( DF_DATE ) ),
808 	aTfDate		( this, SVX_RES( TF_DATE ) ),
809 	aIbClock 	( this, SVX_RES( IB_CLOCK ) ),
810 	aFtDate2	( this, SVX_RES( FT_DATE2 ) ),
811 	aDfDate2	( this, SVX_RES( DF_DATE2 ) ),
812 	aTfDate2	( this, SVX_RES( TF_DATE2 ) ),
813 	aIbClock2 	( this, SVX_RES( IB_CLOCK2) ),
814 	aCbAuthor	( this, SVX_RES( CB_AUTOR ) ),
815 	aLbAuthor	( this, SVX_RES( LB_AUTOR ) ),
816 	aCbRange 	( this, SVX_RES( CB_RANGE ) ),
817 	aEdRange 	( this, SVX_RES( ED_RANGE ) ),
818 	aBtnRange 	( this, SVX_RES( BTN_REF ) ),
819 	aLbAction	( this, SVX_RES( LB_ACTION ) ),
820 	aCbComment	( this, SVX_RES( CB_COMMENT) ),
821 	aEdComment	( this, SVX_RES( ED_COMMENT) ),
822     aActionStr  (       SVX_RES( STR_ACTION) ),
823     aStrMyName  (       SVX_RES( STR_FILTER) ),
824     bModified   (sal_False)
825 {
826     aLbDate.SetAccessibleName( String( SVX_RES( STR_DATE_COMBOX) ) );
827     aDfDate.SetAccessibleName( String( SVX_RES( STR_DATE_SPIN) ) );
828     aTfDate.SetAccessibleName( String( SVX_RES( STR_DATE_TIME_SPIN) ) );
829     aDfDate2.SetAccessibleName( String( SVX_RES( STR_DATE_SPIN1) ) );
830     aTfDate2.SetAccessibleName( String( SVX_RES( STR_DATE_TIME_SPIN1) ) );
831 	aLbAuthor.SetAccessibleName(aCbAuthor.GetText());
832 	aLbAction.SetAccessibleName( String( SVX_RES( STR_ACTION) ) );
833 	aEdComment.SetAccessibleName(aCbComment.GetText());
834     Image aImgTimeHC( SVX_RES( IMG_TIME_H ) );
835 	FreeResource();
836 
837     aIbClock.SetModeImage( aImgTimeHC, BMP_COLOR_HIGHCONTRAST );
838     aIbClock2.SetModeImage( aImgTimeHC, BMP_COLOR_HIGHCONTRAST );
839 
840 	aDfDate.SetShowDateCentury( sal_True );
841 	aDfDate2.SetShowDateCentury( sal_True );
842 
843 	aRangeStr=aCbRange.GetText();
844 	aLbDate.SelectEntryPos(0);
845 	aLbDate.SetSelectHdl( LINK( this, SvxTPFilter, SelDateHdl ) );
846 	aIbClock.SetClickHdl( LINK( this, SvxTPFilter, TimeHdl) );
847 	aIbClock2.SetClickHdl( LINK( this, SvxTPFilter,TimeHdl) );
848 	aBtnRange.SetClickHdl( LINK( this, SvxTPFilter, RefHandle));
849 
850 	Link aLink=LINK( this, SvxTPFilter, RowEnableHdl) ;
851 	aCbDate.SetClickHdl(aLink);
852 	aCbAuthor.SetClickHdl(aLink);
853 	aCbRange.SetClickHdl(aLink);
854 	aCbComment.SetClickHdl(aLink);
855 
856 	Link a2Link=LINK( this, SvxTPFilter, ModifyDate);
857 	aDfDate.SetModifyHdl(a2Link);
858 	aTfDate.SetModifyHdl(a2Link);
859 	aDfDate2.SetModifyHdl(a2Link);
860 	aTfDate2.SetModifyHdl(a2Link);
861 
862 	Link a3Link=LINK( this, SvxTPFilter, ModifyHdl);
863 	aEdRange.SetModifyHdl(a3Link);
864 	aEdComment.SetModifyHdl(a3Link);
865 	aLbAction.SetSelectHdl(a3Link);
866 	aLbAuthor.SetSelectHdl(a3Link);
867 
868 	RowEnableHdl(&aCbDate);
869 	RowEnableHdl(&aCbAuthor);
870 	RowEnableHdl(&aCbRange);
871 	RowEnableHdl(&aCbComment);
872 
873 	Date aDate;
874 	Time aTime;
875 	aDfDate.SetDate(aDate);
876 	aTfDate.SetTime(aTime);
877 	aDfDate2.SetDate(aDate);
878 	aTfDate2.SetTime(aTime);
879 	HideRange();
880 	ShowAction();
881 	bModified=sal_False;
882 
883 	aLbDate.SetAccessibleRelationLabeledBy(&aCbDate);
884 	aLbAuthor.SetAccessibleRelationLabeledBy(&aCbAuthor);
885 	aLbAction.SetAccessibleRelationLabeledBy(&aCbRange);
886 	aEdRange.SetAccessibleRelationLabeledBy(&aCbRange);
887 	aBtnRange.SetAccessibleRelationLabeledBy(&aCbRange);
888 	aEdComment.SetAccessibleRelationLabeledBy(&aCbComment);
889 	aDfDate2.SetAccessibleRelationLabeledBy(&aDfDate2);
890 	aTfDate2.SetAccessibleRelationLabeledBy(&aTfDate2);
891 }
892 
SetRedlinTable(SvxRedlinTable * pTable)893 void SvxTPFilter::SetRedlinTable(SvxRedlinTable* pTable)
894 {
895 	pRedlinTable=pTable;
896 }
897 
GetMyName() const898 String SvxTPFilter::GetMyName() const
899 {
900 	return aStrMyName;
901 }
902 
DisableRange(sal_Bool bFlag)903 void SvxTPFilter::DisableRange(sal_Bool bFlag)
904 {
905 	if(bFlag)
906 	{
907 		aCbRange.Disable();
908 		aEdRange.Disable();
909 		aBtnRange.Disable();
910 	}
911 	else
912 	{
913 		aCbRange.Enable();
914 		aEdRange.Enable();
915 		aBtnRange.Enable();
916 	}
917 }
918 
ShowDateFields(sal_uInt16 nKind)919 void SvxTPFilter::ShowDateFields(sal_uInt16 nKind)
920 {
921 	String aEmpty;
922 	switch(nKind)
923 	{
924 		case FLT_DATE_BEFORE:
925 				EnableDateLine1(sal_True);
926 				EnableDateLine2(sal_False);
927 				break;
928 		case FLT_DATE_SINCE:
929 				EnableDateLine1(sal_True);
930 				EnableDateLine2(sal_False);
931 				break;
932 		case FLT_DATE_EQUAL:
933 				EnableDateLine1(sal_True);
934 				aTfDate.Disable();
935 				aTfDate.SetText(aEmpty);
936 				EnableDateLine2(sal_False);
937 				break;
938 		case FLT_DATE_NOTEQUAL:
939 				EnableDateLine1(sal_True);
940 				aTfDate.Disable();
941 				aTfDate.SetText(aEmpty);
942 				EnableDateLine2(sal_False);
943 				break;
944 		case FLT_DATE_BETWEEN:
945 				EnableDateLine1(sal_True);
946 				EnableDateLine2(sal_True);
947 				break;
948 		case FLT_DATE_SAVE:
949 				EnableDateLine1(sal_False);
950 				EnableDateLine2(sal_False);
951 				break;
952 	}
953 }
954 
EnableDateLine1(sal_Bool bFlag)955 void SvxTPFilter::EnableDateLine1(sal_Bool bFlag)
956 {
957 	if(bFlag && aCbDate.IsChecked())
958 	{
959 		aDfDate.Enable();
960 		aTfDate.Enable();
961 		aIbClock.Enable();
962 	}
963 	else
964 	{
965 		aDfDate.Disable();
966 		aTfDate.Disable();
967 		aIbClock.Disable();
968 	}
969 }
EnableDateLine2(sal_Bool bFlag)970 void SvxTPFilter::EnableDateLine2(sal_Bool bFlag)
971 {
972 	String aEmpty;
973 	if(bFlag && aCbDate.IsChecked())
974 	{
975 		aFtDate2.Enable();
976 		aDfDate2.Enable();
977 		aTfDate2.Enable();
978 		aIbClock2.Enable();
979 	}
980 	else
981 	{
982 		aFtDate2.Disable();
983 		aDfDate2.Disable();
984 		aDfDate2.SetText(aEmpty);
985 		aTfDate2.Disable();
986 		aTfDate2.SetText(aEmpty);
987 		aIbClock2.Disable();
988 	}
989 }
990 
GetFirstDate() const991 Date SvxTPFilter::GetFirstDate() const
992 {
993 	return aDfDate.GetDate();
994 }
995 
SetFirstDate(const Date & aDate)996 void SvxTPFilter::SetFirstDate(const Date &aDate)
997 {
998 	aDfDate.SetDate(aDate);
999 }
1000 
GetFirstTime() const1001 Time SvxTPFilter::GetFirstTime() const
1002 {
1003 	return aTfDate.GetTime();
1004 }
1005 
SetFirstTime(const Time & aTime)1006 void SvxTPFilter::SetFirstTime(const Time &aTime)
1007 {
1008 	aTfDate.SetTime(aTime);
1009 }
1010 
1011 
GetLastDate() const1012 Date SvxTPFilter::GetLastDate() const
1013 {
1014 	return aDfDate2.GetDate();
1015 }
1016 
SetLastDate(const Date & aDate)1017 void SvxTPFilter::SetLastDate(const Date &aDate)
1018 {
1019 	aDfDate2.SetDate(aDate);
1020 }
1021 
GetLastTime() const1022 Time SvxTPFilter::GetLastTime() const
1023 {
1024 	return aTfDate2.GetTime();
1025 }
1026 
SetLastTime(const Time & aTime)1027 void SvxTPFilter::SetLastTime(const Time &aTime)
1028 {
1029 	aTfDate2.SetTime(aTime);
1030 }
1031 
SetDateMode(sal_uInt16 nMode)1032 void SvxTPFilter::SetDateMode(sal_uInt16 nMode)
1033 {
1034 	aLbDate.SelectEntryPos(nMode);
1035 	SelDateHdl(&aLbDate);
1036 }
1037 
GetDateMode()1038 sal_uInt16 SvxTPFilter::GetDateMode()
1039 {
1040 	return (sal_uInt16) aLbDate.GetSelectEntryPos();
1041 }
ClearAuthors()1042 void SvxTPFilter::ClearAuthors()
1043 {
1044 	aLbAuthor.Clear();
1045 }
1046 
InsertAuthor(const String & rString,sal_uInt16 nPos)1047 void SvxTPFilter::InsertAuthor( const String& rString, sal_uInt16 nPos)
1048 {
1049 	aLbAuthor.InsertEntry(rString,nPos);
1050 }
1051 
GetSelectedAuthor() const1052 String SvxTPFilter::GetSelectedAuthor()	const
1053 {
1054 	return aLbAuthor.GetSelectEntry();
1055 }
1056 
GetSelectedAuthorPos()1057 sal_uInt16	SvxTPFilter::GetSelectedAuthorPos()
1058 {
1059 	return (sal_uInt16) aLbAuthor.GetSelectEntryPos();
1060 }
1061 
SelectedAuthorPos(sal_uInt16 nPos)1062 void SvxTPFilter::SelectedAuthorPos(sal_uInt16 nPos)
1063 {
1064 	aLbAuthor.SelectEntryPos(nPos);
1065 }
1066 
SelectAuthor(const String & aString)1067 sal_uInt16 SvxTPFilter::SelectAuthor(const String& aString)
1068 {
1069 	aLbAuthor.SelectEntry(aString);
1070 	return aLbAuthor.GetSelectEntryPos();
1071 }
1072 
SetRange(const String & rString)1073 void SvxTPFilter::SetRange(const String& rString)
1074 {
1075 	aEdRange.SetText(rString);
1076 }
1077 
GetRange() const1078 String SvxTPFilter::GetRange() const
1079 {
1080 	return aEdRange.GetText();
1081 }
1082 
SetFocusToRange()1083 void SvxTPFilter::SetFocusToRange()
1084 {
1085 	aEdRange.GrabFocus();
1086 }
1087 
HideRange(sal_Bool bHide)1088 void SvxTPFilter::HideRange(sal_Bool bHide)
1089 {
1090 	if(bHide)
1091 	{
1092 		aCbRange.Hide();
1093 		aEdRange.Hide();
1094 		aBtnRange.Hide();
1095 	}
1096 	else
1097 	{
1098 		ShowAction(sal_False);
1099 		aCbRange.SetText(aRangeStr);
1100 		aCbRange.Show();
1101 		aEdRange.Show();
1102 		aBtnRange.Show();
1103 	}
1104 }
1105 
HideClocks(sal_Bool bHide)1106 void SvxTPFilter::HideClocks(sal_Bool bHide)
1107 {
1108 	if(bHide)
1109 	{
1110 		aIbClock. Hide();
1111 		aIbClock2.Hide();
1112 	}
1113 	else
1114 	{
1115 		aIbClock. Show();
1116 		aIbClock2.Show();
1117 	}
1118 }
1119 
SetComment(const String & rComment)1120 void SvxTPFilter::SetComment(const String &rComment)
1121 {
1122 	aEdComment.SetText(rComment);
1123 }
GetComment() const1124 String SvxTPFilter::GetComment()const
1125 {
1126 	return aEdComment.GetText();
1127 }
1128 
IsDate()1129 sal_Bool SvxTPFilter::IsDate()
1130 {
1131 	return aCbDate.IsChecked();
1132 }
1133 
IsAuthor()1134 sal_Bool SvxTPFilter::IsAuthor()
1135 {
1136 	return aCbAuthor.IsChecked();
1137 }
1138 
IsRange()1139 sal_Bool SvxTPFilter::IsRange()
1140 {
1141 	return aCbRange.IsChecked();
1142 }
IsAction()1143 sal_Bool SvxTPFilter::IsAction()
1144 {
1145 	return aCbRange.IsChecked();
1146 }
1147 
IsComment()1148 sal_Bool SvxTPFilter::IsComment()
1149 {
1150 	return aCbComment.IsChecked();
1151 }
1152 
CheckDate(sal_Bool bFlag)1153 void SvxTPFilter::CheckDate(sal_Bool bFlag)
1154 {
1155 	aCbDate.Check(bFlag);
1156 	RowEnableHdl(&aCbDate);
1157 	bModified=sal_False;
1158 }
1159 
CheckAuthor(sal_Bool bFlag)1160 void SvxTPFilter::CheckAuthor(sal_Bool bFlag)
1161 {
1162 	aCbAuthor.Check(bFlag);
1163 	RowEnableHdl(&aCbAuthor);
1164 	bModified=sal_False;
1165 }
1166 
CheckRange(sal_Bool bFlag)1167 void SvxTPFilter::CheckRange(sal_Bool bFlag)
1168 {
1169 	aCbRange.Check(bFlag);
1170 	RowEnableHdl(&aCbRange);
1171 	bModified=sal_False;
1172 }
1173 
CheckAction(sal_Bool bFlag)1174 void SvxTPFilter::CheckAction(sal_Bool bFlag)
1175 {
1176 	aCbRange.Check(bFlag);
1177 	RowEnableHdl(&aCbRange);
1178 	bModified=sal_False;
1179 }
1180 
CheckComment(sal_Bool bFlag)1181 void SvxTPFilter::CheckComment(sal_Bool bFlag)
1182 {
1183 	aCbComment.Check(bFlag);
1184 	RowEnableHdl(&aCbComment);
1185 	bModified=sal_False;
1186 }
1187 
ShowAction(sal_Bool bShow)1188 void SvxTPFilter::ShowAction(sal_Bool bShow)
1189 {
1190 	if(!bShow)
1191 	{
1192 		aCbRange.Hide();
1193 		aLbAction.Hide();
1194 		aCbRange.SetHelpId(HID_REDLINING_FILTER_CB_RANGE);
1195 	}
1196 	else
1197 	{
1198 		HideRange();
1199 		aCbRange.SetText(aActionStr);
1200 		aCbRange.SetHelpId(HID_REDLINING_FILTER_CB_ACTION);
1201 		aCbRange.Show();
1202 		aLbAction.Show();
1203 
1204 	}
1205 }
1206 
GetLbAction()1207 ListBox* SvxTPFilter::GetLbAction()
1208 {
1209 	return &aLbAction;
1210 }
1211 
IMPL_LINK(SvxTPFilter,SelDateHdl,ListBox *,pLb)1212 IMPL_LINK( SvxTPFilter, SelDateHdl, ListBox*, pLb )
1213 {
1214 	ShowDateFields((sal_uInt16)aLbDate.GetSelectEntryPos());
1215 	ModifyHdl(pLb);
1216 	return 0;
1217 }
1218 
IMPL_LINK(SvxTPFilter,RowEnableHdl,CheckBox *,pCB)1219 IMPL_LINK( SvxTPFilter, RowEnableHdl, CheckBox*, pCB )
1220 {
1221 	if(pCB==&aCbDate)
1222 	{
1223 		aLbDate.Enable(aCbDate.IsChecked());
1224 		aLbDate.Invalidate();
1225 		EnableDateLine1(sal_False);
1226 		EnableDateLine2(sal_False);
1227 		if(aCbDate.IsChecked()) SelDateHdl(&aLbDate);
1228 	}
1229 	else if(pCB==&aCbAuthor)
1230 	{
1231 		aLbAuthor.Enable(aCbAuthor.IsChecked());
1232 		aLbAuthor.Invalidate();
1233 	}
1234 	else if(pCB==&aCbRange)
1235 	{
1236 		aLbAction.Enable(aCbRange.IsChecked());
1237 		aLbAction.Invalidate();
1238 		aEdRange.Enable(aCbRange.IsChecked());
1239 		aBtnRange.Enable(aCbRange.IsChecked());
1240 	}
1241 	else if(pCB==&aCbComment)
1242 	{
1243 		aEdComment.Enable(aCbComment.IsChecked());
1244 		aEdComment.Invalidate();
1245 	}
1246 
1247 	ModifyHdl(pCB);
1248 	return 0;
1249 }
1250 
IMPL_LINK(SvxTPFilter,TimeHdl,ImageButton *,pIB)1251 IMPL_LINK( SvxTPFilter, TimeHdl, ImageButton*,pIB )
1252 {
1253 	Date aDate;
1254 	Time aTime;
1255 	if(pIB==&aIbClock)
1256 	{
1257 		aDfDate.SetDate(aDate);
1258 		aTfDate.SetTime(aTime);
1259 	}
1260 	else if(pIB==&aIbClock2)
1261 	{
1262 		aDfDate2.SetDate(aDate);
1263 		aTfDate2.SetTime(aTime);
1264 	}
1265 	ModifyHdl(&aDfDate);
1266 	return 0;
1267 }
1268 
IMPL_LINK(SvxTPFilter,ModifyHdl,void *,pCtr)1269 IMPL_LINK( SvxTPFilter, ModifyHdl, void*, pCtr)
1270 {
1271 	if(pCtr!=NULL)
1272 	{
1273 		if(pCtr==&aCbDate  || pCtr==&aLbDate ||
1274 		   pCtr==&aDfDate  || pCtr==&aTfDate ||
1275 		   pCtr==&aIbClock || pCtr==&aFtDate2||
1276 		   pCtr==&aDfDate2 || pCtr==&aTfDate2||
1277 		   pCtr==&aIbClock2)
1278 		{
1279 			aModifyDateLink.Call(this);
1280 		}
1281 		else if(pCtr==&aCbAuthor || pCtr==&aLbAuthor)
1282 		{
1283 			aModifyAuthorLink.Call(this);
1284 		}
1285 		else if(pCtr==&aCbRange  || pCtr==&aEdRange ||
1286 				pCtr==&aBtnRange )
1287 		{
1288 			aModifyRefLink.Call(this);
1289 		}
1290 		else if(pCtr==&aCbComment || pCtr==&aEdComment)
1291 		{
1292 			aModifyComLink.Call(this);
1293 		}
1294 
1295 		bModified=sal_True;
1296 		aModifyLink.Call(this);
1297 	}
1298 	return 0;
1299 }
1300 
DeactivatePage()1301 void SvxTPFilter::DeactivatePage()
1302 {
1303 	if(bModified)
1304 	{
1305 		if(pRedlinTable!=NULL)
1306 		{
1307 			pRedlinTable->SetFilterDate(IsDate());
1308 			pRedlinTable->SetDateTimeMode(GetDateMode());
1309 			pRedlinTable->SetFirstDate(aDfDate.GetDate());
1310 			pRedlinTable->SetLastDate(aDfDate2.GetDate());
1311 			pRedlinTable->SetFirstTime(aTfDate.GetTime());
1312 			pRedlinTable->SetLastTime(aTfDate2.GetTime());
1313 			pRedlinTable->SetFilterAuthor(IsAuthor());
1314 			pRedlinTable->SetAuthor(GetSelectedAuthor());
1315 
1316 			pRedlinTable->SetFilterComment(IsComment());
1317 
1318 			utl::SearchParam aSearchParam( aEdComment.GetText(),
1319 					utl::SearchParam::SRCH_REGEXP,sal_False,sal_False,sal_False );
1320 
1321 			pRedlinTable->SetCommentParams(&aSearchParam);
1322 
1323 			pRedlinTable->UpdateFilterTest();
1324 		}
1325 
1326 		aReadyLink.Call(this);
1327 	}
1328 	bModified=sal_False;
1329 	TabPage::DeactivatePage();
1330 }
1331 
Enable(bool bEnable,bool bChild)1332 void SvxTPFilter::Enable( bool bEnable, bool bChild)
1333 {
1334 	TabPage::Enable(bEnable,bChild);
1335 	if(aCbDate.IsEnabled())
1336 	{
1337 		RowEnableHdl(&aCbDate);
1338 		RowEnableHdl(&aCbAuthor);
1339 		RowEnableHdl(&aCbRange);
1340 		RowEnableHdl(&aCbComment);
1341 	}
1342 }
Disable(bool bChild)1343 void SvxTPFilter::Disable( bool bChild)
1344 {
1345 	Enable( false, bChild );
1346 }
1347 
SetAccessibleRelationMemberOf(Window * pWin)1348 void SvxTPFilter::SetAccessibleRelationMemberOf( Window* pWin )
1349 {
1350 	aCbDate.SetAccessibleRelationMemberOf(pWin);
1351 	aLbDate.SetAccessibleRelationMemberOf(pWin);
1352 	aDfDate.SetAccessibleRelationMemberOf(pWin);
1353 	aTfDate.SetAccessibleRelationMemberOf(pWin);
1354 	aIbClock.SetAccessibleRelationMemberOf(pWin);
1355 	aFtDate2.SetAccessibleRelationMemberOf(pWin);
1356 	aDfDate2.SetAccessibleRelationMemberOf(pWin);
1357 	aTfDate2.SetAccessibleRelationMemberOf(pWin);
1358 	aIbClock2.SetAccessibleRelationMemberOf(pWin);
1359 	aCbAuthor.SetAccessibleRelationMemberOf(pWin);
1360 	aLbAuthor.SetAccessibleRelationMemberOf(pWin);
1361 	aCbRange.SetAccessibleRelationMemberOf(pWin);
1362 	aEdRange.SetAccessibleRelationMemberOf(pWin);
1363 	aBtnRange.SetAccessibleRelationMemberOf(pWin);
1364 	aLbAction.SetAccessibleRelationMemberOf(pWin);
1365 	aCbComment.SetAccessibleRelationMemberOf(pWin);
1366 	aEdComment.SetAccessibleRelationMemberOf(pWin);
1367 }
1368 
IMPL_LINK(SvxTPFilter,ModifyDate,void *,pTF)1369 IMPL_LINK( SvxTPFilter, ModifyDate, void*,pTF)
1370 {
1371 
1372 	Date aDate;
1373 	Time aTime(0);
1374 	if(&aDfDate==pTF)
1375 	{
1376 		if(aDfDate.GetText().Len()==0)
1377 		   aDfDate.SetDate(aDate);
1378 
1379 		if(pRedlinTable!=NULL)
1380 			pRedlinTable->SetFirstDate(aDfDate.GetDate());
1381 	}
1382 	else if(&aDfDate2==pTF)
1383 	{
1384 		if(aDfDate2.GetText().Len()==0)
1385 		   aDfDate2.SetDate(aDate);
1386 
1387 		if(pRedlinTable!=NULL)
1388 			pRedlinTable->SetLastDate(aDfDate2.GetDate());
1389 	}
1390 	else if(&aTfDate==pTF)
1391 	{
1392 		if(aTfDate.GetText().Len()==0)
1393 		   aTfDate.SetTime(aTime);
1394 
1395 		if(pRedlinTable!=NULL)
1396 			pRedlinTable->SetFirstTime(aTfDate.GetTime());
1397 	}
1398 	else if(&aTfDate2==pTF)
1399 	{
1400 		if(aTfDate2.GetText().Len()==0)
1401 		   aTfDate2.SetTime(aTime);
1402 
1403 		if(pRedlinTable!=NULL)
1404 			pRedlinTable->SetLastTime(aTfDate2.GetTime());
1405 
1406 	}
1407 	ModifyHdl(&aDfDate);
1408 	return 0;
1409 }
1410 
IMPL_LINK(SvxTPFilter,RefHandle,PushButton *,pRef)1411 IMPL_LINK( SvxTPFilter, RefHandle, PushButton*, pRef )
1412 {
1413 	if(pRef!=NULL)
1414 	{
1415 		aRefLink.Call(this);
1416 	}
1417 	return 0;
1418 }
1419 
1420 static Size gDiffSize;
1421 //============================================================================
1422 //	class SvxAcceptChgCtr
1423 //----------------------------------------------------------------------------
1424 
SvxAcceptChgCtr(Window * pParent,WinBits nWinStyle)1425 SvxAcceptChgCtr::SvxAcceptChgCtr( Window* pParent, WinBits nWinStyle)
1426 		:	Control(pParent,nWinStyle |WB_DIALOGCONTROL),
1427 			aTCAccept(this,WB_TABSTOP |WB_DIALOGCONTROL)
1428 {
1429 	pTPFilter=new SvxTPFilter(&aTCAccept);
1430 	pTPView=new SvxTPView(&aTCAccept);
1431 	aMinSize=pTPView->GetMinSizePixel();
1432 
1433 	aTCAccept.InsertPage( TP_VIEW,	 pTPView->GetMyName());
1434 	aTCAccept.InsertPage( TP_FILTER, pTPFilter->GetMyName());
1435 	aTCAccept.SetTabPage( TP_VIEW,	 pTPView);
1436 	aTCAccept.SetTabPage( TP_FILTER, pTPFilter);
1437 	aTCAccept.SetHelpId(HID_REDLINING_TABCONTROL);
1438 
1439 	aTCAccept.SetTabPageSizePixel(aMinSize);
1440 	Size aSize=aTCAccept.GetSizePixel();
1441 
1442 	gDiffSize.Height()=aSize.Height()-aMinSize.Height();
1443 	gDiffSize.Width()=aSize.Width()-aMinSize.Width();
1444 
1445 
1446 	pTPFilter->SetRedlinTable(GetViewTable());
1447 
1448 	aTCAccept.Show();
1449 	ShowViewPage();
1450 }
1451 
SvxAcceptChgCtr(Window * pParent,const ResId & rResId)1452 SvxAcceptChgCtr::SvxAcceptChgCtr( Window* pParent, const ResId& rResId )
1453 		:	Control(pParent,rResId ),
1454 			aTCAccept(this,WB_TABSTOP |WB_DIALOGCONTROL)
1455 {
1456 	pTPFilter=new SvxTPFilter(&aTCAccept);
1457 	pTPView=new SvxTPView(&aTCAccept);
1458 	aMinSize=pTPView->GetMinSizePixel();
1459 
1460 	aTCAccept.InsertPage( TP_VIEW,	 pTPView->GetMyName());
1461 	aTCAccept.InsertPage( TP_FILTER, pTPFilter->GetMyName());
1462 	aTCAccept.SetTabPage( TP_VIEW,	 pTPView);
1463 	aTCAccept.SetTabPage( TP_FILTER, pTPFilter);
1464 	aTCAccept.SetHelpId(HID_REDLINING_TABCONTROL);
1465 
1466 	aTCAccept.SetTabPageSizePixel(aMinSize);
1467 	Size aSize=aTCAccept.GetSizePixel();
1468 
1469 	gDiffSize.Height()=aSize.Height()-aMinSize.Height();
1470 	gDiffSize.Width()=aSize.Width()-aMinSize.Width();
1471 
1472 
1473 	pTPFilter->SetRedlinTable(GetViewTable());
1474 	WinBits nWinStyle=GetStyle()|WB_DIALOGCONTROL;
1475 	SetStyle(nWinStyle);
1476 
1477 	aTCAccept.Show();
1478 	ShowViewPage();
1479 	Resize();
1480 }
1481 
~SvxAcceptChgCtr()1482 SvxAcceptChgCtr::~SvxAcceptChgCtr()
1483 {
1484 	delete pTPView;
1485 	delete pTPFilter;
1486 }
1487 
Resize()1488 void SvxAcceptChgCtr::Resize()
1489 {
1490 	aMinSize=pTPView->GetMinSizePixel();
1491 	Size aSize=GetOutputSizePixel();
1492 	sal_Bool bFlag=sal_False;
1493 
1494 	if(aMinSize.Height()>aSize.Height())
1495 	{
1496 		aSize.Height()=aMinSize.Height();
1497 		bFlag=sal_True;
1498 	}
1499 	if(aMinSize.Width()>aSize.Width())
1500 	{
1501 		aSize.Width()=aMinSize.Width();
1502 		bFlag=sal_True;
1503 	}
1504 
1505 	if(bFlag)
1506 	{
1507 		SetOutputSizePixel(aSize);
1508 		aMinSizeLink.Call(this);
1509 	}
1510 
1511 	aSize.Height()-=2;
1512 	aSize.Width()-=2;
1513 	aTCAccept.SetSizePixel(aSize);
1514 }
1515 
GetMinSizePixel() const1516 Size SvxAcceptChgCtr::GetMinSizePixel() const
1517 {
1518 	Size aSize=pTPView->GetMinSizePixel();
1519 	aSize.Height()+=gDiffSize.Height();
1520 	aSize.Width()+=gDiffSize.Width();
1521 	return aSize;
1522 }
1523 
ShowFilterPage()1524 void SvxAcceptChgCtr::ShowFilterPage()
1525 {
1526 	aTCAccept.SetCurPageId(TP_FILTER);
1527 }
1528 
ShowViewPage()1529 void SvxAcceptChgCtr::ShowViewPage()
1530 {
1531 	aTCAccept.SetCurPageId(TP_VIEW);
1532 }
1533 
IsFilterPageVisible()1534 sal_Bool SvxAcceptChgCtr::IsFilterPageVisible()
1535 {
1536 	return (aTCAccept.GetCurPageId()==TP_FILTER);
1537 }
1538 
IsViewPageVisible()1539 sal_Bool SvxAcceptChgCtr::IsViewPageVisible()
1540 {
1541 	return (aTCAccept.GetCurPageId()==TP_VIEW);
1542 }
1543 
GetFilterPage()1544 SvxTPFilter* SvxAcceptChgCtr::GetFilterPage()
1545 {
1546 	return pTPFilter;
1547 }
1548 
GetViewPage()1549 SvxTPView* SvxAcceptChgCtr::GetViewPage()
1550 {
1551 	return pTPView;
1552 }
1553 
GetViewTable()1554 SvxRedlinTable* SvxAcceptChgCtr::GetViewTable()
1555 {
1556 	if(pTPView!=NULL)
1557 	{
1558 		return pTPView->GetTableControl();
1559 	}
1560 	else
1561 	{
1562 		return NULL;
1563 	}
1564 }
1565 
1566 
1567