Grantlee  0.3.0
markupdirector.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 
22 #ifndef GRANTLEE_MARKUPDIRECTOR_H
23 #define GRANTLEE_MARKUPDIRECTOR_H
24 
25 #include "abstractmarkupbuilder.h"
26 #include "grantlee_gui_export.h"
27 
28 #include <QtGui/QTextDocument>
29 #include <QtGui/QTextFrame>
30 
31 class QTextTable;
32 class QTextTableCell;
33 class QTextList;
34 class QTextCharFormat;
35 
36 namespace Grantlee
37 {
38 
39 class MarkupDirectorPrivate;
40 
42 
90 class GRANTLEE_GUI_EXPORT MarkupDirector
91 {
92 public:
97 
101  virtual ~MarkupDirector();
102 
106  virtual void processDocument( QTextDocument* doc );
107 
111  virtual QTextFrame::iterator processFrame( QTextFrame::iterator it, QTextFrame *frame );
112 
118  virtual QTextFrame::iterator processBlock( QTextFrame::iterator it, const QTextBlock &block );
119 
125  virtual QTextFrame::iterator processObject( QTextFrame::iterator it, const QTextBlock &block, QTextObject *textObject );
126 
132  virtual QPair<QTextFrame::iterator, QTextBlock> processBlockGroup( QTextFrame::iterator it, const QTextBlock &block, QTextBlockGroup *textBlockGroup );
133 
139  virtual QPair<QTextFrame::iterator, QTextBlock> processList( QTextFrame::iterator it, const QTextBlock &block, QTextList *textList );
140 
144  virtual QTextFrame::iterator processBlockContents( QTextFrame::iterator it, const QTextBlock &block );
145 
149  virtual void processCustomFragment( const QTextFragment &fragment, QTextDocument const *doc );
150 
154  virtual QTextBlock::iterator processFragment( QTextBlock::iterator it, const QTextFragment &fragment, QTextDocument const *doc );
155 
161  virtual QTextBlock::iterator processCharTextObject( QTextBlock::iterator it, const QTextFragment &fragment, QTextObject *textObject );
162 
168  virtual QTextBlock::iterator processImage( QTextBlock::iterator it, const QTextImageFormat &imageFormat, QTextDocument *doc );
169 
175  virtual QTextFrame::iterator processTable( QTextFrame::iterator it, QTextTable *table );
176 
180  virtual void processTableCell( const QTextTableCell &tableCell, QTextTable *table );
181 
182 protected:
186  void processDocumentContents( QTextFrame::iterator begin, QTextFrame::iterator end );
187 
193  QPair<QTextFrame::iterator, QTextBlock> skipBlockGroup( QTextFrame::iterator it, const QTextBlock &_block, QTextBlockGroup *blockGroup );
194 
200  QList< int > sortOpeningOrder( QSet< int > openingTags, QTextBlock::iterator it ) const;
201 
205  virtual void processClosingElements( QTextBlock::iterator it );
206 
210  virtual void processOpeningElements( QTextBlock::iterator it );
211 
215  virtual QSet< int > getElementsToClose( QTextBlock::iterator it ) const;
216 
220  virtual QList< int > getElementsToOpen( QTextBlock::iterator it );
221 
226  None = 0x0,
227  SuperScript = 0x01,
228  SubScript = 0x02,
229  Anchor = 0x04,
230  SpanForeground = 0x08,
231  SpanBackground = 0x10,
232  SpanFontFamily = 0x20,
233  SpanFontPointSize = 0x40,
234  Strong = 0x80,
235  Emph = 0x100,
236  Underline = 0x200,
237  StrikeOut = 0x400
238  };
239 
240 protected:
241 #ifndef Q_QDOC
242  MarkupDirectorPrivate * const d_ptr;
243 #endif
244 
249 
250 #ifndef Q_QDOC
251 private:
252  Q_DECLARE_PRIVATE( MarkupDirector )
253 #endif
254 };
255 
256 }
257 
258 #endif
The MarkupDirector class controls and instructs a builder object to create markup output...
AbstractMarkupBuilder * m_builder
The AbstractMarkupBuilder class serves as a base class for creating marked up plain text output...