1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 
25 
26 
27 
28 #ifndef OOX_DRAWINGML_DIAGRAMLAYOUTATOMS_HXX
29 #define OOX_DRAWINGML_DIAGRAMLAYOUTATOMS_HXX
30 
31 #include <map>
32 #include <string>
33 
34 #include <boost/shared_ptr.hpp>
35 #include <boost/array.hpp>
36 
37 #include <com/sun/star/uno/Any.hxx>
38 #include <com/sun/star/xml/sax/XFastAttributeList.hpp>
39 
40 #include "oox/drawingml/shape.hxx"
41 
42 
43 namespace oox { namespace drawingml {
44 
45 
46 // AG_IteratorAttributes
47 class IteratorAttr
48 {
49 public:
50 	IteratorAttr();
51 
52 	// not sure this belong here, but wth
53 	void loadFromXAttr( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes );
54 
55 private:
56 	sal_Int32 mnAxis;
57 	sal_Int32 mnCnt;
58 	sal_Bool  mbHideLastTrans;
59 	sal_Int32 mnPtType;
60 	sal_Int32 mnSt;
61 	sal_Int32 mnStep;
62 };
63 
64 class ConditionAttr
65 {
66 public:
67 	ConditionAttr();
68 
69 	// not sure this belong here, but wth
70 	void loadFromXAttr( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes );
71 
72 private:
73 	sal_Int32 mnFunc;
74 	sal_Int32 mnArg;
75 	sal_Int32 mnOp;
76 	::rtl::OUString msVal;
77 };
78 
79 class LayoutAtom;
80 
81 typedef boost::shared_ptr< LayoutAtom > LayoutAtomPtr;
82 
83 /** abstract Atom for the layout */
84 class LayoutAtom
85 {
86 public:
~LayoutAtom()87 	virtual ~LayoutAtom()
88 		{}
89 	// TODO change signature to the proper one
90 	virtual void processAtom() = 0;
setName(const::rtl::OUString & sName)91 	void setName( const ::rtl::OUString & sName )
92 		{ msName = sName; }
addChild(const LayoutAtomPtr & pNode)93 	void addChild( const LayoutAtomPtr & pNode )
94 		{ mpChildNodes.push_back( pNode ); }
95 
96 	// dump for debug
97 	virtual void dump(int level = 0);
98 protected:
99 	std::vector< LayoutAtomPtr > mpChildNodes;
100 	::rtl::OUString msName;
101 };
102 
103 class AlgAtom
104 	: public LayoutAtom
105 {
106 public:
~AlgAtom()107 	virtual ~AlgAtom()
108 		{}
109 	typedef std::map< std::string, ::com::sun::star::uno::Any > ParamMap;
110 
processAtom()111 	virtual void processAtom()
112 		{}
113 private:
114 	ParamMap mParams;
115 };
116 
117 
118 class ForEachAtom
119 	: public LayoutAtom
120 {
121 public:
~ForEachAtom()122 	virtual ~ForEachAtom()
123 		{}
124 
iterator()125 	IteratorAttr & iterator()
126 		{ return maIter; }
127 	virtual void processAtom();
128 private:
129 	IteratorAttr maIter;
130 };
131 
132 typedef boost::shared_ptr< ForEachAtom > ForEachAtomPtr;
133 
134 
135 class ConditionAtom
136 	: public LayoutAtom
137 {
138 public:
ConditionAtom(bool bElse=false)139 	ConditionAtom( bool bElse = false )
140 		: LayoutAtom( )
141 		, mbElse( bElse )
142 		{}
~ConditionAtom()143 	virtual ~ConditionAtom()
144 		{}
145 	bool test();
processAtom()146 	virtual void processAtom()
147 		{}
iterator()148 	IteratorAttr & iterator()
149 		{ return maIter; }
cond()150 	ConditionAttr & cond()
151 		{ return maCond; }
152 private:
153 	bool          mbElse;
154 	IteratorAttr  maIter;
155 	ConditionAttr maCond;
156 };
157 
158 typedef boost::shared_ptr< ConditionAtom > ConditionAtomPtr;
159 
160 
161 /** "choose" statements. Atoms will be tested in order. */
162 class ChooseAtom
163 	: public LayoutAtom
164 {
165 public:
~ChooseAtom()166 	virtual ~ChooseAtom()
167 		{}
168 	virtual void processAtom();
169 };
170 
171 class LayoutNode
172 	: public LayoutAtom
173 {
174 public:
175 	enum {
176 		VAR_animLvl = 0,
177 		VAR_animOne,
178 		VAR_bulletEnabled,
179 		VAR_chMax,
180 		VAR_chPref,
181 		VAR_dir,
182 		VAR_hierBranch,
183 		VAR_orgChart,
184 		VAR_resizeHandles
185 	};
186 	// we know that the array is of fixed size
187 	// the use of Any allow having empty values
188 	typedef boost::array< ::com::sun::star::uno::Any, 9 > VarMap;
189 
~LayoutNode()190 	virtual ~LayoutNode()
191 		{}
processAtom()192 	virtual void processAtom()
193 		{}
variables()194 	VarMap & variables()
195 		{ return mVariables; }
196 private:
197 	VarMap                       mVariables;
198 	std::vector< ShapePtr >      mpShapes;
199 };
200 
201 typedef boost::shared_ptr< LayoutNode > LayoutNodePtr;
202 
203 } }
204 
205 #endif
206