summaryrefslogtreecommitdiff
path: root/sot
diff options
context:
space:
mode:
Diffstat (limited to 'sot')
-rw-r--r--sot/source/sdstor/stg.cxx1
-rw-r--r--sot/source/sdstor/storage.cxx48
2 files changed, 48 insertions, 1 deletions
diff --git a/sot/source/sdstor/stg.cxx b/sot/source/sdstor/stg.cxx
index 67ea06b8f815..f82cd30d5e80 100644
--- a/sot/source/sdstor/stg.cxx
+++ b/sot/source/sdstor/stg.cxx
@@ -941,5 +941,4 @@ bool Storage::Equals( const BaseStorage& rStorage ) const
return pOther && ( pOther->pEntry == pEntry );
}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx
index 4445872b5f2b..9d19bafafedb 100644
--- a/sot/source/sdstor/storage.cxx
+++ b/sot/source/sdstor/storage.cxx
@@ -809,4 +809,52 @@ sal_Int32 SotStorage::GetVersion( const css::uno::Reference < css::embed::XStora
return 0;
}
+namespace
+{
+ void traverse(const tools::SvRef<SotStorage>& rStorage, std::vector<unsigned char>& rBuf)
+ {
+ SvStorageInfoList infos;
+
+ rStorage->FillInfoList(&infos);
+
+ for (const auto& info: infos)
+ {
+ if (info.IsStream())
+ {
+ // try to open and read all content
+ tools::SvRef<SotStorageStream> xStream(rStorage->OpenSotStream(info.GetName(), StreamMode::STD_READ));
+ const size_t nSize = xStream->GetSize();
+ const size_t nRead = xStream->ReadBytes(rBuf.data(), nSize);
+ SAL_INFO("sot", "Read " << nRead << "bytes");
+ }
+ else if (info.IsStorage())
+ {
+ tools::SvRef<SotStorage> xStorage(rStorage->OpenSotStorage(info.GetName(), StreamMode::STD_READ));
+
+ // continue with children
+ traverse(xStorage, rBuf);
+ }
+ else
+ {
+ }
+ }
+ }
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportOLE2(SvStream &rStream)
+{
+ try
+ {
+ size_t nSize = rStream.remainingSize();
+ tools::SvRef<SotStorage> xRootStorage(new SotStorage(&rStream, false));
+ std::vector<unsigned char> aTmpBuf(nSize);
+ traverse(xRootStorage, aTmpBuf);
+ }
+ catch (...)
+ {
+ return false;
+ }
+ return true;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */