VBA CFB test [ci skip]

This commit is contained in:
Maxim Kukhtenkov 2018-02-04 18:58:00 -05:00
parent 75845a0ca7
commit fb97bf1768
6 changed files with 14 additions and 5 deletions

View File

@ -1,3 +1,4 @@
var CT_VBA = "application/vnd.ms-office.vbaProject";
function make_vba_xls(cfb/*:CFBContainer*/) {
var newcfb = CFB.utils.cfb_new({root:"R"});
cfb.FullPaths.forEach(function(p, i) {

View File

@ -169,7 +169,7 @@ function parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
}
if(opts.bookVBA) {
if(dir.vba.length > 0) out.vbaraw = getzipdata(zip,strip_front_slash(dir.vba[0]),true);
else if(dir.defaults && dir.defaults.bin === 'application/vnd.ms-office.vbaProject') out.vbaraw = getzipdata(zip,'xl/vbaProject.bin',true);
else if(dir.defaults && dir.defaults.bin === CT_VBA) out.vbaraw = getzipdata(zip, 'xl/vbaProject.bin',true);
}
return out;
}

View File

@ -591,7 +591,10 @@ describe('parse options', function() {
var wb = X.read(fs.readFileSync(p), {type:TYPE}); assert(typeof wb.vbaraw === 'undefined');
}); });
it('bookVBA should generate vbaraw', function() { NFVBA.forEach(function(p) {
var wb = X.read(fs.readFileSync(p),{type:TYPE, bookVBA:true}); assert(wb.vbaraw);
var wb = X.read(fs.readFileSync(p),{type: TYPE, bookVBA: true});
assert(wb.vbaraw);
var cfb = X.CFB.read(wb.vbaraw, {type: 'array'});
assert(X.CFB.find(cfb, '/VBA/ThisWorkbook'));
}); });
});
});

5
tests/core.js generated
View File

@ -591,7 +591,10 @@ describe('parse options', function() {
var wb = X.read(fs.readFileSync(p), {type:TYPE}); assert(typeof wb.vbaraw === 'undefined');
}); });
it('bookVBA should generate vbaraw', function() { NFVBA.forEach(function(p) {
var wb = X.read(fs.readFileSync(p),{type:TYPE, bookVBA:true}); assert(wb.vbaraw);
var wb = X.read(fs.readFileSync(p),{type: TYPE, bookVBA: true});
assert(wb.vbaraw);
var cfb = X.CFB.read(wb.vbaraw, {type: 'array'});
assert(X.CFB.find(cfb, '/VBA/ThisWorkbook'));
}); });
});
});

View File

@ -9175,6 +9175,7 @@ function write_comments_bin(data/*::, opts*/) {
write_record(ba, "BrtEndComments");
return ba.end();
}
var CT_VBA = "application/vnd.ms-office.vbaProject";
function make_vba_xls(cfb/*:CFBContainer*/) {
var newcfb = CFB.utils.cfb_new({root:"R"});
cfb.FullPaths.forEach(function(p, i) {
@ -18775,7 +18776,7 @@ function parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
}
if(opts.bookVBA) {
if(dir.vba.length > 0) out.vbaraw = getzipdata(zip,strip_front_slash(dir.vba[0]),true);
else if(dir.defaults && dir.defaults.bin === 'application/vnd.ms-office.vbaProject') out.vbaraw = getzipdata(zip,'xl/vbaProject.bin',true);
else if(dir.defaults && dir.defaults.bin === CT_VBA) out.vbaraw = getzipdata(zip, 'xl/vbaProject.bin',true);
}
return out;
}

3
xlsx.js generated
View File

@ -9081,6 +9081,7 @@ function write_comments_bin(data) {
write_record(ba, "BrtEndComments");
return ba.end();
}
var CT_VBA = "application/vnd.ms-office.vbaProject";
function make_vba_xls(cfb) {
var newcfb = CFB.utils.cfb_new({root:"R"});
cfb.FullPaths.forEach(function(p, i) {
@ -18665,7 +18666,7 @@ function parse_zip(zip, opts) {
}
if(opts.bookVBA) {
if(dir.vba.length > 0) out.vbaraw = getzipdata(zip,strip_front_slash(dir.vba[0]),true);
else if(dir.defaults && dir.defaults.bin === 'application/vnd.ms-office.vbaProject') out.vbaraw = getzipdata(zip,'xl/vbaProject.bin',true);
else if(dir.defaults && dir.defaults.bin === CT_VBA) out.vbaraw = getzipdata(zip, 'xl/vbaProject.bin',true);
}
return out;
}