diff --git a/common/Drawings/CommonController.js b/common/Drawings/CommonController.js index 640df19d31..4c3eb79b94 100644 --- a/common/Drawings/CommonController.js +++ b/common/Drawings/CommonController.js @@ -913,6 +913,7 @@ return { objectId: drawing.Get_Id(), cursorType: "text", + content: drawing.getDocContent ? drawing.getDocContent() : null, bMarker: false, hyperlink: oHyperlink, macro: null @@ -1878,8 +1879,8 @@ this.changeCurrentState(new AscFormat.TextAddState(this, object, x, y, e.Button)); return true; } else { - var ret = {objectId: object.Get_Id(), cursorType: "text"}; content = object.getDocContent(); + var ret = {objectId: object.Get_Id(), cursorType: "text", content: content}; invert_transform_text = object.invertTransformText; if (content && invert_transform_text) { tx = invert_transform_text.TransformPointX(x, y); @@ -1929,6 +1930,29 @@ }, + + getParagraphByXY: function (x, y, pageIndex) { + let ret; + this.handleEventMode = HANDLE_EVENT_MODE_CURSOR; + ret = this.curState.onMouseDown(AscCommon.global_mouseEvent, x, y, pageIndex); + this.handleEventMode = HANDLE_EVENT_MODE_HANDLE; + if (ret && ret.content) { + let _x = x; + let _y = y; + let transform = ret.content.GetFullTransform(); + if (transform) { + let invertTransform = AscCommon.global_MatrixTransformer.Invert(transform); + _x = invertTransform.TransformPointX(x, y); + _y = invertTransform.TransformPointY(x, y); + } + let index = ret.content.Internal_GetContentPosByXY(_x, _y, 0); + if (!AscFormat.isRealNumber(index)) + return null; + return ret.content.GetElement(index); + } + return null; + }, + isSlideShow: function () { if (this.drawingObjects && this.drawingObjects.cSld) { return editor && editor.WordControl && editor.WordControl.DemonstrationManager && editor.WordControl.DemonstrationManager.Mode; diff --git a/common/Drawings/DrawingObjectsHandlers.js b/common/Drawings/DrawingObjectsHandlers.js index a2b6868dc9..920a7b2f15 100644 --- a/common/Drawings/DrawingObjectsHandlers.js +++ b/common/Drawings/DrawingObjectsHandlers.js @@ -800,7 +800,7 @@ function handleGroup(drawing, drawingObjectsController, e, x, y, group, pageInde content.UpdateCursorType(tx, ty, 0); } } - return {objectId: drawing.Get_Id(), cursorType: "text"}; + return {objectId: drawing.Get_Id(), cursorType: "text", content: title.getDocContent ? title.getDocContent() : null}; } } } @@ -1622,7 +1622,7 @@ function handleInternalChart(drawing, drawingObjectsController, e, x, y, group, content.UpdateCursorType(tx, ty, 0); } } - return {objectId: drawing.Get_Id(), cursorType: "text", title: oDLbl}; + return {objectId: drawing.Get_Id(), cursorType: "text", title: oDLbl, content: oDLbl.getDocContent()}; } } } @@ -1712,7 +1712,7 @@ function handleInternalChart(drawing, drawingObjectsController, e, x, y, group, content.UpdateCursorType(tx, ty, 0); } } - return {objectId: drawing.Get_Id(), cursorType: "text", title: oTrendlineLbl}; + return {objectId: drawing.Get_Id(), cursorType: "text", title: oTrendlineLbl, content: oTrendlineLbl.getDocContent()}; } } } @@ -1828,7 +1828,7 @@ function handleInternalChart(drawing, drawingObjectsController, e, x, y, group, content.UpdateCursorType(tx, ty, 0); } } - return {objectId: drawing.Get_Id(), cursorType: "text", title: title}; + return {objectId: drawing.Get_Id(), cursorType: "text", title: title, content: title.getDocContent()}; } } } @@ -2286,7 +2286,7 @@ function handleFloatTable(drawing, drawingObjectsController, e, x, y, group, pag else { drawing.updateCursorType(x, y, e); - return {objectId: drawing.Get_Id(), cursorType: "text", updated: true}; + return {objectId: drawing.Get_Id(), cursorType: "text", updated: true, content: drawing.getDocContent && drawing.getDocContent()}; } } } diff --git a/common/Drawings/States.js b/common/Drawings/States.js index f8d98116ff..36a44b4418 100644 --- a/common/Drawings/States.js +++ b/common/Drawings/States.js @@ -2100,7 +2100,7 @@ TextAddState.prototype = && this.majorObject.chart.getObjectType() === AscDFH.historyitem_type_ChartSpace) { sId = this.majorObject.chart.Id; } - return {objectId: sId, cursorType: "text"}; + return {objectId: sId, cursorType: "text", content: this.majorObject.getDocContent && this.majorObject.getDocContent()}; } }, onMouseMove: function(e, x, y, pageIndex) diff --git a/pdf/src/GraphicObjects.js b/pdf/src/GraphicObjects.js index 2d0f63da08..92dc785c31 100644 --- a/pdf/src/GraphicObjects.js +++ b/pdf/src/GraphicObjects.js @@ -1218,7 +1218,7 @@ return true; } else { - var ret = { objectId: object.Get_Id(), cursorType: "text" }; + var ret = { objectId: object.Get_Id(), cursorType: "text", content: object.getDocContent && object.getDocContent() }; content = object.getDocContent(); invert_transform_text = object.invertTransformText; if (content && invert_transform_text) { diff --git a/word/Editor/GraphicObjects/DrawingStates.js b/word/Editor/GraphicObjects/DrawingStates.js index aec517dac7..3ef2a036ee 100644 --- a/word/Editor/GraphicObjects/DrawingStates.js +++ b/word/Editor/GraphicObjects/DrawingStates.js @@ -2642,11 +2642,11 @@ TextAddState.prototype = } } if(oCheckObject && oCheckObject.parent){ - return {cursorType: "default", objectId: oCheckObject.Get_Id()}; + return {cursorType: "default", objectId: oCheckObject.Get_Id(), content: this.majorObject.getDocContent && this.majorObject.getDocContent()}; } else if (Asc.editor.isPdfEditor()) { if (oCheckObject.IsShape()) { - return {cursorType: "text", objectId: oCheckObject.Get_Id()}; + return {cursorType: "text", objectId: oCheckObject.Get_Id(), content: this.majorObject.getDocContent && this.majorObject.getDocContent()}; } } } diff --git a/word/Editor/GraphicObjects/GraphicObjects.js b/word/Editor/GraphicObjects/GraphicObjects.js index 22b8faf315..ef3c408308 100644 --- a/word/Editor/GraphicObjects/GraphicObjects.js +++ b/word/Editor/GraphicObjects/GraphicObjects.js @@ -3821,7 +3821,7 @@ CGraphicObjects.prototype = return false; }, - + getParagraphByXY: DrawingObjectsController.prototype.getParagraphByXY, checkTargetSelection: function() {