summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-01-07 12:05:53 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-01-07 09:34:44 +0100
commite1fb3d95ac6d58b60448981e82d90621cad7fea5 (patch)
tree0a409b12d7356847cde99572589ccc6953529e57 /test
parent27da558d7c1fe45b58d0bcc28b961fabbc5f2f1a (diff)
Remove XmlWriter in test module and use tools::XmlWriter
Change-Id: I0a0e07a6a71ed95d783d35b7d94b857074ec3450 Reviewed-on: https://gerrit.libreoffice.org/47523 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/Library_test.mk1
-rw-r--r--test/source/mtfxmldump.cxx18
-rw-r--r--test/source/primitive2dxmldump.cxx7
-rw-r--r--test/source/xmlwriter.cxx117
4 files changed, 12 insertions, 131 deletions
diff --git a/test/Library_test.mk b/test/Library_test.mk
index 957ffc0d97e0..c3fcdd020f1b 100644
--- a/test/Library_test.mk
+++ b/test/Library_test.mk
@@ -45,7 +45,6 @@ $(eval $(call gb_Library_add_exception_objects,test,\
test/source/xmltesttools \
test/source/htmltesttools \
test/source/mtfxmldump \
- test/source/xmlwriter \
test/source/primitive2dxmldump \
test/source/screenshot_test \
))
diff --git a/test/source/mtfxmldump.cxx b/test/source/mtfxmldump.cxx
index 5cb4402ee4d8..cd21df3ff71e 100644
--- a/test/source/mtfxmldump.cxx
+++ b/test/source/mtfxmldump.cxx
@@ -9,7 +9,7 @@
#include <test/mtfxmldump.hxx>
#include <test/xmltesttools.hxx>
-#include <test/xmlwriter.hxx>
+#include <tools/XmlWriter.hxx>
#include <vcl/metaact.hxx>
#include <rtl/string.hxx>
@@ -350,31 +350,31 @@ OUString hex32(sal_uInt32 nNumber)
return OUString::createFromAscii(ss.str().c_str());
}
-void writePoint(XmlWriter& rWriter, Point const& rPoint)
+void writePoint(tools::XmlWriter& rWriter, Point const& rPoint)
{
rWriter.attribute("x", rPoint.X());
rWriter.attribute("y", rPoint.Y());
}
-void writeStartPoint(XmlWriter& rWriter, Point const& rPoint)
+void writeStartPoint(tools::XmlWriter& rWriter, Point const& rPoint)
{
rWriter.attribute("startx", rPoint.X());
rWriter.attribute("starty", rPoint.Y());
}
-void writeEndPoint(XmlWriter& rWriter, Point const& rPoint)
+void writeEndPoint(tools::XmlWriter& rWriter, Point const& rPoint)
{
rWriter.attribute("endx", rPoint.X());
rWriter.attribute("endy", rPoint.Y());
}
-void writeSize(XmlWriter& rWriter, Size const& rSize)
+void writeSize(tools::XmlWriter& rWriter, Size const& rSize)
{
rWriter.attribute("width", rSize.Width());
rWriter.attribute("height", rSize.Height());
}
-void writeRectangle(XmlWriter& rWriter, tools::Rectangle const& rRectangle)
+void writeRectangle(tools::XmlWriter& rWriter, tools::Rectangle const& rRectangle)
{
rWriter.attribute("left", rRectangle.Left());
rWriter.attribute("top", rRectangle.Top());
@@ -382,7 +382,7 @@ void writeRectangle(XmlWriter& rWriter, tools::Rectangle const& rRectangle)
rWriter.attribute("bottom", rRectangle.Bottom());
}
-void writeLineInfo(XmlWriter& rWriter, LineInfo const& rLineInfo)
+void writeLineInfo(tools::XmlWriter& rWriter, LineInfo const& rLineInfo)
{
rWriter.attribute("style", convertLineStyleToString(rLineInfo.GetStyle()));
rWriter.attribute("width", rLineInfo.GetWidth());
@@ -424,7 +424,7 @@ xmlDocPtr MetafileXmlDump::dumpAndParse(const GDIMetaFile& rMetaFile, const OUSt
else
pStream.reset(new SvFileStream(rTempStreamName, StreamMode::STD_READWRITE | StreamMode::TRUNC));
- XmlWriter aWriter(pStream.get());
+ tools::XmlWriter aWriter(pStream.get());
aWriter.startDocument();
aWriter.startElement("metafile");
@@ -440,7 +440,7 @@ xmlDocPtr MetafileXmlDump::dumpAndParse(const GDIMetaFile& rMetaFile, const OUSt
return pDoc;
}
-void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, XmlWriter& rWriter)
+void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& rWriter)
{
for(size_t nAction = 0; nAction < rMetaFile.GetActionSize(); ++nAction)
{
diff --git a/test/source/primitive2dxmldump.cxx b/test/source/primitive2dxmldump.cxx
index a9304b89ad07..4f5c63ed54a9 100644
--- a/test/source/primitive2dxmldump.cxx
+++ b/test/source/primitive2dxmldump.cxx
@@ -9,6 +9,7 @@
#include <test/primitive2dxmldump.hxx>
#include <test/xmltesttools.hxx>
+#include <tools/XmlWriter.hxx>
#include <vcl/metaact.hxx>
#include <rtl/string.hxx>
@@ -28,8 +29,6 @@
#include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
#include <drawinglayer/geometry/viewinformation2d.hxx>
-
-
#include <drawinglayer/attribute/lineattribute.hxx>
#include <drawinglayer/attribute/fontattribute.hxx>
@@ -70,7 +69,7 @@ xmlDocPtr Primitive2dXmlDump::dumpAndParse(
else
pStream.reset(new SvFileStream(rTempStreamName, StreamMode::STD_READWRITE | StreamMode::TRUNC));
- XmlWriter aWriter(pStream.get());
+ tools::XmlWriter aWriter(pStream.get());
aWriter.startDocument();
aWriter.startElement("primitive2D");
@@ -88,7 +87,7 @@ xmlDocPtr Primitive2dXmlDump::dumpAndParse(
void Primitive2dXmlDump::decomposeAndWrite(
const drawinglayer::primitive2d::Primitive2DContainer& rPrimitive2DSequence,
- XmlWriter& rWriter)
+ tools::XmlWriter& rWriter)
{
for (size_t i = 0; i < rPrimitive2DSequence.size(); i++)
{
diff --git a/test/source/xmlwriter.cxx b/test/source/xmlwriter.cxx
deleted file mode 100644
index f363378d57a1..000000000000
--- a/test/source/xmlwriter.cxx
+++ /dev/null
@@ -1,117 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <libxml/xmlstring.h>
-#include <tools/stream.hxx>
-#include <test/xmlwriter.hxx>
-
-namespace
-{
-
-int lclWriteCallback(void* pContext, const char* sBuffer, int nLen)
-{
- SvStream* pStream = static_cast<SvStream*>(pContext);
- return static_cast<int>(pStream->WriteBytes(sBuffer, nLen));
-}
-
-int lclCloseCallback(void* pContext)
-{
- SvStream* pStream = static_cast<SvStream*>(pContext);
- pStream->Flush();
- return 0; // 0 or -1 in case of error
-}
-
-} // anonymous namespace
-
-XmlWriter::XmlWriter(SvStream* pStream) :
- mpStream(pStream),
- mpWriter(nullptr)
-{}
-
-XmlWriter::~XmlWriter()
-{}
-
-void XmlWriter::startDocument()
-{
- if (mpWriter == nullptr && mpStream != nullptr)
- {
- xmlOutputBufferPtr xmlOutBuffer = xmlOutputBufferCreateIO(lclWriteCallback, lclCloseCallback, mpStream, nullptr);
- mpWriter = xmlNewTextWriter(xmlOutBuffer);
- xmlTextWriterSetIndent(mpWriter, 1);
- xmlTextWriterStartDocument(mpWriter, nullptr, "UTF-8", nullptr);
- }
-}
-
-void XmlWriter::endDocument()
-{
- xmlTextWriterEndDocument(mpWriter);
- xmlFreeTextWriter(mpWriter);
- mpWriter = nullptr;
-}
-
-void XmlWriter::element(const OString& name)
-{
- startElement(name);
- endElement();
-}
-
-void XmlWriter::startElement(const OString& name)
-{
- xmlChar* xmlName = xmlCharStrdup(name.getStr());
- xmlTextWriterStartElement(mpWriter, xmlName);
- xmlFree(xmlName);
-}
-
-void XmlWriter::attribute(const OString& name, const OString & value)
-{
- xmlChar* xmlName = xmlCharStrdup(name.getStr());
- xmlChar* xmlValue = xmlCharStrdup(value.getStr());
- xmlTextWriterWriteAttribute(mpWriter, xmlName, xmlValue);
- xmlFree(xmlValue);
- xmlFree(xmlName);
-}
-
-void XmlWriter::attribute(const OString& name, const OUString& value)
-{
- attribute(name, OUStringToOString(value, RTL_TEXTENCODING_UTF8).getStr());
-}
-
-void XmlWriter::attribute(const OString& name, const sal_Int32 aNumber)
-{
- attribute(name, OUString::number(aNumber));
-}
-
-void XmlWriter::content(const OUString& aValue)
-{
- content(OUStringToOString(aValue, RTL_TEXTENCODING_UTF8));
-}
-
-void XmlWriter::content(const OString& aValue)
-{
- xmlChar* xmlValue = xmlCharStrdup(aValue.getStr());
- xmlTextWriterWriteString(mpWriter, xmlValue);
- xmlFree(xmlValue);
-}
-
-void XmlWriter::endElement()
-{
- xmlTextWriterEndElement(mpWriter);
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */