android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / inc / editsh.hxx
blob3813c33a62415054866f17c55d66a13f7d3f5fb3
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_EDITSH_HXX
20 #define INCLUDED_SW_INC_EDITSH_HXX
22 #include "crsrsh.hxx"
24 #include "charfmt.hxx"
25 #include "fldupde.hxx"
26 #include "frmfmt.hxx"
27 #include "swdllapi.h"
28 #include "swundo.hxx"
29 #include "tblenum.hxx"
30 #include "tox.hxx"
32 #include <memory>
33 #include <utility>
34 #include <vector>
35 #include <o3tl/sorted_vector.hxx>
37 namespace tools { class PolyPolygon; }
38 class SwDoc;
39 class CommandExtTextInputData;
41 class SvNumberFormatter;
42 class SfxPoolItem;
43 class SfxItemSet;
44 class SfxWatermarkItem;
45 class SvxAutoCorrect;
47 class SwDDEFieldType;
48 class SwDBManager;
50 struct SwDocStat;
51 class SwAutoCompleteWord;
53 class SwFormatRefMark;
55 class SwNumRule;
57 class SwTextFormatColl;
58 class SwGrfNode;
60 class Graphic;
61 class GraphicObject;
62 class GraphicAttr;
63 class SwFormatINetFormat;
64 class SwTable;
65 class SwTextBlocks;
66 class SwFormatFootnote;
67 class SwSection;
68 class SwSectionData;
69 class SwSectionFormat;
70 class SwTableAutoFormat;
71 class SwPageDesc;
72 class SwTextINetFormat;
73 class SwSeqFieldList;
74 class SwGlblDocContent;
75 class SwGlblDocContents;
76 class SwRangeRedline;
77 class SwRedlineData;
78 class SwFootnoteInfo;
79 class SwEndNoteInfo;
80 class SwLineNumberInfo;
81 class SwAuthEntry;
82 class SwRewriter;
83 class SwView;
84 class SwWrtShell;
85 struct SwConversionArgs;
86 struct SvxSwAutoFormatFlags;
87 struct SwInsertTableOptions;
88 struct SwDBData;
89 enum class SvtScriptType : sal_uInt8;
90 enum class SfxClassificationPolicyType;
91 enum class RedlineFlags;
92 enum class TransliterationFlags;
93 enum class GraphicType;
95 namespace com::sun::star::uno { template < class > class Sequence; }
96 namespace com::sun::star::linguistic2 { class XSpellAlternatives; }
97 namespace com::sun::star::linguistic2 { struct ProofreadingResult; }
99 namespace svx{
100 struct SpellPortion;
101 typedef std::vector<SpellPortion> SpellPortions;
102 class ClassificationResult;
105 namespace sfx2{
106 class LinkManager;
109 namespace sw {
110 class UndoRedoContext;
113 enum class ParaBreakType {
114 ToBlank = 0,
115 ToOnlyCR = 2
118 /// For querying the INet-attributes for Navigator.
119 struct SwGetINetAttr
121 OUString sText;
122 const SwTextINetFormat& rINetAttr;
124 SwGetINetAttr( OUString aText, const SwTextINetFormat& rAttr )
125 : sText(std::move( aText )), rINetAttr( rAttr )
128 typedef std::vector<SwGetINetAttr> SwGetINetAttrs;
130 // Types of forms of content.
131 #define CNT_TXT 0x0001
132 #define CNT_GRF 0x0002
133 #define CNT_OLE 0x0010
135 // Test USHORT for a defined form of content.
136 #define CNT_HasText(USH) ((USH)&CNT_TXT)
137 #define CNT_HasGrf(USH) ((USH)&CNT_GRF)
138 #define CNT_HasOLE(USH) ((USH)&CNT_OLE)
140 class SW_DLLPUBLIC SwEditShell : public SwCursorShell
142 static SvxSwAutoFormatFlags* s_pAutoFormatFlags;
144 /// For the private methods DelRange and those of AutoCorrect.
145 friend class SwAutoFormat;
146 friend void InitCore();
147 friend void FinitCore();
148 /// For the PamCorrAbs/-Rel methods.
149 friend class SwUndo;
151 /** Returns pointer to a SwGrfNode
152 that will be used by GetGraphic() and GetGraphicSize(). */
153 SAL_DLLPRIVATE SwGrfNode *GetGrfNode_() const ;
155 SAL_DLLPRIVATE void DeleteSel(SwPaM& rPam, bool isArtificialSelection, bool* pUndo = nullptr);
157 SAL_DLLPRIVATE void SetSectionAttr_( SwSectionFormat& rSectFormat, const SfxItemSet& rSet );
159 using SwViewShell::UpdateFields;
160 using sw::BroadcastingModify::GetInfo;
162 public:
163 /// Edit (all selected ranges).
164 void Insert( sal_Unicode, bool bOnlyCurrCursor = false );
165 void Insert2( const OUString &, const bool bForceExpandHints = false );
166 void Overwrite( const OUString & );
168 /** Replace a selected range in a TextNode by given string.
169 Meant for Search & Replace.
170 bRegExpRplc - replace tabs (\\t) and insert found string (not \&).
171 E.g.: Fnd: "zzz", Repl: "xx\t\\t..&..\&"
172 --> "xx\t<Tab>..zzz..&" */
173 bool Replace( const OUString& rNewStr, bool bRegExpRplc );
175 /** Delete content of all ranges.
176 If whole nodes are selected, these nodes get deleted. */
177 bool Delete(bool isArtificialSelection = false);
179 /// Remove a complete paragraph.
180 bool DelFullPara();
182 /// Change text to Upper/Lower/Hiragana/Katakana/...
183 void TransliterateText( TransliterationFlags nType );
185 /// Count words in current selection.
186 void CountWords( SwDocStat& rStat ) const;
188 /// Replace fields by text - mailmerge support.
189 SAL_DLLPRIVATE bool ConvertFieldsToText();
191 /// Set all numbering start points to a fixed value - mailmerge support.
192 void SetNumberingRestart();
194 /// Embeds all local links (ranges/graphics).
195 sal_uInt16 GetLinkUpdMode() const;
196 void SetLinkUpdMode( sal_uInt16 nMode );
198 /// Copy content of all ranges at current position of cursor to given Shell.
199 bool Copy( SwEditShell& rDestShell );
201 /** For copying via ClipBoard:
202 If table is copied into table, move all cursors away from it.
203 Copy and Paste must be in FEShell because of FlyFrames!
204 Copy all selections to the document. */
205 bool CopySelToDoc( SwDoc& rInsDoc );
207 void SplitNode( bool bAutoFormat = false, bool bCheckTableStart = true );
208 bool AppendTextNode();
209 void AutoFormatBySplitNode();
211 /** If cursor is in an INetAttribute it will be deleted completely
212 including the descriptive text (needed at drag & drop). */
213 void DelINetAttrWithText();
215 /** If Cursor is at the end of a character style in which the DontExpand-flag
216 is not yet set, the latter will be set (==> return TRUE). */
217 bool DontExpandFormat();
219 /** Apply / remove attributes.
220 @return attributes in required AttributeSet.
221 When not unambiguous the set has a DONT_CARE !!
222 2nd optional parameter <bMergeIndentValuesOfNumRule>.
223 If <bMergeIndentValuesOfNumRule> == true, the indent attributes of
224 the corresponding list level of an applied list style is merged into
225 the requested item set as a LR-SPACE item, if corresponding node has not
226 its own indent attributes and the position-and-space mode of the list
227 level is SvxNumberFormat::LABEL_ALIGNMENT. */
228 bool GetPaMAttr( SwPaM* pPaM, SfxItemSet& ,
229 const bool bMergeIndentValuesOfNumRule = false ) const;
230 bool GetCurAttr( SfxItemSet& ,
231 const bool bMergeIndentValuesOfNumRule = false ) const;
232 void SetAttrItem( const SfxPoolItem&, SetAttrMode nFlags = SetAttrMode::DEFAULT,
233 const bool bParagraphSetting = false );
234 void SetAttrSet( const SfxItemSet&, SetAttrMode nFlags = SetAttrMode::DEFAULT,
235 SwPaM* pCursor = nullptr, const bool bParagraphSetting = false );
237 /** Get RES_CHRATR_* items of one type in the current selection.
238 * @param nWhich WhichId of the collected items.
239 * If parts of the selection have different scripttypes, the items with corresponding WhichIds are also collected.
240 * @return a vector of pairs. The pair contains a SfxPoolItem and a SwPaM, in which the item is valid and can be changed. */
241 std::vector<std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM>>> GetItemWithPaM( sal_uInt16 nWhich );
244 * Get the paragraph format attribute(s) of the current selection.
246 * @see GetPaMParAttr()
248 * @param rSet
249 * output parameter - the SfxItemSet where the automatic paragraph format attribute(s) will be store.
250 * The attributes aren't invalidated or cleared if the function reach the getMaxLookup limit.
252 void GetCurParAttr( SfxItemSet& rSet ) const;
254 * Get the paragraph format attribute(s) of the selection(s) described by a SwPaM.
256 * @param pPaM
257 * input parameter - the selection where to look for the paragraph format.
259 * @param rSet
260 * output parameter - the SfxItemSet where the automatic paragraph format attribute(s) will be store.
261 * The attributes aren't invalidated or cleared if the function reaches the getMaxLookup limit.
263 void GetPaMParAttr( SwPaM* pPaM, SfxItemSet& rSet ) const;
265 /// Set attribute as new default attribute in document.
266 void SetDefault( const SfxPoolItem& );
268 /// Query default attribute of document.
269 const SfxPoolItem& GetDefault( sal_uInt16 nFormatHint ) const;
270 template<class T> const T& GetDefault( TypedWhichId<T> nWhich ) const
272 return static_cast<const T&>(GetDefault(sal_uInt16(nWhich)));
275 void ResetAttr( const o3tl::sorted_vector<sal_uInt16> &attrs = o3tl::sorted_vector<sal_uInt16>(), SwPaM* pCursor = nullptr );
276 void GCAttr();
278 /// @return the scripttype of the selection.
279 SvtScriptType GetScriptType() const;
281 /// @return the language at current cursor position.
282 LanguageType GetCurLang() const;
284 /// TABLE
285 size_t GetTableFrameFormatCount( bool bUsed = false ) const;
286 SwFrameFormat& GetTableFrameFormat(size_t nFormat, bool bUsed = false ) const;
287 OUString GetUniqueTableName() const;
289 /// CHAR
290 sal_uInt16 GetCharFormatCount() const;
291 SwCharFormat& GetCharFormat(sal_uInt16 nFormat) const;
292 SwCharFormat* GetCurCharFormat() const;
293 void FillByEx(SwCharFormat*);
294 SwCharFormat* MakeCharFormat( const OUString& rName );
295 SwCharFormat* FindCharFormatByName( const OUString& rName ) const;
297 /* FormatCollections (new) - Explaining the general naming pattern:
298 * GetXXXCount() returns the count of xxx in the document.
299 * GetXXX(i) returns i-th xxx (ERR_RAISE if beyond range!).
300 * DelXXX(i) deletes i-th xxx (ERR_RAISE if beyond range!).
301 * GetCurXXX() returns xxx that is valid at cursor or in ranges.
302 * returns 0, if not unanimous.
303 * SetXXX() sets xxx at cursor or in ranges.
304 * MakeXXX() makes a xxx, derived from pDerivedFrom.
307 // TXT
308 SwTextFormatColl& GetDfltTextFormatColl() const;
309 sal_uInt16 GetTextFormatCollCount() const;
310 SwTextFormatColl& GetTextFormatColl( sal_uInt16 nTextFormatColl) const;
312 * Get the named paragraph format of the current selection.
314 * @see GetPaMTextFormatColl()
316 * @return the named paragraph format of the first node that contains one.
317 * Nodes are sort by order of appearance in the selections ;
318 * selections are sort by their order of creation
319 * (last created selection first, oldest selection at last).
321 SwTextFormatColl* GetCurTextFormatColl() const;
323 * Get the named paragraph format of the selection(s) described by a SwPaM.
325 * @param pPaM
326 * input parameter - the selection where to look for the paragraph format.
328 * @return the named paragraph format of the first node that contains one.
330 SwTextFormatColl* GetPaMTextFormatColl( SwPaM* pPaM ) const;
332 // #i62675#
333 /// Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTextFormatColl(..)>
334 void SetTextFormatColl(SwTextFormatColl*, const bool bResetListAttrs = false);
335 SwTextFormatColl *MakeTextFormatColl(const OUString &rFormatCollName,
336 SwTextFormatColl *pDerivedFrom = nullptr);
337 void FillByEx(SwTextFormatColl*);
338 SwTextFormatColl* FindTextFormatCollByName( const OUString& rName ) const;
340 /// @return "Auto-Collection" with given Id. If it does not exist create it.
341 SwTextFormatColl* GetTextCollFromPool( sal_uInt16 nId );
343 /// @return required automatic format base class.
344 SwFormat* GetFormatFromPool( sal_uInt16 nId );
346 /// @return required automatic page style.
347 SwPageDesc* GetPageDescFromPool( sal_uInt16 nId );
349 /// Query if the paragraph-/character-/frame-/page-style is used.
350 bool IsUsed( const sw::BroadcastingModify& ) const;
352 /// @return required automatic format.
353 SwFrameFormat* GetFrameFormatFromPool( sal_uInt16 nId )
354 { return static_cast<SwFrameFormat*>(SwEditShell::GetFormatFromPool( nId )); }
355 SwCharFormat* GetCharFormatFromPool( sal_uInt16 nId )
356 { return static_cast<SwCharFormat*>(SwEditShell::GetFormatFromPool( nId )); }
358 void SetClassification(const OUString& rName, SfxClassificationPolicyType eType);
359 void ApplyAdvancedClassification(std::vector<svx::ClassificationResult> const & rResult);
360 std::vector<svx::ClassificationResult> CollectAdvancedClassification();
362 SfxWatermarkItem GetWatermark() const;
363 void SetWatermark(const SfxWatermarkItem& rText);
365 /// Sign the paragraph at the cursor.
366 void SignParagraph();
368 /// Validate the paragraph signatures, if any, of the current text node.
369 void ValidateParagraphSignatures(SwTextNode* pNode, bool updateDontRemove);
371 /// Validate the current paragraph signatures, if any, at the cursor start.
372 void ValidateCurrentParagraphSignatures(bool updateDontRemove);
374 /// Validate all paragraph signatures.
375 void ValidateAllParagraphSignatures(bool updateDontRemove);
377 /// Restore the metadata fields, if missing, from the RDF metadata
378 /// and validate the signatures and update the signature metadata fields.
379 /// Needed since deleting the metadata field doesn't remove the RDF
380 /// and editing docs using software that don't support paragraph signing.
381 void RestoreMetadataFieldsAndValidateParagraphSignatures();
383 /// Ensure that the classification of the doc is never lower than
384 /// the paragraph with the highest classification.
385 void ClassifyDocPerHighestParagraphClass();
387 /// Apply the classification to the paragraph at cursor.
388 void ApplyParagraphClassification(std::vector<svx::ClassificationResult> aResult);
389 std::vector<svx::ClassificationResult> CollectParagraphClassification();
391 /// Returns true iff the cursor is within a paragraph metadata field.
392 /// Currently there are two variants: signature and classification.
393 bool IsCursorInParagraphMetadataField() const;
395 /// Removes the paragraph metadata field at the current cursor, if any.
396 /// Returns true iff a paragraph metadata field was removed.
397 /// Currently there are two variants: signature and classification.
398 bool RemoveParagraphMetadataFieldAtCursor();
400 bool InsertField(SwField const &, const bool bForceExpandHints);
402 void UpdateOneField(SwField &); ///< One single field.
404 size_t GetFieldTypeCount(SwFieldIds nResId = SwFieldIds::Unknown) const;
405 SwFieldType* GetFieldType(size_t nField, SwFieldIds nResId = SwFieldIds::Unknown) const;
406 SwFieldType* GetFieldType(SwFieldIds nResId, const OUString& rName) const;
408 void RemoveFieldType(size_t nField);
409 void RemoveFieldType(SwFieldIds nResId, const OUString& rName);
411 void FieldToText( SwFieldType const * pType );
413 void ChangeAuthorityData(const SwAuthEntry* pNewData);
415 /// Database information.
416 SwDBData const & GetDBData() const;
417 void ChgDBData(const SwDBData& SwDBData);
418 void ChangeDBFields( const std::vector<OUString>& rOldNames,
419 const OUString& rNewName );
420 void GetAllUsedDB( std::vector<OUString>& rDBNameList,
421 std::vector<OUString> const * pAllDBNames );
423 bool IsAnyDatabaseFieldInDoc()const;
425 /// Check whether DB fields point to an available data source and returns it.
426 bool IsFieldDataSourceAvailable(OUString& rUsedDataSource) const;
427 void UpdateExpFields(bool bCloseDB = false);///< only every expression fields update
428 void LockExpFields();
429 void UnlockExpFields();
430 bool IsExpFieldsLocked() const;
432 SwFieldUpdateFlags GetFieldUpdateFlags() const;
433 void SetFieldUpdateFlags( SwFieldUpdateFlags eFlags );
435 /// For evaluation of DB fields (new DB-manager).
436 SwDBManager* GetDBManager() const;
438 SwFieldType* InsertFieldType(const SwFieldType &);
440 /// Changes in document?
441 bool IsModified() const;
442 void SetModified();
443 void ResetModified();
444 void SetUndoNoResetModified();
446 /// Document - Statistics
447 void UpdateDocStat();
448 const SwDocStat &GetUpdatedDocStat();
450 void Insert(const SwTOXMark& rMark);
452 void DeleteTOXMark(SwTOXMark const * pMark);
454 /// Get all marks at current SPoint.
455 void GetCurTOXMarks(SwTOXMarks& rMarks) const ;
457 /// Insert content table. Renew if required.
458 void InsertTableOf(const SwTOXBase& rTOX,
459 const SfxItemSet* pSet = nullptr);
460 void UpdateTableOf(const SwTOXBase& rTOX,
461 const SfxItemSet* pSet = nullptr);
462 const SwTOXBase* GetCurTOX() const;
463 const SwTOXBase* GetDefaultTOXBase( TOXTypes eTyp, bool bCreate = false );
464 void SetDefaultTOXBase(const SwTOXBase& rBase);
466 static bool IsTOXBaseReadonly(const SwTOXBase& rTOXBase);
467 void SetTOXBaseReadonly(const SwTOXBase& rTOXBase, bool bReadonly);
469 sal_uInt16 GetTOXCount() const;
470 const SwTOXBase* GetTOX( sal_uInt16 nPos ) const;
471 bool DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes );
473 /// After reading file update all content tables.
474 void SetUpdateTOX( bool bFlag );
475 bool IsUpdateTOX() const;
477 /// Manage types of content tables.
478 sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const;
479 const SwTOXType* GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const;
480 void InsertTOXType(const SwTOXType& rTyp);
482 /// AutoMark file
483 OUString const & GetTOIAutoMarkURL() const;
484 void SetTOIAutoMarkURL(const OUString& rSet);
485 void ApplyAutoMark();
487 /// Key for managing index.
488 void GetTOIKeys( SwTOIKeyType eTyp, std::vector<OUString>& rArr ) const;
490 void SetOutlineNumRule(const SwNumRule&);
491 const SwNumRule* GetOutlineNumRule() const;
493 bool OutlineUpDown( short nOffset = 1 );
495 bool MoveOutlinePara( SwOutlineNodes::difference_type nOffset );
497 bool IsProtectedOutlinePara() const;
499 const SwNumRule* GetNumRuleAtCurrCursorPos() const;
501 /** Returns the numbering rule found at the paragraphs of the current selection,
502 if all paragraphs of the current selection have the same or none numbering rule applied. */
503 const SwNumRule* GetNumRuleAtCurrentSelection() const;
505 /** Optional parameter <bResetIndentAttrs> (default value false).
506 If <bResetIndentAttrs> equals true, the indent attributes "before text"
507 and "first line indent" are additionally reset at the current selection,
508 if the list style makes use of the new list level attributes.
509 Parameters <bCreateNewList> and <sContinuedListId>
510 <bCreateNewList> indicates, if a new list is created by applying the given list style.
511 If <bCreateNewList> equals false, <sContinuedListId> may contain the
512 list Id of a list, which has to be continued by applying the given list style */
513 void SetCurNumRule( const SwNumRule&,
514 const bool bCreateNewList /*= false*/,
515 const OUString& sContinuedListId = OUString(),
516 const bool bResetIndentAttrs = false );
518 /// Paragraphs without enumeration but with indents.
519 void NoNum();
521 /// Delete, split enumeration list.
522 void DelNumRules();
524 void NumUpDown( bool bDown = true );
526 bool MoveParagraph( SwNodeOffset nOffset = SwNodeOffset(1));
527 bool MoveNumParas( bool bUpperLower, bool bUpperLeft );
529 /// Switch on/off of numbering via Delete/Backspace.
530 bool NumOrNoNum(bool bDelete = false, bool bChkStart = true);
532 // #i23726#
533 // #i90078#
534 /// Remove unused default parameter <nLevel> and <bRelative>.
535 // Adjust method name and parameter name
536 void ChangeIndentOfAllListLevels( sal_Int32 nDiff );
537 // Adjust method name
538 void SetIndent(short nIndent, const SwPosition & rPos);
539 bool IsFirstOfNumRuleAtCursorPos() const;
541 bool IsNoNum( bool bChkStart = true ) const;
543 /** @return Num-Level of the node in which point of cursor is.
544 @return values can be: NO_NUMBERING, 0..MAXLEVEL-1 */
545 sal_uInt8 GetNumLevel() const;
547 /// Detect highest and lowest level to check moving of outline levels.
548 void GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower );
550 /// Get Outline level of current paragraph.
551 int GetCurrentParaOutlineLevel( ) const;
553 // i29560
554 bool HasNumber() const;
555 bool HasBullet() const;
557 bool SelectionHasNumber() const;
558 bool SelectionHasBullet() const;
560 OUString GetUniqueNumRuleName() const;
561 void ChgNumRuleFormats( const SwNumRule& rRule );
563 /// Set (and query if) a numbering with StartFlag starts at current PointPos.
564 void SetNumRuleStart( bool bFlag, SwPaM* pCursor );
565 bool IsNumRuleStart( SwPaM* pPaM = nullptr ) const;
566 void SetNodeNumStart( sal_uInt16 nStt );
568 sal_uInt16 GetNodeNumStart( SwPaM* pPaM ) const;
570 void ReplaceNumRule( const OUString& rOldRule, const OUString& rNewRule );
572 /** Searches for a text node with a numbering rule.
573 in case a list style is found, <sListId> holds the list id, to which the
574 text node belongs, which applies the found list style. */
575 const SwNumRule * SearchNumRule(const bool bNum,
576 OUString& sListId );
578 /** Undo.
579 Maintain UndoHistory in Document.
580 Reset UndoHistory at Save, SaveAs, Create ??? */
581 void DoUndo( bool bOn = true );
582 bool DoesUndo() const;
583 void DoGroupUndo( bool bUn );
584 bool DoesGroupUndo() const;
585 void DelAllUndoObj();
587 /// Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
588 SwUndoId StartUndo( SwUndoId eUndoId = SwUndoId::EMPTY, const SwRewriter * pRewriter = nullptr );
590 /// Closes parenthesis of nUndoId, not used by UI.
591 SwUndoId EndUndo( SwUndoId eUndoId = SwUndoId::EMPTY, const SwRewriter * pRewriter = nullptr );
593 bool GetLastUndoInfo(OUString *const o_pStr,
594 SwUndoId *const o_pId,
595 const SwView* pView = nullptr) const;
596 bool GetFirstRedoInfo(OUString *const o_pStr,
597 SwUndoId *const o_pId,
598 const SwView* pView = nullptr) const;
599 SwUndoId GetRepeatInfo(OUString *const o_pStr) const;
601 /// is it forbidden to modify cursors via API calls?
602 bool CursorsLocked() const;
603 /// set selections to those contained in the UndoRedoContext
604 /// should only be called by sw::UndoManager!
605 void HandleUndoRedoContext(::sw::UndoRedoContext & rContext);
607 void Undo(sal_uInt16 const nCount = 1, sal_uInt16 nOffset = 0);
608 void Redo(sal_uInt16 const nCount = 1);
609 void Repeat(sal_uInt16 const nCount);
611 /// For all views of this document.
612 void StartAllAction();
613 void EndAllAction();
615 /// To enable set up of StartActions and EndActions.
616 virtual void CalcLayout() override;
618 /// Determine form of content. Return Type at CurrentCursor->SPoint.
619 sal_uInt16 GetCntType() const;
621 /// Are there frames, footnotes, etc.
622 bool HasOtherCnt() const;
624 /// Apply ViewOptions with Start-/EndAction.
625 virtual void ApplyViewOptions( const SwViewOption &rOpt ) override;
627 /// Selected area has readonly content
628 virtual void InfoReadOnlyDialog(bool /*bAsync*/) const
630 // override in SwWrtShell
633 /// Selected area has hidden content
634 virtual bool WarnHiddenSectionDialog() const
636 // override in SwWrtShell
637 return true;
640 /// Switch to Design mode for Forms
641 virtual bool WarnSwitchToDesignModeDialog() const
643 // override in SwWrtShell
644 return false;
647 /** Query text within selection. */
648 void GetSelectedText( OUString &rBuf,
649 ParaBreakType nHndlParaBreak = ParaBreakType::ToBlank );
651 /** @return graphic, if CurrentCursor->Point() points to a SwGrfNode
652 (and mark is not set or points to the same graphic). */
654 const Graphic* GetGraphic( bool bWait = true ) const;
655 const GraphicObject* GetGraphicObj() const;
656 const GraphicAttr* GetGraphicAttr( GraphicAttr& rGA ) const;
658 bool IsLinkedGrfSwapOut() const;
659 GraphicType GetGraphicType() const;
661 const tools::PolyPolygon *GetGraphicPolygon() const;
662 void SetGraphicPolygon( const tools::PolyPolygon *pPoly );
664 /** If there's an automatic, not manipulated polygon at the selected
665 notxtnode, it has to be deleted, e.g. cause the object has changed. */
666 void ClearAutomaticContour();
668 /// @return the size of a graphic in Twips if cursor is in a graphic.
669 bool GetGrfSize(Size&) const;
671 /** @return name and filter of a graphic if the cursor is in a graphic,
672 else give a rap on the knuckles!
673 If a string-ptr != 0 return the respective name. */
674 void GetGrfNms( OUString* pGrfName, OUString* pFltName,
675 const SwFlyFrameFormat* = nullptr ) const;
677 /// Re-read if graphic is not ok. Current graphic is replaced by the new one.
678 void ReRead( const OUString& rGrfName, const OUString& rFltName,
679 const Graphic* pGraphic = nullptr );
681 /// Unique identification of object (for ImageMapDlg).
682 void *GetIMapInventor() const;
684 // #i73788#
685 /// Remove default parameter, because method always called this default value.
686 Graphic GetIMapGraphic() const; ///< @return a graphic for all Flys!
687 const SwFlyFrameFormat* FindFlyByName( const OUString& rName ) const;
689 /** @return a ClientObject, if CurrentCursor->Point() points to a SwOLENode
690 (and mark is neither set not pointint to same ClientObject)
691 else give rap on the knuckles. */
692 svt::EmbeddedObjectRef& GetOLEObject() const;
694 /// Is there an OLEObject with this name (SwFormat)?
695 bool HasOLEObj( std::u16string_view rName ) const;
697 /// @return pointer to the data of the chart in which Cursr is.
698 void SetChartName( const OUString &rName );
700 /// Update content of all charts for table with given name.
701 void UpdateCharts( const OUString& rName );
703 OUString GetCurWord() const;
705 /** Glossary from glossary document in current document.
706 Styles only if not already existent. */
707 void InsertGlossary( SwTextBlocks& rGlossary, const OUString& );
709 /** Make current selection glossary and insert into glossary document
710 including styles. */
711 sal_uInt16 MakeGlossary( SwTextBlocks& rToFill, const OUString& rName,
712 const OUString& rShortName, bool bSaveRelFile,
713 const OUString* pOnlyText );
715 /// Save complete content of doc as glossary.
716 sal_uInt16 SaveGlossaryDoc( SwTextBlocks& rGlossary, const OUString& rName,
717 const OUString& rShortName,
718 bool bSaveRelFile,
719 bool bOnlyText );
721 // Linguistics...
722 /// Save selections.
723 void HyphStart( SwDocPositions eStart, SwDocPositions eEnd );
725 /// restore selections.
726 void HyphEnd();
727 css::uno::Reference< css::uno::XInterface>
728 HyphContinue( sal_uInt16* pPageCnt, sal_uInt16* pPageSt );
730 void HyphIgnore();
732 /// For Inserting SoftHyphen. Position is offset within the syllabificated word.
733 static void InsertSoftHyph( const sal_Int32 nHyphPos );
736 * Inserts an nRows x nCols table to the document at the current position. Unlike the UI, this
737 * function does not move the user's cursor to the first cell of the just inserted table, use
738 * `MoveTable(GotoPrevTable, fnTableStart)` to do that.
740 const SwTable& InsertTable( const SwInsertTableOptions& rInsTableOpts, ///< All
741 sal_uInt16 nRows, sal_uInt16 nCols,
742 const SwTableAutoFormat* pTAFormat = nullptr );
744 void InsertDDETable( const SwInsertTableOptions& rInsTableOpts, ///< HeadlineNoBorder
745 SwDDEFieldType* pDDEType,
746 sal_uInt16 nRows, sal_uInt16 nCols );
748 void UpdateTable();
749 void SetTableName( SwFrameFormat& rTableFormat, const OUString &rNewName );
751 SwFrameFormat *GetTableFormat();
752 bool TextToTable( const SwInsertTableOptions& rInsTableOpts, ///< All
753 sal_Unicode cCh,
754 const SwTableAutoFormat* pTAFormat = nullptr );
755 bool TableToText( sal_Unicode cCh );
756 bool IsTextToTableAvailable() const;
758 bool GetTableBoxFormulaAttrs( SfxItemSet& rSet ) const;
759 void SetTableBoxFormulaAttrs( const SfxItemSet& rSet );
761 bool IsTableBoxTextFormat() const;
762 OUString GetTableBoxText() const;
764 TableChgMode GetTableChgMode() const;
765 void SetTableChgMode( TableChgMode eMode );
767 /// Split table at cursor position.
768 void SplitTable( SplitTable_HeadlineOption eMode );
770 /** Merge tables.
772 Can Merge checks if Prev or Next are possible.
773 If pointer pChkNxtPrv is passed possible direction is given. */
774 bool CanMergeTable( bool bWithPrev = true, bool* pChkNxtPrv = nullptr ) const;
775 bool MergeTable( bool bWithPrev );
777 /// Set up InsertDB as table Undo.
778 void AppendUndoForInsertFromDB( bool bIsTable );
780 /// Functions used for spell checking and text conversion.
782 /// Save selections.
783 void SpellStart( SwDocPositions eStart, SwDocPositions eEnd,
784 SwDocPositions eCurr, SwConversionArgs *pConvArgs = nullptr );
786 /// Restore selections.
787 void SpellEnd( SwConversionArgs const *pConvArgs = nullptr, bool bRestoreSelection = true );
788 css::uno::Any SpellContinue(
789 sal_uInt16* pPageCnt, sal_uInt16* pPageSt,
790 SwConversionArgs const *pConvArgs );
792 /** Spells on a sentence basis - the SpellPortions are needed
793 @return false if no error could be found. */
794 bool SpellSentence(svx::SpellPortions& rToFill, bool bIsGrammarCheck );
796 /// Make SpellIter start with the current sentence when called next time.
797 static void PutSpellingToSentenceStart();
799 /// Moves the continuation position to the end of the currently checked sentence.
800 static void MoveContinuationPosToEndOfCheckedSentence();
802 /// Applies a changed sentence.
803 void ApplyChangedSentence(const svx::SpellPortions& rNewPortions, bool bRecheck);
805 /// Check SwSpellIter data to see if the last sentence got grammar checked.
806 static bool HasLastSentenceGotGrammarChecked();
808 /// Is text conversion active somewhere else?
809 static bool HasConvIter();
811 /// Is hyphenation active somewhere else?
812 static bool HasHyphIter();
814 void HandleCorrectionError(const OUString& aText, SwPosition aPos, sal_Int32 nBegin,
815 sal_Int32 nLen, const Point* pPt,
816 SwRect& rSelectRect);
817 css::uno::Reference< css::linguistic2::XSpellAlternatives >
818 GetCorrection( const Point* pPt, SwRect& rSelectRect );
820 bool GetGrammarCorrection( css::linguistic2::ProofreadingResult /*out*/ &rResult,
821 sal_Int32 /*out*/ &rErrorPosInText,
822 sal_Int32 /*out*/ &rErrorIndexInResult,
823 css::uno::Sequence< OUString > /*out*/ &rSuggestions,
824 const Point* pPt, SwRect& rSelectRect );
826 static void IgnoreGrammarErrorAt( SwPaM& rErrorPosition );
827 void SetLinguRange( SwDocPositions eStart, SwDocPositions eEnd );
829 /// @return reference set in document according to given name.
830 const SwFormatRefMark* GetRefMark( std::u16string_view rName ) const;
832 /** @return names of all references set in document.
833 If ArrayPointer == 0 then return only whether a RefMark is set in document. */
834 sal_uInt16 GetRefMarks( std::vector<OUString>* = nullptr ) const;
836 /// Call AutoCorrect
837 void AutoCorrect( SvxAutoCorrect& rACorr, bool bInsertMode,
838 sal_Unicode cChar );
839 OUString GetPrevAutoCorrWord(SvxAutoCorrect& rACorr);
841 // We consider no more than 9 characters before the cursor, and they must not start in the
842 // middle of a word (leading spaces are OK)
843 std::vector<OUString> GetChunkForAutoText();
845 /// Set our styles according to the respective rules.
846 void AutoFormat( const SvxSwAutoFormatFlags* pAFlags );
848 static SvxSwAutoFormatFlags* GetAutoFormatFlags();
849 static void SetAutoFormatFlags(SvxSwAutoFormatFlags const *);
851 /// Calculates selection.
852 OUString Calculate();
854 bool InsertURL( const SwFormatINetFormat& rFormat, const OUString& rStr,
855 bool bKeepSelection = false );
856 void GetINetAttrs(SwGetINetAttrs& rArr , bool bIncludeInToxContent = true);
858 OUString GetDropText( const sal_Int32 nChars ) const;
859 void ReplaceDropText( const OUString &rStr, SwPaM* pPaM = nullptr );
861 /** May an outline be moved or copied?
862 Check whether it's in text body, not in table, and not read-only (move). */
863 bool IsOutlineMovable( SwOutlineNodes::size_type nIdx ) const;
864 bool IsOutlineCopyable( SwOutlineNodes::size_type nIdx ) const;
866 sal_Int32 GetLineCount();
868 /// Query and set footnote-text/number. Set... to current SSelection!
869 bool GetCurFootnote( SwFormatFootnote* pToFillFootnote = nullptr );
870 bool SetCurFootnote( const SwFormatFootnote& rFillFootnote );
871 bool HasFootnotes( bool bEndNotes = false ) const;
873 size_t GetSeqFootnoteList( SwSeqFieldList& rList, bool bEndNotes = false );
874 /// @return list of all footnotes and their first portions of text.
876 SwSection const* InsertSection(
877 SwSectionData & rNewData, SfxItemSet const*const = nullptr );
878 bool IsInsRegionAvailable() const;
879 const SwSection* GetCurrSection() const;
881 /** @return current range like Cet CurrSection(). But this function iterates
882 also over frames and catches the range even if the cursor is positioned in
883 a footnote the reference of which is in a columned range.
884 If bOutOfTab is set, the range comprising the table is searched
885 and not an inner one. */
886 SwSection* GetAnySection( bool bOutOfTab = false, const Point* pPt = nullptr );
888 size_t GetSectionFormatCount() const;
889 size_t GetSectionFormatPos(const SwSectionFormat&) const;
890 const SwSectionFormat& GetSectionFormat(size_t nFormat) const;
891 void DelSectionFormat( size_t nFormat);
892 void UpdateSection( size_t const nSect, SwSectionData &,
893 SfxItemSet const*const = nullptr);
894 bool IsAnySectionInDoc() const;
896 OUString GetUniqueSectionName( const OUString* pChkStr = nullptr ) const;
898 /// Set attributes.
899 void SetSectionAttr(const SfxItemSet& rSet, SwSectionFormat* pSectFormat = nullptr);
901 /** Search inside the cursor selection for full selected sections.
902 if any part of section in the selection @return 0.
903 if more than one in the selection return the count. */
904 sal_uInt16 GetFullSelectedSectionCount() const;
906 /** Special insert: Insert a new text node just before or after a section or
907 table, if the cursor is positioned at the start/end of said
908 section/table. The purpose of the method is to allow users to inert text
909 at certain 'impossible' position, e.g. before a table at the document
910 start or between to sections. */
911 void DoSpecialInsert();
912 bool CanSpecialInsert() const;
914 /// Optimizing UI.
915 void SetNewDoc();
917 sfx2::LinkManager& GetLinkManager();
918 inline const sfx2::LinkManager& GetLinkManager() const;
920 /** Adjust left margin via object bar (similar to adjustment of numerations).
921 One can either change the margin "by" adding or subtracting a given
922 offset or set it "to" this position @param (bModulus = true). */
923 bool IsMoveLeftMargin( bool bRight, bool bModulus = true ) const;
924 void MoveLeftMargin( bool bRight, bool bModulus = true );
926 /// Query NumberFormatter from document.
927 SvNumberFormatter* GetNumberFormatter();
928 const SvNumberFormatter* GetNumberFormatter() const
929 { return const_cast<SwEditShell*>(this)->GetNumberFormatter(); }
931 /// Interfaces for GlobalDocument.
932 bool IsGlobalDoc() const;
933 void SetGlblDocSaveLinks( bool bFlag );
934 bool IsGlblDocSaveLinks() const;
935 void GetGlobalDocContent( SwGlblDocContents& rArr ) const;
936 void InsertGlobalDocContent( const SwGlblDocContent& rPos,
937 SwSectionData & rNew );
938 bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
939 const SwTOXBase& rTOX );
940 bool InsertGlobalDocContent( const SwGlblDocContent& rPos );
941 void DeleteGlobalDocContent( const SwGlblDocContents& rArr,
942 size_t nPos );
943 bool MoveGlobalDocContent( const SwGlblDocContents& rArr ,
944 size_t nFromPos, size_t nToPos,
945 size_t nNewPos );
946 void GotoGlobalDocContent( const SwGlblDocContent& rPos );
948 /// For Redlining.
949 RedlineFlags GetRedlineFlags() const;
950 void SetRedlineFlags( RedlineFlags eMode );
951 bool IsRedlineOn() const;
952 SwRedlineTable::size_type GetRedlineCount() const;
953 const SwRangeRedline& GetRedline( SwRedlineTable::size_type nPos ) const;
954 bool AcceptRedline( SwRedlineTable::size_type nPos );
955 bool RejectRedline( SwRedlineTable::size_type nPos );
956 bool AcceptRedlinesInSelection();
957 bool RejectRedlinesInSelection();
959 /** Search Redline for this Data and @return position in array.
960 If not found, return SwRedlineTable::npos. */
961 SwRedlineTable::size_type FindRedlineOfData( const SwRedlineData& ) const;
963 /// Set comment to Redline at position.
964 bool SetRedlineComment( const OUString& rS );
965 const SwRangeRedline* GetCurrRedline() const;
967 /// Redline attributes have been changed. Updated views.
968 void UpdateRedlineAttr();
970 /// Compare two documents.
971 tools::Long CompareDoc( const SwDoc& rDoc );
973 /// Merge two documents.
974 tools::Long MergeDoc( const SwDoc& rDoc );
976 /// Footnote attributes global to document.
977 const SwFootnoteInfo& GetFootnoteInfo() const;
978 void SetFootnoteInfo(const SwFootnoteInfo& rInfo);
979 const SwEndNoteInfo& GetEndNoteInfo() const;
980 void SetEndNoteInfo(const SwEndNoteInfo& rInfo);
982 const SwLineNumberInfo &GetLineNumberInfo() const;
983 void SetLineNumberInfo( const SwLineNumberInfo& rInfo);
985 /// Labels: Synchronize ranges.
986 void SetLabelDoc( bool bFlag );
987 bool IsLabelDoc() const;
989 /// Interface for TextInputData - (for input of Japanese/Chinese chars.)
990 void CreateExtTextInput(LanguageType eInputLanguage);
991 OUString DeleteExtTextInput( bool bInsText = true);
992 void SetExtTextInputData( const CommandExtTextInputData& );
994 /// Returns true iff paragraph signature validation is enabled.
995 bool IsParagraphSignatureValidationEnabled() const { return m_bDoParagraphSignatureValidation; }
996 /// Enable/Disable paragraph signature validation and return the previous value.
997 bool SetParagraphSignatureValidation(const bool bEnable)
999 const bool bOldFlag = m_bDoParagraphSignatureValidation;
1000 m_bDoParagraphSignatureValidation = bEnable;
1001 return bOldFlag;
1004 /// Interface for access to AutoComplete-list.
1005 static SwAutoCompleteWord& GetAutoCompleteWords();
1007 /** @return a scaling factor of selected text. Used for the rotated
1008 character attribute dialog. */
1009 sal_uInt16 GetScalingOfSelectedText() const;
1011 bool IsNbspRunNext() const { return m_bNbspRunNext; }
1013 /// Ctor/Dtor.
1014 SwEditShell( SwDoc&, vcl::Window*, const SwViewOption *pOpt );
1016 /// Copy-Constructor in disguise.
1017 SwEditShell( SwEditShell&, vcl::Window* );
1018 virtual ~SwEditShell() override;
1020 private:
1021 SwEditShell(const SwEditShell &) = delete;
1022 const SwEditShell &operator=(const SwEditShell &) = delete;
1024 /* TODO: this flag may have to be invalidated / reset to false at various
1025 * places if it was true and the edit cursor position changes. It's somehow
1026 * overkill though because it can only be true if a NO-BREAK SPACE was
1027 * inserted by the last DoAutoCorrect() call (in French language), any
1028 * subsequent call will reset it anyway and just if the cursor is
1029 * positioned behind "x :" and the next character inserted is not a space
1030 * the existing nb-space will be removed. Bear this in mind if that problem
1031 * arises. */
1032 bool m_bNbspRunNext; ///< NO-BREAK SPACE state flag passed to and maintained by SvxAutoCorrect::DoAutoCorrect()
1033 bool m_bDoParagraphSignatureValidation; ///< Prevent nested calls of ValidateParagraphSignatures.
1036 inline const sfx2::LinkManager& SwEditShell::GetLinkManager() const
1037 { return const_cast<SwEditShell*>(this)->GetLinkManager(); }
1039 /// Class for automated call of Start- and EndAction().
1040 class SwActContext {
1041 SwEditShell & m_rShell;
1042 public:
1043 SwActContext(SwEditShell *pShell);
1044 ~SwActContext() COVERITY_NOEXCEPT_FALSE;
1047 /// Class for automated call of Start- and EndCursorMove().
1048 class SwMvContext {
1049 SwEditShell & m_rShell;
1050 public:
1051 SwMvContext(SwEditShell *pShell);
1052 ~SwMvContext() COVERITY_NOEXCEPT_FALSE;
1055 #endif
1057 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */