Kaydet (Commit) 32a92502 authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud

GetTextBreak takes a DeviceCoordinate as width

Change-Id: Ie03732a0966eedf6c0226beed83356ae4886a016
üst 8e838361
...@@ -123,7 +123,7 @@ public: ...@@ -123,7 +123,7 @@ public:
virtual void AdjustLayout( ImplLayoutArgs& ) SAL_OVERRIDE; // adjusting positions virtual void AdjustLayout( ImplLayoutArgs& ) SAL_OVERRIDE; // adjusting positions
// methods using string indexing // methods using string indexing
virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra=0, int nFactor=1) const SAL_OVERRIDE; virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra=0, int nFactor=1) const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE; virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
virtual void ApplyDXArray(ImplLayoutArgs &rArgs, std::vector<int> & rDeltaWidth); virtual void ApplyDXArray(ImplLayoutArgs &rArgs, std::vector<int> & rDeltaWidth);
......
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
{ {
return maImpl.FillDXArray(dxa); return maImpl.FillDXArray(dxa);
} }
virtual sal_Int32 GetTextBreak(long mw, long ce, int f) const SAL_OVERRIDE virtual sal_Int32 GetTextBreak(DeviceCoordinate mw, long ce, int f) const SAL_OVERRIDE
{ {
return maImpl.GetTextBreak(mw, ce, f); return maImpl.GetTextBreak(mw, ce, f);
} }
......
...@@ -171,7 +171,7 @@ public: ...@@ -171,7 +171,7 @@ public:
int GetOrientation() const { return mnOrientation; } int GetOrientation() const { return mnOrientation; }
// methods using string indexing // methods using string indexing
virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra=0, int nFactor=1) const = 0; virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra=0, int nFactor=1) const = 0;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const = 0; virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const = 0;
virtual long GetTextWidth() const { return FillDXArray( NULL ); } virtual long GetTextWidth() const { return FillDXArray( NULL ); }
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const = 0; virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const = 0;
...@@ -229,7 +229,7 @@ class VCL_PLUGIN_PUBLIC MultiSalLayout : public SalLayout ...@@ -229,7 +229,7 @@ class VCL_PLUGIN_PUBLIC MultiSalLayout : public SalLayout
{ {
public: public:
virtual void DrawText( SalGraphics& ) const SAL_OVERRIDE; virtual void DrawText( SalGraphics& ) const SAL_OVERRIDE;
virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE; virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE; virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const SAL_OVERRIDE; virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const SAL_OVERRIDE;
virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdxAry, Point& rPos, virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIdxAry, Point& rPos,
...@@ -331,7 +331,7 @@ public: ...@@ -331,7 +331,7 @@ public:
// used by upper layers // used by upper layers
virtual long GetTextWidth() const SAL_OVERRIDE; virtual long GetTextWidth() const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE; virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra, int nFactor) 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; virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const SAL_OVERRIDE;
// used by display layers // used by display layers
......
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
virtual long GetTextWidth() const SAL_OVERRIDE; virtual long GetTextWidth() const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE; virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const SAL_OVERRIDE;
virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra, int nFactor) 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; virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const SAL_OVERRIDE;
virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const SAL_OVERRIDE; virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const SAL_OVERRIDE;
...@@ -762,13 +762,16 @@ DeviceCoordinate CTLayout::FillDXArray( DeviceCoordinate* pDXArray ) const ...@@ -762,13 +762,16 @@ DeviceCoordinate CTLayout::FillDXArray( DeviceCoordinate* pDXArray ) const
return nPixWidth; return nPixWidth;
} }
sal_Int32 CTLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const sal_Int32 CTLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
{ {
if( !mpCTLine ) if( !mpCTLine )
{
SAL_INFO("vcl.ct", "GetTextBreak mpCTLine == NULL");
return -1; return -1;
}
CTTypesetterRef aCTTypeSetter = CTTypesetterCreateWithAttributedString( mpAttrString ); CTTypesetterRef aCTTypeSetter = CTTypesetterCreateWithAttributedString( mpAttrString );
CFIndex nBestGuess = (nCharExtra >= 0) ? 0 : mnCharCount; 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 ) for( int i = 1; i <= mnCharCount; i *= 2 )
{ {
// guess the target width considering char-extra expansion/condensation // guess the target width considering char-extra expansion/condensation
...@@ -776,7 +779,9 @@ sal_Int32 CTLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) ...@@ -776,7 +779,9 @@ sal_Int32 CTLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor )
const double fCTMaxWidth = nTargetWidth / nFactor; const double fCTMaxWidth = nTargetWidth / nFactor;
// calculate the breaking index for the guessed target width // calculate the breaking index for the guessed target width
const CFIndex nNewIndex = CTTypesetterSuggestClusterBreak( aCTTypeSetter, 0, fCTMaxWidth ); const CFIndex nNewIndex = CTTypesetterSuggestClusterBreak( aCTTypeSetter, 0, fCTMaxWidth );
if( nNewIndex >= mnCharCount ) { SAL_INFO("vcl.ct", "GetTextBreak nTargetWidth:" << nTargetWidth << " fCTMaxWidth:" << fCTMaxWidth << " nNewIndex:" << nNewIndex);
if( nNewIndex >= mnCharCount )
{
CFRelease( aCTTypeSetter ); CFRelease( aCTTypeSetter );
return -1; return -1;
} }
...@@ -795,6 +800,7 @@ sal_Int32 CTLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) ...@@ -795,6 +800,7 @@ sal_Int32 CTLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor )
// suggest the best fitting cluster break as breaking position // suggest the best fitting cluster break as breaking position
CFRelease( aCTTypeSetter ); CFRelease( aCTTypeSetter );
const int nIndex = nBestGuess + mnMinCharPos; const int nIndex = nBestGuess + mnMinCharPos;
SAL_INFO("vcl.ct", "GetTextBreak nIndex:" << nIndex);
return nIndex; return nIndex;
} }
......
...@@ -1278,14 +1278,14 @@ void GenericSalLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) co ...@@ -1278,14 +1278,14 @@ void GenericSalLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) co
} }
} }
sal_Int32 GenericSalLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const sal_Int32 GenericSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
{ {
int nCharCapacity = mnEndCharPos - mnMinCharPos; int nCharCapacity = mnEndCharPos - mnMinCharPos;
DeviceCoordinate* pCharWidths = (DeviceCoordinate*)alloca( nCharCapacity * sizeof(DeviceCoordinate) ); DeviceCoordinate* pCharWidths = (DeviceCoordinate*)alloca( nCharCapacity * sizeof(DeviceCoordinate) );
if( !GetCharWidths( pCharWidths ) ) if( !GetCharWidths( pCharWidths ) )
return -1; return -1;
long nWidth = 0; DeviceCoordinate nWidth = 0;
for( int i = mnMinCharPos; i < mnEndCharPos; ++i ) for( int i = mnMinCharPos; i < mnEndCharPos; ++i )
{ {
nWidth += pCharWidths[ i - mnMinCharPos ] * nFactor; nWidth += pCharWidths[ i - mnMinCharPos ] * nFactor;
...@@ -1908,7 +1908,7 @@ void MultiSalLayout::DrawText( SalGraphics& rGraphics ) const ...@@ -1908,7 +1908,7 @@ void MultiSalLayout::DrawText( SalGraphics& rGraphics ) const
// NOTE: now the baselevel font is active again // NOTE: now the baselevel font is active again
} }
sal_Int32 MultiSalLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const sal_Int32 MultiSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
{ {
if( mnLevel <= 0 ) if( mnLevel <= 0 )
return -1; return -1;
......
...@@ -681,7 +681,7 @@ bool GraphiteLayout::LayoutGlyphs(ImplLayoutArgs& rArgs, gr_segment * pSegment) ...@@ -681,7 +681,7 @@ bool GraphiteLayout::LayoutGlyphs(ImplLayoutArgs& rArgs, gr_segment * pSegment)
return true; return true;
} }
sal_Int32 GraphiteLayout::GetTextBreak(long maxmnWidth, long char_extra, int factor) const sal_Int32 GraphiteLayout::GetTextBreak(DeviceCoordinate maxmnWidth, long char_extra, int factor) const
{ {
#ifdef GRLAYOUT_DEBUG #ifdef GRLAYOUT_DEBUG
fprintf(grLog(),"Gr::GetTextBreak c[%d-%d) maxWidth %ld char extra %ld factor %d\n", fprintf(grLog(),"Gr::GetTextBreak c[%d-%d) maxWidth %ld char extra %ld factor %d\n",
...@@ -692,7 +692,7 @@ sal_Int32 GraphiteLayout::GetTextBreak(long maxmnWidth, long char_extra, int fac ...@@ -692,7 +692,7 @@ sal_Int32 GraphiteLayout::GetTextBreak(long maxmnWidth, long char_extra, int fac
if (maxmnWidth > mnWidth * factor + char_extra * (mnEndCharPos - mnMinCharPos - 1)) if (maxmnWidth > mnWidth * factor + char_extra * (mnEndCharPos - mnMinCharPos - 1))
return -1; return -1;
long nWidth = mvCharDxs[0] * factor; DeviceCoordinate nWidth = mvCharDxs[0] * factor;
long wLastBreak = 0; long wLastBreak = 0;
int nLastBreak = -1; int nLastBreak = -1;
int nEmergency = -1; int nEmergency = -1;
......
...@@ -146,7 +146,7 @@ public: ...@@ -146,7 +146,7 @@ public:
const PhysicalFontFace** pFallbackFonts = NULL ) const; const PhysicalFontFace** pFallbackFonts = NULL ) const;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const; virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const;
virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE; virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const; virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const;
// for glyph+font+script fallback // for glyph+font+script fallback
...@@ -644,7 +644,7 @@ DeviceCoordinate SimpleWinLayout::FillDXArray( DeviceCoordinate* pDXArray ) cons ...@@ -644,7 +644,7 @@ DeviceCoordinate SimpleWinLayout::FillDXArray( DeviceCoordinate* pDXArray ) cons
return mnWidth; return mnWidth;
} }
sal_Int32 SimpleWinLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const sal_Int32 SimpleWinLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
// NOTE: the nFactor is used to prevent rounding errors for small nCharExtra values // NOTE: the nFactor is used to prevent rounding errors for small nCharExtra values
{ {
if( mnWidth ) if( mnWidth )
...@@ -967,7 +967,7 @@ public: ...@@ -967,7 +967,7 @@ public:
const PhysicalFontFace** pFallbackFonts = NULL ) const; const PhysicalFontFace** pFallbackFonts = NULL ) const;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const; virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const;
virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE; virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const SAL_OVERRIDE;
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const; virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const;
virtual bool IsKashidaPosValid ( int nCharPos ) const; virtual bool IsKashidaPosValid ( int nCharPos ) const;
...@@ -2115,7 +2115,7 @@ DeviceCoordinate UniscribeLayout::FillDXArray( DeviceCoordinate* pDXArray ) cons ...@@ -2115,7 +2115,7 @@ DeviceCoordinate UniscribeLayout::FillDXArray( DeviceCoordinate* pDXArray ) cons
return nWidth; return nWidth;
} }
sal_Int32 UniscribeLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const sal_Int32 UniscribeLayout::GetTextBreak( DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor ) const
{ {
long nWidth = 0; long nWidth = 0;
for( int i = mnMinCharPos; i < mnEndCharPos; ++i ) for( int i = mnMinCharPos; i < mnEndCharPos; ++i )
...@@ -2640,7 +2640,7 @@ public: ...@@ -2640,7 +2640,7 @@ public:
virtual void DrawText( SalGraphics& ) const; virtual void DrawText( SalGraphics& ) const;
// methods using string indexing // methods using string indexing
virtual sal_Int32 GetTextBreak(long nMaxWidth, long nCharExtra=0, int nFactor=1) const SAL_OVERRIDE; virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra=0, int nFactor=1) const SAL_OVERRIDE;
virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const; virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const;
virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const; virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const;
...@@ -2776,8 +2776,7 @@ void GraphiteWinLayout::DrawText(SalGraphics &sal_graphics) const ...@@ -2776,8 +2776,7 @@ void GraphiteWinLayout::DrawText(SalGraphics &sal_graphics) const
DeleteFont( SelectFont( aHDC, hOrigFont ) ); DeleteFont( SelectFont( aHDC, hOrigFont ) );
} }
sal_Int32 GraphiteWinLayout::GetTextBreak( sal_Int32 GraphiteWinLayout::GetTextBreak(DeviceCoordinate nMaxWidth, long nCharExtra, int nFactor) const
long nMaxWidth, long nCharExtra, int nFactor) const
{ {
sal_Int32 nBreak = maImpl.GetTextBreak(nMaxWidth, nCharExtra, nFactor); sal_Int32 nBreak = maImpl.GetTextBreak(nMaxWidth, nCharExtra, nFactor);
return nBreak; return nBreak;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment