compilerplugins/clang/stringstatic.cxx |    3 ++
 sw/source/filter/html/htmlform.cxx     |   45 ++++++++++++++++-----------------
 sw/source/filter/html/htmlform.hxx     |    4 +-
 sw/source/filter/html/htmlforw.cxx     |    6 ++--
 sw/source/filter/ww8/ww8par3.cxx       |   26 +++++++++----------
 5 files changed, 43 insertions(+), 41 deletions(-)

New commits:
commit 05e3d24602b8df6a476233d0a4e3bef23abc1c72
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu May 2 15:08:21 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat May 4 12:28:35 2024 +0200

    replace createFromAscii with OUString literals in sw
    
    and adjust the loplugin:stringstatic to cope with OUString that
    is also declared in a header as extern, in which case we cannot
    mark it as constexpr.
    
    Change-Id: I108aa3ff8cb06a9a6d345cd951883b52dd0318f2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167106
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/compilerplugins/clang/stringstatic.cxx 
b/compilerplugins/clang/stringstatic.cxx
index a7439608d556..0d4fc0574bf4 100644
--- a/compilerplugins/clang/stringstatic.cxx
+++ b/compilerplugins/clang/stringstatic.cxx
@@ -101,6 +101,9 @@ bool StringStatic::VisitVarDecl(VarDecl const* varDecl)
                 return true;
         }
     }
+    // cannot make something constexpr if it is also declared in a header file 
as extern
+    if (loplugin::hasExternalLinkage(varDecl))
+        return true;
     report(DiagnosticsEngine::Warning,
            "rather declare this as constexpr",
            varDecl->getLocation())
diff --git a/sw/source/filter/html/htmlform.cxx 
b/sw/source/filter/html/htmlform.cxx
index d37abddc68d1..8fcc392e9d8f 100644
--- a/sw/source/filter/html/htmlform.cxx
+++ b/sw/source/filter/html/htmlform.cxx
@@ -136,28 +136,28 @@ static SvMacroItemId aEventTypeTable[] =
     SvMacroItemId::NONE
 };
 
-const char * aEventListenerTable[] =
+const OUString aEventListenerTable[] =
 {
-    "XSubmitListener",
-    "XResetListener",
-    "XFocusListener",
-    "XFocusListener",
-    "XApproveActionListener",
-    "XItemListener",
-    "XChangeListener",
-    ""
+    u"XSubmitListener"_ustr,
+    u"XResetListener"_ustr,
+    u"XFocusListener"_ustr,
+    u"XFocusListener"_ustr,
+    u"XApproveActionListener"_ustr,
+    u"XItemListener"_ustr,
+    u"XChangeListener"_ustr,
+    u""_ustr
 };
 
-const char * aEventMethodTable[] =
+const OUString aEventMethodTable[] =
 {
-    "approveSubmit",
-    "approveReset",
-    "focusGained",
-    "focusLost",
-    "approveAction",
-    "itemStateChanged",
-    "changed",
-    ""
+    u"approveSubmit"_ustr,
+    u"approveReset"_ustr,
+    u"focusGained"_ustr,
+    u"focusLost"_ustr,
+    u"approveAction"_ustr,
+    u"itemStateChanged"_ustr,
+    u"changed"_ustr,
+    u""_ustr
 };
 
 const char * aEventSDOptionTable[] =
@@ -735,7 +735,7 @@ static bool lcl_html_setEvents(
     {
         const SvxMacro *pMacro = rMacroTable.Get( aEventTypeTable[i] );
         // As long as not all events are implemented the table also holds 
empty strings
-        if( pMacro && aEventListenerTable[i] )
+        if( pMacro && !aEventListenerTable[i].isEmpty() )
             nEvents++;
     }
     for( const auto &rStr : rUnoMacroTable )
@@ -759,12 +759,11 @@ static bool lcl_html_setEvents(
     for( int i=0; SvMacroItemId::NONE != aEventTypeTable[i]; ++i )
     {
         const SvxMacro *pMacro = rMacroTable.Get( aEventTypeTable[i] );
-        if( pMacro && aEventListenerTable[i] )
+        if( pMacro && !aEventListenerTable[i].isEmpty() )
         {
             script::ScriptEventDescriptor& rDesc = pDescs[nEvent++];
-            rDesc.ListenerType =
-                    OUString::createFromAscii(aEventListenerTable[i]);
-            rDesc.EventMethod = 
OUString::createFromAscii(aEventMethodTable[i]);
+            rDesc.ListenerType = aEventListenerTable[i];
+            rDesc.EventMethod = aEventMethodTable[i];
             rDesc.ScriptType = pMacro->GetLanguage();
             rDesc.ScriptCode = pMacro->GetMacName();
         }
diff --git a/sw/source/filter/html/htmlform.hxx 
b/sw/source/filter/html/htmlform.hxx
index d1acce1faf57..f52e67ca175d 100644
--- a/sw/source/filter/html/htmlform.hxx
+++ b/sw/source/filter/html/htmlform.hxx
@@ -20,8 +20,8 @@
 #ifndef INCLUDED_SW_SOURCE_FILTER_HTML_HTMLFORM_HXX
 #define INCLUDED_SW_SOURCE_FILTER_HTML_HTMLFORM_HXX
 
-extern const char* aEventListenerTable[];
-extern const char* aEventMethodTable[];
+extern const OUString aEventListenerTable[];
+extern const OUString aEventMethodTable[];
 extern const char* aEventSDOptionTable[];
 extern const char* aEventOptionTable[];
 
diff --git a/sw/source/filter/html/htmlforw.cxx 
b/sw/source/filter/html/htmlforw.cxx
index 6416dfc93cd7..0317b7b7f2a3 100644
--- a/sw/source/filter/html/htmlforw.cxx
+++ b/sw/source/filter/html/htmlforw.cxx
@@ -152,10 +152,10 @@ static void lcl_html_outEvents( SvStream& rStrm,
         OUString sMethod( rDesc.EventMethod );
 
         const char *pOpt = nullptr;
-        for( int j=0; aEventListenerTable[j]; j++ )
+        for( int j=0; !aEventListenerTable[j].isEmpty(); j++ )
         {
-            if( sListener.equalsAscii( aEventListenerTable[j] ) &&
-                sMethod.equalsAscii( aEventMethodTable[j] ) )
+            if( sListener == aEventListenerTable[j] &&
+                sMethod == aEventMethodTable[j] )
             {
                 pOpt = (STARBASIC==eScriptType ? aEventSDOptionTable
                                                : aEventOptionTable)[j];
commit 7c053f115512b44838a0a4f21541e7ba54590950
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu May 2 15:10:04 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat May 4 12:28:27 2024 +0200

    replace createFromAscii with OUString literals in SwWW8ImplReader
    
    Change-Id: I505fe025dfbfd64f950d975d0f81527c7efa3d3b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167107
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 83436369d75c..1ed1f0f15e8f 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -2273,18 +2273,18 @@ awt::Size 
SwWW8ImplReader::MiserableDropDownFormHack(const OUString &rString,
     struct CtrlFontMapEntry
     {
         sal_uInt16 nWhichId;
-        const char* pPropNm;
+        OUString pPropNm;
     };
-    const CtrlFontMapEntry aMapTable[] =
-    {
-        { RES_CHRATR_COLOR,           "TextColor" },
-        { RES_CHRATR_FONT,            "FontName" },
-        { RES_CHRATR_FONTSIZE,        "FontHeight" },
-        { RES_CHRATR_WEIGHT,          "FontWeight" },
-        { RES_CHRATR_UNDERLINE,       "FontUnderline" },
-        { RES_CHRATR_CROSSEDOUT,      "FontStrikeout" },
-        { RES_CHRATR_POSTURE,         "FontSlant" },
-        { 0,                          nullptr }
+    constexpr CtrlFontMapEntry aMapTable[] =
+    {
+        { RES_CHRATR_COLOR,           u"TextColor"_ustr },
+        { RES_CHRATR_FONT,            u"FontName"_ustr },
+        { RES_CHRATR_FONTSIZE,        u"FontHeight"_ustr },
+        { RES_CHRATR_WEIGHT,          u"FontWeight"_ustr },
+        { RES_CHRATR_UNDERLINE,       u"FontUnderline"_ustr },
+        { RES_CHRATR_CROSSEDOUT,      u"FontStrikeout"_ustr },
+        { RES_CHRATR_POSTURE,         u"FontSlant"_ustr },
+        { 0,                          u""_ustr }
     };
 
     vcl::Font aFont;
@@ -2383,8 +2383,8 @@ awt::Size 
SwWW8ImplReader::MiserableDropDownFormHack(const OUString &rString,
             break;
         }
 
-        if (bSet && 
xPropSetInfo->hasPropertyByName(OUString::createFromAscii(pMap->pPropNm)))
-            
rPropSet->setPropertyValue(OUString::createFromAscii(pMap->pPropNm), aTmp);
+        if (bSet && xPropSetInfo->hasPropertyByName(pMap->pPropNm))
+            rPropSet->setPropertyValue(pMap->pPropNm, aTmp);
     }
     // now calculate the size of the control
     OutputDevice* pOut = Application::GetDefaultDevice();

Reply via email to