Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a section and remove latlng and leaflet usage from impress&draw c… #10921

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion browser/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ COOL_JS_LST =\
src/canvas/CanvasSectionProps.js \
src/canvas/CanvasSectionContainer.ts \
src/canvas/CanvasSectionObject.ts \
src/canvas/sections/HTMLObjectSection.ts \
src/canvas/sections/CommentMarkerSubSection.ts \
src/canvas/sections/CommentSection.ts \
src/canvas/sections/CommentListSection.ts \
src/canvas/sections/CalcGridSection.ts \
Expand All @@ -273,7 +275,6 @@ COOL_JS_LST =\
src/canvas/sections/PreloadMapSection.ts \
src/canvas/sections/TilesSection.ts \
src/canvas/sections/AutoFillMarkerSection.ts \
src/canvas/sections/HTMLObjectSection.ts \
src/canvas/sections/URLPopUpSection.ts \
src/canvas/sections/InvalidationRectangleSection.ts \
src/canvas/sections/ShapeHandlesSection.ts \
Expand Down Expand Up @@ -947,6 +948,7 @@ pot:
admin/src/Util.js \
js/global.js \
src/canvas/sections/CommentListSection.ts \
src/canvas/sections/CommentMarkerSubSection.ts \
src/canvas/sections/CommentSection.ts \
src/canvas/sections/ShapeHandlesSection.ts \
src/canvas/sections/URLPopUpSection.ts \
Expand Down
153 changes: 78 additions & 75 deletions browser/src/canvas/sections/CommentListSection.ts

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions browser/src/canvas/sections/CommentMarkerSubSection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/* global Proxy _ */
/*
* Copyright the Collabora Online contributors.
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

/*
This class is for Impress's and Draw's comment markers.
This is a sub section, needs to know about the parent section.
*/

class CommentMarkerSubSection extends HTMLObjectSection {
constructor(
sectionName: string,
objectWidth: number,
objectHeight: number,
documentPosition: cool.SimplePoint,
extraClass: string = '',
showSection: boolean = false,
parentSection: any, // Parent section.
data: any, // Parent section's data.
) {
super(
sectionName,
objectWidth,
objectHeight,
documentPosition,
extraClass,
showSection,
);
this.sectionProperties.parentSection = parentSection;
this.sectionProperties.data = data;
this.sectionProperties.dragStartPosition = null;
}

private sendAnnotationPositionChange(newPosition: number[]): void {
if (app.file.fileBasedView) {
app.map.setPart(this.sectionProperties.docLayer._selectedPart, false);
newPosition[1] -= this.sectionProperties.data.yAddition;
}

const comment = {
Id: {
type: 'string',
value: this.sectionProperties.data.id,
},
PositionX: {
type: 'int32',
value: newPosition[0],
},
PositionY: {
type: 'int32',
value: newPosition[1],
},
};
app.map.sendUnoCommand('.uno:EditAnnotation', comment);

if (app.file.fileBasedView) app.setPart(0, false);
}

onMouseMove(
point: Array<number>,
dragDistance: Array<number>,
e: MouseEvent,
): void {
if (this.sectionProperties.parentSection === null) return;

if (app.sectionContainer.isDraggingSomething()) {
(<any>window).IgnorePanning = true;

if (this.sectionProperties.parent === null) return;

if (this.sectionProperties.dragStartPosition === null)
this.sectionProperties.dragStartPosition = this.position.slice();

this.setPosition(
this.sectionProperties.dragStartPosition[0] + dragDistance[0],
this.sectionProperties.dragStartPosition[1] + dragDistance[1],
);
}
}

onDragEnd(): void {
(<any>window).IgnorePanning = undefined;

this.sectionProperties.dragStartPosition = null;

const twips = [
this.position[0] * app.pixelsToTwips,
this.position[1] * app.pixelsToTwips,
];

this.sendAnnotationPositionChange(twips);
}

onClick(point: number[], e: MouseEvent): void {
e.stopPropagation();
this.stopPropagating();
this.sectionProperties.parentSection.sectionProperties.commentListSection.selectById(
this.sectionProperties.data.id,
);
}

onMouseDown(point: number[], e: MouseEvent): void {
e.stopPropagation();
this.stopPropagating();
}

onMouseUp(point: number[], e: MouseEvent): void {
e.stopPropagation();
if (this.containerObject.isDraggingSomething()) {
this.stopPropagating();
this.onDragEnd();
}
}
}

app.definitions.commentMarkerSubSection = CommentMarkerSubSection;
Loading
Loading