vcl: rename opaque fn3 and fn5 functions in map.cxx
The static functions fn3 and fn5 in vcl/source/outdev/map.cxx have names that give no indication of their purpose, making the code difficult to follow. fn3 is responsible for converting logical values between units, so rename it to ImplConvertLogicValue(). fn5 is used to scale logical values (n1 * n2 * n3) / (n4 * n5) while preventing overflow, so rename it to ImplScaleLogicValue(). Change-Id: Ib48db9389c889d19e2c651af6153f3577982ca15 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196464 Tested-by: Jenkins Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit is contained in:
committed by
Dan Williams
parent
ac2e61c4ac
commit
52c1d7021c
+25
-25
@@ -1370,7 +1370,7 @@ std::pair<ImplMapRes, ImplMapRes> ENTER4(const MapMode& rMMSource, const MapMode
|
||||
}
|
||||
}
|
||||
|
||||
static tools::Long fn5( const tools::Long n1,
|
||||
static tools::Long lcl_scaleLogicValue( const tools::Long n1,
|
||||
const double n2,
|
||||
const double n3 )
|
||||
{
|
||||
@@ -1379,7 +1379,7 @@ static tools::Long fn5( const tools::Long n1,
|
||||
return std::llround(n1 * n2 / n3);
|
||||
}
|
||||
|
||||
static tools::Long fn3(const tools::Long n1, const o3tl::Length eFrom, const o3tl::Length eTo)
|
||||
static tools::Long lcl_convertLogicValue(const tools::Long n1, const o3tl::Length eFrom, const o3tl::Length eTo)
|
||||
{
|
||||
if (n1 == 0 || eFrom == o3tl::Length::invalid || eTo == o3tl::Length::invalid)
|
||||
return 0;
|
||||
@@ -1409,10 +1409,10 @@ Point OutputDevice::LogicToLogic( const Point& rPtSource,
|
||||
{
|
||||
ENTER1( rPtSource, pMapModeSource, pMapModeDest );
|
||||
|
||||
return Point( fn5( rPtSource.X() + aMapResSource.mnMapOfsX,
|
||||
return Point( lcl_scaleLogicValue( rPtSource.X() + aMapResSource.mnMapOfsX,
|
||||
aMapResSource.mfMapScX, aMapResDest.mfMapScX ) -
|
||||
aMapResDest.mnMapOfsX,
|
||||
fn5( rPtSource.Y() + aMapResSource.mnMapOfsY,
|
||||
lcl_scaleLogicValue( rPtSource.Y() + aMapResSource.mnMapOfsY,
|
||||
aMapResSource.mfMapScY, aMapResDest.mfMapScY ) -
|
||||
aMapResDest.mnMapOfsY );
|
||||
}
|
||||
@@ -1423,9 +1423,9 @@ Size OutputDevice::LogicToLogic( const Size& rSzSource,
|
||||
{
|
||||
ENTER1( rSzSource, pMapModeSource, pMapModeDest );
|
||||
|
||||
return Size( fn5( rSzSource.Width(),
|
||||
return Size( lcl_scaleLogicValue( rSzSource.Width(),
|
||||
aMapResSource.mfMapScX, aMapResDest.mfMapScX ),
|
||||
fn5( rSzSource.Height(),
|
||||
lcl_scaleLogicValue( rSzSource.Height(),
|
||||
aMapResSource.mfMapScY, aMapResDest.mfMapScY ) );
|
||||
}
|
||||
|
||||
@@ -1435,16 +1435,16 @@ tools::Rectangle OutputDevice::LogicToLogic( const tools::Rectangle& rRectSource
|
||||
{
|
||||
ENTER1( rRectSource, pMapModeSource, pMapModeDest );
|
||||
|
||||
return tools::Rectangle( fn5( rRectSource.Left() + aMapResSource.mnMapOfsX,
|
||||
return tools::Rectangle( lcl_scaleLogicValue( rRectSource.Left() + aMapResSource.mnMapOfsX,
|
||||
aMapResSource.mfMapScX, aMapResDest.mfMapScX ) -
|
||||
aMapResDest.mnMapOfsX,
|
||||
fn5( rRectSource.Top() + aMapResSource.mnMapOfsY,
|
||||
lcl_scaleLogicValue( rRectSource.Top() + aMapResSource.mnMapOfsY,
|
||||
aMapResSource.mfMapScY, aMapResDest.mfMapScY ) -
|
||||
aMapResDest.mnMapOfsY,
|
||||
fn5( rRectSource.Right() + aMapResSource.mnMapOfsX,
|
||||
lcl_scaleLogicValue( rRectSource.Right() + aMapResSource.mnMapOfsX,
|
||||
aMapResSource.mfMapScX, aMapResDest.mfMapScX ) -
|
||||
aMapResDest.mnMapOfsX,
|
||||
fn5( rRectSource.Bottom() + aMapResSource.mnMapOfsY,
|
||||
lcl_scaleLogicValue( rRectSource.Bottom() + aMapResSource.mnMapOfsY,
|
||||
aMapResSource.mfMapScY, aMapResDest.mfMapScY ) -
|
||||
aMapResDest.mnMapOfsY );
|
||||
}
|
||||
@@ -1463,16 +1463,16 @@ Point OutputDevice::LogicToLogic( const Point& rPtSource,
|
||||
if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
|
||||
{
|
||||
const auto [eFrom, eTo] = getCorrectedUnit(eUnitSource, eUnitDest);
|
||||
return Point(fn3(rPtSource.X(), eFrom, eTo), fn3(rPtSource.Y(), eFrom, eTo));
|
||||
return Point(lcl_convertLogicValue(rPtSource.X(), eFrom, eTo), lcl_convertLogicValue(rPtSource.Y(), eFrom, eTo));
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto [aMapResSource, aMapResDest] = ENTER4( rMapModeSource, rMapModeDest );
|
||||
|
||||
return Point( fn5( rPtSource.X() + aMapResSource.mnMapOfsX,
|
||||
return Point( lcl_scaleLogicValue( rPtSource.X() + aMapResSource.mnMapOfsX,
|
||||
aMapResSource.mfMapScX, aMapResDest.mfMapScX ) -
|
||||
aMapResDest.mnMapOfsX,
|
||||
fn5( rPtSource.Y() + aMapResSource.mnMapOfsY,
|
||||
lcl_scaleLogicValue( rPtSource.Y() + aMapResSource.mnMapOfsY,
|
||||
aMapResSource.mfMapScY, aMapResDest.mfMapScY ) -
|
||||
aMapResDest.mnMapOfsY );
|
||||
}
|
||||
@@ -1492,15 +1492,15 @@ Size OutputDevice::LogicToLogic( const Size& rSzSource,
|
||||
if (rMapModeSource.IsSimple() && rMapModeDest.IsSimple())
|
||||
{
|
||||
const auto [eFrom, eTo] = getCorrectedUnit(eUnitSource, eUnitDest);
|
||||
return Size(fn3(rSzSource.Width(), eFrom, eTo), fn3(rSzSource.Height(), eFrom, eTo));
|
||||
return Size(lcl_convertLogicValue(rSzSource.Width(), eFrom, eTo), lcl_convertLogicValue(rSzSource.Height(), eFrom, eTo));
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto [aMapResSource, aMapResDest] = ENTER4( rMapModeSource, rMapModeDest );
|
||||
|
||||
return Size( fn5( rSzSource.Width(),
|
||||
return Size( lcl_scaleLogicValue( rSzSource.Width(),
|
||||
aMapResSource.mfMapScX, aMapResDest.mfMapScX ),
|
||||
fn5( rSzSource.Height(),
|
||||
lcl_scaleLogicValue( rSzSource.Height(),
|
||||
aMapResSource.mfMapScY, aMapResDest.mfMapScY ) );
|
||||
}
|
||||
}
|
||||
@@ -1578,12 +1578,12 @@ tools::Rectangle OutputDevice::LogicToLogic( const tools::Rectangle& rRectSource
|
||||
{
|
||||
const auto [eFrom, eTo] = getCorrectedUnit(eUnitSource, eUnitDest);
|
||||
|
||||
auto left = fn3(rRectSource.Left(), eFrom, eTo);
|
||||
auto top = fn3(rRectSource.Top(), eFrom, eTo);
|
||||
auto left = lcl_convertLogicValue(rRectSource.Left(), eFrom, eTo);
|
||||
auto top = lcl_convertLogicValue(rRectSource.Top(), eFrom, eTo);
|
||||
|
||||
// tdf#141761 see comments above, IsEmpty() removed
|
||||
auto right = rRectSource.IsWidthEmpty() ? 0 : fn3(rRectSource.Right(), eFrom, eTo);
|
||||
auto bottom = rRectSource.IsHeightEmpty() ? 0 : fn3(rRectSource.Bottom(), eFrom, eTo);
|
||||
auto right = rRectSource.IsWidthEmpty() ? 0 : lcl_convertLogicValue(rRectSource.Right(), eFrom, eTo);
|
||||
auto bottom = rRectSource.IsHeightEmpty() ? 0 : lcl_convertLogicValue(rRectSource.Bottom(), eFrom, eTo);
|
||||
|
||||
aRetval = tools::Rectangle(left, top, right, bottom);
|
||||
}
|
||||
@@ -1591,18 +1591,18 @@ tools::Rectangle OutputDevice::LogicToLogic( const tools::Rectangle& rRectSource
|
||||
{
|
||||
const auto [aMapResSource, aMapResDest] = ENTER4( rMapModeSource, rMapModeDest );
|
||||
|
||||
auto left = fn5( rRectSource.Left() + aMapResSource.mnMapOfsX,
|
||||
auto left = lcl_scaleLogicValue( rRectSource.Left() + aMapResSource.mnMapOfsX,
|
||||
aMapResSource.mfMapScX, aMapResDest.mfMapScX ) -
|
||||
aMapResDest.mnMapOfsX;
|
||||
auto top = fn5( rRectSource.Top() + aMapResSource.mnMapOfsY,
|
||||
auto top = lcl_scaleLogicValue( rRectSource.Top() + aMapResSource.mnMapOfsY,
|
||||
aMapResSource.mfMapScY, aMapResDest.mfMapScY ) -
|
||||
aMapResDest.mnMapOfsY;
|
||||
|
||||
// tdf#141761 see comments above, IsEmpty() removed
|
||||
auto right = rRectSource.IsWidthEmpty() ? 0 : fn5( rRectSource.Right() + aMapResSource.mnMapOfsX,
|
||||
auto right = rRectSource.IsWidthEmpty() ? 0 : lcl_scaleLogicValue( rRectSource.Right() + aMapResSource.mnMapOfsX,
|
||||
aMapResSource.mfMapScX, aMapResDest.mfMapScX ) -
|
||||
aMapResDest.mnMapOfsX;
|
||||
auto bottom = rRectSource.IsHeightEmpty() ? 0 : fn5( rRectSource.Bottom() + aMapResSource.mnMapOfsY,
|
||||
auto bottom = rRectSource.IsHeightEmpty() ? 0 : lcl_scaleLogicValue( rRectSource.Bottom() + aMapResSource.mnMapOfsY,
|
||||
aMapResSource.mfMapScY, aMapResDest.mfMapScY ) -
|
||||
aMapResDest.mnMapOfsY;
|
||||
|
||||
@@ -1626,7 +1626,7 @@ tools::Long OutputDevice::LogicToLogic( tools::Long nLongSource,
|
||||
|
||||
verifyUnitSourceDest( eUnitSource, eUnitDest );
|
||||
const auto [eFrom, eTo] = getCorrectedUnit(eUnitSource, eUnitDest);
|
||||
return fn3(nLongSource, eFrom, eTo);
|
||||
return lcl_convertLogicValue(nLongSource, eFrom, eTo);
|
||||
}
|
||||
|
||||
void OutputDevice::SetPixelOffset( const Size& rOffset )
|
||||
|
||||
Reference in New Issue
Block a user