include/oox/export/shapes.hxx      |    3 ++-
 oox/source/drawingml/textfield.cxx |   19 ++++++++++++-------
 oox/source/export/shapes.cxx       |   33 +++++++++++++++++----------------
 3 files changed, 31 insertions(+), 24 deletions(-)

New commits:
commit fcdfdc21b197bb9af1a75348ce912c5d1d47dfba
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Sep 22 21:16:12 2021 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Wed Sep 22 23:23:14 2021 +0200

    Extend loplugin:stringviewparam to starts/endsWith: oox
    
    Change-Id: I02b4352f02fe32f40c4fe0ab198d8ac094381c7a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122491
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx
index 0f4e264fb1b6..646d462e827b 100644
--- a/include/oox/export/shapes.hxx
+++ b/include/oox/export/shapes.hxx
@@ -22,6 +22,7 @@
 
 #include <cstddef>
 #include <memory>
+#include <string_view>
 #include <unordered_map>
 
 #include <com/sun/star/awt/Size.hpp>
@@ -67,7 +68,7 @@ namespace oox {
 OOX_DLLPUBLIC css::uno::Reference<css::io::XInputStream> GetOLEObjectStream(
     css::uno::Reference<css::uno::XComponentContext> const& xContext,
     css::uno::Reference<css::embed::XEmbeddedObject> const& xObj,
-    OUString const& i_rProgID,
+    std::u16string_view i_rProgID,
     OUString & o_rMediaType,
     OUString & o_rRelationType,
     OUString & o_rSuffix,
diff --git a/oox/source/drawingml/textfield.cxx 
b/oox/source/drawingml/textfield.cxx
index 0d33da71266d..405a874d8e57 100644
--- a/oox/source/drawingml/textfield.cxx
+++ b/oox/source/drawingml/textfield.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <drawingml/textfield.hxx>
 
 #include <rtl/ustring.hxx>
@@ -26,6 +30,7 @@
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/text/XTextField.hpp>
 
+#include <o3tl/string_view.hxx>
 #include <oox/helper/helper.hxx>
 #include <oox/helper/propertyset.hxx>
 #include <oox/core/xmlfilterbase.hxx>
@@ -56,11 +61,11 @@ namespace {
  * @param sType the OpenXML field type.
  */
 void lclCreateTextFields( std::vector< Reference< XTextField > > & aFields,
-                                                            const Reference< 
XModel > & xModel, const OUString & sType )
+                                                            const Reference< 
XModel > & xModel, std::u16string_view sType )
 {
     Reference< XInterface > xIface;
     Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW );
-    if( sType.startsWith("datetime"))
+    if( o3tl::starts_with(sType, u"datetime"))
     {
         OString s = OUStringToOString( sType, RTL_TEXTENCODING_UTF8);
         OString p( s.pData->buffer + 8 );
@@ -100,22 +105,22 @@ void lclCreateTextFields( std::vector< Reference< 
XTextField > > & aFields,
             TOOLS_WARN_EXCEPTION("oox", "");
         }
     }
-    else if ( sType == "slidenum" )
+    else if ( sType == u"slidenum" )
     {
         xIface = xFactory->createInstance( 
"com.sun.star.text.TextField.PageNumber" );
         aFields.emplace_back( xIface, UNO_QUERY );
     }
-    else if ( sType == "slidecount" )
+    else if ( sType == u"slidecount" )
     {
         xIface = xFactory->createInstance( 
"com.sun.star.text.TextField.PageCount" );
         aFields.emplace_back( xIface, UNO_QUERY );
     }
-    else if ( sType == "slidename" )
+    else if ( sType == u"slidename" )
     {
         xIface = xFactory->createInstance( 
"com.sun.star.text.TextField.PageName" );
         aFields.emplace_back( xIface, uno::UNO_QUERY );
     }
-    else if ( sType.startsWith("file") )
+    else if ( o3tl::starts_with(sType, u"file") )
     {
         OString s = OUStringToOString( sType, RTL_TEXTENCODING_UTF8);
         OString p( s.pData->buffer + 4 );
@@ -139,7 +144,7 @@ void lclCreateTextFields( std::vector< Reference< 
XTextField > > & aFields,
                 xProps->setPropertyValue("FileFormat", makeAny<sal_Int16>(0));
         }
     }
-    else if( sType == "author" )
+    else if( sType == u"author" )
     {
         xIface = xFactory->createInstance( 
"com.sun.star.text.TextField.Author" );
         aFields.emplace_back( xIface, UNO_QUERY );
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 5fc037029456..bc120abe1627 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -21,6 +21,7 @@
 
 #include <sal/log.hxx>
 #include <filter/msfilter/util.hxx>
+#include <o3tl/string_view.hxx>
 #include <oox/core/xmlfilterbase.hxx>
 #include <oox/export/shapes.hxx>
 #include <oox/export/utils.hxx>
@@ -95,88 +96,88 @@ using ::sax_fastparser::FSHelperPtr;
 
 namespace oox {
 
-static void lcl_ConvertProgID(OUString const& rProgID,
+static void lcl_ConvertProgID(std::u16string_view rProgID,
     OUString & o_rMediaType, OUString & o_rRelationType, OUString & 
o_rFileExtension)
 {
-    if (rProgID == "Excel.Sheet.12")
+    if (rProgID == u"Excel.Sheet.12")
     {
         o_rMediaType = 
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
         o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
         o_rFileExtension = "xlsx";
     }
-    else if (rProgID.startsWith("Excel.SheetBinaryMacroEnabled.12") )
+    else if (o3tl::starts_with(rProgID, u"Excel.SheetBinaryMacroEnabled.12") )
     {
         o_rMediaType = "application/vnd.ms-excel.sheet.binary.macroEnabled.12";
         o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
         o_rFileExtension = "xlsb";
     }
-    else if (rProgID.startsWith("Excel.SheetMacroEnabled.12"))
+    else if (o3tl::starts_with(rProgID, u"Excel.SheetMacroEnabled.12"))
     {
         o_rMediaType = "application/vnd.ms-excel.sheet.macroEnabled.12";
         o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
         o_rFileExtension = "xlsm";
     }
-    else if (rProgID.startsWith("Excel.Sheet"))
+    else if (o3tl::starts_with(rProgID, u"Excel.Sheet"))
     {
         o_rMediaType = "application/vnd.ms-excel";
         o_rRelationType = oox::getRelationship(Relationship::OLEOBJECT);
         o_rFileExtension = "xls";
     }
-    else if (rProgID == "PowerPoint.Show.12")
+    else if (rProgID == u"PowerPoint.Show.12")
     {
         o_rMediaType = 
"application/vnd.openxmlformats-officedocument.presentationml.presentation";
         o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
         o_rFileExtension = "pptx";
     }
-    else if (rProgID == "PowerPoint.ShowMacroEnabled.12")
+    else if (rProgID == u"PowerPoint.ShowMacroEnabled.12")
     {
         o_rMediaType = 
"application/vnd.ms-powerpoint.presentation.macroEnabled.12";
         o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
         o_rFileExtension = "pptm";
     }
-    else if (rProgID.startsWith("PowerPoint.Show"))
+    else if (o3tl::starts_with(rProgID, u"PowerPoint.Show"))
     {
         o_rMediaType = "application/vnd.ms-powerpoint";
         o_rRelationType = oox::getRelationship(Relationship::OLEOBJECT);
         o_rFileExtension = "ppt";
     }
-    else if (rProgID.startsWith("PowerPoint.Slide.12"))
+    else if (o3tl::starts_with(rProgID, u"PowerPoint.Slide.12"))
     {
        o_rMediaType = 
"application/vnd.openxmlformats-officedocument.presentationml.slide";
        o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
        o_rFileExtension = "sldx";
     }
-    else if (rProgID == "PowerPoint.SlideMacroEnabled.12")
+    else if (rProgID == u"PowerPoint.SlideMacroEnabled.12")
     {
        o_rMediaType = "application/vnd.ms-powerpoint.slide.macroEnabled.12";
        o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
        o_rFileExtension = "sldm";
     }
-    else if (rProgID == "Word.DocumentMacroEnabled.12")
+    else if (rProgID == u"Word.DocumentMacroEnabled.12")
     {
         o_rMediaType = "application/vnd.ms-word.document.macroEnabled.12";
         o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
         o_rFileExtension = "docm";
     }
-    else if (rProgID == "Word.Document.12")
+    else if (rProgID == u"Word.Document.12")
     {
         o_rMediaType = 
"application/vnd.openxmlformats-officedocument.wordprocessingml.document";
         o_rRelationType = oox::getRelationship(Relationship::PACKAGE);
         o_rFileExtension = "docx";
     }
-    else if (rProgID == "Word.Document.8")
+    else if (rProgID == u"Word.Document.8")
     {
         o_rMediaType = "application/msword";
         o_rRelationType = oox::getRelationship(Relationship::OLEOBJECT);
         o_rFileExtension = "doc";
     }
-    else if (rProgID == "Excel.Chart.8")
+    else if (rProgID == u"Excel.Chart.8")
     {
         o_rMediaType = "application/vnd.ms-excel";
         o_rRelationType = oox::getRelationship(Relationship::OLEOBJECT);
         o_rFileExtension = "xls";
     }
-    else if (rProgID == "AcroExch.Document.11")
+    else if (rProgID == u"AcroExch.Document.11")
     {
         o_rMediaType = "application/pdf";
         o_rRelationType = oox::getRelationship(Relationship::OLEOBJECT);
@@ -272,7 +273,7 @@ static uno::Reference<io::XInputStream> lcl_StoreOwnAsOOXML(
 uno::Reference<io::XInputStream> GetOLEObjectStream(
         uno::Reference<uno::XComponentContext> const& xContext,
         uno::Reference<embed::XEmbeddedObject> const& xObj,
-        OUString const& i_rProgID,
+        std::u16string_view i_rProgID,
         OUString & o_rMediaType,
         OUString & o_rRelationType,
         OUString & o_rSuffix,

Reply via email to