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

add method GetActiveCell to api builder ApiWorksheet

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