LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xerecord.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 133 0.0 %
Date: 2014-04-14 Functions: 0 45 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 "xerecord.hxx"
      21             : #include "xeroot.hxx"
      22             : 
      23             : using namespace ::oox;
      24             : 
      25             : // Base classes to export Excel records =======================================
      26             : 
      27           0 : XclExpRecordBase::~XclExpRecordBase()
      28             : {
      29           0 : }
      30             : 
      31           0 : void XclExpRecordBase::Save( XclExpStream& /*rStrm*/ )
      32             : {
      33           0 : }
      34             : 
      35           0 : void XclExpRecordBase::SaveXml( XclExpXmlStream& /*rStrm*/ )
      36             : {
      37           0 : }
      38             : 
      39           0 : XclExpDelegatingRecord::XclExpDelegatingRecord( XclExpRecordBase* pRecord ) :
      40           0 :     mpRecord( pRecord )
      41             : {
      42           0 : }
      43             : 
      44           0 : XclExpDelegatingRecord::~XclExpDelegatingRecord()
      45             : {
      46             :     // Do Nothing; we use Delegating Record for other objects we "know" will
      47             :     // survive...
      48           0 : }
      49             : 
      50           0 : void XclExpDelegatingRecord::SaveXml( XclExpXmlStream& rStrm )
      51             : {
      52           0 :     if( mpRecord )
      53           0 :         mpRecord->SaveXml( rStrm );
      54           0 : }
      55             : 
      56           0 : XclExpXmlElementRecord::XclExpXmlElementRecord(sal_Int32 const nElement)
      57           0 :     : mnElement( nElement )
      58             : {
      59           0 : }
      60             : 
      61           0 : XclExpXmlElementRecord::~XclExpXmlElementRecord()
      62             : {
      63           0 : }
      64             : 
      65           0 : XclExpXmlStartElementRecord::XclExpXmlStartElementRecord(sal_Int32 const nElement)
      66           0 :     : XclExpXmlElementRecord(nElement)
      67             : {
      68           0 : }
      69             : 
      70           0 : XclExpXmlStartElementRecord::~XclExpXmlStartElementRecord()
      71             : {
      72           0 : }
      73             : 
      74           0 : void XclExpXmlStartElementRecord::SaveXml( XclExpXmlStream& rStrm )
      75             : {
      76           0 :     sax_fastparser::FSHelperPtr& rStream = rStrm.GetCurrentStream();
      77             :     // TODO: no generic way to add attributes here, but it appears to
      78             :     // not be needed yet
      79           0 :     rStream->startElement( mnElement, FSEND );
      80           0 : }
      81             : 
      82           0 : XclExpXmlEndElementRecord::XclExpXmlEndElementRecord( sal_Int32 nElement )
      83           0 :     : XclExpXmlElementRecord( nElement )
      84             : {
      85           0 : }
      86             : 
      87           0 : XclExpXmlEndElementRecord::~XclExpXmlEndElementRecord()
      88             : {
      89           0 : }
      90             : 
      91           0 : void XclExpXmlEndElementRecord::SaveXml( XclExpXmlStream& rStrm )
      92             : {
      93           0 :     rStrm.GetCurrentStream()->endElement( mnElement );
      94           0 : }
      95             : 
      96           0 : XclExpXmlStartSingleElementRecord::XclExpXmlStartSingleElementRecord(
      97             :             sal_Int32 const nElement)
      98           0 :     : XclExpXmlElementRecord( nElement )
      99             : {
     100           0 : }
     101             : 
     102           0 : XclExpXmlStartSingleElementRecord::~XclExpXmlStartSingleElementRecord()
     103             : {
     104           0 : }
     105             : 
     106           0 : void XclExpXmlStartSingleElementRecord::SaveXml( XclExpXmlStream& rStrm )
     107             : {
     108           0 :     sax_fastparser::FSHelperPtr& rStream = rStrm.GetCurrentStream();
     109           0 :     rStream->write( "<" )->writeId( mnElement );
     110           0 : }
     111             : 
     112           0 : XclExpXmlEndSingleElementRecord::XclExpXmlEndSingleElementRecord()
     113             : {
     114           0 : }
     115             : 
     116           0 : XclExpXmlEndSingleElementRecord::~XclExpXmlEndSingleElementRecord()
     117             : {
     118           0 : }
     119             : 
     120           0 : void XclExpXmlEndSingleElementRecord::SaveXml( XclExpXmlStream& rStrm )
     121             : {
     122           0 :     rStrm.GetCurrentStream()->write( "/>" );
     123           0 : }
     124             : 
     125           0 : XclExpRecord::XclExpRecord( sal_uInt16 nRecId, sal_Size nRecSize ) :
     126             :     mnRecSize( nRecSize ),
     127           0 :     mnRecId( nRecId )
     128             : {
     129           0 : }
     130             : 
     131           0 : XclExpRecord::~XclExpRecord()
     132             : {
     133           0 : }
     134             : 
     135           0 : void XclExpRecord::SetRecHeader( sal_uInt16 nRecId, sal_Size nRecSize )
     136             : {
     137           0 :     SetRecId( nRecId );
     138           0 :     SetRecSize( nRecSize );
     139           0 : }
     140             : 
     141           0 : void XclExpRecord::WriteBody( XclExpStream& /*rStrm*/ )
     142             : {
     143           0 : }
     144             : 
     145           0 : void XclExpRecord::Save( XclExpStream& rStrm )
     146             : {
     147             :     OSL_ENSURE( mnRecId != EXC_ID_UNKNOWN, "XclExpRecord::Save - record ID uninitialized" );
     148           0 :     rStrm.StartRecord( mnRecId, mnRecSize );
     149           0 :     WriteBody( rStrm );
     150           0 :     rStrm.EndRecord();
     151           0 : }
     152             : 
     153             : template<>
     154           0 : void XclExpValueRecord<double>::SaveXml( XclExpXmlStream& rStrm )
     155             : {
     156           0 :     if( mnAttribute == -1 )
     157           0 :         return;
     158             :     rStrm.WriteAttributes(
     159             :         mnAttribute,    OString::number( maValue ).getStr(),
     160           0 :         FSEND );
     161             : }
     162             : 
     163           0 : void XclExpBoolRecord::WriteBody( XclExpStream& rStrm )
     164             : {
     165           0 :     rStrm << (static_cast< sal_uInt16 >( mbValue ? 1 : 0 ));
     166           0 : }
     167             : 
     168           0 : void XclExpBoolRecord::SaveXml( XclExpXmlStream& rStrm )
     169             : {
     170           0 :     if( mnAttribute == -1 )
     171           0 :         return;
     172             : 
     173             :     rStrm.WriteAttributes(
     174             :             // HACK: HIDEOBJ (excdoc.cxx) should be its own object to handle XML_showObjects
     175           0 :             mnAttribute, mnAttribute == XML_showObjects ? "all" : XclXmlUtils::ToPsz( mbValue ),
     176           0 :             FSEND );
     177             : }
     178             : 
     179           0 : XclExpDummyRecord::XclExpDummyRecord( sal_uInt16 nRecId, const void* pRecData, sal_Size nRecSize ) :
     180           0 :     XclExpRecord( nRecId )
     181             : {
     182           0 :     SetData( pRecData, nRecSize );
     183           0 : }
     184             : 
     185           0 : void XclExpDummyRecord::SetData( const void* pRecData, sal_Size nRecSize )
     186             : {
     187           0 :     mpData = pRecData;
     188           0 :     SetRecSize( pRecData ? nRecSize : 0 );
     189           0 : }
     190             : 
     191           0 : void XclExpDummyRecord::WriteBody( XclExpStream& rStrm )
     192             : {
     193           0 :     rStrm.Write( mpData, GetRecSize() );
     194           0 : }
     195             : 
     196             : // Future records =============================================================
     197             : 
     198           0 : XclExpFutureRecord::XclExpFutureRecord( XclFutureRecType eRecType, sal_uInt16 nRecId, sal_Size nRecSize ) :
     199             :     XclExpRecord( nRecId, nRecSize ),
     200           0 :     meRecType( eRecType )
     201             : {
     202           0 : }
     203             : 
     204           0 : void XclExpFutureRecord::Save( XclExpStream& rStrm )
     205             : {
     206           0 :     rStrm.StartRecord( GetRecId(), GetRecSize() + ((meRecType == EXC_FUTUREREC_UNUSEDREF) ? 12 : 4) );
     207           0 :     rStrm << GetRecId() << sal_uInt16( 0 );
     208           0 :     if( meRecType == EXC_FUTUREREC_UNUSEDREF )
     209           0 :         rStrm.WriteZeroBytes( 8 );
     210           0 :     WriteBody( rStrm );
     211           0 :     rStrm.EndRecord();
     212           0 : }
     213             : 
     214           0 : XclExpSubStream::XclExpSubStream( sal_uInt16 nSubStrmType ) :
     215           0 :     mnSubStrmType( nSubStrmType )
     216             : {
     217           0 : }
     218             : 
     219           0 : void XclExpSubStream::Save( XclExpStream& rStrm )
     220             : {
     221             :     // BOF record
     222           0 :     switch( rStrm.GetRoot().GetBiff() )
     223             :     {
     224             :         case EXC_BIFF2:
     225           0 :             rStrm.StartRecord( EXC_ID2_BOF, 4 );
     226           0 :             rStrm << sal_uInt16( 7 ) << mnSubStrmType;
     227           0 :             rStrm.EndRecord();
     228           0 :         break;
     229             :         case EXC_BIFF3:
     230           0 :             rStrm.StartRecord( EXC_ID3_BOF, 6 );
     231           0 :             rStrm << sal_uInt16( 0 ) << mnSubStrmType << sal_uInt16( 2104 );
     232           0 :             rStrm.EndRecord();
     233           0 :         break;
     234             :         case EXC_BIFF4:
     235           0 :             rStrm.StartRecord( EXC_ID4_BOF, 6 );
     236           0 :             rStrm << sal_uInt16( 0 ) << mnSubStrmType << sal_uInt16( 1705 );
     237           0 :             rStrm.EndRecord();
     238           0 :         break;
     239             :         case EXC_BIFF5:
     240           0 :             rStrm.StartRecord( EXC_ID5_BOF, 8 );
     241           0 :             rStrm << EXC_BOF_BIFF5 << mnSubStrmType << sal_uInt16( 4915 ) << sal_uInt16( 1994 );
     242           0 :             rStrm.EndRecord();
     243           0 :         break;
     244             :         case EXC_BIFF8:
     245           0 :             rStrm.StartRecord( EXC_ID5_BOF, 16 );
     246           0 :             rStrm << EXC_BOF_BIFF8 << mnSubStrmType << sal_uInt16( 3612 ) << sal_uInt16( 1996 );
     247           0 :             rStrm << sal_uInt32( 1 ) << sal_uInt32( 6 );
     248           0 :             rStrm.EndRecord();
     249           0 :         break;
     250             :         default:
     251             :             DBG_ERROR_BIFF();
     252             :     }
     253             : 
     254             :     // substream records
     255           0 :     XclExpRecordList<>::Save( rStrm );
     256             : 
     257             :     // EOF record
     258           0 :     rStrm.StartRecord( EXC_ID_EOF, 0 );
     259           0 :     rStrm.EndRecord();
     260           0 : }
     261             : 
     262             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10