2014-03-29 02:05:50 +00:00
|
|
|
/* [MS-XLSB] 2.4.28 BrtBeginComment */
|
2017-07-27 20:07:51 +00:00
|
|
|
function parse_BrtBeginComment(data, length/*:number*/) {
|
2014-03-29 02:05:50 +00:00
|
|
|
var out = {};
|
|
|
|
out.iauthor = data.read_shift(4);
|
|
|
|
var rfx = parse_UncheckedRfX(data, 16);
|
|
|
|
out.rfx = rfx.s;
|
|
|
|
out.ref = encode_cell(rfx.s);
|
|
|
|
data.l += 16; /*var guid = parse_GUID(data); */
|
|
|
|
return out;
|
2014-06-29 18:29:45 +00:00
|
|
|
}
|
2017-04-02 06:47:25 +00:00
|
|
|
function write_BrtBeginComment(data, o) {
|
|
|
|
if(o == null) o = new_buf(36);
|
|
|
|
o.write_shift(4, data[1].iauthor);
|
2017-04-03 00:16:03 +00:00
|
|
|
write_UncheckedRfX((data[0]/*:any*/), o);
|
2017-04-02 06:47:25 +00:00
|
|
|
o.write_shift(4, 0);
|
|
|
|
o.write_shift(4, 0);
|
|
|
|
o.write_shift(4, 0);
|
|
|
|
o.write_shift(4, 0);
|
|
|
|
return o;
|
|
|
|
}
|
2014-03-29 02:05:50 +00:00
|
|
|
|
|
|
|
/* [MS-XLSB] 2.4.324 BrtCommentAuthor */
|
|
|
|
var parse_BrtCommentAuthor = parse_XLWideString;
|
2017-07-27 20:07:51 +00:00
|
|
|
function write_BrtCommentAuthor(data) { return write_XLWideString(data.substr(0, 54)); }
|
2014-03-29 02:05:50 +00:00
|
|
|
|
|
|
|
/* [MS-XLSB] 2.1.7.8 Comments */
|
|
|
|
function parse_comments_bin(data, opts) {
|
|
|
|
var out = [];
|
|
|
|
var authors = [];
|
|
|
|
var c = {};
|
|
|
|
var pass = false;
|
2017-04-09 04:03:19 +00:00
|
|
|
recordhopper(data, function hopper_cmnt(val, R_n, RT) {
|
|
|
|
switch(RT) {
|
|
|
|
case 0x0278: /* 'BrtCommentAuthor' */
|
|
|
|
authors.push(val); break;
|
|
|
|
case 0x027B: /* 'BrtBeginComment' */
|
|
|
|
c = val; break;
|
|
|
|
case 0x027D: /* 'BrtCommentText' */
|
|
|
|
c.t = val.t; c.h = val.h; c.r = val.r; break;
|
|
|
|
case 0x027C: /* 'BrtEndComment' */
|
2014-03-29 02:05:50 +00:00
|
|
|
c.author = authors[c.iauthor];
|
|
|
|
delete c.iauthor;
|
|
|
|
if(opts.sheetRows && opts.sheetRows <= c.rfx.r) break;
|
2017-04-02 06:47:25 +00:00
|
|
|
if(!c.t) c.t = "";
|
2014-03-29 02:05:50 +00:00
|
|
|
delete c.rfx; out.push(c); break;
|
2017-04-08 06:55:35 +00:00
|
|
|
|
2017-04-09 04:03:19 +00:00
|
|
|
/* case 'BrtUid': */
|
|
|
|
|
|
|
|
case 0x0023: /* 'BrtFRTBegin' */
|
|
|
|
pass = true; break;
|
|
|
|
case 0x0024: /* 'BrtFRTEnd' */
|
|
|
|
pass = false; break;
|
|
|
|
case 0x0025: /* 'BrtACBegin' */ break;
|
|
|
|
case 0x0026: /* 'BrtACEnd' */ break;
|
|
|
|
|
2017-04-08 06:55:35 +00:00
|
|
|
|
|
|
|
default:
|
2017-05-09 18:07:57 +00:00
|
|
|
if((R_n||"").indexOf("Begin") > 0){/* empty */}
|
|
|
|
else if((R_n||"").indexOf("End") > 0){/* empty */}
|
2017-04-09 04:03:19 +00:00
|
|
|
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
|
2014-03-29 02:05:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return out;
|
|
|
|
}
|
2014-05-29 22:30:03 +00:00
|
|
|
|
2017-04-02 06:47:25 +00:00
|
|
|
function write_comments_bin(data, opts) {
|
|
|
|
var ba = buf_array();
|
|
|
|
var iauthor = [];
|
|
|
|
write_record(ba, "BrtBeginComments");
|
|
|
|
{ /* COMMENTAUTHORS */
|
|
|
|
write_record(ba, "BrtBeginCommentAuthors");
|
|
|
|
data.forEach(function(comment) {
|
|
|
|
comment[1].forEach(function(c) {
|
|
|
|
if(iauthor.indexOf(c.a) > -1) return;
|
|
|
|
iauthor.push(c.a.substr(0,54));
|
2017-07-27 20:07:51 +00:00
|
|
|
write_record(ba, "BrtCommentAuthor", write_BrtCommentAuthor(c.a));
|
2017-04-02 06:47:25 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
write_record(ba, "BrtEndCommentAuthors");
|
|
|
|
}
|
|
|
|
{ /* COMMENTLIST */
|
|
|
|
write_record(ba, "BrtBeginCommentList");
|
|
|
|
data.forEach(function(comment) {
|
|
|
|
comment[1].forEach(function(c) {
|
|
|
|
c.iauthor = iauthor.indexOf(c.a);
|
2017-04-03 00:16:03 +00:00
|
|
|
var range = {s:decode_cell(comment[0]),e:decode_cell(comment[0])};
|
2017-04-02 06:47:25 +00:00
|
|
|
write_record(ba, "BrtBeginComment", write_BrtBeginComment([range, c]));
|
2017-05-09 18:07:57 +00:00
|
|
|
if(c.t && c.t.length > 0) write_record(ba, "BrtCommentText", write_BrtCommentText(c));
|
2017-04-02 06:47:25 +00:00
|
|
|
write_record(ba, "BrtEndComment");
|
|
|
|
delete c.iauthor;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
write_record(ba, "BrtEndCommentList");
|
|
|
|
}
|
|
|
|
write_record(ba, "BrtEndComments");
|
|
|
|
return ba.end();
|
|
|
|
}
|