diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-08-24 11:32:30 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-08-25 09:51:12 +0200 |
commit | 38a29acd7e305ec99c4eb1871b9f31f75a3ab80c (patch) | |
tree | c81a5ae2ba8c70b836e468244e9456f732ba1ab1 | |
parent | 241ce1488b8354f6c203d4feaef8a9fed9a3f52c (diff) |
use DevicePoint and SubPixelToLogic to return to source coord system
Change-Id: I1aeae6270feb6cb0a44b7850e1b3143e68ae780f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138770
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/inc/pdf/Matrix3.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/pdf/pdfwriter_impl.hxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 25 | ||||
-rw-r--r-- | vcl/source/pdf/Matrix3.cxx | 6 |
4 files changed, 21 insertions, 16 deletions
diff --git a/vcl/inc/pdf/Matrix3.hxx b/vcl/inc/pdf/Matrix3.hxx index 795b2af4be52..da88cc31399b 100644 --- a/vcl/inc/pdf/Matrix3.hxx +++ b/vcl/inc/pdf/Matrix3.hxx @@ -11,6 +11,7 @@ #pragma once #include <vcl/dllapi.h> +#include <vcl/devicecoordinate.hxx> #include <tools/gen.hxx> namespace vcl::pdf @@ -45,6 +46,7 @@ public: double get(size_t i) const { return f[i]; } Point transform(const Point& rPoint) const; + DevicePoint transform(const DevicePoint& rPoint) const; }; } diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx index 4ebddbe5edaf..9af21e81baee 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -579,14 +579,14 @@ struct PDFAddStream // helper structure for drawLayout and friends struct PDFGlyph { - Point const m_aPos; + DevicePoint const m_aPos; const GlyphItem* m_pGlyph; sal_Int32 const m_nNativeWidth; sal_Int32 const m_nMappedFontId; sal_uInt8 const m_nMappedGlyphId; int const m_nCharPos; - PDFGlyph( const Point& rPos, + PDFGlyph( const DevicePoint& rPos, const GlyphItem* pGlyph, sal_Int32 nNativeWidth, sal_Int32 nFontId, diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 48a8b472df03..74b7ccdbcf7d 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -5944,8 +5944,7 @@ void PDFWriterImpl::drawVerticalGlyphs( sal_Int32 nFontHeight ) { tools::Long nXOffset = 0; - Point aCurPos( rGlyphs[0].m_aPos ); - aCurPos = PixelToLogic( aCurPos ); + Point aCurPos(SubPixelToLogic(rGlyphs[0].m_aPos)); aCurPos += rAlignOffset; for( size_t i = 0; i < rGlyphs.size(); i++ ) { @@ -5969,9 +5968,9 @@ void PDFWriterImpl::drawVerticalGlyphs( if( i < rGlyphs.size()-1 ) // #i120627# the text on the Y axis is reversed when export ppt file to PDF format { - tools::Long nOffsetX = rGlyphs[i+1].m_aPos.X() - rGlyphs[i].m_aPos.X(); - tools::Long nOffsetY = rGlyphs[i+1].m_aPos.Y() - rGlyphs[i].m_aPos.Y(); - nXOffset += static_cast<int>(sqrt(double(nOffsetX*nOffsetX + nOffsetY*nOffsetY))); + double nOffsetX = rGlyphs[i+1].m_aPos.getX() - rGlyphs[i].m_aPos.getX(); + double nOffsetY = rGlyphs[i+1].m_aPos.getY() - rGlyphs[i].m_aPos.getY(); + nXOffset += static_cast<int>(sqrt(nOffsetX*nOffsetX + nOffsetY*nOffsetY)); } if (!rGlyphs[i].m_pGlyph->glyphId()) continue; @@ -6022,7 +6021,7 @@ void PDFWriterImpl::drawHorizontalGlyphs( for( size_t i = 1; i < rGlyphs.size(); i++ ) { if( rGlyphs[i].m_nMappedFontId != rGlyphs[i-1].m_nMappedFontId || - rGlyphs[i].m_aPos.Y() != rGlyphs[i-1].m_aPos.Y() ) + rGlyphs[i].m_aPos.getY() != rGlyphs[i-1].m_aPos.getY() ) { aRunEnds.push_back(i); } @@ -6034,10 +6033,8 @@ void PDFWriterImpl::drawHorizontalGlyphs( sal_uInt32 nBeginRun = 0; for( size_t nRun = 0; nRun < aRunEnds.size(); nRun++ ) { - // setup text matrix - Point aCurPos = rGlyphs[nBeginRun].m_aPos; - // back transformation to current coordinate system - aCurPos = PixelToLogic( aCurPos ); + // setup text matrix back transformed to current coordinate system + 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 @@ -6079,9 +6076,9 @@ void PDFWriterImpl::drawHorizontalGlyphs( { appendHex( rGlyphs[nPos].m_nMappedGlyphId, aUnkernedLine ); // check if default glyph positioning is sufficient - const Point aThisPos = aMat.transform( rGlyphs[nPos].m_aPos ); - const Point aPrevPos = aMat.transform( rGlyphs[nPos-1].m_aPos ); - double fAdvance = aThisPos.X() - aPrevPos.X(); + const DevicePoint aThisPos = aMat.transform( rGlyphs[nPos].m_aPos ); + const DevicePoint aPrevPos = aMat.transform( rGlyphs[nPos-1].m_aPos ); + double fAdvance = aThisPos.getX() - aPrevPos.getX(); fAdvance *= 1000.0 / nPixelFontHeight; const double fAdjustment = rGlyphs[nPos-1].m_nNativeWidth - fAdvance + 0.5; SAL_WARN_IF( @@ -6320,7 +6317,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool if (bUseActualText || pGlyph->IsInCluster()) nCharPos = pGlyph->charPos(); - aGlyphs.emplace_back(Point(aPos.getX(), aPos.getY()), + aGlyphs.emplace_back(aPos, pGlyph, nGlyphWidth, nMappedFontObject, diff --git a/vcl/source/pdf/Matrix3.cxx b/vcl/source/pdf/Matrix3.cxx index 475f87d966df..7b225c3a68b4 100644 --- a/vcl/source/pdf/Matrix3.cxx +++ b/vcl/source/pdf/Matrix3.cxx @@ -30,6 +30,12 @@ Point Matrix3::transform(const Point& rOrig) const return Point(x * f[0] + y * f[2] + f[4], x * f[1] + y * f[3] + f[5]); } +DevicePoint Matrix3::transform(const DevicePoint& rOrig) const +{ + double x = rOrig.getX(), y = rOrig.getY(); + return DevicePoint(x * f[0] + y * f[2] + f[4], x * f[1] + y * f[3] + f[5]); +} + void Matrix3::skew(double alpha, double beta) { double fn[6]; |