summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-06-10 18:15:55 +0200
committerJan Holesovsky <kendy@collabora.com>2014-06-10 19:33:12 +0200
commit2a649539b723a01649102ff7be3cab2bbdff834d (patch)
tree1876b69bd6d9ccf92f46fa41b4412ecbae0d5b5c
parent0048709ce4d86ce5aca116474b43d9f1c5c50de5 (diff)
MetafileXmlDump: No need to specify the stream, simplify the API.
Change-Id: Ia08f67e359bbd26cefdba8661f0b0c4ae2147382
-rw-r--r--include/test/mtfxmldump.hxx13
-rw-r--r--include/test/xmltesttools.hxx5
-rw-r--r--test/source/mtfxmldump.cxx25
-rw-r--r--vcl/qa/cppunit/wmf/wmfimporttest.cxx30
4 files changed, 40 insertions, 33 deletions
diff --git a/include/test/mtfxmldump.hxx b/include/test/mtfxmldump.hxx
index 9da10c207ca2..86ffe9dcd3bb 100644
--- a/include/test/mtfxmldump.hxx
+++ b/include/test/mtfxmldump.hxx
@@ -13,23 +13,30 @@
#include <sal/config.h>
#include <test/testdllapi.hxx>
+#include <libxml/tree.h>
#include <vcl/gdimtf.hxx>
#include <vector>
class OOO_DLLPUBLIC_TEST MetafileXmlDump
{
std::vector<bool> maFilter;
- SvStream& mrStream;
public:
- MetafileXmlDump(SvStream& rStream);
+ MetafileXmlDump();
virtual ~MetafileXmlDump();
void filterActionType(const sal_uInt16 nActionType, bool bShouldFilter);
void filterAllActionTypes();
void filterNoneActionTypes();
- void dump(GDIMetaFile& rMetaFile);
+ /** The actual result that will be used for testing.
+
+ This function normally uses a SvMemoryStream for its operation; but
+ can use a physical file when a filename is specified in
+ pTempStreamName - this is useful when creating the test, to dump the
+ file for examination.
+ */
+ xmlDocPtr dumpAndParse(GDIMetaFile& rMetaFile, const OUString& rTempStreamName = OUString());
};
#endif
diff --git a/include/test/xmltesttools.hxx b/include/test/xmltesttools.hxx
index 4849ed9afb5b..058bbc251743 100644
--- a/include/test/xmltesttools.hxx
+++ b/include/test/xmltesttools.hxx
@@ -27,12 +27,15 @@
class OOO_DLLPUBLIC_TEST XmlTestTools
{
+public:
+ /// Return xmlDocPtr representation of the XML stream read from pStream.
+ static xmlDocPtr parseXmlStream(SvStream* pStream);
+
protected:
XmlTestTools();
virtual ~XmlTestTools();
htmlDocPtr parseXml(utl::TempFile& aTempFile);
- htmlDocPtr parseXmlStream(SvStream* pStream);
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx);
diff --git a/test/source/mtfxmldump.cxx b/test/source/mtfxmldump.cxx
index e1a6abdff0f3..5e329a3b85a2 100644
--- a/test/source/mtfxmldump.cxx
+++ b/test/source/mtfxmldump.cxx
@@ -8,6 +8,7 @@
*/
#include <test/mtfxmldump.hxx>
+#include <test/xmltesttools.hxx>
#include <test/xmlwriter.hxx>
#include <vcl/metaact.hxx>
@@ -137,9 +138,8 @@ OUString convertLineStyleToString(LineStyle eAlign)
} // anonymous namespace
-MetafileXmlDump::MetafileXmlDump(SvStream& rStream) :
- maFilter(512, false),
- mrStream(rStream)
+MetafileXmlDump::MetafileXmlDump() :
+ maFilter(512, false)
{}
MetafileXmlDump::~MetafileXmlDump()
@@ -160,9 +160,16 @@ void MetafileXmlDump::filterNoneActionTypes()
maFilter.assign(512, false);
}
-void MetafileXmlDump::dump(GDIMetaFile& rMetaFile)
+xmlDocPtr MetafileXmlDump::dumpAndParse(GDIMetaFile& rMetaFile, const OUString& rTempStreamName)
{
- xmlOutputBufferPtr xmlOutBuffer = xmlOutputBufferCreateIO(lclWriteCallback, lclCloseCallback, &mrStream, NULL);
+ SvStream *pStream = NULL;
+
+ if (rTempStreamName.isEmpty())
+ pStream = new SvMemoryStream();
+ else
+ pStream = new SvFileStream(rTempStreamName, STREAM_STD_READWRITE);
+
+ xmlOutputBufferPtr xmlOutBuffer = xmlOutputBufferCreateIO(lclWriteCallback, lclCloseCallback, pStream, NULL);
xmlTextWriterPtr xmlWriter = xmlNewTextWriter( xmlOutBuffer );
xmlTextWriterSetIndent( xmlWriter, 1 );
@@ -392,6 +399,14 @@ void MetafileXmlDump::dump(GDIMetaFile& rMetaFile)
aWriter.endElement();
aWriter.endDocument();
+
+ pStream->Seek(STREAM_SEEK_TO_BEGIN);
+
+ xmlDocPtr pDoc = XmlTestTools::parseXmlStream(pStream);
+
+ delete pStream;
+
+ return pDoc;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/cppunit/wmf/wmfimporttest.cxx b/vcl/qa/cppunit/wmf/wmfimporttest.cxx
index 45c3cc45d762..cc24c76947b0 100644
--- a/vcl/qa/cppunit/wmf/wmfimporttest.cxx
+++ b/vcl/qa/cppunit/wmf/wmfimporttest.cxx
@@ -57,16 +57,10 @@ void WmfTest::testNonPlaceableWmf()
GDIMetaFile aGDIMetaFile;
ReadWindowMetafile(aFileStream, aGDIMetaFile);
- SvMemoryStream aStream;
-
- MetafileXmlDump dumper(aStream);
+ MetafileXmlDump dumper;
dumper.filterAllActionTypes();
dumper.filterActionType(META_POLYLINE_ACTION, false);
- dumper.dump(aGDIMetaFile);
-
- aStream.Seek(STREAM_SEEK_TO_BEGIN);
-
- xmlDocPtr pDoc = parseXmlStream(&aStream);
+ xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
CPPUNIT_ASSERT (pDoc);
@@ -92,16 +86,10 @@ void WmfTest::testSine()
GDIMetaFile aGDIMetaFile;
ReadWindowMetafile(aFileStream, aGDIMetaFile);
- SvMemoryStream aStream;
-
- MetafileXmlDump dumper(aStream);
+ MetafileXmlDump dumper;
dumper.filterAllActionTypes();
dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false);
- dumper.dump(aGDIMetaFile);
-
- aStream.Seek(STREAM_SEEK_TO_BEGIN);
-
- xmlDocPtr pDoc = parseXmlStream(&aStream);
+ xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
CPPUNIT_ASSERT (pDoc);
@@ -122,16 +110,10 @@ void WmfTest::testEmfProblem()
GDIMetaFile aGDIMetaFile;
ReadWindowMetafile(aFileStream, aGDIMetaFile);
- SvMemoryStream aStream;
-
- MetafileXmlDump dumper(aStream);
+ MetafileXmlDump dumper;
dumper.filterAllActionTypes();
dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false);
- dumper.dump(aGDIMetaFile);
-
- aStream.Seek(STREAM_SEEK_TO_BEGIN);
-
- xmlDocPtr pDoc = parseXmlStream(&aStream);
+ xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
CPPUNIT_ASSERT (pDoc);