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


C++ KoXmlElement::attribute方法代码示例

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


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

示例1: readMathMLAttributes

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;
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例2: loadContext

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;
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:7,代码来源:kptganttview.cpp

示例3: load

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;
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例4: collectStyles

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;
        }
    }
开发者ID:crayonink,项目名称:calligra-2,代码行数:35,代码来源:SvgStyleParser.cpp

示例5: loadSvg

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;
}
开发者ID:KDE,项目名称:calligra,代码行数:27,代码来源:RectangleShape.cpp

示例6: loadCompositions

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);
    }
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:26,代码来源:kis_kra_loader.cpp

示例7: parseClipPath

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;
}
开发者ID:loveq369,项目名称:calligra,代码行数:32,代码来源:SvgParser.cpp

示例8: loadFileLayer

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;
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:60,代码来源:kis_kra_loader.cpp

示例9: context

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;
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:58,代码来源:FilterEffectResource.cpp

示例10: KoScriptingOdfReader

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"));
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例11: loadAssistantsList

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++;

    }
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:13,代码来源:kis_kra_loader.cpp

示例12: parseColorStops

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);
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:51,代码来源:SvgStyleParser.cpp

示例13: loadXML

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;
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例14: parseCharacterTransforms

/// 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());
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:16,代码来源:ArtisticTextLoadingContext.cpp

示例15: loadChannel

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());
        }
开发者ID:,项目名称:,代码行数:15,代码来源:


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