filter/source/msfilter/escherex.cxx        |    3 +--
 filter/source/msfilter/util.cxx            |    8 ++++----
 include/filter/msfilter/util.hxx           |    4 ++--
 oox/source/export/DMLPresetShapeExport.cxx |    8 +++-----
 oox/source/export/shapes.cxx               |    2 +-
 5 files changed, 11 insertions(+), 14 deletions(-)

New commits:
commit d67017bfe251c71ac1345615d9a3080a7fefdf32
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Mar 14 11:30:45 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Mar 14 13:14:55 2022 +0100

    simplify GetOOXMLPresetGeometry
    
    all the call sites are using OUString, so push the utf8 conversion
    into the function
    
    Change-Id: I875249b8702cde63737fd42dc1d1592be059cc11
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131525
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/filter/source/msfilter/escherex.cxx 
b/filter/source/msfilter/escherex.cxx
index 3f817a72bcb1..3e79fe28a8b1 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -3717,8 +3717,7 @@ MSO_SPT EscherPropertyContainer::GetCustomShapeType( 
const uno::Reference< drawi
                                 // In case of VML export, try to handle the
                                 // ooxml- prefix in rShapeType. If that fails,
                                 // just do the same as the binary export.
-                                OString aType = OUStringToOString(rShapeType, 
RTL_TEXTENCODING_UTF8);
-                                eShapeType = 
msfilter::util::GETVMLShapeType(aType);
+                                eShapeType = 
msfilter::util::GETVMLShapeType(rShapeType);
                                 if (eShapeType == mso_sptNil)
                                     eShapeType = 
EnhancedCustomShapeTypeNames::Get(rShapeType);
                             }
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index 23b4de1e87be..d0e4b24fe08c 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -1215,7 +1215,7 @@ struct {
     {"textBox", mso_sptTextBox},
 };
 
-const char* GetOOXMLPresetGeometry( const char* sShapeType )
+const char* GetOOXMLPresetGeometry( const OUString& rShapeType )
 {
     typedef std::unordered_map< const char*, const char*, rtl::CStringHash, 
rtl::CStringEqual> CustomShapeTypeTranslationHashMap;
     static CustomShapeTypeTranslationHashMap 
aCustomShapeTypeTranslationHashMap = []()
@@ -1228,11 +1228,11 @@ const char* GetOOXMLPresetGeometry( const char* 
sShapeType )
         return tmp;
     }();
     CustomShapeTypeTranslationHashMap::iterator i(
-        aCustomShapeTypeTranslationHashMap.find(sShapeType));
+        aCustomShapeTypeTranslationHashMap.find(rShapeType.toUtf8().getStr()));
     return i == aCustomShapeTypeTranslationHashMap.end() ? "rect" : i->second;
 }
 
-MSO_SPT GETVMLShapeType(const OString& aType)
+MSO_SPT GETVMLShapeType(const OUString& aType)
 {
     typedef std::unordered_map< const char*, MSO_SPT, rtl::CStringHash, 
rtl::CStringEqual> DMLToVMLTranslationHashMap;
     static DMLToVMLTranslationHashMap aDMLToVMLMap = []()
@@ -1243,7 +1243,7 @@ MSO_SPT GETVMLShapeType(const OString& aType)
         return tmp;
     }();
 
-    const char* pDML = GetOOXMLPresetGeometry(aType.getStr());
+    const char* pDML = GetOOXMLPresetGeometry(aType);
     DMLToVMLTranslationHashMap::iterator i(aDMLToVMLMap.find(pDML));
     return i == aDMLToVMLMap.end() ? mso_sptNil : i->second;
 }
diff --git a/include/filter/msfilter/util.hxx b/include/filter/msfilter/util.hxx
index f2c2a0dbfcfe..3e7610c28a4f 100644
--- a/include/filter/msfilter/util.hxx
+++ b/include/filter/msfilter/util.hxx
@@ -115,10 +115,10 @@ struct MSFILTER_DLLPUBLIC EquationResult
 MSFILTER_DLLPUBLIC EquationResult ParseCombinedChars(const OUString& rStr);
 
 /// Similar to EnhancedCustomShapeTypeNames::Get(), but it also supports OOXML 
types and returns a drawingML string.
-MSFILTER_DLLPUBLIC const char* GetOOXMLPresetGeometry( const char* sShapeType 
);
+MSFILTER_DLLPUBLIC const char* GetOOXMLPresetGeometry( const OUString& 
rShapeType );
 
 /// Similar to EnhancedCustomShapeTypeNames::Get(), but returns an MSO_SPT 
(binary / VML type).
-MSFILTER_DLLPUBLIC MSO_SPT GETVMLShapeType(const OString& aType);
+MSFILTER_DLLPUBLIC MSO_SPT GETVMLShapeType(const OUString& aType);
 
 /**
  * The following function checks if a MSO shapetype is allowed to have 
textboxcontent.
diff --git a/oox/source/export/DMLPresetShapeExport.cxx 
b/oox/source/export/DMLPresetShapeExport.cxx
index b374eb6b6c1a..ad603bcd2bd2 100644
--- a/oox/source/export/DMLPresetShapeExport.cxx
+++ b/oox/source/export/DMLPresetShapeExport.cxx
@@ -223,8 +223,7 @@ bool DMLPresetShapeExporter::WriteShape()
         if (!m_bHasHandleValues)
         {
             OUString sShapeType = GetShapeType();
-            const char* sPresetShape
-                = 
msfilter::util::GetOOXMLPresetGeometry(sShapeType.toUtf8().getStr());
+            const char* sPresetShape = 
msfilter::util::GetOOXMLPresetGeometry(sShapeType);
             m_pDMLexporter->WriteShapeTransformation(m_xShape, XML_a, 
IsXFlipped(), IsYFlipped(),
                                                      false, false);
             m_pDMLexporter->WritePresetShape(sPresetShape);
@@ -255,8 +254,7 @@ bool DMLPresetShapeExporter::StartAVListWriting()
 {
     try
     {
-        const char* pShape
-            = 
msfilter::util::GetOOXMLPresetGeometry(GetShapeType().toUtf8().getStr());
+        const char* pShape = 
msfilter::util::GetOOXMLPresetGeometry(GetShapeType());
         m_pDMLexporter->GetFS()->startElementNS(XML_a, XML_prstGeom, XML_prst, 
pShape);
         m_pDMLexporter->GetFS()->startElementNS(XML_a, XML_avLst);
         return true;
@@ -287,7 +285,7 @@ bool DMLPresetShapeExporter::WriteShapeWithAVlist()
     // types which do not have pairs in LO, they are do not have to be mapped, 
because import
     // filter it does with GrabBag, this method only maps the SDR ones to 
OOXML shapes.
 
-    OString 
sShapeType(msfilter::util::GetOOXMLPresetGeometry(GetShapeType().toUtf8().getStr()));
+    OString sShapeType(msfilter::util::GetOOXMLPresetGeometry(GetShapeType()));
 
     // OOXML uses 60th of degree, so 360 degree is 21 600 000 60thdeg
     const tools::Long nConstOfMaxDegreeOf60th = 21600000;
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index a061d1306f99..51bf3b528eaf 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -768,7 +768,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const 
Reference< XShape >& xShape )
         EscherPropertyContainer::IsDefaultObject(
             rSdrObjCustomShape,
             eShapeType));
-    const char* sPresetShape = 
msfilter::util::GetOOXMLPresetGeometry(sShapeType.toUtf8().getStr());
+    const char* sPresetShape = 
msfilter::util::GetOOXMLPresetGeometry(sShapeType);
     SAL_INFO("oox.shape", "custom shape type: " << sShapeType << " ==> " << 
sPresetShape);
 
     sal_Int32 nAdjustmentValuesIndex = -1;

Reply via email to