LCOV - code coverage report
Current view: top level - svx/source/xml - xmlgrhlp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 136 461 29.5 %
Date: 2012-08-25 Functions: 29 59 49.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 102 1006 10.1 %

           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 <comphelper/string.hxx>
      30                 :            : #include <sal/macros.h>
      31                 :            : #include <rtl/oustringostreaminserter.hxx>
      32                 :            : #include <rtl/strbuf.hxx>
      33                 :            : #include <com/sun/star/embed/XTransactedObject.hpp>
      34                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      35                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      36                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      37                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      38                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      39                 :            : #include <cppuhelper/compbase4.hxx>
      40                 :            : 
      41                 :            : #include <unotools/ucbstreamhelper.hxx>
      42                 :            : #include <unotools/streamwrap.hxx>
      43                 :            : #include <unotools/tempfile.hxx>
      44                 :            : #include <unotools/saveopt.hxx>
      45                 :            : #include <tools/debug.hxx>
      46                 :            : #include <vcl/cvtgrf.hxx>
      47                 :            : #include <vcl/gfxlink.hxx>
      48                 :            : #include <vcl/metaact.hxx>
      49                 :            : #include <tools/zcodec.hxx>
      50                 :            : 
      51                 :            : #include "svtools/filter.hxx"
      52                 :            : #include "svx/xmlgrhlp.hxx"
      53                 :            : #include "svx/xmleohlp.hxx"
      54                 :            : 
      55                 :            : #include <algorithm>
      56                 :            : 
      57                 :            : // -----------
      58                 :            : // - Defines -
      59                 :            : // -----------
      60                 :            : 
      61                 :            : using namespace com::sun::star;
      62                 :            : using namespace com::sun::star::uno;
      63                 :            : using namespace com::sun::star::io;
      64                 :            : 
      65                 :            : using ::com::sun::star::lang::XMultiServiceFactory;
      66                 :            : 
      67                 :            : #define XML_GRAPHICSTORAGE_NAME     "Pictures"
      68                 :            : #define XML_GRAPHICOBJECT_URL_BASE  "vnd.sun.star.GraphicObject:"
      69                 :            : 
      70                 :            : // ---------------------------
      71                 :            : // - SvXMLGraphicInputStream -
      72                 :            : // ---------------------------
      73                 :            : 
      74                 :          0 : const MetaCommentAction* ImplCheckForEPS( GDIMetaFile& rMtf )
      75                 :            : {
      76                 :          0 :     const MetaCommentAction* pComment = NULL;
      77                 :            : 
      78   [ #  #  #  #  :          0 :     if ( ( rMtf.GetActionSize() >= 2 )
             #  #  #  # ]
                 [ #  # ]
      79                 :          0 :             && ( rMtf.FirstAction()->GetType() == META_EPS_ACTION )
      80                 :          0 :             && ( ((const MetaAction*)rMtf.GetAction( 1 ))->GetType() == META_COMMENT_ACTION )
      81                 :          0 :             && ( ((const MetaCommentAction*)rMtf.GetAction( 1 ))->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("EPSReplacementGraphic")) ) )
      82                 :          0 :         pComment = (const MetaCommentAction*)rMtf.GetAction( 1 );
      83                 :            : 
      84                 :          0 :     return pComment;
      85                 :            : }
      86                 :            : 
      87                 :            : class SvXMLGraphicInputStream : public::cppu::WeakImplHelper1< XInputStream >
      88                 :            : {
      89                 :            : private:
      90                 :            : 
      91                 :            :     virtual sal_Int32   SAL_CALL    readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead) throw(NotConnectedException, BufferSizeExceededException, RuntimeException);
      92                 :            :     virtual sal_Int32   SAL_CALL    readSomeBytes(Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead) throw(NotConnectedException, BufferSizeExceededException, RuntimeException);
      93                 :            :     virtual void        SAL_CALL    skipBytes(sal_Int32 nBytesToSkip) throw(NotConnectedException, BufferSizeExceededException, RuntimeException);
      94                 :            :     virtual sal_Int32   SAL_CALL    available() throw(NotConnectedException, RuntimeException);
      95                 :            :     virtual void        SAL_CALL    closeInput() throw(NotConnectedException, RuntimeException);
      96                 :            : 
      97                 :            : private:
      98                 :            : 
      99                 :            :     ::utl::TempFile                 maTmp;
     100                 :            :     Reference< XInputStream >       mxStmWrapper;
     101                 :            : 
     102                 :            :                                     // not available
     103                 :            :                                     SvXMLGraphicInputStream();
     104                 :            :                                     SvXMLGraphicInputStream( const SvXMLGraphicInputStream& );
     105                 :            :     SvXMLGraphicInputStream&        operator==( SvXMLGraphicInputStream& );
     106                 :            : 
     107                 :            : public:
     108                 :            : 
     109                 :            :                                     SvXMLGraphicInputStream( const ::rtl::OUString& rGraphicId );
     110                 :            :     virtual                         ~SvXMLGraphicInputStream();
     111                 :            : 
     112                 :          0 :     sal_Bool                        Exists() const { return mxStmWrapper.is(); }
     113                 :            : };
     114                 :            : 
     115                 :            : // -----------------------------------------------------------------------------
     116                 :            : 
     117         [ #  # ]:          0 : SvXMLGraphicInputStream::SvXMLGraphicInputStream( const ::rtl::OUString& rGraphicId )
     118                 :            : {
     119 [ #  # ][ #  # ]:          0 :     GraphicObject   aGrfObject( rtl::OUStringToOString(rGraphicId, RTL_TEXTENCODING_ASCII_US) );
     120                 :            : 
     121                 :          0 :     maTmp.EnableKillingFile();
     122                 :            : 
     123         [ #  # ]:          0 :     if( aGrfObject.GetType() != GRAPHIC_NONE )
     124                 :            :     {
     125 [ #  # ][ #  # ]:          0 :         SvStream* pStm = ::utl::UcbStreamHelper::CreateStream( maTmp.GetURL(), STREAM_WRITE | STREAM_TRUNC );
                 [ #  # ]
     126                 :            : 
     127         [ #  # ]:          0 :         if( pStm )
     128                 :            :         {
     129 [ #  # ][ #  # ]:          0 :             Graphic         aGraphic( (Graphic&) aGrfObject.GetGraphic() );
     130         [ #  # ]:          0 :             const GfxLink   aGfxLink( aGraphic.GetLink() );
     131                 :          0 :             sal_Bool        bRet = sal_False;
     132                 :            : 
     133 [ #  # ][ #  # ]:          0 :             if( aGfxLink.GetDataSize() && aGfxLink.GetData() )
         [ #  # ][ #  # ]
                 [ #  # ]
     134                 :            :             {
     135 [ #  # ][ #  # ]:          0 :                 pStm->Write( aGfxLink.GetData(), aGfxLink.GetDataSize() );
                 [ #  # ]
     136                 :          0 :                 bRet = ( pStm->GetError() == 0 );
     137                 :            :             }
     138                 :            :             else
     139                 :            :             {
     140 [ #  # ][ #  # ]:          0 :                 if( aGraphic.GetType() == GRAPHIC_BITMAP )
     141                 :            :                 {
     142         [ #  # ]:          0 :                     GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
     143         [ #  # ]:          0 :                     String          aFormat;
     144                 :            : 
     145 [ #  # ][ #  # ]:          0 :                     if( aGraphic.IsAnimated() )
     146 [ #  # ][ #  # ]:          0 :                         aFormat = String(  "gif"  );
                 [ #  # ]
     147                 :            :                     else
     148 [ #  # ][ #  # ]:          0 :                         aFormat = String(  "png"  );
                 [ #  # ]
     149                 :            : 
     150 [ #  # ][ #  # ]:          0 :                     bRet = ( rFilter.ExportGraphic( aGraphic, String(), *pStm, rFilter.GetExportFormatNumberForShortName( aFormat ) ) == 0 );
         [ #  # ][ #  # ]
                 [ #  # ]
     151                 :            :                 }
     152 [ #  # ][ #  # ]:          0 :                 else if( aGraphic.GetType() == GRAPHIC_GDIMETAFILE )
     153                 :            :                 {
     154                 :          0 :                     pStm->SetVersion( SOFFICE_FILEFORMAT_8 );
     155                 :          0 :                     pStm->SetCompressMode( COMPRESSMODE_ZBITMAP );
     156 [ #  # ][ #  # ]:          0 :                     ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( *pStm, GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC );
     157                 :          0 :                     bRet = ( pStm->GetError() == 0 );
     158                 :            :                 }
     159                 :            :             }
     160                 :            : 
     161         [ #  # ]:          0 :             if( bRet )
     162                 :            :             {
     163         [ #  # ]:          0 :                 pStm->Seek( 0 );
     164 [ #  # ][ #  # ]:          0 :                 mxStmWrapper = new ::utl::OInputStreamWrapper( pStm, sal_True );
                 [ #  # ]
     165                 :            :             }
     166                 :            :             else
     167 [ #  # ][ #  # ]:          0 :                 delete pStm;
         [ #  # ][ #  # ]
     168                 :            :         }
     169         [ #  # ]:          0 :     }
     170                 :          0 : }
     171                 :            : 
     172                 :            : // -----------------------------------------------------------------------------
     173                 :            : 
     174         [ #  # ]:          0 : SvXMLGraphicInputStream::~SvXMLGraphicInputStream()
     175                 :            : {
     176         [ #  # ]:          0 : }
     177                 :            : 
     178                 :            : // -----------------------------------------------------------------------------
     179                 :            : 
     180                 :          0 : sal_Int32 SAL_CALL SvXMLGraphicInputStream::readBytes( Sequence< sal_Int8 >& rData, sal_Int32 nBytesToRead )
     181                 :            :     throw( NotConnectedException, BufferSizeExceededException, RuntimeException )
     182                 :            : {
     183         [ #  # ]:          0 :     if( !mxStmWrapper.is() )
     184         [ #  # ]:          0 :         throw NotConnectedException();
     185                 :            : 
     186                 :          0 :     return mxStmWrapper->readBytes( rData, nBytesToRead );
     187                 :            : }
     188                 :            : 
     189                 :            : // -----------------------------------------------------------------------------
     190                 :            : 
     191                 :          0 : sal_Int32 SAL_CALL SvXMLGraphicInputStream::readSomeBytes( Sequence< sal_Int8 >& rData, sal_Int32 nMaxBytesToRead )
     192                 :            :     throw( NotConnectedException, BufferSizeExceededException, RuntimeException )
     193                 :            : {
     194         [ #  # ]:          0 :     if( !mxStmWrapper.is() )
     195         [ #  # ]:          0 :         throw NotConnectedException() ;
     196                 :            : 
     197                 :          0 :     return mxStmWrapper->readSomeBytes( rData, nMaxBytesToRead );
     198                 :            : }
     199                 :            : 
     200                 :            : // -----------------------------------------------------------------------------
     201                 :            : 
     202                 :          0 : void SAL_CALL SvXMLGraphicInputStream::skipBytes( sal_Int32 nBytesToSkip )
     203                 :            :     throw( NotConnectedException, BufferSizeExceededException, RuntimeException )
     204                 :            : {
     205         [ #  # ]:          0 :     if( !mxStmWrapper.is() )
     206         [ #  # ]:          0 :         throw NotConnectedException() ;
     207                 :            : 
     208                 :          0 :     mxStmWrapper->skipBytes( nBytesToSkip );
     209                 :          0 : }
     210                 :            : 
     211                 :            : // -----------------------------------------------------------------------------
     212                 :            : 
     213                 :          0 : sal_Int32 SAL_CALL SvXMLGraphicInputStream::available() throw( NotConnectedException, RuntimeException )
     214                 :            : {
     215         [ #  # ]:          0 :     if( !mxStmWrapper.is() )
     216         [ #  # ]:          0 :         throw NotConnectedException() ;
     217                 :            : 
     218                 :          0 :     return mxStmWrapper->available();
     219                 :            : }
     220                 :            : 
     221                 :            : // -----------------------------------------------------------------------------
     222                 :            : 
     223                 :          0 : void SAL_CALL SvXMLGraphicInputStream::closeInput() throw( NotConnectedException, RuntimeException )
     224                 :            : {
     225         [ #  # ]:          0 :     if( !mxStmWrapper.is() )
     226         [ #  # ]:          0 :         throw NotConnectedException() ;
     227                 :            : 
     228                 :          0 :     mxStmWrapper->closeInput();
     229                 :          0 : }
     230                 :            : 
     231                 :            : // ----------------------------
     232                 :            : // - SvXMLGraphicOutputStream -
     233                 :            : // ----------------------------
     234                 :            : 
     235                 :            : class SvXMLGraphicOutputStream : public::cppu::WeakImplHelper1< XOutputStream >
     236                 :            : {
     237                 :            : private:
     238                 :            : 
     239                 :            :     // XOutputStream
     240                 :            :     virtual void SAL_CALL           writeBytes( const Sequence< sal_Int8 >& rData ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException );
     241                 :            :     virtual void SAL_CALL           flush() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException );
     242                 :            :     virtual void SAL_CALL           closeOutput() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException );
     243                 :            : 
     244                 :            : private:
     245                 :            : 
     246                 :            :     ::utl::TempFile*                mpTmp;
     247                 :            :     SvStream*                       mpOStm;
     248                 :            :     Reference< XOutputStream >      mxStmWrapper;
     249                 :            :     GraphicObject                   maGrfObj;
     250                 :            :     sal_Bool                        mbClosed;
     251                 :            : 
     252                 :            :                                     // not available
     253                 :            :                                     SvXMLGraphicOutputStream( const SvXMLGraphicOutputStream& );
     254                 :            :     SvXMLGraphicOutputStream&       operator==( SvXMLGraphicOutputStream& );
     255                 :            : 
     256                 :            : public:
     257                 :            : 
     258                 :            :                                     SvXMLGraphicOutputStream();
     259                 :            :     virtual                         ~SvXMLGraphicOutputStream();
     260                 :            : 
     261                 :          0 :     sal_Bool                        Exists() const { return mxStmWrapper.is(); }
     262                 :            :     const GraphicObject&            GetGraphicObject();
     263                 :            : };
     264                 :            : 
     265                 :            : // -----------------------------------------------------------------------------
     266                 :            : 
     267                 :          0 : SvXMLGraphicOutputStream::SvXMLGraphicOutputStream() :
     268         [ #  # ]:          0 :     mpTmp( new ::utl::TempFile ),
     269 [ #  # ][ #  # ]:          0 :     mbClosed( sal_False )
     270                 :            : {
     271                 :          0 :     mpTmp->EnableKillingFile();
     272                 :            : 
     273 [ #  # ][ #  # ]:          0 :     mpOStm = ::utl::UcbStreamHelper::CreateStream( mpTmp->GetURL(), STREAM_WRITE | STREAM_TRUNC );
                 [ #  # ]
     274                 :            : 
     275         [ #  # ]:          0 :     if( mpOStm )
     276 [ #  # ][ #  # ]:          0 :         mxStmWrapper = new ::utl::OOutputStreamWrapper( *mpOStm );
                 [ #  # ]
     277                 :          0 : }
     278                 :            : 
     279                 :            : // -----------------------------------------------------------------------------
     280                 :            : 
     281         [ #  # ]:          0 : SvXMLGraphicOutputStream::~SvXMLGraphicOutputStream()
     282                 :            : {
     283 [ #  # ][ #  # ]:          0 :     delete mpTmp;
     284 [ #  # ][ #  # ]:          0 :     delete mpOStm;
     285         [ #  # ]:          0 : }
     286                 :            : 
     287                 :            : // -----------------------------------------------------------------------------
     288                 :            : 
     289                 :          0 : void SAL_CALL SvXMLGraphicOutputStream::writeBytes( const Sequence< sal_Int8 >& rData )
     290                 :            :     throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
     291                 :            : {
     292         [ #  # ]:          0 :     if( !mxStmWrapper.is() )
     293         [ #  # ]:          0 :         throw NotConnectedException() ;
     294                 :            : 
     295                 :          0 :     mxStmWrapper->writeBytes( rData );
     296                 :          0 : }
     297                 :            : 
     298                 :            : // -----------------------------------------------------------------------------
     299                 :            : 
     300                 :          0 : void SAL_CALL SvXMLGraphicOutputStream::flush()
     301                 :            :     throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
     302                 :            : {
     303         [ #  # ]:          0 :     if( !mxStmWrapper.is() )
     304         [ #  # ]:          0 :         throw NotConnectedException() ;
     305                 :            : 
     306                 :          0 :     mxStmWrapper->flush();
     307                 :          0 : }
     308                 :            : 
     309                 :            : // -----------------------------------------------------------------------------
     310                 :            : 
     311                 :          0 : void SAL_CALL SvXMLGraphicOutputStream::closeOutput()
     312                 :            :     throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
     313                 :            : {
     314         [ #  # ]:          0 :     if( !mxStmWrapper.is() )
     315         [ #  # ]:          0 :         throw NotConnectedException() ;
     316                 :            : 
     317                 :          0 :     mxStmWrapper->closeOutput();
     318         [ #  # ]:          0 :     mxStmWrapper = Reference< XOutputStream >();
     319                 :            : 
     320                 :          0 :     mbClosed = sal_True;
     321                 :          0 : }
     322                 :            : 
     323                 :            : // ------------------------------------------------------------------------------
     324                 :            : 
     325                 :          0 : const GraphicObject& SvXMLGraphicOutputStream::GetGraphicObject()
     326                 :            : {
     327 [ #  # ][ #  # ]:          0 :     if( mbClosed && ( maGrfObj.GetType() == GRAPHIC_NONE ) && mpOStm )
         [ #  # ][ #  # ]
     328                 :            :     {
     329         [ #  # ]:          0 :         Graphic aGraphic;
     330                 :            : 
     331         [ #  # ]:          0 :         mpOStm->Seek( 0 );
     332                 :          0 :         sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW;
     333                 :          0 :         sal_uInt16 pDeterminedFormat = GRFILTER_FORMAT_DONTKNOW;
     334 [ #  # ][ #  # ]:          0 :         GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, String(), *mpOStm ,nFormat,&pDeterminedFormat );
         [ #  # ][ #  # ]
     335                 :            : 
     336         [ #  # ]:          0 :         if (pDeterminedFormat == GRFILTER_FORMAT_DONTKNOW)
     337                 :            :         {
     338                 :            :             //Read the first two byte to check whether it is a gzipped stream, is so it may be in wmz or emz format
     339                 :            :             //unzip them and try again
     340                 :            : 
     341                 :            :             sal_uInt8    sFirstBytes[ 2 ];
     342                 :            : 
     343         [ #  # ]:          0 :             mpOStm->Seek( STREAM_SEEK_TO_END );
     344                 :          0 :             sal_uIntPtr nStreamLen = mpOStm->Tell();
     345         [ #  # ]:          0 :             mpOStm->Seek( 0 );
     346                 :            : 
     347         [ #  # ]:          0 :             if ( !nStreamLen )
     348                 :            :             {
     349                 :          0 :                 SvLockBytes* pLockBytes = mpOStm->GetLockBytes();
     350         [ #  # ]:          0 :                 if ( pLockBytes  )
     351         [ #  # ]:          0 :                     pLockBytes->SetSynchronMode( sal_True );
     352                 :            : 
     353         [ #  # ]:          0 :                 mpOStm->Seek( STREAM_SEEK_TO_END );
     354                 :          0 :                 nStreamLen = mpOStm->Tell();
     355         [ #  # ]:          0 :                 mpOStm->Seek( 0 );
     356                 :            :             }
     357         [ #  # ]:          0 :             if( nStreamLen >= 2 )
     358                 :            :             {
     359                 :            :                 //read two byte
     360         [ #  # ]:          0 :                 mpOStm->Read( sFirstBytes, 2 );
     361                 :            : 
     362 [ #  # ][ #  # ]:          0 :                 if( sFirstBytes[0] == 0x1f && sFirstBytes[1] == 0x8b )
     363                 :            :                 {
     364 [ #  # ][ #  # ]:          0 :                     SvMemoryStream* pDest = new SvMemoryStream;
     365         [ #  # ]:          0 :                     ZCodec aZCodec( 0x8000, 0x8000 );
     366         [ #  # ]:          0 :                     aZCodec.BeginCompression(ZCODEC_GZ_LIB);
     367         [ #  # ]:          0 :                     mpOStm->Seek( 0 );
     368         [ #  # ]:          0 :                     aZCodec.Decompress( *mpOStm, *pDest );
     369                 :            : 
     370 [ #  # ][ #  # ]:          0 :                     if (aZCodec.EndCompression() && pDest )
         [ #  # ][ #  # ]
     371                 :            :                     {
     372         [ #  # ]:          0 :                         pDest->Seek( STREAM_SEEK_TO_END );
     373                 :          0 :                         sal_uIntPtr nStreamLen_ = pDest->Tell();
     374         [ #  # ]:          0 :                         if (nStreamLen_)
     375                 :            :                         {
     376         [ #  # ]:          0 :                             pDest->Seek(0L);
     377 [ #  # ][ #  # ]:          0 :                             GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, String(), *pDest ,nFormat,&pDeterminedFormat );
         [ #  # ][ #  # ]
     378                 :            :                         }
     379                 :            :                     }
     380 [ #  # ][ #  # ]:          0 :                     delete pDest;
                 [ #  # ]
     381                 :            :                 }
     382                 :            :             }
     383                 :            :         }
     384                 :            : 
     385 [ #  # ][ #  # ]:          0 :         maGrfObj = aGraphic;
                 [ #  # ]
     386         [ #  # ]:          0 :         if( maGrfObj.GetType() != GRAPHIC_NONE )
     387                 :            :         {
     388 [ #  # ][ #  # ]:          0 :             delete mpOStm, mpOStm = NULL;
     389 [ #  # ][ #  # ]:          0 :             delete mpTmp, mpTmp = NULL;
     390         [ #  # ]:          0 :         }
     391                 :            :     }
     392                 :            : 
     393                 :          0 :     return maGrfObj;
     394                 :            : }
     395                 :            : 
     396                 :            : // ----------------------
     397                 :            : // - SvXMLGraphicHelper -
     398                 :            : // ----------------------
     399                 :            : 
     400                 :        210 : SvXMLGraphicHelper::SvXMLGraphicHelper( SvXMLGraphicHelperMode eCreateMode ) :
     401                 :            :     ::cppu::WeakComponentImplHelper2< ::com::sun::star::document::XGraphicObjectResolver,
     402 [ +  - ][ +  - ]:        210 :                                       ::com::sun::star::document::XBinaryStreamResolver >( maMutex )
         [ +  - ][ +  - ]
                 [ +  - ]
     403                 :            : {
     404 [ +  - ][ +  - ]:        210 :     Init( NULL, eCreateMode, sal_False );
     405                 :        210 : }
     406                 :            : 
     407                 :        263 : SvXMLGraphicHelper::SvXMLGraphicHelper() :
     408                 :            :     ::cppu::WeakComponentImplHelper2< ::com::sun::star::document::XGraphicObjectResolver,
     409 [ +  - ][ +  - ]:        263 :                                       ::com::sun::star::document::XBinaryStreamResolver >( maMutex )
         [ +  - ][ +  - ]
                 [ +  - ]
     410                 :            : {
     411                 :        263 : }
     412                 :            : 
     413                 :            : // -----------------------------------------------------------------------------
     414                 :            : 
     415         [ +  - ]:        473 : SvXMLGraphicHelper::~SvXMLGraphicHelper()
     416                 :            : {
     417         [ -  + ]:        946 : }
     418                 :            : 
     419                 :            : // -----------------------------------------------------------------------------
     420                 :            : 
     421                 :        473 : void SAL_CALL SvXMLGraphicHelper::disposing()
     422                 :            : {
     423                 :        473 : }
     424                 :            : 
     425                 :            : // -----------------------------------------------------------------------------
     426                 :            : 
     427                 :        180 : sal_Bool SvXMLGraphicHelper::ImplGetStreamNames( const ::rtl::OUString& rURLStr,
     428                 :            :                                                  ::rtl::OUString& rPictureStorageName,
     429                 :            :                                                  ::rtl::OUString& rPictureStreamName )
     430                 :            : {
     431         [ +  - ]:        180 :     String      aURLStr( rURLStr );
     432                 :        180 :     sal_Bool    bRet = sal_False;
     433                 :            : 
     434         [ +  - ]:        180 :     if( aURLStr.Len() )
     435                 :            :     {
     436 [ +  - ][ +  - ]:        180 :         aURLStr = aURLStr.GetToken( comphelper::string::getTokenCount(aURLStr, ':') - 1, ':' );
         [ +  - ][ +  - ]
                 [ +  - ]
     437                 :            : 
     438 [ +  - ][ +  - ]:        180 :         const sal_uInt32 nTokenCount = comphelper::string::getTokenCount(aURLStr, '/');
     439                 :            : 
     440         [ -  + ]:        180 :         if( 1 == nTokenCount )
     441                 :            :         {
     442 [ #  # ][ #  # ]:          0 :             rPictureStorageName = String(  XML_GRAPHICSTORAGE_NAME  );
                 [ #  # ]
     443         [ #  # ]:          0 :             rPictureStreamName = aURLStr;
     444                 :            :         }
     445                 :            :         else
     446 [ +  - ][ +  - ]:        180 :             SvXMLEmbeddedObjectHelper::splitObjectURL(aURLStr, rPictureStorageName, rPictureStreamName);
     447                 :            : 
     448                 :        180 :         bRet = !rPictureStreamName.isEmpty();
     449                 :            :         SAL_WARN_IF(!bRet, "svx", "SvXMLGraphicHelper::ImplInsertGraphicURL: invalid scheme: " << rURLStr);
     450                 :            :     }
     451                 :            : 
     452         [ +  - ]:        180 :     return bRet;
     453                 :            : }
     454                 :            : 
     455                 :            : // -----------------------------------------------------------------------------
     456                 :            : 
     457                 :        180 : uno::Reference < embed::XStorage > SvXMLGraphicHelper::ImplGetGraphicStorage( const ::rtl::OUString& rStorageName )
     458                 :            : {
     459                 :        180 :     uno::Reference < embed::XStorage > xRetStorage;
     460         [ +  - ]:        180 :     if( mxRootStorage.is() )
     461                 :            :     {
     462                 :            :         try
     463                 :            :         {
     464         [ +  - ]:        180 :             xRetStorage = mxRootStorage->openStorageElement(
     465                 :        180 :                 maCurStorageName = rStorageName,
     466                 :            :                 ( GRAPHICHELPER_MODE_WRITE == meCreateMode )
     467                 :            :                     ? embed::ElementModes::READWRITE
     468 [ -  + ][ +  - ]:        360 :                     : embed::ElementModes::READ );
         [ +  - ][ #  # ]
     469                 :            :         }
     470         [ #  # ]:          0 :         catch ( uno::Exception& )
     471                 :            :         {
     472                 :            :         }
     473                 :            :         //#i43196# try again to open the storage element - this time readonly
     474         [ -  + ]:        180 :         if(!xRetStorage.is())
     475                 :            :         {
     476                 :            :             try
     477                 :            :             {
     478 [ #  # ][ #  # ]:          0 :                 xRetStorage = mxRootStorage->openStorageElement( maCurStorageName = rStorageName, embed::ElementModes::READ );
         [ #  # ][ #  # ]
     479                 :            :             }
     480         [ #  # ]:          0 :             catch ( uno::Exception& )
     481                 :            :             {
     482                 :            :             }
     483                 :            :         }
     484                 :            :     }
     485                 :            : 
     486                 :        180 :     return xRetStorage;
     487                 :            : }
     488                 :            : 
     489                 :            : // -----------------------------------------------------------------------------
     490                 :            : 
     491                 :        180 : SvxGraphicHelperStream_Impl SvXMLGraphicHelper::ImplGetGraphicStream( const ::rtl::OUString& rPictureStorageName,
     492                 :            :                                                               const ::rtl::OUString& rPictureStreamName,
     493                 :            :                                                               sal_Bool bTruncate )
     494                 :            : {
     495                 :        180 :     SvxGraphicHelperStream_Impl aRet;
     496 [ +  - ][ +  - ]:        180 :     aRet.xStorage = ImplGetGraphicStorage( rPictureStorageName );
     497                 :            : 
     498         [ +  - ]:        180 :     if( aRet.xStorage.is() )
     499                 :            :     {
     500                 :        180 :         sal_Int32 nMode = embed::ElementModes::READ;
     501         [ -  + ]:        180 :         if ( GRAPHICHELPER_MODE_WRITE == meCreateMode )
     502                 :            :         {
     503                 :          0 :             nMode = embed::ElementModes::READWRITE;
     504         [ #  # ]:          0 :             if ( bTruncate )
     505                 :          0 :                 nMode |= embed::ElementModes::TRUNCATE;
     506                 :            :         }
     507                 :            : 
     508 [ +  - ][ +  - ]:        180 :         aRet.xStream = aRet.xStorage->openStreamElement( rPictureStreamName, nMode );
                 [ +  - ]
     509 [ -  + ][ -  + ]:        180 :         if( aRet.xStream.is() && ( GRAPHICHELPER_MODE_WRITE == meCreateMode ) )
                 [ +  - ]
     510                 :            :         {
     511                 :          0 :             ::rtl::OUString aPropName( "UseCommonStoragePasswordEncryption" );
     512         [ #  # ]:          0 :             uno::Reference < beans::XPropertySet > xProps( aRet.xStream, uno::UNO_QUERY );
     513 [ #  # ][ #  # ]:          0 :             xProps->setPropertyValue( aPropName, uno::makeAny( sal_True) );
                 [ #  # ]
     514                 :            :         }
     515                 :            :     }
     516                 :            : 
     517                 :        180 :     return aRet;
     518                 :            : }
     519                 :            : 
     520                 :            : // -----------------------------------------------------------------------------
     521                 :            : 
     522                 :          0 : String SvXMLGraphicHelper::ImplGetGraphicMimeType( const String& rFileName ) const
     523                 :            : {
     524                 :            :     struct XMLGraphicMimeTypeMapper
     525                 :            :     {
     526                 :            :         const char* pExt;
     527                 :            :         const char* pMimeType;
     528                 :            :     };
     529                 :            : 
     530                 :            :     static XMLGraphicMimeTypeMapper aMapper[] =
     531                 :            :     {
     532                 :            :         { "gif", "image/gif" },
     533                 :            :         { "png", "image/png" },
     534                 :            :         { "jpg", "image/jpeg" },
     535                 :            :         { "tif", "image/tiff" },
     536                 :            :         { "svg", "image/svg+xml" }
     537                 :            :     };
     538                 :            : 
     539                 :          0 :     String aMimeType;
     540                 :            : 
     541 [ #  # ][ #  # ]:          0 :     if( ( rFileName.Len() >= 4 ) && ( rFileName.GetChar( rFileName.Len() - 4 ) == '.' ) )
                 [ #  # ]
     542                 :            :     {
     543                 :          0 :         const rtl::OString aExt(rtl::OUStringToOString(rFileName.Copy(rFileName.Len() - 3),
     544 [ #  # ][ #  # ]:          0 :             RTL_TEXTENCODING_ASCII_US));
         [ #  # ][ #  # ]
     545                 :            : 
     546 [ #  # ][ #  # ]:          0 :         for( long i = 0, nCount = sizeof (aMapper) / sizeof (aMapper[0]); ( i < nCount ) && !aMimeType.Len(); i++ )
                 [ #  # ]
     547         [ #  # ]:          0 :             if( aExt.getStr() == aMapper[ i ].pExt )
     548 [ #  # ][ #  # ]:          0 :                 aMimeType = String( aMapper[ i ].pMimeType, RTL_TEXTENCODING_ASCII_US );
                 [ #  # ]
     549                 :            :     }
     550                 :            : 
     551                 :          0 :     return aMimeType;
     552                 :            : }
     553                 :            : 
     554                 :            : // -----------------------------------------------------------------------------
     555                 :            : 
     556                 :        180 : Graphic SvXMLGraphicHelper::ImplReadGraphic( const ::rtl::OUString& rPictureStorageName,
     557                 :            :                                              const ::rtl::OUString& rPictureStreamName )
     558                 :            : {
     559         [ +  - ]:        180 :     Graphic             aGraphic;
     560         [ +  - ]:        180 :     SvxGraphicHelperStream_Impl aStream( ImplGetGraphicStream( rPictureStorageName, rPictureStreamName, sal_False ) );
     561         [ +  - ]:        180 :     if( aStream.xStream.is() )
     562                 :            :     {
     563         [ +  - ]:        180 :         SvStream* pStream = utl::UcbStreamHelper::CreateStream( aStream.xStream );
     564 [ +  - ][ +  - ]:        180 :         GraphicFilter::GetGraphicFilter().ImportGraphic( aGraphic, String(), *pStream );
         [ +  - ][ +  - ]
     565 [ +  - ][ +  - ]:        180 :         delete pStream;
     566                 :            :     }
     567                 :            : 
     568         [ +  - ]:        180 :     return aGraphic;
     569                 :            : }
     570                 :            : 
     571                 :            : // -----------------------------------------------------------------------------
     572                 :            : 
     573                 :          0 : sal_Bool SvXMLGraphicHelper::ImplWriteGraphic( const ::rtl::OUString& rPictureStorageName,
     574                 :            :                                                const ::rtl::OUString& rPictureStreamName,
     575                 :            :                                                const ::rtl::OUString& rGraphicId,
     576                 :            :                                                bool bUseGfxLink )
     577                 :            : {
     578 [ #  # ][ #  # ]:          0 :     GraphicObject   aGrfObject( rtl::OUStringToOString(rGraphicId, RTL_TEXTENCODING_ASCII_US) );
     579                 :          0 :     sal_Bool        bRet = sal_False;
     580                 :            : 
     581         [ #  # ]:          0 :     if( aGrfObject.GetType() != GRAPHIC_NONE )
     582                 :            :     {
     583         [ #  # ]:          0 :         SvxGraphicHelperStream_Impl aStream( ImplGetGraphicStream( rPictureStorageName, rPictureStreamName, sal_False ) );
     584         [ #  # ]:          0 :         if( aStream.xStream.is() )
     585                 :            :         {
     586 [ #  # ][ #  # ]:          0 :             Graphic         aGraphic( (Graphic&) aGrfObject.GetGraphic() );
     587         [ #  # ]:          0 :             const GfxLink   aGfxLink( aGraphic.GetLink() );
     588 [ #  # ][ #  # ]:          0 :             const ::rtl::OUString  aMimeType( ImplGetGraphicMimeType( rPictureStreamName ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     589                 :          0 :             uno::Any        aAny;
     590         [ #  # ]:          0 :             uno::Reference < beans::XPropertySet > xProps( aStream.xStream, uno::UNO_QUERY );
     591                 :            : 
     592                 :            :             // set stream properties (MediaType/Compression)
     593         [ #  # ]:          0 :             if( !aMimeType.isEmpty() )
     594                 :            :             {
     595         [ #  # ]:          0 :                 aAny <<= aMimeType;
     596 [ #  # ][ #  # ]:          0 :                 xProps->setPropertyValue( String(  "MediaType"  ), aAny );
         [ #  # ][ #  # ]
                 [ #  # ]
     597                 :            :             }
     598                 :            : 
     599 [ #  # ][ #  # ]:          0 :             const sal_Bool bCompressed = aMimeType.isEmpty() || aMimeType == "image/tiff";
     600         [ #  # ]:          0 :             aAny <<= bCompressed;
     601 [ #  # ][ #  # ]:          0 :             xProps->setPropertyValue( String(  "Compressed"  ), aAny );
         [ #  # ][ #  # ]
                 [ #  # ]
     602                 :            : 
     603         [ #  # ]:          0 :             SvStream* pStream = utl::UcbStreamHelper::CreateStream( aStream.xStream );
     604 [ #  # ][ #  # ]:          0 :             if( bUseGfxLink && aGfxLink.GetDataSize() && aGfxLink.GetData() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     605 [ #  # ][ #  # ]:          0 :                 pStream->Write( aGfxLink.GetData(), aGfxLink.GetDataSize() );
                 [ #  # ]
     606                 :            :             else
     607                 :            :             {
     608 [ #  # ][ #  # ]:          0 :                 if( aGraphic.GetType() == GRAPHIC_BITMAP )
     609                 :            :                 {
     610         [ #  # ]:          0 :                     GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
     611         [ #  # ]:          0 :                     String          aFormat;
     612                 :            : 
     613 [ #  # ][ #  # ]:          0 :                     if( aGraphic.IsAnimated() )
     614 [ #  # ][ #  # ]:          0 :                         aFormat = String(  "gif"  );
                 [ #  # ]
     615                 :            :                     else
     616 [ #  # ][ #  # ]:          0 :                         aFormat = String(  "png"  );
                 [ #  # ]
     617                 :            : 
     618                 :            :                     bRet = ( rFilter.ExportGraphic( aGraphic, String(), *pStream,
     619 [ #  # ][ #  # ]:          0 :                                                      rFilter.GetExportFormatNumberForShortName( aFormat ) ) == 0 );
         [ #  # ][ #  # ]
                 [ #  # ]
     620                 :            :                 }
     621 [ #  # ][ #  # ]:          0 :                 else if( aGraphic.GetType() == GRAPHIC_GDIMETAFILE )
     622                 :            :                 {
     623                 :          0 :                     pStream->SetVersion( SOFFICE_FILEFORMAT_8 );
     624                 :          0 :                     pStream->SetCompressMode( COMPRESSMODE_ZBITMAP );
     625                 :            : 
     626                 :            :                     // SJ: first check if this metafile is just a eps file, then we will store the eps instead of svm
     627         [ #  # ]:          0 :                     GDIMetaFile& rMtf( (GDIMetaFile&)aGraphic.GetGDIMetaFile() );
     628         [ #  # ]:          0 :                     const MetaCommentAction* pComment = ImplCheckForEPS( rMtf );
     629         [ #  # ]:          0 :                     if ( pComment )
     630                 :            :                     {
     631                 :          0 :                         sal_uInt32  nSize = pComment->GetDataSize();
     632                 :          0 :                         const sal_uInt8* pData = pComment->GetData();
     633 [ #  # ][ #  # ]:          0 :                         if ( nSize && pData )
     634         [ #  # ]:          0 :                             pStream->Write( pData, nSize );
     635                 :            : 
     636         [ #  # ]:          0 :                         const MetaEPSAction* pAct = ( (const MetaEPSAction*)rMtf.FirstAction() );
     637                 :          0 :                         const GfxLink&       rLink = pAct->GetLink();
     638                 :            : 
     639 [ #  # ][ #  # ]:          0 :                         pStream->Write( rLink.GetData(), rLink.GetDataSize() );
                 [ #  # ]
     640                 :            :                     }
     641                 :            :                     else
     642         [ #  # ]:          0 :                         rMtf.Write( *pStream, GDIMETAFILE_WRITE_REPLACEMENT_RENDERGRAPHIC );
     643                 :            : 
     644                 :          0 :                     bRet = ( pStream->GetError() == 0 );
     645                 :            :                 }
     646                 :            :             }
     647                 :            :             uno::Reference < embed::XTransactedObject > xStorage(
     648         [ #  # ]:          0 :                                     aStream.xStorage, uno::UNO_QUERY);
     649 [ #  # ][ #  # ]:          0 :             delete pStream;
     650 [ #  # ][ #  # ]:          0 :             aStream.xStream->getOutputStream()->closeOutput();
         [ #  # ][ #  # ]
     651         [ #  # ]:          0 :             if( xStorage.is() )
     652 [ #  # ][ #  # ]:          0 :                 xStorage->commit();
         [ #  # ][ #  # ]
     653         [ #  # ]:          0 :         }
     654                 :            :     }
     655                 :            : 
     656         [ #  # ]:          0 :     return bRet;
     657                 :            : }
     658                 :            : 
     659                 :            : // -----------------------------------------------------------------------------
     660                 :            : 
     661                 :        180 : void SvXMLGraphicHelper::ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, sal_uInt32 nInsertPos, rtl::OUString& rRequestedFileName )
     662                 :            : {
     663                 :        180 :     rtl::OUString aURLString( rURLStr );
     664                 :        180 :     ::rtl::OUString aPictureStorageName, aPictureStreamName;
     665 [ -  + ][ +  - ]:        180 :     if( ( maURLSet.find( aURLString ) != maURLSet.end() ) )
     666                 :            :     {
     667                 :          0 :         URLPairVector::iterator aIter( maGrfURLs.begin() ), aEnd( maGrfURLs.end() );
     668 [ #  # ][ #  # ]:          0 :         while( aIter != aEnd )
     669                 :            :         {
     670         [ #  # ]:          0 :             if( aURLString == (*aIter).first )
     671                 :            :             {
     672                 :          0 :                 maGrfURLs[ nInsertPos ].second = (*aIter).second;
     673                 :          0 :                 aIter = aEnd;
     674                 :            :             }
     675                 :            :             else
     676         [ #  # ]:          0 :                 aIter++;
     677                 :            :         }
     678                 :            :     }
     679 [ +  - ][ +  - ]:        180 :     else if( ImplGetStreamNames( aURLString, aPictureStorageName, aPictureStreamName ) )
     680                 :            :     {
     681                 :        180 :         URLPair& rURLPair = maGrfURLs[ nInsertPos ];
     682                 :            : 
     683         [ +  - ]:        180 :         if( GRAPHICHELPER_MODE_READ == meCreateMode )
     684                 :            :         {
     685 [ +  - ][ +  - ]:        180 :             const GraphicObject aObj( ImplReadGraphic( aPictureStorageName, aPictureStreamName ) );
                 [ +  - ]
     686                 :            : 
     687         [ +  - ]:        180 :             if( aObj.GetType() != GRAPHIC_NONE )
     688                 :            :             {
     689         [ +  - ]:        180 :                 maGrfObjs.push_back( aObj );
     690                 :        180 :                 ::rtl::OUString aBaseURL(  XML_GRAPHICOBJECT_URL_BASE  );
     691                 :            : 
     692                 :        180 :                 rURLPair.second = aBaseURL;
     693                 :            :                 rURLPair.second += rtl::OStringToOUString(aObj.GetUniqueID(),
     694 [ +  - ][ +  - ]:        180 :                     RTL_TEXTENCODING_ASCII_US);
     695                 :            :             }
     696                 :            :             else
     697 [ #  # ][ #  # ]:        180 :                 rURLPair.second = String();
         [ #  # ][ +  - ]
     698                 :            :         }
     699                 :            :         else
     700                 :            :         {
     701         [ #  # ]:          0 :             const String        aGraphicObjectId( aPictureStreamName );
     702 [ #  # ][ #  # ]:          0 :             const rtl::OString aAsciiObjectID(rtl::OUStringToOString(aGraphicObjectId, RTL_TEXTENCODING_ASCII_US));
     703         [ #  # ]:          0 :             const GraphicObject aGrfObject( aAsciiObjectID );
     704         [ #  # ]:          0 :             if( aGrfObject.GetType() != GRAPHIC_NONE )
     705                 :            :             {
     706         [ #  # ]:          0 :                 String          aStreamName( aGraphicObjectId );
     707 [ #  # ][ #  # ]:          0 :                 Graphic         aGraphic( (Graphic&) aGrfObject.GetGraphic() );
     708         [ #  # ]:          0 :                 const GfxLink   aGfxLink( aGraphic.GetLink() );
     709         [ #  # ]:          0 :                 String          aExtension;
     710                 :          0 :                 bool            bUseGfxLink( true );
     711                 :            : 
     712 [ #  # ][ #  # ]:          0 :                 if( aGfxLink.GetDataSize() )
     713                 :            :                 {
     714 [ #  # ][ #  #  :          0 :                     switch( aGfxLink.GetType() )
          #  #  #  #  #  
                #  #  # ]
     715                 :            :                     {
     716 [ #  # ][ #  # ]:          0 :                         case( GFX_LINK_TYPE_EPS_BUFFER ): aExtension = String(  ".eps"  ); break;
                 [ #  # ]
     717 [ #  # ][ #  # ]:          0 :                         case( GFX_LINK_TYPE_NATIVE_GIF ): aExtension = String(  ".gif"  ); break;
                 [ #  # ]
     718 [ #  # ][ #  # ]:          0 :                         case( GFX_LINK_TYPE_NATIVE_JPG ): aExtension = String(  ".jpg"  ); break;
                 [ #  # ]
     719 [ #  # ][ #  # ]:          0 :                         case( GFX_LINK_TYPE_NATIVE_PNG ): aExtension = String(  ".png"  ); break;
                 [ #  # ]
     720 [ #  # ][ #  # ]:          0 :                         case( GFX_LINK_TYPE_NATIVE_TIF ): aExtension = String(  ".tif"  ); break;
                 [ #  # ]
     721 [ #  # ][ #  # ]:          0 :                         case( GFX_LINK_TYPE_NATIVE_WMF ): aExtension = String(  ".wmf"  ); break;
                 [ #  # ]
     722 [ #  # ][ #  # ]:          0 :                         case( GFX_LINK_TYPE_NATIVE_MET ): aExtension = String(  ".met"  ); break;
                 [ #  # ]
     723 [ #  # ][ #  # ]:          0 :                         case( GFX_LINK_TYPE_NATIVE_PCT ): aExtension = String(  ".pct"  ); break;
                 [ #  # ]
     724                 :            :                         case( GFX_LINK_TYPE_NATIVE_SVG ): 
     725                 :            :                             // backward-compat kludge: since no released OOo
     726                 :            :                             // version to date can handle svg properly, wrap it up
     727                 :            :                             // into an svm. slight catch22 here, since strict ODF
     728                 :            :                             // conformance _recommends_ svg - then again, most old
     729                 :            :                             // ODF consumers are believed to be OOo
     730 [ #  # ][ #  # ]:          0 :                             if( SvtSaveOptions().GetODFDefaultVersion() <= SvtSaveOptions::ODFVER_012 )
         [ #  # ][ #  # ]
     731                 :            :                             {
     732                 :          0 :                                 bUseGfxLink = false;
     733 [ #  # ][ #  # ]:          0 :                                 aExtension = String(  ".svm"  );
                 [ #  # ]
     734                 :            :                             }
     735                 :            :                             else
     736 [ #  # ][ #  # ]:          0 :                                 aExtension = String(  ".svg"  );
                 [ #  # ]
     737                 :          0 :                             break;
     738                 :            : 
     739                 :            :                         default:
     740 [ #  # ][ #  # ]:          0 :                             aExtension = String(  ".grf"  );
                 [ #  # ]
     741                 :          0 :                         break;
     742                 :            :                     }
     743                 :            :                 }
     744                 :            :                 else
     745                 :            :                 {
     746         [ #  # ]:          0 :                     if( aGrfObject.GetType() == GRAPHIC_BITMAP )
     747                 :            :                     {
     748         [ #  # ]:          0 :                         if( aGrfObject.IsAnimated() )
     749 [ #  # ][ #  # ]:          0 :                             aExtension = String(  ".gif"  );
                 [ #  # ]
     750                 :            :                         else
     751 [ #  # ][ #  # ]:          0 :                             aExtension = String(  ".png"  );
                 [ #  # ]
     752                 :            :                     }
     753         [ #  # ]:          0 :                     else if( aGrfObject.GetType() == GRAPHIC_GDIMETAFILE )
     754                 :            :                     {
     755                 :            :                         // SJ: first check if this metafile is just a eps file, then we will store the eps instead of svm
     756         [ #  # ]:          0 :                         GDIMetaFile& rMtf( (GDIMetaFile&)aGraphic.GetGDIMetaFile() );
     757 [ #  # ][ #  # ]:          0 :                         if ( ImplCheckForEPS( rMtf ) )
     758 [ #  # ][ #  # ]:          0 :                             aExtension = String(  ".eps"  );
                 [ #  # ]
     759                 :            :                         else
     760 [ #  # ][ #  # ]:          0 :                             aExtension = String(  ".svm"  );
                 [ #  # ]
     761                 :            :                     }
     762                 :            :                 }
     763                 :            : 
     764                 :          0 :                 rtl::OUString aURLEntry;
     765         [ #  # ]:          0 :                 const String sPictures(  "Pictures/"  );
     766                 :            : 
     767         [ #  # ]:          0 :                 if ( !rRequestedFileName.isEmpty() )
     768                 :            :                 {
     769         [ #  # ]:          0 :                     aURLEntry = sPictures;
     770                 :          0 :                     aURLEntry += rRequestedFileName;
     771         [ #  # ]:          0 :                     aURLEntry += aExtension;
     772                 :            : 
     773                 :          0 :                     URLPairVector::iterator aIter( maGrfURLs.begin() ), aEnd( maGrfURLs.end() );
     774 [ #  # ][ #  # ]:          0 :                     while( aIter != aEnd )
     775                 :            :                     {
     776         [ #  # ]:          0 :                         if( aURLEntry == (*aIter).second )
     777                 :          0 :                             break;
     778         [ #  # ]:          0 :                         aIter++;
     779                 :            :                     }
     780 [ #  # ][ #  # ]:          0 :                     if ( aIter == aEnd )
     781         [ #  # ]:          0 :                         aStreamName = rRequestedFileName;
     782                 :            :                 }
     783                 :            : 
     784         [ #  # ]:          0 :                 aStreamName += aExtension;
     785                 :            : 
     786 [ #  # ][ #  # ]:          0 :                 if( mbDirect && aStreamName.Len() )
                 [ #  # ]
     787 [ #  # ][ #  # ]:          0 :                     ImplWriteGraphic( aPictureStorageName, aStreamName, aGraphicObjectId, bUseGfxLink );
                 [ #  # ]
     788                 :            : 
     789         [ #  # ]:          0 :                 rURLPair.second = sPictures;
     790 [ #  # ][ #  # ]:          0 :                 rURLPair.second += aStreamName;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     791 [ #  # ][ #  # ]:          0 :             }
     792                 :            : #if OSL_DEBUG_LEVEL > 0
     793                 :            :             else
     794                 :            :             {
     795                 :            :                 rtl::OStringBuffer sMessage(
     796                 :            :                     RTL_CONSTASCII_STRINGPARAM("graphic object with ID '"));
     797                 :            :                 sMessage.append(aAsciiObjectID).
     798                 :            :                     append(RTL_CONSTASCII_STRINGPARAM("' has an unknown type"));
     799                 :            :                 OSL_ENSURE( false, sMessage.getStr() );
     800                 :            :             }
     801                 :            : #endif
     802                 :            :         }
     803                 :            : 
     804         [ +  - ]:        180 :         maURLSet.insert( aURLString );
     805                 :        180 :     }
     806                 :        180 : }
     807                 :            : 
     808                 :            : // -----------------------------------------------------------------------------
     809                 :            : 
     810                 :        473 : void SvXMLGraphicHelper::Init( const uno::Reference < embed::XStorage >& rXMLStorage,
     811                 :            :                                SvXMLGraphicHelperMode eCreateMode,
     812                 :            :                                sal_Bool bDirect )
     813                 :            : {
     814                 :        473 :     mxRootStorage = rXMLStorage;
     815                 :        473 :     meCreateMode = eCreateMode;
     816         [ +  + ]:        473 :     mbDirect = ( ( GRAPHICHELPER_MODE_READ == meCreateMode ) ? bDirect : sal_True );
     817                 :        473 : }
     818                 :            : 
     819                 :            : // -----------------------------------------------------------------------------
     820                 :            : 
     821                 :        223 : SvXMLGraphicHelper* SvXMLGraphicHelper::Create( const uno::Reference < embed::XStorage >& rXMLStorage,
     822                 :            :                                                 SvXMLGraphicHelperMode eCreateMode,
     823                 :            :                                                 sal_Bool bDirect )
     824                 :            : {
     825         [ +  - ]:        223 :     SvXMLGraphicHelper* pThis = new SvXMLGraphicHelper;
     826                 :            : 
     827                 :        223 :     pThis->acquire();
     828                 :        223 :     pThis->Init( rXMLStorage, eCreateMode, bDirect );
     829                 :            : 
     830                 :        223 :     return pThis;
     831                 :            : }
     832                 :            : 
     833                 :            : // -----------------------------------------------------------------------------
     834                 :            : 
     835                 :         40 : SvXMLGraphicHelper* SvXMLGraphicHelper::Create( SvXMLGraphicHelperMode eCreateMode )
     836                 :            : {
     837         [ +  - ]:         40 :     SvXMLGraphicHelper* pThis = new SvXMLGraphicHelper;
     838                 :            : 
     839                 :         40 :     pThis->acquire();
     840         [ +  - ]:         40 :     pThis->Init( NULL, eCreateMode, sal_False );
     841                 :            : 
     842                 :         40 :     return pThis;
     843                 :            : }
     844                 :            : 
     845                 :            : // -----------------------------------------------------------------------------
     846                 :            : 
     847                 :        248 : void SvXMLGraphicHelper::Destroy( SvXMLGraphicHelper* pSvXMLGraphicHelper )
     848                 :            : {
     849         [ +  - ]:        248 :     if( pSvXMLGraphicHelper )
     850                 :            :     {
     851                 :        248 :         pSvXMLGraphicHelper->dispose();
     852                 :        248 :         pSvXMLGraphicHelper->release();
     853                 :            :     }
     854                 :        248 : }
     855                 :            : 
     856                 :            : // -----------------------------------------------------------------------------
     857                 :            : 
     858                 :            : // XGraphicObjectResolver
     859                 :        180 : ::rtl::OUString SAL_CALL SvXMLGraphicHelper::resolveGraphicObjectURL( const ::rtl::OUString& rURL )
     860                 :            :     throw(uno::RuntimeException)
     861                 :            : {
     862         [ +  - ]:        180 :     ::osl::MutexGuard   aGuard( maMutex );
     863                 :        180 :     const sal_Int32     nIndex = maGrfURLs.size();
     864                 :            : 
     865                 :        180 :     rtl::OUString aURL( rURL );
     866                 :        180 :     rtl::OUString aUserData;
     867                 :        180 :     rtl::OUString aRequestedFileName;
     868                 :            : 
     869                 :        180 :     sal_Int32 nUser = rURL.indexOf( '?', 0 );
     870         [ -  + ]:        180 :     if ( nUser >= 0 )
     871                 :            :     {
     872                 :          0 :         aURL = rtl::OUString( rURL.copy( 0, nUser ) );
     873                 :          0 :         nUser++;
     874                 :          0 :         aUserData = rURL.copy( nUser, rURL.getLength() - nUser );
     875                 :            :     }
     876         [ -  + ]:        180 :     if ( !aUserData.isEmpty() )
     877                 :            :     {
     878                 :          0 :         sal_Int32 nIndex2 = 0;
     879         [ #  # ]:          0 :         do
     880                 :            :         {
     881                 :          0 :             rtl::OUString aToken = aUserData.getToken( 0, ';', nIndex2 );
     882                 :          0 :             sal_Int32 n = aToken.indexOf( '=' );
     883 [ #  # ][ #  # ]:          0 :             if ( ( n > 0 ) && ( ( n + 1 ) < aToken.getLength() ) )
                 [ #  # ]
     884                 :            :             {
     885                 :          0 :                 rtl::OUString aParam( aToken.copy( 0, n ) );
     886                 :          0 :                 rtl::OUString aValue( aToken.copy( n + 1, aToken.getLength() - ( n + 1 ) ) );
     887                 :            : 
     888                 :          0 :                 const rtl::OUString sRequestedName( "requestedName" );
     889         [ #  # ]:          0 :                 if ( aParam.match( sRequestedName ) )
     890                 :          0 :                     aRequestedFileName = aValue;
     891                 :          0 :             }
     892                 :            :         }
     893                 :            :         while ( nIndex2 >= 0 );
     894                 :            :     }
     895                 :            : 
     896         [ +  - ]:        180 :     maGrfURLs.push_back( ::std::make_pair( aURL, ::rtl::OUString() ) );
     897         [ +  - ]:        180 :     ImplInsertGraphicURL( aURL, nIndex, aRequestedFileName );
     898                 :            : 
     899         [ +  - ]:        180 :     return maGrfURLs[ nIndex ].second;
     900                 :            : }
     901                 :            : 
     902                 :            : // -----------------------------------------------------------------------------
     903                 :            : 
     904                 :            : // XBinaryStreamResolver
     905                 :          0 : Reference< XInputStream > SAL_CALL SvXMLGraphicHelper::getInputStream( const ::rtl::OUString& rURL )
     906                 :            :     throw( RuntimeException )
     907                 :            : {
     908                 :          0 :     Reference< XInputStream >   xRet;
     909                 :          0 :     ::rtl::OUString                    aPictureStorageName, aGraphicId;
     910                 :            : 
     911                 :            : 
     912 [ #  # ][ #  # ]:          0 :     if( ( GRAPHICHELPER_MODE_WRITE == meCreateMode ) &&
                 [ #  # ]
     913         [ #  # ]:          0 :         ImplGetStreamNames( rURL, aPictureStorageName, aGraphicId ) )
     914                 :            :     {
     915         [ #  # ]:          0 :         SvXMLGraphicInputStream* pInputStream = new SvXMLGraphicInputStream( aGraphicId );
     916                 :            : 
     917         [ #  # ]:          0 :         if( pInputStream->Exists() )
     918 [ #  # ][ #  # ]:          0 :             xRet = pInputStream;
     919                 :            :         else
     920 [ #  # ][ #  # ]:          0 :             delete pInputStream;
     921                 :            :     }
     922                 :            : 
     923                 :          0 :     return xRet;
     924                 :            : }
     925                 :            : 
     926                 :            : // -----------------------------------------------------------------------------
     927                 :            : 
     928                 :          0 : Reference< XOutputStream > SAL_CALL SvXMLGraphicHelper::createOutputStream()
     929                 :            :     throw( RuntimeException )
     930                 :            : {
     931                 :          0 :     Reference< XOutputStream > xRet;
     932                 :            : 
     933         [ #  # ]:          0 :     if( GRAPHICHELPER_MODE_READ == meCreateMode )
     934                 :            :     {
     935         [ #  # ]:          0 :         SvXMLGraphicOutputStream* pOutputStream = new SvXMLGraphicOutputStream;
     936                 :            : 
     937         [ #  # ]:          0 :         if( pOutputStream->Exists() )
     938 [ #  # ][ #  # ]:          0 :             maGrfStms.push_back( xRet = pOutputStream );
                 [ #  # ]
     939                 :            :         else
     940 [ #  # ][ #  # ]:          0 :             delete pOutputStream;
     941                 :            :     }
     942                 :            : 
     943                 :          0 :     return xRet;
     944                 :            : }
     945                 :            : 
     946                 :            : // -----------------------------------------------------------------------------
     947                 :            : 
     948                 :          0 : ::rtl::OUString SAL_CALL SvXMLGraphicHelper::resolveOutputStream( const Reference< XOutputStream >& rxBinaryStream )
     949                 :            :     throw( RuntimeException )
     950                 :            : {
     951                 :          0 :     ::rtl::OUString aRet;
     952                 :            : 
     953 [ #  # ][ #  # ]:          0 :     if( ( GRAPHICHELPER_MODE_READ == meCreateMode ) && rxBinaryStream.is() )
                 [ #  # ]
     954                 :            :     {
     955 [ #  # ][ #  # ]:          0 :         if( ::std::find( maGrfStms.begin(), maGrfStms.end(), rxBinaryStream ) != maGrfStms.end() )
                 [ #  # ]
     956                 :            :         {
     957 [ #  # ][ #  # ]:          0 :             SvXMLGraphicOutputStream* pOStm = static_cast< SvXMLGraphicOutputStream* >( rxBinaryStream.get() );
     958                 :            : 
     959         [ #  # ]:          0 :             if( pOStm )
     960                 :            :             {
     961         [ #  # ]:          0 :                 const GraphicObject& rGrfObj = pOStm->GetGraphicObject();
     962                 :            :                 const ::rtl::OUString aId(::rtl::OStringToOUString(
     963 [ #  # ][ #  # ]:          0 :                     rGrfObj.GetUniqueID(), RTL_TEXTENCODING_ASCII_US));
     964                 :            : 
     965         [ #  # ]:          0 :                 if( !aId.isEmpty() )
     966                 :            :                 {
     967                 :          0 :                     aRet = ::rtl::OUString( XML_GRAPHICOBJECT_URL_BASE );
     968                 :          0 :                     aRet += aId;
     969                 :          0 :                 }
     970                 :            :             }
     971                 :            :         }
     972                 :            :     }
     973                 :            : 
     974                 :          0 :     return aRet;
     975                 :            : }
     976                 :            : 
     977                 :            : 
     978                 :            : // --------------------------------------------------------------------------------
     979                 :            : 
     980                 :            : // for instantiation via service manager
     981                 :            : namespace svx
     982                 :            : {
     983                 :            : 
     984                 :            : namespace impl
     985                 :            : {
     986                 :            : typedef ::cppu::WeakComponentImplHelper4<
     987                 :            :         lang::XInitialization,
     988                 :            :         document::XGraphicObjectResolver,
     989                 :            :         document::XBinaryStreamResolver,
     990                 :            :         lang::XServiceInfo >
     991                 :            :     SvXMLGraphicImportExportHelper_Base;
     992                 :         15 : class MutexContainer
     993                 :            : {
     994                 :            : public:
     995                 :            :     virtual ~MutexContainer();
     996                 :            : 
     997                 :            : protected:
     998                 :            :     mutable ::osl::Mutex m_aMutex;
     999                 :            : };
    1000                 :         15 : MutexContainer::~MutexContainer()
    1001         [ -  + ]:         15 : {}
    1002                 :            : } // namespace impl
    1003                 :            : 
    1004 [ +  - ][ -  + ]:         30 : class SvXMLGraphicImportExportHelper :
    1005                 :            :     public impl::MutexContainer,
    1006                 :            :     public impl::SvXMLGraphicImportExportHelper_Base
    1007                 :            : {
    1008                 :            : public:
    1009                 :            :     SvXMLGraphicImportExportHelper( SvXMLGraphicHelperMode eMode );
    1010                 :            : 
    1011                 :            : protected:
    1012                 :            :     // is called from WeakComponentImplHelper when XComponent::dispose() was
    1013                 :            :     // called from outside
    1014                 :            :     virtual void SAL_CALL disposing();
    1015                 :            : 
    1016                 :            :     // ____ XInitialization ____
    1017                 :            :     // one argument is allowed, which is the XStorage
    1018                 :            :     virtual void SAL_CALL initialize( const Sequence< Any >& aArguments )
    1019                 :            :         throw (Exception,
    1020                 :            :                RuntimeException);
    1021                 :            : 
    1022                 :            :     // ____ XGraphicObjectResolver ____
    1023                 :            :     virtual ::rtl::OUString SAL_CALL resolveGraphicObjectURL( const ::rtl::OUString& aURL )
    1024                 :            :         throw (RuntimeException);
    1025                 :            : 
    1026                 :            :     // ____ XBinaryStreamResolver ____
    1027                 :            :     virtual Reference< io::XInputStream > SAL_CALL getInputStream( const ::rtl::OUString& aURL )
    1028                 :            :         throw (RuntimeException);
    1029                 :            :     virtual Reference< io::XOutputStream > SAL_CALL createOutputStream()
    1030                 :            :         throw (RuntimeException);
    1031                 :            :     virtual ::rtl::OUString SAL_CALL resolveOutputStream( const Reference< io::XOutputStream >& aBinaryStream )
    1032                 :            :         throw (RuntimeException);
    1033                 :            : 
    1034                 :            :     // ____ XServiceInfo ____
    1035                 :            :     virtual ::rtl::OUString SAL_CALL getImplementationName()
    1036                 :            :         throw (RuntimeException);
    1037                 :            :     virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
    1038                 :            :         throw (RuntimeException);
    1039                 :            :     virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
    1040                 :            :         throw (RuntimeException);
    1041                 :            : 
    1042                 :            : private:
    1043                 :            :     SvXMLGraphicHelperMode              m_eGraphicHelperMode;
    1044                 :            :     Reference< XGraphicObjectResolver > m_xGraphicObjectResolver;
    1045                 :            :     Reference< XBinaryStreamResolver >  m_xBinaryStreamResolver;
    1046                 :            : };
    1047                 :            : 
    1048                 :         15 : SvXMLGraphicImportExportHelper::SvXMLGraphicImportExportHelper( SvXMLGraphicHelperMode eMode ) :
    1049                 :            :         impl::SvXMLGraphicImportExportHelper_Base( m_aMutex ),
    1050                 :         15 :         m_eGraphicHelperMode( eMode )
    1051                 :         15 : {}
    1052                 :            : 
    1053                 :         15 : void SAL_CALL SvXMLGraphicImportExportHelper::disposing()
    1054                 :            : {
    1055         [ +  - ]:         15 :     Reference< XComponent > xComp( m_xGraphicObjectResolver, UNO_QUERY );
    1056                 :            :     OSL_ASSERT( xComp.is());
    1057         [ +  - ]:         15 :     if( xComp.is())
    1058 [ +  - ][ +  - ]:         15 :         xComp->dispose();
    1059                 :            :     // m_xBinaryStreamResolver is a reference to the same object => don't call
    1060                 :            :     // dispose() again
    1061                 :         15 : }
    1062                 :            : 
    1063                 :            : // ____ XInitialization ____
    1064                 :         15 : void SAL_CALL SvXMLGraphicImportExportHelper::initialize(
    1065                 :            :     const Sequence< Any >& aArguments )
    1066                 :            :     throw (Exception, RuntimeException)
    1067                 :            : {
    1068                 :         15 :     Reference< embed::XStorage > xStorage;
    1069         [ +  - ]:         15 :     if( aArguments.getLength() > 0 )
    1070         [ +  - ]:         15 :         aArguments[0] >>= xStorage;
    1071                 :            : 
    1072         [ +  - ]:         15 :     SvXMLGraphicHelper * pHelper( SvXMLGraphicHelper::Create( xStorage, m_eGraphicHelperMode ));
    1073 [ +  - ][ +  - ]:         15 :     m_xGraphicObjectResolver.set( pHelper );
    1074 [ +  - ][ +  - ]:         15 :     m_xBinaryStreamResolver.set( pHelper );
    1075                 :            :     // SvXMLGraphicHelper::Create calls acquire.  Since we have two references
    1076                 :            :     // now it is safe (and necessary) to undo this acquire
    1077                 :         15 :     pHelper->release();
    1078                 :         15 : }
    1079                 :            : 
    1080                 :            : // ____ XGraphicObjectResolver ____
    1081                 :         12 : ::rtl::OUString SAL_CALL SvXMLGraphicImportExportHelper::resolveGraphicObjectURL( const ::rtl::OUString& aURL )
    1082                 :            :     throw (uno::RuntimeException)
    1083                 :            : {
    1084                 :         12 :     return m_xGraphicObjectResolver->resolveGraphicObjectURL( aURL );
    1085                 :            : }
    1086                 :            : 
    1087                 :            : 
    1088                 :            : // ____ XBinaryStreamResolver ____
    1089                 :          0 : Reference< io::XInputStream > SAL_CALL SvXMLGraphicImportExportHelper::getInputStream( const ::rtl::OUString& aURL )
    1090                 :            :     throw (uno::RuntimeException)
    1091                 :            : {
    1092                 :          0 :     return m_xBinaryStreamResolver->getInputStream( aURL );
    1093                 :            : }
    1094                 :          0 : Reference< io::XOutputStream > SAL_CALL SvXMLGraphicImportExportHelper::createOutputStream()
    1095                 :            :     throw (uno::RuntimeException)
    1096                 :            : {
    1097                 :          0 :     return m_xBinaryStreamResolver->createOutputStream();
    1098                 :            : }
    1099                 :          0 : ::rtl::OUString SAL_CALL SvXMLGraphicImportExportHelper::resolveOutputStream( const Reference< io::XOutputStream >& aBinaryStream )
    1100                 :            :     throw (uno::RuntimeException)
    1101                 :            : {
    1102                 :          0 :     return m_xBinaryStreamResolver->resolveOutputStream( aBinaryStream );
    1103                 :            : }
    1104                 :            : 
    1105                 :            : // ____ XServiceInfo ____
    1106                 :          0 : ::rtl::OUString SAL_CALL SvXMLGraphicImportExportHelper::getImplementationName()
    1107                 :            :     throw (uno::RuntimeException)
    1108                 :            : {
    1109         [ #  # ]:          0 :     if( m_eGraphicHelperMode == GRAPHICHELPER_MODE_READ )
    1110                 :          0 :         return SvXMLGraphicImportHelper_getImplementationName();
    1111                 :          0 :     return SvXMLGraphicExportHelper_getImplementationName();
    1112                 :            : }
    1113                 :          0 : ::sal_Bool SAL_CALL SvXMLGraphicImportExportHelper::supportsService( const ::rtl::OUString& ServiceName )
    1114                 :            :     throw (uno::RuntimeException)
    1115                 :            : {
    1116         [ #  # ]:          0 :     Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames());
    1117                 :          0 :     const ::rtl::OUString * pBegin = aServiceNames.getConstArray();
    1118                 :          0 :     const ::rtl::OUString * pEnd = pBegin + aServiceNames.getLength();
    1119 [ #  # ][ #  # ]:          0 :     return (::std::find( pBegin, pEnd, ServiceName ) != pEnd);
    1120                 :            : }
    1121                 :          0 : Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicImportExportHelper::getSupportedServiceNames()
    1122                 :            :     throw (uno::RuntimeException)
    1123                 :            : {
    1124         [ #  # ]:          0 :     if( m_eGraphicHelperMode == GRAPHICHELPER_MODE_READ )
    1125                 :          0 :         return SvXMLGraphicImportHelper_getSupportedServiceNames();
    1126                 :          0 :     return SvXMLGraphicExportHelper_getSupportedServiceNames();
    1127                 :            : }
    1128                 :            : 
    1129                 :            : // import
    1130                 :          6 : Reference< XInterface > SAL_CALL SvXMLGraphicImportHelper_createInstance(const Reference< XMultiServiceFactory > & /* rSMgr */ )
    1131                 :            :     throw( Exception )
    1132                 :            : {
    1133 [ +  - ][ +  - ]:          6 :     return static_cast< XWeak* >( new SvXMLGraphicImportExportHelper( GRAPHICHELPER_MODE_READ ));
    1134                 :            : }
    1135                 :          9 : ::rtl::OUString SAL_CALL SvXMLGraphicImportHelper_getImplementationName()
    1136                 :            :     throw()
    1137                 :            : {
    1138                 :          9 :     return ::rtl::OUString(  "com.sun.star.comp.Svx.GraphicImportHelper" );
    1139                 :            : }
    1140                 :          2 : Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicImportHelper_getSupportedServiceNames()
    1141                 :            :     throw()
    1142                 :            : {
    1143                 :            :     // XGraphicObjectResolver and XBinaryStreamResolver are not part of any service
    1144                 :          2 :     Sequence< ::rtl::OUString > aSupportedServiceNames( 2 );
    1145         [ +  - ]:          2 :     aSupportedServiceNames[0] = ::rtl::OUString(  "com.sun.star.document.GraphicObjectResolver"  );
    1146         [ +  - ]:          2 :     aSupportedServiceNames[1] = ::rtl::OUString(  "com.sun.star.document.BinaryStreamResolver"  );
    1147                 :          2 :     return aSupportedServiceNames;
    1148                 :            : }
    1149                 :            : 
    1150                 :            : // export
    1151                 :          9 : Reference< XInterface > SAL_CALL SvXMLGraphicExportHelper_createInstance(const Reference< XMultiServiceFactory > & /* rSMgr */ )
    1152                 :            :     throw( Exception )
    1153                 :            : {
    1154 [ +  - ][ +  - ]:          9 :     return static_cast< XWeak* >( new SvXMLGraphicImportExportHelper( GRAPHICHELPER_MODE_WRITE ));
    1155                 :            : }
    1156                 :         10 : ::rtl::OUString SAL_CALL SvXMLGraphicExportHelper_getImplementationName()
    1157                 :            :     throw()
    1158                 :            : {
    1159                 :         10 :     return ::rtl::OUString(  "com.sun.star.comp.Svx.GraphicExportHelper" );
    1160                 :            : }
    1161                 :          5 : Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicExportHelper_getSupportedServiceNames()
    1162                 :            :     throw()
    1163                 :            : {
    1164                 :            :     // XGraphicObjectResolver and XBinaryStreamResolver are not part of any service
    1165                 :          5 :     Sequence< ::rtl::OUString > aSupportedServiceNames( 2 );
    1166         [ +  - ]:          5 :     aSupportedServiceNames[0] = ::rtl::OUString(  "com.sun.star.document.GraphicObjectResolver"  );
    1167         [ +  - ]:          5 :     aSupportedServiceNames[1] = ::rtl::OUString(  "com.sun.star.document.BinaryStreamResolver"  );
    1168                 :          5 :     return aSupportedServiceNames;
    1169                 :            : }
    1170                 :            : 
    1171                 :            : } // namespace svx
    1172                 :            : 
    1173                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10