summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2021-06-14 14:27:56 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2021-06-29 00:48:36 +0200
commitaa5c6d127559912ad60a63fbd972b78fb8f9691b (patch)
treef58857a341fa8930ad173e82e5c11a5fedf294e0 /editeng
parent99ef46fdb2a975e074c66a02328b86edfc05307f (diff)
new ODF numbered list parameter loext:num-list-format
Instead of style:num-prefix and style:num-suffix new list format is much more flexible for storing list multilevel numberings. Now it is possible to have not just prefix/suffix but any random separators between levels, arbitrary levels order, etc. Internal LO format for list format is changed: instead of placeholders like %1, %2, etc we right now use %1%, %2%... Reason: for ODT documents, having more than 9 levels there is ambiguity in "%10": it is "%1" followed by "0" suffix, or "%10"? Aux changes: * removed zero width space hack: since format string is always defined this hack is interfering with standard list numbers printing (see changes in ooxmlexport14.cxx, ww8export3.cxx tests) * changed cross-references values to lists: they are now including full list label string: previously this was bit self-contradictory (see changes in odfexport.cxx and check_cross_references.py tests) Change-Id: I9696cc4846375c5f6222539aeaadbca5ae58ce27 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117156 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/items/numitem.cxx49
1 files changed, 49 insertions, 0 deletions
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx
index 2dd03a1877cf..9c55ef1e401c 100644
--- a/editeng/source/items/numitem.cxx
+++ b/editeng/source/items/numitem.cxx
@@ -560,6 +560,55 @@ OUString SvxNumberFormat::CreateRomanString( sal_Int32 nNo, bool bUpper )
return sRet.makeStringAndClear();
}
+void SvxNumberFormat::SetListFormat(const OUString& rPrefix, const OUString& rSuffix, int nLevel)
+{
+ sPrefix = rPrefix;
+ sSuffix = rSuffix;
+
+ // Generate list format
+ sListFormat = std::make_optional(sPrefix);
+
+ for (int i = 1; i <= nInclUpperLevels; i++)
+ {
+ int nLevelId = nLevel - nInclUpperLevels + i;
+ if (nLevelId < 0)
+ // There can be cases with curent level 1, but request to show 10 upper levels. Trim it
+ continue;
+
+ *sListFormat += "%";
+ *sListFormat += OUString::number(nLevelId + 1);
+ *sListFormat += "%";
+ if (i != nInclUpperLevels)
+ *sListFormat += "."; // Default separator for older ODT
+ }
+
+ *sListFormat += sSuffix;
+}
+
+void SvxNumberFormat::SetListFormat(std::optional<OUString> oSet)
+{
+ sPrefix.clear();
+ sSuffix.clear();
+
+ if (!oSet.has_value())
+ {
+ return;
+ }
+
+ sListFormat = oSet;
+
+ // For backward compatibility and UI we should create prefix/suffix also
+ sal_Int32 nFirstReplacement = sListFormat->indexOf('%');
+ sal_Int32 nLastReplacement = sListFormat->lastIndexOf('%') + 1;
+ if (nFirstReplacement > 0)
+ // Everything before first '%' will be prefix
+ sPrefix = sListFormat->copy(0, nFirstReplacement);
+ if (nLastReplacement >= 0 && nLastReplacement < sListFormat->getLength())
+ // Everything beyond last '%' is a suffix
+ sSuffix = sListFormat->copy(nLastReplacement);
+}
+
+
OUString SvxNumberFormat::GetCharFormatName()const
{
return sCharStyleName;