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 // creation of new outline numbering rule 858 // --> OD 2008-02-11 #newlistlevelattrs# 859 pOutlineRule = new SwNumRule( String::CreateFromAscii( SwNumRule::GetOutlineRuleName() ), 860 // --> OD 2008-06-06 #i89178# 861 numfunc::GetDefaultPositionAndSpaceMode(), 862 // <-- 863 OUTLINE_RULE ); 864 // <-- 865 AddNumRule(pOutlineRule); 866 // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()> 867 pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) ); 868 // <-- 869 // <-- 870 871 //remove the dummy pagedec from the array and delete all the old ones 872 aPageDescs.Remove( nDummyPgDsc ); 873 aPageDescs.DeleteAndDestroy( 0, aPageDescs.Count() ); 874 875 // Delete fuer Collections 876 // damit die Abhaengigen wech sind 877 pFtnInfo->ReleaseCollection(); 878 pEndNoteInfo->ReleaseCollection(); 879 880 // JP 27.01.98: opt.: ausgehend davon, das Standard als 2. im Array 881 // steht, sollte das als letztes geloescht werden, damit 882 // die ganze Umhaengerei der Formate vermieden wird! 883 if( 2 < pTxtFmtCollTbl->Count() ) 884 pTxtFmtCollTbl->DeleteAndDestroy( 2, pTxtFmtCollTbl->Count()-2 ); 885 pTxtFmtCollTbl->DeleteAndDestroy( 1, pTxtFmtCollTbl->Count()-1 ); 886 pGrfFmtCollTbl->DeleteAndDestroy( 1, pGrfFmtCollTbl->Count()-1 ); 887 pCharFmtTbl->DeleteAndDestroy( 1, pCharFmtTbl->Count()-1 ); 888 889 if( pCurrentView ) 890 { 891 // search the FrameFormat of the root frm. This is not allowed to delete 892 pFrmFmtTbl->Remove( pFrmFmtTbl->GetPos( pCurrentView->GetLayout()->GetFmt() ) ); 893 pFrmFmtTbl->DeleteAndDestroy( 1, pFrmFmtTbl->Count()-1 ); 894 pFrmFmtTbl->Insert( pCurrentView->GetLayout()->GetFmt(), pFrmFmtTbl->Count() ); 895 } 896 else //swmod 071029//swmod 071225 897 pFrmFmtTbl->DeleteAndDestroy( 1, pFrmFmtTbl->Count()-1 ); 898 899 xForbiddenCharsTable.unbind(); 900 901 pFldTypes->DeleteAndDestroy( INIT_FLDTYPES, 902 pFldTypes->Count() - INIT_FLDTYPES ); 903 904 delete pNumberFormatter, pNumberFormatter = 0; 905 906 GetPageDescFromPool( RES_POOLPAGE_STANDARD ); 907 pFirstNd->ChgFmtColl( GetTxtCollFromPool( RES_POOLCOLL_STANDARD )); 908 nDummyPgDsc = aPageDescs.Count(); 909 aPageDescs.Insert( pDummyPgDsc, nDummyPgDsc ); 910 // set the layout back to the new standard pagedesc 911 pFirstNd->ResetAllAttr(); 912 // delete now the dummy pagedesc 913 DelPageDesc( nDummyPgDsc ); 914 } 915 916 void SwDoc::SetPreViewPrtData( const SwPagePreViewPrtData* pNew ) 917 { 918 if( pNew ) 919 { 920 if( pPgPViewPrtData ) 921 *pPgPViewPrtData = *pNew; 922 else 923 pPgPViewPrtData = new SwPagePreViewPrtData( *pNew ); 924 } 925 else if( pPgPViewPrtData ) 926 DELETEZ( pPgPViewPrtData ); 927 SetModified(); 928 } 929 /* -----------------------------06.01.00 14:03-------------------------------- 930 931 ---------------------------------------------------------------------------*/ 932 SwModify* SwDoc::GetUnoCallBack() const 933 { 934 return pUnoCallBack; 935 } 936 937 /*-----------------28.5.2001 10:06------------------ 938 * SwDoc: 939 * Reading and writing of the layout cache. 940 *--------------------------------------------------*/ 941 942 void SwDoc::ReadLayoutCache( SvStream& rStream ) 943 { 944 if( !pLayoutCache ) 945 pLayoutCache = new SwLayoutCache(); 946 if( !pLayoutCache->IsLocked() ) 947 { 948 pLayoutCache->GetLockCount() |= 0x8000; 949 pLayoutCache->Read( rStream ); 950 pLayoutCache->GetLockCount() &= 0x7fff; 951 } 952 } 953 954 void SwDoc::WriteLayoutCache( SvStream& rStream ) 955 { 956 pLayoutCache->Write( rStream, *this ); 957 } 958 959 IGrammarContact* getGrammarContact( const SwTxtNode& rTxtNode ) 960 { 961 const SwDoc* pDoc = rTxtNode.GetDoc(); 962 if( !pDoc || pDoc->IsInDtor() ) 963 return 0; 964 return pDoc->getGrammarContact(); 965 } 966 967 // --> FME 2005-02-25 #i42634# Moved common code of SwReader::Read() and 968 // SwDocShell::UpdateLinks() to new SwDoc::UpdateLinks(): 969 void SwDoc::UpdateLinks( sal_Bool bUI ) 970 { 971 SfxObjectCreateMode eMode; 972 sal_uInt16 nLinkMode = getLinkUpdateMode( true ); 973 sal_uInt16 nUpdateDocMode = GetDocShell()->GetUpdateDocMode(); 974 if( GetDocShell() && 975 (nLinkMode != NEVER || document::UpdateDocMode::FULL_UPDATE == nUpdateDocMode) && 976 GetLinkManager().GetLinks().Count() && 977 SFX_CREATE_MODE_INTERNAL != 978 ( eMode = GetDocShell()->GetCreateMode()) && 979 SFX_CREATE_MODE_ORGANIZER != eMode && 980 SFX_CREATE_MODE_PREVIEW != eMode && 981 !GetDocShell()->IsPreview() ) 982 { 983 ViewShell* pVSh = 0; 984 sal_Bool bAskUpdate = nLinkMode == MANUAL; 985 sal_Bool bUpdate = sal_True; 986 switch(nUpdateDocMode) 987 { 988 case document::UpdateDocMode::NO_UPDATE: bUpdate = sal_False;break; 989 case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = sal_False; break; 990 case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = sal_True; break; 991 } 992 if( bUpdate && (bUI || !bAskUpdate) ) 993 { 994 SfxMedium* pMedium = GetDocShell()->GetMedium(); 995 SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0; 996 Window* pDlgParent = pFrm ? &pFrm->GetWindow() : 0; 997 if( GetCurrentViewShell() && !GetEditShell( &pVSh ) && !pVSh ) //swmod 071108//swmod 071225 998 { 999 ViewShell aVSh( *this, 0, 0 ); 1000 1001 SET_CURR_SHELL( &aVSh ); 1002 GetLinkManager().UpdateAllLinks( bAskUpdate , sal_True, sal_False, pDlgParent ); 1003 } 1004 else 1005 GetLinkManager().UpdateAllLinks( bAskUpdate, sal_True, sal_False, pDlgParent ); 1006 } 1007 } 1008 1009 } 1010 // <-- 1011 // --> OD 2006-04-19 #b6375613# 1012 void SwDoc::SetApplyWorkaroundForB6375613( bool p_bApplyWorkaroundForB6375613 ) 1013 { 1014 if ( mbApplyWorkaroundForB6375613 != p_bApplyWorkaroundForB6375613 ) 1015 { 1016 mbApplyWorkaroundForB6375613 = p_bApplyWorkaroundForB6375613; 1017 1018 uno::Reference< document::XDocumentInfoSupplier > xDoc( 1019 GetDocShell()->GetBaseModel(), 1020 uno::UNO_QUERY); 1021 if ( xDoc.is() ) 1022 { 1023 uno::Reference< beans::XPropertyContainer > xDocInfo( 1024 xDoc->getDocumentInfo(), 1025 uno::UNO_QUERY ); 1026 if ( xDocInfo.is() ) 1027 { 1028 try 1029 { 1030 if ( mbApplyWorkaroundForB6375613 ) 1031 { 1032 xDocInfo->addProperty( 1033 rtl::OUString::createFromAscii("WorkaroundForB6375613Applied"), 1034 beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::REMOVABLE, 1035 uno::makeAny( false ) ); 1036 } 1037 else 1038 { 1039 xDocInfo->removeProperty( rtl::OUString::createFromAscii("WorkaroundForB6375613Applied") ); 1040 } 1041 } 1042 catch( uno::Exception& ) 1043 { 1044 } 1045 } 1046 } 1047 } 1048 } 1049 // <-- 1050 1051 ::sfx2::IXmlIdRegistry& 1052 SwDoc::GetXmlIdRegistry() 1053 { 1054 // UGLY: this relies on SetClipBoard being called before GetXmlIdRegistry! 1055 if (!m_pXmlIdRegistry.get()) 1056 { 1057 m_pXmlIdRegistry.reset( ::sfx2::createXmlIdRegistry( IsClipBoard() ) ); 1058 } 1059 return *m_pXmlIdRegistry; 1060 } 1061 1062 ::sw::MetaFieldManager & 1063 SwDoc::GetMetaFieldManager() 1064 { 1065 return *m_pMetaFieldManager; 1066 } 1067 1068 ::sw::UndoManager & 1069 SwDoc::GetUndoManager() 1070 { 1071 return *m_pUndoManager; 1072 } 1073 1074 ::sw::UndoManager const& 1075 SwDoc::GetUndoManager() const 1076 { 1077 return *m_pUndoManager; 1078 } 1079 1080 IDocumentUndoRedo & 1081 SwDoc::GetIDocumentUndoRedo() 1082 { 1083 return *m_pUndoManager; 1084 } 1085 1086 IDocumentUndoRedo const& 1087 SwDoc::GetIDocumentUndoRedo() const 1088 { 1089 return *m_pUndoManager; 1090 } 1091 1092 void SwDoc::InitTOXTypes() 1093 { 1094 ShellResource* pShellRes = ViewShell::GetShellRes(); 1095 SwTOXType * pNew = new SwTOXType(TOX_CONTENT, pShellRes->aTOXContentName ); 1096 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1097 pNew = new SwTOXType(TOX_INDEX, pShellRes->aTOXIndexName ); 1098 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1099 pNew = new SwTOXType(TOX_USER, pShellRes->aTOXUserName ); 1100 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1101 pNew = new SwTOXType(TOX_ILLUSTRATIONS, pShellRes->aTOXIllustrationsName ); 1102 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1103 pNew = new SwTOXType(TOX_OBJECTS, pShellRes->aTOXObjectsName ); 1104 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1105 pNew = new SwTOXType(TOX_TABLES, pShellRes->aTOXTablesName ); 1106 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1107 pNew = new SwTOXType(TOX_AUTHORITIES, pShellRes->aTOXAuthoritiesName ); 1108 pTOXTypes->Insert( pNew, pTOXTypes->Count() ); 1109 } 1110 1111 /*-- 08.05.2009 10:07:57--------------------------------------------------- 1112 1113 -----------------------------------------------------------------------*/ 1114 SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const 1115 { 1116 SwDoc* pRet = new SwDoc; 1117 //copy settings 1118 sal_uInt16 __FAR_DATA aRangeOfDefaults[] = { 1119 RES_FRMATR_BEGIN, RES_FRMATR_END-1, 1120 RES_CHRATR_BEGIN, RES_CHRATR_END-1, 1121 RES_PARATR_BEGIN, RES_PARATR_END-1, 1122 // --> OD 2008-02-25 #refactorlists## 1123 RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1, 1124 // <-- 1125 RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, 1126 0 1127 }; 1128 1129 SfxItemSet aNewDefaults( pRet->GetAttrPool(), aRangeOfDefaults ); 1130 1131 sal_uInt16 nWhich; 1132 sal_uInt16 nRange = 0; 1133 while( aRangeOfDefaults[nRange] != 0) 1134 { 1135 for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich ) 1136 { 1137 const SfxPoolItem& rSourceAttr = mpAttrPool->GetDefaultItem( nWhich ); 1138 if( rSourceAttr != pRet->mpAttrPool->GetDefaultItem( nWhich ) ) 1139 aNewDefaults.Put( rSourceAttr ); 1140 } 1141 nRange += 2; 1142 } 1143 if( aNewDefaults.Count() ) 1144 pRet->SetDefault( aNewDefaults ); 1145 1146 pRet->n32DummyCompatabilityOptions1 = n32DummyCompatabilityOptions1; 1147 pRet->n32DummyCompatabilityOptions2 = n32DummyCompatabilityOptions2; 1148 pRet->mbParaSpaceMax = mbParaSpaceMax ; 1149 pRet->mbParaSpaceMaxAtPages = mbParaSpaceMaxAtPages ; 1150 pRet->mbTabCompat = mbTabCompat ; 1151 pRet->mbUseVirtualDevice = mbUseVirtualDevice ; 1152 pRet->mbAddExternalLeading = mbAddExternalLeading ; 1153 pRet->mbOldLineSpacing = mbOldLineSpacing ; 1154 pRet->mbAddParaSpacingToTableCells = mbAddParaSpacingToTableCells ; 1155 pRet->mbUseFormerObjectPos = mbUseFormerObjectPos ; 1156 pRet->mbUseFormerTextWrapping = mbUseFormerTextWrapping ; 1157 pRet->mbConsiderWrapOnObjPos = mbConsiderWrapOnObjPos ; 1158 pRet->mbAddFlyOffsets = mbAddFlyOffsets ; 1159 pRet->mbOldNumbering = mbOldNumbering ; 1160 pRet->mbUseHiResolutionVirtualDevice = mbUseHiResolutionVirtualDevice ; 1161 pRet->mbIgnoreFirstLineIndentInNumbering = mbIgnoreFirstLineIndentInNumbering ; 1162 pRet->mbDoNotJustifyLinesWithManualBreak = mbDoNotJustifyLinesWithManualBreak ; 1163 pRet->mbDoNotResetParaAttrsForNumFont = mbDoNotResetParaAttrsForNumFont ; 1164 pRet->mbOutlineLevelYieldsOutlineRule = mbOutlineLevelYieldsOutlineRule ; 1165 pRet->mbTableRowKeep = mbTableRowKeep ; 1166 pRet->mbIgnoreTabsAndBlanksForLineCalculation = mbIgnoreTabsAndBlanksForLineCalculation ; 1167 pRet->mbDoNotCaptureDrawObjsOnPage = mbDoNotCaptureDrawObjsOnPage ; 1168 pRet->mbClipAsCharacterAnchoredWriterFlyFrames= mbClipAsCharacterAnchoredWriterFlyFrames; 1169 pRet->mbUnixForceZeroExtLeading = mbUnixForceZeroExtLeading ; 1170 pRet->mbOldPrinterMetrics = mbOldPrinterMetrics ; 1171 pRet->mbTabRelativeToIndent = mbTabRelativeToIndent ; 1172 pRet->mbTabAtLeftIndentForParagraphsInList = mbTabAtLeftIndentForParagraphsInList ; 1173 1174 // 1175 // COMPATIBILITY FLAGS END 1176 // 1177 pRet->ReplaceStyles( * const_cast< SwDoc*>( this )); 1178 1179 // we have to use pointer here, since the callee has to decide whether SfxObjectShellLock or SfxObjectShellRef should be used 1180 // sometimes the object will be returned with refcount set to 0 ( if no DoInitNew is done ) 1181 SfxObjectShell* pRetShell = new SwDocShell( pRet, SFX_CREATE_MODE_STANDARD ); 1182 if( bCallInitNew ) 1183 { 1184 // it could happen that DoInitNew creates model, that increases the refcount of the object 1185 pRetShell->DoInitNew(); 1186 } 1187 1188 //copy content 1189 pRet->Paste( *this ); 1190 1191 // remove the temporary shell if it is there as it was done before 1192 pRet->SetTmpDocShell( (SfxObjectShell*)NULL ); 1193 1194 return pRetShell; 1195 } 1196 /*-- 08.05.2009 10:52:40--------------------------------------------------- 1197 copy document content - code from SwFEShell::Paste( SwDoc* , sal_Bool ) 1198 -----------------------------------------------------------------------*/ 1199 void SwDoc::Paste( const SwDoc& rSource ) 1200 { 1201 // this has to be empty const sal_uInt16 nStartPageNumber = GetPhyPageNum(); 1202 // until the end of the NodesArray 1203 SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 2 ); 1204 SwPaM aCpyPam( aSourceIdx ); //DocStart 1205 SwNodeIndex aTargetIdx( GetNodes().GetEndOfExtras(), 2 ); 1206 SwPaM aInsertPam( aTargetIdx ); //replaces PCURCRSR from SwFEShell::Paste() 1207 1208 1209 aCpyPam.SetMark(); 1210 aCpyPam.Move( fnMoveForward, fnGoDoc ); 1211 1212 this->GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL ); 1213 this->LockExpFlds(); 1214 1215 { 1216 SwPosition& rInsPos = *aInsertPam.GetPoint(); 1217 //find out if the clipboard document starts with a table 1218 bool bStartWithTable = 0 != aCpyPam.Start()->nNode.GetNode().FindTableNode(); 1219 SwPosition aInsertPosition( rInsPos ); 1220 1221 { 1222 SwNodeIndex aIndexBefore(rInsPos.nNode); 1223 1224 aIndexBefore--; 1225 1226 rSource.CopyRange( aCpyPam, rInsPos, true ); 1227 1228 { 1229 aIndexBefore++; 1230 SwPaM aPaM(SwPosition(aIndexBefore), 1231 SwPosition(rInsPos.nNode)); 1232 1233 MakeUniqueNumRules(aPaM); 1234 } 1235 } 1236 1237 //TODO: Is this necessary here? SaveTblBoxCntnt( &rInsPos ); 1238 if(/*bIncludingPageFrames && */bStartWithTable) 1239 { 1240 //remove the paragraph in front of the table 1241 SwPaM aPara(aInsertPosition); 1242 this->DelFullPara(aPara); 1243 } 1244 //additionally copy page bound frames 1245 if( /*bIncludingPageFrames && */rSource.GetSpzFrmFmts()->Count() ) 1246 { 1247 for ( sal_uInt16 i = 0; i < rSource.GetSpzFrmFmts()->Count(); ++i ) 1248 { 1249 sal_Bool bInsWithFmt = sal_True; 1250 const SwFrmFmt& rCpyFmt = *(*rSource.GetSpzFrmFmts())[i]; 1251 if( bInsWithFmt ) 1252 { 1253 SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() ); 1254 if (FLY_AT_PAGE == aAnchor.GetAnchorId()) 1255 { 1256 aAnchor.SetPageNum( aAnchor.GetPageNum() /*+ nStartPageNumber - */); 1257 } 1258 else 1259 continue; 1260 this->CopyLayoutFmt( rCpyFmt, aAnchor, true, true ); 1261 } 1262 } 1263 } 1264 } 1265 1266 this->GetIDocumentUndoRedo().EndUndo( UNDO_INSGLOSSARY, NULL ); 1267 1268 UnlockExpFlds(); 1269 UpdateFlds(NULL, false); 1270 } 1271