office-gobmx/include/tools/XmlWriter.hxx
Tomaž Vajngerl d016e052dd 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>
2019-12-28 19:46:50 +01:00

67 lines
1.9 KiB
C++

/* -*- 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/.
*/
#ifndef INCLUDED_TOOLS_XMLWRITER_HXX
#define INCLUDED_TOOLS_XMLWRITER_HXX
#include <tools/toolsdllapi.h>
#include <rtl/ustring.hxx>
#include <memory>
#include <vector>
class SvStream;
namespace tools
{
struct XmlWriterImpl;
/**
* XmlWriter writes a XML to a SvStream. It uses libxml2 for writing but hides
* all the internal libxml2 workings and uses types that are native for LO
* development.
*
* The codepage used for XML is always "utf-8" and the output is indented by
* default so it is easier to read.
*
*/
class TOOLS_DLLPUBLIC XmlWriter final
{
private:
std::unique_ptr<XmlWriterImpl> mpImpl;
public:
XmlWriter(SvStream* pStream);
~XmlWriter();
bool startDocument(sal_Int32 nIndent = 2, bool bWriteXmlHeader = true);
void endDocument();
void startElement(const OString& sName);
void startElement(const OString& sPrefix, const OString& sName, const OString& sNamespaceUri);
void endElement();
void attribute(const OString& sTagName, const OString& aValue);
void attribute(const OString& sTagName, const OUString& aValue);
void attribute(const OString& sTagName, sal_Int32 aNumber);
void attributeDouble(const OString& sTagName, double aNumber);
void attributeBase64(const OString& sTagName, std::vector<sal_uInt8> const& rValueInBytes);
void attributeBase64(const OString& sTagName, std::vector<char> const& rValueInBytes);
void content(const OString& sValue);
void content(const OUString& sValue);
void element(const OString& sName);
};
} // end tools namespace
#endif // INCLUDED_TOOLS_XMLWRITER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */