KD Reports API Documentation
2.2
|
#include <KDReportsXmlElementHandler.h>
Public Member Functions | |
XmlElementHandler () | |
virtual | ~XmlElementHandler () |
virtual bool | autoTableElement (KDReports::AutoTableElement &tableElement, QDomElement &xmlElement) |
virtual bool | chartElement (KDReports::ChartElement &chartElement, QDomElement &xmlElement) |
virtual void | customElement (const QDomElement &xmlElement) |
virtual bool | endCell (KDReports::Cell &cell, QDomElement &xmlElement) |
virtual void | endFooter (KDReports::Footer &footer, const QDomElement &xmlElement) |
virtual void | endHeader (KDReports::Header &header, const QDomElement &xmlElement) |
virtual void | endReport (KDReports::Report &report, const QDomElement &xmlElement) |
virtual bool | endTableElement (KDReports::TableElement &tableElement, QDomElement &xmlElement) |
KDReports::ErrorDetails | errorDetails () |
virtual bool | hLineElement (KDReports::HLineElement &hLineElement, QDomElement &xmlElement) |
virtual bool | htmlElement (KDReports::HtmlElement &htmlElement, QDomElement &xmlElement) |
virtual bool | imageElement (KDReports::ImageElement &imageElement, QDomElement &xmlElement) |
virtual bool | pageBreak (QDomElement &xmlElement) |
virtual bool | paragraphMargin (qreal &left, qreal &top, qreal &right, qreal &bottom, const QDomElement &xmlElement) |
void | setErrorDetails (const KDReports::ErrorDetails &details) |
virtual bool | startCell (KDReports::Cell &cell, QDomElement &xmlElement) |
virtual bool | startFooter (KDReports::Footer &footer, QDomElement &xmlElement) |
virtual bool | startHeader (KDReports::Header &header, QDomElement &xmlElement) |
virtual bool | startReport (KDReports::Report &report, QDomElement &xmlElement) |
virtual bool | startTableElement (KDReports::TableElement &tableElement, QDomElement &xmlElement) |
virtual bool | tabs (QList< QTextOption::Tab > &tabs, const QDomElement &xmlElement) |
virtual bool | textElement (KDReports::TextElement &textElement, QDomElement &xmlElement) |
virtual bool | variable (KDReports::VariableType &type, QDomElement &xmlElement) |
virtual bool | vspace (int &size, QDomElement &xmlElement) |
This handler is called for each XML element being parsed from an XML file. It allows you to customize the XML dynamically at runtime, by deriving from the XmlElementHandler interface and reimplementing some or all of the hooks. Each hook (virtual method) is called after the XML element has been parsed into a KDReports element, and before the KDReports element is added to the report. After that, both the XML element and the KDReports element are discarded, which is why this customization has to happen during loading.
Example: bool CustomElementHandler::textElement( KDReports::TextElement& textElement, const QDomElement& xmlElement ) { const QString id = xmlElement.attribute( "id" ); if ( id == "customerName" ) textElement.setTextColor( Qt::blue ); return true; }
All virtual methods return a boolean which can be used to skip an element: if the method returns false, the KDReports element will not be added to the report.
Note that you can even insert new elements into the report from any of the handler methods. Those additional elements will be inserted before the currently parsed element.
It is possible to signal an error, during parsing, by calling setErrorDetails. This will result in parsing being terminated, and the error being reported to the user.
To set up the handler so that it is used during parsing, use handler = new CustomElementHandler; report.setXmlElementHandler( handler );
Definition at line 78 of file KDReportsXmlElementHandler.h.
KDReports::XmlElementHandler::XmlElementHandler | ( | ) |
Definition at line 34 of file KDReportsXmlElementHandler.cpp.
|
virtualdefault |
|
virtual |
Called after parsing a "table" element (when a model is set) and its attributes, but before parsing the cells in the table. Changes to those attributes must be done on tableElement
.
As a special case, changes to the alignment for block elements must be done using xmlElement.setAttribute()
.
Definition at line 116 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "chart" and its attributes. Changes to those attributes must be done on chartElement
.
As a special case, changes to the alignment for block elements must be done using xmlElement.setAttribute()
.
Definition at line 123 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "custom", whose only purpose is to call this method. This allows you to define special places in the XML file where this method should be called, for instance to insert dynamic content into the report.
Definition at line 150 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing each "cell" element inside a table and its contents. Returning false makes the cell empty.
Definition at line 109 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "footer" and its contents.
Definition at line 68 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "header" and its contents.
Definition at line 55 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called at the end of the parsing of the whole report. The "report" element is passed again here.
Definition at line 155 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing a "table" (without a model) and its cells. Returning false skips the whole table.
Definition at line 95 of file KDReportsXmlElementHandler.cpp.
KDReports::ErrorDetails KDReports::XmlElementHandler::errorDetails | ( | ) |
Definition at line 197 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing a "hline". Returning false skips the whole line. Can be used to change hline attributes.
Definition at line 143 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "html", its attributes and the html content. Changes to those attributes must be done on htmlElement
.
As a special case, changes to the alignment and paragraph-background for block elements must done using xmlElement.setAttribute()
, since they are not properties of KDReports::HtmlElement.
Definition at line 81 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "image" and its attributes. Changes to those attributes must be done on imageElement
.
As a special case, changes to the alignment for block elements must be done using xmlElement.setAttribute()
.
Definition at line 130 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "page-break". Can be used to skip the page break depending on some condition.
Definition at line 137 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing a "paragraph-margins". Returning false skips the paragraph margin.
Definition at line 175 of file KDReportsXmlElementHandler.cpp.
void KDReports::XmlElementHandler::setErrorDetails | ( | const KDReports::ErrorDetails & | details | ) |
When parsing the XML code, errors may be reported by setting an ErrorDetail using this method. Parsing will be stopped, and the error reported back to the user.
Definition at line 192 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing a "cell" element inside a table, but before parsing the cell contents. Returning false makes the cell empty.
Definition at line 102 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "footer" and its attributes, but before parsing its contents. Returning false skips this footer.
Definition at line 61 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "header" and its attributes, but before parsing its contents. Returning false skips this header.
Definition at line 48 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "report" and its attributes. Returning false aborts the loading of the report.
Definition at line 41 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "table" (without a model) and its attributes, but before parsing the cells in the table. Changes to those attributes must be done on tableElement
.
As a special case, changes to the alignment for block elements must be done using xmlElement.setAttribute()
. Returning false skips the whole table.
Definition at line 88 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing a "tabs" Returning false skips tabs
Definition at line 185 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "text", its attributes and the text content. Changes to those attributes must be done on textElement
.
As a special case, changes to the alignment and paragraph-background for block elements must done using xmlElement.setAttribute()
, since they are not properties of KDReports::TextElement.
Definition at line 74 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "variable".
Definition at line 168 of file KDReportsXmlElementHandler.cpp.
|
virtual |
Called after parsing "vspace" Can be used to modify vertical space size Returning false skip the vertical space
Definition at line 161 of file KDReportsXmlElementHandler.cpp.