LCOV - code coverage report
Current view: top level - sd/source/ui/remotecontrol - ImagePreparer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 207 0.0 %
Date: 2012-08-25 Functions: 0 10 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 492 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                 :            : #include "ImagePreparer.hxx"
      29                 :            : 
      30                 :            : #include <comphelper/processfactory.hxx>
      31                 :            : #include <osl/file.hxx>
      32                 :            : #include <rtl/ustrbuf.hxx>
      33                 :            : #include <sax/tools/converter.hxx>
      34                 :            : #include <rtl/strbuf.hxx>
      35                 :            : #include <unotools/streamwrap.hxx>
      36                 :            : 
      37                 :            : #include <svl/itemset.hxx>
      38                 :            : #include <sfx2/docfile.hxx>
      39                 :            : 
      40                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      41                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      42                 :            : #include <com/sun/star/document/XFilter.hpp>
      43                 :            : #include <com/sun/star/document/XImporter.hpp>
      44                 :            : #include <com/sun/star/document/XExporter.hpp>
      45                 :            : #include <com/sun/star/lang/XServiceName.hpp>
      46                 :            : #include <com/sun/star/presentation/XPresentationPage.hpp>
      47                 :            : #include <com/sun/star/text/XTextRange.hpp>
      48                 :            : 
      49                 :            : using namespace ::sd;
      50                 :            : using namespace ::rtl;
      51                 :            : using namespace ::osl;
      52                 :            : using namespace ::com::sun::star;
      53                 :            : using namespace ::com::sun::star::uno;
      54                 :            : 
      55                 :          0 : ImagePreparer::ImagePreparer(
      56                 :            :     const uno::Reference<presentation::XSlideShowController>& rxController,
      57                 :            :     Transmitter *aTransmitter, rtl::Reference<ImagePreparer>& rRef )
      58                 :            :  :  Thread( "ImagePreparer Thread" ),
      59                 :            :     xController( rxController ),
      60                 :            :     pTransmitter( aTransmitter ),
      61                 :          0 :     mRef( rRef )
      62                 :            : {
      63                 :          0 : }
      64                 :            : 
      65                 :          0 : ImagePreparer::~ImagePreparer()
      66                 :            : {
      67         [ #  # ]:          0 : }
      68                 :            : 
      69                 :          0 : void ImagePreparer::execute()
      70                 :            : {
      71                 :          0 :     sal_uInt32 aSlides = xController->getSlideCount();
      72         [ #  # ]:          0 :     for ( sal_uInt32 i = 0; i < aSlides; i++ )
      73                 :            :     {
      74         [ #  # ]:          0 :         if ( !xController->isRunning() ) // stopped/disposed of.
      75                 :            :         {
      76                 :          0 :             break;
      77                 :            :         }
      78                 :          0 :         sendPreview( i );
      79                 :            :     }
      80         [ #  # ]:          0 :     for ( sal_uInt32 i = 0; i < aSlides; i++ )
      81                 :            :     {
      82         [ #  # ]:          0 :         if ( !xController->isRunning() ) // stopped/disposed of.
      83                 :            :         {
      84                 :          0 :             break;
      85                 :            :         }
      86                 :          0 :         sendNotes( i );
      87                 :            :     }
      88                 :            : //      notesToHtml( 0 );
      89                 :          0 :     mRef.clear();
      90                 :          0 : }
      91                 :            : 
      92                 :          0 : void ImagePreparer::sendPreview( sal_uInt32 aSlideNumber )
      93                 :            : {
      94                 :            :     sal_uInt64 aSize;
      95                 :            :     uno::Sequence<sal_Int8> aImageData = preparePreview( aSlideNumber, 320, 240,
      96         [ #  # ]:          0 :         aSize );
      97 [ #  # ][ #  # ]:          0 :     if ( !xController->isRunning() )
                 [ #  # ]
      98                 :          0 :         return;
      99                 :            : 
     100                 :          0 :     OUStringBuffer aStrBuffer;
     101         [ #  # ]:          0 :     ::sax::Converter::encodeBase64( aStrBuffer, aImageData );
     102                 :            : 
     103                 :            :     OString aEncodedShortString = OUStringToOString(
     104 [ #  # ][ #  # ]:          0 :         aStrBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
     105                 :            : 
     106                 :            :     // Start the writing
     107                 :          0 :     OStringBuffer aBuffer;
     108                 :            : 
     109         [ #  # ]:          0 :     aBuffer.append( "slide_preview\n" );
     110                 :            : 
     111         [ #  # ]:          0 :     aBuffer.append( OString::valueOf( sal_Int32( aSlideNumber ) ).getStr() );
     112         [ #  # ]:          0 :     aBuffer.append( "\n" );
     113                 :            : 
     114         [ #  # ]:          0 :     aBuffer.append( aEncodedShortString.getStr() );
     115         [ #  # ]:          0 :     aBuffer.append( "\n\n" );
     116                 :            :     pTransmitter->addMessage( aBuffer.makeStringAndClear(),
     117 [ #  # ][ #  # ]:          0 :         Transmitter::PRIORITY_LOW );
                 [ #  # ]
     118                 :            : 
     119                 :            : }
     120                 :            : 
     121                 :          0 : uno::Sequence<sal_Int8> ImagePreparer::preparePreview(
     122                 :            :     sal_uInt32 aSlideNumber, sal_uInt32 aWidth, sal_uInt32 aHeight,
     123                 :            :     sal_uInt64 &rSize )
     124                 :            : {
     125                 :          0 :     OUString aFileURL;
     126         [ #  # ]:          0 :     FileBase::createTempFile( 0, 0, &aFileURL );
     127                 :            : 
     128                 :            :     uno::Reference< lang::XMultiServiceFactory > xServiceManager(
     129                 :            :         ::comphelper::getProcessServiceFactory(),
     130 [ #  # ][ #  # ]:          0 :         uno::UNO_QUERY_THROW );
     131                 :            : 
     132                 :            :     uno::Reference< document::XFilter > xFilter(
     133         [ #  # ]:          0 :         xServiceManager->createInstance(
     134                 :          0 :         "com.sun.star.drawing.GraphicExportFilter" ) ,
     135 [ #  # ][ #  # ]:          0 :         uno::UNO_QUERY_THROW );
     136                 :            : 
     137                 :            :     uno::Reference< document::XExporter > xExporter( xFilter,
     138         [ #  # ]:          0 :         uno::UNO_QUERY_THROW );
     139                 :            : 
     140 [ #  # ][ #  # ]:          0 :     if ( !xController->isRunning() )
                 [ #  # ]
     141         [ #  # ]:          0 :         return uno::Sequence<sal_Int8>();
     142                 :            : 
     143                 :            :     uno::Reference< lang::XComponent > xSourceDoc(
     144         [ #  # ]:          0 :         xController->getSlideByIndex( aSlideNumber ),
     145 [ #  # ][ #  # ]:          0 :         uno::UNO_QUERY_THROW );
     146                 :            : 
     147 [ #  # ][ #  # ]:          0 :     xExporter->setSourceDocument( xSourceDoc );
     148                 :            : 
     149         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > aFilterData(3);
     150                 :            : 
     151         [ #  # ]:          0 :     aFilterData[0].Name = "PixelWidth";
     152 [ #  # ][ #  # ]:          0 :     aFilterData[0].Value <<= aWidth;
     153                 :            : 
     154         [ #  # ]:          0 :     aFilterData[1].Name = "PixelHeight";
     155 [ #  # ][ #  # ]:          0 :     aFilterData[1].Value <<= aHeight;
     156                 :            : 
     157         [ #  # ]:          0 :     aFilterData[2].Name = "ColorMode";
     158 [ #  # ][ #  # ]:          0 :     aFilterData[2].Value <<= sal_Int32(0); // 0: Color, 1: B&W
     159                 :            : 
     160         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > aProps(3);
     161                 :            : 
     162         [ #  # ]:          0 :     aProps[0].Name = "MediaType";
     163 [ #  # ][ #  # ]:          0 :     aProps[0].Value <<= OUString( "image/png" );
     164                 :            : 
     165         [ #  # ]:          0 :     aProps[1].Name = "URL";
     166 [ #  # ][ #  # ]:          0 :     aProps[1].Value <<= aFileURL;
     167                 :            : 
     168         [ #  # ]:          0 :     aProps[2].Name = "FilterData";
     169 [ #  # ][ #  # ]:          0 :     aProps[2].Value <<= aFilterData;
     170                 :            : 
     171 [ #  # ][ #  # ]:          0 :     xFilter->filter( aProps );
     172                 :            : 
     173                 :            :     // FIXME: error handling.
     174                 :            : 
     175                 :          0 :     File aFile( aFileURL );
     176         [ #  # ]:          0 :     aFile.open(0);
     177                 :            :     sal_uInt64 aRead;
     178                 :          0 :     rSize = 0;
     179         [ #  # ]:          0 :     aFile.getSize( rSize );
     180         [ #  # ]:          0 :     uno::Sequence<sal_Int8> aContents( rSize );
     181                 :            : 
     182 [ #  # ][ #  # ]:          0 :     aFile.read( aContents.getArray(), rSize, aRead );
     183         [ #  # ]:          0 :     aFile.close();
     184         [ #  # ]:          0 :     File::remove( aFileURL );
     185 [ #  # ][ #  # ]:          0 :     return aContents;
         [ #  # ][ #  # ]
                 [ #  # ]
     186                 :            : 
     187                 :            : }
     188                 :            : 
     189                 :          0 : void ImagePreparer::sendNotes( sal_uInt32 aSlideNumber )
     190                 :            : {
     191                 :            : 
     192         [ #  # ]:          0 :     OString aNotes = prepareNotes( aSlideNumber );
     193                 :            : 
     194         [ #  # ]:          0 :     if ( aNotes.getLength() == 0 )
     195                 :            :         return;
     196                 :            : 
     197                 :            : //     OUStringBuffer aStrBuffer;
     198                 :            : //     ::sax::Converter::encodeBase64( aStrBuffer, aTemp );
     199                 :            : //
     200                 :            : //     OString aNotes = OUStringToOString(
     201                 :            : //         aStrBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
     202                 :            : 
     203 [ #  # ][ #  # ]:          0 :     if ( !xController->isRunning() )
                 [ #  # ]
     204                 :            :         return;
     205                 :            : 
     206                 :            :     // Start the writing
     207                 :          0 :     OStringBuffer aBuffer;
     208                 :            : 
     209         [ #  # ]:          0 :     aBuffer.append( "slide_notes\n" );
     210                 :            : 
     211         [ #  # ]:          0 :     aBuffer.append( OString::valueOf( sal_Int32( aSlideNumber ) ).getStr() );
     212         [ #  # ]:          0 :     aBuffer.append( "\n" );
     213                 :            : 
     214         [ #  # ]:          0 :     aBuffer.append( "<html><body>" );
     215         [ #  # ]:          0 :     aBuffer.append( aNotes );
     216         [ #  # ]:          0 :     aBuffer.append( "</html></body>" );
     217         [ #  # ]:          0 :     aBuffer.append( "\n\n" );
     218                 :            :     pTransmitter->addMessage( aBuffer.makeStringAndClear(),
     219 [ #  # ][ #  # ]:          0 :         Transmitter::PRIORITY_LOW );
     220                 :            : }
     221                 :            : 
     222                 :            : sal_Bool ExportTo( uno::Reference< drawing::XDrawPage>& aNotesPage, String aUrl );
     223                 :          0 : OString ImagePreparer::notesToHtml( sal_uInt32 aSlideNumber )
     224                 :            : {
     225                 :          0 :     OString aRet("");
     226                 :            : 
     227                 :          0 :     OUString aFileURL;
     228         [ #  # ]:          0 :     FileBase::createTempFile( 0, 0, &aFileURL );
     229 [ #  # ][ #  # ]:          0 :     fprintf( stderr, "%s", OUStringToOString( aFileURL, RTL_TEXTENCODING_UTF8).getStr() );
     230                 :            : 
     231 [ #  # ][ #  # ]:          0 :     if ( !xController->isRunning() )
                 [ #  # ]
     232                 :          0 :         return "";
     233                 :            : 
     234                 :            : 
     235                 :            : 
     236                 :            : 
     237                 :            :     // Get the page
     238                 :          0 :     uno::Reference< drawing::XDrawPage > xNotesPage;
     239                 :            :     uno::Reference< drawing::XDrawPage > xSourceDoc(
     240         [ #  # ]:          0 :         xController->getSlideByIndex( aSlideNumber ),
     241 [ #  # ][ #  # ]:          0 :         uno::UNO_QUERY_THROW );
     242                 :            : 
     243                 :            :     uno::Reference<presentation::XPresentationPage> xPresentationPage(
     244         [ #  # ]:          0 :         xSourceDoc, UNO_QUERY);
     245         [ #  # ]:          0 :     if (xPresentationPage.is())
     246                 :            :         xNotesPage = uno::Reference< drawing::XDrawPage >(
     247 [ #  # ][ #  # ]:          0 :             xPresentationPage->getNotesPage(), uno::UNO_QUERY_THROW );
         [ #  # ][ #  # ]
     248                 :            :     else
     249                 :          0 :         return "";
     250                 :            : 
     251                 :            : 
     252 [ #  # ][ #  # ]:          0 :     ExportTo( xNotesPage, aFileURL );
                 [ #  # ]
     253                 :            : 
     254                 :            :     // FIXME: error handling.
     255                 :            : 
     256                 :            : //     File aFile( aFileURL );
     257                 :            : //     aFile.open(0);
     258                 :            : //     sal_uInt64 aRead;
     259                 :            : //     rSize = 0;
     260                 :            : //     aFile.getSize( rSize );
     261                 :            : //     uno::Sequence<sal_Int8> aContents( rSize );
     262                 :            : 
     263                 :            : //     aFile.read( aContents.getArray(), rSize, aRead );
     264                 :            : //     aFile.close();
     265                 :            : //     File::remove( aFileURL );
     266                 :            : //     return aContents;
     267                 :            : 
     268                 :          0 :     return aRet;
     269                 :            : }
     270                 :            : 
     271                 :            : // Code copied from sdremote/source/presenter/PresenterNotesView.cxx
     272                 :          0 : OString ImagePreparer::prepareNotes( sal_uInt32 aSlideNumber )
     273                 :            : {
     274                 :          0 :     OUStringBuffer aRet;
     275                 :            : 
     276 [ #  # ][ #  # ]:          0 :     if ( !xController->isRunning() )
                 [ #  # ]
     277                 :          0 :         return "";
     278                 :            : 
     279                 :          0 :     uno::Reference<css::drawing::XDrawPage> aNotesPage;
     280                 :            :     uno::Reference< drawing::XDrawPage > xSourceDoc(
     281         [ #  # ]:          0 :         xController->getSlideByIndex( aSlideNumber ),
     282 [ #  # ][ #  # ]:          0 :         uno::UNO_QUERY_THROW );
     283                 :            :     uno::Reference<presentation::XPresentationPage> xPresentationPage(
     284         [ #  # ]:          0 :         xSourceDoc, UNO_QUERY);
     285         [ #  # ]:          0 :     if (xPresentationPage.is())
     286 [ #  # ][ #  # ]:          0 :         aNotesPage = xPresentationPage->getNotesPage();
                 [ #  # ]
     287                 :            :     else
     288                 :          0 :         return "";
     289                 :            : 
     290                 :            : 
     291                 :            :     static const ::rtl::OUString sNotesShapeName (
     292 [ #  # ][ #  # ]:          0 :         "com.sun.star.presentation.NotesShape" );
     293                 :            :     static const ::rtl::OUString sTextShapeName (
     294 [ #  # ][ #  # ]:          0 :         "com.sun.star.drawing.TextShape" );
     295                 :            : 
     296         [ #  # ]:          0 :     uno::Reference<container::XIndexAccess> xIndexAccess ( aNotesPage, UNO_QUERY);
     297         [ #  # ]:          0 :     if (xIndexAccess.is())
     298                 :            :     {
     299                 :            : 
     300                 :            :         // Iterate over all shapes and find the one that holds the text.
     301 [ #  # ][ #  # ]:          0 :         sal_Int32 nCount (xIndexAccess->getCount());
     302         [ #  # ]:          0 :         for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
     303                 :            :         {
     304                 :            : 
     305                 :            :             uno::Reference<lang::XServiceName> xServiceName (
     306 [ #  # ][ #  # ]:          0 :                 xIndexAccess->getByIndex(nIndex), UNO_QUERY);
                 [ #  # ]
     307         [ #  # ]:          0 :             if (xServiceName.is()
           [ #  #  #  # ]
     308 [ #  # ][ #  # ]:          0 :                 && xServiceName->getServiceName().equals(sNotesShapeName))
         [ #  # ][ #  # ]
     309                 :            :             {
     310         [ #  # ]:          0 :                 uno::Reference<text::XTextRange> xText (xServiceName, UNO_QUERY);
     311         [ #  # ]:          0 :                 if (xText.is())
     312                 :            :                 {
     313 [ #  # ][ #  # ]:          0 :                     aRet.append(xText->getString());
                 [ #  # ]
     314         [ #  # ]:          0 :                     aRet.append("<br/>");
     315                 :          0 :                 }
     316                 :            :             }
     317                 :            :             else
     318                 :            :             {
     319                 :            :                 uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor (
     320 [ #  # ][ #  # ]:          0 :                     xIndexAccess->getByIndex(nIndex), UNO_QUERY);
                 [ #  # ]
     321         [ #  # ]:          0 :                 if (xShapeDescriptor.is())
     322                 :            :                 {
     323 [ #  # ][ #  # ]:          0 :                     ::rtl::OUString sType (xShapeDescriptor->getShapeType());
     324 [ #  # ][ #  # ]:          0 :                     if (sType.equals(sNotesShapeName) || sType.equals(sTextShapeName))
                 [ #  # ]
     325                 :            :                     {
     326                 :            :                         uno::Reference<text::XTextRange> xText (
     327 [ #  # ][ #  # ]:          0 :                             xIndexAccess->getByIndex(nIndex), UNO_QUERY);
                 [ #  # ]
     328         [ #  # ]:          0 :                         if (xText.is())
     329                 :            :                         {
     330 [ #  # ][ #  # ]:          0 :                             aRet.append(xText->getString());
                 [ #  # ]
     331         [ #  # ]:          0 :                             aRet.append("<br/>");
     332                 :          0 :                         }
     333                 :          0 :                     }
     334                 :          0 :                 }
     335                 :            :             }
     336                 :          0 :         }
     337                 :            :     }
     338                 :            :     // Replace all newlines with <br\> tags
     339         [ #  # ]:          0 :     for ( sal_Int32 i = 0; i < aRet.getLength(); i++ )
     340                 :            :     {
     341         [ #  # ]:          0 :         if ( aRet[i] == '\n' )
     342                 :            :         {
     343                 :          0 :             aRet[i]=  '<';
     344         [ #  # ]:          0 :             aRet.insert( i+1, "br/>" );
     345                 :            :         }
     346                 :            :     }
     347                 :            :     return OUStringToOString(
     348 [ #  # ][ #  # ]:          0 :         aRet.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
     349                 :            : }
     350                 :            : 
     351                 :          0 : sal_Bool ExportTo( uno::Reference< drawing::XDrawPage>& aNotesPage, String aUrl )
     352                 :            : {
     353                 :          0 :     ::rtl::OUString aFilterName( "XHTML Draw File" );
     354                 :          0 :     uno::Reference< document::XExporter > xExporter;
     355                 :            : 
     356                 :            :     {
     357         [ #  # ]:          0 :         uno::Reference< lang::XMultiServiceFactory >  xMan = ::comphelper::getProcessServiceFactory();
     358                 :            :         uno::Reference < lang::XMultiServiceFactory > xFilterFact (
     359 [ #  # ][ #  # ]:          0 :                 xMan->createInstance( "com.sun.star.document.FilterFactory" ), uno::UNO_QUERY );
                 [ #  # ]
     360                 :            : 
     361         [ #  # ]:          0 :         uno::Sequence < beans::PropertyValue > aProps;
     362         [ #  # ]:          0 :         uno::Reference < container::XNameAccess > xFilters ( xFilterFact, uno::UNO_QUERY );
     363 [ #  # ][ #  # ]:          0 :         if ( xFilters->hasByName( aFilterName ) )
                 [ #  # ]
     364 [ #  # ][ #  # ]:          0 :             xFilters->getByName( aFilterName ) >>= aProps;
                 [ #  # ]
     365                 :            :         else
     366         [ #  # ]:          0 :             fprintf( stderr, "Couldn't find by name.\n" );
     367                 :            : 
     368                 :          0 :         ::rtl::OUString aFilterImplName;
     369                 :          0 :         sal_Int32 nFilterProps = aProps.getLength();
     370         [ #  # ]:          0 :         for ( sal_Int32 nFilterProp = 0; nFilterProp<nFilterProps; nFilterProp++ )
     371                 :            :         {
     372         [ #  # ]:          0 :             const beans::PropertyValue& rFilterProp = aProps[nFilterProp];
     373         [ #  # ]:          0 :             if ( rFilterProp.Name.compareToAscii("FilterService") == 0 )
     374                 :            :             {
     375                 :          0 :                 rFilterProp.Value >>= aFilterImplName;
     376                 :          0 :                 break;
     377                 :            :             }
     378                 :            :         }
     379                 :            : 
     380 [ #  # ][ #  # ]:          0 :         fprintf( stderr, "aName%s\n", OUStringToOString(aFilterImplName, RTL_TEXTENCODING_UTF8).getStr() );
     381         [ #  # ]:          0 :         if ( !aFilterImplName.isEmpty() )
     382                 :            :         {
     383                 :            :             try{
     384                 :            :             xExporter = uno::Reference< document::XExporter >
     385 [ #  # ][ #  # ]:          0 :                 ( xFilterFact->createInstanceWithArguments( aFilterName, uno::Sequence < uno::Any >() ), uno::UNO_QUERY );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     386   [ #  #  #  # ]:          0 :             }catch(const uno::Exception&)
     387                 :            :                 {
     388                 :          0 :                     xExporter.clear();
     389         [ #  # ]:          0 :                     fprintf( stderr, "Couldn't create instance of filter.\n" );
     390                 :            :                 }
     391         [ #  # ]:          0 :         }
     392                 :            :     }
     393                 :            : 
     394         [ #  # ]:          0 :     if ( xExporter.is() )
     395                 :            :     {
     396                 :            :         try{
     397         [ #  # ]:          0 :         uno::Reference< lang::XComponent >  xComp( aNotesPage, uno::UNO_QUERY_THROW );
     398         [ #  # ]:          0 :         uno::Reference< document::XFilter > xFilter( xExporter, uno::UNO_QUERY_THROW );
     399 [ #  # ][ #  # ]:          0 :         xExporter->setSourceDocument( xComp );
     400                 :            : 
     401         [ #  # ]:          0 :         com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aOldArgs ( 2 );
     402         [ #  # ]:          0 :         aOldArgs[0].Name = "FileName";
     403 [ #  # ][ #  # ]:          0 :         aOldArgs[0].Value <<= OUString( aUrl );
                 [ #  # ]
     404         [ #  # ]:          0 :         aOldArgs[1].Name = "FilterName";
     405 [ #  # ][ #  # ]:          0 :         aOldArgs[1].Value <<= OUString("com.sun.star.documentconversion.XSLTFilter");
     406                 :            : 
     407         [ #  # ]:          0 :         SfxMedium rMedium( aUrl , STREAM_STD_WRITE  );
     408                 :            : 
     409                 :          0 :         const com::sun::star::beans::PropertyValue * pOldValue = aOldArgs.getConstArray();
     410         [ #  # ]:          0 :         com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aArgs ( aOldArgs.getLength() );
     411         [ #  # ]:          0 :         com::sun::star::beans::PropertyValue * pNewValue = aArgs.getArray();
     412                 :            : 
     413                 :            : 
     414                 :            :         // put in the REAL file name, and copy all PropertyValues
     415         [ #  # ]:          0 :         const OUString sOutputStream ( RTL_CONSTASCII_USTRINGPARAM ( "OutputStream" ) );
     416         [ #  # ]:          0 :         const OUString sStream ( RTL_CONSTASCII_USTRINGPARAM ( "StreamForOutput" ) );
     417                 :          0 :         sal_Bool bHasOutputStream = sal_False;
     418                 :          0 :         sal_Bool bHasStream = sal_False;
     419                 :          0 :         sal_Bool bHasBaseURL = sal_False;
     420                 :            :         sal_Int32 i;
     421                 :          0 :         sal_Int32 nEnd = aOldArgs.getLength();
     422                 :            : 
     423         [ #  # ]:          0 :         for ( i = 0; i < nEnd; i++ )
     424                 :            :         {
     425                 :          0 :             pNewValue[i] = pOldValue[i];
     426         [ #  # ]:          0 :             if ( pOldValue[i].Name == "FileName" )
     427 [ #  # ][ #  # ]:          0 :                 pNewValue[i].Value <<= OUString ( rMedium.GetName() );
     428         [ #  # ]:          0 :             else if ( pOldValue[i].Name == sOutputStream )
     429                 :          0 :                 bHasOutputStream = sal_True;
     430         [ #  # ]:          0 :             else if ( pOldValue[i].Name == sStream )
     431                 :          0 :                 bHasStream = sal_True;
     432         [ #  # ]:          0 :             else if ( pOldValue[i].Name == "DocumentBaseURL" )
     433                 :          0 :                 bHasBaseURL = sal_True;
     434                 :            :         }
     435                 :            : 
     436         [ #  # ]:          0 :         if ( !bHasOutputStream )
     437                 :            :         {
     438         [ #  # ]:          0 :             aArgs.realloc ( ++nEnd );
     439         [ #  # ]:          0 :             aArgs[nEnd-1].Name = sOutputStream;
     440 [ #  # ][ #  # ]:          0 :             aArgs[nEnd-1].Value <<= uno::Reference < io::XOutputStream > ( new utl::OOutputStreamWrapper ( *rMedium.GetOutStream() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     441                 :            :         }
     442                 :            : 
     443                 :            :         // add stream as well, for OOX export and maybe others
     444         [ #  # ]:          0 :         if ( !bHasStream )
     445                 :            :         {
     446         [ #  # ]:          0 :             aArgs.realloc ( ++nEnd );
     447         [ #  # ]:          0 :             aArgs[nEnd-1].Name = sStream;
     448 [ #  # ][ #  # ]:          0 :             aArgs[nEnd-1].Value <<= com::sun::star::uno::Reference < com::sun::star::io::XStream > ( new utl::OStreamWrapper ( *rMedium.GetOutStream() ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     449                 :            :         }
     450                 :            : 
     451         [ #  # ]:          0 :         if ( !bHasBaseURL )
     452                 :            :         {
     453         [ #  # ]:          0 :             aArgs.realloc ( ++nEnd );
     454 [ #  # ][ #  # ]:          0 :             aArgs[nEnd-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "DocumentBaseURL" ) );
     455 [ #  # ][ #  # ]:          0 :             aArgs[nEnd-1].Value <<= rMedium.GetBaseURL( sal_True );
                 [ #  # ]
     456                 :            :         }
     457                 :            : 
     458 [ #  # ][ #  # ]:          0 :         return xFilter->filter( aArgs );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     459         [ #  # ]:          0 :         }catch(const uno::Exception&)
     460                 :            :         {}
     461                 :            :     }
     462                 :            : 
     463                 :          0 :     return sal_False;
     464                 :            : }
     465                 :            : 
     466                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10