From 7228086fe38b4edf03890a6b6e2b81746d28e542 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 15 Mar 2026 17:21:55 +0200 Subject: [PATCH] Fraction->double in CalculateNewScaling Change-Id: I701afaa206aec1c1ec83afd593035e2154de57df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201739 Reviewed-by: Noel Grandin Tested-by: Jenkins --- include/svx/svdoole2.hxx | 2 +- svx/source/svdraw/svdoole2.cxx | 33 +++++++++++++++------------------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx index 12b308ca21a1..5ec520fdd359 100644 --- a/include/svx/svdoole2.hxx +++ b/include/svx/svdoole2.hxx @@ -171,7 +171,7 @@ public: const OUString& aMediaType ); const css::uno::Reference< css::frame::XModel > & GetParentXModel() const; - bool CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize ); + bool CalculateNewScaling( double& aScaleWidth, double& aScaleHeight, Size& aObjAreaSize ); bool AddOwnLightClient(); // handy to get the empty replacement graphic without accessing all the old stuff diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 2f924f518b4c..a1bc4787d67a 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -113,22 +113,22 @@ class SdrLightEmbeddedClient_Impl : public ::cppu::WeakImplHelper uno::Reference< awt::XWindow > m_xWindow; SdrOle2Obj* mpObj; - Fraction m_aScaleWidth; - Fraction m_aScaleHeight; + double m_aScaleWidth { 0.0 }; + double m_aScaleHeight { 0.0 }; public: explicit SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj ); virtual ~SdrLightEmbeddedClient_Impl() override; - void SetSizeScale( const Fraction& aScaleWidth, const Fraction& aScaleHeight ) + void SetSizeScale( double aScaleWidth, double aScaleHeight ) { m_aScaleWidth = aScaleWidth; m_aScaleHeight = aScaleHeight; } - const Fraction& GetScaleWidth() const { return m_aScaleWidth; } - const Fraction& GetScaleHeight() const { return m_aScaleHeight; } + double GetScaleWidth() const { return m_aScaleWidth; } + double GetScaleHeight() const { return m_aScaleHeight; } void setWindow(const uno::Reference< awt::XWindow >& _xWindow); @@ -1592,15 +1592,15 @@ void SdrOle2Obj::ImpSetVisAreaSize() { // The object isn't active and does not want to resize itself so the changed object area size // will be reflected in a changed object scaling - Fraction aScaleWidth; - Fraction aScaleHeight; + double aScaleWidth; + double aScaleHeight; Size aObjAreaSize; if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) ) { if ( pClient ) { tools::Rectangle aScaleRect(getRectangle().TopLeft(), aObjAreaSize); - pClient->SetObjAreaAndScale( aScaleRect, double(aScaleWidth), double(aScaleHeight)); + pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth, aScaleHeight); } else { @@ -1921,7 +1921,7 @@ const uno::Reference< frame::XModel > & SdrOle2Obj::GetParentXModel() const return getSdrModelFromSdrObject().getUnoModel(); } -bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize ) +bool SdrOle2Obj::CalculateNewScaling( double& aScaleWidth, double& aScaleHeight, Size& aObjAreaSize ) { // TODO/LEAN: to avoid rounding errors scaling always uses the VisArea. // If we don't cache it for own objects also we must load the object here @@ -1935,16 +1935,13 @@ bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHei if (!aObjAreaSize.Width() || !aObjAreaSize.Height()) { // avoid invalid fractions - aScaleWidth = Fraction(1,1); - aScaleHeight = Fraction(1,1); + aScaleWidth = 1.0; + aScaleHeight = 1.0; } else { - aScaleWidth = Fraction(aSize.Width(), aObjAreaSize.Width() ); - aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() ); - // reduce to 10 binary digits - aScaleHeight.ReduceInaccurate(10); - aScaleWidth.ReduceInaccurate(10); + aScaleWidth = double(aSize.Width()) / aObjAreaSize.Width(); + aScaleHeight = double(aSize.Height()) / aObjAreaSize.Height(); } return true; @@ -1962,8 +1959,8 @@ bool SdrOle2Obj::AddOwnLightClient() if (!mpImpl->mbIgnoreOLEObjectScale && mpImpl->mxObjRef.is() && mpImpl->mxLightClient.is()) { - Fraction aScaleWidth; - Fraction aScaleHeight; + double aScaleWidth; + double aScaleHeight; Size aObjAreaSize; if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) ) {