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

Generated by: LCOV version 1.10