Skip to content

Commit

Permalink
calc: use hashes for parts
Browse files Browse the repository at this point in the history
part number is not enough when adding/deleting/moving the sheets

fixes regression from commit 703dae0
Don't save position data when not switching sheets

1. Open Calc
2. in the current sheet scroll down a but and make some rows bigger
3. right-click on the sheet tab, insert sheet before

Result: resized rows are still visible
Expected: new sheet has equal small rows

Signed-off-by: Szymon Kłos <[email protected]>
Change-Id: I57fa45330a9ecc0bee7d91aa32e9aa0e2b4361d3
  • Loading branch information
eszkadev committed Aug 21, 2024
1 parent 0172da1 commit 4ed28ee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
20 changes: 19 additions & 1 deletion browser/src/control/Parts.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,33 @@
/* 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();
return;
}

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;
}

Expand Down
1 change: 1 addition & 0 deletions browser/src/docstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions browser/src/layer/tile/CalcTileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 4ed28ee

Please sign in to comment.