include/oox/ole/olehelper.hxx             |    6 +++---
 oox/source/drawingml/hyperlinkcontext.cxx |    4 ++--
 oox/source/dump/oledumper.cxx             |    9 +++++----
 oox/source/export/drawingml.cxx           |    4 ++--
 oox/source/ole/olehelper.cxx              |    6 ++----
 oox/source/ole/vbamodule.cxx              |    4 ++--
 oox/source/vml/vmlformatting.cxx          |   12 ++++++------
 7 files changed, 22 insertions(+), 23 deletions(-)

New commits:
commit 38d4b6eb42246c0dbd4958a50ed8437bc93508d6
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Apr 29 10:29:11 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Apr 29 12:35:47 2022 +0200

    use more string_view in oox
    
    found by examining uses of OUString::copy() for likely places
    
    Change-Id: I23c397b0438e67e0fdbc1fb4ffa6882aa5e2bf91
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133591
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/oox/ole/olehelper.hxx b/include/oox/ole/olehelper.hxx
index f15642760f3d..e01e6025723a 100644
--- a/include/oox/ole/olehelper.hxx
+++ b/include/oox/ole/olehelper.hxx
@@ -146,11 +146,11 @@ public:
     OleFormCtrlExportHelper( const css::uno::Reference< 
css::uno::XComponentContext >& rxCtx, const css::uno::Reference< 
css::frame::XModel >& xDocModel, const css::uno::Reference< 
css::awt::XControlModel >& xModel );
     ~OleFormCtrlExportHelper();
 
-    OUString getGUID() const
+    std::u16string_view getGUID() const
     {
-        OUString sResult;
+        std::u16string_view sResult;
         if ( maGUID.getLength() > 2 )
-            sResult = maGUID.copy(1, maGUID.getLength() - 2 );
+            sResult = maGUID.subView(1, maGUID.getLength() - 2 );
         return sResult;
     }
     const OUString& getFullName() const { return maFullName; }
diff --git a/oox/source/drawingml/hyperlinkcontext.cxx 
b/oox/source/drawingml/hyperlinkcontext.cxx
index 7bb6930eca13..352eb7bf5efa 100644
--- a/oox/source/drawingml/hyperlinkcontext.cxx
+++ b/oox/source/drawingml/hyperlinkcontext.cxx
@@ -91,8 +91,8 @@ HyperLinkContext::HyperLinkContext( ContextHandler2Helper 
const & rParent,
                 static const OUStringLiteral sJump( u"jump=" );
                 if ( aPPAct.match( sJump, nIndex + 1 ) )
                 {
-                    OUString aDestination( aPPAct.copy( nIndex + 1 + 
sJump.getLength() ) );
-                    sURL += "#action?jump=" + aDestination;
+                    std::u16string_view aDestination( aPPAct.subView( nIndex + 
1 + sJump.getLength() ) );
+                    sURL += OUString::Concat("#action?jump=") + aDestination;
                 }
             }
             else if ( aPPAction.match( "hlinksldjump" ) )
diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx
index 036c12a5670e..92e67c04590f 100644
--- a/oox/source/dump/oledumper.cxx
+++ b/oox/source/dump/oledumper.cxx
@@ -24,6 +24,7 @@
 #include <oox/dump/oledumper.hxx>
 
 #include <rtl/tencinfo.h>
+#include <o3tl/string_view.hxx>
 #include <oox/ole/vbainputstream.hxx>
 
 #ifdef DBG_UTIL
@@ -1830,10 +1831,10 @@ bool VbaContainerStorageObject::isFormStorage( const 
OUString& rStrgPath ) const
 {
     if( (rStrgPath.getLength() >= 3) && (rStrgPath[ 0 ] == 'i') )
     {
-        OUString aId = rStrgPath.copy( 1 );
-        if( (aId.getLength() == 2) && (aId[ 0 ] == '0') )
-            aId = aId.copy( 1 );
-        sal_Int32 nId = aId.toInt32();
+        std::u16string_view aId = rStrgPath.subView( 1 );
+        if( (aId.size() == 2) && (aId[ 0 ] == '0') )
+            aId = aId.substr( 1 );
+        sal_Int32 nId = o3tl::toInt32(aId);
         if( (nId > 0) && (std::u16string_view(OUString::number( nId )) == aId) 
)
             for (auto const& siteInfo : maFormData.maSiteInfos)
                 if( siteInfo.mnId == nId )
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 609528cd33bf..bbeea30af4e5 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2389,9 +2389,9 @@ void DrawingML::WriteRunProperties( const Reference< 
XPropertySet >& rRun, bool
             else
             {
                 sal_Int32 nIndex = sURL.indexOf('=');
-                OUString aDestination(sURL.copy(nIndex + 1));
+                std::u16string_view aDestination(sURL.subView(nIndex + 1));
                 mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, 
XML_id), "", XML_action,
-                                      "ppaction://hlinkshowjump?jump=" + 
aDestination);
+                                      
OUString::Concat("ppaction://hlinkshowjump?jump=") + aDestination);
             }
         }
     }
diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx
index 16b38919a213..41ab34febea3 100644
--- a/oox/source/ole/olehelper.cxx
+++ b/oox/source/ole/olehelper.cxx
@@ -525,8 +525,7 @@ bool MSConvertOCXControls::WriteOCXExcelKludgeStream( const 
css::uno::Reference<
         return false;
     rName = exportHelper.getTypeName();
     SvGlobalName aName;
-    OUString sId = exportHelper.getGUID();
-    aName.MakeId(sId);
+    aName.MakeId(exportHelper.getGUID());
     BinaryXOutputStream aOut( xOutStrm, false );
     OleHelper::exportGuid( aOut, aName );
     exportHelper.exportControl( xOutStrm, rSize );
@@ -544,8 +543,7 @@ bool MSConvertOCXControls::WriteOCXStream( const Reference< 
XModel >& rxModel, t
     if ( !exportHelper.isValid() )
         return false;
 
-    OUString sId = exportHelper.getGUID();
-    aName.MakeId(sId);
+    aName.MakeId(exportHelper.getGUID());
 
     OUString sFullName = exportHelper.getFullName();
     rName = exportHelper.getTypeName();
diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx
index 21a2af75caed..207a76e83bb3 100644
--- a/oox/source/ole/vbamodule.cxx
+++ b/oox/source/ole/vbamodule.cxx
@@ -199,13 +199,13 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg 
)
                         int nSpaceIndex = aCodeLine.indexOf(' ');
                         OUString sProc = aCodeLine.copy( nSpaceIndex + 1, 
index - nSpaceIndex - 1);
                         // for Excel short cut key seems limited to 
cntrl+'a-z, A-Z'
-                        OUString sKey = aCodeLine.copy( 
aCodeLine.lastIndexOf("= ") + 3, 1 );
+                        std::u16string_view sKey = aCodeLine.subView( 
aCodeLine.lastIndexOf("= ") + 3, 1 );
                         // only alpha key valid for key shortcut, however the 
api will accept other keys
                         if ( rtl::isAsciiAlpha( sKey[ 0 ] ) )
                         {
                             // cntrl modifier is explicit ( but could be 
cntrl+shift ), parseKeyEvent
                             // will handle and uppercase letter appropriately
-                            OUString sApiKey = "^" + sKey;
+                            OUString sApiKey = OUString::Concat("^") + sKey;
                             maKeyBindings.push_back({sApiKey, sProc});
                         }
                     }
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index 655069842eda..e83209a7e014 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -166,14 +166,14 @@ sal_Int64 ConversionHelper::decodeMeasureToEmu( const 
GraphicHelper& rGraphicHel
         return 0;
 
     // process trailing unit, convert to EMU
-    OUString aUnit;
+    std::u16string_view aUnit;
     if( (0 < nEndPos) && (nEndPos < rValue.getLength()) )
-        aUnit = rValue.copy( nEndPos );
+        aUnit = rValue.subView( nEndPos );
     else if( bDefaultAsPixel )
-        aUnit = "px";
+        aUnit = u"px";
     // else default is EMU
 
-    if( aUnit.getLength() == 2 )
+    if( aUnit.size() == 2 )
     {
         sal_Unicode cChar1 = aUnit[ 0 ];
         sal_Unicode cChar2 = aUnit[ 1 ];
@@ -192,11 +192,11 @@ sal_Int64 ConversionHelper::decodeMeasureToEmu( const 
GraphicHelper& rGraphicHel
                                            : 
rGraphicHelper.convertScreenPixelYToHmm(fValue),
                                    o3tl::Length::mm100, o3tl::Length::emu);
     }
-    else if( (aUnit.getLength() == 1) && (aUnit[ 0 ] == '%') )
+    else if( (aUnit.size() == 1) && (aUnit[ 0 ] == '%') )
     {
         fValue *= nRefValue / 100.0;
     }
-    else if( bDefaultAsPixel || !aUnit.isEmpty() )   // default as EMU and no 
unit -> do nothing
+    else if( bDefaultAsPixel || !aUnit.empty() )   // default as EMU and no 
unit -> do nothing
     {
         OSL_FAIL( "ConversionHelper::decodeMeasureToEmu - unknown measure 
unit" );
         fValue = nRefValue;

Reply via email to