LCOV - code coverage report
Current view: top level - oox/source/drawingml/diagram - diagramfragmenthandler.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 65 77 84.4 %
Date: 2014-11-03 Functions: 20 21 95.2 %
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 <osl/diagnose.h>
      21             : 
      22             : #include "diagramdefinitioncontext.hxx"
      23             : #include "diagramfragmenthandler.hxx"
      24             : #include "datamodelcontext.hxx"
      25             : #include "drawingml/colorchoicecontext.hxx"
      26             : 
      27             : using namespace ::oox::core;
      28             : using namespace ::com::sun::star::xml::sax;
      29             : using namespace ::com::sun::star::uno;
      30             : 
      31             : namespace oox { namespace drawingml {
      32             : 
      33          88 : DiagramDataFragmentHandler::DiagramDataFragmentHandler( XmlFilterBase& rFilter,
      34             :                                                         const OUString& rFragmentPath,
      35             :                                                         const DiagramDataPtr pDataPtr )
      36             :     throw( )
      37             :     : FragmentHandler2( rFilter, rFragmentPath )
      38          88 :     , mpDataPtr( pDataPtr )
      39             : {
      40          88 : }
      41             : 
      42         176 : DiagramDataFragmentHandler::~DiagramDataFragmentHandler( ) throw ()
      43             : {
      44             : 
      45         176 : }
      46             : 
      47          88 : void SAL_CALL DiagramDataFragmentHandler::endDocument()
      48             :     throw (SAXException, RuntimeException, std::exception)
      49             : {
      50             : 
      51          88 : }
      52             : 
      53             : ContextHandlerRef
      54          88 : DiagramDataFragmentHandler::onCreateContext( ::sal_Int32 aElement,
      55             :                                              const AttributeList& )
      56             : {
      57          88 :     switch( aElement )
      58             :     {
      59             :     case DGM_TOKEN( dataModel ):
      60          88 :         return new DataModelContext( *this, mpDataPtr );
      61             :     default:
      62           0 :         break;
      63             :     }
      64             : 
      65           0 :     return this;
      66             : }
      67             : 
      68          20 : DiagramLayoutFragmentHandler::DiagramLayoutFragmentHandler( XmlFilterBase& rFilter,
      69             :                                                         const OUString& rFragmentPath,
      70             :                                                         const DiagramLayoutPtr pDataPtr )
      71             :     throw( )
      72             :     : FragmentHandler2( rFilter, rFragmentPath )
      73          20 :     , mpDataPtr( pDataPtr )
      74             : {
      75          20 : }
      76             : 
      77          40 : DiagramLayoutFragmentHandler::~DiagramLayoutFragmentHandler( ) throw ()
      78             : {
      79             : 
      80          40 : }
      81             : 
      82          20 : void SAL_CALL DiagramLayoutFragmentHandler::endDocument()
      83             :     throw (SAXException, RuntimeException, std::exception)
      84             : {
      85             : 
      86          20 : }
      87             : 
      88             : ContextHandlerRef
      89         356 : DiagramLayoutFragmentHandler::onCreateContext( ::sal_Int32 aElement,
      90             :                                                const AttributeList& rAttribs )
      91             : {
      92         356 :     switch( aElement )
      93             :     {
      94             :     case DGM_TOKEN( layoutDef ):
      95          20 :         return new DiagramDefinitionContext( *this, AttributeList( rAttribs ), mpDataPtr );
      96             :     default:
      97         336 :         break;
      98             :     }
      99             : 
     100         336 :     return this;
     101             : }
     102             : 
     103          20 : DiagramQStylesFragmentHandler::DiagramQStylesFragmentHandler( XmlFilterBase& rFilter,
     104             :                                                               const OUString& rFragmentPath,
     105             :                                                               DiagramQStyleMap& rStylesMap ) :
     106             :     FragmentHandler2( rFilter, rFragmentPath ),
     107             :     maStyleName(),
     108             :     maStyleEntry(),
     109          20 :     mrStylesMap( rStylesMap )
     110          20 : {}
     111             : 
     112           0 : ::oox::core::ContextHandlerRef DiagramQStylesFragmentHandler::createStyleMatrixContext(
     113             :     sal_Int32 nElement,
     114             :     const AttributeList& rAttribs,
     115             :     ShapeStyleRef& o_rStyle )
     116             : {
     117             :     o_rStyle.mnThemedIdx = (nElement == DGM_TOKEN(fontRef)) ?
     118           0 :         rAttribs.getToken( XML_idx, XML_none ) : rAttribs.getInteger( XML_idx, 0 );
     119           0 :     return new ColorContext( *this, o_rStyle.maPhClr );
     120             : }
     121             : 
     122       14280 : ::oox::core::ContextHandlerRef DiagramQStylesFragmentHandler::onCreateContext( sal_Int32 nElement,
     123             :                                                                                const AttributeList& rAttribs )
     124             : {
     125             :     // state-table like way of navigating the color fragment. we
     126             :     // currently ignore everything except styleLbl in the colorsDef
     127             :     // element
     128       14280 :     switch( getCurrentElement() )
     129             :     {
     130             :         case XML_ROOT_CONTEXT:
     131          20 :             return nElement == DGM_TOKEN(styleDef) ? this : NULL;
     132             :         case DGM_TOKEN(styleDef):
     133        1120 :             return nElement == DGM_TOKEN(styleLbl) ? this : NULL;
     134             :         case DGM_TOKEN(styleLbl):
     135        5880 :             return nElement == DGM_TOKEN(style) ? this : NULL;
     136             :         case DGM_TOKEN(style):
     137             :         {
     138        7260 :             switch( nElement )
     139             :             {
     140             :                 case DGM_TOKEN(lnRef) :     // CT_StyleMatrixReference
     141             :                     return createStyleMatrixContext(nElement,rAttribs,
     142           0 :                                                     maStyleEntry.maLineStyle);
     143             :                 case DGM_TOKEN(fillRef) :   // CT_StyleMatrixReference
     144             :                     return createStyleMatrixContext(nElement,rAttribs,
     145           0 :                                                     maStyleEntry.maFillStyle);
     146             :                 case DGM_TOKEN(effectRef) : // CT_StyleMatrixReference
     147             :                     return createStyleMatrixContext(nElement,rAttribs,
     148           0 :                                                     maStyleEntry.maEffectStyle);
     149             :                 case DGM_TOKEN(fontRef) :   // CT_FontRe    ference
     150             :                     return createStyleMatrixContext(nElement,rAttribs,
     151           0 :                                                     maStyleEntry.maTextStyle);
     152             :             }
     153        7260 :             return 0;
     154             :         }
     155             :     }
     156             : 
     157           0 :     return 0;
     158             : }
     159             : 
     160        1980 : void DiagramQStylesFragmentHandler::onStartElement( const AttributeList& rAttribs )
     161             : {
     162        1980 :     if( getCurrentElement() == DGM_TOKEN( styleLbl ) )
     163             :     {
     164         980 :         maStyleName = rAttribs.getString( XML_name, OUString() );
     165         980 :         maStyleEntry = mrStylesMap[maStyleName];
     166             :     }
     167        1980 : }
     168             : 
     169        1980 : void DiagramQStylesFragmentHandler::onEndElement( )
     170             : {
     171        1980 :     if( getCurrentElement() == DGM_TOKEN(styleLbl) )
     172         980 :         mrStylesMap[maStyleName] = maStyleEntry;
     173        1980 : }
     174             : 
     175          88 : ColorFragmentHandler::ColorFragmentHandler( ::oox::core::XmlFilterBase& rFilter,
     176             :                                             const OUString& rFragmentPath,
     177             :                                             DiagramColorMap& rColorsMap ) :
     178             :     FragmentHandler2(rFilter,rFragmentPath),
     179             :     maColorName(),
     180             :     maColorEntry(),
     181          88 :     mrColorsMap(rColorsMap)
     182          88 : {}
     183             : 
     184       30624 : ::oox::core::ContextHandlerRef ColorFragmentHandler::onCreateContext( sal_Int32 nElement,
     185             :                                                                       const AttributeList& /*rAttribs*/ )
     186             : {
     187             :     // state-table like way of navigating the color fragment. we
     188             :     // currently ignore everything except styleLbl in the colorsDef
     189             :     // element
     190       30624 :     switch( getCurrentElement() )
     191             :     {
     192             :         case XML_ROOT_CONTEXT:
     193          88 :             return nElement == DGM_TOKEN(colorsDef) ? this : NULL;
     194             :         case DGM_TOKEN(colorsDef):
     195        4664 :             return nElement == DGM_TOKEN(styleLbl) ? this : NULL;
     196             :         case DGM_TOKEN(styleLbl):
     197             :         {
     198       25872 :             switch( nElement )
     199             :             {
     200             :                 // the actual colors - defer to color fragment handlers.
     201             : 
     202             :                 // TODO(F1): well, actually, there might be *several* color
     203             :                 // definitions in it, after all its called list. but
     204             :                 // apparently ColorContext doesn't handle that anyway...
     205             :                 case DGM_TOKEN(fillClrLst):
     206        4312 :                     return new ColorContext( *this, maColorEntry.maFillColor );
     207             :                 case DGM_TOKEN(linClrLst):
     208        4312 :                     return new ColorContext( *this, maColorEntry.maLineColor );
     209             :                 case DGM_TOKEN(effectClrLst):
     210        4312 :                     return new ColorContext( *this, maColorEntry.maEffectColor );
     211             :                 case DGM_TOKEN(txFillClrLst):
     212        4312 :                     return new ColorContext( *this, maColorEntry.maTextFillColor );
     213             :                 case DGM_TOKEN(txLinClrLst):
     214        4312 :                     return new ColorContext( *this, maColorEntry.maTextLineColor );
     215             :                 case DGM_TOKEN(txEffectClrLst):
     216        4312 :                     return new ColorContext( *this, maColorEntry.maTextEffectColor );
     217             :             }
     218           0 :             break;
     219             :         }
     220             :     }
     221             : 
     222           0 :     return 0;
     223             : }
     224             : 
     225        4400 : void ColorFragmentHandler::onStartElement( const AttributeList& rAttribs )
     226             : {
     227        4400 :     if( getCurrentElement() == DGM_TOKEN(styleLbl) )
     228             :     {
     229        4312 :         maColorName = rAttribs.getString( XML_name, OUString() );
     230        4312 :         maColorEntry = mrColorsMap[maColorName];
     231             :     }
     232        4400 : }
     233             : 
     234        4400 : void ColorFragmentHandler::onEndElement( )
     235             : {
     236        4400 :     if( getCurrentElement() == DGM_TOKEN(styleLbl) )
     237        4312 :         mrColorsMap[maColorName] = maColorEntry;
     238        4400 : }
     239             : 
     240         408 : } }
     241             : 
     242             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10