Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / svtools / HtmlWriter.hxx
blob21ccad0cd96dda97e4aee8f418e98204181b045a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #pragma once
13 #include <rtl/string.hxx>
14 #include <string_view>
15 #include <vector>
16 #include <svtools/svtdllapi.h>
18 class SvStream;
20 class SVT_DLLPUBLIC HtmlWriter final
22 private:
23 std::vector<OString> maElementStack;
25 SvStream& mrStream;
27 bool mbElementOpen;
28 bool mbCharactersWritten;
29 bool mbPrettyPrint;
30 /// XML namespace, in case of XHTML.
31 OString maNamespace;
33 public:
34 HtmlWriter(SvStream& rStream, std::string_view rNamespace = std::string_view());
35 ~HtmlWriter();
37 void prettyPrint(bool b);
39 void start(const OString& aElement);
41 bool end(const OString& aElement);
42 void end();
44 void flushStack();
46 static void writeAttribute(SvStream& rStream, std::string_view aAttribute, sal_Int32 aValue);
47 static void writeAttribute(SvStream& rStream, std::string_view aAttribute,
48 std::string_view aValue);
50 void attribute(std::string_view aAttribute, const char* aValue);
51 void attribute(std::string_view aAttribute, sal_Int32 aValue);
52 void attribute(std::string_view aAttribute, std::string_view aValue);
53 void attribute(std::string_view aAttribute, std::u16string_view aValue);
54 // boolean attribute e.g. <img ismap>
55 void attribute(std::string_view aAttribute);
57 void single(const OString& aContent);
58 void endAttribute();
60 /// Writes character data.
61 void characters(std::string_view rChars);
64 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */