LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/vcl/source/gdi - graphictools.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 57 161 35.4 %
Date: 2013-07-09 Functions: 12 35 34.3 %
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           0 : SvtGraphicFill::Transform::Transform()
      25             : {
      26           0 :     matrix[0] = 1.0; matrix[1] = 0.0; matrix[2] = 0.0;
      27           0 :     matrix[3] = 0.0; matrix[4] = 1.0; matrix[5] = 0.0;
      28           0 : }
      29             : 
      30         139 : SvtGraphicStroke::SvtGraphicStroke() :
      31             :     maPath(),
      32             :     maStartArrow(),
      33             :     maEndArrow(),
      34             :     mfTransparency(),
      35             :     mfStrokeWidth(),
      36             :     maCapType(),
      37             :     maJoinType(),
      38             :     mfMiterLimit( 3.0 ),
      39         139 :     maDashArray()
      40             : {
      41         139 : }
      42             : 
      43         144 : 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         144 :     maDashArray( rDashArray )
      61             : {
      62         144 : }
      63             : 
      64         139 : void SvtGraphicStroke::getPath( Polygon& rPath ) const
      65             : {
      66         139 :     rPath = maPath;
      67         139 : }
      68             : 
      69         139 : void SvtGraphicStroke::getStartArrow( PolyPolygon& rPath ) const
      70             : {
      71         139 :     rPath = maStartArrow;
      72         139 : }
      73             : 
      74         139 : void SvtGraphicStroke::getEndArrow( PolyPolygon& rPath ) const
      75             : {
      76         139 :     rPath = maEndArrow;
      77         139 : }
      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         139 : void SvtGraphicStroke::setPath( const Polygon& rPoly )
     110             : {
     111         139 :     maPath = rPoly;
     112         139 : }
     113             : 
     114         139 : void SvtGraphicStroke::setStartArrow( const PolyPolygon& rPoly )
     115             : {
     116         139 :     maStartArrow = rPoly;
     117         139 : }
     118             : 
     119         139 : void SvtGraphicStroke::setEndArrow( const PolyPolygon& rPoly )
     120             : {
     121         139 :     maEndArrow = rPoly;
     122         139 : }
     123             : 
     124             : 
     125           0 : void SvtGraphicStroke::scale( double fXScale, double fYScale )
     126             : {
     127             :     // Clearly scaling stroke-width for fat lines is rather a problem
     128           0 :     maPath.Scale( fXScale, fYScale );
     129             : 
     130           0 :     double fScale = sqrt (fabs (fXScale * fYScale) ); // clearly not ideal.
     131           0 :     mfStrokeWidth *= fScale;
     132           0 :     mfMiterLimit *= fScale;
     133             : 
     134           0 :     maStartArrow.Scale( fXScale, fYScale );
     135           0 :     maEndArrow.Scale( fXScale, fYScale );
     136           0 : }
     137             : 
     138         283 : SvStream& operator<<( SvStream& rOStm, const SvtGraphicStroke& rClass )
     139             : {
     140         283 :     VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
     141             : 
     142         283 :     rClass.maPath.Write( rOStm );
     143         283 :     rClass.maStartArrow.Write( rOStm );
     144         283 :     rClass.maEndArrow.Write( rOStm );
     145         283 :     rOStm << rClass.mfTransparency;
     146         283 :     rOStm << rClass.mfStrokeWidth;
     147         283 :     sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maCapType );
     148         283 :     rOStm << nTmp;
     149         283 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maJoinType );
     150         283 :     rOStm << nTmp;
     151         283 :     rOStm << rClass.mfMiterLimit;
     152             : 
     153         283 :     rOStm << static_cast<sal_uInt32>(rClass.maDashArray.size());
     154             :     size_t i;
     155         291 :     for(i=0; i<rClass.maDashArray.size(); ++i)
     156           8 :         rOStm << rClass.maDashArray[i];
     157             : 
     158         283 :     return rOStm;
     159             : }
     160             : 
     161         139 : SvStream& operator>>( SvStream& rIStm, SvtGraphicStroke& rClass )
     162             : {
     163         139 :     VersionCompat aCompat( rIStm, STREAM_READ );
     164             : 
     165         139 :     rClass.maPath.Read( rIStm );
     166         139 :     rClass.maStartArrow.Read( rIStm );
     167         139 :     rClass.maEndArrow.Read( rIStm );
     168         139 :     rIStm >> rClass.mfTransparency;
     169         139 :     rIStm >> rClass.mfStrokeWidth;
     170             :     sal_uInt16 nTmp;
     171         139 :     rIStm >> nTmp;
     172         139 :     rClass.maCapType = SvtGraphicStroke::CapType(nTmp);
     173         139 :     rIStm >> nTmp;
     174         139 :     rClass.maJoinType = SvtGraphicStroke::JoinType(nTmp);
     175         139 :     rIStm >> rClass.mfMiterLimit;
     176             : 
     177             :     sal_uInt32 nSize;
     178         139 :     rIStm >> nSize;
     179         139 :     rClass.maDashArray.resize(nSize);
     180             :     size_t i;
     181         139 :     for(i=0; i<rClass.maDashArray.size(); ++i)
     182           0 :         rIStm >> rClass.maDashArray[i];
     183             : 
     184         139 :     return rIStm;
     185             : }
     186             : 
     187           0 : SvtGraphicFill::SvtGraphicFill() :
     188             :     maPath(),
     189             :     maFillColor( COL_BLACK ),
     190             :     mfTransparency(),
     191             :     maFillRule(),
     192             :     maFillType(),
     193             :     maFillTransform(),
     194             :     maHatchType(),
     195             :     maHatchColor( COL_BLACK ),
     196             :     maGradientType(),
     197             :     maGradient1stColor( COL_BLACK ),
     198             :     maGradient2ndColor( COL_BLACK ),
     199             :     maGradientStepCount( gradientStepsInfinite ),
     200           0 :     maFillGraphic()
     201             : {
     202           0 : }
     203             : 
     204           0 : 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           0 :     maFillGraphic( aFillGraphic )
     232             : {
     233           0 : }
     234             : 
     235           0 : void SvtGraphicFill::getPath( PolyPolygon& rPath ) const
     236             : {
     237           0 :     rPath = maPath;
     238           0 : }
     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           0 : void SvtGraphicFill::setPath( const PolyPolygon& rPath )
     286             : {
     287           0 :     maPath = rPath;
     288           0 : }
     289             : 
     290           0 : SvStream& operator<<( SvStream& rOStm, const SvtGraphicFill& rClass )
     291             : {
     292           0 :     VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
     293             : 
     294           0 :     rClass.maPath.Write( rOStm );
     295           0 :     rOStm << rClass.maFillColor;
     296           0 :     rOStm << rClass.mfTransparency;
     297           0 :     sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillRule );
     298           0 :     rOStm << nTmp;
     299           0 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillType );
     300           0 :     rOStm << nTmp;
     301             :     int i;
     302           0 :     for(i=0; i<SvtGraphicFill::Transform::MatrixSize; ++i)
     303           0 :         rOStm << rClass.maFillTransform.matrix[i];
     304           0 :     nTmp = rClass.mbTiling;
     305           0 :     rOStm << nTmp;
     306           0 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maHatchType );
     307           0 :     rOStm << nTmp;
     308           0 :     rOStm << rClass.maHatchColor;
     309           0 :     nTmp = sal::static_int_cast<sal_uInt16>( rClass.maGradientType );
     310           0 :     rOStm << nTmp;
     311           0 :     rOStm << rClass.maGradient1stColor;
     312           0 :     rOStm << rClass.maGradient2ndColor;
     313           0 :     rOStm << rClass.maGradientStepCount;
     314           0 :     rOStm << rClass.maFillGraphic;
     315             : 
     316           0 :     return rOStm;
     317             : }
     318             : 
     319           0 : SvStream& operator>>( SvStream& rIStm, SvtGraphicFill& rClass )
     320             : {
     321           0 :     VersionCompat aCompat( rIStm, STREAM_READ );
     322             : 
     323           0 :     rClass.maPath.Read( rIStm );
     324           0 :     rIStm >> rClass.maFillColor;
     325           0 :     rIStm >> rClass.mfTransparency;
     326             :     sal_uInt16 nTmp;
     327           0 :     rIStm >> nTmp;
     328           0 :     rClass.maFillRule = SvtGraphicFill::FillRule( nTmp );
     329           0 :     rIStm >> nTmp;
     330           0 :     rClass.maFillType = SvtGraphicFill::FillType( nTmp );
     331             :     int i;
     332           0 :     for(i=0; i<SvtGraphicFill::Transform::MatrixSize; ++i)
     333           0 :         rIStm >> rClass.maFillTransform.matrix[i];
     334           0 :     rIStm >> nTmp;
     335           0 :     rClass.mbTiling = nTmp;
     336           0 :     rIStm >> nTmp;
     337           0 :     rClass.maHatchType = SvtGraphicFill::HatchType( nTmp );
     338           0 :     rIStm >> rClass.maHatchColor;
     339           0 :     rIStm >> nTmp;
     340           0 :     rClass.maGradientType = SvtGraphicFill::GradientType( nTmp );
     341           0 :     rIStm >> rClass.maGradient1stColor;
     342           0 :     rIStm >> rClass.maGradient2ndColor;
     343           0 :     rIStm >> rClass.maGradientStepCount;
     344           0 :     rIStm >> rClass.maFillGraphic;
     345             : 
     346           0 :     return rIStm;
     347         465 : }
     348             : 
     349             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10