merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / doc / docnew.cxx
blobde57a0b5e20ffec34a1924bf77f5b08065703d65
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docnew.cxx,v $
10 * $Revision: 1.89 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #define ROLBCK_HISTORY_ONLY // Der Kampf gegen die CLOOK's
34 #include <doc.hxx>
35 #include <dcontact.hxx>
36 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
37 #include <com/sun/star/document/UpdateDocMode.hpp>
38 #include <com/sun/star/text/XTextDocument.hpp>
39 #include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
40 #include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp>
42 #include <unotools/processfactory.hxx>
43 #include <vcl/svapp.hxx>
44 #include <vcl/virdev.hxx>
45 #include <rtl/logfile.hxx>
46 #include <sfx2/printer.hxx>
47 #include <sfx2/docfile.hxx>
48 #include <sfx2/frame.hxx>
50 #include <svtools/macitem.hxx>
51 #include <svx/svxids.hrc>
52 #include <svx/svdogrp.hxx>
53 #include <svx/linkmgr.hxx>
54 #include <svx/forbiddencharacterstable.hxx>
55 #include <svtools/zforlist.hxx>
56 #include <svtools/compatibility.hxx>
57 #include <svtools/lingucfg.hxx>
58 #include <svx/svdpage.hxx>
59 #include <paratr.hxx>
60 #include <fchrfmt.hxx>
61 #include <fmtcntnt.hxx>
62 #include <fmtanchr.hxx>
63 #include <fmtfsize.hxx>
64 #include <fmtfordr.hxx>
65 #include <fmtpdsc.hxx>
66 #include <pvprtdat.hxx>
67 #include <rootfrm.hxx> //Damit der RootDtor gerufen wird.
68 #include <layouter.hxx>
69 #include <pagedesc.hxx> //Damit die PageDescs zerstoert werden koennen.
70 #include <ndtxt.hxx>
71 #include <printdata.hxx>
72 #include <docfld.hxx>
73 #include <ftninfo.hxx>
74 #include <ftnidx.hxx>
75 #include <docstat.hxx>
76 #include <charfmt.hxx>
77 #include <frmfmt.hxx>
78 #include <rolbck.hxx> // Undo-Attr, SwHistory
79 #include <poolfmt.hxx> // fuer die Pool-Vorlage
80 #include <dbmgr.hxx>
81 #include <docsh.hxx>
82 #include <acorrect.hxx> // fuer die autom. Aufnahme von Ausnahmen
83 #include <visiturl.hxx> // fuer die URL-Change Benachrichtigung
84 #include <docary.hxx>
85 #include <lineinfo.hxx>
86 #include <drawdoc.hxx>
87 #include <linkenum.hxx>
88 #include <fldupde.hxx>
89 #include <extinput.hxx>
90 #include <viewsh.hxx>
91 #include <doctxm.hxx>
92 #include <shellres.hxx>
93 #include <unoclbck.hxx>
94 #include <breakit.hxx>
95 #include <laycache.hxx>
96 #include <mvsave.hxx>
97 #include <istyleaccess.hxx>
98 #include <swstylemanager.hxx>
99 #include <IGrammarContact.hxx>
100 #include <tblsel.hxx>
101 #include <MarkManager.hxx>
102 #include <unochart.hxx>
104 #include <cmdid.h> // fuer den dflt - Printer in SetJob
107 // --> OD 2006-04-19 #b6375613#
108 #include <com/sun/star/document/XDocumentInfoSupplier.hpp>
109 #include <com/sun/star/beans/XPropertyContainer.hpp>
110 #include <com/sun/star/beans/PropertyAttribute.hpp>
112 // <--
114 // --> OD 2007-03-16 #i73788#
115 #include <pausethreadstarting.hxx>
116 // <--
117 #include <numrule.hxx>
118 // --> OD 2008-03-13 #refactorlists#
119 #include <list.hxx>
120 #include <listfunc.hxx>
121 // <--
123 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
125 #include <sfx2/Metadatable.hxx>
126 #include <fmtmeta.hxx> // MetaFieldManager
129 using namespace ::com::sun::star;
130 using namespace ::com::sun::star::document;
132 const sal_Char __FAR_DATA sFrmFmtStr[] = "Frameformat";
133 const sal_Char __FAR_DATA sEmptyPageStr[] = "Empty Page";
134 const sal_Char __FAR_DATA sColumnCntStr[] = "Columncontainer";
135 const sal_Char __FAR_DATA sCharFmtStr[] = "Zeichenformat";
136 const sal_Char __FAR_DATA sTxtCollStr[] = "Textformatvorlage";
137 const sal_Char __FAR_DATA sGrfCollStr[] = "Graphikformatvorlage";
139 SV_IMPL_PTRARR( SwNumRuleTbl, SwNumRulePtr)
140 SV_IMPL_PTRARR( SwTxtFmtColls, SwTxtFmtCollPtr)
141 SV_IMPL_PTRARR( SwGrfFmtColls, SwGrfFmtCollPtr)
144 * global functions...
147 uno::Reference< linguistic2::XProofreadingIterator > SwDoc::GetGCIterator() const
149 if (!m_xGCIterator.is() && SvtLinguConfig().HasGrammarChecker())
151 uno::Reference< lang::XMultiServiceFactory > xMgr( utl::getProcessServiceFactory() );
152 if (xMgr.is())
156 rtl::OUString aServiceName( rtl::OUString::createFromAscii("com.sun.star.linguistic2.ProofreadingIterator") );
157 m_xGCIterator = uno::Reference< linguistic2::XProofreadingIterator >
158 ( xMgr->createInstance( aServiceName ), uno::UNO_QUERY_THROW );
160 catch (uno::Exception &)
162 DBG_ERROR( "No GCIterator" );
167 return m_xGCIterator;
170 void StartGrammarChecking( SwDoc &rDoc )
172 uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( rDoc.GetGCIterator() );
173 if ( xGCIterator.is() )
175 uno::Reference< lang::XComponent > xDoc( rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY );
176 uno::Reference< text::XFlatParagraphIteratorProvider > xFPIP( xDoc, uno::UNO_QUERY );
178 // start automatic background checking if not active already
179 if ( xFPIP.is() && !xGCIterator->isProofreading( xDoc ) )
180 xGCIterator->startProofreading( xDoc, xFPIP );
185 * interne Funktionen
190 BOOL lcl_DelFmtIndizes( const SwFrmFmtPtr& rpFmt, void* )
192 SwFmtCntnt &rFmtCntnt = (SwFmtCntnt&)rpFmt->GetCntnt();
193 if ( rFmtCntnt.GetCntntIdx() )
194 rFmtCntnt.SetNewCntntIdx( 0 );
195 SwFmtAnchor &rFmtAnchor = (SwFmtAnchor&)rpFmt->GetAnchor();
196 if ( rFmtAnchor.GetCntntAnchor() )
197 rFmtAnchor.SetAnchor( 0 );
198 return TRUE;
202 * exportierte Methoden
205 SwDoc::SwDoc() :
206 aNodes( this ),
207 aUndoNodes( this ),
208 mpAttrPool(new SwAttrPool(this)),
209 pMarkManager(new ::sw::mark::MarkManager(*this)),
210 m_pMetaFieldManager(new ::sw::MetaFieldManager()),
211 pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
212 pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ),
213 pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ),
214 pDfltCharFmt( new SwCharFmt( GetAttrPool(), sCharFmtStr, 0 ) ),
215 pDfltTxtFmtColl( new SwTxtFmtColl( GetAttrPool(), sTxtCollStr ) ),
216 pDfltGrfFmtColl( new SwGrfFmtColl( GetAttrPool(), sGrfCollStr ) ),
217 pFrmFmtTbl( new SwFrmFmts() ),
218 pCharFmtTbl( new SwCharFmts() ),
219 pSpzFrmFmtTbl( new SwSpzFrmFmts() ),
220 pSectionFmtTbl( new SwSectionFmts() ),
221 pTblFrmFmtTbl( new SwFrmFmts() ),
222 pTxtFmtCollTbl( new SwTxtFmtColls() ),
223 pGrfFmtCollTbl( new SwGrfFmtColls() ),
224 pTOXTypes( new SwTOXTypes() ),
225 pDefTOXBases( new SwDefTOXBase_Impl() ),
226 pLayout( 0 ), // Rootframe des spezifischen Layouts.
227 pDrawModel( 0 ),
228 pUndos( new SwUndos( 0, 20 ) ),
229 pUpdtFlds( new SwDocUpdtFld() ),
230 pFldTypes( new SwFldTypes() ),
231 pVirDev( 0 ),
232 pPrt( 0 ),
233 pPrtData( 0 ),
234 pGlossaryDoc( 0 ),
235 pOutlineRule( 0 ),
236 pFtnInfo( new SwFtnInfo ),
237 pEndNoteInfo( new SwEndNoteInfo ),
238 pLineNumberInfo( new SwLineNumberInfo ),
239 pFtnIdxs( new SwFtnIdxs ),
240 pDocStat( new SwDocStat ),
241 pDocShell( 0 ),
242 pDocShRef( 0 ),
243 pLinkMgr( new SvxLinkManager( 0 ) ),
244 pACEWord( 0 ),
245 pURLStateChgd( 0 ),
246 pNumberFormatter( 0 ),
247 pNumRuleTbl( new SwNumRuleTbl ),
248 // --> OD 2008-03-26 #refactorlists#
249 maLists(),
250 maListStyleLists(),
251 // <--
252 pRedlineTbl( new SwRedlineTbl ),
253 pAutoFmtRedlnComment( 0 ),
254 pUnoCrsrTbl( new SwUnoCrsrTbl( 0, 16 ) ),
255 pPgPViewPrtData( 0 ),
256 pExtInputRing( 0 ),
257 pLayouter( 0 ),
258 // --> OD 2008-03-07 #refactorlists#
259 pStyleAccess( 0 ),
260 // <--
261 pLayoutCache( 0 ),
262 pUnoCallBack(new SwUnoCallBack(0)),
263 mpGrammarContact( 0 ),
264 aChartDataProviderImplRef(),
265 pChartControllerHelper( 0 ),
266 // --> OD 2007-10-31 #i83479#
267 mpListItemsList( new tImplSortedNodeNumList() ),
268 // <--
269 m_pXmlIdRegistry(),
270 nUndoPos( 0 ),
271 nUndoSavePos( 0 ),
272 nUndoCnt( 0 ),
273 nUndoSttEnd( 0 ),
274 nAutoFmtRedlnCommentNo( 0 ),
275 nLinkUpdMode( GLOBALSETTING ),
276 eFldUpdMode( AUTOUPD_GLOBALSETTING ),
277 eRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)),
278 eChrCmprType( CHARCOMPRESS_NONE ),
279 mReferenceCount(0),
280 mIdleBlockCount(0),
281 nLockExpFld( 0 ),
282 mbReadlineChecked(false),
283 // --> OD 2005-02-11 #i38810#
284 mbLinksUpdated( sal_False ),
285 mbClipBoard( false ),
286 mbColumnSelection( false ),
287 // i#78591#
288 mbProtectForm(false),
289 n32DummyCompatabilityOptions1(0),
290 n32DummyCompatabilityOptions2(0),
291 mbStartIdleTimer(sal_False)
293 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDoc::SwDoc" );
295 mbGlossDoc =
296 mbModified =
297 mbDtor =
298 mbUndo =
299 mbPageNums =
300 mbLoaded =
301 mbUpdateExpFld =
302 mbNewDoc =
303 mbCopyIsMove =
304 mbNoDrawUndoObj =
305 mbBrowseMode =
306 mbInReading =
307 mbInXMLImport =
308 mbUpdateTOX =
309 mbInLoadAsynchron =
310 mbHTMLMode =
311 mbInCallModified =
312 mbIsGlobalDoc =
313 mbGlblDocSaveLinks =
314 mbIsLabelDoc =
315 mbIsAutoFmtRedline =
316 mbOLEPrtNotifyPending =
317 mbAllOLENotify =
318 mbIsRedlineMove =
319 mbInsOnlyTxtGlssry =
320 mbContains_MSVBasic =
321 mbKernAsianPunctuation =
322 #ifndef PRODUCT
323 mbXMLExport =
324 #endif
325 // --> OD 2006-03-21 #b6375613#
326 mbApplyWorkaroundForB6375613 =
327 // <--
328 false;
330 mbGroupUndo =
331 mbNewFldLst =
332 mbVisibleLinks =
333 mbPurgeOLE =
334 true;
337 // COMPATIBILITY FLAGS START
340 // Note: Any non-hidden compatibility flag should obtain its default
341 // by asking SvtCompatibilityOptions, see below.
343 const SvtCompatibilityOptions aOptions;
344 mbParaSpaceMax = aOptions.IsAddSpacing();
345 mbParaSpaceMaxAtPages = aOptions.IsAddSpacingAtPages();
346 mbTabCompat = !aOptions.IsUseOurTabStops();
347 mbUseVirtualDevice = !aOptions.IsUsePrtDevice();
348 mbAddExternalLeading = !aOptions.IsNoExtLeading();
349 mbOldLineSpacing = aOptions.IsUseLineSpacing();
350 mbAddParaSpacingToTableCells = aOptions.IsAddTableSpacing();
351 mbUseFormerObjectPos = aOptions.IsUseObjectPositioning();
352 mbUseFormerTextWrapping = aOptions.IsUseOurTextWrapping();
353 mbConsiderWrapOnObjPos = aOptions.IsConsiderWrappingStyle();
354 mbAddFlyOffsets = false; // hidden
355 mbOldNumbering = false; // hidden
356 mbUseHiResolutionVirtualDevice = true; // hidden
357 mbIgnoreFirstLineIndentInNumbering = false; // hidden
358 mbDoNotJustifyLinesWithManualBreak = !aOptions.IsExpandWordSpace();
359 mbDoNotResetParaAttrsForNumFont = false; // hidden
360 mbOutlineLevelYieldsOutlineRule = false; // hidden
361 mbTableRowKeep = false; // hidden
362 mbIgnoreTabsAndBlanksForLineCalculation = false; // hidden
363 mbDoNotCaptureDrawObjsOnPage = false; // hidden
364 mbClipAsCharacterAnchoredWriterFlyFrames= false; // hidden
365 mbUnixForceZeroExtLeading = false; // hidden
366 mbOldPrinterMetrics = false; // hidden
367 mbTabRelativeToIndent = true; // hidden
368 // --> OD 2008-06-05 #i89181#
369 mbTabAtLeftIndentForParagraphsInList = false; // hidden
370 // <--
371 mbInvertBorderSpacing = false; // hidden
372 mbCollapseEmptyCellPara = true; // hidden
375 // COMPATIBILITY FLAGS END
378 pMacroTable = new SvxMacroTableDtor;
380 mpGrammarContact = ::createGrammarContact();
383 * Defaultformate und DefaultFormatsammlungen (FmtColl)
384 * werden an der Position 0 in das jeweilige Array eingetragen.
385 * Die Formate der FmtColls sind von den Defaultformaten
386 * abgeleitet und stehen auch in der Liste.
388 /* Formate */
389 pFrmFmtTbl->Insert(pDfltFrmFmt, 0 );
390 pCharFmtTbl->Insert(pDfltCharFmt, 0 );
392 /* FmtColls */
393 // TXT
394 pTxtFmtCollTbl->Insert(pDfltTxtFmtColl, 0 );
395 // GRF
396 pGrfFmtCollTbl->Insert(pDfltGrfFmtColl, 0 );
398 // PageDesc, EmptyPageFmt und ColumnFmt anlegen
399 if ( !aPageDescs.Count() )
400 GetPageDescFromPool( RES_POOLPAGE_STANDARD );
402 //Leere Seite Einstellen.
403 pEmptyPageFmt->SetFmtAttr( SwFmtFrmSize( ATT_FIX_SIZE ) );
404 //BodyFmt fuer Spalten Einstellen.
405 pColumnContFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ) );
407 _InitFieldTypes();
409 // lege (fuer die Filter) eine Default-OutlineNumRule an
410 // --> OD 2008-02-11 #newlistlevelattrs#
411 pOutlineRule = new SwNumRule( String::CreateFromAscii( SwNumRule::GetOutlineRuleName() ),
412 // --> OD 2008-06-06 #i89178#
413 numfunc::GetDefaultPositionAndSpaceMode(),
414 // <--
415 OUTLINE_RULE );
416 // <--
417 // #115901#
418 AddNumRule(pOutlineRule);
419 // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()>
420 pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) );
421 // <--
423 new SwTxtNode( SwNodeIndex( aUndoNodes.GetEndOfContent() ), pDfltTxtFmtColl );
424 new SwTxtNode( SwNodeIndex( aNodes.GetEndOfContent() ),
425 GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
427 // den eigenen IdleTimer setzen
428 aIdleTimer.SetTimeout( 600 );
429 aIdleTimer.SetTimeoutHdl( LINK(this, SwDoc, DoIdleJobs) );
431 aOLEModifiedTimer.SetTimeout( 1000 );
432 aOLEModifiedTimer.SetTimeoutHdl( LINK( this, SwDoc, DoUpdateModifiedOLE ));
434 // DBMgr anlegen
435 pNewDBMgr = new SwNewDBMgr;
437 // create TOXTypes
438 InitTOXTypes();
440 // --> OD 2008-03-07 #refactorlists#
441 // pass empty item set containing the paragraph's list attributes
442 // as ignorable items to the stype manager.
444 SfxItemSet aIgnorableParagraphItems( GetAttrPool(),
445 RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
446 0 );
447 pStyleAccess = createStyleManager( &aIgnorableParagraphItems );
449 // <--
451 ResetModified();
455 * Besonderheiten: an der Position 0 des Arrays der Formate und
456 * der GDI-Objekte befindet sich ein Member der Klasse SwDoc.
457 * Dieser darf also keinesfalls durch delete geloescht
458 * werden!!!!!!!!!!
462 SwDoc::~SwDoc()
464 // --> OD 2007-03-16 #i73788#
465 SwPauseThreadStarting aPauseThreadStarting;
466 // <--
468 // --> OD 2007-11-01 #i83479#
469 delete mpListItemsList;
470 mpListItemsList = 0;
471 // <--
473 // clean up chart related structures...
474 // Note: the chart data provider gets already diposed in ~SwDocShell
475 // since all UNO API related functionality requires an existing SwDocShell
476 // this assures that dipose gets called if there is need for it.
477 aChartDataProviderImplRef.reset();
478 delete pChartControllerHelper;
480 delete mpGrammarContact;
481 mpGrammarContact = 0;
483 //!! needs to be done to destroy a possible SwFmtDrop format that may
484 //!! be connected to a char format which may not otherwise be removed
485 //!! and thus would leave a unremoved SwFmt object. (TL)
486 //!! (this is case is not possible via UI but via API...)
487 SwFmtDrop aDrop;
488 SetDefault(aDrop);
489 //!! same for SwFmtCharFmt
490 SwFmtCharFmt aCharFmt(NULL);
491 SetDefault(aCharFmt);
493 StopIdling(); // stop idle timer
495 delete pUnoCallBack, pUnoCallBack = 0;
496 delete pURLStateChgd;
498 delete pLayouter;
499 // --> OD 2005-09-05 #125370#
500 pLayouter = 0L;
501 // <--
503 // Undo-Benachrichtigung vom Draw abschalten
504 if( pDrawModel )
506 DrawNotifyUndoHdl();
507 ClrContourCache();
510 delete pPgPViewPrtData;
512 mbUndo = FALSE; // immer das Undo abschalten !!
513 // damit die Fussnotenattribute die Fussnotennodes in Frieden lassen.
514 mbDtor = TRUE;
516 DELETEZ( pLayout );
518 delete pRedlineTbl;
519 delete pUnoCrsrTbl;
520 delete pAutoFmtRedlnComment;
522 if( pUpdtFlds )
523 delete pUpdtFlds;
525 if( pACEWord )
526 delete pACEWord;
528 // die BaseLinks freigeben.
530 for( USHORT n = pLinkMgr->GetServers().Count(); n; )
531 pLinkMgr->GetServers()[ --n ]->Closed();
533 if( pLinkMgr->GetLinks().Count() )
534 pLinkMgr->Remove( 0, pLinkMgr->GetLinks().Count() );
537 // die KapitelNummern / Nummern muessen vor den Vorlage geloescht werden
538 // ansonsten wird noch staendig geupdatet !!!
539 aNodes.pOutlineNds->Remove( USHORT(0), aNodes.pOutlineNds->Count() );
540 aUndoNodes.pOutlineNds->Remove( USHORT(0), aUndoNodes.pOutlineNds->Count() );
542 pFtnIdxs->Remove( USHORT(0), pFtnIdxs->Count() );
544 pUndos->DeleteAndDestroy( 0, pUndos->Count() ); //Es koennen in den Attributen noch
545 //noch indizes angemeldet sein.
547 // in den BookMarks sind Indizies auf den Content. Diese muessen vorm
548 // loesche der Nodes geloescht werden.
549 pMarkManager->clearAllMarks();
550 DELETEZ( pMacroTable );
552 if( pExtInputRing )
554 Ring* pTmp = pExtInputRing;
555 pExtInputRing = 0;
556 while( pTmp->GetNext() != pTmp )
557 delete pTmp->GetNext();
558 delete pTmp;
561 //JP: alt - loeschen ohne Flag ist teuer; Modify wird verschickt!
562 // aTOXTypes.DeleteAndDestroy( 0, aTOXTypes.Count() );
564 for( USHORT n = pTOXTypes->Count(); n; )
566 (*pTOXTypes)[ --n ]->SetInDocDTOR();
567 delete (*pTOXTypes)[ n ];
569 pTOXTypes->Remove( 0, pTOXTypes->Count() );
571 delete pDefTOXBases;
573 //Im einen oder anderen FrmFormat koennen noch Indizes angemeldet sein,
574 //Diese muessen spaetestens jetzt zerstoert werden.
575 pFrmFmtTbl->ForEach( &lcl_DelFmtIndizes, this );
576 pSpzFrmFmtTbl->ForEach( &lcl_DelFmtIndizes, this );
577 ((SwFrmFmts&)*pSectionFmtTbl).ForEach( &lcl_DelFmtIndizes, this );
579 //Die Formate, die hier hinter stehen sind von den DefaultFormaten
580 //abhaengig. Erst nach dem Loeschen der FmtIndizes weil der Inhalt von
581 //Kopf-/Fussbereichen geloescht wird. Wenn dort noch Indizes von Flys
582 //angemeldet sind gibts was an die Ohren.
583 aPageDescs.DeleteAndDestroy( 0, aPageDescs.Count() );
585 // Inhaltssections loeschen
586 // nicht erst durch den SwNodes-DTOR, damit Formate
587 // keine Abhaengigen mehr haben.
588 aNodes.DelNodes( SwNodeIndex( aNodes ), aNodes.Count() );
589 aUndoNodes.DelNodes( SwNodeIndex( aUndoNodes ), aUndoNodes.Count() );
591 // Formate loeschen, spaeter mal permanent machen.
593 // Delete fuer Collections
594 // damit die Abhaengigen wech sind
595 SwTxtFmtColl *pFtnColl = pFtnInfo->GetFtnTxtColl();
596 if ( pFtnColl ) pFtnColl->Remove(pFtnInfo);
597 pFtnColl = pEndNoteInfo->GetFtnTxtColl();
598 if ( pFtnColl ) pFtnColl->Remove(pEndNoteInfo);
600 ASSERT( pDfltTxtFmtColl == (*pTxtFmtCollTbl)[0],
601 "Default-Text-Collection muss immer am Anfang stehen" );
603 // JP 27.01.98: opt.: ausgehend davon, das Standard als 2. im Array
604 // steht, sollte das als letztes geloescht werden, damit
605 // die ganze Umhaengerei der Formate vermieden wird!
606 if( 2 < pTxtFmtCollTbl->Count() )
607 pTxtFmtCollTbl->DeleteAndDestroy( 2, pTxtFmtCollTbl->Count()-2 );
608 pTxtFmtCollTbl->DeleteAndDestroy( 1, pTxtFmtCollTbl->Count()-1 );
609 delete pTxtFmtCollTbl;
611 ASSERT( pDfltGrfFmtColl == (*pGrfFmtCollTbl)[0],
612 "Default-Grf-Collection muss immer am Anfang stehen" );
614 pGrfFmtCollTbl->DeleteAndDestroy( 1, pGrfFmtCollTbl->Count()-1 );
615 // ergibt sich automatisch - kein _DEL Array!
616 // pGrfFmtCollTbl->Remove( 0, n );
617 delete pGrfFmtCollTbl;
620 * Defaultformate und DefaultFormatsammlungen (FmtColl)
621 * sind an der Position 0 der jeweiligen Arrays eingetragen.
622 * Damit sie nicht vom DTOR der Array's zum 2.mal geloescht werden,
623 * nehme sie aus dem Array.
625 pFrmFmtTbl->Remove( 0 );
626 pCharFmtTbl->Remove( 0 );
628 // Delete fuer pPrt
629 DELETEZ( pPrt );
630 DELETEZ( pNewDBMgr );
632 // Alle Flys muessen vor dem Drawing Model zerstoert werden,
633 // da Flys noch DrawContacts enthalten koennen, wenn wegen
634 // eines Lesefehlers kein Layout aufgebaut wurde.
635 pSpzFrmFmtTbl->DeleteAndDestroy( 0, pSpzFrmFmtTbl->Count() );
637 //Erst jetzt das Model zerstoeren, die Zeichenobjekte - die ja auch
638 //im Undo herumlungern - wollen noch ihre Attribute beim Model entfernen.
639 //Ausserdem koennen vorher noch DrawContacts existieren.
640 ReleaseDrawModel();
641 //JP 28.01.99: DrawModel vorm LinkManager zerstoeren, da am DrawModel
642 // dieser immer gesetzt ist.
643 DELETEZ( pLinkMgr );
645 //Tables vor dem loeschen der Defaults leeren, sonst GPF wegen Def-Abhaengigen.
646 //Die Arrays sollten (wegen includes) bei Gelegenheit auch zu Pointern werden.
647 delete pFrmFmtTbl;
648 delete pSpzFrmFmtTbl;
650 delete pStyleAccess;
652 delete pCharFmtTbl;
653 delete pSectionFmtTbl;
654 delete pTblFrmFmtTbl;
655 delete pDfltTxtFmtColl;
656 delete pDfltGrfFmtColl;
657 delete pNumRuleTbl;
659 // --> OD 2008-03-26 #refactorlists#
661 for ( std::hash_map< String, SwList*, StringHash >::iterator
662 aListIter = maLists.begin();
663 aListIter != maLists.end();
664 ++aListIter )
666 delete (*aListIter).second;
668 maLists.clear();
670 maListStyleLists.clear();
671 // <--
673 delete pPrtData;
674 delete pNumberFormatter;
675 delete pFtnInfo;
676 delete pEndNoteInfo;
677 delete pLineNumberInfo;
678 delete pFtnIdxs;
679 delete pFldTypes;
680 delete pTOXTypes;
681 delete pUndos;
682 delete pDocStat;
683 delete pEmptyPageFmt;
684 delete pColumnContFmt;
685 delete pDfltCharFmt;
686 delete pDfltFrmFmt;
687 delete pLayoutCache;
688 delete pVirDev;
690 SfxItemPool::Free(mpAttrPool);
693 //---------------------------------------------------
695 VirtualDevice& SwDoc::CreateVirtualDevice_() const
697 VirtualDevice* pNewVir = new VirtualDevice( 1 );
699 // <--
700 pNewVir->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
702 // --> FME 2006-10-09 #i60945# External leading compatibility for unix systems.
703 if ( get(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING ) )
704 pNewVir->Compat_ZeroExtleadBug();
705 // <--
707 MapMode aMapMode( pNewVir->GetMapMode() );
708 aMapMode.SetMapUnit( MAP_TWIP );
709 pNewVir->SetMapMode( aMapMode );
711 const_cast<SwDoc*>(this)->setVirtualDevice( pNewVir, true, true );
712 return *pVirDev;
715 //---------------------------------------------------
717 SfxPrinter& SwDoc::CreatePrinter_() const
719 ASSERT( ! pPrt, "Do not call CreatePrinter_(), call getPrinter() instead" )
721 #if OSL_DEBUG_LEVEL > 1
722 ASSERT( false, "Printer will be created!" )
723 #endif
725 // wir erzeugen einen default SfxPrinter.
726 // Das ItemSet wird vom Sfx geloescht!
727 SfxItemSet *pSet = new SfxItemSet( ((SwDoc*)this)->GetAttrPool(),
728 FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
729 SID_HTML_MODE, SID_HTML_MODE,
730 SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
731 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
732 0 );
734 SfxPrinter* pNewPrt = new SfxPrinter( pSet );
735 const_cast<SwDoc*>(this)->setPrinter( pNewPrt, true, true );
736 return *pPrt;
738 //---------------------------------------------------
740 void SwDoc::SetDocShell( SwDocShell* pDSh )
742 if( pDocShell != pDSh )
744 pDocShell = pDSh;
746 pLinkMgr->SetPersist( pDocShell );
747 //JP 27.08.98: Bug 55570 - DocShell Pointer auch am DrawModel setzen
748 if( pDrawModel )
750 ((SwDrawDocument*)pDrawModel)->SetObjectShell( pDocShell );
751 pDrawModel->SetPersist( pDocShell );
752 ASSERT( pDrawModel->GetPersist() == GetPersist(),
753 "draw model's persist is out of sync" );
759 // Convenience-Methode, um uebermaessige Includes von docsh.hxx
760 // zu vermeiden
764 uno::Reference < embed::XStorage > SwDoc::GetDocStorage()
766 if( pDocShell )
767 return pDocShell->GetStorage();
768 if( pLinkMgr->GetPersist() )
769 return pLinkMgr->GetPersist()->GetStorage();
770 return NULL;
775 SfxObjectShell* SwDoc::GetPersist() const
777 return pDocShell ? pDocShell : pLinkMgr->GetPersist();
781 void SwDoc::ClearDoc()
783 BOOL bOldUndo = mbUndo;
784 DelAllUndoObj();
785 mbUndo = FALSE; // immer das Undo abschalten !!
787 // Undo-Benachrichtigung vom Draw abschalten
788 if( pDrawModel )
790 DrawNotifyUndoHdl();
791 ClrContourCache();
794 // stehen noch FlyFrames rum, loesche auch diese
795 USHORT n;
796 while ( 0 != (n = GetSpzFrmFmts()->Count()) )
797 DelLayoutFmt((*pSpzFrmFmtTbl)[n-1]);
798 ASSERT( !pDrawModel || !pDrawModel->GetPage(0)->GetObjCount(),
799 "not all DrawObjects removed from the page" );
801 pRedlineTbl->DeleteAndDestroy( 0, pRedlineTbl->Count() );
803 if( pACEWord )
804 delete pACEWord;
806 // in den BookMarks sind Indizies auf den Content. Diese muessen vorm
807 // loesche der Nodes geloescht werden.
808 pMarkManager->clearAllMarks();
809 InitTOXTypes();
811 // create a dummy pagedesc for the layout
812 sal_uInt16 nDummyPgDsc = MakePageDesc( String::CreateFromAscii( "?DUMMY?" ));
813 SwPageDesc* pDummyPgDsc = aPageDescs[ nDummyPgDsc ];
815 SwNodeIndex aSttIdx( *GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
816 // den ersten immer wieder neu anlegen (ohne Attribute/Vorlagen/...)
817 SwTxtNode* pFirstNd = GetNodes().MakeTxtNode( aSttIdx, pDfltTxtFmtColl );
819 if( pLayout )
821 // set the layout to the dummy pagedesc
822 pFirstNd->SetAttr( SwFmtPageDesc( pDummyPgDsc ));
824 SwPosition aPos( *pFirstNd, SwIndex( pFirstNd ));
825 ::PaMCorrAbs( aSttIdx, SwNodeIndex( GetNodes().GetEndOfContent() ),
826 aPos );
829 GetNodes().Delete( aSttIdx,
830 GetNodes().GetEndOfContent().GetIndex() - aSttIdx.GetIndex() );
832 // --> OD 2006-02-28 #i62440#
833 // destruction of numbering rules and creation of new outline rule
834 // *after* the document nodes are deleted.
835 pOutlineRule = NULL;
836 pNumRuleTbl->DeleteAndDestroy( 0, pNumRuleTbl->Count() );
837 // creation of new outline numbering rule
838 // --> OD 2008-02-11 #newlistlevelattrs#
839 pOutlineRule = new SwNumRule( String::CreateFromAscii( SwNumRule::GetOutlineRuleName() ),
840 // --> OD 2008-06-06 #i89178#
841 numfunc::GetDefaultPositionAndSpaceMode(),
842 // <--
843 OUTLINE_RULE );
844 // <--
845 AddNumRule(pOutlineRule);
846 // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()>
847 pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) );
848 // <--
849 // <--
851 //remove the dummy pagedec from the array and delete all the old ones
852 aPageDescs.Remove( nDummyPgDsc );
853 aPageDescs.DeleteAndDestroy( 0, aPageDescs.Count() );
855 // Delete fuer Collections
856 // damit die Abhaengigen wech sind
857 SwTxtFmtColl* pFtnColl = pFtnInfo->GetFtnTxtColl();
858 if( pFtnColl ) pFtnColl->Remove( pFtnInfo );
859 pFtnColl = pEndNoteInfo->GetFtnTxtColl();
860 if( pFtnColl ) pFtnColl->Remove( pEndNoteInfo );
862 // JP 27.01.98: opt.: ausgehend davon, das Standard als 2. im Array
863 // steht, sollte das als letztes geloescht werden, damit
864 // die ganze Umhaengerei der Formate vermieden wird!
865 if( 2 < pTxtFmtCollTbl->Count() )
866 pTxtFmtCollTbl->DeleteAndDestroy( 2, pTxtFmtCollTbl->Count()-2 );
867 pTxtFmtCollTbl->DeleteAndDestroy( 1, pTxtFmtCollTbl->Count()-1 );
868 pGrfFmtCollTbl->DeleteAndDestroy( 1, pGrfFmtCollTbl->Count()-1 );
869 pCharFmtTbl->DeleteAndDestroy( 1, pCharFmtTbl->Count()-1 );
871 if( pLayout )
873 // search the FrameFormat of the root frm. This is not allowed to delete
874 pFrmFmtTbl->Remove( pFrmFmtTbl->GetPos( pLayout->GetFmt() ) );
875 pFrmFmtTbl->DeleteAndDestroy( 1, pFrmFmtTbl->Count()-1 );
876 pFrmFmtTbl->Insert( pLayout->GetFmt(), pFrmFmtTbl->Count() );
878 else
879 pFrmFmtTbl->DeleteAndDestroy( 1, pFrmFmtTbl->Count()-1 );
881 xForbiddenCharsTable.unbind();
883 pFldTypes->DeleteAndDestroy( INIT_FLDTYPES,
884 pFldTypes->Count() - INIT_FLDTYPES );
886 delete pNumberFormatter, pNumberFormatter = 0;
888 GetPageDescFromPool( RES_POOLPAGE_STANDARD );
889 pFirstNd->ChgFmtColl( GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
890 nDummyPgDsc = aPageDescs.Count();
891 aPageDescs.Insert( pDummyPgDsc, nDummyPgDsc );
892 // set the layout back to the new standard pagedesc
893 pFirstNd->ResetAllAttr();
894 // delete now the dummy pagedesc
895 DelPageDesc( nDummyPgDsc );
897 mbUndo = bOldUndo;
900 void SwDoc::SetPreViewPrtData( const SwPagePreViewPrtData* pNew )
902 if( pNew )
904 if( pPgPViewPrtData )
905 *pPgPViewPrtData = *pNew;
906 else
907 pPgPViewPrtData = new SwPagePreViewPrtData( *pNew );
909 else if( pPgPViewPrtData )
910 DELETEZ( pPgPViewPrtData );
911 SetModified();
913 /* -----------------------------06.01.00 14:03--------------------------------
915 ---------------------------------------------------------------------------*/
916 SwModify* SwDoc::GetUnoCallBack() const
918 return pUnoCallBack;
921 /*-----------------28.5.2001 10:06------------------
922 * SwDoc:
923 * Reading and writing of the layout cache.
924 *--------------------------------------------------*/
926 void SwDoc::ReadLayoutCache( SvStream& rStream )
928 if( !pLayoutCache )
929 pLayoutCache = new SwLayoutCache();
930 if( !pLayoutCache->IsLocked() )
932 pLayoutCache->GetLockCount() |= 0x8000;
933 pLayoutCache->Read( rStream );
934 pLayoutCache->GetLockCount() &= 0x7fff;
938 void SwDoc::WriteLayoutCache( SvStream& rStream )
940 pLayoutCache->Write( rStream, *this );
943 IGrammarContact* getGrammarContact( const SwTxtNode& rTxtNode )
945 const SwDoc* pDoc = rTxtNode.GetDoc();
946 if( !pDoc || pDoc->IsInDtor() )
947 return 0;
948 return pDoc->getGrammarContact();
951 // --> FME 2005-02-25 #i42634# Moved common code of SwReader::Read() and
952 // SwDocShell::UpdateLinks() to new SwDoc::UpdateLinks():
953 void SwDoc::UpdateLinks( BOOL bUI )
955 SfxObjectCreateMode eMode;
956 USHORT nLinkMode = getLinkUpdateMode( true );
957 USHORT nUpdateDocMode = GetDocShell()->GetUpdateDocMode();
958 if( GetDocShell() &&
959 (nLinkMode != NEVER || document::UpdateDocMode::FULL_UPDATE == nUpdateDocMode) &&
960 GetLinkManager().GetLinks().Count() &&
961 SFX_CREATE_MODE_INTERNAL !=
962 ( eMode = GetDocShell()->GetCreateMode()) &&
963 SFX_CREATE_MODE_ORGANIZER != eMode &&
964 SFX_CREATE_MODE_PREVIEW != eMode &&
965 !GetDocShell()->IsPreview() )
967 ViewShell* pVSh = 0;
968 BOOL bAskUpdate = nLinkMode == MANUAL;
969 BOOL bUpdate = TRUE;
970 switch(nUpdateDocMode)
972 case document::UpdateDocMode::NO_UPDATE: bUpdate = FALSE;break;
973 case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = FALSE; break;
974 case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = TRUE; break;
976 if( bUpdate && (bUI || !bAskUpdate) )
978 SfxMedium* pMedium = GetDocShell()->GetMedium();
979 SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0;
980 Window* pDlgParent = pFrm ? &pFrm->GetWindow() : 0;
981 if( GetRootFrm() && !GetEditShell( &pVSh ) && !pVSh )
983 ViewShell aVSh( *this, 0, 0 );
985 SET_CURR_SHELL( &aVSh );
986 GetLinkManager().UpdateAllLinks( bAskUpdate , TRUE, FALSE, pDlgParent );
988 else
989 GetLinkManager().UpdateAllLinks( bAskUpdate, TRUE, FALSE, pDlgParent );
994 // <--
995 // --> OD 2006-04-19 #b6375613#
996 void SwDoc::SetApplyWorkaroundForB6375613( bool p_bApplyWorkaroundForB6375613 )
998 if ( mbApplyWorkaroundForB6375613 != p_bApplyWorkaroundForB6375613 )
1000 mbApplyWorkaroundForB6375613 = p_bApplyWorkaroundForB6375613;
1002 uno::Reference< document::XDocumentInfoSupplier > xDoc(
1003 GetDocShell()->GetBaseModel(),
1004 uno::UNO_QUERY);
1005 if ( xDoc.is() )
1007 uno::Reference< beans::XPropertyContainer > xDocInfo(
1008 xDoc->getDocumentInfo(),
1009 uno::UNO_QUERY );
1010 if ( xDocInfo.is() )
1014 if ( mbApplyWorkaroundForB6375613 )
1016 xDocInfo->addProperty(
1017 rtl::OUString::createFromAscii("WorkaroundForB6375613Applied"),
1018 beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::REMOVABLE,
1019 uno::makeAny( false ) );
1021 else
1023 xDocInfo->removeProperty( rtl::OUString::createFromAscii("WorkaroundForB6375613Applied") );
1026 catch( uno::Exception& )
1033 // <--
1035 ::sfx2::IXmlIdRegistry&
1036 SwDoc::GetXmlIdRegistry()
1038 // UGLY: this relies on SetClipBoard being called before GetXmlIdRegistry!
1039 if (!m_pXmlIdRegistry.get())
1041 m_pXmlIdRegistry.reset( ::sfx2::createXmlIdRegistry( IsClipBoard() ) );
1043 return *m_pXmlIdRegistry;
1046 ::sw::MetaFieldManager &
1047 SwDoc::GetMetaFieldManager()
1049 return *m_pMetaFieldManager;
1052 void SwDoc::InitTOXTypes()
1054 ShellResource* pShellRes = ViewShell::GetShellRes();
1055 SwTOXType * pNew = new SwTOXType(TOX_CONTENT, pShellRes->aTOXContentName );
1056 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1057 pNew = new SwTOXType(TOX_INDEX, pShellRes->aTOXIndexName );
1058 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1059 pNew = new SwTOXType(TOX_USER, pShellRes->aTOXUserName );
1060 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1061 pNew = new SwTOXType(TOX_ILLUSTRATIONS, pShellRes->aTOXIllustrationsName );
1062 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1063 pNew = new SwTOXType(TOX_OBJECTS, pShellRes->aTOXObjectsName );
1064 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1065 pNew = new SwTOXType(TOX_TABLES, pShellRes->aTOXTablesName );
1066 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1067 pNew = new SwTOXType(TOX_AUTHORITIES, pShellRes->aTOXAuthoritiesName );
1068 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1071 /*-- 08.05.2009 10:07:57---------------------------------------------------
1073 -----------------------------------------------------------------------*/
1074 SwDoc* SwDoc::CreateCopy() const
1076 SwDoc* pRet = new SwDoc;
1077 //copy settings
1079 //aNodes( this ),
1080 //aUndoNodes( this ),
1081 mpAttrPool(new SwAttrPool(this)),*/
1082 USHORT __FAR_DATA aRangeOfDefaults[] = {
1083 RES_FRMATR_BEGIN, RES_FRMATR_END-1,
1084 RES_CHRATR_BEGIN, RES_CHRATR_END-1,
1085 RES_PARATR_BEGIN, RES_PARATR_END-1,
1086 // --> OD 2008-02-25 #refactorlists##
1087 RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
1088 // <--
1089 RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
1093 SfxItemSet aNewDefaults( pRet->GetAttrPool(), aRangeOfDefaults );
1095 USHORT nWhich;
1096 USHORT nRange = 0;
1097 while( aRangeOfDefaults[nRange] != 0)
1099 for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich )
1101 const SfxPoolItem& rSourceAttr = mpAttrPool->GetDefaultItem( nWhich );
1102 if( rSourceAttr != pRet->mpAttrPool->GetDefaultItem( nWhich ) )
1103 aNewDefaults.Put( rSourceAttr );
1105 nRange += 2;
1107 if( aNewDefaults.Count() )
1108 pRet->SetDefault( aNewDefaults );
1111 pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
1112 pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ),
1113 pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ),
1114 pDfltCharFmt( new SwCharFmt( GetAttrPool(), sCharFmtStr, 0 ) ),
1115 pDfltTxtFmtColl( new SwTxtFmtColl( GetAttrPool(), sTxtCollStr ) ),
1116 pDfltGrfFmtColl( new SwGrfFmtColl( GetAttrPool(), sGrfCollStr ) ),
1117 pFrmFmtTbl( new SwFrmFmts() ),
1118 pCharFmtTbl( new SwCharFmts() ),
1119 pSpzFrmFmtTbl( new SwSpzFrmFmts() ),
1120 pSectionFmtTbl( new SwSectionFmts() ),
1121 pTblFrmFmtTbl( new SwFrmFmts() ),
1122 pTxtFmtCollTbl( new SwTxtFmtColls() ),
1123 pGrfFmtCollTbl( new SwGrfFmtColls() ),
1124 pBookmarkTbl( new SwBookmarks( 0, 16 ) ),
1125 pTOXTypes( new SwTOXTypes() ),
1126 pDefTOXBases( new SwDefTOXBase_Impl() ),
1127 pLayout( 0 ), // Rootframe des spezifischen Layouts.
1128 pDrawModel( 0 ),
1129 pUndos( new SwUndos( 0, 20 ) ),
1130 pUpdtFlds( new SwDocUpdtFld() ),
1131 pFldTypes( new SwFldTypes() ),
1132 pVirDev( 0 ),
1133 pPrt( 0 ),
1134 pPrtData( 0 ),
1135 pGlossaryDoc( 0 ),
1136 pOutlineRule( 0 ),
1137 pFtnInfo( new SwFtnInfo ),
1138 pEndNoteInfo( new SwEndNoteInfo ),
1139 pLineNumberInfo( new SwLineNumberInfo ),
1140 pFtnIdxs( new SwFtnIdxs ),
1141 pDocStat( new SwDocStat ),
1142 pDocShell( 0 ),
1143 pDocShRef( 0 ),
1144 pLinkMgr( new SvxLinkManager( 0 ) ),
1145 pACEWord( 0 ),
1146 pURLStateChgd( 0 ),
1147 pNumberFormatter( 0 ),
1148 pNumRuleTbl( new SwNumRuleTbl ),
1149 // --> OD 2008-03-26 #refactorlists#
1150 maLists(),
1151 maListStyleLists(),
1152 // <--
1153 pRedlineTbl( new SwRedlineTbl ),
1154 pAutoFmtRedlnComment( 0 ),
1155 pUnoCrsrTbl( new SwUnoCrsrTbl( 0, 16 ) ),
1156 pPgPViewPrtData( 0 ),
1157 pExtInputRing( 0 ),
1158 pLayouter( 0 ),
1159 // --> OD 2008-03-07 #refactorlists#
1160 pStyleAccess( 0 ),
1161 // <--
1162 pLayoutCache( 0 ),
1163 pUnoCallBack(new SwUnoCallBack(0)),
1164 mpGrammarContact( 0 ),
1165 aChartDataProviderImplRef(),
1166 pChartControllerHelper( 0 ),
1167 // --> OD 2007-10-31 #i83479#
1168 mpListItemsList( new tImplSortedNodeNumList() ),
1169 // <--
1170 nUndoPos( 0 ),
1171 nUndoSavePos( 0 ),
1172 nUndoCnt( 0 ),
1173 nUndoSttEnd( 0 ),
1174 nAutoFmtRedlnCommentNo( 0 ),
1175 nLinkUpdMode( GLOBALSETTING ),
1176 eFldUpdMode( AUTOUPD_GLOBALSETTING ),
1177 eRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)),
1178 eChrCmprType( CHARCOMPRESS_NONE ),
1179 mReferenceCount(0),
1180 mIdleBlockCount(0),
1181 nLockExpFld( 0 ),
1182 mbReadlineChecked(false),
1183 mbWinEncryption(sal_False),
1184 // --> OD 2005-02-11 #i38810#
1185 mbLinksUpdated( sal_False ),
1186 mbClipBoard( false ),
1187 mbColumnSelection( false ),
1188 // i#78591#
1189 mbProtectForm(false),*/
1190 pRet->n32DummyCompatabilityOptions1 = n32DummyCompatabilityOptions1;
1191 pRet->n32DummyCompatabilityOptions2 = n32DummyCompatabilityOptions2;
1193 mbStartIdleTimer(sal_False)
1195 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDoc::SwDoc" );
1197 mbGlossDoc =
1198 mbModified =
1199 mbDtor =
1200 mbUndo =
1201 mbPageNums =
1202 mbLoaded =
1203 mbUpdateExpFld =
1204 mbNewDoc =
1205 mbCopyIsMove =
1206 mbNoDrawUndoObj =
1207 mbBrowseMode =
1208 mbInReading =
1209 mbInXMLImport =
1210 mbUpdateTOX =
1211 mbInLoadAsynchron =
1212 mbHTMLMode =
1213 mbInCallModified =
1214 mbIsGlobalDoc =
1215 mbGlblDocSaveLinks =
1216 mbIsLabelDoc =
1217 mbIsAutoFmtRedline =
1218 mbOLEPrtNotifyPending =
1219 mbAllOLENotify =
1220 mbIsRedlineMove =
1221 mbInsOnlyTxtGlssry =
1222 mbContains_MSVBasic =
1223 mbKernAsianPunctuation =
1224 #ifndef PRODUCT
1225 mbXMLExport =
1226 #endif
1227 // --> OD 2006-03-21 #b6375613#
1228 mbApplyWorkaroundForB6375613 =
1229 // <--
1230 false;
1232 mbGroupUndo =
1233 mbNewFldLst =
1234 mbVisibleLinks =
1235 mbPurgeOLE =
1236 true;
1239 // COMPATIBILITY FLAGS START
1242 // Note: Any non-hidden compatibility flag should obtain its default
1243 // by asking SvtCompatibilityOptions, see below.
1245 const SvtCompatibilityOptions aOptions;
1247 pRet->mbParaSpaceMax = mbParaSpaceMax ;
1248 pRet->mbParaSpaceMaxAtPages = mbParaSpaceMaxAtPages ;
1249 pRet->mbTabCompat = mbTabCompat ;
1250 pRet->mbUseVirtualDevice = mbUseVirtualDevice ;
1251 pRet->mbAddExternalLeading = mbAddExternalLeading ;
1252 pRet->mbOldLineSpacing = mbOldLineSpacing ;
1253 pRet->mbAddParaSpacingToTableCells = mbAddParaSpacingToTableCells ;
1254 pRet->mbUseFormerObjectPos = mbUseFormerObjectPos ;
1255 pRet->mbUseFormerTextWrapping = mbUseFormerTextWrapping ;
1256 pRet->mbConsiderWrapOnObjPos = mbConsiderWrapOnObjPos ;
1257 pRet->mbAddFlyOffsets = mbAddFlyOffsets ;
1258 pRet->mbOldNumbering = mbOldNumbering ;
1259 pRet->mbUseHiResolutionVirtualDevice = mbUseHiResolutionVirtualDevice ;
1260 pRet->mbIgnoreFirstLineIndentInNumbering = mbIgnoreFirstLineIndentInNumbering ;
1261 pRet->mbDoNotJustifyLinesWithManualBreak = mbDoNotJustifyLinesWithManualBreak ;
1262 pRet->mbDoNotResetParaAttrsForNumFont = mbDoNotResetParaAttrsForNumFont ;
1263 pRet->mbOutlineLevelYieldsOutlineRule = mbOutlineLevelYieldsOutlineRule ;
1264 pRet->mbTableRowKeep = mbTableRowKeep ;
1265 pRet->mbIgnoreTabsAndBlanksForLineCalculation = mbIgnoreTabsAndBlanksForLineCalculation ;
1266 pRet->mbDoNotCaptureDrawObjsOnPage = mbDoNotCaptureDrawObjsOnPage ;
1267 pRet->mbClipAsCharacterAnchoredWriterFlyFrames= mbClipAsCharacterAnchoredWriterFlyFrames;
1268 pRet->mbUnixForceZeroExtLeading = mbUnixForceZeroExtLeading ;
1269 pRet->mbOldPrinterMetrics = mbOldPrinterMetrics ;
1270 pRet->mbTabRelativeToIndent = mbTabRelativeToIndent ;
1271 pRet->mbTabAtLeftIndentForParagraphsInList = mbTabAtLeftIndentForParagraphsInList ;
1274 // COMPATIBILITY FLAGS END
1277 pMacroTable = new SvxMacroTableDtor;
1279 mpGrammarContact = ::createGrammarContact();
1281 // Formate
1282 pFrmFmtTbl->Insert(pDfltFrmFmt, 0 );
1283 pCharFmtTbl->Insert(pDfltCharFmt, 0 );
1285 // FmtColls
1286 // TXT
1287 pTxtFmtCollTbl->Insert(pDfltTxtFmtColl, 0 );
1288 // GRF
1289 pGrfFmtCollTbl->Insert(pDfltGrfFmtColl, 0 );
1291 // PageDesc, EmptyPageFmt und ColumnFmt anlegen
1292 if ( !aPageDescs.Count() )
1293 GetPageDescFromPool( RES_POOLPAGE_STANDARD );
1295 //Leere Seite Einstellen.
1296 pEmptyPageFmt->SetFmtAttr( SwFmtFrmSize( ATT_FIX_SIZE ) );
1297 //BodyFmt fuer Spalten Einstellen.
1298 pColumnContFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ) );
1300 _InitFieldTypes();
1302 // lege (fuer die Filter) eine Default-OutlineNumRule an
1303 // --> OD 2008-02-11 #newlistlevelattrs#
1304 pOutlineRule = new SwNumRule( String::CreateFromAscii( SwNumRule::GetOutlineRuleName() ),
1305 // --> OD 2008-06-06 #i89178#
1306 numfunc::GetDefaultPositionAndSpaceMode(),
1307 // <--
1308 OUTLINE_RULE );
1309 // <--
1310 // #115901#
1311 AddNumRule(pOutlineRule);
1312 // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()>
1313 pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) );
1314 // <--
1316 new SwTxtNode( SwNodeIndex( aUndoNodes.GetEndOfContent() ), pDfltTxtFmtColl );
1317 new SwTxtNode( SwNodeIndex( aNodes.GetEndOfContent() ),
1318 GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
1320 // den eigenen IdleTimer setzen
1321 aIdleTimer.SetTimeout( 600 );
1322 aIdleTimer.SetTimeoutHdl( LINK(this, SwDoc, DoIdleJobs) );
1324 aOLEModifiedTimer.SetTimeout( 1000 );
1325 aOLEModifiedTimer.SetTimeoutHdl( LINK( this, SwDoc, DoUpdateModifiedOLE ));
1327 // DBMgr anlegen
1328 pNewDBMgr = new SwNewDBMgr;
1330 // create TOXTypes
1331 ShellResource* pShellRes = ViewShell::GetShellRes();
1333 SwTOXType * pNew = new SwTOXType(TOX_CONTENT, pShellRes->aTOXContentName );
1334 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1335 pNew = new SwTOXType(TOX_INDEX, pShellRes->aTOXIndexName );
1336 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1337 pNew = new SwTOXType(TOX_USER, pShellRes->aTOXUserName );
1338 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1339 pNew = new SwTOXType(TOX_ILLUSTRATIONS, pShellRes->aTOXIllustrationsName );
1340 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1341 pNew = new SwTOXType(TOX_OBJECTS, pShellRes->aTOXObjectsName );
1342 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1343 pNew = new SwTOXType(TOX_TABLES, pShellRes->aTOXTablesName );
1344 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1345 pNew = new SwTOXType(TOX_AUTHORITIES, pShellRes->aTOXAuthoritiesName );
1346 pTOXTypes->Insert( pNew, pTOXTypes->Count() );
1349 SfxItemSet aIgnorableParagraphItems( GetAttrPool(),
1350 RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
1351 0 );
1352 pStyleAccess = createStyleManager( &aIgnorableParagraphItems );
1355 ResetModified();
1358 //copy content
1359 pRet->Paste( *this );
1360 return pRet;
1362 /*-- 08.05.2009 10:52:40---------------------------------------------------
1363 copy document content - code from SwFEShell::Paste( SwDoc* , BOOL )
1364 -----------------------------------------------------------------------*/
1365 void SwDoc::Paste( const SwDoc& rSource )
1367 // this has to be empty const USHORT nStartPageNumber = GetPhyPageNum();
1368 // until the end of the NodesArray
1369 SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 2 );
1370 SwPaM aCpyPam( aSourceIdx ); //DocStart
1371 SwNodeIndex aTargetIdx( GetNodes().GetEndOfExtras(), 2 );
1372 SwPaM aInsertPam( aTargetIdx ); //replaces PCURCRSR from SwFEShell::Paste()
1375 aCpyPam.SetMark();
1376 aCpyPam.Move( fnMoveForward, fnGoDoc );
1378 this->StartUndo( UNDO_INSGLOSSARY, NULL );
1379 this->LockExpFlds();
1382 SwPosition& rInsPos = *aInsertPam.GetPoint();
1383 //find out if the clipboard document starts with a table
1384 bool bStartWithTable = 0 != aCpyPam.Start()->nNode.GetNode().FindTableNode();
1385 SwPosition aInsertPosition( rInsPos );
1388 SwNodeIndex aIndexBefore(rInsPos.nNode);
1390 aIndexBefore--;
1392 rSource.CopyRange( aCpyPam, rInsPos, true );
1395 aIndexBefore++;
1396 SwPaM aPaM(SwPosition(aIndexBefore, 0),
1397 SwPosition(rInsPos.nNode, 0));
1399 MakeUniqueNumRules(aPaM);
1403 //TODO: Is this necessary here? SaveTblBoxCntnt( &rInsPos );
1404 if(/*bIncludingPageFrames && */bStartWithTable)
1406 //remove the paragraph in front of the table
1407 SwPaM aPara(aInsertPosition);
1408 this->DelFullPara(aPara);
1410 //additionally copy page bound frames
1411 if( /*bIncludingPageFrames && */rSource.GetSpzFrmFmts()->Count() )
1413 for ( USHORT i = 0; i < rSource.GetSpzFrmFmts()->Count(); ++i )
1415 BOOL bInsWithFmt = TRUE;
1416 const SwFrmFmt& rCpyFmt = *(*rSource.GetSpzFrmFmts())[i];
1417 if( bInsWithFmt )
1419 SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() );
1420 if( FLY_PAGE == aAnchor.GetAnchorId() )
1422 aAnchor.SetPageNum( aAnchor.GetPageNum() + /*nStartPageNumber - */1 );
1424 else
1425 continue;
1426 this->CopyLayoutFmt( rCpyFmt, aAnchor, true, true );
1432 this->EndUndo( UNDO_INSGLOSSARY, NULL );
1434 UnlockExpFlds();
1435 UpdateFlds(NULL, false);