Пример #1
0
void QhcpWriter::writeAssistantSettings()
{
    if (m_properties.isEmpty())
        return;

    writeStartElement(QLatin1String("assistant"));

    if (m_properties.contains(QLatin1String("title")))
        writeTextElement(QLatin1String("title"), m_properties.value(QLatin1String("title")));
    if (m_properties.contains(QLatin1String("applicationicon")))
        writeTextElement(QLatin1String("applicationIcon"),
            m_properties.value(QLatin1String("applicationicon")));
    if (m_properties.contains(QLatin1String("startpage")))
        writeTextElement(QLatin1String("startPage"), m_titlePath + QLatin1String("/")
            + m_properties.value(QLatin1String("startpage")));
    if (m_properties.contains(QLatin1String("aboutmenutext"))) {
        writeStartElement(QLatin1String("aboutMenuText"));
        writeTextElement(QLatin1String("text"),
            m_properties.value(QLatin1String("aboutmenutext")));
        writeEndElement();
    }
    if (m_properties.contains(QLatin1String("abouturl"))) {
        writeStartElement(QLatin1String("aboutDialog"));
        writeTextElement(QLatin1String("file"), m_properties.value(QLatin1String("abouturl")));
        writeEndElement();
    }
    if (m_properties.contains(QLatin1String("name"))) {
        writeTextElement(QLatin1String("cacheDirectory"),
            QLatin1String(".") + m_properties.value(QLatin1String("name")));
    }

    writeEndElement();
}
void CModelWriterNode100_Model::writeBaseMaterials()
{
    nfUint32 nMaterialCount = m_pModel->getBaseMaterialCount();
    nfUint32 nMaterialIndex;
    nfUint32 j;

    for (nMaterialIndex = 0; nMaterialIndex < nMaterialCount; nMaterialIndex++) {
        CModelBaseMaterialResource * pBaseMaterial = m_pModel->getBaseMaterial(nMaterialIndex);

        writeStartElement(XML_3MF_ELEMENT_BASEMATERIALS);
        // Write Object ID (mandatory)
        writeIntAttribute(XML_3MF_ATTRIBUTE_BASEMATERIALS_ID, pBaseMaterial->getResourceID());

        nfUint32 nElementCount = pBaseMaterial->getCount();

        for (j = 0; j < nElementCount; j++) {
            PModelBaseMaterial pElement = pBaseMaterial->getBaseMaterial(j);
            writeStartElement(XML_3MF_ELEMENT_BASE);
            writeStringAttribute(XML_3MF_ATTRIBUTE_BASEMATERIAL_NAME, pElement->getName());
            writeStringAttribute(XML_3MF_ATTRIBUTE_BASEMATERIAL_DISPLAYCOLOR, pElement->getDisplayColorString());
            writeEndElement();

        }

        writeFullEndElement();
    }

}
Пример #3
0
void GwfStreamWriter::writePair(SCgObject *obj)
{
    QString type = mTypeAlias2GWFType[obj->typeAlias()].mid(0,3);
    if(type=="arc")
        writeStartElement(type);
    else
        writeStartElement("pair");
    writeObjectAttributes(obj);
    SCgPair* pair = static_cast<SCgPair*>(obj);
    SCgObject* b = pair->getBeginObject();
    SCgObject* e = pair->getEndObject();
    writeAttribute("id_b", QString::number(b->id()));
    writeAttribute("id_e", QString::number(e->id()));

    writePosition(b,"b_x","b_y");
    writePosition(e,"e_x","e_y");

    writeAttribute("dotBBalance", QString::number(pair->getBeginDot()));
    writeAttribute("dotEBalance", QString::number(pair->getEndDot()));
    QVector<QPointF> points = pair->scenePoints();
    points.pop_back();
    points.pop_front();
    writePoints(points);
    writeEndElement();
}
Пример #4
0
void XbelWriter::writeItem(const BookmarkNode *parent)
{
    switch (parent->type()) {
    case BookmarkNode::Folder:
        writeStartElement(QLatin1String("folder"));
        writeAttribute(QLatin1String("folded"), parent->expanded ? QLatin1String("no") : QLatin1String("yes"));
        writeTextElement(QLatin1String("title"), parent->title);
        for (int i = 0; i < parent->children().count(); ++i)
            writeItem(parent->children().at(i));
        writeEndElement();
        break;
    case BookmarkNode::Bookmark:
        writeStartElement(QLatin1String("bookmark"));
        if (!parent->url.isEmpty())
            writeAttribute(QLatin1String("href"), parent->url);
        writeTextElement(QLatin1String("title"), parent->title);
        if (!parent->desc.isEmpty())
            writeAttribute(QLatin1String("desc"), parent->desc);
        writeEndElement();
        break;
    case BookmarkNode::Separator:
        writeEmptyElement(QLatin1String("separator"));
        break;
    default:
        break;
    }
}
Пример #5
0
void QhcpWriter::writeDocuments()
{
    if (m_qhpFile.isEmpty())
        return;

    QString out = m_qhpFile;
    int i = out.indexOf(QLatin1Char('.'));
    if (i > -1)
        out = out.left(i);
    out.append(QLatin1String(".qch"));

    writeStartElement(QLatin1String("docFiles"));

    writeStartElement(QLatin1String("generate"));
    writeStartElement(QLatin1String("file"));
    writeTextElement(QLatin1String("input"), m_qhpFile);
    writeTextElement(QLatin1String("output"), out);
    writeEndElement();
    writeEndElement();

    writeStartElement(QLatin1String("register"));
    writeTextElement(QLatin1String("file"), out);
    writeEndElement();

    writeEndElement();
}
Пример #6
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();
    }
Пример #7
0
void GwfStreamWriter::startWriting(const char* encoding)
{
    QTextCodec *codec = QTextCodec::codecForName(encoding);
    setCodec(codec);
    setAutoFormatting(true);
    writeStartDocument();
    writeStartElement("GWF");
    writeAttribute("version", "1.6");
    writeStartElement("staticSector");
    isWritingStarted = true;
}
Пример #8
0
void XmlWrite_Input::Write()
{
    //QHash的迭代器
    QHashIterator<QString, SimData_Input*>HashIterator_SimData_Input(Hash_SimData_Input);
    //用于记录输入变量当前个数,并在<addition>中输出
    int num = 0;

    //自动格式化,让输出的xml文件自动考虑空格等排版因素
    setAutoFormatting(true);
    //写文档头,作用类似于创建一个xml文档,并在文档开头部分写入版本信息和编码信息
    writeStartDocument();

    //遍历所有的仿真输入数据
    while(HashIterator_SimData_Input.hasNext())
    {
        //迭代下一个数据
        HashIterator_SimData_Input.next();
        //指向每个仿真输入数据
        pSimData_Input = HashIterator_SimData_Input.value();

        //写入开始记号
        writeStartElement("Data");

        //写入文本信息记号
        writeTextElement("name", pSimData_Input->getName());
        writeTextElement("des", pSimData_Input->getDes());
        writeTextElement("type", pSimData_Input->getType());
        writeTextElement("init", pSimData_Input->getInit());
        writeTextElement("min", QString::number(pSimData_Input->getMin()));
        writeTextElement("max", QString::number(pSimData_Input->getMax()));
        writeTextElement("enable", QString::number(pSimData_Input->getEnable()));

        writeStartElement("unit");
        writeTextElement("type", pSimData_Input->getUnit_type());
        writeTextElement("std", pSimData_Input->getUnit_std());
        writeTextElement("super", pSimData_Input->getUnit_super());
        writeTextElement("StdtoSuper", QString::number(pSimData_Input->getUnit_StdtoSpuer()));
        //</unit>
        writeEndElement();

        writeStartElement("addition");
        writeTextElement("currentNum", QString::number(num++));
        writeTextElement("memAddress","暂不支持输出内存地址值");
        //</addition>
        writeEndElement();

        //</Data>
        writeEndElement();
    }

    //对应于writeStartDocument(),当调用这个函数时,即表示文档信息写入完毕
    writeEndDocument();
    qDebug()<<"INFO:输出仿真输入数据xml成功!";
}
Пример #9
0
void GwfStreamWriter::writeContent(SCgNode *node)
{
    writeStartElement("content");

    int cType = node->contentType();
    QString mimeType = node->contentMimeType();

    writeAttribute("type",QString::number(cType));
    writeAttribute("mime_type", node->contentMimeType());
    writeAttribute("file_name", node->contentFileName());

    switch(cType)
    {
        case 1:
        case 2:
        case 3:
        {
            writeCDATA((node->contentData()).toString());
            break;
        }
        case 4:
        {
            QByteArray arr = node->contentData().toByteArray().toBase64();
            writeCDATA(arr);
            break;
        }
    }

    writeEndElement();//content
}
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();
}
Пример #12
0
void GwfStreamWriter::writeContour(SCgObject *obj)
{
    writeStartElement("contour");
    writeObjectAttributes(obj);
    SCgContour* contour = static_cast<SCgContour*>(obj);

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

    writeEndElement();
}
Пример #13
0
void XMLWriter::emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes)
{
	if (_depth == 0 && _elementCount > 1)
		throw XMLException("Not well-formed. Second root element found.");

	if (_unclosedStartTag) closeStartTag();
	prettyPrint();
	writeStartElement(namespaceURI, localName, qname, attributes);
	_contentWritten = false;
	writeMarkup("/");
	closeStartTag();
}
Пример #14
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();
    }
Пример #15
0
//! [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);
    }
}
Пример #16
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;
}
Пример #17
0
void XMLWriter::startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes)
{
	if (_depth == 0 && !_inFragment && _elementCount > 1) 
		throw XMLException("Not well-formed. Second root element found", nameToString(localName, qname));
	
	if (_unclosedStartTag) closeStartTag();
	prettyPrint();
	writeStartElement(namespaceURI, localName, qname, attributes);
	_elementStack.push_back(Name(qname, namespaceURI, localName));
	_contentWritten = false;
	++_depth;
}
void CModelWriterNode100_Model::writeResources()
{
    writeStartElement(XML_3MF_ELEMENT_RESOURCES);

    writeBaseMaterials();
    writeTextures2D();
    writeColors();
    writeTex2Coords();
    writeObjects();

    writeFullEndElement();
}
Пример #19
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
}
Пример #20
0
//! [1]
bool XbelWriter::writeFile(QIODevice *device)
{
    setDevice(device);

    writeStartDocument();
    writeDTD("<!DOCTYPE xbel>");
    writeStartElement("xbel");
    writeAttribute("version", "1.0");
    for (int i = 0; i < treeWidget->topLevelItemCount(); ++i)
        writeItem(treeWidget->topLevelItem(i));

    writeEndDocument();
    return true;
}
Пример #21
0
bool QhcpWriter::writeFile(const QString &fileName)
{
    QFile out(fileName);
    if (!out.open(QIODevice::WriteOnly))
        return false;

    setDevice(&out);
    writeStartDocument();
    writeStartElement(QLatin1String("QHelpCollectionProject"));
    writeAttribute(QLatin1String("version"), QLatin1String("1.0"));
    writeAssistantSettings();
    writeDocuments();
    writeEndDocument();
    return true;
}
//! [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);
    }
}
Пример #23
0
void XbelWriter::writeToFile(QIODevice *device)
{
    TRACE_OBJ
    setDevice(device);

    writeStartDocument();
    writeDTD(QLatin1String("<!DOCTYPE xbel>"));
    writeStartElement(QLatin1String("xbel"));
    writeAttribute(QLatin1String("version"), QLatin1String("1.0"));

    const QModelIndex &root = bookmarkModel->index(0,0, QModelIndex());
    for (int i = 0; i < bookmarkModel->rowCount(root); ++i)
        writeData(bookmarkModel->index(i, 0, root));
    writeEndDocument();
}
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();
    }

}
Пример #25
0
bool XbelWriter::write(QIODevice *device, const BookmarkNode *root)
{
    setDevice(device);

    writeStartDocument();
    writeDTD(QLatin1String("<!DOCTYPE xbel>"));
    writeStartElement(QLatin1String("xbel"));
    writeAttribute(QLatin1String("version"), QLatin1String("1.0"));
    if (root->type() == BookmarkNode::Root) {
        for (int i = 0; i < root->children().count(); ++i)
            writeItem(root->children().at(i));
    } else {
        writeItem(root);
    }

    writeEndDocument();
    return true;
}
Пример #26
0
bool QhpWriter::writeFile(const QString &fileName)
{
    QFile out(fileName);
    if (!out.open(QIODevice::WriteOnly))
        return false;

    setDevice(&out);
    writeStartDocument();
    writeStartElement(QLatin1String("QtHelpProject"));
    writeAttribute(QLatin1String("version"), QLatin1String("1.0"));
    writeTextElement(QLatin1String("namespace"), m_namespaceName);
    writeTextElement(QLatin1String("virtualFolder"), m_virtualFolder);
    writeCustomFilters();
    writeFilterSection();
    writeEndDocument();

    out.close();
    return true;
}
Пример #27
0
bool OptionsTreeWriter::write(QIODevice* device)
{
	setDevice(device);

	// turn it off for even more speed
	setAutoFormatting(true);
	setAutoFormattingIndent(1);

	writeStartDocument();
	writeDTD(QString("<!DOCTYPE %1>").arg(configName_));
	writeStartElement(configName_);
	writeAttribute("version", configVersion_);
	writeAttribute("xmlns", configNS_);

	writeTree(&options_->tree_);

	writeEndDocument();
	return true;
}
Пример #28
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();
}
void CModelWriterNode100_Model::writeObjects()
{
    nfUint32 nObjectCount = m_pModel->getObjectCount();
    nfUint32 nObjectIndex;

    for (nObjectIndex = 0; nObjectIndex < nObjectCount; nObjectIndex++) {
        CModelObject * pObject = m_pModel->getObject(nObjectIndex);

        writeStartElement(XML_3MF_ELEMENT_OBJECT);
        // Write Object ID (mandatory)
        writeIntAttribute(XML_3MF_ATTRIBUTE_OBJECT_ID, pObject->getResourceID());

        // Write Object Name (optional)
        std::wstring sObjectName = pObject->getName();
        if (sObjectName.length() > 0)
            writeStringAttribute(XML_3MF_ATTRIBUTE_OBJECT_NAME, sObjectName);

        // Write Object Partnumber (optional)
        std::wstring sObjectPartNumber = pObject->getPartNumber();
        if (sObjectPartNumber.length() > 0)
            writeStringAttribute(XML_3MF_ATTRIBUTE_OBJECT_PARTNUMBER, sObjectPartNumber);

        // Write Object Type (optional)
        writeStringAttribute(XML_3MF_ATTRIBUTE_OBJECT_TYPE, pObject->getObjectTypeString());

        // Write Default Property Indices
        ModelResourceID nPropertyID = 0;
        ModelResourceIndex nPropertyIndex = 0;

        PModelDefaultProperty pProperty = pObject->getDefaultProperty();
        // Color Properties
        CModelDefaultProperty_Color * pColorProperty = dynamic_cast<CModelDefaultProperty_Color *> (pProperty.get());
        if (pColorProperty != nullptr) {
            if (m_pColorMapping->findColor(pColorProperty->getColor(), nPropertyIndex)) {
                nPropertyID = m_pColorMapping->getResourceID();
            }
        }

        // TexCoord2D Properties
        CModelDefaultProperty_TexCoord2D * pTexCoord2DProperty = dynamic_cast<CModelDefaultProperty_TexCoord2D *> (pProperty.get());
        if (pTexCoord2DProperty != nullptr) {
            PModelWriter_TexCoordMapping pTexCoordMapping = m_pTexCoordMappingContainer->findTexture(pTexCoord2DProperty->getTextureID());
            if (pTexCoordMapping.get() != nullptr) {
                if (pTexCoordMapping->findTexCoords(pTexCoord2DProperty->getU(), pTexCoord2DProperty->getV(), nPropertyIndex)) {
                    nPropertyID = pTexCoordMapping->getResourceID();
                }
            }
        }

        // Base Material Properties
        CModelDefaultProperty_BaseMaterial * pBaseMaterialProperty = dynamic_cast<CModelDefaultProperty_BaseMaterial *> (pProperty.get());
        if (pBaseMaterialProperty != nullptr) {
            nPropertyID = pBaseMaterialProperty->getResourceID();
            nPropertyIndex = pBaseMaterialProperty->getResourceIndex();
        }

        // Write Attributes
        if (nPropertyID != 0) {
            writeIntAttribute(XML_3MF_ATTRIBUTE_OBJECT_PID, nPropertyID);
            writeIntAttribute(XML_3MF_ATTRIBUTE_OBJECT_PINDEX, nPropertyIndex);
        }


        // Check if object is a mesh Object
        CModelMeshObject * pMeshObject = dynamic_cast<CModelMeshObject *> (pObject);
        if (pMeshObject) {
            CModelWriterNode100_Mesh ModelWriter_Mesh(pMeshObject, m_pXMLWriter, m_pColorMapping, m_pTexCoordMappingContainer);
            ModelWriter_Mesh.writeToXML();
        }

        // Check if object is a component Object
        CModelComponentsObject * pComponentObject = dynamic_cast<CModelComponentsObject *> (pObject);
        if (pComponentObject) {
            writeComponentsObject(pComponentObject);
        }

        writeFullEndElement();
    }

}
Пример #30
0
void GeoWriter::writeElement( const QString &key, const QString &value )
{
    writeStartElement( key );
    writeCharacters( value );
    writeEndElement();
}