LCOV - code coverage report
Current view: top level - sc/source/filter/oox - excelfilter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 42 68 61.8 %
Date: 2012-08-25 Functions: 16 24 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 102 24.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "excelfilter.hxx"
      30                 :            : 
      31                 :            : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
      32                 :            : #include "oox/helper/binaryinputstream.hxx"
      33                 :            : #include "biffinputstream.hxx"
      34                 :            : #include "excelchartconverter.hxx"
      35                 :            : #include "excelvbaproject.hxx"
      36                 :            : #include "stylesbuffer.hxx"
      37                 :            : #include "themebuffer.hxx"
      38                 :            : #include "workbookfragment.hxx"
      39                 :            : 
      40                 :            : namespace oox {
      41                 :            : namespace xls {
      42                 :            : 
      43                 :            : // ============================================================================
      44                 :            : 
      45                 :            : using namespace ::com::sun::star::lang;
      46                 :            : using namespace ::com::sun::star::sheet;
      47                 :            : using namespace ::com::sun::star::uno;
      48                 :            : using namespace ::com::sun::star::xml::sax;
      49                 :            : using namespace ::oox::core;
      50                 :            : 
      51                 :            : using ::rtl::OUString;
      52                 :            : using ::oox::drawingml::table::TableStyleListPtr;
      53                 :            : 
      54                 :            : // ============================================================================
      55                 :            : 
      56                 :         24 : ExcelFilterBase::ExcelFilterBase() :
      57                 :         24 :     mpBookGlob( 0 )
      58                 :            : {
      59                 :         24 : }
      60                 :            : 
      61                 :         24 : ExcelFilterBase::~ExcelFilterBase()
      62                 :            : {
      63                 :            :     OSL_ENSURE( !mpBookGlob, "ExcelFilterBase::~ExcelFilterBase - workbook data not cleared" );
      64         [ -  + ]:         24 : }
      65                 :            : 
      66                 :         24 : void ExcelFilterBase::registerWorkbookGlobals( WorkbookGlobals& rBookGlob )
      67                 :            : {
      68                 :         24 :     mpBookGlob = &rBookGlob;
      69                 :         24 : }
      70                 :            : 
      71                 :         24 : WorkbookGlobals& ExcelFilterBase::getWorkbookGlobals() const
      72                 :            : {
      73                 :            :     OSL_ENSURE( mpBookGlob, "ExcelFilterBase::getWorkbookGlobals - missing workbook data" );
      74                 :         24 :     return *mpBookGlob;
      75                 :            : }
      76                 :            : 
      77                 :         24 : void ExcelFilterBase::unregisterWorkbookGlobals()
      78                 :            : {
      79                 :         24 :     mpBookGlob = 0;
      80                 :         24 : }
      81                 :            : 
      82                 :            : // ============================================================================
      83                 :            : 
      84                 :          6 : OUString SAL_CALL ExcelFilter_getImplementationName() throw()
      85                 :            : {
      86                 :          6 :     return CREATE_OUSTRING( "com.sun.star.comp.oox.xls.ExcelFilter" );
      87                 :            : }
      88                 :            : 
      89                 :          6 : Sequence< OUString > SAL_CALL ExcelFilter_getSupportedServiceNames() throw()
      90                 :            : {
      91                 :          6 :     Sequence< OUString > aSeq( 2 );
      92 [ +  - ][ +  - ]:          6 :     aSeq[ 0 ] = CREATE_OUSTRING( "com.sun.star.document.ImportFilter" );
      93 [ +  - ][ +  - ]:          6 :     aSeq[ 1 ] = CREATE_OUSTRING( "com.sun.star.document.ExportFilter" );
      94                 :          6 :     return aSeq;
      95                 :            : }
      96                 :            : 
      97                 :         24 : Reference< XInterface > SAL_CALL ExcelFilter_createInstance(
      98                 :            :         const Reference< XComponentContext >& rxContext ) throw( Exception )
      99                 :            : {
     100         [ +  - ]:         24 :     return static_cast< ::cppu::OWeakObject* >( new ExcelFilter( rxContext ) );
     101                 :            : }
     102                 :            : 
     103                 :            : // ----------------------------------------------------------------------------
     104                 :            : 
     105                 :         24 : ExcelFilter::ExcelFilter( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
     106                 :         24 :     XmlFilterBase( rxContext )
     107                 :            : {
     108                 :         24 : }
     109                 :            : 
     110                 :         24 : ExcelFilter::~ExcelFilter()
     111                 :            : {
     112         [ -  + ]:         48 : }
     113                 :            : 
     114                 :         24 : bool ExcelFilter::importDocument() throw()
     115                 :            : {
     116                 :            :     /*  To activate the XLSX/XLSB dumper, insert the full path to the file
     117                 :            :         file:///<path-to-oox-module>/source/dump/xlsbdumper.ini
     118                 :            :         into the environment variable OOO_XLSBDUMPER and start the office with
     119                 :            :         this variable (nonpro only). */
     120                 :            :     //OOX_DUMP_FILE( ::oox::dump::xlsb::Dumper );
     121                 :            : 
     122 [ +  - ][ +  - ]:         24 :     OUString aWorkbookPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "officeDocument" ) );
     123         [ -  + ]:         24 :     if( aWorkbookPath.isEmpty() )
     124                 :          0 :         return false;
     125                 :            : 
     126                 :            :     /*  Construct the WorkbookGlobals object referred to by every instance of
     127                 :            :         the class WorkbookHelper, and execute the import filter by constructing
     128                 :            :         an instance of WorkbookFragment and loading the file. */
     129         [ +  - ]:         24 :     WorkbookGlobalsRef xBookGlob = WorkbookHelper::constructGlobals( *this );
     130 [ +  - ][ +  - ]:         24 :     if ( xBookGlob.get() && importFragment( new WorkbookFragment( *xBookGlob, aWorkbookPath ) ) )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  -  
             #  #  #  # ]
     131                 :            :     {
     132                 :         24 :         importDocumentProperties();
     133                 :         24 :         return true;
     134                 :            :     }
     135         [ +  - ]:         24 :     return false;
     136                 :            : }
     137                 :            : 
     138                 :          0 : bool ExcelFilter::exportDocument() throw()
     139                 :            : {
     140                 :          0 :     return false;
     141                 :            : }
     142                 :            : 
     143                 :          0 : const ::oox::drawingml::Theme* ExcelFilter::getCurrentTheme() const
     144                 :            : {
     145 [ #  # ][ #  # ]:          0 :     return &WorkbookHelper( getWorkbookGlobals() ).getTheme();
     146                 :            : }
     147                 :            : 
     148                 :          0 : ::oox::vml::Drawing* ExcelFilter::getVmlDrawing()
     149                 :            : {
     150                 :          0 :     return 0;
     151                 :            : }
     152                 :            : 
     153                 :          0 : const TableStyleListPtr ExcelFilter::getTableStyles()
     154                 :            : {
     155                 :          0 :     return TableStyleListPtr();
     156                 :            : }
     157                 :            : 
     158                 :          0 : ::oox::drawingml::chart::ChartConverter* ExcelFilter::getChartConverter()
     159                 :            : {
     160         [ #  # ]:          0 :     return WorkbookHelper( getWorkbookGlobals() ).getChartConverter();
     161                 :            : }
     162                 :            : 
     163                 :         24 : GraphicHelper* ExcelFilter::implCreateGraphicHelper() const
     164                 :            : {
     165 [ +  - ][ +  - ]:         24 :     return new ExcelGraphicHelper( getWorkbookGlobals() );
     166                 :            : }
     167                 :            : 
     168                 :          0 : ::oox::ole::VbaProject* ExcelFilter::implCreateVbaProject() const
     169                 :            : {
     170 [ #  # ][ #  # ]:          0 :     return new ExcelVbaProject( getComponentContext(), Reference< XSpreadsheetDocument >( getModel(), UNO_QUERY ) );
     171                 :            : }
     172                 :            : 
     173                 :            : 
     174                 :         24 : sal_Bool SAL_CALL ExcelFilter::filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rDescriptor ) throw( ::com::sun::star::uno::RuntimeException )
     175                 :            : {
     176         [ +  - ]:         24 :     if ( XmlFilterBase::filter( rDescriptor ) )
     177                 :         24 :         return true;
     178                 :            : 
     179         [ #  # ]:          0 :     if ( isExportFilter() )
     180                 :            :     {
     181 [ #  # ][ #  # ]:          0 :         Reference< XExporter > xExporter( getServiceFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.comp.oox.ExcelFilterExport" ) ), UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
     182                 :            : 
     183         [ #  # ]:          0 :         if ( xExporter.is() )
     184                 :            :         {
     185 [ #  # ][ #  # ]:          0 :             Reference< XComponent > xDocument( getModel(), UNO_QUERY );
     186         [ #  # ]:          0 :             Reference< XFilter > xFilter( xExporter, UNO_QUERY );
     187                 :            : 
     188         [ #  # ]:          0 :             if ( xFilter.is() )
     189                 :            :             {
     190 [ #  # ][ #  # ]:          0 :                 xExporter->setSourceDocument( xDocument );
     191 [ #  # ][ #  # ]:          0 :                 if ( xFilter->filter( rDescriptor ) )
                 [ #  # ]
     192                 :          0 :                     return true;
     193 [ #  # ][ #  # ]:          0 :             }
     194         [ #  # ]:          0 :         }
     195                 :            :     }
     196                 :            : 
     197                 :         24 :     return false;
     198                 :            : }
     199                 :            : 
     200                 :          0 : OUString ExcelFilter::implGetImplementationName() const
     201                 :            : {
     202                 :          0 :     return ExcelFilter_getImplementationName();
     203                 :            : }
     204                 :            : 
     205                 :            : } // namespace xls
     206 [ +  - ][ +  - ]:         24 : } // namespace oox
     207                 :            : 
     208                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10