本文整理汇总了C++中KoXmlElement::isElement方法的典型用法代码示例。如果您正苦于以下问题:C++ KoXmlElement::isElement方法的具体用法?C++ KoXmlElement::isElement怎么用?C++ KoXmlElement::isElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoXmlElement
的用法示例。
在下文中一共展示了KoXmlElement::isElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadOdf
bool ChartTableModel::loadOdf( const KoXmlElement &tableElement,
KoShapeLoadingContext &context )
{
Q_UNUSED( context );
setRowCount( 0 );
setColumnCount( 0 );
///const QDomNode &node = tableElement.asQDomNode( QDomDocument() );
//QTextStream stream(stdout);
//stream << node;
// FIXME: Rewrite this without the for loop. I think there can
// only be one table-rows and one table-header-rows element
// in each table.
int row = 0;
KoXmlElement n;
int found = false;
forEachElement ( n, tableElement ) {
if ( n.namespaceURI() != KoXmlNS::table )
continue;
if ( n.localName() == "table-rows"
|| n.localName() == "table-header-rows" )
{
found = true;
KoXmlElement _n;
forEachElement ( _n, n ) {
// Must be a table:table-row, else go to next element.
if ( _n.namespaceURI() != KoXmlNS::table
|| _n.localName() != "table-row" )
continue;
// Add a row to the internal representation.
setRowCount( rowCount() + 1 );
// Loop through all cells in a table row.
int column = 0;
KoXmlElement __n;
forEachElement ( __n, _n ) {
// Must be a table:table-cell, otherwise go to
// next element.
if ( __n.namespaceURI() == KoXmlNS::table
&& __n.localName() == "table-cell" )
{
// continue;
// If this row is wider than any previous one,
// then add another column.
// Is this efficient enough?
if ( column >= columnCount() )
setColumnCount( columnCount() + 1 );
const QString valueType = __n.attributeNS( KoXmlNS::office, "value-type" );
QString valueString = __n.attributeNS( KoXmlNS::office, "value" );
const KoXmlElement valueElement = __n.namedItemNS( KoXmlNS::text, "p" ).toElement();
if ( ( valueElement.isNull() || !valueElement.isElement() ) && valueString.isEmpty() )
{
qWarning() << "ChartTableModel::loadOdf(): Cell contains no valid <text:p> element, cannnot load cell data.";
// Even if it doesn't contain any value, it's still a cell.
column++;
continue;
}
// Read the actual value in the cell.
QVariant value;
if ( valueString.isEmpty() )
valueString = valueElement.text();
if ( valueType == "float" )
value = valueString.toDouble();
else if ( valueType == "boolean" )
value = (bool)valueString.toInt();
else // if ( valueType == "string" )
value = valueString;
setData( index( row, column ), value );
++column;
}
} // foreach table:table-cell
++row;
} // foreach table:table-row
}
}