summaryrefslogtreecommitdiff
path: root/reportdesign/source/ui/report/StartMarker.cxx
diff options
context:
space:
mode:
authorJuan Picca <jumapico@gmail.com>2014-09-19 14:19:30 -0300
committerDavid Tardon <dtardon@redhat.com>2014-10-09 11:33:33 +0000
commit47a2d7642d249d70b5da0c330a73f3a0032e4bba (patch)
tree202b04810382ea87cf8015a7b4de29e931408948 /reportdesign/source/ui/report/StartMarker.cxx
parentae77dc81c33ab0817264bcf5fc8bb71a55b78a73 (diff)
fdo#81356: convert Fraction to boost::rational<long> - wip
* Added rational util functions used by Fraction class not available in the boost::rational class. * Replaced usage of Fraction by boost::rational<long> * Removed code that relies on: 1. fraction.IsValid() -- rational only allow valid values, ie denominator() != 0 2. rational.denominator() == 0 -- always false 3. rational.denominator() < 0 -- always false but implementation detail: http://www.boost.org/doc/libs/release/libs/rational/rational.html#Internal%20representation * Simplified code that relies on: 1. rational.denominator() != 0 -- always true * BUGS EXIST because Fraction allows the creation of invalid values but boost::rational throws the exception boost::bad_rational Change-Id: I84970a4956afb3f91ac0c8f726547466319420f9 Reviewed-on: https://gerrit.libreoffice.org/11551 Reviewed-by: David Tardon <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'reportdesign/source/ui/report/StartMarker.cxx')
-rw-r--r--reportdesign/source/ui/report/StartMarker.cxx20
1 files changed, 10 insertions, 10 deletions
diff --git a/reportdesign/source/ui/report/StartMarker.cxx b/reportdesign/source/ui/report/StartMarker.cxx
index a1a3f30944d2..bc7fc19a6efd 100644
--- a/reportdesign/source/ui/report/StartMarker.cxx
+++ b/reportdesign/source/ui/report/StartMarker.cxx
@@ -89,9 +89,9 @@ OStartMarker::~OStartMarker()
sal_Int32 OStartMarker::getMinHeight() const
{
- Fraction aExtraWidth(long(2*REPORT_EXTRA_SPACE));
+ boost::rational<long> aExtraWidth(long(2*REPORT_EXTRA_SPACE));
aExtraWidth *= GetMapMode().GetScaleX();
- return LogicToPixel(Size(0,m_aText.GetTextHeight())).Height() + (long)aExtraWidth;
+ return LogicToPixel(Size(0,m_aText.GetTextHeight())).Height() + boost::rational_cast<long>(aExtraWidth);
}
void OStartMarker::Paint( const Rectangle& rRect )
@@ -99,7 +99,7 @@ void OStartMarker::Paint( const Rectangle& rRect )
(void)rRect;
Size aSize = GetOutputSizePixel();
long nSize = aSize.Width();
- const long nCornerWidth = long(CORNER_SPACE * (double)GetMapMode().GetScaleX());
+ const long nCornerWidth = long(CORNER_SPACE * boost::rational_cast<double>(GetMapMode().GetScaleX()));
if ( isCollapsed() )
{
@@ -134,7 +134,7 @@ void OStartMarker::Paint( const Rectangle& rRect )
}
if ( m_bMarked )
{
- const long nCornerHeight = long(CORNER_SPACE * (double)GetMapMode().GetScaleY());
+ const long nCornerHeight = long(CORNER_SPACE * boost::rational_cast<double>(GetMapMode().GetScaleY()));
Rectangle aRect( Point(nCornerWidth,nCornerHeight),
Size(aSize.Width() - nCornerWidth - nCornerWidth,aSize.Height() - nCornerHeight - nCornerHeight));
ColorChanger aColors( this, COL_WHITE, COL_WHITE );
@@ -218,17 +218,17 @@ void OStartMarker::Resize()
Size aImageSize = m_aImage.GetImage().GetSizePixel();
const MapMode& rMapMode = GetMapMode();
- aImageSize.Width() = long(aImageSize.Width() * (double)rMapMode.GetScaleX());
- aImageSize.Height() = long(aImageSize.Height() * (double)rMapMode.GetScaleY());
+ aImageSize.Width() = long(aImageSize.Width() * boost::rational_cast<double>(rMapMode.GetScaleX()));
+ aImageSize.Height() = long(aImageSize.Height() * boost::rational_cast<double>(rMapMode.GetScaleY()));
- Fraction aExtraWidth(long(REPORT_EXTRA_SPACE));
+ boost::rational<long> aExtraWidth(long(REPORT_EXTRA_SPACE));
aExtraWidth *= rMapMode.GetScaleX();
- Point aPos(aImageSize.Width() + (long)(aExtraWidth + aExtraWidth), aExtraWidth);
+ Point aPos(aImageSize.Width() + boost::rational_cast<long>((aExtraWidth + aExtraWidth)), boost::rational_cast<long>(aExtraWidth));
const long nHeight = ::std::max<sal_Int32>(nOutputHeight - 2*aPos.Y(),LogicToPixel(Size(0,m_aText.GetTextHeight())).Height());
m_aText.SetPosSizePixel(aPos,Size(aRulerPos.X() - aPos.X(),nHeight));
- aPos.X() = aExtraWidth;
+ aPos.X() = boost::rational_cast<long>(aExtraWidth);
aPos.Y() += static_cast<sal_Int32>((LogicToPixel(Size(0,m_aText.GetTextHeight())).Height() - aImageSize.Height()) * 0.5) ;
m_aImage.SetPosSizePixel(aPos,aImageSize);
}
@@ -281,7 +281,7 @@ void OStartMarker::setCollapsed(bool _bCollapsed)
changeImage();
}
-void OStartMarker::zoom(const Fraction& _aZoom)
+void OStartMarker::zoom(const boost::rational<long>& _aZoom)
{
setZoomFactor(_aZoom,*this);
m_aVRuler.SetZoom(_aZoom);