本文整理汇总了C++中KoXmlElement::lastChild方法的典型用法代码示例。如果您正苦于以下问题:C++ KoXmlElement::lastChild方法的具体用法?C++ KoXmlElement::lastChild怎么用?C++ KoXmlElement::lastChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoXmlElement
的用法示例。
在下文中一共展示了KoXmlElement::lastChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadXML
KisImageWSP KisKraLoader::loadXML(const KoXmlElement& element)
{
QString attr;
KisImageWSP image = 0;
QString name;
qint32 width;
qint32 height;
QString profileProductName;
double xres;
double yres;
QString colorspacename;
const KoColorSpace * cs;
if ((attr = element.attribute(MIME)) == NATIVE_MIMETYPE) {
if ((m_d->imageName = element.attribute(NAME)).isNull()) {
m_d->errorMessages << i18n("Image does not have a name.");
return KisImageWSP(0);
}
if ((attr = element.attribute(WIDTH)).isNull()) {
m_d->errorMessages << i18n("Image does not specify a width.");
return KisImageWSP(0);
}
width = attr.toInt();
if ((attr = element.attribute(HEIGHT)).isNull()) {
m_d->errorMessages << i18n("Image does not specify a height.");
return KisImageWSP(0);
}
height = attr.toInt();
m_d->imageComment = element.attribute(DESCRIPTION);
xres = 100.0 / 72.0;
if (!(attr = element.attribute(X_RESOLUTION)).isNull()) {
if (attr.toDouble() > 1.0) {
xres = attr.toDouble() / 72.0;
}
}
yres = 100.0 / 72.0;
if (!(attr = element.attribute(Y_RESOLUTION)).isNull()) {
if (attr.toDouble() > 1.0) {
yres = attr.toDouble() / 72.0;
}
}
if ((colorspacename = element.attribute(COLORSPACE_NAME)).isNull()) {
// An old file: take a reasonable default.
// Krita didn't support anything else in those
// days anyway.
colorspacename = "RGBA";
}
profileProductName = element.attribute(PROFILE);
// A hack for an old colorspacename
convertColorSpaceNames(colorspacename, profileProductName);
QString colorspaceModel = KoColorSpaceRegistry::instance()->colorSpaceColorModelId(colorspacename).id();
QString colorspaceDepth = KoColorSpaceRegistry::instance()->colorSpaceColorDepthId(colorspacename).id();
if (profileProductName.isNull()) {
// no mention of profile so get default profile";
cs = KoColorSpaceRegistry::instance()->colorSpace(colorspaceModel, colorspaceDepth, "");
} else {
cs = KoColorSpaceRegistry::instance()->colorSpace(colorspaceModel, colorspaceDepth, profileProductName);
}
if (cs == 0) {
// try once more without the profile
cs = KoColorSpaceRegistry::instance()->colorSpace(colorspaceModel, colorspaceDepth, "");
if (cs == 0) {
m_d->errorMessages << i18n("Image specifies an unsupported color model: %1.", colorspacename);
return KisImageWSP(0);
}
}
if (m_d->document) {
image = new KisImage(m_d->document->createUndoStore(), width, height, cs, name);
}
else {
image = new KisImage(0, width, height, cs, name);
}
image->setResolution(xres, yres);
loadNodes(element, image, const_cast<KisGroupLayer*>(image->rootLayer().data()));
KoXmlNode child;
for (child = element.lastChild(); !child.isNull(); child = child.previousSibling()) {
KoXmlElement e = child.toElement();
if(e.tagName() == "ProjectionBackgroundColor") {
if (e.hasAttribute("ColorData")) {
QByteArray colorData = QByteArray::fromBase64(e.attribute("ColorData").toLatin1());
KoColor color((const quint8*)colorData.data(), image->colorSpace());
image->setDefaultProjectionColor(color);
}
}
if (e.tagName().toLower() == "animation") {
//.........这里部分代码省略.........
示例2: loadOdf
bool KarbonPart::loadOdf(KoOdfReadStore & odfStore)
{
kDebug(38000) << "Start loading OASIS document..." /*<< doc.toString()*/;
KoXmlElement contents = odfStore.contentDoc().documentElement();
kDebug(38000) << "Start loading OASIS document..." << contents.text();
kDebug(38000) << "Start loading OASIS contents..." << contents.lastChild().localName();
kDebug(38000) << "Start loading OASIS contents..." << contents.lastChild().namespaceURI();
kDebug(38000) << "Start loading OASIS contents..." << contents.lastChild().isElement();
KoXmlElement body(KoXml::namedItemNS(contents, KoXmlNS::office, "body"));
if (body.isNull()) {
kDebug(38000) << "No office:body found!";
setErrorMessage(i18n("Invalid OASIS document. No office:body tag found."));
return false;
}
body = KoXml::namedItemNS(body, KoXmlNS::office, "drawing");
if (body.isNull()) {
kDebug(38000) << "No office:drawing found!";
setErrorMessage(i18n("Invalid OASIS document. No office:drawing tag found."));
return false;
}
KoXmlElement page(KoXml::namedItemNS(body, KoXmlNS::draw, "page"));
if (page.isNull()) {
kDebug(38000) << "No office:drawing found!";
setErrorMessage(i18n("Invalid OASIS document. No draw:page tag found."));
return false;
}
KoXmlElement * master = 0;
if (odfStore.styles().masterPages().contains("Standard"))
master = odfStore.styles().masterPages().value("Standard");
else if (odfStore.styles().masterPages().contains("Default"))
master = odfStore.styles().masterPages().value("Default");
else if (! odfStore.styles().masterPages().empty())
master = odfStore.styles().masterPages().begin().value();
if (master) {
const QString pageStyleName = master->attributeNS(KoXmlNS::style, "page-layout-name", QString());
const KoXmlElement *style = odfStore.styles().findStyle(pageStyleName);
if (style) {
KoPageLayout layout;
layout.loadOdf(*style);
setPageLayout(layout);
}
} else {
kWarning() << "No master page found!";
return false;
}
KoOdfLoadingContext context(odfStore.styles(), odfStore.store());
KoShapeLoadingContext shapeContext(context, resourceManager());
d->document.loadOasis(page, shapeContext);
if (d->document.pageSize().isEmpty()) {
QSizeF pageSize = d->document.contentRect().united(QRectF(0, 0, 1, 1)).size();
setPageSize(pageSize);
}
loadOasisSettings(odfStore.settingsDoc());
return true;
}