a11y: Simplify OCommonAccessibleComponent::getAccessibleIndexInParent
[LibreOffice.git] / sw / inc / doc.hxx
blobca8da4e293e3b979331363a2165a72016262a3c8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #pragma once
21 // SwDoc interfaces
22 #include <o3tl/typed_flags_set.hxx>
23 #include <o3tl/sorted_vector.hxx>
24 #include <vcl/idle.hxx>
25 #include "swdllapi.h"
26 #include "swtypes.hxx"
27 #include "toxe.hxx"
28 #include "flyenum.hxx"
29 #include "flypos.hxx"
30 #include "swdbdata.hxx"
31 #include <sfx2/objsh.hxx>
32 #include <svl/style.hxx>
33 #include <editeng/numitem.hxx>
34 #include "tox.hxx"
35 #include "frmfmt.hxx"
36 #include "frameformats.hxx"
37 #include "charfmt.hxx"
38 #include "docary.hxx"
39 #include "charformats.hxx"
40 #include "pagedesc.hxx"
41 #include "tblenum.hxx"
42 #include "ndarr.hxx"
43 #include "ndtyp.hxx"
44 #include <memory>
45 #include <mutex>
46 #include <set>
47 #include <tuple>
48 #include <unordered_map>
49 #include <vector>
51 namespace editeng { class SvxBorderLine; }
53 class SwExtTextInput;
54 class EditFieldInfo;
55 class Outliner;
56 class OutputDevice;
57 class Point;
58 class SbxArray;
59 class SdrObject;
60 class SdrUndoAction;
61 class SvNumberFormatter;
62 class SvxMacro;
63 class SwAutoCompleteWord;
64 class SwAutoCorrExceptWord;
65 class SwCellFrame;
66 class SwCellStyleTable;
67 class SwCursorShell;
68 class SwCursor;
69 class SwDocShell;
70 class SwDrawView;
71 class SwEditShell;
72 class SwFormat;
73 class SwFormatINetFormat;
74 class SwFormatRefMark;
75 class SwFootnoteIdxs;
76 class SwFootnoteInfo;
77 class SwEndNoteInfo;
78 class SwLineNumberInfo;
79 class SwDBManager;
80 class SwNodeIndex;
81 class SwNodeRange;
82 class SwNumRule;
83 class SwPagePreviewPrtData;
84 class SwRootFrame;
85 class SwRubyListEntry;
86 class SwSectionFormat;
87 class SwSectionData;
88 class SwSelBoxes;
89 class SwTableAutoFormatTable;
90 class SwTOXBaseSection;
91 class SwTabCols;
92 class SwTable;
93 class SwTableAutoFormat;
94 class SwTableBox;
95 class SwTableBoxFormat;
96 class SwTableFormat;
97 class SwTableLineFormat;
98 class SwTableNode;
99 class SwTextBlocks;
100 class SwURLStateChanged;
101 class SwUnoCursor;
102 class SwViewShell;
103 class SwDrawContact;
104 class SdrView;
105 class SdrMarkList;
106 class SwAuthEntry;
107 class SwLayoutCache;
108 class IStyleAccess;
109 struct SwCallMouseEvent;
110 struct SwDocStat;
111 struct SwSortOptions;
112 struct SwDefTOXBase_Impl;
113 class SwPrintUIOptions;
114 struct SwConversionArgs;
115 class SwRenderData;
116 class IDocumentUndoRedo;
117 class IDocumentSettingAccess;
118 class IDocumentDeviceAccess;
119 class IDocumentDrawModelAccess;
120 class IDocumentChartDataProviderAccess;
121 class IDocumentTimerAccess;
122 class IDocumentLinksAdministration;
123 class IDocumentListItems;
124 class IDocumentListsAccess;
125 class IDocumentOutlineNodes;
126 class IDocumentContentOperations;
127 class IDocumentRedlineAccess;
128 class IDocumentStatistics;
129 class IDocumentState;
130 class IDocumentLayoutAccess;
131 class IDocumentStylePoolAccess;
132 class IDocumentExternalData;
133 class IDocumentMarkAccess;
134 class SetGetExpFields;
135 struct SwInsertTableOptions;
136 class SwContentControlManager;
137 enum class SvMacroItemId : sal_uInt16;
138 enum class SvxFrameDirection;
139 enum class RndStdIds;
141 namespace sw::mark { class MarkManager; }
142 namespace sw {
143 enum class RedlineMode;
144 enum class FieldmarkMode;
145 enum class ParagraphBreakMode;
146 class MetaFieldManager;
147 class UndoManager;
148 class IShellCursorSupplier;
149 class DocumentSettingManager;
150 class DocumentDeviceManager;
151 class DocumentDrawModelManager;
152 class DocumentChartDataProviderManager;
153 class DocumentTimerManager;
154 class DocumentLinksAdministrationManager;
155 class DocumentListItemsManager;
156 class DocumentListsManager;
157 class DocumentOutlineNodesManager;
158 class DocumentContentOperationsManager;
159 class DocumentRedlineManager;
160 class DocumentFieldsManager;
161 class DocumentStatisticsManager;
162 class DocumentStateManager;
163 class DocumentLayoutManager;
164 class DocumentStylePoolManager;
165 class DocumentExternalDataManager;
166 template<class T> class FrameFormats;
167 class GrammarContact;
168 class OnlineAccessibilityCheck;
171 namespace com::sun::star {
172 namespace container {
173 class XNameContainer; //< for getXForms()/isXForms()/initXForms() methods
175 namespace embed { class XStorage; }
176 namespace linguistic2 { class XHyphenatedWord; }
177 namespace linguistic2 { class XProofreadingIterator; }
178 namespace linguistic2 { class XSpellChecker1; }
179 namespace script::vba { class XVBAEventProcessor; }
182 namespace ooo::vba::word {
183 class XFind;
186 namespace sfx2 {
187 class IXmlIdRegistry;
190 void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem );
192 using SwRubyList = std::vector<std::unique_ptr<SwRubyListEntry>>;
194 // Represents the model of a Writer document.
195 class SwDoc final
197 friend class ::sw::DocumentContentOperationsManager;
199 friend void InitCore();
200 friend void FinitCore();
202 // private Member
203 std::unique_ptr<SwNodes> m_pNodes; //< document content (Nodes Array)
204 rtl::Reference<SwAttrPool> mpAttrPool; //< the attribute pool
205 SwPageDescs m_PageDescs; //< PageDescriptors
206 Link<bool,void> maOle2Link; //< OLE 2.0-notification
207 /* @@@MAINTAINABILITY-HORROR@@@
208 Timer should not be members of the model
210 Idle maOLEModifiedIdle; //< Timer for update modified OLE-Objects
211 SwDBData maDBData; //< database descriptor
212 OUString msTOIAutoMarkURL; //< URL of table of index AutoMark file
213 std::vector<OUString> m_PatternNames; //< Array for names of document-templates
214 css::uno::Reference<css::container::XNameContainer>
215 mxXForms; //< container with XForms models
216 mutable css::uno::Reference< css::linguistic2::XProofreadingIterator > m_xGCIterator;
218 const std::unique_ptr< ::sw::mark::MarkManager> mpMarkManager;
219 const std::unique_ptr< ::sw::MetaFieldManager > m_pMetaFieldManager;
220 const std::unique_ptr< ::SwContentControlManager > m_pContentControlManager;
221 const std::unique_ptr< ::sw::DocumentDrawModelManager > m_pDocumentDrawModelManager;
222 const std::unique_ptr< ::sw::DocumentRedlineManager > m_pDocumentRedlineManager;
223 const std::unique_ptr< ::sw::DocumentStateManager > m_pDocumentStateManager;
224 const std::unique_ptr< ::sw::UndoManager > m_pUndoManager;
225 const std::unique_ptr< ::sw::DocumentSettingManager > m_pDocumentSettingManager;
226 const std::unique_ptr< ::sw::DocumentChartDataProviderManager > m_pDocumentChartDataProviderManager;
227 std::unique_ptr< ::sw::DocumentDeviceManager > m_pDeviceAccess;
228 const std::unique_ptr< ::sw::DocumentTimerManager > m_pDocumentTimerManager;
229 const std::unique_ptr< ::sw::DocumentLinksAdministrationManager > m_pDocumentLinksAdministrationManager;
230 const std::unique_ptr< ::sw::DocumentListItemsManager > m_pDocumentListItemsManager;
231 const std::unique_ptr< ::sw::DocumentListsManager > m_pDocumentListsManager;
232 const std::unique_ptr< ::sw::DocumentOutlineNodesManager > m_pDocumentOutlineNodesManager;
233 const std::unique_ptr< ::sw::DocumentContentOperationsManager > m_pDocumentContentOperationsManager;
234 const std::unique_ptr< ::sw::DocumentFieldsManager > m_pDocumentFieldsManager;
235 const std::unique_ptr< ::sw::DocumentStatisticsManager > m_pDocumentStatisticsManager;
236 const std::unique_ptr< ::sw::DocumentLayoutManager > m_pDocumentLayoutManager;
237 const std::unique_ptr< ::sw::DocumentStylePoolManager > m_pDocumentStylePoolManager;
238 const std::unique_ptr< ::sw::DocumentExternalDataManager > m_pDocumentExternalDataManager;
240 // Pointer
241 std::unique_ptr<SwFrameFormat> mpDfltFrameFormat; //< Default formats.
242 std::unique_ptr<SwFrameFormat> mpEmptyPageFormat; //< Format for the default empty page
243 std::unique_ptr<SwFrameFormat> mpColumnContFormat; //< Format for column container
244 std::unique_ptr<SwCharFormat> mpDfltCharFormat;
245 std::unique_ptr<SwTextFormatColl> mpDfltTextFormatColl; //< Defaultformatcollections
246 std::unique_ptr<SwGrfFormatColl> mpDfltGrfFormatColl;
248 std::unique_ptr<sw::FrameFormats<SwFrameFormat*>> mpFrameFormatTable; //< Format table
249 std::unique_ptr<SwCharFormats> mpCharFormatTable;
250 std::unique_ptr<SwCharFormats> mpCharFormatDeletionTable;
251 std::unique_ptr<sw::FrameFormats<sw::SpzFrameFormat*>> mpSpzFrameFormatTable;
252 std::unique_ptr<SwSectionFormats> mpSectionFormatTable;
253 std::unique_ptr<sw::TableFrameFormats> mpTableFrameFormatTable; //< For tables
254 std::unique_ptr<SwTextFormatColls> mpTextFormatCollTable; //< FormatCollections
255 std::unique_ptr<SwGrfFormatColls> mpGrfFormatCollTable;
257 std::unique_ptr<SwTOXTypes> mpTOXTypes; //< Tables/indices
258 std::unique_ptr<SwDefTOXBase_Impl> mpDefTOXBases; //< defaults of SwTOXBase's
260 std::unique_ptr<SwDBManager> m_pOwnDBManager; //< own DBManager
261 SwDBManager * m_pDBManager; //< DBManager for evaluation of DB-fields.
263 SwNumRule *mpOutlineRule;
264 std::unique_ptr<SwFootnoteInfo> mpFootnoteInfo;
265 std::unique_ptr<SwEndNoteInfo> mpEndNoteInfo;
266 std::unique_ptr<SwLineNumberInfo> mpLineNumberInfo;
267 std::unique_ptr<SwFootnoteIdxs> mpFootnoteIdxs;
269 SwDocShell *mpDocShell; //< Ptr to SfxDocShell of Doc.
270 SfxObjectShellLock mxTmpDocShell; //< A temporary shell that is used to copy OLE-Nodes
272 std::unique_ptr<SwAutoCorrExceptWord> mpACEWord; /**< For the automated takeover of
273 auto-corrected words that are "re-corrected". */
274 std::unique_ptr<SwURLStateChanged> mpURLStateChgd; //< SfxClient for changes in INetHistory
276 std::mutex mNumberFormatterMutex;
277 SvNumberFormatter* mpNumberFormatter; //< NumFormatter for tables / fields
279 mutable std::unique_ptr<SwNumRuleTable> mpNumRuleTable; //< List of all named NumRules.
281 // Hash map to find numrules by name
282 mutable std::unordered_map<OUString, SwNumRule *> maNumRuleMap;
284 std::unique_ptr<SwPagePreviewPrtData> m_pPgPViewPrtData; //< Indenting / spacing for printing of page view.
285 SwExtTextInput *mpExtInputRing;
287 std::unique_ptr<IStyleAccess> mpStyleAccess; //< handling of automatic styles
288 std::unique_ptr<SwLayoutCache> mpLayoutCache; /**< Layout cache to read and save with the
289 document for a faster formatting */
291 std::unique_ptr<sw::GrammarContact> mpGrammarContact; //< for grammar checking in paragraphs during editing
292 std::unique_ptr<sw::OnlineAccessibilityCheck> mpOnlineAccessibilityCheck;
294 css::uno::Reference< css::script::vba::XVBAEventProcessor > mxVbaEvents;
295 css::uno::Reference< ooo::vba::word::XFind > mxVbaFind;
296 css::uno::Reference<css::container::XNameContainer> m_xTemplateToProjectCache;
298 /// Table styles (autoformats that are applied with table changes).
299 std::unique_ptr<SwTableAutoFormatTable> m_pTableStyles;
300 /// Cell Styles not assigned to a Table Style
301 std::unique_ptr<SwCellStyleTable> mpCellStyles;
302 private:
303 std::unique_ptr< ::sfx2::IXmlIdRegistry > m_pXmlIdRegistry;
305 // other
307 sal_uInt32 mnRsid; //< current session ID of the document
308 sal_uInt32 mnRsidRoot; //< session ID when the document was created
310 oslInterlockedCount mReferenceCount;
312 bool mbDtor : 1; /**< TRUE: is in SwDoc DTOR.
313 and unfortunately temporarily also in
314 SwSwgReader::InLayout() when flawed
315 frames need deletion. */
316 bool mbCopyIsMove : 1; //< TRUE: Copy is a hidden Move.
317 bool mbInReading : 1; //< TRUE: Document is in the process of being read.
318 bool mbInWriting : 1; //< TRUE: Document is in the process of being written.
319 bool mbInMailMerge : 1; //< TRUE: Document is in the process of being written by mail merge.
320 bool mbInXMLImport : 1; //< TRUE: During xml import, attribute portion building is not necessary.
321 bool mbInWriterfilterImport : 1; //< TRUE: writerfilter import (DOCX,RTF)
322 bool mbUpdateTOX : 1; //< TRUE: After loading document, update TOX.
323 bool mbInLoadAsynchron : 1; //< TRUE: Document is in the process of being loaded asynchronously.
324 bool mbIsAutoFormatRedline : 1; //< TRUE: Redlines are recorded by Autoformat.
325 bool mbOLEPrtNotifyPending : 1; /**< TRUE: Printer has changed. At creation of View
326 notification of OLE-Objects PrtOLENotify() is required. */
327 bool mbAllOLENotify : 1; //< True: Notification of all objects is required.
328 bool mbInsOnlyTextGlssry : 1; //< True: insert 'only text' glossary into doc
329 bool mbContains_MSVBasic : 1; //< True: MS-VBasic exist is in our storage
330 bool mbClipBoard : 1; //< TRUE: this document represents the clipboard
331 bool mbColumnSelection : 1; //< TRUE: this content has been created by a column selection (clipboard docs only)
332 bool mbIsPrepareSelAll : 1;
334 enum MissingDictionary { False = -1, Undefined = 0, True = 1 };
335 MissingDictionary meDictionaryMissing;
337 // true: Document contains at least one anchored object, which is anchored AT_PAGE with a content position.
338 // Thus, certain adjustment needed during formatting for these kind of anchored objects.
339 bool mbContainsAtPageObjWithContentAnchor : 1;
341 static SwAutoCompleteWord *s_pAutoCompleteWords; //< List of all words for AutoComplete
342 /// The last, still alive SwDoc instance, for debugging.
343 static SwDoc* s_pLast;
345 // private methods
346 SwFlyFrameFormat* MakeFlySection_( const SwPosition& rAnchPos,
347 const SwContentNode& rNode, RndStdIds eRequestId,
348 const SfxItemSet* pFlyAttrSet,
349 SwFrameFormat* );
350 sal_Int8 SetFlyFrameAnchor( SwFrameFormat& rFlyFormat, SfxItemSet& rSet, bool bNewFrames );
352 typedef SwFormat* (SwDoc::*FNCopyFormat)( const OUString&, SwFormat*, bool );
353 SwFormat* CopyFormat( const SwFormat& rFormat, const SwFormatsBase& rFormatArr,
354 FNCopyFormat fnCopyFormat, const SwFormat& rDfltFormat );
355 void CopyFormatArr( const SwFormatsBase& rSourceArr, SwFormatsBase const & rDestArr,
356 FNCopyFormat fnCopyFormat, SwFormat& rDfltFormat );
357 SW_DLLPUBLIC void CopyPageDescHeaderFooterImpl( bool bCpyHeader,
358 const SwFrameFormat& rSrcFormat, SwFrameFormat& rDestFormat );
360 SwDoc( const SwDoc &) = delete;
362 // Database fields:
363 void AddUsedDBToList( std::vector<OUString>& rDBNameList,
364 const std::vector<OUString>& rUsedDBNames );
365 void AddUsedDBToList( std::vector<OUString>& rDBNameList, const OUString& rDBName );
366 static bool IsNameInArray( const std::vector<OUString>& rOldNames, const OUString& rName );
367 void GetAllDBNames( std::vector<OUString>& rAllDBNames );
368 static OUString ReplaceUsedDBs( const std::vector<OUString>& rUsedDBNames,
369 const OUString& rNewName, const OUString& rFormula );
370 static std::vector<OUString>& FindUsedDBs( const std::vector<OUString>& rAllDBNames,
371 const OUString& rFormula,
372 std::vector<OUString>& rUsedDBNames );
374 SW_DLLPUBLIC void EnsureNumberFormatter(); // must be called with mNumberFormatterMutex locked
376 bool UnProtectTableCells( SwTable& rTable );
378 /** Create sub-documents according to the given collection.
379 If no collection is given, take chapter style of the 1st level. */
380 bool SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline,
381 const SwTextFormatColl* pSplitColl, int nOutlineLevel = 0 );
383 // Update charts of given table.
384 void UpdateCharts_( const SwTable& rTable, SwViewShell const & rVSh ) const;
386 static bool SelectNextRubyChars( SwPaM& rPam, SwRubyListEntry& rRubyEntry );
388 // CharTimer calls this method.
389 void DoUpdateAllCharts();
390 DECL_LINK( DoUpdateModifiedOLE, Timer *, void );
392 public:
393 SW_DLLPUBLIC SwFormat *MakeCharFormat_(const OUString &, SwFormat *, bool );
394 SwFormat *MakeFrameFormat_(const OUString &, SwFormat *, bool );
396 private:
397 SwFormat *MakeTextFormatColl_(const OUString &, SwFormat *, bool );
399 private:
400 OUString msDocAccTitle;
402 void InitTOXTypes();
404 public:
405 enum DocumentType {
406 DOCTYPE_NATIVE,
407 DOCTYPE_MSWORD // This doc model comes from MS Word
409 DocumentType meDocType;
410 DocumentType GetDocumentType() const { return meDocType; }
411 void SetDocumentType( DocumentType eDocType ) { meDocType = eDocType; }
413 // Life cycle
414 SW_DLLPUBLIC SwDoc();
415 SW_DLLPUBLIC ~SwDoc();
417 bool IsInDtor() const { return mbDtor; }
419 /* @@@MAINTAINABILITY-HORROR@@@
420 Implementation details made public.
422 SwNodes & GetNodes() { return *m_pNodes; }
423 SwNodes const& GetNodes() const { return *m_pNodes; }
425 private:
426 friend class ::rtl::Reference<SwDoc>;
428 /** Acquire a reference to an instance. A caller shall release
429 the instance by calling 'release' when it is no longer needed.
430 'acquire' and 'release' calls need to be balanced.
432 @returns
433 the current reference count of the instance for debugging purposes.
435 SW_DLLPUBLIC sal_Int32 acquire();
436 /** Releases a reference to an instance. A caller has to call
437 'release' when a before acquired reference to an instance
438 is no longer needed. 'acquire' and 'release' calls need to
439 be balanced.
441 @returns
442 the current reference count of the instance for debugging purposes.
444 SW_DLLPUBLIC sal_Int32 release();
445 /** Returns the current reference count. This method should be used for
446 debugging purposes. Using it otherwise is a signal of a design flaw.
448 public:
449 sal_Int32 getReferenceCount() const;
451 //MarkManager
452 SW_DLLPUBLIC ::sw::mark::MarkManager& GetMarkManager();
454 // IDocumentSettingAccess
455 SW_DLLPUBLIC IDocumentSettingAccess const & getIDocumentSettingAccess() const; //The IDocumentSettingAccess interface
456 SW_DLLPUBLIC IDocumentSettingAccess & getIDocumentSettingAccess();
457 ::sw::DocumentSettingManager & GetDocumentSettingManager(); //The implementation of the interface with some additional methods
458 ::sw::DocumentSettingManager const& GetDocumentSettingManager() const;
459 sal_uInt32 getRsid() const;
460 void setRsid( sal_uInt32 nVal );
461 sal_uInt32 getRsidRoot() const;
462 void setRsidRoot( sal_uInt32 nVal );
464 // IDocumentDeviceAccess
465 IDocumentDeviceAccess const & getIDocumentDeviceAccess() const;
466 SW_DLLPUBLIC IDocumentDeviceAccess & getIDocumentDeviceAccess();
468 // IDocumentMarkAccess
469 SW_DLLPUBLIC IDocumentMarkAccess* getIDocumentMarkAccess();
470 SW_DLLPUBLIC const IDocumentMarkAccess* getIDocumentMarkAccess() const;
472 // IDocumentRedlineAccess
473 IDocumentRedlineAccess const& getIDocumentRedlineAccess() const;
474 SW_DLLPUBLIC IDocumentRedlineAccess& getIDocumentRedlineAccess();
476 ::sw::DocumentRedlineManager const& GetDocumentRedlineManager() const;
477 SW_DLLPUBLIC ::sw::DocumentRedlineManager& GetDocumentRedlineManager();
479 // IDocumentUndoRedo
480 SW_DLLPUBLIC IDocumentUndoRedo & GetIDocumentUndoRedo();
481 IDocumentUndoRedo const& GetIDocumentUndoRedo() const;
483 // IDocumentLinksAdministration
484 IDocumentLinksAdministration const & getIDocumentLinksAdministration() const;
485 SW_DLLPUBLIC IDocumentLinksAdministration & getIDocumentLinksAdministration();
487 ::sw::DocumentLinksAdministrationManager const & GetDocumentLinksAdministrationManager() const;
488 ::sw::DocumentLinksAdministrationManager & GetDocumentLinksAdministrationManager();
490 // IDocumentFieldsAccess
491 IDocumentFieldsAccess const & getIDocumentFieldsAccess() const;
492 SW_DLLPUBLIC IDocumentFieldsAccess & getIDocumentFieldsAccess();
494 ::sw::DocumentFieldsManager & GetDocumentFieldsManager();
496 // Returns 0 if the field cannot hide para, or a positive integer indicating the field type
497 // "weight" when several hiding fields' FieldHidesPara() give conflicting results
498 int FieldCanHideParaWeight(SwFieldIds eFieldId) const;
499 bool FieldHidesPara(const SwField& rField) const;
501 // IDocumentContentOperations
502 IDocumentContentOperations const & getIDocumentContentOperations() const;
503 SW_DLLPUBLIC IDocumentContentOperations & getIDocumentContentOperations();
504 ::sw::DocumentContentOperationsManager const & GetDocumentContentOperationsManager() const;
505 ::sw::DocumentContentOperationsManager & GetDocumentContentOperationsManager();
507 bool UpdateParRsid( SwTextNode *pTextNode, sal_uInt32 nVal = 0 );
508 void UpdateRsid( const SwPaM &rRg, sal_Int32 nLen );
510 // IDocumentStylePoolAccess
511 IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const;
512 SW_DLLPUBLIC IDocumentStylePoolAccess & getIDocumentStylePoolAccess();
514 // SwLineNumberInfo
515 SW_DLLPUBLIC const SwLineNumberInfo& GetLineNumberInfo() const;
516 SW_DLLPUBLIC void SetLineNumberInfo(const SwLineNumberInfo& rInfo);
518 // IDocumentStatistics
519 IDocumentStatistics const & getIDocumentStatistics() const;
520 SW_DLLPUBLIC IDocumentStatistics & getIDocumentStatistics();
522 ::sw::DocumentStatisticsManager const & GetDocumentStatisticsManager() const;
523 ::sw::DocumentStatisticsManager & GetDocumentStatisticsManager();
525 // IDocumentState
526 IDocumentState const & getIDocumentState() const;
527 SW_DLLPUBLIC IDocumentState & getIDocumentState();
529 // IDocumentDrawModelAccess
530 void AddDrawUndo( std::unique_ptr<SdrUndoAction> );
531 SW_DLLPUBLIC IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const;
532 SW_DLLPUBLIC IDocumentDrawModelAccess & getIDocumentDrawModelAccess();
534 ::sw::DocumentDrawModelManager const & GetDocumentDrawModelManager() const;
535 ::sw::DocumentDrawModelManager & GetDocumentDrawModelManager();
537 // IDocumentLayoutAccess
538 SW_DLLPUBLIC IDocumentLayoutAccess const & getIDocumentLayoutAccess() const;
539 SW_DLLPUBLIC IDocumentLayoutAccess & getIDocumentLayoutAccess();
541 ::sw::DocumentLayoutManager const & GetDocumentLayoutManager() const;
542 ::sw::DocumentLayoutManager & GetDocumentLayoutManager();
544 // IDocumentTimerAccess
545 // Our own 'IdleTimer' calls the following method
546 IDocumentTimerAccess const & getIDocumentTimerAccess() const;
547 IDocumentTimerAccess & getIDocumentTimerAccess();
549 // IDocumentChartDataProviderAccess
550 IDocumentChartDataProviderAccess const & getIDocumentChartDataProviderAccess() const;
551 IDocumentChartDataProviderAccess & getIDocumentChartDataProviderAccess();
553 // IDocumentListItems
554 IDocumentListItems const & getIDocumentListItems() const;
555 IDocumentListItems & getIDocumentListItems();
557 // IDocumentOutlineNodes
558 IDocumentOutlineNodes const & getIDocumentOutlineNodes() const;
559 IDocumentOutlineNodes & getIDocumentOutlineNodes();
561 // IDocumentListsAccess
562 IDocumentListsAccess const & getIDocumentListsAccess() const;
563 SW_DLLPUBLIC IDocumentListsAccess & getIDocumentListsAccess();
565 //IDocumentExternalData
566 IDocumentExternalData const & getIDocumentExternalData() const;
567 SW_DLLPUBLIC IDocumentExternalData & getIDocumentExternalData();
569 //End of Interfaces
571 void setDocAccTitle( const OUString& rTitle ) { msDocAccTitle = rTitle; }
572 const OUString& getDocAccTitle() const { return msDocAccTitle; }
574 // INextInterface here
575 DECL_LINK(CalcFieldValueHdl, EditFieldInfo*, void);
577 // OLE ???
578 bool IsOLEPrtNotifyPending() const { return mbOLEPrtNotifyPending; }
579 inline void SetOLEPrtNotifyPending( bool bSet = true );
580 void PrtOLENotify( bool bAll ); // All or only marked
582 bool IsPrepareSelAll() const { return mbIsPrepareSelAll; }
583 void SetPrepareSelAll() { mbIsPrepareSelAll = true; }
585 void SetContainsAtPageObjWithContentAnchor( const bool bFlag )
587 mbContainsAtPageObjWithContentAnchor = bFlag;
589 bool DoesContainAtPageObjWithContentAnchor()
591 return mbContainsAtPageObjWithContentAnchor;
594 /** Returns positions of all FlyFrames in the document.
595 If a Pam-Pointer is passed the FlyFrames attached to paragraphs
596 have to be surrounded completely by css::awt::Selection.
597 ( Start < Pos < End ) !!!
598 (Required for Writers.) */
599 SW_DLLPUBLIC SwPosFlyFrames GetAllFlyFormats( const SwPaM*,
600 bool bDrawAlso,
601 bool bAsCharAlso = false ) const;
603 SwFlyFrameFormat *MakeFlyFrameFormat (const OUString &rFormatName, SwFrameFormat *pDerivedFrom);
604 SwDrawFrameFormat *MakeDrawFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom);
606 // From now on this interface has to be used for Flys.
607 // pAnchorPos must be set, if they are not attached to pages AND
608 // Anchor is not already set at valid ContentPos
609 // in FlySet/FrameFormat.
610 /* new parameter bCalledFromShell
612 true: An existing adjust item at pAnchorPos is propagated to
613 the content node of the new fly section. That propagation only
614 takes place if there is no adjust item in the paragraph style
615 for the new fly section.
617 false: no propagation
619 SW_DLLPUBLIC SwFlyFrameFormat* MakeFlySection( RndStdIds eAnchorType,
620 const SwPosition* pAnchorPos,
621 const SfxItemSet* pSet = nullptr,
622 SwFrameFormat *pParent = nullptr,
623 bool bCalledFromShell = false );
624 SwFlyFrameFormat* MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet,
625 const SwSelBoxes* pSelBoxes,
626 SwFrameFormat *pParent );
628 // Helper that checks for unique items for DrawingLayer items of type NameOrIndex
629 // and evtl. corrects that items to ensure unique names for that type. This call may
630 // modify/correct entries inside of the given SfxItemSet, and it will apply a name to
631 // the items in question (what is essential to make the named slots associated with
632 // these items work for the UNO API and thus e.g. for ODF import/export)
633 void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet& rSet);
635 SW_DLLPUBLIC bool SetFlyFrameAttr( SwFrameFormat& rFlyFormat, SfxItemSet& rSet );
637 bool SetFrameFormatToFly( SwFrameFormat& rFlyFormat, SwFrameFormat& rNewFormat,
638 SfxItemSet* pSet = nullptr, bool bKeepOrient = false );
639 void SetFlyFrameTitle( SwFlyFrameFormat& rFlyFrameFormat,
640 const OUString& sNewTitle );
641 void SetFlyFrameDescription( SwFlyFrameFormat& rFlyFrameFormat,
642 const OUString& sNewDescription );
643 void SetFlyFrameDecorative(SwFlyFrameFormat& rFlyFrameFormat,
644 bool isDecorative);
646 // Footnotes
647 // Footnote information
648 const SwFootnoteInfo& GetFootnoteInfo() const { return *mpFootnoteInfo; }
649 SW_DLLPUBLIC void SetFootnoteInfo(const SwFootnoteInfo& rInfo);
650 const SwEndNoteInfo& GetEndNoteInfo() const { return *mpEndNoteInfo; }
651 SW_DLLPUBLIC void SetEndNoteInfo(const SwEndNoteInfo& rInfo);
652 SwFootnoteIdxs& GetFootnoteIdxs() { return *mpFootnoteIdxs; }
653 const SwFootnoteIdxs& GetFootnoteIdxs() const { return *mpFootnoteIdxs; }
654 /// change footnotes in range
655 bool SetCurFootnote( const SwPaM& rPam, const OUString& rNumStr,
656 bool bIsEndNote );
658 /** Operations on the content of the document e.g.
659 spell-checking/hyphenating/word-counting
661 css::uno::Any
662 Spell( SwPaM&, css::uno::Reference< css::linguistic2::XSpellChecker1 > const &,
663 sal_uInt16* pPageCnt, sal_uInt16* pPageSt, bool bGrammarCheck,
664 SwRootFrame const* pLayout, // for grammar-check
665 SwConversionArgs *pConvArgs = nullptr ) const;
667 css::uno::Reference< css::linguistic2::XHyphenatedWord >
668 Hyphenate( SwPaM *pPam, const Point &rCursorPos,
669 sal_uInt16* pPageCnt, sal_uInt16* pPageSt );
671 // count words in pam
672 static void CountWords( const SwPaM& rPaM, SwDocStat& rStat );
674 // Glossary Document
675 bool IsInsOnlyTextGlossary() const { return mbInsOnlyTextGlssry; }
677 void Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress);
679 void ChangeAuthorityData(const SwAuthEntry* pNewData);
681 bool IsInHeaderFooter( const SwNode& ) const;
682 SW_DLLPUBLIC SvxFrameDirection GetTextDirection( const SwPosition& rPos,
683 const Point* pPt = nullptr ) const;
684 SW_DLLPUBLIC bool IsInVerticalText( const SwPosition& rPos ) const;
686 // Database and DB-Manager
687 void SetDBManager( SwDBManager* pNewMgr ) { m_pDBManager = pNewMgr; }
688 SwDBManager* GetDBManager() const { return m_pDBManager; }
689 void ChangeDBFields( const std::vector<OUString>& rOldNames,
690 const OUString& rNewName );
691 SW_DLLPUBLIC void SetInitDBFields(bool b);
693 // Find out which databases are used by fields.
694 void GetAllUsedDB( std::vector<OUString>& rDBNameList,
695 const std::vector<OUString>* pAllDBNames = nullptr );
697 void ChgDBData( const SwDBData& rNewData );
698 SW_DLLPUBLIC SwDBData const & GetDBData();
700 // Some helper functions
701 OUString GetUniqueGrfName(std::u16string_view rPrefix = std::u16string_view()) const;
702 OUString GetUniqueOLEName() const;
703 SW_DLLPUBLIC OUString GetUniqueFrameName() const;
704 OUString GetUniqueShapeName() const;
705 SW_DLLPUBLIC OUString GetUniqueDrawObjectName() const;
707 SW_DLLPUBLIC o3tl::sorted_vector<SwRootFrame*> GetAllLayouts();
709 void SetFlyName( SwFlyFrameFormat& rFormat, const OUString& rName );
710 SW_DLLPUBLIC const SwFlyFrameFormat* FindFlyByName( const OUString& rName, SwNodeType nNdTyp = SwNodeType::NONE ) const;
712 static void GetGrfNms( const SwFlyFrameFormat& rFormat, OUString* pGrfName, OUString* pFltName );
714 // Set a valid name for all Flys that have none (Called by Readers after reading).
715 void SetAllUniqueFlyNames();
717 /** Reset attributes. All TextHints and (if completely selected) all hard-
718 formatted stuff (auto-formats) are removed.
719 Introduce new optional parameter <bSendDataChangedEvents> in order to
720 control, if the side effect "send data changed events" is triggered or not. */
721 void ResetAttrs( const SwPaM &rRg,
722 bool bTextAttr = true,
723 const o3tl::sorted_vector<sal_uInt16> &rAttrs = o3tl::sorted_vector<sal_uInt16>(),
724 const bool bSendDataChangedEvents = true,
725 SwRootFrame const* pLayout = nullptr);
726 void RstTextAttrs(const SwPaM &rRg, bool bInclRefToxMark = false,
727 bool bExactRange = false, SwRootFrame const* pLayout = nullptr);
729 /** Set attribute in given format.1y
730 * If Undo is enabled, the old values is added to the Undo history. */
731 SW_DLLPUBLIC void SetAttr( const SfxPoolItem&, SwFormat& );
732 /** Set attribute in given format.1y
733 * If Undo is enabled, the old values is added to the Undo history. */
734 SW_DLLPUBLIC void SetAttr( const SfxItemSet&, SwFormat& );
736 // method to reset a certain attribute at the given format
737 void ResetAttrAtFormat( const std::vector<sal_uInt16>& rIds,
738 SwFormat& rChangedFormat );
740 /** Set attribute as new default attribute in current document.
741 If Undo is activated, the old one is listed in Undo-History. */
742 void SetDefault( const SfxPoolItem& );
743 void SetDefault( const SfxItemSet& );
745 // Query default attribute in this document.
746 SW_DLLPUBLIC const SfxPoolItem& GetDefault( sal_uInt16 nFormatHint ) const;
747 template<class T> const T& GetDefault( TypedWhichId<T> nWhich ) const
749 return static_cast<const T&>(GetDefault(sal_uInt16(nWhich)));
752 // Do not expand text attributes.
753 bool DontExpandFormat( const SwPosition& rPos, bool bFlag = true );
755 // Formats
756 const sw::FrameFormats<SwFrameFormat*>* GetFrameFormats() const { return mpFrameFormatTable.get(); }
757 sw::FrameFormats<SwFrameFormat*>* GetFrameFormats() { return mpFrameFormatTable.get(); }
758 const SwCharFormats* GetCharFormats() const { return mpCharFormatTable.get();}
759 SwCharFormats* GetCharFormats() { return mpCharFormatTable.get();}
761 // LayoutFormats (frames, DrawObjects), sometimes const sometimes not
762 const sw::FrameFormats<sw::SpzFrameFormat*>* GetSpzFrameFormats() const { return mpSpzFrameFormatTable.get(); }
763 sw::FrameFormats<sw::SpzFrameFormat*>* GetSpzFrameFormats() { return mpSpzFrameFormatTable.get(); }
765 const SwFrameFormat *GetDfltFrameFormat() const { return mpDfltFrameFormat.get(); }
766 SwFrameFormat *GetDfltFrameFormat() { return mpDfltFrameFormat.get(); }
767 const SwFrameFormat *GetEmptyPageFormat() const { return mpEmptyPageFormat.get(); }
768 SwFrameFormat *GetEmptyPageFormat() { return mpEmptyPageFormat.get(); }
769 const SwFrameFormat *GetColumnContFormat() const{ return mpColumnContFormat.get(); }
770 SwFrameFormat *GetColumnContFormat() { return mpColumnContFormat.get(); }
771 const SwCharFormat *GetDfltCharFormat() const { return mpDfltCharFormat.get();}
772 SwCharFormat *GetDfltCharFormat() { return mpDfltCharFormat.get();}
774 // @return the interface of the management of (auto)styles
775 IStyleAccess& GetIStyleAccess() { return *mpStyleAccess; }
777 // Remove all language dependencies from all existing formats
778 void RemoveAllFormatLanguageDependencies();
780 SW_DLLPUBLIC SwFrameFormat* MakeFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom,
781 bool bAuto = true);
782 SW_DLLPUBLIC void DelFrameFormat( SwFrameFormat *pFormat, bool bBroadcast = false );
783 SwFrameFormat* FindFrameFormatByName( const OUString& rName ) const;
785 SW_DLLPUBLIC SwCharFormat *MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom);
786 void DelCharFormat(size_t nFormat, bool bBroadcast = false);
787 void DelCharFormat(SwCharFormat const * pFormat, bool bBroadcast = false);
788 SwCharFormat* FindCharFormatByName( const OUString& rName ) const
789 { return mpCharFormatTable->FindFormatByName(rName); }
791 // Formatcollections (styles)
792 // TXT
793 const SwTextFormatColl* GetDfltTextFormatColl() const { return mpDfltTextFormatColl.get(); }
794 SwTextFormatColl* GetDfltTextFormatColl() { return mpDfltTextFormatColl.get(); }
795 const SwTextFormatColls *GetTextFormatColls() const { return mpTextFormatCollTable.get(); }
796 SwTextFormatColls *GetTextFormatColls() { return mpTextFormatCollTable.get(); }
797 SW_DLLPUBLIC SwTextFormatColl *MakeTextFormatColl( const OUString &rFormatName,
798 SwTextFormatColl *pDerivedFrom);
799 SwConditionTextFormatColl* MakeCondTextFormatColl( const OUString &rFormatName,
800 SwTextFormatColl *pDerivedFrom);
801 void DelTextFormatColl(size_t nFormat, bool bBroadcast = false);
802 void DelTextFormatColl( SwTextFormatColl const * pColl, bool bBroadcast = false );
803 /** Add 4th optional parameter <bResetListAttrs>.
804 'side effect' of <SetTextFormatColl> with <bReset = true> is that the hard
805 attributes of the affected text nodes are cleared, except the break
806 attribute, the page description attribute and the list style attribute.
807 The new parameter <bResetListAttrs> indicates, if the list attributes
808 (list style, restart at and restart with) are cleared as well in case
809 that <bReset = true> and the paragraph style has a list style attribute set. */
810 SW_DLLPUBLIC bool SetTextFormatColl(const SwPaM &rRg, SwTextFormatColl *pFormat,
811 const bool bReset = true,
812 const bool bResetListAttrs = false,
813 const bool bResetAllCharAttrs = false,
814 SwRootFrame const* pLayout = nullptr);
815 SwTextFormatColl* FindTextFormatCollByName( const OUString& rName ) const
816 { return mpTextFormatCollTable->FindFormatByName(rName); }
818 void ChkCondColls();
820 const SwGrfFormatColl* GetDfltGrfFormatColl() const { return mpDfltGrfFormatColl.get(); }
821 SwGrfFormatColl* GetDfltGrfFormatColl() { return mpDfltGrfFormatColl.get(); }
822 const SwGrfFormatColls *GetGrfFormatColls() const { return mpGrfFormatCollTable.get(); }
823 SwGrfFormatColl *MakeGrfFormatColl(const OUString &rFormatName,
824 SwGrfFormatColl *pDerivedFrom);
826 // Table formatting
827 const sw::TableFrameFormats* GetTableFrameFormats() const { return mpTableFrameFormatTable.get(); }
828 sw::TableFrameFormats* GetTableFrameFormats() { return mpTableFrameFormatTable.get(); }
829 SW_DLLPUBLIC size_t GetTableFrameFormatCount( bool bUsed ) const;
830 SwTableFormat& GetTableFrameFormat(size_t nFormat, bool bUsed ) const;
831 SwTableFormat* MakeTableFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom);
832 void DelTableFrameFormat( SwTableFormat* pFormat );
833 SW_DLLPUBLIC SwTableFormat* FindTableFormatByName( const OUString& rName, bool bAll = false ) const;
835 /** Access to frames.
836 Iterate over Flys - for Basic-Collections. */
837 SW_DLLPUBLIC size_t GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes = false ) const;
838 SwFrameFormat* GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes = false );
839 SW_DLLPUBLIC std::vector<SwFrameFormat const*> GetFlyFrameFormats(
840 FlyCntType eType,
841 bool bIgnoreTextBoxes);
842 SwFrameFormat* GetFlyFrameFormatByName( const OUString& sFrameFormatName );
844 // Copy formats in own arrays and return them.
845 SwFrameFormat *CopyFrameFormat ( const SwFrameFormat& );
846 SwCharFormat *CopyCharFormat( const SwCharFormat& );
847 SwTextFormatColl* CopyTextColl( const SwTextFormatColl& rColl );
848 SwGrfFormatColl* CopyGrfColl( const SwGrfFormatColl& rColl );
850 // Replace all styles with those from rSource.
851 void ReplaceStyles( const SwDoc& rSource, bool bIncludePageStyles = true );
853 // Replace all property defaults with those from rSource.
854 SW_DLLPUBLIC void ReplaceDefaults( const SwDoc& rSource );
856 // Replace all compatibility options with those from rSource.
857 SW_DLLPUBLIC void ReplaceCompatibilityOptions( const SwDoc& rSource );
859 /** Replace all user defined document properties with xSourceDocProps.
860 Convenience function used by ReplaceDocumentProperties to skip some UNO calls.
862 void ReplaceUserDefinedDocumentProperties( const css::uno::Reference< css::document::XDocumentProperties >& xSourceDocProps );
864 /** Replace document properties with those from rSource.
866 This includes the user defined document properties!
868 SW_DLLPUBLIC void ReplaceDocumentProperties(const SwDoc& rSource, bool mailMerge = false);
870 // Query if style (paragraph- / character- / frame- / page-) is used.
871 bool IsUsed( const sw::BroadcastingModify& ) const;
872 /// Query if table style is used.
873 bool IsUsed( const SwTableAutoFormat& ) const;
874 SW_DLLPUBLIC bool IsUsed( const SwNumRule& ) const;
876 // Set name of newly loaded document template.
877 size_t SetDocPattern(const OUString& rPatternName);
879 // @return name of document template. Can be 0!
880 const OUString* GetDocPattern(size_t nPos) const;
882 // travel over PaM Ring
883 bool InsertGlossary( SwTextBlocks& rBlock, const OUString& rEntry,
884 SwPaM& rPaM, SwCursorShell* pShell = nullptr);
886 /** get the set of printable pages for the XRenderable API by
887 evaluating the respective settings (see implementation) */
888 static void CalculatePagesForPrinting( const SwRootFrame& rLayout, SwRenderData &rData, const SwPrintUIOptions &rOptions, bool bIsPDFExport,
889 sal_Int32 nDocPageCount );
890 static void UpdatePagesForPrintingWithPostItData( SwRenderData &rData, const SwPrintUIOptions &rOptions,
891 sal_Int32 nDocPageCount );
892 static void CalculatePagePairsForProspectPrinting( const SwRootFrame& rLayout, SwRenderData &rData, const SwPrintUIOptions &rOptions,
893 sal_Int32 nDocPageCount );
894 static void CalculateNonBlankPages( const SwRootFrame& rLayout, sal_uInt16& nDocPageCount, sal_uInt16& nActualPage );
896 // PageDescriptor interface.
897 size_t GetPageDescCnt() const { return m_PageDescs.size(); }
898 const SwPageDesc& GetPageDesc(const size_t i) const { return *m_PageDescs[i]; }
899 SwPageDesc& GetPageDesc(size_t const i) { return *m_PageDescs[i]; }
900 SW_DLLPUBLIC SwPageDesc* FindPageDesc(const OUString& rName, size_t* pPos = nullptr) const;
901 // Just searches the pointer in the m_PageDescs vector!
902 bool ContainsPageDesc(const SwPageDesc *pDesc, size_t* pPos) const;
904 /** Copy the complete PageDesc - beyond document and "deep"!
905 Optionally copying of PoolFormatId, -HlpId can be prevented. */
906 SW_DLLPUBLIC void CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc,
907 bool bCopyPoolIds = true );
909 /** Copy header (with contents) from SrcFormat to DestFormat
910 (can also be copied into other document). */
911 void CopyHeader( const SwFrameFormat& rSrcFormat, SwFrameFormat& rDestFormat )
912 { CopyPageDescHeaderFooterImpl( true, rSrcFormat, rDestFormat ); }
914 /** Copy footer (with contents) from SrcFormat to DestFormat.
915 (can also be copied into other document). */
916 void CopyFooter( const SwFrameFormat& rSrcFormat, SwFrameFormat& rDestFormat )
917 { CopyPageDescHeaderFooterImpl( false, rSrcFormat, rDestFormat ); }
919 // For Reader
920 SW_DLLPUBLIC void ChgPageDesc( const OUString & rName, const SwPageDesc& );
921 SW_DLLPUBLIC void ChgPageDesc( size_t i, const SwPageDesc& );
922 void DelPageDesc( const OUString & rName, bool bBroadcast = false);
923 void DelPageDesc( size_t i, bool bBroadcast = false );
924 void PreDelPageDesc(SwPageDesc const * pDel);
925 SW_DLLPUBLIC SwPageDesc* MakePageDesc(const OUString &rName, const SwPageDesc* pCpy = nullptr,
926 bool bRegardLanguage = true);
927 void BroadcastStyleOperation(const OUString& rName, SfxStyleFamily eFamily,
928 SfxHintId nOp);
930 /** The html import sometimes overwrites the page sizes set in
931 the page descriptions. This function is used to correct this. */
932 void CheckDefaultPageFormat();
934 // Methods for tables/indices
935 static sal_uInt16 GetCurTOXMark( const SwPosition& rPos, SwTOXMarks& );
936 void DeleteTOXMark( const SwTOXMark* pTOXMark );
937 SW_DLLPUBLIC const SwTOXMark& GotoTOXMark( const SwTOXMark& rCurTOXMark,
938 SwTOXSearch eDir, bool bInReadOnly );
939 /// Iterate over all SwTOXMark, if the function returns false, iteration is stopped
940 SW_DLLPUBLIC void ForEachTOXMark( const std::function<bool(const SwTOXMark&)>& ) const;
942 // Insert/Renew table/index
943 SW_DLLPUBLIC SwTOXBaseSection* InsertTableOf( const SwPosition& rPos,
944 const SwTOXBase& rTOX,
945 const SfxItemSet* pSet = nullptr,
946 bool bExpand = false,
947 SwRootFrame const* pLayout = nullptr);
948 SwTOXBaseSection* InsertTableOf( const SwPaM& aPam,
949 const SwTOXBase& rTOX,
950 const SfxItemSet* pSet = nullptr,
951 bool bExpand = false,
952 SwRootFrame const* pLayout = nullptr );
953 void InsertTableOf( SwNodeOffset nSttNd, SwNodeOffset nEndNd,
954 const SwTOXBase& rTOX,
955 const SfxItemSet* pSet );
956 SW_DLLPUBLIC static SwTOXBase* GetCurTOX( const SwPosition& rPos );
957 static const SwAttrSet& GetTOXBaseAttrSet(const SwTOXBase& rTOX);
959 bool DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes );
960 OUString GetUniqueTOXBaseName( const SwTOXType& rType,
961 const OUString& sChkStr ) const;
963 bool SetTOXBaseName(const SwTOXBase& rTOXBase, const OUString& rName);
965 // After reading file update all tables/indices
966 void SetUpdateTOX( bool bFlag ) { mbUpdateTOX = bFlag; }
967 bool IsUpdateTOX() const { return mbUpdateTOX; }
969 const OUString& GetTOIAutoMarkURL() const {return msTOIAutoMarkURL;}
970 void SetTOIAutoMarkURL(const OUString& rSet) {msTOIAutoMarkURL = rSet;}
972 bool IsInReading() const { return mbInReading; }
973 void SetInReading( bool bNew ) { mbInReading = bNew; }
975 bool IsInWriting() const { return mbInWriting; }
976 void SetInWriting(bool bNew) { mbInWriting = bNew; }
978 bool IsInMailMerge() const { return mbInMailMerge; }
979 void SetInMailMerge( bool bNew ) { mbInMailMerge = bNew; }
981 bool IsClipBoard() const { return mbClipBoard; }
982 // N.B.: must be called right after constructor! (@see GetXmlIdRegistry)
983 void SetClipBoard( bool bNew ) { mbClipBoard = bNew; }
985 bool IsColumnSelection() const { return mbColumnSelection; }
986 void SetColumnSelection( bool bNew ) { mbColumnSelection = bNew; }
988 bool IsInXMLImport() const { return mbInXMLImport; }
989 void SetInXMLImport( bool bNew ) { mbInXMLImport = bNew; }
990 bool IsInWriterfilterImport() const { return mbInWriterfilterImport; }
991 void SetInWriterfilterImport(bool const b) { mbInWriterfilterImport = b; }
993 // Manage types of tables/indices
994 SW_DLLPUBLIC sal_uInt16 GetTOXTypeCount( TOXTypes eTyp ) const;
995 SW_DLLPUBLIC const SwTOXType* GetTOXType( TOXTypes eTyp, sal_uInt16 nId ) const;
996 const SwTOXType* InsertTOXType( const SwTOXType& rTyp );
997 const SwTOXTypes& GetTOXTypes() const { return *mpTOXTypes; }
999 const SwTOXBase* GetDefaultTOXBase( TOXTypes eTyp, bool bCreate );
1000 void SetDefaultTOXBase(const SwTOXBase& rBase);
1002 // Key for management of index.
1003 void GetTOIKeys(SwTOIKeyType eTyp, std::vector<OUString>& rArr,
1004 SwRootFrame const& rLayout) const;
1006 // Sort table text.
1007 bool SortTable(const SwSelBoxes& rBoxes, const SwSortOptions&);
1008 bool SortText(const SwPaM&, const SwSortOptions&);
1010 // Correct the SwPosition-Objects that are registered with the document
1011 // e. g. Bookmarks or tables/indices.
1012 // If bMoveCursor is set move Cursor too.
1014 // Set everything in rOldNode on rNewPos + Offset.
1015 void CorrAbs(
1016 const SwNode& rOldNode,
1017 const SwPosition& rNewPos,
1018 const sal_Int32 nOffset = 0,
1019 bool bMoveCursor = false );
1021 // Set everything in the range of [rStartNode, rEndNode] to rNewPos.
1022 static void CorrAbs(
1023 const SwNodeIndex& rStartNode,
1024 const SwNodeIndex& rEndNode,
1025 const SwPosition& rNewPos,
1026 bool bMoveCursor = false );
1028 // Set everything in this range from rRange to rNewPos.
1029 static void CorrAbs(
1030 const SwPaM& rRange,
1031 const SwPosition& rNewPos,
1032 bool bMoveCursor = false );
1034 // Set everything in rOldNode to relative Pos.
1035 void CorrRel(
1036 const SwNode& rOldNode,
1037 const SwPosition& rNewPos,
1038 const sal_Int32 nOffset = 0,
1039 bool bMoveCursor = false );
1041 // Query / set rules for Outline.
1042 SwNumRule* GetOutlineNumRule() const
1044 return mpOutlineRule;
1046 SW_DLLPUBLIC void SetOutlineNumRule( const SwNumRule& rRule );
1047 SW_DLLPUBLIC void PropagateOutlineRule();
1049 // Outline - promote / demote.
1050 bool OutlineUpDown(const SwPaM& rPam, short nOffset, SwRootFrame const* pLayout = nullptr);
1052 /// Outline - move up / move down.
1053 bool MoveOutlinePara( const SwPaM& rPam,
1054 SwOutlineNodes::difference_type nOffset,
1055 SwOutlineNodesInline* pOutlNdsInline = nullptr);
1057 SW_DLLPUBLIC bool GotoOutline(SwPosition& rPos, const OUString& rName, SwRootFrame const* = nullptr) const;
1059 enum class SetNumRuleMode {
1060 Default = 0,
1061 /// indicates if a new list is created by applying the given list style.
1062 CreateNewList = 1,
1063 DontSetItem = 2,
1064 /** If enabled, the indent attributes "before text" and
1065 "first line indent" are additionally reset at the provided PaM,
1066 if the list style makes use of the new list level attributes. */
1067 ResetIndentAttrs = 4,
1068 DontSetIfAlreadyApplied = 8
1071 /** Set or change numbering rule on text nodes, as direct formatting.
1072 @param sContinuedListId If bCreateNewList is false, may contain the
1073 list Id of a list which has to be continued by applying the given list style
1075 @return the set ListId if bSetItem is true */
1076 OUString SetNumRule( const SwPaM&,
1077 const SwNumRule&,
1078 SetNumRuleMode mode,
1079 SwRootFrame const* pLayout = nullptr,
1080 const OUString& sContinuedListId = OUString(),
1081 SvxTextLeftMarginItem const* pTextLeftMarginToPropagate = nullptr,
1082 SvxFirstLineIndentItem const* pFirstLineIndentToPropagate = nullptr);
1083 void SetCounted(const SwPaM&, bool bCounted, SwRootFrame const* pLayout);
1085 void MakeUniqueNumRules(const SwPaM & rPaM);
1087 void SetNumRuleStart( const SwPosition& rPos, bool bFlag = true );
1088 void SetNodeNumStart( const SwPosition& rPos, sal_uInt16 nStt );
1090 // sw_redlinehide: may set rPos to different node (the one with the NumRule)
1091 static SwNumRule* GetNumRuleAtPos(SwPosition& rPos, SwRootFrame const* pLayout = nullptr);
1093 const SwNumRuleTable& GetNumRuleTable() const { return *mpNumRuleTable; }
1096 Add numbering rule to document.
1098 @param pRule rule to add
1100 void AddNumRule(SwNumRule * pRule);
1102 // add optional parameter <eDefaultNumberFormatPositionAndSpaceMode>
1103 SW_DLLPUBLIC sal_uInt16 MakeNumRule( const OUString &rName,
1104 const SwNumRule* pCpy = nullptr,
1105 const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode =
1106 SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
1107 sal_uInt16 FindNumRule( std::u16string_view rName ) const;
1108 std::set<OUString> GetUsedBullets();
1109 SW_DLLPUBLIC SwNumRule* FindNumRulePtr( const OUString& rName ) const;
1111 // Deletion only possible if Rule is not used!
1112 bool RenameNumRule(const OUString & aOldName, const OUString & aNewName,
1113 bool bBroadcast = false);
1114 SW_DLLPUBLIC bool DelNumRule( const OUString& rName, bool bBroadCast = false );
1115 SW_DLLPUBLIC OUString GetUniqueNumRuleName( const OUString* pChkStr = nullptr, bool bAutoNum = true ) const;
1117 void UpdateNumRule(); // Update all invalids.
1118 void ChgNumRuleFormats( const SwNumRule& rRule );
1119 void ReplaceNumRule( const SwPosition& rPos, const OUString& rOldRule,
1120 const OUString& rNewRule );
1122 // Goto next/previous on same level.
1123 static bool GotoNextNum( SwPosition&, SwRootFrame const* pLayout,
1124 bool bOverUpper = true,
1125 sal_uInt8* pUpper = nullptr, sal_uInt8* pLower = nullptr );
1126 static bool GotoPrevNum( SwPosition&, SwRootFrame const* pLayout,
1127 bool bOverUpper = true );
1129 /** Searches for a text node with a numbering rule.
1131 add optional parameter <bInvestigateStartNode>
1132 add output parameter <sListId>
1134 \param rPos position to start search
1135 \param bForward - true: search forward
1136 - false: search backward
1137 \param bNum - true: search for enumeration
1138 - false: search for itemize
1139 \param bOutline - true: search for outline numbering rule
1140 - false: search for non-outline numbering rule
1141 \param nNonEmptyAllowed number of non-empty paragraphs allowed between
1142 rPos and found paragraph
1144 @param sListId
1145 output parameter - in case a list style is found, <sListId> holds the
1146 list id, to which the text node belongs, which applies the found list style.
1148 @param bInvestigateStartNode
1149 input parameter - boolean, indicating, if start node, determined by given
1150 start position has to be investigated or not.
1152 const SwNumRule * SearchNumRule(const SwPosition & rPos,
1153 const bool bForward,
1154 const bool bNum,
1155 const bool bOutline,
1156 int nNonEmptyAllowed,
1157 OUString& sListId,
1158 SwRootFrame const* pLayout,
1159 const bool bInvestigateStartNode = false,
1160 SvxTextLeftMarginItem const** o_ppTextLeftMargin = nullptr,
1161 SvxFirstLineIndentItem const** o_ppFirstLineIndent = nullptr);
1163 // Paragraphs without numbering but with indents.
1164 bool NoNum( const SwPaM& );
1166 // Delete, splitting of numbering list.
1167 void DelNumRules(const SwPaM&, SwRootFrame const* pLayout = nullptr);
1169 // Invalidates all numrules
1170 void InvalidateNumRules();
1172 bool NumUpDown(const SwPaM&, bool bDown, SwRootFrame const* pLayout = nullptr);
1174 /** Move selected paragraphs (not only numberings)
1175 according to offsets. (if negative: go to doc start). */
1176 bool MoveParagraph(SwPaM&, SwNodeOffset nOffset, bool bIsOutlMv = false);
1177 bool MoveParagraphImpl(SwPaM&, SwNodeOffset nOffset, bool bIsOutlMv, SwRootFrame const*);
1179 bool NumOrNoNum( SwNode& rIdx, bool bDel = false);
1181 void StopNumRuleAnimations( const OutputDevice* );
1183 /** Insert new table at position @param rPos (will be inserted before Node!).
1184 For AutoFormat at input: columns have to be set at predefined width.
1185 The array holds the positions of the columns (not their widths).
1186 new @param bCalledFromShell:
1187 true: called from shell -> propagate existing adjust item at
1188 rPos to every new cell. A existing adjust item in the table
1189 heading or table contents paragraph style prevent that
1190 propagation.
1191 false: do not propagate
1193 SW_DLLPUBLIC const SwTable* InsertTable( const SwInsertTableOptions& rInsTableOpts, // HeadlineNoBorder
1194 const SwPosition& rPos, sal_uInt16 nRows,
1195 sal_uInt16 nCols, sal_Int16 eAdjust,
1196 const SwTableAutoFormat* pTAFormat = nullptr,
1197 const std::vector<sal_uInt16> *pColArr = nullptr,
1198 bool bCalledFromShell = false,
1199 bool bNewModel = true,
1200 const OUString& rTableName = {} );
1202 // If index is in a table, return TableNode, else 0.
1203 static SwTableNode* IsIdxInTable( const SwNodeIndex& rIdx );
1204 static SwTableNode* IsInTable( const SwNode& );
1206 // Create a balanced table out of the selected range.
1207 const SwTable* TextToTable( const SwInsertTableOptions& rInsTableOpts, // HeadlineNoBorder,
1208 const SwPaM& rRange, sal_Unicode cCh,
1209 sal_Int16 eAdjust,
1210 const SwTableAutoFormat* );
1212 // text to table conversion - API support
1213 const SwTable* TextToTable( const std::vector< std::vector<SwNodeRange> >& rTableNodes );
1215 bool TableToText( const SwTableNode* pTableNd, sal_Unicode cCh );
1217 // Create columns / rows in table.
1218 void InsertCol( const SwCursor& rCursor,
1219 sal_uInt16 nCnt = 1, bool bBehind = true );
1220 bool InsertCol( const SwSelBoxes& rBoxes,
1221 sal_uInt16 nCnt = 1, bool bBehind = true, bool bInsertDummy = true );
1222 void InsertRow( const SwCursor& rCursor,
1223 sal_uInt16 nCnt = 1, bool bBehind = true );
1224 SW_DLLPUBLIC bool InsertRow( const SwSelBoxes& rBoxes,
1225 sal_uInt16 nCnt = 1, bool bBehind = true, bool bInsertDummy = true );
1227 // Delete Columns/Rows in table.
1228 enum class RowColMode { DeleteRow = 0, DeleteColumn = 1, DeleteProtected = 2 };
1229 void DelTable(SwTableNode * pTable);
1230 bool DeleteRowCol(const SwSelBoxes& rBoxes, RowColMode eMode = RowColMode::DeleteRow);
1231 void DeleteRow( const SwCursor& rCursor );
1232 void DeleteCol( const SwCursor& rCursor );
1234 // Split / concatenate boxes in table.
1235 bool SplitTable( const SwSelBoxes& rBoxes, bool bVert,
1236 sal_uInt16 nCnt, bool bSameHeight = false );
1238 TableMergeErr MergeTable( SwPaM& rPam );
1239 OUString GetUniqueTableName() const;
1240 bool IsInsTableFormatNum() const;
1241 bool IsInsTableChangeNumFormat() const;
1242 bool IsInsTableAlignNum() const;
1243 bool IsSplitVerticalByDefault() const;
1244 void SetSplitVerticalByDefault(bool value);
1246 // From FEShell (for Undo and BModified).
1247 static void GetTabCols( SwTabCols &rFill, const SwCellFrame* pBoxFrame );
1248 void SetTabCols( const SwTabCols &rNew, bool bCurRowOnly,
1249 const SwCellFrame* pBoxFrame );
1250 static void GetTabRows( SwTabCols &rFill, const SwCellFrame* pBoxFrame );
1251 void SetTabRows( const SwTabCols &rNew, bool bCurColOnly,
1252 const SwCellFrame* pBoxFrame );
1254 // Direct access for UNO.
1255 void SetTabCols(SwTable& rTab, const SwTabCols &rNew, const SwTabCols &rOld,
1256 const SwTableBox *pStart, bool bCurRowOnly);
1258 void SetRowsToRepeat( SwTable &rTable, sal_uInt16 nSet );
1260 /// AutoFormat for table/table selection.
1261 /// @param bResetDirect Reset direct formatting that might be applied to the cells.
1262 bool SetTableAutoFormat(const SwSelBoxes& rBoxes, const SwTableAutoFormat& rNew, bool bResetDirect = false, OUString const* pStyleNameToSet = nullptr);
1264 // Query attributes.
1265 bool GetTableAutoFormat( const SwSelBoxes& rBoxes, SwTableAutoFormat& rGet );
1267 /// Return the available table styles.
1268 SW_DLLPUBLIC SwTableAutoFormatTable& GetTableStyles();
1269 const SwTableAutoFormatTable& GetTableStyles() const
1271 return const_cast<SwDoc*>(this)->GetTableStyles();
1273 /// Counts table styles without triggering lazy-load of them.
1274 bool HasTableStyles() const { return m_pTableStyles != nullptr; }
1275 // Create a new table style. Tracked by Undo.
1276 SW_DLLPUBLIC SwTableAutoFormat* MakeTableStyle(const OUString& rName);
1277 // Delete table style named rName. Tracked by undo.
1278 SW_DLLPUBLIC std::unique_ptr<SwTableAutoFormat> DelTableStyle(const OUString& rName, bool bBroadcast = false);
1279 // Change (replace) a table style named rName. Tracked by undo.
1280 SW_DLLPUBLIC void ChgTableStyle(const OUString& rName, const SwTableAutoFormat& rNewFormat);
1282 const SwCellStyleTable& GetCellStyles() const { return *mpCellStyles; }
1283 SwCellStyleTable& GetCellStyles() { return *mpCellStyles; }
1285 void AppendUndoForInsertFromDB( const SwPaM& rPam, bool bIsTable );
1287 void SetColRowWidthHeight( SwTableBox& rCurrentBox, TableChgWidthHeightType eType,
1288 SwTwips nAbsDiff, SwTwips nRelDiff );
1289 SwTableBoxFormat* MakeTableBoxFormat();
1290 SwTableLineFormat* MakeTableLineFormat();
1292 // helper function: cleanup before checking number value
1293 bool IsNumberFormat( const OUString& aString, sal_uInt32& F_Index, double& fOutNumber);
1294 // Check if box has numerical value. Change format of box if required.
1295 void ChkBoxNumFormat( SwTableBox& rCurrentBox, bool bCallUpdate );
1296 void SetTableBoxFormulaAttrs( SwTableBox& rBox, const SfxItemSet& rSet );
1297 void ClearBoxNumAttrs( SwNode& rNode );
1298 void ClearLineNumAttrs( SwPosition const & rPos );
1300 bool InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes,
1301 const SwTable* pCpyTable, bool bCpyName = false,
1302 bool bCorrPos = false, const OUString& rStyleName = u""_ustr );
1304 void UnProtectCells( const OUString& rTableName );
1305 bool UnProtectCells( const SwSelBoxes& rBoxes );
1306 void UnProtectTables( const SwPaM& rPam );
1307 bool HasTableAnyProtection( const SwPosition* pPos,
1308 const OUString* pTableName,
1309 bool* pFullTableProtection );
1311 // Split table at baseline position, i.e. create a new table.
1312 void SplitTable( const SwPosition& rPos, SplitTable_HeadlineOption eMode,
1313 bool bCalcNewSize );
1315 /** And vice versa: rPos must be in the table that remains. The flag indicates
1316 whether the current table is merged with the one before or behind it. */
1317 bool MergeTable( const SwPosition& rPos, bool bWithPrev );
1319 // Make charts of given table update.
1320 void UpdateCharts( const OUString& rName ) const;
1322 // Update all charts, for that exists any table.
1323 void UpdateAllCharts() { DoUpdateAllCharts(); }
1325 // Table is renamed and refreshes charts.
1326 void SetTableName( SwFrameFormat& rTableFormat, const OUString &rNewName );
1328 // @return the reference in document that is set for name.
1329 const SwFormatRefMark* GetRefMark( std::u16string_view rName ) const;
1331 // @return RefMark via index - for UNO.
1332 const SwFormatRefMark* GetRefMark( sal_uInt16 nIndex ) const;
1334 /** @return names of all references that are set in document.
1335 If array pointer is 0 return only whether a RefMark is set in document. */
1336 SW_DLLPUBLIC sal_uInt16 GetRefMarks( std::vector<OUString>* = nullptr ) const;
1337 SW_DLLPUBLIC void GetRefMarks( std::vector<const SwFormatRefMark*>& ) const;
1338 /// Iterate over all SwFormatRefMark, if the function returns false, iteration is stopped
1339 SW_DLLPUBLIC void ForEachRefMark( const std::function<bool(const SwFormatRefMark&)>& ) const;
1341 void DeleteFormatRefMark(const SwFormatRefMark* pFormatRefMark);
1343 // Insert label. If a FlyFormat is created, return it.
1344 SwFlyFrameFormat* InsertLabel( const SwLabelType eType, const OUString &rText, const OUString& rSeparator,
1345 const OUString& rNumberingSeparator,
1346 const bool bBefore, const sal_uInt16 nId, const SwNodeOffset nIdx,
1347 const OUString& rCharacterStyle,
1348 const bool bCpyBrd );
1349 SwFlyFrameFormat* InsertDrawLabel(
1350 const OUString &rText, const OUString& rSeparator, const OUString& rNumberSeparator,
1351 const sal_uInt16 nId, const OUString& rCharacterStyle, SdrObject& rObj );
1353 // Query attribute pool.
1354 const SwAttrPool& GetAttrPool() const { return *mpAttrPool; }
1355 SwAttrPool& GetAttrPool() { return *mpAttrPool; }
1357 // Search for an EditShell.
1358 SAL_RET_MAYBENULL SwEditShell const * GetEditShell() const;
1359 SAL_RET_MAYBENULL SW_DLLPUBLIC SwEditShell* GetEditShell();
1360 SAL_RET_MAYBENULL ::sw::IShellCursorSupplier * GetIShellCursorSupplier();
1362 // OLE 2.0-notification.
1363 void SetOle2Link(const Link<bool,void>& rLink) {maOle2Link = rLink;}
1364 const Link<bool,void>& GetOle2Link() const {return maOle2Link;}
1366 // insert section (the ODF kind of section, not the nodesarray kind)
1367 SW_DLLPUBLIC SwSection * InsertSwSection(SwPaM const& rRange, SwSectionData &,
1368 std::tuple<SwTOXBase const*, sw::RedlineMode, sw::FieldmarkMode, sw::ParagraphBreakMode> const* pTOXBase,
1369 SfxItemSet const*const pAttr, bool const bUpdate = true);
1370 static sal_uInt16 IsInsRegionAvailable( const SwPaM& rRange,
1371 const SwNode** ppSttNd = nullptr );
1372 static SwSection* GetCurrSection( const SwPosition& rPos );
1373 SwSectionFormats& GetSections() { return *mpSectionFormatTable; }
1374 const SwSectionFormats& GetSections() const { return *mpSectionFormatTable; }
1375 SwSectionFormat *MakeSectionFormat();
1376 void DelSectionFormat( SwSectionFormat *pFormat, bool bDelNodes = false );
1377 void UpdateSection(size_t const nSect, SwSectionData &,
1378 SfxItemSet const*const = nullptr, bool const bPreventLinkUpdate = false);
1379 SW_DLLPUBLIC OUString GetUniqueSectionName( const OUString* pChkStr = nullptr ) const;
1381 /* @@@MAINTAINABILITY-HORROR@@@
1382 The model should not have anything to do with a shell.
1383 Unnecessary compile/link time dependency.
1386 // Pointer to SfxDocShell from Doc. Can be 0!!
1387 SAL_RET_MAYBENULL SwDocShell* GetDocShell() { return mpDocShell; }
1388 SAL_RET_MAYBENULL const SwDocShell* GetDocShell() const { return mpDocShell; }
1389 void SetDocShell( SwDocShell* pDSh );
1391 /** in case during copying of embedded object a new shell is created,
1392 it should be set here and cleaned later */
1393 void SetTmpDocShell(const SfxObjectShellLock& rLock) { mxTmpDocShell = rLock; }
1394 const SfxObjectShellLock& GetTmpDocShell() const { return mxTmpDocShell; }
1396 // For Autotexts? (text modules) They have only one SVPersist at their disposal.
1397 SW_DLLPUBLIC SfxObjectShell* GetPersist() const;
1399 // Pointer to storage of SfxDocShells. Can be 0!!!
1400 SW_DLLPUBLIC css::uno::Reference< css::embed::XStorage > GetDocStorage();
1402 // Query / set flag indicating if document is loaded asynchronously at this moment.
1403 bool IsInLoadAsynchron() const { return mbInLoadAsynchron; }
1404 void SetInLoadAsynchron( bool bFlag ) { mbInLoadAsynchron = bFlag; }
1406 // For Drag&Move: (e.g. allow "moving" of RefMarks)
1407 bool IsCopyIsMove() const { return mbCopyIsMove; }
1408 void SetCopyIsMove( bool bFlag ) { mbCopyIsMove = bFlag; }
1410 SwDrawContact* GroupSelection( SdrView& );
1411 void UnGroupSelection( SdrView& );
1412 bool DeleteSelection( SwDrawView& );
1414 // Invalidates OnlineSpell-WrongLists.
1415 void SpellItAgainSam( bool bInvalid, bool bOnlyWrong, bool bSmartTags );
1416 void InvalidateAutoCompleteFlag();
1418 void SetCalcFieldValueHdl(Outliner* pOutliner);
1420 // Query if URL was visited.
1421 // Query via Doc, if only a Bookmark has been given.
1422 // In this case the document name has to be set in front.
1423 bool IsVisitedURL( std::u16string_view rURL );
1425 // Save current values for automatic registration of exceptions in Autocorrection.
1426 void SetAutoCorrExceptWord( std::unique_ptr<SwAutoCorrExceptWord> pNew );
1427 SwAutoCorrExceptWord* GetAutoCorrExceptWord() { return mpACEWord.get(); }
1428 void DeleteAutoCorrExceptWord();
1430 const SwFormatINetFormat* FindINetAttr( std::u16string_view rName ) const;
1431 /// Iterate over all SwFormatINetFormat, if the function returns false, iteration is stopped
1432 SW_DLLPUBLIC void ForEachINetFormat( const std::function<bool(const SwFormatINetFormat&)>& ) const;
1434 /// Iterate over all SwFormatURL, if the function returns false, iteration is stopped
1435 SW_DLLPUBLIC void ForEachFormatURL( const std::function<bool(const SwFormatURL&)>& ) const;
1437 /// Iterate over all SvxOverlineItem, if the function returns false, iteration is stopped
1438 SW_DLLPUBLIC void ForEachOverlineItem( const std::function<bool(const SvxOverlineItem&)>& ) const;
1440 /// Iterate over all SwFormatField, if the function returns false, iteration is stopped
1441 void ForEachFormatField( TypedWhichId<SwFormatField> nWhich, const std::function<bool(const SwFormatField&)>& ) const;
1443 /// Iterate over all RES_CHRATR_BOX SvxBoxItem, if the function returns false, iteration is stopped
1444 SW_DLLPUBLIC void ForEachCharacterBoxItem(const std::function<bool(const SvxBoxItem&)>& ) const;
1446 /// Iterate over all RES_CHRATR_COLOR SvxColorItem, if the function returns false, iteration is stopped
1447 SW_DLLPUBLIC void ForEachCharacterColorItem(const std::function<bool(const SvxColorItem&)>& ) const;
1449 /// Iterate over all RES_CHRATR_UNDERLINE SvxUnderlineItem, if the function returns false, iteration is stopped
1450 SW_DLLPUBLIC void ForEachCharacterUnderlineItem(const std::function<bool(const SvxUnderlineItem&)>& ) const;
1452 /// Iterate over all RES_CHRATR_BACKGROUND SvxBrushItem, if the function returns false, iteration is stopped
1453 SW_DLLPUBLIC void ForEachCharacterBrushItem(const std::function<bool(const SvxBrushItem&)>& ) const;
1455 /// Iterate over all RES_CHRATR_FONT/RES_CHRATR_CJK_FONT/RES_CHRATR_CTL_FONT SvxFontItem, if the function returns false, iteration is stopped
1456 SW_DLLPUBLIC void ForEachCharacterFontItem(TypedWhichId<SvxFontItem> nWhich, bool bIgnoreAutoStyles, const std::function<bool(const SvxFontItem&)>& );
1458 /// Iterate over all RES_TXTATR_UNKNOWN_CONTAINER SvXMLAttrContainerItem, if the function returns false, iteration is stopped
1459 SW_DLLPUBLIC void ForEachTxtAtrContainerItem(const std::function<bool(const SvXMLAttrContainerItem&)>& ) const;
1461 /// Iterate over all RES_PARATR_TABSTOP SvxTabStopItem, if the function returns false, iteration is stopped
1462 SW_DLLPUBLIC void ForEachParaAtrTabStopItem(const std::function<bool(const SvxTabStopItem&)>& );
1464 /// Iterate over all RES_UNKNOWNATR_CONTAINER SvXMLAttrContainerItem, if the function returns false, iteration is stopped
1465 SW_DLLPUBLIC void ForEachUnknownAtrContainerItem(const std::function<bool(const SvXMLAttrContainerItem&)>& ) const;
1467 /// Iterate over all RES_BOX SvxBoxItem, if the function returns false, iteration is stopped
1468 SW_DLLPUBLIC void ForEachBoxItem(const std::function<bool(const SvxBoxItem&)>& ) const;
1470 /// Iterate over all RES_SHADOW SvxShadowItem, if the function returns false, iteration is stopped
1471 SW_DLLPUBLIC void ForEachShadowItem(const std::function<bool(const SvxShadowItem&)>& ) const;
1473 /// Iterate over all RES_BACKGROUND SvxBrushItem, if the function returns false, iteration is stopped
1474 SW_DLLPUBLIC void ForEachBackgroundBrushItem(const std::function<bool(const SvxBrushItem&)>& ) const;
1476 // Call into intransparent Basic; expect possible Return String.
1477 void ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs );
1479 // Call into intransparent Basic / JavaScript.
1480 sal_uInt16 CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCallEvent,
1481 bool bChkPtr = false );
1483 /** Adjust left margin via object bar (similar to adjustment of numerations).
1484 One can either change the margin "by" adding or subtracting a given
1485 offset or set it "to" this position (bModulus = true). */
1486 void MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus,
1487 SwRootFrame const* pLayout = nullptr);
1489 // Query NumberFormatter.
1490 SvNumberFormatter* GetNumberFormatter(bool bCreate = true)
1492 std::scoped_lock lock(mNumberFormatterMutex);
1493 if (bCreate)
1494 EnsureNumberFormatter();
1495 return mpNumberFormatter;
1498 const SvNumberFormatter* GetNumberFormatter(bool bCreate = true) const
1500 return const_cast<SwDoc*>(this)->GetNumberFormatter(bCreate);
1503 bool HasInvisibleContent() const;
1504 // delete invisible content, like hidden sections and paragraphs
1505 SW_DLLPUBLIC bool RemoveInvisibleContent();
1506 // restore the invisible content if it's available on the undo stack
1507 bool RestoreInvisibleContent();
1509 // Replace fields by text - mailmerge support
1510 bool ConvertFieldsToText(SwRootFrame const& rLayout);
1512 // Create sub-documents according to given collection.
1513 // If no collection is given, use chapter styles for 1st level.
1514 bool GenerateGlobalDoc( const OUString& rPath,
1515 const SwTextFormatColl* pSplitColl );
1516 bool GenerateGlobalDoc( const OUString& rPath, int nOutlineLevel );
1517 bool GenerateHTMLDoc( const OUString& rPath,
1518 const SwTextFormatColl* pSplitColl );
1519 bool GenerateHTMLDoc( const OUString& rPath, int nOutlineLevel );
1521 // Compare two documents.
1522 tools::Long CompareDoc( const SwDoc& rDoc );
1524 // Merge two documents.
1525 tools::Long MergeDoc( const SwDoc& rDoc );
1527 bool IsAutoFormatRedline() const { return mbIsAutoFormatRedline; }
1528 void SetAutoFormatRedline( bool bFlag ) { mbIsAutoFormatRedline = bFlag; }
1530 // For AutoFormat: with Undo/Redlining.
1531 void SetTextFormatCollByAutoFormat( const SwPosition& rPos, sal_uInt16 nPoolId,
1532 const SfxItemSet* pSet );
1533 void SetFormatItemByAutoFormat( const SwPaM& rPam, const SfxItemSet& );
1535 // Only for SW-textbloxks! Does not pay any attention to layout!
1536 void ClearDoc(); // Deletes all content!
1538 // Query /set data for PagePreview.
1539 const SwPagePreviewPrtData* GetPreviewPrtData() const { return m_pPgPViewPrtData.get(); }
1541 // If pointer == 0 destroy pointer in document.
1542 // Else copy object.
1543 // Pointer is not transferred to ownership by document!
1544 void SetPreviewPrtData( const SwPagePreviewPrtData* pData );
1546 /** update all modified OLE-Objects. The modification is called over the
1547 StarOne - Interface */
1548 void SetOLEObjModified();
1550 // Uno - Interfaces
1551 SW_DLLPUBLIC std::shared_ptr<SwUnoCursor> CreateUnoCursor( const SwPosition& rPos, bool bTableCursor = false );
1553 // FeShell - Interfaces
1554 // !!! These assume always an existing layout !!!
1555 bool ChgAnchor( const SdrMarkList& _rMrkList,
1556 RndStdIds _eAnchorType,
1557 const bool _bSameOnly,
1558 const bool _bPosCorr );
1560 void SetRowHeight( const SwCursor& rCursor, const SwFormatFrameSize &rNew );
1561 static std::unique_ptr<SwFormatFrameSize> GetRowHeight( const SwCursor& rCursor );
1562 void SetRowSplit( const SwCursor& rCursor, const SwFormatRowSplit &rNew );
1563 static std::unique_ptr<SwFormatRowSplit> GetRowSplit( const SwCursor& rCursor );
1565 /// Adjustment of Rowheights. Determine via bTstOnly if more than one row is selected.
1566 /// bOptimize: distribute current table height, instead of using the largest row.
1567 /// Call again without bOptimize to ensure equal height in case some row's content didn't fit.
1568 bool BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly, const bool bOptimize );
1569 void SetRowBackground( const SwCursor& rCursor, const SvxBrushItem &rNew );
1570 static bool GetRowBackground( const SwCursor& rCursor, std::unique_ptr<SvxBrushItem>& rToFill );
1571 /// rNotTracked = false means that the row was deleted or inserted with its tracked cell content
1572 /// bAll: delete all table rows without selection
1573 /// bIns: insert table row
1574 void SetRowNotTracked( const SwCursor& rCursor,
1575 const SvxPrintItem &rNotTracked, bool bAll = false, bool bIns = false );
1576 /// don't call SetRowNotTracked() for rows with tracked row change
1577 static bool HasRowNotTracked( const SwCursor& rCursor );
1578 void SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet );
1579 void SetTabLineStyle( const SwCursor& rCursor,
1580 const Color* pColor, bool bSetLine,
1581 const editeng::SvxBorderLine* pBorderLine );
1582 static void GetTabBorders( const SwCursor& rCursor, SfxItemSet& rSet );
1583 void SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew );
1585 Retrieves a box attribute from the given cursor.
1587 @return Whether the property is set over the current box selection.
1589 @remarks A property is 'set' if it's set to the same value over all boxes in the current selection.
1590 The property value is retrieved from the first box in the current selection. It is then compared to
1591 the values of the same property over any other boxes in the selection; if any value is different from
1592 that of the first box, the property is unset (and false is returned).
1594 static bool GetBoxAttr( const SwCursor& rCursor, std::unique_ptr<SfxPoolItem>& rToFill );
1595 void SetBoxAlign( const SwCursor& rCursor, sal_uInt16 nAlign );
1596 static sal_uInt16 GetBoxAlign( const SwCursor& rCursor );
1597 /// Adjusts selected cell widths in such a way, that their content does not need to be wrapped (if possible).
1598 /// bBalance evenly re-distributes the available space regardless of content or wrapping.
1599 /// bNoShrink keeps table size the same by distributing excess space proportionately.
1600 void AdjustCellWidth( const SwCursor& rCursor, const bool bBalance, const bool bNoShrink );
1602 SW_DLLPUBLIC SwChainRet Chainable( const SwFrameFormat &rSource, const SwFrameFormat &rDest );
1603 SwChainRet Chain( SwFrameFormat &rSource, const SwFrameFormat &rDest );
1604 void Unchain( SwFrameFormat &rFormat );
1606 // For Copy/Move from FrameShell.
1607 rtl::Reference<SdrObject> CloneSdrObj( const SdrObject&, bool bMoveWithinDoc = false,
1608 bool bInsInPage = true );
1610 // FeShell - Interface end
1612 // Interface for TextInputData - for text input of Chinese and Japanese.
1613 SwExtTextInput* CreateExtTextInput( const SwPaM& rPam );
1614 void DeleteExtTextInput( SwExtTextInput* pDel );
1615 SwExtTextInput* GetExtTextInput( const SwNode& rNd,
1616 sal_Int32 nContentPos = -1) const;
1617 SwExtTextInput* GetExtTextInput() const;
1619 // Interface for access to AutoComplete-List.
1620 static SwAutoCompleteWord& GetAutoCompleteWords() { return *s_pAutoCompleteWords; }
1622 bool ContainsMSVBasic() const { return mbContains_MSVBasic; }
1623 void SetContainsMSVBasic( bool bFlag ) { mbContains_MSVBasic = bFlag; }
1625 // Interface for the list of Ruby - texts/attributes
1626 static sal_uInt16 FillRubyList( const SwPaM& rPam, SwRubyList& rList );
1627 void SetRubyList( SwPaM& rPam, const SwRubyList& rList );
1629 void ReadLayoutCache( SvStream& rStream );
1630 void WriteLayoutCache( SvStream& rStream );
1631 SwLayoutCache* GetLayoutCache() const { return mpLayoutCache.get(); }
1633 /** Checks if any of the text node contains hidden characters.
1634 Used for optimization. Changing the view option 'view hidden text'
1635 has to trigger a reformatting only if some of the text is hidden.
1637 bool ContainsHiddenChars() const;
1639 std::unique_ptr<sw::GrammarContact> const& getGrammarContact() const { return mpGrammarContact; }
1640 std::unique_ptr<sw::OnlineAccessibilityCheck> const& getOnlineAccessibilityCheck() const
1642 return mpOnlineAccessibilityCheck;
1645 /** Marks/Unmarks a list level of a certain list
1647 levels of a certain lists are marked now
1649 @param sListId list Id of the list whose level has to be marked/unmarked
1650 @param nListLevel level to mark
1651 @param bValue - true mark the level
1652 - false unmark the level
1654 void MarkListLevel( const OUString& sListId,
1655 const int nListLevel,
1656 const bool bValue );
1658 // Change a format undoable.
1659 SW_DLLPUBLIC void ChgFormat(SwFormat & rFormat, const SfxItemSet & rSet);
1661 void RenameFormat(SwFormat & rFormat, const OUString & sNewName,
1662 bool bBroadcast = false);
1664 // Change a TOX undoable.
1665 void ChangeTOX(SwTOXBase & rTOX, const SwTOXBase & rNew);
1668 Returns a textual description of a PaM.
1670 @param rPaM the PaM to describe
1672 If rPaM only spans one paragraph the result is:
1674 '<text in the PaM>'
1676 <text in the PaM> is shortened to nUndoStringLength characters.
1678 If rPaM spans more than one paragraph the result is:
1680 paragraphs (STR_PARAGRAPHS)
1682 @return the textual description of rPaM
1684 static OUString GetPaMDescr(const SwPaM & rPaM);
1686 static bool IsFirstOfNumRuleAtPos(const SwPosition & rPos, SwRootFrame const& rLayout);
1688 // access methods for XForms model(s)
1690 // access container for XForms model; will be NULL if !isXForms()
1691 const css::uno::Reference<css::container::XNameContainer>&
1692 getXForms() const { return mxXForms;}
1694 css::uno::Reference< css::linguistic2::XProofreadingIterator > const & GetGCIterator() const;
1696 // #i31958# is this an XForms document?
1697 bool isXForms() const;
1699 // #i31958# initialize XForms models; turn this into an XForms document
1700 void initXForms( bool bCreateDefaultModel );
1702 // #i113606# for disposing XForms
1703 void disposeXForms( );
1705 //Update all the page masters
1706 SW_DLLPUBLIC void SetDefaultPageMode(bool bSquaredPageMode);
1707 SW_DLLPUBLIC bool IsSquaredPageMode() const;
1709 const css::uno::Reference< ooo::vba::word::XFind >& getVbaFind() const { return mxVbaFind; }
1710 void setVbaFind( const css::uno::Reference< ooo::vba::word::XFind > &xFind) { mxVbaFind = xFind; }
1711 css::uno::Reference< css::script::vba::XVBAEventProcessor > const & GetVbaEventProcessor();
1712 SW_DLLPUBLIC void SetVbaEventProcessor();
1713 void SetVBATemplateToProjectCache( css::uno::Reference< css::container::XNameContainer > const & xCache ) { m_xTemplateToProjectCache = xCache; };
1714 const css::uno::Reference< css::container::XNameContainer >& GetVBATemplateToProjectCache() const { return m_xTemplateToProjectCache; };
1715 ::sfx2::IXmlIdRegistry& GetXmlIdRegistry();
1716 SW_DLLPUBLIC ::sw::MetaFieldManager & GetMetaFieldManager();
1717 SW_DLLPUBLIC ::SwContentControlManager& GetContentControlManager();
1718 SW_DLLPUBLIC ::sw::UndoManager & GetUndoManager();
1719 ::sw::UndoManager const& GetUndoManager() const;
1721 rtl::Reference<SfxObjectShell> CreateCopy(bool bCallInitNew, bool bEmpty) const;
1722 SwNodeIndex AppendDoc(const SwDoc& rSource, sal_uInt16 nStartPageNumber,
1723 bool bDeletePrevious, int physicalPageOffset,
1724 const sal_uLong nDocNo);
1727 * Dumps the entire nodes structure to the given destination (file nodes.xml in the current directory by default)
1729 void dumpAsXml(xmlTextWriterPtr = nullptr) const;
1731 std::set<Color> GetDocColors();
1732 std::vector< std::weak_ptr<SwUnoCursor> > mvUnoCursorTable;
1734 // Remove expired UnoCursor weak pointers the document keeps to notify about document death.
1735 void cleanupUnoCursorTable() const
1737 auto & rTable = const_cast<SwDoc*>(this)->mvUnoCursorTable;
1738 // In most cases we'll remove most of the elements.
1739 std::erase_if(rTable, [] (std::weak_ptr<SwUnoCursor> const & x) { return x.expired(); });
1743 * @param bSkipStart don't actually start the jobs, just check
1744 * @returns true if new background checking jobs were started
1746 bool StartGrammarChecking( bool bSkipStart = false );
1748 /// Use to notify if the dictionary can be found for a single content portion (has to be called for all portions)
1749 void SetMissingDictionaries( bool bIsMissing );
1750 /// Returns true if no dictionary can be found for any content
1751 bool IsDictionaryMissing() const { return meDictionaryMissing == MissingDictionary::True; }
1753 void SetLanguage(const LanguageType eLang, const sal_uInt16 nId);
1755 static bool HasParagraphDirectFormatting(const SwPosition& rPos);
1757 private:
1758 // Copies master header to left / first one, if necessary - used by ChgPageDesc().
1759 void CopyMasterHeader(const SwPageDesc &rChged, const SwFormatHeader &rHead, SwPageDesc &pDesc, bool bLeft, bool bFirst);
1760 // Copies master footer to left / first one, if necessary - used by ChgPageDesc().
1761 void CopyMasterFooter(const SwPageDesc &rChged, const SwFormatFooter &rFoot, SwPageDesc &pDesc, bool bLeft, bool bFirst);
1765 namespace o3tl {
1766 template<> struct typed_flags<SwDoc::RowColMode> : is_typed_flags<SwDoc::RowColMode, 3> {};
1767 template<> struct typed_flags<SwDoc::SetNumRuleMode> : is_typed_flags<SwDoc::SetNumRuleMode, 0x0f> {};
1770 // This method is called in Dtor of SwDoc and deletes cache of ContourObjects.
1771 void ClrContourCache();
1773 inline void SwDoc::SetOLEPrtNotifyPending( bool bSet )
1775 mbOLEPrtNotifyPending = bSet;
1776 if( !bSet )
1777 mbAllOLENotify = false;
1780 bool sw_GetPostIts(const IDocumentFieldsAccess& rIDFA, SetGetExpFields * pSrtLst);
1782 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */