43#include <osl/diagnose.h>
44#include <rtl/ustrbuf.hxx>
53bool sortTabHasNoToxSourcesOrFirstToxSourceHasNoNode(
const SwTOXSortTabBase& sortTab)
76 if (sortTabHasNoToxSourcesOrFirstToxSourceHasNoNode(rBase)) {
103 if (bAddSpace && !sRet.isEmpty() && !isWhiteSpace(sRet[sRet.getLength() - 1])) {
112 std::shared_ptr<ToxTabStopTokenHandler> tabStopHandler)
115 mTabStopTokenHandler(
std::move(tabStopHandler))
125 if (sortTabHasNoToxSourcesOrFirstToxSourceHasNoNode(rBase)) {
172 std::unordered_map<OUString, int> & rMarkURLs,
173 const std::vector<std::unique_ptr<SwTOXSortTabBase>> &entries,
174 sal_uInt16 indexOfEntryToProcess, sal_uInt16 numberOfEntriesToProcess,
180 OUString & rText =
const_cast<OUString&
>(pTOXNd->
GetText());
182 for(sal_uInt16
nIndex = indexOfEntryToProcess;
nIndex < indexOfEntryToProcess + numberOfEntriesToProcess;
nIndex++)
184 if(
nIndex > indexOfEntryToProcess)
196 for (
size_t i = 0;
i < aPattern.size(); ++
i)
198 const auto& aToken = aPattern[
i];
199 sal_Int32 nStartCharStyle = rText.getLength();
200 OUString aCharStyleName = aToken.sCharStyleName;
201 switch( aToken.eTokenType )
210 static_cast<sal_uInt8>(aToken.nOutlineLevel - 1), pLayout,
238 rText += aToken.sText;
250 mLinkProcessor->StartNewLink(rText.getLength(), aToken.sCharStyleName);
255 auto [url, isMark] = rBase.
GetURL(pLayout);
258 auto [iter, _] = rMarkURLs.emplace(url, 0);
261 url =
"#" + OUString::number(iter->second) + url;
273 aCharStyleName =
SwResId(STR_POOLCHR_INET_NORMAL);
276 rBase.
FillText( *pTOXNd, aIdx, o3tl::narrowing<sal_uInt16>(
eField), pLayout );
280 const auto& rAuthority =
static_cast<const SwTOXAuthority&
>(rBase);
291 if (!aCharStyleName.isEmpty())
294 if( USHRT_MAX != aToken.nPoolId )
313 std::shared_ptr<SfxItemSet>
316 auto retval = std::make_shared<SfxItemSet>(pool);
330 retval->Put(std::unique_ptr<SfxPoolItem>(pItem->
Clone()));
355 for (
size_t i = 0;
i < pHints->Count(); ++
i)
358 std::shared_ptr<SfxItemSet> attributesToClone =
360 if (attributesToClone->Count() <= 0) {
372 pClone->SetStyleHandle(attributesToClone);
382 rOffset += aConversionMap.
getViewText().getLength();
404 sal_Int32 nOffset(0);
413 assert(pSrc == pMerged->pParaPropsNode);
415 i <= pMerged->pLastNode->GetIndex(); ++
i)
434 sal_Int32 offset = targetNode.
GetText().getLength();
447 if (numberOfToxSources == 0) {
450 OUStringBuffer retval;
453 for (
size_t i = 1;
i < numberOfToxSources; ++
i) {
457 return retval.makeStringAndClear();
465 assert(chapterToken);
@ CF_NUM_TITLE
number and title
@ CF_NUMBER
only the chapter number
@ CF_NUMBER_NOPREPST
only chapter number without post-/prefix
@ CF_NUM_NOPREPST_TITLE
chapter number without post-/prefix and title
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
const OUString & getViewText() const
sal_Int32 ConvertToViewPosition(sal_Int32 nModelPos) const
Converts a model position into a view position.
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
bool Insert(const SvxTabStop &rTab)
const OUString & GetTitle(SwRootFrame const *pLayout=nullptr) const
void ChangeExpansion(const SwFrame &, const SwContentNode *, bool bSrchNum=false)
const OUString & GetNumber(SwRootFrame const *pLayout=nullptr) const
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Marks a character position inside a document model content node (SwContentNode)
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
SwCharFormat * FindCharFormatByName(const OUString &rName) const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
const SwAttrPool & GetAttrPool() const
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwNodeOffset GetIndex() const
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Merge GetRedlineMergeFlag() const
The root element of a Writer document layout.
bool HasMergedParas() const
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding).
static constexpr OUStringLiteral S_PAGE_DELI
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
sal_Int32 GetAnyEnd() const
end (if available), else start
sal_Int32 GetStart() const
const SwFormatAutoFormat & GetAutoFormat() const
Represents the visualization of a paragraph.
SwTextNode is a paragraph in the document model.
SwTextAttr * InsertItem(SfxPoolItem &rAttr, const sal_Int32 nStart, const sal_Int32 nEnd, const SetAttrMode nMode=SetAttrMode::DEFAULT)
create new text attribute from rAttr and insert it
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
OUString InsertText(const OUString &rStr, const SwContentIndex &rIdx, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
insert text content
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
int GetActualListLevel(SwListRedlineType eRedline=SwListRedlineType::SHOW) const
Returns the actual list level of this text node, when it is a list item.
OUString GetNumString(const bool _bInclPrefixAndSuffixStrings=true, const unsigned int _nRestrictToThisLevel=MAXLEVEL, SwRootFrame const *pLayout=nullptr, SwListRedlineType eRedline=SwListRedlineType::SHOW) const
Returns outline of numbering string.
SwpHints * GetpSwpHints()
const OUString & GetText() const
An SwTextAttr container, stores all directly formatted text portions for a text node.
A helper class for 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).
std::shared_ptr< ToxTabStopTokenHandler > mTabStopTokenHandler
static void ApplyHandledTextToken(const HandledTextToken &htt, SwTextNode &targetNode)
Applies the result of a handled text token to a target node.
static HandledTextToken HandleTextToken(const SwTOXSortTabBase &source, SwAttrPool &attrPool, SwRootFrame const *const pLayout)
Append text (and selected attributes) to a target node.
ToxTextGenerator(const SwForm &toxForm, std::shared_ptr< ToxTabStopTokenHandler > tabStopHandler)
std::shared_ptr< ToxLinkProcessor > mLinkProcessor
static OUString ConstructPageNumberPlaceholder(size_t numberOfToxSources)
Handle a page number token.
virtual ~ToxTextGenerator()
OUString HandleChapterToken(const SwTOXSortTabBase &rBase, const SwFormToken &aToken, SwRootFrame const *pLayout) const
Handle a chapter token.
virtual SwChapterField ObtainChapterField(SwChapterFieldType *chapterFieldType, const SwFormToken *chapterToken, const SwContentFrame *contentFrame, const SwContentNode *contentNode) const
Obtain a ChapterField to use for the text generation.
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.
OUString GenerateTextForChapterToken(const SwFormToken &chapterToken, const SwContentFrame *contentFrame, const SwContentNode *contentNode, SwRootFrame const *pLayout) const
Generate the text for a chapter token.
static void GetAttributesForNode(HandledTextToken &rResult, sal_Int32 &rOffset, SwTextNode const &rNode, ToxWhitespaceStripper const &rStripper, SwAttrPool &rPool, SwRootFrame const *const pLayout)
static std::shared_ptr< SfxItemSet > CollectAttributesForTox(const SwTextAttr &hint, SwAttrPool &pool)
Collect the attributes of a hint that shall be copied over to the TOX.
This class helps to remove unwanted whitespaces from a string to use in a Tox.
const OUString & GetStrippedString() const
sal_Int32 GetPositionInStrippedString(sal_Int32 pos) const
constexpr TypedWhichId< SwFormatAutoFormat > RES_TXTATR_AUTOFMT(50)
constexpr TypedWhichId< SvxEscapementItem > RES_CHRATR_ESCAPEMENT(6)
constexpr TypedWhichId< SvxTabStopItem > RES_PARATR_TABSTOP(68)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CTL_POSTURE(30)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CJK_POSTURE(25)
ExpandMode
Some helpers for converting model strings to view strings.
std::shared_ptr< T > make_shared(Args &&... args)
Dialog to specify the properties of date form field.
SwTextNode * GetParaPropsNode(SwRootFrame const &rLayout, SwNode const &rNode)
Represents one row in the bibliography table.
static OUString GetSourceURL(const OUString &rText)
Gets the URL of the underlying SwAuthEntry, ignoring its page number.
Class for sorting directories.
virtual sal_uInt16 GetLevel() const =0
std::vector< SwTOXSource > aTOXSources
virtual std::pair< OUString, bool > GetURL(SwRootFrame const *const pLayout) const
virtual void FillText(SwTextNode &rNd, const SwContentIndex &rInsPos, sal_uInt16 nAuthField, SwRootFrame const *pLayout) const
TextAndReading const & GetText() const
virtual bool IsFullPara() const
const SwTextTOXMark * pTextMark
Describes parts of multiple text nodes, which will form a text frame, even when redlines are hidden a...
Return value of HandleTabStopToken.
std::vector< sal_Int32 > startPositions
std::vector< std::unique_ptr< SwFormatAutoFormat > > autoFormats
std::vector< sal_Int32 > endPositions
OUString SwResId(TranslateId aId)
constexpr sal_uInt8 MAXLEVEL
const sal_Unicode C_NUM_REPL
const sal_Unicode C_END_PAGE_NUM
std::vector< SwFormToken > SwFormTokens
Vector of tokens.