merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / misc / redlndlg.cxx
blob59f71f13794a69e9409c81ab117559c10d3c920a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: redlndlg.cxx,v $
10 * $Revision: 1.29.190.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #define _SVSTDARR_STRINGSSORTDTOR
36 #define _SVSTDARR_USHORTSSORT
37 #define _SVSTDARR_USHORTS
40 #include <redline.hxx>
41 #include <tools/datetime.hxx>
42 #include <vcl/msgbox.hxx>
43 #ifndef _SVSTDARR_HXX
44 #include <svtools/svstdarr.hxx>
45 #endif
46 #include <svtools/eitem.hxx>
47 #include <sfx2/viewfrm.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <svx/ctredlin.hxx>
50 #include <svx/postattr.hxx>
51 #include <swtypes.hxx>
52 #include <wrtsh.hxx>
53 #ifndef _VIEW_HXX
54 #include <view.hxx>
55 #endif
56 #include <swmodule.hxx>
57 #ifndef _REDLNDLG_HXX
58 #define _REDLNACCEPTDLG
59 #include <redlndlg.hxx>
60 #endif
61 #include <swwait.hxx>
62 #include <uitool.hxx>
64 #ifndef _HELPID_H
65 #include <helpid.h>
66 #endif
67 #ifndef _CMDID_H
68 #include <cmdid.h>
69 #endif
70 #ifndef _MISC_HRC
71 #include <misc.hrc>
72 #endif
73 #ifndef _REDLNDLG_HRC
74 #include <redlndlg.hrc>
75 #endif
76 #ifndef _SHELLS_HRC
77 #include <shells.hrc>
78 #endif
80 // -> #111827#
81 #include <comcore.hrc>
82 #include <swundo.hxx>
83 #include <undobj.hxx>
84 #include <SwRewriter.hxx>
85 // <- #111827#
87 #include <vector>
88 #include <svx/svxdlg.hxx>
89 #include <svx/dialogs.hrc>
91 #include <unomid.h>
93 #include <docsh.hxx>
95 #include <IDocumentRedlineAccess.hxx>
97 /*------------------------------------------------------------------------
98 Beschreibung:
99 ------------------------------------------------------------------------*/
101 SFX_IMPL_MODELESSDIALOG( SwRedlineAcceptChild, FN_REDLINE_ACCEPT )
103 SV_IMPL_PTRARR(SwRedlineDataParentArr, SwRedlineDataParentPtr)
104 SV_IMPL_OP_PTRARR_SORT(SwRedlineDataParentSortArr, SwRedlineDataParentPtr)
105 SV_IMPL_PTRARR(SwRedlineDataChildArr, SwRedlineDataChildPtr)
106 SV_IMPL_PTRARR(SvLBoxEntryArr, SvLBoxEntryPtr)
108 static USHORT nSortMode = 0xffff;
109 static BOOL bSortDir = TRUE;
111 /*------------------------------------------------------------------------
112 Beschreibung:
113 ------------------------------------------------------------------------*/
115 SwRedlineAcceptChild::SwRedlineAcceptChild( Window* _pParent,
116 USHORT nId,
117 SfxBindings* pBindings,
118 SfxChildWinInfo* pInfo ) :
119 SwChildWinWrapper( _pParent, nId )
121 pWindow = new SwModelessRedlineAcceptDlg( pBindings, this, _pParent);
123 ((SwModelessRedlineAcceptDlg *)pWindow)->Initialize(pInfo);
126 /*--------------------------------------------------------------------
127 Beschreibung: Nach Dok-Wechsel Dialog neu initialisieren
128 --------------------------------------------------------------------*/
130 BOOL SwRedlineAcceptChild::ReInitDlg(SwDocShell *pDocSh)
132 BOOL bRet;
134 if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == TRUE) // Sofort aktualisieren, Dok-Wechsel
135 ((SwModelessRedlineAcceptDlg*)GetWindow())->Activate();
137 return bRet;
140 /*------------------------------------------------------------------------
141 Beschreibung:
142 ------------------------------------------------------------------------*/
144 SwModelessRedlineAcceptDlg::SwModelessRedlineAcceptDlg( SfxBindings* _pBindings,
145 SwChildWinWrapper* pChild,
146 Window *_pParent) :
147 SfxModelessDialog(_pBindings, pChild, _pParent, SW_RES(DLG_REDLINE_ACCEPT)),
148 pChildWin (pChild)
150 pImplDlg = new SwRedlineAcceptDlg(this);
152 FreeResource();
155 /*--------------------------------------------------------------------
156 Beschreibung:
157 --------------------------------------------------------------------*/
159 void SwModelessRedlineAcceptDlg::Activate()
161 SwView *pView = ::GetActiveView();
163 if (!pView) // Kann passieren, wenn man auf eine andere App umschaltet, wenn
164 return; // vorher eine Listbox im Dialog den Focus hatte (eigentlich THs Bug)
166 SwDocShell *pDocSh = pView->GetDocShell();
168 if (pChildWin->GetOldDocShell() != pDocSh)
169 { // Dok-Wechsel
170 SwWait aWait( *pDocSh, FALSE );
171 SwWrtShell* pSh = pView->GetWrtShellPtr();
173 pChildWin->SetOldDocShell(pDocSh); // Rekursion vermeiden (durch Modified-Hdl)
175 BOOL bMod = pSh->IsModified();
176 SfxBoolItem aShow(FN_REDLINE_SHOW, TRUE);
177 pSh->GetView().GetViewFrame()->GetDispatcher()->Execute(
178 FN_REDLINE_SHOW, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aShow, 0L);
179 if (!bMod)
180 pSh->ResetModified();
181 pImplDlg->Init();
183 return;
186 pImplDlg->Activate();
189 /*--------------------------------------------------------------------
190 Beschreibung:
191 --------------------------------------------------------------------*/
193 void SwModelessRedlineAcceptDlg::Initialize(SfxChildWinInfo *pInfo)
195 String aStr;
196 if (pInfo != NULL)
197 pImplDlg->Initialize(pInfo->aExtraString);
199 SfxModelessDialog::Initialize(pInfo);
202 /*--------------------------------------------------------------------
203 Beschreibung:
204 --------------------------------------------------------------------*/
206 void SwModelessRedlineAcceptDlg::FillInfo(SfxChildWinInfo& rInfo) const
208 SfxModelessDialog::FillInfo(rInfo);
209 pImplDlg->FillInfo(rInfo.aExtraString);
212 /*------------------------------------------------------------------------
213 Beschreibung:
214 ------------------------------------------------------------------------*/
216 void SwModelessRedlineAcceptDlg::Resize()
218 pImplDlg->Resize();
219 SfxModelessDialog::Resize();
222 /*------------------------------------------------------------------------
223 Beschreibung:
224 ------------------------------------------------------------------------*/
226 SwModelessRedlineAcceptDlg::~SwModelessRedlineAcceptDlg()
228 delete pImplDlg;
231 /*------------------------------------------------------------------------
232 Beschreibung:
233 ------------------------------------------------------------------------*/
235 SwRedlineAcceptDlg::SwRedlineAcceptDlg(Dialog *pParent, BOOL bAutoFmt) :
236 pParentDlg (pParent),
237 aTabPagesCTRL (pParent, SW_RES(CTRL_TABPAGES)),
238 aPopup (SW_RES(MN_REDLINE_POPUP)),
239 sInserted (SW_RES(STR_REDLINE_INSERTED)),
240 sDeleted (SW_RES(STR_REDLINE_DELETED)),
241 sFormated (SW_RES(STR_REDLINE_FORMATED)),
242 sTableChgd (SW_RES(STR_REDLINE_TABLECHG)),
243 sFmtCollSet (SW_RES(STR_REDLINE_FMTCOLLSET)),
244 sAutoFormat (SW_RES(STR_REDLINE_AUTOFMT)),
245 bOnlyFormatedRedlines( FALSE ),
246 bHasReadonlySel ( FALSE ),
247 bRedlnAutoFmt (bAutoFmt),
248 bInhibitActivate( false )
250 aTabPagesCTRL.SetHelpId(HID_REDLINE_CTRL);
251 pTPView = aTabPagesCTRL.GetViewPage();
252 pTable = pTPView->GetTableControl();
254 pTPView->InsertWriterHeader();
255 pTPView->SetAcceptClickHdl(LINK(this, SwRedlineAcceptDlg, AcceptHdl));
256 pTPView->SetAcceptAllClickHdl(LINK(this, SwRedlineAcceptDlg, AcceptAllHdl));
257 pTPView->SetRejectClickHdl(LINK(this, SwRedlineAcceptDlg, RejectHdl));
258 pTPView->SetRejectAllClickHdl(LINK(this, SwRedlineAcceptDlg, RejectAllHdl));
259 pTPView->SetUndoClickHdl(LINK(this, SwRedlineAcceptDlg, UndoHdl));
261 aTabPagesCTRL.GetFilterPage()->SetReadyHdl(LINK(this, SwRedlineAcceptDlg, FilterChangedHdl));
263 ListBox *pActLB = aTabPagesCTRL.GetFilterPage()->GetLbAction();
264 pActLB->InsertEntry(sInserted);
265 pActLB->InsertEntry(sDeleted);
266 pActLB->InsertEntry(sFormated);
267 pActLB->InsertEntry(sTableChgd);
269 if (HasRedlineAutoFmt())
271 pActLB->InsertEntry(sFmtCollSet);
272 pActLB->InsertEntry(sAutoFormat);
273 pTPView->ShowUndo(TRUE);
274 pTPView->DisableUndo(); // Noch gibts keine UNDO-Events
277 pActLB->SelectEntryPos(0);
279 pTable->SetWindowBits(WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
280 pTable->SetNodeDefaultImages();
281 pTable->SetSelectionMode(MULTIPLE_SELECTION);
282 pTable->SetHighlightRange(1);
284 static long aStaticTabs[]=
286 4,10,70,120,170
289 pTable->SetTabs(aStaticTabs);
291 // Minimalgroesse setzen
292 Size aMinSz(aTabPagesCTRL.GetMinSizePixel());
293 Point aPos(aTabPagesCTRL.GetPosPixel());
295 aMinSz.Width() += (aPos.X() * 2 - 1);
296 aMinSz.Height() += (aPos.Y() * 2 - 1);
297 pParentDlg->SetMinOutputSizePixel(aMinSz);
299 if (pParentDlg->GetOutputSizePixel().Width() < aMinSz.Width())
300 pParentDlg->SetOutputSizePixel(Size(aMinSz.Width(), pParentDlg->GetOutputSizePixel().Height()));
301 if (pParentDlg->GetOutputSizePixel().Height() < aMinSz.Height())
302 pParentDlg->SetOutputSizePixel(Size(pParentDlg->GetOutputSizePixel().Width(), aMinSz.Height()));
304 pTable->SortByCol(nSortMode, bSortDir);
306 aOldSelectHdl = pTable->GetSelectHdl();
307 aOldDeselectHdl = pTable->GetDeselectHdl();
308 pTable->SetSelectHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl));
309 pTable->SetDeselectHdl(LINK(this, SwRedlineAcceptDlg, DeselectHdl));
310 pTable->SetCommandHdl(LINK(this, SwRedlineAcceptDlg, CommandHdl));
312 // Flackern der Buttons vermeiden:
313 aDeselectTimer.SetTimeout(100);
314 aDeselectTimer.SetTimeoutHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl));
316 // Mehrfachselektion der selben Texte vermeiden:
317 aSelectTimer.SetTimeout(100);
318 aSelectTimer.SetTimeoutHdl(LINK(this, SwRedlineAcceptDlg, GotoHdl));
321 /*------------------------------------------------------------------------
322 Beschreibung:
323 ------------------------------------------------------------------------*/
325 SwRedlineAcceptDlg::~SwRedlineAcceptDlg()
329 /*------------------------------------------------------------------------
330 Beschreibung:
331 ------------------------------------------------------------------------*/
333 void SwRedlineAcceptDlg::Init(USHORT nStart)
335 SwWait aWait( *::GetActiveView()->GetDocShell(), FALSE );
336 pTable->SetUpdateMode(FALSE);
337 aUsedSeqNo.Remove((USHORT)0, aUsedSeqNo.Count());
339 if (nStart)
340 RemoveParents(nStart, aRedlineParents.Count() - 1);
341 else
343 pTable->Clear();
344 aRedlineChilds.DeleteAndDestroy(0, aRedlineChilds.Count());
345 aRedlineParents.DeleteAndDestroy(nStart, aRedlineParents.Count() - nStart);
348 // Parents einfuegen
349 InsertParents(nStart);
350 InitAuthors();
352 pTable->SetUpdateMode(TRUE);
353 // #i69618# this moves the list box to the right position, visually
354 SvLBoxEntry* pSelEntry = pTable->FirstSelected();
355 if( pSelEntry )
356 pTable->MakeVisible( pSelEntry, sal_True ); //#i70937#, force the scroll
359 /*------------------------------------------------------------------------
360 Beschreibung:
361 ------------------------------------------------------------------------*/
363 void SwRedlineAcceptDlg::InitAuthors()
365 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
367 SvxTPFilter *pFilterPage = aTabPagesCTRL.GetFilterPage();
369 String sAuthor;
370 SvStringsSortDtor aStrings;
371 String sOldAuthor(pFilterPage->GetSelectedAuthor());
372 pFilterPage->ClearAuthors();
374 String sParent;
375 USHORT nCount = pSh->GetRedlineCount();
377 bOnlyFormatedRedlines = TRUE;
378 bHasReadonlySel = FALSE;
379 BOOL bIsNotFormated = FALSE;
380 USHORT i;
382 // Autoren ermitteln
383 for ( i = 0; i < nCount; i++)
385 const SwRedline& rRedln = pSh->GetRedline(i);
387 if( bOnlyFormatedRedlines && nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType() )
388 bOnlyFormatedRedlines = FALSE;
390 //JP 27.9.2001: make no sense if we handle readonly sections
391 // if( !bHasReadonlySel && rRedln.HasReadonlySel() )
392 // bHasReadonlySel = TRUE;
394 String *pAuthor = new String(rRedln.GetAuthorString());
395 if (!aStrings.Insert(pAuthor))
396 delete pAuthor;
398 for (USHORT nStack = 1; nStack < rRedln.GetStackCount(); nStack++)
400 pAuthor = new String(rRedln.GetAuthorString(nStack));
401 if (!aStrings.Insert(pAuthor))
402 delete pAuthor;
406 for (i = 0; i < aStrings.Count(); i++)
407 pFilterPage->InsertAuthor(*aStrings[i]);
409 if (pFilterPage->SelectAuthor(sOldAuthor) == LISTBOX_ENTRY_NOTFOUND && aStrings.Count())
410 pFilterPage->SelectAuthor(*aStrings[0]);
412 BOOL bEnable = pTable->GetEntryCount() != 0 && !pSh->getIDocumentRedlineAccess()->GetRedlinePassword().getLength();
413 BOOL bSel = pTable->FirstSelected() != 0;
415 SvLBoxEntry* pSelEntry = pTable->FirstSelected();
416 while (pSelEntry)
418 USHORT nPos = GetRedlinePos(*pSelEntry);
419 const SwRedline& rRedln = pSh->GetRedline( nPos );
421 bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType();
422 pSelEntry = pTable->NextSelected(pSelEntry);
425 pTPView->EnableAccept( bEnable && bSel );
426 pTPView->EnableReject( bEnable && bIsNotFormated && bSel );
427 pTPView->EnableAcceptAll( bEnable && !bHasReadonlySel );
428 pTPView->EnableRejectAll( bEnable && !bHasReadonlySel &&
429 !bOnlyFormatedRedlines );
432 /*------------------------------------------------------------------------
433 Beschreibung:
434 ------------------------------------------------------------------------*/
436 String SwRedlineAcceptDlg::GetRedlineText( const SwRedline& rRedln,
437 DateTime &rDateTime, USHORT nStack)
439 String sEntry(GetActionText(rRedln, nStack));
440 sEntry += '\t';
441 sEntry += rRedln.GetAuthorString(nStack);
442 sEntry += '\t';
444 const DateTime &rDT = rRedln.GetTimeStamp(nStack);
445 rDateTime = rDT;
447 sEntry += GetAppLangDateTimeString( rDT );
448 sEntry += '\t';
450 sEntry += rRedln.GetComment(nStack);
452 return sEntry;
455 /*------------------------------------------------------------------------
456 Beschreibung:
457 ------------------------------------------------------------------------*/
459 const String &SwRedlineAcceptDlg::GetActionText(const SwRedline& rRedln, USHORT nStack)
461 switch( rRedln.GetType(nStack) )
463 case nsRedlineType_t::REDLINE_INSERT: return sInserted;
464 case nsRedlineType_t::REDLINE_DELETE: return sDeleted;
465 case nsRedlineType_t::REDLINE_FORMAT: return sFormated;
466 case nsRedlineType_t::REDLINE_TABLE: return sTableChgd;
467 case nsRedlineType_t::REDLINE_FMTCOLL: return sFmtCollSet;
468 default:;//prevent warning
471 return aEmptyStr;
474 /*------------------------------------------------------------------------
475 Beschreibung:
476 ------------------------------------------------------------------------*/
478 void SwRedlineAcceptDlg::Resize()
480 Size aSz(pParentDlg->GetOutputSizePixel());
482 Point aPos(aTabPagesCTRL.GetPosPixel());
484 aSz.Width() -= (aPos.X() * 2 - 1);
485 aSz.Height() -= (aPos.Y() * 2 - 1);
487 aTabPagesCTRL.SetOutputSizePixel(aSz);
490 /*--------------------------------------------------------------------
491 Beschreibung: Nach Aktivierung neu initialisieren
492 --------------------------------------------------------------------*/
494 void SwRedlineAcceptDlg::Activate()
496 // prevent update if flag is set (#102547#)
497 if( bInhibitActivate )
498 return;
500 SwView *pView = ::GetActiveView();
501 SwWait aWait( *pView->GetDocShell(), FALSE );
503 aUsedSeqNo.Remove((USHORT)0, aUsedSeqNo.Count());
505 if (!pView) // Kann passieren, wenn man auf eine andere App umschaltet, wenn
506 return; // vorher eine Listbox im Dialog den Focus hatte (eigentlich THs Bug)
508 /* if (HasRedlineAutoFmt())
510 Init();
511 return;
514 // Hat sich was geaendert?
515 SwWrtShell* pSh = pView->GetWrtShellPtr();
516 USHORT nCount = pSh->GetRedlineCount();
518 // Anzahl und Pointer ueberpruefen
519 SwRedlineDataParent *pParent = 0;
520 USHORT i;
522 for ( i = 0; i < nCount; i++)
524 const SwRedline& rRedln = pSh->GetRedline(i);
526 if (i >= aRedlineParents.Count())
528 // Neue Eintraege wurden angehaengt
529 Init(i);
530 return;
533 pParent = aRedlineParents[i];
534 if (&rRedln.GetRedlineData() != pParent->pData)
536 // Redline-Parents wurden eingefuegt, geaendert oder geloescht
537 if ((i = CalcDiff(i, FALSE)) == USHRT_MAX)
538 return;
539 continue;
542 const SwRedlineData *pRedlineData = rRedln.GetRedlineData().Next();
543 const SwRedlineDataChild *pBackupData = pParent->pNext;
545 if (!pRedlineData && pBackupData)
547 // Redline-Childs wurden geloescht
548 if ((i = CalcDiff(i, TRUE)) == USHRT_MAX)
549 return;
550 continue;
552 else
554 while (pRedlineData)
556 if (pRedlineData != pBackupData->pChild)
558 // Redline-Childs wurden eingefuegt, geaendert oder geloescht
559 if ((i = CalcDiff(i, TRUE)) == USHRT_MAX)
560 return;
561 continue;
563 if (pBackupData)
564 pBackupData = pBackupData->pNext;
565 pRedlineData = pRedlineData->Next();
570 if (nCount != aRedlineParents.Count())
572 // Redlines wurden am Ende geloescht
573 Init(nCount);
574 return;
577 // Kommentar ueberpruefen
578 for (i = 0; i < nCount; i++)
580 const SwRedline& rRedln = pSh->GetRedline(i);
581 pParent = aRedlineParents[i];
583 if(!rRedln.GetComment().Equals(pParent->sComment))
585 if (pParent->pTLBParent)
587 // Nur Kommentar aktualisieren
588 String sComment(rRedln.GetComment());
589 sComment.SearchAndReplaceAll((sal_Unicode)_LF,(sal_Unicode)' ');
590 pTable->SetEntryText(sComment, pParent->pTLBParent, 3);
592 pParent->sComment = rRedln.GetComment();
596 InitAuthors();
599 /* -----------------05.06.98 13:06-------------------
601 * --------------------------------------------------*/
603 USHORT SwRedlineAcceptDlg::CalcDiff(USHORT nStart, BOOL bChild)
605 if (!nStart)
607 Init();
608 return USHRT_MAX;
611 pTable->SetUpdateMode(FALSE);
612 SwView *pView = ::GetActiveView();
613 SwWrtShell* pSh = pView->GetWrtShellPtr();
614 USHORT nAutoFmt = HasRedlineAutoFmt() ? nsRedlineType_t::REDLINE_FORM_AUTOFMT : 0;
615 SwRedlineDataParent *pParent = aRedlineParents[nStart];
616 const SwRedline& rRedln = pSh->GetRedline(nStart);
618 if (bChild) // Sollte eigentlich nie vorkommen, aber sicher ist sicher...
620 // Alle Childs des Eintrags wegwerfen und neu initialisieren
621 SwRedlineDataChildPtr pBackupData = (SwRedlineDataChildPtr)pParent->pNext;
622 SwRedlineDataChildPtr pNext;
624 while (pBackupData)
626 pNext = (SwRedlineDataChildPtr)pBackupData->pNext;
627 if (pBackupData->pTLBChild)
628 pTable->RemoveEntry(pBackupData->pTLBChild);
630 aRedlineChilds.DeleteAndDestroy(aRedlineChilds.GetPos(pBackupData), 1);
631 pBackupData = pNext;
633 pParent->pNext = 0;
635 // Neue Childs einfuegen
636 InsertChilds(pParent, rRedln, nAutoFmt);
638 pTable->SetUpdateMode(TRUE);
639 return nStart;
642 // Wurden Eintraege geloescht?
643 const SwRedlineData *pRedlineData = &rRedln.GetRedlineData();
644 USHORT i;
645 for ( i = nStart + 1; i < aRedlineParents.Count(); i++)
647 if (aRedlineParents[i]->pData == pRedlineData)
649 // Eintraege von nStart bis i-1 entfernen
650 RemoveParents(nStart, i - 1);
651 pTable->SetUpdateMode(TRUE);
652 return nStart - 1;
656 // Wurden Eintraege eingefuegt?
657 USHORT nCount = pSh->GetRedlineCount();
658 pRedlineData = aRedlineParents[nStart]->pData;
660 for (i = nStart + 1; i < nCount; i++)
662 if (&pSh->GetRedline(i).GetRedlineData() == pRedlineData)
664 // Eintraege von nStart bis i-1 einfuegen
665 InsertParents(nStart, i - 1);
666 pTable->SetUpdateMode(TRUE);
667 return nStart - 1;
671 pTable->SetUpdateMode(TRUE);
672 Init(nStart); // Alle Eintraege bis zum Ende abgleichen
673 return USHRT_MAX;
676 /* -----------------05.06.98 13:57-------------------
678 * --------------------------------------------------*/
680 void SwRedlineAcceptDlg::InsertChilds(SwRedlineDataParent *pParent, const SwRedline& rRedln, const USHORT nAutoFmt)
682 String sChild;
683 SwRedlineDataChild *pLastRedlineChild = 0;
684 const SwRedlineData *pRedlineData = &rRedln.GetRedlineData();
685 BOOL bAutoFmt = (rRedln.GetRealType() & nAutoFmt) != 0;
687 const String *pAction = &GetActionText(rRedln);
688 BOOL bValidParent = !sFilterAction.Len() || sFilterAction == *pAction;
689 bValidParent = bValidParent && pTable->IsValidEntry(&rRedln.GetAuthorString(), &rRedln.GetTimeStamp(), &rRedln.GetComment());
690 if (nAutoFmt)
692 USHORT nPos;
694 if (pParent->pData->GetSeqNo() && !aUsedSeqNo.Insert(pParent, nPos)) // Gibts schon
696 if (pParent->pTLBParent)
698 pTable->SetEntryText(sAutoFormat, aUsedSeqNo[nPos]->pTLBParent, 0);
699 pTable->RemoveEntry(pParent->pTLBParent);
700 pParent->pTLBParent = 0;
702 return;
704 bValidParent = bValidParent && bAutoFmt;
706 BOOL bValidTree = bValidParent;
708 for (USHORT nStack = 1; nStack < rRedln.GetStackCount(); nStack++)
710 pRedlineData = pRedlineData->Next();
712 SwRedlineDataChildPtr pRedlineChild = new SwRedlineDataChild;
713 pRedlineChild->pChild = pRedlineData;
714 aRedlineChilds.Insert(pRedlineChild, aRedlineChilds.Count());
716 if ( pLastRedlineChild )
717 pLastRedlineChild->pNext = pRedlineChild;
718 else
719 pParent->pNext = pRedlineChild;
721 pAction = &GetActionText(rRedln, nStack);
722 BOOL bValidChild = !sFilterAction.Len() || sFilterAction == *pAction;
723 bValidChild = bValidChild && pTable->IsValidEntry(&rRedln.GetAuthorString(nStack), &rRedln.GetTimeStamp(nStack), &rRedln.GetComment());
724 if (nAutoFmt)
725 bValidChild = bValidChild && bAutoFmt;
726 bValidTree |= bValidChild;
728 if (bValidChild)
730 RedlinData *pData = new RedlinData;
731 pData->pData = pRedlineChild;
732 pData->bDisabled = TRUE;
733 sChild = GetRedlineText(rRedln, pData->aDateTime, nStack);
735 SvLBoxEntry* pChild = pTable->InsertEntry(sChild, pData, pParent->pTLBParent);
737 pRedlineChild->pTLBChild = pChild;
738 if (!bValidParent)
739 pTable->Expand(pParent->pTLBParent);
741 else
742 pRedlineChild->pTLBChild = 0;
744 pLastRedlineChild = pRedlineChild;
747 if (pLastRedlineChild)
748 pLastRedlineChild->pNext = 0;
750 if (!bValidTree && pParent->pTLBParent)
752 pTable->RemoveEntry(pParent->pTLBParent);
753 pParent->pTLBParent = 0;
754 if (nAutoFmt)
755 aUsedSeqNo.Remove(pParent);
759 /* -----------------05.06.98 15:20-------------------
761 * --------------------------------------------------*/
763 void SwRedlineAcceptDlg::RemoveParents(USHORT nStart, USHORT nEnd)
765 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
766 USHORT nCount = pSh->GetRedlineCount();
768 SvLBoxEntryArr aLBoxArr;
770 // Wegen Bug der TLB, die bei Remove den SelectHandler IMMER ruft:
771 pTable->SetSelectHdl(aOldSelectHdl);
772 pTable->SetDeselectHdl(aOldDeselectHdl);
773 BOOL bChildsRemoved = FALSE;
774 pTable->SelectAll(FALSE);
776 // Hinter dem letzten Eintrag Cursor setzen, da sonst Performance-Problem in TLB.
777 // TLB wuerde sonst bei jedem Remove den Cursor erneut umsetzen (teuer)
778 USHORT nPos = Min((USHORT)nCount, (USHORT)aRedlineParents.Count());
779 SvLBoxEntry *pCurEntry = NULL;
780 while( ( pCurEntry == NULL ) && ( nPos > 0 ) )
782 --nPos;
783 pCurEntry = aRedlineParents[nPos]->pTLBParent;
786 if (pCurEntry)
787 pTable->SetCurEntry(pCurEntry);
789 SvLBoxTreeList* pModel = pTable->GetModel();
791 for (USHORT i = nStart; i <= nEnd; i++)
793 if (!bChildsRemoved && aRedlineParents[i]->pNext)
795 SwRedlineDataChildPtr pChildPtr = (SwRedlineDataChildPtr)aRedlineParents[i]->pNext;
796 USHORT nChildPos = aRedlineChilds.GetPos(pChildPtr);
798 if (nChildPos != USHRT_MAX)
800 USHORT nChilds = 0;
802 while (pChildPtr)
804 pChildPtr = (SwRedlineDataChildPtr)pChildPtr->pNext;
805 nChilds++;
808 aRedlineChilds.DeleteAndDestroy(nChildPos, nChilds);
809 bChildsRemoved = TRUE;
812 SvLBoxEntry *pEntry = aRedlineParents[i]->pTLBParent;
813 if (pEntry)
815 long nIdx = aLBoxArr.Count() - 1L;
816 ULONG nAbsPos = pModel->GetAbsPos(pEntry);
817 while (nIdx >= 0 &&
818 pModel->GetAbsPos(aLBoxArr[ static_cast< USHORT >(nIdx) ]) > nAbsPos)
819 nIdx--;
820 aLBoxArr.Insert( pEntry, static_cast< USHORT >(++nIdx) );
824 // TLB von hinten abraeumen
825 long nIdx = (long)aLBoxArr.Count() - 1L;
826 while (nIdx >= 0)
827 pTable->RemoveEntry(aLBoxArr[ static_cast< USHORT >(nIdx--) ]);
829 pTable->SetSelectHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl));
830 pTable->SetDeselectHdl(LINK(this, SwRedlineAcceptDlg, DeselectHdl));
831 // Durch Remove wurde leider wieder dauernd von der TLB selektiert...
832 pTable->SelectAll(FALSE);
834 aRedlineParents.DeleteAndDestroy( nStart, nEnd - nStart + 1);
837 /* -----------------05.06.98 15:20-------------------
839 * --------------------------------------------------*/
841 void SwRedlineAcceptDlg::InsertParents(USHORT nStart, USHORT nEnd)
843 SwView *pView = ::GetActiveView();
844 SwWrtShell* pSh = pView->GetWrtShellPtr();
845 USHORT nAutoFmt = HasRedlineAutoFmt() ? nsRedlineType_t::REDLINE_FORM_AUTOFMT : 0;
847 String sParent;
848 USHORT nCount = pSh->GetRedlineCount();
849 nEnd = Min((USHORT)nEnd, (USHORT)(nCount - 1)); // Handelt auch nEnd=USHRT_MAX (bis zum Ende) ab
851 if (nEnd == USHRT_MAX)
852 return; // Keine Redlines im Dokument
854 RedlinData *pData;
855 SvLBoxEntry *pParent;
856 SwRedlineDataParentPtr pRedlineParent;
857 const SwRedline* pCurrRedline;
858 if( !nStart && !pTable->FirstSelected() )
860 pCurrRedline = pSh->GetCurrRedline();
861 if( !pCurrRedline )
863 pSh->SwCrsrShell::Push();
864 if( 0 == (pCurrRedline = pSh->SelNextRedline()))
865 pCurrRedline = pSh->SelPrevRedline();
866 pSh->SwCrsrShell::Pop( FALSE );
869 else
870 pCurrRedline = 0;
872 for (USHORT i = nStart; i <= nEnd; i++)
874 const SwRedline& rRedln = pSh->GetRedline(i);
875 const SwRedlineData *pRedlineData = &rRedln.GetRedlineData();
877 pRedlineParent = new SwRedlineDataParent;
878 pRedlineParent->pData = pRedlineData;
879 pRedlineParent->pNext = 0;
880 String sComment(rRedln.GetComment());
881 sComment.SearchAndReplaceAll((sal_Unicode)_LF,(sal_Unicode)' ');
882 pRedlineParent->sComment = sComment;
883 aRedlineParents.Insert(pRedlineParent, i);
885 pData = new RedlinData;
886 pData->pData = pRedlineParent;
887 pData->bDisabled = FALSE;
889 sParent = GetRedlineText(rRedln, pData->aDateTime);
890 pParent = pTable->InsertEntry(sParent, pData, 0, i);
891 if( pCurrRedline == &rRedln )
893 pTable->SetCurEntry( pParent );
894 pTable->Select( pParent );
895 pTable->MakeVisible( pParent );
898 pRedlineParent->pTLBParent = pParent;
900 InsertChilds(pRedlineParent, rRedln, nAutoFmt);
904 /* -----------------05.06.98 13:06-------------------
906 * --------------------------------------------------*/
908 void SwRedlineAcceptDlg::CallAcceptReject( BOOL bSelect, BOOL bAccept )
910 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
911 SvLBoxEntry* pEntry = bSelect ? pTable->FirstSelected() : pTable->First();
912 ULONG nPos = LONG_MAX;
914 typedef std::vector<SvLBoxEntry*> ListBoxEntries_t;
915 ListBoxEntries_t aRedlines;
917 // don't activate
918 DBG_ASSERT( bInhibitActivate == false,
919 "recursive call of CallAcceptReject?");
920 bInhibitActivate = true;
922 // collect redlines-to-be-accepted/rejected in aRedlines vector
923 while( pEntry )
925 if( !pTable->GetParent( pEntry ) )
927 if( bSelect && LONG_MAX == nPos )
928 nPos = pTable->GetModel()->GetAbsPos( pEntry );
930 RedlinData *pData = (RedlinData *)pEntry->GetUserData();
932 if( !pData->bDisabled )
933 aRedlines.push_back( pEntry );
936 pEntry = bSelect ? pTable->NextSelected(pEntry) : pTable->Next(pEntry);
939 BOOL (SwEditShell:: *FnAccRej)( USHORT ) = &SwEditShell::AcceptRedline;
940 if( !bAccept )
941 FnAccRej = &SwEditShell::RejectRedline;
943 SwWait aWait( *pSh->GetView().GetDocShell(), TRUE );
944 pSh->StartAction();
946 // #111827#
947 if (aRedlines.size() > 1)
949 String aTmpStr;
951 SwRewriter aRewriter;
952 aRewriter.AddRule(UNDO_ARG1,
953 String::CreateFromInt32(aRedlines.size()));
954 aTmpStr = aRewriter.Apply(String(SW_RES(STR_N_REDLINES)));
957 SwRewriter aRewriter;
958 aRewriter.AddRule(UNDO_ARG1, aTmpStr);
960 pSh->StartUndo(bAccept? UNDO_ACCEPT_REDLINE : UNDO_REJECT_REDLINE,
961 &aRewriter);
964 // accept/reject the the redlines in aRedlines. The absolute
965 // position may change during the process (e.g. when two redlines
966 // are merged in result of another one being deleted), so the
967 // position must be resolved late and checked before using it.
968 // (cf #102547#)
969 ListBoxEntries_t::iterator aEnd = aRedlines.end();
970 for( ListBoxEntries_t::iterator aIter = aRedlines.begin();
971 aIter != aEnd;
972 aIter++ )
974 USHORT nPosition = GetRedlinePos( **aIter );
975 if( nPosition != USHRT_MAX )
976 (pSh->*FnAccRej)( nPosition );
979 // #111827#
980 if (aRedlines.size() > 1)
981 pSh->EndUndo(bAccept? UNDO_ACCEPT_REDLINE : UNDO_REJECT_REDLINE);
983 pSh->EndAction();
985 bInhibitActivate = false;
986 Activate();
988 if( ULONG_MAX != nPos && pTable->GetEntryCount() )
990 if( nPos >= pTable->GetEntryCount() )
991 nPos = pTable->GetEntryCount() - 1;
992 pEntry = pTable->GetEntry( nPos );
993 if( !pEntry && nPos-- )
994 pEntry = pTable->GetEntry( nPos );
995 if( pEntry )
997 pTable->Select( pEntry );
998 pTable->MakeVisible( pEntry );
999 pTable->SetCurEntry(pEntry);
1002 pTPView->EnableUndo();
1005 /*--------------------------------------------------------------------
1006 Beschreibung:
1007 --------------------------------------------------------------------*/
1009 USHORT SwRedlineAcceptDlg::GetRedlinePos( const SvLBoxEntry& rEntry ) const
1011 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
1012 return pSh->FindRedlineOfData( *((SwRedlineDataParent*)((RedlinData *)
1013 rEntry.GetUserData())->pData)->pData );
1016 /*--------------------------------------------------------------------
1017 Beschreibung:
1018 --------------------------------------------------------------------*/
1020 IMPL_LINK( SwRedlineAcceptDlg, AcceptHdl, void*, EMPTYARG)
1022 CallAcceptReject( TRUE, TRUE );
1023 return 0;
1026 /*--------------------------------------------------------------------
1027 Beschreibung:
1028 --------------------------------------------------------------------*/
1030 IMPL_LINK( SwRedlineAcceptDlg, AcceptAllHdl, void*, EMPTYARG )
1032 CallAcceptReject( FALSE, TRUE );
1033 return 0;
1036 /*--------------------------------------------------------------------
1037 Beschreibung:
1038 --------------------------------------------------------------------*/
1040 IMPL_LINK( SwRedlineAcceptDlg, RejectHdl, void*, EMPTYARG )
1042 CallAcceptReject( TRUE, FALSE );
1043 return 0;
1046 /*--------------------------------------------------------------------
1047 Beschreibung:
1048 --------------------------------------------------------------------*/
1050 IMPL_LINK( SwRedlineAcceptDlg, RejectAllHdl, void*, EMPTYARG )
1052 CallAcceptReject( FALSE, FALSE );
1053 return 0;
1056 /*--------------------------------------------------------------------
1057 Beschreibung:
1058 --------------------------------------------------------------------*/
1060 IMPL_LINK( SwRedlineAcceptDlg, UndoHdl, void*, EMPTYARG )
1062 SwView * pView = ::GetActiveView();
1063 pView->GetViewFrame()->GetDispatcher()->
1064 Execute(SID_UNDO, SFX_CALLMODE_SYNCHRON);
1065 pTPView->EnableUndo(pView->GetSlotState(SID_UNDO) != 0);
1067 Activate();
1069 return 0;
1072 /*--------------------------------------------------------------------
1073 Beschreibung:
1074 --------------------------------------------------------------------*/
1076 IMPL_LINK( SwRedlineAcceptDlg, FilterChangedHdl, void*, EMPTYARG )
1078 SvxTPFilter *pFilterTP = aTabPagesCTRL.GetFilterPage();
1080 if (pFilterTP->IsAction())
1081 sFilterAction = pFilterTP->GetLbAction()->GetSelectEntry();
1082 else
1083 sFilterAction = aEmptyStr;
1085 Init();
1087 return 0;
1090 /*--------------------------------------------------------------------
1091 Beschreibung:
1092 --------------------------------------------------------------------*/
1094 IMPL_LINK( SwRedlineAcceptDlg, DeselectHdl, void*, EMPTYARG )
1096 // Flackern der Buttons vermeiden:
1097 aDeselectTimer.Start();
1099 return 0;
1102 /*--------------------------------------------------------------------
1103 Beschreibung:
1104 --------------------------------------------------------------------*/
1106 IMPL_LINK( SwRedlineAcceptDlg, SelectHdl, void*, EMPTYARG )
1108 aDeselectTimer.Stop();
1109 aSelectTimer.Start();
1111 return 0;
1114 /*--------------------------------------------------------------------
1115 Beschreibung:
1116 --------------------------------------------------------------------*/
1118 IMPL_LINK( SwRedlineAcceptDlg, GotoHdl, void*, EMPTYARG )
1120 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
1121 aSelectTimer.Stop();
1123 BOOL bIsNotFormated = FALSE;
1124 BOOL bSel = FALSE;
1125 // BOOL bReadonlySel = FALSE;
1127 //#98883# don't select redlines while the dialog is not focussed
1128 //#107938# But not only ask pTable if it has the focus. To move
1129 // the selection to the selected redline any child of pParentDlg
1130 // may the focus.
1131 SvLBoxEntry* pSelEntry = 0;
1133 if (pParentDlg->HasChildPathFocus())
1134 pSelEntry = pTable->FirstSelected();
1136 if( pSelEntry )
1138 SvLBoxEntry* pActEntry = pSelEntry;
1139 pSh->StartAction();
1140 pSh->EnterStdMode();
1141 pSh->SetCareWin(pParentDlg);
1143 while (pSelEntry)
1145 if (pTable->GetParent(pSelEntry))
1147 pActEntry = pTable->GetParent(pSelEntry);
1149 if (pTable->IsSelected(pActEntry))
1151 pSelEntry = pActEntry = pTable->NextSelected(pSelEntry);
1152 continue; // Nicht zweimal selektieren
1155 else
1156 bSel = TRUE;
1158 // #98864# find the selected redline (ignore, if the redline is already gone)
1159 USHORT nPos = GetRedlinePos(*pActEntry);
1160 if( nPos != USHRT_MAX )
1163 const SwRedline& rRedln = pSh->GetRedline( nPos );
1164 bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType();
1166 //JP 27.9.2001: make no sense if we handle readonly sections
1167 // if( !bReadonlySel && rRedln.HasReadonlySel() )
1168 // bReadonlySel = TRUE;
1170 if (pSh->GotoRedline(nPos, TRUE))
1172 pSh->SetInSelect();
1173 pSh->EnterAddMode();
1177 pSelEntry = pActEntry = pTable->NextSelected(pSelEntry);
1180 pSh->LeaveAddMode();
1181 pSh->EndAction();
1182 pSh->SetCareWin(NULL);
1184 BOOL bEnable = !pSh->getIDocumentRedlineAccess()->GetRedlinePassword().getLength();
1185 pTPView->EnableAccept( bEnable && bSel /*&& !bReadonlySel*/ );
1186 pTPView->EnableReject( bEnable && bSel && bIsNotFormated /*&& !bReadonlySel*/ );
1187 pTPView->EnableRejectAll( bEnable && !bOnlyFormatedRedlines && !bHasReadonlySel );
1189 return 0;
1192 /*--------------------------------------------------------------------
1193 Beschreibung:
1194 --------------------------------------------------------------------*/
1196 IMPL_LINK( SwRedlineAcceptDlg, CommandHdl, void*, EMPTYARG )
1198 const CommandEvent aCEvt(pTable->GetCommandEvent());
1200 switch ( aCEvt.GetCommand() )
1202 case COMMAND_CONTEXTMENU:
1204 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr();
1205 SvLBoxEntry* pEntry = pTable->FirstSelected();
1206 const SwRedline *pRed = 0;
1208 if (pEntry)
1210 SvLBoxEntry* pTopEntry = pEntry;
1212 if (pTable->GetParent(pEntry))
1213 pTopEntry = pTable->GetParent(pEntry);
1215 USHORT nPos = GetRedlinePos(*pTopEntry);
1217 // Bei geschuetzten Bereichen kommentieren disablen
1218 if ((pRed = pSh->GotoRedline(nPos, TRUE)) != 0)
1220 if( pSh->IsCrsrPtAtEnd() )
1221 pSh->SwapPam();
1222 pSh->SetInSelect();
1226 aPopup.EnableItem( MN_EDIT_COMMENT, pEntry && pRed &&
1227 !pTable->GetParent(pEntry) &&
1228 !pTable->NextSelected(pEntry)
1229 //JP 27.9.2001: make no sense if we handle readonly sections
1230 // && pRed->HasReadonlySel()
1233 aPopup.EnableItem( MN_SUB_SORT, pTable->First() != 0 );
1234 USHORT nColumn = pTable->GetSortedCol();
1235 if (nColumn == 0xffff)
1236 nColumn = 4;
1238 PopupMenu *pSubMenu = aPopup.GetPopupMenu(MN_SUB_SORT);
1239 if (pSubMenu)
1241 for (USHORT i = MN_SORT_ACTION; i < MN_SORT_ACTION + 5; i++)
1242 pSubMenu->CheckItem(i, FALSE);
1244 pSubMenu->CheckItem(nColumn + MN_SORT_ACTION);
1247 USHORT nRet = aPopup.Execute(pTable, aCEvt.GetMousePosPixel());
1249 switch( nRet )
1251 case MN_EDIT_COMMENT:
1253 String sComment;
1254 if (pEntry)
1256 if (pTable->GetParent(pEntry))
1257 pEntry = pTable->GetParent(pEntry);
1259 USHORT nPos = GetRedlinePos(*pEntry);
1260 const SwRedline &rRedline = pSh->GetRedline(nPos);
1263 /* enable again once we have redline comments in the margin
1264 sComment = rRedline.GetComment();
1265 if ( sComment == String(::rtl::OUString::createFromAscii("")) )
1266 GetActiveView()->GetDocShell()->Broadcast(SwRedlineHint(&rRedline,SWREDLINE_INSERTED));
1267 const_cast<SwRedline&>(rRedline).Broadcast(SwRedlineHint(&rRedline,SWREDLINE_FOCUS));
1270 sComment = rRedline.GetComment();
1271 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1272 DBG_ASSERT(pFact, "Dialogdiet fail!");
1273 ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc( RID_SVXDLG_POSTIT );
1274 DBG_ASSERT(fnGetRange, "Dialogdiet fail! GetRanges()");
1275 SfxItemSet aSet( pSh->GetAttrPool(), fnGetRange() );
1277 aSet.Put(SvxPostItTextItem(sComment.ConvertLineEnd(), SID_ATTR_POSTIT_TEXT));
1278 aSet.Put(SvxPostItAuthorItem(rRedline.GetAuthorString(), SID_ATTR_POSTIT_AUTHOR));
1280 aSet.Put(SvxPostItDateItem( GetAppLangDateTimeString(
1281 rRedline.GetRedlineData().GetTimeStamp() ),
1282 SID_ATTR_POSTIT_DATE ));
1284 AbstractSvxPostItDialog* pDlg = pFact->CreateSvxPostItDialog( pParentDlg, aSet, RID_SVXDLG_POSTIT, FALSE );
1285 DBG_ASSERT(pDlg, "Dialogdiet fail!");
1287 pDlg->HideAuthor();
1289 USHORT nResId = 0;
1290 switch( rRedline.GetType() )
1292 case nsRedlineType_t::REDLINE_INSERT:
1293 nResId = STR_REDLINE_INSERTED;
1294 break;
1295 case nsRedlineType_t::REDLINE_DELETE:
1296 nResId = STR_REDLINE_DELETED;
1297 break;
1298 case nsRedlineType_t::REDLINE_FORMAT:
1299 nResId = STR_REDLINE_FORMATED;
1300 break;
1301 case nsRedlineType_t::REDLINE_TABLE:
1302 nResId = STR_REDLINE_TABLECHG;
1303 break;
1304 default:;//prevent warning
1306 String sTitle(SW_RES(STR_REDLINE_COMMENT));
1307 if( nResId )
1308 sTitle += SW_RESSTR( nResId );
1309 pDlg->SetText(sTitle);
1311 pSh->SetCareWin(pDlg->GetWindow());
1313 if ( pDlg->Execute() == RET_OK )
1315 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
1316 String sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue());
1318 // Kommentar einfuegen bzw aendern
1319 pSh->SetRedlineComment(sMsg);
1320 sMsg.SearchAndReplaceAll((sal_Unicode)_LF,(sal_Unicode)' ');
1321 pTable->SetEntryText(sMsg, pEntry, 3);
1324 delete pDlg;
1325 pSh->SetCareWin(NULL);
1329 break;
1331 case MN_SORT_ACTION:
1332 case MN_SORT_AUTHOR:
1333 case MN_SORT_DATE:
1334 case MN_SORT_COMMENT:
1335 case MN_SORT_POSITION:
1337 bSortDir = TRUE;
1338 if (nRet - MN_SORT_ACTION == 4 && pTable->GetSortedCol() == 0xffff)
1339 break; // Haben wir schon
1341 nSortMode = nRet - MN_SORT_ACTION;
1342 if (nSortMode == 4)
1343 nSortMode = 0xffff; // unsortiert bzw sortiert nach Position
1345 if (pTable->GetSortedCol() == nSortMode)
1346 bSortDir = !pTable->GetSortDirection();
1348 SwWait aWait( *::GetActiveView()->GetDocShell(), FALSE );
1349 pTable->SortByCol(nSortMode, bSortDir);
1350 if (nSortMode == 0xffff)
1351 Init(); // Alles neu fuellen
1353 break;
1356 break;
1359 return 0;
1362 /*--------------------------------------------------------------------
1363 Beschreibung:
1364 --------------------------------------------------------------------*/
1366 void SwRedlineAcceptDlg::Initialize(const String& rExtraData)
1368 if (rExtraData.Len())
1370 USHORT nPos = rExtraData.Search(C2S("AcceptChgDat:"));
1372 // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
1373 // er nicht vorhanden ist, liegt eine "altere Version vor
1374 if (nPos != STRING_NOTFOUND)
1376 USHORT n1 = rExtraData.Search('(', nPos);
1377 if (n1 != STRING_NOTFOUND)
1379 USHORT n2 = rExtraData.Search(')', n1);
1380 if (n2 != STRING_NOTFOUND)
1382 // Alignment-String herausschneiden
1383 String aStr = rExtraData.Copy(nPos, n2 - nPos + 1);
1384 aStr.Erase(0, n1 - nPos + 1);
1386 if (aStr.Len())
1388 USHORT nCount = static_cast< USHORT >(aStr.ToInt32());
1390 for (USHORT i = 0; i < nCount; i++)
1392 USHORT n3 = aStr.Search(';');
1393 aStr.Erase(0, n3 + 1);
1394 pTable->SetTab(i, aStr.ToInt32(), MAP_PIXEL);
1403 /*--------------------------------------------------------------------
1404 Beschreibung:
1405 --------------------------------------------------------------------*/
1407 void SwRedlineAcceptDlg::FillInfo(String &rExtraData) const
1409 rExtraData.AppendAscii("AcceptChgDat:(");
1411 USHORT nCount = pTable->TabCount();
1413 rExtraData += String::CreateFromInt32(nCount);
1414 rExtraData += ';';
1415 for(USHORT i = 0; i < nCount; i++)
1417 rExtraData += String::CreateFromInt32( pTable->GetTab(i) );
1418 rExtraData += ';';
1420 rExtraData += ')';