Grantlee  5.1.0
texthtmlbuilder.h
1 /*
2  This file is part of the Grantlee template system.
3 
4  Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either version
9  2.1 of the Licence, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 
19 */
20 
21 #ifndef GRANTLEE_TEXTHTMLBUILDER_H
22 #define GRANTLEE_TEXTHTMLBUILDER_H
23 
24 #ifdef Q_CC_MSVC
25 #pragma warning(disable : 4250)
26 #endif
27 
28 #include "abstractmarkupbuilder.h"
29 #include "grantlee_textdocument_export.h"
30 #include "markupdirector.h"
31 
32 namespace Grantlee
33 {
34 
35 class TextHTMLBuilderPrivate;
36 
38 
103 class GRANTLEE_TEXTDOCUMENT_EXPORT TextHTMLBuilder
104  : virtual public AbstractMarkupBuilder
105 {
106 public:
110  TextHTMLBuilder();
111  ~TextHTMLBuilder() override;
112 
113  void beginStrong() override;
114  void endStrong() override;
115  void beginEmph() override;
116  void endEmph() override;
117  void beginUnderline() override;
118  void endUnderline() override;
119  void beginStrikeout() override;
120  void endStrikeout() override;
121  void beginForeground(const QBrush &brush) override;
122  void endForeground() override;
123  void beginBackground(const QBrush &brush) override;
124  void endBackground() override;
125  void beginAnchor(const QString &href = QString(),
126  const QString &name = QString()) override;
127  void endAnchor() override;
128 
129  // Maybe this stuff should just be added to a list, and then when I add
130  // literal text,
131  // add some kind of style attribute in one span instead of many.
132  void beginFontFamily(const QString &family) override;
133  void endFontFamily() override;
134 
139  void beginFontPointSize(int size) override;
140  void endFontPointSize() override;
141 
150  void beginParagraph(Qt::Alignment al = Qt::AlignLeft, qreal topMargin = 0.0,
151  qreal bottomMargin = 0.0, qreal leftMargin = 0.0,
152  qreal rightMargin = 0.0) override;
153 
158  void beginHeader(int level) override;
159 
164  void endHeader(int level) override;
165 
166  void endParagraph() override;
167  void addNewline() override;
168 
169  void insertHorizontalRule(int width = -1) override;
170 
171  void insertImage(const QString &src, qreal width, qreal height) override;
172 
173  void beginList(QTextListFormat::Style type) override;
174 
175  void endList() override;
176 
177  void beginListItem() override;
178  void endListItem() override;
179 
180  void beginSuperscript() override;
181 
182  void endSuperscript() override;
183 
184  void beginSubscript() override;
185 
186  void endSubscript() override;
187 
188  void beginTable(qreal cellpadding, qreal cellspacing,
189  const QString &width) override;
190 
191  void beginTableRow() override;
192  void beginTableHeaderCell(const QString &width, int colspan,
193  int rowspan) override;
194 
195  void beginTableCell(const QString &width, int colspan, int rowspan) override;
196 
197  void endTable() override;
198  void endTableRow() override;
199  void endTableHeaderCell() override;
200  void endTableCell() override;
201 
217  void appendLiteralText(const QString &text) override;
218 
224  void appendRawText(const QString &text) override;
225 
226  QString getResult() override;
227 
228 private:
229  TextHTMLBuilderPrivate *d_ptr;
230  Q_DECLARE_PRIVATE(TextHTMLBuilder)
231 };
232 }
233 
234 #endif
The TextHTMLBuilder creates a clean html markup output.
The AbstractMarkupBuilder class serves as a base class for creating marked up plain text output...
The Grantlee namespace holds all public Grantlee API.
Definition: Mainpage.dox:7