[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.0' - 2 commits - embeddedobj/source sc/source svtools/inc svtools/source sw/source

Jan Holesovsky kendy at collabora.com
Wed Apr 23 02:50:03 PDT 2014


 embeddedobj/source/msole/olepersist.cxx |   11 +++++------
 sc/source/ui/view/viewfun5.cxx          |    8 ++++++++
 svtools/inc/svtools/transfer.hxx        |   10 +++++++++-
 svtools/source/misc/transfer.cxx        |    6 ++++--
 sw/source/ui/dochdl/swdtflvr.cxx        |    8 ++++++++
 5 files changed, 34 insertions(+), 9 deletions(-)

New commits:
commit 0b503037f52d8c1cb7ce25ee1f4558ad8e0291a9
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Mar 4 22:49:08 2014 +0100

    OLE: Turn an OSL_ENSURE() into a real condition.
    
    This is part of some STAMPIT workaround; no idea what it is, but for sure it
    causes problems with PowerPoint OLE in Writer - so let's avoid updating if it
    is not "STAMPIT".
    
    Change-Id: I266b419ba3461c547f7ee8e447ef64a47a8511e8

diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx
index 18e01cd..a6ba8db 100644
--- a/embeddedobj/source/msole/olepersist.cxx
+++ b/embeddedobj/source/msole/olepersist.cxx
@@ -891,13 +891,12 @@ void OleEmbeddedObject::OnViewChanged_Impl()
     // - if the verb execution is in progress and the view is changed the object will be stored
     // after the execution, so there is no need to send the notification.
     // - the STAMPIT object can never be active.
-    if ( m_aVerbExecutionController.CanDoNotification()
-      && m_pOleComponent && m_nUpdateMode == embed::EmbedUpdateModes::ALWAYS_UPDATE )
+    if (m_aVerbExecutionController.CanDoNotification() &&
+            m_pOleComponent && m_nUpdateMode == embed::EmbedUpdateModes::ALWAYS_UPDATE &&
+            (MimeConfigurationHelper::ClassIDsEqual(m_aClassID, MimeConfigurationHelper::GetSequenceClassID(0x852ee1c9, 0x9058, 0x44ba, 0x8c, 0x6c, 0x0c, 0x5f, 0xc6, 0x6b, 0xdb, 0x8d)) ||
+             MimeConfigurationHelper::ClassIDsEqual(m_aClassID, MimeConfigurationHelper::GetSequenceClassID(0xcf1b4491, 0xbea3, 0x4c9f, 0xa7, 0x0f, 0x22, 0x1b, 0x1e, 0xca, 0xef, 0x3e)))
+       )
     {
-        OSL_ENSURE( MimeConfigurationHelper::ClassIDsEqual( m_aClassID, MimeConfigurationHelper::GetSequenceClassID( 0x852ee1c9, 0x9058, 0x44ba, 0x8c,0x6c,0x0c,0x5f,0xc6,0x6b,0xdb,0x8d ) )
-                    || MimeConfigurationHelper::ClassIDsEqual( m_aClassID, MimeConfigurationHelper::GetSequenceClassID( 0xcf1b4491, 0xbea3, 0x4c9f, 0xa7,0x0f,0x22,0x1b,0x1e,0xca,0xef,0x3e ) ),
-                    "Expected to be triggered for STAMPIT only! Please contact developers!\n" );
-
         // The view is changed while the object is in running state, save the new object
         m_xCachedVisualRepresentation = uno::Reference< io::XStream >();
         SaveObject_Impl();
commit 45646f1def27919b448323a306424f7c6913dde1
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu Feb 20 13:37:04 2014 +0200

    Re-introduce code to try to get GDI metafile replacement image
    
    The code was commented out in 2009 (with any rationale lost from
    version history) and then cleaned away in 2011. Re-introduce the bit
    that tries FORMAT_GDIMETAFILE.
    
    The other part was commented out in 2009 in CWS metropatch01_DEV300,
    with any reasoning behind it lost in history, and then cleaned away in
    2010. Re-introduce the bit that tries FORMAT_GDIMETAFILE. Seems to
    work for data that produces a reasonably sized metafile.
    
    Also limit the GDI metafile size to 100000 actions. Excel can copy huge
    metafiles to the clipboard, with over 3 million of actions, which are
    1) unusable, and 2) crash LibreOffice because of their size.
    
    Change-Id: I80a4ed1681c3833ef1a4b595623387e9d136a774

diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index cf2c7e5..bb2ad16 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -180,6 +180,14 @@ sal_Bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId,
                     Graphic aGraphic;
                     sal_uLong nGrFormat = 0;
 
+                    // limit the size of the preview metafile to 100000 actions
+                    GDIMetaFile aMetafile;
+                    if (aDataHelper.GetGDIMetaFile(FORMAT_GDIMETAFILE, aMetafile, 100000))
+                    {
+                        nGrFormat = SOT_FORMAT_GDIMETAFILE;
+                        aGraphic = aMetafile;
+                    }
+
                     // insert replacement image ( if there is one ) into the object helper
                     if ( nGrFormat )
                     {
diff --git a/svtools/inc/svtools/transfer.hxx b/svtools/inc/svtools/transfer.hxx
index 93dab75..3077715 100644
--- a/svtools/inc/svtools/transfer.hxx
+++ b/svtools/inc/svtools/transfer.hxx
@@ -350,7 +350,15 @@ public:
     sal_Bool                    GetBitmap( SotFormatStringId nFormat, Bitmap& rBmp );
     sal_Bool                    GetBitmap( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, Bitmap& rBmp );
 
-    sal_Bool                    GetGDIMetaFile( SotFormatStringId nFormat, GDIMetaFile& rMtf );
+    /** Return as GDI metafile.
+
+        @param nMaxAction Allows you to limit the amount of actions; defaults to 0 which means no limit.
+
+        Whet you eg. Ctrl+a in Excel, you can get the entire sheet as
+        metafile, with over 3 million (!) actions; which is just too large for
+        any reasonable handling - and you need to set a limit.
+    */
+    sal_Bool                    GetGDIMetaFile( SotFormatStringId nFormat, GDIMetaFile& rMtf, size_t nMaxActions = 0 );
     sal_Bool                    GetGDIMetaFile( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, GDIMetaFile& rMtf );
 
     sal_Bool                    GetGraphic( SotFormatStringId nFormat, Graphic& rGraphic );
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
index 7082867..f09a2d5 100644
--- a/svtools/source/misc/transfer.cxx
+++ b/svtools/source/misc/transfer.cxx
@@ -1772,10 +1772,12 @@ sal_Bool TransferableDataHelper::GetBitmap( const DataFlavor& rFlavor, Bitmap& r
 
 // -----------------------------------------------------------------------------
 
-sal_Bool TransferableDataHelper::GetGDIMetaFile( SotFormatStringId nFormat, GDIMetaFile& rMtf )
+sal_Bool TransferableDataHelper::GetGDIMetaFile(SotFormatStringId nFormat, GDIMetaFile& rMtf, size_t nMaxActions)
 {
     DataFlavor aFlavor;
-    return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetGDIMetaFile( aFlavor, rMtf ) );
+    return SotExchange::GetFormatDataFlavor(nFormat, aFlavor) &&
+        GetGDIMetaFile(aFlavor, rMtf) &&
+        (nMaxActions == 0 || rMtf.GetActionSize() < nMaxActions);
 }
 
 // -----------------------------------------------------------------------------
diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx
index 28bd60c..c2b74fa 100644
--- a/sw/source/ui/dochdl/swdtflvr.cxx
+++ b/sw/source/ui/dochdl/swdtflvr.cxx
@@ -1766,6 +1766,14 @@ int SwTransferable::_PasteOLE( TransferableDataHelper& rData, SwWrtShell& rSh,
             Graphic aGraphic;
             sal_uLong nGrFormat = 0;
 
+            // limit the size of the preview metafile to 100000 actions
+            GDIMetaFile aMetafile;
+            if (rData.GetGDIMetaFile(FORMAT_GDIMETAFILE, aMetafile, 100000))
+            {
+                nGrFormat = SOT_FORMAT_GDIMETAFILE;
+                aGraphic = aMetafile;
+            }
+
             // insert replacement image ( if there is one ) into the object helper
             if ( nGrFormat )
             {


More information about the Libreoffice-commits mailing list