Kaydet (Commit) a0bd5587 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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.

Change-Id: I2312e86c9376d3699ef4aa1e0cf2f4c04f706c1e
üst 4cb52136
......@@ -360,6 +360,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,
......@@ -428,7 +433,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 ;
}
......
......@@ -1790,6 +1790,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 )
......
......@@ -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
......
......@@ -155,13 +155,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();
......
......@@ -2423,6 +2423,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/embed,\
XEmbeddedObjectCreator \
XEmbedObjectFactory \
XEmbedPersist \
XEmbedPersist2 \
XEmbeddedClient \
XEmbeddedObject \
XEncryptionProtectedSource \
......
/* -*- 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: */
......@@ -167,10 +167,6 @@ void OLEObjCache::UnloadOnDemand()
void OLEObjCache::InsertObj(SdrOle2Obj* pObj)
{
if (!pObj->IsUnloadable())
// This OLE object is exempt from automatic unloading.
return;
if (!maObjs.empty())
{
SdrOle2Obj* pExistingObj = maObjs.front();
......
......@@ -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>
......@@ -1956,6 +1957,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();
......@@ -2178,13 +2187,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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment