1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_DIAGRAMLAYOUTATOMS_HXX
#define INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_DIAGRAMLAYOUTATOMS_HXX
#include <map>
#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/array.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/xml/sax/XFastAttributeList.hpp>
#include "oox/drawingml/shape.hxx"
#include "diagram.hxx"
namespace oox { namespace drawingml {
class DiagramLayout;
typedef boost::shared_ptr< DiagramLayout > DiagramLayoutPtr;
// AG_IteratorAttributes
struct IteratorAttr
{
IteratorAttr();
// not sure this belong here, but wth
void loadFromXAttr( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes );
sal_Int32 mnAxis;
sal_Int32 mnCnt;
sal_Bool mbHideLastTrans;
sal_Int32 mnPtType;
sal_Int32 mnSt;
sal_Int32 mnStep;
};
struct ConditionAttr
{
ConditionAttr();
// not sure this belong here, but wth
void loadFromXAttr( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes );
sal_Int32 mnFunc;
sal_Int32 mnArg;
sal_Int32 mnOp;
OUString msVal;
};
struct LayoutAtomVisitor;
class LayoutAtom;
typedef boost::shared_ptr< LayoutAtom > LayoutAtomPtr;
/** abstract Atom for the layout */
class LayoutAtom
{
public:
virtual ~LayoutAtom() { }
/** visitor acceptance
*/
virtual void accept( LayoutAtomVisitor& ) = 0;
void setName( const OUString& sName )
{ msName = sName; }
const OUString& getName() const
{ return msName; }
virtual void addChild( const LayoutAtomPtr & pNode )
{ mpChildNodes.push_back( pNode ); }
virtual const std::vector<LayoutAtomPtr>& getChildren() const
{ return mpChildNodes; }
// dump for debug
void dump(int level = 0);
protected:
std::vector< LayoutAtomPtr > mpChildNodes;
OUString msName;
};
class ConstraintAtom
: public LayoutAtom
{
public:
ConstraintAtom() :
mnFor(-1), msForName(), mnPointType(-1), mnType(-1), mnRefFor(-1), msRefForName(),
mnRefType(-1), mnRefPointType(-1), mfFactor(1.0), mfValue(0.0), mnOperator(0)
{}
virtual ~ConstraintAtom() { }
virtual void accept( LayoutAtomVisitor& );
void setFor( sal_Int32 nToken )
{ mnFor = nToken; }
void setForName( const OUString & sName )
{ msForName = sName; }
void setPointType( sal_Int32 nToken )
{ mnPointType = nToken; }
void setType( sal_Int32 nToken )
{ mnType = nToken; }
void setRefFor( sal_Int32 nToken )
{ mnRefFor = nToken; }
void setRefForName( const OUString & sName )
{ msRefForName = sName; }
void setRefType( sal_Int32 nToken )
{ mnRefType = nToken; }
void setRefPointType( sal_Int32 nToken )
{ mnRefPointType = nToken; }
void setFactor( const double& fVal )
{ mfFactor = fVal; }
void setValue( const double& fVal )
{ mfValue = fVal; }
void setOperator( sal_Int32 nToken )
{ mnOperator = nToken; }
private:
sal_Int32 mnFor;
OUString msForName;
sal_Int32 mnPointType;
sal_Int32 mnType;
sal_Int32 mnRefFor;
OUString msRefForName;
sal_Int32 mnRefType;
sal_Int32 mnRefPointType;
double mfFactor;
double mfValue;
sal_Int32 mnOperator;
};
typedef boost::shared_ptr< ConstraintAtom > ConstraintAtomPtr;
class AlgAtom
: public LayoutAtom
{
public:
AlgAtom() : mnType(0), maMap() {}
virtual ~AlgAtom() { }
typedef std::map<sal_Int32,sal_Int32> ParamMap;
virtual void accept( LayoutAtomVisitor& );
void setType( sal_Int32 nToken )
{ mnType = nToken; }
void addParam( sal_Int32 nType, sal_Int32 nVal )
{ maMap[nType]=nVal; }
void layoutShape( const ShapePtr& rShape,
const Diagram& rDgm,
const OUString& rName ) const;
private:
sal_Int32 mnType;
ParamMap maMap;
};
typedef boost::shared_ptr< AlgAtom > AlgAtomPtr;
class ForEachAtom
: public LayoutAtom
{
public:
explicit ForEachAtom(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes);
virtual ~ForEachAtom() { }
IteratorAttr & iterator()
{ return maIter; }
virtual void accept( LayoutAtomVisitor& );
private:
IteratorAttr maIter;
};
typedef boost::shared_ptr< ForEachAtom > ForEachAtomPtr;
class ConditionAtom
: public LayoutAtom
{
public:
explicit ConditionAtom(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes);
virtual ~ConditionAtom()
{ }
bool test();
virtual void accept( LayoutAtomVisitor& );
IteratorAttr & iterator()
{ return maIter; }
ConditionAttr & cond()
{ return maCond; }
void readElseBranch()
{ mbElse=true; }
virtual void addChild( const LayoutAtomPtr & pNode );
virtual const std::vector<LayoutAtomPtr>& getChildren() const;
private:
bool mbElse;
IteratorAttr maIter;
ConditionAttr maCond;
std::vector< LayoutAtomPtr > mpElseChildNodes;
};
typedef boost::shared_ptr< ConditionAtom > ConditionAtomPtr;
/** "choose" statements. Atoms will be tested in order. */
class ChooseAtom
: public LayoutAtom
{
public:
virtual ~ChooseAtom()
{ }
virtual void accept( LayoutAtomVisitor& );
};
class LayoutNode
: public LayoutAtom
{
public:
enum {
VAR_animLvl = 0,
VAR_animOne,
VAR_bulletEnabled,
VAR_chMax,
VAR_chPref,
VAR_dir,
VAR_hierBranch,
VAR_orgChart,
VAR_resizeHandles
};
// we know that the array is of fixed size
// the use of Any allow having empty values
typedef boost::array< ::com::sun::star::uno::Any, 9 > VarMap;
LayoutNode() : mnChildOrder(0) {}
virtual ~LayoutNode() { }
virtual void accept( LayoutAtomVisitor& );
VarMap & variables()
{ return mVariables; }
void setMoveWith( const OUString & sName )
{ msMoveWith = sName; }
void setStyleLabel( const OUString & sLabel )
{ msStyleLabel = sLabel; }
void setChildOrder( sal_Int32 nOrder )
{ mnChildOrder = nOrder; }
void setShape( const ShapePtr& pShape )
{ mpShape = pShape; }
const ShapePtr& getShape() const
{ return mpShape; }
bool setupShape( const ShapePtr& rShape,
const Diagram& rDgm,
sal_uInt32 nIdx ) const;
private:
VarMap mVariables;
OUString msMoveWith;
OUString msStyleLabel;
ShapePtr mpShape;
sal_Int32 mnChildOrder;
};
typedef boost::shared_ptr< LayoutNode > LayoutNodePtr;
struct LayoutAtomVisitor
{
virtual ~LayoutAtomVisitor() {}
virtual void visit(ConstraintAtom& rAtom) = 0;
virtual void visit(AlgAtom& rAtom) = 0;
virtual void visit(ForEachAtom& rAtom) = 0;
virtual void visit(ConditionAtom& rAtom) = 0;
virtual void visit(ChooseAtom& rAtom) = 0;
virtual void visit(LayoutNode& rAtom) = 0;
};
class ShapeCreationVisitor : public LayoutAtomVisitor
{
ShapePtr mpParentShape;
const Diagram& mrDgm;
sal_Int32 mnCurrIdx;
void defaultVisit(LayoutAtom& rAtom);
virtual void visit(ConstraintAtom& rAtom);
virtual void visit(AlgAtom& rAtom);
virtual void visit(ForEachAtom& rAtom);
virtual void visit(ConditionAtom& rAtom);
virtual void visit(ChooseAtom& rAtom);
virtual void visit(LayoutNode& rAtom);
public:
ShapeCreationVisitor(const ShapePtr& rParentShape,
const Diagram& rDgm) :
mpParentShape(rParentShape),
mrDgm(rDgm),
mnCurrIdx(0)
{}
};
} }
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|