summaryrefslogtreecommitdiff
path: root/sfx2/source
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 /sfx2/source
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 'sfx2/source')
-rw-r--r--sfx2/source/doc/objembed.cxx8
-rw-r--r--sfx2/source/view/ipclient.cxx40
-rw-r--r--sfx2/source/view/viewfrm2.cxx2
-rw-r--r--sfx2/source/view/viewsh.cxx4
4 files changed, 27 insertions, 27 deletions
diff --git a/sfx2/source/doc/objembed.cxx b/sfx2/source/doc/objembed.cxx
index 1ce7b6717fdb..d491b702f9d4 100644
--- a/sfx2/source/doc/objembed.cxx
+++ b/sfx2/source/doc/objembed.cxx
@@ -180,8 +180,8 @@ void SfxObjectShell::DoDraw( OutputDevice* pDev,
aSize = pDev->LogicToLogic( aSize, &aWilliMode, &aMod );
if( aSize.Width() && aSize.Height() )
{
- Fraction aXF( rSize.Width(), aSize.Width() );
- Fraction aYF( rSize.Height(), aSize.Height() );
+ boost::rational<long> aXF( rSize.Width(), aSize.Width() );
+ boost::rational<long> aYF( rSize.Height(), aSize.Height() );
DoDraw_Impl( pDev, rObjPos, aXF, aYF, rSetup, nAspect );
}
@@ -190,8 +190,8 @@ void SfxObjectShell::DoDraw( OutputDevice* pDev,
void SfxObjectShell::DoDraw_Impl( OutputDevice* pDev,
const Point & rViewPos,
- const Fraction & rScaleX,
- const Fraction & rScaleY,
+ const boost::rational<long>& rScaleX,
+ const boost::rational<long>& rScaleY,
const JobSetup & rSetup,
sal_uInt16 nAspect )
{
diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx
index ef03157900e2..ea49352d9f11 100644
--- a/sfx2/source/view/ipclient.cxx
+++ b/sfx2/source/view/ipclient.cxx
@@ -56,7 +56,7 @@
#include <toolkit/awt/vclxwindow.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <toolkit/helper/convert.hxx>
-#include <tools/fract.hxx>
+#include <tools/rational.hxx>
#include <tools/gen.hxx>
#include <svl/rectitem.hxx>
#include <svtools/soerr.hxx>
@@ -99,8 +99,8 @@ class SfxInPlaceClient_Impl : public ::cppu::WeakImplHelper5< embed::XEmbeddedCl
public:
Timer m_aTimer; // activation timeout, starts after object connection
Rectangle m_aObjArea; // area of object in coordinate system of the container (without scaling)
- Fraction m_aScaleWidth; // scaling that was applied to the object when it was not active
- Fraction m_aScaleHeight;
+ boost::rational<long> m_aScaleWidth; // scaling that was applied to the object when it was not active
+ boost::rational<long> m_aScaleHeight;
SfxInPlaceClient* m_pClient;
sal_Int64 m_nAspect; // ViewAspect that is assigned from the container
Rectangle m_aLastObjAreaPixel; // area of object in coordinate system of the container (without scaling)
@@ -427,8 +427,8 @@ awt::Rectangle SAL_CALL SfxInPlaceClient_Impl::getPlacement()
// apply scaling to object area and convert to pixels
Rectangle aRealObjArea( m_aObjArea );
- aRealObjArea.SetSize( Size( Fraction( aRealObjArea.GetWidth() ) * m_aScaleWidth,
- Fraction( aRealObjArea.GetHeight() ) * m_aScaleHeight ) );
+ aRealObjArea.SetSize( Size( boost::rational_cast<long>( aRealObjArea.GetWidth() * m_aScaleWidth ),
+ boost::rational_cast<long>( aRealObjArea.GetHeight() * m_aScaleHeight ) ) );
aRealObjArea = m_pClient->GetEditWin()->LogicToPixel( aRealObjArea );
return AWTRectangle( aRealObjArea );
@@ -444,8 +444,8 @@ awt::Rectangle SAL_CALL SfxInPlaceClient_Impl::getClipRectangle()
// currently(?) same as placement
Rectangle aRealObjArea( m_aObjArea );
- aRealObjArea.SetSize( Size( Fraction( aRealObjArea.GetWidth() ) * m_aScaleWidth,
- Fraction( aRealObjArea.GetHeight() ) * m_aScaleHeight ) );
+ aRealObjArea.SetSize( Size( boost::rational_cast<long>( aRealObjArea.GetWidth() * m_aScaleWidth ),
+ boost::rational_cast<long>( aRealObjArea.GetHeight() * m_aScaleHeight ) ) );
aRealObjArea = m_pClient->GetEditWin()->LogicToPixel( aRealObjArea );
return AWTRectangle( aRealObjArea );
@@ -507,8 +507,8 @@ void SAL_CALL SfxInPlaceClient_Impl::changedPlacement( const awt::Rectangle& aPo
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( boost::rational_cast<long>( aNewLogicRect.GetWidth() / m_aScaleWidth ),
+ boost::rational_cast<long>( aNewLogicRect.GetHeight() / m_aScaleHeight ) );
// now remove scaling from new placement and keep this a the new object area
aNewLogicRect.SetSize( aNewObjSize );
@@ -615,7 +615,7 @@ SfxInPlaceClient::SfxInPlaceClient( SfxViewShell* pViewShell, vcl::Window *pDraw
m_pImp->acquire();
m_pImp->m_pClient = this;
m_pImp->m_nAspect = nAspect;
- m_pImp->m_aScaleWidth = m_pImp->m_aScaleHeight = Fraction(1,1);
+ m_pImp->m_aScaleWidth = m_pImp->m_aScaleHeight = boost::rational<long>(1);
m_pImp->m_xClient = static_cast< embed::XEmbeddedClient* >( m_pImp );
pViewShell->NewIPClient_Impl(this);
m_pImp->m_aTimer.SetTimeout( SFX_CLIENTACTIVATE_TIMEOUT );
@@ -754,13 +754,13 @@ Rectangle SfxInPlaceClient::GetObjArea() const
Rectangle SfxInPlaceClient::GetScaledObjArea() const
{
Rectangle aRealObjArea( m_pImp->m_aObjArea );
- aRealObjArea.SetSize( Size( Fraction( aRealObjArea.GetWidth() ) * m_pImp->m_aScaleWidth,
- Fraction( aRealObjArea.GetHeight() ) * m_pImp->m_aScaleHeight ) );
+ aRealObjArea.SetSize( Size( boost::rational_cast<long>( aRealObjArea.GetWidth() * m_pImp->m_aScaleWidth ),
+ boost::rational_cast<long>( aRealObjArea.GetHeight() * m_pImp->m_aScaleHeight ) ) );
return aRealObjArea;
}
-void SfxInPlaceClient::SetSizeScale( const Fraction & rScaleWidth, const Fraction & rScaleHeight )
+void SfxInPlaceClient::SetSizeScale( const boost::rational<long>& rScaleWidth, const boost::rational<long>& rScaleHeight )
{
if ( m_pImp->m_aScaleWidth != rScaleWidth || m_pImp->m_aScaleHeight != rScaleHeight )
{
@@ -776,7 +776,7 @@ void SfxInPlaceClient::SetSizeScale( const Fraction & rScaleWidth, const Fractio
}
-bool SfxInPlaceClient::SetObjAreaAndScale( const Rectangle& rArea, const Fraction& rScaleWidth, const Fraction& rScaleHeight )
+bool SfxInPlaceClient::SetObjAreaAndScale( const Rectangle& rArea, const boost::rational<long>& rScaleWidth, const boost::rational<long>& rScaleHeight )
{
if( rArea != m_pImp->m_aObjArea || m_pImp->m_aScaleWidth != rScaleWidth || m_pImp->m_aScaleHeight != rScaleHeight )
{
@@ -794,13 +794,13 @@ bool SfxInPlaceClient::SetObjAreaAndScale( const Rectangle& rArea, const Fractio
}
-const Fraction& SfxInPlaceClient::GetScaleWidth() const
+const boost::rational<long>& SfxInPlaceClient::GetScaleWidth() const
{
return m_pImp->m_aScaleWidth;
}
-const Fraction& SfxInPlaceClient::GetScaleHeight() const
+const boost::rational<long>& SfxInPlaceClient::GetScaleHeight() const
{
return m_pImp->m_aScaleHeight;
}
@@ -812,8 +812,8 @@ void SfxInPlaceClient::Invalidate()
// the object area is provided in logical coordinates of the window but without scaling applied
Rectangle aRealObjArea( m_pImp->m_aObjArea );
- aRealObjArea.SetSize( Size( Fraction( aRealObjArea.GetWidth() ) * m_pImp->m_aScaleWidth,
- Fraction( aRealObjArea.GetHeight() ) * m_pImp->m_aScaleHeight ) );
+ aRealObjArea.SetSize( Size( boost::rational_cast<long>( aRealObjArea.GetWidth() * m_pImp->m_aScaleWidth ),
+ boost::rational_cast<long>( aRealObjArea.GetHeight() * m_pImp->m_aScaleHeight ) ) );
m_pEditWin->Invalidate( aRealObjArea );
ViewChanged();
@@ -955,8 +955,8 @@ ErrCode SfxInPlaceClient::DoVerb( long nVerb )
Rectangle aScaledArea = GetScaledObjArea();
m_pImp->m_aObjArea.SetSize( aNewSize );
- m_pImp->m_aScaleWidth = Fraction( aScaledArea.GetWidth(), aNewSize.Width() );
- m_pImp->m_aScaleHeight = Fraction( aScaledArea.GetHeight(), aNewSize.Height() );
+ m_pImp->m_aScaleWidth = boost::rational<long>( aScaledArea.GetWidth(), aNewSize.Width() );
+ m_pImp->m_aScaleHeight = boost::rational<long>( aScaledArea.GetHeight(), aNewSize.Height() );
}
}
catch (uno::Exception const& e)
diff --git a/sfx2/source/view/viewfrm2.cxx b/sfx2/source/view/viewfrm2.cxx
index 404a8b8ca1ff..60bee868f016 100644
--- a/sfx2/source/view/viewfrm2.cxx
+++ b/sfx2/source/view/viewfrm2.cxx
@@ -385,7 +385,7 @@ void SfxViewFrame::INetState_Impl( SfxItemSet &rItemSet )
rItemSet.DisableItem( SID_CREATELINK );
}
-void SfxViewFrame::SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY )
+void SfxViewFrame::SetZoomFactor( const boost::rational<long>& rZoomX, const boost::rational<long>& rZoomY )
{
GetViewShell()->SetZoomFactor( rZoomX, rZoomY );
}
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 35b947e5ee81..e82def5003f4 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -853,8 +853,8 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet )
-void SfxViewShell::SetZoomFactor( const Fraction &rZoomX,
- const Fraction &rZoomY )
+void SfxViewShell::SetZoomFactor( const boost::rational<long>& rZoomX,
+ const boost::rational<long>& rZoomY )
{
DBG_ASSERT( GetWindow(), "no window" );
MapMode aMap( GetWindow()->GetMapMode() );