diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-13 10:20:59 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-13 15:46:47 +0200 |
commit | 1b1afc10f4d90e37c5e81961b8b8902133e65b00 (patch) | |
tree | fb6f68d743b334b8df4fc374afe68dc49fd6cbb8 /svx | |
parent | cc233992dfe0fa9732c24774852d037d161546ce (diff) |
Fraction: make conversion operators and constructor explicit
and simplify some of the calculations that needed to be changed.
Which resulted in one unit test needing to change by one pixel,
let's hope not an indication of a real problem.
Change-Id: Ie56434f35f4e58d21ee6f671392e93dc7542fca3
Reviewed-on: https://gerrit.libreoffice.org/42240
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/form/fmvwimp.cxx | 4 | ||||
-rw-r--r-- | svx/source/sidebar/possize/PosSizePropertyPanel.cxx | 30 | ||||
-rw-r--r-- | svx/source/svdraw/svddrgmt.cxx | 9 | ||||
-rw-r--r-- | svx/source/svdraw/svdoole2.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svdsnpv.cxx | 4 |
5 files changed, 24 insertions, 31 deletions
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index b7d6d5750271..e6dbcd631a71 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -1478,8 +1478,8 @@ SdrObject* FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_ const sal_uInt16 nObjID = OBJ_FM_BUTTON; ::Size controlSize(4000, 500); FmFormObj *pControl = static_cast<FmFormObj*>(SdrObjFactory::MakeNewObject( SdrInventor::FmForm, nObjID, nullptr )); - controlSize.Width() = Fraction(controlSize.Width(), 1) * eTargetMode.GetScaleX(); - controlSize.Height() = Fraction(controlSize.Height(), 1) * eTargetMode.GetScaleY(); + controlSize.Width() = long(controlSize.Width() * eTargetMode.GetScaleX()); + controlSize.Height() = long(controlSize.Height() * eTargetMode.GetScaleY()); ::Point controlPos( OutputDevice::LogicToLogic( ::Point( controlSize.Width(), 0 ), eSourceMode, eTargetMode ) ); ::tools::Rectangle controlRect( controlPos, OutputDevice::LogicToLogic( controlSize, eSourceMode, eTargetMode ) ); pControl->SetLogicRect(controlRect); diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx index 37d132d6ea01..ab27b80cdc68 100644 --- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx +++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx @@ -370,7 +370,7 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosXHdl, Edit&, void ) Fraction aUIScale = mpView->GetModel()->GetUIScale(); lX += maAnchorPos.X(); - lX = Fraction( lX ) * aUIScale; + lX = long( lX * aUIScale ); SfxInt32Item aPosXItem( SID_ATTR_TRANSFORM_POS_X,(sal_uInt32) lX); @@ -388,7 +388,7 @@ IMPL_LINK_NOARG( PosSizePropertyPanel, ChangePosYHdl, Edit&, void ) Fraction aUIScale = mpView->GetModel()->GetUIScale(); lY += maAnchorPos.Y(); - lY = Fraction( lY ) * aUIScale; + lY = long( lY * aUIScale ); SfxInt32Item aPosYItem( SID_ATTR_TRANSFORM_POS_Y,(sal_uInt32) lY); @@ -530,12 +530,10 @@ void PosSizePropertyPanel::NotifyItemUpdate( if(pWidthItem) { - long mlOldWidth1 = pWidthItem->GetValue(); - - mlOldWidth1 = Fraction( mlOldWidth1 ) / maUIScale; + long lOldWidth1 = long( pWidthItem->GetValue() / maUIScale ); SetFieldUnit( *mpMtrWidth, meDlgUnit, true ); - SetMetricValue( *mpMtrWidth, mlOldWidth1, mePoolUnit ); - mlOldWidth = mlOldWidth1; + SetMetricValue( *mpMtrWidth, lOldWidth1, mePoolUnit ); + mlOldWidth = lOldWidth1; break; } } @@ -550,12 +548,10 @@ void PosSizePropertyPanel::NotifyItemUpdate( if(pHeightItem) { - long mlOldHeight1 = pHeightItem->GetValue(); - - mlOldHeight1 = Fraction( mlOldHeight1 ) / maUIScale; + long nTmp = long( pHeightItem->GetValue() / maUIScale); SetFieldUnit( *mpMtrHeight, meDlgUnit, true ); - SetMetricValue( *mpMtrHeight, mlOldHeight1, mePoolUnit ); - mlOldHeight = mlOldHeight1; + SetMetricValue( *mpMtrHeight, nTmp, mePoolUnit ); + mlOldHeight = nTmp; break; } } @@ -570,8 +566,7 @@ void PosSizePropertyPanel::NotifyItemUpdate( if(pItem) { - long nTmp = pItem->GetValue(); - nTmp = Fraction( nTmp ) / maUIScale; + long nTmp = long(pItem->GetValue() / maUIScale); SetFieldUnit( *mpMtrPosX, meDlgUnit, true ); SetMetricValue( *mpMtrPosX, nTmp, mePoolUnit ); break; @@ -588,8 +583,7 @@ void PosSizePropertyPanel::NotifyItemUpdate( if(pItem) { - long nTmp = pItem->GetValue(); - nTmp = Fraction( nTmp ) / maUIScale; + long nTmp = long(pItem->GetValue() / maUIScale); SetFieldUnit( *mpMtrPosY, meDlgUnit, true ); SetMetricValue( *mpMtrPosY, nTmp, mePoolUnit ); break; @@ -607,7 +601,7 @@ void PosSizePropertyPanel::NotifyItemUpdate( if(pItem) { mlRotX = pItem->GetValue(); - mlRotX = Fraction( mlRotX ) / maUIScale; + mlRotX = long( mlRotX / maUIScale ); } } break; @@ -620,7 +614,7 @@ void PosSizePropertyPanel::NotifyItemUpdate( if(pItem) { mlRotY = pItem->GetValue(); - mlRotY = Fraction( mlRotY ) / maUIScale; + mlRotY = long( mlRotY / maUIScale ); } } break; diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index 6fbc665a76b4..ecb7800273f3 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -1835,7 +1835,7 @@ basegfx::B2DHomMatrix SdrDragResize::getCurrentTransformation() { basegfx::B2DHomMatrix aRetval(basegfx::tools::createTranslateB2DHomMatrix( -DragStat().Ref1().X(), -DragStat().Ref1().Y())); - aRetval.scale(aXFact, aYFact); + aRetval.scale(double(aXFact), double(aYFact)); aRetval.translate(DragStat().Ref1().X(), DragStat().Ref1().Y()); return aRetval; @@ -2268,12 +2268,12 @@ basegfx::B2DHomMatrix SdrDragShear::getCurrentTransformation() { if (bVertical) { - aRetval.scale(aFact, 1.0); + aRetval.scale(double(aFact), 1.0); aRetval.shearY(-nTan); } else { - aRetval.scale(1.0, aFact); + aRetval.scale(1.0, double(aFact)); aRetval.shearX(-nTan); } } @@ -2371,8 +2371,7 @@ void SdrDragShear::MoveSdrDrag(const Point& rPnt) if (bUpSideDown) nNewAngle-=18000; if (bNeg) nTmpAngle=-nTmpAngle; bResize=true; - double nCos=cos(nTmpAngle*nPi180); - aNeuFact=nCos; + aNeuFact = cos(nTmpAngle*nPi180); aFact.ReduceInaccurate(10); // three decimals should be enough } diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 2150d636f922..625f9ea1fd9a 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -176,8 +176,8 @@ tools::Rectangle SdrLightEmbeddedClient_Impl::impl_getScaledRect_nothrow() const { tools::Rectangle aLogicRect( mpObj->GetLogicRect() ); // apply scaling to object area and convert to pixels - aLogicRect.SetSize( Size( Fraction( aLogicRect.GetWidth() ) * m_aScaleWidth, - Fraction( aLogicRect.GetHeight() ) * m_aScaleHeight ) ); + aLogicRect.SetSize( Size( long( aLogicRect.GetWidth() * m_aScaleWidth), + long( aLogicRect.GetHeight() * m_aScaleHeight) ) ); return aLogicRect; } @@ -497,8 +497,8 @@ void SAL_CALL SdrLightEmbeddedClient_Impl::changedPlacement( const awt::Rectangl //SfxBooleanFlagGuard aGuard( m_bResizeNoScale, true ); // new size of the object area without scaling - Size aNewObjSize( Fraction( aNewLogicRect.GetWidth() ) / m_aScaleWidth, - Fraction( aNewLogicRect.GetHeight() ) / m_aScaleHeight ); + Size aNewObjSize( long( aNewLogicRect.GetWidth() / m_aScaleWidth ), + long( aNewLogicRect.GetHeight() / m_aScaleHeight ) ); // now remove scaling from new placement and keep this a the new object area aNewLogicRect.SetSize( aNewObjSize ); diff --git a/svx/source/svdraw/svdsnpv.cxx b/svx/source/svdraw/svdsnpv.cxx index 97b96ace2b6d..7a3113e88ea0 100644 --- a/svx/source/svdraw/svdsnpv.cxx +++ b/svx/source/svdraw/svdsnpv.cxx @@ -369,7 +369,7 @@ SdrSnap SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const } if(bGridSnap) { - double fSnapWidth = aSnapWdtX; + double fSnapWidth(aSnapWdtX); if(dx == NOT_SNAPPED && fSnapWidth != 0.0) { double fx = (double)x; @@ -384,7 +384,7 @@ SdrSnap SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const x = (long)((double)x * fSnapWidth + (double)pPV->GetPageOrigin().X()); dx = 0; } - fSnapWidth = aSnapWdtY; + fSnapWidth = double(aSnapWdtY); if(dy == NOT_SNAPPED && fSnapWidth) { double fy = (double)y; |