Commit 3840c556 authored by Alexander.Trofimov's avatar Alexander.Trofimov

add SetDisplayGridlines, SetDisplayHeadings in api builder

asc_setSheetViewSettings -> asc_setDisplayGridlines + asc_setDisplayHeadings
parent 0d9b7737
No related merge requests found
......@@ -2181,9 +2181,15 @@ var editor;
return this.wb.getWorksheet().getSheetViewSettings();
};
spreadsheet_api.prototype.asc_setSheetViewSettings = function(options) {
this.wb.getWorksheet().changeWorksheet("sheetViewSettings", options);
};
spreadsheet_api.prototype.asc_setDisplayGridlines = function (value) {
this.wb.getWorksheet()
.changeWorksheet("sheetViewSettings", {type: AscCH.historyitem_Worksheet_SetDisplayGridlines, value: value});
};
spreadsheet_api.prototype.asc_setDisplayHeadings = function (value) {
this.wb.getWorksheet()
.changeWorksheet("sheetViewSettings", {type: AscCH.historyitem_Worksheet_SetDisplayHeadings, value: value});
};
// Images & Charts
......@@ -3499,7 +3505,8 @@ var editor;
prot["asc_emptyCells"] = prot.asc_emptyCells;
prot["asc_mergeCellsDataLost"] = prot.asc_mergeCellsDataLost;
prot["asc_getSheetViewSettings"] = prot.asc_getSheetViewSettings;
prot["asc_setSheetViewSettings"] = prot.asc_setSheetViewSettings;
prot["asc_setDisplayGridlines"] = prot.asc_setDisplayGridlines;
prot["asc_setDisplayHeadings"] = prot.asc_setDisplayHeadings;
// Defined Names
prot["asc_getDefinedNames"] = prot.asc_getDefinedNames;
......
......@@ -168,6 +168,24 @@
this.worksheet.setColWidth(width, column, column);
};
/**
* Set displayed gridlines
* @memberof ApiWorksheet
* @param {bool} value
*/
ApiWorksheet.prototype.SetDisplayGridlines = function (value) {
this.worksheet.setDisplayGridlines(!!value);
};
/**
* Set displayed headings
* @memberof ApiWorksheet
* @param {bool} value
*/
ApiWorksheet.prototype.SetDisplayHeadings = function (value) {
this.worksheet.setDisplayHeadings(!!value);
};
/**
* Set column width
* @memberof ApiWorksheet
......@@ -336,7 +354,7 @@
/**
* Create a shape.
* @memberof Api
* @memberof ApiWorksheet
* @param {ShapeType} [sType="rect"]
* @param {EMU} nWidth
* @param {EMU} nHeight
......@@ -357,7 +375,7 @@
/**
* Create a image.
* @memberof Api
* @memberof ApiWorksheet
* @param {string} sImageSrc
* @param {EMU} nWidth
* @param {EMU} nHeight
......@@ -393,14 +411,15 @@
/**
* Set cell value
* @memberof ApiRange
* @param {string} val
* @param {string} value
*/
ApiRange.prototype.SetValue = function (val) {
this.range.setValue(val);
ApiRange.prototype.SetValue = function (value) {
this.range.setValue(value);
};
/**
* Set text color in the rgb format.
* @memberof ApiRange
* @param {byte} r
* @param {byte} g
* @param {byte} b
......@@ -411,6 +430,7 @@
/**
* Set font size
* @memberof ApiRange
* @param {number} size
*/
ApiRange.prototype.SetFontSize = function (size) {
......@@ -419,6 +439,7 @@
/**
* Set font name
* @memberof ApiRange
* @param {string} name
*/
ApiRange.prototype.SetFontName = function (name) {
......@@ -427,6 +448,7 @@
/**
* Set align vertical
* @memberof ApiRange
* @param {'center' | 'bottom' | 'top'} value
*/
ApiRange.prototype.SetAlignVertical = function (value) {
......@@ -482,8 +504,8 @@
/**
* Set bold
* @memberof ApiRange
* @param {bool} value
* @constructor
*/
ApiRange.prototype.SetBold = function (value) {
this.range.setBold(!!value);
......@@ -491,8 +513,8 @@
/**
* Set italic
* @memberof ApiRange
* @param {bool} value
* @constructor
*/
ApiRange.prototype.SetItalic = function (value) {
this.range.setItalic(!!value);
......@@ -500,8 +522,8 @@
/**
* Set underline
* @memberof ApiRange
* @param {bool} value
* @constructor
*/
ApiRange.prototype.SetUnderline = function (value) {
this.range.setUnderline(!!value);
......@@ -509,8 +531,8 @@
/**
* Set strikeout
* @memberof ApiRange
* @param {bool} value
* @constructor
*/
ApiRange.prototype.SetStrikeout = function (value) {
this.range.setStrikeout(!!value);
......@@ -518,6 +540,7 @@
/**
* Set fill color in the rgb format.
* @memberof ApiRange
* @param {byte} r
* @param {byte} g
* @param {byte} b
......@@ -741,6 +764,8 @@
ApiWorksheet.prototype["GetRangeByNumber"] = ApiWorksheet.prototype.GetRangeByNumber;
ApiWorksheet.prototype["FormatAsTable"] = ApiWorksheet.prototype.FormatAsTable;
ApiWorksheet.prototype["SetColumnWidth"] = ApiWorksheet.prototype.SetColumnWidth;
ApiWorksheet.prototype["SetDisplayGridlines"] = ApiWorksheet.prototype.SetDisplayGridlines;
ApiWorksheet.prototype["SetDisplayHeadings"] = ApiWorksheet.prototype.SetDisplayHeadings;
ApiWorksheet.prototype["AddChart"] = ApiWorksheet.prototype.AddChart;
ApiWorksheet.prototype["AddShape"] = ApiWorksheet.prototype.AddShape;
ApiWorksheet.prototype["AddImage"] = ApiWorksheet.prototype.AddImage;
......
......@@ -72,12 +72,14 @@ function (window, undefined) {
window['AscCH'].historyitem_Worksheet_CreateRow = 20;
window['AscCH'].historyitem_Worksheet_CreateCol = 21;
window['AscCH'].historyitem_Worksheet_CreateCell = 22;
window['AscCH'].historyitem_Worksheet_SetViewSettings = 23;
window['AscCH'].historyitem_Worksheet_RemoveCellFormula = 24;
window['AscCH'].historyitem_Worksheet_ChangeMerge = 25;
window['AscCH'].historyitem_Worksheet_ChangeHyperlink = 26;
window['AscCH'].historyitem_Worksheet_SetTabColor = 27;
window['AscCH'].historyitem_Worksheet_RowHide = 28;
window['AscCH'].historyitem_Worksheet_SetDisplayGridlines = 31;
window['AscCH'].historyitem_Worksheet_SetDisplayHeadings = 32;
// Frozen cell
window['AscCH'].historyitem_Worksheet_ChangeFrozenCell = 30;
......@@ -543,7 +545,9 @@ CHistory.prototype.Redo = function()
this.UndoRedoEnd(Point, oRedoObjectParam, false);
};
CHistory.prototype._addRedoObjectParam = function (oRedoObjectParam, Point) {
if (AscCommonExcel.g_oUndoRedoWorksheet === Point.Class && AscCH.historyitem_Worksheet_SetViewSettings === Point.Type) {
if (AscCommonExcel.g_oUndoRedoWorksheet === Point.Class &&
(AscCH.historyitem_Worksheet_SetDisplayGridlines === Point.Type ||
AscCH.historyitem_Worksheet_SetDisplayHeadings === Point.Type)) {
oRedoObjectParam.bIsReInit = true;
oRedoObjectParam.oOnUpdateSheetViewSettings[Point.SheetId] = Point.SheetId;
}
......
......@@ -421,7 +421,6 @@ var UndoRedoDataTypes = new function() {
this.DefinedNamesChange = 40;
this.SheetViewSettings = 43;
this.GlobalTableIdAdd = 44;
this.GraphicObjects = 45;
this.GOPairProps = 46;
......@@ -500,7 +499,6 @@ var UndoRedoDataTypes = new function() {
case this.SingleProperty: return new UndoRedoData_SingleProperty(); break;
case this.RgbColor: return new AscCommonExcel.RgbColor(); break;
case this.ThemeColor: return new AscCommonExcel.ThemeColor(); break;
case this.SheetViewSettings: return new AscCommonExcel.asc_CSheetViewSettings(); break;
case this.GraphicObjects: return new UndoRedoDataGraphicObjects();break;
case this.GlobalTableIdAdd: return new UndoRedoData_GTableIdAdd(); break;
......@@ -3560,8 +3558,10 @@ UndoRedoWoorksheet.prototype = {
else
ws._getCell(Data.nRow, Data.nCol);
}
else if (AscCH.historyitem_Worksheet_SetViewSettings === Type) {
ws.setSheetViewSettings(bUndo ? Data.from : Data.to);
else if (AscCH.historyitem_Worksheet_SetDisplayGridlines === Type) {
ws.setDisplayGridlines(bUndo ? Data.from : Data.to);
} else if (AscCH.historyitem_Worksheet_SetDisplayHeadings === Type) {
ws.setDisplayHeadings(bUndo ? Data.from : Data.to);
}
else if(AscCH.historyitem_Worksheet_ChangeMerge === Type){
from = null;
......
......@@ -4002,18 +4002,32 @@ Woorksheet.prototype.setHidden = function (hidden) {
Woorksheet.prototype.getSheetViewSettings = function () {
return this.sheetViews[0].clone();
};
Woorksheet.prototype.setSheetViewSettings = function (options) {
var current = this.getSheetViewSettings();
if (current.isEqual(options))
return;
Woorksheet.prototype.setDisplayGridlines = function (value) {
var view = this.sheetViews[0];
if (value !== view.showGridLines) {
History.Create_NewPoint();
History.Add(AscCommonExcel.g_oUndoRedoWorksheet, AscCH.historyitem_Worksheet_SetDisplayGridlines,
this.getId(), null, new UndoRedoData_FromTo(view.showGridLines, value));
view.showGridLines = value;
History.Create_NewPoint();
History.Add(AscCommonExcel.g_oUndoRedoWorksheet, AscCH.historyitem_Worksheet_SetViewSettings, this.getId(), null, new UndoRedoData_FromTo(current, options.clone()));
if (!this.workbook.bUndoChanges && !this.workbook.bRedoChanges) {
this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings");
}
}
};
Woorksheet.prototype.setDisplayHeadings = function (value) {
var view = this.sheetViews[0];
if (value !== view.showRowColHeaders) {
History.Create_NewPoint();
History.Add(AscCommonExcel.g_oUndoRedoWorksheet, AscCH.historyitem_Worksheet_SetDisplayHeadings,
this.getId(), null, new UndoRedoData_FromTo(view.showRowColHeaders, value));
view.showRowColHeaders = value;
this.sheetViews[0].setSettings(options);
if (!this.workbook.bUndoChanges && !this.workbook.bRedoChanges)
this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings");
};
if (!this.workbook.bUndoChanges && !this.workbook.bRedoChanges) {
this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings");
}
}
};
Woorksheet.prototype.getRowsCount=function(){
var result = this.nRowsCount;
var pane = this.sheetViews[0].pane;
......
......@@ -1570,14 +1570,8 @@
this["r2"] = r2;
}
var g_oCSheetViewSettingsProperties = {
showGridLines : 0,
showRowColHeaders : 1
};
/** @constructor */
function asc_CSheetViewSettings () {
this.Properties = g_oCSheetViewSettingsProperties;
// Показывать ли сетку
this.showGridLines = null;
// Показывать обозначения строк и столбцов
......@@ -1603,33 +1597,11 @@
return this.asc_getShowGridLines() === settings.asc_getShowGridLines() &&
this.asc_getShowRowColHeaders() === settings.asc_getShowRowColHeaders();
},
setSettings: function (settings) {
this.showGridLines = settings.showGridLines;
this.showRowColHeaders = settings.showRowColHeaders;
},
asc_getShowGridLines: function () { return false !== this.showGridLines; },
asc_getShowRowColHeaders: function () { return false !== this.showRowColHeaders; },
asc_getIsFreezePane: function () { return null !== this.pane && this.pane.isInit(); },
asc_setShowGridLines: function (val) { this.showGridLines = val; },
asc_setShowRowColHeaders: function (val) { this.showRowColHeaders = val; },
getType : function () {
return AscCommonExcel.UndoRedoDataTypes.SheetViewSettings;
},
getProperties : function () {
return this.Properties;
},
getProperty : function (nType) {
switch (nType) {
case this.Properties.showGridLines: return this.showGridLines;break;
case this.Properties.showRowColHeaders: return this.showRowColHeaders;break;
}
},
setProperty : function (nType, value) {
switch (nType) {
case this.Properties.showGridLines: this.showGridLines = value;break;
case this.Properties.showRowColHeaders: this.showRowColHeaders = value;break;
}
}
asc_setShowRowColHeaders: function (val) { this.showRowColHeaders = val; }
};
/** @constructor */
......
......@@ -10086,7 +10086,11 @@
break;
case "sheetViewSettings":
functionModelAction = function () {
t.model.setSheetViewSettings(val);
if (AscCH.historyitem_Worksheet_SetDisplayGridlines === val.type) {
t.model.setDisplayGridlines(val.value);
} else {
t.model.setDisplayHeadings(val.value);
}
isUpdateCols = true;
isUpdateRows = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment