LCOV - code coverage report
Current view: top level - oox/source/drawingml/diagram - layoutnodecontext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 148 0.7 %
Date: 2012-08-25 Functions: 2 26 7.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 346 0.6 %

           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                 :            : #include "layoutnodecontext.hxx"
      21                 :            : 
      22                 :            : #include "oox/helper/attributelist.hxx"
      23                 :            : #include "oox/drawingml/diagram/diagram.hxx"
      24                 :            : #include "oox/drawingml/shapecontext.hxx"
      25                 :            : #include "oox/drawingml/customshapeproperties.hxx"
      26                 :            : #include "diagramdefinitioncontext.hxx"
      27                 :            : #include "constraintlistcontext.hxx"
      28                 :            : 
      29                 :            : using namespace ::oox::core;
      30                 :            : using namespace ::com::sun::star::uno;
      31                 :            : using namespace ::com::sun::star::xml::sax;
      32                 :            : using ::rtl::OUString;
      33                 :            : 
      34                 :            : namespace oox { namespace drawingml {
      35                 :            : 
      36         [ #  # ]:          0 : class IfContext
      37                 :            :     : public LayoutNodeContext
      38                 :            : {
      39                 :            : public:
      40                 :          0 :     IfContext( ContextHandler& rParent,
      41                 :            :                const Reference< XFastAttributeList >& xAttribs,
      42                 :            :                const ConditionAtomPtr& pAtom )
      43 [ #  # ][ #  # ]:          0 :         : LayoutNodeContext( rParent, xAttribs, pAtom )
                 [ #  # ]
      44                 :          0 :     {}
      45                 :            : };
      46                 :            : 
      47                 :            : 
      48                 :            : 
      49 [ #  # ][ #  # ]:          0 : class AlgorithmContext
      50                 :            :     : public ContextHandler
      51                 :            : {
      52                 :            : public:
      53                 :          0 :     AlgorithmContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, const AlgAtomPtr & pNode )
      54                 :            :         : ContextHandler( rParent )
      55                 :            :         , mnRevision( 0 )
      56         [ #  # ]:          0 :         , mpNode( pNode )
      57                 :            :         {
      58         [ #  # ]:          0 :             AttributeList aAttribs( xAttribs );
      59         [ #  # ]:          0 :             mnRevision = aAttribs.getInteger( XML_rev, 0 );
      60 [ #  # ][ #  # ]:          0 :             pNode->setType(xAttribs->getOptionalValueToken(XML_type, 0));
                 [ #  # ]
      61                 :          0 :         }
      62                 :            : 
      63                 :            :     virtual Reference< XFastContextHandler > SAL_CALL
      64                 :          0 :     createFastChildContext( ::sal_Int32 aElement,
      65                 :            :                             const Reference< XFastAttributeList >& xAttribs )
      66                 :            :         throw (SAXException, RuntimeException)
      67                 :            :         {
      68                 :          0 :             Reference< XFastContextHandler > xRet;
      69                 :            : 
      70         [ #  # ]:          0 :             switch( aElement )
      71                 :            :             {
      72                 :            :                 case DGM_TOKEN( param ):
      73                 :            :                 {
      74         [ #  # ]:          0 :                     AttributeList aAttribs( xAttribs );
      75         [ #  # ]:          0 :                     const sal_Int32 nValTok=aAttribs.getToken( XML_val, 0 );
      76                 :            :                     mpNode->addParam(
      77                 :            :                         aAttribs.getToken( XML_type, 0 ),
      78 [ #  # ][ #  # ]:          0 :                         nValTok>0 ? nValTok : aAttribs.getInteger( XML_val, 0 ) );
         [ #  # ][ #  # ]
      79         [ #  # ]:          0 :                     break;
      80                 :            :                 }
      81                 :            :                 default:
      82                 :          0 :                     break;
      83                 :            :             }
      84                 :            : 
      85         [ #  # ]:          0 :             if( !xRet.is() )
      86         [ #  # ]:          0 :                 xRet.set(this);
      87                 :            : 
      88                 :          0 :             return xRet;
      89                 :            :         }
      90                 :            : 
      91                 :            : private:
      92                 :            :     sal_Int32  mnRevision;
      93                 :            :     AlgAtomPtr mpNode;
      94                 :            : };
      95                 :            : 
      96                 :            : 
      97 [ #  # ][ #  # ]:          0 : class ChooseContext
                 [ #  # ]
      98                 :            :     : public ContextHandler
      99                 :            : {
     100                 :            : public:
     101                 :          0 :     ChooseContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, const LayoutAtomPtr & pNode )
     102                 :            :         : ContextHandler( rParent )
     103 [ #  # ][ #  # ]:          0 :         , mpNode( pNode )
     104                 :            :         {
     105 [ #  # ][ #  # ]:          0 :             msName = xAttribs->getOptionalValue( XML_name );
     106                 :          0 :         }
     107                 :            : 
     108                 :            :     virtual Reference< XFastContextHandler > SAL_CALL
     109                 :          0 :     createFastChildContext( ::sal_Int32 aElement,
     110                 :            :                             const Reference< XFastAttributeList >& xAttribs )
     111                 :            :         throw (SAXException, RuntimeException)
     112                 :            :         {
     113                 :          0 :             Reference< XFastContextHandler > xRet;
     114                 :            : 
     115      [ #  #  # ]:          0 :             switch( aElement )
     116                 :            :             {
     117                 :            :             case DGM_TOKEN( if ):
     118                 :            :             {
     119                 :            :                 // CT_When
     120 [ #  # ][ #  # ]:          0 :                 mpConditionNode.reset( new ConditionAtom(xAttribs) );
                 [ #  # ]
     121 [ #  # ][ #  # ]:          0 :                 mpNode->addChild( mpConditionNode );
                 [ #  # ]
     122 [ #  # ][ #  # ]:          0 :                 xRet.set( new IfContext( *this, xAttribs, mpConditionNode ) );
                 [ #  # ]
     123                 :          0 :                 break;
     124                 :            :             }
     125                 :            :             case DGM_TOKEN( else ):
     126                 :            :                 // CT_Otherwise
     127         [ #  # ]:          0 :                 if( mpConditionNode )
     128                 :            :                 {
     129                 :          0 :                     mpConditionNode->readElseBranch();
     130 [ #  # ][ #  # ]:          0 :                     xRet.set( new IfContext( *this, xAttribs, mpConditionNode ) );
                 [ #  # ]
     131         [ #  # ]:          0 :                     mpConditionNode.reset();
     132                 :            :                 }
     133                 :            :                 else
     134                 :            :                 {
     135                 :            :                     OSL_TRACE( "ignoring second else clause" );
     136                 :            :                 }
     137                 :          0 :                 break;
     138                 :            :             default:
     139                 :          0 :                 break;
     140                 :            :             }
     141                 :            : 
     142         [ #  # ]:          0 :             if( !xRet.is() )
     143         [ #  # ]:          0 :                 xRet.set(this);
     144                 :            : 
     145                 :          0 :             return xRet;
     146                 :            :         }
     147                 :            : private:
     148                 :            :     OUString msName;
     149                 :            :     LayoutAtomPtr mpNode;
     150                 :            :     ConditionAtomPtr mpConditionNode;
     151                 :            : };
     152                 :            : 
     153                 :            : 
     154                 :            : 
     155                 :            : 
     156         [ #  # ]:          0 : class ForEachContext
     157                 :            :     : public LayoutNodeContext
     158                 :            : {
     159                 :            : public:
     160                 :          0 :     ForEachContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, const ForEachAtomPtr& pAtom )
     161 [ #  # ][ #  # ]:          0 :         : LayoutNodeContext( rParent, xAttribs, pAtom )
                 [ #  # ]
     162                 :            :         {
     163 [ #  # ][ #  # ]:          0 :             xAttribs->getOptionalValue( XML_ref );
     164         [ #  # ]:          0 :             pAtom->iterator().loadFromXAttr( xAttribs );
     165                 :          0 :         }
     166                 :            : };
     167                 :            : 
     168                 :            : 
     169                 :            : // CT_LayoutVariablePropertySet
     170                 :            : class LayoutVariablePropertySetContext
     171                 :            :     : public ContextHandler
     172                 :            : {
     173                 :            : public:
     174                 :          0 :     LayoutVariablePropertySetContext( ContextHandler& rParent, LayoutNode::VarMap & aVar )
     175                 :            :         : ContextHandler( rParent )
     176                 :          0 :         , mVariables( aVar )
     177                 :            :         {
     178                 :          0 :         }
     179                 :            : 
     180                 :          0 :     virtual ~LayoutVariablePropertySetContext()
     181                 :          0 :         {
     182         [ #  # ]:          0 :         }
     183                 :            : 
     184                 :          0 :     virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs )
     185                 :            :         throw (SAXException, RuntimeException)
     186                 :            :         {
     187                 :          0 :             Reference< XFastContextHandler > xRet;
     188                 :            : 
     189                 :          0 :             sal_Int32 nIdx =  LayoutNodeContext::tagToVarIdx( getBaseToken( aElement ) );
     190         [ #  # ]:          0 :             if( nIdx != -1 )
     191                 :            :             {
     192 [ #  # ][ #  # ]:          0 :                 mVariables[ nIdx ] = makeAny( xAttribs->getOptionalValue( XML_val ) );
                 [ #  # ]
     193                 :            :             }
     194         [ #  # ]:          0 :             if( !xRet.is() )
     195         [ #  # ]:          0 :                 xRet.set(this);
     196                 :            : 
     197                 :          0 :             return xRet;
     198                 :            :         }
     199                 :            : private:
     200                 :            :     LayoutNode::VarMap & mVariables;
     201                 :            : };
     202                 :            : 
     203                 :            : 
     204                 :            : // CT_LayoutNode
     205                 :          0 : LayoutNodeContext::LayoutNodeContext( ContextHandler& rParent,
     206                 :            :                                       const Reference< XFastAttributeList >& xAttribs,
     207                 :            :                                       const LayoutAtomPtr& pAtom )
     208                 :            :     : ContextHandler( rParent )
     209         [ #  # ]:          0 :     , mpNode( pAtom )
     210                 :            : {
     211                 :            :     OSL_ENSURE( pAtom, "Node must NOT be NULL" );
     212 [ #  # ][ #  # ]:          0 :     mpNode->setName( xAttribs->getOptionalValue( XML_name ) );
     213                 :          0 : }
     214                 :            : 
     215                 :            : 
     216         [ #  # ]:          0 : LayoutNodeContext::~LayoutNodeContext()
     217                 :            : {
     218         [ #  # ]:          0 : }
     219                 :            : 
     220                 :          0 : void SAL_CALL LayoutNodeContext::endFastElement( ::sal_Int32 )
     221                 :            :     throw (SAXException, RuntimeException)
     222                 :            : {
     223                 :            : 
     224                 :          0 : }
     225                 :            : 
     226                 :            : /** convert the XML tag to a variable index in the array
     227                 :            :  * @param aTag the tag, without namespace
     228                 :            :  * @return the variable index. -1 is an error
     229                 :            :  */
     230                 :          0 : sal_Int32 LayoutNodeContext::tagToVarIdx( sal_Int32 aTag )
     231                 :            : {
     232                 :          0 :     sal_Int32 nIdx = -1;
     233   [ #  #  #  #  :          0 :     switch( aTag )
          #  #  #  #  #  
                      # ]
     234                 :            :     {
     235                 :            :     case DGM_TOKEN( animLvl ):
     236                 :          0 :         nIdx = LayoutNode::VAR_animLvl;
     237                 :          0 :         break;
     238                 :            :     case DGM_TOKEN( animOne ):
     239                 :          0 :         nIdx = LayoutNode::VAR_animOne;
     240                 :          0 :         break;
     241                 :            :     case DGM_TOKEN( bulletEnabled ):
     242                 :          0 :         nIdx = LayoutNode::VAR_bulletEnabled;
     243                 :          0 :         break;
     244                 :            :     case DGM_TOKEN( chMax ):
     245                 :          0 :         nIdx = LayoutNode::VAR_chMax;
     246                 :          0 :         break;
     247                 :            :     case DGM_TOKEN( chPref ):
     248                 :          0 :         nIdx = LayoutNode::VAR_chPref;
     249                 :          0 :         break;
     250                 :            :     case DGM_TOKEN( dir ):
     251                 :          0 :         nIdx = LayoutNode::VAR_dir;
     252                 :          0 :         break;
     253                 :            :     case DGM_TOKEN( hierBranch ):
     254                 :          0 :         nIdx = LayoutNode::VAR_hierBranch;
     255                 :          0 :         break;
     256                 :            :     case DGM_TOKEN( orgChart ):
     257                 :          0 :         nIdx = LayoutNode::VAR_orgChart;
     258                 :          0 :         break;
     259                 :            :     case DGM_TOKEN( resizeHandles ):
     260                 :          0 :         nIdx = LayoutNode::VAR_resizeHandles;
     261                 :          0 :         break;
     262                 :            :     default:
     263                 :          0 :         break;
     264                 :            :     }
     265                 :          0 :     return nIdx;
     266                 :            : }
     267                 :            : 
     268                 :            : 
     269                 :            : Reference< XFastContextHandler > SAL_CALL
     270                 :          0 : LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement,
     271                 :            :                                                   const Reference< XFastAttributeList >& xAttribs )
     272                 :            :     throw (SAXException, RuntimeException)
     273                 :            : {
     274                 :          0 :     Reference< XFastContextHandler > xRet;
     275                 :            : 
     276   [ #  #  #  #  :          0 :     switch( aElement )
          #  #  #  #  #  
                   #  # ]
     277                 :            :     {
     278                 :            :     case DGM_TOKEN( layoutNode ):
     279                 :            :     {
     280 [ #  # ][ #  # ]:          0 :         LayoutNodePtr pNode( new LayoutNode() );
                 [ #  # ]
     281 [ #  # ][ #  # ]:          0 :         mpNode->addChild( pNode );
                 [ #  # ]
     282 [ #  # ][ #  # ]:          0 :         pNode->setChildOrder( xAttribs->getOptionalValueToken( XML_chOrder, XML_b ) );
     283 [ #  # ][ #  # ]:          0 :         pNode->setMoveWith( xAttribs->getOptionalValue( XML_moveWith ) );
     284 [ #  # ][ #  # ]:          0 :         pNode->setStyleLabel( xAttribs->getOptionalValue( XML_styleLbl ) );
     285 [ #  # ][ #  # ]:          0 :         xRet.set( new LayoutNodeContext( *this, xAttribs, pNode ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     286         [ #  # ]:          0 :         break;
     287                 :            :     }
     288                 :            :     case DGM_TOKEN( shape ):
     289                 :            :     {
     290         [ #  # ]:          0 :         LayoutNodePtr pNode( boost::dynamic_pointer_cast< LayoutNode >( mpNode ) );
     291         [ #  # ]:          0 :         if( pNode )
     292                 :            :         {
     293         [ #  # ]:          0 :             ShapePtr pShape;
     294                 :            : 
     295 [ #  # ][ #  # ]:          0 :             if( xAttribs->hasAttribute( XML_type ) )
                 [ #  # ]
     296                 :            :             {
     297 [ #  # ][ #  # ]:          0 :                 pShape.reset( new Shape("com.sun.star.drawing.CustomShape") );
                 [ #  # ]
     298 [ #  # ][ #  # ]:          0 :                 const sal_Int32 nType(xAttribs->getOptionalValueToken( XML_type, XML_obj ));
     299                 :          0 :                 pShape->setSubType( nType );
     300 [ #  # ][ #  # ]:          0 :                 pShape->getCustomShapeProperties()->setShapePresetType( nType );
     301                 :            :             }
     302                 :            :             else
     303                 :            :             {
     304 [ #  # ][ #  # ]:          0 :                 pShape.reset( new Shape("com.sun.star.drawing.GroupShape") );
                 [ #  # ]
     305                 :            :             }
     306                 :            : 
     307         [ #  # ]:          0 :             pNode->setShape( pShape );
     308 [ #  # ][ #  # ]:          0 :             xRet.set( new ShapeContext( *this, ShapePtr(), pShape ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     309                 :            :         }
     310                 :            :         else
     311                 :            :         {
     312                 :            :             OSL_TRACE( "OOX: encountered a shape in a non layoutNode context" );
     313                 :            :         }
     314         [ #  # ]:          0 :         break;
     315                 :            :     }
     316                 :            :     case DGM_TOKEN( extLst ):
     317                 :          0 :         return xRet;
     318                 :            :     case DGM_TOKEN( alg ):
     319                 :            :     {
     320                 :            :         // CT_Algorithm
     321 [ #  # ][ #  # ]:          0 :         AlgAtomPtr pAtom( new AlgAtom );
                 [ #  # ]
     322 [ #  # ][ #  # ]:          0 :         mpNode->addChild( pAtom );
                 [ #  # ]
     323 [ #  # ][ #  # ]:          0 :         xRet.set( new AlgorithmContext( *this, xAttribs, pAtom ) );
                 [ #  # ]
     324         [ #  # ]:          0 :         break;
     325                 :            :     }
     326                 :            :     case DGM_TOKEN( choose ):
     327                 :            :     {
     328                 :            :         // CT_Choose
     329 [ #  # ][ #  # ]:          0 :         LayoutAtomPtr pAtom( new ChooseAtom );
                 [ #  # ]
     330         [ #  # ]:          0 :         mpNode->addChild( pAtom );
     331 [ #  # ][ #  # ]:          0 :         xRet.set( new ChooseContext( *this, xAttribs, pAtom ) );
                 [ #  # ]
     332         [ #  # ]:          0 :          break;
     333                 :            :     }
     334                 :            :     case DGM_TOKEN( forEach ):
     335                 :            :     {
     336                 :            :         // CT_ForEach
     337 [ #  # ][ #  # ]:          0 :         ForEachAtomPtr pAtom( new ForEachAtom(xAttribs) );
                 [ #  # ]
     338 [ #  # ][ #  # ]:          0 :         mpNode->addChild( pAtom );
                 [ #  # ]
     339 [ #  # ][ #  # ]:          0 :         xRet.set( new ForEachContext( *this, xAttribs, pAtom ) );
                 [ #  # ]
     340         [ #  # ]:          0 :         break;
     341                 :            :     }
     342                 :            :     case DGM_TOKEN( constrLst ):
     343                 :            :         // CT_Constraints
     344 [ #  # ][ #  # ]:          0 :         xRet.set( new ConstraintListContext( *this, xAttribs, mpNode ) );
                 [ #  # ]
     345                 :          0 :         break;
     346                 :            :     case DGM_TOKEN( presOf ):
     347                 :            :     {
     348                 :            :         // CT_PresentationOf
     349                 :            :         // TODO
     350 [ #  # ][ #  # ]:          0 :         xAttribs->getOptionalValue( XML_axis );
     351 [ #  # ][ #  # ]:          0 :         xAttribs->getOptionalValue( XML_cnt );
     352 [ #  # ][ #  # ]:          0 :         xAttribs->getOptionalValue( XML_hideLastTrans );
     353 [ #  # ][ #  # ]:          0 :         xAttribs->getOptionalValue( XML_ptType );
     354 [ #  # ][ #  # ]:          0 :         xAttribs->getOptionalValue( XML_st );
     355 [ #  # ][ #  # ]:          0 :         xAttribs->getOptionalValue( XML_step );
     356                 :          0 :         break;
     357                 :            :     }
     358                 :            :     case DGM_TOKEN( ruleLst ):
     359                 :            :         // CT_Rules
     360                 :            :         // TODO
     361                 :          0 :         break;
     362                 :            :     case DGM_TOKEN( varLst ):
     363                 :            :     {
     364         [ #  # ]:          0 :         LayoutNodePtr pNode( boost::dynamic_pointer_cast< LayoutNode >( mpNode ) );
     365         [ #  # ]:          0 :         if( pNode )
     366                 :            :         {
     367 [ #  # ][ #  # ]:          0 :             xRet.set( new LayoutVariablePropertySetContext( *this, pNode->variables() ) );
                 [ #  # ]
     368                 :            :         }
     369                 :            :         else
     370                 :            :         {
     371                 :            :             OSL_TRACE( "OOX: encountered a varLst in a non layoutNode context" );
     372                 :            :         }
     373         [ #  # ]:          0 :         break;
     374                 :            :     }
     375                 :            :     default:
     376                 :          0 :         break;
     377                 :            :     }
     378         [ #  # ]:          0 :     if( !xRet.is() )
     379         [ #  # ]:          0 :         xRet.set(this);
     380                 :            : 
     381                 :          0 :     return xRet;
     382                 :            : }
     383                 :            : 
     384                 :            : 
     385 [ +  - ][ +  - ]:        285 : } }
     386                 :            : 
     387                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10