diff options
author | Herbert Duerr <hdu@openoffice.org> | 2007-02-14 13:53:01 +0000 |
---|---|---|
committer | Herbert Duerr <hdu@openoffice.org> | 2007-02-14 13:53:01 +0000 |
commit | 8bfe0eb3e2d732042faf656196620e25a9ee8123 (patch) | |
tree | 79387c954fc98e7ac575ca348113d33255ebb969 /drawinglayer | |
parent | 597e5c5515724b53f291f3fee4543d0d18b54e91 (diff) |
#i73860# add methods for getting textline related metrics, improve const-correctness
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx | 15 | ||||
-rw-r--r-- | drawinglayer/source/primitive2d/textlayoutdevice.cxx | 35 |
2 files changed, 40 insertions, 10 deletions
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx index 82696ffccac3..e80dfe199a98 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx @@ -4,9 +4,9 @@ * * $RCSfile: textlayoutdevice.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: hdu $ $Date: 2007-02-02 15:13:57 $ + * last change: $Author: hdu $ $Date: 2007-02-14 14:53:01 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -87,12 +87,17 @@ namespace drawinglayer void setFont(const Font& rFont); void setFontAttributes(const FontAttributes& rFontAttributes, const basegfx::B2DHomMatrix& rTransform); - double getTextHeight(); - double getTextWidth(const String& rText, xub_StrLen nIndex, xub_StrLen nLength); + + double getTextHeight() const; + double getUnderlineHeight() const; + double getUnderlineOffset() const; + double getStrikeoutOffset() const; + + double getTextWidth(const String& rText, xub_StrLen nIndex, xub_StrLen nLength) const; bool getTextOutlines( basegfx::B2DPolyPolygonVector&, const String&, xub_StrLen nIndex, xub_StrLen nLength, const ::std::vector< sal_Int32 >& rDXArray ); - basegfx::B2DRange getTextBoundRect(const String& rText, xub_StrLen nIndex, xub_StrLen nLength); + basegfx::B2DRange getTextBoundRect(const String& rText, xub_StrLen nIndex, xub_StrLen nLength) const; }; } // end of namespace primitive2d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx index 6b14cc69284e..769f7cffea1e 100644 --- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx +++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx @@ -4,9 +4,9 @@ * * $RCSfile: textlayoutdevice.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: hdu $ $Date: 2007-02-13 08:07:43 $ + * last change: $Author: hdu $ $Date: 2007-02-14 14:53:01 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -49,6 +49,10 @@ #include <vcl/font.hxx> #endif +#ifndef _SV_METRIC_HXX +#include <vcl/metric.hxx> +#endif + #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTPRIMITIVE2D_HXX #include <drawinglayer/primitive2d/textprimitive2d.hxx> #endif @@ -180,12 +184,33 @@ namespace drawinglayer setFont( getVclFontFromFontAttributes(rFontAttributes, rTransform) ); } - double TextLayouterDevice::getTextHeight() + double TextLayouterDevice::getUnderlineOffset() const + { + const ::FontMetric& rMetric = mrDevice.GetFontMetric(); + double fRet = rMetric.GetDescent() / 2.0; + return fRet; + } + + double TextLayouterDevice::getStrikeoutOffset() const + { + const ::FontMetric& rMetric = mrDevice.GetFontMetric(); + double fRet = (rMetric.GetAscent() - rMetric.GetIntLeading()) / 3.0; + return fRet; + } + + double TextLayouterDevice::getUnderlineHeight() const + { + const ::FontMetric& rMetric = mrDevice.GetFontMetric(); + double fRet = rMetric.GetDescent() / 4.0; + return fRet; + } + + double TextLayouterDevice::getTextHeight() const { return mrDevice.GetTextHeight(); } - double TextLayouterDevice::getTextWidth(const String& rText, xub_StrLen nIndex, xub_StrLen nLength) + double TextLayouterDevice::getTextWidth(const String& rText, xub_StrLen nIndex, xub_StrLen nLength) const { return mrDevice.GetTextWidth(rText, nIndex, nLength); } @@ -196,7 +221,7 @@ namespace drawinglayer return mrDevice.GetTextOutlines( rB2DPolyPolyVector, rText, nIndex, nIndex, nLength, true, 0, pDXArray); } - basegfx::B2DRange TextLayouterDevice::getTextBoundRect(const String& rText, xub_StrLen nIndex, xub_StrLen nLength) + basegfx::B2DRange TextLayouterDevice::getTextBoundRect(const String& rText, xub_StrLen nIndex, xub_StrLen nLength) const { if(rText.Len() && nLength) { |