LCOV - code coverage report
Current view: top level - oox/source/drawingml/diagram - diagramlayoutatoms.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 73 8.2 %
Date: 2012-08-25 Functions: 4 51 7.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 28 14.3 %

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

Generated by: LCOV version 1.10