android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / inc / ndtxt.hxx
blobc16a643ec76c4a40179323f18a0fa65ac303335a
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 class SwXParagraph;
48 namespace utl {
49 class TransliterationWrapper;
51 namespace vcl
53 class Font;
56 class SwContentFrame;
57 class SwTextField;
58 class SwTextInputField;
59 class SfxItemSet;
60 class SwUndoTransliterate;
61 struct SwSpellArgs;
62 struct SwConversionArgs;
63 class SwInterHyphInfo;
64 class SwWrongList;
65 class SwGrammarMarkUp;
66 struct SwDocStat;
67 enum class ExpandMode;
68 enum class SwFieldIds : sal_uInt16;
69 class SwField;
71 namespace sw {
72 class TextNodeNotificationSuppressor;
73 namespace mark { enum class RestoreMode; }
76 namespace com::sun::star {
77 namespace uno {
78 template < class > class Sequence;
82 typedef o3tl::sorted_vector< sal_Int32 > SwSoftPageBreakList;
84 namespace sw
87 enum class WrongState { TODO, PENDING, DONE };
89 struct ParagraphIdleData
91 std::unique_ptr<SwWrongList> pWrong; // for spell checking
92 std::unique_ptr<SwGrammarMarkUp> pGrammarCheck; // for grammar checking / proof reading
93 std::unique_ptr<SwWrongList> pSmartTags;
94 sal_uLong nNumberOfWords = 0;
95 sal_uLong nNumberOfAsianWords = 0;
96 sal_uLong nNumberOfChars = 0;
97 sal_uLong nNumberOfCharsExcludingSpaces = 0;
98 bool bWordCountDirty = true;
99 WrongState eWrongDirty = WrongState::TODO; ///< online spell checking needed/done?
100 bool bGrammarCheckDirty = true;
101 bool bSmartTagDirty = true;
102 bool bAutoComplDirty = true; ///< auto complete list dirty
105 } // end namespace sw
107 /// SwTextNode is a paragraph in the document model.
108 class SW_DLLPUBLIC SwTextNode final
109 : public SwContentNode
110 , public ::sfx2::Metadatable
111 , public sw::FormatDropDefiner
113 friend class SwContentNode;
114 /// For creating the first TextNode.
115 friend class SwDoc; ///< CTOR and AppendTextNode()
116 friend class SwNodes;
117 friend class SwTextFrame;
118 friend class SwScriptInfo;
119 friend class sw::TextNodeNotificationSuppressor;
121 /** May be 0. It is only then not 0 if it contains hard attributes.
122 Therefore: never access directly! */
123 std::unique_ptr<SwpHints> m_pSwpHints;
125 mutable std::unique_ptr<SwNodeNum> mpNodeNum; ///< Numbering for this paragraph.
126 mutable std::unique_ptr<SwNodeNum> mpNodeNumRLHidden; ///< Numbering for this paragraph (hidden redlines)
127 mutable std::unique_ptr<SwNodeNum> mpNodeNumOrig; ///< Numbering for this paragraph (before changes)
129 OUString m_Text;
131 mutable sw::ParagraphIdleData m_aParagraphIdleData;
133 /** Some of the chars this para are hidden. Paragraph has to be reformatted
134 on changing the view to print preview. */
135 mutable bool m_bContainsHiddenChars : 1;
136 /// The whole paragraph is hidden because of the hidden text attribute
137 mutable bool m_bHiddenCharsHidePara : 1;
138 /// The last two flags have to be recalculated if this flag is set:
139 mutable bool m_bRecalcHiddenCharFlags : 1;
141 mutable bool m_bLastOutlineState : 1;
142 bool m_bNotifiable;
144 bool mbEmptyListStyleSetDueToSetOutlineLevelAttr;
146 /** boolean, indicating that a <SetAttr(..)> or <ResetAttr(..)> or
147 <ResetAllAttr(..)> method is running.
148 Needed to avoid duplicate handling of attribute change actions. */
149 bool mbInSetOrResetAttr;
151 /// Is an undo operation in progress?
152 bool m_bInUndo;
154 std::optional< OUString > m_oNumStringCache;
156 unotools::WeakReference<SwXParagraph> m_wXParagraph;
158 // DrawingLayer FillAttributes in a preprocessed form for primitive usage
159 drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes;
161 SAL_DLLPRIVATE SwTextNode( SwNode& rWhere, SwTextFormatColl *pTextColl,
162 const SfxItemSet* pAutoAttr = nullptr );
163 virtual void SwClientNotify( const SwModify&, const SfxHint& ) override;
164 /// Copies the attributes at nStart to pDest.
165 SAL_DLLPRIVATE void CopyAttr( SwTextNode *pDest, const sal_Int32 nStart, const sal_Int32 nOldPos);
167 SAL_DLLPRIVATE SwTextNode* MakeNewTextNode( SwNode&, bool bNext = true,
168 bool bChgFollow = true );
170 SAL_DLLPRIVATE void CutImpl(
171 SwTextNode * const pDest, const SwContentIndex & rDestStart,
172 const SwContentIndex & rStart, /*const*/ sal_Int32 nLen,
173 const bool bUpdate = true );
175 /// Move all comprising hard attributes to the AttrSet of the paragraph.
176 SAL_DLLPRIVATE void MoveTextAttr_To_AttrSet(); // Called by SplitNode.
178 /// Create the specific AttrSet.
179 SAL_DLLPRIVATE virtual void NewAttrSet( SwAttrPool& ) override;
181 /// Optimization: Asking for information about hidden characters at SwScriptInfo
182 /// updates these flags.
183 bool IsCalcHiddenCharFlags() const
184 { return m_bRecalcHiddenCharFlags; }
185 void SetHiddenCharAttribute( bool bNewHiddenCharsHidePara, bool bNewContainsHiddenChars ) const
187 m_bHiddenCharsHidePara = bNewHiddenCharsHidePara;
188 m_bContainsHiddenChars = bNewContainsHiddenChars;
189 m_bRecalcHiddenCharFlags = false;
192 SAL_DLLPRIVATE void CalcHiddenCharFlags() const;
194 SAL_DLLPRIVATE void SetLanguageAndFont( const SwPaM &rPaM,
195 LanguageType nLang, sal_uInt16 nLangWhichId,
196 const vcl::Font *pFont, sal_uInt16 nFontWhichId );
198 inline void TryDeleteSwpHints();
200 SAL_DLLPRIVATE void impl_FormatToTextAttr(const SfxItemSet& i_rAttrSet);
202 const SwTextInputField* GetOverlappingInputField( const SwTextAttr& rTextAttr ) const;
204 void DelFrames_TextNodePart();
205 void HandleNonLegacyHint(const SfxHint&);
207 public:
208 bool IsWordCountDirty() const;
209 sw::WrongState GetWrongDirty() const;
210 bool IsWrongDirty() const;
211 bool IsGrammarCheckDirty() const;
212 bool IsSmartTagDirty() const;
213 bool IsAutoCompleteWordDirty() const;
214 void SetWordCountDirty( bool bNew ) const;
215 void SetWrongDirty(sw::WrongState eNew) const;
216 void SetGrammarCheckDirty( bool bNew ) const;
217 void SetSmartTagDirty( bool bNew ) const;
218 void SetAutoCompleteWordDirty( bool bNew ) const;
219 void SetWrong( std::unique_ptr<SwWrongList> pNew );
220 void ClearWrong();
221 std::unique_ptr<SwWrongList> ReleaseWrong();
222 SwWrongList* GetWrong();
223 const SwWrongList* GetWrong() const;
224 void SetGrammarCheck( std::unique_ptr<SwGrammarMarkUp> pNew );
225 void ClearGrammarCheck();
226 std::unique_ptr<SwGrammarMarkUp> ReleaseGrammarCheck();
227 SwGrammarMarkUp* GetGrammarCheck();
228 // return SwWrongList because *function pointer* return values aren't covariant
229 SwWrongList const* GetGrammarCheck() const;
230 void SetSmartTags( std::unique_ptr<SwWrongList> pNew );
231 void ClearSmartTags();
232 std::unique_ptr<SwWrongList> ReleaseSmartTags();
233 SwWrongList* GetSmartTags();
234 SwWrongList const* GetSmartTags() const;
236 /// End: Data collected during idle time
238 public:
239 using SwContentNode::GetAttr;
240 void UpdateDocPos(const SwTwips nDocPos, const sal_uInt32 nIndex);
241 /// for hanging TextFormatCollections somewhere else (Outline-Numbering!)
242 void TriggerNodeUpdate(const sw::LegacyModifyHint&);
244 const OUString& GetText() const { return m_Text; }
246 // returns the maximum number of characters that can still be added to the node
247 inline sal_Int32 GetSpaceLeft() const;
249 /// getters for SwpHints
250 inline SwpHints &GetSwpHints();
251 inline const SwpHints &GetSwpHints() const;
252 SwpHints *GetpSwpHints() { return m_pSwpHints.get(); }
253 const SwpHints *GetpSwpHints() const { return m_pSwpHints.get(); }
254 bool HasHints() const { return m_pSwpHints != nullptr; }
255 inline SwpHints &GetOrCreateSwpHints();
257 virtual ~SwTextNode() override;
259 virtual sal_Int32 Len() const override;
261 /// Is in itratr.
262 void GetMinMaxSize( SwNodeOffset nIndex, sal_uLong& rMin, sal_uLong &rMax, sal_uLong &rAbs ) const;
264 /// overriding to handle change of certain paragraph attributes
265 virtual bool SetAttr( const SfxPoolItem& ) override;
266 virtual bool SetAttr( const SfxItemSet& rSet ) override;
267 virtual bool ResetAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 ) override;
268 virtual bool ResetAttr( const std::vector<sal_uInt16>& rWhichArr ) override;
269 virtual sal_uInt16 ResetAllAttr() override;
271 /// insert text content
272 /// @param rStr text to insert; in case it does not fit into the capacity
273 /// of the node, the longest prefix that fits is inserted
274 /// @return the prefix of rStr that was actually inserted
275 OUString InsertText( const OUString & rStr, const SwContentIndex & rIdx,
276 const SwInsertFlags nMode
277 = SwInsertFlags::DEFAULT );
278 OUString InsertText( const OUString & rStr, const SwPosition & rIdx,
279 const SwInsertFlags nMode
280 = SwInsertFlags::DEFAULT );
281 /// Add a dummy character to the redline of the table changes
282 void InsertDummy() { m_Text = OUStringChar(CH_TXT_TRACKED_DUMMY_CHAR); }
284 /** delete text content
285 ATTENTION: must not be called with a range that overlaps the start of
286 an attribute with both extent and dummy char
288 void EraseText ( const SwContentIndex &rIdx, const sal_Int32 nCount = SAL_MAX_INT32,
289 const SwInsertFlags nMode = SwInsertFlags::DEFAULT );
290 void EraseText ( const SwPosition& rIdx, const sal_Int32 nCount = SAL_MAX_INT32,
291 const SwInsertFlags nMode = SwInsertFlags::DEFAULT );
293 /** delete all attributes.
294 If neither pSet nor nWhich is given, delete all attributes (except
295 refmarks, toxmarks, meta) in range.
296 @param nContentStart start position
297 @param nLen range in which attributes will be deleted
298 @param pSet if not 0, delete only attributes contained in pSet
299 @param nWhich if not 0, delete only attributes with matching which
300 @param bInclRefToxMark
301 refmarks, toxmarks, and metas will be ignored unless this is true
302 ATTENTION: setting bInclRefToxMark is only allowed from UNDO!
303 @param bExactRange From the attributes included in the range, delete
304 only the ones which have exactly same range. Don't delete the ones
305 which are simply included in the range.
307 void RstTextAttr(
308 const sal_Int32 nContentStart,
309 const sal_Int32 nLen,
310 const sal_uInt16 nWhich = 0,
311 const SfxItemSet* pSet = nullptr,
312 const bool bInclRefToxMark = false,
313 const bool bExactRange = false );
314 void GCAttr();
316 // Delete text attribute (needs to be deregistered at Pool!)
317 void DestroyAttr( SwTextAttr* pAttr );
319 // delete all attributes from SwpHintsArray.
320 void ClearSwpHintsArr( bool bDelFields );
322 /// initialize the hints after file loading (which takes shortcuts)
323 void FileLoadedInitHints();
325 /// Insert pAttr into hints array. @return true iff inserted successfully
326 bool InsertHint( SwTextAttr * const pAttr,
327 const SetAttrMode nMode = SetAttrMode::DEFAULT );
328 /// create new text attribute from rAttr and insert it
329 /// @return inserted hint; 0 if not sure the hint is inserted
330 SwTextAttr* InsertItem( SfxPoolItem& rAttr,
331 const sal_Int32 nStart, const sal_Int32 nEnd,
332 const SetAttrMode nMode = SetAttrMode::DEFAULT );
334 /** Set these attributes at TextNode. If the whole range is comprised
335 set them only in AutoAttrSet (SwContentNode::SetAttr). */
336 bool SetAttr( const SfxItemSet& rSet,
337 sal_Int32 nStt, sal_Int32 nEnd,
338 const SetAttrMode nMode = SetAttrMode::DEFAULT,
339 SwTextAttr **ppNewTextAttr = nullptr);
340 /** Query the attributes of textnode over the range.
341 Introduce 4th optional parameter <bMergeIndentValuesOfNumRule>.
342 If <bMergeIndentValuesOfNumRule> == true, the indent attributes of
343 the corresponding list level of an applied list style is merged into
344 the requested item set as a LR-SPACE item, if <bOnlyTextAttr> == false,
345 corresponding node has not its own indent attributes and the
346 position-and-space mode of the list level is SvxNumberFormat::LABEL_ALIGNMENT. */
347 bool GetParaAttr( SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
348 const bool bOnlyTextAttr = false,
349 const bool bGetFromChrFormat = true,
350 const bool bMergeIndentValuesOfNumRule = false,
351 SwRootFrame const* pLayout = nullptr) const;
353 /// Convey attributes of an AttrSet (AutoFormat) to SwpHintsArray.
354 void FormatToTextAttr( SwTextNode* pNd );
356 /// delete all attributes of type nWhich at nStart (opt. end nEnd)
357 void DeleteAttributes( const sal_uInt16 nWhich,
358 const sal_Int32 nStart, const sal_Int32 nEnd = 0 );
359 /// delete the attribute pTextAttr
360 void DeleteAttribute ( SwTextAttr * const pTextAttr );
362 /** Actions on text and attributes.
363 introduce optional parameter to control, if all attributes have to be copied. */
364 void CopyText( SwTextNode * const pDest,
365 const SwContentIndex &rStart,
366 const sal_Int32 nLen,
367 const bool bForceCopyOfAllAttrs );
368 void CopyText( SwTextNode * const pDest,
369 const SwContentIndex &rDestStart,
370 const SwContentIndex &rStart,
371 sal_Int32 nLen,
372 const bool bForceCopyOfAllAttrs = false );
373 void CopyText( SwTextNode * const pDest,
374 const SwContentIndex &rDestStart,
375 const SwPosition &rStart,
376 sal_Int32 nLen,
377 const bool bForceCopyOfAllAttrs = false );
379 void CutText(SwTextNode * const pDest,
380 const SwContentIndex & rStart, const sal_Int32 nLen);
381 inline void CutText(SwTextNode * const pDest, const SwContentIndex &rDestStart,
382 const SwContentIndex & rStart, const sal_Int32 nLen);
384 /// replace nDelLen characters at rStart with rText
385 /// in case the replacement does not fit, it is partially inserted up to
386 /// the capacity of the node
387 void ReplaceText( const SwContentIndex& rStart, const sal_Int32 nDelLen,
388 const OUString & rText );
389 void ReplaceText( SwPosition& rStart, const sal_Int32 nDelLen,
390 const OUString & rText );
391 void ReplaceTextOnly( sal_Int32 nPos, sal_Int32 nLen,
392 std::u16string_view aText,
393 const css::uno::Sequence<sal_Int32>& rOffsets );
395 /// Virtual methods from ContentNode.
396 virtual SwContentFrame *MakeFrame( SwFrame* ) override;
397 SwTextNode * SplitContentNode(const SwPosition &,
398 std::function<void (SwTextNode *, sw::mark::RestoreMode, bool AtStart)> const* pContentIndexRestore);
399 virtual SwContentNode *JoinNext() override;
400 void JoinPrev();
402 SwContentNode *AppendNode( const SwPosition & );
404 /// When appropriate set DontExpand-flag at INet or character styles respectively.
405 bool DontExpandFormat( sal_Int32 nContentIdx, bool bFlag = true,
406 bool bFormatToTextAttributes = true );
408 /** get the innermost text attribute covering position nIndex.
409 @param nWhich only attribute with this id is returned.
410 @param eMode the predicate for matching (@see GetTextAttrMode).
412 ATTENTION: this function is not well-defined for those
413 hints of which several may cover a single position, like
414 RES_TXTATR_CHARFMT, RES_TXTATR_REFMARK, RES_TXTATR_TOXMARK
416 SwTextAttr *GetTextAttrAt(
417 sal_Int32 const nIndex,
418 sal_uInt16 const nWhich,
419 ::sw::GetTextAttrMode const eMode = ::sw::GetTextAttrMode::Default) const;
421 /** get the innermost text attributes covering position nIndex.
422 @param nWhich only attributes with this id are returned.
423 @param eMode the predicate for matching (@see GetTextAttrMode).
425 std::vector<SwTextAttr *> GetTextAttrsAt(
426 sal_Int32 const nIndex,
427 sal_uInt16 const nWhich ) const;
429 /** get the text attribute at position nIndex which owns
430 the dummy character CH_TXTATR_* at that position, if one exists.
431 @param nIndex the position in the text
432 @param nWhich if different from RES_TXTATR_END, return only
433 attribute with given which id
434 @return the text attribute at nIndex of type nWhich, if it exists
436 SwTextAttr *GetTextAttrForCharAt(
437 const sal_Int32 nIndex,
438 const sal_uInt16 nWhich = RES_TXTATR_END ) const;
441 * Get the text attribute of an end dummy character at nIndex. Return the attribute only in
442 * case its which id is nWhich.
444 * Note that the position of the end dummy character is one less than the end of the attribute.
446 SwTextAttr* GetTextAttrForEndCharAt(sal_Int32 nIndex, sal_uInt16 nWhich) const;
448 SwTextField* GetFieldTextAttrAt(
449 const sal_Int32 nIndex,
450 ::sw::GetTextAttrMode const eMode = ::sw::GetTextAttrMode::Expand) const;
452 bool Spell(SwSpellArgs*);
453 bool Convert( SwConversionArgs & );
455 inline SwTextFormatColl *GetTextColl() const;
456 virtual SwFormatColl *ChgFormatColl( SwFormatColl* ) override;
457 void ChgTextCollUpdateNum( const SwTextFormatColl* pOld,
458 const SwTextFormatColl* pNew );
460 /** Copy collection with all auto formats to dest-node.
461 The latter might be in another document!
462 (Method in ndcopy.cxx!!). */
463 void CopyCollFormat(SwTextNode& rDestNd, bool bUndoForChgFormatColl = true);
465 // BEGIN OF BULLET/NUMBERING/OUTLINE STUFF:
468 Returns numbering rule of this text node.
470 @param bInParent search in parent attributes, too
472 @return numbering rule of this text node or NULL if none is set
474 SwNumRule *GetNumRule(bool bInParent = true) const;
476 const SwNodeNum* GetNum(SwRootFrame const* pLayout = nullptr,
477 SwListRedlineType eRedline = SwListRedlineType::SHOW) const;
478 void DoNum(std::function<void (SwNodeNum &)> const&);
480 SwNumberTree::tNumberVector GetNumberVector(SwRootFrame const* pLayout = nullptr,
481 SwListRedlineType eRedline = SwListRedlineType::SHOW) const;
484 Returns if this text node is an outline.
486 @retval true this text node is an outline
487 @retval false else
489 bool IsOutline() const;
491 bool IsOutlineStateChanged() const;
493 void UpdateOutlineState();
496 Notify this textnode that its numbering rule has changed.
498 void NumRuleChgd();
500 /** Returns outline of numbering string
502 Introduce parameter <_bInclPrefixAndSuffixStrings> in order to control,
503 if the prefix and the suffix strings have to been included or not.
505 @param _bInclPrefixAndSuffixStrings
506 optional input parameter - boolean indicating, if the prefix and the
507 suffix strings have to been included or not. default value = <true>
509 @param _nRestrictToThisLevel
510 optional input parameter - unsigned integer indicating the maximum outline
511 level to which the output string must be restricted to. Default value is
512 MAXLEVEL
514 OUString GetNumString( const bool _bInclPrefixAndSuffixStrings = true,
515 const unsigned int _nRestrictToThisLevel = MAXLEVEL,
516 SwRootFrame const* pLayout = nullptr,
517 SwListRedlineType eRedline = SwListRedlineType::SHOW) const;
520 Returns the additional indents of this text node and its numbering.
522 @param bTextLeft return text-left-margin instead of left-margin
523 (include negative first-line-indent, see lrspitem.hxx)
525 @return additional num indents - a delta to be added to node's items
527 tools::Long GetLeftMarginWithNum( bool bTextLeft = false ) const;
530 Returns the combined first line indent of this text node and
531 its numbering.
533 @param the first line indent of this text node taking the
534 numbering into account (return parameter)
536 @retval true this node has SwNodeNum and has numbering rule
537 @retval false else
539 bool GetFirstLineOfsWithNum( short& rFirstOffset ) const;
541 SwTwips GetAdditionalIndentForStartingNewList() const;
543 void ClearLRSpaceItemDueToListLevelIndents(
544 std::unique_ptr<SvxFirstLineIndentItem>& o_rFirstLineItem,
545 std::unique_ptr<SvxTextLeftMarginItem>& o_rTextLeftMarginItem) const;
547 /** return left margin for tab stop position calculation
549 Needed for text formatting
550 Method considers new list level attributes, which also can provide a left margin value
552 tools::Long GetLeftMarginForTabCalculation() const;
554 /** Returns if this text node has a number.
556 This text node has a number if it has a SwNodeNum and a
557 numbering rule and the numbering format specified for the
558 level of the SwNodeNum is of an enumeration type.
560 @retval true This text node has a number.
561 @retval false else
563 bool HasNumber(SwRootFrame const* pLayout = nullptr) const;
565 /** Returns if this text node has a bullet.
567 This text node has a bullet if it has a SwNodeNum and a
568 numbering rule and the numbering format specified for the
569 level of the SwNodeNum is of a bullet type.
571 @retval true This text node has a bullet.
572 @retval false else
574 bool HasBullet() const;
576 /** Returns is this text node is numbered.
578 This node is numbered if it has a SwNodeNum and it has a
579 numbering rule and has not a hidden SwNodeNum.
581 ATTENTION: Returns true even if the SwNumFormat has type
582 SVX_NUM_NUMBER_NONE.
584 @retval true This node is numbered.
585 @retval false else
587 bool IsNumbered(SwRootFrame const* pLayout = nullptr) const;
589 /** Returns if this text node has a marked label.
591 @retval true This text node has a marked label.
592 @retval false else
594 bool HasMarkedLabel() const;
596 /** Sets the list level of this text node.
598 Side effect, when the text node is a list item:
599 The text node's representation in the list tree (<SwNodeNum> instance)
600 is updated.
602 @param nLevel level to set
604 void SetAttrListLevel(int nLevel);
606 bool HasAttrListLevel() const;
608 int GetAttrListLevel() const;
610 /** Returns the actual list level of this text node, when it is a list item
612 @return the actual list level of this text node, if it is a list item,
613 -1 otherwise
615 int GetActualListLevel(SwListRedlineType eRedline = SwListRedlineType::SHOW) const;
618 Returns outline level of this text node.
620 If a text node has an outline number (i.e. it has an SwNodeNum
621 and an outline numbering rule) the outline level is the level of
622 this SwNodeNum.
624 If a text node has no outline number and has a paragraph style
625 attached the outline level is the outline level of the
626 paragraph style.
628 Otherwise the text node has no outline level (NO_NUMBERING).
630 NOTE: The outline level of text nodes is subject to change. The
631 plan is to have an SwTextNode::nOutlineLevel member that is
632 updated from a paragraph style upon appliance of that paragraph
633 style.
635 @return outline level or NO_NUMBERING if there is no outline level
637 int GetAttrOutlineLevel() const;
640 Sets the out line level *at* a text node.
642 @param nLevel the level to be set
644 If the text node has an outline number the level is set at the
645 outline number.
647 If the text node has no outline number but has a paragraph
648 style applied the outline level is set at the paragraph style.
650 NOTE: This is subject to change, see GetOutlineLevel.
652 void SetAttrOutlineLevel(int nLevel);
655 * @brief GetAttrOutlineContentVisible
656 * @param bOutlineContentVisibleAttr the value stored in RES_PARATR_GRABBAG for 'OutlineContentVisibleAttr'
657 * @return true if 'OutlineContentVisibleAttr' is found in RES_PARATR_GRABBAG
659 void GetAttrOutlineContentVisible(bool& bOutlineContentVisibleAttr);
660 void SetAttrOutlineContentVisible(bool bVisible);
662 bool IsEmptyListStyleDueToSetOutlineLevelAttr() const { return mbEmptyListStyleSetDueToSetOutlineLevelAttr;}
663 void SetEmptyListStyleDueToSetOutlineLevelAttr();
664 void ResetEmptyListStyleDueToResetOutlineLevelAttr();
667 Returns the width of leading tabs/blanks in this paragraph.
668 This space will be converted into numbering indent if the paragraph
669 is set to be numbered.
671 @return the width of the leading whitespace
673 SwTwips GetWidthOfLeadingTabs() const;
676 Returns if the paragraph has a visible numbering or bullet.
677 This includes all kinds of numbering/bullet/outlines.
678 Note: This function returns false, if the numbering format is
679 SVX_NUM_NUMBER_NONE or if the numbering/bullet has been deleted.
681 @return true if the paragraph has a visible numbering/bullet/outline
683 bool HasVisibleNumberingOrBullet() const;
685 void SetListId(OUString const& rListId);
686 OUString GetListId() const;
688 /** Determines, if the list level indent attributes can be applied to the
689 paragraph.
691 The list level indents can be applied to the paragraph under the one
692 of following conditions:
693 - the list style is directly applied to the paragraph and the paragraph
694 has no own indent attributes.
695 - the list style is applied to the paragraph through one of its paragraph
696 styles, the paragraph has no own indent attributes and on the paragraph
697 style hierarchy from the paragraph to the paragraph style with the
698 list style no indent attributes are found.
700 @return bitmask
702 ::sw::ListLevelIndents AreListLevelIndentsApplicable() const;
703 bool AreListLevelIndentsApplicableImpl(sal_uInt16 nWhich) const;
705 /** Retrieves the list tab stop position, if the paragraph's list level defines
706 one and this list tab stop has to merged into the tap stops of the paragraph
708 @param nListTabStopPosition
709 output parameter - containing the list tab stop position
711 @return boolean - indicating, if a list tab stop position is provided
713 bool GetListTabStopPosition( tools::Long& nListTabStopPosition ) const;
715 /** Retrieves the character following the list label, if the paragraph's
716 list level defines one.
718 @return the list tab stop position as string
720 OUString GetLabelFollowedBy() const;
722 // END OF BULLET/NUMBERING/OUTLINE STUFF:
724 void fillSoftPageBreakList( SwSoftPageBreakList& rBreak ) const;
726 LanguageType GetLang( const sal_Int32 nBegin, const sal_Int32 nLen = 0,
727 sal_uInt16 nScript = 0 ) const;
729 /// in ndcopy.cxx
730 bool IsSymbolAt(sal_Int32 nBegin) const; // In itratr.cxx.
731 virtual SwContentNode* MakeCopy(SwDoc&, SwNode& rWhere, bool bNewFrames) const override;
733 /// Interactive hyphenation: we find TextFrame and call its CalcHyph.
734 bool Hyphenate( SwInterHyphInfo &rHyphInf );
735 void DelSoftHyph( const sal_Int32 nStart, const sal_Int32 nEnd );
737 /** add 4th optional parameter <bAddSpaceAfterListLabelStr> indicating,
738 when <bWithNum = true> that a space is inserted after the string for
739 the list label.
740 add 5th optional parameter <bWithSpacesForLevel> indicating, if additional
741 spaces are inserted in front of the expanded text string depending on
742 the list level. */
743 OUString GetExpandText( SwRootFrame const* pLayout,
744 const sal_Int32 nIdx = 0,
745 const sal_Int32 nLen = -1,
746 const bool bWithNum = false,
747 const bool bAddSpaceAfterListLabelStr = false,
748 const bool bWithSpacesForLevel = false,
749 const ExpandMode eAdditionalMode = ExpandMode::ExpandFootnote | ExpandMode::HideFieldmarkCommands) const;
750 bool CopyExpandText( SwTextNode& rDestNd, const SwContentIndex* pDestIdx,
751 sal_Int32 nIdx, sal_Int32 nLen,
752 SwRootFrame const* pLayout,
753 bool bWithNum = false, bool bWithFootnote = true,
754 bool bReplaceTabsWithSpaces = false ) const;
756 OUString GetRedlineText() const;
758 /** @return actual count of initial chars for initial-function.
759 If nWishLen == 0 that of first word. */
760 sal_Int32 GetDropLen(sal_Int32 nWishLen) const;
762 /// Passes back info needed on the dropcap dimensions
763 bool GetDropSize(int& rFontHeight, int& rDropHeight, int& rDropDescent) const;
765 /// Hidden Paragraph Field:
766 bool CalcHiddenParaField()
767 { return m_pSwpHints && m_pSwpHints->CalcHiddenParaField(); }
768 /// set CalcVisible flags
769 void SetCalcHiddenParaField()
770 { if (m_pSwpHints) m_pSwpHints->SetCalcHiddenParaField(); }
772 /// is the paragraph visible?
773 bool IsHiddenByParaField() const
774 { return m_pSwpHints && m_pSwpHints->IsHiddenByParaField(); }
776 /// Hidden Paragraph Field:
778 bool HasHiddenCharAttribute( bool bWholePara ) const
780 if ( m_bRecalcHiddenCharFlags )
781 CalcHiddenCharFlags();
782 return bWholePara ? m_bHiddenCharsHidePara : m_bContainsHiddenChars;
785 void SetCalcHiddenCharFlags() const
786 { m_bRecalcHiddenCharFlags = true; }
788 /** @return if the node is hidden due to
789 1. HiddenParaField
790 2. HiddenCharAttribute
791 3. HiddenSection */
793 bool IsHidden() const;
796 /// override SwContentIndexReg
797 virtual void Update(
798 SwContentIndex const & rPos,
799 const sal_Int32 nChangeLen,
800 UpdateMode eMode) override;
802 /// change text to Upper/Lower/Hiragana/Katakana/...
803 void TransliterateText( utl::TransliterationWrapper& rTrans,
804 sal_Int32 nStart, sal_Int32 nEnd,
805 SwUndoTransliterate* pUndo, bool bUseRedlining = false );
807 /// count words in given range - returns true if we refreshed out count
808 bool CountWords( SwDocStat& rStat, sal_Int32 nStart, sal_Int32 nEnd ) const;
810 /** Checks some global conditions like loading or destruction of document
811 to economize notifications */
812 bool IsNotificationEnabled() const;
814 /// Checks a temporary notification blocker and the global conditions of IsNotificationEnabled()
815 bool IsNotifiable() const;
817 void SetListRestart( bool bRestart );
818 bool IsListRestart() const;
820 void SetAttrListRestartValue( SwNumberTree::tSwNumTreeNumber nNum );
821 bool HasAttrListRestartValue() const;
822 SwNumberTree::tSwNumTreeNumber GetAttrListRestartValue() const;
823 SwNumberTree::tSwNumTreeNumber GetActualListStartValue() const;
825 void SetCountedInList( bool bCounted );
826 bool IsCountedInList() const;
828 void AddToList();
829 void AddToListRLHidden();
830 void AddToListOrig();
831 void RemoveFromList();
832 void RemoveFromListRLHidden();
833 void RemoveFromListOrig();
834 bool IsInList() const;
836 bool IsFirstOfNumRule(SwRootFrame const& rLayout) const;
838 SAL_DLLPRIVATE unotools::WeakReference<SwXParagraph> const& GetXParagraph() const
839 { return m_wXParagraph; }
840 SAL_DLLPRIVATE void SetXParagraph(rtl::Reference<SwXParagraph> const& xParagraph);
842 /// sfx2::Metadatable
843 virtual ::sfx2::IXmlIdRegistry& GetRegistry() override;
844 virtual bool IsInClipboard() const override;
845 /// Is this node in the undo array?
846 virtual bool IsInUndo() const override;
847 virtual bool IsInContent() const override;
848 virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() override;
850 bool IsCollapse() const;
852 virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
854 sal_uInt32 GetRsid( sal_Int32 nStt, sal_Int32 nEnd ) const;
855 sal_uInt32 GetParRsid() const;
857 bool CompareRsid( const SwTextNode &rTextNode, sal_Int32 nStt1, sal_Int32 nStt2 ) const;
858 bool CompareParRsid( const SwTextNode &rTextNode ) const;
860 // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
861 virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const override;
863 /// In MS Word, the font underline setting of the paragraph end position won't affect the formatting of numbering, so we ignore it
864 static bool IsIgnoredCharFormatForNumbering(const sal_uInt16 nWhich, bool bIsCharStyle = false);
865 void FormatDropNotify(const SwFormatDrop& rDrop) override
866 { TriggerNodeUpdate(sw::LegacyModifyHint(&rDrop, &rDrop)); };
868 void SetInSwUndo(bool bInUndo);
871 inline SwpHints & SwTextNode::GetSwpHints()
873 assert( m_pSwpHints );
874 return *m_pSwpHints;
876 inline const SwpHints &SwTextNode::GetSwpHints() const
878 assert( m_pSwpHints );
879 return *m_pSwpHints;
882 inline SwpHints& SwTextNode::GetOrCreateSwpHints()
884 if ( !m_pSwpHints )
886 m_pSwpHints.reset(new SwpHints(*this));
888 return *m_pSwpHints;
891 inline void SwTextNode::TryDeleteSwpHints()
893 if ( m_pSwpHints && m_pSwpHints->CanBeDeleted() )
895 m_pSwpHints.reset();
899 inline SwTextFormatColl* SwTextNode::GetTextColl() const
901 return const_cast<SwTextFormatColl*>(static_cast<const SwTextFormatColl*>(GetRegisteredIn()));
904 /// Inline methods from Node.hxx
905 inline SwTextNode *SwNode::GetTextNode()
907 return SwNodeType::Text == m_nNodeType ? static_cast<SwTextNode*>(this) : nullptr;
910 inline const SwTextNode *SwNode::GetTextNode() const
912 return SwNodeType::Text == m_nNodeType ? static_cast<const SwTextNode*>(this) : nullptr;
915 inline void
916 SwTextNode::CutText(SwTextNode * const pDest, const SwContentIndex & rDestStart,
917 const SwContentIndex & rStart, const sal_Int32 nLen)
919 CutImpl( pDest, rDestStart, rStart, nLen );
922 inline sal_Int32 SwTextNode::GetSpaceLeft() const
924 // do not fill the String up to the max - need to be able to have a
925 // SwPosition "behind" the last character, i.e., at index TXTNODE_MAX + 1
926 const sal_Int32 TXTNODE_MAX = SAL_MAX_INT32 - 2;
927 return TXTNODE_MAX-m_Text.getLength();
930 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */