use more rtl::Reference in SdrLightEmbeddedClient_Impl
instead of manual ref counting Change-Id: Ia07d5411c45d24934a619016cd8dbfb1fac6cc4b Reviewed-on: https://gerrit.libreoffice.org/43204 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -120,7 +120,6 @@ class SdrLightEmbeddedClient_Impl : public ::cppu::WeakImplHelper
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj );
|
explicit SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj );
|
||||||
void Release();
|
|
||||||
|
|
||||||
void SetSizeScale( const Fraction& aScaleWidth, const Fraction& aScaleHeight )
|
void SetSizeScale( const Fraction& aScaleWidth, const Fraction& aScaleHeight )
|
||||||
{
|
{
|
||||||
@@ -185,16 +184,6 @@ void SAL_CALL SdrLightEmbeddedClient_Impl::changingState( const css::lang::Event
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdrLightEmbeddedClient_Impl::Release()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
SolarMutexGuard aGuard;
|
|
||||||
mpObj = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SAL_CALL SdrLightEmbeddedClient_Impl::stateChanged( const css::lang::EventObject& /*aEvent*/, ::sal_Int32 nOldState, ::sal_Int32 nNewState )
|
void SAL_CALL SdrLightEmbeddedClient_Impl::stateChanged( const css::lang::EventObject& /*aEvent*/, ::sal_Int32 nOldState, ::sal_Int32 nNewState )
|
||||||
{
|
{
|
||||||
SolarMutexGuard aGuard;
|
SolarMutexGuard aGuard;
|
||||||
@@ -595,9 +584,9 @@ public:
|
|||||||
svt::EmbeddedObjectRef mxObjRef;
|
svt::EmbeddedObjectRef mxObjRef;
|
||||||
|
|
||||||
std::unique_ptr<Graphic> mxGraphic;
|
std::unique_ptr<Graphic> mxGraphic;
|
||||||
OUString maProgName;
|
OUString maProgName;
|
||||||
OUString aPersistName; // name of object in persist
|
OUString aPersistName; // name of object in persist
|
||||||
SdrLightEmbeddedClient_Impl* pLightClient; // must be registered as client only using AddOwnLightClient() call
|
rtl::Reference<SdrLightEmbeddedClient_Impl> mxLightClient; // must be registered as client only using AddOwnLightClient() call
|
||||||
|
|
||||||
bool mbFrame:1; // Due to compatibility at SdrTextObj for now
|
bool mbFrame:1; // Due to compatibility at SdrTextObj for now
|
||||||
bool mbSuppressSetVisAreaSize:1; // #i118524#
|
bool mbSuppressSetVisAreaSize:1; // #i118524#
|
||||||
@@ -612,7 +601,6 @@ public:
|
|||||||
rtl::Reference<SvxUnoShapeModifyListener> mxModifyListener;
|
rtl::Reference<SvxUnoShapeModifyListener> mxModifyListener;
|
||||||
|
|
||||||
explicit SdrOle2ObjImpl( bool bFrame ) :
|
explicit SdrOle2ObjImpl( bool bFrame ) :
|
||||||
pLightClient (nullptr),
|
|
||||||
mbFrame(bFrame),
|
mbFrame(bFrame),
|
||||||
mbSuppressSetVisAreaSize(false),
|
mbSuppressSetVisAreaSize(false),
|
||||||
mbTypeAsked(false),
|
mbTypeAsked(false),
|
||||||
@@ -626,7 +614,6 @@ public:
|
|||||||
|
|
||||||
SdrOle2ObjImpl( bool bFrame, const svt::EmbeddedObjectRef& rObjRef ) :
|
SdrOle2ObjImpl( bool bFrame, const svt::EmbeddedObjectRef& rObjRef ) :
|
||||||
mxObjRef(rObjRef),
|
mxObjRef(rObjRef),
|
||||||
pLightClient (nullptr),
|
|
||||||
mbFrame(bFrame),
|
mbFrame(bFrame),
|
||||||
mbSuppressSetVisAreaSize(false),
|
mbSuppressSetVisAreaSize(false),
|
||||||
mbTypeAsked(false),
|
mbTypeAsked(false),
|
||||||
@@ -713,11 +700,7 @@ SdrOle2Obj::~SdrOle2Obj()
|
|||||||
|
|
||||||
DisconnectFileLink_Impl();
|
DisconnectFileLink_Impl();
|
||||||
|
|
||||||
if ( mpImpl->pLightClient )
|
mpImpl->mxLightClient.clear();
|
||||||
{
|
|
||||||
mpImpl->pLightClient->Release();
|
|
||||||
mpImpl->pLightClient = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdrOle2Obj::SetAspect( sal_Int64 nAspect )
|
void SdrOle2Obj::SetAspect( sal_Int64 nAspect )
|
||||||
@@ -962,14 +945,11 @@ void SdrOle2Obj::Connect_Impl()
|
|||||||
|
|
||||||
if ( mpImpl->mxObjRef.is() )
|
if ( mpImpl->mxObjRef.is() )
|
||||||
{
|
{
|
||||||
if ( !mpImpl->pLightClient )
|
if ( !mpImpl->mxLightClient.is() )
|
||||||
{
|
mpImpl->mxLightClient = new SdrLightEmbeddedClient_Impl( this );
|
||||||
mpImpl->pLightClient = new SdrLightEmbeddedClient_Impl( this );
|
|
||||||
mpImpl->pLightClient->acquire();
|
|
||||||
}
|
|
||||||
|
|
||||||
mpImpl->mxObjRef->addStateChangeListener( mpImpl->pLightClient );
|
mpImpl->mxObjRef->addStateChangeListener( mpImpl->mxLightClient.get() );
|
||||||
mpImpl->mxObjRef->addEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
|
mpImpl->mxObjRef->addEventListener( uno::Reference< document::XEventListener >( mpImpl->mxLightClient.get() ) );
|
||||||
|
|
||||||
if ( mpImpl->mxObjRef->getCurrentState() != embed::EmbedStates::LOADED )
|
if ( mpImpl->mxObjRef->getCurrentState() != embed::EmbedStates::LOADED )
|
||||||
GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
|
GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
|
||||||
@@ -1119,10 +1099,10 @@ void SdrOle2Obj::Disconnect_Impl()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mpImpl->mxObjRef.is() && mpImpl->pLightClient )
|
if ( mpImpl->mxObjRef.is() && mpImpl->mxLightClient.is() )
|
||||||
{
|
{
|
||||||
mpImpl->mxObjRef->removeStateChangeListener ( mpImpl->pLightClient );
|
mpImpl->mxObjRef->removeStateChangeListener ( mpImpl->mxLightClient.get() );
|
||||||
mpImpl->mxObjRef->removeEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
|
mpImpl->mxObjRef->removeEventListener( uno::Reference< document::XEventListener >( mpImpl->mxLightClient.get() ) );
|
||||||
mpImpl->mxObjRef->setClientSite( nullptr );
|
mpImpl->mxObjRef->setClientSite( nullptr );
|
||||||
|
|
||||||
GetSdrGlobalData().GetOLEObjCache().RemoveObj(this);
|
GetSdrGlobalData().GetOLEObjCache().RemoveObj(this);
|
||||||
@@ -1518,8 +1498,8 @@ void SdrOle2Obj::ImpSetVisAreaSize()
|
|||||||
// the client is required to get access to scaling
|
// the client is required to get access to scaling
|
||||||
SfxInPlaceClient* pClient = SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), mpImpl->mxObjRef.GetObject() );
|
SfxInPlaceClient* pClient = SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), mpImpl->mxObjRef.GetObject() );
|
||||||
bool bHasOwnClient =
|
bool bHasOwnClient =
|
||||||
( mpImpl->pLightClient
|
( mpImpl->mxLightClient.is()
|
||||||
&& mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) );
|
&& mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient.get() ) );
|
||||||
|
|
||||||
if ( pClient || bHasOwnClient )
|
if ( pClient || bHasOwnClient )
|
||||||
{
|
{
|
||||||
@@ -1538,8 +1518,8 @@ void SdrOle2Obj::ImpSetVisAreaSize()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
aScaleWidth = mpImpl->pLightClient->GetScaleWidth();
|
aScaleWidth = mpImpl->mxLightClient->GetScaleWidth();
|
||||||
aScaleHeight = mpImpl->pLightClient->GetScaleHeight();
|
aScaleHeight = mpImpl->mxLightClient->GetScaleHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The object wants to resize itself (f.e. Chart wants to recalculate the layout)
|
// The object wants to resize itself (f.e. Chart wants to recalculate the layout)
|
||||||
@@ -1605,7 +1585,7 @@ void SdrOle2Obj::ImpSetVisAreaSize()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
|
mpImpl->mxLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1942,20 +1922,20 @@ bool SdrOle2Obj::AddOwnLightClient()
|
|||||||
{
|
{
|
||||||
// The Own Light Client must be registered in object only using this method!
|
// The Own Light Client must be registered in object only using this method!
|
||||||
if ( !SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), mpImpl->mxObjRef.GetObject() )
|
if ( !SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), mpImpl->mxObjRef.GetObject() )
|
||||||
&& !( mpImpl->pLightClient && mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) ) )
|
&& !( mpImpl->mxLightClient.is() && mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient.get() ) ) )
|
||||||
{
|
{
|
||||||
Connect();
|
Connect();
|
||||||
|
|
||||||
if ( mpImpl->mxObjRef.is() && mpImpl->pLightClient )
|
if ( mpImpl->mxObjRef.is() && mpImpl->mxLightClient.is() )
|
||||||
{
|
{
|
||||||
Fraction aScaleWidth;
|
Fraction aScaleWidth;
|
||||||
Fraction aScaleHeight;
|
Fraction aScaleHeight;
|
||||||
Size aObjAreaSize;
|
Size aObjAreaSize;
|
||||||
if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
|
if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
|
||||||
{
|
{
|
||||||
mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
|
mpImpl->mxLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
|
||||||
try {
|
try {
|
||||||
mpImpl->mxObjRef->setClientSite( mpImpl->pLightClient );
|
mpImpl->mxObjRef->setClientSite( mpImpl->mxLightClient.get() );
|
||||||
return true;
|
return true;
|
||||||
} catch( uno::Exception& )
|
} catch( uno::Exception& )
|
||||||
{}
|
{}
|
||||||
@@ -1976,9 +1956,9 @@ Graphic SdrOle2Obj::GetEmptyOLEReplacementGraphic()
|
|||||||
|
|
||||||
void SdrOle2Obj::SetWindow(const css::uno::Reference < css::awt::XWindow >& _xWindow)
|
void SdrOle2Obj::SetWindow(const css::uno::Reference < css::awt::XWindow >& _xWindow)
|
||||||
{
|
{
|
||||||
if ( mpImpl->mxObjRef.is() && mpImpl->pLightClient )
|
if ( mpImpl->mxObjRef.is() && mpImpl->mxLightClient.is() )
|
||||||
{
|
{
|
||||||
mpImpl->pLightClient->setWindow(_xWindow);
|
mpImpl->mxLightClient->setWindow(_xWindow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user