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 > const &tabStopHandler)
 
virtual ~ToxTextGenerator ()
 
void GenerateText (SwDoc *doc, 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)
 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 57 of file ToxTextGenerator.hxx.

Constructor & Destructor Documentation

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

Definition at line 108 of file ToxTextGenerator.cxx.

sw::ToxTextGenerator::~ToxTextGenerator ( )
virtual

Definition at line 115 of file ToxTextGenerator.cxx.

Member Function Documentation

void sw::ToxTextGenerator::ApplyHandledTextToken ( const HandledTextToken htt,
SwTextNode targetNode 
)
staticprivate
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 281 of file ToxTextGenerator.cxx.

References SwTextAttr::GetAutoFormat(), SwFormatAutoFormat::GetStyleHandle(), RES_CHRATR_CJK_POSTURE, RES_CHRATR_CTL_POSTURE, RES_CHRATR_ESCAPEMENT, RES_CHRATR_POSTURE, RES_TXTATR_AUTOFMT, and SwTextAttr::Which().

Referenced by GetAttributesForNode().

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 413 of file ToxTextGenerator.cxx.

References C_END_PAGE_NUM, C_NUM_REPL, i, and S_PAGE_DELI.

Referenced by GenerateText().

void sw::ToxTextGenerator::GenerateText ( SwDoc doc,
const std::vector< std::unique_ptr< SwTOXSortTabBase >> &  entries,
sal_uInt16  indexOfEntryToProcess,
sal_uInt16  numberOfEntriesToProcess,
SwRootFrame const *  pLayout 
)
OUString sw::ToxTextGenerator::GenerateTextForChapterToken ( const SwFormToken chapterToken,
const SwContentFrame contentFrame,
const SwContentNode contentNode,
SwRootFrame const *  pLayout 
) const
private
void sw::ToxTextGenerator::GetAttributesForNode ( ToxTextGenerator::HandledTextToken rResult,
sal_Int32 &  rOffset,
SwTextNode const &  rNode,
ToxWhitespaceStripper const &  rStripper,
SwAttrPool rPool,
SwRootFrame const *const  pLayout 
)
staticprivate
OUString sw::ToxTextGenerator::GetNumStringOfFirstNode ( const SwTOXSortTabBase rBase,
bool  bUsePrefix,
sal_uInt8  nLevel,
SwRootFrame const *  pLayout 
)
staticprivate
OUString sw::ToxTextGenerator::HandleChapterToken ( const SwTOXSortTabBase rBase,
const SwFormToken aToken,
SwRootFrame const *  pLayout 
) const
private

Handle a chapter token.

Definition at line 119 of file ToxTextGenerator.cxx.

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

Referenced by GenerateText().

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 354 of file ToxTextGenerator.cxx.

References SwTOXSortTabBase::aTOXSources, GetAttributesForNode(), SwNode::GetIndex(), SwContentNode::getLayoutFrame(), SwNode::GetNodes(), SwTOXSortTabBase::GetText(), i, SwTOXSortTabBase::IsFullPara(), SwRootFrame::IsHideRedlines(), SwNode::NonFirst, result, TextAndReading::sText, and sw::ToxTextGenerator::HandledTextToken::text.

Referenced by GenerateText().

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 430 of file ToxTextGenerator.cxx.

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

Referenced by GenerateTextForChapterToken().

Friends And Related Function Documentation

friend class ::ToxTextGeneratorTest
friend

Definition at line 165 of file ToxTextGenerator.hxx.

Member Data Documentation

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

Definition at line 76 of file ToxTextGenerator.hxx.

Referenced by GenerateText().

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

Definition at line 77 of file ToxTextGenerator.hxx.

Referenced by GenerateText().

const SwForm& sw::ToxTextGenerator::mToxForm
private

Definition at line 75 of file ToxTextGenerator.hxx.

Referenced by GenerateText().


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