1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir #include <tools/stream.hxx> 27cdf0e10cSrcweir #include <tools/vcompat.hxx> 28cdf0e10cSrcweir #include <tools/debug.hxx> 29cdf0e10cSrcweir #ifndef _SV_HATCX_HXX 30cdf0e10cSrcweir #include <vcl/hatch.hxx> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir 33cdf0e10cSrcweir DBG_NAME( Hatch ) 34cdf0e10cSrcweir 35cdf0e10cSrcweir // -------------- 36cdf0e10cSrcweir // - ImplHatch - 37cdf0e10cSrcweir // -------------- 38cdf0e10cSrcweir 39cdf0e10cSrcweir ImplHatch::ImplHatch() : 40cdf0e10cSrcweir mnRefCount ( 1 ), 41cdf0e10cSrcweir maColor ( COL_BLACK ), 42cdf0e10cSrcweir meStyle ( HATCH_SINGLE ), 43cdf0e10cSrcweir mnDistance ( 1 ), 44cdf0e10cSrcweir mnAngle ( 0 ) 45cdf0e10cSrcweir { 46cdf0e10cSrcweir } 47cdf0e10cSrcweir 48cdf0e10cSrcweir // ----------------------------------------------------------------------- 49cdf0e10cSrcweir 50cdf0e10cSrcweir ImplHatch::ImplHatch( const ImplHatch& rImplHatch ) : 51cdf0e10cSrcweir mnRefCount ( 1 ), 52cdf0e10cSrcweir maColor ( rImplHatch.maColor ), 53cdf0e10cSrcweir meStyle ( rImplHatch.meStyle ), 54cdf0e10cSrcweir mnDistance ( rImplHatch.mnDistance ), 55cdf0e10cSrcweir mnAngle ( rImplHatch.mnAngle ) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir } 58cdf0e10cSrcweir 59cdf0e10cSrcweir // --------- 60cdf0e10cSrcweir // - Hatch - 61cdf0e10cSrcweir // --------- 62cdf0e10cSrcweir 63cdf0e10cSrcweir Hatch::Hatch() 64cdf0e10cSrcweir { 65cdf0e10cSrcweir DBG_CTOR( Hatch, NULL ); 66cdf0e10cSrcweir mpImplHatch = new ImplHatch; 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir // ----------------------------------------------------------------------- 70cdf0e10cSrcweir 71cdf0e10cSrcweir Hatch::Hatch( const Hatch& rHatch ) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir DBG_CTOR( Hatch, NULL ); 74cdf0e10cSrcweir DBG_CHKOBJ( &rHatch, Hatch, NULL ); 75cdf0e10cSrcweir mpImplHatch = rHatch.mpImplHatch; 76cdf0e10cSrcweir mpImplHatch->mnRefCount++; 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir // ----------------------------------------------------------------------- 80cdf0e10cSrcweir 81cdf0e10cSrcweir Hatch::Hatch( HatchStyle eStyle, const Color& rColor, 82cdf0e10cSrcweir long nDistance, sal_uInt16 nAngle10 ) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir DBG_CTOR( Hatch, NULL ); 85cdf0e10cSrcweir mpImplHatch = new ImplHatch; 86cdf0e10cSrcweir mpImplHatch->maColor = rColor; 87cdf0e10cSrcweir mpImplHatch->meStyle = eStyle; 88cdf0e10cSrcweir mpImplHatch->mnDistance = nDistance; 89cdf0e10cSrcweir mpImplHatch->mnAngle = nAngle10; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir // ----------------------------------------------------------------------- 93cdf0e10cSrcweir 94cdf0e10cSrcweir Hatch::~Hatch() 95cdf0e10cSrcweir { 96cdf0e10cSrcweir DBG_DTOR( Hatch, NULL ); 97cdf0e10cSrcweir if( !( --mpImplHatch->mnRefCount ) ) 98cdf0e10cSrcweir delete mpImplHatch; 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir // ----------------------------------------------------------------------- 102cdf0e10cSrcweir 103cdf0e10cSrcweir Hatch& Hatch::operator=( const Hatch& rHatch ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir DBG_CHKTHIS( Hatch, NULL ); 106cdf0e10cSrcweir DBG_CHKOBJ( &rHatch, Hatch, NULL ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir rHatch.mpImplHatch->mnRefCount++; 109cdf0e10cSrcweir 110cdf0e10cSrcweir if( !( --mpImplHatch->mnRefCount ) ) 111cdf0e10cSrcweir delete mpImplHatch; 112cdf0e10cSrcweir 113cdf0e10cSrcweir mpImplHatch = rHatch.mpImplHatch; 114cdf0e10cSrcweir return *this; 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir // ----------------------------------------------------------------------- 118cdf0e10cSrcweir 119cdf0e10cSrcweir sal_Bool Hatch::operator==( const Hatch& rHatch ) const 120cdf0e10cSrcweir { 121cdf0e10cSrcweir DBG_CHKTHIS( Hatch, NULL ); 122cdf0e10cSrcweir DBG_CHKOBJ( &rHatch, Hatch, NULL ); 123cdf0e10cSrcweir 124cdf0e10cSrcweir return( mpImplHatch == rHatch.mpImplHatch || 125cdf0e10cSrcweir ( mpImplHatch->maColor == rHatch.mpImplHatch->maColor && 126cdf0e10cSrcweir mpImplHatch->meStyle == rHatch.mpImplHatch->meStyle && 127cdf0e10cSrcweir mpImplHatch->mnDistance == rHatch.mpImplHatch->mnDistance && 128cdf0e10cSrcweir mpImplHatch->mnAngle == rHatch.mpImplHatch->mnAngle ) ); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir // ----------------------------------------------------------------------- 132cdf0e10cSrcweir 133cdf0e10cSrcweir void Hatch::ImplMakeUnique() 134cdf0e10cSrcweir { 135cdf0e10cSrcweir if( mpImplHatch->mnRefCount != 1 ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir if( mpImplHatch->mnRefCount ) 138cdf0e10cSrcweir mpImplHatch->mnRefCount--; 139cdf0e10cSrcweir 140cdf0e10cSrcweir mpImplHatch = new ImplHatch( *mpImplHatch ); 141cdf0e10cSrcweir } 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir // ----------------------------------------------------------------------- 145cdf0e10cSrcweir 146cdf0e10cSrcweir void Hatch::SetStyle( HatchStyle eStyle ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir DBG_CHKTHIS( Hatch, NULL ); 149cdf0e10cSrcweir ImplMakeUnique(); 150cdf0e10cSrcweir mpImplHatch->meStyle = eStyle; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir // ----------------------------------------------------------------------- 154cdf0e10cSrcweir 155cdf0e10cSrcweir void Hatch::SetColor( const Color& rColor ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir DBG_CHKTHIS( Hatch, NULL ); 158cdf0e10cSrcweir ImplMakeUnique(); 159cdf0e10cSrcweir mpImplHatch->maColor = rColor; 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir // ----------------------------------------------------------------------- 163cdf0e10cSrcweir 164cdf0e10cSrcweir void Hatch::SetDistance( long nDistance ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir DBG_CHKTHIS( Hatch, NULL ); 167cdf0e10cSrcweir ImplMakeUnique(); 168cdf0e10cSrcweir mpImplHatch->mnDistance = nDistance; 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir // ----------------------------------------------------------------------- 172cdf0e10cSrcweir 173cdf0e10cSrcweir void Hatch::SetAngle( sal_uInt16 nAngle10 ) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir DBG_CHKTHIS( Hatch, NULL ); 176cdf0e10cSrcweir ImplMakeUnique(); 177cdf0e10cSrcweir mpImplHatch->mnAngle = nAngle10; 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir // ----------------------------------------------------------------------- 181cdf0e10cSrcweir 182cdf0e10cSrcweir SvStream& operator>>( SvStream& rIStm, ImplHatch& rImplHatch ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir VersionCompat aCompat( rIStm, STREAM_READ ); 185cdf0e10cSrcweir sal_uInt16 nTmp16; 186cdf0e10cSrcweir 187cdf0e10cSrcweir rIStm >> nTmp16; rImplHatch.meStyle = (HatchStyle) nTmp16; 188cdf0e10cSrcweir rIStm >> rImplHatch.maColor >> rImplHatch.mnDistance >> rImplHatch.mnAngle; 189cdf0e10cSrcweir 190cdf0e10cSrcweir return rIStm; 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir // ----------------------------------------------------------------------- 194cdf0e10cSrcweir 195cdf0e10cSrcweir SvStream& operator<<( SvStream& rOStm, const ImplHatch& rImplHatch ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir VersionCompat aCompat( rOStm, STREAM_WRITE, 1 ); 198cdf0e10cSrcweir 199cdf0e10cSrcweir rOStm << (sal_uInt16) rImplHatch.meStyle << rImplHatch.maColor; 200cdf0e10cSrcweir rOStm << rImplHatch.mnDistance << rImplHatch.mnAngle; 201cdf0e10cSrcweir 202cdf0e10cSrcweir return rOStm; 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir // ----------------------------------------------------------------------- 206cdf0e10cSrcweir 207cdf0e10cSrcweir SvStream& operator>>( SvStream& rIStm, Hatch& rHatch ) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir rHatch.ImplMakeUnique(); 210cdf0e10cSrcweir return( rIStm >> *rHatch.mpImplHatch ); 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir // ----------------------------------------------------------------------- 214cdf0e10cSrcweir 215cdf0e10cSrcweir SvStream& operator<<( SvStream& rOStm, const Hatch& rHatch ) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir return( rOStm << *rHatch.mpImplHatch ); 218cdf0e10cSrcweir } 219