lok: Hide file linking in section
[LibreOffice.git] / sw / inc / editsh.hxx
blob53b91f44db9837d48d0376d58de7488d177dafbc
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 <vector>
34 #include <set>
36 namespace tools { class PolyPolygon; }
37 class SwDoc;
38 class CommandExtTextInputData;
40 class SvNumberFormatter;
41 class SfxPoolItem;
42 class SfxItemSet;
43 class SfxWatermarkItem;
44 class SvxAutoCorrect;
46 class SwDDEFieldType;
47 class SwDBManager;
49 struct SwDocStat;
50 class SwAutoCompleteWord;
52 class SwFormatRefMark;
54 class SwNumRule;
56 class SwTextFormatColl;
57 class SwGrfNode;
59 class Graphic;
60 class GraphicObject;
61 class GraphicAttr;
62 class SwFormatINetFormat;
63 class SwTable;
64 class SwTextBlocks;
65 class SwFormatFootnote;
66 class SwSection;
67 class SwSectionData;
68 class SwSectionFormat;
69 class SwTableAutoFormat;
70 class SwPageDesc;
71 class SwTextINetFormat;
72 class SwSeqFieldList;
73 class SwGlblDocContent;
74 class SwGlblDocContents;
75 class SwRangeRedline;
76 class SwRedlineData;
77 class SwFootnoteInfo;
78 class SwEndNoteInfo;
79 class SwLineNumberInfo;
80 class SwAuthEntry;
81 class SwRewriter;
82 class SwView;
83 struct SwConversionArgs;
84 struct SvxSwAutoFormatFlags;
85 struct SwInsertTableOptions;
86 struct SwDBData;
87 enum class SvtScriptType;
88 enum class SfxClassificationPolicyType;
89 enum class RedlineFlags;
90 enum class TransliterationFlags;
91 enum class GraphicType;
93 namespace com { namespace sun { namespace star { namespace uno {
94 template < class > class Sequence;
95 }}}}
96 namespace com { namespace sun { namespace star { namespace linguistic2 { class XSpellAlternatives; } } } }
97 namespace com { namespace sun { namespace star { namespace 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 const sText;
122 const SwTextINetFormat& rINetAttr;
124 SwGetINetAttr( const OUString& rText, const SwTextINetFormat& rAttr )
125 : sText( rText ), 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* pUndo = nullptr );
157 SAL_DLLPRIVATE void SetSectionAttr_( SwSectionFormat& rSectFormat, const SfxItemSet& rSet );
159 using SwViewShell::UpdateFields;
160 using SwModify::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();
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 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* pDestShell );
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* pInsDoc );
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 * @return true if the function inspects all the nodes point by the pPaM parameter,
264 * false if the function reaches the limit of getMaxLookup number of nodes inspected.
266 bool GetPaMParAttr( SwPaM* pPaM, SfxItemSet& rSet ) const;
268 /// Set attribute as new default attribute in document.
269 void SetDefault( const SfxPoolItem& );
271 /// Query default attribute of document.
272 const SfxPoolItem& GetDefault( sal_uInt16 nFormatHint ) const;
273 template<class T> const T& GetDefault( TypedWhichId<T> nWhich ) const
275 return static_cast<const T&>(GetDefault(sal_uInt16(nWhich)));
278 void ResetAttr( const std::set<sal_uInt16> &attrs = std::set<sal_uInt16>(), SwPaM* pCursor = nullptr );
279 void GCAttr();
281 /// @return the scripttype of the selection.
282 SvtScriptType GetScriptType() const;
284 /// @return the language at current cursor position.
285 LanguageType GetCurLang() const;
287 /// TABLE
288 size_t GetTableFrameFormatCount( bool bUsed = false ) const;
289 SwFrameFormat& GetTableFrameFormat(size_t nFormat, bool bUsed = false ) const;
290 OUString GetUniqueTableName() const;
292 /// CHAR
293 sal_uInt16 GetCharFormatCount() const;
294 SwCharFormat& GetCharFormat(sal_uInt16 nFormat) const;
295 SwCharFormat* GetCurCharFormat() const;
296 void FillByEx(SwCharFormat*);
297 SwCharFormat* MakeCharFormat( const OUString& rName );
298 SwCharFormat* FindCharFormatByName( const OUString& rName ) const;
300 /* FormatCollections (new) - Explaining the general naming pattern:
301 * GetXXXCount() returns the count of xxx in the document.
302 * GetXXX(i) returns i-th xxx (ERR_RAISE if beyond range!).
303 * DelXXX(i) deletes i-th xxx (ERR_RAISE if beyond range!).
304 * GetCurXXX() returns xxx that is valid at cursor or in ranges.
305 * returns 0, if not unanimous.
306 * SetXXX() sets xxx at cursor or in ranges.
307 * MakeXXX() makes a xxx, derived from pDerivedFrom.
310 // TXT
311 SwTextFormatColl& GetDfltTextFormatColl() const;
312 sal_uInt16 GetTextFormatCollCount() const;
313 SwTextFormatColl& GetTextFormatColl( sal_uInt16 nTextFormatColl) const;
315 * Get the named paragraph format of the current selection.
317 * @see GetPaMTextFormatColl()
319 * @return the named paragraph format of the first node that contains one.
320 * Nodes are sort by order of appearance in the selections ;
321 * selections are sort by their order of creation
322 * (last created selection first, oldest selection at last).
324 SwTextFormatColl* GetCurTextFormatColl() const;
326 * Get the named paragraph format of the selection(s) described by a SwPaM.
328 * @param pPaM
329 * input parameter - the selection where to look for the paragraph format.
331 * @return the named paragraph format of the first node that contains one.
333 SwTextFormatColl* GetPaMTextFormatColl( SwPaM* pPaM ) const;
335 // #i62675#
336 /// Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTextFormatColl(..)>
337 void SetTextFormatColl(SwTextFormatColl*, const bool bResetListAttrs = false);
338 SwTextFormatColl *MakeTextFormatColl(const OUString &rFormatCollName,
339 SwTextFormatColl *pDerivedFrom = nullptr);
340 void FillByEx(SwTextFormatColl*);
341 SwTextFormatColl* FindTextFormatCollByName( const OUString& rName ) const;
343 /// @return "Auto-Collection" with given Id. If it does not exist create it.
344 SwTextFormatColl* GetTextCollFromPool( sal_uInt16 nId );
346 /// @return required automatic format base class.
347 SwFormat* GetFormatFromPool( sal_uInt16 nId );
349 /// @return required automatic page style.
350 SwPageDesc* GetPageDescFromPool( sal_uInt16 nId );
352 /// Query if the paragraph-/character-/frame-/page-style is used.
353 bool IsUsed( const SwModify& ) const;
355 /// @return required automatic format.
356 SwFrameFormat* GetFrameFormatFromPool( sal_uInt16 nId )
357 { return static_cast<SwFrameFormat*>(SwEditShell::GetFormatFromPool( nId )); }
358 SwCharFormat* GetCharFormatFromPool( sal_uInt16 nId )
359 { return static_cast<SwCharFormat*>(SwEditShell::GetFormatFromPool( nId )); }
361 void SetClassification(const OUString& rName, SfxClassificationPolicyType eType);
362 void ApplyAdvancedClassification(std::vector<svx::ClassificationResult> const & rResult);
363 std::vector<svx::ClassificationResult> CollectAdvancedClassification();
365 SfxWatermarkItem GetWatermark() const;
366 void SetWatermark(const SfxWatermarkItem& rText);
368 /// Sign the paragraph at the cursor.
369 void SignParagraph();
371 /// Validate the paragraph signatures, if any, of the current text node.
372 void ValidateParagraphSignatures(SwTextNode* pNode, bool updateDontRemove);
374 /// Validate the current paragraph signatures, if any, at the cursor start.
375 void ValidateCurrentParagraphSignatures(bool updateDontRemove);
377 /// Validate all paragraph signatures.
378 void ValidateAllParagraphSignatures(bool updateDontRemove);
380 /// Restore the metadata fields, if missing, from the RDF metadata
381 /// and validate the signatures and update the signature metadata fields.
382 /// Needed since deleting the metadata field doesn't remove the RDF
383 /// and editing docs using software that don't support paragraph signing.
384 void RestoreMetadataFieldsAndValidateParagraphSignatures();
386 /// Ensure that the classification of the doc is never lower than
387 /// the paragraph with the highest classification.
388 void ClassifyDocPerHighestParagraphClass();
390 /// Apply the classification to the paragraph at cursor.
391 void ApplyParagraphClassification(std::vector<svx::ClassificationResult> aResult);
392 std::vector<svx::ClassificationResult> CollectParagraphClassification();
394 /// Returns true iff the cursor is within a paragraph metadata field.
395 /// Currently there are two variants: signature and classification.
396 bool IsCursorInParagraphMetadataField() const;
398 /// Removes the paragraph metadata field at the current cursor, if any.
399 /// Returns true iff a paragraph metadata field was removed.
400 /// Currently there are two variants: signature and classification.
401 bool RemoveParagraphMetadataFieldAtCursor();
403 void Insert2(SwField const &, const bool bForceExpandHints);
405 void UpdateOneField(SwField &); ///< One single field.
407 size_t GetFieldTypeCount(SwFieldIds nResId = SwFieldIds::Unknown) const;
408 SwFieldType* GetFieldType(size_t nField, SwFieldIds nResId = SwFieldIds::Unknown) const;
409 SwFieldType* GetFieldType(SwFieldIds nResId, const OUString& rName) const;
411 void RemoveFieldType(size_t nField);
412 void RemoveFieldType(SwFieldIds nResId, const OUString& rName);
414 void FieldToText( SwFieldType const * pType );
416 void ChangeAuthorityData(const SwAuthEntry* pNewData);
418 /// Database information.
419 SwDBData const & GetDBData() const;
420 const SwDBData& GetDBDesc() const;
421 void ChgDBData(const SwDBData& SwDBData);
422 void ChangeDBFields( const std::vector<OUString>& rOldNames,
423 const OUString& rNewName );
424 void GetAllUsedDB( std::vector<OUString>& rDBNameList,
425 std::vector<OUString> const * pAllDBNames );
427 bool IsAnyDatabaseFieldInDoc()const;
429 /// Check whether DB fields point to an available data source and returns it.
430 bool IsFieldDataSourceAvailable(OUString& rUsedDataSource) const;
431 void UpdateExpFields(bool bCloseDB = false);///< only every expression fields update
432 void LockExpFields();
433 void UnlockExpFields();
434 bool IsExpFieldsLocked() const;
436 SwFieldUpdateFlags GetFieldUpdateFlags() const;
437 void SetFieldUpdateFlags( SwFieldUpdateFlags eFlags );
439 /// For evaluation of DB fields (new DB-manager).
440 SwDBManager* GetDBManager() const;
442 SwFieldType* InsertFieldType(const SwFieldType &);
444 /// Changes in document?
445 bool IsModified() const;
446 void SetModified();
447 void ResetModified();
448 void SetUndoNoResetModified();
450 /// Document - Statistics
451 void UpdateDocStat();
452 const SwDocStat &GetUpdatedDocStat();
454 void Insert(const SwTOXMark& rMark);
456 void DeleteTOXMark(SwTOXMark const * pMark);
458 /// Get all marks at current SPoint.
459 void GetCurTOXMarks(SwTOXMarks& rMarks) const ;
461 /// Insert content table. Renew if required.
462 void InsertTableOf(const SwTOXBase& rTOX,
463 const SfxItemSet* pSet = nullptr);
464 void UpdateTableOf(const SwTOXBase& rTOX,
465 const SfxItemSet* pSet = nullptr);
466 const SwTOXBase* GetCurTOX() const;
467 const SwTOXBase* GetDefaultTOXBase( TOXTypes eTyp, bool bCreate = false );
468 void SetDefaultTOXBase(const SwTOXBase& rBase);
470 static bool IsTOXBaseReadonly(const SwTOXBase& rTOXBase);
471 void SetTOXBaseReadonly(const SwTOXBase& rTOXBase, bool bReadonly);
473 sal_uInt16 GetTOXCount() const;
474 const SwTOXBase* GetTOX( sal_uInt16 nPos ) const;
475 bool DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes );
477 /// After reading file update all content tables.
478 void SetUpdateTOX( bool bFlag );
479 bool IsUpdateTOX() const;
481 /// Manage types of content tables.
482 sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const;
483 const SwTOXType* GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const;
484 void InsertTOXType(const SwTOXType& rTyp);
486 /// AutoMark file
487 OUString const & GetTOIAutoMarkURL() const;
488 void SetTOIAutoMarkURL(const OUString& rSet);
489 void ApplyAutoMark();
491 /// Key for managing index.
492 void GetTOIKeys( SwTOIKeyType eTyp, std::vector<OUString>& rArr ) const;
494 void SetOutlineNumRule(const SwNumRule&);
495 const SwNumRule* GetOutlineNumRule() const;
497 bool OutlineUpDown( short nOffset = 1 );
499 bool MoveOutlinePara( SwOutlineNodes::difference_type nOffset );
501 bool IsProtectedOutlinePara() const;
503 const SwNumRule* GetNumRuleAtCurrCursorPos() const;
505 /** Returns the numbering rule found at the paragraphs of the current selection,
506 if all paragraphs of the current selection have the same or none numbering rule applied. */
507 const SwNumRule* GetNumRuleAtCurrentSelection() const;
509 /** Optional parameter <bResetIndentAttrs> (default value false).
510 If <bResetIndentAttrs> equals true, the indent attributes "before text"
511 and "first line indent" are additionally reset at the current selection,
512 if the list style makes use of the new list level attributes.
513 Parameters <bCreateNewList> and <sContinuedListId>
514 <bCreateNewList> indicates, if a new list is created by applying the given list style.
515 If <bCreateNewList> equals false, <sContinuedListId> may contain the
516 list Id of a list, which has to be continued by applying the given list style */
517 void SetCurNumRule( const SwNumRule&,
518 const bool bCreateNewList /*= false*/,
519 const OUString& sContinuedListId = OUString(),
520 const bool bResetIndentAttrs = false );
522 /// Paragraphs without enumeration but with indents.
523 void NoNum();
525 /// Delete, split enumeration list.
526 void DelNumRules();
528 void NumUpDown( bool bDown = true );
530 bool MoveParagraph( long nOffset = 1);
531 bool MoveNumParas( bool bUpperLower, bool bUpperLeft );
533 /// Switch on/off of numbering via Delete/Backspace.
534 bool NumOrNoNum(bool bDelete = false, bool bChkStart = true);
536 // #i23726#
537 // #i90078#
538 /// Remove unused default parameter <nLevel> and <bRelative>.
539 // Adjust method name and parameter name
540 void ChangeIndentOfAllListLevels( sal_Int32 nDiff );
541 // Adjust method name
542 void SetIndent(short nIndent, const SwPosition & rPos);
543 bool IsFirstOfNumRuleAtCursorPos() const;
545 bool IsNoNum( bool bChkStart = true ) const;
547 /** @return Num-Level of the node in which point of cursor is.
548 @return values can be: NO_NUMBERING,
549 0..MAXLEVEL-1, NO_NUMLEVEL .. NO_NUMLEVEL|MAXLEVEL-1 */
550 sal_uInt8 GetNumLevel() const;
552 /// Detect highest and lowest level to check moving of outline levels.
553 void GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower );
555 /// Get Outline level of current paragraph.
556 int GetCurrentParaOutlineLevel( ) const;
558 // i29560
559 bool HasNumber() const;
560 bool HasBullet() const;
562 bool SelectionHasNumber() const;
563 bool SelectionHasBullet() const;
565 OUString GetUniqueNumRuleName() const;
566 void ChgNumRuleFormats( const SwNumRule& rRule );
568 /// Set (and query if) a numbering with StartFlag starts at current PointPos.
569 void SetNumRuleStart( bool bFlag, SwPaM* pCursor );
570 bool IsNumRuleStart( SwPaM* pPaM = nullptr ) const;
571 void SetNodeNumStart( sal_uInt16 nStt );
573 sal_uInt16 GetNodeNumStart( SwPaM* pPaM ) const;
575 void ReplaceNumRule( const OUString& rOldRule, const OUString& rNewRule );
577 /** Searches for a text node with a numbering rule.
578 in case a list style is found, <sListId> holds the list id, to which the
579 text node belongs, which applies the found list style. */
580 const SwNumRule * SearchNumRule(const bool bNum,
581 OUString& sListId );
583 /** Undo.
584 Maintain UndoHistory in Document.
585 Reset UndoHistory at Save, SaveAs, Create ??? */
586 void DoUndo( bool bOn = true );
587 bool DoesUndo() const;
588 void DoGroupUndo( bool bUn );
589 bool DoesGroupUndo() const;
590 void DelAllUndoObj();
592 /// Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
593 SwUndoId StartUndo( SwUndoId eUndoId = SwUndoId::EMPTY, const SwRewriter * pRewriter = nullptr );
595 /// Closes parenthesis of nUndoId, not used by UI.
596 SwUndoId EndUndo( SwUndoId eUndoId = SwUndoId::EMPTY, const SwRewriter * pRewriter = nullptr );
598 bool GetLastUndoInfo(OUString *const o_pStr,
599 SwUndoId *const o_pId,
600 const SwView* pView = nullptr) const;
601 bool GetFirstRedoInfo(OUString *const o_pStr,
602 SwUndoId *const o_pId,
603 const SwView* pView = nullptr) const;
604 SwUndoId GetRepeatInfo(OUString *const o_pStr) const;
606 /// is it forbidden to modify cursors via API calls?
607 bool CursorsLocked() const;
608 /// set selections to those contained in the UndoRedoContext
609 /// should only be called by sw::UndoManager!
610 void HandleUndoRedoContext(::sw::UndoRedoContext & rContext);
612 void Undo(sal_uInt16 const nCount = 1);
613 void Redo(sal_uInt16 const nCount = 1);
614 void Repeat(sal_uInt16 const nCount);
616 /// For all views of this document.
617 void StartAllAction();
618 void EndAllAction();
620 /// To enable set up of StartActions and EndActions.
621 virtual void CalcLayout() override;
623 /// Determine form of content. Return Type at CurrentCursor->SPoint.
624 sal_uInt16 GetCntType() const;
626 /// Are there frames, footnotes, etc.
627 bool HasOtherCnt() const;
629 /// Apply ViewOptions with Start-/EndAction.
630 virtual void ApplyViewOptions( const SwViewOption &rOpt ) override;
632 /** Query text within selection. */
633 void GetSelectedText( OUString &rBuf,
634 ParaBreakType nHndlParaBreak = ParaBreakType::ToBlank );
636 /** @return graphic, if CurrentCursor->Point() points to a SwGrfNode
637 (and mark is not set or points to the same graphic). */
639 const Graphic* GetGraphic( bool bWait = true ) const;
640 const GraphicObject* GetGraphicObj() const;
641 const GraphicAttr* GetGraphicAttr( GraphicAttr& rGA ) const;
643 bool IsLinkedGrfSwapOut() const;
644 GraphicType GetGraphicType() const;
646 const tools::PolyPolygon *GetGraphicPolygon() const;
647 void SetGraphicPolygon( const tools::PolyPolygon *pPoly );
649 /** If there's an automatic, not manipulated polygon at the selected
650 notxtnode, it has to be deleted, e.g. cause the object has changed. */
651 void ClearAutomaticContour();
653 /// @return the size of a graphic in Twips if cursor is in a graphic.
654 bool GetGrfSize(Size&) const;
656 /** @return name and filter of a graphic if the cursor is in a graphic,
657 else give a rap on the knuckles!
658 If a string-ptr != 0 return the respective name. */
659 void GetGrfNms( OUString* pGrfName, OUString* pFltName,
660 const SwFlyFrameFormat* = nullptr ) const;
662 /// Re-read if graphic is not ok. Current graphic is replaced by the new one.
663 void ReRead( const OUString& rGrfName, const OUString& rFltName,
664 const Graphic* pGraphic = nullptr );
666 /// Unique identification of object (for ImageMapDlg).
667 void *GetIMapInventor() const;
669 // #i73788#
670 /// Remove default parameter, because method always called this default value.
671 Graphic GetIMapGraphic() const; ///< @return a graphic for all Flys!
672 const SwFlyFrameFormat* FindFlyByName( const OUString& rName ) const;
674 /** @return a ClientObject, if CurrentCursor->Point() points to a SwOLENode
675 (and mark is neither set not pointint to same ClientObject)
676 else give rap on the knuckles. */
677 svt::EmbeddedObjectRef& GetOLEObject() const;
679 /// Is there an OLEObject with this name (SwFormat)?
680 bool HasOLEObj( const OUString &rName ) const;
682 /// @return pointer to the data of the chart in which Cursr is.
683 void SetChartName( const OUString &rName );
685 /// Update content of all charts for table with given name.
686 void UpdateCharts( const OUString &rName );
688 OUString GetCurWord() const;
690 /** Glossary from glossary document in current document.
691 Styles only if not already existent. */
692 void InsertGlossary( SwTextBlocks& rGlossary, const OUString& );
694 /** Make current selection glossary and insert into glossary document
695 including styles. */
696 sal_uInt16 MakeGlossary( SwTextBlocks& rToFill, const OUString& rName,
697 const OUString& rShortName, bool bSaveRelFile,
698 const OUString* pOnlyText );
700 /// Save complete content of doc as glossary.
701 sal_uInt16 SaveGlossaryDoc( SwTextBlocks& rGlossary, const OUString& rName,
702 const OUString& rShortName,
703 bool bSaveRelFile,
704 bool bOnlyText );
706 // Linguistics...
707 /// Save selections.
708 void HyphStart( SwDocPositions eStart, SwDocPositions eEnd );
710 /// restore selections.
711 void HyphEnd();
712 css::uno::Reference< css::uno::XInterface>
713 HyphContinue( sal_uInt16* pPageCnt, sal_uInt16* pPageSt );
715 void HyphIgnore();
717 /// For Inserting SoftHyphen. Position is offset within the syllabificated word.
718 static void InsertSoftHyph( const sal_Int32 nHyphPos );
720 const SwTable& InsertTable( const SwInsertTableOptions& rInsTableOpts, ///< All
721 sal_uInt16 nRows, sal_uInt16 nCols,
722 const SwTableAutoFormat* pTAFormat = nullptr );
724 void InsertDDETable( const SwInsertTableOptions& rInsTableOpts, ///< HeadlineNoBorder
725 SwDDEFieldType* pDDEType,
726 sal_uInt16 nRows, sal_uInt16 nCols );
728 void UpdateTable();
729 void SetTableName( SwFrameFormat& rTableFormat, const OUString &rNewName );
731 SwFrameFormat *GetTableFormat();
732 bool TextToTable( const SwInsertTableOptions& rInsTableOpts, ///< All
733 sal_Unicode cCh,
734 const SwTableAutoFormat* pTAFormat = nullptr );
735 bool TableToText( sal_Unicode cCh );
736 bool IsTextToTableAvailable() const;
738 bool GetTableBoxFormulaAttrs( SfxItemSet& rSet ) const;
739 void SetTableBoxFormulaAttrs( const SfxItemSet& rSet );
741 bool IsTableBoxTextFormat() const;
742 OUString GetTableBoxText() const;
744 TableChgMode GetTableChgMode() const;
745 void SetTableChgMode( TableChgMode eMode );
747 /// Split table at cursor position.
748 void SplitTable( SplitTable_HeadlineOption eMode );
750 /** Merge tables.
752 Can Merge checks if Prev or Next are possible.
753 If pointer pChkNxtPrv is passed possible direction is given. */
754 bool CanMergeTable( bool bWithPrev = true, bool* pChkNxtPrv = nullptr ) const;
755 bool MergeTable( bool bWithPrev );
757 /// Set up InsertDB as table Undo.
758 void AppendUndoForInsertFromDB( bool bIsTable );
760 /// Functions used for spell checking and text conversion.
762 /// Save selections.
763 void SpellStart( SwDocPositions eStart, SwDocPositions eEnd,
764 SwDocPositions eCurr, SwConversionArgs *pConvArgs = nullptr );
766 /// Restore selections.
767 void SpellEnd( SwConversionArgs const *pConvArgs = nullptr, bool bRestoreSelection = true );
768 css::uno::Any SpellContinue(
769 sal_uInt16* pPageCnt, sal_uInt16* pPageSt,
770 SwConversionArgs const *pConvArgs );
772 /** Spells on a sentence basis - the SpellPortions are needed
773 @return false if no error could be found. */
774 bool SpellSentence(svx::SpellPortions& rToFill, bool bIsGrammarCheck );
776 /// Make SpellIter start with the current sentence when called next time.
777 static void PutSpellingToSentenceStart();
779 /// Moves the continuation position to the end of the currently checked sentence.
780 static void MoveContinuationPosToEndOfCheckedSentence();
782 /// Applies a changed sentence.
783 void ApplyChangedSentence(const svx::SpellPortions& rNewPortions, bool bRecheck);
785 /// Check SwSpellIter data to see if the last sentence got grammar checked.
786 static bool HasLastSentenceGotGrammarChecked();
788 /// Is text conversion active somewhere else?
789 static bool HasConvIter();
791 /// Is hyphenation active somewhere else?
792 static bool HasHyphIter();
794 void HandleCorrectionError(const OUString& aText, SwPosition aPos, sal_Int32 nBegin,
795 sal_Int32 nLen, const Point* pPt,
796 SwRect& rSelectRect);
797 css::uno::Reference< css::linguistic2::XSpellAlternatives >
798 GetCorrection( const Point* pPt, SwRect& rSelectRect );
800 bool GetGrammarCorrection( css::linguistic2::ProofreadingResult /*out*/ &rResult,
801 sal_Int32 /*out*/ &rErrorPosInText,
802 sal_Int32 /*out*/ &rErrorIndexInResult,
803 css::uno::Sequence< OUString > /*out*/ &rSuggestions,
804 const Point* pPt, SwRect& rSelectRect );
806 static void IgnoreGrammarErrorAt( SwPaM& rErrorPosition );
807 void SetLinguRange( SwDocPositions eStart, SwDocPositions eEnd );
809 /// @return reference set in document according to given name.
810 const SwFormatRefMark* GetRefMark( const OUString& rName ) const;
812 /** @return names of all references set in document.
813 If ArrayPointer == 0 then return only whether a RefMark is set in document. */
814 sal_uInt16 GetRefMarks( std::vector<OUString>* = nullptr ) const;
816 /// Call AutoCorrect
817 void AutoCorrect( SvxAutoCorrect& rACorr, bool bInsertMode,
818 sal_Unicode cChar );
819 OUString GetPrevAutoCorrWord(SvxAutoCorrect& rACorr);
821 // We consider no more than 9 characters before the cursor, and they must not start in the
822 // middle of a word (leading spaces are OK)
823 std::vector<OUString> GetChunkForAutoText();
825 /// Set our styles according to the respective rules.
826 void AutoFormat( const SvxSwAutoFormatFlags* pAFlags );
828 static SvxSwAutoFormatFlags* GetAutoFormatFlags();
829 static void SetAutoFormatFlags(SvxSwAutoFormatFlags const *);
831 /// Calculates selection.
832 OUString Calculate();
834 bool InsertURL( const SwFormatINetFormat& rFormat, const OUString& rStr,
835 bool bKeepSelection = false );
836 void GetINetAttrs( SwGetINetAttrs& rArr );
838 OUString GetDropText( const sal_Int32 nChars ) const;
839 void ReplaceDropText( const OUString &rStr, SwPaM* pPaM = nullptr );
841 /** May an outline be moved or copied?
842 Check whether it's in text body, not in table, and not read-only (move). */
843 bool IsOutlineMovable( SwOutlineNodes::size_type nIdx ) const;
844 bool IsOutlineCopyable( SwOutlineNodes::size_type nIdx ) const;
846 sal_uInt16 GetLineCount();
848 /// Query and set footnote-text/number. Set... to current SSelection!
849 bool GetCurFootnote( SwFormatFootnote* pToFillFootnote = nullptr );
850 bool SetCurFootnote( const SwFormatFootnote& rFillFootnote );
851 bool HasFootnotes( bool bEndNotes = false ) const;
853 size_t GetSeqFootnoteList( SwSeqFieldList& rList, bool bEndNotes = false );
854 /// @return list of all footnotes and their first portions of text.
856 SwSection const* InsertSection(
857 SwSectionData & rNewData, SfxItemSet const*const = nullptr );
858 bool IsInsRegionAvailable() const;
859 const SwSection* GetCurrSection() const;
861 /** @return current range like Cet CurrSection(). But this function iterates
862 also over frames and catches the range even if the cursor is positioned in
863 a footnote the reference of which is in a columned range.
864 If bOutOfTab is set, the range comprising the table is searched
865 and not an inner one. */
866 SwSection* GetAnySection( bool bOutOfTab = false, const Point* pPt = nullptr );
868 size_t GetSectionFormatCount() const;
869 size_t GetSectionFormatPos(const SwSectionFormat&) const;
870 const SwSectionFormat& GetSectionFormat(size_t nFormat) const;
871 void DelSectionFormat( size_t nFormat);
872 void UpdateSection( size_t const nSect, SwSectionData &,
873 SfxItemSet const*const = nullptr);
874 bool IsAnySectionInDoc() const;
876 OUString GetUniqueSectionName( const OUString* pChkStr = nullptr ) const;
878 /// Set attributes.
879 void SetSectionAttr(const SfxItemSet& rSet, SwSectionFormat* pSectFormat = nullptr);
881 /** Search inside the cursor selection for full selected sections.
882 if any part of section in the selection @return 0.
883 if more than one in the selection return the count. */
884 sal_uInt16 GetFullSelectedSectionCount() const;
886 /** Special insert: Insert a new text node just before or after a section or
887 table, if the cursor is positioned at the start/end of said
888 section/table. The purpose of the method is to allow users to inert text
889 at certain 'impossible' position, e.g. before a table at the document
890 start or between to sections. */
891 void DoSpecialInsert();
892 bool CanSpecialInsert() const;
894 /// Optimizing UI.
895 void SetNewDoc();
897 sfx2::LinkManager& GetLinkManager();
898 inline const sfx2::LinkManager& GetLinkManager() const;
900 /** Adjust left margin via object bar (similar to adjustment of numerations).
901 One can either change the margin "by" adding or subtracting a given
902 offset or set it "to" this position @param (bModulus = true). */
903 bool IsMoveLeftMargin( bool bRight, bool bModulus = true ) const;
904 void MoveLeftMargin( bool bRight, bool bModulus = true );
906 /// Query NumberFormatter from document.
907 SvNumberFormatter* GetNumberFormatter();
908 const SvNumberFormatter* GetNumberFormatter() const
909 { return const_cast<SwEditShell*>(this)->GetNumberFormatter(); }
911 /// Interfaces for GlobalDocument.
912 bool IsGlobalDoc() const;
913 void SetGlblDocSaveLinks( bool bFlag );
914 bool IsGlblDocSaveLinks() const;
915 void GetGlobalDocContent( SwGlblDocContents& rArr ) const;
916 void InsertGlobalDocContent( const SwGlblDocContent& rPos,
917 SwSectionData & rNew );
918 bool InsertGlobalDocContent( const SwGlblDocContent& rPos,
919 const SwTOXBase& rTOX );
920 bool InsertGlobalDocContent( const SwGlblDocContent& rPos );
921 void DeleteGlobalDocContent( const SwGlblDocContents& rArr,
922 size_t nPos );
923 bool MoveGlobalDocContent( const SwGlblDocContents& rArr ,
924 size_t nFromPos, size_t nToPos,
925 size_t nNewPos );
926 void GotoGlobalDocContent( const SwGlblDocContent& rPos );
928 /// For Redlining.
929 RedlineFlags GetRedlineFlags() const;
930 void SetRedlineFlags( RedlineFlags eMode );
931 bool IsRedlineOn() const;
932 SwRedlineTable::size_type GetRedlineCount() const;
933 const SwRangeRedline& GetRedline( SwRedlineTable::size_type nPos ) const;
934 bool AcceptRedline( SwRedlineTable::size_type nPos );
935 bool RejectRedline( SwRedlineTable::size_type nPos );
936 bool AcceptRedlinesInSelection();
937 bool RejectRedlinesInSelection();
939 /** Search Redline for this Data and @return position in array.
940 If not found, return SwRedlineTable::npos. */
941 SwRedlineTable::size_type FindRedlineOfData( const SwRedlineData& ) const;
943 /// Set comment to Redline at position.
944 bool SetRedlineComment( const OUString& rS );
945 const SwRangeRedline* GetCurrRedline() const;
947 /// Redline attributes have been changed. Updated views.
948 void UpdateRedlineAttr();
950 /// Compare two documents.
951 long CompareDoc( const SwDoc& rDoc );
953 /// Merge two documents.
954 long MergeDoc( const SwDoc& rDoc );
956 /// Footnote attributes global to document.
957 const SwFootnoteInfo& GetFootnoteInfo() const;
958 void SetFootnoteInfo(const SwFootnoteInfo& rInfo);
959 const SwEndNoteInfo& GetEndNoteInfo() const;
960 void SetEndNoteInfo(const SwEndNoteInfo& rInfo);
962 const SwLineNumberInfo &GetLineNumberInfo() const;
963 void SetLineNumberInfo( const SwLineNumberInfo& rInfo);
965 /// Labels: Synchronize ranges.
966 void SetLabelDoc( bool bFlag );
967 bool IsLabelDoc() const;
969 /// Interface for TextInputData - (for input of Japanese/Chinese chars.)
970 void CreateExtTextInput(LanguageType eInputLanguage);
971 OUString DeleteExtTextInput( bool bInsText = true);
972 void SetExtTextInputData( const CommandExtTextInputData& );
974 /// Returns true iff paragraph signature validation is enabled.
975 bool IsParagraphSignatureValidationEnabled() const { return m_bDoParagraphSignatureValidation; }
976 /// Enable/Disable paragraph signature validation and return the previous value.
977 bool SetParagraphSignatureValidation(const bool bEnable)
979 const bool bOldFlag = m_bDoParagraphSignatureValidation;
980 m_bDoParagraphSignatureValidation = bEnable;
981 return bOldFlag;
984 /// Interface for access to AutoComplete-list.
985 static SwAutoCompleteWord& GetAutoCompleteWords();
987 /** @return a scaling factor of selected text. Used for the rotated
988 character attribute dialog. */
989 sal_uInt16 GetScalingOfSelectedText() const;
991 bool IsNbspRunNext() const { return m_bNbspRunNext; }
993 /// Ctor/Dtor.
994 SwEditShell( SwDoc&, vcl::Window*, const SwViewOption *pOpt );
996 /// Copy-Constructor in disguise.
997 SwEditShell( SwEditShell&, vcl::Window* );
998 virtual ~SwEditShell() override;
1000 private:
1001 SwEditShell(const SwEditShell &) = delete;
1002 const SwEditShell &operator=(const SwEditShell &) = delete;
1004 /* TODO: this flag may have to be invalidated / reset to false at various
1005 * places if it was true and the edit cursor position changes. It's somehow
1006 * overkill though because it can only be true if a NO-BREAK SPACE was
1007 * inserted by the last DoAutoCorrect() call (in French language), any
1008 * subsequent call will reset it anyway and just if the cursor is
1009 * positioned behind "x :" and the next character inserted is not a space
1010 * the existing nb-space will be removed. Bear this in mind if that problem
1011 * arises. */
1012 bool m_bNbspRunNext; ///< NO-BREAK SPACE state flag passed to and maintained by SvxAutoCorrect::DoAutoCorrect()
1013 bool m_bDoParagraphSignatureValidation; ///< Prevent nested calls of ValidateParagraphSignatures.
1016 inline const sfx2::LinkManager& SwEditShell::GetLinkManager() const
1017 { return const_cast<SwEditShell*>(this)->GetLinkManager(); }
1019 /// Class for automated call of Start- and EndAction().
1020 class SwActContext {
1021 SwEditShell & m_rShell;
1022 public:
1023 SwActContext(SwEditShell *pShell);
1024 ~SwActContext() COVERITY_NOEXCEPT_FALSE;
1027 /// Class for automated call of Start- and EndCursorMove().
1028 class SwMvContext {
1029 SwEditShell & m_rShell;
1030 public:
1031 SwMvContext(SwEditShell *pShell);
1032 ~SwMvContext() COVERITY_NOEXCEPT_FALSE;
1035 #endif
1037 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */