sd/source/ui/dlg/vectdlg.cxx | 14 +++++++------- sd/source/ui/inc/vectdlg.hxx | 2 +- svx/source/dialog/connctrl.cxx | 18 +++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-)
New commits: commit 73581d028421cd56e41ca0c1475f89a88e6e322f Author: Noel Grandin <[email protected]> AuthorDate: Tue Mar 24 15:26:49 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Mar 24 18:40:11 2026 +0100 Fraction->double in SvxXConnectionPreview and also avoid allocating these on the heap Change-Id: I7797fabb2d0d99f3764594846efde6609a669950 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202601 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/svx/source/dialog/connctrl.cxx b/svx/source/dialog/connctrl.cxx index 3e0d48d15e4b..10d1d8b82bf4 100644 --- a/svx/source/dialog/connctrl.cxx +++ b/svx/source/dialog/connctrl.cxx @@ -254,25 +254,25 @@ bool SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt ) MapMode aMapMode = GetMapMode(); Fraction aXFrac = aMapMode.GetScaleX(); Fraction aYFrac = aMapMode.GetScaleY(); - std::unique_ptr<Fraction> pMultFrac; + std::optional<double> oMultFrac; if( bZoomIn ) { if( bCtrl ) - pMultFrac.reset(new Fraction( 3, 2 )); + oMultFrac = 3.0 / 2; else - pMultFrac.reset(new Fraction( 11, 10 )); + oMultFrac = 11.0 / 10; } else { if( bCtrl ) - pMultFrac.reset(new Fraction( 2, 3 )); + oMultFrac = 2.0 / 3; else - pMultFrac.reset(new Fraction( 10, 11 )); + oMultFrac = 10.0 / 11; } - aXFrac *= *pMultFrac; - aYFrac *= *pMultFrac; + aXFrac *= *oMultFrac; + aYFrac *= *oMultFrac; if( static_cast<double>(aXFrac) > 0.001 && static_cast<double>(aXFrac) < 1000.0 && static_cast<double>(aYFrac) > 0.001 && static_cast<double>(aYFrac) < 1000.0 ) { @@ -284,8 +284,8 @@ bool SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt ) aOutSize = GetDrawingArea()->get_ref_device().PixelToLogic(aOutSize); Point aPt( aMapMode.GetOrigin() ); - tools::Long nX = static_cast<tools::Long>( ( static_cast<double>(aOutSize.Width()) - ( static_cast<double>(aOutSize.Width()) * static_cast<double>(*pMultFrac) ) ) / 2.0 + 0.5 ); - tools::Long nY = static_cast<tools::Long>( ( static_cast<double>(aOutSize.Height()) - ( static_cast<double>(aOutSize.Height()) * static_cast<double>(*pMultFrac) ) ) / 2.0 + 0.5 ); + tools::Long nX = static_cast<tools::Long>( ( static_cast<double>(aOutSize.Width()) - ( static_cast<double>(aOutSize.Width()) * *oMultFrac ) ) / 2.0 + 0.5 ); + tools::Long nY = static_cast<tools::Long>( ( static_cast<double>(aOutSize.Height()) - ( static_cast<double>(aOutSize.Height()) * *oMultFrac ) ) / 2.0 + 0.5 ); aPt.AdjustX(nX ); aPt.AdjustY(nY ); commit 67c365fee9fdf7265d9b2f60b3b0bb4ebec6a24a Author: Noel Grandin <[email protected]> AuthorDate: Tue Mar 24 15:21:03 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Mar 24 18:40:01 2026 +0100 Fraction->double in SdVectorizeDlg Change-Id: Ice04e8e6e5bf6c5a048c2c582e982d91a1611acc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202600 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sd/source/ui/dlg/vectdlg.cxx b/sd/source/ui/dlg/vectdlg.cxx index e29ba41cdf43..ce9c8f0bf098 100644 --- a/sd/source/ui/dlg/vectdlg.cxx +++ b/sd/source/ui/dlg/vectdlg.cxx @@ -109,7 +109,7 @@ void SdVectorizeDlg::InitPreviewBmp() m_aBmpWin.SetGraphic(aPreviewBmp); } -Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap const & rBmp, Fraction& rScale ) +Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap const & rBmp, double& rScale ) { Bitmap aNew( rBmp ); const Size aSizePix( aNew.GetSizePixel() ); @@ -117,11 +117,11 @@ Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap const & rBmp, Fraction& rScale if( aSizePix.Width() > VECTORIZE_MAX_EXTENT || aSizePix.Height() > VECTORIZE_MAX_EXTENT ) { const ::tools::Rectangle aRect( GetRect( Size( VECTORIZE_MAX_EXTENT, VECTORIZE_MAX_EXTENT ), aSizePix ) ); - rScale = Fraction( aSizePix.Width(), aRect.GetWidth() ); + rScale = double(aSizePix.Width()) / aRect.GetWidth(); aNew.Scale( aRect.GetSize() ); } else - rScale = Fraction( 1, 1 ); + rScale = 1.0; BitmapFilter::Filter(aNew, BitmapSimpleColorQuantizationFilter(m_xNmLayers->get_value())); @@ -133,8 +133,8 @@ void SdVectorizeDlg::Calculate( Bitmap const & rBmp, GDIMetaFile& rMtf ) m_pDocSh->SetWaitCursor( true ); m_xPrgs->set_percentage(0); - Fraction aScale; - Bitmap aBitmap(GetPreparedBitmap(rBmp, aScale)); + double fScale; + Bitmap aBitmap(GetPreparedBitmap(rBmp, fScale)); if (!aBitmap.IsEmpty()) { @@ -193,8 +193,8 @@ void SdVectorizeDlg::Calculate( Bitmap const & rBmp, GDIMetaFile& rMtf ) for( size_t n = 0, nCount = rMtf.GetActionSize(); n < nCount; n++ ) aNewMtf.AddAction( rMtf.GetAction( n )->Clone() ); - aMap.SetScaleX( aMap.GetScaleX() * aScale ); - aMap.SetScaleY( aMap.GetScaleY() * aScale ); + aMap.SetScaleX( aMap.GetScaleX() * fScale ); + aMap.SetScaleY( aMap.GetScaleY() * fScale ); aNewMtf.SetPrefMapMode( aMap ); rMtf = aNewMtf; } diff --git a/sd/source/ui/inc/vectdlg.hxx b/sd/source/ui/inc/vectdlg.hxx index 10a3b4b070c4..f830ba979ba8 100644 --- a/sd/source/ui/inc/vectdlg.hxx +++ b/sd/source/ui/inc/vectdlg.hxx @@ -61,7 +61,7 @@ class SdVectorizeDlg final : public weld::GenericDialogController void InitPreviewBmp(); static ::tools::Rectangle GetRect( const Size& rDispSize, const Size& rBmpSize ); - Bitmap GetPreparedBitmap( Bitmap const & rBmp, Fraction& rScale ); + Bitmap GetPreparedBitmap( Bitmap const & rBmp, double& rScale ); void Calculate( Bitmap const & rBmp, GDIMetaFile& rMtf ); static void AddTile( BitmapReadAccess const * pRAcc, GDIMetaFile& rMtf, tools::Long nPosX, tools::Long nPosY, tools::Long nWidth, tools::Long nHeight );
