diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-01-30 20:14:10 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-31 07:21:39 +0000 |
commit | 1e92059fe95cc1ba31aab4a66926d55bc00d0684 (patch) | |
tree | f6d6523928daff96ff0a2d15ab923c4777ab09e7 /svx/source/svdraw/svddrgmt.cxx | |
parent | d9ebb2e76bf7ec068ebfceccf7f477471012d157 (diff) |
svx: Refactor (sdr) views to access the SdrModel by reference
In SdrPaintView (and subclasses) the mpModel variable is always
the same as the input (reference) model, so there is no need for
that extra variable.
Change the strange and confusing var. name mrSdrModelFromSdrView
(the input reference to SdrModel) to just mrModel and use that in
GetModel(). Change the GetModel() to return a reference instead
of a pointer and reactor the code to accomodate the change.
This gets rid of many nullptr checks for the pointer that the
GetModel() returns and makes the code more simple is some cases.
Change-Id: I18351a417fd82f49262a83de036ec1420a65399c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146373
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx/source/svdraw/svddrgmt.cxx')
-rw-r--r-- | svx/source/svdraw/svddrgmt.cxx | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index 37531632c5b4..166b174c89be 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -1354,18 +1354,18 @@ bool SdrDragObjOwn::EndSdrDrag(bool /*bCopy*/) { if (DragStat().IsEndDragChangesAttributes()) { - pUndo=getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj); + pUndo=getSdrDragView().GetModel().GetSdrUndoFactory().CreateUndoAttrObject(*pObj); if (DragStat().IsEndDragChangesGeoAndAttributes()) { vConnectorUndoActions = getSdrDragView().CreateConnectorUndo( *pObj ); - pUndo2 = getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj); + pUndo2 = getSdrDragView().GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*pObj); } } else { vConnectorUndoActions = getSdrDragView().CreateConnectorUndo( *pObj ); - pUndo= getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj); + pUndo= getSdrDragView().GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*pObj); } } @@ -1474,9 +1474,9 @@ OUString SdrDragMove::GetSdrDragComment() const { OUString aStr = ImpGetDescriptionStr(STR_DragMethMove) + " (x=" - + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDX()) + + getSdrDragView().GetModel().GetMetricString(DragStat().GetDX()) + " y=" - + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDY()) + + getSdrDragView().GetModel().GetMetricString(DragStat().GetDY()) + ")"; if(getSdrDragView().IsDragWithCopy()) @@ -3352,7 +3352,7 @@ bool SdrDragCrook::EndSdrDrag(bool bCopy) Size aSiz(aCtr1.X()-aCtr0.X(),aCtr1.Y()-aCtr0.Y()); if( bUndo ) - AddUndo(getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,aSiz)); + AddUndo(getSdrDragView().GetModel().GetSdrUndoFactory().CreateUndoMoveObject(*pO,aSiz)); pO->Move(aSiz); } } @@ -3393,9 +3393,9 @@ OUString SdrDragDistort::GetSdrDragComment() const { OUString aStr = ImpGetDescriptionStr(STR_DragMethDistort) + " (x=" - + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDX()) + + getSdrDragView().GetModel().GetMetricString(DragStat().GetDX()) + " y=" - + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDY()) + + getSdrDragView().GetModel().GetMetricString(DragStat().GetDY()) + ")"; if(getSdrDragView().IsDragWithCopy()) @@ -3538,9 +3538,9 @@ OUString SdrDragCrop::GetSdrDragComment() const { OUString aStr = ImpGetDescriptionStr(STR_DragMethCrop) + " (x=" - + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDX()) + + getSdrDragView().GetModel().GetMetricString(DragStat().GetDX()) + " y=" - + getSdrDragView().GetModel()->GetMetricString(DragStat().GetDY()) + + getSdrDragView().GetModel().GetMetricString(DragStat().GetDY()) + ")"; if(getSdrDragView().IsDragWithCopy()) @@ -3625,9 +3625,9 @@ bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/) OUString aUndoStr = ImpGetDescriptionStr(STR_DragMethCrop); getSdrDragView().BegUndo( aUndoStr ); - getSdrDragView().AddUndo( getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); + getSdrDragView().AddUndo(getSdrDragView().GetModel().GetSdrUndoFactory().CreateUndoGeoObject(*pObj)); // also need attr undo, the SdrGrafCropItem will be changed - getSdrDragView().AddUndo( getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); + getSdrDragView().AddUndo(getSdrDragView().GetModel().GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); } // get the original objects transformation @@ -3839,7 +3839,7 @@ bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/) sal_Int32 nRightCrop = static_cast<sal_Int32>( rOldCrop.GetRight() - nDiffRight * fScaleX ); sal_Int32 nBottomCrop = static_cast<sal_Int32>( rOldCrop.GetBottom() - nDiffBottom * fScaleY ); - SfxItemPool& rPool = getSdrDragView().GetModel()->GetItemPool(); + SfxItemPool& rPool = getSdrDragView().GetModel().GetItemPool(); SfxItemSetFixed<SDRATTR_GRAFCROP, SDRATTR_GRAFCROP> aSet( rPool ); aSet.Put( SdrGrafCropItem( nLeftCrop, nTopCrop, nRightCrop, nBottomCrop ) ); getSdrDragView().SetAttributes( aSet, false ); |