LCOV - code coverage report
Current view: top level - sc/source/filter/oox - excelfilter.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 67 0.0 %
Date: 2014-04-14 Functions: 0 22 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 "excelfilter.hxx"
      21             : 
      22             : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      23             : 
      24             : #include "oox/helper/binaryinputstream.hxx"
      25             : #include "biffinputstream.hxx"
      26             : #include "excelchartconverter.hxx"
      27             : #include "excelvbaproject.hxx"
      28             : #include "stylesbuffer.hxx"
      29             : #include "themebuffer.hxx"
      30             : #include "workbookfragment.hxx"
      31             : #include "xestream.hxx"
      32             : 
      33             : namespace oox {
      34             : namespace xls {
      35             : 
      36             : using namespace ::com::sun::star::lang;
      37             : using namespace ::com::sun::star::sheet;
      38             : using namespace ::com::sun::star::uno;
      39             : using namespace ::com::sun::star::xml::sax;
      40             : using namespace ::oox::core;
      41             : 
      42             : using ::oox::drawingml::table::TableStyleListPtr;
      43             : 
      44           0 : OUString ExcelFilter_getImplementationName()
      45             : {
      46           0 :     return OUString( "com.sun.star.comp.oox.xls.ExcelFilter" );
      47             : }
      48             : 
      49           0 : Sequence< OUString > ExcelFilter_getSupportedServiceNames()
      50             : {
      51           0 :     Sequence< OUString > aSeq( 2 );
      52           0 :     aSeq[ 0 ] = "com.sun.star.document.ImportFilter";
      53           0 :     aSeq[ 1 ] = "com.sun.star.document.ExportFilter";
      54           0 :     return aSeq;
      55             : }
      56             : 
      57           0 : Reference< XInterface > ExcelFilter_create(
      58             :         const Reference< XComponentContext >& rxContext )
      59             : {
      60           0 :     return static_cast< ::cppu::OWeakObject* >( new ExcelFilter( rxContext ) );
      61             : }
      62             : 
      63           0 : ExcelFilter::ExcelFilter( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
      64             :     XmlFilterBase( rxContext ),
      65           0 :     mpBookGlob( 0 )
      66             : {
      67           0 : }
      68             : 
      69           0 : ExcelFilter::~ExcelFilter()
      70             : {
      71             :     OSL_ENSURE( !mpBookGlob, "ExcelFilter::~ExcelFilter - workbook data not cleared" );
      72           0 : }
      73             : 
      74           0 : void ExcelFilter::registerWorkbookGlobals( WorkbookGlobals& rBookGlob )
      75             : {
      76           0 :     mpBookGlob = &rBookGlob;
      77           0 : }
      78             : 
      79           0 : WorkbookGlobals& ExcelFilter::getWorkbookGlobals() const
      80             : {
      81             :     OSL_ENSURE( mpBookGlob, "ExcelFilter::getWorkbookGlobals - missing workbook data" );
      82           0 :     return *mpBookGlob;
      83             : }
      84             : 
      85           0 : void ExcelFilter::unregisterWorkbookGlobals()
      86             : {
      87           0 :     mpBookGlob = 0;
      88           0 : }
      89             : 
      90           0 : bool ExcelFilter::importDocument() throw()
      91             : {
      92             :     /*  To activate the XLSX/XLSB dumper, insert the full path to the file
      93             :         file:///<path-to-oox-module>/source/dump/xlsbdumper.ini
      94             :         into the environment variable OOO_XLSBDUMPER and start the office with
      95             :         this variable (nonpro only). */
      96             :     //OOX_DUMP_FILE( ::oox::dump::xlsb::Dumper );
      97             : 
      98           0 :     OUString aWorkbookPath = getFragmentPathFromFirstTypeFromOfficeDoc( "officeDocument" );
      99           0 :     if( aWorkbookPath.isEmpty() )
     100           0 :         return false;
     101             : 
     102             :     /*  Construct the WorkbookGlobals object referred to by every instance of
     103             :         the class WorkbookHelper, and execute the import filter by constructing
     104             :         an instance of WorkbookFragment and loading the file. */
     105           0 :     WorkbookGlobalsRef xBookGlob;
     106             :     try
     107             :     {
     108           0 :         xBookGlob = WorkbookHelper::constructGlobals( *this );
     109             :     }
     110           0 :     catch (...)
     111             :     {
     112             :     }
     113           0 :     if ( xBookGlob.get() && importFragment( new WorkbookFragment( *xBookGlob, aWorkbookPath ) ) )
     114             :     {
     115             :         try
     116             :         {
     117           0 :             importDocumentProperties();
     118             :         }
     119           0 :         catch( const Exception& e )
     120             :         {
     121             :             SAL_WARN("sc", "exception when importing document properties " << e.Message);
     122             :         }
     123           0 :         catch( ... )
     124             :         {
     125             :             SAL_WARN("sc", "exception when importing document properties");
     126             :         }
     127           0 :         return true;
     128             :     }
     129           0 :     return false;
     130             : }
     131             : 
     132           0 : bool ExcelFilter::exportDocument() throw()
     133             : {
     134           0 :     return false;
     135             : }
     136             : 
     137           0 : const ::oox::drawingml::Theme* ExcelFilter::getCurrentTheme() const
     138             : {
     139           0 :     return &WorkbookHelper( getWorkbookGlobals() ).getTheme();
     140             : }
     141             : 
     142           0 : ::oox::vml::Drawing* ExcelFilter::getVmlDrawing()
     143             : {
     144           0 :     return 0;
     145             : }
     146             : 
     147           0 : const TableStyleListPtr ExcelFilter::getTableStyles()
     148             : {
     149           0 :     return TableStyleListPtr();
     150             : }
     151             : 
     152           0 : ::oox::drawingml::chart::ChartConverter* ExcelFilter::getChartConverter()
     153             : {
     154           0 :     return WorkbookHelper( getWorkbookGlobals() ).getChartConverter();
     155             : }
     156             : 
     157           0 : void ExcelFilter::useInternalChartDataTable( bool bInternal )
     158             : {
     159           0 :     return WorkbookHelper( getWorkbookGlobals() ).useInternalChartDataTable( bInternal );
     160             : }
     161             : 
     162           0 : GraphicHelper* ExcelFilter::implCreateGraphicHelper() const
     163             : {
     164           0 :     return new ExcelGraphicHelper( getWorkbookGlobals() );
     165             : }
     166             : 
     167           0 : ::oox::ole::VbaProject* ExcelFilter::implCreateVbaProject() const
     168             : {
     169           0 :     return new ExcelVbaProject( getComponentContext(), Reference< XSpreadsheetDocument >( getModel(), UNO_QUERY ) );
     170             : }
     171             : 
     172             : 
     173           0 : sal_Bool SAL_CALL ExcelFilter::filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rDescriptor ) throw( ::com::sun::star::uno::RuntimeException, std::exception )
     174             : {
     175           0 :     if ( XmlFilterBase::filter( rDescriptor ) )
     176           0 :         return true;
     177             : 
     178           0 :     if ( isExportFilter() )
     179             :     {
     180             :         Reference< XExporter > xExporter(
     181           0 :             new XclExpXmlStream( getComponentContext() ) );
     182             : 
     183           0 :         Reference< XComponent > xDocument( getModel(), UNO_QUERY );
     184           0 :         Reference< XFilter > xFilter( xExporter, UNO_QUERY );
     185             : 
     186           0 :         if ( xFilter.is() )
     187             :         {
     188           0 :             xExporter->setSourceDocument( xDocument );
     189           0 :             if ( xFilter->filter( rDescriptor ) )
     190           0 :                 return true;
     191           0 :         }
     192             :     }
     193             : 
     194           0 :     return false;
     195             : }
     196             : 
     197           0 : OUString ExcelFilter::implGetImplementationName() const
     198             : {
     199           0 :     return ExcelFilter_getImplementationName();
     200             : }
     201             : 
     202             : } // namespace xls
     203           0 : } // namespace oox
     204             : 
     205             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10