summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@libreoffice.org>2023-07-18 17:13:33 +0300
committerخالد حسني <khaled@libreoffice.org>2023-07-23 06:02:51 +0200
commita21958db9111e27312c6ae52e2d5e3a9e8a39e08 (patch)
treee2a257340acebb451ec347329c4c06b79487cee4 /vcl/source
parent9d9e3b439883c3c315501f56bb613e080863db64 (diff)
vcl: Use doubles in GetTextBreak()
Change-Id: I88ee2434ba6ddb41cf1983afceebe1ae72be8d9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154584 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@libreoffice.org>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/outdev/text.cxx26
1 files changed, 9 insertions, 17 deletions
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index c02509718a60..8d4f557288c2 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1456,14 +1456,10 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, tools::Long nTextWid
// problem with rounding errors especially for small nCharExtras
// TODO: remove when layout units have subpixel granularity
tools::Long nSubPixelFactor = 64;
- nTextWidth *= nSubPixelFactor;
- DeviceCoordinate nTextPixelWidth = LogicWidthToDeviceCoordinate( nTextWidth );
- DeviceCoordinate nExtraPixelWidth = 0;
+ double nTextPixelWidth = ImplLogicWidthToDeviceSubPixel(nTextWidth * nSubPixelFactor);
+ double nExtraPixelWidth = 0;
if( nCharExtra != 0 )
- {
- nCharExtra *= nSubPixelFactor;
- nExtraPixelWidth = LogicWidthToDeviceCoordinate( nCharExtra );
- }
+ nExtraPixelWidth = ImplLogicWidthToDeviceSubPixel(nCharExtra * nSubPixelFactor);
nRetVal = pSalLayout->GetTextBreak( nTextPixelWidth, nExtraPixelWidth, nSubPixelFactor );
}
@@ -1490,14 +1486,10 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, tools::Long nTextWid
// TODO: remove when layout units have subpixel granularity
tools::Long nSubPixelFactor = 64;
- nTextWidth *= nSubPixelFactor;
- DeviceCoordinate nTextPixelWidth = LogicWidthToDeviceCoordinate( nTextWidth );
- DeviceCoordinate nExtraPixelWidth = 0;
+ double nTextPixelWidth = ImplLogicWidthToDeviceSubPixel(nTextWidth * nSubPixelFactor);
+ double nExtraPixelWidth = 0;
if( nCharExtra != 0 )
- {
- nCharExtra *= nSubPixelFactor;
- nExtraPixelWidth = LogicWidthToDeviceCoordinate( nCharExtra );
- }
+ nExtraPixelWidth = ImplLogicWidthToDeviceSubPixel(nCharExtra * nSubPixelFactor);
// calculate un-hyphenated break position
nRetVal = pSalLayout->GetTextBreak( nTextPixelWidth, nExtraPixelWidth, nSubPixelFactor );
@@ -1508,7 +1500,7 @@ sal_Int32 OutputDevice::GetTextBreak( const OUString& rStr, tools::Long nTextWid
if( pHyphenLayout )
{
// calculate subpixel width of hyphenation character
- tools::Long nHyphenPixelWidth = pHyphenLayout->GetTextWidth() * nSubPixelFactor;
+ double nHyphenPixelWidth = pHyphenLayout->GetTextWidth() * nSubPixelFactor;
// calculate hyphenated break position
nTextPixelWidth -= nHyphenPixelWidth;
@@ -1689,7 +1681,7 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const tools::Recta
nIndex, nLineLen );
sal_Int32 lc_x1 = pCaretXArray[2*(nMnemonicPos - nIndex)];
sal_Int32 lc_x2 = pCaretXArray[2*(nMnemonicPos - nIndex)+1];
- nMnemonicWidth = rTargetDevice.LogicWidthToDeviceCoordinate( std::abs(lc_x1 - lc_x2) );
+ nMnemonicWidth = rTargetDevice.ImplLogicWidthToDeviceSubPixel(std::abs(lc_x1 - lc_x2));
Point aTempPos = rTargetDevice.LogicToPixel( aPos );
nMnemonicX = rTargetDevice.GetOutOffXPixel() + aTempPos.X() + rTargetDevice.ImplLogicWidthToDevicePixel( std::min( lc_x1, lc_x2 ) );
@@ -1757,7 +1749,7 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const tools::Recta
/*sal_Bool bRet =*/ _rLayout.GetCaretPositions( aStr, pCaretXArray.get(), 0, aStr.getLength() );
tools::Long lc_x1 = pCaretXArray[2*nMnemonicPos];
tools::Long lc_x2 = pCaretXArray[2*nMnemonicPos+1];
- nMnemonicWidth = rTargetDevice.LogicWidthToDeviceCoordinate( std::abs(lc_x1 - lc_x2) );
+ nMnemonicWidth = rTargetDevice.ImplLogicWidthToDeviceSubPixel(std::abs(lc_x1 - lc_x2));
Point aTempPos = rTargetDevice.LogicToPixel( aPos );
nMnemonicX = rTargetDevice.GetOutOffXPixel() + aTempPos.X() + rTargetDevice.ImplLogicWidthToDevicePixel( std::min(lc_x1, lc_x2) );