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