update emoji autocorrect entries from po-files
[LibreOffice.git] / vcl / source / gdi / hatch.cxx
bloba8df021002e54c34b6ce92dd751f5027f7598294
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <tools/stream.hxx>
21 #include <tools/vcompat.hxx>
22 #include <tools/debug.hxx>
23 #include <vcl/hatch.hxx>
25 ImplHatch::ImplHatch() :
26 mnRefCount ( 1 ),
27 maColor ( COL_BLACK ),
28 meStyle ( HATCH_SINGLE ),
29 mnDistance ( 1 ),
30 mnAngle ( 0 )
34 ImplHatch::ImplHatch( const ImplHatch& rImplHatch ) :
35 mnRefCount ( 1 ),
36 maColor ( rImplHatch.maColor ),
37 meStyle ( rImplHatch.meStyle ),
38 mnDistance ( rImplHatch.mnDistance ),
39 mnAngle ( rImplHatch.mnAngle )
43 Hatch::Hatch()
45 mpImplHatch = new ImplHatch;
48 Hatch::Hatch( const Hatch& rHatch )
50 mpImplHatch = rHatch.mpImplHatch;
51 mpImplHatch->mnRefCount++;
54 Hatch::Hatch( HatchStyle eStyle, const Color& rColor,
55 long nDistance, sal_uInt16 nAngle10 )
57 mpImplHatch = new ImplHatch;
58 mpImplHatch->maColor = rColor;
59 mpImplHatch->meStyle = eStyle;
60 mpImplHatch->mnDistance = nDistance;
61 mpImplHatch->mnAngle = nAngle10;
64 Hatch::~Hatch()
66 if( !( --mpImplHatch->mnRefCount ) )
67 delete mpImplHatch;
70 Hatch& Hatch::operator=( const Hatch& rHatch )
73 rHatch.mpImplHatch->mnRefCount++;
75 if( !( --mpImplHatch->mnRefCount ) )
76 delete mpImplHatch;
78 mpImplHatch = rHatch.mpImplHatch;
79 return *this;
82 bool Hatch::operator==( const Hatch& rHatch ) const
85 return( mpImplHatch == rHatch.mpImplHatch ||
86 ( mpImplHatch->maColor == rHatch.mpImplHatch->maColor &&
87 mpImplHatch->meStyle == rHatch.mpImplHatch->meStyle &&
88 mpImplHatch->mnDistance == rHatch.mpImplHatch->mnDistance &&
89 mpImplHatch->mnAngle == rHatch.mpImplHatch->mnAngle ) );
92 void Hatch::ImplMakeUnique()
94 if( mpImplHatch->mnRefCount != 1 )
96 if( mpImplHatch->mnRefCount )
97 mpImplHatch->mnRefCount--;
99 mpImplHatch = new ImplHatch( *mpImplHatch );
103 void Hatch::SetColor( const Color& rColor )
105 ImplMakeUnique();
106 mpImplHatch->maColor = rColor;
109 void Hatch::SetDistance( long nDistance )
111 ImplMakeUnique();
112 mpImplHatch->mnDistance = nDistance;
115 void Hatch::SetAngle( sal_uInt16 nAngle10 )
117 ImplMakeUnique();
118 mpImplHatch->mnAngle = nAngle10;
121 SvStream& ReadImplHatch( SvStream& rIStm, ImplHatch& rImplHatch )
123 VersionCompat aCompat( rIStm, StreamMode::READ );
124 sal_uInt16 nTmp16;
125 sal_Int32 nTmp32(0);
127 rIStm.ReadUInt16( nTmp16 ); rImplHatch.meStyle = (HatchStyle) nTmp16;
128 ReadColor( rIStm, rImplHatch.maColor ).ReadInt32( nTmp32 ).ReadUInt16( rImplHatch.mnAngle );
129 rImplHatch.mnDistance = nTmp32;
131 return rIStm;
134 SvStream& WriteImplHatch( SvStream& rOStm, const ImplHatch& rImplHatch )
136 VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
138 rOStm.WriteUInt16( rImplHatch.meStyle );
139 WriteColor( rOStm, rImplHatch.maColor );
140 rOStm.WriteInt32( rImplHatch.mnDistance ).WriteUInt16( rImplHatch.mnAngle );
142 return rOStm;
145 SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch )
147 rHatch.ImplMakeUnique();
148 return ReadImplHatch( rIStm, *rHatch.mpImplHatch );
151 SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch )
153 return WriteImplHatch( rOStm, *rHatch.mpImplHatch );
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */