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 /cui | |
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 'cui')
-rw-r--r-- | cui/source/tabpages/tpbitmap.cxx | 4 | ||||
-rw-r--r-- | cui/source/tabpages/transfrm.cxx | 22 |
2 files changed, 13 insertions, 13 deletions
diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx index b515d6bd9a36..390fe1c77112 100644 --- a/cui/source/tabpages/tpbitmap.cxx +++ b/cui/source/tabpages/tpbitmap.cxx @@ -260,7 +260,7 @@ void SvxBitmapTabPage::Reset( const SfxItemSet* rAttrs ) double fUIScale = 1.0; if (mpView) { - fUIScale = ( mpView->GetModel() ? double(mpView->GetModel()->GetUIScale()) : 1.0); + fUIScale = double(mpView->GetModel().GetUIScale()); if (mpView->AreObjectsMarked()) @@ -487,7 +487,7 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ModifyBitmapHdl, ValueSet*, void) { BitmapEx aBmpEx(pGraphicObject->GetGraphic().GetBitmapEx()); Size aTempBitmapSize = aBmpEx.GetSizePixel(); - const double fUIScale = ( (mpView && mpView->GetModel()) ? double(mpView->GetModel()->GetUIScale()) : 1.0); + const double fUIScale = mpView ? double(mpView->GetModel().GetUIScale()) : 1.0; Size aBitmapSize100mm = o3tl::convert(aTempBitmapSize, o3tl::Length::pt, o3tl::Length::mm100); rBitmapSize.setWidth(aBitmapSize100mm.Width() / fUIScale); diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx index c9fd14095b9d..40f54d302a3f 100644 --- a/cui/source/tabpages/transfrm.cxx +++ b/cui/source/tabpages/transfrm.cxx @@ -207,7 +207,7 @@ void SvxAngleTabPage::Construct() } // take scale into account - const Fraction aUIScale(pView->GetModel()->GetUIScale()); + const Fraction aUIScale(pView->GetModel().GetUIScale()); TransfrmHelper::ScaleRect(maRange, aUIScale); // take UI units into account @@ -227,7 +227,7 @@ bool SvxAngleTabPage::FillItemSet(SfxItemSet* rSet) if (m_xCtlAngle->IsValueModified() || m_xMtrPosX->get_value_changed_from_saved() || m_xMtrPosY->get_value_changed_from_saved()) { - const double fUIScale(double(pView->GetModel()->GetUIScale())); + const double fUIScale(double(pView->GetModel().GetUIScale())); const double fTmpX((GetCoreValue(*m_xMtrPosX, ePoolUnit) + maAnchor.getX()) * fUIScale); const double fTmpY((GetCoreValue(*m_xMtrPosY, ePoolUnit) + maAnchor.getY()) * fUIScale); @@ -244,7 +244,7 @@ bool SvxAngleTabPage::FillItemSet(SfxItemSet* rSet) void SvxAngleTabPage::Reset(const SfxItemSet* rAttrs) { - const double fUIScale(double(pView->GetModel()->GetUIScale())); + const double fUIScale(double(pView->GetModel().GetUIScale())); const SfxPoolItem* pItem = GetItem( *rAttrs, SID_ATTR_TRANSFORM_ROT_X ); if(pItem) @@ -430,7 +430,7 @@ bool SvxSlantTabPage::FillItemSet(SfxItemSet* rAttrs) if (m_xMtrRadius->get_value_changed_from_saved()) { - Fraction aUIScale = pView->GetModel()->GetUIScale(); + Fraction aUIScale = pView->GetModel().GetUIScale(); tools::Long nTmp = tools::Long(GetCoreValue(*m_xMtrRadius, ePoolUnit) * aUIScale); rAttrs->Put( makeSdrEckenradiusItem( nTmp ) ); @@ -561,7 +561,7 @@ void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) if( pItem ) { - const double fUIScale(double(pView->GetModel()->GetUIScale())); + const double fUIScale(double(pView->GetModel().GetUIScale())); const double fTmp(static_cast<double>(static_cast<const SdrMetricItem*>(pItem)->GetValue()) / fUIScale); SetMetricValue(*m_xMtrRadius, basegfx::fround(fTmp), ePoolUnit); } @@ -627,7 +627,7 @@ void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) *pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj())); //save geometry - const bool bOrigModelChangeState = pView->GetModel()->IsChanged(); + const bool bOrigModelChangeState = pView->GetModel().IsChanged(); SdrCustomShapeGeometryItem aInitialGeometry(rSdrObjCustomShape.GetMergedItem(SDRATTR_CUSTOMSHAPE_GEOMETRY)); EnhancedCustomShape2d aShape(rSdrObjCustomShape); @@ -671,7 +671,7 @@ void SvxSlantTabPage::Reset(const SfxItemSet* rAttrs) //restore geometry rSdrObjCustomShape.SetMergedItem(aInitialGeometry); - pView->GetModel()->SetChanged(bOrigModelChangeState); + pView->GetModel().SetChanged(bOrigModelChangeState); } for (int i = 0; i < 2; ++i) @@ -860,7 +860,7 @@ void SvxPositionSizeTabPage::Construct() } // take scale into account - const Fraction aUIScale(mpView->GetModel()->GetUIScale()); + const Fraction aUIScale(mpView->GetModel().GetUIScale()); TransfrmHelper::ScaleRect( maWorkRange, aUIScale ); TransfrmHelper::ScaleRect( maRange, aUIScale ); @@ -891,7 +891,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) { if (m_xMtrPosX->get_value_changed_from_saved() || m_xMtrPosY->get_value_changed_from_saved()) { - const double fUIScale(double(mpView->GetModel()->GetUIScale())); + const double fUIScale(double(mpView->GetModel().GetUIScale())); double fX((GetCoreValue( *m_xMtrPosX, mePoolUnit ) + maAnchor.getX()) * fUIScale); double fY((GetCoreValue( *m_xMtrPosY, mePoolUnit ) + maAnchor.getY()) * fUIScale); @@ -929,7 +929,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) if (m_xMtrWidth->get_value_changed_from_saved() || m_xMtrHeight->get_value_changed_from_saved()) { - Fraction aUIScale = mpView->GetModel()->GetUIScale(); + Fraction aUIScale = mpView->GetModel().GetUIScale(); // get Width double nWidth = static_cast<double>(m_xMtrWidth->get_value(FieldUnit::MM_100TH)); @@ -999,7 +999,7 @@ bool SvxPositionSizeTabPage::FillItemSet( SfxItemSet* rOutAttrs ) void SvxPositionSizeTabPage::Reset( const SfxItemSet* ) { const SfxPoolItem* pItem; - const double fUIScale(double(mpView->GetModel()->GetUIScale())); + const double fUIScale(double(mpView->GetModel().GetUIScale())); if ( !mbPageDisabled ) { |