[Libreoffice-commits] core.git: 2 commits - writerperfect/CppunitTest_writerperfect_stream.mk writerperfect/qa writerperfect/source
alonso
laurent.alonso at inria.fr
Wed May 28 23:07:37 PDT 2014
writerperfect/CppunitTest_writerperfect_stream.mk | 1
writerperfect/qa/unit/WPXSvStreamTest.cxx | 42 ++++++++++++++++
writerperfect/source/writer/MSWorksImportFilter.cxx | 12 ++++
writerperfect/source/writer/MSWorksImportFilter.hxx | 1
writerperfect/source/writer/MWAWImportFilter.cxx | 52 +++++++++++++++-----
5 files changed, 97 insertions(+), 11 deletions(-)
New commits:
commit 6cae6d682cfdec0104f68552def2d1b5719c8fbe
Author: alonso <laurent.alonso at inria.fr>
Date: Wed May 28 15:55:39 2014 +0200
enable new handlers
Change-Id: I1c07a44e7d318478bcb2561d29ea53a9475e4b1f
diff --git a/writerperfect/source/writer/MSWorksImportFilter.cxx b/writerperfect/source/writer/MSWorksImportFilter.cxx
index 7567294..2d253fb 100644
--- a/writerperfect/source/writer/MSWorksImportFilter.cxx
+++ b/writerperfect/source/writer/MSWorksImportFilter.cxx
@@ -24,6 +24,13 @@ using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
using com::sun::star::uno::XComponentContext;
+static bool handleEmbeddedWKSObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
+{
+ OdsGenerator exporter;
+ exporter.addDocumentHandler(pHandler, streamType);
+ return libwps::WPSDocument::parse(const_cast<librevenge::RVNGInputStream *>(data.getDataStream()), &exporter)==libwps::WPS_OK;
+}
+
bool MSWorksImportFilter::doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &, librevenge::RVNGTextInterface &rGenerator )
{
return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator);
@@ -43,6 +50,11 @@ bool MSWorksImportFilter::doDetectFormat( librevenge::RVNGInputStream &rInput, O
return false;
}
+void MSWorksImportFilter::doRegisterHandlers( OdtGenerator &rGenerator )
+{
+ rGenerator.registerEmbeddedObjectHandler("image/wks-ods", &handleEmbeddedWKSObject);
+}
+
OUString MSWorksImportFilter_getImplementationName ()
throw (RuntimeException)
{
diff --git a/writerperfect/source/writer/MSWorksImportFilter.hxx b/writerperfect/source/writer/MSWorksImportFilter.hxx
index b5ddfe4..9bddf08 100644
--- a/writerperfect/source/writer/MSWorksImportFilter.hxx
+++ b/writerperfect/source/writer/MSWorksImportFilter.hxx
@@ -35,6 +35,7 @@ public:
private:
virtual bool doDetectFormat( librevenge::RVNGInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE;
virtual bool doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator ) SAL_OVERRIDE;
+ virtual void doRegisterHandlers( OdtGenerator &rGenerator ) SAL_OVERRIDE;
};
OUString MSWorksImportFilter_getImplementationName()
diff --git a/writerperfect/source/writer/MWAWImportFilter.cxx b/writerperfect/source/writer/MWAWImportFilter.cxx
index ad656c9..d55a645 100644
--- a/writerperfect/source/writer/MWAWImportFilter.cxx
+++ b/writerperfect/source/writer/MWAWImportFilter.cxx
@@ -24,13 +24,20 @@ using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
using com::sun::star::uno::XComponentContext;
-static bool handleEmbeddedMWAWObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
+static bool handleEmbeddedMWAWGraphicObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
{
OdgGenerator exporter;
exporter.addDocumentHandler(pHandler, streamType);
return MWAWDocument::decodeGraphic(data, &exporter);
}
+static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType)
+{
+ OdsGenerator exporter;
+ exporter.addDocumentHandler(pHandler, streamType);
+ return MWAWDocument::decodeSpreadsheet(data, &exporter);
+}
+
bool MWAWImportFilter::doImportDocument( librevenge::RVNGInputStream &rInput, const rtl::OUString &, librevenge::RVNGTextInterface &rGenerator )
{
return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator);
@@ -65,12 +72,12 @@ bool MWAWImportFilter::doDetectFormat( librevenge::RVNGInputStream &rInput, OUSt
case MWAWDocument::MWAW_T_EDOC:
rTypeName = "writer_eDoc_Document";
break;
- case MWAWDocument::MWAW_T_GREATWORKS:
- rTypeName = "writer_Great_Works";
- break;
case MWAWDocument::MWAW_T_FULLWRITE:
rTypeName = "writer_FullWrite_Professional";
break;
+ case MWAWDocument::MWAW_T_GREATWORKS:
+ rTypeName = "writer_Great_Works";
+ break;
case MWAWDocument::MWAW_T_HANMACWORDJ:
rTypeName = "writer_HanMac_Word_J";
break;
@@ -83,24 +90,24 @@ bool MWAWImportFilter::doDetectFormat( librevenge::RVNGInputStream &rInput, OUSt
case MWAWDocument::MWAW_T_MACDOC:
rTypeName = "writer_MacDoc";
break;
- case MWAWDocument::MWAW_T_MARINERWRITE:
- rTypeName = "writer_Mariner_Write";
- break;
- case MWAWDocument::MWAW_T_MINDWRITE:
- rTypeName = "writer_MindWrite";
- break;
case MWAWDocument::MWAW_T_MACWRITE:
rTypeName = "writer_MacWrite";
break;
case MWAWDocument::MWAW_T_MACWRITEPRO:
rTypeName = "writer_MacWritePro";
break;
+ case MWAWDocument::MWAW_T_MARINERWRITE:
+ rTypeName = "writer_Mariner_Write";
+ break;
case MWAWDocument::MWAW_T_MICROSOFTWORD:
rTypeName = "writer_Mac_Word";
break;
case MWAWDocument::MWAW_T_MICROSOFTWORKS:
rTypeName = "writer_Mac_Works";
break;
+ case MWAWDocument::MWAW_T_MINDWRITE:
+ rTypeName = "writer_MindWrite";
+ break;
case MWAWDocument::MWAW_T_MORE:
rTypeName = "writer_Mac_More";
break;
@@ -123,13 +130,35 @@ bool MWAWImportFilter::doDetectFormat( librevenge::RVNGInputStream &rInput, OUSt
rTypeName = "writer_ZWrite";
break;
+ case MWAWDocument::MWAW_T_ADOBEILLUSTRATOR:
+ case MWAWDocument::MWAW_T_CLARISRESOLVE:
+ case MWAWDocument::MWAW_T_DBASE:
+ case MWAWDocument::MWAW_T_FAMILYTREEMAKER:
+ case MWAWDocument::MWAW_T_FILEMAKER:
+ case MWAWDocument::MWAW_T_FOXBASE:
+ case MWAWDocument::MWAW_T_FULLIMPACT:
+ case MWAWDocument::MWAW_T_FULLPAINT:
case MWAWDocument::MWAW_T_FRAMEMAKER:
+ case MWAWDocument::MWAW_T_INFOGENIE:
+ case MWAWDocument::MWAW_T_KALEIDAGRAPH:
+ case MWAWDocument::MWAW_T_MACDRAFT:
case MWAWDocument::MWAW_T_MACDRAW:
+ case MWAWDocument::MWAW_T_MACDRAWPRO:
case MWAWDocument::MWAW_T_MACPAINT:
+ case MWAWDocument::MWAW_T_MICROSOFTFILE:
+ case MWAWDocument::MWAW_T_MICROSOFTMULTIPLAN:
+ case MWAWDocument::MWAW_T_OVERVUE:
case MWAWDocument::MWAW_T_PAGEMAKER:
+ case MWAWDocument::MWAW_T_PIXELPAINT:
case MWAWDocument::MWAW_T_READYSETGO:
case MWAWDocument::MWAW_T_RAGTIME:
+ case MWAWDocument::MWAW_T_SUPERPAINT:
+ case MWAWDocument::MWAW_T_SYMPOSIUM:
+ case MWAWDocument::MWAW_T_TRAPEZE:
+ case MWAWDocument::MWAW_T_WINGZ:
case MWAWDocument::MWAW_T_XPRESS:
+ case MWAWDocument::MWAW_T_4DIMENSION:
+
case MWAWDocument::MWAW_T_RESERVED1:
case MWAWDocument::MWAW_T_RESERVED2:
case MWAWDocument::MWAW_T_RESERVED3:
@@ -151,7 +180,8 @@ bool MWAWImportFilter::doDetectFormat( librevenge::RVNGInputStream &rInput, OUSt
void MWAWImportFilter::doRegisterHandlers( OdtGenerator &rGenerator )
{
- rGenerator.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWObject);
+ rGenerator.registerEmbeddedObjectHandler("image/mwaw-odg", &handleEmbeddedMWAWGraphicObject);
+ rGenerator.registerEmbeddedObjectHandler("image/mwaw-ods", &handleEmbeddedMWAWSpreadsheetObject);
}
OUString MWAWImportFilter_getImplementationName ()
commit c14a6e0570c33c8a1258d5b562ca082de2cf05ce
Author: David Tardon <dtardon at redhat.com>
Date: Wed May 28 10:22:41 2014 +0200
improve WPXSvInputStream test
Change-Id: I95817ea44b6793d4a80b74b32f3b5477c6169b26
diff --git a/writerperfect/CppunitTest_writerperfect_stream.mk b/writerperfect/CppunitTest_writerperfect_stream.mk
index 8416008..ad943e0 100644
--- a/writerperfect/CppunitTest_writerperfect_stream.mk
+++ b/writerperfect/CppunitTest_writerperfect_stream.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_CppunitTest_use_components,writerperfect_stream,\
package/util/package2 \
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
+ unotools/util/utl \
))
$(eval $(call gb_CppunitTest_add_exception_objects,writerperfect_stream,\
diff --git a/writerperfect/qa/unit/WPXSvStreamTest.cxx b/writerperfect/qa/unit/WPXSvStreamTest.cxx
index d75f201..c2b4f20 100644
--- a/writerperfect/qa/unit/WPXSvStreamTest.cxx
+++ b/writerperfect/qa/unit/WPXSvStreamTest.cxx
@@ -9,6 +9,7 @@
#include <algorithm>
#include <cassert>
+#include <sstream>
#include <boost/shared_ptr.hpp>
@@ -98,6 +99,24 @@ const shared_ptr<RVNGInputStream> lcl_createStreamForURL(const rtl::OUString &rU
return pInput;
}
+void lcl_testSubStreams(const shared_ptr<RVNGInputStream> &pInput)
+{
+ shared_ptr<RVNGInputStream> pSubStream;
+
+ // all valid substreams can be read
+ for (std::size_t i = 0; i != pInput->subStreamCount(); ++i)
+ {
+ std::ostringstream msg("opening substream ");
+ msg << i;
+ pSubStream.reset(pInput->getSubStreamById(i));
+ CPPUNIT_ASSERT_MESSAGE(msg.str(), bool(pSubStream));
+ }
+
+ // invalid substreams cannot be read
+ pSubStream.reset(pInput->getSubStreamById(pInput->subStreamCount()));
+ CPPUNIT_ASSERT(!pSubStream);
+}
+
void WPXSvStreamTest::testRead()
{
const shared_ptr<RVNGInputStream> pInput(lcl_createStream());
@@ -281,8 +300,17 @@ void WPXSvStreamTest::testStructured()
assert(bool(pInput));
CPPUNIT_ASSERT(pInput->isStructured());
+ CPPUNIT_ASSERT(2 == pInput->subStreamCount());
+ lcl_testSubStreams(pInput);
+
+ // check for existing substream
+ CPPUNIT_ASSERT(pInput->existsSubStream("WordDocument"));
shared_ptr<RVNGInputStream> pSubStream(pInput->getSubStreamByName("WordDocument"));
CPPUNIT_ASSERT(bool(pSubStream));
+ CPPUNIT_ASSERT(!pSubStream->isEnd());
+
+ // check for not existing substream
+ CPPUNIT_ASSERT(!pInput->existsSubStream("foo"));
pSubStream.reset(pInput->getSubStreamByName("foo"));
CPPUNIT_ASSERT(!pSubStream);
}
@@ -293,8 +321,18 @@ void WPXSvStreamTest::testStructured()
assert(bool(pInput));
CPPUNIT_ASSERT(pInput->isStructured());
+ CPPUNIT_ASSERT(9 == pInput->subStreamCount());
+ lcl_testSubStreams(pInput);
+
+ // check for existing substream
+ CPPUNIT_ASSERT(pInput->existsSubStream("content.xml"));
shared_ptr<RVNGInputStream> pSubStream(pInput->getSubStreamByName("content.xml"));
CPPUNIT_ASSERT(bool(pSubStream));
+ CPPUNIT_ASSERT(!pSubStream->isEnd());
+
+ // check for not existing substream
+ CPPUNIT_ASSERT(pInput->existsSubStream("content.xml"));
+ CPPUNIT_ASSERT(!pInput->existsSubStream("foo"));
pSubStream.reset(pInput->getSubStreamByName("foo"));
CPPUNIT_ASSERT(!pSubStream);
}
@@ -304,7 +342,11 @@ void WPXSvStreamTest::testStructured()
const shared_ptr<RVNGInputStream> pInput(lcl_createStream());
CPPUNIT_ASSERT(!pInput->isStructured());
+ CPPUNIT_ASSERT(0 == pInput->subStreamCount());
+ CPPUNIT_ASSERT(!pInput->existsSubStream("foo"));
CPPUNIT_ASSERT(0 == pInput->getSubStreamByName("foo"));
+ CPPUNIT_ASSERT(0 == pInput->getSubStreamById(42));
+ CPPUNIT_ASSERT(0 == pInput->subStreamName(42));
}
}
More information about the Libreoffice-commits
mailing list