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

copy/paste shapes,images(через бинарник)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48954 954022d7-b5bf-4e40-9824-e11837661b57
parent cc55a196
......@@ -2055,17 +2055,28 @@
var cloneImg = worksheet.objectRender.cloneDrawingObject(image);
var curImage = new Image();
var url;
if(cloneImg.graphicObject && cloneImg.graphicObject.isImage())
url = cloneImg.graphicObject.getImageUrl();
else if(cloneImg.graphicObject.isChart() && cloneImg.graphicObject.brush.fill.RasterImageId)
if(cloneImg.graphicObject.isChart() && cloneImg.graphicObject.brush.fill.RasterImageId)
url = cloneImg.graphicObject.brush.fill.RasterImageId;
else if(cloneImg.graphicObject && (cloneImg.graphicObject.isShape() || cloneImg.graphicObject.isImage()))
{
var cMemory = new CMemory();
var altAttr = cloneImg.graphicObject.writeToBinaryForCopyPaste(cMemory);
var imageUrl = cloneImg.graphicObject.getImageUrl();
if(cloneImg.graphicObject.isImage() && imageUrl)
url = imageUrl;
else
url = cloneImg.graphicObject.getBase64Image();
curImage.alt = altAttr;
}
else
url = cloneImg.image.src;
curImage.src = url;
curImage.width = cloneImg.getWidthFromTo();
curImage.height = cloneImg.getHeightFromTo();
curImage.name = image.guid;
if(image.guid)
curImage.name = image.guid;
table.appendChild(curImage);
......@@ -2078,7 +2089,7 @@
isChart.height = curImage.height;
isChart.width = curImage.width;
}
else
/*else
{
t.lStorage[nLoc] = {};
t.lStorage[nLoc].image = curImage;
......@@ -2087,9 +2098,10 @@
nLoc++;
isImage = true;
}
}*/
t._addLocalStorage(isImage,isChart,range.worksheet.getCell( new CellAddress(row, col, 0) ),bbox.r1,bbox.c1, image.from.row, image.from.col);
if(image.graphicObject.isChart())
t._addLocalStorage(isImage,isChart,range.worksheet.getCell( new CellAddress(row, col, 0) ),bbox.r1,bbox.c1, image.from.row, image.from.col);
}
}
......@@ -2671,3 +2683,97 @@ function Editor_CopyPaste_Create(api)
document.body.appendChild(elementText);
}
function CreateBinaryReader(szSrc, offset, srcLen)
{
var nWritten = 0;
var index = -1 + offset;
var dst_len = "";
for( ; index < srcLen; )
{
index++;
var _c = szSrc.charCodeAt(index);
if (_c == ";".charCodeAt(0))
{
index++;
break;
}
dst_len += String.fromCharCode(_c);
}
var dstLen = parseInt(dst_len);
if(isNaN(dstLen))
return null;
var pointer = g_memory.Alloc(dstLen);
var stream = new FT_Stream2(pointer.data, dstLen);
stream.obj = pointer.obj;
var dstPx = stream.data;
if (window.chrome)
{
while (index < srcLen)
{
var dwCurr = 0;
var i;
var nBits = 0;
for (i=0; i<4; i++)
{
if (index >= srcLen)
break;
var nCh = DecodeBase64Char(szSrc.charCodeAt(index++));
if (nCh == -1)
{
i--;
continue;
}
dwCurr <<= 6;
dwCurr |= nCh;
nBits += 6;
}
dwCurr <<= 24-nBits;
for (i=0; i<nBits/8; i++)
{
dstPx[nWritten++] = ((dwCurr & 0x00ff0000) >>> 16);
dwCurr <<= 8;
}
}
}
else
{
var p = b64_decode;
while (index < srcLen)
{
var dwCurr = 0;
var i;
var nBits = 0;
for (i=0; i<4; i++)
{
if (index >= srcLen)
break;
var nCh = p[szSrc.charCodeAt(index++)];
if (nCh == undefined)
{
i--;
continue;
}
dwCurr <<= 6;
dwCurr |= nCh;
nBits += 6;
}
dwCurr <<= 24-nBits;
for (i=0; i<nBits/8; i++)
{
dstPx[nWritten++] = ((dwCurr & 0x00ff0000) >>> 16);
dwCurr <<= 8;
}
}
}
return stream;
}
......@@ -7125,8 +7125,66 @@
for(var im = 0; im < val.addImages.length; im++)//вставляем изображения
{
var src = val.addImages[im].tag.src;
if(src && 0 != src.indexOf("file://"))
t.objectRender.addImageDrawingObject(src, { cell: val.addImages[im].curCell, width: val.addImages[im].tag.width, height: val.addImages[im].tag.height });
if(src)
{
var binary_shape = val.addImages[im].tag.getAttribute("alt");
var sub;
if(typeof binary_shape === "string")
sub = binary_shape.substr(0, 12);
if(typeof binary_shape === "string" &&( sub === "TeamLabShape" || sub === "TeamLabImage" /*|| sub === "TeamLabChart" */|| sub === "TeamLabGroup"))
{
var reader = CreateBinaryReader(binary_shape, 12, binary_shape.length);
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 && t.cols[val.addImages[im].curCell.col].left)
positionX = t.cols[val.addImages[im].curCell.col].left;
if(t.rows && val.addImages[im].curCell && val.addImages[im].curCell.row && t.rows[val.addImages[im].curCell.row].top)
positionY = t.rows[val.addImages[im].curCell.row].top
var Drawing;
switch(first_string)
{
case "TeamLabImage":
{
Drawing = new CImageShape();
break;
}
case "TeamLabShape":
{
Drawing = new CShape();
break;
}
case "TeamLabGroup":
{
Drawing = new CGroupShape();
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;
Drawing.addToDrawingObjects();
}
else if(0 != src.indexOf("file://"))
{
t.objectRender.addImageDrawingObject(src, { cell: val.addImages[im].curCell, width: val.addImages[im].tag.width, height: val.addImages[im].tag.height });
}
}
}
}
});
......
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