[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - embeddedobj/source include/svx offapi/com offapi/UnoApi_offapi.mk svx/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Jul 21 01:54:50 PDT 2014


 embeddedobj/source/commonembedding/miscobj.cxx     |    8 ++++-
 embeddedobj/source/commonembedding/persistence.cxx |    9 ++++++
 embeddedobj/source/inc/commonembobj.hxx            |    8 ++++-
 include/svx/svdoole2.hxx                           |    7 ----
 offapi/UnoApi_offapi.mk                            |    1 
 offapi/com/sun/star/embed/XEmbedPersist2.idl       |   30 +++++++++++++++++++++
 svx/source/svdraw/svdetc.cxx                       |    4 --
 svx/source/svdraw/svdoole2.cxx                     |   16 ++++++-----
 8 files changed, 62 insertions(+), 21 deletions(-)

New commits:
commit 65a41146af0c3c86de5c530446719e75f2c5512e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Jul 11 10:50:29 2014 -0400

    bnc#883684: Better fix for this.
    
    Instead of making all chart objects exempt from unloading, check each OLE
    object on whether or not it already has its persistent storage created.
    If not, don't unload it else it would have nothing to load back from once
    unloaded.
    
    (cherry picked from commit a0bd5587a5ac62974bdb10731d3fd21584521a72)
    
    Conflicts:
    	svx/source/svdraw/svdetc.cxx
    
    Change-Id: I2312e86c9376d3699ef4aa1e0cf2f4c04f706c1e
    Reviewed-on: https://gerrit.libreoffice.org/10237
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx
index 8df625d..fd5ab0d 100644
--- a/embeddedobj/source/commonembedding/miscobj.cxx
+++ b/embeddedobj/source/commonembedding/miscobj.cxx
@@ -363,6 +363,11 @@ uno::Any SAL_CALL OCommonEmbeddedObject::queryInterface( const uno::Type& rType
         void * p = static_cast< embed::XEmbeddedObject * >( this );
         return uno::Any( &p, rType );
     }
+    else if (rType == cppu::UnoType<embed::XEmbedPersist2>::get())
+    {
+        void* p = static_cast<embed::XEmbedPersist2*>(this);
+        return uno::Any(&p, rType);
+    }
     else
         aReturn <<= ::cppu::queryInterface(
                     rType,
@@ -431,7 +436,8 @@ uno::Sequence< uno::Type > SAL_CALL OCommonEmbeddedObject::getTypes()
                                             cppu::UnoType<embed::XInplaceObject>::get(),
                                             cppu::UnoType<embed::XCommonEmbedPersist>::get(),
                                             cppu::UnoType<container::XChild>::get(),
-                                            cppu::UnoType<embed::XEmbedPersist>::get());
+                                            cppu::UnoType<embed::XEmbedPersist>::get(),
+                                            cppu::UnoType<embed::XEmbedPersist2>::get());
 
                 pTypeCollection = &aTypeCollection ;
             }
diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx
index 51210a7..c85e786 100644
--- a/embeddedobj/source/commonembedding/persistence.cxx
+++ b/embeddedobj/source/commonembedding/persistence.cxx
@@ -1789,6 +1789,15 @@ void SAL_CALL OCommonEmbeddedObject::reload(
     }
 }
 
+sal_Bool SAL_CALL OCommonEmbeddedObject::isStored() throw (css::uno::RuntimeException, std::exception)
+{
+    uno::Reference<container::XNameAccess> xNA(m_xObjectStorage, uno::UNO_QUERY);
+    if (!xNA.is())
+        return false;
+
+    return xNA->getElementNames().getLength() > 0;
+}
+
 
 void SAL_CALL OCommonEmbeddedObject::breakLink( const uno::Reference< embed::XStorage >& xStorage,
                                                 const OUString& sEntName )
diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx
index ceba61e..0808363 100644
--- a/embeddedobj/source/inc/commonembobj.hxx
+++ b/embeddedobj/source/inc/commonembobj.hxx
@@ -27,7 +27,7 @@
 #include <com/sun/star/document/XStorageBasedDocument.hpp>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 #include <com/sun/star/embed/XVisualObject.hpp>
-#include <com/sun/star/embed/XEmbedPersist.hpp>
+#include <com/sun/star/embed/XEmbedPersist2.hpp>
 #include <com/sun/star/embed/XLinkageSupport.hpp>
 #include <com/sun/star/embed/XClassifiedObject.hpp>
 #include <com/sun/star/embed/XComponentSupplier.hpp>
@@ -72,7 +72,7 @@ namespace comphelper {
 class Interceptor;
 
 class OCommonEmbeddedObject : public ::com::sun::star::embed::XEmbeddedObject
-                            , public ::com::sun::star::embed::XEmbedPersist
+                            , public ::com::sun::star::embed::XEmbedPersist2
                             , public ::com::sun::star::embed::XLinkageSupport
                             , public ::com::sun::star::embed::XInplaceObject
                             , public ::com::sun::star::container::XChild
@@ -429,6 +429,10 @@ public:
                 ::com::sun::star::uno::Exception,
                 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
 
+// XEmbedPersist2
+
+    virtual sal_Bool SAL_CALL isStored()
+        throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
 
 // XInplaceObject
 
diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx
index 21d3b56..68ad43e 100644
--- a/include/svx/svdoole2.hxx
+++ b/include/svx/svdoole2.hxx
@@ -171,13 +171,6 @@ public:
     bool IsChart() const;
     bool IsCalc() const;
 
-    /**
-     * Unloadable OLE objects are subject to automatic unloading per memory
-     * setting.  The "Number of objects" setting in the Memory option controls
-     * how many OLE objects can be loaded at any given moment.
-     */
-    bool IsUnloadable() const;
-
     bool UpdateLinkURL_Impl();
     void BreakFileLink_Impl();
     void DisconnectFileLink_Impl();
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 8a07f15..67ef1c8 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2423,6 +2423,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/embed,\
     XEmbeddedObjectCreator \
 	XEmbedObjectFactory \
 	XEmbedPersist \
+	XEmbedPersist2 \
 	XEmbeddedClient \
 	XEmbeddedObject \
 	XEncryptionProtectedSource \
diff --git a/offapi/com/sun/star/embed/XEmbedPersist2.idl b/offapi/com/sun/star/embed/XEmbedPersist2.idl
new file mode 100644
index 0000000..205b902
--- /dev/null
+++ b/offapi/com/sun/star/embed/XEmbedPersist2.idl
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __com_sun_star_XEmbedPersist2_idl__
+#define __com_sun_star_XEmbedPersist2_idl__
+
+#include <com/sun/star/embed/XEmbedPersist.idl>
+
+module com {  module sun {  module star { module embed {
+
+interface XEmbedPersist2 : XEmbedPersist
+{
+    /**
+     * Checks whether or not the object has created its persistent
+     * representation counterpart of its in-memory model.
+     */
+    boolean isStored();
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 3214a32..a9cb949 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -166,10 +166,6 @@ void OLEObjCache::UnloadOnDemand()
 
 void OLEObjCache::InsertObj(SdrOle2Obj* pObj)
 {
-    if (!pObj->IsUnloadable())
-        // This OLE object is exempt from automatic unloading.
-        return;
-
     if ( !empty() )
     {
         SdrOle2Obj* pExistingObj = front();
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index 889f3ed..3ef566c 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/embed/ElementModes.hpp>
 #include <com/sun/star/embed/EmbedMisc.hpp>
 #include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/embed/XEmbedPersist2.hpp>
 #include <com/sun/star/embed/XInplaceClient.hpp>
 #include <com/sun/star/embed/XInplaceObject.hpp>
 #include <com/sun/star/embed/XLinkageSupport.hpp>
@@ -1929,6 +1930,14 @@ void SdrOle2Obj::NbcMove(const Size& rSize)
 
 bool SdrOle2Obj::CanUnloadRunningObj( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
 {
+    uno::Reference<embed::XEmbedPersist2> xPersist(xObj, uno::UNO_QUERY);
+    if (xPersist.is())
+    {
+        if (!xPersist->isStored())
+            // It doesn't have persistent storage.  We can't unload this.
+            return false;
+    }
+
     bool bResult = false;
 
     sal_Int32 nState = xObj->getCurrentState();
@@ -2162,13 +2171,6 @@ bool SdrOle2Obj::IsCalc() const
     return false;
 }
 
-bool SdrOle2Obj::IsUnloadable() const
-{
-    // Right now, chart OLE objects are the only ones exempt from automatic
-    // unloading.
-    return !IsChart();
-}
-
 uno::Reference< frame::XModel > SdrOle2Obj::GetParentXModel() const
 {
     uno::Reference< frame::XModel > xDoc;


More information about the Libreoffice-commits mailing list