Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <vcl/dialog.hxx>
21 : #include <vcl/layout.hxx>
22 : #include <vcl/svapp.hxx>
23 : #include <tools/shl.hxx>
24 : #include <sfx2/app.hxx>
25 : #include <sfx2/module.hxx>
26 : #include <unotools/textsearch.hxx>
27 : #include <svtools/svlbitm.hxx>
28 : #include "svtools/viewdataentry.hxx"
29 : #include <unotools/charclass.hxx>
30 :
31 : #include <editeng/unolingu.hxx>
32 : #include <svx/dialmgr.hxx>
33 : #include "svx/dialogs.hrc"
34 : #include "ctredlin.hrc"
35 : #include <svx/ctredlin.hxx>
36 : #include "helpid.hrc"
37 :
38 : //============================================================================
39 : // Local Defines and Function
40 : //----------------------------------------------------------------------------
41 :
42 : static long nStaticTabs[]=
43 : {
44 : 5,10,65,120,170,220
45 : };
46 :
47 : #define WRITER_DATE 2
48 : #define CALC_DATE 3
49 :
50 0 : RedlinData::RedlinData()
51 : :
52 0 : aDateTime( DateTime::EMPTY )
53 : {
54 0 : bDisabled=sal_False;
55 0 : pData=NULL;
56 0 : }
57 0 : RedlinData::~RedlinData()
58 : {
59 0 : }
60 :
61 : //============================================================================
62 : // class SvxRedlinEntry (Entries for list)
63 : //----------------------------------------------------------------------------
64 :
65 0 : SvxRedlinEntry::SvxRedlinEntry()
66 0 : :SvTreeListEntry()
67 : {
68 0 : }
69 :
70 0 : SvxRedlinEntry::~SvxRedlinEntry()
71 : {
72 0 : RedlinData* pRedDat=(RedlinData*) GetUserData();
73 0 : delete pRedDat;
74 0 : }
75 :
76 : // Functions in the inserts Items of SvxRedlinTable
77 :
78 : DBG_NAME(SvLBoxColorString);
79 :
80 0 : SvLBoxColorString::SvLBoxColorString( SvTreeListEntry*pEntry,sal_uInt16 nFlags,const XubString& rStr,
81 : const Color& rCol)
82 :
83 0 : : SvLBoxString( pEntry, nFlags, rStr )
84 : {
85 : DBG_CTOR(SvLBoxColorString,0);
86 0 : aPrivColor=rCol;
87 0 : SetText( rStr );
88 0 : }
89 :
90 0 : SvLBoxColorString::SvLBoxColorString()
91 0 : : SvLBoxString()
92 : {
93 : DBG_CTOR(SvLBoxColorString,0);
94 0 : }
95 :
96 0 : SvLBoxColorString::~SvLBoxColorString()
97 : {
98 : DBG_DTOR(SvLBoxColorString,0);
99 0 : }
100 :
101 0 : SvLBoxItem* SvLBoxColorString::Create() const
102 : {
103 : DBG_CHKTHIS(SvLBoxColorString,0);
104 0 : return new SvLBoxColorString;
105 : }
106 :
107 0 : void SvLBoxColorString::Paint(
108 : const Point& rPos, SvTreeListBox& rDev,
109 : const SvViewDataEntry* pView, const SvTreeListEntry* pEntry)
110 : /* [Description]
111 :
112 : Paint function of the SvLBoxColorString class. The relevant text with the
113 : selected color is drawn in the output device.
114 : */
115 :
116 : {
117 0 : Color aColor=rDev.GetTextColor();
118 0 : Color a2Color=aColor;
119 0 : if (!pView->IsSelected())
120 : {
121 0 : rDev.SetTextColor(aPrivColor);
122 : }
123 0 : SvLBoxString::Paint(rPos, rDev, pView, pEntry);
124 0 : rDev.SetTextColor(a2Color);
125 0 : }
126 :
127 : //============================================================================
128 : // class SvxRedlinTable
129 : //----------------------------------------------------------------------------
130 :
131 0 : SvxRedlinTable::SvxRedlinTable(SvxSimpleTableContainer& rParent,WinBits nBits)
132 : : SvxSimpleTable(rParent,nBits),
133 : aDaTiFirst( DateTime::EMPTY ),
134 : aDaTiLast( DateTime::EMPTY ),
135 : aDaTiFilterFirst( DateTime::EMPTY ),
136 0 : aDaTiFilterLast( DateTime::EMPTY )
137 : {
138 0 : bAuthor=sal_False;
139 0 : bDate=sal_False;
140 0 : bIsCalc=sal_False;
141 0 : bComment=sal_False;
142 0 : nDatePos=WRITER_DATE;
143 0 : pCommentSearcher=NULL;
144 0 : SetNodeDefaultImages();
145 0 : }
146 :
147 0 : SvxRedlinTable::~SvxRedlinTable()
148 : {
149 0 : delete pCommentSearcher;
150 0 : }
151 :
152 0 : StringCompare SvxRedlinTable::ColCompare(SvTreeListEntry* pLeft,SvTreeListEntry* pRight)
153 : {
154 0 : StringCompare eCompare=COMPARE_EQUAL;
155 :
156 0 : if(aColCompareLink.IsSet())
157 : {
158 : SvSortData aRedlinCompare;
159 0 : aRedlinCompare.pLeft=pLeft;
160 0 : aRedlinCompare.pRight=pRight;
161 0 : eCompare=(StringCompare) aColCompareLink.Call(&aRedlinCompare);
162 : }
163 : else
164 : {
165 0 : if(nDatePos==GetSortedCol())
166 : {
167 0 : RedlinData *pLeftData=(RedlinData *)(pLeft->GetUserData());
168 0 : RedlinData *pRightData=(RedlinData *)(pRight->GetUserData());
169 :
170 0 : if(pLeftData!=NULL && pRightData!=NULL)
171 : {
172 0 : if(pLeftData->aDateTime < pRightData->aDateTime)
173 : {
174 0 : eCompare=COMPARE_LESS;
175 : }
176 0 : else if(pLeftData->aDateTime > pRightData->aDateTime)
177 : {
178 0 : eCompare=COMPARE_GREATER;
179 : }
180 : }
181 : else
182 0 : eCompare=SvxSimpleTable::ColCompare(pLeft,pRight);
183 : }
184 : else
185 : {
186 0 : eCompare=SvxSimpleTable::ColCompare(pLeft,pRight);
187 : }
188 :
189 : }
190 :
191 0 : return eCompare;
192 : }
193 0 : void SvxRedlinTable::SetCalcView(sal_Bool bFlag)
194 : {
195 0 : bIsCalc=bFlag;
196 0 : if(bFlag)
197 : {
198 0 : nDatePos=CALC_DATE;
199 : }
200 : else
201 : {
202 0 : nDatePos=WRITER_DATE;
203 : }
204 0 : }
205 :
206 :
207 0 : void SvxRedlinTable::UpdateFilterTest()
208 : {
209 0 : Date aDateMax( Date::SYSTEM );
210 0 : sal_uInt16 nYEAR=aDateMax.GetYear()+100;
211 0 : aDateMax.SetYear(nYEAR);
212 0 : Date aDateMin(1,1,1989);
213 0 : Time aTMin(0);
214 0 : Time aTMax(23,59,59);
215 :
216 :
217 0 : DateTime aDTMin(aDateMin);
218 0 : DateTime aDTMax(aDateMax);
219 :
220 0 : switch(nDaTiMode)
221 : {
222 : case FLT_DATE_BEFORE:
223 0 : aDaTiFilterFirst=aDTMin;
224 0 : aDaTiFilterLast=aDaTiFirst;
225 0 : break;
226 : case FLT_DATE_SAVE:
227 : case FLT_DATE_SINCE:
228 0 : aDaTiFilterFirst=aDaTiFirst;
229 0 : aDaTiFilterLast=aDTMax;
230 0 : break;
231 : case FLT_DATE_EQUAL:
232 0 : aDaTiFilterFirst=aDaTiFirst;
233 0 : aDaTiFilterLast=aDaTiFirst;
234 0 : aDaTiFilterFirst.SetTime(aTMin.GetTime());
235 0 : aDaTiFilterLast.SetTime(aTMax.GetTime());
236 0 : break;
237 : case FLT_DATE_NOTEQUAL:
238 0 : aDaTiFilterFirst=aDaTiFirst;
239 0 : aDaTiFilterLast=aDaTiFirst;
240 0 : aDaTiFilterFirst.SetTime(aTMin.GetTime());
241 0 : aDaTiFilterLast.SetTime(aTMax.GetTime());
242 0 : break;
243 : case FLT_DATE_BETWEEN:
244 0 : aDaTiFilterFirst=aDaTiFirst;
245 0 : aDaTiFilterLast=aDaTiLast;
246 0 : break;
247 : }
248 0 : }
249 :
250 :
251 0 : void SvxRedlinTable::SetFilterDate(sal_Bool bFlag)
252 : {
253 0 : bDate=bFlag;
254 0 : }
255 :
256 0 : void SvxRedlinTable::SetDateTimeMode(sal_uInt16 nMode)
257 : {
258 0 : nDaTiMode=nMode;
259 0 : }
260 :
261 0 : void SvxRedlinTable::SetFirstDate(const Date& aDate)
262 : {
263 0 : aDaTiFirst.SetDate(aDate.GetDate());
264 0 : }
265 :
266 0 : void SvxRedlinTable::SetLastDate(const Date& aDate)
267 : {
268 0 : aDaTiLast.SetDate(aDate.GetDate());
269 0 : }
270 :
271 0 : void SvxRedlinTable::SetFirstTime(const Time& aTime)
272 : {
273 0 : aDaTiFirst.SetTime(aTime.GetTime());
274 0 : }
275 :
276 0 : void SvxRedlinTable::SetLastTime(const Time& aTime)
277 : {
278 0 : aDaTiLast.SetTime(aTime.GetTime());
279 0 : }
280 :
281 0 : void SvxRedlinTable::SetFilterAuthor(sal_Bool bFlag)
282 : {
283 0 : bAuthor=bFlag;
284 0 : }
285 :
286 0 : void SvxRedlinTable::SetAuthor(const String &aString)
287 : {
288 0 : aAuthor=aString;
289 0 : }
290 :
291 0 : void SvxRedlinTable::SetFilterComment(sal_Bool bFlag)
292 : {
293 0 : bComment=bFlag;
294 0 : }
295 :
296 0 : void SvxRedlinTable::SetCommentParams( const utl::SearchParam* pSearchPara )
297 : {
298 0 : if(pSearchPara!=NULL)
299 : {
300 0 : delete pCommentSearcher;
301 :
302 0 : pCommentSearcher=new utl::TextSearch(*pSearchPara, LANGUAGE_SYSTEM );
303 : }
304 0 : }
305 :
306 0 : sal_Bool SvxRedlinTable::IsValidEntry(const String* pAuthorStr,
307 : const DateTime *pDateTime,const String* pCommentStr)
308 : {
309 0 : bool nTheFlag=true;
310 0 : if(bAuthor)
311 : {
312 0 : nTheFlag = aAuthor.CompareTo(*pAuthorStr)==COMPARE_EQUAL;
313 : }
314 0 : if(bDate && nTheFlag)
315 : {
316 0 : if(nDaTiMode!=FLT_DATE_NOTEQUAL)
317 : {
318 0 : nTheFlag=pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast);
319 : }
320 : else
321 : {
322 0 : nTheFlag=!(pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast));
323 : }
324 : }
325 0 : if(bComment && nTheFlag)
326 : {
327 0 : sal_Int32 nStartPos = 0;
328 0 : sal_Int32 nEndPos = pCommentStr->Len();
329 :
330 0 : nTheFlag=pCommentSearcher->SearchForward( *pCommentStr, &nStartPos, &nEndPos);
331 : }
332 0 : return nTheFlag;
333 : }
334 :
335 0 : sal_Bool SvxRedlinTable::IsValidEntry(const String* pAuthorStr,const DateTime *pDateTime)
336 : {
337 0 : sal_Bool nTheFlag=sal_True;
338 0 : if(bAuthor)
339 : {
340 0 : if(aAuthor.CompareTo(*pAuthorStr)==COMPARE_EQUAL)
341 0 : nTheFlag=sal_True;
342 : else
343 0 : nTheFlag=sal_False;
344 : }
345 0 : if(bDate && nTheFlag)
346 : {
347 0 : if(nDaTiMode!=FLT_DATE_NOTEQUAL)
348 : {
349 0 : nTheFlag=pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast);
350 : }
351 : else
352 : {
353 0 : nTheFlag=!(pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast));
354 : }
355 : }
356 0 : return nTheFlag;
357 : }
358 :
359 0 : sal_Bool SvxRedlinTable::IsValidComment(const String* pCommentStr)
360 : {
361 0 : bool nTheFlag=true;
362 :
363 0 : if(bComment)
364 : {
365 0 : sal_Int32 nStartPos = 0;
366 0 : sal_Int32 nEndPos = pCommentStr->Len();
367 :
368 0 : nTheFlag=pCommentSearcher->SearchForward( *pCommentStr, &nStartPos, &nEndPos);
369 : }
370 0 : return nTheFlag;
371 : }
372 :
373 0 : SvTreeListEntry* SvxRedlinTable::InsertEntry(const String& rStr,RedlinData *pUserData,
374 : SvTreeListEntry* pParent,sal_uIntPtr nPos)
375 : {
376 0 : aEntryColor=GetTextColor();
377 0 : if(pUserData!=NULL)
378 : {
379 0 : if(pUserData->bDisabled)
380 0 : aEntryColor=Color(COL_GRAY);
381 : }
382 :
383 0 : XubString aStr= rStr;
384 :
385 0 : XubString aFirstStr( aStr );
386 0 : xub_StrLen nEnd = aFirstStr.Search( sal_Unicode( '\t' ) );
387 0 : if( nEnd != STRING_NOTFOUND )
388 : {
389 0 : aFirstStr.Erase( nEnd );
390 0 : aCurEntry = aStr;
391 0 : aCurEntry.Erase( 0, ++nEnd );
392 : }
393 : else
394 0 : aCurEntry.Erase();
395 :
396 0 : return SvxSimpleTable::InsertEntry( aFirstStr, pParent, sal_False, nPos, pUserData );
397 :
398 : }
399 :
400 0 : SvTreeListEntry* SvxRedlinTable::InsertEntry(const String& rStr,RedlinData *pUserData,const Color& aColor,
401 : SvTreeListEntry* pParent,sal_uIntPtr nPos)
402 : {
403 0 : aEntryColor=aColor;
404 :
405 0 : XubString aStr= rStr;
406 :
407 0 : XubString aFirstStr( aStr );
408 0 : xub_StrLen nEnd = aFirstStr.Search( sal_Unicode ( '\t' ) );
409 0 : if( nEnd != STRING_NOTFOUND )
410 : {
411 0 : aFirstStr.Erase( nEnd );
412 0 : aCurEntry = aStr;
413 0 : aCurEntry.Erase( 0, ++nEnd );
414 : }
415 : else
416 0 : aCurEntry.Erase();
417 :
418 0 : return SvxSimpleTable::InsertEntry( aFirstStr, pParent, sal_False, nPos, pUserData );
419 : }
420 :
421 0 : SvTreeListEntry* SvxRedlinTable::CreateEntry() const
422 : {
423 0 : return new SvxRedlinEntry;
424 : }
425 :
426 0 : void SvxRedlinTable::InitEntry(SvTreeListEntry* pEntry, const OUString& rStr,
427 : const Image& rColl, const Image& rExp, SvLBoxButtonKind eButtonKind)
428 : {
429 : SvLBoxButton* pButton;
430 : SvLBoxString* pString;
431 : SvLBoxContextBmp* pContextBmp;
432 :
433 0 : if( nTreeFlags & TREEFLAG_CHKBTN )
434 : {
435 0 : pButton= new SvLBoxButton( pEntry,eButtonKind,0,pCheckButtonData );
436 0 : pEntry->AddItem( pButton );
437 : }
438 :
439 0 : pContextBmp= new SvLBoxContextBmp(pEntry,0, rColl,rExp, true);
440 0 : pEntry->AddItem( pContextBmp );
441 :
442 0 : pString = new SvLBoxColorString( pEntry, 0, rStr ,aEntryColor);
443 0 : pEntry->AddItem( pString );
444 :
445 0 : XubString aToken;
446 :
447 0 : sal_Unicode* pCurToken = (sal_Unicode*)aCurEntry.GetBuffer();
448 : sal_uInt16 nCurTokenLen;
449 0 : sal_Unicode* pNextToken = (sal_Unicode*)GetToken( pCurToken, nCurTokenLen );
450 0 : sal_uInt16 nCount = TabCount(); nCount--;
451 :
452 0 : for( sal_uInt16 nToken = 0; nToken < nCount; nToken++ )
453 : {
454 0 : if( pCurToken && nCurTokenLen )
455 0 : aToken = OUString(pCurToken, nCurTokenLen);
456 : else
457 0 : aToken.Erase();
458 :
459 0 : SvLBoxColorString* pStr = new SvLBoxColorString( pEntry, 0, aToken ,aEntryColor);
460 0 : pEntry->AddItem( pStr );
461 :
462 0 : pCurToken = pNextToken;
463 0 : if( pCurToken )
464 0 : pNextToken = (sal_Unicode*)GetToken( pCurToken, nCurTokenLen );
465 : else
466 0 : nCurTokenLen = 0;
467 0 : }
468 0 : }
469 :
470 :
471 :
472 :
473 : //============================================================================
474 : // class SvxTPView
475 : //----------------------------------------------------------------------------
476 :
477 0 : SvxTPView::SvxTPView(Window * pParent)
478 0 : : TabPage(pParent, "RedlineViewPage", "svx/ui/redlineviewpage.ui")
479 : {
480 0 : Dialog *pTopLevel = GetParentDialog();
481 0 : pTopLevel->get(m_pAccept, "accept");
482 0 : pTopLevel->get(m_pReject, "reject");
483 0 : pTopLevel->get(m_pAcceptAll, "acceptall");
484 0 : pTopLevel->get(m_pRejectAll, "rejectall");
485 0 : pTopLevel->get(m_pUndo, "undo");
486 :
487 0 : SvxSimpleTableContainer* pTable = get<SvxSimpleTableContainer>("changes");
488 0 : Size aControlSize(221, 65);
489 0 : aControlSize = LogicToPixel(aControlSize, MAP_APPFONT);
490 0 : pTable->set_width_request(aControlSize.Width());
491 0 : pTable->set_height_request(aControlSize.Height());
492 0 : m_pViewData = new SvxRedlinTable(*pTable, 0);
493 :
494 0 : Link aLink=LINK( this, SvxTPView, PbClickHdl);
495 :
496 0 : m_pAccept->SetClickHdl(aLink);
497 0 : m_pAcceptAll->SetClickHdl(aLink);
498 0 : m_pReject->SetClickHdl(aLink);
499 0 : m_pRejectAll->SetClickHdl(aLink);
500 0 : m_pUndo->SetClickHdl(aLink);
501 :
502 0 : m_pViewData->SetTabs(nStaticTabs);
503 0 : }
504 :
505 0 : void SvxTPView::ActivatePage()
506 : {
507 0 : m_pAccept->Enable();
508 0 : m_pReject->Enable();
509 0 : m_pAcceptAll->Enable();
510 0 : m_pRejectAll->Enable();
511 0 : m_pUndo->Enable();
512 0 : TabPage::ActivatePage();
513 0 : }
514 :
515 0 : void SvxTPView::DeactivatePage()
516 : {
517 0 : TabPage::DeactivatePage();
518 0 : m_pAccept->Disable();
519 0 : m_pReject->Disable();
520 0 : m_pAcceptAll->Disable();
521 0 : m_pRejectAll->Disable();
522 0 : m_pUndo->Disable();
523 0 : }
524 :
525 0 : SvxTPView::~SvxTPView()
526 : {
527 0 : delete m_pViewData;
528 0 : }
529 :
530 0 : void SvxTPView::InsertWriterHeader()
531 : {
532 0 : OUString aStrTab('\t');
533 0 : OUString aString(get<FixedText>("action")->GetText());
534 0 : aString += aStrTab;
535 0 : aString += get<FixedText>("author")->GetText();
536 0 : aString += aStrTab;
537 0 : aString += get<FixedText>("date")->GetText();
538 0 : aString += aStrTab;
539 0 : aString += get<FixedText>("comment")->GetText();
540 0 : m_pViewData->ClearHeader();
541 0 : m_pViewData->InsertHeaderEntry(aString);
542 0 : }
543 :
544 0 : void SvxTPView::InsertCalcHeader()
545 : {
546 0 : OUString aStrTab('\t');
547 0 : OUString aString(get<FixedText>("action")->GetText());
548 0 : aString += aStrTab;
549 0 : aString += get<FixedText>("position")->GetText();
550 0 : aString += aStrTab;
551 0 : aString += get<FixedText>("author")->GetText();
552 0 : aString += aStrTab;
553 0 : aString += get<FixedText>("date")->GetText();
554 0 : aString += aStrTab;
555 0 : aString += get<FixedText>("comment")->GetText();
556 0 : m_pViewData->ClearHeader();
557 0 : m_pViewData->InsertHeaderEntry(aString);
558 0 : }
559 :
560 0 : void SvxTPView::EnableAccept(sal_Bool nFlag)
561 : {
562 0 : m_pAccept->Enable(nFlag);
563 0 : }
564 :
565 0 : void SvxTPView::EnableAcceptAll(sal_Bool nFlag)
566 : {
567 0 : m_pAcceptAll->Enable(nFlag);
568 0 : }
569 :
570 0 : void SvxTPView::EnableReject(sal_Bool nFlag)
571 : {
572 0 : m_pReject->Enable(nFlag);
573 0 : }
574 :
575 0 : void SvxTPView::EnableRejectAll(sal_Bool nFlag)
576 : {
577 0 : m_pRejectAll->Enable(nFlag);
578 0 : }
579 :
580 0 : void SvxTPView::ShowUndo(sal_Bool nFlag)
581 : {
582 0 : m_pUndo->Show(nFlag);
583 0 : }
584 :
585 0 : void SvxTPView::EnableUndo(sal_Bool nFlag)
586 : {
587 0 : m_pUndo->Enable(nFlag);
588 0 : }
589 :
590 0 : SvxRedlinTable* SvxTPView::GetTableControl()
591 : {
592 0 : return m_pViewData;
593 : }
594 :
595 0 : IMPL_LINK( SvxTPView, PbClickHdl, PushButton*, pPushB )
596 : {
597 0 : if (pPushB == m_pAccept)
598 : {
599 0 : AcceptClickLk.Call(this);
600 : }
601 0 : else if (pPushB == m_pAcceptAll)
602 : {
603 0 : AcceptAllClickLk.Call(this);
604 : }
605 0 : else if (pPushB == m_pReject)
606 : {
607 0 : RejectClickLk.Call(this);
608 : }
609 0 : else if (pPushB == m_pRejectAll)
610 : {
611 0 : RejectAllClickLk.Call(this);
612 : }
613 0 : else if (pPushB == m_pUndo)
614 : {
615 0 : UndoClickLk.Call(this);
616 : }
617 :
618 0 : return 0;
619 : }
620 :
621 :
622 :
623 :
624 : //============================================================================
625 : // class SvxTPFilter
626 : //----------------------------------------------------------------------------
627 :
628 0 : SvxTPFilter::SvxTPFilter( Window * pParent)
629 : : TabPage(pParent, "RedlineFilterPage", "svx/ui/redlinefilterpage.ui")
630 : , pRedlinTable(NULL)
631 0 : , bModified(false)
632 : {
633 0 : get(m_pCbDate, "date");
634 0 : get(m_pLbDate, "datecond");
635 0 : get(m_pDfDate, "startdate");
636 0 : get(m_pTfDate, "starttime");
637 0 : get(m_pIbClock, "startclock");
638 0 : get(m_pFtDate2, "and");
639 0 : get(m_pDfDate2, "enddate");
640 0 : get(m_pTfDate2, "endtime");
641 0 : get(m_pIbClock2, "endclock");
642 0 : get(m_pCbAuthor, "author");
643 0 : get(m_pLbAuthor, "authorlist");
644 0 : get(m_pCbRange, "range");
645 0 : get(m_pEdRange, "rangeedit");
646 0 : get(m_pBtnRange, "dotdotdot");
647 0 : get(m_pCbAction, "action");
648 0 : get(m_pLbAction, "actionlist");
649 0 : get(m_pCbComment, "comment");
650 0 : get(m_pEdComment, "commentedit");
651 :
652 0 : m_pLbAuthor->SetAccessibleName(m_pCbAuthor->GetText());
653 0 : m_pEdComment->SetAccessibleName(m_pCbComment->GetText());
654 :
655 0 : m_pDfDate->SetShowDateCentury( sal_True );
656 0 : m_pDfDate2->SetShowDateCentury( sal_True );
657 :
658 0 : m_pLbDate->SelectEntryPos(0);
659 0 : m_pLbDate->SetSelectHdl( LINK( this, SvxTPFilter, SelDateHdl ) );
660 0 : m_pIbClock->SetClickHdl( LINK( this, SvxTPFilter, TimeHdl) );
661 0 : m_pIbClock2->SetClickHdl( LINK( this, SvxTPFilter,TimeHdl) );
662 0 : m_pBtnRange->SetClickHdl( LINK( this, SvxTPFilter, RefHandle));
663 :
664 0 : Link aLink=LINK( this, SvxTPFilter, RowEnableHdl) ;
665 0 : m_pCbDate->SetClickHdl(aLink);
666 0 : m_pCbAuthor->SetClickHdl(aLink);
667 0 : m_pCbRange->SetClickHdl(aLink);
668 0 : m_pCbAction->SetClickHdl(aLink);
669 0 : m_pCbComment->SetClickHdl(aLink);
670 :
671 0 : Link a2Link=LINK( this, SvxTPFilter, ModifyDate);
672 0 : m_pDfDate->SetModifyHdl(a2Link);
673 0 : m_pTfDate->SetModifyHdl(a2Link);
674 0 : m_pDfDate2->SetModifyHdl(a2Link);
675 0 : m_pTfDate2->SetModifyHdl(a2Link);
676 :
677 0 : Link a3Link=LINK( this, SvxTPFilter, ModifyHdl);
678 0 : m_pEdRange->SetModifyHdl(a3Link);
679 0 : m_pEdComment->SetModifyHdl(a3Link);
680 0 : m_pLbAction->SetSelectHdl(a3Link);
681 0 : m_pLbAuthor->SetSelectHdl(a3Link);
682 :
683 0 : RowEnableHdl(m_pCbDate);
684 0 : RowEnableHdl(m_pCbAuthor);
685 0 : RowEnableHdl(m_pCbRange);
686 0 : RowEnableHdl(m_pCbAction);
687 0 : RowEnableHdl(m_pCbComment);
688 :
689 0 : Date aDate( Date::SYSTEM );
690 0 : Time aTime( Time::SYSTEM );
691 0 : m_pDfDate->SetDate(aDate);
692 0 : m_pTfDate->SetTime(aTime);
693 0 : m_pDfDate2->SetDate(aDate);
694 0 : m_pTfDate2->SetTime(aTime);
695 0 : HideRange();
696 0 : ShowAction();
697 0 : bModified=sal_False;
698 0 : }
699 :
700 0 : void SvxTPFilter::SetRedlinTable(SvxRedlinTable* pTable)
701 : {
702 0 : pRedlinTable=pTable;
703 0 : }
704 :
705 0 : void SvxTPFilter::ShowDateFields(sal_uInt16 nKind)
706 : {
707 0 : String aEmpty;
708 0 : switch(nKind)
709 : {
710 : case FLT_DATE_BEFORE:
711 0 : EnableDateLine1(sal_True);
712 0 : EnableDateLine2(sal_False);
713 0 : break;
714 : case FLT_DATE_SINCE:
715 0 : EnableDateLine1(sal_True);
716 0 : EnableDateLine2(sal_False);
717 0 : break;
718 : case FLT_DATE_EQUAL:
719 0 : EnableDateLine1(sal_True);
720 0 : m_pTfDate->Disable();
721 0 : m_pTfDate->SetText(aEmpty);
722 0 : EnableDateLine2(sal_False);
723 0 : break;
724 : case FLT_DATE_NOTEQUAL:
725 0 : EnableDateLine1(sal_True);
726 0 : m_pTfDate->Disable();
727 0 : m_pTfDate->SetText(aEmpty);
728 0 : EnableDateLine2(sal_False);
729 0 : break;
730 : case FLT_DATE_BETWEEN:
731 0 : EnableDateLine1(sal_True);
732 0 : EnableDateLine2(sal_True);
733 0 : break;
734 : case FLT_DATE_SAVE:
735 0 : EnableDateLine1(sal_False);
736 0 : EnableDateLine2(sal_False);
737 0 : break;
738 0 : }
739 0 : }
740 :
741 0 : void SvxTPFilter::EnableDateLine1(sal_Bool bFlag)
742 : {
743 0 : if(bFlag && m_pCbDate->IsChecked())
744 : {
745 0 : m_pDfDate->Enable();
746 0 : m_pTfDate->Enable();
747 0 : m_pIbClock->Enable();
748 : }
749 : else
750 : {
751 0 : m_pDfDate->Disable();
752 0 : m_pTfDate->Disable();
753 0 : m_pIbClock->Disable();
754 : }
755 0 : }
756 0 : void SvxTPFilter::EnableDateLine2(sal_Bool bFlag)
757 : {
758 0 : String aEmpty;
759 0 : if(bFlag && m_pCbDate->IsChecked())
760 : {
761 0 : m_pFtDate2->Enable();
762 0 : m_pDfDate2->Enable();
763 0 : m_pTfDate2->Enable();
764 0 : m_pIbClock2->Enable();
765 : }
766 : else
767 : {
768 0 : m_pFtDate2->Disable();
769 0 : m_pDfDate2->Disable();
770 0 : m_pDfDate2->SetText(aEmpty);
771 0 : m_pTfDate2->Disable();
772 0 : m_pTfDate2->SetText(aEmpty);
773 0 : m_pIbClock2->Disable();
774 0 : }
775 0 : }
776 :
777 0 : Date SvxTPFilter::GetFirstDate() const
778 : {
779 0 : return m_pDfDate->GetDate();
780 : }
781 :
782 0 : void SvxTPFilter::SetFirstDate(const Date &aDate)
783 : {
784 0 : m_pDfDate->SetDate(aDate);
785 0 : }
786 :
787 0 : Time SvxTPFilter::GetFirstTime() const
788 : {
789 0 : return m_pTfDate->GetTime();
790 : }
791 :
792 0 : void SvxTPFilter::SetFirstTime(const Time &aTime)
793 : {
794 0 : m_pTfDate->SetTime(aTime);
795 0 : }
796 :
797 :
798 0 : Date SvxTPFilter::GetLastDate() const
799 : {
800 0 : return m_pDfDate2->GetDate();
801 : }
802 :
803 0 : void SvxTPFilter::SetLastDate(const Date &aDate)
804 : {
805 0 : m_pDfDate2->SetDate(aDate);
806 0 : }
807 :
808 0 : Time SvxTPFilter::GetLastTime() const
809 : {
810 0 : return m_pTfDate2->GetTime();
811 : }
812 :
813 0 : void SvxTPFilter::SetLastTime(const Time &aTime)
814 : {
815 0 : m_pTfDate2->SetTime(aTime);
816 0 : }
817 :
818 0 : void SvxTPFilter::SetDateMode(sal_uInt16 nMode)
819 : {
820 0 : m_pLbDate->SelectEntryPos(nMode);
821 0 : SelDateHdl(m_pLbDate);
822 0 : }
823 :
824 0 : sal_uInt16 SvxTPFilter::GetDateMode()
825 : {
826 0 : return (sal_uInt16) m_pLbDate->GetSelectEntryPos();
827 : }
828 0 : void SvxTPFilter::ClearAuthors()
829 : {
830 0 : m_pLbAuthor->Clear();
831 0 : }
832 :
833 0 : void SvxTPFilter::InsertAuthor( const String& rString, sal_uInt16 nPos)
834 : {
835 0 : m_pLbAuthor->InsertEntry(rString,nPos);
836 0 : }
837 :
838 0 : String SvxTPFilter::GetSelectedAuthor() const
839 : {
840 0 : return m_pLbAuthor->GetSelectEntry();
841 : }
842 :
843 0 : void SvxTPFilter::SelectedAuthorPos(sal_uInt16 nPos)
844 : {
845 0 : m_pLbAuthor->SelectEntryPos(nPos);
846 0 : }
847 :
848 0 : sal_uInt16 SvxTPFilter::SelectAuthor(const String& aString)
849 : {
850 0 : m_pLbAuthor->SelectEntry(aString);
851 0 : return m_pLbAuthor->GetSelectEntryPos();
852 : }
853 :
854 0 : void SvxTPFilter::SetRange(const String& rString)
855 : {
856 0 : m_pEdRange->SetText(rString);
857 0 : }
858 :
859 0 : String SvxTPFilter::GetRange() const
860 : {
861 0 : return m_pEdRange->GetText();
862 : }
863 :
864 0 : void SvxTPFilter::SetFocusToRange()
865 : {
866 0 : m_pEdRange->GrabFocus();
867 0 : }
868 :
869 0 : void SvxTPFilter::HideRange(sal_Bool bHide)
870 : {
871 0 : if (bHide)
872 : {
873 0 : m_pCbRange->Hide();
874 0 : m_pEdRange->Hide();
875 0 : m_pBtnRange->Hide();
876 : }
877 : else
878 : {
879 0 : ShowAction(false);
880 0 : m_pCbRange->Show();
881 0 : m_pEdRange->Show();
882 0 : m_pBtnRange->Show();
883 : }
884 0 : }
885 :
886 0 : void SvxTPFilter::SetComment(const String &rComment)
887 : {
888 0 : m_pEdComment->SetText(rComment);
889 0 : }
890 0 : String SvxTPFilter::GetComment()const
891 : {
892 0 : return m_pEdComment->GetText();
893 : }
894 :
895 0 : sal_Bool SvxTPFilter::IsDate()
896 : {
897 0 : return m_pCbDate->IsChecked();
898 : }
899 :
900 0 : sal_Bool SvxTPFilter::IsAuthor()
901 : {
902 0 : return m_pCbAuthor->IsChecked();
903 : }
904 :
905 0 : sal_Bool SvxTPFilter::IsRange()
906 : {
907 0 : return m_pCbRange->IsChecked();
908 : }
909 :
910 0 : sal_Bool SvxTPFilter::IsAction()
911 : {
912 0 : return m_pCbAction->IsChecked();
913 : }
914 :
915 0 : sal_Bool SvxTPFilter::IsComment()
916 : {
917 0 : return m_pCbComment->IsChecked();
918 : }
919 :
920 0 : void SvxTPFilter::CheckDate(sal_Bool bFlag)
921 : {
922 0 : m_pCbDate->Check(bFlag);
923 0 : RowEnableHdl(m_pCbDate);
924 0 : bModified=sal_False;
925 0 : }
926 :
927 0 : void SvxTPFilter::CheckAuthor(sal_Bool bFlag)
928 : {
929 0 : m_pCbAuthor->Check(bFlag);
930 0 : RowEnableHdl(m_pCbAuthor);
931 0 : bModified=sal_False;
932 0 : }
933 :
934 0 : void SvxTPFilter::CheckRange(sal_Bool bFlag)
935 : {
936 0 : m_pCbRange->Check(bFlag);
937 0 : RowEnableHdl(m_pCbRange);
938 0 : bModified=sal_False;
939 0 : }
940 :
941 0 : void SvxTPFilter::CheckAction(sal_Bool bFlag)
942 : {
943 0 : m_pCbAction->Check(bFlag);
944 0 : RowEnableHdl(m_pCbAction);
945 0 : bModified=sal_False;
946 0 : }
947 :
948 0 : void SvxTPFilter::CheckComment(sal_Bool bFlag)
949 : {
950 0 : m_pCbComment->Check(bFlag);
951 0 : RowEnableHdl(m_pCbComment);
952 0 : bModified=sal_False;
953 0 : }
954 :
955 0 : void SvxTPFilter::ShowAction(sal_Bool bShow)
956 : {
957 0 : if(!bShow)
958 : {
959 0 : m_pCbAction->Hide();
960 0 : m_pLbAction->Hide();
961 : }
962 : else
963 : {
964 0 : HideRange();
965 0 : m_pCbAction->Show();
966 0 : m_pLbAction->Show();
967 : }
968 0 : }
969 :
970 0 : ListBox* SvxTPFilter::GetLbAction()
971 : {
972 0 : return m_pLbAction;
973 : }
974 :
975 0 : IMPL_LINK( SvxTPFilter, SelDateHdl, ListBox*, pLb )
976 : {
977 0 : ShowDateFields((sal_uInt16)m_pLbDate->GetSelectEntryPos());
978 0 : ModifyHdl(pLb);
979 0 : return 0;
980 : }
981 :
982 0 : IMPL_LINK( SvxTPFilter, RowEnableHdl, CheckBox*, pCB )
983 : {
984 0 : if (pCB == m_pCbDate)
985 : {
986 0 : m_pLbDate->Enable(m_pCbDate->IsChecked());
987 0 : m_pLbDate->Invalidate();
988 0 : EnableDateLine1(sal_False);
989 0 : EnableDateLine2(sal_False);
990 0 : if(m_pCbDate->IsChecked()) SelDateHdl(m_pLbDate);
991 : }
992 0 : else if (pCB == m_pCbAuthor)
993 : {
994 0 : m_pLbAuthor->Enable(m_pCbAuthor->IsChecked());
995 0 : m_pLbAuthor->Invalidate();
996 : }
997 0 : else if (pCB == m_pCbRange)
998 : {
999 0 : m_pEdRange->Enable(m_pCbRange->IsChecked());
1000 0 : m_pBtnRange->Enable(m_pCbRange->IsChecked());
1001 : }
1002 0 : else if (pCB == m_pCbAction)
1003 : {
1004 0 : m_pLbAction->Enable(m_pCbAction->IsChecked());
1005 0 : m_pLbAction->Invalidate();
1006 : }
1007 0 : else if (pCB == m_pCbComment)
1008 : {
1009 0 : m_pEdComment->Enable(m_pCbComment->IsChecked());
1010 0 : m_pEdComment->Invalidate();
1011 : }
1012 :
1013 0 : ModifyHdl(pCB);
1014 0 : return 0;
1015 : }
1016 :
1017 0 : IMPL_LINK( SvxTPFilter, TimeHdl, ImageButton*,pIB )
1018 : {
1019 0 : Date aDate( Date::SYSTEM );
1020 0 : Time aTime( Time::SYSTEM );
1021 0 : if (pIB == m_pIbClock)
1022 : {
1023 0 : m_pDfDate->SetDate(aDate);
1024 0 : m_pTfDate->SetTime(aTime);
1025 : }
1026 0 : else if (pIB == m_pIbClock2)
1027 : {
1028 0 : m_pDfDate2->SetDate(aDate);
1029 0 : m_pTfDate2->SetTime(aTime);
1030 : }
1031 0 : ModifyHdl(m_pDfDate);
1032 0 : return 0;
1033 : }
1034 :
1035 0 : IMPL_LINK( SvxTPFilter, ModifyHdl, void*, pCtr)
1036 : {
1037 0 : if(pCtr!=NULL)
1038 : {
1039 0 : if (pCtr == m_pCbDate || pCtr == m_pLbDate ||
1040 0 : pCtr == m_pDfDate || pCtr == m_pTfDate ||
1041 0 : pCtr == m_pIbClock || pCtr == m_pFtDate2 ||
1042 0 : pCtr == m_pDfDate2 || pCtr == m_pTfDate2 ||
1043 0 : pCtr == m_pIbClock2)
1044 : {
1045 0 : aModifyDateLink.Call(this);
1046 : }
1047 0 : else if (pCtr == m_pCbAuthor || pCtr == m_pLbAuthor)
1048 : {
1049 0 : aModifyAuthorLink.Call(this);
1050 : }
1051 0 : else if (pCtr == m_pCbRange || pCtr == m_pLbAction || pCtr == m_pEdRange ||
1052 0 : pCtr == m_pBtnRange)
1053 : {
1054 0 : aModifyRefLink.Call(this);
1055 : }
1056 0 : else if (pCtr == m_pCbComment || pCtr == m_pEdComment)
1057 : {
1058 0 : aModifyComLink.Call(this);
1059 : }
1060 :
1061 0 : bModified=sal_True;
1062 0 : aModifyLink.Call(this);
1063 : }
1064 0 : return 0;
1065 : }
1066 :
1067 0 : void SvxTPFilter::DeactivatePage()
1068 : {
1069 0 : if(bModified)
1070 : {
1071 0 : if(pRedlinTable!=NULL)
1072 : {
1073 0 : pRedlinTable->SetFilterDate(IsDate());
1074 0 : pRedlinTable->SetDateTimeMode(GetDateMode());
1075 0 : pRedlinTable->SetFirstDate(m_pDfDate->GetDate());
1076 0 : pRedlinTable->SetLastDate(m_pDfDate2->GetDate());
1077 0 : pRedlinTable->SetFirstTime(m_pTfDate->GetTime());
1078 0 : pRedlinTable->SetLastTime(m_pTfDate2->GetTime());
1079 0 : pRedlinTable->SetFilterAuthor(IsAuthor());
1080 0 : pRedlinTable->SetAuthor(GetSelectedAuthor());
1081 :
1082 0 : pRedlinTable->SetFilterComment(IsComment());
1083 :
1084 0 : utl::SearchParam aSearchParam( m_pEdComment->GetText(),
1085 0 : utl::SearchParam::SRCH_REGEXP,sal_False,sal_False,sal_False );
1086 :
1087 0 : pRedlinTable->SetCommentParams(&aSearchParam);
1088 :
1089 0 : pRedlinTable->UpdateFilterTest();
1090 : }
1091 :
1092 0 : aReadyLink.Call(this);
1093 : }
1094 0 : bModified=sal_False;
1095 0 : TabPage::DeactivatePage();
1096 0 : }
1097 :
1098 0 : void SvxTPFilter::Enable( bool bEnable, bool bChild)
1099 : {
1100 0 : TabPage::Enable(bEnable,bChild);
1101 0 : if(m_pCbDate->IsEnabled())
1102 : {
1103 0 : RowEnableHdl(m_pCbDate);
1104 0 : RowEnableHdl(m_pCbAuthor);
1105 0 : RowEnableHdl(m_pCbRange);
1106 0 : RowEnableHdl(m_pCbComment);
1107 : }
1108 0 : }
1109 0 : void SvxTPFilter::Disable( bool bChild)
1110 : {
1111 0 : Enable( false, bChild );
1112 0 : }
1113 :
1114 0 : IMPL_LINK( SvxTPFilter, ModifyDate, void*,pTF)
1115 : {
1116 :
1117 0 : Date aDate( Date::SYSTEM );
1118 0 : Time aTime(0);
1119 0 : if (m_pDfDate==pTF)
1120 : {
1121 0 : if(m_pDfDate->GetText().isEmpty())
1122 0 : m_pDfDate->SetDate(aDate);
1123 :
1124 0 : if(pRedlinTable!=NULL)
1125 0 : pRedlinTable->SetFirstDate(m_pDfDate->GetDate());
1126 : }
1127 0 : else if (m_pDfDate2==pTF)
1128 : {
1129 0 : if(m_pDfDate2->GetText().isEmpty())
1130 0 : m_pDfDate2->SetDate(aDate);
1131 :
1132 0 : if(pRedlinTable!=NULL)
1133 0 : pRedlinTable->SetLastDate(m_pDfDate2->GetDate());
1134 : }
1135 0 : else if (m_pTfDate==pTF)
1136 : {
1137 0 : if(m_pTfDate->GetText().isEmpty())
1138 0 : m_pTfDate->SetTime(aTime);
1139 :
1140 0 : if(pRedlinTable!=NULL)
1141 0 : pRedlinTable->SetFirstTime(m_pTfDate->GetTime());
1142 : }
1143 0 : else if (m_pTfDate2==pTF)
1144 : {
1145 0 : if(m_pTfDate2->GetText().isEmpty())
1146 0 : m_pTfDate2->SetTime(aTime);
1147 :
1148 0 : if(pRedlinTable!=NULL)
1149 0 : pRedlinTable->SetLastTime(m_pTfDate2->GetTime());
1150 :
1151 : }
1152 0 : ModifyHdl(m_pDfDate);
1153 0 : return 0;
1154 : }
1155 :
1156 0 : IMPL_LINK( SvxTPFilter, RefHandle, PushButton*, pRef )
1157 : {
1158 0 : if(pRef!=NULL)
1159 : {
1160 0 : aRefLink.Call(this);
1161 : }
1162 0 : return 0;
1163 : }
1164 :
1165 : //============================================================================
1166 : // class SvxAcceptChgCtr
1167 : //----------------------------------------------------------------------------
1168 :
1169 0 : SvxAcceptChgCtr::SvxAcceptChgCtr(Window* pParent)
1170 0 : : TabControl(pParent, WB_TABSTOP | WB_DIALOGCONTROL)
1171 : {
1172 0 : m_pUIBuilder = new VclBuilder(this, getUIRootDir(), "svx/ui/redlinecontrol.ui", "RedlineControl");
1173 :
1174 0 : pTPFilter = new SvxTPFilter(this);
1175 0 : pTPView = new SvxTPView(this);
1176 :
1177 0 : m_nViewPageId = GetPageId("view");
1178 0 : m_nFilterPageId = GetPageId("filter");
1179 0 : SetTabPage(m_nViewPageId, pTPView);
1180 0 : SetTabPage(m_nFilterPageId, pTPFilter);
1181 :
1182 0 : pTPFilter->SetRedlinTable(GetViewTable());
1183 :
1184 0 : ShowViewPage();
1185 :
1186 0 : Show();
1187 0 : }
1188 :
1189 0 : SvxAcceptChgCtr::~SvxAcceptChgCtr()
1190 : {
1191 0 : delete pTPView;
1192 0 : delete pTPFilter;
1193 0 : }
1194 :
1195 0 : void SvxAcceptChgCtr::ShowFilterPage()
1196 : {
1197 0 : SetCurPageId(m_nFilterPageId);
1198 0 : }
1199 :
1200 0 : void SvxAcceptChgCtr::ShowViewPage()
1201 : {
1202 0 : SetCurPageId(m_nViewPageId);
1203 0 : }
1204 :
1205 0 : SvxTPFilter* SvxAcceptChgCtr::GetFilterPage()
1206 : {
1207 0 : return pTPFilter;
1208 : }
1209 :
1210 0 : SvxTPView* SvxAcceptChgCtr::GetViewPage()
1211 : {
1212 0 : return pTPView;
1213 : }
1214 :
1215 0 : SvxRedlinTable* SvxAcceptChgCtr::GetViewTable()
1216 : {
1217 0 : return pTPView ? pTPView->GetTableControl() : NULL;
1218 216 : }
1219 :
1220 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|