include/vcl/outdev.hxx | 2 - include/vcl/vcllayout.hxx | 2 - vcl/inc/pdf/pdfwriter_impl.hxx | 6 ++--- vcl/inc/sallayout.hxx | 2 - vcl/source/gdi/pdfwriter_impl.cxx | 43 +++++++++++++++++--------------------- vcl/source/gdi/sallayout.cxx | 10 -------- vcl/source/outdev/map.cxx | 16 +++++--------- 7 files changed, 30 insertions(+), 51 deletions(-)
New commits: commit e5d59895ef3897141e5df304a8f98776aa70f021 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Oct 3 11:14:08 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Oct 3 21:31:44 2022 +0200 tdf#151262 drop subpixel->logic pos asserts which have served their bootstrapping purpose Change-Id: I04b832fde21e4932ed191d972737bee97510f53a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140903 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 928f49c3d614..b1b47d60c1a0 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -1709,7 +1709,7 @@ public: SAL_DLLPRIVATE tools::Long ImplLogicHeightToDevicePixel( tools::Long nHeight ) const; SAL_DLLPRIVATE double ImplLogicHeightToDeviceSubPixel(tools::Long nHeight) const; - SAL_DLLPRIVATE Point SubPixelToLogic(const DevicePoint& rDevicePt, bool bCheck) const; + SAL_DLLPRIVATE Point SubPixelToLogic(const DevicePoint& rDevicePt) const; /** Convert device pixels to a width in logical units. diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx index 07918325c1a6..b76c789fb16b 100644 --- a/include/vcl/vcllayout.hxx +++ b/include/vcl/vcllayout.hxx @@ -108,8 +108,6 @@ public: virtual SalLayoutGlyphs GetGlyphs() const; - virtual bool IsMultiSalLayout() const; - protected: // used by layout engines SalLayout(); diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx index 9f099f58b6a4..f415475e5441 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -855,9 +855,9 @@ i12626 /* emits a text object according to the passed layout */ /* TODO: remove rText as soon as SalLayout will change so that rText is not necessary anymore */ - void drawVerticalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, const Matrix3& rRotScale, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight, bool bCheck ); - void drawHorizontalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, bool bFirst, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight, bool bCheck ); - void drawLayout( SalLayout& rLayout, const OUString& rText, bool bTextLines, bool bCheckSubPixelToLogic ); + void drawVerticalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, const Matrix3& rRotScale, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight ); + void drawHorizontalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, bool bFirst, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight ); + void drawLayout( SalLayout& rLayout, const OUString& rText, bool bTextLines ); void drawRelief( SalLayout& rLayout, const OUString& rText, bool bTextLines ); void drawShadow( SalLayout& rLayout, const OUString& rText, bool bTextLines ); diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 2569ff2d5b62..54b486b36afd 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -85,8 +85,6 @@ public: vcl::text::ImplLayoutArgs& rMultiArgs, const double* pMultiDXArray); - virtual bool IsMultiSalLayout() const override; - virtual ~MultiSalLayout() override; private: diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 2082056940f9..cf5ee9dca0f7 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6226,7 +6226,7 @@ void PDFWriterImpl::drawRelief( SalLayout& rLayout, const OUString& rText, bool rLayout.DrawOffset() += Point( nOff, nOff ); updateGraphicsState(); - drawLayout( rLayout, rText, bTextLines, false ); + drawLayout( rLayout, rText, bTextLines ); rLayout.DrawOffset() -= Point( nOff, nOff ); setTextLineColor( aTextLineColor ); @@ -6234,7 +6234,7 @@ void PDFWriterImpl::drawRelief( SalLayout& rLayout, const OUString& rText, bool aSetFont.SetColor( aTextColor ); setFont( aSetFont ); updateGraphicsState(); - drawLayout( rLayout, rText, bTextLines, true ); + drawLayout( rLayout, rText, bTextLines ); // clean up the mess pop(); @@ -6262,7 +6262,7 @@ void PDFWriterImpl::drawShadow( SalLayout& rLayout, const OUString& rText, bool if( rFont.IsOutline() ) nOff++; rLayout.DrawBase() += DevicePoint(nOff, nOff); - drawLayout( rLayout, rText, bTextLines, false ); + drawLayout( rLayout, rText, bTextLines ); rLayout.DrawBase() -= DevicePoint(nOff, nOff); setFont( aSaveFont ); @@ -6279,11 +6279,10 @@ void PDFWriterImpl::drawVerticalGlyphs( double fAngle, double fXScale, double fSkew, - sal_Int32 nFontHeight, - bool bCheck ) + sal_Int32 nFontHeight) { double nXOffset = 0; - Point aCurPos(SubPixelToLogic(rGlyphs[0].m_aPos, bCheck && fAngle == 0.0)); + Point aCurPos(SubPixelToLogic(rGlyphs[0].m_aPos)); aCurPos += rAlignOffset; for( size_t i = 0; i < rGlyphs.size(); i++ ) { @@ -6303,7 +6302,7 @@ void PDFWriterImpl::drawVerticalGlyphs( fSkewA = -fSkewB; fSkewB = 0.0; } - aDeltaPos += SubPixelToLogic(DevicePoint(nXOffset / fXScale, 0), false) - SubPixelToLogic(DevicePoint(), bCheck); + aDeltaPos += SubPixelToLogic(DevicePoint(nXOffset / fXScale, 0)) - SubPixelToLogic(DevicePoint()); if( i < rGlyphs.size()-1 ) // #i120627# the text on the Y axis is reversed when export ppt file to PDF format { @@ -6347,9 +6346,7 @@ void PDFWriterImpl::drawHorizontalGlyphs( double fXScale, double fSkew, sal_Int32 nFontHeight, - sal_Int32 nPixelFontHeight, - bool bCheck - ) + sal_Int32 nPixelFontHeight) { // horizontal (= normal) case @@ -6374,7 +6371,7 @@ void PDFWriterImpl::drawHorizontalGlyphs( for( size_t nRun = 0; nRun < aRunEnds.size(); nRun++ ) { // setup text matrix back transformed to current coordinate system - Point aCurPos(SubPixelToLogic(rGlyphs[nBeginRun].m_aPos, bCheck && fAngle == 0.0)); + Point aCurPos(SubPixelToLogic(rGlyphs[nBeginRun].m_aPos)); aCurPos += rAlignOffset; // the first run can be set with "Td" operator // subsequent use of that operator would move @@ -6445,7 +6442,7 @@ void PDFWriterImpl::drawHorizontalGlyphs( } } -void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool bTextLines, bool bCheckSubPixelToLogic ) +void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool bTextLines ) { // relief takes precedence over shadow (see outdev3.cxx) if( m_aCurrentPDFState.m_aFont.GetRelief() != FontRelief::NONE ) @@ -6677,7 +6674,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool // ascent / descent to match the on-screen rendering. // This is the top left of the text without ascent / descent. DevicePoint aDrawPosition(rLayout.GetDrawPosition()); - tools::Rectangle aRectangle(SubPixelToLogic(aDrawPosition, bCheckSubPixelToLogic), + tools::Rectangle aRectangle(SubPixelToLogic(aDrawPosition), Size(ImplDevicePixelToLogicWidth(rLayout.GetTextWidth()), 0)); aRectangle.AdjustTop(-aRefDevFontMetric.GetAscent()); // This includes ascent / descent. @@ -6688,7 +6685,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool { // Adapt rectangle for rotated text. tools::Polygon aPolygon(aRectangle); - aPolygon.Rotate(SubPixelToLogic(aDrawPosition, bCheckSubPixelToLogic), pFontInstance->mnOrientation); + aPolygon.Rotate(SubPixelToLogic(aDrawPosition), pFontInstance->mnOrientation); drawPolygon(aPolygon); } else @@ -6744,9 +6741,9 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool } if (bVertical) - drawVerticalGlyphs(aRun, aLine, aAlignOffset, aRotScale, fAngle, fXScale, fSkew, nFontHeight, !rLayout.IsMultiSalLayout()); + drawVerticalGlyphs(aRun, aLine, aAlignOffset, aRotScale, fAngle, fXScale, fSkew, nFontHeight); else - drawHorizontalGlyphs(aRun, aLine, aAlignOffset, nStart == 0, fAngle, fXScale, fSkew, nFontHeight, nPixelFontHeight, !rLayout.IsMultiSalLayout()); + drawHorizontalGlyphs(aRun, aLine, aAlignOffset, nStart == 0, fAngle, fXScale, fSkew, nFontHeight, nPixelFontHeight); if (nCharPos >= 0 && nCharCount) aLine.append( "EMC\n" ); @@ -6791,7 +6788,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool } else if( nWidth > 0 ) { - drawTextLine( SubPixelToLogic(aStartPt, bCheckSubPixelToLogic), + drawTextLine( SubPixelToLogic(aStartPt), ImplDevicePixelToLogicWidth( nWidth ), eStrikeout, eUnderline, eOverline, bUnderlineAbove ); nWidth = 0; @@ -6800,7 +6797,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool if( nWidth > 0 ) { - drawTextLine( SubPixelToLogic(aStartPt, bCheckSubPixelToLogic), + drawTextLine( SubPixelToLogic(aStartPt), ImplDevicePixelToLogicWidth( nWidth ), eStrikeout, eUnderline, eOverline, bUnderlineAbove ); } @@ -6809,7 +6806,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool { DevicePoint aStartPt = rLayout.GetDrawPosition(); int nWidth = rLayout.GetTextWidth() / rLayout.GetUnitsPerPixel(); - drawTextLine( SubPixelToLogic(aStartPt, bCheckSubPixelToLogic), + drawTextLine( SubPixelToLogic(aStartPt), ImplDevicePixelToLogicWidth( nWidth ), eStrikeout, eUnderline, eOverline, bUnderlineAbove ); } @@ -6875,7 +6872,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool DevicePoint aMarkDevPos(aPos); aMarkDevPos += aAdjOffset; - Point aMarkPos = SubPixelToLogic(aMarkDevPos, bCheckSubPixelToLogic); + Point aMarkPos = SubPixelToLogic(aMarkDevPos); drawEmphasisMark( aMarkPos.X(), aMarkPos.Y(), aEmphasisMark.GetShape(), aEmphasisMark.IsShapePolyLine(), aEmphasisMark.GetRect1(), aEmphasisMark.GetRect2() ); @@ -6940,7 +6937,7 @@ void PDFWriterImpl::drawText( const Point& rPos, const OUString& rText, sal_Int3 0, {}, {}, SalLayoutFlags::NONE, nullptr, layoutGlyphs ); if( pLayout ) { - drawLayout( *pLayout, rText, bTextLines, true ); + drawLayout( *pLayout, rText, bTextLines ); } } @@ -6958,7 +6955,7 @@ void PDFWriterImpl::drawTextArray( const Point& rPos, const OUString& rText, o3t SalLayoutFlags::NONE, nullptr, layoutGlyphs ); if( pLayout ) { - drawLayout( *pLayout, rText, true, true ); + drawLayout( *pLayout, rText, true ); } } @@ -6976,7 +6973,7 @@ void PDFWriterImpl::drawStretchText( const Point& rPos, sal_uLong nWidth, const {}, {}, SalLayoutFlags::NONE, nullptr, layoutGlyphs ); if( pLayout ) { - drawLayout( *pLayout, rText, true, true ); + drawLayout( *pLayout, rText, true ); } } diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index ea33fd170e58..b960d510ac24 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -265,11 +265,6 @@ SalLayoutGlyphs SalLayout::GetGlyphs() const return SalLayoutGlyphs(); // invalid } -bool SalLayout::IsMultiSalLayout() const -{ - return false; -} - DeviceCoordinate GenericSalLayout::FillDXArray( std::vector<DeviceCoordinate>* pCharWidths, const OUString& rStr ) const { if (pCharWidths) @@ -1217,9 +1212,4 @@ SalLayoutGlyphs MultiSalLayout::GetGlyphs() const return glyphs; } -bool MultiSalLayout::IsMultiSalLayout() const -{ - return true; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index a48e5a3f3670..2c3801bf9e84 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -275,20 +275,16 @@ static double ImplLogicToSubPixel(tools::Long n, tools::Long nDPI, tools::Long n { assert(nDPI > 0); assert(nMapDenom != 0); - double nRet = static_cast<double>(n) * nMapNum * nDPI / nMapDenom; - return nRet; + return static_cast<double>(n) * nMapNum * nDPI / nMapDenom; } -static tools::Long ImplSubPixelToLogic(bool bCheck, double n, tools::Long nDPI, tools::Long nMapNum, +static tools::Long ImplSubPixelToLogic(double n, tools::Long nDPI, tools::Long nMapNum, tools::Long nMapDenom) { assert(nDPI > 0); assert(nMapNum != 0); - double nRes = n * nMapDenom / nMapNum / nDPI; - tools::Long nRet(std::round(nRes)); - assert(!bCheck || rtl_math_approxValue(n) == rtl_math_approxValue(static_cast<double>(nRet) * nMapNum * nDPI / nMapDenom)); (void)bCheck; - return nRet; + return std::round(n * nMapDenom / nMapNum / nDPI); } static tools::Long ImplPixelToLogic(tools::Long n, tools::Long nDPI, tools::Long nMapNum, @@ -1178,7 +1174,7 @@ Point OutputDevice::PixelToLogic( const Point& rDevicePt ) const maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY ) - maMapRes.mnMapOfsY - mnOutOffLogicY ); } -Point OutputDevice::SubPixelToLogic(const DevicePoint& rDevicePt, bool bCheck) const +Point OutputDevice::SubPixelToLogic(const DevicePoint& rDevicePt) const { if (!mbMap) { @@ -1186,9 +1182,9 @@ Point OutputDevice::SubPixelToLogic(const DevicePoint& rDevicePt, bool bCheck) c return Point(rDevicePt.getX(), rDevicePt.getY()); } - return Point(ImplSubPixelToLogic(bCheck, rDevicePt.getX(), mnDPIX, + return Point(ImplSubPixelToLogic(rDevicePt.getX(), mnDPIX, maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX) - maMapRes.mnMapOfsX - mnOutOffLogicX, - ImplSubPixelToLogic(bCheck, rDevicePt.getY(), mnDPIY, + ImplSubPixelToLogic(rDevicePt.getY(), mnDPIY, maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY) - maMapRes.mnMapOfsY - mnOutOffLogicY); }