本文整理汇总了C++中KoXmlElement::hasChildNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ KoXmlElement::hasChildNodes方法的具体用法?C++ KoXmlElement::hasChildNodes怎么用?C++ KoXmlElement::hasChildNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoXmlElement
的用法示例。
在下文中一共展示了KoXmlElement::hasChildNodes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadXML
bool KraConverter::loadXML(const KoXmlDocument &doc, KoStore *store)
{
Q_UNUSED(store);
KoXmlElement root;
KoXmlNode node;
if (doc.doctype().name() != "DOC") {
m_doc->setErrorMessage(i18n("The format is not supported or the file is corrupted"));
return false;
}
root = doc.documentElement();
int syntaxVersion = root.attribute("syntaxVersion", "3").toInt();
if (syntaxVersion > 2) {
m_doc->setErrorMessage(i18n("The file is too new for this version of Krita (%1).", syntaxVersion));
return false;
}
if (!root.hasChildNodes()) {
m_doc->setErrorMessage(i18n("The file has no layers."));
return false;
}
m_kraLoader = new KisKraLoader(m_doc, syntaxVersion);
// Legacy from the multi-image .kra file period.
for (node = root.firstChild(); !node.isNull(); node = node.nextSibling()) {
if (node.isElement()) {
if (node.nodeName() == "IMAGE") {
KoXmlElement elem = node.toElement();
if (!(m_image = m_kraLoader->loadXML(elem))) {
if (m_kraLoader->errorMessages().isEmpty()) {
m_doc->setErrorMessage(i18n("Unknown error."));
}
else {
m_doc->setErrorMessage(m_kraLoader->errorMessages().join(".\n"));
}
return false;
}
return true;
}
else {
if (m_kraLoader->errorMessages().isEmpty()) {
m_doc->setErrorMessage(i18n("The file does not contain an image."));
}
return false;
}
}
}
return false;
}
示例2: parsePattern
void SvgParser::parsePattern(SvgPatternHelper &pattern, const KoXmlElement &e)
{
if (e.attribute("patternUnits") == "userSpaceOnUse") {
pattern.setPatternUnits(SvgPatternHelper::UserSpaceOnUse);
}
if (e.attribute("patternContentUnits") == "objectBoundingBox") {
pattern.setPatternContentUnits(SvgPatternHelper::ObjectBoundingBox);
}
const QString viewBox = e.attribute("viewBox");
if (!viewBox.isEmpty()) {
pattern.setPatternContentViewbox(SvgUtil::parseViewBox(viewBox));
}
const QString transform = e.attribute("patternTransform");
if (!transform.isEmpty()) {
pattern.setTransform(SvgUtil::parseTransform(transform));
}
const QString x = e.attribute("x");
const QString y = e.attribute("y");
const QString w = e.attribute("width");
const QString h = e.attribute("height");
// parse tile reference rectangle
if (pattern.patternUnits() == SvgPatternHelper::UserSpaceOnUse) {
if (!x.isEmpty() && !y.isEmpty()) {
pattern.setPosition(QPointF(parseUnitX(x), parseUnitY(y)));
}
if (!w.isEmpty() && !h.isEmpty()) {
pattern.setSize(QSizeF(parseUnitX(w), parseUnitY(h)));
}
} else {
// x, y, width, height are in percentages of the object referencing the pattern
// so we just parse the percentages
if (!x.isEmpty() && !y.isEmpty()) {
pattern.setPosition(QPointF(SvgUtil::fromPercentage(x), SvgUtil::fromPercentage(y)));
}
if (!w.isEmpty() && !h.isEmpty()) {
pattern.setSize(QSizeF(SvgUtil::fromPercentage(w), SvgUtil::fromPercentage(h)));
}
}
if (e.hasChildNodes()) {
pattern.setContent(e);
}
}