sw/source/filter/ww8/wrtw8sty.cxx |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 01b30c701d065fc9a4582b9bbac221d1edffb45b
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Dec 7 19:55:26 2022 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 7 21:34:59 2022 +0000

    Allow hyphen-minus in style ids
    
    These are used in OOXML; and hyphens are allowed there (at least
    Word uses ids like "E-mailSignature" for "E-mail Signature").
    
    Change-Id: I399e84def504a716553fcfc2b624e58aa7d9ba70
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143795
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/source/filter/ww8/wrtw8sty.cxx 
b/sw/source/filter/ww8/wrtw8sty.cxx
index c73378d4b702..d766f4923f2e 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -30,6 +30,8 @@
 #include <svx/svdouno.hxx>
 #include <editeng/lrspitem.hxx>
 #include <editeng/fhgtitem.hxx>
+#include <rtl/character.hxx>
+
 #include <doc.hxx>
 #include "wrtww8.hxx"
 #include <docary.hxx>
@@ -324,13 +326,11 @@ OString MSWordStyles::CreateStyleId(std::u16string_view 
aName)
     for (size_t i = 0; i < aName.size(); ++i)
     {
         sal_Unicode nChar = aName[i];
-        if (('0' <= nChar && nChar <= '9') ||
-            ('a' <= nChar && nChar <= 'z') ||
-            ('A' <= nChar && nChar <= 'Z'))
+        if (rtl::isAsciiAlphanumeric(nChar) || nChar == '-')
         {
             // first letter should be uppercase
-            if (aStyleIdBuf.isEmpty() && 'a' <= nChar && nChar <= 'z')
-                aStyleIdBuf.append(char(nChar - ('a' - 'A')));
+            if (aStyleIdBuf.isEmpty())
+                aStyleIdBuf.append(char(rtl::toAsciiUpperCase(nChar)));
             else
                 aStyleIdBuf.append(char(nChar));
         }

Reply via email to