xref: /trunk/main/sc/source/ui/miscdlgs/acredlin.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 // System - Includes ---------------------------------------------------------
32 
33 
34 
35 #include <svl/undo.hxx>
36 #include <unotools/textsearch.hxx>
37 #include <unotools/localedatawrapper.hxx>
38 #include <unotools/collatorwrapper.hxx>
39 #include <vcl/msgbox.hxx>
40 #include <sfx2/app.hxx>
41 #include <sfx2/viewfrm.hxx>
42 
43 // INCLUDE -------------------------------------------------------------------
44 
45 #include "acredlin.hxx"
46 #include "global.hxx"
47 #include "reffact.hxx"
48 #include "document.hxx"
49 #include "docsh.hxx"
50 #include "scresid.hxx"
51 #include "globstr.hrc"
52 #include "acredlin.hrc"
53 #include "simpref.hxx"
54 #include "scmod.hxx"
55 #include "popmenu.hxx"
56 #include "tabvwsh.hxx"
57 
58 // defines -------------------------------------------------------------------
59 
60 #define ABS_SREF          SCA_VALID \
61                         | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
62 #define ABS_DREF          ABS_SREF \
63                         | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
64 #define ABS_SREF3D      ABS_SREF | SCA_TAB_3D
65 #define ABS_DREF3D      ABS_DREF | SCA_TAB_3D
66 
67 
68 
69 #define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
70 
71 inline void EnableDisable( Window& rWin, sal_Bool bEnable )
72 {
73     if (bEnable)
74         rWin.Enable();
75     else
76         rWin.Disable();
77 }
78 
79 #define RD_SPECIAL_NONE         0
80 #define RD_SPECIAL_CONTENT      1
81 #define RD_SPECIAL_VISCONTENT   2
82 
83 //============================================================================
84 //  class ScRedlinData
85 //----------------------------------------------------------------------------
86 
87 ScRedlinData::ScRedlinData()
88     :RedlinData()
89 {
90     nInfo=RD_SPECIAL_NONE;
91     nActionNo=0;
92     pData=NULL;
93     bDisabled=sal_False;
94     bIsRejectable=sal_False;
95     bIsAcceptable=sal_False;
96     nTable=SCTAB_MAX;
97     nCol=SCCOL_MAX;
98     nRow=SCROW_MAX;
99 }
100 
101 ScRedlinData::~ScRedlinData()
102 {
103     nInfo=RD_SPECIAL_NONE;
104     nActionNo=0;
105     pData=NULL;
106     bDisabled=sal_False;
107     bIsRejectable=sal_False;
108     bIsAcceptable=sal_False;
109 }
110 
111 
112 //============================================================================
113 //  class ScAcceptChgDlg
114 //----------------------------------------------------------------------------
115 ScAcceptChgDlg::ScAcceptChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
116                       ScViewData*       ptrViewData)
117 
118     :   SfxModelessDialog( pB, pCW, pParent, ScResId(RID_SCDLG_CHANGES) ),
119         //
120         aAcceptChgCtr           ( this, ScResId( CTR_REDLINING ) ),
121         //
122         pViewData       ( ptrViewData ),
123         pDoc            ( ptrViewData->GetDocument() ),
124         aLocalRangeName ( *(pDoc->GetRangeName()) ),
125         //
126         aStrInsertCols          ( ScResId( STR_INSERT_COLS)),
127         aStrInsertRows          ( ScResId( STR_INSERT_ROWS)),
128         aStrInsertTabs          ( ScResId( STR_INSERT_TABS)),
129         aStrDeleteCols          ( ScResId( STR_DELETE_COLS)),
130         aStrDeleteRows          ( ScResId( STR_DELETE_ROWS)),
131         aStrDeleteTabs          ( ScResId( STR_DELETE_TABS)),
132         aStrMove                ( ScResId( STR_MOVE     )),
133         aStrContent             ( ScResId( STR_CONTENT  )),
134         aStrReject              ( ScResId( STR_REJECT       )),
135         aStrAllAccepted         ( ScResId( STR_ACCEPTED )),
136         aStrAllRejected         ( ScResId( STR_REJECTED )),
137         aStrNoEntry             ( ScResId( STR_NO_ENTRY   )),
138         aStrContentWithChild    ( ScResId( STR_CONTENT_WITH_CHILD)),
139         aStrChildContent        ( ScResId( STR_CHILD_CONTENT)),
140         aStrChildOrgContent     ( ScResId( STR_CHILD_ORGCONTENT)),
141         aStrEmpty               ( ScResId( STR_EMPTY        ))
142 {
143     FreeResource();
144 //  bScAcceptChgDlgIsDead=sal_False;
145     bNoSelection=sal_False;
146     bNeedsUpdate=sal_False;
147     bIgnoreMsg=sal_False;
148     nAcceptCount=0;
149     nRejectCount=0;
150     bAcceptEnableFlag=sal_True;
151     bRejectEnableFlag=sal_True;
152     bHasFilterEntry=sal_False;
153     bUseColor=sal_False;
154     aReOpenTimer.SetTimeout(50);
155     aReOpenTimer.SetTimeoutHdl(LINK( this, ScAcceptChgDlg, ReOpenTimerHdl ));
156 
157     //  dialog is now only hidden, not deleted, on switching views,
158     //  so there's no need to restore settings when reopening
159 
160     MinSize=aAcceptChgCtr.GetMinSizePixel();
161     MinSize.Height()+=2;
162     MinSize.Width()+=2;
163     SetMinOutputSizePixel(MinSize);
164     aUnknown.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Unknown"));
165 
166     pTPFilter=aAcceptChgCtr.GetFilterPage();
167     pTPView=aAcceptChgCtr.GetViewPage();
168     pTheView=pTPView->GetTableControl();
169     aSelectionTimer.SetTimeout(100);
170     aSelectionTimer.SetTimeoutHdl(LINK( this, ScAcceptChgDlg, UpdateSelectionHdl ));
171 
172     pTPFilter->SetReadyHdl(LINK( this, ScAcceptChgDlg, FilterHandle ));
173     pTPFilter->SetRefHdl(LINK( this, ScAcceptChgDlg, RefHandle ));
174     pTPFilter->SetModifyHdl(LINK( this, ScAcceptChgDlg, FilterModified));
175     pTPFilter->HideRange(sal_False);
176     pTPView->InsertCalcHeader();
177     pTPView->SetRejectClickHdl( LINK( this, ScAcceptChgDlg,RejectHandle));
178     pTPView->SetAcceptClickHdl( LINK(this, ScAcceptChgDlg, AcceptHandle));
179     pTPView->SetRejectAllClickHdl( LINK( this, ScAcceptChgDlg,RejectAllHandle));
180     pTPView->SetAcceptAllClickHdl( LINK(this, ScAcceptChgDlg, AcceptAllHandle));
181     pTheView->SetCalcView();
182     pTheView->SetStyle(pTheView->GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
183     pTheView->SetExpandingHdl( LINK(this, ScAcceptChgDlg, ExpandingHandle));
184     pTheView->SetSelectHdl( LINK(this, ScAcceptChgDlg, SelectHandle));
185     pTheView->SetDeselectHdl( LINK(this, ScAcceptChgDlg, SelectHandle));
186     pTheView->SetCommandHdl( LINK(this, ScAcceptChgDlg, CommandHdl));
187     pTheView->SetColCompareHdl( LINK(this, ScAcceptChgDlg,ColCompareHdl));
188     pTheView->SetSelectionMode(MULTIPLE_SELECTION);
189     pTheView->SetHighlightRange(1);
190 
191     Init();
192 
193     aAcceptChgCtr.SetMinSizeHdl( LINK( this, ScAcceptChgDlg, MinSizeHandle ));
194 
195     UpdateView();
196     SvLBoxEntry* pEntry=pTheView->First();
197     if(pEntry!=NULL)
198     {
199         pTheView->Select(pEntry);
200     }
201 }
202 ScAcceptChgDlg::~ScAcceptChgDlg()
203 {
204 //  bScAcceptChgDlgIsDead=sal_True;
205     ClearView();
206     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
207 
208     if(pChanges!=NULL)
209     {
210         Link aLink;
211         pChanges->SetModifiedLink(aLink);
212     }
213 }
214 
215 void ScAcceptChgDlg::ReInit(ScViewData* ptrViewData)
216 {
217     pViewData=ptrViewData;
218     if(pViewData!=NULL)
219     {
220         pDoc=ptrViewData->GetDocument();
221     }
222     else
223     {
224         pDoc=NULL;
225     }
226 
227     bNoSelection=sal_False;
228     bNeedsUpdate=sal_False;
229     bIgnoreMsg=sal_False;
230     nAcceptCount=0;
231     nRejectCount=0;
232     bAcceptEnableFlag=sal_True;
233     bRejectEnableFlag=sal_True;
234 
235     //  #91781# don't call Init here (switching between views), just set link below
236     //  (dialog is just hidden, not deleted anymore, when switching views)
237     ClearView();
238     UpdateView();
239 
240     if ( pDoc )
241     {
242         ScChangeTrack* pChanges = pDoc->GetChangeTrack();
243         if ( pChanges )
244             pChanges->SetModifiedLink( LINK( this, ScAcceptChgDlg, ChgTrackModHdl ) );
245     }
246 }
247 
248 void __EXPORT ScAcceptChgDlg::Init()
249 {
250     String  aAreaStr;
251     ScRange aRange;
252 
253     DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
254 
255     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
256 
257     if(pChanges!=NULL)
258     {
259         pChanges->SetModifiedLink( LINK( this, ScAcceptChgDlg,ChgTrackModHdl));
260         aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser());
261         pTPFilter->ClearAuthors();
262         ScStrCollection aUserColl=pChanges->GetUserCollection();
263         for(sal_uInt16  i=0;i<aUserColl.GetCount();i++)
264             pTPFilter->InsertAuthor(aUserColl[i]->GetString());
265     }
266 
267     ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings();
268     if ( pViewSettings!=NULL )
269         aChangeViewSet = *pViewSettings;
270     // adjust TimeField for filter tabpage
271     aChangeViewSet.AdjustDateMode( *pDoc );
272 
273     pTPFilter->CheckDate(aChangeViewSet.HasDate());
274     pTPFilter->SetFirstDate(aChangeViewSet.GetTheFirstDateTime());
275     pTPFilter->SetFirstTime(aChangeViewSet.GetTheFirstDateTime());
276     pTPFilter->SetLastDate(aChangeViewSet.GetTheLastDateTime());
277     pTPFilter->SetLastTime(aChangeViewSet.GetTheLastDateTime());
278     pTPFilter->SetDateMode((sal_uInt16)aChangeViewSet.GetTheDateMode());
279     pTPFilter->CheckComment(aChangeViewSet.HasComment());
280     pTPFilter->SetComment(aChangeViewSet.GetTheComment());
281 
282     pTPFilter->CheckAuthor(aChangeViewSet.HasAuthor());
283     String aString=aChangeViewSet.GetTheAuthorToShow();
284     if(aString.Len()!=0)
285     {
286         pTPFilter->SelectAuthor(aString);
287         if(pTPFilter->GetSelectedAuthor()!=aString)
288         {
289             pTPFilter->InsertAuthor(aString);
290             pTPFilter->SelectAuthor(aString);
291         }
292     }
293     else
294     {
295         pTPFilter->SelectedAuthorPos(0);
296     }
297 
298     pTPFilter->CheckRange(aChangeViewSet.HasRange());
299 
300     ScRange* pRangeEntry=aChangeViewSet.GetTheRangeList().GetObject(0);
301     aRangeList=aChangeViewSet.GetTheRangeList();
302 
303     if(pRangeEntry!=NULL)
304     {
305         String aRefStr;
306         pRangeEntry->Format( aRefStr, ABS_DREF3D, pDoc );
307         pTPFilter->SetRange(aRefStr);
308     }
309 
310     Point aPoint(1,1);
311     aAcceptChgCtr.SetPosPixel(aPoint);
312     InitFilter();
313 }
314 
315 
316 
317 void ScAcceptChgDlg::ClearView()
318 {
319     nAcceptCount=0;
320     nRejectCount=0;
321     pTheView->SetUpdateMode(sal_False);
322 
323     pTheView->Clear();
324     pTheView->SetUpdateMode(sal_True);
325 }
326 
327 String* ScAcceptChgDlg::MakeTypeString(ScChangeActionType eType)
328 {
329     String* pStr;
330 
331     switch(eType)
332     {
333 
334         case SC_CAT_INSERT_COLS:    pStr=&aStrInsertCols;break;
335 
336         case SC_CAT_INSERT_ROWS:    pStr=&aStrInsertRows;break;
337 
338         case SC_CAT_INSERT_TABS:    pStr=&aStrInsertTabs;break;
339 
340         case SC_CAT_DELETE_COLS:    pStr=&aStrDeleteCols;break;
341 
342         case SC_CAT_DELETE_ROWS:    pStr=&aStrDeleteRows;break;
343 
344         case SC_CAT_DELETE_TABS:    pStr=&aStrDeleteTabs;break;
345 
346         case SC_CAT_MOVE:           pStr=&aStrMove;break;
347 
348         case SC_CAT_CONTENT:        pStr=&aStrContent;break;
349 
350         case SC_CAT_REJECT:         pStr=&aStrReject;break;
351 
352         default:                    pStr=&aUnknown;break;
353     }
354     return pStr;
355 }
356 
357 
358 sal_Bool ScAcceptChgDlg::IsValidAction(const ScChangeAction* pScChangeAction)
359 {
360     if(pScChangeAction==NULL) return sal_False;
361 
362     sal_Bool bFlag=sal_False;
363 
364     ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
365     String aUser=pScChangeAction->GetUser();
366     DateTime aDateTime=pScChangeAction->GetDateTime();
367 
368     ScChangeActionType eType=pScChangeAction->GetType();
369     String aString;
370     String aDesc;
371 
372     String aComment=pScChangeAction->GetComment();
373     aComment.EraseAllChars('\n');
374 
375     if(eType==SC_CAT_CONTENT)
376     {
377         if(!pScChangeAction->IsDialogParent())
378         {
379             pScChangeAction->GetDescription( aDesc, pDoc, sal_True);
380         }
381     }
382     else
383     {
384         pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
385     }
386 
387     if(aDesc.Len()>0)
388     {
389         aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
390         aComment+=aDesc;
391         aComment+=')';
392     }
393 
394     if(pTheView->IsValidEntry(&aUser,&aDateTime,&aComment))
395     {
396         if(pTPFilter->IsRange())
397         {
398             ScRange* pRangeEntry=aRangeList.First();
399 
400             while(pRangeEntry!=NULL)
401             {
402                 if(pRangeEntry->Intersects(aRef)) break;
403                 pRangeEntry=aRangeList.Next();
404             }
405 
406             if(pRangeEntry!=NULL)
407             {
408                 bFlag=sal_True;
409             }
410         }
411         else
412         {
413             bFlag=sal_True;
414         }
415     }
416 
417     return bFlag;
418 }
419 
420 SvLBoxEntry* ScAcceptChgDlg::InsertChangeAction(const ScChangeAction* pScChangeAction,
421                                                    ScChangeActionState /* eState */, SvLBoxEntry* pParent,
422                                                    sal_Bool bDelMaster,sal_Bool bDisabled,sal_uLong nPos)
423 {
424     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
425 
426     if(pScChangeAction==NULL || pChanges==NULL) return NULL;
427 
428     SvLBoxEntry* pEntry=NULL;
429 
430     sal_Bool bFlag=sal_False;
431 
432     ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
433     String aUser=pScChangeAction->GetUser();
434     DateTime aDateTime=pScChangeAction->GetDateTime();
435 
436     String aRefStr;
437     ScChangeActionType eType=pScChangeAction->GetType();
438     String aString;
439     String aDesc;
440 
441     ScRedlinData* pNewData=new ScRedlinData;
442     pNewData->pData=(void *)pScChangeAction;
443     pNewData->nActionNo=pScChangeAction->GetActionNumber();
444     pNewData->bIsAcceptable=pScChangeAction->IsClickable();
445     pNewData->bIsRejectable=pScChangeAction->IsRejectable();
446     pNewData->bDisabled=!pNewData->bIsAcceptable | bDisabled;
447     pNewData->aDateTime=aDateTime;
448     pNewData->nRow  = aRef.aStart.Row();
449     pNewData->nCol  = aRef.aStart.Col();
450     pNewData->nTable= aRef.aStart.Tab();
451 
452     if(eType==SC_CAT_CONTENT)
453     {
454         if(pScChangeAction->IsDialogParent())
455         {
456             aString=aStrContentWithChild;
457             pNewData->nInfo=RD_SPECIAL_VISCONTENT;
458             pNewData->bIsRejectable=sal_False;
459             pNewData->bIsAcceptable=sal_False;
460         }
461         else
462         {
463             aString=*MakeTypeString(eType);
464             pScChangeAction->GetDescription( aDesc, pDoc, sal_True);
465         }
466     }
467     else
468     {
469         aString=*MakeTypeString(eType);
470 
471         if(bDelMaster)
472         {
473             pScChangeAction->GetDescription( aDesc, pDoc,sal_True);
474             pNewData->bDisabled=sal_True;
475             pNewData->bIsRejectable=sal_False;
476         }
477         else
478             pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
479 
480     }
481 
482     aString+='\t';
483     pScChangeAction->GetRefString(aRefStr, pDoc, sal_True);
484     aString+=aRefStr;
485     aString+='\t';
486 
487     sal_Bool bIsGenerated;
488 
489     if(!pChanges->IsGenerated(pScChangeAction->GetActionNumber()))
490     {
491         aString+=aUser;
492         aString+='\t';
493 
494         aString+=ScGlobal::pLocaleData->getDate(aDateTime);
495         aString+=' ';
496         aString+=ScGlobal::pLocaleData->getTime(aDateTime);
497         aString+='\t';
498         bIsGenerated=sal_False;
499     }
500     else
501     {
502         aString+='\t';
503         aString+='\t';
504         bIsGenerated=sal_True;
505     }
506 
507     String aComment=pScChangeAction->GetComment();
508     aComment.EraseAllChars('\n');
509     if(aDesc.Len()>0)
510     {
511         aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
512         aComment+=aDesc;
513         aComment+=')';
514     }
515 
516     aString+=aComment;
517 
518     if(pTheView->IsValidEntry(&aUser,&aDateTime)|| bIsGenerated)
519     {
520         if(pTheView->IsValidComment(&aComment))
521         {
522             if(pTPFilter->IsRange())
523             {
524                 ScRange* pRangeEntry=aRangeList.First();
525 
526                 while(pRangeEntry!=NULL)
527                 {
528                     if(pRangeEntry->Intersects(aRef)) break;
529                     pRangeEntry=aRangeList.Next();
530                 }
531                 //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
532                 if(pRangeEntry!=NULL)
533                 {
534                     bHasFilterEntry=sal_True;
535                     bFlag=sal_True;
536                 }
537             }
538             else if(!bIsGenerated)
539             {
540                 bHasFilterEntry=sal_True;
541                 bFlag=sal_True;
542             }
543         }
544     }
545 
546     if(!bFlag&& bUseColor&& pParent==NULL)
547     {
548         pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_LIGHTBLUE),pParent,nPos);
549     }
550     else if(bFlag&& bUseColor&& pParent!=NULL)
551     {
552         pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_GREEN),pParent,nPos);
553         SvLBoxEntry* pExpEntry=pParent;
554 
555         while(pExpEntry!=NULL && !pTheView->IsExpanded(pExpEntry))
556         {
557             SvLBoxEntry* pTmpEntry=pTheView->GetParent(pExpEntry);
558 
559             if(pTmpEntry!=NULL) pTheView->Expand(pExpEntry);
560 
561             pExpEntry=pTmpEntry;
562         }
563     }
564     else
565     {
566         pEntry=pTheView->InsertEntry(aString,pNewData,pParent,nPos);
567     }
568     return pEntry;
569 }
570 
571 SvLBoxEntry* ScAcceptChgDlg::InsertFilteredAction(const ScChangeAction* pScChangeAction,
572                                                    ScChangeActionState eState,SvLBoxEntry* pParent,
573                                                    sal_Bool bDelMaster,sal_Bool bDisabled,sal_uLong nPos)
574 {
575 
576     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
577 
578     if(pScChangeAction==NULL || pChanges==NULL) return NULL;
579 
580     sal_Bool bIsGenerated=pChanges->IsGenerated(pScChangeAction->GetActionNumber());
581 
582     SvLBoxEntry* pEntry=NULL;
583 
584     int bFlag=sal_False;
585 
586     ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
587     String aUser=pScChangeAction->GetUser();
588     DateTime aDateTime=pScChangeAction->GetDateTime();
589 
590     if(pTheView->IsValidEntry(&aUser,&aDateTime)||bIsGenerated)
591     {
592         if(pTPFilter->IsRange())
593         {
594             ScRange* pRangeEntry=aRangeList.First();
595 
596             while(pRangeEntry!=NULL)
597             {
598                 if(pRangeEntry->Intersects(aRef)) break;
599                 pRangeEntry=aRangeList.Next();
600             }
601             //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
602             if(pRangeEntry!=NULL &&
603                 pScChangeAction->GetState()==eState)
604             {
605                 bFlag=sal_True;
606             }
607         }
608         else if(pScChangeAction->GetState()==eState && !bIsGenerated)
609         {
610             bFlag=sal_True;
611         }
612     }
613 
614     if(bFlag)
615     {
616 
617         String aRefStr;
618         ScChangeActionType eType=pScChangeAction->GetType();
619         String aString;
620         String aDesc;
621 
622 
623         ScRedlinData* pNewData=new ScRedlinData;
624         pNewData->pData=(void *)pScChangeAction;
625         pNewData->nActionNo=pScChangeAction->GetActionNumber();
626         pNewData->bIsAcceptable=pScChangeAction->IsClickable();
627         pNewData->bIsRejectable=pScChangeAction->IsRejectable();
628         pNewData->bDisabled=!pNewData->bIsAcceptable | bDisabled;
629         pNewData->aDateTime=aDateTime;
630         pNewData->nRow  = aRef.aStart.Row();
631         pNewData->nCol  = aRef.aStart.Col();
632         pNewData->nTable= aRef.aStart.Tab();
633 
634         if(eType==SC_CAT_CONTENT)
635         {
636             if(pScChangeAction->IsDialogParent())
637             {
638                 aString=aStrContentWithChild;
639                 pNewData->nInfo=RD_SPECIAL_VISCONTENT;
640                 pNewData->bIsRejectable=sal_False;
641                 pNewData->bIsAcceptable=sal_False;
642             }
643             else
644             {
645                 aString=*MakeTypeString(eType);
646                 pScChangeAction->GetDescription( aDesc, pDoc, sal_True);
647             }
648         }
649         else
650         {
651             aString=*MakeTypeString(eType);
652 
653             if(bDelMaster)
654             {
655                 pScChangeAction->GetDescription( aDesc, pDoc,sal_True);
656                 pNewData->bDisabled=sal_True;
657                 pNewData->bIsRejectable=sal_False;
658             }
659             else
660                 pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
661 
662         }
663 
664         aString+='\t';
665         pScChangeAction->GetRefString(aRefStr, pDoc, sal_True);
666         aString+=aRefStr;
667         aString+='\t';
668 
669         if(!bIsGenerated)
670         {
671             aString+=aUser;
672             aString+='\t';
673             aString+=ScGlobal::pLocaleData->getDate(aDateTime);
674             aString+=' ';
675             aString+=ScGlobal::pLocaleData->getTime(aDateTime);
676             aString+='\t';
677         }
678         else
679         {
680             aString+='\t';
681             aString+='\t';
682         }
683 
684         String aComment=pScChangeAction->GetComment();
685         aComment.EraseAllChars('\n');
686         if(aDesc.Len()>0)
687         {
688             aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
689             aComment+=aDesc;
690             aComment+=')';
691         }
692         if(pTheView->IsValidComment(&aComment))
693         {
694             aString+=aComment;
695             pEntry=pTheView->InsertEntry(aString,pNewData,pParent,nPos);
696         }
697         else
698             delete pNewData;
699     }
700     return pEntry;
701 }
702 
703 SvLBoxEntry* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionContent* pScChangeAction,
704                                                           SvLBoxEntry* pParent, sal_uLong nSpecial)
705 {
706     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
707     SvLBoxEntry* pEntry=NULL;
708 
709     if(pScChangeAction==NULL || pChanges==NULL) return NULL;
710 
711     sal_Bool bIsGenerated=pChanges->IsGenerated(pScChangeAction->GetActionNumber());
712 
713     sal_Bool bFlag=sal_False;
714 
715     ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
716     String aUser=pScChangeAction->GetUser();
717     DateTime aDateTime=pScChangeAction->GetDateTime();
718 
719     if(pTheView->IsValidEntry(&aUser,&aDateTime)||bIsGenerated)
720     {
721         if(pTPFilter->IsRange())
722         {
723             ScRange* pRangeEntry=aRangeList.First();
724 
725             while(pRangeEntry!=NULL)
726             {
727                 if(pRangeEntry->Intersects(aRef)) break;
728                 pRangeEntry=aRangeList.Next();
729             }
730             //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
731             if(pRangeEntry!=NULL)
732             {
733                 bFlag=sal_True;
734             }
735         }
736         else if(!bIsGenerated)
737             bFlag=sal_True;
738     }
739 
740     String aRefStr;
741     String aString;
742     String a2String;
743     String aDesc;
744 
745     if(nSpecial==RD_SPECIAL_CONTENT)
746     {
747         pScChangeAction->GetOldString(a2String);
748         if(a2String.Len()==0) a2String=aStrEmpty;
749 
750         //aString+="\'";
751         aString+=a2String;
752         //aString+="\'";
753 
754         aDesc=aStrChildOrgContent;
755         aDesc.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
756     }
757     else
758     {
759         pScChangeAction->GetNewString(a2String);
760         if(a2String.Len()==0)
761         {
762             a2String=aStrEmpty;
763             aString+=a2String;
764         }
765         else
766         {
767             aString+='\'';
768             aString+=a2String;
769             aString+='\'';
770             a2String=aString;
771         }
772         aDesc=aStrChildContent;
773 
774     }
775 
776     aDesc+=a2String;
777     aString+='\t';
778     pScChangeAction->GetRefString(aRefStr, pDoc, sal_True);
779     aString+=aRefStr;
780     aString+='\t';
781 
782     if(!bIsGenerated)
783     {
784         aString+=aUser;
785         aString+='\t';
786 
787         aString+=ScGlobal::pLocaleData->getDate(aDateTime);
788         aString+=' ';
789         aString+=ScGlobal::pLocaleData->getTime(aDateTime);
790         aString+='\t';
791     }
792     else
793     {
794         aString+='\t';
795         aString+='\t';
796     }
797     String aComment=pScChangeAction->GetComment();
798     aComment.EraseAllChars('\n');
799 
800     if(aDesc.Len()>0)
801     {
802         aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
803         aComment+=aDesc;
804         aComment+=')';
805     }
806 
807     aString+=aComment;
808 
809     ScRedlinData* pNewData=new ScRedlinData;
810     pNewData->nInfo=nSpecial;
811     pNewData->pData=(void *)pScChangeAction;
812     pNewData->nActionNo=pScChangeAction->GetActionNumber();
813     pNewData->bIsAcceptable=pScChangeAction->IsClickable();
814     pNewData->bIsRejectable=sal_False;
815     pNewData->bDisabled=!pNewData->bIsAcceptable;
816     pNewData->aDateTime=aDateTime;
817     pNewData->nRow  = aRef.aStart.Row();
818     pNewData->nCol  = aRef.aStart.Col();
819     pNewData->nTable= aRef.aStart.Tab();
820 
821     if(pTheView->IsValidComment(&aComment) && bFlag)
822     {
823         bHasFilterEntry=sal_True;
824         pEntry=pTheView->InsertEntry(aString,pNewData,pParent);
825     }
826     else
827         pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_LIGHTBLUE),pParent);
828     return pEntry;
829 }
830 
831 long ScAcceptChgDlg::PreNotify( NotifyEvent& rNEvt )
832 {
833     if(rNEvt.GetType()==EVENT_GETFOCUS && bNeedsUpdate)
834     {
835         ClearView();
836         UpdateView();
837         bNoSelection=sal_False;
838     }
839 
840     return SfxModelessDialog::PreNotify(rNEvt);
841 }
842 
843 
844 void ScAcceptChgDlg::UpdateView()
845 {
846     bNeedsUpdate=sal_False;
847     DateTime aDateTime;
848     SvLBoxEntry* pParent=NULL;
849     ScChangeTrack* pChanges=NULL;
850     const ScChangeAction* pScChangeAction=NULL;
851     bAcceptEnableFlag=sal_True;
852     bRejectEnableFlag=sal_True;
853     SetPointer(Pointer(POINTER_WAIT));
854     pTheView->SetUpdateMode(sal_False);
855     sal_Bool bFilterFlag=pTPFilter->IsDate()||pTPFilter->IsRange()||
856                      pTPFilter->IsAuthor()||pTPFilter->IsComment();
857 
858     bUseColor=bFilterFlag;
859 
860     if(pDoc!=NULL)
861     {
862         pChanges=pDoc->GetChangeTrack();
863         if(pChanges!=NULL)
864         {
865             pScChangeAction=pChanges->GetFirst();
866         }
867     }
868     ScChangeActionTable ActionTable;
869     sal_Bool bTheFlag=sal_False;
870 
871     while(pScChangeAction!=NULL)
872     {
873         bHasFilterEntry=sal_False;
874         switch(pScChangeAction->GetState())
875         {
876             case SC_CAS_VIRGIN:
877 
878                 if(pScChangeAction->IsDialogRoot())
879                 {
880                     if(pScChangeAction->IsDialogParent())
881                         pParent=InsertChangeAction(pScChangeAction,SC_CAS_VIRGIN);
882                     else
883                         pParent=InsertFilteredAction(pScChangeAction,SC_CAS_VIRGIN);
884                 }
885                 else
886                     pParent=NULL;
887 
888                 bTheFlag=sal_True;
889                 break;
890 
891             case SC_CAS_ACCEPTED:
892                 pParent=NULL;
893                 nAcceptCount++;
894                 break;
895 
896             case SC_CAS_REJECTED:
897                 pParent=NULL;
898                 nRejectCount++;
899                 break;
900         }
901 
902         if(pParent!=NULL && pScChangeAction->IsDialogParent())
903         {
904             if(!bFilterFlag)
905             {
906                 pParent->EnableChildsOnDemand(sal_True);
907             }
908             else
909             {
910                 sal_Bool bTestFlag=bHasFilterEntry;
911                 bHasFilterEntry=sal_False;
912                 if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
913                     pTheView->RemoveEntry(pParent);
914             }
915         }
916 
917         pScChangeAction=pScChangeAction->GetNext();
918     }
919 
920     if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
921         bTheFlag=sal_False;
922 
923     pTPView->EnableAccept(bTheFlag);
924     pTPView->EnableAcceptAll(bTheFlag);
925     pTPView->EnableReject(bTheFlag);
926     pTPView->EnableRejectAll(bTheFlag);
927 
928     if(nAcceptCount>0)
929     {
930         pParent=pTheView->InsertEntry(
931             aStrAllAccepted, static_cast< RedlinData * >(NULL),
932             static_cast< SvLBoxEntry * >(NULL));
933         pParent->EnableChildsOnDemand(sal_True);
934     }
935     if(nRejectCount>0)
936     {
937         pParent=pTheView->InsertEntry(
938             aStrAllRejected, static_cast< RedlinData * >(NULL),
939             static_cast< SvLBoxEntry * >(NULL));
940         pParent->EnableChildsOnDemand(sal_True);
941     }
942     pTheView->SetUpdateMode(sal_True);
943     SetPointer(Pointer(POINTER_ARROW));
944     SvLBoxEntry* pEntry=pTheView->First();
945     if(pEntry!=NULL)
946     {
947         pTheView->Select(pEntry);
948     }
949 }
950 
951 //----------------------------------------------------------------------------
952 sal_Bool ScAcceptChgDlg::Close()
953 {
954     return SfxModelessDialog::Close();
955 }
956 
957 void ScAcceptChgDlg::Resize()
958 {
959     SfxModelessDialog::Resize();
960     Size aOutSize=GetOutputSizePixel();
961     aAcceptChgCtr.SetSizePixel(aOutSize);
962 }
963 
964 IMPL_LINK( ScAcceptChgDlg, MinSizeHandle, SvxAcceptChgCtr*, pCtr )
965 {
966     if(pCtr==&aAcceptChgCtr)
967     {
968         if(!IsRollUp())
969             SetOutputSizePixel(MinSize);
970     }
971     return 0;
972 }
973 
974 IMPL_LINK( ScAcceptChgDlg, RefHandle, SvxTPFilter*, EMPTYARG )
975 {
976     sal_uInt16 nId  =ScSimpleRefDlgWrapper::GetChildWindowId();
977 
978     ScSimpleRefDlgWrapper::SetDefaultPosSize(GetPosPixel(),GetSizePixel(),sal_True);
979 
980     SC_MOD()->SetRefDialog( nId, sal_True );
981 
982     SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
983     ScSimpleRefDlgWrapper* pWnd =(ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
984 
985     if(pWnd!=NULL)
986     {
987 //      bSimpleRefDlgStarted=sal_True;
988         sal_uInt16 nAcceptId=ScAcceptChgDlgWrapper::GetChildWindowId();
989         pViewFrm->ShowChildWindow(nAcceptId,sal_False);
990         pWnd->SetCloseHdl(LINK( this, ScAcceptChgDlg,RefInfoHandle));
991         pWnd->SetRefString(pTPFilter->GetRange());
992         pWnd->SetAutoReOpen(sal_False);
993         Window* pWin=pWnd->GetWindow();
994         pWin->SetPosSizePixel(GetPosPixel(),GetSizePixel());
995         Hide();
996         pWin->SetText(GetText());
997         pWnd->StartRefInput();
998     }
999     return 0;
1000 }
1001 
1002 IMPL_LINK( ScAcceptChgDlg, RefInfoHandle, String*, pResult)
1003 {
1004     sal_uInt16 nId;
1005 
1006 //  bSimpleRefDlgStarted=sal_False;
1007     ScSimpleRefDlgWrapper::SetAutoReOpen(sal_True);
1008 
1009     SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
1010     if(pResult!=NULL)
1011     {
1012         pTPFilter->SetRange(*pResult);
1013         FilterHandle(pTPFilter);
1014 
1015         nId = ScSimpleRefDlgWrapper::GetChildWindowId();
1016         ScSimpleRefDlgWrapper* pWnd = (ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
1017 
1018         if(pWnd!=NULL)
1019         {
1020             Window* pWin=pWnd->GetWindow();
1021             Size aWinSize=pWin->GetSizePixel();
1022             aWinSize.Width()=GetSizePixel().Width();
1023             SetPosSizePixel(pWin->GetPosPixel(),aWinSize);
1024             Invalidate();
1025         }
1026         nId = ScAcceptChgDlgWrapper::GetChildWindowId();
1027         pViewFrm->ShowChildWindow( nId, sal_True );
1028     }
1029     else
1030     {
1031         nId = ScAcceptChgDlgWrapper::GetChildWindowId();
1032         pViewFrm->SetChildWindow( nId, sal_False );
1033     }
1034     return 0;
1035 }
1036 
1037 IMPL_LINK( ScAcceptChgDlg, FilterHandle, SvxTPFilter*, pRef )
1038 {
1039     if(pRef!=NULL)
1040     {
1041         ClearView();
1042         aRangeList.Clear();
1043         aRangeList.Parse(pTPFilter->GetRange(),pDoc);
1044         UpdateView();
1045     }
1046     return 0;
1047 }
1048 
1049 IMPL_LINK( ScAcceptChgDlg, RejectHandle, SvxTPView*, pRef )
1050 {
1051     SetPointer(Pointer(POINTER_WAIT));
1052 
1053     bIgnoreMsg=sal_True;
1054     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1055 
1056     if(pRef!=NULL)
1057     {
1058         SvLBoxEntry* pEntry=pTheView->FirstSelected();
1059         while(pEntry!=NULL)
1060         {
1061             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1062             if(pEntryData!=NULL)
1063             {
1064                 ScChangeAction* pScChangeAction=
1065                         (ScChangeAction*) pEntryData->pData;
1066 
1067                 if(pScChangeAction->GetType()==SC_CAT_INSERT_TABS)
1068                 {
1069                     pViewData->SetTabNo(0);
1070                 }
1071                 pChanges->Reject(pScChangeAction);
1072             }
1073             pEntry = pTheView->NextSelected(pEntry);
1074         }
1075         ScDocShell* pDocSh=pViewData->GetDocShell();
1076         pDocSh->PostPaintExtras();
1077         pDocSh->PostPaintGridAll();
1078         pDocSh->GetUndoManager()->Clear();
1079         pDocSh->SetDocumentModified();
1080         ClearView();
1081         UpdateView();
1082     }
1083     SetPointer(Pointer(POINTER_ARROW));
1084 
1085     bIgnoreMsg=sal_False;
1086     return 0;
1087 }
1088 IMPL_LINK( ScAcceptChgDlg, AcceptHandle, SvxTPView*, pRef )
1089 {
1090     SetPointer(Pointer(POINTER_WAIT));
1091 
1092     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1093     bIgnoreMsg=sal_True;
1094     if(pRef!=NULL)
1095     {
1096         SvLBoxEntry* pEntry=pTheView->FirstSelected();
1097         while(pEntry!=NULL)
1098         {
1099             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1100             if(pEntryData!=NULL)
1101             {
1102                 ScChangeAction* pScChangeAction=
1103                         (ScChangeAction*) pEntryData->pData;
1104                 if(pScChangeAction->GetType()==SC_CAT_CONTENT)
1105                 {
1106                     if(pEntryData->nInfo==RD_SPECIAL_CONTENT)
1107                     {
1108                         pChanges->SelectContent(pScChangeAction,sal_True);
1109                     }
1110                     else
1111                     {
1112                         pChanges->SelectContent(pScChangeAction);
1113                     }
1114                 }
1115                 else
1116                     pChanges->Accept(pScChangeAction);
1117             }
1118             pEntry = pTheView->NextSelected(pEntry);
1119         }
1120         ScDocShell* pDocSh=pViewData->GetDocShell();
1121         pDocSh->PostPaintExtras();
1122         pDocSh->PostPaintGridAll();
1123         pDocSh->SetDocumentModified();
1124         ClearView();
1125         UpdateView();
1126     }
1127     bIgnoreMsg=sal_False;
1128 
1129     return 0;
1130 }
1131 
1132 void ScAcceptChgDlg::RejectFiltered()
1133 {
1134     if(pDoc==NULL) return;
1135     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1136     const ScChangeAction* pScChangeAction=NULL;
1137 
1138     if(pChanges!=NULL)
1139     {
1140         pScChangeAction=pChanges->GetLast();
1141     }
1142 
1143     while(pScChangeAction!=NULL)
1144     {
1145         if(pScChangeAction->IsDialogRoot())
1146         {
1147             if(IsValidAction(pScChangeAction))
1148             {
1149                 pChanges->Reject((ScChangeAction*)pScChangeAction);
1150             }
1151         }
1152         pScChangeAction=pScChangeAction->GetPrev();
1153     }
1154 }
1155 void ScAcceptChgDlg::AcceptFiltered()
1156 {
1157     if(pDoc==NULL) return;
1158     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1159     const ScChangeAction* pScChangeAction=NULL;
1160 
1161     if(pChanges!=NULL)
1162     {
1163         pScChangeAction=pChanges->GetLast();
1164     }
1165 
1166     while(pScChangeAction!=NULL)
1167     {
1168         if(pScChangeAction->IsDialogRoot())
1169         {
1170             if(IsValidAction(pScChangeAction))
1171             {
1172                 pChanges->Accept((ScChangeAction*)pScChangeAction);
1173             }
1174         }
1175         pScChangeAction=pScChangeAction->GetPrev();
1176     }
1177 }
1178 
1179 IMPL_LINK( ScAcceptChgDlg, RejectAllHandle, SvxTPView*, EMPTYARG )
1180 {
1181     SetPointer(Pointer(POINTER_WAIT));
1182     bIgnoreMsg=sal_True;
1183     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1184     if(pChanges!=NULL)
1185     {
1186         if(pTPFilter->IsDate()||pTPFilter->IsAuthor()||pTPFilter->IsRange()||pTPFilter->IsComment())
1187         {
1188             RejectFiltered();
1189         }
1190         else
1191         {
1192             pChanges->RejectAll();
1193         }
1194         pViewData->SetTabNo(0);
1195 
1196         ScDocShell* pDocSh=pViewData->GetDocShell();
1197         pDocSh->PostPaintExtras();
1198         pDocSh->PostPaintGridAll();
1199         pDocSh->GetUndoManager()->Clear();
1200         pDocSh->SetDocumentModified();
1201         ClearView();
1202         UpdateView();
1203     }
1204     SetPointer(Pointer(POINTER_ARROW));
1205 
1206     bIgnoreMsg=sal_False;
1207 
1208     return 0;
1209 }
1210 
1211 IMPL_LINK( ScAcceptChgDlg, AcceptAllHandle, SvxTPView*, EMPTYARG )
1212 {
1213     SetPointer(Pointer(POINTER_WAIT));
1214 
1215     bIgnoreMsg=sal_True;
1216     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1217     if(pChanges!=NULL)
1218     {
1219         if(pTPFilter->IsDate()||pTPFilter->IsAuthor()||pTPFilter->IsRange()||pTPFilter->IsComment())
1220         {
1221             AcceptFiltered();
1222         }
1223         else
1224         {
1225             pChanges->AcceptAll();
1226         }
1227         ScDocShell* pDocSh=pViewData->GetDocShell();
1228         pDocSh->PostPaintExtras();
1229         pDocSh->PostPaintGridAll();
1230         pDocSh->SetDocumentModified();
1231         ClearView();
1232         UpdateView();
1233     }
1234     bIgnoreMsg=sal_False;
1235     SetPointer(Pointer(POINTER_ARROW));
1236 
1237     return 0;
1238 }
1239 
1240 IMPL_LINK( ScAcceptChgDlg, SelectHandle, SvxRedlinTable*, EMPTYARG )
1241 {
1242     if(!bNoSelection)
1243     {
1244         aSelectionTimer.Start();
1245     }
1246     bNoSelection=sal_False;
1247     return 0;
1248 }
1249 
1250 void ScAcceptChgDlg::GetDependents(  const ScChangeAction* pScChangeAction,
1251                                     ScChangeActionTable& aActionTable,
1252                                     SvLBoxEntry* pEntry)
1253 {
1254     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1255 
1256     SvLBoxEntry* pParent=pTheView->GetParent(pEntry);
1257     if(pParent!=NULL)
1258     {
1259         ScRedlinData *pParentData=(ScRedlinData *)(pParent->GetUserData());
1260         ScChangeAction* pParentAction=(ScChangeAction*) pParentData->pData;
1261         if(pParentAction!=pScChangeAction)
1262         {
1263             pChanges->GetDependents((ScChangeAction*) pScChangeAction,
1264                         aActionTable,pScChangeAction->IsMasterDelete());
1265         }
1266         else
1267         {
1268             pChanges->GetDependents((ScChangeAction*) pScChangeAction,
1269                         aActionTable);
1270         }
1271     }
1272     else
1273     {
1274         pChanges->GetDependents((ScChangeAction*) pScChangeAction,
1275                     aActionTable,pScChangeAction->IsMasterDelete());
1276     }
1277 }
1278 
1279 sal_Bool ScAcceptChgDlg::InsertContentChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
1280 {
1281     sal_Bool bTheTestFlag=sal_True;
1282     ScRedlinData *pEntryData=(ScRedlinData *)(pParent->GetUserData());
1283     const ScChangeAction* pScChangeAction = (ScChangeAction*) pEntryData->pData;
1284     sal_Bool bParentInserted = sal_False;
1285     // If the parent is a MatrixOrigin then place it in the right order before
1286     // the MatrixReferences. Also if it is the first content change at this
1287     // position don't insert the first dependent MatrixReference as the special
1288     // content (original value) but insert the predecessor of the MatrixOrigin
1289     // itself instead.
1290     if ( pScChangeAction->GetType() == SC_CAT_CONTENT &&
1291             ((const ScChangeActionContent*)pScChangeAction)->IsMatrixOrigin() )
1292     {
1293         pActionTable->Insert( pScChangeAction->GetActionNumber(),
1294             (ScChangeAction*) pScChangeAction );
1295         bParentInserted = sal_True;
1296     }
1297     SvLBoxEntry* pEntry=NULL;
1298 
1299     const ScChangeActionContent* pCChild=(const ScChangeActionContent*)pActionTable->First();
1300     while(pCChild!=NULL)
1301     {
1302         if( pCChild->GetState()==SC_CAS_VIRGIN )
1303             break;
1304         pCChild=(const ScChangeActionContent*)pActionTable->Next();
1305     }
1306 
1307     if(pCChild==NULL) return sal_True;
1308 
1309     SvLBoxEntry* pOriginal=InsertChangeActionContent(pCChild,pParent,RD_SPECIAL_CONTENT);
1310     if(pOriginal!=NULL)
1311     {
1312         bTheTestFlag=sal_False;
1313         ScRedlinData *pParentData=(ScRedlinData *)(pOriginal->GetUserData());
1314         pParentData->pData=(void *)pScChangeAction;
1315         pParentData->nActionNo=pScChangeAction->GetActionNumber();
1316         pParentData->bIsAcceptable=pScChangeAction->IsRejectable(); // select old value
1317         pParentData->bIsRejectable=sal_False;
1318         pParentData->bDisabled=sal_False;
1319     }
1320     while(pCChild!=NULL)
1321     {
1322         if(pCChild->GetState()==SC_CAS_VIRGIN)
1323         {
1324             pEntry=InsertChangeActionContent(pCChild,pParent,RD_SPECIAL_NONE);
1325 
1326             if(pEntry!=NULL)
1327                 bTheTestFlag=sal_False;
1328         }
1329         pCChild=(const ScChangeActionContent*)pActionTable->Next();
1330     }
1331 
1332     if ( !bParentInserted )
1333     {
1334         pEntry=InsertChangeActionContent((const ScChangeActionContent*)
1335                                 pScChangeAction,pParent,RD_SPECIAL_NONE);
1336 
1337         if(pEntry!=NULL)
1338         {
1339             bTheTestFlag=sal_False;
1340             ScRedlinData *pParentData=(ScRedlinData *)(pEntry->GetUserData());
1341             pParentData->pData=(void *)pScChangeAction;
1342             pParentData->nActionNo=pScChangeAction->GetActionNumber();
1343             pParentData->bIsAcceptable=pScChangeAction->IsClickable();
1344             pParentData->bIsRejectable=sal_False;
1345             pParentData->bDisabled=sal_False;
1346         }
1347     }
1348 
1349     return bTheTestFlag;
1350 
1351 }
1352 
1353 sal_Bool ScAcceptChgDlg::InsertAcceptedORejected(SvLBoxEntry* pParent)
1354 {
1355     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1356     sal_Bool bTheTestFlag=sal_True;
1357 
1358     ScChangeActionState eState = SC_CAS_VIRGIN;
1359     String aString=pTheView->GetEntryText( pParent);
1360     String a2String=aString.Copy(0,aStrAllAccepted.Len());
1361     if(a2String==aStrAllAccepted)
1362     {
1363         eState=SC_CAS_ACCEPTED;
1364     }
1365     else
1366     {
1367         a2String=aString.Copy(0,aStrAllRejected.Len());
1368         if(a2String==aStrAllRejected)
1369         {
1370             eState=SC_CAS_REJECTED;
1371         }
1372     }
1373 
1374     ScChangeAction* pScChangeAction=pChanges->GetFirst();
1375     while(pScChangeAction!=NULL)
1376     {
1377         if(pScChangeAction->GetState()==eState &&
1378             InsertFilteredAction(pScChangeAction,eState,pParent)!=NULL)
1379             bTheTestFlag=sal_False;
1380         pScChangeAction=pScChangeAction->GetNext();
1381     }
1382     return bTheTestFlag;
1383 }
1384 
1385 sal_Bool ScAcceptChgDlg::InsertChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
1386 {
1387     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1388     sal_Bool bTheTestFlag=sal_True;
1389     SvLBoxEntry* pEntry=NULL;
1390     const ScChangeAction* pChild=(const ScChangeAction*)pActionTable->First();
1391     while(pChild!=NULL)
1392     {
1393         pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,sal_False,sal_True);
1394 
1395         if(pEntry!=NULL)
1396         {
1397             bTheTestFlag=sal_False;
1398 
1399             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1400             pEntryData->bIsRejectable=sal_False;
1401             pEntryData->bIsAcceptable=sal_False;
1402             pEntryData->bDisabled=sal_True;
1403 
1404             if(pChild->IsDialogParent())
1405             {
1406 
1407                 //pEntry->EnableChildsOnDemand(sal_True);
1408                 Expand(pChanges,pChild,pEntry);
1409             }
1410         }
1411         pChild=pActionTable->Next();
1412     }
1413     return bTheTestFlag;
1414 }
1415 sal_Bool ScAcceptChgDlg::InsertDeletedChilds(const ScChangeAction* pScChangeAction,
1416                                          ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
1417 {
1418     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1419     sal_Bool bTheTestFlag=sal_True;
1420     SvLBoxEntry* pEntry=NULL;
1421     ScChangeActionTable aDelActionTable;
1422     const ScChangeAction* pChild=(const ScChangeAction*)pActionTable->First();
1423 
1424     while(pChild!=NULL)
1425     {
1426 
1427         if(pScChangeAction!=pChild)
1428             pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,sal_False,sal_True);
1429         else
1430             pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,sal_True,sal_True);
1431 
1432         if(pEntry!=NULL)
1433         {
1434             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1435             pEntryData->bIsRejectable=sal_False;
1436             pEntryData->bIsAcceptable=sal_False;
1437             pEntryData->bDisabled=sal_True;
1438 
1439             bTheTestFlag=sal_False;
1440             if ( pChild->IsDialogParent() )
1441             {
1442                 Expand(pChanges,pChild,pEntry);
1443                 /*
1444                 pChanges->GetDependents((ScChangeAction*) pChild,aDelActionTable);
1445                 if(aDelActionTable.First()!=NULL)
1446                 {
1447                     pEntry->EnableChildsOnDemand(sal_True);
1448                 }
1449                 aDelActionTable.Clear();
1450                 */
1451             }
1452         }
1453         pChild=pActionTable->Next();
1454     }
1455     return bTheTestFlag;
1456 }
1457 
1458 sal_Bool ScAcceptChgDlg::Expand(ScChangeTrack* pChanges,const ScChangeAction* pScChangeAction,
1459                             SvLBoxEntry* pEntry,sal_Bool bFilter)
1460 {
1461     sal_Bool bTheTestFlag=sal_True;
1462 
1463     if(pChanges!=NULL &&pEntry!=NULL &&pScChangeAction!=NULL)
1464     {
1465         ScChangeActionTable aActionTable;
1466 
1467         GetDependents( pScChangeAction,aActionTable,pEntry);
1468 
1469         switch(pScChangeAction->GetType())
1470         {
1471             case SC_CAT_CONTENT:
1472             {
1473                 InsertContentChilds(&aActionTable,pEntry);
1474                 bTheTestFlag=!bHasFilterEntry;
1475                 break;
1476             }
1477             case SC_CAT_DELETE_COLS:
1478             case SC_CAT_DELETE_ROWS:
1479             case SC_CAT_DELETE_TABS:
1480             {
1481                 InsertDeletedChilds(pScChangeAction,&aActionTable,pEntry);
1482                 bTheTestFlag=!bHasFilterEntry;
1483                 break;
1484             }
1485             default:
1486             {
1487                 if(!bFilter)
1488                     bTheTestFlag=InsertChilds(&aActionTable,pEntry);
1489                 break;
1490             }
1491         }
1492         aActionTable.Clear();
1493     }
1494     return bTheTestFlag;
1495 }
1496 
1497 IMPL_LINK( ScAcceptChgDlg, ExpandingHandle, SvxRedlinTable*, pTable )
1498 {
1499     ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1500     ScChangeAction* pScChangeAction=NULL;
1501     SetPointer(Pointer(POINTER_WAIT));
1502     if(pTable!=NULL && pChanges!=NULL)
1503     {
1504         ScChangeActionTable aActionTable;
1505         SvLBoxEntry* pEntry=pTheView->GetHdlEntry();
1506         if(pEntry!=NULL)
1507         {
1508             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1509             if(pEntryData!=NULL)
1510             {
1511                 pScChangeAction=(ScChangeAction*) pEntryData->pData;
1512             }
1513 
1514             if(pEntry->HasChildsOnDemand())
1515             {
1516                 sal_Bool bTheTestFlag=sal_True;
1517                 pEntry->EnableChildsOnDemand(sal_False);
1518                 pTheView->RemoveEntry(pTheView->FirstChild(pEntry));
1519 
1520                 if(pEntryData!=NULL)
1521                 {
1522                     pScChangeAction=(ScChangeAction*) pEntryData->pData;
1523 
1524                     GetDependents( pScChangeAction,aActionTable,pEntry);
1525 
1526                     switch(pScChangeAction->GetType())
1527                     {
1528                         case SC_CAT_CONTENT:
1529                         {
1530                             bTheTestFlag=InsertContentChilds(&aActionTable,pEntry);
1531                             break;
1532                         }
1533                         case SC_CAT_DELETE_COLS:
1534                         case SC_CAT_DELETE_ROWS:
1535                         case SC_CAT_DELETE_TABS:
1536                         {
1537                             bTheTestFlag=InsertDeletedChilds(pScChangeAction,&aActionTable,pEntry);
1538                             break;
1539                         }
1540                         default:
1541                         {
1542                             bTheTestFlag=InsertChilds(&aActionTable,pEntry);
1543                             break;
1544                         }
1545                     }
1546                     aActionTable.Clear();
1547 
1548                 }
1549                 else
1550                 {
1551                     bTheTestFlag=InsertAcceptedORejected(pEntry);
1552                 }
1553                 if(bTheTestFlag) pTheView->InsertEntry(aStrNoEntry,NULL,Color(COL_GRAY),pEntry);
1554             }
1555 
1556         }
1557     }
1558     SetPointer(Pointer(POINTER_ARROW));
1559     return (sal_uLong) sal_True;
1560 }
1561 
1562 
1563 void ScAcceptChgDlg::AppendChanges(ScChangeTrack* pChanges,sal_uLong nStartAction,
1564                                    sal_uLong nEndAction, sal_uLong /* nPos */)
1565 {
1566     if(pChanges!=NULL)
1567     {
1568         DateTime aDateTime;
1569         SvLBoxEntry* pParent=NULL;
1570         const ScChangeAction* pScChangeAction=NULL;
1571         bAcceptEnableFlag=sal_True;
1572         bRejectEnableFlag=sal_True;
1573         SetPointer(Pointer(POINTER_WAIT));
1574         pTheView->SetUpdateMode(sal_False);
1575 
1576         ScChangeActionTable ActionTable;
1577         sal_Bool bTheFlag=sal_False;
1578 
1579         sal_Bool bFilterFlag=pTPFilter->IsDate()||pTPFilter->IsRange()||
1580                      pTPFilter->IsAuthor()||pTPFilter->IsComment();
1581 
1582         bUseColor=bFilterFlag;
1583 
1584         for(sal_uLong i=nStartAction;i<=nEndAction;i++)
1585         {
1586             pScChangeAction=pChanges->GetAction(i);
1587             if(pScChangeAction==NULL) continue;
1588 
1589 
1590             switch(pScChangeAction->GetState())
1591             {
1592                 case SC_CAS_VIRGIN:
1593 
1594                     if(pScChangeAction->IsDialogRoot())
1595                     {
1596                         if(pScChangeAction->IsDialogParent())
1597                             pParent=InsertChangeAction(pScChangeAction,SC_CAS_VIRGIN);
1598                         else
1599                             pParent=InsertFilteredAction(pScChangeAction,SC_CAS_VIRGIN);
1600                     }
1601                     else
1602                         pParent=NULL;
1603 
1604                     bTheFlag=sal_True;
1605                     break;
1606 
1607                 case SC_CAS_ACCEPTED:
1608                     pParent=NULL;
1609                     nAcceptCount++;
1610                     break;
1611 
1612                 case SC_CAS_REJECTED:
1613                     pParent=NULL;
1614                     nRejectCount++;
1615                     break;
1616             }
1617 
1618             if(pParent!=NULL && pScChangeAction->IsDialogParent())
1619             {
1620                 if(!bFilterFlag)
1621                 {
1622                     pParent->EnableChildsOnDemand(sal_True);
1623                 }
1624                 else
1625                 {
1626                     sal_Bool bTestFlag=bHasFilterEntry;
1627                     bHasFilterEntry=sal_False;
1628                     if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
1629                         pTheView->RemoveEntry(pParent);
1630                 }
1631             }
1632 
1633             pScChangeAction=pScChangeAction->GetNext();
1634         }
1635 
1636         if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
1637             bTheFlag=sal_False;
1638 
1639         pTPView->EnableAccept(bTheFlag);
1640         pTPView->EnableAcceptAll(bTheFlag);
1641         pTPView->EnableReject(bTheFlag);
1642         pTPView->EnableRejectAll(bTheFlag);
1643 
1644         pTheView->SetUpdateMode(sal_True);
1645         SetPointer(Pointer(POINTER_ARROW));
1646     }
1647 }
1648 
1649 void ScAcceptChgDlg::RemoveEntrys(sal_uLong nStartAction,sal_uLong nEndAction)
1650 {
1651 
1652     pTheView->SetUpdateMode(sal_False);
1653 
1654     SvLBoxEntry* pEntry=pTheView->GetCurEntry();
1655 
1656     ScRedlinData *pEntryData=NULL;
1657 
1658     if(pEntry!=NULL)
1659         pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1660 
1661     sal_uLong nAction=0;
1662     if(pEntryData!=NULL)
1663     {
1664         nAction=pEntryData->nActionNo;
1665     }
1666 
1667     if(nAction>=nStartAction && nAction<=nEndAction)
1668     {
1669         pTheView->SetCurEntry(pTheView->GetModel()->GetEntry(0));
1670     }
1671 
1672     sal_Bool bRemove=sal_False;
1673 
1674     // MUST do it backwards, don't delete parents before children and GPF
1675     pEntry=pTheView->Last();
1676     while(pEntry!=NULL)
1677     {
1678         bRemove=sal_False;
1679         pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1680         if(pEntryData!=NULL)
1681         {
1682             nAction=pEntryData->nActionNo;
1683 
1684             if(nStartAction<=nAction && nAction<=nEndAction) bRemove=sal_True;
1685 
1686 
1687         }
1688         SvLBoxEntry* pPrevEntry = pTheView->Prev(pEntry);
1689 
1690         if(bRemove)
1691         {
1692             //delete pEntryData;
1693             pTheView->RemoveEntry(pEntry);
1694         }
1695         pEntry=pPrevEntry;
1696     }
1697     pTheView->SetUpdateMode(sal_True);
1698 
1699 }
1700 
1701 void ScAcceptChgDlg::UpdateEntrys(ScChangeTrack* pChgTrack, sal_uLong nStartAction,sal_uLong nEndAction)
1702 {
1703     pTheView->SetUpdateMode(sal_False);
1704 
1705     sal_uLong nPos=LIST_APPEND;
1706 
1707     sal_Bool bRemove=sal_False;
1708 
1709     SvLBoxEntry* pEntry=pTheView->First();
1710     SvLBoxEntry* pNextEntry = (pEntry ? pTheView->NextSibling(pEntry) : NULL);
1711     SvLBoxEntry* pLastEntry=NULL;
1712     while(pEntry!=NULL)
1713     {
1714         bRemove=sal_False;
1715         ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1716         if(pEntryData!=NULL)
1717         {
1718             ScChangeAction* pScChangeAction=
1719                     (ScChangeAction*) pEntryData->pData;
1720 
1721             sal_uLong nAction=pScChangeAction->GetActionNumber();
1722 
1723             if(nStartAction<=nAction && nAction<=nEndAction) bRemove=sal_True;
1724         }
1725 
1726         if(bRemove)
1727         {
1728             nPos=pEntry->GetChildListPos();
1729             pTheView->RemoveEntry(pEntry);
1730 
1731             if(pLastEntry==NULL) pLastEntry=pTheView->First();
1732             if(pLastEntry!=NULL)
1733             {
1734                 pNextEntry=pTheView->Next(pLastEntry);
1735 
1736                 if(pNextEntry==NULL)
1737                 {
1738                     pNextEntry=pLastEntry;
1739                     pLastEntry=NULL;
1740                 }
1741             }
1742             else
1743                 pNextEntry=NULL;
1744 
1745         }
1746         else
1747         {
1748             pLastEntry = pEntry;
1749             pNextEntry = pTheView->Next(pEntry);
1750         }
1751         pEntry=pNextEntry;
1752     }
1753 
1754     if(nStartAction==nEndAction)
1755         AppendChanges(pChgTrack,nStartAction,nEndAction,nPos);
1756     else
1757         AppendChanges(pChgTrack,nStartAction,nEndAction);
1758 
1759     pTheView->SetUpdateMode(sal_True);
1760 
1761 }
1762 
1763 IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack*, pChgTrack)
1764 {
1765 //  if(bScAcceptChgDlgIsDead) return 0;
1766 
1767     ScChangeTrackMsgQueue& aMsgQueue= pChgTrack->GetMsgQueue();
1768 
1769     ScChangeTrackMsgInfo* pTrackInfo=aMsgQueue.Get();
1770     sal_uLong   nStartAction;
1771     sal_uLong   nEndAction;
1772 
1773     while(pTrackInfo!=NULL)
1774     {
1775         nStartAction=pTrackInfo->nStartAction;
1776         nEndAction=pTrackInfo->nEndAction;
1777 
1778         if(!bIgnoreMsg)
1779         {
1780             bNoSelection=sal_True;
1781 
1782             switch(pTrackInfo->eMsgType)
1783             {
1784                 case SC_CTM_APPEND: AppendChanges(pChgTrack,nStartAction,nEndAction);
1785                                     break;
1786                 case SC_CTM_REMOVE: RemoveEntrys(nStartAction,nEndAction);
1787                                     break;
1788                 case SC_CTM_PARENT:
1789                 case SC_CTM_CHANGE: //bNeedsUpdate=sal_True;
1790                                     UpdateEntrys(pChgTrack,nStartAction,nEndAction);
1791                                     break;
1792                 default:
1793                 {
1794                     // added to avoid warnings
1795                 }
1796             }
1797         }
1798         delete pTrackInfo;
1799         pTrackInfo=aMsgQueue.Get();
1800     }
1801 
1802     return 0;
1803 }
1804 IMPL_LINK( ScAcceptChgDlg, ReOpenTimerHdl, Timer*, EMPTYARG )
1805 {
1806     ScSimpleRefDlgWrapper::SetAutoReOpen(sal_True);
1807     aAcceptChgCtr.ShowFilterPage();
1808     RefHandle(NULL);
1809 
1810     return 0;
1811 }
1812 
1813 IMPL_LINK( ScAcceptChgDlg, UpdateSelectionHdl, Timer*, EMPTYARG )
1814 {
1815     ScTabView* pTabView = pViewData->GetView();
1816 
1817     sal_Bool bAcceptFlag = sal_True;
1818     sal_Bool bRejectFlag = sal_True;
1819     sal_Bool bContMark = sal_False;
1820 
1821     pTabView->DoneBlockMode();  // clears old marking
1822     SvLBoxEntry* pEntry = pTheView->FirstSelected();
1823     while( pEntry )
1824     {
1825         ScRedlinData* pEntryData = (ScRedlinData*) pEntry->GetUserData();
1826         if( pEntryData )
1827         {
1828             bRejectFlag &= pEntryData->bIsRejectable;
1829             bAcceptFlag &= pEntryData->bIsAcceptable;
1830 
1831             const ScChangeAction* pScChangeAction = (ScChangeAction*) pEntryData->pData;
1832             if( pScChangeAction && (pScChangeAction->GetType() != SC_CAT_DELETE_TABS) &&
1833                     (!pEntryData->bDisabled || pScChangeAction->IsVisible()) )
1834             {
1835                 const ScBigRange& rBigRange = pScChangeAction->GetBigRange();
1836                 if( rBigRange.IsValid( pDoc ) && IsActive() )
1837                 {
1838                     sal_Bool bSetCursor = !pTheView->NextSelected( pEntry );
1839                     pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark );
1840                     bContMark = sal_True;
1841                 }
1842             }
1843         }
1844         else
1845         {
1846             bAcceptFlag = sal_False;
1847             bRejectFlag = sal_False;
1848         }
1849         bAcceptEnableFlag = bAcceptFlag;
1850         bRejectEnableFlag = bRejectFlag;
1851 
1852         pEntry = pTheView->NextSelected( pEntry );
1853     }
1854 
1855     ScChangeTrack* pChanges = pDoc->GetChangeTrack();
1856     sal_Bool bEnable = pDoc->IsDocEditable() && pChanges && !pChanges->IsProtected();
1857     pTPView->EnableAccept( bAcceptFlag && bEnable );
1858     pTPView->EnableReject( bRejectFlag && bEnable );
1859 
1860     return 0;
1861 }
1862 
1863 IMPL_LINK( ScAcceptChgDlg, CommandHdl, Control*, EMPTYARG )
1864 {
1865 
1866     const CommandEvent aCEvt(pTheView->GetCommandEvent());
1867 
1868     if(aCEvt.GetCommand()==COMMAND_CONTEXTMENU)
1869     {
1870         ScPopupMenu aPopup(ScResId(RID_POPUP_CHANGES));
1871 
1872         aPopup.SetMenuFlags(MENU_FLAG_HIDEDISABLEDENTRIES);
1873 
1874         SvLBoxEntry* pEntry=pTheView->GetCurEntry();
1875         if(pEntry!=NULL)
1876         {
1877             pTheView->Select(pEntry);
1878         }
1879         else
1880         {
1881             aPopup.Deactivate();
1882         }
1883 
1884         sal_uInt16 nSortedCol= pTheView->GetSortedCol();
1885 
1886         if(nSortedCol!=0xFFFF)
1887         {
1888             sal_uInt16 nItemId=nSortedCol+SC_SUB_SORT+1;
1889 
1890             aPopup.CheckItem(nItemId);
1891 
1892             PopupMenu *pSubMenu = aPopup.GetPopupMenu(SC_SUB_SORT);
1893             if (pSubMenu)
1894             {
1895                 pSubMenu->CheckItem(nItemId);
1896             }
1897         }
1898 
1899         aPopup.EnableItem(SC_CHANGES_COMMENT,sal_False);
1900 
1901         if(pDoc->IsDocEditable() && pEntry!=NULL)
1902         {
1903             ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1904             if(pEntryData!=NULL)
1905             {
1906                 ScChangeAction* pScChangeAction=
1907                         (ScChangeAction*) pEntryData->pData;
1908                 if(pScChangeAction!=NULL && !pTheView->GetParent(pEntry))
1909                     aPopup.EnableItem(SC_CHANGES_COMMENT);
1910             }
1911         }
1912 
1913         sal_uInt16 nCommand=aPopup.Execute( this, GetPointerPosPixel() );
1914 
1915 
1916         if(nCommand)
1917         {
1918             if(nCommand==SC_CHANGES_COMMENT)
1919             {
1920                 if(pEntry!=NULL)
1921                 {
1922                     ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1923                     if(pEntryData!=NULL)
1924                     {
1925                         ScChangeAction* pScChangeAction=
1926                                 (ScChangeAction*) pEntryData->pData;
1927 
1928                         pViewData->GetDocShell()->ExecuteChangeCommentDialog( pScChangeAction, this,sal_False);
1929                     }
1930                 }
1931             }
1932             else
1933             {
1934                 sal_Bool bSortDir=pTheView->GetSortDirection();
1935                 sal_uInt16 nDialogCol=nCommand-SC_SUB_SORT-1;
1936                 if(nSortedCol==nDialogCol) bSortDir=!bSortDir;
1937                 pTheView->SortByCol(nDialogCol,bSortDir);
1938                 /*
1939                 SC_SUB_SORT
1940                 SC_SORT_ACTION
1941                 SC_SORT_POSITION
1942                 SC_SORT_AUTHOR
1943                 SC_SORT_DATE
1944                 SC_SORT_COMMENT
1945                 */
1946             }
1947         }
1948     }
1949     return 0;
1950 }
1951 
1952 void ScAcceptChgDlg::Initialize(SfxChildWinInfo *pInfo)
1953 {
1954     String aStr;
1955     if(pInfo!=NULL)
1956     {
1957         if ( pInfo->aExtraString.Len() )
1958         {
1959             xub_StrLen nPos = pInfo->aExtraString.Search(
1960                 String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("AcceptChgDat:")));
1961 
1962             // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
1963             // er nicht vorhanden ist, liegt eine "altere Version vor
1964             if ( nPos != STRING_NOTFOUND )
1965             {
1966                 xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos);
1967                 if ( n1 != STRING_NOTFOUND )
1968                 {
1969                     xub_StrLen n2 = pInfo->aExtraString.Search(')', n1);
1970                     if ( n2 != STRING_NOTFOUND )
1971                     {
1972                         // Alignment-String herausschneiden
1973                         aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1);
1974                         pInfo->aExtraString.Erase(nPos, n2 - nPos + 1);
1975                         aStr.Erase(0, n1-nPos+1);
1976                     }
1977                 }
1978             }
1979         }
1980     }
1981     SfxModelessDialog::Initialize(pInfo);
1982 
1983     if ( aStr.Len())
1984     {
1985         sal_uInt16 nCount=(sal_uInt16)aStr.ToInt32();
1986 
1987         for(sal_uInt16 i=0;i<nCount;i++)
1988         {
1989             xub_StrLen n1 = aStr.Search(';');
1990             aStr.Erase(0, n1+1);
1991             pTheView->SetTab(i,(sal_uInt16)aStr.ToInt32(),MAP_PIXEL);
1992         }
1993     }
1994 }
1995 
1996 //-------------------------------------------------------------------------
1997 
1998 void ScAcceptChgDlg::FillInfo(SfxChildWinInfo& rInfo) const
1999 {
2000     SfxModelessDialog::FillInfo(rInfo);
2001     rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "AcceptChgDat:(" ));
2002 
2003     sal_uInt16  nCount=pTheView->TabCount();
2004 
2005     rInfo.aExtraString += String::CreateFromInt32(nCount);
2006     rInfo.aExtraString += ';';
2007     for(sal_uInt16 i=0;i<nCount;i++)
2008     {
2009         rInfo.aExtraString += String::CreateFromInt32(pTheView->GetTab(i));
2010         rInfo.aExtraString += ';';
2011     }
2012     rInfo.aExtraString += ')';
2013 }
2014 
2015 void ScAcceptChgDlg::InitFilter()
2016 {
2017     if(pTPFilter->IsDate()||pTPFilter->IsRange()||
2018         pTPFilter->IsAuthor()||pTPFilter->IsComment())
2019     {
2020         pTheView->SetFilterDate(pTPFilter->IsDate());
2021         pTheView->SetDateTimeMode(pTPFilter->GetDateMode());
2022         pTheView->SetFirstDate(pTPFilter->GetFirstDate());
2023         pTheView->SetLastDate(pTPFilter->GetLastDate());
2024         pTheView->SetFirstTime(pTPFilter->GetFirstTime());
2025         pTheView->SetLastTime(pTPFilter->GetLastTime());
2026         pTheView->SetFilterAuthor(pTPFilter->IsAuthor());
2027         pTheView->SetAuthor(pTPFilter->GetSelectedAuthor());
2028 
2029         pTheView->SetFilterComment(pTPFilter->IsComment());
2030 
2031         utl::SearchParam aSearchParam( pTPFilter->GetComment(),
2032                 utl::SearchParam::SRCH_REGEXP,sal_False,sal_False,sal_False );
2033 
2034         pTheView->SetCommentParams(&aSearchParam);
2035 
2036         pTheView->UpdateFilterTest();
2037     }
2038 }
2039 
2040 //UNUSED2008-05  void ScAcceptChgDlg::SetMyStaticData()
2041 //UNUSED2008-05  {
2042 //UNUSED2008-05  }
2043 
2044 IMPL_LINK( ScAcceptChgDlg, FilterModified, SvxTPFilter*, EMPTYARG )
2045 {
2046     return 0;
2047 }
2048 
2049 #define CALC_DATE       3
2050 #define CALC_POS        1
2051 
2052 IMPL_LINK( ScAcceptChgDlg, ColCompareHdl, SvSortData*, pSortData )
2053 {
2054     StringCompare eCompare=COMPARE_EQUAL;
2055     SCCOL nSortCol= static_cast<SCCOL>(pTheView->GetSortedCol());
2056 
2057     if(pSortData)
2058     {
2059         SvLBoxEntry* pLeft = (SvLBoxEntry*)(pSortData->pLeft );
2060         SvLBoxEntry* pRight = (SvLBoxEntry*)(pSortData->pRight );
2061 
2062         if(CALC_DATE==nSortCol)
2063         {
2064             RedlinData *pLeftData=(RedlinData *)(pLeft->GetUserData());
2065             RedlinData *pRightData=(RedlinData *)(pRight->GetUserData());
2066 
2067             if(pLeftData!=NULL && pRightData!=NULL)
2068             {
2069                 if(pLeftData->aDateTime < pRightData->aDateTime)
2070                 {
2071                     eCompare=COMPARE_LESS;
2072                 }
2073                 else if(pLeftData->aDateTime > pRightData->aDateTime)
2074                 {
2075                     eCompare=COMPARE_GREATER;
2076                 }
2077                 return eCompare;
2078             }
2079         }
2080         else if(CALC_POS==nSortCol)
2081         {
2082             ScRedlinData *pLeftData=(ScRedlinData *)(pLeft->GetUserData());
2083             ScRedlinData *pRightData=(ScRedlinData *)(pRight->GetUserData());
2084 
2085             if(pLeftData!=NULL && pRightData!=NULL)
2086             {
2087                 eCompare=COMPARE_GREATER;
2088 
2089                 if(pLeftData->nTable < pRightData->nTable)
2090                 {
2091                     eCompare=COMPARE_LESS;
2092                 }
2093                 else if(pLeftData->nTable == pRightData->nTable)
2094                 {
2095                     if(pLeftData->nRow < pRightData->nRow)
2096                     {
2097                         eCompare=COMPARE_LESS;
2098                     }
2099                     else if(pLeftData->nRow == pRightData->nRow)
2100                     {
2101                         if(pLeftData->nCol < pRightData->nCol)
2102                         {
2103                             eCompare=COMPARE_LESS;
2104                         }
2105                         else if(pLeftData->nCol == pRightData->nCol)
2106                         {
2107                             eCompare=COMPARE_EQUAL;
2108                         }
2109                     }
2110                 }
2111 
2112                 return eCompare;
2113             }
2114         }
2115 
2116         SvLBoxItem* pLeftItem = pTheView->GetEntryAtPos( pLeft, static_cast<sal_uInt16>(nSortCol));
2117         SvLBoxItem* pRightItem = pTheView->GetEntryAtPos( pRight, static_cast<sal_uInt16>(nSortCol));
2118 
2119         if(pLeftItem != NULL && pRightItem != NULL)
2120         {
2121             sal_uInt16 nLeftKind=pLeftItem->IsA();
2122             sal_uInt16 nRightKind=pRightItem->IsA();
2123 
2124             if(nRightKind == SV_ITEM_ID_LBOXSTRING &&
2125                 nLeftKind == SV_ITEM_ID_LBOXSTRING )
2126             {
2127                 eCompare= (StringCompare) ScGlobal::GetCaseCollator()->compareString(
2128                                         ((SvLBoxString*)pLeftItem)->GetText(),
2129                                         ((SvLBoxString*)pRightItem)->GetText());
2130 
2131                 if(eCompare==COMPARE_EQUAL) eCompare=COMPARE_LESS;
2132             }
2133         }
2134 
2135 
2136     }
2137     return eCompare;
2138 }
2139 
2140