LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/drawinglayer/primitive2d - textprimitive2d.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 11 90.9 %
Date: 2012-08-25 Functions: 11 12 91.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 8 50.0 %

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

Generated by: LCOV version 1.10