Commit f327b733 authored by Igor.Zotov's avatar Igor.Zotov

bug #17992 - Потеря части содержимого интернет страницы с картинкой при копировании и вставке

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@67464 954022d7-b5bf-4e40-9824-e11837661b57
parent 8cf62b18
......@@ -37,6 +37,9 @@
this.lStorage = {};
this.fontsNew = {};
this.oImages = {};
this.alreadyLoadImagesOnServer = false;
return this;
}
......@@ -2121,6 +2124,8 @@
if(isOnlyLocalBufferSafari && navigator.userAgent.toLowerCase().indexOf('safari') > -1 && navigator.userAgent.toLowerCase().indexOf('mac'))
onlyFromLocalStorage = true;
t.alreadyLoadImagesOnServer = false;
//****binary****
if(onlyFromLocalStorage)
{
......@@ -2164,36 +2169,100 @@
}
this.activeRange = worksheet.activeRange.clone(true);
History.TurnOff();
var t = this;
var oPasteProcessor;
var oTempDrawingDocument = worksheet.model.DrawingDocument;
var newCDocument = new CDocument(oTempDrawingDocument, false);
newCDocument.bFromDocument = true;
//TODo!!!!!!
newCDocument.Content[0].bFromDocument = true;
newCDocument.theme = this.Api.wbModel.theme;
oTempDrawingDocument.m_oLogicDocument = newCDocument;
var oOldEditor = undefined;
if ("undefined" != typeof editor)
oOldEditor = editor;
editor = {WordControl: oTempDrawingDocument, isDocumentEditor: true};
var oPasteProcessor = new PasteProcessor({WordControl:{m_oLogicDocument: newCDocument}, FontLoader: {}}, false, false);
oPasteProcessor._Prepeare_recursive(node, true, true)
oPasteProcessor._Execute(node, {}, true, true, false);
editor = oOldEditor;
var callBackAfterLoadImages = function()
{
History.TurnOff();
History.TurnOn();
var oPasteProcessor;
var oTempDrawingDocument = worksheet.model.DrawingDocument;
var newCDocument = new CDocument(oTempDrawingDocument, false);
newCDocument.bFromDocument = true;
//TODo!!!!!!
newCDocument.Content[0].bFromDocument = true;
newCDocument.theme = t.Api.wbModel.theme;
oTempDrawingDocument.m_oLogicDocument = newCDocument;
var oOldEditor = undefined;
if ("undefined" != typeof editor)
oOldEditor = editor;
editor = {WordControl: oTempDrawingDocument, isDocumentEditor: true};
var oPasteProcessor = new PasteProcessor({WordControl:{m_oLogicDocument: newCDocument}, FontLoader: {}}, false, false);
oPasteProcessor._Prepeare_recursive(node, true, true)
oPasteProcessor._Execute(node, {}, true, true, false);
editor = oOldEditor;
History.TurnOn();
var pasteFromBinaryWord = new Asc.pasteFromBinaryWord(t, worksheet);
pasteFromBinaryWord._paste(worksheet, {content: oPasteProcessor.aContent});
window.GlobalPasteFlagCounter = 0;
window.GlobalPasteFlag = false;
};
var pasteFromBinaryWord = new Asc.pasteFromBinaryWord(t, worksheet);
pasteFromBinaryWord._paste(worksheet, {content: oPasteProcessor.aContent});
window.GlobalPasteFlagCounter = 0;
window.GlobalPasteFlag = false;
var aImagesToDownload = this._getImageFromHtml(node, true);
if(aImagesToDownload !== null)//load to server
{
var api = asc["editor"];
sendImgUrls(api, aImagesToDownload, function (data) {
for (var i = 0, length = Math.min(data.length, aImagesToDownload.length); i < length; ++i)
{
var elem = data[i];
var sFrom = aImagesToDownload[i];
if (null != elem.url)
{
var name = g_oDocumentUrls.imagePath2Local(elem.path);
t.oImages[sFrom] = name;
}
else
{
t.oImages[sFrom] = sFrom;
}
}
t.alreadyLoadImagesOnServer = true;
callBackAfterLoadImages();
}, true);
}
else
{
callBackAfterLoadImages();
}
},
_getImageFromHtml: function(html, isGetUrlsArray)
{
var res = null;
if(html)
{
var allImages = html.getElementsByTagName('img');
if(allImages && allImages.length)
{
if(isGetUrlsArray)
{
var arrayImages = [];
for(var i = 0; i < allImages.length; i++)
{
arrayImages[i] = allImages[i].src;
}
res = arrayImages;
}
else
{
res = allImages;
}
}
}
return res;
},
_pasteResult: function(aResult, worksheet)
{
//insert into document content
......
......@@ -8447,15 +8447,55 @@
else if(val.addImagesFromWord && val.addImagesFromWord.length != 0 && !(window["Asc"]["editor"] && window["Asc"]["editor"].isChartEditor))
{
var oObjectsForDownload = GetObjectsForImageDownload(val._aPastedImages);
//if already load images on server
if(api.wb.clipboard.alreadyLoadImagesOnServer === true)
{
var oImageMap = {};
for (var i = 0, length = oObjectsForDownload.aBuilderImagesByUrl.length; i < length; ++i)
{
var url = oObjectsForDownload.aUrls[i];
//get name from array already load on server urls
var name = api.wb.clipboard.oImages[url];
var aImageElem = oObjectsForDownload.aBuilderImagesByUrl[i];
if(name)
{
if(Array.isArray(aImageElem))
{
for(var j = 0; j < aImageElem.length; ++j)
{
var imageElem = aImageElem[j];
if (null != imageElem)
{
imageElem.SetUrl(name);
}
}
}
oImageMap[i] = name;
}
else
{
oImageMap[i] = url;
}
}
sendImgUrls(api, oObjectsForDownload.aUrls, function (data) {
var oImageMap = {};
ResetNewUrls(data, oObjectsForDownload.aUrls, oObjectsForDownload.aBuilderImagesByUrl, oImageMap);
if(val.onlyImages !== true)
t._pasteFromLocalBuff(isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth);
api.wb.clipboard._insertImagesFromBinaryWord(t, val, oImageMap);
}
else
{
sendImgUrls(api, oObjectsForDownload.aUrls, function (data) {
var oImageMap = {};
ResetNewUrls(data, oObjectsForDownload.aUrls, oObjectsForDownload.aBuilderImagesByUrl, oImageMap);
if(val.onlyImages !== true)
t._pasteFromLocalBuff(isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth);
api.wb.clipboard._insertImagesFromBinaryWord(t, val, oImageMap);
}, true);
if(val.onlyImages !== true)
t._pasteFromLocalBuff(isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth);
api.wb.clipboard._insertImagesFromBinaryWord(t, val, oImageMap);
}, true);
}
}
else if(val.onlyImages !== true)
t._pasteFromLocalBuff(isLargeRange, isLocal, val, bIsUpdate, canChangeColWidth);
......
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