[Libreoffice-commits] core.git: 3 commits - vcl/inc vcl/quartz vcl/source vcl/win
Norbert Thiebaud
nthiebaud at gmail.com
Wed Sep 3 01:59:10 PDT 2014
vcl/inc/graphite_layout.hxx | 2
vcl/inc/graphite_serverfont.hxx | 6
vcl/inc/sallayout.hxx | 12 -
vcl/quartz/ctlayout.cxx | 282 +++++++++++++++++++---------------
vcl/source/gdi/sallayout.cxx | 21 +-
vcl/source/glyphs/graphite_layout.cxx | 2
vcl/win/source/gdi/winlayout.cxx | 28 +--
7 files changed, 194 insertions(+), 159 deletions(-)
New commits:
commit 5ef4bdc7b15686e55fa19f2e98a828763a0cfae6
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date: Tue Sep 2 14:09:12 2014 +0200
fdo#82818 vcl macosx. fix asian vertical ctlayout
Just revert ot regular CTRunDraw in that case
and adjust 'ullet' displaying.
Change-Id: I9ef80f5985b8c7610fcc8e9e8acd5b27542f8730
diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx
index cacd6b8..cd9771a 100644
--- a/vcl/quartz/ctlayout.cxx
+++ b/vcl/quartz/ctlayout.cxx
@@ -178,20 +178,42 @@ void CTLayout::ApplyDXArray(ImplLayoutArgs& rArgs)
if(!(status & kCTRunStatusNonMonotonic))
{
- /* simple 1 to 1 */
- for(int i = 0 ; i < iter->m_nGlyphs; i++)
+ if(mnLayoutFlags & SAL_LAYOUT_VERTICAL)
{
- if(iter->m_pStringIndices[i] == 0)
+ /* simple 1 to 1 */
+ for(int i = 0 ; i < iter->m_nGlyphs; i++)
{
- iter->m_pAdjPositions[i].x = 0;
- SAL_INFO( "vcl.ct", "Apply DXArray["<< i << "]: 0.0 pos: " << iter->m_pPositions[i].x);
+ if(iter->m_pStringIndices[i] == 0)
+ {
+ iter->m_pAdjPositions[i].x = 0;
+ SAL_INFO( "vcl.ct", "Apply DXArray["<< i << "]: 0.0 pos: " << iter->m_pPositions[i].x);
+ }
+ else
+ {
+ iter->m_pAdjPositions[i].x = rArgs.mpDXArray[iter->m_pStringIndices[i-1]];
+ SAL_INFO( "vcl.ct", "Apply to i DXArray["<< iter->m_pStringIndices[i-1] << "]: " <<
+ rArgs.mpDXArray[iter->m_pStringIndices[i-1]] << " pos:( " << iter->m_pPositions[i].x << ", " << iter->m_pPositions[i].y);
+ }
+ iter->m_pAdjPositions[i].y = iter->m_pPositions[i].y;
}
- else
+ }
+ else
+ {
+ /* simple 1 to 1 */
+ for(int i = 0 ; i < iter->m_nGlyphs; i++)
{
- iter->m_pAdjPositions[i].x = rArgs.mpDXArray[iter->m_pStringIndices[i-1]];
- SAL_INFO( "vcl.ct", "Apply to i DXArray["<< iter->m_pStringIndices[i-1] << "]: " << rArgs.mpDXArray[iter->m_pStringIndices[i-1]] << " pos: " << iter->m_pPositions[i].x);
+ if(iter->m_pStringIndices[i] == 0)
+ {
+ iter->m_pAdjPositions[i].x = 0;
+ SAL_INFO( "vcl.ct", "Apply DXArray["<< i << "]: 0.0 pos: " << iter->m_pPositions[i].x);
+ }
+ else
+ {
+ iter->m_pAdjPositions[i].x = rArgs.mpDXArray[iter->m_pStringIndices[i-1]];
+ SAL_INFO( "vcl.ct", "Apply to i DXArray["<< iter->m_pStringIndices[i-1] << "]: " << rArgs.mpDXArray[iter->m_pStringIndices[i-1]] << " pos: " << iter->m_pPositions[i].x);
+ }
+ iter->m_pAdjPositions[i].y = iter->m_pPositions[i].y;
}
- iter->m_pAdjPositions[i].y = iter->m_pPositions[i].y;
}
}
else
@@ -434,130 +456,152 @@ void CTLayout::drawCTLine(AquaSalGraphics& rAquaGraphics, CTLineRef ctline, cons
* iow that we want to use DXArray to align glyphs
* Otherwise we just use CoreText to display the whole line
*/
- boost::ptr_vector<CTRunData>::const_iterator iter = m_vRunData.begin();
- if(iter != m_vRunData.end())
+
+ if(!(mnLayoutFlags & SAL_LAYOUT_VERTICAL))
{
- for(; iter != m_vRunData.end(); ++iter)
+ boost::ptr_vector<CTRunData>::const_iterator iter = m_vRunData.begin();
+ if(iter != m_vRunData.end())
{
- CTRunRef run = iter->m_pRun;
- /* if we do not have Ajusted Poistions for a run, just use CoreText to draw it */
- if(iter->m_pAdjPositions)
+ for(; iter != m_vRunData.end(); ++iter)
{
- CTFontRef runFont = iter->m_pFont;
- CGFloat baseSize = CTFontGetSize(runFont);
- for (CFIndex runGlyphIndex = 0;
- runGlyphIndex < CTRunGetGlyphCount(run);
- runGlyphIndex++)
+ CTRunRef run = iter->m_pRun;
+ /* if we do not have Ajusted Poistions for a run, just use CoreText to draw it */
+ if(iter->m_pAdjPositions)
{
- CGFontRef cgFont = CTFontCopyGraphicsFont(runFont, NULL);
- CGContextSaveGState(context);
+ CTFontRef runFont = iter->m_pFont;
+ CGFloat baseSize = CTFontGetSize(runFont);
+ for (CFIndex runGlyphIndex = 0;
+ runGlyphIndex < CTRunGetGlyphCount(run);
+ runGlyphIndex++)
+ {
+ CGFontRef cgFont = CTFontCopyGraphicsFont(runFont, NULL);
+ CGContextSaveGState(context);
- CGContextSetFont(context, cgFont);
- CGContextSetFontSize(context, CTFontGetSize(runFont));
- CGContextSetFillColor( context, rAquaGraphics.maTextColor.AsArray() );
- CGContextSetTextPosition( context, aTextPos.x, aTextPos.y );
- CGContextShowGlyphsAtPositions(context, iter->m_pGlyphs + runGlyphIndex,
- iter->m_pAdjPositions + runGlyphIndex, 1);
- CGContextRestoreGState(context);
- CFRelease(cgFont);
- }
- /* Do we want to show 'space' as 'bullet' */
- if(mnLayoutFlags & SAL_LAYOUT_DRAW_BULLET)
- {
- for(int i = 0 ; i < iter->m_nGlyphs; i++)
+ CGContextSetFont(context, cgFont);
+ CGContextSetFontSize(context, CTFontGetSize(runFont));
+ CGContextSetFillColor( context, rAquaGraphics.maTextColor.AsArray() );
+ if(mnLayoutFlags & SAL_LAYOUT_VERTICAL)
+ {
+ CGContextRotateCTM( context, -F_PI/2 );
+ }
+ CGContextSetTextPosition( context, aTextPos.x, aTextPos.y );
+ SAL_INFO( "vcl.ct", "CGContextSetTextPosition(" << aTextPos.x << ", " << aTextPos.y << ")");
+ SAL_INFO( "vcl.ct", "CGContextShowGlyphAt(" << iter->m_pAdjPositions[runGlyphIndex].x << ", " << iter->m_pAdjPositions[runGlyphIndex].y << ")");
+
+ CGContextShowGlyphsAtPositions(context, iter->m_pGlyphs + runGlyphIndex,
+ iter->m_pAdjPositions + runGlyphIndex, 1);
+ CGContextRestoreGState(context);
+ CFRelease(cgFont);
+ }
+ /* Do we want to show 'space' as 'bullet' */
+ if(mnLayoutFlags & SAL_LAYOUT_DRAW_BULLET)
{
- UniChar curChar = CFStringGetCharacterAtIndex (CFAttributedStringGetString(mpAttrString),
- iter->m_pStringIndices[i]);
- /* is the character associated with the current glyph a space ? */
- if(curChar == ' ')
+ for(int i = 0 ; i < iter->m_nGlyphs; i++)
{
- /* make a rect that will enclose the bullet we want to draw */
- CFRange glyphRange = CFRangeMake(i, 1);
- CGFloat ascent;
- CGFloat descent;
- CGFloat leading;
- CTRunGetTypographicBounds ( run, glyphRange,
- &ascent, &descent, &leading);
- CGRect bulletRect = CGRectMake(aTextPos.x + iter->m_pAdjPositions[i].x + iter->m_pAdvances[i].width / 4,
- aTextPos.y + iter->m_pAdjPositions[i].y + ascent / 3 - baseSize / 5, baseSize / 5, baseSize / 5 );
-
- /* Draw a bullet filled with the 'special' color for non-displayable characters */
- CGContextSaveGState(context);
- RGBAColor bulletColor(MAKE_SALCOLOR(0x26, 0x8b, 0xd2 )); // NON_PRINTING_CHARACTER_COLOR
- CGContextSetFillColor( context, bulletColor.AsArray() );
- CGContextSetStrokeColor(context, bulletColor.AsArray());
- CGContextBeginPath(context);
- CGContextAddEllipseInRect(context, bulletRect);
- CGContextDrawPath(context, kCGPathFillStroke); // Or kCGPathFill
- CGContextRestoreGState(context);
+ UniChar curChar = CFStringGetCharacterAtIndex (CFAttributedStringGetString(mpAttrString),
+ iter->m_pStringIndices[i]);
+ /* is the character associated with the current glyph a space ? */
+ if(curChar == ' ')
+ {
+ /* make a rect that will enclose the bullet we want to draw */
+ CFRange glyphRange = CFRangeMake(i, 1);
+ CGFloat ascent;
+ CGFloat descent;
+ CGFloat leading;
+ CTRunGetTypographicBounds ( run, glyphRange,
+ &ascent, &descent, &leading);
+ CGRect bulletRect;
+ bulletRect = CGRectMake(aTextPos.x + iter->m_pAdjPositions[i].x + iter->m_pAdvances[i].width / 4,
+ aTextPos.y + iter->m_pAdjPositions[i].y + ascent / 3 - baseSize / 5, baseSize / 5, baseSize / 5 );
+
+ /* Draw a bullet filled with the 'special' color for non-displayable characters */
+ CGContextSaveGState(context);
+ RGBAColor bulletColor(MAKE_SALCOLOR(0x26, 0x8b, 0xd2 )); // NON_PRINTING_CHARACTER_COLOR
+ CGContextSetFillColor( context, bulletColor.AsArray() );
+ CGContextSetStrokeColor(context, bulletColor.AsArray());
+ CGContextBeginPath(context);
+ CGContextAddEllipseInRect(context, bulletRect);
+ CGContextDrawPath(context, kCGPathFillStroke); // Or kCGPathFill
+ CGContextRestoreGState(context);
+ }
}
}
}
+ else
+ {
+ CTRunDraw(run, context, CFRangeMake( 0, 0 ));
+ /* Fixme draw bullet */
+ }
}
- else
- {
- CTRunDraw(run, context, CFRangeMake( 0, 0 ));
- /* Fixme draw bullet */
- }
+ CGContextRestoreGState( context );
+ return;
}
}
- else
+
+ SAL_INFO( "vcl.ct", "CTLineDraw(" << ctline << "," << context << ")" );
+ // draw the text
+ CTLineDraw( ctline, context );
+
+ if(mnLayoutFlags & SAL_LAYOUT_DRAW_BULLET)
{
- SAL_INFO( "vcl.ct", "CTLineDraw(" << ctline << "," << context << ")" );
- // draw the text
- CTLineDraw( ctline, context );
+ CFArrayRef runArray = CTLineGetGlyphRuns(ctline);
+ CFIndex runCount = CFArrayGetCount(runArray);
- if(mnLayoutFlags & SAL_LAYOUT_DRAW_BULLET)
+ for (CFIndex runIndex = 0; runIndex < runCount; runIndex++)
{
- CFArrayRef runArray = CTLineGetGlyphRuns(ctline);
- CFIndex runCount = CFArrayGetCount(runArray);
-
- for (CFIndex runIndex = 0; runIndex < runCount; runIndex++)
+ CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runArray, runIndex);
+ CFIndex runGlyphCount = CTRunGetGlyphCount(run);
+ CGPoint position;
+ CGSize advance;
+ CFIndex runGlyphIndex = 0;
+ CFIndex stringIndice = 0;
+
+ for (; runGlyphIndex < runGlyphCount; runGlyphIndex++)
{
-
- CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runArray, runIndex);
- CFIndex runGlyphCount = CTRunGetGlyphCount(run);
-
- CGPoint position;
- CGSize advance;
- CFIndex runGlyphIndex = 0;
- CFIndex stringIndice = 0;
-
- for (; runGlyphIndex < runGlyphCount; runGlyphIndex++)
+ CFRange glyphRange = CFRangeMake(runGlyphIndex, 1);
+ CTRunGetStringIndices( run, glyphRange, &stringIndice );
+ UniChar curChar = CFStringGetCharacterAtIndex (CFAttributedStringGetString(mpAttrString), stringIndice);
+ if(curChar == ' ')
{
- CFRange glyphRange = CFRangeMake(runGlyphIndex, 1);
-
- CTRunGetStringIndices( run, glyphRange, &stringIndice );
- UniChar curChar = CFStringGetCharacterAtIndex (CFAttributedStringGetString(mpAttrString), stringIndice);
- if(curChar == ' ')
+ CGFloat ascent;
+ CGFloat descent;
+ CGFloat leading;
+ CTFontRef runFont = (CTFontRef)CFDictionaryGetValue(CTRunGetAttributes(run),
+ kCTFontAttributeName);
+ CGFloat baseSize = CTFontGetSize(runFont);
+ CTRunGetTypographicBounds ( run, glyphRange,
+ &ascent, &descent, &leading);
+ CTRunGetPositions(run, glyphRange, &position);
+ CTRunGetAdvances(run, glyphRange, &advance);
+ CGRect bulletRect;
+ if(mnLayoutFlags & SAL_LAYOUT_VERTICAL)
{
- CGFloat ascent;
- CGFloat descent;
- CGFloat leading;
- CTFontRef runFont = (CTFontRef)CFDictionaryGetValue(CTRunGetAttributes(run),
- kCTFontAttributeName);
- CGFloat baseSize = CTFontGetSize(runFont);
- CTRunGetTypographicBounds ( run, glyphRange,
- &ascent, &descent, &leading);
-
- CTRunGetPositions(run, glyphRange, &position);
- CTRunGetAdvances(run, glyphRange, &advance);
- CGRect bulletRect = CGRectMake(aTextPos.x + position.x + advance.width / 4,
- aTextPos.y + position.y + ascent / 3 - baseSize / 5, baseSize / 5, baseSize / 5 );
- CGContextSaveGState(context);
- RGBAColor bulletColor(MAKE_SALCOLOR(0x26, 0x8b, 0xd2 )); // NON_PRINTING_CHARACTER_COLOR
- CGContextSetFillColor( context, bulletColor.AsArray() );
- CGContextSetStrokeColor(context, bulletColor.AsArray());
+ bulletRect = CGRectMake(position.x - advance.width / 4,
+ -position.y, baseSize / 5, baseSize / 5 );
+ }
+ else
+ {
+ bulletRect = CGRectMake(position.x + advance.width / 4,
+ position.y + ascent / 3 - baseSize / 5, baseSize / 5, baseSize / 5 );
+ }
- CGContextBeginPath(context);
- CGContextAddEllipseInRect(context, bulletRect);
- CGContextDrawPath(context, kCGPathFillStroke); // Or kCGPathFill
- CGContextRestoreGState(context);
+ CGContextSaveGState(context);
+ CGContextTranslateCTM(context, aTextPos.x, aTextPos.y);
+ RGBAColor bulletColor(MAKE_SALCOLOR(0x26, 0x8b, 0xd2 )); // NON_PRINTING_CHARACTER_COLOR
+ CGContextSetFillColor( context, bulletColor.AsArray() );
+ CGContextSetStrokeColor(context, bulletColor.AsArray());
+ if(mnLayoutFlags & SAL_LAYOUT_VERTICAL)
+ {
+ CGContextRotateCTM( context, -F_PI/2 );
}
+
+ CGContextBeginPath(context);
+ CGContextAddEllipseInRect(context, bulletRect);
+ CGContextDrawPath(context, kCGPathFillStroke); // Or kCGPathFill
+ CGContextRestoreGState(context);
}
}
}
-
}
// restore the original graphic context transformations
SAL_INFO( "vcl.ct", "CGContextRestoreGState(" << context << ")" );
commit 1a9264c472cd0449641c5206cdf86c8c3412070f
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date: Sat Aug 16 21:44:55 2014 +0200
extra witdh for GetTextBreak is of DeviceCoordinate
Change-Id: Ic25eae1e9b8ae14022ee8d0373be0978ebc21267
diff --git a/vcl/inc/graphite_layout.hxx b/vcl/inc/graphite_layout.hxx
index 24b668d..3295468 100644
--- a/vcl/inc/graphite_layout.hxx
+++ b/vcl/inc/graphite_layout.hxx
@@ -123,7 +123,7 @@ public:
virtual void AdjustLayout( ImplLayoutArgs& ) SAL_OVERRIDE; // adjusting positions
// methods using string indexing
- virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra=0, int nFactor=1) const SAL_OVERRIDE;
+ virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra=0, int nFactor=1) const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
virtual void ApplyDXArray(ImplLayoutArgs &rArgs, std::vector<int> & rDeltaWidth);
diff --git a/vcl/inc/graphite_serverfont.hxx b/vcl/inc/graphite_serverfont.hxx
index 9529b1d..0d533e0 100644
--- a/vcl/inc/graphite_serverfont.hxx
+++ b/vcl/inc/graphite_serverfont.hxx
@@ -76,9 +76,9 @@ public:
{
return maImpl.FillDXArray(dxa);
}
- virtual sal_Int32 GetTextBreak(DeviceCoordinate mw, long ce, int f) const SAL_OVERRIDE
+ virtual sal_Int32 GetTextBreak(DeviceCoordinate max_width, DeviceCoordinate extra, int factor) const SAL_OVERRIDE
{
- return maImpl.GetTextBreak(mw, ce, f);
+ return maImpl.GetTextBreak(max_width, extra, factor);
}
virtual void GetCaretPositions( int as, long* cxa ) const SAL_OVERRIDE
{
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 4d56bba7..3a2061b 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -171,7 +171,7 @@ public:
int GetOrientation() const { return mnOrientation; }
// methods using string indexing
- virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra=0, int nFactor=1) const = 0;
+ virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra=0, int nFactor=1) const = 0;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const = 0;
virtual DeviceCoordinate GetTextWidth() const { return FillDXArray( NULL ); }
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const = 0;
@@ -229,7 +229,7 @@ class VCL_PLUGIN_PUBLIC MultiSalLayout : public SalLayout
{
public:
virtual void DrawText( SalGraphics& ) const SAL_OVERRIDE;
- virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
+ virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const SAL_OVERRIDE;
virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdxAry, Point& rPos,
@@ -331,7 +331,7 @@ public:
// used by upper layers
virtual DeviceCoordinate GetTextWidth() const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
- virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) 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;
// used by display layers
diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx
index da844a7..cacd6b8 100644
--- a/vcl/quartz/ctlayout.cxx
+++ b/vcl/quartz/ctlayout.cxx
@@ -44,7 +44,7 @@ public:
virtual DeviceCoordinate GetTextWidth() const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
- virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) 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;
virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const SAL_OVERRIDE;
@@ -756,7 +756,7 @@ DeviceCoordinate CTLayout::FillDXArray( DeviceCoordinate* pDXArray ) const
return nPixWidth;
}
-sal_Int32 CTLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
+sal_Int32 CTLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor ) const
{
if( !mpCTLine )
{
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 471d298..c30a99a 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1277,7 +1277,7 @@ void GenericSalLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) co
}
}
-sal_Int32 GenericSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
+sal_Int32 GenericSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor ) const
{
int nCharCapacity = mnEndCharPos - mnMinCharPos;
DeviceCoordinate* pCharWidths = (DeviceCoordinate*)alloca( nCharCapacity * sizeof(DeviceCoordinate) );
@@ -1907,7 +1907,7 @@ void MultiSalLayout::DrawText( SalGraphics& rGraphics ) const
// NOTE: now the baselevel font is active again
}
-sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
+sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor ) const
{
if( mnLevel <= 0 )
return -1;
diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx
index 12b5ea9..6f7cbb2 100644
--- a/vcl/source/glyphs/graphite_layout.cxx
+++ b/vcl/source/glyphs/graphite_layout.cxx
@@ -681,7 +681,7 @@ bool GraphiteLayout::LayoutGlyphs(ImplLayoutArgs& rArgs, gr_segment * pSegment)
return true;
}
-sal_Int32 GraphiteLayout::GetTextBreak(DeviceCoordinate maxmnWidth, long char_extra, int factor) const
+sal_Int32 GraphiteLayout::GetTextBreak(DeviceCoordinate maxmnWidth, DeviceCoordinate char_extra, int factor) const
{
#ifdef GRLAYOUT_DEBUG
fprintf(grLog(),"Gr::GetTextBreak c[%d-%d) maxWidth %ld char extra %ld factor %d\n",
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 49da725..eff3f9c 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -146,7 +146,7 @@ public:
const PhysicalFontFace** pFallbackFonts = NULL ) const;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const;
- virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
+ virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const SAL_OVERRIDE;
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const;
// for glyph+font+script fallback
@@ -644,7 +644,7 @@ DeviceCoordinate SimpleWinLayout::FillDXArray( DeviceCoordinate* pDXArray ) cons
return mnWidth;
}
-sal_Int32 SimpleWinLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
+sal_Int32 SimpleWinLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor ) const
// NOTE: the nFactor is used to prevent rounding errors for small nCharExtra values
{
if( mnWidth )
@@ -967,7 +967,7 @@ public:
const PhysicalFontFace** pFallbackFonts = NULL ) const;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const;
- virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
+ virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const SAL_OVERRIDE;
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const;
virtual bool IsKashidaPosValid ( int nCharPos ) const;
@@ -2115,7 +2115,7 @@ DeviceCoordinate UniscribeLayout::FillDXArray( DeviceCoordinate* pDXArray ) cons
return nWidth;
}
-sal_Int32 UniscribeLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
+sal_Int32 UniscribeLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor ) const
{
long nWidth = 0;
for( int i = mnMinCharPos; i < mnEndCharPos; ++i )
@@ -2640,7 +2640,7 @@ public:
virtual void DrawText( SalGraphics& ) const;
// methods using string indexing
- virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra=0, int nFactor=1) const SAL_OVERRIDE;
+ virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra=0, int nFactor=1) const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const;
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const;
@@ -2776,7 +2776,7 @@ void GraphiteWinLayout::DrawText(SalGraphics &sal_graphics) const
DeleteFont( SelectFont( aHDC, hOrigFont ) );
}
-sal_Int32 GraphiteWinLayout::GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const
+sal_Int32 GraphiteWinLayout::GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const
{
sal_Int32 nBreak = maImpl.GetTextBreak(nMaxWidth, nCharExtra, nFactor);
return nBreak;
commit 1632f2a42eaf4c6bdcea9616b3ebc324ecdc30a3
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date: Sat Aug 16 19:50:56 2014 +0200
SalLayout GetTextWidth return DeviceCoordinate
Change-Id: I5b995e54992213e95845e60169238270863e9a7e
diff --git a/vcl/inc/graphite_serverfont.hxx b/vcl/inc/graphite_serverfont.hxx
index 50063e4..9529b1d 100644
--- a/vcl/inc/graphite_serverfont.hxx
+++ b/vcl/inc/graphite_serverfont.hxx
@@ -68,7 +68,7 @@ public:
maImpl.DrawOffset() = maDrawOffset;
maImpl.AdjustLayout(rArgs);
};
- virtual long GetTextWidth() const SAL_OVERRIDE
+ virtual DeviceCoordinate GetTextWidth() const SAL_OVERRIDE
{
return maImpl.GetTextWidth();
}
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index d68a364..4d56bba7 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -173,7 +173,7 @@ public:
// methods using string indexing
virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra=0, int nFactor=1) const = 0;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const = 0;
- virtual long GetTextWidth() const { return FillDXArray( NULL ); }
+ virtual DeviceCoordinate GetTextWidth() const { return FillDXArray( NULL ); }
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const = 0;
virtual bool IsKashidaPosValid ( int /*nCharPos*/ ) const { return true; } // i60594
@@ -323,13 +323,13 @@ public:
void Reserve(int size) { m_GlyphItems.reserve(size + 1); }
virtual void AdjustLayout( ImplLayoutArgs& ) SAL_OVERRIDE;
virtual void ApplyDXArray( ImplLayoutArgs& );
- virtual void Justify( long nNewWidth );
+ virtual void Justify( DeviceCoordinate nNewWidth );
void KashidaJustify( long nIndex, int nWidth );
void ApplyAsianKerning( const sal_Unicode*, int nLength );
void SortGlyphItems();
// used by upper layers
- virtual long GetTextWidth() const SAL_OVERRIDE;
+ virtual DeviceCoordinate GetTextWidth() const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const SAL_OVERRIDE;
diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx
index 659d89b..da844a7 100644
--- a/vcl/quartz/ctlayout.cxx
+++ b/vcl/quartz/ctlayout.cxx
@@ -42,7 +42,7 @@ public:
DeviceCoordinate* pGlyphAdvances, int* pCharIndexes,
const PhysicalFontFace** pFallbackFonts ) const SAL_OVERRIDE;
- virtual long GetTextWidth() const SAL_OVERRIDE;
+ virtual DeviceCoordinate GetTextWidth() const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const SAL_OVERRIDE;
@@ -56,7 +56,6 @@ public:
private:
void drawCTLine(AquaSalGraphics& rAquaGraphics, CTLineRef ctline, const CoreTextStyle* const pStyle) const;
CGPoint GetTextDrawPosition(void) const;
- double GetWidth(void) const;
bool CacheGlyphLayout(void) const;
void ApplyDXArray( ImplLayoutArgs& rArgs);
@@ -327,7 +326,7 @@ CGPoint CTLayout::GetTextDrawPosition(void) const
{
// text is always drawn at its leftmost point
const Point aPos = DrawBase();
- fPosX = aPos.X() + mfBaseAdv - GetWidth();
+ fPosX = aPos.X() + mfBaseAdv - GetTextWidth();
fPosY = aPos.Y();
}
else
@@ -695,7 +694,7 @@ int CTLayout::GetNextGlyphs( int nLen, sal_GlyphId* pOutGlyphIds, Point& rPos, i
}
-double CTLayout::GetWidth() const
+DeviceCoordinate CTLayout::GetTextWidth() const
{
if( (mnCharCount <= 0) || !mpCTLine )
return 0;
@@ -708,14 +707,9 @@ double CTLayout::GetWidth() const
return mfCachedWidth;
}
-long CTLayout::GetTextWidth() const
-{
- return lrint(GetWidth());
-}
-
DeviceCoordinate CTLayout::FillDXArray( DeviceCoordinate* pDXArray ) const
{
- DeviceCoordinate nPixWidth = GetWidth();
+ DeviceCoordinate nPixWidth = GetTextWidth();
// short circuit requests which don't need full details
if( !pDXArray )
return nPixWidth;
@@ -771,7 +765,6 @@ sal_Int32 CTLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, i
}
CTTypesetterRef aCTTypeSetter = CTTypesetterCreateWithAttributedString( mpAttrString );
CFIndex nBestGuess = (nCharExtra >= 0) ? 0 : mnCharCount;
- SAL_INFO("vcl.ct", "GetTextBreak nMaxWidth:" << nMaxWidth << " nBestGuess:" << nBestGuess << " nCharExtra:" << nCharExtra << " nFactor:" << nFactor);
for( int i = 1; i <= mnCharCount; i *= 2 )
{
// guess the target width considering char-extra expansion/condensation
@@ -779,7 +772,6 @@ sal_Int32 CTLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, i
const double fCTMaxWidth = nTargetWidth / nFactor;
// calculate the breaking index for the guessed target width
const CFIndex nNewIndex = CTTypesetterSuggestClusterBreak( aCTTypeSetter, 0, fCTMaxWidth );
- SAL_INFO("vcl.ct", "GetTextBreak nTargetWidth:" << nTargetWidth << " fCTMaxWidth:" << fCTMaxWidth << " nNewIndex:" << nNewIndex);
if( nNewIndex >= mnCharCount )
{
CFRelease( aCTTypeSetter );
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index de39d87..471d298 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -916,24 +916,23 @@ DeviceCoordinate GenericSalLayout::FillDXArray( DeviceCoordinate* pCharWidths )
if( !GetCharWidths( pCharWidths ) )
return 0;
- long nWidth = GetTextWidth();
- return nWidth;
+ return GetTextWidth();
}
// the text width is the maximum logical extent of all glyphs
-long GenericSalLayout::GetTextWidth() const
+DeviceCoordinate GenericSalLayout::GetTextWidth() const
{
if( m_GlyphItems.empty() )
return 0;
// initialize the extent
- long nMinPos = 0;
- long nMaxPos = 0;
+ DeviceCoordinate nMinPos = 0;
+ DeviceCoordinate nMaxPos = 0;
for( GlyphVector::const_iterator pG = m_GlyphItems.begin(), end = m_GlyphItems.end(); pG != end ; ++pG )
{
// update the text extent with the glyph extent
- long nXPos = pG->maLinearPos.X();
+ DeviceCoordinate nXPos = pG->maLinearPos.X();
if( nMinPos > nXPos )
nMinPos = nXPos;
nXPos += pG->mnNewWidth - pG->mnXOffset;
@@ -941,7 +940,7 @@ long GenericSalLayout::GetTextWidth() const
nMaxPos = nXPos;
}
- long nWidth = nMaxPos - nMinPos;
+ DeviceCoordinate nWidth = nMaxPos - nMinPos;
return nWidth;
}
@@ -1081,10 +1080,10 @@ void GenericSalLayout::ApplyDXArray( ImplLayoutArgs& rArgs )
}
}
-void GenericSalLayout::Justify( long nNewWidth )
+void GenericSalLayout::Justify( DeviceCoordinate nNewWidth )
{
nNewWidth *= mnUnitsPerPixel;
- int nOldWidth = GetTextWidth();
+ DeviceCoordinate nOldWidth = GetTextWidth();
if( !nOldWidth || nNewWidth==nOldWidth )
return;
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index a0a0602..49da725 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -155,7 +155,7 @@ public:
virtual void Simplify( bool bIsBase );
protected:
- void Justify( long nNewWidth );
+ void Justify( DeviceCoordinate nNewWidth );
void ApplyDXArray( const ImplLayoutArgs& );
private:
@@ -709,9 +709,9 @@ void SimpleWinLayout::GetCaretPositions( int nMaxIdx, long* pCaretXArray ) const
}
}
-void SimpleWinLayout::Justify( long nNewWidth )
+void SimpleWinLayout::Justify( DeviceCoordinate nNewWidth )
{
- long nOldWidth = mnWidth;
+ DeviceCoordinate nOldWidth = mnWidth;
mnWidth = nNewWidth;
if( mnGlyphCount <= 0 )
@@ -732,12 +732,12 @@ void SimpleWinLayout::Justify( long nNewWidth )
++nStretchable;
// stretch these glyphs
- int nDiffWidth = nNewWidth - nOldWidth;
+ DeviceCoordinate nDiffWidth = nNewWidth - nOldWidth;
for( i = 0; (i < nRight) && (nStretchable > 0); ++i )
{
if( mpGlyphAdvances[i] <= 0 )
continue;
- int nDeltaWidth = nDiffWidth / nStretchable;
+ DeviceCoordinate nDeltaWidth = nDiffWidth / nStretchable;
mpGlyphAdvances[i] += nDeltaWidth;
--nStretchable;
nDiffWidth -= nDeltaWidth;
@@ -980,7 +980,7 @@ public:
protected:
virtual ~UniscribeLayout();
- void Justify( long nNewWidth );
+ void Justify( DeviceCoordinate nNewWidth );
void ApplyDXArray( const ImplLayoutArgs& );
bool GetItemSubrange( const VisualItem&,
@@ -2515,9 +2515,9 @@ bool UniscribeLayout::KashidaWordFix ( int nMinGlyphPos, int nEndGlyphPos, int*
return true;
}
-void UniscribeLayout::Justify( long nNewWidth )
+void UniscribeLayout::Justify( DeviceCoordinate nNewWidth )
{
- long nOldWidth = 0;
+ DeviceCoordinate nOldWidth = 0;
int i;
for( i = mnMinCharPos; i < mnEndCharPos; ++i )
nOldWidth += mpCharWidths[ i ];
More information about the Libreoffice-commits
mailing list