Skip to content

Commit

Permalink
Merge pull request #2510 from ONLYOFFICE/feature/sse-hf-image
Browse files Browse the repository at this point in the history
[SSE] Bug 62317: insert picture to header/footer
  • Loading branch information
JuliaRadzhabova authored Aug 1, 2023
2 parents 4a50d9b + a1179e7 commit 2eec825
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 77 deletions.
173 changes: 98 additions & 75 deletions apps/spreadsheeteditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
},

Expand Down Expand Up @@ -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.<br>Press \"Replace\" to replace existing picture.<br>Press \"Keep\" to keep existing picture.',
textReplace: 'Replace',
textKeep: 'Keep'
}
})(), SSE.Controllers.Main || {}))
});
6 changes: 4 additions & 2 deletions apps/spreadsheeteditor/main/app/view/HeaderFooterDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 || {}))
});
4 changes: 4 additions & 0 deletions apps/spreadsheeteditor/main/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br>Press \"Replace\" to replace existing picture.<br>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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 2eec825

Please sign in to comment.