LCOV - code coverage report
Current view: top level - sc/source/filter/excel - expop2.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 39 46 84.8 %
Date: 2015-06-13 12:38:46 Functions: 7 9 77.8 %
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 <unotools/fltrcfg.hxx>
      21             : 
      22             : #include <sfx2/objsh.hxx>
      23             : #include <sfx2/docinf.hxx>
      24             : #include <filter/msfilter/svxmsbas.hxx>
      25             : 
      26             : #include "scerrors.hxx"
      27             : #include "scextopt.hxx"
      28             : 
      29             : #include "root.hxx"
      30             : #include "excdoc.hxx"
      31             : #include "exp_op.hxx"
      32             : 
      33             : #include "xcl97esc.hxx"
      34             : 
      35             : #include "document.hxx"
      36             : #include "rangenam.hxx"
      37             : #include "filtopt.hxx"
      38             : #include "xltools.hxx"
      39             : #include "xelink.hxx"
      40             : 
      41             : #include <com/sun/star/document/XDocumentProperties.hpp>
      42             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      43             : 
      44          17 : ExportBiff5::ExportBiff5( XclExpRootData& rExpData, SvStream& rStrm ):
      45             :     ExportTyp( rStrm, &rExpData.mrDoc, rExpData.meTextEnc ),
      46          17 :     XclExpRoot( rExpData )
      47             : {
      48             :     // only need part of the Root data
      49          17 :     pExcRoot = &GetOldRoot();
      50          17 :     pExcRoot->pER = this;   // ExcRoot -> XclExpRoot
      51          17 :     pExcRoot->eDateiTyp = Biff5;
      52          17 :     pExcDoc = new ExcDocument( *this );
      53          17 : }
      54             : 
      55          34 : ExportBiff5::~ExportBiff5()
      56             : {
      57          17 :     delete pExcDoc;
      58          17 : }
      59             : 
      60          17 : FltError ExportBiff5::Write()
      61             : {
      62          17 :     SfxObjectShell* pDocShell = GetDocShell();
      63             :     OSL_ENSURE( pDocShell, "ExportBiff5::Write - no document shell" );
      64             : 
      65          17 :     tools::SvRef<SotStorage> xRootStrg = GetRootStorage();
      66             :     OSL_ENSURE( xRootStrg.Is(), "ExportBiff5::Write - no root storage" );
      67             : 
      68          17 :     bool bWriteBasicStrg = false;
      69          17 :     if( GetBiff() == EXC_BIFF8 )
      70             :     {
      71          17 :         const SvtFilterOptions& rFilterOpt = SvtFilterOptions::Get();
      72          17 :         bWriteBasicStrg = rFilterOpt.IsLoadExcelBasicStorage();
      73             :     }
      74             : 
      75          17 :     if( pDocShell && xRootStrg.Is() && bWriteBasicStrg )
      76             :     {
      77          17 :         SvxImportMSVBasic aBasicImport( *pDocShell, *xRootStrg );
      78          17 :         sal_uLong nErr = aBasicImport.SaveOrDelMSVBAStorage( true, EXC_STORAGE_VBA_PROJECT );
      79          17 :         if( nErr != ERRCODE_NONE )
      80           0 :             pDocShell->SetError( nErr, OUString( OSL_LOG_PREFIX ) );
      81             :     }
      82             : 
      83          17 :     pExcDoc->ReadDoc();         // ScDoc -> ExcDoc
      84          17 :     pExcDoc->Write( aOut );     // wechstreamen
      85             : 
      86          17 :     if( pDocShell && xRootStrg.Is() )
      87             :     {
      88             :         using namespace ::com::sun::star;
      89             :         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
      90          17 :                 pDocShell->GetModel(), uno::UNO_QUERY_THROW);
      91             :         uno::Reference<document::XDocumentProperties> xDocProps
      92          34 :                 = xDPS->getDocumentProperties();
      93          17 :         if ( SvtFilterOptions::Get().IsEnableCalcPreview() )
      94             :         {
      95             :             std::shared_ptr<GDIMetaFile> xMetaFile =
      96           0 :                 pDocShell->GetPreviewMetaFile (false);
      97             :             uno::Sequence<sal_uInt8> metaFile(
      98           0 :                 sfx2::convertMetaFile(xMetaFile.get()));
      99           0 :             sfx2::SaveOlePropertySet(xDocProps, xRootStrg, &metaFile);
     100             :         }
     101             :         else
     102          34 :             sfx2::SaveOlePropertySet(xDocProps, xRootStrg );
     103             :     }
     104             : 
     105          17 :     const XclExpAddressConverter& rAddrConv = GetAddressConverter();
     106          17 :     if( rAddrConv.IsRowTruncated() )
     107           0 :         return SCWARN_EXPORT_MAXROW;
     108          17 :     if( rAddrConv.IsColTruncated() )
     109           0 :         return SCWARN_EXPORT_MAXCOL;
     110          17 :     if( rAddrConv.IsTabTruncated() )
     111           0 :         return SCWARN_EXPORT_MAXTAB;
     112             : 
     113          17 :     return eERR_OK;
     114             : }
     115             : 
     116          17 : ExportBiff8::ExportBiff8( XclExpRootData& rExpData, SvStream& rStrm ) :
     117          17 :     ExportBiff5( rExpData, rStrm )
     118             : {
     119          17 :     pExcRoot->eDateiTyp = Biff8;
     120          17 : }
     121             : 
     122          17 : ExportBiff8::~ExportBiff8()
     123             : {
     124          47 : }
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11