LCOV - code coverage report
Current view: top level - xmloff/source/transform - ChartPlotAreaOASISTContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 86 0.0 %
Date: 2012-08-25 Functions: 0 23 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 128 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "ChartPlotAreaOASISTContext.hxx"
      30                 :            : #include "TransformerBase.hxx"
      31                 :            : #include <xmloff/nmspmap.hxx>
      32                 :            : #include "xmloff/xmlnmspe.hxx"
      33                 :            : #include <xmloff/xmltoken.hxx>
      34                 :            : #include "DeepTContext.hxx"
      35                 :            : #include "ActionMapTypesOASIS.hxx"
      36                 :            : #include "MutableAttrList.hxx"
      37                 :            : 
      38                 :            : using namespace ::com::sun::star;
      39                 :            : using namespace ::xmloff::token;
      40                 :            : 
      41                 :            : using ::com::sun::star::uno::Reference;
      42                 :            : using ::rtl::OUString;
      43                 :            : 
      44                 :            : class XMLAxisOASISContext : public XMLPersElemContentTContext
      45                 :            : {
      46                 :            : public:
      47                 :            :     TYPEINFO();
      48                 :            : 
      49                 :            :     XMLAxisOASISContext( XMLTransformerBase& rTransformer,
      50                 :            :                          const ::rtl::OUString& rQName,
      51                 :            :                          ::rtl::Reference< XMLPersAttrListTContext > & rOutCategoriesContext );
      52                 :            :     ~XMLAxisOASISContext();
      53                 :            : 
      54                 :            :     virtual XMLTransformerContext *CreateChildContext(
      55                 :            :         sal_uInt16 nPrefix,
      56                 :            :         const ::rtl::OUString& rLocalName,
      57                 :            :         const ::rtl::OUString& rQName,
      58                 :            :         const Reference< xml::sax::XAttributeList >& xAttrList );
      59                 :            : 
      60                 :            :     virtual void StartElement( const Reference< xml::sax::XAttributeList >& rAttrList );
      61                 :            :     virtual void EndElement();
      62                 :            : 
      63                 :            :     bool IsCategoryAxis() const;
      64                 :            : 
      65                 :            : private:
      66                 :            :     ::rtl::Reference< XMLPersAttrListTContext > &   m_rCategoriesContext;
      67                 :            :     bool                                            m_bHasCategories;
      68                 :            : };
      69                 :            : 
      70 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLAxisOASISContext, XMLPersElemContentTContext );
      71                 :            : 
      72                 :          0 : XMLAxisOASISContext::XMLAxisOASISContext(
      73                 :            :     XMLTransformerBase& rTransformer,
      74                 :            :     const ::rtl::OUString& rQName,
      75                 :            :     ::rtl::Reference< XMLPersAttrListTContext > & rOutCategoriesContext ) :
      76                 :            :         XMLPersElemContentTContext( rTransformer, rQName ),
      77                 :            :         m_rCategoriesContext( rOutCategoriesContext ),
      78                 :          0 :         m_bHasCategories( false )
      79                 :          0 : {}
      80                 :            : 
      81                 :          0 : XMLAxisOASISContext::~XMLAxisOASISContext()
      82         [ #  # ]:          0 : {}
      83                 :            : 
      84                 :          0 : XMLTransformerContext * XMLAxisOASISContext::CreateChildContext(
      85                 :            :     sal_uInt16 nPrefix,
      86                 :            :     const ::rtl::OUString& rLocalName,
      87                 :            :     const ::rtl::OUString& rQName,
      88                 :            :     const Reference< xml::sax::XAttributeList >& xAttrList )
      89                 :            : {
      90                 :          0 :     XMLTransformerContext * pContext = 0;
      91                 :            : 
      92   [ #  #  #  # ]:          0 :     if( XML_NAMESPACE_CHART == nPrefix &&
                 [ #  # ]
      93                 :          0 :         IsXMLToken( rLocalName, XML_CATEGORIES ) )
      94                 :            :     {
      95                 :            :         // store categories element at parent
      96         [ #  # ]:          0 :         m_rCategoriesContext.set( new XMLPersAttrListTContext( GetTransformer(), rQName ));
      97                 :          0 :         m_bHasCategories = true;
      98                 :          0 :         pContext = m_rCategoriesContext.get();
      99                 :            :     }
     100                 :            :     else
     101                 :            :     {
     102                 :            :         pContext =  XMLPersElemContentTContext::CreateChildContext(
     103                 :          0 :             nPrefix, rLocalName, rQName, xAttrList );
     104                 :            :     }
     105                 :            : 
     106                 :          0 :     return pContext;
     107                 :            : }
     108                 :            : 
     109                 :          0 : void XMLAxisOASISContext::StartElement(
     110                 :            :     const Reference< xml::sax::XAttributeList >& rAttrList )
     111                 :            : {
     112                 :          0 :     Reference< xml::sax::XAttributeList > xAttrList( rAttrList );
     113                 :          0 :     XMLMutableAttributeList *pMutableAttrList = 0;
     114 [ #  # ][ #  # ]:          0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
                 [ #  # ]
     115         [ #  # ]:          0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
     116                 :            :     {
     117 [ #  # ][ #  # ]:          0 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
     118                 :          0 :         OUString aLocalName;
     119                 :            :         sal_uInt16 nPrefix =
     120         [ #  # ]:          0 :             GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
     121                 :            : 
     122 [ #  # ][ #  # ]:          0 :         if( nPrefix == XML_NAMESPACE_CHART &&
                 [ #  # ]
     123         [ #  # ]:          0 :             IsXMLToken( aLocalName, XML_DIMENSION ) )
     124                 :            :         {
     125         [ #  # ]:          0 :             if( !pMutableAttrList )
     126                 :            :             {
     127         [ #  # ]:          0 :                 pMutableAttrList = new XMLMutableAttributeList( xAttrList );
     128 [ #  # ][ #  # ]:          0 :                 xAttrList = pMutableAttrList;
     129                 :            :             }
     130                 :            : 
     131 [ #  # ][ #  # ]:          0 :             const OUString& rAttrValue = xAttrList->getValueByIndex( i );
     132                 :          0 :             XMLTokenEnum eToken = XML_TOKEN_INVALID;
     133 [ #  # ][ #  # ]:          0 :             if( IsXMLToken( rAttrValue, XML_X ))
     134                 :            :             {
     135                 :          0 :                 eToken = XML_DOMAIN;
     136                 :            :                 // has to be XML_CATEGORY for axes with a categories
     137                 :            :                 // sub-element.  The attribute is changed later (when it is
     138                 :            :                 // known that there is a categories sub-element) in this case.
     139                 :            :             }
     140 [ #  # ][ #  # ]:          0 :             else if( IsXMLToken( rAttrValue, XML_Y ))
     141                 :            :             {
     142                 :          0 :                 eToken = XML_VALUE;
     143                 :            :             }
     144 [ #  # ][ #  # ]:          0 :             else if( IsXMLToken( rAttrValue, XML_Z ))
     145                 :            :             {
     146                 :          0 :                 eToken = XML_SERIES;
     147                 :            :             }
     148                 :            :             else
     149                 :            :             {
     150                 :            :                 OSL_FAIL( "ChartAxis: Invalid attribute value" );
     151                 :            :             }
     152                 :            : 
     153         [ #  # ]:          0 :             if( eToken != XML_TOKEN_INVALID )
     154                 :            :             {
     155                 :            :                 OUString aNewAttrQName(
     156                 :          0 :                     GetTransformer().GetNamespaceMap().GetQNameByKey(
     157   [ #  #  #  # ]:          0 :                         XML_NAMESPACE_CHART, GetXMLToken( XML_CLASS )));
     158         [ #  # ]:          0 :                 pMutableAttrList->RenameAttributeByIndex( i, aNewAttrQName );
     159                 :            : 
     160 [ #  # ][ #  # ]:          0 :                 pMutableAttrList->SetValueByIndex( i, GetXMLToken( eToken ));
     161                 :          0 :             }
     162                 :            :         }
     163                 :          0 :     }
     164                 :            : 
     165         [ #  # ]:          0 :     XMLPersElemContentTContext::StartElement( xAttrList );
     166                 :          0 : }
     167                 :            : 
     168                 :          0 : void XMLAxisOASISContext::EndElement()
     169                 :            : {
     170                 :            :     // if we have categories, change the "class" attribute
     171   [ #  #  #  # ]:          0 :     if( IsCategoryAxis() &&
                 [ #  # ]
     172                 :          0 :         m_rCategoriesContext.is() )
     173                 :            :     {
     174                 :            :         OSL_ENSURE( GetAttrList().is(), "Invalid attribute list" );
     175                 :            :         XMLMutableAttributeList * pMutableAttrList =
     176 [ #  # ][ #  # ]:          0 :             new XMLMutableAttributeList( GetAttrList());
     177                 :          0 :         OUString aAttrQName( GetTransformer().GetNamespaceMap().GetQNameByKey(
     178   [ #  #  #  # ]:          0 :                                  XML_NAMESPACE_CHART, GetXMLToken( XML_CLASS )));
     179         [ #  # ]:          0 :         sal_Int16 nIndex = pMutableAttrList->GetIndexByName( aAttrQName );
     180         [ #  # ]:          0 :         if( nIndex != -1 )
     181                 :            :         {
     182                 :            :             OSL_ENSURE( IsXMLToken( pMutableAttrList->getValueByIndex( nIndex ),
     183                 :            :                                     XML_DOMAIN ), "Axis Dimension: invalid former value" );
     184 [ #  # ][ #  # ]:          0 :             pMutableAttrList->SetValueByIndex( nIndex, GetXMLToken( XML_CATEGORY ));
     185                 :            :             OSL_ENSURE( IsXMLToken( pMutableAttrList->getValueByIndex( nIndex ),
     186                 :            :                                     XML_CATEGORY ), "Axis Dimension: invalid new value" );
     187                 :            :         }
     188                 :            : 
     189         [ #  # ]:          0 :         GetTransformer().GetDocHandler()->startElement(
     190                 :          0 :             GetExportQName(),
     191         [ #  # ]:          0 :             Reference< xml::sax::XAttributeList >( pMutableAttrList ));
           [ #  #  #  # ]
     192         [ #  # ]:          0 :         ExportContent();
     193 [ #  # ][ #  # ]:          0 :         GetTransformer().GetDocHandler()->endElement( GetExportQName());
     194                 :            :     }
     195                 :            :     else
     196                 :          0 :         Export();
     197                 :          0 : }
     198                 :            : 
     199                 :          0 : bool XMLAxisOASISContext::IsCategoryAxis() const
     200                 :            : {
     201                 :          0 :     return m_bHasCategories;
     202                 :            : }
     203                 :            : 
     204                 :            : 
     205 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLChartPlotAreaOASISTContext, XMLProcAttrTransformerContext );
     206                 :            : 
     207                 :          0 : XMLChartPlotAreaOASISTContext::XMLChartPlotAreaOASISTContext(
     208                 :            :     XMLTransformerBase & rTransformer, const ::rtl::OUString & rQName ) :
     209                 :          0 :         XMLProcAttrTransformerContext( rTransformer, rQName, OASIS_SHAPE_ACTIONS )
     210                 :            : {
     211                 :          0 : }
     212                 :            : 
     213         [ #  # ]:          0 : XMLChartPlotAreaOASISTContext::~XMLChartPlotAreaOASISTContext()
     214         [ #  # ]:          0 : {}
     215                 :            : 
     216                 :          0 : XMLTransformerContext * XMLChartPlotAreaOASISTContext::CreateChildContext(
     217                 :            :     sal_uInt16 nPrefix,
     218                 :            :     const ::rtl::OUString& rLocalName,
     219                 :            :     const ::rtl::OUString& rQName,
     220                 :            :     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     221                 :            : {
     222                 :          0 :     XMLTransformerContext *pContext = 0;
     223                 :            : 
     224   [ #  #  #  # ]:          0 :     if( XML_NAMESPACE_CHART == nPrefix &&
                 [ #  # ]
     225                 :          0 :         IsXMLToken( rLocalName, XML_AXIS ) )
     226                 :            :     {
     227         [ #  # ]:          0 :         pContext = new XMLAxisOASISContext( GetTransformer(), rQName, m_rCategoriesContext );
     228                 :            :     }
     229                 :            :     else
     230                 :            :     {
     231                 :            :         // export (and forget) categories if found in an axis-element
     232                 :            :         // otherwise export regularly
     233                 :          0 :         ExportCategories();
     234                 :            :         pContext =  XMLProcAttrTransformerContext::CreateChildContext(
     235                 :          0 :                 nPrefix, rLocalName, rQName, xAttrList );
     236                 :            :     }
     237                 :            : 
     238                 :          0 :     return pContext;
     239                 :            : }
     240                 :            : 
     241                 :          0 : void XMLChartPlotAreaOASISTContext::EndElement()
     242                 :            : {
     243                 :          0 :     ExportCategories();
     244                 :          0 :     XMLProcAttrTransformerContext::EndElement();
     245                 :          0 : }
     246                 :            : 
     247                 :          0 : void XMLChartPlotAreaOASISTContext::ExportCategories()
     248                 :            : {
     249         [ #  # ]:          0 :     if( m_rCategoriesContext.is())
     250                 :            :     {
     251                 :          0 :         m_rCategoriesContext->Export();
     252                 :          0 :         m_rCategoriesContext.clear();
     253                 :            :     }
     254                 :          0 : }
     255                 :            : 
     256                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10