LCOV - code coverage report
Current view: top level - vcl/source/gdi - graphictools.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 118 160 73.8 %
Date: 2014-04-11 Functions: 17 33 51.5 %
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          20 : SvtGraphicFill::Transform::Transform()
      25             : {
      26          20 :     matrix[0] = 1.0; matrix[1] = 0.0; matrix[2] = 0.0;
      27          20 :     matrix[3] = 0.0; matrix[4] = 1.0; matrix[5] = 0.0;
      28          20 : }
      29             : 
      30         557 : SvtGraphicStroke::SvtGraphicStroke() :
      31             :     maPath(),
      32             :     maStartArrow(),
      33             :     maEndArrow(),
      34             :     mfTransparency(),
      35             :     mfStrokeWidth(),
      36             :     maCapType(),
      37             :     maJoinType(),
      38             :     mfMiterLimit( 3.0 ),
      39         557 :     maDashArray()
      40             : {
      41         557 : }
      42             : 
      43         981 : SvtGraphicStroke::SvtGraphicStroke( const Polygon&      rPath,
      44             :                                     const PolyPolygon&  rStartArrow,
      45             :                                     const 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         981 :     maDashArray( rDashArray )
      61             : {
      62         981 : }
      63             : 
      64         557 : void SvtGraphicStroke::getPath( Polygon& rPath ) const
      65             : {
      66         557 :     rPath = maPath;
      67         557 : }
      68             : 
      69         557 : void SvtGraphicStroke::getStartArrow( PolyPolygon& rPath ) const
      70             : {
      71         557 :     rPath = maStartArrow;
      72         557 : }
      73             : 
      74         557 : void SvtGraphicStroke::getEndArrow( PolyPolygon& rPath ) const
      75             : {
      76         557 :     rPath = maEndArrow;
      77         557 : }
      78             : 
      79           0 : double SvtGraphicStroke::getTransparency() const
      80             : {
      81           0 :     return mfTransparency;
      82             : }
      83             : 
      84           0 : double SvtGraphicStroke::getStrokeWidth() const
      85             : {
      86           0 :     return mfStrokeWidth;
      87             : }
      88             : 
      89           0 : SvtGraphicStroke::CapType SvtGraphicStroke::getCapType() const
      90             : {
      91           0 :     return maCapType;
      92             : }
      93             : 
      94           0 : SvtGraphicStroke::JoinType SvtGraphicStroke::getJoinType() const
      95             : {
      96           0 :     return maJoinType;
      97             : }
      98             : 
      99           0 : double SvtGraphicStroke::getMiterLimit() const
     100             : {
     101           0 :     return mfMiterLimit;
     102             : }
     103             : 
     104           0 : void SvtGraphicStroke::getDashArray( DashArray& rDashArray ) const
     105             : {
     106           0 :     rDashArray = maDashArray;
     107           0 : }
     108             : 
     109         557 : void SvtGraphicStroke::setPath( const Polygon& rPoly )
     110             : {
     111         557 :     maPath = rPoly;
     112         557 : }
     113             : 
     114         557 : void SvtGraphicStroke::setStartArrow( const PolyPolygon& rPoly )
     115             : {
     116         557 :     maStartArrow = rPoly;
     117         557 : }
     118             : 
     119         557 : void SvtGraphicStroke::setEndArrow( const PolyPolygon& rPoly )
     120             : {
     121         557 :     maEndArrow = rPoly;
     122         557 : }
     123             : 
     124           0 : void SvtGraphicStroke::scale( double fXScale, double fYScale )
     125             : {
     126             :     // Clearly scaling stroke-width for fat lines is rather a problem
     127           0 :     maPath.Scale( fXScale, fYScale );
     128             : 
     129           0 :     double fScale = sqrt (fabs (fXScale * fYScale) ); // clearly not ideal.
     130           0 :     mfStrokeWidth *= fScale;
     131           0 :     mfMiterLimit *= fScale;
     132             : 
     133           0 :     maStartArrow.Scale( fXScale, fYScale );
     134           0 :     maEndArrow.Scale( fXScale, fYScale );
     135           0 : }
     136             : 
     137        1538 : SvStream& WriteSvtGraphicStroke( SvStream& rOStm, const SvtGraphicStroke& rClass )
     138             : {
     139        1538 :     VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
     140             : 
     141        1538 :     rClass.maPath.Write( rOStm );
     142        1538 :     rClass.maStartArrow.Write( rOStm );
     143        1538 :     rClass.maEndArrow.Write( rOStm );
     144        1538 :     rOStm.WriteDouble( rClass.mfTransparency );
     145        1538 :     rOStm.WriteDouble( rClass.mfStrokeWidth );
     146        1538 :     sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maCapType );
     147        1538 :     rOStm.WriteUInt16( nTmp );
     148        1538 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maJoinType );
     149        1538 :     rOStm.WriteUInt16( nTmp );
     150        1538 :     rOStm.WriteDouble( rClass.mfMiterLimit );
     151             : 
     152        1538 :     rOStm.WriteUInt32( static_cast<sal_uInt32>(rClass.maDashArray.size()) );
     153             :     size_t i;
     154        1544 :     for(i=0; i<rClass.maDashArray.size(); ++i)
     155           6 :         rOStm.WriteDouble( rClass.maDashArray[i] );
     156             : 
     157        1538 :     return rOStm;
     158             : }
     159             : 
     160         557 : SvStream& ReadSvtGraphicStroke( SvStream& rIStm, SvtGraphicStroke& rClass )
     161             : {
     162         557 :     VersionCompat aCompat( rIStm, STREAM_READ );
     163             : 
     164         557 :     rClass.maPath.Read( rIStm );
     165         557 :     rClass.maStartArrow.Read( rIStm );
     166         557 :     rClass.maEndArrow.Read( rIStm );
     167         557 :     rIStm.ReadDouble( rClass.mfTransparency );
     168         557 :     rIStm.ReadDouble( rClass.mfStrokeWidth );
     169             :     sal_uInt16 nTmp;
     170         557 :     rIStm.ReadUInt16( nTmp );
     171         557 :     rClass.maCapType = SvtGraphicStroke::CapType(nTmp);
     172         557 :     rIStm.ReadUInt16( nTmp );
     173         557 :     rClass.maJoinType = SvtGraphicStroke::JoinType(nTmp);
     174         557 :     rIStm.ReadDouble( rClass.mfMiterLimit );
     175             : 
     176             :     sal_uInt32 nSize;
     177         557 :     rIStm.ReadUInt32( nSize );
     178         557 :     rClass.maDashArray.resize(nSize);
     179             :     size_t i;
     180         557 :     for(i=0; i<rClass.maDashArray.size(); ++i)
     181           0 :         rIStm.ReadDouble( rClass.maDashArray[i] );
     182             : 
     183         557 :     return rIStm;
     184             : }
     185             : 
     186           2 : SvtGraphicFill::SvtGraphicFill() :
     187             :     maPath(),
     188             :     maFillColor( COL_BLACK ),
     189             :     mfTransparency(),
     190             :     maFillRule(),
     191             :     maFillType(),
     192             :     maFillTransform(),
     193             :     mbTiling( false ),
     194             :     maHatchType(),
     195             :     maHatchColor( COL_BLACK ),
     196             :     maGradientType(),
     197             :     maGradient1stColor( COL_BLACK ),
     198             :     maGradient2ndColor( COL_BLACK ),
     199             :     maGradientStepCount( gradientStepsInfinite ),
     200           2 :     maFillGraphic()
     201             : {
     202           2 : }
     203             : 
     204          18 : SvtGraphicFill::SvtGraphicFill( const PolyPolygon&  rPath,
     205             :                                 Color               aFillColor,
     206             :                                 double              fTransparency,
     207             :                                 FillRule            aFillRule,
     208             :                                 FillType            aFillType,
     209             :                                 const Transform&    aFillTransform,
     210             :                                 bool                bTiling,
     211             :                                 HatchType           aHatchType,
     212             :                                 Color               aHatchColor,
     213             :                                 GradientType        aGradientType,
     214             :                                 Color               aGradient1stColor,
     215             :                                 Color               aGradient2ndColor,
     216             :                                 sal_Int32           aGradientStepCount,
     217             :                                 const Graphic&      aFillGraphic ) :
     218             :     maPath( rPath ),
     219             :     maFillColor( aFillColor ),
     220             :     mfTransparency( fTransparency ),
     221             :     maFillRule( aFillRule ),
     222             :     maFillType( aFillType ),
     223             :     maFillTransform( aFillTransform ),
     224             :     mbTiling( bTiling ),
     225             :     maHatchType( aHatchType ),
     226             :     maHatchColor( aHatchColor ),
     227             :     maGradientType( aGradientType ),
     228             :     maGradient1stColor( aGradient1stColor ),
     229             :     maGradient2ndColor( aGradient2ndColor ),
     230             :     maGradientStepCount( aGradientStepCount ),
     231          18 :     maFillGraphic( aFillGraphic )
     232             : {
     233          18 : }
     234             : 
     235           2 : void SvtGraphicFill::getPath( PolyPolygon& rPath ) const
     236             : {
     237           2 :     rPath = maPath;
     238           2 : }
     239             : 
     240           0 : Color SvtGraphicFill::getFillColor() const
     241             : {
     242           0 :     return maFillColor;
     243             : }
     244             : 
     245           0 : double SvtGraphicFill::getTransparency() const
     246             : {
     247           0 :     return mfTransparency;
     248             : }
     249             : 
     250           0 : SvtGraphicFill::FillRule SvtGraphicFill::getFillRule() const
     251             : {
     252           0 :     return maFillRule;
     253             : }
     254             : 
     255           0 : SvtGraphicFill::FillType SvtGraphicFill::getFillType() const
     256             : {
     257           0 :     return maFillType;
     258             : }
     259             : 
     260           0 : void SvtGraphicFill::getTransform( Transform& rTrans ) const
     261             : {
     262           0 :     rTrans = maFillTransform;
     263           0 : }
     264             : 
     265           0 : bool SvtGraphicFill::IsTiling() const
     266             : {
     267           0 :     return mbTiling;
     268             : }
     269             : 
     270           0 : bool SvtGraphicFill::isTiling() const
     271             : {
     272           0 :     return mbTiling;
     273             : }
     274             : 
     275           0 : SvtGraphicFill::GradientType SvtGraphicFill::getGradientType() const
     276             : {
     277           0 :     return maGradientType;
     278             : }
     279             : 
     280           0 : void SvtGraphicFill::getGraphic( Graphic& rGraphic ) const
     281             : {
     282           0 :     rGraphic = maFillGraphic;
     283           0 : }
     284             : 
     285           2 : void SvtGraphicFill::setPath( const PolyPolygon& rPath )
     286             : {
     287           2 :     maPath = rPath;
     288           2 : }
     289             : 
     290          20 : SvStream& WriteSvtGraphicFill( SvStream& rOStm, const SvtGraphicFill& rClass )
     291             : {
     292          20 :     VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
     293             : 
     294          20 :     rClass.maPath.Write( rOStm );
     295          20 :     WriteColor( rOStm, rClass.maFillColor );
     296          20 :     rOStm.WriteDouble( rClass.mfTransparency );
     297          20 :     sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillRule );
     298          20 :     rOStm.WriteUInt16( nTmp );
     299          20 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillType );
     300          20 :     rOStm.WriteUInt16( nTmp );
     301             :     int i;
     302         140 :     for(i=0; i<SvtGraphicFill::Transform::MatrixSize; ++i)
     303         120 :         rOStm.WriteDouble( rClass.maFillTransform.matrix[i] );
     304          20 :     nTmp = sal_uInt16(rClass.mbTiling);
     305          20 :     rOStm.WriteUInt16( nTmp );
     306          20 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maHatchType );
     307          20 :     rOStm.WriteUInt16( nTmp );
     308          20 :     WriteColor( rOStm, rClass.maHatchColor );
     309          20 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maGradientType );
     310          20 :     rOStm.WriteUInt16( nTmp );
     311          20 :     WriteColor( rOStm, rClass.maGradient1stColor );
     312          20 :     WriteColor( rOStm, rClass.maGradient2ndColor );
     313          20 :     rOStm.WriteInt32( rClass.maGradientStepCount );
     314          20 :     WriteGraphic( rOStm, rClass.maFillGraphic );
     315             : 
     316          20 :     return rOStm;
     317             : }
     318             : 
     319           2 : SvStream& ReadSvtGraphicFill( SvStream& rIStm, SvtGraphicFill& rClass )
     320             : {
     321           2 :     VersionCompat aCompat( rIStm, STREAM_READ );
     322             : 
     323           2 :     rClass.maPath.Read( rIStm );
     324           2 :     ReadColor( rIStm, rClass.maFillColor );
     325           2 :     rIStm.ReadDouble( rClass.mfTransparency );
     326             :     sal_uInt16 nTmp;
     327           2 :     rIStm.ReadUInt16( nTmp );
     328           2 :     rClass.maFillRule = SvtGraphicFill::FillRule( nTmp );
     329           2 :     rIStm.ReadUInt16( nTmp );
     330           2 :     rClass.maFillType = SvtGraphicFill::FillType( nTmp );
     331             :     int i;
     332          14 :     for(i=0; i<SvtGraphicFill::Transform::MatrixSize; ++i)
     333          12 :         rIStm.ReadDouble( rClass.maFillTransform.matrix[i] );
     334           2 :     rIStm.ReadUInt16( nTmp );
     335           2 :     rClass.mbTiling = nTmp;
     336           2 :     rIStm.ReadUInt16( nTmp );
     337           2 :     rClass.maHatchType = SvtGraphicFill::HatchType( nTmp );
     338           2 :     ReadColor( rIStm, rClass.maHatchColor );
     339           2 :     rIStm.ReadUInt16( nTmp );
     340           2 :     rClass.maGradientType = SvtGraphicFill::GradientType( nTmp );
     341           2 :     ReadColor( rIStm, rClass.maGradient1stColor );
     342           2 :     ReadColor( rIStm, rClass.maGradient2ndColor );
     343           2 :     rIStm.ReadInt32( rClass.maGradientStepCount );
     344           2 :     ReadGraphic( rIStm, rClass.maFillGraphic );
     345             : 
     346           2 :     return rIStm;
     347             : }
     348             : 
     349             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10