LibreOffice Module vcl (master)  1
gdi/hatch.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <tools/stream.hxx>
21 #include <tools/vcompat.hxx>
23 #include <vcl/hatch.hxx>
24 
26  maColor ( COL_BLACK ),
27  meStyle ( HatchStyle::Single ),
28  mnDistance ( 1 ),
29  mnAngle ( 0 )
30 {
31 }
32 
33 bool ImplHatch::operator==( const ImplHatch& rImplHatch ) const
34 {
35  return maColor == rImplHatch.maColor &&
36  meStyle == rImplHatch.meStyle &&
37  mnDistance == rImplHatch.mnDistance &&
38  mnAngle == rImplHatch.mnAngle;
39 }
40 
41 Hatch::Hatch() = default;
42 
43 Hatch::Hatch( const Hatch& ) = default;
44 
45 Hatch::Hatch( HatchStyle eStyle, const Color& rColor,
46  long nDistance, sal_uInt16 nAngle10 ) : mpImplHatch()
47 {
48  mpImplHatch->maColor = rColor;
49  mpImplHatch->meStyle = eStyle;
50  mpImplHatch->mnDistance = nDistance;
51  mpImplHatch->mnAngle = nAngle10;
52 }
53 
54 Hatch::~Hatch() = default;
55 
56 Hatch& Hatch::operator=( const Hatch& ) = default;
57 
58 bool Hatch::operator==( const Hatch& rHatch ) const
59 {
60  return mpImplHatch == rHatch.mpImplHatch;
61 }
62 
63 
64 void Hatch::SetColor( const Color& rColor )
65 {
66  mpImplHatch->maColor = rColor;
67 }
68 
69 void Hatch::SetDistance( long nDistance )
70 {
71  mpImplHatch->mnDistance = nDistance;
72 }
73 
74 void Hatch::SetAngle( sal_uInt16 nAngle10 )
75 {
76  mpImplHatch->mnAngle = nAngle10;
77 }
78 
79 SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch )
80 {
81  VersionCompat aCompat(rIStm, StreamMode::READ);
82  sal_uInt16 nTmp16;
83  sal_Int32 nTmp32(0);
84 
85  rIStm.ReadUInt16(nTmp16);
86  rHatch.mpImplHatch->meStyle = static_cast<HatchStyle>(nTmp16);
87 
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;
93 
94  return rIStm;
95 }
96 
97 SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch )
98 {
99  VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
100 
101  rOStm.WriteUInt16( static_cast<sal_uInt16>(rHatch.mpImplHatch->meStyle) );
102 
103  tools::GenericTypeSerializer aSerializer(rOStm);
104  aSerializer.writeColor(rHatch.mpImplHatch->maColor);
105  rOStm.WriteInt32( rHatch.mpImplHatch->mnDistance ).WriteUInt16( rHatch.mpImplHatch->mnAngle );
106 
107  return rOStm;
108 }
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: hatch.hxx:44
SvStream & WriteHatch(SvStream &rOStm, const Hatch &rHatch)
Definition: gdi/hatch.cxx:97
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteInt32(sal_Int32 nInt32)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
o3tl::cow_wrapper< ImplHatch > mpImplHatch
Definition: hatch.hxx:72
HatchStyle meStyle
Definition: hatch.hxx:35
Hatch & operator=(const Hatch &rHatch)
sal_uInt16 mnAngle
Definition: hatch.hxx:37
void SetDistance(long nDistance)
Definition: gdi/hatch.cxx:69
Color maColor
Definition: hatch.hxx:34
bool operator==(const ImplHatch &rImplHatch) const
Definition: gdi/hatch.cxx:33
SvStream & ReadHatch(SvStream &rIStm, Hatch &rHatch)
Definition: gdi/hatch.cxx:79
SvStream & ReadInt32(sal_Int32 &rInt32)
void SetAngle(sal_uInt16 nAngle10)
Definition: gdi/hatch.cxx:74
long mnDistance
Definition: hatch.hxx:36
bool operator==(const Hatch &rHatch) const
Definition: gdi/hatch.cxx:58
void writeColor(const Color &rColor)
void SetColor(const Color &rColor)
Definition: gdi/hatch.cxx:64
HatchStyle
void readColor(Color &rColor)