summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-13 10:20:59 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-13 15:46:47 +0200
commit1b1afc10f4d90e37c5e81961b8b8902133e65b00 (patch)
treefb6f68d743b334b8df4fc374afe68dc49fd6cbb8 /sd
parentcc233992dfe0fa9732c24774852d037d161546ce (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 'sd')
-rw-r--r--sd/source/ui/dlg/copydlg.cxx34
-rw-r--r--sd/source/ui/dlg/dlgsnap.cxx16
-rw-r--r--sd/source/ui/tools/PreviewRenderer.cxx8
-rw-r--r--sd/source/ui/view/drviewsa.cxx20
4 files changed, 39 insertions, 39 deletions
diff --git a/sd/source/ui/dlg/copydlg.cxx b/sd/source/ui/dlg/copydlg.cxx
index 69a8e7e6922b..d957d1706aa8 100644
--- a/sd/source/ui/dlg/copydlg.cxx
+++ b/sd/source/ui/dlg/copydlg.cxx
@@ -127,7 +127,7 @@ void CopyDlg::Reset()
// Set Min/Max values
::tools::Rectangle aRect = mpView->GetAllMarkedRect();
Size aPageSize = mpView->GetSdrPageView()->GetPage()->GetSize();
- SetMetricValue( *m_pMtrFldMoveX, Fraction(1000000) / maUIScale, MapUnit::Map100thMM);
+ SetMetricValue( *m_pMtrFldMoveX, long(1000000 / maUIScale), MapUnit::Map100thMM);
double fScaleFactor = m_pMtrFldMoveX->GetValue()/1000000.0;
long nPageWidth = aPageSize.Width() * fScaleFactor;
@@ -156,12 +156,12 @@ void CopyDlg::Reset()
long nMoveX = 500;
if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_MOVE_X, true, &pPoolItem ) )
nMoveX = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue();
- SetMetricValue( *m_pMtrFldMoveX, Fraction(nMoveX) / maUIScale, MapUnit::Map100thMM);
+ SetMetricValue( *m_pMtrFldMoveX, long(nMoveX / maUIScale), MapUnit::Map100thMM);
long nMoveY = 500;
if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_MOVE_Y, true, &pPoolItem ) )
nMoveY = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue();
- SetMetricValue( *m_pMtrFldMoveY, Fraction(nMoveY) / maUIScale, MapUnit::Map100thMM);
+ SetMetricValue( *m_pMtrFldMoveY, long(nMoveY / maUIScale), MapUnit::Map100thMM);
if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_ANGLE, true, &pPoolItem ) )
m_pMtrFldAngle->SetValue( static_cast<const SfxInt32Item*>( pPoolItem )->GetValue() );
@@ -171,12 +171,12 @@ void CopyDlg::Reset()
long nWidth = 0;
if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_WIDTH, true, &pPoolItem ) )
nWidth = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue();
- SetMetricValue( *m_pMtrFldWidth, Fraction(nWidth) / maUIScale, MapUnit::Map100thMM);
+ SetMetricValue( *m_pMtrFldWidth, long(nWidth / maUIScale), MapUnit::Map100thMM);
long nHeight = 0;
if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_HEIGHT, true, &pPoolItem ) )
nHeight = static_cast<const SfxInt32Item*>( pPoolItem )->GetValue();
- SetMetricValue( *m_pMtrFldHeight, Fraction(nHeight) / maUIScale, MapUnit::Map100thMM);
+ SetMetricValue( *m_pMtrFldHeight, long(nHeight / maUIScale), MapUnit::Map100thMM);
if( SfxItemState::SET == mrOutAttrs.GetItemState( ATTR_COPY_START_COLOR, true, &pPoolItem ) )
{
@@ -227,10 +227,10 @@ void CopyDlg::Reset()
*/
void CopyDlg::GetAttr( SfxItemSet& rOutAttrs )
{
- long nMoveX = Fraction( GetCoreValue( *m_pMtrFldMoveX, MapUnit::Map100thMM) ) * maUIScale;
- long nMoveY = Fraction( GetCoreValue( *m_pMtrFldMoveY, MapUnit::Map100thMM) ) * maUIScale;
- long nHeight = Fraction( GetCoreValue( *m_pMtrFldHeight, MapUnit::Map100thMM) ) * maUIScale;
- long nWidth = Fraction( GetCoreValue( *m_pMtrFldWidth, MapUnit::Map100thMM) ) * maUIScale;
+ long nMoveX = long( GetCoreValue( *m_pMtrFldMoveX, MapUnit::Map100thMM) * maUIScale);
+ long nMoveY = long( GetCoreValue( *m_pMtrFldMoveY, MapUnit::Map100thMM) * maUIScale);
+ long nHeight = long( GetCoreValue( *m_pMtrFldHeight, MapUnit::Map100thMM) * maUIScale);
+ long nWidth = long( GetCoreValue( *m_pMtrFldWidth, MapUnit::Map100thMM) * maUIScale);
rOutAttrs.Put( SfxUInt16Item( ATTR_COPY_NUMBER, (sal_uInt16) m_pNumFldCopies->GetValue() ) );
rOutAttrs.Put( SfxInt32Item( ATTR_COPY_MOVE_X, nMoveX ) );
@@ -267,10 +267,10 @@ IMPL_LINK_NOARG(CopyDlg, SetViewData, Button*, void)
{
::tools::Rectangle aRect = mpView->GetAllMarkedRect();
- SetMetricValue( *m_pMtrFldMoveX, Fraction( aRect.GetWidth() ) /
- maUIScale, MapUnit::Map100thMM);
- SetMetricValue( *m_pMtrFldMoveY, Fraction( aRect.GetHeight() ) /
- maUIScale, MapUnit::Map100thMM);
+ SetMetricValue( *m_pMtrFldMoveX, long( aRect.GetWidth() /
+ maUIScale ), MapUnit::Map100thMM);
+ SetMetricValue( *m_pMtrFldMoveY, long( aRect.GetHeight() /
+ maUIScale ), MapUnit::Map100thMM);
// sets color attribute
const SfxPoolItem* pPoolItem = nullptr;
@@ -289,13 +289,13 @@ IMPL_LINK_NOARG(CopyDlg, SetDefault, Button*, void)
m_pNumFldCopies->SetValue( 1 );
long nValue = 500;
- SetMetricValue( *m_pMtrFldMoveX, Fraction(nValue) / maUIScale, MapUnit::Map100thMM);
- SetMetricValue( *m_pMtrFldMoveY, Fraction(nValue) / maUIScale, MapUnit::Map100thMM);
+ SetMetricValue( *m_pMtrFldMoveX, long(nValue / maUIScale), MapUnit::Map100thMM);
+ SetMetricValue( *m_pMtrFldMoveY, long(nValue / maUIScale), MapUnit::Map100thMM);
nValue = 0;
m_pMtrFldAngle->SetValue( nValue );
- SetMetricValue( *m_pMtrFldWidth, Fraction(nValue) / maUIScale, MapUnit::Map100thMM);
- SetMetricValue( *m_pMtrFldHeight, Fraction(nValue) / maUIScale, MapUnit::Map100thMM);
+ SetMetricValue( *m_pMtrFldWidth, long(nValue / maUIScale), MapUnit::Map100thMM);
+ SetMetricValue( *m_pMtrFldHeight, long(nValue / maUIScale), MapUnit::Map100thMM);
// set color attribute
const SfxPoolItem* pPoolItem = nullptr;
diff --git a/sd/source/ui/dlg/dlgsnap.cxx b/sd/source/ui/dlg/dlgsnap.cxx
index a46a1f040c11..231a654df18f 100644
--- a/sd/source/ui/dlg/dlgsnap.cxx
+++ b/sd/source/ui/dlg/dlgsnap.cxx
@@ -78,33 +78,33 @@ SdSnapLineDlg::SdSnapLineDlg(
SetMetricValue( *m_pMtrFldX, aLeftTop.X(), ePoolUnit );
long nValue = static_cast<long>(m_pMtrFldX->GetValue());
- nValue = Fraction( nValue ) / aUIScale;
+ nValue = long( nValue / aUIScale);
m_pMtrFldX->SetMin( nValue );
m_pMtrFldX->SetFirst( nValue );
SetMetricValue( *m_pMtrFldX, aRightBottom.X(), ePoolUnit );
nValue = static_cast<long>(m_pMtrFldX->GetValue());
- nValue = Fraction( nValue ) / aUIScale;
+ nValue = long( nValue / aUIScale);
m_pMtrFldX->SetMax( nValue );
m_pMtrFldX->SetLast( nValue );
SetMetricValue( *m_pMtrFldY, aLeftTop.Y(), ePoolUnit );
nValue = static_cast<long>(m_pMtrFldY->GetValue());
- nValue = Fraction( nValue ) / aUIScale;
+ nValue = long( nValue / aUIScale);
m_pMtrFldY->SetMin( nValue );
m_pMtrFldY->SetFirst( nValue );
SetMetricValue( *m_pMtrFldY, aRightBottom.Y(), ePoolUnit );
nValue = static_cast<long>(m_pMtrFldY->GetValue());
- nValue = Fraction( nValue ) / aUIScale;
+ nValue = long( nValue / aUIScale);
m_pMtrFldY->SetMax( nValue );
m_pMtrFldY->SetLast( nValue );
// set values
nXValue = static_cast<const SfxInt32Item&>( rInAttrs.Get(ATTR_SNAPLINE_X)).GetValue();
nYValue = static_cast<const SfxInt32Item&>( rInAttrs.Get(ATTR_SNAPLINE_Y)).GetValue();
- nXValue = Fraction(nXValue) / aUIScale;
- nYValue = Fraction(nYValue) / aUIScale;
+ nXValue = long(nXValue / aUIScale);
+ nYValue = long(nYValue / aUIScale);
SetMetricValue( *m_pMtrFldX, nXValue, MapUnit::Map100thMM);
SetMetricValue( *m_pMtrFldY, nYValue, MapUnit::Map100thMM);
@@ -152,8 +152,8 @@ void SdSnapLineDlg::GetAttr(SfxItemSet& rOutAttrs)
else if ( m_pRbVert->IsChecked() ) eKind = SK_VERTICAL;
else eKind = SK_POINT;
- nXValue = Fraction( GetCoreValue( *m_pMtrFldX, MapUnit::Map100thMM) ) * aUIScale;
- nYValue = Fraction( GetCoreValue( *m_pMtrFldY, MapUnit::Map100thMM) ) * aUIScale;
+ nXValue = long( GetCoreValue( *m_pMtrFldX, MapUnit::Map100thMM) * aUIScale);
+ nYValue = long( GetCoreValue( *m_pMtrFldY, MapUnit::Map100thMM) * aUIScale);
rOutAttrs.Put(SfxAllEnumItem(ATTR_SNAPLINE_KIND, (sal_uInt16)eKind));
rOutAttrs.Put(SfxInt32Item(ATTR_SNAPLINE_X, nXValue));
diff --git a/sd/source/ui/tools/PreviewRenderer.cxx b/sd/source/ui/tools/PreviewRenderer.cxx
index a7e88b811363..63e06f4b79a3 100644
--- a/sd/source/ui/tools/PreviewRenderer.cxx
+++ b/sd/source/ui/tools/PreviewRenderer.cxx
@@ -374,8 +374,8 @@ void PreviewRenderer::SetupOutputSize (
{
// We should never get here.
OSL_ASSERT(false);
- aMapMode.SetScaleX(1.0);
- aMapMode.SetScaleY(1.0);
+ aMapMode.SetScaleX(Fraction(1.0));
+ aMapMode.SetScaleY(Fraction(1.0));
}
mpPreviewDevice->SetMapMode (aMapMode);
mpPreviewDevice->SetOutputSizePixel(rFramePixelSize);
@@ -443,8 +443,8 @@ Image PreviewRenderer::ScaleBitmap (
MapMode aMapMode (mpPreviewDevice->GetMapMode());
aMapMode.SetMapUnit(MapUnit::MapPixel);
aMapMode.SetOrigin (Point());
- aMapMode.SetScaleX (1.0);
- aMapMode.SetScaleY (1.0);
+ aMapMode.SetScaleX (Fraction(1.0));
+ aMapMode.SetScaleY (Fraction(1.0));
mpPreviewDevice->SetMapMode (aMapMode);
mpPreviewDevice->SetOutputSize (aFrameSize);
diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx
index 074ad05157b1..06ae7dae72b1 100644
--- a/sd/source/ui/view/drviewsa.cxx
+++ b/sd/source/ui/view/drviewsa.cxx
@@ -597,8 +597,8 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet)
Point aPos = GetActiveWindow()->PixelToLogic(maMousePos);
pPageView->LogicToPagePos(aPos);
Fraction aUIScale(GetDoc()->GetUIScale());
- aPos.X() = Fraction(aPos.X()) / aUIScale;
- aPos.Y() = Fraction(aPos.Y()) / aUIScale;
+ aPos.X() = long(aPos.X() / aUIScale);
+ aPos.Y() = long(aPos.Y() / aUIScale);
// position- and size items
if ( mpDrawView->IsAction() )
@@ -612,12 +612,12 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet)
{
pPageView->LogicToPagePos(aRect);
aPos = aRect.TopLeft();
- aPos.X() = Fraction(aPos.X()) / aUIScale;
- aPos.Y() = Fraction(aPos.Y()) / aUIScale;
+ aPos.X() = long(aPos.X() / aUIScale);
+ aPos.Y() = long(aPos.Y() / aUIScale);
rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos) );
Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
- aSize.Height() = Fraction(aSize.Height()) / aUIScale;
- aSize.Width() = Fraction(aSize.Width()) / aUIScale;
+ aSize.Height() = long(aSize.Height() / aUIScale);
+ aSize.Width() = long(aSize.Width() / aUIScale);
rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
}
}
@@ -630,13 +630,13 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet)
// Show the position of the selected shape(s)
Point aShapePosition (aRect.TopLeft());
- aShapePosition.X() = Fraction(aShapePosition.X()) / aUIScale;
- aShapePosition.Y() = Fraction(aShapePosition.Y()) / aUIScale;
+ aShapePosition.X() = long(aShapePosition.X() / aUIScale);
+ aShapePosition.Y() = long(aShapePosition.Y() / aUIScale);
rSet.Put (SfxPointItem(SID_ATTR_POSITION, aShapePosition));
Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
- aSize.Height() = Fraction(aSize.Height()) / aUIScale;
- aSize.Width() = Fraction(aSize.Width()) / aUIScale;
+ aSize.Height() = long(aSize.Height() / aUIScale);
+ aSize.Width() = long(aSize.Width() / aUIScale);
rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
}
else