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