related tdf#150197: use SetListFormat or SetPrefix/Suffix
GetListFormat DEPENDS on having managed prefix/suffix itself,
since it uses their getLength to modify the sListFormat.
So any modification via SetPrefix/Suffix
(potentially) invalidates the ListFormat.
I added some code to ensure this doesn't get out of sync.
One place that still uses PREFIX/SUFFIX is old ODT files.
After import they are updated, but during import they use
the old UNO properties, so I didn't add any assert here.
Change-Id: I3bab780fb8e8e985c3573075bc7aac9216d116d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138073
Tested-by: Jenkins
Reviewed-by: Vasily Melenchuk <vasily.melenchuk@cib.de>
Reviewed-by: Justin Luth <jluth@mail.com>
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx
index 1239ea5..e8c1c4d 100644
--- a/editeng/source/items/numitem.cxx
+++ b/editeng/source/items/numitem.cxx
@@ -559,6 +559,24 @@ OUString SvxNumberFormat::CreateRomanString( sal_Int32 nNo, bool bUpper )
: sRet.makeStringAndClear().toAsciiLowerCase();
}
void SvxNumberFormat::SetPrefix(const OUString& rSet)
{
// ListFormat manages the prefix. If badly changed via this function, sListFormat is invalidated
if (sListFormat && rSet.getLength() != sPrefix.getLength())
sListFormat.reset();
sPrefix = rSet;
}
void SvxNumberFormat::SetSuffix(const OUString& rSet)
{
// ListFormat manages the suffix. If badly changed via this function, sListFormat is invalidated
if (sListFormat && rSet.getLength() != sSuffix.getLength())
sListFormat.reset();
sSuffix = rSet;
}
void SvxNumberFormat::SetListFormat(const OUString& rPrefix, const OUString& rSuffix, int nLevel)
{
sPrefix = rPrefix;
diff --git a/include/editeng/numitem.hxx b/include/editeng/numitem.hxx
index baa6ad3..aea72d8 100644
--- a/include/editeng/numitem.hxx
+++ b/include/editeng/numitem.hxx
@@ -167,9 +167,9 @@ public:
void SetNumAdjust(SvxAdjust eSet) {eNumAdjust = eSet;}
SvxAdjust GetNumAdjust() const {return eNumAdjust;}
void SetPrefix(const OUString& rSet) { sPrefix = rSet;}
void SetPrefix(const OUString& rSet);
const OUString& GetPrefix() const { return sPrefix;}
void SetSuffix(const OUString& rSet) { sSuffix = rSet;}
void SetSuffix(const OUString& rSet);
const OUString& GetSuffix() const { return sSuffix;}
// Based on prefix and suffix initialize them (for backward compatibility) and generate listformat string
void SetListFormat(const OUString& rPrefix, const OUString& rSuffix, int nLevel);