From 318e2319ee613d5a1f7ac7a2df542854650ea875 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Sun, 10 Nov 2024 21:27:04 -0500 Subject: [PATCH] ODS parse hyperlink tooltips --- bits/78_writebiff.js | 22 ++++++++++------------ bits/80_parseods.js | 4 ++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/bits/78_writebiff.js b/bits/78_writebiff.js index beb0a8f..b93ae75 100644 --- a/bits/78_writebiff.js +++ b/bits/78_writebiff.js @@ -433,7 +433,7 @@ function write_FMTS_biff8(ba, NF/*:?SSFTable*/, opts) { function write_ws_protect_biff8(sp) { /* SheetProtection */ - let flags = 0x0000; + var flags = 0x0000; [ ["objects", false, 0x0001], // fObjects - Bit 0 (Edit objects) ["scenarios", false, 0x0002], // fScenarios - Bit 1 (Edit scenarios) @@ -451,17 +451,17 @@ function write_ws_protect_biff8(sp) { ["pivotTables", true, 0x2000], // fPivotTables - Bit 13 (Edit PivotTables) ["selectUnlockedCells", false, 0x4000] // fSelUnlockedCells - Bit 14 (Select unlocked cells) ].forEach(function(n) { - if(n[1]) flags |= sp[n[0]] != null && !sp[n[0]] ? n[2] : 0x0000 + if(n[1]) flags |= sp[n[0]] != null && !sp[n[0]] ? n[2] : 0x0000; else flags |= sp[n[0]] != null && sp[n[0]] ? 0x0000 : n[2]; }); /* [MS-XLS] 2.4.112 */ - const featHdr = new_buf(23); + var featHdr = new_buf(23); /* [MS-XLS] 2.5.135 */ - featHdr.write_shift(2, 0x0867) + featHdr.write_shift(2, 0x0867); featHdr.write_shift(2, 0x0000); - featHdr.write_shift(4, 0x00000000) - featHdr.write_shift(4, 0x00000000) + featHdr.write_shift(4, 0x00000000); + featHdr.write_shift(4, 0x00000000); /* [MS-XLS] 2.5.237 */ featHdr.write_shift(2, 0x0002); // SharedFeatureType ISFPROTECTION /* Reserved byte */ @@ -469,17 +469,15 @@ function write_ws_protect_biff8(sp) { /* cbHdrData */ featHdr.write_shift(4, 0xffffffff); /* [MS-XLS] 2.5.104 */ - featHdr.write_shift(4, flags) + featHdr.write_shift(4, flags); - return featHdr + return featHdr; } function write_FEAT(ba, ws) { /* [MS-XLS] 2.4.112 */ /* ISFPROTECTION */ - if(ws['!protect']){ - write_biff_rec(ba, 0x0867 /* FeatHdr */, write_ws_protect_biff8(ws['!protect'])) - } + if(ws['!protect']) write_biff_rec(ba, 0x0867 /* FeatHdr */, write_ws_protect_biff8(ws['!protect'])); /* ISFFEC2 */ var o = new_buf(19); o.write_shift(4, 0x867); o.write_shift(4, 0); o.write_shift(4, 0); @@ -587,7 +585,7 @@ function write_ws_biff8(idx/*:number*/, opts, wb/*:Workbook*/) { write_biff_rec(ba, 0x0084 /* VCenter */, writebool(false)); /* PROTECTION */ if(ws['!protect']){ - const sp = ws['!protect'] + var sp = ws['!protect']; /* [MS-XLS] 2.4.207 */ write_biff_rec(ba, 0x0012 /* Protect */, writeuint16(1)); /* [MS-XLS] 2.4.191 */ diff --git a/bits/80_parseods.js b/bits/80_parseods.js index ff1718b..e004ecd 100644 --- a/bits/80_parseods.js +++ b/bits/80_parseods.js @@ -764,6 +764,10 @@ function parse_content_xml(d/*:string*/, _opts, _nfm)/*:Workbook*/ { _Ref = ods_to_csf_3D(atag.Target.slice(1)); atag.Target = "#" + _Ref[0] + "!" + _Ref[1]; } else if(atag.Target.match(/^\.\.[\\\/]/)) atag.Target = atag.Target.slice(3); + /* Appendix D.2 Hyperlink Titles */ + if(atag.title) { + atag.Tooltip = unescapexml(atag.title); delete atag.title; + } } break;