Better toolbar state message in OO strict mode

pull/1/head
yflory 4 years ago
parent 2172e1405c
commit 437328e7af

@ -1356,7 +1356,7 @@ define([
var unsaved = APP.unsavedChanges;
delete APP.unsavedChanges;
rtChannel.sendMsg(unsaved, null, function (err, hash) {
if (err) { return; }
if (err) { return void UI.warn(Messages.error); } // XXX Better error message?
// This is supposed to be a "send" function to tell our OO
// to unlock the cell. We use this to know that the patch was
// correctly sent so that we can apply it to our OO too.
@ -2042,6 +2042,28 @@ define([
}
};
var setStrictEditing = function () {
if (APP.isFast) { return; }
var editor = getEditor();
var editing = editor.asc_isDocumentModified();
if (editing) {
evOnPatch.fire();
} else {
evOnSync.fire();
}
};
APP.onFastChange = function (isFast) {
APP.isFast = isFast;
if (isFast) {
if (APP.hasChangedInterval) {
window.clearInterval(APP.hasChangedInterval)
}
return;
}
setStrictEditing();
APP.hasChangedInterval = window.setInterval(setStrictEditing, 500);
};
APP.getContent = function () { return content; };
APP.onLocal = config.onLocal = function () {

@ -1689,17 +1689,17 @@ function(){var t=this;if(this.openingEnd.xlsxStart)return;this.openingEnd.xlsxSt
function(actionType,options,oAdditionalData,dataContainer){var fileType=options.fileType;if(c_oAscFileType.PDF===fileType||c_oAscFileType.PDFA===fileType){var printPagesData=this.wb.calcPagesPrint(options.advancedOptions);var pdfPrinterMemory=this.wb.printSheets(printPagesData).DocumentRenderer.Memory;dataContainer.data=oAdditionalData["nobase64"]?pdfPrinterMemory.GetData():pdfPrinterMemory.GetBase64Memory()}else{var oBinaryFileWriter=new AscCommonExcel.BinaryFileWriter(this.wbModel);if(c_oAscFileType.CSV===
fileType)if(options.advancedOptions instanceof asc.asc_CTextOptions){oAdditionalData["codepage"]=options.advancedOptions.asc_getCodePage();oAdditionalData["delimiter"]=options.advancedOptions.asc_getDelimiter();oAdditionalData["delimiterChar"]=options.advancedOptions.asc_getDelimiterChar()}dataContainer.data=oBinaryFileWriter.Write(oAdditionalData["nobase64"])}if(window.isCloudCryptoDownloadAs){var sParamXml="<m_nCsvTxtEncoding>"+oAdditionalData["codepage"]+"</m_nCsvTxtEncoding>";sParamXml+="<m_nCsvDelimiter>"+
oAdditionalData["delimiter"]+"</m_nCsvDelimiter>";window["AscDesktopEditor"]["CryptoDownloadAs"](dataContainer.data,fileType,sParamXml);return true}};spreadsheet_api.prototype.asc_isDocumentModified=function(){if(!this.canSave||this.asc_getCellEditMode())return true;else if(History&&History.Have_Changes)return History.Have_Changes();return false};spreadsheet_api.prototype.asc_registerCallback=function(name,callback,replaceOldCallback){this.handlers.add(name,callback,replaceOldCallback)};spreadsheet_api.prototype.asc_unregisterCallback=
function(name,callback){this.handlers.remove(name,callback)};spreadsheet_api.prototype.asc_SetDocumentPlaceChangedEnabled=function(val){this.wb.setDocumentPlaceChangedEnabled(val)};spreadsheet_api.prototype.asc_SetFastCollaborative=function(bFast){if(this.collaborativeEditing){AscCommon.CollaborativeEditing.Set_Fast(bFast);this.collaborativeEditing.setFast(bFast)}};spreadsheet_api.prototype.asc_setThumbnailStylesSizes=function(width,height){this.styleThumbnailWidth=width;this.styleThumbnailHeight=
height};spreadsheet_api.prototype.sheetsChanged=function(){this.handlers.trigger("asc_onSheetsChanged")};spreadsheet_api.prototype.asyncFontsDocumentStartLoaded=function(){this.OpenDocumentProgress.Type=c_oAscAsyncAction.LoadDocumentFonts;this.OpenDocumentProgress.FontsCount=this.FontLoader.fonts_loading.length;this.OpenDocumentProgress.CurrentFont=0;this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction,c_oAscAsyncAction.LoadDocumentFonts)};spreadsheet_api.prototype.asyncFontsDocumentEndLoaded=
function(){this.sync_EndAction(c_oAscAsyncActionType.BlockInteraction,c_oAscAsyncAction.LoadDocumentFonts);if(this.asyncMethodCallback!==undefined){this.asyncMethodCallback();this.asyncMethodCallback=undefined}else{this.FontLoadWaitComplete=true;this._openDocumentEndCallback()}};spreadsheet_api.prototype.asyncFontEndLoaded=function(font){this.sync_EndAction(c_oAscAsyncActionType.Information,c_oAscAsyncAction.LoadFont)};spreadsheet_api.prototype._loadFonts=function(fonts,callback){if(window["NATIVE_EDITOR_ENJINE"])return callback();
this.asyncMethodCallback=callback;var arrLoadFonts=[];for(var i in fonts)arrLoadFonts.push(new AscFonts.CFont(i,0,"",0));AscFonts.FontPickerByCharacter.extendFonts(arrLoadFonts);this.FontLoader.LoadDocumentFonts2(arrLoadFonts)};spreadsheet_api.prototype.openDocument=function(file){this._openDocument(file.data);this._openOnClient()};spreadsheet_api.prototype.openDocumentFromZip=function(wb,data){var t=this;return new Promise(function(resolve,reject){var openXml=AscCommon.openXml;if(t.isChartEditor){resolve();
return}var nextPromise;if(data){var doc=new openXml.OpenXmlPackage;var wbPart=null;var wbXml=null;var pivotCaches={};var jsZipWrapper=new AscCommon.JSZipWrapper;nextPromise=jsZipWrapper.loadAsync(data).then(function(zip){return doc.openFromZip(zip)}).then(function(){wbPart=doc.getPartByRelationshipType(openXml.relationshipTypes.workbook);return wbPart.getDocumentContent()}).then(function(contentWorkbook){wbXml=new AscCommonExcel.CT_Workbook;(new openXml.SaxParserBase).parse(contentWorkbook,wbXml);
if(wbXml.pivotCaches)return wbXml.pivotCaches.reduce(function(prevVal,wbPivotCacheXml){var pivotTableCacheDefinitionPart;var pivotTableCacheDefinition;return prevVal.then(function(){if(null!==wbPivotCacheXml.cacheId&&null!==wbPivotCacheXml.id){pivotTableCacheDefinitionPart=wbPart.getPartById(wbPivotCacheXml.id);return pivotTableCacheDefinitionPart.getDocumentContent()}}).then(function(content){if(content){pivotTableCacheDefinition=new Asc.CT_PivotCacheDefinition;(new openXml.SaxParserBase).parse(content,
pivotTableCacheDefinition);if(pivotTableCacheDefinition.isValidCacheSource()){pivotCaches[wbPivotCacheXml.cacheId]=pivotTableCacheDefinition;if(pivotTableCacheDefinition.id){var partPivotTableCacheRecords=pivotTableCacheDefinitionPart.getPartById(pivotTableCacheDefinition.id);return partPivotTableCacheRecords.getDocumentContent()}}}}).then(function(content){if(content){var pivotTableCacheRecords=new Asc.CT_PivotCacheRecords;(new openXml.SaxParserBase).parse(content,pivotTableCacheRecords);pivotTableCacheDefinition.cacheRecords=
pivotTableCacheRecords}})},Promise.resolve())}).then(function(){if(wbXml.sheets){var wsIndex=0;return wbXml.sheets.reduce(function(prevVal,wbSheetXml){var wsPart;return prevVal.then(function(){if(null!==wbSheetXml.id){var actions=[];wsPart=wbPart.getPartById(wbSheetXml.id);var pivotParts=wsPart.getPartsByRelationshipType(openXml.relationshipTypes.pivotTable);for(var i=0;i<pivotParts.length;++i)actions.push(pivotParts[i].getDocumentContent());return Promise.all(actions)}}).then(function(res){if(res){var ws=
t.wbModel.getWorksheet(wsIndex);for(var i=0;i<res.length;++i){var pivotTable=new Asc.CT_pivotTableDefinition;(new openXml.SaxParserBase).parse(res[i],pivotTable);var cacheDefinition=pivotCaches[pivotTable.cacheId];if(cacheDefinition){pivotTable.cacheDefinition=cacheDefinition;ws.insertPivotTable(pivotTable)}}}wsIndex++})},Promise.resolve())}}).catch(function(err){if(window.console&&window.console.log)window.console.log(err)}).then(function(){jsZipWrapper.close()})}else nextPromise=Promise.resolve();
nextPromise.then(function(err){openXml.SaxParserDataTransfer={};return Asc.ReadDefTableStyles(wb)}).then(resolve,reject)})};spreadsheet_api.prototype.syncCollaborativeChanges=function(){if(!this.collaborativeEditing.getFast())this.handlers.trigger("asc_onCollaborativeChanges")};spreadsheet_api.prototype._applyFirstLoadChanges=function(){if(this.isDocumentLoadComplete)return;if(this.collaborativeEditing.applyChanges())this.onDocumentContentReady();this.collaborativeEditing.sendChanges()};spreadsheet_api.prototype.goTo=
function(action){var comment=this.wbModel.getComment(action&&action["data"]);if(comment){this.asc_showWorksheet(this.wbModel.getWorksheetById(comment.wsId).getIndex());this.asc_selectComment(comment.nId);this.asc_showComment(comment.nId)}};spreadsheet_api.prototype._coAuthoringInitEnd=function(){var t=this;this.collaborativeEditing=new AscCommonExcel.CCollaborativeEditing({"askLock":function(){t.CoAuthoringApi.askLock.apply(t.CoAuthoringApi,arguments)},"releaseLocks":function(){t.CoAuthoringApi.releaseLocks.apply(t.CoAuthoringApi,
function(name,callback){this.handlers.remove(name,callback)};spreadsheet_api.prototype.asc_SetDocumentPlaceChangedEnabled=function(val){this.wb.setDocumentPlaceChangedEnabled(val)};spreadsheet_api.prototype.asc_SetFastCollaborative=function(bFast){if(this.collaborativeEditing){if(window.parent&&window.parent.APP&&window.parent.APP.onFastChange)window.parent.APP.onFastChange(bFast);AscCommon.CollaborativeEditing.Set_Fast(bFast);this.collaborativeEditing.setFast(bFast)}};spreadsheet_api.prototype.asc_setThumbnailStylesSizes=
function(width,height){this.styleThumbnailWidth=width;this.styleThumbnailHeight=height};spreadsheet_api.prototype.sheetsChanged=function(){this.handlers.trigger("asc_onSheetsChanged")};spreadsheet_api.prototype.asyncFontsDocumentStartLoaded=function(){this.OpenDocumentProgress.Type=c_oAscAsyncAction.LoadDocumentFonts;this.OpenDocumentProgress.FontsCount=this.FontLoader.fonts_loading.length;this.OpenDocumentProgress.CurrentFont=0;this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction,c_oAscAsyncAction.LoadDocumentFonts)};
spreadsheet_api.prototype.asyncFontsDocumentEndLoaded=function(){this.sync_EndAction(c_oAscAsyncActionType.BlockInteraction,c_oAscAsyncAction.LoadDocumentFonts);if(this.asyncMethodCallback!==undefined){this.asyncMethodCallback();this.asyncMethodCallback=undefined}else{this.FontLoadWaitComplete=true;this._openDocumentEndCallback()}};spreadsheet_api.prototype.asyncFontEndLoaded=function(font){this.sync_EndAction(c_oAscAsyncActionType.Information,c_oAscAsyncAction.LoadFont)};spreadsheet_api.prototype._loadFonts=
function(fonts,callback){if(window["NATIVE_EDITOR_ENJINE"])return callback();this.asyncMethodCallback=callback;var arrLoadFonts=[];for(var i in fonts)arrLoadFonts.push(new AscFonts.CFont(i,0,"",0));AscFonts.FontPickerByCharacter.extendFonts(arrLoadFonts);this.FontLoader.LoadDocumentFonts2(arrLoadFonts)};spreadsheet_api.prototype.openDocument=function(file){this._openDocument(file.data);this._openOnClient()};spreadsheet_api.prototype.openDocumentFromZip=function(wb,data){var t=this;return new Promise(function(resolve,
reject){var openXml=AscCommon.openXml;if(t.isChartEditor){resolve();return}var nextPromise;if(data){var doc=new openXml.OpenXmlPackage;var wbPart=null;var wbXml=null;var pivotCaches={};var jsZipWrapper=new AscCommon.JSZipWrapper;nextPromise=jsZipWrapper.loadAsync(data).then(function(zip){return doc.openFromZip(zip)}).then(function(){wbPart=doc.getPartByRelationshipType(openXml.relationshipTypes.workbook);return wbPart.getDocumentContent()}).then(function(contentWorkbook){wbXml=new AscCommonExcel.CT_Workbook;
(new openXml.SaxParserBase).parse(contentWorkbook,wbXml);if(wbXml.pivotCaches)return wbXml.pivotCaches.reduce(function(prevVal,wbPivotCacheXml){var pivotTableCacheDefinitionPart;var pivotTableCacheDefinition;return prevVal.then(function(){if(null!==wbPivotCacheXml.cacheId&&null!==wbPivotCacheXml.id){pivotTableCacheDefinitionPart=wbPart.getPartById(wbPivotCacheXml.id);return pivotTableCacheDefinitionPart.getDocumentContent()}}).then(function(content){if(content){pivotTableCacheDefinition=new Asc.CT_PivotCacheDefinition;
(new openXml.SaxParserBase).parse(content,pivotTableCacheDefinition);if(pivotTableCacheDefinition.isValidCacheSource()){pivotCaches[wbPivotCacheXml.cacheId]=pivotTableCacheDefinition;if(pivotTableCacheDefinition.id){var partPivotTableCacheRecords=pivotTableCacheDefinitionPart.getPartById(pivotTableCacheDefinition.id);return partPivotTableCacheRecords.getDocumentContent()}}}}).then(function(content){if(content){var pivotTableCacheRecords=new Asc.CT_PivotCacheRecords;(new openXml.SaxParserBase).parse(content,
pivotTableCacheRecords);pivotTableCacheDefinition.cacheRecords=pivotTableCacheRecords}})},Promise.resolve())}).then(function(){if(wbXml.sheets){var wsIndex=0;return wbXml.sheets.reduce(function(prevVal,wbSheetXml){var wsPart;return prevVal.then(function(){if(null!==wbSheetXml.id){var actions=[];wsPart=wbPart.getPartById(wbSheetXml.id);var pivotParts=wsPart.getPartsByRelationshipType(openXml.relationshipTypes.pivotTable);for(var i=0;i<pivotParts.length;++i)actions.push(pivotParts[i].getDocumentContent());
return Promise.all(actions)}}).then(function(res){if(res){var ws=t.wbModel.getWorksheet(wsIndex);for(var i=0;i<res.length;++i){var pivotTable=new Asc.CT_pivotTableDefinition;(new openXml.SaxParserBase).parse(res[i],pivotTable);var cacheDefinition=pivotCaches[pivotTable.cacheId];if(cacheDefinition){pivotTable.cacheDefinition=cacheDefinition;ws.insertPivotTable(pivotTable)}}}wsIndex++})},Promise.resolve())}}).catch(function(err){if(window.console&&window.console.log)window.console.log(err)}).then(function(){jsZipWrapper.close()})}else nextPromise=
Promise.resolve();nextPromise.then(function(err){openXml.SaxParserDataTransfer={};return Asc.ReadDefTableStyles(wb)}).then(resolve,reject)})};spreadsheet_api.prototype.syncCollaborativeChanges=function(){if(!this.collaborativeEditing.getFast())this.handlers.trigger("asc_onCollaborativeChanges")};spreadsheet_api.prototype._applyFirstLoadChanges=function(){if(this.isDocumentLoadComplete)return;if(this.collaborativeEditing.applyChanges())this.onDocumentContentReady();this.collaborativeEditing.sendChanges()};
spreadsheet_api.prototype.goTo=function(action){var comment=this.wbModel.getComment(action&&action["data"]);if(comment){this.asc_showWorksheet(this.wbModel.getWorksheetById(comment.wsId).getIndex());this.asc_selectComment(comment.nId);this.asc_showComment(comment.nId)}};spreadsheet_api.prototype._coAuthoringInitEnd=function(){var t=this;this.collaborativeEditing=new AscCommonExcel.CCollaborativeEditing({"askLock":function(){t.CoAuthoringApi.askLock.apply(t.CoAuthoringApi,arguments)},"releaseLocks":function(){t.CoAuthoringApi.releaseLocks.apply(t.CoAuthoringApi,
arguments)},"sendChanges":function(){t._onSaveChanges.apply(t,arguments)},"applyChanges":function(){t._onApplyChanges.apply(t,arguments)},"updateAfterApplyChanges":function(){t._onUpdateAfterApplyChanges.apply(t,arguments)},"drawSelection":function(){t._onDrawSelection.apply(t,arguments)},"drawFrozenPaneLines":function(){t._onDrawFrozenPaneLines.apply(t,arguments)},"updateAllSheetsLock":function(){t._onUpdateAllSheetsLock.apply(t,arguments)},"showDrawingObjects":function(){t._onShowDrawingObjects.apply(t,
arguments)},"showComments":function(){t._onShowComments.apply(t,arguments)},"cleanSelection":function(){t._onCleanSelection.apply(t,arguments)},"updateDocumentCanSave":function(){t._onUpdateDocumentCanSave()},"checkCommentRemoveLock":function(lockElem){return t._onCheckCommentRemoveLock(lockElem)},"unlockDefName":function(){t._onUnlockDefName.apply(t,arguments)},"checkDefNameLock":function(lockElem){return t._onCheckDefNameLock(lockElem)},"updateAllLayoutsLock":function(){t._onUpdateAllLayoutsLock.apply(t,
arguments)},"updateAllHeaderFooterLock":function(){t._onUpdateAllHeaderFooterLock.apply(t,arguments)}},this.getViewMode());this.CoAuthoringApi.onConnectionStateChanged=function(e){t.handlers.trigger("asc_onConnectionStateChanged",e)};this.CoAuthoringApi.onLocksAcquired=function(e){if(t._coAuthoringCheckEndOpenDocument(t.CoAuthoringApi.onLocksAcquired,e))return;if(2!=e["state"]){var elementValue=e["blockValue"];var lockElem=t.collaborativeEditing.getLockByElem(elementValue,c_oAscLockTypes.kLockTypeOther);

Loading…
Cancel
Save