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
 
SwTextAttrGetSortedByEnd (size_t nPos) const
 
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
 

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. More...
 
void BuildPortions (SwTextNode &rNode, SwTextAttr &rNewHint, const SetAttrMode nMode)
 
bool MergePortions (SwTextNode &rNode)
 
void Insert (const SwTextAttr *pHt)
 
void Resort ()
 
size_t GetIndexOf (const SwTextAttr *pHt) const
 
bool Check (bool) const
 

Private Attributes

const SwTextNodem_rParent
 
SwpHtStart m_HintsByStart
 
SwpHtEnd m_HintsByEnd
 
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...
 

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 76 of file ndhints.hxx.

Constructor & Destructor Documentation

SwpHints::SwpHints ( const SwTextNode rParent)

Definition at line 95 of file thints.cxx.

Member Function Documentation

void SwpHints::BuildPortions ( SwTextNode rNode,
SwTextAttr rNewHint,
const SetAttrMode  nMode 
)
private
void SwpHints::CalcFlags ( )
private
bool SwpHints::CalcHiddenParaField ( ) const
bool SwpHints::CanBeDeleted ( ) const
inline
bool SwpHints::Check ( bool  bPortionsMerged) const
private
bool SwpHints::Contains ( const SwTextAttr pHt) const

Definition at line 122 of file ndhints.cxx.

References i, m_HintsByStart, and o3tl::sorted_vector< Value, Compare, Find, class >::size().

Referenced by lcl_CopyHint().

size_t SwpHints::Count ( ) const
inline
SwTextAttr* SwpHints::Cut ( const size_t  nPosInStart)
inline
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 3316 of file thints.cxx.

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

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

void SwpHints::DeleteAtPos ( size_t  nPos)
private
void SwpHints::DeRegister ( )
inline
SwTextAttr* SwpHints::Get ( size_t  nPos) const
inline
SwRegHistory* SwpHints::GetHistory ( ) const
inline

Definition at line 175 of file ndhints.hxx.

References m_pHistory.

Referenced by SwTextNode::InsertHint().

size_t SwpHints::GetIndexOf ( const SwTextAttr pHt) const
inlineprivate
SwTextAttr* SwpHints::GetSortedByEnd ( size_t  nPos) const
inline

Definition at line 158 of file ndhints.hxx.

Referenced by lcl_ExportHints(), lcl_SearchBackward(), and TryInsertNesting().

bool SwpHints::HasFootnote ( ) const
inline

Definition at line 182 of file ndhints.hxx.

References m_bFootnote.

void SwpHints::Insert ( const SwTextAttr pHt)
private
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 282 of file thints.cxx.

References Insert(), and NoteInHistory().

Referenced by TryInsertNesting().

bool SwpHints::IsHiddenByParaField ( ) const
inlineprivate

Definition at line 116 of file ndhints.hxx.

References CalcHiddenParaField(), m_bCalcHiddenParaField, and m_bHiddenByParaField.

bool SwpHints::IsInSplitNode ( ) const
inline

Definition at line 183 of file ndhints.hxx.

References m_bInSplitNode.

Referenced by SwTextFlyCnt::SetAnchor().

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

records a new attribute in m_pHistory.

Definition at line 2627 of file thints.cxx.

References SwRegHistory::AddHint(), and m_pHistory.

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

void SwpHints::Register ( SwRegHistory pHist)
inline

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

Definition at line 172 of file ndhints.hxx.

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

void SwpHints::Resort ( )
private
void SwpHints::SetCalcHiddenParaField ( ) const
inlineprivate

Definition at line 114 of file ndhints.hxx.

References m_bCalcHiddenParaField.

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

Definition at line 115 of file ndhints.hxx.

References m_bHiddenByParaField.

Referenced by CalcHiddenParaField().

void SwpHints::SetInSplitNode ( bool  bInSplit)
inlineprivate

Definition at line 113 of file ndhints.hxx.

References m_bInSplitNode.

Referenced by SwTextNode::SplitContentNode().

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 2940 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, SwModify::HasWriterListeners(), 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(), SwContentNode::ModifyNotification(), 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_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(), SetExp, SwSetExpFieldType::SetSeqRefNo(), static_txtattr_cast(), TryInsertNesting(), User, SwTextAttr::Which(), and SwFieldType::Which().

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.

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.

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 356 of file thints.cxx.

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

Referenced by TryInsertHint().

Friends And Related Function Documentation

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 108 of file ndhints.hxx.

Member Data Documentation

bool SwpHints::m_bCalcHiddenParaField
mutableprivate
bool SwpHints::m_bDDEFields
private

the TextNode has DDE fields

Definition at line 98 of file ndhints.hxx.

Referenced by CalcFlags().

bool SwpHints::m_bFootnote
private

footnotes

Definition at line 97 of file ndhints.hxx.

Referenced by CalcFlags(), and HasFootnote().

bool SwpHints::m_bHiddenByParaField
mutableprivate
bool SwpHints::m_bInSplitNode
private

true: the Node is in Split and Frames are moved

Definition at line 91 of file ndhints.hxx.

Referenced by IsInSplitNode(), and SetInSplitNode().

SwpHtEnd SwpHints::m_HintsByEnd
private

Definition at line 86 of file ndhints.hxx.

Referenced by Check(), DeleteAtPos(), Insert(), and Resort().

SwpHtStart SwpHints::m_HintsByStart
private

Definition at line 85 of file ndhints.hxx.

Referenced by Check(), Contains(), DeleteAtPos(), Insert(), and Resort().

SwRegHistory* SwpHints::m_pHistory
private

for Undo

Definition at line 88 of file ndhints.hxx.

Referenced by GetHistory(), and NoteInHistory().

const SwTextNode& SwpHints::m_rParent
private

Definition at line 79 of file ndhints.hxx.

Referenced by CalcHiddenParaField(), and DeleteAtPos().

const size_t SwpHints::MAX_HINTS = SAL_MAX_SIZE-1
staticprivate

Definition at line 83 of file ndhints.hxx.

Referenced by TryInsertHint(), and TryInsertNesting().


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