diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-05-25 12:14:05 +0200 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-05-25 12:23:07 +0200 |
commit | 02c61b924d4687477e4818e1f8682e2f9f4a753c (patch) | |
tree | 326dfcaf8760db645a04ef7ea3ff246471d65c5d | |
parent | 1bab1e998762bf4a11614b5b0bd074873b88424c (diff) |
Allow WPXSvStream to read stream in a hierarchy of substorages
Change-Id: I8f9726e3e93a16d59f0e3c24783a98f4b9edd692
-rw-r--r-- | writerperfect/source/stream/WPXSvStream.cxx | 46 | ||||
-rw-r--r-- | writerperfect/source/stream/WPXSvStream.h | 4 |
2 files changed, 40 insertions, 10 deletions
diff --git a/writerperfect/source/stream/WPXSvStream.cxx b/writerperfect/source/stream/WPXSvStream.cxx index 762220c372a2..58c054456f64 100644 --- a/writerperfect/source/stream/WPXSvStream.cxx +++ b/writerperfect/source/stream/WPXSvStream.cxx @@ -9,10 +9,20 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::io; +namespace +{ +static void splitPath( std::vector<rtl::OUString> &rElems, const ::rtl::OUString &rPath ) +{ + for (sal_Int32 i = 0; i >= 0;) + rElems.push_back( rPath.getToken( 0, '/', i ) ); +} + +} // anonymous namespace + WPXSvInputStream::WPXSvInputStream( Reference< XInputStream > xStream ) : WPXInputStream(), - mxChildStorage(), - mxChildStream(), + mxChildrenStorages(), + mxChildrenStreams(), mxStream(xStream), mxSeekable(xStream, UNO_QUERY), maData(0) @@ -133,6 +143,12 @@ bool WPXSvInputStream::isOLEStream() WPXInputStream *WPXSvInputStream::getDocumentOLEStream(const char *name) { + if (!name) + return 0; + rtl::OUString rPath(name,strlen(name),RTL_TEXTENCODING_UTF8); + std::vector<rtl::OUString> aElems; + splitPath( aElems, rPath ); + if ((mnLength == 0) || !mxStream.is() || !mxSeekable.is()) return 0; @@ -147,21 +163,35 @@ WPXInputStream *WPXSvInputStream::getDocumentOLEStream(const char *name) return 0; } - mxChildStorage = new SotStorage( pStream, sal_True ); + mxChildrenStorages.push_back(new SotStorage( pStream, sal_True )); + + unsigned i = 0; + while (i < aElems.size()) + { + if( mxChildrenStorages.back()->IsStream(aElems[i])) + break; + else if (mxChildrenStorages.back()->IsStorage(aElems[i])) + { + SotStorageRef &tmpParent(mxChildrenStorages.back()); + mxChildrenStorages.push_back(tmpParent->OpenSotStorage(aElems[i++], STREAM_STD_READ)); + } + else + // should not happen + return 0; + } - mxChildStream = mxChildStorage->OpenSotStream( - rtl::OUString::createFromAscii( name ), - STREAM_STD_READ ); + mxChildrenStreams.push_back( mxChildrenStorages.back()->OpenSotStream( + aElems[i], STREAM_STD_READ )); mxSeekable->seek(tmpPosition); - if ( !mxChildStream.Is() || mxChildStream->GetError() ) + if ( !mxChildrenStreams.back().Is() || mxChildrenStreams.back()->GetError() ) { mxSeekable->seek(tmpPosition); return 0; } - Reference < XInputStream > xContents(new utl::OSeekableInputStreamWrapper( mxChildStream )); + Reference < XInputStream > xContents(new utl::OSeekableInputStreamWrapper( mxChildrenStreams.back() )); mxSeekable->seek(tmpPosition); if (xContents.is()) return new WPXSvInputStream( xContents ); diff --git a/writerperfect/source/stream/WPXSvStream.h b/writerperfect/source/stream/WPXSvStream.h index 37d905adcc41..2e9dc0971084 100644 --- a/writerperfect/source/stream/WPXSvStream.h +++ b/writerperfect/source/stream/WPXSvStream.h @@ -34,8 +34,8 @@ public: virtual bool atEOS(); private: - SotStorageRef mxChildStorage; - SotStorageStreamRef mxChildStream; + std::vector< SotStorageRef > mxChildrenStorages; + std::vector< SotStorageStreamRef > mxChildrenStreams; ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > mxStream; ::com::sun::star::uno::Reference< |