From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- include/tools/XmlWriter.hxx | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 include/tools/XmlWriter.hxx (limited to 'include/tools/XmlWriter.hxx') diff --git a/include/tools/XmlWriter.hxx b/include/tools/XmlWriter.hxx new file mode 100644 index 000000000..e8f6579b0 --- /dev/null +++ b/include/tools/XmlWriter.hxx @@ -0,0 +1,68 @@ +/* -*- 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 +#include +#include +#include +#include + +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 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, std::u16string_view aValue); + void attribute(const OString& sTagName, sal_Int32 aNumber); + void attributeDouble(const OString& sTagName, double aNumber); + void attributeBase64(const OString& sTagName, std::vector const& rValueInBytes); + void attributeBase64(const OString& sTagName, std::vector const& rValueInBytes); + + void content(const OString& sValue); + void content(std::u16string_view sValue); + + void element(const OString& sName); +}; + +} // end tools namespace + +#endif // INCLUDED_TOOLS_XMLWRITER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3