Commit 819ec09e authored by Sergey Luzyanin's avatar Sergey Luzyanin

asc_addShapeOnSheet

parent ee6d36de
......@@ -2404,6 +2404,16 @@ var editor;
this.handlers.trigger("asc_onEndAddShape");
};
spreadsheet_api.prototype.asc_addShapeOnSheet = function(sPreset) {
if(this.wb){
var ws = this.wb.getWorksheet();
if(ws && ws.objectRender){
ws.objectRender.addShapeOnSheet(sPreset);
}
}
};
spreadsheet_api.prototype.asc_addOleObjectAction = function(sLocalUrl, sData, sApplicationId, fWidth, fHeight, nWidthPix, nHeightPix)
{
var _image = this.ImageLoader.LoadImage(AscCommon.getFullImageSrc2(sLocalUrl), 1);
......@@ -3555,6 +3565,7 @@ var editor;
prot["setEndPointHistory"] = prot.setEndPointHistory;
prot["asc_startAddShape"] = prot.asc_startAddShape;
prot["asc_endAddShape"] = prot.asc_endAddShape;
prot["asc_addShapeOnSheet"] = prot.asc_addShapeOnSheet;
prot["asc_isAddAutoshape"] = prot.asc_isAddAutoshape;
prot["asc_canAddShapeHyperlink"] = prot.asc_canAddShapeHyperlink;
prot["asc_canGroupGraphicsObjects"] = prot.asc_canGroupGraphicsObjects;
......
......@@ -1648,6 +1648,68 @@ function DrawingObjects() {
// Constructor
//-----------------------------------------------------------------------------------
_this.addShapeOnSheet = function(sType){
if(this.controller){
if (!_this.isViewerMode()) {
var oVisibleRange = worksheet.getVisibleRange();
_this.objectLocker.reset();
_this.objectLocker.addObjectId(AscCommon.g_oIdCounter.Get_NewId());
_this.objectLocker.checkObjects(function (bLock) {
if (bLock !== true)
return;
_this.controller.resetSelection();
var activeCell = worksheet.model.selectionRange.activeCell;
var metrics = {};
metrics.col = activeCell.col;
metrics.colOff = 0;
metrics.row = activeCell.row;
metrics.rowOff = 0;
var coordsFrom = _this.coordsManager.calculateCoords(metrics);
var ext_x, ext_y;
if(typeof AscFormat.SHAPE_EXT[sType] === "number")
{
ext_x = AscFormat.SHAPE_EXT[sType];
}
else
{
ext_x = 25.4;
}
if(typeof AscFormat.SHAPE_ASPECTS[sType] === "number")
{
var _aspect = AscFormat.SHAPE_ASPECTS[sType];
ext_y = ext_x/_aspect;
}
else
{
ext_y = ext_x;
}
History.Create_NewPoint();
var posX = pxToMm(coordsFrom.x) + MOVE_DELTA;
var posY = pxToMm(coordsFrom.y) + MOVE_DELTA;
var oTrack = new AscFormat.NewShapeTrack(sType, posX, posY, _this.controller.getTheme(), null, null, null, 0);
oTrack.track({}, posX + ext_x, posY + ext_y);
var oShape = oTrack.getShape(false, _this.drawingDocument, null);
oShape.setWorksheet(worksheet.model);
oShape.addToDrawingObjects();
worksheet.setSelectionShape(true);
_this.controller.startRecalculate();
});
}
}
};
_this.getScrollOffset = function()
{
return scrollOffset;
......
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