LibreOffice Module sw (master) 1
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
SwpHints Class Reference

An SwTextAttr container, stores all directly formatted text portions for a text node. More...

#include <ndhints.hxx>

Collaboration diagram for SwpHints:
[legend]

Public Member Functions

 SwpHints (const SwTextNode &rParent)
 
size_t Count () const
 
bool Contains (const SwTextAttr *pHt) const
 
SwTextAttrGet (size_t nPos) const
 
SwTextAttrGetWithoutResorting (size_t nPos) const
 
int GetLastPosSortedByEnd (sal_Int32 nEndPos) const
 
SwTextAttrGetSortedByEnd (size_t nPos) const
 
size_t GetFirstPosSortedByWhichAndStart (sal_uInt16 nWhich) const
 
SwTextAttrGetSortedByWhichAndStart (size_t nPos) const
 
void SortIfNeedBe () const
 Trigger the sorting if necessary. More...
 
SwTextAttrCut (const size_t nPosInStart)
 
bool CanBeDeleted () const
 
void Register (SwRegHistory *pHist)
 register a History, which receives all attribute changes (for Undo) More...
 
void DeRegister ()
 deregister the currently registered History More...
 
SwRegHistoryGetHistory () const
 
bool TryInsertHint (SwTextAttr *const pHint, SwTextNode &rNode, const SetAttrMode nMode=SetAttrMode::DEFAULT)
 try to insert the hint More...
 
bool HasFootnote () const
 
bool IsInSplitNode () const
 
bool CalcHiddenParaField () const
 
void StartPosChanged () const
 
void EndPosChanged () const
 

Private Member Functions

void NoteInHistory (SwTextAttr *pAttr, const bool bNew=false)
 records a new attribute in m_pHistory. More...
 
void CalcFlags ()
 
void DeleteAtPos (size_t nPos)
 
void Delete (SwTextAttr const *pTextHt)
 Delete the given Hint. The Hint must actually be in the array! More...
 
void SetInSplitNode (bool bInSplit)
 
void SetCalcHiddenParaField () const
 
void SetHiddenByParaField (const bool bNew) const
 
bool IsHiddenByParaField () const
 
void InsertNesting (SwTextAttrNesting &rNewHint)
 Insert nesting hint into the hints array. More...
 
bool TryInsertNesting (SwTextNode &rNode, SwTextAttrNesting &rNewHint)
 The following hints correspond to well-formed XML elements in ODF: RES_TXTATR_INETFMT, RES_TXTATR_CJK_RUBY, RES_TXTATR_META, RES_TXTATR_METAFIELD, RES_TXTATR_CONTENTCONTROL. More...
 
void BuildPortions (SwTextNode &rNode, SwTextAttr &rNewHint, const SetAttrMode nMode)
 
bool MergePortions (SwTextNode &rNode)
 
void Insert (SwTextAttr *pHt)
 
SW_DLLPUBLIC void Resort () const
 
SW_DLLPUBLIC void ResortStartMap () const
 
SW_DLLPUBLIC void ResortEndMap () const
 
SW_DLLPUBLIC void ResortWhichMap () const
 
size_t GetIndexOf (const SwTextAttr *pHt) const
 
bool Check (bool) const
 

Private Attributes

const SwTextNodem_rParent
 
std::vector< SwTextAttr * > m_HintsByStart
 
std::vector< SwTextAttr * > m_HintsByEnd
 
std::vector< SwTextAttr * > m_HintsByWhichAndStart
 
SwRegHistorym_pHistory
 for Undo More...
 
bool m_bInSplitNode: 1
 true: the Node is in Split and Frames are moved More...
 
bool m_bCalcHiddenParaField: 1
 
bool m_bHiddenByParaField: 1
 
bool m_bFootnote: 1
 footnotes More...
 
bool m_bDDEFields: 1
 the TextNode has DDE fields More...
 
bool m_bStartMapNeedsSorting: 1
 
bool m_bEndMapNeedsSorting: 1
 
bool m_bWhichMapNeedsSorting: 1
 

Static Private Attributes

static const size_t MAX_HINTS = SAL_MAX_SIZE-1
 

Friends

class SwTextNode
 Delete methods may only be called by the TextNode! Because the TextNode also guarantees removal of the Character for attributes without an end. More...
 

Detailed Description

An SwTextAttr container, stores all directly formatted text portions for a text node.

Definition at line 67 of file ndhints.hxx.

Constructor & Destructor Documentation

◆ SwpHints()

SwpHints::SwpHints ( const SwTextNode rParent)

Definition at line 92 of file thints.cxx.

References m_rParent.

Member Function Documentation

◆ BuildPortions()

void SwpHints::BuildPortions ( SwTextNode rNode,
SwTextAttr rNewHint,
const SetAttrMode  nMode 
)
private

◆ CalcFlags()

void SwpHints::CalcFlags ( )
private

◆ CalcHiddenParaField()

bool SwpHints::CalcHiddenParaField ( ) const

◆ CanBeDeleted()

bool SwpHints::CanBeDeleted ( ) const
inline

Definition at line 192 of file ndhints.hxx.

References m_HintsByStart.

◆ Check()

bool SwpHints::Check ( bool  bPortionsMerged) const
private

◆ Contains()

bool SwpHints::Contains ( const SwTextAttr pHt) const

Definition at line 169 of file ndhints.cxx.

References m_HintsByStart.

Referenced by lcl_CopyHint().

◆ Count()

size_t SwpHints::Count ( ) const
inline

◆ Cut()

SwTextAttr * SwpHints::Cut ( const size_t  nPosInStart)
inline

◆ Delete()

void SwpHints::Delete ( SwTextAttr const *  pTextHt)
private

Delete the given Hint. The Hint must actually be in the array!

delete the hint precondition: pTextHt must be in this array

Definition at line 3429 of file thints.cxx.

References DeleteAtPos(), GetIndexOf(), and nPos.

Referenced by BuildPortions(), SwTextNode::CopyText(), MergePortions(), and TryInsertNesting().

◆ DeleteAtPos()

void SwpHints::DeleteAtPos ( size_t  nPos)
private

◆ DeRegister()

void SwpHints::DeRegister ( )
inline

◆ EndPosChanged()

void SwpHints::EndPosChanged ( ) const
inline

◆ Get()

SwTextAttr * SwpHints::Get ( size_t  nPos) const
inline

◆ GetFirstPosSortedByWhichAndStart()

size_t SwpHints::GetFirstPosSortedByWhichAndStart ( sal_uInt16  nWhich) const

Definition at line 458 of file ndhints.cxx.

References m_bWhichMapNeedsSorting, m_HintsByWhichAndStart, and ResortWhichMap().

Referenced by lcl_GetTextAttrs().

◆ GetHistory()

SwRegHistory * SwpHints::GetHistory ( ) const
inline

Definition at line 198 of file ndhints.hxx.

References m_pHistory.

Referenced by SwTextNode::InsertHint().

◆ GetIndexOf()

size_t SwpHints::GetIndexOf ( const SwTextAttr pHt) const
private

Definition at line 476 of file ndhints.cxx.

References CompareSwpHtStart(), m_bStartMapNeedsSorting, m_HintsByStart, and ResortStartMap().

Referenced by Delete().

◆ GetLastPosSortedByEnd()

int SwpHints::GetLastPosSortedByEnd ( sal_Int32  nEndPos) const

Definition at line 468 of file ndhints.cxx.

References m_bEndMapNeedsSorting, m_HintsByEnd, and ResortEndMap().

◆ GetSortedByEnd()

SwTextAttr * SwpHints::GetSortedByEnd ( size_t  nPos) const
inline

◆ GetSortedByWhichAndStart()

SwTextAttr * SwpHints::GetSortedByWhichAndStart ( size_t  nPos) const
inline

Definition at line 167 of file ndhints.hxx.

References m_bWhichMapNeedsSorting, m_HintsByWhichAndStart, nPos, and ResortWhichMap().

Referenced by lcl_GetTextAttrs().

◆ GetWithoutResorting()

SwTextAttr * SwpHints::GetWithoutResorting ( size_t  nPos) const
inline

Definition at line 152 of file ndhints.hxx.

References m_HintsByStart, and nPos.

Referenced by BuildPortions().

◆ HasFootnote()

bool SwpHints::HasFootnote ( ) const
inline

Definition at line 205 of file ndhints.hxx.

References m_bFootnote.

◆ Insert()

void SwpHints::Insert ( SwTextAttr pHt)
private

◆ InsertNesting()

void SwpHints::InsertNesting ( SwTextAttrNesting rNewHint)
private

Insert nesting hint into the hints array.

Also calls NoteInHistory.

Parameters
rNewHintthe hint to be inserted (must not overlap existing!)

Definition at line 301 of file thints.cxx.

References Insert(), and NoteInHistory().

Referenced by TryInsertNesting().

◆ IsHiddenByParaField()

bool SwpHints::IsHiddenByParaField ( ) const
inlineprivate

Definition at line 112 of file ndhints.hxx.

References CalcHiddenParaField(), m_bCalcHiddenParaField, and m_bHiddenByParaField.

◆ IsInSplitNode()

bool SwpHints::IsInSplitNode ( ) const
inline

Definition at line 206 of file ndhints.hxx.

References m_bInSplitNode.

Referenced by SwTextFlyCnt::SetAnchor().

◆ MergePortions()

bool SwpHints::MergePortions ( SwTextNode rNode)
private

◆ NoteInHistory()

void SwpHints::NoteInHistory ( SwTextAttr pAttr,
const bool  bNew = false 
)
private

records a new attribute in m_pHistory.

Definition at line 2694 of file thints.cxx.

References SwRegHistory::AddHint(), and m_pHistory.

Referenced by BuildPortions(), DeleteAtPos(), InsertNesting(), MergePortions(), and TryInsertHint().

◆ Register()

void SwpHints::Register ( SwRegHistory pHist)
inline

register a History, which receives all attribute changes (for Undo)

Definition at line 195 of file ndhints.hxx.

References m_pHistory.

Referenced by SwDoc::DeleteFormatRefMark(), SwDoc::DeleteTOXMark(), DeRegister(), SwRegHistory::InsertItems(), and sw::DocumentContentOperationsManager::lcl_RstTextAttr().

◆ Resort()

void SwpHints::Resort ( ) const
private

◆ ResortEndMap()

void SwpHints::ResortEndMap ( ) const
private

◆ ResortStartMap()

void SwpHints::ResortStartMap ( ) const
private

◆ ResortWhichMap()

void SwpHints::ResortWhichMap ( ) const
private

◆ SetCalcHiddenParaField()

void SwpHints::SetCalcHiddenParaField ( ) const
inlineprivate

Definition at line 110 of file ndhints.hxx.

References m_bCalcHiddenParaField.

◆ SetHiddenByParaField()

void SwpHints::SetHiddenByParaField ( const bool  bNew) const
inlineprivate

Definition at line 111 of file ndhints.hxx.

References m_bHiddenByParaField.

Referenced by CalcHiddenParaField().

◆ SetInSplitNode()

void SwpHints::SetInSplitNode ( bool  bInSplit)
inlineprivate

Definition at line 109 of file ndhints.hxx.

References m_bInSplitNode.

Referenced by SwTextNode::SplitContentNode().

◆ SortIfNeedBe()

void SwpHints::SortIfNeedBe ( ) const
inline

◆ StartPosChanged()

void SwpHints::StartPosChanged ( ) const
inline

◆ TryInsertHint()

bool SwpHints::TryInsertHint ( SwTextAttr *const  pHint,
SwTextNode rNode,
const SetAttrMode  nMode = SetAttrMode::DEFAULT 
)

try to insert the hint

Returns
true iff hint successfully inserted

Definition at line 3037 of file thints.cxx.

References Before, Behind, BuildPortions(), CalcFlags(), CHECK, SwTextField::ChgTextNode(), SwField::ChgTyp(), CollideEnd, CollideStart, ComparePosition(), Count(), Cut(), Database, DbNextSet, DbNumSet, Dde, SwTextNode::DestroyAttr(), DONTEXPAND, Get(), SwTextAttr::GetAttr(), SwDoc::GetAttrPool(), SwTextAttr::GetAutoFormat(), SwFormatCharFormat::GetCharFormat(), SwTextAttr::GetCharFormat(), SwNode::GetDoc(), SwDoc::GetDocShell(), SwTextAttr::GetEnd(), SwFormatField::GetField(), SwTextAttr::GetFormatField(), SwDoc::getIDocumentFieldsAccess(), CharFormat::GetItem(), SwFormat::GetItemState(), SwNode::GetNodes(), SwTextField::GetpTextNode(), SwTextAttr::GetStart(), SwFormatAutoFormat::GetStyleHandle(), SwField::GetTyp(), nsSwGetSetExpType::GSE_SEQ, HiddenPara, HiddenText, IDocumentFieldsAccess::InsDeletedFieldType(), IDocumentFieldsAccess::InsDelFieldInFieldLst(), Insert(), INSERTED, IDocumentFieldsAccess::InsertFieldType(), SwNodes::IsDocNodes(), SwDoc::IsInReading(), SwDoc::IsInXMLImport(), SwTextAttr::IsNesting(), IDocumentFieldsAccess::IsNewFieldLst(), SwTextAttr::IsOverlapAllowedAttr(), lcl_CheckSortNumber(), MAX_HINTS, MergePortions(), n, NOHINTADJUST, NoteInHistory(), Outside, OverlapBefore, OverlapBehind, Postit, SwFormatField::RegisterToFieldType(), RES_CHRATR_HIDDEN(), RES_CHRATR_RSID(), RES_TXTATR_ANNOTATION(), RES_TXTATR_AUTOFMT(), RES_TXTATR_CHARFMT(), RES_TXTATR_CJK_RUBY(), RES_TXTATR_CONTENTCONTROL(), RES_TXTATR_FIELD(), RES_TXTATR_FTN(), RES_TXTATR_INETFMT(), RES_TXTATR_INPUTFIELD(), RES_TXTATR_META(), RES_TXTATR_METAFIELD(), RES_TXTATR_REFMARK(), RES_TXTATR_TOXMARK(), SwTextNode::SetCalcHiddenCharFlags(), SwTextAttr::SetDontExpand(), SwTextAttr::SetEnd(), SetExp, SwSetExpFieldType::SetSeqRefNo(), SwTextAttr::SetStart(), SwTextNode::TriggerNodeUpdate(), TryInsertNesting(), User, SwFieldType::Which(), and SwTextAttr::Which().

◆ TryInsertNesting()

bool SwpHints::TryInsertNesting ( SwTextNode rNode,
SwTextAttrNesting rNewHint 
)
private

The following hints correspond to well-formed XML elements in ODF: RES_TXTATR_INETFMT, RES_TXTATR_CJK_RUBY, RES_TXTATR_META, RES_TXTATR_METAFIELD, RES_TXTATR_CONTENTCONTROL.

The writer core must ensure that these do not overlap; if they did, the document would not be storable as ODF.

Also, a Hyperlink must not be nested within another Hyperlink, and a Ruby must not be nested within another Ruby.

The ODF export in xmloff will only put a hyperlink into a ruby, never a ruby into a hyperlink.

Unfortunately the UNO API for Hyperlink and Ruby consists of the properties Hyperlink* and Ruby* of the css.text.CharacterProperties service. In other words, they are treated as formatting attributes, not as content entities. Furthermore, for API users it is not possible to easily test whether a certain range would be overlapping with other nested attributes, and most importantly, which ones, so we can hardly refuse to insert these in cases of overlap.

It is possible to split Hyperlink and Ruby into multiple portions, such that the result is properly nested.

meta and meta-field must not be split, because they have xml:id.

content controls should not split, either.

These constraints result in the following design:

RES_TXTATR_INETFMT: always succeeds inserts n attributes split at RES_TXTATR_CJK_RUBY, RES_TXTATR_META, RES_TXTATR_METAFIELD may replace existing RES_TXTATR_INETFMT at overlap RES_TXTATR_CJK_RUBY: always succeeds inserts n attributes split at RES_TXTATR_META, RES_TXTATR_METAFIELD may replace existing RES_TXTATR_CJK_RUBY at overlap may split existing overlapping RES_TXTATR_INETFMT RES_TXTATR_META: may fail if overlapping existing RES_TXTATR_META/RES_TXTATR_METAFIELD may split existing overlapping RES_TXTATR_INETFMT or RES_TXTATR_CJK_RUBY inserts 1 attribute RES_TXTATR_METAFIELD: may fail if overlapping existing RES_TXTATR_META/RES_TXTATR_METAFIELD may split existing overlapping RES_TXTATR_INETFMT or RES_TXTATR_CJK_RUBY inserts 1 attribute

The nesting is expressed by the position of the hints. RES_TXTATR_META and RES_TXTATR_METAFIELD have a CH_TXTATR, and there can only be one such hint starting and ending at a given position. Only RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY lack a CH_TXTATR. The interpretation given is that RES_TXTATR_CJK_RUBY is always around a RES_TXTATR_INETFMT at the same start and end position (which corresponds with the UNO API). Both of these are always around a nesting hint with CH_TXTATR at the same start and end position (if they should be inside, then the start should be after the CH_TXTATR). It would probably be a bad idea to add another nesting hint without CH_TXTATR; on the other hand, it would be difficult adding a CH_TXTATR to RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY, due to the overwriting and splitting of existing hints that is necessary for backward compatibility.

@param rNode    the text node
@param rHint    the hint to be inserted
@returns        true iff hint was successfully inserted

Definition at line 378 of file thints.cxx.

References sw::CalcBreaks(), ComparePosition(), Count(), Delete(), SwTextNode::DestroyAttr(), Equal, SwNode::GetDoc(), SwTextAttr::GetEnd(), SwTextAttrEnd::GetEnd(), SwNode::GetIndex(), GetSortedByEnd(), SwTextAttr::GetStart(), SwTextAttr::HasDummyChar(), i, InsertNesting(), Inside, isNestedAny(), SwTextAttr::IsNesting(), isOverlap(), isSelfNestable(), isSplittable(), lcl_DoSplitImpl(), lcl_DoSplitNew(), MakeTextAttrNesting(), MAX_HINTS, Outside, OverlapBefore, OverlapBehind, RES_TXTATR_CJK_RUBY(), RES_TXTATR_CONTENTCONTROL(), RES_TXTATR_INETFMT(), RES_TXTATR_INPUTFIELD(), RES_TXTATR_META(), RES_TXTATR_METAFIELD(), SAL_INFO, SAL_WARN_IF, splitPolicy(), TextAttrDelete(), TryInsertNesting(), and SwTextAttr::Which().

Referenced by TryInsertHint(), and TryInsertNesting().

Friends And Related Function Documentation

◆ SwTextNode

friend class SwTextNode
friend

Delete methods may only be called by the TextNode! Because the TextNode also guarantees removal of the Character for attributes without an end.

Definition at line 104 of file ndhints.hxx.

Member Data Documentation

◆ m_bCalcHiddenParaField

bool SwpHints::m_bCalcHiddenParaField
mutableprivate

◆ m_bDDEFields

bool SwpHints::m_bDDEFields
private

the TextNode has DDE fields

Definition at line 90 of file ndhints.hxx.

Referenced by CalcFlags().

◆ m_bEndMapNeedsSorting

bool SwpHints::m_bEndMapNeedsSorting
mutableprivate

◆ m_bFootnote

bool SwpHints::m_bFootnote
private

footnotes

Definition at line 89 of file ndhints.hxx.

Referenced by CalcFlags(), and HasFootnote().

◆ m_bHiddenByParaField

bool SwpHints::m_bHiddenByParaField
mutableprivate

◆ m_bInSplitNode

bool SwpHints::m_bInSplitNode
private

true: the Node is in Split and Frames are moved

Definition at line 83 of file ndhints.hxx.

Referenced by IsInSplitNode(), and SetInSplitNode().

◆ m_bStartMapNeedsSorting

bool SwpHints::m_bStartMapNeedsSorting
mutableprivate

◆ m_bWhichMapNeedsSorting

bool SwpHints::m_bWhichMapNeedsSorting
mutableprivate

◆ m_HintsByEnd

std::vector<SwTextAttr*> SwpHints::m_HintsByEnd
private

◆ m_HintsByStart

std::vector<SwTextAttr*> SwpHints::m_HintsByStart
private

◆ m_HintsByWhichAndStart

std::vector<SwTextAttr*> SwpHints::m_HintsByWhichAndStart
private

◆ m_pHistory

SwRegHistory* SwpHints::m_pHistory
private

for Undo

Definition at line 80 of file ndhints.hxx.

Referenced by GetHistory(), NoteInHistory(), and Register().

◆ m_rParent

const SwTextNode& SwpHints::m_rParent
private

Definition at line 70 of file ndhints.hxx.

Referenced by CalcHiddenParaField(), and DeleteAtPos().

◆ MAX_HINTS

const size_t SwpHints::MAX_HINTS = SAL_MAX_SIZE-1
staticprivate

Definition at line 74 of file ndhints.hxx.

Referenced by TryInsertHint(), and TryInsertNesting().


The documentation for this class was generated from the following files: