Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / vcl / source / gdi / hatch.cxx
blobf0f822cbf01a74a44d6f6bee25dd21f1ff7184b8
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 <vcl/hatch.hxx>
24 ImplHatch::ImplHatch() :
25 maColor ( COL_BLACK ),
26 meStyle ( HatchStyle::Single ),
27 mnDistance ( 1 ),
28 mnAngle ( 0 )
32 ImplHatch::ImplHatch( const ImplHatch& rImplHatch ) :
33 maColor ( rImplHatch.maColor ),
34 meStyle ( rImplHatch.meStyle ),
35 mnDistance ( rImplHatch.mnDistance ),
36 mnAngle ( rImplHatch.mnAngle )
40 bool ImplHatch::operator==( const ImplHatch& rImplHatch ) const
42 return maColor == rImplHatch.maColor &&
43 meStyle == rImplHatch.meStyle &&
44 mnDistance == rImplHatch.mnDistance &&
45 mnAngle == rImplHatch.mnAngle;
48 Hatch::Hatch() : mpImplHatch()
52 Hatch::Hatch( const Hatch& rHatch ) : mpImplHatch( rHatch.mpImplHatch )
56 Hatch::Hatch( HatchStyle eStyle, const Color& rColor,
57 long nDistance, sal_uInt16 nAngle10 ) : mpImplHatch()
59 mpImplHatch->maColor = rColor;
60 mpImplHatch->meStyle = eStyle;
61 mpImplHatch->mnDistance = nDistance;
62 mpImplHatch->mnAngle = nAngle10;
65 Hatch::~Hatch()
69 Hatch& Hatch::operator=( const Hatch& rHatch )
71 mpImplHatch = rHatch.mpImplHatch;
72 return *this;
75 bool Hatch::operator==( const Hatch& rHatch ) const
77 return mpImplHatch == rHatch.mpImplHatch;
81 void Hatch::SetColor( const Color& rColor )
83 mpImplHatch->maColor = rColor;
86 void Hatch::SetDistance( long nDistance )
88 mpImplHatch->mnDistance = nDistance;
91 void Hatch::SetAngle( sal_uInt16 nAngle10 )
93 mpImplHatch->mnAngle = nAngle10;
96 SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch )
98 VersionCompat aCompat( rIStm, StreamMode::READ );
99 sal_uInt16 nTmp16;
100 sal_Int32 nTmp32(0);
102 rIStm.ReadUInt16( nTmp16 ); rHatch.mpImplHatch->meStyle = (HatchStyle) nTmp16;
103 ReadColor( rIStm, rHatch.mpImplHatch->maColor ).ReadInt32( nTmp32 ).ReadUInt16(
104 rHatch.mpImplHatch->mnAngle );
105 rHatch.mpImplHatch->mnDistance = nTmp32;
107 return rIStm;
110 SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch )
112 VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
114 rOStm.WriteUInt16( (sal_uInt16)rHatch.mpImplHatch->meStyle );
115 WriteColor( rOStm, rHatch.mpImplHatch->maColor );
116 rOStm.WriteInt32( rHatch.mpImplHatch->mnDistance ).WriteUInt16( rHatch.mpImplHatch->mnAngle );
118 return rOStm;
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */