Skip to content

Commit

Permalink
impress: move part hashes to the docstate
Browse files Browse the repository at this point in the history
Signed-off-by: Szymon Kłos <[email protected]>
Change-Id: Ib9007dc3d4b2baec6280066f0b9852cd5a435c5f
  • Loading branch information
eszkadev committed Aug 21, 2024
1 parent 828fb49 commit 0172da1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion browser/src/canvas/sections/CommentListSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions browser/src/canvas/sections/CommentSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions browser/src/docstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions browser/src/layer/tile/ImpressTileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
},
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 0172da1

Please sign in to comment.