a11y: Simplify OCommonAccessibleComponent::getAccessibleIndexInParent
[LibreOffice.git] / sw / inc / ndtxt.hxx
blob174a88e74c53384f4b34dc6632fe05c1460aaf4e
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 #pragma once
21 #include <cppuhelper/weakref.hxx>
22 #include <com/sun/star/text/XTextContent.hpp>
24 #include "swdllapi.h"
25 #include "IDocumentContentOperations.hxx"
26 #include "SwNumberTreeTypes.hxx"
27 #include "hintids.hxx"
28 #include "list.hxx"
29 #include "modeltoviewhelper.hxx"
30 #include "ndhints.hxx"
31 #include "node.hxx"
32 #include "paratr.hxx"
34 #include <sfx2/Metadatable.hxx>
35 #include <unotools/weakref.hxx>
36 #include <o3tl/sorted_vector.hxx>
37 #include <memory>
38 #include <vector>
39 #include <functional>
41 class SfxHint;
42 class SwNumRule;
43 class SwNodeNum;
44 class SvxFirstLineIndentItem;
45 class SvxTextLeftMarginItem;
46 struct SvxFontUnitMetrics;
47 class SwXParagraph;
49 namespace utl {
50 class TransliterationWrapper;
52 namespace vcl
54 class Font;
57 class SwContentFrame;
58 class SwTextField;
59 class SwTextInputField;
60 class SfxItemSet;
61 class SwUndoTransliterate;
62 struct SwSpellArgs;
63 struct SwConversionArgs;
64 class SwInterHyphInfo;
65 class SwWrongList;
66 class SwGrammarMarkUp;
67 struct SwDocStat;
68 enum class ExpandMode;
69 enum class SwFieldIds : sal_uInt16;
70 class SwField;
72 namespace sw {
73 class TextNodeNotificationSuppressor;
74 namespace mark { enum class RestoreMode; }
77 namespace com::sun::star {
78 namespace uno {
79 template < class > class Sequence;
83 typedef o3tl::sorted_vector< sal_Int32 > SwSoftPageBreakList;
85 namespace sw
88 enum class WrongState { TODO, PENDING, DONE };
90 struct ParagraphIdleData
92 std::unique_ptr<SwWrongList> pWrong; // for spell checking
93 std::unique_ptr<SwGrammarMarkUp> pGrammarCheck; // for grammar checking / proof reading
94 std::unique_ptr<SwWrongList> pSmartTags;
95 sal_uLong nNumberOfWords = 0;
96 sal_uLong nNumberOfAsianWords = 0;
97 sal_uLong nNumberOfChars = 0;
98 sal_uLong nNumberOfCharsExcludingSpaces = 0;
99 bool bWordCountDirty = true;
100 WrongState eWrongDirty = WrongState::TODO; ///< online spell checking needed/done?
101 bool bGrammarCheckDirty = true;
102 bool bSmartTagDirty = true;
103 bool bAutoComplDirty = true; ///< auto complete list dirty
106 } // end namespace sw
108 /// SwTextNode is a paragraph in the document model.
109 class SW_DLLPUBLIC SwTextNode final
110 : public SwContentNode
111 , public ::sfx2::Metadatable
112 , public sw::FormatDropDefiner
114 friend class SwContentNode;
115 /// For creating the first TextNode.
116 friend class SwDoc; ///< CTOR and AppendTextNode()
117 friend class SwNodes;
118 friend class SwTextFrame;
119 friend class SwScriptInfo;
120 friend class sw::TextNodeNotificationSuppressor;
122 /** May be 0. It is only then not 0 if it contains hard attributes.
123 Therefore: never access directly! */
124 std::unique_ptr<SwpHints> m_pSwpHints;
126 mutable std::unique_ptr<SwNodeNum> mpNodeNum; ///< Numbering for this paragraph.
127 mutable std::unique_ptr<SwNodeNum> mpNodeNumRLHidden; ///< Numbering for this paragraph (hidden redlines)
128 mutable std::unique_ptr<SwNodeNum> mpNodeNumOrig; ///< Numbering for this paragraph (before changes)
130 OUString m_Text;
132 mutable sw::ParagraphIdleData m_aParagraphIdleData;
134 /** Some of the chars this para are hidden. Paragraph has to be reformatted
135 on changing the view to print preview. */
136 mutable bool m_bContainsHiddenChars : 1;
137 /// The whole paragraph is hidden because of the hidden text attribute
138 mutable bool m_bHiddenCharsHidePara : 1;
139 /// The last two flags have to be recalculated if this flag is set:
140 mutable bool m_bRecalcHiddenCharFlags : 1;
142 mutable bool m_bLastOutlineState : 1;
143 bool m_bNotifiable;
145 bool mbEmptyListStyleSetDueToSetOutlineLevelAttr;
147 /** boolean, indicating that a <SetAttr(..)> or <ResetAttr(..)> or
148 <ResetAllAttr(..)> method is running.
149 Needed to avoid duplicate handling of attribute change actions. */
150 bool mbInSetOrResetAttr;
152 /// Is an undo operation in progress?
153 bool m_bInUndo;
155 std::optional< OUString > m_oNumStringCache;
157 unotools::WeakReference<SwXParagraph> m_wXParagraph;
159 // DrawingLayer FillAttributes in a preprocessed form for primitive usage
160 drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes;
162 SAL_DLLPRIVATE SwTextNode( SwNode& rWhere, SwTextFormatColl *pTextColl,
163 const SfxItemSet* pAutoAttr = nullptr );
164 virtual void SwClientNotify( const SwModify&, const SfxHint& ) override;
165 /// Copies the attributes at nStart to pDest.
166 SAL_DLLPRIVATE void CopyAttr( SwTextNode *pDest, const sal_Int32 nStart, const sal_Int32 nOldPos);
168 SAL_DLLPRIVATE SwTextNode* MakeNewTextNode( SwNode&, bool bNext = true,
169 bool bChgFollow = true );
171 SAL_DLLPRIVATE void CutImpl(
172 SwTextNode * const pDest, const SwContentIndex & rDestStart,
173 const SwContentIndex & rStart, /*const*/ sal_Int32 nLen,
174 const bool bUpdate = true );
176 /// Move all comprising hard attributes to the AttrSet of the paragraph.
177 SAL_DLLPRIVATE void MoveTextAttr_To_AttrSet(); // Called by SplitNode.
179 /// Create the specific AttrSet.
180 SAL_DLLPRIVATE virtual void NewAttrSet( SwAttrPool& ) override;
182 /// Optimization: Asking for information about hidden characters at SwScriptInfo
183 /// updates these flags.
184 bool IsCalcHiddenCharFlags() const
185 { return m_bRecalcHiddenCharFlags; }
186 void SetHiddenCharAttribute( bool bNewHiddenCharsHidePara, bool bNewContainsHiddenChars ) const
188 m_bHiddenCharsHidePara = bNewHiddenCharsHidePara;
189 m_bContainsHiddenChars = bNewContainsHiddenChars;
190 m_bRecalcHiddenCharFlags = false;
193 SAL_DLLPRIVATE void CalcHiddenCharFlags() const;
195 SAL_DLLPRIVATE void SetLanguageAndFont( const SwPaM &rPaM,
196 LanguageType nLang, sal_uInt16 nLangWhichId,
197 const vcl::Font *pFont, sal_uInt16 nFontWhichId );
199 inline void TryDeleteSwpHints();
201 SAL_DLLPRIVATE void impl_FormatToTextAttr(const SfxItemSet& i_rAttrSet);
203 const SwTextInputField* GetOverlappingInputField( const SwTextAttr& rTextAttr ) const;
205 void DelFrames_TextNodePart();
206 void HandleNonLegacyHint(const SfxHint&);
208 public:
209 bool IsWordCountDirty() const;
210 sw::WrongState GetWrongDirty() const;
211 bool IsWrongDirty() const;
212 bool IsGrammarCheckDirty() const;
213 bool IsSmartTagDirty() const;
214 bool IsAutoCompleteWordDirty() const;
215 void SetWordCountDirty( bool bNew ) const;
216 void SetWrongDirty(sw::WrongState eNew) const;
217 void SetGrammarCheckDirty( bool bNew ) const;
218 void SetSmartTagDirty( bool bNew ) const;
219 void SetAutoCompleteWordDirty( bool bNew ) const;
220 void SetWrong( std::unique_ptr<SwWrongList> pNew );
221 void ClearWrong();
222 std::unique_ptr<SwWrongList> ReleaseWrong();
223 SwWrongList* GetWrong();
224 const SwWrongList* GetWrong() const;
225 void SetGrammarCheck( std::unique_ptr<SwGrammarMarkUp> pNew );
226 void ClearGrammarCheck();
227 std::unique_ptr<SwGrammarMarkUp> ReleaseGrammarCheck();
228 SwGrammarMarkUp* GetGrammarCheck();
229 // return SwWrongList because *function pointer* return values aren't covariant
230 SwWrongList const* GetGrammarCheck() const;
231 void SetSmartTags( std::unique_ptr<SwWrongList> pNew );
232 void ClearSmartTags();
233 std::unique_ptr<SwWrongList> ReleaseSmartTags();
234 SwWrongList* GetSmartTags();
235 SwWrongList const* GetSmartTags() const;
237 /// End: Data collected during idle time
239 public:
240 using SwContentNode::GetAttr;
241 void UpdateDocPos(const SwTwips nDocPos, const sal_uInt32 nIndex);
242 /// for hanging TextFormatCollections somewhere else (Outline-Numbering!)
243 void TriggerNodeUpdate(const sw::LegacyModifyHint&);
245 const OUString& GetText() const { return m_Text; }
247 // returns the maximum number of characters that can still be added to the node
248 inline sal_Int32 GetSpaceLeft() const;
250 /// getters for SwpHints
251 inline SwpHints &GetSwpHints();
252 inline const SwpHints &GetSwpHints() const;
253 SwpHints *GetpSwpHints() { return m_pSwpHints.get(); }
254 const SwpHints *GetpSwpHints() const { return m_pSwpHints.get(); }
255 bool HasHints() const { return m_pSwpHints != nullptr; }
256 inline SwpHints &GetOrCreateSwpHints();
258 virtual ~SwTextNode() override;
260 virtual sal_Int32 Len() const override;
262 /// Is in itratr.
263 void GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong &rMax, sal_uLong &rAbs ) const;
265 /// overriding to handle change of certain paragraph attributes
266 virtual bool SetAttr( const SfxPoolItem& ) override;
267 virtual bool SetAttr( const SfxItemSet& rSet ) override;
268 virtual bool ResetAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 ) override;
269 virtual bool ResetAttr( const std::vector<sal_uInt16>& rWhichArr ) override;
270 virtual sal_uInt16 ResetAllAttr() override;
272 /// insert text content
273 /// @param rStr text to insert; in case it does not fit into the capacity
274 /// of the node, the longest prefix that fits is inserted
275 /// @return the prefix of rStr that was actually inserted
276 OUString InsertText( const OUString & rStr, const SwContentIndex & rIdx,
277 const SwInsertFlags nMode
278 = SwInsertFlags::DEFAULT );
279 OUString InsertText( const OUString & rStr, const SwPosition & rIdx,
280 const SwInsertFlags nMode
281 = SwInsertFlags::DEFAULT );
282 /// Add a dummy character to the redline of the table changes
283 void InsertDummy() { m_Text = OUStringChar(CH_TXT_TRACKED_DUMMY_CHAR); }
285 /** delete text content
286 ATTENTION: must not be called with a range that overlaps the start of
287 an attribute with both extent and dummy char
289 void EraseText ( const SwContentIndex &rIdx, const sal_Int32 nCount = SAL_MAX_INT32,
290 const SwInsertFlags nMode = SwInsertFlags::DEFAULT );
291 void EraseText ( const SwPosition& rIdx, const sal_Int32 nCount = SAL_MAX_INT32,
292 const SwInsertFlags nMode = SwInsertFlags::DEFAULT );
294 /** delete all attributes.
295 If neither pSet nor nWhich is given, delete all attributes (except
296 refmarks, toxmarks, meta) in range.
297 @param nContentStart start position
298 @param nLen range in which attributes will be deleted
299 @param pSet if not 0, delete only attributes contained in pSet
300 @param nWhich if not 0, delete only attributes with matching which
301 @param bInclRefToxMark
302 refmarks, toxmarks, and metas will be ignored unless this is true
303 ATTENTION: setting bInclRefToxMark is only allowed from UNDO!
304 @param bExactRange From the attributes included in the range, delete
305 only the ones which have exactly same range. Don't delete the ones
306 which are simply included in the range.
308 void RstTextAttr(
309 const sal_Int32 nContentStart,
310 const sal_Int32 nLen,
311 const sal_uInt16 nWhich = 0,
312 const SfxItemSet* pSet = nullptr,
313 const bool bInclRefToxMark = false,
314 const bool bExactRange = false );
315 void GCAttr();
317 // Delete text attribute (needs to be deregistered at Pool!)
318 void DestroyAttr( SwTextAttr* pAttr );
320 // delete all attributes from SwpHintsArray.
321 void ClearSwpHintsArr( bool bDelFields );
323 /// initialize the hints after file loading (which takes shortcuts)
324 void FileLoadedInitHints();
326 /// Insert pAttr into hints array. @return true iff inserted successfully
327 bool InsertHint( SwTextAttr * const pAttr,
328 const SetAttrMode nMode = SetAttrMode::DEFAULT );
329 /// create new text attribute from rAttr and insert it
330 /// @return inserted hint; 0 if not sure the hint is inserted
331 SwTextAttr* InsertItem( SfxPoolItem& rAttr,
332 const sal_Int32 nStart, const sal_Int32 nEnd,
333 const SetAttrMode nMode = SetAttrMode::DEFAULT );
335 /** Set these attributes at TextNode. If the whole range is comprised
336 set them only in AutoAttrSet (SwContentNode::SetAttr). */
337 bool SetAttr( const SfxItemSet& rSet,
338 sal_Int32 nStt, sal_Int32 nEnd,
339 const SetAttrMode nMode = SetAttrMode::DEFAULT,
340 SwTextAttr **ppNewTextAttr = nullptr);
341 /** Query the attributes of textnode over the range.
342 Introduce 4th optional parameter <bMergeIndentValuesOfNumRule>.
343 If <bMergeIndentValuesOfNumRule> == true, the indent attributes of
344 the corresponding list level of an applied list style is merged into
345 the requested item set as a LR-SPACE item, if <bOnlyTextAttr> == false,
346 corresponding node has not its own indent attributes and the
347 position-and-space mode of the list level is SvxNumberFormat::LABEL_ALIGNMENT. */
348 bool GetParaAttr( SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
349 const bool bOnlyTextAttr = false,
350 const bool bGetFromChrFormat = true,
351 const bool bMergeIndentValuesOfNumRule = false,
352 SwRootFrame const* pLayout = nullptr) const;
354 /// Convey attributes of an AttrSet (AutoFormat) to SwpHintsArray.
355 void FormatToTextAttr( SwTextNode* pNd );
357 /// delete all attributes of type nWhich at nStart (opt. end nEnd)
358 void DeleteAttributes( const sal_uInt16 nWhich,
359 const sal_Int32 nStart, const sal_Int32 nEnd = 0 );
360 /// delete the attribute pTextAttr
361 void DeleteAttribute ( SwTextAttr * const pTextAttr );
363 /** Actions on text and attributes.
364 introduce optional parameter to control, if all attributes have to be copied. */
365 void CopyText( SwTextNode * const pDest,
366 const SwContentIndex &rStart,
367 const sal_Int32 nLen,
368 const bool bForceCopyOfAllAttrs );
369 void CopyText( SwTextNode * const pDest,
370 const SwContentIndex &rDestStart,
371 const SwContentIndex &rStart,
372 sal_Int32 nLen,
373 const bool bForceCopyOfAllAttrs = false );
374 void CopyText( SwTextNode * const pDest,
375 const SwContentIndex &rDestStart,
376 const SwPosition &rStart,
377 sal_Int32 nLen,
378 const bool bForceCopyOfAllAttrs = false );
380 void CutText(SwTextNode * const pDest,
381 const SwContentIndex & rStart, const sal_Int32 nLen);
382 inline void CutText(SwTextNode * const pDest, const SwContentIndex &rDestStart,
383 const SwContentIndex & rStart, const sal_Int32 nLen);
385 /// replace nDelLen characters at rStart with rText
386 /// in case the replacement does not fit, it is partially inserted up to
387 /// the capacity of the node
388 void ReplaceText( const SwContentIndex& rStart, const sal_Int32 nDelLen,
389 const OUString & rText );
390 void ReplaceText( SwPosition& rStart, const sal_Int32 nDelLen,
391 const OUString & rText );
392 void ReplaceTextOnly( sal_Int32 nPos, sal_Int32 nLen,
393 std::u16string_view aText,
394 const css::uno::Sequence<sal_Int32>& rOffsets );
396 /// Virtual methods from ContentNode.
397 virtual SwContentFrame *MakeFrame( SwFrame* ) override;
398 SwTextNode * SplitContentNode(const SwPosition &,
399 std::function<void (SwTextNode *, sw::mark::RestoreMode, bool AtStart)> const* pContentIndexRestore);
400 virtual SwContentNode *JoinNext() override;
401 void JoinPrev();
403 SwContentNode *AppendNode( const SwPosition & );
405 /// When appropriate set DontExpand-flag at INet or character styles respectively.
406 bool DontExpandFormat( sal_Int32 nContentIdx, bool bFlag = true,
407 bool bFormatToTextAttributes = true );
409 /** get the innermost text attribute covering position nIndex.
410 @param nWhich only attribute with this id is returned.
411 @param eMode the predicate for matching (@see GetTextAttrMode).
413 ATTENTION: this function is not well-defined for those
414 hints of which several may cover a single position, like
415 RES_TXTATR_CHARFMT, RES_TXTATR_REFMARK, RES_TXTATR_TOXMARK
417 SwTextAttr *GetTextAttrAt(
418 sal_Int32 const nIndex,
419 sal_uInt16 const nWhich,
420 ::sw::GetTextAttrMode const eMode = ::sw::GetTextAttrMode::Default) const;
422 /** get the innermost text attributes covering position nIndex.
423 @param nWhich only attributes with this id are returned.
424 @param eMode the predicate for matching (@see GetTextAttrMode).
426 std::vector<SwTextAttr *> GetTextAttrsAt(
427 sal_Int32 const nIndex,
428 sal_uInt16 const nWhich ) const;
430 /** get the text attribute at position nIndex which owns
431 the dummy character CH_TXTATR_* at that position, if one exists.
432 @param nIndex the position in the text
433 @param nWhich if different from RES_TXTATR_END, return only
434 attribute with given which id
435 @return the text attribute at nIndex of type nWhich, if it exists
437 SwTextAttr *GetTextAttrForCharAt(
438 const sal_Int32 nIndex,
439 const sal_uInt16 nWhich = RES_TXTATR_END ) const;
442 * Get the text attribute of an end dummy character at nIndex. Return the attribute only in
443 * case its which id is nWhich.
445 * Note that the position of the end dummy character is one less than the end of the attribute.
447 SwTextAttr* GetTextAttrForEndCharAt(sal_Int32 nIndex, sal_uInt16 nWhich) const;
449 SwTextField* GetFieldTextAttrAt(
450 const sal_Int32 nIndex,
451 ::sw::GetTextAttrMode const eMode = ::sw::GetTextAttrMode::Expand) const;
453 bool Spell(SwSpellArgs*);
454 bool Convert( SwConversionArgs & );
456 inline SwTextFormatColl *GetTextColl() const;
457 virtual SwFormatColl *ChgFormatColl( SwFormatColl* ) override;
458 void ChgTextCollUpdateNum(const SwTextFormatColl* pOld,
459 const SwTextFormatColl* pNew );
461 /** Copy collection with all auto formats to dest-node.
462 The latter might be in another document!
463 (Method in ndcopy.cxx!!). */
464 void CopyCollFormat(SwTextNode& rDestNd, bool bUndoForChgFormatColl = true);
466 // BEGIN OF BULLET/NUMBERING/OUTLINE STUFF:
469 Returns numbering rule of this text node.
471 @param bInParent search in parent attributes, too
473 @return numbering rule of this text node or NULL if none is set
475 SwNumRule *GetNumRule(bool bInParent = true) const;
477 const SwNodeNum* GetNum(SwRootFrame const* pLayout = nullptr,
478 SwListRedlineType eRedline = SwListRedlineType::SHOW) const;
479 void DoNum(std::function<void (SwNodeNum &)> const&);
481 SwNumberTree::tNumberVector GetNumberVector(SwRootFrame const* pLayout = nullptr,
482 SwListRedlineType eRedline = SwListRedlineType::SHOW) const;
485 Returns if this text node is an outline.
487 @retval true this text node is an outline
488 @retval false else
490 bool IsOutline() const;
492 bool IsOutlineStateChanged() const;
494 void UpdateOutlineState();
497 Notify this textnode that its numbering rule has changed.
499 void NumRuleChgd();
501 /** Returns outline of numbering string
503 Introduce parameter <_bInclPrefixAndSuffixStrings> in order to control,
504 if the prefix and the suffix strings have to been included or not.
506 @param _bInclPrefixAndSuffixStrings
507 optional input parameter - boolean indicating, if the prefix and the
508 suffix strings have to been included or not. default value = <true>
510 @param _nRestrictToThisLevel
511 optional input parameter - unsigned integer indicating the maximum outline
512 level to which the output string must be restricted to. Default value is
513 MAXLEVEL
515 OUString GetNumString( const bool _bInclPrefixAndSuffixStrings = true,
516 const unsigned int _nRestrictToThisLevel = MAXLEVEL,
517 SwRootFrame const* pLayout = nullptr,
518 SwListRedlineType eRedline = SwListRedlineType::SHOW) const;
521 Returns the additional indents of this text node and its numbering.
523 @param bTextLeft return text-left-margin instead of left-margin
524 (include negative first-line-indent, see lrspitem.hxx)
526 @return additional num indents - a delta to be added to node's items
528 tools::Long GetLeftMarginWithNum( bool bTextLeft = false ) const;
531 Returns the combined first line indent of this text node and
532 its numbering.
534 @param rFirstOffset
535 the first line indent of this text node taking the numbering into
536 account (return parameter)
538 @param rMetrics
539 helper structure containing font metrics, used for resolving font-
540 relative indentation
542 @retval true this node has SwNodeNum and has numbering rule
543 @retval false else
545 bool GetFirstLineOfsWithNum( short& rFirstOffset, const SvxFontUnitMetrics& rMetrics ) const;
547 SwTwips GetAdditionalIndentForStartingNewList() const;
549 /** return left margin for tab stop position calculation
551 Needed for text formatting
552 Method considers new list level attributes, which also can provide a left margin value
554 tools::Long GetLeftMarginForTabCalculation() const;
556 /** Returns if this text node has a number.
558 This text node has a number if it has a SwNodeNum and a
559 numbering rule and the numbering format specified for the
560 level of the SwNodeNum is of an enumeration type.
562 @retval true This text node has a number.
563 @retval false else
565 bool HasNumber(SwRootFrame const* pLayout = nullptr) const;
567 /** Returns if this text node has a bullet.
569 This text node has a bullet if it has a SwNodeNum and a
570 numbering rule and the numbering format specified for the
571 level of the SwNodeNum is of a bullet type.
573 @retval true This text node has a bullet.
574 @retval false else
576 bool HasBullet() const;
578 /** Returns is this text node is numbered.
580 This node is numbered if it has a SwNodeNum and it has a
581 numbering rule and has not a hidden SwNodeNum.
583 ATTENTION: Returns true even if the SwNumFormat has type
584 SVX_NUM_NUMBER_NONE.
586 @retval true This node is numbered.
587 @retval false else
589 bool IsNumbered(SwRootFrame const* pLayout = nullptr) const;
591 /** Returns if this text node has a marked label.
593 @retval true This text node has a marked label.
594 @retval false else
596 bool HasMarkedLabel() const;
598 /** Sets the list level of this text node.
600 Side effect, when the text node is a list item:
601 The text node's representation in the list tree (<SwNodeNum> instance)
602 is updated.
604 @param nLevel level to set
606 void SetAttrListLevel(int nLevel);
608 bool HasAttrListLevel() const;
610 int GetAttrListLevel() const;
612 /** Returns the actual list level of this text node, when it is a list item
614 @return the actual list level of this text node, if it is a list item,
615 -1 otherwise
617 int GetActualListLevel(SwListRedlineType eRedline = SwListRedlineType::SHOW) const;
620 Returns outline level of this text node.
622 @param bInlineHeading it can return the outline level of the inline heading
624 If a text node has an outline number (i.e. it has an SwNodeNum
625 and an outline numbering rule) the outline level is the level of
626 this SwNodeNum.
628 If a text node has no outline number and has a paragraph style
629 attached the outline level is the outline level of the
630 paragraph style.
632 Otherwise the text node has no outline level (NO_NUMBERING),
633 except if bInlineHeading is true, and there is an inline heading
634 at the beginning of the paragraph anchored as character and
635 with a different outline level.
637 NOTE: The outline level of text nodes is subject to change. The
638 plan is to have an SwTextNode::nOutlineLevel member that is
639 updated from a paragraph style upon appliance of that paragraph
640 style.
642 @return outline level or NO_NUMBERING if there is no outline level
644 int GetAttrOutlineLevel(bool bInlineHeading = false) const;
647 Sets the out line level *at* a text node.
649 @param nLevel the level to be set
651 If the text node has an outline number the level is set at the
652 outline number.
654 If the text node has no outline number but has a paragraph
655 style applied the outline level is set at the paragraph style.
657 NOTE: This is subject to change, see GetOutlineLevel.
659 void SetAttrOutlineLevel(int nLevel);
662 * @brief GetAttrOutlineContentVisible
663 * @return true if 'OutlineContentVisibleAttr' is found in RES_PARATR_GRABBAG
665 bool GetAttrOutlineContentVisible() const;
666 void SetAttrOutlineContentVisible(bool bVisible);
668 bool IsEmptyListStyleDueToSetOutlineLevelAttr() const { return mbEmptyListStyleSetDueToSetOutlineLevelAttr;}
669 void SetEmptyListStyleDueToSetOutlineLevelAttr();
670 void ResetEmptyListStyleDueToResetOutlineLevelAttr();
673 Returns the width of leading tabs/blanks in this paragraph.
674 This space will be converted into numbering indent if the paragraph
675 is set to be numbered.
677 @return the width of the leading whitespace
679 SwTwips GetWidthOfLeadingTabs() const;
682 Returns if the paragraph has a visible numbering or bullet.
683 This includes all kinds of numbering/bullet/outlines.
684 Note: This function returns false, if the numbering format is
685 SVX_NUM_NUMBER_NONE or if the numbering/bullet has been deleted.
687 @return true if the paragraph has a visible numbering/bullet/outline
689 bool HasVisibleNumberingOrBullet() const;
691 void SetListId(OUString const& rListId);
692 OUString GetListId() const;
694 /** Determines, if the list level indent attributes can be applied to the
695 paragraph.
697 The list level indents can be applied to the paragraph under the one
698 of following conditions:
699 - the list style is directly applied to the paragraph and the paragraph
700 has no own indent attributes.
701 - the list style is applied to the paragraph through one of its paragraph
702 styles, the paragraph has no own indent attributes and on the paragraph
703 style hierarchy from the paragraph to the paragraph style with the
704 list style no indent attributes are found.
706 @return bitmask
708 ::sw::ListLevelIndents AreListLevelIndentsApplicable() const;
709 bool AreListLevelIndentsApplicableImpl(sal_uInt16 nWhich) const;
711 /** Retrieves the list tab stop position, if the paragraph's list level defines
712 one and this list tab stop has to merged into the tap stops of the paragraph
714 @param nListTabStopPosition
715 output parameter - containing the list tab stop position
717 @return boolean - indicating, if a list tab stop position is provided
719 bool GetListTabStopPosition( tools::Long& nListTabStopPosition ) const;
721 /** Retrieves the character following the list label, if the paragraph's
722 list level defines one.
724 @return the list tab stop position as string
726 OUString GetLabelFollowedBy() const;
728 // END OF BULLET/NUMBERING/OUTLINE STUFF:
730 void fillSoftPageBreakList( SwSoftPageBreakList& rBreak ) const;
732 LanguageType GetLang( const sal_Int32 nBegin, const sal_Int32 nLen = 0,
733 sal_uInt16 nScript = 0, bool bNoneIfNoHyphenation = false ) const;
735 /// in ndcopy.cxx
736 bool IsSymbolAt(sal_Int32 nBegin) const; // In itratr.cxx.
737 virtual SwContentNode* MakeCopy(SwDoc&, SwNode& rWhere, bool bNewFrames) const override;
739 /// Interactive hyphenation: we find TextFrame and call its CalcHyph.
740 bool Hyphenate( SwInterHyphInfo &rHyphInf );
741 void DelSoftHyph( const sal_Int32 nStart, const sal_Int32 nEnd );
743 /** add 4th optional parameter <bAddSpaceAfterListLabelStr> indicating,
744 when <bWithNum = true> that a space is inserted after the string for
745 the list label.
746 add 5th optional parameter <bWithSpacesForLevel> indicating, if additional
747 spaces are inserted in front of the expanded text string depending on
748 the list level. */
749 OUString GetExpandText( SwRootFrame const* pLayout,
750 const sal_Int32 nIdx = 0,
751 const sal_Int32 nLen = -1,
752 const bool bWithNum = false,
753 const bool bAddSpaceAfterListLabelStr = false,
754 const bool bWithSpacesForLevel = false,
755 const ExpandMode eAdditionalMode = ExpandMode::ExpandFootnote | ExpandMode::HideFieldmarkCommands) const;
756 bool CopyExpandText( SwTextNode& rDestNd, const SwContentIndex* pDestIdx,
757 sal_Int32 nIdx, sal_Int32 nLen,
758 SwRootFrame const* pLayout,
759 bool bWithFootnote = true,
760 bool bReplaceTabsWithSpaces = false ) const;
762 OUString GetRedlineText() const;
764 /** @return actual count of initial chars for initial-function.
765 If nWishLen == 0 that of first word. */
766 sal_Int32 GetDropLen(sal_Int32 nWishLen) const;
768 /// Passes back info needed on the dropcap dimensions
769 bool GetDropSize(int& rFontHeight, int& rDropHeight, int& rDropDescent) const;
771 /// Hidden Paragraph Field:
772 bool CalcHiddenParaField()
773 { return m_pSwpHints && m_pSwpHints->CalcHiddenParaField(); }
774 /// set CalcVisible flags
775 void SetCalcHiddenParaField()
776 { if (m_pSwpHints) m_pSwpHints->SetCalcHiddenParaField(); }
778 /// is the paragraph visible?
779 bool IsHiddenByParaField() const
780 { return m_pSwpHints && m_pSwpHints->IsHiddenByParaField(); }
782 /// Hidden Paragraph Field:
784 bool HasHiddenCharAttribute( bool bWholePara ) const
786 if ( m_bRecalcHiddenCharFlags )
787 CalcHiddenCharFlags();
788 return bWholePara ? m_bHiddenCharsHidePara : m_bContainsHiddenChars;
791 void SetCalcHiddenCharFlags() const
792 { m_bRecalcHiddenCharFlags = true; }
794 /** @return if the node is hidden due to
795 1. HiddenParaField
796 2. HiddenCharAttribute
797 3. HiddenSection */
799 bool IsHidden() const;
802 /// override SwContentIndexReg
803 virtual void Update(
804 SwContentIndex const & rPos,
805 const sal_Int32 nChangeLen,
806 UpdateMode eMode) override;
808 /// change text to Upper/Lower/Hiragana/Katakana/...
809 void TransliterateText( utl::TransliterationWrapper& rTrans,
810 sal_Int32 nStart, sal_Int32 nEnd,
811 SwUndoTransliterate* pUndo, bool bUseRedlining = false );
813 /// count words in given range - returns true if we refreshed out count
814 bool CountWords( SwDocStat& rStat, sal_Int32 nStart, sal_Int32 nEnd ) const;
816 /** Checks some global conditions like loading or destruction of document
817 to economize notifications */
818 bool IsNotificationEnabled() const;
820 /// Checks a temporary notification blocker and the global conditions of IsNotificationEnabled()
821 bool IsNotifiable() const;
823 void SetListRestart( bool bRestart );
824 bool IsListRestart() const;
826 void SetAttrListRestartValue( SwNumberTree::tSwNumTreeNumber nNum );
827 bool HasAttrListRestartValue() const;
828 SwNumberTree::tSwNumTreeNumber GetAttrListRestartValue() const;
829 SwNumberTree::tSwNumTreeNumber GetActualListStartValue() const;
831 void SetCountedInList( bool bCounted );
832 bool IsCountedInList() const;
834 void AddToList();
835 void AddToListRLHidden();
836 void AddToListOrig();
837 void RemoveFromList();
838 void RemoveFromListRLHidden();
839 void RemoveFromListOrig();
840 bool IsInList() const;
841 bool IsInListFromStyle() const;
843 bool IsFirstOfNumRule(SwRootFrame const& rLayout) const;
845 SAL_DLLPRIVATE unotools::WeakReference<SwXParagraph> const& GetXParagraph() const
846 { return m_wXParagraph; }
847 SAL_DLLPRIVATE void SetXParagraph(rtl::Reference<SwXParagraph> const& xParagraph);
849 /// sfx2::Metadatable
850 virtual ::sfx2::IXmlIdRegistry& GetRegistry() override;
851 virtual bool IsInClipboard() const override;
852 /// Is this node in the undo array?
853 virtual bool IsInUndo() const override;
854 virtual bool IsInContent() const override;
855 virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override;
857 bool IsCollapse() const;
859 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
861 sal_uInt32 GetRsid( sal_Int32 nStt, sal_Int32 nEnd ) const;
862 sal_uInt32 GetParRsid() const;
864 bool CompareRsid( const SwTextNode &rTextNode, sal_Int32 nStt1, sal_Int32 nStt2 ) const;
865 bool CompareParRsid( const SwTextNode &rTextNode ) const;
867 // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
868 virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const override;
870 /// In MS Word, the font underline setting of the paragraph end position won't affect the formatting of numbering, so we ignore it
871 static bool IsIgnoredCharFormatForNumbering(const sal_uInt16 nWhich, bool bIsCharStyle = false);
872 void FormatDropNotify(const SwFormatDrop& rDrop) override
873 { TriggerNodeUpdate(sw::LegacyModifyHint(&rDrop, &rDrop)); };
875 void SetInSwUndo(bool bInUndo);
878 inline SwpHints & SwTextNode::GetSwpHints()
880 assert( m_pSwpHints );
881 return *m_pSwpHints;
883 inline const SwpHints &SwTextNode::GetSwpHints() const
885 assert( m_pSwpHints );
886 return *m_pSwpHints;
889 inline SwpHints& SwTextNode::GetOrCreateSwpHints()
891 if ( !m_pSwpHints )
893 m_pSwpHints.reset(new SwpHints(*this));
895 return *m_pSwpHints;
898 inline void SwTextNode::TryDeleteSwpHints()
900 if ( m_pSwpHints && m_pSwpHints->CanBeDeleted() )
902 m_pSwpHints.reset();
906 inline SwTextFormatColl* SwTextNode::GetTextColl() const
908 return const_cast<SwTextFormatColl*>(static_cast<const SwTextFormatColl*>(GetRegisteredIn()));
911 /// Inline methods from Node.hxx
912 inline SwTextNode *SwNode::GetTextNode()
914 return SwNodeType::Text == m_nNodeType ? static_cast<SwTextNode*>(this) : nullptr;
917 inline const SwTextNode *SwNode::GetTextNode() const
919 return SwNodeType::Text == m_nNodeType ? static_cast<const SwTextNode*>(this) : nullptr;
922 inline void
923 SwTextNode::CutText(SwTextNode * const pDest, const SwContentIndex & rDestStart,
924 const SwContentIndex & rStart, const sal_Int32 nLen)
926 CutImpl( pDest, rDestStart, rStart, nLen );
929 inline sal_Int32 SwTextNode::GetSpaceLeft() const
931 // do not fill the String up to the max - need to be able to have a
932 // SwPosition "behind" the last character, i.e., at index TXTNODE_MAX + 1
933 const sal_Int32 TXTNODE_MAX = SAL_MAX_INT32 - 2;
934 return TXTNODE_MAX-m_Text.getLength();
937 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */