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

Generated by: LCOV version 1.10