Blob Blame History Raw
From bac8126cf1d485eaa65d9ab480118346eff90ad2 Mon Sep 17 00:00:00 2001
From: Kohei Yoshida <kohei.yoshida@collabora.com>
Date: Wed, 9 Jul 2014 21:46:34 -0400
Subject: [PATCH 006/137] bnc#883684: Make chart objects exempt from automatic
 unloading.

The Memory option page contains "Number of objects" setting which controls
how many OLE objects can be loaded at any given time.  When the number of
total OLE objects exceeds this number the oldest ones get unloaded.  Note
that the total number is across all open documents, not per document.

Technically, chart objects are OLE objects, but unlike other OLE objects
that are embedded Calc, Writer, Draw documents, chart objects normally
"belong" to the host document.  It therefore makes no sense to subject
chart objects to this automatic unloading.

In the future we may want to apply this exemption to other types of OLE
objects, like formula objects for example..  Or maybe this setting can be
removed altogether...

(cherry picked from commit b023565d4f064cd0312e8c1fcc23a9f552112935)
Signed-off-by: Andras Timar <andras.timar@collabora.com>

Conflicts:
	include/svx/svdoole2.hxx
	svx/source/svdraw/svdetc.cxx
	svx/source/svdraw/svdoole2.cxx

Change-Id: I7dd92550880efb4db8fc843cf1c915c712166da4
(cherry picked from commit 55612305b645a1c0872373c0a9f434763708732a)
Signed-off-by: Andras Timar <andras.timar@collabora.com>
---
 include/svx/svdoole2.hxx       | 7 +++++++
 svx/source/svdraw/svdetc.cxx   | 4 ++++
 svx/source/svdraw/svdoole2.cxx | 8 +++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx
index 7a93f4b..0f1df14 100644
--- a/include/svx/svdoole2.hxx
+++ b/include/svx/svdoole2.hxx
@@ -167,6 +167,13 @@ public:
     sal_Bool IsChart() const;
     sal_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;
+
     sal_Bool UpdateLinkURL_Impl();
     void BreakFileLink_Impl();
     void DisconnectFileLink_Impl();
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 4caca94..afcc792 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -165,6 +165,10 @@ 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 2929252..1102de8 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -2142,7 +2142,13 @@ sal_Bool SdrOle2Obj::IsCalc() const
     return sal_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;
-- 
1.9.3