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

Generated by: LCOV version 1.10