Messagelib

htmlwriter.h
1/* -*- c++ -*-
2 interfaces/htmlwriter.h
3
4 This file is part of KMail's plugin interface.
5 SPDX-FileCopyrightText: 2003 Marc Mutz <mutz@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#pragma once
11
12#include "messageviewer_export.h"
13
14#include <QByteArray>
15#include <memory>
16#include <qglobal.h>
17class QIODevice;
18class QString;
19class QTextStream;
20
21namespace MessageViewer
22{
23/**
24 * @short An interface for HTML sinks.
25 * @author Marc Mutz <mutz@kde.org>
26 *
27 */
28class MESSAGEVIEWER_EXPORT HtmlWriter
29{
30public:
31 HtmlWriter();
32 virtual ~HtmlWriter();
33
34 /** Signal the begin of stuff to write.
35 * Sub-classes should open device() in a writable mode here and then
36 * call the base class.
37 */
38 virtual void begin();
39
40 /** Write out a chunk of text. No HTML escaping is performed.
41 * @deprecated use stream() instead
42 */
43 void write(const QString &html);
44
45 /** Signal the end of stuff to write.
46 * Sub-classes should call the base class and then close device() here.
47 */
48 virtual void end();
49
50 /**
51 * Stop all possibly pending processing in order to be able to
52 * call #begin() again.
53 * Sub-classes should call the base class and then reset device() here.
54 */
55 virtual void reset();
56
57 /** Returns the QIODevice backing this HtmlWriter instance.
58 * Before writing to this directly, make sure to flush stream().
59 */
60 virtual QIODevice *device() const = 0;
61
62 /** Returns a QTextStream on device().
63 * Use this for writing QString data, rather than local string
64 * concatenations.
65 */
66 QTextStream *stream() const;
67
68 /**
69 * Embed a part with Content-ID @p contentId, using url @p url.
70 */
71 virtual void embedPart(const QByteArray &contentId, const QString &url) = 0;
72
73 virtual void setExtraHead(const QString &str) = 0;
74
75 virtual void setStyleBody(const QString &styleBody) = 0;
76
77private:
78 Q_DISABLE_COPY(HtmlWriter)
79 mutable std::unique_ptr<QTextStream> m_stream;
80};
81}
An interface for HTML sinks.
Definition htmlwriter.h:29
virtual void embedPart(const QByteArray &contentId, const QString &url)=0
Embed a part with Content-ID contentId, using url url.
virtual QIODevice * device() const =0
Returns the QIODevice backing this HtmlWriter instance.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 11:49:56 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.