bool GlyphElement::readMathMLAttributes( const KoXmlElement& element ) { // MathML Section 3.2.9.2 m_fontFamily = element.attribute( "fontfamily" ); if ( m_fontFamily.isNull() ) { kWarning( DEBUGID ) << "Required attribute fontfamily not found in glyph element\n"; return false; } QString indexStr = element.attribute( "index" ); if ( indexStr.isNull() ) { kWarning( DEBUGID ) << "Required attribute index not found in glyph element\n"; return false; } bool ok; ushort index = indexStr.toUShort( &ok ); if ( ! ok ) { kWarning( DEBUGID ) << "Invalid index value in glyph element\n"; return false; } m_char = QChar( index ); m_alt = element.attribute( "alt" ); if ( m_alt.isNull() ) { kWarning( DEBUGID ) << "Required attribute alt not found in glyph element\n"; return false; } // TODO: Check whether we have needed fontfamily return true; }
bool GanttViewBase::loadContext( const KoXmlElement &settings ) { KGantt::DateTimeGrid *g = static_cast<KGantt::DateTimeGrid*>( grid() ); g->setScale( static_cast<KGantt::DateTimeGrid::Scale>( settings.attribute( "chart-scale", "0" ).toInt() ) ); g->setDayWidth( settings.attribute( "chart-daywidth", "30" ).toDouble() ); return true; }
bool MorphologyEffect::load(const KoXmlElement &element, const KoFilterEffectLoadingContext &context) { if (element.tagName() != id()) return false; m_radius = QPointF(); m_operator = Erode; if (element.hasAttribute("radius")) { QString radiusStr = element.attribute("radius").trimmed(); QStringList params = radiusStr.replace(',', ' ').simplified().split(' '); switch (params.count()) { case 1: m_radius.rx() = params[0].toDouble()*72./90.; m_radius.ry() = m_radius.x(); break; case 2: m_radius.rx() = params[0].toDouble()*72./90.; m_radius.ry() = params[1].toDouble()*72./90.; break; default: m_radius = QPointF(); } } m_radius = context.convertFilterPrimitiveUnits(m_radius); if (element.hasAttribute("operator")) { QString op = element.attribute("operator"); if (op == "dilate") m_operator = Dilate; } return true; }
SvgStyles SvgStyleParser::collectStyles(const KoXmlElement &e) { SvgStyles styleMap; // collect individual presentation style attributes which have the priority 0 foreach(const QString &command, d->styleAttributes) { const QString attribute = e.attribute(command); if (!attribute.isEmpty()) styleMap[command] = attribute; } foreach(const QString & command, d->fontAttributes) { const QString attribute = e.attribute(command); if (!attribute.isEmpty()) styleMap[command] = attribute; } // match css style rules to element QStringList cssStyles = d->context.matchingStyles(e); // collect all css style attributes foreach(const QString &style, cssStyles) { QStringList substyles = style.split(';', QString::SkipEmptyParts); if (!substyles.count()) continue; for (QStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) { QStringList substyle = it->split(':'); if (substyle.count() != 2) continue; QString command = substyle[0].trimmed(); QString params = substyle[1].trimmed(); // only use style and font attributes if (d->styleAttributes.contains(command) || d->fontAttributes.contains(command)) styleMap[command] = params; } }
bool RectangleShape::loadSvg(const KoXmlElement &element, SvgLoadingContext &context) { const qreal x = SvgUtil::parseUnitX(context.currentGC(), element.attribute("x")); const qreal y = SvgUtil::parseUnitY(context.currentGC(), element.attribute("y")); const qreal w = SvgUtil::parseUnitX(context.currentGC(), element.attribute("width")); const qreal h = SvgUtil::parseUnitY(context.currentGC(), element.attribute("height")); const QString rxStr = element.attribute("rx"); const QString ryStr = element.attribute("ry"); qreal rx = rxStr.isEmpty() ? 0.0 : SvgUtil::parseUnitX(context.currentGC(), rxStr); qreal ry = ryStr.isEmpty() ? 0.0 : SvgUtil::parseUnitY(context.currentGC(), ryStr); // if one radius is given but not the other, use the same value for both if (!rxStr.isEmpty() && ryStr.isEmpty()) ry = rx; if (rxStr.isEmpty() && !ryStr.isEmpty()) rx = ry; setSize(QSizeF(w, h)); setPosition(QPointF(x, y)); if (rx >= 0.0) setCornerRadiusX(qMin(qreal(100.0), qreal(rx / (0.5 * w) * 100.0))); if (ry >= 0.0) setCornerRadiusY(qMin(qreal(100.0), qreal(ry / (0.5 * h) * 100.0))); if (w == 0.0 || h == 0.0) setVisible(false); return true; }
void KisKraLoader::loadCompositions(const KoXmlElement& elem, KisImageWSP image) { KoXmlNode child; for (child = elem.firstChild(); !child.isNull(); child = child.nextSibling()) { KoXmlElement e = child.toElement(); QString name = e.attribute("name"); bool exportEnabled = e.attribute("exportEnabled", "1") == "0" ? false : true; KisLayerComposition* composition = new KisLayerComposition(image, name); composition->setExportEnabled(exportEnabled); KoXmlNode value; for (value = child.lastChild(); !value.isNull(); value = value.previousSibling()) { KoXmlElement e = value.toElement(); QUuid uuid(e.attribute("uuid")); bool visible = e.attribute("visible", "1") == "0" ? false : true; composition->setVisible(uuid, visible); bool collapsed = e.attribute("collapsed", "1") == "0" ? false : true; composition->setCollapsed(uuid, collapsed); } image->addComposition(composition); } }
bool SvgParser::parseClipPath(const KoXmlElement &e, const KoXmlElement &referencedBy) { SvgClipPathHelper clipPath; // Use the filter that is referencing, or if there isn't one, the original filter KoXmlElement b; if (!referencedBy.isNull()) b = referencedBy; else b = e; // check if we are referencing another clip path if (e.hasAttribute("xlink:href")) { QString href = e.attribute("xlink:href").mid(1); if (! href.isEmpty()) { // copy the referenced clip path if found SvgClipPathHelper *refClipPath = findClipPath(href); if (refClipPath) clipPath = *refClipPath; } } else { clipPath.setContent(b); } if (b.attribute("clipPathUnits") == "objectBoundingBox") clipPath.setClipPathUnits(SvgClipPathHelper::ObjectBoundingBox); m_clipPaths.insert(b.attribute("id"), clipPath); return true; }
KisNodeSP KisKraLoader::loadFileLayer(const KoXmlElement& element, KisImageWSP image, const QString& name, quint32 opacity) { QString filename = element.attribute("source", QString()); if (filename.isNull()) return 0; bool scale = (element.attribute("scale", "true") == "true"); int scalingMethod = element.attribute("scalingmethod", "-1").toInt(); if (scalingMethod < 0) { if (scale) { scalingMethod = KisFileLayer::ToImagePPI; } else { scalingMethod = KisFileLayer::None; } } QString documentPath; if (m_d->document) { documentPath = m_d->document->url().toLocalFile(); } QFileInfo info(documentPath); QString basePath = info.absolutePath(); QString fullPath = basePath + QDir::separator() + filename; // Entering the event loop to show the messagebox will delete the image, so up the ref by one image->ref(); if (!QFileInfo(fullPath).exists()) { qApp->setOverrideCursor(Qt::ArrowCursor); QString msg = i18nc( "@info", "The file associated to a file layer with the name \"%1\" is not found.<nl/><nl/>" "Expected path:<nl/>" "%2<nl/><nl/>" "Do you want to locate it manually?", name, fullPath); int result = QMessageBox::warning(0, i18nc("@title:window", "File not found"), msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if (result == QMessageBox::Yes) { KoFileDialog dialog(0, KoFileDialog::OpenFile, "OpenDocument"); dialog.setMimeTypeFilters(KisImportExportManager::mimeFilter("application/x-krita", KisImportExportManager::Import)); dialog.setDefaultDir(basePath); QString url = dialog.filename(); if (!QFileInfo(basePath).exists()) { filename = url; } else { QDir d(basePath); filename = d.relativeFilePath(url); } } qApp->restoreOverrideCursor(); } KisLayer *layer = new KisFileLayer(image, basePath, filename, (KisFileLayer::ScalingMethod)scalingMethod, name, opacity); Q_CHECK_PTR(layer); return layer; }
bool Document::load( KoXmlElement &element, XMLLoaderObject &status ) { m_url = KUrl( element.attribute( "url" ) ); m_type = ( Type )( element.attribute( "type" ).toInt() ); m_status = element.attribute( "status" ); m_sendAs = ( SendAs )( element.attribute( "sendas" ).toInt() ); return true; }
KoFilterEffectStack * FilterEffectResource::toFilterStack() const { KoFilterEffectStack * filterStack = new KoFilterEffectStack(); if (!filterStack) return 0; QByteArray data = m_data.toByteArray(); KoXmlDocument doc; doc.setContent(data); KoXmlElement e = doc.documentElement(); // only allow obect bounding box units if (e.hasAttribute("filterUnits") && e.attribute("filterUnits") != "objectBoundingBox") return 0; if (e.attribute("primitiveUnits") != "objectBoundingBox") return 0; // parse filter region rectangle QRectF filterRegion; filterRegion.setX(fromPercentage(e.attribute("x", "-0.1"))); filterRegion.setY(fromPercentage(e.attribute("y", "-0.1"))); filterRegion.setWidth(fromPercentage(e.attribute("width", "1.2"))); filterRegion.setHeight(fromPercentage(e.attribute("height", "1.2"))); filterStack->setClipRect(filterRegion); KoFilterEffectLoadingContext context(QString("")); KoFilterEffectRegistry * registry = KoFilterEffectRegistry::instance(); // create the filter effects and add them to the shape for (KoXmlNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) { KoXmlElement primitive = n.toElement(); KoFilterEffect * filterEffect = registry->createFilterEffectFromXml(primitive, context); if (!filterEffect) { qWarning() << "filter effect" << primitive.tagName() << "is not implemented yet"; continue; } // parse subregion qreal x = fromPercentage(primitive.attribute("x", "0")); qreal y = fromPercentage(primitive.attribute("y", "0")); qreal w = fromPercentage(primitive.attribute("width", "1")); qreal h = fromPercentage(primitive.attribute("height", "1")); QRectF subRegion(QPointF(x, y), QSizeF(w, h)); if (primitive.hasAttribute("in")) filterEffect->setInput(0, primitive.attribute("in")); if (primitive.hasAttribute("result")) filterEffect->setOutput(primitive.attribute("result")); filterEffect->setFilterRect(subRegion); filterStack->appendFilterEffect(filterEffect); } return filterStack; }
KoScriptingOdfManifestReader::KoScriptingOdfManifestReader(KoScriptingOdfStore *store, const KoXmlDocument &doc) : KoScriptingOdfReader(store, doc) { KoXmlElement elem = doc.documentElement(); KoXmlElement e; forEachElement(e, elem) if (e.tagName() == "manifest:file-entry") m_entries << QPair<QString,QString>(e.attribute("manifest:media-type"), e.attribute("manifest:full-path")); }
bool GanttPrintingOptions::loadContext( const KoXmlElement &settings ) { KoXmlElement e = settings.namedItem( "print-options" ).toElement(); if ( ! e.isNull() ) { printRowLabels = (bool)( e.attribute( "print-rowlabels", "0" ).toInt() ); singlePage = (bool)( e.attribute( "print-singlepage", "0" ).toInt() ); } kDebug()<<"..........."<<printRowLabels<<singlePage; return true; }
void KisKraLoader::loadAssistantsList(const KoXmlElement &elem) { KoXmlNode child; int count = 0; for (child = elem.firstChild(); !child.isNull(); child = child.nextSibling()) { KoXmlElement e = child.toElement(); QString type = e.attribute("type"); QString file_name = e.attribute("filename"); m_d->assistantsFilenames.insert(file_name,type); count++; } }
void SvgStyleParser::parseColorStops(QGradient *gradient, const KoXmlElement &e) { QGradientStops stops; QColor c; for (KoXmlNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) { KoXmlElement stop = n.toElement(); if (stop.tagName() == "stop") { float offset; QString temp = stop.attribute("offset"); if (temp.contains('%')) { temp = temp.left(temp.length() - 1); offset = temp.toFloat() / 100.0; } else offset = temp.toFloat(); QString stopColorStr = stop.attribute("stop-color"); if (!stopColorStr.isEmpty()) { if (stopColorStr == "inherit") { stopColorStr = inheritedAttribute("stop-color", stop); } parseColor(c, stopColorStr); } else { // try style attr QString style = stop.attribute("style").simplified(); QStringList substyles = style.split(';', QString::SkipEmptyParts); for (QStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) { QStringList substyle = it->split(':'); QString command = substyle[0].trimmed(); QString params = substyle[1].trimmed(); if (command == "stop-color") parseColor(c, params); if (command == "stop-opacity") c.setAlphaF(params.toDouble()); } } QString opacityStr = stop.attribute("stop-opacity"); if (!opacityStr.isEmpty()) { if (opacityStr == "inherit") { opacityStr = inheritedAttribute("stop-opacity", stop); } c.setAlphaF(opacityStr.toDouble()); } stops.append(QPair<qreal, QColor>(offset, c)); } } if (stops.count()) gradient->setStops(stops); }
bool WBSDefinition::loadXML(KoXmlElement &element, XMLLoaderObject & ) { m_projectCode = element.attribute( "project-code" ); m_projectSeparator = element.attribute( "project-separator" ); m_levelsEnabled = (bool)element.attribute( "levels-enabled", "0" ).toInt(); KoXmlNode n = element.firstChild(); for ( ; ! n.isNull(); n = n.nextSibling() ) { if ( ! n.isElement() ) { continue; } KoXmlElement e = n.toElement(); if (e.tagName() == "default") { m_defaultDef.code = e.attribute( "code", "Number" ); m_defaultDef.separator = e.attribute( "separator", "." ); } else if (e.tagName() == "levels") { KoXmlNode n = e.firstChild(); for ( ; ! n.isNull(); n = n.nextSibling() ) { if ( ! n.isElement() ) { continue; } KoXmlElement el = n.toElement(); CodeDef d; d.code = el.attribute( "code" ); d.separator = el.attribute( "separator" ); int lvl = el.attribute( "level", "-1" ).toInt(); if ( lvl >= 0 ) { setLevelsDef( lvl, d ); } else kError()<<"Invalid levels definition"; } } } return true; }
/// Parses current character transforms (x,y,dx,dy,rotate) void ArtisticTextLoadingContext::parseCharacterTransforms(const KoXmlElement &element, SvgGraphicsContext *gc) { m_currentAbsolutePosX = parseList(element.attribute("x"), gc, XLength); m_currentAbsolutePosY = parseList(element.attribute("y"), gc, YLength); m_currentRelativePosX = parseList(element.attribute("dx"), gc, XLength); m_currentRelativePosY = parseList(element.attribute("dy"), gc, YLength); m_currentRotations = parseList(element.attribute("rotate"), gc, Number); if (m_textPosition.x() == HUGE_VAL && m_currentAbsolutePosX.data.count()) { m_textPosition.setX(m_currentAbsolutePosX.data.first()); } if (m_textPosition.y() == HUGE_VAL && m_currentAbsolutePosY.data.count()) { m_textPosition.setY(m_currentAbsolutePosY.data.first()); } }
void ComponentTransferEffect::loadChannel(Channel channel, const KoXmlElement &element) { QString typeStr = element.attribute("type"); if (typeStr.isEmpty()) return; Data &d = m_data[channel]; if (typeStr == "table" || typeStr == "discrete") { d.function = typeStr == "table" ? Table : Discrete; QString valueStr = element.attribute("tableValues"); QStringList values = valueStr.split(QRegExp("(\\s+|,)"), QString::SkipEmptyParts); foreach(const QString &v, values) { d.tableValues.append(v.toDouble()); }
bool SvgParser::parseFilter(const KoXmlElement &e, const KoXmlElement &referencedBy) { SvgFilterHelper filter; // Use the filter that is referencing, or if there isn't one, the original filter KoXmlElement b; if (!referencedBy.isNull()) b = referencedBy; else b = e; // check if we are referencing another filter if (e.hasAttribute("xlink:href")) { QString href = e.attribute("xlink:href").mid(1); if (! href.isEmpty()) { // copy the referenced filter if found SvgFilterHelper *refFilter = findFilter(href); if (refFilter) filter = *refFilter; } } else { filter.setContent(b); } if (b.attribute("filterUnits") == "userSpaceOnUse") filter.setFilterUnits(SvgFilterHelper::UserSpaceOnUse); if (b.attribute("primitiveUnits") == "objectBoundingBox") filter.setPrimitiveUnits(SvgFilterHelper::ObjectBoundingBox); // parse filter region rectangle if (filter.filterUnits() == SvgFilterHelper::UserSpaceOnUse) { filter.setPosition(QPointF(parseUnitX(b.attribute("x")), parseUnitY(b.attribute("y")))); filter.setSize(QSizeF(parseUnitX(b.attribute("width")), parseUnitY(b.attribute("height")))); } else { // x, y, width, height are in percentages of the object referencing the filter // so we just parse the percentages filter.setPosition(QPointF(SvgUtil::fromPercentage(b.attribute("x", "-0.1")), SvgUtil::fromPercentage(b.attribute("y", "-0.1")))); filter.setSize(QSizeF(SvgUtil::fromPercentage(b.attribute("width", "1.2")), SvgUtil::fromPercentage(b.attribute("height", "1.2")))); } m_filters.insert(b.attribute("id"), filter); return true; }
KisNodeSP KisKraLoader::loadFilterMask(const KoXmlElement& element, KisNodeSP parent) { Q_UNUSED(parent); QString attr; KisFilterMask* mask; QString filtername; // XXX: should we check the version? if ((filtername = element.attribute(FILTER_NAME)).isNull()) { // XXX: Invalid filter layer! We should warn about it! warnFile << "No filter in filter layer"; return 0; } KisFilterSP f = KisFilterRegistry::instance()->value(filtername); if (!f) { warnFile << "No filter for filtername" << filtername << ""; return 0; // XXX: We don't have this filter. We should warn about it! } KisFilterConfiguration * kfc = f->defaultConfiguration(0); // We'll load the configuration and the selection later. mask = new KisFilterMask(); mask->setFilter(kfc); Q_CHECK_PTR(mask); return mask; }
KisNodeSP KisKraLoader::loadGeneratorLayer(const KoXmlElement& element, KisImageWSP image, const QString& name, const KoColorSpace* cs, quint32 opacity) { Q_UNUSED(cs); // XXX: do something with generator version? KisGeneratorLayer* layer; QString generatorname = element.attribute(GENERATOR_NAME); if (generatorname.isNull()) { // XXX: Invalid generator layer! We should warn about it! warnFile << "No generator in generator layer"; return 0; } KisGeneratorSP generator = KisGeneratorRegistry::instance()->value(generatorname); if (!generator) { warnFile << "No generator for generatorname" << generatorname << ""; return 0; // XXX: We don't have this generator. We should warn about it! } KisFilterConfiguration * kgc = generator->defaultConfiguration(0); // We'll load the configuration and the selection later. layer = new KisGeneratorLayer(image, name, kgc, 0); Q_CHECK_PTR(layer); layer->setOpacity(opacity); return layer; }
KisNodeSP KisKraLoader::loadAdjustmentLayer(const KoXmlElement& element, KisImageWSP image, const QString& name, const KoColorSpace* cs, quint32 opacity) { // XXX: do something with filterversion? Q_UNUSED(cs); QString attr; KisAdjustmentLayer* layer; QString filtername; if ((filtername = element.attribute(FILTER_NAME)).isNull()) { // XXX: Invalid adjustmentlayer! We should warn about it! warnFile << "No filter in adjustment layer"; return 0; } KisFilterSP f = KisFilterRegistry::instance()->value(filtername); if (!f) { warnFile << "No filter for filtername" << filtername << ""; return 0; // XXX: We don't have this filter. We should warn about it! } KisFilterConfiguration * kfc = f->defaultConfiguration(0); // We'll load the configuration and the selection later. layer = new KisAdjustmentLayer(image, name, kfc, 0); Q_CHECK_PTR(layer); layer->setOpacity(opacity); return layer; }
bool PictureShape::loadOdfFrameElement(const KoXmlElement &element, KoShapeLoadingContext &context) { if (m_imageCollection) { const QString href = element.attribute("href"); // this can happen in case it is a presentation:placeholder if (!href.isEmpty()) { KoStore *store = context.odfLoadingContext().store(); KoImageData *data = m_imageCollection->createImageData(href, store); setUserData(data); } else { // check if we have an office:binary data element containing the image data const KoXmlElement &binaryData(KoXml::namedItemNS(element, KoXmlNS::office, "binary-data")); if (!binaryData.isNull()) { QImage image; if (image.loadFromData(QByteArray::fromBase64(binaryData.text().toLatin1()))) { KoImageData *data = m_imageCollection->createImageData(image); setUserData(data); } } } } loadText(element, context); return true; }
bool VectorShapeFactory::supports(const KoXmlElement & e, KoShapeLoadingContext &context) const { if (e.localName() == "image" && e.namespaceURI() == KoXmlNS::draw) { QString href = e.attribute("href"); if (!href.isEmpty()) { // check the mimetype if (href.startsWith(QLatin1String("./"))) { href.remove(0, 2); } // LO 3.5 does not write a mimetype for embedded wmf files, so guess also from content const QString mimetype = context.odfLoadingContext().mimeTypeForPath(href, true); return mimetype == QLatin1String("image/x-svm") || mimetype == QLatin1String("image/x-emf") || mimetype == QLatin1String("image/x-wmf") || // Note: the Vector Shape supports SVG, but _NOT_ in this method, otherwise it will stomp all over loading the artistic text shape's svg //mimetype == QLatin1String("image/svg+xml") || // next three for backward compatibility with Calligra mimetype == QLatin1String("application/x-svm") || mimetype == QLatin1String("application/x-emf") || mimetype == QLatin1String("application/x-wmf") || // seems like MSO does not always write a mimetype // see jeffcoweb.jeffco.k12.co.us%2Fhigh%2Fchatfield%2Fdepartments%2Fbusiness%2Fbanking_finance%2Funit_Plan_Budget.odp mimetype.isEmpty() || // next for compatibility with OO/LO and our filters // see drwho.virtadpt.net%2Ffiles%2FNOVALUG-Tor.odp mimetype.startsWith(QLatin1String("application/x-openoffice")); } return true; } return false; }
bool BlurEffect::load(const KoXmlElement &element, const KoFilterEffectLoadingContext &context) { if (element.tagName() != id()) return false; QString deviationStr = element.attribute("stdDeviation"); QStringList params = deviationStr.replace(',', ' ').simplified().split(' '); switch (params.count()) { case 1: m_deviation.rx() = params[0].toDouble(); m_deviation.ry() = m_deviation.x(); break; case 2: m_deviation.rx() = params[0].toDouble(); m_deviation.ry() = params[1].toDouble(); break; default: return false; } m_deviation = context.convertFilterPrimitiveUnits(m_deviation); return true; }
bool PictureShapeFactory::supports(const KoXmlElement &e, KoShapeLoadingContext &context) const { if (e.localName() == "image" && e.namespaceURI() == KoXmlNS::draw) { QString href = e.attribute("href"); if (!href.isEmpty()) { // check the mimetype if (href.startsWith(QLatin1String("./"))) { href.remove(0, 2); } QString mimetype = context.odfLoadingContext().mimeTypeForPath(href); if (!mimetype.isEmpty()) { return mimetype.startsWith("image"); } else { return ( href.endsWith("bmp") || href.endsWith("jpg") || href.endsWith("gif") || href.endsWith("eps") || href.endsWith("png") || href.endsWith("tif") || href.endsWith("tiff")); } } else { return !KoXml::namedItemNS(e, KoXmlNS::office, "binary-data").isNull(); } } return false; }
int getAttribute(KoXmlElement &element, const char *attributeName, int defaultValue) { QString value = element.attribute(attributeName); if (! value.isEmpty()) return value.toInt(); else return defaultValue; }
bool VideoShapeFactory::supports(const KoXmlElement &e, KoShapeLoadingContext &context) const { Q_UNUSED(context); if (e.localName() != "plugin" || e.namespaceURI() != KoXmlNS::draw) { return false; } return e.attribute("mime-type") == "application/vnd.sun.star.media"; }
QPen Calligra::Sheets::NativeFormat::toPen(KoXmlElement & element) { bool ok; QPen p; p.setStyle((Qt::PenStyle)element.attribute("style").toInt(&ok)); if (!ok) return QPen(); p.setWidth(element.attribute("width").toInt(&ok)); if (!ok) return QPen(); p.setColor(QColor(element.attribute("color"))); return p; }
qreal getAttribute(KoXmlElement &element, const char *attributeName, qreal defaultValue) { QString value = element.attribute(attributeName); if (! value.isEmpty()) return value.toDouble(); else return defaultValue; }
KisNodeSP KisKraLoader::loadSelectionMask(KisImageWSP image, const KoXmlElement& element, KisNodeSP parent) { Q_UNUSED(parent); KisSelectionMaskSP mask = new KisSelectionMask(image); bool active = element.attribute(ACTIVE, "1") == "0" ? false : true; mask->setActive(active); Q_CHECK_PTR(mask); return mask; }