Commit 9c8e9704 authored by Igor.Zotov's avatar Igor.Zotov Committed by Alexander.Trofimov

загрузка изображения на сервер при вставке, + fix http://bugzserver/show_bug.cgi?id=24837

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56784 954022d7-b5bf-4e40-9824-e11837661b57
parent 6694fc14
......@@ -1757,13 +1757,75 @@
//parse HTML
aResult = this._parseHtml(pasteFragment, node, worksheet, isText);
this._correctImageUrl(aResult, worksheet);
},
_correctImageUrl: function (aResult, worksheet)
{
var api = asc["editor"];
var aImagesToDownload = [];
var t = this;
var addImages = aResult.addImages ? aResult.addImages : [];
for(var k = 0; k < addImages.length; k++)
{
var src = addImages[k].tag.src;
//TODO просмотреть для локальных ссылок
/*if(0 == src.indexOf("file:"))
this.oImages[image] = "local";
else*/
if(false == (0 == src.indexOf("data:") || 0 == src.indexOf(api.documentUrl) || 0 == src.indexOf(api.documentUrl)))
aImagesToDownload.push(src);
};
if(aImagesToDownload.length > 0)
{
var rData = {"id": api.documentId, "c":"imgurls", "vkey": api.documentVKey, "data": JSON.stringify(aImagesToDownload)};
api._asc_sendCommand(function(incomeObject){
if(incomeObject && "imgurls" == incomeObject.type)
{
var oFromTo = JSON.parse(incomeObject.data);
var nC, height, width;
for(var i = 0, length = addImages.length; i < length; ++i)
{
var sTo = oFromTo[aResult.addImages[i].tag.src];
if(sTo)
{
if(aResult.addImages[i])
{
height = aResult.addImages[i].tag.height;
width = aResult.addImages[i].tag.width;
aResult.addImages[i].tag =
{
height: height,
width: width,
src: sTo
};
}
};
};
};
t._pasteResult(aResult, worksheet);
}, rData );
}
else
t._pasteResult(aResult, worksheet);
},
_pasteResult: function(aResult, worksheet)
{
//insert into document content
if(aResult && !(aResult.onlyImages && window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor))
worksheet.setSelectionInfo('paste',aResult,t);
worksheet.setSelectionInfo('paste',aResult,this);
window.GlobalPasteFlagCounter = 0;
window.GlobalPasteFlag = false;
},
},
_parseHtml: function(pasteFragment, node, worksheet, isText)
{
......
......@@ -8100,58 +8100,7 @@
for (var im = 0; im < val.addImages.length; im++) {
var src = val.addImages[im].tag.src;
var binary_shape = val.addImages[im].tag.getAttribute("alt");
var sub;
if (typeof binary_shape === "string")
sub = binary_shape.substr(0, 18);
if (typeof binary_shape === "string" &&( sub === "TeamLabShapeSheets" || sub === "TeamLabImageSheets" || sub === "TeamLabChartSheets" || sub === "TeamLabGroupSheets")) {
var reader = CreateBinaryReader(binary_shape, 18, binary_shape.length);
reader.GetLong();
if (isRealObject(reader))
reader.oImages = this.oImages;
var first_string = null;
if (reader !== null && typeof reader === "object") {
first_string = sub;
}
var positionX = null;
var positionY = null;
if (t.cols && val.addImages[im].curCell && val.addImages[im].curCell.col != undefined && t.cols[val.addImages[im].curCell.col].left != undefined)
positionX = t.cols[val.addImages[im].curCell.col].left - t.getCellLeft(0, 1);
if (t.rows && val.addImages[im].curCell && val.addImages[im].curCell.row != undefined && t.rows[val.addImages[im].curCell.row].top != undefined)
positionY = t.rows[val.addImages[im].curCell.row].top - t.getCellTop(0, 1);
var Drawing;
switch(first_string) {
case "TeamLabImageSheets": {
Drawing = new CImageShape(null, t.objectRender);
break;
}
case "TeamLabShapeSheets": {
Drawing = new CShape(null, t.objectRender);
break;
}
case "TeamLabGroupSheets": {
Drawing = new CGroupShape(null, t.objectRender);
break;
}
case "TeamLabChartSheets": {
Drawing = new CChartAsGroup(null, t.objectRender);
break;
}
default : {
Drawing = CreateImageFromBinary(src);
break;
}
}
if (positionX && positionY && t.objectRender)
Drawing.readFromBinaryForCopyPaste(reader,null, t.objectRender,t.objectRender.convertMetric(positionX,1,3),t.objectRender.convertMetric(positionY,1,3));
else
Drawing.readFromBinaryForCopyPaste(reader,null, t.objectRender);
Drawing.drawingObjects = t.objectRender;
a_drawings.push(Drawing);
//Drawing.addToDrawingObjects();
} else if (src && 0 != src.indexOf("file://")) {
if (src /*&& 0 != src.indexOf("file://")*/) {
var drawing = CreateImageDrawingObject(src, { cell: val.addImages[im].curCell, width: val.addImages[im].tag.width, height: val.addImages[im].tag.height }, t.objectRender);
if(drawing && drawing.graphicObject)
a_drawings.push(drawing.graphicObject);
......
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