From a1179e76304da3118f13d41fe406294e9e8d516a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 1 Aug 2023 15:26:07 +0300 Subject: [PATCH] [SSE] Bug 62317: insert picture to header/footer --- .../main/app/controller/Main.js | 173 ++++++++++-------- .../main/app/view/HeaderFooterDialog.js | 6 +- apps/spreadsheeteditor/main/locale/en.json | 4 + 3 files changed, 106 insertions(+), 77 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index cd913493d5..056d1a953f 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2433,82 +2433,102 @@ define([ onConfirmAction: function(id, apiCallback, data) { var me = this; - if (id == Asc.c_oAscConfirm.ConfirmReplaceRange || id == Asc.c_oAscConfirm.ConfirmReplaceFormulaInTable) { - Common.UI.warning({ - title: this.notcriticalErrorTitle, - msg: id == Asc.c_oAscConfirm.ConfirmReplaceRange ? this.confirmMoveCellRange : this.confirmReplaceFormulaInTable, - buttons: ['yes', 'no'], - primary: 'yes', - callback: _.bind(function(btn) { - if (apiCallback) { - apiCallback(btn === 'yes'); - } - if (btn == 'yes') { + switch (id) { + case Asc.c_oAscConfirm.ConfirmReplaceRange: + case Asc.c_oAscConfirm.ConfirmReplaceFormulaInTable: + Common.UI.warning({ + title: this.notcriticalErrorTitle, + msg: id == Asc.c_oAscConfirm.ConfirmReplaceRange ? this.confirmMoveCellRange : this.confirmReplaceFormulaInTable, + buttons: ['yes', 'no'], + primary: 'yes', + callback: _.bind(function(btn) { + if (apiCallback) { + apiCallback(btn === 'yes'); + } + if (btn == 'yes') { + me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); + } + }, this) + }); + break; + case Asc.c_oAscConfirm.ConfirmPutMergeRange: + Common.UI.warning({ + closable: false, + title: this.notcriticalErrorTitle, + msg: this.confirmPutMergeRange, + buttons: ['ok'], + primary: 'ok', + callback: _.bind(function(btn) { + if (apiCallback) { + apiCallback(); + } + me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); + }, this) + }); + break; + case Asc.c_oAscConfirm.ConfirmChangeProtectRange: + var win = new Common.Views.OpenDialog({ + title: this.txtUnlockRange, + closable: true, + type: Common.Utils.importTextType.DRM, + warning: true, + warningMsg: this.txtUnlockRangeWarning, + txtOpenFile: this.txtUnlockRangeDescription, + validatePwd: false, + handler: function (result, value) { + if (me.api && apiCallback) { + if (result == 'ok') { + me.api.asc_checkProtectedRangesPassword(value.drmOptions.asc_getPassword(), data, function(res) { + apiCallback(res, false); + }); + } else + apiCallback(false, true); + } me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); } - }, this) - }); - } else if (id == Asc.c_oAscConfirm.ConfirmPutMergeRange) { - Common.UI.warning({ - closable: false, - title: this.notcriticalErrorTitle, - msg: this.confirmPutMergeRange, - buttons: ['ok'], - primary: 'ok', - callback: _.bind(function(btn) { - if (apiCallback) { - apiCallback(); - } - me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); - }, this) - }); - } else if (id == Asc.c_oAscConfirm.ConfirmChangeProtectRange) { - var win = new Common.Views.OpenDialog({ - title: this.txtUnlockRange, - closable: true, - type: Common.Utils.importTextType.DRM, - warning: true, - warningMsg: this.txtUnlockRangeWarning, - txtOpenFile: this.txtUnlockRangeDescription, - validatePwd: false, - handler: function (result, value) { - if (me.api && apiCallback) { - if (result == 'ok') { - me.api.asc_checkProtectedRangesPassword(value.drmOptions.asc_getPassword(), data, function(res) { - apiCallback(res, false); - }); - } else - apiCallback(false, true); - } - me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); - } - }); - win.show(); - } else if (id == Asc.c_oAscConfirm.ConfirmAddCellWatches) { - Common.UI.warning({ - title: this.notcriticalErrorTitle, - msg: (data>Asc.c_nAscMaxAddCellWatchesCount) ? Common.Utils.String.format(this.confirmAddCellWatchesMax, Asc.c_nAscMaxAddCellWatchesCount) : Common.Utils.String.format(this.confirmAddCellWatches, data), - buttons: ['yes', 'no'], - primary: 'yes', - callback: _.bind(function(btn) { - if (apiCallback) { - apiCallback(btn === 'yes'); - } - }, this) - }); - } else if (id == Asc.c_oAscConfirm.ConfirmMaxChangesSize) { - Common.UI.warning({ - title: this.notcriticalErrorTitle, - msg: this.confirmMaxChangesSize, - buttons: [{value: 'ok', caption: this.textUndo, primary: true}, {value: 'cancel', caption: this.textContinue}], - maxwidth: 600, - callback: _.bind(function(btn) { - if (apiCallback) { - apiCallback(btn === 'ok'); - } - me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); - }, this) - }); + }); + win.show(); + break; + case Asc.c_oAscConfirm.ConfirmAddCellWatches: + Common.UI.warning({ + title: this.notcriticalErrorTitle, + msg: (data>Asc.c_nAscMaxAddCellWatchesCount) ? Common.Utils.String.format(this.confirmAddCellWatchesMax, Asc.c_nAscMaxAddCellWatchesCount) : Common.Utils.String.format(this.confirmAddCellWatches, data), + buttons: ['yes', 'no'], + primary: 'yes', + callback: _.bind(function(btn) { + if (apiCallback) { + apiCallback(btn === 'yes'); + } + }, this) + }); + break; + case Asc.c_oAscConfirm.ConfirmMaxChangesSize: + Common.UI.warning({ + title: this.notcriticalErrorTitle, + msg: this.confirmMaxChangesSize, + buttons: [{value: 'ok', caption: this.textUndo, primary: true}, {value: 'cancel', caption: this.textContinue}], + maxwidth: 600, + callback: _.bind(function(btn) { + if (apiCallback) { + apiCallback(btn === 'ok'); + } + me.onEditComplete(me.application.getController('DocumentHolder').getView('DocumentHolder')); + }, this) + }); + break; + case Asc.c_oAscConfirm.ConfirmReplaceHeaderFooterPicture: + Common.UI.warning({ + title: this.notcriticalErrorTitle, + msg: this.confirmReplaceHFPicture, + buttons: [{value: 'ok', caption: this.textReplace, primary: true}, {value: 'cancel', caption: this.textKeep}], + maxwidth: 600, + callback: _.bind(function(btn) { + if (apiCallback) { + apiCallback(btn === 'ok'); + } + }, this) + }); + break; } }, @@ -3856,7 +3876,10 @@ define([ txtNone: 'None', warnLicenseAnonymous: 'Access denied for anonymous users. This document will be opened for viewing only.', txtSlicer: 'Slicer', - txtInfo: 'Info' + txtInfo: 'Info', + confirmReplaceHFPicture: 'Only one picture can be inserted in each section of the header.
Press \"Replace\" to replace existing picture.
Press \"Keep\" to keep existing picture.', + textReplace: 'Replace', + textKeep: 'Keep' } })(), SSE.Controllers.Main || {})) }); diff --git a/apps/spreadsheeteditor/main/app/view/HeaderFooterDialog.js b/apps/spreadsheeteditor/main/app/view/HeaderFooterDialog.js index 8647f89b81..6ec3a7a134 100644 --- a/apps/spreadsheeteditor/main/app/view/HeaderFooterDialog.js +++ b/apps/spreadsheeteditor/main/app/view/HeaderFooterDialog.js @@ -292,7 +292,8 @@ define([ {caption: this.textDate, value: Asc.c_oAscHeaderFooterField.date}, {caption: this.textTime, value: Asc.c_oAscHeaderFooterField.time}, {caption: this.textFileName, value: Asc.c_oAscHeaderFooterField.fileName}, - {caption: this.textSheet, value: Asc.c_oAscHeaderFooterField.sheetName} + {caption: this.textSheet, value: Asc.c_oAscHeaderFooterField.sheetName}, + {caption: this.textImage, value: Asc.c_oAscHeaderFooterField.picture} ]; this.btnInsertH = new Common.UI.Button({ @@ -1029,7 +1030,8 @@ define([ textOdd: 'Odd page', textEven: 'Even page', textAll: 'All pages', - textMaxError: 'The text string you entered is too long. Reduce the number of characters used.' + textMaxError: 'The text string you entered is too long. Reduce the number of characters used.', + textImage: 'Picture' }, SSE.Views.HeaderFooterDialog || {})) }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 5f2f71e46d..82b968bb2d 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1372,6 +1372,9 @@ "SSE.Controllers.Main.txtNone": "None", "SSE.Controllers.Main.txtSlicer": "Slicer", "SSE.Controllers.Main.txtInfo": "Info", + "SSE.Controllers.Main.confirmReplaceHFPicture": "Only one picture can be inserted in each section of the header.
Press \"Replace\" to replace existing picture.
Press \"Keep\" to keep existing picture.", + "SSE.Controllers.Main.textReplace": "Replace", + "SSE.Controllers.Main.textKeep": "Keep", "SSE.Controllers.PivotTable.strSheet": "Sheet", "SSE.Controllers.Print.strAllSheets": "All Sheets", "SSE.Controllers.Print.textFirstCol": "First column", @@ -2878,6 +2881,7 @@ "SSE.Views.HeaderFooterDialog.textUnderline": "Underline", "SSE.Views.HeaderFooterDialog.tipFontName": "Font", "SSE.Views.HeaderFooterDialog.tipFontSize": "Font size", + "SSE.Views.HeaderFooterDialog.textImage": "Picture", "SSE.Views.HyperlinkSettingsDialog.strDisplay": "Display", "SSE.Views.HyperlinkSettingsDialog.strLinkTo": "Link to", "SSE.Views.HyperlinkSettingsDialog.strRange": "Range",