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
27 meStyle ( HatchStyle::Single ),
28 mnDistance ( 1 ),
29 mnAngle ( 0 )
30{
31}
32
33bool 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
41Hatch::Hatch() = default;
42
43Hatch::Hatch( const Hatch& ) = default;
44
45Hatch::Hatch( HatchStyle eStyle, const Color& rColor,
46 tools::Long nDistance, Degree10 nAngle10 )
47{
48 mpImplHatch->maColor = rColor;
49 mpImplHatch->meStyle = eStyle;
50 mpImplHatch->mnDistance = nDistance;
51 mpImplHatch->mnAngle = nAngle10;
52}
53
54Hatch::~Hatch() = default;
55
56Hatch& Hatch::operator=( const Hatch& ) = default;
57
58bool Hatch::operator==( const Hatch& rHatch ) const
59{
60 return mpImplHatch == rHatch.mpImplHatch;
61}
62
63
64void Hatch::SetColor( const Color& rColor )
65{
66 mpImplHatch->maColor = rColor;
67}
68
70{
71 mpImplHatch->mnDistance = nDistance;
72}
73
74void Hatch::SetAngle( Degree10 nAngle10 )
75{
76 mpImplHatch->mnAngle = nAngle10;
77}
78
79SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch )
80{
81 VersionCompatRead aCompat(rIStm);
82
83 sal_uInt16 nTmpStyle(0);
84 rIStm.ReadUInt16(nTmpStyle);
85 rHatch.mpImplHatch->meStyle = static_cast<HatchStyle>(nTmpStyle);
86
87 tools::GenericTypeSerializer aSerializer(rIStm);
88 aSerializer.readColor(rHatch.mpImplHatch->maColor);
89
90 sal_Int32 nTmp32(0);
91 rIStm.ReadInt32(nTmp32);
92 rHatch.mpImplHatch->mnDistance = nTmp32;
93
94 sal_Int16 nTmpAngle(0);
95 rIStm.ReadInt16(nTmpAngle);
96 rHatch.mpImplHatch->mnAngle = Degree10(nTmpAngle);
97
98 return rIStm;
99}
100
101SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch )
102{
103 VersionCompatWrite aCompat(rOStm, 1);
104
105 rOStm.WriteUInt16( static_cast<sal_uInt16>(rHatch.mpImplHatch->meStyle) );
106
107 tools::GenericTypeSerializer aSerializer(rOStm);
108 aSerializer.writeColor(rHatch.mpImplHatch->maColor);
109 rOStm.WriteInt32( rHatch.mpImplHatch->mnDistance ).WriteInt16( rHatch.mpImplHatch->mnAngle.get() );
110
111 return rOStm;
112}
113
114/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
basegfx::BColor maColor
Definition: hatch.hxx:47
void SetAngle(Degree10 nAngle10)
Definition: gdi/hatch.cxx:74
Hatch & operator=(const Hatch &rHatch)
void SetColor(const Color &rColor)
Definition: gdi/hatch.cxx:64
bool operator==(const Hatch &rHatch) const
Definition: gdi/hatch.cxx:58
o3tl::cow_wrapper< ImplHatch > mpImplHatch
Definition: hatch.hxx:74
void SetDistance(tools::Long nDistance)
Definition: gdi/hatch.cxx:69
SvStream & WriteInt32(sal_Int32 nInt32)
SvStream & ReadInt16(sal_Int16 &rInt16)
SvStream & WriteInt16(sal_Int16 nInt16)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & ReadInt32(sal_Int32 &rInt32)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
void writeColor(const Color &rColor)
void readColor(Color &rColor)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
SvStream & ReadHatch(SvStream &rIStm, Hatch &rHatch)
Definition: gdi/hatch.cxx:79
SvStream & WriteHatch(SvStream &rOStm, const Hatch &rHatch)
Definition: gdi/hatch.cxx:101
HatchStyle
long Long
Color maColor
Definition: hatch.hxx:36
HatchStyle meStyle
Definition: hatch.hxx:37
tools::Long mnDistance
Definition: hatch.hxx:38
bool operator==(const ImplHatch &rImplHatch) const
Definition: gdi/hatch.cxx:33
Degree10 mnAngle
Definition: hatch.hxx:39
sal_Int32 mnAngle