summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtexthtmlparser_p.h
diff options
context:
space:
mode:
authorNils Jeisecke <jeisecke@saltation.de>2015-12-17 16:38:15 +0100
committerNils Jeisecke <nils.jeisecke@saltation.com>2019-08-19 20:59:12 +0200
commitd8a9bec35fb0c60a0e5990c1a12ffe6f39fdbf2d (patch)
treef2682539a00af01d617d744f1c28510988639beb /src/gui/text/qtexthtmlparser_p.h
parent8240c24866550c4c083a7c1020d0b1b1bb7c8329 (diff)
QTextDocument: add css-styling of table cell borders to HTML import/export
Supported style attributes: <table> style: supports "border-collapse: collapse" and "border-color". border: width of the outer border bordercolor: basic color for all borders <tr> style: not supported <td>/</th> style: supports the "border", "border-[top|left|bottom|right]]" shorthand styles and the "border-width", "border-color" and "border-style" (and the top/left/bottom/right variants) attributes <table border=1 style="border-collapse: collapse"> will render a simple 1px table grid. Notes: The QTextDocument table model is much simpler than the HTML table model. It basically only has <table> and <td> support. So the HTML parser is forced to map markup and styling to the QTextDocument model which is not without loss. In other words: While QTextDocument -> HTML -> QTextDocument should preserve the QTextDocument structure, HTML -> QTextDocument -> HTML does not preserve the HTML DOM at all. So for now the HTML importer and writer only support border styles on the <td> and <th> nodes. In future updates, the HTML parser might be enhanced to map <tr> and <table> CSS styles to the cells. Change-Id: If9e7312fa6cbf270cf8f7b3c72ba1fa094107517 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/gui/text/qtexthtmlparser_p.h')
-rw-r--r--src/gui/text/qtexthtmlparser_p.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h
index ff5f5b4c35..31f558709f 100644
--- a/src/gui/text/qtexthtmlparser_p.h
+++ b/src/gui/text/qtexthtmlparser_p.h
@@ -195,8 +195,12 @@ struct QTextHtmlParserNode {
int tableCellColSpan;
qreal tableCellSpacing;
qreal tableCellPadding;
+ qreal tableCellBorder[4];
+ QBrush tableCellBorderBrush[4];
+ QTextFrameFormat::BorderStyle tableCellBorderStyle[4];
QBrush borderBrush;
QTextFrameFormat::BorderStyle borderStyle;
+ bool borderCollapse;
int userState;
int cssListIndent;
@@ -290,6 +294,10 @@ public:
inline int leftPadding(int i) const { return at(i).padding[MarginLeft]; }
inline int rightPadding(int i) const { return at(i).padding[MarginRight]; }
+ inline qreal tableCellBorder(int i, int edge) const { return at(i).tableCellBorder[edge]; }
+ inline QTextFrameFormat::BorderStyle tableCellBorderStyle(int i, int edge) const { return at(i).tableCellBorderStyle[edge]; }
+ inline QBrush tableCellBorderBrush(int i, int edge) const { return at(i).tableCellBorderBrush[edge]; }
+
void dumpHtml();
void parse(const QString &text, const QTextDocument *resourceProvider);