update dev300-m58
[ooovba.git] / sc / source / ui / miscdlgs / acredlin.cxx
blobac64a486a1ed24de679f3c1ee56cd88e46414719
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: acredlin.cxx,v $
10 * $Revision: 1.25.32.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 // System - Includes ---------------------------------------------------------
38 #include <svtools/undo.hxx>
39 #include <unotools/textsearch.hxx>
40 #include <unotools/localedatawrapper.hxx>
41 #include <unotools/collatorwrapper.hxx>
42 #include <vcl/msgbox.hxx>
43 #include <sfx2/app.hxx>
44 #include <sfx2/viewfrm.hxx>
46 // INCLUDE -------------------------------------------------------------------
48 #include "acredlin.hxx"
49 #include "global.hxx"
50 #include "reffact.hxx"
51 #include "document.hxx"
52 #include "docsh.hxx"
53 #include "scresid.hxx"
54 #include "globstr.hrc"
55 #include "acredlin.hrc"
56 #include "simpref.hxx"
57 #include "scmod.hxx"
58 #include "popmenu.hxx"
59 #include "tabvwsh.hxx"
61 // defines -------------------------------------------------------------------
63 #define ABS_SREF SCA_VALID \
64 | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
65 #define ABS_DREF ABS_SREF \
66 | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
67 #define ABS_SREF3D ABS_SREF | SCA_TAB_3D
68 #define ABS_DREF3D ABS_DREF | SCA_TAB_3D
72 #define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
74 inline void EnableDisable( Window& rWin, BOOL bEnable )
76 if (bEnable)
77 rWin.Enable();
78 else
79 rWin.Disable();
82 #define RD_SPECIAL_NONE 0
83 #define RD_SPECIAL_CONTENT 1
84 #define RD_SPECIAL_VISCONTENT 2
86 //============================================================================
87 // class ScRedlinData
88 //----------------------------------------------------------------------------
90 ScRedlinData::ScRedlinData()
91 :RedlinData()
93 nInfo=RD_SPECIAL_NONE;
94 nActionNo=0;
95 pData=NULL;
96 bDisabled=FALSE;
97 bIsRejectable=FALSE;
98 bIsAcceptable=FALSE;
99 nTable=SCTAB_MAX;
100 nCol=SCCOL_MAX;
101 nRow=SCROW_MAX;
104 ScRedlinData::~ScRedlinData()
106 nInfo=RD_SPECIAL_NONE;
107 nActionNo=0;
108 pData=NULL;
109 bDisabled=FALSE;
110 bIsRejectable=FALSE;
111 bIsAcceptable=FALSE;
115 //============================================================================
116 // class ScAcceptChgDlg
117 //----------------------------------------------------------------------------
118 ScAcceptChgDlg::ScAcceptChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
119 ScViewData* ptrViewData)
121 : SfxModelessDialog( pB, pCW, pParent, ScResId(RID_SCDLG_CHANGES) ),
123 aAcceptChgCtr ( this, ScResId( CTR_REDLINING ) ),
125 pViewData ( ptrViewData ),
126 pDoc ( ptrViewData->GetDocument() ),
127 aLocalRangeName ( *(pDoc->GetRangeName()) ),
129 aStrInsertCols ( ScResId( STR_INSERT_COLS)),
130 aStrInsertRows ( ScResId( STR_INSERT_ROWS)),
131 aStrInsertTabs ( ScResId( STR_INSERT_TABS)),
132 aStrDeleteCols ( ScResId( STR_DELETE_COLS)),
133 aStrDeleteRows ( ScResId( STR_DELETE_ROWS)),
134 aStrDeleteTabs ( ScResId( STR_DELETE_TABS)),
135 aStrMove ( ScResId( STR_MOVE )),
136 aStrContent ( ScResId( STR_CONTENT )),
137 aStrReject ( ScResId( STR_REJECT )),
138 aStrAllAccepted ( ScResId( STR_ACCEPTED )),
139 aStrAllRejected ( ScResId( STR_REJECTED )),
140 aStrNoEntry ( ScResId( STR_NO_ENTRY )),
141 aStrContentWithChild ( ScResId( STR_CONTENT_WITH_CHILD)),
142 aStrChildContent ( ScResId( STR_CHILD_CONTENT)),
143 aStrChildOrgContent ( ScResId( STR_CHILD_ORGCONTENT)),
144 aStrEmpty ( ScResId( STR_EMPTY ))
146 FreeResource();
147 // bScAcceptChgDlgIsDead=FALSE;
148 bNoSelection=FALSE;
149 bNeedsUpdate=FALSE;
150 bIgnoreMsg=FALSE;
151 nAcceptCount=0;
152 nRejectCount=0;
153 bAcceptEnableFlag=TRUE;
154 bRejectEnableFlag=TRUE;
155 bHasFilterEntry=FALSE;
156 bUseColor=FALSE;
157 aReOpenTimer.SetTimeout(50);
158 aReOpenTimer.SetTimeoutHdl(LINK( this, ScAcceptChgDlg, ReOpenTimerHdl ));
160 // dialog is now only hidden, not deleted, on switching views,
161 // so there's no need to restore settings when reopening
163 MinSize=aAcceptChgCtr.GetMinSizePixel();
164 MinSize.Height()+=2;
165 MinSize.Width()+=2;
166 SetMinOutputSizePixel(MinSize);
167 aUnknown.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Unknown"));
169 pTPFilter=aAcceptChgCtr.GetFilterPage();
170 pTPView=aAcceptChgCtr.GetViewPage();
171 pTheView=pTPView->GetTableControl();
172 aSelectionTimer.SetTimeout(100);
173 aSelectionTimer.SetTimeoutHdl(LINK( this, ScAcceptChgDlg, UpdateSelectionHdl ));
175 pTPFilter->SetReadyHdl(LINK( this, ScAcceptChgDlg, FilterHandle ));
176 pTPFilter->SetRefHdl(LINK( this, ScAcceptChgDlg, RefHandle ));
177 pTPFilter->SetModifyHdl(LINK( this, ScAcceptChgDlg, FilterModified));
178 pTPFilter->HideRange(FALSE);
179 pTPView->InsertCalcHeader();
180 pTPView->SetRejectClickHdl( LINK( this, ScAcceptChgDlg,RejectHandle));
181 pTPView->SetAcceptClickHdl( LINK(this, ScAcceptChgDlg, AcceptHandle));
182 pTPView->SetRejectAllClickHdl( LINK( this, ScAcceptChgDlg,RejectAllHandle));
183 pTPView->SetAcceptAllClickHdl( LINK(this, ScAcceptChgDlg, AcceptAllHandle));
184 pTheView->SetCalcView();
185 pTheView->SetWindowBits(WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
186 pTheView->SetExpandingHdl( LINK(this, ScAcceptChgDlg, ExpandingHandle));
187 pTheView->SetSelectHdl( LINK(this, ScAcceptChgDlg, SelectHandle));
188 pTheView->SetDeselectHdl( LINK(this, ScAcceptChgDlg, SelectHandle));
189 pTheView->SetCommandHdl( LINK(this, ScAcceptChgDlg, CommandHdl));
190 pTheView->SetColCompareHdl( LINK(this, ScAcceptChgDlg,ColCompareHdl));
191 pTheView->SetSelectionMode(MULTIPLE_SELECTION);
192 pTheView->SetHighlightRange(1);
194 Init();
196 aAcceptChgCtr.SetMinSizeHdl( LINK( this, ScAcceptChgDlg, MinSizeHandle ));
198 UpdateView();
199 SvLBoxEntry* pEntry=pTheView->First();
200 if(pEntry!=NULL)
202 pTheView->Select(pEntry);
205 ScAcceptChgDlg::~ScAcceptChgDlg()
207 // bScAcceptChgDlgIsDead=TRUE;
208 ClearView();
209 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
211 if(pChanges!=NULL)
213 Link aLink;
214 pChanges->SetModifiedLink(aLink);
218 void ScAcceptChgDlg::ReInit(ScViewData* ptrViewData)
220 pViewData=ptrViewData;
221 if(pViewData!=NULL)
223 pDoc=ptrViewData->GetDocument();
225 else
227 pDoc=NULL;
230 bNoSelection=FALSE;
231 bNeedsUpdate=FALSE;
232 bIgnoreMsg=FALSE;
233 nAcceptCount=0;
234 nRejectCount=0;
235 bAcceptEnableFlag=TRUE;
236 bRejectEnableFlag=TRUE;
238 // #91781# don't call Init here (switching between views), just set link below
239 // (dialog is just hidden, not deleted anymore, when switching views)
240 ClearView();
241 UpdateView();
243 if ( pDoc )
245 ScChangeTrack* pChanges = pDoc->GetChangeTrack();
246 if ( pChanges )
247 pChanges->SetModifiedLink( LINK( this, ScAcceptChgDlg, ChgTrackModHdl ) );
251 void __EXPORT ScAcceptChgDlg::Init()
253 String aAreaStr;
254 ScRange aRange;
256 DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
258 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
260 if(pChanges!=NULL)
262 pChanges->SetModifiedLink( LINK( this, ScAcceptChgDlg,ChgTrackModHdl));
263 aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser());
264 pTPFilter->ClearAuthors();
265 ScStrCollection aUserColl=pChanges->GetUserCollection();
266 for(USHORT i=0;i<aUserColl.GetCount();i++)
267 pTPFilter->InsertAuthor(aUserColl[i]->GetString());
270 ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings();
271 if ( pViewSettings!=NULL )
272 aChangeViewSet = *pViewSettings;
273 // adjust TimeField for filter tabpage
274 aChangeViewSet.AdjustDateMode( *pDoc );
276 pTPFilter->CheckDate(aChangeViewSet.HasDate());
277 pTPFilter->SetFirstDate(aChangeViewSet.GetTheFirstDateTime());
278 pTPFilter->SetFirstTime(aChangeViewSet.GetTheFirstDateTime());
279 pTPFilter->SetLastDate(aChangeViewSet.GetTheLastDateTime());
280 pTPFilter->SetLastTime(aChangeViewSet.GetTheLastDateTime());
281 pTPFilter->SetDateMode((USHORT)aChangeViewSet.GetTheDateMode());
282 pTPFilter->CheckComment(aChangeViewSet.HasComment());
283 pTPFilter->SetComment(aChangeViewSet.GetTheComment());
285 pTPFilter->CheckAuthor(aChangeViewSet.HasAuthor());
286 String aString=aChangeViewSet.GetTheAuthorToShow();
287 if(aString.Len()!=0)
289 pTPFilter->SelectAuthor(aString);
290 if(pTPFilter->GetSelectedAuthor()!=aString)
292 pTPFilter->InsertAuthor(aString);
293 pTPFilter->SelectAuthor(aString);
296 else
298 pTPFilter->SelectedAuthorPos(0);
301 pTPFilter->CheckRange(aChangeViewSet.HasRange());
303 ScRange* pRangeEntry=aChangeViewSet.GetTheRangeList().GetObject(0);
304 aRangeList=aChangeViewSet.GetTheRangeList();
306 if(pRangeEntry!=NULL)
308 String aRefStr;
309 pRangeEntry->Format( aRefStr, ABS_DREF3D, pDoc );
310 pTPFilter->SetRange(aRefStr);
313 Point aPoint(1,1);
314 aAcceptChgCtr.SetPosPixel(aPoint);
315 InitFilter();
320 void ScAcceptChgDlg::ClearView()
322 nAcceptCount=0;
323 nRejectCount=0;
324 pTheView->SetUpdateMode(FALSE);
326 pTheView->Clear();
327 pTheView->SetUpdateMode(TRUE);
330 String* ScAcceptChgDlg::MakeTypeString(ScChangeActionType eType)
332 String* pStr;
334 switch(eType)
337 case SC_CAT_INSERT_COLS: pStr=&aStrInsertCols;break;
339 case SC_CAT_INSERT_ROWS: pStr=&aStrInsertRows;break;
341 case SC_CAT_INSERT_TABS: pStr=&aStrInsertTabs;break;
343 case SC_CAT_DELETE_COLS: pStr=&aStrDeleteCols;break;
345 case SC_CAT_DELETE_ROWS: pStr=&aStrDeleteRows;break;
347 case SC_CAT_DELETE_TABS: pStr=&aStrDeleteTabs;break;
349 case SC_CAT_MOVE: pStr=&aStrMove;break;
351 case SC_CAT_CONTENT: pStr=&aStrContent;break;
353 case SC_CAT_REJECT: pStr=&aStrReject;break;
355 default: pStr=&aUnknown;break;
357 return pStr;
361 BOOL ScAcceptChgDlg::IsValidAction(const ScChangeAction* pScChangeAction)
363 if(pScChangeAction==NULL) return FALSE;
365 BOOL bFlag=FALSE;
367 ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
368 String aUser=pScChangeAction->GetUser();
369 DateTime aDateTime=pScChangeAction->GetDateTime();
371 ScChangeActionType eType=pScChangeAction->GetType();
372 String aString;
373 String aDesc;
375 String aComment=pScChangeAction->GetComment();
376 aComment.EraseAllChars('\n');
378 if(eType==SC_CAT_CONTENT)
380 if(!pScChangeAction->IsDialogParent())
382 pScChangeAction->GetDescription( aDesc, pDoc, TRUE);
385 else
387 pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
390 if(aDesc.Len()>0)
392 aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
393 aComment+=aDesc;
394 aComment+=')';
397 if(pTheView->IsValidEntry(&aUser,&aDateTime,&aComment))
399 if(pTPFilter->IsRange())
401 ScRange* pRangeEntry=aRangeList.First();
403 while(pRangeEntry!=NULL)
405 if(pRangeEntry->Intersects(aRef)) break;
406 pRangeEntry=aRangeList.Next();
409 if(pRangeEntry!=NULL)
411 bFlag=TRUE;
414 else
416 bFlag=TRUE;
420 return bFlag;
423 SvLBoxEntry* ScAcceptChgDlg::InsertChangeAction(const ScChangeAction* pScChangeAction,
424 ScChangeActionState /* eState */, SvLBoxEntry* pParent,
425 BOOL bDelMaster,BOOL bDisabled,ULONG nPos)
427 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
429 if(pScChangeAction==NULL || pChanges==NULL) return NULL;
431 SvLBoxEntry* pEntry=NULL;
433 BOOL bFlag=FALSE;
435 ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
436 String aUser=pScChangeAction->GetUser();
437 DateTime aDateTime=pScChangeAction->GetDateTime();
439 String aRefStr;
440 ScChangeActionType eType=pScChangeAction->GetType();
441 String aString;
442 String aDesc;
444 ScRedlinData* pNewData=new ScRedlinData;
445 pNewData->pData=(void *)pScChangeAction;
446 pNewData->nActionNo=pScChangeAction->GetActionNumber();
447 pNewData->bIsAcceptable=pScChangeAction->IsClickable();
448 pNewData->bIsRejectable=pScChangeAction->IsRejectable();
449 pNewData->bDisabled=!pNewData->bIsAcceptable | bDisabled;
450 pNewData->aDateTime=aDateTime;
451 pNewData->nRow = aRef.aStart.Row();
452 pNewData->nCol = aRef.aStart.Col();
453 pNewData->nTable= aRef.aStart.Tab();
455 if(eType==SC_CAT_CONTENT)
457 if(pScChangeAction->IsDialogParent())
459 aString=aStrContentWithChild;
460 pNewData->nInfo=RD_SPECIAL_VISCONTENT;
461 pNewData->bIsRejectable=FALSE;
462 pNewData->bIsAcceptable=FALSE;
464 else
466 aString=*MakeTypeString(eType);
467 pScChangeAction->GetDescription( aDesc, pDoc, TRUE);
470 else
472 aString=*MakeTypeString(eType);
474 if(bDelMaster)
476 pScChangeAction->GetDescription( aDesc, pDoc,TRUE);
477 pNewData->bDisabled=TRUE;
478 pNewData->bIsRejectable=FALSE;
480 else
481 pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
485 aString+='\t';
486 pScChangeAction->GetRefString(aRefStr, pDoc, TRUE);
487 aString+=aRefStr;
488 aString+='\t';
490 BOOL bIsGenerated;
492 if(!pChanges->IsGenerated(pScChangeAction->GetActionNumber()))
494 aString+=aUser;
495 aString+='\t';
497 aString+=ScGlobal::pLocaleData->getDate(aDateTime);
498 aString+=' ';
499 aString+=ScGlobal::pLocaleData->getTime(aDateTime);
500 aString+='\t';
501 bIsGenerated=FALSE;
503 else
505 aString+='\t';
506 aString+='\t';
507 bIsGenerated=TRUE;
510 String aComment=pScChangeAction->GetComment();
511 aComment.EraseAllChars('\n');
512 if(aDesc.Len()>0)
514 aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
515 aComment+=aDesc;
516 aComment+=')';
519 aString+=aComment;
521 if(pTheView->IsValidEntry(&aUser,&aDateTime)|| bIsGenerated)
523 if(pTheView->IsValidComment(&aComment))
525 if(pTPFilter->IsRange())
527 ScRange* pRangeEntry=aRangeList.First();
529 while(pRangeEntry!=NULL)
531 if(pRangeEntry->Intersects(aRef)) break;
532 pRangeEntry=aRangeList.Next();
534 //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
535 if(pRangeEntry!=NULL)
537 bHasFilterEntry=TRUE;
538 bFlag=TRUE;
541 else if(!bIsGenerated)
543 bHasFilterEntry=TRUE;
544 bFlag=TRUE;
549 if(!bFlag&& bUseColor&& pParent==NULL)
551 pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_LIGHTBLUE),pParent,nPos);
553 else if(bFlag&& bUseColor&& pParent!=NULL)
555 pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_GREEN),pParent,nPos);
556 SvLBoxEntry* pExpEntry=pParent;
558 while(pExpEntry!=NULL && !pTheView->IsExpanded(pExpEntry))
560 SvLBoxEntry* pTmpEntry=pTheView->GetParent(pExpEntry);
562 if(pTmpEntry!=NULL) pTheView->Expand(pExpEntry);
564 pExpEntry=pTmpEntry;
567 else
569 pEntry=pTheView->InsertEntry(aString,pNewData,pParent,nPos);
571 return pEntry;
574 SvLBoxEntry* ScAcceptChgDlg::InsertFilteredAction(const ScChangeAction* pScChangeAction,
575 ScChangeActionState eState,SvLBoxEntry* pParent,
576 BOOL bDelMaster,BOOL bDisabled,ULONG nPos)
579 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
581 if(pScChangeAction==NULL || pChanges==NULL) return NULL;
583 BOOL bIsGenerated=pChanges->IsGenerated(pScChangeAction->GetActionNumber());
585 SvLBoxEntry* pEntry=NULL;
587 int bFlag=FALSE;
589 ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
590 String aUser=pScChangeAction->GetUser();
591 DateTime aDateTime=pScChangeAction->GetDateTime();
593 if(pTheView->IsValidEntry(&aUser,&aDateTime)||bIsGenerated)
595 if(pTPFilter->IsRange())
597 ScRange* pRangeEntry=aRangeList.First();
599 while(pRangeEntry!=NULL)
601 if(pRangeEntry->Intersects(aRef)) break;
602 pRangeEntry=aRangeList.Next();
604 //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
605 if(pRangeEntry!=NULL &&
606 pScChangeAction->GetState()==eState)
608 bFlag=TRUE;
611 else if(pScChangeAction->GetState()==eState && !bIsGenerated)
613 bFlag=TRUE;
617 if(bFlag)
620 String aRefStr;
621 ScChangeActionType eType=pScChangeAction->GetType();
622 String aString;
623 String aDesc;
626 ScRedlinData* pNewData=new ScRedlinData;
627 pNewData->pData=(void *)pScChangeAction;
628 pNewData->nActionNo=pScChangeAction->GetActionNumber();
629 pNewData->bIsAcceptable=pScChangeAction->IsClickable();
630 pNewData->bIsRejectable=pScChangeAction->IsRejectable();
631 pNewData->bDisabled=!pNewData->bIsAcceptable | bDisabled;
632 pNewData->aDateTime=aDateTime;
633 pNewData->nRow = aRef.aStart.Row();
634 pNewData->nCol = aRef.aStart.Col();
635 pNewData->nTable= aRef.aStart.Tab();
637 if(eType==SC_CAT_CONTENT)
639 if(pScChangeAction->IsDialogParent())
641 aString=aStrContentWithChild;
642 pNewData->nInfo=RD_SPECIAL_VISCONTENT;
643 pNewData->bIsRejectable=FALSE;
644 pNewData->bIsAcceptable=FALSE;
646 else
648 aString=*MakeTypeString(eType);
649 pScChangeAction->GetDescription( aDesc, pDoc, TRUE);
652 else
654 aString=*MakeTypeString(eType);
656 if(bDelMaster)
658 pScChangeAction->GetDescription( aDesc, pDoc,TRUE);
659 pNewData->bDisabled=TRUE;
660 pNewData->bIsRejectable=FALSE;
662 else
663 pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
667 aString+='\t';
668 pScChangeAction->GetRefString(aRefStr, pDoc, TRUE);
669 aString+=aRefStr;
670 aString+='\t';
672 if(!bIsGenerated)
674 aString+=aUser;
675 aString+='\t';
676 aString+=ScGlobal::pLocaleData->getDate(aDateTime);
677 aString+=' ';
678 aString+=ScGlobal::pLocaleData->getTime(aDateTime);
679 aString+='\t';
681 else
683 aString+='\t';
684 aString+='\t';
687 String aComment=pScChangeAction->GetComment();
688 aComment.EraseAllChars('\n');
689 if(aDesc.Len()>0)
691 aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
692 aComment+=aDesc;
693 aComment+=')';
695 if(pTheView->IsValidComment(&aComment))
697 aString+=aComment;
698 pEntry=pTheView->InsertEntry(aString,pNewData,pParent,nPos);
700 else
701 delete pNewData;
703 return pEntry;
706 SvLBoxEntry* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionContent* pScChangeAction,
707 SvLBoxEntry* pParent, ULONG nSpecial)
709 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
710 SvLBoxEntry* pEntry=NULL;
712 if(pScChangeAction==NULL || pChanges==NULL) return NULL;
714 BOOL bIsGenerated=pChanges->IsGenerated(pScChangeAction->GetActionNumber());
716 BOOL bFlag=FALSE;
718 ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
719 String aUser=pScChangeAction->GetUser();
720 DateTime aDateTime=pScChangeAction->GetDateTime();
722 if(pTheView->IsValidEntry(&aUser,&aDateTime)||bIsGenerated)
724 if(pTPFilter->IsRange())
726 ScRange* pRangeEntry=aRangeList.First();
728 while(pRangeEntry!=NULL)
730 if(pRangeEntry->Intersects(aRef)) break;
731 pRangeEntry=aRangeList.Next();
733 //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
734 if(pRangeEntry!=NULL)
736 bFlag=TRUE;
739 else if(!bIsGenerated)
740 bFlag=TRUE;
743 String aRefStr;
744 String aString;
745 String a2String;
746 String aDesc;
748 if(nSpecial==RD_SPECIAL_CONTENT)
750 pScChangeAction->GetOldString(a2String);
751 if(a2String.Len()==0) a2String=aStrEmpty;
753 //aString+="\'";
754 aString+=a2String;
755 //aString+="\'";
757 aDesc=aStrChildOrgContent;
758 aDesc.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
760 else
762 pScChangeAction->GetNewString(a2String);
763 if(a2String.Len()==0)
765 a2String=aStrEmpty;
766 aString+=a2String;
768 else
770 aString+='\'';
771 aString+=a2String;
772 aString+='\'';
773 a2String=aString;
775 aDesc=aStrChildContent;
779 aDesc+=a2String;
780 aString+='\t';
781 pScChangeAction->GetRefString(aRefStr, pDoc, TRUE);
782 aString+=aRefStr;
783 aString+='\t';
785 if(!bIsGenerated)
787 aString+=aUser;
788 aString+='\t';
790 aString+=ScGlobal::pLocaleData->getDate(aDateTime);
791 aString+=' ';
792 aString+=ScGlobal::pLocaleData->getTime(aDateTime);
793 aString+='\t';
795 else
797 aString+='\t';
798 aString+='\t';
800 String aComment=pScChangeAction->GetComment();
801 aComment.EraseAllChars('\n');
803 if(aDesc.Len()>0)
805 aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
806 aComment+=aDesc;
807 aComment+=')';
810 aString+=aComment;
812 ScRedlinData* pNewData=new ScRedlinData;
813 pNewData->nInfo=nSpecial;
814 pNewData->pData=(void *)pScChangeAction;
815 pNewData->nActionNo=pScChangeAction->GetActionNumber();
816 pNewData->bIsAcceptable=pScChangeAction->IsClickable();
817 pNewData->bIsRejectable=FALSE;
818 pNewData->bDisabled=!pNewData->bIsAcceptable;
819 pNewData->aDateTime=aDateTime;
820 pNewData->nRow = aRef.aStart.Row();
821 pNewData->nCol = aRef.aStart.Col();
822 pNewData->nTable= aRef.aStart.Tab();
824 if(pTheView->IsValidComment(&aComment) && bFlag)
826 bHasFilterEntry=TRUE;
827 pEntry=pTheView->InsertEntry(aString,pNewData,pParent);
829 else
830 pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_LIGHTBLUE),pParent);
831 return pEntry;
834 long ScAcceptChgDlg::PreNotify( NotifyEvent& rNEvt )
836 if(rNEvt.GetType()==EVENT_GETFOCUS && bNeedsUpdate)
838 ClearView();
839 UpdateView();
840 bNoSelection=FALSE;
843 return SfxModelessDialog::PreNotify(rNEvt);
847 void ScAcceptChgDlg::UpdateView()
849 bNeedsUpdate=FALSE;
850 DateTime aDateTime;
851 SvLBoxEntry* pParent=NULL;
852 ScChangeTrack* pChanges=NULL;
853 const ScChangeAction* pScChangeAction=NULL;
854 bAcceptEnableFlag=TRUE;
855 bRejectEnableFlag=TRUE;
856 SetPointer(Pointer(POINTER_WAIT));
857 pTheView->SetUpdateMode(FALSE);
858 BOOL bFilterFlag=pTPFilter->IsDate()||pTPFilter->IsRange()||
859 pTPFilter->IsAuthor()||pTPFilter->IsComment();
861 bUseColor=bFilterFlag;
863 if(pDoc!=NULL)
865 pChanges=pDoc->GetChangeTrack();
866 if(pChanges!=NULL)
868 pScChangeAction=pChanges->GetFirst();
871 ScChangeActionTable ActionTable;
872 BOOL bTheFlag=FALSE;
874 while(pScChangeAction!=NULL)
876 bHasFilterEntry=FALSE;
877 switch(pScChangeAction->GetState())
879 case SC_CAS_VIRGIN:
881 if(pScChangeAction->IsDialogRoot())
883 if(pScChangeAction->IsDialogParent())
884 pParent=InsertChangeAction(pScChangeAction,SC_CAS_VIRGIN);
885 else
886 pParent=InsertFilteredAction(pScChangeAction,SC_CAS_VIRGIN);
888 else
889 pParent=NULL;
891 bTheFlag=TRUE;
892 break;
894 case SC_CAS_ACCEPTED:
895 pParent=NULL;
896 nAcceptCount++;
897 break;
899 case SC_CAS_REJECTED:
900 pParent=NULL;
901 nRejectCount++;
902 break;
905 if(pParent!=NULL && pScChangeAction->IsDialogParent())
907 if(!bFilterFlag)
909 pParent->EnableChildsOnDemand(TRUE);
911 else
913 BOOL bTestFlag=bHasFilterEntry;
914 bHasFilterEntry=FALSE;
915 if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
916 pTheView->RemoveEntry(pParent);
920 pScChangeAction=pScChangeAction->GetNext();
923 if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
924 bTheFlag=FALSE;
926 pTPView->EnableAccept(bTheFlag);
927 pTPView->EnableAcceptAll(bTheFlag);
928 pTPView->EnableReject(bTheFlag);
929 pTPView->EnableRejectAll(bTheFlag);
931 if(nAcceptCount>0)
933 pParent=pTheView->InsertEntry(
934 aStrAllAccepted, static_cast< RedlinData * >(NULL),
935 static_cast< SvLBoxEntry * >(NULL));
936 pParent->EnableChildsOnDemand(TRUE);
938 if(nRejectCount>0)
940 pParent=pTheView->InsertEntry(
941 aStrAllRejected, static_cast< RedlinData * >(NULL),
942 static_cast< SvLBoxEntry * >(NULL));
943 pParent->EnableChildsOnDemand(TRUE);
945 pTheView->SetUpdateMode(TRUE);
946 SetPointer(Pointer(POINTER_ARROW));
947 SvLBoxEntry* pEntry=pTheView->First();
948 if(pEntry!=NULL)
950 pTheView->Select(pEntry);
954 //----------------------------------------------------------------------------
955 BOOL ScAcceptChgDlg::Close()
957 return SfxModelessDialog::Close();
960 void ScAcceptChgDlg::Resize()
962 SfxModelessDialog::Resize();
963 Size aOutSize=GetOutputSizePixel();
964 aAcceptChgCtr.SetSizePixel(aOutSize);
967 IMPL_LINK( ScAcceptChgDlg, MinSizeHandle, SvxAcceptChgCtr*, pCtr )
969 if(pCtr==&aAcceptChgCtr)
971 if(!IsRollUp())
972 SetOutputSizePixel(MinSize);
974 return 0;
977 IMPL_LINK( ScAcceptChgDlg, RefHandle, SvxTPFilter*, EMPTYARG )
979 USHORT nId =ScSimpleRefDlgWrapper::GetChildWindowId();
981 ScSimpleRefDlgWrapper::SetDefaultPosSize(GetPosPixel(),GetSizePixel(),TRUE);
983 SC_MOD()->SetRefDialog( nId, TRUE );
985 SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
986 ScSimpleRefDlgWrapper* pWnd =(ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
988 if(pWnd!=NULL)
990 // bSimpleRefDlgStarted=TRUE;
991 USHORT nAcceptId=ScAcceptChgDlgWrapper::GetChildWindowId();
992 pViewFrm->ShowChildWindow(nAcceptId,FALSE);
993 pWnd->SetCloseHdl(LINK( this, ScAcceptChgDlg,RefInfoHandle));
994 pWnd->SetRefString(pTPFilter->GetRange());
995 pWnd->SetAutoReOpen(FALSE);
996 Window* pWin=pWnd->GetWindow();
997 pWin->SetPosSizePixel(GetPosPixel(),GetSizePixel());
998 Hide();
999 pWin->SetText(GetText());
1000 pWnd->StartRefInput();
1002 return 0;
1005 IMPL_LINK( ScAcceptChgDlg, RefInfoHandle, String*, pResult)
1007 USHORT nId;
1009 // bSimpleRefDlgStarted=FALSE;
1010 ScSimpleRefDlgWrapper::SetAutoReOpen(TRUE);
1012 SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
1013 if(pResult!=NULL)
1015 pTPFilter->SetRange(*pResult);
1016 FilterHandle(pTPFilter);
1018 nId = ScSimpleRefDlgWrapper::GetChildWindowId();
1019 ScSimpleRefDlgWrapper* pWnd = (ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
1021 if(pWnd!=NULL)
1023 Window* pWin=pWnd->GetWindow();
1024 Size aWinSize=pWin->GetSizePixel();
1025 aWinSize.Width()=GetSizePixel().Width();
1026 SetPosSizePixel(pWin->GetPosPixel(),aWinSize);
1027 Invalidate();
1029 nId = ScAcceptChgDlgWrapper::GetChildWindowId();
1030 pViewFrm->ShowChildWindow( nId, TRUE );
1032 else
1034 nId = ScAcceptChgDlgWrapper::GetChildWindowId();
1035 pViewFrm->SetChildWindow( nId, FALSE );
1037 return 0;
1040 IMPL_LINK( ScAcceptChgDlg, FilterHandle, SvxTPFilter*, pRef )
1042 if(pRef!=NULL)
1044 ClearView();
1045 aRangeList.Clear();
1046 aRangeList.Parse(pTPFilter->GetRange(),pDoc);
1047 UpdateView();
1049 return 0;
1052 IMPL_LINK( ScAcceptChgDlg, RejectHandle, SvxTPView*, pRef )
1054 SetPointer(Pointer(POINTER_WAIT));
1056 bIgnoreMsg=TRUE;
1057 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1059 if(pRef!=NULL)
1061 SvLBoxEntry* pEntry=pTheView->FirstSelected();
1062 while(pEntry!=NULL)
1064 ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1065 if(pEntryData!=NULL)
1067 ScChangeAction* pScChangeAction=
1068 (ScChangeAction*) pEntryData->pData;
1070 if(pScChangeAction->GetType()==SC_CAT_INSERT_TABS)
1072 pViewData->SetTabNo(0);
1074 pChanges->Reject(pScChangeAction);
1076 pEntry = pTheView->NextSelected(pEntry);
1078 ScDocShell* pDocSh=pViewData->GetDocShell();
1079 pDocSh->PostPaintExtras();
1080 pDocSh->PostPaintGridAll();
1081 pDocSh->GetUndoManager()->Clear();
1082 pDocSh->SetDocumentModified();
1083 ClearView();
1084 UpdateView();
1086 SetPointer(Pointer(POINTER_ARROW));
1088 bIgnoreMsg=FALSE;
1089 return 0;
1091 IMPL_LINK( ScAcceptChgDlg, AcceptHandle, SvxTPView*, pRef )
1093 SetPointer(Pointer(POINTER_WAIT));
1095 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1096 bIgnoreMsg=TRUE;
1097 if(pRef!=NULL)
1099 SvLBoxEntry* pEntry=pTheView->FirstSelected();
1100 while(pEntry!=NULL)
1102 ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1103 if(pEntryData!=NULL)
1105 ScChangeAction* pScChangeAction=
1106 (ScChangeAction*) pEntryData->pData;
1107 if(pScChangeAction->GetType()==SC_CAT_CONTENT)
1109 if(pEntryData->nInfo==RD_SPECIAL_CONTENT)
1111 pChanges->SelectContent(pScChangeAction,TRUE);
1113 else
1115 pChanges->SelectContent(pScChangeAction);
1118 else
1119 pChanges->Accept(pScChangeAction);
1121 pEntry = pTheView->NextSelected(pEntry);
1123 ScDocShell* pDocSh=pViewData->GetDocShell();
1124 pDocSh->PostPaintExtras();
1125 pDocSh->PostPaintGridAll();
1126 pDocSh->SetDocumentModified();
1127 ClearView();
1128 UpdateView();
1130 bIgnoreMsg=FALSE;
1132 return 0;
1135 void ScAcceptChgDlg::RejectFiltered()
1137 if(pDoc==NULL) return;
1138 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1139 const ScChangeAction* pScChangeAction=NULL;
1141 if(pChanges!=NULL)
1143 pScChangeAction=pChanges->GetLast();
1146 while(pScChangeAction!=NULL)
1148 if(pScChangeAction->IsDialogRoot())
1150 if(IsValidAction(pScChangeAction))
1152 pChanges->Reject((ScChangeAction*)pScChangeAction);
1155 pScChangeAction=pScChangeAction->GetPrev();
1158 void ScAcceptChgDlg::AcceptFiltered()
1160 if(pDoc==NULL) return;
1161 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1162 const ScChangeAction* pScChangeAction=NULL;
1164 if(pChanges!=NULL)
1166 pScChangeAction=pChanges->GetLast();
1169 while(pScChangeAction!=NULL)
1171 if(pScChangeAction->IsDialogRoot())
1173 if(IsValidAction(pScChangeAction))
1175 pChanges->Accept((ScChangeAction*)pScChangeAction);
1178 pScChangeAction=pScChangeAction->GetPrev();
1182 IMPL_LINK( ScAcceptChgDlg, RejectAllHandle, SvxTPView*, EMPTYARG )
1184 SetPointer(Pointer(POINTER_WAIT));
1185 bIgnoreMsg=TRUE;
1186 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1187 if(pChanges!=NULL)
1189 if(pTPFilter->IsDate()||pTPFilter->IsAuthor()||pTPFilter->IsRange()||pTPFilter->IsComment())
1191 RejectFiltered();
1193 else
1195 pChanges->RejectAll();
1197 pViewData->SetTabNo(0);
1199 ScDocShell* pDocSh=pViewData->GetDocShell();
1200 pDocSh->PostPaintExtras();
1201 pDocSh->PostPaintGridAll();
1202 pDocSh->GetUndoManager()->Clear();
1203 pDocSh->SetDocumentModified();
1204 ClearView();
1205 UpdateView();
1207 SetPointer(Pointer(POINTER_ARROW));
1209 bIgnoreMsg=FALSE;
1211 return 0;
1214 IMPL_LINK( ScAcceptChgDlg, AcceptAllHandle, SvxTPView*, EMPTYARG )
1216 SetPointer(Pointer(POINTER_WAIT));
1218 bIgnoreMsg=TRUE;
1219 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1220 if(pChanges!=NULL)
1222 if(pTPFilter->IsDate()||pTPFilter->IsAuthor()||pTPFilter->IsRange()||pTPFilter->IsComment())
1224 AcceptFiltered();
1226 else
1228 pChanges->AcceptAll();
1230 ScDocShell* pDocSh=pViewData->GetDocShell();
1231 pDocSh->PostPaintExtras();
1232 pDocSh->PostPaintGridAll();
1233 pDocSh->SetDocumentModified();
1234 ClearView();
1235 UpdateView();
1237 bIgnoreMsg=FALSE;
1238 SetPointer(Pointer(POINTER_ARROW));
1240 return 0;
1243 IMPL_LINK( ScAcceptChgDlg, SelectHandle, SvxRedlinTable*, EMPTYARG )
1245 if(!bNoSelection)
1247 aSelectionTimer.Start();
1249 bNoSelection=FALSE;
1250 return 0;
1253 void ScAcceptChgDlg::GetDependents( const ScChangeAction* pScChangeAction,
1254 ScChangeActionTable& aActionTable,
1255 SvLBoxEntry* pEntry)
1257 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1259 SvLBoxEntry* pParent=pTheView->GetParent(pEntry);
1260 if(pParent!=NULL)
1262 ScRedlinData *pParentData=(ScRedlinData *)(pParent->GetUserData());
1263 ScChangeAction* pParentAction=(ScChangeAction*) pParentData->pData;
1264 if(pParentAction!=pScChangeAction)
1266 pChanges->GetDependents((ScChangeAction*) pScChangeAction,
1267 aActionTable,pScChangeAction->IsMasterDelete());
1269 else
1271 pChanges->GetDependents((ScChangeAction*) pScChangeAction,
1272 aActionTable);
1275 else
1277 pChanges->GetDependents((ScChangeAction*) pScChangeAction,
1278 aActionTable,pScChangeAction->IsMasterDelete());
1282 BOOL ScAcceptChgDlg::InsertContentChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
1284 BOOL bTheTestFlag=TRUE;
1285 ScRedlinData *pEntryData=(ScRedlinData *)(pParent->GetUserData());
1286 const ScChangeAction* pScChangeAction = (ScChangeAction*) pEntryData->pData;
1287 BOOL bParentInserted = FALSE;
1288 // If the parent is a MatrixOrigin then place it in the right order before
1289 // the MatrixReferences. Also if it is the first content change at this
1290 // position don't insert the first dependent MatrixReference as the special
1291 // content (original value) but insert the predecessor of the MatrixOrigin
1292 // itself instead.
1293 if ( pScChangeAction->GetType() == SC_CAT_CONTENT &&
1294 ((const ScChangeActionContent*)pScChangeAction)->IsMatrixOrigin() )
1296 pActionTable->Insert( pScChangeAction->GetActionNumber(),
1297 (ScChangeAction*) pScChangeAction );
1298 bParentInserted = TRUE;
1300 SvLBoxEntry* pEntry=NULL;
1302 const ScChangeActionContent* pCChild=(const ScChangeActionContent*)pActionTable->First();
1303 while(pCChild!=NULL)
1305 if( pCChild->GetState()==SC_CAS_VIRGIN )
1306 break;
1307 pCChild=(const ScChangeActionContent*)pActionTable->Next();
1310 if(pCChild==NULL) return TRUE;
1312 SvLBoxEntry* pOriginal=InsertChangeActionContent(pCChild,pParent,RD_SPECIAL_CONTENT);
1313 if(pOriginal!=NULL)
1315 bTheTestFlag=FALSE;
1316 ScRedlinData *pParentData=(ScRedlinData *)(pOriginal->GetUserData());
1317 pParentData->pData=(void *)pScChangeAction;
1318 pParentData->nActionNo=pScChangeAction->GetActionNumber();
1319 pParentData->bIsAcceptable=pScChangeAction->IsRejectable(); // select old value
1320 pParentData->bIsRejectable=FALSE;
1321 pParentData->bDisabled=FALSE;
1323 while(pCChild!=NULL)
1325 if(pCChild->GetState()==SC_CAS_VIRGIN)
1327 pEntry=InsertChangeActionContent(pCChild,pParent,RD_SPECIAL_NONE);
1329 if(pEntry!=NULL)
1330 bTheTestFlag=FALSE;
1332 pCChild=(const ScChangeActionContent*)pActionTable->Next();
1335 if ( !bParentInserted )
1337 pEntry=InsertChangeActionContent((const ScChangeActionContent*)
1338 pScChangeAction,pParent,RD_SPECIAL_NONE);
1340 if(pEntry!=NULL)
1342 bTheTestFlag=FALSE;
1343 ScRedlinData *pParentData=(ScRedlinData *)(pEntry->GetUserData());
1344 pParentData->pData=(void *)pScChangeAction;
1345 pParentData->nActionNo=pScChangeAction->GetActionNumber();
1346 pParentData->bIsAcceptable=pScChangeAction->IsClickable();
1347 pParentData->bIsRejectable=FALSE;
1348 pParentData->bDisabled=FALSE;
1352 return bTheTestFlag;
1356 BOOL ScAcceptChgDlg::InsertAcceptedORejected(SvLBoxEntry* pParent)
1358 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1359 BOOL bTheTestFlag=TRUE;
1361 ScChangeActionState eState = SC_CAS_VIRGIN;
1362 String aString=pTheView->GetEntryText( pParent);
1363 String a2String=aString.Copy(0,aStrAllAccepted.Len());
1364 if(a2String==aStrAllAccepted)
1366 eState=SC_CAS_ACCEPTED;
1368 else
1370 a2String=aString.Copy(0,aStrAllRejected.Len());
1371 if(a2String==aStrAllRejected)
1373 eState=SC_CAS_REJECTED;
1377 ScChangeAction* pScChangeAction=pChanges->GetFirst();
1378 while(pScChangeAction!=NULL)
1380 if(pScChangeAction->GetState()==eState &&
1381 InsertFilteredAction(pScChangeAction,eState,pParent)!=NULL)
1382 bTheTestFlag=FALSE;
1383 pScChangeAction=pScChangeAction->GetNext();
1385 return bTheTestFlag;
1388 BOOL ScAcceptChgDlg::InsertChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
1390 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1391 BOOL bTheTestFlag=TRUE;
1392 SvLBoxEntry* pEntry=NULL;
1393 const ScChangeAction* pChild=(const ScChangeAction*)pActionTable->First();
1394 while(pChild!=NULL)
1396 pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,FALSE,TRUE);
1398 if(pEntry!=NULL)
1400 bTheTestFlag=FALSE;
1402 ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1403 pEntryData->bIsRejectable=FALSE;
1404 pEntryData->bIsAcceptable=FALSE;
1405 pEntryData->bDisabled=TRUE;
1407 if(pChild->IsDialogParent())
1410 //pEntry->EnableChildsOnDemand(TRUE);
1411 Expand(pChanges,pChild,pEntry);
1414 pChild=pActionTable->Next();
1416 return bTheTestFlag;
1418 BOOL ScAcceptChgDlg::InsertDeletedChilds(const ScChangeAction* pScChangeAction,
1419 ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
1421 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1422 BOOL bTheTestFlag=TRUE;
1423 SvLBoxEntry* pEntry=NULL;
1424 ScChangeActionTable aDelActionTable;
1425 const ScChangeAction* pChild=(const ScChangeAction*)pActionTable->First();
1427 while(pChild!=NULL)
1430 if(pScChangeAction!=pChild)
1431 pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,FALSE,TRUE);
1432 else
1433 pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,TRUE,TRUE);
1435 if(pEntry!=NULL)
1437 ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1438 pEntryData->bIsRejectable=FALSE;
1439 pEntryData->bIsAcceptable=FALSE;
1440 pEntryData->bDisabled=TRUE;
1442 bTheTestFlag=FALSE;
1443 if ( pChild->IsDialogParent() )
1445 Expand(pChanges,pChild,pEntry);
1447 pChanges->GetDependents((ScChangeAction*) pChild,aDelActionTable);
1448 if(aDelActionTable.First()!=NULL)
1450 pEntry->EnableChildsOnDemand(TRUE);
1452 aDelActionTable.Clear();
1456 pChild=pActionTable->Next();
1458 return bTheTestFlag;
1461 BOOL ScAcceptChgDlg::Expand(ScChangeTrack* pChanges,const ScChangeAction* pScChangeAction,
1462 SvLBoxEntry* pEntry,BOOL bFilter)
1464 BOOL bTheTestFlag=TRUE;
1466 if(pChanges!=NULL &&pEntry!=NULL &&pScChangeAction!=NULL)
1468 ScChangeActionTable aActionTable;
1470 GetDependents( pScChangeAction,aActionTable,pEntry);
1472 switch(pScChangeAction->GetType())
1474 case SC_CAT_CONTENT:
1476 InsertContentChilds(&aActionTable,pEntry);
1477 bTheTestFlag=!bHasFilterEntry;
1478 break;
1480 case SC_CAT_DELETE_COLS:
1481 case SC_CAT_DELETE_ROWS:
1482 case SC_CAT_DELETE_TABS:
1484 InsertDeletedChilds(pScChangeAction,&aActionTable,pEntry);
1485 bTheTestFlag=!bHasFilterEntry;
1486 break;
1488 default:
1490 if(!bFilter)
1491 bTheTestFlag=InsertChilds(&aActionTable,pEntry);
1492 break;
1495 aActionTable.Clear();
1497 return bTheTestFlag;
1500 IMPL_LINK( ScAcceptChgDlg, ExpandingHandle, SvxRedlinTable*, pTable )
1502 ScChangeTrack* pChanges=pDoc->GetChangeTrack();
1503 ScChangeAction* pScChangeAction=NULL;
1504 SetPointer(Pointer(POINTER_WAIT));
1505 if(pTable!=NULL && pChanges!=NULL)
1507 ScChangeActionTable aActionTable;
1508 SvLBoxEntry* pEntry=pTheView->GetHdlEntry();
1509 if(pEntry!=NULL)
1511 ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1512 if(pEntryData!=NULL)
1514 pScChangeAction=(ScChangeAction*) pEntryData->pData;
1517 if(pEntry->HasChildsOnDemand())
1519 BOOL bTheTestFlag=TRUE;
1520 pEntry->EnableChildsOnDemand(FALSE);
1521 pTheView->RemoveEntry(pTheView->FirstChild(pEntry));
1523 if(pEntryData!=NULL)
1525 pScChangeAction=(ScChangeAction*) pEntryData->pData;
1527 GetDependents( pScChangeAction,aActionTable,pEntry);
1529 switch(pScChangeAction->GetType())
1531 case SC_CAT_CONTENT:
1533 bTheTestFlag=InsertContentChilds(&aActionTable,pEntry);
1534 break;
1536 case SC_CAT_DELETE_COLS:
1537 case SC_CAT_DELETE_ROWS:
1538 case SC_CAT_DELETE_TABS:
1540 bTheTestFlag=InsertDeletedChilds(pScChangeAction,&aActionTable,pEntry);
1541 break;
1543 default:
1545 bTheTestFlag=InsertChilds(&aActionTable,pEntry);
1546 break;
1549 aActionTable.Clear();
1552 else
1554 bTheTestFlag=InsertAcceptedORejected(pEntry);
1556 if(bTheTestFlag) pTheView->InsertEntry(aStrNoEntry,NULL,Color(COL_GRAY),pEntry);
1561 SetPointer(Pointer(POINTER_ARROW));
1562 return (ULONG) TRUE;
1566 void ScAcceptChgDlg::AppendChanges(ScChangeTrack* pChanges,ULONG nStartAction,
1567 ULONG nEndAction, ULONG /* nPos */)
1569 if(pChanges!=NULL)
1571 DateTime aDateTime;
1572 SvLBoxEntry* pParent=NULL;
1573 const ScChangeAction* pScChangeAction=NULL;
1574 bAcceptEnableFlag=TRUE;
1575 bRejectEnableFlag=TRUE;
1576 SetPointer(Pointer(POINTER_WAIT));
1577 pTheView->SetUpdateMode(FALSE);
1579 ScChangeActionTable ActionTable;
1580 BOOL bTheFlag=FALSE;
1582 BOOL bFilterFlag=pTPFilter->IsDate()||pTPFilter->IsRange()||
1583 pTPFilter->IsAuthor()||pTPFilter->IsComment();
1585 bUseColor=bFilterFlag;
1587 for(ULONG i=nStartAction;i<=nEndAction;i++)
1589 pScChangeAction=pChanges->GetAction(i);
1590 if(pScChangeAction==NULL) continue;
1593 switch(pScChangeAction->GetState())
1595 case SC_CAS_VIRGIN:
1597 if(pScChangeAction->IsDialogRoot())
1599 if(pScChangeAction->IsDialogParent())
1600 pParent=InsertChangeAction(pScChangeAction,SC_CAS_VIRGIN);
1601 else
1602 pParent=InsertFilteredAction(pScChangeAction,SC_CAS_VIRGIN);
1604 else
1605 pParent=NULL;
1607 bTheFlag=TRUE;
1608 break;
1610 case SC_CAS_ACCEPTED:
1611 pParent=NULL;
1612 nAcceptCount++;
1613 break;
1615 case SC_CAS_REJECTED:
1616 pParent=NULL;
1617 nRejectCount++;
1618 break;
1621 if(pParent!=NULL && pScChangeAction->IsDialogParent())
1623 if(!bFilterFlag)
1625 pParent->EnableChildsOnDemand(TRUE);
1627 else
1629 BOOL bTestFlag=bHasFilterEntry;
1630 bHasFilterEntry=FALSE;
1631 if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
1632 pTheView->RemoveEntry(pParent);
1636 pScChangeAction=pScChangeAction->GetNext();
1639 if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
1640 bTheFlag=FALSE;
1642 pTPView->EnableAccept(bTheFlag);
1643 pTPView->EnableAcceptAll(bTheFlag);
1644 pTPView->EnableReject(bTheFlag);
1645 pTPView->EnableRejectAll(bTheFlag);
1647 pTheView->SetUpdateMode(TRUE);
1648 SetPointer(Pointer(POINTER_ARROW));
1652 void ScAcceptChgDlg::RemoveEntrys(ULONG nStartAction,ULONG nEndAction)
1655 pTheView->SetUpdateMode(FALSE);
1657 SvLBoxEntry* pEntry=pTheView->GetCurEntry();
1659 ScRedlinData *pEntryData=NULL;
1661 if(pEntry!=NULL)
1662 pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1664 ULONG nAction=0;
1665 if(pEntryData!=NULL)
1667 nAction=pEntryData->nActionNo;
1670 if(nAction>=nStartAction && nAction<=nEndAction)
1672 pTheView->SetCurEntry(pTheView->GetModel()->GetEntry(0));
1675 BOOL bRemove=FALSE;
1677 // MUST do it backwards, don't delete parents before children and GPF
1678 pEntry=pTheView->Last();
1679 while(pEntry!=NULL)
1681 bRemove=FALSE;
1682 pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1683 if(pEntryData!=NULL)
1685 nAction=pEntryData->nActionNo;
1687 if(nStartAction<=nAction && nAction<=nEndAction) bRemove=TRUE;
1691 SvLBoxEntry* pPrevEntry = pTheView->Prev(pEntry);
1693 if(bRemove)
1695 //delete pEntryData;
1696 pTheView->RemoveEntry(pEntry);
1698 pEntry=pPrevEntry;
1700 pTheView->SetUpdateMode(TRUE);
1704 void ScAcceptChgDlg::UpdateEntrys(ScChangeTrack* pChgTrack, ULONG nStartAction,ULONG nEndAction)
1706 pTheView->SetUpdateMode(FALSE);
1708 ULONG nPos=LIST_APPEND;
1710 BOOL bRemove=FALSE;
1712 SvLBoxEntry* pEntry=pTheView->First();
1713 SvLBoxEntry* pNextEntry = (pEntry ? pTheView->NextSibling(pEntry) : NULL);
1714 SvLBoxEntry* pLastEntry=NULL;
1715 while(pEntry!=NULL)
1717 bRemove=FALSE;
1718 ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1719 if(pEntryData!=NULL)
1721 ScChangeAction* pScChangeAction=
1722 (ScChangeAction*) pEntryData->pData;
1724 ULONG nAction=pScChangeAction->GetActionNumber();
1726 if(nStartAction<=nAction && nAction<=nEndAction) bRemove=TRUE;
1729 if(bRemove)
1731 nPos=pEntry->GetChildListPos();
1732 pTheView->RemoveEntry(pEntry);
1734 if(pLastEntry==NULL) pLastEntry=pTheView->First();
1735 if(pLastEntry!=NULL)
1737 pNextEntry=pTheView->Next(pLastEntry);
1739 if(pNextEntry==NULL)
1741 pNextEntry=pLastEntry;
1742 pLastEntry=NULL;
1745 else
1746 pNextEntry=NULL;
1749 else
1751 pLastEntry = pEntry;
1752 pNextEntry = pTheView->Next(pEntry);
1754 pEntry=pNextEntry;
1757 if(nStartAction==nEndAction)
1758 AppendChanges(pChgTrack,nStartAction,nEndAction,nPos);
1759 else
1760 AppendChanges(pChgTrack,nStartAction,nEndAction);
1762 pTheView->SetUpdateMode(TRUE);
1766 IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack*, pChgTrack)
1768 // if(bScAcceptChgDlgIsDead) return 0;
1770 ScChangeTrackMsgQueue& aMsgQueue= pChgTrack->GetMsgQueue();
1772 ScChangeTrackMsgInfo* pTrackInfo=aMsgQueue.Get();
1773 ULONG nStartAction;
1774 ULONG nEndAction;
1776 while(pTrackInfo!=NULL)
1778 nStartAction=pTrackInfo->nStartAction;
1779 nEndAction=pTrackInfo->nEndAction;
1781 if(!bIgnoreMsg)
1783 bNoSelection=TRUE;
1785 switch(pTrackInfo->eMsgType)
1787 case SC_CTM_APPEND: AppendChanges(pChgTrack,nStartAction,nEndAction);
1788 break;
1789 case SC_CTM_REMOVE: RemoveEntrys(nStartAction,nEndAction);
1790 break;
1791 case SC_CTM_PARENT:
1792 case SC_CTM_CHANGE: //bNeedsUpdate=TRUE;
1793 UpdateEntrys(pChgTrack,nStartAction,nEndAction);
1794 break;
1795 default:
1797 // added to avoid warnings
1801 delete pTrackInfo;
1802 pTrackInfo=aMsgQueue.Get();
1805 return 0;
1807 IMPL_LINK( ScAcceptChgDlg, ReOpenTimerHdl, Timer*, EMPTYARG )
1809 ScSimpleRefDlgWrapper::SetAutoReOpen(TRUE);
1810 aAcceptChgCtr.ShowFilterPage();
1811 RefHandle(NULL);
1813 return 0;
1816 IMPL_LINK( ScAcceptChgDlg, UpdateSelectionHdl, Timer*, EMPTYARG )
1818 ScTabView* pTabView = pViewData->GetView();
1820 BOOL bAcceptFlag = TRUE;
1821 BOOL bRejectFlag = TRUE;
1822 BOOL bContMark = FALSE;
1824 pTabView->DoneBlockMode(); // clears old marking
1825 SvLBoxEntry* pEntry = pTheView->FirstSelected();
1826 while( pEntry )
1828 ScRedlinData* pEntryData = (ScRedlinData*) pEntry->GetUserData();
1829 if( pEntryData )
1831 bRejectFlag &= pEntryData->bIsRejectable;
1832 bAcceptFlag &= pEntryData->bIsAcceptable;
1834 const ScChangeAction* pScChangeAction = (ScChangeAction*) pEntryData->pData;
1835 if( pScChangeAction && (pScChangeAction->GetType() != SC_CAT_DELETE_TABS) &&
1836 (!pEntryData->bDisabled || pScChangeAction->IsVisible()) )
1838 const ScBigRange& rBigRange = pScChangeAction->GetBigRange();
1839 if( rBigRange.IsValid( pDoc ) && IsActive() )
1841 BOOL bSetCursor = !pTheView->NextSelected( pEntry );
1842 pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark );
1843 bContMark = TRUE;
1847 else
1849 bAcceptFlag = FALSE;
1850 bRejectFlag = FALSE;
1852 bAcceptEnableFlag = bAcceptFlag;
1853 bRejectEnableFlag = bRejectFlag;
1855 pEntry = pTheView->NextSelected( pEntry );
1858 ScChangeTrack* pChanges = pDoc->GetChangeTrack();
1859 BOOL bEnable = pDoc->IsDocEditable() && pChanges && !pChanges->IsProtected();
1860 pTPView->EnableAccept( bAcceptFlag && bEnable );
1861 pTPView->EnableReject( bRejectFlag && bEnable );
1863 return 0;
1866 IMPL_LINK( ScAcceptChgDlg, CommandHdl, Control*, EMPTYARG )
1869 const CommandEvent aCEvt(pTheView->GetCommandEvent());
1871 if(aCEvt.GetCommand()==COMMAND_CONTEXTMENU)
1873 ScPopupMenu aPopup(ScResId(RID_POPUP_CHANGES));
1875 aPopup.SetMenuFlags(MENU_FLAG_HIDEDISABLEDENTRIES);
1877 SvLBoxEntry* pEntry=pTheView->GetCurEntry();
1878 if(pEntry!=NULL)
1880 pTheView->Select(pEntry);
1882 else
1884 aPopup.Deactivate();
1887 USHORT nSortedCol= pTheView->GetSortedCol();
1889 if(nSortedCol!=0xFFFF)
1891 USHORT nItemId=nSortedCol+SC_SUB_SORT+1;
1893 aPopup.CheckItem(nItemId);
1895 PopupMenu *pSubMenu = aPopup.GetPopupMenu(SC_SUB_SORT);
1896 if (pSubMenu)
1898 pSubMenu->CheckItem(nItemId);
1902 aPopup.EnableItem(SC_CHANGES_COMMENT,FALSE);
1904 if(pDoc->IsDocEditable() && pEntry!=NULL)
1906 ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1907 if(pEntryData!=NULL)
1909 ScChangeAction* pScChangeAction=
1910 (ScChangeAction*) pEntryData->pData;
1911 if(pScChangeAction!=NULL && !pTheView->GetParent(pEntry))
1912 aPopup.EnableItem(SC_CHANGES_COMMENT);
1916 USHORT nCommand=aPopup.Execute( this, GetPointerPosPixel() );
1919 if(nCommand)
1921 if(nCommand==SC_CHANGES_COMMENT)
1923 if(pEntry!=NULL)
1925 ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
1926 if(pEntryData!=NULL)
1928 ScChangeAction* pScChangeAction=
1929 (ScChangeAction*) pEntryData->pData;
1931 pViewData->GetDocShell()->ExecuteChangeCommentDialog( pScChangeAction, this,FALSE);
1935 else
1937 BOOL bSortDir=pTheView->GetSortDirection();
1938 USHORT nDialogCol=nCommand-SC_SUB_SORT-1;
1939 if(nSortedCol==nDialogCol) bSortDir=!bSortDir;
1940 pTheView->SortByCol(nDialogCol,bSortDir);
1942 SC_SUB_SORT
1943 SC_SORT_ACTION
1944 SC_SORT_POSITION
1945 SC_SORT_AUTHOR
1946 SC_SORT_DATE
1947 SC_SORT_COMMENT
1952 return 0;
1955 void ScAcceptChgDlg::Initialize(SfxChildWinInfo *pInfo)
1957 String aStr;
1958 if(pInfo!=NULL)
1960 if ( pInfo->aExtraString.Len() )
1962 xub_StrLen nPos = pInfo->aExtraString.Search(
1963 String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("AcceptChgDat:")));
1965 // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
1966 // er nicht vorhanden ist, liegt eine "altere Version vor
1967 if ( nPos != STRING_NOTFOUND )
1969 xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos);
1970 if ( n1 != STRING_NOTFOUND )
1972 xub_StrLen n2 = pInfo->aExtraString.Search(')', n1);
1973 if ( n2 != STRING_NOTFOUND )
1975 // Alignment-String herausschneiden
1976 aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1);
1977 pInfo->aExtraString.Erase(nPos, n2 - nPos + 1);
1978 aStr.Erase(0, n1-nPos+1);
1984 SfxModelessDialog::Initialize(pInfo);
1986 if ( aStr.Len())
1988 USHORT nCount=(USHORT)aStr.ToInt32();
1990 for(USHORT i=0;i<nCount;i++)
1992 xub_StrLen n1 = aStr.Search(';');
1993 aStr.Erase(0, n1+1);
1994 pTheView->SetTab(i,(USHORT)aStr.ToInt32(),MAP_PIXEL);
1999 //-------------------------------------------------------------------------
2001 void ScAcceptChgDlg::FillInfo(SfxChildWinInfo& rInfo) const
2003 SfxModelessDialog::FillInfo(rInfo);
2004 rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "AcceptChgDat:(" ));
2006 USHORT nCount=pTheView->TabCount();
2008 rInfo.aExtraString += String::CreateFromInt32(nCount);
2009 rInfo.aExtraString += ';';
2010 for(USHORT i=0;i<nCount;i++)
2012 rInfo.aExtraString += String::CreateFromInt32(pTheView->GetTab(i));
2013 rInfo.aExtraString += ';';
2015 rInfo.aExtraString += ')';
2018 void ScAcceptChgDlg::InitFilter()
2020 if(pTPFilter->IsDate()||pTPFilter->IsRange()||
2021 pTPFilter->IsAuthor()||pTPFilter->IsComment())
2023 pTheView->SetFilterDate(pTPFilter->IsDate());
2024 pTheView->SetDateTimeMode(pTPFilter->GetDateMode());
2025 pTheView->SetFirstDate(pTPFilter->GetFirstDate());
2026 pTheView->SetLastDate(pTPFilter->GetLastDate());
2027 pTheView->SetFirstTime(pTPFilter->GetFirstTime());
2028 pTheView->SetLastTime(pTPFilter->GetLastTime());
2029 pTheView->SetFilterAuthor(pTPFilter->IsAuthor());
2030 pTheView->SetAuthor(pTPFilter->GetSelectedAuthor());
2032 pTheView->SetFilterComment(pTPFilter->IsComment());
2034 utl::SearchParam aSearchParam( pTPFilter->GetComment(),
2035 utl::SearchParam::SRCH_REGEXP,FALSE,FALSE,FALSE );
2037 pTheView->SetCommentParams(&aSearchParam);
2039 pTheView->UpdateFilterTest();
2043 //UNUSED2008-05 void ScAcceptChgDlg::SetMyStaticData()
2044 //UNUSED2008-05 {
2045 //UNUSED2008-05 }
2047 IMPL_LINK( ScAcceptChgDlg, FilterModified, SvxTPFilter*, EMPTYARG )
2049 return 0;
2052 #define CALC_DATE 3
2053 #define CALC_POS 1
2055 IMPL_LINK( ScAcceptChgDlg, ColCompareHdl, SvSortData*, pSortData )
2057 StringCompare eCompare=COMPARE_EQUAL;
2058 SCCOL nSortCol= static_cast<SCCOL>(pTheView->GetSortedCol());
2060 if(pSortData)
2062 SvLBoxEntry* pLeft = (SvLBoxEntry*)(pSortData->pLeft );
2063 SvLBoxEntry* pRight = (SvLBoxEntry*)(pSortData->pRight );
2065 if(CALC_DATE==nSortCol)
2067 RedlinData *pLeftData=(RedlinData *)(pLeft->GetUserData());
2068 RedlinData *pRightData=(RedlinData *)(pRight->GetUserData());
2070 if(pLeftData!=NULL && pRightData!=NULL)
2072 if(pLeftData->aDateTime < pRightData->aDateTime)
2074 eCompare=COMPARE_LESS;
2076 else if(pLeftData->aDateTime > pRightData->aDateTime)
2078 eCompare=COMPARE_GREATER;
2080 return eCompare;
2083 else if(CALC_POS==nSortCol)
2085 ScRedlinData *pLeftData=(ScRedlinData *)(pLeft->GetUserData());
2086 ScRedlinData *pRightData=(ScRedlinData *)(pRight->GetUserData());
2088 if(pLeftData!=NULL && pRightData!=NULL)
2090 eCompare=COMPARE_GREATER;
2092 if(pLeftData->nTable < pRightData->nTable)
2094 eCompare=COMPARE_LESS;
2096 else if(pLeftData->nTable == pRightData->nTable)
2098 if(pLeftData->nRow < pRightData->nRow)
2100 eCompare=COMPARE_LESS;
2102 else if(pLeftData->nRow == pRightData->nRow)
2104 if(pLeftData->nCol < pRightData->nCol)
2106 eCompare=COMPARE_LESS;
2108 else if(pLeftData->nCol == pRightData->nCol)
2110 eCompare=COMPARE_EQUAL;
2115 return eCompare;
2119 SvLBoxItem* pLeftItem = pTheView->GetEntryAtPos( pLeft, static_cast<sal_uInt16>(nSortCol));
2120 SvLBoxItem* pRightItem = pTheView->GetEntryAtPos( pRight, static_cast<sal_uInt16>(nSortCol));
2122 if(pLeftItem != NULL && pRightItem != NULL)
2124 USHORT nLeftKind=pLeftItem->IsA();
2125 USHORT nRightKind=pRightItem->IsA();
2127 if(nRightKind == SV_ITEM_ID_LBOXSTRING &&
2128 nLeftKind == SV_ITEM_ID_LBOXSTRING )
2130 eCompare= (StringCompare) ScGlobal::GetCaseCollator()->compareString(
2131 ((SvLBoxString*)pLeftItem)->GetText(),
2132 ((SvLBoxString*)pRightItem)->GetText());
2134 if(eCompare==COMPARE_EQUAL) eCompare=COMPARE_LESS;
2140 return eCompare;