1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <comphelper/string.hxx>
22 #include <svl/undo.hxx>
23 #include <unotools/textsearch.hxx>
24 #include <unotools/localedatawrapper.hxx>
25 #include <unotools/collatorwrapper.hxx>
26 #include <vcl/msgbox.hxx>
27 #include <sfx2/app.hxx>
28 #include <sfx2/viewfrm.hxx>
30 #include "acredlin.hxx"
32 #include "reffact.hxx"
33 #include "document.hxx"
35 #include "scresid.hxx"
36 #include "globstr.hrc"
37 #include "acredlin.hrc"
38 #include "simpref.hxx"
40 #include "popmenu.hxx"
41 #include "tabvwsh.hxx"
43 // defines -------------------------------------------------------------------
45 #define ABS_SREF SCA_VALID \
46 | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
47 #define ABS_DREF ABS_SREF \
48 | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
49 #define ABS_DREF3D ABS_DREF | SCA_TAB_3D
51 #define RD_SPECIAL_NONE 0
52 #define RD_SPECIAL_CONTENT 1
53 #define RD_SPECIAL_VISCONTENT 2
55 //============================================================================
57 //----------------------------------------------------------------------------
58 ScRedlinData::ScRedlinData()
61 nInfo
=RD_SPECIAL_NONE
;
72 ScRedlinData::~ScRedlinData()
74 nInfo
=RD_SPECIAL_NONE
;
82 //============================================================================
83 // class ScAcceptChgDlg
84 //----------------------------------------------------------------------------
85 ScAcceptChgDlg::ScAcceptChgDlg(SfxBindings
* pB
, SfxChildWindow
* pCW
, Window
* pParent
,
86 ScViewData
* ptrViewData
)
87 : SfxModelessDialog(pB
, pCW
, pParent
,
88 "AcceptRejectChangesDialog", "svx/ui/acceptrejectchangesdialog.ui"),
89 pViewData ( ptrViewData
),
90 pDoc ( ptrViewData
->GetDocument() ),
91 aLocalRangeName ( *(pDoc
->GetRangeName()) ),
92 aStrInsertCols (SC_RESSTR(STR_CHG_INSERT_COLS
)),
93 aStrInsertRows (SC_RESSTR(STR_CHG_INSERT_ROWS
)),
94 aStrInsertTabs (SC_RESSTR(STR_CHG_INSERT_TABS
)),
95 aStrDeleteCols (SC_RESSTR(STR_CHG_DELETE_COLS
)),
96 aStrDeleteRows (SC_RESSTR(STR_CHG_DELETE_ROWS
)),
97 aStrDeleteTabs (SC_RESSTR(STR_CHG_DELETE_TABS
)),
98 aStrMove (SC_RESSTR(STR_CHG_MOVE
)),
99 aStrContent (SC_RESSTR(STR_CHG_CONTENT
)),
100 aStrReject (SC_RESSTR(STR_CHG_REJECT
)),
101 aStrAllAccepted (SC_RESSTR(STR_CHG_ACCEPTED
)),
102 aStrAllRejected (SC_RESSTR(STR_CHG_REJECTED
)),
103 aStrNoEntry (SC_RESSTR(STR_CHG_NO_ENTRY
)),
104 aStrContentWithChild (SC_RESSTR(STR_CHG_CONTENT_WITH_CHILD
)),
105 aStrChildContent (SC_RESSTR(STR_CHG_CHILD_CONTENT
)),
106 aStrChildOrgContent (SC_RESSTR(STR_CHG_CHILD_ORGCONTENT
)),
107 aStrEmpty (SC_RESSTR(STR_CHG_EMPTY
)),
109 bAcceptEnableFlag(true),
110 bRejectEnableFlag(true),
114 bHasFilterEntry(false),
117 m_pAcceptChgCtr
= new SvxAcceptChgCtr(get_content_area());
120 aReOpenTimer
.SetTimeout(50);
121 aReOpenTimer
.SetTimeoutHdl(LINK( this, ScAcceptChgDlg
, ReOpenTimerHdl
));
123 pTPFilter
=m_pAcceptChgCtr
->GetFilterPage();
124 pTPView
=m_pAcceptChgCtr
->GetViewPage();
125 pTheView
=pTPView
->GetTableControl();
126 aSelectionTimer
.SetTimeout(100);
127 aSelectionTimer
.SetTimeoutHdl(LINK( this, ScAcceptChgDlg
, UpdateSelectionHdl
));
129 pTPFilter
->SetReadyHdl(LINK( this, ScAcceptChgDlg
, FilterHandle
));
130 pTPFilter
->SetRefHdl(LINK( this, ScAcceptChgDlg
, RefHandle
));
131 pTPFilter
->SetModifyHdl(LINK( this, ScAcceptChgDlg
, FilterModified
));
132 pTPFilter
->HideRange(false);
133 pTPView
->InsertCalcHeader();
134 pTPView
->SetRejectClickHdl( LINK( this, ScAcceptChgDlg
,RejectHandle
));
135 pTPView
->SetAcceptClickHdl( LINK(this, ScAcceptChgDlg
, AcceptHandle
));
136 pTPView
->SetRejectAllClickHdl( LINK( this, ScAcceptChgDlg
,RejectAllHandle
));
137 pTPView
->SetAcceptAllClickHdl( LINK(this, ScAcceptChgDlg
, AcceptAllHandle
));
138 pTheView
->SetCalcView();
139 pTheView
->SetStyle(pTheView
->GetStyle()|WB_HASLINES
|WB_CLIPCHILDREN
|WB_HASBUTTONS
|WB_HASBUTTONSATROOT
|WB_HSCROLL
);
140 pTheView
->SetExpandingHdl( LINK(this, ScAcceptChgDlg
, ExpandingHandle
));
141 pTheView
->SetSelectHdl( LINK(this, ScAcceptChgDlg
, SelectHandle
));
142 pTheView
->SetDeselectHdl( LINK(this, ScAcceptChgDlg
, SelectHandle
));
143 pTheView
->SetCommandHdl( LINK(this, ScAcceptChgDlg
, CommandHdl
));
144 pTheView
->SetColCompareHdl( LINK(this, ScAcceptChgDlg
,ColCompareHdl
));
145 pTheView
->SetSelectionMode(MULTIPLE_SELECTION
);
146 pTheView
->SetHighlightRange(1);
151 SvTreeListEntry
* pEntry
=pTheView
->First();
154 pTheView
->Select(pEntry
);
158 ScAcceptChgDlg::~ScAcceptChgDlg()
161 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
166 pChanges
->SetModifiedLink(aLink
);
169 delete m_pAcceptChgCtr
;
172 void ScAcceptChgDlg::ReInit(ScViewData
* ptrViewData
)
174 pViewData
=ptrViewData
;
176 pDoc
=ptrViewData
->GetDocument();
185 bAcceptEnableFlag
=true;
186 bRejectEnableFlag
=true;
188 // don't call Init here (switching between views), just set link below
189 // (dialog is just hidden, not deleted anymore, when switching views)
195 ScChangeTrack
* pChanges
= pDoc
->GetChangeTrack();
197 pChanges
->SetModifiedLink( LINK( this, ScAcceptChgDlg
, ChgTrackModHdl
) );
201 void ScAcceptChgDlg::Init()
205 OSL_ENSURE( pViewData
&& pDoc
, "ViewData oder Document nicht gefunden!" );
207 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
211 pChanges
->SetModifiedLink( LINK( this, ScAcceptChgDlg
,ChgTrackModHdl
));
212 aChangeViewSet
.SetTheAuthorToShow(pChanges
->GetUser());
213 pTPFilter
->ClearAuthors();
214 const std::set
<OUString
>& rUserColl
= pChanges
->GetUserCollection();
215 std::set
<OUString
>::const_iterator it
= rUserColl
.begin(), itEnd
= rUserColl
.end();
216 for (; it
!= itEnd
; ++it
)
217 pTPFilter
->InsertAuthor(*it
);
220 ScChangeViewSettings
* pViewSettings
=pDoc
->GetChangeViewSettings();
221 if ( pViewSettings
!=NULL
)
222 aChangeViewSet
= *pViewSettings
;
223 // adjust TimeField for filter tabpage
224 aChangeViewSet
.AdjustDateMode( *pDoc
);
226 pTPFilter
->CheckDate(aChangeViewSet
.HasDate());
227 pTPFilter
->SetFirstDate(aChangeViewSet
.GetTheFirstDateTime());
228 pTPFilter
->SetFirstTime(aChangeViewSet
.GetTheFirstDateTime());
229 pTPFilter
->SetLastDate(aChangeViewSet
.GetTheLastDateTime());
230 pTPFilter
->SetLastTime(aChangeViewSet
.GetTheLastDateTime());
231 pTPFilter
->SetDateMode((sal_uInt16
)aChangeViewSet
.GetTheDateMode());
232 pTPFilter
->CheckComment(aChangeViewSet
.HasComment());
233 pTPFilter
->SetComment(aChangeViewSet
.GetTheComment());
235 pTPFilter
->CheckAuthor(aChangeViewSet
.HasAuthor());
236 OUString aString
=aChangeViewSet
.GetTheAuthorToShow();
237 if(!aString
.isEmpty())
239 pTPFilter
->SelectAuthor(aString
);
240 if(pTPFilter
->GetSelectedAuthor()!=aString
)
242 pTPFilter
->InsertAuthor(aString
);
243 pTPFilter
->SelectAuthor(aString
);
247 pTPFilter
->SelectedAuthorPos(0);
249 pTPFilter
->CheckRange(aChangeViewSet
.HasRange());
251 aRangeList
=aChangeViewSet
.GetTheRangeList();
253 if( !aChangeViewSet
.GetTheRangeList().empty() )
255 const ScRange
* pRangeEntry
= aChangeViewSet
.GetTheRangeList().front();
256 OUString
aRefStr(pRangeEntry
->Format(ABS_DREF3D
, pDoc
));
257 pTPFilter
->SetRange(aRefStr
);
263 void ScAcceptChgDlg::ClearView()
267 pTheView
->SetUpdateMode(false);
270 pTheView
->SetUpdateMode(true);
273 OUString
* ScAcceptChgDlg::MakeTypeString(ScChangeActionType eType
)
280 case SC_CAT_INSERT_COLS
: pStr
=&aStrInsertCols
;break;
281 case SC_CAT_INSERT_ROWS
: pStr
=&aStrInsertRows
;break;
282 case SC_CAT_INSERT_TABS
: pStr
=&aStrInsertTabs
;break;
283 case SC_CAT_DELETE_COLS
: pStr
=&aStrDeleteCols
;break;
284 case SC_CAT_DELETE_ROWS
: pStr
=&aStrDeleteRows
;break;
285 case SC_CAT_DELETE_TABS
: pStr
=&aStrDeleteTabs
;break;
286 case SC_CAT_MOVE
: pStr
=&aStrMove
;break;
287 case SC_CAT_CONTENT
: pStr
=&aStrContent
;break;
288 case SC_CAT_REJECT
: pStr
=&aStrReject
;break;
289 default: pStr
=&aUnknown
;break;
295 bool ScAcceptChgDlg::IsValidAction(const ScChangeAction
* pScChangeAction
)
297 if(pScChangeAction
==NULL
) return false;
301 ScRange aRef
=pScChangeAction
->GetBigRange().MakeRange();
302 OUString aUser
=pScChangeAction
->GetUser();
303 DateTime aDateTime
=pScChangeAction
->GetDateTime();
305 ScChangeActionType eType
=pScChangeAction
->GetType();
308 OUString aComment
= comphelper::string::remove(pScChangeAction
->GetComment(), '\n');
310 if(eType
==SC_CAT_CONTENT
)
312 if(!pScChangeAction
->IsDialogParent())
313 pScChangeAction
->GetDescription(aDesc
, pDoc
, true);
316 pScChangeAction
->GetDescription(aDesc
, pDoc
, !pScChangeAction
->IsMasterDelete());
318 if (!aDesc
.isEmpty())
325 if (pTheView
->IsValidEntry(aUser
, aDateTime
, aComment
))
327 if(pTPFilter
->IsRange())
329 for ( size_t i
= 0, nRanges
= aRangeList
.size(); i
< nRanges
; ++i
)
331 ScRange
* pRangeEntry
= aRangeList
[ i
];
332 if (pRangeEntry
->Intersects(aRef
)) {
345 SvTreeListEntry
* ScAcceptChgDlg::InsertChangeAction(
346 const ScChangeAction
* pScChangeAction
, ScChangeActionState
/*eState*/,
347 SvTreeListEntry
* pParent
, bool bDelMaster
,bool bDisabled
, sal_uLong nPos
)
349 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
351 if(pScChangeAction
==NULL
|| pChanges
==NULL
) return NULL
;
353 SvTreeListEntry
* pEntry
=NULL
;
357 ScRange aRef
=pScChangeAction
->GetBigRange().MakeRange();
358 OUString aUser
=pScChangeAction
->GetUser();
359 DateTime aDateTime
=pScChangeAction
->GetDateTime();
362 ScChangeActionType eType
=pScChangeAction
->GetType();
366 ScRedlinData
* pNewData
=new ScRedlinData
;
367 pNewData
->pData
=(void *)pScChangeAction
;
368 pNewData
->nActionNo
=pScChangeAction
->GetActionNumber();
369 pNewData
->bIsAcceptable
=pScChangeAction
->IsClickable();
370 pNewData
->bIsRejectable
=pScChangeAction
->IsRejectable();
371 pNewData
->bDisabled
=!pNewData
->bIsAcceptable
|| bDisabled
;
372 pNewData
->aDateTime
=aDateTime
;
373 pNewData
->nRow
= aRef
.aStart
.Row();
374 pNewData
->nCol
= aRef
.aStart
.Col();
375 pNewData
->nTable
= aRef
.aStart
.Tab();
377 if(eType
==SC_CAT_CONTENT
)
379 if(pScChangeAction
->IsDialogParent())
381 aBuf
.append(aStrContentWithChild
);
382 pNewData
->nInfo
=RD_SPECIAL_VISCONTENT
;
383 pNewData
->bIsRejectable
=false;
384 pNewData
->bIsAcceptable
=false;
388 aBuf
.append(*MakeTypeString(eType
));
389 pScChangeAction
->GetDescription( aDesc
, pDoc
, true);
394 aBuf
.append(aStrContentWithChild
);
398 pScChangeAction
->GetDescription( aDesc
, pDoc
,true);
399 pNewData
->bDisabled
=true;
400 pNewData
->bIsRejectable
=false;
403 pScChangeAction
->GetDescription( aDesc
, pDoc
,!pScChangeAction
->IsMasterDelete());
407 pScChangeAction
->GetRefString(aRefStr
, pDoc
, true);
410 aBuf
.append(aRefStr
);
413 bool bIsGenerated
= false;
415 if(!pChanges
->IsGenerated(pScChangeAction
->GetActionNumber()))
419 aBuf
.append(ScGlobal::pLocaleData
->getDate(aDateTime
));
421 aBuf
.append(ScGlobal::pLocaleData
->getTime(aDateTime
));
424 bIsGenerated
= false;
433 OUString aComment
= comphelper::string::remove(pScChangeAction
->GetComment(), '\n');
435 if (!aDesc
.isEmpty())
442 aBuf
.append(aComment
);
444 if (pTheView
->IsValidEntry(aUser
, aDateTime
) || bIsGenerated
)
446 if (pTheView
->IsValidComment(aComment
))
448 if(pTPFilter
->IsRange())
450 for ( size_t i
= 0, nRanges
= aRangeList
.size(); i
< nRanges
; ++i
)
452 ScRange
* pRangeEntry
= aRangeList
[ i
];
453 if( pRangeEntry
->Intersects(aRef
) )
455 bHasFilterEntry
=true;
461 else if(!bIsGenerated
)
463 bHasFilterEntry
=true;
469 if(!bFlag
&& bUseColor
&& pParent
==NULL
)
471 pEntry
= pTheView
->InsertEntry(
472 aBuf
.makeStringAndClear() ,pNewData
, Color(COL_LIGHTBLUE
), pParent
, nPos
);
474 else if(bFlag
&& bUseColor
&& pParent
!=NULL
)
476 pEntry
= pTheView
->InsertEntry(
477 aBuf
.makeStringAndClear(), pNewData
, Color(COL_GREEN
), pParent
, nPos
);
478 SvTreeListEntry
* pExpEntry
=pParent
;
480 while(pExpEntry
!=NULL
&& !pTheView
->IsExpanded(pExpEntry
))
482 SvTreeListEntry
* pTmpEntry
=pTheView
->GetParent(pExpEntry
);
484 if(pTmpEntry
!=NULL
) pTheView
->Expand(pExpEntry
);
491 pEntry
= pTheView
->InsertEntry(
492 aBuf
.makeStringAndClear(), pNewData
, pParent
, nPos
);
497 SvTreeListEntry
* ScAcceptChgDlg::InsertFilteredAction(
498 const ScChangeAction
* pScChangeAction
, ScChangeActionState eState
,
499 SvTreeListEntry
* pParent
, bool bDelMaster
, bool bDisabled
, sal_uLong nPos
)
502 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
504 if(pScChangeAction
==NULL
|| pChanges
==NULL
) return NULL
;
506 bool bIsGenerated
= pChanges
->IsGenerated(pScChangeAction
->GetActionNumber());
508 SvTreeListEntry
* pEntry
=NULL
;
512 ScRange aRef
=pScChangeAction
->GetBigRange().MakeRange();
513 OUString aUser
=pScChangeAction
->GetUser();
514 DateTime aDateTime
=pScChangeAction
->GetDateTime();
516 if (pTheView
->IsValidEntry(aUser
, aDateTime
) || bIsGenerated
)
518 if(pTPFilter
->IsRange())
520 for ( size_t i
= 0, nRanges
= aRangeList
.size(); i
< nRanges
; ++i
)
522 ScRange
* pRangeEntry
=aRangeList
[ i
];
523 if( pRangeEntry
->Intersects(aRef
) )
525 if( pScChangeAction
->GetState()==eState
)
531 else if(pScChangeAction
->GetState()==eState
&& !bIsGenerated
)
539 ScChangeActionType eType
=pScChangeAction
->GetType();
543 ScRedlinData
* pNewData
=new ScRedlinData
;
544 pNewData
->pData
=(void *)pScChangeAction
;
545 pNewData
->nActionNo
=pScChangeAction
->GetActionNumber();
546 pNewData
->bIsAcceptable
=pScChangeAction
->IsClickable();
547 pNewData
->bIsRejectable
=pScChangeAction
->IsRejectable();
548 pNewData
->bDisabled
=!pNewData
->bIsAcceptable
|| bDisabled
;
549 pNewData
->aDateTime
=aDateTime
;
550 pNewData
->nRow
= aRef
.aStart
.Row();
551 pNewData
->nCol
= aRef
.aStart
.Col();
552 pNewData
->nTable
= aRef
.aStart
.Tab();
554 if(eType
==SC_CAT_CONTENT
)
556 if(pScChangeAction
->IsDialogParent())
558 aString
=aStrContentWithChild
;
559 pNewData
->nInfo
=RD_SPECIAL_VISCONTENT
;
560 pNewData
->bIsRejectable
=false;
561 pNewData
->bIsAcceptable
=false;
565 aString
=*MakeTypeString(eType
);
566 pScChangeAction
->GetDescription( aDesc
, pDoc
, true);
571 aString
=*MakeTypeString(eType
);
575 pScChangeAction
->GetDescription( aDesc
, pDoc
,true);
576 pNewData
->bDisabled
=true;
577 pNewData
->bIsRejectable
=false;
580 pScChangeAction
->GetDescription( aDesc
, pDoc
,!pScChangeAction
->IsMasterDelete());
585 pScChangeAction
->GetRefString(aRefStr
, pDoc
, true);
593 aString
+= ScGlobal::pLocaleData
->getDate(aDateTime
);
595 aString
+= ScGlobal::pLocaleData
->getTime(aDateTime
);
604 OUString aComment
= comphelper::string::remove(pScChangeAction
->GetComment(), '\n');
606 if (!aDesc
.isEmpty())
612 if (pTheView
->IsValidComment(aComment
))
615 pEntry
=pTheView
->InsertEntry(aString
,pNewData
,pParent
,nPos
);
623 SvTreeListEntry
* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionContent
* pScChangeAction
,
624 SvTreeListEntry
* pParent
, sal_uLong nSpecial
)
626 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
627 SvTreeListEntry
* pEntry
=NULL
;
629 if(pScChangeAction
==NULL
|| pChanges
==NULL
) return NULL
;
631 bool bIsGenerated
= pChanges
->IsGenerated(pScChangeAction
->GetActionNumber());
635 ScRange aRef
=pScChangeAction
->GetBigRange().MakeRange();
636 OUString aUser
=pScChangeAction
->GetUser();
637 DateTime aDateTime
=pScChangeAction
->GetDateTime();
639 if (pTheView
->IsValidEntry(aUser
, aDateTime
) || bIsGenerated
)
641 if(pTPFilter
->IsRange())
643 for ( size_t i
= 0, nRanges
= aRangeList
.size(); i
< nRanges
; ++i
)
645 ScRange
* pRangeEntry
= aRangeList
[ i
];
646 if( pRangeEntry
->Intersects(aRef
) )
653 else if(!bIsGenerated
)
662 if(nSpecial
==RD_SPECIAL_CONTENT
)
665 pScChangeAction
->GetOldString(aTmp
, pDoc
);
667 if(a2String
.isEmpty()) a2String
=aStrEmpty
;
673 aDesc
=aStrChildOrgContent
;
679 pScChangeAction
->GetNewString(aTmp
, pDoc
);
681 if(a2String
.isEmpty())
693 aDesc
= aStrChildContent
;
699 pScChangeAction
->GetRefString(aRefStr
, pDoc
, true);
708 aString
+= ScGlobal::pLocaleData
->getDate(aDateTime
);
710 aString
+= ScGlobal::pLocaleData
->getTime(aDateTime
);
719 OUString aComment
= comphelper::string::remove(pScChangeAction
->GetComment(), '\n');
730 ScRedlinData
* pNewData
=new ScRedlinData
;
731 pNewData
->nInfo
=nSpecial
;
732 pNewData
->pData
=(void *)pScChangeAction
;
733 pNewData
->nActionNo
=pScChangeAction
->GetActionNumber();
734 pNewData
->bIsAcceptable
=pScChangeAction
->IsClickable();
735 pNewData
->bIsRejectable
=false;
736 pNewData
->bDisabled
=!pNewData
->bIsAcceptable
;
737 pNewData
->aDateTime
=aDateTime
;
738 pNewData
->nRow
= aRef
.aStart
.Row();
739 pNewData
->nCol
= aRef
.aStart
.Col();
740 pNewData
->nTable
= aRef
.aStart
.Tab();
742 if (pTheView
->IsValidComment(aComment
) && bFlag
)
744 bHasFilterEntry
=true;
745 pEntry
=pTheView
->InsertEntry(aString
,pNewData
,pParent
);
748 pEntry
=pTheView
->InsertEntry(aString
,pNewData
,Color(COL_LIGHTBLUE
),pParent
);
752 long ScAcceptChgDlg::PreNotify( NotifyEvent
& rNEvt
)
754 if(rNEvt
.GetType()==EVENT_GETFOCUS
&& bNeedsUpdate
)
761 return SfxModelessDialog::PreNotify(rNEvt
);
765 void ScAcceptChgDlg::UpdateView()
768 SvTreeListEntry
* pParent
=NULL
;
769 ScChangeTrack
* pChanges
=NULL
;
770 const ScChangeAction
* pScChangeAction
=NULL
;
771 bAcceptEnableFlag
=true;
772 bRejectEnableFlag
=true;
773 SetPointer(Pointer(POINTER_WAIT
));
774 pTheView
->SetUpdateMode(false);
775 bool bFilterFlag
= pTPFilter
->IsDate() || pTPFilter
->IsRange() ||
776 pTPFilter
->IsAuthor() || pTPFilter
->IsComment();
778 bUseColor
= bFilterFlag
;
782 pChanges
=pDoc
->GetChangeTrack();
784 pScChangeAction
=pChanges
->GetFirst();
786 bool bTheFlag
= false;
788 while(pScChangeAction
!=NULL
)
790 bHasFilterEntry
=false;
791 switch(pScChangeAction
->GetState())
795 if(pScChangeAction
->IsDialogRoot())
797 if(pScChangeAction
->IsDialogParent())
798 pParent
=InsertChangeAction(pScChangeAction
,SC_CAS_VIRGIN
);
800 pParent
=InsertFilteredAction(pScChangeAction
,SC_CAS_VIRGIN
);
808 case SC_CAS_ACCEPTED
:
813 case SC_CAS_REJECTED
:
819 if(pParent
!=NULL
&& pScChangeAction
->IsDialogParent())
822 pParent
->EnableChildrenOnDemand(true);
825 bool bTestFlag
= bHasFilterEntry
;
826 bHasFilterEntry
=false;
827 if(Expand(pChanges
,pScChangeAction
,pParent
,!bTestFlag
)&&!bTestFlag
)
828 pTheView
->RemoveEntry(pParent
);
832 pScChangeAction
=pScChangeAction
->GetNext();
835 if( bTheFlag
&& (!pDoc
->IsDocEditable() || pChanges
->IsProtected()) )
838 pTPView
->EnableAccept(bTheFlag
);
839 pTPView
->EnableAcceptAll(bTheFlag
);
840 pTPView
->EnableReject(bTheFlag
);
841 pTPView
->EnableRejectAll(bTheFlag
);
845 pParent
=pTheView
->InsertEntry(
846 aStrAllAccepted
, static_cast< RedlinData
* >(NULL
),
847 static_cast< SvTreeListEntry
* >(NULL
));
848 pParent
->EnableChildrenOnDemand(true);
852 pParent
=pTheView
->InsertEntry(
853 aStrAllRejected
, static_cast< RedlinData
* >(NULL
),
854 static_cast< SvTreeListEntry
* >(NULL
));
855 pParent
->EnableChildrenOnDemand(true);
857 pTheView
->SetUpdateMode(true);
858 SetPointer(Pointer(POINTER_ARROW
));
859 SvTreeListEntry
* pEntry
=pTheView
->First();
861 pTheView
->Select(pEntry
);
864 IMPL_LINK_NOARG(ScAcceptChgDlg
, RefHandle
)
866 sal_uInt16 nId
=ScSimpleRefDlgWrapper::GetChildWindowId();
868 ScSimpleRefDlgWrapper::SetDefaultPosSize(GetPosPixel(),GetSizePixel(),true);
870 SC_MOD()->SetRefDialog( nId
, true );
872 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
873 ScSimpleRefDlgWrapper
* pWnd
=(ScSimpleRefDlgWrapper
*)pViewFrm
->GetChildWindow( nId
);
877 sal_uInt16 nAcceptId
=ScAcceptChgDlgWrapper::GetChildWindowId();
878 pViewFrm
->ShowChildWindow(nAcceptId
,false);
879 pWnd
->SetCloseHdl(LINK( this, ScAcceptChgDlg
,RefInfoHandle
));
880 pWnd
->SetRefString(pTPFilter
->GetRange());
881 pWnd
->SetAutoReOpen(false);
882 Window
* pWin
=pWnd
->GetWindow();
883 pWin
->SetPosSizePixel(GetPosPixel(),GetSizePixel());
885 pWin
->SetText(GetText());
886 pWnd
->StartRefInput();
891 IMPL_LINK( ScAcceptChgDlg
, RefInfoHandle
, OUString
*, pResult
)
895 ScSimpleRefDlgWrapper::SetAutoReOpen(true);
897 SfxViewFrame
* pViewFrm
= pViewData
->GetViewShell()->GetViewFrame();
900 pTPFilter
->SetRange(*pResult
);
901 FilterHandle(pTPFilter
);
903 nId
= ScSimpleRefDlgWrapper::GetChildWindowId();
904 ScSimpleRefDlgWrapper
* pWnd
= (ScSimpleRefDlgWrapper
*)pViewFrm
->GetChildWindow( nId
);
908 Window
* pWin
=pWnd
->GetWindow();
909 Size aWinSize
=pWin
->GetSizePixel();
910 aWinSize
.Width()=GetSizePixel().Width();
911 SetPosSizePixel(pWin
->GetPosPixel(),aWinSize
);
914 nId
= ScAcceptChgDlgWrapper::GetChildWindowId();
915 pViewFrm
->ShowChildWindow( nId
, true );
919 nId
= ScAcceptChgDlgWrapper::GetChildWindowId();
920 pViewFrm
->SetChildWindow( nId
, false );
925 IMPL_LINK( ScAcceptChgDlg
, FilterHandle
, SvxTPFilter
*, pRef
)
930 aRangeList
.RemoveAll();
931 aRangeList
.Parse(pTPFilter
->GetRange(),pDoc
);
937 IMPL_LINK( ScAcceptChgDlg
, RejectHandle
, SvxTPView
*, pRef
)
939 SetPointer(Pointer(POINTER_WAIT
));
942 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
946 SvTreeListEntry
* pEntry
=pTheView
->FirstSelected();
949 ScRedlinData
*pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
952 ScChangeAction
* pScChangeAction
=
953 (ScChangeAction
*) pEntryData
->pData
;
955 if(pScChangeAction
->GetType()==SC_CAT_INSERT_TABS
)
956 pViewData
->SetTabNo(0);
958 pChanges
->Reject(pScChangeAction
);
960 pEntry
= pTheView
->NextSelected(pEntry
);
962 ScDocShell
* pDocSh
=pViewData
->GetDocShell();
963 pDocSh
->PostPaintExtras();
964 pDocSh
->PostPaintGridAll();
965 pDocSh
->GetUndoManager()->Clear();
966 pDocSh
->SetDocumentModified();
970 SetPointer(Pointer(POINTER_ARROW
));
975 IMPL_LINK( ScAcceptChgDlg
, AcceptHandle
, SvxTPView
*, pRef
)
977 SetPointer(Pointer(POINTER_WAIT
));
979 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
983 SvTreeListEntry
* pEntry
=pTheView
->FirstSelected();
986 ScRedlinData
*pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
989 ScChangeAction
* pScChangeAction
=
990 (ScChangeAction
*) pEntryData
->pData
;
991 if(pScChangeAction
->GetType()==SC_CAT_CONTENT
)
993 if(pEntryData
->nInfo
==RD_SPECIAL_CONTENT
)
994 pChanges
->SelectContent(pScChangeAction
,true);
996 pChanges
->SelectContent(pScChangeAction
);
999 pChanges
->Accept(pScChangeAction
);
1001 pEntry
= pTheView
->NextSelected(pEntry
);
1003 ScDocShell
* pDocSh
=pViewData
->GetDocShell();
1004 pDocSh
->PostPaintExtras();
1005 pDocSh
->PostPaintGridAll();
1006 pDocSh
->SetDocumentModified();
1015 void ScAcceptChgDlg::RejectFiltered()
1017 if(pDoc
==NULL
) return;
1018 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1019 const ScChangeAction
* pScChangeAction
=NULL
;
1023 pScChangeAction
=pChanges
->GetLast();
1026 while(pScChangeAction
!=NULL
)
1028 if(pScChangeAction
->IsDialogRoot())
1029 if(IsValidAction(pScChangeAction
))
1030 pChanges
->Reject((ScChangeAction
*)pScChangeAction
);
1032 pScChangeAction
=pScChangeAction
->GetPrev();
1035 void ScAcceptChgDlg::AcceptFiltered()
1037 if(pDoc
==NULL
) return;
1038 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1039 const ScChangeAction
* pScChangeAction
=NULL
;
1042 pScChangeAction
=pChanges
->GetLast();
1044 while(pScChangeAction
!=NULL
)
1046 if(pScChangeAction
->IsDialogRoot())
1047 if(IsValidAction(pScChangeAction
))
1048 pChanges
->Accept((ScChangeAction
*)pScChangeAction
);
1050 pScChangeAction
=pScChangeAction
->GetPrev();
1054 IMPL_LINK_NOARG(ScAcceptChgDlg
, RejectAllHandle
)
1056 SetPointer(Pointer(POINTER_WAIT
));
1058 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1061 if(pTPFilter
->IsDate()||pTPFilter
->IsAuthor()||pTPFilter
->IsRange()||pTPFilter
->IsComment())
1064 pChanges
->RejectAll();
1066 pViewData
->SetTabNo(0);
1068 ScDocShell
* pDocSh
=pViewData
->GetDocShell();
1069 pDocSh
->PostPaintExtras();
1070 pDocSh
->PostPaintGridAll();
1071 pDocSh
->GetUndoManager()->Clear();
1072 pDocSh
->SetDocumentModified();
1076 SetPointer(Pointer(POINTER_ARROW
));
1083 IMPL_LINK_NOARG(ScAcceptChgDlg
, AcceptAllHandle
)
1085 SetPointer(Pointer(POINTER_WAIT
));
1088 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1091 if(pTPFilter
->IsDate()||pTPFilter
->IsAuthor()||pTPFilter
->IsRange()||pTPFilter
->IsComment())
1094 pChanges
->AcceptAll();
1096 ScDocShell
* pDocSh
=pViewData
->GetDocShell();
1097 pDocSh
->PostPaintExtras();
1098 pDocSh
->PostPaintGridAll();
1099 pDocSh
->SetDocumentModified();
1104 SetPointer(Pointer(POINTER_ARROW
));
1109 IMPL_LINK_NOARG(ScAcceptChgDlg
, SelectHandle
)
1112 aSelectionTimer
.Start();
1118 void ScAcceptChgDlg::GetDependents( const ScChangeAction
* pScChangeAction
,
1119 ScChangeActionMap
& aActionMap
,
1120 SvTreeListEntry
* pEntry
)
1122 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1124 SvTreeListEntry
* pParent
=pTheView
->GetParent(pEntry
);
1127 ScRedlinData
*pParentData
=(ScRedlinData
*)(pParent
->GetUserData());
1128 ScChangeAction
* pParentAction
=(ScChangeAction
*) pParentData
->pData
;
1130 if(pParentAction
!=pScChangeAction
)
1131 pChanges
->GetDependents((ScChangeAction
*) pScChangeAction
,
1132 aActionMap
,pScChangeAction
->IsMasterDelete());
1134 pChanges
->GetDependents( (ScChangeAction
*) pScChangeAction
,
1138 pChanges
->GetDependents((ScChangeAction
*) pScChangeAction
,
1139 aActionMap
, pScChangeAction
->IsMasterDelete() );
1142 bool ScAcceptChgDlg::InsertContentChildren(ScChangeActionMap
* pActionMap
,SvTreeListEntry
* pParent
)
1144 bool bTheTestFlag
= true;
1145 ScRedlinData
*pEntryData
=(ScRedlinData
*)(pParent
->GetUserData());
1146 const ScChangeAction
* pScChangeAction
= (ScChangeAction
*) pEntryData
->pData
;
1147 bool bParentInserted
= false;
1148 // If the parent is a MatrixOrigin then place it in the right order before
1149 // the MatrixReferences. Also if it is the first content change at this
1150 // position don't insert the first dependent MatrixReference as the special
1151 // content (original value) but insert the predecessor of the MatrixOrigin
1153 if ( pScChangeAction
->GetType() == SC_CAT_CONTENT
&&
1154 ((const ScChangeActionContent
*)pScChangeAction
)->IsMatrixOrigin() )
1156 pActionMap
->insert( ::std::make_pair( pScChangeAction
->GetActionNumber(),
1157 const_cast<ScChangeAction
*>( pScChangeAction
) ) );
1158 bParentInserted
= true;
1160 SvTreeListEntry
* pEntry
=NULL
;
1162 ScChangeActionMap::iterator itChangeAction
= pActionMap
->begin();
1163 while( itChangeAction
!= pActionMap
->end() )
1165 if( itChangeAction
->second
->GetState()==SC_CAS_VIRGIN
)
1170 if( itChangeAction
== pActionMap
->end() )
1173 SvTreeListEntry
* pOriginal
= InsertChangeActionContent(
1174 dynamic_cast<const ScChangeActionContent
*>( itChangeAction
->second
),
1175 pParent
, RD_SPECIAL_CONTENT
);
1180 ScRedlinData
*pParentData
=(ScRedlinData
*)(pOriginal
->GetUserData());
1181 pParentData
->pData
=(void *)pScChangeAction
;
1182 pParentData
->nActionNo
=pScChangeAction
->GetActionNumber();
1183 pParentData
->bIsAcceptable
=pScChangeAction
->IsRejectable(); // select old value
1184 pParentData
->bIsRejectable
=false;
1185 pParentData
->bDisabled
=false;
1187 while( itChangeAction
!= pActionMap
->end() )
1189 if( itChangeAction
->second
->GetState() == SC_CAS_VIRGIN
)
1191 pEntry
= InsertChangeActionContent( dynamic_cast<const ScChangeActionContent
*>( itChangeAction
->second
),
1192 pParent
, RD_SPECIAL_NONE
);
1200 if ( !bParentInserted
)
1202 pEntry
=InsertChangeActionContent((const ScChangeActionContent
*)
1203 pScChangeAction
,pParent
,RD_SPECIAL_NONE
);
1208 ScRedlinData
*pParentData
=(ScRedlinData
*)(pEntry
->GetUserData());
1209 pParentData
->pData
=(void *)pScChangeAction
;
1210 pParentData
->nActionNo
=pScChangeAction
->GetActionNumber();
1211 pParentData
->bIsAcceptable
=pScChangeAction
->IsClickable();
1212 pParentData
->bIsRejectable
=false;
1213 pParentData
->bDisabled
=false;
1217 return bTheTestFlag
;
1221 bool ScAcceptChgDlg::InsertAcceptedORejected(SvTreeListEntry
* pParent
)
1223 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1224 bool bTheTestFlag
= true;
1226 ScChangeActionState eState
= SC_CAS_VIRGIN
;
1227 OUString aString
= pTheView
->GetEntryText(pParent
);
1228 OUString a2String
= aString
.copy(0, aStrAllAccepted
.getLength());
1229 if (a2String
.equals(aStrAllAccepted
))
1230 eState
=SC_CAS_ACCEPTED
;
1233 a2String
= aString
.copy(0, aStrAllRejected
.getLength());
1234 if (a2String
.equals(aStrAllRejected
))
1235 eState
=SC_CAS_REJECTED
;
1238 ScChangeAction
* pScChangeAction
=pChanges
->GetFirst();
1239 while(pScChangeAction
!=NULL
)
1241 if(pScChangeAction
->GetState()==eState
&&
1242 InsertFilteredAction(pScChangeAction
,eState
,pParent
)!=NULL
)
1244 pScChangeAction
=pScChangeAction
->GetNext();
1246 return bTheTestFlag
;
1249 bool ScAcceptChgDlg::InsertChildren(ScChangeActionMap
* pActionMap
,SvTreeListEntry
* pParent
)
1251 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1252 bool bTheTestFlag
= true;
1253 SvTreeListEntry
* pEntry
=NULL
;
1254 ScChangeActionMap::iterator itChangeAction
;
1256 for( itChangeAction
= pActionMap
->begin(); itChangeAction
!= pActionMap
->end(); ++itChangeAction
)
1258 pEntry
=InsertChangeAction( itChangeAction
->second
, SC_CAS_VIRGIN
, pParent
, false, true );
1264 ScRedlinData
*pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
1265 pEntryData
->bIsRejectable
=false;
1266 pEntryData
->bIsAcceptable
=false;
1267 pEntryData
->bDisabled
=true;
1269 if( itChangeAction
->second
->IsDialogParent() )
1270 Expand( pChanges
, itChangeAction
->second
, pEntry
);
1273 return bTheTestFlag
;
1276 bool ScAcceptChgDlg::InsertDeletedChildren(const ScChangeAction
* pScChangeAction
,
1277 ScChangeActionMap
* pActionMap
,SvTreeListEntry
* pParent
)
1279 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1280 bool bTheTestFlag
= true;
1281 SvTreeListEntry
* pEntry
=NULL
;
1282 ScChangeActionMap::iterator itChangeAction
;
1284 for( itChangeAction
= pActionMap
->begin(); itChangeAction
!= pActionMap
->end(); ++itChangeAction
)
1287 if( pScChangeAction
!= itChangeAction
->second
)
1288 pEntry
= InsertChangeAction( itChangeAction
->second
, SC_CAS_VIRGIN
, pParent
, false, true );
1290 pEntry
= InsertChangeAction( itChangeAction
->second
, SC_CAS_VIRGIN
, pParent
, true, true );
1294 ScRedlinData
*pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
1295 pEntryData
->bIsRejectable
=false;
1296 pEntryData
->bIsAcceptable
=false;
1297 pEntryData
->bDisabled
=true;
1301 if( itChangeAction
->second
->IsDialogParent() )
1302 Expand( pChanges
, itChangeAction
->second
, pEntry
);
1305 return bTheTestFlag
;
1308 bool ScAcceptChgDlg::Expand(
1309 ScChangeTrack
* pChanges
, const ScChangeAction
* pScChangeAction
,
1310 SvTreeListEntry
* pEntry
, bool bFilter
)
1312 bool bTheTestFlag
= true;
1314 if(pChanges
!=NULL
&&pEntry
!=NULL
&&pScChangeAction
!=NULL
)
1316 ScChangeActionMap aActionMap
;
1318 GetDependents( pScChangeAction
, aActionMap
, pEntry
);
1320 switch(pScChangeAction
->GetType())
1322 case SC_CAT_CONTENT
:
1324 InsertContentChildren( &aActionMap
, pEntry
);
1325 bTheTestFlag
=!bHasFilterEntry
;
1328 case SC_CAT_DELETE_COLS
:
1329 case SC_CAT_DELETE_ROWS
:
1330 case SC_CAT_DELETE_TABS
:
1332 InsertDeletedChildren( pScChangeAction
, &aActionMap
, pEntry
);
1333 bTheTestFlag
=!bHasFilterEntry
;
1339 bTheTestFlag
= InsertChildren( &aActionMap
, pEntry
);
1345 return bTheTestFlag
;
1348 IMPL_LINK( ScAcceptChgDlg
, ExpandingHandle
, SvxRedlinTable
*, pTable
)
1350 ScChangeTrack
* pChanges
=pDoc
->GetChangeTrack();
1351 ScChangeAction
* pScChangeAction
=NULL
;
1352 SetPointer(Pointer(POINTER_WAIT
));
1353 if(pTable
!=NULL
&& pChanges
!=NULL
)
1355 ScChangeActionMap aActionMap
;
1356 SvTreeListEntry
* pEntry
=pTheView
->GetHdlEntry();
1359 ScRedlinData
*pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
1360 if(pEntryData
!=NULL
)
1361 pScChangeAction
=(ScChangeAction
*) pEntryData
->pData
;
1363 if(pEntry
->HasChildrenOnDemand())
1365 bool bTheTestFlag
= true;
1366 pEntry
->EnableChildrenOnDemand(false);
1367 pTheView
->RemoveEntry(pTheView
->FirstChild(pEntry
));
1369 if(pEntryData
!=NULL
)
1371 pScChangeAction
=(ScChangeAction
*) pEntryData
->pData
;
1373 GetDependents( pScChangeAction
, aActionMap
, pEntry
);
1375 switch(pScChangeAction
->GetType())
1377 case SC_CAT_CONTENT
:
1379 bTheTestFlag
= InsertContentChildren( &aActionMap
, pEntry
);
1382 case SC_CAT_DELETE_COLS
:
1383 case SC_CAT_DELETE_ROWS
:
1384 case SC_CAT_DELETE_TABS
:
1386 bTheTestFlag
= InsertDeletedChildren( pScChangeAction
, &aActionMap
, pEntry
);
1391 bTheTestFlag
= InsertChildren( &aActionMap
, pEntry
);
1400 bTheTestFlag
=InsertAcceptedORejected(pEntry
);
1402 if(bTheTestFlag
) pTheView
->InsertEntry(aStrNoEntry
,NULL
,Color(COL_GRAY
),pEntry
);
1407 SetPointer(Pointer(POINTER_ARROW
));
1408 return (sal_uLong
) true;
1412 void ScAcceptChgDlg::AppendChanges(ScChangeTrack
* pChanges
,sal_uLong nStartAction
,
1413 sal_uLong nEndAction
, sal_uLong
/* nPos */)
1417 SvTreeListEntry
* pParent
=NULL
;
1418 const ScChangeAction
* pScChangeAction
=NULL
;
1419 bAcceptEnableFlag
=true;
1420 bRejectEnableFlag
=true;
1421 SetPointer(Pointer(POINTER_WAIT
));
1422 pTheView
->SetUpdateMode(false);
1424 bool bTheFlag
= false;
1426 bool bFilterFlag
= pTPFilter
->IsDate() || pTPFilter
->IsRange() ||
1427 pTPFilter
->IsAuthor() || pTPFilter
->IsComment();
1429 bUseColor
= bFilterFlag
;
1431 for(sal_uLong i
=nStartAction
;i
<=nEndAction
;i
++)
1433 pScChangeAction
=pChanges
->GetAction(i
);
1434 if(pScChangeAction
==NULL
) continue;
1437 switch(pScChangeAction
->GetState())
1441 if(pScChangeAction
->IsDialogRoot())
1443 if(pScChangeAction
->IsDialogParent())
1444 pParent
=InsertChangeAction(pScChangeAction
,SC_CAS_VIRGIN
);
1446 pParent
=InsertFilteredAction(pScChangeAction
,SC_CAS_VIRGIN
);
1454 case SC_CAS_ACCEPTED
:
1459 case SC_CAS_REJECTED
:
1465 if(pParent
!=NULL
&& pScChangeAction
->IsDialogParent())
1468 pParent
->EnableChildrenOnDemand(true);
1471 bool bTestFlag
= bHasFilterEntry
;
1472 bHasFilterEntry
= false;
1473 if(Expand(pChanges
,pScChangeAction
,pParent
,!bTestFlag
)&&!bTestFlag
)
1474 pTheView
->RemoveEntry(pParent
);
1479 if( bTheFlag
&& (!pDoc
->IsDocEditable() || pChanges
->IsProtected()) )
1482 pTPView
->EnableAccept(bTheFlag
);
1483 pTPView
->EnableAcceptAll(bTheFlag
);
1484 pTPView
->EnableReject(bTheFlag
);
1485 pTPView
->EnableRejectAll(bTheFlag
);
1487 pTheView
->SetUpdateMode(true);
1488 SetPointer(Pointer(POINTER_ARROW
));
1492 void ScAcceptChgDlg::RemoveEntrys(sal_uLong nStartAction
,sal_uLong nEndAction
)
1495 pTheView
->SetUpdateMode(false);
1497 SvTreeListEntry
* pEntry
=pTheView
->GetCurEntry();
1499 ScRedlinData
*pEntryData
=NULL
;
1502 pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
1504 sal_uLong nAction
=0;
1505 if(pEntryData
!=NULL
)
1506 nAction
=pEntryData
->nActionNo
;
1508 if(nAction
>=nStartAction
&& nAction
<=nEndAction
)
1509 pTheView
->SetCurEntry(pTheView
->GetModel()->GetEntry(0));
1511 bool bRemove
= false;
1513 // MUST do it backwards, don't delete parents before children and GPF
1514 pEntry
=pTheView
->Last();
1518 pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
1519 if(pEntryData
!=NULL
)
1521 nAction
=pEntryData
->nActionNo
;
1523 if(nStartAction
<=nAction
&& nAction
<=nEndAction
) bRemove
=true;
1527 SvTreeListEntry
* pPrevEntry
= pTheView
->Prev(pEntry
);
1530 pTheView
->RemoveEntry(pEntry
);
1534 pTheView
->SetUpdateMode(true);
1538 void ScAcceptChgDlg::UpdateEntrys(ScChangeTrack
* pChgTrack
, sal_uLong nStartAction
,sal_uLong nEndAction
)
1540 pTheView
->SetUpdateMode(false);
1542 sal_uLong nPos
=LIST_APPEND
;
1544 bool bRemove
= false;
1546 SvTreeListEntry
* pEntry
=pTheView
->First();
1547 SvTreeListEntry
* pNextEntry
= (pEntry
? pTheView
->NextSibling(pEntry
) : NULL
);
1548 SvTreeListEntry
* pLastEntry
=NULL
;
1552 ScRedlinData
*pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
1553 if(pEntryData
!=NULL
)
1555 ScChangeAction
* pScChangeAction
=
1556 (ScChangeAction
*) pEntryData
->pData
;
1558 sal_uLong nAction
=pScChangeAction
->GetActionNumber();
1560 if(nStartAction
<=nAction
&& nAction
<=nEndAction
) bRemove
=true;
1565 nPos
=pEntry
->GetChildListPos();
1566 pTheView
->RemoveEntry(pEntry
);
1568 if(pLastEntry
==NULL
) pLastEntry
=pTheView
->First();
1569 if(pLastEntry
!=NULL
)
1571 pNextEntry
=pTheView
->Next(pLastEntry
);
1573 if(pNextEntry
==NULL
)
1575 pNextEntry
=pLastEntry
;
1585 pLastEntry
= pEntry
;
1586 pNextEntry
= pTheView
->Next(pEntry
);
1591 if(nStartAction
==nEndAction
)
1592 AppendChanges(pChgTrack
,nStartAction
,nEndAction
,nPos
);
1594 AppendChanges(pChgTrack
,nStartAction
,nEndAction
);
1596 pTheView
->SetUpdateMode(true);
1600 IMPL_LINK( ScAcceptChgDlg
, ChgTrackModHdl
, ScChangeTrack
*, pChgTrack
)
1602 ScChangeTrackMsgQueue::iterator iter
;
1603 ScChangeTrackMsgQueue
& aMsgQueue
= pChgTrack
->GetMsgQueue();
1605 sal_uLong nStartAction
;
1606 sal_uLong nEndAction
;
1608 for (iter
= aMsgQueue
.begin(); iter
!= aMsgQueue
.end(); ++iter
)
1610 nStartAction
=(*iter
)->nStartAction
;
1611 nEndAction
=(*iter
)->nEndAction
;
1617 switch((*iter
)->eMsgType
)
1619 case SC_CTM_APPEND
: AppendChanges(pChgTrack
,nStartAction
,nEndAction
);
1621 case SC_CTM_REMOVE
: RemoveEntrys(nStartAction
,nEndAction
);
1624 case SC_CTM_CHANGE
: //bNeedsUpdate=true;
1625 UpdateEntrys(pChgTrack
,nStartAction
,nEndAction
);
1629 // added to avoid warnings
1640 IMPL_LINK_NOARG(ScAcceptChgDlg
, ReOpenTimerHdl
)
1642 ScSimpleRefDlgWrapper::SetAutoReOpen(true);
1643 m_pAcceptChgCtr
->ShowFilterPage();
1649 IMPL_LINK_NOARG(ScAcceptChgDlg
, UpdateSelectionHdl
)
1651 ScTabView
* pTabView
= pViewData
->GetView();
1653 bool bAcceptFlag
= true;
1654 bool bRejectFlag
= true;
1655 bool bContMark
= false;
1657 pTabView
->DoneBlockMode(); // clears old marking
1658 SvTreeListEntry
* pEntry
= pTheView
->FirstSelected();
1661 ScRedlinData
* pEntryData
= (ScRedlinData
*) pEntry
->GetUserData();
1664 bRejectFlag
&= (bool) pEntryData
->bIsRejectable
;
1665 bAcceptFlag
&= (bool) pEntryData
->bIsAcceptable
;
1667 const ScChangeAction
* pScChangeAction
= (ScChangeAction
*) pEntryData
->pData
;
1668 if( pScChangeAction
&& (pScChangeAction
->GetType() != SC_CAT_DELETE_TABS
) &&
1669 (!pEntryData
->bDisabled
|| pScChangeAction
->IsVisible()) )
1671 const ScBigRange
& rBigRange
= pScChangeAction
->GetBigRange();
1672 if( rBigRange
.IsValid( pDoc
) && IsActive() )
1674 bool bSetCursor
= !pTheView
->NextSelected( pEntry
);
1675 pTabView
->MarkRange( rBigRange
.MakeRange(), bSetCursor
, bContMark
);
1682 bAcceptFlag
= false;
1683 bRejectFlag
= false;
1685 bAcceptEnableFlag
= bAcceptFlag
;
1686 bRejectEnableFlag
= bRejectFlag
;
1688 pEntry
= pTheView
->NextSelected( pEntry
);
1691 ScChangeTrack
* pChanges
= pDoc
->GetChangeTrack();
1692 bool bEnable
= pDoc
->IsDocEditable() && pChanges
&& !pChanges
->IsProtected();
1693 pTPView
->EnableAccept( bAcceptFlag
&& bEnable
);
1694 pTPView
->EnableReject( bRejectFlag
&& bEnable
);
1699 IMPL_LINK_NOARG(ScAcceptChgDlg
, CommandHdl
)
1702 const CommandEvent
aCEvt(pTheView
->GetCommandEvent());
1704 if(aCEvt
.GetCommand()==COMMAND_CONTEXTMENU
)
1706 ScPopupMenu
aPopup(ScResId(RID_POPUP_CHANGES
));
1708 aPopup
.SetMenuFlags(MENU_FLAG_HIDEDISABLEDENTRIES
);
1710 SvTreeListEntry
* pEntry
=pTheView
->GetCurEntry();
1713 pTheView
->Select(pEntry
);
1717 aPopup
.Deactivate();
1720 sal_uInt16 nSortedCol
= pTheView
->GetSortedCol();
1722 if(nSortedCol
!=0xFFFF)
1724 sal_uInt16 nItemId
=nSortedCol
+SC_SUB_SORT
+1;
1726 aPopup
.CheckItem(nItemId
);
1728 PopupMenu
*pSubMenu
= aPopup
.GetPopupMenu(SC_SUB_SORT
);
1731 pSubMenu
->CheckItem(nItemId
);
1734 aPopup
.EnableItem(SC_CHANGES_COMMENT
,false);
1736 if(pDoc
->IsDocEditable() && pEntry
!=NULL
)
1738 ScRedlinData
*pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
1739 if(pEntryData
!=NULL
)
1741 ScChangeAction
* pScChangeAction
=
1742 (ScChangeAction
*) pEntryData
->pData
;
1743 if(pScChangeAction
!=NULL
&& !pTheView
->GetParent(pEntry
))
1744 aPopup
.EnableItem(SC_CHANGES_COMMENT
);
1748 sal_uInt16 nCommand
=aPopup
.Execute( this, GetPointerPosPixel() );
1753 if(nCommand
==SC_CHANGES_COMMENT
)
1757 ScRedlinData
*pEntryData
=(ScRedlinData
*)(pEntry
->GetUserData());
1758 if(pEntryData
!=NULL
)
1760 ScChangeAction
* pScChangeAction
=
1761 (ScChangeAction
*) pEntryData
->pData
;
1763 pViewData
->GetDocShell()->ExecuteChangeCommentDialog( pScChangeAction
, this,false);
1769 bool bSortDir
= pTheView
->GetSortDirection();
1770 sal_uInt16 nDialogCol
=nCommand
-SC_SUB_SORT
-1;
1771 if(nSortedCol
==nDialogCol
) bSortDir
=!bSortDir
;
1772 pTheView
->SortByCol(nDialogCol
,bSortDir
);
1787 void ScAcceptChgDlg::Initialize(SfxChildWinInfo
*pInfo
)
1792 if ( !pInfo
->aExtraString
.isEmpty() )
1794 sal_Int32 nPos
= pInfo
->aExtraString
.indexOf("AcceptChgDat:");
1796 // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
1797 // er nicht vorhanden ist, liegt eine "altere Version vor
1800 sal_Int32 n1
= pInfo
->aExtraString
.indexOf('(', nPos
);
1803 sal_Int32 n2
= pInfo
->aExtraString
.indexOf(')', n1
);
1806 // Alignment-String herausschneiden
1807 aStr
= pInfo
->aExtraString
.copy(nPos
, n2
- nPos
+ 1);
1808 pInfo
->aExtraString
= pInfo
->aExtraString
.replaceAt(nPos
, n2
- nPos
+ 1, "");
1809 aStr
= aStr
.copy( n1
-nPos
+1 );
1815 SfxModelessDialog::Initialize(pInfo
);
1817 if ( !aStr
.isEmpty())
1819 sal_uInt16 nCount
=(sal_uInt16
)aStr
.toInt32();
1821 for(sal_uInt16 i
=0;i
<nCount
;i
++)
1823 sal_Int32 n1
= aStr
.indexOf(';');
1824 aStr
= aStr
.copy( n1
+1 );
1825 pTheView
->SetTab(i
, (sal_uInt16
)aStr
.toInt32(), MAP_PIXEL
);
1830 //-------------------------------------------------------------------------
1832 void ScAcceptChgDlg::FillInfo(SfxChildWinInfo
& rInfo
) const
1834 SfxModelessDialog::FillInfo(rInfo
);
1835 rInfo
.aExtraString
+= "AcceptChgDat:(";
1837 sal_uInt16 nCount
=pTheView
->TabCount();
1839 rInfo
.aExtraString
+= OUString::number(nCount
);
1840 rInfo
.aExtraString
+= ";";
1841 for(sal_uInt16 i
=0;i
<nCount
;i
++)
1843 rInfo
.aExtraString
+= OUString::number(pTheView
->GetTab(i
));
1844 rInfo
.aExtraString
+= ";";
1846 rInfo
.aExtraString
+= ")";
1849 void ScAcceptChgDlg::InitFilter()
1851 if(pTPFilter
->IsDate()||pTPFilter
->IsRange()||
1852 pTPFilter
->IsAuthor()||pTPFilter
->IsComment())
1854 pTheView
->SetFilterDate(pTPFilter
->IsDate());
1855 pTheView
->SetDateTimeMode(pTPFilter
->GetDateMode());
1856 pTheView
->SetFirstDate(pTPFilter
->GetFirstDate());
1857 pTheView
->SetLastDate(pTPFilter
->GetLastDate());
1858 pTheView
->SetFirstTime(pTPFilter
->GetFirstTime());
1859 pTheView
->SetLastTime(pTPFilter
->GetLastTime());
1860 pTheView
->SetFilterAuthor(pTPFilter
->IsAuthor());
1861 pTheView
->SetAuthor(pTPFilter
->GetSelectedAuthor());
1863 pTheView
->SetFilterComment(pTPFilter
->IsComment());
1865 utl::SearchParam
aSearchParam( pTPFilter
->GetComment(),
1866 utl::SearchParam::SRCH_REGEXP
,false,false,false );
1868 pTheView
->SetCommentParams(&aSearchParam
);
1870 pTheView
->UpdateFilterTest();
1874 IMPL_LINK_NOARG(ScAcceptChgDlg
, FilterModified
)
1882 IMPL_LINK( ScAcceptChgDlg
, ColCompareHdl
, SvSortData
*, pSortData
)
1884 sal_Int32 nCompare
= 0;
1885 SCCOL nSortCol
= static_cast<SCCOL
>(pTheView
->GetSortedCol());
1889 SvTreeListEntry
* pLeft
= (SvTreeListEntry
*)(pSortData
->pLeft
);
1890 SvTreeListEntry
* pRight
= (SvTreeListEntry
*)(pSortData
->pRight
);
1892 if(CALC_DATE
==nSortCol
)
1894 RedlinData
*pLeftData
=(RedlinData
*)(pLeft
->GetUserData());
1895 RedlinData
*pRightData
=(RedlinData
*)(pRight
->GetUserData());
1897 if(pLeftData
!=NULL
&& pRightData
!=NULL
)
1899 if(pLeftData
->aDateTime
< pRightData
->aDateTime
)
1901 else if(pLeftData
->aDateTime
> pRightData
->aDateTime
)
1906 else if(CALC_POS
==nSortCol
)
1908 ScRedlinData
*pLeftData
=(ScRedlinData
*)(pLeft
->GetUserData());
1909 ScRedlinData
*pRightData
=(ScRedlinData
*)(pRight
->GetUserData());
1911 if(pLeftData
!=NULL
&& pRightData
!=NULL
)
1915 if(pLeftData
->nTable
< pRightData
->nTable
)
1917 else if(pLeftData
->nTable
== pRightData
->nTable
)
1919 if(pLeftData
->nRow
< pRightData
->nRow
)
1921 else if(pLeftData
->nRow
== pRightData
->nRow
)
1923 if(pLeftData
->nCol
< pRightData
->nCol
)
1925 else if(pLeftData
->nCol
== pRightData
->nCol
)
1934 SvLBoxItem
* pLeftItem
= pTheView
->GetEntryAtPos( pLeft
, static_cast<sal_uInt16
>(nSortCol
));
1935 SvLBoxItem
* pRightItem
= pTheView
->GetEntryAtPos( pRight
, static_cast<sal_uInt16
>(nSortCol
));
1937 if(pLeftItem
!= NULL
&& pRightItem
!= NULL
)
1939 sal_uInt16 nLeftKind
= pLeftItem
->GetType();
1940 sal_uInt16 nRightKind
= pRightItem
->GetType();
1942 if(nRightKind
== SV_ITEM_ID_LBOXSTRING
&&
1943 nLeftKind
== SV_ITEM_ID_LBOXSTRING
)
1945 nCompare
= ScGlobal::GetCaseCollator()->compareString(
1946 ((SvLBoxString
*)pLeftItem
)->GetText(),
1947 ((SvLBoxString
*)pRightItem
)->GetText());
1959 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */