LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/vcl/source/gdi - hatch.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 31 71 43.7 %
Date: 2013-07-09 Functions: 7 16 43.8 %
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             : DBG_NAME( Hatch )
      26             : 
      27         238 : ImplHatch::ImplHatch() :
      28             :     mnRefCount  ( 1 ),
      29             :     maColor     ( COL_BLACK ),
      30             :     meStyle     ( HATCH_SINGLE ),
      31             :     mnDistance  ( 1 ),
      32         238 :     mnAngle     ( 0 )
      33             : {
      34         238 : }
      35             : 
      36         238 : ImplHatch::ImplHatch( const ImplHatch& rImplHatch ) :
      37             :     mnRefCount  ( 1 ),
      38             :     maColor     ( rImplHatch.maColor ),
      39             :     meStyle     ( rImplHatch.meStyle ),
      40             :     mnDistance  ( rImplHatch.mnDistance ),
      41         238 :     mnAngle     ( rImplHatch.mnAngle )
      42             : {
      43         238 : }
      44             : 
      45           0 : Hatch::Hatch()
      46             : {
      47             :     DBG_CTOR( Hatch, NULL );
      48           0 :     mpImplHatch = new ImplHatch;
      49           0 : }
      50             : 
      51         238 : Hatch::Hatch( const Hatch& rHatch )
      52             : {
      53             :     DBG_CTOR( Hatch, NULL );
      54             :     DBG_CHKOBJ( &rHatch, Hatch, NULL );
      55         238 :     mpImplHatch = rHatch.mpImplHatch;
      56         238 :     mpImplHatch->mnRefCount++;
      57         238 : }
      58             : 
      59         238 : Hatch::Hatch( HatchStyle eStyle, const Color& rColor,
      60             :               long nDistance, sal_uInt16 nAngle10 )
      61             : {
      62             :     DBG_CTOR( Hatch, NULL );
      63         238 :     mpImplHatch = new ImplHatch;
      64         238 :     mpImplHatch->maColor = rColor;
      65         238 :     mpImplHatch->meStyle = eStyle;
      66         238 :     mpImplHatch->mnDistance = nDistance;
      67         238 :     mpImplHatch->mnAngle = nAngle10;
      68         238 : }
      69             : 
      70         476 : Hatch::~Hatch()
      71             : {
      72             :     DBG_DTOR( Hatch, NULL );
      73         476 :     if( !( --mpImplHatch->mnRefCount ) )
      74         476 :         delete mpImplHatch;
      75         476 : }
      76             : 
      77           0 : Hatch& Hatch::operator=( const Hatch& rHatch )
      78             : {
      79             :     DBG_CHKTHIS( Hatch, NULL );
      80             :     DBG_CHKOBJ( &rHatch, Hatch, NULL );
      81             : 
      82           0 :     rHatch.mpImplHatch->mnRefCount++;
      83             : 
      84           0 :     if( !( --mpImplHatch->mnRefCount ) )
      85           0 :         delete mpImplHatch;
      86             : 
      87           0 :     mpImplHatch = rHatch.mpImplHatch;
      88           0 :     return *this;
      89             : }
      90             : 
      91           0 : sal_Bool Hatch::operator==( const Hatch& rHatch ) const
      92             : {
      93             :     DBG_CHKTHIS( Hatch, NULL );
      94             :     DBG_CHKOBJ( &rHatch, Hatch, NULL );
      95             : 
      96           0 :     return( mpImplHatch == rHatch.mpImplHatch ||
      97           0 :             ( mpImplHatch->maColor == rHatch.mpImplHatch->maColor &&
      98           0 :               mpImplHatch->meStyle == rHatch.mpImplHatch->meStyle &&
      99           0 :               mpImplHatch->mnDistance == rHatch.mpImplHatch->mnDistance &&
     100           0 :               mpImplHatch->mnAngle == rHatch.mpImplHatch->mnAngle ) );
     101             : }
     102             : 
     103         238 : void Hatch::ImplMakeUnique()
     104             : {
     105         238 :     if( mpImplHatch->mnRefCount != 1 )
     106             :     {
     107         238 :         if( mpImplHatch->mnRefCount )
     108         238 :             mpImplHatch->mnRefCount--;
     109             : 
     110         238 :         mpImplHatch = new ImplHatch( *mpImplHatch );
     111             :     }
     112         238 : }
     113             : 
     114           0 : void Hatch::SetColor( const Color& rColor )
     115             : {
     116             :     DBG_CHKTHIS( Hatch, NULL );
     117           0 :     ImplMakeUnique();
     118           0 :     mpImplHatch->maColor = rColor;
     119           0 : }
     120             : 
     121         238 : void Hatch::SetDistance( long nDistance )
     122             : {
     123             :     DBG_CHKTHIS( Hatch, NULL );
     124         238 :     ImplMakeUnique();
     125         238 :     mpImplHatch->mnDistance = nDistance;
     126         238 : }
     127             : 
     128           0 : void Hatch::SetAngle( sal_uInt16 nAngle10 )
     129             : {
     130             :     DBG_CHKTHIS( Hatch, NULL );
     131           0 :     ImplMakeUnique();
     132           0 :     mpImplHatch->mnAngle = nAngle10;
     133           0 : }
     134             : 
     135           0 : SvStream& operator>>( SvStream& rIStm, ImplHatch& rImplHatch )
     136             : {
     137           0 :     VersionCompat   aCompat( rIStm, STREAM_READ );
     138             :     sal_uInt16          nTmp16;
     139           0 :     sal_Int32       nTmp32(0);
     140             : 
     141           0 :     rIStm >> nTmp16; rImplHatch.meStyle = (HatchStyle) nTmp16;
     142             :     //#fdo39428 SvStream no longer supports operator>>(long&)
     143           0 :     rIStm >> rImplHatch.maColor >> nTmp32 >> rImplHatch.mnAngle;
     144           0 :     rImplHatch.mnDistance = nTmp32;
     145             : 
     146           0 :     return rIStm;
     147             : }
     148             : 
     149           0 : SvStream& operator<<( SvStream& rOStm, const ImplHatch& rImplHatch )
     150             : {
     151           0 :     VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
     152             : 
     153           0 :     rOStm << (sal_uInt16) rImplHatch.meStyle << rImplHatch.maColor;
     154             :     //#fdo39428 SvStream no longer supports operator<<(long)
     155           0 :     rOStm << sal::static_int_cast<sal_Int32>(rImplHatch.mnDistance) << rImplHatch.mnAngle;
     156             : 
     157           0 :     return rOStm;
     158             : }
     159             : 
     160           0 : SvStream& operator>>( SvStream& rIStm, Hatch& rHatch )
     161             : {
     162           0 :     rHatch.ImplMakeUnique();
     163           0 :     return( rIStm >> *rHatch.mpImplHatch );
     164             : }
     165             : 
     166           0 : SvStream& operator<<( SvStream& rOStm, const Hatch& rHatch )
     167             : {
     168           0 :     return( rOStm << *rHatch.mpImplHatch );
     169             : }
     170             : 
     171             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10