bump product version to 7.2.5.1
[LibreOffice.git] / vcl / source / gdi / hatch.cxx
blob4adbd035fa52e0bc9231dc9a0e89ce37f3924fea
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/GenericTypeSerializer.hxx>
23 #include <vcl/hatch.hxx>
25 ImplHatch::ImplHatch() :
26 maColor ( COL_BLACK ),
27 meStyle ( HatchStyle::Single ),
28 mnDistance ( 1 ),
29 mnAngle ( 0 )
33 bool ImplHatch::operator==( const ImplHatch& rImplHatch ) const
35 return maColor == rImplHatch.maColor &&
36 meStyle == rImplHatch.meStyle &&
37 mnDistance == rImplHatch.mnDistance &&
38 mnAngle == rImplHatch.mnAngle;
41 Hatch::Hatch() = default;
43 Hatch::Hatch( const Hatch& ) = default;
45 Hatch::Hatch( HatchStyle eStyle, const Color& rColor,
46 tools::Long nDistance, Degree10 nAngle10 ) : mpImplHatch()
48 mpImplHatch->maColor = rColor;
49 mpImplHatch->meStyle = eStyle;
50 mpImplHatch->mnDistance = nDistance;
51 mpImplHatch->mnAngle = nAngle10;
54 Hatch::~Hatch() = default;
56 Hatch& Hatch::operator=( const Hatch& ) = default;
58 bool Hatch::operator==( const Hatch& rHatch ) const
60 return mpImplHatch == rHatch.mpImplHatch;
64 void Hatch::SetColor( const Color& rColor )
66 mpImplHatch->maColor = rColor;
69 void Hatch::SetDistance( tools::Long nDistance )
71 mpImplHatch->mnDistance = nDistance;
74 void Hatch::SetAngle( Degree10 nAngle10 )
76 mpImplHatch->mnAngle = nAngle10;
79 SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch )
81 VersionCompatRead aCompat(rIStm);
82 sal_uInt16 nTmp16;
83 sal_Int32 nTmp32(0);
85 rIStm.ReadUInt16(nTmp16);
86 rHatch.mpImplHatch->meStyle = static_cast<HatchStyle>(nTmp16);
88 tools::GenericTypeSerializer aSerializer(rIStm);
89 aSerializer.readColor(rHatch.mpImplHatch->maColor);
90 rIStm.ReadInt32(nTmp32);
91 rHatch.mpImplHatch->mnDistance = nTmp32;
92 rIStm.ReadUInt16(nTmp16);
93 rHatch.mpImplHatch->mnAngle = Degree10(nTmp16);
95 return rIStm;
98 SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch )
100 VersionCompatWrite aCompat(rOStm, 1);
102 rOStm.WriteUInt16( static_cast<sal_uInt16>(rHatch.mpImplHatch->meStyle) );
104 tools::GenericTypeSerializer aSerializer(rOStm);
105 aSerializer.writeColor(rHatch.mpImplHatch->maColor);
106 rOStm.WriteInt32( rHatch.mpImplHatch->mnDistance ).WriteUInt16( rHatch.mpImplHatch->mnAngle.get() );
108 return rOStm;
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */