Commit 735714ed authored by Alexander.Trofimov's avatar Alexander.Trofimov

add method GetActiveCell to api builder ApiWorksheet

parent b8859a32
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
"use strict"; "use strict";
(function(window, builder) { (function (window, builder) {
/** /**
* @global * @global
* @class * @class
...@@ -44,8 +44,9 @@ ...@@ -44,8 +44,9 @@
* Class representing a sheet. * Class representing a sheet.
* @constructor * @constructor
*/ */
function ApiWorksheet(worksheet) { function ApiWorksheet(worksheet, worksheetView) {
this.worksheet = worksheet; this.worksheet = worksheet;
this.worksheetView = worksheetView;
} }
/** /**
...@@ -61,8 +62,7 @@ ...@@ -61,8 +62,7 @@
* Class representing a graphical object. * Class representing a graphical object.
* @constructor * @constructor
*/ */
function ApiDrawing(Drawing) function ApiDrawing(Drawing) {
{
this.Drawing = Drawing; this.Drawing = Drawing;
} }
...@@ -77,11 +77,11 @@ ...@@ -77,11 +77,11 @@
* @constructor * @constructor
* *
*/ */
function ApiChart(Chart) function ApiChart(Chart) {
{
ApiChart.superclass.constructor.call(this, Chart.parent); ApiChart.superclass.constructor.call(this, Chart.parent);
this.Chart = Chart; this.Chart = Chart;
} }
AscCommon.extendClass(ApiChart, ApiDrawing); AscCommon.extendClass(ApiChart, ApiDrawing);
/** /**
...@@ -89,8 +89,19 @@ ...@@ -89,8 +89,19 @@
* @memberof Api * @memberof Api
* @returns {ApiWorksheet} * @returns {ApiWorksheet}
*/ */
Api.prototype.GetActiveSheet = function() { Api.prototype.GetActiveSheet = function () {
return new ApiWorksheet(this.wbModel.getWorksheet(this.wbModel.getActive())); var index = this.wbModel.getActive();
return new ApiWorksheet(this.wbModel.getWorksheet(index), this.wb.getWorksheet(index));
};
/**
* Returns an object that represents the active cell
* @memberof ApiWorksheet
* @returns {ApiRange}
*/
ApiWorksheet.prototype.GetActiveCell = function () {
var ar = this.worksheetView.activeRange;
return new ApiRange(this.worksheet.getCell3(ar.startRow, ar.startCol));
}; };
/** /**
...@@ -98,7 +109,7 @@ ...@@ -98,7 +109,7 @@
* @memberof ApiWorksheet * @memberof ApiWorksheet
* @param {string} name * @param {string} name
*/ */
ApiWorksheet.prototype.SetName = function(name) { ApiWorksheet.prototype.SetName = function (name) {
this.worksheet.setName(name); this.worksheet.setName(name);
}; };
...@@ -108,7 +119,7 @@ ...@@ -108,7 +119,7 @@
* @param {string} sRange * @param {string} sRange
* @returns {ApiRange} * @returns {ApiRange}
*/ */
ApiWorksheet.prototype.GetRange = function(sRange) { ApiWorksheet.prototype.GetRange = function (sRange) {
return new ApiRange(this.worksheet.getRange2(sRange)); return new ApiRange(this.worksheet.getRange2(sRange));
}; };
...@@ -117,7 +128,7 @@ ...@@ -117,7 +128,7 @@
* @memberof ApiWorksheet * @memberof ApiWorksheet
* @param {string} sRange * @param {string} sRange
*/ */
ApiWorksheet.prototype.FormatAsTable = function(sRange) { ApiWorksheet.prototype.FormatAsTable = function (sRange) {
this.worksheet.autoFilters.addAutoFilter('TableStyleLight9', AscCommonExcel.g_oRangeCache.getAscRange(sRange)); this.worksheet.autoFilters.addAutoFilter('TableStyleLight9', AscCommonExcel.g_oRangeCache.getAscRange(sRange));
}; };
...@@ -127,7 +138,7 @@ ...@@ -127,7 +138,7 @@
* @param {number} column * @param {number} column
* @param {number} width * @param {number} width
*/ */
ApiWorksheet.prototype.SetColumnWidth = function(column, width) { ApiWorksheet.prototype.SetColumnWidth = function (column, width) {
this.worksheet.setColWidth(width, column, column); this.worksheet.setColWidth(width, column, column);
}; };
...@@ -143,12 +154,12 @@ ...@@ -143,12 +154,12 @@
* @param {number} nToCol * @param {number} nToCol
* @param {number} nToRow * @param {number} nToRow
*/ */
ApiWorksheet.prototype.AddChart = function(sDataRange, bInRows, sType, nStyleIndex, nFromCol, nFromRow, nToCol, nToRow) { ApiWorksheet.prototype.AddChart =
function (sDataRange, bInRows, sType, nStyleIndex, nFromCol, nFromRow, nToCol, nToRow) {
History.Create_NewPoint(); History.Create_NewPoint();
var settings = new AscCommon.asc_ChartSettings(); var settings = new AscCommon.asc_ChartSettings();
switch (sType) switch (sType) {
{
case "bar" : case "bar" :
{ {
settings.type = Asc.c_oAscChartTypeSettings.barNormal; settings.type = Asc.c_oAscChartTypeSettings.barNormal;
...@@ -268,8 +279,7 @@ ...@@ -268,8 +279,7 @@
oChart.setBFromSerialize(true); oChart.setBFromSerialize(true);
oChart.addToDrawingObjects(); oChart.addToDrawingObjects();
oChart.setDrawingBaseCoords(nFromCol, 0, nFromRow, 0, nToCol, 0, nToRow, 0, 0, 0, 0, 0); oChart.setDrawingBaseCoords(nFromCol, 0, nFromRow, 0, nToCol, 0, nToRow, 0, 0, 0, 0, 0);
if(AscFormat.isRealNumber(nStyleIndex)) if (AscFormat.isRealNumber(nStyleIndex)) {
{
oChart.setStyle(nStyleIndex); oChart.setStyle(nStyleIndex);
} }
}; };
...@@ -279,7 +289,7 @@ ...@@ -279,7 +289,7 @@
* @memberof ApiRange * @memberof ApiRange
* @param {string} val * @param {string} val
*/ */
ApiRange.prototype.SetValue = function(val) { ApiRange.prototype.SetValue = function (val) {
this.range.setValue(val); this.range.setValue(val);
}; };
...@@ -289,7 +299,7 @@ ...@@ -289,7 +299,7 @@
* @param {byte} g * @param {byte} g
* @param {byte} b * @param {byte} b
*/ */
ApiRange.prototype.SetFontColor = function(r, g, b) { ApiRange.prototype.SetFontColor = function (r, g, b) {
this.range.setFontcolor(new AscCommonExcel.RgbColor((r << 16) + (g << 8) + b)); this.range.setFontcolor(new AscCommonExcel.RgbColor((r << 16) + (g << 8) + b));
}; };
...@@ -297,7 +307,7 @@ ...@@ -297,7 +307,7 @@
* Set font size * Set font size
* @param {number} size * @param {number} size
*/ */
ApiRange.prototype.SetFontSize = function(size) { ApiRange.prototype.SetFontSize = function (size) {
this.range.setFontsize(size); this.range.setFontsize(size);
}; };
...@@ -305,7 +315,7 @@ ...@@ -305,7 +315,7 @@
* Set font name * Set font name
* @param {string} name * @param {string} name
*/ */
ApiRange.prototype.SetFontName = function(name) { ApiRange.prototype.SetFontName = function (name) {
this.range.setFontname(name); this.range.setFontname(name);
}; };
...@@ -313,7 +323,7 @@ ...@@ -313,7 +323,7 @@
* Set align vertical * Set align vertical
* @param {'center' | 'bottom' | 'top'} value * @param {'center' | 'bottom' | 'top'} value
*/ */
ApiRange.prototype.SetAlignVertical = function(value) { ApiRange.prototype.SetAlignVertical = function (value) {
this.range.setAlignVertical(value); this.range.setAlignVertical(value);
}; };
...@@ -321,18 +331,17 @@ ...@@ -321,18 +331,17 @@
* Set align horizontal * Set align horizontal
* @param {'left' | 'right' | 'center' | 'justify'} value * @param {'left' | 'right' | 'center' | 'justify'} value
*/ */
ApiRange.prototype.SetAlignHorizontal = function(value) { ApiRange.prototype.SetAlignHorizontal = function (value) {
this.range.setAlignHorizontal(value); this.range.setAlignHorizontal(value);
}; };
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Export // Export
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Api.prototype["GetActiveSheet"] = Api.prototype.GetActiveSheet; Api.prototype["GetActiveSheet"] = Api.prototype.GetActiveSheet;
ApiWorksheet.prototype["GetActiveCell"] = ApiWorksheet.prototype.GetActiveCell;
ApiWorksheet.prototype["SetName"] = ApiWorksheet.prototype.SetName; ApiWorksheet.prototype["SetName"] = ApiWorksheet.prototype.SetName;
ApiWorksheet.prototype["GetRange"] = ApiWorksheet.prototype.GetRange; ApiWorksheet.prototype["GetRange"] = ApiWorksheet.prototype.GetRange;
ApiWorksheet.prototype["FormatAsTable"] = ApiWorksheet.prototype.FormatAsTable; ApiWorksheet.prototype["FormatAsTable"] = ApiWorksheet.prototype.FormatAsTable;
......
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