Commit aa919687 authored by Dmitry.Vikulov's avatar Dmitry.Vikulov Committed by Alexander.Trofimov

- Перехват событий мыши при добавлении автофигуры

- addGraphicObject = function(x, y, extX, extY, flipH, flipV, presetGeom)
- +shapeOverlayCtx
- getWorkbook для DrawingBase

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47539 954022d7-b5bf-4e40-9824-e11837661b57
parent 594d9992
...@@ -1971,9 +1971,12 @@ function DrawingObjects() { ...@@ -1971,9 +1971,12 @@ function DrawingObjects() {
var chartRender = new ChartRender(); var chartRender = new ChartRender();
var worksheet = null; var worksheet = null;
var isViewerMode = null; var isViewerMode = null;
var drawingCtx = null; var drawingCtx = null;
var overlayCtx = null; var overlayCtx = null;
var shapeCtx = null; var shapeCtx = null;
var shapeOverlayCtx = null;
var aObjects = null; var aObjects = null;
var minImageWidth = 20; var minImageWidth = 20;
var minImageHeight = 20; var minImageHeight = 20;
...@@ -2003,6 +2006,8 @@ function DrawingObjects() { ...@@ -2003,6 +2006,8 @@ function DrawingObjects() {
drawingCtx = currentSheet.drawingCtx; drawingCtx = currentSheet.drawingCtx;
overlayCtx = currentSheet.overlayCtx; overlayCtx = currentSheet.overlayCtx;
shapeCtx = currentSheet.shapeCtx; shapeCtx = currentSheet.shapeCtx;
shapeOverlayCtx = currentSheet.shapeOverlayCtx;
isViewerMode = function() { return worksheet._trigger("getViewerMode"); }; isViewerMode = function() { return worksheet._trigger("getViewerMode"); };
aObjects = []; aObjects = [];
...@@ -2032,10 +2037,6 @@ function DrawingObjects() { ...@@ -2032,10 +2037,6 @@ function DrawingObjects() {
} }
} }
_this.getWorkbook = function() {
return (worksheet ? worksheet.model.workbook : null);
}
_this.getDrawingObjects = function() { _this.getDrawingObjects = function() {
return aObjects; return aObjects;
} }
...@@ -2210,6 +2211,13 @@ function DrawingObjects() { ...@@ -2210,6 +2211,13 @@ function DrawingObjects() {
var index = i; var index = i;
var obj = aObjects[i]; var obj = aObjects[i];
// Shape render
if ( obj.isGraphicObject() ) {
obj.graphicObject.draw(shapeCtx);
continue;
}
obj.normalizeMetrics(); obj.normalizeMetrics();
obj.size.coeff = obj.getHeightFromTo(true) / obj.getWidthFromTo(true); obj.size.coeff = obj.getHeightFromTo(true) / obj.getWidthFromTo(true);
...@@ -2448,7 +2456,7 @@ function DrawingObjects() { ...@@ -2448,7 +2456,7 @@ function DrawingObjects() {
_t.move = { x: 0, y: 0, inAction: false }; _t.move = { x: 0, y: 0, inAction: false };
_t.chart = new asc_CChart(); _t.chart = new asc_CChart();
_t.shape = null; //new CShape(_t); _t.graphicObject = null; // CShape or GroupShape
_t.flags = { _t.flags = {
selected: false, selected: false,
...@@ -2468,8 +2476,12 @@ function DrawingObjects() { ...@@ -2468,8 +2476,12 @@ function DrawingObjects() {
return _t.chart.type ? true : false; return _t.chart.type ? true : false;
} }
_t.isShape = function() { _t.isGraphicObject = function() {
return _t.shape != null; return _t.graphicObject != null;
}
_t.getWorkbook = function() {
return (_t.worksheet ? _t.worksheet.model.workbook : null);
} }
// Проверяет выход за границы // Проверяет выход за границы
...@@ -3241,6 +3253,15 @@ function DrawingObjects() { ...@@ -3241,6 +3253,15 @@ function DrawingObjects() {
} }
} }
_this.addGraphicObject = function(x, y, extX, extY, flipH, flipV, presetGeom) {
var obj = _this.createDrawingObject();
obj.graphicObject = new CShape(_this);
obj.graphicObject.initDefault(x, y, extX, extY, flipH, flipV, presetGeom);
aObjects.push(obj);
_this.showDrawingObjects(false);
}
_this.deleteSelectedDrawingObject = function() { _this.deleteSelectedDrawingObject = function() {
var bResult = false; var bResult = false;
......
...@@ -2059,17 +2059,16 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -2059,17 +2059,16 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.isStartAddShape = true; this.isStartAddShape = true;
this.addShapePreset = sPreset; this.addShapePreset = sPreset;
if (is_apply) if (is_apply) {
{
//this.WordControl.m_oDrawingDocument.LockCursorType("crosshair");
} }
else else {
{
//editor.sync_EndAddShape();
//editor.sync_StartAddShapeCallback(false);
} }
}, },
asc_endAddShape: function() {
this.isStartAddShape = false;
},
// Cell interface // Cell interface
asc_getCellInfo: function (bExt) { asc_getCellInfo: function (bExt) {
return this.wb.getWorksheet().getSelectionInfo(!!bExt); return this.wb.getWorksheet().getSelectionInfo(!!bExt);
...@@ -2818,6 +2817,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -2818,6 +2817,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
// Shapes // Shapes
prot["asc_startAddShape"] = prot.asc_startAddShape; prot["asc_startAddShape"] = prot.asc_startAddShape;
prot["asc_endAddShape"] = prot.asc_endAddShape;
// Cell interface // Cell interface
prot["asc_getCellInfo"] = prot.asc_getCellInfo; prot["asc_getCellInfo"] = prot.asc_getCellInfo;
......
...@@ -15,6 +15,8 @@ var STATES_ID_START_TRACK_NEW_SHAPE = 0x05; ...@@ -15,6 +15,8 @@ var STATES_ID_START_TRACK_NEW_SHAPE = 0x05;
var STATES_ID_BEGIN_TRACK_NEW_SHAPE = 0x06; var STATES_ID_BEGIN_TRACK_NEW_SHAPE = 0x06;
var STATES_ID_TRACK_NEW_SHAPE = 0x07; var STATES_ID_TRACK_NEW_SHAPE = 0x07;
var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
function NullState(drawingObjectsController, drawingObjects) function NullState(drawingObjectsController, drawingObjects)
{ {
this.id = STATES_ID_NULL; this.id = STATES_ID_NULL;
...@@ -80,7 +82,9 @@ function NullState(drawingObjectsController, drawingObjects) ...@@ -80,7 +82,9 @@ function NullState(drawingObjectsController, drawingObjects)
{}; {};
this.onMouseUp = function(e, x, y) this.onMouseUp = function(e, x, y)
{} {
asc.editor.asc_endAddShape();
}
} }
function PreRotateState(drawingObjectsController, drawingObjects, majorObject) function PreRotateState(drawingObjectsController, drawingObjects, majorObject)
......
...@@ -1058,6 +1058,12 @@ ...@@ -1058,6 +1058,12 @@
this.handlers.trigger("setShiftKey", event.shiftKey); this.handlers.trigger("setShiftKey", event.shiftKey);
// shapes
if ( asc.editor.isStartAddShape ) {
t.handlers.trigger("shapeMouseDown", event, coord.x, coord.y);
return;
}
if (t.handlers.trigger("isGlobalLockEditCell")) if (t.handlers.trigger("isGlobalLockEditCell"))
return; return;
...@@ -1190,6 +1196,14 @@ ...@@ -1190,6 +1196,14 @@
/** @param event {jQuery.Event} */ /** @param event {jQuery.Event} */
_onMouseUp: function (event) { _onMouseUp: function (event) {
// shapes
var coord = this._getCoordinates(event);
if ( asc.editor.isStartAddShape ) {
this.handlers.trigger("shapeMouseUp", event, coord.x, coord.y);
return;
}
if (this.isSelectMode) { if (this.isSelectMode) {
this.isSelectMode = false; this.isSelectMode = false;
this._changeSelectionDone(event); this._changeSelectionDone(event);
...@@ -1233,6 +1247,13 @@ ...@@ -1233,6 +1247,13 @@
var coord = t._getCoordinates(event); var coord = t._getCoordinates(event);
t.hasCursor = true; t.hasCursor = true;
// shapes
if ( asc.editor.isStartAddShape ) {
t.handlers.trigger("shapeMouseMove", event, coord.x, coord.y);
t.handlers.trigger("updateWorksheet", t.element[0], coord.x, coord.y, event.ctrlKey, function(info){t.targetInfo = info;});
return;
}
if (t.isSelectMode) { if (t.isSelectMode) {
t._changeSelection(event, /*isSelectMode*/true); t._changeSelection(event, /*isSelectMode*/true);
return true; return true;
......
...@@ -196,7 +196,12 @@ ...@@ -196,7 +196,12 @@
"canvasClick": function () {self.enableKeyEventsHandler(true);}, "canvasClick": function () {self.enableKeyEventsHandler(true);},
"autoFiltersClick": function () {self._onAutoFiltersClick.apply(self, arguments);}, "autoFiltersClick": function () {self._onAutoFiltersClick.apply(self, arguments);},
"commentCellClick": function () {self._onCommentCellClick.apply(self, arguments);}, "commentCellClick": function () {self._onCommentCellClick.apply(self, arguments);},
"isGlobalLockEditCell": function () {return self.collaborativeEditing.getGlobalLockEditCell();} "isGlobalLockEditCell": function () {return self.collaborativeEditing.getGlobalLockEditCell();},
// shapes
"shapeMouseDown": function () {self._onShapeMouseDown.apply(self, arguments);},
"shapeMouseMove": function () {self._onShapeMouseMove.apply(self, arguments);},
"shapeMouseUp": function () {self._onShapeMouseUp.apply(self, arguments);}
}); });
this.model.handlers.add("cleanCellCache", function (wsId, range, canChangeColWidth) { this.model.handlers.add("cleanCellCache", function (wsId, range, canChangeColWidth) {
...@@ -648,6 +653,24 @@ ...@@ -648,6 +653,24 @@
ws.cellCommentator.asc_showComment(comments[0].asc_getId()); ws.cellCommentator.asc_showComment(comments[0].asc_getId());
}, },
_onShapeMouseDown: function (e, x, y) {
var ws = this.getWorksheet();
//console.log("_onShapeMouseDown");
ws.objectRender.controller.onMouseDown(e, x, y);
},
_onShapeMouseMove: function (e, x, y) {
var ws = this.getWorksheet();
//console.log("_onShapeMouseMove");
ws.objectRender.controller.onMouseMove(e, x, y);
},
_onShapeMouseUp: function (e, x, y) {
var ws = this.getWorksheet();
//console.log("_onShapeMouseUp");
ws.objectRender.controller.onMouseUp(e, x, y);
},
_onMouseDblClick: function (x, y, isHideCursor, isCoord, callback) { _onMouseDblClick: function (x, y, isHideCursor, isCoord, callback) {
var res = false; var res = false;
var ws = this.getWorksheet(); var ws = this.getWorksheet();
......
...@@ -372,6 +372,8 @@ ...@@ -372,6 +372,8 @@
this.overlayCtx = this.buffers.overlay; this.overlayCtx = this.buffers.overlay;
this.shapeCtx = new CGraphics(); this.shapeCtx = new CGraphics();
this.shapeCtx.init(this.drawingCtx.ctx, this.drawingCtx.getWidth(0), this.drawingCtx.getHeight(0), this.drawingCtx.getWidth(3), this.drawingCtx.getHeight(3)); this.shapeCtx.init(this.drawingCtx.ctx, this.drawingCtx.getWidth(0), this.drawingCtx.getHeight(0), this.drawingCtx.getWidth(3), this.drawingCtx.getHeight(3));
this.shapeOverlayCtx = new CGraphics();
this.shapeOverlayCtx.init(this.overlayCtx.ctx, this.overlayCtx.getWidth(0), this.overlayCtx.getHeight(0), this.overlayCtx.getWidth(3), this.overlayCtx.getHeight(3));
this.stringRender = stringRender; this.stringRender = stringRender;
...@@ -632,6 +634,7 @@ ...@@ -632,6 +634,7 @@
this._shiftVisibleRange(); this._shiftVisibleRange();
this.cellCommentator.updateCommentPosition(); this.cellCommentator.updateCommentPosition();
this.shapeCtx.init(this.drawingCtx.ctx, this.drawingCtx.getWidth(0), this.drawingCtx.getHeight(0), this.drawingCtx.getWidth(3), this.drawingCtx.getHeight(3)); this.shapeCtx.init(this.drawingCtx.ctx, this.drawingCtx.getWidth(0), this.drawingCtx.getHeight(0), this.drawingCtx.getWidth(3), this.drawingCtx.getHeight(3));
this.shapeOverlayCtx.init(this.overlayCtx.ctx, this.overlayCtx.getWidth(0), this.overlayCtx.getHeight(0), this.overlayCtx.getWidth(3), this.overlayCtx.getHeight(3));
this.updateZoom = false; this.updateZoom = false;
} else { } else {
...@@ -5026,6 +5029,9 @@ ...@@ -5026,6 +5029,9 @@
var lockInfo = undefined; var lockInfo = undefined;
var isLocked = false; var isLocked = false;
if ( asc.editor.isStartAddShape )
return {cursor: kCurFillHandle, target: "shape", col: -1, row: -1};
var drawingInfo = this.objectRender.checkCursorDrawingObject(x, y); var drawingInfo = this.objectRender.checkCursorDrawingObject(x, y);
if (drawingInfo && drawingInfo.cursor) { if (drawingInfo && drawingInfo.cursor) {
// Возможно картинка с lock // Возможно картинка с lock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment