mirror of
https://github.com/ONLYOFFICE/sdkjs-forms.git
synced 2026-03-31 10:23:35 +08:00
[oform] Implement writing of default user master to xml
Also fix writing to xml of duplicates in relationship table
This commit is contained in:
@ -220,10 +220,9 @@
|
||||
};
|
||||
CDocument.prototype.toPkg = function(xmlPkg)
|
||||
{
|
||||
// TODO: default.xml
|
||||
|
||||
let xmlContext = xmlPkg.getContext();
|
||||
let xmlWriter = xmlPkg.getXmlWriter();
|
||||
|
||||
let main = xmlPkg.addPart(AscCommon.openXml.Types.oformMain).part;
|
||||
|
||||
xmlWriter.Seek(0);
|
||||
@ -324,10 +323,30 @@
|
||||
|
||||
// TODO: Author, Date
|
||||
|
||||
writer.WriteXmlNodeWithText("description", this.getDescription());
|
||||
writer.WriteXmlNodeWithText("type", this.getType());
|
||||
writer.WriteXmlNodeWithText("application", this.getApplication());
|
||||
writer.WriteXmlNodeWithText("id", this.getDocumentId());
|
||||
let description = this.getDescription();
|
||||
if (description)
|
||||
writer.WriteXmlNodeWithText("description", description);
|
||||
|
||||
let type = this.getType();
|
||||
if (type)
|
||||
writer.WriteXmlNodeWithText("type", type);
|
||||
|
||||
let application = this.getApplication();
|
||||
if (application)
|
||||
writer.WriteXmlNodeWithText("application", application);
|
||||
|
||||
let documentId = this.getDocumentId();
|
||||
if (documentId)
|
||||
writer.WriteXmlNodeWithText("id", documentId);
|
||||
|
||||
let xmlContext = writer.context;
|
||||
let defaultUserPart = xmlContext.getDefaultUserMasterPart(this.DefaultUser);
|
||||
if (defaultUserPart)
|
||||
{
|
||||
writer.WriteXmlNodeStart("defaultUser");
|
||||
writer.WriteXmlNullableAttributeString("r:id", xmlContext.getRId(defaultUserPart));
|
||||
writer.WriteXmlAttributesEnd(true);
|
||||
}
|
||||
|
||||
for (let fgIndex = 0, fgCount = this.FieldGroups.length; fgIndex < fgCount; ++fgIndex)
|
||||
{
|
||||
|
||||
@ -186,12 +186,18 @@
|
||||
this.userMasterToPart = {};
|
||||
this.fieldToPart = {};
|
||||
this.fieldMasterToPart = {};
|
||||
|
||||
this.partToRId = {};
|
||||
}
|
||||
XmlWriterContext.prototype.clearCurrentPartDataMaps = function()
|
||||
{
|
||||
this.partToRId = {};
|
||||
};
|
||||
XmlWriterContext.prototype.getRId = function(part)
|
||||
{
|
||||
if (this.partToRId[part.uri])
|
||||
return this.partToRId[part.uri];
|
||||
|
||||
if (!this.part)
|
||||
return "";
|
||||
|
||||
@ -220,7 +226,9 @@
|
||||
|
||||
relative += targetSplit.join('/');
|
||||
|
||||
return this.part.addRelationship(null, relative);
|
||||
let rId = this.part.addRelationship(null, relative);
|
||||
this.partToRId[part.uri] = rId;
|
||||
return rId;
|
||||
};
|
||||
XmlWriterContext.prototype.getUserPart = function(user)
|
||||
{
|
||||
@ -234,6 +242,10 @@
|
||||
{
|
||||
return this.getPartFromPkg(this.userMasterToPart, userMaster, AscCommon.openXml.Types.oformUserMaster);
|
||||
};
|
||||
XmlWriterContext.prototype.getDefaultUserMasterPart = function(userMaster)
|
||||
{
|
||||
return this.getPartFromPkg(this.userMasterToPart, userMaster, AscCommon.openXml.Types.oformDefaultUserMaster);
|
||||
};
|
||||
XmlWriterContext.prototype.haveUserMasterPart = function(userMaster)
|
||||
{
|
||||
return !!this.userMasterToPart[userMaster.GetId()];
|
||||
|
||||
Reference in New Issue
Block a user