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() {
sheetId = data["input"]["sheetId"];
var url = data["url"];
if (sheetId == worksheet.model.getId())
_this.addImageDrawingObject(url, false, null);
if (sheetId == worksheet.model.getId()) {
if ( api.isImageChangeUrl ) {
_this.editImageDrawingObject(url);
api.isImageChangeUrl = false;
}
else
_this.addImageDrawingObject(url, false, null);
}
else
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
......@@ -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) {
if (isViewerMode())
......
......@@ -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.put_Api(this);
this.shapeElementId = null;
this.isImageChangeUrl = false;
/**************************************/
......@@ -2146,6 +2147,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.shapeElementId = elementId;
},
asc_changeImageFromFile: function() {
this.isImageChangeUrl = true;
this.asc_showImageFileDialog();
},
asyncImageStartLoaded: function() {
},
......@@ -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_changeShapeType"] = prot.asc_changeShapeType;
prot["asc_setInterfaceDrawImagePlaceShape"] = prot.asc_setInterfaceDrawImagePlaceShape;
prot["asc_changeImageFromFile"] = prot.asc_changeImageFromFile;
// Cell interface
prot["asc_getCellInfo"] = prot.asc_getCellInfo;
......
......@@ -544,124 +544,112 @@ DrawingObjectsController.prototype =
if (isRealObject(properties) || isRealObject(props))
{
var arr_pages = [];
if (isRealObject(props) && typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign))
{
if (this.curState.id === STATES_ID_TEXT_ADD)
{
if(typeof this.curState.textObject.GraphicObj.setTextVerticalAlign === "function")
this.curState.textObject.GraphicObj.setTextVerticalAlign(props.verticalTextAlign);
}
if (this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP)
{
if (typeof this.curState.textObject.setTextVerticalAlign === "function")
this.curState.textObject.setTextVerticalAlign(props.verticalTextAlign);
}
}
if (!(this.curState.id === STATES_ID_GROUP || this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP) && isRealObject(properties))
{
var ArrGlyph = this.selectedObjects;
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 (properties.type != undefined && properties.type != -1)
{
ArrGlyph[i].changePresetGeometry(properties.type);
}
if (properties.fill)
{
ArrGlyph[i].changeFill(properties.fill);
}
if (properties.stroke)
{
ArrGlyph[i].changeLine(properties.stroke);
}
}
}
if (typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign) && typeof ArrGlyph[i].setTextVerticalAlign === "function")
{
ArrGlyph[i].setTextVerticalAlign(props.verticalTextAlign);
}
}
/*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)
{
if (false === this.document.Document_Is_SelectionLocked(changestype_Drawing_Props, {Type : changestype_2_Element_and_Type , Element : this.curState.group.parent.Parent, CheckType : changestype_Paragraph_Content} ))
{
if ( undefined != props.PositionH )
this.curState.group.parent.Set_PositionH( props.PositionH.RelativeFrom, props.PositionH.UseAlign, ( true === props.PositionH.UseAlign ? props.PositionH.Align : props.PositionH.Value ) );
if ( undefined != props.PositionV )
this.curState.group.parent.Set_PositionV( props.PositionV.RelativeFrom, props.PositionV.UseAlign, ( true === props.PositionV.UseAlign ? props.PositionV.Align : props.PositionV.Value ) );
ArrGlyph = this.curState.group.selectionInfo.selectionArray;
var b_change_diagram = false;
for (i = 0; i< ArrGlyph.length; ++i)
{
if (ArrGlyph[i].isShape() && isRealObject(properties))
{
if (properties.type != undefined && properties.type != -1)
{
ArrGlyph[i].changePresetGeometry(properties.type);
}
if (properties.fill)
{
ArrGlyph[i].changeFill(properties.fill);
}
if (properties.stroke)
{
ArrGlyph[i].changeLine(properties.stroke);
}
}
else if (isRealObject(props) && typeof props.ImageUrl === "string" && ArrGlyph[i].isImage() && ArrGlyph[i].chart == null)
{
ArrGlyph[i].setRasterImage2(props.ImageUrl);
}
else if (ArrGlyph[i].chart != null && isRealObject(props) && isRealObject(props.ChartProperties))
{
b_change_diagram = true;
ArrGlyph[i].setDiagram(props.ChartProperties)
}
if (typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign) && typeof ArrGlyph[i].setTextVerticalAlign === "function")
{
ArrGlyph[i].setTextVerticalAlign(props.verticalTextAlign);
}
}
if (b_change_diagram)
{
this.curState.group.updateSizes();
this.curState.group.recalculate();
var bounds = this.curState.group.parent.getBounds();
if (!this.curState.group.parent.Is_Inline())
this.curState.group.parent.OnEnd_ChangeFlow(this.curState.group.absOffsetX, this.curState.group.absOffsetY, this.curState.group.pageIndex, bounds.r - bounds.l, bounds.b - bounds.t, null, true, true);
else
this.curState.group.parent.OnEnd_ResizeInline(bounds.r - bounds.l, bounds.b - bounds.t);
}
}
}
}
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 (this.curState.id === STATES_ID_TEXT_ADD)
{
if(typeof this.curState.textObject.GraphicObj.setTextVerticalAlign === "function")
this.curState.textObject.GraphicObj.setTextVerticalAlign(props.verticalTextAlign);
}
if (this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP)
{
if (typeof this.curState.textObject.setTextVerticalAlign === "function")
this.curState.textObject.setTextVerticalAlign(props.verticalTextAlign);
}
}
if (!(this.curState.id === STATES_ID_GROUP || this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP) && isRealObject(properties))
{
var ArrGlyph = this.selectedObjects;
for (var i = 0; i< ArrGlyph.length; ++i)
{
if (((ArrGlyph[i].isShape()) || (ArrGlyph[i].isGroup())))
{
if (properties.type != undefined && properties.type != -1)
{
ArrGlyph[i].changePresetGeometry(properties.type);
}
if (properties.fill)
{
ArrGlyph[i].changeFill(properties.fill);
}
if (properties.stroke)
{
ArrGlyph[i].changeLine(properties.stroke);
}
}
if (typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign) && typeof ArrGlyph[i].setTextVerticalAlign === "function")
{
ArrGlyph[i].setTextVerticalAlign(props.verticalTextAlign);
}
}
}
else if (this.curState.id === STATES_ID_GROUP || this.curState.id === STATES_ID_TEXT_ADD_IN_GROUP)
{
if (false === this.document.Document_Is_SelectionLocked(changestype_Drawing_Props, {Type : changestype_2_Element_and_Type , Element : this.curState.group.parent.Parent, CheckType : changestype_Paragraph_Content} ))
{
if ( undefined != props.PositionH )
this.curState.group.parent.Set_PositionH( props.PositionH.RelativeFrom, props.PositionH.UseAlign, ( true === props.PositionH.UseAlign ? props.PositionH.Align : props.PositionH.Value ) );
if ( undefined != props.PositionV )
this.curState.group.parent.Set_PositionV( props.PositionV.RelativeFrom, props.PositionV.UseAlign, ( true === props.PositionV.UseAlign ? props.PositionV.Align : props.PositionV.Value ) );
ArrGlyph = this.curState.group.selectionInfo.selectionArray;
var b_change_diagram = false;
for (i = 0; i< ArrGlyph.length; ++i)
{
if (ArrGlyph[i].isShape() && isRealObject(properties))
{
if (properties.type != undefined && properties.type != -1)
{
ArrGlyph[i].changePresetGeometry(properties.type);
}
if (properties.fill)
{
ArrGlyph[i].changeFill(properties.fill);
}
if (properties.stroke)
{
ArrGlyph[i].changeLine(properties.stroke);
}
}
else if (isRealObject(props) && typeof props.ImageUrl === "string" && ArrGlyph[i].isImage() && ArrGlyph[i].chart == null)
{
ArrGlyph[i].setRasterImage2(props.ImageUrl);
}
else if (ArrGlyph[i].chart != null && isRealObject(props) && isRealObject(props.ChartProperties))
{
b_change_diagram = true;
ArrGlyph[i].setDiagram(props.ChartProperties)
}
if (typeof props.verticalTextAlign === "number" && !isNaN(props.verticalTextAlign) && typeof ArrGlyph[i].setTextVerticalAlign === "function")
{
ArrGlyph[i].setTextVerticalAlign(props.verticalTextAlign);
}
}
if (b_change_diagram)
{
this.curState.group.updateSizes();
this.curState.group.recalculate();
var bounds = this.curState.group.parent.getBounds();
if (!this.curState.group.parent.Is_Inline())
this.curState.group.parent.OnEnd_ChangeFlow(this.curState.group.absOffsetX, this.curState.group.absOffsetY, this.curState.group.pageIndex, bounds.r - bounds.l, bounds.b - bounds.t, null, true, true);
else
this.curState.group.parent.OnEnd_ResizeInline(bounds.r - bounds.l, bounds.b - bounds.t);
}
}
}
}
}
this.drawingObjects.showDrawingObjects(true);
this.drawingObjects.selectGraphicObject();
this.drawingObjects.sendSelectionChanged();
......
......@@ -73,8 +73,6 @@ function CImage(drawingBase, drawingObjects)
CImage.prototype =
{
getObjectType: function()
{
return CLASS_TYPE_IMAGE;
......@@ -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()
{
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