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  tools::Long nDistance, Degree10 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 
70 {
71  mpImplHatch->mnDistance = nDistance;
72 }
73 
74 void Hatch::SetAngle( Degree10 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  rHatch.mpImplHatch->mnDistance = nTmp32;
92  rIStm.ReadUInt16(nTmp16);
93  rHatch.mpImplHatch->mnAngle = Degree10(nTmp16);
94 
95  return rIStm;
96 }
97 
98 SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch )
99 {
100  VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
101 
102  rOStm.WriteUInt16( static_cast<sal_uInt16>(rHatch.mpImplHatch->meStyle) );
103 
104  tools::GenericTypeSerializer aSerializer(rOStm);
105  aSerializer.writeColor(rHatch.mpImplHatch->maColor);
106  rOStm.WriteInt32( rHatch.mpImplHatch->mnDistance ).WriteUInt16( rHatch.mpImplHatch->mnAngle.get() );
107 
108  return rOStm;
109 }
110 
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetDistance(tools::Long nDistance)
Definition: gdi/hatch.cxx:69
Degree10 mnAngle
Definition: hatch.hxx:39
Definition: hatch.hxx:46
SvStream & WriteHatch(SvStream &rOStm, const Hatch &rHatch)
Definition: gdi/hatch.cxx:98
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteInt32(sal_Int32 nInt32)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
long Long
tools::Long mnDistance
Definition: hatch.hxx:38
basegfx::BColor maColor
o3tl::cow_wrapper< ImplHatch > mpImplHatch
Definition: hatch.hxx:74
HatchStyle meStyle
Definition: hatch.hxx:37
Hatch & operator=(const Hatch &rHatch)
UNDERLYING_TYPE get() const
void SetAngle(Degree10 nAngle10)
Definition: gdi/hatch.cxx:74
Color maColor
Definition: hatch.hxx:36
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)
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
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
sal_Int32 mnAngle
HatchStyle
void readColor(Color &rColor)