summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/svdoole2.cxx
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de (CIB)>2018-03-01 15:54:32 +0100
committerArmin Le Grand <Armin.Le.Grand@cib.de>2018-04-07 00:28:30 +0200
commitdfefe448c41921f2f1e54d3f69b8b9e89031d055 (patch)
tree1aace31054b5740e2faffcbc5de66a791be27f7d /svx/source/svdraw/svdoole2.cxx
parenteba4d5b2b76cefde90cb3d6638c736f435023a45 (diff)
SOSAW080: Added first bunch of basic changes to helpers
SOSAW080: Make SdrModel& prerequisite to SdrObjects Added need for SdrModel& in constructors of SdrModel, SdrPage, SdrView and SdrObjList. Builds, not finished. SOSAW080: removed and replaced old SdrModel Removed and replaced GetModel()/SetModel() in all using classes (SdrObject, SdrPage, SdrView), added accessors to new referenced SdrModel, adapted all accessing places. Refactored/Extended ::Clone and ::operator== for these classes to allow cloning objects to a target SdrModel. Adapted places where this is done AFAP. Added quite some comments (tagged with 'TTTT') where possible further work is needed. Builds completely, thus checking in. This does not mean that this change is done yet. SOSAW080: Adapted SdrPage/SdrModel relationship Also needed to work on copy-construction of SdrPage and hierarchy, quite some stuff removed, no copy-constructor anymore, no MigrateItemPool stuff. Builds well, test stuck, will need some cleanup/finetunung SOSAW080: Smaller corrections/includes adapted SOSAW080: Smaller corrections/includes adapted SOSAW080: Debugging/Stabilizing/MakeUnitTestWork SOSAW080: Stabilized for UnitTests, cleanups SOSAW080: Adapted GetObjGraphic to just take a const SdrObject& SOSAW080: Removed ChangeModel from classes Classes SvxTextEditSource and SvxDrawPage (including TextEditSource stuff) do not need change of SdrModel anymore. SOSAW080: Adapted some comments to make more readable SOSAW080: Corrected constructor SOSAW080: getSdrModelFromUnoModel added override marks SOSAW080: Added missing includes SOSAW080: Corrected SdrPage constructor SOSAW080: Corrected some SdrObject::Clone scenarios Especially when cloning to another SdrModel and taking the sdr::properties into account. SOSAW080: Added include for Mac-Build SOSAW080: Added Scale to DefaultProperties If a SdrModel change happens in DefaultProperties copy constructor (used from Clone()), potentially a Scale for the SfxItems has to be done. SOSAW080: Added missing include for MacBuild SOSAW080: Corrected CppunitTest_sc_anchor_test An adaption of a SdrPathObj instantiation was missing, added that. Seems as if that test is no tpart of the usual 'make' scenario, but used/executed in gerrit builds SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Reworked SvxShape to use SdrObject's SdrModel SOSAW080: Free SdrObjects when SdrModel goes down In an UNO API test problem is that SvxShapes reference SdrShapes, but these are not added to a SdrPage and not 'owned' by the SvxShape. Thus these do not get deleted at all (same in master, memory leak). I extended SvxShape::Notify the case for ModelCleared to also Free the SdrObject when not owner and it's not added to a SdrPage (in that case it gets deleted with deleting the SdrModel) SOSAW080: Solve UNO API calls that move SvxShapes to other Model Due to UNO API tests I got a call to insert an xShape to a xDrawPage which was constructed in another Model, this has now to be done by Cloning the SdrObject to the new SdrModel, getting rid of the old one and getting all the UNO implementation stuff right (referemces SdrObject <-> xShape). 1cb7d573d323e98a89761fe662c10c4a654fdec0 24617494a0ef79f6e33dfcb02782a833a81c6434 763f39094b6a48b529a6952d01468f8776c97679 242b9e228a9a042c3a5bdd38b1ea6600144276d5 242b9e228a9a042c3a5bdd38b1ea6600144276d5 33a6f3f306b70c223171aef796dd5ee041ad14df 6878b33f8b05738a44c0910e40a60a0f0d1d58ed 0a636caf3cb36c2f9c6cd11aa22cb9bc435dc8f2 8c4626274a5cc531dad27f27c0c45d4c528fb2fb 446685a49a6d67aedd01cfbbd5e87b07f97a4d7b c1b5ed3c99bc7219a0061e4ece24ea42afd2889a 22de9a1c8af7c25be5c108671ddc548ba323ed47 4caf6b6fbbe6e8130741d793dffb560fd01d4ed5 488b9601735ec1822433f82f633990063951fe08 c366d60299f239e3df856ddffedb19e743e4be0c c5137ba8c597c7b5f90318df50e87b93a39a28dc f9e646242cf89f6fde1315046952252a2c429779 f830fbc5fadd89d04be5edd2a5abf9b0d4bf0410 1694b54903df784385abaa8452e1201e12344238 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 17bcb44d2e29920c0c74430c2d9c703b36cfa0ad 7b5c241faec7488924e5935ae8b19f785846b5e4 bf097ee7467895823fbd158a2a9543da3b5a5078 Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c Reviewed-on: https://gerrit.libreoffice.org/52526 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'svx/source/svdraw/svdoole2.cxx')
-rw-r--r--svx/source/svdraw/svdoole2.cxx348
1 files changed, 173 insertions, 175 deletions
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index 8a264270bddf..50595c5766df 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -663,13 +663,42 @@ sdr::contact::ViewContact* SdrOle2Obj::CreateObjectSpecificViewContact()
return new sdr::contact::ViewContactOfSdrOle2Obj(*this);
}
-SdrOle2Obj::SdrOle2Obj( bool bFrame_ ) :
+void SdrOle2Obj::Init()
+{
+ // Stuff that was done from old SetModel:
+ // #i43086# #i85304 redo the change for charts for the above bugfix, as #i43086# does not occur anymore
+ // so maybe the ImpSetVisAreaSize call can be removed here completely
+ // Nevertheless I leave it in for other objects as I am not sure about the side effects when removing now
+ if(!getSdrModelFromSdrObject().isLocked() && !IsChart())
+ {
+ ImpSetVisAreaSize();
+ }
+
+ ::comphelper::IEmbeddedHelper* pDestPers(getSdrModelFromSdrObject().GetPersist());
+ if(pDestPers && !IsEmptyPresObj())
+ {
+ // object wasn't connected, now it should be
+ Connect_Impl();
+ }
+
+ AddListeners_Impl();
+}
+
+SdrOle2Obj::SdrOle2Obj(
+ SdrModel& rSdrModel,
+ bool bFrame_)
+: SdrRectObj(rSdrModel),
mpImpl(new SdrOle2ObjImpl(bFrame_))
{
+ Init();
}
-SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, const OUString& rNewObjName, const tools::Rectangle& rNewRect) :
- SdrRectObj(rNewRect),
+SdrOle2Obj::SdrOle2Obj(
+ SdrModel& rSdrModel,
+ const svt::EmbeddedObjectRef& rNewObjRef,
+ const OUString& rNewObjName,
+ const tools::Rectangle& rNewRect)
+: SdrRectObj(rSdrModel, rNewRect),
mpImpl(new SdrOle2ObjImpl(false/*bFrame_*/, rNewObjRef))
{
mpImpl->aPersistName = rNewObjName;
@@ -679,6 +708,8 @@ SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, const OUStrin
// For math objects, set closed state to transparent
SetClosedObj(!ImplIsMathObj( mpImpl->mxObjRef.GetObject() ));
+
+ Init();
}
OUString SdrOle2Obj::GetStyleString()
@@ -781,7 +812,8 @@ bool SdrOle2Obj::UpdateLinkURL_Impl()
if ( mpImpl->mpObjectLink )
{
- sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : nullptr;
+ sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
+
if ( pLinkManager )
{
OUString aNewLinkURL;
@@ -831,9 +863,7 @@ bool SdrOle2Obj::UpdateLinkURL_Impl()
void SdrOle2Obj::BreakFileLink_Impl()
{
- uno::Reference<document::XStorageBasedDocument> xDoc;
- if ( pModel )
- xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
+ uno::Reference<document::XStorageBasedDocument> xDoc(getSdrModelFromSdrObject().getUnoModel(), uno::UNO_QUERY);
if ( xDoc.is() )
{
@@ -858,7 +888,8 @@ void SdrOle2Obj::BreakFileLink_Impl()
void SdrOle2Obj::DisconnectFileLink_Impl()
{
- sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : nullptr;
+ sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
+
if ( pLinkManager && mpImpl->mpObjectLink )
{
pLinkManager->Remove( mpImpl->mpObjectLink );
@@ -868,18 +899,21 @@ void SdrOle2Obj::DisconnectFileLink_Impl()
void SdrOle2Obj::CheckFileLink_Impl()
{
- if (pModel && mpImpl->mxObjRef.GetObject().is() && !mpImpl->mpObjectLink)
+ if (mpImpl->mxObjRef.GetObject().is() && !mpImpl->mpObjectLink)
{
try
{
uno::Reference< embed::XLinkageSupport > xLinkSupport( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY );
+
if ( xLinkSupport.is() && xLinkSupport->isLink() )
{
OUString aLinkURL = xLinkSupport->getLinkURL();
+
if ( !aLinkURL.isEmpty() )
{
// this is a file link so the model link manager should handle it
- sfx2::LinkManager* pLinkManager = pModel->GetLinkManager();
+ sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
+
if ( pLinkManager )
{
mpImpl->mpObjectLink = new SdrEmbedObjectLink( this );
@@ -905,14 +939,16 @@ void SdrOle2Obj::Reconnect_Impl()
void SdrOle2Obj::Connect_Impl()
{
- if( pModel && !mpImpl->aPersistName.isEmpty() )
+ if(!mpImpl->aPersistName.isEmpty() )
{
try
{
- ::comphelper::IEmbeddedHelper* pPers = pModel->GetPersist();
+ ::comphelper::IEmbeddedHelper* pPers(getSdrModelFromSdrObject().GetPersist());
+
if ( pPers )
{
comphelper::EmbeddedObjectContainer& rContainer = pPers->getEmbeddedObjectContainer();
+
if ( !rContainer.HasEmbeddedObject( mpImpl->aPersistName )
|| ( mpImpl->mxObjRef.is() && !rContainer.HasEmbeddedObject( mpImpl->mxObjRef.GetObject() ) ) )
{
@@ -957,9 +993,9 @@ void SdrOle2Obj::Connect_Impl()
uno::Reference< container::XChild > xChild( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY );
if( xChild.is() )
{
- uno::Reference< uno::XInterface > xParent( pModel->getUnoModel());
+ uno::Reference< uno::XInterface > xParent( getSdrModelFromSdrObject().getUnoModel());
if( xParent.is())
- xChild->setParent( pModel->getUnoModel() );
+ xChild->setParent( getSdrModelFromSdrObject().getUnoModel() );
}
}
@@ -1040,9 +1076,9 @@ void SdrOle2Obj::Disconnect_Impl()
{
try
{
- if ( pModel && !mpImpl->aPersistName.isEmpty() )
+ if ( !mpImpl->aPersistName.isEmpty() )
{
- if( pModel->IsInDestruction() )
+ if( getSdrModelFromSdrObject().IsInDestruction() )
{
// 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
@@ -1078,7 +1114,7 @@ void SdrOle2Obj::Disconnect_Impl()
}
else if ( mpImpl->mxObjRef.is() )
{
- if ( pModel->getUnoModel().is() )
+ if ( getSdrModelFromSdrObject().getUnoModel().is() )
{
// remove object, but don't close it (that's up to someone else)
comphelper::EmbeddedObjectContainer* pContainer = mpImpl->mxObjRef.GetContainer();
@@ -1122,8 +1158,9 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
if(pOLEGraphic)
{
// #i118485# allow creating a SdrGrafObj representation
- SdrGrafObj* pClone = new SdrGrafObj(*pOLEGraphic);
- pClone->SetModel(GetModel());
+ SdrGrafObj* pClone = new SdrGrafObj(
+ getSdrModelFromSdrObject(),
+ *pOLEGraphic);
// copy transformation
basegfx::B2DHomMatrix aMatrix;
@@ -1141,7 +1178,7 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
// #i118485# copy text (Caution! Model needed, as guaranteed in aw080)
OutlinerParaObject* pOPO = GetOutlinerParaObject();
- if(pOPO && GetModel())
+ if(pOPO)
{
pClone->NbcSetOutlinerParaObject(new OutlinerParaObject(*pOPO));
}
@@ -1153,8 +1190,9 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
{
// #i100710# pOLEGraphic may be zero (no visualisation available),
// so we need to use the OLE replacement graphic
- SdrRectObj* pClone = new SdrRectObj(GetSnapRect());
- pClone->SetModel(GetModel());
+ SdrRectObj* pClone = new SdrRectObj(
+ getSdrModelFromSdrObject(),
+ GetSnapRect());
// gray outline
pClone->SetMergedItem(XLineStyleItem(css::drawing::LineStyle_SOLID));
@@ -1175,90 +1213,17 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
SdrObject* SdrOle2Obj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
// #i118485# missing converter added
- if(GetModel())
- {
- SdrObject* pRetval = createSdrGrafObjReplacement(true);
-
- if(pRetval)
- {
- SdrObject* pRetval2 = pRetval->DoConvertToPolyObj(bBezier, bAddText);
- SdrObject::Free(pRetval);
-
- return pRetval2;
- }
- }
+ SdrObject* pRetval = createSdrGrafObjReplacement(true);
- return nullptr;
-}
-
-void SdrOle2Obj::SetModel(SdrModel* pNewModel)
-{
- ::comphelper::IEmbeddedHelper* pDestPers = pNewModel ? pNewModel->GetPersist() : nullptr;
- ::comphelper::IEmbeddedHelper* pSrcPers = pModel ? pModel->GetPersist() : nullptr;
-
- if ( pNewModel == pModel )
- {
- // don't know if this is necessary or if it will ever happen, but who knows?!
- SdrRectObj::SetModel( pNewModel );
- return;
- }
-
- // assignment to model has changed
- DBG_ASSERT( pSrcPers || !mpImpl->mbConnected, "Connected object without a model?!" );
-
- 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;
-
- RemoveListeners_Impl();
-
- if( pDestPers && pSrcPers && !IsEmptyPresObj() )
+ if(pRetval)
{
- try
- {
- // move the object's storage; ObjectRef remains the same, but PersistName may change
- OUString aTmp;
- comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
- uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
- DBG_ASSERT( !mpImpl->mxObjRef.is() || mpImpl->mxObjRef.GetObject() == xObj, "Wrong object identity!" );
- if ( xObj.is() )
- {
- pDestPers->getEmbeddedObjectContainer().MoveEmbeddedObject( rContainer, xObj, aTmp );
- mpImpl->aPersistName = aTmp;
- mpImpl->mxObjRef.AssignToContainer( &pDestPers->getEmbeddedObjectContainer(), aTmp );
- }
- DBG_ASSERT( !aTmp.isEmpty(), "Copying embedded object failed!" );
- }
- catch( css::uno::Exception& )
- {
- SAL_WARN( "svx", "SdrOle2Obj::SetModel(), exception caught: "
- << comphelper::anyToString( cppu::getCaughtException() ) );
- }
- }
-
- SdrRectObj::SetModel( pNewModel );
+ SdrObject* pRetval2 = pRetval->DoConvertToPolyObj(bBezier, bAddText);
+ SdrObject::Free(pRetval);
- // #i43086#
- // #i85304 redo the change for charts for the above bugfix, as #i43086# does not occur anymore
- //so maybe the ImpSetVisAreaSize call can be removed here completely
- //Nevertheless I leave it in for other objects as I am not sure about the side effects when removing now
- if( pModel && !pModel->isLocked() && !IsChart() )
- ImpSetVisAreaSize();
-
- if( pDestPers && !IsEmptyPresObj() )
- {
- if ( !pSrcPers || IsEmptyPresObj() )
- // object wasn't connected, now it should be
- Connect_Impl();
- else
- Reconnect_Impl();
+ return pRetval2;
}
- AddListeners_Impl();
+ return nullptr;
}
void SdrOle2Obj::SetPage(SdrPage* pNewPage)
@@ -1269,14 +1234,14 @@ void SdrOle2Obj::SetPage(SdrPage* pNewPage)
if (bRemove && mpImpl->mbConnected )
Disconnect();
- if(!pModel && !GetStyleSheet() && pNewPage && pNewPage->GetModel())
+ if(!GetStyleSheet() && pNewPage)
{
// #i119287# Set default StyleSheet for SdrGrafObj here, it is different from 'Default'. This
// needs to be done before the style 'Default' is set from the :SetModel() call which is triggered
// from the following :SetPage().
// TTTT: Needs to be moved in branch aw080 due to having a SdrModel from the beginning, is at this
// place for convenience currently (works in both versions, is not in the way)
- SfxStyleSheet* pSheet = pNewPage->GetModel()->GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj();
+ SfxStyleSheet* pSheet = pNewPage->getSdrModelFromSdrPage().GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj();
if(pSheet)
{
@@ -1414,65 +1379,68 @@ OUString SdrOle2Obj::TakeObjNamePlural() const
return ImpGetResStr(mpImpl->mbFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2);
}
-SdrOle2Obj* SdrOle2Obj::Clone() const
+SdrOle2Obj* SdrOle2Obj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrOle2Obj >();
+ return CloneHelper< SdrOle2Obj >(pTargetModel);
+}
+
+SdrOle2Obj& SdrOle2Obj::operator=(const SdrOle2Obj& rObj)
+{
+ return assignFrom(rObj);
}
SdrOle2Obj& SdrOle2Obj::assignFrom(const SdrOle2Obj& rObj)
{
//TODO/LATER: who takes over control of my old object?!
- if( &rObj != this )
+ if( &rObj == this )
{
- // ImpAssign( rObj );
- const SdrOle2Obj& rOle2Obj = rObj;
+ return *this;
+ }
+
+ // ImpAssign( rObj );
+ const SdrOle2Obj& rOle2Obj = rObj;
- if( pModel && mpImpl->mbConnected )
- Disconnect();
+ if( mpImpl->mbConnected )
+ Disconnect();
- SdrRectObj::operator=( rObj );
+ SdrRectObj::operator=( rObj );
- // Manually copying bClosedObj attribute
- SetClosedObj( rObj.IsClosedObj() );
+ // Manually copying bClosedObj attribute
+ SetClosedObj( rObj.IsClosedObj() );
- mpImpl->aPersistName = rOle2Obj.mpImpl->aPersistName;
- mpImpl->maProgName = rOle2Obj.mpImpl->maProgName;
- mpImpl->mbFrame = rOle2Obj.mpImpl->mbFrame;
+ mpImpl->aPersistName = rOle2Obj.mpImpl->aPersistName;
+ mpImpl->maProgName = rOle2Obj.mpImpl->maProgName;
+ mpImpl->mbFrame = rOle2Obj.mpImpl->mbFrame;
- if (rOle2Obj.mpImpl->mxGraphic)
- {
- mpImpl->mxGraphic.reset(new Graphic(*rOle2Obj.mpImpl->mxGraphic));
- }
+ if (rOle2Obj.mpImpl->mxGraphic)
+ {
+ mpImpl->mxGraphic.reset(new Graphic(*rOle2Obj.mpImpl->mxGraphic));
+ }
- if( pModel && rObj.GetModel() && !IsEmptyPresObj() )
+ if( !IsEmptyPresObj() )
+ {
+ ::comphelper::IEmbeddedHelper* pDestPers(getSdrModelFromSdrObject().GetPersist());
+ ::comphelper::IEmbeddedHelper* pSrcPers(rObj.getSdrModelFromSdrObject().GetPersist());
+ if( pDestPers && pSrcPers )
{
- ::comphelper::IEmbeddedHelper* pDestPers = pModel->GetPersist();
- ::comphelper::IEmbeddedHelper* pSrcPers = rObj.GetModel()->GetPersist();
- if( pDestPers && pSrcPers )
+ DBG_ASSERT( !mpImpl->mxObjRef.is(), "Object already existing!" );
+ comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
+ uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
+ if ( xObj.is() )
{
- DBG_ASSERT( !mpImpl->mxObjRef.is(), "Object already existing!" );
- comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
- uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
- if ( xObj.is() )
- {
- OUString aTmp;
- mpImpl->mxObjRef.Assign( pDestPers->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject(
- rContainer, xObj, aTmp, pSrcPers->getDocumentBaseURL(), pDestPers->getDocumentBaseURL()), rOle2Obj.GetAspect());
- mpImpl->mbTypeAsked = false;
- mpImpl->aPersistName = aTmp;
- CheckFileLink_Impl();
- }
-
- Connect();
+ OUString aTmp;
+ mpImpl->mxObjRef.Assign( pDestPers->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject(
+ rContainer, xObj, aTmp, pSrcPers->getDocumentBaseURL(), pDestPers->getDocumentBaseURL()), rOle2Obj.GetAspect());
+ mpImpl->mbTypeAsked = false;
+ mpImpl->aPersistName = aTmp;
+ CheckFileLink_Impl();
}
+
+ Connect();
}
}
- return *this;
-}
-SdrOle2Obj& SdrOle2Obj::operator=(const SdrOle2Obj& rObj)
-{
- return assignFrom(rObj);
+ return *this;
}
void SdrOle2Obj::ImpSetVisAreaSize()
@@ -1490,14 +1458,17 @@ void SdrOle2Obj::ImpSetVisAreaSize()
GetObjRef();
if (mpImpl->mxObjRef.is())
{
- OSL_ASSERT( pModel );
sal_Int64 nMiscStatus = mpImpl->mxObjRef->getStatus( GetAspect() );
// the client is required to get access to scaling
- SfxInPlaceClient* pClient = SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), mpImpl->mxObjRef.GetObject() );
- bool bHasOwnClient =
- ( mpImpl->mxLightClient.is()
- && mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient.get() ) );
+ SfxInPlaceClient* pClient(
+ SfxInPlaceClient::GetClient(
+ dynamic_cast<SfxObjectShell*>(
+ getSdrModelFromSdrObject().GetPersist()),
+ mpImpl->mxObjRef.GetObject()));
+ const bool bHasOwnClient(
+ mpImpl->mxLightClient.is() &&
+ mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient.get() ) );
if ( pClient || bHasOwnClient )
{
@@ -1529,7 +1500,10 @@ void SdrOle2Obj::ImpSetVisAreaSize()
Size aVisSize( static_cast<long>( Fraction( maRect.GetWidth() ) / aScaleWidth ),
static_cast<long>( Fraction( maRect.GetHeight() ) / aScaleHeight ) );
- aVisSize = OutputDevice::LogicToLogic(aVisSize, MapMode(pModel->GetScaleUnit()), MapMode(aMapUnit));
+ aVisSize = OutputDevice::LogicToLogic(
+ aVisSize,
+ MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
+ MapMode(aMapUnit));
awt::Size aSz;
aSz.Width = aVisSize.Width();
aSz.Height = aVisSize.Height();
@@ -1550,7 +1524,11 @@ void SdrOle2Obj::ImpSetVisAreaSize()
// server changed VisArea to its liking and the VisArea is different than the suggested one
// store the new value as given by the object
MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) );
- maRect.SetSize(OutputDevice::LogicToLogic(aAcceptedVisArea.GetSize(), MapMode(aNewMapUnit), MapMode(pModel->GetScaleUnit())));
+ maRect.SetSize(
+ OutputDevice::LogicToLogic(
+ aAcceptedVisArea.GetSize(),
+ MapMode(aNewMapUnit),
+ MapMode(getSdrModelFromSdrObject().GetScaleUnit())));
}
// make the new object area known to the client
@@ -1596,13 +1574,30 @@ void SdrOle2Obj::ImpSetVisAreaSize()
uno::Reference< embed::XVisualObject > xVisualObject( getXModel(), uno::UNO_QUERY );
if( xVisualObject.is() )
{
- MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) );
- Point aTL( maRect.TopLeft() );
- Point aBR( maRect.BottomRight() );
- Point aTL2(OutputDevice::LogicToLogic(aTL, MapMode(pModel->GetScaleUnit()), MapMode(aMapUnit)));
- Point aBR2(OutputDevice::LogicToLogic(aBR, MapMode(pModel->GetScaleUnit()), MapMode(aMapUnit)));
- tools::Rectangle aNewRect( aTL2, aBR2 );
- xVisualObject->setVisualAreaSize( GetAspect(), awt::Size( aNewRect.GetWidth(), aNewRect.GetHeight() ) );
+ const MapUnit aMapUnit(
+ VCLUnoHelper::UnoEmbed2VCLMapUnit(
+ mpImpl->mxObjRef->getMapUnit(GetAspect())));
+ const Point aTL( maRect.TopLeft() );
+ const Point aBR( maRect.BottomRight() );
+ const Point aTL2(
+ OutputDevice::LogicToLogic(
+ aTL,
+ MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
+ MapMode(aMapUnit)));
+ const Point aBR2(
+ OutputDevice::LogicToLogic(
+ aBR,
+ MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
+ MapMode(aMapUnit)));
+ const tools::Rectangle aNewRect(
+ aTL2,
+ aBR2);
+
+ xVisualObject->setVisualAreaSize(
+ GetAspect(),
+ awt::Size(
+ aNewRect.GetWidth(),
+ aNewRect.GetHeight()));
}
}
}
@@ -1610,9 +1605,10 @@ void SdrOle2Obj::ImpSetVisAreaSize()
void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
{
- if( pModel && !pModel->isLocked() )
+ if(!getSdrModelFromSdrObject().isLocked())
{
GetObjRef();
+
if ( mpImpl->mxObjRef.is() && ( mpImpl->mxObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
{
// if the object needs recompose on resize
@@ -1623,7 +1619,8 @@ void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract
}
SdrRectObj::NbcResize(rRef,xFact,yFact);
- if( pModel && !pModel->isLocked() )
+
+ if( !getSdrModelFromSdrObject().isLocked() )
ImpSetVisAreaSize();
}
@@ -1631,7 +1628,7 @@ void SdrOle2Obj::SetGeoData(const SdrObjGeoData& rGeo)
{
SdrRectObj::SetGeoData(rGeo);
- if( pModel && !pModel->isLocked() )
+ if( !getSdrModelFromSdrObject().isLocked() )
ImpSetVisAreaSize();
}
@@ -1639,7 +1636,7 @@ void SdrOle2Obj::NbcSetSnapRect(const tools::Rectangle& rRect)
{
SdrRectObj::NbcSetSnapRect(rRect);
- if( pModel && !pModel->isLocked() )
+ if( !getSdrModelFromSdrObject().isLocked() )
ImpSetVisAreaSize();
if ( mpImpl->mxObjRef.is() && IsChart() )
@@ -1655,7 +1652,7 @@ void SdrOle2Obj::NbcSetLogicRect(const tools::Rectangle& rRect)
{
SdrRectObj::NbcSetLogicRect(rRect);
- if( pModel && !pModel->isLocked() )
+ if( !getSdrModelFromSdrObject().isLocked() )
ImpSetVisAreaSize();
}
@@ -1686,7 +1683,7 @@ void SdrOle2Obj::NbcMove(const Size& rSize)
{
SdrRectObj::NbcMove(rSize);
- if( pModel && !pModel->isLocked() )
+ if( !getSdrModelFromSdrObject().isLocked() )
ImpSetVisAreaSize();
}
@@ -1758,7 +1755,8 @@ bool SdrOle2Obj::Unload()
return true;
bool bUnloaded = false;
- if ( pModel && mpImpl->mxObjRef.is() )
+
+ if ( mpImpl->mxObjRef.is() )
{
bUnloaded = Unload( mpImpl->mxObjRef.GetObject(), GetAspect() );
}
@@ -1768,12 +1766,14 @@ bool SdrOle2Obj::Unload()
void SdrOle2Obj::GetObjRef_Impl()
{
- if ( !mpImpl->mxObjRef.is() && !mpImpl->aPersistName.isEmpty() && pModel && pModel->GetPersist() )
+ if ( !mpImpl->mxObjRef.is() && !mpImpl->aPersistName.isEmpty() && getSdrModelFromSdrObject().GetPersist() )
{
// Only try loading if it did not went wrong up to now
if(!mpImpl->mbLoadingOLEObjectFailed)
{
- mpImpl->mxObjRef.Assign( pModel->GetPersist()->getEmbeddedObjectContainer().GetEmbeddedObject( mpImpl->aPersistName ), GetAspect() );
+ mpImpl->mxObjRef.Assign(
+ getSdrModelFromSdrObject().GetPersist()->getEmbeddedObjectContainer().GetEmbeddedObject(mpImpl->aPersistName),
+ GetAspect());
mpImpl->mbTypeAsked = false;
CheckFileLink_Impl();
@@ -1793,7 +1793,7 @@ void SdrOle2Obj::GetObjRef_Impl()
if( !IsEmptyPresObj() )
{
// remember modified status of model
- const bool bWasChanged = pModel && pModel->IsChanged();
+ const bool bWasChanged(getSdrModelFromSdrObject().IsChanged());
// perhaps preview not valid anymore
// This line changes the modified state of the model
@@ -1802,9 +1802,9 @@ void SdrOle2Obj::GetObjRef_Impl()
// if status was not set before, force it back
// to not set, so that SetGraphic(0) above does not
// set the modified state of the model.
- if(!bWasChanged && pModel && pModel->IsChanged())
+ if(!bWasChanged && getSdrModelFromSdrObject().IsChanged())
{
- pModel->SetChanged( false );
+ getSdrModelFromSdrObject().SetChanged( false );
}
}
}
@@ -1889,9 +1889,7 @@ bool SdrOle2Obj::IsCalc() const
uno::Reference< frame::XModel > SdrOle2Obj::GetParentXModel() const
{
- uno::Reference< frame::XModel > xDoc;
- if ( pModel )
- xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
+ uno::Reference< frame::XModel > xDoc(getSdrModelFromSdrObject().getUnoModel(), uno::UNO_QUERY);
return xDoc;
}
@@ -1899,10 +1897,10 @@ bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHei
{
// 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 ( !mpImpl->mxObjRef.is() || !pModel )
+ if (!mpImpl->mxObjRef.is())
return false;
- MapMode aMapMode( pModel->GetScaleUnit() );
+ MapMode aMapMode(getSdrModelFromSdrObject().GetScaleUnit());
aObjAreaSize = mpImpl->mxObjRef.GetSize( &aMapMode );
Size aSize = maRect.GetSize();
@@ -1919,7 +1917,7 @@ bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHei
bool SdrOle2Obj::AddOwnLightClient()
{
// 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*>(getSdrModelFromSdrObject().GetPersist()), mpImpl->mxObjRef.GetObject() )
&& !( mpImpl->mxLightClient.is() && mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient.get() ) ) )
{
Connect();