2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* 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/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-16 20:26:53 +00:00
|
|
|
|
2005-03-15 10:25:11 +00:00
|
|
|
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
|
2005-04-04 07:20:55 +00:00
|
|
|
#include <com/sun/star/container/XChild.hpp>
|
2004-10-04 18:08:55 +00:00
|
|
|
#include <com/sun/star/embed/XEmbedPersist.hpp>
|
2005-01-18 13:58:11 +00:00
|
|
|
#include <com/sun/star/embed/XLinkageSupport.hpp>
|
2004-10-04 18:08:55 +00:00
|
|
|
#include <com/sun/star/embed/Aspects.hpp>
|
|
|
|
#include <com/sun/star/embed/EmbedMisc.hpp>
|
|
|
|
#include <com/sun/star/embed/EmbedStates.hpp>
|
|
|
|
#include <com/sun/star/util/XCloseable.hpp>
|
|
|
|
#include <com/sun/star/util/XModifiable.hpp>
|
|
|
|
#include <com/sun/star/document/XEventBroadcaster.hpp>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <com/sun/star/chart2/XChartDocument.hpp>
|
2015-04-06 18:44:54 +02:00
|
|
|
#include <cppuhelper/implbase.hxx>
|
2004-11-26 15:26:56 +00:00
|
|
|
|
2004-10-04 18:08:55 +00:00
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <hintids.hxx>
|
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
#include <sfx2/app.hxx>
|
2010-01-13 22:25:07 +01:00
|
|
|
#include <sfx2/linkmgr.hxx>
|
2000-12-18 10:16:07 +00:00
|
|
|
#include <unotools/configitem.hxx>
|
2001-07-05 09:34:53 +00:00
|
|
|
#include <vcl/outdev.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <fmtanchr.hxx>
|
|
|
|
#include <frmfmt.hxx>
|
|
|
|
#include <doc.hxx>
|
2005-04-04 07:20:55 +00:00
|
|
|
#include <docsh.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <pam.hxx>
|
|
|
|
#include <section.hxx>
|
|
|
|
#include <cntfrm.hxx>
|
|
|
|
#include <frmatr.hxx>
|
|
|
|
#include <ndole.hxx>
|
2014-05-25 14:10:13 +02:00
|
|
|
#include <DocumentSettingManager.hxx>
|
2014-06-15 20:54:04 +02:00
|
|
|
#include <IDocumentLinksAdministration.hxx>
|
2004-10-04 18:08:55 +00:00
|
|
|
|
2005-03-29 13:49:32 +00:00
|
|
|
#include <comphelper/classids.hxx>
|
2004-10-04 18:08:55 +00:00
|
|
|
#include <vcl/graph.hxx>
|
2005-01-18 13:58:11 +00:00
|
|
|
#include <sot/formats.hxx>
|
2004-10-04 18:08:55 +00:00
|
|
|
#include <unotools/ucbstreamhelper.hxx>
|
2013-01-02 22:07:41 +01:00
|
|
|
#include <vcl/graphicfilter.hxx>
|
2004-09-08 13:56:58 +00:00
|
|
|
#include <comcore.hrc>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2014-12-04 10:43:02 -05:00
|
|
|
#include <deque>
|
|
|
|
|
2000-12-18 10:16:07 +00:00
|
|
|
using namespace utl;
|
2008-03-12 11:22:35 +00:00
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-06-25 18:53:01 +02:00
|
|
|
class SwOLELRUCache
|
|
|
|
: private utl::ConfigItem
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-06-25 18:53:01 +02:00
|
|
|
private:
|
|
|
|
typedef std::deque<SwOLEObj *> OleObjects_t;
|
|
|
|
OleObjects_t m_OleObjects;
|
|
|
|
sal_Int32 m_nLRU_InitSize;
|
2015-05-04 10:29:18 +02:00
|
|
|
static uno::Sequence< OUString > GetPropertyNames();
|
2000-12-18 10:16:07 +00:00
|
|
|
|
2015-03-11 16:14:47 +01:00
|
|
|
virtual void ImplCommit() SAL_OVERRIDE;
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
public:
|
2000-12-18 10:16:07 +00:00
|
|
|
SwOLELRUCache();
|
|
|
|
|
2007-09-27 08:08:33 +00:00
|
|
|
virtual void Notify( const uno::Sequence<
|
2014-03-27 18:12:18 +01:00
|
|
|
OUString>& aPropertyNames ) SAL_OVERRIDE;
|
2000-12-18 10:16:07 +00:00
|
|
|
void Load();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2007-09-27 08:08:33 +00:00
|
|
|
void InsertObj( SwOLEObj& rObj );
|
|
|
|
void RemoveObj( SwOLEObj& rObj );
|
2000-09-18 23:08:29 +00:00
|
|
|
};
|
|
|
|
|
2004-11-26 15:26:56 +00:00
|
|
|
SwOLELRUCache* pOLELRU_Cache = 0;
|
|
|
|
|
2015-04-06 18:44:54 +02:00
|
|
|
class SwOLEListener_Impl : public ::cppu::WeakImplHelper< embed::XStateChangeListener >
|
2004-11-26 15:26:56 +00:00
|
|
|
{
|
|
|
|
SwOLEObj* mpObj;
|
|
|
|
public:
|
2015-05-27 10:53:55 +01:00
|
|
|
explicit SwOLEListener_Impl( SwOLEObj* pObj );
|
2004-11-26 15:26:56 +00:00
|
|
|
void Release();
|
2014-03-27 18:12:18 +01:00
|
|
|
virtual void SAL_CALL changingState( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (embed::WrongStateException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
virtual void SAL_CALL stateChanged( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
|
|
|
virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
|
2004-11-26 15:26:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SwOLEListener_Impl::SwOLEListener_Impl( SwOLEObj* pObj )
|
|
|
|
: mpObj( pObj )
|
|
|
|
{
|
|
|
|
if ( mpObj->IsOleRef() && mpObj->GetOleRef()->getCurrentState() == embed::EmbedStates::RUNNING )
|
|
|
|
{
|
2007-09-27 08:08:33 +00:00
|
|
|
pOLELRU_Cache->InsertObj( *mpObj );
|
2004-11-26 15:26:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void SAL_CALL SwOLEListener_Impl::changingState( const lang::EventObject&, ::sal_Int32 , ::sal_Int32 ) throw (embed::WrongStateException, uno::RuntimeException, std::exception)
|
2004-11-26 15:26:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void SAL_CALL SwOLEListener_Impl::stateChanged( const lang::EventObject&, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (uno::RuntimeException, std::exception)
|
2004-11-26 15:26:56 +00:00
|
|
|
{
|
|
|
|
if ( mpObj && nOldState == embed::EmbedStates::LOADED && nNewState == embed::EmbedStates::RUNNING )
|
|
|
|
{
|
|
|
|
if( !pOLELRU_Cache )
|
|
|
|
pOLELRU_Cache = new SwOLELRUCache;
|
2007-09-27 08:08:33 +00:00
|
|
|
pOLELRU_Cache->InsertObj( *mpObj );
|
2004-11-26 15:26:56 +00:00
|
|
|
}
|
|
|
|
else if ( mpObj && nNewState == embed::EmbedStates::LOADED && nOldState == embed::EmbedStates::RUNNING )
|
|
|
|
{
|
|
|
|
if ( pOLELRU_Cache )
|
2007-09-27 08:08:33 +00:00
|
|
|
pOLELRU_Cache->RemoveObj( *mpObj );
|
2004-11-26 15:26:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwOLEListener_Impl::Release()
|
|
|
|
{
|
|
|
|
if ( mpObj && pOLELRU_Cache )
|
2007-09-27 08:08:33 +00:00
|
|
|
pOLELRU_Cache->RemoveObj( *mpObj );
|
2004-11-26 15:26:56 +00:00
|
|
|
mpObj=0;
|
|
|
|
release();
|
|
|
|
}
|
|
|
|
|
2014-02-25 21:31:58 +01:00
|
|
|
void SAL_CALL SwOLEListener_Impl::disposing( const lang::EventObject& ) throw (uno::RuntimeException, std::exception)
|
2004-11-26 15:26:56 +00:00
|
|
|
{
|
|
|
|
if ( mpObj && pOLELRU_Cache )
|
2007-09-27 08:08:33 +00:00
|
|
|
pOLELRU_Cache->RemoveObj( *mpObj );
|
2004-11-26 15:26:56 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2005-01-18 13:58:11 +00:00
|
|
|
// TODO/LATER: actually SwEmbedObjectLink should be used here, but because different objects are used to control
|
|
|
|
// embedded object different link objects with the same functionality had to be implemented
|
|
|
|
|
|
|
|
class SwEmbedObjectLink : public sfx2::SvBaseLink
|
|
|
|
{
|
|
|
|
SwOLENode* pOleNode;
|
|
|
|
|
|
|
|
public:
|
2015-05-27 10:53:55 +01:00
|
|
|
explicit SwEmbedObjectLink(SwOLENode* pNode);
|
2005-01-18 13:58:11 +00:00
|
|
|
virtual ~SwEmbedObjectLink();
|
|
|
|
|
2014-03-27 18:12:18 +01:00
|
|
|
virtual void Closed() SAL_OVERRIDE;
|
2011-05-25 14:58:03 -04:00
|
|
|
virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
|
2014-03-27 18:12:18 +01:00
|
|
|
const OUString& rMimeType, const ::com::sun::star::uno::Any & rValue ) SAL_OVERRIDE;
|
2005-01-18 13:58:11 +00:00
|
|
|
|
2012-11-30 08:49:55 +09:00
|
|
|
bool Connect() { return GetRealObject() != NULL; }
|
2005-01-18 13:58:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SwEmbedObjectLink::SwEmbedObjectLink(SwOLENode* pNode):
|
2015-03-23 14:23:01 +02:00
|
|
|
::sfx2::SvBaseLink( ::SfxLinkUpdateMode::ONCALL, SotClipboardFormatId::SVXB ),
|
2005-01-18 13:58:11 +00:00
|
|
|
pOleNode(pNode)
|
|
|
|
{
|
2014-03-14 11:18:53 +02:00
|
|
|
SetSynchron( false );
|
2005-01-18 13:58:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwEmbedObjectLink::~SwEmbedObjectLink()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-05-25 14:58:03 -04:00
|
|
|
::sfx2::SvBaseLink::UpdateResult SwEmbedObjectLink::DataChanged(
|
2013-08-23 17:23:52 +02:00
|
|
|
const OUString&, const uno::Any& )
|
2005-01-18 13:58:11 +00:00
|
|
|
{
|
|
|
|
if ( !pOleNode->UpdateLinkURL_Impl() )
|
|
|
|
{
|
|
|
|
// the link URL was not changed
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xObject = pOleNode->GetOLEObj().GetOleRef();
|
|
|
|
OSL_ENSURE( xObject.is(), "The object must exist always!\n" );
|
|
|
|
if ( xObject.is() )
|
|
|
|
{
|
|
|
|
// let the object reload the link
|
|
|
|
// TODO/LATER: reload call could be used for this case
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sal_Int32 nState = xObject->getCurrentState();
|
2009-04-23 13:48:24 +00:00
|
|
|
if ( nState != embed::EmbedStates::LOADED )
|
2005-01-18 13:58:11 +00:00
|
|
|
{
|
|
|
|
// in some cases the linked file probably is not locked so it could be changed
|
|
|
|
xObject->changeState( embed::EmbedStates::LOADED );
|
|
|
|
xObject->changeState( nState );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch ( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pOleNode->GetNewReplacement();
|
2011-05-25 14:58:03 -04:00
|
|
|
return SUCCESS;
|
2005-01-18 13:58:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwEmbedObjectLink::Closed()
|
|
|
|
{
|
|
|
|
pOleNode->BreakFileLink_Impl();
|
|
|
|
SvBaseLink::Closed();
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
SwOLENode::SwOLENode( const SwNodeIndex &rWhere,
|
2004-10-04 18:08:55 +00:00
|
|
|
const svt::EmbeddedObjectRef& xObj,
|
2015-05-20 13:05:49 +02:00
|
|
|
SwGrfFormatColl *pGrfColl,
|
2000-09-18 23:08:29 +00:00
|
|
|
SwAttrSet* pAutoAttr ) :
|
2015-05-20 13:05:49 +02:00
|
|
|
SwNoTextNode( rWhere, ND_OLENODE, pGrfColl, pAutoAttr ),
|
2004-10-04 18:08:55 +00:00
|
|
|
aOLEObj( xObj ),
|
2014-04-25 14:00:35 +02:00
|
|
|
bOLESizeInvalid( false ),
|
2005-01-18 13:58:11 +00:00
|
|
|
mpObjectLink( NULL )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
aOLEObj.SetNode( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
SwOLENode::SwOLENode( const SwNodeIndex &rWhere,
|
2013-08-17 13:47:15 +02:00
|
|
|
const OUString &rString,
|
2006-10-13 10:09:11 +00:00
|
|
|
sal_Int64 nAspect,
|
2015-05-20 13:05:49 +02:00
|
|
|
SwGrfFormatColl *pGrfColl,
|
2000-09-18 23:08:29 +00:00
|
|
|
SwAttrSet* pAutoAttr ) :
|
2015-05-20 13:05:49 +02:00
|
|
|
SwNoTextNode( rWhere, ND_OLENODE, pGrfColl, pAutoAttr ),
|
2006-10-13 10:09:11 +00:00
|
|
|
aOLEObj( rString, nAspect ),
|
2014-04-25 14:00:35 +02:00
|
|
|
bOLESizeInvalid( false ),
|
2005-01-18 13:58:11 +00:00
|
|
|
mpObjectLink( NULL )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
aOLEObj.SetNode( this );
|
|
|
|
}
|
|
|
|
|
2004-10-04 18:08:55 +00:00
|
|
|
SwOLENode::~SwOLENode()
|
|
|
|
{
|
2005-01-18 13:58:11 +00:00
|
|
|
DisconnectFileLink_Impl();
|
2004-10-04 18:08:55 +00:00
|
|
|
}
|
|
|
|
|
2013-01-17 14:28:41 -05:00
|
|
|
const Graphic* SwOLENode::GetGraphic()
|
2004-10-04 18:08:55 +00:00
|
|
|
{
|
|
|
|
if ( aOLEObj.GetOleRef().is() )
|
|
|
|
return aOLEObj.xOLERef.GetGraphic();
|
2014-10-31 18:27:30 +01:00
|
|
|
return 0;
|
2004-10-04 18:08:55 +00:00
|
|
|
}
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
SwContentNode *SwOLENode::SplitContentNode( const SwPosition & )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-10-06 10:12:46 +02:00
|
|
|
// Multiply OLE objects?
|
2011-03-19 14:13:18 +01:00
|
|
|
OSL_FAIL( "OleNode: can't split." );
|
2000-09-18 23:08:29 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-10-06 10:12:46 +02:00
|
|
|
/**
|
|
|
|
* Loading a OLE object that has been moved to the Undo Area
|
|
|
|
*/
|
2014-03-15 19:22:14 +01:00
|
|
|
bool SwOLENode::RestorePersistentData()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE( aOLEObj.GetOleRef().is(), "No object to restore!" );
|
2004-10-04 18:08:55 +00:00
|
|
|
if ( aOLEObj.xOLERef.is() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-10-06 10:12:46 +02:00
|
|
|
// If a SvPersist instance already exists, we use it
|
2004-10-04 18:08:55 +00:00
|
|
|
SfxObjectShell* p = GetDoc()->GetPersist();
|
|
|
|
if( !p )
|
|
|
|
{
|
2014-10-06 10:12:46 +02:00
|
|
|
// TODO/LATER: Isn't a EmbeddedObjectContainer sufficient here?
|
|
|
|
// What happens to this document?
|
|
|
|
OSL_ENSURE( false, "Why are we creating a DocShell here?" );
|
2015-04-09 15:24:21 +02:00
|
|
|
p = new SwDocShell( GetDoc(), SfxObjectCreateMode::INTERNAL );
|
2004-10-04 18:08:55 +00:00
|
|
|
p->DoInitNew( NULL );
|
|
|
|
}
|
|
|
|
|
2005-04-04 07:20:55 +00:00
|
|
|
uno::Reference < container::XChild > xChild( aOLEObj.xOLERef.GetObject(), uno::UNO_QUERY );
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent( p->GetModel() );
|
|
|
|
|
2013-08-17 11:47:04 +02:00
|
|
|
OSL_ENSURE( !aOLEObj.aName.isEmpty(), "No object name!" );
|
2013-03-01 13:50:58 +01:00
|
|
|
OUString aObjName;
|
2004-10-04 18:08:55 +00:00
|
|
|
if ( !p->GetEmbeddedObjectContainer().InsertEmbeddedObject( aOLEObj.xOLERef.GetObject(), aObjName ) )
|
|
|
|
{
|
2005-04-04 07:20:55 +00:00
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent( 0 );
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL( "InsertObject failed" );
|
2004-10-04 18:08:55 +00:00
|
|
|
}
|
|
|
|
else
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-10-04 18:08:55 +00:00
|
|
|
aOLEObj.aName = aObjName;
|
|
|
|
aOLEObj.xOLERef.AssignToContainer( &p->GetEmbeddedObjectContainer(), aObjName );
|
2005-01-18 13:58:11 +00:00
|
|
|
CheckFileLink_Impl();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-15 19:22:14 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2014-10-06 10:12:46 +02:00
|
|
|
/**
|
|
|
|
* OLE object is transported into UNDO area
|
|
|
|
*/
|
2014-03-15 19:22:14 +01:00
|
|
|
bool SwOLENode::SavePersistentData()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-10-04 18:08:55 +00:00
|
|
|
if( aOLEObj.xOLERef.is() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2005-05-11 11:01:44 +00:00
|
|
|
comphelper::EmbeddedObjectContainer* pCnt = aOLEObj.xOLERef.GetContainer();
|
|
|
|
|
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2004-10-04 18:08:55 +00:00
|
|
|
SfxObjectShell* p = GetDoc()->GetPersist();
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE( p, "No document!" );
|
2005-05-11 11:01:44 +00:00
|
|
|
if( p )
|
|
|
|
{
|
|
|
|
comphelper::EmbeddedObjectContainer& rCnt = p->GetEmbeddedObjectContainer();
|
|
|
|
OSL_ENSURE( !pCnt || &rCnt == pCnt, "The helper is assigned to unexpected container!\n" );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ( pCnt && pCnt->HasEmbeddedObject( aOLEObj.aName ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2005-04-04 07:20:55 +00:00
|
|
|
uno::Reference < container::XChild > xChild( aOLEObj.xOLERef.GetObject(), uno::UNO_QUERY );
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent( 0 );
|
|
|
|
|
2014-03-15 19:29:18 +01:00
|
|
|
/*
|
|
|
|
#i119941
|
|
|
|
When cut or move the chart, SwUndoFlyBase::DelFly will call SaveSection
|
|
|
|
to store the content to storage. In this step, chart filter functions
|
|
|
|
will be called. And chart filter will call chart core functions to create
|
|
|
|
the chart again. Then chart core function will call the class
|
|
|
|
ExplicitCategoryProvider to create data source. In this step, when SW data
|
2014-04-07 10:21:05 +02:00
|
|
|
source provider create the data source, an UnoActionRemoveContext
|
|
|
|
will mess with the layout and create a new SwFlyFrm.
|
2014-03-15 19:29:18 +01:00
|
|
|
But later in SwUndoFlyBase::DelFly, it will clear anchor related attributes
|
|
|
|
of SwFlyFrm. Then finally null pointer occur.
|
|
|
|
Resolution:
|
|
|
|
In pCnt->RemoveEmbeddedObject in SaveSection process of table chart,
|
|
|
|
only remove the object from the object container, without removing it's
|
|
|
|
storage and graphic stream. The chart already removed from formatter.
|
|
|
|
*/
|
2014-04-07 10:21:05 +02:00
|
|
|
bool bKeepObjectToTempStorage = true;
|
2014-03-15 19:29:18 +01:00
|
|
|
uno::Reference < embed::XEmbeddedObject > xIP = GetOLEObj().GetOleRef();
|
2015-05-20 13:05:49 +02:00
|
|
|
if (IsChart() && !sChartTableName.isEmpty()
|
2014-04-07 10:21:05 +02:00
|
|
|
&& svt::EmbeddedObjectRef::TryRunningState(xIP))
|
2014-03-15 19:29:18 +01:00
|
|
|
{
|
|
|
|
uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
|
2014-04-07 10:21:05 +02:00
|
|
|
if (xChart.is() && !xChart->hasInternalDataProvider())
|
|
|
|
{
|
|
|
|
bKeepObjectToTempStorage = false;
|
|
|
|
}
|
2014-03-15 19:29:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pCnt->RemoveEmbeddedObject( aOLEObj.aName, false, bKeepObjectToTempStorage );
|
2012-06-21 14:25:25 +00:00
|
|
|
|
2005-05-11 11:01:44 +00:00
|
|
|
// TODO/LATER: aOLEObj.aName has no meaning here, since the undo container contains the object
|
2014-11-10 15:05:25 +01:00
|
|
|
// by different name, in future it might makes sense that the name is transported here.
|
2004-10-04 18:08:55 +00:00
|
|
|
aOLEObj.xOLERef.AssignToContainer( 0, aOLEObj.aName );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// "unload" object
|
|
|
|
aOLEObj.xOLERef->changeState( embed::EmbedStates::LOADED );
|
|
|
|
}
|
|
|
|
catch ( uno::Exception& )
|
2003-04-24 15:44:48 +00:00
|
|
|
{
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-18 13:58:11 +00:00
|
|
|
DisconnectFileLink_Impl();
|
|
|
|
|
2014-03-15 19:22:14 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwOLENode * SwNodes::MakeOLENode( const SwNodeIndex & rWhere,
|
2004-10-04 18:08:55 +00:00
|
|
|
const svt::EmbeddedObjectRef& xObj,
|
2015-05-20 13:05:49 +02:00
|
|
|
SwGrfFormatColl* pGrfColl,
|
2000-09-18 23:08:29 +00:00
|
|
|
SwAttrSet* pAutoAttr )
|
|
|
|
{
|
2014-10-06 10:12:46 +02:00
|
|
|
OSL_ENSURE( pGrfColl,"SwNodes::MakeOLENode: Formatpointer is 0." );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwOLENode *pNode =
|
2004-10-04 18:08:55 +00:00
|
|
|
new SwOLENode( rWhere, xObj, pGrfColl, pAutoAttr );
|
2005-04-04 07:20:55 +00:00
|
|
|
|
|
|
|
// set parent if XChild is supported
|
|
|
|
//!! needed to supply Math objects with a valid reference device
|
2007-06-05 16:29:54 +00:00
|
|
|
uno::Reference< container::XChild > xChild( pNode->GetOLEObj().GetObject().GetObject(), UNO_QUERY );
|
2005-04-04 07:20:55 +00:00
|
|
|
if (xChild.is())
|
|
|
|
{
|
|
|
|
SwDocShell *pDocSh = GetDoc()->GetDocShell();
|
|
|
|
if (pDocSh)
|
|
|
|
xChild->setParent( pDocSh->GetModel() );
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
return pNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwOLENode * SwNodes::MakeOLENode( const SwNodeIndex & rWhere,
|
2015-05-20 13:05:49 +02:00
|
|
|
const OUString &rName, sal_Int64 nAspect, SwGrfFormatColl* pGrfColl, SwAttrSet* pAutoAttr )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-10-06 10:12:46 +02:00
|
|
|
OSL_ENSURE( pGrfColl,"SwNodes::MakeOLENode: Formatpointer is 0." );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwOLENode *pNode =
|
2006-10-13 10:09:11 +00:00
|
|
|
new SwOLENode( rWhere, rName, nAspect, pGrfColl, pAutoAttr );
|
2005-04-04 07:20:55 +00:00
|
|
|
|
|
|
|
// set parent if XChild is supported
|
|
|
|
//!! needed to supply Math objects with a valid reference device
|
2007-06-05 16:29:54 +00:00
|
|
|
uno::Reference< container::XChild > xChild( pNode->GetOLEObj().GetObject().GetObject(), UNO_QUERY );
|
2005-04-04 07:20:55 +00:00
|
|
|
if (xChild.is())
|
|
|
|
{
|
|
|
|
SwDocShell *pDocSh= GetDoc()->GetDocShell();
|
|
|
|
if (pDocSh)
|
|
|
|
xChild->setParent( pDocSh->GetModel() );
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
return pNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
Size SwOLENode::GetTwipSize() const
|
|
|
|
{
|
2006-10-13 10:09:11 +00:00
|
|
|
MapMode aMapMode( MAP_TWIP );
|
2014-11-24 10:39:29 +02:00
|
|
|
return const_cast<SwOLENode*>(this)->aOLEObj.GetObject().GetSize( &aMapMode );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
SwContentNode* SwOLENode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-10-06 10:12:46 +02:00
|
|
|
// If there's already a SvPersist instance, we use it
|
2011-01-03 13:40:23 +01:00
|
|
|
SfxObjectShell* pPersistShell = pDoc->GetPersist();
|
|
|
|
if( !pPersistShell )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-01-03 13:40:23 +01:00
|
|
|
// TODO/LATER: is EmbeddedObjectContainer not enough?
|
|
|
|
// the created document will be closed by pDoc ( should use SfxObjectShellLock )
|
2015-04-09 15:24:21 +02:00
|
|
|
pPersistShell = new SwDocShell( pDoc, SfxObjectCreateMode::INTERNAL );
|
2011-03-15 13:50:53 +00:00
|
|
|
pDoc->SetTmpDocShell( pPersistShell );
|
2011-01-03 13:40:23 +01:00
|
|
|
pPersistShell->DoInitNew( NULL );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2014-10-06 10:12:46 +02:00
|
|
|
// We insert it at SvPersist level
|
2004-10-04 18:08:55 +00:00
|
|
|
// TODO/LATER: check if using the same naming scheme for all apps works here
|
2013-03-01 13:50:58 +01:00
|
|
|
OUString aNewName/*( Sw3Io::UniqueName( p->GetStorage(), "Obj" ) )*/;
|
2004-10-04 18:08:55 +00:00
|
|
|
SfxObjectShell* pSrc = GetDoc()->GetPersist();
|
2001-09-13 15:18:24 +00:00
|
|
|
|
2011-01-03 13:40:23 +01:00
|
|
|
pPersistShell->GetEmbeddedObjectContainer().CopyAndGetEmbeddedObject(
|
2005-07-12 11:10:58 +00:00
|
|
|
pSrc->GetEmbeddedObjectContainer(),
|
|
|
|
pSrc->GetEmbeddedObjectContainer().GetEmbeddedObject( aOLEObj.aName ),
|
2014-06-13 11:12:50 -04:00
|
|
|
aNewName,
|
|
|
|
OUString(),
|
|
|
|
OUString());
|
2005-05-11 11:01:44 +00:00
|
|
|
|
2006-10-13 10:09:11 +00:00
|
|
|
SwOLENode* pOLENd = pDoc->GetNodes().MakeOLENode( rIdx, aNewName, GetAspect(),
|
2015-05-20 13:05:49 +02:00
|
|
|
pDoc->GetDfltGrfFormatColl(),
|
2015-03-26 15:31:55 +01:00
|
|
|
const_cast<SwAttrSet*>(GetpSwAttrSet()) );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
pOLENd->SetChartTableName( GetChartTableName() );
|
2009-08-27 11:59:20 +00:00
|
|
|
pOLENd->SetTitle( GetTitle() );
|
|
|
|
pOLENd->SetDescription( GetDescription() );
|
2001-04-24 09:07:58 +00:00
|
|
|
pOLENd->SetContour( HasContour(), HasAutomaticContour() );
|
2006-10-13 10:09:11 +00:00
|
|
|
pOLENd->SetAspect( GetAspect() ); // the replacement image must be already copied
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
pOLENd->SetOLESizeInvalid( true );
|
2000-09-18 23:08:29 +00:00
|
|
|
pDoc->SetOLEPrtNotifyPending();
|
|
|
|
|
|
|
|
return pOLENd;
|
|
|
|
}
|
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool SwOLENode::IsInGlobalDocSection() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-10-06 10:12:46 +02:00
|
|
|
// Find the "Body Anchor"
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nEndExtraIdx = GetNodes().GetEndOfExtras().GetIndex();
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwNode* pAnchorNd = this;
|
|
|
|
do {
|
2015-05-20 13:05:49 +02:00
|
|
|
SwFrameFormat* pFlyFormat = pAnchorNd->GetFlyFormat();
|
|
|
|
if( !pFlyFormat )
|
2014-04-25 14:00:35 +02:00
|
|
|
return false;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
const SwFormatAnchor& rAnchor = pFlyFormat->GetAnchor();
|
|
|
|
if( !rAnchor.GetContentAnchor() )
|
2014-04-25 14:00:35 +02:00
|
|
|
return false;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
pAnchorNd = &rAnchor.GetContentAnchor()->nNode.GetNode();
|
2000-09-18 23:08:29 +00:00
|
|
|
} while( pAnchorNd->GetIndex() < nEndExtraIdx );
|
|
|
|
|
|
|
|
const SwSectionNode* pSectNd = pAnchorNd->FindSectionNode();
|
|
|
|
if( !pSectNd )
|
2014-04-25 14:00:35 +02:00
|
|
|
return false;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
while( pSectNd )
|
|
|
|
{
|
|
|
|
pAnchorNd = pSectNd;
|
2006-08-14 15:31:12 +00:00
|
|
|
pSectNd = pAnchorNd->StartOfSectionNode()->FindSectionNode();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2014-10-06 10:12:46 +02:00
|
|
|
// pAnchorNd contains the most recently found Section Node, which
|
2014-11-10 15:05:25 +01:00
|
|
|
// now must fulfill the prerequesites for the GlobalDoc
|
2014-11-21 14:36:31 +02:00
|
|
|
pSectNd = static_cast<const SwSectionNode*>(pAnchorNd);
|
2000-09-18 23:08:29 +00:00
|
|
|
return FILE_LINK_SECTION == pSectNd->GetSection().GetType() &&
|
|
|
|
pSectNd->GetIndex() > nEndExtraIdx;
|
|
|
|
}
|
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool SwOLENode::IsOLEObjectDeleted() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-04-25 14:00:35 +02:00
|
|
|
bool bRet = false;
|
2004-10-04 18:08:55 +00:00
|
|
|
if( aOLEObj.xOLERef.is() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-10-04 18:08:55 +00:00
|
|
|
SfxObjectShell* p = GetDoc()->GetPersist();
|
2014-10-06 10:12:46 +02:00
|
|
|
if( p ) // Must be there
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2005-11-10 14:56:52 +00:00
|
|
|
return !p->GetEmbeddedObjectContainer().HasEmbeddedObject( aOLEObj.aName );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2005-01-18 13:58:11 +00:00
|
|
|
void SwOLENode::GetNewReplacement()
|
|
|
|
{
|
|
|
|
if ( aOLEObj.xOLERef.is() )
|
|
|
|
aOLEObj.xOLERef.UpdateReplacement();
|
|
|
|
}
|
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool SwOLENode::UpdateLinkURL_Impl()
|
2005-01-18 13:58:11 +00:00
|
|
|
{
|
2014-04-25 14:00:35 +02:00
|
|
|
bool bResult = false;
|
2005-01-18 13:58:11 +00:00
|
|
|
|
|
|
|
if ( mpObjectLink )
|
|
|
|
{
|
2013-08-17 13:47:15 +02:00
|
|
|
OUString aNewLinkURL;
|
2015-04-13 13:50:56 +02:00
|
|
|
sfx2::LinkManager::GetDisplayNames( mpObjectLink, 0, &aNewLinkURL, 0, 0 );
|
2013-08-17 13:47:15 +02:00
|
|
|
if ( !aNewLinkURL.equalsIgnoreAsciiCase( maLinkURL ) )
|
2005-01-18 13:58:11 +00:00
|
|
|
{
|
|
|
|
if ( !aOLEObj.xOLERef.is() )
|
|
|
|
aOLEObj.GetOleRef();
|
|
|
|
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xObj = aOLEObj.xOLERef.GetObject();
|
|
|
|
uno::Reference< embed::XCommonEmbedPersist > xPersObj( xObj, uno::UNO_QUERY );
|
|
|
|
OSL_ENSURE( xPersObj.is(), "The object must exist!\n" );
|
|
|
|
if ( xPersObj.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sal_Int32 nCurState = xObj->getCurrentState();
|
|
|
|
if ( nCurState != embed::EmbedStates::LOADED )
|
|
|
|
xObj->changeState( embed::EmbedStates::LOADED );
|
|
|
|
|
|
|
|
// TODO/LATER: there should be possible to get current mediadescriptor settings from the object
|
|
|
|
uno::Sequence< beans::PropertyValue > aArgs( 1 );
|
2013-10-31 17:16:50 +02:00
|
|
|
aArgs[0].Name = "URL";
|
2013-08-17 13:47:15 +02:00
|
|
|
aArgs[0].Value <<= aNewLinkURL;
|
2005-01-18 13:58:11 +00:00
|
|
|
xPersObj->reload( aArgs, uno::Sequence< beans::PropertyValue >() );
|
|
|
|
|
|
|
|
maLinkURL = aNewLinkURL;
|
2014-04-25 14:00:35 +02:00
|
|
|
bResult = true;
|
2005-01-18 13:58:11 +00:00
|
|
|
|
|
|
|
if ( nCurState != embed::EmbedStates::LOADED )
|
|
|
|
xObj->changeState( nCurState );
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bResult )
|
|
|
|
{
|
|
|
|
// TODO/LATER: return the old name to the link manager, is it possible?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwOLENode::BreakFileLink_Impl()
|
|
|
|
{
|
|
|
|
SfxObjectShell* pPers = GetDoc()->GetPersist();
|
|
|
|
|
|
|
|
if ( pPers )
|
|
|
|
{
|
|
|
|
uno::Reference< embed::XStorage > xStorage = pPers->GetStorage();
|
|
|
|
if ( xStorage.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< embed::XLinkageSupport > xLinkSupport( aOLEObj.GetOleRef(), uno::UNO_QUERY_THROW );
|
|
|
|
xLinkSupport->breakLink( xStorage, aOLEObj.GetCurrentPersistName() );
|
|
|
|
DisconnectFileLink_Impl();
|
2014-12-18 13:35:13 +01:00
|
|
|
maLinkURL.clear();
|
2005-01-18 13:58:11 +00:00
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwOLENode::DisconnectFileLink_Impl()
|
|
|
|
{
|
|
|
|
if ( mpObjectLink )
|
|
|
|
{
|
2014-06-15 20:54:04 +02:00
|
|
|
GetDoc()->getIDocumentLinksAdministration().GetLinkManager().Remove( mpObjectLink );
|
2005-01-18 13:58:11 +00:00
|
|
|
mpObjectLink = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwOLENode::CheckFileLink_Impl()
|
|
|
|
{
|
|
|
|
if ( aOLEObj.xOLERef.GetObject().is() && !mpObjectLink )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< embed::XLinkageSupport > xLinkSupport( aOLEObj.xOLERef.GetObject(), uno::UNO_QUERY_THROW );
|
|
|
|
if ( xLinkSupport->isLink() )
|
|
|
|
{
|
2013-08-17 13:47:15 +02:00
|
|
|
const OUString aLinkURL = xLinkSupport->getLinkURL();
|
|
|
|
if ( !aLinkURL.isEmpty() )
|
2005-01-18 13:58:11 +00:00
|
|
|
{
|
|
|
|
// this is a file link so the model link manager should handle it
|
|
|
|
mpObjectLink = new SwEmbedObjectLink( this );
|
|
|
|
maLinkURL = aLinkURL;
|
2014-06-15 20:54:04 +02:00
|
|
|
GetDoc()->getIDocumentLinksAdministration().GetLinkManager().InsertFileLink( *mpObjectLink, OBJECT_CLIENT_OLE, aLinkURL, NULL, NULL );
|
2005-01-18 13:58:11 +00:00
|
|
|
mpObjectLink->Connect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i99665#
|
2009-03-17 10:06:02 +00:00
|
|
|
bool SwOLENode::IsChart() const
|
|
|
|
{
|
|
|
|
bool bIsChart( false );
|
|
|
|
|
|
|
|
const uno::Reference< embed::XEmbeddedObject > xEmbObj =
|
|
|
|
const_cast<SwOLEObj&>(GetOLEObj()).GetOleRef();
|
|
|
|
if ( xEmbObj.is() )
|
|
|
|
{
|
|
|
|
SvGlobalName aClassID( xEmbObj->getClassID() );
|
|
|
|
bIsChart = SotExchange::IsChart( aClassID );
|
|
|
|
}
|
|
|
|
|
|
|
|
return bIsChart;
|
|
|
|
}
|
|
|
|
|
2004-10-04 18:08:55 +00:00
|
|
|
SwOLEObj::SwOLEObj( const svt::EmbeddedObjectRef& xObj ) :
|
2004-11-26 15:26:56 +00:00
|
|
|
pOLENd( 0 ),
|
2007-09-27 08:08:33 +00:00
|
|
|
pListener( 0 ),
|
|
|
|
xOLERef( xObj )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-01-28 19:59:54 +01:00
|
|
|
xOLERef.Lock( true );
|
2004-11-26 15:26:56 +00:00
|
|
|
if ( xObj.is() )
|
|
|
|
{
|
|
|
|
pListener = new SwOLEListener_Impl( this );
|
|
|
|
pListener->acquire();
|
|
|
|
xObj->addStateChangeListener( pListener );
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-08-17 11:47:04 +02:00
|
|
|
SwOLEObj::SwOLEObj( const OUString &rString, sal_Int64 nAspect ) :
|
2000-09-18 23:08:29 +00:00
|
|
|
pOLENd( 0 ),
|
2007-09-27 08:08:33 +00:00
|
|
|
pListener( 0 ),
|
|
|
|
aName( rString )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-01-28 19:59:54 +01:00
|
|
|
xOLERef.Lock( true );
|
2006-10-13 10:09:11 +00:00
|
|
|
xOLERef.SetViewAspect( nAspect );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwOLEObj::~SwOLEObj()
|
|
|
|
{
|
2004-11-26 15:26:56 +00:00
|
|
|
if( pListener )
|
|
|
|
{
|
|
|
|
if ( xOLERef.is() )
|
|
|
|
xOLERef->removeStateChangeListener( pListener );
|
|
|
|
pListener->Release();
|
|
|
|
}
|
2004-10-04 18:08:55 +00:00
|
|
|
|
2004-11-26 15:26:56 +00:00
|
|
|
if( pOLENd && !pOLENd->GetDoc()->IsInDtor() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-11-26 15:26:56 +00:00
|
|
|
// if the model is not currently in destruction it means that this object should be removed from the model
|
2005-05-11 11:01:44 +00:00
|
|
|
comphelper::EmbeddedObjectContainer* pCnt = xOLERef.GetContainer();
|
|
|
|
|
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2004-10-04 18:08:55 +00:00
|
|
|
SfxObjectShell* p = pOLENd->GetDoc()->GetPersist();
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE( p, "No document!" );
|
2004-11-26 15:26:56 +00:00
|
|
|
if( p )
|
2004-10-04 18:08:55 +00:00
|
|
|
{
|
|
|
|
comphelper::EmbeddedObjectContainer& rCnt = p->GetEmbeddedObjectContainer();
|
2005-05-11 11:01:44 +00:00
|
|
|
OSL_ENSURE( !pCnt || &rCnt == pCnt, "The helper is assigned to unexpected container!\n" );
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-04 07:20:55 +00:00
|
|
|
|
2005-05-11 11:01:44 +00:00
|
|
|
if ( pCnt && pCnt->HasEmbeddedObject( aName ) )
|
|
|
|
{
|
|
|
|
uno::Reference < container::XChild > xChild( xOLERef.GetObject(), uno::UNO_QUERY );
|
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent( 0 );
|
2004-11-26 15:26:56 +00:00
|
|
|
|
2005-05-11 11:01:44 +00:00
|
|
|
// not already removed by deleting the object
|
|
|
|
xOLERef.AssignToContainer( 0, aName );
|
|
|
|
|
|
|
|
// unlock object so that object can be closed in RemoveEmbeddedObject
|
|
|
|
// successful closing of the object will automatically clear the reference then
|
2014-01-28 19:59:54 +01:00
|
|
|
xOLERef.Lock(false);
|
2005-05-11 11:01:44 +00:00
|
|
|
|
2013-12-09 19:13:36 +05:30
|
|
|
// Always remove object from container it is connected to
|
2006-07-19 08:35:46 +00:00
|
|
|
try
|
|
|
|
{
|
2013-12-09 19:13:36 +05:30
|
|
|
// remove object from container but don't close it
|
2014-02-16 22:51:15 +01:00
|
|
|
pCnt->RemoveEmbeddedObject( aName, false);
|
2006-07-19 08:35:46 +00:00
|
|
|
}
|
|
|
|
catch ( uno::Exception& )
|
|
|
|
{
|
|
|
|
}
|
2004-10-04 18:08:55 +00:00
|
|
|
}
|
2005-05-11 11:01:44 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2004-11-26 15:26:56 +00:00
|
|
|
if ( xOLERef.is() )
|
|
|
|
// in case the object wasn't closed: release it
|
|
|
|
// in case the object was not in the container: it's still locked, try to close
|
|
|
|
xOLERef.Clear();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwOLEObj::SetNode( SwOLENode* pNode )
|
|
|
|
{
|
|
|
|
pOLENd = pNode;
|
2013-08-17 11:47:04 +02:00
|
|
|
if ( aName.isEmpty() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwDoc* pDoc = pNode->GetDoc();
|
|
|
|
|
2014-10-06 10:12:46 +02:00
|
|
|
// If there's already a SvPersist instance, we use it
|
2004-10-04 18:08:55 +00:00
|
|
|
SfxObjectShell* p = pDoc->GetPersist();
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !p )
|
|
|
|
{
|
2014-10-06 10:12:46 +02:00
|
|
|
// TODO/LATER: Isn't a EmbeddedObjectContainer sufficient here?
|
|
|
|
// What happens to the document?
|
|
|
|
OSL_ENSURE( false, "Why are we creating a DocShell here??" );
|
2015-04-09 15:24:21 +02:00
|
|
|
p = new SwDocShell( pDoc, SfxObjectCreateMode::INTERNAL );
|
2000-09-18 23:08:29 +00:00
|
|
|
p->DoInitNew( NULL );
|
|
|
|
}
|
2004-10-04 18:08:55 +00:00
|
|
|
|
2013-03-01 13:50:58 +01:00
|
|
|
OUString aObjName;
|
2005-04-04 07:20:55 +00:00
|
|
|
uno::Reference < container::XChild > xChild( xOLERef.GetObject(), uno::UNO_QUERY );
|
|
|
|
if ( xChild.is() && xChild->getParent() != p->GetModel() )
|
|
|
|
// it is possible that the parent was set already
|
|
|
|
xChild->setParent( p->GetModel() );
|
2004-10-04 18:08:55 +00:00
|
|
|
if (!p->GetEmbeddedObjectContainer().InsertEmbeddedObject( xOLERef.GetObject(), aObjName ) )
|
2001-08-16 09:39:18 +00:00
|
|
|
{
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL( "InsertObject failed" );
|
2005-04-04 07:20:55 +00:00
|
|
|
if ( xChild.is() )
|
|
|
|
xChild->setParent( 0 );
|
2001-08-16 09:39:18 +00:00
|
|
|
}
|
2004-10-04 18:08:55 +00:00
|
|
|
else
|
|
|
|
xOLERef.AssignToContainer( &p->GetEmbeddedObjectContainer(), aObjName );
|
|
|
|
|
2015-03-26 15:31:55 +01:00
|
|
|
const_cast<SwOLENode*>(pOLENd)->CheckFileLink_Impl(); // for this notification nonconst access is required
|
2005-01-18 13:58:11 +00:00
|
|
|
|
2004-10-04 18:08:55 +00:00
|
|
|
aName = aObjName;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-29 13:03:27 +00:00
|
|
|
OUString SwOLEObj::GetStyleString()
|
|
|
|
{
|
|
|
|
OUString strStyle;
|
|
|
|
if (xOLERef.is() && xOLERef.IsChart())
|
|
|
|
strStyle = xOLERef.GetChartType();
|
|
|
|
return strStyle;
|
|
|
|
}
|
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool SwOLEObj::IsOleRef() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-10-04 18:08:55 +00:00
|
|
|
return xOLERef.is();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2010-11-03 15:50:00 +01:00
|
|
|
const uno::Reference < embed::XEmbeddedObject > SwOLEObj::GetOleRef()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-10-04 18:08:55 +00:00
|
|
|
if( !xOLERef.is() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-10-04 18:08:55 +00:00
|
|
|
SfxObjectShell* p = pOLENd->GetDoc()->GetPersist();
|
2014-10-06 10:12:46 +02:00
|
|
|
OSL_ENSURE( p, "No SvPersist present" );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2004-10-04 18:08:55 +00:00
|
|
|
uno::Reference < embed::XEmbeddedObject > xObj = p->GetEmbeddedObjectContainer().GetEmbeddedObject( aName );
|
2014-10-06 10:12:46 +02:00
|
|
|
OSL_ENSURE( !xOLERef.is(), "Calling GetOleRef() recursively is not permitted" );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2004-10-04 18:08:55 +00:00
|
|
|
if ( !xObj.is() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-10-06 10:12:46 +02:00
|
|
|
// We could not load this part (probably broken)
|
2000-09-18 23:08:29 +00:00
|
|
|
Rectangle aArea;
|
2010-06-13 15:22:56 +02:00
|
|
|
SwFrm *pFrm = pOLENd->getLayoutFrm(0);
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( pFrm )
|
|
|
|
{
|
|
|
|
Size aSz( pFrm->Frm().SSize() );
|
|
|
|
const MapMode aSrc ( MAP_TWIP );
|
|
|
|
const MapMode aDest( MAP_100TH_MM );
|
|
|
|
aSz = OutputDevice::LogicToLogic( aSz, aSrc, aDest );
|
|
|
|
aArea.SetSize( aSz );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aArea.SetSize( Size( 5000, 5000 ) );
|
2004-10-04 18:08:55 +00:00
|
|
|
// TODO/LATER: set replacement graphic for dead object
|
|
|
|
// It looks as if it should work even without the object, because the replace will be generated automatically
|
2013-03-01 13:50:58 +01:00
|
|
|
OUString aTmpName;
|
2007-09-27 08:08:33 +00:00
|
|
|
xObj = p->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_DUMMY_CLASSID ).GetByteSequence(), aTmpName );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2005-03-29 13:49:32 +00:00
|
|
|
// else
|
2004-10-04 18:08:55 +00:00
|
|
|
{
|
|
|
|
xOLERef.Assign( xObj, xOLERef.GetViewAspect() );
|
|
|
|
xOLERef.AssignToContainer( &p->GetEmbeddedObjectContainer(), aName );
|
2004-11-26 15:26:56 +00:00
|
|
|
pListener = new SwOLEListener_Impl( this );
|
|
|
|
pListener->acquire();
|
|
|
|
xObj->addStateChangeListener( pListener );
|
2004-10-04 18:08:55 +00:00
|
|
|
}
|
2005-01-18 13:58:11 +00:00
|
|
|
|
2015-03-26 15:31:55 +01:00
|
|
|
const_cast<SwOLENode*>(pOLENd)->CheckFileLink_Impl(); // for this notification nonconst access is required
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2004-11-26 15:26:56 +00:00
|
|
|
else if ( xOLERef->getCurrentState() == embed::EmbedStates::RUNNING )
|
|
|
|
{
|
|
|
|
// move object to first position in cache
|
|
|
|
if( !pOLELRU_Cache )
|
|
|
|
pOLELRU_Cache = new SwOLELRUCache;
|
2007-09-27 08:08:33 +00:00
|
|
|
pOLELRU_Cache->InsertObj( *this );
|
2004-11-26 15:26:56 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2004-10-04 18:08:55 +00:00
|
|
|
return xOLERef.GetObject();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2004-10-04 18:08:55 +00:00
|
|
|
svt::EmbeddedObjectRef& SwOLEObj::GetObject()
|
|
|
|
{
|
|
|
|
GetOleRef();
|
|
|
|
return xOLERef;
|
|
|
|
}
|
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool SwOLEObj::UnloadObject()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-04-25 14:00:35 +02:00
|
|
|
bool bRet = true;
|
2006-02-01 17:49:44 +00:00
|
|
|
if ( pOLENd )
|
|
|
|
{
|
|
|
|
const SwDoc* pDoc = pOLENd->GetDoc();
|
2006-10-13 10:09:11 +00:00
|
|
|
bRet = UnloadObject( xOLERef.GetObject(), pDoc, xOLERef.GetViewAspect() );
|
2006-02-01 17:49:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool SwOLEObj::UnloadObject( uno::Reference< embed::XEmbeddedObject > xObj, const SwDoc* pDoc, sal_Int64 nAspect )
|
2006-02-01 17:49:44 +00:00
|
|
|
{
|
|
|
|
if ( !pDoc )
|
2014-04-25 14:00:35 +02:00
|
|
|
return false;
|
2006-02-01 17:49:44 +00:00
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool bRet = true;
|
2006-02-01 17:49:44 +00:00
|
|
|
sal_Int32 nState = xObj.is() ? xObj->getCurrentState() : embed::EmbedStates::LOADED;
|
2012-11-30 08:49:55 +09:00
|
|
|
bool bIsActive = ( nState != embed::EmbedStates::LOADED && nState != embed::EmbedStates::RUNNING );
|
2006-02-01 17:49:44 +00:00
|
|
|
sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
|
|
|
|
|
|
|
|
if( nState != embed::EmbedStates::LOADED && !pDoc->IsInDtor() && !bIsActive &&
|
|
|
|
embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
|
|
|
|
embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-10-04 18:08:55 +00:00
|
|
|
SfxObjectShell* p = pDoc->GetPersist();
|
2000-09-18 23:08:29 +00:00
|
|
|
if( p )
|
|
|
|
{
|
2015-03-11 15:04:54 +02:00
|
|
|
if( pDoc->GetDocumentSettingManager().get(DocumentSettingId::PURGE_OLE) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-11-26 15:26:56 +00:00
|
|
|
try
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2006-02-01 17:49:44 +00:00
|
|
|
uno::Reference < util::XModifiable > xMod( xObj->getComponent(), uno::UNO_QUERY );
|
2004-11-26 15:26:56 +00:00
|
|
|
if( xMod.is() && xMod->isModified() )
|
2004-10-04 18:08:55 +00:00
|
|
|
{
|
2006-02-01 17:49:44 +00:00
|
|
|
uno::Reference < embed::XEmbedPersist > xPers( xObj, uno::UNO_QUERY );
|
2004-11-26 15:26:56 +00:00
|
|
|
if ( xPers.is() )
|
|
|
|
xPers->storeOwn();
|
2008-04-22 14:00:08 +00:00
|
|
|
else {
|
2014-03-29 18:15:35 +01:00
|
|
|
OSL_FAIL("Modified object without persistence in cache!");
|
2008-04-22 14:00:08 +00:00
|
|
|
}
|
2004-10-04 18:08:55 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2004-11-26 15:26:56 +00:00
|
|
|
// setting object to loaded state will remove it from cache
|
2006-02-01 17:49:44 +00:00
|
|
|
xObj->changeState( embed::EmbedStates::LOADED );
|
2004-11-26 15:26:56 +00:00
|
|
|
}
|
|
|
|
catch ( uno::Exception& )
|
|
|
|
{
|
2014-04-25 14:00:35 +02:00
|
|
|
bRet = false;
|
2004-11-26 15:26:56 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
2014-04-25 14:00:35 +02:00
|
|
|
bRet = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-26 15:26:56 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2013-08-17 11:47:04 +02:00
|
|
|
OUString SwOLEObj::GetDescription()
|
2004-09-08 13:56:58 +00:00
|
|
|
{
|
2004-10-04 18:08:55 +00:00
|
|
|
uno::Reference< embed::XEmbeddedObject > xEmbObj = GetOleRef();
|
2013-08-17 11:47:04 +02:00
|
|
|
if ( !xEmbObj.is() )
|
|
|
|
return OUString();
|
|
|
|
|
|
|
|
SvGlobalName aClassID( xEmbObj->getClassID() );
|
|
|
|
if ( SotExchange::IsMath( aClassID ) )
|
|
|
|
return SW_RESSTR(STR_MATH_FORMULA);
|
|
|
|
|
|
|
|
if ( SotExchange::IsChart( aClassID ) )
|
|
|
|
return SW_RESSTR(STR_CHART);
|
2004-09-08 13:56:58 +00:00
|
|
|
|
2013-08-17 11:47:04 +02:00
|
|
|
return SW_RESSTR(STR_OLE);
|
2004-09-08 13:56:58 +00:00
|
|
|
}
|
|
|
|
|
2000-12-18 10:16:07 +00:00
|
|
|
SwOLELRUCache::SwOLELRUCache()
|
2012-06-25 18:53:01 +02:00
|
|
|
: utl::ConfigItem(OUString("Office.Common/Cache"))
|
|
|
|
, m_nLRU_InitSize( 20 )
|
2000-12-18 10:16:07 +00:00
|
|
|
{
|
|
|
|
EnableNotification( GetPropertyNames() );
|
|
|
|
Load();
|
|
|
|
}
|
|
|
|
|
2013-03-01 13:50:58 +01:00
|
|
|
uno::Sequence< OUString > SwOLELRUCache::GetPropertyNames()
|
2000-12-18 10:16:07 +00:00
|
|
|
{
|
|
|
|
Sequence< OUString > aNames( 1 );
|
|
|
|
OUString* pNames = aNames.getArray();
|
2013-10-31 17:16:50 +02:00
|
|
|
pNames[0] = "Writer/OLE_Objects";
|
2000-12-18 10:16:07 +00:00
|
|
|
return aNames;
|
|
|
|
}
|
|
|
|
|
2013-03-01 13:50:58 +01:00
|
|
|
void SwOLELRUCache::Notify( const uno::Sequence< OUString>& )
|
2000-12-18 10:16:07 +00:00
|
|
|
{
|
|
|
|
Load();
|
|
|
|
}
|
|
|
|
|
2015-03-11 16:14:47 +01:00
|
|
|
void SwOLELRUCache::ImplCommit()
|
2000-12-18 10:16:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwOLELRUCache::Load()
|
|
|
|
{
|
|
|
|
Sequence< OUString > aNames( GetPropertyNames() );
|
|
|
|
Sequence< Any > aValues = GetProperties( aNames );
|
|
|
|
const Any* pValues = aValues.getConstArray();
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
|
2004-11-26 15:26:56 +00:00
|
|
|
if( aValues.getLength() == aNames.getLength() && pValues->hasValue() )
|
2000-12-18 10:16:07 +00:00
|
|
|
{
|
2007-11-12 15:25:50 +00:00
|
|
|
sal_Int32 nVal = 0;
|
2000-12-18 10:16:07 +00:00
|
|
|
*pValues >>= nVal;
|
|
|
|
|
|
|
|
{
|
2012-06-25 18:53:01 +02:00
|
|
|
if (nVal < m_nLRU_InitSize)
|
2000-12-18 10:16:07 +00:00
|
|
|
{
|
2004-11-26 15:26:56 +00:00
|
|
|
// size of cache has been changed
|
2012-06-25 18:53:01 +02:00
|
|
|
sal_Int32 nCount = m_OleObjects.size();
|
|
|
|
sal_Int32 nPos = nCount;
|
2004-11-26 15:26:56 +00:00
|
|
|
|
|
|
|
// try to remove the last entries until new maximum size is reached
|
|
|
|
while( nCount > nVal )
|
2001-12-12 13:30:50 +00:00
|
|
|
{
|
2012-06-25 18:53:01 +02:00
|
|
|
SwOLEObj *const pObj = m_OleObjects[ --nPos ];
|
2004-11-26 15:26:56 +00:00
|
|
|
if ( pObj->UnloadObject() )
|
|
|
|
nCount--;
|
|
|
|
if ( !nPos )
|
|
|
|
break;
|
2001-12-12 13:30:50 +00:00
|
|
|
}
|
2000-12-18 10:16:07 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-26 15:26:56 +00:00
|
|
|
|
2012-06-25 18:53:01 +02:00
|
|
|
m_nLRU_InitSize = nVal;
|
2000-12-18 10:16:07 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2007-09-27 08:08:33 +00:00
|
|
|
void SwOLELRUCache::InsertObj( SwOLEObj& rObj )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-11-26 15:26:56 +00:00
|
|
|
SwOLEObj* pObj = &rObj;
|
2012-06-25 18:53:01 +02:00
|
|
|
OleObjects_t::iterator it =
|
|
|
|
std::find(m_OleObjects.begin(), m_OleObjects.end(), pObj);
|
|
|
|
if (it != m_OleObjects.end() && it != m_OleObjects.begin())
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-06-25 18:53:01 +02:00
|
|
|
// object in cache but is currently not the first in cache
|
|
|
|
m_OleObjects.erase(it);
|
|
|
|
it = m_OleObjects.end();
|
|
|
|
}
|
|
|
|
if (it == m_OleObjects.end())
|
|
|
|
{
|
|
|
|
// try to remove objects if necessary
|
|
|
|
sal_Int32 nCount = m_OleObjects.size();
|
|
|
|
sal_Int32 nPos = nCount-1;
|
tdf#67421: Prevent unloading objects due to cache full
When an object is added to OLE objects cache, when cache is full,
old objects are tried to be unloaded. This triggers notifications
that cause all loaded objects to become active, and to be added to
cache (moved to front).
As the new object already was added to front of the cache, later
activity pushes it to back, until it is the last object in cache.
The cache in this process is overfilled, so each next refresh tries
to unload current last OLE object. So, in the end, this effectively
unloads all cached OLE objects.
This patch prevents this by first unloading last object, and then
adding new object to front of cache.
Also, removed needless creation of reference (makes at least 200
function calls for no reason).
Change-Id: Ia903f4df101971df1b0b0148320fc8e45ac1e79c
Reviewed-on: https://gerrit.libreoffice.org/15772
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
2015-05-18 00:03:41 +10:00
|
|
|
while (nPos >= 0 && nCount >= m_nLRU_InitSize)
|
2004-11-26 15:26:56 +00:00
|
|
|
{
|
2012-06-25 18:53:01 +02:00
|
|
|
pObj = m_OleObjects[ nPos-- ];
|
2004-11-26 15:26:56 +00:00
|
|
|
if ( pObj->UnloadObject() )
|
|
|
|
nCount--;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
tdf#67421: Prevent unloading objects due to cache full
When an object is added to OLE objects cache, when cache is full,
old objects are tried to be unloaded. This triggers notifications
that cause all loaded objects to become active, and to be added to
cache (moved to front).
As the new object already was added to front of the cache, later
activity pushes it to back, until it is the last object in cache.
The cache in this process is overfilled, so each next refresh tries
to unload current last OLE object. So, in the end, this effectively
unloads all cached OLE objects.
This patch prevents this by first unloading last object, and then
adding new object to front of cache.
Also, removed needless creation of reference (makes at least 200
function calls for no reason).
Change-Id: Ia903f4df101971df1b0b0148320fc8e45ac1e79c
Reviewed-on: https://gerrit.libreoffice.org/15772
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
2015-05-18 00:03:41 +10:00
|
|
|
m_OleObjects.push_front(&rObj);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-27 08:08:33 +00:00
|
|
|
void SwOLELRUCache::RemoveObj( SwOLEObj& rObj )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-06-25 18:53:01 +02:00
|
|
|
OleObjects_t::iterator const it =
|
|
|
|
std::find(m_OleObjects.begin(), m_OleObjects.end(), &rObj);
|
|
|
|
if (it != m_OleObjects.end())
|
|
|
|
{
|
|
|
|
m_OleObjects.erase(it);
|
|
|
|
}
|
|
|
|
if (m_OleObjects.empty())
|
|
|
|
{
|
2004-11-26 15:26:56 +00:00
|
|
|
DELETEZ( pOLELRU_Cache );
|
2012-06-25 18:53:01 +02:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|