/* 9.3 Relationships */ var RELS = ({ WB: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", SHEET: "http://sheetjs.openxmlformats.org/officeDocument/2006/relationships/officeDocument", HLINK: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", VML: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing", XPATH: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath", XMISS: "http://schemas.microsoft.com/office/2006/relationships/xlExternalLinkPath/xlPathMissing", XLINK: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink", VBA: "http://schemas.microsoft.com/office/2006/relationships/vbaProject" }/*:any*/); /* 9.3.3 Representing Relationships */ function get_rels_path(file/*:string*/)/*:string*/ { var n = file.lastIndexOf("/"); return file.slice(0,n+1) + '_rels/' + file.slice(n+1) + ".rels"; } function parse_rels(data/*:?string*/, currentFilePath/*:string*/) { if (!data) return data; if (currentFilePath.charAt(0) !== '/') { currentFilePath = '/'+currentFilePath; } var rels = {}; var hash = {}; (data.match(tagregex)||[]).forEach(function(x) { var y = parsexmltag(x); /* 9.3.2.2 OPC_Relationships */ if (y[0] === '2){ o[o.length] = (''); o[1]=o[1].replace("/>",">"); } return o.join(""); } var RELS_EXTERN = [RELS.HLINK, RELS.XPATH, RELS.XMISS]; function add_rels(rels, rId/*:number*/, f, type, relobj, targetmode/*:?string*/)/*:number*/ { if(!relobj) relobj = {}; if(!rels['!id']) rels['!id'] = {}; if(rId < 0) for(rId = 1; rels['!id']['rId' + rId]; ++rId){/* empty */} relobj.Id = 'rId' + rId; relobj.Type = type; relobj.Target = f; if(targetmode) relobj.TargetMode = targetmode; else if(RELS_EXTERN.indexOf(relobj.Type) > -1) relobj.TargetMode = "External"; if(rels['!id'][relobj.Id]) throw new Error("Cannot rewrite rId " + rId); rels['!id'][relobj.Id] = relobj; rels[('/' + relobj.Target).replace("//","/")] = relobj; return rId; }