LCOV - code coverage report
Current view: top level - oox/source/drawingml/diagram - diagramfragmenthandler.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 65 77 84.4 %
Date: 2015-06-13 12:38:46 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          47 : DiagramDataFragmentHandler::DiagramDataFragmentHandler( XmlFilterBase& rFilter,
      34             :                                                         const OUString& rFragmentPath,
      35             :                                                         const DiagramDataPtr& rDataPtr )
      36             :     throw( )
      37             :     : FragmentHandler2( rFilter, rFragmentPath )
      38          47 :     , mpDataPtr( rDataPtr )
      39             : {
      40          47 : }
      41             : 
      42          94 : DiagramDataFragmentHandler::~DiagramDataFragmentHandler( ) throw ()
      43             : {
      44             : 
      45          94 : }
      46             : 
      47          47 : void SAL_CALL DiagramDataFragmentHandler::endDocument()
      48             :     throw (SAXException, RuntimeException, std::exception)
      49             : {
      50             : 
      51          47 : }
      52             : 
      53             : ContextHandlerRef
      54          47 : DiagramDataFragmentHandler::onCreateContext( ::sal_Int32 aElement,
      55             :                                              const AttributeList& )
      56             : {
      57          47 :     switch( aElement )
      58             :     {
      59             :     case DGM_TOKEN( dataModel ):
      60          47 :         return new DataModelContext( *this, mpDataPtr );
      61             :     default:
      62           0 :         break;
      63             :     }
      64             : 
      65           0 :     return this;
      66             : }
      67             : 
      68          10 : DiagramLayoutFragmentHandler::DiagramLayoutFragmentHandler( XmlFilterBase& rFilter,
      69             :                                                         const OUString& rFragmentPath,
      70             :                                                         const DiagramLayoutPtr& rDataPtr )
      71             :     throw( )
      72             :     : FragmentHandler2( rFilter, rFragmentPath )
      73          10 :     , mpDataPtr( rDataPtr )
      74             : {
      75          10 : }
      76             : 
      77          20 : DiagramLayoutFragmentHandler::~DiagramLayoutFragmentHandler( ) throw ()
      78             : {
      79             : 
      80          20 : }
      81             : 
      82          10 : void SAL_CALL DiagramLayoutFragmentHandler::endDocument()
      83             :     throw (SAXException, RuntimeException, std::exception)
      84             : {
      85             : 
      86          10 : }
      87             : 
      88             : ContextHandlerRef
      89         178 : DiagramLayoutFragmentHandler::onCreateContext( ::sal_Int32 aElement,
      90             :                                                const AttributeList& rAttribs )
      91             : {
      92         178 :     switch( aElement )
      93             :     {
      94             :     case DGM_TOKEN( layoutDef ):
      95          10 :         return new DiagramDefinitionContext( *this, AttributeList( rAttribs ), mpDataPtr );
      96             :     default:
      97         168 :         break;
      98             :     }
      99             : 
     100         168 :     return this;
     101             : }
     102             : 
     103          10 : DiagramQStylesFragmentHandler::DiagramQStylesFragmentHandler( XmlFilterBase& rFilter,
     104             :                                                               const OUString& rFragmentPath,
     105             :                                                               DiagramQStyleMap& rStylesMap ) :
     106             :     FragmentHandler2( rFilter, rFragmentPath ),
     107             :     maStyleName(),
     108             :     maStyleEntry(),
     109          10 :     mrStylesMap( rStylesMap )
     110          10 : {}
     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        7140 : ::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        7140 :     switch( getCurrentElement() )
     129             :     {
     130             :         case XML_ROOT_CONTEXT:
     131          10 :             return nElement == DGM_TOKEN(styleDef) ? this : NULL;
     132             :         case DGM_TOKEN(styleDef):
     133         560 :             return nElement == DGM_TOKEN(styleLbl) ? this : NULL;
     134             :         case DGM_TOKEN(styleLbl):
     135        2940 :             return nElement == DGM_TOKEN(style) ? this : NULL;
     136             :         case DGM_TOKEN(style):
     137             :         {
     138        3630 :             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        3630 :             return 0;
     154             :         }
     155             :     }
     156             : 
     157           0 :     return 0;
     158             : }
     159             : 
     160         990 : void DiagramQStylesFragmentHandler::onStartElement( const AttributeList& rAttribs )
     161             : {
     162         990 :     if( getCurrentElement() == DGM_TOKEN( styleLbl ) )
     163             :     {
     164         490 :         maStyleName = rAttribs.getString( XML_name, OUString() );
     165         490 :         maStyleEntry = mrStylesMap[maStyleName];
     166             :     }
     167         990 : }
     168             : 
     169         990 : void DiagramQStylesFragmentHandler::onEndElement( )
     170             : {
     171         990 :     if( getCurrentElement() == DGM_TOKEN(styleLbl) )
     172         490 :         mrStylesMap[maStyleName] = maStyleEntry;
     173         990 : }
     174             : 
     175          47 : ColorFragmentHandler::ColorFragmentHandler( ::oox::core::XmlFilterBase& rFilter,
     176             :                                             const OUString& rFragmentPath,
     177             :                                             DiagramColorMap& rColorsMap ) :
     178             :     FragmentHandler2(rFilter,rFragmentPath),
     179             :     maColorName(),
     180             :     maColorEntry(),
     181          47 :     mrColorsMap(rColorsMap)
     182          47 : {}
     183             : 
     184       16356 : ::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       16356 :     switch( getCurrentElement() )
     191             :     {
     192             :         case XML_ROOT_CONTEXT:
     193          47 :             return nElement == DGM_TOKEN(colorsDef) ? this : NULL;
     194             :         case DGM_TOKEN(colorsDef):
     195        2491 :             return nElement == DGM_TOKEN(styleLbl) ? this : NULL;
     196             :         case DGM_TOKEN(styleLbl):
     197             :         {
     198       13818 :             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        2303 :                     return new ColorContext( *this, maColorEntry.maFillColor );
     207             :                 case DGM_TOKEN(linClrLst):
     208        2303 :                     return new ColorContext( *this, maColorEntry.maLineColor );
     209             :                 case DGM_TOKEN(effectClrLst):
     210        2303 :                     return new ColorContext( *this, maColorEntry.maEffectColor );
     211             :                 case DGM_TOKEN(txFillClrLst):
     212        2303 :                     return new ColorContext( *this, maColorEntry.maTextFillColor );
     213             :                 case DGM_TOKEN(txLinClrLst):
     214        2303 :                     return new ColorContext( *this, maColorEntry.maTextLineColor );
     215             :                 case DGM_TOKEN(txEffectClrLst):
     216        2303 :                     return new ColorContext( *this, maColorEntry.maTextEffectColor );
     217             :             }
     218           0 :             break;
     219             :         }
     220             :     }
     221             : 
     222           0 :     return 0;
     223             : }
     224             : 
     225        2350 : void ColorFragmentHandler::onStartElement( const AttributeList& rAttribs )
     226             : {
     227        2350 :     if( getCurrentElement() == DGM_TOKEN(styleLbl) )
     228             :     {
     229        2303 :         maColorName = rAttribs.getString( XML_name, OUString() );
     230        2303 :         maColorEntry = mrColorsMap[maColorName];
     231             :     }
     232        2350 : }
     233             : 
     234        2350 : void ColorFragmentHandler::onEndElement( )
     235             : {
     236        2350 :     if( getCurrentElement() == DGM_TOKEN(styleLbl) )
     237        2303 :         mrColorsMap[maColorName] = maColorEntry;
     238        2350 : }
     239             : 
     240         246 : } }
     241             : 
     242             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11