1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 29 30 31 32 #ifndef OOX_DRAWINGML_DIAGRAMLAYOUTATOMS_HXX 33 #define OOX_DRAWINGML_DIAGRAMLAYOUTATOMS_HXX 34 35 #include <map> 36 #include <string> 37 38 #include <boost/shared_ptr.hpp> 39 #include <boost/array.hpp> 40 41 #include <com/sun/star/uno/Any.hxx> 42 #include <com/sun/star/xml/sax/XFastAttributeList.hpp> 43 44 #include "oox/drawingml/shape.hxx" 45 46 47 namespace oox { namespace drawingml { 48 49 50 // AG_IteratorAttributes 51 class IteratorAttr 52 { 53 public: 54 IteratorAttr(); 55 56 // not sure this belong here, but wth 57 void loadFromXAttr( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes ); 58 59 private: 60 sal_Int32 mnAxis; 61 sal_Int32 mnCnt; 62 sal_Bool mbHideLastTrans; 63 sal_Int32 mnPtType; 64 sal_Int32 mnSt; 65 sal_Int32 mnStep; 66 }; 67 68 class ConditionAttr 69 { 70 public: 71 ConditionAttr(); 72 73 // not sure this belong here, but wth 74 void loadFromXAttr( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes ); 75 76 private: 77 sal_Int32 mnFunc; 78 sal_Int32 mnArg; 79 sal_Int32 mnOp; 80 ::rtl::OUString msVal; 81 }; 82 83 class LayoutAtom; 84 85 typedef boost::shared_ptr< LayoutAtom > LayoutAtomPtr; 86 87 /** abstract Atom for the layout */ 88 class LayoutAtom 89 { 90 public: 91 virtual ~LayoutAtom() 92 {} 93 // TODO change signature to the proper one 94 virtual void processAtom() = 0; 95 void setName( const ::rtl::OUString & sName ) 96 { msName = sName; } 97 void addChild( const LayoutAtomPtr & pNode ) 98 { mpChildNodes.push_back( pNode ); } 99 100 // dump for debug 101 virtual void dump(int level = 0); 102 protected: 103 std::vector< LayoutAtomPtr > mpChildNodes; 104 ::rtl::OUString msName; 105 }; 106 107 class AlgAtom 108 : public LayoutAtom 109 { 110 public: 111 virtual ~AlgAtom() 112 {} 113 typedef std::map< std::string, ::com::sun::star::uno::Any > ParamMap; 114 115 virtual void processAtom() 116 {} 117 private: 118 ParamMap mParams; 119 }; 120 121 122 class ForEachAtom 123 : public LayoutAtom 124 { 125 public: 126 virtual ~ForEachAtom() 127 {} 128 129 IteratorAttr & iterator() 130 { return maIter; } 131 virtual void processAtom(); 132 private: 133 IteratorAttr maIter; 134 }; 135 136 typedef boost::shared_ptr< ForEachAtom > ForEachAtomPtr; 137 138 139 class ConditionAtom 140 : public LayoutAtom 141 { 142 public: 143 ConditionAtom( bool bElse = false ) 144 : LayoutAtom( ) 145 , mbElse( bElse ) 146 {} 147 virtual ~ConditionAtom() 148 {} 149 bool test(); 150 virtual void processAtom() 151 {} 152 IteratorAttr & iterator() 153 { return maIter; } 154 ConditionAttr & cond() 155 { return maCond; } 156 private: 157 bool mbElse; 158 IteratorAttr maIter; 159 ConditionAttr maCond; 160 }; 161 162 typedef boost::shared_ptr< ConditionAtom > ConditionAtomPtr; 163 164 165 /** "choose" statements. Atoms will be tested in order. */ 166 class ChooseAtom 167 : public LayoutAtom 168 { 169 public: 170 virtual ~ChooseAtom() 171 {} 172 virtual void processAtom(); 173 }; 174 175 class LayoutNode 176 : public LayoutAtom 177 { 178 public: 179 enum { 180 VAR_animLvl = 0, 181 VAR_animOne, 182 VAR_bulletEnabled, 183 VAR_chMax, 184 VAR_chPref, 185 VAR_dir, 186 VAR_hierBranch, 187 VAR_orgChart, 188 VAR_resizeHandles 189 }; 190 // we know that the array is of fixed size 191 // the use of Any allow having empty values 192 typedef boost::array< ::com::sun::star::uno::Any, 9 > VarMap; 193 194 virtual ~LayoutNode() 195 {} 196 virtual void processAtom() 197 {} 198 VarMap & variables() 199 { return mVariables; } 200 private: 201 VarMap mVariables; 202 std::vector< ShapePtr > mpShapes; 203 }; 204 205 typedef boost::shared_ptr< LayoutNode > LayoutNodePtr; 206 207 } } 208 209 #endif 210