Kaydet (Commit) 2a649539 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

MetafileXmlDump: No need to specify the stream, simplify the API.

Change-Id: Ia08f67e359bbd26cefdba8661f0b0c4ae2147382
üst 0048709c
...@@ -13,23 +13,30 @@ ...@@ -13,23 +13,30 @@
#include <sal/config.h> #include <sal/config.h>
#include <test/testdllapi.hxx> #include <test/testdllapi.hxx>
#include <libxml/tree.h>
#include <vcl/gdimtf.hxx> #include <vcl/gdimtf.hxx>
#include <vector> #include <vector>
class OOO_DLLPUBLIC_TEST MetafileXmlDump class OOO_DLLPUBLIC_TEST MetafileXmlDump
{ {
std::vector<bool> maFilter; std::vector<bool> maFilter;
SvStream& mrStream;
public: public:
MetafileXmlDump(SvStream& rStream); MetafileXmlDump();
virtual ~MetafileXmlDump(); virtual ~MetafileXmlDump();
void filterActionType(const sal_uInt16 nActionType, bool bShouldFilter); void filterActionType(const sal_uInt16 nActionType, bool bShouldFilter);
void filterAllActionTypes(); void filterAllActionTypes();
void filterNoneActionTypes(); 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 #endif
......
...@@ -27,12 +27,15 @@ ...@@ -27,12 +27,15 @@
class OOO_DLLPUBLIC_TEST XmlTestTools class OOO_DLLPUBLIC_TEST XmlTestTools
{ {
public:
/// Return xmlDocPtr representation of the XML stream read from pStream.
static xmlDocPtr parseXmlStream(SvStream* pStream);
protected: protected:
XmlTestTools(); XmlTestTools();
virtual ~XmlTestTools(); virtual ~XmlTestTools();
htmlDocPtr parseXml(utl::TempFile& aTempFile); htmlDocPtr parseXml(utl::TempFile& aTempFile);
htmlDocPtr parseXmlStream(SvStream* pStream);
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
#include <test/mtfxmldump.hxx> #include <test/mtfxmldump.hxx>
#include <test/xmltesttools.hxx>
#include <test/xmlwriter.hxx> #include <test/xmlwriter.hxx>
#include <vcl/metaact.hxx> #include <vcl/metaact.hxx>
...@@ -137,9 +138,8 @@ OUString convertLineStyleToString(LineStyle eAlign) ...@@ -137,9 +138,8 @@ OUString convertLineStyleToString(LineStyle eAlign)
} // anonymous namespace } // anonymous namespace
MetafileXmlDump::MetafileXmlDump(SvStream& rStream) : MetafileXmlDump::MetafileXmlDump() :
maFilter(512, false), maFilter(512, false)
mrStream(rStream)
{} {}
MetafileXmlDump::~MetafileXmlDump() MetafileXmlDump::~MetafileXmlDump()
...@@ -160,9 +160,16 @@ void MetafileXmlDump::filterNoneActionTypes() ...@@ -160,9 +160,16 @@ void MetafileXmlDump::filterNoneActionTypes()
maFilter.assign(512, false); 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 ); xmlTextWriterPtr xmlWriter = xmlNewTextWriter( xmlOutBuffer );
xmlTextWriterSetIndent( xmlWriter, 1 ); xmlTextWriterSetIndent( xmlWriter, 1 );
...@@ -392,6 +399,14 @@ void MetafileXmlDump::dump(GDIMetaFile& rMetaFile) ...@@ -392,6 +399,14 @@ void MetafileXmlDump::dump(GDIMetaFile& rMetaFile)
aWriter.endElement(); aWriter.endElement();
aWriter.endDocument(); aWriter.endDocument();
pStream->Seek(STREAM_SEEK_TO_BEGIN);
xmlDocPtr pDoc = XmlTestTools::parseXmlStream(pStream);
delete pStream;
return pDoc;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -57,16 +57,10 @@ void WmfTest::testNonPlaceableWmf() ...@@ -57,16 +57,10 @@ void WmfTest::testNonPlaceableWmf()
GDIMetaFile aGDIMetaFile; GDIMetaFile aGDIMetaFile;
ReadWindowMetafile(aFileStream, aGDIMetaFile); ReadWindowMetafile(aFileStream, aGDIMetaFile);
SvMemoryStream aStream; MetafileXmlDump dumper;
MetafileXmlDump dumper(aStream);
dumper.filterAllActionTypes(); dumper.filterAllActionTypes();
dumper.filterActionType(META_POLYLINE_ACTION, false); dumper.filterActionType(META_POLYLINE_ACTION, false);
dumper.dump(aGDIMetaFile); xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
aStream.Seek(STREAM_SEEK_TO_BEGIN);
xmlDocPtr pDoc = parseXmlStream(&aStream);
CPPUNIT_ASSERT (pDoc); CPPUNIT_ASSERT (pDoc);
...@@ -92,16 +86,10 @@ void WmfTest::testSine() ...@@ -92,16 +86,10 @@ void WmfTest::testSine()
GDIMetaFile aGDIMetaFile; GDIMetaFile aGDIMetaFile;
ReadWindowMetafile(aFileStream, aGDIMetaFile); ReadWindowMetafile(aFileStream, aGDIMetaFile);
SvMemoryStream aStream; MetafileXmlDump dumper;
MetafileXmlDump dumper(aStream);
dumper.filterAllActionTypes(); dumper.filterAllActionTypes();
dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false); dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false);
dumper.dump(aGDIMetaFile); xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
aStream.Seek(STREAM_SEEK_TO_BEGIN);
xmlDocPtr pDoc = parseXmlStream(&aStream);
CPPUNIT_ASSERT (pDoc); CPPUNIT_ASSERT (pDoc);
...@@ -122,16 +110,10 @@ void WmfTest::testEmfProblem() ...@@ -122,16 +110,10 @@ void WmfTest::testEmfProblem()
GDIMetaFile aGDIMetaFile; GDIMetaFile aGDIMetaFile;
ReadWindowMetafile(aFileStream, aGDIMetaFile); ReadWindowMetafile(aFileStream, aGDIMetaFile);
SvMemoryStream aStream; MetafileXmlDump dumper;
MetafileXmlDump dumper(aStream);
dumper.filterAllActionTypes(); dumper.filterAllActionTypes();
dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false); dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false);
dumper.dump(aGDIMetaFile); xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
aStream.Seek(STREAM_SEEK_TO_BEGIN);
xmlDocPtr pDoc = parseXmlStream(&aStream);
CPPUNIT_ASSERT (pDoc); CPPUNIT_ASSERT (pDoc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment