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

Generated by: LCOV version 1.10