LCOV - code coverage report
Current view: top level - vcl/source/gdi - hatch.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 72 0.0 %
Date: 2014-04-14 Functions: 0 16 0.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/stream.hxx>
      21             : #include <tools/vcompat.hxx>
      22             : #include <tools/debug.hxx>
      23             : #include <vcl/hatch.hxx>
      24             : 
      25           0 : ImplHatch::ImplHatch() :
      26             :     mnRefCount  ( 1 ),
      27             :     maColor     ( COL_BLACK ),
      28             :     meStyle     ( HATCH_SINGLE ),
      29             :     mnDistance  ( 1 ),
      30           0 :     mnAngle     ( 0 )
      31             : {
      32           0 : }
      33             : 
      34           0 : ImplHatch::ImplHatch( const ImplHatch& rImplHatch ) :
      35             :     mnRefCount  ( 1 ),
      36             :     maColor     ( rImplHatch.maColor ),
      37             :     meStyle     ( rImplHatch.meStyle ),
      38             :     mnDistance  ( rImplHatch.mnDistance ),
      39           0 :     mnAngle     ( rImplHatch.mnAngle )
      40             : {
      41           0 : }
      42             : 
      43           0 : Hatch::Hatch()
      44             : {
      45           0 :     mpImplHatch = new ImplHatch;
      46           0 : }
      47             : 
      48           0 : Hatch::Hatch( const Hatch& rHatch )
      49             : {
      50           0 :     mpImplHatch = rHatch.mpImplHatch;
      51           0 :     mpImplHatch->mnRefCount++;
      52           0 : }
      53             : 
      54           0 : Hatch::Hatch( HatchStyle eStyle, const Color& rColor,
      55             :               long nDistance, sal_uInt16 nAngle10 )
      56             : {
      57           0 :     mpImplHatch = new ImplHatch;
      58           0 :     mpImplHatch->maColor = rColor;
      59           0 :     mpImplHatch->meStyle = eStyle;
      60           0 :     mpImplHatch->mnDistance = nDistance;
      61           0 :     mpImplHatch->mnAngle = nAngle10;
      62           0 : }
      63             : 
      64           0 : Hatch::~Hatch()
      65             : {
      66           0 :     if( !( --mpImplHatch->mnRefCount ) )
      67           0 :         delete mpImplHatch;
      68           0 : }
      69             : 
      70           0 : Hatch& Hatch::operator=( const Hatch& rHatch )
      71             : {
      72             : 
      73           0 :     rHatch.mpImplHatch->mnRefCount++;
      74             : 
      75           0 :     if( !( --mpImplHatch->mnRefCount ) )
      76           0 :         delete mpImplHatch;
      77             : 
      78           0 :     mpImplHatch = rHatch.mpImplHatch;
      79           0 :     return *this;
      80             : }
      81             : 
      82           0 : bool Hatch::operator==( const Hatch& rHatch ) const
      83             : {
      84             : 
      85           0 :     return( mpImplHatch == rHatch.mpImplHatch ||
      86           0 :             ( mpImplHatch->maColor == rHatch.mpImplHatch->maColor &&
      87           0 :               mpImplHatch->meStyle == rHatch.mpImplHatch->meStyle &&
      88           0 :               mpImplHatch->mnDistance == rHatch.mpImplHatch->mnDistance &&
      89           0 :               mpImplHatch->mnAngle == rHatch.mpImplHatch->mnAngle ) );
      90             : }
      91             : 
      92           0 : void Hatch::ImplMakeUnique()
      93             : {
      94           0 :     if( mpImplHatch->mnRefCount != 1 )
      95             :     {
      96           0 :         if( mpImplHatch->mnRefCount )
      97           0 :             mpImplHatch->mnRefCount--;
      98             : 
      99           0 :         mpImplHatch = new ImplHatch( *mpImplHatch );
     100             :     }
     101           0 : }
     102             : 
     103           0 : void Hatch::SetColor( const Color& rColor )
     104             : {
     105           0 :     ImplMakeUnique();
     106           0 :     mpImplHatch->maColor = rColor;
     107           0 : }
     108             : 
     109           0 : void Hatch::SetDistance( long nDistance )
     110             : {
     111           0 :     ImplMakeUnique();
     112           0 :     mpImplHatch->mnDistance = nDistance;
     113           0 : }
     114             : 
     115           0 : void Hatch::SetAngle( sal_uInt16 nAngle10 )
     116             : {
     117           0 :     ImplMakeUnique();
     118           0 :     mpImplHatch->mnAngle = nAngle10;
     119           0 : }
     120             : 
     121           0 : SvStream& ReadImplHatch( SvStream& rIStm, ImplHatch& rImplHatch )
     122             : {
     123           0 :     VersionCompat   aCompat( rIStm, STREAM_READ );
     124             :     sal_uInt16          nTmp16;
     125           0 :     sal_Int32       nTmp32(0);
     126             : 
     127           0 :     rIStm.ReadUInt16( nTmp16 ); rImplHatch.meStyle = (HatchStyle) nTmp16;
     128             :     //#fdo39428 SvStream no longer supports operator>>(long&)
     129           0 :     ReadColor( rIStm, rImplHatch.maColor ).ReadInt32( nTmp32 ).ReadUInt16( rImplHatch.mnAngle );
     130           0 :     rImplHatch.mnDistance = nTmp32;
     131             : 
     132           0 :     return rIStm;
     133             : }
     134             : 
     135           0 : SvStream& WriteImplHatch( SvStream& rOStm, const ImplHatch& rImplHatch )
     136             : {
     137           0 :     VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
     138             : 
     139           0 :     rOStm.WriteUInt16( (sal_uInt16) rImplHatch.meStyle );
     140           0 :     WriteColor( rOStm, rImplHatch.maColor );
     141             :     //#fdo39428 SvStream no longer supports operator<<(long)
     142           0 :     rOStm.WriteInt32( sal::static_int_cast<sal_Int32>(rImplHatch.mnDistance) ).WriteUInt16( rImplHatch.mnAngle );
     143             : 
     144           0 :     return rOStm;
     145             : }
     146             : 
     147           0 : SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch )
     148             : {
     149           0 :     rHatch.ImplMakeUnique();
     150           0 :     return ReadImplHatch( rIStm, *rHatch.mpImplHatch );
     151             : }
     152             : 
     153           0 : SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch )
     154             : {
     155           0 :     return WriteImplHatch( rOStm, *rHatch.mpImplHatch );
     156             : }
     157             : 
     158             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10