diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-05-21 17:31:48 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-05-21 21:35:53 +0200 |
commit | 098df8583bc8d4a8d0210525f05f69b460386a46 (patch) | |
tree | f3fb4046cd87db04c442ae2f2410ba31ae29be30 | |
parent | 11e4235930f05906311f7b70444b0a6487d59a47 (diff) |
ofz#47559 Integer-overflow
setLinearPosX already takes a double so use that type for nOffset,
use DeviceCoordinate as the types where that is the type of the
source data
Change-Id: I411d5034a42648bab94d6b8789bbdd172d0cf841
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134713
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/inc/impglyphitem.hxx | 14 | ||||
-rw-r--r-- | vcl/source/gdi/sallayout.cxx | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/vcl/inc/impglyphitem.hxx b/vcl/inc/impglyphitem.hxx index 18764cede500..7c3aa88849df 100644 --- a/vcl/inc/impglyphitem.hxx +++ b/vcl/inc/impglyphitem.hxx @@ -52,18 +52,18 @@ template <> struct typed_flags<GlyphItemFlags> : is_typed_flags<GlyphItemFlags, class VCL_DLLPUBLIC GlyphItem { DevicePoint m_aLinearPos; // absolute position of non rotated string - sal_Int32 m_nOrigWidth; // original glyph width + DeviceCoordinate m_nOrigWidth; // original glyph width sal_Int32 m_nCharPos; // index in string sal_Int32 m_nXOffset; sal_Int32 m_nYOffset; - sal_Int32 m_nNewWidth; // width after adjustments + DeviceCoordinate m_nNewWidth; // width after adjustments sal_GlyphId m_aGlyphId; GlyphItemFlags m_nFlags; sal_Int8 m_nCharCount; // number of characters making up this glyph public: GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const DevicePoint& rLinearPos, - GlyphItemFlags nFlags, int nOrigWidth, int nXOffset, int nYOffset) + GlyphItemFlags nFlags, DeviceCoordinate nOrigWidth, int nXOffset, int nYOffset) : m_aLinearPos(rLinearPos) , m_nOrigWidth(nOrigWidth) , m_nCharPos(nCharPos) @@ -92,15 +92,15 @@ public: sal_GlyphId glyphId() const { return m_aGlyphId; } int charCount() const { return m_nCharCount; } - int origWidth() const { return m_nOrigWidth; } + DeviceCoordinate origWidth() const { return m_nOrigWidth; } int charPos() const { return m_nCharPos; } int xOffset() const { return m_nXOffset; } int yOffset() const { return m_nYOffset; } - sal_Int32 newWidth() const { return m_nNewWidth; } + DeviceCoordinate newWidth() const { return m_nNewWidth; } const DevicePoint& linearPos() const { return m_aLinearPos; } - void setNewWidth(sal_Int32 width) { m_nNewWidth = width; } - void addNewWidth(sal_Int32 width) { m_nNewWidth += width; } + void setNewWidth(DeviceCoordinate width) { m_nNewWidth = width; } + void addNewWidth(DeviceCoordinate width) { m_nNewWidth += width; } void setLinearPos(const DevicePoint& point) { m_aLinearPos = point; } void setLinearPosX(double x) { m_aLinearPos.setX(x); } void adjustLinearPosX(double diff) { m_aLinearPos.adjustX(diff); } diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 81897ac68bbd..d76d72c490e9 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -411,7 +411,7 @@ static bool lcl_CanApplyAsianKerning(sal_Unicode cp) void GenericSalLayout::ApplyAsianKerning(const OUString& rStr) { const int nLength = rStr.getLength(); - tools::Long nOffset = 0; + double nOffset = 0; for (std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.begin(), pGlyphIterEnd = m_GlyphItems.end(); @@ -437,7 +437,7 @@ void GenericSalLayout::ApplyAsianKerning(const OUString& rStr) continue; // apply punctuation compression to logical glyph widths - int nDelta = (nKernCurrent < nKernNext) ? nKernCurrent : nKernNext; + DeviceCoordinate nDelta = (nKernCurrent < nKernNext) ? nKernCurrent : nKernNext; if (nDelta < 0) { nDelta = (nDelta * pGlyphIter->origWidth() + 2) / 4; |