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