Grantlee 0.1.9
|
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 00022 #ifndef GRANTLEE_MARKUPDIRECTOR_H 00023 #define GRANTLEE_MARKUPDIRECTOR_H 00024 00025 #include "abstractmarkupbuilder.h" 00026 #include "grantlee_gui_export.h" 00027 00028 #include <QtGui/QTextDocument> 00029 #include <QtGui/QTextFrame> 00030 00031 class QTextTable; 00032 class QTextTableCell; 00033 class QTextList; 00034 class QTextCharFormat; 00035 00036 namespace Grantlee 00037 { 00038 00039 class MarkupDirectorPrivate; 00040 00042 00090 class GRANTLEE_GUI_EXPORT MarkupDirector 00091 { 00092 public: 00096 MarkupDirector( AbstractMarkupBuilder *builder ); 00097 00101 virtual ~MarkupDirector(); 00102 00106 virtual void processDocument( QTextDocument* doc ); 00107 00111 virtual QTextFrame::iterator processFrame( QTextFrame::iterator it, QTextFrame *frame ); 00112 00118 virtual QTextFrame::iterator processBlock( QTextFrame::iterator it, const QTextBlock &block ); 00119 00125 virtual QTextFrame::iterator processObject( QTextFrame::iterator it, const QTextBlock &block, QTextObject *textObject ); 00126 00132 virtual QPair<QTextFrame::iterator, QTextBlock> processBlockGroup( QTextFrame::iterator it, const QTextBlock &block, QTextBlockGroup *textBlockGroup ); 00133 00139 virtual QPair<QTextFrame::iterator, QTextBlock> processList( QTextFrame::iterator it, const QTextBlock &block, QTextList *textList ); 00140 00144 virtual QTextFrame::iterator processBlockContents( QTextFrame::iterator it, const QTextBlock &block ); 00145 00149 virtual void processCustomFragment( const QTextFragment &fragment, QTextDocument const *doc ); 00150 00154 virtual QTextBlock::iterator processFragment( QTextBlock::iterator it, const QTextFragment &fragment, QTextDocument const *doc ); 00155 00161 virtual QTextBlock::iterator processCharTextObject( QTextBlock::iterator it, const QTextFragment &fragment, QTextObject *textObject ); 00162 00168 virtual QTextBlock::iterator processImage( QTextBlock::iterator it, const QTextImageFormat &imageFormat, QTextDocument *doc ); 00169 00175 virtual QTextFrame::iterator processTable( QTextFrame::iterator it, QTextTable *table ); 00176 00180 virtual void processTableCell( const QTextTableCell &tableCell, QTextTable *table ); 00181 00182 protected: 00186 void processDocumentContents( QTextFrame::iterator begin, QTextFrame::iterator end ); 00187 00193 QPair<QTextFrame::iterator, QTextBlock> skipBlockGroup( QTextFrame::iterator it, const QTextBlock &_block, QTextBlockGroup *blockGroup ); 00194 00200 QList< int > sortOpeningOrder( QSet< int > openingTags, QTextBlock::iterator it ) const; 00201 00205 virtual void processClosingElements( QTextBlock::iterator it ); 00206 00210 virtual void processOpeningElements( QTextBlock::iterator it ); 00211 00215 virtual QSet< int > getElementsToClose( QTextBlock::iterator it ) const; 00216 00220 virtual QList< int > getElementsToOpen( QTextBlock::iterator it ); 00221 00225 enum OpenElementValues { 00226 None = 0x0, 00227 SuperScript = 0x01, 00228 SubScript = 0x02, 00229 Anchor = 0x04, 00230 SpanForeground = 0x08, 00231 SpanBackground = 0x10, 00232 SpanFontFamily = 0x20, 00233 SpanFontPointSize = 0x40, 00234 Strong = 0x80, 00235 Emph = 0x100, 00236 Underline = 0x200, 00237 StrikeOut = 0x400 00238 }; 00239 00240 protected: 00241 #ifndef Q_QDOC 00242 MarkupDirectorPrivate * const d_ptr; 00243 #endif 00244 00248 AbstractMarkupBuilder *m_builder; 00249 00250 #ifndef Q_QDOC 00251 private: 00252 Q_DECLARE_PRIVATE( MarkupDirector ) 00253 #endif 00254 }; 00255 00256 } 00257 00258 #endif