Skip to content

Commit

Permalink
Fix bug #72807
Browse files Browse the repository at this point in the history
  • Loading branch information
KhromovNikita authored and KirillovIlya committed Jan 28, 2025
1 parent 6e30b0b commit 756685c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
27 changes: 26 additions & 1 deletion pdf/src/annotations/freeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
this.recalcInfo.recalculateGeometry = true;
this.isInTextBox = false; // флаг, что внутри текстбокса
this.defaultPerpLength = 12; // длина выступающего перпендикуляра callout по умолчанию

this.lastClickCoords = {}; // for onPreMove
};
CAnnotationFreeText.prototype.constructor = CAnnotationFreeText;
AscFormat.InitClass(CAnnotationFreeText, AscFormat.CGroupShape, AscDFH.historyitem_type_Pdf_Annot_FreeText);
Expand Down Expand Up @@ -955,6 +957,9 @@
let oDoc = this.GetDocument();
let oController = oDoc.GetController();

this.lastClickCoords.X = x;
this.lastClickCoords.Y = y;

if (this.IsInTextBox() == false) {
if (oController.selectedObjects.length > 1) {
AscPDF.CAnnotationBase.prototype.onMouseDown.call(this, x, y, e);
Expand Down Expand Up @@ -1371,14 +1376,34 @@
}
};
CAnnotationFreeText.prototype.onAfterMove = function() {
this.onMouseDown();
let oDoc = this.GetDocument();
let oController = oDoc.GetController();
let _t = this;
this.lastClickCoords.X = undefined;
this.lastClickCoords.Y = undefined;

// селектим все фигуры в группе (кроме перпендикулярной линии) если до сих пор не заселекчены
if (oController.selectedObjects.length == 1) {
oController.selection.groupSelection = this;
}

this.selectedObjects.length = 0;
this.spTree.forEach(function(sp) {
if (!(sp instanceof AscPDF.CPdfConnectionShape)) {
sp.selectStartPage = _t.selectStartPage;
_t.selectedObjects.push(sp);
}
});
};
CAnnotationFreeText.prototype.onPreMove = function(x, y, e) {
let oViewer = editor.getDocumentRenderer();
let oDrawingObjects = oViewer.DrawingObjects;

this.selectStartPage = this.GetPage();

x = this.lastClickCoords.X;
y = this.lastClickCoords.Y;

// координаты клика на странице в MM
var pageObject = oViewer.getPageByCoords2(x, y);
if (!pageObject)
Expand Down
15 changes: 0 additions & 15 deletions pdf/src/annotations/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,21 +336,6 @@
CAnnotationText.prototype.IsNeedDrawFromStream = function() {
return false;
};
CAnnotationText.prototype.onMouseDown = function(x, y, e) {
let oViewer = Asc.editor.getDocumentRenderer();
let oDrawingObjects = oViewer.DrawingObjects;

this.selectStartPage = this.GetPage();

let pageObject = oViewer.getPageByCoords2(x, y);
if (!pageObject)
return false;

let X = pageObject.x;
let Y = pageObject.y;

oDrawingObjects.OnMouseDown(e, X, Y, pageObject.index);
};
CAnnotationText.prototype.IsComment = function() {
return true;
};
Expand Down
1 change: 1 addition & 0 deletions pdf/src/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@ var CPresentation = CPresentation || function(){};
let isSameType = (oCurObject && oFloatObject) && (oCurObject.IsAnnot() && oFloatObject.IsAnnot() || oCurObject.IsDrawing() && oFloatObject.IsDrawing());
// докидываем в селект
if (e.CtrlKey && (oCurObject && oFloatObject) && (oCurObject != oFloatObject) && isSameType) {
oController.selection.groupSelection = null;
oController.selectObject(oFloatObject, oFloatObject.GetPage());
return;
}
Expand Down

0 comments on commit 756685c

Please sign in to comment.