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>
This commit is contained in:
Justin Luth 2022-08-02 13:30:31 -04:00
parent acf2a2f179
commit 835cda5612
2 changed files with 20 additions and 2 deletions

View file

@ -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;

View file

@ -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);