diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2023-02-07 14:12:54 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2023-02-07 15:17:30 +0000 |
commit | 0fafc03c24996ccd53dbf76eaab372779cfbca90 (patch) | |
tree | 34371a2e5f1497a4bc095ac1be65634d8c313ce9 /filter/source | |
parent | 74590b782dfef65c612bb1577cdcb0a5f29df82a (diff) |
tdf#153083 writerfilter,sw: consolidate StyleName->StyleId in msfilter
Turns out there was already a function MSWordStyles::CreateStyleId()
doing the same thing as FilterChars(), presumably better.
Change-Id: Idd0129c753841b86bd026e1300aa57a56721c89e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146609
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'filter/source')
-rw-r--r-- | filter/source/msfilter/util.cxx | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index aea2f816bde9..32783f2c42f8 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -10,6 +10,7 @@ #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/lang/Locale.hpp> #include <rtl/ustring.hxx> +#include <rtl/character.hxx> #include <comphelper/string.hxx> #include <unotools/fontcvt.hxx> #include <unotools/fontdefs.hxx> @@ -311,6 +312,24 @@ const ApiPaperSize& PaperSizeConv::getApiSizeForMSPaperSizeIndex( sal_Int32 nMSO return spPaperSizeTable[ nMSOPaperIndex ]; } +OUString CreateDOCXStyleId(std::u16string_view const aName) +{ + OUStringBuffer aStyleIdBuf(aName.size()); + for (size_t i = 0; i < aName.size(); ++i) + { + sal_Unicode nChar = aName[i]; + if (rtl::isAsciiAlphanumeric(nChar) || nChar == '-') + { + // first letter should be uppercase + if (aStyleIdBuf.isEmpty()) + aStyleIdBuf.append(char(rtl::toAsciiUpperCase(nChar))); + else + aStyleIdBuf.append(char(nChar)); + } + } + return aStyleIdBuf.makeStringAndClear(); +} + std::u16string_view findQuotedText( std::u16string_view rCommand, const char* cStartQuote, const sal_Unicode uEndQuote ) { |