LCOV - code coverage report
Current view: top level - oox/source/ppt - pptimport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 57 84 67.9 %
Date: 2012-08-25 Functions: 17 23 73.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 57 172 33.1 %

           Branch data     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 "oox/ppt/pptimport.hxx"
      21                 :            : #include "oox/drawingml/chart/chartconverter.hxx"
      22                 :            : #include "oox/dump/pptxdumper.hxx"
      23                 :            : #include "oox/drawingml/table/tablestylelistfragmenthandler.hxx"
      24                 :            : #include "oox/helper/graphichelper.hxx"
      25                 :            : #include "oox/ole/vbaproject.hxx"
      26                 :            : 
      27                 :            : using ::rtl::OUString;
      28                 :            : using namespace ::com::sun::star;
      29                 :            : using namespace ::com::sun::star::uno;
      30                 :            : using namespace ::com::sun::star::xml::sax;
      31                 :            : using namespace oox::core;
      32                 :            : 
      33                 :            : using ::com::sun::star::beans::PropertyValue;
      34                 :            : using ::com::sun::star::lang::XComponent;
      35                 :            : 
      36                 :            : namespace oox { namespace ppt {
      37                 :            : 
      38                 :         43 : OUString SAL_CALL PowerPointImport_getImplementationName() throw()
      39                 :            : {
      40                 :         43 :     return CREATE_OUSTRING( "com.sun.star.comp.oox.ppt.PowerPointImport" );
      41                 :            : }
      42                 :            : 
      43                 :          6 : uno::Sequence< OUString > SAL_CALL PowerPointImport_getSupportedServiceNames() throw()
      44                 :            : {
      45                 :          6 :     Sequence< OUString > aSeq( 2 );
      46 [ +  - ][ +  - ]:          6 :     aSeq[ 0 ] = CREATE_OUSTRING( "com.sun.star.document.ImportFilter" );
      47 [ +  - ][ +  - ]:          6 :     aSeq[ 1 ] = CREATE_OUSTRING( "com.sun.star.document.ExportFilter" );
      48                 :          6 :     return aSeq;
      49                 :            : }
      50                 :            : 
      51                 :          9 : uno::Reference< uno::XInterface > SAL_CALL PowerPointImport_createInstance( const Reference< XComponentContext >& rxContext ) throw( Exception )
      52                 :            : {
      53         [ +  - ]:          9 :     return static_cast< ::cppu::OWeakObject* >( new PowerPointImport( rxContext ) );
      54                 :            : }
      55                 :            : 
      56                 :            : #if OSL_DEBUG_LEVEL > 0
      57                 :            : XmlFilterBase* PowerPointImport::mpDebugFilterBase = NULL;
      58                 :            : #endif
      59                 :            : 
      60                 :          9 : PowerPointImport::PowerPointImport( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
      61                 :            :     XmlFilterBase( rxContext ),
      62 [ +  - ][ +  - ]:          9 :     mxChartConv( new ::oox::drawingml::chart::ChartConverter )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      63                 :            : 
      64                 :            : {
      65                 :            : #if OSL_DEBUG_LEVEL > 0
      66                 :            :     mpDebugFilterBase = this;
      67                 :            : #endif
      68                 :          9 : }
      69                 :            : 
      70 [ +  - ][ +  - ]:          9 : PowerPointImport::~PowerPointImport()
                 [ +  - ]
      71                 :            : {
      72         [ -  + ]:         18 : }
      73                 :            : 
      74                 :          9 : bool PowerPointImport::importDocument() throw()
      75                 :            : {
      76                 :            :     /*  to activate the PPTX dumper, define the environment variable
      77                 :            :         OOO_PPTXDUMPER and insert the full path to the file
      78                 :            :         file:///<path-to-oox-module>/source/dump/pptxdumper.ini. */
      79                 :            :     OOX_DUMP_FILE( ::oox::dump::pptx::Dumper );
      80                 :            : 
      81 [ +  - ][ +  - ]:          9 :     OUString aFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "officeDocument" ) );
      82                 :          9 :     FragmentHandlerRef xPresentationFragmentHandler( new PresentationFragmentHandler( *this, aFragmentPath ) );
      83 [ +  - ][ +  - ]:          9 :     maTableStyleListPath = xPresentationFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "tableStyles" ) );
      84         [ +  - ]:          9 :     return importFragment( xPresentationFragmentHandler );
      85                 :            : 
      86                 :            : 
      87                 :            : }
      88                 :            : 
      89                 :          0 : bool PowerPointImport::exportDocument() throw()
      90                 :            : {
      91                 :          0 :     return false;
      92                 :            : }
      93                 :            : 
      94                 :        108 : sal_Int32 PowerPointImport::getSchemeColor( sal_Int32 nToken ) const
      95                 :            : {
      96                 :        108 :     sal_Int32 nColor = 0;
      97         [ +  - ]:        108 :     if ( mpActualSlidePersist )
      98                 :            :     {
      99                 :        108 :         sal_Bool bColorMapped = sal_False;
     100         [ +  - ]:        108 :         oox::drawingml::ClrMapPtr pClrMapPtr( mpActualSlidePersist->getClrMap() );
     101         [ +  + ]:        108 :         if ( pClrMapPtr )
     102         [ +  - ]:         84 :             bColorMapped = pClrMapPtr->getColorMap( nToken );
     103                 :            : 
     104         [ +  + ]:        108 :         if ( !bColorMapped )    // try masterpage mapping
     105                 :            :         {
     106         [ +  - ]:         24 :             SlidePersistPtr pMasterPersist = mpActualSlidePersist->getMasterPersist();
     107         [ +  - ]:         24 :             if ( pMasterPersist )
     108                 :            :             {
     109 [ +  - ][ +  - ]:         24 :                 pClrMapPtr = pMasterPersist->getClrMap();
                 [ +  - ]
     110         [ +  - ]:         24 :                 if ( pClrMapPtr )
     111         [ +  - ]:         24 :                     bColorMapped = pClrMapPtr->getColorMap( nToken );
     112         [ +  - ]:         24 :             }
     113                 :            :         }
     114         [ +  - ]:        108 :         oox::drawingml::ClrSchemePtr pClrSchemePtr( mpActualSlidePersist->getClrScheme() );
     115         [ -  + ]:        108 :         if ( pClrSchemePtr )
     116         [ #  # ]:          0 :             pClrSchemePtr->getColor( nToken, nColor );
     117                 :            :         else
     118                 :            :         {
     119         [ +  - ]:        108 :             ::oox::drawingml::ThemePtr pTheme = mpActualSlidePersist->getTheme();
     120         [ +  - ]:        108 :             if( pTheme )
     121                 :            :             {
     122         [ +  - ]:        108 :                 pTheme->getClrScheme().getColor( nToken, nColor );
     123                 :            :             }
     124                 :            :             else
     125                 :            :             {
     126                 :            :                 OSL_TRACE("OOX: PowerPointImport::mpThemePtr is NULL");
     127         [ +  - ]:        108 :             }
     128 [ +  - ][ +  - ]:        108 :         }
     129                 :            :     }
     130                 :        108 :     return nColor;
     131                 :            : }
     132                 :            : 
     133                 :        723 : const ::oox::drawingml::Theme* PowerPointImport::getCurrentTheme() const
     134                 :            : {
     135 [ +  - ][ +  - ]:        723 :     return mpActualSlidePersist ? mpActualSlidePersist->getTheme().get() : 0;
         [ +  - ][ #  # ]
     136                 :            : }
     137                 :            : 
     138                 :          9 : sal_Bool SAL_CALL PowerPointImport::filter( const Sequence< PropertyValue >& rDescriptor ) throw( RuntimeException )
     139                 :            : {
     140         [ +  - ]:          9 :     if( XmlFilterBase::filter( rDescriptor ) )
     141                 :          9 :         return true;
     142                 :            : 
     143         [ #  # ]:          0 :     if( isExportFilter() ) {
     144 [ #  # ][ #  # ]:          0 :         Reference< XExporter > xExporter( getServiceFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.comp.Impress.oox.PowerPointExport" ) ), UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
     145                 :            : 
     146         [ #  # ]:          0 :         if( xExporter.is() ) {
     147 [ #  # ][ #  # ]:          0 :             Reference< XComponent > xDocument( getModel(), UNO_QUERY );
     148         [ #  # ]:          0 :             Reference< XFilter > xFilter( xExporter, UNO_QUERY );
     149                 :            : 
     150         [ #  # ]:          0 :             if( xFilter.is() ) {
     151 [ #  # ][ #  # ]:          0 :                 xExporter->setSourceDocument( xDocument );
     152 [ #  # ][ #  # ]:          0 :                 if( xFilter->filter( rDescriptor ) )
                 [ #  # ]
     153                 :          0 :                     return true;
     154 [ #  # ][ #  # ]:          0 :             }
     155         [ #  # ]:          0 :         }
     156                 :            :     }
     157                 :            : 
     158                 :          9 :     return false;
     159                 :            : }
     160                 :            : 
     161                 :          0 : ::oox::vml::Drawing* PowerPointImport::getVmlDrawing()
     162                 :            : {
     163         [ #  # ]:          0 :     return mpActualSlidePersist ? mpActualSlidePersist->getDrawing() : 0;
     164                 :            : }
     165                 :            : 
     166                 :          0 : const oox::drawingml::table::TableStyleListPtr PowerPointImport::getTableStyles()
     167                 :            : {
     168 [ #  # ][ #  # ]:          0 :     if ( !mpTableStyleList && !maTableStyleListPath.isEmpty() )
                 [ #  # ]
     169                 :            :     {
     170 [ #  # ][ #  # ]:          0 :         mpTableStyleList = oox::drawingml::table::TableStyleListPtr( new oox::drawingml::table::TableStyleList() );
     171                 :            :         importFragment( new oox::drawingml::table::TableStyleListFragmentHandler(
     172 [ #  # ][ #  # ]:          0 :             *this, maTableStyleListPath, *mpTableStyleList ) );
     173                 :            :     }
     174                 :          0 :     return mpTableStyleList;
     175                 :            : }
     176                 :            : 
     177                 :          0 : ::oox::drawingml::chart::ChartConverter* PowerPointImport::getChartConverter()
     178                 :            : {
     179                 :          0 :     return mxChartConv.get();
     180                 :            : }
     181                 :            : 
     182                 :            : namespace {
     183                 :            : 
     184         [ -  + ]:         18 : class PptGraphicHelper : public GraphicHelper
     185                 :            : {
     186                 :            : public:
     187                 :            :     explicit            PptGraphicHelper( const PowerPointImport& rFilter );
     188                 :            :     virtual sal_Int32   getSchemeColor( sal_Int32 nToken ) const;
     189                 :            : private:
     190                 :            :     const PowerPointImport& mrFilter;
     191                 :            : };
     192                 :            : 
     193                 :          9 : PptGraphicHelper::PptGraphicHelper( const PowerPointImport& rFilter ) :
     194 [ +  - ][ +  - ]:          9 :     GraphicHelper( rFilter.getComponentContext(), rFilter.getTargetFrame(), rFilter.getStorage() ),
     195         [ +  - ]:         18 :     mrFilter( rFilter )
     196                 :            : {
     197                 :          9 : }
     198                 :            : 
     199                 :        108 : sal_Int32 PptGraphicHelper::getSchemeColor( sal_Int32 nToken ) const
     200                 :            : {
     201                 :        108 :     return mrFilter.getSchemeColor( nToken );
     202                 :            : }
     203                 :            : 
     204                 :            : } // namespace
     205                 :            : 
     206                 :          9 : GraphicHelper* PowerPointImport::implCreateGraphicHelper() const
     207                 :            : {
     208         [ +  - ]:          9 :     return new PptGraphicHelper( *this );
     209                 :            : }
     210                 :            : 
     211                 :          0 : ::oox::ole::VbaProject* PowerPointImport::implCreateVbaProject() const
     212                 :            : {
     213 [ #  # ][ #  # ]:          0 :     return new ::oox::ole::VbaProject( getComponentContext(), getModel(), CREATE_OUSTRING( "Impress" ) );
     214                 :            : }
     215                 :            : 
     216                 :          0 : OUString PowerPointImport::implGetImplementationName() const
     217                 :            : {
     218                 :          0 :     return PowerPointImport_getImplementationName();
     219                 :            : }
     220                 :            : 
     221 [ +  - ][ +  - ]:        285 : }}
     222                 :            : 
     223                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10