Commit 9216fa74 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил функцию проверки валидности диапазона для диаграммы или форматированной таблицы.

asc_checkDataRange
Добавил ошибку c_oAscError.ID.MaxDataSeriesError

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57559 954022d7-b5bf-4e40-9824-e11837661b57
parent de645e24
...@@ -419,38 +419,6 @@ ChartPreviewManager.prototype.getChartPreviews = function(chartType) { ...@@ -419,38 +419,6 @@ ChartPreviewManager.prototype.getChartPreviews = function(chartType) {
return null; return null;
}; };
//-----------------------------------------------------------------------------------
// Draw
//-----------------------------------------------------------------------------------
function checkDataRange(type, interval, isRows) {
var dataRange = parserHelp.parse3DRef(interval);
if (null !== dataRange)
dataRange = Asc.g_oRangeCache.getAscRange(dataRange.range);
if (null === dataRange)
return c_oAscError.ID.DataRangeError;
//проверка максимального дипазона
var maxSeries = 255;
var minStockVal = 4;
var intervalValues, intervalSeries;
if (isRows) {
intervalSeries = dataRange.r2 - dataRange.r1 + 1;
intervalValues = dataRange.c2 - dataRange.c1 + 1;
} else {
intervalSeries = dataRange.c2 - dataRange.c1 + 1;
intervalValues = dataRange.r2 - dataRange.r1 + 1;
}
if (c_oAscChartTypeSettings.stock === type) {
if (minStockVal !== intervalSeries || intervalValues < minStockVal)
return c_oAscError.ID.StockChartError;
} else if (intervalSeries > maxSeries)
return c_oAscError.ID.DataRangeError;
return c_oAscError.ID.No;
}
function arrReverse(arr) { function arrReverse(arr) {
if(!arr || !arr.length) if(!arr || !arr.length)
return; return;
......
...@@ -524,7 +524,6 @@ parserHelper.prototype.parse3DRef = function ( formula ) { ...@@ -524,7 +524,6 @@ parserHelper.prototype.parse3DRef = function ( formula ) {
return {sheet:sheetName, range:this.operand_str}; return {sheet:sheetName, range:this.operand_str};
else else
return null; return null;
} }
} }
// Возвращаем ошибку // Возвращаем ошибку
...@@ -547,5 +546,41 @@ parserHelper.prototype.get3DRef = function (sheet, range) { ...@@ -547,5 +546,41 @@ parserHelper.prototype.get3DRef = function (sheet, range) {
parserHelper.prototype.getEscapeSheetName = function (sheet) { parserHelper.prototype.getEscapeSheetName = function (sheet) {
return rx_test_ws_name.test(sheet) ? sheet : "'" + sheet.replace(/'/g, "''") + "'"; return rx_test_ws_name.test(sheet) ? sheet : "'" + sheet.replace(/'/g, "''") + "'";
}; };
// Проверяем ссылку на валидность для диаграммы или автофильтра
parserHelper.prototype.checkDataRange = function (model, dialogType, dataRange, isRows, chartType) {
if (c_oAscSelectionDialogType.Chart === dialogType) {
dataRange = parserHelp.parse3DRef(dataRange);
if (null === dataRange || !model.getWorksheetByName(dataRange.sheet))
return c_oAscError.ID.DataRangeError;
dataRange = Asc.g_oRangeCache.getAscRange(dataRange.range);
} else
dataRange = Asc.g_oRangeCache.getAscRange(dataRange);
if (null === dataRange)
return c_oAscError.ID.DataRangeError;
if (c_oAscSelectionDialogType.Chart === dialogType) {
// Проверка максимального дипазона
var maxSeries = 255;
var minStockVal = 4;
var intervalValues, intervalSeries;
if (isRows) {
intervalSeries = dataRange.r2 - dataRange.r1 + 1;
intervalValues = dataRange.c2 - dataRange.c1 + 1;
} else {
intervalSeries = dataRange.c2 - dataRange.c1 + 1;
intervalValues = dataRange.r2 - dataRange.r1 + 1;
}
if (c_oAscChartTypeSettings.stock === chartType) {
if (minStockVal !== intervalSeries || intervalValues < minStockVal)
return c_oAscError.ID.StockChartError;
} else if (intervalSeries > maxSeries)
return c_oAscError.ID.MaxDataSeriesError;
}
return c_oAscError.ID.No;
};
var parserHelp = new parserHelper(); var parserHelp = new parserHelper();
\ No newline at end of file
...@@ -2543,12 +2543,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -2543,12 +2543,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
return this.chartPreviewManager.getChartPreviews(chartType); return this.chartPreviewManager.getChartPreviews(chartType);
}, },
asc_checkChartInterval: function(type, interval, isRows) { asc_checkDataRange: function(dialogType, dataRange, isRows, chartType) {
var errorId = checkDataRange(type, interval, isRows); return parserHelp.checkDataRange(this.wbModel, dialogType, dataRange, isRows, chartType);
var bResult = errorId !== c_oAscError.ID.No;
if (bResult)
this.handlers.trigger("asc_onError", errorId, c_oAscError.Level.NoCritical);
return !bResult;
}, },
// Для вставки диаграмм в Word // Для вставки диаграмм в Word
...@@ -3724,7 +3720,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -3724,7 +3720,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
prot["asc_addImageDrawingObject"] = prot.asc_addImageDrawingObject; prot["asc_addImageDrawingObject"] = prot.asc_addImageDrawingObject;
prot["asc_setSelectedDrawingObjectLayer"] = prot.asc_setSelectedDrawingObjectLayer; prot["asc_setSelectedDrawingObjectLayer"] = prot.asc_setSelectedDrawingObjectLayer;
prot["asc_getChartPreviews"] = prot.asc_getChartPreviews; prot["asc_getChartPreviews"] = prot.asc_getChartPreviews;
prot["asc_checkChartInterval"] = prot.asc_checkChartInterval; prot["asc_checkDataRange"] = prot.asc_checkDataRange;
prot["asc_getBinaryFileWriter"] = prot.asc_getBinaryFileWriter; prot["asc_getBinaryFileWriter"] = prot.asc_getBinaryFileWriter;
prot["asc_getWordChartObject"] = prot.asc_getWordChartObject; prot["asc_getWordChartObject"] = prot.asc_getWordChartObject;
prot["asc_cleanWorksheet"] = prot.asc_cleanWorksheet; prot["asc_cleanWorksheet"] = prot.asc_cleanWorksheet;
......
...@@ -31,6 +31,7 @@ var c_oAscError = { ...@@ -31,6 +31,7 @@ var c_oAscError = {
UplImageUrl: -17, UplImageUrl: -17,
CoAuthoringDisconnect: -18, CoAuthoringDisconnect: -18,
ConvertationPassword: -19, ConvertationPassword: -19,
MaxDataSeriesError: -80,
VKeyEncrypt: -20, VKeyEncrypt: -20,
......
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