tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sw / inc / editsh.hxx
blob5a16812e89da50673a6517a9b09502be6b7a9c59
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 SAL_DLLPUBLIC_RTTI 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 SwGrfNode *GetGrfNode_() const ;
155 void DeleteSel(SwPaM& rPam, bool isArtificialSelection, bool goLeft = false, bool* pUndo = nullptr);
157 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 SW_DLLPUBLIC 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 SW_DLLPUBLIC bool Replace( const OUString& rNewStr, bool bRegExpRplc );
175 /** Replace a selected range in a TextNode by given string.
176 Possible comments will be kept (moved to the end of the selection). */
177 bool ReplaceKeepComments( const OUString& rNewStr);
179 /** Delete content of all ranges.
180 If whole nodes are selected, these nodes get deleted. */
181 SW_DLLPUBLIC bool Delete(bool isArtificialSelection = false, bool goLeft = false);
183 /// Remove a complete paragraph.
184 SW_DLLPUBLIC bool DelFullPara();
186 /// Change text to Upper/Lower/Hiragana/Katakana/...
187 void TransliterateText( TransliterationFlags nType );
189 /// Count words in current selection.
190 SW_DLLPUBLIC void CountWords( SwDocStat& rStat ) const;
192 /// Replace fields by text - mailmerge support.
193 bool ConvertFieldsToText();
195 /// Set all numbering start points to a fixed value - mailmerge support.
196 void SetNumberingRestart();
198 /// Embeds all local links (ranges/graphics).
199 SW_DLLPUBLIC sal_uInt16 GetLinkUpdMode() const;
200 SW_DLLPUBLIC void SetLinkUpdMode( sal_uInt16 nMode );
202 /// Copy content of all ranges at current position of cursor to given Shell.
203 bool Copy( SwEditShell& rDestShell );
205 /** For copying via ClipBoard:
206 If table is copied into table, move all cursors away from it.
207 Copy and Paste must be in FEShell because of FlyFrames!
208 Copy all selections to the document. */
209 bool CopySelToDoc( SwDoc& rInsDoc );
211 SW_DLLPUBLIC void SplitNode( bool bAutoFormat = false, bool bCheckTableStart = true );
212 SW_DLLPUBLIC bool AppendTextNode();
213 void AutoFormatBySplitNode();
215 /** If cursor is in an INetAttribute it will be deleted completely
216 including the descriptive text (needed at drag & drop). */
217 void DelINetAttrWithText();
219 /** If Cursor is at the end of a character style in which the DontExpand-flag
220 is not yet set, the latter will be set (==> return TRUE). */
221 bool DontExpandFormat();
223 /** Apply / remove attributes.
224 @return attributes in required AttributeSet.
225 When not unambiguous the set has a DONT_CARE !!
226 2nd optional parameter <bMergeIndentValuesOfNumRule>.
227 If <bMergeIndentValuesOfNumRule> == true, the indent attributes of
228 the corresponding list level of an applied list style is merged into
229 the requested item set as a LR-SPACE item, if corresponding node has not
230 its own indent attributes and the position-and-space mode of the list
231 level is SvxNumberFormat::LABEL_ALIGNMENT. */
232 bool GetPaMAttr( SwPaM* pPaM, SfxItemSet& ,
233 const bool bMergeIndentValuesOfNumRule = false ) const;
234 SW_DLLPUBLIC bool GetCurAttr( SfxItemSet& ,
235 const bool bMergeIndentValuesOfNumRule = false ) const;
236 SW_DLLPUBLIC void SetAttrItem( const SfxPoolItem&, SetAttrMode nFlags = SetAttrMode::DEFAULT,
237 const bool bParagraphSetting = false );
238 SW_DLLPUBLIC void SetAttrSet( const SfxItemSet&, SetAttrMode nFlags = SetAttrMode::DEFAULT,
239 SwPaM* pCursor = nullptr, const bool bParagraphSetting = false );
241 /** Get RES_CHRATR_* items of one type in the current selection.
242 * @param nWhich WhichId of the collected items.
243 * If parts of the selection have different scripttypes, the items with corresponding WhichIds are also collected.
244 * @return a vector of pairs. The pair contains a SfxPoolItem and a SwPaM, in which the item is valid and can be changed. */
245 std::vector<std::pair< const SfxPoolItem*, std::unique_ptr<SwPaM>>> GetItemWithPaM( sal_uInt16 nWhich );
248 * Get the paragraph format attribute(s) of the current selection.
250 * @see GetPaMParAttr()
252 * @param rSet
253 * output parameter - the SfxItemSet where the automatic paragraph format attribute(s) will be store.
254 * The attributes aren't invalidated or cleared if the function reach the getMaxLookup limit.
256 SW_DLLPUBLIC void GetCurParAttr( SfxItemSet& rSet ) const;
258 * Get the paragraph format attribute(s) of the selection(s) described by a SwPaM.
260 * @param pPaM
261 * input parameter - the selection where to look for the paragraph format.
263 * @param rSet
264 * output parameter - the SfxItemSet where the automatic paragraph format attribute(s) will be store.
265 * The attributes aren't invalidated or cleared if the function reaches the getMaxLookup limit.
267 void GetPaMParAttr( SwPaM* pPaM, SfxItemSet& rSet ) const;
269 /// Set attribute as new default attribute in document.
270 SW_DLLPUBLIC void SetDefault( const SfxPoolItem& );
272 /// Query default attribute of document.
273 SW_DLLPUBLIC const SfxPoolItem& GetDefault( sal_uInt16 nFormatHint ) const;
274 template<class T> const T& GetDefault( TypedWhichId<T> nWhich ) const
276 return static_cast<const T&>(GetDefault(sal_uInt16(nWhich)));
279 void ResetAttr( const o3tl::sorted_vector<sal_uInt16> &attrs = o3tl::sorted_vector<sal_uInt16>(), SwPaM* pCursor = nullptr );
280 void GCAttr();
282 /// @return the scripttype of the selection.
283 SW_DLLPUBLIC SvtScriptType GetScriptType() const;
285 /// @return the language at current cursor position.
286 SW_DLLPUBLIC LanguageType GetCurLang() const;
288 /// TABLE
289 size_t GetTableFrameFormatCount( bool bUsed = false ) const;
290 SwFrameFormat& GetTableFrameFormat(size_t nFormat, bool bUsed = false ) const;
291 SW_DLLPUBLIC OUString GetUniqueTableName() const;
293 /// CHAR
294 SW_DLLPUBLIC sal_uInt16 GetCharFormatCount() const;
295 SW_DLLPUBLIC SwCharFormat& GetCharFormat(sal_uInt16 nFormat) const;
296 SwCharFormat* GetCurCharFormat() const;
297 void FillByEx(SwCharFormat*);
298 SwCharFormat* MakeCharFormat( const OUString& rName );
299 SW_DLLPUBLIC SwCharFormat* FindCharFormatByName( const OUString& rName ) const;
301 /* FormatCollections (new) - Explaining the general naming pattern:
302 * GetXXXCount() returns the count of xxx in the document.
303 * GetXXX(i) returns i-th xxx (ERR_RAISE if beyond range!).
304 * DelXXX(i) deletes i-th xxx (ERR_RAISE if beyond range!).
305 * GetCurXXX() returns xxx that is valid at cursor or in ranges.
306 * returns 0, if not unanimous.
307 * SetXXX() sets xxx at cursor or in ranges.
308 * MakeXXX() makes a xxx, derived from pDerivedFrom.
311 // TXT
312 SwTextFormatColl& GetDfltTextFormatColl() const;
313 SW_DLLPUBLIC sal_uInt16 GetTextFormatCollCount() const;
314 SW_DLLPUBLIC SwTextFormatColl& GetTextFormatColl( sal_uInt16 nTextFormatColl) const;
316 * Get the named paragraph format of the current selection.
318 * @see GetPaMTextFormatColl()
320 * @return the named paragraph format of the first node that contains one.
321 * Nodes are sort by order of appearance in the selections ;
322 * selections are sort by their order of creation
323 * (last created selection first, oldest selection at last).
325 SW_DLLPUBLIC SwTextFormatColl* GetCurTextFormatColl() const;
327 * Get the named paragraph format of the selection(s) described by a SwPaM.
329 * @param pPaM
330 * input parameter - the selection where to look for the paragraph format.
332 * @return the named paragraph format of the first node that contains one.
334 SwTextFormatColl* GetPaMTextFormatColl( SwPaM* pPaM ) const;
336 // #i62675#
337 /// Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTextFormatColl(..)>
338 SW_DLLPUBLIC void SetTextFormatColl(SwTextFormatColl*,
339 const bool bResetListAttrs = false,
340 SetAttrMode nMode = SetAttrMode::DEFAULT);
341 SW_DLLPUBLIC SwTextFormatColl *MakeTextFormatColl(const OUString &rFormatCollName,
342 SwTextFormatColl *pDerivedFrom = nullptr);
343 void FillByEx(SwTextFormatColl*);
344 SW_DLLPUBLIC SwTextFormatColl* FindTextFormatCollByName( const OUString& rName ) const;
346 /// @return "Auto-Collection" with given Id. If it does not exist create it.
347 SW_DLLPUBLIC SwTextFormatColl* GetTextCollFromPool( sal_uInt16 nId );
349 /// @return required automatic format base class.
350 SwFormat* GetFormatFromPool( sal_uInt16 nId );
352 /// @return required automatic page style.
353 SW_DLLPUBLIC SwPageDesc* GetPageDescFromPool( sal_uInt16 nId );
355 /// Query if the paragraph-/character-/frame-/page-style is used.
356 SW_DLLPUBLIC bool IsUsed( const sw::BroadcastingModify& ) const;
358 /// @return required automatic format.
359 SwFrameFormat* GetFrameFormatFromPool( sal_uInt16 nId )
360 { return static_cast<SwFrameFormat*>(SwEditShell::GetFormatFromPool( nId )); }
361 SwCharFormat* GetCharFormatFromPool( sal_uInt16 nId )
362 { return static_cast<SwCharFormat*>(SwEditShell::GetFormatFromPool( nId )); }
364 void SetClassification(const OUString& rName, SfxClassificationPolicyType eType);
365 void ApplyAdvancedClassification(std::vector<svx::ClassificationResult> const & rResult);
366 std::vector<svx::ClassificationResult> CollectAdvancedClassification();
368 SfxWatermarkItem GetWatermark() const;
369 SW_DLLPUBLIC void SetWatermark(const SfxWatermarkItem& rText);
371 /// Sign the paragraph at the cursor.
372 void SignParagraph();
374 /// Validate the paragraph signatures, if any, of the current text node.
375 void ValidateParagraphSignatures(SwTextNode* pNode, bool updateDontRemove);
377 /// Validate the current paragraph signatures, if any, at the cursor start.
378 void ValidateCurrentParagraphSignatures(bool updateDontRemove);
380 /// Validate all paragraph signatures.
381 void ValidateAllParagraphSignatures(bool updateDontRemove);
383 /// Restore the metadata fields, if missing, from the RDF metadata
384 /// and validate the signatures and update the signature metadata fields.
385 /// Needed since deleting the metadata field doesn't remove the RDF
386 /// and editing docs using software that don't support paragraph signing.
387 void RestoreMetadataFieldsAndValidateParagraphSignatures();
389 /// Ensure that the classification of the doc is never lower than
390 /// the paragraph with the highest classification.
391 void ClassifyDocPerHighestParagraphClass();
393 /// Apply the classification to the paragraph at cursor.
394 void ApplyParagraphClassification(std::vector<svx::ClassificationResult> aResult);
395 std::vector<svx::ClassificationResult> CollectParagraphClassification();
397 /// Returns true iff the cursor is within a paragraph metadata field.
398 /// Currently there are two variants: signature and classification.
399 bool IsCursorInParagraphMetadataField() const;
401 /// Removes the paragraph metadata field at the current cursor, if any.
402 /// Returns true iff a paragraph metadata field was removed.
403 /// Currently there are two variants: signature and classification.
404 bool RemoveParagraphMetadataFieldAtCursor();
406 bool InsertField(SwField const &, const bool bForceExpandHints);
408 SW_DLLPUBLIC void UpdateOneField(SwField &); ///< One single field.
410 SW_DLLPUBLIC size_t GetFieldTypeCount(SwFieldIds nResId = SwFieldIds::Unknown) const;
411 SW_DLLPUBLIC SwFieldType* GetFieldType(size_t nField, SwFieldIds nResId = SwFieldIds::Unknown) const;
412 SW_DLLPUBLIC SwFieldType* GetFieldType(SwFieldIds nResId, const OUString& rName) const;
414 void RemoveFieldType(size_t nField);
415 void RemoveFieldType(SwFieldIds nResId, const OUString& rName);
417 void FieldToText( SwFieldType const * pType );
419 SW_DLLPUBLIC void ChangeAuthorityData(const SwAuthEntry* pNewData);
421 /// Database information.
422 SW_DLLPUBLIC SwDBData const & GetDBData() const;
423 void ChgDBData(const SwDBData& SwDBData);
424 SW_DLLPUBLIC void ChangeDBFields( const std::vector<OUString>& rOldNames,
425 const OUString& rNewName );
426 SW_DLLPUBLIC void GetAllUsedDB( std::vector<OUString>& rDBNameList,
427 std::vector<OUString> const * pAllDBNames );
429 bool IsAnyDatabaseFieldInDoc()const;
431 /// Check whether DB fields point to an available data source and returns it.
432 bool IsFieldDataSourceAvailable(OUString& rUsedDataSource) const;
433 SW_DLLPUBLIC void UpdateExpFields(bool bCloseDB = false);///< only every expression fields update
434 SW_DLLPUBLIC void LockExpFields();
435 SW_DLLPUBLIC void UnlockExpFields();
436 bool IsExpFieldsLocked() const;
438 SW_DLLPUBLIC SwFieldUpdateFlags GetFieldUpdateFlags() const;
439 SW_DLLPUBLIC void SetFieldUpdateFlags( SwFieldUpdateFlags eFlags );
441 /// For evaluation of DB fields (new DB-manager).
442 SW_DLLPUBLIC SwDBManager* GetDBManager() const;
444 SW_DLLPUBLIC SwFieldType* InsertFieldType(const SwFieldType &);
446 /// Changes in document?
447 SW_DLLPUBLIC bool IsModified() const;
448 SW_DLLPUBLIC void SetModified();
449 SW_DLLPUBLIC void ResetModified();
450 SW_DLLPUBLIC void SetUndoNoResetModified();
452 /// Document - Statistics
453 void UpdateDocStat();
454 SW_DLLPUBLIC const SwDocStat &GetUpdatedDocStat();
456 void Insert(const SwTOXMark& rMark);
458 void DeleteTOXMark(SwTOXMark const * pMark);
460 /// Get all marks at current SPoint.
461 void GetCurTOXMarks(SwTOXMarks& rMarks) const ;
463 /// Insert content table. Renew if required.
464 void InsertTableOf(const SwTOXBase& rTOX,
465 const SfxItemSet* pSet = nullptr);
466 void UpdateTableOf(const SwTOXBase& rTOX,
467 const SfxItemSet* pSet = nullptr);
468 SW_DLLPUBLIC const SwTOXBase* GetCurTOX() const;
469 SW_DLLPUBLIC const SwTOXBase* GetDefaultTOXBase( TOXTypes eTyp, bool bCreate = false );
470 SW_DLLPUBLIC void SetDefaultTOXBase(const SwTOXBase& rBase);
472 static bool IsTOXBaseReadonly(const SwTOXBase& rTOXBase);
473 void SetTOXBaseReadonly(const SwTOXBase& rTOXBase, bool bReadonly);
475 SW_DLLPUBLIC sal_uInt16 GetTOXCount() const;
476 SW_DLLPUBLIC const SwTOXBase* GetTOX( sal_uInt16 nPos ) const;
477 SW_DLLPUBLIC bool DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes );
479 /// After reading file update all content tables.
480 void SetUpdateTOX( bool bFlag );
481 bool IsUpdateTOX() const;
483 /// Manage types of content tables.
484 SW_DLLPUBLIC sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const;
485 SW_DLLPUBLIC const SwTOXType* GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const;
486 void InsertTOXType(const SwTOXType& rTyp);
488 /// AutoMark file
489 SW_DLLPUBLIC OUString const & GetTOIAutoMarkURL() const;
490 void SetTOIAutoMarkURL(const OUString& rSet);
491 void ApplyAutoMark();
493 /// Key for managing index.
494 SW_DLLPUBLIC void GetTOIKeys( SwTOIKeyType eTyp, std::vector<OUString>& rArr ) const;
496 SW_DLLPUBLIC void SetOutlineNumRule(const SwNumRule&);
497 SW_DLLPUBLIC const SwNumRule* GetOutlineNumRule() const;
499 bool OutlineUpDown( short nOffset = 1 );
501 bool MoveOutlinePara( SwOutlineNodes::difference_type nOffset,
502 SwOutlineNodesInline* pOutlineNodesInline = nullptr );
504 bool IsProtectedOutlinePara() const;
506 SW_DLLPUBLIC const SwNumRule* GetNumRuleAtCurrCursorPos() const;
508 /** Returns the numbering rule found at the paragraphs of the current selection,
509 if all paragraphs of the current selection have the same or none numbering rule applied. */
510 const SwNumRule* GetNumRuleAtCurrentSelection() const;
512 /** Optional parameter <bResetIndentAttrs> (default value false).
513 If <bResetIndentAttrs> equals true, the indent attributes "before text"
514 and "first line indent" are additionally reset at the current selection,
515 if the list style makes use of the new list level attributes.
516 Parameters <bCreateNewList> and <sContinuedListId>
517 <bCreateNewList> indicates, if a new list is created by applying the given list style.
518 If <bCreateNewList> equals false, <sContinuedListId> may contain the
519 list Id of a list, which has to be continued by applying the given list style */
520 void SetCurNumRule( const SwNumRule&,
521 const bool bCreateNewList /*= false*/,
522 const OUString& sContinuedListId = OUString(),
523 const bool bResetIndentAttrs = false );
525 /// Paragraphs without enumeration but with indents.
526 void NoNum();
528 /// Delete, split enumeration list.
529 void DelNumRules();
531 void NumUpDown( bool bDown = true );
533 SW_DLLPUBLIC bool MoveParagraph( SwNodeOffset nOffset = SwNodeOffset(1));
534 bool MoveNumParas( bool bUpperLower, bool bUpperLeft );
536 /// Switch on/off of numbering via Delete/Backspace.
537 SW_DLLPUBLIC bool NumOrNoNum(bool bDelete = false);
539 // #i23726#
540 // #i90078#
541 /// Remove unused default parameter <nLevel> and <bRelative>.
542 // Adjust method name and parameter name
543 void ChangeIndentOfAllListLevels( sal_Int32 nDiff );
544 // Adjust method name
545 void SetIndent(short nIndent, const SwPosition & rPos);
546 bool IsFirstOfNumRuleAtCursorPos() const;
548 bool IsNoNum() const;
550 /** @return Num-Level of the node in which point of cursor is.
551 @return values can be: NO_NUMBERING, 0..MAXLEVEL-1 */
552 sal_uInt8 GetNumLevel() const;
554 /// Detect highest and lowest level to check moving of outline levels.
555 void GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower );
557 /// Get Outline level of current paragraph.
558 int GetCurrentParaOutlineLevel( ) const;
560 // i29560
561 bool HasNumber() const;
562 bool HasBullet() const;
564 bool SelectionHasNumber() const;
565 bool SelectionHasBullet() const;
567 SW_DLLPUBLIC OUString GetUniqueNumRuleName() const;
568 void ChgNumRuleFormats( const SwNumRule& rRule );
570 /// Set (and query if) a numbering with StartFlag starts at current PointPos.
571 void SetNumRuleStart( bool bFlag, SwPaM* pCursor );
572 bool IsNumRuleStart( SwPaM* pPaM = nullptr ) const;
573 void SetNodeNumStart( sal_uInt16 nStt );
575 sal_uInt16 GetNodeNumStart( SwPaM* pPaM ) const;
577 void ReplaceNumRule( const OUString& rOldRule, const OUString& rNewRule );
579 /** Searches for a text node with a numbering rule.
580 in case a list style is found, <sListId> holds the list id, to which the
581 text node belongs, which applies the found list style. */
582 const SwNumRule * SearchNumRule(const bool bNum,
583 OUString& sListId );
584 std::set<OUString> GetUsedBullets();
586 /** Undo.
587 Maintain UndoHistory in Document.
588 Reset UndoHistory at Save, SaveAs, Create ??? */
589 SW_DLLPUBLIC void DoUndo( bool bOn = true );
590 SW_DLLPUBLIC bool DoesUndo() const;
591 void DoGroupUndo( bool bUn );
592 bool DoesGroupUndo() const;
593 void DelAllUndoObj();
595 /// Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
596 SW_DLLPUBLIC SwUndoId StartUndo( SwUndoId eUndoId = SwUndoId::EMPTY, const SwRewriter * pRewriter = nullptr );
598 /// Closes parenthesis of nUndoId, not used by UI.
599 SW_DLLPUBLIC SwUndoId EndUndo( SwUndoId eUndoId = SwUndoId::EMPTY, const SwRewriter * pRewriter = nullptr );
601 SW_DLLPUBLIC bool GetLastUndoInfo(OUString *const o_pStr,
602 SwUndoId *const o_pId,
603 const SwView* pView = nullptr) const;
604 bool GetFirstRedoInfo(OUString *const o_pStr,
605 SwUndoId *const o_pId,
606 const SwView* pView = nullptr) const;
607 SwUndoId GetRepeatInfo(OUString *const o_pStr) const;
609 /// is it forbidden to modify cursors via API calls?
610 bool CursorsLocked() const;
611 /// set selections to those contained in the UndoRedoContext
612 /// should only be called by sw::UndoManager!
613 void HandleUndoRedoContext(::sw::UndoRedoContext & rContext);
615 SW_DLLPUBLIC void Undo(sal_uInt16 const nCount = 1, sal_uInt16 nOffset = 0);
616 SW_DLLPUBLIC void Redo(sal_uInt16 const nCount = 1);
617 void Repeat(sal_uInt16 const nCount);
619 /// For all views of this document.
620 SW_DLLPUBLIC void StartAllAction();
621 SW_DLLPUBLIC void EndAllAction();
623 /// To enable set up of StartActions and EndActions.
624 SW_DLLPUBLIC virtual void CalcLayout() override;
626 /// Determine form of content. Return Type at CurrentCursor->SPoint.
627 sal_uInt16 GetCntType() const;
629 /// Are there frames, footnotes, etc.
630 bool HasOtherCnt() const;
632 /// Apply ViewOptions with Start-/EndAction.
633 virtual void ApplyViewOptions( const SwViewOption &rOpt ) override;
635 /// Selected area has readonly content
636 virtual void InfoReadOnlyDialog(bool /*bAsync*/) const
638 // override in SwWrtShell
641 /// Selected area has hidden content
642 virtual bool WarnHiddenSectionDialog() const
644 // override in SwWrtShell
645 return true;
648 /// Switch to Design mode for Forms
649 virtual bool WarnSwitchToDesignModeDialog() const
651 // override in SwWrtShell
652 return false;
655 /** Query text within selection. */
656 SW_DLLPUBLIC void GetSelectedText( OUString &rBuf,
657 ParaBreakType nHndlParaBreak = ParaBreakType::ToBlank );
659 /** @return graphic, if CurrentCursor->Point() points to a SwGrfNode
660 (and mark is not set or points to the same graphic). */
662 const Graphic* GetGraphic( bool bWait = true ) const;
663 const GraphicObject* GetGraphicObj() const;
664 const GraphicAttr* GetGraphicAttr( GraphicAttr& rGA ) const;
666 bool IsLinkedGrfSwapOut() const;
667 GraphicType GetGraphicType() const;
669 const tools::PolyPolygon *GetGraphicPolygon() const;
670 void SetGraphicPolygon( const tools::PolyPolygon *pPoly );
672 /** If there's an automatic, not manipulated polygon at the selected
673 notxtnode, it has to be deleted, e.g. cause the object has changed. */
674 void ClearAutomaticContour();
676 /// @return the size of a graphic in Twips if cursor is in a graphic.
677 SW_DLLPUBLIC bool GetGrfSize(Size&) const;
679 /** @return name and filter of a graphic if the cursor is in a graphic,
680 else give a rap on the knuckles!
681 If a string-ptr != 0 return the respective name. */
682 void GetGrfNms( OUString* pGrfName, OUString* pFltName ) const;
684 /// Re-read if graphic is not ok. Current graphic is replaced by the new one.
685 void ReRead( const OUString& rGrfName, const OUString& rFltName,
686 const Graphic* pGraphic = nullptr );
688 /// Unique identification of object (for ImageMapDlg).
689 void *GetIMapInventor() const;
691 // #i73788#
692 /// Remove default parameter, because method always called this default value.
693 SW_DLLPUBLIC Graphic GetIMapGraphic() const; ///< @return a graphic for all Flys!
694 const SwFlyFrameFormat* FindFlyByName( const OUString& rName ) const;
696 /** @return a ClientObject, if CurrentCursor->Point() points to a SwOLENode
697 (and mark is neither set not pointint to same ClientObject)
698 else give rap on the knuckles. */
699 SW_DLLPUBLIC svt::EmbeddedObjectRef& GetOLEObject() const;
701 /// Is there an OLEObject with this name (SwFormat)?
702 bool HasOLEObj( std::u16string_view rName ) const;
704 /// @return pointer to the data of the chart in which Cursr is.
705 void SetChartName( const OUString &rName );
707 /// Update content of all charts for table with given name.
708 void UpdateCharts( const OUString& rName );
710 OUString GetCurWord() const;
712 /** Glossary from glossary document in current document.
713 Styles only if not already existent. */
714 void InsertGlossary( SwTextBlocks& rGlossary, const OUString& );
716 /** Make current selection glossary and insert into glossary document
717 including styles. */
718 sal_uInt16 MakeGlossary( SwTextBlocks& rToFill, const OUString& rName,
719 const OUString& rShortName, bool bSaveRelFile,
720 const OUString* pOnlyText );
722 /// Save complete content of doc as glossary.
723 sal_uInt16 SaveGlossaryDoc( SwTextBlocks& rGlossary, const OUString& rName,
724 const OUString& rShortName,
725 bool bSaveRelFile,
726 bool bOnlyText );
728 // Linguistics...
729 /// Save selections.
730 void HyphStart( SwDocPositions eStart, SwDocPositions eEnd );
732 /// restore selections.
733 void HyphEnd();
734 css::uno::Reference< css::uno::XInterface>
735 HyphContinue( sal_uInt16* pPageCnt, sal_uInt16* pPageSt );
737 void HyphIgnore();
739 /// For Inserting SoftHyphen. Position is offset within the syllabificated word.
740 static void InsertSoftHyph( const sal_Int32 nHyphPos );
743 * Inserts an nRows x nCols table to the document at the current position. Unlike the UI, this
744 * function does not move the user's cursor to the first cell of the just inserted table, use
745 * `MoveTable(GotoPrevTable, fnTableStart)` to do that.
747 SW_DLLPUBLIC const SwTable& InsertTable( const SwInsertTableOptions& rInsTableOpts, ///< All
748 sal_uInt16 nRows, sal_uInt16 nCols,
749 const SwTableAutoFormat* pTAFormat = nullptr );
751 void InsertDDETable( const SwInsertTableOptions& rInsTableOpts, ///< HeadlineNoBorder
752 SwDDEFieldType* pDDEType,
753 sal_uInt16 nRows, sal_uInt16 nCols );
755 void UpdateTable();
756 SW_DLLPUBLIC void SetTableName( SwFrameFormat& rTableFormat, const OUString &rNewName );
758 SW_DLLPUBLIC SwFrameFormat *GetTableFormat();
759 SW_DLLPUBLIC bool TextToTable( const SwInsertTableOptions& rInsTableOpts, ///< All
760 sal_Unicode cCh,
761 const SwTableAutoFormat* pTAFormat = nullptr );
762 SW_DLLPUBLIC bool TableToText( sal_Unicode cCh );
763 bool IsTextToTableAvailable() const;
765 bool GetTableBoxFormulaAttrs( SfxItemSet& rSet ) const;
766 SW_DLLPUBLIC void SetTableBoxFormulaAttrs( const SfxItemSet& rSet );
768 bool IsTableBoxTextFormat() const;
769 OUString GetTableBoxText() const;
771 TableChgMode GetTableChgMode() const;
772 SW_DLLPUBLIC void SetTableChgMode( TableChgMode eMode );
774 /// Split table at cursor position.
775 SW_DLLPUBLIC void SplitTable( SplitTable_HeadlineOption eMode );
777 /** Merge tables.
779 Can Merge checks if Prev or Next are possible.
780 If pointer pChkNxtPrv is passed possible direction is given. */
781 bool CanMergeTable( bool bWithPrev = true, bool* pChkNxtPrv = nullptr ) const;
782 bool MergeTable( bool bWithPrev );
784 /// Set up InsertDB as table Undo.
785 SW_DLLPUBLIC void AppendUndoForInsertFromDB( bool bIsTable );
787 /// Functions used for spell checking and text conversion.
789 /// Save selections.
790 void SpellStart( SwDocPositions eStart, SwDocPositions eEnd,
791 SwDocPositions eCurr, SwConversionArgs *pConvArgs = nullptr );
793 /// Restore selections.
794 void SpellEnd( SwConversionArgs const *pConvArgs = nullptr, bool bRestoreSelection = true );
795 css::uno::Any SpellContinue(
796 sal_uInt16* pPageCnt, sal_uInt16* pPageSt,
797 SwConversionArgs const *pConvArgs );
799 /** Spells on a sentence basis - the SpellPortions are needed
800 @return false if no error could be found. */
801 bool SpellSentence(svx::SpellPortions& rToFill, bool bIsGrammarCheck );
803 /// Make SpellIter start with the current sentence when called next time.
804 static void PutSpellingToSentenceStart();
806 /// Moves the continuation position to the end of the currently checked sentence.
807 static void MoveContinuationPosToEndOfCheckedSentence();
809 /// Applies a changed sentence.
810 void ApplyChangedSentence(const svx::SpellPortions& rNewPortions, bool bRecheck);
812 /// Check SwSpellIter data to see if the last sentence got grammar checked.
813 static bool HasLastSentenceGotGrammarChecked();
815 /// Is text conversion active somewhere else?
816 static bool HasConvIter();
818 /// Is hyphenation active somewhere else?
819 static bool HasHyphIter();
821 void HandleCorrectionError(const OUString& aText, SwPosition aPos, sal_Int32 nBegin,
822 sal_Int32 nLen, const Point* pPt,
823 SwRect& rSelectRect);
824 css::uno::Reference< css::linguistic2::XSpellAlternatives >
825 GetCorrection( const Point* pPt, SwRect& rSelectRect );
827 bool GetGrammarCorrection( css::linguistic2::ProofreadingResult /*out*/ &rResult,
828 sal_Int32 /*out*/ &rErrorPosInText,
829 sal_Int32 /*out*/ &rErrorIndexInResult,
830 css::uno::Sequence< OUString > /*out*/ &rSuggestions,
831 const Point* pPt, SwRect& rSelectRect );
833 static void IgnoreGrammarErrorAt( SwPaM& rErrorPosition );
834 void SetLinguRange( SwDocPositions eStart, SwDocPositions eEnd );
836 /// @return reference set in document according to given name.
837 const SwFormatRefMark* GetRefMark( std::u16string_view rName ) const;
839 /** @return names of all references set in document.
840 If ArrayPointer == 0 then return only whether a RefMark is set in document. */
841 sal_uInt16 GetRefMarks( std::vector<OUString>* = nullptr ) const;
843 /// Call AutoCorrect
844 void AutoCorrect( SvxAutoCorrect& rACorr, bool bInsertMode,
845 sal_Unicode cChar );
846 OUString GetPrevAutoCorrWord(SvxAutoCorrect& rACorr);
848 // We consider no more than 9 characters before the cursor, and they must not start in the
849 // middle of a word (leading spaces are OK)
850 std::vector<OUString> GetChunkForAutoText();
852 /// Set our styles according to the respective rules.
853 void AutoFormat( const SvxSwAutoFormatFlags* pAFlags, bool bCurrentParagraphOnly );
855 SW_DLLPUBLIC static SvxSwAutoFormatFlags* GetAutoFormatFlags();
856 SW_DLLPUBLIC static void SetAutoFormatFlags(SvxSwAutoFormatFlags const *);
858 /// Calculates selection.
859 OUString Calculate();
861 bool InsertURL( const SwFormatINetFormat& rFormat, const OUString& rStr,
862 bool bKeepSelection = false );
863 void GetINetAttrs(SwGetINetAttrs& rArr , bool bIncludeInToxContent = true);
865 SW_DLLPUBLIC OUString GetDropText( const sal_Int32 nChars ) const;
866 void ReplaceDropText( const OUString &rStr, SwPaM* pPaM = nullptr );
868 /** May an outline be moved or copied?
869 Check whether it's in text body, not in table, and not read-only (move). */
870 bool IsOutlineMovable( SwOutlineNodes::size_type nIdx ) const;
871 bool IsOutlineCopyable( SwOutlineNodes::size_type nIdx ) const;
873 SW_DLLPUBLIC sal_Int32 GetLineCount();
875 /// Query and set footnote-text/number. Set... to current SSelection!
876 SW_DLLPUBLIC bool GetCurFootnote( SwFormatFootnote* pToFillFootnote = nullptr );
877 SW_DLLPUBLIC bool SetCurFootnote( const SwFormatFootnote& rFillFootnote );
878 SW_DLLPUBLIC bool HasFootnotes( bool bEndNotes = false ) const;
880 SW_DLLPUBLIC size_t GetSeqFootnoteList( SwSeqFieldList& rList, bool bEndNotes = false );
881 /// @return list of all footnotes and their first portions of text.
883 SW_DLLPUBLIC SwSection const* InsertSection(
884 SwSectionData & rNewData, SfxItemSet const*const = nullptr );
885 SW_DLLPUBLIC bool IsInsRegionAvailable() const;
886 SW_DLLPUBLIC const SwSection* GetCurrSection() const;
888 /** @return current range like Cet CurrSection(). But this function iterates
889 also over frames and catches the range even if the cursor is positioned in
890 a footnote the reference of which is in a columned range.
891 If bOutOfTab is set, the range comprising the table is searched
892 and not an inner one. */
893 SwSection* GetAnySection( bool bOutOfTab = false, const Point* pPt = nullptr );
895 SW_DLLPUBLIC size_t GetSectionFormatCount() const;
896 SW_DLLPUBLIC size_t GetSectionFormatPos(const SwSectionFormat&) const;
897 SW_DLLPUBLIC const SwSectionFormat& GetSectionFormat(size_t nFormat) const;
898 SW_DLLPUBLIC void DelSectionFormat( size_t nFormat);
899 SW_DLLPUBLIC void UpdateSection( size_t const nSect, SwSectionData &,
900 SfxItemSet const*const = nullptr);
901 bool IsAnySectionInDoc() const;
903 SW_DLLPUBLIC OUString GetUniqueSectionName( const OUString* pChkStr = nullptr ) const;
905 /// Set attributes.
906 SW_DLLPUBLIC void SetSectionAttr(const SfxItemSet& rSet, SwSectionFormat* pSectFormat = nullptr);
908 /** Search inside the cursor selection for full selected sections.
909 if any part of section in the selection @return 0.
910 if more than one in the selection return the count. */
911 SW_DLLPUBLIC sal_uInt16 GetFullSelectedSectionCount() const;
913 /** Special insert: Insert a new text node just before or after a section or
914 table, if the cursor is positioned at the start/end of said
915 section/table. The purpose of the method is to allow users to inert text
916 at certain 'impossible' position, e.g. before a table at the document
917 start or between to sections. */
918 void DoSpecialInsert();
919 bool CanSpecialInsert() const;
921 /// Optimizing UI.
922 void SetNewDoc();
924 SW_DLLPUBLIC sfx2::LinkManager& GetLinkManager();
925 inline const sfx2::LinkManager& GetLinkManager() const;
927 /** Adjust left margin via object bar (similar to adjustment of numerations).
928 One can either change the margin "by" adding or subtracting a given
929 offset or set it "to" this position @param (bModulus = true). */
930 bool IsMoveLeftMargin( bool bRight, bool bModulus = true ) const;
931 void MoveLeftMargin( bool bRight, bool bModulus = true );
933 /// Query NumberFormatter from document.
934 SW_DLLPUBLIC SvNumberFormatter* GetNumberFormatter();
935 const SvNumberFormatter* GetNumberFormatter() const
936 { return const_cast<SwEditShell*>(this)->GetNumberFormatter(); }
938 /// Interfaces for GlobalDocument.
939 bool IsGlobalDoc() const;
940 void SetGlblDocSaveLinks( bool bFlag );
941 bool IsGlblDocSaveLinks() const;
942 void GetGlobalDocContent( SwGlblDocContents& rArr ) const;
943 void InsertGlobalDocContent( const SwGlblDocContent& rPos,
944 SwSectionData & rNew );
945 bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
946 const SwTOXBase& rTOX );
947 bool InsertGlobalDocContent( const SwGlblDocContent& rPos );
948 void DeleteGlobalDocContent( const SwGlblDocContents& rArr,
949 size_t nPos );
950 bool MoveGlobalDocContent( const SwGlblDocContents& rArr ,
951 size_t nFromPos, size_t nToPos,
952 size_t nNewPos );
953 void GotoGlobalDocContent( const SwGlblDocContent& rPos );
955 /// For Redlining.
956 SW_DLLPUBLIC RedlineFlags GetRedlineFlags() const;
957 SW_DLLPUBLIC void SetRedlineFlags( RedlineFlags eMode );
958 bool IsRedlineOn() const;
959 SW_DLLPUBLIC SwRedlineTable::size_type GetRedlineCount() const;
960 const SwRangeRedline& GetRedline( SwRedlineTable::size_type nPos ) const;
961 SW_DLLPUBLIC bool AcceptRedline( SwRedlineTable::size_type nPos );
962 SW_DLLPUBLIC bool RejectRedline( SwRedlineTable::size_type nPos );
963 bool AcceptRedlinesInSelection();
964 bool RejectRedlinesInSelection();
966 /** Search Redline for this Data and @return position in array.
967 If not found, return SwRedlineTable::npos. */
968 SwRedlineTable::size_type FindRedlineOfData( const SwRedlineData& ) const;
970 /// Set comment to Redline at position.
971 bool SetRedlineComment( const OUString& rS );
972 const SwRangeRedline* GetCurrRedline() const;
974 /// Redline attributes have been changed. Updated views.
975 SW_DLLPUBLIC void UpdateRedlineAttr();
977 /// Compare two documents.
978 tools::Long CompareDoc( const SwDoc& rDoc );
980 /// Merge two documents.
981 SW_DLLPUBLIC tools::Long MergeDoc( const SwDoc& rDoc );
983 /// Footnote attributes global to document.
984 SW_DLLPUBLIC const SwFootnoteInfo& GetFootnoteInfo() const;
985 SW_DLLPUBLIC void SetFootnoteInfo(const SwFootnoteInfo& rInfo);
986 SW_DLLPUBLIC const SwEndNoteInfo& GetEndNoteInfo() const;
987 SW_DLLPUBLIC void SetEndNoteInfo(const SwEndNoteInfo& rInfo);
989 SW_DLLPUBLIC const SwLineNumberInfo &GetLineNumberInfo() const;
990 SW_DLLPUBLIC void SetLineNumberInfo( const SwLineNumberInfo& rInfo);
992 /// Labels: Synchronize ranges.
993 void SetLabelDoc( bool bFlag );
994 SW_DLLPUBLIC bool IsLabelDoc() const;
996 /// Interface for TextInputData - (for input of Japanese/Chinese chars.)
997 void CreateExtTextInput(LanguageType eInputLanguage);
998 OUString DeleteExtTextInput( bool bInsText = true);
999 void SetExtTextInputData( const CommandExtTextInputData& );
1001 /// Returns true iff paragraph signature validation is enabled.
1002 bool IsParagraphSignatureValidationEnabled() const { return m_bDoParagraphSignatureValidation; }
1003 /// Enable/Disable paragraph signature validation and return the previous value.
1004 bool SetParagraphSignatureValidation(const bool bEnable)
1006 const bool bOldFlag = m_bDoParagraphSignatureValidation;
1007 m_bDoParagraphSignatureValidation = bEnable;
1008 return bOldFlag;
1011 /// Interface for access to AutoComplete-list.
1012 static SwAutoCompleteWord& GetAutoCompleteWords();
1014 /** @return a scaling factor of selected text. Used for the rotated
1015 character attribute dialog. */
1016 sal_uInt16 GetScalingOfSelectedText() const;
1018 bool IsNbspRunNext() const { return m_bNbspRunNext; }
1020 /// Ctor/Dtor.
1021 SwEditShell( SwDoc&, vcl::Window*, const SwViewOption *pOpt );
1023 /// Copy-Constructor in disguise.
1024 SwEditShell( SwEditShell&, vcl::Window* );
1025 virtual ~SwEditShell() override;
1027 private:
1028 SwEditShell(const SwEditShell &) = delete;
1029 const SwEditShell &operator=(const SwEditShell &) = delete;
1031 /* TODO: this flag may have to be invalidated / reset to false at various
1032 * places if it was true and the edit cursor position changes. It's somehow
1033 * overkill though because it can only be true if a NO-BREAK SPACE was
1034 * inserted by the last DoAutoCorrect() call (in French language), any
1035 * subsequent call will reset it anyway and just if the cursor is
1036 * positioned behind "x :" and the next character inserted is not a space
1037 * the existing nb-space will be removed. Bear this in mind if that problem
1038 * arises. */
1039 bool m_bNbspRunNext; ///< NO-BREAK SPACE state flag passed to and maintained by SvxAutoCorrect::DoAutoCorrect()
1040 bool m_bDoParagraphSignatureValidation; ///< Prevent nested calls of ValidateParagraphSignatures.
1043 inline const sfx2::LinkManager& SwEditShell::GetLinkManager() const
1044 { return const_cast<SwEditShell*>(this)->GetLinkManager(); }
1046 /// Class for automated call of Start- and EndAction().
1047 class SwActContext {
1048 SwEditShell & m_rShell;
1049 public:
1050 SwActContext(SwEditShell *pShell);
1051 ~SwActContext() COVERITY_NOEXCEPT_FALSE;
1054 /// Class for automated call of Start- and EndCursorMove().
1055 class SwMvContext {
1056 SwEditShell & m_rShell;
1057 public:
1058 SwMvContext(SwEditShell *pShell);
1059 ~SwMvContext() COVERITY_NOEXCEPT_FALSE;
1062 #endif
1064 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */