From 0172da1a3003d1b131d93c2fc05f34390bafffb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20K=C5=82os?= Date: Mon, 12 Aug 2024 14:59:57 +0200 Subject: [PATCH] impress: move part hashes to the docstate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Szymon Kłos Change-Id: Ib9007dc3d4b2baec6280066f0b9852cd5a435c5f --- browser/src/canvas/sections/CommentListSection.ts | 2 +- browser/src/canvas/sections/CommentSection.ts | 4 ++-- browser/src/docstate.js | 3 +++ browser/src/layer/tile/ImpressTileLayer.js | 10 +++++----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/browser/src/canvas/sections/CommentListSection.ts b/browser/src/canvas/sections/CommentListSection.ts index 6e6b3b33d403..13d643553836 100644 --- a/browser/src/canvas/sections/CommentListSection.ts +++ b/browser/src/canvas/sections/CommentListSection.ts @@ -1511,7 +1511,7 @@ export class CommentSection extends app.definitions.canvasSectionObject { private adjustCommentFileBasedView (comment: any): void { // Below calculations are the same with the ones we do while drawing tiles in fileBasedView. var partHeightTwips = this.sectionProperties.docLayer._partHeightTwips + this.sectionProperties.docLayer._spaceBetweenParts; - var index = this.sectionProperties.docLayer._partHashes.indexOf(String(comment.parthash)); + var index = app.impress.partHashes.indexOf(String(comment.parthash)); var yAddition = index * partHeightTwips; comment.yAddition = yAddition; // We'll use this while we save the new position of the comment. diff --git a/browser/src/canvas/sections/CommentSection.ts b/browser/src/canvas/sections/CommentSection.ts index 4ed2b57adffb..235c1174c3a1 100644 --- a/browser/src/canvas/sections/CommentSection.ts +++ b/browser/src/canvas/sections/CommentSection.ts @@ -117,7 +117,7 @@ export class Comment extends CanvasSectionObject { if (this.sectionProperties.docLayer._docType === 'presentation' || this.sectionProperties.docLayer._docType === 'drawing') { this.sectionProperties.parthash = this.sectionProperties.data.parthash; - this.sectionProperties.partIndex = this.sectionProperties.docLayer._partHashes.indexOf(String(this.sectionProperties.parthash)); + this.sectionProperties.partIndex = app.impress.partHashes.indexOf(String(this.sectionProperties.parthash)); } this.sectionProperties.isHighlighted = false; @@ -645,7 +645,7 @@ export class Comment extends CanvasSectionObject { }), draggable: true }); - if (this.sectionProperties.docLayer._partHashes[this.sectionProperties.docLayer._selectedPart] === this.sectionProperties.data.parthash || app.file.fileBasedView) + if (app.impress.partHashes[this.sectionProperties.docLayer._selectedPart] === this.sectionProperties.data.parthash || app.file.fileBasedView) this.map.addLayer(this.sectionProperties.annotationMarker); } if (this.sectionProperties.data.rectangle != null) { diff --git a/browser/src/docstate.js b/browser/src/docstate.js index 213c5a1e126c..5977217b5f75 100644 --- a/browser/src/docstate.js +++ b/browser/src/docstate.js @@ -29,6 +29,9 @@ window.app = { otherCellCursors: {}, splitCoordinate: null, // SimplePoint. }, + impress: { + partHashes: null, // hashes used to distinguish parts + }, map: null, // Make map object a part of this. dispatcher: null, // A Dispatcher class instance is assigned to this. twipsToPixels: 0, // Twips to pixels multiplier. diff --git a/browser/src/layer/tile/ImpressTileLayer.js b/browser/src/layer/tile/ImpressTileLayer.js index 6da2ffa33b1b..65a5079543ec 100644 --- a/browser/src/layer/tile/ImpressTileLayer.js +++ b/browser/src/layer/tile/ImpressTileLayer.js @@ -24,7 +24,7 @@ L.ImpressTileLayer = L.CanvasTileLayer.extend({ } this._preview = L.control.partsPreview(); - this._partHashes = null; + app.impress.partHashes = null; if (window.mode.isMobile()) { this._addButton = L.control.mobileSlide(); L.DomUtil.addClass(L.DomUtil.get('mobile-edit-button'), 'impress'); @@ -83,7 +83,7 @@ L.ImpressTileLayer = L.CanvasTileLayer.extend({ comment.anchorPos = [docTopLeft[0], docTopLeft[1]]; comment.rectangle = [docTopLeft[0], docTopLeft[1], 566, 566]; - comment.parthash = this._partHashes[this._selectedPart]; + comment.parthash = app.impress.partHashes[this._selectedPart]; var annotation = app.sectionContainer.getSectionWithName(L.CSections.CommentList.name).add(comment); app.sectionContainer.getSectionWithName(L.CSections.CommentList.name).modify(annotation); }, @@ -284,15 +284,15 @@ L.ImpressTileLayer = L.CanvasTileLayer.extend({ var partMatch = textMsg.match(/[^\r\n]+/g); // only get the last matches var newPartHashes = partMatch.slice(partMatch.length - this._parts); - var refreshAnnotation = this._partHashes && (this._partHashes.length !== newPartHashes.length || !this._partHashes.every(function(element,i) { return element === newPartHashes[i]; })); - this._partHashes = newPartHashes; + var refreshAnnotation = app.impress.partHashes && (app.impress.partHashes.length !== newPartHashes.length || !app.impress.partHashes.every(function(element,i) { return element === newPartHashes[i]; })); + app.impress.partHashes = newPartHashes; this._hiddenSlides = new Set(command.hiddenparts); this._map.fire('updateparts', { selectedPart: this._selectedPart, selectedParts: this._selectedParts, parts: this._parts, docType: this._docType, - partNames: this._partHashes + partNames: app.impress.partHashes }); if (refreshAnnotation) app.socket.sendMessage('commandvalues command=.uno:ViewAnnotations');