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

Definition at line 192 of file ndhints.hxx.

bool SwpHints::Check ( bool  bPortionsMerged) const
private
bool SwpHints::Contains ( const SwTextAttr pHt) const

Definition at line 171 of file ndhints.cxx.

References m_HintsByStart.

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 3341 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
void SwpHints::EndPosChanged ( ) const
inline
SwTextAttr* SwpHints::Get ( size_t  nPos) const
inline
size_t SwpHints::GetFirstPosSortedByWhichAndStart ( sal_uInt16  nWhich) const

Definition at line 448 of file ndhints.cxx.

References m_bWhichMapNeedsSorting, m_HintsByWhichAndStart, and ResortWhichMap().

Referenced by lcl_GetTextAttrs().

SwRegHistory* SwpHints::GetHistory ( ) const
inline

Definition at line 198 of file ndhints.hxx.

References m_pHistory.

Referenced by SwTextNode::InsertHint().

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

Definition at line 466 of file ndhints.cxx.

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

Referenced by Delete().

int SwpHints::GetLastPosSortedByEnd ( sal_Int32  nEndPos) const

Definition at line 458 of file ndhints.cxx.

References m_bEndMapNeedsSorting, m_HintsByEnd, and ResortEndMap().

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

Definition at line 158 of file ndhints.hxx.

References m_bEndMapNeedsSorting, and ResortEndMap().

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

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

Definition at line 167 of file ndhints.hxx.

References m_bWhichMapNeedsSorting, and ResortWhichMap().

Referenced by lcl_GetTextAttrs().

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

Definition at line 152 of file ndhints.hxx.

Referenced by BuildPortions().

bool SwpHints::HasFootnote ( ) const
inline

Definition at line 205 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 285 of file thints.cxx.

References Insert(), and NoteInHistory().

Referenced by TryInsertNesting().

bool SwpHints::IsHiddenByParaField ( ) const
inlineprivate

Definition at line 112 of file ndhints.hxx.

References CalcHiddenParaField(), m_bCalcHiddenParaField, and m_bHiddenByParaField.

bool SwpHints::IsInSplitNode ( ) const
inline

Definition at line 206 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 2636 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 195 of file ndhints.hxx.

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

void SwpHints::Resort ( ) const
private
void SwpHints::ResortEndMap ( ) const
private
void SwpHints::ResortStartMap ( ) const
private
void SwpHints::ResortWhichMap ( ) const
private
void SwpHints::SetCalcHiddenParaField ( ) const
inlineprivate

Definition at line 110 of file ndhints.hxx.

References m_bCalcHiddenParaField.

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

Definition at line 111 of file ndhints.hxx.

References m_bHiddenByParaField.

Referenced by CalcHiddenParaField().

void SwpHints::SetInSplitNode ( bool  bInSplit)
inlineprivate

Definition at line 109 of file ndhints.hxx.

References m_bInSplitNode.

Referenced by SwTextNode::SplitContentNode().

void SwpHints::SortIfNeedBe ( ) const
inline
void SwpHints::StartPosChanged ( ) const
inline
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 2949 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(), SwTextAttr::SetEnd(), SetExp, SwSetExpFieldType::SetSeqRefNo(), SwTextAttr::SetStart(), 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 359 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 104 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 90 of file ndhints.hxx.

Referenced by CalcFlags().

bool SwpHints::m_bEndMapNeedsSorting
mutableprivate
bool SwpHints::m_bFootnote
private

footnotes

Definition at line 89 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 83 of file ndhints.hxx.

Referenced by IsInSplitNode(), and SetInSplitNode().

bool SwpHints::m_bStartMapNeedsSorting
mutableprivate
bool SwpHints::m_bWhichMapNeedsSorting
mutableprivate
std::vector<SwTextAttr*> SwpHints::m_HintsByEnd
private

Definition at line 77 of file ndhints.hxx.

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

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

Definition at line 76 of file ndhints.hxx.

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

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

for Undo

Definition at line 80 of file ndhints.hxx.

Referenced by GetHistory(), and NoteInHistory().

const SwTextNode& SwpHints::m_rParent
private

Definition at line 70 of file ndhints.hxx.

Referenced by CalcHiddenParaField(), and DeleteAtPos().

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: