本文整理汇总了C++中dom::Element::getRect方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::getRect方法的具体用法?C++ Element::getRect怎么用?C++ Element::getRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dom::Element
的用法示例。
在下文中一共展示了Element::getRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_table
bool KHTMLReader::parse_table(DOM::Element e)
{
if (_writer->isInTable()) {
// We are already inside of a table. Tables in tables are not supported
// yet. So, just add that table-content as text.
for (DOM::Node rows = e.firstChild().firstChild();!rows.isNull();rows = rows.nextSibling())
if (!rows.isNull() && rows.nodeName().string().toLower() == "tr")
for (DOM::Node cols = rows.firstChild();!cols.isNull();cols = cols.nextSibling())
if (!cols.isNull())
parseNode(cols);
return false;
}
DOM::Element table_body = e.firstChild();
if (table_body.isNull()) {
// If the table_body is empty, we don't continue cause else
// KHTML will throw a DOM::DOMException if we try to access
// the null element.
return true;
}
int tableno = _writer->createTable();
int nrow = 0;
int ncol = 0;
bool has_borders = false;
QColor bgcolor = parsecolor("#FFFFFF");
if (!table_body.getAttribute("bgcolor").string().isEmpty())
bgcolor = parsecolor(table_body.getAttribute("bgcolor").string());
if ((e.getAttribute("border").string().toInt() > 0))
has_borders = true;
// fixme rewrite this proper
//(maybe using computed sizes from khtml if thats once exported)
for (DOM::Node rowsnode = table_body.firstChild();!rowsnode.isNull();rowsnode = rowsnode.nextSibling()) {
DOM::Element rows = rowsnode;
if (!rows.isNull() && rows.tagName().string().toLower() == "tr") {
QColor obgcolor = bgcolor;
if (!rows.getAttribute("bgcolor").string().isEmpty())
bgcolor = parsecolor(rows.getAttribute("bgcolor").string());
ncol = 0;
for (DOM::Node colsnode = rows.firstChild();!colsnode.isNull();colsnode = colsnode.nextSibling()) {
DOM::Element cols = colsnode;
const QString nodename = cols.isNull() ? QString() : cols.nodeName().string().toLower();
if (nodename == "td" || nodename == "th") {
QColor bbgcolor = bgcolor;
if (!cols.getAttribute("bgcolor").string().isEmpty())
bgcolor = parsecolor(cols.getAttribute("bgcolor").string());
pushNewState();
QRect colrect = cols.getRect();
state()->frameset = _writer->createTableCell(tableno, nrow, ncol, 1, colrect);
state()->frameset.firstChild().toElement().setAttribute("bkRed", bgcolor.red());
state()->frameset.firstChild().toElement().setAttribute("bkGreen", bgcolor.green());
state()->frameset.firstChild().toElement().setAttribute("bkBlue", bgcolor.blue());
if (has_borders) {
state()->frameset.firstChild().toElement().setAttribute("lWidth", 1);
state()->frameset.firstChild().toElement().setAttribute("rWidth", 1);
state()->frameset.firstChild().toElement().setAttribute("bWidth", 1);
state()->frameset.firstChild().toElement().setAttribute("tWidth", 1);
}
// fixme don't guess. get it right.
state()->paragraph = _writer->addParagraph(state()->frameset);
parseNode(cols);
_writer->cleanUpParagraph(state()->paragraph);
popState();
ncol++;
bgcolor = bbgcolor;
}
}
nrow++;
bgcolor = obgcolor;
}
}
_writer->finishTable(tableno/*,0,0,r.right()-r.left(),r.bottom()-r.top()*/); // FIXME find something better.
startNewParagraph(false, false);
_writer->createInline(state()->paragraph, _writer->fetchTableCell(tableno, 0, 0));
startNewParagraph(false, false);
return false; // we do our own recursion
}