LCOV - code coverage report
Current view: top level - xmloff/source/chart - contexts.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 61 72.1 %
Date: 2012-08-25 Functions: 13 26 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 18 81 22.2 %

           Branch data     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                 :            : // ==================================================
      35                 :            : 
      36                 :            : class SchXMLBodyContext_Impl : public SvXMLImportContext
      37                 :            : {
      38                 :            : private:
      39                 :            :     SchXMLImportHelper& mrImportHelper;
      40                 :            : 
      41                 :            : public:
      42                 :            : 
      43                 :            :     SchXMLBodyContext_Impl( SchXMLImportHelper& rImpHelper,
      44                 :            :                 SvXMLImport& rImport, sal_uInt16 nPrfx,
      45                 :            :                 const ::rtl::OUString& rLName );
      46                 :            :     virtual ~SchXMLBodyContext_Impl();
      47                 :            : 
      48                 :            :     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
      49                 :            :             const ::rtl::OUString& rLocalName,
      50                 :            :                 const uno::Reference< xml::sax::XAttributeList > & xAttrList );
      51                 :            : };
      52                 :            : 
      53                 :          6 : SchXMLBodyContext_Impl::SchXMLBodyContext_Impl(
      54                 :            :         SchXMLImportHelper& rImpHelper, SvXMLImport& rImport,
      55                 :            :         sal_uInt16 nPrfx, const ::rtl::OUString& rLName ) :
      56                 :            :     SvXMLImportContext( rImport, nPrfx, rLName ),
      57                 :          6 :     mrImportHelper( rImpHelper )
      58                 :            : {
      59                 :          6 : }
      60                 :            : 
      61                 :          6 : SchXMLBodyContext_Impl::~SchXMLBodyContext_Impl()
      62                 :            : {
      63         [ -  + ]:         12 : }
      64                 :            : 
      65                 :          6 : SvXMLImportContext *SchXMLBodyContext_Impl::CreateChildContext(
      66                 :            :         sal_uInt16 nPrefix,
      67                 :            :         const ::rtl::OUString& rLocalName,
      68                 :            :         const uno::Reference< xml::sax::XAttributeList > & )
      69                 :            : {
      70                 :          6 :     return new SchXMLBodyContext( mrImportHelper, GetImport(), nPrefix,
      71         [ +  - ]:          6 :                                   rLocalName );
      72                 :            : }
      73                 :            : 
      74                 :            : // ==================================================
      75                 :            : 
      76                 :         12 : SchXMLDocContext::SchXMLDocContext( SchXMLImportHelper& rImpHelper,
      77                 :            :                                     SvXMLImport& rImport,
      78                 :            :                                     sal_uInt16 nPrefix,
      79                 :            :                                     const rtl::OUString& rLName ) :
      80                 :            :         SvXMLImportContext( rImport, nPrefix, rLName ),
      81                 :         12 :         mrImportHelper( rImpHelper )
      82                 :            : {
      83                 :            :     DBG_ASSERT( XML_NAMESPACE_OFFICE == nPrefix &&
      84                 :            :         ( IsXMLToken( rLName, XML_DOCUMENT ) ||
      85                 :            :           IsXMLToken( rLName, XML_DOCUMENT_META) ||
      86                 :            :           IsXMLToken( rLName, XML_DOCUMENT_STYLES) ||
      87                 :            :           IsXMLToken( rLName, XML_DOCUMENT_CONTENT) ),
      88                 :            :                 "SchXMLDocContext instanciated with no <office:document> element" );
      89                 :         12 : }
      90                 :            : 
      91                 :         12 : SchXMLDocContext::~SchXMLDocContext()
      92 [ +  - ][ -  + ]:         36 : {}
         [ #  # ][ #  # ]
      93                 :            : 
      94 [ #  # ][ #  # ]:          0 : TYPEINIT1( SchXMLDocContext, SvXMLImportContext );
      95                 :            : 
      96                 :         18 : SvXMLImportContext* SchXMLDocContext::CreateChildContext(
      97                 :            :     sal_uInt16 nPrefix,
      98                 :            :     const ::rtl::OUString& rLocalName,
      99                 :            :     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     100                 :            : {
     101                 :         18 :     SvXMLImportContext* pContext = 0;
     102                 :         18 :     const SvXMLTokenMap& rTokenMap = mrImportHelper.GetDocElemTokenMap();
     103                 :         18 :     sal_uInt16 nFlags = GetImport().getImportFlags();
     104                 :            : 
     105   [ +  +  -  +  :         18 :     switch( rTokenMap.Get( nPrefix, rLocalName ))
                      - ]
     106                 :            :     {
     107                 :            :         case XML_TOK_DOC_AUTOSTYLES:
     108         [ +  - ]:          6 :             if( nFlags & IMPORT_AUTOSTYLES )
     109                 :            :                 // not nice, but this is safe, as the SchXMLDocContext class can only by
     110                 :            :                 // instantiated by the chart import class SchXMLImport (header is not exported)
     111                 :            :                 pContext =
     112                 :          6 :                     static_cast< SchXMLImport& >( GetImport() ).CreateStylesContext( rLocalName, xAttrList );
     113                 :          6 :             break;
     114                 :            :         case XML_TOK_DOC_STYLES:
     115                 :            :             // for draw styles containing gradients/hatches/markers and dashes
     116         [ +  - ]:          6 :             if( nFlags & IMPORT_STYLES )
     117         [ +  - ]:          6 :                 pContext = new SvXMLStylesContext( GetImport(), nPrefix, rLocalName, xAttrList );
     118                 :          6 :             break;
     119                 :            :         case XML_TOK_DOC_META:
     120                 :            :           // we come here in the flat ODF file format,
     121                 :            :           // if XDocumentPropertiesSupplier is not supported at the model
     122                 :            : //        DBG_WARNING("XML_TOK_DOC_META: should not have come here, maybe document is invalid?");
     123                 :          0 :             pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
     124                 :          0 :             break;
     125                 :            :         case XML_TOK_DOC_BODY:
     126         [ +  - ]:          6 :             if( nFlags & IMPORT_CONTENT )
     127         [ +  - ]:          6 :                 pContext = new SchXMLBodyContext_Impl( mrImportHelper, GetImport(), nPrefix, rLocalName );
     128                 :          6 :             break;
     129                 :            :     }
     130                 :            : 
     131                 :            :     // call parent when no own context was created
     132         [ -  + ]:         18 :     if( ! pContext )
     133                 :          0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
     134                 :            : 
     135                 :         18 :     return pContext;
     136                 :            : }
     137                 :            : 
     138                 :            : // ==================================================
     139                 :            : 
     140                 :          0 : SchXMLFlatDocContext_Impl::SchXMLFlatDocContext_Impl(
     141                 :            :         SchXMLImportHelper& i_rImpHelper,
     142                 :            :         SchXMLImport& i_rImport,
     143                 :            :         sal_uInt16 i_nPrefix, const ::rtl::OUString & i_rLName,
     144                 :            :         const uno::Reference<document::XDocumentProperties>& i_xDocProps,
     145                 :            :         const uno::Reference<xml::sax::XDocumentHandler>& i_xDocBuilder) :
     146                 :            :     SvXMLImportContext(i_rImport, i_nPrefix, i_rLName),
     147                 :            :     SchXMLDocContext(i_rImpHelper, i_rImport, i_nPrefix, i_rLName),
     148                 :            :     SvXMLMetaDocumentContext(i_rImport, i_nPrefix, i_rLName,
     149 [ #  # ][ #  # ]:          0 :         i_xDocProps, i_xDocBuilder)
         [ #  # ][ #  # ]
     150                 :            : {
     151                 :          0 : }
     152                 :            : 
     153 [ #  # ][ #  # ]:          0 : SchXMLFlatDocContext_Impl::~SchXMLFlatDocContext_Impl() { }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     154                 :            : 
     155                 :            : 
     156                 :          0 : SvXMLImportContext *SchXMLFlatDocContext_Impl::CreateChildContext(
     157                 :            :     sal_uInt16 i_nPrefix, const ::rtl::OUString& i_rLocalName,
     158                 :            :     const uno::Reference<xml::sax::XAttributeList>& i_xAttrList)
     159                 :            : {
     160                 :            :     // behave like meta base class iff we encounter office:meta
     161                 :            :     const SvXMLTokenMap& rTokenMap =
     162                 :          0 :         mrImportHelper.GetDocElemTokenMap();
     163         [ #  # ]:          0 :     if ( XML_TOK_DOC_META == rTokenMap.Get( i_nPrefix, i_rLocalName ) ) {
     164                 :            :         return SvXMLMetaDocumentContext::CreateChildContext(
     165                 :          0 :                     i_nPrefix, i_rLocalName, i_xAttrList );
     166                 :            :     } else {
     167                 :            :         return SchXMLDocContext::CreateChildContext(
     168                 :          0 :                     i_nPrefix, i_rLocalName, i_xAttrList );
     169                 :            :     }
     170                 :            : }
     171                 :            : 
     172                 :            : // ----------------------------------------
     173                 :            : 
     174                 :          6 : SchXMLBodyContext::SchXMLBodyContext( SchXMLImportHelper& rImpHelper,
     175                 :            :                                       SvXMLImport& rImport,
     176                 :            :                                       sal_uInt16 nPrefix,
     177                 :            :                                       const rtl::OUString& rLName ) :
     178                 :            :         SvXMLImportContext( rImport, nPrefix, rLName ),
     179                 :          6 :         mrImportHelper( rImpHelper )
     180                 :            : {
     181                 :            :     DBG_ASSERT( XML_NAMESPACE_OFFICE == nPrefix &&
     182                 :            :                 IsXMLToken( rLName, XML_CHART ),
     183                 :            :                 "SchXMLBodyContext instanciated with no <office:chart> element" );
     184                 :          6 : }
     185                 :            : 
     186                 :          6 : SchXMLBodyContext::~SchXMLBodyContext()
     187         [ -  + ]:         12 : {}
     188                 :            : 
     189                 :          6 : void SchXMLBodyContext::EndElement()
     190                 :            : {
     191                 :          6 : }
     192                 :            : 
     193                 :          6 : SvXMLImportContext* SchXMLBodyContext::CreateChildContext(
     194                 :            :     sal_uInt16 nPrefix,
     195                 :            :     const rtl::OUString& rLocalName,
     196                 :            :     const uno::Reference< xml::sax::XAttributeList >& xAttrList )
     197                 :            : {
     198                 :          6 :     SvXMLImportContext* pContext = 0;
     199                 :            : 
     200                 :            :     // <chart:chart> element
     201   [ +  -  +  - ]:         12 :     if( nPrefix == XML_NAMESPACE_CHART &&
                 [ +  - ]
     202                 :          6 :         IsXMLToken( rLocalName, XML_CHART ) )
     203                 :            :     {
     204                 :          6 :         pContext = mrImportHelper.CreateChartContext( GetImport(),
     205                 :            :                                                       nPrefix, rLocalName,
     206                 :          6 :                                                       GetImport().GetModel(),
     207         [ +  - ]:         12 :                                                       xAttrList );
     208                 :            :     }
     209   [ #  #  #  # ]:          0 :     else if(nPrefix == XML_NAMESPACE_TABLE &&
                 [ #  # ]
     210                 :          0 :             IsXMLToken( rLocalName, XML_CALCULATION_SETTINGS ))
     211                 :            :     {
     212                 :            :         // i99104 handle null date correctly
     213         [ #  # ]:          0 :         pContext = new SchXMLCalculationSettingsContext ( GetImport(), nPrefix, rLocalName, xAttrList);
     214                 :            :     }
     215                 :            :     else
     216                 :            :     {
     217                 :          0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
     218                 :            :     }
     219                 :            : 
     220                 :          6 :     return pContext;
     221                 :            : }
     222                 :            : 
     223                 :            : 
     224                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10