summaryrefslogtreecommitdiff
path: root/svx
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
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')
-rw-r--r--svx/inc/dragmt3d.hxx9
-rw-r--r--svx/inc/sdr/properties/attributeproperties.hxx16
-rw-r--r--svx/inc/sdr/properties/e3dsceneproperties.hxx3
-rw-r--r--svx/inc/sdr/properties/groupproperties.hxx3
-rw-r--r--svx/source/accessibility/AccessibleEmptyEditSource.cxx9
-rw-r--r--svx/source/accessibility/AccessibleGraphicShape.cxx2
-rw-r--r--svx/source/core/extedit.cxx9
-rw-r--r--svx/source/customshapes/EnhancedCustomShape2d.cxx16
-rw-r--r--svx/source/customshapes/EnhancedCustomShape3d.cxx54
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeEngine.cxx16
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFontWork.cxx6
-rw-r--r--svx/source/dialog/connctrl.cxx32
-rw-r--r--svx/source/dialog/contwnd.cxx5
-rw-r--r--svx/source/dialog/dlgctl3d.cxx10
-rw-r--r--svx/source/dialog/dlgctrl.cxx35
-rw-r--r--svx/source/dialog/graphctl.cxx2
-rw-r--r--svx/source/dialog/imapwnd.cxx32
-rw-r--r--svx/source/dialog/measctrl.cxx6
-rw-r--r--svx/source/engine3d/cube3d.cxx37
-rw-r--r--svx/source/engine3d/dragmt3d.cxx47
-rw-r--r--svx/source/engine3d/e3dsceneupdater.cxx35
-rw-r--r--svx/source/engine3d/e3dundo.cxx43
-rw-r--r--svx/source/engine3d/extrud3d.cxx37
-rw-r--r--svx/source/engine3d/lathe3d.cxx37
-rw-r--r--svx/source/engine3d/obj3d.cxx46
-rw-r--r--svx/source/engine3d/objfac3d.cxx19
-rw-r--r--svx/source/engine3d/polygn3d.cxx29
-rw-r--r--svx/source/engine3d/scene3d.cxx38
-rw-r--r--svx/source/engine3d/sphere3d.cxx46
-rw-r--r--svx/source/engine3d/view3d.cxx25
-rw-r--r--svx/source/form/fmdmod.cxx9
-rw-r--r--svx/source/form/fmdpage.cxx7
-rw-r--r--svx/source/form/fmobj.cxx51
-rw-r--r--svx/source/form/fmobjfac.cxx8
-rw-r--r--svx/source/form/fmpage.cxx82
-rw-r--r--svx/source/form/fmpgeimp.cxx52
-rw-r--r--svx/source/form/fmshimp.cxx11
-rw-r--r--svx/source/form/fmview.cxx8
-rw-r--r--svx/source/form/fmvwimp.cxx27
-rw-r--r--svx/source/gallery2/galobj.cxx2
-rw-r--r--svx/source/gallery2/galtheme.cxx4
-rw-r--r--svx/source/inc/cell.hxx2
-rw-r--r--svx/source/inc/fmobj.hxx13
-rw-r--r--svx/source/inc/tablemodel.hxx2
-rw-r--r--svx/source/sdr/contact/viewcontactofgraphic.cxx5
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrrectobj.cxx3
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofgraphic.cxx2
-rw-r--r--svx/source/sdr/primitive2d/sdrattributecreator.cxx4
-rw-r--r--svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx14
-rw-r--r--svx/source/sdr/properties/attributeproperties.cxx426
-rw-r--r--svx/source/sdr/properties/defaultproperties.cxx28
-rw-r--r--svx/source/sdr/properties/e3dsceneproperties.cxx25
-rw-r--r--svx/source/sdr/properties/groupproperties.cxx25
-rw-r--r--svx/source/sdr/properties/properties.cxx12
-rw-r--r--svx/source/sdr/properties/textproperties.cxx12
-rw-r--r--svx/source/svdraw/svdcrtv.cxx21
-rw-r--r--svx/source/svdraw/svddrgv.cxx6
-rw-r--r--svx/source/svdraw/svdedtv.cxx7
-rw-r--r--svx/source/svdraw/svdedtv2.cxx28
-rw-r--r--svx/source/svdraw/svdedxv.cxx23
-rw-r--r--svx/source/svdraw/svdetc.cxx6
-rw-r--r--svx/source/svdraw/svdfmtf.cxx126
-rw-r--r--svx/source/svdraw/svdglev.cxx8
-rw-r--r--svx/source/svdraw/svdhdl.cxx12
-rw-r--r--svx/source/svdraw/svdmodel.cxx45
-rw-r--r--svx/source/svdraw/svdmrkv.cxx8
-rw-r--r--svx/source/svdraw/svdoashp.cxx37
-rw-r--r--svx/source/svdraw/svdoattr.cxx22
-rw-r--r--svx/source/svdraw/svdobj.cxx504
-rw-r--r--svx/source/svdraw/svdocapt.cxx45
-rw-r--r--svx/source/svdraw/svdocirc.cxx43
-rw-r--r--svx/source/svdraw/svdoedge.cxx17
-rw-r--r--svx/source/svdraw/svdograf.cxx296
-rw-r--r--svx/source/svdraw/svdogrp.cxx195
-rw-r--r--svx/source/svdraw/svdomeas.cxx190
-rw-r--r--svx/source/svdraw/svdomedia.cxx48
-rw-r--r--svx/source/svdraw/svdoole2.cxx348
-rw-r--r--svx/source/svdraw/svdopage.cxx20
-rw-r--r--svx/source/svdraw/svdopath.cxx43
-rw-r--r--svx/source/svdraw/svdorect.cxx58
-rw-r--r--svx/source/svdraw/svdotext.cxx123
-rw-r--r--svx/source/svdraw/svdotextdecomposition.cxx5
-rw-r--r--svx/source/svdraw/svdotxat.cxx8
-rw-r--r--svx/source/svdraw/svdotxed.cxx10
-rw-r--r--svx/source/svdraw/svdotxln.cxx9
-rw-r--r--svx/source/svdraw/svdotxtr.cxx45
-rw-r--r--svx/source/svdraw/svdouno.cxx53
-rw-r--r--svx/source/svdraw/svdovirt.cxx59
-rw-r--r--svx/source/svdraw/svdpage.cxx313
-rw-r--r--svx/source/svdraw/svdpagv.cxx26
-rw-r--r--svx/source/svdraw/svdpntv.cxx11
-rw-r--r--svx/source/svdraw/svdpoev.cxx6
-rw-r--r--svx/source/svdraw/svdsnpv.cxx49
-rw-r--r--svx/source/svdraw/svdtext.cxx90
-rw-r--r--svx/source/svdraw/svdundo.cxx30
-rw-r--r--svx/source/svdraw/svdview.cxx8
-rw-r--r--svx/source/svdraw/svdviter.cxx4
-rw-r--r--svx/source/svdraw/svdxcgv.cxx150
-rw-r--r--svx/source/table/cell.cxx120
-rw-r--r--svx/source/table/cellcursor.cxx23
-rw-r--r--svx/source/table/svdotable.cxx125
-rw-r--r--svx/source/table/tablecolumn.cxx8
-rw-r--r--svx/source/table/tablecontroller.cxx981
-rw-r--r--svx/source/table/tablemodel.cxx74
-rw-r--r--svx/source/table/tablerow.cxx18
-rw-r--r--svx/source/table/tablertfimporter.cxx4
-rw-r--r--svx/source/table/tableundo.cxx54
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx8
-rw-r--r--svx/source/unodraw/UnoGraphicExporter.cxx53
-rw-r--r--svx/source/unodraw/tableshape.cxx34
-rw-r--r--svx/source/unodraw/unomod.cxx22
-rw-r--r--svx/source/unodraw/unopage.cxx128
-rw-r--r--svx/source/unodraw/unoshap2.cxx180
-rw-r--r--svx/source/unodraw/unoshap3.cxx182
-rw-r--r--svx/source/unodraw/unoshap4.cxx80
-rw-r--r--svx/source/unodraw/unoshape.cxx553
-rw-r--r--svx/source/unodraw/unoshtxt.cxx72
-rw-r--r--svx/source/unogallery/unogaltheme.cxx5
118 files changed, 3544 insertions, 3873 deletions
diff --git a/svx/inc/dragmt3d.hxx b/svx/inc/dragmt3d.hxx
index d8eba435c667..2ac1274fbb96 100644
--- a/svx/inc/dragmt3d.hxx
+++ b/svx/inc/dragmt3d.hxx
@@ -30,7 +30,7 @@
class E3dDragMethodUnit
{
public:
- E3dObject* mp3DObj;
+ E3dObject& mr3DObj;
basegfx::B3DPolyPolygon maWireframePoly;
basegfx::B3DHomMatrix maDisplayTransform;
basegfx::B3DHomMatrix maInvDisplayTransform;
@@ -39,8 +39,8 @@ public:
sal_Int32 mnStartAngle;
sal_Int32 mnLastAngle;
- E3dDragMethodUnit()
- : mp3DObj(nullptr),
+ E3dDragMethodUnit(E3dObject& r3DObj)
+ : mr3DObj(r3DObj),
maWireframePoly(),
maDisplayTransform(),
maInvDisplayTransform(),
@@ -48,7 +48,8 @@ public:
maTransform(),
mnStartAngle(0),
mnLastAngle(0)
- {}
+ {
+ }
};
// Derivative of SdrDragMethod for 3D objects
diff --git a/svx/inc/sdr/properties/attributeproperties.hxx b/svx/inc/sdr/properties/attributeproperties.hxx
index 603442634df2..d12374f31ee1 100644
--- a/svx/inc/sdr/properties/attributeproperties.hxx
+++ b/svx/inc/sdr/properties/attributeproperties.hxx
@@ -31,6 +31,12 @@ namespace sdr
{
class AttributeProperties : public DefaultProperties, public SfxListener, public svl::StyleSheetUser
{
+ // get the correct (#119287#) default SfyStyleSheet from SdrObject's SdrModel
+ SfxStyleSheet* ImpGetDefaultStyleSheet() const;
+
+ // core to set parent at SfxItemSet and to execute the hard attribute computations
+ void ImpSetParentAtSfxItemSet(bool bDontRemoveHardAttr);
+
// add style sheet, do all the necessary handling
void ImpAddStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr);
@@ -60,6 +66,10 @@ namespace sdr
// Clone() operator, normally just calls the local copy constructor
virtual BaseProperties& Clone(SdrObject& rObj) const override;
+ // Get the local ItemSet. This directly returns the local ItemSet of the object. No
+ // merging of ItemSets is done for e.g. Group objects.
+ virtual const SfxItemSet& GetObjectItemSet() const override;
+
// destructor
virtual ~AttributeProperties() override;
@@ -69,12 +79,6 @@ namespace sdr
// get the installed StyleSheet
virtual SfxStyleSheet* GetStyleSheet() const override;
- // Move properties to a new ItemPool.
- virtual void MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel) override;
-
- // Set new model.
- virtual void SetModel(SdrModel* pOldModel, SdrModel* pNewModel) override;
-
// force all attributes which come from styles to hard attributes
// to be able to live without the style.
virtual void ForceStyleToHardAttributes() override;
diff --git a/svx/inc/sdr/properties/e3dsceneproperties.hxx b/svx/inc/sdr/properties/e3dsceneproperties.hxx
index 3705fd684258..00d377766e01 100644
--- a/svx/inc/sdr/properties/e3dsceneproperties.hxx
+++ b/svx/inc/sdr/properties/e3dsceneproperties.hxx
@@ -68,9 +68,6 @@ namespace sdr
// get the installed StyleSheet
virtual SfxStyleSheet* GetStyleSheet() const override;
- // Move properties to a new ItemPool. Default implementation does nothing.
- virtual void MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel) override;
-
// Special for scene:
void SetSceneItemsFromCamera();
};
diff --git a/svx/inc/sdr/properties/groupproperties.hxx b/svx/inc/sdr/properties/groupproperties.hxx
index af197dc91360..9b6b28a73dc3 100644
--- a/svx/inc/sdr/properties/groupproperties.hxx
+++ b/svx/inc/sdr/properties/groupproperties.hxx
@@ -103,9 +103,6 @@ namespace sdr
// DefaultProperties::GetObjectItemSet() if a new ItemSet is created
virtual void ForceDefaultAttributes() override;
- // Move properties to a new ItemPool.
- virtual void MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel) override;
-
// force all attributes which come from styles to hard attributes
// to be able to live without the style.
virtual void ForceStyleToHardAttributes() override;
diff --git a/svx/source/accessibility/AccessibleEmptyEditSource.cxx b/svx/source/accessibility/AccessibleEmptyEditSource.cxx
index 6cbd41f35ce0..19a09ec8f502 100644
--- a/svx/source/accessibility/AccessibleEmptyEditSource.cxx
+++ b/svx/source/accessibility/AccessibleEmptyEditSource.cxx
@@ -218,8 +218,7 @@ namespace accessibility
mrViewWindow(rViewWindow),
mbEditSourceEmpty( true )
{
- if( mrObj.GetModel() )
- StartListening( *mrObj.GetModel() );
+ StartListening( mrObj.getSdrModelFromSdrObject() );
}
AccessibleEmptyEditSource::~AccessibleEmptyEditSource()
@@ -232,8 +231,7 @@ namespace accessibility
}
else
{
- if( mrObj.GetModel() )
- EndListening( *mrObj.GetModel() );
+ EndListening( mrObj.getSdrModelFromSdrObject() );
}
}
@@ -256,8 +254,7 @@ namespace accessibility
void AccessibleEmptyEditSource::Switch2ProxyEditSource()
{
// deregister EmptyEditSource model listener
- if( mrObj.GetModel() )
- EndListening( *mrObj.GetModel() );
+ EndListening( mrObj.getSdrModelFromSdrObject() );
::std::unique_ptr< SvxEditSource > pProxySource( new AccessibleProxyEditSource_Impl(mrObj, mrView, mrViewWindow) );
mpEditSource.swap(pProxySource);
diff --git a/svx/source/accessibility/AccessibleGraphicShape.cxx b/svx/source/accessibility/AccessibleGraphicShape.cxx
index 31c4690f5b97..fba25f4ad007 100644
--- a/svx/source/accessibility/AccessibleGraphicShape.cxx
+++ b/svx/source/accessibility/AccessibleGraphicShape.cxx
@@ -169,7 +169,7 @@ OUString AccessibleGraphicShape::CreateAccessibleDescription()
// Return this object's role.
sal_Int16 SAL_CALL AccessibleGraphicShape::getAccessibleRole()
{
- if( m_pShape->GetModel()->GetImageMapForObject(m_pShape) != nullptr )
+ if( m_pShape->getSdrModelFromSdrObject().GetImageMapForObject(m_pShape) != nullptr )
return AccessibleRole::IMAGE_MAP;
else
return AccessibleShape::getAccessibleRole();
diff --git a/svx/source/core/extedit.cxx b/svx/source/core/extedit.cxx
index a00216d40b16..dab305257299 100644
--- a/svx/source/core/extedit.cxx
+++ b/svx/source/core/extedit.cxx
@@ -154,12 +154,13 @@ void ExternalToolEdit::Edit(GraphicObject const*const pGraphicObject)
}
SdrExternalToolEdit::SdrExternalToolEdit(
- FmFormView *const pView, SdrObject *const pObj)
- : m_pView(pView)
- , m_pObj(pObj)
+ FmFormView* pView,
+ SdrObject* pObj)
+: m_pView(pView)
+ ,m_pObj(pObj)
{
assert(m_pObj && m_pView);
- StartListening(*m_pObj->GetModel());
+ StartListening(m_pObj->getSdrModelFromSdrObject());
}
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index 2386b5887d8f..f2a00feaad80 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -1980,7 +1980,10 @@ void EnhancedCustomShape2d::CreateSubPath(
{
basegfx::B2DPolyPolygon aClosedPolyPolygon(aNewB2DPolyPolygon);
aClosedPolyPolygon.setClosed(true);
- SdrPathObj* pFill = new SdrPathObj(OBJ_POLY, aClosedPolyPolygon);
+ SdrPathObj* pFill = new SdrPathObj(
+ mrSdrObjCustomShape.getSdrModelFromSdrObject(),
+ OBJ_POLY,
+ aClosedPolyPolygon);
SfxItemSet aTempSet(*this);
aTempSet.Put(makeSdrShadowItem(false));
aTempSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1995,6 +1998,7 @@ void EnhancedCustomShape2d::CreateSubPath(
// to correct the polygon (here: open it) using the type, the last edge may get lost.
// Thus, use a type that fits the polygon
SdrPathObj* pStroke = new SdrPathObj(
+ mrSdrObjCustomShape.getSdrModelFromSdrObject(),
aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
aNewB2DPolyPolygon);
SfxItemSet aTempSet(*this);
@@ -2014,6 +2018,7 @@ void EnhancedCustomShape2d::CreateSubPath(
{
// see comment above about OBJ_PLIN
pObj = new SdrPathObj(
+ mrSdrObjCustomShape.getSdrModelFromSdrObject(),
aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
aNewB2DPolyPolygon);
aTempSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
@@ -2021,7 +2026,10 @@ void EnhancedCustomShape2d::CreateSubPath(
else
{
aNewB2DPolyPolygon.setClosed(true);
- pObj = new SdrPathObj(OBJ_POLY, aNewB2DPolyPolygon);
+ pObj = new SdrPathObj(
+ mrSdrObjCustomShape.getSdrModelFromSdrObject(),
+ OBJ_POLY,
+ aNewB2DPolyPolygon);
}
if(bNoStroke)
@@ -2372,7 +2380,7 @@ SdrObject* EnhancedCustomShape2d::CreatePathObj( bool bLineGeometryNeededOnly )
// copy remaining objects to pRet
if(vObjectList.size() > 1)
{
- pRet = new SdrObjGroup;
+ pRet = new SdrObjGroup(mrSdrObjCustomShape.getSdrModelFromSdrObject());
for ( std::pair< SdrPathObj*, double >& rCandidate : vObjectList )
{
@@ -2404,7 +2412,7 @@ SdrObject* EnhancedCustomShape2d::CreateObject( bool bLineGeometryNeededOnly )
if ( eSpType == mso_sptRectangle )
{
- pRet = new SdrRectObj( aLogicRect );
+ pRet = new SdrRectObj(mrSdrObjCustomShape.getSdrModelFromSdrObject(), aLogicRect);
pRet->SetMergedItemSet( *this );
}
if ( !pRet )
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx
index 60177fc9fbe8..a0e2a6badba0 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx
@@ -255,27 +255,24 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
const SdrObject* pShape2d,
const SdrObjCustomShape& rSdrObjCustomShape)
{
- SdrObject* pRet = nullptr;
- SdrModel* pModel = rSdrObjCustomShape.GetModel();
- const SdrCustomShapeGeometryItem& rGeometryItem = rSdrObjCustomShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ SdrObject* pRet(nullptr);
+ const SdrCustomShapeGeometryItem& rGeometryItem(rSdrObjCustomShape.GetMergedItem(SDRATTR_CUSTOMSHAPE_GEOMETRY));
+ double fMap(1.0), *pMap = nullptr;
+ Fraction aFraction( rSdrObjCustomShape.getSdrModelFromSdrObject().GetScaleFraction() );
- double fMap, *pMap = nullptr;
- if ( pModel )
+ if ( aFraction.GetNumerator() != 1 || aFraction.GetDenominator() != 1 )
{
- fMap = 1.0;
- Fraction aFraction( pModel->GetScaleFraction() );
- if ( aFraction.GetNumerator() != 1 || aFraction.GetDenominator() != 1 )
- {
- fMap *= double(aFraction);
- pMap = &fMap;
- }
- if ( pModel->GetScaleUnit() != MapUnit::Map100thMM )
- {
- DBG_ASSERT( pModel->GetScaleUnit() == MapUnit::MapTwip, "EnhancedCustomShape3d::Current MapMode is Unsupported" );
- fMap *= 1440.0 / 2540.0;
- pMap = &fMap;
- }
+ fMap *= double(aFraction);
+ pMap = &fMap;
+ }
+
+ if ( rSdrObjCustomShape.getSdrModelFromSdrObject().GetScaleUnit() != MapUnit::Map100thMM )
+ {
+ DBG_ASSERT( rSdrObjCustomShape.getSdrModelFromSdrObject().GetScaleUnit() == MapUnit::MapTwip, "EnhancedCustomShape3d::Current MapMode is Unsupported" );
+ fMap *= 1440.0 / 2540.0;
+ pMap = &fMap;
}
+
if ( GetBool( rGeometryItem, "Extrusion", false ) )
{
bool bIsMirroredX(rSdrObjCustomShape.IsMirroredX());
@@ -326,7 +323,7 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
a3DDefaultAttr.SetDefaultLatheCharacterMode( true );
a3DDefaultAttr.SetDefaultExtrudeCharacterMode( true );
- E3dScene* pScene = new E3dScene;
+ E3dScene* pScene = new E3dScene(rSdrObjCustomShape.getSdrModelFromSdrObject());
bool bSceneHasObjects ( false );
bool bUseTwoFillStyles( false );
@@ -480,10 +477,15 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
aBoundRect2d.Union( aBoundRect );
// #i122777# depth 0 is okay for planes when using double-sided
- E3dCompoundObject* p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, bUseTwoFillStyles ? 0 : fDepth );
+ E3dCompoundObject* p3DObj = new E3dExtrudeObj(
+ rSdrObjCustomShape.getSdrModelFromSdrObject(),
+ a3DDefaultAttr,
+ aPolyPoly,
+ bUseTwoFillStyles ? 0 : fDepth );
p3DObj->NbcSetLayer( pShape2d->GetLayer() );
p3DObj->SetMergedItemSet( aLocalSet );
+
if ( bIsPlaceholderObject )
aPlaceholderObjectList.push_back( p3DObj );
else if ( bUseTwoFillStyles )
@@ -530,7 +532,11 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
}
}
pScene->Insert3DObj( p3DObj );
- p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, fDepth );
+ p3DObj = new E3dExtrudeObj(
+ rSdrObjCustomShape.getSdrModelFromSdrObject(),
+ a3DDefaultAttr,
+ aPolyPoly,
+ fDepth);
p3DObj->NbcSetLayer( pShape2d->GetLayer() );
p3DObj->SetMergedItemSet( aLocalSet );
if ( bUseExtrusionColor )
@@ -541,7 +547,11 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
pScene->Insert3DObj( p3DObj );
// #i122777# depth 0 is okay for planes when using double-sided
- p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, 0 );
+ p3DObj = new E3dExtrudeObj(
+ rSdrObjCustomShape.getSdrModelFromSdrObject(),
+ a3DDefaultAttr,
+ aPolyPoly,
+ 0);
p3DObj->NbcSetLayer( pShape2d->GetLayer() );
p3DObj->SetMergedItemSet( aLocalSet );
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
index 133c008ebc4e..753d43c3a0c7 100644
--- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -167,7 +167,7 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText(
if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape) == nullptr )
{
SdrObject* pTmp = pRenderedShape;
- pRenderedShape = new SdrObjGroup();
+ pRenderedShape = new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject());
static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
}
static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pShadowGeometry->Clone(), 0 );
@@ -181,10 +181,9 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText(
{
// #i37011# also create a text object and add at rPos + 1
SdrObject* pTextObj = SdrObjFactory::MakeNewObject(
+ rSdrObjCustomShape.getSdrModelFromSdrObject(),
rSdrObjCustomShape.GetObjInventor(),
- OBJ_TEXT,
- nullptr,
- rSdrObjCustomShape.GetModel());
+ OBJ_TEXT);
// Copy text content
OutlinerParaObject* pParaObj(rSdrObjCustomShape.GetOutlinerParaObject());
@@ -233,7 +232,7 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText(
if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape) == nullptr )
{
SdrObject* pTmp = pRenderedShape;
- pRenderedShape = new SdrObjGroup();
+ pRenderedShape = new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject());
static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
}
static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pTextObj );
@@ -248,12 +247,11 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText(
if ( dynamic_cast<const SdrObjGroup*>( pRenderedShape) == nullptr )
{
SdrObject* pTmp = pRenderedShape;
- pRenderedShape = new SdrObjGroup();
+ pRenderedShape = new SdrObjGroup(rSdrObjCustomShape.getSdrModelFromSdrObject());
static_cast<SdrObjGroup*>(pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
}
pRenderedShape->SetPage(rSdrObjCustomShape.GetPage());
- pRenderedShape->SetModel(rSdrObjCustomShape.GetModel());
}
}
@@ -391,9 +389,7 @@ awt::Rectangle SAL_CALL EnhancedCustomShapeEngine::getTextBounds()
SdrObjCustomShape& rSdrObjCustomShape(static_cast< SdrObjCustomShape& >(*GetSdrObjectFromXShape(mxShape)));
uno::Reference< document::XActionLockable > xLockable( mxShape, uno::UNO_QUERY );
- if(rSdrObjCustomShape.GetModel()
- && xLockable.is()
- && !xLockable->isActionLocked())
+ if(xLockable.is() && !xLockable->isActionLocked())
{
EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
tools::Rectangle aRect( aCustomShape2d.GetTextRect() );
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index 71dc441f1727..9bfed5d53ab4 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -853,13 +853,17 @@ SdrObject* CreateSdrObjectFromParagraphOutlines(
++aTextAreaIter;
}
- pRet = new SdrPathObj( OBJ_POLY, aPolyPoly );
+ pRet = new SdrPathObj(
+ rSdrObjCustomShape.getSdrModelFromSdrObject(),
+ OBJ_POLY,
+ aPolyPoly);
SfxItemSet aSet(rSdrObjCustomShape.GetMergedItemSet());
aSet.ClearItem( SDRATTR_TEXTDIRECTION ); //SJ: vertical writing is not required, by removing this item no outliner is created
aSet.Put(makeSdrShadowItem(false)); // #i37011# NO shadow for FontWork geometry
pRet->SetMergedItemSet( aSet ); // * otherwise we would crash, because the outliner tries to create a Paraobject, but there is no model
}
+
return pRet;
}
diff --git a/svx/source/dialog/connctrl.cxx b/svx/source/dialog/connctrl.cxx
index b9a8ea76b1bd..9440ce6796a6 100644
--- a/svx/source/dialog/connctrl.cxx
+++ b/svx/source/dialog/connctrl.cxx
@@ -39,7 +39,7 @@
SvxXConnectionPreview::SvxXConnectionPreview( vcl::Window* pParent, WinBits nStyle)
: Control(pParent, nStyle)
, pEdgeObj(nullptr)
- , pObjList(nullptr)
+ , pSdrPage(nullptr)
, pView(nullptr)
{
SetMapMode(MapMode(MapUnit::Map100thMM));
@@ -55,7 +55,7 @@ SvxXConnectionPreview::~SvxXConnectionPreview()
void SvxXConnectionPreview::dispose()
{
- delete pObjList;
+ delete pSdrPage;
Control::dispose();
}
@@ -76,13 +76,13 @@ Size SvxXConnectionPreview::GetOptimalSize() const
void SvxXConnectionPreview::AdaptSize()
{
// Adapt size
- if( !pObjList )
+ if( !pSdrPage )
return;
SetMapMode(MapMode(MapUnit::Map100thMM));
OutputDevice* pOD = pView->GetFirstOutputDevice(); // GetWin( 0 );
- tools::Rectangle aRect = pObjList->GetAllObjBoundRect();
+ tools::Rectangle aRect = pSdrPage->GetAllObjBoundRect();
MapMode aMapMode = GetMapMode();
aMapMode.SetMapUnit( pOD->GetMapMode().GetMapUnit() );
@@ -171,37 +171,43 @@ void SvxXConnectionPreview::Construct()
// potential memory leak here (!). Create SdrObjList only when there is
// not yet one.
- if(!pObjList)
+ if(!pSdrPage)
{
- pObjList = new SdrObjList( pView->GetModel(), nullptr );
+ pSdrPage = new SdrPage(
+ pView->getSdrModelFromSdrView(),
+ false);
}
if( pTmpObj1 )
{
SdrObject* pObj1 = pTmpObj1->Clone();
- pObjList->InsertObject( pObj1 );
+ pSdrPage->InsertObject( pObj1 );
pEdgeObj->ConnectToNode( true, pObj1 );
}
+
if( pTmpObj2 )
{
SdrObject* pObj2 = pTmpObj2->Clone();
- pObjList->InsertObject( pObj2 );
+ pSdrPage->InsertObject( pObj2 );
pEdgeObj->ConnectToNode( false, pObj2 );
}
- pObjList->InsertObject( pEdgeObj );
+
+ pSdrPage->InsertObject( pEdgeObj );
}
}
}
if( !pEdgeObj )
- pEdgeObj = new SdrEdgeObj();
+ {
+ pEdgeObj = new SdrEdgeObj(pView->getSdrModelFromSdrView());
+ }
AdaptSize();
}
void SvxXConnectionPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
- if (pObjList)
+ if (pSdrPage)
{
// This will not work anymore. To not start at Adam and Eve, i will
// ATM not try to change all this stuff to really using an own model
@@ -212,9 +218,9 @@ void SvxXConnectionPreview::Paint(vcl::RenderContext& rRenderContext, const tool
// New stuff: Use a ObjectContactOfObjListPainter.
sdr::contact::SdrObjectVector aObjectVector;
- for (size_t a = 0; a < pObjList->GetObjCount(); ++a)
+ for (size_t a = 0; a < pSdrPage->GetObjCount(); ++a)
{
- SdrObject* pObject = pObjList->GetObj(a);
+ SdrObject* pObject = pSdrPage->GetObj(a);
DBG_ASSERT(pObject,
"SvxXConnectionPreview::Paint: Corrupt ObjectList (!)");
aObjectVector.push_back(pObject);
diff --git a/svx/source/dialog/contwnd.cxx b/svx/source/dialog/contwnd.cxx
index e404154ed46d..c041a7240032 100644
--- a/svx/source/dialog/contwnd.cxx
+++ b/svx/source/dialog/contwnd.cxx
@@ -61,7 +61,10 @@ void ContourWindow::SetPolyPolygon(const tools::PolyPolygon& rPolyPoly)
{
basegfx::B2DPolyPolygon aPolyPolygon;
aPolyPolygon.append(aPolyPoly[ i ].getB2DPolygon());
- SdrPathObj* pPathObj = new SdrPathObj( OBJ_PATHFILL, aPolyPolygon );
+ SdrPathObj* pPathObj = new SdrPathObj(
+ *pModel,
+ OBJ_PATHFILL,
+ aPolyPolygon);
SfxItemSet aSet(pModel->GetItemPool());
diff --git a/svx/source/dialog/dlgctl3d.cxx b/svx/source/dialog/dlgctl3d.cxx
index 0eee4586f225..22bb53ba2d18 100644
--- a/svx/source/dialog/dlgctl3d.cxx
+++ b/svx/source/dialog/dlgctl3d.cxx
@@ -92,12 +92,12 @@ void Svx3DPreviewControl::Construct()
mpModel->InsertPage( mpFmPage, 0 );
// 3D View
- mp3DView = new E3dView( mpModel, this );
+ mp3DView = new E3dView(*mpModel, this );
mp3DView->SetBufferedOutputAllowed(true);
mp3DView->SetBufferedOverlayAllowed(true);
// 3D Scene
- mpScene = new E3dScene;
+ mpScene = new E3dScene(*mpModel);
// initially create object
SetObjectType(SvxPreviewObjectType::SPHERE);
@@ -204,6 +204,7 @@ void Svx3DPreviewControl::SetObjectType(SvxPreviewObjectType nType)
case SvxPreviewObjectType::SPHERE:
{
mp3DObj = new E3dSphereObj(
+ *mpModel,
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPoint( 0, 0, 0 ),
basegfx::B3DVector( 5000, 5000, 5000 ));
@@ -213,6 +214,7 @@ void Svx3DPreviewControl::SetObjectType(SvxPreviewObjectType nType)
case SvxPreviewObjectType::CUBE:
{
mp3DObj = new E3dCubeObj(
+ *mpModel,
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPoint( -2500, -2500, -2500 ),
basegfx::B3DVector( 5000, 5000, 5000 ));
@@ -286,6 +288,7 @@ void Svx3DLightControl::Construct2()
// create invisible expansion object
const double fMaxExpansion(RADIUS_LAMP_BIG + RADIUS_LAMP_PREVIEW_SIZE);
mpExpansionObject = new E3dCubeObj(
+ *mpModel,
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPoint(-fMaxExpansion, -fMaxExpansion, -fMaxExpansion),
basegfx::B3DVector(2.0 * fMaxExpansion, 2.0 * fMaxExpansion, 2.0 * fMaxExpansion));
@@ -309,6 +312,7 @@ void Svx3DLightControl::Construct2()
// create object for it
mpLampBottomObject = new E3dPolygonObj(
+ *mpModel,
basegfx::B3DPolyPolygon(a3DCircle));
mpScene->Insert3DObj( mpLampBottomObject );
@@ -322,6 +326,7 @@ void Svx3DLightControl::Construct2()
// create object for it
mpLampShaftObject = new E3dPolygonObj(
+ *mpModel,
basegfx::B3DPolyPolygon(a3DHalfCircle));
mpScene->Insert3DObj( mpLampShaftObject );
@@ -383,6 +388,7 @@ void Svx3DLightControl::ConstructLightObjects()
const double fLampSize(bIsSelectedLight ? RADIUS_LAMP_BIG : RADIUS_LAMP_SMALL);
E3dObject* pNewLight = new E3dSphereObj(
+ *mpModel,
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPoint( 0, 0, 0 ),
basegfx::B3DVector( fLampSize, fLampSize, fLampSize));
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index d89b71b3e2a1..7e2ffb67c0e3 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -1468,14 +1468,9 @@ SvxXLinePreview::SvxXLinePreview(vcl::Window* pParent)
{
InitSettings( true, true );
- mpLineObjA = new SdrPathObj(OBJ_LINE);
- mpLineObjA->SetModel(&getModel());
-
- mpLineObjB = new SdrPathObj(OBJ_PLIN);
- mpLineObjB->SetModel(&getModel());
-
- mpLineObjC = new SdrPathObj(OBJ_PLIN);
- mpLineObjC->SetModel(&getModel());
+ mpLineObjA = new SdrPathObj(getModel(), OBJ_LINE);
+ mpLineObjB = new SdrPathObj(getModel(), OBJ_PLIN);
+ mpLineObjC = new SdrPathObj(getModel(), OBJ_PLIN);
}
VCL_BUILDER_FACTORY(SvxXLinePreview)
@@ -1563,15 +1558,16 @@ void SvxXLinePreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rec
}
SvxXRectPreview::SvxXRectPreview(vcl::Window* pParent)
- : SvxPreviewBase(pParent)
- , mpRectangleObject(nullptr)
+: SvxPreviewBase(pParent)
+ ,mpRectangleObject(nullptr)
{
InitSettings(true, true);
// create RectangleObject
const tools::Rectangle aObjectSize(Point(), GetOutputSize());
- mpRectangleObject = new SdrRectObj(aObjectSize);
- mpRectangleObject->SetModel(&getModel());
+ mpRectangleObject = new SdrRectObj(
+ getModel(),
+ aObjectSize);
}
void SvxXRectPreview::Resize()
@@ -1580,8 +1576,9 @@ void SvxXRectPreview::Resize()
SdrObject *pOrigObject = mpRectangleObject;
if (pOrigObject)
{
- mpRectangleObject = new SdrRectObj(aObjectSize);
- mpRectangleObject->SetModel(&getModel());
+ mpRectangleObject = new SdrRectObj(
+ getModel(),
+ aObjectSize);
SetAttributes(pOrigObject->GetMergedItemSet());
SdrObject::Free(pOrigObject);
}
@@ -1637,13 +1634,15 @@ SvxXShadowPreview::SvxXShadowPreview( vcl::Window* pParent )
// create RectangleObject
const tools::Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
- mpRectangleObject = new SdrRectObj(aObjectSize);
- mpRectangleObject->SetModel(&getModel());
+ mpRectangleObject = new SdrRectObj(
+ getModel(),
+ aObjectSize);
// create ShadowObject
const tools::Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
- mpRectangleShadow = new SdrRectObj(aShadowSize);
- mpRectangleShadow->SetModel(&getModel());
+ mpRectangleShadow = new SdrRectObj(
+ getModel(),
+ aShadowSize);
}
VCL_BUILDER_FACTORY(SvxXShadowPreview)
diff --git a/svx/source/dialog/graphctl.cxx b/svx/source/dialog/graphctl.cxx
index 481c55ccd418..07ff51e01fd9 100644
--- a/svx/source/dialog/graphctl.cxx
+++ b/svx/source/dialog/graphctl.cxx
@@ -142,7 +142,7 @@ void GraphCtrl::InitSdrModel()
pModel->SetChanged( false );
// Creating a View
- pView = new GraphCtrlView( pModel, this );
+ pView = new GraphCtrlView(*pModel, this);
pView->SetWorkArea( tools::Rectangle( Point(), aGraphSize ) );
pView->EnableExtendedMouseEventDispatcher( true );
pView->ShowSdrPage(pView->GetModel()->GetPage(0));
diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx
index da1a22a37ed9..557bbb005a95 100644
--- a/svx/source/dialog/imapwnd.cxx
+++ b/svx/source/dialog/imapwnd.cxx
@@ -195,7 +195,10 @@ SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj )
// clipped on CanvasPane
aDrawRect.Intersection( aClipRect );
- pSdrObj = static_cast<SdrObject*>(new SdrRectObj( aDrawRect ));
+ pSdrObj = static_cast<SdrObject*>(
+ new SdrRectObj(
+ *pModel,
+ aDrawRect));
pCloneIMapObj.reset(static_cast<IMapObject*>(new IMapRectangleObject( *pIMapRectObj )));
}
break;
@@ -211,7 +214,13 @@ SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj )
// limited to CanvasPane
aCircle.Intersection( aClipRect );
- pSdrObj = static_cast<SdrObject*>(new SdrCircObj( OBJ_CIRC, aCircle, 0, 36000 ));
+ pSdrObj = static_cast<SdrObject*>(
+ new SdrCircObj(
+ *pModel,
+ OBJ_CIRC,
+ aCircle,
+ 0,
+ 36000));
pCloneIMapObj.reset(static_cast<IMapObject*>(new IMapCircleObject( *pIMapCircleObj )));
}
break;
@@ -228,7 +237,13 @@ SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj )
// clipped on CanvasPane
aDrawRect.Intersection( aClipRect );
- pSdrObj = static_cast<SdrObject*>(new SdrCircObj( OBJ_CIRC, aDrawRect, 0, 36000 ));
+ pSdrObj = static_cast<SdrObject*>(
+ new SdrCircObj(
+ *pModel,
+ OBJ_CIRC,
+ aDrawRect,
+ 0,
+ 36000));
}
else
{
@@ -240,7 +255,11 @@ SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj )
basegfx::B2DPolygon aPolygon;
aPolygon.append(aDrawPoly.getB2DPolygon());
- pSdrObj = static_cast<SdrObject*>(new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aPolygon)));
+ pSdrObj = static_cast<SdrObject*>(
+ new SdrPathObj(
+ *pModel,
+ OBJ_POLY,
+ basegfx::B2DPolyPolygon(aPolygon)));
}
pCloneIMapObj.reset(static_cast<IMapObject*>(new IMapPolygonObject( *pIMapPolyObj )));
@@ -745,7 +764,10 @@ void IMapWindow::CreateDefaultObject()
aPagePos.AdjustY((aPageSize.Height() / 2) - (nDefaultObjectSizeHeight / 2) );
tools::Rectangle aNewObjectRectangle(aPagePos, Size(nDefaultObjectSizeWidth, nDefaultObjectSizeHeight));
- SdrObject* pObj = SdrObjFactory::MakeNewObject( pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(), nullptr, pModel);
+ SdrObject* pObj = SdrObjFactory::MakeNewObject(
+ *pModel,
+ pView->GetCurrentObjInventor(),
+ pView->GetCurrentObjIdentifier());
pObj->SetLogicRect(aNewObjectRectangle);
switch( pObj->GetObjIdentifier() )
diff --git a/svx/source/dialog/measctrl.cxx b/svx/source/dialog/measctrl.cxx
index ddca770b766d..03e630041189 100644
--- a/svx/source/dialog/measctrl.cxx
+++ b/svx/source/dialog/measctrl.cxx
@@ -42,9 +42,11 @@ SvxXMeasurePreview::SvxXMeasurePreview(vcl::Window* pParent, WinBits nStyle)
Point aPt1 = Point(aSize.Width() / 5, static_cast<long>(aSize.Height() / 2));
Point aPt2 = Point(aSize.Width() * 4 / 5, static_cast<long>(aSize.Height() / 2));
- pMeasureObj = new SdrMeasureObj(aPt1, aPt2);
pModel = new SdrModel();
- pMeasureObj->SetModel(pModel);
+ pMeasureObj = new SdrMeasureObj(
+ *pModel,
+ aPt1,
+ aPt2);
bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
SetDrawMode(bHighContrast ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
diff --git a/svx/source/engine3d/cube3d.cxx b/svx/source/engine3d/cube3d.cxx
index 6583969bb771..509688fe2f77 100644
--- a/svx/source/engine3d/cube3d.cxx
+++ b/svx/source/engine3d/cube3d.cxx
@@ -35,25 +35,31 @@ sdr::contact::ViewContact* E3dCubeObj::CreateObjectSpecificViewContact()
}
-E3dCubeObj::E3dCubeObj(E3dDefaultAttributes& rDefault, const basegfx::B3DPoint& aPos, const basegfx::B3DVector& r3DSize)
-: E3dCompoundObject()
+E3dCubeObj::E3dCubeObj(
+ SdrModel& rSdrModel,
+ const E3dDefaultAttributes& rDefault,
+ const basegfx::B3DPoint& aPos,
+ const basegfx::B3DVector& r3DSize)
+: E3dCompoundObject(rSdrModel)
{
// Set Defaults
SetDefaultAttributes(rDefault);
- aCubePos = aPos; // position centre or left, bottom, back (dependent on bPosIsCenter)
+ // position centre or left, bottom, back (dependent on bPosIsCenter)
+ aCubePos = aPos;
aCubeSize = r3DSize;
}
-E3dCubeObj::E3dCubeObj()
-: E3dCompoundObject()
+E3dCubeObj::E3dCubeObj(SdrModel& rSdrModel)
+: E3dCompoundObject(rSdrModel)
{
// Set Defaults
- E3dDefaultAttributes aDefault;
+ const E3dDefaultAttributes aDefault;
+
SetDefaultAttributes(aDefault);
}
-void E3dCubeObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
+void E3dCubeObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
aCubePos = rDefault.GetDefaultCubePos();
aCubeSize = rDefault.GetDefaultCubeSize();
@@ -72,9 +78,22 @@ SdrObject *E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) c
return nullptr;
}
-E3dCubeObj* E3dCubeObj::Clone() const
+E3dCubeObj* E3dCubeObj::Clone(SdrModel* pTargetModel) const
+{
+ return CloneHelper< E3dCubeObj >(pTargetModel);
+}
+
+E3dCubeObj& E3dCubeObj::operator=(const E3dCubeObj& rObj)
{
- return CloneHelper< E3dCubeObj >();
+ if( this == &rObj )
+ return *this;
+ E3dCompoundObject::operator=(rObj);
+
+ aCubePos = rObj.aCubePos;
+ aCubeSize = rObj.aCubeSize;
+ bPosIsCenter = rObj.bPosIsCenter;
+
+ return *this;
}
// Set local parameters with geometry re-creating
diff --git a/svx/source/engine3d/dragmt3d.cxx b/svx/source/engine3d/dragmt3d.cxx
index e55931b568f5..5e070abb6c43 100644
--- a/svx/source/engine3d/dragmt3d.cxx
+++ b/svx/source/engine3d/dragmt3d.cxx
@@ -73,8 +73,7 @@ E3dDragMethod::E3dDragMethod (
if(pE3dObj)
{
// fill new interaction unit
- E3dDragMethodUnit aNewUnit;
- aNewUnit.mp3DObj = pE3dObj;
+ E3dDragMethodUnit aNewUnit(*pE3dObj);
// get transformations
aNewUnit.maInitTransform = aNewUnit.maTransform = pE3dObj->GetTransform();
@@ -157,13 +156,15 @@ bool E3dDragMethod::EndSdrDrag(bool /*bCopy*/)
for(nOb=0;nOb<nCnt;nOb++)
{
E3dDragMethodUnit& rCandidate = maGrp[nOb];
- E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
- rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
+ E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj);
+ rCandidate.mr3DObj.SetTransform(rCandidate.maTransform);
if( bUndo )
{
- getSdrDragView().AddUndo(new E3dRotateUndoAction(rCandidate.mp3DObj->GetModel(),
- rCandidate.mp3DObj, rCandidate.maInitTransform,
- rCandidate.maTransform));
+ getSdrDragView().AddUndo(
+ new E3dRotateUndoAction(
+ rCandidate.mr3DObj,
+ rCandidate.maInitTransform,
+ rCandidate.maTransform));
}
}
if( bUndo )
@@ -185,8 +186,8 @@ void E3dDragMethod::CancelSdrDrag()
{
// Restore transformation
E3dDragMethodUnit& rCandidate = maGrp[nOb];
- E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
- rCandidate.mp3DObj->SetTransform(rCandidate.maInitTransform);
+ E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj);
+ rCandidate.mr3DObj.SetTransform(rCandidate.maInitTransform);
}
}
}
@@ -224,7 +225,7 @@ void E3dDragMethod::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlay
if(nPlyCnt)
{
- const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mr3DObj.GetScene()->GetViewContact());
const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D());
const basegfx::B3DHomMatrix aWorldToView(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection() * aViewInfo3D.getOrientation());
const basegfx::B3DHomMatrix aTransform(aWorldToView * rCandidate.maDisplayTransform);
@@ -261,7 +262,7 @@ E3dDragRotate::E3dDragRotate(SdrDragView &_rView,
if(nCnt)
{
- const E3dScene *pScene = maGrp[0].mp3DObj->GetScene();
+ const E3dScene *pScene = maGrp[0].mr3DObj.GetScene();
if(pScene)
{
@@ -271,7 +272,7 @@ E3dDragRotate::E3dDragRotate(SdrDragView &_rView,
for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
{
E3dDragMethodUnit& rCandidate = maGrp[nOb];
- basegfx::B3DPoint aObjCenter = rCandidate.mp3DObj->GetBoundVolume().getCenter();
+ basegfx::B3DPoint aObjCenter = rCandidate.mr3DObj.GetBoundVolume().getCenter();
const basegfx::B3DHomMatrix aTransform(aViewInfo3D.getOrientation() * rCandidate.maDisplayTransform * rCandidate.maInitTransform);
aObjCenter = aTransform * aObjCenter;
@@ -387,7 +388,7 @@ void E3dDragRotate::MoveSdrDrag(const Point& rPnt)
}
// Transformation in eye coordinates, there rotate then and back
- const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mr3DObj.GetScene()->GetViewContact());
const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D());
basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
aInverseOrientation.invert();
@@ -405,8 +406,8 @@ void E3dDragRotate::MoveSdrDrag(const Point& rPnt)
if(mbMoveFull)
{
- E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
- rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
+ E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj);
+ rCandidate.mr3DObj.SetTransform(rCandidate.maTransform);
}
else
{
@@ -504,7 +505,7 @@ void E3dDragMove::MoveSdrDrag(const Point& rPnt)
for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
{
E3dDragMethodUnit& rCandidate = maGrp[nOb];
- const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mr3DObj.GetScene()->GetViewContact());
const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D());
// move coor from 2d world to 3d Eye
@@ -554,8 +555,8 @@ void E3dDragMove::MoveSdrDrag(const Point& rPnt)
if(mbMoveFull)
{
- E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
- rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
+ E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj);
+ rCandidate.mr3DObj.SetTransform(rCandidate.maTransform);
}
else
{
@@ -575,10 +576,10 @@ void E3dDragMove::MoveSdrDrag(const Point& rPnt)
for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
{
E3dDragMethodUnit& rCandidate = maGrp[nOb];
- const basegfx::B3DPoint aObjectCenter(rCandidate.mp3DObj->GetBoundVolume().getCenter());
+ const basegfx::B3DPoint aObjectCenter(rCandidate.mr3DObj.GetBoundVolume().getCenter());
// transform from 2D world view to 3D eye
- const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mr3DObj.GetScene()->GetViewContact());
const drawinglayer::geometry::ViewInformation3D& aViewInfo3D(rVCScene.getViewInformation3D());
basegfx::B2DPoint aGlobalScaleStart2D(static_cast<double>(aStartPos.X()), static_cast<double>(aStartPos.Y()));
@@ -673,14 +674,14 @@ void E3dDragMove::MoveSdrDrag(const Point& rPnt)
if(mbMoveFull)
{
- E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
- rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
+ E3DModifySceneSnapRectUpdater aUpdater(&rCandidate.mr3DObj);
+ rCandidate.mr3DObj.SetTransform(rCandidate.maTransform);
}
else
{
Hide();
rCandidate.maWireframePoly.clear();
- rCandidate.maWireframePoly = rCandidate.mp3DObj->CreateWireframe();
+ rCandidate.maWireframePoly = rCandidate.mr3DObj.CreateWireframe();
rCandidate.maWireframePoly.transform(rCandidate.maTransform);
Show();
}
diff --git a/svx/source/engine3d/e3dsceneupdater.cxx b/svx/source/engine3d/e3dsceneupdater.cxx
index bc696daebafb..28c472727e17 100644
--- a/svx/source/engine3d/e3dsceneupdater.cxx
+++ b/svx/source/engine3d/e3dsceneupdater.cxx
@@ -29,30 +29,27 @@ E3DModifySceneSnapRectUpdater::E3DModifySceneSnapRectUpdater(const SdrObject* pO
mpViewInformation3D(nullptr)
{
// Secure old 3D transformation stack before modification
- if(pObject)
+ if(const E3dObject* pE3dObject = dynamic_cast< const E3dObject* >(pObject))
{
- const E3dObject* pE3dObject = dynamic_cast< const E3dObject* >(pObject);
+ mpScene = pE3dObject->GetScene();
- if(pE3dObject)
+ if(mpScene && mpScene->GetScene() == mpScene)
{
- mpScene = pE3dObject->GetScene();
+ // if there is a scene and it's the outmost scene, get current 3D range
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(mpScene->GetViewContact());
+ const basegfx::B3DRange aAllContentRange(rVCScene.getAllContentRange3D());
- if(mpScene && mpScene->GetScene() == mpScene)
+ if(aAllContentRange.isEmpty())
{
- // if there is a scene and it's the outmost scene, get current 3D range
- const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(mpScene->GetViewContact());
- const basegfx::B3DRange aAllContentRange(rVCScene.getAllContentRange3D());
-
- if(aAllContentRange.isEmpty())
- {
- // no content, nothing to do
- mpScene = nullptr;
- }
- else
- {
- // secure current 3D transformation stack
- mpViewInformation3D.reset( new drawinglayer::geometry::ViewInformation3D(rVCScene.getViewInformation3D(aAllContentRange)) );
- }
+ // no content, nothing to do
+ mpScene = nullptr;
+ }
+ else
+ {
+ // secure current 3D transformation stack
+ mpViewInformation3D.reset(
+ new drawinglayer::geometry::ViewInformation3D(
+ rVCScene.getViewInformation3D(aAllContentRange)));
}
}
}
diff --git a/svx/source/engine3d/e3dundo.cxx b/svx/source/engine3d/e3dundo.cxx
index e194dd661ef1..47268fcda660 100644
--- a/svx/source/engine3d/e3dundo.cxx
+++ b/svx/source/engine3d/e3dundo.cxx
@@ -38,36 +38,32 @@ bool E3dUndoAction::CanRepeat(SfxRepeatTarget&) const
// Undo destructor for 3D-Rotation
-
-E3dRotateUndoAction::~E3dRotateUndoAction ()
+E3dRotateUndoAction::~E3dRotateUndoAction()
{
}
// Undo for 3D-Rotation on the Rotation matrix
-
-void E3dRotateUndoAction::Undo ()
+void E3dRotateUndoAction::Undo()
{
- E3DModifySceneSnapRectUpdater aUpdater(pMy3DObj);
- pMy3DObj->SetTransform(aMyOldRotation);
+ E3DModifySceneSnapRectUpdater aUpdater(&mrMy3DObj);
+ mrMy3DObj.SetTransform(maMyOldRotation);
}
// Redo for 3D-Rotation on the Rotation matrix
-
-void E3dRotateUndoAction::Redo ()
+void E3dRotateUndoAction::Redo()
{
- E3DModifySceneSnapRectUpdater aUpdater(pMy3DObj);
- pMy3DObj->SetTransform(aMyNewRotation);
+ E3DModifySceneSnapRectUpdater aUpdater(&mrMy3DObj);
+ mrMy3DObj.SetTransform(maMyNewRotation);
}
-
-E3dAttributesUndoAction::E3dAttributesUndoAction( SdrModel &rModel,
- E3dObject* pInObject,
- const SfxItemSet& rNewSet,
- const SfxItemSet& rOldSet)
- : SdrUndoAction( rModel )
- , pObject ( pInObject )
- , aNewSet ( rNewSet )
- , aOldSet ( rOldSet )
+E3dAttributesUndoAction::E3dAttributesUndoAction(
+ E3dObject& rInObject,
+ const SfxItemSet& rNewSet,
+ const SfxItemSet& rOldSet)
+: SdrUndoAction(rInObject.getSdrModelFromSdrObject())
+ ,mrObject(rInObject)
+ ,maNewSet(rNewSet)
+ ,maOldSet(rOldSet)
{
}
@@ -80,18 +76,17 @@ E3dAttributesUndoAction::~E3dAttributesUndoAction()
void E3dAttributesUndoAction::Undo()
{
- E3DModifySceneSnapRectUpdater aUpdater(pObject);
- pObject->SetMergedItemSetAndBroadcast(aOldSet);
+ E3DModifySceneSnapRectUpdater aUpdater(&mrObject);
+ mrObject.SetMergedItemSetAndBroadcast(maOldSet);
}
void E3dAttributesUndoAction::Redo()
{
- E3DModifySceneSnapRectUpdater aUpdater(pObject);
- pObject->SetMergedItemSetAndBroadcast(aNewSet);
+ E3DModifySceneSnapRectUpdater aUpdater(&mrObject);
+ mrObject.SetMergedItemSetAndBroadcast(maNewSet);
}
// Multiple Undo is not possible
-
bool E3dAttributesUndoAction::CanRepeat(SfxRepeatTarget& /*rView*/) const
{
return false;
diff --git a/svx/source/engine3d/extrud3d.cxx b/svx/source/engine3d/extrud3d.cxx
index 3b3bb93956c3..0a929970e50e 100644
--- a/svx/source/engine3d/extrud3d.cxx
+++ b/svx/source/engine3d/extrud3d.cxx
@@ -39,24 +39,24 @@
// DrawContact section
-
sdr::contact::ViewContact* E3dExtrudeObj::CreateObjectSpecificViewContact()
{
return new sdr::contact::ViewContactOfE3dExtrude(*this);
}
-
sdr::properties::BaseProperties* E3dExtrudeObj::CreateObjectSpecificProperties()
{
return new sdr::properties::E3dExtrudeProperties(*this);
}
-
// Constructor creates a two cover surface tools::PolyPolygon and (point-count 1) side
// surfaces rectangles from the passed PolyPolygon
-
-E3dExtrudeObj::E3dExtrudeObj(E3dDefaultAttributes const & rDefault, const basegfx::B2DPolyPolygon& rPP, double fDepth)
-: E3dCompoundObject(),
+E3dExtrudeObj::E3dExtrudeObj(
+ SdrModel& rSdrModel,
+ const E3dDefaultAttributes& rDefault,
+ const basegfx::B2DPolyPolygon& rPP,
+ double fDepth)
+: E3dCompoundObject(rSdrModel),
maExtrudePolygon(rPP)
{
// since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here
@@ -71,15 +71,16 @@ E3dExtrudeObj::E3dExtrudeObj(E3dDefaultAttributes const & rDefault, const basegf
GetProperties().SetObjectItemDirect(makeSvx3DDepthItem(static_cast<sal_uInt32>(fDepth + 0.5)));
}
-E3dExtrudeObj::E3dExtrudeObj()
-: E3dCompoundObject()
+E3dExtrudeObj::E3dExtrudeObj(SdrModel& rSdrModel)
+: E3dCompoundObject(rSdrModel)
{
// Set Defaults
- E3dDefaultAttributes aDefault;
+ const E3dDefaultAttributes aDefault;
+
SetDefaultAttributes(aDefault);
}
-void E3dExtrudeObj::SetDefaultAttributes(E3dDefaultAttributes const & rDefault)
+void E3dExtrudeObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultExtrudeSmoothed()));
GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultExtrudeSmoothFrontBack()));
@@ -97,11 +98,21 @@ sal_uInt16 E3dExtrudeObj::GetObjIdentifier() const
return E3D_EXTRUDEOBJ_ID;
}
-E3dExtrudeObj* E3dExtrudeObj::Clone() const
+E3dExtrudeObj* E3dExtrudeObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< E3dExtrudeObj >();
+ return CloneHelper< E3dExtrudeObj >(pTargetModel);
}
+E3dExtrudeObj& E3dExtrudeObj::operator=(const E3dExtrudeObj& rObj)
+{
+ if( this == &rObj )
+ return *this;
+ E3dCompoundObject::operator=(rObj);
+
+ maExtrudePolygon = rObj.maExtrudePolygon;
+
+ return *this;
+}
// Set local parameters with geometry re-creating
@@ -194,7 +205,7 @@ SdrAttrObj* E3dExtrudeObj::GetBreakObj()
{
// create PathObj
basegfx::B2DPolyPolygon aPoly = TransformToScreenCoor(aBackSide);
- SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aPoly);
+ SdrPathObj* pPathObj = new SdrPathObj(getSdrModelFromSdrObject(), OBJ_PLIN, aPoly);
SfxItemSet aSet(GetObjectItemSet());
aSet.Put(XLineStyleItem(css::drawing::LineStyle_SOLID));
diff --git a/svx/source/engine3d/lathe3d.cxx b/svx/source/engine3d/lathe3d.cxx
index 99268c6d5ff8..74097eb29f63 100644
--- a/svx/source/engine3d/lathe3d.cxx
+++ b/svx/source/engine3d/lathe3d.cxx
@@ -37,23 +37,22 @@
// DrawContact section
-
sdr::contact::ViewContact* E3dLatheObj::CreateObjectSpecificViewContact()
{
return new sdr::contact::ViewContactOfE3dLathe(*this);
}
-
sdr::properties::BaseProperties* E3dLatheObj::CreateObjectSpecificProperties()
{
return new sdr::properties::E3dLatheProperties(*this);
}
-
// Constructor from 3D polygon, scale is the conversion factor for the coordinates
-
-E3dLatheObj::E3dLatheObj(E3dDefaultAttributes const & rDefault, const basegfx::B2DPolyPolygon& rPoly2D)
-: E3dCompoundObject(),
+E3dLatheObj::E3dLatheObj(
+ SdrModel& rSdrModel,
+ const E3dDefaultAttributes& rDefault,
+ const basegfx::B2DPolyPolygon& rPoly2D)
+: E3dCompoundObject(rSdrModel),
maPolyPoly2D(rPoly2D)
{
// since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here
@@ -82,15 +81,16 @@ E3dLatheObj::E3dLatheObj(E3dDefaultAttributes const & rDefault, const basegfx::B
}
}
-E3dLatheObj::E3dLatheObj()
-: E3dCompoundObject()
+E3dLatheObj::E3dLatheObj(SdrModel& rSdrModel)
+: E3dCompoundObject(rSdrModel)
{
// Set Defaults
- E3dDefaultAttributes aDefault;
+ const E3dDefaultAttributes aDefault;
+
SetDefaultAttributes(aDefault);
}
-void E3dLatheObj::SetDefaultAttributes(E3dDefaultAttributes const & rDefault)
+void E3dLatheObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultLatheSmoothed()));
GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultLatheSmoothFrontBack()));
@@ -104,9 +104,20 @@ sal_uInt16 E3dLatheObj::GetObjIdentifier() const
return E3D_LATHEOBJ_ID;
}
-E3dLatheObj* E3dLatheObj::Clone() const
+E3dLatheObj* E3dLatheObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< E3dLatheObj >();
+ return CloneHelper< E3dLatheObj >(pTargetModel);
+}
+
+E3dLatheObj& E3dLatheObj::operator=(const E3dLatheObj& rObj)
+{
+ if( this == &rObj )
+ return *this;
+ E3dCompoundObject::operator=(rObj);
+
+ maPolyPoly2D = rObj.maPolyPoly2D;
+
+ return *this;
}
// Convert the object to group object consisting of n polygons
@@ -176,7 +187,7 @@ SdrAttrObj* E3dLatheObj::GetBreakObj()
// create PathObj
basegfx::B3DPolyPolygon aLathePoly3D(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(maPolyPoly2D));
basegfx::B2DPolyPolygon aTransPoly(TransformToScreenCoor(aLathePoly3D));
- SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aTransPoly);
+ SdrPathObj* pPathObj = new SdrPathObj(getSdrModelFromSdrObject(), OBJ_PLIN, aTransPoly);
// Set Attribute
SfxItemSet aSet(GetObjectItemSet());
diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx
index 73a0675efdb4..959ecf1f0c49 100644
--- a/svx/source/engine3d/obj3d.cxx
+++ b/svx/source/engine3d/obj3d.cxx
@@ -81,16 +81,16 @@ using namespace com::sun::star;
// List for 3D-Objects
-
-
E3dObjList::E3dObjList()
-: SdrObjList(nullptr, nullptr)
+: SdrObjList(nullptr)
{
}
-E3dObjList::E3dObjList(const E3dObjList&)
-: SdrObjList()
+E3dObjList* E3dObjList::CloneSdrObjList(SdrModel* pNewModel) const
{
+ E3dObjList* pObjList = new E3dObjList();
+ pObjList->lateInitSdrObjList(*this, pNewModel);
+ return pObjList;
}
E3dObjList::~E3dObjList()
@@ -169,8 +169,9 @@ sdr::properties::BaseProperties* E3dObject::CreateObjectSpecificProperties()
}
-E3dObject::E3dObject()
-: maSubList(),
+E3dObject::E3dObject(SdrModel& rSdrModel)
+: SdrAttrObj(rSdrModel),
+ maSubList(),
maLocalBoundVol(),
maTransformation(),
maFullTransform(),
@@ -303,14 +304,7 @@ void E3dObject::SetPage(SdrPage* pNewPage)
maSubList.SetPage(pNewPage);
}
-void E3dObject::SetModel(SdrModel* pNewModel)
-{
- SdrAttrObj::SetModel(pNewModel);
- maSubList.SetModel(pNewModel);
-}
-
// resize object, used from old 2d interfaces, e.g. in Move/Scale dialog (F4)
-
void E3dObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
{
// Movement in X, Y in the eye coordinate system
@@ -656,9 +650,9 @@ OUString E3dObject::TakeObjNamePlural() const
return ImpGetResStr(STR_ObjNamePluralObj3d);
}
-E3dObject* E3dObject::Clone() const
+E3dObject* E3dObject::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< E3dObject >();
+ return CloneHelper< E3dObject >(pTargetModel);
}
E3dObject& E3dObject::operator=(const E3dObject& rObj)
@@ -736,9 +730,8 @@ sdr::properties::BaseProperties* E3dCompoundObject::CreateObjectSpecificProperti
return new sdr::properties::E3dCompoundProperties(*this);
}
-
-E3dCompoundObject::E3dCompoundObject()
-: E3dObject(),
+E3dCompoundObject::E3dCompoundObject(SdrModel& rSdrModel)
+: E3dObject(rSdrModel),
aMaterialAmbientColor()
{
// Set defaults
@@ -881,9 +874,20 @@ void E3dCompoundObject::RecalcSnapRect()
}
}
-E3dCompoundObject* E3dCompoundObject::Clone() const
+E3dCompoundObject* E3dCompoundObject::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< E3dCompoundObject >();
+ return CloneHelper< E3dCompoundObject >(pTargetModel);
+}
+
+E3dCompoundObject& E3dCompoundObject::operator=(const E3dCompoundObject& rObj)
+{
+ if( this == &rObj )
+ return *this;
+ E3dObject::operator=(rObj);
+
+ aMaterialAmbientColor = rObj.aMaterialAmbientColor;
+
+ return *this;
}
// convert given basegfx::B3DPolyPolygon to screen coor
diff --git a/svx/source/engine3d/objfac3d.cxx b/svx/source/engine3d/objfac3d.cxx
index b704cf2b848d..58e1479e413b 100644
--- a/svx/source/engine3d/objfac3d.cxx
+++ b/svx/source/engine3d/objfac3d.cxx
@@ -52,24 +52,19 @@ IMPL_STATIC_LINK( E3dObjFactory, MakeObject, SdrObjCreatorParams, aParams, SdrOb
switch ( aParams.nObjIdentifier )
{
case E3D_SCENE_ID:
- return new E3dScene();
+ return new E3dScene(aParams.rSdrModel);
case E3D_POLYGONOBJ_ID :
- return new E3dPolygonObj();
+ return new E3dPolygonObj(aParams.rSdrModel);
case E3D_CUBEOBJ_ID :
- return new E3dCubeObj();
+ return new E3dCubeObj(aParams.rSdrModel);
case E3D_SPHEREOBJ_ID:
- // Gets the dummy constructor, as this is only called when
- // loading documents. The actual number of segments is however
- // determined only after loading the members. This will result
- // in that the first sphere will be immediately destroyed,
- // although it was never used.
- return new E3dSphereObj(E3dSphereObj::DUMMY);
+ return new E3dSphereObj(aParams.rSdrModel);
case E3D_EXTRUDEOBJ_ID:
- return new E3dExtrudeObj();
+ return new E3dExtrudeObj(aParams.rSdrModel);
case E3D_LATHEOBJ_ID:
- return new E3dLatheObj();
+ return new E3dLatheObj(aParams.rSdrModel);
case E3D_COMPOUNDOBJ_ID:
- return new E3dCompoundObject();
+ return new E3dCompoundObject(aParams.rSdrModel);
}
}
return nullptr;
diff --git a/svx/source/engine3d/polygn3d.cxx b/svx/source/engine3d/polygn3d.cxx
index 190c0ca89ee5..bcb9ba81b9eb 100644
--- a/svx/source/engine3d/polygn3d.cxx
+++ b/svx/source/engine3d/polygn3d.cxx
@@ -25,17 +25,16 @@
#include <basegfx/polygon/b3dpolygon.hxx>
#include <basegfx/polygon/b3dpolygontools.hxx>
-
// DrawContact section
-
sdr::contact::ViewContact* E3dPolygonObj::CreateObjectSpecificViewContact()
{
return new sdr::contact::ViewContactOfE3dPolygon(*this);
}
E3dPolygonObj::E3dPolygonObj(
+ SdrModel& rSdrModel,
const basegfx::B3DPolyPolygon& rPolyPoly3D)
-: E3dCompoundObject(),
+: E3dCompoundObject(rSdrModel),
bLineOnly(true)
{
// Set geometry
@@ -48,9 +47,9 @@ E3dPolygonObj::E3dPolygonObj(
CreateDefaultTexture();
}
-E3dPolygonObj::E3dPolygonObj()
-: E3dCompoundObject(),
- bLineOnly(false) // added missing initialisation
+E3dPolygonObj::E3dPolygonObj(SdrModel& rSdrModel)
+: E3dCompoundObject(rSdrModel),
+ bLineOnly(false)
{
// Create no geometry
}
@@ -219,9 +218,23 @@ SdrObject *E3dPolygonObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/
return nullptr;
}
-E3dPolygonObj* E3dPolygonObj::Clone() const
+E3dPolygonObj* E3dPolygonObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< E3dPolygonObj >();
+ return CloneHelper< E3dPolygonObj >(pTargetModel);
+}
+
+E3dPolygonObj& E3dPolygonObj::operator=(const E3dPolygonObj& rObj)
+{
+ if( this == &rObj )
+ return *this;
+ E3dCompoundObject::operator=(rObj);
+
+ aPolyPoly3D = rObj.aPolyPoly3D;
+ aPolyNormals3D = rObj.aPolyNormals3D;
+ aPolyTexture2D = rObj.aPolyTexture2D;
+ bLineOnly = rObj.bLineOnly;
+
+ return *this;
}
void E3dPolygonObj::SetLineOnly(bool bNew)
diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx
index 444331de3472..38961d3ccfa8 100644
--- a/svx/source/engine3d/scene3d.cxx
+++ b/svx/source/engine3d/scene3d.cxx
@@ -170,8 +170,8 @@ sdr::contact::ViewContact* E3dScene::CreateObjectSpecificViewContact()
}
-E3dScene::E3dScene()
-: E3dObject(),
+E3dScene::E3dScene(SdrModel& rSdrModel)
+: E3dObject(rSdrModel),
aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
mp3DDepthRemapper(nullptr),
bDrawOnlySelected(false),
@@ -411,24 +411,9 @@ void E3dScene::removeAllNonSelectedObjects()
}
}
-E3dScene* E3dScene::Clone() const
+E3dScene* E3dScene::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< E3dScene >();
-}
-
-void E3dScene::SuspendReportingDirtyRects()
-{
- GetScene()->mbSkipSettingDirty = true;
-}
-
-void E3dScene::ResumeReportingDirtyRects()
-{
- GetScene()->mbSkipSettingDirty = false;
-}
-
-void E3dScene::SetAllSceneRectsDirty()
-{
- GetScene()->SetRectsDirty();
+ return CloneHelper< E3dScene >(pTargetModel);
}
E3dScene& E3dScene::operator=(const E3dScene& rObj)
@@ -463,6 +448,21 @@ E3dScene& E3dScene::operator=(const E3dScene& rObj)
return *this;
}
+void E3dScene::SuspendReportingDirtyRects()
+{
+ GetScene()->mbSkipSettingDirty = true;
+}
+
+void E3dScene::ResumeReportingDirtyRects()
+{
+ GetScene()->mbSkipSettingDirty = false;
+}
+
+void E3dScene::SetAllSceneRectsDirty()
+{
+ GetScene()->SetRectsDirty();
+}
+
// Rebuild Light- and label- object lists rebuild (after loading, allocation)
void E3dScene::RebuildLists()
diff --git a/svx/source/engine3d/sphere3d.cxx b/svx/source/engine3d/sphere3d.cxx
index ecac05170094..75670c2e28d7 100644
--- a/svx/source/engine3d/sphere3d.cxx
+++ b/svx/source/engine3d/sphere3d.cxx
@@ -33,25 +33,24 @@
#include <sdr/contact/viewcontactofe3dsphere.hxx>
#include <basegfx/polygon/b3dpolygon.hxx>
-
// DrawContact section
-
sdr::contact::ViewContact* E3dSphereObj::CreateObjectSpecificViewContact()
{
return new sdr::contact::ViewContactOfE3dSphere(*this);
}
-
sdr::properties::BaseProperties* E3dSphereObj::CreateObjectSpecificProperties()
{
return new sdr::properties::E3dSphereProperties(*this);
}
-
// Build Sphere from polygon facets in latitude and longitude
-
-E3dSphereObj::E3dSphereObj(E3dDefaultAttributes& rDefault, const basegfx::B3DPoint& rCenter, const basegfx::B3DVector& r3DSize)
-: E3dCompoundObject()
+E3dSphereObj::E3dSphereObj(
+ SdrModel& rSdrModel,
+ const E3dDefaultAttributes& rDefault,
+ const basegfx::B3DPoint& rCenter,
+ const basegfx::B3DVector& r3DSize)
+: E3dCompoundObject(rSdrModel)
{
// Set defaults
SetDefaultAttributes(rDefault);
@@ -60,23 +59,16 @@ E3dSphereObj::E3dSphereObj(E3dDefaultAttributes& rDefault, const basegfx::B3DPoi
aSize = r3DSize;
}
-// Create Sphere without creating the Polygons within
-
-// This call is from the 3D Object Factory (objfac3d.cxx) and only when loading
-// of documents. Here you do not need CreateSphere call, since the real number
-// of segments is not even known yet. This was until 10.02.1997 a (small)
-// memory leak.
-
-E3dSphereObj::E3dSphereObj(Dummy /*dummy*/)
-// the parameters it needs to be able to distinguish which
-// constructors of the two is meant. The above is the default.
+E3dSphereObj::E3dSphereObj(SdrModel& rSdrModel)
+: E3dCompoundObject(rSdrModel)
{
// Set defaults
- E3dDefaultAttributes aDefault;
+ const E3dDefaultAttributes aDefault;
+
SetDefaultAttributes(aDefault);
}
-void E3dSphereObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
+void E3dSphereObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
{
// Set defaults
aCenter = rDefault.GetDefaultSphereCenter();
@@ -95,9 +87,21 @@ SdrObject *E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/)
return nullptr;
}
-E3dSphereObj* E3dSphereObj::Clone() const
+E3dSphereObj* E3dSphereObj::Clone(SdrModel* pTargetModel) const
+{
+ return CloneHelper< E3dSphereObj >(pTargetModel);
+}
+
+E3dSphereObj& E3dSphereObj::operator=(const E3dSphereObj& rObj)
{
- return CloneHelper< E3dSphereObj >();
+ if( this == &rObj )
+ return *this;
+ E3dCompoundObject::operator=(rObj);
+
+ aCenter = rObj.aCenter;
+ aSize = rObj.aSize;
+
+ return *this;
}
// Set local parameters with geometry re-creating
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx
index 33d051f23309..31d6c36bb44c 100644
--- a/svx/source/engine3d/view3d.cxx
+++ b/svx/source/engine3d/view3d.cxx
@@ -224,10 +224,12 @@ void Impl3DMirrorConstructOverlay::SetMirrorAxis(Point aMirrorAxisA, Point aMirr
}
}
-E3dView::E3dView(SdrModel* pModel, OutputDevice* pOut) :
- SdrView(pModel, pOut)
+E3dView::E3dView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: SdrView(rSdrModel, pOut)
{
- InitView ();
+ InitView();
}
// DrawMarkedObj override, since possibly only a single 3D object is to be
@@ -579,7 +581,6 @@ bool E3dView::ImpCloneAll3DObjectsToDestScene(E3dScene const * pSrcScene, E3dSce
pNewCompoundObj->SetTransform(aModifyingTransform * aNewObjectTrans);
// fill and insert new object
- pNewCompoundObj->SetModel(pDstScene->GetModel());
pNewCompoundObj->SetPage(pDstScene->GetPage());
pNewCompoundObj->NbcSetLayer(pCompoundObj->GetLayer());
pNewCompoundObj->NbcSetStyleSheet(pCompoundObj->GetStyleSheet(), true);
@@ -700,10 +701,15 @@ void E3dView::ImpCreateSingle3DObjectFlat(E3dScene* pScene, SdrObject* pObj, boo
if(pPath)
{
E3dDefaultAttributes aDefault = Get3DDefaultAttributes();
+
if(bExtrude)
+ {
aDefault.SetDefaultExtrudeCharacterMode(true);
+ }
else
+ {
aDefault.SetDefaultLatheCharacterMode(true);
+ }
// Get Itemset of the original object
SfxItemSet aSet(pObj->GetMergedItemSet());
@@ -736,13 +742,13 @@ void E3dView::ImpCreateSingle3DObjectFlat(E3dScene* pScene, SdrObject* pObj, boo
E3dObject* p3DObj = nullptr;
if(bExtrude)
{
- p3DObj = new E3dExtrudeObj(aDefault, pPath->GetPathPoly(), fDepth);
+ p3DObj = new E3dExtrudeObj(pObj->getSdrModelFromSdrObject(), aDefault, pPath->GetPathPoly(), fDepth);
}
else
{
basegfx::B2DPolyPolygon aPolyPoly2D(pPath->GetPathPoly());
aPolyPoly2D.transform(rLatheMat);
- p3DObj = new E3dLatheObj(aDefault, aPolyPoly2D);
+ p3DObj = new E3dLatheObj(pObj->getSdrModelFromSdrObject(), aDefault, aPolyPoly2D);
}
// Set attribute
@@ -836,8 +842,10 @@ void E3dView::ConvertMarkedObjTo3D(bool bExtrude, const basegfx::B2DPoint& rPnt1
else
BegUndo(SvxResId(RID_SVX_3D_UNDO_LATHE));
+ SdrModel& rSdrModel(GetSdrMarkByIndex(0)->GetMarkedSdrObj()->getSdrModelFromSdrObject());
+
// Create a new scene for the created 3D object
- E3dScene* pScene = new E3dScene;
+ E3dScene* pScene = new E3dScene(rSdrModel);
// Determine rectangle and possibly correct it
tools::Rectangle aRect = GetAllMarkedRect();
@@ -1262,7 +1270,6 @@ bool E3dView::BegDragObj(const Point& rPnt, OutputDevice* pOut,
}
// Set current 3D drawing object, create the scene for this
-
E3dScene* E3dView::SetCurrent3DObj(E3dObject* p3DObj)
{
DBG_ASSERT(p3DObj != nullptr, "Who puts in a NULL-pointer here");
@@ -1275,7 +1282,7 @@ E3dScene* E3dView::SetCurrent3DObj(E3dObject* p3DObj)
tools::Rectangle aRect(0,0, static_cast<long>(fW), static_cast<long>(fH));
- E3dScene* pScene = new E3dScene;
+ E3dScene* pScene = new E3dScene(p3DObj->getSdrModelFromSdrObject());
InitScene(pScene, fW, fH, aVolume.getMaxZ() + ((fW + fH) / 4.0));
diff --git a/svx/source/form/fmdmod.cxx b/svx/source/form/fmdmod.cxx
index d487399fedf9..ac197b2ff419 100644
--- a/svx/source/form/fmdmod.cxx
+++ b/svx/source/form/fmdmod.cxx
@@ -31,6 +31,7 @@ using namespace ::svxform;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxFmMSFactory::createInstance(const OUString& rServiceSpecifier)
{
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRet;
+
if ( rServiceSpecifier.startsWith( "com.sun.star.form.component." ) )
{
css::uno::Reference<css::uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
@@ -38,11 +39,17 @@ using namespace ::svxform;
}
else if ( rServiceSpecifier == "com.sun.star.drawing.ControlShape" )
{
- SdrObject* pObj = new FmFormObj();
+ SdrModel* pTargetModel = getSdrModelFromUnoModel();
+ OSL_ENSURE(pTargetModel, "Got no SdrModel for SdrShape construction (!)");
+ SdrObject* pObj = new FmFormObj(*pTargetModel);
xRet = static_cast<cppu::OWeakObject*>(static_cast<SvxShape_UnoImplHelper*>(new SvxShapeControl(pObj)));
}
+
if (!xRet.is())
+ {
xRet = SvxUnoDrawMSFactory::createInstance(rServiceSpecifier);
+ }
+
return xRet;
}
diff --git a/svx/source/form/fmdpage.cxx b/svx/source/form/fmdpage.cxx
index 1e81e8fe08e8..45ac667c50eb 100644
--- a/svx/source/form/fmdpage.cxx
+++ b/svx/source/form/fmdpage.cxx
@@ -73,10 +73,13 @@ SdrObject *SvxFmDrawPage::CreateSdrObject_( const css::uno::Reference< css::draw
if ( aShapeType == "com.sun.star.drawing.ShapeControl" // compatibility
|| aShapeType == "com.sun.star.drawing.ControlShape"
)
- return new FmFormObj();
+ {
+ return new FmFormObj(GetSdrPage()->getSdrModelFromSdrPage());
+ }
else
+ {
return SvxDrawPage::CreateSdrObject_( xDescr );
-
+ }
}
css::uno::Reference< css::drawing::XShape > SvxFmDrawPage::CreateShape( SdrObject *pObj ) const
diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx
index 5863ec9f38f6..44431b8018da 100644
--- a/svx/source/form/fmobj.cxx
+++ b/svx/source/form/fmobj.cxx
@@ -55,26 +55,27 @@ using namespace ::com::sun::star::container;
using namespace ::svxform;
-FmFormObj::FmFormObj(const OUString& rModelName)
- :SdrUnoObj ( rModelName )
- ,m_nPos ( -1 )
- ,m_pLastKnownRefDevice ( nullptr )
+FmFormObj::FmFormObj(
+ SdrModel& rSdrModel,
+ const OUString& rModelName)
+: SdrUnoObj(rSdrModel, rModelName)
+ ,m_nPos(-1)
+ ,m_pLastKnownRefDevice(nullptr)
{
-
// normally, this is done in SetUnoControlModel, but if the call happened in the base class ctor,
// then our incarnation of it was not called (since we were not constructed at this time).
impl_checkRefDevice_nothrow( true );
}
-
-FmFormObj::FmFormObj()
- :SdrUnoObj ( "" )
- ,m_nPos ( -1 )
- ,m_pLastKnownRefDevice ( nullptr )
+FmFormObj::FmFormObj(SdrModel& rSdrModel)
+: SdrUnoObj(rSdrModel, "")
+ ,m_nPos(-1)
+ ,m_pLastKnownRefDevice(nullptr)
{
+ // Stuff that old SetModel also did:
+ impl_checkRefDevice_nothrow();
}
-
FmFormObj::~FmFormObj()
{
@@ -105,7 +106,7 @@ void FmFormObj::ClearObjEnv()
void FmFormObj::impl_checkRefDevice_nothrow( bool _force )
{
- const FmFormModel* pFormModel = dynamic_cast<FmFormModel*>( GetModel() );
+ const FmFormModel* pFormModel = dynamic_cast<FmFormModel*>(&getSdrModelFromSdrObject());
if ( !pFormModel || !pFormModel->ControlsUseRefDevice() )
return;
@@ -357,9 +358,9 @@ void FmFormObj::clonedFrom(const FmFormObj* _pSource)
}
-FmFormObj* FmFormObj::Clone() const
+FmFormObj* FmFormObj::Clone(SdrModel* pTargetModel) const
{
- FmFormObj* pFormObject = CloneHelper< FmFormObj >();
+ FmFormObj* pFormObject = CloneHelper< FmFormObj >(pTargetModel);
DBG_ASSERT(pFormObject != nullptr, "FmFormObj::Clone : invalid clone !");
if (pFormObject)
pFormObject->clonedFrom(this);
@@ -368,13 +369,6 @@ FmFormObj* FmFormObj::Clone() const
}
-void FmFormObj::NbcReformatText()
-{
- impl_checkRefDevice_nothrow();
- SdrUnoObj::NbcReformatText();
-}
-
-
FmFormObj& FmFormObj::operator= (const FmFormObj& rObj)
{
if( this == &rObj )
@@ -401,6 +395,13 @@ FmFormObj& FmFormObj::operator= (const FmFormObj& rObj)
}
+void FmFormObj::NbcReformatText()
+{
+ impl_checkRefDevice_nothrow();
+ SdrUnoObj::NbcReformatText();
+}
+
+
namespace
{
OUString lcl_getFormComponentAccessPath(const Reference< XInterface >& _xElement, Reference< XInterface >& _rTopLevelElement)
@@ -584,14 +585,6 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface >
return Reference<XInterface>( xDestContainer, UNO_QUERY );
}
-
-void FmFormObj::SetModel( SdrModel* _pNewModel )
-{
- SdrUnoObj::SetModel( _pNewModel );
- impl_checkRefDevice_nothrow();
-}
-
-
FmFormObj* FmFormObj::GetFormObject( SdrObject* _pSdrObject )
{
FmFormObj* pFormObject = dynamic_cast< FmFormObj* >( _pSdrObject );
diff --git a/svx/source/form/fmobjfac.cxx b/svx/source/form/fmobjfac.cxx
index bfc834e9cd1a..a640caac7c0c 100644
--- a/svx/source/form/fmobjfac.cxx
+++ b/svx/source/form/fmobjfac.cxx
@@ -106,10 +106,10 @@ namespace
}
}
-IMPL_STATIC_LINK(
- FmFormObjFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject*)
+IMPL_STATIC_LINK(FmFormObjFactory, MakeObject, SdrObjCreatorParams, aParams, SdrObject*)
{
SdrObject* pNewObj = nullptr;
+
if (aParams.nInventor == SdrInventor::FmForm)
{
OUString sServiceSpecifier;
@@ -213,9 +213,9 @@ IMPL_STATIC_LINK(
// create the actual object
if ( !sServiceSpecifier.isEmpty() )
- pNewObj = new FmFormObj(sServiceSpecifier);
+ pNewObj = new FmFormObj(aParams.rSdrModel, sServiceSpecifier);
else
- pNewObj = new FmFormObj();
+ pNewObj = new FmFormObj(aParams.rSdrModel);
// initialize some properties which we want to differ from the defaults
for ( PropertyValueArray::const_iterator aInitProp = aInitialProperties.begin();
diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx
index 7f267cbbcf03..ca79aba3845f 100644
--- a/svx/source/form/fmpage.cxx
+++ b/svx/source/form/fmpage.cxx
@@ -49,22 +49,17 @@ using com::sun::star::uno::UNO_QUERY;
FmFormPage::FmFormPage(FmFormModel& rModel, bool bMasterPage)
- :SdrPage(rModel, bMasterPage)
- ,m_pImpl( new FmFormPageImpl( *this ) )
+: SdrPage(rModel, bMasterPage)
+ ,m_pImpl( new FmFormPageImpl( *this ) )
{
}
-
-FmFormPage::FmFormPage(const FmFormPage& rPage)
- :SdrPage(rPage)
- ,m_pImpl(new FmFormPageImpl( *this ) )
-{
-}
-
-void FmFormPage::lateInit(const FmFormPage& rPage, FmFormModel* const pNewModel)
+void FmFormPage::lateInit(const FmFormPage& rPage)
{
- SdrPage::lateInit( rPage, pNewModel );
+ // call parent
+ SdrPage::lateInit( rPage );
+ // copy local variables (former stuff from copy constructor)
m_pImpl->initFrom( rPage.GetImpl() );
m_sPageName = rPage.m_sPageName;
}
@@ -74,65 +69,22 @@ FmFormPage::~FmFormPage()
{
}
-
-void FmFormPage::SetModel(SdrModel* pNewModel)
-{
- /* #35055# */
- // we want to call the super's "SetModel" method even if the model is the
- // same, in case code somewhere in the system depends on it. But our code
- // doesn't, so get the old model to do a check.
- SdrModel *pOldModel = GetModel();
-
- SdrPage::SetModel( pNewModel );
-
- /* #35055# */
- if ( ( pOldModel != pNewModel ) && m_pImpl )
- {
- try
- {
- Reference< css::form::XForms > xForms( m_pImpl->getForms( false ) );
- if ( xForms.is() )
- {
- // we want to keep the current collection, just reset the model
- // with which it's associated.
- FmFormModel* pDrawModel = static_cast<FmFormModel*>( GetModel() );
- SfxObjectShell* pObjShell = pDrawModel->GetObjectShell();
- if ( pObjShell )
- xForms->setParent( pObjShell->GetModel() );
- }
- }
- catch( css::uno::Exception const& )
- {
- OSL_FAIL( "UNO Exception caught resetting model for m_pImpl (FmFormPageImpl) in FmFormPage::SetModel" );
- }
- }
-}
-
-
-SdrPage* FmFormPage::Clone() const
-{
- return Clone(nullptr);
-}
-
-SdrPage* FmFormPage::Clone(SdrModel* const pNewModel) const
+SdrPage* FmFormPage::Clone(SdrModel* pNewModel) const
{
- FmFormPage* const pNewPage = new FmFormPage(*this);
- FmFormModel* pFormModel = nullptr;
- if (pNewModel)
- {
- pFormModel = dynamic_cast<FmFormModel*>(pNewModel);
- assert(pFormModel);
- }
- pNewPage->lateInit(*this, pFormModel);
- return pNewPage;
+ FmFormModel& rFmFormModel(static_cast< FmFormModel& >(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
+ FmFormPage* pClonedFmFormPage(
+ new FmFormPage(
+ rFmFormModel,
+ IsMasterPage()));
+ pClonedFmFormPage->lateInit(*this);
+ return pClonedFmFormPage;
}
void FmFormPage::InsertObject(SdrObject* pObj, size_t nPos)
{
SdrPage::InsertObject( pObj, nPos );
- if (GetModel())
- static_cast<FmFormModel*>(GetModel())->GetUndoEnv().Inserted(pObj);
+ static_cast< FmFormModel& >(getSdrModelFromSdrPage()).GetUndoEnv().Inserted(pObj);
}
@@ -217,8 +169,8 @@ bool FmFormPage::RequestHelp( vcl::Window* pWindow, SdrView const * pView,
SdrObject* FmFormPage::RemoveObject(size_t nObjNum)
{
SdrObject* pObj = SdrPage::RemoveObject(nObjNum);
- if (pObj && GetModel())
- static_cast<FmFormModel*>(GetModel())->GetUndoEnv().Removed(pObj);
+ if (pObj)
+ static_cast< FmFormModel& >(getSdrModelFromSdrPage()).GetUndoEnv().Removed(pObj);
return pObj;
}
diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx
index 3d974c0eb02e..417f84a1212c 100644
--- a/svx/source/form/fmpgeimp.cxx
+++ b/svx/source/form/fmpgeimp.cxx
@@ -315,16 +315,15 @@ const Reference< css::form::XForms >& FmFormPageImpl::getForms( bool _bForceCrea
m_aFormsCreationHdl.Call( *this );
}
- FmFormModel* pFormsModel = dynamic_cast<FmFormModel*>( m_rPage.GetModel() );
+ FmFormModel& rFmFormModel(dynamic_cast< FmFormModel& >(m_rPage.getSdrModelFromSdrPage()));
// give the newly created collection a place in the universe
- SfxObjectShell* pObjShell = pFormsModel ? pFormsModel->GetObjectShell() : nullptr;
+ SfxObjectShell* pObjShell(rFmFormModel.GetObjectShell());
if ( pObjShell )
m_xForms->setParent( pObjShell->GetModel() );
// tell the UNDO environment that we have a new forms collection
- if ( pFormsModel )
- pFormsModel->GetUndoEnv().AddForms( Reference<XNameContainer>(m_xForms,UNO_QUERY_THROW) );
+ rFmFormModel.GetUndoEnv().AddForms( Reference<XNameContainer>(m_xForms,UNO_QUERY_THROW) );
}
return m_xForms;
}
@@ -396,13 +395,13 @@ Reference< XForm > FmFormPageImpl::getDefaultForm()
// did not find an existing suitable form -> create a new one
if ( !xForm.is() )
{
- SdrModel* pModel = m_rPage.GetModel();
+ SdrModel& rModel(m_rPage.getSdrModelFromSdrPage());
- if( pModel->IsUndoEnabled() )
+ if( rModel.IsUndoEnabled() )
{
OUString aStr(SvxResId(RID_STR_FORM));
OUString aUndoStr(SvxResId(RID_STR_UNDO_CONTAINER_INSERT));
- pModel->BegUndo(aUndoStr.replaceFirst("'#'", aStr));
+ rModel.BegUndo(aUndoStr.replaceFirst("'#'", aStr));
}
try
@@ -417,13 +416,15 @@ Reference< XForm > FmFormPageImpl::getDefaultForm()
OUString sName = SvxResId(RID_STR_STDFORMNAME);
xFormProps->setPropertyValue( FM_PROP_NAME, makeAny( sName ) );
- if( pModel->IsUndoEnabled() )
+ if( rModel.IsUndoEnabled() )
{
- pModel->AddUndo(new FmUndoContainerAction(*static_cast<FmFormModel*>(pModel),
- FmUndoContainerAction::Inserted,
- xForms,
- xForm,
- xForms->getCount()));
+ rModel.AddUndo(
+ new FmUndoContainerAction(
+ static_cast< FmFormModel& >(rModel),
+ FmUndoContainerAction::Inserted,
+ xForms,
+ xForm,
+ xForms->getCount()));
}
xForms->insertByName( sName, makeAny( xForm ) );
xCurrentForm = xForm;
@@ -434,8 +435,8 @@ Reference< XForm > FmFormPageImpl::getDefaultForm()
xForm.clear();
}
- if( pModel->IsUndoEnabled() )
- pModel->EndUndo();
+ if( rModel.IsUndoEnabled() )
+ rModel.EndUndo();
}
return xForm;
@@ -474,16 +475,15 @@ Reference< css::form::XForm > FmFormPageImpl::findPlaceInFormComponentHierarchy
// If no css::form found, then create a new one
if (!xForm.is())
{
- SdrModel* pModel = m_rPage.GetModel();
-
- const bool bUndo = pModel->IsUndoEnabled();
+ SdrModel& rModel(m_rPage.getSdrModelFromSdrPage());
+ const bool bUndo(rModel.IsUndoEnabled());
if( bUndo )
{
OUString aStr(SvxResId(RID_STR_FORM));
OUString aUndoStr(SvxResId(RID_STR_UNDO_CONTAINER_INSERT));
aUndoStr = aUndoStr.replaceFirst("#", aStr);
- pModel->BegUndo(aUndoStr);
+ rModel.BegUndo(aUndoStr);
}
xForm.set(::comphelper::getProcessServiceFactory()->createInstance(FM_SUN_COMPONENT_FORM), UNO_QUERY);
@@ -515,17 +515,19 @@ Reference< css::form::XForm > FmFormPageImpl::findPlaceInFormComponentHierarchy
if( bUndo )
{
Reference< css::container::XIndexContainer > xContainer( getForms(), UNO_QUERY );
- pModel->AddUndo(new FmUndoContainerAction(*static_cast<FmFormModel*>(pModel),
- FmUndoContainerAction::Inserted,
- xContainer,
- xForm,
- xContainer->getCount()));
+ rModel.AddUndo(
+ new FmUndoContainerAction(
+ static_cast< FmFormModel& >(rModel),
+ FmUndoContainerAction::Inserted,
+ xContainer,
+ xForm,
+ xContainer->getCount()));
}
getForms()->insertByName( sName, makeAny( xForm ) );
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
}
xCurrentForm = xForm;
}
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
index a21e90431d7b..560b2fa5c70b 100644
--- a/svx/source/form/fmshimp.cxx
+++ b/svx/source/form/fmshimp.cxx
@@ -3845,10 +3845,8 @@ void FmXFormShell::loadForms_Lock(FmFormPage* _pPage, const LoadFormsFlags _nBeh
{
// lock the undo env so the forms can change non-transient properties while loading
// (without this my doc's modified flag would be set)
- FmFormModel* pModel = dynamic_cast<FmFormModel*>( _pPage->GetModel() );
- DBG_ASSERT( pModel, "FmXFormShell::loadForms: invalid model!" );
- if ( pModel )
- pModel->GetUndoEnv().Lock();
+ FmFormModel& rFmFormModel(dynamic_cast< FmFormModel& >(_pPage->getSdrModelFromSdrPage()));
+ rFmFormModel.GetUndoEnv().Lock();
// load all forms
Reference< XIndexAccess > xForms;
@@ -3894,9 +3892,8 @@ void FmXFormShell::loadForms_Lock(FmFormPage* _pPage, const LoadFormsFlags _nBeh
}
}
- if ( pModel )
- // unlock the environment
- pModel->GetUndoEnv().UnLock();
+ // unlock the environment
+ rFmFormModel.GetUndoEnv().UnLock();
}
}
diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx
index 2adad0dc524f..6acd8b890e2d 100644
--- a/svx/source/form/fmview.cxx
+++ b/svx/source/form/fmview.cxx
@@ -77,14 +77,14 @@ using namespace ::com::sun::star::util;
using namespace ::svxform;
using namespace ::svx;
-
-FmFormView::FmFormView( FmFormModel* pModel, OutputDevice* pOut )
- :E3dView(pModel,pOut)
+FmFormView::FmFormView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: E3dView(rSdrModel, pOut)
{
Init();
}
-
void FmFormView::Init()
{
pFormShell = nullptr;
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx
index cbf975fe0a2d..30dd8add1b1d 100644
--- a/svx/source/form/fmvwimp.cxx
+++ b/svx/source/form/fmvwimp.cxx
@@ -1350,7 +1350,7 @@ SdrObject* FmXFormView::implCreateFieldControl( const svx::ODataAccessDescriptor
if ( bCheckbox )
return pControl;
- SdrObjGroup* pGroup = new SdrObjGroup();
+ SdrObjGroup* pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
SdrObjList* pObjList = pGroup->GetSubList();
pObjList->InsertObject( pLabel );
pObjList->InsertObject( pControl );
@@ -1462,7 +1462,7 @@ SdrObject* FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_
// group objects
- SdrObjGroup* pGroup = new SdrObjGroup();
+ SdrObjGroup* pGroup = new SdrObjGroup(getView()->getSdrModelFromSdrView());
SdrObjList* pObjList = pGroup->GetSubList();
pObjList->InsertObject(pLabel);
pObjList->InsertObject(pControl);
@@ -1476,7 +1476,11 @@ SdrObject* FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_
const MapMode eSourceMode(MapUnit::Map100thMM);
const sal_uInt16 nObjID = OBJ_FM_BUTTON;
::Size controlSize(4000, 500);
- FmFormObj *pControl = static_cast<FmFormObj*>(SdrObjFactory::MakeNewObject( SdrInventor::FmForm, nObjID, nullptr ));
+ FmFormObj *pControl = static_cast<FmFormObj*>(
+ SdrObjFactory::MakeNewObject(
+ getView()->getSdrModelFromSdrView(),
+ SdrInventor::FmForm,
+ nObjID));
controlSize.setWidth( long(controlSize.Width() * eTargetMode.GetScaleX()) );
controlSize.setHeight( long(controlSize.Height() * eTargetMode.GetScaleY()) );
::Point controlPos( OutputDevice::LogicToLogic( ::Point( controlSize.Width(), 0 ), eSourceMode, eTargetMode ) );
@@ -1576,11 +1580,18 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
// the label
::std::unique_ptr< SdrUnoObj > pLabel;
Reference< XPropertySet > xLabelModel;
+
if ( bNeedLabel )
{
pLabel.reset( dynamic_cast< SdrUnoObj* >(
- SdrObjFactory::MakeNewObject( _nInventor, _nLabelObjectID, _pLabelPage, _pModel ) ) );
+ SdrObjFactory::MakeNewObject(
+ *_pModel,
+ _nInventor,
+ _nLabelObjectID,
+ _pLabelPage)));
+
OSL_ENSURE( pLabel.get(), "FmXFormView::createControlLabelPair: could not create the label!" );
+
if ( !pLabel.get() )
return false;
@@ -1606,8 +1617,14 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int
// the control
::std::unique_ptr< SdrUnoObj > pControl( dynamic_cast< SdrUnoObj* >(
- SdrObjFactory::MakeNewObject( _nInventor, _nControlObjectID, _pControlPage, _pModel ) ) );
+ SdrObjFactory::MakeNewObject(
+ *_pModel,
+ _nInventor,
+ _nControlObjectID,
+ _pControlPage)));
+
OSL_ENSURE( pControl.get(), "FmXFormView::createControlLabelPair: could not create the control!" );
+
if ( !pControl.get() )
return false;
diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx
index d9e6a205cbfe..a91fabd1c527 100644
--- a/svx/source/gallery2/galobj.cxx
+++ b/svx/source/gallery2/galobj.cxx
@@ -458,7 +458,7 @@ bool SgaObjectSvDraw::CreateThumb( const FmFormModel& rModel )
if(aObjRect.GetWidth() && aObjRect.GetHeight())
{
ScopedVclPtrInstance< VirtualDevice > pVDev;
- FmFormView aView(const_cast< FmFormModel* >(&rModel), pVDev);
+ FmFormView aView(const_cast< FmFormModel& >(rModel), pVDev);
aView.ShowSdrPage(const_cast< FmFormPage* >(pPage));
aView.MarkAllObj();
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index de21ba0307bb..9c8b27bef7d5 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -801,7 +801,7 @@ bool GalleryTheme::GetGraphic(sal_uInt32 nPos, Graphic& rGraphic)
{
ScopedVclPtrInstance< VirtualDevice > pVDev;
pVDev->SetMapMode( MapMode( MapUnit::Map100thMM ) );
- FmFormView aView( aModel.GetModel(), pVDev );
+ FmFormView aView(*aModel.GetModel(), pVDev);
aView.hideMarkHandles();
aView.ShowSdrPage(aView.GetModel()->GetPage(0));
@@ -1244,7 +1244,7 @@ bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTrans
if( aModel.GetModel() )
{
SdrPage* pPage = aModel.GetModel()->GetPage(0);
- SdrGrafObj* pGrafObj = new SdrGrafObj( *pGraphic );
+ SdrGrafObj* pGrafObj = new SdrGrafObj(*aModel.GetModel(), *pGraphic );
pGrafObj->AppendUserData( new SgaIMapInfo( aImageMap ) );
pPage->InsertObject( pGrafObj );
diff --git a/svx/source/inc/cell.hxx b/svx/source/inc/cell.hxx
index 5b7f71b04c89..86c7579e1726 100644
--- a/svx/source/inc/cell.hxx
+++ b/svx/source/inc/cell.hxx
@@ -91,8 +91,6 @@ public:
SVX_DLLPRIVATE SdrTextVertAdjust GetTextVerticalAdjust() const;
SdrTextHorzAdjust GetTextHorizontalAdjust() const;
- SVX_DLLPRIVATE virtual void SetModel(SdrModel* pNewModel) override;
-
SVX_DLLPRIVATE void merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan );
SVX_DLLPRIVATE void mergeContent( const CellRef& xSourceCell );
SVX_DLLPRIVATE void replaceContentAndFormating( const CellRef& xSourceCell );
diff --git a/svx/source/inc/fmobj.hxx b/svx/source/inc/fmobj.hxx
index 6b9adf61c548..da9f7c6fbfd7 100644
--- a/svx/source/inc/fmobj.hxx
+++ b/svx/source/inc/fmobj.hxx
@@ -27,7 +27,7 @@
// FmFormObj
-class SVX_DLLPUBLIC FmFormObj: public SdrUnoObj
+class SVX_DLLPUBLIC FmFormObj : public SdrUnoObj
{
FmFormObj( const FmFormObj& ) = delete;
@@ -47,9 +47,10 @@ class SVX_DLLPUBLIC FmFormObj: public SdrUnoObj
// only to be used for comparison with the current ref device!
public:
- FmFormObj(const OUString& rModelName);
- FmFormObj();
-
+ FmFormObj(
+ SdrModel& rSdrModel,
+ const OUString& rModelName);
+ FmFormObj(SdrModel& rSdrModel);
SAL_DLLPRIVATE const css::uno::Reference< css::container::XIndexContainer>&
GetOriginalParent() const { return m_xParent; }
@@ -72,12 +73,10 @@ public:
SAL_DLLPRIVATE virtual sal_uInt16 GetObjIdentifier() const override;
SAL_DLLPRIVATE virtual void NbcReformatText() override;
- SAL_DLLPRIVATE virtual FmFormObj* Clone() const override;
+ SAL_DLLPRIVATE virtual FmFormObj* Clone(SdrModel* pTargetModel = nullptr) const override;
// #116235# virtual SdrObject* Clone(SdrPage* pPage, SdrModel* pModel) const;
SAL_DLLPRIVATE FmFormObj& operator= (const FmFormObj& rObj);
- SAL_DLLPRIVATE virtual void SetModel(SdrModel* pNewModel) override;
-
SAL_DLLPRIVATE void clonedFrom(const FmFormObj* _pSource);
SAL_DLLPRIVATE static css::uno::Reference< css::uno::XInterface> ensureModelEnv(
diff --git a/svx/source/inc/tablemodel.hxx b/svx/source/inc/tablemodel.hxx
index e59626da0200..791a4310f190 100644
--- a/svx/source/inc/tablemodel.hxx
+++ b/svx/source/inc/tablemodel.hxx
@@ -176,7 +176,7 @@ private:
rtl::Reference< TableColumns > mxTableColumns;
rtl::Reference< TableRows > mxTableRows;
- SdrTableObj* mpTableObj;
+ SdrTableObj* mpTableObj; // TTTT should be reference
bool mbModified;
bool mbNotifyPending;
diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx
index b7c3086fe735..3c0622bad264 100644
--- a/svx/source/sdr/contact/viewcontactofgraphic.cxx
+++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx
@@ -241,7 +241,7 @@ namespace sdr
aDraftText += " ...";
}
- if (!aDraftText.isEmpty() && GetGrafObject().GetModel())
+ if (!aDraftText.isEmpty())
{
// #i103255# Goal is to produce TextPrimitives which hold the given text as
// BlockText in the available space. It would be very tricky to do
@@ -253,8 +253,7 @@ namespace sdr
// needed and can be deleted.
// create temp RectObj as TextObj and set needed attributes
- SdrRectObj aRectObj(OBJ_TEXT);
- aRectObj.SetModel(GetGrafObject().GetModel());
+ SdrRectObj aRectObj(GetGrafObject().getSdrModelFromSdrObject(), OBJ_TEXT);
aRectObj.NbcSetText(aDraftText);
aRectObj.SetMergedItem(SvxColorItem(COL_LIGHTRED, EE_CHAR_COLOR));
diff --git a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx
index c0ab639395de..f02ba917280c 100644
--- a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx
@@ -72,8 +72,7 @@ drawinglayer::primitive2d::Primitive2DContainer ViewContactOfSdrRectObj::createV
drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY);
// #i105856# use knowledge about pickthrough from the model
- const bool bPickThroughTransparentTextFrames(
- GetRectObj().GetModel() && GetRectObj().GetModel()->IsPickThroughTransparentTextFrames());
+ const bool bPickThroughTransparentTextFrames(GetRectObj().getSdrModelFromSdrObject().IsPickThroughTransparentTextFrames());
// create primitive. Always create primitives to allow the decomposition of
// SdrRectanglePrimitive2D to create needed invisible elements for HitTest and/or BoundRect
diff --git a/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx
index 95ed93a42b4c..f6e425fb1cfa 100644
--- a/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx
+++ b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx
@@ -242,7 +242,7 @@ namespace sdr
{
// prepare primitive generation with evtl. loading the graphic when it's swapped out
SdrGrafObj& rGrafObj = const_cast< ViewObjectContactOfGraphic* >(this)->getSdrGrafObj();
- bool bDoAsynchronGraphicLoading(rGrafObj.GetModel() && rGrafObj.GetModel()->IsSwapGraphics());
+ bool bDoAsynchronGraphicLoading(rGrafObj.getSdrModelFromSdrObject().IsSwapGraphics());
if( bDoAsynchronGraphicLoading && rGrafObj.IsSwappedOut() )
{
diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
index 60e130c8b949..452971758bbc 100644
--- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx
+++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
@@ -527,7 +527,7 @@ namespace drawinglayer
bool bChainable = rTextObj.IsChainable();
- if(rText.GetOutlinerParaObject() && rText.GetModel())
+ if(rText.GetOutlinerParaObject())
{
// added TextEdit text suppression
bool bInEditMode(false);
@@ -564,7 +564,7 @@ namespace drawinglayer
const SdrTextAniKind eAniKind(rTextObj.GetTextAniKind());
// #i107346#
- const SdrOutliner& rDrawTextOutliner = rText.GetModel()->GetDrawOutliner(&rTextObj);
+ const SdrOutliner& rDrawTextOutliner(rText.GetObject().getSdrModelFromSdrObject().GetDrawOutliner(&rTextObj));
const bool bWrongSpell(rDrawTextOutliner.GetControlWord() & EEControlBits::ONLINESPELLING);
return attribute::SdrTextAttribute(
diff --git a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx
index 0cdd5d0216d2..e3d7aba47366 100644
--- a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx
+++ b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx
@@ -64,16 +64,16 @@ namespace
sal_Int16 nRetval(0);
SdrPage* pPage = GetSdrPageFromXDrawPage(rxDrawPage);
- if(pPage && pPage->GetModel())
+ if(pPage)
{
if( (pPage->GetPageNum() == 0) && !pPage->IsMasterPage() )
{
// handout page!
- return pPage->GetModel()->getHandoutPageCount();
+ return pPage->getSdrModelFromSdrPage().getHandoutPageCount();
}
else
{
- const sal_uInt16 nPageCount(pPage->GetModel()->GetPageCount());
+ const sal_uInt16 nPageCount(pPage->getSdrModelFromSdrPage().GetPageCount());
nRetval = (static_cast<sal_Int16>(nPageCount) - 1) / 2;
}
}
@@ -188,9 +188,9 @@ namespace drawinglayer
}
// #i101443# check change of TextBackgroundolor
- if(!bDoDelete && getSdrText() && getSdrText()->GetModel())
+ if(!bDoDelete && getSdrText())
{
- SdrOutliner& rDrawOutliner = getSdrText()->GetModel()->GetDrawOutliner();
+ SdrOutliner& rDrawOutliner = getSdrText()->GetObject().getSdrModelFromSdrObject().GetDrawOutliner();
aNewTextBackgroundColor = rDrawOutliner.GetBackgroundColor();
bNewTextBackgroundColorIsSet = true;
@@ -223,9 +223,9 @@ namespace drawinglayer
nCurrentlyValidPageCount = getPageCount(xCurrentlyVisualizingPage);
}
- if(!bNewTextBackgroundColorIsSet && getSdrText() && getSdrText()->GetModel())
+ if(!bNewTextBackgroundColorIsSet && getSdrText())
{
- SdrOutliner& rDrawOutliner = getSdrText()->GetModel()->GetDrawOutliner();
+ SdrOutliner& rDrawOutliner = getSdrText()->GetObject().getSdrModelFromSdrObject().GetDrawOutliner();
aNewTextBackgroundColor = rDrawOutliner.GetBackgroundColor();
}
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx
index b4038eab847a..d14b7ffd6b2f 100644
--- a/svx/source/sdr/properties/attributeproperties.cxx
+++ b/svx/source/sdr/properties/attributeproperties.cxx
@@ -44,33 +44,40 @@
#include <svx/svdmodel.hxx>
#include <svx/svdtrans.hxx>
#include <svx/svdpage.hxx>
-
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
namespace sdr
{
namespace properties
{
- void AttributeProperties::ImpAddStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr)
+ SfxStyleSheet* AttributeProperties::ImpGetDefaultStyleSheet() const
{
- // test if old StyleSheet is cleared, else it would be lost
- // after this method -> memory leak (!)
- DBG_ASSERT(!mpStyleSheet, "Old style sheet not deleted before setting new one (!)");
+ // use correct default stylesheet #119287#
+ const SdrGrafObj* pIsSdrGrafObj(dynamic_cast< const SdrGrafObj* >(&GetSdrObject()));
+ const SdrOle2Obj* pIsSdrOle2Obj(dynamic_cast< const SdrOle2Obj* >(&GetSdrObject()));
+ SfxStyleSheet* pRetval(nullptr);
- if(pNewStyleSheet)
+ if(pIsSdrGrafObj || pIsSdrOle2Obj)
{
- mpStyleSheet = pNewStyleSheet;
-
- // local ItemSet is needed here, force it
- GetObjectItemSet();
+ pRetval = GetSdrObject().getSdrModelFromSdrObject().GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj();
+ }
+ else
+ {
+ pRetval = GetSdrObject().getSdrModelFromSdrObject().GetDefaultStyleSheet();
+ }
- // register as listener
- StartListening(pNewStyleSheet->GetPool());
- StartListening(*pNewStyleSheet);
+ return pRetval;
+ }
+ void AttributeProperties::ImpSetParentAtSfxItemSet(bool bDontRemoveHardAttr)
+ {
+ if(HasSfxItemSet() && mpStyleSheet)
+ {
// Delete hard attributes where items are set in the style sheet
if(!bDontRemoveHardAttr)
{
- const SfxItemSet& rStyle = pNewStyleSheet->GetItemSet();
+ const SfxItemSet& rStyle = mpStyleSheet->GetItemSet();
SfxWhichIter aIter(rStyle);
sal_uInt16 nWhich = aIter.FirstWhich();
@@ -86,7 +93,37 @@ namespace sdr
}
// set new stylesheet as parent
- mpItemSet->SetParent(&pNewStyleSheet->GetItemSet());
+ mpItemSet->SetParent(&mpStyleSheet->GetItemSet());
+ }
+ else
+ {
+ OSL_ENSURE(false, "ImpSetParentAtSfxItemSet called without SfxItemSet/SfxStyleSheet (!)");
+ }
+ }
+
+ void AttributeProperties::ImpAddStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr)
+ {
+ // test if old StyleSheet is cleared, else it would be lost
+ // after this method -> memory leak (!)
+ DBG_ASSERT(!mpStyleSheet, "Old style sheet not deleted before setting new one (!)");
+
+ if(pNewStyleSheet)
+ {
+ // local remember
+ mpStyleSheet = pNewStyleSheet;
+
+ if(HasSfxItemSet())
+ {
+ // register as listener
+ StartListening(pNewStyleSheet->GetPool());
+ StartListening(*pNewStyleSheet);
+
+ // only apply the following when we have an SfxItemSet already, else
+ if(GetStyleSheet())
+ {
+ ImpSetParentAtSfxItemSet(bDontRemoveHardAttr);
+ }
+ }
}
}
@@ -99,7 +136,7 @@ namespace sdr
EndListening(mpStyleSheet->GetPool());
// reset parent of ItemSet
- if(mpItemSet)
+ if(HasSfxItemSet())
{
mpItemSet->SetParent(nullptr);
}
@@ -127,15 +164,59 @@ namespace sdr
: DefaultProperties(rObj),
mpStyleSheet(nullptr)
{
+ // Do nothing else, esp. do *not* try to get and set
+ // a default SfxStyle sheet. Nothing is allowed to be done
+ // that may lead to calls to virtual functions like
+ // CreateObjectSpecificItemSet - these would go *wrong*.
+ // Thus the rest is lazy-init from here.
}
AttributeProperties::AttributeProperties(const AttributeProperties& rProps, SdrObject& rObj)
: DefaultProperties(rProps, rObj),
mpStyleSheet(nullptr)
{
- if(rProps.GetStyleSheet())
+ SfxStyleSheet* pTargetStyleSheet(rProps.GetStyleSheet());
+
+ if(pTargetStyleSheet && &rObj.getSdrModelFromSdrObject() != &GetSdrObject().getSdrModelFromSdrObject())
{
- ImpAddStyleSheet(rProps.GetStyleSheet(), true);
+ // TTTT It is a clone to another model, thus the TargetStyleSheet
+ // is probably also from another SdrModel, so do *not* simply use it.
+ //
+ // The DefaultProperties::Clone already has cloned the ::SET items
+ // to a new SfxItemSet in the new SfxItemPool. There are quite some
+ // possibilities to continue:
+ // - Do not use StyleSheet (will do this for now)
+ // - Search for same StyleSheet in Target-SdrModel and use if found
+ // (use e.g. Name)
+ // - Clone used StyleSheet(s) to Target-SdrModel and use
+ // - Set all Attributes from the StyleSheet as hard attributes at the
+ // SfxItemSet
+ // The original AW080 uses 'ImpModelChange' (see there) which Clones
+ // and uses the used StyleSheets if there is a Target-SfxItemPool
+ // and sets to hard attributes if not. This may be used later if needed,
+ // but for now only a single UnitTest uses this Clone-scenario and works
+ // well with not using the TargetStyleSheet. The logic Cloning
+ // StyleSheets *should* - if needed - be on a higher level where it is
+ // potentially better known what would be the correct thing to do.
+ pTargetStyleSheet = nullptr;
+ }
+
+ if(pTargetStyleSheet)
+ {
+ if(HasSfxItemSet())
+ {
+ // The SfxItemSet has been cloned and exists,
+ // we can directly set the SfxStyleSheet at it
+ ImpAddStyleSheet(pTargetStyleSheet, true);
+ }
+ else
+ {
+ // No SfxItemSet exists yet (there is none in
+ // the source, so none was cloned). Remember the
+ // SfxStyleSheet to set it when the SfxItemSet
+ // got constructed on-demand
+ mpStyleSheet = pTargetStyleSheet;
+ }
}
}
@@ -149,6 +230,42 @@ namespace sdr
return *(new AttributeProperties(*this, rObj));
}
+ const SfxItemSet& AttributeProperties::GetObjectItemSet() const
+ {
+ // remember if we had a SfxItemSet already
+ const bool bHadSfxItemSet(HasSfxItemSet());
+
+ // call parent - this will then guarantee
+ // SfxItemSet existance
+ DefaultProperties::GetObjectItemSet();
+
+ if(!bHadSfxItemSet)
+ {
+ if(GetStyleSheet())
+ {
+ // Late-Init of setting parent to SfxStyleSheet after
+ // it's creation. See copy-constructor and how it remembers
+ // the SfxStyleSheet there.
+ // It is necessary to reset mpStyleSheet to nullptr to
+ // not trigger alarm insde ImpAddStyleSheet (!)
+ SfxStyleSheet* pNew(mpStyleSheet);
+ const_cast< AttributeProperties* >(this)->mpStyleSheet = nullptr;
+ const_cast< AttributeProperties* >(this)->ImpAddStyleSheet(
+ pNew,
+ true);
+ }
+ else
+ {
+ // Set missing defaults and do not RemoveHardAttributes
+ const_cast< AttributeProperties* >(this)->ImpAddStyleSheet(
+ ImpGetDefaultStyleSheet(),
+ true);
+ }
+ }
+
+ return *mpItemSet;
+ }
+
void AttributeProperties::ItemSetChanged(const SfxItemSet& /*rSet*/)
{
// own modifications
@@ -164,64 +281,72 @@ namespace sdr
if(pNewItem)
{
const SfxPoolItem* pResultItem = nullptr;
- SdrModel* pModel = GetSdrObject().GetModel();
+ SdrModel& rModel(GetSdrObject().getSdrModelFromSdrObject());
switch( nWhich )
{
case XATTR_FILLBITMAP:
{
- pResultItem = static_cast<const XFillBitmapItem*>(pNewItem)->checkForUniqueItem( pModel );
+ // TTTT checkForUniqueItem should use SdrModel&
+ pResultItem = static_cast<const XFillBitmapItem*>(pNewItem)->checkForUniqueItem( &rModel );
break;
}
case XATTR_LINEDASH:
{
- pResultItem = static_cast<const XLineDashItem*>(pNewItem)->checkForUniqueItem( pModel );
+ pResultItem = static_cast<const XLineDashItem*>(pNewItem)->checkForUniqueItem( &rModel );
break;
}
case XATTR_LINESTART:
{
- pResultItem = static_cast<const XLineStartItem*>(pNewItem)->checkForUniqueItem( pModel );
+ pResultItem = static_cast<const XLineStartItem*>(pNewItem)->checkForUniqueItem( &rModel );
break;
}
case XATTR_LINEEND:
{
- pResultItem = static_cast<const XLineEndItem*>(pNewItem)->checkForUniqueItem( pModel );
+ pResultItem = static_cast<const XLineEndItem*>(pNewItem)->checkForUniqueItem( &rModel );
break;
}
case XATTR_FILLGRADIENT:
{
- pResultItem = static_cast<const XFillGradientItem*>(pNewItem)->checkForUniqueItem( pModel );
+ pResultItem = static_cast<const XFillGradientItem*>(pNewItem)->checkForUniqueItem( &rModel );
break;
}
case XATTR_FILLFLOATTRANSPARENCE:
{
// #85953# allow all kinds of XFillFloatTransparenceItem to be set
- pResultItem = static_cast<const XFillFloatTransparenceItem*>(pNewItem)->checkForUniqueItem( pModel );
+ pResultItem = static_cast<const XFillFloatTransparenceItem*>(pNewItem)->checkForUniqueItem( &rModel );
break;
}
case XATTR_FILLHATCH:
{
- pResultItem = static_cast<const XFillHatchItem*>(pNewItem)->checkForUniqueItem( pModel );
+ pResultItem = static_cast<const XFillHatchItem*>(pNewItem)->checkForUniqueItem( &rModel );
break;
}
}
// set item
- GetObjectItemSet();
+ if(!HasSfxItemSet())
+ {
+ GetObjectItemSet();
+ }
+
if(pResultItem)
{
// force ItemSet
mpItemSet->Put(*pResultItem);
+
// delete item if it was a generated one
delete pResultItem;
}
else
+ {
mpItemSet->Put(*pNewItem);
+ }
}
else
{
// clear item if ItemSet exists
- if(mpItemSet)
+ if(HasSfxItemSet())
{
mpItemSet->ClearItem(nWhich);
}
@@ -230,6 +355,12 @@ namespace sdr
void AttributeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr)
{
+ // guarantee SfxItemSet existance here
+ if(!HasSfxItemSet())
+ {
+ GetObjectItemSet();
+ }
+
ImpRemoveStyleSheet();
ImpAddStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
@@ -243,237 +374,18 @@ namespace sdr
return mpStyleSheet;
}
- void AttributeProperties::MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
- {
- OSL_ASSERT(pNewModel!=nullptr);
-
- if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
- {
- if(mpItemSet)
- {
- // migrate ItemSet to new pool. Scaling is NOT necessary
- // because this functionality is used by UNDO only. Thus
- // objects and ItemSets would be moved back to their original
- // pool before usage.
- SfxStyleSheet* pStySheet = GetStyleSheet();
-
- if(pStySheet)
- {
- ImpRemoveStyleSheet();
- }
-
- auto pOldSet = std::move(mpItemSet);
- mpItemSet.reset(pOldSet->Clone(false, pDestPool));
- SdrModel::MigrateItemSet(pOldSet.get(), mpItemSet.get(), pNewModel);
-
- // set stylesheet (if used)
- if(pStySheet)
- {
- // #i109515#
- SfxItemPool* pStyleSheetPool = &pStySheet->GetPool().GetPool();
-
- if(pStyleSheetPool == pDestPool)
- {
- // just re-set stylesheet
- ImpAddStyleSheet(pStySheet, true);
- }
- else
- {
- // StyleSheet is NOT from the correct pool.
- // Look one up in the right pool with the same
- // name or use the default.
-
- // Look up the style in the new document.
- OSL_ASSERT(pNewModel->GetStyleSheetPool() != nullptr);
- SfxStyleSheet* pNewStyleSheet = dynamic_cast<SfxStyleSheet*>(
- pNewModel->GetStyleSheetPool()->Find(
- pStySheet->GetName(),
- SfxStyleFamily::All));
- if (pNewStyleSheet == nullptr
- || &pNewStyleSheet->GetPool().GetPool() != pDestPool)
- {
- // There is no copy of the style in the new
- // document. Use the default as a fallback.
- pNewStyleSheet = pNewModel->GetDefaultStyleSheet();
- }
- ImpAddStyleSheet(pNewStyleSheet, true);
- }
- }
- }
- }
- }
-
- void AttributeProperties::SetModel(SdrModel* pOldModel, SdrModel* pNewModel)
- {
- if(pOldModel != pNewModel && pNewModel)
- {
- // For a living model move the items from one pool to the other
- if(pOldModel)
- {
- // If metric has changed, scale items.
- MapUnit aOldUnit(pOldModel->GetScaleUnit());
- MapUnit aNewUnit(pNewModel->GetScaleUnit());
- bool bScaleUnitChanged(aNewUnit != aOldUnit);
- Fraction aMetricFactor;
-
- if(bScaleUnitChanged)
- {
- aMetricFactor = GetMapFactor(aOldUnit, aNewUnit).X();
- Scale(aMetricFactor);
- }
-
- // Move all styles which are used by the object to the new
- // StyleSheet pool
- SfxStyleSheet* pOldStyleSheet = GetStyleSheet();
-
- if(pOldStyleSheet)
- {
- SfxStyleSheetBase* pSheet = pOldStyleSheet;
- SfxStyleSheetBasePool* pOldPool = pOldModel->GetStyleSheetPool();
- SfxStyleSheetBasePool* pNewPool = pNewModel->GetStyleSheetPool();
- DBG_ASSERT(pOldPool, "Properties::SetModel(): Object has StyleSheet but no StyleSheetPool (!)");
-
- if(pOldPool && pNewPool)
- {
- // build a list of to-be-copied Styles
- std::vector<SfxStyleSheetBase*> aStyleList;
- SfxStyleSheetBase* pAnchor = nullptr;
-
- while(pSheet)
- {
- pAnchor = pNewPool->Find(pSheet->GetName(), pSheet->GetFamily());
-
- if(!pAnchor)
- {
- aStyleList.push_back(pSheet);
- pSheet = pOldPool->Find(pSheet->GetParent(), pSheet->GetFamily());
- }
- else
- {
- // the style does exist
- pSheet = nullptr;
- }
- }
-
- // copy and set the parents
- SfxStyleSheetBase* pNewSheet = nullptr;
- SfxStyleSheetBase* pLastSheet = nullptr;
- SfxStyleSheetBase* pForThisObject = nullptr;
-
- for (std::vector<SfxStyleSheetBase*>::const_iterator iter = aStyleList.begin(), aEnd = aStyleList.end()
- ; iter != aEnd; ++iter)
- {
- pNewSheet = &pNewPool->Make((*iter)->GetName(), (*iter)->GetFamily(), (*iter)->GetMask());
- pNewSheet->GetItemSet().Put((*iter)->GetItemSet(), false);
-
- if(bScaleUnitChanged)
- {
- sdr::properties::ScaleItemSet(pNewSheet->GetItemSet(), aMetricFactor);
- }
-
- if(pLastSheet)
- {
- pLastSheet->SetParent(pNewSheet->GetName());
- }
-
- if(!pForThisObject)
- {
- pForThisObject = pNewSheet;
- }
-
- pLastSheet = pNewSheet;
- }
-
- // Set link to the Style found in the Pool
- if(pAnchor && pLastSheet)
- {
- pLastSheet->SetParent(pAnchor->GetName());
- }
-
- // if list was empty (all Styles exist in destination pool)
- // pForThisObject is not yet set
- if(!pForThisObject && pAnchor)
- {
- pForThisObject = pAnchor;
- }
-
- // De-register at old and register at new Style
- if(GetStyleSheet() != pForThisObject)
- {
- ImpRemoveStyleSheet();
- ImpAddStyleSheet(static_cast<SfxStyleSheet*>(pForThisObject), true);
- }
- }
- else
- {
- // there is no StyleSheetPool in the new model, thus set
- // all items as hard items in the object
- std::vector<const SfxItemSet*> aSetList;
- const SfxItemSet* pItemSet = &pOldStyleSheet->GetItemSet();
-
- while(pItemSet)
- {
- aSetList.push_back(pItemSet);
- pItemSet = pItemSet->GetParent();
- }
-
- auto pNewSet = CreateObjectSpecificItemSet(pNewModel->GetItemPool());
-
- std::vector<const SfxItemSet*>::reverse_iterator riter;
- for (riter = aSetList.rbegin(); riter != aSetList.rend(); ++riter)
- pNewSet->Put(*(*riter));
-
- // Items which were hard attributes before need to stay
- if(mpItemSet)
- {
- SfxWhichIter aIter(*mpItemSet);
- sal_uInt16 nWhich = aIter.FirstWhich();
-
- while(nWhich)
- {
- if(mpItemSet->GetItemState(nWhich, false) == SfxItemState::SET)
- {
- pNewSet->Put(mpItemSet->Get(nWhich));
- }
-
- nWhich = aIter.NextWhich();
- }
- }
-
- if(bScaleUnitChanged)
- {
- ScaleItemSet(*pNewSet, aMetricFactor);
- }
-
- if(mpItemSet)
- {
- if(GetStyleSheet())
- {
- ImpRemoveStyleSheet();
- }
- }
-
- mpItemSet = std::move(pNewSet);
- }
- }
- }
-
- // each object gets the default Style if there is none set yet.
- if(!GetStyleSheet() && pNewModel)
- {
- GetObjectItemSet(); // #118414 force ItemSet to allow style to be set
- SetStyleSheet(pNewModel->GetDefaultStyleSheet(), true);
- }
- }
- }
-
void AttributeProperties::ForceStyleToHardAttributes()
{
if(!GetStyleSheet() || dynamic_cast<const SfxStyleSheet *>(mpStyleSheet) == nullptr)
return;
+ // force SfxItemSet existence
+ if(!HasSfxItemSet())
+ {
+ GetObjectItemSet();
+ }
+
// prepare copied, new itemset, but WITHOUT parent
- GetObjectItemSet();
SfxItemSet* pDestItemSet = new SfxItemSet(*mpItemSet);
pDestItemSet->SetParent(nullptr);
@@ -539,22 +451,22 @@ namespace sdr
{
// Style needs to be exchanged
SfxStyleSheet* pNewStSh = nullptr;
- SdrModel* pModel = rObj.GetModel();
+ SdrModel& rModel(rObj.getSdrModelFromSdrObject());
// Do nothing if object is in destruction, else a StyleSheet may be found from
// a StyleSheetPool which is just being deleted itself. and thus it would be fatal
// to register as listener to that new StyleSheet.
- if(pModel && !rObj.IsInDestruction())
+ if(!rObj.IsInDestruction())
{
if(dynamic_cast<const SfxStyleSheet *>(GetStyleSheet()) != nullptr)
{
- pNewStSh = static_cast<SfxStyleSheet*>(pModel->GetStyleSheetPool()->Find(
+ pNewStSh = static_cast<SfxStyleSheet*>(rModel.GetStyleSheetPool()->Find(
GetStyleSheet()->GetParent(), GetStyleSheet()->GetFamily()));
}
if(!pNewStSh)
{
- pNewStSh = pModel->GetDefaultStyleSheet();
+ pNewStSh = rModel.GetDefaultStyleSheet();
}
}
diff --git a/svx/source/sdr/properties/defaultproperties.cxx b/svx/source/sdr/properties/defaultproperties.cxx
index 167e368382c4..56d23b6851bd 100644
--- a/svx/source/sdr/properties/defaultproperties.cxx
+++ b/svx/source/sdr/properties/defaultproperties.cxx
@@ -25,14 +25,14 @@
#include <svl/itemset.hxx>
#include <svl/whiter.hxx>
#include <vcl/outdev.hxx>
-
#include <vector>
#include <svx/svdobj.hxx>
#include <svx/svddef.hxx>
#include <svx/svdpool.hxx>
#include <editeng/eeitem.hxx>
#include <libxml/xmlwriter.h>
-
+#include <svx/svdmodel.hxx>
+#include <svx/svdtrans.hxx>
namespace sdr
{
@@ -56,7 +56,29 @@ namespace sdr
{
if(rProps.mpItemSet)
{
- mpItemSet.reset(rProps.mpItemSet->Clone());
+ // Clone may be to another model and thus another ItemPool.
+ // SfxItemSet supports that thus we are able to Clone all
+ // SfxItemState::SET items to the target pool.
+ mpItemSet.reset(
+ rProps.mpItemSet->Clone(
+ true,
+ &rObj.getSdrModelFromSdrObject().GetItemPool()));
+
+ // React on ModelChange: If metric has changed, scale items.
+ // As seen above, clone is supported, but scale is not included,
+ // thus: TTTT maybe add scale to SfxItemSet::Clone() (?)
+ if(&rObj.getSdrModelFromSdrObject() != &GetSdrObject().getSdrModelFromSdrObject())
+ {
+ const MapUnit aOldUnit(GetSdrObject().getSdrModelFromSdrObject().GetScaleUnit());
+ const MapUnit aNewUnit(rObj.getSdrModelFromSdrObject().GetScaleUnit());
+ const bool bScaleUnitChanged(aNewUnit != aOldUnit);
+
+ if(bScaleUnitChanged)
+ {
+ const Fraction aMetricFactor(GetMapFactor(aOldUnit, aNewUnit).X());
+ Scale(aMetricFactor);
+ }
+ }
// do not keep parent info, this may be changed by later constructors.
// This class just copies the ItemSet, ignore parent.
diff --git a/svx/source/sdr/properties/e3dsceneproperties.cxx b/svx/source/sdr/properties/e3dsceneproperties.cxx
index 1b3bdbf486b6..a5f59940d51e 100644
--- a/svx/source/sdr/properties/e3dsceneproperties.cxx
+++ b/svx/source/sdr/properties/e3dsceneproperties.cxx
@@ -267,31 +267,6 @@ namespace sdr
return pRetval;
}
- void E3dSceneProperties::MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
- {
- if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
- {
- // call parent
- E3dProperties::MoveToItemPool(pSrcPool, pDestPool, pNewModel);
-
- // own reaction, but only with outmost scene
- E3dScene& rObj = static_cast<E3dScene&>(GetSdrObject());
- const SdrObjList* pSubList = rObj.GetSubList();
-
- if(pSubList && rObj.GetScene() == &rObj)
- {
- SdrObjListIter a3DIterator(*pSubList, SdrIterMode::DeepWithGroups);
-
- while(a3DIterator.IsMore())
- {
- E3dObject* pObj = static_cast<E3dObject*>(a3DIterator.Next());
- DBG_ASSERT(dynamic_cast<const E3dObject* >(pObj) != nullptr, "In scenes there are only 3D objects allowed (!)");
- pObj->GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
- }
- }
- }
- }
-
void E3dSceneProperties::SetSceneItemsFromCamera()
{
// force ItemSet
diff --git a/svx/source/sdr/properties/groupproperties.cxx b/svx/source/sdr/properties/groupproperties.cxx
index 7b46704e0923..a79f7cc9059a 100644
--- a/svx/source/sdr/properties/groupproperties.cxx
+++ b/svx/source/sdr/properties/groupproperties.cxx
@@ -246,31 +246,6 @@ namespace sdr
// nothing to do here, groups have no items and thus no default items, too.
}
- void GroupProperties::MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
- {
- if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
- {
- const SdrObjList* pSub = static_cast<const SdrObjGroup&>(GetSdrObject()).GetSubList();
- const size_t nCount(pSub->GetObjCount());
-
- for(size_t a = 0; a < nCount; ++a)
- {
- pSub->GetObj(a)->GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
- }
-
- // also clear local ItemSet, it's only temporary for group objects anyways.
- if(mpItemSet)
- {
- // copy/paste is still using clone operators and MoveToItemPool functionality.
- // Since SfxItemSet contains a pool pointer, ClearItem is not enough here.
- // The ItemSet for merge is constructed on demand, so it's enough here to
- // just delete it and set to 0L.
- // mpItemSet->ClearItem();
- mpItemSet.reset();
- }
- }
- }
-
void GroupProperties::ForceStyleToHardAttributes()
{
const SdrObjList* pSub = static_cast<const SdrObjGroup&>(GetSdrObject()).GetSubList();
diff --git a/svx/source/sdr/properties/properties.cxx b/svx/source/sdr/properties/properties.cxx
index c8082ab53f8f..256e6ea275bb 100644
--- a/svx/source/sdr/properties/properties.cxx
+++ b/svx/source/sdr/properties/properties.cxx
@@ -80,18 +80,6 @@ namespace sdr
ClearObjectItem(nWhich);
}
- void BaseProperties::MoveToItemPool(SfxItemPool* /*pSrcPool*/, SfxItemPool* /*pDestPool*/, SdrModel* /*pNewModel*/)
- {
- // Move properties to a new ItemPool. Default implementation does nothing.
- // Override where an ItemSet is implemented.
- }
-
- void BaseProperties::SetModel(SdrModel* /*pOldModel*/, SdrModel* /*pNewModel*/)
- {
- // Set new model. Default implementation does nothing.
- // Override where an ItemSet is implemented.
- }
-
void BaseProperties::ForceStyleToHardAttributes()
{
// force all attributes which come from styles to hard attributes
diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx
index 0d57e931cd23..f6e1aba0b791 100644
--- a/svx/source/sdr/properties/textproperties.cxx
+++ b/svx/source/sdr/properties/textproperties.cxx
@@ -240,7 +240,7 @@ namespace sdr
// #i101556# StyleSheet has changed -> new version
maVersion++;
- if( rObj.GetModel() /*&& !rObj.IsTextEditActive()*/ && !rObj.IsLinkedText() )
+ if(!rObj.IsLinkedText() )
{
SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner();
@@ -279,9 +279,7 @@ namespace sdr
aNewStyleSheetName = aNewStyleSheetName.copy(0, aNewStyleSheetName.getLength() - 1);
sal_Int16 nDepth = rOutliner.GetDepth(nPara);
aNewStyleSheetName += OUString::number( nDepth <= 0 ? 1 : nDepth + 1);
-
- SdrModel* pModel = rObj.GetModel();
- SfxStyleSheetBasePool* pStylePool = (pModel != nullptr) ? pModel->GetStyleSheetPool() : nullptr;
+ SfxStyleSheetBasePool* pStylePool(rObj.getSdrModelFromSdrObject().GetStyleSheetPool());
SfxStyleSheet* pNewStyle = nullptr;
if(pStylePool)
pNewStyle = static_cast<SfxStyleSheet*>(pStylePool->Find(aNewStyleSheetName, GetStyleSheet()->GetFamily()));
@@ -397,11 +395,9 @@ namespace sdr
// now the standard TextProperties stuff
SdrTextObj& rObj = static_cast<SdrTextObj&>(GetSdrObject());
- if(rObj.GetModel()
- && !rObj.IsTextEditActive()
- && !rObj.IsLinkedText())
+ if(!rObj.IsTextEditActive() && !rObj.IsLinkedText())
{
- Outliner* pOutliner = SdrMakeOutliner(OutlinerMode::OutlineObject, *rObj.GetModel());
+ Outliner* pOutliner = SdrMakeOutliner(OutlinerMode::OutlineObject, rObj.getSdrModelFromSdrObject());
const svx::ITextProvider& rTextProvider(getTextProvider());
sal_Int32 nText = rTextProvider.getTextCount();
while (nText--)
diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx
index 33cf4eb9b3c2..f2d739e76612 100644
--- a/svx/source/svdraw/svdcrtv.cxx
+++ b/svx/source/svdraw/svdcrtv.cxx
@@ -197,8 +197,10 @@ void SdrCreateView::ImpClearVars()
ImpClearConnectMarker();
}
-SdrCreateView::SdrCreateView(SdrModel* pModel1, OutputDevice* pOut)
-: SdrDragView(pModel1,pOut),
+SdrCreateView::SdrCreateView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: SdrDragView(rSdrModel, pOut),
mpCoMaOverlay(nullptr),
mpCreateViewExtraData(new ImpSdrCreateViewExtraData())
{
@@ -348,7 +350,10 @@ void SdrCreateView::SetCurrentObj(sal_uInt16 nIdent, SdrInventor nInvent)
nCurrentInvent=nInvent;
nCurrentIdent=nIdent;
SdrObject * pObj = (nIdent == OBJ_NONE) ? nullptr :
- SdrObjFactory::MakeNewObject(nInvent, nIdent, nullptr);
+ SdrObjFactory::MakeNewObject(
+ *GetModel(),
+ nInvent,
+ nIdent);
if(pObj)
{
@@ -407,14 +412,14 @@ bool SdrCreateView::ImpBegCreateObj(SdrInventor nInvent, sal_uInt16 nIdent, cons
{
pCurrentCreate->SetPage(pCreatePV->GetPage());
}
- else if (mpModel)
- {
- pCurrentCreate->SetModel(mpModel);
- }
}
else
{
- pCurrentCreate = SdrObjFactory::MakeNewObject(nInvent, nIdent, pCreatePV->GetPage(), mpModel);
+ pCurrentCreate = SdrObjFactory::MakeNewObject(
+ *mpModel,
+ nInvent,
+ nIdent,
+ pCreatePV->GetPage());
}
Point aPnt(rPnt);
diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx
index b13383b27a32..5d18d6840d27 100644
--- a/svx/source/svdraw/svddrgv.cxx
+++ b/svx/source/svdraw/svddrgv.cxx
@@ -71,8 +71,10 @@ void SdrDragView::ImpClearVars()
mbSolidDragging = getOptionsDrawinglayer().IsSolidDragCreate();
}
-SdrDragView::SdrDragView(SdrModel* pModel1, OutputDevice* pOut)
-: SdrExchangeView(pModel1,pOut)
+SdrDragView::SdrDragView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: SdrExchangeView(rSdrModel, pOut)
{
ImpClearVars();
}
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index c373caac480f..ce620ae67e41 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -88,8 +88,10 @@ void SdrEditView::ImpClearVars()
bPossibilitiesDirty=true; // << Purify didn't like this
}
-SdrEditView::SdrEditView(SdrModel* pModel1, OutputDevice* pOut):
- SdrMarkView(pModel1,pOut)
+SdrEditView::SdrEditView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: SdrMarkView(rSdrModel, pOut)
{
ImpClearVars();
}
@@ -98,7 +100,6 @@ SdrEditView::~SdrEditView()
{
}
-
void SdrEditView::InsertNewLayer(const OUString& rName, sal_uInt16 nPos)
{
SdrLayerAdmin& rLA=mpModel->GetLayerAdmin();
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index 01820c63bc34..ef63499a1eb8 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -1126,7 +1126,7 @@ void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode)
// #i73441# check insert list before taking actions
if(pInsOL)
{
- SdrPathObj* pPath = new SdrPathObj(OBJ_PATHFILL, aMergePolyPolygonA);
+ SdrPathObj* pPath = new SdrPathObj(pAttrObj->getSdrModelFromSdrObject(), OBJ_PATHFILL, aMergePolyPolygonA);
ImpCopyAttributes(pAttrObj, pPath);
pInsOL->InsertObject(pPath, nInsPos);
if( bUndo )
@@ -1134,7 +1134,7 @@ void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode)
// #i124760# To have a correct selection with only the new object it is necessary to
// unmark all objects first. If not doing so, there may remain invalid pointers to objects
- //TTTT:Not needed for aw080 (!)
+ // TTTT:Not needed for aw080 (!)
UnmarkAllObj(pInsPV);
MarkObj(pPath, pInsPV, false, true);
@@ -1355,7 +1355,7 @@ void SdrEditView::CombineMarkedObjects(bool bNoPolyPoly)
}
}
- SdrPathObj* pPath = new SdrPathObj(eKind,aPolyPolygon);
+ SdrPathObj* pPath = new SdrPathObj(pAttrObj->getSdrModelFromSdrObject(), eKind, aPolyPolygon);
// attributes of the lowest object
ImpCopyAttributes(pAttrObj, pPath);
@@ -1522,7 +1522,10 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
if(!bMakeLines || nPointCount < 2)
{
- SdrPathObj* pPath = new SdrPathObj(static_cast<SdrObjKind>(pSrcPath->GetObjIdentifier()), basegfx::B2DPolyPolygon(rCandidate));
+ SdrPathObj* pPath = new SdrPathObj(
+ pSrcPath->getSdrModelFromSdrObject(),
+ static_cast<SdrObjKind>(pSrcPath->GetObjIdentifier()),
+ basegfx::B2DPolyPolygon(rCandidate));
ImpCopyAttributes(pSrcPath, pPath);
pLast = pPath;
rOL.InsertObject(pPath, rPos);
@@ -1556,7 +1559,10 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
aNewPolygon.append(rCandidate.getB2DPoint(nNextIndex));
}
- SdrPathObj* pPath = new SdrPathObj(eKind, basegfx::B2DPolyPolygon(aNewPolygon));
+ SdrPathObj* pPath = new SdrPathObj(
+ pSrcPath->getSdrModelFromSdrObject(),
+ eKind,
+ basegfx::B2DPolyPolygon(aNewPolygon));
ImpCopyAttributes(pSrcPath, pPath);
pLast = pPath;
rOL.InsertObject(pPath, rPos);
@@ -1584,7 +1590,6 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
{
SdrObject* pCandidate = pReplacement->Clone();
DBG_ASSERT(pCandidate, "SdrEditView::ImpDismantleOneObject: Could not clone SdrObject (!)");
- pCandidate->SetModel(pCustomShape->GetModel());
if(pCustomShape->GetMergedItem(SDRATTR_SHADOW).GetValue())
{
@@ -1603,7 +1608,9 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL,
{
// #i37011# also create a text object and add at rPos + 1
SdrObject* pTextObj = SdrObjFactory::MakeNewObject(
- pCustomShape->GetObjInventor(), OBJ_TEXT, nullptr, pCustomShape->GetModel());
+ pCustomShape->getSdrModelFromSdrObject(),
+ pCustomShape->GetObjInventor(),
+ OBJ_TEXT);
// Copy text content
OutlinerParaObject* pParaObj = pCustomShape->GetOutlinerParaObject();
@@ -1754,14 +1761,13 @@ void SdrEditView::GroupMarked()
SdrMark* pM=GetSdrMarkByIndex(nm);
if (pM->GetPageView()==pPV)
{
- if (pGrp==nullptr)
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ if (nullptr==pGrp)
{
- if (pGrp==nullptr)
- pGrp=new SdrObjGroup;
+ pGrp = new SdrObjGroup(pObj->getSdrModelFromSdrObject());
pDstLst=pGrp->GetSubList();
DBG_ASSERT(pDstLst!=nullptr,"Alleged group object doesn't return object list.");
}
- SdrObject* pObj=pM->GetMarkedSdrObj();
pSrcLst=pObj->GetObjList();
if (pSrcLst!=pSrcLst0)
{
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 51ef80fb46b6..d03a55fe4b11 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -88,8 +88,10 @@ void SdrObjEditView::ImpClearVars()
bTextEditOnlyOneView=false;
}
-SdrObjEditView::SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut):
- SdrGlueEditView(pModel1,pOut),
+SdrObjEditView::SdrObjEditView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: SdrGlueEditView(rSdrModel, pOut),
mpOldTextEditUndoManager(nullptr)
{
ImpClearVars();
@@ -1089,7 +1091,7 @@ bool SdrObjEditView::SdrBeginTextEdit(
mxTextEditObj.reset( pObj );
pTextEditOutliner=pGivenOutliner;
if (pTextEditOutliner==nullptr)
- pTextEditOutliner = SdrMakeOutliner( OutlinerMode::TextObject, *mxTextEditObj->GetModel() );
+ pTextEditOutliner = SdrMakeOutliner( OutlinerMode::TextObject, mxTextEditObj->getSdrModelFromSdrObject() );
{
SvtAccessibilityOptions aOptions;
@@ -1588,8 +1590,7 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
}
if( pTEObj &&
- pTEObj->GetModel() &&
- !pTEObj->GetModel()->isLocked() &&
+ !pTEObj->getSdrModelFromSdrObject().isLocked() &&
pTEObj->GetBroadcaster())
{
SdrHint aHint(SdrHintKind::EndEdit, *pTEObj);
@@ -2408,11 +2409,17 @@ void SdrObjEditView::MarkListHasChanged()
const SdrMarkList& rMarkList=GetMarkedObjectList();
if( rMarkList.GetMarkCount() == 1 )
{
- const SdrObject* pObj= rMarkList.GetMark(0)->GetMarkedSdrObj();
+ const SdrObject* pObj(rMarkList.GetMark(0)->GetMarkedSdrObj());
+ SdrView* pView(dynamic_cast< SdrView* >(this));
+
// check for table
- if( pObj && (pObj->GetObjInventor() == SdrInventor::Default ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
+ if(pObj && pView && (pObj->GetObjInventor() == SdrInventor::Default ) && (pObj->GetObjIdentifier() == OBJ_TABLE))
{
- mxSelectionController = sdr::table::CreateTableController( this, static_cast<sdr::table::SdrTableObj const *>(pObj), mxLastSelectionController );
+ mxSelectionController = sdr::table::CreateTableController(
+ *pView,
+ static_cast<const sdr::table::SdrTableObj&>(*pObj),
+ mxLastSelectionController);
+
if( mxSelectionController.is() )
{
mxLastSelectionController.clear();
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 4b29e2c53efe..24479d6e8a06 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -531,9 +531,6 @@ namespace
const SdrLayerIDSet& rVisLayers,
Color& rCol)
{
- if(!rList.GetModel())
- return false;
-
bool bRet(false);
bool bMaster(rList.GetPage() && rList.GetPage()->IsMasterPage());
@@ -576,9 +573,6 @@ namespace
Color& rCol,
bool bSkipBackgroundShape)
{
- if(!rPage.GetModel())
- return false;
-
bool bRet(impGetSdrObjListFillColor(rPage, rPnt, rTextEditPV, rVisLayers, rCol));
if(!bRet && !rPage.IsMasterPage())
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index f3806362aba6..3f3a93565979 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -557,6 +557,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
if(!aNewRange.isEmpty())
{
pObj = new SdrPathObj(
+ *mpModel,
aNewPoly.isClosed() ? OBJ_POLY : OBJ_PLIN,
aNewPoly);
@@ -686,7 +687,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction const & rAct)
if(bCreateLineObject)
{
- SdrPathObj* pPath = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aLine));
+ SdrPathObj* pPath = new SdrPathObj(
+ *mpModel,
+ OBJ_LINE,
+ basegfx::B2DPolyPolygon(aLine));
mnLineWidth = nNewLineWidth;
maLineJoin = rLineInfo.GetLineJoin();
maLineCap = rLineInfo.GetLineCap();
@@ -705,14 +709,18 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction const & rAct)
void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction const & rAct)
{
- SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
+ SdrRectObj* pRect = new SdrRectObj(
+ *mpModel,
+ rAct.GetRect());
SetAttributes(pRect);
InsertObj(pRect);
}
void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction const & rAct)
{
- SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
+ SdrRectObj* pRect = new SdrRectObj(
+ *mpModel,
+ rAct.GetRect());
SetAttributes(pRect);
long nRad=(rAct.GetHorzRound()+rAct.GetVertRound())/2;
if (nRad!=0) {
@@ -725,7 +733,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction const & rAct)
void ImpSdrGDIMetaFileImport::DoAction(MetaEllipseAction const & rAct)
{
- SdrCircObj* pCirc=new SdrCircObj(OBJ_CIRC,rAct.GetRect());
+ SdrCircObj* pCirc=new SdrCircObj(
+ *mpModel,
+ OBJ_CIRC,
+ rAct.GetRect());
SetAttributes(pCirc);
InsertObj(pCirc);
}
@@ -735,7 +746,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction const & rAct)
Point aCenter(rAct.GetRect().Center());
long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
- SdrCircObj* pCirc=new SdrCircObj(OBJ_CARC,rAct.GetRect(),nStart,nEnd);
+ SdrCircObj* pCirc = new SdrCircObj(
+ *mpModel,
+ OBJ_CARC,
+ rAct.GetRect(),nStart,nEnd);
SetAttributes(pCirc);
InsertObj(pCirc);
}
@@ -745,7 +759,12 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction const & rAct)
Point aCenter(rAct.GetRect().Center());
long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
- SdrCircObj* pCirc=new SdrCircObj(OBJ_SECT,rAct.GetRect(),nStart,nEnd);
+ SdrCircObj* pCirc = new SdrCircObj(
+ *mpModel,
+ OBJ_SECT,
+ rAct.GetRect(),
+ nStart,
+ nEnd);
SetAttributes(pCirc);
InsertObj(pCirc);
}
@@ -755,7 +774,12 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction const & rAct)
Point aCenter(rAct.GetRect().Center());
long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
- SdrCircObj* pCirc=new SdrCircObj(OBJ_CCUT,rAct.GetRect(),nStart,nEnd);
+ SdrCircObj* pCirc = new SdrCircObj(
+ *mpModel,
+ OBJ_CCUT,
+ rAct.GetRect(),
+ nStart,
+ nEnd);
SetAttributes(pCirc);
InsertObj(pCirc);
}
@@ -911,6 +935,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction const & rAct )
if(bCreateLineObject)
{
SdrPathObj* pPath = new SdrPathObj(
+ *mpModel,
aSource.isClosed() ? OBJ_POLY : OBJ_PLIN,
basegfx::B2DPolyPolygon(aSource));
mnLineWidth = nNewLineWidth;
@@ -942,7 +967,10 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction const & rAct )
{
// #i73407# make sure polygon is closed, it's a filled primitive
aSource.setClosed(true);
- SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aSource));
+ SdrPathObj* pPath = new SdrPathObj(
+ *mpModel,
+ OBJ_POLY,
+ basegfx::B2DPolyPolygon(aSource));
SetAttributes(pPath);
InsertObj(pPath, false);
}
@@ -963,7 +991,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction const & rAct)
{
// #i73407# make sure polygon is closed, it's a filled primitive
aSource.setClosed(true);
- SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
+ SdrPathObj* pPath = new SdrPathObj(
+ *mpModel,
+ OBJ_POLY,
+ aSource);
SetAttributes(pPath);
InsertObj(pPath, false);
}
@@ -990,7 +1021,10 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const OUString& rSt
aPos.AdjustY( -nTextHeight );
tools::Rectangle aTextRect( aPos, aSize );
- SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect );
+ SdrRectObj* pText = new SdrRectObj(
+ *mpModel,
+ OBJ_TEXT,
+ aTextRect);
pText->SetMergedItem ( makeSdrTextUpperDistItem (0));
pText->SetMergedItem ( makeSdrTextLowerDistItem (0));
@@ -1009,7 +1043,6 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const OUString& rSt
pText->SetMergedItem( makeSdrTextAutoGrowWidthItem( true ) );
}
- pText->SetModel(mpModel);
pText->SetLayer(mnLayer);
pText->NbcSetText( rStr );
SetAttributes( pText, true );
@@ -1059,7 +1092,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(
+ *mpModel,
+ Graphic(rAct.GetBitmap()),
+ aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1071,7 +1107,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(
+ *mpModel,
+ Graphic(rAct.GetBitmap()),
+ aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1083,7 +1122,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
+ SdrGrafObj* pGraf = new SdrGrafObj(
+ *mpModel,
+ rAct.GetBitmapEx(),
+ aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1095,7 +1137,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction const & rAct)
{
tools::Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
+ SdrGrafObj* pGraf = new SdrGrafObj(
+ *mpModel,
+ rAct.GetBitmapEx(),
+ aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1117,7 +1162,10 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction const & rAct )
if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
{
const Hatch& rHatch = rAct.GetHatch();
- SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
+ SdrPathObj* pPath = new SdrPathObj(
+ *mpModel,
+ OBJ_POLY,
+ aSource);
// #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
SfxItemSet aHatchAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
css::drawing::HatchStyle eStyle;
@@ -1207,7 +1255,10 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction const & rAct, GDIMetaF
if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
{
const Gradient& rGrad = pAct->GetGradient();
- SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
+ SdrPathObj* pPath = new SdrPathObj(
+ *mpModel,
+ OBJ_POLY,
+ aSource);
// #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
SfxItemSet aGradAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
XGradient aXGradient;
@@ -1275,7 +1326,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScalePartAction const & rAct)
aRect.AdjustRight( 1 );
aRect.AdjustBottom( 1 );
aBitmap.Crop(tools::Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
- SdrGrafObj* pGraf = new SdrGrafObj(aBitmap, aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(
+ *mpModel,
+ aBitmap,
+ aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1291,7 +1345,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScalePartAction const & rAct)
aRect.AdjustRight( 1 );
aRect.AdjustBottom( 1 );
aBitmapEx.Crop(tools::Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
- SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(
+ *mpModel,
+ aBitmapEx,
+ aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1305,7 +1362,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskAction const & rAct)
BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(
+ *mpModel,
+ aBitmapEx,
+ aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1319,7 +1379,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScaleAction const & rAct)
BitmapEx aBitmapEx(rAct.GetBitmap(), rAct.GetColor());
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
- SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(
+ *mpModel,
+ aBitmapEx,
+ aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1334,7 +1397,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMaskScalePartAction const & rAct)
aRect.AdjustRight( 1 ); aRect.AdjustBottom( 1 );
aBitmapEx.Crop(tools::Rectangle(rAct.GetSrcPoint(), rAct.GetSrcSize()));
- SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(
+ *mpModel,
+ aBitmapEx,
+ aRect);
// This action is not creating line and fill, set directly, do not use SetAttributes(..)
pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1381,6 +1447,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientAction const & rAct)
aRange.transform(aTransform);
const Gradient& rGradient = rAct.GetGradient();
SdrRectObj* pRect = new SdrRectObj(
+ *mpModel,
tools::Rectangle(
floor(aRange.getMinX()),
floor(aRange.getMinY()),
@@ -1420,7 +1487,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaTransparentAction const & rAct)
aSource.transform(aTransform);
aSource.setClosed(true);
- SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
+ SdrPathObj* pPath = new SdrPathObj(
+ *mpModel,
+ OBJ_POLY,
+ aSource);
SetAttributes(pPath);
pPath->SetMergedItem(XFillTransparenceItem(rAct.GetTransparence()));
InsertObj(pPath, false);
@@ -1439,7 +1509,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaGradientExAction const & rAct)
if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
{
const Gradient& rGradient = rAct.GetGradient();
- SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
+ SdrPathObj* pPath = new SdrPathObj(
+ *mpModel,
+ OBJ_POLY,
+ aSource);
// #i125211# Use the ranges from the SdrObject to create a new empty SfxItemSet
SfxItemSet aGradientAttr(mpModel->GetItemPool(), pPath->GetMergedItemSet().GetRanges());
const css::awt::GradientStyle aXGradientStyle(getXGradientStyleFromGradientStyle(rGradient.GetStyle()));
@@ -1563,7 +1636,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaFloatTransparentAction const & rAct)
}
// create and add object
- SdrGrafObj* pGraf = new SdrGrafObj(aBitmapEx, aRect);
+ SdrGrafObj* pGraf = new SdrGrafObj(
+ *mpModel,
+ aBitmapEx,
+ aRect);
// for MetaFloatTransparentAction, do not use SetAttributes(...)
// since these metafile content is not used to draw line/fill
diff --git a/svx/source/svdraw/svdglev.cxx b/svx/source/svdraw/svdglev.cxx
index 64da87b646ab..3bbd461923fd 100644
--- a/svx/source/svdraw/svdglev.cxx
+++ b/svx/source/svdraw/svdglev.cxx
@@ -29,9 +29,10 @@
#include <svx/svdtrans.hxx>
#include <svx/svdobj.hxx>
-
-SdrGlueEditView::SdrGlueEditView(SdrModel* pModel1, OutputDevice* pOut):
- SdrPolyEditView(pModel1,pOut)
+SdrGlueEditView::SdrGlueEditView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: SdrPolyEditView(rSdrModel, pOut)
{
}
@@ -39,7 +40,6 @@ SdrGlueEditView::~SdrGlueEditView()
{
}
-
void SdrGlueEditView::ImpDoMarkedGluePoints(PGlueDoFunc pDoFunc, bool bConst, const void* p1, const void* p2, const void* p3, const void* p4)
{
const size_t nMarkCount=GetMarkedObjectCount();
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
index 711a96e1dfff..b00b9671ece4 100644
--- a/svx/source/svdraw/svdhdl.cxx
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -1351,8 +1351,8 @@ void SdrHdlGradient::FromIAOToItem(SdrObject* _pObj, bool bSetItemOnObject, bool
if(bSetItemOnObject)
{
- SdrModel* pModel = _pObj->GetModel();
- SfxItemSet aNewSet(pModel->GetItemPool());
+ SdrModel& rModel(_pObj->getSdrModelFromSdrObject());
+ SfxItemSet aNewSet(rModel.GetItemPool());
if(IsGradient())
{
@@ -1367,11 +1367,11 @@ void SdrHdlGradient::FromIAOToItem(SdrObject* _pObj, bool bSetItemOnObject, bool
aNewSet.Put(aNewTransItem);
}
- if(bUndo && pModel->IsUndoEnabled())
+ if(bUndo && rModel.IsUndoEnabled())
{
- pModel->BegUndo(SvxResId(IsGradient() ? SIP_XA_FILLGRADIENT : SIP_XA_FILLTRANSPARENCE));
- pModel->AddUndo(pModel->GetSdrUndoFactory().CreateUndoAttrObject(*_pObj));
- pModel->EndUndo();
+ rModel.BegUndo(SvxResId(IsGradient() ? SIP_XA_FILLGRADIENT : SIP_XA_FILLTRANSPARENCE));
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoAttrObject(*_pObj));
+ rModel.EndUndo();
}
pObj->SetMergedItemSetAndBroadcast(aNewSet);
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 04d0f701247e..bb237ba756cf 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1323,7 +1323,7 @@ void SdrModel::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
PageListChanged();
pPage->SetInserted();
pPage->SetPageNum(nPos);
- pPage->SetModel(this);
+
if (nPos<nCount) bPagNumsDirty=true;
SetChanged();
SdrHint aHint(SdrHintKind::PageOrderChange, pPage);
@@ -1372,10 +1372,11 @@ void SdrModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos)
MasterPageListChanged();
pPage->SetInserted();
pPage->SetPageNum(nPos);
- pPage->SetModel(this);
+
if (nPos<nCount) {
bMPgNumsDirty=true;
}
+
SetChanged();
SdrHint aHint(SdrHintKind::PageOrderChange, pPage);
Broadcast(aHint);
@@ -1476,7 +1477,10 @@ void SdrModel::CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
if (!bMoveNoCopy)
{
const SdrPage* pPg1=GetPage(nPageNum2);
+
+ // Clone to local model
pPg=pPg1->Clone();
+
InsertPage(pPg,nDestNum);
if (bUndo)
AddUndo(GetSdrUndoFactory().CreateUndoCopyPage(*pPg));
@@ -1577,14 +1581,18 @@ void SdrModel::Merge(SdrModel& rSourceModel,
if (pMasterMap && pMasterNeed && nMasterNeed!=0) {
for (sal_uInt16 i=nSrcMasterPageCnt; i>0;) {
i--;
- if (pMasterNeed[i]) {
- SdrPage* pPg=nullptr;
- if (bTreadSourceAsConst) {
- const SdrPage* pPg1=rSourceModel.GetMasterPage(i);
- pPg=pPg1->Clone();
- } else {
- pPg=rSourceModel.RemoveMasterPage(i);
+ if (pMasterNeed[i])
+ {
+ // Always Clone to new model
+ const SdrPage* pPg1(rSourceModel.GetMasterPage(i));
+ SdrPage* pPg(pPg1->Clone(this));
+
+ if(!bTreadSourceAsConst)
+ {
+ // if requested, delete original/modify original model
+ delete rSourceModel.RemoveMasterPage(i);
}
+
if (pPg!=nullptr) {
// Now append all of them to the end of the DstModel.
// Don't use InsertMasterPage(), because everything is
@@ -1592,7 +1600,6 @@ void SdrModel::Merge(SdrModel& rSourceModel,
maMaPag.insert(maMaPag.begin()+nDstMasterPageCnt, pPg);
MasterPageListChanged();
pPg->SetInserted();
- pPg->SetModel(this);
bMPgNumsDirty=true;
if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
} else {
@@ -1607,14 +1614,18 @@ void SdrModel::Merge(SdrModel& rSourceModel,
sal_uInt16 nSourcePos=nFirstPageNum;
sal_uInt16 nMergeCount=sal_uInt16(std::abs(static_cast<long>(static_cast<long>(nFirstPageNum)-nLastPageNum))+1);
if (nDestPos>GetPageCount()) nDestPos=GetPageCount();
- while (nMergeCount>0) {
- SdrPage* pPg=nullptr;
- if (bTreadSourceAsConst) {
- const SdrPage* pPg1=rSourceModel.GetPage(nSourcePos);
- pPg=pPg1->Clone();
- } else {
- pPg=rSourceModel.RemovePage(nSourcePos);
+ while (nMergeCount>0)
+ {
+ // Always Clone to new model
+ const SdrPage* pPg1(rSourceModel.GetPage(nSourcePos));
+ SdrPage* pPg(pPg1->Clone(this));
+
+ if(!bTreadSourceAsConst)
+ {
+ // if requested, delete original/modify original model
+ delete rSourceModel.RemovePage(nSourcePos);
}
+
if (pPg!=nullptr) {
InsertPage(pPg,nDestPos);
if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 985b415ca3b6..07a5b2876361 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -144,15 +144,17 @@ void SdrMarkView::ImpClearVars()
BrkMarkGluePoints();
}
-SdrMarkView::SdrMarkView(SdrModel* pModel1, OutputDevice* pOut)
-: SdrSnapView(pModel1,pOut),
+SdrMarkView::SdrMarkView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: SdrSnapView(rSdrModel, pOut),
mpMarkObjOverlay(nullptr),
mpMarkPointsOverlay(nullptr),
mpMarkGluePointsOverlay(nullptr),
maHdlList(this)
{
ImpClearVars();
- StartListening(*pModel1);
+ StartListening(rSdrModel);
}
SdrMarkView::~SdrMarkView()
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 70c9faf7978b..783c5e9b5b58 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -810,8 +810,8 @@ sdr::properties::BaseProperties* SdrObjCustomShape::CreateObjectSpecificProperti
return new sdr::properties::CustomShapeProperties(*this);
}
-SdrObjCustomShape::SdrObjCustomShape()
- : SdrTextObj()
+SdrObjCustomShape::SdrObjCustomShape(SdrModel& rSdrModel)
+: SdrTextObj(rSdrModel)
, fObjectRotation(0.0)
, mbAdjustingTextFrameWidthAndHeight(false)
, mpLastShadowGeometry(nullptr)
@@ -1346,23 +1346,16 @@ void SdrObjCustomShape::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
}
}
-void SdrObjCustomShape::SetModel(SdrModel* pNewModel)
-{
- SdrTextObj::SetModel(pNewModel);
- mXRenderedCustomShape.clear();
-}
-
sal_uInt16 SdrObjCustomShape::GetObjIdentifier() const
{
return sal_uInt16(OBJ_CUSTOMSHAPE);
}
-
// #115391# This implementation is based on the TextFrame size of the CustomShape and the
// state of the ResizeShapeToFitText flag to correctly set TextMinFrameWidth/Height
void SdrObjCustomShape::AdaptTextMinSize()
{
- if (!pModel || (!pModel->IsCreatingDataObj() && !pModel->IsPasteResize()))
+ if (!getSdrModelFromSdrObject().IsCreatingDataObj() && !getSdrModelFromSdrObject().IsPasteResize())
{
const bool bResizeShapeToFitText(GetObjectItem(SDRATTR_TEXT_AUTOGROWHEIGHT).GetValue());
SfxItemSet aSet(
@@ -2232,7 +2225,7 @@ bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(tools::Rectangle& rR, bool
{
// Either we have text or the application has native text and suggested its size to us.
bool bHasText = HasText() || (m_aSuggestedTextFrameSize.Width() != 0 && m_aSuggestedTextFrameSize.Height() != 0);
- if ( pModel && bHasText && !rR.IsEmpty() )
+ if ( bHasText && !rR.IsEmpty() )
{
bool bWdtGrow=bWdt && IsAutoGrowWidth();
bool bHgtGrow=bHgt && IsAutoGrowHeight();
@@ -2243,7 +2236,7 @@ bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(tools::Rectangle& rR, bool
long nWdt=0,nMinWdt=0,nMaxWdt=0;
Size aSiz(rR.GetSize()); aSiz.AdjustWidth( -1 ); aSiz.AdjustHeight( -1 );
Size aMaxSiz(100000,100000);
- Size aTmpSiz(pModel->GetMaxObjSize());
+ Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
if (aTmpSiz.Width()!=0) aMaxSiz.setWidth(aTmpSiz.Width() );
if (aTmpSiz.Height()!=0) aMaxSiz.setHeight(aTmpSiz.Height() );
if (bWdtGrow)
@@ -2499,8 +2492,8 @@ void SdrObjCustomShape::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, tools
Size aAnkSiz(aViewInit.GetSize());
aAnkSiz.AdjustWidth( -1 ); aAnkSiz.AdjustHeight( -1 ); // because GetSize() adds 1
Size aMaxSiz(1000000,1000000);
- if (pModel!=nullptr) {
- Size aTmpSiz(pModel->GetMaxObjSize());
+ {
+ Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
if (aTmpSiz.Width()!=0) aMaxSiz.setWidth(aTmpSiz.Width() );
if (aTmpSiz.Height()!=0) aMaxSiz.setHeight(aTmpSiz.Height() );
}
@@ -2646,11 +2639,9 @@ void SdrObjCustomShape::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle&
if (pPara)
{
- bool bHitTest = false;
- if( pModel )
- bHitTest = &pModel->GetHitTestOutliner() == &rOutliner;
-
+ bool bHitTest(&getSdrModelFromSdrObject().GetHitTestOutliner() == &rOutliner);
const SdrTextObj* pTestObj = rOutliner.GetTextObj();
+
if( !pTestObj || !bHitTest || pTestObj != this ||
pTestObj->GetOutlinerParaObject() != GetOutlinerParaObject() )
{
@@ -2746,9 +2737,9 @@ void SdrObjCustomShape::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject
InvalidateRenderGeometry();
}
-SdrObjCustomShape* SdrObjCustomShape::Clone() const
+SdrObjCustomShape* SdrObjCustomShape::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrObjCustomShape >();
+ return CloneHelper< SdrObjCustomShape >(pTargetModel);
}
SdrObjCustomShape& SdrObjCustomShape::operator=(const SdrObjCustomShape& rObj)
@@ -2815,9 +2806,9 @@ SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) co
if ( pRenderedCustomShape )
{
+ // Clone to same SdrModel
SdrObject* pCandidate = pRenderedCustomShape->Clone();
DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)");
- pCandidate->SetModel(GetModel());
pRetval = pCandidate->DoConvertToPolyObj(bBezier, bAddText);
SdrObject::Free( pCandidate );
@@ -2948,7 +2939,7 @@ void SdrObjCustomShape::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix,
}
// if anchor is used, make position relative to it
- if( pModel && pModel->IsWriter() )
+ if(getSdrModelFromSdrObject().IsWriter())
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -3065,7 +3056,7 @@ bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegf
basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
// position may be relative to anchorpos, convert
- if( pModel && pModel->IsWriter() )
+ if(getSdrModelFromSdrObject().IsWriter())
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
diff --git a/svx/source/svdraw/svdoattr.cxx b/svx/source/svdraw/svdoattr.cxx
index 1f118f838f84..f33a47e63ee5 100644
--- a/svx/source/svdraw/svdoattr.cxx
+++ b/svx/source/svdraw/svdoattr.cxx
@@ -80,7 +80,8 @@ sdr::properties::BaseProperties* SdrAttrObj::CreateObjectSpecificProperties()
}
-SdrAttrObj::SdrAttrObj()
+SdrAttrObj::SdrAttrObj(SdrModel& rSdrModel)
+: SdrObject(rSdrModel)
{
}
@@ -99,26 +100,7 @@ const tools::Rectangle& SdrAttrObj::GetSnapRect() const
return maSnapRect;
}
-void SdrAttrObj::SetModel(SdrModel* pNewModel)
-{
- SdrModel* pOldModel = pModel;
-
- // test for correct pool in ItemSet; move to new pool if necessary
- if(pNewModel && &GetObjectItemPool() != &pNewModel->GetItemPool())
- {
- MigrateItemPool(&GetObjectItemPool(), &pNewModel->GetItemPool(), pNewModel);
- }
-
- // call parent
- SdrObject::SetModel(pNewModel);
-
- // modify properties
- GetProperties().SetModel(pOldModel, pNewModel);
-}
-
-
// syntactical sugar for ItemSet accesses
-
void SdrAttrObj::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
{
bool bDataChg(SfxHintId::DataChanged == rHint.GetId());
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 6726c2eafda3..29b66b5cdf92 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -226,6 +226,10 @@ sdr::properties::BaseProperties& SdrObject::GetProperties() const
{
if(!mpProperties)
{
+ // CAUTION(!) Do *not* call this during SdrObject construction,
+ // that will lead to wrong type-casts (dependent on costructor-level)
+ // and thus eventually create the wrong sdr::properties (!). Is there
+ // a way to check if on the stack is a SdrObject-constructor (?)
const_cast< SdrObject* >(this)->mpProperties.reset(
const_cast< SdrObject* >(this)->CreateObjectSpecificProperties() );
}
@@ -284,10 +288,10 @@ void SdrObject::SetBoundRectDirty()
}
-SdrObject::SdrObject() :
- mpFillGeometryDefiningShape(nullptr)
+SdrObject::SdrObject(SdrModel& rSdrModel)
+: mpFillGeometryDefiningShape(nullptr)
+ ,mrSdrModelFromSdrObject(rSdrModel)
,pPage(nullptr)
- ,pModel(nullptr)
,pUserCall(nullptr)
,pPlusData(nullptr)
,mpImpl(new Impl)
@@ -343,22 +347,7 @@ SdrObject::~SdrObject()
// when they get called from ObjectInDestruction().
mpImpl->maObjectUsers.clear();
- try
- {
- SvxShape* pSvxShape = getSvxShape();
- if ( pSvxShape )
- {
- OSL_ENSURE(!pSvxShape->HasSdrObjectOwnership(),"Please check where this call come from and replace it with SdrObject::Free");
- pSvxShape->InvalidateSdrObject();
- uno::Reference< lang::XComponent > xShapeComp( getWeakUnoShape(), uno::UNO_QUERY_THROW );
- xShapeComp->dispose();
- }
- }
- catch( const uno::Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("svx");
- }
-
+ // UserCall
SendUserCall(SdrUserCallType::Delete, GetLastBoundRect());
o3tl::reset_preserve_ptr_during(pPlusData);
@@ -370,14 +359,38 @@ SdrObject::~SdrObject()
void SdrObject::Free( SdrObject*& _rpObject )
{
SdrObject* pObject = _rpObject; _rpObject = nullptr;
- if ( pObject == nullptr )
+
+ if(nullptr == pObject)
+ {
// nothing to do
return;
+ }
- SvxShape* pShape = pObject->getSvxShape();
- if ( pShape && pShape->HasSdrObjectOwnership() )
- // only the shape is allowed to delete me, and will reset the ownership before doing so
- return;
+ SvxShape* pShape(pObject->getSvxShape());
+
+ if(pShape)
+ {
+ if(pShape->HasSdrObjectOwnership())
+ {
+ // only the SvxShape is allowed to delete me, and will reset
+ // the ownership before doing so
+ return;
+ }
+ else
+ {
+ // not only delete pObject, but also need to dispose uno shape
+ try
+ {
+ pShape->InvalidateSdrObject();
+ uno::Reference< lang::XComponent > xShapeComp( pObject->getWeakUnoShape(), uno::UNO_QUERY_THROW );
+ xShapeComp->dispose();
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("svx");
+ }
+ }
+ }
delete pObject;
}
@@ -393,28 +406,6 @@ void SdrObject::SetRectsDirty(bool bNotMyself)
}
}
-void SdrObject::SetModel(SdrModel* pNewModel)
-{
- if(pNewModel && pPage)
- {
- if(pPage->GetModel() != pNewModel)
- {
- pPage = nullptr;
- }
- }
-
- // update listeners at possible API wrapper object
- if( pModel != pNewModel )
- {
- SvxShape* pShape = getSvxShape();
- if( pShape )
- pShape->ChangeModel( pNewModel );
- }
-
- pModel = pNewModel;
-}
-
-
void SdrObject::SetObjList(SdrObjList* pNewObjList)
{
pObjList=pNewObjList;
@@ -423,16 +414,23 @@ void SdrObject::SetObjList(SdrObjList* pNewObjList)
void SdrObject::SetPage(SdrPage* pNewPage)
{
- SdrModel* pOldModel = pModel;
- SdrPage* pOldPage = pPage;
+ SdrModel* pOldModel(&getSdrModelFromSdrObject());
+ SdrPage* pOldPage(pPage);
- pPage=pNewPage;
- if (pPage!=nullptr)
- {
- SdrModel* pMod=pPage->GetModel();
- if (pMod!=pModel && pMod!=nullptr)
- SetModel(pMod);
- }
+ pPage = pNewPage;
+
+ // TTTT Possibility here to add a warning for the future -> SdrModel
+ // of SdrObject (this) and SdrPage it it added to *have* to have the
+ // same SdrModel
+ // if(nullptr != pPage)
+ // {
+ // SdrModel* pMod(&pPage->getSdrModelFromSdrPage());
+ //
+ // if(pMod != &getSdrModelFromSdrObject())
+ // {
+ // SetModel(pMod);
+ // }
+ // }
// The creation of the UNO shape in SdrObject::getUnoShape is influenced
// by pPage, so when the page changes we need to discard the cached UNO
@@ -440,7 +438,14 @@ void SdrObject::SetPage(SdrPage* pNewPage)
// If the page is changing to another page with the same model, we
// assume they create compatible UNO shape objects so we shouldn't have
// to invalidate.
- if (pOldPage != pPage && !(pOldPage && pPage && pOldModel == pModel))
+ // TTTT: This causes quite some problems in SvxDrawPage::add when used
+ // e.g. from Writer - the SdrObject may be cloned to target model, and
+ // the xShape was added to it by purpose (see there). Thus it will be
+ // good to think about if this is really needed - it *seems* to be intended
+ // for a xShape being a on-demand-creatable resource - wit hthe argument that
+ // the SdrPage/UnoPage used influences the SvxShape creation. This uses
+ // ressources and would be nice to get rid of anyways.
+ if (pOldPage != pPage && !(pOldPage && pPage && pOldModel == &getSdrModelFromSdrObject()))
{
SvxShape* const pShape(getSvxShape());
if (pShape && !pShape->HasSdrObjectOwnership())
@@ -512,13 +517,9 @@ sal_Int16 SdrObject::GetRelativeHeightRelation() const
return mpImpl->meRelativeHeightRelation;
}
-SfxItemPool & SdrObject::GetObjectItemPool() const
+SfxItemPool& SdrObject::GetObjectItemPool() const
{
- if(pModel)
- return pModel->GetItemPool();
-
- // use a static global default pool
- return SdrObject::GetGlobalDrawObjectItemPool();
+ return getSdrModelFromSdrObject().GetItemPool();
}
SdrInventor SdrObject::GetObjInventor() const
@@ -636,7 +637,7 @@ void SdrObject::SetName(const OUString& rStr)
{
// Undo/Redo for setting object's name (#i73249#)
bool bUndo( false );
- if ( GetModel() && GetModel()->IsUndoEnabled() )
+ if ( getSdrModelFromSdrObject().IsUndoEnabled() )
{
bUndo = true;
SdrUndoAction* pUndoAction =
@@ -645,14 +646,14 @@ void SdrObject::SetName(const OUString& rStr)
SdrUndoObjStrAttr::ObjStrAttrType::Name,
GetName(),
rStr );
- GetModel()->BegUndo( pUndoAction->GetComment() );
- GetModel()->AddUndo( pUndoAction );
+ getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() );
+ getSdrModelFromSdrObject().AddUndo( pUndoAction );
}
pPlusData->aObjName = rStr;
// Undo/Redo for setting object's name (#i73249#)
if ( bUndo )
{
- GetModel()->EndUndo();
+ getSdrModelFromSdrObject().EndUndo();
}
SetChanged();
BroadcastObjectChange();
@@ -680,7 +681,7 @@ void SdrObject::SetTitle(const OUString& rStr)
{
// Undo/Redo for setting object's title (#i73249#)
bool bUndo( false );
- if ( GetModel() && GetModel()->IsUndoEnabled() )
+ if ( getSdrModelFromSdrObject().IsUndoEnabled() )
{
bUndo = true;
SdrUndoAction* pUndoAction =
@@ -689,14 +690,14 @@ void SdrObject::SetTitle(const OUString& rStr)
SdrUndoObjStrAttr::ObjStrAttrType::Title,
GetTitle(),
rStr );
- GetModel()->BegUndo( pUndoAction->GetComment() );
- GetModel()->AddUndo( pUndoAction );
+ getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() );
+ getSdrModelFromSdrObject().AddUndo( pUndoAction );
}
pPlusData->aObjTitle = rStr;
// Undo/Redo for setting object's title (#i73249#)
if ( bUndo )
{
- GetModel()->EndUndo();
+ getSdrModelFromSdrObject().EndUndo();
}
SetChanged();
BroadcastObjectChange();
@@ -724,7 +725,7 @@ void SdrObject::SetDescription(const OUString& rStr)
{
// Undo/Redo for setting object's description (#i73249#)
bool bUndo( false );
- if ( GetModel() && GetModel()->IsUndoEnabled() )
+ if ( getSdrModelFromSdrObject().IsUndoEnabled() )
{
bUndo = true;
SdrUndoAction* pUndoAction =
@@ -733,14 +734,14 @@ void SdrObject::SetDescription(const OUString& rStr)
SdrUndoObjStrAttr::ObjStrAttrType::Description,
GetDescription(),
rStr );
- GetModel()->BegUndo( pUndoAction->GetComment() );
- GetModel()->AddUndo( pUndoAction );
+ getSdrModelFromSdrObject().BegUndo( pUndoAction->GetComment() );
+ getSdrModelFromSdrObject().AddUndo( pUndoAction );
}
pPlusData->aObjDescription = rStr;
// Undo/Redo for setting object's description (#i73249#)
if ( bUndo )
{
- GetModel()->EndUndo();
+ getSdrModelFromSdrObject().EndUndo();
}
SetChanged();
BroadcastObjectChange();
@@ -835,7 +836,7 @@ const tools::Rectangle& SdrObject::GetLastBoundRect() const
void SdrObject::RecalcBoundRect()
{
// #i101680# suppress BoundRect calculations on import(s)
- if ((pModel && pModel->isLocked()) || utl::ConfigManager::IsFuzzing())
+ if ((getSdrModelFromSdrObject().isLocked()) || utl::ConfigManager::IsFuzzing())
return;
// central new method which will calculate the BoundRect using primitive geometry
@@ -865,7 +866,7 @@ void SdrObject::RecalcBoundRect()
void SdrObject::BroadcastObjectChange() const
{
- if ((pModel && pModel->isLocked()) || utl::ConfigManager::IsFuzzing())
+ if ((getSdrModelFromSdrObject().isLocked()) || utl::ConfigManager::IsFuzzing())
return;
if (mbDelayBroadcastObjectChange)
@@ -875,7 +876,7 @@ void SdrObject::BroadcastObjectChange() const
}
bool bPlusDataBroadcast(pPlusData && pPlusData->pBroadcast);
- bool bObjectChange(IsInserted() && pModel);
+ bool bObjectChange(IsInserted());
if(bPlusDataBroadcast || bObjectChange)
{
@@ -888,7 +889,7 @@ void SdrObject::BroadcastObjectChange() const
if(bObjectChange)
{
- pModel->Broadcast(aHint);
+ getSdrModelFromSdrObject().Broadcast(aHint);
}
}
}
@@ -899,9 +900,13 @@ void SdrObject::SetChanged()
// notification now.
ActionChanged();
- if(IsInserted() && pModel)
+ // TTTT Need to check meaning/usage of IsInserted in one
+ // of the next changes. It should not mean to have a SdrModel
+ // set (this is guaranteed now), but should be connected to
+ // being added to a SdrPage (?)
+ if(IsInserted())
{
- pModel->SetChanged();
+ getSdrModelFromSdrObject().SetChanged();
}
}
@@ -929,9 +934,9 @@ bool SdrObject::HasLimitedRotation() const
return false;
}
-SdrObject* SdrObject::Clone() const
+SdrObject* SdrObject::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrObject >();
+ return CloneHelper< SdrObject >(pTargetModel);
}
SdrObject& SdrObject::operator=(const SdrObject& rObj)
@@ -947,7 +952,6 @@ SdrObject& SdrObject::operator=(const SdrObject& rObj)
// draw object, an SdrObject needs to be provided, as in the normal constructor.
mpProperties.reset( &rObj.GetProperties().Clone(*this) );
- pModel =rObj.pModel;
pPage = rObj.pPage;
aOutRect=rObj.aOutRect;
mnLayerID = rObj.mnLayerID;
@@ -1021,19 +1025,9 @@ void SdrObject::ImpForcePlusData()
pPlusData.reset( new SdrObjPlusData );
}
-OUString SdrObject::GetAngleStr(long nAngle) const
-{
- if (pModel!=nullptr)
- return SdrModel::GetAngleString(nAngle);
-
- return OUString();
-}
-
OUString SdrObject::GetMetrStr(long nVal) const
{
- if (pModel!=nullptr)
- return pModel->GetMetricString(nVal);
- return OUString();
+ return getSdrModelFromSdrObject().GetMetricString(nVal);
}
basegfx::B2DPolyPolygon SdrObject::TakeXorPoly() const
@@ -2054,16 +2048,16 @@ void SdrObject::NbcApplyNotPersistAttr(const SfxItemSet& rAttr)
if (rAttr.GetItemState(SDRATTR_LAYERID,true,&pPoolItem)==SfxItemState::SET) {
nLayer=static_cast<const SdrLayerIdItem*>(pPoolItem)->GetValue();
}
- if (rAttr.GetItemState(SDRATTR_LAYERNAME,true,&pPoolItem)==SfxItemState::SET && pModel!=nullptr) {
- OUString aLayerName=static_cast<const SdrLayerNameItem*>(pPoolItem)->GetValue();
- const SdrLayerAdmin* pLayAd=pPage!=nullptr ? &pPage->GetLayerAdmin() : pModel!=nullptr ? &pModel->GetLayerAdmin() : nullptr;
- if (pLayAd!=nullptr) {
- const SdrLayer* pLayer=pLayAd->GetLayer(aLayerName);
- if (pLayer!=nullptr) {
- nLayer=pLayer->GetID();
- }
- }
+ if (rAttr.GetItemState(SDRATTR_LAYERNAME,true,&pPoolItem)==SfxItemState::SET)
+ {
+ OUString aLayerName = static_cast<const SdrLayerNameItem*>(pPoolItem)->GetValue();
+ const SdrLayerAdmin& rLayAd(nullptr != pPage ? pPage->GetLayerAdmin() : getSdrModelFromSdrObject().GetLayerAdmin());
+ const SdrLayer* pLayer = rLayAd.GetLayer(aLayerName);
+ if(nullptr != pLayer)
+ {
+ nLayer=pLayer->GetID();
+ }
}
if (nLayer!=SDRLAYER_NOTFOUND) {
NbcSetLayer(nLayer);
@@ -2126,12 +2120,11 @@ void SdrObject::TakeNotPersistAttr(SfxItemSet& rAttr) const
}
rAttr.Put(SdrLayerIdItem(GetLayer()));
- const SdrLayerAdmin* pLayAd=pPage!=nullptr ? &pPage->GetLayerAdmin() : pModel!=nullptr ? &pModel->GetLayerAdmin() : nullptr;
- if (pLayAd!=nullptr) {
- const SdrLayer* pLayer=pLayAd->GetLayerPerID(GetLayer());
- if (pLayer!=nullptr) {
- rAttr.Put(SdrLayerNameItem(pLayer->GetName()));
- }
+ const SdrLayerAdmin& rLayAd(nullptr != pPage ? pPage->GetLayerAdmin() : getSdrModelFromSdrObject().GetLayerAdmin());
+ const SdrLayer* pLayer = rLayAd.GetLayerPerID(GetLayer());
+ if(nullptr != pLayer)
+ {
+ rAttr.Put(SdrLayerNameItem(pLayer->GetName()));
}
Point aRef1(rSnap.Center());
Point aRef2(aRef1); aRef2.AdjustY( 1 );
@@ -2309,15 +2302,15 @@ void extractLineContourFromPrimitive2DSequence(
}
-SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDash)
+SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
{
- bool bNoChange(true);
+ SdrObject* pRetval(nullptr);
- if(pRet->LineGeometryUsageIsNecessary())
+ if(LineGeometryUsageIsNecessary())
{
basegfx::B2DPolyPolygon aMergedLineFillPolyPolygon;
basegfx::B2DPolyPolygon aMergedHairlinePolyPolygon;
- const drawinglayer::primitive2d::Primitive2DContainer xSequence(pRet->GetViewContact().getViewIndependentPrimitive2DContainer());
+ const drawinglayer::primitive2d::Primitive2DContainer xSequence(GetViewContact().getViewIndependentPrimitive2DContainer());
if(!xSequence.empty())
{
@@ -2345,7 +2338,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDas
if(aMergedLineFillPolyPolygon.count() || (bForceLineDash && aMergedHairlinePolyPolygon.count()))
{
- SfxItemSet aSet(pRet->GetMergedItemSet());
+ SfxItemSet aSet(GetMergedItemSet());
drawing::FillStyle eOldFillStyle = aSet.Get(XATTR_FILLSTYLE).GetValue();
SdrPathObj* aLinePolygonPart = nullptr;
SdrPathObj* aLineHairlinePart = nullptr;
@@ -2354,8 +2347,10 @@ SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDas
if(aMergedLineFillPolyPolygon.count())
{
// create SdrObject for filled line geometry
- aLinePolygonPart = new SdrPathObj(OBJ_PATHFILL, aMergedLineFillPolyPolygon);
- aLinePolygonPart->SetModel(pRet->GetModel());
+ aLinePolygonPart = new SdrPathObj(
+ getSdrModelFromSdrObject(),
+ OBJ_PATHFILL,
+ aMergedLineFillPolyPolygon);
// correct item properties
aSet.Put(XLineWidthItem(0));
@@ -2375,8 +2370,10 @@ SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDas
// OBJ_PATHLINE is necessary here, not OBJ_PATHFILL. This is intended
// to get a non-filled object. If the poly is closed, the PathObj takes care for
// the correct closed state.
- aLineHairlinePart = new SdrPathObj(OBJ_PATHLINE, aMergedHairlinePolyPolygon);
- aLineHairlinePart->SetModel(pRet->GetModel());
+ aLineHairlinePart = new SdrPathObj(
+ getSdrModelFromSdrObject(),
+ OBJ_PATHLINE,
+ aMergedHairlinePolyPolygon);
aSet.Put(XLineWidthItem(0));
aSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
@@ -2396,7 +2393,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDas
// check if original geometry should be added (e.g. filled and closed)
bool bAddOriginalGeometry(false);
- SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pRet );
+ SdrPathObj* pPath = dynamic_cast<SdrPathObj*>(this);
if(pPath && pPath->IsClosed())
{
@@ -2409,20 +2406,17 @@ SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDas
// do we need a group?
if(bBuildGroup || bAddOriginalGeometry)
{
- SdrObject* pGroup = new SdrObjGroup;
- pGroup->SetModel(pRet->GetModel());
+ SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
if(bAddOriginalGeometry)
{
// Add a clone of the original geometry.
aSet.ClearItem();
- aSet.Put(pRet->GetMergedItemSet());
+ aSet.Put(GetMergedItemSet());
aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
aSet.Put(XLineWidthItem(0));
- SdrObject* pClone = pRet->Clone();
-
- pClone->SetModel(pRet->GetModel());
+ SdrObject* pClone = Clone();
pClone->SetMergedItemSet(aSet);
pGroup->GetSubList()->NbcInsertObject(pClone);
@@ -2438,38 +2432,30 @@ SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDas
pGroup->GetSubList()->NbcInsertObject(aLineHairlinePart);
}
- pRet = pGroup;
-
- // be more careful with the state describing bool
- bNoChange = false;
+ pRetval = pGroup;
}
else
{
if(aLinePolygonPart)
{
- pRet = aLinePolygonPart;
- // be more careful with the state describing bool
- bNoChange = false;
+ pRetval = aLinePolygonPart;
}
else if(aLineHairlinePart)
{
- pRet = aLineHairlinePart;
- // be more careful with the state describing bool
- bNoChange = false;
+ pRetval = aLineHairlinePart;
}
}
}
}
- if(bNoChange)
+ if(nullptr == pRetval)
{
// due to current method usage, create and return a clone when nothing has changed
- SdrObject* pClone = pRet->Clone();
- pClone->SetModel(pRet->GetModel());
- pRet = pClone;
+ SdrObject* pClone = Clone();
+ pRetval = pClone;
}
- return pRet;
+ return pRetval;
}
@@ -2497,8 +2483,7 @@ SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, bool bForceLineDash)
if(dynamic_cast<const SdrObjGroup*>( pRet) != nullptr)
{
SdrObjList* pObjList2 = pRet->GetSubList();
- SdrObject* pGroup = new SdrObjGroup;
- pGroup->SetModel(pRet->GetModel());
+ SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
for(size_t a=0; a<pObjList2->GetObjCount(); ++a)
{
@@ -2518,7 +2503,7 @@ SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, bool bForceLineDash)
pPathObj->SetPathPoly(basegfx::utils::simplifyCurveSegments(pPathObj->GetPathPoly()));
}
- pRet = ImpConvertToContourObj(pRet, bForceLineDash);
+ pRet = pRet->ImpConvertToContourObj(bForceLineDash);
}
// #i73441# preserve LayerID
@@ -2601,10 +2586,10 @@ void SdrObject::SetPrintable(bool bPrn)
{
bNoPrint=!bPrn;
SetChanged();
- if (IsInserted() && pModel!=nullptr)
+ if (IsInserted())
{
SdrHint aHint(SdrHintKind::ObjectChange, *this);
- pModel->Broadcast(aHint);
+ getSdrModelFromSdrObject().Broadcast(aHint);
}
}
}
@@ -2615,10 +2600,10 @@ void SdrObject::SetVisible(bool bVisible)
{
mbVisible = bVisible;
SetChanged();
- if (IsInserted() && pModel!=nullptr)
+ if (IsInserted())
{
SdrHint aHint(SdrHintKind::ObjectChange, *this);
- pModel->Broadcast(aHint);
+ getSdrModelFromSdrObject().Broadcast(aHint);
}
}
}
@@ -2744,15 +2729,6 @@ void SdrObject::SendUserCall(SdrUserCallType eUserCall, const tools::Rectangle&
}
}
-// change ItemPool for this object
-void SdrObject::MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
-{
- if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
- {
- GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
- }
-}
-
void SdrObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& _rxUnoShape )
{
const uno::Reference< uno::XInterface>& xOldUnoShape( maWeakUnoShape );
@@ -2882,7 +2858,7 @@ bool SdrObject::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPo
basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
// position maybe relative to anchorpos, convert
- if( pModel && pModel->IsWriter() )
+ if(getSdrModelFromSdrObject().IsWriter())
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -2966,7 +2942,7 @@ void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const ba
}
// if anchor is used, make position relative to it
- if( pModel && pModel->IsWriter() )
+ if(getSdrModelFromSdrObject().IsWriter())
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -2985,9 +2961,7 @@ void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const ba
// Give info if object is in destruction
bool SdrObject::IsInDestruction() const
{
- if(pModel)
- return pModel->IsInDestruction();
- return false;
+ return getSdrModelFromSdrObject().IsInDestruction();
}
// return if fill is != drawing::FillStyle_NONE
@@ -3056,9 +3030,9 @@ SdrDelayBroadcastObjectChange::~SdrDelayBroadcastObjectChange()
}
-SdrObject* SdrObjFactory::CreateObjectFromFactory( SdrInventor nInventor, sal_uInt16 nObjIdentifier )
+SdrObject* SdrObjFactory::CreateObjectFromFactory(SdrModel& rSdrModel, SdrInventor nInventor, sal_uInt16 nObjIdentifier)
{
- SdrObjCreatorParams aParams { nInventor, nObjIdentifier };
+ SdrObjCreatorParams aParams { nInventor, nObjIdentifier, rSdrModel };
for (const auto & i : ImpGetUserMakeObjHdl()) {
SdrObject* pObj = i.Call(aParams);
if (pObj) {
@@ -3068,78 +3042,15 @@ SdrObject* SdrObjFactory::CreateObjectFromFactory( SdrInventor nInventor, sal_uI
return nullptr;
}
-SdrObject* SdrObjFactory::MakeNewObject(SdrInventor nInvent, sal_uInt16 nIdent, SdrPage* pPage, SdrModel* pModel)
-{
- if (!pModel && pPage)
- pModel = pPage->GetModel();
-
- SdrObject* pObj = nullptr;
-
- if (nInvent == SdrInventor::Default)
- {
- switch (nIdent)
- {
- case sal_uInt16(OBJ_NONE ): pObj=new SdrObject; break;
- case sal_uInt16(OBJ_GRUP ): pObj=new SdrObjGroup; break;
- case sal_uInt16(OBJ_LINE ): pObj=new SdrPathObj(OBJ_LINE ); break;
- case sal_uInt16(OBJ_POLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
- case sal_uInt16(OBJ_PLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
- case sal_uInt16(OBJ_PATHLINE ): pObj=new SdrPathObj(OBJ_PATHLINE ); break;
- case sal_uInt16(OBJ_PATHFILL ): pObj=new SdrPathObj(OBJ_PATHFILL ); break;
- case sal_uInt16(OBJ_FREELINE ): pObj=new SdrPathObj(OBJ_FREELINE ); break;
- case sal_uInt16(OBJ_FREEFILL ): pObj=new SdrPathObj(OBJ_FREEFILL ); break;
- case sal_uInt16(OBJ_PATHPOLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
- case sal_uInt16(OBJ_PATHPLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
- case sal_uInt16(OBJ_EDGE ): pObj=new SdrEdgeObj; break;
- case sal_uInt16(OBJ_RECT ): pObj=new SdrRectObj; break;
- case sal_uInt16(OBJ_CIRC ): pObj=new SdrCircObj(OBJ_CIRC ); break;
- case sal_uInt16(OBJ_SECT ): pObj=new SdrCircObj(OBJ_SECT ); break;
- case sal_uInt16(OBJ_CARC ): pObj=new SdrCircObj(OBJ_CARC ); break;
- case sal_uInt16(OBJ_CCUT ): pObj=new SdrCircObj(OBJ_CCUT ); break;
- case sal_uInt16(OBJ_TEXT ): pObj=new SdrRectObj(OBJ_TEXT ); break;
- case sal_uInt16(OBJ_TEXTEXT ): pObj=new SdrRectObj(OBJ_TEXTEXT ); break;
- case sal_uInt16(OBJ_TITLETEXT ): pObj=new SdrRectObj(OBJ_TITLETEXT ); break;
- case sal_uInt16(OBJ_OUTLINETEXT): pObj=new SdrRectObj(OBJ_OUTLINETEXT); break;
- case sal_uInt16(OBJ_MEASURE ): pObj=new SdrMeasureObj; break;
- case sal_uInt16(OBJ_GRAF ): pObj=new SdrGrafObj; break;
- case sal_uInt16(OBJ_OLE2 ): pObj=new SdrOle2Obj; break;
- case sal_uInt16(OBJ_FRAME ): pObj=new SdrOle2Obj(true); break;
- case sal_uInt16(OBJ_CAPTION ): pObj=new SdrCaptionObj; break;
- case sal_uInt16(OBJ_PAGE ): pObj=new SdrPageObj; break;
- case sal_uInt16(OBJ_UNO ): pObj=new SdrUnoObj(OUString()); break;
- case sal_uInt16(OBJ_CUSTOMSHAPE ): pObj=new SdrObjCustomShape(); break;
-#if HAVE_FEATURE_AVMEDIA
- case sal_uInt16(OBJ_MEDIA ): pObj=new SdrMediaObj(); break;
-#endif
- case sal_uInt16(OBJ_TABLE ): pObj=new sdr::table::SdrTableObj(pModel); break;
- }
- }
-
- if (!pObj)
- pObj = CreateObjectFromFactory(nInvent, nIdent);
-
- if (!pObj)
- {
- // Well, if no one wants it...
- return nullptr;
- }
-
- if (pPage)
- pObj->SetPage(pPage);
- else if (pModel)
- pObj->SetModel(pModel);
-
- return pObj;
-}
-
SdrObject* SdrObjFactory::MakeNewObject(
- SdrInventor nInventor, sal_uInt16 nIdentifier, const tools::Rectangle& rSnapRect, SdrPage* pPage )
+ SdrModel& rSdrModel,
+ SdrInventor nInventor,
+ sal_uInt16 nIdentifier,
+ SdrPage* pPage,
+ const tools::Rectangle* pSnapRect)
{
- SdrModel* pModel = pPage ? pPage->GetModel() : nullptr;
-
- SdrObject* pObj = nullptr;
-
- bool bSetSnapRect = true;
+ SdrObject* pObj(nullptr);
+ bool bSetSnapRect(nullptr != pSnapRect);
if (nInventor == SdrInventor::Default)
{
@@ -3147,15 +3058,44 @@ SdrObject* SdrObjFactory::MakeNewObject(
{
case OBJ_MEASURE:
{
- pObj = new SdrMeasureObj(rSnapRect.TopLeft(), rSnapRect.BottomRight());
+ if(nullptr != pSnapRect)
+ {
+ pObj = new SdrMeasureObj(
+ rSdrModel,
+ pSnapRect->TopLeft(),
+ pSnapRect->BottomRight());
+ }
+ else
+ {
+ pObj = new SdrMeasureObj(rSdrModel);
+ }
}
break;
case OBJ_LINE:
{
- basegfx::B2DPolygon aPoly;
- aPoly.append(basegfx::B2DPoint(rSnapRect.Left(), rSnapRect.Top()));
- aPoly.append(basegfx::B2DPoint(rSnapRect.Right(), rSnapRect.Bottom()));
- pObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly));
+ if(nullptr != pSnapRect)
+ {
+ basegfx::B2DPolygon aPoly;
+
+ aPoly.append(
+ basegfx::B2DPoint(
+ pSnapRect->Left(),
+ pSnapRect->Top()));
+ aPoly.append(
+ basegfx::B2DPoint(
+ pSnapRect->Right(),
+ pSnapRect->Bottom()));
+ pObj = new SdrPathObj(
+ rSdrModel,
+ OBJ_LINE,
+ basegfx::B2DPolyPolygon(aPoly));
+ }
+ else
+ {
+ pObj = new SdrPathObj(
+ rSdrModel,
+ OBJ_LINE);
+ }
}
break;
case OBJ_TEXT:
@@ -3163,8 +3103,20 @@ SdrObject* SdrObjFactory::MakeNewObject(
case OBJ_TITLETEXT:
case OBJ_OUTLINETEXT:
{
- pObj = new SdrRectObj(static_cast<SdrObjKind>(nIdentifier), rSnapRect);
- bSetSnapRect = false;
+ if(nullptr != pSnapRect)
+ {
+ pObj = new SdrRectObj(
+ rSdrModel,
+ static_cast<SdrObjKind>(nIdentifier),
+ *pSnapRect);
+ bSetSnapRect = false;
+ }
+ else
+ {
+ pObj = new SdrRectObj(
+ rSdrModel,
+ static_cast<SdrObjKind>(nIdentifier));
+ }
}
break;
case OBJ_CIRC:
@@ -3172,38 +3124,52 @@ SdrObject* SdrObjFactory::MakeNewObject(
case OBJ_CARC:
case OBJ_CCUT:
{
- pObj = new SdrCircObj(static_cast<SdrObjKind>(nIdentifier), rSnapRect);
- bSetSnapRect = false;
+ if(nullptr != pSnapRect)
+ {
+ pObj = new SdrCircObj(
+ rSdrModel,
+ static_cast<SdrObjKind>(nIdentifier),
+ *pSnapRect);
+ bSetSnapRect = false;
+ }
+ else
+ {
+ pObj = new SdrCircObj(
+ rSdrModel,
+ static_cast<SdrObjKind>(nIdentifier));
+ }
}
break;
- case sal_uInt16(OBJ_NONE ): pObj=new SdrObject; break;
- case sal_uInt16(OBJ_GRUP ): pObj=new SdrObjGroup; break;
- case sal_uInt16(OBJ_POLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
- case sal_uInt16(OBJ_PLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
- case sal_uInt16(OBJ_PATHLINE ): pObj=new SdrPathObj(OBJ_PATHLINE ); break;
- case sal_uInt16(OBJ_PATHFILL ): pObj=new SdrPathObj(OBJ_PATHFILL ); break;
- case sal_uInt16(OBJ_FREELINE ): pObj=new SdrPathObj(OBJ_FREELINE ); break;
- case sal_uInt16(OBJ_FREEFILL ): pObj=new SdrPathObj(OBJ_FREEFILL ); break;
- case sal_uInt16(OBJ_PATHPOLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
- case sal_uInt16(OBJ_PATHPLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
- case sal_uInt16(OBJ_EDGE ): pObj=new SdrEdgeObj; break;
- case sal_uInt16(OBJ_RECT ): pObj=new SdrRectObj; break;
- case sal_uInt16(OBJ_GRAF ): pObj=new SdrGrafObj; break;
- case sal_uInt16(OBJ_OLE2 ): pObj=new SdrOle2Obj; break;
- case sal_uInt16(OBJ_FRAME ): pObj=new SdrOle2Obj(true); break;
- case sal_uInt16(OBJ_CAPTION ): pObj=new SdrCaptionObj; break;
- case sal_uInt16(OBJ_PAGE ): pObj=new SdrPageObj; break;
- case sal_uInt16(OBJ_UNO ): pObj=new SdrUnoObj(OUString()); break;
- case sal_uInt16(OBJ_CUSTOMSHAPE ): pObj=new SdrObjCustomShape(); break;
+ case sal_uInt16(OBJ_NONE ): pObj=new SdrObject(rSdrModel); break;
+ case sal_uInt16(OBJ_GRUP ): pObj=new SdrObjGroup(rSdrModel); break;
+ case sal_uInt16(OBJ_POLY ): pObj=new SdrPathObj(rSdrModel, OBJ_POLY ); break;
+ case sal_uInt16(OBJ_PLIN ): pObj=new SdrPathObj(rSdrModel, OBJ_PLIN ); break;
+ case sal_uInt16(OBJ_PATHLINE ): pObj=new SdrPathObj(rSdrModel, OBJ_PATHLINE ); break;
+ case sal_uInt16(OBJ_PATHFILL ): pObj=new SdrPathObj(rSdrModel, OBJ_PATHFILL ); break;
+ case sal_uInt16(OBJ_FREELINE ): pObj=new SdrPathObj(rSdrModel, OBJ_FREELINE ); break;
+ case sal_uInt16(OBJ_FREEFILL ): pObj=new SdrPathObj(rSdrModel, OBJ_FREEFILL ); break;
+ case sal_uInt16(OBJ_PATHPOLY ): pObj=new SdrPathObj(rSdrModel, OBJ_POLY ); break;
+ case sal_uInt16(OBJ_PATHPLIN ): pObj=new SdrPathObj(rSdrModel, OBJ_PLIN ); break;
+ case sal_uInt16(OBJ_EDGE ): pObj=new SdrEdgeObj(rSdrModel); break;
+ case sal_uInt16(OBJ_RECT ): pObj=new SdrRectObj(rSdrModel); break;
+ case sal_uInt16(OBJ_GRAF ): pObj=new SdrGrafObj(rSdrModel); break;
+ case sal_uInt16(OBJ_OLE2 ): pObj=new SdrOle2Obj(rSdrModel); break;
+ case sal_uInt16(OBJ_FRAME ): pObj=new SdrOle2Obj(rSdrModel, true); break;
+ case sal_uInt16(OBJ_CAPTION ): pObj=new SdrCaptionObj(rSdrModel); break;
+ case sal_uInt16(OBJ_PAGE ): pObj=new SdrPageObj(rSdrModel); break;
+ case sal_uInt16(OBJ_UNO ): pObj=new SdrUnoObj(rSdrModel, OUString()); break;
+ case sal_uInt16(OBJ_CUSTOMSHAPE ): pObj=new SdrObjCustomShape(rSdrModel); break;
#if HAVE_FEATURE_AVMEDIA
- case sal_uInt16(OBJ_MEDIA ): pObj=new SdrMediaObj(); break;
+ case sal_uInt16(OBJ_MEDIA ): pObj=new SdrMediaObj(rSdrModel); break;
#endif
- case sal_uInt16(OBJ_TABLE ): pObj=new sdr::table::SdrTableObj(pModel); break;
+ case sal_uInt16(OBJ_TABLE ): pObj=new sdr::table::SdrTableObj(rSdrModel); break;
}
}
if (!pObj)
- pObj = CreateObjectFromFactory(nInventor, nIdentifier);
+ {
+ pObj = CreateObjectFromFactory(rSdrModel, nInventor, nIdentifier);
+ }
if (!pObj)
{
@@ -3211,11 +3177,15 @@ SdrObject* SdrObjFactory::MakeNewObject(
return nullptr;
}
- if (pPage)
+ if(nullptr != pPage)
+ {
pObj->SetPage(pPage);
+ }
- if (bSetSnapRect)
- pObj->SetSnapRect(rSnapRect);
+ if(bSetSnapRect && nullptr != pSnapRect)
+ {
+ pObj->SetSnapRect(*pSnapRect);
+ }
return pObj;
}
diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx
index 00cb7ded37ab..cd688f348842 100644
--- a/svx/source/svdraw/svdocapt.cxx
+++ b/svx/source/svdraw/svdocapt.cxx
@@ -189,16 +189,19 @@ sdr::contact::ViewContact* SdrCaptionObj::CreateObjectSpecificViewContact()
}
-SdrCaptionObj::SdrCaptionObj():
- SdrRectObj(OBJ_TEXT),
+SdrCaptionObj::SdrCaptionObj(SdrModel& rSdrModel)
+: SdrRectObj(rSdrModel, OBJ_TEXT),
aTailPoly(3), // default size: 3 points = 2 lines
mbSpecialTextBoxShadow(false),
mbFixedTail(false)
{
}
-SdrCaptionObj::SdrCaptionObj(const tools::Rectangle& rRect, const Point& rTail):
- SdrRectObj(OBJ_TEXT,rRect),
+SdrCaptionObj::SdrCaptionObj(
+ SdrModel& rSdrModel,
+ const tools::Rectangle& rRect,
+ const Point& rTail)
+: SdrRectObj(rSdrModel, OBJ_TEXT,rRect),
aTailPoly(3), // default size: 3 points = 2 lines
mbSpecialTextBoxShadow(false),
mbFixedTail(false)
@@ -232,9 +235,23 @@ sal_uInt16 SdrCaptionObj::GetObjIdentifier() const
return sal_uInt16(OBJ_CAPTION);
}
-SdrCaptionObj* SdrCaptionObj::Clone() const
+SdrCaptionObj* SdrCaptionObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrCaptionObj >();
+ return CloneHelper< SdrCaptionObj >(pTargetModel);
+}
+
+SdrCaptionObj& SdrCaptionObj::operator=(const SdrCaptionObj& rObj)
+{
+ if( this == &rObj )
+ return *this;
+ SdrRectObj::operator=(rObj);
+
+ aTailPoly = rObj.aTailPoly;
+ mbSpecialTextBoxShadow = rObj.mbSpecialTextBoxShadow;
+ mbFixedTail = rObj.mbFixedTail;
+ maFixedTailPos = rObj.maFixedTailPos;
+
+ return *this;
}
OUString SdrCaptionObj::TakeObjNameSingul() const
@@ -663,12 +680,6 @@ Point SdrCaptionObj::GetSnapPoint(sal_uInt32 /*i*/) const
return Point(0,0);
}
-void SdrCaptionObj::SetModel(SdrModel* pNewModel)
-{
- SdrRectObj::SetModel(pNewModel);
- ImpRecalcTail();
-}
-
void SdrCaptionObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
{
SdrRectObj::Notify(rBC,rHint);
@@ -706,8 +717,9 @@ SdrObject* SdrCaptionObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
if (pOL!=nullptr) { pRet=pRect; bInsTail = false; }
if (pOL==nullptr) pOL=pRect->GetSubList();
if (pOL!=nullptr) { pRet=pRect; bInsRect = false; }
- if (pOL==nullptr) {
- SdrObjGroup* pGrp=new SdrObjGroup;
+ if (pOL==nullptr)
+ {
+ SdrObjGroup* pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
pOL=pGrp->GetSubList();
pRet=pGrp;
}
@@ -747,7 +759,8 @@ void SdrCaptionObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, cons
handleNegativeScale(aScale, &fRotate);
// force metric to pool metric
- MapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
+ MapUnit eMapUnit(getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
+
if(eMapUnit != MapUnit::Map100thMM)
{
switch(eMapUnit)
@@ -772,7 +785,7 @@ void SdrCaptionObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, cons
}
// if anchor is used, make position relative to it
- if( pModel->IsWriter() )
+ if(getSdrModelFromSdrObject().IsWriter())
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index dc87f9a5de9a..1dc049f07d17 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -104,8 +104,10 @@ sdr::contact::ViewContact* SdrCircObj::CreateObjectSpecificViewContact()
return new sdr::contact::ViewContactOfSdrCircObj(*this);
}
-
-SdrCircObj::SdrCircObj(SdrObjKind eNewKind)
+SdrCircObj::SdrCircObj(
+ SdrModel& rSdrModel,
+ SdrObjKind eNewKind)
+: SdrRectObj(rSdrModel)
{
nStartAngle=0;
nEndAngle=36000;
@@ -113,8 +115,11 @@ SdrCircObj::SdrCircObj(SdrObjKind eNewKind)
bClosedObj=eNewKind!=OBJ_CARC;
}
-SdrCircObj::SdrCircObj(SdrObjKind eNewKind, const tools::Rectangle& rRect):
- SdrRectObj(rRect)
+SdrCircObj::SdrCircObj(
+ SdrModel& rSdrModel,
+ SdrObjKind eNewKind,
+ const tools::Rectangle& rRect)
+: SdrRectObj(rSdrModel, rRect)
{
nStartAngle=0;
nEndAngle=36000;
@@ -122,8 +127,13 @@ SdrCircObj::SdrCircObj(SdrObjKind eNewKind, const tools::Rectangle& rRect):
bClosedObj=eNewKind!=OBJ_CARC;
}
-SdrCircObj::SdrCircObj(SdrObjKind eNewKind, const tools::Rectangle& rRect, long nNewStartWink, long nNewEndWink):
- SdrRectObj(rRect)
+SdrCircObj::SdrCircObj(
+ SdrModel& rSdrModel,
+ SdrObjKind eNewKind,
+ const tools::Rectangle& rRect,
+ long nNewStartWink,
+ long nNewEndWink)
+: SdrRectObj(rSdrModel, rRect)
{
long nAngleDif=nNewEndWink-nNewStartWink;
nStartAngle=NormAngle360(nNewStartWink);
@@ -338,9 +348,22 @@ OUString SdrCircObj::TakeObjNamePlural() const
return ImpGetResStr(pID);
}
-SdrCircObj* SdrCircObj::Clone() const
+SdrCircObj* SdrCircObj::Clone(SdrModel* pTargetModel) const
+{
+ return CloneHelper< SdrCircObj >(pTargetModel);
+}
+
+SdrCircObj& SdrCircObj::operator=(const SdrCircObj& rObj)
{
- return CloneHelper< SdrCircObj >();
+ if( this == &rObj )
+ return *this;
+ SdrRectObj::operator=(rObj);
+
+ meCircleKind = rObj.meCircleKind;
+ nStartAngle = rObj.nStartAngle;
+ nEndAngle = rObj.nEndAngle;
+
+ return *this;
}
basegfx::B2DPolyPolygon SdrCircObj::TakeXorPoly() const
@@ -576,7 +599,7 @@ OUString SdrCircObj::getSpecialDragComment(const SdrDragStat& rDrag) const
nAngle = pU->nEnd;
}
- aBuf.append(GetAngleStr(nAngle));
+ aBuf.append(SdrModel::GetAngleString(nAngle));
aBuf.append(')');
}
@@ -594,7 +617,7 @@ OUString SdrCircObj::getSpecialDragComment(const SdrDragStat& rDrag) const
ImpTakeDescriptionStr(STR_DragCircAngle, aStr);
OUStringBuffer aBuf(aStr);
aBuf.append(" (");
- aBuf.append(GetAngleStr(nAngle));
+ aBuf.append(SdrModel::GetAngleString(nAngle));
aBuf.append(')');
return aBuf.makeStringAndClear();
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index 45203c3d63cf..ce5a636a5e03 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -161,8 +161,8 @@ sdr::contact::ViewContact* SdrEdgeObj::CreateObjectSpecificViewContact()
}
-SdrEdgeObj::SdrEdgeObj()
-: SdrTextObj(),
+SdrEdgeObj::SdrEdgeObj(SdrModel& rSdrModel)
+: SdrTextObj(rSdrModel),
nNotifyingCount(0),
bEdgeTrackDirty(false),
bEdgeTrackUserDefined(false),
@@ -520,13 +520,14 @@ void SdrEdgeObj::ImpSetTailPoint(bool bTail1, const Point& rPt)
void SdrEdgeObj::ImpDirtyEdgeTrack()
{
- if ( !bEdgeTrackUserDefined || !(GetModel() && GetModel()->isLocked()) )
+ if ( !bEdgeTrackUserDefined || !getSdrModelFromSdrObject().isLocked() )
bEdgeTrackDirty = true;
}
void SdrEdgeObj::ImpUndirtyEdgeTrack()
{
- if (bEdgeTrackDirty && (GetModel() && GetModel()->isLocked()) ) {
+ if (bEdgeTrackDirty && getSdrModelFromSdrObject().isLocked())
+ {
ImpRecalcEdgeTrack();
}
}
@@ -540,7 +541,7 @@ void SdrEdgeObj::ImpRecalcEdgeTrack()
}
// #i120437# also not when model locked during import, but remember
- if(!GetModel() || GetModel()->isLocked())
+ if(getSdrModelFromSdrObject().isLocked())
{
mbSuppressed = true;
return;
@@ -1615,9 +1616,9 @@ void SdrEdgeObj::Reformat()
}
}
-SdrEdgeObj* SdrEdgeObj::Clone() const
+SdrEdgeObj* SdrEdgeObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrEdgeObj >();
+ return CloneHelper< SdrEdgeObj >(pTargetModel);
}
SdrEdgeObj& SdrEdgeObj::operator=(const SdrEdgeObj& rObj)
@@ -2247,7 +2248,7 @@ void SdrEdgeObj::NbcResize(const Point& rRefPnt, const Fraction& aXFact, const F
ResizeXPoly(*pEdgeTrack,rRefPnt,aXFact,aYFact);
// if resize is not from paste, forget user distances
- if (!GetModel() || !GetModel()->IsPasteResize())
+ if (!getSdrModelFromSdrObject().IsPasteResize())
{
aEdgeInfo.aObj1Line2 = Point();
aEdgeInfo.aObj1Line3 = Point();
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 1a00716fa088..e61a09da8e2b 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -216,8 +216,8 @@ void SdrGraphicLink::RemoveGraphicUpdater()
::sfx2::SvBaseLink::UpdateResult SdrGraphicLink::DataChanged(
const OUString& rMimeType, const css::uno::Any & rValue )
{
- SdrModel* pModel = rGrafObj.GetModel();
- sfx2::LinkManager* pLinkManager= pModel ? pModel->GetLinkManager() : nullptr;
+ SdrModel& rModel(rGrafObj.getSdrModelFromSdrObject());
+ sfx2::LinkManager* pLinkManager(rModel.GetLinkManager());
if( pLinkManager && rValue.hasValue() )
{
@@ -325,15 +325,14 @@ void SdrGrafObj::onGraphicChanged()
}
}
-
-SdrGrafObj::SdrGrafObj()
- : SdrRectObj()
- , mpGraphicObject(new GraphicObject)
- , pGraphicLink(nullptr)
- , bMirrored(false)
- , mbIsSignatureLine(false)
- , mbIsSignatureLineShowSignDate(true)
- , mbIsSignatureLineCanAddComment(false)
+SdrGrafObj::SdrGrafObj(SdrModel& rSdrModel)
+: SdrRectObj(rSdrModel)
+ ,mpGraphicObject(new GraphicObject)
+ ,pGraphicLink(nullptr)
+ ,bMirrored(false)
+ ,mbIsSignatureLine(false)
+ ,mbIsSignatureLineShowSignDate(true)
+ ,mbIsSignatureLineCanAddComment(false)
{
mpGraphicObject->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
@@ -352,14 +351,17 @@ SdrGrafObj::SdrGrafObj()
mbSupportTextIndentingOnLineWidthChange = false;
}
-SdrGrafObj::SdrGrafObj(const Graphic& rGraphic, const tools::Rectangle& rRect)
- : SdrRectObj(rRect)
- , mpGraphicObject(new GraphicObject(rGraphic))
- , pGraphicLink(nullptr)
- , bMirrored(false)
- , mbIsSignatureLine(false)
- , mbIsSignatureLineShowSignDate(true)
- , mbIsSignatureLineCanAddComment(false)
+SdrGrafObj::SdrGrafObj(
+ SdrModel& rSdrModel,
+ const Graphic& rGraphic,
+ const tools::Rectangle& rRect)
+: SdrRectObj(rSdrModel, rRect)
+ ,mpGraphicObject(new GraphicObject(rGraphic))
+ ,pGraphicLink(nullptr)
+ ,bMirrored(false)
+ ,mbIsSignatureLine(false)
+ ,mbIsSignatureLineShowSignDate(true)
+ ,mbIsSignatureLineCanAddComment(false)
{
mpGraphicObject->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
@@ -378,14 +380,16 @@ SdrGrafObj::SdrGrafObj(const Graphic& rGraphic, const tools::Rectangle& rRect)
mbSupportTextIndentingOnLineWidthChange = false;
}
-SdrGrafObj::SdrGrafObj(const Graphic& rGraphic)
- : SdrRectObj()
- , mpGraphicObject(new GraphicObject(rGraphic))
- , pGraphicLink(nullptr)
- , bMirrored(false)
- , mbIsSignatureLine(false)
- , mbIsSignatureLineShowSignDate(true)
- , mbIsSignatureLineCanAddComment(false)
+SdrGrafObj::SdrGrafObj(
+ SdrModel& rSdrModel,
+ const Graphic& rGraphic)
+: SdrRectObj(rSdrModel)
+ ,mpGraphicObject(new GraphicObject(rGraphic))
+ ,pGraphicLink(nullptr)
+ ,bMirrored(false)
+ ,mbIsSignatureLine(false)
+ ,mbIsSignatureLineShowSignDate(true)
+ ,mbIsSignatureLineCanAddComment(false)
{
mpGraphicObject->SetSwapStreamHdl( LINK(this, SdrGrafObj, ImpSwapHdl) );
onGraphicChanged();
@@ -481,10 +485,12 @@ Graphic SdrGrafObj::GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformF
{
// Refactored most of the code to GraphicObject, where
// everybody can use e.g. the cropping functionality
-
- MapMode aDestMap( pModel->GetScaleUnit(), Point(), pModel->GetScaleFraction(), pModel->GetScaleFraction() );
- const Size aDestSize( GetLogicRect().GetSize() );
-
+ MapMode aDestMap(
+ getSdrModelFromSdrObject().GetScaleUnit(),
+ Point(),
+ getSdrModelFromSdrObject().GetScaleFraction(),
+ getSdrModelFromSdrObject().GetScaleFraction());
+ const Size aDestSize( GetLogicRect().GetSize() );
GraphicAttr aActAttr = GetGraphicAttr(nTransformFlags);
// Delegate to moved code in GraphicObject
@@ -559,11 +565,12 @@ const Size& SdrGrafObj::GetGrafPrefSize() const
void SdrGrafObj::SetGrafStreamURL( const OUString& rGraphicStreamURL )
{
mbIsPreview = false;
+
if( rGraphicStreamURL.isEmpty() )
{
mpGraphicObject->SetUserData();
}
- else if( pModel->IsSwapGraphics() )
+ else if(getSdrModelFromSdrObject().IsSwapGraphics() )
{
mpGraphicObject->SetUserData( rGraphicStreamURL );
}
@@ -580,21 +587,20 @@ Size SdrGrafObj::getOriginalSize() const
if (aGrafInfo.IsCropped())
{
- long aCroppedTop = OutputDevice::LogicToLogic( aGrafInfo.GetTopCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
- long aCroppedBottom = OutputDevice::LogicToLogic( aGrafInfo.GetBottomCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
- long aCroppedLeft = OutputDevice::LogicToLogic( aGrafInfo.GetLeftCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
- long aCroppedRight = OutputDevice::LogicToLogic( aGrafInfo.GetRightCrop(), GetModel()->GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit());
-
- long aCroppedWidth = aSize.getWidth() - aCroppedLeft + aCroppedRight;
- long aCroppedHeight = aSize.getHeight() - aCroppedTop + aCroppedBottom;
+ const long aCroppedTop(OutputDevice::LogicToLogic(aGrafInfo.GetTopCrop(), getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
+ const long aCroppedBottom(OutputDevice::LogicToLogic(aGrafInfo.GetBottomCrop(), getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
+ const long aCroppedLeft(OutputDevice::LogicToLogic(aGrafInfo.GetLeftCrop(), getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
+ const long aCroppedRight(OutputDevice::LogicToLogic(aGrafInfo.GetRightCrop(), getSdrModelFromSdrObject().GetScaleUnit(), GetGrafPrefMapMode().GetMapUnit()));
+ const long aCroppedWidth(aSize.getWidth() - aCroppedLeft + aCroppedRight);
+ const long aCroppedHeight(aSize.getHeight() - aCroppedTop + aCroppedBottom);
aSize = Size ( aCroppedWidth, aCroppedHeight);
}
if ( GetGrafPrefMapMode().GetMapUnit() == MapUnit::MapPixel )
- aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, MapMode(GetModel()->GetScaleUnit()));
+ aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, MapMode(getSdrModelFromSdrObject().GetScaleUnit()));
else
- aSize = OutputDevice::LogicToLogic(aSize, GetGrafPrefMapMode(), MapMode(GetModel()->GetScaleUnit()));
+ aSize = OutputDevice::LogicToLogic(aSize, GetGrafPrefMapMode(), MapMode(getSdrModelFromSdrObject().GetScaleUnit()));
return aSize;
}
@@ -629,7 +635,7 @@ void SdrGrafObj::ForceSwapIn() const
void SdrGrafObj::ImpRegisterLink()
{
- sfx2::LinkManager* pLinkManager = pModel != nullptr ? pModel->GetLinkManager() : nullptr;
+ sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
if( pLinkManager != nullptr && pGraphicLink == nullptr )
{
@@ -645,7 +651,7 @@ void SdrGrafObj::ImpRegisterLink()
void SdrGrafObj::ImpDeregisterLink()
{
- sfx2::LinkManager* pLinkManager = pModel != nullptr ? pModel->GetLinkManager() : nullptr;
+ sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
if( pLinkManager != nullptr && pGraphicLink!=nullptr)
{
@@ -730,11 +736,11 @@ bool SdrGrafObj::ImpUpdateGraphicLink( bool bAsynchron ) const
void SdrGrafObj::ImpSetLinkedGraphic( const Graphic& rGraphic )
{
- const bool bIsChanged = GetModel()->IsChanged();
+ const bool bIsChanged(getSdrModelFromSdrObject().IsChanged());
NbcSetGraphic( rGraphic );
ActionChanged();
BroadcastObjectChange();
- GetModel()->SetChanged( bIsChanged );
+ getSdrModelFromSdrObject().SetChanged(bIsChanged);
}
OUString SdrGrafObj::TakeObjNameSingul() const
@@ -894,9 +900,9 @@ SdrObject* SdrGrafObj::getFullDragClone() const
return pRetval;
}
-SdrGrafObj* SdrGrafObj::Clone() const
+SdrGrafObj* SdrGrafObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrGrafObj >();
+ return CloneHelper< SdrGrafObj >(pTargetModel);
}
SdrGrafObj& SdrGrafObj::operator=( const SdrGrafObj& rObj )
@@ -1016,14 +1022,14 @@ void SdrGrafObj::SetPage( SdrPage* pNewPage )
ImpDeregisterLink();
}
- 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)
{
@@ -1042,28 +1048,6 @@ void SdrGrafObj::SetPage( SdrPage* pNewPage )
ImpRegisterLink();
}
-void SdrGrafObj::SetModel( SdrModel* pNewModel )
-{
- bool bChg = pNewModel != pModel;
-
- if( bChg )
- {
- if( mpGraphicObject->HasUserData() )
- {
- ForceSwapIn();
- }
-
- if( pGraphicLink != nullptr )
- ImpDeregisterLink();
- }
-
- // realize model
- SdrRectObj::SetModel(pNewModel);
-
- if (bChg && !aFileName.isEmpty())
- ImpRegisterLink();
-}
-
void SdrGrafObj::StartAnimation()
{
SetGrafAnimationAllowed(true);
@@ -1083,11 +1067,15 @@ GDIMetaFile SdrGrafObj::getMetafileFromEmbeddedVectorGraphicData() const
{
GDIMetaFile aRetval;
- if(isEmbeddedVectorGraphicData() && GetModel())
+ if(isEmbeddedVectorGraphicData())
{
ScopedVclPtrInstance< VirtualDevice > pOut;
const tools::Rectangle aBoundRect(GetCurrentBoundRect());
- const MapMode aMap(GetModel()->GetScaleUnit(), Point(), GetModel()->GetScaleFraction(), GetModel()->GetScaleFraction());
+ const MapMode aMap(
+ getSdrModelFromSdrObject().GetScaleUnit(),
+ Point(),
+ getSdrModelFromSdrObject().GetScaleFraction(),
+ getSdrModelFromSdrObject().GetScaleFraction());
pOut->EnableOutput(false);
pOut->SetMapMode(aMap);
@@ -1132,8 +1120,11 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
case GraphicType::GdiMetafile:
{
// Sort into group and return ONLY those objects that can be created from the MetaFile.
- ImpSdrGDIMetaFileImport aFilter(*GetModel(), GetLayer(), maRect);
- SdrObjGroup* pGrp = new SdrObjGroup();
+ ImpSdrGDIMetaFileImport aFilter(
+ getSdrModelFromSdrObject(),
+ GetLayer(),
+ maRect);
+ SdrObjGroup* pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
if(aFilter.DoImport(aMtf, *pGrp->GetSubList(), 0))
{
@@ -1156,7 +1147,6 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
pRetval = pGrp;
pGrp->NbcSetLayer(GetLayer());
- pGrp->SetModel(GetModel());
if(bAddText)
{
@@ -1198,10 +1188,8 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
if(!pGrp)
{
- pGrp = new SdrObjGroup();
-
+ pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
pGrp->NbcSetLayer(GetLayer());
- pGrp->SetModel(GetModel());
pGrp->GetSubList()->NbcInsertObject(pRetval);
}
@@ -1335,7 +1323,7 @@ IMPL_LINK(SdrGrafObj, ReplacementSwapHdl, const GraphicObject*, pO, SvStream*)
// replacement image is always swapped
if (pO->IsInSwapOut())
{
- SdrSwapGraphicsMode const nSwapMode(pModel->GetSwapGraphicsMode());
+ SdrSwapGraphicsMode const nSwapMode(getSdrModelFromSdrObject().GetSwapGraphicsMode());
if (nSwapMode & SdrSwapGraphicsMode::TEMP)
{
return GRFMGR_AUTOSWAPSTREAM_TEMP;
@@ -1359,13 +1347,13 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, const GraphicObject*, pO, SvStream* )
if( pO->IsInSwapOut() )
{
- if( pModel && !mbIsPreview && pModel->IsSwapGraphics() && mpGraphicObject->GetSizeBytes() > 20480 )
+ if( !mbIsPreview && getSdrModelFromSdrObject().IsSwapGraphics() && mpGraphicObject->GetSizeBytes() > 20480 )
{
// test if this object is visualized from someone
// ## test only if there are VOCs other than the preview renderer
if(!GetViewContact().HasViewObjectContacts())
{
- const SdrSwapGraphicsMode nSwapMode = pModel->GetSwapGraphicsMode();
+ const SdrSwapGraphicsMode nSwapMode = getSdrModelFromSdrObject().GetSwapGraphicsMode();
if( ( pGraphicLink ) &&
( nSwapMode & SdrSwapGraphicsMode::PURGE ) )
@@ -1391,78 +1379,73 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, const GraphicObject*, pO, SvStream* )
else if( pO->IsInSwapIn() )
{
// can be loaded from the original document stream later
- if( pModel != nullptr )
+ if(mpGraphicObject->HasUserData())
{
- if(mpGraphicObject->HasUserData())
+ ::comphelper::LifecycleProxy proxy;
+ OUString aUserData = mpGraphicObject->GetUserData();
+ uno::Reference<io::XInputStream> const xStream(
+ getSdrModelFromSdrObject().GetDocumentStream(aUserData, proxy));
+
+ std::unique_ptr<SvStream> const pStream( (xStream.is())
+ ? ::utl::UcbStreamHelper::CreateStream(xStream)
+ : nullptr );
+
+ if( pStream != nullptr )
{
- ::comphelper::LifecycleProxy proxy;
- OUString aUserData = mpGraphicObject->GetUserData();
- uno::Reference<io::XInputStream> const xStream(
- pModel->GetDocumentStream(aUserData, proxy));
+ Graphic aGraphic;
- std::unique_ptr<SvStream> const pStream( (xStream.is())
- ? ::utl::UcbStreamHelper::CreateStream(xStream)
- : nullptr );
+ std::unique_ptr<css::uno::Sequence< css::beans::PropertyValue > > pFilterData;
- if( pStream != nullptr )
+ if(mbInsidePaint && !GetViewContact().HasViewObjectContacts())
{
- Graphic aGraphic;
-
- std::unique_ptr<css::uno::Sequence< css::beans::PropertyValue > > pFilterData;
+ pFilterData.reset(new css::uno::Sequence< css::beans::PropertyValue >( 3 ));
+
+ const css::awt::Size aPreviewSizeHint( 64, 64 );
+ const bool bAllowPartialStreamRead = true;
+ // create <GfxLink> instance also for previews in order to avoid that its corresponding
+ // data is cleared in the graphic cache entry in case that the preview data equals the complete graphic data
+ const bool bCreateNativeLink = true;
+ (*pFilterData)[ 0 ].Name = "PreviewSizeHint";
+ (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint;
+ (*pFilterData)[ 1 ].Name = "AllowPartialStreamRead";
+ (*pFilterData)[ 1 ].Value <<= bAllowPartialStreamRead;
+ (*pFilterData)[ 2 ].Name = "CreateNativeLink";
+ (*pFilterData)[ 2 ].Value <<= bCreateNativeLink;
+
+ mbIsPreview = true;
+ }
- if(mbInsidePaint && !GetViewContact().HasViewObjectContacts())
+ if(!GraphicFilter::GetGraphicFilter().ImportGraphic(
+ aGraphic, aUserData, *pStream,
+ GRFILTER_FORMAT_DONTKNOW, nullptr, GraphicFilterImportFlags::NONE, pFilterData.get()))
+ {
+ const OUString aNewUserData( mpGraphicObject->GetUserData() );
+ mpGraphicObject->SetGraphic( aGraphic );
+ if( mbIsPreview )
{
- pFilterData.reset(new css::uno::Sequence< css::beans::PropertyValue >( 3 ));
-
- const css::awt::Size aPreviewSizeHint( 64, 64 );
- const bool bAllowPartialStreamRead = true;
- // create <GfxLink> instance also for previews in order to avoid that its corresponding
- // data is cleared in the graphic cache entry in case that the preview data equals the complete graphic data
- const bool bCreateNativeLink = true;
- (*pFilterData)[ 0 ].Name = "PreviewSizeHint";
- (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint;
- (*pFilterData)[ 1 ].Name = "AllowPartialStreamRead";
- (*pFilterData)[ 1 ].Value <<= bAllowPartialStreamRead;
- (*pFilterData)[ 2 ].Name = "CreateNativeLink";
- (*pFilterData)[ 2 ].Value <<= bCreateNativeLink;
-
- mbIsPreview = true;
+ mpGraphicObject->SetUserData(aNewUserData);
}
-
- if(!GraphicFilter::GetGraphicFilter().ImportGraphic(
- aGraphic, aUserData, *pStream,
- GRFILTER_FORMAT_DONTKNOW, nullptr, GraphicFilterImportFlags::NONE, pFilterData.get()))
+ else
{
- const OUString aNewUserData( mpGraphicObject->GetUserData() );
- mpGraphicObject->SetGraphic( aGraphic );
- if( mbIsPreview )
- {
- mpGraphicObject->SetUserData(aNewUserData);
- }
- else
- {
- mpGraphicObject->SetUserData();
- }
-
- // Graphic successfully swapped in.
- pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
+ mpGraphicObject->SetUserData();
}
- pFilterData.reset();
- pStream->ResetError();
+ // Graphic successfully swapped in.
+ pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
}
- }
- else if( !ImpUpdateGraphicLink( false ) )
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
- }
- else
- {
- pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
+ pFilterData.reset();
+
+ pStream->ResetError();
}
}
- else
+ else if( !ImpUpdateGraphicLink( false ) )
+ {
pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
+ }
+ else
+ {
+ pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
+ }
}
return pRet;
@@ -1481,30 +1464,27 @@ Reference< XInputStream > SdrGrafObj::getInputStream()
{
Reference< XInputStream > xStream;
- if( pModel )
+ if (mpGraphicObject && GetGraphic().IsLink())
{
- if (mpGraphicObject && GetGraphic().IsLink())
+ Graphic aGraphic( GetGraphic() );
+ GfxLink aLink( aGraphic.GetLink() );
+ sal_uInt32 nSize = aLink.GetDataSize();
+ const void* pSourceData = static_cast<const void*>(aLink.GetData());
+ if( nSize && pSourceData )
{
- Graphic aGraphic( GetGraphic() );
- GfxLink aLink( aGraphic.GetLink() );
- sal_uInt32 nSize = aLink.GetDataSize();
- const void* pSourceData = static_cast<const void*>(aLink.GetData());
- if( nSize && pSourceData )
- {
- sal_uInt8 * pBuffer = new sal_uInt8[ nSize ];
- memcpy( pBuffer, pSourceData, nSize );
+ sal_uInt8 * pBuffer = new sal_uInt8[ nSize ];
+ memcpy( pBuffer, pSourceData, nSize );
- SvMemoryStream* pStream = new SvMemoryStream( static_cast<void*>(pBuffer), static_cast<std::size_t>(nSize), StreamMode::READ );
- pStream->ObjectOwnsMemory( true );
- xStream.set( new utl::OInputStreamWrapper( pStream, true ) );
- }
+ SvMemoryStream* pStream = new SvMemoryStream( static_cast<void*>(pBuffer), static_cast<std::size_t>(nSize), StreamMode::READ );
+ pStream->ObjectOwnsMemory( true );
+ xStream.set( new utl::OInputStreamWrapper( pStream, true ) );
}
+ }
- if (!xStream.is() && !aFileName.isEmpty())
- {
- SvFileStream* pStream = new SvFileStream( aFileName, StreamMode::READ );
- xStream.set( new utl::OInputStreamWrapper( pStream ) );
- }
+ if (!xStream.is() && !aFileName.isEmpty())
+ {
+ SvFileStream* pStream = new SvFileStream( aFileName, StreamMode::READ );
+ xStream.set( new utl::OInputStreamWrapper( pStream ) );
}
return xStream;
diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx
index d2151f14f4e4..6311106c4e2f 100644
--- a/svx/source/svdraw/svdogrp.cxx
+++ b/svx/source/svdraw/svdogrp.cxx
@@ -50,32 +50,28 @@
#include <basegfx/polygon/b2dpolygon.hxx>
#include <libxml/xmlwriter.h>
-
// BaseProperties section
-
sdr::properties::BaseProperties* SdrObjGroup::CreateObjectSpecificProperties()
{
return new sdr::properties::GroupProperties(*this);
}
-
// DrawContact section
-
sdr::contact::ViewContact* SdrObjGroup::CreateObjectSpecificViewContact()
{
return new sdr::contact::ViewContactOfGroup(*this);
}
-
-SdrObjGroup::SdrObjGroup()
+SdrObjGroup::SdrObjGroup(SdrModel& rSdrModel)
+: SdrObject(rSdrModel),
+ maSdrObjList(),
+ aRefPoint(0, 0)
{
- pSub.reset( new SdrObjList(nullptr,nullptr) );
- pSub->SetOwnerObj(this);
- pSub->SetListKind(SdrObjListKind::GroupObj);
+ maSdrObjList.SetOwnerObj(this);
+ maSdrObjList.SetListKind(SdrObjListKind::GroupObj);
bClosedObj=false;
}
-
SdrObjGroup::~SdrObjGroup()
{
}
@@ -83,10 +79,9 @@ SdrObjGroup::~SdrObjGroup()
void SdrObjGroup::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
{
rInfo.bNoContortion=false;
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
SdrObjTransformInfoRec aInfo;
pObj->TakeObjInfo(aInfo);
if (!aInfo.bMoveAllowed ) rInfo.bMoveAllowed =false;
@@ -145,10 +140,9 @@ SdrLayerID SdrObjGroup::GetLayer() const
{
bool b1st = true;
SdrLayerID nLay = SdrObject::GetLayer();
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrLayerID nLay1=pOL->GetObj(i)->GetLayer();
+ SdrLayerID nLay1=maSdrObjList.GetObj(i)->GetLayer();
if (b1st) { nLay=nLay1; b1st = false; }
else if (nLay1!=nLay) return SdrLayerID(0);
}
@@ -159,10 +153,9 @@ SdrLayerID SdrObjGroup::GetLayer() const
void SdrObjGroup::NbcSetLayer(SdrLayerID nLayer)
{
SdrObject::NbcSetLayer(nLayer);
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- pOL->GetObj(i)->NbcSetLayer(nLayer);
+ maSdrObjList.GetObj(i)->NbcSetLayer(nLayer);
}
}
@@ -170,58 +163,27 @@ void SdrObjGroup::NbcSetLayer(SdrLayerID nLayer)
void SdrObjGroup::SetObjList(SdrObjList* pNewObjList)
{
SdrObject::SetObjList(pNewObjList);
- pSub->SetUpList(pNewObjList);
+ maSdrObjList.SetUpList(pNewObjList);
}
void SdrObjGroup::SetPage(SdrPage* pNewPage)
{
SdrObject::SetPage(pNewPage);
- pSub->SetPage(pNewPage);
-}
-
-
-void SdrObjGroup::SetModel(SdrModel* pNewModel)
-{
- if(pNewModel!=pModel)
- {
- // #i30648#
- // This method also needs to migrate the used ItemSet
- // when the destination model uses a different pool
- // than the current one. Else it is possible to create
- // SdrObjGroups which reference the old pool which might
- // be destroyed (as the bug shows).
- SdrModel* pOldModel = pModel;
-
- // test for correct pool in ItemSet; move to new pool if necessary
- if(pNewModel && &GetObjectItemPool() != &pNewModel->GetItemPool())
- {
- MigrateItemPool(&GetObjectItemPool(), &pNewModel->GetItemPool(), pNewModel);
- }
-
- // call parent
- SdrObject::SetModel(pNewModel);
-
- // set new model at content
- pSub->SetModel(pNewModel);
-
- // modify properties
- GetProperties().SetModel(pOldModel, pNewModel);
- }
+ maSdrObjList.SetPage(pNewPage);
}
-
SdrObjList* SdrObjGroup::GetSubList() const
{
- return pSub.get();
+ return const_cast< SdrObjList* >(&maSdrObjList);
}
const tools::Rectangle& SdrObjGroup::GetCurrentBoundRect() const
{
// <aOutRect> has to contain the bounding rectangle
- if ( pSub->GetObjCount()!=0 )
+ if ( maSdrObjList.GetObjCount()!=0 )
{
- const_cast<SdrObjGroup*>(this)->aOutRect = pSub->GetAllObjBoundRect();
+ const_cast<SdrObjGroup*>(this)->aOutRect = maSdrObjList.GetAllObjBoundRect();
}
return aOutRect;
@@ -230,9 +192,9 @@ const tools::Rectangle& SdrObjGroup::GetCurrentBoundRect() const
const tools::Rectangle& SdrObjGroup::GetSnapRect() const
{
// <aOutRect> has to contain the bounding rectangle
- if ( pSub->GetObjCount()!=0 )
+ if ( maSdrObjList.GetObjCount()!=0 )
{
- return pSub->GetAllObjSnapRect();
+ return maSdrObjList.GetAllObjSnapRect();
}
else
{
@@ -240,24 +202,24 @@ const tools::Rectangle& SdrObjGroup::GetSnapRect() const
}
}
-SdrObjGroup* SdrObjGroup::Clone() const
+SdrObjGroup* SdrObjGroup::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrObjGroup >();
+ return CloneHelper< SdrObjGroup >(pTargetModel);
}
SdrObjGroup& SdrObjGroup::operator=(const SdrObjGroup& rObj)
{
if( this == &rObj )
return *this;
+
// copy SdrObject stuff
SdrObject::operator=(rObj);
// #i36404#
// copy SubList, init model and page first
SdrObjList& rSourceSubList = *rObj.GetSubList();
- pSub->SetPage(rSourceSubList.GetPage());
- pSub->SetModel(rSourceSubList.GetModel());
- pSub->CopyObjects(*rObj.GetSubList());
+ maSdrObjList.SetPage(rSourceSubList.GetPage());
+ maSdrObjList.CopyObjects(*rObj.GetSubList());
// copy local parameters
aRefPoint = rObj.aRefPoint;
@@ -269,7 +231,7 @@ OUString SdrObjGroup::TakeObjNameSingul() const
{
OUStringBuffer sName;
- if(!pSub->GetObjCount())
+ if(!maSdrObjList.GetObjCount())
{
sName.append(ImpGetResStr(STR_ObjNameSingulGRUPEMPTY));
}
@@ -294,7 +256,7 @@ OUString SdrObjGroup::TakeObjNameSingul() const
OUString SdrObjGroup::TakeObjNamePlural() const
{
- if (pSub->GetObjCount()==0)
+ if (maSdrObjList.GetObjCount()==0)
return ImpGetResStr(STR_ObjNamePluralGRUPEMPTY);
return ImpGetResStr(STR_ObjNamePluralGRUP);
}
@@ -308,11 +270,11 @@ void SdrObjGroup::RecalcSnapRect()
basegfx::B2DPolyPolygon SdrObjGroup::TakeXorPoly() const
{
basegfx::B2DPolyPolygon aRetval;
- const size_t nObjCount(pSub->GetObjCount());
+ const size_t nObjCount(maSdrObjList.GetObjCount());
for(size_t a = 0; a < nObjCount; ++a)
{
- SdrObject* pObj = pSub->GetObj(a);
+ SdrObject* pObj = maSdrObjList.GetObj(a);
aRetval.append(pObj->TakeXorPoly());
}
@@ -341,9 +303,9 @@ long SdrObjGroup::GetRotateAngle() const
{
long nRetval(0);
- if(pSub->GetObjCount())
+ if(maSdrObjList.GetObjCount())
{
- SdrObject* pObj = pSub->GetObj(0);
+ SdrObject* pObj = maSdrObjList.GetObj(0);
nRetval = pObj->GetRotateAngle();
}
@@ -356,9 +318,9 @@ long SdrObjGroup::GetShearAngle(bool /*bVertical*/) const
{
long nRetval(0);
- if(pSub->GetObjCount())
+ if(maSdrObjList.GetObjCount())
{
- SdrObject* pObj = pSub->GetObj(0);
+ SdrObject* pObj = maSdrObjList.GetObj(0);
nRetval = pObj->GetShearAngle();
}
@@ -396,11 +358,10 @@ void SdrObjGroup::NbcSetLogicRect(const tools::Rectangle& rRect)
void SdrObjGroup::NbcMove(const Size& rSiz)
{
aRefPoint.Move(rSiz);
- if (pSub->GetObjCount()!=0) {
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ if (maSdrObjList.GetObjCount()!=0) {
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
pObj->NbcMove(rSiz);
}
} else {
@@ -428,11 +389,10 @@ void SdrObjGroup::NbcResize(const Point& rRef, const Fraction& xFact, const Frac
}
}
ResizePoint(aRefPoint,rRef,xFact,yFact);
- if (pSub->GetObjCount()!=0) {
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ if (maSdrObjList.GetObjCount()!=0) {
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
pObj->NbcResize(rRef,xFact,yFact);
}
} else {
@@ -446,10 +406,9 @@ void SdrObjGroup::NbcRotate(const Point& rRef, long nAngle, double sn, double cs
{
SetGlueReallyAbsolute(true);
RotatePoint(aRefPoint,rRef,sn,cs);
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
pObj->NbcRotate(rRef,nAngle,sn,cs);
}
NbcRotateGluePoints(rRef,nAngle,sn,cs);
@@ -461,10 +420,9 @@ void SdrObjGroup::NbcMirror(const Point& rRef1, const Point& rRef2)
{
SetGlueReallyAbsolute(true);
MirrorPoint(aRefPoint,rRef1,rRef2); // implementation missing in SvdEtc!
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
pObj->NbcMirror(rRef1,rRef2);
}
NbcMirrorGluePoints(rRef1,rRef2);
@@ -476,10 +434,9 @@ void SdrObjGroup::NbcShear(const Point& rRef, long nAngle, double tn, bool bVShe
{
SetGlueReallyAbsolute(true);
ShearPoint(aRefPoint,rRef,tn);
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
pObj->NbcShear(rRef,nAngle,tn,bVShear);
}
NbcShearGluePoints(rRef,tn,bVShear);
@@ -492,10 +449,9 @@ void SdrObjGroup::NbcSetAnchorPos(const Point& rPnt)
aAnchor=rPnt;
Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
aRefPoint.Move(aSiz);
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount=pOL->GetObjCount();
+ const size_t nObjCount=maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
pObj->NbcSetAnchorPos(rPnt);
}
}
@@ -537,16 +493,15 @@ void SdrObjGroup::Move(const Size& rSiz)
if (rSiz.Width()!=0 || rSiz.Height()!=0) {
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
aRefPoint.Move(rSiz);
- if (pSub->GetObjCount()!=0) {
+ if (maSdrObjList.GetObjCount()!=0) {
// first move the connectors, then everything else
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
if (pObj->IsEdgeObj()) pObj->Move(rSiz);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
if (!pObj->IsEdgeObj()) pObj->Move(rSiz);
}
} else {
@@ -581,16 +536,15 @@ void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fractio
}
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
ResizePoint(aRefPoint,rRef,xFact,yFact);
- if (pSub->GetObjCount()!=0) {
+ if (maSdrObjList.GetObjCount()!=0) {
// move the connectors first, everything else afterwards
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
if (pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact,bUnsetRelative);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
if (!pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact,bUnsetRelative);
}
} else {
@@ -614,14 +568,13 @@ void SdrObjGroup::Rotate(const Point& rRef, long nAngle, double sn, double cs)
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
RotatePoint(aRefPoint,rRef,sn,cs);
// move the connectors first, everything else afterwards
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
if (pObj->IsEdgeObj()) pObj->Rotate(rRef,nAngle,sn,cs);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
if (!pObj->IsEdgeObj()) pObj->Rotate(rRef,nAngle,sn,cs);
}
NbcRotateGluePoints(rRef,nAngle,sn,cs);
@@ -638,14 +591,13 @@ void SdrObjGroup::Mirror(const Point& rRef1, const Point& rRef2)
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
MirrorPoint(aRefPoint,rRef1,rRef2); // implementation missing in SvdEtc!
// move the connectors first, everything else afterwards
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
if (pObj->IsEdgeObj()) pObj->Mirror(rRef1,rRef2);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
if (!pObj->IsEdgeObj()) pObj->Mirror(rRef1,rRef2);
}
NbcMirrorGluePoints(rRef1,rRef2);
@@ -665,14 +617,13 @@ void SdrObjGroup::Shear(const Point& rRef, long nAngle, double tn, bool bVShear)
tools::Rectangle aBoundRect0; if (pUserCall!=nullptr) aBoundRect0=GetLastBoundRect();
ShearPoint(aRefPoint,rRef,tn);
// move the connectors first, everything else afterwards
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
if (pObj->IsEdgeObj()) pObj->Shear(rRef,nAngle,tn,bVShear);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
if (!pObj->IsEdgeObj()) pObj->Shear(rRef,nAngle,tn,bVShear);
}
NbcShearGluePoints(rRef,tn,bVShear);
@@ -692,14 +643,13 @@ void SdrObjGroup::SetAnchorPos(const Point& rPnt)
Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
aRefPoint.Move(aSiz);
// move the connectors first, everything else afterwards
- SdrObjList* pOL=pSub.get();
- const size_t nObjCount = pOL->GetObjCount();
+ const size_t nObjCount = maSdrObjList.GetObjCount();
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj=pOL->GetObj(i);
+ SdrObject* pObj=maSdrObjList.GetObj(i);
if (pObj->IsEdgeObj()) pObj->SetAnchorPos(rPnt);
}
for (size_t i=0; i<nObjCount; ++i) {
- SdrObject* pObj = pOL->GetObj(i);
+ SdrObject* pObj = maSdrObjList.GetObj(i);
if (!pObj->IsEdgeObj()) pObj->SetAnchorPos(rPnt);
}
if (bChg) {
@@ -726,22 +676,21 @@ void SdrObjGroup::SetRelativePos(const Point& rPnt)
void SdrObjGroup::NbcReformatText()
{
- pSub->NbcReformatAllTextObjects();
+ maSdrObjList.NbcReformatAllTextObjects();
}
void SdrObjGroup::ReformatText()
{
- pSub->ReformatAllTextObjects();
+ maSdrObjList.ReformatAllTextObjects();
}
SdrObject* SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
- SdrObject* pGroup = new SdrObjGroup;
- pGroup->SetModel(GetModel());
+ SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
- for(size_t a=0; a<pSub->GetObjCount(); ++a)
+ for(size_t a=0; a<maSdrObjList.GetObjCount(); ++a)
{
- SdrObject* pIterObj = pSub->GetObj(a);
+ SdrObject* pIterObj = maSdrObjList.GetObj(a);
SdrObject* pResult = pIterObj->DoConvertToPolyObj(bBezier, bAddText);
// pResult can be NULL e.g. for empty objects
@@ -759,7 +708,7 @@ void SdrObjGroup::dumpAsXml(xmlTextWriterPtr pWriter) const
SdrObject::dumpAsXml(pWriter);
- pSub->dumpAsXml(pWriter);
+ maSdrObjList.dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
}
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 63f33c6cbbce..9c1f6550f66d 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -94,71 +94,63 @@ OUString SdrMeasureObj::TakeRepresentation(SdrMeasureFieldKind eMeasureFieldKind
{
case SdrMeasureFieldKind::Value:
{
- if(pModel)
+ eModUIUnit = getSdrModelFromSdrObject().GetUIUnit();
+
+ if(eMeasureUnit == FUNIT_NONE)
+ eMeasureUnit = eModUIUnit;
+
+ sal_Int32 nLen(GetLen(aPt2 - aPt1));
+ Fraction aFact(1,1);
+
+ if(eMeasureUnit != eModUIUnit)
{
- eModUIUnit = pModel->GetUIUnit();
+ // for the unit conversion
+ aFact *= GetMapFactor(eModUIUnit, eMeasureUnit).X();
+ }
- if(eMeasureUnit == FUNIT_NONE)
- eMeasureUnit = eModUIUnit;
+ if(aMeasureScale.GetNumerator() != aMeasureScale.GetDenominator())
+ {
+ aFact *= aMeasureScale;
+ }
- sal_Int32 nLen(GetLen(aPt2 - aPt1));
- Fraction aFact(1,1);
+ if(aFact.GetNumerator() != aFact.GetDenominator())
+ {
+ // scale via BigInt, to avoid overruns
+ nLen = BigMulDiv(nLen, aFact.GetNumerator(), aFact.GetDenominator());
+ }
- if(eMeasureUnit != eModUIUnit)
- {
- // for the unit conversion
- aFact *= GetMapFactor(eModUIUnit, eMeasureUnit).X();
- }
+ if(!aFact.IsValid())
+ {
+ aStr = "?";
+ }
+ else
+ {
+ aStr = getSdrModelFromSdrObject().GetMetricString(nLen, true, nNumDigits);
+ }
- if(aMeasureScale.GetNumerator() != aMeasureScale.GetDenominator())
- {
- aFact *= aMeasureScale;
- }
+ SvtSysLocale aSysLocale;
+ const LocaleDataWrapper& rLocaleDataWrapper = aSysLocale.GetLocaleData();
+ sal_Unicode cDec(rLocaleDataWrapper.getNumDecimalSep()[0]);
+ sal_Unicode cDecAlt(rLocaleDataWrapper.getNumDecimalSepAlt().toChar());
- if(aFact.GetNumerator() != aFact.GetDenominator())
- {
- // scale via BigInt, to avoid overruns
- nLen = BigMulDiv(nLen, aFact.GetNumerator(), aFact.GetDenominator());
- }
+ if(aStr.indexOf(cDec) != -1 || (cDecAlt && aStr.indexOf(cDecAlt) != -1))
+ {
+ sal_Int32 nLen2(aStr.getLength() - 1);
- if(!aFact.IsValid())
- {
- aStr = "?";
- }
- else
+ while(aStr[nLen2] == '0')
{
- aStr = pModel->GetMetricString(nLen, true, nNumDigits);
+ aStr = aStr.copy(0, nLen2);
+ nLen2--;
}
- SvtSysLocale aSysLocale;
- const LocaleDataWrapper& rLocaleDataWrapper = aSysLocale.GetLocaleData();
- sal_Unicode cDec(rLocaleDataWrapper.getNumDecimalSep()[0]);
- sal_Unicode cDecAlt(rLocaleDataWrapper.getNumDecimalSepAlt().toChar());
-
- if(aStr.indexOf(cDec) != -1 || (cDecAlt && aStr.indexOf(cDecAlt) != -1))
+ if(aStr[nLen2] == cDec || (cDecAlt && aStr[nLen2] == cDecAlt))
{
- sal_Int32 nLen2(aStr.getLength() - 1);
-
- while(aStr[nLen2] == '0')
- {
- aStr = aStr.copy(0, nLen2);
- nLen2--;
- }
-
- if(aStr[nLen2] == cDec || (cDecAlt && aStr[nLen2] == cDecAlt))
- {
- aStr = aStr.copy(0, nLen2);
- nLen2--;
- }
-
- if(aStr.isEmpty())
- aStr += "0";
+ aStr = aStr.copy(0, nLen2);
+ nLen2--;
}
- }
- else
- {
- // if there's no Model ... (e. g. preview in dialog)
- aStr = "4711";
+
+ if(aStr.isEmpty())
+ aStr += "0";
}
break;
@@ -167,16 +159,13 @@ OUString SdrMeasureObj::TakeRepresentation(SdrMeasureFieldKind eMeasureFieldKind
{
if(bShowUnit)
{
- if(pModel)
- {
- eModUIUnit = pModel->GetUIUnit();
+ eModUIUnit = getSdrModelFromSdrObject().GetUIUnit();
- if(eMeasureUnit == FUNIT_NONE)
- eMeasureUnit = eModUIUnit;
+ if(eMeasureUnit == FUNIT_NONE)
+ eMeasureUnit = eModUIUnit;
- if(bShowUnit)
- aStr = SdrModel::GetUnitString(eMeasureUnit);
- }
+ if(bShowUnit)
+ aStr = SdrModel::GetUnitString(eMeasureUnit);
}
break;
@@ -211,14 +200,19 @@ sdr::contact::ViewContact* SdrMeasureObj::CreateObjectSpecificViewContact()
}
-SdrMeasureObj::SdrMeasureObj():
+SdrMeasureObj::SdrMeasureObj(SdrModel& rSdrModel)
+: SdrTextObj(rSdrModel),
bTextDirty(false)
{
// #i25616#
mbSupportTextIndentingOnLineWidthChange = false;
}
-SdrMeasureObj::SdrMeasureObj(const Point& rPt1, const Point& rPt2):
+SdrMeasureObj::SdrMeasureObj(
+ SdrModel& rSdrModel,
+ const Point& rPt1,
+ const Point& rPt2)
+: SdrTextObj(rSdrModel),
aPt1(rPt1),
aPt2(rPt2),
bTextDirty(false)
@@ -708,9 +702,22 @@ void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const
}
}
-SdrMeasureObj* SdrMeasureObj::Clone() const
+SdrMeasureObj* SdrMeasureObj::Clone(SdrModel* pTargetModel) const
+{
+ return CloneHelper< SdrMeasureObj >(pTargetModel);
+}
+
+SdrMeasureObj& SdrMeasureObj::operator=(const SdrMeasureObj& rObj)
{
- return CloneHelper< SdrMeasureObj >();
+ if( this == &rObj )
+ return *this;
+ SdrTextObj::operator=(rObj);
+
+ aPt1 = rObj.aPt1;
+ aPt2 = rObj.aPt2;
+ bTextDirty = rObj.bTextDirty;
+
+ return *this;
}
OUString SdrMeasureObj::TakeObjNameSingul() const
@@ -1138,8 +1145,7 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
SfxStyleSheet* pStyleSheet = GetStyleSheet();
// prepare group
- SdrObjGroup* pGroup = new SdrObjGroup;
- pGroup->SetModel(GetModel());
+ SdrObjGroup* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
// prepare parameters
basegfx::B2DPolyPolygon aPolyPoly;
@@ -1153,8 +1159,11 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
- pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
- pPath->SetModel(GetModel());
+ pPath = new SdrPathObj(
+ getSdrModelFromSdrObject(),
+ OBJ_PATHLINE,
+ aPolyPoly);
+
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
pGroup->GetSubList()->NbcInsertObject(pPath);
@@ -1171,8 +1180,11 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
- pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
- pPath->SetModel(GetModel());
+ pPath = new SdrPathObj(
+ getSdrModelFromSdrObject(),
+ OBJ_PATHLINE,
+ aPolyPoly);
+
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
@@ -1183,8 +1195,11 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[1].getB2DPolygon());
- pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
- pPath->SetModel(GetModel());
+ pPath = new SdrPathObj(
+ getSdrModelFromSdrObject(),
+ OBJ_PATHLINE,
+ aPolyPoly);
+
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
@@ -1202,8 +1217,11 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
- pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
- pPath->SetModel(GetModel());
+ pPath = new SdrPathObj(
+ getSdrModelFromSdrObject(),
+ OBJ_PATHLINE,
+ aPolyPoly);
+
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
@@ -1214,8 +1232,11 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[1].getB2DPolygon());
- pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
- pPath->SetModel(GetModel());
+ pPath = new SdrPathObj(
+ getSdrModelFromSdrObject(),
+ OBJ_PATHLINE,
+ aPolyPoly);
+
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
@@ -1229,8 +1250,11 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
{
aPolyPoly.clear();
aPolyPoly.append(aTmpPolyPolygon[nLoopStart].getB2DPolygon());
- pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
- pPath->SetModel(GetModel());
+ pPath = new SdrPathObj(
+ getSdrModelFromSdrObject(),
+ OBJ_PATHLINE,
+ aPolyPoly);
+
pPath->SetMergedItemSet(aSet);
pPath->SetStyleSheet(pStyleSheet, true);
@@ -1361,7 +1385,7 @@ bool SdrMeasureObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B
basegfx::B2DTuple aTranslate(aRange.getMinimum());
// position maybe relative to anchor position, convert
- if( pModel->IsWriter() )
+ if( getSdrModelFromSdrObject().IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -1370,7 +1394,7 @@ bool SdrMeasureObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B
}
// force MapUnit to 100th mm
- MapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
+ MapUnit eMapUnit = getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
if(eMapUnit != MapUnit::Map100thMM)
{
switch(eMapUnit)
@@ -1407,7 +1431,7 @@ void SdrMeasureObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, cons
basegfx::B2DPoint aPosB(rMatrix * basegfx::B2DPoint(1.0, 0.0));
// force metric to pool metric
- MapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
+ MapUnit eMapUnit = getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
if(eMapUnit != MapUnit::Map100thMM)
{
switch(eMapUnit)
@@ -1429,7 +1453,7 @@ void SdrMeasureObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, cons
}
}
- if( pModel->IsWriter() )
+ if( getSdrModelFromSdrObject().IsWriter() )
{
// if anchor is used, make position relative to it
if(GetAnchorPos().X() || GetAnchorPos().Y())
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index 4c41e76e6dc3..012dc1d35879 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -65,16 +65,17 @@ struct SdrMediaObj::Impl
OUString m_LastFailedPkgURL;
};
-
-SdrMediaObj::SdrMediaObj()
- : SdrRectObj()
- , m_xImpl( new Impl )
+SdrMediaObj::SdrMediaObj(SdrModel& rSdrModel)
+: SdrRectObj(rSdrModel)
+ ,m_xImpl( new Impl )
{
}
-SdrMediaObj::SdrMediaObj( const tools::Rectangle& rRect )
- : SdrRectObj( rRect )
- , m_xImpl( new Impl )
+SdrMediaObj::SdrMediaObj(
+ SdrModel& rSdrModel,
+ const tools::Rectangle& rRect)
+: SdrRectObj(rSdrModel, rRect)
+ ,m_xImpl( new Impl )
{
}
@@ -141,9 +142,9 @@ OUString SdrMediaObj::TakeObjNamePlural() const
return ImpGetResStr(STR_ObjNamePluralMEDIA);
}
-SdrMediaObj* SdrMediaObj::Clone() const
+SdrMediaObj* SdrMediaObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrMediaObj >();
+ return CloneHelper< SdrMediaObj >(pTargetModel);
}
SdrMediaObj& SdrMediaObj::operator=(const SdrMediaObj& rObj)
@@ -315,8 +316,14 @@ void SdrMediaObj::SetInputStream(uno::Reference<io::XInputStream> const& xStream
SAL_WARN("svx", "this is only intended for embedded media");
return;
}
+
OUString tempFileURL;
- bool const bSuccess = lcl_CopyToTempFile(xStream, tempFileURL, "");
+ const bool bSuccess(
+ lcl_CopyToTempFile(
+ xStream,
+ tempFileURL,
+ ""));
+
if (bSuccess)
{
m_xImpl->m_pTempFile.reset(new MediaTempFile(tempFileURL));
@@ -331,19 +338,14 @@ void SdrMediaObj::SetInputStream(uno::Reference<io::XInputStream> const& xStream
/// copy a stream from XStorage to temp file
#if HAVE_FEATURE_AVMEDIA
static bool lcl_HandlePackageURL(
- OUString const & rURL,
- SdrModel const *const pModel,
- OUString & o_rTempFileURL)
+ OUString const & rURL,
+ const SdrModel& rModel,
+ OUString & o_rTempFileURL)
{
- if (!pModel)
- {
- SAL_WARN("svx", "no model");
- return false;
- }
::comphelper::LifecycleProxy sourceProxy;
uno::Reference<io::XInputStream> xInStream;
try {
- xInStream = pModel->GetDocumentStream(rURL, sourceProxy);
+ xInStream = rModel.GetDocumentStream(rURL, sourceProxy);
}
catch (container::NoSuchElementException const&)
{
@@ -394,8 +396,12 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper
rNewProperties.getTempURL()))
{
OUString tempFileURL;
- bool bSuccess;
- bSuccess = lcl_HandlePackageURL(url, GetModel(), tempFileURL);
+ const bool bSuccess(
+ lcl_HandlePackageURL(
+ url,
+ getSdrModelFromSdrObject(),
+ tempFileURL));
+
if (bSuccess)
{
m_xImpl->m_pTempFile.reset(
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();
diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx
index a2a6592037ee..af38237fa632 100644
--- a/svx/source/svdraw/svdopage.cxx
+++ b/svx/source/svdraw/svdopage.cxx
@@ -64,9 +64,11 @@ void SdrPageObj::PageInDestruction(const SdrPage& rPage)
}
}
-
-SdrPageObj::SdrPageObj(SdrPage* pNewPage)
-: mpShownPage(pNewPage)
+SdrPageObj::SdrPageObj(
+ SdrModel& rSdrModel,
+ SdrPage* pNewPage)
+: SdrObject(rSdrModel),
+ mpShownPage(pNewPage)
{
if(mpShownPage)
{
@@ -74,8 +76,12 @@ SdrPageObj::SdrPageObj(SdrPage* pNewPage)
}
}
-SdrPageObj::SdrPageObj(const tools::Rectangle& rRect, SdrPage* pNewPage)
-: mpShownPage(pNewPage)
+SdrPageObj::SdrPageObj(
+ SdrModel& rSdrModel,
+ const tools::Rectangle& rRect,
+ SdrPage* pNewPage)
+: SdrObject(rSdrModel),
+ mpShownPage(pNewPage)
{
if(mpShownPage)
{
@@ -144,9 +150,9 @@ void SdrPageObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
rInfo.bCanConvToPolyLineToArea=false;
}
-SdrPageObj* SdrPageObj::Clone() const
+SdrPageObj* SdrPageObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrPageObj >();
+ return CloneHelper< SdrPageObj >(pTargetModel);
}
SdrPageObj& SdrPageObj::operator=(const SdrPageObj& rObj)
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index 5cf8dd58c115..fc991ab478c3 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -941,27 +941,27 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
{
aStr += SdrModel::GetAngleString(std::abs(pU->nCircRelAngle))
+ " r="
- + mrSdrPathObject.GetModel()->GetMetricString(pU->nCircRadius, true);
+ + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(pU->nCircRadius, true);
}
aStr += "dx="
- + mrSdrPathObject.GetModel()->GetMetricString(aNow.X(), true)
+ + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(aNow.X(), true)
+ " dy="
- + mrSdrPathObject.GetModel()->GetMetricString(aNow.Y(), true);
+ + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(aNow.Y(), true);
if(!IsFreeHand(meObjectKind))
{
sal_Int32 nLen(GetLen(aNow));
sal_Int32 nAngle(GetAngle(aNow));
aStr += " l="
- + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+ + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(nLen, true)
+ " "
+ SdrModel::GetAngleString(nAngle);
}
aStr += ")";
}
- else if(!mrSdrPathObject.GetModel() || !pHdl)
+ else if(!pHdl)
{
// #i103058# fallback when no model and/or Handle, both needed
// for else-path
@@ -1011,9 +1011,9 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
aStr.clear();
aStr += "dx="
- + mrSdrPathObject.GetModel()->GetMetricString(aNow.X() - aBeg.X(), true)
+ + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(aNow.X() - aBeg.X(), true)
+ " dy="
- + mrSdrPathObject.GetModel()->GetMetricString(aNow.Y() - aBeg.Y(), true);
+ + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(aNow.Y() - aBeg.Y(), true);
if(!pDragData->IsMultiPointDrag())
{
@@ -1040,7 +1040,7 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
sal_Int32 nLen(GetLen(aNow));
sal_Int32 nAngle(GetAngle(aNow));
aStr += " l="
- + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+ + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(nLen, true)
+ " "
+ SdrModel::GetAngleString(nAngle);
}
@@ -1083,7 +1083,7 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
sal_Int32 nLen(GetLen(aPt));
sal_Int32 nAngle(GetAngle(aPt));
aStr += " l="
- + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+ + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(nLen, true)
+ " "
+ SdrModel::GetAngleString(nAngle);
}
@@ -1101,7 +1101,7 @@ OUString ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag
sal_Int32 nLen(GetLen(aPt));
sal_Int32 nAngle(GetAngle(aPt));
aStr += "l="
- + mrSdrPathObject.GetModel()->GetMetricString(nLen, true)
+ + mrSdrPathObject.getSdrModelFromSdrObject().GetMetricString(nLen, true)
+ " "
+ SdrModel::GetAngleString(nAngle);
}
@@ -1628,14 +1628,21 @@ sdr::contact::ViewContact* SdrPathObj::CreateObjectSpecificViewContact()
}
-SdrPathObj::SdrPathObj(SdrObjKind eNewKind)
-: meKind(eNewKind)
+SdrPathObj::SdrPathObj(
+ SdrModel& rSdrModel,
+ SdrObjKind eNewKind)
+: SdrTextObj(rSdrModel),
+ meKind(eNewKind)
{
bClosedObj = IsClosed();
}
-SdrPathObj::SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly)
-: maPathPolygon(rPathPoly),
+SdrPathObj::SdrPathObj(
+ SdrModel& rSdrModel,
+ SdrObjKind eNewKind,
+ const basegfx::B2DPolyPolygon& rPathPoly)
+: SdrTextObj(rSdrModel),
+ maPathPolygon(rPathPoly),
meKind(eNewKind)
{
bClosedObj = IsClosed();
@@ -1821,9 +1828,9 @@ sal_uInt16 SdrPathObj::GetObjIdentifier() const
return sal_uInt16(meKind);
}
-SdrPathObj* SdrPathObj::Clone() const
+SdrPathObj* SdrPathObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrPathObj >();
+ return CloneHelper< SdrPathObj >(pTargetModel);
}
SdrPathObj& SdrPathObj::operator=(const SdrPathObj& rObj)
@@ -2879,7 +2886,7 @@ bool SdrPathObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DP
}
// position maybe relative to anchorpos, convert
- if( pModel && pModel->IsWriter() )
+ if( getSdrModelFromSdrObject().IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -2988,7 +2995,7 @@ void SdrPathObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b
}
}
- if( pModel && pModel->IsWriter() )
+ if( getSdrModelFromSdrObject().IsWriter() )
{
// if anchor is used, make position relative to it
if(GetAnchorPos().X() || GetAnchorPos().Y())
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
index 7f85da4b71a8..e68b38ce3205 100644
--- a/svx/source/svdraw/svdorect.cxx
+++ b/svx/source/svdraw/svdorect.cxx
@@ -62,21 +62,26 @@ sdr::contact::ViewContact* SdrRectObj::CreateObjectSpecificViewContact()
}
-SdrRectObj::SdrRectObj()
-: mpXPoly(nullptr)
+SdrRectObj::SdrRectObj(SdrModel& rSdrModel)
+: SdrTextObj(rSdrModel),
+ mpXPoly(nullptr)
{
bClosedObj=true;
}
-SdrRectObj::SdrRectObj(const tools::Rectangle& rRect)
-: SdrTextObj(rRect),
+SdrRectObj::SdrRectObj(
+ SdrModel& rSdrModel,
+ const tools::Rectangle& rRect)
+: SdrTextObj(rSdrModel, rRect),
mpXPoly(nullptr)
{
bClosedObj=true;
}
-SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind)
-: SdrTextObj(eNewTextKind),
+SdrRectObj::SdrRectObj(
+ SdrModel& rSdrModel,
+ SdrObjKind eNewTextKind)
+: SdrTextObj(rSdrModel, eNewTextKind),
mpXPoly(nullptr)
{
DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT ||
@@ -85,8 +90,11 @@ SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind)
bClosedObj=true;
}
-SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind, const tools::Rectangle& rRect)
-: SdrTextObj(eNewTextKind,rRect),
+SdrRectObj::SdrRectObj(
+ SdrModel& rSdrModel,
+ SdrObjKind eNewTextKind,
+ const tools::Rectangle& rRect)
+: SdrTextObj(rSdrModel, eNewTextKind, rRect),
mpXPoly(nullptr)
{
DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT ||
@@ -99,21 +107,6 @@ SdrRectObj::~SdrRectObj()
{
}
-SdrRectObj& SdrRectObj::operator=(const SdrRectObj& rCopy)
-{
- if ( this == &rCopy )
- return *this;
-
- SdrTextObj::operator=( rCopy );
-
- if ( rCopy.mpXPoly )
- mpXPoly.reset( new XPolygon( *rCopy.mpXPoly ) );
- else
- mpXPoly.reset();
-
- return *this;
-}
-
void SdrRectObj::SetXPolyDirty()
{
mpXPoly.reset();
@@ -266,9 +259,24 @@ OUString SdrRectObj::TakeObjNamePlural() const
return ImpGetResStr(pResId);
}
-SdrRectObj* SdrRectObj::Clone() const
+SdrRectObj* SdrRectObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrRectObj >();
+ return CloneHelper< SdrRectObj >(pTargetModel);
+}
+
+SdrRectObj& SdrRectObj::operator=(const SdrRectObj& rCopy)
+{
+ if ( this == &rCopy )
+ return *this;
+
+ SdrTextObj::operator=( rCopy );
+
+ if ( rCopy.mpXPoly )
+ mpXPoly.reset( new XPolygon( *rCopy.mpXPoly ) );
+ else
+ mpXPoly.reset();
+
+ return *this;
}
basegfx::B2DPolyPolygon SdrRectObj::TakeXorPoly() const
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index cf4448fac249..63ca33f850fc 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -64,25 +64,20 @@
using namespace com::sun::star;
-
// BaseProperties section
-
sdr::properties::BaseProperties* SdrTextObj::CreateObjectSpecificProperties()
{
return new sdr::properties::TextProperties(*this);
}
-
// DrawContact section
-
sdr::contact::ViewContact* SdrTextObj::CreateObjectSpecificViewContact()
{
return new sdr::contact::ViewContactOfTextObj(*this);
}
-
-SdrTextObj::SdrTextObj()
-: SdrAttrObj(),
+SdrTextObj::SdrTextObj(SdrModel& rSdrModel)
+: SdrAttrObj(rSdrModel),
mpText(nullptr),
pEdtOutl(nullptr),
eTextKind(OBJ_TEXT)
@@ -102,8 +97,10 @@ SdrTextObj::SdrTextObj()
mbInDownScale = false;
}
-SdrTextObj::SdrTextObj(const tools::Rectangle& rNewRect)
-: SdrAttrObj(),
+SdrTextObj::SdrTextObj(
+ SdrModel& rSdrModel,
+ const tools::Rectangle& rNewRect)
+: SdrAttrObj(rSdrModel),
maRect(rNewRect),
mpText(nullptr),
pEdtOutl(nullptr),
@@ -125,8 +122,10 @@ SdrTextObj::SdrTextObj(const tools::Rectangle& rNewRect)
mbSupportTextIndentingOnLineWidthChange = true;
}
-SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind)
-: SdrAttrObj(),
+SdrTextObj::SdrTextObj(
+ SdrModel& rSdrModel,
+ SdrObjKind eNewTextKind)
+: SdrAttrObj(rSdrModel),
mpText(nullptr),
pEdtOutl(nullptr),
eTextKind(eNewTextKind)
@@ -146,8 +145,11 @@ SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind)
mbSupportTextIndentingOnLineWidthChange = true;
}
-SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const tools::Rectangle& rNewRect)
-: SdrAttrObj(),
+SdrTextObj::SdrTextObj(
+ SdrModel& rSdrModel,
+ SdrObjKind eNewTextKind,
+ const tools::Rectangle& rNewRect)
+: SdrAttrObj(rSdrModel),
maRect(rNewRect),
mpText(nullptr),
pEdtOutl(nullptr),
@@ -171,25 +173,19 @@ SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const tools::Rectangle& rNewRect
SdrTextObj::~SdrTextObj()
{
- if( pModel )
- {
- SdrOutliner& rOutl = pModel->GetHitTestOutliner();
- if( rOutl.GetTextObj() == this )
- rOutl.SetTextObj( nullptr );
- }
-
+ SdrOutliner& rOutl(getSdrModelFromSdrObject().GetHitTestOutliner());
+ if( rOutl.GetTextObj() == this )
+ rOutl.SetTextObj( nullptr );
mpText.reset();
-
ImpDeregisterLink();
}
void SdrTextObj::FitFrameToTextSize()
{
- DBG_ASSERT(pModel!=nullptr,"SdrTextObj::FitFrameToTextSize(): pModel=NULL!");
ImpJustifyRect(maRect);
SdrText* pText = getActiveText();
- if( pText==nullptr || !pText->GetOutlinerParaObject() || pModel==nullptr)
+ if(pText==nullptr || !pText->GetOutlinerParaObject())
return;
SdrOutliner& rOutliner=ImpGetDrawOutliner();
@@ -478,39 +474,6 @@ void SdrTextObj::SetPage(SdrPage* pNewPage)
}
}
-void SdrTextObj::SetModel(SdrModel* pNewModel)
-{
- SdrModel* pOldModel=pModel;
- bool bLinked=IsLinkedText();
- bool bChg=pNewModel!=pModel;
-
- if (bLinked && bChg)
- {
- ImpDeregisterLink();
- }
-
- SdrAttrObj::SetModel(pNewModel);
-
- if( bChg )
- {
- if( pNewModel != nullptr && pOldModel != nullptr )
- SetTextSizeDirty();
-
- sal_Int32 nCount = getTextCount();
- for( sal_Int32 nText = 0; nText < nCount; nText++ )
- {
- SdrText* pText = getText( nText );
- if( pText )
- pText->SetModel( pNewModel );
- }
- }
-
- if (bLinked && bChg)
- {
- ImpRegisterLink();
- }
-}
-
void SdrTextObj::NbcSetEckenradius(long nRad)
{
SetObjectItem(makeSdrEckenradiusItem(nRad));
@@ -524,7 +487,7 @@ void SdrTextObj::AdaptTextMinSize()
// Only do this for text frame.
return;
- if (pModel && pModel->IsPasteResize())
+ if (getSdrModelFromSdrObject().IsPasteResize())
// Don't do this during paste resize.
return;
@@ -754,11 +717,9 @@ void SdrTextObj::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRe
if (pPara)
{
- bool bHitTest = false;
- if( pModel )
- bHitTest = &pModel->GetHitTestOutliner() == &rOutliner;
-
+ const bool bHitTest(&getSdrModelFromSdrObject().GetHitTestOutliner() == &rOutliner);
const SdrTextObj* pTestObj = rOutliner.GetTextObj();
+
if( !pTestObj || !bHitTest || pTestObj != this ||
pTestObj->GetOutlinerParaObject() != pOutlinerParaObject )
{
@@ -1049,9 +1010,9 @@ OUString SdrTextObj::TakeObjNamePlural() const
return sName;
}
-SdrTextObj* SdrTextObj::Clone() const
+SdrTextObj* SdrTextObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrTextObj >();
+ return CloneHelper< SdrTextObj >(pTargetModel);
}
SdrTextObj& SdrTextObj::operator=(const SdrTextObj& rObj)
@@ -1111,7 +1072,7 @@ basegfx::B2DPolyPolygon SdrTextObj::TakeContour() const
basegfx::B2DPolyPolygon aRetval(SdrAttrObj::TakeContour());
// and now add the BoundRect of the text, if necessary
- if ( pModel && GetOutlinerParaObject() && !IsFontwork() && !IsContourTextFrame() )
+ if ( GetOutlinerParaObject() && !IsFontwork() && !IsContourTextFrame() )
{
// using Clone()-Paint() strategy inside TakeContour() leaves a destroyed
// SdrObject as pointer in DrawOutliner. Set *this again in fetching the outliner
@@ -1213,7 +1174,7 @@ void SdrTextObj::ImpInitDrawOutliner( SdrOutliner& rOutl ) const
SdrOutliner& SdrTextObj::ImpGetDrawOutliner() const
{
- SdrOutliner& rOutl=pModel->GetDrawOutliner(this);
+ SdrOutliner& rOutl(getSdrModelFromSdrObject().GetDrawOutliner(this));
// Code extracted to ImpInitDrawOutliner()
ImpInitDrawOutliner( rOutl );
@@ -1261,7 +1222,7 @@ void SdrTextObj::ImpSetupDrawOutlinerForPaint( bool bContourFrame,
double SdrTextObj::GetFontScaleY() const
{
SdrText* pText = getActiveText();
- if (pText == nullptr || !pText->GetOutlinerParaObject() || pModel == nullptr)
+ if (pText == nullptr || !pText->GetOutlinerParaObject())
return 1.0;
SdrOutliner& rOutliner = ImpGetDrawOutliner();
@@ -1403,17 +1364,21 @@ void SdrTextObj::UpdateOutlinerFormatting( SdrOutliner& rOutl, tools::Rectangle&
tools::Rectangle aAnchorRect;
Fraction aFitXCorrection(1,1);
- bool bContourFrame=IsContourTextFrame();
-
- if( GetModel() )
- {
- MapMode aMapMode(GetModel()->GetScaleUnit(), Point(0,0),
- GetModel()->GetScaleFraction(),
- GetModel()->GetScaleFraction());
- rOutl.SetRefMapMode(aMapMode);
- }
+ const bool bContourFrame(IsContourTextFrame());
+ const MapMode aMapMode(
+ getSdrModelFromSdrObject().GetScaleUnit(),
+ Point(0,0),
+ getSdrModelFromSdrObject().GetScaleFraction(),
+ getSdrModelFromSdrObject().GetScaleFraction());
- ImpSetupDrawOutlinerForPaint( bContourFrame, rOutl, aTextRect, aAnchorRect, rPaintRect, aFitXCorrection );
+ rOutl.SetRefMapMode(aMapMode);
+ ImpSetupDrawOutlinerForPaint(
+ bContourFrame,
+ rOutl,
+ aTextRect,
+ aAnchorRect,
+ rPaintRect,
+ aFitXCorrection);
}
@@ -1561,7 +1526,7 @@ TextChain *SdrTextObj::GetTextChain() const
//if (!IsChainable())
// return NULL;
- return pModel->GetTextChain();
+ return getSdrModelFromSdrObject().GetTextChain();
}
bool SdrTextObj::IsVerticalWriting() const
@@ -1670,7 +1635,7 @@ bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DP
basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
// position maybe relative to anchorpos, convert
- if( pModel && pModel->IsWriter() )
+ if( getSdrModelFromSdrObject().IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
@@ -1769,7 +1734,7 @@ void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b
}
// if anchor is used, make position relative to it
- if( pModel && pModel->IsWriter() )
+ if( getSdrModelFromSdrObject().IsWriter() )
{
if(GetAnchorPos().X() || GetAnchorPos().Y())
{
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
index af6977fc3cbe..b50736972d35 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -973,8 +973,9 @@ void SdrTextObj::impDecomposeBlockTextPrimitive(
// Usual processing - always grow in one of directions
bool bAllowGrowVertical = !bVerticalWriting;
bool bAllowGrowHorizontal = bVerticalWriting;
+
// Compatibility mode for tdf#99729
- if (pModel->IsAnchoredTextOverflowLegacy())
+ if (getSdrModelFromSdrObject().IsAnchoredTextOverflowLegacy())
{
bAllowGrowVertical = bHorizontalIsBlock;
bAllowGrowHorizontal = bVerticalIsBlock;
@@ -1466,7 +1467,7 @@ void SdrTextObj::impHandleChainingEventsDuringDecomposition(SdrOutliner &rOutlin
if (bIsOverflow && !IsInEditMode()) {
// Initialize Chaining Outliner
- SdrOutliner &rChainingOutl = pModel->GetChainingOutliner(this);
+ SdrOutliner &rChainingOutl(getSdrModelFromSdrObject().GetChainingOutliner(this));
ImpInitDrawOutliner( rChainingOutl );
rChainingOutl.SetUpdateMode(true);
// We must pass the chaining outliner otherwise we would mess up decomposition
diff --git a/svx/source/svdraw/svdotxat.cxx b/svx/source/svdraw/svdotxat.cxx
index f4c9528d4125..e88e55519930 100644
--- a/svx/source/svdraw/svdotxat.cxx
+++ b/svx/source/svdraw/svdotxat.cxx
@@ -62,10 +62,6 @@ bool SdrTextObj::AdjustTextFrameWidthAndHeight( tools::Rectangle& rR, bool bHgt,
// Not a text frame. Bail out.
return false;
- if (!pModel)
- // Model doesn't exist. Bail out.
- return false;
-
if (rR.IsEmpty())
// Empty rectangle.
return false;
@@ -95,7 +91,7 @@ bool SdrTextObj::AdjustTextFrameWidthAndHeight( tools::Rectangle& rR, bool bHgt,
aNewSize.AdjustWidth( -1 ); aNewSize.AdjustHeight( -1 );
Size aMaxSiz(100000, 100000);
- Size aTmpSiz = pModel->GetMaxObjSize();
+ Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
if (aTmpSiz.Width())
aMaxSiz.setWidth( aTmpSiz.Width() );
@@ -312,7 +308,7 @@ bool SdrTextObj::AdjustTextFrameWidthAndHeight()
void SdrTextObj::ImpSetTextStyleSheetListeners()
{
- SfxStyleSheetBasePool* pStylePool=pModel!=nullptr ? pModel->GetStyleSheetPool() : nullptr;
+ SfxStyleSheetBasePool* pStylePool(getSdrModelFromSdrObject().GetStyleSheetPool());
if (pStylePool!=nullptr)
{
std::vector<OUString> aStyleNames;
diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx
index 3290435144b1..bb3e60d9291b 100644
--- a/svx/source/svdraw/svdotxed.cxx
+++ b/svx/source/svdraw/svdotxed.cxx
@@ -49,7 +49,7 @@ bool SdrTextObj::BegTextEdit(SdrOutliner& rOutl)
if ( !IsOutlText() )
nOutlinerMode = OutlinerMode::TextObject;
rOutl.Init( nOutlinerMode );
- rOutl.SetRefDevice( pModel->GetRefDevice() );
+ rOutl.SetRefDevice(getSdrModelFromSdrObject().GetRefDevice());
bool bFitToSize(IsFitToSize());
bool bContourFrame=IsContourTextFrame();
@@ -146,11 +146,9 @@ void SdrTextObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, tools::Recta
Size aAnkSiz(aViewInit.GetSize());
aAnkSiz.AdjustWidth( -1 ); aAnkSiz.AdjustHeight( -1 ); // because GetSize() adds 1
Size aMaxSiz(1000000,1000000);
- if (pModel!=nullptr) {
- Size aTmpSiz(pModel->GetMaxObjSize());
- if (aTmpSiz.Width()!=0) aMaxSiz.setWidth(aTmpSiz.Width() );
- if (aTmpSiz.Height()!=0) aMaxSiz.setHeight(aTmpSiz.Height() );
- }
+ Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
+ if (aTmpSiz.Width()!=0) aMaxSiz.setWidth(aTmpSiz.Width() );
+ if (aTmpSiz.Height()!=0) aMaxSiz.setHeight(aTmpSiz.Height() );
// Done earlier since used in else tree below
SdrTextHorzAdjust eHAdj(GetTextHorizontalAdjust());
diff --git a/svx/source/svdraw/svdotxln.cxx b/svx/source/svdraw/svdotxln.cxx
index 75964d95d60b..27d4b9679da8 100644
--- a/svx/source/svdraw/svdotxln.cxx
+++ b/svx/source/svdraw/svdotxln.cxx
@@ -67,8 +67,9 @@ void ImpSdrObjTextLink::Closed()
const OUString& /*rMimeType*/, const css::uno::Any & /*rValue */)
{
bool bForceReload = false;
- SdrModel* pModel = pSdrObj ? pSdrObj->GetModel() : nullptr;
- sfx2::LinkManager* pLinkManager= pModel ? pModel->GetLinkManager() : nullptr;
+ SdrModel* pModel(pSdrObj ? &pSdrObj->getSdrModelFromSdrObject() : nullptr);
+ sfx2::LinkManager* pLinkManager(pModel ? pModel->GetLinkManager() : nullptr);
+
if( pLinkManager )
{
ImpSdrObjTextLinkUserData* pData=pSdrObj->GetLinkUserData();
@@ -254,7 +255,7 @@ ImpSdrObjTextLinkUserData* SdrTextObj::GetLinkUserData() const
void SdrTextObj::ImpRegisterLink()
{
ImpSdrObjTextLinkUserData* pData=GetLinkUserData();
- sfx2::LinkManager* pLinkManager=pModel!=nullptr ? pModel->GetLinkManager() : nullptr;
+ sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
if (pLinkManager!=nullptr && pData!=nullptr && pData->pLink==nullptr) { // don't register twice
pData->pLink = new ImpSdrObjTextLink(this);
pLinkManager->InsertFileLink(*pData->pLink,OBJECT_CLIENT_FILE,pData->aFileName,
@@ -266,7 +267,7 @@ void SdrTextObj::ImpRegisterLink()
void SdrTextObj::ImpDeregisterLink()
{
ImpSdrObjTextLinkUserData* pData=GetLinkUserData();
- sfx2::LinkManager* pLinkManager=pModel!=nullptr ? pModel->GetLinkManager() : nullptr;
+ sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
if (pLinkManager!=nullptr && pData!=nullptr && pData->pLink!=nullptr) { // don't register twice
// when doing Remove, *pLink is deleted implicitly
pLinkManager->Remove( pData->pLink.get() );
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 40eca1077e38..1a6d4a50a358 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -175,7 +175,7 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract
AdaptTextMinSize();
- if(bTextFrame && (!pModel || !pModel->IsPasteResize()))
+ if(bTextFrame && !getSdrModelFromSdrObject().IsPasteResize())
{
NbcAdjustTextFrameWidthAndHeight();
}
@@ -313,7 +313,7 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
if(nResultCount)
{
// prepare own target
- SdrObjGroup* pGroup = new SdrObjGroup();
+ SdrObjGroup* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
SdrObjList* pObjectList = pGroup->GetSubList();
// process results
@@ -355,7 +355,10 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
aAttributeSet.Put(XFillStyleItem(drawing::FillStyle_SOLID));
// create filled SdrPathObj
- pPathObj = new SdrPathObj(OBJ_PATHFILL, aPolyPolygon);
+ pPathObj = new SdrPathObj(
+ getSdrModelFromSdrObject(),
+ OBJ_PATHFILL,
+ aPolyPolygon);
}
else
{
@@ -366,18 +369,16 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
aAttributeSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
// create line SdrPathObj
- pPathObj = new SdrPathObj(OBJ_PATHLINE, aPolyPolygon);
+ pPathObj = new SdrPathObj(
+ getSdrModelFromSdrObject(),
+ OBJ_PATHLINE,
+ aPolyPolygon);
}
// copy basic information from original
pPathObj->ImpSetAnchorPos(GetAnchorPos());
pPathObj->NbcSetLayer(GetLayer());
-
- if(GetModel())
- {
- pPathObj->SetModel(GetModel());
- pPathObj->NbcSetStyleSheet(GetStyleSheet(), true);
- }
+ pPathObj->NbcSetStyleSheet(GetStyleSheet(), true);
// apply prepared ItemSet and add to target
pPathObj->SetMergedItemSet(aAttributeSet);
@@ -433,7 +434,10 @@ SdrObject* SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPol
ePathKind = bClosed ? OBJ_POLY : OBJ_PLIN;
}
- SdrPathObj* pPathObj = new SdrPathObj(ePathKind, aB2DPolyPolygon);
+ SdrPathObj* pPathObj = new SdrPathObj(
+ getSdrModelFromSdrObject(),
+ ePathKind,
+ aB2DPolyPolygon);
if(bBezier)
{
@@ -443,18 +447,11 @@ SdrObject* SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPol
pPathObj->ImpSetAnchorPos(aAnchor);
pPathObj->NbcSetLayer(GetLayer());
-
- if(pModel)
- {
- pPathObj->SetModel(pModel);
-
- sdr::properties::ItemChangeBroadcaster aC(*pPathObj);
-
- pPathObj->ClearMergedItem();
- pPathObj->SetMergedItemSet(GetObjectItemSet());
- pPathObj->GetProperties().BroadcastItemChange(aC);
- pPathObj->NbcSetStyleSheet(GetStyleSheet(), true);
- }
+ sdr::properties::ItemChangeBroadcaster aC(*pPathObj);
+ pPathObj->ClearMergedItem();
+ pPathObj->SetMergedItemSet(GetObjectItemSet());
+ pPathObj->GetProperties().BroadcastItemChange(aC);
+ pPathObj->NbcSetStyleSheet(GetStyleSheet(), true);
return pPathObj;
}
@@ -489,7 +486,7 @@ SdrObject* SdrTextObj::ImpConvertAddText(SdrObject* pObj, bool bBezier) const
else
{
// not yet a group, create one and add partial and new shapes
- SdrObjGroup* pGrp=new SdrObjGroup;
+ SdrObjGroup* pGrp=new SdrObjGroup(getSdrModelFromSdrObject());
SdrObjList* pOL=pGrp->GetSubList();
pOL->InsertObject(pObj);
pOL->InsertObject(pText);
diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx
index 6e364c33ade1..4a0e071ca8b9 100644
--- a/svx/source/svdraw/svdouno.cxx
+++ b/svx/source/svdraw/svdouno.cxx
@@ -145,9 +145,11 @@ namespace
}
}
-
-SdrUnoObj::SdrUnoObj(const OUString& rModelName)
-: m_pImpl( new SdrUnoObjDataHolder )
+SdrUnoObj::SdrUnoObj(
+ SdrModel& rSdrModel,
+ const OUString& rModelName)
+: SdrRectObj(rSdrModel),
+ m_pImpl( new SdrUnoObjDataHolder )
{
bIsUnoObj = true;
@@ -158,9 +160,12 @@ SdrUnoObj::SdrUnoObj(const OUString& rModelName)
CreateUnoControlModel(rModelName);
}
-SdrUnoObj::SdrUnoObj(const OUString& rModelName,
- const uno::Reference< lang::XMultiServiceFactory >& rxSFac)
-: m_pImpl( new SdrUnoObjDataHolder )
+SdrUnoObj::SdrUnoObj(
+ SdrModel& rSdrModel,
+ const OUString& rModelName,
+ const uno::Reference< lang::XMultiServiceFactory >& rxSFac)
+: SdrRectObj(rSdrModel),
+ m_pImpl( new SdrUnoObjDataHolder )
{
bIsUnoObj = true;
@@ -250,9 +255,9 @@ OUString SdrUnoObj::TakeObjNamePlural() const
return ImpGetResStr(STR_ObjNamePluralUno);
}
-SdrUnoObj* SdrUnoObj::Clone() const
+SdrUnoObj* SdrUnoObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrUnoObj >();
+ return CloneHelper< SdrUnoObj >(pTargetModel);
}
SdrUnoObj& SdrUnoObj::operator= (const SdrUnoObj& rObj)
@@ -328,38 +333,6 @@ bool SdrUnoObj::hasSpecialDrag() const
return false;
}
-bool SdrUnoObj::supportsFullDrag() const
-{
- // override to have the possibility to enable/disable in debug and
- // to check some things out. Current solution is working, so default is
- // enabled
- static bool bDoSupportFullDrag(true);
-
- return bDoSupportFullDrag;
-}
-
-SdrObject* SdrUnoObj::getFullDragClone() const
-{
- SdrObject* pRetval = nullptr;
- static bool bHandleSpecial(false);
-
- if(bHandleSpecial)
- {
- // special handling for SdrUnoObj (FormControl). Create a SdrGrafObj
- // for drag containing the graphical representation. This does not work too
- // well, so the default is to simply clone
- pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), this), GetLogicRect());
- }
- else
- {
- // call parent (simply clone)
- pRetval = SdrRectObj::getFullDragClone();
- }
-
- return pRetval;
-}
-
-
void SdrUnoObj::NbcSetLayer( SdrLayerID _nLayer )
{
if ( GetLayer() == _nLayer )
diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx
index 2ffcdc313473..4306ecd577fa 100644
--- a/svx/source/svdraw/svdovirt.cxx
+++ b/svx/source/svdraw/svdovirt.cxx
@@ -42,8 +42,10 @@ sdr::contact::ViewContact* SdrVirtObj::CreateObjectSpecificViewContact()
return new sdr::contact::ViewContactOfVirtObj(*this);
}
-
-SdrVirtObj::SdrVirtObj(SdrObject& rNewObj):
+SdrVirtObj::SdrVirtObj(
+ SdrModel& rSdrModel,
+ SdrObject& rNewObj)
+: SdrObject(rSdrModel),
rRefObj(rNewObj)
{
bVirtObj=true; // this is only a virtual object
@@ -56,7 +58,6 @@ SdrVirtObj::~SdrVirtObj()
rRefObj.DelReference(*this);
}
-
const SdrObject& SdrVirtObj::GetReferencedObj() const
{
return rRefObj;
@@ -81,13 +82,6 @@ void SdrVirtObj::NbcSetAnchorPos(const Point& rAnchorPos)
aAnchor=rAnchorPos;
}
-
-void SdrVirtObj::SetModel(SdrModel* pNewModel)
-{
- SdrObject::SetModel(pNewModel);
- rRefObj.SetModel(pNewModel);
-}
-
void SdrVirtObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
{
rRefObj.TakeObjInfo(rInfo);
@@ -128,15 +122,29 @@ void SdrVirtObj::RecalcBoundRect()
aOutRect+=aAnchor;
}
-SdrVirtObj* SdrVirtObj::Clone() const
+SdrVirtObj* SdrVirtObj::Clone(SdrModel* pTargetModel) const
{
- return new SdrVirtObj(rRefObj); // only a further reference
+ return CloneHelper< SdrVirtObj >(pTargetModel);
+ // TTTT not sure if the above works - how could SdrObjFactory::MakeNewObject
+ // create an object wit correct rRefObj (?) OTOH VirtObj probably needs not
+ // to be cloned ever - only used in Writer for multiple instances e.g. Header/Footer
+ // return new SdrVirtObj(
+ // getSdrModelFromSdrObject(),
+ // rRefObj); // only a further reference
}
SdrVirtObj& SdrVirtObj::operator=(const SdrVirtObj& rObj)
-{ // reference different object??
+{
SdrObject::operator=(rObj);
- aAnchor=rObj.aAnchor;
+
+ // reference different object?? TTTT -> yes!
+ rRefObj.DelReference(*this);
+ rRefObj = rObj.rRefObj;
+ rRefObj.AddReference(*this);
+
+ aSnapRect = rObj.aSnapRect;
+ aAnchor = rObj.aAnchor;
+
return *this;
}
@@ -266,24 +274,11 @@ bool SdrVirtObj::supportsFullDrag() const
SdrObject* SdrVirtObj::getFullDragClone() const
{
- static bool bSpecialHandling(false);
- SdrObject* pRetval = nullptr;
-
- if(bSpecialHandling)
- {
- // special handling for VirtObj. Do not create another
- // reference to rRefObj, this would allow to change that
- // one on drag. Instead, create a SdrGrafObj for drag containing
- // the graphical representation
- pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), this), GetLogicRect());
- }
- else
- {
- SdrObject& rReferencedObject = const_cast<SdrVirtObj*>(this)->ReferencedObj();
- pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), &rReferencedObject), GetLogicRect());
- }
-
- return pRetval;
+ SdrObject& rReferencedObject = const_cast<SdrVirtObj*>(this)->ReferencedObj();
+ return new SdrGrafObj(
+ getSdrModelFromSdrObject(),
+ SdrDragView::GetObjGraphic(rReferencedObject),
+ GetLogicRect());
}
bool SdrVirtObj::beginSpecialDrag(SdrDragStat& rDrag) const
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 7ff4129691ff..2dff0a900148 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -70,13 +70,12 @@ public:
static const sal_Int32 InitialObjectContainerCapacity (64);
-SdrObjList::SdrObjList(SdrModel* pNewModel, SdrPage* pNewPage):
- maList(),
+SdrObjList::SdrObjList(SdrPage* pNewPage)
+: maList(),
mxNavigationOrder(),
mbIsNavigationOrderDirty(false)
{
maList.reserve(InitialObjectContainerCapacity);
- pModel=pNewModel;
pPage=pNewPage;
pUpList=nullptr;
bObjOrdNumsDirty=false;
@@ -85,58 +84,46 @@ SdrObjList::SdrObjList(SdrModel* pNewModel, SdrPage* pNewPage):
eListKind=SdrObjListKind::Unknown;
}
-SdrObjList::SdrObjList():
- maList(),
- mxNavigationOrder(),
- mbIsNavigationOrderDirty(false)
+SdrObjList::~SdrObjList()
{
- maList.reserve(InitialObjectContainerCapacity);
- pModel=nullptr;
- pPage=nullptr;
- pUpList=nullptr;
- bObjOrdNumsDirty=false;
- bRectsDirty=false;
- pOwnerObj=nullptr;
- eListKind=SdrObjListKind::Unknown;
+ Clear(); // delete contents of container
}
-SdrObjList::~SdrObjList()
+SdrObjList* SdrObjList::CloneSdrObjList(SdrModel* pNewModel) const
{
-
- // To avoid that the Clear() method will broadcast changes when in destruction
- // which would call virtual method (not allowed in destructor), the model is set
- // to NULL here.
- pModel = nullptr;
-
- Clear(); // delete contents of container
+ SdrObjList* pObjList = new SdrObjList();
+ pObjList->lateInitSdrObjList(*this, pNewModel);
+ return pObjList;
}
-void SdrObjList::lateInit(const SdrObjList& rSrcList)
+void SdrObjList::lateInitSdrObjList(const SdrObjList& rSrcList, SdrModel* pNewModel)
{
// this function is only supposed to be called once, right after construction
assert(maList.empty());
-
eListKind=rSrcList.eListKind;
- CopyObjects(rSrcList);
+ CopyObjects(rSrcList, pNewModel);
}
-void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
+void SdrObjList::CopyObjects(const SdrObjList& rSrcList, SdrModel* pNewModel)
{
Clear();
- bObjOrdNumsDirty=false;
- bRectsDirty =false;
- size_t nCloneErrCnt = 0;
- const size_t nCount = rSrcList.GetObjCount();
- for (size_t no=0; no<nCount; ++no) {
- SdrObject* pSO=rSrcList.GetObj(no);
+ bObjOrdNumsDirty = false;
+ bRectsDirty = false;
+ size_t nCloneErrCnt(0);
+ const size_t nCount(rSrcList.GetObjCount());
- SdrObject* pDO = pSO->Clone();
+ for (size_t no(0); no < nCount; ++no)
+ {
+ SdrObject* pSO(rSrcList.GetObj(no));
+ SdrObject* pDO(pSO->Clone(pNewModel));
- if (pDO!=nullptr) {
- pDO->SetModel(pModel);
+ if(nullptr != pDO)
+ {
pDO->SetPage(pPage);
NbcInsertObject(pDO, SAL_MAX_SIZE);
- } else {
+ }
+ else
+ {
nCloneErrCnt++;
}
}
@@ -209,9 +196,9 @@ void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
void SdrObjList::Clear()
{
- bool bObjectsRemoved(false);
+ SdrModel* pSdrModelFromRemovedSdrObject(nullptr);
- while( ! maList.empty())
+ while(!maList.empty())
{
// remove last object from list
SdrObject* pObj = maList.back();
@@ -221,22 +208,22 @@ void SdrObjList::Clear()
// to delete the object and thus refresh visualisations
pObj->GetViewContact().flushViewObjectContacts();
- bObjectsRemoved = true;
-
- // sent remove hint (after removal, see RemoveObject())
- if(pModel)
+ if(nullptr == pSdrModelFromRemovedSdrObject)
{
- SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj, pPage);
- pModel->Broadcast(aHint);
+ pSdrModelFromRemovedSdrObject = &pObj->getSdrModelFromSdrObject();
}
+ // sent remove hint (after removal, see RemoveObject())
+ SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj, pPage);
+ pObj->getSdrModelFromSdrObject().Broadcast(aHint);
+
// delete the object itself
SdrObject::Free( pObj );
}
- if(pModel && bObjectsRemoved)
+ if(nullptr != pSdrModelFromRemovedSdrObject)
{
- pModel->SetChanged();
+ pSdrModelFromRemovedSdrObject->SetChanged();
}
}
@@ -257,23 +244,6 @@ void SdrObjList::SetPage(SdrPage* pNewPage)
}
}
-SdrModel* SdrObjList::GetModel() const
-{
- return pModel;
-}
-
-void SdrObjList::SetModel(SdrModel* pNewModel)
-{
- if (pModel!=pNewModel) {
- pModel=pNewModel;
- const size_t nCount = GetObjCount();
- for (size_t i=0; i<nCount; ++i) {
- SdrObject* pObj=GetObj(i);
- pObj->SetModel(pModel);
- }
- }
-}
-
void SdrObjList::RecalcObjOrdNums()
{
const size_t nCount = GetObjCount();
@@ -369,18 +339,15 @@ void SdrObjList::InsertObject(SdrObject* pObj, size_t nPos)
pOwnerObj->ActionChanged();
}
- if(pModel)
+ // TODO: We need a different broadcast here!
+ // Repaint from object number ... (heads-up: GroupObj)
+ if(pObj->GetPage())
{
- // TODO: We need a different broadcast here!
- // Repaint from object number ... (heads-up: GroupObj)
- if(pObj->GetPage())
- {
- SdrHint aHint(SdrHintKind::ObjectInserted, *pObj);
- pModel->Broadcast(aHint);
- }
-
- pModel->SetChanged();
+ SdrHint aHint(SdrHintKind::ObjectInserted, *pObj);
+ pObj->getSdrModelFromSdrObject().Broadcast(aHint);
}
+
+ pObj->getSdrModelFromSdrObject().SetChanged();
}
}
@@ -432,16 +399,17 @@ SdrObject* SdrObjList::RemoveObject(size_t nObjNum)
{
// flushViewObjectContacts() clears the VOC's and those invalidate
pObj->GetViewContact().flushViewObjectContacts();
-
DBG_ASSERT(pObj->IsInserted(),"The object does not have the status Inserted.");
- if (pModel!=nullptr) {
- // TODO: We need a different broadcast here.
- if (pObj->GetPage()!=nullptr) {
- SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj);
- pModel->Broadcast(aHint);
- }
- pModel->SetChanged();
+
+ // TODO: We need a different broadcast here.
+ if (pObj->GetPage()!=nullptr)
+ {
+ SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj);
+ pObj->getSdrModelFromSdrObject().Broadcast(aHint);
}
+
+ pObj->getSdrModelFromSdrObject().SetChanged();
+
pObj->SetInserted(false); // calls, among other things, the UserCall
pObj->SetObjList(nullptr);
pObj->SetPage(nullptr);
@@ -514,13 +482,14 @@ SdrObject* SdrObjList::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
DBG_ASSERT(pObj!=nullptr,"SdrObjList::ReplaceObject: Could not find object to remove.");
if (pObj!=nullptr) {
DBG_ASSERT(pObj->IsInserted(),"SdrObjList::ReplaceObject: the object does not have status Inserted.");
- if (pModel!=nullptr) {
- // TODO: We need a different broadcast here.
- if (pObj->GetPage()!=nullptr) {
- SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj);
- pModel->Broadcast(aHint);
- }
+
+ // TODO: We need a different broadcast here.
+ if (pObj->GetPage()!=nullptr)
+ {
+ SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj);
+ pObj->getSdrModelFromSdrObject().Broadcast(aHint);
}
+
pObj->SetInserted(false);
pObj->SetObjList(nullptr);
pObj->SetPage(nullptr);
@@ -538,14 +507,15 @@ SdrObject* SdrObjList::ReplaceObject(SdrObject* pNewObj, size_t nObjNum)
impChildInserted(*pNewObj);
pNewObj->SetInserted(true);
- if (pModel!=nullptr) {
- // TODO: We need a different broadcast here.
- if (pNewObj->GetPage()!=nullptr) {
- SdrHint aHint(SdrHintKind::ObjectInserted, *pNewObj);
- pModel->Broadcast(aHint);
- }
- pModel->SetChanged();
+
+ // TODO: We need a different broadcast here.
+ if (pNewObj->GetPage()!=nullptr) {
+ SdrHint aHint(SdrHintKind::ObjectInserted, *pNewObj);
+ pNewObj->getSdrModelFromSdrObject().Broadcast(aHint);
}
+
+ pNewObj->getSdrModelFromSdrObject().SetChanged();
+
SetRectsDirty();
}
return pObj;
@@ -574,13 +544,11 @@ SdrObject* SdrObjList::SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum)
pObj->SetOrdNum(nNewObjNum);
bObjOrdNumsDirty=true;
- if (pModel!=nullptr)
- {
- // TODO: We need a different broadcast here.
- if (pObj->GetPage()!=nullptr)
- pModel->Broadcast(SdrHint(SdrHintKind::ObjectChange, *pObj));
- pModel->SetChanged();
- }
+
+ // TODO: We need a different broadcast here.
+ if (pObj->GetPage()!=nullptr)
+ pObj->getSdrModelFromSdrObject().Broadcast(SdrHint(SdrHintKind::ObjectChange, *pObj));
+ pObj->getSdrModelFromSdrObject().SetChanged();
}
return pObj;
}
@@ -781,8 +749,7 @@ void SdrObjList::SetObjectNavigationPosition (
mbIsNavigationOrderDirty = true;
// The navigation order is written out to file so mark the model as modified.
- if (pModel != nullptr)
- pModel->SetChanged();
+ rObject.getSdrModelFromSdrObject().SetChanged();
}
}
@@ -1048,20 +1015,18 @@ void SdrPageProperties::ImpAddStyleSheet(SfxStyleSheet& rNewStyleSheet)
void ImpPageChange(SdrPage& rSdrPage)
{
rSdrPage.ActionChanged();
-
- if(rSdrPage.GetModel())
- {
- rSdrPage.GetModel()->SetChanged();
- SdrHint aHint(SdrHintKind::PageOrderChange, &rSdrPage);
- rSdrPage.GetModel()->Broadcast(aHint);
- }
+ rSdrPage.getSdrModelFromSdrPage().SetChanged();
+ SdrHint aHint(SdrHintKind::PageOrderChange, &rSdrPage);
+ rSdrPage.getSdrModelFromSdrPage().Broadcast(aHint);
}
SdrPageProperties::SdrPageProperties(SdrPage& rSdrPage)
: SfxListener(),
mpSdrPage(&rSdrPage),
mpStyleSheet(nullptr),
- maProperties(mpSdrPage->GetModel()->GetItemPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{})
+ maProperties(
+ mpSdrPage->getSdrModelFromSdrPage().GetItemPool(),
+ svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{})
{
if(!rSdrPage.IsMasterPage())
{
@@ -1136,18 +1101,23 @@ void SdrPageProperties::SetStyleSheet(SfxStyleSheet* pStyleSheet)
}
-SdrPage::SdrPage(SdrModel& rNewModel, bool bMasterPage)
-: SdrObjList(&rNewModel, this),
+SdrPage::SdrPage(SdrModel& rModel, bool bMasterPage)
+: tools::WeakBase(),
+ SdrObjList(this),
+ maPageUsers(),
mpViewContact(nullptr),
+ mrSdrModelFromSdrPage(rModel),
mnWidth(10),
mnHeight(10),
mnBorderLeft(0),
mnBorderUpper(0),
mnBorderRight(0),
mnBorderLower(0),
- mpLayerAdmin(new SdrLayerAdmin(&rNewModel.GetLayerAdmin())),
+ mpLayerAdmin(new SdrLayerAdmin(&rModel.GetLayerAdmin())),
mpSdrPageProperties(nullptr),
+ mxUnoPage(),
mpMasterPageDescriptor(nullptr),
+ aPrefVisiLayers(),
nPageNum(0),
mbMaster(bMasterPage),
mbInserted(false),
@@ -1160,27 +1130,6 @@ SdrPage::SdrPage(SdrModel& rNewModel, bool bMasterPage)
mpSdrPageProperties.reset(new SdrPageProperties(*this));
}
-SdrPage::SdrPage(const SdrPage& rSrcPage)
-: SdrObjList(rSrcPage.pModel, this),
- mpViewContact(nullptr),
- mnWidth(rSrcPage.mnWidth),
- mnHeight(rSrcPage.mnHeight),
- mnBorderLeft(rSrcPage.mnBorderLeft),
- mnBorderUpper(rSrcPage.mnBorderUpper),
- mnBorderRight(rSrcPage.mnBorderRight),
- mnBorderLower(rSrcPage.mnBorderLower),
- mpLayerAdmin(new SdrLayerAdmin(rSrcPage.pModel->GetLayerAdmin())),
- mpSdrPageProperties(nullptr),
- mpMasterPageDescriptor(nullptr),
- nPageNum(rSrcPage.nPageNum),
- mbMaster(rSrcPage.mbMaster),
- mbInserted(false),
- mbObjectsNotPersistent(rSrcPage.mbObjectsNotPersistent),
- mbPageBorderOnlyLeftRight(rSrcPage.mbPageBorderOnlyLeftRight)
-{
- aPrefVisiLayers.SetAll();
-}
-
SdrPage::~SdrPage()
{
if( mxUnoPage.is() ) try
@@ -1218,18 +1167,13 @@ SdrPage::~SdrPage()
mpSdrPageProperties.reset();
}
-void SdrPage::lateInit(const SdrPage& rSrcPage, SdrModel* const pNewModel)
+void SdrPage::lateInit(const SdrPage& rSrcPage)
{
assert(!mpViewContact);
- assert(!mpSdrPageProperties);
+ // SdrPageProperties get set by SdrPage::SdrPage already, so do not assert anymore
+ // assert(!mpSdrPageProperties);
assert(!mxUnoPage.is());
- if (pNewModel && (pNewModel != pModel))
- {
- pModel = pNewModel;
- impl_setModelForLayerAdmin(pNewModel);
- }
-
// copy all the local parameters to make this instance
// a valid copy of source page before copying and inserting
// the contained objects
@@ -1268,24 +1212,18 @@ void SdrPage::lateInit(const SdrPage& rSrcPage, SdrModel* const pNewModel)
}
// Now copy the contained objects
- SdrObjList::lateInit(rSrcPage);
+ SdrObjList::lateInitSdrObjList(rSrcPage, &getSdrModelFromSdrPage());
// be careful and correct eListKind, a member of SdrObjList which
// will be changed by the SdrObjList::lateInit before...
eListKind = (mbMaster) ? SdrObjListKind::MasterPage : SdrObjListKind::DrawPage;
}
-SdrPage* SdrPage::Clone() const
-{
- return Clone(nullptr);
-}
-
SdrPage* SdrPage::Clone(SdrModel* pNewModel) const
{
- if (pNewModel==nullptr) pNewModel=pModel;
- SdrPage* pPage2=new SdrPage(*pNewModel);
- pPage2->lateInit(*this);
- return pPage2;
+ SdrPage* pClonedPage(new SdrPage(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
+ pClonedPage->lateInit(*this);
+ return pClonedPage;
}
void SdrPage::SetSize(const Size& aSiz)
@@ -1435,59 +1373,6 @@ sal_Int32 SdrPage::GetLowerBorder() const
return mnBorderLower;
}
-void SdrPage::impl_setModelForLayerAdmin(SdrModel* const pNewModel)
-{
- if (pNewModel!=nullptr) {
- mpLayerAdmin->SetParent(&pNewModel->GetLayerAdmin());
- } else {
- mpLayerAdmin->SetParent(nullptr);
- }
- mpLayerAdmin->SetModel(pNewModel);
-}
-
-void SdrPage::SetModel(SdrModel* pNewModel)
-{
- SdrModel* pOldModel=pModel;
- SdrObjList::SetModel(pNewModel);
-
- if (pNewModel!=pOldModel)
- {
- impl_setModelForLayerAdmin( pNewModel );
-
- // create new SdrPageProperties with new model (due to SfxItemSet there)
- // and copy ItemSet and StyleSheet
- std::unique_ptr<SdrPageProperties> pNew(new SdrPageProperties(*this));
-
- if(!IsMasterPage())
- {
- const SfxItemSet& rOldSet = getSdrPageProperties().GetItemSet();
- SfxItemSet* pNewSet = rOldSet.Clone(false, &pNewModel->GetItemPool());
- //ensure checkForUniqueItem is called so new pages which have e.g.
- //XFillBitmapItem set, do not conflict with an existing XFillBitmapItem
- //with the same name but different properties
- SdrModel::MigrateItemSet(&rOldSet, pNewSet, pNewModel);
- pNew->PutItemSet(*pNewSet);
- delete pNewSet;
- }
-
- pNew->SetStyleSheet(getSdrPageProperties().GetStyleSheet());
-
- mpSdrPageProperties = std::move(pNew);
- }
-
- // update listeners at possible API wrapper object
- if( pOldModel != pNewModel )
- {
- if( mxUnoPage.is() )
- {
- SvxDrawPage* pPage2 = SvxDrawPage::getImplementation( mxUnoPage );
- if( pPage2 )
- pPage2->ChangeModel( pNewModel );
- }
- }
-}
-
-
// #i68775# React on PageNum changes (from Model in most cases)
void SdrPage::SetPageNum(sal_uInt16 nNew)
{
@@ -1507,11 +1392,11 @@ sal_uInt16 SdrPage::GetPageNum() const
return 0;
if (mbMaster) {
- if (pModel && pModel->IsMPgNumsDirty())
- pModel->RecalcPageNums(true);
+ if (getSdrModelFromSdrPage().IsMPgNumsDirty())
+ getSdrModelFromSdrPage().RecalcPageNums(true);
} else {
- if (pModel && pModel->IsPagNumsDirty())
- pModel->RecalcPageNums(false);
+ if (getSdrModelFromSdrPage().IsPagNumsDirty())
+ getSdrModelFromSdrPage().RecalcPageNums(false);
}
return nPageNum;
}
@@ -1521,11 +1406,7 @@ void SdrPage::SetChanged()
// For test purposes, use the new ViewContact for change
// notification now.
ActionChanged();
-
- if( pModel )
- {
- pModel->SetChanged();
- }
+ getSdrModelFromSdrPage().SetChanged();
}
diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
index da88ec5907f3..ff6349894259 100644
--- a/svx/source/svdraw/svdpagv.cxx
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -898,15 +898,25 @@ sal_uInt16 SdrPageView::GetEnteredLevel() const
void SdrPageView::CheckAktGroup()
{
- SdrObject* pGrp=GetAktGroup();
- while (pGrp!=nullptr &&
- (!pGrp->IsInserted() || pGrp->GetObjList()==nullptr ||
- pGrp->GetPage()==nullptr || pGrp->GetModel()==nullptr)) { // anything outside of the borders?
- pGrp=pGrp->GetUpGroup();
+ SdrObject* pGrp(GetAktGroup());
+
+ while(nullptr != pGrp &&
+ (!pGrp->IsInserted() || nullptr == pGrp->GetObjList() || nullptr == pGrp->GetPage()))
+ {
+ // anything outside of the borders?
+ pGrp = pGrp->GetUpGroup();
}
- if (pGrp!=GetAktGroup()) {
- if (pGrp!=nullptr) EnterGroup(pGrp);
- else LeaveAllGroup();
+
+ if(pGrp != GetAktGroup())
+ {
+ if(nullptr != pGrp)
+ {
+ EnterGroup(pGrp);
+ }
+ else
+ {
+ LeaveAllGroup();
+ }
}
}
diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx
index 48c971d61792..ba0e252da346 100644
--- a/svx/source/svdraw/svdpntv.cxx
+++ b/svx/source/svdraw/svdpntv.cxx
@@ -181,9 +181,12 @@ void SdrPaintView::ImpClearVars()
maGridColor = COL_BLACK;
}
-SdrPaintView::SdrPaintView(SdrModel* pModel, OutputDevice* pOut)
-: mpPageView(nullptr),
- maDefaultAttr(pModel->GetItemPool()),
+SdrPaintView::SdrPaintView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: mrSdrModelFromSdrView(rSdrModel),
+ mpPageView(nullptr),
+ maDefaultAttr(rSdrModel.GetItemPool()),
mbBufferedOutputAllowed(false),
mbBufferedOverlayAllowed(false),
mbPagePaintingAllowed(true),
@@ -192,7 +195,7 @@ SdrPaintView::SdrPaintView(SdrModel* pModel, OutputDevice* pOut)
mbHideDraw(false),
mbHideFormControl(false)
{
- mpModel=pModel;
+ mpModel=&rSdrModel;
ImpClearVars();
if(pOut)
diff --git a/svx/source/svdraw/svdpoev.cxx b/svx/source/svdraw/svdpoev.cxx
index 509eb112dd96..56e32865e012 100644
--- a/svx/source/svdraw/svdpoev.cxx
+++ b/svx/source/svdraw/svdpoev.cxx
@@ -44,8 +44,10 @@ void SdrPolyEditView::ImpResetPolyPossibilityFlags()
bSetMarkedSegmentsKindPossible=false;
}
-SdrPolyEditView::SdrPolyEditView(SdrModel* pModel1, OutputDevice* pOut):
- SdrEditView(pModel1,pOut)
+SdrPolyEditView::SdrPolyEditView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: SdrEditView(rSdrModel, pOut)
{
ImpResetPolyPossibilityFlags();
}
diff --git a/svx/source/svdraw/svdsnpv.cxx b/svx/source/svdraw/svdsnpv.cxx
index 94f1f5affc00..10aacc3f87fd 100644
--- a/svx/source/svdraw/svdsnpv.cxx
+++ b/svx/source/svdraw/svdsnpv.cxx
@@ -165,30 +165,31 @@ void ImplHelpLineOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition)
}
}
-
-SdrSnapView::SdrSnapView(SdrModel* pModel1, OutputDevice* pOut)
- : SdrPaintView(pModel1,pOut)
- , mpPageOriginOverlay(nullptr)
- , mpHelpLineOverlay(nullptr)
- , nMagnSizPix(4)
- , nSnapAngle(1500)
- , nEliminatePolyPointLimitAngle(0)
- , eCrookMode(SdrCrookMode::Rotate)
- , bSnapEnab(true)
- , bGridSnap(true)
- , bBordSnap(true)
- , bHlplSnap(true)
- , bOFrmSnap(true)
- , bOPntSnap(false)
- , bOConSnap(true)
- , bMoveSnapOnlyTopLeft(false)
- , bOrtho(false)
- , bBigOrtho(true)
- , bAngleSnapEnab(false)
- , bMoveOnlyDragging(false)
- , bSlantButShear(false)
- , bCrookNoContortion(false)
- , bEliminatePolyPoints(false)
+SdrSnapView::SdrSnapView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: SdrPaintView(rSdrModel, pOut)
+ ,mpPageOriginOverlay(nullptr)
+ ,mpHelpLineOverlay(nullptr)
+ ,nMagnSizPix(4)
+ ,nSnapAngle(1500)
+ ,nEliminatePolyPointLimitAngle(0)
+ ,eCrookMode(SdrCrookMode::Rotate)
+ ,bSnapEnab(true)
+ ,bGridSnap(true)
+ ,bBordSnap(true)
+ ,bHlplSnap(true)
+ ,bOFrmSnap(true)
+ ,bOPntSnap(false)
+ ,bOConSnap(true)
+ ,bMoveSnapOnlyTopLeft(false)
+ ,bOrtho(false)
+ ,bBigOrtho(true)
+ ,bAngleSnapEnab(false)
+ ,bMoveOnlyDragging(false)
+ ,bSlantButShear(false)
+ ,bCrookNoContortion(false)
+ ,bEliminatePolyPoints(false)
{
}
diff --git a/svx/source/svdraw/svdtext.cxx b/svx/source/svdraw/svdtext.cxx
index 159f863cb54c..549578832885 100644
--- a/svx/source/svdraw/svdtext.cxx
+++ b/svx/source/svdraw/svdtext.cxx
@@ -31,7 +31,6 @@
SdrText::SdrText( SdrTextObj& rObject )
: mpOutlinerParaObject( nullptr )
, mrObject( rObject )
-, mpModel( rObject.GetModel() )
, mbPortionInfoChecked( false )
{
OSL_ENSURE(&mrObject, "SdrText created without SdrTextObj (!)");
@@ -48,11 +47,12 @@ void SdrText::CheckPortionInfo( SdrOutliner& rOutliner )
{
// #i102062# no action when the Outliner is the HitTestOutliner,
// this will remove WrongList info at the OPO
- if(mpModel && &rOutliner == &mpModel->GetHitTestOutliner())
+ if(&rOutliner == &mrObject.getSdrModelFromSdrObject().GetHitTestOutliner())
return;
// TODO: optimization: we could create a BigTextObject
mbPortionInfoChecked=true;
+
if(mpOutlinerParaObject!=nullptr && rOutliner.ShouldCreateBigTextObject())
{
// #i102062# MemoryLeak closed
@@ -76,16 +76,15 @@ void SdrText::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
{
if( mpOutlinerParaObject.get() != pTextObject )
{
- if( mpModel )
+ // Update HitTestOutliner
+ const SdrTextObj* pTestObj(mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
+
+ if(pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get())
{
- // Update HitTestOutliner
- const SdrTextObj* pTestObj = mpModel->GetHitTestOutliner().GetTextObj();
- if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get() )
- mpModel->GetHitTestOutliner().SetTextObj( nullptr );
+ mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
}
mpOutlinerParaObject.reset(pTextObject);
-
mbPortionInfoChecked = false;
}
}
@@ -98,82 +97,33 @@ OutlinerParaObject* SdrText::GetOutlinerParaObject() const
/** returns the current OutlinerParaObject and removes it from this instance */
OutlinerParaObject* SdrText::RemoveOutlinerParaObject()
{
- if( mpModel )
+ // Update HitTestOutliner
+ const SdrTextObj* pTestObj(mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
+
+ if(pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get())
{
- // Update HitTestOutliner
- const SdrTextObj* pTestObj = mpModel->GetHitTestOutliner().GetTextObj();
- if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject.get() )
- mpModel->GetHitTestOutliner().SetTextObj( nullptr );
+ mrObject.getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
}
OutlinerParaObject* pOPO = mpOutlinerParaObject.release();
-
mbPortionInfoChecked = false;
return pOPO;
}
-void SdrText::SetModel( SdrModel* pNewModel )
-{
- if( pNewModel == mpModel )
- return;
-
- SdrModel* pOldModel = mpModel;
- mpModel = pNewModel;
-
- if( !mpOutlinerParaObject || pOldModel==nullptr || pNewModel==nullptr)
- return;
-
- bool bHgtSet = GetObjectItemSet().GetItemState(EE_CHAR_FONTHEIGHT) == SfxItemState::SET;
-
- MapUnit aOldUnit(pOldModel->GetScaleUnit());
- MapUnit aNewUnit(pNewModel->GetScaleUnit());
- bool bScaleUnitChanged=aNewUnit!=aOldUnit;
- // Now move the OutlinerParaObject into a new Pool.
- // TODO: We should compare the DefTab and RefDevice of both Models to
- // see whether we need to use AutoGrow!
- sal_Int32 nOldFontHgt=pOldModel->GetDefaultFontHeight();
- sal_Int32 nNewFontHgt=pNewModel->GetDefaultFontHeight();
- bool bDefHgtChanged=nNewFontHgt!=nOldFontHgt;
- bool bSetHgtItem=bDefHgtChanged && !bHgtSet;
- if (bSetHgtItem)
- {
- // fix the value of HeightItem, so
- // 1. it remains and
- // 2. DoStretchChars gets the right value
- SetObjectItem(SvxFontHeightItem(nOldFontHgt, 100, EE_CHAR_FONTHEIGHT));
- }
- // now use the Outliner, etc. so the above SetAttr can work at all
- SdrOutliner& rOutliner = mrObject.ImpGetDrawOutliner();
- rOutliner.SetText(*mpOutlinerParaObject);
- mpOutlinerParaObject.reset();
- if (bScaleUnitChanged)
- {
- Fraction aMetricFactor=GetMapFactor(aOldUnit,aNewUnit).X();
-
- if (bSetHgtItem)
- {
- // Now correct the frame attribute
- nOldFontHgt=BigMulDiv(nOldFontHgt,aMetricFactor.GetNumerator(),aMetricFactor.GetDenominator());
- SetObjectItem(SvxFontHeightItem(nOldFontHgt, 100, EE_CHAR_FONTHEIGHT));
- }
- }
- SetOutlinerParaObject(rOutliner.CreateParaObject());
- mpOutlinerParaObject->ClearPortionInfo();
- mbPortionInfoChecked=false;
- rOutliner.Clear();
-}
-
void SdrText::ForceOutlinerParaObject( OutlinerMode nOutlMode )
{
- if( mpModel && !mpOutlinerParaObject )
+ if(!mpOutlinerParaObject)
{
- std::unique_ptr<Outliner> pOutliner(SdrMakeOutliner(nOutlMode, *mpModel));
- if( pOutliner )
+ std::unique_ptr<Outliner> pOutliner(
+ SdrMakeOutliner(
+ nOutlMode,
+ mrObject.getSdrModelFromSdrObject()));
+
+ if(pOutliner)
{
- Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
+ Outliner& aDrawOutliner(mrObject.getSdrModelFromSdrObject().GetDrawOutliner());
pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
-
pOutliner->SetStyleSheet( 0, GetStyleSheet());
OutlinerParaObject* pOutlinerParaObject = pOutliner->CreateParaObject();
SetOutlinerParaObject( pOutlinerParaObject );
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
index 1c6ec236f34b..22720cfb4ca4 100644
--- a/svx/source/svdraw/svdundo.cxx
+++ b/svx/source/svdraw/svdundo.cxx
@@ -209,8 +209,8 @@ OUString SdrUndoGroup::GetSdrRepeatComment(SdrView& /*rView*/) const
}
SdrUndoObj::SdrUndoObj(SdrObject& rNewObj)
- : SdrUndoAction(*rNewObj.GetModel())
- , pObj(&rNewObj)
+: SdrUndoAction(rNewObj.getSdrModelFromSdrObject())
+ ,pObj(&rNewObj)
{
}
@@ -237,10 +237,10 @@ void SdrUndoObj::ImpTakeDescriptionStr(const char* pStrCacheID, OUString& rStr,
// common call method for possible change of the page when UNDO/REDO is triggered
void SdrUndoObj::ImpShowPageOfThisObject()
{
- if(pObj && pObj->IsInserted() && pObj->GetPage() && pObj->GetModel())
+ if(pObj && pObj->IsInserted() && pObj->GetPage())
{
SdrHint aHint(SdrHintKind::SwitchToPage, *pObj, pObj->GetPage());
- pObj->GetModel()->Broadcast(aHint);
+ pObj->getSdrModelFromSdrObject().Broadcast(aHint);
}
}
@@ -275,7 +275,7 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave
if(bIsGroup)
{
// it's a group object!
- pUndoGroup.reset( new SdrUndoGroup(*pObj->GetModel()) );
+ pUndoGroup.reset(new SdrUndoGroup(pObj->getSdrModelFromSdrObject()));
const size_t nObjCount(pOL->GetObjCount());
for(size_t nObjNum = 0; nObjNum < nObjCount; ++nObjNum)
@@ -343,9 +343,9 @@ void SdrUndoAttrObj::Undo()
mxRedoStyleSheet = pObj->GetStyleSheet();
SfxStyleSheet* pSheet = dynamic_cast< SfxStyleSheet* >(mxUndoStyleSheet.get());
- if(pSheet && pObj->GetModel() && pObj->GetModel()->GetStyleSheetPool())
+ if(pSheet && pObj->getSdrModelFromSdrObject().GetStyleSheetPool())
{
- ensureStyleSheetInStyleSheetPool(*pObj->GetModel()->GetStyleSheetPool(), *pSheet);
+ ensureStyleSheetInStyleSheetPool(*pObj->getSdrModelFromSdrObject().GetStyleSheetPool(), *pSheet);
pObj->SetStyleSheet(pSheet, true);
}
else
@@ -426,9 +426,9 @@ void SdrUndoAttrObj::Redo()
mxUndoStyleSheet = pObj->GetStyleSheet();
SfxStyleSheet* pSheet = dynamic_cast< SfxStyleSheet* >(mxRedoStyleSheet.get());
- if(pSheet && pObj->GetModel() && pObj->GetModel()->GetStyleSheetPool())
+ if(pSheet && pObj->getSdrModelFromSdrObject().GetStyleSheetPool())
{
- ensureStyleSheetInStyleSheetPool(*pObj->GetModel()->GetStyleSheetPool(), *pSheet);
+ ensureStyleSheetInStyleSheetPool(*pObj->getSdrModelFromSdrObject().GetStyleSheetPool(), *pSheet);
pObj->SetStyleSheet(pSheet, true);
}
else
@@ -581,7 +581,7 @@ SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj)
// this is a group object!
// If this were 3D scene, we'd only add an Undo for the scene itself
// (which we do elsewhere).
- pUndoGroup.reset(new SdrUndoGroup(*pObj->GetModel()));
+ pUndoGroup.reset(new SdrUndoGroup(pObj->getSdrModelFromSdrObject()));
const size_t nObjCount = pOL->GetObjCount();
for (size_t nObjNum = 0; nObjNum<nObjCount; ++nObjNum) {
pUndoGroup->AddAction(new SdrUndoGeoObj(*pOL->GetObj(nObjNum)));
@@ -1335,8 +1335,8 @@ OUString SdrUndoMoveLayer::GetComment() const
SdrUndoPage::SdrUndoPage(SdrPage& rNewPg)
- : SdrUndoAction(*rNewPg.GetModel())
- , mrPage(rNewPg)
+: SdrUndoAction(rNewPg.getSdrModelFromSdrPage())
+ ,mrPage(rNewPg)
{
}
@@ -1657,7 +1657,7 @@ void SdrUndoPageRemoveMasterPage::Undo()
{
if(mbOldHadMasterPage)
{
- mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maOldMasterPageNumber));
+ mrPage.TRG_SetMasterPage(*mrPage.getSdrModelFromSdrPage().GetMasterPage(maOldMasterPageNumber));
mrPage.TRG_SetMasterPageVisibleLayers(maOldSet);
}
}
@@ -1695,7 +1695,7 @@ void SdrUndoPageChangeMasterPage::Undo()
if(mbOldHadMasterPage)
{
mrPage.TRG_ClearMasterPage();
- mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maOldMasterPageNumber));
+ mrPage.TRG_SetMasterPage(*mrPage.getSdrModelFromSdrPage().GetMasterPage(maOldMasterPageNumber));
mrPage.TRG_SetMasterPageVisibleLayers(maOldSet);
}
}
@@ -1706,7 +1706,7 @@ void SdrUndoPageChangeMasterPage::Redo()
if(mbNewHadMasterPage)
{
mrPage.TRG_ClearMasterPage();
- mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maNewMasterPageNumber));
+ mrPage.TRG_SetMasterPage(*mrPage.getSdrModelFromSdrPage().GetMasterPage(maNewMasterPageNumber));
mrPage.TRG_SetMasterPageVisibleLayers(maNewSet);
}
}
diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx
index db460ea89d45..d9eb52432957 100644
--- a/svx/source/svdraw/svdview.cxx
+++ b/svx/source/svdraw/svdview.cxx
@@ -146,15 +146,15 @@ SdrDropMarkerOverlay::~SdrDropMarkerOverlay()
// OverlayManager and deletes them.
}
-
-SdrView::SdrView(SdrModel* pModel1, OutputDevice* pOut)
-: SdrCreateView(pModel1,pOut),
+SdrView::SdrView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: SdrCreateView(rSdrModel, pOut),
bNoExtendedMouseDispatcher(false),
bNoExtendedKeyDispatcher(false),
mbMasterPagePaintCaching(false)
{
maAccessibilityOptions.AddListener(this);
-
onAccessibilityOptionsChanged();
}
diff --git a/svx/source/svdraw/svdviter.cxx b/svx/source/svdraw/svdviter.cxx
index 2dbd8b5f3bb2..044526e6e638 100644
--- a/svx/source/svdraw/svdviter.cxx
+++ b/svx/source/svdraw/svdviter.cxx
@@ -38,7 +38,7 @@ void SdrViewIter::ImpInitVars()
SdrViewIter::SdrViewIter(const SdrPage* pPage)
{
mpPage = pPage;
- mpModel = pPage ? pPage->GetModel() : nullptr;
+ mpModel = pPage ? &pPage->getSdrModelFromSdrPage() : nullptr;
mpObject = nullptr;
mbNoMasterPage = false;
ImpInitVars();
@@ -48,7 +48,7 @@ SdrViewIter::SdrViewIter(const SdrPage* pPage)
SdrViewIter::SdrViewIter(const SdrObject* pObject)
{
mpObject = pObject;
- mpModel = pObject ? pObject->GetModel() : nullptr;
+ mpModel = pObject ? &pObject->getSdrModelFromSdrObject() : nullptr;
mpPage = pObject ? pObject->GetPage() : nullptr;
mbNoMasterPage = false;
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index 1011c8a11e87..58fc73351181 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -57,8 +57,10 @@
using namespace com::sun::star;
-SdrExchangeView::SdrExchangeView(SdrModel* pModel1, OutputDevice* pOut):
- SdrObjEditView(pModel1,pOut)
+SdrExchangeView::SdrExchangeView(
+ SdrModel& rSdrModel,
+ OutputDevice* pOut)
+: SdrObjEditView(rSdrModel, pOut)
{
}
@@ -143,8 +145,11 @@ bool SdrExchangeView::Paste(const OUString& rStr, const Point& rPos, SdrObjList*
if (pPage!=nullptr) {
aTextRect.SetSize(pPage->GetSize());
}
- SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect);
- pObj->SetModel(mpModel);
+ SdrRectObj* pObj = new SdrRectObj(
+ getSdrModelFromSdrView(),
+ OBJ_TEXT,
+ aTextRect);
+
pObj->SetLayer(nLayer);
pObj->NbcSetText(rStr); // SetText before SetAttr, else SetAttr doesn't work!
if (mpDefaultStyleSheet!=nullptr) pObj->NbcSetStyleSheet(mpDefaultStyleSheet, false);
@@ -180,8 +185,11 @@ bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point&
if (pPage!=nullptr) {
aTextRect.SetSize(pPage->GetSize());
}
- SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect);
- pObj->SetModel(mpModel);
+ SdrRectObj* pObj = new SdrRectObj(
+ getSdrModelFromSdrView(),
+ OBJ_TEXT,
+ aTextRect);
+
pObj->SetLayer(nLayer);
if (mpDefaultStyleSheet!=nullptr) pObj->NbcSetStyleSheet(mpDefaultStyleSheet, false);
@@ -201,9 +209,9 @@ bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point&
ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
// b4967543
- if(pObj->GetModel() && pObj->GetOutlinerParaObject())
+ if(pObj->GetOutlinerParaObject())
{
- SdrOutliner& rOutliner = pObj->GetModel()->GetHitTestOutliner();
+ SdrOutliner& rOutliner = pObj->getSdrModelFromSdrObject().GetHitTestOutliner();
rOutliner.SetText(*pObj->GetOutlinerParaObject());
if(1 == rOutliner.GetParagraphCount())
@@ -212,7 +220,7 @@ bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point&
if(pCandidate)
{
- if(pObj->GetModel()->GetStyleSheetPool() == &pCandidate->GetPool())
+ if(pObj->getSdrModelFromSdrObject().GetStyleSheetPool() == &pCandidate->GetPool())
{
pObj->NbcSetStyleSheet(pCandidate, true);
}
@@ -305,15 +313,13 @@ bool SdrExchangeView::Paste(
{
if(bResize)
{
- pNewObj->GetModel()->SetPasteResize(true);
+ pNewObj->getSdrModelFromSdrObject().SetPasteResize(true);
pNewObj->NbcResize(aPt0,aXResize,aYResize);
- pNewObj->GetModel()->SetPasteResize(false);
+ pNewObj->getSdrModelFromSdrObject().SetPasteResize(false);
}
// #i39861#
- pNewObj->SetModel(pDstLst->GetModel());
pNewObj->SetPage(pDstLst->GetPage());
-
pNewObj->NbcMove(aSiz);
const SdrPage* pPg = pDstLst->GetPage();
@@ -345,7 +351,7 @@ bool SdrExchangeView::Paste(
pDstLst->InsertObject(pNewObj, SAL_MAX_SIZE);
if( bUndo )
- AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewObj));
+ AddUndo(getSdrModelFromSdrView().GetSdrUndoFactory().CreateUndoNewObject(*pNewObj));
if (bMark) {
// Don't already set Markhandles!
@@ -414,7 +420,7 @@ void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Po
rLst.InsertObject(pObj, SAL_MAX_SIZE);
if( IsUndoEnabled() )
- AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
+ AddUndo(getSdrModelFromSdrView().GetSdrUndoFactory().CreateUndoNewObject(*pObj));
SdrPageView* pMarkPV=nullptr;
SdrPageView* pPV = GetSdrPageView();
@@ -579,7 +585,7 @@ Graphic SdrExchangeView::GetAllMarkedGraphic() const
if( AreObjectsMarked() )
{
if( ( 1 == GetMarkedObjectCount() ) && GetSdrMarkByIndex( 0 ) )
- aRet = SdrExchangeView::GetObjGraphic( mpModel, GetMarkedObjectByIndex( 0 ) );
+ aRet = SdrExchangeView::GetObjGraphic(*GetMarkedObjectByIndex(0));
else
aRet = GetMarkedObjMetaFile();
}
@@ -588,68 +594,68 @@ Graphic SdrExchangeView::GetAllMarkedGraphic() const
}
-Graphic SdrExchangeView::GetObjGraphic( const SdrModel* pModel, const SdrObject* pObj )
+Graphic SdrExchangeView::GetObjGraphic(const SdrObject& rSdrObject)
{
Graphic aRet;
- if( pModel && pObj )
- {
- // try to get a graphic from the object first
- const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
- const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj);
+ // try to get a graphic from the object first
+ const SdrGrafObj* pSdrGrafObj(dynamic_cast< const SdrGrafObj* >(&rSdrObject));
+ const SdrOle2Obj* pSdrOle2Obj(dynamic_cast< const SdrOle2Obj* >(&rSdrObject));
- if(pSdrGrafObj)
+ if(pSdrGrafObj)
+ {
+ if(pSdrGrafObj->isEmbeddedVectorGraphicData())
{
- if(pSdrGrafObj->isEmbeddedVectorGraphicData())
- {
- // get Metafile for Svg content
- aRet = pSdrGrafObj->getMetafileFromEmbeddedVectorGraphicData();
- }
- else
- {
- // Make behaviour coherent with metafile
- // recording below (which of course also takes
- // view-transformed objects)
- aRet = pSdrGrafObj->GetTransformedGraphic();
- }
+ // get Metafile for Svg content
+ aRet = pSdrGrafObj->getMetafileFromEmbeddedVectorGraphicData();
}
- else if(pSdrOle2Obj)
+ else
{
- if ( pSdrOle2Obj->GetGraphic() )
- aRet = *pSdrOle2Obj->GetGraphic();
+ // Make behaviour coherent with metafile
+ // recording below (which of course also takes
+ // view-transformed objects)
+ aRet = pSdrGrafObj->GetTransformedGraphic();
}
-
- // if graphic could not be retrieved => go the hard way and create a MetaFile
- if( ( GraphicType::NONE == aRet.GetType() ) || ( GraphicType::Default == aRet.GetType() ) )
+ }
+ else if(pSdrOle2Obj)
+ {
+ if(pSdrOle2Obj->GetGraphic())
{
- ScopedVclPtrInstance< VirtualDevice > pOut;
- GDIMetaFile aMtf;
- const tools::Rectangle aBoundRect( pObj->GetCurrentBoundRect() );
- const MapMode aMap( pModel->GetScaleUnit(),
- Point(),
- pModel->GetScaleFraction(),
- pModel->GetScaleFraction() );
-
- pOut->EnableOutput( false );
- pOut->SetMapMode( aMap );
- aMtf.Record( pOut );
- pObj->SingleObjectPainter( *pOut.get() );
- aMtf.Stop();
- aMtf.WindStart();
-
- // #i99268# replace the original offset from using XOutDev's SetOffset
- // NOT (as tried with #i92760#) with another MapMode which gets recorded
- // by the Metafile itself (what always leads to problems), but by
- // moving the result directly
- aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top());
-
- aMtf.SetPrefMapMode( aMap );
- aMtf.SetPrefSize( aBoundRect.GetSize() );
+ aRet = *pSdrOle2Obj->GetGraphic();
+ }
+ }
- if( aMtf.GetActionSize() )
- aRet = aMtf;
+ // if graphic could not be retrieved => go the hard way and create a MetaFile
+ if((GraphicType::NONE == aRet.GetType()) || (GraphicType::Default == aRet.GetType()))
+ {
+ ScopedVclPtrInstance< VirtualDevice > pOut;
+ GDIMetaFile aMtf;
+ const tools::Rectangle aBoundRect(rSdrObject.GetCurrentBoundRect());
+ const MapMode aMap(rSdrObject.getSdrModelFromSdrObject().GetScaleUnit(),
+ Point(),
+ rSdrObject.getSdrModelFromSdrObject().GetScaleFraction(),
+ rSdrObject.getSdrModelFromSdrObject().GetScaleFraction());
+
+ pOut->EnableOutput(false);
+ pOut->SetMapMode(aMap);
+ aMtf.Record(pOut);
+ rSdrObject.SingleObjectPainter(*pOut.get());
+ aMtf.Stop();
+ aMtf.WindStart();
+
+ // #i99268# replace the original offset from using XOutDev's SetOffset
+ // NOT (as tried with #i92760#) with another MapMode which gets recorded
+ // by the Metafile itself (what always leads to problems), but by
+ // moving the result directly
+ aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top());
+ aMtf.SetPrefMapMode(aMap);
+ aMtf.SetPrefSize(aBoundRect.GetSize());
+
+ if(aMtf.GetActionSize())
+ {
+ aRet = aMtf;
}
- }
+ }
return aRet;
}
@@ -703,7 +709,6 @@ void SdrExchangeView::DrawMarkedObj(OutputDevice& rOut) const
}
}
-
SdrModel* SdrExchangeView::GetMarkedObjModel() const
{
// Sorting the MarkList here might be problematic in the future, so
@@ -729,15 +734,16 @@ SdrModel* SdrExchangeView::GetMarkedObjModel() const
{
// convert SdrPageObj's to a graphic representation, because
// virtual connection to referenced page gets lost in new model
- pNewObj = new SdrGrafObj( GetObjGraphic( mpModel, pObj ), pObj->GetLogicRect() );
+ pNewObj = new SdrGrafObj(
+ *pNeuMod,
+ GetObjGraphic(*pObj),
+ pObj->GetLogicRect());
pNewObj->SetPage( pNeuPag );
- pNewObj->SetModel( pNeuMod );
}
else
{
pNewObj = pObj->Clone();
pNewObj->SetPage( pNeuPag );
- pNewObj->SetModel( pNeuMod );
}
pNeuPag->InsertObject(pNewObj, SAL_MAX_SIZE);
@@ -750,8 +756,8 @@ SdrModel* SdrExchangeView::GetMarkedObjModel() const
// New mechanism to re-create the connections of cloned connectors
aCloneList.CopyConnections();
}
+
return pNeuMod;
}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
index cd1973848746..0f733d0c6e5d 100644
--- a/svx/source/table/cell.cxx
+++ b/svx/source/table/cell.cxx
@@ -392,21 +392,31 @@ rtl::Reference< Cell > Cell::create( SdrTableObj& rTableObj )
}
-Cell::Cell( SdrTableObj& rTableObj )
-: SdrText( rTableObj )
-, SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
-, mpPropSet( ImplGetSvxCellPropertySet() )
-, mpProperties( new sdr::properties::CellProperties( rTableObj, this ) )
-, mnCellContentType( CellContentType_EMPTY )
-, mfValue( 0.0 )
-, mnError( 0 )
-, mbMerged( false )
-, mnRowSpan( 1 )
-, mnColSpan( 1 )
-, mxTable( rTableObj.getTable() )
-{
- if( rTableObj.GetModel() )
- SetModel( rTableObj.GetModel() );
+Cell::Cell(
+ SdrTableObj& rTableObj)
+: SdrText(rTableObj)
+ ,SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
+ ,mpPropSet( ImplGetSvxCellPropertySet() )
+ ,mpProperties( new sdr::properties::CellProperties( rTableObj, this ) )
+ ,mnCellContentType( CellContentType_EMPTY )
+ ,mfValue( 0.0 )
+ ,mnError( 0 )
+ ,mbMerged( false )
+ ,mnRowSpan( 1 )
+ ,mnColSpan( 1 )
+ ,mxTable( rTableObj.getTable() )
+{
+ // Caution: Old SetModel() indirectly did a very necessary thing here,
+ // it created a valid SvxTextEditSource which is needed to bind contained
+ // Text to the UNO API and thus to save/load and more. Added version without
+ // model change.
+ // Also done was (not needed, for reference):
+ // SetStyleSheet( nullptr, true );
+ // ForceOutlinerParaObject( OutlinerMode::TextObject );
+ if(nullptr == GetEditSource())
+ {
+ SetEditSource(new SvxTextEditSource(&GetObject(), this));
+ }
}
@@ -440,37 +450,6 @@ void Cell::dispose()
SetOutlinerParaObject( nullptr );
}
-
-void Cell::SetModel(SdrModel* pNewModel)
-{
- SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( GetEditSource() );
- if( (GetModel() != pNewModel) || ( pNewModel && !pTextEditSource) )
- {
- if( mpProperties )
- {
- SfxItemPool* pItemPool = mpProperties->GetObjectItemSet().GetPool();
-
- // test for correct pool in ItemSet; move to new pool if necessary
- if( pNewModel && pItemPool && pItemPool != &pNewModel->GetItemPool())
- mpProperties->MoveToItemPool(pItemPool, &pNewModel->GetItemPool(), pNewModel);
- }
-
- if( pTextEditSource )
- {
- pTextEditSource->ChangeModel( pNewModel );
- }
- else
- {
- SetEditSource( new SvxTextEditSource( &GetObject(), this ) );
- }
-
- SetStyleSheet( nullptr, true );
- SdrText::SetModel( pNewModel );
- ForceOutlinerParaObject( OutlinerMode::TextObject );
- }
-}
-
-
void Cell::merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan )
{
if ((mnColSpan != nColumnSpan) || (mnRowSpan != nRowSpan) || mbMerged)
@@ -537,12 +516,13 @@ void Cell::replaceContentAndFormating( const CellRef& xSourceCell )
{
mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() );
SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell->GetOutlinerParaObject()) );
-
SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() );
- if(rSourceTableObj.GetModel() != rTableObj.GetModel())
+ if(&rSourceTableObj.getSdrModelFromSdrObject() != &rTableObj.getSdrModelFromSdrObject())
{
+ // TTTT should not happen - if, then a clone may be needed
+ // Maybe add a assertion here later
SetStyleSheet( nullptr, true );
}
}
@@ -564,12 +544,13 @@ void Cell::copyFormatFrom( const CellRef& xSourceCell )
if( xSourceCell.is() && mpProperties )
{
mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() );
-
SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() );
- if(rSourceTableObj.GetModel() != rTableObj.GetModel())
+ if(&rSourceTableObj.getSdrModelFromSdrObject() != &rTableObj.getSdrModelFromSdrObject())
{
+ // TTTT should not happen - if, then a clone may be needed
+ // Maybe add a assertion here later
SetStyleSheet( nullptr, true );
}
@@ -812,10 +793,11 @@ void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
void Cell::AddUndo()
{
SdrObject& rObj = GetObject();
- if( rObj.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() )
+
+ if( rObj.IsInserted() && rObj.getSdrModelFromSdrObject().IsUndoEnabled() )
{
CellRef xCell( this );
- GetModel()->AddUndo( new CellUndo( &rObj, xCell ) );
+ rObj.getSdrModelFromSdrObject().AddUndo( new CellUndo( &rObj, xCell ) );
// Undo action for the after-text-edit-ended stack.
SdrTableObj* pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(&rObj);
@@ -1019,7 +1001,7 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any&
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
@@ -1111,7 +1093,7 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any&
}
default:
{
- SfxItemSet aSet( GetModel()->GetItemPool(), {{pMap->nWID, pMap->nWID}});
+ SfxItemSet aSet(GetObject().getSdrModelFromSdrObject().GetItemPool(), {{pMap->nWID, pMap->nWID}});
aSet.Put(mpProperties->GetItem(pMap->nWID));
bool bSpecial = false;
@@ -1131,7 +1113,7 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any&
OUString aApiName;
if( rValue >>= aApiName )
{
- if( SvxShape::SetFillAttribute( pMap->nWID, aApiName, aSet, GetModel() ) )
+ if(SvxShape::SetFillAttribute(pMap->nWID, aApiName, aSet, &GetObject().getSdrModelFromSdrObject()))
bSpecial = true;
}
}
@@ -1148,7 +1130,7 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any&
{
// fetch the default from ItemPool
if(SfxItemPool::IsWhich(pMap->nWID))
- aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
+ aSet.Put(GetObject().getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID));
}
if( aSet.GetItemState( pMap->nWID ) == SfxItemState::SET )
@@ -1158,7 +1140,7 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any&
}
}
- GetModel()->SetChanged();
+ GetObject().getSdrModelFromSdrObject().SetChanged();
mpProperties->SetMergedItemSetAndBroadcast( aSet );
return;
}
@@ -1172,7 +1154,7 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName )
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
@@ -1231,7 +1213,7 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName )
}
default:
{
- SfxItemSet aSet( GetModel()->GetItemPool(), {{pMap->nWID, pMap->nWID}});
+ SfxItemSet aSet(GetObject().getSdrModelFromSdrObject().GetItemPool(), {{pMap->nWID, pMap->nWID}});
aSet.Put(mpProperties->GetItem(pMap->nWID));
Any aAny;
@@ -1241,7 +1223,7 @@ Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName )
{
// fetch the default from ItemPool
if(SfxItemPool::IsWhich(pMap->nWID))
- aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
+ aSet.Put(GetObject().getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID));
}
if( aSet.Count() )
@@ -1283,7 +1265,7 @@ void SAL_CALL Cell::setPropertyValues( const Sequence< OUString >& aPropertyName
{
::SolarMutexGuard aSolarGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const sal_Int32 nCount = aPropertyNames.getLength();
@@ -1313,7 +1295,7 @@ Sequence< Any > SAL_CALL Cell::getPropertyValues( const Sequence< OUString >& aP
{
::SolarMutexGuard aSolarGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const sal_Int32 nCount = aPropertyNames.getLength();
@@ -1364,7 +1346,7 @@ PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName )
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
@@ -1467,7 +1449,7 @@ Sequence< PropertyState > SAL_CALL Cell::getPropertyStates( const Sequence< OUSt
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const sal_Int32 nCount = aPropertyName.getLength();
@@ -1497,7 +1479,7 @@ void SAL_CALL Cell::setPropertyToDefault( const OUString& PropertyName )
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
@@ -1527,7 +1509,7 @@ void SAL_CALL Cell::setPropertyToDefault( const OUString& PropertyName )
}
}
- GetModel()->SetChanged();
+ GetObject().getSdrModelFromSdrObject().SetChanged();
return;
}
throw UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this));
@@ -1538,7 +1520,7 @@ Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName )
{
::SolarMutexGuard aGuard;
- if( (mpProperties == nullptr) || (GetModel() == nullptr) )
+ if(mpProperties == nullptr)
throw DisposedException();
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
@@ -1565,8 +1547,8 @@ Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName )
{
if( SfxItemPool::IsWhich(pMap->nWID) )
{
- SfxItemSet aSet( GetModel()->GetItemPool(), {{pMap->nWID, pMap->nWID}});
- aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
+ SfxItemSet aSet(GetObject().getSdrModelFromSdrObject().GetItemPool(), {{pMap->nWID, pMap->nWID}});
+ aSet.Put(GetObject().getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID));
return GetAnyForItem( aSet, pMap );
}
}
diff --git a/svx/source/table/cellcursor.cxx b/svx/source/table/cellcursor.cxx
index db68fdb61ab4..b6368837cfc5 100644
--- a/svx/source/table/cellcursor.cxx
+++ b/svx/source/table/cellcursor.cxx
@@ -242,11 +242,11 @@ void SAL_CALL CellCursor::merge( )
if( !mxTable.is() || (mxTable->getSdrTableObj() == nullptr) )
throw DisposedException();
- SdrModel* pModel = mxTable->getSdrTableObj()->GetModel();
- const bool bUndo = pModel && mxTable->getSdrTableObj()->IsInserted() && pModel->IsUndoEnabled();
+ SdrModel& rModel(mxTable->getSdrTableObj()->getSdrModelFromSdrObject());
+ const bool bUndo(mxTable->getSdrTableObj()->IsInserted() && rModel.IsUndoEnabled());
if( bUndo )
- pModel->BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
try
{
@@ -260,10 +260,9 @@ void SAL_CALL CellCursor::merge( )
}
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
}
@@ -503,10 +502,11 @@ void SAL_CALL CellCursor::split( sal_Int32 nColumns, sal_Int32 nRows )
if( !mxTable.is() || (mxTable->getSdrTableObj() == nullptr) )
throw DisposedException();
- SdrModel* pModel = mxTable->getSdrTableObj()->GetModel();
- const bool bUndo = pModel && mxTable->getSdrTableObj()->IsInserted() && pModel->IsUndoEnabled();
+ SdrModel& rModel(mxTable->getSdrTableObj()->getSdrModelFromSdrObject());
+ const bool bUndo(mxTable->getSdrTableObj()->IsInserted() && rModel.IsUndoEnabled());
+
if( bUndo )
- pModel->BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
try
{
@@ -526,10 +526,9 @@ void SAL_CALL CellCursor::split( sal_Int32 nColumns, sal_Int32 nRows )
}
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
}
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index dab61a948e33..f8b23626b281 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -684,7 +684,7 @@ sal_Int32 SdrTableObjImpl::getRowCount() const
void SdrTableObjImpl::LayoutTable( tools::Rectangle& rArea, bool bFitWidth, bool bFitHeight )
{
- if( mpLayouter && mpTableObj->GetModel() )
+ if(mpLayouter)
{
// Optimization: SdrTableObj::SetChanged() can call this very often, repeatedly
// with the same settings, noticeably increasing load time. Skip if already done.
@@ -749,20 +749,20 @@ sdr::contact::ViewContact* SdrTableObj::CreateObjectSpecificViewContact()
return new sdr::contact::ViewContactOfTableObj(*this);
}
-
-SdrTableObj::SdrTableObj(SdrModel* _pModel)
+SdrTableObj::SdrTableObj(SdrModel& rSdrModel)
+: SdrTextObj(rSdrModel)
{
- pModel = _pModel;
init( 1, 1 );
}
-
-SdrTableObj::SdrTableObj(SdrModel* _pModel, const ::tools::Rectangle& rNewRect, sal_Int32 nColumns, sal_Int32 nRows)
-: SdrTextObj( rNewRect )
-, maLogicRect( rNewRect )
+SdrTableObj::SdrTableObj(
+ SdrModel& rSdrModel,
+ const ::tools::Rectangle& rNewRect,
+ sal_Int32 nColumns,
+ sal_Int32 nRows)
+: SdrTextObj(rSdrModel, rNewRect)
+ ,maLogicRect(rNewRect)
{
- pModel = _pModel;
-
if( nColumns <= 0 )
nColumns = 1;
@@ -779,6 +779,16 @@ void SdrTableObj::init( sal_Int32 nColumns, sal_Int32 nRows )
mpImpl = new SdrTableObjImpl;
mpImpl->init( this, nColumns, nRows );
+
+ // Stuff done from old SetModel:
+ if( !maLogicRect.IsEmpty() )
+ {
+ maRect = maLogicRect;
+ mpImpl->LayoutTable( maRect, false, false );
+ }
+
+ // Also init from old SetModel:
+ mpImpl->SetModel(&getSdrModelFromSdrObject());
}
@@ -1349,28 +1359,6 @@ sal_uInt16 SdrTableObj::GetObjIdentifier() const
return static_cast<sal_uInt16>(OBJ_TABLE);
}
-
-void SdrTableObj::SetModel(SdrModel* pNewModel)
-{
- SdrModel* pOldModel = GetModel();
- if( pNewModel != pOldModel )
- {
- SdrTextObj::SetModel(pNewModel);
-
- if( mpImpl.is() )
- {
- mpImpl->SetModel( pNewModel );
-
- if( !maLogicRect.IsEmpty() )
- {
- maRect = maLogicRect;
- mpImpl->LayoutTable( maRect, false, false );
- }
- }
- }
-}
-
-
void SdrTableObj::TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText, tools::Rectangle* pAnchorRect, bool /*bLineWidth*/ ) const
{
if( mpImpl.is() )
@@ -1418,9 +1406,9 @@ void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, too
if (pPara)
{
- const bool bHitTest = pModel && (&pModel->GetHitTestOutliner() == &rOutliner);
+ const bool bHitTest(&getSdrModelFromSdrObject().GetHitTestOutliner() == &rOutliner);
+ const SdrTextObj* pTestObj(rOutliner.GetTextObj());
- const SdrTextObj* pTestObj = rOutliner.GetTextObj();
if( !pTestObj || !bHitTest || (pTestObj != this) || (pTestObj->GetOutlinerParaObject() != xCell->GetOutlinerParaObject()) )
{
if( bHitTest ) // #i33696# take back fix #i27510#
@@ -1565,12 +1553,9 @@ void SdrTableObj::TakeTextEditArea( const CellPos& rPos, Size* pPaperMin, Size*
aAnkSiz.AdjustWidth( -1 ); aAnkSiz.AdjustHeight( -1 ); // because GetSize() increments by one
Size aMaxSiz(aAnkSiz.Width(),1000000);
- if (pModel!=nullptr)
- {
- Size aTmpSiz(pModel->GetMaxObjSize());
- if (aTmpSiz.Height()!=0)
- aMaxSiz.setHeight(aTmpSiz.Height() );
- }
+ Size aTmpSiz(getSdrModelFromSdrObject().GetMaxObjSize());
+ if (aTmpSiz.Height()!=0)
+ aMaxSiz.setHeight(aTmpSiz.Height() );
CellRef xCell( mpImpl->getCell( rPos ) );
SdrTextVertAdjust eVAdj = xCell.is() ? xCell->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_TOP;
@@ -1661,9 +1646,9 @@ OUString SdrTableObj::TakeObjNamePlural() const
}
-SdrTableObj* SdrTableObj::Clone() const
+SdrTableObj* SdrTableObj::Clone(SdrModel* pTargetModel) const
{
- return CloneHelper< SdrTableObj >();
+ return CloneHelper< SdrTableObj >(pTargetModel);
}
SdrTableObj& SdrTableObj::operator=(const SdrTableObj& rObj)
@@ -1724,20 +1709,20 @@ bool SdrTableObj::BegTextEdit(SdrOutliner& rOutl)
mbInEditMode = true;
rOutl.Init( OutlinerMode::TextObject );
- rOutl.SetRefDevice( pModel->GetRefDevice() );
+ rOutl.SetRefDevice(getSdrModelFromSdrObject().GetRefDevice());
- bool bUpdMerk=rOutl.GetUpdateMode();
- if (bUpdMerk) rOutl.SetUpdateMode(false);
- Size aPaperMin;
- Size aPaperMax;
- tools::Rectangle aEditArea;
- TakeTextEditArea(&aPaperMin,&aPaperMax,&aEditArea,nullptr);
+ bool bUpdMerk=rOutl.GetUpdateMode();
+ if (bUpdMerk) rOutl.SetUpdateMode(false);
+ Size aPaperMin;
+ Size aPaperMax;
+ tools::Rectangle aEditArea;
+ TakeTextEditArea(&aPaperMin,&aPaperMax,&aEditArea,nullptr);
- rOutl.SetMinAutoPaperSize(aPaperMin);
- rOutl.SetMaxAutoPaperSize(aPaperMax);
- rOutl.SetPaperSize(aPaperMax);
+ rOutl.SetMinAutoPaperSize(aPaperMin);
+ rOutl.SetMaxAutoPaperSize(aPaperMax);
+ rOutl.SetPaperSize(aPaperMax);
- if (bUpdMerk) rOutl.SetUpdateMode(true);
+ if (bUpdMerk) rOutl.SetUpdateMode(true);
EEControlBits nStat=rOutl.GetControlWord();
nStat |= EEControlBits::AUTOPAGESIZE;
@@ -1758,14 +1743,14 @@ bool SdrTableObj::BegTextEdit(SdrOutliner& rOutl)
void SdrTableObj::EndTextEdit(SdrOutliner& rOutl)
{
- if (GetModel() && GetModel()->IsUndoEnabled() && !mpImpl->maUndos.empty())
+ if (getSdrModelFromSdrObject().IsUndoEnabled() && !mpImpl->maUndos.empty())
{
// These actions should be on the undo stack after text edit.
for (std::unique_ptr<SdrUndoAction>& pAction : mpImpl->maUndos)
- GetModel()->AddUndo(pAction.release());
+ getSdrModelFromSdrObject().AddUndo(pAction.release());
mpImpl->maUndos.clear();
- GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*this));
+ getSdrModelFromSdrObject().AddUndo(getSdrModelFromSdrObject().GetSdrUndoFactory().CreateUndoGeoObject(*this));
}
if(rOutl.IsModified())
@@ -1810,16 +1795,15 @@ void SdrTableObj::NbcSetOutlinerParaObject( OutlinerParaObject* pTextObject)
CellRef xCell( getActiveCell() );
if( xCell.is() )
{
- if( pModel )
+ // Update HitTestOutliner
+ const SdrTextObj* pTestObj(getSdrModelFromSdrObject().GetHitTestOutliner().GetTextObj());
+
+ if(pTestObj && pTestObj->GetOutlinerParaObject() == xCell->GetOutlinerParaObject())
{
- // Update HitTestOutliner
- const SdrTextObj* pTestObj = pModel->GetHitTestOutliner().GetTextObj();
- if( pTestObj && pTestObj->GetOutlinerParaObject() == xCell->GetOutlinerParaObject() )
- pModel->GetHitTestOutliner().SetTextObj( nullptr );
+ getSdrModelFromSdrObject().GetHitTestOutliner().SetTextObj(nullptr);
}
xCell->SetOutlinerParaObject( pTextObject );
-
SetTextSizeDirty();
NbcAdjustTextFrameWidthAndHeight();
}
@@ -1891,7 +1875,7 @@ bool SdrTableObj::AdjustTextFrameWidthAndHeight()
bool SdrTableObj::AdjustTextFrameWidthAndHeight(tools::Rectangle& rR, bool bHeight, bool bWidth) const
{
- if((pModel == nullptr) || rR.IsEmpty() || !mpImpl.is() || !mpImpl->mxTable.is() )
+ if(rR.IsEmpty() || !mpImpl.is() || !mpImpl->mxTable.is())
return false;
tools::Rectangle aRectangle( rR );
@@ -2203,7 +2187,7 @@ bool SdrTableObj::applySpecialDrag(SdrDragStat& rDrag)
if( pEdgeHdl )
{
- if( GetModel() && IsInserted() )
+ if( IsInserted() )
{
rDrag.SetEndDragChangesAttributes(true);
rDrag.SetEndDragChangesLayout(true);
@@ -2341,12 +2325,21 @@ void SdrTableObj::RestGeoData(const SdrObjGeoData& rGeo)
}
-SdrTableObj* SdrTableObj::CloneRange( const CellPos& rStart, const CellPos& rEnd )
+SdrTableObj* SdrTableObj::CloneRange(
+ const CellPos& rStart,
+ const CellPos& rEnd,
+ SdrModel& rTargetModel)
{
const sal_Int32 nColumns = rEnd.mnCol - rStart.mnCol + 1;
const sal_Int32 nRows = rEnd.mnRow - rStart.mnRow + 1;
- SdrTableObj* pNewTableObj = new SdrTableObj( GetModel(), GetCurrentBoundRect(), nColumns, nRows);
+ SdrTableObj* pNewTableObj(
+ new SdrTableObj(
+ rTargetModel,
+ GetCurrentBoundRect(),
+ nColumns,
+ nRows));
+
pNewTableObj->setTableStyleSettings( getTableStyleSettings() );
pNewTableObj->setTableStyle( getTableStyle() );
diff --git a/svx/source/table/tablecolumn.cxx b/svx/source/table/tablecolumn.cxx
index e6f1c4a77b6b..e4007b3b35cf 100644
--- a/svx/source/table/tablecolumn.cxx
+++ b/svx/source/table/tablecolumn.cxx
@@ -141,10 +141,10 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a
bool bOk = false;
bool bChange = false;
- SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
-
+ SdrModel& rModel(mxTableModel->getSdrTableObj()->getSdrModelFromSdrObject());
TableColumnUndo* pUndo = nullptr;
- if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled() )
+
+ if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && rModel.IsUndoEnabled() )
{
TableColumnRef xThis( this );
pUndo = new TableColumnUndo( xThis );
@@ -214,7 +214,7 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a
{
if( pUndo )
{
- pModel->AddUndo( pUndo );
+ rModel.AddUndo( pUndo );
pUndo = nullptr;
}
mxTableModel->setModified(true);
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index cc0b6de54254..aaf4af78bc8f 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -140,35 +140,44 @@ void SAL_CALL SvxTableControllerModifyListener::disposing( const css::lang::Even
// class SvxTableController
-rtl::Reference< sdr::SelectionController > CreateTableController( SdrObjEditView* pView, const SdrTableObj* pObj, const rtl::Reference< sdr::SelectionController >& xRefController )
+rtl::Reference< sdr::SelectionController > CreateTableController(
+ SdrView& rView,
+ const SdrTableObj& rObj,
+ const rtl::Reference< sdr::SelectionController >& xRefController )
{
- return SvxTableController::create( pView, pObj, xRefController );
+ return SvxTableController::create(rView, rObj, xRefController);
}
-rtl::Reference< sdr::SelectionController > SvxTableController::create( SdrObjEditView* pView, const SdrTableObj* pObj, const rtl::Reference< sdr::SelectionController >& xRefController )
+rtl::Reference< sdr::SelectionController > SvxTableController::create(
+ SdrView& rView,
+ const SdrTableObj& rObj,
+ const rtl::Reference< sdr::SelectionController >& xRefController )
{
if( xRefController.is() )
{
SvxTableController* pController = dynamic_cast< SvxTableController* >( xRefController.get() );
- if( pController && (pController->mxTableObj.get() == pObj) && (pController->mpView == pView) )
+
+ if(pController && (pController->mxTableObj.get() == &rObj) && (&pController->mrView == &rView))
+ {
return xRefController;
+ }
}
- return new SvxTableController( pView, pObj );
+
+ return new SvxTableController(rView, rObj);
}
-SvxTableController::SvxTableController( SdrObjEditView* pView, const SdrTableObj* pObj )
-: mbCellSelectionMode(false)
-, mbLeftButtonDown(false)
-, mpSelectionOverlay(nullptr)
-, mpView( dynamic_cast< SdrView* >( pView ) )
-, mxTableObj( const_cast< SdrTableObj* >( pObj ) )
-, mpModel( nullptr )
-, mnUpdateEvent( nullptr )
+SvxTableController::SvxTableController(
+ SdrView& rView,
+ const SdrTableObj& rObj)
+: mbCellSelectionMode(false)
+ ,mbLeftButtonDown(false)
+ ,mpSelectionOverlay(nullptr)
+ ,mrView(rView)
+ ,mxTableObj(const_cast< SdrTableObj* >(&rObj))
+ ,mnUpdateEvent( nullptr )
{
- mpModel = mxTableObj->GetModel();
-
mxTableObj->getActiveCellPos( maCursorFirstPos );
maCursorLastPos = maCursorFirstPos;
@@ -202,11 +211,14 @@ SvxTableController::~SvxTableController()
bool SvxTableController::onKeyInput(const KeyEvent& rKEvt, vcl::Window* pWindow )
{
- if( !checkTableObject() )
+ if(!checkTableObject())
return false;
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+
// check if we are read only
- if( mpModel && mpModel->IsReadOnly())
+ if( rModel.IsReadOnly())
{
switch( rKEvt.GetKeyCode().GetCode() )
{
@@ -252,7 +264,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
if (comphelper::LibreOfficeKit::isActive() && !pWindow)
{
// Tiled rendering: get the window that has the disabled map mode.
- if (OutputDevice* pOutputDevice = mpView->GetFirstOutputDevice())
+ if (OutputDevice* pOutputDevice = mrView.GetFirstOutputDevice())
{
if (pOutputDevice->GetOutDevType() == OUTDEV_WINDOW)
pWindow = static_cast<vcl::Window*>(pOutputDevice);
@@ -263,7 +275,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
return false;
SdrViewEvent aVEvt;
- if( !rMEvt.IsRight() && mpView->PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN, aVEvt) == SdrHitKind::Handle )
+ if( !rMEvt.IsRight() && mrView.PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN, aVEvt) == SdrHitKind::Handle )
return false;
TableHitKind eHit = mxTableObj->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), maMouseDownPos.mnCol, maMouseDownPos.mnRow);
@@ -284,7 +296,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
{
RemoveSelection();
- SdrHdl* pHdl = mpView->PickHandle(pixelToLogic(rMEvt.GetPosPixel(), pWindow));
+ SdrHdl* pHdl = mrView.PickHandle(pixelToLogic(rMEvt.GetPosPixel(), pWindow));
if( pHdl )
{
@@ -304,7 +316,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
if (comphelper::LibreOfficeKit::isActive() && rMEvt.GetClicks() == 2 && rMEvt.IsLeft() && eHit == TableHitKind::CellTextArea)
{
bool bEmptyOutliner = false;
- if (Outliner* pOutliner = mpView->GetTextEditOutliner())
+ if (Outliner* pOutliner = mrView.GetTextEditOutliner())
{
if (pOutliner->GetParagraphCount() == 1)
{
@@ -318,7 +330,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
StartSelection(maMouseDownPos);
setSelectedCells(maMouseDownPos, maMouseDownPos);
// Update graphic selection, should be hidden now.
- mpView->AdjustMarkHdl();
+ mrView.AdjustMarkHdl();
return true;
}
}
@@ -382,7 +394,7 @@ void SvxTableController::onSelectionHasChanged()
}
else
{
- const SdrMarkList& rMarkList= mpView->GetMarkedObjectList();
+ const SdrMarkList& rMarkList= mrView.GetMarkedObjectList();
if( rMarkList.GetMarkCount() == 1 )
bSelected = mxTableObj.get() == rMarkList.GetMark(0)->GetMarkedSdrObj();
/* fdo#46186 Selecting the table means selecting the entire cells */
@@ -407,12 +419,13 @@ void SvxTableController::onSelectionHasChanged()
void SvxTableController::GetState( SfxItemSet& rSet )
{
- if( !mxTable.is() || !mxTableObj.is() || !mxTableObj->GetModel() )
+ if(!mxTable.is() || !mxTableObj.is())
return;
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
std::unique_ptr<SfxItemSet> xSet;
-
- bool bVertDone = false;
+ bool bVertDone(false);
// Iterate over all requested items in the set.
SfxWhichIter aIter( rSet );
@@ -425,15 +438,11 @@ void SvxTableController::GetState( SfxItemSet& rSet )
case SID_TABLE_VERT_CENTER:
case SID_TABLE_VERT_NONE:
{
- if( !mxTable.is() || !mxTableObj->GetModel() )
- {
- rSet.DisableItem(nWhich);
- }
- else if(!bVertDone)
+ if(!bVertDone)
{
if (!xSet)
{
- xSet.reset(new SfxItemSet( mxTableObj->GetModel()->GetItemPool() ));
+ xSet.reset(new SfxItemSet(rModel.GetItemPool()));
MergeAttrFromSelectedCells(*xSet, false);
}
@@ -505,277 +514,270 @@ void SvxTableController::GetState( SfxItemSet& rSet )
void SvxTableController::onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs )
{
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
- if( !pTableObj )
+ if(!checkTableObject())
return;
- if( mxTable.is() ) try
- {
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ bool bInsertAfter = true;
+ sal_uInt16 nCount = 0;
- bool bInsertAfter = true;
- sal_uInt16 nCount = 0;
- if( pArgs )
+ if( pArgs )
+ {
+ const SfxPoolItem* pItem = nullptr;
+ pArgs->GetItemState(nSId, false, &pItem);
+ if (pItem)
{
- const SfxPoolItem* pItem = nullptr;
- pArgs->GetItemState(nSId, false, &pItem);
- if (pItem)
- {
- nCount = static_cast<const SfxInt16Item*>(pItem)->GetValue();
- if(SfxItemState::SET == pArgs->GetItemState(SID_TABLE_PARAM_INSERT_AFTER, true, &pItem))
- bInsertAfter = static_cast<const SfxBoolItem*>(pItem)->GetValue();
- }
+ nCount = static_cast<const SfxInt16Item*>(pItem)->GetValue();
+ if(SfxItemState::SET == pArgs->GetItemState(SID_TABLE_PARAM_INSERT_AFTER, true, &pItem))
+ bInsertAfter = static_cast<const SfxBoolItem*>(pItem)->GetValue();
}
+ }
- CellPos aStart, aEnd;
- if( hasSelectedCells() )
- {
- getSelectedCells( aStart, aEnd );
- }
- else
+ CellPos aStart, aEnd;
+ if( hasSelectedCells() )
+ {
+ getSelectedCells( aStart, aEnd );
+ }
+ else
+ {
+ if( bInsertAfter )
{
- if( bInsertAfter )
- {
- aStart.mnCol = mxTable->getColumnCount() - 1;
- aStart.mnRow = mxTable->getRowCount() - 1;
- aEnd = aStart;
- }
+ aStart.mnCol = mxTable->getColumnCount() - 1;
+ aStart.mnRow = mxTable->getRowCount() - 1;
+ aEnd = aStart;
}
+ }
- if( pTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ if( rTableObj.IsTextEditActive() )
+ mrView.SdrEndTextEdit(true);
- RemoveSelection();
+ RemoveSelection();
- const OUString sSize( "Size" );
+ const OUString sSize( "Size" );
+ const bool bUndo(rModel.IsUndoEnabled());
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ switch( nSId )
+ {
+ case SID_TABLE_INSERT_COL:
+ {
+ TableModelNotifyGuard aGuard( mxTable.get() );
- switch( nSId )
- {
- case SID_TABLE_INSERT_COL:
+ if( bUndo )
{
- TableModelNotifyGuard aGuard( mxTable.get() );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
+ }
- if( bUndo )
- {
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
- }
+ Reference< XTableColumns > xCols( mxTable->getColumns() );
+ const sal_Int32 nNewColumns = (nCount == 0) ? (aEnd.mnCol - aStart.mnCol + 1) : nCount;
+ const sal_Int32 nNewStartColumn = aEnd.mnCol + (bInsertAfter ? 1 : 0);
+ xCols->insertByIndex( nNewStartColumn, nNewColumns );
- Reference< XTableColumns > xCols( mxTable->getColumns() );
- const sal_Int32 nNewColumns = (nCount == 0) ? (aEnd.mnCol - aStart.mnCol + 1) : nCount;
- const sal_Int32 nNewStartColumn = aEnd.mnCol + (bInsertAfter ? 1 : 0);
- xCols->insertByIndex( nNewStartColumn, nNewColumns );
+ for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
+ {
+ // Resolves fdo#61540
+ // On Insert before, the reference column whose size is going to be
+ // used for newly created column(s) is wrong. As the new columns are
+ // inserted before the reference column, the reference column moved
+ // to the new position by no., of new columns i.e (earlier+newcolumns).
+ Reference< XPropertySet >(xCols->getByIndex(nNewStartColumn+nOffset), UNO_QUERY_THROW )->
+ setPropertyValue( sSize,
+ Reference< XPropertySet >(xCols->getByIndex( bInsertAfter?nNewStartColumn-1:nNewStartColumn+nNewColumns ), UNO_QUERY_THROW )->
+ getPropertyValue( sSize ) );
+ }
- for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
- {
- // Resolves fdo#61540
- // On Insert before, the reference column whose size is going to be
- // used for newly created column(s) is wrong. As the new columns are
- // inserted before the reference column, the reference column moved
- // to the new position by no., of new columns i.e (earlier+newcolumns).
- Reference< XPropertySet >(xCols->getByIndex(nNewStartColumn+nOffset), UNO_QUERY_THROW )->
- setPropertyValue( sSize,
- Reference< XPropertySet >(xCols->getByIndex( bInsertAfter?nNewStartColumn-1:nNewStartColumn+nNewColumns ), UNO_QUERY_THROW )->
- getPropertyValue( sSize ) );
- }
+ // Copy cell properties
+ sal_Int32 nPropSrcCol = (bInsertAfter ? aEnd.mnCol : aStart.mnCol + nNewColumns);
+ sal_Int32 nRowSpan = 0;
+ bool bNewSpan = false;
- // Copy cell properties
- sal_Int32 nPropSrcCol = (bInsertAfter ? aEnd.mnCol : aStart.mnCol + nNewColumns);
- sal_Int32 nRowSpan = 0;
- bool bNewSpan = false;
+ for( sal_Int32 nRow = 0; nRow < mxTable->getRowCount(); ++nRow )
+ {
+ CellRef xSourceCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nPropSrcCol, nRow ).get() ) );
- for( sal_Int32 nRow = 0; nRow < mxTable->getRowCount(); ++nRow )
+ // When we insert new COLUMNs, we want to copy ROW spans.
+ if (xSourceCell.is() && nRowSpan == 0)
{
- CellRef xSourceCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nPropSrcCol, nRow ).get() ) );
+ // we are not in a span yet. Let's find out if the current cell is in a span.
+ sal_Int32 nColSpan = sal_Int32();
+ sal_Int32 nSpanInfoCol = sal_Int32();
- // When we insert new COLUMNs, we want to copy ROW spans.
- if (xSourceCell.is() && nRowSpan == 0)
+ if( xSourceCell->getRowSpan() > 1 )
{
- // we are not in a span yet. Let's find out if the current cell is in a span.
- sal_Int32 nColSpan = sal_Int32();
- sal_Int32 nSpanInfoCol = sal_Int32();
-
- if( xSourceCell->getRowSpan() > 1 )
- {
- // The current cell is the top-left cell in a span.
- // Get the span info and propagate it to the target.
- nRowSpan = xSourceCell->getRowSpan();
- nColSpan = xSourceCell->getColumnSpan();
- nSpanInfoCol = nPropSrcCol;
- }
- else if( xSourceCell->isMerged() )
+ // The current cell is the top-left cell in a span.
+ // Get the span info and propagate it to the target.
+ nRowSpan = xSourceCell->getRowSpan();
+ nColSpan = xSourceCell->getColumnSpan();
+ nSpanInfoCol = nPropSrcCol;
+ }
+ else if( xSourceCell->isMerged() )
+ {
+ // The current cell is a middle cell in a 2D span.
+ // Look for the top-left cell in the span.
+ for( nSpanInfoCol = nPropSrcCol - 1; nSpanInfoCol >= 0; --nSpanInfoCol )
{
- // The current cell is a middle cell in a 2D span.
- // Look for the top-left cell in the span.
- for( nSpanInfoCol = nPropSrcCol - 1; nSpanInfoCol >= 0; --nSpanInfoCol )
+ CellRef xMergeInfoCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nSpanInfoCol, nRow ).get() ) );
+ if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
{
- CellRef xMergeInfoCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nSpanInfoCol, nRow ).get() ) );
- if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
- {
- nRowSpan = xMergeInfoCell->getRowSpan();
- nColSpan = xMergeInfoCell->getColumnSpan();
- break;
- }
+ nRowSpan = xMergeInfoCell->getRowSpan();
+ nColSpan = xMergeInfoCell->getColumnSpan();
+ break;
}
- if( nRowSpan == 1 )
- nRowSpan = 0;
}
-
- // The target columns are outside the span; Start a new span.
- if( nRowSpan > 0 && ( nNewStartColumn < nSpanInfoCol || nSpanInfoCol + nColSpan <= nNewStartColumn ) )
- bNewSpan = true;
+ if( nRowSpan == 1 )
+ nRowSpan = 0;
}
- // Now copy the properties from the source to the targets
- for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
+ // The target columns are outside the span; Start a new span.
+ if( nRowSpan > 0 && ( nNewStartColumn < nSpanInfoCol || nSpanInfoCol + nColSpan <= nNewStartColumn ) )
+ bNewSpan = true;
+ }
+
+ // Now copy the properties from the source to the targets
+ for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
+ {
+ CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nNewStartColumn + nOffset, nRow ).get() ) );
+ if( xTargetCell.is() )
{
- CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nNewStartColumn + nOffset, nRow ).get() ) );
- if( xTargetCell.is() )
+ if( nRowSpan > 0 )
{
- if( nRowSpan > 0 )
- {
- if( bNewSpan )
- xTargetCell->merge( 1, nRowSpan );
- else
- xTargetCell->setMerged();
- }
- xTargetCell->copyFormatFrom( xSourceCell );
+ if( bNewSpan )
+ xTargetCell->merge( 1, nRowSpan );
+ else
+ xTargetCell->setMerged();
}
+ xTargetCell->copyFormatFrom( xSourceCell );
}
+ }
- if( nRowSpan > 0 )
- {
- --nRowSpan;
- bNewSpan = false;
- }
+ if( nRowSpan > 0 )
+ {
+ --nRowSpan;
+ bNewSpan = false;
}
+ }
- if( bUndo )
- mpModel->EndUndo();
+ if( bUndo )
+ rModel.EndUndo();
- aStart.mnCol = nNewStartColumn;
- aStart.mnRow = 0;
- aEnd.mnCol = aStart.mnCol + nNewColumns - 1;
- aEnd.mnRow = mxTable->getRowCount() - 1;
- break;
- }
+ aStart.mnCol = nNewStartColumn;
+ aStart.mnRow = 0;
+ aEnd.mnCol = aStart.mnCol + nNewColumns - 1;
+ aEnd.mnRow = mxTable->getRowCount() - 1;
+ break;
+ }
- case SID_TABLE_INSERT_ROW:
+ case SID_TABLE_INSERT_ROW:
+ {
+ TableModelNotifyGuard aGuard( mxTable.get() );
+
+ if( bUndo )
{
- TableModelNotifyGuard aGuard( mxTable.get() );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_INSROW ) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
+ }
- if( bUndo )
- {
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW ) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
- }
+ Reference< XTableRows > xRows( mxTable->getRows() );
+ const sal_Int32 nNewRows = (nCount == 0) ? (aEnd.mnRow - aStart.mnRow + 1) : nCount;
+ const sal_Int32 nNewRowStart = aEnd.mnRow + (bInsertAfter ? 1 : 0);
+ xRows->insertByIndex( nNewRowStart, nNewRows );
- Reference< XTableRows > xRows( mxTable->getRows() );
- const sal_Int32 nNewRows = (nCount == 0) ? (aEnd.mnRow - aStart.mnRow + 1) : nCount;
- const sal_Int32 nNewRowStart = aEnd.mnRow + (bInsertAfter ? 1 : 0);
- xRows->insertByIndex( nNewRowStart, nNewRows );
+ for( sal_Int32 nOffset = 0; nOffset < nNewRows; nOffset++ )
+ {
+ Reference< XPropertySet >( xRows->getByIndex( aEnd.mnRow + nOffset + 1 ), UNO_QUERY_THROW )->
+ setPropertyValue( sSize,
+ Reference< XPropertySet >( xRows->getByIndex( aStart.mnRow + nOffset ), UNO_QUERY_THROW )->
+ getPropertyValue( sSize ) );
+ }
- for( sal_Int32 nOffset = 0; nOffset < nNewRows; nOffset++ )
- {
- Reference< XPropertySet >( xRows->getByIndex( aEnd.mnRow + nOffset + 1 ), UNO_QUERY_THROW )->
- setPropertyValue( sSize,
- Reference< XPropertySet >( xRows->getByIndex( aStart.mnRow + nOffset ), UNO_QUERY_THROW )->
- getPropertyValue( sSize ) );
- }
+ // Copy the cell properties
+ sal_Int32 nPropSrcRow = (bInsertAfter ? aEnd.mnRow : aStart.mnRow + nNewRows);
+ sal_Int32 nColSpan = 0;
+ bool bNewSpan = false;
- // Copy the cell properties
- sal_Int32 nPropSrcRow = (bInsertAfter ? aEnd.mnRow : aStart.mnRow + nNewRows);
- sal_Int32 nColSpan = 0;
- bool bNewSpan = false;
+ for( sal_Int32 nCol = 0; nCol < mxTable->getColumnCount(); ++nCol )
+ {
+ CellRef xSourceCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nPropSrcRow ).get() ) );
- for( sal_Int32 nCol = 0; nCol < mxTable->getColumnCount(); ++nCol )
- {
- CellRef xSourceCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nPropSrcRow ).get() ) );
+ if (!xSourceCell.is())
+ continue;
- if (!xSourceCell.is())
- continue;
+ // When we insert new ROWs, we want to copy COLUMN spans.
+ if( nColSpan == 0 )
+ {
+ // we are not in a span yet. Let's find out if the current cell is in a span.
+ sal_Int32 nRowSpan = sal_Int32();
+ sal_Int32 nSpanInfoRow = sal_Int32();
- // When we insert new ROWs, we want to copy COLUMN spans.
- if( nColSpan == 0 )
+ if( xSourceCell->getColumnSpan() > 1 )
{
- // we are not in a span yet. Let's find out if the current cell is in a span.
- sal_Int32 nRowSpan = sal_Int32();
- sal_Int32 nSpanInfoRow = sal_Int32();
-
- if( xSourceCell->getColumnSpan() > 1 )
- {
- // The current cell is the top-left cell in a span.
- // Get the span info and propagate it to the target.
- nColSpan = xSourceCell->getColumnSpan();
- nRowSpan = xSourceCell->getRowSpan();
- nSpanInfoRow = nPropSrcRow;
- }
- else if( xSourceCell->isMerged() )
- {
- // The current cell is a middle cell in a 2D span.
- // Look for the top-left cell in the span.
- for( nSpanInfoRow = nPropSrcRow - 1; nSpanInfoRow >= 0; --nSpanInfoRow )
- {
- CellRef xMergeInfoCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nSpanInfoRow ).get() ) );
- if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
- {
- nColSpan = xMergeInfoCell->getColumnSpan();
- nRowSpan = xMergeInfoCell->getRowSpan();
- break;
- }
- }
- if( nColSpan == 1 )
- nColSpan = 0;
- }
-
- // Inserted rows are outside the span; Start a new span.
- if( nColSpan > 0 && ( nNewRowStart < nSpanInfoRow || nSpanInfoRow + nRowSpan <= nNewRowStart ) )
- bNewSpan = true;
+ // The current cell is the top-left cell in a span.
+ // Get the span info and propagate it to the target.
+ nColSpan = xSourceCell->getColumnSpan();
+ nRowSpan = xSourceCell->getRowSpan();
+ nSpanInfoRow = nPropSrcRow;
}
-
- // Now copy the properties from the source to the targets
- for( sal_Int32 nOffset = 0; nOffset < nNewRows; ++nOffset )
+ else if( xSourceCell->isMerged() )
{
- CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nNewRowStart + nOffset ).get() ) );
- if( xTargetCell.is() )
+ // The current cell is a middle cell in a 2D span.
+ // Look for the top-left cell in the span.
+ for( nSpanInfoRow = nPropSrcRow - 1; nSpanInfoRow >= 0; --nSpanInfoRow )
{
- if( nColSpan > 0 )
+ CellRef xMergeInfoCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nSpanInfoRow ).get() ) );
+ if (xMergeInfoCell.is() && !xMergeInfoCell->isMerged())
{
- if( bNewSpan )
- xTargetCell->merge( nColSpan, 1 );
- else
- xTargetCell->setMerged();
+ nColSpan = xMergeInfoCell->getColumnSpan();
+ nRowSpan = xMergeInfoCell->getRowSpan();
+ break;
}
- xTargetCell->copyFormatFrom( xSourceCell );
}
+ if( nColSpan == 1 )
+ nColSpan = 0;
}
- if( nColSpan > 0 )
+ // Inserted rows are outside the span; Start a new span.
+ if( nColSpan > 0 && ( nNewRowStart < nSpanInfoRow || nSpanInfoRow + nRowSpan <= nNewRowStart ) )
+ bNewSpan = true;
+ }
+
+ // Now copy the properties from the source to the targets
+ for( sal_Int32 nOffset = 0; nOffset < nNewRows; ++nOffset )
+ {
+ CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nNewRowStart + nOffset ).get() ) );
+ if( xTargetCell.is() )
{
- --nColSpan;
- bNewSpan = false;
+ if( nColSpan > 0 )
+ {
+ if( bNewSpan )
+ xTargetCell->merge( nColSpan, 1 );
+ else
+ xTargetCell->setMerged();
+ }
+ xTargetCell->copyFormatFrom( xSourceCell );
}
}
- if( bUndo )
- mpModel->EndUndo();
-
- aStart.mnCol = 0;
- aStart.mnRow = nNewRowStart;
- aEnd.mnCol = mxTable->getColumnCount() - 1;
- aEnd.mnRow = aStart.mnRow + nNewRows - 1;
- break;
- }
+ if( nColSpan > 0 )
+ {
+ --nColSpan;
+ bNewSpan = false;
+ }
}
- StartSelection( aStart );
- UpdateSelection( aEnd );
+ if( bUndo )
+ rModel.EndUndo();
+
+ aStart.mnCol = 0;
+ aStart.mnRow = nNewRowStart;
+ aEnd.mnCol = mxTable->getColumnCount() - 1;
+ aEnd.mnRow = aStart.mnRow + nNewRows - 1;
+ break;
}
- catch( Exception& )
- {
- OSL_FAIL("svx::SvxTableController::onInsert(), exception caught!");
}
+
+ StartSelection( aStart );
+ UpdateSelection( aEnd );
}
@@ -791,7 +793,7 @@ void SvxTableController::onDelete( sal_uInt16 nSId )
getSelectedCells( aStart, aEnd );
if( pTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ mrView.SdrEndTextEdit(true);
RemoveSelection();
@@ -830,7 +832,7 @@ void SvxTableController::onDelete( sal_uInt16 nSId )
}
if( bDeleteTable )
- mpView->DeleteMarkedObj();
+ mrView.DeleteMarkedObj();
else
UpdateTableShape();
}
@@ -886,15 +888,16 @@ namespace
void SvxTableController::onFormatTable( SfxRequest const & rReq )
{
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
- if( !pTableObj )
+ if(!mxTableObj.is())
return;
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
const SfxItemSet* pArgs = rReq.GetArgs();
- if( !pArgs && pTableObj->GetModel() )
+ if(!pArgs)
{
- SfxItemSet aNewAttr( pTableObj->GetModel()->GetItemPool() );
+ SfxItemSet aNewAttr(rModel.GetItemPool());
// merge drawing layer text distance items into SvxBoxItem used by the dialog
SvxBoxItem aBoxItem(mergeDrawinglayerTextDistancesAndSvxBoxItem(aNewAttr));
@@ -907,7 +910,11 @@ void SvxTableController::onFormatTable( SfxRequest const & rReq )
aNewAttr.Put( aBoxInfoItem );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- ScopedVclPtr<SfxAbstractTabDialog> xDlg( pFact ? pFact->CreateSvxFormatCellsDialog( &aNewAttr, pTableObj->GetModel(), pTableObj) : nullptr );
+ ScopedVclPtr<SfxAbstractTabDialog> xDlg( pFact ? pFact->CreateSvxFormatCellsDialog(
+ &aNewAttr,
+ rModel,
+ &rTableObj) : nullptr );
+
// Even Cancel Button is returning positive(101) value,
if (xDlg.get() && xDlg->Execute() == RET_OK)
{
@@ -1026,16 +1033,19 @@ void SvxTableController::Execute( SfxRequest& rReq )
void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
{
- SdrTableObj* pTableObj = mxTableObj.get();
- SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr;
+ if(!checkTableObject())
+ return;
- if( !pTableObj || !pModel || !pArgs || (SfxItemState::SET != pArgs->GetItemState(SID_TABLE_STYLE, false)) )
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+
+ if(!pArgs || (SfxItemState::SET != pArgs->GetItemState(SID_TABLE_STYLE, false)))
return;
const SfxStringItem* pArg = dynamic_cast< const SfxStringItem* >( &pArgs->Get( SID_TABLE_STYLE ) );
if( pArg && mxTable.is() ) try
{
- Reference< XStyleFamiliesSupplier > xSFS( pModel->getUnoModel(), UNO_QUERY_THROW );
+ Reference< XStyleFamiliesSupplier > xSFS( rModel.getUnoModel(), UNO_QUERY_THROW );
Reference< XNameAccess > xFamilyNameAccess( xSFS->getStyleFamilies(), UNO_QUERY_THROW );
const OUString sFamilyName( "table" );
Reference< XNameAccess > xTableFamilyAccess( xFamilyNameAccess->getByName( sFamilyName ), UNO_QUERY_THROW );
@@ -1045,15 +1055,15 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
// found table style with the same name
Reference< XIndexAccess > xNewTableStyle( xTableFamilyAccess->getByName( pArg->GetValue() ), UNO_QUERY_THROW );
- const bool bUndo = pModel->IsUndoEnabled();
+ const bool bUndo = rModel.IsUndoEnabled();
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE) );
- pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ rModel.BegUndo(ImpGetResStr(STR_TABLE_STYLE));
+ rModel.AddUndo(new TableStyleUndo(rTableObj));
}
- pTableObj->setTableStyle( xNewTableStyle );
+ rTableObj.setTableStyle( xNewTableStyle );
const sal_Int32 nRowCount = mxTable->getRowCount();
const sal_Int32 nColCount = mxTable->getColumnCount();
@@ -1098,7 +1108,7 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
}
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
}
}
catch( Exception& )
@@ -1109,14 +1119,13 @@ void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
void SvxTableController::SetTableStyleSettings( const SfxItemSet* pArgs )
{
- SdrTableObj* pTableObj = mxTableObj.get();
- SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr;
-
- if( !pTableObj || !pModel )
+ if(!checkTableObject())
return;
- TableStyleSettings aSettings( pTableObj->getTableStyleSettings() );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ TableStyleSettings aSettings(rTableObj.getTableStyleSettings() );
const SfxPoolItem *pPoolItem=nullptr;
if( SfxItemState::SET == pArgs->GetItemState(ID_VAL_USEFIRSTROWSTYLE, false,&pPoolItem) )
@@ -1137,36 +1146,38 @@ void SvxTableController::SetTableStyleSettings( const SfxItemSet* pArgs )
if( SfxItemState::SET == pArgs->GetItemState(ID_VAL_USEBANDINGCOLUMNSTYLE, false,&pPoolItem) )
aSettings.mbUseColumnBanding = static_cast< const SfxBoolItem* >(pPoolItem)->GetValue();
- if( aSettings == pTableObj->getTableStyleSettings() )
+ if( aSettings == rTableObj.getTableStyleSettings() )
return;
- const bool bUndo = pModel->IsUndoEnabled();
+ const bool bUndo(rModel.IsUndoEnabled());
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE_SETTINGS) );
- pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_STYLE_SETTINGS) );
+ rModel.AddUndo(new TableStyleUndo(rTableObj));
}
- pTableObj->setTableStyleSettings( aSettings );
+ rTableObj.setTableStyleSettings( aSettings );
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
}
void SvxTableController::SetVertical( sal_uInt16 nSId )
{
- SdrTableObj* pTableObj = mxTableObj.get();
- if( !mxTable.is() || !pTableObj )
+ if(!checkTableObject())
return;
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+
TableModelNotifyGuard aGuard( mxTable.get() );
+ const bool bUndo(rModel.IsUndoEnabled());
- bool bUndo = mpModel && mpModel->IsUndoEnabled();
if (bUndo)
{
- mpModel->BegUndo(ImpGetResStr(STR_TABLE_NUMFORMAT));
- mpModel->AddUndo(mpModel->GetSdrUndoFactory().CreateUndoAttrObject(*pTableObj));
+ rModel.BegUndo(ImpGetResStr(STR_TABLE_NUMFORMAT));
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoAttrObject(rTableObj));
}
CellPos aStart, aEnd;
@@ -1208,7 +1219,7 @@ void SvxTableController::SetVertical( sal_uInt16 nSId )
UpdateTableShape();
if (bUndo)
- mpModel->EndUndo();
+ rModel.EndUndo();
}
void SvxTableController::MergeMarkedCells()
@@ -1219,7 +1230,7 @@ void SvxTableController::MergeMarkedCells()
if( pTableObj )
{
if( pTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ mrView.SdrEndTextEdit(true);
TableModelNotifyGuard aGuard( mxTable.get() );
MergeRange( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow );
@@ -1228,102 +1239,102 @@ void SvxTableController::MergeMarkedCells()
void SvxTableController::SplitMarkedCells()
{
- if( mxTable.is() )
- {
- CellPos aStart, aEnd;
- getSelectedCells( aStart, aEnd );
+ if(!checkTableObject() || !mxTable.is())
+ return;
- SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- ScopedVclPtr< SvxAbstractSplitTableDialog > xDlg( pFact ? pFact->CreateSvxSplitTableDialog( nullptr, false, 99 ) : nullptr );
- if( xDlg.get() && xDlg->Execute() )
- {
- const sal_Int32 nCount = xDlg->GetCount() - 1;
- if( nCount < 1 )
- return;
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ ScopedVclPtr< SvxAbstractSplitTableDialog > xDlg( pFact ? pFact->CreateSvxSplitTableDialog( nullptr, false, 99 ) : nullptr );
- getSelectedCells( aStart, aEnd );
+ if( xDlg.get() && xDlg->Execute() )
+ {
+ const sal_Int32 nCount = xDlg->GetCount() - 1;
- Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow ) ), UNO_QUERY_THROW );
+ if( nCount < 1 )
+ return;
- const sal_Int32 nRowCount = mxTable->getRowCount();
- const sal_Int32 nColCount = mxTable->getColumnCount();
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow ) ), UNO_QUERY_THROW );
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+ const sal_Int32 nColCount = mxTable->getColumnCount();
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ if( rTableObj.IsTextEditActive() )
+ mrView.SdrEndTextEdit(true);
- SdrTableObj* pTableObj = mxTableObj.get();
- if( pTableObj )
- {
- if( pTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ TableModelNotifyGuard aGuard( mxTable.get() );
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
- TableModelNotifyGuard aGuard( mxTable.get() );
+ if( bUndo )
+ {
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
+ }
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
- if( bUndo )
- {
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
- }
+ if( xDlg->IsHorizontal() )
+ {
+ xRange->split( 0, nCount );
+ }
+ else
+ {
+ xRange->split( nCount, 0 );
+ }
- if( xDlg->IsHorizontal() )
- {
- xRange->split( 0, nCount );
- }
- else
- {
- xRange->split( nCount, 0 );
- }
+ if( bUndo )
+ rModel.EndUndo();
- if( bUndo )
- mpModel->EndUndo();
- }
- aEnd.mnRow += mxTable->getRowCount() - nRowCount;
- aEnd.mnCol += mxTable->getColumnCount() - nColCount;
+ aEnd.mnRow += mxTable->getRowCount() - nRowCount;
+ aEnd.mnCol += mxTable->getColumnCount() - nColCount;
- setSelectedCells( aStart, aEnd );
- }
+ setSelectedCells( aStart, aEnd );
}
}
void SvxTableController::DistributeColumns()
{
- SdrTableObj* pTableObj = mxTableObj.get();
- if( pTableObj )
- {
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
- if( bUndo )
- {
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_COLUMNS) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
- }
+ if(!checkTableObject())
+ return;
- CellPos aStart, aEnd;
- getSelectedCells( aStart, aEnd );
- pTableObj->DistributeColumns( aStart.mnCol, aEnd.mnCol );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
- if( bUndo )
- mpModel->EndUndo();
+ if( bUndo )
+ {
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_COLUMNS) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
}
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ rTableObj.DistributeColumns( aStart.mnCol, aEnd.mnCol );
+
+ if( bUndo )
+ rModel.EndUndo();
}
void SvxTableController::DistributeRows()
{
- SdrTableObj* pTableObj = mxTableObj.get();
- if( pTableObj )
- {
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
- if( bUndo )
- {
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_ROWS) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
- }
+ if(!checkTableObject())
+ return;
- CellPos aStart, aEnd;
- getSelectedCells( aStart, aEnd );
- pTableObj->DistributeRows( aStart.mnRow, aEnd.mnRow );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
- if( bUndo )
- mpModel->EndUndo();
+ if( bUndo )
+ {
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_ROWS) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
}
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ rTableObj.DistributeRows( aStart.mnRow, aEnd.mnRow );
+
+ if( bUndo )
+ rModel.EndUndo();
}
bool SvxTableController::HasMarked()
@@ -1333,12 +1344,15 @@ bool SvxTableController::HasMarked()
bool SvxTableController::DeleteMarked()
{
- if (!HasMarked())
+ if(!checkTableObject() || !HasMarked())
return false;
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
+
if (bUndo)
- mpModel->BegUndo(ImpGetResStr(STR_TABLE_DELETE_CELL_CONTENTS));
+ rModel.BegUndo(ImpGetResStr(STR_TABLE_DELETE_CELL_CONTENTS));
CellPos aStart, aEnd;
getSelectedCells( aStart, aEnd );
@@ -1357,7 +1371,7 @@ bool SvxTableController::DeleteMarked()
}
if (bUndo)
- mpModel->EndUndo();
+ rModel.EndUndo();
UpdateTableShape();
return true;
@@ -1444,8 +1458,7 @@ SvxTableController::TblAction SvxTableController::getKeyboardAction(const KeyEve
{
const bool bMod1 = rKEvt.GetKeyCode().IsMod1(); // ctrl
const bool bMod2 = rKEvt.GetKeyCode().IsMod2(); // Alt
-
- const bool bTextEdit = mpView->IsTextEdit();
+ const bool bTextEdit = mrView.IsTextEdit();
TblAction nAction = TblAction::HandledByView;
@@ -1576,7 +1589,7 @@ SvxTableController::TblAction SvxTableController::getKeyboardAction(const KeyEve
}
bool bTextMove = false;
- OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+ OutlinerView* pOLV = mrView.GetTextEditOutlinerView();
if( pOLV )
{
RemoveSelection();
@@ -1740,7 +1753,7 @@ bool SvxTableController::executeAction(TblAction nAction, bool bSelect, vcl::Win
void SvxTableController::gotoCell(const CellPos& rPos, bool bSelect, vcl::Window* pWindow, TblAction nAction /*= TblAction::NONE */)
{
if( mxTableObj.is() && mxTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ mrView.SdrEndTextEdit(true);
if( bSelect )
{
@@ -1787,22 +1800,29 @@ const CellPos& SvxTableController::getSelectionEnd()
void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow )
{
- if( mxTable.is() ) try
+ if(!checkTableObject() || !mxTable.is())
+ return;
+
+ try
{
Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( nFirstCol, nFirstRow,nLastCol, nLastRow ) ), UNO_QUERY_THROW );
+
if( xRange->isMergeable() )
{
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
+
if( bUndo )
{
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
- mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*mxTableObj.get()) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
+ rModel.AddUndo(rModel.GetSdrUndoFactory().CreateUndoGeoObject(rTableObj));
}
xRange->merge();
if( bUndo )
- mpModel->EndUndo();
+ rModel.EndUndo();
}
}
catch( Exception& )
@@ -1848,16 +1868,20 @@ void SvxTableController::findMergeOrigin( CellPos& rPos )
void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, TblAction nAction /*= TblAction::NONE */)
{
- SdrPageView* pPV = mpView->GetSdrPageView();
+ SdrPageView* pPV(mrView.GetSdrPageView());
- sdr::table::SdrTableObj* pTableObj = mxTableObj.get();
- if( pTableObj && pTableObj->GetPage() == pPV->GetPage() )
+ if(nullptr == pPV || !checkTableObject())
+ return;
+
+ SdrTableObj& rTableObj(*mxTableObj.get());
+
+ if(rTableObj.GetPage() == pPV->GetPage())
{
bool bEmptyOutliner = false;
- if(!pTableObj->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
+ if(!rTableObj.GetOutlinerParaObject() && mrView.GetTextEditOutliner())
{
- ::Outliner* pOutl = mpView->GetTextEditOutliner();
+ ::Outliner* pOutl = mrView.GetTextEditOutliner();
sal_Int32 nParaCnt = pOutl->GetParagraphCount();
Paragraph* p1stPara = pOutl->GetParagraph( 0 );
@@ -1874,28 +1898,30 @@ void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, Tbl
CellPos aPos( rPos );
findMergeOrigin( aPos );
- if( pTableObj != mpView->GetTextEditObject() || bEmptyOutliner || !pTableObj->IsTextEditActive( aPos ) )
+ if( &rTableObj != mrView.GetTextEditObject() || bEmptyOutliner || !rTableObj.IsTextEditActive( aPos ) )
{
- if( pTableObj->IsTextEditActive() )
- mpView->SdrEndTextEdit(true);
+ if( rTableObj.IsTextEditActive() )
+ mrView.SdrEndTextEdit(true);
- pTableObj->setActiveCell( aPos );
+ rTableObj.setActiveCell( aPos );
// create new outliner, owner will be the SdrObjEditView
- SdrOutliner* pOutl = mpModel ? SdrMakeOutliner(OutlinerMode::OutlineObject, *mpModel) : nullptr;
- if (pOutl && pTableObj->IsVerticalWriting())
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ SdrOutliner* pOutl(SdrMakeOutliner(OutlinerMode::OutlineObject, rModel));
+
+ if (pOutl && rTableObj.IsVerticalWriting())
pOutl->SetVertical( true );
- if (mpView->SdrBeginTextEdit(pTableObj, pPV, pWindow, true, pOutl))
+ if (mrView.SdrBeginTextEdit(&rTableObj, pPV, pWindow, true, pOutl))
{
maCursorLastPos = maCursorFirstPos = rPos;
- OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+ OutlinerView* pOLV = mrView.GetTextEditOutlinerView();
// Move cursor to end of text
ESelection aNewSelection;
- const WritingMode eMode = pTableObj->GetWritingMode();
+ const WritingMode eMode = rTableObj.GetWritingMode();
if (((nAction == TblAction::GotoLeftCell) || (nAction == TblAction::GotoRightCell)) && (eMode != WritingMode_TB_RL))
{
const bool bLast = ((nAction == TblAction::GotoLeftCell) && (eMode == WritingMode_LR_TB)) ||
@@ -1913,11 +1939,11 @@ void SvxTableController::EditCell(const CellPos& rPos, vcl::Window* pWindow, Tbl
void SvxTableController::StopTextEdit()
{
- if(mpView->IsTextEdit())
+ if(mrView.IsTextEdit())
{
- mpView->SdrEndTextEdit();
- mpView->SetCurrentObj(OBJ_TABLE);
- mpView->SetEditMode(SdrViewEditMode::Edit);
+ mrView.SdrEndTextEdit();
+ mrView.SetCurrentObj(OBJ_TABLE);
+ mrView.SetEditMode(SdrViewEditMode::Edit);
}
}
@@ -1971,7 +1997,7 @@ void SvxTableController::getSelectedCells( CellPos& rFirst, CellPos& rLast )
}
while(bExt);
}
- else if( mpView && mpView->IsTextEdit() )
+ else if(mrView.IsTextEdit())
{
rFirst = getSelectionStart();
findMergeOrigin( rFirst );
@@ -2010,7 +2036,7 @@ void SvxTableController::StartSelection( const CellPos& rPos )
StopTextEdit();
mbCellSelectionMode = true;
maCursorLastPos = maCursorFirstPos = rPos;
- mpView->MarkListHasChanged();
+ mrView.MarkListHasChanged();
}
@@ -2025,53 +2051,58 @@ void SvxTableController::setSelectedCells( const CellPos& rStart, const CellPos&
bool SvxTableController::ChangeFontSize(bool bGrow, const FontList* pFontList)
{
- if (mxTable.is())
- {
- if (mpView->IsTextEdit())
- return true;
+ if(!checkTableObject() || !mxTable.is())
+ return false;
- CellPos aStart, aEnd;
- if(hasSelectedCells())
- {
- getSelectedCells(aStart, aEnd);
- }
- else
- {
- aStart.mnRow = 0;
- aStart.mnCol = 0;
- aEnd.mnRow = mxTable->getRowCount() - 1;
- aEnd.mnCol = mxTable->getColumnCount() - 1;
- }
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
- for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++)
+ if (mrView.IsTextEdit())
+ return true;
+
+ CellPos aStart, aEnd;
+
+ if(hasSelectedCells())
+ {
+ getSelectedCells(aStart, aEnd);
+ }
+ else
+ {
+ aStart.mnRow = 0;
+ aStart.mnCol = 0;
+ aEnd.mnRow = mxTable->getRowCount() - 1;
+ aEnd.mnCol = mxTable->getColumnCount() - 1;
+ }
+
+ for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++)
+ {
+ for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++)
{
- for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++)
+ CellRef xCell(dynamic_cast< Cell* >(mxTable->getCellByPosition(nCol, nRow).get()));
+ if (xCell.is())
{
- CellRef xCell(dynamic_cast< Cell* >(mxTable->getCellByPosition(nCol, nRow).get()));
- if (xCell.is())
- {
- if (mpModel && mpModel->IsUndoEnabled())
- xCell->AddUndo();
+ if (rModel.IsUndoEnabled())
+ xCell->AddUndo();
- SfxItemSet aCellSet(xCell->GetItemSet());
- if (EditView::ChangeFontSize(bGrow, aCellSet, pFontList))
- {
- xCell->SetMergedItemSetAndBroadcast(aCellSet, false);
- }
+ SfxItemSet aCellSet(xCell->GetItemSet());
+ if (EditView::ChangeFontSize(bGrow, aCellSet, pFontList))
+ {
+ xCell->SetMergedItemSetAndBroadcast(aCellSet, false);
}
}
}
- UpdateTableShape();
- return true;
}
- return false;
+
+ UpdateTableShape();
+
+ return true;
}
void SvxTableController::UpdateSelection( const CellPos& rPos )
{
maCursorLastPos = rPos;
- mpView->MarkListHasChanged();
+ mrView.MarkListHasChanged();
}
@@ -2099,7 +2130,7 @@ void SvxTableController::RemoveSelection()
if( mbCellSelectionMode )
{
mbCellSelectionMode = false;
- mpView->MarkListHasChanged();
+ mrView.MarkListHasChanged();
}
}
@@ -2136,14 +2167,14 @@ void SvxTableController::updateSelectionOverlay()
aRanges.push_back( a2DRange );
::Color aHighlight( COL_BLUE );
- OutputDevice* pOutDev = mpView->GetFirstOutputDevice();
+ OutputDevice* pOutDev = mrView.GetFirstOutputDevice();
if( pOutDev )
aHighlight = pOutDev->GetSettings().GetStyleSettings().GetHighlightColor();
- const sal_uInt32 nCount = mpView->PaintWindowCount();
+ const sal_uInt32 nCount = mrView.PaintWindowCount();
for( sal_uInt32 nIndex = 0; nIndex < nCount; nIndex++ )
{
- SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(nIndex);
+ SdrPaintWindow* pPaintWindow = mrView.GetPaintWindow(nIndex);
if( pPaintWindow )
{
rtl::Reference < sdr::overlay::OverlayManager > xOverlayManager = pPaintWindow->GetOverlayManager();
@@ -2500,13 +2531,15 @@ void SvxTableController::UpdateTableShape()
void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll)
{
- if( !mxTable.is() )
+ if(!checkTableObject() || !mxTable.is())
return;
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
if( bUndo )
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_NUMFORMAT) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_NUMFORMAT) );
CellPos aStart, aEnd;
getSelectedCells( aStart, aEnd );
@@ -2544,7 +2577,7 @@ void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bR
UpdateTableShape();
if( bUndo )
- mpModel->EndUndo();
+ rModel.EndUndo();
}
@@ -2554,9 +2587,9 @@ bool SvxTableController::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAtt
{
MergeAttrFromSelectedCells( rTargetSet, bOnlyHardAttr );
- if( mpView->IsTextEdit() )
+ if( mrView.IsTextEdit() )
{
- OutlinerView* pTextEditOutlinerView = mpView->GetTextEditOutlinerView();
+ OutlinerView* pTextEditOutlinerView = mrView.GetTextEditOutlinerView();
if(pTextEditOutlinerView)
{
// FALSE= consider InvalidItems not as the default, but as "holes"
@@ -2575,7 +2608,7 @@ bool SvxTableController::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAtt
bool SvxTableController::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
{
- if( mbCellSelectionMode || mpView->IsTextEdit() )
+ if( mbCellSelectionMode || mrView.IsTextEdit() )
{
SetAttrToSelectedCells( rSet, bReplaceAll );
return true;
@@ -2588,16 +2621,17 @@ bool SvxTableController::GetMarkedObjModel( SdrPage* pNewPage )
{
if( mxTableObj.is() && mbCellSelectionMode && pNewPage ) try
{
- sdr::table::SdrTableObj& rTableObj = *mxTableObj.get();
-
+ sdr::table::SdrTableObj& rTableObj(*mxTableObj.get());
CellPos aStart, aEnd;
- getSelectedCells( aStart, aEnd );
-
- SdrTableObj* pNewTableObj = rTableObj.CloneRange( aStart, aEnd );
-
- pNewTableObj->SetPage( pNewPage );
- pNewTableObj->SetModel( pNewPage->GetModel() );
-
+ getSelectedCells(aStart, aEnd);
+
+ // Clone to new SdrModel
+ SdrTableObj* pNewTableObj(
+ rTableObj.CloneRange(
+ aStart,
+ aEnd,
+ pNewPage->getSdrModelFromSdrPage()));
+ pNewTableObj->SetPage(pNewPage);
pNewPage->InsertObject(pNewTableObj, SAL_MAX_SIZE);
return true;
@@ -2606,13 +2640,14 @@ bool SvxTableController::GetMarkedObjModel( SdrPage* pNewPage )
{
OSL_FAIL( "svx::SvxTableController::GetMarkedObjModel(), exception caught!" );
}
+
return false;
}
bool SvxTableController::PasteObjModel( const SdrModel& rModel )
{
- if( mxTableObj.is() && mpView && (rModel.GetPageCount() >= 1) )
+ if( mxTableObj.is() && (rModel.GetPageCount() >= 1) )
{
const SdrPage* pPastePage = rModel.GetPage(0);
if( pPastePage && pPastePage->GetObjCount() == 1 )
@@ -2647,8 +2682,8 @@ bool SvxTableController::PasteObject( SdrTableObj const * pPasteTableObj )
CellPos aStart, aEnd;
getSelectedCells( aStart, aEnd );
- if( mpView->IsTextEdit() )
- mpView->SdrEndTextEdit(true);
+ if( mrView.IsTextEdit() )
+ mrView.SdrEndTextEdit(true);
sal_Int32 nColumns = mxTable->getColumnCount();
sal_Int32 nRows = mxTable->getRowCount();
@@ -2692,51 +2727,51 @@ bool SvxTableController::TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& /*
bool SvxTableController::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats )
{
- if( mbCellSelectionMode )
+ if(!mbCellSelectionMode)
{
- SdrTextObj* pTableObj = dynamic_cast<SdrTextObj*>( mxTableObj.get() );
- if( !pTableObj )
- return false;
+ return false;
+ }
- const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if(!checkTableObject())
+ return false;
- if( bUndo )
- mpModel->BegUndo( ImpGetResStr(STR_TABLE_NUMFORMAT) );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ const bool bUndo(rModel.IsUndoEnabled());
- CellPos aStart, aEnd;
- getSelectedCells( aStart, aEnd );
+ if( bUndo )
+ rModel.BegUndo(ImpGetResStr(STR_TABLE_NUMFORMAT));
- const bool bFrame = (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER ) == SfxItemState::SET) || (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER_INNER ) == SfxItemState::SET);
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ const bool bFrame = (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER ) == SfxItemState::SET) || (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER_INNER ) == SfxItemState::SET);
- for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+ for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+ {
+ for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
{
- for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() )
{
- CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
- if( xCell.is() )
- {
- if (bUndo)
- xCell->AddUndo();
- SdrText* pText = static_cast< SdrText* >( xCell.get() );
- SdrObjEditView::ApplyFormatPaintBrushToText( rFormatSet, *pTableObj, pText, bNoCharacterFormats, bNoParagraphFormats );
- }
+ if (bUndo)
+ xCell->AddUndo();
+ SdrText* pText = static_cast< SdrText* >( xCell.get() );
+ SdrObjEditView::ApplyFormatPaintBrushToText( rFormatSet, rTableObj, pText, bNoCharacterFormats, bNoParagraphFormats );
}
}
+ }
- if( bFrame )
- {
- ApplyBorderAttr( rFormatSet );
- }
-
- UpdateTableShape();
+ if( bFrame )
+ {
+ ApplyBorderAttr( rFormatSet );
+ }
- if( bUndo )
- mpModel->EndUndo();
+ UpdateTableShape();
- return true;
+ if( bUndo )
+ rModel.EndUndo();
- }
- return false;
+ return true;
}
@@ -3077,26 +3112,22 @@ bool SvxTableController::isColumnSelected( sal_Int32 nColumn )
bool SvxTableController::isRowHeader()
{
- SdrTableObj* pTableObj = mxTableObj.get();
- SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr;
-
- if( !pTableObj || !pModel )
+ if(!checkTableObject())
return false;
- TableStyleSettings aSettings( pTableObj->getTableStyleSettings() );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ TableStyleSettings aSettings(rTableObj.getTableStyleSettings());
return aSettings.mbUseFirstRow;
}
bool SvxTableController::isColumnHeader()
{
- SdrTableObj* pTableObj = mxTableObj.get();
- SdrModel* pModel = pTableObj ? pTableObj->GetModel() : nullptr;
-
- if( !pTableObj || !pModel )
+ if(!checkTableObject())
return false;
- TableStyleSettings aSettings( pTableObj->getTableStyleSettings() );
+ SdrTableObj& rTableObj(*mxTableObj.get());
+ TableStyleSettings aSettings(rTableObj.getTableStyleSettings());
return aSettings.mbUseFirstColumn;
}
@@ -3125,7 +3156,7 @@ bool SvxTableController::setCursorLogicPosition(const Point& rPosition, bool bPo
// No selection, but rPosition is at an other cell: start table selection.
StartSelection(maMouseDownPos);
// Update graphic selection, should be hidden now.
- mpView->AdjustMarkHdl();
+ mrView.AdjustMarkHdl();
}
}
diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx
index 033af2477a45..812e3de7fe26 100644
--- a/svx/source/table/tablemodel.cxx
+++ b/svx/source/table/tablemodel.cxx
@@ -554,7 +554,7 @@ void TableModel::unlockBroadcasts()
void TableModel::notifyModification()
{
::osl::MutexGuard guard( m_aMutex );
- if( (mnNotifyLock == 0) && mpTableObj && mpTableObj->GetModel() )
+ if( (mnNotifyLock == 0) && mpTableObj )
{
mbNotifyPending = false;
@@ -602,8 +602,7 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
{
try
{
- SdrModel* pModel = mpTableObj->GetModel();
-
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
TableModelNotifyGuard aGuard( this );
nIndex = insert_range<ColumnVector,ColumnVector::iterator,TableColumnRef>( maColumns, nIndex, nCount );
@@ -619,11 +618,12 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
aNewColumns[nOffset] = xNewCol;
}
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
+
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
@@ -638,7 +638,7 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
(*aCellIter++) = getCell( nIndex + nOffset, nRow );
}
- pModel->AddUndo( new InsertColUndo( xThis, nIndex, aNewColumns, aNewCells ) );
+ rModel.AddUndo( new InsertColUndo( xThis, nIndex, aNewColumns, aNewCells ) );
}
const sal_Int32 nRowCount = getRowCountImpl();
@@ -660,11 +660,9 @@ void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
}
if( bUndo )
- pModel->EndUndo();
-
- if( pModel )
- pModel->SetChanged();
+ rModel.EndUndo();
+ rModel.SetChanged();
}
catch( Exception& )
{
@@ -691,14 +689,13 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
nCount = nColCount - nIndex;
sal_Int32 nRows = getRowCountImpl();
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
- SdrModel* pModel = mpTableObj->GetModel();
-
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_UNDO_COL_DELETE) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_UNDO_COL_DELETE) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
ColumnVector aRemovedCols( nCount );
@@ -716,7 +713,7 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
(*aCellIter++) = getCell( nIndex + nOffset, nRow );
}
- pModel->AddUndo( new RemoveColUndo( xThis, nIndex, aRemovedCols, aRemovedCells ) );
+ rModel.AddUndo( new RemoveColUndo( xThis, nIndex, aRemovedCols, aRemovedCells ) );
}
// only rows before and inside the removed rows are considered
@@ -769,10 +766,9 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
maRows[nRows]->removeColumns( nIndex, nCount );
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
}
catch( Exception& )
{
@@ -789,8 +785,9 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
{
if( nCount && mpTableObj )
{
- SdrModel* pModel = mpTableObj->GetModel();
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
+
try
{
TableModelNotifyGuard aGuard( this );
@@ -808,10 +805,10 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_TABLE_INSROW) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
- pModel->AddUndo( new InsertRowUndo( xThis, nIndex, aNewRows ) );
+ rModel.AddUndo( new InsertRowUndo( xThis, nIndex, aNewRows ) );
}
// check if cells merge over new columns
@@ -836,10 +833,9 @@ void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
OSL_FAIL("sdr::table::TableModel::insertRows(), exception caught!");
}
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
updateRows();
setModified(true);
@@ -853,8 +849,8 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
if( mpTableObj && nCount && (nIndex >= 0) && (nIndex < nRowCount) )
{
- SdrModel* pModel = mpTableObj->GetModel();
- const bool bUndo = pModel && mpTableObj->IsInserted()&& pModel->IsUndoEnabled();
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
try
{
@@ -866,8 +862,8 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
if( bUndo )
{
- pModel->BegUndo( ImpGetResStr(STR_UNDO_ROW_DELETE) );
- pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ rModel.BegUndo( ImpGetResStr(STR_UNDO_ROW_DELETE) );
+ rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
TableModelRef xThis( this );
@@ -875,7 +871,7 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset )
aRemovedRows[nOffset] = maRows[nIndex+nOffset];
- pModel->AddUndo( new RemoveRowUndo( xThis, nIndex, aRemovedRows ) );
+ rModel.AddUndo( new RemoveRowUndo( xThis, nIndex, aRemovedRows ) );
}
// only rows before and inside the removed rows are considered
@@ -926,10 +922,9 @@ void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
remove_range<RowVector,RowVector::iterator>( maRows, nIndex, nCount );
if( bUndo )
- pModel->EndUndo();
+ rModel.EndUndo();
- if( pModel )
- pModel->SetChanged();
+ rModel.SetChanged();
}
catch( Exception& )
{
@@ -1050,10 +1045,11 @@ void TableModel::optimize()
void TableModel::merge( sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan )
{
- SdrModel* pModel = mpTableObj->GetModel();
-
- const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ if(nullptr == mpTableObj)
+ return;
+ SdrModel& rModel(mpTableObj->getSdrModelFromSdrObject());
+ const bool bUndo(mpTableObj->IsInserted() && rModel.IsUndoEnabled());
const sal_Int32 nLastRow = nRow + nRowSpan;
const sal_Int32 nLastCol = nCol + nColSpan;
diff --git a/svx/source/table/tablerow.cxx b/svx/source/table/tablerow.cxx
index 43010ad698fe..cf765b47830a 100644
--- a/svx/source/table/tablerow.cxx
+++ b/svx/source/table/tablerow.cxx
@@ -206,14 +206,15 @@ void SAL_CALL TableRow::setName( const OUString& aName )
void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue )
{
- bool bOk = false;
- bool bChange = false;
+ if(!mxTableModel.is() || nullptr == mxTableModel->getSdrTableObj())
+ return;
- TableRowUndo* pUndo = nullptr;
-
- SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
-
- const bool bUndo = mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled();
+ SdrTableObj& rTableObj(*mxTableModel->getSdrTableObj());
+ SdrModel& rModel(rTableObj.getSdrModelFromSdrObject());
+ bool bOk(false);
+ bool bChange(false);
+ TableRowUndo* pUndo(nullptr);
+ const bool bUndo(rTableObj.IsInserted() && rModel.IsUndoEnabled());
if( bUndo )
{
@@ -276,6 +277,7 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal
delete pUndo;
throw UnknownPropertyException( OUString::number(nHandle), static_cast<cppu::OWeakObject*>(this));
}
+
if( !bOk )
{
delete pUndo;
@@ -286,7 +288,7 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal
{
if( pUndo )
{
- pModel->AddUndo( pUndo );
+ rModel.AddUndo( pUndo );
pUndo = nullptr;
}
mxTableModel->setModified(true);
diff --git a/svx/source/table/tablertfimporter.cxx b/svx/source/table/tablertfimporter.cxx
index 714e0c62c4ed..b50efb35bc3a 100644
--- a/svx/source/table/tablertfimporter.cxx
+++ b/svx/source/table/tablertfimporter.cxx
@@ -132,8 +132,8 @@ private:
SdrTableRTFParser::SdrTableRTFParser( SdrTableObj& rTableObj )
: mrTableObj( rTableObj )
-, mpOutliner( SdrMakeOutliner( OutlinerMode::TextObject, *rTableObj.GetModel() ) )
-, mrItemPool( rTableObj.GetModel()->GetItemPool() )
+, mpOutliner( SdrMakeOutliner( OutlinerMode::TextObject, rTableObj.getSdrModelFromSdrObject() ) )
+, mrItemPool( rTableObj.getSdrModelFromSdrObject().GetItemPool() )
, mnLastToken( 0 )
, mbNewDef( false )
, mnStartPara( 0 )
diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx
index 9a14948b1dfe..493c895057dc 100644
--- a/svx/source/table/tableundo.cxx
+++ b/svx/source/table/tableundo.cxx
@@ -35,10 +35,10 @@ using namespace ::com::sun::star::table;
namespace sdr { namespace table {
CellUndo::CellUndo( const tools::WeakReference<SdrObject>& xObjRef, const CellRef& xCell )
- : SdrUndoAction( *xCell->GetModel() )
- , mxObjRef( xObjRef )
- , mxCell( xCell )
- , mbUndo( true )
+: SdrUndoAction(xCell->GetObject().getSdrModelFromSdrObject())
+ ,mxObjRef( xObjRef )
+ ,mxCell( xCell )
+ ,mbUndo( true )
{
if( mxCell.is() && mxObjRef.is() )
{
@@ -162,10 +162,10 @@ static void Dispose( RowVector& rRows )
InsertRowUndo::InsertRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aNewRows )
- : SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
- , mxTable( xTable )
- , mnIndex( nIndex )
- , mbUndo( true )
+: SdrUndoAction(xTable->getSdrTableObj()->getSdrModelFromSdrObject())
+ ,mxTable( xTable )
+ ,mnIndex( nIndex )
+ ,mbUndo( true )
{
maRows.swap( aNewRows );
}
@@ -202,10 +202,10 @@ void InsertRowUndo::Redo()
RemoveRowUndo::RemoveRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aRemovedRows )
- : SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
- , mxTable( xTable )
- , mnIndex( nIndex )
- , mbUndo( true )
+: SdrUndoAction(xTable->getSdrTableObj()->getSdrModelFromSdrObject())
+ ,mxTable( xTable )
+ ,mnIndex( nIndex )
+ ,mbUndo( true )
{
maRows.swap( aRemovedRows );
}
@@ -258,10 +258,10 @@ static void Dispose( CellVector& rCells )
InsertColUndo::InsertColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells )
- : SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
- , mxTable( xTable )
- , mnIndex( nIndex )
- , mbUndo( true )
+: SdrUndoAction(xTable->getSdrTableObj()->getSdrModelFromSdrObject())
+ ,mxTable( xTable )
+ ,mnIndex( nIndex )
+ ,mbUndo( true )
{
maColumns.swap( aNewCols );
maCells.swap( aCells );
@@ -302,10 +302,10 @@ void InsertColUndo::Redo()
RemoveColUndo::RemoveColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells )
- : SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
- , mxTable( xTable )
- , mnIndex( nIndex )
- , mbUndo( true )
+: SdrUndoAction(xTable->getSdrTableObj()->getSdrModelFromSdrObject())
+ ,mxTable( xTable )
+ ,mnIndex( nIndex )
+ ,mbUndo( true )
{
maColumns.swap( aNewCols );
maCells.swap( aCells );
@@ -346,9 +346,9 @@ void RemoveColUndo::Redo()
TableColumnUndo::TableColumnUndo( const TableColumnRef& xCol )
- : SdrUndoAction( *xCol->mxTableModel->getSdrTableObj()->GetModel() )
- , mxCol( xCol )
- , mbHasRedoData( false )
+: SdrUndoAction(xCol->mxTableModel->getSdrTableObj()->getSdrModelFromSdrObject())
+ ,mxCol( xCol )
+ ,mbHasRedoData( false )
{
getData( maUndoData );
}
@@ -412,7 +412,7 @@ void TableColumnUndo::getData( Data& rData )
TableRowUndo::TableRowUndo( const TableRowRef& xRow )
- : SdrUndoAction( *xRow->mxTableModel->getSdrTableObj()->GetModel() )
+: SdrUndoAction(xRow->mxTableModel->getSdrTableObj()->getSdrModelFromSdrObject())
, mxRow( xRow )
, mbHasRedoData( false )
{
@@ -475,9 +475,9 @@ void TableRowUndo::getData( Data& rData )
TableStyleUndo::TableStyleUndo( const SdrTableObj& rTableObj )
- : SdrUndoAction( *rTableObj.GetModel() )
- , mxObjRef( const_cast< sdr::table::SdrTableObj*>( &rTableObj ) )
- , mbHasRedoData(false)
+: SdrUndoAction(rTableObj.getSdrModelFromSdrObject())
+ ,mxObjRef( const_cast< sdr::table::SdrTableObj*>( &rTableObj ) )
+ ,mbHasRedoData(false)
{
getData( maUndoData );
}
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index cca40d210b01..1dadd4983cf5 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -197,7 +197,8 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
SdrPage* pPage = pModel->GetPage(0);
if( pPage && pPage->GetObjCount() )
{
- SdrObject* pNewObject = pPage->GetObj(0)->Clone();
+ // Clone directly to target SdrModel
+ SdrObject* pNewObject(pPage->GetObj(0)->Clone(mpDestModel));
// center shape on current view
OutputDevice* pOutDev = mpSdrView->GetFirstOutputDevice();
@@ -210,16 +211,15 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
aPagePos.AdjustY( -(aObjRect.GetHeight() / 2) );
tools::Rectangle aNewObjectRectangle(aPagePos, aObjRect.GetSize());
SdrPageView* pPV = mpSdrView->GetSdrPageView();
-
pNewObject->SetLogicRect(aNewObjectRectangle);
+
if ( mppSdrObject )
{
*mppSdrObject = pNewObject;
- (*mppSdrObject)->SetModel( mpDestModel );
}
else if( pPV )
{
- mpSdrView->InsertObjectAtView( pNewObject, *pPV );
+ mpSdrView->InsertObjectAtView( pNewObject, *pPV );
}
}
}
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx
index 9fb0d021930a..a70c99ae3109 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -108,24 +108,21 @@ namespace {
Fraction maScaleX;
Fraction maScaleY;
- explicit ExportSettings( SdrModel const * pDoc );
+ explicit ExportSettings(const SdrModel& rSdrModel);
};
- ExportSettings::ExportSettings( SdrModel const * pDoc )
- : mnWidth( 0 )
- , mnHeight( 0 )
- , mbExportOnlyBackground( false )
- , mbScrollText( false )
- , mbUseHighContrast( false )
- , mbTranslucent( false )
- , maScaleX( 1, 1 )
- , maScaleY( 1, 1 )
+ ExportSettings::ExportSettings(const SdrModel& rSdrModel)
+ : mnWidth( 0 )
+ ,mnHeight( 0 )
+ ,mbExportOnlyBackground( false )
+ ,mbScrollText( false )
+ ,mbUseHighContrast( false )
+ ,mbTranslucent( false )
+ ,maScaleX( 1, 1 )
+ ,maScaleY( 1, 1 )
{
- if( pDoc )
- {
- maScaleX = pDoc->GetScaleFraction();
- maScaleY = pDoc->GetScaleFraction();
- }
+ maScaleX = rSdrModel.GetScaleFraction();
+ maScaleY = rSdrModel.GetScaleFraction();
}
/** implements a component to export shapes or pages to external graphic formats.
@@ -421,13 +418,15 @@ VclPtr<VirtualDevice> GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntP
if(bSuccess)
{
- std::unique_ptr<SdrView> pView(new SdrView(mpDoc, pVDev));
+ std::unique_ptr<SdrView> pView(new SdrView(*mpDoc, pVDev));
+
pView->SetPageVisible( false );
pView->SetBordVisible( false );
pView->SetGridVisible( false );
pView->SetHlplVisible( false );
pView->SetGlueVisible( false );
pView->ShowSdrPage(pPage);
+
vcl::Region aRegion (tools::Rectangle( aPoint, aPageSize ) );
ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
@@ -631,7 +630,9 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr
if(pCorrectProperties)
{
- pTempBackgroundShape = new SdrRectObj(tools::Rectangle(Point(0,0), pPage->GetSize()));
+ pTempBackgroundShape = new SdrRectObj(
+ *mpDoc,
+ tools::Rectangle(Point(0,0), pPage->GetSize()));
pTempBackgroundShape->SetMergedItemSet(pCorrectProperties->GetItemSet());
pTempBackgroundShape->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
pTempBackgroundShape->NbcSetStyleSheet(pCorrectProperties->GetStyleSheet(), true);
@@ -683,13 +684,14 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr
}
std::unique_ptr<SdrView> xLocalView;
+
if (FmFormModel* pFormModel = dynamic_cast<FmFormModel*>(mpDoc))
{
- xLocalView.reset(new FmFormView(pFormModel, aVDev) );
+ xLocalView.reset(new FmFormView(*pFormModel, aVDev));
}
else
{
- xLocalView.reset(new SdrView(mpDoc, aVDev));
+ xLocalView.reset(new SdrView(*mpDoc, aVDev));
}
ScopedVclPtr<VirtualDevice> pVDev(CreatePageVDev( pPage, nWidthPix, nHeightPix ));
@@ -715,13 +717,14 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr
// create a view
std::unique_ptr< SdrView > pView;
+
if (FmFormModel *pFormModel = dynamic_cast<FmFormModel*>(mpDoc))
{
- pView.reset(new FmFormView(pFormModel, aVDev));
+ pView.reset(new FmFormView(*pFormModel, aVDev));
}
else
{
- pView.reset(new SdrView( mpDoc, aVDev ));
+ pView.reset(new SdrView(*mpDoc, aVDev));
}
pView->SetBordVisible( false );
@@ -997,8 +1000,8 @@ sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDes
GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
// get the arguments from the descriptor
- ExportSettings aSettings( mpDoc );
- ParseSettings( aDescriptor, aSettings );
+ ExportSettings aSettings(*mpDoc);
+ ParseSettings(aDescriptor, aSettings);
const sal_uInt16 nFilter = !aSettings.maMediaType.isEmpty()
? rFilter.GetExportFormatNumberForMediaType( aSettings.maMediaType )
@@ -1136,7 +1139,7 @@ void SAL_CALL GraphicExporter::setSourceDocument( const Reference< lang::XCompon
if( nullptr == mpUnoPage || nullptr == mpUnoPage->GetSdrPage() )
break;
- mpDoc = mpUnoPage->GetSdrPage()->GetModel();
+ mpDoc = &mpUnoPage->GetSdrPage()->getSdrModelFromSdrPage();
// Step 4: If we got a generic XShapes test all contained shapes
// if they belong to the same XDrawPage
@@ -1246,7 +1249,7 @@ Graphic SvxGetGraphicForShape( SdrObject& rShape )
rtl::Reference< GraphicExporter > xExporter( new GraphicExporter() );
Reference< XComponent > xComp( rShape.getUnoShape(), UNO_QUERY_THROW );
xExporter->setSourceDocument( xComp );
- ExportSettings aSettings( rShape.GetModel() );
+ ExportSettings aSettings(rShape.getSdrModelFromSdrObject());
xExporter->GetGraphic( aSettings, aGraphic, true/*bVector*/ );
}
catch( Exception& )
diff --git a/svx/source/unodraw/tableshape.cxx b/svx/source/unodraw/tableshape.cxx
index a34815611bca..281dfa288ea9 100644
--- a/svx/source/unodraw/tableshape.cxx
+++ b/svx/source/unodraw/tableshape.cxx
@@ -59,8 +59,8 @@ bool SvxTableShape::setPropertyValueImpl(
if( !(rValue >>= xTemplate) )
throw IllegalArgumentException();
- if( mpObj.is() )
- static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyle(xTemplate);
+ if( HasSdrObject() )
+ static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyle(xTemplate);
return true;
}
@@ -71,9 +71,9 @@ bool SvxTableShape::setPropertyValueImpl(
case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
{
- if( mpObj.is() )
+ if( HasSdrObject() )
{
- TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
+ TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
switch( pProperty->nWID )
{
@@ -85,7 +85,7 @@ bool SvxTableShape::setPropertyValueImpl(
case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue >>= aSettings.mbUseColumnBanding; break;
}
- static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyleSettings(aSettings);
+ static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyleSettings(aSettings);
}
return true;
@@ -106,25 +106,25 @@ bool SvxTableShape::getPropertyValueImpl(
{
case OWN_ATTR_OLEMODEL:
{
- if( mpObj.is() )
+ if( HasSdrObject() )
{
- rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTable();
+ rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTable();
}
return true;
}
case OWN_ATTR_TABLETEMPLATE:
{
- if( mpObj.is() )
+ if( HasSdrObject() )
{
- rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyle();
+ rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyle();
}
return true;
}
case OWN_ATTR_BITMAP:
{
- if( mpObj.is() )
+ if( HasSdrObject() )
{
- Graphic aGraphic( SvxGetGraphicForShape( *mpObj.get() ) );
+ Graphic aGraphic( SvxGetGraphicForShape( *GetSdrObject() ) );
rValue <<= aGraphic.GetXGraphic();
}
return true;
@@ -136,9 +136,9 @@ bool SvxTableShape::getPropertyValueImpl(
case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
{
- if( mpObj.is() )
+ if( HasSdrObject() )
{
- TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
+ TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
switch( pProperty->nWID )
{
@@ -163,14 +163,14 @@ bool SvxTableShape::getPropertyValueImpl(
void SvxTableShape::lock()
{
SvxShape::lock();
- if( mpObj.is() )
- static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_lock();
+ if( HasSdrObject() )
+ static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_lock();
}
void SvxTableShape::unlock()
{
- if( mpObj.is() )
- static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_unlock();
+ if( HasSdrObject() )
+ static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_unlock();
SvxShape::unlock();
}
diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx
index 4f0ea1fcddab..dd1d1317f7a6 100644
--- a/svx/source/unodraw/unomod.cxx
+++ b/svx/source/unodraw/unomod.cxx
@@ -246,8 +246,26 @@ uno::Sequence< OUString > SvxUnoDrawMSFactory::concatServiceNames( uno::Sequence
return aSeq;
}
-SvxUnoDrawingModel::SvxUnoDrawingModel( SdrModel* pDoc ) throw()
-: SfxBaseModel(nullptr), mpDoc( pDoc )
+SdrModel* SvxUnoDrawingModel::getSdrModelFromUnoModel() const
+{
+ return mpDoc;
+}
+
+SvxUnoDrawingModel::SvxUnoDrawingModel(SdrModel* pDoc) throw()
+: SfxBaseModel(nullptr),
+ SvxFmMSFactory(),
+ css::drawing::XDrawPagesSupplier(),
+ css::lang::XServiceInfo(),
+ css::ucb::XAnyCompareFactory(),
+ mpDoc(pDoc),
+ mxDrawPagesAccess(),
+ mxDashTable(),
+ mxGradientTable(),
+ mxHatchTable(),
+ mxBitmapTable(),
+ mxTransGradientTable(),
+ mxMarkerTable(),
+ maTypeSequence()
{
}
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index d7f14d3676c5..3dc69e899965 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -61,12 +61,11 @@ using namespace ::com::sun::star::drawing;
UNO3_GETIMPLEMENTATION_IMPL( SvxDrawPage );
-SvxDrawPage::SvxDrawPage(SdrPage* pInPage)
- : mrBHelper(getMutex())
- , mpPage(pInPage)
- , mpModel(mpPage->GetModel()) // register at broadcaster
- , mpView(new SdrView(mpModel)) // create (hidden) view
-
+SvxDrawPage::SvxDrawPage(SdrPage* pInPage) // TTTT should be reference
+: mrBHelper(getMutex())
+ ,mpPage(pInPage)
+ ,mpModel(&pInPage->getSdrModelFromSdrPage()) // register at broadcaster
+ ,mpView(new SdrView(pInPage->getSdrModelFromSdrPage())) // create (hidden) view
{
mpView->SetDesignMode();
}
@@ -192,6 +191,24 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape
return;
SdrObject *pObj = pShape->GetSdrObject();
+ bool bNeededToClone(false);
+
+ if(nullptr != pObj && &pObj->getSdrModelFromSdrObject() != &mpPage->getSdrModelFromSdrPage())
+ {
+ // TTTT UNO API tries to add an existing SvxShape to this SvxDrawPage,
+ // but these use different SdrModels. It was possible before to completely
+ // 'change' a SdrObject to another SdrModel (including dangerous MigrateItemPool
+ // stuff), but is no longer. We need to Clone the SdrObject to the target model
+ // and ::Create a new SvxShape (set SdrObject there, take obver values, ...)
+ SdrObject* pClonedSdrShape(pObj->Clone(&mpPage->getSdrModelFromSdrPage()));
+ pObj->setUnoShape(nullptr);
+ pClonedSdrShape->setUnoShape(xShape);
+ // pShape->InvalidateSdrObject();
+ // pShape->Create(pClonedSdrShape, this);
+ SdrObject::Free(pObj);
+ pObj = pClonedSdrShape;
+ bNeededToClone = true;
+ }
if(!pObj)
{
@@ -200,8 +217,20 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape
}
else if ( !pObj->IsInserted() )
{
- pObj->SetModel(mpModel);
mpPage->InsertObject( pObj );
+
+ if(bNeededToClone)
+ {
+ // TTTT Unfortunately in SdrObject::SetPage (see there) the
+ // xShape/UnoShape at the newly cloned SDrObject is *removed* again,
+ // so re-set it here, the caller *may need it* (e.g. Writer)
+ uno::Reference< uno::XInterface > xShapeCheck(pObj->getWeakUnoShape());
+
+ if( !xShapeCheck.is() )
+ {
+ pObj->setUnoShape(xShape);
+ }
+ }
}
pShape->Create( pObj, this );
@@ -209,7 +238,6 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape
if ( !pObj->IsInserted() )
{
- pObj->SetModel(mpModel);
mpPage->InsertObject( pObj );
}
@@ -242,7 +270,6 @@ void SAL_CALL SvxDrawPage::addBottom( const uno::Reference< drawing::XShape >& x
}
else if ( !pObj->IsInserted() )
{
- pObj->SetModel(mpModel);
mpPage->InsertObject( pObj, 0 );
}
@@ -251,7 +278,6 @@ void SAL_CALL SvxDrawPage::addBottom( const uno::Reference< drawing::XShape >& x
if ( !pObj->IsInserted() )
{
- pObj->SetModel(mpModel);
mpPage->InsertObject( pObj, 0 );
}
@@ -465,7 +491,7 @@ void SAL_CALL SvxDrawPage::ungroup( const Reference< drawing::XShapeGroup >& aGr
mpModel->SetChanged();
}
-SdrObject *SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xShape)
+SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xShape)
{
sal_uInt16 nType = 0;
SdrInventor nInventor;
@@ -480,7 +506,13 @@ SdrObject *SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xS
awt::Point aPos = xShape->getPosition();
tools::Rectangle aRect( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) );
- SdrObject* pNewObj = SdrObjFactory::MakeNewObject(nInventor, nType, aRect, mpPage);
+ SdrObject* pNewObj = SdrObjFactory::MakeNewObject(
+ *mpModel,
+ nInventor,
+ nType,
+ mpPage,
+ &aRect);
+
if (!pNewObj)
return nullptr;
@@ -680,39 +712,37 @@ SvxShape* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType, SdrInvent
SdrPage* pSdrPage = mpPage->GetSdrPage();
if( pSdrPage )
{
- SdrModel* pSdrModel = pSdrPage->GetModel();
- if( pSdrModel )
+ SdrModel& rSdrModel(pSdrPage->getSdrModelFromSdrPage());
+ ::comphelper::IEmbeddedHelper *pPersist = rSdrModel.GetPersist();
+
+ if( pPersist )
{
- ::comphelper::IEmbeddedHelper *pPersist = pSdrModel->GetPersist();
- if( pPersist )
+ uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
+ GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
+
+ // TODO CL->KA: Why is this not working anymore?
+ if( xObject.is() )
{
- uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
- GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
+ SvGlobalName aClassId( xObject->getClassID() );
- // TODO CL->KA: Why is this not working anymore?
- if( xObject.is() )
+ const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
+ const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
+ const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
+
+ if( aPluginClassId == aClassId )
+ {
+ pRet = new SvxPluginShape( pObj );
+ nType = OBJ_OLE2_PLUGIN;
+ }
+ else if( aAppletClassId == aClassId )
{
- SvGlobalName aClassId( xObject->getClassID() );
-
- const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
- const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
- const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
-
- if( aPluginClassId == aClassId )
- {
- pRet = new SvxPluginShape( pObj );
- nType = OBJ_OLE2_PLUGIN;
- }
- else if( aAppletClassId == aClassId )
- {
- pRet = new SvxAppletShape( pObj );
- nType = OBJ_OLE2_APPLET;
- }
- else if( aIFrameClassId == aClassId )
- {
- pRet = new SvxFrameShape( pObj );
- nType = OBJ_FRAME;
- }
+ pRet = new SvxAppletShape( pObj );
+ nType = OBJ_OLE2_APPLET;
+ }
+ else if( aIFrameClassId == aClassId )
+ {
+ pRet = new SvxFrameShape( pObj );
+ nType = OBJ_FRAME;
}
}
}
@@ -812,7 +842,6 @@ SdrObject *SvxDrawPage::CreateSdrObject( const Reference< drawing::XShape > & xS
SdrObject* pObj = CreateSdrObject_( xShape );
if( pObj)
{
- pObj->SetModel(mpModel);
if ( !pObj->IsInserted() && !pObj->IsDoNotInsertIntoPageAutomatically() )
{
if(bBeginning)
@@ -847,21 +876,6 @@ SvxShape* CreateSvxShapeByTypeAndInventor(sal_uInt16 nType, SdrInventor nInvento
return SvxDrawPage::CreateShapeByTypeAndInventor( nType, nInventor, nullptr, nullptr, referer );
}
-void SvxDrawPage::ChangeModel( SdrModel* pNewModel )
-{
- if( pNewModel != mpModel )
- {
- mpModel = pNewModel;
-
- if( mpView )
- {
- delete mpView;
- mpView = new SdrView( mpModel );
- mpView->SetDesignMode();
- }
- }
-}
-
/** returns a StarOffice API wrapper for the given SdrPage */
uno::Reference< drawing::XDrawPage > GetXDrawPageForSdrPage( SdrPage* pPage ) throw ()
{
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 8c5fc28b8fd0..34106635f1cb 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -181,7 +181,7 @@ void SAL_CALL SvxShapeGroup::leaveGroup( )
void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape, size_t nPos )
{
- if (!mpObj.is() || !mxPage.is())
+ if (!HasSdrObject() || !mxPage.is())
{
OSL_FAIL("could not add XShape to group shape!");
return;
@@ -201,8 +201,10 @@ void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape
if( pSdrShape->IsInserted() )
pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() );
- mpObj->GetSubList()->InsertObject(pSdrShape, nPos);
- pSdrShape->SetModel(mpObj->GetModel());
+ GetSdrObject()->GetSubList()->InsertObject(pSdrShape, nPos);
+ // TTTT Was created using mpModel in CreateSdrObject_ above
+ // TTTT may be good to add a assertion here for the future
+ // pSdrShape->SetModel(GetSdrObject()->GetModel());
// #85922# It makes no sense to set the layer asked
// from the group object since these is an iteration
@@ -217,8 +219,7 @@ void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape
// would be created when this connection would not already exist.
pShape->Create( pSdrShape, mxPage.get() );
- if( mpModel )
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
// XShapes
@@ -241,7 +242,7 @@ void SAL_CALL SvxShapeGroup::remove( const uno::Reference< drawing::XShape >& xS
if( pShape )
pSdrShape = pShape->GetSdrObject();
- if( !mpObj.is() || pSdrShape == nullptr || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get() )
+ if( !HasSdrObject() || pSdrShape == nullptr || pSdrShape->GetObjList()->GetOwnerObj() != GetSdrObject() )
throw uno::RuntimeException();
SdrObjList& rList = *pSdrShape->GetObjList();
@@ -278,8 +279,7 @@ void SAL_CALL SvxShapeGroup::remove( const uno::Reference< drawing::XShape >& xS
SAL_WARN( "svx", "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" );
}
- if( mpModel )
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
void SAL_CALL SvxShapeGroup::addTop( const uno::Reference< drawing::XShape >& xShape )
@@ -305,10 +305,10 @@ sal_Int32 SAL_CALL SvxShapeGroup::getCount()
{
::SolarMutexGuard aGuard;
- if(!mpObj.is() || !mpObj->GetSubList())
+ if(!HasSdrObject() || !GetSdrObject()->GetSubList())
throw uno::RuntimeException();
- sal_Int32 nRetval = mpObj->GetSubList()->GetObjCount();
+ sal_Int32 nRetval = GetSdrObject()->GetSubList()->GetObjCount();
return nRetval;
}
@@ -317,13 +317,13 @@ uno::Any SAL_CALL SvxShapeGroup::getByIndex( sal_Int32 Index )
{
::SolarMutexGuard aGuard;
- if( !mpObj.is() || mpObj->GetSubList() == nullptr )
+ if( !HasSdrObject() || GetSdrObject()->GetSubList() == nullptr )
throw uno::RuntimeException();
- if( Index<0 || mpObj->GetSubList()->GetObjCount() <= static_cast<size_t>(Index) )
+ if( Index<0 || GetSdrObject()->GetSubList()->GetObjCount() <= static_cast<size_t>(Index) )
throw lang::IndexOutOfBoundsException();
- SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index );
+ SdrObject* pDestObj = GetSdrObject()->GetSubList()->GetObj( Index );
if(pDestObj == nullptr)
throw lang::IndexOutOfBoundsException();
@@ -345,7 +345,7 @@ sal_Bool SAL_CALL SvxShapeGroup::hasElements()
{
::SolarMutexGuard aGuard;
- return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0);
+ return HasSdrObject() && GetSdrObject()->GetSubList() && (GetSdrObject()->GetSubList()->GetObjCount() > 0);
}
SvxShapeConnector::SvxShapeConnector(SdrObject* pObj)
@@ -438,10 +438,9 @@ void SAL_CALL SvxShapeConnector::connectStart( const uno::Reference< drawing::XC
SvxShape* pShape = SvxShape::getImplementation( xRef );
if( pShape )
- mpObj->ConnectToNode( true, pShape->mpObj.get() );
+ GetSdrObject()->ConnectToNode( true, pShape->GetSdrObject() );
- if( mpModel )
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
@@ -452,11 +451,10 @@ void SAL_CALL SvxShapeConnector::connectEnd( const uno::Reference< drawing::XCon
Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
SvxShape* pShape = SvxShape::getImplementation( xRef );
- if( mpObj.is() && pShape )
- mpObj->ConnectToNode( false, pShape->mpObj.get() );
+ if( HasSdrObject() && pShape )
+ GetSdrObject()->ConnectToNode( false, pShape->GetSdrObject() );
- if( mpModel )
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
@@ -464,11 +462,10 @@ void SAL_CALL SvxShapeConnector::disconnectBegin( const uno::Reference< drawing:
{
::SolarMutexGuard aGuard;
- if(mpObj.is())
- mpObj->DisconnectFromNode( true );
+ if(HasSdrObject())
+ GetSdrObject()->DisconnectFromNode( true );
- if( mpModel )
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
@@ -476,11 +473,10 @@ void SAL_CALL SvxShapeConnector::disconnectEnd( const uno::Reference< drawing::X
{
::SolarMutexGuard aGuard;
- if(mpObj.is())
- mpObj->DisconnectFromNode( false );
+ if(HasSdrObject())
+ GetSdrObject()->DisconnectFromNode( false );
- if( mpModel )
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
SvxShapeControl::SvxShapeControl(SdrObject* pObj)
@@ -572,7 +568,7 @@ Reference< awt::XControlModel > SAL_CALL SvxShapeControl::getControl()
Reference< awt::XControlModel > xModel;
- SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
+ SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(GetSdrObject());
if( pUnoObj )
xModel = pUnoObj->GetUnoControlModel();
@@ -584,12 +580,11 @@ void SAL_CALL SvxShapeControl::setControl( const Reference< awt::XControlModel >
{
::SolarMutexGuard aGuard;
- SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
+ SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(GetSdrObject());
if( pUnoObj )
pUnoObj->SetUnoControlModel( xControl );
- if( mpModel )
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
static struct
@@ -983,14 +978,14 @@ bool SvxShapePolyPolygon::setPropertyValueImpl( const OUString& rName, const Sfx
{
if( auto s = o3tl::tryAccess<drawing::PointSequenceSequence>(rValue) )
{
- if( mpObj.is() )
+ if( HasSdrObject() )
{
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
- mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
aNewPolyPolygon = ImplSvxPointSequenceSequenceToB2DPolyPolygon(s);
- mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
}
return true;
}
@@ -1093,8 +1088,8 @@ bool SvxShapePolyPolygon::getPropertyValueImpl( const OUString& rName, const Sfx
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
- if(mpObj.is())
- mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ if(HasSdrObject())
+ GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
drawing::PointSequenceSequence aRetval(aNewPolyPolygon.count());
B2DPolyPolygonToSvxPointSequenceSequence(aNewPolyPolygon, aRetval);
@@ -1147,8 +1142,8 @@ void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon& rNew)
{
::SolarMutexGuard aGuard;
- if(mpObj.is())
- static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew);
+ if(HasSdrObject())
+ static_cast<SdrPathObj*>(GetSdrObject())->SetPathPoly(rNew);
}
@@ -1156,9 +1151,9 @@ basegfx::B2DPolyPolygon SvxShapePolyPolygon::GetPolygon() const throw()
{
::SolarMutexGuard aGuard;
- if(mpObj.is())
+ if(HasSdrObject())
{
- return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly();
+ return static_cast<SdrPathObj*>(GetSdrObject())->GetPathPoly();
}
else
{
@@ -1195,15 +1190,15 @@ bool SvxShapePolyPolygonBezier::setPropertyValueImpl( const OUString& rName, con
{
if( auto s = o3tl::tryAccess<drawing::PolyPolygonBezierCoords>(rValue) )
{
- if( mpObj.is() )
+ if( HasSdrObject() )
{
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
- mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
aNewPolyPolygon = basegfx::unotools::polyPolygonBezierToB2DPolyPolygon(
*s);
- mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
}
return true;
}
@@ -1236,7 +1231,7 @@ bool SvxShapePolyPolygonBezier::getPropertyValueImpl( const OUString& rName, con
// pack a tools::PolyPolygon in a struct tools::PolyPolygon
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
- mpObj.get()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
drawing::PolyPolygonBezierCoords aRetval;
basegfx::unotools::b2DPolyPolygonToPolyPolygonBezier(aNewPolyPolygon, aRetval);
@@ -1259,8 +1254,8 @@ void SvxShapePolyPolygonBezier::SetPolygon(const basegfx::B2DPolyPolygon& rNew)
{
::SolarMutexGuard aGuard;
- if(mpObj.is())
- static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew);
+ if(HasSdrObject())
+ static_cast<SdrPathObj*>(GetSdrObject())->SetPathPoly(rNew);
}
@@ -1268,9 +1263,9 @@ basegfx::B2DPolyPolygon SvxShapePolyPolygonBezier::GetPolygon() const throw()
{
::SolarMutexGuard aGuard;
- if(mpObj.is())
+ if(HasSdrObject())
{
- return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly();
+ return static_cast<SdrPathObj*>(GetSdrObject())->GetPathPoly();
}
else
{
@@ -1303,7 +1298,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
if( GraphicConverter::Import( aMemStm, aGraphic ) == ERRCODE_NONE )
{
- static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic);
+ static_cast<SdrGrafObj*>(GetSdrObject())->SetGraphic(aGraphic);
bOk = true;
}
}
@@ -1312,7 +1307,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
auto xGraphic = rValue.get<uno::Reference<graphic::XGraphic>>();
if (xGraphic.is())
{
- static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(Graphic(xGraphic));
+ static_cast<SdrGrafObj*>(GetSdrObject())->SetGraphic(Graphic(xGraphic));
bOk = true;
}
}
@@ -1323,7 +1318,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
{
uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
Graphic aGraphic(xGraphic);
- static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic);
+ static_cast<SdrGrafObj*>(GetSdrObject())->SetGraphic(aGraphic);
bOk = true;
}
}
@@ -1339,9 +1334,9 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
if( !aStreamURL.startsWith( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) )
aStreamURL.clear();
- if( mpObj.is() )
+ if( HasSdrObject() )
{
- static_cast<SdrGrafObj*>(mpObj.get())->SetGrafStreamURL( aStreamURL );
+ static_cast<SdrGrafObj*>(GetSdrObject())->SetGrafStreamURL( aStreamURL );
}
bOk = true;
}
@@ -1353,7 +1348,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
if( xGraphic.is() )
{
- static_cast< SdrGrafObj*>( mpObj.get() )->SetGraphic( xGraphic );
+ static_cast< SdrGrafObj*>( GetSdrObject() )->SetGraphic( xGraphic );
bOk = true;
}
break;
@@ -1364,7 +1359,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
bool bIsSignatureLine;
if (rValue >>= bIsSignatureLine)
{
- static_cast<SdrGrafObj*>(mpObj.get())->setIsSignatureLine(bIsSignatureLine);
+ static_cast<SdrGrafObj*>(GetSdrObject())->setIsSignatureLine(bIsSignatureLine);
bOk = true;
}
break;
@@ -1375,7 +1370,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
OUString aSignatureLineId;
if (rValue >>= aSignatureLineId)
{
- static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineId(aSignatureLineId);
+ static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineId(aSignatureLineId);
bOk = true;
}
break;
@@ -1386,7 +1381,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
OUString aSuggestedSignerName;
if (rValue >>= aSuggestedSignerName)
{
- static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineSuggestedSignerName(aSuggestedSignerName);
+ static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineSuggestedSignerName(aSuggestedSignerName);
bOk = true;
}
break;
@@ -1397,7 +1392,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
OUString aSuggestedSignerTitle;
if (rValue >>= aSuggestedSignerTitle)
{
- static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineSuggestedSignerTitle(aSuggestedSignerTitle);
+ static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineSuggestedSignerTitle(aSuggestedSignerTitle);
bOk = true;
}
break;
@@ -1408,7 +1403,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
OUString aSuggestedSignerEmail;
if (rValue >>= aSuggestedSignerEmail)
{
- static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineSuggestedSignerEmail(aSuggestedSignerEmail);
+ static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineSuggestedSignerEmail(aSuggestedSignerEmail);
bOk = true;
}
break;
@@ -1419,7 +1414,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
OUString aSigningInstructions;
if (rValue >>= aSigningInstructions)
{
- static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineSigningInstructions(aSigningInstructions);
+ static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineSigningInstructions(aSigningInstructions);
bOk = true;
}
break;
@@ -1430,7 +1425,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
bool bShowSignDate;
if (rValue >>= bShowSignDate)
{
- static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineShowSignDate(bShowSignDate);
+ static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineShowSignDate(bShowSignDate);
bOk = true;
}
break;
@@ -1441,7 +1436,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
bool bCanAddComment;
if (rValue >>= bCanAddComment)
{
- static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineCanAddComment(bCanAddComment);
+ static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineCanAddComment(bCanAddComment);
bOk = true;
}
break;
@@ -1452,7 +1447,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
Reference<graphic::XGraphic> xGraphic(rValue, uno::UNO_QUERY);
if (xGraphic.is())
{
- static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineUnsignedGraphic(xGraphic);
+ static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineUnsignedGraphic(xGraphic);
bOk = true;
}
break;
@@ -1465,8 +1460,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
if( !bOk )
throw lang::IllegalArgumentException();
- if( mpModel )
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
return true;
}
@@ -1477,7 +1471,7 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
{
case OWN_ATTR_VALUE_FILLBITMAP:
{
- const Graphic& rGraphic = static_cast<SdrGrafObj*>(mpObj.get())->GetGraphic();
+ const Graphic& rGraphic = static_cast<SdrGrafObj*>(GetSdrObject())->GetGraphic();
if (rGraphic.GetType() != GraphicType::GdiMetafile)
{
@@ -1499,7 +1493,7 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
case OWN_ATTR_REPLACEMENT_GRAPHIC:
{
- const GraphicObject* pGrafObj = static_cast< SdrGrafObj* >(mpObj.get())->GetReplacementGraphicObject();
+ const GraphicObject* pGrafObj = static_cast< SdrGrafObj* >(GetSdrObject())->GetReplacementGraphicObject();
if (pGrafObj)
{
@@ -1511,7 +1505,7 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
case OWN_ATTR_GRAFSTREAMURL:
{
- const OUString aStreamURL( static_cast<SdrGrafObj*>( mpObj.get() )->GetGrafStreamURL() );
+ const OUString aStreamURL( static_cast<SdrGrafObj*>( GetSdrObject() )->GetGrafStreamURL() );
if( !aStreamURL.isEmpty() )
rValue <<= aStreamURL;
break;
@@ -1520,7 +1514,7 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
case OWN_ATTR_VALUE_GRAPHIC:
{
Reference<graphic::XGraphic> xGraphic;
- auto pSdrGraphicObject = static_cast<SdrGrafObj*>(mpObj.get());
+ auto pSdrGraphicObject = static_cast<SdrGrafObj*>(GetSdrObject());
if (pSdrGraphicObject->GetGraphicObject().GetType() != GraphicType::NONE)
xGraphic = pSdrGraphicObject->GetGraphic().GetXGraphic();
rValue <<= xGraphic;
@@ -1529,62 +1523,62 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
case OWN_ATTR_GRAPHIC_STREAM:
{
- rValue <<= static_cast< SdrGrafObj* >( mpObj.get() )->getInputStream();
+ rValue <<= static_cast< SdrGrafObj* >( GetSdrObject() )->getInputStream();
break;
}
case OWN_ATTR_IS_SIGNATURELINE:
{
- rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->isSignatureLine();
+ rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->isSignatureLine();
break;
}
case OWN_ATTR_SIGNATURELINE_ID:
{
- rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineId();
+ rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineId();
break;
}
case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_NAME:
{
- rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineSuggestedSignerName();
+ rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineSuggestedSignerName();
break;
}
case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_TITLE:
{
- rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineSuggestedSignerTitle();
+ rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineSuggestedSignerTitle();
break;
}
case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_EMAIL:
{
- rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineSuggestedSignerEmail();
+ rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineSuggestedSignerEmail();
break;
}
case OWN_ATTR_SIGNATURELINE_SIGNING_INSTRUCTIONS:
{
- rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineSigningInstructions();
+ rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineSigningInstructions();
break;
}
case OWN_ATTR_SIGNATURELINE_SHOW_SIGN_DATE:
{
- rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->isSignatureLineShowSignDate();
+ rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->isSignatureLineShowSignDate();
break;
}
case OWN_ATTR_SIGNATURELINE_CAN_ADD_COMMENT:
{
- rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->isSignatureLineCanAddComment();
+ rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->isSignatureLineCanAddComment();
break;
}
case OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE:
{
Reference<graphic::XGraphic> xGraphic(
- static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineUnsignedGraphic());
+ static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineUnsignedGraphic());
rValue <<= xGraphic;
break;
}
@@ -1655,21 +1649,21 @@ uno::Sequence< sal_Int8 > SAL_CALL SvxCustomShape::getImplementationId()
awt::Point SAL_CALL SvxCustomShape::getPosition()
{
::SolarMutexGuard aGuard;
- if ( mpModel && mpObj.is() )
+ if ( HasSdrObject() )
{
SdrAShapeObjGeoData aCustomShapeGeoData;
- static_cast<SdrObjCustomShape*>(mpObj.get())->SaveGeoData( aCustomShapeGeoData );
+ static_cast<SdrObjCustomShape*>(GetSdrObject())->SaveGeoData( aCustomShapeGeoData );
bool bMirroredX = false;
bool bMirroredY = false;
- if ( mpObj.is() )
+ if ( HasSdrObject() )
{
- bMirroredX = static_cast<SdrObjCustomShape*>(mpObj.get())->IsMirroredX();
- bMirroredY = static_cast<SdrObjCustomShape*>(mpObj.get())->IsMirroredY();
+ bMirroredX = static_cast<SdrObjCustomShape*>(GetSdrObject())->IsMirroredX();
+ bMirroredY = static_cast<SdrObjCustomShape*>(GetSdrObject())->IsMirroredY();
}
// get aRect, this is the unrotated snaprect
- tools::Rectangle aRect(static_cast<SdrObjCustomShape*>(mpObj.get())->GetLogicRect());
+ tools::Rectangle aRect(static_cast<SdrObjCustomShape*>(GetSdrObject())->GetLogicRect());
tools::Rectangle aRectangle( aRect );
if ( bMirroredX || bMirroredY )
@@ -1723,8 +1717,8 @@ awt::Point SAL_CALL SvxCustomShape::getPosition()
}
Point aPt( aRectangle.TopLeft() );
- if( mpModel->IsWriter() )
- aPt -= mpObj->GetAnchorPos();
+ if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+ aPt -= GetSdrObject()->GetAnchorPos();
ForceMetricTo100th_mm(aPt);
return css::awt::Point( aPt.X(), aPt.Y() );
@@ -1738,7 +1732,7 @@ void SAL_CALL SvxCustomShape::setPropertyValue( const OUString& aPropertyName, c
{
::SolarMutexGuard aGuard;
- SdrObject* pObject = mpObj.get();
+ SdrObject* pObject = GetSdrObject();
// tdf#98163 Use a custom slot to have filter code flush the UNO
// API implementations of SdrObjCustomShape. Used e.g. by
@@ -1824,7 +1818,7 @@ bool SvxCustomShape::getPropertyValueImpl( const OUString& rName, const SfxItemP
{
case SDRATTR_ROTATEANGLE:
{
- double fAngle = static_cast<SdrObjCustomShape*>(mpObj.get())->GetObjectRotation();
+ double fAngle = static_cast<SdrObjCustomShape*>(GetSdrObject())->GetObjectRotation();
fAngle *= 100;
rValue <<= static_cast<sal_Int32>(fAngle);
return true;
@@ -1836,13 +1830,13 @@ bool SvxCustomShape::getPropertyValueImpl( const OUString& rName, const SfxItemP
void SvxCustomShape::createCustomShapeDefaults( const OUString& rValueType )
{
- if (!mpObj.is())
+ if (!HasSdrObject())
{
OSL_FAIL("could not create Custom Shape Defaults!");
return;
}
- static_cast<SdrObjCustomShape*>(mpObj.get())->MergeDefaultAttributes( &rValueType );
+ static_cast<SdrObjCustomShape*>(GetSdrObject())->MergeDefaultAttributes( &rValueType );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoshap3.cxx b/svx/source/unodraw/unoshap3.cxx
index 66ac52b876db..663dcc9f6bd9 100644
--- a/svx/source/unodraw/unoshap3.cxx
+++ b/svx/source/unodraw/unoshap3.cxx
@@ -45,6 +45,7 @@
#include <basegfx/polygon/b3dpolygontools.hxx>
#include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/matrix/b3dhommatrixtools.hxx>
#include "shapeimpl.hxx"
using namespace ::cppu;
@@ -118,13 +119,13 @@ void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape
SvxShape* pShape = SvxShape::getImplementation( xShape );
- if(!mpObj.is() || !mxPage.is() || pShape == nullptr || nullptr != pShape->GetSdrObject() )
+ if(!HasSdrObject() || !mxPage.is() || pShape == nullptr || nullptr != pShape->GetSdrObject() )
throw uno::RuntimeException();
SdrObject* pSdrShape = mxPage->CreateSdrObject_( xShape );
if( dynamic_cast<const E3dObject* >(pSdrShape) != nullptr )
{
- mpObj->GetSubList()->NbcInsertObject( pSdrShape );
+ GetSdrObject()->GetSubList()->NbcInsertObject( pSdrShape );
if(pShape)
pShape->Create( pSdrShape, mxPage.get() );
@@ -135,8 +136,7 @@ void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape
throw uno::RuntimeException();
}
- if( mpModel )
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
@@ -146,11 +146,11 @@ void SAL_CALL Svx3DSceneObject::remove( const Reference< drawing::XShape >& xSha
SvxShape* pShape = SvxShape::getImplementation( xShape );
- if(!mpObj.is() || pShape == nullptr)
+ if(!HasSdrObject() || pShape == nullptr)
throw uno::RuntimeException();
SdrObject* pSdrShape = pShape->GetSdrObject();
- if(pSdrShape == nullptr || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get())
+ if(pSdrShape == nullptr || pSdrShape->GetObjList()->GetOwnerObj() != GetSdrObject())
{
throw uno::RuntimeException();
}
@@ -184,8 +184,8 @@ sal_Int32 SAL_CALL Svx3DSceneObject::getCount()
sal_Int32 nRetval = 0;
- if(mpObj.is() && dynamic_cast<const E3dScene* >(mpObj.get()) != nullptr && mpObj->GetSubList())
- nRetval = mpObj->GetSubList()->GetObjCount();
+ if(HasSdrObject() && dynamic_cast<const E3dScene* >(GetSdrObject()) != nullptr && GetSdrObject()->GetSubList())
+ nRetval = GetSdrObject()->GetSubList()->GetObjCount();
return nRetval;
}
@@ -194,13 +194,13 @@ uno::Any SAL_CALL Svx3DSceneObject::getByIndex( sal_Int32 Index )
{
SolarMutexGuard aGuard;
- if( !mpObj.is() || mpObj->GetSubList() == nullptr )
+ if( !HasSdrObject() || GetSdrObject()->GetSubList() == nullptr )
throw uno::RuntimeException();
- if( Index<0 || mpObj->GetSubList()->GetObjCount() <= static_cast<size_t>(Index) )
+ if( Index<0 || GetSdrObject()->GetSubList()->GetObjCount() <= static_cast<size_t>(Index) )
throw lang::IndexOutOfBoundsException();
- SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index );
+ SdrObject* pDestObj = GetSdrObject()->GetSubList()->GetObj( Index );
if(pDestObj == nullptr)
throw lang::IndexOutOfBoundsException();
@@ -221,33 +221,16 @@ sal_Bool SAL_CALL Svx3DSceneObject::hasElements()
{
SolarMutexGuard aGuard;
- return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0);
+ return HasSdrObject() && GetSdrObject()->GetSubList() && (GetSdrObject()->GetSubList()->GetObjCount() > 0);
}
static bool ConvertHomogenMatrixToObject( E3dObject* pObject, const Any& rValue )
{
- drawing::HomogenMatrix m;
- if( rValue >>= m )
+ drawing::HomogenMatrix aMat;
+ if( rValue >>= aMat )
{
- basegfx::B3DHomMatrix aMat;
- aMat.set(0, 0, m.Line1.Column1);
- aMat.set(0, 1, m.Line1.Column2);
- aMat.set(0, 2, m.Line1.Column3);
- aMat.set(0, 3, m.Line1.Column4);
- aMat.set(1, 0, m.Line2.Column1);
- aMat.set(1, 1, m.Line2.Column2);
- aMat.set(1, 2, m.Line2.Column3);
- aMat.set(1, 3, m.Line2.Column4);
- aMat.set(2, 0, m.Line3.Column1);
- aMat.set(2, 1, m.Line3.Column2);
- aMat.set(2, 2, m.Line3.Column3);
- aMat.set(2, 3, m.Line3.Column4);
- aMat.set(3, 0, m.Line4.Column1);
- aMat.set(3, 1, m.Line4.Column2);
- aMat.set(3, 2, m.Line4.Column3);
- aMat.set(3, 3, m.Line4.Column4);
- pObject->SetTransform(aMat);
+ pObject->SetTransform(basegfx::utils::UnoHomogenMatrixToB3DHomMatrix(aMat));
return true;
}
return false;
@@ -257,22 +240,7 @@ static void ConvertObjectToHomogenMatric( E3dObject const * pObject, Any& rValue
{
drawing::HomogenMatrix aHomMat;
const basegfx::B3DHomMatrix& rMat = pObject->GetTransform();
- aHomMat.Line1.Column1 = rMat.get(0, 0);
- aHomMat.Line1.Column2 = rMat.get(0, 1);
- aHomMat.Line1.Column3 = rMat.get(0, 2);
- aHomMat.Line1.Column4 = rMat.get(0, 3);
- aHomMat.Line2.Column1 = rMat.get(1, 0);
- aHomMat.Line2.Column2 = rMat.get(1, 1);
- aHomMat.Line2.Column3 = rMat.get(1, 2);
- aHomMat.Line2.Column4 = rMat.get(1, 3);
- aHomMat.Line3.Column1 = rMat.get(2, 0);
- aHomMat.Line3.Column2 = rMat.get(2, 1);
- aHomMat.Line3.Column3 = rMat.get(2, 2);
- aHomMat.Line3.Column4 = rMat.get(2, 3);
- aHomMat.Line4.Column1 = rMat.get(3, 0);
- aHomMat.Line4.Column2 = rMat.get(3, 1);
- aHomMat.Line4.Column3 = rMat.get(3, 2);
- aHomMat.Line4.Column4 = rMat.get(3, 3);
+ basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(rMat, aHomMat);
rValue <<= aHomMat;
}
@@ -290,14 +258,14 @@ bool Svx3DSceneObject::setPropertyValueImpl( const OUString& rName, const SfxIte
case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
{
// patch transformation matrix to the object
- if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
return true;
break;
}
case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY:
{
// set CameraGeometry at scene
- E3dScene* pScene = static_cast< E3dScene* >( mpObj.get() );
+ E3dScene* pScene = static_cast< E3dScene* >( GetSdrObject() );
drawing::CameraGeometry aCamGeo;
if(rValue >>= aCamGeo)
@@ -402,13 +370,13 @@ bool Svx3DSceneObject::getPropertyValueImpl(const OUString& rName, const SfxItem
case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
{
// patch object to a homogeneous 4x4 matrix
- ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+ ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue );
break;
}
case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY:
{
// get CameraGeometry from scene
- E3dScene* pScene = static_cast< E3dScene* >( mpObj.get() );
+ E3dScene* pScene = static_cast< E3dScene* >( GetSdrObject() );
drawing::CameraGeometry aCamGeo;
// fill Vectors from scene camera
@@ -464,7 +432,7 @@ bool Svx3DCubeObject::setPropertyValueImpl( const OUString& rName, const SfxItem
case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
{
// pack transformationmatrix to the object
- if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
return true;
break;
}
@@ -475,7 +443,7 @@ bool Svx3DCubeObject::setPropertyValueImpl( const OUString& rName, const SfxItem
if( rValue >>= aUnoPos )
{
basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ);
- static_cast< E3dCubeObj* >( mpObj.get() )->SetCubePos(aPos);
+ static_cast< E3dCubeObj* >( GetSdrObject() )->SetCubePos(aPos);
return true;
}
break;
@@ -487,7 +455,7 @@ bool Svx3DCubeObject::setPropertyValueImpl( const OUString& rName, const SfxItem
if( rValue >>= aDirection )
{
basegfx::B3DVector aSize(aDirection.DirectionX, aDirection.DirectionY, aDirection.DirectionZ);
- static_cast< E3dCubeObj* >( mpObj.get() )->SetCubeSize(aSize);
+ static_cast< E3dCubeObj* >( GetSdrObject() )->SetCubeSize(aSize);
return true;
}
break;
@@ -498,7 +466,7 @@ bool Svx3DCubeObject::setPropertyValueImpl( const OUString& rName, const SfxItem
// pack sal_Bool bPosIsCenter to the object
if( rValue >>= bNew )
{
- static_cast< E3dCubeObj* >( mpObj.get() )->SetPosIsCenter(bNew);
+ static_cast< E3dCubeObj* >( GetSdrObject() )->SetPosIsCenter(bNew);
return true;
}
break;
@@ -517,13 +485,13 @@ bool Svx3DCubeObject::getPropertyValueImpl( const OUString& rName, const SfxItem
case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
{
// pack transformation to a homogeneous matrix
- ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+ ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue );
break;
}
case OWN_ATTR_3D_VALUE_POSITION:
{
// pack position
- const basegfx::B3DPoint& rPos = static_cast<E3dCubeObj*>(mpObj.get())->GetCubePos();
+ const basegfx::B3DPoint& rPos = static_cast<E3dCubeObj*>(GetSdrObject())->GetCubePos();
drawing::Position3D aPos;
aPos.PositionX = rPos.getX();
@@ -536,7 +504,7 @@ bool Svx3DCubeObject::getPropertyValueImpl( const OUString& rName, const SfxItem
case OWN_ATTR_3D_VALUE_SIZE:
{
// pack size
- const basegfx::B3DVector& rSize = static_cast<E3dCubeObj*>(mpObj.get())->GetCubeSize();
+ const basegfx::B3DVector& rSize = static_cast<E3dCubeObj*>(GetSdrObject())->GetCubeSize();
drawing::Direction3D aDir;
aDir.DirectionX = rSize.getX();
@@ -548,7 +516,7 @@ bool Svx3DCubeObject::getPropertyValueImpl( const OUString& rName, const SfxItem
}
case OWN_ATTR_3D_VALUE_POS_IS_CENTER:
{
- rValue <<= static_cast<E3dCubeObj*>(mpObj.get())->GetPosIsCenter();
+ rValue <<= static_cast<E3dCubeObj*>(GetSdrObject())->GetPosIsCenter();
break;
}
default:
@@ -583,7 +551,7 @@ bool Svx3DSphereObject::setPropertyValueImpl( const OUString& rName, const SfxIt
case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
{
// pack transformation matrix to the object
- if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
return true;
break;
}
@@ -595,7 +563,7 @@ bool Svx3DSphereObject::setPropertyValueImpl( const OUString& rName, const SfxIt
if( rValue >>= aUnoPos )
{
basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ);
- static_cast<E3dSphereObj*>(mpObj.get())->SetCenter(aPos);
+ static_cast<E3dSphereObj*>(GetSdrObject())->SetCenter(aPos);
return true;
}
break;
@@ -608,7 +576,7 @@ bool Svx3DSphereObject::setPropertyValueImpl( const OUString& rName, const SfxIt
if( rValue >>= aDir )
{
basegfx::B3DVector aPos(aDir.DirectionX, aDir.DirectionY, aDir.DirectionZ);
- static_cast<E3dSphereObj*>(mpObj.get())->SetSize(aPos);
+ static_cast<E3dSphereObj*>(GetSdrObject())->SetSize(aPos);
return true;
}
break;
@@ -627,13 +595,13 @@ bool Svx3DSphereObject::getPropertyValueImpl( const OUString& rName, const SfxIt
case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
{
// pack transformation to a homogeneous matrix
- ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+ ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue );
break;
}
case OWN_ATTR_3D_VALUE_POSITION:
{
// pack position
- const basegfx::B3DPoint& rPos = static_cast<E3dSphereObj*>(mpObj.get())->Center();
+ const basegfx::B3DPoint& rPos = static_cast<E3dSphereObj*>(GetSdrObject())->Center();
drawing::Position3D aPos;
aPos.PositionX = rPos.getX();
@@ -646,7 +614,7 @@ bool Svx3DSphereObject::getPropertyValueImpl( const OUString& rName, const SfxIt
case OWN_ATTR_3D_VALUE_SIZE:
{
// pack size
- const basegfx::B3DVector& rSize = static_cast<E3dSphereObj*>(mpObj.get())->Size();
+ const basegfx::B3DVector& rSize = static_cast<E3dSphereObj*>(GetSdrObject())->Size();
drawing::Direction3D aDir;
aDir.DirectionX = rSize.getX();
@@ -776,7 +744,7 @@ bool Svx3DLatheObject::setPropertyValueImpl( const OUString& rName, const SfxIte
case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
{
// pack transformation matrix to the object
- if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
return true;
break;
}
@@ -791,18 +759,18 @@ bool Svx3DLatheObject::setPropertyValueImpl( const OUString& rName, const SfxIte
// #105127# SetPolyPoly3D sets the Svx3DVerticalSegmentsItem to the number
// of points of the polygon. Thus, value gets lost. To avoid this, rescue
// item here and re-set after setting the polygon.
- const sal_uInt32 nPrevVerticalSegs(static_cast<E3dLatheObj*>(mpObj.get())->GetVerticalSegments());
+ const sal_uInt32 nPrevVerticalSegs(static_cast<E3dLatheObj*>(GetSdrObject())->GetVerticalSegments());
// set polygon
const basegfx::B3DHomMatrix aIdentity;
const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity));
- static_cast<E3dLatheObj*>(mpObj.get())->SetPolyPoly2D(aB2DPolyPolygon);
- const sal_uInt32 nPostVerticalSegs(static_cast<E3dLatheObj*>(mpObj.get())->GetVerticalSegments());
+ static_cast<E3dLatheObj*>(GetSdrObject())->SetPolyPoly2D(aB2DPolyPolygon);
+ const sal_uInt32 nPostVerticalSegs(static_cast<E3dLatheObj*>(GetSdrObject())->GetVerticalSegments());
if(nPrevVerticalSegs != nPostVerticalSegs)
{
// restore the vertical segment count
- static_cast<E3dLatheObj*>(mpObj.get())->SetMergedItem(makeSvx3DVerticalSegmentsItem(nPrevVerticalSegs));
+ static_cast<E3dLatheObj*>(GetSdrObject())->SetMergedItem(makeSvx3DVerticalSegmentsItem(nPrevVerticalSegs));
}
return true;
}
@@ -823,32 +791,14 @@ bool Svx3DLatheObject::getPropertyValueImpl( const OUString& rName, const SfxIte
{
// pack transformation to a homogeneous matrix
drawing::HomogenMatrix aHomMat;
- basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(mpObj.get())->GetTransform();
-
- // pack evtl. transformed matrix to output
- aHomMat.Line1.Column1 = aMat.get(0, 0);
- aHomMat.Line1.Column2 = aMat.get(0, 1);
- aHomMat.Line1.Column3 = aMat.get(0, 2);
- aHomMat.Line1.Column4 = aMat.get(0, 3);
- aHomMat.Line2.Column1 = aMat.get(1, 0);
- aHomMat.Line2.Column2 = aMat.get(1, 1);
- aHomMat.Line2.Column3 = aMat.get(1, 2);
- aHomMat.Line2.Column4 = aMat.get(1, 3);
- aHomMat.Line3.Column1 = aMat.get(2, 0);
- aHomMat.Line3.Column2 = aMat.get(2, 1);
- aHomMat.Line3.Column3 = aMat.get(2, 2);
- aHomMat.Line3.Column4 = aMat.get(2, 3);
- aHomMat.Line4.Column1 = aMat.get(3, 0);
- aHomMat.Line4.Column2 = aMat.get(3, 1);
- aHomMat.Line4.Column3 = aMat.get(3, 2);
- aHomMat.Line4.Column4 = aMat.get(3, 3);
-
+ basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(GetSdrObject())->GetTransform();
+ basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(aMat, aHomMat);
rValue <<= aHomMat;
break;
}
case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
{
- const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dLatheObj*>(mpObj.get())->GetPolyPoly2D();
+ const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dLatheObj*>(GetSdrObject())->GetPolyPoly2D();
const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly));
B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue);
@@ -886,7 +836,7 @@ bool Svx3DExtrudeObject::setPropertyValueImpl( const OUString& rName, const SfxI
case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
{
// pack transformation matrix to the object
- if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
return true;
break;
}
@@ -902,7 +852,7 @@ bool Svx3DExtrudeObject::setPropertyValueImpl( const OUString& rName, const SfxI
// set polygon
const basegfx::B3DHomMatrix aIdentity;
const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity));
- static_cast<E3dExtrudeObj*>(mpObj.get())->SetExtrudePolygon(aB2DPolyPolygon);
+ static_cast<E3dExtrudeObj*>(GetSdrObject())->SetExtrudePolygon(aB2DPolyPolygon);
return true;
}
break;
@@ -922,26 +872,8 @@ bool Svx3DExtrudeObject::getPropertyValueImpl( const OUString& rName, const SfxI
{
// pack transformation to a homogeneous matrix
drawing::HomogenMatrix aHomMat;
- basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(mpObj.get())->GetTransform();
-
- // pack evtl. transformed matrix to output
- aHomMat.Line1.Column1 = aMat.get(0, 0);
- aHomMat.Line1.Column2 = aMat.get(0, 1);
- aHomMat.Line1.Column3 = aMat.get(0, 2);
- aHomMat.Line1.Column4 = aMat.get(0, 3);
- aHomMat.Line2.Column1 = aMat.get(1, 0);
- aHomMat.Line2.Column2 = aMat.get(1, 1);
- aHomMat.Line2.Column3 = aMat.get(1, 2);
- aHomMat.Line2.Column4 = aMat.get(1, 3);
- aHomMat.Line3.Column1 = aMat.get(2, 0);
- aHomMat.Line3.Column2 = aMat.get(2, 1);
- aHomMat.Line3.Column3 = aMat.get(2, 2);
- aHomMat.Line3.Column4 = aMat.get(2, 3);
- aHomMat.Line4.Column1 = aMat.get(3, 0);
- aHomMat.Line4.Column2 = aMat.get(3, 1);
- aHomMat.Line4.Column3 = aMat.get(3, 2);
- aHomMat.Line4.Column4 = aMat.get(3, 3);
-
+ basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(GetSdrObject())->GetTransform();
+ basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(aMat, aHomMat);
rValue <<= aHomMat;
break;
}
@@ -949,7 +881,7 @@ bool Svx3DExtrudeObject::getPropertyValueImpl( const OUString& rName, const SfxI
case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
{
// pack polygon definition
- const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dExtrudeObj*>(mpObj.get())->GetExtrudePolygon();
+ const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dExtrudeObj*>(GetSdrObject())->GetExtrudePolygon();
const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly));
B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue);
@@ -987,7 +919,7 @@ bool Svx3DPolygonObject::setPropertyValueImpl( const OUString& rName, const SfxI
case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
{
// pack transformation matrix to the object
- if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
return true;
break;
}
@@ -1001,7 +933,7 @@ bool Svx3DPolygonObject::setPropertyValueImpl( const OUString& rName, const SfxI
if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) )
{
// set polygon
- static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyPolygon3D(aNewB3DPolyPolygon);
+ static_cast<E3dPolygonObj*>(GetSdrObject())->SetPolyPolygon3D(aNewB3DPolyPolygon);
return true;
}
break;
@@ -1015,7 +947,7 @@ bool Svx3DPolygonObject::setPropertyValueImpl( const OUString& rName, const SfxI
if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) )
{
// set polygon
- static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyNormals3D(aNewB3DPolyPolygon);
+ static_cast<E3dPolygonObj*>(GetSdrObject())->SetPolyNormals3D(aNewB3DPolyPolygon);
return true;
}
break;
@@ -1031,7 +963,7 @@ bool Svx3DPolygonObject::setPropertyValueImpl( const OUString& rName, const SfxI
// set polygon
const basegfx::B3DHomMatrix aIdentity;
const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity));
- static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyTexture2D(aB2DPolyPolygon);
+ static_cast<E3dPolygonObj*>(GetSdrObject())->SetPolyTexture2D(aB2DPolyPolygon);
return true;
}
break;
@@ -1041,7 +973,7 @@ bool Svx3DPolygonObject::setPropertyValueImpl( const OUString& rName, const SfxI
bool bNew = false;
if( rValue >>= bNew )
{
- static_cast<E3dPolygonObj*>(mpObj.get())->SetLineOnly(bNew);
+ static_cast<E3dPolygonObj*>(GetSdrObject())->SetLineOnly(bNew);
return true;
}
break;
@@ -1059,26 +991,26 @@ bool Svx3DPolygonObject::getPropertyValueImpl( const OUString& rName, const SfxI
{
case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
{
- ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+ ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue );
break;
}
case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
{
- B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyPolygon3D(),rValue);
+ B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(GetSdrObject())->GetPolyPolygon3D(),rValue);
break;
}
case OWN_ATTR_3D_VALUE_NORMALSPOLYGON3D:
{
- B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyNormals3D(),rValue);
+ B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(GetSdrObject())->GetPolyNormals3D(),rValue);
break;
}
case OWN_ATTR_3D_VALUE_TEXTUREPOLYGON3D:
{
// pack texture definition
- const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyTexture2D();
+ const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dPolygonObj*>(GetSdrObject())->GetPolyTexture2D();
const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly));
B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon,rValue);
@@ -1087,7 +1019,7 @@ bool Svx3DPolygonObject::getPropertyValueImpl( const OUString& rName, const SfxI
case OWN_ATTR_3D_VALUE_LINEONLY:
{
- rValue <<= static_cast<E3dPolygonObj*>(mpObj.get())->GetLineOnly();
+ rValue <<= static_cast<E3dPolygonObj*>(GetSdrObject())->GetLineOnly();
break;
}
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
index a5ef378525f7..c9e40652e372 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -90,10 +90,10 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro
// TODO/LATER: seems to make no sense for iconified object
awt::Rectangle aVisArea;
- if( (rValue >>= aVisArea) && dynamic_cast<const SdrOle2Obj* >(mpObj.get()) != nullptr)
+ if( (rValue >>= aVisArea) && dynamic_cast<const SdrOle2Obj* >(GetSdrObject()) != nullptr)
{
Size aTmp( aVisArea.X + aVisArea.Width, aVisArea.Y + aVisArea.Height );
- uno::Reference < embed::XEmbeddedObject > xObj = static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef();
+ uno::Reference < embed::XEmbeddedObject > xObj = static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef();
if( xObj.is() )
{
try
@@ -118,7 +118,7 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro
sal_Int64 nAspect = 0;
if( rValue >>= nAspect )
{
- static_cast<SdrOle2Obj*>(mpObj.get())->SetAspect( nAspect );
+ static_cast<SdrOle2Obj*>(GetSdrObject())->SetAspect( nAspect );
return true;
}
break;
@@ -144,7 +144,7 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro
if( xGraphic.is() )
{
const Graphic aGraphic(xGraphic);
- static_cast<SdrOle2Obj*>(mpObj.get())->SetGraphic(aGraphic);
+ static_cast<SdrOle2Obj*>(GetSdrObject())->SetGraphic(aGraphic);
return true;
}
break;
@@ -154,7 +154,7 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro
uno::Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
if( xGraphic.is() )
{
- SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
if( pOle )
{
GraphicObject aGrafObj( xGraphic );
@@ -172,10 +172,10 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro
{
SdrOle2Obj *pOle;
#if OSL_DEBUG_LEVEL > 0
- pOle = dynamic_cast<SdrOle2Obj*>(mpObj.get());
+ pOle = dynamic_cast<SdrOle2Obj*>(GetSdrObject());
assert(pOle);
#else
- pOle = static_cast<SdrOle2Obj*>(mpObj.get());
+ pOle = static_cast<SdrOle2Obj*>(GetSdrObject());
#endif
pOle->SetPersistName( aPersistName );
return true;
@@ -220,7 +220,7 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
case OWN_ATTR_METAFILE:
{
- SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get());
+ SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(GetSdrObject());
if( pObj )
{
const Graphic* pGraphic = pObj->GetGraphic();
@@ -260,10 +260,10 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
case OWN_ATTR_OLE_VISAREA:
{
awt::Rectangle aVisArea;
- if( dynamic_cast<const SdrOle2Obj* >(mpObj.get()) != nullptr)
+ if( dynamic_cast<const SdrOle2Obj* >(GetSdrObject()) != nullptr)
{
MapMode aMapMode( MapUnit::Map100thMM ); // the API uses this map mode
- Size aTmp = static_cast<SdrOle2Obj*>(mpObj.get())->GetOrigObjSize( &aMapMode ); // get the size in the requested map mode
+ Size aTmp = static_cast<SdrOle2Obj*>(GetSdrObject())->GetOrigObjSize( &aMapMode ); // get the size in the requested map mode
aVisArea = awt::Rectangle( 0, 0, aTmp.Width(), aTmp.Height() );
}
@@ -273,14 +273,14 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
case OWN_ATTR_OLESIZE:
{
- Size aTmp( static_cast<SdrOle2Obj*>(mpObj.get())->GetOrigObjSize() );
+ Size aTmp( static_cast<SdrOle2Obj*>(GetSdrObject())->GetOrigObjSize() );
rValue <<= awt::Size( aTmp.Width(), aTmp.Height() );
break;
}
case OWN_ATTR_OLE_ASPECT:
{
- rValue <<= static_cast<SdrOle2Obj*>(mpObj.get())->GetAspect();
+ rValue <<= static_cast<SdrOle2Obj*>(GetSdrObject())->GetAspect();
break;
}
@@ -288,7 +288,7 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
case OWN_ATTR_OLE_EMBEDDED_OBJECT:
case OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT:
{
- SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>( mpObj.get() );
+ SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>( GetSdrObject() );
if( pObj )
{
uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() );
@@ -315,7 +315,7 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
case OWN_ATTR_VALUE_GRAPHIC:
{
uno::Reference< graphic::XGraphic > xGraphic;
- const Graphic* pGraphic = static_cast<SdrOle2Obj*>( mpObj.get() )->GetGraphic();
+ const Graphic* pGraphic = static_cast<SdrOle2Obj*>( GetSdrObject() )->GetGraphic();
if( pGraphic )
xGraphic = pGraphic->GetXGraphic();
rValue <<= xGraphic;
@@ -325,7 +325,7 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
case OWN_ATTR_THUMBNAIL:
{
uno::Reference< graphic::XGraphic > xGraphic;
- const Graphic* pGraphic = static_cast<SdrOle2Obj*>( mpObj.get() )->GetGraphic();
+ const Graphic* pGraphic = static_cast<SdrOle2Obj*>( GetSdrObject() )->GetGraphic();
if( pGraphic )
xGraphic = pGraphic->GetXGraphic();
rValue <<= xGraphic;
@@ -334,14 +334,14 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
case OWN_ATTR_PERSISTNAME:
{
OUString aPersistName;
- SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
if( pOle )
{
aPersistName = pOle->GetPersistName();
if( !aPersistName.isEmpty() )
{
- ::comphelper::IEmbeddedHelper *pPersist = mpObj->GetModel()->GetPersist();
+ ::comphelper::IEmbeddedHelper* pPersist(GetSdrObject()->getSdrModelFromSdrObject().GetPersist());
if( (nullptr == pPersist) || !pPersist->getEmbeddedObjectContainer().HasEmbeddedObject( pOle->GetPersistName() ) )
aPersistName.clear();
}
@@ -353,7 +353,7 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
case OWN_ATTR_OLE_LINKURL:
{
OUString aLinkURL;
- SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
if( pOle )
{
@@ -376,12 +376,12 @@ bool SvxOle2Shape::createObject( const SvGlobalName &aClassName )
{
DBG_TESTSOLARMUTEX();
- SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
if ( !pOle2Obj || !pOle2Obj->IsEmpty() )
return false;
// create storage and inplace object
- ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist();
+ ::comphelper::IEmbeddedHelper* pPersist = GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
OUString aPersistName;
OUString aTmpStr;
if( SvxShape::getPropertyValue( UNO_NAME_OLE2_PERSISTNAME ) >>= aTmpStr )
@@ -438,13 +438,13 @@ void SvxOle2Shape::createLink( const OUString& aLinkURL )
{
DBG_TESTSOLARMUTEX();
- SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
if ( !pOle2Obj || !pOle2Obj->IsEmpty() )
return;
OUString aPersistName;
- ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist();
+ ::comphelper::IEmbeddedHelper* pPersist = GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
uno::Sequence< beans::PropertyValue > aMediaDescr( 1 );
aMediaDescr[0].Name = "URL";
@@ -497,10 +497,10 @@ void SvxOle2Shape::createLink( const OUString& aLinkURL )
void SvxOle2Shape::resetModifiedState()
{
- ::comphelper::IEmbeddedHelper* pPersist = mpModel ? mpModel->GetPersist() : nullptr;
+ ::comphelper::IEmbeddedHelper* pPersist = GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
if( pPersist && !pPersist->isEnableSetModified() )
{
- SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
if( pOle && !pOle->IsEmpty() )
{
uno::Reference < util::XModifiable > xMod( pOle->GetObjRef(), uno::UNO_QUERY );
@@ -515,7 +515,7 @@ const SvGlobalName SvxOle2Shape::GetClassName_Impl(OUString& rHexCLSID)
{
DBG_TESTSOLARMUTEX();
SvGlobalName aClassName;
- SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
if( pOle2Obj )
{
@@ -523,7 +523,7 @@ const SvGlobalName SvxOle2Shape::GetClassName_Impl(OUString& rHexCLSID)
if( pOle2Obj->IsEmpty() )
{
- ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist();
+ ::comphelper::IEmbeddedHelper* pPersist = GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
if( pPersist )
{
uno::Reference < embed::XEmbeddedObject > xObj =
@@ -584,9 +584,9 @@ bool SvxAppletShape::setPropertyValueImpl( const OUString& rName, const SfxItemP
{
if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) )
{
- if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
{
- uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
if( xSet.is() )
{
// allow exceptions to pass through
@@ -605,9 +605,9 @@ bool SvxAppletShape::getPropertyValueImpl( const OUString& rName, const SfxItemP
{
if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) )
{
- if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
{
- uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
if( xSet.is() )
{
rValue = xSet->getPropertyValue( rName );
@@ -655,9 +655,9 @@ bool SvxPluginShape::setPropertyValueImpl( const OUString& rName, const SfxItemP
{
if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) )
{
- if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
{
- uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
if( xSet.is() )
{
// allow exceptions to pass through
@@ -676,9 +676,9 @@ bool SvxPluginShape::getPropertyValueImpl( const OUString& rName, const SfxItemP
{
if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) )
{
- if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
{
- uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
if( xSet.is() )
{
rValue = xSet->getPropertyValue( rName );
@@ -727,9 +727,9 @@ bool SvxFrameShape::setPropertyValueImpl( const OUString& rName, const SfxItemPr
{
if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) )
{
- if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
{
- uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
if( xSet.is() )
{
// allow exceptions to pass through
@@ -749,9 +749,9 @@ bool SvxFrameShape::getPropertyValueImpl(const OUString& rName, const SfxItemPro
{
if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) )
{
- if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
{
- uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
if( xSet.is() )
{
rValue = xSet->getPropertyValue( rName );
@@ -783,7 +783,7 @@ bool SvxMediaShape::setPropertyValueImpl( const OUString& rName, const SfxItemPr
|| (pProperty->nWID == OWN_ATTR_MEDIA_STREAM)
|| (pProperty->nWID == OWN_ATTR_MEDIA_MIMETYPE) )
{
- SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() );
+ SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( GetSdrObject() );
::avmedia::MediaItem aItem;
bool bOk = false;
@@ -926,7 +926,7 @@ bool SvxMediaShape::getPropertyValueImpl( const OUString& rName, const SfxItemPr
|| (pProperty->nWID == OWN_ATTR_MEDIA_MIMETYPE)
|| (pProperty->nWID == OWN_ATTR_FALLBACK_GRAPHIC))
{
- SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() );
+ SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( GetSdrObject() );
const ::avmedia::MediaItem aItem( pMedia->getMediaProperties() );
switch( pProperty->nWID )
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 572b31c44313..c726444e814d 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -180,8 +180,7 @@ SvxShape::SvxShape( SdrObject* pObject )
, mbIsMultiPropertyCall(false)
, mpPropSet(getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
, maPropMapEntries(getSvxMapProvider().GetMap(SVXMAP_SHAPE))
-, mpObj(pObject)
-, mpModel(nullptr)
+, mpSdrObjectWeakReference(pObject)
, mnLockCount(0)
{
impl_construct();
@@ -194,8 +193,7 @@ SvxShape::SvxShape( SdrObject* pObject, const SfxItemPropertyMapEntry* pEntries,
, mbIsMultiPropertyCall(false)
, mpPropSet(pPropertySet)
, maPropMapEntries(pEntries)
-, mpObj(pObject)
-, mpModel(nullptr)
+, mpSdrObjectWeakReference(pObject)
, mnLockCount(0)
{
impl_construct();
@@ -208,8 +206,7 @@ SvxShape::SvxShape()
, mbIsMultiPropertyCall(false)
, mpPropSet(getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
, maPropMapEntries(getSvxMapProvider().GetMap(SVXMAP_SHAPE))
-, mpObj(nullptr)
-, mpModel(nullptr)
+, mpSdrObjectWeakReference(nullptr)
, mnLockCount(0)
{
impl_construct();
@@ -222,19 +219,19 @@ SvxShape::~SvxShape() throw()
DBG_ASSERT( mnLockCount == 0, "Locked shape was disposed!" );
- if ( mpModel )
- EndListening( *mpModel );
-
if ( mpImpl->mpMaster )
mpImpl->mpMaster->dispose();
- if ( mpObj.is() )
- mpObj->setUnoShape(nullptr);
+ if ( HasSdrObject() )
+ {
+ EndListening(GetSdrObject()->getSdrModelFromSdrObject());
+ GetSdrObject()->setUnoShape(nullptr);
+ }
- if( HasSdrObjectOwnership() && mpObj.is() )
+ if( HasSdrObjectOwnership() && HasSdrObject() )
{
mpImpl->mbHasSdrObjectOwnership = false;
- SdrObject* pObject = mpObj.get();
+ SdrObject* pObject = GetSdrObject();
SdrObject::Free( pObject );
}
@@ -248,13 +245,23 @@ void SvxShape::TakeSdrObjectOwnership()
}
+void SvxShape::InvalidateSdrObject()
+{
+ if(HasSdrObject())
+ {
+ EndListening(GetSdrObject()->getSdrModelFromSdrObject());
+ }
+
+ mpSdrObjectWeakReference.reset( nullptr );
+};
+
bool SvxShape::HasSdrObjectOwnership() const
{
if ( !mpImpl->mbHasSdrObjectOwnership )
return false;
- OSL_ENSURE( mpObj.is(), "SvxShape::HasSdrObjectOwnership: have the ownership of an object which I don't know!" );
- return mpObj.is();
+ OSL_ENSURE( HasSdrObject(), "SvxShape::HasSdrObjectOwnership: have the ownership of an object which I don't know!" );
+ return HasSdrObject();
}
@@ -335,40 +342,31 @@ void SvxShape::impl_construct()
mpImpl->maPropertyNotifier.registerProvider( svx::ShapeProperty::Size,
std::shared_ptr<svx::IPropertyValueProvider>( new ShapeSizeProvider( *mpImpl ) ) );
- if ( mpObj.is() )
+ if ( HasSdrObject() )
+ {
+ StartListening(GetSdrObject()->getSdrModelFromSdrObject());
impl_initFromSdrObject();
+ }
}
void SvxShape::impl_initFromSdrObject()
{
DBG_TESTSOLARMUTEX();
- OSL_PRECOND( mpObj.is(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" );
- if ( !mpObj.is() )
+ OSL_PRECOND( HasSdrObject(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" );
+ if ( !HasSdrObject() )
return;
osl_atomic_increment( &m_refCount );
{
- mpObj->setUnoShape(*this);
+ GetSdrObject()->setUnoShape(*this);
}
osl_atomic_decrement( &m_refCount );
- auto pNewModel = mpObj->GetModel();
-
- if (pNewModel != mpModel)
- {
- if (mpModel)
- EndListening( *mpModel );
- if (pNewModel)
- StartListening( *pNewModel );
- mpModel = pNewModel;
- }
-
// #i40944#
// Do not simply return when no model but do the type corrections
// following below.
-
- const SdrInventor nInventor = mpObj->GetObjInventor();
+ const SdrInventor nInventor = GetSdrObject()->GetObjInventor();
// is it one of ours (svx) ?
if( nInventor == SdrInventor::Default || nInventor == SdrInventor::E3d || nInventor == SdrInventor::FmForm )
@@ -379,7 +377,7 @@ void SvxShape::impl_initFromSdrObject()
}
else
{
- mpImpl->mnObjId = mpObj->GetObjIdentifier();
+ mpImpl->mnObjId = GetSdrObject()->GetObjIdentifier();
if( nInventor == SdrInventor::E3d )
mpImpl->mnObjId |= E3D_INVENTOR_FLAG;
}
@@ -412,16 +410,20 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ )
if ( pCreatedObj == pNewObj )
return;
- DBG_ASSERT( pNewObj->GetModel(), "no model for SdrObject?" );
// Correct condition (#i52126#)
mpImpl->mpCreatedObj = pNewObj;
- if( mpObj.is() && mpObj->GetModel() )
+ if( HasSdrObject() )
{
- EndListening( *mpObj->GetModel() );
+ EndListening( GetSdrObject()->getSdrModelFromSdrObject() );
}
- mpObj.reset( pNewObj );
+ mpSdrObjectWeakReference.reset( pNewObj );
+
+ if( HasSdrObject() )
+ {
+ StartListening( GetSdrObject()->getSdrModelFromSdrObject() );
+ }
OSL_ENSURE( !mbIsMultiPropertyCall, "SvxShape::Create: hmm?" );
// this was previously set in impl_initFromSdrObject, but I think it was superfluous
@@ -432,63 +434,29 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ )
ObtainSettingsFromPropertySet( *mpPropSet );
// save user call
- SdrObjUserCall* pUser = mpObj->GetUserCall();
- mpObj->SetUserCall(nullptr);
+ SdrObjUserCall* pUser = GetSdrObject()->GetUserCall();
+ GetSdrObject()->SetUserCall(nullptr);
setPosition( maPosition );
setSize( maSize );
// restore user call after we set the initial size
- mpObj->SetUserCall( pUser );
+ GetSdrObject()->SetUserCall( pUser );
// if this shape was already named, use this name
if( !maShapeName.isEmpty() )
{
- mpObj->SetName( maShapeName );
+ GetSdrObject()->SetName( maShapeName );
maShapeName.clear();
}
}
-
-void SvxShape::ChangeModel( SdrModel* pNewModel )
-{
- DBG_TESTSOLARMUTEX();
- if( mpObj.is() && mpObj->GetModel() )
- {
- if( mpObj->GetModel() != pNewModel )
- {
- EndListening( *mpObj->GetModel() );
- }
- }
-
- // Always listen to new model (#i52126#)
- if( pNewModel )
- {
- StartListening( *pNewModel );
- }
-
- // HACK #i53696# ChangeModel should be virtual, but it isn't. can't change that for 2.0.1
- SvxShapeText* pShapeText = dynamic_cast< SvxShapeText* >( this );
- if( pShapeText )
- {
- SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( pShapeText->GetEditSource() );
- if( pTextEditSource )
- pTextEditSource->ChangeModel( pNewModel );
- }
-
- mpModel = pNewModel;
-
- if( mpImpl->mpMaster )
- mpImpl->mpMaster->modelChanged( pNewModel );
-}
-
-
void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw()
{
DBG_TESTSOLARMUTEX();
- if(mpModel)
+ if(HasSdrObject())
{
- MapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0);
+ MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
if(eMapUnit != MapUnit::Map100thMM)
{
switch(eMapUnit)
@@ -512,9 +480,9 @@ void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw()
void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const throw()
{
DBG_TESTSOLARMUTEX();
- if(mpModel)
+ if(HasSdrObject())
{
- MapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0);
+ MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
if(eMapUnit != MapUnit::Map100thMM)
{
switch(eMapUnit)
@@ -542,9 +510,9 @@ void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw()
{
DBG_TESTSOLARMUTEX();
MapUnit eMapUnit = MapUnit::Map100thMM;
- if(mpModel)
+ if(HasSdrObject())
{
- eMapUnit = mpModel->GetItemPool().GetMetric(0);
+ eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
if(eMapUnit != MapUnit::Map100thMM)
{
switch(eMapUnit)
@@ -569,9 +537,9 @@ void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) cons
{
DBG_TESTSOLARMUTEX();
MapUnit eMapUnit = MapUnit::Map100thMM;
- if(mpModel)
+ if(HasSdrObject())
{
- eMapUnit = mpModel->GetItemPool().GetMetric(0);
+ eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
if(eMapUnit != MapUnit::Map100thMM)
{
switch(eMapUnit)
@@ -651,15 +619,15 @@ void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet&
void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet)
{
DBG_TESTSOLARMUTEX();
- if(mpObj.is() && rPropSet.AreThereOwnUsrAnys() && mpModel)
+ if(HasSdrObject() && rPropSet.AreThereOwnUsrAnys())
{
- SfxItemSet aSet( mpModel->GetItemPool(), svl::Items<SDRATTR_START, SDRATTR_END>{});
+ SfxItemSet aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), svl::Items<SDRATTR_START, SDRATTR_END>{});
Reference< beans::XPropertySet > xShape( static_cast<OWeakObject*>(this), UNO_QUERY );
SvxItemPropertySet_ObtainSettingsFromPropertySet(rPropSet, aSet, xShape, &mpPropSet->getPropertyMap() );
- mpObj->SetMergedItemSetAndBroadcast(aSet);
+ GetSdrObject()->SetMergedItemSetAndBroadcast(aSet);
- mpObj->ApplyNotPersistAttr( aSet );
+ GetSdrObject()->ApplyNotPersistAttr( aSet );
}
}
@@ -668,20 +636,21 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const
DBG_TESTSOLARMUTEX();
uno::Any aAny;
- if( !mpObj.is() || mpModel == nullptr || !mpObj->IsInserted() || nullptr == mpObj->GetPage() )
+ if( !HasSdrObject() || !GetSdrObject()->IsInserted() || nullptr == GetSdrObject()->GetPage() )
return aAny;
ScopedVclPtrInstance< VirtualDevice > pVDev;
pVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
+ SdrPage* pPage = GetSdrObject()->GetPage();
- SdrModel* pModel = mpObj->GetModel();
- SdrPage* pPage = mpObj->GetPage();
-
- std::unique_ptr<E3dView> pView(new E3dView( pModel, pVDev.get() ));
+ std::unique_ptr<E3dView> pView(
+ new E3dView(
+ GetSdrObject()->getSdrModelFromSdrObject(),
+ pVDev.get()));
pView->hideMarkHandles();
SdrPageView* pPageView = pView->ShowSdrPage(pPage);
- SdrObject *pTempObj = mpObj.get();
+ SdrObject *pTempObj = GetSdrObject();
pView->MarkObj(pTempObj,pPageView);
tools::Rectangle aRect(pTempObj->GetCurrentBoundRect());
@@ -1011,7 +980,7 @@ uno::Sequence< sal_Int8 > SAL_CALL SvxShape::getImplementationId()
void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
{
DBG_TESTSOLARMUTEX();
- if( !mpObj.is() )
+ if( !HasSdrObject() )
return;
// #i55919# SdrHintKind::ObjectChange is only interesting if it's for this object
@@ -1019,13 +988,14 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>(&rHint);
if (!pSdrHint ||
((pSdrHint->GetKind() != SdrHintKind::ModelCleared) &&
- (pSdrHint->GetKind() != SdrHintKind::ObjectChange || pSdrHint->GetObject() != mpObj.get() )))
+ (pSdrHint->GetKind() != SdrHintKind::ObjectChange || pSdrHint->GetObject() != GetSdrObject() )))
return;
- uno::Reference< uno::XInterface > xSelf( mpObj->getWeakUnoShape() );
+ uno::Reference< uno::XInterface > xSelf( GetSdrObject()->getWeakUnoShape() );
if( !xSelf.is() )
{
- mpObj.reset( nullptr );
+ EndListening(GetSdrObject()->getSdrModelFromSdrObject());
+ mpSdrObjectWeakReference.reset( nullptr );
return;
}
@@ -1041,7 +1011,6 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
case SdrHintKind::ModelCleared:
{
bClearMe = true;
- mpModel = nullptr;
break;
}
default:
@@ -1050,13 +1019,30 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
if( bClearMe )
{
- if( !HasSdrObjectOwnership() ) {
- if( mpObj.is() )
- mpObj->setUnoShape( nullptr );
- mpObj.reset( nullptr );
+ SdrObject* pSdrObject(GetSdrObject());
+
+ if(!HasSdrObjectOwnership())
+ {
+ if(nullptr != pSdrObject)
+ {
+ EndListening(pSdrObject->getSdrModelFromSdrObject());
+ pSdrObject->setUnoShape(nullptr);
+ }
+
+ mpSdrObjectWeakReference.reset(nullptr);
+
+ // SdrModel *is* going down, try to Free SdrObject even
+ // when !HasSdrObjectOwnership
+ if(nullptr != pSdrObject && !pSdrObject->IsInserted())
+ {
+ SdrObject::Free(pSdrObject);
+ }
}
- if ( !mpImpl->mbDisposing )
+
+ if(!mpImpl->mbDisposing)
+ {
dispose();
+ }
}
}
@@ -1125,14 +1111,14 @@ awt::Point SAL_CALL SvxShape::getPosition()
{
::SolarMutexGuard aGuard;
- if( mpObj.is() && mpModel)
+ if(HasSdrObject())
{
- tools::Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
+ tools::Rectangle aRect( svx_getLogicRectHack(GetSdrObject()) );
Point aPt( aRect.Left(), aRect.Top() );
// Position is relative to anchor, so recalc to absolute position
- if( mpModel->IsWriter() )
- aPt -= mpObj->GetAnchorPos();
+ if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+ aPt -= GetSdrObject()->GetAnchorPos();
ForceMetricTo100th_mm(aPt);
return css::awt::Point( aPt.X(), aPt.Y() );
@@ -1148,25 +1134,25 @@ void SAL_CALL SvxShape::setPosition( const awt::Point& Position )
{
::SolarMutexGuard aGuard;
- if( mpObj.is() && mpModel )
+ if(HasSdrObject())
{
// do NOT move 3D objects, this would change the homogen
// transformation matrix
- if(dynamic_cast<const E3dCompoundObject* >(mpObj.get()) == nullptr)
+ if(dynamic_cast<const E3dCompoundObject* >(GetSdrObject()) == nullptr)
{
- tools::Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
+ tools::Rectangle aRect( svx_getLogicRectHack(GetSdrObject()) );
Point aLocalPos( Position.X, Position.Y );
ForceMetricToItemPoolMetric(aLocalPos);
// Position is absolute, so recalc to position relative to anchor
- if( mpModel->IsWriter() )
- aLocalPos += mpObj->GetAnchorPos();
+ if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+ aLocalPos += GetSdrObject()->GetAnchorPos();
long nDX = aLocalPos.X() - aRect.Left();
long nDY = aLocalPos.Y() - aRect.Top();
- mpObj->Move( Size( nDX, nDY ) );
- mpModel->SetChanged();
+ GetSdrObject()->Move( Size( nDX, nDY ) );
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
}
@@ -1178,9 +1164,9 @@ awt::Size SAL_CALL SvxShape::getSize()
{
::SolarMutexGuard aGuard;
- if( mpObj.is() && mpModel)
+ if(HasSdrObject())
{
- tools::Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
+ tools::Rectangle aRect( svx_getLogicRectHack(GetSdrObject()) );
Size aObjSize( aRect.getWidth(), aRect.getHeight() );
ForceMetricTo100th_mm(aObjSize);
return css::awt::Size( aObjSize.getWidth(), aObjSize.getHeight() );
@@ -1194,26 +1180,26 @@ void SAL_CALL SvxShape::setSize( const awt::Size& rSize )
{
::SolarMutexGuard aGuard;
- if( mpObj.is() && mpModel)
+ if(HasSdrObject())
{
// #i123539# optimization for 3D chart object generation: do not use UNO
// API commands to get the range, this is too expensive since for 3D
// scenes it may recalculate the whole scene since in AOO this depends
// on the contained geometry (layouted to show all content)
- const bool b3DConstruction(dynamic_cast< E3dObject* >(mpObj.get()) && mpModel->isLocked());
+ const bool b3DConstruction(dynamic_cast< E3dObject* >(GetSdrObject()) && GetSdrObject()->getSdrModelFromSdrObject().isLocked());
tools::Rectangle aRect(
b3DConstruction ?
tools::Rectangle(maPosition.X, maPosition.Y, maSize.Width, maSize.Height) :
- svx_getLogicRectHack(mpObj.get()) );
+ svx_getLogicRectHack(GetSdrObject()) );
Size aLocalSize( rSize.Width, rSize.Height );
ForceMetricToItemPoolMetric(aLocalSize);
- if(mpObj->GetObjInventor() == SdrInventor::Default && mpObj->GetObjIdentifier() == OBJ_MEASURE )
+ if(GetSdrObject()->GetObjInventor() == SdrInventor::Default && GetSdrObject()->GetObjIdentifier() == OBJ_MEASURE )
{
Fraction aWdt(aLocalSize.Width(),aRect.Right()-aRect.Left());
Fraction aHgt(aLocalSize.Height(),aRect.Bottom()-aRect.Top());
- Point aPt = mpObj->GetSnapRect().TopLeft();
- mpObj->Resize(aPt,aWdt,aHgt);
+ Point aPt = GetSdrObject()->GetSnapRect().TopLeft();
+ GetSdrObject()->Resize(aPt,aWdt,aHgt);
}
else
{
@@ -1231,10 +1217,10 @@ void SAL_CALL SvxShape::setSize( const awt::Size& rSize )
else
aRect.setHeight(aLocalSize.Height());
- svx_setLogicRectHack( mpObj.get(), aRect );
+ svx_setLogicRectHack( GetSdrObject(), aRect );
}
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
maSize = rSize;
}
@@ -1244,9 +1230,9 @@ void SAL_CALL SvxShape::setSize( const awt::Size& rSize )
OUString SAL_CALL SvxShape::getName( )
{
::SolarMutexGuard aGuard;
- if( mpObj.is() )
+ if( HasSdrObject() )
{
- return mpObj->GetName();
+ return GetSdrObject()->GetName();
}
else
{
@@ -1258,9 +1244,9 @@ OUString SAL_CALL SvxShape::getName( )
void SAL_CALL SvxShape::setName( const OUString& aName )
{
::SolarMutexGuard aGuard;
- if( mpObj.is() )
+ if( HasSdrObject() )
{
- mpObj->SetName( aName );
+ GetSdrObject()->SetName( aName );
}
else
{
@@ -1296,47 +1282,42 @@ void SAL_CALL SvxShape::dispose()
mpImpl->maDisposeListeners.disposeAndClear(aEvt);
mpImpl->maPropertyNotifier.disposing();
- if ( mpObj.is() )
+ if ( HasSdrObject() )
{
+ EndListening( GetSdrObject()->getSdrModelFromSdrObject() );
bool bFreeSdrObject = false;
- if ( mpObj->IsInserted() && mpObj->GetPage() )
+ if ( GetSdrObject()->IsInserted() && GetSdrObject()->GetPage() )
{
OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" );
// normally, we are allowed to free the SdrObject only if we have its ownership.
// Why isn't this checked here?
- SdrPage* pPage = mpObj->GetPage();
+ SdrPage* pPage = GetSdrObject()->GetPage();
// delete the SdrObject from the page
const size_t nCount = pPage->GetObjCount();
for ( size_t nNum = 0; nNum < nCount; ++nNum )
{
- if ( pPage->GetObj( nNum ) == mpObj.get() )
+ if ( pPage->GetObj( nNum ) == GetSdrObject() )
{
- OSL_VERIFY( pPage->RemoveObject( nNum ) == mpObj.get() );
+ OSL_VERIFY( pPage->RemoveObject( nNum ) == GetSdrObject() );
bFreeSdrObject = true;
break;
}
}
}
- mpObj->setUnoShape(nullptr);
+ GetSdrObject()->setUnoShape(nullptr);
if ( bFreeSdrObject )
{
// in case we have the ownership of the SdrObject, a Free
// would do nothing. So ensure the ownership is reset.
mpImpl->mbHasSdrObjectOwnership = false;
- SdrObject* pObject = mpObj.get();
+ SdrObject* pObject = GetSdrObject();
SdrObject::Free( pObject );
}
}
-
- if( mpModel )
- {
- EndListening( *mpModel );
- mpModel = nullptr;
- }
}
@@ -1402,19 +1383,20 @@ void SAL_CALL SvxShape::removeVetoableChangeListener( const OUString& , const Re
bool SvxShape::SetFillAttribute( sal_uInt16 nWID, const OUString& rName )
{
- SfxItemSet aSet( mpModel->GetItemPool(), {{nWID, nWID}} );
-
- if( SetFillAttribute( nWID, rName, aSet, mpModel ) )
+ if(HasSdrObject())
{
- //mpObj->SetItemSetAndBroadcast(aSet);
- mpObj->SetMergedItemSetAndBroadcast(aSet);
+ SfxItemSet aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), {{nWID, nWID}} );
- return true;
- }
- else
- {
- return false;
+ if( SetFillAttribute( nWID, rName, aSet, &GetSdrObject()->getSdrModelFromSdrObject() ) )
+ {
+ //GetSdrObject()->SetItemSetAndBroadcast(aSet);
+ GetSdrObject()->SetMergedItemSetAndBroadcast(aSet);
+
+ return true;
+ }
}
+
+ return false;
}
@@ -1597,7 +1579,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
- if (!mpObj.is() || !mpModel)
+ if (!HasSdrObject())
{
// Since we have no actual sdr object right now, remember all
// properties in a list. These properties will be set when the sdr
@@ -1612,6 +1594,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
// supported after creation.
mpPropSet->setPropertyValue( pMap, rVal );
}
+
return;
}
@@ -1626,7 +1609,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
"Readonly property can't be set: " + rPropertyName,
uno::Reference<drawing::XShape>(this));
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
if (setPropertyValueImpl(rPropertyName, pMap, rVal))
return;
@@ -1648,7 +1631,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
{
if( mpImpl->mpItemSet == nullptr )
{
- pSet = mpImpl->mpItemSet = mpObj->GetMergedItemSet().Clone();
+ pSet = mpImpl->mpItemSet = GetSdrObject()->GetMergedItemSet().Clone();
}
else
{
@@ -1657,11 +1640,11 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
}
else
{
- pSet = new SfxItemSet( mpModel->GetItemPool(), {{pMap->nWID, pMap->nWID}});
+ pSet = new SfxItemSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), {{pMap->nWID, pMap->nWID}});
}
if( pSet->GetItemState( pMap->nWID ) != SfxItemState::SET )
- pSet->Put(mpObj->GetMergedItem(pMap->nWID));
+ pSet->Put(GetSdrObject()->GetMergedItem(pMap->nWID));
if( !SvxUnoTextRangeBase::SetPropertyValueHelper( pMap, rVal, *pSet ))
{
@@ -1670,7 +1653,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
if(bIsNotPersist)
{
// not-persistent attribute, get those extra
- mpObj->TakeNotPersistAttr(*pSet);
+ GetSdrObject()->TakeNotPersistAttr(*pSet);
}
}
@@ -1678,7 +1661,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
{
// get default from ItemPool
if(SfxItemPool::IsWhich(pMap->nWID))
- pSet->Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
+ pSet->Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID));
}
if( pSet->GetItemState( pMap->nWID ) == SfxItemState::SET )
@@ -1690,7 +1673,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
if(bIsNotPersist)
{
// set not-persistent attribute extra
- mpObj->ApplyNotPersistAttr( *pSet );
+ GetSdrObject()->ApplyNotPersistAttr( *pSet );
delete pSet;
}
else
@@ -1699,7 +1682,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
// will be set in setPropertyValues later
if( !mbIsMultiPropertyCall )
{
- mpObj->SetMergedItemSetAndBroadcast( *pSet );
+ GetSdrObject()->SetMergedItemSetAndBroadcast( *pSet );
delete pSet;
}
@@ -1723,7 +1706,7 @@ uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
uno::Any aAny;
- if( mpObj.is() && mpModel )
+ if(HasSdrObject())
{
if(pMap == nullptr )
throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this));
@@ -1733,8 +1716,8 @@ uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || (pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST), "Not persist item not handled!" );
DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" );
- SfxItemSet aSet( mpModel->GetItemPool(), {{pMap->nWID, pMap->nWID}});
- aSet.Put(mpObj->GetMergedItem(pMap->nWID));
+ SfxItemSet aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), {{pMap->nWID, pMap->nWID}});
+ aSet.Put(GetSdrObject()->GetMergedItem(pMap->nWID));
if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny ))
return aAny;
@@ -1744,7 +1727,7 @@ uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
if(pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST)
{
// not-persistent attribute, get those extra
- mpObj->TakeNotPersistAttr(aSet);
+ GetSdrObject()->TakeNotPersistAttr(aSet);
}
}
@@ -1752,7 +1735,7 @@ uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
{
// get default from ItemPool
if(SfxItemPool::IsWhich(pMap->nWID))
- aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
+ aSet.Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID));
}
if(aSet.Count())
@@ -1817,8 +1800,8 @@ void SAL_CALL SvxShape::setPropertyValues( const css::uno::Sequence< OUString >&
}
}
- if( mpImpl->mpItemSet && mpObj.is() )
- mpObj->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet );
+ if( mpImpl->mpItemSet && HasSdrObject() )
+ GetSdrObject()->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet );
}
@@ -1920,10 +1903,10 @@ uno::Any SvxShape::GetAnyForItem( SfxItemSet const & aSet, const SfxItemProperty
case SDRATTR_CIRCKIND:
{
- if( mpObj->GetObjInventor() == SdrInventor::Default)
+ if( GetSdrObject()->GetObjInventor() == SdrInventor::Default)
{
drawing::CircleKind eKind;
- switch(mpObj->GetObjIdentifier())
+ switch(GetSdrObject()->GetObjIdentifier())
{
case OBJ_CIRC: // circle, ellipse
eKind = drawing::CircleKind_FULL;
@@ -1988,13 +1971,13 @@ beans::PropertyState SvxShape::_getPropertyState( const OUString& PropertyName )
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
- if( !mpObj.is() || pMap == nullptr )
+ if( !HasSdrObject() || pMap == nullptr )
throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this));
beans::PropertyState eState;
if( !getPropertyStateImpl( pMap, eState ) )
{
- const SfxItemSet& rSet = mpObj->GetMergedItemSet();
+ const SfxItemSet& rSet = GetSdrObject()->GetMergedItemSet();
switch( rSet.GetItemState( pMap->nWID, false ) )
{
@@ -2063,7 +2046,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
// #90763# position is relative to top left, make it absolute
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
- mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
aVclPoint.AdjustX(basegfx::fround(aNewHomogenMatrix.get(0, 2)) );
aVclPoint.AdjustY(basegfx::fround(aNewHomogenMatrix.get(1, 2)) );
@@ -2072,12 +2055,12 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
ForceMetricToItemPoolMetric(aVclPoint);
// #88491# position relative to anchor
- if( mpModel->IsWriter() )
+ if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
{
- aVclPoint += mpObj->GetAnchorPos();
+ aVclPoint += GetSdrObject()->GetAnchorPos();
}
- static_cast<SdrCaptionObj*>(mpObj.get())->SetTailPos(aVclPoint);
+ static_cast<SdrCaptionObj*>(GetSdrObject())->SetTailPos(aVclPoint);
return true;
}
@@ -2091,7 +2074,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
- mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
aNewHomogenMatrix.set(0, 0, aMatrix.Line1.Column1);
aNewHomogenMatrix.set(0, 1, aMatrix.Line1.Column2);
@@ -2103,7 +2086,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
aNewHomogenMatrix.set(2, 1, aMatrix.Line3.Column2);
aNewHomogenMatrix.set(2, 2, aMatrix.Line3.Column3);
- mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
return true;
}
break;
@@ -2114,12 +2097,12 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
sal_Int32 nNewOrdNum = 0;
if(rValue >>= nNewOrdNum)
{
- SdrObjList* pObjList = mpObj->GetObjList();
+ SdrObjList* pObjList = GetSdrObject()->GetObjList();
if( pObjList )
{
SdrObject* pCheck =
- pObjList->SetObjectOrdNum( mpObj->GetOrdNum(), static_cast<size_t>(nNewOrdNum) );
- DBG_ASSERT( pCheck == mpObj.get(), "GetOrdNum() failed!" );
+ pObjList->SetObjectOrdNum( GetSdrObject()->GetOrdNum(), static_cast<size_t>(nNewOrdNum) );
+ DBG_ASSERT( pCheck == GetSdrObject(), "GetOrdNum() failed!" );
}
return true;
}
@@ -2137,7 +2120,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
tools::Rectangle aRect;
aRect.SetPos(aTopLeft);
aRect.SetSize(aObjSize);
- mpObj->SetSnapRect(aRect);
+ GetSdrObject()->SetSnapRect(aRect);
return true;
}
break;
@@ -2147,7 +2130,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
bool bMirror;
if(rValue >>= bMirror )
{
- SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( mpObj.get() );
+ SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( GetSdrObject() );
if( pObj )
pObj->SetMirrored(bMirror);
return true;
@@ -2162,7 +2145,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_EDGE_END_POS:
case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
{
- SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(mpObj.get());
+ SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(GetSdrObject());
if(pEdgeObj)
{
switch(pProperty->nWID)
@@ -2196,8 +2179,8 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
// perform metric change before applying anchor position,
// because the anchor position is in pool metric.
ForceMetricToItemPoolMetric( aPoint );
- if( mpModel->IsWriter() )
- aPoint += mpObj->GetAnchorPos();
+ if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+ aPoint += GetSdrObject()->GetAnchorPos();
pEdgeObj->SetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS, aPoint );
return true;
@@ -2238,9 +2221,9 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
{
// Reintroduction of fix for issue i59051 (#i108851#)
ForceMetricToItemPoolMetric( aNewPolyPolygon );
- if( mpModel->IsWriter() )
+ if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
{
- Point aPoint( mpObj->GetAnchorPos() );
+ Point aPoint( GetSdrObject()->GetAnchorPos() );
aNewPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix(aPoint.X(), aPoint.Y()));
}
pEdgeObj->SetEdgeTrackPath( aNewPolyPolygon );
@@ -2254,7 +2237,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_MEASURE_START_POS:
case OWN_ATTR_MEASURE_END_POS:
{
- SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(mpObj.get());
+ SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(GetSdrObject());
awt::Point aUnoPoint;
if(pMeasureObj && ( rValue >>= aUnoPoint ) )
{
@@ -2262,8 +2245,8 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
// Reintroduction of fix for issue #i59051# (#i108851#)
ForceMetricToItemPoolMetric( aPoint );
- if( mpModel->IsWriter() )
- aPoint += mpObj->GetAnchorPos();
+ if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+ aPoint += GetSdrObject()->GetAnchorPos();
pMeasureObj->NbcSetPoint( aPoint, pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 );
pMeasureObj->SetChanged();
@@ -2283,8 +2266,8 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
eMode = static_cast<drawing::BitmapMode>(nMode);
}
- mpObj->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) );
- mpObj->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) );
+ GetSdrObject()->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) );
+ GetSdrObject()->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) );
return true;
}
@@ -2293,10 +2276,10 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
sal_Int16 nLayerId = sal_Int16();
if( rValue >>= nLayerId )
{
- SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID(SdrLayerID(nLayerId));
+ SdrLayer* pLayer = GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(SdrLayerID(nLayerId));
if( pLayer )
{
- mpObj->SetLayer(SdrLayerID(nLayerId));
+ GetSdrObject()->SetLayer(SdrLayerID(nLayerId));
return true;
}
}
@@ -2308,10 +2291,10 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
OUString aLayerName;
if( rValue >>= aLayerName )
{
- const SdrLayer* pLayer=mpModel->GetLayerAdmin().GetLayer(aLayerName);
+ const SdrLayer* pLayer = GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayer(aLayerName);
if( pLayer != nullptr )
{
- mpObj->SetLayer( pLayer->GetID() );
+ GetSdrObject()->SetLayer( pLayer->GetID() );
return true;
}
}
@@ -2322,13 +2305,13 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
sal_Int32 nAngle = 0;
if( rValue >>= nAngle )
{
- Point aRef1(mpObj->GetSnapRect().Center());
- nAngle -= mpObj->GetRotateAngle();
+ Point aRef1(GetSdrObject()->GetSnapRect().Center());
+ nAngle -= GetSdrObject()->GetRotateAngle();
if (nAngle!=0)
{
double nSin=sin(nAngle*nPi180);
double nCos=cos(nAngle*nPi180);
- mpObj->Rotate(aRef1,nAngle,nSin,nCos);
+ GetSdrObject()->Rotate(aRef1,nAngle,nSin,nCos);
}
return true;
}
@@ -2341,12 +2324,12 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
sal_Int32 nShear = 0;
if( rValue >>= nShear )
{
- nShear -= mpObj->GetShearAngle();
+ nShear -= GetSdrObject()->GetShearAngle();
if(nShear != 0 )
{
- Point aRef1(mpObj->GetSnapRect().Center());
+ Point aRef1(GetSdrObject()->GetSnapRect().Center());
double nTan=tan(nShear*nPi180);
- mpObj->Shear(aRef1,nShear,nTan,false);
+ GetSdrObject()->Shear(aRef1,nShear,nTan,false);
return true;
}
}
@@ -2356,7 +2339,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_INTEROPGRABBAG:
{
- mpObj->SetGrabBagItem(rValue);
+ GetSdrObject()->SetGrabBagItem(rValue);
return true;
}
@@ -2365,7 +2348,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
bool bMoveProtect;
if( rValue >>= bMoveProtect )
{
- mpObj->SetMoveProtect(bMoveProtect);
+ GetSdrObject()->SetMoveProtect(bMoveProtect);
return true;
}
break;
@@ -2375,7 +2358,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
OUString aName;
if( rValue >>= aName )
{
- mpObj->SetName( aName );
+ GetSdrObject()->SetName( aName );
return true;
}
break;
@@ -2387,7 +2370,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
OUString aTitle;
if( rValue >>= aTitle )
{
- mpObj->SetTitle( aTitle );
+ GetSdrObject()->SetTitle( aTitle );
return true;
}
break;
@@ -2397,7 +2380,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
OUString aDescription;
if( rValue >>= aDescription )
{
- mpObj->SetDescription( aDescription );
+ GetSdrObject()->SetDescription( aDescription );
return true;
}
break;
@@ -2408,7 +2391,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
bool bPrintable;
if( rValue >>= bPrintable )
{
- mpObj->SetPrintable(bPrintable);
+ GetSdrObject()->SetPrintable(bPrintable);
return true;
}
break;
@@ -2418,7 +2401,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
bool bVisible;
if( rValue >>= bVisible )
{
- mpObj->SetVisible(bVisible);
+ GetSdrObject()->SetVisible(bVisible);
return true;
}
break;
@@ -2428,7 +2411,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
bool bResizeProtect;
if( rValue >>= bResizeProtect )
{
- mpObj->SetResizeProtect(bResizeProtect);
+ GetSdrObject()->SetResizeProtect(bResizeProtect);
return true;
}
break;
@@ -2438,19 +2421,16 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
sal_Int32 nPageNum = 0;
if( (rValue >>= nPageNum) && ( nPageNum >= 0 ) && ( nPageNum <= 0xffff ) )
{
- SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(mpObj.get());
+ SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(GetSdrObject());
if( pPageObj )
{
- SdrModel* pModel = pPageObj->GetModel();
+ SdrModel& rModel(pPageObj->getSdrModelFromSdrObject());
SdrPage* pNewPage = nullptr;
const sal_uInt16 nDestinationPageNum(static_cast<sal_uInt16>((nPageNum << 1) - 1));
- if(pModel)
+ if(nDestinationPageNum < rModel.GetPageCount())
{
- if(nDestinationPageNum < pModel->GetPageCount())
- {
- pNewPage = pModel->GetPage(nDestinationPageNum);
- }
+ pNewPage = rModel.GetPage(nDestinationPageNum);
}
pPageObj->SetReferencedPage(pNewPage);
@@ -2498,12 +2478,12 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
{
case OWN_ATTR_CAPTION_POINT:
{
- Point aVclPoint = static_cast<SdrCaptionObj*>(mpObj.get())->GetTailPos();
+ Point aVclPoint = static_cast<SdrCaptionObj*>(GetSdrObject())->GetTailPos();
// #88491# make pos relative to anchor
- if( mpModel->IsWriter() )
+ if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
{
- aVclPoint -= mpObj->GetAnchorPos();
+ aVclPoint -= GetSdrObject()->GetAnchorPos();
}
// #88657# metric of pool maybe twips (writer)
@@ -2512,7 +2492,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
// #90763# pos is absolute, make it relative to top left
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
- mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
aVclPoint.AdjustX( -(basegfx::fround(aNewHomogenMatrix.get(0, 2))) );
aVclPoint.AdjustY( -(basegfx::fround(aNewHomogenMatrix.get(1, 2))) );
@@ -2526,7 +2506,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
{
basegfx::B2DPolyPolygon aNewPolyPolygon;
basegfx::B2DHomMatrix aNewHomogenMatrix;
- mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
drawing::HomogenMatrix3 aMatrix;
aMatrix.Line1.Column1 = aNewHomogenMatrix.get(0, 0);
@@ -2546,7 +2526,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_ZORDER:
{
- rValue <<= static_cast<sal_Int32>(mpObj->GetOrdNum());
+ rValue <<= static_cast<sal_Int32>(GetSdrObject()->GetOrdNum());
break;
}
@@ -2561,13 +2541,13 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_ISFONTWORK:
{
- rValue <<= dynamic_cast<const SdrTextObj*>(mpObj.get()) != nullptr && static_cast<SdrTextObj*>(mpObj.get())->IsFontwork();
+ rValue <<= dynamic_cast<const SdrTextObj*>(GetSdrObject()) != nullptr && static_cast<SdrTextObj*>(GetSdrObject())->IsFontwork();
break;
}
case OWN_ATTR_FRAMERECT:
{
- tools::Rectangle aRect( mpObj->GetSnapRect() );
+ tools::Rectangle aRect( GetSdrObject()->GetSnapRect() );
Point aTopLeft( aRect.TopLeft() );
Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
ForceMetricTo100th_mm(aTopLeft);
@@ -2581,7 +2561,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_BOUNDRECT:
{
- tools::Rectangle aRect( mpObj->GetCurrentBoundRect() );
+ tools::Rectangle aRect( GetSdrObject()->GetCurrentBoundRect() );
Point aTopLeft( aRect.TopLeft() );
Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
ForceMetricTo100th_mm(aTopLeft);
@@ -2595,7 +2575,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_LDNAME:
{
- OUString aName( mpObj->GetName() );
+ OUString aName( GetSdrObject()->GetName() );
rValue <<= aName;
break;
}
@@ -2603,11 +2583,11 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_LDBITMAP:
{
OUString sId;
- if( mpObj->GetObjInventor() == SdrInventor::Default && mpObj->GetObjIdentifier() == OBJ_OLE2 )
+ if( GetSdrObject()->GetObjInventor() == SdrInventor::Default && GetSdrObject()->GetObjIdentifier() == OBJ_OLE2 )
{
sId = RID_UNODRAW_OLE2;
}
- else if( mpObj->GetObjInventor() == SdrInventor::Default && mpObj->GetObjIdentifier() == OBJ_GRAF )
+ else if( GetSdrObject()->GetObjInventor() == SdrInventor::Default && GetSdrObject()->GetObjIdentifier() == OBJ_GRAF )
{
sId = RID_UNODRAW_GRAPHICS;
}
@@ -2626,8 +2606,8 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_MIRRORED:
{
bool bMirror = false;
- if( mpObj.is() && dynamic_cast<const SdrGrafObj*>(mpObj.get()) != nullptr )
- bMirror = static_cast<SdrGrafObj*>(mpObj.get())->IsMirrored();
+ if( HasSdrObject() && dynamic_cast<const SdrGrafObj*>(GetSdrObject()) != nullptr )
+ bMirror = static_cast<SdrGrafObj*>(GetSdrObject())->IsMirrored();
rValue <<= bMirror;
break;
@@ -2641,7 +2621,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_GLUEID_TAIL:
case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
{
- SdrEdgeObj* pEdgeObj = dynamic_cast<SdrEdgeObj*>(mpObj.get());
+ SdrEdgeObj* pEdgeObj = dynamic_cast<SdrEdgeObj*>(GetSdrObject());
if(pEdgeObj)
{
switch(pProperty->nWID)
@@ -2664,8 +2644,8 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_EDGE_END_POS:
{
Point aPoint( pEdgeObj->GetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS ) );
- if( mpModel->IsWriter() )
- aPoint -= mpObj->GetAnchorPos();
+ if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+ aPoint -= GetSdrObject()->GetAnchorPos();
ForceMetricTo100th_mm( aPoint );
awt::Point aUnoPoint( aPoint.X(), aPoint.Y() );
@@ -2682,9 +2662,9 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
{
basegfx::B2DPolyPolygon aPolyPoly( pEdgeObj->GetEdgeTrackPath() );
- if( mpModel->IsWriter() )
+ if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
{
- Point aPoint( mpObj->GetAnchorPos() );
+ Point aPoint( GetSdrObject()->GetAnchorPos() );
aPolyPoly.transform(basegfx::utils::createTranslateB2DHomMatrix(-aPoint.X(), -aPoint.Y()));
}
// Reintroduction of fix for issue #i59051# (#i108851#)
@@ -2702,12 +2682,12 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_MEASURE_START_POS:
case OWN_ATTR_MEASURE_END_POS:
{
- SdrMeasureObj* pMeasureObj = dynamic_cast<SdrMeasureObj*>(mpObj.get());
+ SdrMeasureObj* pMeasureObj = dynamic_cast<SdrMeasureObj*>(GetSdrObject());
if(pMeasureObj)
{
Point aPoint( pMeasureObj->GetPoint( pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 ) );
- if( mpModel->IsWriter() )
- aPoint -= mpObj->GetAnchorPos();
+ if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+ aPoint -= GetSdrObject()->GetAnchorPos();
// Reintroduction of fix for issue #i59051# (#i108851#)
ForceMetricTo100th_mm( aPoint );
@@ -2721,7 +2701,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_FILLBMP_MODE:
{
- const SfxItemSet& rObjItemSet = mpObj->GetMergedItemSet();
+ const SfxItemSet& rObjItemSet = GetSdrObject()->GetMergedItemSet();
const XFillBmpStretchItem* pStretchItem = &rObjItemSet.Get(XATTR_FILLBMP_STRETCH);
const XFillBmpTileItem* pTileItem = &rObjItemSet.Get(XATTR_FILLBMP_TILE);
@@ -2741,12 +2721,12 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
break;
}
case SDRATTR_LAYERID:
- rValue <<= sal_uInt16(sal_uInt8(mpObj->GetLayer()));
+ rValue <<= sal_uInt16(sal_uInt8(GetSdrObject()->GetLayer()));
break;
case SDRATTR_LAYERNAME:
{
- SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID(mpObj->GetLayer());
+ SdrLayer* pLayer = GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(GetSdrObject()->GetLayer());
if( pLayer )
{
OUString aName( pLayer->GetName() );
@@ -2756,26 +2736,26 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
}
case SDRATTR_ROTATEANGLE:
- rValue <<= static_cast<sal_Int32>(mpObj->GetRotateAngle());
+ rValue <<= static_cast<sal_Int32>(GetSdrObject()->GetRotateAngle());
break;
case SDRATTR_SHEARANGLE:
- rValue <<= static_cast<sal_Int32>(mpObj->GetShearAngle());
+ rValue <<= static_cast<sal_Int32>(GetSdrObject()->GetShearAngle());
break;
case OWN_ATTR_INTEROPGRABBAG:
{
- mpObj->GetGrabBagItem(rValue);
+ GetSdrObject()->GetGrabBagItem(rValue);
break;
}
case SDRATTR_OBJMOVEPROTECT:
- rValue <<= mpObj->IsMoveProtect();
+ rValue <<= GetSdrObject()->IsMoveProtect();
break;
case SDRATTR_OBJECTNAME:
{
- OUString aName( mpObj->GetName() );
+ OUString aName( GetSdrObject()->GetName() );
rValue <<= aName;
break;
}
@@ -2783,33 +2763,33 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
// #i68101#
case OWN_ATTR_MISC_OBJ_TITLE:
{
- OUString aTitle( mpObj->GetTitle() );
+ OUString aTitle( GetSdrObject()->GetTitle() );
rValue <<= aTitle;
break;
}
case OWN_ATTR_MISC_OBJ_DESCRIPTION:
{
- OUString aDescription( mpObj->GetDescription() );
+ OUString aDescription( GetSdrObject()->GetDescription() );
rValue <<= aDescription;
break;
}
case SDRATTR_OBJPRINTABLE:
- rValue <<= mpObj->IsPrintable();
+ rValue <<= GetSdrObject()->IsPrintable();
break;
case SDRATTR_OBJVISIBLE:
- rValue <<= mpObj->IsVisible();
+ rValue <<= GetSdrObject()->IsVisible();
break;
case SDRATTR_OBJSIZEPROTECT:
- rValue <<= mpObj->IsResizeProtect();
+ rValue <<= GetSdrObject()->IsResizeProtect();
break;
case OWN_ATTR_PAGE_NUMBER:
{
- SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(mpObj.get());
+ SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(GetSdrObject());
if(pPageObj)
{
SdrPage* pPage = pPageObj->GetReferencedPage();
@@ -2823,18 +2803,18 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
case OWN_ATTR_UINAME_SINGULAR:
{
- rValue <<= mpObj->TakeObjNameSingul();
+ rValue <<= GetSdrObject()->TakeObjNameSingul();
break;
}
case OWN_ATTR_UINAME_PLURAL:
{
- rValue <<= mpObj->TakeObjNamePlural();
+ rValue <<= GetSdrObject()->TakeObjNamePlural();
break;
}
case OWN_ATTR_METAFILE:
{
- SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get());
+ SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(GetSdrObject());
if( pObj )
{
const Graphic* pGraphic = pObj->GetGraphic();
@@ -2883,7 +2863,7 @@ bool SvxShape::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty
{
if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
{
- const SfxItemSet& rSet = mpObj->GetMergedItemSet();
+ const SfxItemSet& rSet = GetSdrObject()->GetMergedItemSet();
if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SfxItemState::SET ||
rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SfxItemState::SET )
@@ -2913,8 +2893,8 @@ bool SvxShape::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProp
{
if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
{
- mpObj->ClearMergedItem( XATTR_FILLBMP_STRETCH );
- mpObj->ClearMergedItem( XATTR_FILLBMP_TILE );
+ GetSdrObject()->ClearMergedItem( XATTR_FILLBMP_STRETCH );
+ GetSdrObject()->ClearMergedItem( XATTR_FILLBMP_TILE );
return true;
}
else if((pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) ||
@@ -2962,15 +2942,15 @@ void SvxShape::_setPropertyToDefault( const OUString& PropertyName )
const SfxItemPropertySimpleEntry* pProperty = mpPropSet->getPropertyMapEntry(PropertyName);
- if( !mpObj.is() || mpModel == nullptr || pProperty == nullptr )
+ if( !HasSdrObject() || pProperty == nullptr )
throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this));
if( !setPropertyToDefaultImpl( pProperty ) )
{
- mpObj->ClearMergedItem( pProperty->nWID );
+ GetSdrObject()->ClearMergedItem( pProperty->nWID );
}
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
@@ -2992,7 +2972,7 @@ uno::Any SvxShape::_getPropertyDefault( const OUString& aPropertyName )
const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
- if( !mpObj.is() || pMap == nullptr || mpModel == nullptr )
+ if( !HasSdrObject() || pMap == nullptr )
throw beans::UnknownPropertyException( aPropertyName, static_cast<cppu::OWeakObject*>(this));
if(( pMap->nWID >= OWN_ATTR_VALUE_START && pMap->nWID <= OWN_ATTR_VALUE_END ) ||
@@ -3005,8 +2985,8 @@ uno::Any SvxShape::_getPropertyDefault( const OUString& aPropertyName )
if(!SfxItemPool::IsWhich(pMap->nWID))
throw beans::UnknownPropertyException( "No WhichID " + OUString::number(pMap->nWID) + " for " + aPropertyName, static_cast<cppu::OWeakObject*>(this));
- SfxItemSet aSet( mpModel->GetItemPool(), {{pMap->nWID, pMap->nWID}});
- aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
+ SfxItemSet aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), {{pMap->nWID, pMap->nWID}});
+ aSet.Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID));
return GetAnyForItem( aSet, pMap );
}
@@ -3016,15 +2996,15 @@ void SvxShape::setAllPropertiesToDefault()
{
::SolarMutexGuard aGuard;
- if( !mpObj.is() )
+ if( !HasSdrObject() )
throw lang::DisposedException();
- mpObj->ClearMergedItem(); // nWhich == 0 => all
+ GetSdrObject()->ClearMergedItem(); // nWhich == 0 => all
- if(dynamic_cast<const SdrGrafObj*>(mpObj.get()) != nullptr)
+ if(dynamic_cast<const SdrGrafObj*>(GetSdrObject()) != nullptr)
{
// defaults for graphic objects have changed:
- mpObj->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) );
- mpObj->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) );
+ GetSdrObject()->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) );
+ GetSdrObject()->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) );
}
// #i68523# special handling for Svx3DCharacterModeItem, this is not saved
@@ -3032,13 +3012,12 @@ void SvxShape::setAllPropertiesToDefault()
// does not load lathe or extrude objects, it is possible to set the items
// here.
// For other solution possibilities, see task description.
- if( dynamic_cast<const E3dLatheObj* >(mpObj.get()) != nullptr|| dynamic_cast<const E3dExtrudeObj* >(mpObj.get()) != nullptr)
+ if( dynamic_cast<const E3dLatheObj* >(GetSdrObject()) != nullptr|| dynamic_cast<const E3dExtrudeObj* >(GetSdrObject()) != nullptr)
{
- mpObj->SetMergedItem(Svx3DCharacterModeItem(true));
+ GetSdrObject()->SetMergedItem(Svx3DCharacterModeItem(true));
}
- if (mpModel)
- mpModel->SetChanged();
+ GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
}
void SvxShape::setPropertiesToDefault(
@@ -3126,9 +3105,9 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames()
{
::SolarMutexGuard aGuard;
- if( mpObj.is() && mpObj->GetObjInventor() == SdrInventor::Default)
+ if( HasSdrObject() && GetSdrObject()->GetObjInventor() == SdrInventor::Default)
{
- const sal_uInt16 nIdent = mpObj->GetObjIdentifier();
+ const sal_uInt16 nIdent = GetSdrObject()->GetObjIdentifier();
switch(nIdent)
{
@@ -3653,10 +3632,10 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames()
}
}
}
- else if( mpObj.is() && mpObj->GetObjInventor() == SdrInventor::FmForm)
+ else if( HasSdrObject() && GetSdrObject()->GetObjInventor() == SdrInventor::FmForm)
{
#if OSL_DEBUG_LEVEL > 0
- const sal_uInt16 nIdent = mpObj->GetObjIdentifier();
+ const sal_uInt16 nIdent = GetSdrObject()->GetObjIdentifier();
OSL_ENSURE( nIdent == OBJ_UNO, "SvxShape::_getSupportedServiceNames: SdrInventor::FmForm, but no UNO object?" );
#endif
static uno::Sequence< OUString > *pSeq = nullptr;
@@ -3687,9 +3666,9 @@ uno::Reference< container::XIndexContainer > SAL_CALL SvxShape::getGluePoints()
::SolarMutexGuard aGuard;
uno::Reference< container::XIndexContainer > xGluePoints( mxGluePoints );
- if( mpObj.is() && !xGluePoints.is() )
+ if( HasSdrObject() && !xGluePoints.is() )
{
- uno::Reference< container::XIndexContainer > xNew( SvxUnoGluePointAccess_createInstance( mpObj.get() ), uno::UNO_QUERY );
+ uno::Reference< container::XIndexContainer > xNew( SvxUnoGluePointAccess_createInstance( GetSdrObject() ), uno::UNO_QUERY );
mxGluePoints = xGluePoints = xNew;
}
@@ -3701,9 +3680,9 @@ uno::Reference<uno::XInterface> SAL_CALL SvxShape::getParent()
{
::SolarMutexGuard aGuard;
- if( mpObj.is() && mpObj->GetObjList() )
+ if( HasSdrObject() && GetSdrObject()->GetObjList() )
{
- SdrObjList* pObjList = mpObj->GetObjList();
+ SdrObjList* pObjList = GetSdrObject()->GetObjList();
switch (pObjList->GetListKind())
{
@@ -3823,7 +3802,7 @@ void SvxShape::updateShapeKind()
case OBJ_PATHPOLY:
case OBJ_PATHPLIN:
{
- const sal_uInt32 nId = mpObj->GetObjIdentifier();
+ const sal_uInt32 nId = GetSdrObject()->GetObjIdentifier();
if( nId != mpImpl->mnObjId )
{
@@ -3838,7 +3817,7 @@ void SvxShape::updateShapeKind()
SvxShapeText::SvxShapeText(SdrObject* pObject)
: SvxShape( pObject, getSvxMapProvider().GetMap(SVXMAP_TEXT), getSvxMapProvider().GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
{
- if( pObject && pObject->GetModel() )
+ if( pObject )
SetEditSource( new SvxTextEditSource( pObject, nullptr ) );
}
@@ -3846,7 +3825,7 @@ SvxShapeText::SvxShapeText(SdrObject* pObject)
SvxShapeText::SvxShapeText(SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet)
: SvxShape( pObject, pPropertyMap, pPropertySet ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
{
- if( pObject && pObject->GetModel() )
+ if( pObject )
SetEditSource( new SvxTextEditSource( pObject, nullptr ) );
}
@@ -4002,7 +3981,7 @@ bool SvxShapeText::setPropertyValueImpl( const OUString& rName, const SfxItemPro
if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() );
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetSdrObject() );
if( pTextObj )
{
css::text::WritingMode eMode;
@@ -4020,7 +3999,7 @@ bool SvxShapeText::getPropertyValueImpl( const OUString& rName, const SfxItemPro
{
if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
{
- SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() );
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetSdrObject() );
if( pTextObj && pTextObj->IsVerticalWriting() )
rValue <<= css::text::WritingMode_TB_RL;
else
diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx
index 4cb601c3495f..f09305dd9939 100644
--- a/svx/source/unodraw/unoshtxt.cxx
+++ b/svx/source/unodraw/unoshtxt.cxx
@@ -80,11 +80,11 @@ class SvxTextEditSourceImpl : public SfxListener, public SfxBroadcaster, public
private:
oslInterlockedCount maRefCount;
- SdrObject* mpObject;
+ SdrObject* mpObject; // TTTT could be reference (?)
SdrText* mpText;
SdrView* mpView;
VclPtr<const vcl::Window> mpWindow;
- SdrModel* mpModel;
+ SdrModel* mpModel; // TTTT probably not needed -> use SdrModel from SdrObject (?)
SdrOutliner* mpOutliner;
SvxOutlinerForwarder* mpTextForwarder;
SvxDrawOutlinerViewForwarder* mpViewForwarder; // if non-NULL, use GetViewModeTextForwarder text forwarder
@@ -147,8 +147,6 @@ public:
virtual void ObjectInDestruction(const SdrObject& rObject) override;
- void ChangeModel( SdrModel* pNewModel );
-
void UpdateOutliner();
};
@@ -159,7 +157,7 @@ SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject* pObject, SdrText* pText
mpText ( pText ),
mpView ( nullptr ),
mpWindow ( nullptr ),
- mpModel ( pObject ? pObject->GetModel() : nullptr ),
+ mpModel ( pObject ? &pObject->getSdrModelFromSdrObject() : nullptr ), // TTTT should be reference
mpOutliner ( nullptr ),
mpTextForwarder ( nullptr ),
mpViewForwarder ( nullptr ),
@@ -195,7 +193,7 @@ SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject& rObject, SdrText* pText
mpText ( pText ),
mpView ( &rView ),
mpWindow ( &rWindow ),
- mpModel ( rObject.GetModel() ),
+ mpModel ( &rObject.getSdrModelFromSdrObject() ), // TTTT should be reference
mpOutliner ( nullptr ),
mpTextForwarder ( nullptr ),
mpViewForwarder ( nullptr ),
@@ -264,51 +262,6 @@ void SvxTextEditSourceImpl::release()
delete this;
}
-void SvxTextEditSourceImpl::ChangeModel( SdrModel* pNewModel )
-{
- if( mpModel != pNewModel )
- {
- if( mpModel )
- EndListening( *mpModel );
-
- if( mpOutliner )
- {
- if( mpModel )
- mpModel->disposeOutliner( mpOutliner );
- else
- delete mpOutliner;
- mpOutliner = nullptr;
- }
-
- if( mpView )
- {
- EndListening( *mpView );
- mpView = nullptr;
- }
-
- mpWindow = nullptr;
- m_xLinguServiceManager.clear();
-
- mpModel = pNewModel;
-
- if( mpTextForwarder )
- {
- delete mpTextForwarder;
- mpTextForwarder = nullptr;
- }
-
- if( mpViewForwarder )
- {
- delete mpViewForwarder;
- mpViewForwarder = nullptr;
- }
-
- if( mpModel )
- StartListening( *mpModel );
- }
-}
-
-
void SvxTextEditSourceImpl::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
{
// #i105988 keep reference to this object
@@ -638,7 +591,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
bool bVertical = pOutlinerParaObject && pOutlinerParaObject->IsVertical();
// set objects style sheet on empty outliner
- SfxStyleSheetPool* pPool = static_cast<SfxStyleSheetPool*>(mpObject->GetModel()->GetStyleSheetPool());
+ SfxStyleSheetPool* pPool = static_cast<SfxStyleSheetPool*>(mpObject->getSdrModelFromSdrObject().GetStyleSheetPool());
if( pPool )
mpOutliner->SetStyleSheetPool( pPool );
@@ -709,10 +662,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetTextForwarder()
return nullptr;
if( mpModel == nullptr )
- mpModel = mpObject->GetModel();
-
- if( mpModel == nullptr )
- return nullptr;
+ mpModel = &mpObject->getSdrModelFromSdrObject();
// distinguish the cases
// a) connected to view, maybe edit mode is active, can work directly on the EditOutliner
@@ -763,10 +713,7 @@ SvxEditViewForwarder* SvxTextEditSourceImpl::GetEditViewForwarder( bool bCreate
return nullptr;
if( mpModel == nullptr )
- mpModel = mpObject->GetModel();
-
- if( mpModel == nullptr )
- return nullptr;
+ mpModel = &mpObject->getSdrModelFromSdrObject();
// shall we delete?
if( mpViewForwarder )
@@ -1108,11 +1055,6 @@ const SvxUnoTextRangeBaseList& SvxTextEditSource::getRanges() const
return mpImpl->getRanges();
}
-void SvxTextEditSource::ChangeModel( SdrModel* pNewModel )
-{
- mpImpl->ChangeModel( pNewModel );
-}
-
void SvxTextEditSource::UpdateOutliner()
{
mpImpl->UpdateOutliner();
diff --git a/svx/source/unogallery/unogaltheme.cxx b/svx/source/unogallery/unogaltheme.cxx
index 404a9bb897dd..1bf753bc3066 100644
--- a/svx/source/unogallery/unogaltheme.cxx
+++ b/svx/source/unogallery/unogaltheme.cxx
@@ -254,13 +254,14 @@ void SAL_CALL GalleryTheme::update( )
uno::Reference< drawing::XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
uno::Reference< drawing::XDrawPage > xPage( xDrawPages->getByIndex( 0 ), uno::UNO_QUERY_THROW );
SvxDrawPage* pUnoPage = xPage.is() ? SvxDrawPage::getImplementation( xPage ) : nullptr;
- SdrModel* pOrigModel = pUnoPage ? pUnoPage->GetSdrPage()->GetModel() : nullptr;
+ SdrModel* pOrigModel = pUnoPage ? &pUnoPage->GetSdrPage()->getSdrModelFromSdrPage() : nullptr;
SdrPage* pOrigPage = pUnoPage ? pUnoPage->GetSdrPage() : nullptr;
if (pOrigPage && pOrigModel)
{
FmFormModel* pTmpModel = new FmFormModel(&pOrigModel->GetItemPool());
- SdrPage* pNewPage = pOrigPage->Clone();
+ // Clone to new target SdrModel
+ SdrPage* pNewPage = pOrigPage->Clone(pTmpModel);
pTmpModel->InsertPage(pNewPage, 0);
uno::Reference< lang::XComponent > xDrawing( new GalleryDrawingModel( pTmpModel ) );