Grantlee  5.1.0
textdocument/lib/plaintextmarkupbuilder.h
00001 /*
00002   This file is part of the Grantlee template system.
00003 
00004   Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Lesser General Public
00008   License as published by the Free Software Foundation; either version
00009   2.1 of the Licence, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Lesser General Public License for more details.
00015 
00016   You should have received a copy of the GNU Lesser General Public
00017   License along with this library.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 */
00020 
00021 #ifndef GRANTLEE_PLAINTEXTMARKUPBUILDER_H
00022 #define GRANTLEE_PLAINTEXTMARKUPBUILDER_H
00023 
00024 #ifdef Q_OS_WIN
00025 #pragma warning(disable : 4250)
00026 #endif
00027 
00028 #define LETTERSINALPHABET 26
00029 #define DIGITSOFFSET 10
00030 
00031 #include "abstractmarkupbuilder.h"
00032 #include "grantlee_textdocument_export.h"
00033 #include "markupdirector.h"
00034 
00035 class QBrush;
00036 
00037 namespace Grantlee
00038 {
00039 
00040 class PlainTextMarkupBuilderPrivate;
00041 
00043 
00104 class GRANTLEE_TEXTDOCUMENT_EXPORT PlainTextMarkupBuilder
00105     : virtual public AbstractMarkupBuilder
00106 {
00107 public:
00109   PlainTextMarkupBuilder();
00110 
00111   ~PlainTextMarkupBuilder() override;
00112 
00113   void beginStrong() override;
00114   void endStrong() override;
00115   void beginEmph() override;
00116   void endEmph() override;
00117   void beginUnderline() override;
00118   void endUnderline() override;
00119   void beginStrikeout() override;
00120   void endStrikeout() override;
00121 
00122   void beginAnchor(const QString &href = QString(),
00123                    const QString &name = QString()) override;
00124 
00125   void endAnchor() override;
00126 
00127   void beginForeground(const QBrush &brush) override;
00128 
00129   void endForeground() override;
00130 
00131   void beginBackground(const QBrush &brush) override;
00132 
00133   void endBackground() override;
00134 
00135   void beginFontFamily(const QString &family) override;
00136 
00137   void endFontFamily() override;
00138 
00139   void beginFontPointSize(int size) override;
00140 
00141   void endFontPointSize() override;
00142 
00143   void beginParagraph(Qt::Alignment a = Qt::AlignLeft, qreal top = 0.0,
00144                       qreal bottom = 0.0, qreal left = 0.0,
00145                       qreal right = 0.0) override;
00146 
00147   void endParagraph() override;
00148   void addNewline() override;
00149 
00150   void insertHorizontalRule(int width = -1) override;
00151 
00152   void insertImage(const QString &src, qreal width, qreal height) override;
00153 
00154   void beginList(QTextListFormat::Style style) override;
00155 
00156   void endList() override;
00157 
00158   void beginListItem() override;
00159 
00160   void endListItem() override;
00161 
00162   void beginSuperscript() override;
00163 
00164   void endSuperscript() override;
00165 
00166   void beginSubscript() override;
00167 
00168   void endSubscript() override;
00169 
00170   void beginTable(qreal cellpadding, qreal cellspacing,
00171                   const QString &width) override;
00172 
00173   void beginTableRow() override;
00174 
00175   void beginTableHeaderCell(const QString &width, int colSpan,
00176                             int rowSpan) override;
00177 
00178   void beginTableCell(const QString &width, int colSpan, int rowSpan) override;
00179 
00180   void endTable() override;
00181 
00182   void endTableRow() override;
00183 
00184   void endTableHeaderCell() override;
00185 
00186   void endTableCell() override;
00187 
00188   void beginHeader(int level) override;
00189 
00190   void endHeader(int level) override;
00191 
00192   void appendLiteralText(const QString &text) override;
00193 
00194   void appendRawText(const QString &text) override;
00195 
00200   int addReference(const QString &reference);
00201 
00205   QString getResult() override;
00206 
00207 private:
00208   PlainTextMarkupBuilderPrivate *const d_ptr;
00209   Q_DECLARE_PRIVATE(PlainTextMarkupBuilder)
00210 };
00211 }
00212 
00213 #endif