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

This class generates text for the entries of a table of x. More...

#include <ToxTextGenerator.hxx>

Collaboration diagram for sw::ToxTextGenerator:
[legend]

Classes

struct  HandledTextToken
 A handled text token. More...
 

Public Member Functions

 ToxTextGenerator (const SwForm &toxForm, std::shared_ptr< ToxTabStopTokenHandler > tabStopHandler)
 
virtual ~ToxTextGenerator ()
 
void GenerateText (SwDoc *doc, std::unordered_map< OUString, int > &rMarkURLs, const std::vector< std::unique_ptr< SwTOXSortTabBase > > &entries, sal_uInt16 indexOfEntryToProcess, sal_uInt16 numberOfEntriesToProcess, SwRootFrame const *pLayout)
 Generate the text for an entry of a table of X (X is, e.g., content). More...
 

Private Member Functions

OUString HandleChapterToken (const SwTOXSortTabBase &rBase, const SwFormToken &aToken, SwRootFrame const *pLayout) const
 Handle a chapter token. More...
 
OUString GenerateTextForChapterToken (const SwFormToken &chapterToken, const SwContentFrame *contentFrame, const SwContentNode *contentNode, SwRootFrame const *pLayout) const
 Generate the text for a chapter token. More...
 
virtual SwChapterField ObtainChapterField (SwChapterFieldType *chapterFieldType, const SwFormToken *chapterToken, const SwContentFrame *contentFrame, const SwContentNode *contentNode) const
 Obtain a ChapterField to use for the text generation. More...
 

Static Private Member Functions

static void GetAttributesForNode (HandledTextToken &rResult, sal_Int32 &rOffset, SwTextNode const &rNode, ToxWhitespaceStripper const &rStripper, SwAttrPool &rPool, SwRootFrame const *const pLayout)
 
static HandledTextToken HandleTextToken (const SwTOXSortTabBase &source, SwAttrPool &attrPool, SwRootFrame const *const pLayout)
 Append text (and selected attributes) to a target node. More...
 
static void ApplyHandledTextToken (const HandledTextToken &htt, SwTextNode &targetNode)
 Applies the result of a handled text token to a target node. More...
 
static OUString ConstructPageNumberPlaceholder (size_t numberOfToxSources)
 Handle a page number token. More...
 
static std::shared_ptr< SfxItemSetCollectAttributesForTox (const SwTextAttr &hint, SwAttrPool &pool)
 Collect the attributes of a hint that shall be copied over to the TOX. More...
 
static OUString GetNumStringOfFirstNode (const SwTOXSortTabBase &rBase, bool bUsePrefix, sal_uInt8 nLevel, SwRootFrame const *pLayout, bool bAddSpace=true)
 This method will call GetNumStringOfFirstNode() of the first node in the provided SwTOXSortTabBase. More...
 

Private Attributes

const SwFormmToxForm
 
std::shared_ptr< ToxLinkProcessormLinkProcessor
 
std::shared_ptr< ToxTabStopTokenHandlermTabStopTokenHandler
 

Friends

class ::ToxTextGeneratorTest
 

Detailed Description

This class generates text for the entries of a table of x.

You can control its behavior by calling and specifying the desired behavior.

Definition at line 58 of file ToxTextGenerator.hxx.

Constructor & Destructor Documentation

◆ ToxTextGenerator()

sw::ToxTextGenerator::ToxTextGenerator ( const SwForm toxForm,
std::shared_ptr< ToxTabStopTokenHandler tabStopHandler 
)

Definition at line 111 of file ToxTextGenerator.cxx.

References make_shared().

◆ ~ToxTextGenerator()

sw::ToxTextGenerator::~ToxTextGenerator ( )
virtual

Definition at line 118 of file ToxTextGenerator.cxx.

Member Function Documentation

◆ ApplyHandledTextToken()

void sw::ToxTextGenerator::ApplyHandledTextToken ( const HandledTextToken htt,
SwTextNode targetNode 
)
staticprivate

◆ CollectAttributesForTox()

std::shared_ptr< SfxItemSet > sw::ToxTextGenerator::CollectAttributesForTox ( const SwTextAttr hint,
SwAttrPool pool 
)
staticprivate

Collect the attributes of a hint that shall be copied over to the TOX.

Some text attributes are used in the TOX entries. This method defines which attributes are used.

Parameters
hintThe hint from which the attributes are taken
poolThe attribute pool for the new items

Definition at line 314 of file ToxTextGenerator.cxx.

References SfxPoolItem::Clone(), SwTextAttr::GetAutoFormat(), SfxItemIter::GetCurItem(), SwFormatAutoFormat::GetStyleHandle(), SfxItemIter::NextItem(), RES_CHRATR_CJK_POSTURE(), RES_CHRATR_CTL_POSTURE(), RES_CHRATR_ESCAPEMENT(), RES_CHRATR_POSTURE(), RES_TXTATR_AUTOFMT(), SfxPoolItem::Which(), and SwTextAttr::Which().

Referenced by GetAttributesForNode().

◆ ConstructPageNumberPlaceholder()

OUString sw::ToxTextGenerator::ConstructPageNumberPlaceholder ( size_t  numberOfToxSources)
staticprivate

Handle a page number token.

Will return a string of numberOfToxSources concatenated '@' signs, separated by commas, and finished by a '~'. (The '@' sign is the magic character C_NUM_REPL, the '~' sign is the magic character C_END_PAGE_NUM.

Definition at line 445 of file ToxTextGenerator.cxx.

References C_END_PAGE_NUM, C_NUM_REPL, i, and SwTOXMark::S_PAGE_DELI.

Referenced by GenerateText().

◆ GenerateText()

void sw::ToxTextGenerator::GenerateText ( SwDoc doc,
std::unordered_map< OUString, int > &  rMarkURLs,
const std::vector< std::unique_ptr< SwTOXSortTabBase > > &  entries,
sal_uInt16  indexOfEntryToProcess,
sal_uInt16  numberOfEntriesToProcess,
SwRootFrame const *  pLayout 
)

◆ GenerateTextForChapterToken()

OUString sw::ToxTextGenerator::GenerateTextForChapterToken ( const SwFormToken chapterToken,
const SwContentFrame contentFrame,
const SwContentNode contentNode,
SwRootFrame const *  pLayout 
) const
private

◆ GetAttributesForNode()

void sw::ToxTextGenerator::GetAttributesForNode ( ToxTextGenerator::HandledTextToken rResult,
sal_Int32 &  rOffset,
SwTextNode const &  rNode,
ToxWhitespaceStripper const &  rStripper,
SwAttrPool rPool,
SwRootFrame const *const  pLayout 
)
staticprivate

◆ GetNumStringOfFirstNode()

OUString sw::ToxTextGenerator::GetNumStringOfFirstNode ( const SwTOXSortTabBase rBase,
bool  bUsePrefix,
sal_uInt8  nLevel,
SwRootFrame const *  pLayout,
bool  bAddSpace = true 
)
staticprivate

◆ HandleChapterToken()

OUString sw::ToxTextGenerator::HandleChapterToken ( const SwTOXSortTabBase rBase,
const SwFormToken aToken,
SwRootFrame const *  pLayout 
) const
private

Handle a chapter token.

Definition at line 122 of file ToxTextGenerator.cxx.

References SwTOXSortTabBase::aTOXSources, GenerateTextForChapterToken(), and SwContentNode::getLayoutFrame().

Referenced by GenerateText().

◆ HandleTextToken()

ToxTextGenerator::HandledTextToken sw::ToxTextGenerator::HandleTextToken ( const SwTOXSortTabBase source,
SwAttrPool attrPool,
SwRootFrame const *const  pLayout 
)
staticprivate

Append text (and selected attributes) to a target node.

Will take the text of source, and return the text and the attributes which should be added to the target text node.

See also
CollectAttributesForTox() for the criteria of the attributes which are taken.

Definition at line 386 of file ToxTextGenerator.cxx.

References SwTOXSortTabBase::aTOXSources, GetAttributesForNode(), SwNode::GetIndex(), SwContentNode::getLayoutFrame(), SwNode::GetNodes(), SwNode::GetRedlineMergeFlag(), sw::ToxWhitespaceStripper::GetStrippedString(), SwTOXSortTabBase::GetText(), SwNode::GetTextNode(), SwRootFrame::HasMergedParas(), i, SwTOXSortTabBase::IsFullPara(), SwNode::NonFirst, result, and TextAndReading::sText.

Referenced by GenerateText().

◆ ObtainChapterField()

SwChapterField sw::ToxTextGenerator::ObtainChapterField ( SwChapterFieldType chapterFieldType,
const SwFormToken chapterToken,
const SwContentFrame contentFrame,
const SwContentNode contentNode 
) const
privatevirtual

Obtain a ChapterField to use for the text generation.

Definition at line 461 of file ToxTextGenerator.cxx.

References SwChapterField::ChangeExpansion(), SwFormToken::nChapterFormat, SwFormToken::nOutlineLevel, and SwChapterField::SetLevel().

Referenced by GenerateTextForChapterToken().

Friends And Related Function Documentation

◆ ::ToxTextGeneratorTest

friend class ::ToxTextGeneratorTest
friend

Definition at line 168 of file ToxTextGenerator.hxx.

Member Data Documentation

◆ mLinkProcessor

std::shared_ptr<ToxLinkProcessor> sw::ToxTextGenerator::mLinkProcessor
private

Definition at line 79 of file ToxTextGenerator.hxx.

Referenced by GenerateText().

◆ mTabStopTokenHandler

std::shared_ptr<ToxTabStopTokenHandler> sw::ToxTextGenerator::mTabStopTokenHandler
private

Definition at line 80 of file ToxTextGenerator.hxx.

Referenced by GenerateText().

◆ mToxForm

const SwForm& sw::ToxTextGenerator::mToxForm
private

Definition at line 78 of file ToxTextGenerator.hxx.

Referenced by GenerateText().


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