1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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"
50 #include "reffact.hxx"
51 #include "document.hxx"
53 #include "scresid.hxx"
54 #include "globstr.hrc"
55 #include "acredlin.hrc"
56 #include "simpref.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
)
82 #define RD_SPECIAL_NONE 0
83 #define RD_SPECIAL_CONTENT 1
84 #define RD_SPECIAL_VISCONTENT 2
86 //============================================================================
88 //----------------------------------------------------------------------------
90 ScRedlinData::ScRedlinData()
93 nInfo
=RD_SPECIAL_NONE
;
104 ScRedlinData::~ScRedlinData()
106 nInfo
=RD_SPECIAL_NONE
;
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
))
147 // bScAcceptChgDlgIsDead=FALSE;
153 bAcceptEnableFlag
=TRUE
;
154 bRejectEnableFlag
=TRUE
;
155 bHasFilterEntry
=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();
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);
196 aAcceptChgCtr
.SetMinSizeHdl( LINK( this, ScAcceptChgDlg
, MinSizeHandle
));
199 SvLBoxEntry
* pEntry
=pTheView
->First();
202 pTheView
->Select(pEntry
);
205 ScAcceptChgDlg::~ScAcceptChgDlg()
207 // bScAcceptChgDlgIsDead=TRUE;
209 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
214 pChanges
->SetModifiedLink(aLink
);
218 void ScAcceptChgDlg::ReInit(ScViewData
* ptrViewData
)
220 pViewData
=ptrViewData
;
223 pDoc
=ptrViewData
->GetDocument();
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)
245 ScChangeTrack
* pChanges
= pDoc
->GetChangeTrack();
247 pChanges
->SetModifiedLink( LINK( this, ScAcceptChgDlg
, ChgTrackModHdl
) );
251 void __EXPORT
ScAcceptChgDlg::Init()
256 DBG_ASSERT( pViewData
&& pDoc
, "ViewData oder Document nicht gefunden!" );
258 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
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();
289 pTPFilter
->SelectAuthor(aString
);
290 if(pTPFilter
->GetSelectedAuthor()!=aString
)
292 pTPFilter
->InsertAuthor(aString
);
293 pTPFilter
->SelectAuthor(aString
);
298 pTPFilter
->SelectedAuthorPos(0);
301 pTPFilter
->CheckRange(aChangeViewSet
.HasRange());
303 ScRange
* pRangeEntry
=aChangeViewSet
.GetTheRangeList().GetObject(0);
304 aRangeList
=aChangeViewSet
.GetTheRangeList();
306 if(pRangeEntry
!=NULL
)
309 pRangeEntry
->Format( aRefStr
, ABS_DREF3D
, pDoc
);
310 pTPFilter
->SetRange(aRefStr
);
314 aAcceptChgCtr
.SetPosPixel(aPoint
);
320 void ScAcceptChgDlg::ClearView()
324 pTheView
->SetUpdateMode(FALSE
);
327 pTheView
->SetUpdateMode(TRUE
);
330 String
* ScAcceptChgDlg::MakeTypeString(ScChangeActionType 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;
361 BOOL
ScAcceptChgDlg::IsValidAction(const ScChangeAction
* pScChangeAction
)
363 if(pScChangeAction
==NULL
) return FALSE
;
367 ScRange aRef
=pScChangeAction
->GetBigRange().MakeRange();
368 String aUser
=pScChangeAction
->GetUser();
369 DateTime aDateTime
=pScChangeAction
->GetDateTime();
371 ScChangeActionType eType
=pScChangeAction
->GetType();
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
);
387 pScChangeAction
->GetDescription( aDesc
, pDoc
,!pScChangeAction
->IsMasterDelete());
392 aComment
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
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
)
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
;
435 ScRange aRef
=pScChangeAction
->GetBigRange().MakeRange();
436 String aUser
=pScChangeAction
->GetUser();
437 DateTime aDateTime
=pScChangeAction
->GetDateTime();
440 ScChangeActionType eType
=pScChangeAction
->GetType();
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
;
466 aString
=*MakeTypeString(eType
);
467 pScChangeAction
->GetDescription( aDesc
, pDoc
, TRUE
);
472 aString
=*MakeTypeString(eType
);
476 pScChangeAction
->GetDescription( aDesc
, pDoc
,TRUE
);
477 pNewData
->bDisabled
=TRUE
;
478 pNewData
->bIsRejectable
=FALSE
;
481 pScChangeAction
->GetDescription( aDesc
, pDoc
,!pScChangeAction
->IsMasterDelete());
486 pScChangeAction
->GetRefString(aRefStr
, pDoc
, TRUE
);
492 if(!pChanges
->IsGenerated(pScChangeAction
->GetActionNumber()))
497 aString
+=ScGlobal::pLocaleData
->getDate(aDateTime
);
499 aString
+=ScGlobal::pLocaleData
->getTime(aDateTime
);
510 String aComment
=pScChangeAction
->GetComment();
511 aComment
.EraseAllChars('\n');
514 aComment
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
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
;
541 else if(!bIsGenerated
)
543 bHasFilterEntry
=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
);
569 pEntry
=pTheView
->InsertEntry(aString
,pNewData
,pParent
,nPos
);
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
;
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
)
611 else if(pScChangeAction
->GetState()==eState
&& !bIsGenerated
)
621 ScChangeActionType eType
=pScChangeAction
->GetType();
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
;
648 aString
=*MakeTypeString(eType
);
649 pScChangeAction
->GetDescription( aDesc
, pDoc
, TRUE
);
654 aString
=*MakeTypeString(eType
);
658 pScChangeAction
->GetDescription( aDesc
, pDoc
,TRUE
);
659 pNewData
->bDisabled
=TRUE
;
660 pNewData
->bIsRejectable
=FALSE
;
663 pScChangeAction
->GetDescription( aDesc
, pDoc
,!pScChangeAction
->IsMasterDelete());
668 pScChangeAction
->GetRefString(aRefStr
, pDoc
, TRUE
);
676 aString
+=ScGlobal::pLocaleData
->getDate(aDateTime
);
678 aString
+=ScGlobal::pLocaleData
->getTime(aDateTime
);
687 String aComment
=pScChangeAction
->GetComment();
688 aComment
.EraseAllChars('\n');
691 aComment
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
695 if(pTheView
->IsValidComment(&aComment
))
698 pEntry
=pTheView
->InsertEntry(aString
,pNewData
,pParent
,nPos
);
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());
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
)
739 else if(!bIsGenerated
)
748 if(nSpecial
==RD_SPECIAL_CONTENT
)
750 pScChangeAction
->GetOldString(a2String
);
751 if(a2String
.Len()==0) a2String
=aStrEmpty
;
757 aDesc
=aStrChildOrgContent
;
758 aDesc
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
762 pScChangeAction
->GetNewString(a2String
);
763 if(a2String
.Len()==0)
775 aDesc
=aStrChildContent
;
781 pScChangeAction
->GetRefString(aRefStr
, pDoc
, TRUE
);
790 aString
+=ScGlobal::pLocaleData
->getDate(aDateTime
);
792 aString
+=ScGlobal::pLocaleData
->getTime(aDateTime
);
800 String aComment
=pScChangeAction
->GetComment();
801 aComment
.EraseAllChars('\n');
805 aComment
.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
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
);
830 pEntry
=pTheView
->InsertEntry(aString
,pNewData
,Color(COL_LIGHTBLUE
),pParent
);
834 long ScAcceptChgDlg::PreNotify( NotifyEvent
& rNEvt
)
836 if(rNEvt
.GetType()==EVENT_GETFOCUS
&& bNeedsUpdate
)
843 return SfxModelessDialog::PreNotify(rNEvt
);
847 void ScAcceptChgDlg::UpdateView()
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
;
865 pChanges
=pDoc
->GetChangeTrack();
868 pScChangeAction
=pChanges
->GetFirst();
871 ScChangeActionTable ActionTable
;
874 while(pScChangeAction
!=NULL
)
876 bHasFilterEntry
=FALSE
;
877 switch(pScChangeAction
->GetState())
881 if(pScChangeAction
->IsDialogRoot())
883 if(pScChangeAction
->IsDialogParent())
884 pParent
=InsertChangeAction(pScChangeAction
,SC_CAS_VIRGIN
);
886 pParent
=InsertFilteredAction(pScChangeAction
,SC_CAS_VIRGIN
);
894 case SC_CAS_ACCEPTED
:
899 case SC_CAS_REJECTED
:
905 if(pParent
!=NULL
&& pScChangeAction
->IsDialogParent())
909 pParent
->EnableChildsOnDemand(TRUE
);
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()) )
926 pTPView
->EnableAccept(bTheFlag
);
927 pTPView
->EnableAcceptAll(bTheFlag
);
928 pTPView
->EnableReject(bTheFlag
);
929 pTPView
->EnableRejectAll(bTheFlag
);
933 pParent
=pTheView
->InsertEntry(
934 aStrAllAccepted
, static_cast< RedlinData
* >(NULL
),
935 static_cast< SvLBoxEntry
* >(NULL
));
936 pParent
->EnableChildsOnDemand(TRUE
);
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();
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
)
972 SetOutputSizePixel(MinSize
);
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
);
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());
999 pWin
->SetText(GetText());
1000 pWnd
->StartRefInput();
1005 IMPL_LINK( ScAcceptChgDlg
, RefInfoHandle
, String
*, pResult
)
1009 // bSimpleRefDlgStarted=FALSE;
1010 ScSimpleRefDlgWrapper::SetAutoReOpen(TRUE
);
1012 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
1015 pTPFilter
->SetRange(*pResult
);
1016 FilterHandle(pTPFilter
);
1018 nId
= ScSimpleRefDlgWrapper::GetChildWindowId();
1019 ScSimpleRefDlgWrapper
* pWnd
= (ScSimpleRefDlgWrapper
*)pViewFrm
->GetChildWindow( nId
);
1023 Window
* pWin
=pWnd
->GetWindow();
1024 Size aWinSize
=pWin
->GetSizePixel();
1025 aWinSize
.Width()=GetSizePixel().Width();
1026 SetPosSizePixel(pWin
->GetPosPixel(),aWinSize
);
1029 nId
= ScAcceptChgDlgWrapper::GetChildWindowId();
1030 pViewFrm
->ShowChildWindow( nId
, TRUE
);
1034 nId
= ScAcceptChgDlgWrapper::GetChildWindowId();
1035 pViewFrm
->SetChildWindow( nId
, FALSE
);
1040 IMPL_LINK( ScAcceptChgDlg
, FilterHandle
, SvxTPFilter
*, pRef
)
1046 aRangeList
.Parse(pTPFilter
->GetRange(),pDoc
);
1052 IMPL_LINK( ScAcceptChgDlg
, RejectHandle
, SvxTPView
*, pRef
)
1054 SetPointer(Pointer(POINTER_WAIT
));
1057 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1061 SvLBoxEntry
* pEntry
=pTheView
->FirstSelected();
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();
1086 SetPointer(Pointer(POINTER_ARROW
));
1091 IMPL_LINK( ScAcceptChgDlg
, AcceptHandle
, SvxTPView
*, pRef
)
1093 SetPointer(Pointer(POINTER_WAIT
));
1095 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1099 SvLBoxEntry
* pEntry
=pTheView
->FirstSelected();
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
);
1115 pChanges
->SelectContent(pScChangeAction
);
1119 pChanges
->Accept(pScChangeAction
);
1121 pEntry
= pTheView
->NextSelected(pEntry
);
1123 ScDocShell
* pDocSh
=pViewData
->GetDocShell();
1124 pDocSh
->PostPaintExtras();
1125 pDocSh
->PostPaintGridAll();
1126 pDocSh
->SetDocumentModified();
1135 void ScAcceptChgDlg::RejectFiltered()
1137 if(pDoc
==NULL
) return;
1138 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1139 const ScChangeAction
* pScChangeAction
=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
;
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
));
1186 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1189 if(pTPFilter
->IsDate()||pTPFilter
->IsAuthor()||pTPFilter
->IsRange()||pTPFilter
->IsComment())
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();
1207 SetPointer(Pointer(POINTER_ARROW
));
1214 IMPL_LINK( ScAcceptChgDlg
, AcceptAllHandle
, SvxTPView
*, EMPTYARG
)
1216 SetPointer(Pointer(POINTER_WAIT
));
1219 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1222 if(pTPFilter
->IsDate()||pTPFilter
->IsAuthor()||pTPFilter
->IsRange()||pTPFilter
->IsComment())
1228 pChanges
->AcceptAll();
1230 ScDocShell
* pDocSh
=pViewData
->GetDocShell();
1231 pDocSh
->PostPaintExtras();
1232 pDocSh
->PostPaintGridAll();
1233 pDocSh
->SetDocumentModified();
1238 SetPointer(Pointer(POINTER_ARROW
));
1243 IMPL_LINK( ScAcceptChgDlg
, SelectHandle
, SvxRedlinTable
*, EMPTYARG
)
1247 aSelectionTimer
.Start();
1253 void ScAcceptChgDlg::GetDependents( const ScChangeAction
* pScChangeAction
,
1254 ScChangeActionTable
& aActionTable
,
1255 SvLBoxEntry
* pEntry
)
1257 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1259 SvLBoxEntry
* pParent
=pTheView
->GetParent(pEntry
);
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());
1271 pChanges
->GetDependents((ScChangeAction
*) pScChangeAction
,
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
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
)
1307 pCChild
=(const ScChangeActionContent
*)pActionTable
->Next();
1310 if(pCChild
==NULL
) return TRUE
;
1312 SvLBoxEntry
* pOriginal
=InsertChangeActionContent(pCChild
,pParent
,RD_SPECIAL_CONTENT
);
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
);
1332 pCChild
=(const ScChangeActionContent
*)pActionTable
->Next();
1335 if ( !bParentInserted
)
1337 pEntry
=InsertChangeActionContent((const ScChangeActionContent
*)
1338 pScChangeAction
,pParent
,RD_SPECIAL_NONE
);
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
;
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
)
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();
1396 pEntry
=InsertChangeAction(pChild
,SC_CAS_VIRGIN
,pParent
,FALSE
,TRUE
);
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();
1430 if(pScChangeAction
!=pChild
)
1431 pEntry
=InsertChangeAction(pChild
,SC_CAS_VIRGIN
,pParent
,FALSE
,TRUE
);
1433 pEntry
=InsertChangeAction(pChild
,SC_CAS_VIRGIN
,pParent
,TRUE
,TRUE
);
1437 ScRedlinData
*pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
1438 pEntryData
->bIsRejectable
=FALSE
;
1439 pEntryData
->bIsAcceptable
=FALSE
;
1440 pEntryData
->bDisabled
=TRUE
;
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
;
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
;
1491 bTheTestFlag
=InsertChilds(&aActionTable
,pEntry
);
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();
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
);
1536 case SC_CAT_DELETE_COLS
:
1537 case SC_CAT_DELETE_ROWS
:
1538 case SC_CAT_DELETE_TABS
:
1540 bTheTestFlag
=InsertDeletedChilds(pScChangeAction
,&aActionTable
,pEntry
);
1545 bTheTestFlag
=InsertChilds(&aActionTable
,pEntry
);
1549 aActionTable
.Clear();
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 */)
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())
1597 if(pScChangeAction
->IsDialogRoot())
1599 if(pScChangeAction
->IsDialogParent())
1600 pParent
=InsertChangeAction(pScChangeAction
,SC_CAS_VIRGIN
);
1602 pParent
=InsertFilteredAction(pScChangeAction
,SC_CAS_VIRGIN
);
1610 case SC_CAS_ACCEPTED
:
1615 case SC_CAS_REJECTED
:
1621 if(pParent
!=NULL
&& pScChangeAction
->IsDialogParent())
1625 pParent
->EnableChildsOnDemand(TRUE
);
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()) )
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
;
1662 pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
1665 if(pEntryData
!=NULL
)
1667 nAction
=pEntryData
->nActionNo
;
1670 if(nAction
>=nStartAction
&& nAction
<=nEndAction
)
1672 pTheView
->SetCurEntry(pTheView
->GetModel()->GetEntry(0));
1677 // MUST do it backwards, don't delete parents before children and GPF
1678 pEntry
=pTheView
->Last();
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
);
1695 //delete pEntryData;
1696 pTheView
->RemoveEntry(pEntry
);
1700 pTheView
->SetUpdateMode(TRUE
);
1704 void ScAcceptChgDlg::UpdateEntrys(ScChangeTrack
* pChgTrack
, ULONG nStartAction
,ULONG nEndAction
)
1706 pTheView
->SetUpdateMode(FALSE
);
1708 ULONG nPos
=LIST_APPEND
;
1712 SvLBoxEntry
* pEntry
=pTheView
->First();
1713 SvLBoxEntry
* pNextEntry
= (pEntry
? pTheView
->NextSibling(pEntry
) : NULL
);
1714 SvLBoxEntry
* pLastEntry
=NULL
;
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
;
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
;
1751 pLastEntry
= pEntry
;
1752 pNextEntry
= pTheView
->Next(pEntry
);
1757 if(nStartAction
==nEndAction
)
1758 AppendChanges(pChgTrack
,nStartAction
,nEndAction
,nPos
);
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();
1776 while(pTrackInfo
!=NULL
)
1778 nStartAction
=pTrackInfo
->nStartAction
;
1779 nEndAction
=pTrackInfo
->nEndAction
;
1785 switch(pTrackInfo
->eMsgType
)
1787 case SC_CTM_APPEND
: AppendChanges(pChgTrack
,nStartAction
,nEndAction
);
1789 case SC_CTM_REMOVE
: RemoveEntrys(nStartAction
,nEndAction
);
1792 case SC_CTM_CHANGE
: //bNeedsUpdate=TRUE;
1793 UpdateEntrys(pChgTrack
,nStartAction
,nEndAction
);
1797 // added to avoid warnings
1802 pTrackInfo
=aMsgQueue
.Get();
1807 IMPL_LINK( ScAcceptChgDlg
, ReOpenTimerHdl
, Timer
*, EMPTYARG
)
1809 ScSimpleRefDlgWrapper::SetAutoReOpen(TRUE
);
1810 aAcceptChgCtr
.ShowFilterPage();
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();
1828 ScRedlinData
* pEntryData
= (ScRedlinData
*) pEntry
->GetUserData();
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
);
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
);
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();
1880 pTheView
->Select(pEntry
);
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
);
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() );
1921 if(nCommand
==SC_CHANGES_COMMENT
)
1925 ScRedlinData
*pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
1926 if(pEntryData
!=NULL
)
1928 ScChangeAction
* pScChangeAction
=
1929 (ScChangeAction
*) pEntryData
->pData
;
1931 pViewData
->GetDocShell()->ExecuteChangeCommentDialog( pScChangeAction
, this,FALSE
);
1937 BOOL bSortDir
=pTheView
->GetSortDirection();
1938 USHORT nDialogCol
=nCommand
-SC_SUB_SORT
-1;
1939 if(nSortedCol
==nDialogCol
) bSortDir
=!bSortDir
;
1940 pTheView
->SortByCol(nDialogCol
,bSortDir
);
1955 void ScAcceptChgDlg::Initialize(SfxChildWinInfo
*pInfo
)
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
);
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()
2047 IMPL_LINK( ScAcceptChgDlg
, FilterModified
, SvxTPFilter
*, EMPTYARG
)
2055 IMPL_LINK( ScAcceptChgDlg
, ColCompareHdl
, SvSortData
*, pSortData
)
2057 StringCompare eCompare
=COMPARE_EQUAL
;
2058 SCCOL nSortCol
= static_cast<SCCOL
>(pTheView
->GetSortedCol());
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
;
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
;
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::pCaseCollator
->compareString(
2131 ((SvLBoxString
*)pLeftItem
)->GetText(),
2132 ((SvLBoxString
*)pRightItem
)->GetText());
2134 if(eCompare
==COMPARE_EQUAL
) eCompare
=COMPARE_LESS
;