include/sfx2/ipclient.hxx | 8 ++--- sc/source/ui/app/client.cxx | 6 ++-- sc/source/ui/view/tabvwshb.cxx | 19 ++++--------- sd/source/ui/docshell/sdclient.cxx | 4 +- sd/source/ui/view/sdview.cxx | 8 ++--- sd/source/ui/view/viewshe2.cxx | 8 ++--- sfx2/source/view/ipclient.cxx | 54 ++++++++++++++++++------------------- svx/source/svdraw/svdoole2.cxx | 2 - sw/source/uibase/wrtsh/wrtsh1.cxx | 10 +++--- 9 files changed, 55 insertions(+), 64 deletions(-)
New commits: commit 0adeec44518064942a7657a26cbe86cc5b06f315 Author: Jesus Solis <[email protected]> AuthorDate: Mon Mar 9 18:08:33 2026 -0500 Commit: Mike Kaganski <[email protected]> CommitDate: Tue Mar 10 07:51:08 2026 +0100 tdf#161837 use double instead of Fraction class replaced use of Fraction in SfxInPlaceClient::SetObjAreaAndScale and related methods SetSizeScale, GetScaleWidth, GetScaleHeight; replaced attributes m_aScaleWidth and m_aScaleHeight from SfxInPlaceClient_Impl with m_fScaleWidth and m_fScaleHeight Change-Id: I9019c7fde9a75880ad8b01b1f0b643d4932b116e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201310 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/include/sfx2/ipclient.hxx b/include/sfx2/ipclient.hxx index 54c0c3f03520..2a541ae11f94 100644 --- a/include/sfx2/ipclient.hxx +++ b/include/sfx2/ipclient.hxx @@ -72,10 +72,10 @@ public: bool SetObjArea( const tools::Rectangle & ); const tools::Rectangle& GetObjArea() const; tools::Rectangle GetScaledObjArea() const; - void SetSizeScale( const Fraction & rScaleWidth, const Fraction & rScaleHeight ); - void SetObjAreaAndScale( const tools::Rectangle&, const Fraction&, const Fraction& ); - const Fraction& GetScaleWidth() const; - const Fraction& GetScaleHeight() const; + void SetSizeScale( const double fScaleWidth, const double fScaleHeight ); + void SetObjAreaAndScale( const tools::Rectangle&, const double, const double ); + double GetScaleWidth() const; + double GetScaleHeight() const; void Invalidate(); static SfxInPlaceClient* GetClient( SfxObjectShell const * pDoc, const css::uno::Reference < css::embed::XEmbeddedObject >& xObject ); sal_Int64 GetAspect() const; diff --git a/sc/source/ui/app/client.cxx b/sc/source/ui/app/client.cxx index cbb00c3c9ddd..f3af0655f5db 100644 --- a/sc/source/ui/app/client.cxx +++ b/sc/source/ui/app/client.cxx @@ -211,9 +211,9 @@ void ScClient::ViewChanged() } tools::Rectangle aLogicRect = pDrawObj->GetLogicRect(); - Fraction aFractX = GetScaleWidth() * aVisSize.Width(); - Fraction aFractY = GetScaleHeight() * aVisSize.Height(); - aVisSize = Size( static_cast<tools::Long>(aFractX), static_cast<tools::Long>(aFractY) ); // Scaled for Draw model + double fX = GetScaleWidth() * aVisSize.Width(); + double fY = GetScaleHeight() * aVisSize.Height(); + aVisSize = Size( static_cast<tools::Long>(fX), static_cast<tools::Long>(fY) ); // Scaled for Draw model // pClientData->SetObjArea before pDrawObj->SetLogicRect, so that we don't // calculate wrong scalings: diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx index e5ae4360050a..6039bcdadf3a 100644 --- a/sc/source/ui/view/tabvwshb.cxx +++ b/sc/source/ui/view/tabvwshb.cxx @@ -98,11 +98,9 @@ void ScTabViewShell::ConnectObject( const SdrOle2Obj* pObj ) Size aOleSize = pObj->GetOrigObjSize(); - Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() ); - Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() ); - aScaleWidth.ReduceInaccurate(10); // compatible with SdrOle2Obj - aScaleHeight.ReduceInaccurate(10); - pClient->SetSizeScale(aScaleWidth,aScaleHeight); + double fScaleWidth = static_cast<double>(aDrawSize.Width()) / aOleSize.Width(); + double fScaleHeight = static_cast<double>(aDrawSize.Height()) / aOleSize.Height(); + pClient->SetSizeScale(fScaleWidth,fScaleHeight); // visible section is only changed inplace! // the object area must be set after the scaling since it triggers the resizing @@ -207,18 +205,15 @@ void ScTabViewShell::ActivateObject(SdrOle2Obj* pObj, sal_Int32 nVerb) awt::Size aSz( aOleSize.Width(), aOleSize.Height() ); xObj->setVisualAreaSize( pClient->GetAspect(), aSz ); } - Fraction aOne( 1, 1 ); - pClient->SetSizeScale( aOne, aOne ); + pClient->SetSizeScale( 1.0, 1.0 ); } else { // calculate scale from client and VisArea size - Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() ); - Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() ); - aScaleWidth.ReduceInaccurate(10); // compatible with SdrOle2Obj - aScaleHeight.ReduceInaccurate(10); - pClient->SetSizeScale(aScaleWidth,aScaleHeight); + double fScaleWidth = static_cast<double>(aDrawSize.Width()) / aOleSize.Width(); + double fScaleHeight = static_cast<double>(aDrawSize.Height()) / aOleSize.Height(); + pClient->SetSizeScale(fScaleWidth,fScaleHeight); } // visible section is only changed inplace! diff --git a/sd/source/ui/docshell/sdclient.cxx b/sd/source/ui/docshell/sdclient.cxx index a066b81e8cbe..c435a8a97d7a 100644 --- a/sd/source/ui/docshell/sdclient.cxx +++ b/sd/source/ui/docshell/sdclient.cxx @@ -168,8 +168,8 @@ void Client::ViewChanged() Size aSize = pSdrOle2Obj->GetOrigObjSize( &aMap100 ); aVisArea.SetSize( aSize ); - Size aScaledSize( static_cast< ::tools::Long >( GetScaleWidth() * Fraction( aVisArea.GetWidth() ) ), - static_cast< ::tools::Long >( GetScaleHeight() * Fraction( aVisArea.GetHeight() ) ) ); + Size aScaledSize( static_cast< ::tools::Long >( GetScaleWidth() * aVisArea.GetWidth() ), + static_cast< ::tools::Long >( GetScaleHeight() * aVisArea.GetHeight() ) ); // react to the change if the difference is bigger than one pixel Size aPixelDiff = diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx index 218e8c1ad869..e8cf4333e3cf 100644 --- a/sd/source/ui/view/sdview.cxx +++ b/sd/source/ui/view/sdview.cxx @@ -970,11 +970,9 @@ void View::DoConnect(SdrOle2Obj* pObj) MapMode aMapMode( mrDoc.GetScaleUnit() ); Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode ); - Fraction aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() ); - Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() ); - aScaleWidth.ReduceInaccurate(10); // compatible to SdrOle2Obj - aScaleHeight.ReduceInaccurate(10); - pSdClient->SetSizeScale(aScaleWidth, aScaleHeight); + double fScaleWidth = static_cast<double>(aDrawSize.Width()) / aObjAreaSize.Width(); + double fScaleHeight = static_cast<double>(aDrawSize.Height()) / aObjAreaSize.Height(); + pSdClient->SetSizeScale(fScaleWidth, fScaleHeight); // visible area is only changed in-place! // the object area must be set after the scaling, since it triggers resize diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index 7f74dbd8bcc6..7f30249cb578 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -859,11 +859,9 @@ bool ViewShell::ActivateObject(SdrOle2Obj* pObj, sal_Int32 nVerb) if( pObj->IsChart() ) //charts never should be stretched see #i84323# for example aObjAreaSize = aDrawSize; - Fraction aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() ); - Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() ); - aScaleWidth.ReduceInaccurate(10); // compatible to the SdrOle2Obj - aScaleHeight.ReduceInaccurate(10); - pSdClient->SetSizeScale(aScaleWidth, aScaleHeight); + double fScaleWidth = static_cast<double>(aDrawSize.Width()) / aObjAreaSize.Width(); + double fScaleHeight = static_cast<double>(aDrawSize.Height()) / aObjAreaSize.Height(); + pSdClient->SetSizeScale(fScaleWidth, fScaleHeight); // visible section is only changed in-place! aRect.SetSize(aObjAreaSize); diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 7b6a94a7211e..deeb94b78fc4 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -116,8 +116,8 @@ class SfxInPlaceClient_Impl : public ::cppu::WeakImplHelper< embed::XEmbeddedCli public: Timer m_aTimer { "sfx::SfxInPlaceClient m_xImpl::m_aTimer" }; // activation timeout, starts after object connection tools::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; + double m_fScaleWidth; // scaling that was applied to the object when it was not active + double m_fScaleHeight; SfxInPlaceClient* m_pClient; sal_Int64 m_nAspect; // ViewAspect that is assigned from the container bool m_bStoreObject; @@ -436,8 +436,8 @@ awt::Rectangle SAL_CALL SfxInPlaceClient_Impl::getPlacement() // apply scaling to object area and convert to pixels tools::Rectangle aRealObjArea( m_aObjArea ); - aRealObjArea.SetSize( Size( tools::Long( aRealObjArea.GetWidth() * m_aScaleWidth), - tools::Long( aRealObjArea.GetHeight() * m_aScaleHeight) ) ); + aRealObjArea.SetSize( Size( tools::Long( aRealObjArea.GetWidth() * m_fScaleWidth), + tools::Long( aRealObjArea.GetHeight() * m_fScaleHeight) ) ); vcl::Window* pEditWin = m_pClient->GetEditWin(); // In Writer and Impress the map mode is disabled. So when a chart is @@ -471,8 +471,8 @@ awt::Rectangle SAL_CALL SfxInPlaceClient_Impl::getClipRectangle() // currently(?) same as placement tools::Rectangle aRealObjArea( m_aObjArea ); - aRealObjArea.SetSize( Size( tools::Long( aRealObjArea.GetWidth() * m_aScaleWidth), - tools::Long( aRealObjArea.GetHeight() * m_aScaleHeight) ) ); + aRealObjArea.SetSize( Size( tools::Long( aRealObjArea.GetWidth() * m_fScaleWidth), + tools::Long( aRealObjArea.GetHeight() * m_fScaleHeight) ) ); vcl::Window* pEditWin = m_pClient->GetEditWin(); // See comment for SfxInPlaceClient_Impl::getPlacement. @@ -542,8 +542,8 @@ void SAL_CALL SfxInPlaceClient_Impl::changedPlacement( const awt::Rectangle& aPo SfxBooleanFlagGuard aGuard( m_bResizeNoScale ); // new size of the object area without scaling - Size aNewObjSize( tools::Long( aNewLogicRect.GetWidth() / m_aScaleWidth ), - tools::Long( aNewLogicRect.GetHeight() / m_aScaleHeight ) ); + Size aNewObjSize( tools::Long( aNewLogicRect.GetWidth() / m_fScaleWidth ), + tools::Long( aNewLogicRect.GetHeight() / m_fScaleHeight ) ); // now remove scaling from new placement and keep this at the new object area aNewLogicRect.SetSize( aNewObjSize ); @@ -643,7 +643,7 @@ SfxInPlaceClient::SfxInPlaceClient( SfxViewShell* pViewShell, vcl::Window *pDraw { m_xImp->m_pClient = this; m_xImp->m_nAspect = nAspect; - m_xImp->m_aScaleWidth = m_xImp->m_aScaleHeight = Fraction(1,1); + m_xImp->m_fScaleWidth = m_xImp->m_fScaleHeight = 1.0; pViewShell->NewIPClient_Impl(this); m_xImp->m_aTimer.SetTimeout( SFX_CLIENTACTIVATE_TIMEOUT ); m_xImp->m_aTimer.SetInvokeHandler( LINK( m_xImp.get(), SfxInPlaceClient_Impl, TimerHdl ) ); @@ -779,18 +779,18 @@ const tools::Rectangle& SfxInPlaceClient::GetObjArea() const tools::Rectangle SfxInPlaceClient::GetScaledObjArea() const { tools::Rectangle aRealObjArea( m_xImp->m_aObjArea ); - aRealObjArea.SetSize( Size( tools::Long( aRealObjArea.GetWidth() * m_xImp->m_aScaleWidth ), - tools::Long( aRealObjArea.GetHeight() * m_xImp->m_aScaleHeight ) ) ); + aRealObjArea.SetSize( Size( tools::Long( aRealObjArea.GetWidth() * m_xImp->m_fScaleWidth ), + tools::Long( aRealObjArea.GetHeight() * m_xImp->m_fScaleHeight ) ) ); return aRealObjArea; } -void SfxInPlaceClient::SetSizeScale( const Fraction & rScaleWidth, const Fraction & rScaleHeight ) +void SfxInPlaceClient::SetSizeScale( const double fScaleWidth, const double fScaleHeight ) { - if ( m_xImp->m_aScaleWidth != rScaleWidth || m_xImp->m_aScaleHeight != rScaleHeight ) + if ( m_xImp->m_fScaleWidth != fScaleWidth || m_xImp->m_fScaleHeight != fScaleHeight ) { - m_xImp->m_aScaleWidth = rScaleWidth; - m_xImp->m_aScaleHeight = rScaleHeight; + m_xImp->m_fScaleWidth = fScaleWidth; + m_xImp->m_fScaleHeight = fScaleHeight; m_xImp->SizeHasChanged(); @@ -801,13 +801,13 @@ void SfxInPlaceClient::SetSizeScale( const Fraction & rScaleWidth, const Fractio } -void SfxInPlaceClient::SetObjAreaAndScale( const tools::Rectangle& rArea, const Fraction& rScaleWidth, const Fraction& rScaleHeight ) +void SfxInPlaceClient::SetObjAreaAndScale( const tools::Rectangle& rArea, const double fScaleWidth, const double fScaleHeight ) { - if( rArea != m_xImp->m_aObjArea || m_xImp->m_aScaleWidth != rScaleWidth || m_xImp->m_aScaleHeight != rScaleHeight ) + if( rArea != m_xImp->m_aObjArea || m_xImp->m_fScaleWidth != fScaleWidth || m_xImp->m_fScaleHeight != fScaleHeight ) { m_xImp->m_aObjArea = rArea; - m_xImp->m_aScaleWidth = rScaleWidth; - m_xImp->m_aScaleHeight = rScaleHeight; + m_xImp->m_fScaleWidth = fScaleWidth; + m_xImp->m_fScaleHeight = fScaleHeight; m_xImp->SizeHasChanged(); @@ -816,15 +816,15 @@ void SfxInPlaceClient::SetObjAreaAndScale( const tools::Rectangle& rArea, const } -const Fraction& SfxInPlaceClient::GetScaleWidth() const +double SfxInPlaceClient::GetScaleWidth() const { - return m_xImp->m_aScaleWidth; + return m_xImp->m_fScaleWidth; } -const Fraction& SfxInPlaceClient::GetScaleHeight() const +double SfxInPlaceClient::GetScaleHeight() const { - return m_xImp->m_aScaleHeight; + return m_xImp->m_fScaleHeight; } @@ -834,8 +834,8 @@ void SfxInPlaceClient::Invalidate() // the object area is provided in logical coordinates of the window but without scaling applied tools::Rectangle aRealObjArea( m_xImp->m_aObjArea ); - aRealObjArea.SetSize( Size( tools::Long( aRealObjArea.GetWidth() * m_xImp->m_aScaleWidth ), - tools::Long( aRealObjArea.GetHeight() * m_xImp->m_aScaleHeight ) ) ); + aRealObjArea.SetSize( Size( tools::Long( aRealObjArea.GetWidth() * m_xImp->m_fScaleWidth ), + tools::Long( aRealObjArea.GetHeight() * m_xImp->m_fScaleHeight ) ) ); m_pEditWin->Invalidate( IsNegativeX() ? lcl_negateRectX(aRealObjArea) : aRealObjArea ); @@ -992,8 +992,8 @@ ErrCodeMsg SfxInPlaceClient::DoVerb(sal_Int32 nVerb) tools::Rectangle aScaledArea = GetScaledObjArea(); m_xImp->m_aObjArea.SetSize( aNewSize ); - m_xImp->m_aScaleWidth = Fraction( aScaledArea.GetWidth(), aNewSize.Width() ); - m_xImp->m_aScaleHeight = Fraction( aScaledArea.GetHeight(), aNewSize.Height() ); + m_xImp->m_fScaleWidth = static_cast<double>(aScaledArea.GetWidth()) / aNewSize.Width(); + m_xImp->m_fScaleHeight = static_cast<double>(aScaledArea.GetHeight()) / aNewSize.Height(); } } catch (uno::Exception const&) diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 679f8e536d95..94c753b73d48 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -1600,7 +1600,7 @@ void SdrOle2Obj::ImpSetVisAreaSize() if ( pClient ) { tools::Rectangle aScaleRect(getRectangle().TopLeft(), aObjAreaSize); - pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth, aScaleHeight); + pClient->SetObjAreaAndScale( aScaleRect, double(aScaleWidth), double(aScaleHeight)); } else { diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx index bfb9c8fe6d43..4f8ed4439bee 100644 --- a/sw/source/uibase/wrtsh/wrtsh1.cxx +++ b/sw/source/uibase/wrtsh/wrtsh1.cxx @@ -874,8 +874,8 @@ void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj, Size _aVisArea( aSize.Width, aSize.Height ); - Fraction aScaleWidth( 1, 1 ); - Fraction aScaleHeight( 1, 1 ); + double fScaleWidth = 1.0; + double fScaleHeight = 1.0; bool bUseObjectSize = false; @@ -908,8 +908,8 @@ void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj, } else { - aScaleWidth = Fraction( aObjArea.Width(), _aVisArea.Width() ); - aScaleHeight = Fraction( aObjArea.Height(), _aVisArea.Height()); + fScaleWidth = static_cast<double>(aObjArea.Width()) / _aVisArea.Width(); + fScaleHeight = static_cast<double>(aObjArea.Height()) / _aVisArea.Height(); } } } @@ -955,7 +955,7 @@ void SwWrtShell::CalcAndSetScale( svt::EmbeddedObjectRef& xObj, } } - pCli->SetObjAreaAndScale( aArea.SVRect(), aScaleWidth, aScaleHeight ); + pCli->SetObjAreaAndScale( aArea.SVRect(), fScaleWidth, fScaleHeight ); } void SwWrtShell::ConnectObj( svt::EmbeddedObjectRef& xObj, const SwRect &rPrt,
