android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / inc / doc.hxx
blobbbf045188c5553f018d649ed626ec4661d9f839d
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 #ifndef INCLUDED_SW_INC_DOC_HXX
20 #define INCLUDED_SW_INC_DOC_HXX
22 // SwDoc interfaces
23 #include <o3tl/typed_flags_set.hxx>
24 #include <o3tl/sorted_vector.hxx>
25 #include <vcl/idle.hxx>
26 #include "swdllapi.h"
27 #include "swtypes.hxx"
28 #include "toxe.hxx"
29 #include "flyenum.hxx"
30 #include "flypos.hxx"
31 #include "swdbdata.hxx"
32 #include <sfx2/objsh.hxx>
33 #include <svl/style.hxx>
34 #include <editeng/numitem.hxx>
35 #include "tox.hxx"
36 #include "frmfmt.hxx"
37 #include "frameformats.hxx"
38 #include "charfmt.hxx"
39 #include "docary.hxx"
40 #include "charformats.hxx"
41 #include "pagedesc.hxx"
42 #include "tblenum.hxx"
43 #include "ndarr.hxx"
44 #include "ndtyp.hxx"
45 #include <memory>
46 #include <mutex>
47 #include <set>
48 #include <tuple>
49 #include <unordered_map>
50 #include <vector>
52 namespace editeng { class SvxBorderLine; }
54 class SwExtTextInput;
55 class EditFieldInfo;
56 class Outliner;
57 class OutputDevice;
58 class Point;
59 class SbxArray;
60 class SdrObject;
61 class SdrUndoAction;
62 class SvNumberFormatter;
63 class SvxMacro;
64 class SwAutoCompleteWord;
65 class SwAutoCorrExceptWord;
66 class SwCellFrame;
67 class SwCellStyleTable;
68 class SwCursorShell;
69 class SwCursor;
70 class SwDocShell;
71 class SwDrawView;
72 class SwEditShell;
73 class SwFormat;
74 class SwFormatINetFormat;
75 class SwFormatRefMark;
76 class SwFootnoteIdxs;
77 class SwFootnoteInfo;
78 class SwEndNoteInfo;
79 class SwLineNumberInfo;
80 class SwDBManager;
81 class SwNodeIndex;
82 class SwNodeRange;
83 class SwNumRule;
84 class SwPagePreviewPrtData;
85 class SwRootFrame;
86 class SwRubyListEntry;
87 class SwSectionFormat;
88 class SwSectionData;
89 class SwSelBoxes;
90 class SwTableAutoFormatTable;
91 class SwTOXBaseSection;
92 class SwTabCols;
93 class SwTable;
94 class SwTableAutoFormat;
95 class SwTableBox;
96 class SwTableBoxFormat;
97 class SwTableFormat;
98 class SwTableLineFormat;
99 class SwTableNode;
100 class SwTextBlocks;
101 class SwURLStateChanged;
102 class SwUnoCursor;
103 class SwViewShell;
104 class SwDrawContact;
105 class SdrView;
106 class SdrMarkList;
107 class SwAuthEntry;
108 class SwLayoutCache;
109 class IStyleAccess;
110 struct SwCallMouseEvent;
111 struct SwDocStat;
112 struct SwSortOptions;
113 struct SwDefTOXBase_Impl;
114 class SwPrintUIOptions;
115 struct SwConversionArgs;
116 class SwRenderData;
117 class IDocumentUndoRedo;
118 class IDocumentSettingAccess;
119 class IDocumentDeviceAccess;
120 class IDocumentDrawModelAccess;
121 class IDocumentChartDataProviderAccess;
122 class IDocumentTimerAccess;
123 class IDocumentLinksAdministration;
124 class IDocumentListItems;
125 class IDocumentListsAccess;
126 class IDocumentOutlineNodes;
127 class IDocumentContentOperations;
128 class IDocumentRedlineAccess;
129 class IDocumentStatistics;
130 class IDocumentState;
131 class IDocumentLayoutAccess;
132 class IDocumentStylePoolAccess;
133 class IDocumentExternalData;
134 class IDocumentMarkAccess;
135 class SetGetExpFields;
136 struct SwInsertTableOptions;
137 class SwContentControlManager;
138 enum class SvMacroItemId : sal_uInt16;
139 enum class SvxFrameDirection;
140 enum class RndStdIds;
142 namespace sw::mark { class MarkManager; }
143 namespace sw {
144 enum class RedlineMode;
145 enum class FieldmarkMode;
146 enum class ParagraphBreakMode;
147 class MetaFieldManager;
148 class UndoManager;
149 class IShellCursorSupplier;
150 class DocumentSettingManager;
151 class DocumentDeviceManager;
152 class DocumentDrawModelManager;
153 class DocumentChartDataProviderManager;
154 class DocumentTimerManager;
155 class DocumentLinksAdministrationManager;
156 class DocumentListItemsManager;
157 class DocumentListsManager;
158 class DocumentOutlineNodesManager;
159 class DocumentContentOperationsManager;
160 class DocumentRedlineManager;
161 class DocumentFieldsManager;
162 class DocumentStatisticsManager;
163 class DocumentStateManager;
164 class DocumentLayoutManager;
165 class DocumentStylePoolManager;
166 class DocumentExternalDataManager;
167 template<class T> class FrameFormats;
168 class GrammarContact;
169 class OnlineAccessibilityCheck;
172 namespace com::sun::star {
173 namespace container {
174 class XNameContainer; //< for getXForms()/isXForms()/initXForms() methods
176 namespace embed { class XStorage; }
177 namespace linguistic2 { class XHyphenatedWord; }
178 namespace linguistic2 { class XProofreadingIterator; }
179 namespace linguistic2 { class XSpellChecker1; }
180 namespace script::vba { class XVBAEventProcessor; }
183 namespace ooo::vba::word {
184 class XFind;
187 namespace sfx2 {
188 class IXmlIdRegistry;
191 void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem );
193 using SwRubyList = std::vector<std::unique_ptr<SwRubyListEntry>>;
195 // Represents the model of a Writer document.
196 class SW_DLLPUBLIC SwDoc final
198 friend class ::sw::DocumentContentOperationsManager;
200 friend void InitCore();
201 friend void FinitCore();
203 // private Member
204 std::unique_ptr<SwNodes> m_pNodes; //< document content (Nodes Array)
205 rtl::Reference<SwAttrPool> mpAttrPool; //< the attribute pool
206 SwPageDescs m_PageDescs; //< PageDescriptors
207 Link<bool,void> maOle2Link; //< OLE 2.0-notification
208 /* @@@MAINTAINABILITY-HORROR@@@
209 Timer should not be members of the model
211 Idle maOLEModifiedIdle; //< Timer for update modified OLE-Objects
212 SwDBData maDBData; //< database descriptor
213 OUString msTOIAutoMarkURL; //< URL of table of index AutoMark file
214 std::vector<OUString> m_PatternNames; //< Array for names of document-templates
215 css::uno::Reference<css::container::XNameContainer>
216 mxXForms; //< container with XForms models
217 mutable css::uno::Reference< css::linguistic2::XProofreadingIterator > m_xGCIterator;
219 const std::unique_ptr< ::sw::mark::MarkManager> mpMarkManager;
220 const std::unique_ptr< ::sw::MetaFieldManager > m_pMetaFieldManager;
221 const std::unique_ptr< ::SwContentControlManager > m_pContentControlManager;
222 const std::unique_ptr< ::sw::DocumentDrawModelManager > m_pDocumentDrawModelManager;
223 const std::unique_ptr< ::sw::DocumentRedlineManager > m_pDocumentRedlineManager;
224 const std::unique_ptr< ::sw::DocumentStateManager > m_pDocumentStateManager;
225 const std::unique_ptr< ::sw::UndoManager > m_pUndoManager;
226 const std::unique_ptr< ::sw::DocumentSettingManager > m_pDocumentSettingManager;
227 const std::unique_ptr< ::sw::DocumentChartDataProviderManager > m_pDocumentChartDataProviderManager;
228 std::unique_ptr< ::sw::DocumentDeviceManager > m_pDeviceAccess;
229 const std::unique_ptr< ::sw::DocumentTimerManager > m_pDocumentTimerManager;
230 const std::unique_ptr< ::sw::DocumentLinksAdministrationManager > m_pDocumentLinksAdministrationManager;
231 const std::unique_ptr< ::sw::DocumentListItemsManager > m_pDocumentListItemsManager;
232 const std::unique_ptr< ::sw::DocumentListsManager > m_pDocumentListsManager;
233 const std::unique_ptr< ::sw::DocumentOutlineNodesManager > m_pDocumentOutlineNodesManager;
234 const std::unique_ptr< ::sw::DocumentContentOperationsManager > m_pDocumentContentOperationsManager;
235 const std::unique_ptr< ::sw::DocumentFieldsManager > m_pDocumentFieldsManager;
236 const std::unique_ptr< ::sw::DocumentStatisticsManager > m_pDocumentStatisticsManager;
237 const std::unique_ptr< ::sw::DocumentLayoutManager > m_pDocumentLayoutManager;
238 const std::unique_ptr< ::sw::DocumentStylePoolManager > m_pDocumentStylePoolManager;
239 const std::unique_ptr< ::sw::DocumentExternalDataManager > m_pDocumentExternalDataManager;
241 // Pointer
242 std::unique_ptr<SwFrameFormat> mpDfltFrameFormat; //< Default formats.
243 std::unique_ptr<SwFrameFormat> mpEmptyPageFormat; //< Format for the default empty page
244 std::unique_ptr<SwFrameFormat> mpColumnContFormat; //< Format for column container
245 std::unique_ptr<SwCharFormat> mpDfltCharFormat;
246 std::unique_ptr<SwTextFormatColl> mpDfltTextFormatColl; //< Defaultformatcollections
247 std::unique_ptr<SwGrfFormatColl> mpDfltGrfFormatColl;
249 std::unique_ptr<sw::FrameFormats<SwFrameFormat*>> mpFrameFormatTable; //< Format table
250 std::unique_ptr<SwCharFormats> mpCharFormatTable;
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, 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 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 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_DLLPRIVATE_LINK( DoUpdateModifiedOLE, Timer *, void );
392 public:
393 SwFormat *MakeCharFormat_(const OUString &, SwFormat *, bool, bool );
394 SwFormat *MakeFrameFormat_(const OUString &, SwFormat *, bool, bool );
396 private:
397 SwFormat *MakeTextFormatColl_(const OUString &, SwFormat *, bool, 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 SwDoc();
415 ~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 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 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 // IDocumentSettingAccess
452 IDocumentSettingAccess const & getIDocumentSettingAccess() const; //The IDocumentSettingAccess interface
453 IDocumentSettingAccess & getIDocumentSettingAccess();
454 ::sw::DocumentSettingManager & GetDocumentSettingManager(); //The implementation of the interface with some additional methods
455 ::sw::DocumentSettingManager const& GetDocumentSettingManager() const;
456 sal_uInt32 getRsid() const;
457 void setRsid( sal_uInt32 nVal );
458 sal_uInt32 getRsidRoot() const;
459 void setRsidRoot( sal_uInt32 nVal );
461 // IDocumentDeviceAccess
462 IDocumentDeviceAccess const & getIDocumentDeviceAccess() const;
463 IDocumentDeviceAccess & getIDocumentDeviceAccess();
465 // IDocumentMarkAccess
466 IDocumentMarkAccess* getIDocumentMarkAccess();
467 const IDocumentMarkAccess* getIDocumentMarkAccess() const;
469 // IDocumentRedlineAccess
470 IDocumentRedlineAccess const& getIDocumentRedlineAccess() const;
471 IDocumentRedlineAccess& getIDocumentRedlineAccess();
473 ::sw::DocumentRedlineManager const& GetDocumentRedlineManager() const;
474 ::sw::DocumentRedlineManager& GetDocumentRedlineManager();
476 // IDocumentUndoRedo
477 IDocumentUndoRedo & GetIDocumentUndoRedo();
478 IDocumentUndoRedo const& GetIDocumentUndoRedo() const;
480 // IDocumentLinksAdministration
481 IDocumentLinksAdministration const & getIDocumentLinksAdministration() const;
482 IDocumentLinksAdministration & getIDocumentLinksAdministration();
484 ::sw::DocumentLinksAdministrationManager const & GetDocumentLinksAdministrationManager() const;
485 ::sw::DocumentLinksAdministrationManager & GetDocumentLinksAdministrationManager();
487 // IDocumentFieldsAccess
488 IDocumentFieldsAccess const & getIDocumentFieldsAccess() const;
489 IDocumentFieldsAccess & getIDocumentFieldsAccess();
491 ::sw::DocumentFieldsManager & GetDocumentFieldsManager();
493 // Returns 0 if the field cannot hide para, or a positive integer indicating the field type
494 // "weight" when several hiding fields' FieldHidesPara() give conflicting results
495 int FieldCanHideParaWeight(SwFieldIds eFieldId) const;
496 bool FieldHidesPara(const SwField& rField) const;
498 // IDocumentContentOperations
499 IDocumentContentOperations const & getIDocumentContentOperations() const;
500 IDocumentContentOperations & getIDocumentContentOperations();
501 ::sw::DocumentContentOperationsManager const & GetDocumentContentOperationsManager() const;
502 ::sw::DocumentContentOperationsManager & GetDocumentContentOperationsManager();
504 bool UpdateParRsid( SwTextNode *pTextNode, sal_uInt32 nVal = 0 );
505 void UpdateRsid( const SwPaM &rRg, sal_Int32 nLen );
507 // IDocumentStylePoolAccess
508 IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const;
509 IDocumentStylePoolAccess & getIDocumentStylePoolAccess();
511 // SwLineNumberInfo
512 const SwLineNumberInfo& GetLineNumberInfo() const;
513 void SetLineNumberInfo(const SwLineNumberInfo& rInfo);
515 // IDocumentStatistics
516 IDocumentStatistics const & getIDocumentStatistics() const;
517 IDocumentStatistics & getIDocumentStatistics();
519 ::sw::DocumentStatisticsManager const & GetDocumentStatisticsManager() const;
520 ::sw::DocumentStatisticsManager & GetDocumentStatisticsManager();
522 // IDocumentState
523 IDocumentState const & getIDocumentState() const;
524 IDocumentState & getIDocumentState();
526 // IDocumentDrawModelAccess
527 void AddDrawUndo( std::unique_ptr<SdrUndoAction> );
528 IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const;
529 IDocumentDrawModelAccess & getIDocumentDrawModelAccess();
531 ::sw::DocumentDrawModelManager const & GetDocumentDrawModelManager() const;
532 ::sw::DocumentDrawModelManager & GetDocumentDrawModelManager();
534 // IDocumentLayoutAccess
535 IDocumentLayoutAccess const & getIDocumentLayoutAccess() const;
536 IDocumentLayoutAccess & getIDocumentLayoutAccess();
538 ::sw::DocumentLayoutManager const & GetDocumentLayoutManager() const;
539 ::sw::DocumentLayoutManager & GetDocumentLayoutManager();
541 // IDocumentTimerAccess
542 // Our own 'IdleTimer' calls the following method
543 IDocumentTimerAccess const & getIDocumentTimerAccess() const;
544 IDocumentTimerAccess & getIDocumentTimerAccess();
546 // IDocumentChartDataProviderAccess
547 IDocumentChartDataProviderAccess const & getIDocumentChartDataProviderAccess() const;
548 IDocumentChartDataProviderAccess & getIDocumentChartDataProviderAccess();
550 // IDocumentListItems
551 IDocumentListItems const & getIDocumentListItems() const;
552 IDocumentListItems & getIDocumentListItems();
554 // IDocumentOutlineNodes
555 IDocumentOutlineNodes const & getIDocumentOutlineNodes() const;
556 IDocumentOutlineNodes & getIDocumentOutlineNodes();
558 // IDocumentListsAccess
559 IDocumentListsAccess const & getIDocumentListsAccess() const;
560 IDocumentListsAccess & getIDocumentListsAccess();
562 //IDocumentExternalData
563 IDocumentExternalData const & getIDocumentExternalData() const;
564 IDocumentExternalData & getIDocumentExternalData();
566 //End of Interfaces
568 void setDocAccTitle( const OUString& rTitle ) { msDocAccTitle = rTitle; }
569 const OUString& getDocAccTitle() const { return msDocAccTitle; }
571 // INextInterface here
572 DECL_DLLPRIVATE_LINK(CalcFieldValueHdl, EditFieldInfo*, void);
574 // OLE ???
575 bool IsOLEPrtNotifyPending() const { return mbOLEPrtNotifyPending; }
576 inline void SetOLEPrtNotifyPending( bool bSet = true );
577 void PrtOLENotify( bool bAll ); // All or only marked
579 bool IsPrepareSelAll() const { return mbIsPrepareSelAll; }
580 void SetPrepareSelAll() { mbIsPrepareSelAll = true; }
582 void SetContainsAtPageObjWithContentAnchor( const bool bFlag )
584 mbContainsAtPageObjWithContentAnchor = bFlag;
586 bool DoesContainAtPageObjWithContentAnchor()
588 return mbContainsAtPageObjWithContentAnchor;
591 /** Returns positions of all FlyFrames in the document.
592 If a Pam-Pointer is passed the FlyFrames attached to paragraphs
593 have to be surrounded completely by css::awt::Selection.
594 ( Start < Pos < End ) !!!
595 (Required for Writers.) */
596 SwPosFlyFrames GetAllFlyFormats( const SwPaM*,
597 bool bDrawAlso,
598 bool bAsCharAlso = false ) const;
600 SwFlyFrameFormat *MakeFlyFrameFormat (const OUString &rFormatName, SwFrameFormat *pDerivedFrom);
601 SwDrawFrameFormat *MakeDrawFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom);
603 // From now on this interface has to be used for Flys.
604 // pAnchorPos must be set, if they are not attached to pages AND
605 // Anchor is not already set at valid ContentPos
606 // in FlySet/FrameFormat.
607 /* new parameter bCalledFromShell
609 true: An existing adjust item at pAnchorPos is propagated to
610 the content node of the new fly section. That propagation only
611 takes place if there is no adjust item in the paragraph style
612 for the new fly section.
614 false: no propagation
616 SwFlyFrameFormat* MakeFlySection( RndStdIds eAnchorType,
617 const SwPosition* pAnchorPos,
618 const SfxItemSet* pSet = nullptr,
619 SwFrameFormat *pParent = nullptr,
620 bool bCalledFromShell = false );
621 SwFlyFrameFormat* MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet,
622 const SwSelBoxes* pSelBoxes,
623 SwFrameFormat *pParent );
625 // Helper that checks for unique items for DrawingLayer items of type NameOrIndex
626 // and evtl. corrects that items to ensure unique names for that type. This call may
627 // modify/correct entries inside of the given SfxItemSet, and it will apply a name to
628 // the items in question (what is essential to make the named slots associated with
629 // these items work for the UNO API and thus e.g. for ODF import/export)
630 void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet& rSet);
632 bool SetFlyFrameAttr( SwFrameFormat& rFlyFormat, SfxItemSet& rSet );
634 bool SetFrameFormatToFly( SwFrameFormat& rFlyFormat, SwFrameFormat& rNewFormat,
635 SfxItemSet* pSet = nullptr, bool bKeepOrient = false );
636 void SetFlyFrameTitle( SwFlyFrameFormat& rFlyFrameFormat,
637 const OUString& sNewTitle );
638 void SetFlyFrameDescription( SwFlyFrameFormat& rFlyFrameFormat,
639 const OUString& sNewDescription );
640 void SetFlyFrameDecorative(SwFlyFrameFormat& rFlyFrameFormat,
641 bool isDecorative);
643 // Footnotes
644 // Footnote information
645 const SwFootnoteInfo& GetFootnoteInfo() const { return *mpFootnoteInfo; }
646 void SetFootnoteInfo(const SwFootnoteInfo& rInfo);
647 const SwEndNoteInfo& GetEndNoteInfo() const { return *mpEndNoteInfo; }
648 void SetEndNoteInfo(const SwEndNoteInfo& rInfo);
649 SwFootnoteIdxs& GetFootnoteIdxs() { return *mpFootnoteIdxs; }
650 const SwFootnoteIdxs& GetFootnoteIdxs() const { return *mpFootnoteIdxs; }
651 /// change footnotes in range
652 bool SetCurFootnote( const SwPaM& rPam, const OUString& rNumStr,
653 bool bIsEndNote );
655 /** Operations on the content of the document e.g.
656 spell-checking/hyphenating/word-counting
658 css::uno::Any
659 Spell( SwPaM&, css::uno::Reference< css::linguistic2::XSpellChecker1 > const &,
660 sal_uInt16* pPageCnt, sal_uInt16* pPageSt, bool bGrammarCheck,
661 SwRootFrame const* pLayout, // for grammar-check
662 SwConversionArgs *pConvArgs = nullptr ) const;
664 css::uno::Reference< css::linguistic2::XHyphenatedWord >
665 Hyphenate( SwPaM *pPam, const Point &rCursorPos,
666 sal_uInt16* pPageCnt, sal_uInt16* pPageSt );
668 // count words in pam
669 static void CountWords( const SwPaM& rPaM, SwDocStat& rStat );
671 // Glossary Document
672 bool IsInsOnlyTextGlossary() const { return mbInsOnlyTextGlssry; }
674 void Summary(SwDoc& rExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, bool bImpress);
676 void ChangeAuthorityData(const SwAuthEntry* pNewData);
678 bool IsInHeaderFooter( const SwNode& ) const;
679 SvxFrameDirection GetTextDirection( const SwPosition& rPos,
680 const Point* pPt = nullptr ) const;
681 bool IsInVerticalText( const SwPosition& rPos ) const;
683 // Database and DB-Manager
684 void SetDBManager( SwDBManager* pNewMgr ) { m_pDBManager = pNewMgr; }
685 SwDBManager* GetDBManager() const { return m_pDBManager; }
686 void ChangeDBFields( const std::vector<OUString>& rOldNames,
687 const OUString& rNewName );
688 void SetInitDBFields(bool b);
690 // Find out which databases are used by fields.
691 void GetAllUsedDB( std::vector<OUString>& rDBNameList,
692 const std::vector<OUString>* pAllDBNames = nullptr );
694 void ChgDBData( const SwDBData& rNewData );
695 SwDBData const & GetDBData();
697 // Some helper functions
698 OUString GetUniqueGrfName(std::u16string_view rPrefix = std::u16string_view()) const;
699 OUString GetUniqueOLEName() const;
700 OUString GetUniqueFrameName() const;
701 OUString GetUniqueShapeName() const;
702 OUString GetUniqueDrawObjectName() const;
704 o3tl::sorted_vector<SwRootFrame*> GetAllLayouts();
706 void SetFlyName( SwFlyFrameFormat& rFormat, const OUString& rName );
707 const SwFlyFrameFormat* FindFlyByName( const OUString& rName, SwNodeType nNdTyp = SwNodeType::NONE ) const;
709 static void GetGrfNms( const SwFlyFrameFormat& rFormat, OUString* pGrfName, OUString* pFltName );
711 // Set a valid name for all Flys that have none (Called by Readers after reading).
712 void SetAllUniqueFlyNames();
714 /** Reset attributes. All TextHints and (if completely selected) all hard-
715 formatted stuff (auto-formats) are removed.
716 Introduce new optional parameter <bSendDataChangedEvents> in order to
717 control, if the side effect "send data changed events" is triggered or not. */
718 void ResetAttrs( const SwPaM &rRg,
719 bool bTextAttr = true,
720 const o3tl::sorted_vector<sal_uInt16> &rAttrs = o3tl::sorted_vector<sal_uInt16>(),
721 const bool bSendDataChangedEvents = true,
722 SwRootFrame const* pLayout = nullptr);
723 void RstTextAttrs(const SwPaM &rRg, bool bInclRefToxMark = false,
724 bool bExactRange = false, SwRootFrame const* pLayout = nullptr);
726 /** Set attribute in given format.1y
727 * If Undo is enabled, the old values is added to the Undo history. */
728 void SetAttr( const SfxPoolItem&, SwFormat& );
729 /** Set attribute in given format.1y
730 * If Undo is enabled, the old values is added to the Undo history. */
731 void SetAttr( const SfxItemSet&, SwFormat& );
733 // method to reset a certain attribute at the given format
734 void ResetAttrAtFormat( const sal_uInt16 nWhichId,
735 SwFormat& rChangedFormat );
737 /** Set attribute as new default attribute in current document.
738 If Undo is activated, the old one is listed in Undo-History. */
739 void SetDefault( const SfxPoolItem& );
740 void SetDefault( const SfxItemSet& );
742 // Query default attribute in this document.
743 const SfxPoolItem& GetDefault( sal_uInt16 nFormatHint ) const;
744 template<class T> const T& GetDefault( TypedWhichId<T> nWhich ) const
746 return static_cast<const T&>(GetDefault(sal_uInt16(nWhich)));
749 // Do not expand text attributes.
750 bool DontExpandFormat( const SwPosition& rPos, bool bFlag = true );
752 // Formats
753 const sw::FrameFormats<SwFrameFormat*>* GetFrameFormats() const { return mpFrameFormatTable.get(); }
754 sw::FrameFormats<SwFrameFormat*>* GetFrameFormats() { return mpFrameFormatTable.get(); }
755 const SwCharFormats* GetCharFormats() const { return mpCharFormatTable.get();}
756 SwCharFormats* GetCharFormats() { return mpCharFormatTable.get();}
758 // LayoutFormats (frames, DrawObjects), sometimes const sometimes not
759 const sw::FrameFormats<sw::SpzFrameFormat*>* GetSpzFrameFormats() const { return mpSpzFrameFormatTable.get(); }
760 sw::FrameFormats<sw::SpzFrameFormat*>* GetSpzFrameFormats() { return mpSpzFrameFormatTable.get(); }
762 const SwFrameFormat *GetDfltFrameFormat() const { return mpDfltFrameFormat.get(); }
763 SwFrameFormat *GetDfltFrameFormat() { return mpDfltFrameFormat.get(); }
764 const SwFrameFormat *GetEmptyPageFormat() const { return mpEmptyPageFormat.get(); }
765 SwFrameFormat *GetEmptyPageFormat() { return mpEmptyPageFormat.get(); }
766 const SwFrameFormat *GetColumnContFormat() const{ return mpColumnContFormat.get(); }
767 SwFrameFormat *GetColumnContFormat() { return mpColumnContFormat.get(); }
768 const SwCharFormat *GetDfltCharFormat() const { return mpDfltCharFormat.get();}
769 SwCharFormat *GetDfltCharFormat() { return mpDfltCharFormat.get();}
771 // @return the interface of the management of (auto)styles
772 IStyleAccess& GetIStyleAccess() { return *mpStyleAccess; }
774 // Remove all language dependencies from all existing formats
775 void RemoveAllFormatLanguageDependencies();
777 SwFrameFormat *MakeFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom,
778 bool bBroadcast = false, bool bAuto = true);
779 void DelFrameFormat( SwFrameFormat *pFormat, bool bBroadcast = false );
780 SwFrameFormat* FindFrameFormatByName( const OUString& rName ) const;
782 SwCharFormat *MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom,
783 bool bBroadcast = false );
784 void DelCharFormat(size_t nFormat, bool bBroadcast = false);
785 void DelCharFormat(SwCharFormat const * pFormat, bool bBroadcast = false);
786 SwCharFormat* FindCharFormatByName( const OUString& rName ) const
787 { return mpCharFormatTable->FindFormatByName(rName); }
789 // Formatcollections (styles)
790 // TXT
791 const SwTextFormatColl* GetDfltTextFormatColl() const { return mpDfltTextFormatColl.get(); }
792 SwTextFormatColl* GetDfltTextFormatColl() { return mpDfltTextFormatColl.get(); }
793 const SwTextFormatColls *GetTextFormatColls() const { return mpTextFormatCollTable.get(); }
794 SwTextFormatColls *GetTextFormatColls() { return mpTextFormatCollTable.get(); }
795 SwTextFormatColl *MakeTextFormatColl( const OUString &rFormatName,
796 SwTextFormatColl *pDerivedFrom,
797 bool bBroadcast = false);
798 SwConditionTextFormatColl* MakeCondTextFormatColl( const OUString &rFormatName,
799 SwTextFormatColl *pDerivedFrom,
800 bool bBroadcast = false);
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 bool SetTextFormatColl(const SwPaM &rRg, SwTextFormatColl *pFormat,
811 const bool bReset = true,
812 const bool bResetListAttrs = false,
813 SwRootFrame const* pLayout = nullptr);
814 SwTextFormatColl* FindTextFormatCollByName( const OUString& rName ) const
815 { return mpTextFormatCollTable->FindFormatByName(rName); }
817 void ChkCondColls();
819 const SwGrfFormatColl* GetDfltGrfFormatColl() const { return mpDfltGrfFormatColl.get(); }
820 SwGrfFormatColl* GetDfltGrfFormatColl() { return mpDfltGrfFormatColl.get(); }
821 const SwGrfFormatColls *GetGrfFormatColls() const { return mpGrfFormatCollTable.get(); }
822 SwGrfFormatColl *MakeGrfFormatColl(const OUString &rFormatName,
823 SwGrfFormatColl *pDerivedFrom);
825 // Table formatting
826 const sw::TableFrameFormats* GetTableFrameFormats() const { return mpTableFrameFormatTable.get(); }
827 sw::TableFrameFormats* GetTableFrameFormats() { return mpTableFrameFormatTable.get(); }
828 size_t GetTableFrameFormatCount( bool bUsed ) const;
829 SwTableFormat& GetTableFrameFormat(size_t nFormat, bool bUsed ) const;
830 SwTableFormat* MakeTableFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom);
831 void DelTableFrameFormat( SwTableFormat* pFormat );
832 SwTableFormat* FindTableFormatByName( const OUString& rName, bool bAll = false ) const;
834 /** Access to frames.
835 Iterate over Flys - for Basic-Collections. */
836 size_t GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes = false ) const;
837 SwFrameFormat* GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes = false );
838 std::vector<SwFrameFormat const*> GetFlyFrameFormats(
839 FlyCntType eType,
840 bool bIgnoreTextBoxes);
842 // Copy formats in own arrays and return them.
843 SwFrameFormat *CopyFrameFormat ( const SwFrameFormat& );
844 SwCharFormat *CopyCharFormat( const SwCharFormat& );
845 SwTextFormatColl* CopyTextColl( const SwTextFormatColl& rColl );
846 SwGrfFormatColl* CopyGrfColl( const SwGrfFormatColl& rColl );
848 // Replace all styles with those from rSource.
849 void ReplaceStyles( const SwDoc& rSource, bool bIncludePageStyles = true );
851 // Replace all property defaults with those from rSource.
852 void ReplaceDefaults( const SwDoc& rSource );
854 // Replace all compatibility options with those from rSource.
855 void ReplaceCompatibilityOptions( const SwDoc& rSource );
857 /** Replace all user defined document properties with xSourceDocProps.
858 Convenience function used by ReplaceDocumentProperties to skip some UNO calls.
860 void ReplaceUserDefinedDocumentProperties( const css::uno::Reference< css::document::XDocumentProperties >& xSourceDocProps );
862 /** Replace document properties with those from rSource.
864 This includes the user defined document properties!
866 void ReplaceDocumentProperties(const SwDoc& rSource, bool mailMerge = false);
868 // Query if style (paragraph- / character- / frame- / page-) is used.
869 bool IsUsed( const sw::BroadcastingModify& ) const;
870 /// Query if table style is used.
871 bool IsUsed( const SwTableAutoFormat& ) const;
872 bool IsUsed( const SwNumRule& ) const;
874 // Set name of newly loaded document template.
875 size_t SetDocPattern(const OUString& rPatternName);
877 // @return name of document template. Can be 0!
878 const OUString* GetDocPattern(size_t nPos) const;
880 // travel over PaM Ring
881 bool InsertGlossary( SwTextBlocks& rBlock, const OUString& rEntry,
882 SwPaM& rPaM, SwCursorShell* pShell = nullptr);
884 /** get the set of printable pages for the XRenderable API by
885 evaluating the respective settings (see implementation) */
886 static void CalculatePagesForPrinting( const SwRootFrame& rLayout, SwRenderData &rData, const SwPrintUIOptions &rOptions, bool bIsPDFExport,
887 sal_Int32 nDocPageCount );
888 static void UpdatePagesForPrintingWithPostItData( SwRenderData &rData, const SwPrintUIOptions &rOptions,
889 sal_Int32 nDocPageCount );
890 static void CalculatePagePairsForProspectPrinting( const SwRootFrame& rLayout, SwRenderData &rData, const SwPrintUIOptions &rOptions,
891 sal_Int32 nDocPageCount );
892 static void CalculateNonBlankPages( const SwRootFrame& rLayout, sal_uInt16& nDocPageCount, sal_uInt16& nActualPage );
894 // PageDescriptor interface.
895 size_t GetPageDescCnt() const { return m_PageDescs.size(); }
896 const SwPageDesc& GetPageDesc(const size_t i) const { return *m_PageDescs[i]; }
897 SwPageDesc& GetPageDesc(size_t const i) { return *m_PageDescs[i]; }
898 SwPageDesc* FindPageDesc(const OUString& rName, size_t* pPos = nullptr) const;
899 // Just searches the pointer in the m_PageDescs vector!
900 bool ContainsPageDesc(const SwPageDesc *pDesc, size_t* pPos) const;
902 /** Copy the complete PageDesc - beyond document and "deep"!
903 Optionally copying of PoolFormatId, -HlpId can be prevented. */
904 void CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc,
905 bool bCopyPoolIds = true );
907 /** Copy header (with contents) from SrcFormat to DestFormat
908 (can also be copied into other document). */
909 void CopyHeader( const SwFrameFormat& rSrcFormat, SwFrameFormat& rDestFormat )
910 { CopyPageDescHeaderFooterImpl( true, rSrcFormat, rDestFormat ); }
912 /** Copy footer (with contents) from SrcFormat to DestFormat.
913 (can also be copied into other document). */
914 void CopyFooter( const SwFrameFormat& rSrcFormat, SwFrameFormat& rDestFormat )
915 { CopyPageDescHeaderFooterImpl( false, rSrcFormat, rDestFormat ); }
917 // For Reader
918 void ChgPageDesc( const OUString & rName, const SwPageDesc& );
919 void ChgPageDesc( size_t i, const SwPageDesc& );
920 void DelPageDesc( const OUString & rName, bool bBroadcast = false);
921 void DelPageDesc( size_t i, bool bBroadcast = false );
922 void PreDelPageDesc(SwPageDesc const * pDel);
923 SwPageDesc* MakePageDesc(const OUString &rName, const SwPageDesc* pCpy = nullptr,
924 bool bRegardLanguage = true,
925 bool bBroadcast = false);
926 void BroadcastStyleOperation(const OUString& rName, SfxStyleFamily eFamily,
927 SfxHintId nOp);
929 /** The html import sometimes overwrites the page sizes set in
930 the page descriptions. This function is used to correct this. */
931 void CheckDefaultPageFormat();
933 // Methods for tables/indices
934 static sal_uInt16 GetCurTOXMark( const SwPosition& rPos, SwTOXMarks& );
935 void DeleteTOXMark( const SwTOXMark* pTOXMark );
936 const SwTOXMark& GotoTOXMark( const SwTOXMark& rCurTOXMark,
937 SwTOXSearch eDir, bool bInReadOnly );
939 // Insert/Renew table/index
940 SwTOXBaseSection* InsertTableOf( const SwPosition& rPos,
941 const SwTOXBase& rTOX,
942 const SfxItemSet* pSet = nullptr,
943 bool bExpand = false,
944 SwRootFrame const* pLayout = nullptr);
945 SwTOXBaseSection* InsertTableOf( const SwPaM& aPam,
946 const SwTOXBase& rTOX,
947 const SfxItemSet* pSet = nullptr,
948 bool bExpand = false,
949 SwRootFrame const* pLayout = nullptr );
950 void InsertTableOf( SwNodeOffset nSttNd, SwNodeOffset nEndNd,
951 const SwTOXBase& rTOX,
952 const SfxItemSet* pSet );
953 static SwTOXBase* GetCurTOX( const SwPosition& rPos );
954 static const SwAttrSet& GetTOXBaseAttrSet(const SwTOXBase& rTOX);
956 bool DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes );
957 OUString GetUniqueTOXBaseName( const SwTOXType& rType,
958 const OUString& sChkStr ) const;
960 bool SetTOXBaseName(const SwTOXBase& rTOXBase, const OUString& rName);
962 // After reading file update all tables/indices
963 void SetUpdateTOX( bool bFlag ) { mbUpdateTOX = bFlag; }
964 bool IsUpdateTOX() const { return mbUpdateTOX; }
966 const OUString& GetTOIAutoMarkURL() const {return msTOIAutoMarkURL;}
967 void SetTOIAutoMarkURL(const OUString& rSet) {msTOIAutoMarkURL = rSet;}
969 bool IsInReading() const { return mbInReading; }
970 void SetInReading( bool bNew ) { mbInReading = bNew; }
972 bool IsInWriting() const { return mbInWriting; }
973 void SetInWriting(bool bNew) { mbInWriting = bNew; }
975 bool IsInMailMerge() const { return mbInMailMerge; }
976 void SetInMailMerge( bool bNew ) { mbInMailMerge = bNew; }
978 bool IsClipBoard() const { return mbClipBoard; }
979 // N.B.: must be called right after constructor! (@see GetXmlIdRegistry)
980 void SetClipBoard( bool bNew ) { mbClipBoard = bNew; }
982 bool IsColumnSelection() const { return mbColumnSelection; }
983 void SetColumnSelection( bool bNew ) { mbColumnSelection = bNew; }
985 bool IsInXMLImport() const { return mbInXMLImport; }
986 void SetInXMLImport( bool bNew ) { mbInXMLImport = bNew; }
987 bool IsInWriterfilterImport() const { return mbInWriterfilterImport; }
988 void SetInWriterfilterImport(bool const b) { mbInWriterfilterImport = b; }
990 // Manage types of tables/indices
991 sal_uInt16 GetTOXTypeCount( TOXTypes eTyp ) const;
992 const SwTOXType* GetTOXType( TOXTypes eTyp, sal_uInt16 nId ) const;
993 const SwTOXType* InsertTOXType( const SwTOXType& rTyp );
994 const SwTOXTypes& GetTOXTypes() const { return *mpTOXTypes; }
996 const SwTOXBase* GetDefaultTOXBase( TOXTypes eTyp, bool bCreate );
997 void SetDefaultTOXBase(const SwTOXBase& rBase);
999 // Key for management of index.
1000 void GetTOIKeys(SwTOIKeyType eTyp, std::vector<OUString>& rArr,
1001 SwRootFrame const& rLayout) const;
1003 // Sort table text.
1004 bool SortTable(const SwSelBoxes& rBoxes, const SwSortOptions&);
1005 bool SortText(const SwPaM&, const SwSortOptions&);
1007 // Correct the SwPosition-Objects that are registered with the document
1008 // e. g. Bookmarks or tables/indices.
1009 // If bMoveCursor is set move Cursor too.
1011 // Set everything in rOldNode on rNewPos + Offset.
1012 void CorrAbs(
1013 const SwNode& rOldNode,
1014 const SwPosition& rNewPos,
1015 const sal_Int32 nOffset = 0,
1016 bool bMoveCursor = false );
1018 // Set everything in the range of [rStartNode, rEndNode] to rNewPos.
1019 static void CorrAbs(
1020 const SwNodeIndex& rStartNode,
1021 const SwNodeIndex& rEndNode,
1022 const SwPosition& rNewPos,
1023 bool bMoveCursor = false );
1025 // Set everything in this range from rRange to rNewPos.
1026 static void CorrAbs(
1027 const SwPaM& rRange,
1028 const SwPosition& rNewPos,
1029 bool bMoveCursor = false );
1031 // Set everything in rOldNode to relative Pos.
1032 void CorrRel(
1033 const SwNode& rOldNode,
1034 const SwPosition& rNewPos,
1035 const sal_Int32 nOffset = 0,
1036 bool bMoveCursor = false );
1038 // Query / set rules for Outline.
1039 SwNumRule* GetOutlineNumRule() const
1041 return mpOutlineRule;
1043 void SetOutlineNumRule( const SwNumRule& rRule );
1044 void PropagateOutlineRule();
1046 // Outline - promote / demote.
1047 bool OutlineUpDown(const SwPaM& rPam, short nOffset, SwRootFrame const* pLayout = nullptr);
1049 /// Outline - move up / move down.
1050 bool MoveOutlinePara( const SwPaM& rPam, SwOutlineNodes::difference_type nOffset);
1052 bool GotoOutline(SwPosition& rPos, const OUString& rName, SwRootFrame const* = nullptr) const;
1054 /** Accept changes of outline styles for OutlineRule.
1055 @param bResetIndentAttrs Optional parameter - default value false:
1056 If <bResetIndentAttrs> equals true, the indent attributes "before text"
1057 and "first line indent" are additionally reset at the provided PaM, if
1058 the list style makes use of the new list level attributes.
1059 @param bCreateNewList indicates if a new list is created by applying the given list style.
1060 @param sContinuedListId If bCreateNewList is false, may contain the
1061 list Id of a list which has to be continued by applying the given list style
1063 @return the set ListId if bSetItem is true */
1064 OUString SetNumRule( const SwPaM&,
1065 const SwNumRule&,
1066 bool bCreateNewList,
1067 SwRootFrame const* pLayout = nullptr,
1068 const OUString& sContinuedListId = OUString(),
1069 bool bSetItem = true,
1070 const bool bResetIndentAttrs = false );
1071 void SetCounted(const SwPaM&, bool bCounted, SwRootFrame const* pLayout);
1073 void MakeUniqueNumRules(const SwPaM & rPaM);
1075 void SetNumRuleStart( const SwPosition& rPos, bool bFlag = true );
1076 void SetNodeNumStart( const SwPosition& rPos, sal_uInt16 nStt );
1078 // sw_redlinehide: may set rPos to different node (the one with the NumRule)
1079 static SwNumRule* GetNumRuleAtPos(SwPosition& rPos, SwRootFrame const* pLayout = nullptr);
1081 const SwNumRuleTable& GetNumRuleTable() const { return *mpNumRuleTable; }
1084 Add numbering rule to document.
1086 @param pRule rule to add
1088 void AddNumRule(SwNumRule * pRule);
1090 // add optional parameter <eDefaultNumberFormatPositionAndSpaceMode>
1091 sal_uInt16 MakeNumRule( const OUString &rName,
1092 const SwNumRule* pCpy = nullptr,
1093 bool bBroadcast = false,
1094 const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode =
1095 SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
1096 sal_uInt16 FindNumRule( std::u16string_view rName ) const;
1097 SwNumRule* FindNumRulePtr( const OUString& rName ) const;
1099 // Deletion only possible if Rule is not used!
1100 bool RenameNumRule(const OUString & aOldName, const OUString & aNewName,
1101 bool bBroadcast = false);
1102 bool DelNumRule( const OUString& rName, bool bBroadCast = false );
1103 OUString GetUniqueNumRuleName( const OUString* pChkStr = nullptr, bool bAutoNum = true ) const;
1105 void UpdateNumRule(); // Update all invalids.
1106 void ChgNumRuleFormats( const SwNumRule& rRule );
1107 void ReplaceNumRule( const SwPosition& rPos, const OUString& rOldRule,
1108 const OUString& rNewRule );
1110 // Goto next/previous on same level.
1111 static bool GotoNextNum( SwPosition&, SwRootFrame const* pLayout,
1112 bool bOverUpper = true,
1113 sal_uInt8* pUpper = nullptr, sal_uInt8* pLower = nullptr );
1114 static bool GotoPrevNum( SwPosition&, SwRootFrame const* pLayout,
1115 bool bOverUpper = true );
1117 /** Searches for a text node with a numbering rule.
1119 add optional parameter <bInvestigateStartNode>
1120 add output parameter <sListId>
1122 \param rPos position to start search
1123 \param bForward - true: search forward
1124 - false: search backward
1125 \param bNum - true: search for enumeration
1126 - false: search for itemize
1127 \param bOutline - true: search for outline numbering rule
1128 - false: search for non-outline numbering rule
1129 \param nNonEmptyAllowed number of non-empty paragraphs allowed between
1130 rPos and found paragraph
1132 @param sListId
1133 output parameter - in case a list style is found, <sListId> holds the
1134 list id, to which the text node belongs, which applies the found list style.
1136 @param bInvestigateStartNode
1137 input parameter - boolean, indicating, if start node, determined by given
1138 start position has to be investigated or not.
1140 const SwNumRule * SearchNumRule(const SwPosition & rPos,
1141 const bool bForward,
1142 const bool bNum,
1143 const bool bOutline,
1144 int nNonEmptyAllowed,
1145 OUString& sListId,
1146 SwRootFrame const* pLayout,
1147 const bool bInvestigateStartNode = false );
1149 // Paragraphs without numbering but with indents.
1150 bool NoNum( const SwPaM& );
1152 // Delete, splitting of numbering list.
1153 void DelNumRules(const SwPaM&, SwRootFrame const* pLayout = nullptr);
1155 // Invalidates all numrules
1156 void InvalidateNumRules();
1158 bool NumUpDown(const SwPaM&, bool bDown, SwRootFrame const* pLayout = nullptr);
1160 /** Move selected paragraphs (not only numberings)
1161 according to offsets. (if negative: go to doc start). */
1162 bool MoveParagraph(SwPaM&, SwNodeOffset nOffset, bool bIsOutlMv = false);
1163 bool MoveParagraphImpl(SwPaM&, SwNodeOffset nOffset, bool bIsOutlMv, SwRootFrame const*);
1165 bool NumOrNoNum( SwNode& rIdx, bool bDel = false);
1167 void StopNumRuleAnimations( const OutputDevice* );
1169 /** Insert new table at position @param rPos (will be inserted before Node!).
1170 For AutoFormat at input: columns have to be set at predefined width.
1171 The array holds the positions of the columns (not their widths).
1172 new @param bCalledFromShell:
1173 true: called from shell -> propagate existing adjust item at
1174 rPos to every new cell. A existing adjust item in the table
1175 heading or table contents paragraph style prevent that
1176 propagation.
1177 false: do not propagate
1179 const SwTable* InsertTable( const SwInsertTableOptions& rInsTableOpts, // HeadlineNoBorder
1180 const SwPosition& rPos, sal_uInt16 nRows,
1181 sal_uInt16 nCols, sal_Int16 eAdjust,
1182 const SwTableAutoFormat* pTAFormat = nullptr,
1183 const std::vector<sal_uInt16> *pColArr = nullptr,
1184 bool bCalledFromShell = false,
1185 bool bNewModel = true,
1186 const OUString& rTableName = {} );
1188 // If index is in a table, return TableNode, else 0.
1189 static SwTableNode* IsIdxInTable( const SwNodeIndex& rIdx );
1190 static SwTableNode* IsInTable( const SwNode& );
1192 // Create a balanced table out of the selected range.
1193 const SwTable* TextToTable( const SwInsertTableOptions& rInsTableOpts, // HeadlineNoBorder,
1194 const SwPaM& rRange, sal_Unicode cCh,
1195 sal_Int16 eAdjust,
1196 const SwTableAutoFormat* );
1198 // text to table conversion - API support
1199 const SwTable* TextToTable( const std::vector< std::vector<SwNodeRange> >& rTableNodes );
1201 bool TableToText( const SwTableNode* pTableNd, sal_Unicode cCh );
1203 // Create columns / rows in table.
1204 void InsertCol( const SwCursor& rCursor,
1205 sal_uInt16 nCnt = 1, bool bBehind = true );
1206 bool InsertCol( const SwSelBoxes& rBoxes,
1207 sal_uInt16 nCnt = 1, bool bBehind = true, bool bInsertDummy = true );
1208 void InsertRow( const SwCursor& rCursor,
1209 sal_uInt16 nCnt = 1, bool bBehind = true );
1210 bool InsertRow( const SwSelBoxes& rBoxes,
1211 sal_uInt16 nCnt = 1, bool bBehind = true, bool bInsertDummy = true );
1213 // Delete Columns/Rows in table.
1214 enum class RowColMode { DeleteRow = 0, DeleteColumn = 1, DeleteProtected = 2 };
1215 void DelTable(SwTableNode * pTable);
1216 bool DeleteRowCol(const SwSelBoxes& rBoxes, RowColMode eMode = RowColMode::DeleteRow);
1217 void DeleteRow( const SwCursor& rCursor );
1218 void DeleteCol( const SwCursor& rCursor );
1220 // Split / concatenate boxes in table.
1221 bool SplitTable( const SwSelBoxes& rBoxes, bool bVert,
1222 sal_uInt16 nCnt, bool bSameHeight = false );
1224 TableMergeErr MergeTable( SwPaM& rPam );
1225 OUString GetUniqueTableName() const;
1226 bool IsInsTableFormatNum() const;
1227 bool IsInsTableChangeNumFormat() const;
1228 bool IsInsTableAlignNum() const;
1229 bool IsSplitVerticalByDefault() const;
1230 void SetSplitVerticalByDefault(bool value);
1232 // From FEShell (for Undo and BModified).
1233 static void GetTabCols( SwTabCols &rFill, const SwCellFrame* pBoxFrame );
1234 void SetTabCols( const SwTabCols &rNew, bool bCurRowOnly,
1235 const SwCellFrame* pBoxFrame );
1236 static void GetTabRows( SwTabCols &rFill, const SwCellFrame* pBoxFrame );
1237 void SetTabRows( const SwTabCols &rNew, bool bCurColOnly,
1238 const SwCellFrame* pBoxFrame );
1240 // Direct access for UNO.
1241 void SetTabCols(SwTable& rTab, const SwTabCols &rNew, const SwTabCols &rOld,
1242 const SwTableBox *pStart, bool bCurRowOnly);
1244 void SetRowsToRepeat( SwTable &rTable, sal_uInt16 nSet );
1246 /// AutoFormat for table/table selection.
1247 /// @param bResetDirect Reset direct formatting that might be applied to the cells.
1248 bool SetTableAutoFormat(const SwSelBoxes& rBoxes, const SwTableAutoFormat& rNew, bool bResetDirect = false, bool isSetStyleName = false);
1250 // Query attributes.
1251 bool GetTableAutoFormat( const SwSelBoxes& rBoxes, SwTableAutoFormat& rGet );
1253 /// Return the available table styles.
1254 SwTableAutoFormatTable& GetTableStyles();
1255 const SwTableAutoFormatTable& GetTableStyles() const
1257 return const_cast<SwDoc*>(this)->GetTableStyles();
1259 /// Counts table styles without triggering lazy-load of them.
1260 bool HasTableStyles() const { return m_pTableStyles != nullptr; }
1261 // Create a new table style. Tracked by Undo.
1262 SwTableAutoFormat* MakeTableStyle(const OUString& rName, bool bBroadcast = false);
1263 // Delete table style named rName. Tracked by undo.
1264 std::unique_ptr<SwTableAutoFormat> DelTableStyle(const OUString& rName, bool bBroadcast = false);
1265 // Change (replace) a table style named rName. Tracked by undo.
1266 void ChgTableStyle(const OUString& rName, const SwTableAutoFormat& rNewFormat);
1268 const SwCellStyleTable& GetCellStyles() const { return *mpCellStyles; }
1269 SwCellStyleTable& GetCellStyles() { return *mpCellStyles; }
1271 void AppendUndoForInsertFromDB( const SwPaM& rPam, bool bIsTable );
1273 void SetColRowWidthHeight( SwTableBox& rCurrentBox, TableChgWidthHeightType eType,
1274 SwTwips nAbsDiff, SwTwips nRelDiff );
1275 SwTableBoxFormat* MakeTableBoxFormat();
1276 SwTableLineFormat* MakeTableLineFormat();
1278 // helper function: cleanup before checking number value
1279 bool IsNumberFormat( std::u16string_view aString, sal_uInt32& F_Index, double& fOutNumber);
1280 // Check if box has numerical value. Change format of box if required.
1281 void ChkBoxNumFormat( SwTableBox& rCurrentBox, bool bCallUpdate );
1282 void SetTableBoxFormulaAttrs( SwTableBox& rBox, const SfxItemSet& rSet );
1283 void ClearBoxNumAttrs( SwNode& rNode );
1284 void ClearLineNumAttrs( SwPosition const & rPos );
1286 bool InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes,
1287 const SwTable* pCpyTable, bool bCpyName = false,
1288 bool bCorrPos = false, const OUString& rStyleName = "" );
1290 void UnProtectCells( const OUString& rTableName );
1291 bool UnProtectCells( const SwSelBoxes& rBoxes );
1292 void UnProtectTables( const SwPaM& rPam );
1293 bool HasTableAnyProtection( const SwPosition* pPos,
1294 const OUString* pTableName,
1295 bool* pFullTableProtection );
1297 // Split table at baseline position, i.e. create a new table.
1298 void SplitTable( const SwPosition& rPos, SplitTable_HeadlineOption eMode,
1299 bool bCalcNewSize );
1301 /** And vice versa: rPos must be in the table that remains. The flag indicates
1302 whether the current table is merged with the one before or behind it. */
1303 bool MergeTable( const SwPosition& rPos, bool bWithPrev );
1305 // Make charts of given table update.
1306 void UpdateCharts( const OUString& rName ) const;
1308 // Update all charts, for that exists any table.
1309 void UpdateAllCharts() { DoUpdateAllCharts(); }
1311 // Table is renamed and refreshes charts.
1312 void SetTableName( SwFrameFormat& rTableFormat, const OUString &rNewName );
1314 // @return the reference in document that is set for name.
1315 const SwFormatRefMark* GetRefMark( std::u16string_view rName ) const;
1317 // @return RefMark via index - for UNO.
1318 const SwFormatRefMark* GetRefMark( sal_uInt16 nIndex ) const;
1320 /** @return names of all references that are set in document.
1321 If array pointer is 0 return only whether a RefMark is set in document. */
1322 sal_uInt16 GetRefMarks( std::vector<OUString>* = nullptr ) const;
1324 void DeleteFormatRefMark(const SwFormatRefMark* pFormatRefMark);
1326 // Insert label. If a FlyFormat is created, return it.
1327 SwFlyFrameFormat* InsertLabel( const SwLabelType eType, const OUString &rText, const OUString& rSeparator,
1328 const OUString& rNumberingSeparator,
1329 const bool bBefore, const sal_uInt16 nId, const SwNodeOffset nIdx,
1330 const OUString& rCharacterStyle,
1331 const bool bCpyBrd );
1332 SwFlyFrameFormat* InsertDrawLabel(
1333 const OUString &rText, const OUString& rSeparator, const OUString& rNumberSeparator,
1334 const sal_uInt16 nId, const OUString& rCharacterStyle, SdrObject& rObj );
1336 // Query attribute pool.
1337 const SwAttrPool& GetAttrPool() const { return *mpAttrPool; }
1338 SwAttrPool& GetAttrPool() { return *mpAttrPool; }
1340 // Search for an EditShell.
1341 SwEditShell const * GetEditShell() const;
1342 SwEditShell* GetEditShell();
1343 ::sw::IShellCursorSupplier * GetIShellCursorSupplier();
1345 // OLE 2.0-notification.
1346 void SetOle2Link(const Link<bool,void>& rLink) {maOle2Link = rLink;}
1347 const Link<bool,void>& GetOle2Link() const {return maOle2Link;}
1349 // insert section (the ODF kind of section, not the nodesarray kind)
1350 SwSection * InsertSwSection(SwPaM const& rRange, SwSectionData &,
1351 std::tuple<SwTOXBase const*, sw::RedlineMode, sw::FieldmarkMode, sw::ParagraphBreakMode> const* pTOXBase,
1352 SfxItemSet const*const pAttr, bool const bUpdate = true);
1353 static sal_uInt16 IsInsRegionAvailable( const SwPaM& rRange,
1354 const SwNode** ppSttNd = nullptr );
1355 static SwSection* GetCurrSection( const SwPosition& rPos );
1356 SwSectionFormats& GetSections() { return *mpSectionFormatTable; }
1357 const SwSectionFormats& GetSections() const { return *mpSectionFormatTable; }
1358 SwSectionFormat *MakeSectionFormat();
1359 void DelSectionFormat( SwSectionFormat *pFormat, bool bDelNodes = false );
1360 void UpdateSection(size_t const nSect, SwSectionData &,
1361 SfxItemSet const*const = nullptr, bool const bPreventLinkUpdate = false);
1362 OUString GetUniqueSectionName( const OUString* pChkStr = nullptr ) const;
1364 /* @@@MAINTAINABILITY-HORROR@@@
1365 The model should not have anything to do with a shell.
1366 Unnecessary compile/link time dependency.
1369 // Pointer to SfxDocShell from Doc. Can be 0!!
1370 SwDocShell* GetDocShell() { return mpDocShell; }
1371 const SwDocShell* GetDocShell() const { return mpDocShell; }
1372 void SetDocShell( SwDocShell* pDSh );
1374 /** in case during copying of embedded object a new shell is created,
1375 it should be set here and cleaned later */
1376 void SetTmpDocShell( SfxObjectShellLock rLock ) { mxTmpDocShell = rLock; }
1377 const SfxObjectShellLock& GetTmpDocShell() const { return mxTmpDocShell; }
1379 // For Autotexts? (text modules) They have only one SVPersist at their disposal.
1380 SfxObjectShell* GetPersist() const;
1382 // Pointer to storage of SfxDocShells. Can be 0!!!
1383 css::uno::Reference< css::embed::XStorage > GetDocStorage();
1385 // Query / set flag indicating if document is loaded asynchronously at this moment.
1386 bool IsInLoadAsynchron() const { return mbInLoadAsynchron; }
1387 void SetInLoadAsynchron( bool bFlag ) { mbInLoadAsynchron = bFlag; }
1389 // For Drag&Move: (e.g. allow "moving" of RefMarks)
1390 bool IsCopyIsMove() const { return mbCopyIsMove; }
1391 void SetCopyIsMove( bool bFlag ) { mbCopyIsMove = bFlag; }
1393 SwDrawContact* GroupSelection( SdrView& );
1394 void UnGroupSelection( SdrView& );
1395 bool DeleteSelection( SwDrawView& );
1397 // Invalidates OnlineSpell-WrongLists.
1398 void SpellItAgainSam( bool bInvalid, bool bOnlyWrong, bool bSmartTags );
1399 void InvalidateAutoCompleteFlag();
1401 void SetCalcFieldValueHdl(Outliner* pOutliner);
1403 // Query if URL was visited.
1404 // Query via Doc, if only a Bookmark has been given.
1405 // In this case the document name has to be set in front.
1406 bool IsVisitedURL( std::u16string_view rURL );
1408 // Save current values for automatic registration of exceptions in Autocorrection.
1409 void SetAutoCorrExceptWord( std::unique_ptr<SwAutoCorrExceptWord> pNew );
1410 SwAutoCorrExceptWord* GetAutoCorrExceptWord() { return mpACEWord.get(); }
1411 void DeleteAutoCorrExceptWord();
1413 const SwFormatINetFormat* FindINetAttr( std::u16string_view rName ) const;
1415 // Call into intransparent Basic; expect possible Return String.
1416 void ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs );
1418 // Call into intransparent Basic / JavaScript.
1419 sal_uInt16 CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCallEvent,
1420 bool bChkPtr = false );
1422 /** Adjust left margin via object bar (similar to adjustment of numerations).
1423 One can either change the margin "by" adding or subtracting a given
1424 offset or set it "to" this position (bModulus = true). */
1425 void MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus,
1426 SwRootFrame const* pLayout = nullptr);
1428 // Query NumberFormatter.
1429 SvNumberFormatter* GetNumberFormatter(bool bCreate = true)
1431 std::scoped_lock lock(mNumberFormatterMutex);
1432 if (bCreate)
1433 EnsureNumberFormatter();
1434 return mpNumberFormatter;
1437 const SvNumberFormatter* GetNumberFormatter(bool bCreate = true) const
1439 return const_cast<SwDoc*>(this)->GetNumberFormatter(bCreate);
1442 bool HasInvisibleContent() const;
1443 // delete invisible content, like hidden sections and paragraphs
1444 bool RemoveInvisibleContent();
1445 // restore the invisible content if it's available on the undo stack
1446 bool RestoreInvisibleContent();
1448 // Replace fields by text - mailmerge support
1449 SAL_DLLPRIVATE bool ConvertFieldsToText(SwRootFrame const& rLayout);
1451 // Create sub-documents according to given collection.
1452 // If no collection is given, use chapter styles for 1st level.
1453 bool GenerateGlobalDoc( const OUString& rPath,
1454 const SwTextFormatColl* pSplitColl );
1455 bool GenerateGlobalDoc( const OUString& rPath, int nOutlineLevel );
1456 bool GenerateHTMLDoc( const OUString& rPath,
1457 const SwTextFormatColl* pSplitColl );
1458 bool GenerateHTMLDoc( const OUString& rPath, int nOutlineLevel );
1460 // Compare two documents.
1461 tools::Long CompareDoc( const SwDoc& rDoc );
1463 // Merge two documents.
1464 tools::Long MergeDoc( const SwDoc& rDoc );
1466 bool IsAutoFormatRedline() const { return mbIsAutoFormatRedline; }
1467 void SetAutoFormatRedline( bool bFlag ) { mbIsAutoFormatRedline = bFlag; }
1469 // For AutoFormat: with Undo/Redlining.
1470 void SetTextFormatCollByAutoFormat( const SwPosition& rPos, sal_uInt16 nPoolId,
1471 const SfxItemSet* pSet );
1472 void SetFormatItemByAutoFormat( const SwPaM& rPam, const SfxItemSet& );
1474 // Only for SW-textbloxks! Does not pay any attention to layout!
1475 void ClearDoc(); // Deletes all content!
1477 // Query /set data for PagePreview.
1478 const SwPagePreviewPrtData* GetPreviewPrtData() const { return m_pPgPViewPrtData.get(); }
1480 // If pointer == 0 destroy pointer in document.
1481 // Else copy object.
1482 // Pointer is not transferred to ownership by document!
1483 void SetPreviewPrtData( const SwPagePreviewPrtData* pData );
1485 /** update all modified OLE-Objects. The modification is called over the
1486 StarOne - Interface */
1487 void SetOLEObjModified();
1489 // Uno - Interfaces
1490 std::shared_ptr<SwUnoCursor> CreateUnoCursor( const SwPosition& rPos, bool bTableCursor = false );
1492 // FeShell - Interfaces
1493 // !!! These assume always an existing layout !!!
1494 bool ChgAnchor( const SdrMarkList& _rMrkList,
1495 RndStdIds _eAnchorType,
1496 const bool _bSameOnly,
1497 const bool _bPosCorr );
1499 void SetRowHeight( const SwCursor& rCursor, const SwFormatFrameSize &rNew );
1500 static std::unique_ptr<SwFormatFrameSize> GetRowHeight( const SwCursor& rCursor );
1501 void SetRowSplit( const SwCursor& rCursor, const SwFormatRowSplit &rNew );
1502 static std::unique_ptr<SwFormatRowSplit> GetRowSplit( const SwCursor& rCursor );
1504 /// Adjustment of Rowheights. Determine via bTstOnly if more than one row is selected.
1505 /// bOptimize: distribute current table height, instead of using the largest row.
1506 /// Call again without bOptimize to ensure equal height in case some row's content didn't fit.
1507 bool BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly, const bool bOptimize );
1508 void SetRowBackground( const SwCursor& rCursor, const SvxBrushItem &rNew );
1509 static bool GetRowBackground( const SwCursor& rCursor, std::unique_ptr<SvxBrushItem>& rToFill );
1510 /// rNotTracked = false means that the row was deleted or inserted with its tracked cell content
1511 /// bAll: delete all table rows without selection
1512 /// bIns: insert table row
1513 void SetRowNotTracked( const SwCursor& rCursor,
1514 const SvxPrintItem &rNotTracked, bool bAll = false, bool bIns = false );
1515 /// don't call SetRowNotTracked() for rows with tracked row change
1516 static bool HasRowNotTracked( const SwCursor& rCursor );
1517 void SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet );
1518 void SetTabLineStyle( const SwCursor& rCursor,
1519 const Color* pColor, bool bSetLine,
1520 const editeng::SvxBorderLine* pBorderLine );
1521 static void GetTabBorders( const SwCursor& rCursor, SfxItemSet& rSet );
1522 void SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew );
1524 Retrieves a box attribute from the given cursor.
1526 @return Whether the property is set over the current box selection.
1528 @remarks A property is 'set' if it's set to the same value over all boxes in the current selection.
1529 The property value is retrieved from the first box in the current selection. It is then compared to
1530 the values of the same property over any other boxes in the selection; if any value is different from
1531 that of the first box, the property is unset (and false is returned).
1533 static bool GetBoxAttr( const SwCursor& rCursor, std::unique_ptr<SfxPoolItem>& rToFill );
1534 void SetBoxAlign( const SwCursor& rCursor, sal_uInt16 nAlign );
1535 static sal_uInt16 GetBoxAlign( const SwCursor& rCursor );
1536 /// Adjusts selected cell widths in such a way, that their content does not need to be wrapped (if possible).
1537 /// bBalance evenly re-distributes the available space regardless of content or wrapping.
1538 /// bNoShrink keeps table size the same by distributing excess space proportionately.
1539 void AdjustCellWidth( const SwCursor& rCursor, const bool bBalance, const bool bNoShrink );
1541 SwChainRet Chainable( const SwFrameFormat &rSource, const SwFrameFormat &rDest );
1542 SwChainRet Chain( SwFrameFormat &rSource, const SwFrameFormat &rDest );
1543 void Unchain( SwFrameFormat &rFormat );
1545 // For Copy/Move from FrameShell.
1546 rtl::Reference<SdrObject> CloneSdrObj( const SdrObject&, bool bMoveWithinDoc = false,
1547 bool bInsInPage = true );
1549 // FeShell - Interface end
1551 // Interface for TextInputData - for text input of Chinese and Japanese.
1552 SwExtTextInput* CreateExtTextInput( const SwPaM& rPam );
1553 void DeleteExtTextInput( SwExtTextInput* pDel );
1554 SwExtTextInput* GetExtTextInput( const SwNode& rNd,
1555 sal_Int32 nContentPos = -1) const;
1556 SwExtTextInput* GetExtTextInput() const;
1558 // Interface for access to AutoComplete-List.
1559 static SwAutoCompleteWord& GetAutoCompleteWords() { return *s_pAutoCompleteWords; }
1561 bool ContainsMSVBasic() const { return mbContains_MSVBasic; }
1562 void SetContainsMSVBasic( bool bFlag ) { mbContains_MSVBasic = bFlag; }
1564 // Interface for the list of Ruby - texts/attributes
1565 static sal_uInt16 FillRubyList( const SwPaM& rPam, SwRubyList& rList );
1566 void SetRubyList( const SwPaM& rPam, const SwRubyList& rList );
1568 void ReadLayoutCache( SvStream& rStream );
1569 void WriteLayoutCache( SvStream& rStream );
1570 SwLayoutCache* GetLayoutCache() const { return mpLayoutCache.get(); }
1572 /** Checks if any of the text node contains hidden characters.
1573 Used for optimization. Changing the view option 'view hidden text'
1574 has to trigger a reformatting only if some of the text is hidden.
1576 bool ContainsHiddenChars() const;
1578 std::unique_ptr<sw::GrammarContact> const& getGrammarContact() const { return mpGrammarContact; }
1579 std::unique_ptr<sw::OnlineAccessibilityCheck> const& getOnlineAccessibilityCheck() const
1581 return mpOnlineAccessibilityCheck;
1584 /** Marks/Unmarks a list level of a certain list
1586 levels of a certain lists are marked now
1588 @param sListId list Id of the list whose level has to be marked/unmarked
1589 @param nListLevel level to mark
1590 @param bValue - true mark the level
1591 - false unmark the level
1593 void MarkListLevel( const OUString& sListId,
1594 const int nListLevel,
1595 const bool bValue );
1597 // Change a format undoable.
1598 void ChgFormat(SwFormat & rFormat, const SfxItemSet & rSet);
1600 void RenameFormat(SwFormat & rFormat, const OUString & sNewName,
1601 bool bBroadcast = false);
1603 // Change a TOX undoable.
1604 void ChangeTOX(SwTOXBase & rTOX, const SwTOXBase & rNew);
1607 Returns a textual description of a PaM.
1609 @param rPaM the PaM to describe
1611 If rPaM only spans one paragraph the result is:
1613 '<text in the PaM>'
1615 <text in the PaM> is shortened to nUndoStringLength characters.
1617 If rPaM spans more than one paragraph the result is:
1619 paragraphs (STR_PARAGRAPHS)
1621 @return the textual description of rPaM
1623 static OUString GetPaMDescr(const SwPaM & rPaM);
1625 static bool IsFirstOfNumRuleAtPos(const SwPosition & rPos, SwRootFrame const& rLayout);
1627 // access methods for XForms model(s)
1629 // access container for XForms model; will be NULL if !isXForms()
1630 const css::uno::Reference<css::container::XNameContainer>&
1631 getXForms() const { return mxXForms;}
1633 css::uno::Reference< css::linguistic2::XProofreadingIterator > const & GetGCIterator() const;
1635 // #i31958# is this an XForms document?
1636 bool isXForms() const;
1638 // #i31958# initialize XForms models; turn this into an XForms document
1639 void initXForms( bool bCreateDefaultModel );
1641 // #i113606# for disposing XForms
1642 void disposeXForms( );
1644 //Update all the page masters
1645 void SetDefaultPageMode(bool bSquaredPageMode);
1646 bool IsSquaredPageMode() const;
1648 const css::uno::Reference< ooo::vba::word::XFind >& getVbaFind() const { return mxVbaFind; }
1649 void setVbaFind( const css::uno::Reference< ooo::vba::word::XFind > &xFind) { mxVbaFind = xFind; }
1650 css::uno::Reference< css::script::vba::XVBAEventProcessor > const & GetVbaEventProcessor();
1651 void SetVbaEventProcessor();
1652 void SetVBATemplateToProjectCache( css::uno::Reference< css::container::XNameContainer > const & xCache ) { m_xTemplateToProjectCache = xCache; };
1653 const css::uno::Reference< css::container::XNameContainer >& GetVBATemplateToProjectCache() const { return m_xTemplateToProjectCache; };
1654 ::sfx2::IXmlIdRegistry& GetXmlIdRegistry();
1655 ::sw::MetaFieldManager & GetMetaFieldManager();
1656 ::SwContentControlManager& GetContentControlManager();
1657 ::sw::UndoManager & GetUndoManager();
1658 ::sw::UndoManager const& GetUndoManager() const;
1660 SfxObjectShell* CreateCopy(bool bCallInitNew, bool bEmpty) const;
1661 SwNodeIndex AppendDoc(const SwDoc& rSource, sal_uInt16 nStartPageNumber,
1662 bool bDeletePrevious, int physicalPageOffset,
1663 const sal_uLong nDocNo);
1666 * Dumps the entire nodes structure to the given destination (file nodes.xml in the current directory by default)
1668 void dumpAsXml(xmlTextWriterPtr = nullptr) const;
1670 std::set<Color> GetDocColors();
1671 std::vector< std::weak_ptr<SwUnoCursor> > mvUnoCursorTable;
1673 // Remove expired UnoCursor weak pointers the document keeps to notify about document death.
1674 void cleanupUnoCursorTable() const
1676 auto & rTable = const_cast<SwDoc*>(this)->mvUnoCursorTable;
1677 // In most cases we'll remove most of the elements.
1678 rTable.erase( std::remove_if(rTable.begin(),
1679 rTable.end(),
1680 [] (std::weak_ptr<SwUnoCursor> const & x) { return x.expired(); }),
1681 rTable.end());
1685 * @param bSkipStart don't actually start the jobs, just check
1686 * @returns true if new background checking jobs were started
1688 bool StartGrammarChecking( bool bSkipStart = false );
1690 /// Use to notify if the dictionary can be found for a single content portion (has to be called for all portions)
1691 void SetMissingDictionaries( bool bIsMissing );
1692 /// Returns true if no dictionary can be found for any content
1693 bool IsDictionaryMissing() const { return meDictionaryMissing == MissingDictionary::True; }
1695 void SetLanguage(const LanguageType eLang, const sal_uInt16 nId);
1697 static bool HasParagraphDirectFormatting(const SwPosition& rPos);
1699 private:
1700 // Copies master header to left / first one, if necessary - used by ChgPageDesc().
1701 void CopyMasterHeader(const SwPageDesc &rChged, const SwFormatHeader &rHead, SwPageDesc &pDesc, bool bLeft, bool bFirst);
1702 // Copies master footer to left / first one, if necessary - used by ChgPageDesc().
1703 void CopyMasterFooter(const SwPageDesc &rChged, const SwFormatFooter &rFoot, SwPageDesc &pDesc, bool bLeft, bool bFirst);
1707 namespace o3tl {
1708 template<> struct typed_flags<SwDoc::RowColMode> : is_typed_flags<SwDoc::RowColMode, 3> {};
1711 // This method is called in Dtor of SwDoc and deletes cache of ContourObjects.
1712 void ClrContourCache();
1714 inline void SwDoc::SetOLEPrtNotifyPending( bool bSet )
1716 mbOLEPrtNotifyPending = bSet;
1717 if( !bSet )
1718 mbAllOLENotify = false;
1721 bool sw_GetPostIts(const IDocumentFieldsAccess& rIDFA, SetGetExpFields * pSrtLst);
1723 #endif //_DOC_HXX
1725 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */