1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmleohlp.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
35 #include <com/sun/star/io/XStream.hpp>
36 #include <com/sun/star/embed/XTransactedObject.hpp>
37 #include <com/sun/star/embed/XEmbedObjectCreator.hpp>
38 #include <com/sun/star/embed/XEmbedObjectFactory.hpp>
39 #include <com/sun/star/embed/ElementModes.hpp>
40 #include <com/sun/star/embed/XEmbeddedObject.hpp>
41 #ifndef _COM_SUN_STAR_EMBED_XEMBED_PERSIST_HPP_
42 #include <com/sun/star/embed/XEmbedPersist.hpp>
44 #include <com/sun/star/embed/EntryInitModes.hpp>
45 #include <com/sun/star/embed/EmbedStates.hpp>
46 #include <com/sun/star/embed/Aspects.hpp>
47 #include <com/sun/star/beans/XPropertySet.hpp>
48 #include <tools/debug.hxx>
49 #include <unotools/streamwrap.hxx>
50 #include <unotools/tempfile.hxx>
52 #include <svtools/embedhlp.hxx>
53 #include <unotools/ucbstreamhelper.hxx>
54 #include <comphelper/processfactory.hxx>
55 #include <comphelper/storagehelper.hxx>
56 #include <comphelper/embeddedobjectcontainer.hxx>
58 #ifndef _SO_CLSIDS_HXX
59 #include <sot/clsids.hxx>
62 #include "xmleohlp.hxx"
68 using namespace ::osl
;
69 using namespace ::cppu
;
70 using namespace ::utl
;
71 using namespace ::com::sun::star
;
72 using namespace ::com::sun::star::document
;
73 using namespace ::com::sun::star::uno
;
74 using namespace ::com::sun::star::container
;
75 using namespace ::com::sun::star::io
;
76 using namespace ::com::sun::star::lang
;
78 #define XML_CONTAINERSTORAGE_NAME_60 "Pictures"
79 #define XML_CONTAINERSTORAGE_NAME "ObjectReplacements"
80 #define XML_EMBEDDEDOBJECT_URL_BASE "vnd.sun.star.EmbeddedObject:"
81 #define XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE "vnd.sun.star.GraphicObject:"
83 // -----------------------------------------------------------------------------
85 // -----------------------------------------------------------------------------
87 class OutputStorageWrapper_Impl
: public ::cppu::WeakImplHelper1
<XOutputStream
>
90 Reference
< XOutputStream
> xOut
;
92 sal_Bool bStreamClosed
: 1;
96 OutputStorageWrapper_Impl();
97 virtual ~OutputStorageWrapper_Impl();
99 // stario::XOutputStream
100 virtual void SAL_CALL
writeBytes(const Sequence
< sal_Int8
>& aData
) throw(NotConnectedException
, BufferSizeExceededException
, RuntimeException
);
101 virtual void SAL_CALL
flush() throw(NotConnectedException
, BufferSizeExceededException
, RuntimeException
);
102 virtual void SAL_CALL
closeOutput() throw(NotConnectedException
, BufferSizeExceededException
, RuntimeException
);
104 SvStream
* GetStream();
107 OutputStorageWrapper_Impl::OutputStorageWrapper_Impl()
108 : bStreamClosed( sal_False
)
111 aTempFile
.EnableKillingFile();
112 pStream
= aTempFile
.GetStream( STREAM_READWRITE
);
113 xOut
= new OOutputStreamWrapper( *pStream
);
116 OutputStorageWrapper_Impl::~OutputStorageWrapper_Impl()
120 SvStream
*OutputStorageWrapper_Impl::GetStream()
127 void SAL_CALL
OutputStorageWrapper_Impl::writeBytes(
128 const Sequence
< sal_Int8
>& aData
)
129 throw(NotConnectedException
, BufferSizeExceededException
, RuntimeException
)
131 MutexGuard
aGuard( maMutex
);
132 xOut
->writeBytes( aData
);
135 void SAL_CALL
OutputStorageWrapper_Impl::flush()
136 throw(NotConnectedException
, BufferSizeExceededException
, RuntimeException
)
138 MutexGuard
aGuard( maMutex
);
142 void SAL_CALL
OutputStorageWrapper_Impl::closeOutput()
143 throw(NotConnectedException
, BufferSizeExceededException
, RuntimeException
)
145 MutexGuard
aGuard( maMutex
);
147 bStreamClosed
= sal_True
;
150 // -----------------------------------------------------------------------------
154 bool operator() ( const ::rtl::OUString
& r1
, const ::rtl::OUString
& r2
) const
156 return (r1
< r2
) != sal_False
;
160 // -----------------------------------------------------------------------------
162 // -----------------------------
163 // - SvXMLEmbeddedObjectHelper -
164 // -----------------------------
165 DBG_NAME(SvXMLEmbeddedObjectHelper
)
166 SvXMLEmbeddedObjectHelper::SvXMLEmbeddedObjectHelper() :
167 WeakComponentImplHelper2
< XEmbeddedObjectResolver
, XNameAccess
>( maMutex
),
168 maReplacementGraphicsContainerStorageName( RTL_CONSTASCII_USTRINGPARAM(XML_CONTAINERSTORAGE_NAME
) ),
169 maReplacementGraphicsContainerStorageName60( RTL_CONSTASCII_USTRINGPARAM(XML_CONTAINERSTORAGE_NAME_60
) ),
171 meCreateMode( EMBEDDEDOBJECTHELPER_MODE_READ
),
174 DBG_CTOR(SvXMLEmbeddedObjectHelper
,NULL
);
177 SvXMLEmbeddedObjectHelper::SvXMLEmbeddedObjectHelper( ::comphelper::IEmbeddedHelper
& rDocPersist
, SvXMLEmbeddedObjectHelperMode eCreateMode
) :
178 WeakComponentImplHelper2
< XEmbeddedObjectResolver
, XNameAccess
>( maMutex
),
179 maReplacementGraphicsContainerStorageName( RTL_CONSTASCII_USTRINGPARAM(XML_CONTAINERSTORAGE_NAME
) ),
180 maReplacementGraphicsContainerStorageName60( RTL_CONSTASCII_USTRINGPARAM(XML_CONTAINERSTORAGE_NAME_60
) ),
182 meCreateMode( EMBEDDEDOBJECTHELPER_MODE_READ
),
185 DBG_CTOR(SvXMLEmbeddedObjectHelper
,NULL
);
186 Init( 0, rDocPersist
, eCreateMode
);
190 // -----------------------------------------------------------------------------
192 SvXMLEmbeddedObjectHelper::~SvXMLEmbeddedObjectHelper()
194 DBG_DTOR(SvXMLEmbeddedObjectHelper
,NULL
);
197 SvXMLEmbeddedObjectHelper_Impl::iterator aIter
= mpStreamMap
->begin();
198 SvXMLEmbeddedObjectHelper_Impl::iterator aEnd
= mpStreamMap
->end();
199 for( ; aIter
!= aEnd
; aIter
++ )
203 aIter
->second
->release();
210 // -----------------------------------------------------------------------------
212 void SAL_CALL
SvXMLEmbeddedObjectHelper::disposing()
217 // -----------------------------------------------------------------------------
219 sal_Bool
SvXMLEmbeddedObjectHelper::ImplGetStorageNames(
220 const ::rtl::OUString
& rURLStr
,
221 ::rtl::OUString
& rContainerStorageName
,
222 ::rtl::OUString
& rObjectStorageName
,
223 sal_Bool bInternalToExternal
,
224 sal_Bool
*pGraphicRepl
,
225 sal_Bool
*pOasisFormat
) const
227 // internal URL: vnd.sun.star.EmbeddedObject:<object-name>
228 // or: vnd.sun.star.EmbeddedObject:<path>/<object-name>
229 // internal replacement images:
230 // vnd.sun.star.EmbeddedObjectGraphic:<object-name>
231 // or: vnd.sun.star.EmbeddedObjectGraphic:<path>/<object-name>
232 // external URL: ./<path>/<object-name>
233 // or: <path>/<object-name>
235 // currently, path may only consist of a single directory name
236 // it is also possible to have additional arguments at the end of URL: <main URL>[?<name>=<value>[,<name>=<value>]*]
239 *pGraphicRepl
= sal_False
;
242 *pOasisFormat
= sal_True
; // the default value
244 if( !rURLStr
.getLength() )
247 // get rid of arguments
248 sal_Int32 nPos
= rURLStr
.indexOf( '?' );
249 ::rtl::OUString aURLNoPar
;
254 aURLNoPar
= rURLStr
.copy( 0, nPos
);
256 // check the arguments
258 while( nPos
>= 0 && nPos
< rURLStr
.getLength() )
260 ::rtl::OUString aToken
= rURLStr
.getToken( 0, ',', nPos
);
261 if ( aToken
.equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "oasis=false" ) ) ) )
264 *pOasisFormat
= sal_False
;
269 DBG_ASSERT( sal_False
, "invalid arguments was found in URL!" );
274 if( bInternalToExternal
)
276 nPos
= aURLNoPar
.indexOf( ':' );
280 0 == aURLNoPar
.compareToAscii( XML_EMBEDDEDOBJECT_URL_BASE
,
281 sizeof( XML_EMBEDDEDOBJECT_URL_BASE
) -1 );
282 sal_Bool bGrUrl
= !bObjUrl
&&
283 0 == aURLNoPar
.compareToAscii( XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE
,
284 sizeof( XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE
) -1 );
285 if( !(bObjUrl
|| bGrUrl
) )
288 sal_Int32 nPathStart
= nPos
+ 1;
289 nPos
= aURLNoPar
.lastIndexOf( '/' );
292 rContainerStorageName
= ::rtl::OUString();
293 rObjectStorageName
= aURLNoPar
.copy( nPathStart
);
295 else if( nPos
> nPathStart
)
297 rContainerStorageName
= aURLNoPar
.copy( nPathStart
, nPos
-nPathStart
);
298 rObjectStorageName
= aURLNoPar
.copy( nPos
+1 );
305 sal_Bool bOASIS
= mxRootStorage
.is() &&
306 ( SotStorage::GetVersion( mxRootStorage
) > SOFFICE_FILEFORMAT_60
);
307 rContainerStorageName
= bOASIS
308 ? maReplacementGraphicsContainerStorageName
309 : maReplacementGraphicsContainerStorageName60
;
312 *pGraphicRepl
= sal_True
;
319 DBG_ASSERT( '#' != aURLNoPar
[0], "invalid object URL" );
321 sal_Int32 _nPos
= aURLNoPar
.lastIndexOf( '/' );
324 rContainerStorageName
= ::rtl::OUString();
325 rObjectStorageName
= aURLNoPar
;
329 sal_Int32 nPathStart
= 0;
330 if( 0 == aURLNoPar
.compareToAscii( "./", 2 ) )
332 if( _nPos
>= nPathStart
)
333 rContainerStorageName
= aURLNoPar
.copy( nPathStart
, _nPos
-nPathStart
);
334 rObjectStorageName
= aURLNoPar
.copy( _nPos
+1 );
338 if( -1 != rContainerStorageName
.indexOf( '/' ) )
340 DBG_ERROR( "SvXMLEmbeddedObjectHelper: invalid path name" );
348 // -----------------------------------------------------------------------------
350 uno::Reference
< embed::XStorage
> SvXMLEmbeddedObjectHelper::ImplGetContainerStorage(
351 const ::rtl::OUString
& rStorageName
)
353 DBG_ASSERT( -1 == rStorageName
.indexOf( '/' ) &&
354 -1 == rStorageName
.indexOf( '\\' ),
355 "nested embedded storages aren't supported" );
356 if( !mxContainerStorage
.is() ||
357 ( rStorageName
!= maCurContainerStorageName
) )
359 if( mxContainerStorage
.is() &&
360 maCurContainerStorageName
.getLength() > 0 &&
361 EMBEDDEDOBJECTHELPER_MODE_WRITE
== meCreateMode
)
363 uno::Reference
< embed::XTransactedObject
> xTrans( mxContainerStorage
, uno::UNO_QUERY
);
368 if( rStorageName
.getLength() > 0 && mxRootStorage
.is() )
370 sal_Int32 nMode
= EMBEDDEDOBJECTHELPER_MODE_WRITE
== meCreateMode
371 ? ::embed::ElementModes::READWRITE
372 : ::embed::ElementModes::READ
;
373 mxContainerStorage
= mxRootStorage
->openStorageElement( rStorageName
,
378 mxContainerStorage
= mxRootStorage
;
380 maCurContainerStorageName
= rStorageName
;
383 return mxContainerStorage
;
386 // -----------------------------------------------------------------------------
388 sal_Bool
SvXMLEmbeddedObjectHelper::ImplReadObject(
389 const ::rtl::OUString
& rContainerStorageName
,
390 ::rtl::OUString
& rObjName
,
391 const SvGlobalName
*pClassId
,
396 uno::Reference
< embed::XStorage
> xDocStor( mpDocPersist
->getStorage() );
397 uno::Reference
< embed::XStorage
> xCntnrStor( ImplGetContainerStorage( rContainerStorageName
) );
399 if( !xCntnrStor
.is() && !pTemp
)
402 String
aSrcObjName( rObjName
);
403 comphelper::EmbeddedObjectContainer
& rContainer
= mpDocPersist
->getEmbeddedObjectContainer();
405 // Is the object name unique?
406 // if the object is already instantiated by GetEmbeddedObject
407 // that means that the duplication is being loaded
408 sal_Bool bDuplicate
= rContainer
.HasInstantiatedEmbeddedObject( rObjName
);
409 DBG_ASSERT( !bDuplicate
, "An object in the document is referenced twice!" );
411 if( xDocStor
!= xCntnrStor
|| pTemp
|| bDuplicate
)
413 // TODO/LATER: make this alltogether a method in the EmbeddedObjectContainer
415 // create a unique name for the duplicate object
417 rObjName
= rContainer
.CreateUniqueObjectName();
424 uno::Reference
< io::XStream
> xStm
= xDocStor
->openStreamElement( rObjName
,
425 embed::ElementModes::READWRITE
| embed::ElementModes::TRUNCATE
);
426 SvStream
* pStream
= ::utl::UcbStreamHelper::CreateStream( xStm
);
430 // TODO/LATER: what to do when other types of objects are based on substream persistence?
431 // This is an ole object
432 uno::Reference
< beans::XPropertySet
> xProps( xStm
, uno::UNO_QUERY_THROW
);
433 xProps
->setPropertyValue(
434 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ),
435 uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.oleobject" ) ) ) );
437 xStm
->getOutputStream()->closeOutput();
439 catch ( uno::Exception
& )
448 xCntnrStor
->copyElementTo( aSrcObjName
, xDocStor
, rObjName
);
450 catch ( uno::Exception
& )
457 // make object known to the container
458 // TODO/LATER: could be done a little bit more efficient!
459 ::rtl::OUString
aName( rObjName
);
461 // TODO/LATER: The provided pClassId is ignored for now.
462 // The stream contains OLE storage internally and this storage already has a class id specifying the
463 // server that was used to create the object. pClassId could be used to specify the server that should
464 // be used for the next opening, but this information seems to be out of the file format responsibility
466 rContainer
.GetEmbeddedObject( aName
);
471 // -----------------------------------------------------------------------------
473 ::rtl::OUString
SvXMLEmbeddedObjectHelper::ImplInsertEmbeddedObjectURL(
474 const ::rtl::OUString
& rURLStr
)
476 ::rtl::OUString sRetURL
;
478 ::rtl::OUString aContainerStorageName
, aObjectStorageName
;
479 if( !ImplGetStorageNames( rURLStr
, aContainerStorageName
,
481 EMBEDDEDOBJECTHELPER_MODE_WRITE
== meCreateMode
) )
484 if( EMBEDDEDOBJECTHELPER_MODE_READ
== meCreateMode
)
486 OutputStorageWrapper_Impl
*pOut
= 0;
487 SvXMLEmbeddedObjectHelper_Impl::iterator aIter
;
491 aIter
= mpStreamMap
->find( rURLStr
);
492 if( aIter
!= mpStreamMap
->end() && aIter
->second
)
493 pOut
= aIter
->second
;
496 SvGlobalName aClassId
, *pClassId
= 0;
497 sal_Int32 nPos
= aObjectStorageName
.lastIndexOf( '!' );
498 if( -1 != nPos
&& aClassId
.MakeId( aObjectStorageName
.copy( nPos
+1 ) ) )
500 aObjectStorageName
= aObjectStorageName
.copy( 0, nPos
);
501 pClassId
= &aClassId
;
504 ImplReadObject( aContainerStorageName
, aObjectStorageName
, pClassId
, pOut
? pOut
->GetStream() : 0 );
505 sRetURL
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(XML_EMBEDDEDOBJECT_URL_BASE
) );
506 sRetURL
+= aObjectStorageName
;
510 mpStreamMap
->erase( aIter
);
516 // Objects are written using ::comphelper::IEmbeddedHelper::SaveAs
517 sRetURL
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("./") );
518 if( aContainerStorageName
.getLength() )
520 sRetURL
+= aContainerStorageName
;
521 sRetURL
+= ::rtl::OUString( '/' );
523 sRetURL
+= aObjectStorageName
;
529 // -----------------------------------------------------------------------------
531 uno::Reference
< io::XInputStream
> SvXMLEmbeddedObjectHelper::ImplGetReplacementImage(
532 const uno::Reference
< embed::XEmbeddedObject
>& xObj
)
534 uno::Reference
< io::XInputStream
> xStream
;
540 sal_Bool bSwitchBackToLoaded
= sal_False
;
541 sal_Int32 nCurState
= xObj
->getCurrentState();
542 if ( nCurState
== embed::EmbedStates::LOADED
|| nCurState
== embed::EmbedStates::RUNNING
)
544 // means that the object is not active
545 // copy replacement image from old to new container
546 ::rtl::OUString aMediaType
;
547 xStream
= mpDocPersist
->getEmbeddedObjectContainer().GetGraphicStream( xObj
, &aMediaType
);
552 // the image must be regenerated
553 // TODO/LATER: another aspect could be used
554 if ( nCurState
== embed::EmbedStates::LOADED
)
555 bSwitchBackToLoaded
= sal_True
;
557 ::rtl::OUString aMediaType
;
558 xStream
= svt::EmbeddedObjectRef::GetGraphicReplacementStream(
559 embed::Aspects::MSOLE_CONTENT
,
564 if ( bSwitchBackToLoaded
)
565 // switch back to loaded state; that way we have a minimum cache confusion
566 xObj
->changeState( embed::EmbedStates::LOADED
);
568 catch( uno::Exception
& )
575 // -----------------------------------------------------------------------------
577 void SvXMLEmbeddedObjectHelper::Init(
578 const uno::Reference
< embed::XStorage
>& rRootStorage
,
579 ::comphelper::IEmbeddedHelper
& rPersist
,
580 SvXMLEmbeddedObjectHelperMode eCreateMode
)
582 mxRootStorage
= rRootStorage
;
583 mpDocPersist
= &rPersist
;
584 meCreateMode
= eCreateMode
;
587 // -----------------------------------------------------------------------------
589 SvXMLEmbeddedObjectHelper
* SvXMLEmbeddedObjectHelper::Create(
590 const uno::Reference
< embed::XStorage
>& rRootStorage
,
591 ::comphelper::IEmbeddedHelper
& rDocPersist
,
592 SvXMLEmbeddedObjectHelperMode eCreateMode
,
597 SvXMLEmbeddedObjectHelper
* pThis
= new SvXMLEmbeddedObjectHelper
;
600 pThis
->Init( rRootStorage
, rDocPersist
, eCreateMode
);
605 SvXMLEmbeddedObjectHelper
* SvXMLEmbeddedObjectHelper::Create(
606 ::comphelper::IEmbeddedHelper
& rDocPersist
,
607 SvXMLEmbeddedObjectHelperMode eCreateMode
)
609 SvXMLEmbeddedObjectHelper
* pThis
= new SvXMLEmbeddedObjectHelper
;
612 pThis
->Init( 0, rDocPersist
, eCreateMode
);
617 // -----------------------------------------------------------------------------
619 void SvXMLEmbeddedObjectHelper::Destroy(
620 SvXMLEmbeddedObjectHelper
* pSvXMLEmbeddedObjectHelper
)
622 if( pSvXMLEmbeddedObjectHelper
)
624 pSvXMLEmbeddedObjectHelper
->dispose();
625 pSvXMLEmbeddedObjectHelper
->release();
629 // -----------------------------------------------------------------------------
631 void SvXMLEmbeddedObjectHelper::Flush()
633 if( mxTempStorage
.is() )
635 Reference
< XComponent
> xComp( mxTempStorage
, UNO_QUERY
);
640 // XGraphicObjectResolver: alien objects!
641 ::rtl::OUString SAL_CALL
SvXMLEmbeddedObjectHelper::resolveEmbeddedObjectURL( const ::rtl::OUString
& aURL
)
642 throw(RuntimeException
)
644 MutexGuard
aGuard( maMutex
);
646 return ImplInsertEmbeddedObjectURL( aURL
);
649 // XNameAccess: alien objects!
650 Any SAL_CALL
SvXMLEmbeddedObjectHelper::getByName(
651 const ::rtl::OUString
& rURLStr
)
652 throw (NoSuchElementException
, WrappedTargetException
, RuntimeException
)
654 MutexGuard
aGuard( maMutex
);
656 if( EMBEDDEDOBJECTHELPER_MODE_READ
== meCreateMode
)
658 Reference
< XOutputStream
> xStrm
;
661 SvXMLEmbeddedObjectHelper_Impl::iterator aIter
=
662 mpStreamMap
->find( rURLStr
);
663 if( aIter
!= mpStreamMap
->end() && aIter
->second
)
664 xStrm
= aIter
->second
;
668 OutputStorageWrapper_Impl
*pOut
= new OutputStorageWrapper_Impl
;
671 mpStreamMap
= new SvXMLEmbeddedObjectHelper_Impl
;
672 (*mpStreamMap
)[rURLStr
] = pOut
;
680 sal_Bool bGraphicRepl
= sal_False
;
681 sal_Bool bOasisFormat
= sal_True
;
682 Reference
< XInputStream
> xStrm
;
683 ::rtl::OUString aContainerStorageName
, aObjectStorageName
;
684 if( ImplGetStorageNames( rURLStr
, aContainerStorageName
,
692 comphelper::EmbeddedObjectContainer
& rContainer
=
693 mpDocPersist
->getEmbeddedObjectContainer();
695 Reference
< embed::XEmbeddedObject
> xObj
= rContainer
.GetEmbeddedObject( aObjectStorageName
);
696 DBG_ASSERT( xObj
.is(), "Didn't get object" );
702 xStrm
= ImplGetReplacementImage( xObj
);
706 Reference
< embed::XEmbedPersist
> xPersist( xObj
, UNO_QUERY
);
709 if( !mxTempStorage
.is() )
711 comphelper::OStorageHelper::GetTemporaryStorage();
712 Sequence
< beans::PropertyValue
> aDummy( 0 ), aEmbDescr( 1 );
713 aEmbDescr
[0].Name
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StoreVisualReplacement" ) );
714 aEmbDescr
[0].Value
<<= (sal_Bool
)(!bOasisFormat
);
717 ::rtl::OUString aMimeType
;
718 uno::Reference
< io::XInputStream
> xGrInStream
= ImplGetReplacementImage( xObj
);
719 if ( xGrInStream
.is() )
721 aEmbDescr
.realloc( 2 );
722 aEmbDescr
[1].Name
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VisualReplacement" ) );
723 aEmbDescr
[1].Value
<<= xGrInStream
;
727 xPersist
->storeToEntry( mxTempStorage
, aObjectStorageName
,
729 Reference
< io::XStream
> xStream
=
730 mxTempStorage
->openStreamElement(
732 embed::ElementModes::READ
);
734 xStrm
= xStream
->getInputStream();
739 catch ( uno::Exception
& )
750 Sequence
< ::rtl::OUString
> SAL_CALL
SvXMLEmbeddedObjectHelper::getElementNames()
751 throw (RuntimeException
)
753 MutexGuard
aGuard( maMutex
);
754 return Sequence
< ::rtl::OUString
>(0);
757 sal_Bool SAL_CALL
SvXMLEmbeddedObjectHelper::hasByName( const ::rtl::OUString
& rURLStr
)
758 throw (RuntimeException
)
760 MutexGuard
aGuard( maMutex
);
761 if( EMBEDDEDOBJECTHELPER_MODE_READ
== meCreateMode
)
767 ::rtl::OUString aContainerStorageName
, aObjectStorageName
;
768 if( !ImplGetStorageNames( rURLStr
, aContainerStorageName
,
773 comphelper::EmbeddedObjectContainer
& rContainer
= mpDocPersist
->getEmbeddedObjectContainer();
774 return aObjectStorageName
.getLength() > 0 &&
775 rContainer
.HasEmbeddedObject( aObjectStorageName
);
780 Type SAL_CALL
SvXMLEmbeddedObjectHelper::getElementType()
781 throw (RuntimeException
)
783 MutexGuard
aGuard( maMutex
);
784 if( EMBEDDEDOBJECTHELPER_MODE_READ
== meCreateMode
)
785 return ::getCppuType((const Reference
<XOutputStream
>*)0);
787 return ::getCppuType((const Reference
<XInputStream
>*)0);
790 sal_Bool SAL_CALL
SvXMLEmbeddedObjectHelper::hasElements()
791 throw (RuntimeException
)
793 MutexGuard
aGuard( maMutex
);
794 if( EMBEDDEDOBJECTHELPER_MODE_READ
== meCreateMode
)
800 comphelper::EmbeddedObjectContainer
& rContainer
= mpDocPersist
->getEmbeddedObjectContainer();
801 return rContainer
.HasEmbeddedObjects();