Fraction->double in GDIMetaFile

Change-Id: I10343479423a94272df30423c3dd910d02bde42d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202325
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2026-03-23 07:06:06 +01:00
committed by Noel Grandin
parent 0e40cab8b4
commit cb1da4662f
6 changed files with 9 additions and 15 deletions
+2 -2
View File
@@ -221,8 +221,8 @@ void Impl_OlePres::Write( SvStream & rStm )
Size aPrefS( pMtf->GetPrefSize() );
Size aS = OutputDevice::LogicToLogic(aPrefS, MapMode(nMU), MapMode(MapUnit::Map100thMM));
pMtf->Scale( Fraction( aS.Width(), aPrefS.Width() ),
Fraction( aS.Height(), aPrefS.Height() ) );
pMtf->Scale( double(aS.Width()) / aPrefS.Width(),
double(aS.Height()) / aPrefS.Height() );
pMtf->SetPrefMapMode(MapMode(MapUnit::Map100thMM));
pMtf->SetPrefSize( aS );
}
-1
View File
@@ -114,7 +114,6 @@ public:
void Move( tools::Long nX, tools::Long nY, tools::Long nDPIX, tools::Long nDPIY );
void ScaleActions(double fScaleX, double fScaleY);
void Scale( double fScaleX, double fScaleY );
void Scale( const Fraction& rScaleX, const Fraction& rScaleY );
SAL_DLLPRIVATE void Rotate( Degree10 nAngle10 );
void Clip( const tools::Rectangle& );
bool HasTransparentActions() const;
+4 -4
View File
@@ -166,8 +166,8 @@ static bool SwWw6ReadMetaStream(GDIMetaFile& rWMF, OLE_MFP* pMfp,
// Scale MetaFile to new size and save new size to MetaFile
Size aOldSiz( rWMF.GetPrefSize() );
Size aNewSiz( pMfp->xExt, pMfp->yExt );
Fraction aFracX( aNewSiz.Width(), aOldSiz.Width() );
Fraction aFracY( aNewSiz.Height(), aOldSiz.Height() );
double aFracX = double(aNewSiz.Width()) / aOldSiz.Width();
double aFracY = double(aNewSiz.Height()) / aOldSiz.Height();
rWMF.Scale( aFracX, aFracY );
rWMF.SetPrefSize( aNewSiz );
@@ -316,8 +316,8 @@ bool SwWW8ImplReader::ImportOleWMF(const rtl::Reference<SotStorage>& xSrc1, GDIM
aFinalSize = OutputDevice::LogicToLogic(
aFinalSize, MapMode(MapUnit::MapTwip), rWMF.GetPrefMapMode() );
aOrigSize = rWMF.GetPrefSize();
Fraction aScaleX(aFinalSize.Width(),aOrigSize.Width());
Fraction aScaleY(aFinalSize.Height(),aOrigSize.Height());
double aScaleX = double(aFinalSize.Width()) / aOrigSize.Width();
double aScaleY = double(aFinalSize.Height()) / aOrigSize.Height();
rWMF.Scale( aScaleX, aScaleY );
bOk = true;
}
+2 -2
View File
@@ -262,8 +262,8 @@ static Graphic ImpGetScaledGraphic( const Graphic& rGraphic, FilterConfigItem& r
if( aNewSize.Width() && aNewSize.Height() )
{
const Size aPreferredSize( aMtf.GetPrefSize() );
aMtf.Scale( Fraction( aNewSize.Width(), aPreferredSize.Width() ),
Fraction( aNewSize.Height(), aPreferredSize.Height() ) );
aMtf.Scale( double(aNewSize.Width()) / aPreferredSize.Width(),
double(aNewSize.Height()) / aPreferredSize.Height() );
}
aGraphic = Graphic( aMtf );
}
-5
View File
@@ -740,11 +740,6 @@ void GDIMetaFile::Scale( double fScaleX, double fScaleY )
m_aPrefSize.setHeight(basegfx::fround<tools::Long>(m_aPrefSize.Height() * fScaleY));
}
void GDIMetaFile::Scale( const Fraction& rScaleX, const Fraction& rScaleY )
{
Scale( static_cast<double>(rScaleX), static_cast<double>(rScaleY) );
}
void GDIMetaFile::Clip( const tools::Rectangle& i_rClipRect )
{
tools::Rectangle aCurRect( i_rClipRect );
+1 -1
View File
@@ -690,7 +690,7 @@ Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMo
}
else
{
aMtf.Scale( Fraction( rDestSize.Width(), aSrcSize.Width() ), Fraction( rDestSize.Height(), aSrcSize.Height() ) );
aMtf.Scale( double(rDestSize.Width()) / aSrcSize.Width(), double(rDestSize.Height()) / aSrcSize.Height() );
aMtf.SetPrefMapMode( rDestMap );
}