1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
24 #include "charfmt.hxx"
25 #include "fldupde.hxx"
29 #include "tblenum.hxx"
35 #include <o3tl/sorted_vector.hxx>
37 namespace tools
{ class PolyPolygon
; }
39 class CommandExtTextInputData
;
41 class SvNumberFormatter
;
44 class SfxWatermarkItem
;
51 class SwAutoCompleteWord
;
53 class SwFormatRefMark
;
57 class SwTextFormatColl
;
63 class SwFormatINetFormat
;
66 class SwFormatFootnote
;
69 class SwSectionFormat
;
70 class SwTableAutoFormat
;
72 class SwTextINetFormat
;
74 class SwGlblDocContent
;
75 class SwGlblDocContents
;
80 class SwLineNumberInfo
;
84 struct SwConversionArgs
;
85 struct SvxSwAutoFormatFlags
;
86 struct SwInsertTableOptions
;
88 enum class SvtScriptType
;
89 enum class SfxClassificationPolicyType
;
90 enum class RedlineFlags
;
91 enum class TransliterationFlags
;
92 enum class GraphicType
;
94 namespace com::sun::star::uno
{ template < class > class Sequence
; }
95 namespace com::sun::star::linguistic2
{ class XSpellAlternatives
; }
96 namespace com::sun::star::linguistic2
{ struct ProofreadingResult
; }
100 typedef std::vector
<SpellPortion
> SpellPortions
;
101 class ClassificationResult
;
109 class UndoRedoContext
;
112 enum class ParaBreakType
{
117 /// For querying the INet-attributes for Navigator.
121 const SwTextINetFormat
& rINetAttr
;
123 SwGetINetAttr( const OUString
& rText
, const SwTextINetFormat
& rAttr
)
124 : sText( rText
), rINetAttr( rAttr
)
127 typedef std::vector
<SwGetINetAttr
> SwGetINetAttrs
;
129 // Types of forms of content.
130 #define CNT_TXT 0x0001
131 #define CNT_GRF 0x0002
132 #define CNT_OLE 0x0010
134 // Test USHORT for a defined form of content.
135 #define CNT_HasText(USH) ((USH)&CNT_TXT)
136 #define CNT_HasGrf(USH) ((USH)&CNT_GRF)
137 #define CNT_HasOLE(USH) ((USH)&CNT_OLE)
139 class SW_DLLPUBLIC SwEditShell
: public SwCursorShell
141 static SvxSwAutoFormatFlags
* s_pAutoFormatFlags
;
143 /// For the private methods DelRange and those of AutoCorrect.
144 friend class SwAutoFormat
;
145 friend void InitCore();
146 friend void FinitCore();
147 /// For the PamCorrAbs/-Rel methods.
150 /** Returns pointer to a SwGrfNode
151 that will be used by GetGraphic() and GetGraphicSize(). */
152 SAL_DLLPRIVATE SwGrfNode
*GetGrfNode_() const ;
154 SAL_DLLPRIVATE
void DeleteSel( SwPaM
& rPam
, bool* pUndo
= nullptr );
156 SAL_DLLPRIVATE
void SetSectionAttr_( SwSectionFormat
& rSectFormat
, const SfxItemSet
& rSet
);
158 using SwViewShell::UpdateFields
;
159 using sw::BroadcastingModify::GetInfo
;
162 /// Edit (all selected ranges).
163 void Insert( sal_Unicode
, bool bOnlyCurrCursor
= false );
164 void Insert2( const OUString
&, const bool bForceExpandHints
= false );
165 void Overwrite( const OUString
& );
167 /** Replace a selected range in a TextNode by given string.
168 Meant for Search & Replace.
169 bRegExpRplc - replace tabs (\\t) and insert found string (not \&).
170 E.g.: Fnd: "zzz", Repl: "xx\t\\t..&..\&"
171 --> "xx\t<Tab>..zzz..&" */
172 bool Replace( const OUString
& rNewStr
, bool bRegExpRplc
);
174 /** Delete content of all ranges.
175 If whole nodes are selected, these nodes get deleted. */
178 /// Remove a complete paragraph.
181 /// Change text to Upper/Lower/Hiragana/Katakana/...
182 void TransliterateText( TransliterationFlags nType
);
184 /// Count words in current selection.
185 void CountWords( SwDocStat
& rStat
) const;
187 /// Replace fields by text - mailmerge support.
188 bool ConvertFieldsToText();
190 /// Set all numbering start points to a fixed value - mailmerge support.
191 void SetNumberingRestart();
193 /// Embeds all local links (ranges/graphics).
194 sal_uInt16
GetLinkUpdMode() const;
195 void SetLinkUpdMode( sal_uInt16 nMode
);
197 /// Copy content of all ranges at current position of cursor to given Shell.
198 bool Copy( SwEditShell
& rDestShell
);
200 /** For copying via ClipBoard:
201 If table is copied into table, move all cursors away from it.
202 Copy and Paste must be in FEShell because of FlyFrames!
203 Copy all selections to the document. */
204 bool CopySelToDoc( SwDoc
& rInsDoc
);
206 void SplitNode( bool bAutoFormat
= false, bool bCheckTableStart
= true );
207 bool AppendTextNode();
208 void AutoFormatBySplitNode();
210 /** If cursor is in an INetAttribute it will be deleted completely
211 including the descriptive text (needed at drag & drop). */
212 void DelINetAttrWithText();
214 /** If Cursor is at the end of a character style in which the DontExpand-flag
215 is not yet set, the latter will be set (==> return TRUE). */
216 bool DontExpandFormat();
218 /** Apply / remove attributes.
219 @return attributes in required AttributeSet.
220 When not unambiguous the set has a DONT_CARE !!
221 2nd optional parameter <bMergeIndentValuesOfNumRule>.
222 If <bMergeIndentValuesOfNumRule> == true, the indent attributes of
223 the corresponding list level of an applied list style is merged into
224 the requested item set as a LR-SPACE item, if corresponding node has not
225 its own indent attributes and the position-and-space mode of the list
226 level is SvxNumberFormat::LABEL_ALIGNMENT. */
227 bool GetPaMAttr( SwPaM
* pPaM
, SfxItemSet
& ,
228 const bool bMergeIndentValuesOfNumRule
= false ) const;
229 bool GetCurAttr( SfxItemSet
& ,
230 const bool bMergeIndentValuesOfNumRule
= false ) const;
231 void SetAttrItem( const SfxPoolItem
&, SetAttrMode nFlags
= SetAttrMode::DEFAULT
,
232 const bool bParagraphSetting
= false );
233 void SetAttrSet( const SfxItemSet
&, SetAttrMode nFlags
= SetAttrMode::DEFAULT
,
234 SwPaM
* pCursor
= nullptr, const bool bParagraphSetting
= false );
236 /** Get RES_CHRATR_* items of one type in the current selection.
237 * @param nWhich WhichId of the collected items.
238 * If parts of the selection have different scripttypes, the items with corresponding WhichIds are also collected.
239 * @return a vector of pairs. The pair contains a SfxPoolItem and a SwPaM, in which the item is valid and can be changed. */
240 std::vector
<std::pair
< const SfxPoolItem
*, std::unique_ptr
<SwPaM
>>> GetItemWithPaM( sal_uInt16 nWhich
);
243 * Get the paragraph format attribute(s) of the current selection.
245 * @see GetPaMParAttr()
248 * output parameter - the SfxItemSet where the automatic paragraph format attribute(s) will be store.
249 * The attributes aren't invalidated or cleared if the function reach the getMaxLookup limit.
251 void GetCurParAttr( SfxItemSet
& rSet
) const;
253 * Get the paragraph format attribute(s) of the selection(s) described by a SwPaM.
256 * input parameter - the selection where to look for the paragraph format.
259 * output parameter - the SfxItemSet where the automatic paragraph format attribute(s) will be store.
260 * The attributes aren't invalidated or cleared if the function reaches the getMaxLookup limit.
262 * @return true if the function inspects all the nodes point by the pPaM parameter,
263 * false if the function reaches the limit of getMaxLookup number of nodes inspected.
265 bool GetPaMParAttr( SwPaM
* pPaM
, SfxItemSet
& rSet
) const;
267 /// Set attribute as new default attribute in document.
268 void SetDefault( const SfxPoolItem
& );
270 /// Query default attribute of document.
271 const SfxPoolItem
& GetDefault( sal_uInt16 nFormatHint
) const;
272 template<class T
> const T
& GetDefault( TypedWhichId
<T
> nWhich
) const
274 return static_cast<const T
&>(GetDefault(sal_uInt16(nWhich
)));
277 void ResetAttr( const o3tl::sorted_vector
<sal_uInt16
> &attrs
= o3tl::sorted_vector
<sal_uInt16
>(), SwPaM
* pCursor
= nullptr );
280 /// @return the scripttype of the selection.
281 SvtScriptType
GetScriptType() const;
283 /// @return the language at current cursor position.
284 LanguageType
GetCurLang() const;
287 size_t GetTableFrameFormatCount( bool bUsed
= false ) const;
288 SwFrameFormat
& GetTableFrameFormat(size_t nFormat
, bool bUsed
= false ) const;
289 OUString
GetUniqueTableName() const;
292 sal_uInt16
GetCharFormatCount() const;
293 SwCharFormat
& GetCharFormat(sal_uInt16 nFormat
) const;
294 SwCharFormat
* GetCurCharFormat() const;
295 void FillByEx(SwCharFormat
*);
296 SwCharFormat
* MakeCharFormat( const OUString
& rName
);
297 SwCharFormat
* FindCharFormatByName( const OUString
& rName
) const;
299 /* FormatCollections (new) - Explaining the general naming pattern:
300 * GetXXXCount() returns the count of xxx in the document.
301 * GetXXX(i) returns i-th xxx (ERR_RAISE if beyond range!).
302 * DelXXX(i) deletes i-th xxx (ERR_RAISE if beyond range!).
303 * GetCurXXX() returns xxx that is valid at cursor or in ranges.
304 * returns 0, if not unanimous.
305 * SetXXX() sets xxx at cursor or in ranges.
306 * MakeXXX() makes a xxx, derived from pDerivedFrom.
310 SwTextFormatColl
& GetDfltTextFormatColl() const;
311 sal_uInt16
GetTextFormatCollCount() const;
312 SwTextFormatColl
& GetTextFormatColl( sal_uInt16 nTextFormatColl
) const;
314 * Get the named paragraph format of the current selection.
316 * @see GetPaMTextFormatColl()
318 * @return the named paragraph format of the first node that contains one.
319 * Nodes are sort by order of appearance in the selections ;
320 * selections are sort by their order of creation
321 * (last created selection first, oldest selection at last).
323 SwTextFormatColl
* GetCurTextFormatColl() const;
325 * Get the named paragraph format of the selection(s) described by a SwPaM.
328 * input parameter - the selection where to look for the paragraph format.
330 * @return the named paragraph format of the first node that contains one.
332 SwTextFormatColl
* GetPaMTextFormatColl( SwPaM
* pPaM
) const;
335 /// Add 2nd optional parameter <bResetListAttrs> - see also <SwDoc::SetTextFormatColl(..)>
336 void SetTextFormatColl(SwTextFormatColl
*, const bool bResetListAttrs
= false);
337 SwTextFormatColl
*MakeTextFormatColl(const OUString
&rFormatCollName
,
338 SwTextFormatColl
*pDerivedFrom
= nullptr);
339 void FillByEx(SwTextFormatColl
*);
340 SwTextFormatColl
* FindTextFormatCollByName( const OUString
& rName
) const;
342 /// @return "Auto-Collection" with given Id. If it does not exist create it.
343 SwTextFormatColl
* GetTextCollFromPool( sal_uInt16 nId
);
345 /// @return required automatic format base class.
346 SwFormat
* GetFormatFromPool( sal_uInt16 nId
);
348 /// @return required automatic page style.
349 SwPageDesc
* GetPageDescFromPool( sal_uInt16 nId
);
351 /// Query if the paragraph-/character-/frame-/page-style is used.
352 bool IsUsed( const sw::BroadcastingModify
& ) const;
354 /// @return required automatic format.
355 SwFrameFormat
* GetFrameFormatFromPool( sal_uInt16 nId
)
356 { return static_cast<SwFrameFormat
*>(SwEditShell::GetFormatFromPool( nId
)); }
357 SwCharFormat
* GetCharFormatFromPool( sal_uInt16 nId
)
358 { return static_cast<SwCharFormat
*>(SwEditShell::GetFormatFromPool( nId
)); }
360 void SetClassification(const OUString
& rName
, SfxClassificationPolicyType eType
);
361 void ApplyAdvancedClassification(std::vector
<svx::ClassificationResult
> const & rResult
);
362 std::vector
<svx::ClassificationResult
> CollectAdvancedClassification();
364 SfxWatermarkItem
GetWatermark() const;
365 void SetWatermark(const SfxWatermarkItem
& rText
);
367 /// Sign the paragraph at the cursor.
368 void SignParagraph();
370 /// Validate the paragraph signatures, if any, of the current text node.
371 void ValidateParagraphSignatures(SwTextNode
* pNode
, bool updateDontRemove
);
373 /// Validate the current paragraph signatures, if any, at the cursor start.
374 void ValidateCurrentParagraphSignatures(bool updateDontRemove
);
376 /// Validate all paragraph signatures.
377 void ValidateAllParagraphSignatures(bool updateDontRemove
);
379 /// Restore the metadata fields, if missing, from the RDF metadata
380 /// and validate the signatures and update the signature metadata fields.
381 /// Needed since deleting the metadata field doesn't remove the RDF
382 /// and editing docs using software that don't support paragraph signing.
383 void RestoreMetadataFieldsAndValidateParagraphSignatures();
385 /// Ensure that the classification of the doc is never lower than
386 /// the paragraph with the highest classification.
387 void ClassifyDocPerHighestParagraphClass();
389 /// Apply the classification to the paragraph at cursor.
390 void ApplyParagraphClassification(std::vector
<svx::ClassificationResult
> aResult
);
391 std::vector
<svx::ClassificationResult
> CollectParagraphClassification();
393 /// Returns true iff the cursor is within a paragraph metadata field.
394 /// Currently there are two variants: signature and classification.
395 bool IsCursorInParagraphMetadataField() const;
397 /// Removes the paragraph metadata field at the current cursor, if any.
398 /// Returns true iff a paragraph metadata field was removed.
399 /// Currently there are two variants: signature and classification.
400 bool RemoveParagraphMetadataFieldAtCursor();
402 void Insert2(SwField
const &, const bool bForceExpandHints
);
404 void UpdateOneField(SwField
&); ///< One single field.
406 size_t GetFieldTypeCount(SwFieldIds nResId
= SwFieldIds::Unknown
) const;
407 SwFieldType
* GetFieldType(size_t nField
, SwFieldIds nResId
= SwFieldIds::Unknown
) const;
408 SwFieldType
* GetFieldType(SwFieldIds nResId
, const OUString
& rName
) const;
410 void RemoveFieldType(size_t nField
);
411 void RemoveFieldType(SwFieldIds nResId
, const OUString
& rName
);
413 void FieldToText( SwFieldType
const * pType
);
415 void ChangeAuthorityData(const SwAuthEntry
* pNewData
);
417 /// Database information.
418 SwDBData
const & GetDBData() const;
419 const SwDBData
& GetDBDesc() const;
420 void ChgDBData(const SwDBData
& SwDBData
);
421 void ChangeDBFields( const std::vector
<OUString
>& rOldNames
,
422 const OUString
& rNewName
);
423 void GetAllUsedDB( std::vector
<OUString
>& rDBNameList
,
424 std::vector
<OUString
> const * pAllDBNames
);
426 bool IsAnyDatabaseFieldInDoc()const;
428 /// Check whether DB fields point to an available data source and returns it.
429 bool IsFieldDataSourceAvailable(OUString
& rUsedDataSource
) const;
430 void UpdateExpFields(bool bCloseDB
= false);///< only every expression fields update
431 void LockExpFields();
432 void UnlockExpFields();
433 bool IsExpFieldsLocked() const;
435 SwFieldUpdateFlags
GetFieldUpdateFlags() const;
436 void SetFieldUpdateFlags( SwFieldUpdateFlags eFlags
);
438 /// For evaluation of DB fields (new DB-manager).
439 SwDBManager
* GetDBManager() const;
441 SwFieldType
* InsertFieldType(const SwFieldType
&);
443 /// Changes in document?
444 bool IsModified() const;
446 void ResetModified();
447 void SetUndoNoResetModified();
449 /// Document - Statistics
450 void UpdateDocStat();
451 const SwDocStat
&GetUpdatedDocStat();
453 void Insert(const SwTOXMark
& rMark
);
455 void DeleteTOXMark(SwTOXMark
const * pMark
);
457 /// Get all marks at current SPoint.
458 void GetCurTOXMarks(SwTOXMarks
& rMarks
) const ;
460 /// Insert content table. Renew if required.
461 void InsertTableOf(const SwTOXBase
& rTOX
,
462 const SfxItemSet
* pSet
= nullptr);
463 void UpdateTableOf(const SwTOXBase
& rTOX
,
464 const SfxItemSet
* pSet
= nullptr);
465 const SwTOXBase
* GetCurTOX() const;
466 const SwTOXBase
* GetDefaultTOXBase( TOXTypes eTyp
, bool bCreate
= false );
467 void SetDefaultTOXBase(const SwTOXBase
& rBase
);
469 static bool IsTOXBaseReadonly(const SwTOXBase
& rTOXBase
);
470 void SetTOXBaseReadonly(const SwTOXBase
& rTOXBase
, bool bReadonly
);
472 sal_uInt16
GetTOXCount() const;
473 const SwTOXBase
* GetTOX( sal_uInt16 nPos
) const;
474 bool DeleteTOX( const SwTOXBase
& rTOXBase
, bool bDelNodes
);
476 /// After reading file update all content tables.
477 void SetUpdateTOX( bool bFlag
);
478 bool IsUpdateTOX() const;
480 /// Manage types of content tables.
481 sal_uInt16
GetTOXTypeCount(TOXTypes eTyp
) const;
482 const SwTOXType
* GetTOXType(TOXTypes eTyp
, sal_uInt16 nId
) const;
483 void InsertTOXType(const SwTOXType
& rTyp
);
486 OUString
const & GetTOIAutoMarkURL() const;
487 void SetTOIAutoMarkURL(const OUString
& rSet
);
488 void ApplyAutoMark();
490 /// Key for managing index.
491 void GetTOIKeys( SwTOIKeyType eTyp
, std::vector
<OUString
>& rArr
) const;
493 void SetOutlineNumRule(const SwNumRule
&);
494 const SwNumRule
* GetOutlineNumRule() const;
496 bool OutlineUpDown( short nOffset
= 1 );
498 bool MoveOutlinePara( SwOutlineNodes::difference_type nOffset
);
500 bool IsProtectedOutlinePara() const;
502 const SwNumRule
* GetNumRuleAtCurrCursorPos() const;
504 /** Returns the numbering rule found at the paragraphs of the current selection,
505 if all paragraphs of the current selection have the same or none numbering rule applied. */
506 const SwNumRule
* GetNumRuleAtCurrentSelection() const;
508 /** Optional parameter <bResetIndentAttrs> (default value false).
509 If <bResetIndentAttrs> equals true, the indent attributes "before text"
510 and "first line indent" are additionally reset at the current selection,
511 if the list style makes use of the new list level attributes.
512 Parameters <bCreateNewList> and <sContinuedListId>
513 <bCreateNewList> indicates, if a new list is created by applying the given list style.
514 If <bCreateNewList> equals false, <sContinuedListId> may contain the
515 list Id of a list, which has to be continued by applying the given list style */
516 void SetCurNumRule( const SwNumRule
&,
517 const bool bCreateNewList
/*= false*/,
518 const OUString
& sContinuedListId
= OUString(),
519 const bool bResetIndentAttrs
= false );
521 /// Paragraphs without enumeration but with indents.
524 /// Delete, split enumeration list.
527 void NumUpDown( bool bDown
= true );
529 bool MoveParagraph( tools::Long nOffset
= 1);
530 bool MoveNumParas( bool bUpperLower
, bool bUpperLeft
);
532 /// Switch on/off of numbering via Delete/Backspace.
533 bool NumOrNoNum(bool bDelete
= false, bool bChkStart
= true);
537 /// Remove unused default parameter <nLevel> and <bRelative>.
538 // Adjust method name and parameter name
539 void ChangeIndentOfAllListLevels( sal_Int32 nDiff
);
540 // Adjust method name
541 void SetIndent(short nIndent
, const SwPosition
& rPos
);
542 bool IsFirstOfNumRuleAtCursorPos() const;
544 bool IsNoNum( bool bChkStart
= true ) const;
546 /** @return Num-Level of the node in which point of cursor is.
547 @return values can be: NO_NUMBERING,
548 0..MAXLEVEL-1, NO_NUMLEVEL .. NO_NUMLEVEL|MAXLEVEL-1 */
549 sal_uInt8
GetNumLevel() const;
551 /// Detect highest and lowest level to check moving of outline levels.
552 void GetCurrentOutlineLevels( sal_uInt8
& rUpper
, sal_uInt8
& rLower
);
554 /// Get Outline level of current paragraph.
555 int GetCurrentParaOutlineLevel( ) const;
558 bool HasNumber() const;
559 bool HasBullet() const;
561 bool SelectionHasNumber() const;
562 bool SelectionHasBullet() const;
564 OUString
GetUniqueNumRuleName() const;
565 void ChgNumRuleFormats( const SwNumRule
& rRule
);
567 /// Set (and query if) a numbering with StartFlag starts at current PointPos.
568 void SetNumRuleStart( bool bFlag
, SwPaM
* pCursor
);
569 bool IsNumRuleStart( SwPaM
* pPaM
= nullptr ) const;
570 void SetNodeNumStart( sal_uInt16 nStt
);
572 sal_uInt16
GetNodeNumStart( SwPaM
* pPaM
) const;
574 void ReplaceNumRule( const OUString
& rOldRule
, const OUString
& rNewRule
);
576 /** Searches for a text node with a numbering rule.
577 in case a list style is found, <sListId> holds the list id, to which the
578 text node belongs, which applies the found list style. */
579 const SwNumRule
* SearchNumRule(const bool bNum
,
583 Maintain UndoHistory in Document.
584 Reset UndoHistory at Save, SaveAs, Create ??? */
585 void DoUndo( bool bOn
= true );
586 bool DoesUndo() const;
587 void DoGroupUndo( bool bUn
);
588 bool DoesGroupUndo() const;
589 void DelAllUndoObj();
591 /// Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
592 SwUndoId
StartUndo( SwUndoId eUndoId
= SwUndoId::EMPTY
, const SwRewriter
* pRewriter
= nullptr );
594 /// Closes parenthesis of nUndoId, not used by UI.
595 SwUndoId
EndUndo( SwUndoId eUndoId
= SwUndoId::EMPTY
, const SwRewriter
* pRewriter
= nullptr );
597 bool GetLastUndoInfo(OUString
*const o_pStr
,
598 SwUndoId
*const o_pId
,
599 const SwView
* pView
= nullptr) const;
600 bool GetFirstRedoInfo(OUString
*const o_pStr
,
601 SwUndoId
*const o_pId
,
602 const SwView
* pView
= nullptr) const;
603 SwUndoId
GetRepeatInfo(OUString
*const o_pStr
) const;
605 /// is it forbidden to modify cursors via API calls?
606 bool CursorsLocked() const;
607 /// set selections to those contained in the UndoRedoContext
608 /// should only be called by sw::UndoManager!
609 void HandleUndoRedoContext(::sw::UndoRedoContext
& rContext
);
611 void Undo(sal_uInt16
const nCount
= 1, sal_uInt16 nOffset
= 0);
612 void Redo(sal_uInt16
const nCount
= 1);
613 void Repeat(sal_uInt16
const nCount
);
615 /// For all views of this document.
616 void StartAllAction();
619 /// To enable set up of StartActions and EndActions.
620 virtual void CalcLayout() override
;
622 /// Determine form of content. Return Type at CurrentCursor->SPoint.
623 sal_uInt16
GetCntType() const;
625 /// Are there frames, footnotes, etc.
626 bool HasOtherCnt() const;
628 /// Apply ViewOptions with Start-/EndAction.
629 virtual void ApplyViewOptions( const SwViewOption
&rOpt
) override
;
631 /** Query text within selection. */
632 void GetSelectedText( OUString
&rBuf
,
633 ParaBreakType nHndlParaBreak
= ParaBreakType::ToBlank
);
635 /** @return graphic, if CurrentCursor->Point() points to a SwGrfNode
636 (and mark is not set or points to the same graphic). */
638 const Graphic
* GetGraphic( bool bWait
= true ) const;
639 const GraphicObject
* GetGraphicObj() const;
640 const GraphicAttr
* GetGraphicAttr( GraphicAttr
& rGA
) const;
642 bool IsLinkedGrfSwapOut() const;
643 GraphicType
GetGraphicType() const;
645 const tools::PolyPolygon
*GetGraphicPolygon() const;
646 void SetGraphicPolygon( const tools::PolyPolygon
*pPoly
);
648 /** If there's an automatic, not manipulated polygon at the selected
649 notxtnode, it has to be deleted, e.g. cause the object has changed. */
650 void ClearAutomaticContour();
652 /// @return the size of a graphic in Twips if cursor is in a graphic.
653 bool GetGrfSize(Size
&) const;
655 /** @return name and filter of a graphic if the cursor is in a graphic,
656 else give a rap on the knuckles!
657 If a string-ptr != 0 return the respective name. */
658 void GetGrfNms( OUString
* pGrfName
, OUString
* pFltName
,
659 const SwFlyFrameFormat
* = nullptr ) const;
661 /// Re-read if graphic is not ok. Current graphic is replaced by the new one.
662 void ReRead( const OUString
& rGrfName
, const OUString
& rFltName
,
663 const Graphic
* pGraphic
= nullptr );
665 /// Unique identification of object (for ImageMapDlg).
666 void *GetIMapInventor() const;
669 /// Remove default parameter, because method always called this default value.
670 Graphic
GetIMapGraphic() const; ///< @return a graphic for all Flys!
671 const SwFlyFrameFormat
* FindFlyByName( const OUString
& rName
) const;
673 /** @return a ClientObject, if CurrentCursor->Point() points to a SwOLENode
674 (and mark is neither set not pointint to same ClientObject)
675 else give rap on the knuckles. */
676 svt::EmbeddedObjectRef
& GetOLEObject() const;
678 /// Is there an OLEObject with this name (SwFormat)?
679 bool HasOLEObj( const OUString
&rName
) const;
681 /// @return pointer to the data of the chart in which Cursr is.
682 void SetChartName( const OUString
&rName
);
684 /// Update content of all charts for table with given name.
685 void UpdateCharts( const OUString
&rName
);
687 OUString
GetCurWord() const;
689 /** Glossary from glossary document in current document.
690 Styles only if not already existent. */
691 void InsertGlossary( SwTextBlocks
& rGlossary
, const OUString
& );
693 /** Make current selection glossary and insert into glossary document
695 sal_uInt16
MakeGlossary( SwTextBlocks
& rToFill
, const OUString
& rName
,
696 const OUString
& rShortName
, bool bSaveRelFile
,
697 const OUString
* pOnlyText
);
699 /// Save complete content of doc as glossary.
700 sal_uInt16
SaveGlossaryDoc( SwTextBlocks
& rGlossary
, const OUString
& rName
,
701 const OUString
& rShortName
,
707 void HyphStart( SwDocPositions eStart
, SwDocPositions eEnd
);
709 /// restore selections.
711 css::uno::Reference
< css::uno::XInterface
>
712 HyphContinue( sal_uInt16
* pPageCnt
, sal_uInt16
* pPageSt
);
716 /// For Inserting SoftHyphen. Position is offset within the syllabificated word.
717 static void InsertSoftHyph( const sal_Int32 nHyphPos
);
719 const SwTable
& InsertTable( const SwInsertTableOptions
& rInsTableOpts
, ///< All
720 sal_uInt16 nRows
, sal_uInt16 nCols
,
721 const SwTableAutoFormat
* pTAFormat
= nullptr );
723 void InsertDDETable( const SwInsertTableOptions
& rInsTableOpts
, ///< HeadlineNoBorder
724 SwDDEFieldType
* pDDEType
,
725 sal_uInt16 nRows
, sal_uInt16 nCols
);
728 void SetTableName( SwFrameFormat
& rTableFormat
, const OUString
&rNewName
);
730 SwFrameFormat
*GetTableFormat();
731 bool TextToTable( const SwInsertTableOptions
& rInsTableOpts
, ///< All
733 const SwTableAutoFormat
* pTAFormat
= nullptr );
734 bool TableToText( sal_Unicode cCh
);
735 bool IsTextToTableAvailable() const;
737 bool GetTableBoxFormulaAttrs( SfxItemSet
& rSet
) const;
738 void SetTableBoxFormulaAttrs( const SfxItemSet
& rSet
);
740 bool IsTableBoxTextFormat() const;
741 OUString
GetTableBoxText() const;
743 TableChgMode
GetTableChgMode() const;
744 void SetTableChgMode( TableChgMode eMode
);
746 /// Split table at cursor position.
747 void SplitTable( SplitTable_HeadlineOption eMode
);
751 Can Merge checks if Prev or Next are possible.
752 If pointer pChkNxtPrv is passed possible direction is given. */
753 bool CanMergeTable( bool bWithPrev
= true, bool* pChkNxtPrv
= nullptr ) const;
754 bool MergeTable( bool bWithPrev
);
756 /// Set up InsertDB as table Undo.
757 void AppendUndoForInsertFromDB( bool bIsTable
);
759 /// Functions used for spell checking and text conversion.
762 void SpellStart( SwDocPositions eStart
, SwDocPositions eEnd
,
763 SwDocPositions eCurr
, SwConversionArgs
*pConvArgs
= nullptr );
765 /// Restore selections.
766 void SpellEnd( SwConversionArgs
const *pConvArgs
= nullptr, bool bRestoreSelection
= true );
767 css::uno::Any
SpellContinue(
768 sal_uInt16
* pPageCnt
, sal_uInt16
* pPageSt
,
769 SwConversionArgs
const *pConvArgs
);
771 /** Spells on a sentence basis - the SpellPortions are needed
772 @return false if no error could be found. */
773 bool SpellSentence(svx::SpellPortions
& rToFill
, bool bIsGrammarCheck
);
775 /// Make SpellIter start with the current sentence when called next time.
776 static void PutSpellingToSentenceStart();
778 /// Moves the continuation position to the end of the currently checked sentence.
779 static void MoveContinuationPosToEndOfCheckedSentence();
781 /// Applies a changed sentence.
782 void ApplyChangedSentence(const svx::SpellPortions
& rNewPortions
, bool bRecheck
);
784 /// Check SwSpellIter data to see if the last sentence got grammar checked.
785 static bool HasLastSentenceGotGrammarChecked();
787 /// Is text conversion active somewhere else?
788 static bool HasConvIter();
790 /// Is hyphenation active somewhere else?
791 static bool HasHyphIter();
793 void HandleCorrectionError(const OUString
& aText
, SwPosition aPos
, sal_Int32 nBegin
,
794 sal_Int32 nLen
, const Point
* pPt
,
795 SwRect
& rSelectRect
);
796 css::uno::Reference
< css::linguistic2::XSpellAlternatives
>
797 GetCorrection( const Point
* pPt
, SwRect
& rSelectRect
);
799 bool GetGrammarCorrection( css::linguistic2::ProofreadingResult
/*out*/ &rResult
,
800 sal_Int32
/*out*/ &rErrorPosInText
,
801 sal_Int32
/*out*/ &rErrorIndexInResult
,
802 css::uno::Sequence
< OUString
> /*out*/ &rSuggestions
,
803 const Point
* pPt
, SwRect
& rSelectRect
);
805 static void IgnoreGrammarErrorAt( SwPaM
& rErrorPosition
);
806 void SetLinguRange( SwDocPositions eStart
, SwDocPositions eEnd
);
808 /// @return reference set in document according to given name.
809 const SwFormatRefMark
* GetRefMark( const OUString
& rName
) const;
811 /** @return names of all references set in document.
812 If ArrayPointer == 0 then return only whether a RefMark is set in document. */
813 sal_uInt16
GetRefMarks( std::vector
<OUString
>* = nullptr ) const;
816 void AutoCorrect( SvxAutoCorrect
& rACorr
, bool bInsertMode
,
818 OUString
GetPrevAutoCorrWord(SvxAutoCorrect
& rACorr
);
820 // We consider no more than 9 characters before the cursor, and they must not start in the
821 // middle of a word (leading spaces are OK)
822 std::vector
<OUString
> GetChunkForAutoText();
824 /// Set our styles according to the respective rules.
825 void AutoFormat( const SvxSwAutoFormatFlags
* pAFlags
);
827 static SvxSwAutoFormatFlags
* GetAutoFormatFlags();
828 static void SetAutoFormatFlags(SvxSwAutoFormatFlags
const *);
830 /// Calculates selection.
831 OUString
Calculate();
833 bool InsertURL( const SwFormatINetFormat
& rFormat
, const OUString
& rStr
,
834 bool bKeepSelection
= false );
835 void GetINetAttrs( SwGetINetAttrs
& rArr
);
837 OUString
GetDropText( const sal_Int32 nChars
) const;
838 void ReplaceDropText( const OUString
&rStr
, SwPaM
* pPaM
= nullptr );
840 /** May an outline be moved or copied?
841 Check whether it's in text body, not in table, and not read-only (move). */
842 bool IsOutlineMovable( SwOutlineNodes::size_type nIdx
) const;
843 bool IsOutlineCopyable( SwOutlineNodes::size_type nIdx
) const;
845 sal_uInt16
GetLineCount();
847 /// Query and set footnote-text/number. Set... to current SSelection!
848 bool GetCurFootnote( SwFormatFootnote
* pToFillFootnote
= nullptr );
849 bool SetCurFootnote( const SwFormatFootnote
& rFillFootnote
);
850 bool HasFootnotes( bool bEndNotes
= false ) const;
852 size_t GetSeqFootnoteList( SwSeqFieldList
& rList
, bool bEndNotes
= false );
853 /// @return list of all footnotes and their first portions of text.
855 SwSection
const* InsertSection(
856 SwSectionData
& rNewData
, SfxItemSet
const*const = nullptr );
857 bool IsInsRegionAvailable() const;
858 const SwSection
* GetCurrSection() const;
860 /** @return current range like Cet CurrSection(). But this function iterates
861 also over frames and catches the range even if the cursor is positioned in
862 a footnote the reference of which is in a columned range.
863 If bOutOfTab is set, the range comprising the table is searched
864 and not an inner one. */
865 SwSection
* GetAnySection( bool bOutOfTab
= false, const Point
* pPt
= nullptr );
867 size_t GetSectionFormatCount() const;
868 size_t GetSectionFormatPos(const SwSectionFormat
&) const;
869 const SwSectionFormat
& GetSectionFormat(size_t nFormat
) const;
870 void DelSectionFormat( size_t nFormat
);
871 void UpdateSection( size_t const nSect
, SwSectionData
&,
872 SfxItemSet
const*const = nullptr);
873 bool IsAnySectionInDoc() const;
875 OUString
GetUniqueSectionName( const OUString
* pChkStr
= nullptr ) const;
878 void SetSectionAttr(const SfxItemSet
& rSet
, SwSectionFormat
* pSectFormat
= nullptr);
880 /** Search inside the cursor selection for full selected sections.
881 if any part of section in the selection @return 0.
882 if more than one in the selection return the count. */
883 sal_uInt16
GetFullSelectedSectionCount() const;
885 /** Special insert: Insert a new text node just before or after a section or
886 table, if the cursor is positioned at the start/end of said
887 section/table. The purpose of the method is to allow users to inert text
888 at certain 'impossible' position, e.g. before a table at the document
889 start or between to sections. */
890 void DoSpecialInsert();
891 bool CanSpecialInsert() const;
896 sfx2::LinkManager
& GetLinkManager();
897 inline const sfx2::LinkManager
& GetLinkManager() const;
899 /** Adjust left margin via object bar (similar to adjustment of numerations).
900 One can either change the margin "by" adding or subtracting a given
901 offset or set it "to" this position @param (bModulus = true). */
902 bool IsMoveLeftMargin( bool bRight
, bool bModulus
= true ) const;
903 void MoveLeftMargin( bool bRight
, bool bModulus
= true );
905 /// Query NumberFormatter from document.
906 SvNumberFormatter
* GetNumberFormatter();
907 const SvNumberFormatter
* GetNumberFormatter() const
908 { return const_cast<SwEditShell
*>(this)->GetNumberFormatter(); }
910 /// Interfaces for GlobalDocument.
911 bool IsGlobalDoc() const;
912 void SetGlblDocSaveLinks( bool bFlag
);
913 bool IsGlblDocSaveLinks() const;
914 void GetGlobalDocContent( SwGlblDocContents
& rArr
) const;
915 void InsertGlobalDocContent( const SwGlblDocContent
& rPos
,
916 SwSectionData
& rNew
);
917 bool InsertGlobalDocContent( const SwGlblDocContent
& rPos
,
918 const SwTOXBase
& rTOX
);
919 bool InsertGlobalDocContent( const SwGlblDocContent
& rPos
);
920 void DeleteGlobalDocContent( const SwGlblDocContents
& rArr
,
922 bool MoveGlobalDocContent( const SwGlblDocContents
& rArr
,
923 size_t nFromPos
, size_t nToPos
,
925 void GotoGlobalDocContent( const SwGlblDocContent
& rPos
);
928 RedlineFlags
GetRedlineFlags() const;
929 void SetRedlineFlags( RedlineFlags eMode
);
930 bool IsRedlineOn() const;
931 SwRedlineTable::size_type
GetRedlineCount() const;
932 const SwRangeRedline
& GetRedline( SwRedlineTable::size_type nPos
) const;
933 bool AcceptRedline( SwRedlineTable::size_type nPos
);
934 bool RejectRedline( SwRedlineTable::size_type nPos
);
935 bool AcceptRedlinesInSelection();
936 bool RejectRedlinesInSelection();
938 /** Search Redline for this Data and @return position in array.
939 If not found, return SwRedlineTable::npos. */
940 SwRedlineTable::size_type
FindRedlineOfData( const SwRedlineData
& ) const;
942 /// Set comment to Redline at position.
943 bool SetRedlineComment( const OUString
& rS
);
944 const SwRangeRedline
* GetCurrRedline() const;
946 /// Redline attributes have been changed. Updated views.
947 void UpdateRedlineAttr();
949 /// Compare two documents.
950 tools::Long
CompareDoc( const SwDoc
& rDoc
);
952 /// Merge two documents.
953 tools::Long
MergeDoc( const SwDoc
& rDoc
);
955 /// Footnote attributes global to document.
956 const SwFootnoteInfo
& GetFootnoteInfo() const;
957 void SetFootnoteInfo(const SwFootnoteInfo
& rInfo
);
958 const SwEndNoteInfo
& GetEndNoteInfo() const;
959 void SetEndNoteInfo(const SwEndNoteInfo
& rInfo
);
961 const SwLineNumberInfo
&GetLineNumberInfo() const;
962 void SetLineNumberInfo( const SwLineNumberInfo
& rInfo
);
964 /// Labels: Synchronize ranges.
965 void SetLabelDoc( bool bFlag
);
966 bool IsLabelDoc() const;
968 /// Interface for TextInputData - (for input of Japanese/Chinese chars.)
969 void CreateExtTextInput(LanguageType eInputLanguage
);
970 OUString
DeleteExtTextInput( bool bInsText
= true);
971 void SetExtTextInputData( const CommandExtTextInputData
& );
973 /// Returns true iff paragraph signature validation is enabled.
974 bool IsParagraphSignatureValidationEnabled() const { return m_bDoParagraphSignatureValidation
; }
975 /// Enable/Disable paragraph signature validation and return the previous value.
976 bool SetParagraphSignatureValidation(const bool bEnable
)
978 const bool bOldFlag
= m_bDoParagraphSignatureValidation
;
979 m_bDoParagraphSignatureValidation
= bEnable
;
983 /// Interface for access to AutoComplete-list.
984 static SwAutoCompleteWord
& GetAutoCompleteWords();
986 /** @return a scaling factor of selected text. Used for the rotated
987 character attribute dialog. */
988 sal_uInt16
GetScalingOfSelectedText() const;
990 bool IsNbspRunNext() const { return m_bNbspRunNext
; }
993 SwEditShell( SwDoc
&, vcl::Window
*, const SwViewOption
*pOpt
);
995 /// Copy-Constructor in disguise.
996 SwEditShell( SwEditShell
&, vcl::Window
* );
997 virtual ~SwEditShell() override
;
1000 SwEditShell(const SwEditShell
&) = delete;
1001 const SwEditShell
&operator=(const SwEditShell
&) = delete;
1003 /* TODO: this flag may have to be invalidated / reset to false at various
1004 * places if it was true and the edit cursor position changes. It's somehow
1005 * overkill though because it can only be true if a NO-BREAK SPACE was
1006 * inserted by the last DoAutoCorrect() call (in French language), any
1007 * subsequent call will reset it anyway and just if the cursor is
1008 * positioned behind "x :" and the next character inserted is not a space
1009 * the existing nb-space will be removed. Bear this in mind if that problem
1011 bool m_bNbspRunNext
; ///< NO-BREAK SPACE state flag passed to and maintained by SvxAutoCorrect::DoAutoCorrect()
1012 bool m_bDoParagraphSignatureValidation
; ///< Prevent nested calls of ValidateParagraphSignatures.
1015 inline const sfx2::LinkManager
& SwEditShell::GetLinkManager() const
1016 { return const_cast<SwEditShell
*>(this)->GetLinkManager(); }
1018 /// Class for automated call of Start- and EndAction().
1019 class SwActContext
{
1020 SwEditShell
& m_rShell
;
1022 SwActContext(SwEditShell
*pShell
);
1023 ~SwActContext() COVERITY_NOEXCEPT_FALSE
;
1026 /// Class for automated call of Start- and EndCursorMove().
1028 SwEditShell
& m_rShell
;
1030 SwMvContext(SwEditShell
*pShell
);
1031 ~SwMvContext() COVERITY_NOEXCEPT_FALSE
;
1036 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */