writerperfect/source/stream/WPXSvStream.cxx |   46 +++++++++++++++++++++++-----
 writerperfect/source/stream/WPXSvStream.h   |    4 +-
 2 files changed, 40 insertions(+), 10 deletions(-)

New commits:
commit 02c61b924d4687477e4818e1f8682e2f9f4a753c
Author: Fridrich Å trba <fridrich.st...@bluewin.ch>
Date:   Fri May 25 12:14:05 2012 +0200

    Allow WPXSvStream to read stream in a hierarchy of substorages
    
    Change-Id: I8f9726e3e93a16d59f0e3c24783a98f4b9edd692

diff --git a/writerperfect/source/stream/WPXSvStream.cxx 
b/writerperfect/source/stream/WPXSvStream.cxx
index 762220c..58c0544 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 37d905a..2e9dc09 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<
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to