Esempio n. 1
1
bool KisOpenRasterStackSaveVisitor::visit(KisGroupLayer *layer)
{
    QDomElement* previousElt = d->currentElement;

    QDomElement elt = d->layerStack.createElement("stack");
    d->currentElement = &elt;
    saveLayerInfo(elt, layer);

    visitAll(layer);

    if (previousElt) {
        previousElt->appendChild(elt);
        d->currentElement = previousElt;
    } else {
        QDomElement imageElt = d->layerStack.createElement("image");
        int width = layer->image()->width();
        int height = layer->image()->height();
        imageElt.setAttribute("w", width);
        imageElt.setAttribute("h", height);
        imageElt.appendChild(elt);
        d->layerStack.insertBefore(imageElt, QDomNode());
        d->currentElement = 0;
        d->saveContext->saveStack(d->layerStack);
    }

    return true;
}
Esempio n. 2
0
QDomNode KGameSvgDocumentPrivate::findElementById(const QString& attributeName, const QString& attributeValue, const QDomNode& node)
{
    QDomElement e = node.toElement(); // try to convert the node to an element.
    QString value = e.attribute( attributeName, QLatin1String( "Element has no attribute with that name." ));

    if (value == attributeValue)
    {
        // We found our node.  Stop recursion and return it.
        return node;
    }

    if (!node.firstChild().isNull())
    {
        QDomNode result = findElementById(attributeName, attributeValue, node.firstChild());
        /** We have recursed, now we need to have this recursion end when
         * the function call above returns
         */
        if (!result.isNull()) return result; // If we found the node with id, then return it
    }
    if (!node.nextSibling().isNull())
    {
        QDomNode result = findElementById(attributeName, attributeValue, node.nextSibling());
        /** We have recursed, now we need to have this recursion end when
         * the function call above returns */
        if (!result.isNull()) return result;
    }
    if (!node.firstChild().isNull() && !node.nextSibling().isNull())
    {
        // Do Nothing
        //kDebug(11000) << "No children or siblings.";
    }

    // Matching node not found, so return a null node.
    return QDomNode();
}
Esempio n. 3
0
QDomNode QDomDocumentProto::insertBefore(const QDomNode& newChild, const QDomNode& refChild)
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->insertBefore(newChild, refChild);
    return QDomNode();
}
QDomNode QDomNamedNodeMapProto:: item(int index) const
{
  QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject());
  if (item)
    return item->item(index);
  return QDomNode();
}
Esempio n. 5
0
QDomNode findChild( QDomNode &parent, const QString &name )
{
  for ( QDomNode n = parent.firstChild(); !n.isNull(); n = n.nextSibling() )
    if ( n.nodeName() == name )
         return n;
  return QDomNode();
}
Esempio n. 6
0
QDomNode QDomNodeProto:: removeChild(const QDomNode& oldChild)
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->removeChild(oldChild);
  return QDomNode();
}
Esempio n. 7
0
QDomNode QDomNodeProto:: appendChild(const QDomNode& newChild)
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->appendChild(newChild);
  return QDomNode();
}
Esempio n. 8
0
QDomNode QDomNodeProto:: parentNode() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->parentNode();
  return QDomNode();
}
Esempio n. 9
0
QDomNode QDomNodeProto:: nextSibling() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->nextSibling();
  return QDomNode();
}
Esempio n. 10
0
QDomNode QDomNodeProto:: insertAfter(const QDomNode& newChild, const QDomNode& refChild)
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->insertAfter(newChild, refChild);
  return QDomNode();
}
Esempio n. 11
0
QDomNode QDomDocumentProto::importNode(const QDomNode& importedNode, bool deep)
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->importNode(importedNode, deep);
    return QDomNode();
}
Esempio n. 12
0
QDomNode QDomDocumentProto::lastChild() const
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->lastChild();
    return QDomNode();
}
Esempio n. 13
0
QDomNode QDomDocumentProto::cloneNode(bool deep) const
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->cloneNode(deep);
    return QDomNode();
}
QDomNode QDomNamedNodeMapProto:: setNamedItemNS(const QDomNode& newNode)
{
  QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject());
  if (item)
    return item->setNamedItemNS(newNode);
  return QDomNode();
}
Esempio n. 15
0
QDomNode QDomDocumentProto::previousSibling() const
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->previousSibling();
    return QDomNode();
}
Esempio n. 16
0
QDomNode QDomDocumentProto::namedItem(const QString& name) const
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->namedItem(name);
    return QDomNode();
}
QDomNode QDomNamedNodeMapProto:: removeNamedItem(const QString& name)
{
  QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject());
  if (item)
    return item->removeNamedItem(name);
  return QDomNode();
}
QDomNode QDomNamedNodeMapProto:: namedItemNS(const QString& nsURI, const QString& localName) const
{
  QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject());
  if (item)
    return item->namedItemNS(nsURI, localName);
  return QDomNode();
}
Esempio n. 19
0
QDomNode QDomDocumentProto::replaceChild(const QDomNode& newChild, const QDomNode& oldChild)
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->replaceChild(newChild, oldChild);
    return QDomNode();
}
Esempio n. 20
0
QDomNode QDomNodeProto:: firstChild() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->firstChild();
  return QDomNode();
}
Esempio n. 21
0
StyleItem::StyleItem( QDomElement el, QString colors[], QDomElement defs )
{
    QDomElement name = el.firstChildElement("name");
    this->name = name.text();
    QDomElement svg = el.firstChildElement("svg");
    if ( svg.isNull() ) {
        this->renderer = NULL;
    } else {
        if ( !defs.isNull() ) svg.insertBefore( defs, QDomNode() );
        QDomDocument doc;
        doc.setContent( css );
        svg.insertBefore( doc, QDomNode() );
        QTextStream stream(&(this->svg));
        svg.save(stream, 0);
        this->renderer = new QSvgRenderer( this->makeSvg( colors, STYLE_KEY_COLOR ).toAscii() );
    }
}
Esempio n. 22
0
void FLReportViewer::setReportPages(FLReportPages *pgs)
{
  setReportEngine(0);
  qry_ = 0;
  xmlData_ = QDomNode();
  rptViewer_->setReportPages(pgs ? pgs->pageCollection() : 0);
  report = rptViewer_->reportPages();
}
Esempio n. 23
0
bool KisOpenRasterStackSaveVisitor::visit(KisAdjustmentLayer *layer)
{
    QDomElement elt = d->layerStack.createElement("filter");
    saveLayerInfo(elt, layer);
    elt.setAttribute("type", "applications:krita:" + layer->filter()->name());
    saveLayerInfo(elt, layer);
    d->currentElement->insertBefore(elt, QDomNode());
    return true;
}
Esempio n. 24
0
void
vleVpm::onSnapshotVpm(QDomNode /*snapVpm*/, bool isMerged)
{

    if (not isMerged) {
        bool oldBlock = vleVpz::undoStack->blockSignals(true);
        vleVpz::undoStack->snapshot(QDomNode());
        vleVpz::undoStack->blockSignals(oldBlock);
    }
}
Esempio n. 25
0
/*!
 * \brief TLMEditor::createAnnotationElement
 * Creates an Annotation tag for SubModel.
 * \param subModel
 * \param visible
 * \param origin
 * \param extent
 * \param rotation
 */
void TLMEditor::createAnnotationElement(QDomElement subModel, QString visible, QString origin, QString extent, QString rotation)
{
  QDomElement annotation = mXmlDocument.createElement("Annotation");
  annotation.setAttribute("Visible", visible);
  annotation.setAttribute("Origin", origin);
  annotation.setAttribute("Extent", extent);
  annotation.setAttribute("Rotation", rotation);
  subModel.insertBefore(annotation, QDomNode());
  mpPlainTextEdit->setPlainText(mXmlDocument.toString());
}
Esempio n. 26
0
bool KisOpenRasterStackSaveVisitor::visit(KisPaintLayer *layer)
{
    QString filename = d->saveContext->saveDeviceData(layer);

    QDomElement elt = d->layerStack.createElement("layer");
    saveLayerInfo(elt, layer);
    elt.setAttribute("src", filename);
    d->currentElement->insertBefore(elt, QDomNode());

    return true;
}
Esempio n. 27
0
QDomNode arnConfig::_findkeyonchildren(const QDomNode &cur,const char *key)
{
    if (cur.isNull()) return QDomNode();

    QString keyName(key);
    QDomNode res;

    for (QDomNode chld = cur.firstChild();
	 !chld.isNull();
	 chld = chld.nextSibling()) {
	
	if (keyName == chld.nodeName())
	    return chld;

	if (!(res = _findkeyonchildren (chld, key)).isNull())
	    return res;
    }
    
    return QDomNode();  // not found
}
Esempio n. 28
0
// Return the node as a QDomElement iff it is a QDomElement with
// a `value' attribute; otherwise return a null element.
QDomElement PDFOptionsIO::getValueElement(QDomNode& node, QString name, bool isValue)
{
	if (node.isNull())
	{
		m_error = QObject::tr("Unable to read settings XML:")
			.arg(QObject::tr("unexpected null <%2> node", "Load PDF settings")
				.arg(name)
			);
		return QDomNode().toElement();
	}
	if (!node.isElement())
	{
		m_error = QObject::tr("Unable to read settings XML:")
			.arg(QObject::tr("node <%1> not an element", "Load PDF settings")
				.arg(name)
			);
		return QDomNode().toElement();
	}
	QDomElement elem = node.toElement();
	if (elem.tagName() != name)
	{
		m_error = QObject::tr("Unable to read settings XML:")
			.arg(QString("Internal error: element named <%1> not expected <%2>")
					.arg(elem.tagName()).arg(name)
			);
		return QDomNode().toElement();
	}
	if (isValue)
	{
		// We need to check that it has a `value' attribute
		if (!elem.hasAttribute("value"))
		{
			m_error = QObject::tr("Unable to read settings XML:")
				.arg(QObject::tr("element <%1> lacks `value' attribute", "Load PDF settings")
					.arg(name)
				);
			return QDomNode().toElement();
		}
	}
	return elem;
}
Esempio n. 29
0
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// ---- Utility functions
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
QDomNode getChildByName( QDomNode parent, QString nodeName )
{
    QDomNodeList nodes = parent.childNodes();
    for( int index = 0; index < nodes.count(); ++index )
    {
        QDomNode node = nodes.at( index );
        if( nodeName == node.toElement().tagName() )
            return node;
    }

    return QDomNode();
}
Esempio n. 30
0
QDomNode getNodeFromKeyName( QDomDocument domDocument, QString keyName )
{
    // pointing the parent node to be the root of the DOM document
    QDomNode node = domDocument.documentElement();

    QStringList listOfNodeNames = keyName.split( "/" );
    foreach( QString nodeName, listOfNodeNames )
    {
        node = getChildByName( node, nodeName );
        if( node.isNull() )
            return QDomNode();
    }