diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de (CIB)> | 2018-03-09 17:23:01 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-04-06 17:16:34 +0200 |
commit | a389390bd7ce7daa67d322532f876eeaf9d0b05f (patch) | |
tree | aae2cdcf3a570bfdf92444e8593fa4b539991e9a | |
parent | d240987998d56f5d53a2b0d48dff8cc7aa62ba5b (diff) |
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.
Change-Id: I24617494a0ef79f6e33dfcb02782a833a81c6434
189 files changed, 2686 insertions, 2533 deletions
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index 26027c117a44..44d7b7a10d55 100644 --- a/basctl/source/dlged/dlgedobj.cxx +++ b/basctl/source/dlged/dlgedobj.cxx @@ -502,7 +502,7 @@ void DlgEdObj::UpdateStep() sal_Int32 nCurStep = GetDlgEdForm()->GetStep(); sal_Int32 nStep = GetStep(); - SdrLayerAdmin& rLayerAdmin = GetModel()->GetLayerAdmin(); + SdrLayerAdmin& rLayerAdmin(getSdrModelFromSdrObject().GetLayerAdmin()); SdrLayerID nHiddenLayerId = rLayerAdmin.GetLayerID( "HiddenLayer" ); SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName() ); @@ -606,7 +606,7 @@ void DlgEdObj::TabIndexChange( const beans::PropertyChangeEvent& evt ) } // reorder objects in drawing page - GetModel()->GetPage(0)->SetObjectOrdNum( nOldTabIndex + 1, nNewTabIndex + 1 ); + getSdrModelFromSdrObject().GetPage(0)->SetObjectOrdNum( nOldTabIndex + 1, nNewTabIndex + 1 ); pForm->UpdateTabOrderAndGroups(); } @@ -886,9 +886,9 @@ void DlgEdObj::clonedFrom(const DlgEdObj* _pSource) StartListening(); } -DlgEdObj* DlgEdObj::Clone() const +DlgEdObj* DlgEdObj::Clone(SdrModel* pTargetModel) const { - DlgEdObj* pDlgEdObj = CloneHelper< DlgEdObj >(); + DlgEdObj* pDlgEdObj = CloneHelper< DlgEdObj >(pTargetModel); DBG_ASSERT( pDlgEdObj != nullptr, "DlgEdObj::Clone: invalid clone!" ); if ( pDlgEdObj ) pDlgEdObj->clonedFrom( this ); diff --git a/basctl/source/dlged/dlgedpage.cxx b/basctl/source/dlged/dlgedpage.cxx index 243154c7cd99..1c86b93ca618 100644 --- a/basctl/source/dlged/dlgedpage.cxx +++ b/basctl/source/dlged/dlgedpage.cxx @@ -43,11 +43,11 @@ DlgEdPage::~DlgEdPage() Clear(); } - -SdrPage* DlgEdPage::Clone() const -{ - return Clone(nullptr); -} +// TTTT +// SdrPage* DlgEdPage::Clone() const +// { +// return Clone(nullptr); +// } SdrPage* DlgEdPage::Clone(SdrModel* const pNewModel) const { diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx index 5bef190a4f08..4660c29d2682 100644 --- a/basctl/source/inc/dlgedobj.hxx +++ b/basctl/source/inc/dlgedobj.hxx @@ -96,7 +96,7 @@ public: virtual SdrInventor GetObjInventor() const override; virtual sal_uInt16 GetObjIdentifier() const override; - virtual DlgEdObj* Clone() const override; // not working yet + virtual DlgEdObj* Clone(SdrModel* pTargetModel = nullptr) const override; // not working yet void clonedFrom(const DlgEdObj* _pSource); // not working yet // FullDrag support diff --git a/basctl/source/inc/dlgedpage.hxx b/basctl/source/inc/dlgedpage.hxx index 814826e02f77..618b1e502aea 100644 --- a/basctl/source/inc/dlgedpage.hxx +++ b/basctl/source/inc/dlgedpage.hxx @@ -43,8 +43,9 @@ public: explicit DlgEdPage( DlgEdModel& rModel, bool bMasterPage = false ); virtual ~DlgEdPage() override; - virtual SdrPage* Clone() const override; - virtual SdrPage* Clone( SdrModel* pNewModel ) const override; + // TTTT + // virtual SdrPage* Clone() const override; + virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const override; void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; } DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; } diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index c1ee7778aa6e..3ca0000cc06a 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -395,11 +395,12 @@ void ChartController::impl_PasteShapes( SdrModel* pModel ) SdrObjListIter aIter( *pPage, SdrIterMode::DeepNoGroups ); while ( aIter.IsMore() ) { - SdrObject* pObj = aIter.Next(); - SdrObject* pNewObj = ( pObj ? pObj->Clone() : nullptr ); + SdrObject* pObj(aIter.Next()); + // TTTT clone to new SdrModel + SdrObject* pNewObj(pObj ? pObj->Clone(&pDrawModelWrapper->getSdrModel()) : nullptr); + if ( pNewObj ) { - pNewObj->SetModel( &pDrawModelWrapper->getSdrModel() ); pNewObj->SetPage( pDestPage ); // set position diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx index 22f4b4e9e4a9..6c59620ce6c1 100644 --- a/chart2/source/controller/main/DrawCommandDispatch.cxx +++ b/chart2/source/controller/main/DrawCommandDispatch.cxx @@ -74,7 +74,7 @@ bool DrawCommandDispatch::isFeatureSupported( const OUString& rCommandURL ) return parseCommandURL( rCommandURL, &nFeatureId, &aBaseCommand, &aCustomShapeType ); } -::basegfx::B2DPolyPolygon getPolygon(const char* pResId, SdrModel const & rModel) +::basegfx::B2DPolyPolygon getPolygon(const char* pResId, const SdrModel& rModel) { ::basegfx::B2DPolyPolygon aReturn; XLineEndListRef pLineEndList = rModel.GetLineEndList(); @@ -123,7 +123,7 @@ void DrawCommandDispatch::setAttributes( SdrObject* pObj ) { const SfxItemSet& rSource = pSourceObj->GetMergedItemSet(); SfxItemSet aDest( - pObj->GetModel()->GetItemPool(), + pObj->getSdrModelFromSdrObject().GetItemPool(), svl::Items< // Ranges from SdrAttrObj: SDRATTR_START, SDRATTR_SHADOW_LAST, diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx index 4c5bac5abfc0..897bbe390ea4 100644 --- a/chart2/source/view/diagram/VDiagram.cxx +++ b/chart2/source/view/diagram/VDiagram.cxx @@ -436,7 +436,7 @@ void VDiagram::adjustAspectRatio3d( const awt::Size& rAvailableSize ) // To get the 3D aspect ratio's effect on the 2D scene size, the scene's 2D size needs to be adapted to // 3D content changes here. The tooling class remembers the current 3D transformation stack // and in its destructor, calculates a new 2D SnapRect for the scene and it's modified 3D geometry. - E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene( m_xOuterGroupShape )); + E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene(m_xOuterGroupShape)); m_xAspectRatio3D->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX , uno::Any(BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aResult )) ); @@ -599,7 +599,8 @@ void VDiagram::createShapes_3d() aEffectiveTranformation.shearXY(m_fYAnglePi,-m_fXAnglePi); //#i98497# 3D charts are rendered with wrong size - E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene( m_xOuterGroupShape )); + E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene(m_xOuterGroupShape)); + xDestProp->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX, uno::Any( BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aEffectiveTranformation ) ) ); } @@ -656,7 +657,8 @@ void VDiagram::createShapes_3d() ::basegfx::B3DHomMatrix aM; aM.translate(GRID_TO_WALL_DISTANCE/fXScale, GRID_TO_WALL_DISTANCE/fYScale, GRID_TO_WALL_DISTANCE/fZScale); aM.scale( fXScale, fYScale, fZScale ); - E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene( m_xOuterGroupShape )); + E3DModifySceneSnapRectUpdater aUpdater(lcl_getE3dScene(m_xOuterGroupShape)); + xShapeProp->setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX , uno::Any(BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aM)) ); } diff --git a/cui/source/dialogs/sdrcelldlg.cxx b/cui/source/dialogs/sdrcelldlg.cxx index 7789ddd64c13..a7de7c1f2ed2 100644 --- a/cui/source/dialogs/sdrcelldlg.cxx +++ b/cui/source/dialogs/sdrcelldlg.cxx @@ -26,14 +26,14 @@ #include <border.hxx> #include <svx/dialogs.hrc> -SvxFormatCellsDialog::SvxFormatCellsDialog( vcl::Window* pParent, const SfxItemSet* pAttr, SdrModel const * pModel ) +SvxFormatCellsDialog::SvxFormatCellsDialog( vcl::Window* pParent, const SfxItemSet* pAttr, const SdrModel& rModel ) : SfxTabDialog(pParent, "FormatCellsDialog", "cui/ui/formatcellsdialog.ui", pAttr) , mrOutAttrs(*pAttr) - , mpColorTab(pModel->GetColorList()) - , mpGradientList(pModel->GetGradientList()) - , mpHatchingList(pModel->GetHatchList()) - , mpBitmapList(pModel->GetBitmapList()) - , mpPatternList(pModel->GetPatternList()) + , mpColorTab(rModel.GetColorList()) + , mpGradientList(rModel.GetGradientList()) + , mpHatchingList(rModel.GetHatchList()) + , mpBitmapList(rModel.GetBitmapList()) + , mpPatternList(rModel.GetPatternList()) , m_nAreaPageId(0) { AddTabPage("name", RID_SVXPAGE_CHAR_NAME); diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 8a8647b088af..51c7d5afd500 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -1524,9 +1524,9 @@ VclPtr<SfxAbstractLinksDialog> AbstractDialogFactory_Impl::CreateLinksDialog( vc return VclPtr<AbstractLinksDialog_Impl>::Create( pLinkDlg ); } -VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* /*pObj*/ ) +VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, const SdrModel& rModel, const SdrObject* /*pObj*/ ) { - return VclPtr<CuiAbstractTabDialog_Impl>::Create( VclPtr<SvxFormatCellsDialog>::Create( nullptr, pAttr, pModel ) ); + return VclPtr<CuiAbstractTabDialog_Impl>::Create( VclPtr<SvxFormatCellsDialog>::Create( nullptr, pAttr, rModel ) ); } VclPtr<SvxAbstractSplitTableDialog> AbstractDialogFactory_Impl::CreateSvxSplitTableDialog(weld::Window* pParent, bool bIsTableVertical, long nMaxVertical) diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index ae87ab25bb72..e9ea89b340e3 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -690,7 +690,7 @@ public: const sal_uInt16 _nInitiallySelectedEvent ) override; - virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj ) override; + virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, const SdrModel& rModel, const SdrObject* pObj ) override; virtual VclPtr<SvxAbstractSplitTableDialog> CreateSvxSplitTableDialog(weld::Window* pParent, bool bIsTableVertical, long nMaxVertical) override; diff --git a/cui/source/inc/sdrcelldlg.hxx b/cui/source/inc/sdrcelldlg.hxx index 97a2abeec613..0a38f759a494 100644 --- a/cui/source/inc/sdrcelldlg.hxx +++ b/cui/source/inc/sdrcelldlg.hxx @@ -40,7 +40,7 @@ private: sal_uInt16 m_nBorderPageId; public: - SvxFormatCellsDialog( vcl::Window* pParent, const SfxItemSet* pAttr, SdrModel const * pModel ); + SvxFormatCellsDialog( vcl::Window* pParent, const SfxItemSet* pAttr, const SdrModel& rModel ); virtual void PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) override; diff --git a/cui/source/tabpages/measure.cxx b/cui/source/tabpages/measure.cxx index adfb0ec6fa26..4ed4cce5eec3 100644 --- a/cui/source/tabpages/measure.cxx +++ b/cui/source/tabpages/measure.cxx @@ -598,7 +598,14 @@ void SvxMeasurePage::Construct() { DBG_ASSERT( pView, "No valid View transferred!" ); - m_pCtlPreview->pMeasureObj->SetModel( pView->GetModel() ); + // TTTT + // pMeasureObj is member of SvxXMeasurePreview and can only be accessed due to + // SvxMeasurePage being a friend. It has it's own SdrModel (also in SvxXMeasurePreview) + // and 'setting' the SdrModel is a hack. The comment above about 'notify unit and + // floatingpoint-values' is not clear, but has to be done another way. + // Checked on aw080, is just commented out there, too. + + // m_pCtlPreview->pMeasureObj->SetModel( pView->GetModel() ); m_pCtlPreview->Invalidate(); } diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx index 226947059a7b..ee3f76be840f 100644 --- a/cui/source/tabpages/transfrm.cxx +++ b/cui/source/tabpages/transfrm.cxx @@ -566,15 +566,15 @@ bool SvxSlantTabPage::FillItemSet(SfxItemSet* rAttrs) SdrObjCustomShape& rSdrObjCustomShape( static_cast< SdrObjCustomShape& >( *pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj())); - SdrModel* pModel(rSdrObjCustomShape.GetModel()); + SdrModel& rModel(rSdrObjCustomShape.getSdrModelFromSdrObject()); SdrUndoAction* pUndo( - pModel->IsUndoEnabled() - ? pModel->GetSdrUndoFactory().CreateUndoAttrObject(rSdrObjCustomShape) + rModel.IsUndoEnabled() + ? rModel.GetSdrUndoFactory().CreateUndoAttrObject(rSdrObjCustomShape) : nullptr); if(pUndo) { - pModel->BegUndo(pUndo->GetComment()); + rModel.BegUndo(pUndo->GetComment()); } EnhancedCustomShape2d aShape(rSdrObjCustomShape); @@ -602,8 +602,8 @@ bool SvxSlantTabPage::FillItemSet(SfxItemSet* rAttrs) if (pUndo) { - pModel->AddUndo(pUndo); - pModel->EndUndo(); + rModel.AddUndo(pUndo); + rModel.EndUndo(); } } diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 0eb9efe66e86..c5c5f3af7b3a 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -3774,10 +3774,12 @@ bool EscherPropertyContainer::CreateBlipPropertiesforOLEControl(const uno::Refer SdrObject* pShape = GetSdrObjectFromXShape( rXShape ); if ( pShape ) { - SdrModel* pMod = pShape->GetModel(); - Graphic aGraphic(SdrExchangeView::GetObjGraphic( pMod, pShape)); - + Graphic aGraphic( + SdrExchangeView::GetObjGraphic( // TTTT GetObjGraphic may use a SdrObject& + &pShape->getSdrModelFromSdrObject(), + pShape)); GraphicObject aGraphicObject(aGraphic); + if (!aGraphicObject.GetUniqueID().isEmpty()) { if ( pGraphicProvider && pPicOutStrm && pShapeBoundRect ) diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index dc6712625d13..e958c813068c 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -3997,7 +3997,6 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons pRet->SetName( aFileName ); } } - pRet->SetModel( pSdrModel ); // required for GraphicLink pRet->SetLogicRect( rObjData.aBoundRect ); if ( dynamic_cast<const SdrGrafObj* >(pRet) != nullptr ) @@ -4341,7 +4340,6 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r *pSdrModel, OBJ_LINE, basegfx::B2DPolyPolygon(aPoly)); - pRet->SetModel( pSdrModel ); ApplyAttributes( rSt, aSet, aObjData ); pRet->SetMergedItemSet(aSet); } @@ -4353,7 +4351,6 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r ApplyAttributes( rSt, aSet, aObjData ); pRet = new SdrObjCustomShape(*pSdrModel); - pRet->SetModel( pSdrModel ); sal_uInt32 ngtextFStrikethrough = GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ); bool bIsFontwork = ( ngtextFStrikethrough & 0x4000 ) != 0; @@ -4474,9 +4471,7 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r { SdrOutliner& rOutliner = static_cast<SdrObjCustomShape*>(pRet)->ImpGetDrawOutliner(); bool bOldUpdateMode = rOutliner.GetUpdateMode(); - SdrModel* pModel = pRet->GetModel(); - if ( pModel ) - rOutliner.SetStyleSheetPool( static_cast<SfxStyleSheetPool*>(pModel->GetStyleSheetPool()) ); + rOutliner.SetStyleSheetPool(static_cast< SfxStyleSheetPool* >(pRet->getSdrModelFromSdrObject().GetStyleSheetPool())); rOutliner.SetUpdateMode( false ); rOutliner.SetText( *pParaObj ); ScopedVclPtrInstance< VirtualDevice > pVirDev(DeviceFormat::BITMASK); @@ -5370,7 +5365,6 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt, } pTextObj->SetMergedItemSet(aSet); - pTextObj->SetModel(pSdrModel); if (bVerticalText) pTextObj->SetVerticalWriting(true); @@ -5422,8 +5416,8 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt, pObj = new SdrRectObj( *pSdrModel, rTextRect); + pOrgObj = pObj; - pObj->SetModel( pSdrModel ); SfxItemSet aSet( pSdrModel->GetItemPool() ); ApplyAttributes( rSt, aSet, rObjData ); diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx index 7e886b6ed479..5758ca606a1b 100644 --- a/filter/source/msfilter/svdfppt.cxx +++ b/filter/source/msfilter/svdfppt.cxx @@ -1075,7 +1075,6 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi pTObj = new SdrRectObj( *pSdrModel, eTextKind != OBJ_RECT ? eTextKind : OBJ_TEXT); - pTObj->SetModel( pSdrModel ); SfxItemSet aSet( pSdrModel->GetItemPool() ); if ( !pRet ) ApplyAttributes( rSt, aSet, rObjData ); @@ -3075,14 +3074,17 @@ SdrObject* SdrPowerPointImport::ImportPageBackgroundObject( const SdrPage& rPage pSet->Put( XFillStyleItem( drawing::FillStyle_NONE ) ); } pSet->Put( XLineStyleItem( drawing::LineStyle_NONE ) ); - tools::Rectangle aRect( rPage.GetLeftBorder(), rPage.GetUpperBorder(), rPage.GetWidth()-rPage.GetRightBorder(), rPage.GetHeight()-rPage.GetLowerBorder() ); + tools::Rectangle aRect( + rPage.GetLeftBorder(), + rPage.GetUpperBorder(), + rPage.GetWidth() - rPage.GetRightBorder(), + rPage.GetHeight() - rPage.GetLowerBorder()); + pRet = new SdrRectObj( *pSdrModel, aRect); - pRet->SetModel( pSdrModel ); pRet->SetMergedItemSet(*pSet); - pRet->SetMarkProtect( true ); pRet->SetMoveProtect( true ); pRet->SetResizeProtect( true ); diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index e923eb92c021..7619c92647d1 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -1931,7 +1931,10 @@ bool SVGFilter::implCreateObjectsFromShape( const Reference< css::drawing::XDraw if( pObj ) { - Graphic aGraphic( SdrExchangeView::GetObjGraphic( pObj->GetModel(), pObj ) ); + Graphic aGraphic( + SdrExchangeView::GetObjGraphic( + &pObj->getSdrModelFromSdrObject(), + pObj)); if( aGraphic.GetType() != GraphicType::NONE ) { diff --git a/include/svx/cube3d.hxx b/include/svx/cube3d.hxx index d78de43ba672..95acaab386cd 100644 --- a/include/svx/cube3d.hxx +++ b/include/svx/cube3d.hxx @@ -67,7 +67,10 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override; - virtual E3dCubeObj* Clone() const override; + virtual E3dCubeObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dCubeObj& operator=(const E3dCubeObj& rObj); // Set local parameters with geometry recreation void SetCubePos(const basegfx::B3DPoint& rNew); diff --git a/include/svx/e3dsceneupdater.hxx b/include/svx/e3dsceneupdater.hxx index ad01d667b4f5..e6800e845e01 100644 --- a/include/svx/e3dsceneupdater.hxx +++ b/include/svx/e3dsceneupdater.hxx @@ -50,7 +50,7 @@ class SVX_DLLPUBLIC E3DModifySceneSnapRectUpdater // of the to-be-changed 3D object when the scene has a 3d transformation // stack at construction time. In all other cases it's set to zero and // no action needs to be taken - E3dScene* mpScene; + E3dScene* mpScene; // the 3d transformation stack at the time of construction, valid when // mpScene is not zero @@ -58,7 +58,7 @@ class SVX_DLLPUBLIC E3DModifySceneSnapRectUpdater public: // the constructor evaluates and sets the members at construction time - E3DModifySceneSnapRectUpdater(const SdrObject* pObject); + E3DModifySceneSnapRectUpdater(const SdrObject* mpObject); // the destructor will take action if mpScene is not zero and modify the // 2D geomeztry of the target scene diff --git a/include/svx/e3dundo.hxx b/include/svx/e3dundo.hxx index 8be61b7b9e0e..17335ea1e8e0 100644 --- a/include/svx/e3dundo.hxx +++ b/include/svx/e3dundo.hxx @@ -31,17 +31,15 @@ \************************************************************************/ class SAL_WARN_UNUSED E3dUndoAction : public SdrUndoAction { - protected: - E3dObject *pMy3DObj; + E3dObject& mrMy3DObj; public: - E3dUndoAction (SdrModel *pModel, - E3dObject *p3DObj) : - SdrUndoAction (*pModel), - pMy3DObj (p3DObj) - { - } + E3dUndoAction(E3dObject &r3DObj) + : SdrUndoAction(r3DObj.getSdrModelFromSdrObject()), + mrMy3DObj(r3DObj) + { + } virtual ~E3dUndoAction () override; @@ -55,25 +53,25 @@ class SAL_WARN_UNUSED E3dUndoAction : public SdrUndoAction \************************************************************************/ class SAL_WARN_UNUSED E3dRotateUndoAction : public E3dUndoAction { - basegfx::B3DHomMatrix aMyOldRotation; - basegfx::B3DHomMatrix aMyNewRotation; - - public: - E3dRotateUndoAction (SdrModel *pModel, - E3dObject *p3DObj, - const basegfx::B3DHomMatrix &aOldRotation, - const basegfx::B3DHomMatrix &aNewRotation) : - E3dUndoAction (pModel, p3DObj), - aMyOldRotation (aOldRotation), - aMyNewRotation (aNewRotation) - { - } - - virtual ~E3dRotateUndoAction () override; - - virtual void Undo() override; - virtual void Redo() override; - +private: + basegfx::B3DHomMatrix maMyOldRotation; + basegfx::B3DHomMatrix maMyNewRotation; + +public: + E3dRotateUndoAction( + E3dObject& r3DObj, + const basegfx::B3DHomMatrix &aOldRotation, + const basegfx::B3DHomMatrix &aNewRotation) + : E3dUndoAction(r3DObj), + maMyOldRotation(aOldRotation), + maMyNewRotation(aNewRotation) + { + } + + virtual ~E3dRotateUndoAction () override; + + virtual void Undo() override; + virtual void Redo() override; }; /************************************************************************\ @@ -83,16 +81,16 @@ class SAL_WARN_UNUSED E3dRotateUndoAction : public E3dUndoAction \************************************************************************/ class SAL_WARN_UNUSED SVX_DLLPUBLIC E3dAttributesUndoAction : public SdrUndoAction { +private: using SdrUndoAction::Repeat; - SdrObject* pObject; - - const SfxItemSet aNewSet; - const SfxItemSet aOldSet; + SdrObject& mrObject; + const SfxItemSet maNewSet; + const SfxItemSet maOldSet; public: - E3dAttributesUndoAction( SdrModel &rModel, - E3dObject* pInObject, + E3dAttributesUndoAction( + E3dObject& rInObject, const SfxItemSet& rNewSet, const SfxItemSet& rOldSet); diff --git a/include/svx/extedit.hxx b/include/svx/extedit.hxx index 5ee2864a94a2..82afea29c83f 100644 --- a/include/svx/extedit.hxx +++ b/include/svx/extedit.hxx @@ -43,18 +43,20 @@ class FmFormView; class SdrObject; class SAL_WARN_UNUSED SVX_DLLPUBLIC SdrExternalToolEdit - : public ExternalToolEdit - , public SfxListener +: public ExternalToolEdit + ,public SfxListener { private: - FmFormView * m_pView; - SdrObject * m_pObj; + FmFormView* m_pView; + SdrObject* m_pObj; SAL_DLLPRIVATE virtual void Update(Graphic&) override; SAL_DLLPRIVATE virtual void Notify(SfxBroadcaster&, const SfxHint&) override; public: - SdrExternalToolEdit(FmFormView * pView, SdrObject * pObj); + SdrExternalToolEdit( + FmFormView* pView, + SdrObject* pObj); }; #endif diff --git a/include/svx/extrud3d.hxx b/include/svx/extrud3d.hxx index 02065927efe3..5c121343af4d 100644 --- a/include/svx/extrud3d.hxx +++ b/include/svx/extrud3d.hxx @@ -84,7 +84,10 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; - virtual E3dExtrudeObj* Clone() const override; + virtual E3dExtrudeObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dExtrudeObj& operator=(const E3dExtrudeObj& rObj); // TakeObjName...() is for the display in the UI (for example "3 frames selected") virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/fmpage.hxx b/include/svx/fmpage.hxx index 808d814452b1..d7244844cf01 100644 --- a/include/svx/fmpage.hxx +++ b/include/svx/fmpage.hxx @@ -52,10 +52,12 @@ public: explicit FmFormPage(FmFormModel& rModel, bool bMasterPage=false); virtual ~FmFormPage() override; - virtual void SetModel(SdrModel* pNewModel) override; + // TTTT + // virtual void SetModel(SdrModel* pNewModel) override; - virtual SdrPage* Clone() const override; - virtual SdrPage* Clone(SdrModel* pNewModel) const override; + // TTTT + // virtual SdrPage* Clone() const override; + virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const override; virtual void InsertObject(SdrObject* pObj, size_t nPos = SAL_MAX_SIZE) override; diff --git a/include/svx/lathe3d.hxx b/include/svx/lathe3d.hxx index dd4e9cdb626a..89df10369045 100644 --- a/include/svx/lathe3d.hxx +++ b/include/svx/lathe3d.hxx @@ -90,7 +90,10 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; - virtual E3dLatheObj* Clone() const override; + virtual E3dLatheObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dLatheObj& operator=(const E3dLatheObj& rObj); virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override; diff --git a/include/svx/obj3d.hxx b/include/svx/obj3d.hxx index 36d9e61d75d7..65598f33cf7c 100644 --- a/include/svx/obj3d.hxx +++ b/include/svx/obj3d.hxx @@ -148,7 +148,6 @@ public: virtual void SetObjList(SdrObjList* pNewObjList) override; virtual void SetPage(SdrPage* pNewPage) override; - virtual void SetModel(SdrModel* pNewModel) override; virtual void NbcMove(const Size& rSize) override; virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override; virtual SdrObjList* GetSubList() const override; @@ -183,7 +182,7 @@ public: // TakeObjName...() is for the display in the UI, for example "3 frames selected". virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual E3dObject* Clone() const override; + virtual E3dObject* Clone(SdrModel* pTargetModel = nullptr) const override; E3dObject& operator=( const E3dObject& rObj ); virtual SdrObjGeoData *NewGeoData() const override; @@ -242,7 +241,10 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual void RecalcSnapRect() override; - virtual E3dCompoundObject* Clone() const override; + virtual E3dCompoundObject* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dCompoundObject& operator=(const E3dCompoundObject& rObj); bool IsAOrdNumRemapCandidate(E3dScene*& prScene) const; }; diff --git a/include/svx/polygn3d.hxx b/include/svx/polygn3d.hxx index 68bc22260092..9f5acca38ce2 100644 --- a/include/svx/polygn3d.hxx +++ b/include/svx/polygn3d.hxx @@ -57,7 +57,10 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override; - virtual E3dPolygonObj* Clone() const override; + virtual E3dPolygonObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dPolygonObj& operator=(const E3dPolygonObj& rObj); // LineOnly? bool GetLineOnly() const { return bLineOnly; } diff --git a/include/svx/scene3d.hxx b/include/svx/scene3d.hxx index e4ca3e4a779c..eef2c0422ba9 100644 --- a/include/svx/scene3d.hxx +++ b/include/svx/scene3d.hxx @@ -130,7 +130,7 @@ public: const Camera3D& GetCamera() const { return aCamera; } void removeAllNonSelectedObjects(); - virtual E3dScene* Clone() const override; + virtual E3dScene* Clone(SdrModel* pTargetModel = nullptr) const override; E3dScene& operator=(const E3dScene&); virtual SdrObjGeoData *NewGeoData() const override; diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx index 6a999a78b344..fe03d7353a2b 100644 --- a/include/svx/sdr/table/tablecontroller.hxx +++ b/include/svx/sdr/table/tablecontroller.hxx @@ -29,7 +29,7 @@ #include <svx/svdotable.hxx> #include <svx/svdview.hxx> -class SdrObjEditView; +class SdrView; class SdrObject; class SfxItemSet; class SvxBoxInfoItem; @@ -39,10 +39,12 @@ namespace sdr { namespace table { class TableModel; -class SVX_DLLPUBLIC SvxTableController: public sdr::SelectionController +class SVX_DLLPUBLIC SvxTableController : public sdr::SelectionController { public: - SVX_DLLPRIVATE SvxTableController( SdrObjEditView* pView, const SdrTableObj* pObj ); + SVX_DLLPRIVATE SvxTableController( + SdrView& rView, + const SdrTableObj& rObj); SVX_DLLPRIVATE virtual ~SvxTableController() override; // from sdr::SelectionController @@ -76,7 +78,10 @@ public: SVX_DLLPRIVATE void DistributeRows(); SVX_DLLPRIVATE void SetVertical( sal_uInt16 nSId ); - SVX_DLLPRIVATE static rtl::Reference< sdr::SelectionController > create( SdrObjEditView* pView, const SdrTableObj* pObj, const rtl::Reference< sdr::SelectionController >& xRefController ); + SVX_DLLPRIVATE static rtl::Reference< sdr::SelectionController > create( + SdrView& rView, + const SdrTableObj& rObj, + const rtl::Reference< sdr::SelectionController >& xRefController); SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const; SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll); @@ -93,7 +98,7 @@ public: SVX_DLLPRIVATE virtual bool GetMarkedObjModel( SdrPage* pNewPage ) override; SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel ) override; - SVX_DLLPRIVATE virtual bool hasSelectedCells() const override { return mbCellSelectionMode || mpView->IsTextEdit(); } + SVX_DLLPRIVATE virtual bool hasSelectedCells() const override { return mbCellSelectionMode || mrView.IsTextEdit(); } /// @see sdr::SelectionController::setCursorLogicPosition(). SVX_DLLPRIVATE virtual bool setCursorLogicPosition(const Point& rPosition, bool bPoint) override; @@ -174,17 +179,16 @@ private: CellPos maMouseDownPos; bool mbLeftButtonDown; sdr::overlay::OverlayObjectList* mpSelectionOverlay; - - SdrView* mpView; + SdrView& mrView; tools::WeakReference<SdrTableObj> mxTableObj; - SdrModel* mpModel; - css::uno::Reference< css::util::XModifyListener > mxModifyListener; - ImplSVEvent * mnUpdateEvent; }; -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 ); } } diff --git a/include/svx/sphere3d.hxx b/include/svx/sphere3d.hxx index b26c5dc881aa..e5534e528fa9 100644 --- a/include/svx/sphere3d.hxx +++ b/include/svx/sphere3d.hxx @@ -60,7 +60,10 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override; - virtual E3dSphereObj* Clone() const override; + virtual E3dSphereObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dSphereObj& operator=(const E3dSphereObj& rObj); const basegfx::B3DPoint& Center() const { return aCenter; } const basegfx::B3DVector& Size() const { return aSize; } diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx index 9e60509c8f54..3ce7833ca8c8 100644 --- a/include/svx/svdoashp.hxx +++ b/include/svx/svdoashp.hxx @@ -165,8 +165,6 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; - virtual void SetModel(SdrModel* pNewModel) override; - virtual void Move(const Size& rSiz) override; virtual void Shear(const Point& rRef, long nAngle, double tn, bool bVShear) override; virtual void SetSnapRect(const tools::Rectangle& rRect) override; @@ -209,7 +207,7 @@ public: virtual void TakeTextAnchorRect( tools::Rectangle& rAnchorRect ) const override; virtual void TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText, tools::Rectangle* pAnchorRect, bool bLineWidth = true ) const override; - virtual SdrObjCustomShape* Clone() const override; + virtual SdrObjCustomShape* Clone(SdrModel* pTargetModel = nullptr) const override; SdrObjCustomShape& operator=(const SdrObjCustomShape& rObj); virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/svdoattr.hxx b/include/svx/svdoattr.hxx index dceb694adc61..a39a91957841 100644 --- a/include/svx/svdoattr.hxx +++ b/include/svx/svdoattr.hxx @@ -28,20 +28,14 @@ #include <svx/svdattr.hxx> #include <svx/svxdllapi.h> - // Initial Declarations - - class SfxPoolItem; class SfxSetItem; class SdrOutliner; class SfxItemSet; class SfxItemPool; - // SdrAttrObj - - class SVX_DLLPUBLIC SdrAttrObj : public SdrObject { private: @@ -71,8 +65,6 @@ public: bool HasLine() const; virtual const tools::Rectangle& GetSnapRect() const override; - - virtual void SetModel(SdrModel* pNewModel) override; }; diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index bd65d70d554b..553a3ae580a3 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -334,6 +334,7 @@ private: void setFillGeometryDefiningShape(const SdrObject* pNew) { mpFillGeometryDefiningShape = pNew; } public: const SdrObject* getFillGeometryDefiningShape() const { return mpFillGeometryDefiningShape; } + private: // the SdrModel this objects was created with, unchanged during SdrObject lifetime SdrModel& mrSdrModelFromSdrObject; @@ -387,9 +388,6 @@ public: virtual void SetPage(SdrPage* pNewPage); SdrPage* GetPage() const { return pPage;} - - virtual void SetModel(SdrModel* pNewModel); - SdrModel* GetModel() const { return pModel;} SfxItemPool & GetObjectItemPool() const; void AddListener(SfxListener& rListener); @@ -484,7 +482,7 @@ public: // Returns a copy of the object. Every inherited class must reimplement this (in class Foo // it should be sufficient to do "virtual Foo* Clone() const { return CloneHelper< Foo >(); }". // Note that this function uses operator= internally. - virtual SdrObject* Clone() const; + virtual SdrObject* Clone(SdrModel* pTargetModel = nullptr) const; // implemented mainly for the purposes of Clone() SdrObject& operator=(const SdrObject& rObj); @@ -915,7 +913,6 @@ protected: tools::Rectangle aOutRect; // surrounding rectangle for Paint (incl. LineWdt, ...) Point aAnchor; // anchor position (Writer) SdrPage* pPage; - SdrModel* pModel; SdrObjUserCall* pUserCall; std::unique_ptr<SdrObjPlusData> pPlusData; // Broadcaster, UserData, connectors, ... (this is the Bitsack) @@ -957,7 +954,6 @@ protected: void ImpForcePlusData(); - OUString GetAngleStr(long nAngle) const; OUString GetMetrStr(long nVal) const; /// A derived class must override these 3 methods if it has own geometric @@ -993,7 +989,7 @@ protected: virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& _rxUnoShape ); // helper function for reimplementing Clone(). - template< typename T > T* CloneHelper() const; + template< typename T > T* CloneHelper(SdrModel* pTargetModel) const; private: struct Impl; @@ -1069,34 +1065,39 @@ class SVX_DLLPUBLIC SdrObjFactory { public: static SdrObject* MakeNewObject( - SdrModel& rSdrModel, // TTTT check usages, may be better to put to a class - SdrInventor nInventor, - sal_uInt16 nObjIdentifier, - SdrPage* pPage, - SdrModel* pModel=nullptr); - - static SdrObject* MakeNewObject( SdrModel& rSdrModel, SdrInventor nInventor, sal_uInt16 nObjIdentifier, - const tools::Rectangle& rSnapRect, - SdrPage* pPage); + SdrPage* pPage = nullptr, + const tools::Rectangle* pSnapRect = nullptr); static void InsertMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> const & rLink); static void RemoveMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> const & rLink); private: - static SVX_DLLPRIVATE SdrObject* CreateObjectFromFactory(SdrModel& rSdrModel, SdrInventor nInventor, sal_uInt16 nIdentifier); + static SVX_DLLPRIVATE SdrObject* CreateObjectFromFactory( + SdrModel& rSdrModel, + SdrInventor nInventor, + sal_uInt16 nIdentifier); SdrObjFactory() = delete; }; -template< typename T > T* SdrObject::CloneHelper() const +template< typename T > T* SdrObject::CloneHelper(SdrModel* pTargetModel) const { OSL_ASSERT( typeid( T ) == typeid( *this )); - T* pObj = dynamic_cast< T* >(SdrObjFactory::MakeNewObject(getSdrModelFromSdrObject(), GetObjInventor(), GetObjIdentifier(), nullptr)); - if (pObj!=nullptr) - *pObj=*static_cast< const T* >( this ); + T* pObj = dynamic_cast< T* >( + SdrObjFactory::MakeNewObject( + nullptr == pTargetModel ? getSdrModelFromSdrObject() : *pTargetModel, + GetObjInventor(), + GetObjIdentifier())); + + if(nullptr != pObj) + { + // use ::operator=() + *pObj = *static_cast< const T* >( this ); + } + return pObj; } diff --git a/include/svx/svdocapt.hxx b/include/svx/svdocapt.hxx index 078c51fc7741..baa0e0390bd6 100644 --- a/include/svx/svdocapt.hxx +++ b/include/svx/svdocapt.hxx @@ -75,7 +75,10 @@ public: virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; - virtual SdrCaptionObj* Clone() const override; + virtual SdrCaptionObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + SdrCaptionObj& operator=(const SdrCaptionObj& rObj); // for calc: special shadow only for text box void SetSpecialTextBoxShadow() { mbSpecialTextBoxShadow = true; } @@ -88,7 +91,6 @@ public: virtual OUString TakeObjNamePlural() const override; virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; - virtual void SetModel(SdrModel* pNewModel) override; virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; virtual sal_uInt32 GetHdlCount() const override; diff --git a/include/svx/svdocirc.hxx b/include/svx/svdocirc.hxx index 56028e49a370..fc3045585aa6 100644 --- a/include/svx/svdocirc.hxx +++ b/include/svx/svdocirc.hxx @@ -94,7 +94,11 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrCircObj* Clone() const override; + virtual SdrCircObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + SdrCircObj& operator=(const SdrCircObj& rObj); + virtual void RecalcSnapRect() override; virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; diff --git a/include/svx/svdoedge.hxx b/include/svx/svdoedge.hxx index 94e02d167872..ae28ad7103be 100644 --- a/include/svx/svdoedge.hxx +++ b/include/svx/svdoedge.hxx @@ -213,7 +213,7 @@ public: virtual void RecalcSnapRect() override; virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; - virtual SdrEdgeObj* Clone() const override; + virtual SdrEdgeObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrEdgeObj& operator=(const SdrEdgeObj& rObj); virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx index 7d7e0cbe0854..d11a289060f8 100644 --- a/include/svx/svdograf.hxx +++ b/include/svx/svdograf.hxx @@ -186,7 +186,7 @@ public: // #i25616# virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; - virtual SdrGrafObj* Clone() const override; + virtual SdrGrafObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrGrafObj& operator=(const SdrGrafObj& rObj); virtual sal_uInt32 GetHdlCount() const override; @@ -201,7 +201,6 @@ public: bool HasGDIMetaFile() const; virtual void SetPage(SdrPage* pNewPage) override; - virtual void SetModel(SdrModel* pNewModel) override; bool isEmbeddedVectorGraphicData() const; GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() const; diff --git a/include/svx/svdogrp.hxx b/include/svx/svdogrp.hxx index 068a14ecdb1b..5206e5b05f4d 100644 --- a/include/svx/svdogrp.hxx +++ b/include/svx/svdogrp.hxx @@ -56,13 +56,12 @@ public: virtual void NbcSetLayer(SdrLayerID nLayer) override; virtual void SetObjList(SdrObjList* pNewObjList) override; virtual void SetPage(SdrPage* pNewPage) override; - virtual void SetModel(SdrModel* pNewModel) override; virtual SdrObjList* GetSubList() const override; virtual const tools::Rectangle& GetCurrentBoundRect() const override; virtual const tools::Rectangle& GetSnapRect() const override; - virtual SdrObjGroup* Clone() const override; + virtual SdrObjGroup* Clone(SdrModel* pTargetModel = nullptr) const override; SdrObjGroup& operator=(const SdrObjGroup& rObj); virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx index 1f6aa000806a..00a4a9567546 100644 --- a/include/svx/svdomeas.hxx +++ b/include/svx/svdomeas.hxx @@ -95,7 +95,10 @@ public: virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; - virtual SdrMeasureObj* Clone() const override; + virtual SdrMeasureObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + SdrMeasureObj& operator=(const SdrMeasureObj& rObj); virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx index c4aafc46cce8..a45410f76bdf 100644 --- a/include/svx/svdomedia.hxx +++ b/include/svx/svdomedia.hxx @@ -52,7 +52,7 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrMediaObj* Clone() const override; + virtual SdrMediaObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrMediaObj& operator=(const SdrMediaObj& rObj); virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override; diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx index 7e9241d5a660..4f842733f86a 100644 --- a/include/svx/svdoole2.hxx +++ b/include/svx/svdoole2.hxx @@ -119,7 +119,6 @@ public: void AbandonObject(); virtual void SetPage(SdrPage* pNewPage) override; - virtual void SetModel(SdrModel* pModel) override; /** Change the IsClosedObj attribute @@ -136,7 +135,7 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrOle2Obj* Clone() const override; + virtual SdrOle2Obj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrOle2Obj& assignFrom(const SdrOle2Obj& rObj); SdrOle2Obj& operator=(const SdrOle2Obj& rObj); diff --git a/include/svx/svdopage.hxx b/include/svx/svdopage.hxx index 7e0bc3aa7f34..1f349a9a38ad 100644 --- a/include/svx/svdopage.hxx +++ b/include/svx/svdopage.hxx @@ -59,7 +59,7 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; - virtual SdrPageObj* Clone() const override; + virtual SdrPageObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrPageObj& operator=(const SdrPageObj& rObj); virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx index 77e2752f3866..6c21fd06571a 100644 --- a/include/svx/svdopath.hxx +++ b/include/svx/svdopath.hxx @@ -75,7 +75,7 @@ public: virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; - virtual SdrPathObj* Clone() const override; + virtual SdrPathObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrPathObj& operator=(const SdrPathObj& rObj); virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/svdorect.hxx b/include/svx/svdorect.hxx index 665ccfeba885..f9c1c34fd145 100644 --- a/include/svx/svdorect.hxx +++ b/include/svx/svdorect.hxx @@ -91,7 +91,7 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrRectObj* Clone() const override; + virtual SdrRectObj* Clone(SdrModel* pTargetModel = nullptr) const override; virtual void RecalcSnapRect() override; virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override; diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx index 29923b5f5160..7c5e30ec4e8d 100644 --- a/include/svx/svdotable.hxx +++ b/include/svx/svdotable.hxx @@ -108,7 +108,10 @@ public: virtual ~SdrTableObj() override; // Table stuff - SdrTableObj* CloneRange( const CellPos& rStartPos, const CellPos& rEndPos ); + SdrTableObj* CloneRange( + const CellPos& rStartPos, + const CellPos& rEndPos, + SdrModel& rTargetModel); void DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColumn ); void DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow ); @@ -188,7 +191,6 @@ public: virtual bool IsFontwork() const override; - virtual void SetModel(SdrModel* pNewModel) override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; virtual void SetChanged() override; @@ -197,7 +199,7 @@ public: virtual bool AdjustTextFrameWidthAndHeight() override; virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrTableObj* Clone() const override; + virtual SdrTableObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrTableObj& operator=(const SdrTableObj& rObj); virtual void RecalcSnapRect() override; virtual const tools::Rectangle& GetSnapRect() const override; diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index 9acaf3e2f119..13ff8940d0c1 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -437,7 +437,6 @@ public: SdrTextAniDirection GetTextAniDirection() const; virtual void SetPage(SdrPage* pNewPage) override; - virtual void SetModel(SdrModel* pNewModel) override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; @@ -445,7 +444,7 @@ public: virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const; virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrTextObj* Clone() const override; + virtual SdrTextObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrTextObj& operator=(const SdrTextObj& rObj); virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; virtual basegfx::B2DPolyPolygon TakeContour() const override; diff --git a/include/svx/svdouno.hxx b/include/svx/svdouno.hxx index 161c52c6d05c..d9dfb5d6acd2 100644 --- a/include/svx/svdouno.hxx +++ b/include/svx/svdouno.hxx @@ -73,7 +73,7 @@ public: virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; - virtual SdrUnoObj* Clone() const override; + virtual SdrUnoObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrUnoObj& operator= (const SdrUnoObj& rObj); virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override; virtual void NbcSetLayer(SdrLayerID nLayer) override; diff --git a/include/svx/svdovirt.hxx b/include/svx/svdovirt.hxx index 791a2d1fa275..9e4e6d9ed179 100644 --- a/include/svx/svdovirt.hxx +++ b/include/svx/svdovirt.hxx @@ -37,7 +37,7 @@ protected: virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override; SdrObject& rRefObj; // Referenced drawing object - tools::Rectangle aSnapRect; + tools::Rectangle aSnapRect; protected: virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; @@ -55,7 +55,6 @@ public: SdrObject& ReferencedObj(); const SdrObject& GetReferencedObj() const; virtual void NbcSetAnchorPos(const Point& rAnchorPos) override; - virtual void SetModel(SdrModel* pNewModel) override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual SdrInventor GetObjInventor() const override; @@ -65,7 +64,7 @@ public: virtual const tools::Rectangle& GetCurrentBoundRect() const override; virtual const tools::Rectangle& GetLastBoundRect() const override; virtual void RecalcBoundRect() override; - virtual SdrVirtObj* Clone() const override; + virtual SdrVirtObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrVirtObj& operator=(const SdrVirtObj& rObj); virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx index cbf3032baddd..41b9363839a9 100644 --- a/include/svx/svdpage.hxx +++ b/include/svx/svdpage.hxx @@ -120,7 +120,10 @@ public: SdrPage* GetPage() const; void SetPage(SdrPage* pNewPage); SdrModel* GetModel() const; - virtual void SetModel(SdrModel* pNewModel); + + // TTTT + // virtual void SetModel(SdrModel* pNewModel); + /// recalculate order numbers / ZIndex void RecalcObjOrdNums(); bool IsObjOrdNumsDirty() const { return bObjOrdNumsDirty; } @@ -446,8 +449,11 @@ protected: public: explicit SdrPage(SdrModel& rNewModel, bool bMasterPage=false); virtual ~SdrPage() override; - virtual SdrPage* Clone() const; - virtual SdrPage* Clone(SdrModel* pNewModel) const; + + // TTTT + // virtual SdrPage* Clone() const override; + + virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const; bool IsMasterPage() const { return mbMaster; } void SetInserted(bool bNew = true); bool IsInserted() const { return mbInserted; } @@ -478,7 +484,8 @@ public: sal_Int32 GetRightBorder() const; sal_Int32 GetLowerBorder() const; - virtual void SetModel(SdrModel* pNewModel) override; + // TTTT + // virtual void SetModel(SdrModel* pNewModel) override; // New MasterPage interface bool TRG_HasMasterPage() const { return (nullptr != mpMasterPageDescriptor); } diff --git a/include/svx/svdtext.hxx b/include/svx/svdtext.hxx index 020d8a483b4b..c232cc929f93 100644 --- a/include/svx/svdtext.hxx +++ b/include/svx/svdtext.hxx @@ -47,7 +47,9 @@ public: explicit SdrText( SdrTextObj& rObject ); virtual ~SdrText() override; - virtual void SetModel(SdrModel* pNewModel); + // TTTT + // virtual void SetModel(SdrModel* pNewModel); + void ForceOutlinerParaObject( OutlinerMode nOutlMode ); virtual void SetOutlinerParaObject( OutlinerParaObject* pTextObject ); @@ -60,7 +62,8 @@ public: // return a text-specific ItemSet virtual const SfxItemSet& GetItemSet() const; - SdrModel* GetModel() const { return mpModel; } + // TTTT does not need an own SdrModel reference - always has the SdrTextObj working with + // SdrModel& GetSdrModelFromSdrTextObj() const { return mrObject.getSdrModelFromSdrObject(); } SdrTextObj& GetObject() const { return mrObject; } /** returns the current OutlinerParaObject and removes it from this instance */ @@ -76,7 +79,6 @@ protected: private: std::unique_ptr<OutlinerParaObject> mpOutlinerParaObject; SdrTextObj& mrObject; - SdrModel* mpModel; bool mbPortionInfoChecked; }; diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx index 77f4437f8ae9..ae84bb361a92 100644 --- a/include/svx/svxdlg.hxx +++ b/include/svx/svxdlg.hxx @@ -464,7 +464,7 @@ public: const sal_uInt16 _nInitiallySelectedEvent ) = 0; - virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj )=0; + virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, const SdrModel& rModel, const SdrObject* pObj )=0; virtual VclPtr<SvxAbstractSplitTableDialog> CreateSvxSplitTableDialog(weld::Window* pParent, bool bIsTableVertical, long nMaxVertical) = 0; diff --git a/include/svx/unoshape.hxx b/include/svx/unoshape.hxx index 4bb90d88ee0e..d3b38c6456e9 100644 --- a/include/svx/unoshape.hxx +++ b/include/svx/unoshape.hxx @@ -206,7 +206,8 @@ public: void TakeSdrObjectOwnership(); bool HasSdrObjectOwnership() const; - void ChangeModel( SdrModel* pNewModel ); + // TTTT needed? + // void ChangeModel( SdrModel* pNewModel ); void InvalidateSdrObject() { mpObj.reset( nullptr ); }; SdrObject* GetSdrObject() const {return mpObj.get();} diff --git a/reportdesign/inc/RptObject.hxx b/reportdesign/inc/RptObject.hxx index b6aca58c5fb3..17f433629c56 100644 --- a/reportdesign/inc/RptObject.hxx +++ b/reportdesign/inc/RptObject.hxx @@ -182,7 +182,7 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual SdrInventor GetObjInventor() const override; // Clone() should make a complete copy of the object. - virtual OOle2Obj* Clone() const override; + virtual OOle2Obj* Clone(SdrModel* pTargetModel = nullptr) const override; virtual void initializeOle() override; OOle2Obj& operator=(const OOle2Obj& rObj); @@ -259,7 +259,7 @@ public: virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override; virtual sal_uInt16 GetObjIdentifier() const override; virtual SdrInventor GetObjInventor() const override; - virtual OUnoObject* Clone() const override; + virtual OUnoObject* Clone(SdrModel* pTargetModel = nullptr) const override; OUnoObject& operator=(const OUnoObject& rObj); diff --git a/reportdesign/inc/RptPage.hxx b/reportdesign/inc/RptPage.hxx index d5a3d42429dc..fac9855da86c 100644 --- a/reportdesign/inc/RptPage.hxx +++ b/reportdesign/inc/RptPage.hxx @@ -58,9 +58,9 @@ public: OReportPage( OReportModel& rModel ,const css::uno::Reference< css::report::XSection >& _xSection ); - - virtual SdrPage* Clone() const override; - virtual SdrPage* Clone( SdrModel* pNewModel ) const override; + // TTTT + // virtual SdrPage* Clone() const override; + virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const override; virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE) override; virtual SdrObject* RemoveObject(size_t nObjNum) override; diff --git a/reportdesign/source/core/sdr/ReportDrawPage.cxx b/reportdesign/source/core/sdr/ReportDrawPage.cxx index 714e4a7c07d7..bd28331e0ca8 100644 --- a/reportdesign/source/core/sdr/ReportDrawPage.cxx +++ b/reportdesign/source/core/sdr/ReportDrawPage.cxx @@ -106,7 +106,7 @@ uno::Reference< drawing::XShape > OReportDrawPage::CreateShape( SdrObject *pObj sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; uno::Reference < embed::XEmbeddedObject > xObj; OUString sName; - xObj = pObj->GetModel()->GetPersist()->getEmbeddedObjectContainer().CreateEmbeddedObject( + xObj = pObj->getSdrModelFromSdrObject().GetPersist()->getEmbeddedObjectContainer().CreateEmbeddedObject( ::comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation( "80243D39-6741-46C5-926E-069164FF87BB"), sName ); OSL_ENSURE(xObj.is(),"Embedded Object could not be created!"); @@ -136,8 +136,8 @@ uno::Reference< drawing::XShape > OReportDrawPage::CreateShape( SdrObject *pObj try { - OReportModel* pRptModel = static_cast<OReportModel*>(pObj->GetModel()); - xRet.set( pRptModel->createShape(sServiceName,xShape,bChangeOrientation ? 0 : 1), uno::UNO_QUERY_THROW ); + OReportModel& rRptModel(static_cast< OReportModel& >(pObj->getSdrModelFromSdrObject())); + xRet.set( rRptModel.createShape(sServiceName,xShape,bChangeOrientation ? 0 : 1), uno::UNO_QUERY_THROW ); } catch( const uno::Exception& ) { diff --git a/reportdesign/source/core/sdr/ReportUndoFactory.cxx b/reportdesign/source/core/sdr/ReportUndoFactory.cxx index e40411c3b2ec..ee64aed0e003 100644 --- a/reportdesign/source/core/sdr/ReportUndoFactory.cxx +++ b/reportdesign/source/core/sdr/ReportUndoFactory.cxx @@ -35,9 +35,9 @@ SdrUndoAction* lcl_createUndo(SdrObject& rObject, Action _eAction, const char* p uno::Reference< report::XGroup> xGroup = xSection->getGroup(); SdrUndoAction* pUndo = nullptr; if ( xGroup.is() ) - pUndo = new OUndoGroupSectionAction(*rObject.GetModel(),_eAction,OGroupHelper::getMemberFunction(xSection),xGroup,xReportComponent,pCommentId); + pUndo = new OUndoGroupSectionAction(rObject.getSdrModelFromSdrObject(),_eAction,OGroupHelper::getMemberFunction(xSection),xGroup,xReportComponent,pCommentId); else - pUndo = new OUndoReportSectionAction(*rObject.GetModel(),_eAction,OReportHelper::getMemberFunction(xSection),xSection->getReportDefinition(),xReportComponent,pCommentId); + pUndo = new OUndoReportSectionAction(rObject.getSdrModelFromSdrObject(),_eAction,OReportHelper::getMemberFunction(xSection),xSection->getReportDefinition(),xReportComponent,pCommentId); return pUndo; } diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx index c85a88fe04c7..737c87e3b1fe 100644 --- a/reportdesign/source/core/sdr/RptObject.cxx +++ b/reportdesign/source/core/sdr/RptObject.cxx @@ -517,8 +517,8 @@ void OCustomShape::NbcMove( const Size& rSize ) if ( m_xReportComponent.is() ) { - OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); - OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv()); m_xReportComponent->setPositionX(m_xReportComponent->getPositionX() + rSize.Width()); m_xReportComponent->setPositionY(m_xReportComponent->getPositionY() + rSize.Height()); } @@ -550,13 +550,12 @@ bool OCustomShape::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) bool bResult = SdrObjCustomShape::EndCreate(rStat, eCmd); if ( bResult ) { - OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); - if ( pRptModel ) - { - OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); - if ( !m_xReportComponent.is() ) - m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); - } + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv()); + + if ( !m_xReportComponent.is() ) + m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); + SetPropsFromRect(GetSnapRect()); } @@ -575,8 +574,8 @@ uno::Reference< uno::XInterface > OCustomShape::getUnoShape() uno::Reference< uno::XInterface> xShape = OObjectBase::getUnoShapeOf( *this ); if ( !m_xReportComponent.is() ) { - OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); - OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv()); m_xReportComponent.set(xShape,uno::UNO_QUERY); } return xShape; @@ -646,12 +645,8 @@ void OUnoObject::impl_setReportComponent_nothrow() if ( m_xReportComponent.is() ) return; - OReportModel* pReportModel = static_cast<OReportModel*>(GetModel()); - OSL_ENSURE( pReportModel, "OUnoObject::impl_setReportComponent_nothrow: no report model!" ); - if ( !pReportModel ) - return; - - OXUndoEnvironment::OUndoEnvLock aLock( pReportModel->GetUndoEnv() ); + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + OXUndoEnvironment::OUndoEnvLock aLock( rRptModel.GetUndoEnv() ); m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); impl_initializeModel_nothrow(); @@ -685,13 +680,14 @@ void OUnoObject::NbcMove( const Size& rSize ) if ( m_xReportComponent.is() ) { bool bUndoMode = false; - OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); - if (pRptModel->GetUndoEnv().IsUndoMode()) + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + + if (rRptModel.GetUndoEnv().IsUndoMode()) { // if we are locked from outside, then we must not handle wrong moves, we are in UNDO mode bUndoMode = true; } - OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv()); // LLA: why there exists getPositionX and getPositionY and NOT getPosition() which return a Point? int nNewX = m_xReportComponent->getPositionX() + rSize.Width(); @@ -707,7 +703,7 @@ void OUnoObject::NbcMove( const Size& rSize ) } if (bPositionFixed) { - GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize)); + getSdrModelFromSdrObject().AddUndo(getSdrModelFromSdrObject().GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize)); } // set geometry properties SetPropsFromRect(GetLogicRect()); @@ -887,6 +883,11 @@ void OUnoObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& rxUn releaseUnoShape(); } +OUnoObject* OUnoObject::Clone(SdrModel* pTargetModel) const +{ + return CloneHelper< OUnoObject >(pTargetModel); +} + OUnoObject& OUnoObject::operator=(const OUnoObject& rObj) { if( this == &rObj ) @@ -901,11 +902,6 @@ OUnoObject& OUnoObject::operator=(const OUnoObject& rObj) return *this; } -OUnoObject* OUnoObject::Clone() const -{ - return CloneHelper< OUnoObject >(); -} - // OOle2Obj OOle2Obj::OOle2Obj( SdrModel& rSdrModel, @@ -964,13 +960,14 @@ void OOle2Obj::NbcMove( const Size& rSize ) if ( m_xReportComponent.is() ) { bool bUndoMode = false; - OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); - if (pRptModel->GetUndoEnv().IsUndoMode()) + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + + if (rRptModel.GetUndoEnv().IsUndoMode()) { // if we are locked from outside, then we must not handle wrong moves, we are in UNDO mode bUndoMode = true; } - OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv()); // LLA: why there exists getPositionX and getPositionY and NOT getPosition() which return a Point? int nNewX = m_xReportComponent->getPositionX() + rSize.Width(); @@ -991,7 +988,7 @@ void OOle2Obj::NbcMove( const Size& rSize ) } if (bPositionFixed) { - GetModel()->AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize)); + getSdrModelFromSdrObject().AddUndo(getSdrModelFromSdrObject().GetSdrUndoFactory().CreateUndoMoveObject(*this, aUndoSize)); } // set geometry properties SetPropsFromRect(GetLogicRect()); @@ -1037,13 +1034,12 @@ bool OOle2Obj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) bool bResult = SdrOle2Obj::EndCreate(rStat, eCmd); if ( bResult ) { - OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); - if ( pRptModel ) - { - OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); - if ( !m_xReportComponent.is() ) - m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); - } + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv()); + + if ( !m_xReportComponent.is() ) + m_xReportComponent.set(getUnoShape(),uno::UNO_QUERY); + // set geometry properties SetPropsFromRect(GetLogicRect()); } @@ -1062,8 +1058,8 @@ uno::Reference< uno::XInterface > OOle2Obj::getUnoShape() uno::Reference< uno::XInterface> xShape = OObjectBase::getUnoShapeOf( *this ); if ( !m_xReportComponent.is() ) { - OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); - OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv()); m_xReportComponent.set(xShape,uno::UNO_QUERY); } return xShape; @@ -1092,33 +1088,32 @@ uno::Reference< chart2::data::XDatabaseDataProvider > lcl_getDataProvider(const return xSource; } +// Clone() should make a complete copy of the object. +OOle2Obj* OOle2Obj::Clone(SdrModel* pTargetModel) const +{ + return CloneHelper< OOle2Obj >(pTargetModel); +} + OOle2Obj& OOle2Obj::operator=(const OOle2Obj& rObj) { if( this == &rObj ) return *this; SdrOle2Obj::operator=(rObj); - OReportModel* pRptModel = static_cast<OReportModel*>(rObj.GetModel()); + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); svt::EmbeddedObjectRef::TryRunningState( GetObjRef() ); - impl_createDataProvider_nothrow(pRptModel->getReportDefinition().get()); + impl_createDataProvider_nothrow(rRptModel.getReportDefinition().get()); uno::Reference< chart2::data::XDatabaseDataProvider > xSource( lcl_getDataProvider(rObj.GetObjRef()) ); uno::Reference< chart2::data::XDatabaseDataProvider > xDest( lcl_getDataProvider(GetObjRef()) ); if ( xSource.is() && xDest.is() ) comphelper::copyProperties(xSource.get(),xDest.get()); - initializeChart(pRptModel->getReportDefinition().get()); + initializeChart(rRptModel.getReportDefinition().get()); return *this; } - -// Clone() should make a complete copy of the object. -OOle2Obj* OOle2Obj::Clone() const -{ - return CloneHelper< OOle2Obj >(); -} - void OOle2Obj::impl_createDataProvider_nothrow(const uno::Reference< frame::XModel>& _xModel) { try @@ -1147,8 +1142,8 @@ void OOle2Obj::initializeOle() { m_bOnlyOnce = false; uno::Reference < embed::XEmbeddedObject > xObj = GetObjRef(); - OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); - pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + rRptModel.GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); if( xCompSupp.is() ) @@ -1179,8 +1174,8 @@ void OOle2Obj::initializeChart( const uno::Reference< frame::XModel>& _xModel) if ( !lcl_getDataProvider(xObj).is() ) impl_createDataProvider_nothrow(_xModel); - OReportModel* pRptModel = static_cast<OReportModel*>(GetModel()); - pRptModel->GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); + OReportModel& rRptModel(static_cast< OReportModel& >(getSdrModelFromSdrObject())); + rRptModel.GetUndoEnv().AddElement(lcl_getDataProvider(xObj)); ::comphelper::NamedValueCollection aArgs; aArgs.put( "CellRangeRepresentation", uno::makeAny( OUString( "all" ) ) ); diff --git a/reportdesign/source/core/sdr/RptPage.cxx b/reportdesign/source/core/sdr/RptPage.cxx index 9f783bc1723e..5c70e62c8929 100644 --- a/reportdesign/source/core/sdr/RptPage.cxx +++ b/reportdesign/source/core/sdr/RptPage.cxx @@ -53,11 +53,11 @@ OReportPage::~OReportPage() { } - -SdrPage* OReportPage::Clone() const -{ - return Clone(nullptr); -} +// TTTT +// SdrPage* OReportPage::Clone() const +// { +// return Clone(nullptr); +// } SdrPage* OReportPage::Clone( SdrModel* const pNewModel ) const { diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index 9c10c8bf19e8..d4ee02b408ed 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -3111,8 +3111,7 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co *m_aReportModel, SdrInventor::ReportDesign, _nObjectId, - pSectionWindow->getReportSection().getPage(), - m_aReportModel.get()); + pSectionWindow->getReportSection().getPage()); xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY); OUString sCustomShapeType = getDesignView()->GetInsertObjString(); if ( sCustomShapeType.isEmpty() ) @@ -3126,8 +3125,7 @@ void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,co *m_aReportModel, SdrInventor::ReportDesign, _nObjectId, - pSectionWindow->getReportSection().getPage(), - m_aReportModel.get()); + pSectionWindow->getReportSection().getPage()); pNewControl->SetLogicRect(tools::Rectangle(3000,500,8000,5500)); // switch height and width xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY_THROW); diff --git a/reportdesign/source/ui/report/ReportSection.cxx b/reportdesign/source/ui/report/ReportSection.cxx index cbae30cc481d..cb23ef347f01 100644 --- a/reportdesign/source/ui/report/ReportSection.cxx +++ b/reportdesign/source/ui/report/ReportSection.cxx @@ -265,10 +265,11 @@ void OReportSection::Paste(const uno::Sequence< beans::NamedValue >& _aAllreadyC SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr; if ( pObject ) { - SdrObject* pNewObj = pObject->Clone(); + // TTTT clone to target SdrModel + SdrObject* pNewObj(pObject->Clone(m_pModel.get())); pNewObj->SetPage( m_pPage ); - pNewObj->SetModel( m_pModel.get() ); + //pNewObj->SetModel( m_pModel.get() ); m_pPage->InsertObject(pNewObj, SAL_MAX_SIZE); tools::Rectangle aRet(VCLPoint((*pCopiesIter)->getPosition()),VCLSize((*pCopiesIter)->getSize())); @@ -609,7 +610,7 @@ void OReportSection::createDefault(const OUString& _sType,SdrObject* _pObj) { const SfxItemSet& rSource = pSourceObj->GetMergedItemSet(); SfxItemSet aDest( - _pObj->GetModel()->GetItemPool(), + _pObj->getSdrModelFromSdrObject().GetItemPool(), svl::Items< // Ranges from SdrAttrObj: SDRATTR_START, SDRATTR_SHADOW_LAST, diff --git a/reportdesign/source/ui/report/dlgedfunc.cxx b/reportdesign/source/ui/report/dlgedfunc.cxx index c66e3d00184d..0c465d1bb106 100644 --- a/reportdesign/source/ui/report/dlgedfunc.cxx +++ b/reportdesign/source/ui/report/dlgedfunc.cxx @@ -450,18 +450,15 @@ void DlgEdFunc::colorizeOverlappedObject(SdrObject* _pOverlappedObj) uno::Reference<report::XReportComponent> xComponent = pObj->getReportComponent(); if (xComponent.is() && xComponent != m_xOverlappingObj) { - OReportModel* pRptModel = static_cast<OReportModel*>(_pOverlappedObj->GetModel()); - if ( pRptModel ) - { - OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + OReportModel& rRptModel(static_cast< OReportModel& >(_pOverlappedObj->getSdrModelFromSdrObject())); + OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv()); - // uncolorize an old object, if there is one - unColorizeOverlappedObj(); + // uncolorize an old object, if there is one + unColorizeOverlappedObj(); - m_nOldColor = lcl_setColorOfObject(xComponent, m_nOverlappedControlColor); - m_xOverlappingObj = xComponent; - m_pOverlappingObj = _pOverlappedObj; - } + m_nOldColor = lcl_setColorOfObject(xComponent, m_nOverlappedControlColor); + m_xOverlappingObj = xComponent; + m_pOverlappingObj = _pOverlappedObj; } } } @@ -471,15 +468,12 @@ void DlgEdFunc::unColorizeOverlappedObj() // uncolorize an old object, if there is one if (m_xOverlappingObj.is()) { - OReportModel* pRptModel = static_cast<OReportModel*>(m_pOverlappingObj->GetModel()); - if ( pRptModel ) - { - OXUndoEnvironment::OUndoEnvLock aLock(pRptModel->GetUndoEnv()); + OReportModel& rRptModel(static_cast< OReportModel& >(m_pOverlappingObj->getSdrModelFromSdrObject())); + OXUndoEnvironment::OUndoEnvLock aLock(rRptModel.GetUndoEnv()); - lcl_setColorOfObject(m_xOverlappingObj, m_nOldColor); - m_xOverlappingObj = nullptr; - m_pOverlappingObj = nullptr; - } + lcl_setColorOfObject(m_xOverlappingObj, m_nOldColor); + m_xOverlappingObj = nullptr; + m_pOverlappingObj = nullptr; } } diff --git a/sc/inc/drawpage.hxx b/sc/inc/drawpage.hxx index 8f9348220172..0f6373f37d9f 100644 --- a/sc/inc/drawpage.hxx +++ b/sc/inc/drawpage.hxx @@ -24,7 +24,7 @@ class ScDrawLayer; -class ScDrawPage: public FmFormPage +class ScDrawPage : public FmFormPage { ScDrawPage& operator=(const ScDrawPage&) = delete; @@ -32,8 +32,8 @@ public: explicit ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage); virtual ~ScDrawPage() override; - virtual ScDrawPage* Clone() const override; - virtual ScDrawPage* Clone(SdrModel* pNewModel) const override; + // TTTT virtual ScDrawPage* Clone() const override; + virtual ScDrawPage* Clone(SdrModel* pNewModel = nullptr) const override; virtual css::uno::Reference< css::uno::XInterface > createUnoPage() override; diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx index 70b99bdf03e5..671d47278c33 100644 --- a/sc/source/core/data/documen9.cxx +++ b/sc/source/core/data/documen9.cxx @@ -84,11 +84,11 @@ void ScDocument::TransferDrawPage(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDes SdrObject* pOldObject = aIter.Next(); while (pOldObject) { - SdrObject* pNewObject = pOldObject->Clone(); + // TTTT clone to target SdrModel + SdrObject* pNewObject = pOldObject->Clone(mpDrawLayer); // SdrObject* pNewObject = pOldObject->Clone( pNewPage, mpDrawLayer ); - pNewObject->SetModel(mpDrawLayer); + // pNewObject->SetModel(mpDrawLayer); pNewObject->SetPage(pNewPage); - pNewObject->NbcMove(Size(0,0)); pNewPage->InsertObject( pNewObject ); diff --git a/sc/source/core/data/drawpage.cxx b/sc/source/core/data/drawpage.cxx index 831cc3a65715..eb5d51865c4e 100644 --- a/sc/source/core/data/drawpage.cxx +++ b/sc/source/core/data/drawpage.cxx @@ -39,10 +39,11 @@ ScDrawPage::~ScDrawPage() { } -ScDrawPage* ScDrawPage::Clone() const -{ - return Clone(nullptr); -} +// TTTT +// ScDrawPage* ScDrawPage::Clone() const +// { +// return Clone(nullptr); +// } ScDrawPage* ScDrawPage::Clone(SdrModel* const pNewModel) const { diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index e694fed7c25a..6a6d3cd5fb51 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -155,10 +155,10 @@ ScUndoAnchorData::~ScUndoAnchorData() void ScUndoAnchorData::Undo() { // Trigger Object Change - if (pObj->IsInserted() && pObj->GetPage() && pObj->GetModel()) + if (pObj->IsInserted() && pObj->GetPage()) { SdrHint aHint(SdrHintKind::ObjectChange, *pObj); - pObj->GetModel()->Broadcast(aHint); + pObj->getSdrModelFromSdrObject().Broadcast(aHint); } if (mbWasCellAnchored) @@ -175,10 +175,10 @@ void ScUndoAnchorData::Redo() ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *mpDoc, mnTab, mbWasResizeWithCell); // Trigger Object Change - if (pObj->IsInserted() && pObj->GetPage() && pObj->GetModel()) + if (pObj->IsInserted() && pObj->GetPage()) { SdrHint aHint(SdrHintKind::ObjectChange, *pObj); - pObj->GetModel()->Broadcast(aHint); + pObj->getSdrModelFromSdrObject().Broadcast(aHint); } } @@ -463,10 +463,11 @@ void ScDrawLayer::ScCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos ) pOldData->maStart.SetTab(nOldTab); pOldData->maEnd.SetTab(nOldTab); } - SdrObject* pNewObject = pOldObject->Clone(); - pNewObject->SetModel(this); - pNewObject->SetPage(pNewPage); + // TTTT clone to thatet SdrModel + SdrObject* pNewObject = pOldObject->Clone(this); + // pNewObject->SetModel(this); + pNewObject->SetPage(pNewPage); pNewObject->NbcMove(Size(0,0)); pNewPage->InsertObject( pNewObject ); ScDrawObjData* pNewData = GetObjData(pNewObject); @@ -1492,8 +1493,9 @@ void ScDrawLayer::CopyToClip( ScDocument* pClipDoc, SCTAB nTab, const tools::Rec OSL_ENSURE( pDestPage, "no page" ); if (pDestPage) { - SdrObject* pNewObject = pOldObject->Clone(); - pNewObject->SetModel(pDestModel); + // TTTT clone to target SdrModel + SdrObject* pNewObject = pOldObject->Clone(pDestModel); + // pNewObject->SetModel(pDestModel); pNewObject->SetPage(pDestPage); uno::Reference< chart2::XChartDocument > xOldChart( ScChartHelper::GetChartFromSdrObject( pOldObject ) ); @@ -1667,8 +1669,9 @@ void ScDrawLayer::CopyFromClip( ScDrawLayer* pClipModel, SCTAB nSourceTab, const if (bObjectInArea && (pOldObject->GetLayer() != SC_LAYER_INTERN) && !IsNoteCaption(pOldObject)) { - SdrObject* pNewObject = pOldObject->Clone(); - pNewObject->SetModel(this); + // TTTT clone to target SdrModel + SdrObject* pNewObject = pOldObject->Clone(this); + // pNewObject->SetModel(this); pNewObject->SetPage(pDestPage); if ( bMirrorObj ) diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index aa93fe7b8052..676a0dafb35a 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -758,7 +758,7 @@ void ScCaptionPtr::removeFromDrawPageAndFree( bool bIgnoreUndo ) bool bRecording = false; if (!bIgnoreUndo) { - ScDrawLayer* pDrawLayer = dynamic_cast<ScDrawLayer*>(mpCaption->GetModel()); + ScDrawLayer* pDrawLayer(dynamic_cast< ScDrawLayer* >(&mpCaption->getSdrModelFromSdrObject())); SAL_WARN_IF( !pDrawLayer, "sc.core", "ScCaptionPtr::removeFromDrawPageAndFree - object without drawing layer"); // create drawing undo action (before removing the object to have valid draw page in undo action) bRecording = (pDrawLayer && pDrawLayer->IsRecording()); @@ -1141,8 +1141,9 @@ void ScPostIt::RemoveCaption() /* Remove caption object only, if this note is its owner (e.g. notes in undo documents refer to captions in original document, do not remove them from drawing layer here). */ + // TTTT maybe no longer needed - can that still happen? ScDrawLayer* pDrawLayer = mrDoc.GetDrawLayer(); - if (pDrawLayer == maNoteData.mxCaption->GetModel()) + if (pDrawLayer == &maNoteData.mxCaption->getSdrModelFromSdrObject()) maNoteData.mxCaption.removeFromDrawPageAndFree(); SAL_INFO("sc.core","ScPostIt::RemoveCaption - refs: " << maNoteData.mxCaption.getRefs() << diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index 998abab1590c..b8d34a27785e 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -425,8 +425,14 @@ SdrObjectPtr XclImpDrawObjBase::CreateSdrObject( XclImpDffConverter& rDffConv, c else { xSdrObj = DoCreateSdrObj( rDffConv, rAnchorRect ); - if( xSdrObj ) - xSdrObj->SetModel( rDffConv.GetModel() ); + + // TTTT DoCreateSdrObj uses *GetDoc().GetDrawLayer() in most cases, + // also XclImpDffConverter::CreateSdrObject which uses + // XclImpTbxObjBase::CreateSdrObjectFromShape, so all creating aleady + // in the target SdrModel + // if( xSdrObj ) + // xSdrObj->SetModel( rDffConv.GetModel() ); + //added for exporting OCX control /* mnObjType value set should be as below table: 0x0000 Group 0x0001 Line diff --git a/sc/source/ui/drawfunc/fuconarc.cxx b/sc/source/ui/drawfunc/fuconarc.cxx index 7f89725a9e5e..d167649a5086 100644 --- a/sc/source/ui/drawfunc/fuconarc.cxx +++ b/sc/source/ui/drawfunc/fuconarc.cxx @@ -125,9 +125,7 @@ SdrObject* FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const tools::Re SdrObject* pObj = SdrObjFactory::MakeNewObject( *pDrDoc, pView->GetCurrentObjInventor(), - pView->GetCurrentObjIdentifier(), - nullptr, - pDrDoc); + pView->GetCurrentObjIdentifier()); if(pObj) { diff --git a/sc/source/ui/drawfunc/fuconcustomshape.cxx b/sc/source/ui/drawfunc/fuconcustomshape.cxx index df3c807a43e4..e028a4d1dcd3 100644 --- a/sc/source/ui/drawfunc/fuconcustomshape.cxx +++ b/sc/source/ui/drawfunc/fuconcustomshape.cxx @@ -134,9 +134,7 @@ SdrObject* FuConstCustomShape::CreateDefaultObject(const sal_uInt16 /* nID */, c SdrObject* pObj = SdrObjFactory::MakeNewObject( *pDrDoc, pView->GetCurrentObjInventor(), - pView->GetCurrentObjIdentifier(), - nullptr, - pDrDoc); + pView->GetCurrentObjIdentifier()); if( pObj ) { @@ -173,7 +171,7 @@ void FuConstCustomShape::SetAttributes( SdrObject* pObj ) { const SfxItemSet& rSource = pSourceObj->GetMergedItemSet(); SfxItemSet aDest( - pObj->GetModel()->GetItemPool(), + pObj->getSdrModelFromSdrObject().GetItemPool(), svl::Items< // Ranges from SdrAttrObj: SDRATTR_START, SDRATTR_SHADOW_LAST, diff --git a/sc/source/ui/drawfunc/fuconpol.cxx b/sc/source/ui/drawfunc/fuconpol.cxx index 809d245651c8..cc9ec052cea2 100644 --- a/sc/source/ui/drawfunc/fuconpol.cxx +++ b/sc/source/ui/drawfunc/fuconpol.cxx @@ -187,9 +187,7 @@ SdrObject* FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const tools SdrObject* pObj = SdrObjFactory::MakeNewObject( *pDrDoc, pView->GetCurrentObjInventor(), - pView->GetCurrentObjIdentifier(), - nullptr, - pDrDoc); + pView->GetCurrentObjIdentifier()); if(pObj) { diff --git a/sc/source/ui/drawfunc/fuconrec.cxx b/sc/source/ui/drawfunc/fuconrec.cxx index 67b2239fc5dd..79ccb4868160 100644 --- a/sc/source/ui/drawfunc/fuconrec.cxx +++ b/sc/source/ui/drawfunc/fuconrec.cxx @@ -58,10 +58,10 @@ FuConstRectangle::~FuConstRectangle() namespace { -::basegfx::B2DPolyPolygon getPolygon(const char* pResId, const SdrModel* pDoc) +::basegfx::B2DPolyPolygon getPolygon(const char* pResId, const SdrModel& rModel) { ::basegfx::B2DPolyPolygon aRetval; - XLineEndListRef pLineEndList = pDoc->GetLineEndList(); + XLineEndListRef pLineEndList(rModel.GetLineEndList()); if( pLineEndList.is() ) { @@ -116,7 +116,7 @@ bool FuConstRectangle::MouseButtonDown(const MouseEvent& rMEvt) if (pObj) { - SfxItemSet aAttr(pObj->GetModel()->GetItemPool()); + SfxItemSet aAttr(pObj->getSdrModelFromSdrObject().GetItemPool()); SetLineEnds(aAttr, pObj, aSfxRequest.GetSlot()); pObj->SetMergedItemSet(aAttr); } @@ -216,7 +216,7 @@ void FuConstRectangle::Activate() void FuConstRectangle::SetLineEnds(SfxItemSet& rAttr, const SdrObject* pObj, sal_uInt16 nSlotId) { - SdrModel *pDoc = pObj->GetModel(); + SdrModel& rModel(pObj->getSdrModelFromSdrObject()); // TTTT pObj shbe ref if ( nSlotId == SID_LINE_ARROW_START || nSlotId == SID_LINE_ARROW_END || @@ -230,7 +230,7 @@ void FuConstRectangle::SetLineEnds(SfxItemSet& rAttr, const SdrObject* pObj, sal // set attributes of line start and ends // arrowhead - ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, pDoc ) ); + ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, rModel ) ); if( !aArrow.count() ) { ::basegfx::B2DPolygon aNewArrow; @@ -242,7 +242,7 @@ void FuConstRectangle::SetLineEnds(SfxItemSet& rAttr, const SdrObject* pObj, sal } // Circles - ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, pDoc ) ); + ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, rModel ) ); if( !aCircle.count() ) { ::basegfx::B2DPolygon aNewCircle; @@ -252,7 +252,7 @@ void FuConstRectangle::SetLineEnds(SfxItemSet& rAttr, const SdrObject* pObj, sal } // Square - ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, pDoc ) ); + ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, rModel ) ); if( !aSquare.count() ) { ::basegfx::B2DPolygon aNewSquare; @@ -264,7 +264,7 @@ void FuConstRectangle::SetLineEnds(SfxItemSet& rAttr, const SdrObject* pObj, sal aSquare.append(aNewSquare); } - SfxItemSet aSet( pDoc->GetItemPool() ); + SfxItemSet aSet( rModel.GetItemPool() ); long nWidth = 200; // (1/100th mm) // determine line width and calculate with it the line end width @@ -358,9 +358,7 @@ SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const too SdrObject* pObj = SdrObjFactory::MakeNewObject( *pDrDoc, pView->GetCurrentObjInventor(), - pView->GetCurrentObjIdentifier(), - nullptr, - pDrDoc); + pView->GetCurrentObjIdentifier()); if(pObj) { diff --git a/sc/source/ui/drawfunc/fuconuno.cxx b/sc/source/ui/drawfunc/fuconuno.cxx index 3a505a2638d5..a3a141a8732e 100644 --- a/sc/source/ui/drawfunc/fuconuno.cxx +++ b/sc/source/ui/drawfunc/fuconuno.cxx @@ -113,9 +113,7 @@ SdrObject* FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, co SdrObject* pObj = SdrObjFactory::MakeNewObject( *pDrDoc, pView->GetCurrentObjInventor(), - pView->GetCurrentObjIdentifier(), - nullptr, - pDrDoc); + pView->GetCurrentObjIdentifier()); if(pObj) { diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx index b612f14fc6c9..cd04f02b7b3c 100644 --- a/sc/source/ui/drawfunc/fuins1.cxx +++ b/sc/source/ui/drawfunc/fuins1.cxx @@ -251,7 +251,7 @@ static void lcl_InsertMedia( const OUString& rMediaURL, bool bApi, *rData.GetDocument()->GetDrawLayer(), tools::Rectangle(aInsertPos, aSize)); - pObj->SetModel(rData.GetDocument()->GetDrawLayer()); // set before setURL + // TTTT pObj->SetModel(rData.GetDocument()->GetDrawLayer()); // set before setURL pObj->setURL( realURL, ""/*TODO?*/ ); pView->InsertObjectAtView( pObj, *pPV, bApi ? SdrInsertFlags::DONTMARK : SdrInsertFlags::NONE ); } diff --git a/sc/source/ui/drawfunc/futext.cxx b/sc/source/ui/drawfunc/futext.cxx index a6c70e19301b..7914c87a7313 100644 --- a/sc/source/ui/drawfunc/futext.cxx +++ b/sc/source/ui/drawfunc/futext.cxx @@ -645,9 +645,7 @@ SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectan SdrObject* pObj = SdrObjFactory::MakeNewObject( *pDrDoc, pView->GetCurrentObjInventor(), - pView->GetCurrentObjIdentifier(), - nullptr, - pDrDoc); + pView->GetCurrentObjIdentifier()); if(pObj) { diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx index a938851e26fb..8c590d64a90e 100644 --- a/sc/source/ui/unoobj/shapeuno.cxx +++ b/sc/source/ui/unoobj/shapeuno.cxx @@ -333,11 +333,13 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const SdrObject *pObj = GetSdrObject(); if (pObj) { - ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel()); - SdrPage* pPage = pObj->GetPage(); - if ( pModel && pPage ) + ScDrawLayer& rModel(static_cast< ScDrawLayer& >(pObj->getSdrModelFromSdrObject())); + SdrPage* pPage(pObj->GetPage()); + + if ( pPage ) { - ScDocument* pDoc = pModel->GetDocument(); + ScDocument* pDoc(rModel.GetDocument()); + if ( pDoc ) { SfxObjectShell* pObjSh = pDoc->GetDocumentShell(); @@ -346,7 +348,7 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh); SCTAB nTab = 0; - if ( lcl_GetPageNum( pPage, *pModel, nTab ) ) + if ( lcl_GetPageNum( pPage, rModel, nTab ) ) { table::CellRangeAddress aAddress = xRangeAdd->getRangeAddress(); if (nTab == aAddress.Sheet) @@ -463,14 +465,15 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const SdrObject *pObj = GetSdrObject(); if (pObj) { - ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel()); - SdrPage* pPage = pObj->GetPage(); - if ( pModel && pPage ) + ScDrawLayer& rModel(static_cast< ScDrawLayer& >(pObj->getSdrModelFromSdrObject())); + SdrPage* pPage(pObj->GetPage()); + + if ( pPage ) { SCTAB nTab = 0; - if ( lcl_GetPageNum( pPage, *pModel, nTab ) ) + if ( lcl_GetPageNum( pPage, rModel, nTab ) ) { - ScDocument* pDoc = pModel->GetDocument(); + ScDocument* pDoc = rModel.GetDocument(); if ( pDoc ) { SfxObjectShell* pObjSh = pDoc->GetDocumentShell(); @@ -561,14 +564,15 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const SdrObject *pObj = GetSdrObject(); if (pObj) { - ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel()); - SdrPage* pPage = pObj->GetPage(); - if ( pModel && pPage ) + ScDrawLayer& rModel(static_cast< ScDrawLayer& >(pObj->getSdrModelFromSdrObject())); + SdrPage* pPage(pObj->GetPage()); + + if ( pPage ) { SCTAB nTab = 0; - if ( lcl_GetPageNum( pPage, *pModel, nTab ) ) + if ( lcl_GetPageNum( pPage, rModel, nTab ) ) { - ScDocument* pDoc = pModel->GetDocument(); + ScDocument* pDoc = rModel.GetDocument(); if ( pDoc ) { SfxObjectShell* pObjSh = pDoc->GetDocumentShell(); @@ -657,15 +661,16 @@ uno::Any SAL_CALL ScShapeObj::getPropertyValue( const OUString& aPropertyName ) SdrObject *pObj = GetSdrObject(); if (pObj) { - ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel()); - SdrPage* pPage = pObj->GetPage(); - if ( pModel && pPage ) + ScDrawLayer& rModel(static_cast< ScDrawLayer& >(pObj->getSdrModelFromSdrObject())); + SdrPage* pPage(pObj->GetPage()); + + if ( pPage ) { - ScDocument* pDoc = pModel->GetDocument(); + ScDocument* pDoc = rModel.GetDocument(); if ( pDoc ) { SCTAB nTab = 0; - if ( lcl_GetPageNum( pPage, *pModel, nTab ) ) + if ( lcl_GetPageNum( pPage, rModel, nTab ) ) { SfxObjectShell* pObjSh = pDoc->GetDocumentShell(); if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) != nullptr ) @@ -705,15 +710,16 @@ uno::Any SAL_CALL ScShapeObj::getPropertyValue( const OUString& aPropertyName ) SdrObject *pObj = GetSdrObject(); if (pObj) { - ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel()); - SdrPage* pPage = pObj->GetPage(); - if ( pModel && pPage ) + ScDrawLayer& rModel(static_cast< ScDrawLayer& >(pObj->getSdrModelFromSdrObject())); + SdrPage* pPage(pObj->GetPage()); + + if ( pPage ) { - ScDocument* pDoc = pModel->GetDocument(); + ScDocument* pDoc = rModel.GetDocument(); if ( pDoc ) { SCTAB nTab = 0; - if ( lcl_GetPageNum( pPage, *pModel, nTab ) ) + if ( lcl_GetPageNum( pPage, rModel, nTab ) ) { uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY ); if (xShape.is()) @@ -764,15 +770,16 @@ uno::Any SAL_CALL ScShapeObj::getPropertyValue( const OUString& aPropertyName ) SdrObject *pObj = GetSdrObject(); if (pObj) { - ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel()); - SdrPage* pPage = pObj->GetPage(); - if ( pModel && pPage ) + ScDrawLayer& rModel(static_cast< ScDrawLayer& >(pObj->getSdrModelFromSdrObject())); + SdrPage* pPage(pObj->GetPage()); + + if ( pPage ) { - ScDocument* pDoc = pModel->GetDocument(); + ScDocument* pDoc = rModel.GetDocument(); if ( pDoc ) { SCTAB nTab = 0; - if ( lcl_GetPageNum( pPage, *pModel, nTab ) ) + if ( lcl_GetPageNum( pPage, rModel, nTab ) ) { uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY ); if (xShape.is()) @@ -997,28 +1004,26 @@ uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getAnchor() SdrObject* pObj = GetSdrObject(); if( pObj ) { - ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel()); - SdrPage* pPage = pObj->GetPage(); - if ( pModel ) + ScDrawLayer& rModel(static_cast< ScDrawLayer& >(pObj->getSdrModelFromSdrObject())); + SdrPage* pPage(pObj->GetPage()); + ScDocument* pDoc = rModel.GetDocument(); + + if ( pPage && pDoc ) { - ScDocument* pDoc = pModel->GetDocument(); - if ( pDoc ) + SfxObjectShell* pObjSh = pDoc->GetDocumentShell(); + if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) != nullptr ) { - SfxObjectShell* pObjSh = pDoc->GetDocumentShell(); - if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) != nullptr ) - { - ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh); + ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh); - SCTAB nTab = 0; - if ( lcl_GetPageNum( pPage, *pModel, nTab ) ) - { - Point aPos(pObj->GetCurrentBoundRect().TopLeft()); - ScRange aRange(pDoc->GetRange( nTab, tools::Rectangle( aPos, aPos ) )); + SCTAB nTab = 0; + if ( lcl_GetPageNum( pPage, rModel, nTab ) ) + { + Point aPos(pObj->GetCurrentBoundRect().TopLeft()); + ScRange aRange(pDoc->GetRange( nTab, tools::Rectangle( aPos, aPos ) )); - // anchor is always the cell + // anchor is always the cell - xRet.set(new ScCellObj( pDocSh, aRange.aStart )); - } + xRet.set(new ScCellObj( pDocSh, aRange.aStart )); } } } @@ -1242,25 +1247,23 @@ uno::Reference< uno::XInterface > SAL_CALL ScShapeObj::getParent() SdrObject* pObj = GetSdrObject(); if( pObj ) { - ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel()); - SdrPage* pPage = pObj->GetPage(); - if ( pModel ) + ScDrawLayer& rModel(static_cast< ScDrawLayer& >(pObj->getSdrModelFromSdrObject())); + SdrPage* pPage(pObj->GetPage()); + ScDocument* pDoc = rModel.GetDocument(); + + if ( pPage && pDoc ) { - ScDocument* pDoc = pModel->GetDocument(); - if ( pDoc ) + SfxObjectShell* pObjSh = pDoc->GetDocumentShell(); + if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) != nullptr ) { - SfxObjectShell* pObjSh = pDoc->GetDocumentShell(); - if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) != nullptr ) - { - ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh); + ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh); - SCTAB nTab = 0; - if ( lcl_GetPageNum( pPage, *pModel, nTab ) ) - { - const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, nTab ); - if( pCaptData ) - return static_cast< ::cppu::OWeakObject* >( new ScCellObj( pDocSh, pCaptData->maStart ) ); - } + SCTAB nTab = 0; + if ( lcl_GetPageNum( pPage, rModel, nTab ) ) + { + const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, nTab ); + if( pCaptData ) + return static_cast< ::cppu::OWeakObject* >( new ScCellObj( pDocSh, pCaptData->maStart ) ); } } } diff --git a/sc/source/ui/view/tabvwshg.cxx b/sc/source/ui/view/tabvwshg.cxx index 285894bc2b73..d081c875c4cb 100644 --- a/sc/source/ui/view/tabvwshg.cxx +++ b/sc/source/ui/view/tabvwshg.cxx @@ -64,8 +64,7 @@ void ScTabViewShell::InsertURLButton( const OUString& rName, const OUString& rUR *pModel, SdrInventor::FmForm, OBJ_FM_BUTTON, - pDrView->GetSdrPageView()->GetPage(), - pModel); + pDrView->GetSdrPageView()->GetPage()); SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( pObj ); OSL_ENSURE( pUnoCtrl, "no SdrUnoObj"); if( !pUnoCtrl ) diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx index 1a87f9fc05f8..20bb7bca7060 100644 --- a/sc/source/ui/view/viewfun7.cxx +++ b/sc/source/ui/view/viewfun7.cxx @@ -153,11 +153,12 @@ void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel, const SdrMark* pM=aMark.GetMark(nm); const SdrObject* pObj=pM->GetMarkedSdrObj(); - SdrObject* pNewObj=pObj->Clone(); + // TTTT directly clone to taget SdrModel + SdrObject* pNewObj(pObj->Clone(pDrawModel)); if (pNewObj!=nullptr) { - pNewObj->SetModel(pDrawModel); + // pNewObj->SetModel(pDrawModel); pNewObj->SetPage(pDestPage); // copy graphics within the same model - always needs new name diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx index 42af131102c0..a3f51d8a516f 100644 --- a/sd/inc/sdpage.hxx +++ b/sd/inc/sdpage.hxx @@ -154,8 +154,10 @@ public: SdPage(SdDrawDocument& rNewDoc, bool bMasterPage); virtual ~SdPage() override; - virtual SdrPage* Clone() const override; - virtual SdrPage* Clone(SdrModel* pNewModel) const override; + + // TTTT + // virtual SdrPage* Clone() const override; + virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const override; virtual void SetSize(const Size& aSize) override; virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, sal_Int32 Lwr) override; @@ -163,7 +165,10 @@ public: virtual void SetRightBorder(sal_Int32 nBorder) override; virtual void SetUpperBorder(sal_Int32 nBorder) override; virtual void SetLowerBorder(sal_Int32 nBorder) override; - virtual void SetModel(SdrModel* pNewModel) override; + + // TTTT + // virtual void SetModel(SdrModel* pNewModel) override; + virtual bool IsReadOnly() const override; sd::ShapeList& GetPresentationShapeList() { return maPresentationShapeList; } diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index d6335e3671d3..a2f76ab0a6ec 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -659,17 +659,18 @@ void SdDrawDocument::NewOrLoadCompleted(DocCreationMode eMode) mbNewOrLoadCompleted = true; // Update all linked pages - sal_uInt16 nMaxSdPages = GetSdPageCount(PageKind::Standard); - - for (sal_uInt16 nSdPage=0; nSdPage < nMaxSdPages; nSdPage++) - { - SdPage* pPage = GetSdPage(nSdPage, PageKind::Standard); - - if (pPage && !pPage->GetFileName().isEmpty() && pPage->GetBookmarkName().getLength()) - { - pPage->SetModel(this); - } - } + // TTTT SdrPage s should already be constructed with *this as SdrModel + // sal_uInt16 nMaxSdPages = GetSdPageCount(PageKind::Standard); + + // for (sal_uInt16 nSdPage=0; nSdPage < nMaxSdPages; nSdPage++) + // { + // SdPage* pPage = GetSdPage(nSdPage, PageKind::Standard); + + // if (pPage && !pPage->GetFileName().isEmpty() && pPage->GetBookmarkName().getLength()) + // { + // pPage->SetModel(this); + // } + // } UpdateAllLinks(); diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx index 9bc68bc98710..e9793dd708a3 100644 --- a/sd/source/core/drawdoc3.cxx +++ b/sd/source/core/drawdoc3.cxx @@ -608,7 +608,9 @@ bool SdDrawDocument::InsertBookmarkAsPage( // Assemble all link names pPage->SetFileName(aBookmarkName); pPage->SetBookmarkName(aName); - pPage->SetModel(this); + + // TTTT ::Merge above already has Clone'd to *this + // pPage->SetModel(this); } nActualInsertPos += 2; @@ -705,7 +707,9 @@ bool SdDrawDocument::InsertBookmarkAsPage( SdPage* pPage = static_cast<SdPage*>( GetPage(nActualInsertPos) ); pPage->SetFileName(aBookmarkName); pPage->SetBookmarkName(aPgName); - pPage->SetModel(this); + + // TTTT ::Merge above already has Clone'd to *this + // pPage->SetModel(this); } if (bReplace) diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx index 61fd29db97f7..0a0aaeb0f223 100644 --- a/sd/source/core/sdpage2.cxx +++ b/sd/source/core/sdpage2.cxx @@ -286,15 +286,16 @@ void SdPage::EndListenOutlineText() |* \************************************************************************/ -void SdPage::SetModel(SdrModel* pNewModel) -{ - DisconnectLink(); +// TTTT +// void SdPage::SetModel(SdrModel* pNewModel) +// { +// DisconnectLink(); - // assign model - FmFormPage::SetModel(pNewModel); +// // assign model +// FmFormPage::SetModel(pNewModel); - ConnectLink(); -} +// ConnectLink(); +// } /************************************************************************* |* @@ -426,10 +427,11 @@ void SdPage::lateInit(const SdPage& rSrcPage) |* \************************************************************************/ -SdrPage* SdPage::Clone() const -{ - return Clone(nullptr); -} +// TTTT +// SdrPage* SdPage::Clone() const +// { +// return Clone(nullptr); +// } SdrPage* SdPage::Clone(SdrModel* pNewModel) const { diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx index 56eed187444d..056b2924a6ba 100644 --- a/sd/source/filter/ppt/pptin.cxx +++ b/sd/source/filter/ppt/pptin.cxx @@ -2691,7 +2691,6 @@ SdrObject* ImplSdPPTImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi SdrMediaObj* pMediaObj = new SdrMediaObj( pObj->getSdrModelFromSdrObject(), pObj->GetSnapRect()); - pMediaObj->SetModel( pObj->GetModel() ); pMediaObj->SetMergedItemSet( pObj->GetMergedItemSet() ); //--remove object from maAnimations list and add the new object instead diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx index e9d185c58758..37a862294b29 100644 --- a/sd/source/ui/app/sdmod2.cxx +++ b/sd/source/ui/app/sdmod2.cxx @@ -160,7 +160,7 @@ IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo, void) const SdrTextObj* pTextObj = pSdrOutliner->GetTextObj(); if( pTextObj ) - pDoc = dynamic_cast< SdDrawDocument* >( pTextObj->GetModel() ); + pDoc = dynamic_cast< SdDrawDocument* >( &pTextObj->getSdrModelFromSdrObject() ); if( pDoc ) pDocShell = pDoc->GetDocSh(); diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx index 5eea85808f02..deddf8b68a53 100644 --- a/sd/source/ui/dlg/animobjs.cxx +++ b/sd/source/ui/dlg/animobjs.cxx @@ -781,7 +781,8 @@ void AnimationWindow::AddObj (::sd::View& rView ) BitmapEx *const pBitmapEx = new BitmapEx( SdrExchangeView::GetObjGraphic( - pSnapShot->GetModel(), pSnapShot).GetBitmapEx() ); + &pSnapShot->getSdrModelFromSdrObject(), + pSnapShot).GetBitmapEx() ); ::tools::Time* pTime = new ::tools::Time( m_pTimeField->GetTime() ); size_t nIndex = m_nCurrentFrame + 1; @@ -834,7 +835,8 @@ void AnimationWindow::AddObj (::sd::View& rView ) BitmapEx *const pBitmapEx = new BitmapEx( SdrExchangeView::GetObjGraphic( - pObject->GetModel(), pObject).GetBitmapEx() ); + &pObject->getSdrModelFromSdrObject(), + pObject).GetBitmapEx() ); ::tools::Time* pTime = new ::tools::Time( m_pTimeField->GetTime() ); diff --git a/sd/source/ui/func/fucon3d.cxx b/sd/source/ui/func/fucon3d.cxx index f56f0a6fab2d..f74db13144eb 100644 --- a/sd/source/ui/func/fucon3d.cxx +++ b/sd/source/ui/func/fucon3d.cxx @@ -393,7 +393,7 @@ SdrObject* FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID, const double fW(aVolume.getWidth()); double fH(aVolume.getHeight()); ::tools::Rectangle a3DRect(0, 0, static_cast<long>(fW), static_cast<long>(fH)); - E3dScene* pScene = new E3dScene(mpView->getSdrModelFromSdrView()); + E3dScene* pScene = new E3dScene(*mpDoc); // copied code from E3dView::InitScene double fCamZ(aVolume.getMaxZ() + ((fW + fH) / 4.0)); @@ -407,13 +407,9 @@ SdrObject* FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID, const aCam.SetFocalLength(mpView->GetDefaultCamFocal()); aCam.SetDefaults(::basegfx::B3DPoint(0.0, 0.0, fDefaultCamPosZ), aLookAt); pScene->SetCamera(aCam); - pScene->Insert3DObj(p3DObj); pScene->NbcSetSnapRect(a3DRect); - pScene->SetModel(mpDoc); - ImpPrepareBasic3DShape(p3DObj, pScene); - SfxItemSet aAttr(mpDoc->GetPool()); SetStyleSheet(aAttr, p3DObj); aAttr.Put(XLineStyleItem (drawing::LineStyle_NONE)); diff --git a/sd/source/ui/func/fuconarc.cxx b/sd/source/ui/func/fuconarc.cxx index 83facbfd2efc..6967a1495017 100644 --- a/sd/source/ui/func/fuconarc.cxx +++ b/sd/source/ui/func/fuconarc.cxx @@ -206,9 +206,7 @@ SdrObject* FuConstructArc::CreateDefaultObject(const sal_uInt16 nID, const ::too SdrObject* pObj = SdrObjFactory::MakeNewObject( mpView->getSdrModelFromSdrView(), mpView->GetCurrentObjInventor(), - mpView->GetCurrentObjIdentifier(), - nullptr, - mpDoc); + mpView->GetCurrentObjIdentifier()); if(pObj) { diff --git a/sd/source/ui/func/fuconbez.cxx b/sd/source/ui/func/fuconbez.cxx index 5b72ff9b0d1f..cad7080afd6b 100644 --- a/sd/source/ui/func/fuconbez.cxx +++ b/sd/source/ui/func/fuconbez.cxx @@ -311,9 +311,7 @@ SdrObject* FuConstructBezierPolygon::CreateDefaultObject(const sal_uInt16 nID, c SdrObject* pObj = SdrObjFactory::MakeNewObject( mpView->getSdrModelFromSdrView(), mpView->GetCurrentObjInventor(), - mpView->GetCurrentObjIdentifier(), - nullptr, - mpDoc); + mpView->GetCurrentObjIdentifier()); if(pObj) { diff --git a/sd/source/ui/func/fuconcs.cxx b/sd/source/ui/func/fuconcs.cxx index a70af6b8bb40..97a60a302c11 100644 --- a/sd/source/ui/func/fuconcs.cxx +++ b/sd/source/ui/func/fuconcs.cxx @@ -188,7 +188,7 @@ void FuConstructCustomShape::SetAttributes( SdrObject* pObj ) { const SfxItemSet& rSource = pSourceObj->GetMergedItemSet(); SfxItemSet aDest( - pObj->GetModel()->GetItemPool(), + pObj->getSdrModelFromSdrObject().GetItemPool(), svl::Items< // Ranges from SdrAttrObj: SDRATTR_START, SDRATTR_SHADOW_LAST, @@ -238,8 +238,7 @@ SdrObject* FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const : SdrObject* pObj = SdrObjFactory::MakeNewObject( mpView->getSdrModelFromSdrView(), mpView->GetCurrentObjInventor(), - mpView->GetCurrentObjIdentifier(), - nullptr, mpDoc); + mpView->GetCurrentObjIdentifier()); if( pObj ) { diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx index 8cf49d7b69d0..4785d5392e7b 100644 --- a/sd/source/ui/func/fuconrec.cxx +++ b/sd/source/ui/func/fuconrec.cxx @@ -501,10 +501,10 @@ void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj) /** * set line starts and ends for the object to be created */ -::basegfx::B2DPolyPolygon getPolygon(const char* pResId, SdrModel const * pDoc) +::basegfx::B2DPolyPolygon getPolygon(const char* pResId, const SdrModel& rModel) { ::basegfx::B2DPolyPolygon aRetval; - XLineEndListRef pLineEndList = pDoc->GetLineEndList(); + XLineEndListRef pLineEndList(rModel.GetLineEndList()); if( pLineEndList.is() ) { @@ -541,9 +541,10 @@ void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const * pObj nSlotId == SID_LINE_SQUARE_ARROW ) { // set attributes of line start and ends + SdrModel& rModel(pObj->getSdrModelFromSdrObject()); // TTTT pObj shbe ref // arrowhead - ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, mpDoc ) ); + ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, rModel ) ); if( !aArrow.count() ) { ::basegfx::B2DPolygon aNewArrow; @@ -555,7 +556,7 @@ void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const * pObj } // Circles - ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, mpDoc ) ); + ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, rModel ) ); if( !aCircle.count() ) { ::basegfx::B2DPolygon aNewCircle; @@ -565,7 +566,7 @@ void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const * pObj } // Square - ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, mpDoc ) ); + ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, rModel ) ); if( !aSquare.count() ) { ::basegfx::B2DPolygon aNewSquare; @@ -771,8 +772,7 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const SdrObject* pObj = SdrObjFactory::MakeNewObject( mpView->getSdrModelFromSdrView(), mpView->GetCurrentObjInventor(), - mpView->GetCurrentObjIdentifier(), - nullptr, mpDoc); + mpView->GetCurrentObjIdentifier()); if(pObj) { diff --git a/sd/source/ui/func/fuconuno.cxx b/sd/source/ui/func/fuconuno.cxx index bec0857e4813..8ff99fdb7e00 100644 --- a/sd/source/ui/func/fuconuno.cxx +++ b/sd/source/ui/func/fuconuno.cxx @@ -140,8 +140,7 @@ SdrObject* FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const :: SdrObject* pObj = SdrObjFactory::MakeNewObject( mpView->getSdrModelFromSdrView(), mpView->GetCurrentObjInventor(), - mpView->GetCurrentObjIdentifier(), - nullptr, mpDoc); + mpView->GetCurrentObjIdentifier()); if(pObj) { diff --git a/sd/source/ui/func/futext.cxx b/sd/source/ui/func/futext.cxx index 78f01f6bd77f..b6d81901f870 100644 --- a/sd/source/ui/func/futext.cxx +++ b/sd/source/ui/func/futext.cxx @@ -691,7 +691,7 @@ bool FuText::MouseButtonUp(const MouseEvent& rMEvt) // outliner object up to now; also it needs to be set back to not // vertical when there was a vertical one used last time. OutlinerParaObject* pOPO = GetTextObj()->GetOutlinerParaObject(); - SdrOutliner& rOutl = mxTextObj->GetModel()->GetDrawOutliner(GetTextObj()); + SdrOutliner& rOutl(mxTextObj->getSdrModelFromSdrObject().GetDrawOutliner(GetTextObj())); bool bVertical((pOPO && pOPO->IsVertical()) || nSlotId == SID_ATTR_CHAR_VERTICAL || nSlotId == SID_TEXT_FITTOSIZE_VERTICAL); @@ -1308,8 +1308,7 @@ SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rect mpView->getSdrModelFromSdrView(), mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(), - nullptr, - mpDoc); + nullptr); if(pObj) { diff --git a/sd/source/ui/func/unoaprms.cxx b/sd/source/ui/func/unoaprms.cxx index 021dc5ba7a02..ab46b90ac8ee 100644 --- a/sd/source/ui/func/unoaprms.cxx +++ b/sd/source/ui/func/unoaprms.cxx @@ -27,7 +27,7 @@ void SdAnimationPrmsUndoAction::Undo() // no new info created: restore data if (!bInfoCreated) { - SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(pObject->GetModel()); + SdDrawDocument* pDoc(dynamic_cast< SdDrawDocument* >(&pObject->getSdrModelFromSdrObject())); if( pDoc ) { SdAnimationInfo* pInfo = SdDrawDocument::GetAnimationInfo( pObject ); diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index 0709c07d5db3..8b69d3616037 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -1541,8 +1541,7 @@ void DrawViewShell::InsertURLButton(const OUString& rURL, const OUString& rText, GetView()->getSdrModelFromSdrView(), SdrInventor::FmForm, OBJ_FM_BUTTON, - mpDrawView->GetSdrPageView()->GetPage(), - GetDoc())); + mpDrawView->GetSdrPageView()->GetPage())); Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_QUERY_THROW ); Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW ); diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index d9e0418a43d5..7bff93080e61 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -659,7 +659,7 @@ bool View::SdrBeginTextEdit( EventMultiplexerEventId::BeginTextEdit, static_cast<void*>(pObj) ); if( pOutl==nullptr && pObj ) - pOutl = SdrMakeOutliner(OutlinerMode::TextObject, *pObj->GetModel()); + pOutl = SdrMakeOutliner(OutlinerMode::TextObject, pObj->getSdrModelFromSdrObject()); // make draw&impress specific initialisations if( pOutl ) diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx index d36ccbb75528..cf6f72870045 100644 --- a/sd/source/ui/view/sdview3.cxx +++ b/sd/source/ui/view/sdview3.cxx @@ -797,7 +797,11 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper, aNewSet.Put( pObj->GetMergedItemSet() ); if( bUndo ) - AddUndo( new E3dAttributesUndoAction( mrDoc, static_cast<E3dObject*>(pPickObj), aNewSet, aOldSet ) ); + AddUndo( + new E3dAttributesUndoAction( + *static_cast< E3dObject* >(pPickObj), + aNewSet, + aOldSet)); pPickObj->SetMergedItemSetAndBroadcast( aNewSet ); } 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/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/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx index 4a95f2c7d850..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()); diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index dd9b1b800737..753d43c3a0c7 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -183,9 +183,7 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( SdrObject* pTextObj = SdrObjFactory::MakeNewObject( rSdrObjCustomShape.getSdrModelFromSdrObject(), rSdrObjCustomShape.GetObjInventor(), - OBJ_TEXT, - nullptr, - rSdrObjCustomShape.GetModel()); + OBJ_TEXT); // Copy text content OutlinerParaObject* pParaObj(rSdrObjCustomShape.GetOutlinerParaObject()); @@ -254,7 +252,6 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( } pRenderedShape->SetPage(rSdrObjCustomShape.GetPage()); - pRenderedShape->SetModel(rSdrObjCustomShape.GetModel()); } } @@ -392,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/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index 1bf7206ef826..7e2ffb67c0e3 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -1469,13 +1469,8 @@ SvxXLinePreview::SvxXLinePreview(vcl::Window* pParent) InitSettings( true, true ); mpLineObjA = new SdrPathObj(getModel(), OBJ_LINE); - mpLineObjA->SetModel(&getModel()); - mpLineObjB = new SdrPathObj(getModel(), OBJ_PLIN); - mpLineObjB->SetModel(&getModel()); - mpLineObjC = new SdrPathObj(getModel(), OBJ_PLIN); - mpLineObjC->SetModel(&getModel()); } VCL_BUILDER_FACTORY(SvxXLinePreview) @@ -1573,7 +1568,6 @@ SvxXRectPreview::SvxXRectPreview(vcl::Window* pParent) mpRectangleObject = new SdrRectObj( getModel(), aObjectSize); - mpRectangleObject->SetModel(&getModel()); } void SvxXRectPreview::Resize() @@ -1585,7 +1579,6 @@ void SvxXRectPreview::Resize() mpRectangleObject = new SdrRectObj( getModel(), aObjectSize); - mpRectangleObject->SetModel(&getModel()); SetAttributes(pOrigObject->GetMergedItemSet()); SdrObject::Free(pOrigObject); } @@ -1644,14 +1637,12 @@ SvxXShadowPreview::SvxXShadowPreview( vcl::Window* pParent ) mpRectangleObject = new SdrRectObj( getModel(), aObjectSize); - mpRectangleObject->SetModel(&getModel()); // create ShadowObject const tools::Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize ); mpRectangleShadow = new SdrRectObj( getModel(), aShadowSize); - mpRectangleShadow->SetModel(&getModel()); } VCL_BUILDER_FACTORY(SvxXShadowPreview) diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx index f1624b184f92..557bbb005a95 100644 --- a/svx/source/dialog/imapwnd.cxx +++ b/svx/source/dialog/imapwnd.cxx @@ -767,9 +767,7 @@ void IMapWindow::CreateDefaultObject() SdrObject* pObj = SdrObjFactory::MakeNewObject( *pModel, pView->GetCurrentObjInventor(), - pView->GetCurrentObjIdentifier(), - nullptr, - pModel); + pView->GetCurrentObjIdentifier()); pObj->SetLogicRect(aNewObjectRectangle); switch( pObj->GetObjIdentifier() ) diff --git a/svx/source/dialog/measctrl.cxx b/svx/source/dialog/measctrl.cxx index 29a1d4948ac5..03e630041189 100644 --- a/svx/source/dialog/measctrl.cxx +++ b/svx/source/dialog/measctrl.cxx @@ -47,7 +47,6 @@ SvxXMeasurePreview::SvxXMeasurePreview(vcl::Window* pParent, WinBits nStyle) *pModel, aPt1, aPt2); - pMeasureObj->SetModel(pModel); 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 b2dac7462808..509688fe2f77 100644 --- a/svx/source/engine3d/cube3d.cxx +++ b/svx/source/engine3d/cube3d.cxx @@ -78,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 >(); + return CloneHelper< E3dCubeObj >(pTargetModel); +} + +E3dCubeObj& E3dCubeObj::operator=(const E3dCubeObj& rObj) +{ + 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 b79954629114..0a929970e50e 100644 --- a/svx/source/engine3d/extrud3d.cxx +++ b/svx/source/engine3d/extrud3d.cxx @@ -53,7 +53,7 @@ sdr::properties::BaseProperties* E3dExtrudeObj::CreateObjectSpecificProperties() // surfaces rectangles from the passed PolyPolygon E3dExtrudeObj::E3dExtrudeObj( SdrModel& rSdrModel, - const E3dDefaultAttributes const& rDefault, + const E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon& rPP, double fDepth) : E3dCompoundObject(rSdrModel), @@ -98,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 diff --git a/svx/source/engine3d/lathe3d.cxx b/svx/source/engine3d/lathe3d.cxx index 0bc772ec1670..74097eb29f63 100644 --- a/svx/source/engine3d/lathe3d.cxx +++ b/svx/source/engine3d/lathe3d.cxx @@ -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 diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx index 18c2bb382536..a149871c4e81 100644 --- a/svx/source/engine3d/obj3d.cxx +++ b/svx/source/engine3d/obj3d.cxx @@ -304,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 @@ -657,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) @@ -881,9 +874,20 @@ void E3dCompoundObject::RecalcSnapRect() } } -E3dCompoundObject* E3dCompoundObject::Clone() const +E3dCompoundObject* E3dCompoundObject::Clone(SdrModel* pTargetModel) const +{ + return CloneHelper< E3dCompoundObject >(pTargetModel); +} + +E3dCompoundObject& E3dCompoundObject::operator=(const E3dCompoundObject& rObj) { - return CloneHelper< E3dCompoundObject >(); + 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/polygn3d.cxx b/svx/source/engine3d/polygn3d.cxx index 9c5db2c26d28..bcb9ba81b9eb 100644 --- a/svx/source/engine3d/polygn3d.cxx +++ b/svx/source/engine3d/polygn3d.cxx @@ -218,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 007d5db413b2..38961d3ccfa8 100644 --- a/svx/source/engine3d/scene3d.cxx +++ b/svx/source/engine3d/scene3d.cxx @@ -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 805ce06c48dd..75670c2e28d7 100644 --- a/svx/source/engine3d/sphere3d.cxx +++ b/svx/source/engine3d/sphere3d.cxx @@ -87,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 >(); + return CloneHelper< E3dSphereObj >(pTargetModel); +} + +E3dSphereObj& E3dSphereObj::operator=(const E3dSphereObj& rObj) +{ + 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 831c029edff5..31d6c36bb44c 100644 --- a/svx/source/engine3d/view3d.cxx +++ b/svx/source/engine3d/view3d.cxx @@ -581,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); diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx index 0c580ac77ae6..e68f30690039 100644 --- a/svx/source/form/fmobj.cxx +++ b/svx/source/form/fmobj.cxx @@ -104,7 +104,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; @@ -356,9 +356,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); @@ -367,13 +367,6 @@ FmFormObj* FmFormObj::Clone() const } -void FmFormObj::NbcReformatText() -{ - impl_checkRefDevice_nothrow(); - SdrUnoObj::NbcReformatText(); -} - - FmFormObj& FmFormObj::operator= (const FmFormObj& rObj) { if( this == &rObj ) @@ -400,6 +393,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,11 +584,12 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > } -void FmFormObj::SetModel( SdrModel* _pNewModel ) -{ - SdrUnoObj::SetModel( _pNewModel ); - impl_checkRefDevice_nothrow(); -} +// TTTT needed? +// void FmFormObj::SetModel( SdrModel* _pNewModel ) +// { +// SdrUnoObj::SetModel( _pNewModel ); +// impl_checkRefDevice_nothrow(); +// } FmFormObj* FmFormObj::GetFormObject( SdrObject* _pSdrObject ) diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx index ae6c45b1d980..9d2b166eea24 100644 --- a/svx/source/form/fmpage.cxx +++ b/svx/source/form/fmpage.cxx @@ -74,45 +74,45 @@ 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); -} +// TTTT +// 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" ); +// } +// } +// } + +// TTTT +// SdrPage* FmFormPage::Clone() const +// { +// return Clone(nullptr); +// } SdrPage* FmFormPage::Clone(SdrModel* const pNewModel) const { diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index c2d7b2471d15..30dd8add1b1d 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -1480,8 +1480,7 @@ SdrObject* FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_ SdrObjFactory::MakeNewObject( getView()->getSdrModelFromSdrView(), SdrInventor::FmForm, - nObjID, - nullptr)); + 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 ) ); @@ -1589,8 +1588,7 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int *_pModel, _nInventor, _nLabelObjectID, - _pLabelPage, - _pModel))); + _pLabelPage))); OSL_ENSURE( pLabel.get(), "FmXFormView::createControlLabelPair: could not create the label!" ); @@ -1623,8 +1621,7 @@ bool FmXFormView::createControlLabelPair( OutputDevice const & _rOutDev, sal_Int *_pModel, _nInventor, _nControlObjectID, - _pControlPage, - _pModel))); + _pControlPage))); OSL_ENSURE( pControl.get(), "FmXFormView::createControlLabelPair: could not create the control!" ); diff --git a/svx/source/inc/cell.hxx b/svx/source/inc/cell.hxx index 5b7f71b04c89..a8da63251743 100644 --- a/svx/source/inc/cell.hxx +++ b/svx/source/inc/cell.hxx @@ -91,7 +91,8 @@ public: SVX_DLLPRIVATE SdrTextVertAdjust GetTextVerticalAdjust() const; SdrTextHorzAdjust GetTextHorizontalAdjust() const; - SVX_DLLPRIVATE virtual void SetModel(SdrModel* pNewModel) override; + // TTTT + // 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 ); diff --git a/svx/source/inc/fmobj.hxx b/svx/source/inc/fmobj.hxx index 5cc7050f3fb6..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; @@ -73,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..af8f6b445f1e 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 ref? bool mbModified; bool mbNotifyPending; diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx index b629d0c39b9c..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 @@ -254,7 +254,6 @@ namespace sdr // create temp RectObj as TextObj and set needed attributes SdrRectObj aRectObj(GetGrafObject().getSdrModelFromSdrObject(), OBJ_TEXT); - aRectObj.SetModel(GetGrafObject().GetModel()); 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..0369cde231d6 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->getSdrModelFromSdrObjList().getHandoutPageCount(); } else { - const sal_uInt16 nPageCount(pPage->GetModel()->GetPageCount()); + const sal_uInt16 nPageCount(pPage->getSdrModelFromSdrObjList().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..a67dc8000bd3 100644 --- a/svx/source/sdr/properties/attributeproperties.cxx +++ b/svx/source/sdr/properties/attributeproperties.cxx @@ -164,44 +164,45 @@ 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; } } @@ -539,22 +540,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/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 dfbbf0b60f33..8bc9cfde4ae8 100644 --- a/svx/source/svdraw/svdcrtv.cxx +++ b/svx/source/svdraw/svdcrtv.cxx @@ -350,7 +350,10 @@ void SdrCreateView::SetCurrentObj(sal_uInt16 nIdent, SdrInventor nInvent) nCurrentInvent=nInvent; nCurrentIdent=nIdent; SdrObject * pObj = (nIdent == OBJ_NONE) ? nullptr : - SdrObjFactory::MakeNewObject(*GetModel(), nInvent, nIdent, nullptr); + SdrObjFactory::MakeNewObject( + *GetModel(), + nInvent, + nIdent); if(pObj) { @@ -411,12 +414,16 @@ bool SdrCreateView::ImpBegCreateObj(SdrInventor nInvent, sal_uInt16 nIdent, cons } else if (mpModel) { - pCurrentCreate->SetModel(mpModel); + // TTTT pCurrentCreate->SetModel(mpModel); } } else { - pCurrentCreate = SdrObjFactory::MakeNewObject(*mpModel, nInvent, nIdent, pCreatePV->GetPage(), mpModel); + pCurrentCreate = SdrObjFactory::MakeNewObject( + *mpModel, + nInvent, + nIdent, + pCreatePV->GetPage()); } Point aPnt(rPnt); diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx index ab33efc23860..d0a7fdef8f1e 100644 --- a/svx/source/svdraw/svdedtv2.cxx +++ b/svx/source/svdraw/svdedtv2.cxx @@ -1590,7 +1590,7 @@ 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()); + // TTTT pCandidate->SetModel(pCustomShape->GetModel()); if(pCustomShape->GetMergedItem(SDRATTR_SHADOW).GetValue()) { @@ -1611,9 +1611,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, SdrObject* pTextObj = SdrObjFactory::MakeNewObject( pCustomShape->getSdrModelFromSdrObject(), pCustomShape->GetObjInventor(), - OBJ_TEXT, - nullptr, - pCustomShape->GetModel()); + OBJ_TEXT); // Copy text content OutlinerParaObject* pParaObj = pCustomShape->GetOutlinerParaObject(); diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index da5ed7ab6df5..cd72e38d19ab 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -1089,8 +1089,14 @@ bool SdrObjEditView::SdrBeginTextEdit( pTextEditPV=pPV; mxTextEditObj.reset( pObj ); pTextEditOutliner.reset(pGivenOutliner); - if (pTextEditOutliner==nullptr) - pTextEditOutliner.reset(SdrMakeOutliner( OutlinerMode::TextObject, *mxTextEditObj->GetModel() )); + + if(nullptr == pTextEditOutliner) + { + pTextEditOutliner.reset( + SdrMakeOutliner( + OutlinerMode::TextObject, + mxTextEditObj->getSdrModelFromSdrObject())); + } { SvtAccessibilityOptions aOptions; @@ -1586,8 +1592,7 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally) } if( pTEObj && - pTEObj->GetModel() && - !pTEObj->GetModel()->isLocked() && + !pTEObj->getSdrModelFromSdrObject().isLocked() && pTEObj->GetBroadcaster()) { SdrHint aHint(SdrHintKind::EndEdit, *pTEObj); @@ -2406,11 +2411,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/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index f63e11dec371..3f3a93565979 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -1021,7 +1021,7 @@ void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const OUString& rSt aPos.AdjustY( -nTextHeight ); tools::Rectangle aTextRect( aPos, aSize ); - SdrRectObj* pText =new SdrRectObj( + SdrRectObj* pText = new SdrRectObj( *mpModel, OBJ_TEXT, aTextRect); @@ -1043,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 ); 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..6b82f7ef9fb9 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -1323,7 +1323,10 @@ void SdrModel::InsertPage(SdrPage* pPage, sal_uInt16 nPos) PageListChanged(); pPage->SetInserted(); pPage->SetPageNum(nPos); - pPage->SetModel(this); + + // TTTT + // pPage->SetModel(this); + if (nPos<nCount) bPagNumsDirty=true; SetChanged(); SdrHint aHint(SdrHintKind::PageOrderChange, pPage); @@ -1372,7 +1375,10 @@ void SdrModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos) MasterPageListChanged(); pPage->SetInserted(); pPage->SetPageNum(nPos); - pPage->SetModel(this); + + // TTTT + // pPage->SetModel(this); + if (nPos<nCount) { bMPgNumsDirty=true; } @@ -1476,7 +1482,7 @@ void SdrModel::CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum, if (!bMoveNoCopy) { const SdrPage* pPg1=GetPage(nPageNum2); - pPg=pPg1->Clone(); + pPg=pPg1->Clone(nullptr); // TTTT copy to local model InsertPage(pPg,nDestNum); if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoCopyPage(*pPg)); @@ -1577,14 +1583,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]) + { + // TTTT 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 +1602,10 @@ void SdrModel::Merge(SdrModel& rSourceModel, maMaPag.insert(maMaPag.begin()+nDstMasterPageCnt, pPg); MasterPageListChanged(); pPg->SetInserted(); - pPg->SetModel(this); + + // TTTT + // pPg->SetModel(this); + bMPgNumsDirty=true; if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg)); } else { @@ -1607,14 +1620,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) + { + // TTTT 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/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index ab82cf1343e0..bb0cba9e7f1e 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -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) @@ -2817,7 +2808,7 @@ SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) co { SdrObject* pCandidate = pRenderedCustomShape->Clone(); DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)"); - pCandidate->SetModel(GetModel()); + // TTTT clone? 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 38fd4d2e14ca..8a1b7a0b56f4 100644 --- a/svx/source/svdraw/svdoattr.cxx +++ b/svx/source/svdraw/svdoattr.cxx @@ -100,22 +100,23 @@ 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); -} +// TTTT clone? +// 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 diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 51567a4b38ef..75472aca9f39 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -288,7 +288,6 @@ SdrObject::SdrObject(SdrModel& rSdrModel) : mpFillGeometryDefiningShape(nullptr) ,mrSdrModelFromSdrObject(rSdrModel) ,pPage(nullptr) - ,pModel(nullptr) ,pUserCall(nullptr) ,pPlusData(nullptr) ,mpImpl(new Impl) @@ -394,26 +393,27 @@ void SdrObject::SetRectsDirty(bool bNotMyself) } } -void SdrObject::SetModel(SdrModel* pNewModel) -{ - if(pNewModel && pPage) - { - if(pPage->GetModel() != pNewModel) - { - pPage = nullptr; - } - } +// TTTT clone? +// 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 ); - } +// // update listeners at possible API wrapper object +// if( pModel != pNewModel ) +// { +// SvxShape* pShape = getSvxShape(); +// if( pShape ) +// pShape->ChangeModel( pNewModel ); +// } - pModel = pNewModel; -} +// pModel = pNewModel; +// } void SdrObject::SetObjList(SdrObjList* pNewObjList) @@ -424,15 +424,19 @@ void SdrObject::SetObjList(SdrObjList* pNewObjList) void SdrObject::SetPage(SdrPage* pNewPage) { - SdrModel* pOldModel = pModel; - SdrPage* pOldPage = pPage; + SdrModel* pOldModel(&getSdrModelFromSdrObject()); + SdrPage* pOldPage(pPage); + + pPage = pNewPage; - pPage=pNewPage; - if (pPage!=nullptr) + if(nullptr != pPage) { - SdrModel* pMod=pPage->GetModel(); - if (pMod!=pModel && pMod!=nullptr) - SetModel(pMod); + SdrModel* pMod(&pPage->getSdrModelFromSdrObjList()); + + if(pMod != &getSdrModelFromSdrObject()) + { + // TTTT model change? Clone needed? SetModel(pMod); + } } // The creation of the UNO shape in SdrObject::getUnoShape is influenced @@ -441,7 +445,7 @@ 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)) + if (pOldPage != pPage && !(pOldPage && pPage && pOldModel == &getSdrModelFromSdrObject())) { SvxShape* const pShape(getSvxShape()); if (pShape && !pShape->HasSdrObjectOwnership()) @@ -513,13 +517,12 @@ sal_Int16 SdrObject::GetRelativeHeightRelation() const return mpImpl->meRelativeHeightRelation; } -SfxItemPool & SdrObject::GetObjectItemPool() const +SfxItemPool& SdrObject::GetObjectItemPool() const { - if(pModel) - return pModel->GetItemPool(); + return getSdrModelFromSdrObject().GetItemPool(); // use a static global default pool - return SdrObject::GetGlobalDrawObjectItemPool(); + // TTTT needed? return SdrObject::GetGlobalDrawObjectItemPool(); } SdrInventor SdrObject::GetObjInventor() const @@ -637,7 +640,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 = @@ -646,14 +649,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(); @@ -681,7 +684,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 = @@ -690,14 +693,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(); @@ -725,7 +728,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 = @@ -734,14 +737,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(); @@ -836,7 +839,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 @@ -866,7 +869,7 @@ void SdrObject::RecalcBoundRect() void SdrObject::BroadcastObjectChange() const { - if ((pModel && pModel->isLocked()) || utl::ConfigManager::IsFuzzing()) + if ((getSdrModelFromSdrObject().isLocked()) || utl::ConfigManager::IsFuzzing()) return; if (mbDelayBroadcastObjectChange) @@ -876,7 +879,7 @@ void SdrObject::BroadcastObjectChange() const } bool bPlusDataBroadcast(pPlusData && pPlusData->pBroadcast); - bool bObjectChange(IsInserted() && pModel); + bool bObjectChange(IsInserted()); if(bPlusDataBroadcast || bObjectChange) { @@ -889,7 +892,7 @@ void SdrObject::BroadcastObjectChange() const if(bObjectChange) { - pModel->Broadcast(aHint); + getSdrModelFromSdrObject().Broadcast(aHint); } } } @@ -900,9 +903,9 @@ void SdrObject::SetChanged() // notification now. ActionChanged(); - if(IsInserted() && pModel) + if(IsInserted()) // TTTT IsInserted->no model stuff, but SdrPage (?) { - pModel->SetChanged(); + getSdrModelFromSdrObject().SetChanged(); } } @@ -930,9 +933,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) @@ -948,7 +951,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; @@ -1022,19 +1024,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 @@ -2055,16 +2047,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); @@ -2127,12 +2119,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 ); @@ -2359,7 +2350,6 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash) getSdrModelFromSdrObject(), OBJ_PATHFILL, aMergedLineFillPolyPolygon); - aLinePolygonPart->SetModel(GetModel()); // correct item properties aSet.Put(XLineWidthItem(0)); @@ -2383,7 +2373,6 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash) getSdrModelFromSdrObject(), OBJ_PATHLINE, aMergedHairlinePolyPolygon); - aLineHairlinePart->SetModel(GetModel()); aSet.Put(XLineWidthItem(0)); aSet.Put(XFillStyleItem(drawing::FillStyle_NONE)); @@ -2417,7 +2406,6 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash) if(bBuildGroup || bAddOriginalGeometry) { SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject()); - pGroup->SetModel(GetModel()); if(bAddOriginalGeometry) { @@ -2428,8 +2416,6 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash) aSet.Put(XLineWidthItem(0)); SdrObject* pClone = Clone(); - - pClone->SetModel(GetModel()); pClone->SetMergedItemSet(aSet); pGroup->GetSubList()->NbcInsertObject(pClone); @@ -2465,7 +2451,6 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash) { // due to current method usage, create and return a clone when nothing has changed SdrObject* pClone = Clone(); - pClone->SetModel(GetModel()); pRetval = pClone; } @@ -2498,7 +2483,6 @@ SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, bool bForceLineDash) { SdrObjList* pObjList2 = pRet->GetSubList(); SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject()); - pGroup->SetModel(pRet->GetModel()); for(size_t a=0; a<pObjList2->GetObjCount(); ++a) { @@ -2601,10 +2585,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 +2599,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); } } } @@ -2882,7 +2866,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 +2950,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 +2969,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 @@ -3070,85 +3052,13 @@ SdrObject* SdrObjFactory::CreateObjectFromFactory(SdrModel& rSdrModel, SdrInvent SdrObject* SdrObjFactory::MakeNewObject( SdrModel& rSdrModel, - 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(rSdrModel); break; - case sal_uInt16(OBJ_GRUP ): pObj=new SdrObjGroup(rSdrModel); break; - case sal_uInt16(OBJ_LINE ): pObj=new SdrPathObj(rSdrModel, OBJ_LINE ); 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_CIRC ): pObj=new SdrCircObj(rSdrModel, OBJ_CIRC ); break; - case sal_uInt16(OBJ_SECT ): pObj=new SdrCircObj(rSdrModel, OBJ_SECT ); break; - case sal_uInt16(OBJ_CARC ): pObj=new SdrCircObj(rSdrModel, OBJ_CARC ); break; - case sal_uInt16(OBJ_CCUT ): pObj=new SdrCircObj(rSdrModel, OBJ_CCUT ); break; - case sal_uInt16(OBJ_TEXT ): pObj=new SdrRectObj(rSdrModel, OBJ_TEXT ); break; - case sal_uInt16(OBJ_TEXTEXT ): pObj=new SdrRectObj(rSdrModel, OBJ_TEXTEXT ); break; - case sal_uInt16(OBJ_TITLETEXT ): pObj=new SdrRectObj(rSdrModel, OBJ_TITLETEXT ); break; - case sal_uInt16(OBJ_OUTLINETEXT): pObj=new SdrRectObj(rSdrModel, OBJ_OUTLINETEXT); break; - case sal_uInt16(OBJ_MEASURE ): pObj=new SdrMeasureObj(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(rSdrModel); break; -#endif - case sal_uInt16(OBJ_TABLE ): pObj=new sdr::table::SdrTableObj(rSdrModel); break; - } - } - - if (!pObj) - { - pObj = CreateObjectFromFactory(rSdrModel, 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( - SdrModel& rSdrModel, SdrInventor nInventor, sal_uInt16 nIdentifier, - const tools::Rectangle& rSnapRect, - SdrPage* pPage) + 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) { @@ -3156,15 +3066,44 @@ SdrObject* SdrObjFactory::MakeNewObject( { case OBJ_MEASURE: { - pObj = new SdrMeasureObj(rSdrModel, 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(rSdrModel, 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: @@ -3172,8 +3111,20 @@ SdrObject* SdrObjFactory::MakeNewObject( case OBJ_TITLETEXT: case OBJ_OUTLINETEXT: { - pObj = new SdrRectObj(rSdrModel, 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: @@ -3181,8 +3132,20 @@ SdrObject* SdrObjFactory::MakeNewObject( case OBJ_CARC: case OBJ_CCUT: { - pObj = new SdrCircObj(rSdrModel, 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(rSdrModel); break; @@ -3222,11 +3185,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 e72333f6062c..60e56b6f02b1 100644 --- a/svx/source/svdraw/svdocapt.cxx +++ b/svx/source/svdraw/svdocapt.cxx @@ -235,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 @@ -666,11 +680,12 @@ Point SdrCaptionObj::GetSnapPoint(sal_uInt32 /*i*/) const return Point(0,0); } -void SdrCaptionObj::SetModel(SdrModel* pNewModel) -{ - SdrRectObj::SetModel(pNewModel); - ImpRecalcTail(); -} +// TTTT needed? +// void SdrCaptionObj::SetModel(SdrModel* pNewModel) +// { +// SdrRectObj::SetModel(pNewModel); +// ImpRecalcTail(); +// } void SdrCaptionObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) { @@ -751,7 +766,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) @@ -776,7 +792,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 90cecb978232..1dc049f07d17 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -348,9 +348,22 @@ OUString SdrCircObj::TakeObjNamePlural() const return ImpGetResStr(pID); } -SdrCircObj* SdrCircObj::Clone() const +SdrCircObj* SdrCircObj::Clone(SdrModel* pTargetModel) const { - return CloneHelper< SdrCircObj >(); + return CloneHelper< SdrCircObj >(pTargetModel); +} + +SdrCircObj& SdrCircObj::operator=(const SdrCircObj& rObj) +{ + if( this == &rObj ) + return *this; + SdrRectObj::operator=(rObj); + + meCircleKind = rObj.meCircleKind; + nStartAngle = rObj.nStartAngle; + nEndAngle = rObj.nEndAngle; + + return *this; } basegfx::B2DPolyPolygon SdrCircObj::TakeXorPoly() const @@ -586,7 +599,7 @@ OUString SdrCircObj::getSpecialDragComment(const SdrDragStat& rDrag) const nAngle = pU->nEnd; } - aBuf.append(GetAngleStr(nAngle)); + aBuf.append(SdrModel::GetAngleString(nAngle)); aBuf.append(')'); } @@ -604,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 e6f7a048db50..ce5a636a5e03 100644 --- a/svx/source/svdraw/svdoedge.cxx +++ b/svx/source/svdraw/svdoedge.cxx @@ -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 2307b8e029fa..64557a9f485a 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() ) { @@ -485,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 @@ -563,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 ); } @@ -584,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; } @@ -633,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 ) { @@ -649,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) { @@ -734,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 @@ -898,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 ) @@ -1020,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->getSdrModelFromSdrObjList().GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj()); if(pSheet) { @@ -1046,27 +1048,28 @@ void SdrGrafObj::SetPage( SdrPage* pNewPage ) ImpRegisterLink(); } -void SdrGrafObj::SetModel( SdrModel* pNewModel ) -{ - bool bChg = pNewModel != pModel; +// TTTT needed? +// void SdrGrafObj::SetModel( SdrModel* pNewModel ) +// { +// bool bChg = pNewModel != pModel; - if( bChg ) - { - if( mpGraphicObject->HasUserData() ) - { - ForceSwapIn(); - } +// if( bChg ) +// { +// if( mpGraphicObject->HasUserData() ) +// { +// ForceSwapIn(); +// } - if( pGraphicLink != nullptr ) - ImpDeregisterLink(); - } +// if( pGraphicLink != nullptr ) +// ImpDeregisterLink(); +// } - // realize model - SdrRectObj::SetModel(pNewModel); +// // realize model +// SdrRectObj::SetModel(pNewModel); - if (bChg && !aFileName.isEmpty()) - ImpRegisterLink(); -} +// if (bChg && !aFileName.isEmpty()) +// ImpRegisterLink(); +// } void SdrGrafObj::StartAnimation() { @@ -1087,11 +1090,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); @@ -1136,7 +1143,10 @@ 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); + ImpSdrGDIMetaFileImport aFilter( + getSdrModelFromSdrObject(), + GetLayer(), + maRect); SdrObjGroup* pGrp = new SdrObjGroup(getSdrModelFromSdrObject()); if(aFilter.DoImport(aMtf, *pGrp->GetSubList(), 0)) @@ -1160,7 +1170,6 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const pRetval = pGrp; pGrp->NbcSetLayer(GetLayer()); - pGrp->SetModel(GetModel()); if(bAddText) { @@ -1204,7 +1213,6 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const { pGrp = new SdrObjGroup(getSdrModelFromSdrObject()); pGrp->NbcSetLayer(GetLayer()); - pGrp->SetModel(GetModel()); pGrp->GetSubList()->NbcInsertObject(pRetval); } @@ -1338,7 +1346,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; @@ -1362,13 +1370,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 ) ) @@ -1394,78 +1402,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; @@ -1484,30 +1487,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 24c452213686..917ed0a67334 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -175,36 +175,35 @@ void SdrObjGroup::SetPage(SdrPage* 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); - } -} - +// TTTT needed? +// 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); +// } +// } SdrObjList* SdrObjGroup::GetSubList() const { @@ -235,15 +234,16 @@ 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); @@ -251,7 +251,10 @@ SdrObjGroup& SdrObjGroup::operator=(const SdrObjGroup& rObj) // copy SubList, init model and page first SdrObjList& rSourceSubList = *rObj.GetSubList(); pSub->SetPage(rSourceSubList.GetPage()); - pSub->SetModel(rSourceSubList.GetModel()); + + // TTTT maybe check SdrModels/need to clone? + // pSub->SetModel(rSourceSubList.GetModel()); + pSub->CopyObjects(*rObj.GetSubList()); // copy local parameters @@ -732,7 +735,6 @@ void SdrObjGroup::ReformatText() SdrObject* SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const { SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject()); - pGroup->SetModel(GetModel()); for(size_t a=0; a<pSub->GetObjCount(); ++a) { diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx index 38c14d176e13..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; @@ -713,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 @@ -1144,7 +1146,6 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const // prepare group SdrObjGroup* pGroup = new SdrObjGroup(getSdrModelFromSdrObject()); - pGroup->SetModel(GetModel()); // prepare parameters basegfx::B2DPolyPolygon aPolyPoly; @@ -1162,7 +1163,7 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const getSdrModelFromSdrObject(), OBJ_PATHLINE, aPolyPoly); - pPath->SetModel(GetModel()); + pPath->SetMergedItemSet(aSet); pPath->SetStyleSheet(pStyleSheet, true); pGroup->GetSubList()->NbcInsertObject(pPath); @@ -1183,7 +1184,7 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const getSdrModelFromSdrObject(), OBJ_PATHLINE, aPolyPoly); - pPath->SetModel(GetModel()); + pPath->SetMergedItemSet(aSet); pPath->SetStyleSheet(pStyleSheet, true); @@ -1198,7 +1199,7 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const getSdrModelFromSdrObject(), OBJ_PATHLINE, aPolyPoly); - pPath->SetModel(GetModel()); + pPath->SetMergedItemSet(aSet); pPath->SetStyleSheet(pStyleSheet, true); @@ -1220,7 +1221,7 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const getSdrModelFromSdrObject(), OBJ_PATHLINE, aPolyPoly); - pPath->SetModel(GetModel()); + pPath->SetMergedItemSet(aSet); pPath->SetStyleSheet(pStyleSheet, true); @@ -1235,7 +1236,7 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const getSdrModelFromSdrObject(), OBJ_PATHLINE, aPolyPoly); - pPath->SetModel(GetModel()); + pPath->SetMergedItemSet(aSet); pPath->SetStyleSheet(pStyleSheet, true); @@ -1253,7 +1254,7 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const getSdrModelFromSdrObject(), OBJ_PATHLINE, aPolyPoly); - pPath->SetModel(GetModel()); + pPath->SetMergedItemSet(aSet); pPath->SetStyleSheet(pStyleSheet, true); @@ -1384,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()) { @@ -1393,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) @@ -1430,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) @@ -1452,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 453893455f62..012dc1d35879 100644 --- a/svx/source/svdraw/svdomedia.cxx +++ b/svx/source/svdraw/svdomedia.cxx @@ -142,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) @@ -316,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)); @@ -332,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&) { @@ -395,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 49b3c4526bdb..6a00d1bf19aa 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -788,7 +788,8 @@ bool SdrOle2Obj::UpdateLinkURL_Impl() if ( mpImpl->mpObjectLink ) { - sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : nullptr; + sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager()); + if ( pLinkManager ) { OUString aNewLinkURL; @@ -838,9 +839,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() ) { @@ -865,7 +864,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 ); @@ -875,18 +875,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 ); @@ -912,14 +915,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() ) ) ) { @@ -964,9 +969,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() ); } } @@ -1047,9 +1052,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 @@ -1085,7 +1090,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(); @@ -1132,7 +1137,6 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const SdrGrafObj* pClone = new SdrGrafObj( getSdrModelFromSdrObject(), *pOLEGraphic); - pClone->SetModel(GetModel()); // copy transformation basegfx::B2DHomMatrix aMatrix; @@ -1150,7 +1154,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)); } @@ -1165,7 +1169,6 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const SdrRectObj* pClone = new SdrRectObj( getSdrModelFromSdrObject(), GetSnapRect()); - pClone->SetModel(GetModel()); // gray outline pClone->SetMergedItem(XLineStyleItem(css::drawing::LineStyle_SOLID)); @@ -1186,91 +1189,89 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const SdrObject* SdrOle2Obj::DoConvertToPolyObj(bool bBezier, bool bAddText) const { // #i118485# missing converter added - if(GetModel()) - { - SdrObject* pRetval = createSdrGrafObjReplacement(true); + SdrObject* pRetval = createSdrGrafObjReplacement(true); - if(pRetval) - { - SdrObject* pRetval2 = pRetval->DoConvertToPolyObj(bBezier, bAddText); - SdrObject::Free(pRetval); + if(pRetval) + { + SdrObject* pRetval2 = pRetval->DoConvertToPolyObj(bBezier, bAddText); + SdrObject::Free(pRetval); - return pRetval2; - } + return pRetval2; } 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() ) - { - 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 ); - - // #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(); - } - - AddListeners_Impl(); -} +// TTTT needed? +// 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() ) +// { +// 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 ); + +// // #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(); +// } + +// AddListeners_Impl(); +// } void SdrOle2Obj::SetPage(SdrPage* pNewPage) { @@ -1280,14 +1281,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->getSdrModelFromSdrObjList().GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(); if(pSheet) { @@ -1425,65 +1426,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; + } - if( pModel && mpImpl->mbConnected ) - Disconnect(); + // ImpAssign( rObj ); + const SdrOle2Obj& rOle2Obj = rObj; - SdrRectObj::operator=( rObj ); + if( mpImpl->mbConnected ) + Disconnect(); - // Manually copying bClosedObj attribute - SetClosedObj( rObj.IsClosedObj() ); + SdrRectObj::operator=( rObj ); - mpImpl->aPersistName = rOle2Obj.mpImpl->aPersistName; - mpImpl->maProgName = rOle2Obj.mpImpl->maProgName; - mpImpl->mbFrame = rOle2Obj.mpImpl->mbFrame; + // Manually copying bClosedObj attribute + SetClosedObj( rObj.IsClosedObj() ); - if (rOle2Obj.mpImpl->mxGraphic) - { - mpImpl->mxGraphic.reset(new Graphic(*rOle2Obj.mpImpl->mxGraphic)); - } + 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( 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() @@ -1501,14 +1505,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 ) { @@ -1540,7 +1547,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(); @@ -1561,7 +1571,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 @@ -1607,13 +1621,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())); } } } @@ -1621,9 +1652,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 @@ -1634,7 +1666,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(); } @@ -1642,7 +1675,7 @@ void SdrOle2Obj::SetGeoData(const SdrObjGeoData& rGeo) { SdrRectObj::SetGeoData(rGeo); - if( pModel && !pModel->isLocked() ) + if( !getSdrModelFromSdrObject().isLocked() ) ImpSetVisAreaSize(); } @@ -1650,7 +1683,7 @@ void SdrOle2Obj::NbcSetSnapRect(const tools::Rectangle& rRect) { SdrRectObj::NbcSetSnapRect(rRect); - if( pModel && !pModel->isLocked() ) + if( !getSdrModelFromSdrObject().isLocked() ) ImpSetVisAreaSize(); if ( mpImpl->mxObjRef.is() && IsChart() ) @@ -1666,7 +1699,7 @@ void SdrOle2Obj::NbcSetLogicRect(const tools::Rectangle& rRect) { SdrRectObj::NbcSetLogicRect(rRect); - if( pModel && !pModel->isLocked() ) + if( !getSdrModelFromSdrObject().isLocked() ) ImpSetVisAreaSize(); } @@ -1697,7 +1730,7 @@ void SdrOle2Obj::NbcMove(const Size& rSize) { SdrRectObj::NbcMove(rSize); - if( pModel && !pModel->isLocked() ) + if( !getSdrModelFromSdrObject().isLocked() ) ImpSetVisAreaSize(); } @@ -1769,7 +1802,8 @@ bool SdrOle2Obj::Unload() return true; bool bUnloaded = false; - if ( pModel && mpImpl->mxObjRef.is() ) + + if ( mpImpl->mxObjRef.is() ) { bUnloaded = Unload( mpImpl->mxObjRef.GetObject(), GetAspect() ); } @@ -1779,12 +1813,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(); @@ -1804,7 +1840,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 @@ -1813,9 +1849,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 ); } } } @@ -1900,9 +1936,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; } @@ -1910,10 +1944,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(); @@ -1930,7 +1964,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 a5c169c8424a..af38237fa632 100644 --- a/svx/source/svdraw/svdopage.cxx +++ b/svx/source/svdraw/svdopage.cxx @@ -150,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 b48651f0532d..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); } @@ -1828,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) @@ -2886,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()) { @@ -2995,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 ce3f6d2c2418..e68b38ce3205 100644 --- a/svx/source/svdraw/svdorect.cxx +++ b/svx/source/svdraw/svdorect.cxx @@ -107,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(); @@ -274,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 6bab4d8f6bc2..b7eff267d073 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -173,25 +173,19 @@ SdrTextObj::SdrTextObj( 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(); @@ -480,38 +474,39 @@ void SdrTextObj::SetPage(SdrPage* pNewPage) } } -void SdrTextObj::SetModel(SdrModel* pNewModel) -{ - SdrModel* pOldModel=pModel; - bool bLinked=IsLinkedText(); - bool bChg=pNewModel!=pModel; +// TTTT needed? +// void SdrTextObj::SetModel(SdrModel* pNewModel) +// { +// SdrModel* pOldModel=pModel; +// bool bLinked=IsLinkedText(); +// bool bChg=pNewModel!=pModel; - if (bLinked && bChg) - { - ImpDeregisterLink(); - } +// if (bLinked && bChg) +// { +// ImpDeregisterLink(); +// } - SdrAttrObj::SetModel(pNewModel); +// SdrAttrObj::SetModel(pNewModel); - if( bChg ) - { - if( pNewModel != nullptr && pOldModel != nullptr ) - SetTextSizeDirty(); +// 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 ); - } - } +// 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(); - } -} +// if (bLinked && bChg) +// { +// ImpRegisterLink(); +// } +// } void SdrTextObj::NbcSetEckenradius(long nRad) { @@ -526,7 +521,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; @@ -756,11 +751,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 ) { @@ -1051,9 +1044,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) @@ -1113,7 +1106,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 @@ -1215,7 +1208,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 ); @@ -1263,7 +1256,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(); @@ -1405,17 +1398,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); } @@ -1563,7 +1560,7 @@ TextChain *SdrTextObj::GetTextChain() const //if (!IsChainable()) // return NULL; - return pModel->GetTextChain(); + return getSdrModelFromSdrObject().GetTextChain(); } bool SdrTextObj::IsVerticalWriting() const @@ -1672,7 +1669,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()) { @@ -1771,7 +1768,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 298a832983fb..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(); } @@ -378,12 +378,7 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const // 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); @@ -452,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; } diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx index 504682dea454..4a0e071ca8b9 100644 --- a/svx/source/svdraw/svdouno.cxx +++ b/svx/source/svdraw/svdouno.cxx @@ -255,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) diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx index 11fd73c99974..2c862950dd26 100644 --- a/svx/source/svdraw/svdovirt.cxx +++ b/svx/source/svdraw/svdovirt.cxx @@ -82,12 +82,12 @@ void SdrVirtObj::NbcSetAnchorPos(const Point& rAnchorPos) aAnchor=rAnchorPos; } - -void SdrVirtObj::SetModel(SdrModel* pNewModel) -{ - SdrObject::SetModel(pNewModel); - rRefObj.SetModel(pNewModel); -} +// TTTT not needed +// void SdrVirtObj::SetModel(SdrModel* pNewModel) +// { +// SdrObject::SetModel(pNewModel); +// rRefObj.SetModel(pNewModel); +// } void SdrVirtObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const { @@ -129,17 +129,29 @@ void SdrVirtObj::RecalcBoundRect() aOutRect+=aAnchor; } -SdrVirtObj* SdrVirtObj::Clone() const +SdrVirtObj* SdrVirtObj::Clone(SdrModel* pTargetModel) const { - return new SdrVirtObj( - getSdrModelFromSdrObject(), - 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; } @@ -272,7 +284,9 @@ SdrObject* SdrVirtObj::getFullDragClone() const SdrObject& rReferencedObject = const_cast<SdrVirtObj*>(this)->ReferencedObj(); return new SdrGrafObj( getSdrModelFromSdrObject(), - SdrDragView::GetObjGraphic(GetModel(), &rReferencedObject), + SdrDragView::GetObjGraphic( + &getSdrModelFromSdrObject(), + &rReferencedObject), GetLogicRect()); } diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index 1d660b24d851..080fd17b3a3d 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -132,20 +132,23 @@ void SdrObjList::lateInit(const SdrObjList& rSrcList) void SdrObjList::CopyObjects(const SdrObjList& rSrcList) { 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(&getSdrModelFromSdrObjList())); - if (pDO!=nullptr) { - pDO->SetModel(pModel); + if(nullptr != pDO) + { pDO->SetPage(pPage); NbcInsertObject(pDO, SAL_MAX_SIZE); - } else { + } + else + { nCloneErrCnt++; } } @@ -271,17 +274,18 @@ 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); - } - } -} +// TTTT needed? +// 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() { @@ -1284,10 +1288,11 @@ void SdrPage::lateInit(const SdrPage& rSrcPage, SdrModel* const pNewModel) eListKind = (mbMaster) ? SdrObjListKind::MasterPage : SdrObjListKind::DrawPage; } -SdrPage* SdrPage::Clone() const -{ - return Clone(nullptr); -} +// TTTT +// SdrPage* SdrPage::Clone() const +// { +// return Clone(nullptr); +// } SdrPage* SdrPage::Clone(SdrModel* pNewModel) const { @@ -1454,47 +1459,48 @@ void SdrPage::impl_setModelForLayerAdmin(SdrModel* const pNewModel) 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 ); - } - } -} +// TTTT needed? +// 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) 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/svdtext.cxx b/svx/source/svdraw/svdtext.cxx index 159f863cb54c..c088ddd9122e 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,85 @@ 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(); -} +// TTTT needed? +// 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..dca103a7be90 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.getSdrModelFromSdrObjList()) + ,mrPage(rNewPg) { } @@ -1657,7 +1657,7 @@ void SdrUndoPageRemoveMasterPage::Undo() { if(mbOldHadMasterPage) { - mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maOldMasterPageNumber)); + mrPage.TRG_SetMasterPage(*mrPage.getSdrModelFromSdrObjList().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.getSdrModelFromSdrObjList().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.getSdrModelFromSdrObjList().GetMasterPage(maNewMasterPageNumber)); mrPage.TRG_SetMasterPageVisibleLayers(maNewSet); } } diff --git a/svx/source/svdraw/svdviter.cxx b/svx/source/svdraw/svdviter.cxx index 2dbd8b5f3bb2..c82823d0b280 100644 --- a/svx/source/svdraw/svdviter.cxx +++ b/svx/source/svdraw/svdviter.cxx @@ -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 569e0554024d..8603cc472ca2 100644 --- a/svx/source/svdraw/svdxcgv.cxx +++ b/svx/source/svdraw/svdxcgv.cxx @@ -149,7 +149,7 @@ bool SdrExchangeView::Paste(const OUString& rStr, const Point& rPos, SdrObjList* getSdrModelFromSdrView(), OBJ_TEXT, aTextRect); - pObj->SetModel(mpModel); + pObj->SetLayer(nLayer); pObj->NbcSetText(rStr); // SetText before SetAttr, else SetAttr doesn't work! if (mpDefaultStyleSheet!=nullptr) pObj->NbcSetStyleSheet(mpDefaultStyleSheet, false); @@ -189,7 +189,7 @@ bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point& getSdrModelFromSdrView(), OBJ_TEXT, aTextRect); - pObj->SetModel(mpModel); + pObj->SetLayer(nLayer); if (mpDefaultStyleSheet!=nullptr) pObj->NbcSetStyleSheet(mpDefaultStyleSheet, false); @@ -209,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()) @@ -220,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); } @@ -313,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(); @@ -353,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! @@ -422,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(); @@ -741,13 +739,11 @@ SdrModel* SdrExchangeView::GetMarkedObjModel() const GetObjGraphic(mpModel, 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); diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index cd1973848746..b235fd924ef5 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -392,21 +392,23 @@ 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() ) +{ + // TTTT should not be needed (?) + // if( rTableObj.GetModel() ) + // SetModel( rTableObj.GetModel() ); } @@ -440,35 +442,35 @@ 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 ); - } -} +// TTTT should not be needed - not intended to change. Maybe parts needed at construction time +// 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 ) @@ -537,12 +539,12 @@ 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 SetStyleSheet( nullptr, true ); } } @@ -564,12 +566,12 @@ 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 SetStyleSheet( nullptr, true ); } @@ -812,10 +814,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 +1022,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 +1114,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 +1134,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 +1151,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 +1161,7 @@ void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any& } } - GetModel()->SetChanged(); + GetObject().getSdrModelFromSdrObject().SetChanged(); mpProperties->SetMergedItemSetAndBroadcast( aSet ); return; } @@ -1172,7 +1175,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 +1234,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 +1244,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 +1286,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 +1316,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 +1367,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 +1470,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 +1500,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 +1530,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 +1541,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 +1568,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 d6079b26c023..c9d886aca6e5 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. @@ -1349,26 +1349,26 @@ sal_uInt16 SdrTableObj::GetObjIdentifier() const return static_cast<sal_uInt16>(OBJ_TABLE); } +// TTTT needed? +// void SdrTableObj::SetModel(SdrModel* pNewModel) +// { +// SdrModel* pOldModel = GetModel(); +// if( pNewModel != pOldModel ) +// { +// SdrTextObj::SetModel(pNewModel); -void SdrTableObj::SetModel(SdrModel* pNewModel) -{ - SdrModel* pOldModel = GetModel(); - if( pNewModel != pOldModel ) - { - SdrTextObj::SetModel(pNewModel); - - if( mpImpl.is() ) - { - mpImpl->SetModel( pNewModel ); +// if( mpImpl.is() ) +// { +// mpImpl->SetModel( pNewModel ); - if( !maLogicRect.IsEmpty() ) - { - maRect = maLogicRect; - mpImpl->LayoutTable( maRect, false, false ); - } - } - } -} +// 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 @@ -1418,9 +1418,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 +1565,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 +1658,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 +1721,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 +1755,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 +1807,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 +1887,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 +2199,7 @@ bool SdrTableObj::applySpecialDrag(SdrDragStat& rDrag) if( pEdgeHdl ) { - if( GetModel() && IsInserted() ) + if( IsInserted() ) { rDrag.SetEndDragChangesAttributes(true); rDrag.SetEndDragChangesLayout(true); @@ -2341,16 +2337,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( - getSdrModelFromSdrObject(), - 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..bfde40456d5b 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,15 @@ 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); + SdrTableObj* pNewTableObj( + rTableObj.CloneRange( // TTTT clone to new SdrModel + aStart, + aEnd, + pNewPage->getSdrModelFromSdrObjList())); + pNewTableObj->SetPage(pNewPage); pNewPage->InsertObject(pNewTableObj, SAL_MAX_SIZE); return true; @@ -2606,13 +2638,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 +2680,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 +2725,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 +3110,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 +3154,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..096ef11f7ed6 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(); + // TTTT 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 40a4307c0425..f9f561c956dc 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. @@ -1003,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 ) @@ -1252,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/unopage.cxx b/svx/source/unodraw/unopage.cxx index b8e266835239..7b4d625de08b 100644 --- a/svx/source/unodraw/unopage.cxx +++ b/svx/source/unodraw/unopage.cxx @@ -199,7 +199,8 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape } else if ( !pObj->IsInserted() ) { - pObj->SetModel(mpModel); + // TTTT should no tbe needed, should altready be constructed with it + // pObj->SetModel(mpModel); mpPage->InsertObject( pObj ); } @@ -208,7 +209,8 @@ void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape if ( !pObj->IsInserted() ) { - pObj->SetModel(mpModel); + // TTTT should no tbe needed, should altready be constructed with it + // pObj->SetModel(mpModel); mpPage->InsertObject( pObj ); } @@ -241,7 +243,8 @@ void SAL_CALL SvxDrawPage::addBottom( const uno::Reference< drawing::XShape >& x } else if ( !pObj->IsInserted() ) { - pObj->SetModel(mpModel); + // TTTT should no tbe needed, should altready be constructed with it + // pObj->SetModel(mpModel); mpPage->InsertObject( pObj, 0 ); } @@ -250,7 +253,8 @@ void SAL_CALL SvxDrawPage::addBottom( const uno::Reference< drawing::XShape >& x if ( !pObj->IsInserted() ) { - pObj->SetModel(mpModel); + // TTTT should no tbe needed, should altready be constructed with it + // pObj->SetModel(mpModel); mpPage->InsertObject( pObj, 0 ); } @@ -483,8 +487,8 @@ SdrObject* SvxDrawPage::CreateSdrObject_(const Reference< drawing::XShape > & xS *mpModel, nInventor, nType, - aRect, - mpPage); + mpPage, + &aRect); if (!pNewObj) return nullptr; @@ -817,7 +821,8 @@ SdrObject *SvxDrawPage::CreateSdrObject( const Reference< drawing::XShape > & xS SdrObject* pObj = CreateSdrObject_( xShape ); if( pObj) { - pObj->SetModel(mpModel); + // TTTT CreateSdrObject_ already uses mpModel + // pObj->SetModel(mpModel); if ( !pObj->IsInserted() && !pObj->IsDoNotInsertIntoPageAutomatically() ) { if(bBeginning) diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index 8c5fc28b8fd0..fa53c1cdef43 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -202,7 +202,9 @@ void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() ); mpObj->GetSubList()->InsertObject(pSdrShape, nPos); - pSdrShape->SetModel(mpObj->GetModel()); + // TTTT was created using mpModel in CreateSdrObject_ above + // TTTT may need to be compared and re-constructed (?) + // pSdrShape->SetModel(mpObj->GetModel()); // #85922# It makes no sense to set the layer asked // from the group object since these is an iteration diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx index a5ef378525f7..08e33cf04c0f 100644 --- a/svx/source/unodraw/unoshap4.cxx +++ b/svx/source/unodraw/unoshap4.cxx @@ -341,7 +341,7 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro aPersistName = pOle->GetPersistName(); if( !aPersistName.isEmpty() ) { - ::comphelper::IEmbeddedHelper *pPersist = mpObj->GetModel()->GetPersist(); + ::comphelper::IEmbeddedHelper* pPersist(mpObj->getSdrModelFromSdrObject().GetPersist()); if( (nullptr == pPersist) || !pPersist->getEmbeddedObjectContainer().HasEmbeddedObject( pOle->GetPersistName() ) ) aPersistName.clear(); } diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 790fee07c352..8c2becf222f3 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -353,7 +353,7 @@ void SvxShape::impl_initFromSdrObject() } osl_atomic_decrement( &m_refCount ); - auto pNewModel = mpObj->GetModel(); + auto pNewModel = &mpObj->getSdrModelFromSdrObject(); if (pNewModel != mpModel) { @@ -412,13 +412,12 @@ 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( mpObj.is() ) { - EndListening( *mpObj->GetModel() ); + EndListening( mpObj->getSdrModelFromSdrObject() ); } mpObj.reset( pNewObj ); @@ -449,38 +448,38 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) } } +// TTTT needed? +// void SvxShape::ChangeModel( SdrModel* pNewModel ) +// { +// DBG_TESTSOLARMUTEX(); +// if( mpObj.is() && mpObj->GetModel() ) +// { +// if( mpObj->GetModel() != pNewModel ) +// { +// EndListening( *mpObj->GetModel() ); +// } +// } -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 ); +// } - // 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 ); +// } - // 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; - mpModel = pNewModel; - - if( mpImpl->mpMaster ) - mpImpl->mpMaster->modelChanged( pNewModel ); -} +// if( mpImpl->mpMaster ) +// mpImpl->mpMaster->modelChanged( pNewModel ); +// } void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw() @@ -673,8 +672,6 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const ScopedVclPtrInstance< VirtualDevice > pVDev; pVDev->SetMapMode(MapMode(MapUnit::Map100thMM)); - - SdrModel* pModel = mpObj->GetModel(); SdrPage* pPage = mpObj->GetPage(); std::unique_ptr<E3dView> pView( @@ -2444,16 +2441,13 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(mpObj.get()); 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); @@ -3841,7 +3835,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 ) ); } @@ -3849,7 +3843,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 ) ); } diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx index 4cb601c3495f..1540aef4e1cc 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -159,7 +159,7 @@ SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject* pObject, SdrText* pText mpText ( pText ), mpView ( nullptr ), mpWindow ( nullptr ), - mpModel ( pObject ? pObject->GetModel() : nullptr ), + mpModel ( pObject ? &pObject->getSdrModelFromSdrObject() : nullptr ), // TTTT shbe ref mpOutliner ( nullptr ), mpTextForwarder ( nullptr ), mpViewForwarder ( nullptr ), @@ -195,7 +195,7 @@ SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject& rObject, SdrText* pText mpText ( pText ), mpView ( &rView ), mpWindow ( &rWindow ), - mpModel ( rObject.GetModel() ), + mpModel ( &rObject.getSdrModelFromSdrObject() ), // TTTT shbe ref mpOutliner ( nullptr ), mpTextForwarder ( nullptr ), mpViewForwarder ( nullptr ), @@ -638,7 +638,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 +709,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 +760,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 ) diff --git a/svx/source/unogallery/unogaltheme.cxx b/svx/source/unogallery/unogaltheme.cxx index 404a9bb897dd..6f0a3e857603 100644 --- a/svx/source/unogallery/unogaltheme.cxx +++ b/svx/source/unogallery/unogaltheme.cxx @@ -260,7 +260,7 @@ void SAL_CALL GalleryTheme::update( ) if (pOrigPage && pOrigModel) { FmFormModel* pTmpModel = new FmFormModel(&pOrigModel->GetItemPool()); - SdrPage* pNewPage = pOrigPage->Clone(); + SdrPage* pNewPage = pOrigPage->Clone(pTmpModel); // TTTT clone to new target pTmpModel->InsertPage(pNewPage, 0); uno::Reference< lang::XComponent > xDrawing( new GalleryDrawingModel( pTmpModel ) ); diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx index af9f298f2bd2..2262eeac6036 100644 --- a/sw/inc/dcontact.hxx +++ b/sw/inc/dcontact.hxx @@ -250,7 +250,7 @@ class SwDrawVirtObj : public SdrVirtObj /// access to offset virtual const Point GetOffset() const override; - virtual SwDrawVirtObj* Clone() const override; + virtual SwDrawVirtObj* Clone(SdrModel* pTargetModel = nullptr) const override; SwDrawVirtObj& operator= (const SwDrawVirtObj& rObj); /// connection to writer layout diff --git a/sw/inc/dpage.hxx b/sw/inc/dpage.hxx index f905f6834627..333f130f2875 100644 --- a/sw/inc/dpage.hxx +++ b/sw/inc/dpage.hxx @@ -38,8 +38,8 @@ public: explicit SwDPage(SwDrawModel& rNewModel, bool bMasterPage); virtual ~SwDPage() override; - virtual SwDPage* Clone() const override; - virtual SwDPage* Clone(SdrModel* pNewModel) const override; + // TTTT virtual SwDPage* Clone() const override; + virtual SwDPage* Clone(SdrModel* pNewModel = nullptr) const override; // #i3694# // This GetOffset() method is not needed anymore, it even leads to errors. diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 5709971c57a7..c690b2514156 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -517,7 +517,6 @@ SwVirtFlyDrawObj* SwFlyDrawContact::CreateNewRef(SwFlyFrame* pFly, SwFlyFrameFor pContact->GetMaster()->getSdrModelFromSdrObject(), *pContact->GetMaster(), pFly)); - pDrawObj->SetModel(pContact->GetMaster()->GetModel()); pDrawObj->SetUserCall(pContact); // The Reader creates the Masters and inserts them into the Page in @@ -2181,10 +2180,10 @@ SwDrawVirtObj& SwDrawVirtObj::operator=( const SwDrawVirtObj& rObj ) return *this; } -SwDrawVirtObj* SwDrawVirtObj::Clone() const +SwDrawVirtObj* SwDrawVirtObj::Clone(SdrModel* pTargetModel) const { SwDrawVirtObj* pObj = new SwDrawVirtObj( - getSdrModelFromSdrObject(), + nullptr == pTargetModel ? getSdrModelFromSdrObject() : *pTargetModel, rRefObj, mrDrawContact); diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx index 081a96cfc28a..36c98a6cf088 100644 --- a/sw/source/core/draw/dpage.cxx +++ b/sw/source/core/draw/dpage.cxx @@ -85,10 +85,11 @@ void SwDPage::lateInit(const SwDPage& rPage, SwDrawModel* const pNewModel) pDoc = &pSwDrawModel->GetDoc(); } -SwDPage* SwDPage::Clone() const -{ - return Clone( nullptr ); -} +// TTTT +// SwDPage* SwDPage::Clone() const +// { +// return Clone( nullptr ); +// } SwDPage* SwDPage::Clone(SdrModel* const pNewModel) const { diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index d2771def0e7f..250fec87a4dd 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -111,10 +111,10 @@ using namespace com::sun::star; namespace { -::basegfx::B2DPolyPolygon getPolygon(const char* pResId, SdrModel const * pDoc) +::basegfx::B2DPolyPolygon getPolygon(const char* pResId, const SdrModel& rModel) { ::basegfx::B2DPolyPolygon aRetval; - XLineEndListRef pLineEndList = pDoc->GetLineEndList(); + XLineEndListRef pLineEndList(rModel.GetLineEndList()); if( pLineEndList.is() ) { @@ -894,7 +894,7 @@ static void lcl_NotifyNeighbours( const SdrMarkList *pLst ) void SwFEShell::SetLineEnds(SfxItemSet& rAttr, SdrObject const * pObj, sal_uInt16 nSlotId) { - SdrModel *pDoc = pObj->GetModel(); + SdrModel& rModel(pObj->getSdrModelFromSdrObject()); if ( !(nSlotId == SID_LINE_ARROW_START || nSlotId == SID_LINE_ARROW_END || @@ -908,7 +908,7 @@ void SwFEShell::SetLineEnds(SfxItemSet& rAttr, SdrObject const * pObj, sal_uInt1 // set attributes of line start and ends // arrowhead - ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, pDoc ) ); + ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, rModel ) ); if( !aArrow.count() ) { ::basegfx::B2DPolygon aNewArrow; @@ -920,7 +920,7 @@ void SwFEShell::SetLineEnds(SfxItemSet& rAttr, SdrObject const * pObj, sal_uInt1 } // Circles - ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, pDoc ) ); + ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, rModel ) ); if( !aCircle.count() ) { ::basegfx::B2DPolygon aNewCircle; @@ -930,7 +930,7 @@ void SwFEShell::SetLineEnds(SfxItemSet& rAttr, SdrObject const * pObj, sal_uInt1 } // Square - ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, pDoc ) ); + ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, rModel ) ); if( !aSquare.count() ) { ::basegfx::B2DPolygon aNewSquare; @@ -942,7 +942,7 @@ void SwFEShell::SetLineEnds(SfxItemSet& rAttr, SdrObject const * pObj, sal_uInt1 aSquare.append(aNewSquare); } - SfxItemSet aSet( pDoc->GetItemPool() ); + SfxItemSet aSet( rModel.GetItemPool() ); long nWidth = 100; // (1/100th mm) // determine line width and calculate with it the line end width @@ -2921,9 +2921,7 @@ long SwFEShell::GetSectionWidth( SwFormat const & rFormat ) const SdrObject* pObj = SdrObjFactory::MakeNewObject( *pDrawModel, SdrInventor::Default, - eSdrObjectKind, - nullptr, - pDrawModel); + eSdrObjectKind); if(pObj) { @@ -3043,7 +3041,7 @@ long SwFEShell::GetSectionWidth( SwFormat const & rFormat ) const aTempPoly.append(basegfx::B2DPoint(aRect.BottomRight().getX(), nYMiddle)); aPoly.append(aTempPoly); - SfxItemSet aAttr(pObj->GetModel()->GetItemPool()); + SfxItemSet aAttr(pObj->getSdrModelFromSdrObject().GetItemPool()); SetLineEnds(aAttr, pObj, nSlotId); pObj->SetMergedItemSet(aAttr); } diff --git a/sw/source/filter/html/htmldrawreader.cxx b/sw/source/filter/html/htmldrawreader.cxx index 8508cbe1c668..8b1589563026 100644 --- a/sw/source/filter/html/htmldrawreader.cxx +++ b/sw/source/filter/html/htmldrawreader.cxx @@ -359,8 +359,7 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable ) *pModel, SdrInventor::Default, OBJ_TEXT, - pPg, - pModel); + pPg); if( !m_pMarquee ) return; diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index 4eb0af6602b7..4654ad009eeb 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -1118,7 +1118,9 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj, GrafikCtor(); - pNew->SetModel( m_pDrawModel ); + // TTTT already in constructor, also in ImportOleBase + // which may trigger xShape creation, too + // pNew->SetModel( m_pDrawModel ); pNew->SetLogicRect( pTextObj->GetCurrentBoundRect() ); pNew->SetLayer( pTextObj->GetLayer() ); @@ -1246,7 +1248,6 @@ SdrObject* SwWW8ImplReader::ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &r OBJ_TEXT, tools::Rectangle(aP0, aP1)); - pObj->SetModel( m_pDrawModel ); pObj->NbcSetSnapRect(tools::Rectangle(aP0, aP1)); Size aSize( static_cast<sal_Int16>(SVBT16ToShort( pHd->dxa )) , static_cast<sal_Int16>(SVBT16ToShort( pHd->dya )) ); @@ -1320,7 +1321,6 @@ SdrObject* SwWW8ImplReader::ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet tools::Rectangle(aP0, aP1), aP2); - pObj->SetModel( m_pDrawModel ); pObj->NbcSetSnapRect(tools::Rectangle(aP0, aP1)); Size aSize( static_cast<sal_Int16>(SVBT16ToShort( aCallB.dpheadTxbx.dxa )), static_cast<sal_Int16>(SVBT16ToShort( aCallB.dpheadTxbx.dya )) ); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 50e4eeae4d8a..0990ec498bb5 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -870,7 +870,6 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, if (pObj != nullptr) { pObj->SetMergedItemSet(aSet); - pObj->SetModel(pSdrModel); if (bVerticalText) { @@ -939,7 +938,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, pObj = new SdrRectObj( *pSdrModel, rTextRect); - pObj->SetModel( pSdrModel ); + SfxItemSet aSet( pSdrModel->GetItemPool() ); ApplyAttributes( rSt, aSet, rObjData ); diff --git a/sw/source/uibase/ribbar/concustomshape.cxx b/sw/source/uibase/ribbar/concustomshape.cxx index be8e19e092ab..adbbd07ebd2b 100644 --- a/sw/source/uibase/ribbar/concustomshape.cxx +++ b/sw/source/uibase/ribbar/concustomshape.cxx @@ -128,7 +128,7 @@ void ConstCustomShape::SetAttributes( SdrObject* pObj ) { const SfxItemSet& rSource = pSourceObj->GetMergedItemSet(); SfxItemSet aDest( - pObj->GetModel()->GetItemPool(), + pObj->getSdrModelFromSdrObject().GetItemPool(), svl::Items< // Ranges from SdrAttrObj: SDRATTR_START, SDRATTR_SHADOW_LAST, diff --git a/sw/source/uibase/ribbar/conrect.cxx b/sw/source/uibase/ribbar/conrect.cxx index 36f1050ace37..395bca6961fe 100644 --- a/sw/source/uibase/ribbar/conrect.cxx +++ b/sw/source/uibase/ribbar/conrect.cxx @@ -65,7 +65,7 @@ bool ConstRectangle::MouseButtonDown(const MouseEvent& rMEvt) SdrObject* pObj = m_pView->GetDrawView()->GetCreateObj(); if (pObj) { - SfxItemSet aAttr(pObj->GetModel()->GetItemPool()); + SfxItemSet aAttr(pObj->getSdrModelFromSdrObject().GetItemPool()); SwFEShell::SetLineEnds(aAttr, pObj, m_nSlotId); pObj->SetMergedItemSet(aAttr); } diff --git a/sw/source/uibase/shells/grfshex.cxx b/sw/source/uibase/shells/grfshex.cxx index 6e9a2d4ffa1b..add4d0eeab27 100644 --- a/sw/source/uibase/shells/grfshex.cxx +++ b/sw/source/uibase/shells/grfshex.cxx @@ -134,7 +134,6 @@ bool SwTextShell::InsertMediaDlg( SfxRequest const & rReq ) *rSh.GetDoc()->getIDocumentDrawModelAccess().GetDrawModel(), tools::Rectangle(aPos, aSize)); - pObj->SetModel(rSh.GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()); // set before setURL pObj->setURL( realURL, "" ); rSh.EnterStdMode(); rSh.SwFEShell::InsertDrawObj( *pObj, aPos ); |