예제 #1
0
void GwfStreamWriter::writeContour(SCgObject *obj)
{
    writeStartElement("contour");
    writeObjectAttributes(obj);
    SCgContour* contour = static_cast<SCgContour*>(obj);

    QVector<QPointF> points(contour->scenePoints());
    writePoints(points);

    writeEndElement();
}
예제 #2
0
void GwfStreamWriter::writePoints(const QVector<QPointF>& points)
{
    writeStartElement("points");

    foreach(const QPointF& point,points)
    {
        writeStartElement("point");
        writeAttribute("x", QString::number(point.x()));
        writeAttribute("y", QString::number(point.y()));
        writeEndElement();
    }
예제 #3
0
void QhpWriter::writeCustomFilters()
{
    if (!m_customFilters.count())
        return;

    foreach (const CustomFilter &f, m_customFilters) {
        writeStartElement(QLatin1String("customFilter"));
        writeAttribute(QLatin1String("name"), f.name);
        foreach (const QString &a, f.filterAttributes)
            writeTextElement(QLatin1String("filterAttribute"), a);
        writeEndElement();
    }
예제 #4
0
QString QxXmlWriter::writeBinaryData(const QString & qualifiedName, QxXmlWriter::type_byte_arr_ptr pData)
{
   QString sKey(getNextKeyBinaryData());
   m_mapBinaryData.insert(sKey, pData);

   writeStartElement(qualifiedName);
   writeAttribute(QX_XML_ATTRIBUTE_IS_BINARY_DATA, "1");
   writeCharacters(sKey);
   writeEndElement();

   return sKey;
}
예제 #5
0
파일: xbelwriter.cpp 프로젝트: Fale/qtmoko
//! [2]
void XbelWriter::writeItem(QTreeWidgetItem *item)
{
    QString tagName = item->data(0, Qt::UserRole).toString();
    if (tagName == "folder") {
        bool folded = !treeWidget->isItemExpanded(item);
        writeStartElement(tagName);
        writeAttribute("folded", folded ? "yes" : "no");
        writeTextElement("title", item->text(0));
        for (int i = 0; i < item->childCount(); ++i)
            writeItem(item->child(i));
        writeEndElement();
    } else if (tagName == "bookmark") {
        writeStartElement(tagName);
        if (!item->text(1).isEmpty())
            writeAttribute("href", item->text(1));
        writeTextElement("title", item->text(0));
        writeEndElement();
    } else if (tagName == "separator") {
        writeEmptyElement(tagName);
    }
}
예제 #6
0
void GwfStreamWriter::writeNode( SCgObject *obj)
{
    writeStartElement("node");
    writeObjectAttributes(obj);
    writePosition(obj, "x", "y");

    SCgNode *node = static_cast<SCgNode*>(obj);

    writeAttribute("haveBus", node->bus() ? "true" : "false");

    writeContent(node);

    writeEndElement();//node
}
//! [1]
def writeFile(self, device):
    self.setDevice(device)

    self.writeStartDocument()
    self.writeDTD("<!DOCTYPE xbel>")
    self.writeStartElement("xbel")
    self.writeAttribute("version", "1.0")
    for i in range(0, self.treeWidget.topLevelItemCount()):
        self.writeItem(self.treeWidget.topLevelItem(i))

    self.writeEndDocument()
    return True;
//! [1]

//! [2]
void XbelWriter::writeItem(QTreeWidgetItem *item)
{
    QString tagName = item->data(0, Qt::UserRole).toString();
    if (tagName == "folder") {
        bool folded = !treeWidget->isItemExpanded(item);
        writeStartElement(tagName);
        writeAttribute("folded", folded ? "yes" : "no");
        writeTextElement("title", item->text(0));
        for (int i = 0; i < item->childCount(); ++i)
            writeItem(item->child(i));
        writeEndElement();
    } else if (tagName == "bookmark") {
        writeStartElement(tagName);
        if (!item->text(1).isEmpty())
            writeAttribute("href", item->text(1));
        writeTextElement("title", item->text(0));
        writeEndElement();
    } else if (tagName == "separator") {
        writeEmptyElement(tagName);
    }
}
예제 #8
0
void XMLWriter::endElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname)
{
	if (_depth < 1)
		throw XMLException("No unclosed tag");

	if (!_elementStack.back().equalsWeakly(qname, namespaceURI, localName))
		throw XMLException("End tag does not match start tag", nameToString(localName, qname));

	_elementStack.pop_back();
	--_depth;
	if (!_unclosedStartTag) prettyPrint();
	writeEndElement(namespaceURI, localName, qname);
	_contentWritten = false;
	if (_depth == 0)
		writeNewLine();
}
void CModelWriterNode100_Model::writeColors()
{
    nfUint32 nCount = m_pColorMapping->getCount();
    nfUint32 nIndex;
    if (nCount > 0) {
        writeStartElementWithPrefix(XML_3MF_ELEMENT_COLORGROUP, XML_3MF_NAMESPACEPREFIX_MATERIAL);
        writeIntAttribute(XML_3MF_ATTRIBUTE_COLORS_ID, m_pColorMapping->getResourceID());
        for (nIndex = 0; nIndex < nCount; nIndex++) {
            nfColor cColor = m_pColorMapping->getColor(nIndex);
            writeStartElementWithPrefix(XML_3MF_ELEMENT_COLOR, XML_3MF_NAMESPACEPREFIX_MATERIAL);
            writeStringAttribute(XML_3MF_ATTRIBUTE_COLORS_COLOR, fnColorToWString(cColor));
            writeEndElement();
        }

        writeFullEndElement();
    }
}
void CModelWriterNode100_Model::writeMetaData()
{
    nfUint32 nMetaDataCount = m_pModel->getMetaDataCount();
    nfUint32 nMetaDataIndex;

    for (nMetaDataIndex = 0; nMetaDataIndex < nMetaDataCount; nMetaDataIndex++) {
        std::wstring sKey;
        std::wstring sValue;
        m_pModel->getMetaData(nMetaDataIndex, sKey, sValue);

        writeStartElement(XML_3MF_ELEMENT_METADATA);
        writeStringAttribute(XML_3MF_ATTRIBUTE_METADATA_NAME, sKey);
        writeText(sValue.c_str(), (nfUint32)sValue.length());
        writeEndElement();
    }

}
void CModelWriterNode100_Model::writeBuild()
{
    writeStartElement(XML_3MF_ELEMENT_BUILD);
    nfUint32 nCount = m_pModel->getBuildItemCount();
    nfUint32 nIndex;

    for (nIndex = 0; nIndex < nCount; nIndex++) {
        PModelBuildItem pBuildItem = m_pModel->getBuildItem(nIndex);

        writeStartElement(XML_3MF_ELEMENT_ITEM);
        writeIntAttribute(XML_3MF_ATTRIBUTE_ITEM_OBJECTID, pBuildItem->getObjectID());
        if (pBuildItem->hasTransform())
            writeStringAttribute(XML_3MF_ATTRIBUTE_ITEM_TRANSFORM, pBuildItem->getTransformString());
        writeEndElement();
    }

    writeFullEndElement();
}
void CModelWriterNode100_Model::writeComponentsObject(_In_ CModelComponentsObject * pComponentsObject)
{
    __NMRASSERT(pComponentsObject);

    nfUint32 nIndex;
    nfUint32 nCount = pComponentsObject->getComponentCount();

    writeStartElement(XML_3MF_ELEMENT_COMPONENTS);
    for (nIndex = 0; nIndex < nCount; nIndex++) {
        PModelComponent pComponent = pComponentsObject->getComponent(nIndex);
        writeStartElement(XML_3MF_ELEMENT_COMPONENT);
        writeIntAttribute(XML_3MF_ATTRIBUTE_COMPONENT_OBJECTID, pComponent->getObjectID());
        if (pComponent->hasTransform())
            writeStringAttribute(XML_3MF_ATTRIBUTE_COMPONENT_TRANSFORM, pComponent->getTransformString());
        writeEndElement();
    }

    writeFullEndElement();
}
예제 #13
0
void GwfStreamWriter::writeBus(SCgObject *obj)
{
    writeStartElement("bus");
    writeObjectAttributes(obj);
    SCgBus* bus = static_cast<SCgBus*>(obj);

    writeAttribute("owner", QString::number(bus->owner()->id()));

    QVector<QPointF> points = bus->scenePoints();
    writeAttribute("b_x", QString::number(points.first().x()));
    writeAttribute("b_y", QString::number(points.first().y()));
    writeAttribute("e_x", QString::number(points.last().x()));
    writeAttribute("e_y", QString::number(points.last().y()));

    // do not save begin and end points
    points.pop_back();
    points.pop_front();
    writePoints(points);

    writeEndElement();
}
예제 #14
0
void GeoWriter::writeElement( const QString &key, const QString &value )
{
    writeStartElement( key );
    writeCharacters( value );
    writeEndElement();
}
예제 #15
0
void OpenSearchWriter::write(OpenSearchEngine *engine)
{
    writeStartDocument();
    writeStartElement(QL1S("OpenSearchDescription"));
    writeDefaultNamespace(QL1S("http://a9.com/-/spec/opensearch/1.1/"));

    if (!engine->name().isEmpty())
    {
        writeTextElement(QL1S("ShortName"), engine->name());
    }

    if (!engine->description().isEmpty())
    {
        writeTextElement(QL1S("Description"), engine->description());
    }

    if (!engine->searchUrlTemplate().isEmpty())
    {
        writeStartElement(QL1S("Url"));
        writeAttribute(QL1S("method"), QL1S("get"));
        writeAttribute(QL1S("template"), engine->searchUrlTemplate());

        if (!engine->searchParameters().empty())
        {
            writeNamespace(QL1S("http://a9.com/-/spec/opensearch/extensions/parameters/1.0/"), QL1S("p"));

            QList<OpenSearchEngine::Parameter>::const_iterator end = engine->searchParameters().constEnd();
            QList<OpenSearchEngine::Parameter>::const_iterator i = engine->searchParameters().constBegin();
            for (; i != end; ++i)
            {
                writeStartElement(QL1S("p:Parameter"));
                writeAttribute(QL1S("name"), i->first);
                writeAttribute(QL1S("value"), i->second);
                writeEndElement();
            }
        }

        writeEndElement();
    }

    if (!engine->suggestionsUrlTemplate().isEmpty())
    {
        writeStartElement(QL1S("Url"));
        writeAttribute(QL1S("method"), QL1S("get"));
        writeAttribute(QL1S("type"), engine->type());
        writeAttribute(QL1S("template"), engine->suggestionsUrlTemplate());

        if (!engine->suggestionsParameters().empty())
        {
            writeNamespace(QL1S("http://a9.com/-/spec/opensearch/extensions/parameters/1.0/"), QL1S("p"));

            QList<OpenSearchEngine::Parameter>::const_iterator end = engine->suggestionsParameters().constEnd();
            QList<OpenSearchEngine::Parameter>::const_iterator i = engine->suggestionsParameters().constBegin();
            for (; i != end; ++i)
            {
                writeStartElement(QL1S("p:Parameter"));
                writeAttribute(QL1S("name"), i->first);
                writeAttribute(QL1S("value"), i->second);
                writeEndElement();
            }
        }

        writeEndElement();
    }

    if (!engine->imageUrl().isEmpty())
        writeTextElement(QL1S("Image"), engine->imageUrl());

    writeEndElement();
    writeEndDocument();
}