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() {
var chartRender = new ChartRender();
var worksheet = null;
var isViewerMode = null;
var drawingCtx = null;
var overlayCtx = null;
var shapeCtx = null;
var shapeOverlayCtx = null;
var aObjects = null;
var minImageWidth = 20;
var minImageHeight = 20;
......@@ -2003,6 +2006,8 @@ function DrawingObjects() {
drawingCtx = currentSheet.drawingCtx;
overlayCtx = currentSheet.overlayCtx;
shapeCtx = currentSheet.shapeCtx;
shapeOverlayCtx = currentSheet.shapeOverlayCtx;
isViewerMode = function() { return worksheet._trigger("getViewerMode"); };
aObjects = [];
......@@ -2032,10 +2037,6 @@ function DrawingObjects() {
}
}
_this.getWorkbook = function() {
return (worksheet ? worksheet.model.workbook : null);
}
_this.getDrawingObjects = function() {
return aObjects;
}
......@@ -2210,6 +2211,13 @@ function DrawingObjects() {
var index = i;
var obj = aObjects[i];
// Shape render
if ( obj.isGraphicObject() ) {
obj.graphicObject.draw(shapeCtx);
continue;
}
obj.normalizeMetrics();
obj.size.coeff = obj.getHeightFromTo(true) / obj.getWidthFromTo(true);
......@@ -2448,7 +2456,7 @@ function DrawingObjects() {
_t.move = { x: 0, y: 0, inAction: false };
_t.chart = new asc_CChart();
_t.shape = null; //new CShape(_t);
_t.graphicObject = null; // CShape or GroupShape
_t.flags = {
selected: false,
......@@ -2468,8 +2476,12 @@ function DrawingObjects() {
return _t.chart.type ? true : false;
}
_t.isShape = function() {
return _t.shape != null;
_t.isGraphicObject = function() {
return _t.graphicObject != null;
}
_t.getWorkbook = function() {
return (_t.worksheet ? _t.worksheet.model.workbook : null);
}
// Проверяет выход за границы
......@@ -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() {
var bResult = false;
......
......@@ -2059,17 +2059,16 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.isStartAddShape = true;
this.addShapePreset = sPreset;
if (is_apply)
{
//this.WordControl.m_oDrawingDocument.LockCursorType("crosshair");
if (is_apply) {
}
else
{
//editor.sync_EndAddShape();
//editor.sync_StartAddShapeCallback(false);
else {
}
},
asc_endAddShape: function() {
this.isStartAddShape = false;
},
// Cell interface
asc_getCellInfo: function (bExt) {
return this.wb.getWorksheet().getSelectionInfo(!!bExt);
......@@ -2818,6 +2817,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
// Shapes
prot["asc_startAddShape"] = prot.asc_startAddShape;
prot["asc_endAddShape"] = prot.asc_endAddShape;
// Cell interface
prot["asc_getCellInfo"] = prot.asc_getCellInfo;
......
......@@ -15,6 +15,8 @@ var STATES_ID_START_TRACK_NEW_SHAPE = 0x05;
var STATES_ID_BEGIN_TRACK_NEW_SHAPE = 0x06;
var STATES_ID_TRACK_NEW_SHAPE = 0x07;
var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
function NullState(drawingObjectsController, drawingObjects)
{
this.id = STATES_ID_NULL;
......@@ -80,7 +82,9 @@ function NullState(drawingObjectsController, drawingObjects)
{};
this.onMouseUp = function(e, x, y)
{}
{
asc.editor.asc_endAddShape();
}
}
function PreRotateState(drawingObjectsController, drawingObjects, majorObject)
......
......@@ -1058,6 +1058,12 @@
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"))
return;
......@@ -1190,6 +1196,14 @@
/** @param event {jQuery.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) {
this.isSelectMode = false;
this._changeSelectionDone(event);
......@@ -1233,6 +1247,13 @@
var coord = t._getCoordinates(event);
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) {
t._changeSelection(event, /*isSelectMode*/true);
return true;
......
......@@ -196,7 +196,12 @@
"canvasClick": function () {self.enableKeyEventsHandler(true);},
"autoFiltersClick": function () {self._onAutoFiltersClick.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) {
......@@ -648,6 +653,24 @@
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) {
var res = false;
var ws = this.getWorksheet();
......
......@@ -372,6 +372,8 @@
this.overlayCtx = this.buffers.overlay;
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.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;
......@@ -632,6 +634,7 @@
this._shiftVisibleRange();
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.shapeOverlayCtx.init(this.overlayCtx.ctx, this.overlayCtx.getWidth(0), this.overlayCtx.getHeight(0), this.overlayCtx.getWidth(3), this.overlayCtx.getHeight(3));
this.updateZoom = false;
} else {
......@@ -5026,6 +5029,9 @@
var lockInfo = undefined;
var isLocked = false;
if ( asc.editor.isStartAddShape )
return {cursor: kCurFillHandle, target: "shape", col: -1, row: -1};
var drawingInfo = this.objectRender.checkCursorDrawingObject(x, y);
if (drawingInfo && drawingInfo.cursor) {
// Возможно картинка с 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