[Libreoffice-commits] core.git: vcl/generic vcl/inc vcl/source
Chris Sherlock
chris.sherlock at collabora.com
Thu Jan 29 19:05:53 PST 2015
vcl/generic/glyphs/gcach_layout.cxx | 2 -
vcl/inc/sallayout.hxx | 11 +++++++++-
vcl/source/gdi/sallayout.cxx | 37 ++++++++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 2 deletions(-)
New commits:
commit 8e33c9be8780806359e3bbb8c7c5788169f4d2e1
Author: Chris Sherlock <chris.sherlock at collabora.com>
Date: Wed Jan 28 17:49:05 2015 +1100
vcl: add GenericSalLayout::GetTextRect()
I have extended GlyphItem to also record the original and new height,
along with the y offset.
Change-Id: I1e9646a8f0d844951d5533d035d9a16dbc8e257c
Reviewed-on: https://gerrit.libreoffice.org/14216
Reviewed-by: Chris Sherlock <chris.sherlock79 at gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79 at gmail.com>
diff --git a/vcl/generic/glyphs/gcach_layout.cxx b/vcl/generic/glyphs/gcach_layout.cxx
index ae4a2f7..a6f86ee 100644
--- a/vcl/generic/glyphs/gcach_layout.cxx
+++ b/vcl/generic/glyphs/gcach_layout.cxx
@@ -514,7 +514,7 @@ bool HbLayoutEngine::Layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
int32_t nYAdvance = pHbPositions[i].y_advance >> 6;
Point aNewPos = Point(aCurrPos.X() + nXOffset, -(aCurrPos.Y() + nYOffset));
- const GlyphItem aGI(nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nXAdvance, nXOffset);
+ const GlyphItem aGI(nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nXAdvance, nXOffset, nYAdvance, nYOffset);
rLayout.AppendGlyph(aGI);
aCurrPos.X() += nXAdvance;
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index e77cb00..f295c3e 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -273,9 +273,15 @@ struct GlyphItem
{
int mnFlags;
int mnCharPos; // index in string
+
int mnOrigWidth; // original glyph width
int mnNewWidth; // width after adjustments
int mnXOffset;
+
+ int mnOrigHeight; // original glyph height
+ int mnNewHeight; // width after adjustments
+ int mnYOffset;
+
sal_GlyphId maGlyphId;
Point maLinearPos; // absolute position of non rotated string
@@ -298,10 +304,12 @@ public:
{}
GlyphItem( int nCharPos, sal_GlyphId aGlyphId, const Point& rLinearPos,
- long nFlags, int nOrigWidth, int nXOffset )
+ long nFlags, int nOrigWidth, int nXOffset, int nOrigHeight, int nYOffset )
: mnFlags(nFlags), mnCharPos(nCharPos),
mnOrigWidth(nOrigWidth), mnNewWidth(nOrigWidth),
mnXOffset(nXOffset),
+ mnOrigHeight(nOrigHeight), mnNewHeight(nOrigHeight),
+ mnYOffset(nYOffset),
maGlyphId(aGlyphId), maLinearPos(rLinearPos)
{}
@@ -330,6 +338,7 @@ public:
// used by upper layers
virtual DeviceCoordinate GetTextWidth() const SAL_OVERRIDE;
+ virtual Rectangle GetTextRect() const;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const SAL_OVERRIDE;
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const SAL_OVERRIDE;
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 245b821..27bb7e1 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -945,6 +945,43 @@ DeviceCoordinate GenericSalLayout::GetTextWidth() const
return nWidth;
}
+Rectangle GenericSalLayout::GetTextRect() const
+{
+ if( m_GlyphItems.empty() )
+ return Rectangle(Point(0, 0), Size(0, 0));
+
+ // initialize the extent
+ DeviceCoordinate nMinXPos = 0;
+ DeviceCoordinate nMaxXPos = 0;
+
+ DeviceCoordinate nMinYPos = 0;
+ DeviceCoordinate nMaxYPos = 0;
+
+ for( GlyphVector::const_iterator pGlyphIter = m_GlyphItems.begin(), end = m_GlyphItems.end(); pGlyphIter != end ; ++pGlyphIter )
+ {
+ // update the text extent with the glyph extent
+ DeviceCoordinate nXPos = pGlyphIter->maLinearPos.X();
+ DeviceCoordinate nYPos = pGlyphIter->maLinearPos.Y();
+
+ if( nMinXPos > nXPos )
+ nMinXPos = nXPos;
+ nXPos += pGlyphIter->mnNewWidth - pGlyphIter->mnXOffset;
+ if( nMaxXPos < nXPos )
+ nMaxXPos = nXPos;
+
+ if( nMinYPos > nYPos )
+ nMinYPos = nYPos;
+ nYPos += pGlyphIter->mnNewWidth - pGlyphIter->mnYOffset;
+ if( nMaxYPos < nYPos )
+ nMaxYPos = nYPos;
+ }
+
+ DeviceCoordinate nWidth = nMaxXPos - nMinXPos;
+ DeviceCoordinate nHeight = nMaxYPos - nMinYPos;
+
+ return Rectangle( Point(nMinXPos, nMinYPos), Size(nWidth, nHeight) );
+}
+
void GenericSalLayout::AdjustLayout( ImplLayoutArgs& rArgs )
{
SalLayout::AdjustLayout( rArgs );
More information about the Libreoffice-commits
mailing list