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