diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-10-27 21:44:39 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-10-30 12:45:03 +0100 |
commit | adf71090c94b90d95d3b320e070d53b7071751cd (patch) | |
tree | 1760879530bf5cdfec74f8b1478a0a7e55856ffe | |
parent | 7b0f2ee441b0cbcb88f3020df40c49e7cd6f9fb1 (diff) |
Hide SalLayoutGlyphs details
Nobody outside of VCL should deal with GlyphItems.
Change-Id: Id84b0f320bc49f790658f23efe129b92262c2aea
Reviewed-on: https://gerrit.libreoffice.org/62446
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
-rw-r--r-- | include/vcl/glyphitem.hxx | 65 | ||||
-rw-r--r-- | include/vcl/outdev.hxx | 3 | ||||
-rw-r--r-- | include/vcl/vcllayout.hxx | 4 | ||||
-rw-r--r-- | vcl/Library_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/inc/impglyphitem.hxx | 76 | ||||
-rw-r--r-- | vcl/inc/sallayout.hxx | 2 | ||||
-rw-r--r-- | vcl/quartz/ctfonts.cxx | 4 | ||||
-rw-r--r-- | vcl/source/control/imp_listbox.cxx | 1 | ||||
-rw-r--r-- | vcl/source/gdi/CommonSalLayout.cxx | 53 | ||||
-rw-r--r-- | vcl/source/gdi/impglyphitem.cxx | 47 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 1 | ||||
-rw-r--r-- | vcl/source/gdi/sallayout.cxx | 48 | ||||
-rw-r--r-- | vcl/source/outdev/font.cxx | 1 | ||||
-rw-r--r-- | vcl/source/outdev/text.cxx | 1 | ||||
-rw-r--r-- | vcl/source/outdev/textline.cxx | 1 | ||||
-rw-r--r-- | vcl/source/window/menu.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/menuitemlist.cxx | 1 | ||||
-rw-r--r-- | vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 4 | ||||
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 4 |
19 files changed, 200 insertions, 119 deletions
diff --git a/include/vcl/glyphitem.hxx b/include/vcl/glyphitem.hxx index 5019e5825c47..75213a5b49c5 100644 --- a/include/vcl/glyphitem.hxx +++ b/include/vcl/glyphitem.hxx @@ -20,64 +20,27 @@ #ifndef INCLUDED_VCL_GLYPHITEM_HXX #define INCLUDED_VCL_GLYPHITEM_HXX -#include <rtl/ref.hxx> -#include <tools/gen.hxx> -#include <vcl/dllapi.h> - -class LogicalFontInstance; - typedef sal_uInt16 sal_GlyphId; -struct VCL_DLLPUBLIC GlyphItem -{ - int m_nFlags; - int m_nCharPos; // index in string - int m_nCharCount; // number of characters m_aking up this glyph +struct GlyphItem; +class SalLayoutGlyphsImpl; - int m_nOrigWidth; // original glyph width - int m_nNewWidth; // width after adjustments - int m_nXOffset; - - sal_GlyphId m_aGlyphId; - Point m_aLinearPos; // absolute position of non rotated string +class VCL_DLLPUBLIC SalLayoutGlyphs final +{ + friend class SalLayoutGlyphsImpl; + SalLayoutGlyphsImpl* m_pImpl; - LogicalFontInstance* m_pFontInstance; +public: + SalLayoutGlyphs(); + SalLayoutGlyphs(const SalLayoutGlyphs&); + ~SalLayoutGlyphs(); - GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const Point& rLinearPos, - long nFlags, int nOrigWidth, int nXOffset, LogicalFontInstance* pFontInstance) - : m_nFlags(nFlags) - , m_nCharPos(nCharPos) - , m_nCharCount(nCharCount) - , m_nOrigWidth(nOrigWidth) - , m_nNewWidth(nOrigWidth) - , m_nXOffset(nXOffset) - , m_aGlyphId(aGlyphId) - , m_aLinearPos(rLinearPos) - , m_pFontInstance(pFontInstance) - { - assert(pFontInstance); - } + SalLayoutGlyphs& operator=(const SalLayoutGlyphs&); - enum - { - IS_IN_CLUSTER = 0x001, - IS_RTL_GLYPH = 0x002, - IS_DIACRITIC = 0x004, - IS_VERTICAL = 0x008, - IS_SPACING = 0x010, - ALLOW_KASHIDA = 0x020, - IS_DROPPED = 0x040, - IS_CLUSTER_START = 0x080 - }; + SalLayoutGlyphsImpl* Impl() const { return m_pImpl; } - bool IsInCluster() const { return ((m_nFlags & IS_IN_CLUSTER) != 0); } - bool IsRTLGlyph() const { return ((m_nFlags & IS_RTL_GLYPH) != 0); } - bool IsDiacritic() const { return ((m_nFlags & IS_DIACRITIC) != 0); } - bool IsVertical() const { return ((m_nFlags & IS_VERTICAL) != 0); } - bool IsSpacing() const { return ((m_nFlags & IS_SPACING) != 0); } - bool AllowKashida() const { return ((m_nFlags & ALLOW_KASHIDA) != 0); } - bool IsDropped() const { return ((m_nFlags & IS_DROPPED) != 0); } - bool IsClusterStart() const { return ((m_nFlags & IS_CLUSTER_START) != 0); } + bool empty() const; + void clear(); }; #endif // INCLUDED_VCL_GLYPHITEM_HXX diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 8970fe0e3788..8f93be10c284 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -31,6 +31,7 @@ #include <vcl/devicecoordinate.hxx> #include <vcl/dllapi.h> #include <vcl/font.hxx> +#include <vcl/glyphitem.hxx> #include <vcl/region.hxx> #include <vcl/mapmod.hxx> #include <vcl/wall.hxx> @@ -150,8 +151,6 @@ namespace o3tl } typedef std::vector< tools::Rectangle > MetricVector; -struct GlyphItem; -typedef std::vector<GlyphItem> SalLayoutGlyphs; // OutputDevice-Types diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx index 3237973e9ffc..ced231713966 100644 --- a/include/vcl/vcllayout.hxx +++ b/include/vcl/vcllayout.hxx @@ -27,6 +27,7 @@ #include <tools/gen.hxx> #include <vcl/devicecoordinate.hxx> #include <vcl/dllapi.h> +#include <vcl/glyphitem.hxx> class ImplLayoutArgs; class PhysicalFontFace; @@ -36,9 +37,6 @@ namespace vcl class TextLayoutCache; } -struct GlyphItem; -typedef std::vector<GlyphItem> SalLayoutGlyphs; - // all positions/widths are in font units // one exception: drawposition is in pixel units diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index a16134017627..8e8460c71ba9 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -252,6 +252,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/gdi/graphictools \ vcl/source/gdi/hatch \ vcl/source/gdi/impanmvw \ + vcl/source/gdi/impglyphitem \ vcl/source/gdi/impgraph \ vcl/source/gdi/impvect \ vcl/source/gdi/jobset \ diff --git a/vcl/inc/impglyphitem.hxx b/vcl/inc/impglyphitem.hxx index a4843be677fb..7c5dc66d1d8b 100644 --- a/vcl/inc/impglyphitem.hxx +++ b/vcl/inc/impglyphitem.hxx @@ -20,21 +20,85 @@ #ifndef INCLUDED_VCL_IMPGLYPHITEM_HXX #define INCLUDED_VCL_IMPGLYPHITEM_HXX +#include <tools/gen.hxx> +#include <vcl/dllapi.h> #include <vcl/glyphitem.hxx> +#include <vector> -// for whatever reason MSVC tries to export these when declared class inline even -// when annotated with VCL_DLLPRIVATE, so keep them as seperate static inline. +#include "fontinstance.hxx" -static inline bool GetCachedGlyphBoundRect(const GlyphItem& rItem, tools::Rectangle& rRect) +struct VCL_DLLPUBLIC GlyphItem { - return rItem.m_pFontInstance->GetCachedGlyphBoundRect(rItem.m_aGlyphId, rRect); + sal_GlyphId m_aGlyphId; + int m_nCharCount; // number of characters making up this glyph + int m_nOrigWidth; // original glyph width + LogicalFontInstance* m_pFontInstance; + + int m_nCharPos; // index in string + int m_nFlags; + int m_nNewWidth; // width after adjustments + int m_nXOffset; + Point m_aLinearPos; // absolute position of non rotated string + + GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const Point& rLinearPos, + long nFlags, int nOrigWidth, int nXOffset, LogicalFontInstance* pFontInstance) + : m_aGlyphId(aGlyphId) + , m_nCharCount(nCharCount) + , m_nOrigWidth(nOrigWidth) + , m_pFontInstance(pFontInstance) + , m_nCharPos(nCharPos) + , m_nFlags(nFlags) + , m_nNewWidth(nOrigWidth) + , m_nXOffset(nXOffset) + , m_aLinearPos(rLinearPos) + { + assert(m_pFontInstance); + } + + enum + { + IS_IN_CLUSTER = 0x001, + IS_RTL_GLYPH = 0x002, + IS_DIACRITIC = 0x004, + IS_VERTICAL = 0x008, + IS_SPACING = 0x010, + ALLOW_KASHIDA = 0x020, + IS_DROPPED = 0x040, + IS_CLUSTER_START = 0x080 + }; + + bool IsInCluster() const { return ((m_nFlags & IS_IN_CLUSTER) != 0); } + bool IsRTLGlyph() const { return ((m_nFlags & IS_RTL_GLYPH) != 0); } + bool IsDiacritic() const { return ((m_nFlags & IS_DIACRITIC) != 0); } + bool IsVertical() const { return ((m_nFlags & IS_VERTICAL) != 0); } + bool IsSpacing() const { return ((m_nFlags & IS_SPACING) != 0); } + bool AllowKashida() const { return ((m_nFlags & ALLOW_KASHIDA) != 0); } + bool IsDropped() const { return ((m_nFlags & IS_DROPPED) != 0); } + bool IsClusterStart() const { return ((m_nFlags & IS_CLUSTER_START) != 0); } + + inline bool GetCachedGlyphBoundRect(tools::Rectangle& rRect) const; + inline void CacheGlyphBoundRect(tools::Rectangle& rRect) const; +}; + +VCL_DLLPUBLIC bool GlyphItem::GetCachedGlyphBoundRect(tools::Rectangle& rRect) const +{ + return m_pFontInstance->GetCachedGlyphBoundRect(m_aGlyphId, rRect); } -static inline void CacheGlyphBoundRect(const GlyphItem& rItem, tools::Rectangle& rRect) +VCL_DLLPUBLIC void GlyphItem::CacheGlyphBoundRect(tools::Rectangle& rRect) const { - rItem.m_pFontInstance->CacheGlyphBoundRect(rItem.m_aGlyphId, rRect); + m_pFontInstance->CacheGlyphBoundRect(m_aGlyphId, rRect); } +class SalLayoutGlyphsImpl : public std::vector<GlyphItem> +{ + friend class GenericSalLayout; + friend class SalLayoutGlyphs; + void SetPImpl(SalLayoutGlyphs* pFacade) { pFacade->m_pImpl = this; } + + SalLayoutGlyphsImpl(SalLayoutGlyphs& rGlyphs) { SetPImpl(&rGlyphs); } +}; + #endif // INCLUDED_VCL_IMPGLYPHITEM_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 6b2ca93a7a39..972631d838e8 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -37,7 +37,7 @@ #include <vcl/devicecoordinate.hxx> #include <vcl/vcllayout.hxx> -#include "fontinstance.hxx" +#include "impglyphitem.hxx" #define MAX_FALLBACK 16 diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index 1425f7d1617b..fee6a676ac6c 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -141,7 +141,7 @@ void CoreTextStyle::GetFontMetric( ImplFontMetricDataRef const & rxFontMetric ) bool CoreTextStyle::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect ) { assert(this == rGlyph.m_pFontInstance); - if (::GetCachedGlyphBoundRect(rGlyph, rRect)) + if (rGlyph.GetCachedGlyphBoundRect(rRect)) return true; CGGlyph nCGGlyph = rGlyph.m_aGlyphId; @@ -162,7 +162,7 @@ bool CoreTextStyle::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& long yMax = ceil(aCGRect.origin.y + aCGRect.size.height); rRect = tools::Rectangle(xMin, -yMax, xMax, -yMin); - ::CacheGlyphBoundRect(rGlyph, rRect); + rGlyph.CacheGlyphBoundRect(rRect); return true; } diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx index 6433c49c3bd7..174e6a01fbd9 100644 --- a/vcl/source/control/imp_listbox.cxx +++ b/vcl/source/control/imp_listbox.cxx @@ -32,6 +32,7 @@ #include <controldata.hxx> #include <svdata.hxx> #include <window.h> +#include <impglyphitem.hxx> #include <com/sun/star/i18n/XCollator.hpp> #include <com/sun/star/accessibility/XAccessible.hpp> diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 8831d9457174..0fc540fcb823 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -61,6 +61,7 @@ GenericSalLayout::GenericSalLayout(LogicalFontInstance &rFont) , mpVertGlyphs(nullptr) , mbFuzzing(utl::ConfigManager::IsFuzzing()) { + new SalLayoutGlyphsImpl(m_GlyphItems); } GenericSalLayout::~GenericSalLayout() @@ -279,7 +280,7 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphs* hb_font_t *pHbFont = mpFont->GetHbFont(); int nGlyphCapacity = 2 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos); - m_GlyphItems.reserve(nGlyphCapacity); + m_GlyphItems.Impl()->reserve(nGlyphCapacity); const int nLength = rArgs.mrStr.getLength(); const sal_Unicode *pStr = rArgs.mrStr.getStr(); @@ -571,7 +572,7 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphs* Point aNewPos(aCurrPos.X() + nXOffset, aCurrPos.Y() + nYOffset); const GlyphItem aGI(nCharPos, nCharCount, nGlyphIndex, aNewPos, nGlyphFlags, nAdvance, nXOffset, mpFont.get()); - m_GlyphItems.push_back(aGI); + m_GlyphItems.Impl()->push_back(aGI); aCurrPos.AdjustX(nAdvance ); } @@ -590,7 +591,7 @@ void GenericSalLayout::GetCharWidths(DeviceCoordinate* pCharWidths) const for (int i = 0; i < nCharCount; ++i) pCharWidths[i] = 0; - for (auto const& aGlyphItem : m_GlyphItems) + for (auto const& aGlyphItem : *m_GlyphItems.Impl()) { const int nIndex = aGlyphItem.m_nCharPos - mnMinCharPos; if (nIndex >= nCharCount) @@ -659,31 +660,31 @@ void GenericSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs) // Apply the DX adjustments to glyph positions and widths. size_t i = 0; - while (i < m_GlyphItems.size()) + while (i < m_GlyphItems.Impl()->size()) { // Accumulate the width difference for all characters corresponding to // this glyph. - int nCharPos = m_GlyphItems[i].m_nCharPos - mnMinCharPos; + int nCharPos = (*m_GlyphItems.Impl())[i].m_nCharPos - mnMinCharPos; DeviceCoordinate nDiff = 0; - for (int j = 0; j < m_GlyphItems[i].m_nCharCount; j++) + for (int j = 0; j < (*m_GlyphItems.Impl())[i].m_nCharCount; j++) nDiff += pNewCharWidths[nCharPos + j] - pOldCharWidths[nCharPos + j]; - if (!m_GlyphItems[i].IsRTLGlyph()) + if (!(*m_GlyphItems.Impl())[i].IsRTLGlyph()) { // Adjust the width and position of the first (leftmost) glyph in // the cluster. - m_GlyphItems[i].m_nNewWidth += nDiff; - m_GlyphItems[i].m_aLinearPos.AdjustX(nDelta); + (*m_GlyphItems.Impl())[i].m_nNewWidth += nDiff; + (*m_GlyphItems.Impl())[i].m_aLinearPos.AdjustX(nDelta); // Adjust the position of the rest of the glyphs in the cluster. - while (++i < m_GlyphItems.size()) + while (++i < m_GlyphItems.Impl()->size()) { - if (!m_GlyphItems[i].IsInCluster()) + if (!(*m_GlyphItems.Impl())[i].IsInCluster()) break; - m_GlyphItems[i].m_aLinearPos.AdjustX(nDelta); + (*m_GlyphItems.Impl())[i].m_aLinearPos.AdjustX(nDelta); } } - else if (m_GlyphItems[i].IsInCluster()) + else if ((*m_GlyphItems.Impl())[i].IsInCluster()) { // RTL glyph in the middle of the cluster, will be handled in the // loop below. @@ -694,34 +695,34 @@ void GenericSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs) // Adjust the width and position of the first (rightmost) glyph in // the cluster. // For RTL, we put all the adjustment to the left of the glyph. - m_GlyphItems[i].m_nNewWidth += nDiff; - m_GlyphItems[i].m_aLinearPos.AdjustX(nDelta + nDiff); + (*m_GlyphItems.Impl())[i].m_nNewWidth += nDiff; + (*m_GlyphItems.Impl())[i].m_aLinearPos.AdjustX(nDelta + nDiff); // Adjust the X position of all glyphs in the cluster. size_t j = i; while (j > 0) { --j; - if (!m_GlyphItems[j].IsInCluster()) + if (!(*m_GlyphItems.Impl())[j].IsInCluster()) break; - m_GlyphItems[j].m_aLinearPos.AdjustX(nDelta + nDiff); + (*m_GlyphItems.Impl())[j].m_aLinearPos.AdjustX(nDelta + nDiff); } // If this glyph is Kashida-justifiable, then mark this as a // Kashida position. Since this must be a RTL glyph, we mark the // last glyph in the cluster not the first as this would be the // base glyph. - if (bKashidaJustify && m_GlyphItems[i].AllowKashida() && - nDiff > m_GlyphItems[i].m_nCharCount) // Rounding errors, 1 pixel per character! + if (bKashidaJustify && (*m_GlyphItems.Impl())[i].AllowKashida() && + nDiff > (*m_GlyphItems.Impl())[i].m_nCharCount) // Rounding errors, 1 pixel per character! { pKashidas[i] = nDiff; // Move any non-spacing marks attached to this cluster as well. // Looping backward because this is RTL glyph. while (j > 0) { - if (!m_GlyphItems[j].IsDiacritic()) + if (!(*m_GlyphItems.Impl())[j].IsDiacritic()) break; - m_GlyphItems[j--].m_aLinearPos.AdjustX(nDiff); + (*m_GlyphItems.Impl())[j--].m_aLinearPos.AdjustX(nDiff); } } i++; @@ -740,7 +741,7 @@ void GenericSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs) size_t nInserted = 0; for (auto const& pKashida : pKashidas) { - auto pGlyphIter = m_GlyphItems.begin() + nInserted + pKashida.first; + auto pGlyphIter = m_GlyphItems.Impl()->begin() + nInserted + pKashida.first; // The total Kashida width. DeviceCoordinate nTotalWidth = pKashida.second; @@ -768,7 +769,7 @@ void GenericSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs) while (nCopies--) { GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, nKashidaWidth, 0, mpFont.get()); - pGlyphIter = m_GlyphItems.insert(pGlyphIter, aKashida); + pGlyphIter = m_GlyphItems.Impl()->insert(pGlyphIter, aKashida); aPos.AdjustX(nKashidaWidth ); aPos.AdjustX( -nOverlap ); ++pGlyphIter; @@ -780,7 +781,7 @@ void GenericSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs) bool GenericSalLayout::IsKashidaPosValid(int nCharPos) const { - for (auto pIter = m_GlyphItems.begin(); pIter != m_GlyphItems.end(); ++pIter) + for (auto pIter = m_GlyphItems.Impl()->begin(); pIter != m_GlyphItems.Impl()->end(); ++pIter) { if (pIter->m_nCharPos == nCharPos) { @@ -788,7 +789,7 @@ bool GenericSalLayout::IsKashidaPosValid(int nCharPos) const // changed the text styling in the middle of a word. Since we don’t // do ligatures across layout engine instances, this can’t be a // ligature so it should be fine. - if (pIter == m_GlyphItems.begin()) + if (pIter == m_GlyphItems.Impl()->begin()) return true; // If the character is not supported by this layout, return false @@ -799,7 +800,7 @@ bool GenericSalLayout::IsKashidaPosValid(int nCharPos) const // Search backwards for previous glyph belonging to a different // character. We are looking backwards because we are dealing with // RTL glyphs, which will be in visual order. - for (auto pPrev = pIter - 1; pPrev != m_GlyphItems.begin(); --pPrev) + for (auto pPrev = pIter - 1; pPrev != m_GlyphItems.Impl()->begin(); --pPrev) { if (pPrev->m_nCharPos != nCharPos) { diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx new file mode 100644 index 000000000000..ee30ee5ab2df --- /dev/null +++ b/vcl/source/gdi/impglyphitem.cxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <impglyphitem.hxx> + +SalLayoutGlyphs::SalLayoutGlyphs() + : m_pImpl(nullptr) +{ +} + +SalLayoutGlyphs::~SalLayoutGlyphs() { delete m_pImpl; } + +SalLayoutGlyphs::SalLayoutGlyphs(const SalLayoutGlyphs& rOther) { *m_pImpl = *rOther.m_pImpl; } + +SalLayoutGlyphs& SalLayoutGlyphs::operator=(const SalLayoutGlyphs& rOther) +{ + if (!m_pImpl) + m_pImpl = new SalLayoutGlyphsImpl(*this); + *m_pImpl = *rOther.m_pImpl; + return *this; +} + +bool SalLayoutGlyphs::empty() const { return !m_pImpl || m_pImpl->empty(); } + +void SalLayoutGlyphs::clear() +{ + if (m_pImpl) + m_pImpl->clear(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 5abb8998032f..ba20619a5118 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -84,6 +84,7 @@ #include <textlayout.hxx> #include <textlineinfo.hxx> #include <bitmapwriteaccess.hxx> +#include <impglyphitem.hxx> #include "pdfwriter_impl.hxx" diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 33013696ee84..4ecf9a26193d 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -45,6 +45,8 @@ #include <algorithm> #include <memory> +#include <impglyphitem.hxx> + // Glyph Flags #define GF_FONTMASK 0xF0000000 #define GF_FONTSHIFT 28 @@ -710,7 +712,7 @@ DeviceCoordinate GenericSalLayout::GetTextWidth() const DeviceCoordinate nMinPos = 0; DeviceCoordinate nMaxPos = 0; - for (auto const& aGlyphItem : m_GlyphItems) + for (auto const& aGlyphItem : *m_GlyphItems.Impl()) { // update the text extent with the glyph extent DeviceCoordinate nXPos = aGlyphItem.m_aLinearPos.X(); @@ -737,13 +739,13 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) return; } // find rightmost glyph, it won't get stretched - std::vector<GlyphItem>::iterator pGlyphIterRight = m_GlyphItems.begin(); - pGlyphIterRight += m_GlyphItems.size() - 1; + std::vector<GlyphItem>::iterator pGlyphIterRight = m_GlyphItems.Impl()->begin(); + pGlyphIterRight += m_GlyphItems.Impl()->size() - 1; std::vector<GlyphItem>::iterator pGlyphIter; // count stretchable glyphs int nStretchable = 0; int nMaxGlyphWidth = 0; - for(pGlyphIter = m_GlyphItems.begin(); pGlyphIter != pGlyphIterRight; ++pGlyphIter) + for(pGlyphIter = m_GlyphItems.Impl()->begin(); pGlyphIter != pGlyphIterRight; ++pGlyphIter) { if( !pGlyphIter->IsDiacritic() ) ++nStretchable; @@ -766,7 +768,7 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) { // expand width by distributing space between glyphs evenly int nDeltaSum = 0; - for( pGlyphIter = m_GlyphItems.begin(); pGlyphIter != pGlyphIterRight; ++pGlyphIter ) + for( pGlyphIter = m_GlyphItems.Impl()->begin(); pGlyphIter != pGlyphIterRight; ++pGlyphIter ) { // move glyph to justified position pGlyphIter->m_aLinearPos.AdjustX(nDeltaSum ); @@ -786,9 +788,9 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) { // squeeze width by moving glyphs proportionally double fSqueeze = static_cast<double>(nNewWidth) / nOldWidth; - if(m_GlyphItems.size() > 1) + if(m_GlyphItems.Impl()->size() > 1) { - for( pGlyphIter = m_GlyphItems.begin(); ++pGlyphIter != pGlyphIterRight;) + for( pGlyphIter = m_GlyphItems.Impl()->begin(); ++pGlyphIter != pGlyphIterRight;) { int nX = pGlyphIter->m_aLinearPos.X(); nX = static_cast<int>(nX * fSqueeze); @@ -796,7 +798,7 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth ) } } // adjust glyph widths to new positions - for( pGlyphIter = m_GlyphItems.begin(); pGlyphIter != pGlyphIterRight; ++pGlyphIter ) + for( pGlyphIter = m_GlyphItems.Impl()->begin(); pGlyphIter != pGlyphIterRight; ++pGlyphIter ) pGlyphIter->m_nNewWidth = pGlyphIter[1].m_aLinearPos.X() - pGlyphIter[0].m_aLinearPos.X(); } } @@ -806,7 +808,7 @@ void GenericSalLayout::ApplyAsianKerning(const OUString& rStr) const int nLength = rStr.getLength(); long nOffset = 0; - for( std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.begin(), pGlyphIterEnd = m_GlyphItems.end(); pGlyphIter != pGlyphIterEnd; ++pGlyphIter ) + for( std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.Impl()->begin(), pGlyphIterEnd = m_GlyphItems.Impl()->end(); pGlyphIter != pGlyphIterEnd; ++pGlyphIter ) { const int n = pGlyphIter->m_nCharPos; if( n < nLength - 1) @@ -849,7 +851,7 @@ void GenericSalLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) co pCaretXArray[i] = -1; // calculate caret positions using glyph array - for (auto const& aGlyphItem : m_GlyphItems) + for (auto const& aGlyphItem : *m_GlyphItems.Impl()) { long nXPos = aGlyphItem.m_aLinearPos.X(); long nXRight = nXPos + aGlyphItem.m_nOrigWidth; @@ -895,8 +897,8 @@ bool GenericSalLayout::GetNextGlyph(const GlyphItem** pGlyph, Point& rPos, int& nStart, const PhysicalFontFace**, int* const) const { - std::vector<GlyphItem>::const_iterator pGlyphIter = m_GlyphItems.begin(); - std::vector<GlyphItem>::const_iterator pGlyphIterEnd = m_GlyphItems.end(); + std::vector<GlyphItem>::const_iterator pGlyphIter = m_GlyphItems.Impl()->begin(); + std::vector<GlyphItem>::const_iterator pGlyphIterEnd = m_GlyphItems.Impl()->end(); pGlyphIter += nStart; // find next glyph in substring @@ -908,7 +910,7 @@ bool GenericSalLayout::GetNextGlyph(const GlyphItem** pGlyph, } // return zero if no more glyph found - if( nStart >= static_cast<int>(m_GlyphItems.size()) ) + if( nStart >= static_cast<int>(m_GlyphItems.Impl()->size()) ) return false; if( pGlyphIter == pGlyphIterEnd ) @@ -930,10 +932,10 @@ bool GenericSalLayout::GetNextGlyph(const GlyphItem** pGlyph, void GenericSalLayout::MoveGlyph( int nStart, long nNewXPos ) { - if( nStart >= static_cast<int>(m_GlyphItems.size()) ) + if( nStart >= static_cast<int>(m_GlyphItems.Impl()->size()) ) return; - std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.begin(); + std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.Impl()->begin(); pGlyphIter += nStart; // the nNewXPos argument determines the new cell position @@ -946,7 +948,7 @@ void GenericSalLayout::MoveGlyph( int nStart, long nNewXPos ) // adjust all following glyph positions if needed if( nXDelta != 0 ) { - for( std::vector<GlyphItem>::iterator pGlyphIterEnd = m_GlyphItems.end(); pGlyphIter != pGlyphIterEnd; ++pGlyphIter ) + for( std::vector<GlyphItem>::iterator pGlyphIterEnd = m_GlyphItems.Impl()->end(); pGlyphIter != pGlyphIterEnd; ++pGlyphIter ) { pGlyphIter->m_aLinearPos.AdjustX(nXDelta ); } @@ -955,10 +957,10 @@ void GenericSalLayout::MoveGlyph( int nStart, long nNewXPos ) void GenericSalLayout::DropGlyph( int nStart ) { - if( nStart >= static_cast<int>(m_GlyphItems.size())) + if( nStart >= static_cast<int>(m_GlyphItems.Impl()->size())) return; - std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.begin(); + std::vector<GlyphItem>::iterator pGlyphIter = m_GlyphItems.Impl()->begin(); pGlyphIter += nStart; pGlyphIter->m_nCharPos = -1; pGlyphIter->m_nFlags |= GlyphItem::IS_DROPPED; @@ -968,20 +970,20 @@ void GenericSalLayout::Simplify( bool bIsBase ) { // remove dropped glyphs inplace size_t j = 0; - for(size_t i = 0; i < m_GlyphItems.size(); i++ ) + for(size_t i = 0; i < m_GlyphItems.Impl()->size(); i++ ) { - if (bIsBase && m_GlyphItems[i].IsDropped()) + if (bIsBase && (*m_GlyphItems.Impl())[i].IsDropped()) continue; - if (!bIsBase && m_GlyphItems[i].m_aGlyphId == 0) + if (!bIsBase && (*m_GlyphItems.Impl())[i].m_aGlyphId == 0) continue; if( i != j ) { - m_GlyphItems[j] = m_GlyphItems[i]; + (*m_GlyphItems.Impl())[j] = (*m_GlyphItems.Impl())[i]; } j += 1; } - m_GlyphItems.erase(m_GlyphItems.begin() + j, m_GlyphItems.end()); + m_GlyphItems.Impl()->erase(m_GlyphItems.Impl()->begin() + j, m_GlyphItems.Impl()->end()); } MultiSalLayout::MultiSalLayout( std::unique_ptr<SalLayout> pBaseLayout ) diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index b11d97b0deb8..44c010869df6 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -31,6 +31,7 @@ #include <sallayout.hxx> #include <salgdi.hxx> #include <svdata.hxx> +#include <impglyphitem.hxx> #include <outdev.h> #include <window.h> diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index ce30eb4bb07a..cdb5e5c9e597 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -43,6 +43,7 @@ #include <svdata.hxx> #include <textlayout.hxx> #include <textlineinfo.hxx> +#include <impglyphitem.hxx> #define TEXT_DRAW_ELLIPSIS (DrawTextFlags::EndEllipsis | DrawTextFlags::PathEllipsis | DrawTextFlags::NewsEllipsis) diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index 9b4f6be2a042..7ae959493f09 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -32,6 +32,7 @@ #include <salgdi.hxx> #include <impfont.hxx> #include <outdata.hxx> +#include <impglyphitem.hxx> #define UNDERLINE_LAST LINESTYLE_BOLDWAVE #define STRIKEOUT_LAST STRIKEOUT_X diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 0374a1754e1e..eef0138f36b3 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -43,7 +43,7 @@ #include <vcl/settings.hxx> #include <vcl/commandinfoprovider.hxx> #include <vcl/IDialogRenderable.hxx> -#include <vcl/glyphitem.hxx> +#include <impglyphitem.hxx> #include <salinst.hxx> #include <svdata.hxx> diff --git a/vcl/source/window/menuitemlist.cxx b/vcl/source/window/menuitemlist.cxx index 9c25bf4e17d1..c0496f1ee603 100644 --- a/vcl/source/window/menuitemlist.cxx +++ b/vcl/source/window/menuitemlist.cxx @@ -26,6 +26,7 @@ #include <vcl/i18nhelp.hxx> #include <vcl/settings.hxx> #include <vcl/window.hxx> +#include <impglyphitem.hxx> using namespace css; using namespace vcl; diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index ce04e4f68b55..50f1b8d451c6 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -591,7 +591,7 @@ void FreetypeFont::ApplyGlyphTransform(bool bVertical, FT_Glyph pGlyphFT ) const bool FreetypeFont::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect) { - if (::GetCachedGlyphBoundRect(rGlyph, rRect)) + if (rGlyph.GetCachedGlyphBoundRect(rRect)) return true; FT_Activate_Size( maSizeFT ); @@ -616,7 +616,7 @@ bool FreetypeFont::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& FT_Done_Glyph( pGlyphFT ); rRect = tools::Rectangle(aBbox.xMin, -aBbox.yMax, aBbox.xMax, -aBbox.yMin); - ::CacheGlyphBoundRect(rGlyph, rRect); + rGlyph.CacheGlyphBoundRect(rRect); return true; } diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 0e74be70f5a8..2303f7ba0bc1 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -1328,7 +1328,7 @@ void WinSalGraphics::ClearDevFontCache() bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect) { - if (::GetCachedGlyphBoundRect(rGlyph, rRect)) + if (rGlyph.GetCachedGlyphBoundRect(rRect)) return true; WinFontInstance* pFont = static_cast<WinFontInstance*>(rGlyph.m_pFontInstance); @@ -1364,7 +1364,7 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle rRect.SetTop(static_cast<int>( fFontScale * rRect.Top() )); rRect.SetBottom(static_cast<int>( fFontScale * rRect.Bottom() ) + 1); - ::CacheGlyphBoundRect(rGlyph, rRect); + rGlyph.CacheGlyphBoundRect(rRect); return true; } |