sfx2/source/doc/sfxbasemodel.cxx |   69 ++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 36 deletions(-)

New commits:
commit e5c33076ab2a4d995e312908ca482b56dd502189
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed May 11 19:16:06 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu May 12 18:03:06 2022 +0200

    avoid cost of NamedValueCollection in SfxBaseModel::attachResource
    
    which wants to construct a whole map just to extract some properties
    
    Change-Id: I79ea0e2d53c2b4aa8182b0622fe0cda2eaacef0f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134224
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index c0f677ad5da6..4d95e47ba1be 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -857,50 +857,47 @@ sal_Bool SAL_CALL SfxBaseModel::attachResource( const   
OUString&
 
         SfxObjectShell* pObjectShell = m_pData->m_pObjectShell.get();
 
-        ::comphelper::NamedValueCollection aArgs( rArgs );
-
         Sequence< sal_Int32 > aWinExtent;
-        if ( ( aArgs.get( "WinExtent" ) >>= aWinExtent )&& ( 
aWinExtent.getLength() == 4 ) )
-        {
-            tools::Rectangle aVisArea( aWinExtent[0], aWinExtent[1], 
aWinExtent[2], aWinExtent[3] );
-            aVisArea = OutputDevice::LogicToLogic(aVisArea, 
MapMode(MapUnit::Map100thMM), MapMode(pObjectShell->GetMapUnit()));
-            pObjectShell->SetVisArea( aVisArea );
-        }
-
-        bool bBreakMacroSign = false;
-        if ( aArgs.get( "BreakMacroSignature" ) >>= bBreakMacroSign )
+        for (const beans::PropertyValue & rProp : rArgs)
         {
-            pObjectShell->BreakMacroSign_Impl( bBreakMacroSign );
+            if (rProp.Name == "WinExtent" && (rProp.Value >>= aWinExtent) && ( 
aWinExtent.getLength() == 4 ) )
+            {
+                tools::Rectangle aVisArea( aWinExtent[0], aWinExtent[1], 
aWinExtent[2], aWinExtent[3] );
+                aVisArea = OutputDevice::LogicToLogic(aVisArea, 
MapMode(MapUnit::Map100thMM), MapMode(pObjectShell->GetMapUnit()));
+                pObjectShell->SetVisArea( aVisArea );
+            }
+            bool bBreakMacroSign = false;
+            if ( rProp.Name == "BreakMacroSignature" && (rProp.Value >>= 
bBreakMacroSign) )
+            {
+                pObjectShell->BreakMacroSign_Impl( bBreakMacroSign );
+            }
+            bool bMacroEventRead = false;
+            if ( rProp.Name == "MacroEventRead" && (rProp.Value >>= 
bMacroEventRead) && bMacroEventRead)
+            {
+                pObjectShell->SetMacroCallsSeenWhileLoading();
+            }
         }
-
-        bool bMacroEventRead = false;
-        if ((aArgs.get("MacroEventRead") >>= bMacroEventRead) && 
bMacroEventRead)
+        Sequence<beans::PropertyValue> aStrippedArgs(rArgs.getLength());
+        beans::PropertyValue* pStripped = aStrippedArgs.getArray();
+        for (const beans::PropertyValue & rProp : rArgs)
         {
-            pObjectShell->SetMacroCallsSeenWhileLoading();
+            if (rProp.Name == "WinExtent"
+                || rProp.Name == "BreakMacroSignature"
+                || rProp.Name == "MacroEventRead"
+                || rProp.Name == "Stream"
+                || rProp.Name == "InputStream"
+                || rProp.Name == "URL"
+                || rProp.Name == "Frame"
+                || rProp.Name == "Password"
+                || rProp.Name == "EncryptionData")
+                continue;
+            *pStripped++ = rProp;
         }
-
-        static constexpr OUStringLiteral sWinExtent = u"WinExtent";
-        static constexpr OUStringLiteral sBreakMacroSignature = 
u"BreakMacroSignature";
-        static constexpr OUStringLiteral sMacroEventRead = u"MacroEventRead";
-        static constexpr OUStringLiteral sStream = u"Stream";
-        static constexpr OUStringLiteral sInputStream = u"InputStream";
-        static constexpr OUStringLiteral sURL = u"URL";
-        static constexpr OUStringLiteral sFrame = u"Frame";
-        static constexpr OUStringLiteral sPassword = u"Password";
-        static constexpr OUStringLiteral sEncryptionData = u"EncryptionData";
-        aArgs.remove( sWinExtent );
-        aArgs.remove( sBreakMacroSignature );
-        aArgs.remove( sMacroEventRead );
-        aArgs.remove( sStream );
-        aArgs.remove( sInputStream );
-        aArgs.remove( sURL );
-        aArgs.remove( sFrame );
-        aArgs.remove( sPassword );
-        aArgs.remove( sEncryptionData );
+        aStrippedArgs.realloc(pStripped - aStrippedArgs.getArray());
 
         // TODO/LATER: all the parameters that are accepted by ItemSet of the 
DocShell must be removed here
 
-        m_pData->m_seqArguments = aArgs.getPropertyValues();
+        m_pData->m_seqArguments = aStrippedArgs;
 
         SfxMedium* pMedium = pObjectShell->GetMedium();
         if ( pMedium )

Reply via email to