diff --git a/cell/api.js b/cell/api.js index c90425f979..056c023f69 100644 --- a/cell/api.js +++ b/cell/api.js @@ -5813,9 +5813,22 @@ var editor; return oWorksheet.getActiveCellCoord(useUpRightMerge); } } - }; + // Получить координаты активной ячейки + spreadsheet_api.prototype.asc_getActiveCell = function() { + var oWorksheet = this.wb.getWorksheet(); + if(oWorksheet){ + if(oWorksheet.isSelectOnShape){ + return null; + } + else{ + return oWorksheet.getActiveCell(); + } + } + + }; + // Получить координаты для каких-либо действий (для общей схемы) spreadsheet_api.prototype.asc_getAnchorPosition = function() { return this.asc_getActiveCellCoord(); @@ -8820,16 +8833,34 @@ var editor; return ws.resetAllPageBreaks(); }; - spreadsheet_api.prototype.asc_isContainsPageBreaks = function (index) { + spreadsheet_api.prototype.asc_GetPageBreaksDisableType = function (index) { if (!this.wbModel) { return; } let sheetIndex = (undefined !== index && null !== index) ? index : this.wbModel.getActive(); let ws = this.wbModel.getWorksheet(sheetIndex); + let res = Asc.c_oAscPageBreaksDisableType.none; + if (ws) { + let isPageBreaks = ws && ((ws.colBreaks && ws.colBreaks.getCount()) || (ws.rowBreaks && ws.rowBreaks.getCount())); + let activeCell = ws.selectionRange && ws.selectionRange.activeCell; + let isFirstActiveCell = activeCell && activeCell.col === 0 && activeCell.row === 0; + + if (isFirstActiveCell && !isPageBreaks) { + //disable all + res = Asc.c_oAscPageBreaksDisableType.all; + } else if (isFirstActiveCell && isPageBreaks) { + //disable insert/remove + res = Asc.c_oAscPageBreaksDisableType.insertRemove; + } else if (!isFirstActiveCell && !isPageBreaks) { + //disable reset + res = Asc.c_oAscPageBreaksDisableType.reset; + } + } - return ws && ((ws.colBreaks && ws.colBreaks.getCount()) || (ws.rowBreaks && ws.rowBreaks.getCount())); + return res; }; + /* * Export * ----------------------------------------------------------------------------- @@ -9395,10 +9426,10 @@ var editor; prot["asc_ChangeTextCase"] = prot.asc_ChangeTextCase; - prot["asc_InsertPageBreak"] = prot.asc_InsertPageBreak; - prot["asc_RemovePageBreak"] = prot.asc_RemovePageBreak; - prot["asc_ResetAllPageBreaks"] = prot.asc_ResetAllPageBreaks; - prot["asc_isContainsPageBreaks"] = prot.asc_isContainsPageBreaks; + prot["asc_InsertPageBreak"] = prot.asc_InsertPageBreak; + prot["asc_RemovePageBreak"] = prot.asc_RemovePageBreak; + prot["asc_ResetAllPageBreaks"] = prot.asc_ResetAllPageBreaks; + prot["asc_GetPageBreaksDisableType"]= prot.asc_GetPageBreaksDisableType; diff --git a/cell/apiDefines.js b/cell/apiDefines.js index e03a5aa286..7e717d0101 100644 --- a/cell/apiDefines.js +++ b/cell/apiDefines.js @@ -571,7 +571,15 @@ var c_oAscPopUpSelectorType = { path: 2 }; - //----------------------------------------------------------export---------------------------------------------------- + var c_oAscPageBreaksDisableType = { + none: 0, + all: 1, + insertRemove: 3, + reset: 3 + }; + + + //----------------------------------------------------------export---------------------------------------------------- window['AscCommonExcel'] = window['AscCommonExcel'] || {}; window['AscCommonExcel'].c_oAscDrawDepOptions = c_oAscDrawDepOptions; window['AscCommonExcel'].c_oAscScrollType = c_oAscScrollType; @@ -965,5 +973,12 @@ var c_oAscPopUpSelectorType = { prot['link'] = prot.link; prot['path'] = prot.path; + window['Asc']['c_oAscPageBreaksDisableType'] = window['Asc'].c_oAscPageBreaksDisableType = c_oAscPageBreaksDisableType; + prot = c_oAscPageBreaksDisableType; + prot['none'] = prot.none; + prot['all'] = prot.all; + prot['insertRemove'] = prot.insertRemove; + prot['reset'] = prot.reset; + })(window);