summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-12-19 20:55:16 +0100
committerTomaž Vajngerl <quikee@gmail.com>2019-12-28 19:46:50 +0100
commitd016e052ddf30649ad9b729b59134ce1e90a0263 (patch)
tree5049f4d7b99e3be8276e66c0d179e93318c755ad /tools
parent0d52da4637b563c175cd21d04a639160441436ef (diff)
pdf: extract XMP metadata writing and use XmlWriter
Instead of writing XMP metadata with a string buffer, change to use XmlWriter instead. Extract XMP metadata writing into its own class vcl::pdf::XmpMetadata. This also needs a change to the XmlWriter to not write a classic XML header: '<?xml version="1.0" ... ?>' Change-Id: I95ea0e7ba58e7c43a0c707bf9c676994210ff104 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85908 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/xml/XmlWriter.cxx11
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/source/xml/XmlWriter.cxx b/tools/source/xml/XmlWriter.cxx
index 3400a6e9d94b..a314eed6e940 100644
--- a/tools/source/xml/XmlWriter.cxx
+++ b/tools/source/xml/XmlWriter.cxx
@@ -36,11 +36,13 @@ struct XmlWriterImpl
XmlWriterImpl(SvStream* pStream)
: mpStream(pStream)
, mpWriter(nullptr)
+ , mbWriteXmlHeader(true)
{
}
SvStream* const mpStream;
xmlTextWriterPtr mpWriter;
+ bool mbWriteXmlHeader;
};
XmlWriter::XmlWriter(SvStream* pStream)
@@ -54,21 +56,24 @@ XmlWriter::~XmlWriter()
endDocument();
}
-bool XmlWriter::startDocument(sal_Int32 nIndent)
+bool XmlWriter::startDocument(sal_Int32 nIndent, bool bWriteXmlHeader)
{
+ mpImpl->mbWriteXmlHeader = bWriteXmlHeader;
xmlOutputBufferPtr xmlOutBuffer
= xmlOutputBufferCreateIO(funcWriteCallback, funcCloseCallback, mpImpl->mpStream, nullptr);
mpImpl->mpWriter = xmlNewTextWriter(xmlOutBuffer);
if (mpImpl->mpWriter == nullptr)
return false;
xmlTextWriterSetIndent(mpImpl->mpWriter, nIndent);
- xmlTextWriterStartDocument(mpImpl->mpWriter, nullptr, "UTF-8", nullptr);
+ if (mpImpl->mbWriteXmlHeader)
+ xmlTextWriterStartDocument(mpImpl->mpWriter, nullptr, "UTF-8", nullptr);
return true;
}
void XmlWriter::endDocument()
{
- xmlTextWriterEndDocument(mpImpl->mpWriter);
+ if (mpImpl->mbWriteXmlHeader)
+ xmlTextWriterEndDocument(mpImpl->mpWriter);
xmlFreeTextWriter(mpImpl->mpWriter);
mpImpl->mpWriter = nullptr;
}