Skip to content

Commit

Permalink
Fix/client external reference (#2837)
Browse files Browse the repository at this point in the history
* [se] Fix client read/write: external link
  • Loading branch information
GoshaZotov authored Jun 17, 2022
1 parent 9e97777 commit 029002c
Showing 1 changed file with 74 additions and 28 deletions.
102 changes: 74 additions & 28 deletions cell/model/SerializeXml.js
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,63 @@
return res;
}

function FromXml_ST_CellValueType(val) {
var res = undefined;
switch (val) {
case "s":
res = CellValueType.String;
break;
case "str":
res = CellValueType.String;
break;
case "n":
res = CellValueType.Number;
break;
case "e":
res = CellValueType.Error;
break;
case "b":
res = CellValueType.Bool;
break;
case "inlineStr":
res = CellValueType.String;
break;
case "d":
res = CellValueType.String;
break;
}
return res;
}

function ToXml_ST_CellValueType(val) {
var res = undefined;
switch (val) {
case CellValueType.String:
res = "s";
break;
/*case CellValueType.String:
res = "str";
break;*/
case CellValueType.Number:
res = "n";
break;
case CellValueType.Error:
res = "e";
break;
case CellValueType.Bool:
res = "b";
break;
/*case "inlineStr":
res = CellValueType.String;
break;
case "d":
res = CellValueType.String;
break;*/
}
return res;
}



//additional functions
function prepareCommentsToWrite(m_mapComments, personList) {
Expand Down Expand Up @@ -3705,28 +3762,9 @@
}
} else if ("t" === reader.GetName()) {
val = reader.GetValue();
switch (val) {
case "s":
this.type = CellValueType.String;
break;
case "str":
this.type = CellValueType.String;
break;
case "n":
this.type = CellValueType.Number;
break;
case "e":
this.type = CellValueType.Error;
break;
case "b":
this.type = CellValueType.Bool;
break;
case "inlineStr":
this.type = CellValueType.String;
break;
case "d":
this.type = CellValueType.String;
break;
var type = FromXml_ST_CellValueType(val);
if (type != null) {
this.type = type;
}
}
}
Expand All @@ -3743,6 +3781,7 @@
var text = null;
var number = null;
var type = null;
//TODO ToXml_ST_CellValueType
switch (this.type) {
case CellValueType.String:
type = "s";
Expand Down Expand Up @@ -10033,9 +10072,16 @@ xmlns:xr16=\"http://schemas.microsoft.com/office/spreadsheetml/2017/revision16\"
//здесь пишем externalLink[]
var oExternalReference = new CT_ExternalReference();
oExternalReference.val = externalReference;

var wsPart = context.part.addPart(AscCommon.openXml.Types.externalWorkbook);
var rId = wsPart.part.addRelationship("http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath", externalReference.Id, "External");
var trueId = externalReference.Id;
externalReference.Id = rId;

//внутри дёргается toXml
wsPart.part.setDataXml(oExternalReference, writer);

externalReference.Id = trueId;
ids.push(wsPart.rId);
});

Expand Down Expand Up @@ -10102,9 +10148,9 @@ xmlns:xr16=\"http://schemas.microsoft.com/office/spreadsheetml/2017/revision16\"
writer.WriteXmlString(("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"));
writer.WriteXmlString(("<externalLink xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">"));

if (this.val && this.val.externalBook) {
if (this.val) {
var externalBook = new CT_ExternalBook();
externalBook.val = this.val.externalBook;
externalBook.val = this.val;
externalBook.toXml(writer);
}
/*if (m_oExternalBook.IsInit())
Expand Down Expand Up @@ -10170,9 +10216,10 @@ xmlns:xr16=\"http://schemas.microsoft.com/office/spreadsheetml/2017/revision16\"

writer.WriteXmlString("<externalBook");
if (this.val.Id) {
writer.WriteXmlString("\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"");
writer.WriteXmlString(" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"");
writer.WriteXmlString(" r:id=\"");
writer.WriteXmlString(this.val.Id);
writer.WriteXmlString("\"");
}
writer.WriteXmlString(">");

Expand Down Expand Up @@ -10466,7 +10513,7 @@ xmlns:xr16=\"http://schemas.microsoft.com/office/spreadsheetml/2017/revision16\"
this.val.Ref = val;
} else if ("t" === reader.GetName()) {
val = reader.GetValue();
this.val.CellType = val;
this.val.CellType = FromXml_ST_CellValueType(val);
} else if ("vm" === reader.GetName()) {
/*val = reader.GetValue();
this.val.CellType = val;*/
Expand All @@ -10477,7 +10524,7 @@ xmlns:xr16=\"http://schemas.microsoft.com/office/spreadsheetml/2017/revision16\"
CT_ExternalCell.prototype.toXml = function (writer) {
writer.WriteXmlString("<cell");
writer.WriteXmlNullableAttributeString("r", this.val.Ref);
writer.WriteXmlNullableAttributeString("t", this.val.CellType);
writer.WriteXmlNullableAttributeString("t", ToXml_ST_CellValueType(this.val.CellType));
//writer.WriteXmlNullableAttributeNumber("vm", this.vm);
writer.WriteXmlString(">");

Expand All @@ -10489,7 +10536,6 @@ xmlns:xr16=\"http://schemas.microsoft.com/office/spreadsheetml/2017/revision16\"
}

writer.WriteXmlString("</cell>");

};


Expand Down

0 comments on commit 029002c

Please sign in to comment.