LCOV - code coverage report
Current view: top level - xmloff/source/chart - contexts.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 53 61 86.9 %
Date: 2015-06-13 12:38:46 Functions: 19 26 73.1 %
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 <tools/debug.hxx>
      21             : #include <xmloff/xmltoken.hxx>
      22             : #include <xmloff/xmlnmspe.hxx>
      23             : #include <xmloff/xmlmetai.hxx>
      24             : #include <xmloff/xmlstyle.hxx>
      25             : #include "SchXMLImport.hxx"
      26             : #include "SchXMLCalculationSettingsContext.hxx"
      27             : 
      28             : #include "contexts.hxx"
      29             : #include "SchXMLChartContext.hxx"
      30             : 
      31             : using namespace com::sun::star;
      32             : using namespace ::xmloff::token;
      33             : 
      34             : class SchXMLBodyContext_Impl : public SvXMLImportContext
      35             : {
      36             : private:
      37             :     SchXMLImportHelper& mrImportHelper;
      38             : 
      39             : public:
      40             : 
      41             :     SchXMLBodyContext_Impl( SchXMLImportHelper& rImpHelper,
      42             :                 SvXMLImport& rImport, sal_uInt16 nPrfx,
      43             :                 const OUString& rLName );
      44             :     virtual ~SchXMLBodyContext_Impl();
      45             : 
      46             :     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
      47             :             const OUString& rLocalName,
      48             :                 const uno::Reference< xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
      49             : };
      50             : 
      51          86 : SchXMLBodyContext_Impl::SchXMLBodyContext_Impl(
      52             :         SchXMLImportHelper& rImpHelper, SvXMLImport& rImport,
      53             :         sal_uInt16 nPrfx, const OUString& rLName ) :
      54             :     SvXMLImportContext( rImport, nPrfx, rLName ),
      55          86 :     mrImportHelper( rImpHelper )
      56             : {
      57          86 : }
      58             : 
      59         172 : SchXMLBodyContext_Impl::~SchXMLBodyContext_Impl()
      60             : {
      61         172 : }
      62             : 
      63          86 : SvXMLImportContext *SchXMLBodyContext_Impl::CreateChildContext(
      64             :         sal_uInt16 nPrefix,
      65             :         const OUString& rLocalName,
      66             :         const uno::Reference< xml::sax::XAttributeList > & )
      67             : {
      68          86 :     return new SchXMLBodyContext( mrImportHelper, GetImport(), nPrefix,
      69          86 :                                   rLocalName );
      70             : }
      71             : 
      72         171 : SchXMLDocContext::SchXMLDocContext( SchXMLImportHelper& rImpHelper,
      73             :                                     SvXMLImport& rImport,
      74             :                                     sal_uInt16 nPrefix,
      75             :                                     const OUString& rLName ) :
      76             :         SvXMLImportContext( rImport, nPrefix, rLName ),
      77         171 :         mrImportHelper( rImpHelper )
      78             : {
      79             :     SAL_WARN_IF( (XML_NAMESPACE_OFFICE != nPrefix) ||
      80             :         ( !IsXMLToken( rLName, XML_DOCUMENT ) &&
      81             :           !IsXMLToken( rLName, XML_DOCUMENT_META) &&
      82             :           !IsXMLToken( rLName, XML_DOCUMENT_STYLES) &&
      83             :           !IsXMLToken( rLName, XML_DOCUMENT_CONTENT) ), "xmloff.chart", "SchXMLDocContext instantiated with no <office:document> element" );
      84         171 : }
      85             : 
      86         511 : SchXMLDocContext::~SchXMLDocContext()
      87         511 : {}
      88             : 
      89           0 : TYPEINIT1( SchXMLDocContext, SvXMLImportContext );
      90             : 
      91         258 : SvXMLImportContext* SchXMLDocContext::CreateChildContext(
      92             :     sal_uInt16 nPrefix,
      93             :     const OUString& rLocalName,
      94             :     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
      95             : {
      96         258 :     SvXMLImportContext* pContext = 0;
      97         258 :     const SvXMLTokenMap& rTokenMap = mrImportHelper.GetDocElemTokenMap();
      98         258 :     SvXMLImportFlags nFlags = GetImport().getImportFlags();
      99             : 
     100         258 :     switch( rTokenMap.Get( nPrefix, rLocalName ))
     101             :     {
     102             :         case XML_TOK_DOC_AUTOSTYLES:
     103          86 :             if( nFlags & SvXMLImportFlags::AUTOSTYLES )
     104             :                 // not nice, but this is safe, as the SchXMLDocContext class can only by
     105             :                 // instantiated by the chart import class SchXMLImport (header is not exported)
     106             :                 pContext =
     107          86 :                     static_cast< SchXMLImport& >( GetImport() ).CreateStylesContext( rLocalName, xAttrList );
     108          86 :             break;
     109             :         case XML_TOK_DOC_STYLES:
     110             :             // for draw styles containing gradients/hatches/markers and dashes
     111          86 :             if( nFlags & SvXMLImportFlags::STYLES )
     112          86 :                 pContext = new SvXMLStylesContext( GetImport(), nPrefix, rLocalName, xAttrList );
     113          86 :             break;
     114             :         case XML_TOK_DOC_META:
     115             :           // we come here in the flat ODF file format,
     116             :           // if XDocumentPropertiesSupplier is not supported at the model
     117             : //        DBG_WARNING("XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
     118           0 :             pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
     119           0 :             break;
     120             :         case XML_TOK_DOC_BODY:
     121          86 :             if( nFlags & SvXMLImportFlags::CONTENT )
     122          86 :                 pContext = new SchXMLBodyContext_Impl( mrImportHelper, GetImport(), nPrefix, rLocalName );
     123          86 :             break;
     124             :     }
     125             : 
     126             :     // call parent when no own context was created
     127         258 :     if( ! pContext )
     128           0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
     129             : 
     130         258 :     return pContext;
     131             : }
     132             : 
     133           1 : SchXMLFlatDocContext_Impl::SchXMLFlatDocContext_Impl(
     134             :         SchXMLImportHelper& i_rImpHelper,
     135             :         SchXMLImport& i_rImport,
     136             :         sal_uInt16 i_nPrefix, const OUString & i_rLName,
     137             :         const uno::Reference<document::XDocumentProperties>& i_xDocProps) :
     138             :     SvXMLImportContext(i_rImport, i_nPrefix, i_rLName),
     139             :     SchXMLDocContext(i_rImpHelper, i_rImport, i_nPrefix, i_rLName),
     140             :     SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName,
     141           1 :         i_xDocProps)
     142             : {
     143           1 : }
     144             : 
     145           2 : SchXMLFlatDocContext_Impl::~SchXMLFlatDocContext_Impl() { }
     146             : 
     147           4 : SvXMLImportContext *SchXMLFlatDocContext_Impl::CreateChildContext(
     148             :     sal_uInt16 i_nPrefix, const OUString& i_rLocalName,
     149             :     const uno::Reference<xml::sax::XAttributeList>& i_xAttrList)
     150             : {
     151             :     // behave like meta base class iff we encounter office:meta
     152             :     const SvXMLTokenMap& rTokenMap =
     153           4 :         mrImportHelper.GetDocElemTokenMap();
     154           4 :     if ( XML_TOK_DOC_META == rTokenMap.Get( i_nPrefix, i_rLocalName ) ) {
     155             :         return SvXMLMetaDocumentContext::CreateChildContext(
     156           1 :                     i_nPrefix, i_rLocalName, i_xAttrList );
     157             :     } else {
     158             :         return SchXMLDocContext::CreateChildContext(
     159           3 :                     i_nPrefix, i_rLocalName, i_xAttrList );
     160             :     }
     161             : }
     162             : 
     163          86 : SchXMLBodyContext::SchXMLBodyContext( SchXMLImportHelper& rImpHelper,
     164             :                                       SvXMLImport& rImport,
     165             :                                       sal_uInt16 nPrefix,
     166             :                                       const OUString& rLName ) :
     167             :         SvXMLImportContext( rImport, nPrefix, rLName ),
     168          86 :         mrImportHelper( rImpHelper )
     169             : {
     170             :     SAL_WARN_IF( (XML_NAMESPACE_OFFICE != nPrefix) ||
     171             :                 !IsXMLToken( rLName, XML_CHART ), "xmloff.chart", "SchXMLBodyContext instantiated with no <office:chart> element" );
     172          86 : }
     173             : 
     174         172 : SchXMLBodyContext::~SchXMLBodyContext()
     175         172 : {}
     176             : 
     177          86 : void SchXMLBodyContext::EndElement()
     178             : {
     179          86 : }
     180             : 
     181          86 : SvXMLImportContext* SchXMLBodyContext::CreateChildContext(
     182             :     sal_uInt16 nPrefix,
     183             :     const OUString& rLocalName,
     184             :     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     185             : {
     186          86 :     SvXMLImportContext* pContext = 0;
     187             : 
     188             :     // <chart:chart> element
     189         172 :     if( nPrefix == XML_NAMESPACE_CHART &&
     190          86 :         IsXMLToken( rLocalName, XML_CHART ) )
     191             :     {
     192          86 :         pContext = mrImportHelper.CreateChartContext( GetImport(),
     193             :                                                       nPrefix, rLocalName,
     194          86 :                                                       GetImport().GetModel(),
     195         172 :                                                       xAttrList );
     196             :     }
     197           0 :     else if(nPrefix == XML_NAMESPACE_TABLE &&
     198           0 :             IsXMLToken( rLocalName, XML_CALCULATION_SETTINGS ))
     199             :     {
     200             :         // i99104 handle null date correctly
     201           0 :         pContext = new SchXMLCalculationSettingsContext ( GetImport(), nPrefix, rLocalName, xAttrList);
     202             :     }
     203             :     else
     204             :     {
     205           0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
     206             :     }
     207             : 
     208          86 :     return pContext;
     209             : }
     210             : 
     211             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11