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

- setRasterImage для CImage

- смена src картинки по URL и через файл
- api: asc_changeImageFromFile

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48227 954022d7-b5bf-4e40-9824-e11837661b57
parent 2c68cbe6
...@@ -3210,8 +3210,14 @@ function DrawingObjects() { ...@@ -3210,8 +3210,14 @@ function DrawingObjects() {
sheetId = data["input"]["sheetId"]; sheetId = data["input"]["sheetId"];
var url = data["url"]; var url = data["url"];
if (sheetId == worksheet.model.getId()) if (sheetId == worksheet.model.getId()) {
if ( api.isImageChangeUrl ) {
_this.editImageDrawingObject(url);
api.isImageChangeUrl = false;
}
else
_this.addImageDrawingObject(url, false, null); _this.addImageDrawingObject(url, false, null);
}
else else
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage); worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
} }
...@@ -3726,6 +3732,39 @@ function DrawingObjects() { ...@@ -3726,6 +3732,39 @@ function DrawingObjects() {
} }
} }
_this.editImageDrawingObject = function(imageUrl) {
if ( imageUrl && (_this.controller.selectedObjects.length == 1) ) {
var drawingObject = _this.controller.selectedObjects[0].drawingBase;
if ( drawingObject.graphicObject.isImage() ) {
var _image = api.ImageLoader.LoadImage(imageUrl, 1);
if (null != _image) {
addImageObject(_image);
}
else {
_this.asyncImageEndLoaded = function(_image) {
addImageObject(_image);
}
}
function addImageObject(_image) {
if ( !_image.Image ) {
worksheet.model.workbook.handlers.trigger("asc_onError", c_oAscError.ID.UplImageUrl, c_oAscError.Level.NoCritical);
}
else {
drawingObject.graphicObject.setRasterImage(_image.src);
_this.showDrawingObjects(true);
_this.selectGraphicObject();
}
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
}
}
}
_this.addChartDrawingObject = function(chart, bWithoutHistory, options) { _this.addChartDrawingObject = function(chart, bWithoutHistory, options) {
if (isViewerMode()) if (isViewerMode())
......
...@@ -115,6 +115,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -115,6 +115,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.ImageLoader = window.g_image_loader; this.ImageLoader = window.g_image_loader;
this.ImageLoader.put_Api(this); this.ImageLoader.put_Api(this);
this.shapeElementId = null; this.shapeElementId = null;
this.isImageChangeUrl = false;
/**************************************/ /**************************************/
...@@ -2146,6 +2147,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -2146,6 +2147,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.shapeElementId = elementId; this.shapeElementId = elementId;
}, },
asc_changeImageFromFile: function() {
this.isImageChangeUrl = true;
this.asc_showImageFileDialog();
},
asyncImageStartLoaded: function() { asyncImageStartLoaded: function() {
}, },
...@@ -2951,6 +2957,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -2951,6 +2957,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
prot["asc_getOriginalImageSize"] = prot.asc_getOriginalImageSize; prot["asc_getOriginalImageSize"] = prot.asc_getOriginalImageSize;
prot["asc_changeShapeType"] = prot.asc_changeShapeType; prot["asc_changeShapeType"] = prot.asc_changeShapeType;
prot["asc_setInterfaceDrawImagePlaceShape"] = prot.asc_setInterfaceDrawImagePlaceShape; prot["asc_setInterfaceDrawImagePlaceShape"] = prot.asc_setInterfaceDrawImagePlaceShape;
prot["asc_changeImageFromFile"] = prot.asc_changeImageFromFile;
// Cell interface // Cell interface
prot["asc_getCellInfo"] = prot.asc_getCellInfo; prot["asc_getCellInfo"] = prot.asc_getCellInfo;
......
...@@ -544,7 +544,12 @@ DrawingObjectsController.prototype = ...@@ -544,7 +544,12 @@ DrawingObjectsController.prototype =
if (isRealObject(properties) || isRealObject(props)) if (isRealObject(properties) || isRealObject(props))
{ {
var arr_pages = []; if (props.ImageUrl != undefined && props.ImageUrl != null && props.ImageUrl != "")
{
this.drawingObjects.editImageDrawingObject(props.ImageUrl);
}
else
{
if (isRealObject(props) && typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign)) if (isRealObject(props) && typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign))
{ {
if (this.curState.id === STATES_ID_TEXT_ADD) if (this.curState.id === STATES_ID_TEXT_ADD)
...@@ -564,17 +569,6 @@ DrawingObjectsController.prototype = ...@@ -564,17 +569,6 @@ DrawingObjectsController.prototype =
var ArrGlyph = this.selectedObjects; var ArrGlyph = this.selectedObjects;
for (var i = 0; i< ArrGlyph.length; ++i) for (var i = 0; i< ArrGlyph.length; ++i)
{ {
//if(false === this.document.Document_Is_SelectionLocked(changestype_Drawing_Props, {Type : changestype_2_Element_and_Type , Element : ArrGlyph[i].Parent, CheckType : changestype_Paragraph_Content} ))
{
/*var cur_page_index = ArrGlyph[i].pageIndex;
for (var j = 0; j < arr_pages.length; ++j)
{
if(arr_pages[j] === cur_page_index)
break;
}
if (j === arr_pages.length)
arr_pages.push(cur_page_index);*/
if (((ArrGlyph[i].isShape()) || (ArrGlyph[i].isGroup()))) if (((ArrGlyph[i].isShape()) || (ArrGlyph[i].isGroup())))
{ {
if (properties.type != undefined && properties.type != -1) if (properties.type != undefined && properties.type != -1)
...@@ -590,7 +584,6 @@ DrawingObjectsController.prototype = ...@@ -590,7 +584,6 @@ DrawingObjectsController.prototype =
ArrGlyph[i].changeLine(properties.stroke); ArrGlyph[i].changeLine(properties.stroke);
} }
} }
}
if (typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign) && typeof ArrGlyph[i].setTextVerticalAlign === "function") if (typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign) && typeof ArrGlyph[i].setTextVerticalAlign === "function")
{ {
...@@ -598,12 +591,6 @@ DrawingObjectsController.prototype = ...@@ -598,12 +591,6 @@ DrawingObjectsController.prototype =
} }
} }
/*arr_pages.sort(function(a, b){return a-b;});
for (i = 0; i < arr_pages.length; ++i)
{
this.drawingDocument.OnRecalculatePage(arr_pages[i], this.document.Pages[arr_pages[i]]);
}
this.drawingDocument.OnEndRecalculate(false, false);*/
} }
else if (this.curState.id === STATES_ID_GROUP || this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP) else if (this.curState.id === STATES_ID_GROUP || this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP)
{ {
...@@ -662,6 +649,7 @@ DrawingObjectsController.prototype = ...@@ -662,6 +649,7 @@ DrawingObjectsController.prototype =
} }
} }
} }
}
this.drawingObjects.showDrawingObjects(true); this.drawingObjects.showDrawingObjects(true);
this.drawingObjects.selectGraphicObject(); this.drawingObjects.selectGraphicObject();
this.drawingObjects.sendSelectionChanged(); this.drawingObjects.sendSelectionChanged();
......
...@@ -73,8 +73,6 @@ function CImage(drawingBase, drawingObjects) ...@@ -73,8 +73,6 @@ function CImage(drawingBase, drawingObjects)
CImage.prototype = CImage.prototype =
{ {
getObjectType: function() getObjectType: function()
{ {
return CLASS_TYPE_IMAGE; return CLASS_TYPE_IMAGE;
...@@ -160,6 +158,18 @@ CImage.prototype = ...@@ -160,6 +158,18 @@ CImage.prototype =
}; };
}, },
setRasterImage: function(img, canvas)
{
this.blipFill = new CBlipFill();
this.blipFill.RasterImageId = img;
if(isRealObject(canvas))
this.blipFill.canvas = canvas;
this.spPr.Fill = new CUniFill();
this.spPr.Fill.fill = this.blipFill;
this.brush = this.spPr.Fill;
},
updateDrawingBaseCoordinates: function() updateDrawingBaseCoordinates: function()
{ {
if(isRealObject(this.drawingBase)) if(isRealObject(this.drawingBase))
......
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