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 #define ROLBCK_HISTORY_ONLY // Der Kampf gegen die CLOOK's 31 #include <doc.hxx> 32 #include <dcontact.hxx> 33 #include <com/sun/star/document/PrinterIndependentLayout.hpp> 34 #include <com/sun/star/document/UpdateDocMode.hpp> 35 #include <com/sun/star/text/XTextDocument.hpp> 36 #include <com/sun/star/linguistic2/XProofreadingIterator.hpp> 37 #include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp> 38 39 #include <unotools/processfactory.hxx> 40 #include <vcl/svapp.hxx> 41 #include <vcl/virdev.hxx> 42 #include <rtl/logfile.hxx> 43 #include <sfx2/printer.hxx> 44 #include <sfx2/docfile.hxx> 45 #include <sfx2/frame.hxx> 46 #include <sfx2/viewfrm.hxx> 47 48 #include <svl/macitem.hxx> 49 #include <svx/svxids.hrc> 50 #include <svx/svdogrp.hxx> 51 #include <sfx2/linkmgr.hxx> 52 #include <editeng/forbiddencharacterstable.hxx> 53 #include <svl/zforlist.hxx> 54 #include <unotools/compatibility.hxx> 55 #include <unotools/lingucfg.hxx> 56 #include <svx/svdpage.hxx> 57 #include <paratr.hxx> 58 #include <fchrfmt.hxx> 59 #include <fmtcntnt.hxx> 60 #include <fmtanchr.hxx> 61 #include <fmtfsize.hxx> 62 #include <fmtfordr.hxx> 63 #include <fmtpdsc.hxx> 64 #include <pvprtdat.hxx> 65 #include <rootfrm.hxx> //Damit der RootDtor gerufen wird. 66 #include <layouter.hxx> 67 #include <pagedesc.hxx> //Damit die PageDescs zerstoert werden koennen. 68 #include <ndtxt.hxx> 69 #include <printdata.hxx> 70 #include <docfld.hxx> 71 #include <ftninfo.hxx> 72 #include <ftnidx.hxx> 73 #include <docstat.hxx> 74 #include <charfmt.hxx> 75 #include <frmfmt.hxx> 76 #include <rolbck.hxx> // Undo-Attr, SwHistory 77 #include <poolfmt.hxx> // fuer die Pool-Vorlage 78 #include <dbmgr.hxx> 79 #include <docsh.hxx> 80 #include <acorrect.hxx> // fuer die autom. Aufnahme von Ausnahmen 81 #include <visiturl.hxx> // fuer die URL-Change Benachrichtigung 82 #include <docary.hxx> 83 #include <lineinfo.hxx> 84 #include <drawdoc.hxx> 85 #include <linkenum.hxx> 86 #include <fldupde.hxx> 87 #include <extinput.hxx> 88 #include <viewsh.hxx> 89 #include <doctxm.hxx> 90 #include <shellres.hxx> 91 #include <breakit.hxx> 92 #include <laycache.hxx> 93 #include <mvsave.hxx> 94 #include <istyleaccess.hxx> 95 #include <swstylemanager.hxx> 96 #include <IGrammarContact.hxx> 97 #include <tblsel.hxx> 98 #include <MarkManager.hxx> 99 #include <UndoManager.hxx> 100 #include <unochart.hxx> 101 102 #include <cmdid.h> // fuer den dflt - Printer in SetJob 103 104 105 // --> OD 2006-04-19 #b6375613# 106 #include <com/sun/star/document/XDocumentInfoSupplier.hpp> 107 #include <com/sun/star/beans/XPropertyContainer.hpp> 108 #include <com/sun/star/beans/PropertyAttribute.hpp> 109 110 // <-- 111 112 // --> OD 2007-03-16 #i73788# 113 #include <pausethreadstarting.hxx> 114 // <-- 115 #include <numrule.hxx> 116 // --> OD 2008-03-13 #refactorlists# 117 #include <list.hxx> 118 #include <listfunc.hxx> 119 // <-- 120 121 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> 122 123 #include <sfx2/Metadatable.hxx> 124 #include <fmtmeta.hxx> // MetaFieldManager 125 126 127 using namespace ::com::sun::star; 128 using namespace ::com::sun::star::document; 129 130 const sal_Char __FAR_DATA sFrmFmtStr[] = "Frameformat"; 131 const sal_Char __FAR_DATA sEmptyPageStr[] = "Empty Page"; 132 const sal_Char __FAR_DATA sColumnCntStr[] = "Columncontainer"; 133 const sal_Char __FAR_DATA sCharFmtStr[] = "Zeichenformat"; 134 const sal_Char __FAR_DATA sTxtCollStr[] = "Textformatvorlage"; 135 const sal_Char __FAR_DATA sGrfCollStr[] = "Graphikformatvorlage"; 136 137 SV_IMPL_PTRARR( SwNumRuleTbl, SwNumRulePtr) 138 SV_IMPL_PTRARR( SwTxtFmtColls, SwTxtFmtCollPtr) 139 SV_IMPL_PTRARR( SwGrfFmtColls, SwGrfFmtCollPtr) 140 141 /* 142 * global functions... 143 */ 144 145 uno::Reference< linguistic2::XProofreadingIterator > SwDoc::GetGCIterator() const 146 { 147 if (!m_xGCIterator.is() && SvtLinguConfig().HasGrammarChecker()) 148 { 149 uno::Reference< lang::XMultiServiceFactory > xMgr( utl::getProcessServiceFactory() ); 150 if (xMgr.is()) 151 { 152 try 153 { 154 rtl::OUString aServiceName( rtl::OUString::createFromAscii("com.sun.star.linguistic2.ProofreadingIterator") ); 155 m_xGCIterator = uno::Reference< linguistic2::XProofreadingIterator > 156 ( xMgr->createInstance( aServiceName ), uno::UNO_QUERY_THROW ); 157 } 158 catch (uno::Exception &) 159 { 160 DBG_ERROR( "No GCIterator" ); 161 } 162 } 163 } 164 165 return m_xGCIterator; 166 } 167 168 void StartGrammarChecking( SwDoc &rDoc ) 169 { 170 // check for a visible view 171 bool bVisible = false; 172 const SwDocShell *pDocShell = rDoc.GetDocShell(); 173 SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, sal_False ); 174 while (pFrame && !bVisible) 175 { 176 if (pFrame->IsVisible()) 177 bVisible = true; 178 pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, sal_False ); 179 } 180 181 //!! only documents with visible views need to be checked 182 //!! (E.g. don't check temporary documents created for printing, see printing of notes and selections. 183 //!! Those get created on the fly and get hard deleted a bit later as well, and no one should have 184 //!! a uno reference to them) 185 if (bVisible) 186 { 187 uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( rDoc.GetGCIterator() ); 188 if ( xGCIterator.is() ) 189 { 190 uno::Reference< lang::XComponent > xDoc( rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY ); 191 uno::Reference< text::XFlatParagraphIteratorProvider > xFPIP( xDoc, uno::UNO_QUERY ); 192 193 // start automatic background checking if not active already 194 if ( xFPIP.is() && !xGCIterator->isProofreading( xDoc ) ) 195 xGCIterator->startProofreading( xDoc, xFPIP ); 196 } 197 } 198 } 199 200 /* 201 * interne Funktionen 202 */ 203 204 205 206 sal_Bool lcl_DelFmtIndizes( const SwFrmFmtPtr& rpFmt, void* ) 207 { 208 SwFmtCntnt &rFmtCntnt = (SwFmtCntnt&)rpFmt->GetCntnt(); 209 if ( rFmtCntnt.GetCntntIdx() ) 210 rFmtCntnt.SetNewCntntIdx( 0 ); 211 SwFmtAnchor &rFmtAnchor = (SwFmtAnchor&)rpFmt->GetAnchor(); 212 if ( rFmtAnchor.GetCntntAnchor() ) 213 rFmtAnchor.SetAnchor( 0 ); 214 return sal_True; 215 } 216 217 /* 218 * exportierte Methoden 219 */ 220 221 SwDoc::SwDoc() 222 : m_pNodes( new SwNodes(this) ) 223 , 224 mpAttrPool(new SwAttrPool(this)), 225 pMarkManager(new ::sw::mark::MarkManager(*this)), 226 m_pMetaFieldManager(new ::sw::MetaFieldManager()), 227 m_pUndoManager(new ::sw::UndoManager( 228 ::std::auto_ptr<SwNodes>(new SwNodes(this)), *this, *this, *this)), 229 pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ), 230 pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ), 231 pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ), 232 pDfltCharFmt( new SwCharFmt( GetAttrPool(), sCharFmtStr, 0 ) ), 233 pDfltTxtFmtColl( new SwTxtFmtColl( GetAttrPool(), sTxtCollStr ) ), 234 pDfltGrfFmtColl( new SwGrfFmtColl( GetAttrPool(), sGrfCollStr ) ), 235 pFrmFmtTbl( new SwFrmFmts() ), 236 pCharFmtTbl( new SwCharFmts() ), 237 pSpzFrmFmtTbl( new SwSpzFrmFmts() ), 238 pSectionFmtTbl( new SwSectionFmts() ), 239 pTblFrmFmtTbl( new SwFrmFmts() ), 240 pTxtFmtCollTbl( new SwTxtFmtColls() ), 241 pGrfFmtCollTbl( new SwGrfFmtColls() ), 242 pTOXTypes( new SwTOXTypes() ), 243 pDefTOXBases( new SwDefTOXBase_Impl() ), 244 pCurrentView( 0 ), //swmod 071225 245 pDrawModel( 0 ), 246 pUpdtFlds( new SwDocUpdtFld() ), 247 pFldTypes( new SwFldTypes() ), 248 pVirDev( 0 ), 249 pPrt( 0 ), 250 pPrtData( 0 ), 251 pGlossaryDoc( 0 ), 252 pOutlineRule( 0 ), 253 pFtnInfo( new SwFtnInfo ), 254 pEndNoteInfo( new SwEndNoteInfo ), 255 pLineNumberInfo( new SwLineNumberInfo ), 256 pFtnIdxs( new SwFtnIdxs ), 257 pDocStat( new SwDocStat ), 258 pDocShell( 0 ), 259 pLinkMgr( new sfx2::LinkManager( 0 ) ), 260 pACEWord( 0 ), 261 pURLStateChgd( 0 ), 262 pNumberFormatter( 0 ), 263 pNumRuleTbl( new SwNumRuleTbl ), 264 // --> OD 2008-03-26 #refactorlists# 265 maLists(), 266 maListStyleLists(), 267 // <-- 268 pRedlineTbl( new SwRedlineTbl ), 269 pAutoFmtRedlnComment( 0 ), 270 pUnoCrsrTbl( new SwUnoCrsrTbl( 0, 16 ) ), 271 pPgPViewPrtData( 0 ), 272 pExtInputRing( 0 ), 273 pLayouter( 0 ), 274 // --> OD 2008-03-07 #refactorlists# 275 pStyleAccess( 0 ), 276 // <-- 277 pLayoutCache( 0 ), 278 pUnoCallBack(new SwModify(0)), 279 mpGrammarContact( 0 ), 280 aChartDataProviderImplRef(), 281 pChartControllerHelper( 0 ), 282 // --> OD 2007-10-31 #i83479# 283 mpListItemsList( new tImplSortedNodeNumList() ), 284 // <-- 285 m_pXmlIdRegistry(), 286 nAutoFmtRedlnCommentNo( 0 ), 287 nLinkUpdMode( GLOBALSETTING ), 288 eFldUpdMode( AUTOUPD_GLOBALSETTING ), 289 eRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)), 290 eChrCmprType( CHARCOMPRESS_NONE ), 291 mReferenceCount(0), 292 mIdleBlockCount(0), 293 nLockExpFld( 0 ), 294 mbReadlineChecked(false), 295 // --> OD 2005-02-11 #i38810# 296 mbLinksUpdated( sal_False ), 297 mbClipBoard( false ), 298 mbColumnSelection( false ), 299 // i#78591# 300 mbProtectForm(false), 301 mbLastBrowseMode( false ), 302 n32DummyCompatabilityOptions1(0), 303 n32DummyCompatabilityOptions2(0), 304 mbStartIdleTimer(sal_False), 305 mbSetDrawDefaults(false) 306 { 307 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDoc::SwDoc" ); 308 309 mbGlossDoc = 310 mbModified = 311 mbDtor = 312 mbPageNums = 313 mbLoaded = 314 mbUpdateExpFld = 315 mbNewDoc = 316 mbCopyIsMove = 317 mbInReading = 318 mbInXMLImport = 319 mbUpdateTOX = 320 mbInLoadAsynchron = 321 mbHTMLMode = 322 mbInCallModified = 323 mbIsGlobalDoc = 324 mbGlblDocSaveLinks = 325 mbIsLabelDoc = 326 mbIsAutoFmtRedline = 327 mbOLEPrtNotifyPending = 328 mbAllOLENotify = 329 mbIsRedlineMove = 330 mbInsOnlyTxtGlssry = 331 mbContains_MSVBasic = 332 mbKernAsianPunctuation = 333 #ifdef DBG_UTIL 334 mbXMLExport = 335 #endif 336 // --> OD 2006-03-21 #b6375613# 337 mbApplyWorkaroundForB6375613 = 338 // <-- 339 false; 340 341 mbNewFldLst = 342 mbVisibleLinks = 343 mbPurgeOLE = 344 true; 345 346 // 347 // COMPATIBILITY FLAGS START 348 // 349 350 // Note: Any non-hidden compatibility flag should obtain its default 351 // by asking SvtCompatibilityOptions, see below. 352 // 353 const SvtCompatibilityOptions aOptions; 354 mbParaSpaceMax = aOptions.IsAddSpacing(); 355 mbParaSpaceMaxAtPages = aOptions.IsAddSpacingAtPages(); 356 mbTabCompat = !aOptions.IsUseOurTabStops(); 357 mbUseVirtualDevice = !aOptions.IsUsePrtDevice(); 358 mbAddExternalLeading = !aOptions.IsNoExtLeading(); 359 mbOldLineSpacing = aOptions.IsUseLineSpacing(); 360 mbAddParaSpacingToTableCells = aOptions.IsAddTableSpacing(); 361 mbUseFormerObjectPos = aOptions.IsUseObjectPositioning(); 362 mbUseFormerTextWrapping = aOptions.IsUseOurTextWrapping(); 363 mbConsiderWrapOnObjPos = aOptions.IsConsiderWrappingStyle(); 364 mbMathBaselineAlignment = false; // default for *old* documents is 'off' 365 mbAddFlyOffsets = false; // hidden 366 mbOldNumbering = false; // hidden 367 mbUseHiResolutionVirtualDevice = true; // hidden 368 mbIgnoreFirstLineIndentInNumbering = false; // hidden 369 mbDoNotJustifyLinesWithManualBreak = !aOptions.IsExpandWordSpace(); 370 mbDoNotResetParaAttrsForNumFont = false; // hidden 371 mbOutlineLevelYieldsOutlineRule = false; // hidden 372 mbTableRowKeep = false; // hidden 373 mbIgnoreTabsAndBlanksForLineCalculation = false; // hidden 374 mbDoNotCaptureDrawObjsOnPage = false; // hidden 375 mbClipAsCharacterAnchoredWriterFlyFrames= false; // hidden 376 mbUnixForceZeroExtLeading = false; // hidden 377 mbOldPrinterMetrics = false; // hidden 378 mbTabRelativeToIndent = true; // hidden 379 // --> OD 2008-06-05 #i89181# 380 mbTabAtLeftIndentForParagraphsInList = false; // hidden 381 // <-- 382 383 // 384 // COMPATIBILITY FLAGS END 385 // 386 387 pMacroTable = new SvxMacroTableDtor; 388 389 mpGrammarContact = ::createGrammarContact(); 390 391 /* 392 * Defaultformate und DefaultFormatsammlungen (FmtColl) 393 * werden an der Position 0 in das jeweilige Array eingetragen. 394 * Die Formate der FmtColls sind von den Defaultformaten 395 * abgeleitet und stehen auch in der Liste. 396 */ 397 /* Formate */ 398 pFrmFmtTbl->Insert(pDfltFrmFmt, 0 ); 399 pCharFmtTbl->Insert(pDfltCharFmt, 0 ); 400 401 /* FmtColls */ 402 // TXT 403 pTxtFmtCollTbl->Insert(pDfltTxtFmtColl, 0 ); 404 // GRF 405 pGrfFmtCollTbl->Insert(pDfltGrfFmtColl, 0 ); 406 407 // PageDesc, EmptyPageFmt und ColumnFmt anlegen 408 if ( !aPageDescs.Count() ) 409 GetPageDescFromPool( RES_POOLPAGE_STANDARD ); 410 411 //Leere Seite Einstellen. 412 pEmptyPageFmt->SetFmtAttr( SwFmtFrmSize( ATT_FIX_SIZE ) ); 413 //BodyFmt fuer Spalten Einstellen. 414 pColumnContFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ) ); 415 416 _InitFieldTypes(); 417 418 // lege (fuer die Filter) eine Default-OutlineNumRule an 419 // --> OD 2008-02-11 #newlistlevelattrs# 420 pOutlineRule = new SwNumRule( String::CreateFromAscii( SwNumRule::GetOutlineRuleName() ), 421 // --> OD 2008-06-06 #i89178# 422 numfunc::GetDefaultPositionAndSpaceMode(), 423 // <-- 424 OUTLINE_RULE ); 425 // <-- 426 // #115901# 427 AddNumRule(pOutlineRule); 428 // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()> 429 pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) ); 430 // <-- 431 432 new SwTxtNode( 433 SwNodeIndex(GetUndoManager().GetUndoNodes().GetEndOfContent()), 434 pDfltTxtFmtColl ); 435 new SwTxtNode( SwNodeIndex( GetNodes().GetEndOfContent() ), 436 GetTxtCollFromPool( RES_POOLCOLL_STANDARD )); 437 438 // den eigenen IdleTimer setzen 439 aIdleTimer.SetTimeout( 600 ); 440 aIdleTimer.SetTimeoutHdl( LINK(this, SwDoc, DoIdleJobs) ); 441 442 aOLEModifiedTimer.SetTimeout( 1000 ); 443 aOLEModifiedTimer.SetTimeoutHdl( LINK( this, SwDoc, DoUpdateModifiedOLE )); 444 445 // DBMgr anlegen 446 pNewDBMgr = new SwNewDBMgr; 447 448 // create TOXTypes 449 InitTOXTypes(); 450 451 // --> OD 2008-03-07 #refactorlists# 452 // pass empty item set containing the paragraph's list attributes 453 // as ignorable items to the stype manager. 454 { 455 SfxItemSet aIgnorableParagraphItems( GetAttrPool(), 456 RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, 457 0 ); 458 pStyleAccess = createStyleManager( &aIgnorableParagraphItems ); 459 } 460 // <-- 461 462 ResetModified(); 463 } 464 465 /* 466 * Besonderheiten: an der Position 0 des Arrays der Formate und 467 * der GDI-Objekte befindet sich ein Member der Klasse SwDoc. 468 * Dieser darf also keinesfalls durch delete geloescht 469 * werden!!!!!!!!!! 470 */ 471 472 473 SwDoc::~SwDoc() 474 { 475 // nothing here should create Undo actions! 476 GetIDocumentUndoRedo().DoUndo(false); 477 478 if (pDocShell) 479 { 480 pDocShell->SetUndoManager(0); 481 } 482 483 // --> OD 2007-03-16 #i73788# 484 SwPauseThreadStarting aPauseThreadStarting; 485 // <-- 486 487 // --> OD 2007-11-01 #i83479# 488 delete mpListItemsList; 489 mpListItemsList = 0; 490 // <-- 491 492 // clean up chart related structures... 493 // Note: the chart data provider gets already diposed in ~SwDocShell 494 // since all UNO API related functionality requires an existing SwDocShell 495 // this assures that dipose gets called if there is need for it. 496 aChartDataProviderImplRef.reset(); 497 delete pChartControllerHelper; 498 499 delete mpGrammarContact; 500 mpGrammarContact = 0; 501 502 //!! needs to be done to destroy a possible SwFmtDrop format that may 503 //!! be connected to a char format which may not otherwise be removed 504 //!! and thus would leave a unremoved SwFmt object. (TL) 505 //!! (this is case is not possible via UI but via API...) 506 SwFmtDrop aDrop; 507 SetDefault(aDrop); 508 //!! same for SwFmtCharFmt 509 SwFmtCharFmt aCharFmt(NULL); 510 SetDefault(aCharFmt); 511 512 StopIdling(); // stop idle timer 513 514 delete pUnoCallBack, pUnoCallBack = 0; 515 delete pURLStateChgd; 516 517 delete pLayouter; 518 // --> OD 2005-09-05 #125370# 519 pLayouter = 0L; 520 // <-- 521 522 // Undo-Benachrichtigung vom Draw abschalten 523 if( pDrawModel ) 524 { 525 DrawNotifyUndoHdl(); 526 ClrContourCache(); 527 } 528 529 delete pPgPViewPrtData; 530 531 mbDtor = sal_True; 532 533 delete pRedlineTbl; 534 delete pUnoCrsrTbl; 535 delete pAutoFmtRedlnComment; 536 537 if( pUpdtFlds ) 538 delete pUpdtFlds; 539 540 if( pACEWord ) 541 delete pACEWord; 542 543 // die BaseLinks freigeben. 544 { 545 for( sal_uInt16 n = pLinkMgr->GetServers().Count(); n; ) 546 pLinkMgr->GetServers()[ --n ]->Closed(); 547 548 if( pLinkMgr->GetLinks().Count() ) 549 pLinkMgr->Remove( 0, pLinkMgr->GetLinks().Count() ); 550 } 551 552 // die KapitelNummern / Nummern muessen vor den Vorlage geloescht werden 553 // ansonsten wird noch staendig geupdatet !!! 554 m_pNodes->pOutlineNds->Remove(sal_uInt16(0), m_pNodes->pOutlineNds->Count()); 555 SwNodes & rUndoNodes( GetUndoManager().GetUndoNodes() ); 556 rUndoNodes.pOutlineNds->Remove(sal_uInt16(0), rUndoNodes.pOutlineNds->Count()); 557 558 pFtnIdxs->Remove( sal_uInt16(0), pFtnIdxs->Count() ); 559 560 // indices could be registered in attributes 561 m_pUndoManager->DelAllUndoObj(); 562 563 // in den BookMarks sind Indizies auf den Content. Diese muessen vorm 564 // loesche der Nodes geloescht werden. 565 pMarkManager->clearAllMarks(); 566 DELETEZ( pMacroTable ); 567 568 if( pExtInputRing ) 569 { 570 Ring* pTmp = pExtInputRing; 571 pExtInputRing = 0; 572 while( pTmp->GetNext() != pTmp ) 573 delete pTmp->GetNext(); 574 delete pTmp; 575 } 576 577 //JP: alt - loeschen ohne Flag ist teuer; Modify wird verschickt! 578 // aTOXTypes.DeleteAndDestroy( 0, aTOXTypes.Count() ); 579 { 580 for( sal_uInt16 n = pTOXTypes->Count(); n; ) 581 { 582 (*pTOXTypes)[ --n ]->SetInDocDTOR(); 583 delete (*pTOXTypes)[ n ]; 584 } 585 pTOXTypes->Remove( 0, pTOXTypes->Count() ); 586 } 587 delete pDefTOXBases; 588 589 //Im einen oder anderen FrmFormat koennen noch Indizes angemeldet sein, 590 //Diese muessen spaetestens jetzt zerstoert werden. 591 pFrmFmtTbl->ForEach( &lcl_DelFmtIndizes, this ); 592 pSpzFrmFmtTbl->ForEach( &lcl_DelFmtIndizes, this ); 593 ((SwFrmFmts&)*pSectionFmtTbl).ForEach( &lcl_DelFmtIndizes, this ); 594 595 //Die Formate, die hier hinter stehen sind von den DefaultFormaten 596 //abhaengig. Erst nach dem Loeschen der FmtIndizes weil der Inhalt von 597 //Kopf-/Fussbereichen geloescht wird. Wenn dort noch Indizes von Flys 598 //angemeldet sind gibts was an die Ohren. 599 aPageDescs.DeleteAndDestroy( 0, aPageDescs.Count() ); 600 601 // Inhaltssections loeschen 602 // nicht erst durch den SwNodes-DTOR, damit Formate 603 // keine Abhaengigen mehr haben. 604 m_pNodes->DelNodes( SwNodeIndex(*m_pNodes), m_pNodes->Count() ); 605 rUndoNodes.DelNodes( SwNodeIndex( rUndoNodes ), rUndoNodes.Count() ); 606 607 // Formate loeschen, spaeter mal permanent machen. 608 609 // Delete fuer Collections 610 // damit die Abhaengigen wech sind 611 pFtnInfo->ReleaseCollection(); 612 pEndNoteInfo->ReleaseCollection(); 613 614 ASSERT( pDfltTxtFmtColl == (*pTxtFmtCollTbl)[0], 615 "Default-Text-Collection muss immer am Anfang stehen" ); 616 617 // JP 27.01.98: opt.: ausgehend davon, das Standard als 2. im Array 618 // steht, sollte das als letztes geloescht werden, damit 619 // die ganze Umhaengerei der Formate vermieden wird! 620 if( 2 < pTxtFmtCollTbl->Count() ) 621 pTxtFmtCollTbl->DeleteAndDestroy( 2, pTxtFmtCollTbl->Count()-2 ); 622 pTxtFmtCollTbl->DeleteAndDestroy( 1, pTxtFmtCollTbl->Count()-1 ); 623 delete pTxtFmtCollTbl; 624 625 ASSERT( pDfltGrfFmtColl == (*pGrfFmtCollTbl)[0], 626 "Default-Grf-Collection muss immer am Anfang stehen" ); 627 628 pGrfFmtCollTbl->DeleteAndDestroy( 1, pGrfFmtCollTbl->Count()-1 ); 629 // ergibt sich automatisch - kein _DEL Array! 630 // pGrfFmtCollTbl->Remove( 0, n ); 631 delete pGrfFmtCollTbl; 632 633 /* 634 * Defaultformate und DefaultFormatsammlungen (FmtColl) 635 * sind an der Position 0 der jeweiligen Arrays eingetragen. 636 * Damit sie nicht vom DTOR der Array's zum 2.mal geloescht werden, 637 * nehme sie aus dem Array. 638 */ 639 pFrmFmtTbl->Remove( 0 ); 640 pCharFmtTbl->Remove( 0 ); 641 642 // Delete fuer pPrt 643 DELETEZ( pPrt ); 644 DELETEZ( pNewDBMgr ); 645 646 // Alle Flys muessen vor dem Drawing Model zerstoert werden, 647 // da Flys noch DrawContacts enthalten koennen, wenn wegen 648 // eines Lesefehlers kein Layout aufgebaut wurde. 649 pSpzFrmFmtTbl->DeleteAndDestroy( 0, pSpzFrmFmtTbl->Count() ); 650 651 //Erst jetzt das Model zerstoeren, die Zeichenobjekte - die ja auch 652 //im Undo herumlungern - wollen noch ihre Attribute beim Model entfernen. 653 //Ausserdem koennen vorher noch DrawContacts existieren. 654 ReleaseDrawModel(); 655 //JP 28.01.99: DrawModel vorm LinkManager zerstoeren, da am DrawModel 656 // dieser immer gesetzt ist. 657 DELETEZ( pLinkMgr ); 658 659 //Tables vor dem loeschen der Defaults leeren, sonst GPF wegen Def-Abhaengigen. 660 //Die Arrays sollten (wegen includes) bei Gelegenheit auch zu Pointern werden. 661 delete pFrmFmtTbl; 662 delete pSpzFrmFmtTbl; 663 664 delete pStyleAccess; 665 666 delete pCharFmtTbl; 667 delete pSectionFmtTbl; 668 delete pTblFrmFmtTbl; 669 delete pDfltTxtFmtColl; 670 delete pDfltGrfFmtColl; 671 delete pNumRuleTbl; 672 673 // --> OD 2008-03-26 #refactorlists# 674 { 675 for ( std::hash_map< String, SwList*, StringHash >::iterator 676 aListIter = maLists.begin(); 677 aListIter != maLists.end(); 678 ++aListIter ) 679 { 680 delete (*aListIter).second; 681 } 682 maLists.clear(); 683 } 684 maListStyleLists.clear(); 685 // <-- 686 687 delete pPrtData; 688 delete pNumberFormatter; 689 delete pFtnInfo; 690 delete pEndNoteInfo; 691 delete pLineNumberInfo; 692 delete pFtnIdxs; 693 delete pFldTypes; 694 delete pTOXTypes; 695 delete pDocStat; 696 delete pEmptyPageFmt; 697 delete pColumnContFmt; 698 delete pDfltCharFmt; 699 delete pDfltFrmFmt; 700 delete pLayoutCache; 701 delete pVirDev; 702 703 SfxItemPool::Free(mpAttrPool); 704 } 705 706 //--------------------------------------------------- 707 708 VirtualDevice& SwDoc::CreateVirtualDevice_() const 709 { 710 VirtualDevice* pNewVir = new VirtualDevice( 1 ); 711 712 // <-- 713 pNewVir->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 ); 714 715 // --> FME 2006-10-09 #i60945# External leading compatibility for unix systems. 716 if ( get(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING ) ) 717 pNewVir->Compat_ZeroExtleadBug(); 718 // <-- 719 720 MapMode aMapMode( pNewVir->GetMapMode() ); 721 aMapMode.SetMapUnit( MAP_TWIP ); 722 pNewVir->SetMapMode( aMapMode ); 723 724 const_cast<SwDoc*>(this)->setVirtualDevice( pNewVir, true, true ); 725 return *pVirDev; 726 } 727 728 //--------------------------------------------------- 729 730 SfxPrinter& SwDoc::CreatePrinter_() const 731 { 732 ASSERT( ! pPrt, "Do not call CreatePrinter_(), call getPrinter() instead" ) 733 734 #if OSL_DEBUG_LEVEL > 1 735 ASSERT( false, "Printer will be created!" ) 736 #endif 737 738 // wir erzeugen einen default SfxPrinter. 739 // Das ItemSet wird vom Sfx geloescht! 740 SfxItemSet *pSet = new SfxItemSet( ((SwDoc*)this)->GetAttrPool(), 741 FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER, 742 SID_HTML_MODE, SID_HTML_MODE, 743 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, 744 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, 745 0 ); 746 747 SfxPrinter* pNewPrt = new SfxPrinter( pSet ); 748 const_cast<SwDoc*>(this)->setPrinter( pNewPrt, true, true ); 749 return *pPrt; 750 } 751 //--------------------------------------------------- 752 753 void SwDoc::SetDocShell( SwDocShell* pDSh ) 754 { 755 if( pDocShell != pDSh ) 756 { 757 if (pDocShell) 758 { 759 pDocShell->SetUndoManager(0); 760 } 761 pDocShell = pDSh; 762 if (pDocShell) 763 { 764 pDocShell->SetUndoManager(& GetUndoManager()); 765 } 766 767 pLinkMgr->SetPersist( pDocShell ); 768 //JP 27.08.98: Bug 55570 - DocShell Pointer auch am DrawModel setzen 769 if( pDrawModel ) 770 { 771 ((SwDrawDocument*)pDrawModel)->SetObjectShell( pDocShell ); 772 pDrawModel->SetPersist( pDocShell ); 773 ASSERT( pDrawModel->GetPersist() == GetPersist(), 774 "draw model's persist is out of sync" ); 775 } 776 } 777 } 778 779 780 // Convenience-Methode, um uebermaessige Includes von docsh.hxx 781 // zu vermeiden 782 783 784 785 uno::Reference < embed::XStorage > SwDoc::GetDocStorage() 786 { 787 if( pDocShell ) 788 return pDocShell->GetStorage(); 789 if( pLinkMgr->GetPersist() ) 790 return pLinkMgr->GetPersist()->GetStorage(); 791 return NULL; 792 } 793 794 795 796 SfxObjectShell* SwDoc::GetPersist() const 797 { 798 return pDocShell ? pDocShell : pLinkMgr->GetPersist(); 799 } 800 801 802 void SwDoc::ClearDoc() 803 { 804 GetIDocumentUndoRedo().DelAllUndoObj(); 805 ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); 806 807 // Undo-Benachrichtigung vom Draw abschalten 808 if( pDrawModel ) 809 { 810 DrawNotifyUndoHdl(); 811 ClrContourCache(); 812 } 813 814 // stehen noch FlyFrames rum, loesche auch diese 815 sal_uInt16 n; 816 while ( 0 != (n = GetSpzFrmFmts()->Count()) ) 817 DelLayoutFmt((*pSpzFrmFmtTbl)[n-1]); 818 ASSERT( !pDrawModel || !pDrawModel->GetPage(0)->GetObjCount(), 819 "not all DrawObjects removed from the page" ); 820 821 pRedlineTbl->DeleteAndDestroy( 0, pRedlineTbl->Count() ); 822 823 if( pACEWord ) 824 delete pACEWord; 825 826 // in den BookMarks sind Indizies auf den Content. Diese muessen vorm 827 // loesche der Nodes geloescht werden. 828 pMarkManager->clearAllMarks(); 829 InitTOXTypes(); 830 831 // create a dummy pagedesc for the layout 832 sal_uInt16 nDummyPgDsc = MakePageDesc( String::CreateFromAscii( "?DUMMY?" )); 833 SwPageDesc* pDummyPgDsc = aPageDescs[ nDummyPgDsc ]; 834 835 SwNodeIndex aSttIdx( *GetNodes().GetEndOfContent().StartOfSectionNode(), 1 ); 836 // den ersten immer wieder neu anlegen (ohne Attribute/Vorlagen/...) 837 SwTxtNode* pFirstNd = GetNodes().MakeTxtNode( aSttIdx, pDfltTxtFmtColl ); 838 839 if( pCurrentView ) //swmod 071029//swmod 071225 840 { 841 // set the layout to the dummy pagedesc 842 pFirstNd->SetAttr( SwFmtPageDesc( pDummyPgDsc )); 843 844 SwPosition aPos( *pFirstNd, SwIndex( pFirstNd )); 845 SwPaM const tmpPaM(aSttIdx, SwNodeIndex(GetNodes().GetEndOfContent())); 846 ::PaMCorrAbs(tmpPaM, aPos); 847 } 848 849 GetNodes().Delete( aSttIdx, 850 GetNodes().GetEndOfContent().GetIndex() - aSttIdx.GetIndex() ); 851 852 // --> OD 2006-02-28 #i62440# 853 // destruction of numbering rules and creation of new outline rule 854 // *after* the document nodes are deleted. 855 pOutlineRule = NULL; 856 pNumRuleTbl->DeleteAndDestroy( 0, pNumRuleTbl->Count() ); 857 // --> OD #i114725#,#i115828# 858 { 859 for ( std::hash_map< String, SwList*, StringHash >::iterator 860 aListIter = maLists.begin(); 861 aListIter != maLists.end(); 862 ++aListIter ) 863 { 864 delete (*aListIter).second; 865 } 866 maLists.clear(); 867 } 868 maListStyleLists.clear(); 869 // <-- 870 // creation of new outline numbering rule 871 // --> OD 2008-02-11 #newlistlevelattrs# 872 pOutlineRule = new SwNumRule( String::CreateFromAscii( SwNumRule::GetOutlineRuleName() ), 873 // --> OD 2008-06-06 #i89178# 874 numfunc::GetDefaultPositionAndSpaceMode(), 875 // <-- 876 OUTLINE_RULE ); 877 // <-- 878 AddNumRule(pOutlineRule); 879 // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()> 880 pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) ); 881 // <-- 882 // <-- 883 884 //remove the dummy pagedec from the array and delete all the old ones 885 aPageDescs.Remove( nDummyPgDsc ); 886 aPageDescs.DeleteAndDestroy( 0, aPageDescs.Count() ); 887 888 // Delete fuer Collections 889 // damit die Abhaengigen wech sind 890 pFtnInfo->ReleaseCollection(); 891 pEndNoteInfo->ReleaseCollection(); 892 893 // JP 27.01.98: opt.: ausgehend davon, das Standard als 2. im Array 894 // steht, sollte das als letztes geloescht werden, damit 895 // die ganze Umhaengerei der Formate vermieden wird! 896 if( 2 < pTxtFmtCollTbl->Count() ) 897 pTxtFmtCollTbl->DeleteAndDestroy( 2, pTxtFmtCollTbl->Count()-2 ); 898 pTxtFmtCollTbl->DeleteAndDestroy( 1, pTxtFmtCollTbl->Count()-1 ); 899 pGrfFmtCollTbl->DeleteAndDestroy( 1, pGrfFmtCollTbl->Count()-1 ); 900 pCharFmtTbl->DeleteAndDestroy( 1, pCharFmtTbl->Count()-1 ); 901 902 if( pCurrentView ) 903 { 904 // search the FrameFormat of the root frm. This is not allowed to delete 905 pFrmFmtTbl->Remove( pFrmFmtTbl->GetPos( pCurrentView->GetLayout()->GetFmt() ) ); 906 pFrmFmtTbl->DeleteAndDestroy( 1, pFrmFmtTbl->Count()-1 ); 907 pFrmFmtTbl->Insert( pCurrentView->GetLayout()->GetFmt(), pFrmFmtTbl->Count() ); 908 } 909 else //swmod 071029//swmod 071225 910 pFrmFmtTbl->DeleteAndDestroy( 1, pFrmFmtTbl->Count()-1 ); 911 912 xForbiddenCharsTable.unbind(); 913 914 pFldTypes->DeleteAndDestroy( INIT_FLDTYPES, 915 pFldTypes->Count() - INIT_FLDTYPES ); 916 917 delete pNumberFormatter, pNumberFormatter = 0; 918 919 GetPageDescFromPool( RES_POOLPAGE_STANDARD ); 920 pFirstNd->ChgFmtColl( GetTxtCollFromPool( RES_POOLCOLL_STANDARD )); 921 nDummyPgDsc = aPageDescs.Count(); 922 aPageDescs.Insert( pDummyPgDsc, nDummyPgDsc ); 923 // set the layout back to the new standard pagedesc 924 pFirstNd->ResetAllAttr(); 925 // delete now the dummy pagedesc 926 DelPageDesc( nDummyPgDsc ); 927 } 928 929 void SwDoc::SetPreViewPrtData( const SwPagePreViewPrtData* pNew ) 930 { 931 if( pNew ) 932 { 933 if( pPgPViewPrtData ) 934 *pPgPViewPrtData = *pNew; 935 else 936 pPgPViewPrtData = new SwPagePreViewPrtData( *pNew ); 937 } 938 else if( pPgPViewPrtData ) 939 DELETEZ( pPgPViewPrtData ); 940 SetModified(); 941 } 942 /* -----------------------------06.01.00 14:03-------------------------------- 943 944 ---------------------------------------------------------------------------*/ 945 SwModify* SwDoc::GetUnoCallBack() const 946 { 947 return pUnoCallBack; 948 } 949 950 /*-----------------28.5.2001 10:06------------------ 951 * SwDoc: 952 * Reading and writing of the layout cache. 953 *--------------------------------------------------*/ 954 955 void SwDoc::ReadLayoutCache( SvStream& rStream ) 956 { 957 if( !pLayoutCache ) 958 pLayoutCache = new SwLayoutCache(); 959 if( !pLayoutCache->IsLocked() ) 960 { 961 pLayoutCache->GetLockCount() |= 0x8000; 962 pLayoutCache->Read( rStream ); 963 pLayoutCache->GetLockCount() &= 0x7fff; 964 } 965 } 966 967 void SwDoc::WriteLayoutCache( SvStream& rStream ) 968 { 969 pLayoutCache->Write( rStream, *this ); 970 } 971 972 IGrammarContact* getGrammarContact( const SwTxtNode& rTxtNode ) 973 { 974 const SwDoc* pDoc = rTxtNode.GetDoc(); 975 if( !pDoc || pDoc->IsInDtor() ) 976 return 0; 977 return pDoc->getGrammarContact(); 978 } 979 980 // --> FME 2005-02-25 #i42634# Moved common code of SwReader::Read() and 981 // SwDocShell::UpdateLinks() to new SwDoc::UpdateLinks(): 982 void SwDoc::UpdateLinks( sal_Bool bUI ) 983 { 984 SfxObjectCreateMode eMode; 985 sal_uInt16 nLinkMode = getLinkUpdateMode( true ); 986 sal_uInt16 nUpdateDocMode = GetDocShell()->GetUpdateDocMode(); 987 if( GetDocShell() && 988 (nLinkMode != NEVER || document::UpdateDocMode::FULL_UPDATE == nUpdateDocMode) && 989 GetLinkManager().GetLinks().Count() && 990 SFX_CREATE_MODE_INTERNAL != 991 ( eMode = GetDocShell()->GetCreateMode()) && 992 SFX_CREATE_MODE_ORGANIZER != eMode && 993 SFX_CREATE_MODE_PREVIEW != eMode && 994 !GetDocShell()->IsPreview() ) 995 { 996 ViewShell* pVSh = 0; 997 sal_Bool bAskUpdate = nLinkMode == MANUAL; 998 sal_Bool bUpdate = sal_True; 999 switch(nUpdateDocMode) 1000 { 1001 case document::UpdateDocMode::NO_UPDATE: bUpdate = sal_False;break; 1002 case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = sal_False; break; 1003 case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = sal_True; break; 1004 } 1005 if( bUpdate && (bUI || !bAskUpdate) ) 1006 { 1007 SfxMedium* pMedium = GetDocShell()->GetMedium(); 1008 SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0; 1009 Window* pDlgParent = pFrm ? &pFrm->GetWindow() : 0; 1010 if( GetCurrentViewShell() && !GetEditShell( &pVSh ) && !pVSh ) //swmod 071108//swmod 071225 1011 { 1012 ViewShell aVSh( *this, 0, 0 ); 1013 1014 SET_CURR_SHELL( &aVSh ); 1015 GetLinkManager().UpdateAllLinks( bAskUpdate , sal_True, sal_False, pDlgParent ); 1016 } 1017 else 1018 GetLinkManager().UpdateAllLinks( bAskUpdate, sal_True, sal_False, pDlgParent ); 1019 } 1020 } 1021 1022 } 1023 // <-- 1024 // --> OD 2006-04-19 #b6375613# 1025 void SwDoc::SetApplyWorkaroundForB6375613( bool p_bApplyWorkaroundForB6375613 ) 1026 { 1027 if ( mbApplyWorkaroundForB6375613 != p_bApplyWorkaroundForB6375613 ) 1028 { 1029 mbApplyWorkaroundForB6375613 = p_bApplyWorkaroundForB6375613; 1030 1031 uno::Reference< document::XDocumentInfoSupplier > xDoc( 1032 GetDocShell()->GetBaseModel(), 1033 uno::UNO_QUERY); 1034 if ( xDoc.is() ) 1035 { 1036 uno::Reference< beans::XPropertyContainer > xDocInfo( 1037 xDoc->getDocumentInfo(), 1038 uno::UNO_QUERY ); 1039 if ( xDocInfo.is() ) 1040 { 1041 try 1042 { 1043 if ( mbApplyWorkaroundForB6375613 ) 1044 { 1045 xDocInfo->addProperty( 1046 rtl::OUString::createFromAscii("WorkaroundForB6375613Applied"), 1047 beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::REMOVABLE, 1048 uno::makeAny( false ) ); 1049 } 1050 else 1051 { 1052 xDocInfo->removeProperty( rtl::OUString::createFromAscii("WorkaroundForB6375613Applied") ); 1053 } 1054 } 1055 catch( uno::Exception& ) 1056 { 1057 } 1058 } 1059 } 1060 } 1061 } 1062 // <-- 1063 1064 ::sfx2::IXmlIdRegistry& 1065 SwDoc::GetXmlIdRegistry() 1066 { 1067 // UGLY: this relies on SetClipBoard being called before GetXmlIdRegistry! 1068 if (!m_pXmlIdRegistry.get()) 1069 { 1070 m_pXmlIdRegistry.reset( ::sfx2::createXmlIdRegistry( IsClipBoard() ) ); 1071 } 1072 return *m_pXmlIdRegistry; 1073 } 1074 1075 ::sw::MetaFieldManager & 1076 SwDoc::GetMetaFieldManager() 1077 { 1078 return *m_pMetaFieldManager; 1079 } 1080 1081 ::sw::UndoManager & 1082 SwDoc::GetUndoManager() 1083 { 1084 return *m_pUndoManager; 1085 } 1086 1087 ::sw::UndoManager const& 1088 SwDoc::GetUndoManager() const 1089 { 1090 return *m_pUndoManager; 1091 } 1092 1093 IDocumentUndoRedo & 1094 SwDoc::GetIDocumentUndoRedo() 1095 { 1096 return *m_pUndoManager; 1097 } 1098 1099 IDocumentUndoRedo const& 1100 SwDoc::GetIDocumentUndoRedo() const 1101 { 1102 return *m_pUndoManager; 1103 } 1104 1105 void SwDoc::InitTOXTypes() 1106 { 1107 ShellResource* pShellRes = ViewShell::GetShellRes(); 1108 SwTOXType * pNew = new SwTOXType(TOX_CONTENT, pShellRes->aTOXContentName ); 1109 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1110 pNew = new SwTOXType(TOX_INDEX, pShellRes->aTOXIndexName ); 1111 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1112 pNew = new SwTOXType(TOX_USER, pShellRes->aTOXUserName ); 1113 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1114 pNew = new SwTOXType(TOX_ILLUSTRATIONS, pShellRes->aTOXIllustrationsName ); 1115 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1116 pNew = new SwTOXType(TOX_OBJECTS, pShellRes->aTOXObjectsName ); 1117 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1118 pNew = new SwTOXType(TOX_TABLES, pShellRes->aTOXTablesName ); 1119 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1120 pNew = new SwTOXType(TOX_AUTHORITIES, pShellRes->aTOXAuthoritiesName ); 1121 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1122 } 1123 1124 /*-- 08.05.2009 10:07:57--------------------------------------------------- 1125 1126 -----------------------------------------------------------------------*/ 1127 SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const 1128 { 1129 SwDoc* pRet = new SwDoc; 1130 //copy settings 1131 sal_uInt16 __FAR_DATA aRangeOfDefaults[] = { 1132 RES_FRMATR_BEGIN, RES_FRMATR_END-1, 1133 RES_CHRATR_BEGIN, RES_CHRATR_END-1, 1134 RES_PARATR_BEGIN, RES_PARATR_END-1, 1135 // --> OD 2008-02-25 #refactorlists## 1136 RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, 1137 // <-- 1138 RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, 1139 0 1140 }; 1141 1142 SfxItemSet aNewDefaults( pRet->GetAttrPool(), aRangeOfDefaults ); 1143 1144 sal_uInt16 nWhich; 1145 sal_uInt16 nRange = 0; 1146 while( aRangeOfDefaults[nRange] != 0) 1147 { 1148 for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich ) 1149 { 1150 const SfxPoolItem& rSourceAttr = mpAttrPool->GetDefaultItem( nWhich ); 1151 if( rSourceAttr != pRet->mpAttrPool->GetDefaultItem( nWhich ) ) 1152 aNewDefaults.Put( rSourceAttr ); 1153 } 1154 nRange += 2; 1155 } 1156 if( aNewDefaults.Count() ) 1157 pRet->SetDefault( aNewDefaults ); 1158 1159 pRet->n32DummyCompatabilityOptions1 = n32DummyCompatabilityOptions1; 1160 pRet->n32DummyCompatabilityOptions2 = n32DummyCompatabilityOptions2; 1161 pRet->mbParaSpaceMax = mbParaSpaceMax ; 1162 pRet->mbParaSpaceMaxAtPages = mbParaSpaceMaxAtPages ; 1163 pRet->mbTabCompat = mbTabCompat ; 1164 pRet->mbUseVirtualDevice = mbUseVirtualDevice ; 1165 pRet->mbAddExternalLeading = mbAddExternalLeading ; 1166 pRet->mbOldLineSpacing = mbOldLineSpacing ; 1167 pRet->mbAddParaSpacingToTableCells = mbAddParaSpacingToTableCells ; 1168 pRet->mbUseFormerObjectPos = mbUseFormerObjectPos ; 1169 pRet->mbUseFormerTextWrapping = mbUseFormerTextWrapping ; 1170 pRet->mbConsiderWrapOnObjPos = mbConsiderWrapOnObjPos ; 1171 pRet->mbAddFlyOffsets = mbAddFlyOffsets ; 1172 pRet->mbOldNumbering = mbOldNumbering ; 1173 pRet->mbUseHiResolutionVirtualDevice = mbUseHiResolutionVirtualDevice ; 1174 pRet->mbIgnoreFirstLineIndentInNumbering = mbIgnoreFirstLineIndentInNumbering ; 1175 pRet->mbDoNotJustifyLinesWithManualBreak = mbDoNotJustifyLinesWithManualBreak ; 1176 pRet->mbDoNotResetParaAttrsForNumFont = mbDoNotResetParaAttrsForNumFont ; 1177 pRet->mbOutlineLevelYieldsOutlineRule = mbOutlineLevelYieldsOutlineRule ; 1178 pRet->mbTableRowKeep = mbTableRowKeep ; 1179 pRet->mbIgnoreTabsAndBlanksForLineCalculation = mbIgnoreTabsAndBlanksForLineCalculation ; 1180 pRet->mbDoNotCaptureDrawObjsOnPage = mbDoNotCaptureDrawObjsOnPage ; 1181 pRet->mbClipAsCharacterAnchoredWriterFlyFrames= mbClipAsCharacterAnchoredWriterFlyFrames; 1182 pRet->mbUnixForceZeroExtLeading = mbUnixForceZeroExtLeading ; 1183 pRet->mbOldPrinterMetrics = mbOldPrinterMetrics ; 1184 pRet->mbTabRelativeToIndent = mbTabRelativeToIndent ; 1185 pRet->mbTabAtLeftIndentForParagraphsInList = mbTabAtLeftIndentForParagraphsInList ; 1186 1187 // 1188 // COMPATIBILITY FLAGS END 1189 // 1190 pRet->ReplaceStyles( * const_cast< SwDoc*>( this )); 1191 1192 // we have to use pointer here, since the callee has to decide whether SfxObjectShellLock or SfxObjectShellRef should be used 1193 // sometimes the object will be returned with refcount set to 0 ( if no DoInitNew is done ) 1194 SfxObjectShell* pRetShell = new SwDocShell( pRet, SFX_CREATE_MODE_STANDARD ); 1195 if( bCallInitNew ) 1196 { 1197 // it could happen that DoInitNew creates model, that increases the refcount of the object 1198 pRetShell->DoInitNew(); 1199 } 1200 1201 //copy content 1202 pRet->Paste( *this ); 1203 1204 // remove the temporary shell if it is there as it was done before 1205 pRet->SetTmpDocShell( (SfxObjectShell*)NULL ); 1206 1207 return pRetShell; 1208 } 1209 /*-- 08.05.2009 10:52:40--------------------------------------------------- 1210 copy document content - code from SwFEShell::Paste( SwDoc* , sal_Bool ) 1211 -----------------------------------------------------------------------*/ 1212 void SwDoc::Paste( const SwDoc& rSource ) 1213 { 1214 // this has to be empty const sal_uInt16 nStartPageNumber = GetPhyPageNum(); 1215 // until the end of the NodesArray 1216 SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 2 ); 1217 SwPaM aCpyPam( aSourceIdx ); //DocStart 1218 SwNodeIndex aTargetIdx( GetNodes().GetEndOfExtras(), 2 ); 1219 SwPaM aInsertPam( aTargetIdx ); //replaces PCURCRSR from SwFEShell::Paste() 1220 1221 1222 aCpyPam.SetMark(); 1223 aCpyPam.Move( fnMoveForward, fnGoDoc ); 1224 1225 this->GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL ); 1226 this->LockExpFlds(); 1227 1228 { 1229 SwPosition& rInsPos = *aInsertPam.GetPoint(); 1230 //find out if the clipboard document starts with a table 1231 bool bStartWithTable = 0 != aCpyPam.Start()->nNode.GetNode().FindTableNode(); 1232 SwPosition aInsertPosition( rInsPos ); 1233 1234 { 1235 SwNodeIndex aIndexBefore(rInsPos.nNode); 1236 1237 aIndexBefore--; 1238 1239 rSource.CopyRange( aCpyPam, rInsPos, true ); 1240 1241 { 1242 aIndexBefore++; 1243 SwPaM aPaM(SwPosition(aIndexBefore), 1244 SwPosition(rInsPos.nNode)); 1245 1246 MakeUniqueNumRules(aPaM); 1247 } 1248 } 1249 1250 //TODO: Is this necessary here? SaveTblBoxCntnt( &rInsPos ); 1251 if(/*bIncludingPageFrames && */bStartWithTable) 1252 { 1253 //remove the paragraph in front of the table 1254 SwPaM aPara(aInsertPosition); 1255 this->DelFullPara(aPara); 1256 } 1257 //additionally copy page bound frames 1258 if( /*bIncludingPageFrames && */rSource.GetSpzFrmFmts()->Count() ) 1259 { 1260 for ( sal_uInt16 i = 0; i < rSource.GetSpzFrmFmts()->Count(); ++i ) 1261 { 1262 sal_Bool bInsWithFmt = sal_True; 1263 const SwFrmFmt& rCpyFmt = *(*rSource.GetSpzFrmFmts())[i]; 1264 if( bInsWithFmt ) 1265 { 1266 SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); 1267 if (FLY_AT_PAGE == aAnchor.GetAnchorId()) 1268 { 1269 aAnchor.SetPageNum( aAnchor.GetPageNum() /*+ nStartPageNumber - */); 1270 } 1271 else 1272 continue; 1273 this->CopyLayoutFmt( rCpyFmt, aAnchor, true, true ); 1274 } 1275 } 1276 } 1277 } 1278 1279 this->GetIDocumentUndoRedo().EndUndo( UNDO_INSGLOSSARY, NULL ); 1280 1281 UnlockExpFlds(); 1282 UpdateFlds(NULL, false); 1283 } 1284