LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/oox - connectionsfragment.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 64 1.6 %
Date: 2012-12-27 Functions: 2 12 16.7 %
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 "connectionsfragment.hxx"
      21             : 
      22             : #include "oox/helper/attributelist.hxx"
      23             : #include "biffhelper.hxx"
      24             : #include "connectionsbuffer.hxx"
      25             : 
      26             : namespace oox {
      27             : namespace xls {
      28             : 
      29             : // ============================================================================
      30             : 
      31             : using namespace ::oox::core;
      32             : 
      33             : using ::rtl::OUString;
      34             : 
      35             : // ============================================================================
      36             : 
      37           0 : ConnectionContext::ConnectionContext( WorkbookFragmentBase& rParent, Connection& rConnection ) :
      38             :     WorkbookContextBase( rParent ),
      39           0 :     mrConnection( rConnection )
      40             : {
      41           0 : }
      42             : 
      43           0 : ContextHandlerRef ConnectionContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      44             : {
      45           0 :     switch( getCurrentElement() )
      46             :     {
      47             :         case XLS_TOKEN( connection ):
      48           0 :             if( nElement == XLS_TOKEN( webPr ) )
      49             :             {
      50           0 :                 mrConnection.importWebPr( rAttribs );
      51           0 :                 return this;
      52             :             }
      53           0 :         break;
      54             : 
      55             :         case XLS_TOKEN( webPr ):
      56           0 :             if( nElement == XLS_TOKEN( tables ) )
      57             :             {
      58           0 :                 mrConnection.importTables( rAttribs );
      59           0 :                 return this;
      60             :             }
      61           0 :         break;
      62             : 
      63             :         case XLS_TOKEN( tables ):
      64           0 :             mrConnection.importTable( rAttribs, nElement );
      65           0 :         break;
      66             :     }
      67           0 :     return 0;
      68             : }
      69             : 
      70           0 : void ConnectionContext::onStartElement( const AttributeList& rAttribs )
      71             : {
      72           0 :     if( getCurrentElement() == XLS_TOKEN( connection ) )
      73           0 :         mrConnection.importConnection( rAttribs );
      74           0 : }
      75             : 
      76           0 : ContextHandlerRef ConnectionContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
      77             : {
      78           0 :     switch( getCurrentElement() )
      79             :     {
      80             :         case BIFF12_ID_CONNECTION:
      81           0 :             if( nRecId == BIFF12_ID_WEBPR )
      82             :             {
      83           0 :                 mrConnection.importWebPr( rStrm );
      84           0 :                 return this;
      85             :             }
      86           0 :         break;
      87             : 
      88             :         case BIFF12_ID_WEBPR:
      89           0 :             if( nRecId == BIFF12_ID_WEBPRTABLES )
      90             :             {
      91           0 :                 mrConnection.importWebPrTables( rStrm );
      92           0 :                 return this;
      93             :             }
      94           0 :         break;
      95             : 
      96             :         case BIFF12_ID_WEBPRTABLES:
      97           0 :             mrConnection.importWebPrTable( rStrm, nRecId );
      98           0 :         break;
      99             :     }
     100           0 :     return 0;
     101             : }
     102             : 
     103           0 : void ConnectionContext::onStartRecord( SequenceInputStream& rStrm )
     104             : {
     105           0 :     if( getCurrentElement() == BIFF12_ID_CONNECTION )
     106           0 :         mrConnection.importConnection( rStrm );
     107           0 : }
     108             : 
     109             : // ============================================================================
     110             : 
     111           0 : ConnectionsFragment::ConnectionsFragment( const WorkbookHelper& rHelper, const OUString& rFragmentPath ) :
     112           0 :     WorkbookFragmentBase( rHelper, rFragmentPath )
     113             : {
     114           0 : }
     115             : 
     116           0 : ContextHandlerRef ConnectionsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
     117             : {
     118           0 :     switch( getCurrentElement() )
     119             :     {
     120             :         case XML_ROOT_CONTEXT:
     121           0 :             if( nElement == XLS_TOKEN( connections ) )
     122           0 :                 return this;
     123           0 :         break;
     124             : 
     125             :         case XLS_TOKEN( connections ):
     126           0 :             if( nElement == XLS_TOKEN( connection ) )
     127           0 :                 return new ConnectionContext( *this, getConnections().createConnection() );
     128           0 :         break;
     129             :     }
     130           0 :     return 0;
     131             : }
     132             : 
     133           0 : ContextHandlerRef ConnectionsFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& /*rStrm*/ )
     134             : {
     135           0 :     switch( getCurrentElement() )
     136             :     {
     137             :         case XML_ROOT_CONTEXT:
     138           0 :             if( nRecId == BIFF12_ID_CONNECTIONS )
     139           0 :                 return this;
     140           0 :         break;
     141             : 
     142             :         case BIFF12_ID_CONNECTIONS:
     143           0 :             if( nRecId == BIFF12_ID_CONNECTION )
     144           0 :                 return new ConnectionContext( *this, getConnections().createConnection() );
     145           0 :         break;
     146             :     }
     147           0 :     return 0;
     148             : }
     149             : 
     150           0 : const RecordInfo* ConnectionsFragment::getRecordInfos() const
     151             : {
     152             :     static const RecordInfo spRecInfos[] =
     153             :     {
     154             :         { BIFF12_ID_CONNECTIONS,    BIFF12_ID_CONNECTIONS + 1   },
     155             :         { BIFF12_ID_CONNECTION,     BIFF12_ID_CONNECTION + 1    },
     156             :         { BIFF12_ID_WEBPR,          BIFF12_ID_WEBPR + 1         },
     157             :         { BIFF12_ID_WEBPRTABLES,    BIFF12_ID_WEBPRTABLES + 1   },
     158             :         { -1,                       -1                          }
     159             :     };
     160           0 :     return spRecInfos;
     161             : }
     162             : 
     163           0 : void ConnectionsFragment::finalizeImport()
     164             : {
     165           0 :     getConnections().finalizeImport();
     166           0 : }
     167             : 
     168             : // ============================================================================
     169             : 
     170             : } // namespace xls
     171           9 : } // namespace oox
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10