Cutelee
6.1.0
|
Instructs a builder object to create markup output. More...
#include <cutelee/markupdirector.h>
Public Member Functions | |
MarkupDirector (AbstractMarkupBuilder *builder) | |
virtual | ~MarkupDirector () |
virtual QTextFrame::iterator | processBlock (QTextFrame::iterator it, const QTextBlock &block) |
virtual QTextFrame::iterator | processBlockContents (QTextFrame::iterator it, const QTextBlock &block) |
virtual std::pair< QTextFrame::iterator, QTextBlock > | processBlockGroup (QTextFrame::iterator it, const QTextBlock &block, QTextBlockGroup *textBlockGroup) |
virtual QTextBlock::iterator | processCharTextObject (QTextBlock::iterator it, const QTextFragment &fragment, QTextObject *textObject) |
virtual void | processCustomFragment (const QTextFragment &fragment, QTextDocument const *doc) |
virtual void | processDocument (QTextDocument *doc) |
virtual QTextBlock::iterator | processFragment (QTextBlock::iterator it, const QTextFragment &fragment, QTextDocument const *doc) |
virtual QTextFrame::iterator | processFrame (QTextFrame::iterator it, QTextFrame *frame) |
virtual QTextBlock::iterator | processImage (QTextBlock::iterator it, const QTextImageFormat &imageFormat, QTextDocument *doc) |
virtual std::pair< QTextFrame::iterator, QTextBlock > | processList (QTextFrame::iterator it, const QTextBlock &block, QTextList *textList) |
virtual QTextFrame::iterator | processObject (QTextFrame::iterator it, const QTextBlock &block, QTextObject *textObject) |
virtual QTextFrame::iterator | processTable (QTextFrame::iterator it, QTextTable *table) |
virtual void | processTableCell (const QTextTableCell &tableCell, QTextTable *table) |
Protected Types | |
enum | OpenElementValues { None , SuperScript , SubScript , Anchor , SpanForeground , SpanBackground , SpanFontFamily , SpanFontPointSize , Strong , Emph , Underline , StrikeOut } |
Protected Member Functions | |
virtual QSet< int > | getElementsToClose (QTextBlock::iterator it) const |
virtual QList< int > | getElementsToOpen (QTextBlock::iterator it) |
virtual void | processClosingElements (QTextBlock::iterator it) |
void | processDocumentContents (QTextFrame::iterator begin, QTextFrame::iterator end) |
virtual void | processOpeningElements (QTextBlock::iterator it) |
std::pair< QTextFrame::iterator, QTextBlock > | skipBlockGroup (QTextFrame::iterator it, const QTextBlock &_block, QTextBlockGroup *blockGroup) |
QList< int > | sortOpeningOrder (QSet< int > openingTags, QTextBlock::iterator it) const |
Protected Attributes | |
AbstractMarkupBuilder * | m_builder |
The MarkupDirector is used with an implementation of AbstractMarkupBuilder to create a marked up document output.
Usage can be quite simple.
Or with a different builder:
The MarkupDirector also provides API for processing just part of a QTextDocument, such as a QTextFrame or a QTextBlock. The appropriate method may then be called with an invalid iterator as appropriate.
The behaviour of the MarkupDirector can be customized by subclassing. Support for custom types can also be added by implementing the processCustomFragment method.
Definition at line 92 of file markupdirector.h.
|
protected |
Flags for the tags that may be open.
Definition at line 273 of file markupdirector.h.
MarkupDirector::MarkupDirector | ( | AbstractMarkupBuilder * | builder | ) |
Constructor
Definition at line 42 of file markupdirector.cpp.
|
virtual |
Destructor
Definition at line 47 of file markupdirector.cpp.
|
protectedvirtual |
Returns the tags that should be closed at the position of it
.
Definition at line 646 of file markupdirector.cpp.
References Anchor, Emph, SpanBackground, SpanFontFamily, SpanFontPointSize, SpanForeground, StrikeOut, Strong, SubScript, SuperScript, and Underline.
Referenced by processClosingElements(), and sortOpeningOrder().
|
protectedvirtual |
Returns the tags that should be opened at the position of it
.
Definition at line 762 of file markupdirector.cpp.
References Anchor, Emph, sortOpeningOrder(), SpanBackground, SpanFontFamily, SpanFontPointSize, SpanForeground, StrikeOut, Strong, SubScript, SuperScript, and Underline.
Referenced by processOpeningElements().
|
virtual |
Directs the builder to create output for the single block
. If calling this method directly, an invalid QTextFrame::iterator may be used.
This method does not process the contents of the block
, but uses the processBlockContents method to do so.
Definition at line 80 of file markupdirector.cpp.
References processBlockContents(), and processObject().
Referenced by processDocumentContents().
|
virtual |
Directs the builder to create output for the contents of the single block
. If calling this method directly, an invalid QTextFrame::iterator may be used.
Definition at line 224 of file markupdirector.cpp.
References Cutelee::AbstractMarkupBuilder::addNewline(), Cutelee::AbstractMarkupBuilder::beginParagraph(), Cutelee::AbstractMarkupBuilder::endParagraph(), Cutelee::AbstractMarkupBuilder::insertHorizontalRule(), m_builder, and processFragment().
Referenced by processBlock(), and processList().
|
virtual |
Directs the builder to create output for the single textBlockGroup
. If calling this method directly, an invalid QTextFrame::iterator may be used.
The block block
is the first block in the textBlockGroup
.
Definition at line 442 of file markupdirector.cpp.
References processList(), and skipBlockGroup().
Referenced by processList(), and processObject().
|
virtual |
Directs the builder to create output for the contents of the single textObject
. The textObject
is represented in the QTextDocument with the QTextFragment fragment
.
If calling this method directly, an invalid QTextBlock::iterator may be used.
Definition at line 459 of file markupdirector.cpp.
References processImage().
Referenced by processFragment().
|
protectedvirtual |
Directs the builder to close the appropriate tags at the position of it
.
Definition at line 487 of file markupdirector.cpp.
References Anchor, Emph, Cutelee::AbstractMarkupBuilder::endAnchor(), Cutelee::AbstractMarkupBuilder::endBackground(), Cutelee::AbstractMarkupBuilder::endEmph(), Cutelee::AbstractMarkupBuilder::endFontFamily(), Cutelee::AbstractMarkupBuilder::endFontPointSize(), Cutelee::AbstractMarkupBuilder::endForeground(), Cutelee::AbstractMarkupBuilder::endStrikeout(), Cutelee::AbstractMarkupBuilder::endStrong(), Cutelee::AbstractMarkupBuilder::endSubscript(), Cutelee::AbstractMarkupBuilder::endSuperscript(), Cutelee::AbstractMarkupBuilder::endUnderline(), getElementsToClose(), m_builder, SpanBackground, SpanFontFamily, SpanFontPointSize, SpanForeground, StrikeOut, Strong, SubScript, SuperScript, and Underline.
Referenced by processFragment().
|
virtual |
Hook for instructing the builder to create output for the fragemnt
with a custom type. doc
is the document the fragment is in.
Definition at line 380 of file markupdirector.cpp.
Referenced by processFragment().
|
virtual |
Constructs the output by directing the builder to create the markup.
Definition at line 453 of file markupdirector.cpp.
References processFrame().
|
protected |
Processes the document between begin
and end
Definition at line 49 of file markupdirector.cpp.
References processBlock(), processFrame(), and processTable().
Referenced by processFrame(), and processTableCell().
|
virtual |
Directs the builder to create output for the contents of the single fragment
. If calling this method directly, an invalid QTextBlock::iterator may be used. doc
is the document the fragment is in.
Definition at line 282 of file markupdirector.cpp.
References Cutelee::AbstractMarkupBuilder::addNewline(), Cutelee::AbstractMarkupBuilder::appendLiteralText(), Cutelee::AbstractMarkupBuilder::beginParagraph(), Cutelee::AbstractMarkupBuilder::endParagraph(), m_builder, processCharTextObject(), processClosingElements(), processCustomFragment(), and processOpeningElements().
Referenced by processBlockContents().
|
virtual |
Directs the builder to create output for the single frame
. If calling this method directly, an invalid QTextFrame::iterator may be used.
Definition at line 69 of file markupdirector.cpp.
References processDocumentContents().
Referenced by processDocument(), and processDocumentContents().
|
virtual |
Directs the builder to create output for the image represented by the imageFormat
.
If calling this method directly, an invalid QTextBlock::iterator may be used. doc
is the document the fragment is in.
Definition at line 474 of file markupdirector.cpp.
References Cutelee::AbstractMarkupBuilder::insertImage(), and m_builder.
Referenced by processCharTextObject().
|
virtual |
Directs the builder to create output for the single textList
. If calling this method directly, an invalid QTextFrame::iterator may be used.
The block block
is the first block in the textList
.
Definition at line 195 of file markupdirector.cpp.
References Cutelee::AbstractMarkupBuilder::beginList(), Cutelee::AbstractMarkupBuilder::beginListItem(), Cutelee::AbstractMarkupBuilder::endList(), Cutelee::AbstractMarkupBuilder::endListItem(), m_builder, processBlockContents(), and processBlockGroup().
Referenced by processBlockGroup().
|
virtual |
Directs the builder to create output for the single textObject
. If calling this method directly, an invalid QTextFrame::iterator may be used.
The block block
is the container of the textObject
.
Definition at line 387 of file markupdirector.cpp.
References processBlockGroup().
Referenced by processBlock().
|
protectedvirtual |
Directs the builder to open the appropriate tags at the position of it
.
Definition at line 563 of file markupdirector.cpp.
References Anchor, Cutelee::AbstractMarkupBuilder::beginAnchor(), Cutelee::AbstractMarkupBuilder::beginBackground(), Cutelee::AbstractMarkupBuilder::beginEmph(), Cutelee::AbstractMarkupBuilder::beginFontFamily(), Cutelee::AbstractMarkupBuilder::beginFontPointSize(), Cutelee::AbstractMarkupBuilder::beginForeground(), Cutelee::AbstractMarkupBuilder::beginStrikeout(), Cutelee::AbstractMarkupBuilder::beginStrong(), Cutelee::AbstractMarkupBuilder::beginSubscript(), Cutelee::AbstractMarkupBuilder::beginSuperscript(), Cutelee::AbstractMarkupBuilder::beginUnderline(), Emph, Cutelee::AbstractMarkupBuilder::endAnchor(), getElementsToOpen(), m_builder, SpanBackground, SpanFontFamily, SpanFontPointSize, SpanForeground, StrikeOut, Strong, SubScript, SuperScript, and Underline.
Referenced by processFragment().
|
virtual |
Directs the builder to create output for the contents of the single table
.
If calling this method directly, an invalid QTextFrame::iterator may be used.
Definition at line 98 of file markupdirector.cpp.
References Cutelee::AbstractMarkupBuilder::beginTable(), Cutelee::AbstractMarkupBuilder::beginTableCell(), Cutelee::AbstractMarkupBuilder::beginTableHeaderCell(), Cutelee::AbstractMarkupBuilder::beginTableRow(), Cutelee::AbstractMarkupBuilder::endTable(), Cutelee::AbstractMarkupBuilder::endTableCell(), Cutelee::AbstractMarkupBuilder::endTableHeaderCell(), Cutelee::AbstractMarkupBuilder::endTableRow(), m_builder, and processTableCell().
Referenced by processDocumentContents().
|
virtual |
Directs the builder to create output for the contents of the single tableCell
. The tableCell is in the table
.
Definition at line 187 of file markupdirector.cpp.
References processDocumentContents().
Referenced by processTable().
|
protected |
Iterates the iterator it
to the first block after blockGroup
. _block
is any block in the blockGroup
.
The return pair is the iterator pointing after the end of blockGroup
and the first block after blockGroup
.
Definition at line 401 of file markupdirector.cpp.
Referenced by processBlockGroup().
|
protected |
Returns a list of tags contained in openingTags
sorted so they can be opened in order and will be closed in the correct order.
openingTags
should be a set of tags opened at the fragment pointed to by it
.
Definition at line 873 of file markupdirector.cpp.
References getElementsToClose().
Referenced by getElementsToOpen().
|
protected |
The builder this MarkupDirector is operating on. This is available when subclassing to customize behaviour.
Definition at line 297 of file markupdirector.h.
Referenced by processBlockContents(), processClosingElements(), processFragment(), processImage(), processList(), processOpeningElements(), and processTable().