LCOV - code coverage report
Current view: top level - oox/source/drawingml/diagram - datamodelcontext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 144 0.0 %
Date: 2014-04-14 Functions: 0 30 0.0 %
Legend: Lines: hit not hit

          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 "datamodelcontext.hxx"
      21             : #include "oox/helper/attributelist.hxx"
      22             : #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
      23             : #include "oox/drawingml/shapepropertiescontext.hxx"
      24             : #include "oox/drawingml/textbodycontext.hxx"
      25             : 
      26             : using namespace ::oox::core;
      27             : using namespace ::com::sun::star::xml::sax;
      28             : using namespace ::com::sun::star::uno;
      29             : 
      30             : namespace oox { namespace drawingml {
      31             : 
      32             : // CT_CxnList
      33           0 : class CxnListContext
      34             :     : public ContextHandler2
      35             : {
      36             : public:
      37           0 :     CxnListContext( ContextHandler2Helper& rParent,
      38             :                     dgm::Connections & aConnections )
      39             :         : ContextHandler2( rParent )
      40           0 :         , mrConnection( aConnections )
      41             :         {
      42           0 :         }
      43             : 
      44             :     virtual ContextHandlerRef
      45           0 :     onCreateContext( sal_Int32 aElementToken,
      46             :                      const AttributeList& rAttribs ) SAL_OVERRIDE
      47             :         {
      48           0 :             switch( aElementToken )
      49             :             {
      50             :                 case DGM_TOKEN( cxn ):
      51             :                 {
      52           0 :                     mrConnection.push_back( dgm::Connection() );
      53           0 :                     dgm::Connection& rConnection=mrConnection.back();
      54             : 
      55           0 :                     const sal_Int32 nType = rAttribs.getToken( XML_type, XML_parOf );
      56           0 :                     rConnection.mnType = nType;
      57           0 :                     rConnection.msModelId = rAttribs.getString( XML_modelId ).get();
      58           0 :                     rConnection.msSourceId = rAttribs.getString( XML_srcId ).get();
      59           0 :                     rConnection.msDestId  = rAttribs.getString( XML_destId ).get();
      60           0 :                     rConnection.msPresId  = rAttribs.getString( XML_presId ).get();
      61           0 :                     rConnection.msSibTransId  = rAttribs.getString( XML_sibTransId ).get();
      62           0 :                     rConnection.msParTransId  = rAttribs.getString( XML_parTransId ).get();
      63           0 :                     rConnection.mnSourceOrder = rAttribs.getInteger( XML_srcOrd, 0 );
      64           0 :                     rConnection.mnDestOrder = rAttribs.getInteger( XML_destOrd, 0 );
      65             : 
      66             :                     // skip CT_extLst
      67           0 :                     return 0;
      68             :                 }
      69             :                 default:
      70           0 :                     break;
      71             :             }
      72             : 
      73           0 :             return this;
      74             :         }
      75             : private:
      76             :     dgm::Connections& mrConnection;
      77             : };
      78             : 
      79             : 
      80             : // CT_presLayoutVars
      81           0 : class PresLayoutVarsContext
      82             :     : public ContextHandler2
      83             : {
      84             : public:
      85           0 :     PresLayoutVarsContext( ContextHandler2Helper& rParent,
      86             :                            dgm::Point & rPoint ) :
      87             :         ContextHandler2( rParent ),
      88           0 :         mrPoint( rPoint )
      89             :     {
      90           0 :     }
      91             :     virtual ContextHandlerRef
      92           0 :     onCreateContext( sal_Int32 aElementToken,
      93             :                      const AttributeList& rAttribs ) SAL_OVERRIDE
      94             :     {
      95           0 :         switch( aElementToken )
      96             :         {
      97             :             // TODO
      98             :             case DGM_TOKEN( animLvl ):
      99             :             case DGM_TOKEN( animOne ):
     100           0 :                 break;
     101             :             case DGM_TOKEN( bulletEnabled ):
     102           0 :                 mrPoint.mbBulletEnabled = rAttribs.getBool( XML_val, false );
     103           0 :                 break;
     104             :             case DGM_TOKEN( chMax ):
     105           0 :                 mrPoint.mnMaxChildren = rAttribs.getInteger( XML_val, -1 );
     106           0 :                 break;
     107             :             case DGM_TOKEN( chPref ):
     108           0 :                 mrPoint.mnPreferredChildren = rAttribs.getInteger( XML_val, -1 );
     109           0 :                 break;
     110             :             case DGM_TOKEN( dir ):
     111           0 :                 mrPoint.mnDirection = rAttribs.getToken( XML_val, XML_norm );
     112           0 :                 break;
     113             :             case DGM_TOKEN( hierBranch ):
     114           0 :                 mrPoint.mnHierarchyBranch = rAttribs.getToken( XML_val, XML_std );
     115           0 :                 break;
     116             :             case DGM_TOKEN( orgChart ):
     117           0 :                 mrPoint.mbOrgChartEnabled = rAttribs.getBool( XML_val, false );
     118           0 :                 break;
     119             :             case DGM_TOKEN( resizeHandles ):
     120           0 :                 mrPoint.mnResizeHandles = rAttribs.getToken( XML_val, XML_rel );
     121           0 :                 break;
     122             :             default:
     123           0 :                 break;
     124             :         }
     125             : 
     126           0 :         return this;
     127             :     }
     128             : 
     129             : private:
     130             :     dgm::Point& mrPoint;
     131             : };
     132             : 
     133             : 
     134             : // CT_prSet
     135           0 : class PropertiesContext
     136             :     : public ContextHandler2
     137             : {
     138             : public:
     139           0 :     PropertiesContext( ContextHandler2Helper& rParent,
     140             :                        dgm::Point & rPoint,
     141             :                        const AttributeList& rAttribs ) :
     142             :         ContextHandler2( rParent ),
     143           0 :         mrPoint( rPoint )
     144             :     {
     145           0 :         OUString aEmptyStr;
     146             : 
     147           0 :         mrPoint.msColorTransformCategoryId = rAttribs.getString( XML_csCatId, aEmptyStr );
     148           0 :         mrPoint.msColorTransformTypeId = rAttribs.getString( XML_csTypeId, aEmptyStr );
     149           0 :         mrPoint.msLayoutCategoryId = rAttribs.getString( XML_loCatId, aEmptyStr );
     150           0 :         mrPoint.msLayoutTypeId = rAttribs.getString( XML_loTypeId, aEmptyStr );
     151           0 :         mrPoint.msPlaceholderText = rAttribs.getString( XML_phldrT, aEmptyStr );
     152           0 :         mrPoint.msPresentationAssociationId = rAttribs.getString( XML_presAssocID, aEmptyStr );
     153           0 :         mrPoint.msPresentationLayoutName = rAttribs.getString( XML_presName, aEmptyStr );
     154           0 :         mrPoint.msPresentationLayoutStyleLabel = rAttribs.getString( XML_presStyleLbl, aEmptyStr );
     155           0 :         mrPoint.msQuickStyleCategoryId = rAttribs.getString( XML_qsCatId, aEmptyStr );
     156           0 :         mrPoint.msQuickStyleTypeId = rAttribs.getString( XML_qsTypeId, aEmptyStr );
     157             : 
     158           0 :         mrPoint.mnCustomAngle = rAttribs.getInteger( XML_custAng, -1 );
     159           0 :         mrPoint.mnPercentageNeighbourWidth = rAttribs.getInteger( XML_custLinFactNeighborX, -1 );
     160           0 :         mrPoint.mnPercentageNeighbourHeight = rAttribs.getInteger( XML_custLinFactNeighborY, -1 );
     161           0 :         mrPoint.mnPercentageOwnWidth = rAttribs.getInteger( XML_custLinFactX, -1 );
     162           0 :         mrPoint.mnPercentageOwnHeight = rAttribs.getInteger( XML_custLinFactY, -1 );
     163           0 :         mrPoint.mnIncludeAngleScale = rAttribs.getInteger( XML_custRadScaleInc, -1 );
     164           0 :         mrPoint.mnRadiusScale = rAttribs.getInteger( XML_custRadScaleRad, -1 );
     165           0 :         mrPoint.mnWidthScale = rAttribs.getInteger( XML_custScaleX, -1 );
     166           0 :         mrPoint.mnHeightScale = rAttribs.getInteger( XML_custScaleY, -1 );
     167           0 :         mrPoint.mnWidthOverride = rAttribs.getInteger( XML_custSzX, -1 );
     168           0 :         mrPoint.mnHeightOverride = rAttribs.getInteger( XML_custSzY, -1 );
     169           0 :         mrPoint.mnLayoutStyleCount = rAttribs.getInteger( XML_presStyleCnt, -1 );
     170           0 :         mrPoint.mnLayoutStyleIndex = rAttribs.getInteger( XML_presStyleIdx, -1 );
     171             : 
     172           0 :         mrPoint.mbCoherent3DOffset = rAttribs.getBool( XML_coherent3DOff, false );
     173           0 :         mrPoint.mbCustomHorizontalFlip = rAttribs.getBool( XML_custFlipHor, false );
     174           0 :         mrPoint.mbCustomVerticalFlip = rAttribs.getBool( XML_custFlipVert, false );
     175           0 :         mrPoint.mbCustomText = rAttribs.getBool( XML_custT, false );
     176           0 :         mrPoint.mbIsPlaceholder = rAttribs.getBool( XML_phldr, false );
     177           0 :     }
     178             : 
     179             :     virtual ContextHandlerRef
     180           0 :     onCreateContext( sal_Int32 aElementToken,
     181             :                      const AttributeList& ) SAL_OVERRIDE
     182             :         {
     183           0 :             switch( aElementToken )
     184             :             {
     185             :             case DGM_TOKEN( presLayoutVars ):
     186           0 :                 return new PresLayoutVarsContext( *this, mrPoint );
     187             :             case DGM_TOKEN( style ):
     188             :                 // skip CT_shapeStyle
     189           0 :                 return 0;
     190             :             default:
     191           0 :                 break;
     192             :             }
     193           0 :             return this;
     194             :         }
     195             : 
     196             : private:
     197             :     dgm::Point& mrPoint;
     198             : };
     199             : 
     200             : 
     201             : // CL_Pt
     202           0 : class PtContext
     203             :     : public ContextHandler2
     204             : {
     205             : public:
     206           0 :     PtContext( ContextHandler2Helper& rParent,
     207             :                const AttributeList& rAttribs,
     208             :                dgm::Point & rPoint):
     209             :         ContextHandler2( rParent ),
     210           0 :         mrPoint( rPoint )
     211             :     {
     212           0 :         mrPoint.msModelId = rAttribs.getString( XML_modelId ).get();
     213             : 
     214             :         // the default type is XML_node
     215           0 :         const sal_Int32 nType  = rAttribs.getToken( XML_type, XML_node );
     216           0 :         mrPoint.mnType = nType;
     217             : 
     218             :         // ignore the cxnId unless it is this type. See 5.15.3.1.3 in Primer
     219           0 :         if( ( nType == XML_parTrans ) || ( nType == XML_sibTrans ) )
     220           0 :             mrPoint.msCnxId = rAttribs.getString( XML_cxnId ).get();
     221           0 :     }
     222             : 
     223             : 
     224             :     virtual ContextHandlerRef
     225           0 :     onCreateContext( sal_Int32 aElementToken,
     226             :                      const AttributeList& rAttribs ) SAL_OVERRIDE
     227             :         {
     228           0 :             switch( aElementToken )
     229             :             {
     230             :             case DGM_TOKEN( extLst ):
     231           0 :                 return 0;
     232             :             case DGM_TOKEN( prSet ):
     233             :                 OSL_TRACE( "diagram property set for point");
     234           0 :                 return new PropertiesContext( *this, mrPoint, rAttribs );
     235             :             case DGM_TOKEN( spPr ):
     236             :                 OSL_TRACE( "shape props for point");
     237           0 :                 if( !mrPoint.mpShape )
     238           0 :                     mrPoint.mpShape.reset( new Shape() );
     239           0 :                 return new ShapePropertiesContext( *this, *(mrPoint.mpShape) );
     240             :             case DGM_TOKEN( t ):
     241             :             {
     242             :                 OSL_TRACE( "shape text body for point");
     243           0 :                 TextBodyPtr xTextBody( new TextBody );
     244           0 :                 if( !mrPoint.mpShape )
     245           0 :                     mrPoint.mpShape.reset( new Shape() );
     246           0 :                 mrPoint.mpShape->setTextBody( xTextBody );
     247           0 :                 return new TextBodyContext( *this, *xTextBody );
     248             :             }
     249             :             default:
     250           0 :                 break;
     251             :             }
     252           0 :             return this;
     253             :         }
     254             : 
     255             : private:
     256             :     dgm::Point& mrPoint;
     257             : };
     258             : 
     259             : 
     260             : 
     261             : // CT_PtList
     262           0 : class PtListContext
     263             :     : public ContextHandler2
     264             : {
     265             : public:
     266           0 :     PtListContext( ContextHandler2Helper& rParent,  dgm::Points& rPoints) :
     267             :         ContextHandler2( rParent ),
     268           0 :         mrPoints( rPoints )
     269           0 :     {}
     270             :     virtual ContextHandlerRef
     271           0 :     onCreateContext( sal_Int32 aElementToken,
     272             :                      const AttributeList& rAttribs ) SAL_OVERRIDE
     273             :         {
     274           0 :             switch( aElementToken )
     275             :             {
     276             :             case DGM_TOKEN( pt ):
     277             :             {
     278             :                 // CT_Pt
     279           0 :                 mrPoints.push_back( dgm::Point() );
     280           0 :                 return new PtContext( *this, rAttribs, mrPoints.back() );
     281             :             }
     282             :             default:
     283           0 :                 break;
     284             :             }
     285           0 :             return this;
     286             :         }
     287             : 
     288             : private:
     289             :     dgm::Points& mrPoints;
     290             : };
     291             : 
     292             : // CT_BackgroundFormatting
     293           0 : class BackgroundFormattingContext
     294             :     : public ContextHandler2
     295             : {
     296             : public:
     297           0 :     BackgroundFormattingContext( ContextHandler2Helper& rParent, DiagramDataPtr & pModel )
     298             :         : ContextHandler2( rParent )
     299           0 :         , mpDataModel( pModel )
     300             :         {
     301             :             OSL_ENSURE( pModel, "the data model MUST NOT be NULL" );
     302           0 :         }
     303             : 
     304             :     virtual ContextHandlerRef
     305           0 :     onCreateContext( sal_Int32 aElementToken,
     306             :                      const AttributeList& rAttribs ) SAL_OVERRIDE
     307             :         {
     308           0 :             switch( aElementToken )
     309             :             {
     310             :             case A_TOKEN( blipFill ):
     311             :             case A_TOKEN( gradFill ):
     312             :             case A_TOKEN( grpFill ):
     313             :             case A_TOKEN( noFill ):
     314             :             case A_TOKEN( pattFill ):
     315             :             case A_TOKEN( solidFill ):
     316             :                 // EG_FillProperties
     317             :                 return FillPropertiesContext::createFillContext(
     318           0 :                     *this, aElementToken, rAttribs, *mpDataModel->getFillProperties() );
     319             :             case A_TOKEN( effectDag ):
     320             :             case A_TOKEN( effectLst ):
     321             :                 // TODO
     322             :                 // EG_EffectProperties
     323           0 :                 break;
     324             :             default:
     325           0 :                 break;
     326             :             }
     327           0 :             return this;
     328             :         }
     329             : private:
     330             :     DiagramDataPtr mpDataModel;
     331             : };
     332             : 
     333             : 
     334             : 
     335           0 : DataModelContext::DataModelContext( ContextHandler2Helper& rParent,
     336             :                                     const DiagramDataPtr & pDataModel )
     337             :     : ContextHandler2( rParent )
     338           0 :     , mpDataModel( pDataModel )
     339             : {
     340             :     OSL_ENSURE( pDataModel, "Data Model must not be NULL" );
     341           0 : }
     342             : 
     343             : 
     344           0 : DataModelContext::~DataModelContext()
     345             : {
     346             :     // some debug
     347           0 :     mpDataModel->dump();
     348           0 : }
     349             : 
     350             : ContextHandlerRef
     351           0 : DataModelContext::onCreateContext( ::sal_Int32 aElement,
     352             :                                    const AttributeList& rAttribs )
     353             : {
     354           0 :     switch( aElement )
     355             :     {
     356             :     case DGM_TOKEN( cxnLst ):
     357             :         // CT_CxnList
     358           0 :         return new CxnListContext( *this, mpDataModel->getConnections() );
     359             :     case DGM_TOKEN( ptLst ):
     360             :         // CT_PtList
     361           0 :         return new PtListContext( *this, mpDataModel->getPoints() );
     362             :     case DGM_TOKEN( bg ):
     363             :         // CT_BackgroundFormatting
     364           0 :         return new BackgroundFormattingContext( *this, mpDataModel );
     365             :     case DGM_TOKEN( whole ):
     366             :         // CT_WholeE2oFormatting
     367             :         // TODO
     368           0 :         return 0;
     369             :     case DGM_TOKEN( extLst ):
     370             :     case A_TOKEN( ext ):
     371           0 :         break;
     372             :     case DSP_TOKEN( dataModelExt ):
     373           0 :         mpDataModel->getExtDrawings().push_back( rAttribs.getString( XML_relId ).get() );
     374           0 :         break;
     375             :     default:
     376           0 :         break;
     377             :     }
     378             : 
     379           0 :     return this;
     380             : }
     381             : 
     382           0 : } }
     383             : 
     384             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10