当前位置: 首页>>代码示例>>C++>>正文


C++ QXmlStreamAttributes::isEmpty方法代码示例

本文整理汇总了C++中QXmlStreamAttributes::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlStreamAttributes::isEmpty方法的具体用法?C++ QXmlStreamAttributes::isEmpty怎么用?C++ QXmlStreamAttributes::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QXmlStreamAttributes的用法示例。


在下文中一共展示了QXmlStreamAttributes::isEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: simplifyRichTextFilter

// Richtext simplification filter: Remove hard-coded font settings,
// <style> elements, <p> attributes other than 'align' and
// and unnecessary meta-information.
QString simplifyRichTextFilter(const QString &in, bool *isPlainTextPtr = 0)
{
	unsigned elementCount = 0;
	bool paragraphAlignmentFound = false;
	QString out;
	QXmlStreamReader reader(in);
	QXmlStreamWriter writer(&out);
	writer.setAutoFormatting(false);
	writer.setAutoFormattingIndent(0);

	while (!reader.atEnd()) {
		switch (reader.readNext()) {
		case QXmlStreamReader::StartElement:
			elementCount++;
			if (filterElement(reader.name())) {
				const QStringRef name = reader.name();
				QXmlStreamAttributes attributes = reader.attributes();
				filterAttributes(name, &attributes, &paragraphAlignmentFound);
				writer.writeStartElement(name.toString());
				if (!attributes.isEmpty())
					writer.writeAttributes(attributes);
			} else
				reader.readElementText(); // Skip away all nested elements and characters.
			break;
		case QXmlStreamReader::Characters:
			if (!isWhiteSpace(reader.text()))
				writer.writeCharacters(reader.text().toString());
			break;
		case QXmlStreamReader::EndElement:
			writer.writeEndElement();
			break;
		default:
			break;
		}
	}
	// Check for plain text (no spans, just <html><head><body><p>)
	if (isPlainTextPtr)
		*isPlainTextPtr = !paragraphAlignmentFound && elementCount == 4u; //
	return out;
}
开发者ID:Monthy,项目名称:gr-lida,代码行数:43,代码来源:editorwidget.cpp

示例2: writeParagraphStyle

bool OdtWriter::writeParagraphStyle(const QTextBlockFormat& format, const QString& name)
{
	QXmlStreamAttributes attributes;
	bool rtl = format.layoutDirection() == Qt::RightToLeft;
	if (rtl) {
		attributes.append(QString::fromLatin1("style:writing-mode"), QString::fromLatin1("rl"));
	}

	Qt::Alignment align = format.alignment();
	if (rtl && (align & Qt::AlignLeft)) {
		attributes.append(QString::fromLatin1("fo:text-align"), QString::fromLatin1("left"));
	} else if (align & Qt::AlignRight) {
		attributes.append(QString::fromLatin1("fo:text-align"), QString::fromLatin1("right"));
	} else if (align & Qt::AlignCenter) {
		attributes.append(QString::fromLatin1("fo:text-align"), QString::fromLatin1("center"));
	} else if (align & Qt::AlignJustify) {
		attributes.append(QString::fromLatin1("fo:text-align"), QString::fromLatin1("justify"));
	}

	if (format.indent() > 0) {
		attributes.append(QString::fromLatin1("fo:margin-left"), QString::number(format.indent() * 0.5) + QString::fromLatin1("in"));
	}

	if (attributes.isEmpty()) {
		return false;
	}

	m_xml.writeStartElement(QString::fromLatin1("style:style"));
	m_xml.writeAttribute(QString::fromLatin1("style:name"), name);
	m_xml.writeAttribute(QString::fromLatin1("style:family"), QString::fromLatin1("paragraph"));
	m_xml.writeAttribute(QString::fromLatin1("style:parent-style-name"), QString::fromLatin1("Normal"));

	m_xml.writeEmptyElement(QString::fromLatin1("style:paragraph-properties"));
	m_xml.writeAttributes(attributes);
	m_xml.writeEndElement();

	return true;
}
开发者ID:olivierkes,项目名称:focuswriter,代码行数:38,代码来源:odt_writer.cpp

示例3: writeTextStyle

bool OdtWriter::writeTextStyle(const QTextCharFormat& format, const QString& name)
{
	QXmlStreamAttributes attributes;
	if (format.fontWeight() == QFont::Bold) {
		attributes.append(QString::fromLatin1("fo:font-weight"), QString::fromLatin1("bold"));
	}
	if (format.fontItalic()) {
		attributes.append(QString::fromLatin1("fo:font-style"), QString::fromLatin1("italic"));
	}
	if (format.fontUnderline()) {
		attributes.append(QString::fromLatin1("style:text-underline-type"), QString::fromLatin1("single"));
		attributes.append(QString::fromLatin1("style:text-underline-style"), QString::fromLatin1("solid"));
	}
	if (format.fontStrikeOut()) {
		attributes.append(QString::fromLatin1("style:text-line-through-type"), QString::fromLatin1("single"));
	}
	if (format.verticalAlignment() == QTextCharFormat::AlignSuperScript) {
		attributes.append(QString::fromLatin1("style:text-position"), QString::fromLatin1("super"));
	} else if (format.verticalAlignment() == QTextCharFormat::AlignSubScript) {
		attributes.append(QString::fromLatin1("style:text-position"), QString::fromLatin1("sub"));
	}

	if (attributes.isEmpty()) {
		return false;
	}

	m_xml.writeStartElement(QString::fromLatin1("style:style"));
	m_xml.writeAttribute(QString::fromLatin1("style:name"), name);
	m_xml.writeAttribute(QString::fromLatin1("style:family"), QString::fromLatin1("text"));

	m_xml.writeEmptyElement(QString::fromLatin1("style:text-properties"));
	m_xml.writeAttributes(attributes);
	m_xml.writeEndElement();

	return true;
}
开发者ID:olivierkes,项目名称:focuswriter,代码行数:36,代码来源:odt_writer.cpp


注:本文中的QXmlStreamAttributes::isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。