Commit e598e553 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

(1.0.0.24): FileConverterUtils2

копирование emf и wmf вместе с svg.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@49949 954022d7-b5bf-4e40-9824-e11837661b57
parent d98df598
...@@ -2793,21 +2793,42 @@ PasteProcessor.prototype = ...@@ -2793,21 +2793,42 @@ PasteProcessor.prototype =
} }
} }
this.aContent = aContent.content; this.aContent = aContent.content;
var oImagesToDownload = {};
if(aContent.aPastedImages.length > 0) if(aContent.aPastedImages.length > 0)
{ {
var rData = {"id":documentId, "c":"imgurls", "data": JSON.stringify(aContent.images)}; for(var i = 0, length = aContent.aPastedImages.length; i < length; ++i)
{
var imageElem = aContent.aPastedImages[i];
var src = imageElem.Url;
if(false == (0 == src.indexOf("data:") || 0 == src.indexOf(documentOrigin + this.api.DocumentUrl) || 0 == src.indexOf(this.api.DocumentUrl)))
{
oImagesToDownload[src] = 1;
//для svg надо еще скопировать wmf и emf
var nExtIndex = src.lastIndexOf(".");
if(-1 != nExtIndex && ".svg" == src.substring(nExtIndex))
{
var sStart = src.substring(0, nExtIndex)
oImagesToDownload[sStart + ".wmf"] = 1;
oImagesToDownload[sStart + ".emf"] = 1;
}
}
}
}
var aImagesToDownload = [];
for(var i in oImagesToDownload)
aImagesToDownload.push(i);
if(aImagesToDownload.length > 0)
{
var rData = {"id":documentId, "c":"imgurls", "data": JSON.stringify(aImagesToDownload)};
sendCommand( this.api, function(incomeObject){ sendCommand( this.api, function(incomeObject){
if(incomeObject && "imgurls" == incomeObject.type) if(incomeObject && "imgurls" == incomeObject.type)
{ {
var aImages = JSON.parse(incomeObject.data); var oFromTo = JSON.parse(incomeObject.data);
var oFromTo = {}; for(var i = 0, length = aContent.images.length; i < length; ++i)
for(var i = 0, length1 = aImages.length, length2 = aContent.images.length; i < length1 && i < length2; ++i)
{ {
var sFrom = aContent.images[i]; var sFrom = aContent.images[i];
var sTo = aImages[i]; var sTo = oFromTo[sFrom];
if(0 == sTo.indexOf(oThis.api.DocumentUrl + "media/")) if(sTo)
sTo = sTo.substring((oThis.api.DocumentUrl + "media/").length);
oFromTo[sFrom] = sTo;
aContent.images[i] = sTo; aContent.images[i] = sTo;
} }
for(var i = 0, length = aContent.aPastedImages.length; i < length; ++i) for(var i = 0, length = aContent.aPastedImages.length; i < length; ++i)
...@@ -2879,7 +2900,7 @@ PasteProcessor.prototype = ...@@ -2879,7 +2900,7 @@ PasteProcessor.prototype =
var src = this.oImages[image]; var src = this.oImages[image];
if(0 == src.indexOf("file:")) if(0 == src.indexOf("file:"))
this.oImages[image] = "local"; this.oImages[image] = "local";
else if(false == (0 == src.indexOf("data:") || 0 == src.indexOf(documentOrigin + this.api.DocumentUrl) && 0 == src.indexOf(this.api.DocumentUrl))) else if(false == (0 == src.indexOf("data:") || 0 == src.indexOf(documentOrigin + this.api.DocumentUrl) || 0 == src.indexOf(this.api.DocumentUrl)))
aImagesToDownload.push(src); aImagesToDownload.push(src);
} }
var oPrepeareImages = new Object(); var oPrepeareImages = new Object();
...@@ -2889,12 +2910,16 @@ PasteProcessor.prototype = ...@@ -2889,12 +2910,16 @@ PasteProcessor.prototype =
sendCommand( this.api, function(incomeObject){ sendCommand( this.api, function(incomeObject){
if(incomeObject && "imgurls" == incomeObject.type) if(incomeObject && "imgurls" == incomeObject.type)
{ {
var aImages = JSON.parse(incomeObject.data); var oFromTo = JSON.parse(incomeObject.data);
for(var i = 0, length1 = aImages.length, length2 = aImagesToDownload.length; i < length1 && i < length2; ++i) for(var i = 0, length = aImagesToDownload.length; i < length; ++i)
{
var sFrom = aImagesToDownload[i];
var sTo = oFromTo[sFrom];
if(sTo)
{ {
var sNewSrc = aImages[i]; oThis.oImages[sFrom] = sTo;
oThis.oImages[aImagesToDownload[i]] = sNewSrc; oPrepeareImages[i] = sTo;
oPrepeareImages[i] = sNewSrc; }
} }
} }
oThis.api.pre_Paste(aPrepeareFonts, oPrepeareImages, fCallback); oThis.api.pre_Paste(aPrepeareFonts, oPrepeareImages, fCallback);
......
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