Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / vcl / source / gdi / hatch.cxx
blob06b15f1bbf6d3431b0f9549ccbf727cda685965a
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 long nDistance, sal_uInt16 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( long nDistance )
71 mpImplHatch->mnDistance = nDistance;
74 void Hatch::SetAngle( sal_uInt16 nAngle10 )
76 mpImplHatch->mnAngle = nAngle10;
79 SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch )
81 VersionCompat aCompat(rIStm, StreamMode::READ);
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 rIStm.ReadUInt16(rHatch.mpImplHatch->mnAngle);
92 rHatch.mpImplHatch->mnDistance = nTmp32;
94 return rIStm;
97 SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch )
99 VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
101 rOStm.WriteUInt16( static_cast<sal_uInt16>(rHatch.mpImplHatch->meStyle) );
103 tools::GenericTypeSerializer aSerializer(rOStm);
104 aSerializer.writeColor(rHatch.mpImplHatch->maColor);
105 rOStm.WriteInt32( rHatch.mpImplHatch->mnDistance ).WriteUInt16( rHatch.mpImplHatch->mnAngle );
107 return rOStm;
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */