merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / doc / doc.cxx
blobb52edf6bd73e32715dd96490dd6a5035121cf0eb
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 $
10 * $Revision: 1.71 $
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 #include <doc.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>
64 #include <fmtfld.hxx>
65 #include <txtfld.hxx>
66 #include <dbfld.hxx>
67 #include <txtinet.hxx>
68 #include <txtrfmrk.hxx>
69 #include <frmatr.hxx>
70 #include <linkenum.hxx>
71 #include <errhdl.hxx>
72 #include <pagefrm.hxx>
73 #include <rootfrm.hxx>
74 #include <swtable.hxx>
75 #include <pam.hxx>
76 #include <ndtxt.hxx>
77 #include <swundo.hxx> // fuer die UndoIds
78 #include <undobj.hxx>
79 #include <pagedesc.hxx> //DTor
80 #include <breakit.hxx>
81 #include <ndole.hxx>
82 #include <ndgrf.hxx>
83 #include <rolbck.hxx> // Undo-Attr
84 #include <doctxm.hxx> // fuer die Verzeichnisse
85 #include <grfatr.hxx>
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>
93 #include <docary.hxx>
94 #include <redline.hxx>
95 #include <fldupde.hxx>
96 #include <swbaslnk.hxx>
97 #include <printdata.hxx>
98 #ifndef _CMDID_H
99 #include <cmdid.h> // fuer den dflt - Printer in SetJob
100 #endif
101 #ifndef _STATSTR_HRC
102 #include <statstr.hrc> // StatLine-String
103 #endif
104 #include <comcore.hrc>
105 #include <SwUndoTOXChange.hxx>
106 #include <SwUndoFmt.hxx>
107 #include <unocrsr.hxx>
108 #include <docsh.hxx>
109 #include <vector>
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>
119 // <--
121 using namespace ::com::sun::star;
123 // Seiten-Deskriptoren
124 SV_IMPL_PTRARR(SwPageDescs,SwPageDescPtr);
125 // Verzeichnisse
126 SV_IMPL_PTRARR( SwTOXTypes, SwTOXTypePtr )
127 // FeldTypen
128 SV_IMPL_PTRARR( SwFldTypes, SwFldTypePtr)
130 /** IInterface
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
154 switch (id)
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;
178 // <--
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;
185 // <--
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;
198 default:
199 ASSERT(false, "Invalid setting id");
201 return false;
204 void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
206 switch (id)
208 // COMPATIBILITY FLAGS START
209 case PARA_SPACE_MAX:
210 mbParaSpaceMax = value;
211 break;
212 case PARA_SPACE_MAX_AT_PAGES:
213 mbParaSpaceMaxAtPages = value;
214 break;
215 case TAB_COMPAT:
216 mbTabCompat = value;
217 break;
218 case ADD_FLY_OFFSETS:
219 mbAddFlyOffsets = value;
220 break;
221 case ADD_EXT_LEADING:
222 mbAddExternalLeading = value;
223 break;
224 case USE_VIRTUAL_DEVICE:
225 mbUseVirtualDevice = value;
226 break;
227 case USE_HIRES_VIRTUAL_DEVICE:
228 mbUseHiResolutionVirtualDevice = value;
229 break;
230 case OLD_NUMBERING:
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);
239 UpdateNumRule();
241 if (pOutlineRule)
243 pOutlineRule->Validate();
244 // --> OD 2005-10-21 - counting of phantoms depends on <IsOldNumbering()>
245 pOutlineRule->SetCountPhantoms( !mbOldNumbering );
246 // <--
249 break;
250 case OLD_LINE_SPACING:
251 mbOldLineSpacing = value;
252 break;
253 case ADD_PARA_SPACING_TO_TABLE_CELLS:
254 mbAddParaSpacingToTableCells = value;
255 break;
256 case USE_FORMER_OBJECT_POS:
257 mbUseFormerObjectPos = value;
258 break;
259 case USE_FORMER_TEXT_WRAPPING:
260 mbUseFormerTextWrapping = value;
261 break;
262 case CONSIDER_WRAP_ON_OBJECT_POSITION:
263 mbConsiderWrapOnObjPos = value;
264 break;
265 case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
266 mbDoNotJustifyLinesWithManualBreak = value;
267 break;
268 case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
269 mbIgnoreFirstLineIndentInNumbering = value;
270 break;
272 case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE:
273 mbOutlineLevelYieldsOutlineRule = value;
274 break;
276 case TABLE_ROW_KEEP:
277 mbTableRowKeep = value;
278 break;
280 case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
281 mbIgnoreTabsAndBlanksForLineCalculation = value;
282 break;
284 case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
285 mbDoNotCaptureDrawObjsOnPage = value;
286 break;
288 // --> OD 2006-08-25 #i68949#
289 case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME:
290 mbClipAsCharacterAnchoredWriterFlyFrames = value;
291 break;
292 // <--
293 case UNIX_FORCE_ZERO_EXT_LEADING:
294 mbUnixForceZeroExtLeading = value;
295 break;
296 case PROTECT_FORM:
297 mbProtectForm = value;
298 break;
300 case USE_OLD_PRINTER_METRICS:
301 mbOldPrinterMetrics = value;
302 break;
303 case TABS_RELATIVE_TO_INDENT:
304 mbTabRelativeToIndent = value;
305 break;
306 // --> OD 2008-06-05 #i89181#
307 case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
308 mbTabAtLeftIndentForParagraphsInList = value;
309 break;
310 // <--
311 case INVERT_BORDER_SPACING:
312 mbInvertBorderSpacing = value;
313 break;
314 case COLLAPSE_EMPTY_CELL_PARA:
315 mbCollapseEmptyCellPara = value;
316 break;
317 // COMPATIBILITY FLAGS END
319 case BROWSE_MODE:
320 mbBrowseMode = value;
321 break;
322 case HTML_MODE:
323 mbHTMLMode = value;
324 break;
325 case GLOBAL_DOCUMENT:
326 mbIsGlobalDoc = value;
327 break;
328 case GLOBAL_DOCUMENT_SAVE_LINKS:
329 mbGlblDocSaveLinks = value;
330 break;
331 case LABEL_DOCUMENT:
332 mbIsLabelDoc = value;
333 break;
334 case PURGE_OLE:
335 mbPurgeOLE = value;
336 break;
337 case KERN_ASIAN_PUNCTUATION:
338 mbKernAsianPunctuation = value;
339 break;
340 case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
341 mbDoNotResetParaAttrsForNumFont = value;
342 break;
343 default:
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 );
356 return pRet;
359 void SwDoc::setForbiddenCharacters(/*[in]*/ USHORT nLang,
360 /*[in]*/ const i18n::ForbiddenCharacters& rFChars )
362 if( !xForbiddenCharsTable.isValid() )
364 uno::Reference<
365 lang::XMultiServiceFactory > xMSF =
366 ::comphelper::getProcessServiceFactory();
367 xForbiddenCharsTable = new SvxForbiddenCharactersTable( xMSF );
369 xForbiddenCharsTable->SetForbiddenCharacters( nLang, rFChars );
370 if( pDrawModel )
372 pDrawModel->SetForbiddenCharsTable( xForbiddenCharsTable );
373 if( !mbInReading )
374 pDrawModel->ReformatAllTextObjects();
377 if( pLayout && !mbInReading )
379 pLayout->StartAllAction();
380 pLayout->InvalidateAllCntnt();
381 pLayout->EndAllAction();
383 SetModified();
386 vos::ORef<SvxForbiddenCharactersTable>& SwDoc::getForbiddenCharacterTable()
388 if( !xForbiddenCharsTable.isValid() )
390 uno::Reference<
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));
408 return nRet;
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));
421 return eRet;
424 void SwDoc::setFieldUpdateFlags(/*[in]*/SwFldUpdateFlags eMode )
426 eFldUpdMode = eMode;
429 SwCharCompressType SwDoc::getCharacterCompressionType() const
431 return eChrCmprType;
434 void SwDoc::setCharacterCompressionType( /*[in]*/SwCharCompressType n )
436 if( eChrCmprType != n )
438 eChrCmprType = n;
439 if( pDrawModel )
441 pDrawModel->SetCharCompressType( static_cast<UINT16>(n) );
442 if( !mbInReading )
443 pDrawModel->ReformatAllTextObjects();
446 if( pLayout && !mbInReading )
448 pLayout->StartAllAction();
449 pLayout->InvalidateAllCntnt();
450 pLayout->EndAllAction();
452 SetModified();
456 /** IDocumentDeviceAccess
458 SfxPrinter* SwDoc::getPrinter(/*[in]*/ bool bCreate ) const
460 SfxPrinter* pRet = 0;
461 if ( !bCreate || pPrt )
462 pRet = pPrt;
463 else
464 pRet = &CreatePrinter_();
466 return pRet;
469 void SwDoc::setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged )
471 if ( pP != pPrt )
473 if ( bDeleteOld )
474 delete pPrt;
475 pPrt = pP;
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) )
482 // <--
483 PrtDataChanged();
486 VirtualDevice* SwDoc::getVirtualDevice(/*[in]*/ bool bCreate ) const
488 VirtualDevice* pRet = 0;
489 if ( !bCreate || pVirDev )
490 pRet = pVirDev;
491 else
492 pRet = &CreateVirtualDevice_();
494 return pRet;
497 void SwDoc::setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool )
499 if ( pVirDev != pVd )
501 if ( bDeleteOld )
502 delete pVirDev;
503 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 );
519 else
521 pRet = getVirtualDevice( bCreate );
524 return pRet;
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 )
532 if ( bNewVirtual )
534 VirtualDevice* pMyVirDev = getVirtualDevice( true );
535 if ( !bNewHiRes )
536 pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE06 );
537 else
538 pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
540 else
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()
548 getPrinter( true );
549 // <--
552 set(IDocumentSettingAccess::USE_VIRTUAL_DEVICE, bNewVirtual );
553 set(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE, bNewHiRes );
554 PrtDataChanged();
555 SetModified();
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;
569 if ( pPrt )
571 if ( pPrt->GetName() == rJobSetup.GetPrinterName() )
573 if ( pPrt->GetJobSetup() != rJobSetup )
575 pPrt->SetJobSetup( rJobSetup );
576 bDataChanged = TRUE;
579 else
580 delete pPrt, pPrt = 0;
583 if( !pPrt )
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,
591 0 );
592 SfxPrinter *p = new SfxPrinter( pSet, rJobSetup );
593 if ( bCheckPageDescs )
594 setPrinter( p, true, true );
595 else
597 pPrt = p;
598 bDataChanged = TRUE;
601 if ( bDataChanged && !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
602 PrtDataChanged();
605 SwPrintData* SwDoc::getPrintData() const
607 return pPrtData;
610 void SwDoc::setPrintData(/*[in]*/ const SwPrintData& rPrtData )
612 if(!pPrtData)
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 )
628 aDBData = rNewData;
629 SetModified();
631 GetSysFldType(RES_DBNAMEFLD)->UpdateFlds();
634 bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart )
636 SwCntntNode *pNode = rPos.nNode.GetNode().GetCntntNode();
637 if(0 == pNode)
638 return false;
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;
648 if ( DoesUndo() )
650 ClearRedo();
651 // einfuegen vom Undo-Object, z.Z. nur beim TextNode
652 if( pNode->IsTxtNode() )
654 pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart );
655 AppendUndo(pUndo);
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
662 // einen Absatz ein
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() )
683 pNd = 0;
684 else
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 ) )
690 pNd = 0;
694 if( pNd )
696 SwTxtNode* pTxtNd = GetNodes().MakeTxtNode(
697 SwNodeIndex( *pTblNd ),
698 GetTxtCollFromPool( RES_POOLCOLL_TEXT ));
699 if( pTxtNd )
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,
710 FALSE, &pItem ) )
712 pTxtNd->SetAttr( *pItem );
713 pFrmFmt->ResetFmtAttr( RES_PAGEDESC );
715 if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_BREAK,
716 FALSE, &pItem ) )
718 pTxtNd->SetAttr( *pItem );
719 pFrmFmt->ResetFmtAttr( RES_BREAK );
723 if( pUndo )
724 pUndo->SetTblFlag();
725 SetModified();
726 return true;
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 );
738 if (pNode)
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() ))
746 SwPaM aPam( rPos );
747 aPam.SetMark();
748 aPam.Move( fnMoveBackward );
749 if( IsRedlineOn() )
750 AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
751 else
752 SplitRedline( aPam );
756 SetModified();
757 return true;
760 bool SwDoc::AppendTxtNode( SwPosition& rPos )
763 * Neuen Node vor EndOfContent erzeugen.
765 SwTxtNode *pCurNode = GetNodes()[ rPos.nNode ]->GetTxtNode();
766 if( !pCurNode )
768 // dann kann ja einer angelegt werden!
769 SwNodeIndex aIdx( rPos.nNode, 1 );
770 pCurNode = GetNodes().MakeTxtNode( aIdx,
771 GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
773 else
774 pCurNode = (SwTxtNode*)pCurNode->AppendNode( rPos );
776 rPos.nNode++;
777 rPos.nContent.Assign( pCurNode, 0 );
779 if( DoesUndo() )
781 ClearRedo();
782 AppendUndo( new SwUndoInsert( rPos.nNode ));
785 if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() ))
787 SwPaM aPam( rPos );
788 aPam.SetMark();
789 aPam.Move( fnMoveBackward );
790 if( IsRedlineOn() )
791 AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
792 else
793 SplitRedline( aPam );
796 SetModified();
797 return TRUE;
800 bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr,
801 const enum InsertFlags nInsertMode )
803 if( DoesUndo() )
805 ClearRedo();
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();
820 if(!pNode)
822 return false;
825 SwDataChanged aTmp( rRg, 0 );
827 if( !DoesUndo() || !DoesGroupUndo() )
829 pNode->InsertText( rStr, rPos.nContent, nInsertMode );
831 if( DoesUndo() )
833 SwUndoInsert * const pUndo( new SwUndoInsert(
834 rPos.nNode, rPos.nContent.GetIndex(), rStr.Len(), nInsertMode));
835 AppendUndo(pUndo);
838 else
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))
844 // -> #111827#
846 USHORT const nUndoSize = pUndos->Count();
847 if (0 != nUndoSize)
849 SwUndo * const pLastUndo = (*pUndos)[ nUndoSize - 1 ];
851 switch (pLastUndo->GetId())
853 case UNDO_INSERT:
854 case UNDO_TYPING:
855 if (static_cast<SwUndoInsert*>(pLastUndo)
856 ->CanGrouping( rPos ))
858 pUndo = static_cast<SwUndoInsert*>(pLastUndo);
860 break;
862 default:
863 break;
867 // <- #111827#
869 CharClass const& rCC = GetAppCharClass();
870 xub_StrLen nInsPos = rPos.nContent.GetIndex();
872 if (!pUndo)
874 pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 0, nInsertMode,
875 !rCC.isLetterNumeric( rStr, 0 ) );
876 AppendUndo( pUndo );
879 pNode->InsertText( rStr, rPos.nContent, nInsertMode );
881 for( xub_StrLen i = 0; i < rStr.Len(); ++i )
883 nInsPos++;
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 ) );
889 AppendUndo( pUndo );
894 if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() ))
896 SwPaM aPam( rPos.nNode, aTmp.GetCntnt(),
897 rPos.nNode, rPos.nContent.GetIndex());
898 if( IsRedlineOn() )
900 AppendRedline(
901 new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
903 else
905 SplitRedline( aPam );
909 SetModified();
910 return true;
913 SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode,
914 const SfxItemSet* pFlyAttrSet,
915 const SfxItemSet* pGrfAttrSet,
916 SwFrmFmt* pFrmFmt)
918 SwFlyFrmFmt *pFmt = 0;
919 if( pNode )
921 pFmt = _MakeFlySection( rPos, *pNode, FLY_AT_CNTNT,
922 pFlyAttrSet, pFrmFmt );
923 if( pGrfAttrSet )
924 pNode->SetAttr( *pGrfAttrSet );
926 return pFmt;
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,
935 SwFrmFmt* pFrmFmt )
937 if( !pFrmFmt )
938 pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC );
939 return _InsNoTxtNode( *rRg.GetPoint(), GetNodes().MakeGrfNode(
940 SwNodeIndex( GetNodes().GetEndOfAutotext() ),
941 rGrfName, rFltName, pGraphic,
942 pDfltGrfFmtColl ),
943 pFlyAttrSet, pGrfAttrSet, pFrmFmt );
945 SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg, const GraphicObject& rGrfObj,
946 const SfxItemSet* pFlyAttrSet,
947 const SfxItemSet* pGrfAttrSet,
948 SwFrmFmt* pFrmFmt )
950 if( !pFrmFmt )
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,
961 SwFrmFmt* pFrmFmt )
963 if( !pFrmFmt )
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() ),
974 xObj,
975 pDfltGrfFmtColl ),
976 pFlyAttrSet, pGrfAttrSet,
977 pFrmFmt );
980 SwFlyFrmFmt* SwDoc::InsertOLE(const SwPaM &rRg, const String& rObjName,
981 sal_Int64 nAspect,
982 const SfxItemSet* pFlyAttrSet,
983 const SfxItemSet* pGrfAttrSet,
984 SwFrmFmt* pFrmFmt )
986 if( !pFrmFmt )
987 pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_OLE );
989 return _InsNoTxtNode( *rRg.GetPoint(),
990 GetNodes().MakeOLENode(
991 SwNodeIndex( GetNodes().GetEndOfAutotext() ),
992 rObjName,
993 nAspect,
994 pDfltGrfFmtColl,
995 0 ),
996 pFlyAttrSet, pGrfAttrSet,
997 pFrmFmt );
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];
1010 return 0;
1012 /*************************************************************************
1013 * void SetDocStat( const SwDocStat& rStat );
1014 *************************************************************************/
1016 void SwDoc::SetDocStat( const SwDocStat& rStat )
1018 *pDocStat = rStat;
1021 const SwDocStat& SwDoc::GetDocStat() const
1023 return *pDocStat;
1026 sal_uInt16 SwDoc::GetPageCount() const
1028 return GetRootFrm() ? GetRootFrm()->GetPageNum() : 0;
1031 const Size SwDoc::GetPageSize( sal_uInt16 nPageNum, bool bSkipEmptyPages ) const
1033 Size aSize;
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();
1047 return aSize;
1051 /*************************************************************************
1052 * void UpdateDocStat( const SwDocStat& rStat );
1053 *************************************************************************/
1055 void SwDoc::UpdateDocStat( SwDocStat& rStat )
1057 if( rStat.bModified )
1059 rStat.Reset();
1060 rStat.nPara = 0; // Default ist auf 1 !!
1061 SwNode* pNd;
1063 for( ULONG i = GetNodes().Count(); i; )
1065 switch( ( pNd = GetNodes()[ --i ])->GetNodeType() )
1067 case ND_TEXTNODE:
1068 ((SwTxtNode*)pNd)->CountWords( rStat, 0, ((SwTxtNode*)pNd)->GetTxt().Len() );
1069 break;
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);
1082 sal_Int32 n=0;
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;
1089 if ( rStat.nPage )
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();
1117 // Dokument - Info
1119 void SwDoc::DocInfoChgd( )
1121 GetSysFldType( RES_DOCINFOFLD )->UpdateFlds();
1122 GetSysFldType( RES_TEMPLNAMEFLD )->UpdateFlds();
1123 SetModified();
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 ) ))
1134 continue;
1136 const SwFmtRefMark* pFmtRef = (SwFmtRefMark*)pItem;
1137 const SwTxtRefMark* pTxtRef = pFmtRef->GetTxtRefMark();
1138 if( pTxtRef && &pTxtRef->GetTxtNode().GetNodes() == &GetNodes() &&
1139 rName.Equals( pFmtRef->GetRefName() ) )
1140 return pFmtRef;
1142 return 0;
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 );
1153 USHORT nCount = 0;
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;
1162 break;
1164 nCount++;
1166 return pRet;
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 );
1179 USHORT nCount = 0;
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() )
1185 if( pNames )
1187 String* pTmp = new String( ((SwFmtRefMark*)pItem)->GetRefName() );
1188 pNames->Insert( pTmp, nCount );
1190 nCount ++;
1193 return nCount;
1196 bool SwDoc::IsLoaded() const
1198 return mbLoaded;
1201 bool SwDoc::IsUpdateExpFld() const
1203 return mbUpdateExpFld;
1206 bool SwDoc::IsNewDoc() const
1208 return mbNewDoc;
1211 bool SwDoc::IsPageNums() const
1213 return mbPageNums;
1216 void SwDoc::SetPageNums(bool b)
1218 mbPageNums = b;
1221 void SwDoc::SetNewDoc(bool b)
1223 mbNewDoc = b;
1226 void SwDoc::SetUpdateExpFldStat(bool b)
1228 mbUpdateExpFld = b;
1231 void SwDoc::SetLoaded(bool b)
1233 mbLoaded = b;
1236 bool SwDoc::IsModified() const
1238 return mbModified;
1241 void SwDoc::SetModified()
1243 // --> OD 2005-08-29 #125370#
1244 SwLayouter::ClearMovedFwdFrms( *this );
1245 SwLayouter::ClearObjsTmpConsiderWrapInfluence( *this );
1246 SwLayouter::ClearFrmsNotToWrap( *this );
1247 // <--
1248 // --> OD 2006-05-10 #i65250#
1249 SwLayouter::ClearMoveBwdLayoutInfo( *this );
1250 // <--
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;
1255 mbModified = TRUE;
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;
1274 mbModified = FALSE;
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 )
1293 SwGrfNode *pGrfNd;
1294 if( ( !rPam.HasMark()
1295 || rPam.GetPoint()->nNode.GetIndex() == rPam.GetMark()->nNode.GetIndex() )
1296 && 0 != ( pGrfNd = rPam.GetPoint()->nNode.GetNode().GetGrfNode() ) )
1298 if( DoesUndo() )
1300 ClearRedo();
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 );
1311 SetModified();
1315 BOOL lcl_SpellAndGrammarAgain( const SwNodePtr& rpNd, void* pArgs )
1317 SwTxtNode *pTxtNode = (SwTxtNode*)rpNd->GetTxtNode();
1318 BOOL bOnlyWrong = *(BOOL*)pArgs;
1319 if( pTxtNode )
1321 if( bOnlyWrong )
1323 if( pTxtNode->GetWrong() &&
1324 pTxtNode->GetWrong()->InvalidateWrong() )
1325 pTxtNode->SetWrongDirty( true );
1326 if( pTxtNode->GetGrammarCheck() &&
1327 pTxtNode->GetGrammarCheck()->InvalidateWrong() )
1328 pTxtNode->SetGrammarCheckDirty( true );
1330 else
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 );
1340 return TRUE;
1343 BOOL lcl_CheckSmartTagsAgain( const SwNodePtr& rpNd, void* )
1345 SwTxtNode *pTxtNode = (SwTxtNode*)rpNd->GetTxtNode();
1346 // BOOL bOnlyWrong = *(BOOL*)pArgs;
1347 if( pTxtNode )
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 );
1358 return TRUE;
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
1368 * gesetzt.
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?" );
1376 if( bInvalid )
1378 SwPageFrm *pPage = (SwPageFrm*)GetRootFrm()->Lower();
1379 while ( pPage )
1381 if ( bSmartTags )
1382 pPage->InvalidateSmartTags();
1384 pPage->InvalidateSpelling();
1385 pPage = (SwPageFrm*)pPage->GetNext();
1387 GetRootFrm()->SetNeedGrammarCheck( true );
1389 if ( bSmartTags )
1390 GetNodes().ForEach( lcl_CheckSmartTagsAgain, &bOnlyWrong );
1392 GetNodes().ForEach( lcl_SpellAndGrammarAgain, &bOnlyWrong );
1395 GetRootFrm()->SetIdleFlags();
1398 void SwDoc::InvalidateAutoCompleteFlag()
1400 if( GetRootFrm() )
1402 SwPageFrm *pPage = (SwPageFrm*)GetRootFrm()->Lower();
1403 while ( pPage )
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() )
1431 return pItem;
1434 return 0;
1437 void SwDoc::Summary( SwDoc* pExtDoc, BYTE nLevel, BYTE nPara, BOOL bImpress )
1439 const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds();
1440 if( pExtDoc && rOutNds.Count() )
1442 USHORT i;
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
1452 if( nLvl > nLevel )
1453 continue;
1454 USHORT nEndOfs = 1;
1455 BYTE nWish = nPara;
1456 ULONG nNextOutNd = i + 1 < rOutNds.Count() ?
1457 rOutNds[ i + 1 ]->GetIndex() : GetNodes().Count();
1458 BOOL bKeep = FALSE;
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 )
1464 --nWish;
1465 bKeep = pTxtNode->GetSwAttrSet().GetKeep().GetValue();
1466 ++nEndOfs;
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() );
1476 ++aEndOfDoc;
1477 while( aIndx < aEndOfDoc )
1479 SwNode *pNode;
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 );
1486 if( bImpress )
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 );
1497 if( !pNd->Len() &&
1498 pNd->StartOfSectionIndex()+2 < pNd->EndOfSectionIndex() )
1500 bDelete = TRUE;
1501 pExtDoc->GetNodes().Delete( aIndx );
1504 if( !bDelete )
1505 ++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()
1515 BOOL bRet = FALSE;
1516 StartUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL );
1519 SwTxtNode* pTxtNd;
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() )
1529 bRet = TRUE;
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 );
1543 else
1545 aPam.DeleteMark();
1546 DelFullPara( aPam );
1553 // Remove any hidden paragraph (hidden text attribute)
1555 for( ULONG n = GetNodes().Count(); n; )
1557 SwTxtNode* pTxtNd = GetNodes()[ --n ]->GetTxtNode();
1558 if ( pTxtNd )
1560 bool bRemoved = false;
1561 SwPaM aPam( *pTxtNd, 0, *pTxtNd, pTxtNd->GetTxt().Len() );
1562 if ( pTxtNd->HasHiddenCharAttribute( true ) )
1564 bRemoved = TRUE;
1565 bRet = 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 );
1579 else
1581 aPam.DeleteMark();
1582 DelFullPara( aPam );
1585 else if ( pTxtNd->HasHiddenCharAttribute( false ) )
1587 bRemoved = TRUE;
1588 bRet = TRUE;
1589 SwScriptInfo::DeleteHiddenRanges( *pTxtNd );
1592 // --> FME 2006-01-11 #120473#
1593 // Footnotes/Frames may have been removed, therefore we have
1594 // to reset n:
1595 if ( bRemoved )
1596 n = aPam.GetPoint()->nNode.GetIndex();
1597 // <--
1602 // dann noch alle versteckten Bereiche loeschen/leeren
1603 SwSectionFmts aSectFmts;
1604 SwSectionFmts& rSectFmts = GetSections();
1605 USHORT n;
1607 for( n = rSectFmts.Count(); n; )
1609 SwSectionFmt* pSectFmt = rSectFmts[ --n ];
1610 // don't add sections in Undo/Redo
1611 if( !pSectFmt->IsInNodesArr())
1612 continue;
1613 SwSection* pSect = pSectFmt->GetSection();
1614 if( pSect->CalcHiddenFlag() )
1616 SwSection* pParent = pSect, *pTmp;
1617 while( 0 != (pTmp = pParent->GetParent() ))
1619 if( pTmp->IsHiddenFlag() )
1620 pSect = pTmp;
1621 pParent = pTmp;
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() );
1630 aSect = *pSect;
1631 aSect.SetCondition( aEmptyStr );
1632 aSect.SetHidden( FALSE );
1633 ChgSection( n, aSect );
1637 if( 0 != ( n = aSectFmts.Count() ))
1639 while( n )
1641 SwSectionFmt* pSectFmt = aSectFmts[ --n ];
1642 SwSectionNode* pSectNd = pSectFmt->GetSectionNode();
1643 if( pSectNd )
1645 bRet = TRUE;
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 );
1657 aPam.SetMark();
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 );
1665 else
1667 // die gesamte Section loeschen
1668 aPam.SetMark();
1669 aPam.GetPoint()->nNode = *pSectNd->EndOfSectionNode();
1670 DelFullPara( aPam );
1675 aSectFmts.Remove( 0, aSectFmts.Count() );
1679 if( bRet )
1680 SetModified();
1681 EndUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL );
1682 return bRet;
1684 /*-- 11.06.2004 08:34:04---------------------------------------------------
1686 -----------------------------------------------------------------------*/
1687 BOOL SwDoc::ConvertFieldsToText()
1689 BOOL bRet = FALSE;
1690 LockExpFlds();
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() )
1701 continue;
1703 SwClientIter aIter( *(SwFieldType*)pCurType );
1704 const SwFmtFld* pCurFldFmt = (SwFmtFld*)aIter.First( TYPE( SwFmtFld ));
1705 ::std::vector<const SwFmtFld*> aFieldFmts;
1706 while (pCurFldFmt)
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();
1722 if (!bSkip)
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())
1742 sText.Erase();
1744 //now remove the field and insert the string
1745 SwPaM aPam1(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart());
1746 aPam1.Move();
1747 //insert first to keep the field's attributes
1748 InsertString( aPam1, sText );
1749 SwPaM aPam2(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart());
1750 aPam2.SetMark();
1751 aPam2.Move();
1752 DeleteAndJoin(aPam2);//remove the field
1755 ++aBegin;
1759 if( bRet )
1760 SetModified();
1761 EndUndo( UNDO_UI_REPLACE, NULL );
1762 UnlockExpFlds();
1763 return bRet;
1767 bool SwDoc::IsVisibleLinks() const
1769 return mbVisibleLinks;
1772 void SwDoc::SetVisibleLinks(bool bFlag)
1774 mbVisibleLinks = bFlag;
1777 SvxLinkManager& SwDoc::GetLinkManager()
1779 return *pLinkMgr;
1782 const SvxLinkManager& SwDoc::GetLinkManager() const
1784 return *pLinkMgr;
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()
1800 BOOL bRet = FALSE;
1801 SvxLinkManager& rLnkMgr = GetLinkManager();
1802 const ::sfx2::SvBaseLinks& rLnks = rLnkMgr.GetLinks();
1803 if( rLnks.Count() )
1805 BOOL bDoesUndo = DoesUndo();
1806 DoUndo( FALSE );
1808 for( USHORT n = 0; n < rLnks.Count(); ++n )
1810 ::sfx2::SvBaseLink* pLnk = &(*rLnks[ n ]);
1811 if( pLnk &&
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();
1819 String sFName;
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!
1827 xLink->Closed();
1829 // falls einer vergessen hat sich auszutragen
1830 if( xLink.Is() )
1831 rLnkMgr.Remove( xLink );
1833 if( nCount != rLnks.Count() + 1 )
1834 n = 0; // wieder von vorne anfangen, es wurden
1835 // mehrere Links entfernt
1836 bRet = TRUE;
1841 DelAllUndoObj();
1842 DoUndo( bDoesUndo );
1843 SetModified();
1845 return bRet;
1848 /*--------------------------------------------------------------------
1849 Beschreibung:
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 /*--------------------------------------------------------------------
1863 Beschreibung:
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 )
1874 if( bIsTable )
1876 const SwTableNode* pTblNd = rPam.GetPoint()->nNode.GetNode().FindTableNode();
1877 if( pTblNd )
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)
1894 if (DoesUndo())
1896 DelAllUndoObj();
1898 SwUndo * pUndo = new SwUndoTOXChange(&rTOX, rNew);
1900 AppendUndo(pUndo);
1903 rTOX = rNew;
1905 if (rTOX.ISA(SwTOXBaseSection))
1907 static_cast<SwTOXBaseSection &>(rTOX).Update();
1908 static_cast<SwTOXBaseSection &>(rTOX).UpdatePageNum();
1912 // #111827#
1913 String SwDoc::GetPaMDescr(const SwPaM & rPam) const
1915 String aResult;
1916 bool bOK = false;
1918 if (rPam.GetNode(TRUE) == rPam.GetNode(FALSE))
1920 SwTxtNode * pTxtNode = rPam.GetNode(TRUE)->GetTxtNode();
1922 if (0 != pTxtNode)
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),
1930 nUndoStringLength,
1931 String(SW_RES(STR_LDOTS)));
1932 aResult += String(SW_RES(STR_END_QUOTE));
1934 bOK = true;
1937 else if (0 != rPam.GetNode(TRUE))
1939 if (0 != rPam.GetNode(FALSE))
1940 aResult += String(SW_RES(STR_PARAGRAPHS));
1942 bOK = true;
1945 if (! bOK)
1946 aResult += String("??", RTL_TEXTENCODING_ASCII_US);
1948 return aResult;
1951 // -> #111840#
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();
1963 return (pNode)
1964 ? static_cast<SwTxtFld*>( pNode->GetTxtAttrForCharAt(
1965 rPos.nContent.GetIndex(), RES_TXTATR_FIELD) )
1966 : 0;
1968 // <- #111840#
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 ) )
1977 return true;
1980 return false;
1983 SwUnoCrsr* SwDoc::CreateUnoCrsr( const SwPosition& rPos, BOOL bTblCrsr )
1985 SwUnoCrsr* pNew;
1986 if( bTblCrsr )
1987 pNew = new SwUnoTableCrsr( rPos );
1988 else
1989 pNew = new SwUnoCrsr( rPos );
1991 pUnoCrsrTbl->Insert( pNew, pUnoCrsrTbl->Count() );
1992 return pNew;
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));
2006 while (pClient)
2008 SwTxtNode * pTxtNode = static_cast<SwTxtNode *>(pClient);
2010 pTxtNode->ChkCondColl();
2012 pClient = aIter.Next();