LCOV - code coverage report
Current view: top level - filter/source/flash - swffilter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 159 0.0 %
Date: 2012-08-25 Functions: 0 29 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           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 <com/sun/star/frame/XDesktop.hpp>
      30                 :            : #include <com/sun/star/frame/XStorable.hpp>
      31                 :            : #include <com/sun/star/document/XFilter.hpp>
      32                 :            : #include <com/sun/star/document/XExporter.hpp>
      33                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      34                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      35                 :            : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      36                 :            : #include <com/sun/star/drawing/XDrawView.hpp>
      37                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      38                 :            : #include <com/sun/star/frame/XModel.hpp>
      39                 :            : #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
      40                 :            : #include <com/sun/star/io/XOutputStream.hpp>
      41                 :            : #include <cppuhelper/implbase1.hxx>
      42                 :            : #include <cppuhelper/implbase4.hxx>
      43                 :            : #include <osl/file.hxx>
      44                 :            : 
      45                 :            : #include "swfexporter.hxx"
      46                 :            : 
      47                 :            : #include <string.h>
      48                 :            : 
      49                 :            : using namespace ::com::sun::star::uno;
      50                 :            : using namespace ::com::sun::star::frame;
      51                 :            : using namespace ::com::sun::star::lang;
      52                 :            : using namespace ::com::sun::star::drawing;
      53                 :            : using namespace ::com::sun::star::presentation;
      54                 :            : using namespace ::com::sun::star::task;
      55                 :            : 
      56                 :            : using ::rtl::OUString;
      57                 :            : using ::rtl::OString;
      58                 :            : using ::com::sun::star::lang::XComponent;
      59                 :            : using ::com::sun::star::beans::PropertyValue;
      60                 :            : using ::com::sun::star::io::XOutputStream;
      61                 :            : using ::com::sun::star::container::XIndexAccess;
      62                 :            : using ::osl::FileBase;
      63                 :            : using ::com::sun::star::frame::XModel;
      64                 :            : 
      65                 :            : namespace swf {
      66                 :            : 
      67                 :            : typedef ::cppu::WeakImplHelper1<com::sun::star::io::XOutputStream> OslOutputStreamWrapper_Base;
      68                 :            :     // needed for some compilers
      69                 :          0 : class OslOutputStreamWrapper : public OslOutputStreamWrapper_Base
      70                 :            : {
      71                 :            :     osl::File   mrFile;
      72                 :            : 
      73                 :            : public:
      74                 :          0 :     OslOutputStreamWrapper(const OUString& sFileName) : mrFile(sFileName)
      75                 :            :     {
      76                 :          0 :         osl_removeFile(sFileName.pData);
      77                 :          0 :         mrFile.open( osl_File_OpenFlag_Create|osl_File_OpenFlag_Write );
      78                 :          0 :     }
      79                 :            : 
      80                 :            :     // stario::XOutputStream
      81                 :            :     virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
      82                 :            :     virtual void SAL_CALL flush(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
      83                 :            :     virtual void SAL_CALL closeOutput(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
      84                 :            : };
      85                 :            : 
      86                 :          0 : void SAL_CALL OslOutputStreamWrapper::writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
      87                 :            : {
      88                 :          0 :     sal_uInt64 uBytesToWrite = aData.getLength();
      89                 :          0 :     sal_uInt64 uBytesWritten = 0;
      90                 :            : 
      91                 :          0 :     sal_Int8 const * pBuffer = aData.getConstArray();
      92                 :            : 
      93                 :          0 :     while( uBytesToWrite )
      94                 :            :     {
      95                 :          0 :         osl::File::RC eRC = mrFile.write( pBuffer, uBytesToWrite, uBytesWritten);
      96                 :            : 
      97                 :          0 :         switch( eRC )
      98                 :            :         {
      99                 :            :         case osl::File::E_INVAL:    // the format of the parameters was not valid
     100                 :            :         case osl::File::E_FBIG:        // File too large
     101                 :            : 
     102                 :            :         case osl::File::E_AGAIN:    // Operation would block
     103                 :            :         case osl::File::E_BADF:        // Bad file
     104                 :            :         case osl::File::E_FAULT:    // Bad address
     105                 :            :         case osl::File::E_INTR:        // function call was interrupted
     106                 :            :         case osl::File::E_IO:        // I/O error
     107                 :            :         case osl::File::E_NOLCK:    // No record locks available
     108                 :            :         case osl::File::E_NOLINK:    // Link has been severed
     109                 :            :         case osl::File::E_NOSPC:    // No space left on device
     110                 :            :         case osl::File::E_NXIO:        // No such device or address
     111                 :          0 :             throw com::sun::star::io::IOException();    // TODO: Better error handling
     112                 :          0 :         default: break;
     113                 :            :         }
     114                 :            : 
     115                 :          0 :         uBytesToWrite -= uBytesWritten;
     116                 :          0 :         pBuffer += uBytesWritten;
     117                 :            :     }
     118                 :          0 : }
     119                 :            : 
     120                 :          0 : void SAL_CALL OslOutputStreamWrapper::flush(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
     121                 :            : {
     122                 :          0 : }
     123                 :            : 
     124                 :          0 : void SAL_CALL OslOutputStreamWrapper::closeOutput(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
     125                 :            : {
     126                 :          0 :     osl::File::RC eRC = mrFile.close();
     127                 :            : 
     128                 :          0 :     switch( eRC )
     129                 :            :     {
     130                 :            :     case osl::File::E_INVAL:    // the format of the parameters was not valid
     131                 :            : 
     132                 :            :     case osl::File::E_BADF:        // Bad file
     133                 :            :     case osl::File::E_INTR:        // function call was interrupted
     134                 :            :     case osl::File::E_NOLINK:    // Link has been severed
     135                 :            :     case osl::File::E_NOSPC:    // No space left on device
     136                 :            :     case osl::File::E_IO:        // I/O error
     137                 :          0 :         throw com::sun::star::io::IOException();    // TODO: Better error handling
     138                 :          0 :     default: break;
     139                 :            :     }
     140                 :          0 : }
     141                 :            : 
     142                 :            : // -----------------------------------------------------------------------------
     143                 :            : 
     144                 :          0 : class FlashExportFilter : public cppu::WeakImplHelper4
     145                 :            : <
     146                 :            :     com::sun::star::document::XFilter,
     147                 :            :     com::sun::star::document::XExporter,
     148                 :            :     com::sun::star::lang::XInitialization,
     149                 :            :     com::sun::star::lang::XServiceInfo
     150                 :            : >
     151                 :            : {
     152                 :            :     Reference< XComponent > mxDoc;
     153                 :            :     Reference< XMultiServiceFactory > mxMSF;
     154                 :            :     Reference< XStatusIndicator> mxStatusIndicator;
     155                 :            : 
     156                 :            : public:
     157                 :            :     FlashExportFilter( const Reference< XMultiServiceFactory > &rxMSF);
     158                 :            : 
     159                 :            :     // XFilter
     160                 :            :     virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& aDescriptor ) throw(RuntimeException);
     161                 :            : 
     162                 :            :     sal_Bool ExportAsMultipleFiles( const Sequence< PropertyValue >& aDescriptor );
     163                 :            :     sal_Bool ExportAsSingleFile( const Sequence< PropertyValue >& aDescriptor );
     164                 :            : 
     165                 :            :     virtual void SAL_CALL cancel( ) throw (RuntimeException);
     166                 :            : 
     167                 :            :     // XExporter
     168                 :            :     virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException);
     169                 :            : 
     170                 :            :     // XInitialization
     171                 :            :     virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException);
     172                 :            : 
     173                 :            :     // XServiceInfo
     174                 :            :     virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
     175                 :            :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
     176                 :            :     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()  throw(RuntimeException);
     177                 :            : };
     178                 :            : 
     179                 :            : // -----------------------------------------------------------------------------
     180                 :            : 
     181                 :          0 : FlashExportFilter::FlashExportFilter(const Reference< XMultiServiceFactory > &rxMSF)
     182                 :          0 : :   mxMSF( rxMSF )
     183                 :            : {
     184                 :          0 : }
     185                 :            : 
     186                 :            : 
     187                 :            : // -----------------------------------------------------------------------------
     188                 :            : 
     189                 :          0 : OUString exportBackground(FlashExporter &aFlashExporter, Reference< XDrawPage > xDrawPage, OUString sPath, sal_uInt32 nPage, const char* suffix)
     190                 :            : {
     191                 :          0 :     OUString filename = STR("slide") + VAL(nPage+1) + STR(suffix) + STR(".swf");
     192                 :          0 :     OUString fullpath = sPath + STR("/") + filename;
     193                 :            : 
     194                 :            :     // AS: If suffix is "o" then the last paramter is true (for exporting objects).
     195                 :          0 :     Reference<XOutputStream> xOutputStreamWrap(*(new OslOutputStreamWrapper(fullpath)), UNO_QUERY);
     196                 :          0 :     sal_uInt16 nCached = aFlashExporter.exportBackgrounds( xDrawPage, xOutputStreamWrap, sal::static_int_cast<sal_uInt16>( nPage ), *suffix == 'o' );
     197                 :          0 :     aFlashExporter.Flush();
     198                 :          0 :     xOutputStreamWrap.clear();
     199                 :            : 
     200                 :          0 :     if (nCached != nPage)
     201                 :            :     {
     202                 :          0 :         osl_removeFile(fullpath.pData);
     203                 :          0 :         if ( 0xffff == nCached )
     204                 :          0 :             return STR("NULL");
     205                 :            :         else
     206                 :          0 :             return STR("slide") + VAL(nCached+1) + STR(suffix) + STR(".swf");
     207                 :            :     }
     208                 :            : 
     209                 :          0 :     return filename;
     210                 :            : }
     211                 :            : 
     212                 :            : template <typename TYPE>
     213                 :          0 : TYPE findPropertyValue(const Sequence< PropertyValue >& aPropertySequence, const sal_Char* name, TYPE def)
     214                 :            : {
     215                 :          0 :     TYPE temp = TYPE();
     216                 :            : 
     217                 :          0 :     sal_Int32 nLength = aPropertySequence.getLength();
     218                 :          0 :     const PropertyValue * pValue = aPropertySequence.getConstArray();
     219                 :            : 
     220                 :          0 :     for ( sal_Int32 i = 0 ; i < nLength; i++)
     221                 :            :     {
     222                 :          0 :         if ( pValue[i].Name.equalsAsciiL ( name, strlen(name) ) )
     223                 :            :         {
     224                 :          0 :             pValue[i].Value >>= temp;
     225                 :          0 :             return temp;
     226                 :            :         }
     227                 :            :     }
     228                 :            : 
     229                 :          0 :     return def;
     230                 :            : }
     231                 :            : 
     232                 :          0 : sal_Bool SAL_CALL FlashExportFilter::filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
     233                 :            :     throw (RuntimeException)
     234                 :            : {
     235                 :          0 :     mxStatusIndicator = findPropertyValue<Reference<XStatusIndicator> >(aDescriptor, "StatusIndicator", mxStatusIndicator);
     236                 :            : 
     237                 :          0 :     Sequence< PropertyValue > aFilterData;
     238                 :          0 :     aFilterData = findPropertyValue<Sequence< PropertyValue > >(aDescriptor, "FilterData", aFilterData);
     239                 :            : 
     240                 :          0 :     if (findPropertyValue<sal_Bool>(aFilterData, "ExportMultipleFiles", false ))
     241                 :            :     {
     242                 :          0 :         ExportAsMultipleFiles(aDescriptor);
     243                 :            :     }
     244                 :            :     else
     245                 :            :     {
     246                 :          0 :         ExportAsSingleFile(aDescriptor);
     247                 :            :     }
     248                 :            : 
     249                 :          0 :     if( mxStatusIndicator.is() )
     250                 :          0 :         mxStatusIndicator->end();
     251                 :            : 
     252                 :          0 :     return sal_True;
     253                 :            : }
     254                 :            : 
     255                 :            : 
     256                 :            : // AS: When exporting as multiple files, each background, object layer, and slide gets its own
     257                 :            : //  file.  Additionally, a file called BackgroundConfig.txt is generated, indicating which
     258                 :            : //  background and objects (if any) go with each slide.  The files are named slideNb.swf,
     259                 :            : //  slideNo.swf, and slideNp.swf, where N is the slide number, and b=background, o=objects, and
     260                 :            : //  p=slide contents.  Note that under normal circumstances, there will be very few b and o files.
     261                 :            : 
     262                 :            : // AS: HACK!  Right now, I create a directory as a sibling to the swf file selected in the Export
     263                 :            : //  dialog.  This directory is called presentation.sxi-swf-files.  The name of the swf file selected
     264                 :            : //  in the Export dialog has no impact on this.  All files created are placed in this directory.
     265                 :          0 : sal_Bool FlashExportFilter::ExportAsMultipleFiles(const Sequence< PropertyValue >& aDescriptor)
     266                 :            : {
     267                 :          0 :     Reference< XDrawPagesSupplier > xDrawPagesSupplier(mxDoc, UNO_QUERY);
     268                 :          0 :     if(!xDrawPagesSupplier.is())
     269                 :          0 :         return sal_False;
     270                 :            : 
     271                 :          0 :     Reference< XIndexAccess > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY );
     272                 :          0 :     if(!xDrawPages.is())
     273                 :          0 :         return sal_False;
     274                 :            : 
     275                 :          0 :     Reference< XDesktop > rDesktop( mxMSF->createInstance(OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ))), UNO_QUERY);
     276                 :          0 :     if (!rDesktop.is())
     277                 :          0 :         return sal_False;
     278                 :            : 
     279                 :          0 :     Reference< XStorable > xStorable(rDesktop->getCurrentComponent(), UNO_QUERY);
     280                 :          0 :     if (!xStorable.is())
     281                 :          0 :         return sal_False;
     282                 :            : 
     283                 :          0 :     Reference< XDrawPage > xDrawPage;
     284                 :            : 
     285                 :          0 :     Reference< XFrame > rFrame = rDesktop->getCurrentFrame();
     286                 :          0 :     Reference< XDrawView > rDrawView = Reference< XDrawView >( rFrame->getController(), UNO_QUERY );
     287                 :            : 
     288                 :          0 :     Reference< XDrawPage > rCurrentPage = rDrawView->getCurrentPage();
     289                 :            : 
     290                 :          0 :     Sequence< PropertyValue > aFilterData;
     291                 :            : 
     292                 :          0 :     aFilterData = findPropertyValue<Sequence< PropertyValue > >(aDescriptor, "FilterData", aFilterData);
     293                 :            : 
     294                 :            :     //AS: Do a bunch of path mangling to figure out where to put the files.
     295                 :            : 
     296                 :          0 :     OUString sOriginalPath = findPropertyValue<OUString>(aDescriptor, "URL", OUString());
     297                 :            : 
     298                 :            :     // AS: sPath is the parent directory, where everything else exists (like the sxi,
     299                 :            :     //  the -swf-files folder, the -audio files, etc.
     300                 :          0 :     int lastslash = sOriginalPath.lastIndexOf('/');
     301                 :          0 :     OUString sPath( sOriginalPath.copy(0, lastslash) );
     302                 :            : 
     303                 :          0 :     OUString sPresentation(xStorable->getLocation());
     304                 :            : 
     305                 :          0 :     lastslash = sPresentation.lastIndexOf('/') + 1;
     306                 :          0 :     int lastdot = sPresentation.lastIndexOf('.');
     307                 :            : 
     308                 :            :     // AS: The name of the presentation, without 3 character extension.
     309                 :          0 :     OUString sPresentationName = sPresentation.copy(lastslash, lastdot - lastslash);
     310                 :            : 
     311                 :          0 :     OUString fullpath, swfdirpath, backgroundfilename, objectsfilename;
     312                 :            : 
     313                 :          0 :     swfdirpath = sPath + STR("/") + sPresentationName + STR(".sxi-swf-files");
     314                 :            : 
     315                 :            :     oslFileError err;
     316                 :          0 :     err = osl_createDirectory( swfdirpath.pData );
     317                 :            : 
     318                 :          0 :     fullpath = swfdirpath + STR("/backgroundconfig.txt");
     319                 :            : 
     320                 :          0 :     oslFileHandle xBackgroundConfig( 0 );
     321                 :            : 
     322                 :            :     // AS: Only export the background config if we're exporting all of the pages, otherwise we'll
     323                 :            :     //  screw it up.
     324                 :          0 :     sal_Bool bExportAll = findPropertyValue<sal_Bool>(aFilterData, "ExportAll", true);
     325                 :          0 :     if (bExportAll)
     326                 :            :     {
     327                 :          0 :         osl_removeFile(fullpath.pData);
     328                 :          0 :         osl_openFile( fullpath.pData, &xBackgroundConfig, osl_File_OpenFlag_Create | osl_File_OpenFlag_Write );
     329                 :            : 
     330                 :            :         sal_uInt64 bytesWritten;
     331                 :          0 :         err = osl_writeFile(xBackgroundConfig, "slides=", strlen("slides="), &bytesWritten);
     332                 :            :     }
     333                 :            : 
     334                 :            :     // TODO: check for errors
     335                 :            :     (void) err;
     336                 :            : 
     337                 :            :     FlashExporter aFlashExporter( mxMSF, findPropertyValue<sal_Int32>(aFilterData, "CompressMode", 75),
     338                 :          0 :                                          findPropertyValue<sal_Bool>(aFilterData, "ExportOLEAsJPEG", false));
     339                 :            : 
     340                 :          0 :     const sal_Int32 nPageCount = xDrawPages->getCount();
     341                 :          0 :     if ( mxStatusIndicator.is() )
     342                 :          0 :         mxStatusIndicator->start(OUString( RTL_CONSTASCII_USTRINGPARAM( "Saving :" )), nPageCount);
     343                 :            : 
     344                 :          0 :     for(sal_Int32 nPage = 0; nPage < nPageCount; nPage++)
     345                 :            :     {
     346                 :          0 :         if ( mxStatusIndicator.is() )
     347                 :          0 :             mxStatusIndicator->setValue( nPage );
     348                 :          0 :         xDrawPages->getByIndex(nPage) >>= xDrawPage;
     349                 :            : 
     350                 :            :         // AS: If we're only exporting the current page, then skip the rest.
     351                 :          0 :         if (!bExportAll && xDrawPage != rCurrentPage)
     352                 :          0 :             continue;
     353                 :            : 
     354                 :            :         // AS: Export the background, the background objects, and then the slide contents.
     355                 :          0 :         if (bExportAll || findPropertyValue<sal_Bool>(aFilterData, "ExportBackgrounds", true))
     356                 :            :         {
     357                 :          0 :             backgroundfilename = exportBackground(aFlashExporter, xDrawPage, swfdirpath, nPage, "b");
     358                 :            :         }
     359                 :            : 
     360                 :          0 :         if (bExportAll || findPropertyValue<sal_Bool>(aFilterData, "ExportBackgroundObjects", true))
     361                 :            :         {
     362                 :          0 :             objectsfilename = exportBackground(aFlashExporter, xDrawPage, swfdirpath, nPage, "o");
     363                 :            :         }
     364                 :            : 
     365                 :          0 :         if (bExportAll || findPropertyValue<sal_Bool>(aFilterData, "ExportSlideContents", true))
     366                 :            :         {
     367                 :          0 :             fullpath = swfdirpath + STR("/slide") + VAL(nPage+1) + STR("p.swf");
     368                 :            : 
     369                 :          0 :             Reference<XOutputStream> xOutputStreamWrap(*(new OslOutputStreamWrapper(fullpath)), UNO_QUERY);
     370                 :          0 :             sal_Bool ret = aFlashExporter.exportSlides( xDrawPage, xOutputStreamWrap, sal::static_int_cast<sal_uInt16>( nPage ) );
     371                 :          0 :             aFlashExporter.Flush();
     372                 :          0 :             xOutputStreamWrap.clear();
     373                 :            : 
     374                 :          0 :             if (!ret)
     375                 :          0 :                 osl_removeFile(fullpath.pData);
     376                 :            :         }
     377                 :            : 
     378                 :            :         // AS: Write out to the background config what backgrounds and objects this
     379                 :            :         //  slide used.
     380                 :          0 :         if (bExportAll)
     381                 :            :         {
     382                 :          0 :             OUString temp = backgroundfilename + STR("|") + objectsfilename;
     383                 :          0 :             OString ASCIItemp(temp.getStr(), temp.getLength(), RTL_TEXTENCODING_ASCII_US);
     384                 :            : 
     385                 :            :             sal_uInt64 bytesWritten;
     386                 :          0 :             osl_writeFile(xBackgroundConfig, ASCIItemp.getStr(), ASCIItemp.getLength(), &bytesWritten);
     387                 :            : 
     388                 :          0 :             if (nPage < nPageCount - 1)
     389                 :          0 :                 osl_writeFile(xBackgroundConfig, "|", 1, &bytesWritten);
     390                 :            :         }
     391                 :            : 
     392                 :            : #ifdef AUGUSTUS
     393                 :            :         if (findPropertyValue<sal_Bool>(aFilterData, "ExportSound", true))
     394                 :            :         {
     395                 :            :             fullpath = swfdirpath + STR("/slide") + VAL(nPage+1) + STR("s.swf");
     396                 :            : 
     397                 :            :             OUString wavpath = sPath + STR("/") + sPresentationName + STR(".ppt-audio/slide") + VAL(nPage+1) + STR(".wav");
     398                 :            :             FileBase::getSystemPathFromFileURL(wavpath, wavpath);
     399                 :            :             OString sASCIIPath(wavpath.getStr(), wavpath.getLength(), RTL_TEXTENCODING_ASCII_US);
     400                 :            : 
     401                 :            :             Reference<XOutputStream> xOutputStreamWrap(*(new OslOutputStreamWrapper(fullpath)), UNO_QUERY);
     402                 :            :             sal_Bool ret = aFlashExporter.exportSound(xOutputStreamWrap, sASCIIPath.getStr());
     403                 :            :             aFlashExporter.Flush();
     404                 :            :             xOutputStreamWrap.clear();
     405                 :            : 
     406                 :            :             if (!ret)
     407                 :            :                 osl_removeFile(fullpath.pData);
     408                 :            :         }
     409                 :            : #endif // defined AUGUSTUS
     410                 :            :     }
     411                 :            : 
     412                 :          0 :     if (bExportAll)
     413                 :          0 :         osl_closeFile(xBackgroundConfig);
     414                 :            : 
     415                 :          0 :     return sal_True;
     416                 :            : }
     417                 :            : 
     418                 :          0 : sal_Bool FlashExportFilter::ExportAsSingleFile(const Sequence< PropertyValue >& aDescriptor)
     419                 :            : {
     420                 :          0 :     Reference < XOutputStream > xOutputStream = findPropertyValue<Reference<XOutputStream> >(aDescriptor, "OutputStream", 0);
     421                 :          0 :     Sequence< PropertyValue > aFilterData;
     422                 :            : 
     423                 :          0 :     if (!xOutputStream.is() )
     424                 :            :     {
     425                 :            :         OSL_ASSERT ( 0 );
     426                 :          0 :         return sal_False;
     427                 :            :     }
     428                 :            : 
     429                 :            :     FlashExporter aFlashExporter( mxMSF, findPropertyValue<sal_Int32>(aFilterData, "CompressMode", 75),
     430                 :          0 :                                          findPropertyValue<sal_Bool>(aFilterData, "ExportOLEAsJPEG", false));
     431                 :            : 
     432                 :          0 :     return aFlashExporter.exportAll( mxDoc, xOutputStream, mxStatusIndicator );
     433                 :            : }
     434                 :            : 
     435                 :            : // -----------------------------------------------------------------------------
     436                 :            : 
     437                 :          0 : void SAL_CALL FlashExportFilter::cancel(  )
     438                 :            :     throw (RuntimeException)
     439                 :            : {
     440                 :          0 : }
     441                 :            : 
     442                 :            : // -----------------------------------------------------------------------------
     443                 :            : 
     444                 :            : // XExporter
     445                 :          0 : void SAL_CALL FlashExportFilter::setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
     446                 :            :     throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException)
     447                 :            : {
     448                 :          0 :     mxDoc = xDoc;
     449                 :          0 : }
     450                 :            : 
     451                 :            : // -----------------------------------------------------------------------------
     452                 :            : 
     453                 :            : // XInitialization
     454                 :          0 : void SAL_CALL FlashExportFilter::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& /* aArguments */ )
     455                 :            :     throw (Exception, RuntimeException)
     456                 :            : {
     457                 :          0 : }
     458                 :            : 
     459                 :            : // -----------------------------------------------------------------------------
     460                 :            : 
     461                 :          0 : OUString FlashExportFilter_getImplementationName ()
     462                 :            :     throw (RuntimeException)
     463                 :            : {
     464                 :          0 :     return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Impress.FlashExportFilter" ) );
     465                 :            : }
     466                 :            : 
     467                 :            : // -----------------------------------------------------------------------------
     468                 :            : 
     469                 :            : #define SERVICE_NAME "com.sun.star.document.ExportFilter"
     470                 :            : 
     471                 :          0 : sal_Bool SAL_CALL FlashExportFilter_supportsService( const OUString& ServiceName )
     472                 :            :     throw (RuntimeException)
     473                 :            : {
     474                 :          0 :     return ServiceName == SERVICE_NAME;
     475                 :            : }
     476                 :            : 
     477                 :            : // -----------------------------------------------------------------------------
     478                 :            : 
     479                 :          0 : Sequence< OUString > SAL_CALL FlashExportFilter_getSupportedServiceNames(  )
     480                 :            :     throw (RuntimeException)
     481                 :            : {
     482                 :          0 :     Sequence < OUString > aRet(1);
     483                 :          0 :     OUString* pArray = aRet.getArray();
     484                 :          0 :     pArray[0] =  OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
     485                 :          0 :     return aRet;
     486                 :            : }
     487                 :            : #undef SERVICE_NAME
     488                 :            : 
     489                 :            : // -----------------------------------------------------------------------------
     490                 :            : 
     491                 :          0 : Reference< XInterface > SAL_CALL FlashExportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
     492                 :            :     throw( Exception )
     493                 :            : {
     494                 :          0 :     return (cppu::OWeakObject*) new FlashExportFilter( rSMgr );
     495                 :            : }
     496                 :            : 
     497                 :            : // -----------------------------------------------------------------------------
     498                 :            : 
     499                 :            : // XServiceInfo
     500                 :          0 : OUString SAL_CALL FlashExportFilter::getImplementationName(  )
     501                 :            :     throw (RuntimeException)
     502                 :            : {
     503                 :          0 :     return FlashExportFilter_getImplementationName();
     504                 :            : }
     505                 :            : 
     506                 :            : // -----------------------------------------------------------------------------
     507                 :            : 
     508                 :          0 : sal_Bool SAL_CALL FlashExportFilter::supportsService( const OUString& rServiceName )
     509                 :            :     throw (RuntimeException)
     510                 :            : {
     511                 :          0 :     return FlashExportFilter_supportsService( rServiceName );
     512                 :            : }
     513                 :            : 
     514                 :            : // -----------------------------------------------------------------------------
     515                 :            : 
     516                 :          0 : ::com::sun::star::uno::Sequence< OUString > SAL_CALL FlashExportFilter::getSupportedServiceNames(  )
     517                 :            :     throw (RuntimeException)
     518                 :            : {
     519                 :          0 :     return FlashExportFilter_getSupportedServiceNames();
     520                 :            : }
     521                 :            : 
     522                 :            : // -----------------------------------------------------------------------------
     523                 :            : 
     524                 :            : }
     525                 :            : 
     526                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10