summaryrefslogtreecommitdiff
path: root/vcl/source/window
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 /vcl/source/window
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 'vcl/source/window')
-rw-r--r--vcl/source/window/window.cxx2
-rw-r--r--vcl/source/window/window2.cxx26
2 files changed, 14 insertions, 14 deletions
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 8b52d5c5804e..be0e35cd1613 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -572,7 +572,7 @@ Window::~Window()
WindowImpl::WindowImpl( WindowType nType )
{
- maZoom = Fraction( 1, 1 );
+ maZoom = boost::rational<long>( 1, 1 );
maWinRegion = vcl::Region(true);
maWinClipRegion = vcl::Region(true);
mpWinData = NULL; // Extra Window Data, that we dont need for all windows
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 48faf1f2f8f7..f3588f59e548 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -507,7 +507,7 @@ bool Window::EndSaveFocus( sal_uIntPtr nSaveId, bool bRestore )
}
}
-void Window::SetZoom( const Fraction& rZoom )
+void Window::SetZoom( const boost::rational<long>& rZoom )
{
if ( mpWindowImpl->maZoom != rZoom )
{
@@ -523,18 +523,18 @@ inline long WinFloatRound( double fVal )
void Window::SetZoomedPointFont( const vcl::Font& rFont )
{
- const Fraction& rZoom = GetZoom();
- if ( rZoom.GetNumerator() != rZoom.GetDenominator() )
+ const boost::rational<long>& rZoom = GetZoom();
+ if ( rZoom.numerator() != rZoom.denominator() )
{
vcl::Font aFont( rFont );
Size aSize = aFont.GetSize();
double n = (double)aSize.Width();
- n *= (double)rZoom.GetNumerator();
- n /= (double)rZoom.GetDenominator();
+ n *= (double)rZoom.numerator();
+ n /= (double)rZoom.denominator();
aSize.Width() = WinFloatRound( n );
n = (double)aSize.Height();
- n *= (double)rZoom.GetNumerator();
- n /= (double)rZoom.GetDenominator();
+ n *= (double)rZoom.numerator();
+ n /= (double)rZoom.denominator();
aSize.Height() = WinFloatRound( n );
aFont.SetSize( aSize );
SetPointFont( aFont );
@@ -562,12 +562,12 @@ void Window::SetZoomedPointFont( const vcl::Font& rFont )
long Window::CalcZoom( long nCalc ) const
{
- const Fraction& rZoom = GetZoom();
- if ( rZoom.GetNumerator() != rZoom.GetDenominator() )
+ const boost::rational<long>& rZoom = GetZoom();
+ if ( rZoom.numerator() != rZoom.denominator() )
{
double n = (double)nCalc;
- n *= (double)rZoom.GetNumerator();
- n /= (double)rZoom.GetDenominator();
+ n *= (double)rZoom.numerator();
+ n /= (double)rZoom.denominator();
nCalc = WinFloatRound( n );
}
return nCalc;
@@ -1318,14 +1318,14 @@ vcl::Cursor* Window::GetCursor() const
return mpWindowImpl->mpCursor;
}
-const Fraction& Window::GetZoom() const
+const boost::rational<long>& Window::GetZoom() const
{
return mpWindowImpl->maZoom;
}
bool Window::IsZoom() const
{
- return mpWindowImpl->maZoom.GetNumerator() != mpWindowImpl->maZoom.GetDenominator();
+ return mpWindowImpl->maZoom.numerator() != mpWindowImpl->maZoom.denominator();
}
void Window::SetHelpText( const OUString& rHelpText )