Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/row col breaks #3616

Merged
merged 43 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
48cd155
[se] Init for read colbreaks/rowbreaks
GoshaZotov Jun 29, 2023
612d818
[se] By init
GoshaZotov Jun 29, 2023
334d524
[se] Fix
GoshaZotov Jun 29, 2023
269591a
[se] Init view
GoshaZotov Jul 3, 2023
a04f851
[se] Fix
GoshaZotov Jul 4, 2023
aaee687
[se] Fix
GoshaZotov Jul 4, 2023
f3b5f8e
[se] Fix
GoshaZotov Jul 4, 2023
a1c3a96
[se] Fix
GoshaZotov Jul 5, 2023
6021a55
[se] By move break lines
GoshaZotov Jul 5, 2023
063d4d1
[se] Fix
GoshaZotov Jul 5, 2023
a394564
[se] By change row/col breaks
GoshaZotov Jul 6, 2023
2955692
[se] Add change breaks functions
GoshaZotov Jul 6, 2023
e702458
[se] Fix
GoshaZotov Jul 6, 2023
5a058df
[se] Fix
GoshaZotov Jul 6, 2023
8d0520c
[se] Fix
GoshaZotov Jul 6, 2023
281a70f
[se] Fix
GoshaZotov Jul 7, 2023
79994ac
[se] Fix
GoshaZotov Jul 7, 2023
0514fe1
[se] Insert page break
GoshaZotov Jul 7, 2023
e904bd0
[se] Remove page break
GoshaZotov Jul 7, 2023
9c24fe2
[se] Remove all
GoshaZotov Jul 7, 2023
5da5cc8
[se] Export
GoshaZotov Jul 7, 2023
f82b095
[se] By tests
GoshaZotov Jul 10, 2023
839485a
[se] Add tests
GoshaZotov Jul 10, 2023
1e79a89
[se] Add tests
GoshaZotov Jul 10, 2023
5d8f190
[se] By history
GoshaZotov Jul 11, 2023
564831b
[se] By history
GoshaZotov Jul 11, 2023
cf4fac7
[se] Fix
GoshaZotov Jul 11, 2023
a39e5c0
[se] Fix tests
GoshaZotov Jul 11, 2023
7b385b6
[se] Tests
GoshaZotov Jul 13, 2023
14f00fa
[se] Tests
GoshaZotov Jul 13, 2023
6c61ac7
[se] Fix + tests
GoshaZotov Jul 14, 2023
4983a97
[se] Add remove all to history
GoshaZotov Jul 14, 2023
0ec1071
[se] Fix
GoshaZotov Jul 14, 2023
d579b05
[se] Fixes + test
GoshaZotov Jul 17, 2023
a73f819
[se] Fix
GoshaZotov Jul 17, 2023
c3955bd
[se] By tests
GoshaZotov Jul 17, 2023
04fb71d
Merge branch 'develop' into feature/row-col-breaks
GoshaZotov Jul 17, 2023
ae3992e
[se] Add asc_isContainsPageBreaks
GoshaZotov Jul 18, 2023
00bf82f
[se] Add asc_GetPageBreaksDisableType
GoshaZotov Jul 18, 2023
3b63aa3
[se] Fix style code
GoshaZotov Jul 18, 2023
6626567
[se] Fix
GoshaZotov Jul 18, 2023
5fd1547
[se] Fix
GoshaZotov Jul 18, 2023
893141b
[se] Fix style code
GoshaZotov Jul 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 123 additions & 9 deletions cell/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -5886,7 +5899,11 @@ var editor;
};

spreadsheet_api.prototype.asc_setCellBold = function(isBold) {
var ws = this.wb.getWorksheet();
if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) {
return;
}

let ws = this.wb.getWorksheet();
if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellBold) {
ws.objectRender.controller.setCellBold(isBold);
} else {
Expand All @@ -5896,7 +5913,11 @@ var editor;
};

spreadsheet_api.prototype.asc_setCellItalic = function(isItalic) {
var ws = this.wb.getWorksheet();
if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) {
return;
}

let ws = this.wb.getWorksheet();
if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellItalic) {
ws.objectRender.controller.setCellItalic(isItalic);
} else {
Expand All @@ -5906,7 +5927,11 @@ var editor;
};

spreadsheet_api.prototype.asc_setCellUnderline = function(isUnderline) {
var ws = this.wb.getWorksheet();
if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) {
return;
}

let ws = this.wb.getWorksheet();
if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellUnderline) {
ws.objectRender.controller.setCellUnderline(isUnderline);
} else {
Expand All @@ -5916,7 +5941,11 @@ var editor;
};

spreadsheet_api.prototype.asc_setCellStrikeout = function(isStrikeout) {
var ws = this.wb.getWorksheet();
if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) {
return;
}

let ws = this.wb.getWorksheet();
if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellStrikeout) {
ws.objectRender.controller.setCellStrikeout(isStrikeout);
} else {
Expand All @@ -5926,7 +5955,11 @@ var editor;
};

spreadsheet_api.prototype.asc_setCellSubscript = function(isSubscript) {
var ws = this.wb.getWorksheet();
if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) {
return;
}

let ws = this.wb.getWorksheet();
if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellSubscript) {
ws.objectRender.controller.setCellSubscript(isSubscript);
} else {
Expand All @@ -5936,7 +5969,11 @@ var editor;
};

spreadsheet_api.prototype.asc_setCellSuperscript = function(isSuperscript) {
var ws = this.wb.getWorksheet();
if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) {
return;
}

let ws = this.wb.getWorksheet();
if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellSuperscript) {
ws.objectRender.controller.setCellSuperscript(isSuperscript);
} else {
Expand All @@ -5946,7 +5983,11 @@ var editor;
};

spreadsheet_api.prototype.asc_setCellAlign = function(align) {
var ws = this.wb.getWorksheet();
if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) {
return;
}

let ws = this.wb.getWorksheet();
if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellAlign) {
ws.objectRender.controller.setCellAlign(align);
} else {
Expand All @@ -5956,7 +5997,11 @@ var editor;
};

spreadsheet_api.prototype.asc_setCellVertAlign = function(align) {
var ws = this.wb.getWorksheet();
if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) {
return;
}

let ws = this.wb.getWorksheet();
if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellVertAlign) {
ws.objectRender.controller.setCellVertAlign(align);
} else {
Expand Down Expand Up @@ -8775,6 +8820,70 @@ var editor;
return res == null ? AscCommonExcel.ESheetViewType.normal : res;
};

spreadsheet_api.prototype.asc_InsertPageBreak = function() {
if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) {
return;
}
let wb = this.wb;
if (!wb) {
return;
}
var ws = this.wb.getWorksheet();
return ws && ws.insertPageBreak();
};

spreadsheet_api.prototype.asc_RemovePageBreak = function() {
if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) {
return;
}
let wb = this.wb;
if (!wb) {
return;
}
var ws = this.wb.getWorksheet();
return ws.removePageBreak();
};

spreadsheet_api.prototype.asc_ResetAllPageBreaks = function() {
if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) {
return;
}
let wb = this.wb;
if (!wb) {
return;
}
var ws = this.wb.getWorksheet();
return ws.resetAllPageBreaks();
};

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 res;
};


/*
* Export
* -----------------------------------------------------------------------------
Expand Down Expand Up @@ -9340,6 +9449,11 @@ 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_GetPageBreaksDisableType"]= prot.asc_GetPageBreaksDisableType;




Expand Down
17 changes: 16 additions & 1 deletion cell/apiDefines.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,15 @@ var c_oAscPopUpSelectorType = {
path: 2
};

//----------------------------------------------------------export----------------------------------------------------
var c_oAscPageBreaksDisableType = {
none: 0,
all: 1,
insertRemove: 2,
reset: 3
};


//----------------------------------------------------------export----------------------------------------------------
window['AscCommonExcel'] = window['AscCommonExcel'] || {};
window['AscCommonExcel'].c_oAscDrawDepOptions = c_oAscDrawDepOptions;
window['AscCommonExcel'].c_oAscScrollType = c_oAscScrollType;
Expand Down Expand Up @@ -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);
2 changes: 2 additions & 0 deletions cell/model/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ function (window, undefined) {

window['AscCH'].historyitem_Worksheet_SetShowFormulas = 62;

window['AscCH'].historyitem_Worksheet_ChangeRowColBreaks = 63;

window['AscCH'].historyitem_RowCol_Fontname = 1;
window['AscCH'].historyitem_RowCol_Fontsize = 2;
window['AscCH'].historyitem_RowCol_Fontcolor = 3;
Expand Down
56 changes: 32 additions & 24 deletions cell/model/Serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -8244,18 +8244,17 @@
res = this.bcr.Read1(length, function(t, l) {
return oThis.ReadHeaderFooter(t, l, oWorksheet.headerFooter);
});
// Disable HeaderFooter opening to prevent file corruption
// } else if (c_oSerWorksheetsTypes.RowBreaks === type) {
// oWorksheet.rowBreaks = {count: null, manualBreakCount: null, breaks: []};
// res = this.bcr.Read1(length, function (t, l) {
// return oThis.ReadRowColBreaks(t, l, oWorksheet.rowBreaks);
// });
// } else if (c_oSerWorksheetsTypes.ColBreaks === type) {
// oWorksheet.colBreaks = {count: null, manualBreakCount: null, breaks: []};
// res = this.bcr.Read1(length, function (t, l) {
// return oThis.ReadRowColBreaks(t, l, oWorksheet.colBreaks);
// });
// } else if (c_oSerWorksheetsTypes.LegacyDrawingHF === type) {
} else if (c_oSerWorksheetsTypes.RowBreaks === type) {
oWorksheet.rowBreaks = new AscCommonExcel.CRowColBreaks();
res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadRowColBreaks(t, l, oWorksheet.rowBreaks);
});
} else if (c_oSerWorksheetsTypes.ColBreaks === type) {
oWorksheet.colBreaks = new AscCommonExcel.CRowColBreaks();
res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadRowColBreaks(t, l, oWorksheet.colBreaks);
});
//} else if (c_oSerWorksheetsTypes.LegacyDrawingHF === type) {
// oWorksheet.legacyDrawingHF = {
// drawings: [], cfe: null, cff: null, cfo: null, che: null, chf: null, cho: null, lfe: null,
// lff: null, lfo: null, lhe: null, lhf: null, lho: null, rfe: null, rff: null, rfo: null, rhe: null,
Expand Down Expand Up @@ -9895,34 +9894,43 @@
return res;
};
this.ReadRowColBreaks = function (type, length, breaks) {
var oThis = this;
var res = c_oSerConstants.ReadOk;
let oThis = this;
let res = c_oSerConstants.ReadOk;
let val;
if (c_oSer_RowColBreaks.Count === type) {
breaks.count = this.stream.GetLong();
val = this.stream.GetLong();
breaks.setCount(val);
} else if (c_oSer_RowColBreaks.ManualBreakCount === type) {
breaks.manualBreakCount = this.stream.GetLong();
val = this.stream.GetLong();
breaks.setManualBreakCount(val);
} else if (c_oSer_RowColBreaks.Break === type) {
var brk = {id: null, man: null, max: null, min: null, pt: null};
var brk = new AscCommonExcel.CBreak();
res = this.bcr.Read1(length, function(t, l) {
return oThis.ReadRowColBreak(t, l, brk);
});
breaks.breaks.push(brk);
breaks.pushBreak(brk);
} else
res = c_oSerConstants.ReadUnknown;
return res;
};
this.ReadRowColBreak = function (type, length, brk) {
var res = c_oSerConstants.ReadOk;
let res = c_oSerConstants.ReadOk;
let val;
if (c_oSer_RowColBreaks.Id === type) {
brk.id = this.stream.GetLong();
val = this.stream.GetLong();
brk.setId(val);
} else if (c_oSer_RowColBreaks.Man === type) {
brk.man = this.stream.GetBool();
val = this.stream.GetBool();
brk.setMan(val);
} else if (c_oSer_RowColBreaks.Max === type) {
brk.max = this.stream.GetLong();
val = this.stream.GetLong();
brk.setMax(val);
} else if (c_oSer_RowColBreaks.Min === type) {
brk.min = this.stream.GetLong();
val = this.stream.GetLong();
brk.setMin(val);
} else if (c_oSer_RowColBreaks.Pt === type) {
brk.pt = this.stream.GetBool();
val = this.stream.GetBool();
brk.setPt(val);
} else
res = c_oSerConstants.ReadUnknown;
return res;
Expand Down
Loading
Loading