LCOV - code coverage report
Current view: top level - xmloff/source/chart - contexts.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 53 61 86.9 %
Date: 2014-11-03 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         244 : SchXMLBodyContext_Impl::SchXMLBodyContext_Impl(
      52             :         SchXMLImportHelper& rImpHelper, SvXMLImport& rImport,
      53             :         sal_uInt16 nPrfx, const OUString& rLName ) :
      54             :     SvXMLImportContext( rImport, nPrfx, rLName ),
      55         244 :     mrImportHelper( rImpHelper )
      56             : {
      57         244 : }
      58             : 
      59         488 : SchXMLBodyContext_Impl::~SchXMLBodyContext_Impl()
      60             : {
      61         488 : }
      62             : 
      63         244 : SvXMLImportContext *SchXMLBodyContext_Impl::CreateChildContext(
      64             :         sal_uInt16 nPrefix,
      65             :         const OUString& rLocalName,
      66             :         const uno::Reference< xml::sax::XAttributeList > & )
      67             : {
      68         244 :     return new SchXMLBodyContext( mrImportHelper, GetImport(), nPrefix,
      69         244 :                                   rLocalName );
      70             : }
      71             : 
      72         486 : SchXMLDocContext::SchXMLDocContext( SchXMLImportHelper& rImpHelper,
      73             :                                     SvXMLImport& rImport,
      74             :                                     sal_uInt16 nPrefix,
      75             :                                     const OUString& rLName ) :
      76             :         SvXMLImportContext( rImport, nPrefix, rLName ),
      77         486 :         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         486 : }
      85             : 
      86         970 : SchXMLDocContext::~SchXMLDocContext()
      87         970 : {}
      88             : 
      89           0 : TYPEINIT1( SchXMLDocContext, SvXMLImportContext );
      90             : 
      91         732 : SvXMLImportContext* SchXMLDocContext::CreateChildContext(
      92             :     sal_uInt16 nPrefix,
      93             :     const OUString& rLocalName,
      94             :     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
      95             : {
      96         732 :     SvXMLImportContext* pContext = 0;
      97         732 :     const SvXMLTokenMap& rTokenMap = mrImportHelper.GetDocElemTokenMap();
      98         732 :     sal_uInt16 nFlags = GetImport().getImportFlags();
      99             : 
     100         732 :     switch( rTokenMap.Get( nPrefix, rLocalName ))
     101             :     {
     102             :         case XML_TOK_DOC_AUTOSTYLES:
     103         244 :             if( nFlags & IMPORT_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         244 :                     static_cast< SchXMLImport& >( GetImport() ).CreateStylesContext( rLocalName, xAttrList );
     108         244 :             break;
     109             :         case XML_TOK_DOC_STYLES:
     110             :             // for draw styles containing gradients/hatches/markers and dashes
     111         244 :             if( nFlags & IMPORT_STYLES )
     112         244 :                 pContext = new SvXMLStylesContext( GetImport(), nPrefix, rLocalName, xAttrList );
     113         244 :             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         244 :             if( nFlags & IMPORT_CONTENT )
     122         244 :                 pContext = new SchXMLBodyContext_Impl( mrImportHelper, GetImport(), nPrefix, rLocalName );
     123         244 :             break;
     124             :     }
     125             : 
     126             :     // call parent when no own context was created
     127         732 :     if( ! pContext )
     128           0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
     129             : 
     130         732 :     return pContext;
     131             : }
     132             : 
     133           2 : 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           2 :         i_xDocProps)
     142             : {
     143           2 : }
     144             : 
     145           4 : SchXMLFlatDocContext_Impl::~SchXMLFlatDocContext_Impl() { }
     146             : 
     147           8 : 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           8 :         mrImportHelper.GetDocElemTokenMap();
     154           8 :     if ( XML_TOK_DOC_META == rTokenMap.Get( i_nPrefix, i_rLocalName ) ) {
     155             :         return SvXMLMetaDocumentContext::CreateChildContext(
     156           2 :                     i_nPrefix, i_rLocalName, i_xAttrList );
     157             :     } else {
     158             :         return SchXMLDocContext::CreateChildContext(
     159           6 :                     i_nPrefix, i_rLocalName, i_xAttrList );
     160             :     }
     161             : }
     162             : 
     163         244 : SchXMLBodyContext::SchXMLBodyContext( SchXMLImportHelper& rImpHelper,
     164             :                                       SvXMLImport& rImport,
     165             :                                       sal_uInt16 nPrefix,
     166             :                                       const OUString& rLName ) :
     167             :         SvXMLImportContext( rImport, nPrefix, rLName ),
     168         244 :         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         244 : }
     173             : 
     174         488 : SchXMLBodyContext::~SchXMLBodyContext()
     175         488 : {}
     176             : 
     177         244 : void SchXMLBodyContext::EndElement()
     178             : {
     179         244 : }
     180             : 
     181         244 : SvXMLImportContext* SchXMLBodyContext::CreateChildContext(
     182             :     sal_uInt16 nPrefix,
     183             :     const OUString& rLocalName,
     184             :     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     185             : {
     186         244 :     SvXMLImportContext* pContext = 0;
     187             : 
     188             :     // <chart:chart> element
     189         488 :     if( nPrefix == XML_NAMESPACE_CHART &&
     190         244 :         IsXMLToken( rLocalName, XML_CHART ) )
     191             :     {
     192         244 :         pContext = mrImportHelper.CreateChartContext( GetImport(),
     193             :                                                       nPrefix, rLocalName,
     194         244 :                                                       GetImport().GetModel(),
     195         488 :                                                       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         244 :     return pContext;
     209             : }
     210             : 
     211             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10