Commit fada8909 authored by Sergey Luzyanin's avatar Sergey Luzyanin

loading fonts and images before recalculate in cell

parent b096c874
...@@ -3225,10 +3225,29 @@ var editor; ...@@ -3225,10 +3225,29 @@ var editor;
return true; return true;
}; };
spreadsheet_api.prototype.asc_Recalculate = function () { spreadsheet_api.prototype.asc_Recalculate = function () {
var t = this;
this._loadFonts(this.wbModel.generateFontMap(), function() {
History.EndTransaction(); History.EndTransaction();
t._onUpdateAfterApplyChanges(); this._onUpdateAfterApplyChanges();
};
spreadsheet_api.prototype.pre_Paste = function(_fonts, _images, callback)
{
var oFontMap = {};
for(var i = 0; i < _fonts.length; ++i){
oFontMap[_fonts[i].name] = 1;
}
this._loadFonts(oFontMap, function() {
var aImages = [];
for(var key in _images){
if(_images.hasOwnProperty(key)){
aImages.push(_images[key])
}
}
if(aImages.length > 0) {
window["Asc"]["editor"].ImageLoader.LoadDocumentImages(aImages, null);
}
callback();
}); });
}; };
......
...@@ -2507,6 +2507,18 @@ Workbook.prototype.generateFontMap2=function(){ ...@@ -2507,6 +2507,18 @@ Workbook.prototype.generateFontMap2=function(){
aRes.push(new AscFonts.CFont(i, 0, "", 0)); aRes.push(new AscFonts.CFont(i, 0, "", 0));
return aRes; return aRes;
}; };
Workbook.prototype.getAllImageUrls = function(){
var aImageUrls = [];
for(var i = 0; i < this.aWorksheets.length; ++i){
this.aWorksheets[i].getAllImageUrls(aImageUrls);
}
return aImageUrls;
};
Workbook.prototype.reassignImageUrls = function(oImages){
for(var i = 0; i < this.aWorksheets.length; ++i){
this.aWorksheets[i].reassignImageUrls(oImages);
}
};
Workbook.prototype.recalcWB = function(isRecalcWB){ Workbook.prototype.recalcWB = function(isRecalcWB){
//todo //todo
if ( this.dependencyFormulas.getNodesLength() > 0 ) { if ( this.dependencyFormulas.getNodesLength() > 0 ) {
...@@ -3408,6 +3420,16 @@ Woorksheet.prototype.generateFontMap=function(oFontMap){ ...@@ -3408,6 +3420,16 @@ Woorksheet.prototype.generateFontMap=function(oFontMap){
} }
} }
}; };
Woorksheet.prototype.getAllImageUrls = function(aImages){
for(var i = 0; i < this.Drawings.length; ++i){
this.Drawings[i].graphicObject.getAllRasterImages(aImages);
}
};
Woorksheet.prototype.reassignImageUrls = function(oImages){
for(var i = 0; i < this.Drawings.length; ++i){
this.Drawings[i].graphicObject.Reassign_ImageUrls(oImages);
}
};
Woorksheet.prototype.clone=function(sNewId, sName, tableNames){ Woorksheet.prototype.clone=function(sNewId, sName, tableNames){
var i, elem, range; var i, elem, range;
var oNewWs = new Woorksheet(this.workbook, this.workbook.aWorksheets.length, sNewId); var oNewWs = new Woorksheet(this.workbook, this.workbook.aWorksheets.length, sNewId);
......
...@@ -1021,6 +1021,9 @@ ...@@ -1021,6 +1021,9 @@
baseEditorsApi.prototype.onKeyUp = function(e) baseEditorsApi.prototype.onKeyUp = function(e)
{ {
}; };
baseEditorsApi.prototype.pre_Paste = function(_fonts, _images, callback)
{
};
// System input // System input
baseEditorsApi.prototype.SetTextBoxInputMode = function(bIsEnable) baseEditorsApi.prototype.SetTextBoxInputMode = function(bIsEnable)
......
...@@ -440,7 +440,21 @@ ...@@ -440,7 +440,21 @@
} }
else if (AscCommon.c_oEditorId.Spreadsheet === editorId) else if (AscCommon.c_oEditorId.Spreadsheet === editorId)
{ {
window.g_asc_plugins.api.asc_Recalculate(); var oApi = window.g_asc_plugins.api;
var oFonts = oApi.wbModel._generateFontMap();
var aImages = oApi.wbModel.getAllImageUrls();
var oImages = {};
for (var i = 0; i < aImages.length; i++)
{
oImages[aImages[i]] = aImages[i];
}
window.g_asc_plugins.images_rename = oImages;
AscCommon.Check_LoadingDataBeforePrepaste(window.g_asc_plugins.api, oFonts, oImages,
function(){
oApi.wbModel.reassignImageUrls(window.g_asc_plugins.images_rename);
delete window.g_asc_plugins.images_rename;
window.g_asc_plugins.api.asc_Recalculate();
});
} }
} }
} }
......
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