Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <redline.hxx>
21 : #include <tools/datetime.hxx>
22 : #include <vcl/msgbox.hxx>
23 : #include <svl/eitem.hxx>
24 : #include <sfx2/viewfrm.hxx>
25 : #include <sfx2/dispatch.hxx>
26 : #include <svx/ctredlin.hxx>
27 : #include <svx/postattr.hxx>
28 : #include <swtypes.hxx>
29 : #include <wrtsh.hxx>
30 : #include <view.hxx>
31 : #include <swmodule.hxx>
32 : #include <redlndlg.hxx>
33 : #include <swwait.hxx>
34 : #include <uitool.hxx>
35 :
36 : #include <helpid.h>
37 : #include <cmdid.h>
38 : #include <misc.hrc>
39 : #include <redlndlg.hrc>
40 : #include <shells.hrc>
41 :
42 : // -> #111827#
43 : #include <comcore.hrc>
44 : #include <swundo.hxx>
45 : #include <SwRewriter.hxx>
46 : // <- #111827#
47 :
48 : #include <vector>
49 : #include <svx/svxdlg.hxx>
50 : #include <svx/dialogs.hrc>
51 :
52 : #include <unomid.h>
53 :
54 : #include <docsh.hxx>
55 :
56 : #include <IDocumentRedlineAccess.hxx>
57 :
58 16600 : SFX_IMPL_MODELESSDIALOG_WITHID( SwRedlineAcceptChild, FN_REDLINE_ACCEPT )
59 :
60 : static sal_uInt16 nSortMode = 0xffff;
61 : static sal_Bool bSortDir = sal_True;
62 :
63 0 : SwRedlineAcceptChild::SwRedlineAcceptChild( Window* _pParent,
64 : sal_uInt16 nId,
65 : SfxBindings* pBindings,
66 : SfxChildWinInfo* pInfo ) :
67 0 : SwChildWinWrapper( _pParent, nId )
68 : {
69 0 : pWindow = new SwModelessRedlineAcceptDlg( pBindings, this, _pParent);
70 :
71 0 : ((SwModelessRedlineAcceptDlg *)pWindow)->Initialize(pInfo);
72 0 : }
73 :
74 : /*--------------------------------------------------------------------
75 : Description: newly initialise dialog after document switch
76 : --------------------------------------------------------------------*/
77 0 : sal_Bool SwRedlineAcceptChild::ReInitDlg(SwDocShell *pDocSh)
78 : {
79 : sal_Bool bRet;
80 :
81 0 : if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == sal_True) // update immediately, doc switch!
82 0 : ((SwModelessRedlineAcceptDlg*)GetWindow())->Activate();
83 :
84 0 : return bRet;
85 : }
86 :
87 0 : SwModelessRedlineAcceptDlg::SwModelessRedlineAcceptDlg(
88 : SfxBindings* _pBindings, SwChildWinWrapper* pChild, Window *_pParent)
89 : : SfxModelessDialog(_pBindings, pChild, _pParent,
90 : "AcceptRejectChangesDialog", "svx/ui/acceptrejectchangesdialog.ui")
91 0 : , pChildWin (pChild)
92 : {
93 0 : pImplDlg = new SwRedlineAcceptDlg(this);
94 0 : }
95 :
96 0 : void SwModelessRedlineAcceptDlg::Activate()
97 : {
98 0 : SwView *pView = ::GetActiveView();
99 :
100 0 : if (!pView) // can happen when switching to another app, when a Listbox in dialog
101 0 : return; // had the focus previously (actually THs Bug)
102 :
103 0 : SwDocShell *pDocSh = pView->GetDocShell();
104 :
105 0 : if (pChildWin->GetOldDocShell() != pDocSh)
106 : { // doc-switch
107 0 : SwWait aWait( *pDocSh, sal_False );
108 0 : SwWrtShell* pSh = pView->GetWrtShellPtr();
109 :
110 0 : pChildWin->SetOldDocShell(pDocSh); // avoid recursion (using modified-Hdl)
111 :
112 0 : sal_Bool bMod = pSh->IsModified();
113 0 : SfxBoolItem aShow(FN_REDLINE_SHOW, sal_True);
114 0 : pSh->GetView().GetViewFrame()->GetDispatcher()->Execute(
115 0 : FN_REDLINE_SHOW, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aShow, 0L);
116 0 : if (!bMod)
117 0 : pSh->ResetModified();
118 0 : pImplDlg->Init();
119 :
120 0 : return;
121 : }
122 :
123 0 : pImplDlg->Activate();
124 : }
125 :
126 0 : void SwModelessRedlineAcceptDlg::Initialize(SfxChildWinInfo *pInfo)
127 : {
128 0 : if (pInfo != NULL)
129 0 : pImplDlg->Initialize(pInfo->aExtraString);
130 :
131 0 : SfxModelessDialog::Initialize(pInfo);
132 0 : }
133 :
134 0 : void SwModelessRedlineAcceptDlg::FillInfo(SfxChildWinInfo& rInfo) const
135 : {
136 0 : SfxModelessDialog::FillInfo(rInfo);
137 0 : pImplDlg->FillInfo(rInfo.aExtraString);
138 0 : }
139 :
140 0 : SwModelessRedlineAcceptDlg::~SwModelessRedlineAcceptDlg()
141 : {
142 0 : delete pImplDlg;
143 0 : }
144 :
145 0 : SwRedlineAcceptDlg::SwRedlineAcceptDlg(Dialog *pParent, sal_Bool bAutoFmt) :
146 : pParentDlg (pParent),
147 0 : aTabPagesCTRL (pParent->get_content_area()),
148 : aPopup (SW_RES(MN_REDLINE_POPUP)),
149 : sInserted (SW_RES(STR_REDLINE_INSERTED)),
150 : sDeleted (SW_RES(STR_REDLINE_DELETED)),
151 : sFormated (SW_RES(STR_REDLINE_FORMATED)),
152 : sTableChgd (SW_RES(STR_REDLINE_TABLECHG)),
153 : sFmtCollSet (SW_RES(STR_REDLINE_FMTCOLLSET)),
154 : sAutoFormat (SW_RES(STR_REDLINE_AUTOFMT)),
155 : bOnlyFormatedRedlines( sal_False ),
156 : bHasReadonlySel ( sal_False ),
157 : bRedlnAutoFmt (bAutoFmt),
158 0 : bInhibitActivate( false )
159 : {
160 0 : aTabPagesCTRL.SetHelpId(HID_REDLINE_CTRL);
161 0 : pTPView = aTabPagesCTRL.GetViewPage();
162 0 : pTable = pTPView->GetTableControl();
163 :
164 0 : pTPView->InsertWriterHeader();
165 0 : pTPView->SetAcceptClickHdl(LINK(this, SwRedlineAcceptDlg, AcceptHdl));
166 0 : pTPView->SetAcceptAllClickHdl(LINK(this, SwRedlineAcceptDlg, AcceptAllHdl));
167 0 : pTPView->SetRejectClickHdl(LINK(this, SwRedlineAcceptDlg, RejectHdl));
168 0 : pTPView->SetRejectAllClickHdl(LINK(this, SwRedlineAcceptDlg, RejectAllHdl));
169 0 : pTPView->SetUndoClickHdl(LINK(this, SwRedlineAcceptDlg, UndoHdl));
170 :
171 0 : aTabPagesCTRL.GetFilterPage()->SetReadyHdl(LINK(this, SwRedlineAcceptDlg, FilterChangedHdl));
172 :
173 0 : ListBox *pActLB = aTabPagesCTRL.GetFilterPage()->GetLbAction();
174 0 : pActLB->InsertEntry(sInserted);
175 0 : pActLB->InsertEntry(sDeleted);
176 0 : pActLB->InsertEntry(sFormated);
177 0 : pActLB->InsertEntry(sTableChgd);
178 :
179 0 : if (HasRedlineAutoFmt())
180 : {
181 0 : pActLB->InsertEntry(sFmtCollSet);
182 0 : pActLB->InsertEntry(sAutoFormat);
183 0 : pTPView->ShowUndo(sal_True);
184 0 : pTPView->DisableUndo(); // no UNDO events yet
185 : }
186 :
187 0 : pActLB->SelectEntryPos(0);
188 :
189 0 : pTable->SetStyle(pTable->GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
190 0 : pTable->SetNodeDefaultImages();
191 0 : pTable->SetSelectionMode(MULTIPLE_SELECTION);
192 0 : pTable->SetHighlightRange(1);
193 :
194 : static long aStaticTabs[]=
195 : {
196 : 4,10,70,120,170
197 : };
198 :
199 0 : pTable->SetTabs(aStaticTabs);
200 :
201 0 : pTable->SortByCol(nSortMode, bSortDir);
202 :
203 0 : aOldSelectHdl = pTable->GetSelectHdl();
204 0 : aOldDeselectHdl = pTable->GetDeselectHdl();
205 0 : pTable->SetSelectHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl));
206 0 : pTable->SetDeselectHdl(LINK(this, SwRedlineAcceptDlg, DeselectHdl));
207 0 : pTable->SetCommandHdl(LINK(this, SwRedlineAcceptDlg, CommandHdl));
208 :
209 : // avoid flickering of buttons:
210 0 : aDeselectTimer.SetTimeout(100);
211 0 : aDeselectTimer.SetTimeoutHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl));
212 :
213 : // avoid multiple selection of the same texts:
214 0 : aSelectTimer.SetTimeout(100);
215 0 : aSelectTimer.SetTimeoutHdl(LINK(this, SwRedlineAcceptDlg, GotoHdl));
216 0 : }
217 :
218 0 : SwRedlineAcceptDlg::~SwRedlineAcceptDlg()
219 : {
220 0 : }
221 :
222 0 : void SwRedlineAcceptDlg::Init(sal_uInt16 nStart)
223 : {
224 0 : SwWait aWait( *::GetActiveView()->GetDocShell(), sal_False );
225 0 : pTable->SetUpdateMode(sal_False);
226 0 : aUsedSeqNo.clear();
227 :
228 0 : if (nStart)
229 0 : RemoveParents(nStart, aRedlineParents.size() - 1);
230 : else
231 : {
232 0 : pTable->Clear();
233 0 : aRedlineChildren.clear();
234 0 : aRedlineParents.erase(aRedlineParents.begin() + nStart, aRedlineParents.end());
235 : }
236 :
237 : // insert parents
238 0 : InsertParents(nStart);
239 0 : InitAuthors();
240 :
241 0 : pTable->SetUpdateMode(sal_True);
242 : // #i69618# this moves the list box to the right position, visually
243 0 : SvTreeListEntry* pSelEntry = pTable->FirstSelected();
244 0 : if( pSelEntry )
245 0 : pTable->MakeVisible( pSelEntry, sal_True ); //#i70937#, force the scroll
246 0 : }
247 :
248 0 : void SwRedlineAcceptDlg::InitAuthors()
249 : {
250 0 : SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
251 :
252 0 : SvxTPFilter *pFilterPage = aTabPagesCTRL.GetFilterPage();
253 :
254 0 : std::vector<String> aStrings;
255 0 : String sOldAuthor(pFilterPage->GetSelectedAuthor());
256 0 : pFilterPage->ClearAuthors();
257 :
258 0 : sal_uInt16 nCount = pSh->GetRedlineCount();
259 :
260 0 : bOnlyFormatedRedlines = sal_True;
261 0 : bHasReadonlySel = sal_False;
262 0 : sal_Bool bIsNotFormated = sal_False;
263 : sal_uInt16 i;
264 :
265 : // determine authors
266 0 : for ( i = 0; i < nCount; i++)
267 : {
268 0 : const SwRedline& rRedln = pSh->GetRedline(i);
269 :
270 0 : if( bOnlyFormatedRedlines && nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType() )
271 0 : bOnlyFormatedRedlines = sal_False;
272 :
273 0 : aStrings.push_back(rRedln.GetAuthorString());
274 :
275 0 : for (sal_uInt16 nStack = 1; nStack < rRedln.GetStackCount(); nStack++)
276 : {
277 0 : aStrings.push_back(rRedln.GetAuthorString(nStack));
278 : }
279 : }
280 :
281 0 : std::sort(aStrings.begin(), aStrings.end());
282 0 : aStrings.erase(std::unique(aStrings.begin(), aStrings.end()), aStrings.end());
283 :
284 0 : for (i = 0; i < aStrings.size(); i++)
285 0 : pFilterPage->InsertAuthor(aStrings[i]);
286 :
287 0 : if (pFilterPage->SelectAuthor(sOldAuthor) == LISTBOX_ENTRY_NOTFOUND && !aStrings.empty())
288 0 : pFilterPage->SelectAuthor(aStrings[0]);
289 :
290 0 : bool bEnable = pTable->GetEntryCount() != 0 && !pSh->getIDocumentRedlineAccess()->GetRedlinePassword().getLength();
291 0 : bool bSel = pTable->FirstSelected() != 0;
292 :
293 0 : SvTreeListEntry* pSelEntry = pTable->FirstSelected();
294 0 : while (pSelEntry)
295 : {
296 : // find the selected redline
297 : // (fdo#57874: ignore, if the redline is already gone)
298 0 : sal_uInt16 nPos = GetRedlinePos(*pSelEntry);
299 0 : if( nPos != USHRT_MAX )
300 : {
301 0 : const SwRedline& rRedln = pSh->GetRedline( nPos );
302 :
303 0 : bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType();
304 : }
305 0 : pSelEntry = pTable->NextSelected(pSelEntry);
306 : }
307 :
308 0 : pTPView->EnableAccept( bEnable && bSel );
309 0 : pTPView->EnableReject( bEnable && bIsNotFormated && bSel );
310 0 : pTPView->EnableAcceptAll( bEnable && !bHasReadonlySel );
311 0 : pTPView->EnableRejectAll( bEnable && !bHasReadonlySel &&
312 0 : !bOnlyFormatedRedlines );
313 0 : }
314 :
315 0 : String SwRedlineAcceptDlg::GetRedlineText( const SwRedline& rRedln,
316 : DateTime &rDateTime, sal_uInt16 nStack)
317 : {
318 0 : String sEntry(GetActionText(rRedln, nStack));
319 0 : sEntry += '\t';
320 0 : sEntry += rRedln.GetAuthorString(nStack);
321 0 : sEntry += '\t';
322 :
323 0 : const DateTime &rDT = rRedln.GetTimeStamp(nStack);
324 0 : rDateTime = rDT;
325 :
326 0 : sEntry += GetAppLangDateTimeString( rDT );
327 0 : sEntry += '\t';
328 :
329 0 : sEntry += rRedln.GetComment(nStack);
330 :
331 0 : return sEntry;
332 : }
333 :
334 0 : const String &SwRedlineAcceptDlg::GetActionText(const SwRedline& rRedln, sal_uInt16 nStack)
335 : {
336 0 : switch( rRedln.GetType(nStack) )
337 : {
338 0 : case nsRedlineType_t::REDLINE_INSERT: return sInserted;
339 0 : case nsRedlineType_t::REDLINE_DELETE: return sDeleted;
340 0 : case nsRedlineType_t::REDLINE_FORMAT: return sFormated;
341 0 : case nsRedlineType_t::REDLINE_TABLE: return sTableChgd;
342 0 : case nsRedlineType_t::REDLINE_FMTCOLL: return sFmtCollSet;
343 : default:;//prevent warning
344 : }
345 :
346 0 : return aEmptyStr;
347 : }
348 :
349 : /*--------------------------------------------------------------------
350 : Description: newly initialise after activation
351 : --------------------------------------------------------------------*/
352 0 : void SwRedlineAcceptDlg::Activate()
353 : {
354 : // prevent update if flag is set (#102547#)
355 0 : if( bInhibitActivate )
356 0 : return;
357 :
358 0 : SwView *pView = ::GetActiveView();
359 :
360 0 : if (!pView) // can happen when switching to another app, when a Listbox in the dialog
361 0 : return; // had the focus previously (actually THs Bug)
362 :
363 0 : SwWait aWait( *pView->GetDocShell(), sal_False );
364 :
365 0 : aUsedSeqNo.clear();
366 :
367 : // did something change?
368 0 : SwWrtShell* pSh = pView->GetWrtShellPtr();
369 0 : sal_uInt16 nCount = pSh->GetRedlineCount();
370 :
371 : // check the number of pointers
372 0 : SwRedlineDataParent *pParent = 0;
373 : sal_uInt16 i;
374 :
375 0 : for ( i = 0; i < nCount; i++)
376 : {
377 0 : const SwRedline& rRedln = pSh->GetRedline(i);
378 :
379 0 : if (i >= aRedlineParents.size())
380 : {
381 : // new entries have been appended
382 0 : Init(i);
383 0 : return;
384 : }
385 :
386 0 : pParent = &aRedlineParents[i];
387 0 : if (&rRedln.GetRedlineData() != pParent->pData)
388 : {
389 : // Redline-Parents were inserted, changed or deleted
390 0 : if ((i = CalcDiff(i, sal_False)) == USHRT_MAX)
391 0 : return;
392 0 : continue;
393 : }
394 :
395 0 : const SwRedlineData *pRedlineData = rRedln.GetRedlineData().Next();
396 0 : const SwRedlineDataChild *pBackupData = pParent->pNext;
397 :
398 0 : if (!pRedlineData && pBackupData)
399 : {
400 : // Redline-Children were deleted
401 0 : if ((i = CalcDiff(i, sal_True)) == USHRT_MAX)
402 0 : return;
403 0 : continue;
404 : }
405 : else
406 : {
407 0 : while (pRedlineData)
408 : {
409 0 : if (pRedlineData != pBackupData->pChild)
410 : {
411 : // Redline-Children were inserted, changed or deleted
412 0 : if ((i = CalcDiff(i, sal_True)) == USHRT_MAX)
413 0 : return;
414 0 : continue;
415 : }
416 0 : if (pBackupData)
417 0 : pBackupData = pBackupData->pNext;
418 0 : pRedlineData = pRedlineData->Next();
419 : }
420 : }
421 : }
422 :
423 0 : if (nCount != aRedlineParents.size())
424 : {
425 : // Redlines were deleted at the end
426 0 : Init(nCount);
427 0 : return;
428 : }
429 :
430 : // check comment
431 0 : for (i = 0; i < nCount; i++)
432 : {
433 0 : const SwRedline& rRedln = pSh->GetRedline(i);
434 0 : pParent = &aRedlineParents[i];
435 :
436 0 : if(!rRedln.GetComment().Equals(pParent->sComment))
437 : {
438 0 : if (pParent->pTLBParent)
439 : {
440 : // update only comment
441 0 : String sComment(rRedln.GetComment());
442 0 : sComment.SearchAndReplaceAll((sal_Unicode)'\n',(sal_Unicode)' ');
443 0 : pTable->SetEntryText(sComment, pParent->pTLBParent, 3);
444 : }
445 0 : pParent->sComment = rRedln.GetComment();
446 : }
447 : }
448 :
449 0 : InitAuthors();
450 : }
451 :
452 0 : sal_uInt16 SwRedlineAcceptDlg::CalcDiff(sal_uInt16 nStart, sal_Bool bChild)
453 : {
454 0 : if (!nStart)
455 : {
456 0 : Init();
457 0 : return USHRT_MAX;
458 : }
459 :
460 0 : pTable->SetUpdateMode(sal_False);
461 0 : SwView *pView = ::GetActiveView();
462 0 : SwWrtShell* pSh = pView->GetWrtShellPtr();
463 0 : sal_uInt16 nAutoFmt = HasRedlineAutoFmt() ? nsRedlineType_t::REDLINE_FORM_AUTOFMT : 0;
464 0 : SwRedlineDataParent *pParent = &aRedlineParents[nStart];
465 0 : const SwRedline& rRedln = pSh->GetRedline(nStart);
466 :
467 0 : if (bChild) // should actually never happen, but just in case...
468 : {
469 : // throw away all entry's children and initialise newly
470 0 : SwRedlineDataChild* pBackupData = (SwRedlineDataChild*)pParent->pNext;
471 : SwRedlineDataChild* pNext;
472 :
473 0 : while (pBackupData)
474 : {
475 0 : pNext = (SwRedlineDataChild*)pBackupData->pNext;
476 0 : if (pBackupData->pTLBChild)
477 0 : pTable->RemoveEntry(pBackupData->pTLBChild);
478 :
479 0 : for( SwRedlineDataChildArr::iterator it = aRedlineChildren.begin();
480 0 : it != aRedlineChildren.end(); ++it)
481 0 : if (&*it == pBackupData)
482 : {
483 0 : aRedlineChildren.erase(it);
484 0 : break;
485 : }
486 0 : pBackupData = pNext;
487 : }
488 0 : pParent->pNext = 0;
489 :
490 : // insert new children
491 0 : InsertChildren(pParent, rRedln, nAutoFmt);
492 :
493 0 : pTable->SetUpdateMode(sal_True);
494 0 : return nStart;
495 : }
496 :
497 : // have entries been deleted?
498 0 : const SwRedlineData *pRedlineData = &rRedln.GetRedlineData();
499 : sal_uInt16 i;
500 0 : for ( i = nStart + 1; i < aRedlineParents.size(); i++)
501 : {
502 0 : if (aRedlineParents[i].pData == pRedlineData)
503 : {
504 : // remove entries from nStart to i-1
505 0 : RemoveParents(nStart, i - 1);
506 0 : pTable->SetUpdateMode(sal_True);
507 0 : return nStart - 1;
508 : }
509 : }
510 :
511 : // entries been inserted?
512 0 : sal_uInt16 nCount = pSh->GetRedlineCount();
513 0 : pRedlineData = aRedlineParents[nStart].pData;
514 :
515 0 : for (i = nStart + 1; i < nCount; i++)
516 : {
517 0 : if (&pSh->GetRedline(i).GetRedlineData() == pRedlineData)
518 : {
519 : // insert entries from nStart to i-1
520 0 : InsertParents(nStart, i - 1);
521 0 : pTable->SetUpdateMode(sal_True);
522 0 : return nStart - 1;
523 : }
524 : }
525 :
526 0 : pTable->SetUpdateMode(sal_True);
527 0 : Init(nStart); // adjust all entries until the end
528 0 : return USHRT_MAX;
529 : }
530 :
531 0 : void SwRedlineAcceptDlg::InsertChildren(SwRedlineDataParent *pParent, const SwRedline& rRedln, const sal_uInt16 nAutoFmt)
532 : {
533 0 : String sChild;
534 0 : SwRedlineDataChild *pLastRedlineChild = 0;
535 0 : const SwRedlineData *pRedlineData = &rRedln.GetRedlineData();
536 0 : bool bAutoFmt = (rRedln.GetRealType() & nAutoFmt) != 0;
537 :
538 0 : const String *pAction = &GetActionText(rRedln);
539 0 : sal_Bool bValidParent = !sFilterAction.Len() || sFilterAction == *pAction;
540 0 : bValidParent = bValidParent && pTable->IsValidEntry(&rRedln.GetAuthorString(), &rRedln.GetTimeStamp(), &rRedln.GetComment());
541 0 : if (nAutoFmt)
542 : {
543 :
544 0 : if (pParent->pData->GetSeqNo())
545 : {
546 : std::pair<SwRedlineDataParentSortArr::const_iterator,bool> const ret
547 0 : = aUsedSeqNo.insert(pParent);
548 0 : if (ret.second) // already there
549 : {
550 0 : if (pParent->pTLBParent)
551 : {
552 : pTable->SetEntryText(
553 0 : sAutoFormat, (*ret.first)->pTLBParent, 0);
554 0 : pTable->RemoveEntry(pParent->pTLBParent);
555 0 : pParent->pTLBParent = 0;
556 : }
557 0 : return;
558 : }
559 : }
560 0 : bValidParent = bValidParent && bAutoFmt;
561 : }
562 0 : sal_Bool bValidTree = bValidParent;
563 :
564 0 : for (sal_uInt16 nStack = 1; nStack < rRedln.GetStackCount(); nStack++)
565 : {
566 0 : pRedlineData = pRedlineData->Next();
567 :
568 0 : SwRedlineDataChildPtr pRedlineChild = new SwRedlineDataChild;
569 0 : pRedlineChild->pChild = pRedlineData;
570 0 : aRedlineChildren.push_back(pRedlineChild);
571 :
572 0 : if ( pLastRedlineChild )
573 0 : pLastRedlineChild->pNext = pRedlineChild;
574 : else
575 0 : pParent->pNext = pRedlineChild;
576 :
577 0 : pAction = &GetActionText(rRedln, nStack);
578 0 : sal_Bool bValidChild = !sFilterAction.Len() || sFilterAction == *pAction;
579 0 : bValidChild = bValidChild && pTable->IsValidEntry(&rRedln.GetAuthorString(nStack), &rRedln.GetTimeStamp(nStack), &rRedln.GetComment());
580 0 : if (nAutoFmt)
581 0 : bValidChild = bValidChild && bAutoFmt;
582 0 : bValidTree |= bValidChild;
583 :
584 0 : if (bValidChild)
585 : {
586 0 : RedlinData *pData = new RedlinData;
587 0 : pData->pData = pRedlineChild;
588 0 : pData->bDisabled = sal_True;
589 0 : sChild = GetRedlineText(rRedln, pData->aDateTime, nStack);
590 :
591 0 : SvTreeListEntry* pChild = pTable->InsertEntry(sChild, pData, pParent->pTLBParent);
592 :
593 0 : pRedlineChild->pTLBChild = pChild;
594 0 : if (!bValidParent)
595 0 : pTable->Expand(pParent->pTLBParent);
596 : }
597 : else
598 0 : pRedlineChild->pTLBChild = 0;
599 :
600 0 : pLastRedlineChild = pRedlineChild;
601 : }
602 :
603 0 : if (pLastRedlineChild)
604 0 : pLastRedlineChild->pNext = 0;
605 :
606 0 : if (!bValidTree && pParent->pTLBParent)
607 : {
608 0 : pTable->RemoveEntry(pParent->pTLBParent);
609 0 : pParent->pTLBParent = 0;
610 0 : if (nAutoFmt)
611 0 : aUsedSeqNo.erase(pParent);
612 0 : }
613 : }
614 :
615 0 : void SwRedlineAcceptDlg::RemoveParents(sal_uInt16 nStart, sal_uInt16 nEnd)
616 : {
617 0 : SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
618 0 : sal_uInt16 nCount = pSh->GetRedlineCount();
619 :
620 0 : SvLBoxEntryArr aLBoxArr;
621 :
622 : // because of Bug of TLB that ALWAYS calls the SelectHandler at Remove:
623 0 : pTable->SetSelectHdl(aOldSelectHdl);
624 0 : pTable->SetDeselectHdl(aOldDeselectHdl);
625 0 : bool bChildrenRemoved = false;
626 0 : pTable->SelectAll(sal_False);
627 :
628 : // set the cursor after the last entry because otherwise performance problem in TLB.
629 : // TLB would otherwise reset the cursor at every Remove (expensive)
630 0 : sal_uInt16 nPos = std::min((sal_uInt16)nCount, (sal_uInt16)aRedlineParents.size());
631 0 : SvTreeListEntry *pCurEntry = NULL;
632 0 : while( ( pCurEntry == NULL ) && ( nPos > 0 ) )
633 : {
634 0 : --nPos;
635 0 : pCurEntry = aRedlineParents[nPos].pTLBParent;
636 : }
637 :
638 0 : if (pCurEntry)
639 0 : pTable->SetCurEntry(pCurEntry);
640 :
641 0 : SvTreeList* pModel = pTable->GetModel();
642 :
643 0 : for (sal_uInt16 i = nStart; i <= nEnd; i++)
644 : {
645 0 : if (!bChildrenRemoved && aRedlineParents[i].pNext)
646 : {
647 0 : SwRedlineDataChildPtr pChildPtr = (SwRedlineDataChildPtr)aRedlineParents[i].pNext;
648 0 : for( SwRedlineDataChildArr::iterator it = aRedlineChildren.begin();
649 0 : it != aRedlineChildren.end(); ++it)
650 0 : if (&*it == pChildPtr)
651 : {
652 0 : sal_uInt16 nChildren = 0;
653 0 : while (pChildPtr)
654 : {
655 0 : pChildPtr = (SwRedlineDataChildPtr)pChildPtr->pNext;
656 0 : nChildren++;
657 : }
658 :
659 0 : aRedlineChildren.erase(it, it + nChildren);
660 0 : bChildrenRemoved = true;
661 0 : break;
662 : }
663 : }
664 0 : SvTreeListEntry *pEntry = aRedlineParents[i].pTLBParent;
665 0 : if (pEntry)
666 : {
667 0 : long nIdx = aLBoxArr.size() - 1L;
668 0 : sal_uLong nAbsPos = pModel->GetAbsPos(pEntry);
669 0 : while (nIdx >= 0 &&
670 0 : pModel->GetAbsPos(aLBoxArr[ static_cast< sal_uInt16 >(nIdx) ]) > nAbsPos)
671 0 : nIdx--;
672 0 : aLBoxArr.insert( aLBoxArr.begin() + static_cast< sal_uInt16 >(++nIdx) , pEntry);
673 : }
674 : }
675 :
676 : // clear TLB from behind
677 0 : long nIdx = (long)aLBoxArr.size() - 1L;
678 0 : while (nIdx >= 0)
679 0 : pTable->RemoveEntry(aLBoxArr[ static_cast< sal_uInt16 >(nIdx--) ]);
680 :
681 0 : pTable->SetSelectHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl));
682 0 : pTable->SetDeselectHdl(LINK(this, SwRedlineAcceptDlg, DeselectHdl));
683 : // unfortunately by Remove it was selected from the TLB always again ...
684 0 : pTable->SelectAll(sal_False);
685 :
686 0 : aRedlineParents.erase( aRedlineParents.begin() + nStart, aRedlineParents.begin() + nEnd + 1);
687 0 : }
688 :
689 0 : void SwRedlineAcceptDlg::InsertParents(sal_uInt16 nStart, sal_uInt16 nEnd)
690 : {
691 0 : SwView *pView = ::GetActiveView();
692 0 : SwWrtShell* pSh = pView->GetWrtShellPtr();
693 0 : sal_uInt16 nAutoFmt = HasRedlineAutoFmt() ? nsRedlineType_t::REDLINE_FORM_AUTOFMT : 0;
694 :
695 0 : String sParent;
696 0 : sal_uInt16 nCount = pSh->GetRedlineCount();
697 0 : nEnd = std::min((sal_uInt16)nEnd, (sal_uInt16)(nCount - 1)); // also treats nEnd=USHRT_MAX (until the end)
698 :
699 0 : if (nEnd == USHRT_MAX)
700 0 : return; // no redlines in the document
701 :
702 : RedlinData *pData;
703 : SvTreeListEntry *pParent;
704 : SwRedlineDataParent* pRedlineParent;
705 : const SwRedline* pCurrRedline;
706 0 : if( !nStart && !pTable->FirstSelected() )
707 : {
708 0 : pCurrRedline = pSh->GetCurrRedline();
709 0 : if( !pCurrRedline )
710 : {
711 0 : pSh->SwCrsrShell::Push();
712 0 : if( 0 == (pCurrRedline = pSh->SelNextRedline()))
713 0 : pCurrRedline = pSh->SelPrevRedline();
714 0 : pSh->SwCrsrShell::Pop( sal_False );
715 : }
716 : }
717 : else
718 0 : pCurrRedline = 0;
719 :
720 0 : for (sal_uInt16 i = nStart; i <= nEnd; i++)
721 : {
722 0 : const SwRedline& rRedln = pSh->GetRedline(i);
723 0 : const SwRedlineData *pRedlineData = &rRedln.GetRedlineData();
724 :
725 0 : pRedlineParent = new SwRedlineDataParent;
726 0 : pRedlineParent->pData = pRedlineData;
727 0 : pRedlineParent->pNext = 0;
728 0 : String sComment(rRedln.GetComment());
729 0 : sComment.SearchAndReplaceAll((sal_Unicode)'\n',(sal_Unicode)' ');
730 0 : pRedlineParent->sComment = sComment;
731 0 : aRedlineParents.insert(aRedlineParents.begin() + i, pRedlineParent);
732 :
733 0 : pData = new RedlinData;
734 0 : pData->pData = pRedlineParent;
735 0 : pData->bDisabled = sal_False;
736 :
737 0 : sParent = GetRedlineText(rRedln, pData->aDateTime);
738 0 : pParent = pTable->InsertEntry(sParent, pData, 0, i);
739 0 : if( pCurrRedline == &rRedln )
740 : {
741 0 : pTable->SetCurEntry( pParent );
742 0 : pTable->Select( pParent );
743 0 : pTable->MakeVisible( pParent );
744 : }
745 :
746 0 : pRedlineParent->pTLBParent = pParent;
747 :
748 0 : InsertChildren(pRedlineParent, rRedln, nAutoFmt);
749 0 : }
750 : }
751 :
752 0 : void SwRedlineAcceptDlg::CallAcceptReject( sal_Bool bSelect, sal_Bool bAccept )
753 : {
754 0 : SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
755 0 : SvTreeListEntry* pEntry = bSelect ? pTable->FirstSelected() : pTable->First();
756 0 : sal_uLong nPos = LONG_MAX;
757 :
758 : typedef std::vector<SvTreeListEntry*> ListBoxEntries_t;
759 0 : ListBoxEntries_t aRedlines;
760 :
761 : // don't activate
762 : OSL_ENSURE( bInhibitActivate == false,
763 : "recursive call of CallAcceptReject?");
764 0 : bInhibitActivate = true;
765 :
766 : // collect redlines-to-be-accepted/rejected in aRedlines vector
767 0 : while( pEntry )
768 : {
769 0 : if( !pTable->GetParent( pEntry ) )
770 : {
771 0 : if( bSelect && LONG_MAX == nPos )
772 0 : nPos = pTable->GetModel()->GetAbsPos( pEntry );
773 :
774 0 : RedlinData *pData = (RedlinData *)pEntry->GetUserData();
775 :
776 0 : if( !pData->bDisabled )
777 0 : aRedlines.push_back( pEntry );
778 : }
779 :
780 0 : pEntry = bSelect ? pTable->NextSelected(pEntry) : pTable->Next(pEntry);
781 : }
782 :
783 0 : sal_Bool (SwEditShell:: *FnAccRej)( sal_uInt16 ) = &SwEditShell::AcceptRedline;
784 0 : if( !bAccept )
785 0 : FnAccRej = &SwEditShell::RejectRedline;
786 :
787 0 : SwWait aWait( *pSh->GetView().GetDocShell(), sal_True );
788 0 : pSh->StartAction();
789 :
790 : // #111827#
791 0 : if (aRedlines.size() > 1)
792 : {
793 0 : String aTmpStr;
794 : {
795 0 : SwRewriter aRewriter;
796 : aRewriter.AddRule(UndoArg1,
797 0 : OUString::number(aRedlines.size()));
798 0 : aTmpStr = aRewriter.Apply(String(SW_RES(STR_N_REDLINES)));
799 : }
800 :
801 0 : SwRewriter aRewriter;
802 0 : aRewriter.AddRule(UndoArg1, aTmpStr);
803 :
804 : pSh->StartUndo(bAccept? UNDO_ACCEPT_REDLINE : UNDO_REJECT_REDLINE,
805 0 : &aRewriter);
806 : }
807 :
808 : // accept/reject the redlines in aRedlines. The absolute
809 : // position may change during the process (e.g. when two redlines
810 : // are merged in result of another one being deleted), so the
811 : // position must be resolved late and checked before using it.
812 : // (cf #102547#)
813 0 : ListBoxEntries_t::iterator aEnd = aRedlines.end();
814 0 : for( ListBoxEntries_t::iterator aIter = aRedlines.begin();
815 : aIter != aEnd;
816 : ++aIter )
817 : {
818 0 : sal_uInt16 nPosition = GetRedlinePos( **aIter );
819 0 : if( nPosition != USHRT_MAX )
820 0 : (pSh->*FnAccRej)( nPosition );
821 : }
822 :
823 : // #111827#
824 0 : if (aRedlines.size() > 1)
825 : {
826 0 : pSh->EndUndo();
827 : }
828 :
829 0 : pSh->EndAction();
830 :
831 0 : bInhibitActivate = false;
832 0 : Activate();
833 :
834 0 : if( ULONG_MAX != nPos && pTable->GetEntryCount() )
835 : {
836 0 : if( nPos >= pTable->GetEntryCount() )
837 0 : nPos = pTable->GetEntryCount() - 1;
838 0 : pEntry = pTable->GetEntry( nPos );
839 0 : if( !pEntry && nPos-- )
840 0 : pEntry = pTable->GetEntry( nPos );
841 0 : if( pEntry )
842 : {
843 0 : pTable->Select( pEntry );
844 0 : pTable->MakeVisible( pEntry );
845 0 : pTable->SetCurEntry(pEntry);
846 : }
847 : }
848 0 : pTPView->EnableUndo();
849 0 : }
850 :
851 0 : sal_uInt16 SwRedlineAcceptDlg::GetRedlinePos( const SvTreeListEntry& rEntry ) const
852 : {
853 0 : SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
854 : return pSh->FindRedlineOfData( *((SwRedlineDataParent*)((RedlinData *)
855 0 : rEntry.GetUserData())->pData)->pData );
856 : }
857 :
858 0 : IMPL_LINK_NOARG(SwRedlineAcceptDlg, AcceptHdl)
859 : {
860 0 : CallAcceptReject( sal_True, sal_True );
861 0 : return 0;
862 : }
863 :
864 0 : IMPL_LINK_NOARG(SwRedlineAcceptDlg, AcceptAllHdl)
865 : {
866 0 : CallAcceptReject( sal_False, sal_True );
867 0 : return 0;
868 : }
869 :
870 0 : IMPL_LINK_NOARG(SwRedlineAcceptDlg, RejectHdl)
871 : {
872 0 : CallAcceptReject( sal_True, sal_False );
873 0 : return 0;
874 : }
875 :
876 0 : IMPL_LINK_NOARG(SwRedlineAcceptDlg, RejectAllHdl)
877 : {
878 0 : CallAcceptReject( sal_False, sal_False );
879 0 : return 0;
880 : }
881 :
882 0 : IMPL_LINK_NOARG(SwRedlineAcceptDlg, UndoHdl)
883 : {
884 0 : SwView * pView = ::GetActiveView();
885 : pView->GetViewFrame()->GetDispatcher()->
886 0 : Execute(SID_UNDO, SFX_CALLMODE_SYNCHRON);
887 0 : pTPView->EnableUndo(pView->GetSlotState(SID_UNDO) != 0);
888 :
889 0 : Activate();
890 :
891 0 : return 0;
892 : }
893 :
894 0 : IMPL_LINK_NOARG(SwRedlineAcceptDlg, FilterChangedHdl)
895 : {
896 0 : SvxTPFilter *pFilterTP = aTabPagesCTRL.GetFilterPage();
897 :
898 0 : if (pFilterTP->IsAction())
899 0 : sFilterAction = pFilterTP->GetLbAction()->GetSelectEntry();
900 : else
901 0 : sFilterAction = aEmptyStr;
902 :
903 0 : Init();
904 :
905 0 : return 0;
906 : }
907 :
908 0 : IMPL_LINK_NOARG(SwRedlineAcceptDlg, DeselectHdl)
909 : {
910 : // avoid flickering of buttons:
911 0 : aDeselectTimer.Start();
912 :
913 0 : return 0;
914 : }
915 :
916 0 : IMPL_LINK_NOARG(SwRedlineAcceptDlg, SelectHdl)
917 : {
918 0 : aDeselectTimer.Stop();
919 0 : aSelectTimer.Start();
920 :
921 0 : return 0;
922 : }
923 :
924 0 : IMPL_LINK_NOARG(SwRedlineAcceptDlg, GotoHdl)
925 : {
926 0 : SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
927 0 : aSelectTimer.Stop();
928 :
929 0 : sal_Bool bIsNotFormated = sal_False;
930 0 : bool bSel = false;
931 :
932 : //#98883# don't select redlines while the dialog is not focussed
933 : //#107938# But not only ask pTable if it has the focus. To move
934 : // the selection to the selected redline any child of pParentDlg
935 : // may the focus.
936 0 : SvTreeListEntry* pSelEntry = 0;
937 :
938 0 : if (pParentDlg->HasChildPathFocus())
939 0 : pSelEntry = pTable->FirstSelected();
940 :
941 0 : if( pSelEntry )
942 : {
943 0 : SvTreeListEntry* pActEntry = pSelEntry;
944 0 : pSh->StartAction();
945 0 : pSh->EnterStdMode();
946 0 : pSh->SetCareWin(pParentDlg);
947 :
948 0 : while (pSelEntry)
949 : {
950 0 : if (pTable->GetParent(pSelEntry))
951 : {
952 0 : pActEntry = pTable->GetParent(pSelEntry);
953 :
954 0 : if (pTable->IsSelected(pActEntry))
955 : {
956 0 : pSelEntry = pActEntry = pTable->NextSelected(pSelEntry);
957 0 : continue; // don't select twice
958 : }
959 : }
960 : else
961 0 : bSel = true;
962 :
963 : // #98864# find the selected redline (ignore, if the redline is already gone)
964 0 : sal_uInt16 nPos = GetRedlinePos(*pActEntry);
965 0 : if( nPos != USHRT_MAX )
966 : {
967 :
968 0 : const SwRedline& rRedln = pSh->GetRedline( nPos );
969 0 : bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType();
970 :
971 0 : if (pSh->GotoRedline(nPos, sal_True))
972 : {
973 0 : pSh->SetInSelect();
974 0 : pSh->EnterAddMode();
975 : }
976 : }
977 :
978 0 : pSelEntry = pActEntry = pTable->NextSelected(pSelEntry);
979 : }
980 :
981 0 : pSh->LeaveAddMode();
982 0 : pSh->EndAction();
983 0 : pSh->SetCareWin(NULL);
984 : }
985 0 : bool bEnable = !pSh->getIDocumentRedlineAccess()->GetRedlinePassword().getLength();
986 0 : pTPView->EnableAccept( bEnable && bSel /*&& !bReadonlySel*/ );
987 0 : pTPView->EnableReject( bEnable && bSel && bIsNotFormated /*&& !bReadonlySel*/ );
988 0 : pTPView->EnableRejectAll( bEnable && !bOnlyFormatedRedlines && !bHasReadonlySel );
989 :
990 0 : return 0;
991 : }
992 :
993 0 : IMPL_LINK_NOARG(SwRedlineAcceptDlg, CommandHdl)
994 : {
995 0 : const CommandEvent aCEvt(pTable->GetCommandEvent());
996 :
997 0 : switch ( aCEvt.GetCommand() )
998 : {
999 : case COMMAND_CONTEXTMENU:
1000 : {
1001 0 : SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
1002 0 : SvTreeListEntry* pEntry = pTable->FirstSelected();
1003 0 : const SwRedline *pRed = 0;
1004 :
1005 0 : if (pEntry)
1006 : {
1007 0 : SvTreeListEntry* pTopEntry = pEntry;
1008 :
1009 0 : if (pTable->GetParent(pEntry))
1010 0 : pTopEntry = pTable->GetParent(pEntry);
1011 :
1012 0 : sal_uInt16 nPos = GetRedlinePos(*pTopEntry);
1013 :
1014 : // disable commenting for protected areas
1015 0 : if (nPos != USHRT_MAX && (pRed = pSh->GotoRedline(nPos, sal_True)) != 0)
1016 : {
1017 0 : if( pSh->IsCrsrPtAtEnd() )
1018 0 : pSh->SwapPam();
1019 0 : pSh->SetInSelect();
1020 : }
1021 : }
1022 :
1023 0 : aPopup.EnableItem( MN_EDIT_COMMENT, pEntry && pRed &&
1024 0 : !pTable->GetParent(pEntry) &&
1025 0 : !pTable->NextSelected(pEntry)
1026 : //JP 27.9.2001: make no sense if we handle readonly sections
1027 : // && pRed->HasReadonlySel()
1028 0 : );
1029 :
1030 0 : aPopup.EnableItem( MN_SUB_SORT, pTable->First() != 0 );
1031 0 : sal_uInt16 nColumn = pTable->GetSortedCol();
1032 0 : if (nColumn == 0xffff)
1033 0 : nColumn = 4;
1034 :
1035 0 : PopupMenu *pSubMenu = aPopup.GetPopupMenu(MN_SUB_SORT);
1036 0 : if (pSubMenu)
1037 : {
1038 0 : for (sal_uInt16 i = MN_SORT_ACTION; i < MN_SORT_ACTION + 5; i++)
1039 0 : pSubMenu->CheckItem(i, sal_False);
1040 :
1041 0 : pSubMenu->CheckItem(nColumn + MN_SORT_ACTION);
1042 : }
1043 :
1044 0 : sal_uInt16 nRet = aPopup.Execute(pTable, aCEvt.GetMousePosPixel());
1045 :
1046 0 : switch( nRet )
1047 : {
1048 : case MN_EDIT_COMMENT:
1049 : {
1050 0 : if (pEntry)
1051 : {
1052 0 : if (pTable->GetParent(pEntry))
1053 0 : pEntry = pTable->GetParent(pEntry);
1054 :
1055 0 : sal_uInt16 nPos = GetRedlinePos(*pEntry);
1056 :
1057 0 : if (nPos == USHRT_MAX)
1058 0 : break;
1059 :
1060 0 : const SwRedline &rRedline = pSh->GetRedline(nPos);
1061 :
1062 :
1063 : /* enable again once we have redline comments in the margin
1064 : sComment = rRedline.GetComment();
1065 : if ( !sComment.Len() )
1066 : GetActiveView()->GetDocShell()->Broadcast(SwRedlineHint(&rRedline,SWREDLINE_INSERTED));
1067 : const_cast<SwRedline&>(rRedline).Broadcast(SwRedlineHint(&rRedline,SWREDLINE_FOCUS));
1068 : */
1069 :
1070 0 : OUString sComment = convertLineEnd(rRedline.GetComment(), GetSystemLineEnd());
1071 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1072 : OSL_ENSURE(pFact, "Dialogdiet fail!");
1073 0 : ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc();
1074 : OSL_ENSURE(fnGetRange, "Dialogdiet fail! GetRanges()");
1075 0 : SfxItemSet aSet( pSh->GetAttrPool(), fnGetRange() );
1076 :
1077 0 : aSet.Put(SvxPostItTextItem(sComment, SID_ATTR_POSTIT_TEXT));
1078 0 : aSet.Put(SvxPostItAuthorItem(rRedline.GetAuthorString(), SID_ATTR_POSTIT_AUTHOR));
1079 :
1080 : aSet.Put(SvxPostItDateItem( GetAppLangDateTimeString(
1081 0 : rRedline.GetRedlineData().GetTimeStamp() ),
1082 0 : SID_ATTR_POSTIT_DATE ));
1083 :
1084 0 : AbstractSvxPostItDialog* pDlg = pFact->CreateSvxPostItDialog( pParentDlg, aSet, sal_False );
1085 : OSL_ENSURE(pDlg, "Dialogdiet fail!");
1086 :
1087 0 : pDlg->HideAuthor();
1088 :
1089 0 : sal_uInt16 nResId = 0;
1090 0 : switch( rRedline.GetType() )
1091 : {
1092 : case nsRedlineType_t::REDLINE_INSERT:
1093 0 : nResId = STR_REDLINE_INSERTED;
1094 0 : break;
1095 : case nsRedlineType_t::REDLINE_DELETE:
1096 0 : nResId = STR_REDLINE_DELETED;
1097 0 : break;
1098 : case nsRedlineType_t::REDLINE_FORMAT:
1099 0 : nResId = STR_REDLINE_FORMATED;
1100 0 : break;
1101 : case nsRedlineType_t::REDLINE_TABLE:
1102 0 : nResId = STR_REDLINE_TABLECHG;
1103 0 : break;
1104 : default:;//prevent warning
1105 : }
1106 0 : String sTitle(SW_RES(STR_REDLINE_COMMENT));
1107 0 : if( nResId )
1108 0 : sTitle += SW_RESSTR( nResId );
1109 0 : pDlg->SetText(sTitle);
1110 :
1111 0 : pSh->SetCareWin(pDlg->GetWindow());
1112 :
1113 0 : if ( pDlg->Execute() == RET_OK )
1114 : {
1115 0 : const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
1116 0 : String sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue());
1117 :
1118 : // insert / change comment
1119 0 : pSh->SetRedlineComment(sMsg);
1120 0 : sMsg.SearchAndReplaceAll((sal_Unicode)'\n',(sal_Unicode)' ');
1121 0 : pTable->SetEntryText(sMsg, pEntry, 3);
1122 : }
1123 :
1124 0 : delete pDlg;
1125 0 : pSh->SetCareWin(NULL);
1126 : }
1127 :
1128 : }
1129 0 : break;
1130 :
1131 : case MN_SORT_ACTION:
1132 : case MN_SORT_AUTHOR:
1133 : case MN_SORT_DATE:
1134 : case MN_SORT_COMMENT:
1135 : case MN_SORT_POSITION:
1136 : {
1137 0 : bSortDir = sal_True;
1138 0 : if (nRet - MN_SORT_ACTION == 4 && pTable->GetSortedCol() == 0xffff)
1139 0 : break; // we already have it
1140 :
1141 0 : nSortMode = nRet - MN_SORT_ACTION;
1142 0 : if (nSortMode == 4)
1143 0 : nSortMode = 0xffff; // unsorted / sorted by position
1144 :
1145 0 : if (pTable->GetSortedCol() == nSortMode)
1146 0 : bSortDir = !pTable->GetSortDirection();
1147 :
1148 0 : SwWait aWait( *::GetActiveView()->GetDocShell(), sal_False );
1149 0 : pTable->SortByCol(nSortMode, bSortDir);
1150 0 : if (nSortMode == 0xffff)
1151 0 : Init(); // newly fill everything
1152 : }
1153 0 : break;
1154 : }
1155 : }
1156 0 : break;
1157 : }
1158 :
1159 0 : return 0;
1160 : }
1161 :
1162 0 : void SwRedlineAcceptDlg::Initialize(const String& rExtraData)
1163 : {
1164 0 : if (rExtraData.Len())
1165 : {
1166 0 : sal_uInt16 nPos = rExtraData.Search(OUString("AcceptChgDat:"));
1167 :
1168 : // try to read the alignment string "ALIGN:(...)"; if none existing,
1169 : // it's an old version
1170 0 : if (nPos != STRING_NOTFOUND)
1171 : {
1172 0 : sal_uInt16 n1 = rExtraData.Search('(', nPos);
1173 0 : if (n1 != STRING_NOTFOUND)
1174 : {
1175 0 : sal_uInt16 n2 = rExtraData.Search(')', n1);
1176 0 : if (n2 != STRING_NOTFOUND)
1177 : {
1178 : // cut out the alignment string
1179 0 : String aStr = rExtraData.Copy(nPos, n2 - nPos + 1);
1180 0 : aStr.Erase(0, n1 - nPos + 1);
1181 :
1182 0 : if (aStr.Len())
1183 : {
1184 0 : sal_uInt16 nCount = static_cast< sal_uInt16 >(aStr.ToInt32());
1185 :
1186 0 : for (sal_uInt16 i = 0; i < nCount; i++)
1187 : {
1188 0 : sal_uInt16 n3 = aStr.Search(';');
1189 0 : aStr.Erase(0, n3 + 1);
1190 0 : pTable->SetTab(i, aStr.ToInt32(), MAP_PIXEL);
1191 : }
1192 0 : }
1193 : }
1194 : }
1195 : }
1196 : }
1197 0 : }
1198 :
1199 0 : void SwRedlineAcceptDlg::FillInfo(String &rExtraData) const
1200 : {
1201 0 : rExtraData.AppendAscii("AcceptChgDat:(");
1202 :
1203 0 : sal_uInt16 nCount = pTable->TabCount();
1204 :
1205 0 : rExtraData += OUString::number(nCount);
1206 0 : rExtraData += ';';
1207 0 : for(sal_uInt16 i = 0; i < nCount; i++)
1208 : {
1209 0 : rExtraData += OUString::number( pTable->GetTab(i) );
1210 0 : rExtraData += ';';
1211 : }
1212 0 : rExtraData += ')';
1213 99 : }
1214 :
1215 :
1216 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|