fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / drawingml / diagram / diagramlayoutatoms.hxx
blob6d57510d090c94def2a119e19b834c058ae78777
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_DIAGRAMLAYOUTATOMS_HXX
21 #define INCLUDED_OOX_SOURCE_DRAWINGML_DIAGRAM_DIAGRAMLAYOUTATOMS_HXX
23 #include <map>
24 #include <string>
26 #include <boost/shared_ptr.hpp>
27 #include <boost/array.hpp>
29 #include <com/sun/star/uno/Any.hxx>
30 #include <com/sun/star/xml/sax/XFastAttributeList.hpp>
32 #include "oox/drawingml/shape.hxx"
33 #include "diagram.hxx"
35 namespace oox { namespace drawingml {
37 class DiagramLayout;
38 typedef boost::shared_ptr< DiagramLayout > DiagramLayoutPtr;
40 // AG_IteratorAttributes
41 struct IteratorAttr
43 IteratorAttr();
45 // not sure this belong here, but wth
46 void loadFromXAttr( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes );
48 sal_Int32 mnAxis;
49 sal_Int32 mnCnt;
50 bool mbHideLastTrans;
51 sal_Int32 mnPtType;
52 sal_Int32 mnSt;
53 sal_Int32 mnStep;
56 struct ConditionAttr
58 ConditionAttr();
60 // not sure this belong here, but wth
61 void loadFromXAttr( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes );
63 sal_Int32 mnFunc;
64 sal_Int32 mnArg;
65 sal_Int32 mnOp;
66 OUString msVal;
69 struct LayoutAtomVisitor;
70 class LayoutAtom;
72 typedef boost::shared_ptr< LayoutAtom > LayoutAtomPtr;
74 /** abstract Atom for the layout */
75 class LayoutAtom
77 public:
78 virtual ~LayoutAtom() { }
80 /** visitor acceptance
82 virtual void accept( LayoutAtomVisitor& ) = 0;
84 void setName( const OUString& sName )
85 { msName = sName; }
86 const OUString& getName() const
87 { return msName; }
89 virtual void addChild( const LayoutAtomPtr & pNode )
90 { mpChildNodes.push_back( pNode ); }
91 virtual const std::vector<LayoutAtomPtr>& getChildren() const
92 { return mpChildNodes; }
94 // dump for debug
95 void dump(int level = 0);
96 protected:
97 std::vector< LayoutAtomPtr > mpChildNodes;
98 OUString msName;
101 class ConstraintAtom
102 : public LayoutAtom
104 public:
105 ConstraintAtom() :
106 mnFor(-1), msForName(), mnPointType(-1), mnType(-1), mnRefFor(-1), msRefForName(),
107 mnRefType(-1), mnRefPointType(-1), mfFactor(1.0), mfValue(0.0), mnOperator(0)
110 virtual ~ConstraintAtom() { }
112 virtual void accept( LayoutAtomVisitor& ) SAL_OVERRIDE;
114 void setFor( sal_Int32 nToken )
115 { mnFor = nToken; }
116 void setForName( const OUString & sName )
117 { msForName = sName; }
118 void setPointType( sal_Int32 nToken )
119 { mnPointType = nToken; }
120 void setType( sal_Int32 nToken )
121 { mnType = nToken; }
122 void setRefFor( sal_Int32 nToken )
123 { mnRefFor = nToken; }
124 void setRefForName( const OUString & sName )
125 { msRefForName = sName; }
126 void setRefType( sal_Int32 nToken )
127 { mnRefType = nToken; }
128 void setRefPointType( sal_Int32 nToken )
129 { mnRefPointType = nToken; }
130 void setFactor( const double& fVal )
131 { mfFactor = fVal; }
132 void setValue( const double& fVal )
133 { mfValue = fVal; }
134 void setOperator( sal_Int32 nToken )
135 { mnOperator = nToken; }
136 private:
137 sal_Int32 mnFor;
138 OUString msForName;
139 sal_Int32 mnPointType;
140 sal_Int32 mnType;
141 sal_Int32 mnRefFor;
142 OUString msRefForName;
143 sal_Int32 mnRefType;
144 sal_Int32 mnRefPointType;
145 double mfFactor;
146 double mfValue;
147 sal_Int32 mnOperator;
150 typedef boost::shared_ptr< ConstraintAtom > ConstraintAtomPtr;
152 class AlgAtom
153 : public LayoutAtom
155 public:
156 AlgAtom() : mnType(0), maMap() {}
158 virtual ~AlgAtom() { }
160 typedef std::map<sal_Int32,sal_Int32> ParamMap;
162 virtual void accept( LayoutAtomVisitor& ) SAL_OVERRIDE;
164 void setType( sal_Int32 nToken )
165 { mnType = nToken; }
166 void addParam( sal_Int32 nType, sal_Int32 nVal )
167 { maMap[nType]=nVal; }
168 void layoutShape( const ShapePtr& rShape,
169 const Diagram& rDgm,
170 const OUString& rName ) const;
171 private:
172 sal_Int32 mnType;
173 ParamMap maMap;
176 typedef boost::shared_ptr< AlgAtom > AlgAtomPtr;
178 class ForEachAtom
179 : public LayoutAtom
181 public:
182 explicit ForEachAtom(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes);
184 virtual ~ForEachAtom() { }
186 IteratorAttr & iterator()
187 { return maIter; }
188 virtual void accept( LayoutAtomVisitor& ) SAL_OVERRIDE;
190 private:
191 IteratorAttr maIter;
194 typedef boost::shared_ptr< ForEachAtom > ForEachAtomPtr;
196 class ConditionAtom
197 : public LayoutAtom
199 public:
200 explicit ConditionAtom(const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes);
201 virtual ~ConditionAtom()
203 bool test();
204 virtual void accept( LayoutAtomVisitor& ) SAL_OVERRIDE;
205 IteratorAttr & iterator()
206 { return maIter; }
207 ConditionAttr & cond()
208 { return maCond; }
209 void readElseBranch()
210 { mbElse=true; }
211 virtual void addChild( const LayoutAtomPtr & pNode ) SAL_OVERRIDE;
212 virtual const std::vector<LayoutAtomPtr>& getChildren() const SAL_OVERRIDE;
213 private:
214 bool mbElse;
215 IteratorAttr maIter;
216 ConditionAttr maCond;
217 std::vector< LayoutAtomPtr > mpElseChildNodes;
220 typedef boost::shared_ptr< ConditionAtom > ConditionAtomPtr;
222 /** "choose" statements. Atoms will be tested in order. */
223 class ChooseAtom
224 : public LayoutAtom
226 public:
227 virtual ~ChooseAtom()
229 virtual void accept( LayoutAtomVisitor& ) SAL_OVERRIDE;
232 class LayoutNode
233 : public LayoutAtom
235 public:
236 enum {
237 VAR_animLvl = 0,
238 VAR_animOne,
239 VAR_bulletEnabled,
240 VAR_chMax,
241 VAR_chPref,
242 VAR_dir,
243 VAR_hierBranch,
244 VAR_orgChart,
245 VAR_resizeHandles
247 // we know that the array is of fixed size
248 // the use of Any allow having empty values
249 typedef boost::array< ::com::sun::star::uno::Any, 9 > VarMap;
251 LayoutNode() : mnChildOrder(0) {}
252 virtual ~LayoutNode() { }
253 virtual void accept( LayoutAtomVisitor& ) SAL_OVERRIDE;
254 VarMap & variables()
255 { return mVariables; }
256 void setMoveWith( const OUString & sName )
257 { msMoveWith = sName; }
258 void setStyleLabel( const OUString & sLabel )
259 { msStyleLabel = sLabel; }
260 void setChildOrder( sal_Int32 nOrder )
261 { mnChildOrder = nOrder; }
262 void setShape( const ShapePtr& pShape )
263 { mpShape = pShape; }
264 const ShapePtr& getShape() const
265 { return mpShape; }
267 bool setupShape( const ShapePtr& rShape,
268 const Diagram& rDgm,
269 sal_uInt32 nIdx ) const;
271 private:
272 VarMap mVariables;
273 OUString msMoveWith;
274 OUString msStyleLabel;
275 ShapePtr mpShape;
276 sal_Int32 mnChildOrder;
279 typedef boost::shared_ptr< LayoutNode > LayoutNodePtr;
281 struct LayoutAtomVisitor
283 virtual ~LayoutAtomVisitor() {}
284 virtual void visit(ConstraintAtom& rAtom) = 0;
285 virtual void visit(AlgAtom& rAtom) = 0;
286 virtual void visit(ForEachAtom& rAtom) = 0;
287 virtual void visit(ConditionAtom& rAtom) = 0;
288 virtual void visit(ChooseAtom& rAtom) = 0;
289 virtual void visit(LayoutNode& rAtom) = 0;
292 class ShapeCreationVisitor : public LayoutAtomVisitor
294 ShapePtr mpParentShape;
295 const Diagram& mrDgm;
296 sal_Int32 mnCurrIdx;
298 void defaultVisit(LayoutAtom& rAtom);
299 virtual void visit(ConstraintAtom& rAtom) SAL_OVERRIDE;
300 virtual void visit(AlgAtom& rAtom) SAL_OVERRIDE;
301 virtual void visit(ForEachAtom& rAtom) SAL_OVERRIDE;
302 virtual void visit(ConditionAtom& rAtom) SAL_OVERRIDE;
303 virtual void visit(ChooseAtom& rAtom) SAL_OVERRIDE;
304 virtual void visit(LayoutNode& rAtom) SAL_OVERRIDE;
306 public:
307 ShapeCreationVisitor(const ShapePtr& rParentShape,
308 const Diagram& rDgm) :
309 mpParentShape(rParentShape),
310 mrDgm(rDgm),
311 mnCurrIdx(0)
317 #endif
319 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */