2014-03-15 23:09:09 +01:00
|
|
|
/* -*- 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/.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-11-18 23:08:50 +01:00
|
|
|
#pragma once
|
2014-03-15 23:09:09 +01:00
|
|
|
|
|
|
|
#include <rtl/string.hxx>
|
2023-11-24 19:50:23 +03:00
|
|
|
#include <rtl/ustring.hxx>
|
2020-12-11 17:44:34 +01:00
|
|
|
#include <string_view>
|
2014-03-15 23:09:09 +01:00
|
|
|
#include <vector>
|
|
|
|
#include <svtools/svtdllapi.h>
|
|
|
|
|
2015-10-11 18:21:11 +02:00
|
|
|
class SvStream;
|
|
|
|
|
2016-11-07 10:42:33 +02:00
|
|
|
class SVT_DLLPUBLIC HtmlWriter final
|
2014-03-15 23:09:09 +01:00
|
|
|
{
|
|
|
|
private:
|
2014-03-16 20:50:27 +01:00
|
|
|
std::vector<OString> maElementStack;
|
2014-03-15 23:09:09 +01:00
|
|
|
|
2014-09-20 14:50:46 +02:00
|
|
|
SvStream& mrStream;
|
|
|
|
|
2023-11-24 18:16:11 +03:00
|
|
|
bool mbOpeningTagOpen = false;
|
2014-09-20 14:50:46 +02:00
|
|
|
bool mbPrettyPrint;
|
2018-02-27 13:51:13 +01:00
|
|
|
/// XML namespace, in case of XHTML.
|
|
|
|
OString maNamespace;
|
2014-03-15 23:09:09 +01:00
|
|
|
|
|
|
|
public:
|
2020-12-28 17:56:40 +01:00
|
|
|
HtmlWriter(SvStream& rStream, std::string_view rNamespace = std::string_view());
|
2016-11-07 10:42:33 +02:00
|
|
|
~HtmlWriter();
|
2014-03-15 23:09:09 +01:00
|
|
|
|
2016-03-08 14:45:58 +02:00
|
|
|
void prettyPrint(bool b);
|
2014-03-16 20:50:27 +01:00
|
|
|
|
2014-09-20 14:50:46 +02:00
|
|
|
void start(const OString& aElement);
|
|
|
|
|
2021-05-31 21:14:41 +09:00
|
|
|
bool end(const OString& aElement);
|
2014-03-15 23:09:09 +01:00
|
|
|
void end();
|
2014-09-20 14:50:46 +02:00
|
|
|
|
|
|
|
void flushStack();
|
|
|
|
|
2021-04-26 12:06:09 +02:00
|
|
|
void attribute(std::string_view aAttribute, sal_Int32 aValue);
|
|
|
|
void attribute(std::string_view aAttribute, std::string_view aValue);
|
2023-11-24 19:50:23 +03:00
|
|
|
void attribute(std::string_view aAttribute, const OUString& aValue);
|
|
|
|
template <size_t N> void attribute(std::string_view aAttribute, const char (&aValue)[N])
|
|
|
|
{
|
|
|
|
attribute(aAttribute, OUString(aValue));
|
|
|
|
}
|
2014-09-20 14:50:46 +02:00
|
|
|
// boolean attribute e.g. <img ismap>
|
2021-04-26 12:06:09 +02:00
|
|
|
void attribute(std::string_view aAttribute);
|
2014-09-20 14:50:46 +02:00
|
|
|
|
|
|
|
void single(const OString& aContent);
|
2018-03-08 15:56:08 +01:00
|
|
|
|
|
|
|
/// Writes character data.
|
2021-04-26 12:06:09 +02:00
|
|
|
void characters(std::string_view rChars);
|
2014-03-15 23:09:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|