diff options
author | Kurt Zenker <kz@openoffice.org> | 2004-10-04 19:31:39 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2004-10-04 19:31:39 +0000 |
commit | 9c63f346a2b22069f094a2dfc1225d4b3f1997ee (patch) | |
tree | 4ec75e943dcf4c8ff172223474c2b7b81a0c5336 /sot/source | |
parent | 7e28a36ff63ef25fb1df327ad1669f033bdc0c3d (diff) |
INTEGRATION: CWS mav09 (1.38.2); FILE MERGED
2004/09/02 14:04:04 mav 1.38.2.9: #i27773# fix typo
2004/09/02 13:57:32 mav 1.38.2.8: #i27773# set mediatype only in writeable mode
2004/08/31 12:06:55 mav 1.38.2.7: #i27773# set media type
2004/08/16 13:34:15 mav 1.38.2.6: #i27773# storage version
2004/07/06 16:51:35 mba 1.38.2.5: #i27773#: work on TODOs
2004/05/18 12:11:35 mav 1.38.2.4: #i27773# resolve resync problems
2004/05/17 17:42:45 mav 1.38.2.3: RESYNC: (1.38-1.39); FILE MERGED
2004/05/17 09:08:57 mba 1.38.2.2: #i27773#: use new method to detect ID from storage
2004/05/04 13:00:07 mba 1.38.2.1: #i27773#: remove so3
Diffstat (limited to 'sot/source')
-rw-r--r-- | sot/source/sdstor/storage.cxx | 91 |
1 files changed, 86 insertions, 5 deletions
diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx index 42ef1430ba05..eb359a5090b4 100644 --- a/sot/source/sdstor/storage.cxx +++ b/sot/source/sdstor/storage.cxx @@ -2,9 +2,9 @@ * * $RCSfile: storage.cxx,v $ * - * $Revision: 1.39 $ + * $Revision: 1.40 $ * - * last change: $Author: hr $ $Date: 2004-05-10 18:10:57 $ + * last change: $Author: kz $ $Date: 2004-10-04 20:31:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,24 +62,25 @@ #ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ #include <com/sun/star/uno/Sequence.hxx> #endif - #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ #include <com/sun/star/lang/XSingleServiceFactory.hpp> #endif - #ifndef _COM_SUN_STAR_EMBED_XSTORAGE_HPP_ #include <com/sun/star/embed/XStorage.hpp> #endif #ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_ #include <com/sun/star/embed/ElementModes.hpp> #endif - +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif #include <rtl/digest.h> #include <osl/file.hxx> #include <stg.hxx> #include <storinfo.hxx> #include <storage.hxx> +#include <formats.hxx> #include <exchange.hxx> #ifndef _UNTOOLS_UCBSTREAMHELPER_HXX @@ -1517,4 +1518,84 @@ void SotStorage::SetKey( const ByteString& rKey ) } } +SotStorage* SotStorage::OpenOLEStorage( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage, + const String& rEleName, StreamMode nMode ) +{ + sal_Int32 nEleMode = embed::ElementModes::SEEKABLEREAD; + if ( nMode & STREAM_WRITE ) + nEleMode |= embed::ElementModes::WRITE; + if ( nMode & STREAM_TRUNC ) + nEleMode |= embed::ElementModes::TRUNCATE; + + SvStream* pStream = NULL; + try + { + uno::Reference < io::XStream > xStream = xStorage->openStreamElement( rEleName, nEleMode ); + + // TODO/LATER: should it be done this way? + if ( nMode & STREAM_WRITE ) + { + uno::Reference < beans::XPropertySet > xStreamProps( xStream, uno::UNO_QUERY_THROW ); + xStreamProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), + uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.oleobject" ) ) ) ); + } + + pStream = utl::UcbStreamHelper::CreateStream( xStream ); + } + catch ( uno::Exception& ) + { + //TODO/LATER: ErrorHandling + pStream = new SvMemoryStream; + pStream->SetError( ERRCODE_IO_GENERAL ); + } + + return new SotStorage( pStream, TRUE ); +} + +sal_Int32 SotStorage::GetFormatID( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage ) +{ + uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY ); + if ( !xProps.is() ) + return 0; + + ::rtl::OUString aMediaType; + xProps->getPropertyValue( ::rtl::OUString::createFromAscii( "MediaType" ) ) >>= aMediaType; + if ( aMediaType.getLength() ) + { + ::com::sun::star::datatransfer::DataFlavor aDataFlavor; + aDataFlavor.MimeType = aMediaType; + return SotExchange::GetFormat( aDataFlavor ); + } + + return 0; +} + +sal_Int32 SotStorage::GetVersion( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& xStorage ) +{ + sal_Int32 nSotFormatID = SotStorage::GetFormatID( xStorage ); + switch( nSotFormatID ) + { + case SOT_FORMATSTR_ID_STARWRITER_8: + case SOT_FORMATSTR_ID_STARWRITERWEB_8: + case SOT_FORMATSTR_ID_STARWRITERGLOB_8: + case SOT_FORMATSTR_ID_STARDRAW_8: + case SOT_FORMATSTR_ID_STARIMPRESS_8: + case SOT_FORMATSTR_ID_STARCALC_8: + case SOT_FORMATSTR_ID_STARCHART_8: + case SOT_FORMATSTR_ID_STARMATH_8: + return SOFFICE_FILEFORMAT_8; + case SOT_FORMATSTR_ID_STARWRITER_60: + case SOT_FORMATSTR_ID_STARWRITERWEB_60: + case SOT_FORMATSTR_ID_STARWRITERGLOB_60: + case SOT_FORMATSTR_ID_STARDRAW_60: + case SOT_FORMATSTR_ID_STARIMPRESS_60: + case SOT_FORMATSTR_ID_STARCALC_60: + case SOT_FORMATSTR_ID_STARCHART_60: + case SOT_FORMATSTR_ID_STARMATH_60: + return SOFFICE_FILEFORMAT_60; + } + + return 0; +} |