1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_DRAWINGLAYER_TEXTLAYOUTDEVICE_HXX 25 #define INCLUDED_DRAWINGLAYER_TEXTLAYOUTDEVICE_HXX 26 27 #include <drawinglayer/drawinglayerdllapi.h> 28 #include <tools/solar.h> 29 #include <tools/poly.hxx> 30 #include <basegfx/range/b2drange.hxx> 31 #include <vector> 32 #include <com/sun/star/lang/Locale.hpp> 33 34 ////////////////////////////////////////////////////////////////////////////// 35 // predefines 36 class VirtualDevice; 37 class Font; 38 class String; 39 class OutputDevice; 40 class GDIMetaFile; 41 42 namespace drawinglayer { namespace attribute { 43 class FontAttribute; 44 }} 45 46 namespace basegfx { 47 class B2DPolyPolygon; 48 typedef ::std::vector< B2DPolyPolygon > B2DPolyPolygonVector; 49 } 50 51 ////////////////////////////////////////////////////////////////////////////// 52 // access to one global impTimedRefDev incarnation in namespace drawinglayer::primitive 53 54 namespace drawinglayer 55 { 56 namespace primitive2d 57 { 58 /** TextLayouterDevice class 59 60 This helper class exists to isolate all accesses to VCL 61 text formatting/handling functionality for primitive implementations. 62 When in the future FontHandling may move to an own library independent 63 from VCL, primitives will be prepared. 64 */ 65 class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice 66 { 67 /// internally used VirtualDevice 68 VirtualDevice& mrDevice; 69 70 public: 71 /// constructor/destructor 72 TextLayouterDevice(); 73 ~TextLayouterDevice(); 74 75 /// tooling methods 76 void setFont(const Font& rFont); 77 void setFontAttribute( 78 const attribute::FontAttribute& rFontAttribute, 79 double fFontScaleX, 80 double fFontScaleY, 81 const ::com::sun::star::lang::Locale & rLocale); 82 83 double getTextHeight() const; 84 double getOverlineHeight() const; 85 double getOverlineOffset() const; 86 double getUnderlineHeight() const; 87 double getUnderlineOffset() const; 88 double getStrikeoutOffset() const; 89 90 double getTextWidth( 91 const String& rText, 92 sal_uInt32 nIndex, 93 sal_uInt32 nLength) const; 94 95 bool getTextOutlines( 96 basegfx::B2DPolyPolygonVector&, 97 const String& rText, 98 sal_uInt32 nIndex, 99 sal_uInt32 nLength, 100 const ::std::vector< double >& rDXArray) const; 101 102 basegfx::B2DRange getTextBoundRect( 103 const String& rText, 104 sal_uInt32 nIndex, 105 sal_uInt32 nLength) const; 106 107 double getFontAscent() const; 108 double getFontDescent() const; 109 110 void addTextRectActions( 111 const Rectangle& rRectangle, 112 const String& rText, 113 sal_uInt16 nStyle, 114 GDIMetaFile& rGDIMetaFile) const; 115 116 ::std::vector< double > getTextArray( 117 const String& rText, 118 sal_uInt32 nIndex, 119 sal_uInt32 nLength) const; 120 }; 121 } // end of namespace primitive2d 122 } // end of namespace drawinglayer 123 124 ////////////////////////////////////////////////////////////////////////////// 125 // helper methods for vcl font handling 126 127 namespace drawinglayer 128 { 129 namespace primitive2d 130 { 131 /** Create a VCL-Font based on the definitions in FontAttribute 132 and the given FontScaling. The FontScaling defines the FontHeight 133 (fFontScaleY) and the FontWidth (fFontScaleX). The combination of 134 both defines FontStretching, where no stretching happens at 135 fFontScaleY == fFontScaleX 136 */ 137 Font DRAWINGLAYER_DLLPUBLIC getVclFontFromFontAttribute( 138 const attribute::FontAttribute& rFontAttribute, 139 double fFontScaleX, 140 double fFontScaleY, 141 double fFontRotation, 142 const ::com::sun::star::lang::Locale & rLocale); 143 144 /** Generate FontAttribute DataSet derived from the given VCL-Font. 145 The FontScaling with fFontScaleY, fFontScaleX relationship (see 146 above) will be set in return parameter o_rSize to allow further 147 processing 148 */ 149 attribute::FontAttribute DRAWINGLAYER_DLLPUBLIC getFontAttributeFromVclFont( 150 basegfx::B2DVector& o_rSize, 151 const Font& rFont, 152 bool bRTL, 153 bool bBiDiStrong); 154 155 } // end of namespace primitive2d 156 } // end of namespace drawinglayer 157 158 ////////////////////////////////////////////////////////////////////////////// 159 160 #endif //_DRAWINGLAYER_TEXTLAYOUTDEVICE_HXX 161