1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_DRAWINGLAYER_TEXTLAYOUTDEVICE_HXX 29 #define INCLUDED_DRAWINGLAYER_TEXTLAYOUTDEVICE_HXX 30 31 #include <drawinglayer/drawinglayerdllapi.h> 32 #include <tools/solar.h> 33 #include <tools/poly.hxx> 34 #include <basegfx/range/b2drange.hxx> 35 #include <vector> 36 #include <com/sun/star/lang/Locale.hpp> 37 38 ////////////////////////////////////////////////////////////////////////////// 39 // predefines 40 class VirtualDevice; 41 class Font; 42 class String; 43 class OutputDevice; 44 class GDIMetaFile; 45 46 namespace drawinglayer { namespace attribute { 47 class FontAttribute; 48 }} 49 50 namespace basegfx { 51 class B2DPolyPolygon; 52 typedef ::std::vector< B2DPolyPolygon > B2DPolyPolygonVector; 53 } 54 55 ////////////////////////////////////////////////////////////////////////////// 56 // access to one global impTimedRefDev incarnation in namespace drawinglayer::primitive 57 58 namespace drawinglayer 59 { 60 namespace primitive2d 61 { 62 /** TextLayouterDevice class 63 64 This helper class exists to isolate all accesses to VCL 65 text formatting/handling functionality for primitive implementations. 66 When in the future FontHandling may move to an own library independent 67 from VCL, primitives will be prepared. 68 */ 69 class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice 70 { 71 /// internally used VirtualDevice 72 VirtualDevice& mrDevice; 73 74 public: 75 /// constructor/destructor 76 TextLayouterDevice(); 77 ~TextLayouterDevice(); 78 79 /// tooling methods 80 void setFont(const Font& rFont); 81 void setFontAttribute( 82 const attribute::FontAttribute& rFontAttribute, 83 double fFontScaleX, 84 double fFontScaleY, 85 const ::com::sun::star::lang::Locale & rLocale); 86 87 double getTextHeight() const; 88 double getOverlineHeight() const; 89 double getOverlineOffset() const; 90 double getUnderlineHeight() const; 91 double getUnderlineOffset() const; 92 double getStrikeoutOffset() const; 93 94 double getTextWidth( 95 const String& rText, 96 sal_uInt32 nIndex, 97 sal_uInt32 nLength) const; 98 99 bool getTextOutlines( 100 basegfx::B2DPolyPolygonVector&, 101 const String& rText, 102 sal_uInt32 nIndex, 103 sal_uInt32 nLength, 104 const ::std::vector< double >& rDXArray) const; 105 106 basegfx::B2DRange getTextBoundRect( 107 const String& rText, 108 sal_uInt32 nIndex, 109 sal_uInt32 nLength) const; 110 111 double getFontAscent() const; 112 double getFontDescent() const; 113 114 void addTextRectActions( 115 const Rectangle& rRectangle, 116 const String& rText, 117 sal_uInt16 nStyle, 118 GDIMetaFile& rGDIMetaFile) const; 119 120 ::std::vector< double > getTextArray( 121 const String& rText, 122 sal_uInt32 nIndex, 123 sal_uInt32 nLength) const; 124 }; 125 } // end of namespace primitive2d 126 } // end of namespace drawinglayer 127 128 ////////////////////////////////////////////////////////////////////////////// 129 // helper methods for vcl font handling 130 131 namespace drawinglayer 132 { 133 namespace primitive2d 134 { 135 /** Create a VCL-Font based on the definitions in FontAttribute 136 and the given FontScaling. The FontScaling defines the FontHeight 137 (fFontScaleY) and the FontWidth (fFontScaleX). The combination of 138 both defines FontStretching, where no stretching happens at 139 fFontScaleY == fFontScaleX 140 */ 141 Font DRAWINGLAYER_DLLPUBLIC getVclFontFromFontAttribute( 142 const attribute::FontAttribute& rFontAttribute, 143 double fFontScaleX, 144 double fFontScaleY, 145 double fFontRotation, 146 const ::com::sun::star::lang::Locale & rLocale); 147 148 /** Generate FontAttribute DataSet derived from the given VCL-Font. 149 The FontScaling with fFontScaleY, fFontScaleX relationship (see 150 above) will be set in return parameter o_rSize to allow further 151 processing 152 */ 153 attribute::FontAttribute DRAWINGLAYER_DLLPUBLIC getFontAttributeFromVclFont( 154 basegfx::B2DVector& o_rSize, 155 const Font& rFont, 156 bool bRTL, 157 bool bBiDiStrong); 158 159 } // end of namespace primitive2d 160 } // end of namespace drawinglayer 161 162 ////////////////////////////////////////////////////////////////////////////// 163 164 #endif //_DRAWINGLAYER_TEXTLAYOUTDEVICE_HXX 165