diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-08-16 19:50:56 +0200 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-09-03 10:58:34 +0200 |
commit | 1632f2a42eaf4c6bdcea9616b3ebc324ecdc30a3 (patch) | |
tree | 24105ed7877480f4c94c7a7b1b6feef2db7c2e24 /vcl | |
parent | fd81523328891c69ee7cb28bf22308225da42744 (diff) |
SalLayout GetTextWidth return DeviceCoordinate
Change-Id: I5b995e54992213e95845e60169238270863e9a7e
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/graphite_serverfont.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/sallayout.hxx | 6 | ||||
-rw-r--r-- | vcl/quartz/ctlayout.cxx | 16 | ||||
-rw-r--r-- | vcl/source/gdi/sallayout.cxx | 17 | ||||
-rw-r--r-- | vcl/win/source/gdi/winlayout.cxx | 16 |
5 files changed, 24 insertions, 33 deletions
diff --git a/vcl/inc/graphite_serverfont.hxx b/vcl/inc/graphite_serverfont.hxx index 50063e4838df..9529b1dc0598 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 d68a364ca8f8..4d56bba718ab 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 659d89b7c3ee..da844a799771 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 de39d873788c..471d298de687 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 a0a0602b4051..49da72541825 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 ]; |