2017-04-02 06:47:25 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								RELS.CMNT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments";
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 06:09:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								function parse_comments(zip, dirComments, sheets, sheetRels, opts) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									for(var i = 0; i != dirComments.length; ++i) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										var canonicalpath=dirComments[i];
							 | 
						
					
						
							
								
									
										
										
										
											2014-03-29 02:05:50 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										var comments=parse_cmnt(getzipdata(zip, canonicalpath.replace(/^\//,''), true), canonicalpath, opts);
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-19 03:03:28 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if(!comments || !comments.length) continue;
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										// find the sheets targeted by these comments
							 | 
						
					
						
							
								
									
										
										
										
											2014-05-16 00:33:34 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										var sheetNames = keys(sheets);
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										for(var j = 0; j != sheetNames.length; ++j) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											var sheetName = sheetNames[j];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											var rels = sheetRels[sheetName];
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 06:09:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											if(rels) {
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
												var rel = rels[canonicalpath];
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 06:09:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												if(rel) insertCommentsIntoSheet(sheetName, sheets[sheetName], comments);
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-29 06:00:09 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-30 05:40:35 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								function insertCommentsIntoSheet(sheetName, sheet, comments/*:Array<RawComment>*/) {
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-08 06:55:35 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									var dense = Array.isArray(sheet);
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-01 14:25:15 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									var cell/*:Cell*/;
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									comments.forEach(function(comment) {
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-01 14:25:15 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										var r = decode_cell(comment.ref);
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-08 06:55:35 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if(dense) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if(!sheet[r.r]) sheet[r.r] = [];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											cell = sheet[r.r][r.c];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										} else cell = sheet[comment.ref];
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										if (!cell) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											cell = {};
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-08 06:55:35 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											if(dense) sheet[r.r][r.c] = cell;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											else sheet[comment.ref] = cell;
							 | 
						
					
						
							
								
									
										
										
										
											2014-06-29 18:29:45 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											var range = safe_decode_range(sheet["!ref"]||"BDWGO1000001:A1");
							 | 
						
					
						
							
								
									
										
										
										
											2019-04-01 14:25:15 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											if(range.s.r > r.r) range.s.r = r.r;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if(range.e.r < r.r) range.e.r = r.r;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if(range.s.c > r.c) range.s.c = r.c;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if(range.e.c < r.c) range.e.c = r.c;
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											var encoded = encode_range(range);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											if (encoded !== sheet["!ref"]) sheet["!ref"] = encoded;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 06:09:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (!cell.c) cell.c = [];
							 | 
						
					
						
							
								
									
										
										
										
											2017-12-30 05:40:35 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										var o/*:Comment*/ = ({a: comment.author, t: comment.t, r: comment.r});
							 | 
						
					
						
							
								
									
										
										
										
											2014-02-12 06:09:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if(comment.h) o.h = comment.h;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										cell.c.push(o);
							 | 
						
					
						
							
								
									
										
										
										
											2014-01-28 16:38:02 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 |