mirror of
https://github.com/ONLYOFFICE/sdkjs-forms.git
synced 2026-03-31 10:23:35 +08:00
[oform] Base methods to read/write main.xml
This commit is contained in:
@ -34,8 +34,6 @@
|
|||||||
|
|
||||||
(function(window)
|
(function(window)
|
||||||
{
|
{
|
||||||
AscCommonWord.g_sXmlHeader = AscCommonWord.g_sXmlHeader || '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Класс представляющий отдельный файл в xml-структуре вместе со своими рельсами
|
* Класс представляющий отдельный файл в xml-структуре вместе со своими рельсами
|
||||||
* @param name {string}
|
* @param name {string}
|
||||||
|
|||||||
@ -171,104 +171,61 @@
|
|||||||
|
|
||||||
return this.FieldGroups[index];
|
return this.FieldGroups[index];
|
||||||
};
|
};
|
||||||
CDocument.prototype.readChildXml = function(name, reader)
|
CDocument.prototype.fromXml = function()
|
||||||
{
|
{
|
||||||
// TODO: fix me
|
// TODO: Author, Date
|
||||||
switch (name)
|
if (!reader.ReadNextNode() || "document" !== reader.GetNameNoNS())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
let depth = reader.GetDepth();
|
||||||
|
while (reader.ReadNextSiblingNode(depth))
|
||||||
{
|
{
|
||||||
case "Author":
|
switch(reader.GetNameNoNS())
|
||||||
{
|
{
|
||||||
let oNode = new CT_XmlNode();
|
case "author":
|
||||||
oNode.fromXml(reader);
|
break;
|
||||||
let sAuthor = oNode.attributes["id"];
|
case "date":
|
||||||
if (sAuthor)
|
break;
|
||||||
{
|
case "description":
|
||||||
this.setAuthor(sAuthor);
|
this.setDescription(reader.GetValueDecodeXml());
|
||||||
}
|
break;
|
||||||
break;
|
case "type":
|
||||||
}
|
this.setType(reader.GetValueDecodeXml());
|
||||||
case "Date":
|
break;
|
||||||
{
|
case "application":
|
||||||
let oDate = new CFormDate();
|
this.setApplication(reader.GetValueDecodeXml());
|
||||||
oDate.fromXml(reader);
|
break;
|
||||||
this.setDate(oDate);
|
case "id":
|
||||||
break;
|
this.setDocumentId(reader.GetValueDecodeXml());
|
||||||
}
|
break;
|
||||||
case "Description":
|
case "fieldGroup":
|
||||||
{
|
this.addFieldMaster(AscOForm.CFieldGroup.fromXml(reader));
|
||||||
|
break;
|
||||||
let oNode = new CT_XmlNode();
|
|
||||||
oNode.fromXml(reader);
|
|
||||||
this.setDescription(oNode.text);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Type":
|
|
||||||
{
|
|
||||||
let oNode = new CT_XmlNode();
|
|
||||||
oNode.fromXml(reader);
|
|
||||||
this.setType(oNode.text);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Application":
|
|
||||||
{
|
|
||||||
let oNode = new CT_XmlNode();
|
|
||||||
oNode.fromXml(reader);
|
|
||||||
this.setApplication(oNode.text);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Id":
|
|
||||||
{
|
|
||||||
let oNode = new CT_XmlNode();
|
|
||||||
oNode.fromXml(reader);
|
|
||||||
this.setDocumentId(oNode.text);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "FieldsGroup":
|
|
||||||
{
|
|
||||||
let oFieldsGroup = new CFieldsGroup();
|
|
||||||
oFieldsGroup.fromXml(reader);
|
|
||||||
this.addFieldsGroups(oFieldsGroup);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
CDocument.prototype.toXml = function(writer)
|
CDocument.prototype.toXml = function(writer)
|
||||||
{
|
{
|
||||||
// TODO: fix me
|
writer.WriteXmlHeader();
|
||||||
writer.WriteXmlString(AscCommonWord.g_sXmlHeader);
|
writer.WriteXmlNodeStart("document");
|
||||||
writer.WriteXmlNodeStart("Document");
|
writer.WriteXmlRelationshipsNS();
|
||||||
writer.WriteXmlAttributeString("xmlns:r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
|
||||||
writer.WriteXmlAttributesEnd();
|
writer.WriteXmlAttributesEnd();
|
||||||
if (this.Author)
|
|
||||||
{
|
|
||||||
let oNode = new CT_XmlNode();
|
|
||||||
oNode.attributes["id"] = this.Author;
|
|
||||||
oNode.toXml(writer, "Author");
|
|
||||||
}
|
|
||||||
if (this.Date)
|
|
||||||
{
|
|
||||||
this.Date.toXml(writer);
|
|
||||||
}
|
|
||||||
let oDescriptionNode = new CT_XmlNode();
|
|
||||||
oDescriptionNode.text = this.Description;
|
|
||||||
oDescriptionNode.toXml(writer, "Description");
|
|
||||||
|
|
||||||
let oTypeNode = new CT_XmlNode();
|
// TODO: Author, Date
|
||||||
oTypeNode.text = this.Type;
|
|
||||||
oTypeNode.toXml(writer, "Type");
|
|
||||||
|
|
||||||
let oAppNode = new CT_XmlNode();
|
writer.WriteXmlNodeWithText("description", this.getDescription());
|
||||||
oAppNode.text = this.Application;
|
writer.WriteXmlNodeWithText("type", this.getType());
|
||||||
oAppNode.toXml(writer, "Application");
|
writer.WriteXmlNodeWithText("application", this.getApplication());
|
||||||
|
writer.WriteXmlNodeWithText("id", this.getDocumentId());
|
||||||
|
|
||||||
let oIdNode = new CT_XmlNode();
|
for (let fgIndex = 0, fgCount = this.FieldGroups.length; fgIndex < fgCount; ++fgIndex)
|
||||||
oIdNode.text = this.DocumentId;
|
|
||||||
oIdNode.toXml(writer, "Id");
|
|
||||||
for (let nFG = 0; nFG < this.FieldsGroups.length; ++nFG)
|
|
||||||
{
|
{
|
||||||
this.FieldsGroups[nFG].toXml(writer);
|
this.FieldsGroups[fgIndex].toXml(writer);
|
||||||
}
|
}
|
||||||
writer.WriteXmlNodeEnd("Document");
|
|
||||||
|
writer.WriteXmlNodeEnd("document");
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @returns {AscOForm.CUserMaster}
|
* @returns {AscOForm.CUserMaster}
|
||||||
|
|||||||
@ -189,11 +189,6 @@
|
|||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
};
|
};
|
||||||
CFieldGroup.prototype.readChildXml = function(name, reader)
|
|
||||||
{
|
|
||||||
// TODO: implement
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
CFieldGroup.prototype.toXml = function(writer, xmlFormat)
|
CFieldGroup.prototype.toXml = function(writer, xmlFormat)
|
||||||
{
|
{
|
||||||
writer.WriteXmlNodeStart("fieldGroup");
|
writer.WriteXmlNodeStart("fieldGroup");
|
||||||
|
|||||||
@ -151,7 +151,7 @@
|
|||||||
};
|
};
|
||||||
CUserMaster.prototype.toXml = function(writer)
|
CUserMaster.prototype.toXml = function(writer)
|
||||||
{
|
{
|
||||||
writer.WriteXmlString(AscCommonWord.g_sXmlHeader);
|
writer.WriteXmlHeader();
|
||||||
writer.WriteXmlNodeStart("userMaster");
|
writer.WriteXmlNodeStart("userMaster");
|
||||||
writer.WriteXmlAttributesEnd();
|
writer.WriteXmlAttributesEnd();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user