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

Generated by: LCOV version 1.11