LCOV - code coverage report
Current view: top level - sd/source/filter - sdpptwrp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 28 73 38.4 %
Date: 2012-08-25 Functions: 3 6 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 32 138 23.2 %

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

Generated by: LCOV version 1.10