diff --git a/browser/src/control/Parts.js b/browser/src/control/Parts.js index 5c5d76f66403..2c8e297fec5d 100644 --- a/browser/src/control/Parts.js +++ b/browser/src/control/Parts.js @@ -15,6 +15,11 @@ /* global app _ cool */ L.Map.include({ + /* + @param {number} part - Target part + @param {boolean} external - Do we need to inform a core + @param {boolean} calledFromSetPartHandler - Requests a scroll to the cursor + */ setPart: function (part, external, calledFromSetPartHandler) { if (cool.Comment.isAnyEdit()) { cool.CommentSection.showCommentEditingWarning(); @@ -22,8 +27,21 @@ L.Map.include({ } var docLayer = this._docLayer; + var docType = docLayer._docType; + var isTheSamePart = true; - if (docLayer._selectedPart === part) { + // check hashes, when we add/delete/move parts they can have the same part number as before + if (docType === 'spreadsheet') { + isTheSamePart = + app.calc.partHashes[docLayer._prevSelectedPart] === app.calc.partHashes[part]; + } else if (docType === 'presentation' || docType === 'drawing') { + isTheSamePart = + app.impress.partHashes[docLayer._prevSelectedPart] === app.impress.partHashes[part]; + } else if (docType !== 'text') { + console.error('Unknown docType: ' + docType); + } + + if (docLayer._selectedPart === part && isTheSamePart) { return; } diff --git a/browser/src/docstate.js b/browser/src/docstate.js index 5977217b5f75..e5ffada333e7 100644 --- a/browser/src/docstate.js +++ b/browser/src/docstate.js @@ -28,6 +28,7 @@ window.app = { cellCursorRectangle: null, // To be assigned SimpleRectangle. otherCellCursors: {}, splitCoordinate: null, // SimplePoint. + partHashes: null, // hashes used to distinguish parts (we use sheet name) }, impress: { partHashes: null, // hashes used to distinguish parts diff --git a/browser/src/layer/tile/CalcTileLayer.js b/browser/src/layer/tile/CalcTileLayer.js index b79bd560e415..f30bf87715e3 100644 --- a/browser/src/layer/tile/CalcTileLayer.js +++ b/browser/src/layer/tile/CalcTileLayer.js @@ -444,6 +444,7 @@ L.CalcTileLayer = L.CanvasTileLayer.extend({ // only get the last matches var oldPartNames = this._partNames; this._partNames = partNames.slice(partNames.length - this._parts); + app.calc.partHashes = this._partNames; // TODO: generate unique hash on the core side // if the number of parts, or order has changed then refresh comment positions if (oldPartNames !== this._partNames) { app.socket.sendMessage('commandvalues command=.uno:ViewAnnotationsPosition');