2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 23:34:33 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 23:34:33 +00:00
|
|
|
* $RCSfile: svdoole2.cxx,v $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2007-05-22 14:20:35 +00:00
|
|
|
* $Revision: 1.78 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2007-05-22 14:20:35 +00:00
|
|
|
* last change: $Author: vg $ $Date: 2007-05-22 15:20:35 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 23:34:33 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 23:34:33 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 23:34:33 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 23:34:33 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 23:34:33 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 04:56:07 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_svx.hxx"
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
#include "svdoole2.hxx"
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XMODIFYBROADCASTER_HPP_
|
|
|
|
#include <com/sun/star/util/XModifyBroadcaster.hpp>
|
|
|
|
#endif
|
2004-10-04 16:54:47 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XMODIFIABLE_HPP_
|
|
|
|
#include <com/sun/star/util/XModifiable.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
2004-10-04 16:54:47 +00:00
|
|
|
#ifndef _COM_SUN_STAR_EMBED_EMBEDSTATES_HPP_
|
|
|
|
#include <com/sun/star/embed/EmbedStates.hpp>
|
2001-09-18 09:47:27 +00:00
|
|
|
#endif
|
2004-10-04 16:54:47 +00:00
|
|
|
#ifndef _COM_SUN_STAR_EMBED_ELEMENTMODE_HPP_
|
|
|
|
#include <com/sun/star/embed/ElementModes.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
2004-10-04 16:54:47 +00:00
|
|
|
#ifndef _COM_SUN_STAR_EMBED_EMBEDMISC_HPP_
|
|
|
|
#include <com/sun/star/embed/EmbedMisc.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_EMBED_ASPECTS_HPP_
|
|
|
|
#include <com/sun/star/embed/Aspects.hpp>
|
|
|
|
#endif
|
2005-01-18 14:01:22 +00:00
|
|
|
#ifndef _COM_SUN_STAR_EMBED_XLINKAGESUPPORT_HPP_
|
|
|
|
#include <com/sun/star/embed/XLinkageSupport.hpp>
|
|
|
|
#endif
|
2005-03-15 10:31:56 +00:00
|
|
|
#ifndef _COM_SUN_STAR_EMBED_NOVISUALAREASIZEEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
|
|
|
|
#endif
|
2004-10-04 16:54:47 +00:00
|
|
|
#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTLISTENER_HPP_
|
|
|
|
#include <com/sun/star/document/XEventListener.hpp>
|
|
|
|
#endif
|
2005-11-10 15:42:56 +00:00
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
|
|
|
|
#include <com/sun/star/container/XChild.hpp>
|
|
|
|
#endif
|
2004-10-04 16:54:47 +00:00
|
|
|
|
|
|
|
#include <comphelper/processfactory.hxx>
|
2005-02-24 14:11:49 +00:00
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
2004-10-04 16:54:47 +00:00
|
|
|
#include <unotools/ucbstreamhelper.hxx>
|
|
|
|
#include <svtools/filter.hxx>
|
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
|
|
|
#include <svtools/embedhlp.hxx>
|
|
|
|
|
|
|
|
#include <sfx2/objsh.hxx>
|
|
|
|
#include <sfx2/ipclient.hxx>
|
2005-01-18 14:01:22 +00:00
|
|
|
#include <sfx2/lnkbase.hxx>
|
2004-10-04 16:54:47 +00:00
|
|
|
#include <tools/stream.hxx>
|
2005-02-24 14:11:49 +00:00
|
|
|
#include <comphelper/anytostring.hxx>
|
2004-10-04 16:54:47 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef _SVDPAGV_HXX
|
|
|
|
#include <svdpagv.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _GLOBNAME_HXX
|
|
|
|
#include <tools/globname.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_JOBSET_HXX
|
|
|
|
#include <vcl/jobset.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SO_CLSIDS_HXX
|
2004-10-04 16:54:47 +00:00
|
|
|
#include <sot/clsids.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#endif
|
|
|
|
|
2001-03-08 20:28:23 +00:00
|
|
|
#include <sot/formats.hxx>
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef _SVXLINKMGR_HXX //autogen
|
|
|
|
#include <linkmgr.hxx>
|
|
|
|
#endif
|
2001-06-22 14:46:24 +00:00
|
|
|
#ifndef SVTOOLS_TRANSFER_HXX
|
|
|
|
#include <svtools/transfer.hxx>
|
|
|
|
#endif
|
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
#include <cppuhelper/implbase3.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include <svtools/solar.hrc>
|
|
|
|
#include "svdxout.hxx"
|
|
|
|
#ifndef SVTOOLS_URIHELPER_HXX
|
|
|
|
#include <svtools/urihelper.hxx>
|
|
|
|
#endif
|
|
|
|
|
2006-11-14 12:46:22 +00:00
|
|
|
#ifndef _VOS_MUTEX_HXX_
|
|
|
|
#include <vos/mutex.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_SVAPP_HXX //autogen
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "svdpagv.hxx"
|
|
|
|
#include "svdmodel.hxx"
|
|
|
|
#include "svdglob.hxx" // Stringcache
|
|
|
|
#include "svdstr.hrc" // Objektname
|
|
|
|
#include "svdetc.hxx"
|
|
|
|
#include "svdview.hxx"
|
|
|
|
#include "unomlstr.hxx"
|
2004-10-04 16:54:47 +00:00
|
|
|
#include "impgrf.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
using namespace ::rtl;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
class SdrLightEmbeddedClient_Impl : public ::cppu::WeakImplHelper3
|
|
|
|
< embed::XStateChangeListener
|
|
|
|
, document::XEventListener
|
|
|
|
, embed::XEmbeddedClient >
|
2004-11-26 15:33:16 +00:00
|
|
|
{
|
|
|
|
SdrOle2Obj* mpObj;
|
2006-10-13 10:23:44 +00:00
|
|
|
|
|
|
|
Fraction m_aScaleWidth;
|
|
|
|
Fraction m_aScaleHeight;
|
|
|
|
|
|
|
|
|
2004-11-26 15:33:16 +00:00
|
|
|
public:
|
2006-10-13 10:23:44 +00:00
|
|
|
SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj );
|
2004-11-26 15:33:16 +00:00
|
|
|
void Release();
|
2006-10-13 10:23:44 +00:00
|
|
|
|
|
|
|
void SetSizeScale( const Fraction& aScaleWidth, const Fraction& aScaleHeight )
|
|
|
|
{
|
|
|
|
m_aScaleWidth = aScaleWidth;
|
|
|
|
m_aScaleHeight = aScaleHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
Fraction GetScaleWidth() { return m_aScaleWidth; }
|
|
|
|
Fraction GetScaleHeight() { return m_aScaleHeight; }
|
|
|
|
|
|
|
|
// XStateChangeListener
|
2004-11-26 15:33:16 +00:00
|
|
|
virtual void SAL_CALL changingState( const ::com::sun::star::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::embed::WrongStateException, ::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual void SAL_CALL stateChanged( const ::com::sun::star::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::uno::RuntimeException);
|
|
|
|
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
|
2006-10-13 10:23:44 +00:00
|
|
|
|
|
|
|
// document::XEventListener
|
|
|
|
virtual void SAL_CALL notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException );
|
|
|
|
|
|
|
|
// XEmbeddedClient
|
|
|
|
virtual void SAL_CALL saveObject() throw ( embed::ObjectSaveVetoException, uno::Exception, uno::RuntimeException );
|
|
|
|
virtual void SAL_CALL visibilityChanged( sal_Bool bVisible ) throw ( embed::WrongStateException, uno::RuntimeException );
|
|
|
|
|
|
|
|
// XComponentSupplier
|
|
|
|
virtual uno::Reference< util::XCloseable > SAL_CALL getComponent() throw ( uno::RuntimeException );
|
2004-11-26 15:33:16 +00:00
|
|
|
};
|
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
SdrLightEmbeddedClient_Impl::SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj )
|
2004-11-26 15:33:16 +00:00
|
|
|
: mpObj( pObj )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL SdrLightEmbeddedClient_Impl::changingState( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 /*nOldState*/, ::sal_Int32 /*nNewState*/ ) throw (::com::sun::star::embed::WrongStateException, ::com::sun::star::uno::RuntimeException)
|
2004-11-26 15:33:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SdrLightEmbeddedClient_Impl::Release()
|
2004-11-26 15:33:16 +00:00
|
|
|
{
|
2006-10-13 10:23:44 +00:00
|
|
|
{
|
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
mpObj = NULL;
|
|
|
|
}
|
|
|
|
|
2004-11-26 15:33:16 +00:00
|
|
|
release();
|
|
|
|
}
|
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL SdrLightEmbeddedClient_Impl::stateChanged( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::uno::RuntimeException)
|
2004-11-26 15:33:16 +00:00
|
|
|
{
|
2006-10-13 10:23:44 +00:00
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
2004-11-26 15:33:16 +00:00
|
|
|
if ( mpObj && nOldState == embed::EmbedStates::LOADED && nNewState == embed::EmbedStates::RUNNING )
|
|
|
|
{
|
|
|
|
mpObj->ObjectLoaded();
|
|
|
|
GetSdrGlobalData().GetOLEObjCache().InsertObj(mpObj);
|
|
|
|
}
|
|
|
|
else if ( mpObj && nNewState == embed::EmbedStates::LOADED && nOldState == embed::EmbedStates::RUNNING )
|
|
|
|
{
|
|
|
|
GetSdrGlobalData().GetOLEObjCache().RemoveObj(mpObj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL SdrLightEmbeddedClient_Impl::disposing( const ::com::sun::star::lang::EventObject& /*aEvent*/ ) throw (::com::sun::star::uno::RuntimeException)
|
2004-11-26 15:33:16 +00:00
|
|
|
{
|
2006-10-13 10:23:44 +00:00
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
2004-11-26 15:33:16 +00:00
|
|
|
GetSdrGlobalData().GetOLEObjCache().RemoveObj(mpObj);
|
|
|
|
}
|
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL SdrLightEmbeddedClient_Impl::notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException )
|
|
|
|
{
|
|
|
|
// TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
|
|
|
|
|
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
|
|
|
// the code currently makes sence only in case there is no other client
|
|
|
|
if ( mpObj && mpObj->GetAspect() != embed::Aspects::MSOLE_ICON && aEvent.EventName.equalsAscii("OnVisAreaChanged")
|
|
|
|
&& mpObj->GetObjRef().is() && mpObj->GetObjRef()->getClientSite() == uno::Reference< embed::XEmbeddedClient >( this ) )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
MapUnit aContainerMapUnit( MAP_100TH_MM );
|
|
|
|
uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
|
|
|
|
if ( xParentVis.is() )
|
|
|
|
aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
|
|
|
|
|
|
|
|
MapUnit aObjMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpObj->GetObjRef()->getMapUnit( mpObj->GetAspect() ) );
|
|
|
|
|
|
|
|
Rectangle aVisArea;
|
|
|
|
awt::Size aSz;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
aSz = mpObj->GetObjRef()->getVisualAreaSize( mpObj->GetAspect() );
|
|
|
|
}
|
|
|
|
catch( embed::NoVisualAreaSizeException& )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( sal_False, "No visual area size!\n" );
|
|
|
|
aSz.Width = 5000;
|
|
|
|
aSz.Height = 5000;
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( sal_False, "Unexpected exception!\n" );
|
|
|
|
aSz.Width = 5000;
|
|
|
|
aSz.Height = 5000;
|
|
|
|
}
|
|
|
|
|
|
|
|
aVisArea.SetSize( Size( aSz.Width, aSz.Height ) );
|
|
|
|
aVisArea = OutputDevice::LogicToLogic( aVisArea, aObjMapUnit, aContainerMapUnit );
|
|
|
|
Rectangle aLogicRect( mpObj->GetLogicRect() );
|
|
|
|
Size aScaledSize( static_cast< long >( m_aScaleWidth * Fraction( aVisArea.GetWidth() ) ),
|
|
|
|
static_cast< long >( m_aScaleHeight * Fraction( aVisArea.GetHeight() ) ) );
|
|
|
|
|
|
|
|
// react to the change if the difference is bigger than one pixel
|
|
|
|
Size aPixelDiff =
|
|
|
|
Application::GetDefaultDevice()->LogicToPixel(
|
|
|
|
Size( aLogicRect.GetWidth() - aScaledSize.Width(),
|
|
|
|
aLogicRect.GetHeight() - aScaledSize.Height() ),
|
|
|
|
aContainerMapUnit );
|
|
|
|
if( aPixelDiff.Width() || aPixelDiff.Height() )
|
|
|
|
{
|
|
|
|
mpObj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aScaledSize ) );
|
|
|
|
mpObj->BroadcastObjectChange();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mpObj->ActionChanged();
|
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( sal_False, "Unexpected exception!\n" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL SdrLightEmbeddedClient_Impl::saveObject()
|
|
|
|
throw ( embed::ObjectSaveVetoException,
|
|
|
|
uno::Exception,
|
|
|
|
uno::RuntimeException )
|
|
|
|
{
|
|
|
|
// TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
|
|
|
|
uno::Reference< embed::XCommonEmbedPersist > xPersist;
|
|
|
|
uno::Reference< util::XModifiable > xModifiable;
|
|
|
|
|
|
|
|
{
|
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
|
|
|
|
if ( !mpObj )
|
|
|
|
throw embed::ObjectSaveVetoException();
|
|
|
|
|
|
|
|
// the common persistance is supported by objects and links
|
|
|
|
xPersist = uno::Reference< embed::XCommonEmbedPersist >( mpObj->GetObjRef(), uno::UNO_QUERY_THROW );
|
|
|
|
xModifiable = uno::Reference< util::XModifiable >( mpObj->GetParentXModel(), uno::UNO_QUERY );
|
|
|
|
}
|
|
|
|
|
|
|
|
xPersist->storeOwn();
|
|
|
|
|
|
|
|
if ( xModifiable.is() )
|
|
|
|
xModifiable->setModified( sal_True );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL SdrLightEmbeddedClient_Impl::visibilityChanged( sal_Bool /*bVisible*/ )
|
|
|
|
throw ( embed::WrongStateException,
|
|
|
|
uno::RuntimeException )
|
|
|
|
{
|
|
|
|
// nothing to do currently
|
|
|
|
// TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
uno::Reference< util::XCloseable > SAL_CALL SdrLightEmbeddedClient_Impl::getComponent()
|
|
|
|
throw ( uno::RuntimeException )
|
|
|
|
{
|
|
|
|
uno::Reference< util::XCloseable > xResult;
|
|
|
|
|
|
|
|
::vos::OGuard aGuard( Application::GetSolarMutex() );
|
|
|
|
if ( mpObj )
|
|
|
|
xResult = uno::Reference< util::XCloseable >( mpObj->GetParentXModel(), uno::UNO_QUERY );
|
|
|
|
|
|
|
|
return xResult;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2005-01-18 14:01:22 +00:00
|
|
|
class SdrEmbedObjectLink : public sfx2::SvBaseLink
|
|
|
|
{
|
|
|
|
SdrOle2Obj* pObj;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SdrEmbedObjectLink(SdrOle2Obj* pObj);
|
|
|
|
virtual ~SdrEmbedObjectLink();
|
|
|
|
|
|
|
|
virtual void Closed();
|
|
|
|
virtual void DataChanged( const String& rMimeType,
|
|
|
|
const ::com::sun::star::uno::Any & rValue );
|
|
|
|
|
|
|
|
sal_Bool Connect() { return GetRealObject() != NULL; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SdrEmbedObjectLink::SdrEmbedObjectLink(SdrOle2Obj* pObject):
|
|
|
|
::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, SOT_FORMATSTR_ID_SVXB ),
|
|
|
|
pObj(pObject)
|
|
|
|
{
|
|
|
|
SetSynchron( FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SdrEmbedObjectLink::~SdrEmbedObjectLink()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2006-06-19 15:43:13 +00:00
|
|
|
void SdrEmbedObjectLink::DataChanged( const String& /*rMimeType*/,
|
|
|
|
const ::com::sun::star::uno::Any & /*rValue*/ )
|
2005-01-18 14:01:22 +00:00
|
|
|
{
|
|
|
|
if ( !pObj->UpdateLinkURL_Impl() )
|
|
|
|
{
|
|
|
|
// the link URL was not changed
|
|
|
|
uno::Reference< embed::XEmbeddedObject > xObject = pObj->GetObjRef();
|
|
|
|
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();
|
|
|
|
if ( nState == embed::EmbedStates::LOADED )
|
|
|
|
xObject->changeState( embed::EmbedStates::RUNNING );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// 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& )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pObj->GetNewReplacement();
|
|
|
|
pObj->SetChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SdrEmbedObjectLink::Closed()
|
|
|
|
{
|
|
|
|
pObj->BreakFileLink_Impl();
|
|
|
|
SvBaseLink::Closed();
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-06-14 15:30:17 +00:00
|
|
|
class SdrOle2ObjImpl
|
|
|
|
{
|
|
|
|
public:
|
2004-10-04 16:54:47 +00:00
|
|
|
// TODO/LATER: do we really need this pointer?
|
2001-06-14 15:30:17 +00:00
|
|
|
GraphicObject* pGraphicObject;
|
2001-09-10 10:38:27 +00:00
|
|
|
String aPersistName; // name of object in persist
|
2006-10-13 10:23:44 +00:00
|
|
|
SdrLightEmbeddedClient_Impl* pLightClient; // must be registered as client only using AddOwnLightClient() call
|
2003-03-27 14:06:05 +00:00
|
|
|
|
|
|
|
// #107645#
|
|
|
|
// New local var to avoid repeated loading if load of OLE2 fails
|
|
|
|
sal_Bool mbLoadingOLEObjectFailed;
|
2005-01-18 14:01:22 +00:00
|
|
|
sal_Bool mbConnected;
|
|
|
|
|
|
|
|
SdrEmbedObjectLink* mpObjectLink;
|
|
|
|
String maLinkURL;
|
|
|
|
|
|
|
|
SdrOle2ObjImpl()
|
|
|
|
: pGraphicObject( NULL )
|
|
|
|
// #107645#
|
|
|
|
// init to start situation, loading did not fail
|
|
|
|
, mbLoadingOLEObjectFailed( sal_False )
|
|
|
|
, mbConnected( sal_False )
|
2005-03-03 16:34:09 +00:00
|
|
|
, mpObjectLink( NULL )
|
2005-01-18 14:01:22 +00:00
|
|
|
{
|
|
|
|
}
|
2001-06-14 15:30:17 +00:00
|
|
|
};
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2003-04-24 13:49:28 +00:00
|
|
|
// Predicate determining whether the given OLE is an internal math
|
|
|
|
// object
|
2004-10-04 16:54:47 +00:00
|
|
|
static bool ImplIsMathObj( const uno::Reference < embed::XEmbeddedObject >& rObjRef )
|
2003-04-24 13:49:28 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( !rObjRef.is() )
|
2003-04-24 13:49:28 +00:00
|
|
|
return false;
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
SvGlobalName aClassName( rObjRef->getClassID() );
|
2003-04-24 13:49:28 +00:00
|
|
|
if( aClassName == SvGlobalName(SO3_SM_CLASSID_30) ||
|
|
|
|
aClassName == SvGlobalName(SO3_SM_CLASSID_40) ||
|
|
|
|
aClassName == SvGlobalName(SO3_SM_CLASSID_50) ||
|
|
|
|
aClassName == SvGlobalName(SO3_SM_CLASSID_60) ||
|
|
|
|
aClassName == SvGlobalName(SO3_SM_CLASSID) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
TYPEINIT1(SdrOle2Obj,SdrRectObj);
|
|
|
|
|
|
|
|
SdrOle2Obj::SdrOle2Obj(FASTBOOL bFrame_)
|
|
|
|
{
|
2001-04-11 08:30:44 +00:00
|
|
|
bInDestruction = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
Init();
|
|
|
|
bFrame=bFrame_;
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2004-10-04 16:54:47 +00:00
|
|
|
SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, FASTBOOL bFrame_)
|
|
|
|
: xObjRef( rNewObjRef )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-04-11 08:30:44 +00:00
|
|
|
bInDestruction = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
Init();
|
|
|
|
|
|
|
|
bFrame=bFrame_;
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
SetResizeProtect(TRUE);
|
|
|
|
|
2003-04-24 13:49:28 +00:00
|
|
|
// #108759# For math objects, set closed state to transparent
|
2004-10-04 16:54:47 +00:00
|
|
|
if( ImplIsMathObj( xObjRef.GetObject() ) )
|
2003-04-24 13:49:28 +00:00
|
|
|
SetClosedObj( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, const XubString& rNewObjName, FASTBOOL bFrame_)
|
|
|
|
: xObjRef( rNewObjRef )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-04-11 08:30:44 +00:00
|
|
|
bInDestruction = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
Init();
|
|
|
|
|
2001-09-10 10:38:27 +00:00
|
|
|
mpImpl->aPersistName = rNewObjName;
|
2000-09-18 16:07:07 +00:00
|
|
|
bFrame=bFrame_;
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
SetResizeProtect(TRUE);
|
2003-04-24 13:49:28 +00:00
|
|
|
|
|
|
|
// #108759# For math objects, set closed state to transparent
|
2004-10-04 16:54:47 +00:00
|
|
|
if( ImplIsMathObj( xObjRef.GetObject() ) )
|
2003-04-24 13:49:28 +00:00
|
|
|
SetClosedObj( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, const XubString& rNewObjName, const Rectangle& rNewRect, FASTBOOL bFrame_)
|
|
|
|
: SdrRectObj(rNewRect)
|
|
|
|
, xObjRef( rNewObjRef )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-04-11 08:30:44 +00:00
|
|
|
bInDestruction = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
Init();
|
|
|
|
|
2001-09-10 10:38:27 +00:00
|
|
|
mpImpl->aPersistName = rNewObjName;
|
2000-09-18 16:07:07 +00:00
|
|
|
bFrame=bFrame_;
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
SetResizeProtect(TRUE);
|
2003-04-24 13:49:28 +00:00
|
|
|
|
|
|
|
// #108759# For math objects, set closed state to transparent
|
2004-10-04 16:54:47 +00:00
|
|
|
if( ImplIsMathObj( xObjRef.GetObject() ) )
|
2003-04-24 13:49:28 +00:00
|
|
|
SetClosedObj( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::Init()
|
|
|
|
{
|
2001-06-14 15:30:17 +00:00
|
|
|
mpImpl = new SdrOle2ObjImpl;
|
2000-09-18 16:07:07 +00:00
|
|
|
pModifyListener = NULL;
|
|
|
|
pGraphic=NULL;
|
2001-06-14 15:30:17 +00:00
|
|
|
mpImpl->pGraphicObject=NULL;
|
2006-10-13 10:23:44 +00:00
|
|
|
mpImpl->pLightClient = 0;
|
2003-03-27 14:06:05 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
xObjRef.Lock( TRUE );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SdrOle2Obj::~SdrOle2Obj()
|
|
|
|
{
|
2001-04-11 08:30:44 +00:00
|
|
|
bInDestruction = TRUE;
|
2003-04-24 15:45:53 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( mpImpl->mbConnected )
|
|
|
|
Disconnect();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if( pGraphic!=NULL )
|
2000-09-18 16:07:07 +00:00
|
|
|
delete pGraphic;
|
|
|
|
|
2001-06-14 15:30:17 +00:00
|
|
|
if(mpImpl->pGraphicObject!=NULL)
|
|
|
|
delete mpImpl->pGraphicObject;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if(pModifyListener)
|
|
|
|
{
|
|
|
|
pModifyListener->invalidate();
|
|
|
|
pModifyListener->release();
|
|
|
|
}
|
2004-11-26 15:33:16 +00:00
|
|
|
|
2005-01-18 14:01:22 +00:00
|
|
|
DisconnectFileLink_Impl();
|
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
if ( mpImpl->pLightClient )
|
|
|
|
{
|
|
|
|
mpImpl->pLightClient->Release();
|
|
|
|
mpImpl->pLightClient = NULL;
|
|
|
|
}
|
2004-11-26 15:33:16 +00:00
|
|
|
|
2001-06-14 15:30:17 +00:00
|
|
|
delete mpImpl;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SdrOle2Obj::SetAspect( sal_Int64 nAspect )
|
|
|
|
{
|
|
|
|
xObjRef.SetViewAspect( nAspect );
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
void SdrOle2Obj::SetGraphic_Impl(const Graphic* pGrf)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( pGraphic )
|
|
|
|
{
|
|
|
|
delete pGraphic;
|
|
|
|
pGraphic = NULL;
|
2001-06-14 15:30:17 +00:00
|
|
|
delete mpImpl->pGraphicObject;
|
|
|
|
mpImpl->pGraphicObject = NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pGrf!=NULL)
|
2001-06-14 15:30:17 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
pGraphic = new Graphic(*pGrf);
|
2001-06-14 15:30:17 +00:00
|
|
|
mpImpl->pGraphicObject = new GraphicObject( *pGraphic );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
SetChanged();
|
2003-11-24 15:57:52 +00:00
|
|
|
BroadcastObjectChange();
|
|
|
|
|
|
|
|
//if ( ppObjRef->Is() && pGrf )
|
|
|
|
// BroadcastObjectChange();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
void SdrOle2Obj::SetGraphic(const Graphic* pGrf)
|
|
|
|
{
|
|
|
|
// only for setting a preview graphic
|
|
|
|
SetGraphic_Impl( pGrf );
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
FASTBOOL SdrOle2Obj::IsEmpty() const
|
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
return !(xObjRef.is());
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2001-04-12 09:06:03 +00:00
|
|
|
void SdrOle2Obj::Connect()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-02-16 16:05:07 +00:00
|
|
|
if( IsEmptyPresObj() )
|
|
|
|
return;
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if( mpImpl->mbConnected )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-04-18 13:40:00 +00:00
|
|
|
// mba: currently there are situations where it seems to be unavoidable to have multiple connects
|
|
|
|
// changing this would need a larger code rewrite, so for now I remove the assertion
|
|
|
|
// DBG_ERROR("Connect() called on connected object!");
|
2004-10-04 16:54:47 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-04-12 09:06:03 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
Connect_Impl();
|
|
|
|
AddListeners_Impl();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-01-18 14:01:22 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool SdrOle2Obj::UpdateLinkURL_Impl()
|
|
|
|
{
|
|
|
|
sal_Bool bResult = sal_False;
|
|
|
|
|
|
|
|
if ( mpImpl->mpObjectLink )
|
|
|
|
{
|
|
|
|
SvxLinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : NULL;
|
|
|
|
if ( pLinkManager )
|
|
|
|
{
|
|
|
|
String aNewLinkURL;
|
|
|
|
pLinkManager->GetDisplayNames( mpImpl->mpObjectLink, 0, &aNewLinkURL, 0, 0 );
|
|
|
|
if ( !aNewLinkURL.EqualsIgnoreCaseAscii( mpImpl->maLinkURL ) )
|
|
|
|
{
|
|
|
|
const_cast<SdrOle2Obj*>(this)->GetObjRef_Impl();
|
|
|
|
uno::Reference< embed::XCommonEmbedPersist > xPersObj( xObjRef.GetObject(), uno::UNO_QUERY );
|
|
|
|
OSL_ENSURE( xPersObj.is(), "The object must exist!\n" );
|
|
|
|
if ( xPersObj.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sal_Int32 nCurState = xObjRef->getCurrentState();
|
|
|
|
if ( nCurState != embed::EmbedStates::LOADED )
|
|
|
|
xObjRef->changeState( embed::EmbedStates::LOADED );
|
|
|
|
|
|
|
|
// TODO/LATER: there should be possible to get current mediadescriptor settings from the object
|
|
|
|
uno::Sequence< beans::PropertyValue > aArgs( 1 );
|
|
|
|
aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
|
|
|
|
aArgs[0].Value <<= ::rtl::OUString( aNewLinkURL );
|
|
|
|
xPersObj->reload( aArgs, uno::Sequence< beans::PropertyValue >() );
|
|
|
|
|
|
|
|
mpImpl->maLinkURL = aNewLinkURL;
|
|
|
|
bResult = sal_True;
|
|
|
|
|
|
|
|
if ( nCurState != embed::EmbedStates::LOADED )
|
|
|
|
xObjRef->changeState( nCurState );
|
|
|
|
}
|
2005-02-24 14:11:49 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& e )
|
|
|
|
{
|
|
|
|
(void)e;
|
|
|
|
DBG_ERROR(
|
|
|
|
(OString("SdrOle2Obj::UpdateLinkURL_Impl(), "
|
|
|
|
"exception caught: ") +
|
|
|
|
rtl::OUStringToOString(
|
|
|
|
comphelper::anyToString( cppu::getCaughtException() ),
|
|
|
|
RTL_TEXTENCODING_UTF8 )).getStr() );
|
|
|
|
}
|
2005-01-18 14:01:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bResult )
|
|
|
|
{
|
|
|
|
// TODO/LATER: return the old name to the link manager, is it possible?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SdrOle2Obj::BreakFileLink_Impl()
|
|
|
|
{
|
|
|
|
|
|
|
|
SfxObjectShell* pPers = pModel ? pModel->GetPersist() : NULL;
|
|
|
|
|
|
|
|
if ( pPers )
|
|
|
|
{
|
|
|
|
uno::Reference< embed::XStorage > xStorage = pPers->GetStorage();
|
|
|
|
if ( xStorage.is() )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference< embed::XLinkageSupport > xLinkSupport( xObjRef.GetObject(), uno::UNO_QUERY_THROW );
|
|
|
|
xLinkSupport->breakLink( xStorage, mpImpl->aPersistName );
|
|
|
|
DisconnectFileLink_Impl();
|
|
|
|
mpImpl->maLinkURL = String();
|
|
|
|
}
|
2005-02-24 14:11:49 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& e )
|
2005-01-18 14:01:22 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
(void)e;
|
|
|
|
DBG_ERROR(
|
|
|
|
(OString("SdrOle2Obj::BreakFileLink_Impl(), "
|
|
|
|
"exception caught: ") +
|
|
|
|
rtl::OUStringToOString(
|
|
|
|
comphelper::anyToString( cppu::getCaughtException() ),
|
|
|
|
RTL_TEXTENCODING_UTF8 )).getStr() );
|
2005-01-18 14:01:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SdrOle2Obj::DisconnectFileLink_Impl()
|
|
|
|
{
|
|
|
|
SvxLinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : NULL;
|
|
|
|
if ( pLinkManager && mpImpl->mpObjectLink )
|
|
|
|
{
|
|
|
|
pLinkManager->Remove( mpImpl->mpObjectLink );
|
|
|
|
mpImpl->mpObjectLink = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SdrOle2Obj::CheckFileLink_Impl()
|
|
|
|
{
|
|
|
|
if ( pModel && xObjRef.GetObject().is() && !mpImpl->mpObjectLink )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2005-07-12 11:14:10 +00:00
|
|
|
uno::Reference< embed::XLinkageSupport > xLinkSupport( xObjRef.GetObject(), uno::UNO_QUERY );
|
|
|
|
if ( xLinkSupport.is() && xLinkSupport->isLink() )
|
2005-01-18 14:01:22 +00:00
|
|
|
{
|
|
|
|
String aLinkURL = xLinkSupport->getLinkURL();
|
|
|
|
if ( aLinkURL.Len() )
|
|
|
|
{
|
|
|
|
// this is a file link so the model link manager should handle it
|
|
|
|
SvxLinkManager* pLinkManager = pModel->GetLinkManager();
|
|
|
|
if ( pLinkManager )
|
|
|
|
{
|
|
|
|
mpImpl->mpObjectLink = new SdrEmbedObjectLink( this );
|
|
|
|
mpImpl->maLinkURL = aLinkURL;
|
|
|
|
pLinkManager->InsertFileLink( *mpImpl->mpObjectLink, OBJECT_CLIENT_OLE, aLinkURL, NULL, NULL );
|
|
|
|
mpImpl->mpObjectLink->Connect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-02-24 14:11:49 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& e )
|
2005-01-18 14:01:22 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
(void)e;
|
|
|
|
DBG_ERROR(
|
|
|
|
(OString("SdrOle2Obj::CheckFileLink_Impl(), "
|
|
|
|
"exception caught: ") +
|
|
|
|
rtl::OUStringToOString(
|
|
|
|
comphelper::anyToString( cppu::getCaughtException() ),
|
|
|
|
RTL_TEXTENCODING_UTF8 )).getStr() );
|
2005-01-18 14:01:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2004-11-26 15:33:16 +00:00
|
|
|
void SdrOle2Obj::Reconnect_Impl()
|
|
|
|
{
|
|
|
|
DBG_ASSERT( mpImpl->mbConnected, "Assigned unconnected object?!" );
|
|
|
|
Connect_Impl();
|
|
|
|
}
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
void SdrOle2Obj::Connect_Impl()
|
|
|
|
{
|
|
|
|
if( pModel && mpImpl->aPersistName.Len() )
|
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
try
|
2004-10-04 16:54:47 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
SfxObjectShell* pPers=pModel->GetPersist();
|
|
|
|
if ( pPers )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
comphelper::EmbeddedObjectContainer& rContainer = pPers->GetEmbeddedObjectContainer();
|
|
|
|
if ( !rContainer.HasEmbeddedObject( mpImpl->aPersistName ) )
|
2004-10-04 16:54:47 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
// object not known to container document
|
|
|
|
// No object -> disaster!
|
|
|
|
DBG_ASSERT( xObjRef.is(), "No object in connect!");
|
|
|
|
if ( xObjRef.is() )
|
|
|
|
{
|
|
|
|
// object came from the outside, now add it to the container
|
|
|
|
::rtl::OUString aTmp;
|
|
|
|
rContainer.InsertEmbeddedObject( xObjRef.GetObject(), aTmp );
|
|
|
|
mpImpl->aPersistName = aTmp;
|
|
|
|
}
|
2004-10-04 16:54:47 +00:00
|
|
|
}
|
2005-02-24 14:11:49 +00:00
|
|
|
else if ( !xObjRef.is() )
|
|
|
|
xObjRef.Assign( rContainer.GetEmbeddedObject( mpImpl->aPersistName ), xObjRef.GetViewAspect() );
|
2004-10-04 16:54:47 +00:00
|
|
|
|
2005-02-24 14:11:49 +00:00
|
|
|
if ( xObjRef.GetObject().is() )
|
|
|
|
{
|
|
|
|
xObjRef.AssignToContainer( &rContainer, mpImpl->aPersistName );
|
|
|
|
mpImpl->mbConnected = true;
|
|
|
|
xObjRef.Lock( TRUE );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2005-02-24 14:11:49 +00:00
|
|
|
if ( xObjRef.is() )
|
2004-11-26 15:33:16 +00:00
|
|
|
{
|
2006-10-13 10:23:44 +00:00
|
|
|
if ( !mpImpl->pLightClient )
|
2005-02-24 14:11:49 +00:00
|
|
|
{
|
2006-10-13 10:23:44 +00:00
|
|
|
mpImpl->pLightClient = new SdrLightEmbeddedClient_Impl( this );
|
|
|
|
mpImpl->pLightClient->acquire();
|
2005-02-24 14:11:49 +00:00
|
|
|
}
|
2004-11-26 15:33:16 +00:00
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
xObjRef->addStateChangeListener( mpImpl->pLightClient );
|
|
|
|
xObjRef->addEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
|
|
|
|
|
2005-02-24 14:11:49 +00:00
|
|
|
if ( xObjRef->getCurrentState() != embed::EmbedStates::LOADED )
|
|
|
|
GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
|
2005-01-18 14:01:22 +00:00
|
|
|
|
2005-02-24 14:11:49 +00:00
|
|
|
CheckFileLink_Impl();
|
2005-11-10 15:42:56 +00:00
|
|
|
|
|
|
|
uno::Reference< container::XChild > xChild( xObjRef.GetObject(), uno::UNO_QUERY );
|
|
|
|
if( xChild.is() )
|
2007-05-22 14:20:35 +00:00
|
|
|
{
|
|
|
|
uno::Reference< uno::XInterface > xParent( pModel->getUnoModel());
|
|
|
|
if( xParent.is())
|
|
|
|
xChild->setParent( pModel->getUnoModel() );
|
|
|
|
}
|
|
|
|
|
2005-02-24 14:11:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::uno::Exception& e )
|
|
|
|
{
|
|
|
|
(void)e;
|
|
|
|
DBG_ERROR(
|
|
|
|
(OString("SdrOle2Obj::Connect_Impl(), "
|
|
|
|
"exception caught: ") +
|
|
|
|
rtl::OUStringToOString(
|
|
|
|
comphelper::anyToString( cppu::getCaughtException() ),
|
|
|
|
RTL_TEXTENCODING_UTF8 )).getStr() );
|
2004-11-26 15:33:16 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
//TODO/LATER: wait for definition of MiscStatus RESIZEONPRINTERCHANGE
|
|
|
|
//if ( xObjRef.is() && (*ppObjRef)->GetMiscStatus() & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
//TODO/LATER: needs a new handling for OnPrinterChanged
|
|
|
|
/*
|
2000-09-18 16:07:07 +00:00
|
|
|
if (pModel && pModel->GetRefDevice() &&
|
|
|
|
pModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER)
|
|
|
|
{
|
|
|
|
// Kein RefDevice oder RefDevice kein Printer
|
|
|
|
BOOL bModified = (*ppObjRef)->IsModified();
|
|
|
|
Printer* pPrinter = (Printer*) pModel->GetRefDevice();
|
|
|
|
(*ppObjRef)->OnDocumentPrinterChanged( pPrinter );
|
|
|
|
(*ppObjRef)->SetModified( bModified );
|
2004-10-04 16:54:47 +00:00
|
|
|
}*/
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-10-04 16:54:47 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-11-26 15:33:16 +00:00
|
|
|
void SdrOle2Obj::ObjectLoaded()
|
|
|
|
{
|
|
|
|
AddListeners_Impl();
|
|
|
|
}
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
void SdrOle2Obj::AddListeners_Impl()
|
|
|
|
{
|
2004-11-26 15:33:16 +00:00
|
|
|
if( xObjRef.is() && xObjRef->getCurrentState() != embed::EmbedStates::LOADED )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
// register modify listener
|
2004-11-26 15:33:16 +00:00
|
|
|
if( !pModifyListener )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
((SdrOle2Obj*)this)->pModifyListener = new SvxUnoShapeModifyListener( (SdrOle2Obj*)this );
|
|
|
|
pModifyListener->acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
|
|
|
|
if( xBC.is() && pModifyListener )
|
|
|
|
{
|
|
|
|
uno::Reference< util::XModifyListener > xListener( pModifyListener );
|
|
|
|
xBC->addModifyListener( xListener );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2001-04-12 09:06:03 +00:00
|
|
|
void SdrOle2Obj::Disconnect()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-02-16 16:05:07 +00:00
|
|
|
if( IsEmptyPresObj() )
|
|
|
|
return;
|
|
|
|
|
2003-05-26 08:06:45 +00:00
|
|
|
if( !mpImpl->mbConnected )
|
2004-10-04 16:54:47 +00:00
|
|
|
{
|
2005-02-16 16:05:07 +00:00
|
|
|
DBG_ERROR("Disconnect() called on disconnected object!");
|
2003-05-26 08:06:45 +00:00
|
|
|
return;
|
2004-10-04 16:54:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RemoveListeners_Impl();
|
|
|
|
Disconnect_Impl();
|
|
|
|
}
|
2003-05-26 08:06:45 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
void SdrOle2Obj::RemoveListeners_Impl()
|
|
|
|
{
|
|
|
|
if( xObjRef.is() && mpImpl->aPersistName.Len() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
try
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
sal_Int32 nState = xObjRef->getCurrentState();
|
|
|
|
if ( nState != embed::EmbedStates::LOADED )
|
2004-10-04 16:54:47 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
|
|
|
|
if( xBC.is() && pModifyListener )
|
|
|
|
{
|
|
|
|
uno::Reference< util::XModifyListener > xListener( pModifyListener );
|
|
|
|
xBC->removeModifyListener( xListener );
|
|
|
|
}
|
2004-10-04 16:54:47 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2005-02-24 14:11:49 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& e )
|
|
|
|
{
|
|
|
|
(void)e;
|
|
|
|
DBG_ERROR(
|
|
|
|
(OString("SdrOle2Obj::RemoveListeners_Impl(), "
|
|
|
|
"exception caught: ") +
|
|
|
|
rtl::OUStringToOString(
|
|
|
|
comphelper::anyToString( cppu::getCaughtException() ),
|
|
|
|
RTL_TEXTENCODING_UTF8 )).getStr() );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-10-04 16:54:47 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
void SdrOle2Obj::Disconnect_Impl()
|
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
try
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
if ( pModel && mpImpl->aPersistName.Len() )
|
2003-04-24 15:45:53 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
if( pModel->IsInDestruction() )
|
2003-04-24 15:45:53 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
// TODO/LATER: here we must assume that the destruction of the model is enough to make clear that we will not
|
|
|
|
// remove the object from the container, even if the DrawingObject itself is not destroyed (unfortunately this
|
2005-10-19 11:11:48 +00:00
|
|
|
// There is no real need to do the following removing of the object from the container
|
|
|
|
// in case the model has correct persistance, but in case of problems such a removing
|
|
|
|
// would make the behaviour of the office more stable
|
|
|
|
|
|
|
|
comphelper::EmbeddedObjectContainer* pContainer = xObjRef.GetContainer();
|
|
|
|
if ( pContainer )
|
|
|
|
{
|
|
|
|
pContainer->CloseEmbeddedObject( xObjRef.GetObject() );
|
|
|
|
xObjRef.AssignToContainer( NULL, mpImpl->aPersistName );
|
|
|
|
}
|
|
|
|
|
2005-02-24 14:11:49 +00:00
|
|
|
// happens later than the destruction of the model, so we can't assert that).
|
|
|
|
//DBG_ASSERT( bInDestruction, "Model is destroyed, but not me?!" );
|
|
|
|
//TODO/LATER: should be make sure that the ObjectShell also forgets the object, because we will close it soon?
|
|
|
|
/*
|
|
|
|
uno::Reference < util::XCloseable > xClose( xObjRef, uno::UNO_QUERY );
|
|
|
|
if ( xClose.is() )
|
2004-10-04 16:54:47 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
xClose->close( sal_True );
|
|
|
|
}
|
|
|
|
catch ( util::CloseVetoException& )
|
|
|
|
{
|
|
|
|
// there's still someone who needs the object!
|
|
|
|
}
|
2004-10-04 16:54:47 +00:00
|
|
|
}
|
2005-02-24 14:11:49 +00:00
|
|
|
|
|
|
|
xObjRef = NULL;*/
|
|
|
|
}
|
|
|
|
else if ( xObjRef.is() )
|
|
|
|
{
|
|
|
|
SfxObjectShell* pPers = pModel->GetPersist();
|
|
|
|
if ( pPers )
|
2003-04-24 15:45:53 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
// remove object, but don't close it (that's up to someone else)
|
2005-07-12 11:14:10 +00:00
|
|
|
comphelper::EmbeddedObjectContainer* pContainer = xObjRef.GetContainer();
|
|
|
|
if ( pContainer )
|
|
|
|
{
|
|
|
|
pContainer->RemoveEmbeddedObject( xObjRef.GetObject(), sal_False);
|
|
|
|
|
|
|
|
// TODO/LATER: mpImpl->aPersistName contains outdated information, to have it uptodate
|
|
|
|
// it should be returned from RemoveEmbeddedObject call. Currently it is no problem,
|
|
|
|
// since no container is adjusted, actually the empty string could be provided as a name here
|
|
|
|
xObjRef.AssignToContainer( NULL, mpImpl->aPersistName );
|
|
|
|
}
|
|
|
|
|
2005-02-24 14:11:49 +00:00
|
|
|
DisconnectFileLink_Impl();
|
2003-04-24 15:45:53 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-04 16:54:47 +00:00
|
|
|
}
|
2005-02-24 14:11:49 +00:00
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
if ( xObjRef.is() && mpImpl->pLightClient )
|
2004-10-04 16:54:47 +00:00
|
|
|
{
|
2006-10-13 10:23:44 +00:00
|
|
|
xObjRef->removeStateChangeListener ( mpImpl->pLightClient );
|
|
|
|
xObjRef->removeEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
|
|
|
|
xObjRef->setClientSite( NULL );
|
|
|
|
|
2005-02-24 14:11:49 +00:00
|
|
|
GetSdrGlobalData().GetOLEObjCache().RemoveObj(this);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-11-26 15:33:16 +00:00
|
|
|
}
|
2005-02-24 14:11:49 +00:00
|
|
|
catch( ::com::sun::star::uno::Exception& e )
|
2004-11-26 15:33:16 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
(void)e;
|
|
|
|
DBG_ERROR(
|
|
|
|
(OString("SdrOle2Obj::Disconnect_Impl(), "
|
|
|
|
"exception caught: ") +
|
|
|
|
rtl::OUStringToOString(
|
|
|
|
comphelper::anyToString( cppu::getCaughtException() ),
|
|
|
|
RTL_TEXTENCODING_UTF8 )).getStr() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2003-05-26 08:06:45 +00:00
|
|
|
|
|
|
|
mpImpl->mbConnected = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::SetModel(SdrModel* pNewModel)
|
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
SfxObjectShell* pDestPers = pNewModel ? pNewModel->GetPersist() : 0;
|
|
|
|
SfxObjectShell* pSrcPers = pModel ? pModel->GetPersist() : 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-11-26 15:33:16 +00:00
|
|
|
if ( pNewModel == pModel )
|
|
|
|
{
|
|
|
|
// don't know if this is necessary or if it will ever happen, but who know?!
|
|
|
|
SdrRectObj::SetModel( pNewModel );
|
|
|
|
return;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-11-26 15:33:16 +00:00
|
|
|
// assignment to model has changed
|
|
|
|
DBG_ASSERT( pSrcPers || !mpImpl->mbConnected, "Connected object without a model?!" );
|
2005-10-19 11:11:48 +00:00
|
|
|
|
|
|
|
DBG_ASSERT( pDestPers, "The destination model must have a persistence! Please submit an issue!" );
|
|
|
|
DBG_ASSERT( pDestPers != pSrcPers, "The source and the destination models should have different persistences! Problems are possible!" );
|
|
|
|
|
|
|
|
// this is a bug if the target model has no persistence
|
|
|
|
// no error handling is possible so just do nothing in this method
|
|
|
|
if ( !pDestPers )
|
|
|
|
return;
|
|
|
|
|
2004-11-26 15:33:16 +00:00
|
|
|
RemoveListeners_Impl();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-02-16 16:05:07 +00:00
|
|
|
if( pDestPers && pSrcPers && !IsEmptyPresObj() )
|
2004-10-04 16:54:47 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
try
|
2004-11-26 15:33:16 +00:00
|
|
|
{
|
2005-02-24 14:11:49 +00:00
|
|
|
// move the objects' storage; ObjectRef remains the same, but PersistName may change
|
|
|
|
::rtl::OUString aTmp;
|
|
|
|
comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->GetEmbeddedObjectContainer();
|
|
|
|
uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
|
|
|
|
DBG_ASSERT( !xObjRef.is() || xObjRef.GetObject() == xObj, "Wrong object identity!" );
|
|
|
|
if ( xObj.is() )
|
2005-01-18 14:01:22 +00:00
|
|
|
{
|
2005-07-12 11:14:10 +00:00
|
|
|
pDestPers->GetEmbeddedObjectContainer().MoveEmbeddedObject( rContainer, xObj, aTmp );
|
2005-02-24 14:11:49 +00:00
|
|
|
mpImpl->aPersistName = aTmp;
|
2005-07-12 11:14:10 +00:00
|
|
|
xObjRef.AssignToContainer( &pDestPers->GetEmbeddedObjectContainer(), aTmp );
|
2005-02-24 14:11:49 +00:00
|
|
|
}
|
|
|
|
DBG_ASSERT( aTmp.getLength(), "Copying embedded object failed!" );
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::uno::Exception& e )
|
|
|
|
{
|
|
|
|
(void)e;
|
|
|
|
DBG_ERROR(
|
|
|
|
(OString("SdrOle2Obj::SetModel(), "
|
|
|
|
"exception caught: ") +
|
|
|
|
rtl::OUStringToOString(
|
|
|
|
comphelper::anyToString( cppu::getCaughtException() ),
|
|
|
|
RTL_TEXTENCODING_UTF8 )).getStr() );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
SdrRectObj::SetModel( pNewModel );
|
2001-09-10 10:38:27 +00:00
|
|
|
|
2005-03-03 16:34:09 +00:00
|
|
|
// #i43086#
|
|
|
|
if( pModel && !pModel->isLocked() )
|
|
|
|
ImpSetVisAreaSize();
|
|
|
|
|
2005-02-16 16:05:07 +00:00
|
|
|
if( pDestPers && !IsEmptyPresObj() )
|
2004-11-26 15:33:16 +00:00
|
|
|
{
|
2005-02-17 08:54:15 +00:00
|
|
|
if ( !pSrcPers || IsEmptyPresObj() )
|
2004-11-26 15:33:16 +00:00
|
|
|
// object wasn't connected, now it should
|
|
|
|
Connect_Impl();
|
|
|
|
else
|
|
|
|
Reconnect_Impl();
|
|
|
|
}
|
|
|
|
|
|
|
|
AddListeners_Impl();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::SetPage(SdrPage* pNewPage)
|
|
|
|
{
|
|
|
|
FASTBOOL bRemove=pNewPage==NULL && pPage!=NULL;
|
|
|
|
FASTBOOL bInsert=pNewPage!=NULL && pPage==NULL;
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if (bRemove && mpImpl->mbConnected )
|
|
|
|
Disconnect();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
SdrRectObj::SetPage(pNewPage);
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if (bInsert && !mpImpl->mbConnected )
|
|
|
|
Connect();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
void SdrOle2Obj::SetObjRef( const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >& rNewObjRef )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
DBG_ASSERT( !rNewObjRef.is() || !xObjRef.GetObject().is(), "SetObjRef called on already initialized object!");
|
|
|
|
if( rNewObjRef == xObjRef.GetObject() )
|
2003-05-26 08:06:45 +00:00
|
|
|
return;
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
// MBA: the caller of the method is responsible to control the old object, it will not be closed here
|
|
|
|
// Otherwise WW8 import crashes because it tranfers control to OLENode by this method
|
|
|
|
if ( xObjRef.GetObject().is() )
|
|
|
|
xObjRef.Lock( FALSE );
|
2003-04-24 15:45:53 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
// MBA: avoid removal of object in Disconnect! It is definitely a HACK to call SetObjRef(0)!
|
2004-11-26 15:33:16 +00:00
|
|
|
// This call will try to close the objects; so if anybody else wants to keep it, it must be locked by a CloseListener
|
2004-10-04 16:54:47 +00:00
|
|
|
xObjRef.Clear();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( mpImpl->mbConnected )
|
|
|
|
Disconnect();
|
|
|
|
|
|
|
|
xObjRef.Assign( rNewObjRef, GetAspect() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( xObjRef.is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
DELETEZ( pGraphic );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
|
|
|
|
SetResizeProtect(TRUE);
|
2003-04-24 13:49:28 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
// #108759# For math objects, set closed state to transparent
|
|
|
|
if( ImplIsMathObj( rNewObjRef ) )
|
|
|
|
SetClosedObj( false );
|
|
|
|
|
|
|
|
Connect();
|
|
|
|
}
|
2003-11-24 15:57:52 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SetChanged();
|
2003-11-24 15:57:52 +00:00
|
|
|
BroadcastObjectChange();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2003-04-24 13:49:28 +00:00
|
|
|
void SdrOle2Obj::SetClosedObj( bool bIsClosed )
|
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
// TODO/LATER: do we still need this hack?
|
2003-04-24 13:49:28 +00:00
|
|
|
// #108759# Allow changes to the closed state of OLE objects
|
|
|
|
bClosedObj = bIsClosed;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2001-09-13 08:23:24 +00:00
|
|
|
void SdrOle2Obj::SetPersistName( const String& rPersistName )
|
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
DBG_ASSERT( !mpImpl->aPersistName.Len(), "Persist name changed!");
|
2003-11-05 13:33:18 +00:00
|
|
|
|
2001-09-13 08:23:24 +00:00
|
|
|
mpImpl->aPersistName = rPersistName;
|
2003-12-01 08:30:56 +00:00
|
|
|
mpImpl->mbLoadingOLEObjectFailed = false;
|
2003-11-05 13:33:18 +00:00
|
|
|
|
|
|
|
Connect();
|
2001-09-13 08:23:24 +00:00
|
|
|
SetChanged();
|
|
|
|
}
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
void SdrOle2Obj::AbandonObject()
|
|
|
|
{
|
|
|
|
mpImpl->aPersistName.Erase();
|
|
|
|
mpImpl->mbLoadingOLEObjectFailed = false;
|
|
|
|
SetObjRef(0);
|
|
|
|
}
|
|
|
|
|
2001-09-13 08:23:24 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
String SdrOle2Obj::GetPersistName() const
|
|
|
|
{
|
|
|
|
return mpImpl->aPersistName;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
|
|
|
|
{
|
|
|
|
rInfo.bRotateFreeAllowed=FALSE;
|
|
|
|
rInfo.bRotate90Allowed =FALSE;
|
|
|
|
rInfo.bMirrorFreeAllowed=FALSE;
|
|
|
|
rInfo.bMirror45Allowed =FALSE;
|
|
|
|
rInfo.bMirror90Allowed =FALSE;
|
|
|
|
rInfo.bTransparenceAllowed = FALSE;
|
|
|
|
rInfo.bGradientAllowed = FALSE;
|
|
|
|
rInfo.bShearAllowed =FALSE;
|
2001-02-15 15:11:33 +00:00
|
|
|
rInfo.bEdgeRadiusAllowed=FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
rInfo.bNoOrthoDesired =FALSE;
|
|
|
|
rInfo.bCanConvToPath =FALSE;
|
|
|
|
rInfo.bCanConvToPoly =FALSE;
|
|
|
|
rInfo.bCanConvToPathLineToArea=FALSE;
|
|
|
|
rInfo.bCanConvToPolyLineToArea=FALSE;
|
|
|
|
rInfo.bCanConvToContour = FALSE;
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
UINT16 SdrOle2Obj::GetObjIdentifier() const
|
|
|
|
{
|
|
|
|
return bFrame ? UINT16(OBJ_FRAME) : UINT16(OBJ_OLE2);
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2004-11-03 10:01:06 +00:00
|
|
|
sal_Bool SdrOle2Obj::DoPaintObject(XOutputDevice& rOut, const SdrPaintInfoRec& rInfoRec) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2003-11-24 15:57:52 +00:00
|
|
|
sal_Bool bOk(sal_True);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if( !GetGraphic() )
|
|
|
|
( (SdrOle2Obj*) this)->GetObjRef_Impl(); // try to create embedded object
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( xObjRef.is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
sal_Int64 nMiscStatus = xObjRef->getStatus( GetAspect() );
|
|
|
|
if( !bSizProt && (nMiscStatus & embed::EmbedMisc::EMBED_NEVERRESIZE) )
|
2000-09-18 16:07:07 +00:00
|
|
|
( (SdrOle2Obj*) this)->bSizProt = TRUE;
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
OutputDevice* pOut = rOut.GetOutDev();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
//TODO/LATER: currently it's not possible to compare the windows, the XOutDev contains a virtual device
|
|
|
|
sal_Int32 nState = xObjRef->getCurrentState();
|
|
|
|
//if ( ( nState != embed::EmbedStates::INPLACE_ACTIVE && nState != embed::EmbedStates::UI_ACTIVE ) ||
|
|
|
|
// pModel && SfxInPlaceClient::GetActiveWindow( pModel->GetPersist(), xObjRef ) != pOut )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ((rInfoRec.nPaintMode & SDRPAINTMODE_DRAFTGRAF) ==0)
|
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
// PlugIn-Objekt connecten
|
|
|
|
if (rInfoRec.pPV!=NULL)
|
|
|
|
{
|
|
|
|
SdrOle2Obj* pOle2Obj = (SdrOle2Obj*) this;
|
|
|
|
SdrView* pSdrView = (SdrView*) &rInfoRec.pPV->GetView();
|
|
|
|
pSdrView->DoConnect(pOle2Obj);
|
|
|
|
}
|
|
|
|
}
|
2001-08-17 11:00:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
// #108759# Temporarily set the current background
|
|
|
|
// color, since OLEs rely on that during
|
|
|
|
// auto-colored text rendering
|
|
|
|
Wallpaper aOldBg( pOut->GetBackground() );
|
2001-08-17 11:00:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if( rInfoRec.pPV && GetPage() )
|
|
|
|
pOut->SetBackground( rInfoRec.pPV->GetView().CalcBackgroundColor( GetSnapRect(),
|
|
|
|
rInfoRec.pPV->GetVisibleLayers(),
|
|
|
|
*GetPage() ) );
|
|
|
|
|
|
|
|
pOut->Push( PUSH_CLIPREGION );
|
|
|
|
pOut->IntersectClipRegion( aRect );
|
|
|
|
|
|
|
|
GetGraphic();
|
|
|
|
PaintGraphic_Impl( rOut, rInfoRec, nState == embed::EmbedStates::ACTIVE );
|
|
|
|
|
|
|
|
/*
|
|
|
|
if ( !mpImpl->pMetaFile )
|
|
|
|
GetGDIMetaFile();
|
|
|
|
if ( mpImpl->pMetaFile )
|
|
|
|
mpImpl->pMetaFile->Play( pOut, aRect.TopLeft(), aRect.GetSize() );
|
|
|
|
//(*ppObjRef)->DoDraw(pOut,aRect.TopLeft(),aRect.GetSize(),JobSetup());
|
|
|
|
*/
|
|
|
|
|
|
|
|
pOut->Pop();
|
|
|
|
|
|
|
|
// #108759# Restore old background
|
|
|
|
pOut->SetBackground( aOldBg );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2001-08-17 11:00:07 +00:00
|
|
|
else if( ( rInfoRec.nPaintMode & SDRPAINTMODE_HIDEDRAFTGRAF ) == 0 )
|
2000-09-18 16:07:07 +00:00
|
|
|
{ // sonst SDRPAINTMODE_DRAFTGRAF
|
|
|
|
Polygon aPoly(Rect2Poly(aRect,aGeo));
|
|
|
|
pOut->SetLineColor(Color(COL_BLACK));
|
|
|
|
pOut->DrawPolyLine(aPoly);
|
|
|
|
pOut->DrawLine(aPoly[0],aPoly[2]);
|
|
|
|
pOut->DrawLine(aPoly[1],aPoly[3]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-10-04 16:54:47 +00:00
|
|
|
else if ( GetGraphic() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
PaintGraphic_Impl( rOut, rInfoRec );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2002-07-02 15:28:53 +00:00
|
|
|
// #100499# OLE without context and without bitmap, do the same as
|
|
|
|
// for empty groups, additionally draw empty OLE bitmap
|
|
|
|
else
|
|
|
|
{
|
2006-11-21 15:47:14 +00:00
|
|
|
if(!rInfoRec.bPrinter && rInfoRec.aPaintLayer.IsSet(GetLayer()))
|
2002-07-02 15:28:53 +00:00
|
|
|
{
|
|
|
|
OutputDevice* pOutDev = rOut.GetOutDev();
|
|
|
|
|
2004-01-06 14:42:45 +00:00
|
|
|
pOutDev->SetFillColor();
|
|
|
|
pOutDev->SetLineColor(Color(COL_LIGHTGRAY));
|
2002-07-02 15:28:53 +00:00
|
|
|
pOutDev->DrawRect(aOutRect);
|
|
|
|
|
2007-04-26 06:52:26 +00:00
|
|
|
Bitmap aBitmap(ResId(BMP_OLEOBJ, *ImpGetResMgr()));
|
2002-07-02 15:28:53 +00:00
|
|
|
Rectangle aSnapRect(GetSnapRect());
|
|
|
|
Size aBitmapSize(pOutDev->PixelToLogic(aBitmap.GetSizePixel()));
|
|
|
|
|
|
|
|
pOutDev->DrawBitmap(
|
|
|
|
aSnapRect.Center() - Point(aBitmapSize.Width() / 2, aBitmapSize.Height() / 2),
|
|
|
|
aBitmapSize,
|
|
|
|
aBitmap);
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (HasText())
|
|
|
|
{
|
2003-11-24 15:57:52 +00:00
|
|
|
bOk = SdrTextObj::DoPaintObject(rOut, rInfoRec);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
return bOk;
|
|
|
|
}
|
|
|
|
|
2006-06-19 15:43:13 +00:00
|
|
|
void SdrOle2Obj::PaintGraphic_Impl( XOutputDevice& rOut, const SdrPaintInfoRec& /*rInfoRec*/, sal_Bool bActive ) const
|
2004-10-04 16:54:47 +00:00
|
|
|
{
|
2006-03-24 12:01:09 +00:00
|
|
|
OutputDevice* pOutDev = rOut.GetOutDev();
|
|
|
|
OSL_ENSURE( pOutDev, "The device must be provided!\n" );
|
|
|
|
if ( !pOutDev )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// In case High Contrast mode is requested try to get a graphical representation in this mode
|
|
|
|
// if it is not possible the replacement image should be used
|
|
|
|
Graphic* pGr = NULL;
|
|
|
|
if ( ( pOutDev->GetDrawMode() & DRAWMODE_SETTINGSFILL ) && xObjRef.is() )
|
|
|
|
pGr = xObjRef.GetHCGraphic();
|
|
|
|
|
|
|
|
if ( !pGr )
|
|
|
|
pGr = GetGraphic();
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( pGr && pGr->GetType() != GRAPHIC_NONE )
|
|
|
|
{
|
|
|
|
if( IsEmptyPresObj() )
|
|
|
|
{
|
|
|
|
const MapMode aDstMapMode( pOutDev->GetMapMode().GetMapUnit() );
|
|
|
|
Point aPos(aRect.Center());
|
|
|
|
Size aDstSize;
|
|
|
|
|
|
|
|
if( pGr->GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
|
|
|
|
aDstSize = pOutDev->PixelToLogic( pGr->GetPrefSize(), aDstMapMode );
|
|
|
|
else
|
|
|
|
aDstSize = pOutDev->LogicToLogic( pGr->GetPrefSize(), pGr->GetPrefMapMode(), aDstMapMode );
|
|
|
|
|
|
|
|
aPos.X()-=aDstSize.Width() /2;
|
|
|
|
aPos.Y()-=aDstSize.Height()/2;
|
|
|
|
if (aPos.X() >= aRect.Left() && aPos.Y() >= aRect.Top())
|
|
|
|
pGr->Draw(pOutDev,aPos, aDstSize);
|
|
|
|
|
|
|
|
svtools::ColorConfig aColorConfig;
|
|
|
|
svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( svtools::OBJECTBOUNDARIES ) );
|
|
|
|
|
|
|
|
if( aColor.bIsVisible )
|
|
|
|
{
|
|
|
|
pOutDev->SetFillColor();
|
|
|
|
pOutDev->SetLineColor( aColor.nColor );
|
|
|
|
pOutDev->DrawRect(aRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pGr->Draw( pOutDev, aRect.TopLeft(), aRect.GetSize() );
|
|
|
|
|
|
|
|
// shade the representation if the object is activated outplace
|
|
|
|
if ( bActive )
|
|
|
|
::svt::EmbeddedObjectRef::DrawShading( aRect, pOutDev );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
::svt::EmbeddedObjectRef::DrawPaintReplacement( aRect, mpImpl->aPersistName, pOutDev );
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SdrObject* SdrOle2Obj::CheckHit(const Point& rPnt, USHORT nTol, const SetOfByte* pVisiLayer) const
|
|
|
|
{
|
|
|
|
return ImpCheckHit(rPnt,nTol,pVisiLayer,TRUE,TRUE);
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::TakeObjNameSingul(XubString& rName) const
|
|
|
|
{
|
2001-09-10 10:38:27 +00:00
|
|
|
rName = ImpGetResStr(bFrame ? STR_ObjNameSingulFrame : STR_ObjNameSingulOLE2);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-12-19 16:47:26 +00:00
|
|
|
const String aName(GetName());
|
|
|
|
|
2001-09-10 10:38:27 +00:00
|
|
|
if( aName.Len() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
rName.AppendAscii(" '");
|
|
|
|
rName += aName;
|
|
|
|
rName += sal_Unicode('\'');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::TakeObjNamePlural(XubString& rName) const
|
|
|
|
{
|
2001-09-10 10:38:27 +00:00
|
|
|
rName=ImpGetResStr(bFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SdrOle2Obj::operator=(const SdrObject& rObj)
|
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
//TODO/LATER: who takes over control of my old object?!
|
2001-09-10 11:59:59 +00:00
|
|
|
if( &rObj != this )
|
2004-05-10 13:33:02 +00:00
|
|
|
{
|
|
|
|
// #116235#
|
|
|
|
// ImpAssign( rObj );
|
|
|
|
const SdrOle2Obj& rOle2Obj = static_cast< const SdrOle2Obj& >( rObj );
|
2001-09-10 11:59:59 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
uno::Reference < util::XCloseable > xClose( xObjRef.GetObject(), uno::UNO_QUERY );
|
|
|
|
|
|
|
|
if( pModel && mpImpl->mbConnected )
|
2004-05-10 13:33:02 +00:00
|
|
|
Disconnect();
|
2001-09-10 11:59:59 +00:00
|
|
|
|
2004-05-10 13:33:02 +00:00
|
|
|
SdrRectObj::operator=( rObj );
|
2001-09-10 11:59:59 +00:00
|
|
|
|
2004-05-10 13:33:02 +00:00
|
|
|
// #108867# Manually copying bClosedObj attribute
|
|
|
|
SetClosedObj( rObj.IsClosedObj() );
|
2001-09-10 11:59:59 +00:00
|
|
|
|
2004-05-10 13:33:02 +00:00
|
|
|
mpImpl->aPersistName = rOle2Obj.mpImpl->aPersistName;
|
|
|
|
aProgName = rOle2Obj.aProgName;
|
|
|
|
bFrame = rOle2Obj.bFrame;
|
|
|
|
|
|
|
|
if( rOle2Obj.pGraphic )
|
|
|
|
{
|
|
|
|
if( pGraphic )
|
|
|
|
{
|
|
|
|
delete pGraphic;
|
|
|
|
delete mpImpl->pGraphicObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
pGraphic = new Graphic( *rOle2Obj.pGraphic );
|
|
|
|
mpImpl->pGraphicObject = new GraphicObject( *pGraphic );
|
|
|
|
}
|
2001-09-13 08:23:24 +00:00
|
|
|
|
2006-01-10 13:50:54 +00:00
|
|
|
if( pModel && rObj.GetModel() && !IsEmptyPresObj() )
|
2004-05-10 13:33:02 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
SfxObjectShell* pDestPers = pModel->GetPersist();
|
|
|
|
SfxObjectShell* pSrcPers = rObj.GetModel()->GetPersist();
|
2004-05-10 13:33:02 +00:00
|
|
|
if( pDestPers && pSrcPers )
|
|
|
|
{
|
2005-07-12 11:14:10 +00:00
|
|
|
DBG_ASSERT( !xObjRef.is(), "Object already existing!" );
|
|
|
|
comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->GetEmbeddedObjectContainer();
|
|
|
|
uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
|
|
|
|
if ( xObj.is() )
|
2004-05-10 13:33:02 +00:00
|
|
|
{
|
2005-07-12 11:14:10 +00:00
|
|
|
::rtl::OUString aTmp;
|
2006-10-13 10:23:44 +00:00
|
|
|
xObjRef.Assign( pDestPers->GetEmbeddedObjectContainer().CopyAndGetEmbeddedObject( rContainer, xObj, aTmp ), rOle2Obj.GetAspect() );
|
2005-07-12 11:14:10 +00:00
|
|
|
mpImpl->aPersistName = aTmp;
|
|
|
|
CheckFileLink_Impl();
|
2004-11-26 15:33:16 +00:00
|
|
|
}
|
2005-07-12 11:14:10 +00:00
|
|
|
|
|
|
|
Connect();
|
|
|
|
|
2007-05-22 14:20:35 +00:00
|
|
|
/* only needed for MSOLE-Objects, now handled inside implementation of Object
|
2006-10-13 10:23:44 +00:00
|
|
|
if ( xObjRef.is() && rOle2Obj.xObjRef.is() && rOle2Obj.GetAspect() != embed::Aspects::MSOLE_ICON )
|
2004-11-26 15:33:16 +00:00
|
|
|
{
|
2005-07-12 11:14:10 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
awt::Size aVisSize = rOle2Obj.xObjRef->getVisualAreaSize( rOle2Obj.GetAspect() );
|
|
|
|
if( rOle2Obj.xObjRef->getMapUnit( rOle2Obj.GetAspect() ) == xObjRef->getMapUnit( GetAspect() ) )
|
|
|
|
xObjRef->setVisualAreaSize( GetAspect(), aVisSize );
|
|
|
|
}
|
|
|
|
catch ( embed::WrongStateException& )
|
|
|
|
{
|
|
|
|
// setting of VisArea not necessary for objects that don't cache it in loaded state
|
|
|
|
}
|
|
|
|
catch( embed::NoVisualAreaSizeException& )
|
|
|
|
{
|
|
|
|
// objects my not have visual areas
|
|
|
|
}
|
|
|
|
catch( uno::Exception& e )
|
|
|
|
{
|
|
|
|
(void)e;
|
|
|
|
DBG_ERROR( "SdrOle2Obj::operator=(), unexcpected exception caught!" );
|
|
|
|
}
|
2007-05-22 14:20:35 +00:00
|
|
|
} */
|
2004-05-10 13:33:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-09-10 11:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2004-05-10 13:33:02 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
FASTBOOL SdrOle2Obj::HasSpecialDrag() const
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::ImpSetVisAreaSize()
|
|
|
|
{
|
2006-10-13 10:23:44 +00:00
|
|
|
// currently there is no need to recalculate scaling for iconified objects
|
|
|
|
// TODO/LATER: it might be needed in future when it is possible to change the icon
|
|
|
|
if ( GetAspect() == embed::Aspects::MSOLE_ICON )
|
|
|
|
return;
|
|
|
|
|
2006-11-02 08:51:10 +00:00
|
|
|
// the object area of an embedded object was changed, e.g. by user interaction an a selected object
|
2004-11-26 15:33:16 +00:00
|
|
|
GetObjRef();
|
2006-10-13 10:23:44 +00:00
|
|
|
if ( xObjRef.is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-03-03 16:34:09 +00:00
|
|
|
OSL_ASSERT( pModel );
|
2004-10-04 16:54:47 +00:00
|
|
|
sal_Int64 nMiscStatus = xObjRef->getStatus( GetAspect() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-03-24 12:01:09 +00:00
|
|
|
// the client is required to get access to scaling
|
|
|
|
SfxInPlaceClient* pClient = SfxInPlaceClient::GetClient( pModel->GetPersist(), xObjRef.GetObject() );
|
2006-10-13 10:23:44 +00:00
|
|
|
sal_Bool bHasOwnClient =
|
|
|
|
( mpImpl->pLightClient
|
|
|
|
&& xObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) );
|
|
|
|
|
|
|
|
if ( pClient || bHasOwnClient )
|
2006-03-24 12:01:09 +00:00
|
|
|
{
|
2006-11-02 08:51:10 +00:00
|
|
|
// TODO/LATER: IMHO we need to do similar things when object is UIActive or OutplaceActive?! (MBA)
|
|
|
|
if ( (nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) &&
|
|
|
|
svt::EmbeddedObjectRef::TryRunningState( xObjRef.GetObject() )
|
|
|
|
|| xObjRef->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE
|
|
|
|
)
|
2005-03-15 10:31:56 +00:00
|
|
|
{
|
2006-10-13 10:23:44 +00:00
|
|
|
Fraction aScaleWidth;
|
|
|
|
Fraction aScaleHeight;
|
|
|
|
if ( pClient )
|
|
|
|
{
|
|
|
|
aScaleWidth = pClient->GetScaleWidth();
|
|
|
|
aScaleHeight = pClient->GetScaleHeight();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aScaleWidth = mpImpl->pLightClient->GetScaleWidth();
|
|
|
|
aScaleHeight = mpImpl->pLightClient->GetScaleHeight();
|
|
|
|
}
|
|
|
|
|
2006-11-02 08:51:10 +00:00
|
|
|
// The object wants to resize itself (f.e. Chart wants to recalculate the layout)
|
|
|
|
// or object is inplace active and so has a window that must be resized also
|
|
|
|
// In these cases the change in the object area size will be reflected in a change of the
|
|
|
|
// objects' visual area. The scaling will not change, but it might exist already and must
|
|
|
|
// be used in calculations
|
2006-03-24 12:01:09 +00:00
|
|
|
MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
|
2006-10-13 10:23:44 +00:00
|
|
|
Size aVisSize( (long)( Fraction( aRect.GetWidth() ) / aScaleWidth ),
|
|
|
|
(long)( Fraction( aRect.GetHeight() ) / aScaleHeight ) );
|
2005-03-15 10:31:56 +00:00
|
|
|
|
2006-03-24 12:01:09 +00:00
|
|
|
aVisSize = OutputDevice::LogicToLogic( aVisSize, pModel->GetScaleUnit(), aMapUnit);
|
|
|
|
awt::Size aSz;
|
|
|
|
aSz.Width = aVisSize.Width();
|
|
|
|
aSz.Height = aVisSize.Height();
|
|
|
|
xObjRef->setVisualAreaSize( GetAspect(), aSz );
|
2004-10-04 16:54:47 +00:00
|
|
|
|
2006-03-24 12:01:09 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
aSz = xObjRef->getVisualAreaSize( GetAspect() );
|
|
|
|
}
|
|
|
|
catch( embed::NoVisualAreaSizeException& )
|
|
|
|
{}
|
|
|
|
|
|
|
|
Rectangle aAcceptedVisArea;
|
2006-10-13 10:23:44 +00:00
|
|
|
aAcceptedVisArea.SetSize( Size( (long)( Fraction( long( aSz.Width ) ) * aScaleWidth ),
|
|
|
|
(long)( Fraction( long( aSz.Height ) ) * aScaleHeight ) ) );
|
2006-03-24 12:01:09 +00:00
|
|
|
if (aVisSize != aAcceptedVisArea.GetSize())
|
|
|
|
{
|
2006-11-02 08:51:10 +00:00
|
|
|
// server changed VisArea to its liking and the VisArea is different than the suggested one
|
|
|
|
// store the new value as given by the object
|
2006-03-24 12:01:09 +00:00
|
|
|
MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
|
|
|
|
aRect.SetSize(OutputDevice::LogicToLogic( aAcceptedVisArea.GetSize(), aNewMapUnit, pModel->GetScaleUnit()));
|
|
|
|
}
|
|
|
|
|
2006-11-02 08:51:10 +00:00
|
|
|
// make the new object area known to the client
|
|
|
|
// compared to the "else" branch aRect might have been changed by the object and no additional scaling was applied
|
2007-05-22 14:20:35 +00:00
|
|
|
OSL_ASSERT( pClient );
|
|
|
|
if( pClient )
|
|
|
|
pClient->SetObjArea(aRect);
|
2006-11-02 08:51:10 +00:00
|
|
|
|
|
|
|
// we need a new replacement image as the object has resized itself
|
2006-03-24 12:01:09 +00:00
|
|
|
xObjRef.UpdateReplacement();
|
|
|
|
}
|
|
|
|
else
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-11-02 08:51:10 +00:00
|
|
|
// The object isn't active and does not want to resize itself so the changed object area size
|
|
|
|
// will be reflected in a changed object scaling
|
2006-10-13 10:23:44 +00:00
|
|
|
Fraction aScaleWidth;
|
|
|
|
Fraction aScaleHeight;
|
|
|
|
Size aObjAreaSize;
|
|
|
|
if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
|
2005-03-15 10:31:56 +00:00
|
|
|
{
|
2006-10-13 10:23:44 +00:00
|
|
|
if ( pClient )
|
|
|
|
{
|
|
|
|
Rectangle aScaleRect(aRect.TopLeft(), aObjAreaSize);
|
2006-12-19 13:00:07 +00:00
|
|
|
pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth, aScaleHeight);
|
2006-10-13 10:23:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
|
|
|
|
{
|
|
|
|
SdrRectObj::NbcResize(rRef,xFact,yFact);
|
|
|
|
if (aGeo.nShearWink!=0 || aGeo.nDrehWink!=0) { // kleine Korrekturen
|
|
|
|
if (aGeo.nDrehWink>=9000 && aGeo.nDrehWink<27000) {
|
|
|
|
aRect.Move(aRect.Left()-aRect.Right(),aRect.Top()-aRect.Bottom());
|
|
|
|
}
|
|
|
|
aGeo.nDrehWink=0;
|
|
|
|
aGeo.nShearWink=0;
|
|
|
|
aGeo.nSin=0.0;
|
|
|
|
aGeo.nCos=1.0;
|
|
|
|
aGeo.nTan=0.0;
|
|
|
|
SetRectsDirty();
|
|
|
|
}
|
2005-03-03 16:34:09 +00:00
|
|
|
if( pModel && !pModel->isLocked() )
|
2001-07-24 07:51:46 +00:00
|
|
|
ImpSetVisAreaSize();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::SetGeoData(const SdrObjGeoData& rGeo)
|
|
|
|
{
|
|
|
|
SdrRectObj::SetGeoData(rGeo);
|
2005-03-03 16:34:09 +00:00
|
|
|
if( pModel && !pModel->isLocked() )
|
2001-07-24 07:51:46 +00:00
|
|
|
ImpSetVisAreaSize();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::NbcSetSnapRect(const Rectangle& rRect)
|
|
|
|
{
|
|
|
|
SdrRectObj::NbcSetSnapRect(rRect);
|
2005-03-03 16:34:09 +00:00
|
|
|
if( pModel && !pModel->isLocked() )
|
2001-07-24 07:51:46 +00:00
|
|
|
ImpSetVisAreaSize();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::NbcSetLogicRect(const Rectangle& rRect)
|
|
|
|
{
|
|
|
|
SdrRectObj::NbcSetLogicRect(rRect);
|
2005-03-03 16:34:09 +00:00
|
|
|
if( pModel && !pModel->isLocked() )
|
2001-07-24 07:51:46 +00:00
|
|
|
ImpSetVisAreaSize();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
Graphic* SdrOle2Obj::GetGraphic() const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( xObjRef.is() )
|
|
|
|
return xObjRef.GetGraphic();
|
|
|
|
return pGraphic;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
void SdrOle2Obj::GetNewReplacement()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( xObjRef.is() )
|
|
|
|
xObjRef.UpdateReplacement();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
Size SdrOle2Obj::GetOrigObjSize( MapMode* pTargetMapMode ) const
|
|
|
|
{
|
|
|
|
return xObjRef.GetSize( pTargetMapMode );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SdrOle2Obj::NbcMove(const Size& rSize)
|
|
|
|
{
|
|
|
|
SdrRectObj::NbcMove(rSize);
|
2005-03-03 16:34:09 +00:00
|
|
|
if( pModel && !pModel->isLocked() )
|
2001-07-24 07:51:46 +00:00
|
|
|
ImpSetVisAreaSize();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2006-02-01 18:02:05 +00:00
|
|
|
sal_Bool SdrOle2Obj::Unload( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
|
|
|
|
{
|
|
|
|
sal_Bool bResult = sal_False;
|
|
|
|
|
|
|
|
sal_Int32 nState = xObj->getCurrentState();
|
|
|
|
if ( nState == embed::EmbedStates::LOADED )
|
|
|
|
{
|
|
|
|
bResult = sal_True;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
|
|
|
|
uno::Reference < util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
|
|
|
|
|
|
|
|
if ( embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
|
|
|
|
embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) &&
|
|
|
|
!( xModifiable.is() && xModifiable->isModified() ) &&
|
|
|
|
!( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE || nState == embed::EmbedStates::ACTIVE ) )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xObj->changeState( embed::EmbedStates::LOADED );
|
|
|
|
bResult = sal_True;
|
|
|
|
}
|
|
|
|
catch( ::com::sun::star::uno::Exception& e )
|
|
|
|
{
|
|
|
|
(void)e;
|
|
|
|
DBG_ERROR(
|
|
|
|
(OString("SdrOle2Obj::Unload=(), "
|
|
|
|
"exception caught: ") +
|
|
|
|
rtl::OUStringToOString(
|
|
|
|
comphelper::anyToString( cppu::getCaughtException() ),
|
|
|
|
RTL_TEXTENCODING_UTF8 )).getStr() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL SdrOle2Obj::Unload()
|
|
|
|
{
|
|
|
|
BOOL bUnloaded = FALSE;
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if( xObjRef.is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
//TODO/LATER: no refcounting tricks anymore!
|
|
|
|
//"customers" must register as state change listeners
|
2000-09-18 16:07:07 +00:00
|
|
|
//Nicht notwendig im Doc DTor (MM)
|
2004-10-04 16:54:47 +00:00
|
|
|
//ULONG nRefCount = (*ppObjRef)->GetRefCount();
|
2000-09-18 16:07:07 +00:00
|
|
|
// prevent Unload if there are external references
|
2004-10-04 16:54:47 +00:00
|
|
|
//if( nRefCount > 2 )
|
|
|
|
// return FALSE;
|
|
|
|
//DBG_ASSERT( nRefCount == 2, "Wrong RefCount for unload" );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2001-04-12 09:06:03 +00:00
|
|
|
else
|
|
|
|
bUnloaded = TRUE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( pModel && xObjRef.is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-02-01 18:02:05 +00:00
|
|
|
bUnloaded = Unload( xObjRef.GetObject(), GetAspect() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bUnloaded;
|
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
void SdrOle2Obj::CreatePersistName( SfxObjectShell* pPers )
|
2001-09-10 10:38:27 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
mpImpl->aPersistName = pPers->GetEmbeddedObjectContainer().CreateUniqueObjectName();
|
2001-09-10 10:38:27 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2001-09-10 10:38:27 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
void SdrOle2Obj::GetObjRef_Impl()
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( !xObjRef.is() && mpImpl->aPersistName.Len() && pModel && pModel->GetPersist() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2003-03-27 14:06:05 +00:00
|
|
|
// #107645#
|
2004-10-04 16:54:47 +00:00
|
|
|
// Only try loading if it did not went wrong up to now
|
2003-03-27 14:06:05 +00:00
|
|
|
if(!mpImpl->mbLoadingOLEObjectFailed)
|
|
|
|
{
|
2006-10-13 10:23:44 +00:00
|
|
|
xObjRef.Assign( pModel->GetPersist()->GetEmbeddedObjectContainer().GetEmbeddedObject( mpImpl->aPersistName ), GetAspect() );
|
2005-01-18 14:01:22 +00:00
|
|
|
CheckFileLink_Impl();
|
2003-03-27 14:06:05 +00:00
|
|
|
|
|
|
|
// #107645#
|
|
|
|
// If loading of OLE object failed, remember that to not invoke a endless
|
|
|
|
// loop trying to load it again and again.
|
2004-10-04 16:54:47 +00:00
|
|
|
if( xObjRef.is() )
|
2003-03-27 14:06:05 +00:00
|
|
|
{
|
|
|
|
mpImpl->mbLoadingOLEObjectFailed = sal_True;
|
|
|
|
}
|
2003-04-24 13:49:28 +00:00
|
|
|
|
|
|
|
// #108759# For math objects, set closed state to transparent
|
2004-10-04 16:54:47 +00:00
|
|
|
if( ImplIsMathObj( xObjRef.GetObject() ) )
|
|
|
|
SetClosedObj( false );
|
2003-03-27 14:06:05 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( xObjRef.is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if( !IsEmptyPresObj() )
|
|
|
|
{
|
|
|
|
// #75637# remember modified status of model
|
2003-11-24 15:57:52 +00:00
|
|
|
const sal_Bool bWasChanged(pModel ? pModel->IsChanged() : sal_False);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// perhaps preview not valid anymore
|
|
|
|
// #75637# This line changes the modified state of the model
|
2004-10-04 16:54:47 +00:00
|
|
|
SetGraphic_Impl( NULL );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// #75637# if status was not set before, force it back
|
|
|
|
// to not set, so that SetGraphic(0L) above does not
|
|
|
|
// set the modified state of the model.
|
|
|
|
if(!bWasChanged && pModel && pModel->IsChanged())
|
2003-11-24 15:57:52 +00:00
|
|
|
{
|
|
|
|
pModel->SetChanged( sal_False );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
sal_Int64 nMiscStatus = xObjRef->getStatus( GetAspect() );
|
2006-06-19 15:43:13 +00:00
|
|
|
(void)nMiscStatus;
|
2004-10-04 16:54:47 +00:00
|
|
|
//TODO/LATER: wait until ResizeOnPrinterChange is defined
|
|
|
|
//if ( nMiscStatus & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (pModel && pModel->GetRefDevice() &&
|
|
|
|
pModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER)
|
|
|
|
{
|
2001-04-11 08:30:44 +00:00
|
|
|
if(!bInDestruction)
|
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
//TODO/LATER: printerchange notification
|
|
|
|
/*
|
2001-08-17 12:48:26 +00:00
|
|
|
// prevent SetModified (don't want no update here)
|
|
|
|
sal_Bool bWasEnabled = (*ppObjRef)->IsEnableSetModified();
|
|
|
|
if ( bWasEnabled )
|
|
|
|
(*ppObjRef)->EnableSetModified( sal_False );
|
|
|
|
|
2001-04-11 08:30:44 +00:00
|
|
|
// Kein RefDevice oder RefDevice kein Printer
|
|
|
|
Printer* pPrinter = (Printer*) pModel->GetRefDevice();
|
|
|
|
(*ppObjRef)->OnDocumentPrinterChanged( pPrinter );
|
2001-08-17 12:48:26 +00:00
|
|
|
|
|
|
|
// reset state
|
2004-10-04 16:54:47 +00:00
|
|
|
(*ppObjRef)->EnableSetModified( bWasEnabled );*/
|
2001-04-11 08:30:44 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( xObjRef.is() )
|
|
|
|
Connect();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-11-26 15:33:16 +00:00
|
|
|
|
|
|
|
if ( mpImpl->mbConnected )
|
|
|
|
// move object to first position in cache
|
|
|
|
GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
|
2004-10-04 16:54:47 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
uno::Reference < embed::XEmbeddedObject > SdrOle2Obj::GetObjRef() const
|
|
|
|
{
|
|
|
|
const_cast<SdrOle2Obj*>(this)->GetObjRef_Impl();
|
|
|
|
return xObjRef.GetObject();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
uno::Reference< frame::XModel > SdrOle2Obj::getXModel() const
|
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
GetObjRef();
|
2004-11-26 15:33:16 +00:00
|
|
|
if ( svt::EmbeddedObjectRef::TryRunningState(xObjRef.GetObject()) )
|
2004-10-04 16:54:47 +00:00
|
|
|
return uno::Reference< frame::XModel >( xObjRef->getComponent(), uno::UNO_QUERY );
|
|
|
|
else
|
|
|
|
return uno::Reference< frame::XModel >();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-10 11:59:59 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2003-11-24 15:57:52 +00:00
|
|
|
// #109985#
|
|
|
|
sal_Bool SdrOle2Obj::IsChart() const
|
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
if ( !xObjRef.is() )
|
|
|
|
return false;
|
2003-11-24 15:57:52 +00:00
|
|
|
|
2004-10-04 16:54:47 +00:00
|
|
|
SvGlobalName aObjClsId( xObjRef->getClassID() );
|
|
|
|
if(
|
|
|
|
SvGlobalName(SO3_SCH_CLASSID_30) == aObjClsId
|
|
|
|
|| SvGlobalName(SO3_SCH_CLASSID_40) == aObjClsId
|
|
|
|
|| SvGlobalName(SO3_SCH_CLASSID_50) == aObjClsId
|
|
|
|
|| SvGlobalName(SO3_SCH_CLASSID_60) == aObjClsId)
|
2003-11-24 15:57:52 +00:00
|
|
|
{
|
2004-10-04 16:54:47 +00:00
|
|
|
return sal_True;
|
2003-11-24 15:57:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-02-01 18:02:05 +00:00
|
|
|
void SdrOle2Obj::SetGraphicToObj( const Graphic& aGraphic, const ::rtl::OUString& aMediaType )
|
|
|
|
{
|
|
|
|
xObjRef.SetGraphic( aGraphic, aMediaType );
|
|
|
|
}
|
2003-11-24 15:57:52 +00:00
|
|
|
|
2006-10-13 10:23:44 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SdrOle2Obj::SetGraphicToObj( const uno::Reference< io::XInputStream >& xGrStream, const ::rtl::OUString& aMediaType )
|
|
|
|
{
|
|
|
|
xObjRef.SetGraphicStream( xGrStream, aMediaType );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-01-10 13:50:54 +00:00
|
|
|
sal_Bool SdrOle2Obj::IsCalc() const
|
|
|
|
{
|
|
|
|
if ( !xObjRef.is() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SvGlobalName aObjClsId( xObjRef->getClassID() );
|
|
|
|
if( SvGlobalName(SO3_SC_CLASSID_30) == aObjClsId
|
|
|
|
|| SvGlobalName(SO3_SC_CLASSID_40) == aObjClsId
|
|
|
|
|| SvGlobalName(SO3_SC_CLASSID_50) == aObjClsId
|
|
|
|
|| SvGlobalName(SO3_SC_CLASSID_60) == aObjClsId
|
|
|
|
|| SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_60) == aObjClsId
|
|
|
|
|| SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_8) == aObjClsId
|
|
|
|
|| SvGlobalName(SO3_SC_CLASSID) == aObjClsId )
|
|
|
|
{
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sal_False;
|
|
|
|
}
|
2006-10-13 10:23:44 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
uno::Reference< frame::XModel > SdrOle2Obj::GetParentXModel()
|
|
|
|
{
|
|
|
|
uno::Reference< frame::XModel > xResult;
|
|
|
|
|
|
|
|
SfxObjectShell* pPers = pModel ? pModel->GetPersist() : NULL;
|
|
|
|
if ( pPers )
|
|
|
|
xResult = pPers->GetModel();
|
|
|
|
|
|
|
|
return xResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize )
|
|
|
|
{
|
|
|
|
// TODO/LEAN: to avoid rounding errors scaling always uses the VisArea.
|
|
|
|
// If we don't cache it for own objects also we must load the object here
|
|
|
|
if ( !xObjRef.is() || !pModel )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
MapMode aMapMode( pModel->GetScaleUnit() );
|
|
|
|
aObjAreaSize = xObjRef.GetSize( &aMapMode );
|
|
|
|
|
|
|
|
Size aSize = aRect.GetSize();
|
|
|
|
aScaleWidth = Fraction(aSize.Width(), aObjAreaSize.Width() );
|
|
|
|
aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() );
|
|
|
|
|
|
|
|
// reduce to 10 binary digits
|
|
|
|
Kuerzen(aScaleHeight, 10);
|
|
|
|
Kuerzen(aScaleWidth, 10);
|
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
2006-01-10 13:50:54 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2006-10-13 10:23:44 +00:00
|
|
|
sal_Bool SdrOle2Obj::AddOwnLightClient()
|
|
|
|
{
|
|
|
|
// The Own Light Client must be registered in object only using this method!
|
|
|
|
Connect();
|
|
|
|
|
|
|
|
if ( xObjRef.is() && mpImpl->pLightClient )
|
|
|
|
{
|
|
|
|
Fraction aScaleWidth;
|
|
|
|
Fraction aScaleHeight;
|
|
|
|
Size aObjAreaSize;
|
|
|
|
if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
|
|
|
|
{
|
|
|
|
mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
|
|
|
|
try {
|
|
|
|
xObjRef->setClientSite( mpImpl->pLightClient );
|
|
|
|
return sal_True;
|
|
|
|
} catch( uno::Exception& )
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return sal_False;
|
|
|
|
}
|
2006-01-10 13:50:54 +00:00
|
|
|
|
2003-11-24 15:57:52 +00:00
|
|
|
// eof
|