LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/drawinglayer/primitive2d - textprimitive2d.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 11 90.9 %
Date: 2012-12-27 Functions: 11 12 91.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTPRIMITIVE2D_HXX
      21             : #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTPRIMITIVE2D_HXX
      22             : 
      23             : #include <drawinglayer/drawinglayerdllapi.h>
      24             : 
      25             : #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
      26             : #include <basegfx/matrix/b2dhommatrix.hxx>
      27             : #include <tools/string.hxx>
      28             : #include <vcl/font.hxx>
      29             : #include <basegfx/color/bcolor.hxx>
      30             : #include <vector>
      31             : #include <com/sun/star/lang/Locale.hpp>
      32             : #include <drawinglayer/attribute/fontattribute.hxx>
      33             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      34             : 
      35             : //////////////////////////////////////////////////////////////////////////////
      36             : // predefines
      37             : 
      38             : class OutputDevice;
      39             : 
      40             : //////////////////////////////////////////////////////////////////////////////
      41             : 
      42             : namespace drawinglayer
      43             : {
      44             :     namespace primitive2d
      45             :     {
      46             :         /** TextSimplePortionPrimitive2D class
      47             : 
      48             :             This is the basic primitive for representing a text portion. It contains
      49             :             all needed information. If it is not handled by a renderer, it's decomposition
      50             :             will provide the text PolyPolygon outlines as filled polygons, correctly
      51             :             transformed.
      52             : 
      53             :             To get better text quality, it is suggested to handle tis primitive directly
      54             :             in a renderer. In that case, e.g. hintings on the system can be supported.
      55             : 
      56             :             @param maTextTransform
      57             :             The text transformation contains the text start position (always baselined)
      58             :             as translation, the FontSize as scale (where width relative to height defines
      59             :             font scaling and width == height means no font scaling) and the font rotation
      60             :             and shear.
      61             :             When shear is used and a renderer does not support it, it may be better to use
      62             :             the decomposition which will do everything correctly. Same is true for mirroring
      63             :             which would be expressed as negative scalings.
      64             : 
      65             :             @param rText
      66             :             The text to be used. Only a part may be used, but a bigger part of the string
      67             :             may be necessary for correct layouting (e.g. international)
      68             : 
      69             :             @param aTextPosition
      70             :             The index to the first character to use from rText
      71             : 
      72             :             @param aTextLength
      73             :             The number of characters to use from rText
      74             : 
      75             :             @param rDXArray
      76             :             The distances between the characters. This parameter may be empty, in that case
      77             :             the renderer is responsible to do something useful. If it is given, it has to be of
      78             :             the size aTextLength. Its values are in logical coordinates and describe the
      79             :             distance for each character to use. This is independent from the font width which
      80             :             is given with maTextTransform. The first value is the offset to use from the start
      81             :             point in FontCoordinateSystem X-Direction (given by maTextTransform) to the start
      82             :             point of the second character
      83             : 
      84             :             @param rFontAttribute
      85             :             The font definition
      86             : 
      87             :             @param rLocale
      88             :             The locale to use
      89             : 
      90             :             @param rFontColor
      91             :             The font color to use
      92             :          */
      93         460 :         class DRAWINGLAYER_DLLPUBLIC TextSimplePortionPrimitive2D : public BufferedDecompositionPrimitive2D
      94             :         {
      95             :         private:
      96             :             /// text transformation (FontCoordinateSystem)
      97             :             basegfx::B2DHomMatrix                   maTextTransform;
      98             : 
      99             :             /// The text, used from maTextPosition up to maTextPosition + maTextLength
     100             :             String                                  maText;
     101             : 
     102             :             /// The index from where on maText is used
     103             :             xub_StrLen                              maTextPosition;
     104             : 
     105             :             /// The length for maText usage, starting from maTextPosition
     106             :             xub_StrLen                              maTextLength;
     107             : 
     108             :             /// The DX array in logic units
     109             :             ::std::vector< double >                 maDXArray;
     110             : 
     111             :             /// The font definition
     112             :             attribute::FontAttribute                maFontAttribute;
     113             : 
     114             :             /// The Locale for the text
     115             :             ::com::sun::star::lang::Locale          maLocale;
     116             : 
     117             :             /// font color
     118             :             basegfx::BColor                         maFontColor;
     119             : 
     120             :             /// #i96669# internal: add simple range buffering for this primitive
     121             :             basegfx::B2DRange                       maB2DRange;
     122             :             bool                                    mbFilled;           // Whether to fill a given width with the text
     123             :             long                                    mnWidthToFill;      // the width to fill
     124             : 
     125             :         protected:
     126             :             /// local decomposition.
     127             :             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
     128             : 
     129             :         public:
     130             :             /// constructor
     131             :             TextSimplePortionPrimitive2D(
     132             :                 const basegfx::B2DHomMatrix& rNewTransform,
     133             :                 const String& rText,
     134             :                 xub_StrLen aTextPosition,
     135             :                 xub_StrLen aTextLength,
     136             :                 const ::std::vector< double >& rDXArray,
     137             :                 const attribute::FontAttribute& rFontAttribute,
     138             :                 const ::com::sun::star::lang::Locale& rLocale,
     139             :                 const basegfx::BColor& rFontColor,
     140             :                 bool bFilled = false,
     141             :                 long nWidthToFill = 0);
     142             : 
     143             :             /// helpers
     144             :             /** get text outlines as polygons and their according ObjectTransformation. Handles all
     145             :                 the necessary VCL outline extractins, scaling adaptions and other stuff.
     146             :              */
     147             :             void getTextOutlinesAndTransformation(basegfx::B2DPolyPolygonVector& rTarget, basegfx::B2DHomMatrix& rTransformation) const;
     148             : 
     149             :             /// data read access
     150         249 :             const basegfx::B2DHomMatrix& getTextTransform() const { return maTextTransform; }
     151         254 :             const String& getText() const { return maText; }
     152         254 :             xub_StrLen getTextPosition() const { return maTextPosition; }
     153         496 :             xub_StrLen getTextLength() const { return maTextLength; }
     154          67 :             const ::std::vector< double >& getDXArray() const { return maDXArray; }
     155         263 :             const attribute::FontAttribute& getFontAttribute() const { return maFontAttribute; }
     156         254 :             const ::com::sun::star::lang::Locale& getLocale() const { return  maLocale; }
     157           7 :             const basegfx::BColor& getFontColor() const { return maFontColor; }
     158           7 :             bool isFilled() const { return mbFilled; }
     159           0 :             long getWidthToFill() const { return mnWidthToFill; }
     160             : 
     161             :             /// compare operator
     162             :             virtual bool operator==( const BasePrimitive2D& rPrimitive ) const;
     163             : 
     164             :             /// get range
     165             :             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
     166             : 
     167             :             /// provide unique ID
     168             :             DeclPrimitrive2DIDBlock()
     169             :         };
     170             : 
     171             :         /// small helper to have a compare operator for Locale
     172             :         bool DRAWINGLAYER_DLLPUBLIC LocalesAreEqual(const ::com::sun::star::lang::Locale& rA, const ::com::sun::star::lang::Locale& rB);
     173             : 
     174             :     } // end of namespace primitive2d
     175             : } // end of namespace drawinglayer
     176             : 
     177             : //////////////////////////////////////////////////////////////////////////////
     178             : 
     179             : #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTPRIMITIVE2D_HXX
     180             : 
     181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10