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: doc.cxx,v $
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"
34 #include <hintids.hxx>
36 #include <tools/shl.hxx>
37 #include <tools/globname.hxx>
39 #include <com/sun/star/i18n/WordType.hdl>
40 #include <com/sun/star/i18n/ForbiddenCharacters.hdl>
41 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42 #include <com/sun/star/beans/NamedValue.hpp>
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
45 #include <com/sun/star/document/XDocumentProperties.hpp>
46 #include <comphelper/processfactory.hxx>
47 #include <tools/urlobj.hxx>
48 #include <tools/poly.hxx>
49 #include <vcl/virdev.hxx>
50 #include <svtools/itemiter.hxx>
51 #include <sfx2/printer.hxx>
52 #include <svx/keepitem.hxx>
53 #include <svx/cscoitem.hxx>
54 #include <svx/brkitem.hxx>
55 #include <svx/linkmgr.hxx>
56 #include <svx/forbiddencharacterstable.hxx>
57 #include <svx/svdmodel.hxx>
58 #include <unotools/charclass.hxx>
59 #include <swmodule.hxx>
60 #include <fmtpdsc.hxx>
61 #include <fmtanchr.hxx>
62 #include <fmtrfmrk.hxx>
63 #include <fmtinfmt.hxx>
67 #include <txtinet.hxx>
68 #include <txtrfmrk.hxx>
70 #include <linkenum.hxx>
72 #include <pagefrm.hxx>
73 #include <rootfrm.hxx>
74 #include <swtable.hxx>
77 #include <swundo.hxx> // fuer die UndoIds
79 #include <pagedesc.hxx> //DTor
80 #include <breakit.hxx>
83 #include <rolbck.hxx> // Undo-Attr
84 #include <doctxm.hxx> // fuer die Verzeichnisse
86 #include <poolfmt.hxx> // PoolVorlagen-Id's
87 #include <mvsave.hxx> // fuer Server-Funktionalitaet
88 #include <SwGrammarMarkUp.hxx>
89 #include <scriptinfo.hxx>
90 #include <acorrect.hxx> // Autokorrektur
91 #include <mdiexp.hxx> // Statusanzeige
92 #include <docstat.hxx>
94 #include <redline.hxx>
95 #include <fldupde.hxx>
96 #include <swbaslnk.hxx>
97 #include <printdata.hxx>
99 #include <cmdid.h> // fuer den dflt - Printer in SetJob
102 #include <statstr.hrc> // StatLine-String
104 #include <comcore.hrc>
105 #include <SwUndoTOXChange.hxx>
106 #include <SwUndoFmt.hxx>
107 #include <unocrsr.hxx>
111 #include <osl/diagnose.h>
112 #include <osl/interlck.h>
114 /* @@@MAINTAINABILITY-HORROR@@@
115 Probably unwanted dependency on SwDocShell
117 // --> OD 2005-08-29 #125370#
118 #include <layouter.hxx>
121 using namespace ::com::sun::star
;
123 // Seiten-Deskriptoren
124 SV_IMPL_PTRARR(SwPageDescs
,SwPageDescPtr
);
126 SV_IMPL_PTRARR( SwTOXTypes
, SwTOXTypePtr
)
128 SV_IMPL_PTRARR( SwFldTypes
, SwFldTypePtr
)
132 sal_Int32
SwDoc::acquire()
134 OSL_ASSERT(mReferenceCount
>= 0 && "Negative reference count detected! This is a sign for unbalanced acquire/release calls.");
135 return osl_incrementInterlockedCount(&mReferenceCount
);
138 sal_Int32
SwDoc::release()
140 OSL_PRECOND(mReferenceCount
>= 1, "Object is already released! Releasing it again leads to a negative reference count.");
141 return osl_decrementInterlockedCount(&mReferenceCount
);
144 sal_Int32
SwDoc::getReferenceCount() const
146 OSL_ASSERT(mReferenceCount
>= 0 && "Negative reference count detected! This is a sign for unbalanced acquire/release calls.");
147 return mReferenceCount
;
150 /** IDocumentSettingAccess
152 bool SwDoc::get(/*[in]*/ DocumentSettingId id
) const
156 // COMPATIBILITY FLAGS START
157 case PARA_SPACE_MAX
: return mbParaSpaceMax
; //(n8Dummy1 & DUMMY_PARASPACEMAX);
158 case PARA_SPACE_MAX_AT_PAGES
: return mbParaSpaceMaxAtPages
; //(n8Dummy1 & DUMMY_PARASPACEMAX_AT_PAGES);
159 case TAB_COMPAT
: return mbTabCompat
; //(n8Dummy1 & DUMMY_TAB_COMPAT);
160 case ADD_FLY_OFFSETS
: return mbAddFlyOffsets
; //(n8Dummy2 & DUMMY_ADD_FLY_OFFSETS);
161 case ADD_EXT_LEADING
: return mbAddExternalLeading
; //(n8Dummy2 & DUMMY_ADD_EXTERNAL_LEADING);
162 case USE_VIRTUAL_DEVICE
: return mbUseVirtualDevice
; //(n8Dummy1 & DUMMY_USE_VIRTUAL_DEVICE);
163 case USE_HIRES_VIRTUAL_DEVICE
: return mbUseHiResolutionVirtualDevice
; //(n8Dummy2 & DUMMY_USE_HIRES_VIR_DEV);
164 case OLD_NUMBERING
: return mbOldNumbering
;
165 case OLD_LINE_SPACING
: return mbOldLineSpacing
;
166 case ADD_PARA_SPACING_TO_TABLE_CELLS
: return mbAddParaSpacingToTableCells
;
167 case USE_FORMER_OBJECT_POS
: return mbUseFormerObjectPos
;
168 case USE_FORMER_TEXT_WRAPPING
: return mbUseFormerTextWrapping
;
169 case CONSIDER_WRAP_ON_OBJECT_POSITION
: return mbConsiderWrapOnObjPos
;
170 case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK
: return mbDoNotJustifyLinesWithManualBreak
;
171 case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING
: return mbIgnoreFirstLineIndentInNumbering
;
172 case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE
: return mbOutlineLevelYieldsOutlineRule
;
173 case TABLE_ROW_KEEP
: return mbTableRowKeep
;
174 case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION
: return mbIgnoreTabsAndBlanksForLineCalculation
;
175 case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE
: return mbDoNotCaptureDrawObjsOnPage
;
176 // --> OD 2006-08-25 #i68949#
177 case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME
: return mbClipAsCharacterAnchoredWriterFlyFrames
;
179 case UNIX_FORCE_ZERO_EXT_LEADING
: return mbUnixForceZeroExtLeading
;
180 case USE_OLD_PRINTER_METRICS
: return mbOldPrinterMetrics
;
181 case TABS_RELATIVE_TO_INDENT
: return mbTabRelativeToIndent
;
182 case PROTECT_FORM
: return mbProtectForm
;
183 // --> OD 2008-06-05 #i89181#
184 case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST
: return mbTabAtLeftIndentForParagraphsInList
;
186 case INVERT_BORDER_SPACING
: return mbInvertBorderSpacing
;
187 case COLLAPSE_EMPTY_CELL_PARA
: return mbCollapseEmptyCellPara
;
188 // COMPATIBILITY FLAGS END
190 case BROWSE_MODE
: return mbBrowseMode
;
191 case HTML_MODE
: return mbHTMLMode
;
192 case GLOBAL_DOCUMENT
: return mbIsGlobalDoc
;
193 case GLOBAL_DOCUMENT_SAVE_LINKS
: return mbGlblDocSaveLinks
;
194 case LABEL_DOCUMENT
: return mbIsLabelDoc
;
195 case PURGE_OLE
: return mbPurgeOLE
;
196 case KERN_ASIAN_PUNCTUATION
: return mbKernAsianPunctuation
;
197 case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT
: return mbDoNotResetParaAttrsForNumFont
;
199 ASSERT(false, "Invalid setting id");
204 void SwDoc::set(/*[in]*/ DocumentSettingId id
, /*[in]*/ bool value
)
208 // COMPATIBILITY FLAGS START
210 mbParaSpaceMax
= value
;
212 case PARA_SPACE_MAX_AT_PAGES
:
213 mbParaSpaceMaxAtPages
= value
;
218 case ADD_FLY_OFFSETS
:
219 mbAddFlyOffsets
= value
;
221 case ADD_EXT_LEADING
:
222 mbAddExternalLeading
= value
;
224 case USE_VIRTUAL_DEVICE
:
225 mbUseVirtualDevice
= value
;
227 case USE_HIRES_VIRTUAL_DEVICE
:
228 mbUseHiResolutionVirtualDevice
= value
;
231 if (mbOldNumbering
!= value
)
233 mbOldNumbering
= value
;
235 const SwNumRuleTbl
& rNmTbl
= GetNumRuleTbl();
236 for( USHORT n
= 0; n
< rNmTbl
.Count(); ++n
)
237 rNmTbl
[n
]->SetInvalidRule(TRUE
);
243 pOutlineRule
->Validate();
244 // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()>
245 pOutlineRule
->SetCountPhantoms( !mbOldNumbering
);
250 case OLD_LINE_SPACING
:
251 mbOldLineSpacing
= value
;
253 case ADD_PARA_SPACING_TO_TABLE_CELLS
:
254 mbAddParaSpacingToTableCells
= value
;
256 case USE_FORMER_OBJECT_POS
:
257 mbUseFormerObjectPos
= value
;
259 case USE_FORMER_TEXT_WRAPPING
:
260 mbUseFormerTextWrapping
= value
;
262 case CONSIDER_WRAP_ON_OBJECT_POSITION
:
263 mbConsiderWrapOnObjPos
= value
;
265 case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK
:
266 mbDoNotJustifyLinesWithManualBreak
= value
;
268 case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING
:
269 mbIgnoreFirstLineIndentInNumbering
= value
;
272 case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE
:
273 mbOutlineLevelYieldsOutlineRule
= value
;
277 mbTableRowKeep
= value
;
280 case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION
:
281 mbIgnoreTabsAndBlanksForLineCalculation
= value
;
284 case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE
:
285 mbDoNotCaptureDrawObjsOnPage
= value
;
288 // --> OD 2006-08-25 #i68949#
289 case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME
:
290 mbClipAsCharacterAnchoredWriterFlyFrames
= value
;
293 case UNIX_FORCE_ZERO_EXT_LEADING
:
294 mbUnixForceZeroExtLeading
= value
;
297 mbProtectForm
= value
;
300 case USE_OLD_PRINTER_METRICS
:
301 mbOldPrinterMetrics
= value
;
303 case TABS_RELATIVE_TO_INDENT
:
304 mbTabRelativeToIndent
= value
;
306 // --> OD 2008-06-05 #i89181#
307 case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST
:
308 mbTabAtLeftIndentForParagraphsInList
= value
;
311 case INVERT_BORDER_SPACING
:
312 mbInvertBorderSpacing
= value
;
314 case COLLAPSE_EMPTY_CELL_PARA
:
315 mbCollapseEmptyCellPara
= value
;
317 // COMPATIBILITY FLAGS END
320 mbBrowseMode
= value
;
325 case GLOBAL_DOCUMENT
:
326 mbIsGlobalDoc
= value
;
328 case GLOBAL_DOCUMENT_SAVE_LINKS
:
329 mbGlblDocSaveLinks
= value
;
332 mbIsLabelDoc
= value
;
337 case KERN_ASIAN_PUNCTUATION
:
338 mbKernAsianPunctuation
= value
;
340 case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT
:
341 mbDoNotResetParaAttrsForNumFont
= value
;
344 ASSERT(false, "Invalid setting id");
348 const i18n::ForbiddenCharacters
*
349 SwDoc::getForbiddenCharacters(/*[in]*/ USHORT nLang
, /*[in]*/ bool bLocaleData
) const
351 const i18n::ForbiddenCharacters
* pRet
= 0;
352 if( xForbiddenCharsTable
.isValid() )
353 pRet
= xForbiddenCharsTable
->GetForbiddenCharacters( nLang
, FALSE
);
354 if( bLocaleData
&& !pRet
&& pBreakIt
)
355 pRet
= &pBreakIt
->GetForbidden( (LanguageType
)nLang
);
359 void SwDoc::setForbiddenCharacters(/*[in]*/ USHORT nLang
,
360 /*[in]*/ const i18n::ForbiddenCharacters
& rFChars
)
362 if( !xForbiddenCharsTable
.isValid() )
365 lang::XMultiServiceFactory
> xMSF
=
366 ::comphelper::getProcessServiceFactory();
367 xForbiddenCharsTable
= new SvxForbiddenCharactersTable( xMSF
);
369 xForbiddenCharsTable
->SetForbiddenCharacters( nLang
, rFChars
);
372 pDrawModel
->SetForbiddenCharsTable( xForbiddenCharsTable
);
374 pDrawModel
->ReformatAllTextObjects();
377 if( pLayout
&& !mbInReading
)
379 pLayout
->StartAllAction();
380 pLayout
->InvalidateAllCntnt();
381 pLayout
->EndAllAction();
386 vos::ORef
<SvxForbiddenCharactersTable
>& SwDoc::getForbiddenCharacterTable()
388 if( !xForbiddenCharsTable
.isValid() )
391 lang::XMultiServiceFactory
> xMSF
=
392 ::comphelper::getProcessServiceFactory();
393 xForbiddenCharsTable
= new SvxForbiddenCharactersTable( xMSF
);
395 return xForbiddenCharsTable
;
398 const vos::ORef
<SvxForbiddenCharactersTable
>& SwDoc::getForbiddenCharacterTable() const
400 return xForbiddenCharsTable
;
403 sal_uInt16
SwDoc::getLinkUpdateMode( /*[in]*/bool bGlobalSettings
) const
405 sal_uInt16 nRet
= nLinkUpdMode
;
406 if( bGlobalSettings
&& GLOBALSETTING
== nRet
)
407 nRet
= SW_MOD()->GetLinkUpdMode(get(IDocumentSettingAccess::HTML_MODE
));
411 void SwDoc::setLinkUpdateMode( /*[in]*/sal_uInt16 eMode
)
413 nLinkUpdMode
= eMode
;
416 SwFldUpdateFlags
SwDoc::getFieldUpdateFlags( /*[in]*/bool bGlobalSettings
) const
418 SwFldUpdateFlags eRet
= eFldUpdMode
;
419 if( bGlobalSettings
&& AUTOUPD_GLOBALSETTING
== eRet
)
420 eRet
= SW_MOD()->GetFldUpdateFlags(get(IDocumentSettingAccess::HTML_MODE
));
424 void SwDoc::setFieldUpdateFlags(/*[in]*/SwFldUpdateFlags eMode
)
429 SwCharCompressType
SwDoc::getCharacterCompressionType() const
434 void SwDoc::setCharacterCompressionType( /*[in]*/SwCharCompressType n
)
436 if( eChrCmprType
!= n
)
441 pDrawModel
->SetCharCompressType( static_cast<UINT16
>(n
) );
443 pDrawModel
->ReformatAllTextObjects();
446 if( pLayout
&& !mbInReading
)
448 pLayout
->StartAllAction();
449 pLayout
->InvalidateAllCntnt();
450 pLayout
->EndAllAction();
456 /** IDocumentDeviceAccess
458 SfxPrinter
* SwDoc::getPrinter(/*[in]*/ bool bCreate
) const
460 SfxPrinter
* pRet
= 0;
461 if ( !bCreate
|| pPrt
)
464 pRet
= &CreatePrinter_();
469 void SwDoc::setPrinter(/*[in]*/ SfxPrinter
*pP
,/*[in]*/ bool bDeleteOld
,/*[in]*/ bool bCallPrtDataChanged
)
478 if ( bCallPrtDataChanged
&&
479 // --> FME 2005-01-21 #i41075# Do not call PrtDataChanged() if we do not
480 // use the printer for formatting:
481 !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE
) )
486 VirtualDevice
* SwDoc::getVirtualDevice(/*[in]*/ bool bCreate
) const
488 VirtualDevice
* pRet
= 0;
489 if ( !bCreate
|| pVirDev
)
492 pRet
= &CreateVirtualDevice_();
497 void SwDoc::setVirtualDevice(/*[in]*/ VirtualDevice
* pVd
,/*[in]*/ bool bDeleteOld
, /*[in]*/ bool )
499 if ( pVirDev
!= pVd
)
507 OutputDevice
* SwDoc::getReferenceDevice(/*[in]*/ bool bCreate
) const
509 OutputDevice
* pRet
= 0;
510 if ( !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE
) )
512 pRet
= getPrinter( bCreate
);
514 if ( bCreate
&& !pPrt
->IsValid() )
516 pRet
= getVirtualDevice( sal_True
);
521 pRet
= getVirtualDevice( bCreate
);
527 void SwDoc::setReferenceDeviceType(/*[in]*/ bool bNewVirtual
,/*[in]*/ bool bNewHiRes
)
529 if ( get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE
) != bNewVirtual
||
530 get(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE
) != bNewHiRes
)
534 VirtualDevice
* pMyVirDev
= getVirtualDevice( true );
536 pMyVirDev
->SetReferenceDevice( VirtualDevice::REFDEV_MODE06
);
538 pMyVirDev
->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1
);
542 // --> FME 2005-01-21 #i41075#
543 // We have to take care that a printer exists before calling
544 // PrtDataChanged() in order to prevent that PrtDataChanged()
545 // triggers this funny situation:
546 // getReferenceDevice()->getPrinter()->CreatePrinter_()
547 // ->setPrinter()-> PrtDataChanged()
552 set(IDocumentSettingAccess::USE_VIRTUAL_DEVICE
, bNewVirtual
);
553 set(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE
, bNewHiRes
);
559 const JobSetup
* SwDoc::getJobsetup() const
561 return pPrt
? &pPrt
->GetJobSetup() : 0;
564 void SwDoc::setJobsetup(/*[in]*/ const JobSetup
&rJobSetup
)
566 BOOL bCheckPageDescs
= 0 == pPrt
;
567 BOOL bDataChanged
= FALSE
;
571 if ( pPrt
->GetName() == rJobSetup
.GetPrinterName() )
573 if ( pPrt
->GetJobSetup() != rJobSetup
)
575 pPrt
->SetJobSetup( rJobSetup
);
580 delete pPrt
, pPrt
= 0;
585 //Das ItemSet wird vom Sfx geloescht!
586 SfxItemSet
*pSet
= new SfxItemSet( GetAttrPool(),
587 FN_PARAM_ADDPRINTER
, FN_PARAM_ADDPRINTER
,
588 SID_HTML_MODE
, SID_HTML_MODE
,
589 SID_PRINTER_NOTFOUND_WARN
, SID_PRINTER_NOTFOUND_WARN
,
590 SID_PRINTER_CHANGESTODOC
, SID_PRINTER_CHANGESTODOC
,
592 SfxPrinter
*p
= new SfxPrinter( pSet
, rJobSetup
);
593 if ( bCheckPageDescs
)
594 setPrinter( p
, true, true );
601 if ( bDataChanged
&& !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE
) )
605 SwPrintData
* SwDoc::getPrintData() const
610 void SwDoc::setPrintData(/*[in]*/ const SwPrintData
& rPrtData
)
613 pPrtData
= new SwPrintData
;
614 *pPrtData
= rPrtData
;
617 /** Implementations the next Interface here
621 * Dokumenteditieren (Doc-SS) zum Fuellen des Dokuments
622 * durch den RTF Parser und fuer die EditShell.
624 void SwDoc::ChgDBData(const SwDBData
& rNewData
)
626 if( rNewData
!= aDBData
)
631 GetSysFldType(RES_DBNAMEFLD
)->UpdateFlds();
634 bool SwDoc::SplitNode( const SwPosition
&rPos
, bool bChkTableStart
)
636 SwCntntNode
*pNode
= rPos
.nNode
.GetNode().GetCntntNode();
641 // Bug 26675: DataChanged vorm loeschen verschicken, dann bekommt
642 // man noch mit, welche Objecte sich im Bereich befinden.
643 // Danach koennen sie vor/hinter der Position befinden.
644 SwDataChanged
aTmp( this, rPos
, 0 );
647 SwUndoSplitNode
* pUndo
= 0;
651 // einfuegen vom Undo-Object, z.Z. nur beim TextNode
652 if( pNode
->IsTxtNode() )
654 pUndo
= new SwUndoSplitNode( this, rPos
, bChkTableStart
);
659 //JP 28.01.97: Sonderfall fuer SplitNode am Tabellenanfang:
660 // steht die am Doc/Fly/Footer/..-Anfang oder direkt
661 // hinter einer Tabelle, dann fuege davor
663 if( bChkTableStart
&& !rPos
.nContent
.GetIndex() && pNode
->IsTxtNode() )
665 ULONG nPrevPos
= rPos
.nNode
.GetIndex() - 1;
666 const SwTableNode
* pTblNd
;
667 const SwNode
* pNd
= GetNodes()[ nPrevPos
];
668 if( pNd
->IsStartNode() &&
669 SwTableBoxStartNode
== ((SwStartNode
*)pNd
)->GetStartNodeType() &&
670 0 != ( pTblNd
= GetNodes()[ --nPrevPos
]->GetTableNode() ) &&
671 ((( pNd
= GetNodes()[ --nPrevPos
])->IsStartNode() &&
672 SwTableBoxStartNode
!= ((SwStartNode
*)pNd
)->GetStartNodeType() )
673 || ( pNd
->IsEndNode() && pNd
->StartOfSectionNode()->IsTableNode() )
674 || pNd
->IsCntntNode() ))
676 if( pNd
->IsCntntNode() )
678 //JP 30.04.99 Bug 65660:
679 // ausserhalb des normalen BodyBereiches gibt es keine
680 // Seitenumbrueche, also ist das hier kein gueltige
681 // Bedingung fuers einfuegen eines Absatzes
682 if( nPrevPos
< GetNodes().GetEndOfExtras().GetIndex() )
686 // Dann nur, wenn die Tabelle Umbrueche traegt!
687 const SwFrmFmt
* pFrmFmt
= pTblNd
->GetTable().GetFrmFmt();
688 if( SFX_ITEM_SET
!= pFrmFmt
->GetItemState(RES_PAGEDESC
, FALSE
) &&
689 SFX_ITEM_SET
!= pFrmFmt
->GetItemState( RES_BREAK
, FALSE
) )
696 SwTxtNode
* pTxtNd
= GetNodes().MakeTxtNode(
697 SwNodeIndex( *pTblNd
),
698 GetTxtCollFromPool( RES_POOLCOLL_TEXT
));
701 ((SwPosition
&)rPos
).nNode
= pTblNd
->GetIndex()-1;
702 ((SwPosition
&)rPos
).nContent
.Assign( pTxtNd
, 0 );
704 // nur im BodyBereich den SeitenUmbruch/-Vorlage umhaengem
705 if( nPrevPos
> GetNodes().GetEndOfExtras().GetIndex() )
707 SwFrmFmt
* pFrmFmt
= pTblNd
->GetTable().GetFrmFmt();
708 const SfxPoolItem
*pItem
;
709 if( SFX_ITEM_SET
== pFrmFmt
->GetItemState( RES_PAGEDESC
,
712 pTxtNd
->SetAttr( *pItem
);
713 pFrmFmt
->ResetFmtAttr( RES_PAGEDESC
);
715 if( SFX_ITEM_SET
== pFrmFmt
->GetItemState( RES_BREAK
,
718 pTxtNd
->SetAttr( *pItem
);
719 pFrmFmt
->ResetFmtAttr( RES_BREAK
);
732 SvULongs
aBkmkArr( 15, 15 );
733 _SaveCntntIdx( this, rPos
.nNode
.GetIndex(), rPos
.nContent
.GetIndex(),
734 aBkmkArr
, SAVEFLY_SPLIT
);
735 // FIXME: only SwTxtNode has a valid implementation of SplitCntntNode!
736 ASSERT(pNode
->IsTxtNode(), "splitting non-text node?");
737 pNode
= pNode
->SplitCntntNode( rPos
);
740 // verschiebe noch alle Bookmarks/TOXMarks/FlyAtCnt
741 if( aBkmkArr
.Count() )
742 _RestoreCntntIdx( this, aBkmkArr
, rPos
.nNode
.GetIndex()-1, 0, TRUE
);
744 if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl
->Count() ))
748 aPam
.Move( fnMoveBackward
);
750 AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT
, aPam
), true);
752 SplitRedline( aPam
);
760 bool SwDoc::AppendTxtNode( SwPosition
& rPos
)
763 * Neuen Node vor EndOfContent erzeugen.
765 SwTxtNode
*pCurNode
= GetNodes()[ rPos
.nNode
]->GetTxtNode();
768 // dann kann ja einer angelegt werden!
769 SwNodeIndex
aIdx( rPos
.nNode
, 1 );
770 pCurNode
= GetNodes().MakeTxtNode( aIdx
,
771 GetTxtCollFromPool( RES_POOLCOLL_STANDARD
));
774 pCurNode
= (SwTxtNode
*)pCurNode
->AppendNode( rPos
);
777 rPos
.nContent
.Assign( pCurNode
, 0 );
782 AppendUndo( new SwUndoInsert( rPos
.nNode
));
785 if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl
->Count() ))
789 aPam
.Move( fnMoveBackward
);
791 AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT
, aPam
), true);
793 SplitRedline( aPam
);
800 bool SwDoc::InsertString( const SwPaM
&rRg
, const String
&rStr
,
801 const enum InsertFlags nInsertMode
)
808 const SwPosition
& rPos
= *rRg
.GetPoint();
810 if( pACEWord
) // Aufnahme in die Autokorrektur
812 if( 1 == rStr
.Len() && pACEWord
->IsDeleted() )
814 pACEWord
->CheckChar( rPos
, rStr
.GetChar( 0 ) );
816 delete pACEWord
, pACEWord
= 0;
819 SwTxtNode
*const pNode
= rPos
.nNode
.GetNode().GetTxtNode();
825 SwDataChanged
aTmp( rRg
, 0 );
827 if( !DoesUndo() || !DoesGroupUndo() )
829 pNode
->InsertText( rStr
, rPos
.nContent
, nInsertMode
);
833 SwUndoInsert
* const pUndo( new SwUndoInsert(
834 rPos
.nNode
, rPos
.nContent
.GetIndex(), rStr
.Len(), nInsertMode
));
839 { // ist Undo und Gruppierung eingeschaltet, ist alles anders !
840 SwUndoInsert
* pUndo
= NULL
; // #111827#
842 // don't group the start if hints at the start should be expanded
843 if (!(nInsertMode
& IDocumentContentOperations::INS_FORCEHINTEXPAND
))
846 USHORT
const nUndoSize
= pUndos
->Count();
849 SwUndo
* const pLastUndo
= (*pUndos
)[ nUndoSize
- 1 ];
851 switch (pLastUndo
->GetId())
855 if (static_cast<SwUndoInsert
*>(pLastUndo
)
856 ->CanGrouping( rPos
))
858 pUndo
= static_cast<SwUndoInsert
*>(pLastUndo
);
869 CharClass
const& rCC
= GetAppCharClass();
870 xub_StrLen nInsPos
= rPos
.nContent
.GetIndex();
874 pUndo
= new SwUndoInsert( rPos
.nNode
, nInsPos
, 0, nInsertMode
,
875 !rCC
.isLetterNumeric( rStr
, 0 ) );
879 pNode
->InsertText( rStr
, rPos
.nContent
, nInsertMode
);
881 for( xub_StrLen i
= 0; i
< rStr
.Len(); ++i
)
884 // wenn CanGrouping() TRUE returnt, ist schon alles erledigt
885 if( !pUndo
->CanGrouping( rStr
.GetChar( i
) ))
887 pUndo
= new SwUndoInsert( rPos
.nNode
, nInsPos
, 1, nInsertMode
,
888 !rCC
.isLetterNumeric( rStr
, i
) );
894 if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl
->Count() ))
896 SwPaM
aPam( rPos
.nNode
, aTmp
.GetCntnt(),
897 rPos
.nNode
, rPos
.nContent
.GetIndex());
901 new SwRedline( nsRedlineType_t::REDLINE_INSERT
, aPam
), true);
905 SplitRedline( aPam
);
913 SwFlyFrmFmt
* SwDoc::_InsNoTxtNode( const SwPosition
& rPos
, SwNoTxtNode
* pNode
,
914 const SfxItemSet
* pFlyAttrSet
,
915 const SfxItemSet
* pGrfAttrSet
,
918 SwFlyFrmFmt
*pFmt
= 0;
921 pFmt
= _MakeFlySection( rPos
, *pNode
, FLY_AT_CNTNT
,
922 pFlyAttrSet
, pFrmFmt
);
924 pNode
->SetAttr( *pGrfAttrSet
);
929 SwFlyFrmFmt
* SwDoc::Insert( const SwPaM
&rRg
,
930 const String
& rGrfName
,
931 const String
& rFltName
,
932 const Graphic
* pGraphic
,
933 const SfxItemSet
* pFlyAttrSet
,
934 const SfxItemSet
* pGrfAttrSet
,
938 pFrmFmt
= GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC
);
939 return _InsNoTxtNode( *rRg
.GetPoint(), GetNodes().MakeGrfNode(
940 SwNodeIndex( GetNodes().GetEndOfAutotext() ),
941 rGrfName
, rFltName
, pGraphic
,
943 pFlyAttrSet
, pGrfAttrSet
, pFrmFmt
);
945 SwFlyFrmFmt
* SwDoc::Insert( const SwPaM
&rRg
, const GraphicObject
& rGrfObj
,
946 const SfxItemSet
* pFlyAttrSet
,
947 const SfxItemSet
* pGrfAttrSet
,
951 pFrmFmt
= GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC
);
952 return _InsNoTxtNode( *rRg
.GetPoint(), GetNodes().MakeGrfNode(
953 SwNodeIndex( GetNodes().GetEndOfAutotext() ),
954 rGrfObj
, pDfltGrfFmtColl
),
955 pFlyAttrSet
, pGrfAttrSet
, pFrmFmt
);
958 SwFlyFrmFmt
* SwDoc::Insert(const SwPaM
&rRg
, const svt::EmbeddedObjectRef
& xObj
,
959 const SfxItemSet
* pFlyAttrSet
,
960 const SfxItemSet
* pGrfAttrSet
,
965 USHORT nId
= RES_POOLFRM_OLE
;
966 SvGlobalName
aClassName( xObj
->getClassID() );
967 if (SotExchange::IsMath(aClassName
))
968 nId
= RES_POOLFRM_FORMEL
;
970 pFrmFmt
= GetFrmFmtFromPool( nId
);
972 return _InsNoTxtNode( *rRg
.GetPoint(), GetNodes().MakeOLENode(
973 SwNodeIndex( GetNodes().GetEndOfAutotext() ),
976 pFlyAttrSet
, pGrfAttrSet
,
980 SwFlyFrmFmt
* SwDoc::InsertOLE(const SwPaM
&rRg
, const String
& rObjName
,
982 const SfxItemSet
* pFlyAttrSet
,
983 const SfxItemSet
* pGrfAttrSet
,
987 pFrmFmt
= GetFrmFmtFromPool( RES_POOLFRM_OLE
);
989 return _InsNoTxtNode( *rRg
.GetPoint(),
990 GetNodes().MakeOLENode(
991 SwNodeIndex( GetNodes().GetEndOfAutotext() ),
996 pFlyAttrSet
, pGrfAttrSet
,
1000 /*************************************************************************
1001 |* SwDoc::GetFldType()
1002 |* Beschreibung: liefert den am Doc eingerichteten Feldtypen zurueck
1003 *************************************************************************/
1005 SwFieldType
*SwDoc::GetSysFldType( const USHORT eWhich
) const
1007 for( USHORT i
= 0; i
< INIT_FLDTYPES
; ++i
)
1008 if( eWhich
== (*pFldTypes
)[i
]->Which() )
1009 return (*pFldTypes
)[i
];
1012 /*************************************************************************
1013 * void SetDocStat( const SwDocStat& rStat );
1014 *************************************************************************/
1016 void SwDoc::SetDocStat( const SwDocStat
& rStat
)
1021 const SwDocStat
& SwDoc::GetDocStat() const
1026 sal_uInt16
SwDoc::GetPageCount() const
1028 return GetRootFrm() ? GetRootFrm()->GetPageNum() : 0;
1031 const Size
SwDoc::GetPageSize( sal_uInt16 nPageNum
, bool bSkipEmptyPages
) const
1034 if( GetRootFrm() && nPageNum
)
1036 const SwPageFrm
* pPage
= static_cast<const SwPageFrm
*>
1037 (GetRootFrm()->Lower());
1039 while( --nPageNum
&& pPage
->GetNext() )
1040 pPage
= static_cast<const SwPageFrm
*>( pPage
->GetNext() );
1042 if( !bSkipEmptyPages
&& pPage
->IsEmptyPage() && pPage
->GetNext() )
1043 pPage
= static_cast<const SwPageFrm
*>( pPage
->GetNext() );
1045 aSize
= pPage
->Frm().SSize();
1051 /*************************************************************************
1052 * void UpdateDocStat( const SwDocStat& rStat );
1053 *************************************************************************/
1055 void SwDoc::UpdateDocStat( SwDocStat
& rStat
)
1057 if( rStat
.bModified
)
1060 rStat
.nPara
= 0; // Default ist auf 1 !!
1063 for( ULONG i
= GetNodes().Count(); i
; )
1065 switch( ( pNd
= GetNodes()[ --i
])->GetNodeType() )
1068 ((SwTxtNode
*)pNd
)->CountWords( rStat
, 0, ((SwTxtNode
*)pNd
)->GetTxt().Len() );
1070 case ND_TABLENODE
: ++rStat
.nTbl
; break;
1071 case ND_GRFNODE
: ++rStat
.nGrf
; break;
1072 case ND_OLENODE
: ++rStat
.nOLE
; break;
1073 case ND_SECTIONNODE
: break;
1077 rStat
.nPage
= GetRootFrm() ? GetRootFrm()->GetPageNum() : 0;
1078 rStat
.bModified
= FALSE
;
1079 SetDocStat( rStat
);
1081 com::sun::star::uno::Sequence
< com::sun::star::beans::NamedValue
> aStat( rStat
.nPage
? 7 : 6);
1083 aStat
[n
].Name
= ::rtl::OUString::createFromAscii("TableCount");
1084 aStat
[n
++].Value
<<= (sal_Int32
)rStat
.nTbl
;
1085 aStat
[n
].Name
= ::rtl::OUString::createFromAscii("ImageCount");
1086 aStat
[n
++].Value
<<= (sal_Int32
)rStat
.nGrf
;
1087 aStat
[n
].Name
= ::rtl::OUString::createFromAscii("ObjectCount");
1088 aStat
[n
++].Value
<<= (sal_Int32
)rStat
.nOLE
;
1091 aStat
[n
].Name
= ::rtl::OUString::createFromAscii("PageCount");
1092 aStat
[n
++].Value
<<= (sal_Int32
)rStat
.nPage
;
1094 aStat
[n
].Name
= ::rtl::OUString::createFromAscii("ParagraphCount");
1095 aStat
[n
++].Value
<<= (sal_Int32
)rStat
.nPara
;
1096 aStat
[n
].Name
= ::rtl::OUString::createFromAscii("WordCount");
1097 aStat
[n
++].Value
<<= (sal_Int32
)rStat
.nWord
;
1098 aStat
[n
].Name
= ::rtl::OUString::createFromAscii("CharacterCount");
1099 aStat
[n
++].Value
<<= (sal_Int32
)rStat
.nChar
;
1101 // For e.g. autotext documents there is no pSwgInfo (#i79945)
1102 if (GetDocShell()) {
1103 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS(
1104 GetDocShell()->GetModel(), uno::UNO_QUERY_THROW
);
1105 uno::Reference
<document::XDocumentProperties
> xDocProps(
1106 xDPS
->getDocumentProperties());
1107 xDocProps
->setDocumentStatistics(aStat
);
1110 // event. Stat. Felder Updaten
1111 SwFieldType
*pType
= GetSysFldType(RES_DOCSTATFLD
);
1112 pType
->UpdateFlds();
1119 void SwDoc::DocInfoChgd( )
1121 GetSysFldType( RES_DOCINFOFLD
)->UpdateFlds();
1122 GetSysFldType( RES_TEMPLNAMEFLD
)->UpdateFlds();
1126 // returne zum Namen die im Doc gesetzte Referenz
1127 const SwFmtRefMark
* SwDoc::GetRefMark( const String
& rName
) const
1129 const SfxPoolItem
* pItem
;
1130 USHORT nMaxItems
= GetAttrPool().GetItemCount( RES_TXTATR_REFMARK
);
1131 for( USHORT n
= 0; n
< nMaxItems
; ++n
)
1133 if( 0 == (pItem
= GetAttrPool().GetItem( RES_TXTATR_REFMARK
, n
) ))
1136 const SwFmtRefMark
* pFmtRef
= (SwFmtRefMark
*)pItem
;
1137 const SwTxtRefMark
* pTxtRef
= pFmtRef
->GetTxtRefMark();
1138 if( pTxtRef
&& &pTxtRef
->GetTxtNode().GetNodes() == &GetNodes() &&
1139 rName
.Equals( pFmtRef
->GetRefName() ) )
1145 // returne die RefMark per Index - fuer Uno
1146 const SwFmtRefMark
* SwDoc::GetRefMark( USHORT nIndex
) const
1148 const SfxPoolItem
* pItem
;
1149 const SwTxtRefMark
* pTxtRef
;
1150 const SwFmtRefMark
* pRet
= 0;
1152 USHORT nMaxItems
= GetAttrPool().GetItemCount( RES_TXTATR_REFMARK
);
1154 for( USHORT n
= 0; n
< nMaxItems
; ++n
)
1155 if( 0 != (pItem
= GetAttrPool().GetItem( RES_TXTATR_REFMARK
, n
)) &&
1156 0 != (pTxtRef
= ((SwFmtRefMark
*)pItem
)->GetTxtRefMark()) &&
1157 &pTxtRef
->GetTxtNode().GetNodes() == &GetNodes() )
1159 if(nCount
== nIndex
)
1161 pRet
= (SwFmtRefMark
*)pItem
;
1169 // returne die Namen aller im Doc gesetzten Referenzen
1170 //JP 24.06.96: Ist der ArrayPointer 0 dann returne nur, ob im Doc. eine
1171 // RefMark gesetzt ist
1172 // OS 25.06.96: ab jetzt wird immer die Anzahl der Referenzen returnt
1173 USHORT
SwDoc::GetRefMarks( SvStringsDtor
* pNames
) const
1175 const SfxPoolItem
* pItem
;
1176 const SwTxtRefMark
* pTxtRef
;
1178 USHORT nMaxItems
= GetAttrPool().GetItemCount( RES_TXTATR_REFMARK
);
1180 for( USHORT n
= 0; n
< nMaxItems
; ++n
)
1181 if( 0 != (pItem
= GetAttrPool().GetItem( RES_TXTATR_REFMARK
, n
)) &&
1182 0 != (pTxtRef
= ((SwFmtRefMark
*)pItem
)->GetTxtRefMark()) &&
1183 &pTxtRef
->GetTxtNode().GetNodes() == &GetNodes() )
1187 String
* pTmp
= new String( ((SwFmtRefMark
*)pItem
)->GetRefName() );
1188 pNames
->Insert( pTmp
, nCount
);
1196 bool SwDoc::IsLoaded() const
1201 bool SwDoc::IsUpdateExpFld() const
1203 return mbUpdateExpFld
;
1206 bool SwDoc::IsNewDoc() const
1211 bool SwDoc::IsPageNums() const
1216 void SwDoc::SetPageNums(bool b
)
1221 void SwDoc::SetNewDoc(bool b
)
1226 void SwDoc::SetUpdateExpFldStat(bool b
)
1231 void SwDoc::SetLoaded(bool b
)
1236 bool SwDoc::IsModified() const
1241 void SwDoc::SetModified()
1243 // --> OD 2005-08-29 #125370#
1244 SwLayouter::ClearMovedFwdFrms( *this );
1245 SwLayouter::ClearObjsTmpConsiderWrapInfluence( *this );
1246 SwLayouter::ClearFrmsNotToWrap( *this );
1248 // --> OD 2006-05-10 #i65250#
1249 SwLayouter::ClearMoveBwdLayoutInfo( *this );
1251 // dem Link wird der Status returnt, wie die Flags waren und werden
1252 // Bit 0: -> alter Zustand
1253 // Bit 1: -> neuer Zustand
1254 long nCall
= mbModified
? 3 : 2;
1256 pDocStat
->bModified
= TRUE
;
1257 if( aOle2Link
.IsSet() )
1259 mbInCallModified
= TRUE
;
1260 aOle2Link
.Call( (void*)nCall
);
1261 mbInCallModified
= FALSE
;
1264 if( pACEWord
&& !pACEWord
->IsDeleted() )
1265 delete pACEWord
, pACEWord
= 0;
1268 void SwDoc::ResetModified()
1270 // dem Link wird der Status returnt, wie die Flags waren und werden
1271 // Bit 0: -> alter Zustand
1272 // Bit 1: -> neuer Zustand
1273 long nCall
= mbModified
? 1 : 0;
1275 // If there is already a document statistic, we assume that
1276 // it is correct. In this case we reset the modified flag.
1277 if ( 0 != pDocStat
->nChar
)
1278 pDocStat
->bModified
= FALSE
;
1279 nUndoSavePos
= nUndoPos
;
1280 if( nCall
&& aOle2Link
.IsSet() )
1282 mbInCallModified
= TRUE
;
1283 aOle2Link
.Call( (void*)nCall
);
1284 mbInCallModified
= FALSE
;
1289 void SwDoc::ReRead( SwPaM
& rPam
, const String
& rGrfName
,
1290 const String
& rFltName
, const Graphic
* pGraphic
,
1291 const GraphicObject
* pGrafObj
)
1294 if( ( !rPam
.HasMark()
1295 || rPam
.GetPoint()->nNode
.GetIndex() == rPam
.GetMark()->nNode
.GetIndex() )
1296 && 0 != ( pGrfNd
= rPam
.GetPoint()->nNode
.GetNode().GetGrfNode() ) )
1301 AppendUndo( new SwUndoReRead( rPam
, *pGrfNd
) );
1304 // Weil nicht bekannt ist, ob sich die Grafik spiegeln laesst,
1305 // immer das SpiegelungsAttribut zuruecksetzen
1306 if( RES_MIRROR_GRAPH_DONT
!= pGrfNd
->GetSwAttrSet().
1307 GetMirrorGrf().GetValue() )
1308 pGrfNd
->SetAttr( SwMirrorGrf() );
1310 pGrfNd
->ReRead( rGrfName
, rFltName
, pGraphic
, pGrafObj
, TRUE
);
1315 BOOL
lcl_SpellAndGrammarAgain( const SwNodePtr
& rpNd
, void* pArgs
)
1317 SwTxtNode
*pTxtNode
= (SwTxtNode
*)rpNd
->GetTxtNode();
1318 BOOL bOnlyWrong
= *(BOOL
*)pArgs
;
1323 if( pTxtNode
->GetWrong() &&
1324 pTxtNode
->GetWrong()->InvalidateWrong() )
1325 pTxtNode
->SetWrongDirty( true );
1326 if( pTxtNode
->GetGrammarCheck() &&
1327 pTxtNode
->GetGrammarCheck()->InvalidateWrong() )
1328 pTxtNode
->SetGrammarCheckDirty( true );
1332 pTxtNode
->SetWrongDirty( true );
1333 if( pTxtNode
->GetWrong() )
1334 pTxtNode
->GetWrong()->SetInvalid( 0, STRING_LEN
);
1335 pTxtNode
->SetGrammarCheckDirty( true );
1336 if( pTxtNode
->GetGrammarCheck() )
1337 pTxtNode
->GetGrammarCheck()->SetInvalid( 0, STRING_LEN
);
1343 BOOL
lcl_CheckSmartTagsAgain( const SwNodePtr
& rpNd
, void* )
1345 SwTxtNode
*pTxtNode
= (SwTxtNode
*)rpNd
->GetTxtNode();
1346 // BOOL bOnlyWrong = *(BOOL*)pArgs;
1349 pTxtNode
->SetSmartTagDirty( true );
1350 if( pTxtNode
->GetSmartTags() )
1352 // if ( bOnlyWrong ) // only some smart tag types have been enabled or disabled
1353 // pTxtNode->GetSmartTags()->SetInvalid( 0, STRING_LEN );
1354 // else // smart tags all have been enabled or disabled
1355 pTxtNode
->SetSmartTags( NULL
);
1362 /*************************************************************************
1363 * SwDoc::SpellItAgainSam( BOOL bInvalid, BOOL bOnlyWrong )
1365 * stoesst das Spelling im Idle-Handler wieder an.
1366 * Wird bInvalid als TRUE uebergeben, so werden zusaetzlich die WrongListen
1367 * an allen Nodes invalidiert und auf allen Seiten das SpellInvalid-Flag
1369 * Mit bOnlyWrong kann man dann steuern, ob nur die Bereiche mit falschen
1370 * Woertern oder die kompletten Bereiche neu ueberprueft werden muessen.
1371 ************************************************************************/
1373 void SwDoc::SpellItAgainSam( BOOL bInvalid
, BOOL bOnlyWrong
, BOOL bSmartTags
)
1375 ASSERT( GetRootFrm(), "SpellAgain: Where's my RootFrm?" );
1378 SwPageFrm
*pPage
= (SwPageFrm
*)GetRootFrm()->Lower();
1382 pPage
->InvalidateSmartTags();
1384 pPage
->InvalidateSpelling();
1385 pPage
= (SwPageFrm
*)pPage
->GetNext();
1387 GetRootFrm()->SetNeedGrammarCheck( true );
1390 GetNodes().ForEach( lcl_CheckSmartTagsAgain
, &bOnlyWrong
);
1392 GetNodes().ForEach( lcl_SpellAndGrammarAgain
, &bOnlyWrong
);
1395 GetRootFrm()->SetIdleFlags();
1398 void SwDoc::InvalidateAutoCompleteFlag()
1402 SwPageFrm
*pPage
= (SwPageFrm
*)GetRootFrm()->Lower();
1405 pPage
->InvalidateAutoCompleteWords();
1406 pPage
= (SwPageFrm
*)pPage
->GetNext();
1408 for( ULONG nNd
= 1, nCnt
= GetNodes().Count(); nNd
< nCnt
; ++nNd
)
1410 SwTxtNode
* pTxtNode
= GetNodes()[ nNd
]->GetTxtNode();
1411 if ( pTxtNode
) pTxtNode
->SetAutoCompleteWordDirty( true );
1413 GetRootFrm()->SetIdleFlags();
1417 const SwFmtINetFmt
* SwDoc::FindINetAttr( const String
& rName
) const
1419 const SwFmtINetFmt
* pItem
;
1420 const SwTxtINetFmt
* pTxtAttr
;
1421 const SwTxtNode
* pTxtNd
;
1422 USHORT n
, nMaxItems
= GetAttrPool().GetItemCount( RES_TXTATR_INETFMT
);
1423 for( n
= 0; n
< nMaxItems
; ++n
)
1424 if( 0 != (pItem
= (SwFmtINetFmt
*)GetAttrPool().GetItem(
1425 RES_TXTATR_INETFMT
, n
) ) &&
1426 pItem
->GetName().Equals( rName
) &&
1427 0 != ( pTxtAttr
= pItem
->GetTxtINetFmt()) &&
1428 0 != ( pTxtNd
= pTxtAttr
->GetpTxtNode() ) &&
1429 &pTxtNd
->GetNodes() == &GetNodes() )
1437 void SwDoc::Summary( SwDoc
* pExtDoc
, BYTE nLevel
, BYTE nPara
, BOOL bImpress
)
1439 const SwOutlineNodes
& rOutNds
= GetNodes().GetOutLineNds();
1440 if( pExtDoc
&& rOutNds
.Count() )
1443 ::StartProgress( STR_STATSTR_SUMMARY
, 0, rOutNds
.Count(), GetDocShell() );
1444 SwNodeIndex
aEndOfDoc( pExtDoc
->GetNodes().GetEndOfContent(), -1 );
1445 for( i
= 0; i
< rOutNds
.Count(); ++i
)
1447 ::SetProgressState( i
, GetDocShell() );
1448 const ULONG nIndex
= rOutNds
[ i
]->GetIndex();
1449 //BYTE nLvl = ((SwTxtNode*)GetNodes()[ nIndex ])->GetTxtColl()//#outline level,zhaojianwei
1450 // ->GetOutlineLevel();
1451 const int nLvl
= ((SwTxtNode
*)GetNodes()[ nIndex
])->GetAttrOutlineLevel()-1;//<-end,zhaojianwei
1456 ULONG nNextOutNd
= i
+ 1 < rOutNds
.Count() ?
1457 rOutNds
[ i
+ 1 ]->GetIndex() : GetNodes().Count();
1459 while( ( nWish
|| bKeep
) && nIndex
+ nEndOfs
< nNextOutNd
&&
1460 GetNodes()[ nIndex
+ nEndOfs
]->IsTxtNode() )
1462 SwTxtNode
* pTxtNode
= (SwTxtNode
*)GetNodes()[ nIndex
+nEndOfs
];
1463 if( pTxtNode
->GetTxt().Len() && nWish
)
1465 bKeep
= pTxtNode
->GetSwAttrSet().GetKeep().GetValue();
1469 SwNodeRange
aRange( *rOutNds
[ i
], 0, *rOutNds
[ i
], nEndOfs
);
1470 GetNodes()._Copy( aRange
, aEndOfDoc
);
1472 const SwTxtFmtColls
*pColl
= pExtDoc
->GetTxtFmtColls();
1473 for( i
= 0; i
< pColl
->Count(); ++i
)
1474 (*pColl
)[ i
]->ResetFmtAttr( RES_PAGEDESC
, RES_BREAK
);
1475 SwNodeIndex
aIndx( pExtDoc
->GetNodes().GetEndOfExtras() );
1477 while( aIndx
< aEndOfDoc
)
1480 BOOL bDelete
= FALSE
;
1481 if( (pNode
= &aIndx
.GetNode())->IsTxtNode() )
1483 SwTxtNode
*pNd
= (SwTxtNode
*)pNode
;
1484 if( pNd
->HasSwAttrSet() )
1485 pNd
->ResetAttr( RES_PAGEDESC
, RES_BREAK
);
1488 SwTxtFmtColl
* pMyColl
= pNd
->GetTxtColl();
1489 //USHORT nHeadLine = static_cast<USHORT>(pMyColl->GetOutlineLevel()==NO_NUMBERING ?//#outlinelevel,zhaojianwei
1490 const USHORT nHeadLine
= static_cast<USHORT
>(
1491 !pMyColl
->IsAssignedToListLevelOfOutlineStyle() //<-end,zhaojianwei
1492 ? RES_POOLCOLL_HEADLINE2
1493 : RES_POOLCOLL_HEADLINE1
);
1494 pMyColl
= pExtDoc
->GetTxtCollFromPool( nHeadLine
);
1495 pNd
->ChgFmtColl( pMyColl
);
1498 pNd
->StartOfSectionIndex()+2 < pNd
->EndOfSectionIndex() )
1501 pExtDoc
->GetNodes().Delete( aIndx
);
1507 ::EndProgress( GetDocShell() );
1511 // loesche den nicht sichtbaren Content aus dem Document, wie z.B.:
1512 // versteckte Bereiche, versteckte Absaetze
1513 BOOL
SwDoc::RemoveInvisibleContent()
1516 StartUndo( UNDO_UI_DELETE_INVISIBLECNTNT
, NULL
);
1520 SwClientIter
aIter( *GetSysFldType( RES_HIDDENPARAFLD
) );
1521 for( SwFmtFld
* pFmtFld
= (SwFmtFld
*)aIter
.First( TYPE( SwFmtFld
));
1522 pFmtFld
; pFmtFld
= (SwFmtFld
*)aIter
.Next() )
1524 if( pFmtFld
->GetTxtFld() &&
1525 0 != ( pTxtNd
= (SwTxtNode
*)pFmtFld
->GetTxtFld()->GetpTxtNode() ) &&
1526 pTxtNd
->GetpSwpHints() && pTxtNd
->HasHiddenParaField() &&
1527 &pTxtNd
->GetNodes() == &GetNodes() )
1530 SwPaM
aPam( *pTxtNd
, 0, *pTxtNd
, pTxtNd
->GetTxt().Len() );
1532 // Remove hidden paragraph or delete contents:
1533 // Delete contents if
1534 // 1. removing the paragraph would result in an empty section or
1535 // 2. if the paragraph is the last paragraph in the section and
1536 // there is no paragraph in front of the paragraph:
1537 if ( ( 2 == pTxtNd
->EndOfSectionIndex() - pTxtNd
->StartOfSectionIndex() ) ||
1538 ( 1 == pTxtNd
->EndOfSectionIndex() - pTxtNd
->GetIndex() &&
1539 !GetNodes()[ pTxtNd
->GetIndex() - 1 ]->GetTxtNode() ) )
1541 DeleteRange( aPam
);
1546 DelFullPara( aPam
);
1553 // Remove any hidden paragraph (hidden text attribute)
1555 for( ULONG n
= GetNodes().Count(); n
; )
1557 SwTxtNode
* pTxtNd
= GetNodes()[ --n
]->GetTxtNode();
1560 bool bRemoved
= false;
1561 SwPaM
aPam( *pTxtNd
, 0, *pTxtNd
, pTxtNd
->GetTxt().Len() );
1562 if ( pTxtNd
->HasHiddenCharAttribute( true ) )
1567 // Remove hidden paragraph or delete contents:
1568 // Delete contents if
1569 // 1. removing the paragraph would result in an empty section or
1570 // 2. if the paragraph is the last paragraph in the section and
1571 // there is no paragraph in front of the paragraph:
1573 if ( ( 2 == pTxtNd
->EndOfSectionIndex() - pTxtNd
->StartOfSectionIndex() ) ||
1574 ( 1 == pTxtNd
->EndOfSectionIndex() - pTxtNd
->GetIndex() &&
1575 !GetNodes()[ pTxtNd
->GetIndex() - 1 ]->GetTxtNode() ) )
1577 DeleteRange( aPam
);
1582 DelFullPara( aPam
);
1585 else if ( pTxtNd
->HasHiddenCharAttribute( false ) )
1589 SwScriptInfo::DeleteHiddenRanges( *pTxtNd
);
1592 // --> FME 2006-01-11 #120473#
1593 // Footnotes/Frames may have been removed, therefore we have
1596 n
= aPam
.GetPoint()->nNode
.GetIndex();
1602 // dann noch alle versteckten Bereiche loeschen/leeren
1603 SwSectionFmts aSectFmts
;
1604 SwSectionFmts
& rSectFmts
= GetSections();
1607 for( n
= rSectFmts
.Count(); n
; )
1609 SwSectionFmt
* pSectFmt
= rSectFmts
[ --n
];
1610 // don't add sections in Undo/Redo
1611 if( !pSectFmt
->IsInNodesArr())
1613 SwSection
* pSect
= pSectFmt
->GetSection();
1614 if( pSect
->CalcHiddenFlag() )
1616 SwSection
* pParent
= pSect
, *pTmp
;
1617 while( 0 != (pTmp
= pParent
->GetParent() ))
1619 if( pTmp
->IsHiddenFlag() )
1624 if( USHRT_MAX
== aSectFmts
.GetPos( pSect
->GetFmt() ) )
1625 aSectFmts
.Insert( pSect
->GetFmt(), 0 );
1627 if( pSect
->GetCondition().Len() )
1629 SwSection
aSect( pSect
->GetType(), pSect
->GetName() );
1631 aSect
.SetCondition( aEmptyStr
);
1632 aSect
.SetHidden( FALSE
);
1633 ChgSection( n
, aSect
);
1637 if( 0 != ( n
= aSectFmts
.Count() ))
1641 SwSectionFmt
* pSectFmt
= aSectFmts
[ --n
];
1642 SwSectionNode
* pSectNd
= pSectFmt
->GetSectionNode();
1646 SwPaM
aPam( *pSectNd
);
1648 if( pSectNd
->StartOfSectionNode()->StartOfSectionIndex() ==
1649 pSectNd
->GetIndex() - 1 &&
1650 pSectNd
->StartOfSectionNode()->EndOfSectionIndex() ==
1651 pSectNd
->EndOfSectionIndex() + 1 )
1653 // nur den Inhalt loeschen
1654 SwCntntNode
* pCNd
= GetNodes().GoNext(
1655 &aPam
.GetPoint()->nNode
);
1656 aPam
.GetPoint()->nContent
.Assign( pCNd
, 0 );
1658 aPam
.GetPoint()->nNode
= *pSectNd
->EndOfSectionNode();
1659 pCNd
= GetNodes().GoPrevious(
1660 &aPam
.GetPoint()->nNode
);
1661 aPam
.GetPoint()->nContent
.Assign( pCNd
, pCNd
->Len() );
1663 DeleteRange( aPam
);
1667 // die gesamte Section loeschen
1669 aPam
.GetPoint()->nNode
= *pSectNd
->EndOfSectionNode();
1670 DelFullPara( aPam
);
1675 aSectFmts
.Remove( 0, aSectFmts
.Count() );
1681 EndUndo( UNDO_UI_DELETE_INVISIBLECNTNT
, NULL
);
1684 /*-- 11.06.2004 08:34:04---------------------------------------------------
1686 -----------------------------------------------------------------------*/
1687 BOOL
SwDoc::ConvertFieldsToText()
1691 StartUndo( UNDO_UI_REPLACE
, NULL
);
1693 const SwFldTypes
* pMyFldTypes
= GetFldTypes();
1694 sal_uInt16 nCount
= pMyFldTypes
->Count();
1695 //go backward, field types are removed
1696 for(sal_uInt16 nType
= nCount
; nType
> 0; --nType
)
1698 const SwFieldType
*pCurType
= pMyFldTypes
->GetObject(nType
- 1);
1700 if ( RES_POSTITFLD
== pCurType
->Which() )
1703 SwClientIter
aIter( *(SwFieldType
*)pCurType
);
1704 const SwFmtFld
* pCurFldFmt
= (SwFmtFld
*)aIter
.First( TYPE( SwFmtFld
));
1705 ::std::vector
<const SwFmtFld
*> aFieldFmts
;
1708 aFieldFmts
.push_back(pCurFldFmt
);
1709 pCurFldFmt
= (SwFmtFld
*)aIter
.Next();
1711 ::std::vector
<const SwFmtFld
*>::iterator aBegin
= aFieldFmts
.begin();
1712 ::std::vector
<const SwFmtFld
*>::iterator aEnd
= aFieldFmts
.end();
1713 while(aBegin
!= aEnd
)
1715 const SwTxtFld
*pTxtFld
= (*aBegin
)->GetTxtFld();
1716 // skip fields that are currently not in the document
1717 // e.g. fields in undo or redo array
1719 BOOL bSkip
= !pTxtFld
||
1720 !pTxtFld
->GetpTxtNode()->GetNodes().IsDocNodes();
1724 BOOL bInHeaderFooter
= IsInHeaderFooter(SwNodeIndex(*pTxtFld
->GetpTxtNode()));
1725 const SwFmtFld
& rFmtFld
= pTxtFld
->GetFld();
1726 const SwField
* pField
= rFmtFld
.GetFld();
1728 //#i55595# some fields have to be excluded in headers/footers
1729 USHORT nWhich
= pField
->GetTyp()->Which();
1730 if(!bInHeaderFooter
||
1731 (nWhich
!= RES_PAGENUMBERFLD
&&
1732 nWhich
!= RES_CHAPTERFLD
&&
1733 nWhich
!= RES_GETEXPFLD
&&
1734 nWhich
!= RES_SETEXPFLD
&&
1735 nWhich
!= RES_INPUTFLD
&&
1736 nWhich
!= RES_REFPAGEGETFLD
&&
1737 nWhich
!= RES_REFPAGESETFLD
))
1739 String sText
= pField
->GetCntnt();
1740 //database fields should not convert their command into text
1741 if( RES_DBFLD
== pCurType
->Which() && !static_cast<const SwDBField
*>(pField
)->IsInitialized())
1744 //now remove the field and insert the string
1745 SwPaM
aPam1(*pTxtFld
->GetpTxtNode(), *pTxtFld
->GetStart());
1747 //insert first to keep the field's attributes
1748 InsertString( aPam1
, sText
);
1749 SwPaM
aPam2(*pTxtFld
->GetpTxtNode(), *pTxtFld
->GetStart());
1752 DeleteAndJoin(aPam2
);//remove the field
1761 EndUndo( UNDO_UI_REPLACE
, NULL
);
1767 bool SwDoc::IsVisibleLinks() const
1769 return mbVisibleLinks
;
1772 void SwDoc::SetVisibleLinks(bool bFlag
)
1774 mbVisibleLinks
= bFlag
;
1777 SvxLinkManager
& SwDoc::GetLinkManager()
1782 const SvxLinkManager
& SwDoc::GetLinkManager() const
1787 void SwDoc::SetLinksUpdated(const bool bNewLinksUpdated
)
1789 mbLinksUpdated
= bNewLinksUpdated
;
1792 bool SwDoc::LinksUpdated() const
1794 return mbLinksUpdated
;
1797 // embedded alle lokalen Links (Bereiche/Grafiken)
1798 bool SwDoc::EmbedAllLinks()
1801 SvxLinkManager
& rLnkMgr
= GetLinkManager();
1802 const ::sfx2::SvBaseLinks
& rLnks
= rLnkMgr
.GetLinks();
1805 BOOL bDoesUndo
= DoesUndo();
1808 for( USHORT n
= 0; n
< rLnks
.Count(); ++n
)
1810 ::sfx2::SvBaseLink
* pLnk
= &(*rLnks
[ n
]);
1812 ( OBJECT_CLIENT_GRF
== pLnk
->GetObjType() ||
1813 OBJECT_CLIENT_FILE
== pLnk
->GetObjType() ) &&
1814 pLnk
->ISA( SwBaseLink
) )
1816 ::sfx2::SvBaseLinkRef xLink
= pLnk
;
1817 USHORT nCount
= rLnks
.Count();
1820 rLnkMgr
.GetDisplayNames( xLink
, 0, &sFName
, 0, 0 );
1822 INetURLObject
aURL( sFName
);
1823 if( INET_PROT_FILE
== aURL
.GetProtocol() ||
1824 INET_PROT_CID
== aURL
.GetProtocol() )
1826 // dem Link sagen, das er aufgeloest wird!
1829 // falls einer vergessen hat sich auszutragen
1831 rLnkMgr
.Remove( xLink
);
1833 if( nCount
!= rLnks
.Count() + 1 )
1834 n
= 0; // wieder von vorne anfangen, es wurden
1835 // mehrere Links entfernt
1842 DoUndo( bDoesUndo
);
1848 /*--------------------------------------------------------------------
1850 --------------------------------------------------------------------*/
1852 BOOL
SwDoc::IsInsTblFormatNum() const
1854 return SW_MOD()->IsInsTblFormatNum(get(IDocumentSettingAccess::HTML_MODE
));
1857 BOOL
SwDoc::IsInsTblChangeNumFormat() const
1859 return SW_MOD()->IsInsTblChangeNumFormat(get(IDocumentSettingAccess::HTML_MODE
));
1862 /*--------------------------------------------------------------------
1864 --------------------------------------------------------------------*/
1866 BOOL
SwDoc::IsInsTblAlignNum() const
1868 return SW_MOD()->IsInsTblAlignNum(get(IDocumentSettingAccess::HTML_MODE
));
1871 // setze das InsertDB als Tabelle Undo auf:
1872 void SwDoc::AppendUndoForInsertFromDB( const SwPaM
& rPam
, BOOL bIsTable
)
1876 const SwTableNode
* pTblNd
= rPam
.GetPoint()->nNode
.GetNode().FindTableNode();
1879 SwUndoCpyTbl
* pUndo
= new SwUndoCpyTbl
;
1880 pUndo
->SetTableSttIdx( pTblNd
->GetIndex() );
1881 AppendUndo( pUndo
);
1884 else if( rPam
.HasMark() )
1886 SwUndoCpyDoc
* pUndo
= new SwUndoCpyDoc( rPam
);
1887 pUndo
->SetInsertRange( rPam
, FALSE
);
1888 AppendUndo( pUndo
);
1892 void SwDoc::ChgTOX(SwTOXBase
& rTOX
, const SwTOXBase
& rNew
)
1898 SwUndo
* pUndo
= new SwUndoTOXChange(&rTOX
, rNew
);
1905 if (rTOX
.ISA(SwTOXBaseSection
))
1907 static_cast<SwTOXBaseSection
&>(rTOX
).Update();
1908 static_cast<SwTOXBaseSection
&>(rTOX
).UpdatePageNum();
1913 String
SwDoc::GetPaMDescr(const SwPaM
& rPam
) const
1918 if (rPam
.GetNode(TRUE
) == rPam
.GetNode(FALSE
))
1920 SwTxtNode
* pTxtNode
= rPam
.GetNode(TRUE
)->GetTxtNode();
1924 xub_StrLen nStart
= rPam
.Start()->nContent
.GetIndex();
1925 xub_StrLen nEnd
= rPam
.End()->nContent
.GetIndex();
1927 aResult
+= String(SW_RES(STR_START_QUOTE
));
1928 aResult
+= ShortenString(pTxtNode
->GetTxt().
1929 Copy(nStart
, nEnd
- nStart
),
1931 String(SW_RES(STR_LDOTS
)));
1932 aResult
+= String(SW_RES(STR_END_QUOTE
));
1937 else if (0 != rPam
.GetNode(TRUE
))
1939 if (0 != rPam
.GetNode(FALSE
))
1940 aResult
+= String(SW_RES(STR_PARAGRAPHS
));
1946 aResult
+= String("??", RTL_TEXTENCODING_ASCII_US
);
1952 SwField
* SwDoc::GetField(const SwPosition
& rPos
)
1954 SwTxtFld
* const pAttr
= GetTxtFld(rPos
);
1956 return (pAttr
) ? const_cast<SwField
*>( pAttr
->GetFld().GetFld() ) : 0;
1959 SwTxtFld
* SwDoc::GetTxtFld(const SwPosition
& rPos
)
1961 SwTxtNode
* const pNode
= rPos
.nNode
.GetNode().GetTxtNode();
1964 ? static_cast<SwTxtFld
*>( pNode
->GetTxtAttrForCharAt(
1965 rPos
.nContent
.GetIndex(), RES_TXTATR_FIELD
) )
1970 bool SwDoc::ContainsHiddenChars() const
1972 for( ULONG n
= GetNodes().Count(); n
; )
1974 SwNode
* pNd
= GetNodes()[ --n
];
1975 if ( ND_TEXTNODE
== pNd
->GetNodeType() &&
1976 ((SwTxtNode
*)pNd
)->HasHiddenCharAttribute( false ) )
1983 SwUnoCrsr
* SwDoc::CreateUnoCrsr( const SwPosition
& rPos
, BOOL bTblCrsr
)
1987 pNew
= new SwUnoTableCrsr( rPos
);
1989 pNew
= new SwUnoCrsr( rPos
);
1991 pUnoCrsrTbl
->Insert( pNew
, pUnoCrsrTbl
->Count() );
1995 void SwDoc::ChkCondColls()
1997 for (USHORT n
= 0; n
< pTxtFmtCollTbl
->Count(); n
++)
1999 SwTxtFmtColl
*pColl
= (*pTxtFmtCollTbl
)[n
];
2001 if (RES_CONDTXTFMTCOLL
== pColl
->Which())
2003 SwClientIter
aIter(*pColl
);
2005 SwClient
* pClient
= aIter
.First(TYPE(SwTxtNode
));
2008 SwTxtNode
* pTxtNode
= static_cast<SwTxtNode
*>(pClient
);
2010 pTxtNode
->ChkCondColl();
2012 pClient
= aIter
.Next();