1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 #define _SVSTDARR_STRINGSSORTDTOR 33 #define _SVSTDARR_USHORTSSORT 34 #define _SVSTDARR_USHORTS 35 36 37 #include <redline.hxx> 38 #include <tools/datetime.hxx> 39 #include <vcl/msgbox.hxx> 40 #include <svl/svstdarr.hxx> 41 #include <svl/eitem.hxx> 42 #include <sfx2/viewfrm.hxx> 43 #include <sfx2/dispatch.hxx> 44 #include <svx/ctredlin.hxx> 45 #include <svx/postattr.hxx> 46 #include <swtypes.hxx> 47 #include <wrtsh.hxx> 48 #include <view.hxx> 49 #include <swmodule.hxx> 50 #ifndef _REDLNDLG_HXX 51 #define _REDLNACCEPTDLG 52 #include <redlndlg.hxx> 53 #endif 54 #include <swwait.hxx> 55 #include <uitool.hxx> 56 57 #include <helpid.h> 58 #include <cmdid.h> 59 #include <misc.hrc> 60 #include <redlndlg.hrc> 61 #include <shells.hrc> 62 63 // -> #111827# 64 #include <comcore.hrc> 65 #include <swundo.hxx> 66 #include <SwRewriter.hxx> 67 // <- #111827# 68 69 #include <vector> 70 #include <svx/svxdlg.hxx> 71 #include <svx/dialogs.hrc> 72 73 #include <unomid.h> 74 75 #include <docsh.hxx> 76 77 #include <IDocumentRedlineAccess.hxx> 78 79 /*------------------------------------------------------------------------ 80 Beschreibung: 81 ------------------------------------------------------------------------*/ 82 83 SFX_IMPL_MODELESSDIALOG( SwRedlineAcceptChild, FN_REDLINE_ACCEPT ) 84 85 SV_IMPL_PTRARR(SwRedlineDataParentArr, SwRedlineDataParentPtr) 86 SV_IMPL_OP_PTRARR_SORT(SwRedlineDataParentSortArr, SwRedlineDataParentPtr) 87 SV_IMPL_PTRARR(SwRedlineDataChildArr, SwRedlineDataChildPtr) 88 SV_IMPL_PTRARR(SvLBoxEntryArr, SvLBoxEntryPtr) 89 90 static sal_uInt16 nSortMode = 0xffff; 91 static sal_Bool bSortDir = sal_True; 92 93 /*------------------------------------------------------------------------ 94 Beschreibung: 95 ------------------------------------------------------------------------*/ 96 97 SwRedlineAcceptChild::SwRedlineAcceptChild( Window* _pParent, 98 sal_uInt16 nId, 99 SfxBindings* pBindings, 100 SfxChildWinInfo* pInfo ) : 101 SwChildWinWrapper( _pParent, nId ) 102 { 103 pWindow = new SwModelessRedlineAcceptDlg( pBindings, this, _pParent); 104 105 ((SwModelessRedlineAcceptDlg *)pWindow)->Initialize(pInfo); 106 } 107 108 /*-------------------------------------------------------------------- 109 Beschreibung: Nach Dok-Wechsel Dialog neu initialisieren 110 --------------------------------------------------------------------*/ 111 112 sal_Bool SwRedlineAcceptChild::ReInitDlg(SwDocShell *pDocSh) 113 { 114 sal_Bool bRet; 115 116 if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == sal_True) // Sofort aktualisieren, Dok-Wechsel 117 ((SwModelessRedlineAcceptDlg*)GetWindow())->Activate(); 118 119 return bRet; 120 } 121 122 /*------------------------------------------------------------------------ 123 Beschreibung: 124 ------------------------------------------------------------------------*/ 125 126 SwModelessRedlineAcceptDlg::SwModelessRedlineAcceptDlg( SfxBindings* _pBindings, 127 SwChildWinWrapper* pChild, 128 Window *_pParent) : 129 SfxModelessDialog(_pBindings, pChild, _pParent, SW_RES(DLG_REDLINE_ACCEPT)), 130 pChildWin (pChild) 131 { 132 pImplDlg = new SwRedlineAcceptDlg(this); 133 134 FreeResource(); 135 } 136 137 /*-------------------------------------------------------------------- 138 Beschreibung: 139 --------------------------------------------------------------------*/ 140 141 void SwModelessRedlineAcceptDlg::Activate() 142 { 143 SwView *pView = ::GetActiveView(); 144 145 if (!pView) // Kann passieren, wenn man auf eine andere App umschaltet, wenn 146 return; // vorher eine Listbox im Dialog den Focus hatte (eigentlich THs Bug) 147 148 SwDocShell *pDocSh = pView->GetDocShell(); 149 150 if (pChildWin->GetOldDocShell() != pDocSh) 151 { // Dok-Wechsel 152 SwWait aWait( *pDocSh, sal_False ); 153 SwWrtShell* pSh = pView->GetWrtShellPtr(); 154 155 pChildWin->SetOldDocShell(pDocSh); // Rekursion vermeiden (durch Modified-Hdl) 156 157 sal_Bool bMod = pSh->IsModified(); 158 SfxBoolItem aShow(FN_REDLINE_SHOW, sal_True); 159 pSh->GetView().GetViewFrame()->GetDispatcher()->Execute( 160 FN_REDLINE_SHOW, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aShow, 0L); 161 if (!bMod) 162 pSh->ResetModified(); 163 pImplDlg->Init(); 164 165 return; 166 } 167 168 pImplDlg->Activate(); 169 } 170 171 /*-------------------------------------------------------------------- 172 Beschreibung: 173 --------------------------------------------------------------------*/ 174 175 void SwModelessRedlineAcceptDlg::Initialize(SfxChildWinInfo *pInfo) 176 { 177 String aStr; 178 if (pInfo != NULL) 179 pImplDlg->Initialize(pInfo->aExtraString); 180 181 SfxModelessDialog::Initialize(pInfo); 182 } 183 184 /*-------------------------------------------------------------------- 185 Beschreibung: 186 --------------------------------------------------------------------*/ 187 188 void SwModelessRedlineAcceptDlg::FillInfo(SfxChildWinInfo& rInfo) const 189 { 190 SfxModelessDialog::FillInfo(rInfo); 191 pImplDlg->FillInfo(rInfo.aExtraString); 192 } 193 194 /*------------------------------------------------------------------------ 195 Beschreibung: 196 ------------------------------------------------------------------------*/ 197 198 void SwModelessRedlineAcceptDlg::Resize() 199 { 200 pImplDlg->Resize(); 201 SfxModelessDialog::Resize(); 202 } 203 204 /*------------------------------------------------------------------------ 205 Beschreibung: 206 ------------------------------------------------------------------------*/ 207 208 SwModelessRedlineAcceptDlg::~SwModelessRedlineAcceptDlg() 209 { 210 delete pImplDlg; 211 } 212 213 /*------------------------------------------------------------------------ 214 Beschreibung: 215 ------------------------------------------------------------------------*/ 216 217 SwRedlineAcceptDlg::SwRedlineAcceptDlg(Dialog *pParent, sal_Bool bAutoFmt) : 218 pParentDlg (pParent), 219 aTabPagesCTRL (pParent, SW_RES(CTRL_TABPAGES)), 220 aPopup (SW_RES(MN_REDLINE_POPUP)), 221 sInserted (SW_RES(STR_REDLINE_INSERTED)), 222 sDeleted (SW_RES(STR_REDLINE_DELETED)), 223 sFormated (SW_RES(STR_REDLINE_FORMATED)), 224 sTableChgd (SW_RES(STR_REDLINE_TABLECHG)), 225 sFmtCollSet (SW_RES(STR_REDLINE_FMTCOLLSET)), 226 sAutoFormat (SW_RES(STR_REDLINE_AUTOFMT)), 227 bOnlyFormatedRedlines( sal_False ), 228 bHasReadonlySel ( sal_False ), 229 bRedlnAutoFmt (bAutoFmt), 230 bInhibitActivate( false ) 231 { 232 aTabPagesCTRL.SetHelpId(HID_REDLINE_CTRL); 233 pTPView = aTabPagesCTRL.GetViewPage(); 234 pTable = pTPView->GetTableControl(); 235 236 pTPView->InsertWriterHeader(); 237 pTPView->SetAcceptClickHdl(LINK(this, SwRedlineAcceptDlg, AcceptHdl)); 238 pTPView->SetAcceptAllClickHdl(LINK(this, SwRedlineAcceptDlg, AcceptAllHdl)); 239 pTPView->SetRejectClickHdl(LINK(this, SwRedlineAcceptDlg, RejectHdl)); 240 pTPView->SetRejectAllClickHdl(LINK(this, SwRedlineAcceptDlg, RejectAllHdl)); 241 pTPView->SetUndoClickHdl(LINK(this, SwRedlineAcceptDlg, UndoHdl)); 242 243 aTabPagesCTRL.GetFilterPage()->SetReadyHdl(LINK(this, SwRedlineAcceptDlg, FilterChangedHdl)); 244 245 ListBox *pActLB = aTabPagesCTRL.GetFilterPage()->GetLbAction(); 246 pActLB->InsertEntry(sInserted); 247 pActLB->InsertEntry(sDeleted); 248 pActLB->InsertEntry(sFormated); 249 pActLB->InsertEntry(sTableChgd); 250 251 if (HasRedlineAutoFmt()) 252 { 253 pActLB->InsertEntry(sFmtCollSet); 254 pActLB->InsertEntry(sAutoFormat); 255 pTPView->ShowUndo(sal_True); 256 pTPView->DisableUndo(); // Noch gibts keine UNDO-Events 257 } 258 259 pActLB->SelectEntryPos(0); 260 261 pTable->SetStyle(pTable->GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL); 262 pTable->SetNodeDefaultImages(); 263 pTable->SetSelectionMode(MULTIPLE_SELECTION); 264 pTable->SetHighlightRange(1); 265 266 static long aStaticTabs[]= 267 { 268 4,10,70,120,170 269 }; 270 271 pTable->SetTabs(aStaticTabs); 272 273 // Minimalgroesse setzen 274 Size aMinSz(aTabPagesCTRL.GetMinSizePixel()); 275 Point aPos(aTabPagesCTRL.GetPosPixel()); 276 277 aMinSz.Width() += (aPos.X() * 2 - 1); 278 aMinSz.Height() += (aPos.Y() * 2 - 1); 279 pParentDlg->SetMinOutputSizePixel(aMinSz); 280 281 if (pParentDlg->GetOutputSizePixel().Width() < aMinSz.Width()) 282 pParentDlg->SetOutputSizePixel(Size(aMinSz.Width(), pParentDlg->GetOutputSizePixel().Height())); 283 if (pParentDlg->GetOutputSizePixel().Height() < aMinSz.Height()) 284 pParentDlg->SetOutputSizePixel(Size(pParentDlg->GetOutputSizePixel().Width(), aMinSz.Height())); 285 286 pTable->SortByCol(nSortMode, bSortDir); 287 288 aOldSelectHdl = pTable->GetSelectHdl(); 289 aOldDeselectHdl = pTable->GetDeselectHdl(); 290 pTable->SetSelectHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl)); 291 pTable->SetDeselectHdl(LINK(this, SwRedlineAcceptDlg, DeselectHdl)); 292 pTable->SetCommandHdl(LINK(this, SwRedlineAcceptDlg, CommandHdl)); 293 294 // Flackern der Buttons vermeiden: 295 aDeselectTimer.SetTimeout(100); 296 aDeselectTimer.SetTimeoutHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl)); 297 298 // Mehrfachselektion der selben Texte vermeiden: 299 aSelectTimer.SetTimeout(100); 300 aSelectTimer.SetTimeoutHdl(LINK(this, SwRedlineAcceptDlg, GotoHdl)); 301 } 302 303 /*------------------------------------------------------------------------ 304 Beschreibung: 305 ------------------------------------------------------------------------*/ 306 307 SwRedlineAcceptDlg::~SwRedlineAcceptDlg() 308 { 309 } 310 311 /*------------------------------------------------------------------------ 312 Beschreibung: 313 ------------------------------------------------------------------------*/ 314 315 void SwRedlineAcceptDlg::Init(sal_uInt16 nStart) 316 { 317 SwWait aWait( *::GetActiveView()->GetDocShell(), sal_False ); 318 pTable->SetUpdateMode(sal_False); 319 aUsedSeqNo.Remove((sal_uInt16)0, aUsedSeqNo.Count()); 320 321 if (nStart) 322 RemoveParents(nStart, aRedlineParents.Count() - 1); 323 else 324 { 325 pTable->Clear(); 326 aRedlineChilds.DeleteAndDestroy(0, aRedlineChilds.Count()); 327 aRedlineParents.DeleteAndDestroy(nStart, aRedlineParents.Count() - nStart); 328 } 329 330 // Parents einfuegen 331 InsertParents(nStart); 332 InitAuthors(); 333 334 pTable->SetUpdateMode(sal_True); 335 // #i69618# this moves the list box to the right position, visually 336 SvLBoxEntry* pSelEntry = pTable->FirstSelected(); 337 if( pSelEntry ) 338 pTable->MakeVisible( pSelEntry, sal_True ); //#i70937#, force the scroll 339 } 340 341 /*------------------------------------------------------------------------ 342 Beschreibung: 343 ------------------------------------------------------------------------*/ 344 345 void SwRedlineAcceptDlg::InitAuthors() 346 { 347 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr(); 348 349 SvxTPFilter *pFilterPage = aTabPagesCTRL.GetFilterPage(); 350 351 String sAuthor; 352 SvStringsSortDtor aStrings; 353 String sOldAuthor(pFilterPage->GetSelectedAuthor()); 354 pFilterPage->ClearAuthors(); 355 356 String sParent; 357 sal_uInt16 nCount = pSh->GetRedlineCount(); 358 359 bOnlyFormatedRedlines = sal_True; 360 bHasReadonlySel = sal_False; 361 sal_Bool bIsNotFormated = sal_False; 362 sal_uInt16 i; 363 364 // Autoren ermitteln 365 for ( i = 0; i < nCount; i++) 366 { 367 const SwRedline& rRedln = pSh->GetRedline(i); 368 369 if( bOnlyFormatedRedlines && nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType() ) 370 bOnlyFormatedRedlines = sal_False; 371 372 //JP 27.9.2001: make no sense if we handle readonly sections 373 // if( !bHasReadonlySel && rRedln.HasReadonlySel() ) 374 // bHasReadonlySel = sal_True; 375 376 String *pAuthor = new String(rRedln.GetAuthorString()); 377 if (!aStrings.Insert(pAuthor)) 378 delete pAuthor; 379 380 for (sal_uInt16 nStack = 1; nStack < rRedln.GetStackCount(); nStack++) 381 { 382 pAuthor = new String(rRedln.GetAuthorString(nStack)); 383 if (!aStrings.Insert(pAuthor)) 384 delete pAuthor; 385 } 386 } 387 388 for (i = 0; i < aStrings.Count(); i++) 389 pFilterPage->InsertAuthor(*aStrings[i]); 390 391 if (pFilterPage->SelectAuthor(sOldAuthor) == LISTBOX_ENTRY_NOTFOUND && aStrings.Count()) 392 pFilterPage->SelectAuthor(*aStrings[0]); 393 394 sal_Bool bEnable = pTable->GetEntryCount() != 0 && !pSh->getIDocumentRedlineAccess()->GetRedlinePassword().getLength(); 395 sal_Bool bSel = pTable->FirstSelected() != 0; 396 397 SvLBoxEntry* pSelEntry = pTable->FirstSelected(); 398 while (pSelEntry) 399 { 400 sal_uInt16 nPos = GetRedlinePos(*pSelEntry); 401 const SwRedline& rRedln = pSh->GetRedline( nPos ); 402 403 bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType(); 404 pSelEntry = pTable->NextSelected(pSelEntry); 405 } 406 407 pTPView->EnableAccept( bEnable && bSel ); 408 pTPView->EnableReject( bEnable && bIsNotFormated && bSel ); 409 pTPView->EnableAcceptAll( bEnable && !bHasReadonlySel ); 410 pTPView->EnableRejectAll( bEnable && !bHasReadonlySel && 411 !bOnlyFormatedRedlines ); 412 } 413 414 /*------------------------------------------------------------------------ 415 Beschreibung: 416 ------------------------------------------------------------------------*/ 417 418 String SwRedlineAcceptDlg::GetRedlineText( const SwRedline& rRedln, 419 DateTime &rDateTime, sal_uInt16 nStack) 420 { 421 String sEntry(GetActionText(rRedln, nStack)); 422 sEntry += '\t'; 423 sEntry += rRedln.GetAuthorString(nStack); 424 sEntry += '\t'; 425 426 const DateTime &rDT = rRedln.GetTimeStamp(nStack); 427 rDateTime = rDT; 428 429 sEntry += GetAppLangDateTimeString( rDT ); 430 sEntry += '\t'; 431 432 sEntry += rRedln.GetComment(nStack); 433 434 return sEntry; 435 } 436 437 /*------------------------------------------------------------------------ 438 Beschreibung: 439 ------------------------------------------------------------------------*/ 440 441 const String &SwRedlineAcceptDlg::GetActionText(const SwRedline& rRedln, sal_uInt16 nStack) 442 { 443 switch( rRedln.GetType(nStack) ) 444 { 445 case nsRedlineType_t::REDLINE_INSERT: return sInserted; 446 case nsRedlineType_t::REDLINE_DELETE: return sDeleted; 447 case nsRedlineType_t::REDLINE_FORMAT: return sFormated; 448 case nsRedlineType_t::REDLINE_TABLE: return sTableChgd; 449 case nsRedlineType_t::REDLINE_FMTCOLL: return sFmtCollSet; 450 default:;//prevent warning 451 } 452 453 return aEmptyStr; 454 } 455 456 /*------------------------------------------------------------------------ 457 Beschreibung: 458 ------------------------------------------------------------------------*/ 459 460 void SwRedlineAcceptDlg::Resize() 461 { 462 Size aSz(pParentDlg->GetOutputSizePixel()); 463 464 Point aPos(aTabPagesCTRL.GetPosPixel()); 465 466 aSz.Width() -= (aPos.X() * 2 - 1); 467 aSz.Height() -= (aPos.Y() * 2 - 1); 468 469 aTabPagesCTRL.SetOutputSizePixel(aSz); 470 } 471 472 /*-------------------------------------------------------------------- 473 Beschreibung: Nach Aktivierung neu initialisieren 474 --------------------------------------------------------------------*/ 475 476 void SwRedlineAcceptDlg::Activate() 477 { 478 // prevent update if flag is set (#102547#) 479 if( bInhibitActivate ) 480 return; 481 482 SwView *pView = ::GetActiveView(); 483 SwWait aWait( *pView->GetDocShell(), sal_False ); 484 485 aUsedSeqNo.Remove((sal_uInt16)0, aUsedSeqNo.Count()); 486 487 if (!pView) // Kann passieren, wenn man auf eine andere App umschaltet, wenn 488 return; // vorher eine Listbox im Dialog den Focus hatte (eigentlich THs Bug) 489 490 /* if (HasRedlineAutoFmt()) 491 { 492 Init(); 493 return; 494 }*/ 495 496 // Hat sich was geaendert? 497 SwWrtShell* pSh = pView->GetWrtShellPtr(); 498 sal_uInt16 nCount = pSh->GetRedlineCount(); 499 500 // Anzahl und Pointer ueberpruefen 501 SwRedlineDataParent *pParent = 0; 502 sal_uInt16 i; 503 504 for ( i = 0; i < nCount; i++) 505 { 506 const SwRedline& rRedln = pSh->GetRedline(i); 507 508 if (i >= aRedlineParents.Count()) 509 { 510 // Neue Eintraege wurden angehaengt 511 Init(i); 512 return; 513 } 514 515 pParent = aRedlineParents[i]; 516 if (&rRedln.GetRedlineData() != pParent->pData) 517 { 518 // Redline-Parents wurden eingefuegt, geaendert oder geloescht 519 if ((i = CalcDiff(i, sal_False)) == USHRT_MAX) 520 return; 521 continue; 522 } 523 524 const SwRedlineData *pRedlineData = rRedln.GetRedlineData().Next(); 525 const SwRedlineDataChild *pBackupData = pParent->pNext; 526 527 if (!pRedlineData && pBackupData) 528 { 529 // Redline-Childs wurden geloescht 530 if ((i = CalcDiff(i, sal_True)) == USHRT_MAX) 531 return; 532 continue; 533 } 534 else 535 { 536 while (pRedlineData) 537 { 538 if (pRedlineData != pBackupData->pChild) 539 { 540 // Redline-Childs wurden eingefuegt, geaendert oder geloescht 541 if ((i = CalcDiff(i, sal_True)) == USHRT_MAX) 542 return; 543 continue; 544 } 545 if (pBackupData) 546 pBackupData = pBackupData->pNext; 547 pRedlineData = pRedlineData->Next(); 548 } 549 } 550 } 551 552 if (nCount != aRedlineParents.Count()) 553 { 554 // Redlines wurden am Ende geloescht 555 Init(nCount); 556 return; 557 } 558 559 // Kommentar ueberpruefen 560 for (i = 0; i < nCount; i++) 561 { 562 const SwRedline& rRedln = pSh->GetRedline(i); 563 pParent = aRedlineParents[i]; 564 565 if(!rRedln.GetComment().Equals(pParent->sComment)) 566 { 567 if (pParent->pTLBParent) 568 { 569 // Nur Kommentar aktualisieren 570 String sComment(rRedln.GetComment()); 571 sComment.SearchAndReplaceAll((sal_Unicode)_LF,(sal_Unicode)' '); 572 pTable->SetEntryText(sComment, pParent->pTLBParent, 3); 573 } 574 pParent->sComment = rRedln.GetComment(); 575 } 576 } 577 578 InitAuthors(); 579 } 580 581 /* -----------------05.06.98 13:06------------------- 582 * 583 * --------------------------------------------------*/ 584 585 sal_uInt16 SwRedlineAcceptDlg::CalcDiff(sal_uInt16 nStart, sal_Bool bChild) 586 { 587 if (!nStart) 588 { 589 Init(); 590 return USHRT_MAX; 591 } 592 593 pTable->SetUpdateMode(sal_False); 594 SwView *pView = ::GetActiveView(); 595 SwWrtShell* pSh = pView->GetWrtShellPtr(); 596 sal_uInt16 nAutoFmt = HasRedlineAutoFmt() ? nsRedlineType_t::REDLINE_FORM_AUTOFMT : 0; 597 SwRedlineDataParent *pParent = aRedlineParents[nStart]; 598 const SwRedline& rRedln = pSh->GetRedline(nStart); 599 600 if (bChild) // Sollte eigentlich nie vorkommen, aber sicher ist sicher... 601 { 602 // Alle Childs des Eintrags wegwerfen und neu initialisieren 603 SwRedlineDataChildPtr pBackupData = (SwRedlineDataChildPtr)pParent->pNext; 604 SwRedlineDataChildPtr pNext; 605 606 while (pBackupData) 607 { 608 pNext = (SwRedlineDataChildPtr)pBackupData->pNext; 609 if (pBackupData->pTLBChild) 610 pTable->RemoveEntry(pBackupData->pTLBChild); 611 612 aRedlineChilds.DeleteAndDestroy(aRedlineChilds.GetPos(pBackupData), 1); 613 pBackupData = pNext; 614 } 615 pParent->pNext = 0; 616 617 // Neue Childs einfuegen 618 InsertChilds(pParent, rRedln, nAutoFmt); 619 620 pTable->SetUpdateMode(sal_True); 621 return nStart; 622 } 623 624 // Wurden Eintraege geloescht? 625 const SwRedlineData *pRedlineData = &rRedln.GetRedlineData(); 626 sal_uInt16 i; 627 for ( i = nStart + 1; i < aRedlineParents.Count(); i++) 628 { 629 if (aRedlineParents[i]->pData == pRedlineData) 630 { 631 // Eintraege von nStart bis i-1 entfernen 632 RemoveParents(nStart, i - 1); 633 pTable->SetUpdateMode(sal_True); 634 return nStart - 1; 635 } 636 } 637 638 // Wurden Eintraege eingefuegt? 639 sal_uInt16 nCount = pSh->GetRedlineCount(); 640 pRedlineData = aRedlineParents[nStart]->pData; 641 642 for (i = nStart + 1; i < nCount; i++) 643 { 644 if (&pSh->GetRedline(i).GetRedlineData() == pRedlineData) 645 { 646 // Eintraege von nStart bis i-1 einfuegen 647 InsertParents(nStart, i - 1); 648 pTable->SetUpdateMode(sal_True); 649 return nStart - 1; 650 } 651 } 652 653 pTable->SetUpdateMode(sal_True); 654 Init(nStart); // Alle Eintraege bis zum Ende abgleichen 655 return USHRT_MAX; 656 } 657 658 /* -----------------05.06.98 13:57------------------- 659 * 660 * --------------------------------------------------*/ 661 662 void SwRedlineAcceptDlg::InsertChilds(SwRedlineDataParent *pParent, const SwRedline& rRedln, const sal_uInt16 nAutoFmt) 663 { 664 String sChild; 665 SwRedlineDataChild *pLastRedlineChild = 0; 666 const SwRedlineData *pRedlineData = &rRedln.GetRedlineData(); 667 sal_Bool bAutoFmt = (rRedln.GetRealType() & nAutoFmt) != 0; 668 669 const String *pAction = &GetActionText(rRedln); 670 sal_Bool bValidParent = !sFilterAction.Len() || sFilterAction == *pAction; 671 bValidParent = bValidParent && pTable->IsValidEntry(&rRedln.GetAuthorString(), &rRedln.GetTimeStamp(), &rRedln.GetComment()); 672 if (nAutoFmt) 673 { 674 sal_uInt16 nPos; 675 676 if (pParent->pData->GetSeqNo() && !aUsedSeqNo.Insert(pParent, nPos)) // Gibts schon 677 { 678 if (pParent->pTLBParent) 679 { 680 pTable->SetEntryText(sAutoFormat, aUsedSeqNo[nPos]->pTLBParent, 0); 681 pTable->RemoveEntry(pParent->pTLBParent); 682 pParent->pTLBParent = 0; 683 } 684 return; 685 } 686 bValidParent = bValidParent && bAutoFmt; 687 } 688 sal_Bool bValidTree = bValidParent; 689 690 for (sal_uInt16 nStack = 1; nStack < rRedln.GetStackCount(); nStack++) 691 { 692 pRedlineData = pRedlineData->Next(); 693 694 SwRedlineDataChildPtr pRedlineChild = new SwRedlineDataChild; 695 pRedlineChild->pChild = pRedlineData; 696 aRedlineChilds.Insert(pRedlineChild, aRedlineChilds.Count()); 697 698 if ( pLastRedlineChild ) 699 pLastRedlineChild->pNext = pRedlineChild; 700 else 701 pParent->pNext = pRedlineChild; 702 703 pAction = &GetActionText(rRedln, nStack); 704 sal_Bool bValidChild = !sFilterAction.Len() || sFilterAction == *pAction; 705 bValidChild = bValidChild && pTable->IsValidEntry(&rRedln.GetAuthorString(nStack), &rRedln.GetTimeStamp(nStack), &rRedln.GetComment()); 706 if (nAutoFmt) 707 bValidChild = bValidChild && bAutoFmt; 708 bValidTree |= bValidChild; 709 710 if (bValidChild) 711 { 712 RedlinData *pData = new RedlinData; 713 pData->pData = pRedlineChild; 714 pData->bDisabled = sal_True; 715 sChild = GetRedlineText(rRedln, pData->aDateTime, nStack); 716 717 SvLBoxEntry* pChild = pTable->InsertEntry(sChild, pData, pParent->pTLBParent); 718 719 pRedlineChild->pTLBChild = pChild; 720 if (!bValidParent) 721 pTable->Expand(pParent->pTLBParent); 722 } 723 else 724 pRedlineChild->pTLBChild = 0; 725 726 pLastRedlineChild = pRedlineChild; 727 } 728 729 if (pLastRedlineChild) 730 pLastRedlineChild->pNext = 0; 731 732 if (!bValidTree && pParent->pTLBParent) 733 { 734 pTable->RemoveEntry(pParent->pTLBParent); 735 pParent->pTLBParent = 0; 736 if (nAutoFmt) 737 aUsedSeqNo.Remove(pParent); 738 } 739 } 740 741 /* -----------------05.06.98 15:20------------------- 742 * 743 * --------------------------------------------------*/ 744 745 void SwRedlineAcceptDlg::RemoveParents(sal_uInt16 nStart, sal_uInt16 nEnd) 746 { 747 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr(); 748 sal_uInt16 nCount = pSh->GetRedlineCount(); 749 750 SvLBoxEntryArr aLBoxArr; 751 752 // Wegen Bug der TLB, die bei Remove den SelectHandler IMMER ruft: 753 pTable->SetSelectHdl(aOldSelectHdl); 754 pTable->SetDeselectHdl(aOldDeselectHdl); 755 sal_Bool bChildsRemoved = sal_False; 756 pTable->SelectAll(sal_False); 757 758 // Hinter dem letzten Eintrag Cursor setzen, da sonst Performance-Problem in TLB. 759 // TLB wuerde sonst bei jedem Remove den Cursor erneut umsetzen (teuer) 760 sal_uInt16 nPos = Min((sal_uInt16)nCount, (sal_uInt16)aRedlineParents.Count()); 761 SvLBoxEntry *pCurEntry = NULL; 762 while( ( pCurEntry == NULL ) && ( nPos > 0 ) ) 763 { 764 --nPos; 765 pCurEntry = aRedlineParents[nPos]->pTLBParent; 766 } 767 768 if (pCurEntry) 769 pTable->SetCurEntry(pCurEntry); 770 771 SvLBoxTreeList* pModel = pTable->GetModel(); 772 773 for (sal_uInt16 i = nStart; i <= nEnd; i++) 774 { 775 if (!bChildsRemoved && aRedlineParents[i]->pNext) 776 { 777 SwRedlineDataChildPtr pChildPtr = (SwRedlineDataChildPtr)aRedlineParents[i]->pNext; 778 sal_uInt16 nChildPos = aRedlineChilds.GetPos(pChildPtr); 779 780 if (nChildPos != USHRT_MAX) 781 { 782 sal_uInt16 nChilds = 0; 783 784 while (pChildPtr) 785 { 786 pChildPtr = (SwRedlineDataChildPtr)pChildPtr->pNext; 787 nChilds++; 788 } 789 790 aRedlineChilds.DeleteAndDestroy(nChildPos, nChilds); 791 bChildsRemoved = sal_True; 792 } 793 } 794 SvLBoxEntry *pEntry = aRedlineParents[i]->pTLBParent; 795 if (pEntry) 796 { 797 long nIdx = aLBoxArr.Count() - 1L; 798 sal_uLong nAbsPos = pModel->GetAbsPos(pEntry); 799 while (nIdx >= 0 && 800 pModel->GetAbsPos(aLBoxArr[ static_cast< sal_uInt16 >(nIdx) ]) > nAbsPos) 801 nIdx--; 802 aLBoxArr.Insert( pEntry, static_cast< sal_uInt16 >(++nIdx) ); 803 } 804 } 805 806 // TLB von hinten abraeumen 807 long nIdx = (long)aLBoxArr.Count() - 1L; 808 while (nIdx >= 0) 809 pTable->RemoveEntry(aLBoxArr[ static_cast< sal_uInt16 >(nIdx--) ]); 810 811 pTable->SetSelectHdl(LINK(this, SwRedlineAcceptDlg, SelectHdl)); 812 pTable->SetDeselectHdl(LINK(this, SwRedlineAcceptDlg, DeselectHdl)); 813 // Durch Remove wurde leider wieder dauernd von der TLB selektiert... 814 pTable->SelectAll(sal_False); 815 816 aRedlineParents.DeleteAndDestroy( nStart, nEnd - nStart + 1); 817 } 818 819 /* -----------------05.06.98 15:20------------------- 820 * 821 * --------------------------------------------------*/ 822 823 void SwRedlineAcceptDlg::InsertParents(sal_uInt16 nStart, sal_uInt16 nEnd) 824 { 825 SwView *pView = ::GetActiveView(); 826 SwWrtShell* pSh = pView->GetWrtShellPtr(); 827 sal_uInt16 nAutoFmt = HasRedlineAutoFmt() ? nsRedlineType_t::REDLINE_FORM_AUTOFMT : 0; 828 829 String sParent; 830 sal_uInt16 nCount = pSh->GetRedlineCount(); 831 nEnd = Min((sal_uInt16)nEnd, (sal_uInt16)(nCount - 1)); // Handelt auch nEnd=USHRT_MAX (bis zum Ende) ab 832 833 if (nEnd == USHRT_MAX) 834 return; // Keine Redlines im Dokument 835 836 RedlinData *pData; 837 SvLBoxEntry *pParent; 838 SwRedlineDataParentPtr pRedlineParent; 839 const SwRedline* pCurrRedline; 840 if( !nStart && !pTable->FirstSelected() ) 841 { 842 pCurrRedline = pSh->GetCurrRedline(); 843 if( !pCurrRedline ) 844 { 845 pSh->SwCrsrShell::Push(); 846 if( 0 == (pCurrRedline = pSh->SelNextRedline())) 847 pCurrRedline = pSh->SelPrevRedline(); 848 pSh->SwCrsrShell::Pop( sal_False ); 849 } 850 } 851 else 852 pCurrRedline = 0; 853 854 for (sal_uInt16 i = nStart; i <= nEnd; i++) 855 { 856 const SwRedline& rRedln = pSh->GetRedline(i); 857 const SwRedlineData *pRedlineData = &rRedln.GetRedlineData(); 858 859 pRedlineParent = new SwRedlineDataParent; 860 pRedlineParent->pData = pRedlineData; 861 pRedlineParent->pNext = 0; 862 String sComment(rRedln.GetComment()); 863 sComment.SearchAndReplaceAll((sal_Unicode)_LF,(sal_Unicode)' '); 864 pRedlineParent->sComment = sComment; 865 aRedlineParents.Insert(pRedlineParent, i); 866 867 pData = new RedlinData; 868 pData->pData = pRedlineParent; 869 pData->bDisabled = sal_False; 870 871 sParent = GetRedlineText(rRedln, pData->aDateTime); 872 pParent = pTable->InsertEntry(sParent, pData, 0, i); 873 if( pCurrRedline == &rRedln ) 874 { 875 pTable->SetCurEntry( pParent ); 876 pTable->Select( pParent ); 877 pTable->MakeVisible( pParent ); 878 } 879 880 pRedlineParent->pTLBParent = pParent; 881 882 InsertChilds(pRedlineParent, rRedln, nAutoFmt); 883 } 884 } 885 886 /* -----------------05.06.98 13:06------------------- 887 * 888 * --------------------------------------------------*/ 889 890 void SwRedlineAcceptDlg::CallAcceptReject( sal_Bool bSelect, sal_Bool bAccept ) 891 { 892 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr(); 893 SvLBoxEntry* pEntry = bSelect ? pTable->FirstSelected() : pTable->First(); 894 sal_uLong nPos = LONG_MAX; 895 896 typedef std::vector<SvLBoxEntry*> ListBoxEntries_t; 897 ListBoxEntries_t aRedlines; 898 899 // don't activate 900 DBG_ASSERT( bInhibitActivate == false, 901 "recursive call of CallAcceptReject?"); 902 bInhibitActivate = true; 903 904 // collect redlines-to-be-accepted/rejected in aRedlines vector 905 while( pEntry ) 906 { 907 if( !pTable->GetParent( pEntry ) ) 908 { 909 if( bSelect && LONG_MAX == nPos ) 910 nPos = pTable->GetModel()->GetAbsPos( pEntry ); 911 912 RedlinData *pData = (RedlinData *)pEntry->GetUserData(); 913 914 if( !pData->bDisabled ) 915 aRedlines.push_back( pEntry ); 916 } 917 918 pEntry = bSelect ? pTable->NextSelected(pEntry) : pTable->Next(pEntry); 919 } 920 921 sal_Bool (SwEditShell:: *FnAccRej)( sal_uInt16 ) = &SwEditShell::AcceptRedline; 922 if( !bAccept ) 923 FnAccRej = &SwEditShell::RejectRedline; 924 925 SwWait aWait( *pSh->GetView().GetDocShell(), sal_True ); 926 pSh->StartAction(); 927 928 // #111827# 929 if (aRedlines.size() > 1) 930 { 931 String aTmpStr; 932 { 933 SwRewriter aRewriter; 934 aRewriter.AddRule(UNDO_ARG1, 935 String::CreateFromInt32(aRedlines.size())); 936 aTmpStr = aRewriter.Apply(String(SW_RES(STR_N_REDLINES))); 937 } 938 939 SwRewriter aRewriter; 940 aRewriter.AddRule(UNDO_ARG1, aTmpStr); 941 942 pSh->StartUndo(bAccept? UNDO_ACCEPT_REDLINE : UNDO_REJECT_REDLINE, 943 &aRewriter); 944 } 945 946 // accept/reject the the redlines in aRedlines. The absolute 947 // position may change during the process (e.g. when two redlines 948 // are merged in result of another one being deleted), so the 949 // position must be resolved late and checked before using it. 950 // (cf #102547#) 951 ListBoxEntries_t::iterator aEnd = aRedlines.end(); 952 for( ListBoxEntries_t::iterator aIter = aRedlines.begin(); 953 aIter != aEnd; 954 aIter++ ) 955 { 956 sal_uInt16 nPosition = GetRedlinePos( **aIter ); 957 if( nPosition != USHRT_MAX ) 958 (pSh->*FnAccRej)( nPosition ); 959 } 960 961 // #111827# 962 if (aRedlines.size() > 1) 963 { 964 pSh->EndUndo(); 965 } 966 967 pSh->EndAction(); 968 969 bInhibitActivate = false; 970 Activate(); 971 972 if( ULONG_MAX != nPos && pTable->GetEntryCount() ) 973 { 974 if( nPos >= pTable->GetEntryCount() ) 975 nPos = pTable->GetEntryCount() - 1; 976 pEntry = pTable->GetEntry( nPos ); 977 if( !pEntry && nPos-- ) 978 pEntry = pTable->GetEntry( nPos ); 979 if( pEntry ) 980 { 981 pTable->Select( pEntry ); 982 pTable->MakeVisible( pEntry ); 983 pTable->SetCurEntry(pEntry); 984 } 985 } 986 pTPView->EnableUndo(); 987 } 988 989 /*-------------------------------------------------------------------- 990 Beschreibung: 991 --------------------------------------------------------------------*/ 992 993 sal_uInt16 SwRedlineAcceptDlg::GetRedlinePos( const SvLBoxEntry& rEntry ) const 994 { 995 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr(); 996 return pSh->FindRedlineOfData( *((SwRedlineDataParent*)((RedlinData *) 997 rEntry.GetUserData())->pData)->pData ); 998 } 999 1000 /*-------------------------------------------------------------------- 1001 Beschreibung: 1002 --------------------------------------------------------------------*/ 1003 1004 IMPL_LINK( SwRedlineAcceptDlg, AcceptHdl, void*, EMPTYARG) 1005 { 1006 CallAcceptReject( sal_True, sal_True ); 1007 return 0; 1008 } 1009 1010 /*-------------------------------------------------------------------- 1011 Beschreibung: 1012 --------------------------------------------------------------------*/ 1013 1014 IMPL_LINK( SwRedlineAcceptDlg, AcceptAllHdl, void*, EMPTYARG ) 1015 { 1016 CallAcceptReject( sal_False, sal_True ); 1017 return 0; 1018 } 1019 1020 /*-------------------------------------------------------------------- 1021 Beschreibung: 1022 --------------------------------------------------------------------*/ 1023 1024 IMPL_LINK( SwRedlineAcceptDlg, RejectHdl, void*, EMPTYARG ) 1025 { 1026 CallAcceptReject( sal_True, sal_False ); 1027 return 0; 1028 } 1029 1030 /*-------------------------------------------------------------------- 1031 Beschreibung: 1032 --------------------------------------------------------------------*/ 1033 1034 IMPL_LINK( SwRedlineAcceptDlg, RejectAllHdl, void*, EMPTYARG ) 1035 { 1036 CallAcceptReject( sal_False, sal_False ); 1037 return 0; 1038 } 1039 1040 /*-------------------------------------------------------------------- 1041 Beschreibung: 1042 --------------------------------------------------------------------*/ 1043 1044 IMPL_LINK( SwRedlineAcceptDlg, UndoHdl, void*, EMPTYARG ) 1045 { 1046 SwView * pView = ::GetActiveView(); 1047 pView->GetViewFrame()->GetDispatcher()-> 1048 Execute(SID_UNDO, SFX_CALLMODE_SYNCHRON); 1049 pTPView->EnableUndo(pView->GetSlotState(SID_UNDO) != 0); 1050 1051 Activate(); 1052 1053 return 0; 1054 } 1055 1056 /*-------------------------------------------------------------------- 1057 Beschreibung: 1058 --------------------------------------------------------------------*/ 1059 1060 IMPL_LINK( SwRedlineAcceptDlg, FilterChangedHdl, void*, EMPTYARG ) 1061 { 1062 SvxTPFilter *pFilterTP = aTabPagesCTRL.GetFilterPage(); 1063 1064 if (pFilterTP->IsAction()) 1065 sFilterAction = pFilterTP->GetLbAction()->GetSelectEntry(); 1066 else 1067 sFilterAction = aEmptyStr; 1068 1069 Init(); 1070 1071 return 0; 1072 } 1073 1074 /*-------------------------------------------------------------------- 1075 Beschreibung: 1076 --------------------------------------------------------------------*/ 1077 1078 IMPL_LINK( SwRedlineAcceptDlg, DeselectHdl, void*, EMPTYARG ) 1079 { 1080 // Flackern der Buttons vermeiden: 1081 aDeselectTimer.Start(); 1082 1083 return 0; 1084 } 1085 1086 /*-------------------------------------------------------------------- 1087 Beschreibung: 1088 --------------------------------------------------------------------*/ 1089 1090 IMPL_LINK( SwRedlineAcceptDlg, SelectHdl, void*, EMPTYARG ) 1091 { 1092 aDeselectTimer.Stop(); 1093 aSelectTimer.Start(); 1094 1095 return 0; 1096 } 1097 1098 /*-------------------------------------------------------------------- 1099 Beschreibung: 1100 --------------------------------------------------------------------*/ 1101 1102 IMPL_LINK( SwRedlineAcceptDlg, GotoHdl, void*, EMPTYARG ) 1103 { 1104 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr(); 1105 aSelectTimer.Stop(); 1106 1107 sal_Bool bIsNotFormated = sal_False; 1108 sal_Bool bSel = sal_False; 1109 // sal_Bool bReadonlySel = sal_False; 1110 1111 //#98883# don't select redlines while the dialog is not focussed 1112 //#107938# But not only ask pTable if it has the focus. To move 1113 // the selection to the selected redline any child of pParentDlg 1114 // may the focus. 1115 SvLBoxEntry* pSelEntry = 0; 1116 1117 if (pParentDlg->HasChildPathFocus()) 1118 pSelEntry = pTable->FirstSelected(); 1119 1120 if( pSelEntry ) 1121 { 1122 SvLBoxEntry* pActEntry = pSelEntry; 1123 pSh->StartAction(); 1124 pSh->EnterStdMode(); 1125 pSh->SetCareWin(pParentDlg); 1126 1127 while (pSelEntry) 1128 { 1129 if (pTable->GetParent(pSelEntry)) 1130 { 1131 pActEntry = pTable->GetParent(pSelEntry); 1132 1133 if (pTable->IsSelected(pActEntry)) 1134 { 1135 pSelEntry = pActEntry = pTable->NextSelected(pSelEntry); 1136 continue; // Nicht zweimal selektieren 1137 } 1138 } 1139 else 1140 bSel = sal_True; 1141 1142 // #98864# find the selected redline (ignore, if the redline is already gone) 1143 sal_uInt16 nPos = GetRedlinePos(*pActEntry); 1144 if( nPos != USHRT_MAX ) 1145 { 1146 1147 const SwRedline& rRedln = pSh->GetRedline( nPos ); 1148 bIsNotFormated |= nsRedlineType_t::REDLINE_FORMAT != rRedln.GetType(); 1149 1150 //JP 27.9.2001: make no sense if we handle readonly sections 1151 // if( !bReadonlySel && rRedln.HasReadonlySel() ) 1152 // bReadonlySel = sal_True; 1153 1154 if (pSh->GotoRedline(nPos, sal_True)) 1155 { 1156 pSh->SetInSelect(); 1157 pSh->EnterAddMode(); 1158 } 1159 } 1160 1161 pSelEntry = pActEntry = pTable->NextSelected(pSelEntry); 1162 } 1163 1164 pSh->LeaveAddMode(); 1165 pSh->EndAction(); 1166 pSh->SetCareWin(NULL); 1167 } 1168 sal_Bool bEnable = !pSh->getIDocumentRedlineAccess()->GetRedlinePassword().getLength(); 1169 pTPView->EnableAccept( bEnable && bSel /*&& !bReadonlySel*/ ); 1170 pTPView->EnableReject( bEnable && bSel && bIsNotFormated /*&& !bReadonlySel*/ ); 1171 pTPView->EnableRejectAll( bEnable && !bOnlyFormatedRedlines && !bHasReadonlySel ); 1172 1173 return 0; 1174 } 1175 1176 /*-------------------------------------------------------------------- 1177 Beschreibung: 1178 --------------------------------------------------------------------*/ 1179 1180 IMPL_LINK( SwRedlineAcceptDlg, CommandHdl, void*, EMPTYARG ) 1181 { 1182 const CommandEvent aCEvt(pTable->GetCommandEvent()); 1183 1184 switch ( aCEvt.GetCommand() ) 1185 { 1186 case COMMAND_CONTEXTMENU: 1187 { 1188 SwWrtShell* pSh = ::GetActiveView()->GetWrtShellPtr(); 1189 SvLBoxEntry* pEntry = pTable->FirstSelected(); 1190 const SwRedline *pRed = 0; 1191 1192 if (pEntry) 1193 { 1194 SvLBoxEntry* pTopEntry = pEntry; 1195 1196 if (pTable->GetParent(pEntry)) 1197 pTopEntry = pTable->GetParent(pEntry); 1198 1199 sal_uInt16 nPos = GetRedlinePos(*pTopEntry); 1200 1201 // Bei geschuetzten Bereichen kommentieren disablen 1202 if ((pRed = pSh->GotoRedline(nPos, sal_True)) != 0) 1203 { 1204 if( pSh->IsCrsrPtAtEnd() ) 1205 pSh->SwapPam(); 1206 pSh->SetInSelect(); 1207 } 1208 } 1209 1210 aPopup.EnableItem( MN_EDIT_COMMENT, pEntry && pRed && 1211 !pTable->GetParent(pEntry) && 1212 !pTable->NextSelected(pEntry) 1213 //JP 27.9.2001: make no sense if we handle readonly sections 1214 // && pRed->HasReadonlySel() 1215 ); 1216 1217 aPopup.EnableItem( MN_SUB_SORT, pTable->First() != 0 ); 1218 sal_uInt16 nColumn = pTable->GetSortedCol(); 1219 if (nColumn == 0xffff) 1220 nColumn = 4; 1221 1222 PopupMenu *pSubMenu = aPopup.GetPopupMenu(MN_SUB_SORT); 1223 if (pSubMenu) 1224 { 1225 for (sal_uInt16 i = MN_SORT_ACTION; i < MN_SORT_ACTION + 5; i++) 1226 pSubMenu->CheckItem(i, sal_False); 1227 1228 pSubMenu->CheckItem(nColumn + MN_SORT_ACTION); 1229 } 1230 1231 sal_uInt16 nRet = aPopup.Execute(pTable, aCEvt.GetMousePosPixel()); 1232 1233 switch( nRet ) 1234 { 1235 case MN_EDIT_COMMENT: 1236 { 1237 String sComment; 1238 if (pEntry) 1239 { 1240 if (pTable->GetParent(pEntry)) 1241 pEntry = pTable->GetParent(pEntry); 1242 1243 sal_uInt16 nPos = GetRedlinePos(*pEntry); 1244 const SwRedline &rRedline = pSh->GetRedline(nPos); 1245 1246 1247 /* enable again once we have redline comments in the margin 1248 sComment = rRedline.GetComment(); 1249 if ( sComment == String(::rtl::OUString::createFromAscii("")) ) 1250 GetActiveView()->GetDocShell()->Broadcast(SwRedlineHint(&rRedline,SWREDLINE_INSERTED)); 1251 const_cast<SwRedline&>(rRedline).Broadcast(SwRedlineHint(&rRedline,SWREDLINE_FOCUS)); 1252 */ 1253 1254 sComment = rRedline.GetComment(); 1255 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 1256 DBG_ASSERT(pFact, "Dialogdiet fail!"); 1257 ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc( RID_SVXDLG_POSTIT ); 1258 DBG_ASSERT(fnGetRange, "Dialogdiet fail! GetRanges()"); 1259 SfxItemSet aSet( pSh->GetAttrPool(), fnGetRange() ); 1260 1261 aSet.Put(SvxPostItTextItem(sComment.ConvertLineEnd(), SID_ATTR_POSTIT_TEXT)); 1262 aSet.Put(SvxPostItAuthorItem(rRedline.GetAuthorString(), SID_ATTR_POSTIT_AUTHOR)); 1263 1264 aSet.Put(SvxPostItDateItem( GetAppLangDateTimeString( 1265 rRedline.GetRedlineData().GetTimeStamp() ), 1266 SID_ATTR_POSTIT_DATE )); 1267 1268 AbstractSvxPostItDialog* pDlg = pFact->CreateSvxPostItDialog( pParentDlg, aSet, sal_False ); 1269 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 1270 1271 pDlg->HideAuthor(); 1272 1273 sal_uInt16 nResId = 0; 1274 switch( rRedline.GetType() ) 1275 { 1276 case nsRedlineType_t::REDLINE_INSERT: 1277 nResId = STR_REDLINE_INSERTED; 1278 break; 1279 case nsRedlineType_t::REDLINE_DELETE: 1280 nResId = STR_REDLINE_DELETED; 1281 break; 1282 case nsRedlineType_t::REDLINE_FORMAT: 1283 nResId = STR_REDLINE_FORMATED; 1284 break; 1285 case nsRedlineType_t::REDLINE_TABLE: 1286 nResId = STR_REDLINE_TABLECHG; 1287 break; 1288 default:;//prevent warning 1289 } 1290 String sTitle(SW_RES(STR_REDLINE_COMMENT)); 1291 if( nResId ) 1292 sTitle += SW_RESSTR( nResId ); 1293 pDlg->SetText(sTitle); 1294 1295 pSh->SetCareWin(pDlg->GetWindow()); 1296 1297 if ( pDlg->Execute() == RET_OK ) 1298 { 1299 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); 1300 String sMsg(((const SvxPostItTextItem&)pOutSet->Get(SID_ATTR_POSTIT_TEXT)).GetValue()); 1301 1302 // Kommentar einfuegen bzw aendern 1303 pSh->SetRedlineComment(sMsg); 1304 sMsg.SearchAndReplaceAll((sal_Unicode)_LF,(sal_Unicode)' '); 1305 pTable->SetEntryText(sMsg, pEntry, 3); 1306 } 1307 1308 delete pDlg; 1309 pSh->SetCareWin(NULL); 1310 } 1311 1312 } 1313 break; 1314 1315 case MN_SORT_ACTION: 1316 case MN_SORT_AUTHOR: 1317 case MN_SORT_DATE: 1318 case MN_SORT_COMMENT: 1319 case MN_SORT_POSITION: 1320 { 1321 bSortDir = sal_True; 1322 if (nRet - MN_SORT_ACTION == 4 && pTable->GetSortedCol() == 0xffff) 1323 break; // Haben wir schon 1324 1325 nSortMode = nRet - MN_SORT_ACTION; 1326 if (nSortMode == 4) 1327 nSortMode = 0xffff; // unsortiert bzw sortiert nach Position 1328 1329 if (pTable->GetSortedCol() == nSortMode) 1330 bSortDir = !pTable->GetSortDirection(); 1331 1332 SwWait aWait( *::GetActiveView()->GetDocShell(), sal_False ); 1333 pTable->SortByCol(nSortMode, bSortDir); 1334 if (nSortMode == 0xffff) 1335 Init(); // Alles neu fuellen 1336 } 1337 break; 1338 } 1339 } 1340 break; 1341 } 1342 1343 return 0; 1344 } 1345 1346 /*-------------------------------------------------------------------- 1347 Beschreibung: 1348 --------------------------------------------------------------------*/ 1349 1350 void SwRedlineAcceptDlg::Initialize(const String& rExtraData) 1351 { 1352 if (rExtraData.Len()) 1353 { 1354 sal_uInt16 nPos = rExtraData.Search(C2S("AcceptChgDat:")); 1355 1356 // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn 1357 // er nicht vorhanden ist, liegt eine "altere Version vor 1358 if (nPos != STRING_NOTFOUND) 1359 { 1360 sal_uInt16 n1 = rExtraData.Search('(', nPos); 1361 if (n1 != STRING_NOTFOUND) 1362 { 1363 sal_uInt16 n2 = rExtraData.Search(')', n1); 1364 if (n2 != STRING_NOTFOUND) 1365 { 1366 // Alignment-String herausschneiden 1367 String aStr = rExtraData.Copy(nPos, n2 - nPos + 1); 1368 aStr.Erase(0, n1 - nPos + 1); 1369 1370 if (aStr.Len()) 1371 { 1372 sal_uInt16 nCount = static_cast< sal_uInt16 >(aStr.ToInt32()); 1373 1374 for (sal_uInt16 i = 0; i < nCount; i++) 1375 { 1376 sal_uInt16 n3 = aStr.Search(';'); 1377 aStr.Erase(0, n3 + 1); 1378 pTable->SetTab(i, aStr.ToInt32(), MAP_PIXEL); 1379 } 1380 } 1381 } 1382 } 1383 } 1384 } 1385 } 1386 1387 /*-------------------------------------------------------------------- 1388 Beschreibung: 1389 --------------------------------------------------------------------*/ 1390 1391 void SwRedlineAcceptDlg::FillInfo(String &rExtraData) const 1392 { 1393 rExtraData.AppendAscii("AcceptChgDat:("); 1394 1395 sal_uInt16 nCount = pTable->TabCount(); 1396 1397 rExtraData += String::CreateFromInt32(nCount); 1398 rExtraData += ';'; 1399 for(sal_uInt16 i = 0; i < nCount; i++) 1400 { 1401 rExtraData += String::CreateFromInt32( pTable->GetTab(i) ); 1402 rExtraData += ';'; 1403 } 1404 rExtraData += ')'; 1405 } 1406