1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * This file is part of the libvisio 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
10 #include "VSDStencils.h"
11
12 #include "libvisio_utils.h"
13
VSDShape()14 libvisio::VSDShape::VSDShape()
15 : m_geometries(), m_shapeList(), m_fields(), m_foreign(), m_parent(0), m_masterPage(MINUS_ONE),
16 m_masterShape(MINUS_ONE), m_shapeId(MINUS_ONE), m_lineStyleId(MINUS_ONE), m_fillStyleId(MINUS_ONE),
17 m_textStyleId(MINUS_ONE), m_lineStyle(), m_fillStyle(), m_textBlockStyle(), m_charStyle(),
18 m_charList(), m_paraStyle(), m_paraList(), m_tabSets(), m_text(), m_names(),
19 m_textFormat(libvisio::VSD_TEXT_UTF16), m_nurbsData(), m_polylineData(), m_xform(), m_txtxform(),
20 m_xform1d(), m_misc(), m_layerMem()
21 {
22 }
23
VSDShape(const libvisio::VSDShape & shape)24 libvisio::VSDShape::VSDShape(const libvisio::VSDShape &shape)
25 : m_geometries(shape.m_geometries), m_shapeList(shape.m_shapeList), m_fields(shape.m_fields),
26 m_foreign(shape.m_foreign ? new ForeignData(*(shape.m_foreign)) : nullptr), m_parent(shape.m_parent),
27 m_masterPage(shape.m_masterPage), m_masterShape(shape.m_masterShape), m_shapeId(shape.m_shapeId),
28 m_lineStyleId(shape.m_lineStyleId), m_fillStyleId(shape.m_fillStyleId), m_textStyleId(shape.m_textStyleId),
29 m_lineStyle(shape.m_lineStyle), m_fillStyle(shape.m_fillStyle), m_textBlockStyle(shape.m_textBlockStyle),
30 m_charStyle(shape.m_charStyle), m_charList(shape.m_charList), m_paraStyle(shape.m_paraStyle),
31 m_paraList(shape.m_paraList), m_tabSets(shape.m_tabSets), m_text(shape.m_text), m_names(shape.m_names),
32 m_textFormat(shape.m_textFormat), m_nurbsData(shape.m_nurbsData), m_polylineData(shape.m_polylineData),
33 m_xform(shape.m_xform), m_txtxform(shape.m_txtxform ? new XForm(*(shape.m_txtxform)) : nullptr),
34 m_xform1d(shape.m_xform1d ? new XForm1D(*(shape.m_xform1d)) : nullptr), m_misc(shape.m_misc),
35 m_layerMem(shape.m_layerMem)
36 {
37 }
38
~VSDShape()39 libvisio::VSDShape::~VSDShape()
40 {
41 clear();
42 }
43
operator =(const libvisio::VSDShape & shape)44 libvisio::VSDShape &libvisio::VSDShape::operator=(const libvisio::VSDShape &shape)
45 {
46 if (this != &shape)
47 {
48 m_geometries = shape.m_geometries;
49 m_shapeList = shape.m_shapeList;
50 m_fields = shape.m_fields;
51 m_foreign.reset(shape.m_foreign ? new ForeignData(*(shape.m_foreign)) : nullptr);
52 m_parent = shape.m_parent;
53 m_masterPage = shape.m_masterPage;
54 m_masterShape = shape.m_masterShape;
55 m_shapeId = shape.m_shapeId;
56 m_lineStyleId = shape.m_lineStyleId;
57 m_fillStyleId = shape.m_fillStyleId;
58 m_textStyleId = shape.m_textStyleId;
59 m_lineStyle = shape.m_lineStyle;
60 m_fillStyle = shape.m_fillStyle;
61 m_textBlockStyle = shape.m_textBlockStyle;
62 m_charStyle = shape.m_charStyle;
63 m_charList = shape.m_charList;
64 m_paraStyle = shape.m_paraStyle;
65 m_paraList = shape.m_paraList;
66 m_tabSets = shape.m_tabSets;
67 m_text = shape.m_text;
68 m_names = shape.m_names;
69 m_textFormat = shape.m_textFormat;
70 m_nurbsData = shape.m_nurbsData;
71 m_polylineData = shape.m_polylineData;
72 m_xform = shape.m_xform;
73 m_txtxform.reset(shape.m_txtxform ? new XForm(*(shape.m_txtxform)) : nullptr);
74 m_xform1d.reset(shape.m_xform1d ? new XForm1D(*shape.m_xform1d) : nullptr);
75 m_misc = shape.m_misc;
76 m_layerMem = shape.m_layerMem;
77 }
78 return *this;
79 }
80
clear()81 void libvisio::VSDShape::clear()
82 {
83 m_foreign = nullptr;
84 m_txtxform = nullptr;
85 m_xform1d = nullptr;
86
87 m_geometries.clear();
88 m_shapeList.clear();
89 m_fields.clear();
90 m_lineStyle = VSDOptionalLineStyle();
91 m_fillStyle = VSDOptionalFillStyle();
92 m_textBlockStyle = VSDOptionalTextBlockStyle();
93 m_charStyle = VSDOptionalCharStyle();
94 m_charList.clear();
95 m_paraStyle = VSDOptionalParaStyle();
96 m_paraList.clear();
97 m_tabSets.clear();
98 m_text.clear();
99 m_names.clear();
100 m_nurbsData.clear();
101 m_polylineData.clear();
102 m_xform = XForm();
103 m_parent = 0;
104 m_masterPage = MINUS_ONE;
105 m_masterShape = MINUS_ONE;
106 m_shapeId = MINUS_ONE;
107 m_lineStyleId = MINUS_ONE;
108 m_fillStyleId = MINUS_ONE;
109 m_textStyleId = MINUS_ONE;
110 m_textFormat = libvisio::VSD_TEXT_UTF16;
111 m_misc = VSDMisc();
112 m_layerMem = VSDName();
113 }
114
VSDStencil()115 libvisio::VSDStencil::VSDStencil()
116 : m_shapes(), m_shadowOffsetX(0.0), m_shadowOffsetY(0.0), m_firstShapeId(MINUS_ONE)
117 {
118 }
119
~VSDStencil()120 libvisio::VSDStencil::~VSDStencil()
121 {
122 }
123
addStencilShape(unsigned id,const VSDShape & shape)124 void libvisio::VSDStencil::addStencilShape(unsigned id, const VSDShape &shape)
125 {
126 m_shapes[id] = shape;
127 }
128
setFirstShape(unsigned id)129 void libvisio::VSDStencil::setFirstShape(unsigned id)
130 {
131 if (m_firstShapeId == MINUS_ONE)
132 m_firstShapeId = id;
133 }
134
getStencilShape(unsigned id) const135 const libvisio::VSDShape *libvisio::VSDStencil::getStencilShape(unsigned id) const
136 {
137 auto iter = m_shapes.find(id);
138 if (iter != m_shapes.end())
139 return &(iter->second);
140 else
141 return nullptr;
142 }
143
144
145
VSDStencils()146 libvisio::VSDStencils::VSDStencils() :
147 m_stencils()
148 {
149 }
150
~VSDStencils()151 libvisio::VSDStencils::~VSDStencils()
152 {
153 }
154
addStencil(unsigned idx,const libvisio::VSDStencil & stencil)155 void libvisio::VSDStencils::addStencil(unsigned idx, const libvisio::VSDStencil &stencil)
156 {
157 m_stencils[idx] = stencil;
158 }
159
getStencil(unsigned idx) const160 const libvisio::VSDStencil *libvisio::VSDStencils::getStencil(unsigned idx) const
161 {
162 auto iter = m_stencils.find(idx);
163 if (iter != m_stencils.end())
164 return &(iter->second);
165 else
166 return nullptr;
167 }
168
getStencilShape(unsigned pageId,unsigned shapeId) const169 const libvisio::VSDShape *libvisio::VSDStencils::getStencilShape(unsigned pageId, unsigned shapeId) const
170 {
171 if (MINUS_ONE == pageId)
172 return nullptr;
173 const libvisio::VSDStencil *tmpStencil = getStencil(pageId);
174 if (!tmpStencil)
175 return nullptr;
176 if (MINUS_ONE == shapeId)
177 shapeId = tmpStencil->m_firstShapeId;
178 return tmpStencil->getStencilShape(shapeId);
179 }
180
181 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
182