LCOV - code coverage report
Current view: top level - sd/source/filter - sdpptwrp.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 28 73 38.4 %
Date: 2014-04-11 Functions: 3 6 50.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             : 
      21             : #include <sfx2/docfile.hxx>
      22             : #include <sfx2/docfilt.hxx>
      23             : #include <osl/module.hxx>
      24             : #include <filter/msfilter/msoleexp.hxx>
      25             : #include <filter/msfilter/svxmsbas.hxx>
      26             : #include <svx/svxerr.hxx>
      27             : #include <unotools/fltrcfg.hxx>
      28             : 
      29             : #include "sdpptwrp.hxx"
      30             : #include "ppt/pptin.hxx"
      31             : #include "drawdoc.hxx"
      32             : #include <tools/urlobj.hxx>
      33             : 
      34             : 
      35             : // - Namespaces -
      36             : 
      37             : 
      38             : using namespace ::com::sun::star::uno;
      39             : using namespace ::com::sun::star::beans;
      40             : using namespace ::com::sun::star::task;
      41             : using namespace ::com::sun::star::frame;
      42             : 
      43             : typedef sal_Bool ( SAL_CALL *ExportPPTPointer )( const std::vector< com::sun::star::beans::PropertyValue >&, SvStorageRef&,
      44             :                                              Reference< XModel > &,
      45             :                                              Reference< XStatusIndicator > &,
      46             :                                              SvMemoryStream*, sal_uInt32 nCnvrtFlags );
      47             : 
      48             : typedef sal_Bool ( SAL_CALL *ImportPPTPointer )( SdDrawDocument*, SvStream&, SvStorage&, SfxMedium& );
      49             : 
      50             : typedef sal_Bool ( SAL_CALL *SaveVBAPointer )( SfxObjectShell&, SvMemoryStream*& );
      51             : 
      52             : #ifdef DISABLE_DYNLOADING
      53             : 
      54             : extern "C" sal_Bool ExportPPT( const std::vector< com::sun::star::beans::PropertyValue >&, SvStorageRef&,
      55             :                                Reference< XModel > &,
      56             :                                Reference< XStatusIndicator > &,
      57             :                                SvMemoryStream*, sal_uInt32 nCnvrtFlags );
      58             : 
      59             : extern "C" sal_Bool ImportPPT( SdDrawDocument*, SvStream&, SvStorage&, SfxMedium& );
      60             : 
      61             : extern "C" sal_Bool SaveVBA( SfxObjectShell&, SvMemoryStream*& );
      62             : 
      63             : #endif
      64             : 
      65             : 
      66             : // - SdPPTFilter -
      67             : 
      68             : 
      69          10 : SdPPTFilter::SdPPTFilter( SfxMedium& rMedium, ::sd::DrawDocShell& rDocShell, sal_Bool bShowProgress ) :
      70             :     SdFilter( rMedium, rDocShell, bShowProgress ),
      71          10 :     pBas    ( NULL )
      72             : {
      73          10 : }
      74             : 
      75             : 
      76             : 
      77          20 : SdPPTFilter::~SdPPTFilter()
      78             : {
      79          10 :     delete pBas;    // deleting the compressed basic storage
      80          10 : }
      81             : 
      82             : 
      83             : 
      84          10 : sal_Bool SdPPTFilter::Import()
      85             : {
      86          10 :     sal_Bool    bRet = sal_False;
      87          10 :     SotStorageRef pStorage = new SotStorage( mrMedium.GetInStream(), false );
      88          10 :     if( !pStorage->GetError() )
      89             :     {
      90             :         /* check if there is a dualstorage, then the
      91             :         document is probably a PPT95 containing PPT97 */
      92          10 :         SvStorageRef xDualStorage;
      93          20 :         OUString sDualStorage( "PP97_DUALSTORAGE"  );
      94          10 :         if ( pStorage->IsContained( sDualStorage ) )
      95             :         {
      96           0 :             xDualStorage = pStorage->OpenSotStorage( sDualStorage, STREAM_STD_READ );
      97           0 :             pStorage = xDualStorage;
      98             :         }
      99          10 :         SvStream* pDocStream = pStorage->OpenSotStream( OUString("PowerPoint Document") , STREAM_STD_READ );
     100          10 :         if( pDocStream )
     101             :         {
     102          10 :             pDocStream->SetVersion( pStorage->GetVersion() );
     103          10 :             pDocStream->SetCryptMaskKey(pStorage->GetKey());
     104             : 
     105          10 :             if ( pStorage->IsStream( OUString("EncryptedSummary" ) ) )
     106           0 :                 mrMedium.SetError( ERRCODE_SVX_READ_FILTER_PPOINT, OSL_LOG_PREFIX );
     107             :             else
     108             :             {
     109             : #ifndef DISABLE_DYNLOADING
     110          10 :                 ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
     111          10 :                 if ( pLibrary )
     112             :                 {
     113          10 :                     ImportPPTPointer PPTImport = reinterpret_cast< ImportPPTPointer >( pLibrary->getFunctionSymbol( "ImportPPT" ) );
     114          10 :                     if ( PPTImport )
     115          10 :                         bRet = PPTImport( &mrDocument, *pDocStream, *pStorage, mrMedium );
     116             : 
     117          10 :                     if ( !bRet )
     118           1 :                         mrMedium.SetError( SVSTREAM_WRONGVERSION, OSL_LOG_PREFIX );
     119             :                 }
     120             : #else
     121             :                 bRet = ImportPPT( &mrDocument, *pDocStream, *pStorage, mrMedium );
     122             :                 if ( !bRet )
     123             :                     mrMedium.SetError( SVSTREAM_WRONGVERSION, OSL_LOG_PREFIX );
     124             : #endif
     125             :             }
     126             : 
     127          10 :             delete pDocStream;
     128          10 :         }
     129             :     }
     130             : 
     131          10 :     return bRet;
     132             : }
     133             : 
     134             : 
     135             : 
     136           0 : sal_Bool SdPPTFilter::Export()
     137             : {
     138             : #ifndef DISABLE_DYNLOADING
     139           0 :     ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
     140             : #endif
     141           0 :     sal_Bool        bRet = sal_False;
     142             : 
     143             : #ifndef DISABLE_DYNLOADING
     144           0 :     if( pLibrary )
     145             : #endif
     146             :     {
     147           0 :         if( mxModel.is() )
     148             :         {
     149           0 :             SotStorageRef    xStorRef = new SotStorage( mrMedium.GetOutStream(), false );
     150             : #ifndef DISABLE_DYNLOADING
     151           0 :             ExportPPTPointer PPTExport = reinterpret_cast<ExportPPTPointer>(pLibrary->getFunctionSymbol( "ExportPPT" ));
     152             : #else
     153             :             ExportPPTPointer PPTExport = ExportPPT;
     154             : #endif
     155             : 
     156           0 :             if( PPTExport && xStorRef.Is() )
     157             :             {
     158           0 :                 sal_uInt32          nCnvrtFlags = 0;
     159           0 :                 const SvtFilterOptions& rFilterOptions = SvtFilterOptions::Get();
     160           0 :                 if ( rFilterOptions.IsMath2MathType() )
     161           0 :                     nCnvrtFlags |= OLE_STARMATH_2_MATHTYPE;
     162           0 :                 if ( rFilterOptions.IsWriter2WinWord() )
     163           0 :                     nCnvrtFlags |= OLE_STARWRITER_2_WINWORD;
     164           0 :                 if ( rFilterOptions.IsCalc2Excel() )
     165           0 :                     nCnvrtFlags |= OLE_STARCALC_2_EXCEL;
     166           0 :                 if ( rFilterOptions.IsImpress2PowerPoint() )
     167           0 :                     nCnvrtFlags |= OLE_STARIMPRESS_2_POWERPOINT;
     168           0 :                 if ( rFilterOptions.IsEnablePPTPreview() )
     169           0 :                     nCnvrtFlags |= 0x8000;
     170             : 
     171           0 :                 mrDocument.SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_TEMP );
     172             : 
     173           0 :                 if( mbShowProgress )
     174           0 :                     CreateStatusIndicator();
     175             : 
     176             :                 //OUString sBaseURI( "BaseURI");
     177           0 :                 std::vector< PropertyValue > aProperties;
     178           0 :                 PropertyValue aProperty;
     179           0 :                 aProperty.Name = "BaseURI";
     180           0 :                 aProperty.Value = makeAny( mrMedium.GetBaseURL( true ) );
     181           0 :                 aProperties.push_back( aProperty );
     182             : 
     183           0 :                 bRet = PPTExport( aProperties, xStorRef, mxModel, mxStatusIndicator, pBas, nCnvrtFlags );
     184           0 :                 xStorRef->Commit();
     185           0 :             }
     186             :         }
     187             : #ifndef DISABLE_DYNLOADING
     188           0 :         delete pLibrary;
     189             : #endif
     190             :     }
     191           0 :     return bRet;
     192             : }
     193             : 
     194           0 : void SdPPTFilter::PreSaveBasic()
     195             : {
     196           0 :     const SvtFilterOptions& rFilterOptions = SvtFilterOptions::Get();
     197           0 :     if( rFilterOptions.IsLoadPPointBasicStorage() )
     198             :     {
     199             : #ifndef DISABLE_DYNLOADING
     200           0 :         ::osl::Module* pLibrary = OpenLibrary( mrMedium.GetFilter()->GetUserData() );
     201           0 :         if( pLibrary )
     202             :         {
     203           0 :             SaveVBAPointer pSaveVBA= reinterpret_cast<SaveVBAPointer>(pLibrary->getFunctionSymbol( "SaveVBA" ));
     204           0 :             if( pSaveVBA )
     205             :             {
     206           0 :                 pSaveVBA( (SfxObjectShell&) mrDocShell, pBas );
     207             :             }
     208             :         }
     209             : #else
     210             :         SaveVBA( (SfxObjectShell&) mrDocShell, pBas );
     211             : #endif
     212             :     }
     213           0 : }
     214             : 
     215             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10