/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
OUString sRet; if (rBase.pTextMark) { // only if it's not a Mark return sRet;
}
const SwTextNode* pNd = rBase.aTOXSources[0].pNd->GetTextNode(); if (!pNd) { return sRet;
} if (pLayout && pLayout->HasMergedParas())
{ // note: pNd could be any node, since it could be Sequence etc.
pNd = sw::GetParaPropsNode(*pLayout, *pNd);
}
if (bAddSpace && !sRet.isEmpty() && !isWhiteSpace(sRet[sRet.getLength() - 1])) {
sRet += " ";// Makes sure spacing is done only when there is outline numbering
}
// A bit tricky: Find a random Frame const SwContentNode* contentNode = rBase.aTOXSources.at(0).pNd->GetContentNode(); if (!contentNode) { return OUString();
}
//---> #i89791# // continue to support CF_NUMBER and CF_NUM_TITLE in order to handle ODF 1.0/1.1 written by OOo 3.x // in the same way as OOo 2.x would handle them. if (CF_NUM_NOPREPST_TITLE == chapterToken.nChapterFormat || CF_NUMBER == chapterToken.nChapterFormat) {
retval += aField.GetNumber(pLayout); // get the string number without pre/postfix
} elseif (CF_NUMBER_NOPREPST == chapterToken.nChapterFormat || CF_NUM_TITLE == chapterToken.nChapterFormat) {
retval += aField.GetNumber(pLayout) + " " + aField.GetTitle(pLayout);
} elseif (CF_TITLE == chapterToken.nChapterFormat) {
retval += aField.GetTitle(pLayout);
} return retval;
}
std::optional<std::pair<SwTextNode *, SvxTabStopItem>>
ToxTextGenerator::GenerateText(SwDoc& rDoc,
std::unordered_map<OUString, int> & rMarkURLs, const std::vector<std::unique_ptr<SwTOXSortTabBase>> &entries,
sal_uInt16 indexOfEntryToProcess, sal_uInt16 numberOfEntriesToProcess,
SwRootFrame const*const pLayout)
{
std::optional<std::pair<SwTextNode *, SvxTabStopItem>> oRet; // pTOXNd is only set at the first mark
SwTextNode* pTOXNd = const_cast<SwTextNode*>(entries.at(indexOfEntryToProcess)->pTOXNd); // FIXME this operates directly on the node text
OUString & rText = const_cast<OUString&>(pTOXNd->GetText());
rText.clear();
OUString rAltText; for(sal_uInt16 nIndex = indexOfEntryToProcess; nIndex < indexOfEntryToProcess + numberOfEntriesToProcess; nIndex++)
{ if(nIndex > indexOfEntryToProcess)
rText += ", "; // comma separation // Initialize String with the Pattern from the form const SwTOXSortTabBase& rBase = *entries.at(nIndex);
sal_uInt16 nLvl = rBase.GetLevel();
OSL_ENSURE( nLvl < mToxForm.GetFormMax(), "invalid FORM_LEVEL");
oRet.emplace(pTOXNd, SvxTabStopItem(0, 0, SvxTabAdjust::Default, RES_PARATR_TABSTOP)); // create an enumerator // #i21237#
SwFormTokens aPattern = mToxForm.GetPattern(nLvl); // remove text from node for (size_t i = 0; i < aPattern.size(); ++i) // #i21237#
{ constauto& aToken = aPattern[i];
sal_Int32 nStartCharStyle = rText.getLength();
UIName aCharStyleName = aToken.sCharStyleName; switch( aToken.eTokenType )
{ case TOKEN_ENTRY_NO: // for TOC numbering // Only add space when there is outline numbering, and also when the next token // is the entry text: it can also be e.g. a tab, or the entry number can be used // in page number area like "2-15" for chapter 2, page 15.
rText += GetNumStringOfFirstNode(rBase,
aToken.nChapterFormat == CF_NUMBER, static_cast<sal_uInt8>(aToken.nOutlineLevel - 1), pLayout,
i < aPattern.size() - 1 && aPattern[i + 1].eTokenType == TOKEN_ENTRY_TEXT); break;
// FIXME: there is a pre-existing problem that the index mapping of the // attributes only works if the paragraph is fully selected if (!source.IsFullPara() || source.aTOXSources.empty()) return result;
/*static*/ OUString
ToxTextGenerator::ConstructPageNumberPlaceholder(size_t numberOfToxSources)
{ if (numberOfToxSources == 0) { return OUString();
}
OUStringBuffer retval; // Place holder for the PageNumber; we only respect the first one
retval.append(C_NUM_REPL); for (size_t i = 1; i < numberOfToxSources; ++i) {
retval.append(SwTOXMark::S_PAGE_DELI + OUStringChar(C_NUM_REPL));
}
retval.append(C_END_PAGE_NUM); return retval.makeStringAndClear();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.