diff options
author | Justin Luth <jluth@mail.com> | 2022-08-02 13:30:31 -0400 |
---|---|---|
committer | Justin Luth <jluth@mail.com> | 2022-08-12 16:27:42 +0200 |
commit | 835cda561217bd8c53af2de927158dd5712b06c0 (patch) | |
tree | 4342021d4381f499eaafa4e31347e53ef007d955 | |
parent | acf2a2f17942c21b5aca4691c738902a3dd9aa6c (diff) |
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>
-rw-r--r-- | editeng/source/items/numitem.cxx | 18 | ||||
-rw-r--r-- | include/editeng/numitem.hxx | 4 |
2 files changed, 20 insertions, 2 deletions
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx index 1239ea529126..e8c1c4d9a77c 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 baa6ad3204e1..aea72d86a7ed 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); |