LCOV - code coverage report
Current view: top level - vcl/source/gdi - graphictools.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 127 137 92.7 %
Date: 2014-11-03 Functions: 20 23 87.0 %
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             : #include <tools/vcompat.hxx>
      21             : 
      22             : #include <vcl/graphictools.hxx>
      23             : 
      24         186 : SvtGraphicFill::Transform::Transform()
      25             : {
      26         186 :     matrix[0] = 1.0; matrix[1] = 0.0; matrix[2] = 0.0;
      27         186 :     matrix[3] = 0.0; matrix[4] = 1.0; matrix[5] = 0.0;
      28         186 : }
      29             : 
      30        2814 : SvtGraphicStroke::SvtGraphicStroke() :
      31             :     maPath(),
      32             :     maStartArrow(),
      33             :     maEndArrow(),
      34             :     mfTransparency(),
      35             :     mfStrokeWidth(),
      36             :     maCapType(),
      37             :     maJoinType(),
      38             :     mfMiterLimit( 3.0 ),
      39        2814 :     maDashArray()
      40             : {
      41        2814 : }
      42             : 
      43        3386 : SvtGraphicStroke::SvtGraphicStroke( const Polygon&      rPath,
      44             :                                     const tools::PolyPolygon&  rStartArrow,
      45             :                                     const tools::PolyPolygon&  rEndArrow,
      46             :                                     double              fTransparency,
      47             :                                     double              fStrokeWidth,
      48             :                                     CapType             aCap,
      49             :                                     JoinType            aJoin,
      50             :                                     double              fMiterLimit,
      51             :                                     const DashArray&    rDashArray  ) :
      52             :     maPath( rPath ),
      53             :     maStartArrow( rStartArrow ),
      54             :     maEndArrow( rEndArrow ),
      55             :     mfTransparency( fTransparency ),
      56             :     mfStrokeWidth( fStrokeWidth ),
      57             :     maCapType( aCap ),
      58             :     maJoinType( aJoin ),
      59             :     mfMiterLimit( fMiterLimit ),
      60        3386 :     maDashArray( rDashArray )
      61             : {
      62        3386 : }
      63             : 
      64        2006 : void SvtGraphicStroke::getPath( Polygon& rPath ) const
      65             : {
      66        2006 :     rPath = maPath;
      67        2006 : }
      68             : 
      69        2006 : void SvtGraphicStroke::getStartArrow( tools::PolyPolygon& rPath ) const
      70             : {
      71        2006 :     rPath = maStartArrow;
      72        2006 : }
      73             : 
      74        2006 : void SvtGraphicStroke::getEndArrow( tools::PolyPolygon& rPath ) const
      75             : {
      76        2006 :     rPath = maEndArrow;
      77        2006 : }
      78             : 
      79             : 
      80             : 
      81             : 
      82             : 
      83             : 
      84           0 : void SvtGraphicStroke::getDashArray( DashArray& rDashArray ) const
      85             : {
      86           0 :     rDashArray = maDashArray;
      87           0 : }
      88             : 
      89        2006 : void SvtGraphicStroke::setPath( const Polygon& rPoly )
      90             : {
      91        2006 :     maPath = rPoly;
      92        2006 : }
      93             : 
      94        2006 : void SvtGraphicStroke::setStartArrow( const tools::PolyPolygon& rPoly )
      95             : {
      96        2006 :     maStartArrow = rPoly;
      97        2006 : }
      98             : 
      99        2006 : void SvtGraphicStroke::setEndArrow( const tools::PolyPolygon& rPoly )
     100             : {
     101        2006 :     maEndArrow = rPoly;
     102        2006 : }
     103             : 
     104         808 : void SvtGraphicStroke::scale( double fXScale, double fYScale )
     105             : {
     106             :     // Clearly scaling stroke-width for fat lines is rather a problem
     107         808 :     maPath.Scale( fXScale, fYScale );
     108             : 
     109         808 :     double fScale = sqrt (fabs (fXScale * fYScale) ); // clearly not ideal.
     110         808 :     mfStrokeWidth *= fScale;
     111         808 :     mfMiterLimit *= fScale;
     112             : 
     113         808 :     maStartArrow.Scale( fXScale, fYScale );
     114         808 :     maEndArrow.Scale( fXScale, fYScale );
     115         808 : }
     116             : 
     117        6200 : SvStream& WriteSvtGraphicStroke( SvStream& rOStm, const SvtGraphicStroke& rClass )
     118             : {
     119        6200 :     VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
     120             : 
     121        6200 :     rClass.maPath.Write( rOStm );
     122        6200 :     rClass.maStartArrow.Write( rOStm );
     123        6200 :     rClass.maEndArrow.Write( rOStm );
     124        6200 :     rOStm.WriteDouble( rClass.mfTransparency );
     125        6200 :     rOStm.WriteDouble( rClass.mfStrokeWidth );
     126        6200 :     sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maCapType );
     127        6200 :     rOStm.WriteUInt16( nTmp );
     128        6200 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maJoinType );
     129        6200 :     rOStm.WriteUInt16( nTmp );
     130        6200 :     rOStm.WriteDouble( rClass.mfMiterLimit );
     131             : 
     132        6200 :     rOStm.WriteUInt32( rClass.maDashArray.size() );
     133             :     size_t i;
     134        6208 :     for(i=0; i<rClass.maDashArray.size(); ++i)
     135           8 :         rOStm.WriteDouble( rClass.maDashArray[i] );
     136             : 
     137        6200 :     return rOStm;
     138             : }
     139             : 
     140        2814 : SvStream& ReadSvtGraphicStroke( SvStream& rIStm, SvtGraphicStroke& rClass )
     141             : {
     142        2814 :     VersionCompat aCompat( rIStm, STREAM_READ );
     143             : 
     144        2814 :     rClass.maPath.Read( rIStm );
     145        2814 :     rClass.maStartArrow.Read( rIStm );
     146        2814 :     rClass.maEndArrow.Read( rIStm );
     147        2814 :     rIStm.ReadDouble( rClass.mfTransparency );
     148        2814 :     rIStm.ReadDouble( rClass.mfStrokeWidth );
     149             :     sal_uInt16 nTmp;
     150        2814 :     rIStm.ReadUInt16( nTmp );
     151        2814 :     rClass.maCapType = SvtGraphicStroke::CapType(nTmp);
     152        2814 :     rIStm.ReadUInt16( nTmp );
     153        2814 :     rClass.maJoinType = SvtGraphicStroke::JoinType(nTmp);
     154        2814 :     rIStm.ReadDouble( rClass.mfMiterLimit );
     155             : 
     156             :     sal_uInt32 nSize;
     157        2814 :     rIStm.ReadUInt32( nSize );
     158        2814 :     rClass.maDashArray.resize(nSize);
     159             :     size_t i;
     160        2814 :     for(i=0; i<rClass.maDashArray.size(); ++i)
     161           0 :         rIStm.ReadDouble( rClass.maDashArray[i] );
     162             : 
     163        2814 :     return rIStm;
     164             : }
     165             : 
     166          92 : SvtGraphicFill::SvtGraphicFill() :
     167             :     maPath(),
     168             :     maFillColor( COL_BLACK ),
     169             :     mfTransparency(),
     170             :     maFillRule(),
     171             :     maFillType(),
     172             :     maFillTransform(),
     173             :     mbTiling( false ),
     174             :     maHatchType(),
     175             :     maHatchColor( COL_BLACK ),
     176             :     maGradientType(),
     177             :     maGradient1stColor( COL_BLACK ),
     178             :     maGradient2ndColor( COL_BLACK ),
     179             :     maGradientStepCount( gradientStepsInfinite ),
     180          92 :     maFillGraphic()
     181             : {
     182          92 : }
     183             : 
     184          94 : SvtGraphicFill::SvtGraphicFill( const tools::PolyPolygon&  rPath,
     185             :                                 Color               aFillColor,
     186             :                                 double              fTransparency,
     187             :                                 FillRule            aFillRule,
     188             :                                 FillType            aFillType,
     189             :                                 const Transform&    aFillTransform,
     190             :                                 bool                bTiling,
     191             :                                 HatchType           aHatchType,
     192             :                                 Color               aHatchColor,
     193             :                                 GradientType        aGradientType,
     194             :                                 Color               aGradient1stColor,
     195             :                                 Color               aGradient2ndColor,
     196             :                                 sal_Int32           aGradientStepCount,
     197             :                                 const Graphic&      aFillGraphic ) :
     198             :     maPath( rPath ),
     199             :     maFillColor( aFillColor ),
     200             :     mfTransparency( fTransparency ),
     201             :     maFillRule( aFillRule ),
     202             :     maFillType( aFillType ),
     203             :     maFillTransform( aFillTransform ),
     204             :     mbTiling( bTiling ),
     205             :     maHatchType( aHatchType ),
     206             :     maHatchColor( aHatchColor ),
     207             :     maGradientType( aGradientType ),
     208             :     maGradient1stColor( aGradient1stColor ),
     209             :     maGradient2ndColor( aGradient2ndColor ),
     210             :     maGradientStepCount( aGradientStepCount ),
     211          94 :     maFillGraphic( aFillGraphic )
     212             : {
     213          94 : }
     214             : 
     215          92 : void SvtGraphicFill::getPath( tools::PolyPolygon& rPath ) const
     216             : {
     217          92 :     rPath = maPath;
     218          92 : }
     219             : 
     220             : 
     221             : 
     222             : 
     223             : 
     224           0 : void SvtGraphicFill::getTransform( Transform& rTrans ) const
     225             : {
     226           0 :     rTrans = maFillTransform;
     227           0 : }
     228             : 
     229             : 
     230             : 
     231             : 
     232           0 : void SvtGraphicFill::getGraphic( Graphic& rGraphic ) const
     233             : {
     234           0 :     rGraphic = maFillGraphic;
     235           0 : }
     236             : 
     237          92 : void SvtGraphicFill::setPath( const tools::PolyPolygon& rPath )
     238             : {
     239          92 :     maPath = rPath;
     240          92 : }
     241             : 
     242         186 : SvStream& WriteSvtGraphicFill( SvStream& rOStm, const SvtGraphicFill& rClass )
     243             : {
     244         186 :     VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
     245             : 
     246         186 :     rClass.maPath.Write( rOStm );
     247         186 :     WriteColor( rOStm, rClass.maFillColor );
     248         186 :     rOStm.WriteDouble( rClass.mfTransparency );
     249         186 :     sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillRule );
     250         186 :     rOStm.WriteUInt16( nTmp );
     251         186 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillType );
     252         186 :     rOStm.WriteUInt16( nTmp );
     253             :     int i;
     254        1302 :     for(i=0; i<SvtGraphicFill::Transform::MatrixSize; ++i)
     255        1116 :         rOStm.WriteDouble( rClass.maFillTransform.matrix[i] );
     256         186 :     nTmp = sal_uInt16(rClass.mbTiling);
     257         186 :     rOStm.WriteUInt16( nTmp );
     258         186 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maHatchType );
     259         186 :     rOStm.WriteUInt16( nTmp );
     260         186 :     WriteColor( rOStm, rClass.maHatchColor );
     261         186 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maGradientType );
     262         186 :     rOStm.WriteUInt16( nTmp );
     263         186 :     WriteColor( rOStm, rClass.maGradient1stColor );
     264         186 :     WriteColor( rOStm, rClass.maGradient2ndColor );
     265         186 :     rOStm.WriteInt32( rClass.maGradientStepCount );
     266         186 :     WriteGraphic( rOStm, rClass.maFillGraphic );
     267             : 
     268         186 :     return rOStm;
     269             : }
     270             : 
     271          92 : SvStream& ReadSvtGraphicFill( SvStream& rIStm, SvtGraphicFill& rClass )
     272             : {
     273          92 :     VersionCompat aCompat( rIStm, STREAM_READ );
     274             : 
     275          92 :     rClass.maPath.Read( rIStm );
     276          92 :     ReadColor( rIStm, rClass.maFillColor );
     277          92 :     rIStm.ReadDouble( rClass.mfTransparency );
     278             :     sal_uInt16 nTmp;
     279          92 :     rIStm.ReadUInt16( nTmp );
     280          92 :     rClass.maFillRule = SvtGraphicFill::FillRule( nTmp );
     281          92 :     rIStm.ReadUInt16( nTmp );
     282          92 :     rClass.maFillType = SvtGraphicFill::FillType( nTmp );
     283             :     int i;
     284         644 :     for(i=0; i<SvtGraphicFill::Transform::MatrixSize; ++i)
     285         552 :         rIStm.ReadDouble( rClass.maFillTransform.matrix[i] );
     286          92 :     rIStm.ReadUInt16( nTmp );
     287          92 :     rClass.mbTiling = nTmp;
     288          92 :     rIStm.ReadUInt16( nTmp );
     289          92 :     rClass.maHatchType = SvtGraphicFill::HatchType( nTmp );
     290          92 :     ReadColor( rIStm, rClass.maHatchColor );
     291          92 :     rIStm.ReadUInt16( nTmp );
     292          92 :     rClass.maGradientType = SvtGraphicFill::GradientType( nTmp );
     293          92 :     ReadColor( rIStm, rClass.maGradient1stColor );
     294          92 :     ReadColor( rIStm, rClass.maGradient2ndColor );
     295          92 :     rIStm.ReadInt32( rClass.maGradientStepCount );
     296          92 :     ReadGraphic( rIStm, rClass.maFillGraphic );
     297             : 
     298          92 :     return rIStm;
     299        1233 : }
     300             : 
     301             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10