Commit 3b1f768f authored by Alexander.Trofimov's avatar Alexander.Trofimov

charCountToModelColWidth move to model

fix set width in api builder
parent b7acb4d8
......@@ -1997,6 +1997,9 @@ function Workbook(eventsHandlers, oApi){
this.openErrors = [];
this.lockCounter = 0;
this.maxDigitWidth = 0;
this.paddingPlusBorder = 0;
}
Workbook.prototype.init=function(bNoBuildDep){
if(this.nActive < 0)
......@@ -3237,6 +3240,17 @@ Workbook.prototype.getTableNameColumnByIndex = function(tableName, columnIndex){
}
}
};
/**
* Вычисляет ширину столбца для заданного количества символов
* @param {Number} count Количество символов
* @returns {Number} Ширина столбца в символах
*/
Workbook.prototype.charCountToModelColWidth = function (count) {
if (count <= 0) {
return 0;
}
return Asc.floor((count * this.maxDigitWidth + this.paddingPlusBorder) / this.maxDigitWidth * 256) / 256;
};
//-------------------------------------------------------------------------------------------------
/**
* @constructor
......@@ -4259,6 +4273,9 @@ Woorksheet.prototype.getDefaultFontName=function(){
Woorksheet.prototype.getDefaultFontSize=function(){
return this.workbook.getDefaultSize();
};
Woorksheet.prototype.charCountToModelColWidth = function (count) {
return this.workbook.charCountToModelColWidth(count);
};
Woorksheet.prototype.getColWidth=function(index){
//index 0 based
//Результат в пунктах
......@@ -4272,8 +4289,10 @@ Woorksheet.prototype.getColWidth=function(index){
return dResult;
};
Woorksheet.prototype.setColWidth=function(width, start, stop){
width = this.charCountToModelColWidth(width);
if(0 == width)
return this.setColHidden(true, start, stop);
//start, stop 0 based
if(null == start)
return;
......
......@@ -2532,7 +2532,7 @@
}
};
WorkbookView.prototype._calcMaxDigitWidth = function() {
WorkbookView.prototype._calcMaxDigitWidth = function () {
// set default worksheet header font for calculations
this.buffers.main.setFont(this.defaultFont);
// Измеряем в pt
......@@ -2546,7 +2546,7 @@
// Максимальная ширина в Pt
var maxWidthInPt = this.stringRender.getWidestCharWidth();
// Переводим в px и приводим к целому (int)
this.maxDigitWidth = asc_round(maxWidthInPt * ptConvToPx);
this.model.maxDigitWidth = this.maxDigitWidth = asc_round(maxWidthInPt * ptConvToPx);
// Проверка для Calibri 11 должно быть this.maxDigitWidth = 7
if (!this.maxDigitWidth) {
......@@ -2555,442 +2555,400 @@
// Padding рассчитывается исходя из maxDigitWidth (http://social.msdn.microsoft.com/Forums/en-US/9a6a9785-66ad-4b6b-bb9f-74429381bd72/margin-padding-in-cell-excel?forum=os_binaryfile)
this.defaults.worksheetView.cells.padding = Math.max(asc.ceil(this.maxDigitWidth / 4), 2);
this.defaults.worksheetView.cells.paddingPlusBorder = 2 * this.defaults.worksheetView.cells.padding + 1;
};
WorkbookView.prototype.af_getTablePictures = function(wb, fmgrGraphics, oFont, props)
{
var styleThumbnailWidth = 61;
var styleThumbnailHeight = 46;
if (AscBrowser.isRetina) {
styleThumbnailWidth <<= 1;
styleThumbnailHeight <<= 1;
}
var canvas = document.createElement('canvas');
canvas.width = styleThumbnailWidth;
canvas.height = styleThumbnailHeight;
var customStyles = wb.TableStyles.CustomStyles;
var result = [];
var options;
var n = 0;
if(customStyles)
{
for(var i in customStyles)
{
if(customStyles[i].table)
{
options =
{
name: i,
displayName: customStyles[i].displayName,
type: 'custom',
image: this.af_getSmallIconTable(canvas, customStyles[i], fmgrGraphics, oFont, props)
};
result[n] = new AscCommonExcel.formatTablePictures(options);
n++;
}
}
this.model.paddingPlusBorder = this.defaults.worksheetView.cells.paddingPlusBorder = 2 * this.defaults.worksheetView.cells.padding + 1;
};
WorkbookView.prototype.af_getTablePictures = function (wb, fmgrGraphics, oFont, props) {
var styleThumbnailWidth = 61;
var styleThumbnailHeight = 46;
if (AscBrowser.isRetina) {
styleThumbnailWidth <<= 1;
styleThumbnailHeight <<= 1;
}
var canvas = document.createElement('canvas');
canvas.width = styleThumbnailWidth;
canvas.height = styleThumbnailHeight;
var customStyles = wb.TableStyles.CustomStyles;
var result = [];
var options;
var n = 0;
if (customStyles) {
for (var i in customStyles) {
if (customStyles[i].table) {
options = {
name: i,
displayName: customStyles[i].displayName,
type: 'custom',
image: this.af_getSmallIconTable(canvas, customStyles[i], fmgrGraphics, oFont, props)
};
result[n] = new AscCommonExcel.formatTablePictures(options);
n++;
}
var defaultStyles = wb.TableStyles.DefaultStyles;
if(defaultStyles)
{
for(var i in defaultStyles)
{
if(defaultStyles[i].table)
{
options =
{
name: i,
displayName: defaultStyles[i].displayName,
type: 'default',
image: this.af_getSmallIconTable(canvas, defaultStyles[i], fmgrGraphics, oFont, props)
};
result[n] = new AscCommonExcel.formatTablePictures(options);
n++;
}
}
}
}
var defaultStyles = wb.TableStyles.DefaultStyles;
if (defaultStyles) {
for (var i in defaultStyles) {
if (defaultStyles[i].table) {
options = {
name: i,
displayName: defaultStyles[i].displayName,
type: 'default',
image: this.af_getSmallIconTable(canvas, defaultStyles[i], fmgrGraphics, oFont, props)
};
result[n] = new AscCommonExcel.formatTablePictures(options);
n++;
}
return result;
};
}
}
return result;
};
WorkbookView.prototype.af_getSmallIconTable = function(canvas, style, fmgrGraphics, oFont, props)
{
var ctx = new Asc.DrawingContext({canvas: canvas, units: 1/*pt*/, fmgrGraphics: fmgrGraphics, font: oFont});
var styleOptions = style;
//по умолчанию ставим строку заголовка и чередующиеся строки, позже нужно будет получать параметр
var styleInfo;
if(props)
{
styleInfo =
{
ShowColumnStripes: props.asc_getBandVer(),
ShowFirstColumn: props.asc_getFirstCol(),
ShowLastColumn: props.asc_getLastCol(),
ShowRowStripes: props.asc_getBandHor(),
HeaderRowCount: props.asc_getFirstRow(),
TotalsRowCount: props.asc_getLastRow()
};
}
else
{
styleInfo =
{
ShowColumnStripes: false,
ShowFirstColumn: false,
ShowLastColumn: false,
ShowRowStripes: true,
HeaderRowCount: true,
TotalsRowCount: false
};
}
WorkbookView.prototype.af_getSmallIconTable = function (canvas, style, fmgrGraphics, oFont, props) {
var ctx = new Asc.DrawingContext({canvas: canvas, units: 1/*pt*/, fmgrGraphics: fmgrGraphics, font: oFont});
var styleOptions = style;
//по умолчанию ставим строку заголовка и чередующиеся строки, позже нужно будет получать параметр
var styleInfo;
if (props) {
styleInfo = {
ShowColumnStripes: props.asc_getBandVer(),
ShowFirstColumn: props.asc_getFirstCol(),
ShowLastColumn: props.asc_getLastCol(),
ShowRowStripes: props.asc_getBandHor(),
HeaderRowCount: props.asc_getFirstRow(),
TotalsRowCount: props.asc_getLastRow()
};
} else {
styleInfo = {
ShowColumnStripes: false,
ShowFirstColumn: false,
ShowLastColumn: false,
ShowRowStripes: true,
HeaderRowCount: true,
TotalsRowCount: false
};
}
var pxToMM = 72 / 96;
var ySize = 45 * pxToMM;
var xSize = 61 * pxToMM;
var stepY = (ySize) / 5;
var stepX = (60 * pxToMM) / 5;
var whiteColor = new CColor(255, 255, 255);
var blackColor = new CColor(0, 0, 0);
var pxToMM = 72 / 96;
var ySize = 45 * pxToMM;
var xSize = 61 * pxToMM;
//**draw background**
var defaultColorBackground;
if(styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill)
defaultColorBackground = styleOptions.wholeTable.dxf.fill.bg;
else
defaultColorBackground = whiteColor;
var stepY = (ySize) / 5;
var stepX = (60 * pxToMM) / 5;
var whiteColor = new CColor(255, 255, 255);
var blackColor = new CColor(0, 0, 0);
var color;
if(styleOptions != undefined)
{
if(styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill && null != styleOptions.wholeTable.dxf.fill.bg)
{
ctx.setFillStyle(styleOptions.wholeTable.dxf.fill.bg);
ctx.fillRect(0, 0, xSize, ySize);
}
else
{
ctx.setFillStyle(whiteColor);
ctx.fillRect(0, 0, xSize, ySize);
}
if(styleInfo.ShowColumnStripes)//column stripes
{
for(k = 0; k < 6; k++)
{
color = defaultColorBackground;
if(k % 2 == 0)
{
if(styleOptions.firstColumnStripe && styleOptions.firstColumnStripe.dxf.fill && null != styleOptions.firstColumnStripe.dxf.fill.bg)
color = styleOptions.firstColumnStripe.dxf.fill.bg;
else if(styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill && null != styleOptions.wholeTable.dxf.fill.bg)
color = styleOptions.wholeTable.dxf.fill.bg;
}
else
{
if(styleOptions.secondColumnStripe && styleOptions.secondColumnStripe.dxf.fill && null != styleOptions.secondColumnStripe.dxf.fill.bg)
color = styleOptions.secondColumnStripe.dxf.fill.bg;
else if(styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill && null != styleOptions.wholeTable.dxf.fill.bg)
color = styleOptions.wholeTable.dxf.fill.bg;
}
ctx.setFillStyle(color);
ctx.fillRect(k * stepX, 0, stepX, ySize);
}
}
//**draw background**
var defaultColorBackground;
if (styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill) {
defaultColorBackground = styleOptions.wholeTable.dxf.fill.bg;
} else {
defaultColorBackground = whiteColor;
}
if(styleInfo.ShowRowStripes)//row stripes
{
for(var k = 0; k < 6; k++)
{
color = null;
if(k == 0 && styleInfo.HeaderRowCount)
continue;
if(styleInfo.HeaderRowCount)
{
if(k % 2 != 0)
{
if(styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.fill && null != styleOptions.firstRowStripe.dxf.fill.bg)
{
color = styleOptions.firstRowStripe.dxf.fill.bg;
}
}
else
{
if(styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.fill && null != styleOptions.secondRowStripe.dxf.fill.bg)
{
color = styleOptions.secondRowStripe.dxf.fill.bg;
}
}
}
else
{
if(k % 2 != 0)
{
if(styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.fill && null != styleOptions.secondRowStripe.dxf.fill.bg)
{
color = styleOptions.secondRowStripe.dxf.fill.bg;
}
}
else
{
if(styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.fill && null != styleOptions.firstRowStripe.dxf.fill.bg)
{
color = styleOptions.firstRowStripe.dxf.fill.bg;
}
}
}
if(color != null)
{
ctx.setFillStyle(color);
ctx.fillRect(0, k * stepY, xSize, stepY);
}
}
var color;
if (styleOptions != undefined) {
if (styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill && null != styleOptions.wholeTable.dxf.fill.bg) {
ctx.setFillStyle(styleOptions.wholeTable.dxf.fill.bg);
ctx.fillRect(0, 0, xSize, ySize);
} else {
ctx.setFillStyle(whiteColor);
ctx.fillRect(0, 0, xSize, ySize);
}
if (styleInfo.ShowColumnStripes)//column stripes
{
for (k = 0; k < 6; k++) {
color = defaultColorBackground;
if (k % 2 == 0) {
if (styleOptions.firstColumnStripe && styleOptions.firstColumnStripe.dxf.fill &&
null != styleOptions.firstColumnStripe.dxf.fill.bg) {
color = styleOptions.firstColumnStripe.dxf.fill.bg;
} else if (styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill &&
null != styleOptions.wholeTable.dxf.fill.bg) {
color = styleOptions.wholeTable.dxf.fill.bg;
}
if(styleInfo.ShowFirstColumn && styleOptions.firstColumn)//first column
{
color = null;
if(styleOptions.firstColumn && styleOptions.firstColumn.dxf.fill && null != styleOptions.firstColumn.dxf.fill.bg)
color = styleOptions.firstColumn.dxf.fill.bg;
if(color != null)
{
ctx.setFillStyle(color);
ctx.fillRect(0, 0, stepX, ySize);
}
} else {
if (styleOptions.secondColumnStripe && styleOptions.secondColumnStripe.dxf.fill &&
null != styleOptions.secondColumnStripe.dxf.fill.bg) {
color = styleOptions.secondColumnStripe.dxf.fill.bg;
} else if (styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill &&
null != styleOptions.wholeTable.dxf.fill.bg) {
color = styleOptions.wholeTable.dxf.fill.bg;
}
if(styleInfo.ShowLastColumn)//last column
{
color = null;
if(styleOptions.lastColumn && styleOptions.lastColumn.dxf.fill && null != styleOptions.lastColumn.dxf.fill.bg)
color =styleOptions.lastColumn.dxf.fill.bg;
if(color != null)
{
ctx.setFillStyle(color);
ctx.fillRect(4*stepX + 1, 0, stepX, ySize);
}
}
ctx.setFillStyle(color);
ctx.fillRect(k * stepX, 0, stepX, ySize);
}
}
}
if(styleInfo.HeaderRowCount)//header row
{
if(styleOptions.headerRow && styleOptions.headerRow.dxf.fill && null != styleOptions.headerRow.dxf.fill.bg)
{
ctx.setFillStyle(styleOptions.headerRow.dxf.fill.bg);
}
else
{
ctx.setFillStyle(defaultColorBackground);
}
ctx.fillRect(0, 0, xSize, stepY);
if (styleInfo.ShowRowStripes)//row stripes
{
for (var k = 0; k < 6; k++) {
color = null;
if (k == 0 && styleInfo.HeaderRowCount) {
continue;
}
if (styleInfo.HeaderRowCount) {
if (k % 2 != 0) {
if (styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.fill &&
null != styleOptions.firstRowStripe.dxf.fill.bg) {
color = styleOptions.firstRowStripe.dxf.fill.bg;
}
} else {
if (styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.fill &&
null != styleOptions.secondRowStripe.dxf.fill.bg) {
color = styleOptions.secondRowStripe.dxf.fill.bg;
}
}
if(styleInfo.TotalsRowCount)//total row
{
color = null;
if(styleOptions.totalRow && styleOptions.totalRow.dxf.fill && null != styleOptions.totalRow.dxf.fill.bg)
color = styleOptions.totalRow.dxf.fill.bg;
if(color !== null)
{
ctx.setFillStyle(color);
ctx.fillRect(0, stepY * 4, xSize, stepY);
}
} else {
if (k % 2 != 0) {
if (styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.fill &&
null != styleOptions.secondRowStripe.dxf.fill.bg) {
color = styleOptions.secondRowStripe.dxf.fill.bg;
}
} else {
if (styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.fill &&
null != styleOptions.firstRowStripe.dxf.fill.bg) {
color = styleOptions.firstRowStripe.dxf.fill.bg;
}
}
}
if (color != null) {
ctx.setFillStyle(color);
ctx.fillRect(0, k * stepY, xSize, stepY);
}
}
}
//первая ячейка
if(styleOptions.firstHeaderCell && styleInfo.ShowFirstColumn)
{
if(styleOptions.firstHeaderCell && styleOptions.firstHeaderCell.dxf.fill && null != styleOptions.firstHeaderCell.dxf.fill.bg)
ctx.setFillStyle(styleOptions.firstHeaderCell.dxf.fill.bg);
else
ctx.setFillStyle(defaultColorBackground);
ctx.fillRect(0,0,stepX,stepY);
}
//последняя в первой строке
if(styleOptions.lastHeaderCell && styleInfo.ShowLastColumn)
{
if(styleOptions.lastHeaderCell && styleOptions.lastHeaderCell.dxf.fill && null != styleOptions.lastHeaderCell.dxf.fill.bg)
ctx.setFillStyle(styleOptions.lastHeaderCell.dxf.fill.bg);
else
ctx.setFillStyle(defaultColorBackground);
ctx.fillRect(4*stepX,0,stepX,stepY);
}
//первая в последней строке
if(styleOptions.firstTotalCell && styleInfo.TotalsRowCount && styleInfo.ShowFirstColumn)
{
if(styleOptions.firstTotalCell && styleOptions.firstTotalCell.dxf.fill && null != styleOptions.firstTotalCell.dxf.fill.bg)
ctx.setFillStyle(styleOptions.firstTotalCell.dxf.fill.bg);
else
ctx.setFillStyle(defaultColorBackground);
ctx.fillRect(0,4*stepY,stepX,stepY);
}
//последняя ячейка
if(styleOptions.lastTotalCell && styleInfo.TotalsRowCount && styleInfo.ShowLastColumn)
{
if(styleOptions.lastTotalCell && styleOptions.lastTotalCell.dxf.fill && null != styleOptions.lastTotalCell.dxf.fill.bg)
ctx.setFillStyle(styleOptions.lastTotalCell.dxf.fill.bg);
else
ctx.setFillStyle(defaultColorBackground);
ctx.fillRect(4*stepX,4*stepY,stepX,ySize);
}
if (styleInfo.ShowFirstColumn && styleOptions.firstColumn)//first column
{
color = null;
if (styleOptions.firstColumn && styleOptions.firstColumn.dxf.fill &&
null != styleOptions.firstColumn.dxf.fill.bg) {
color = styleOptions.firstColumn.dxf.fill.bg;
}
if (color != null) {
ctx.setFillStyle(color);
ctx.fillRect(0, 0, stepX, ySize);
}
else
{
ctx.setFillStyle(whiteColor);
ctx.fillRect(0,0,xSize,ySize);
}
if (styleInfo.ShowLastColumn)//last column
{
color = null;
if (styleOptions.lastColumn && styleOptions.lastColumn.dxf.fill &&
null != styleOptions.lastColumn.dxf.fill.bg) {
color = styleOptions.lastColumn.dxf.fill.bg;
}
if (color != null) {
ctx.setFillStyle(color);
ctx.fillRect(4 * stepX + 1, 0, stepX, ySize);
}
}
if (styleInfo.HeaderRowCount)//header row
{
if (styleOptions.headerRow && styleOptions.headerRow.dxf.fill && null != styleOptions.headerRow.dxf.fill.bg) {
ctx.setFillStyle(styleOptions.headerRow.dxf.fill.bg);
} else {
ctx.setFillStyle(defaultColorBackground);
}
ctx.fillRect(0, 0, xSize, stepY);
//**draw vertical and horizontal lines**
if(styleOptions != undefined)
{
ctx.setLineWidth(1);
ctx.beginPath();
if(styleOptions.wholeTable && styleOptions.wholeTable.dxf.border)
{
var borders = styleOptions.wholeTable.dxf.border;
if(borders.t.s !== c_oAscBorderStyles.None)
{
ctx.setStrokeStyle(borders.t.c);
ctx.lineHor(0, 0, xSize);
}
if(borders.b.s !== c_oAscBorderStyles.None)
{
ctx.setStrokeStyle(borders.b.c);
ctx.lineHor(0, ySize, xSize);
}
if(borders.l.s !== c_oAscBorderStyles.None)
{
ctx.setStrokeStyle(borders.l.c);
ctx.lineVer(0, 0, ySize);
}
if(borders.r.s !== c_oAscBorderStyles.None)
{
ctx.setStrokeStyle(borders.r.c);
ctx.lineVer(xSize - 1, 0, ySize);
}
if(borders.ih.s !== c_oAscBorderStyles.None)
{
ctx.setStrokeStyle(borders.ih.c);
for(var n = 1; n < 5; n++)
{
ctx.lineHor(0, stepY*n, xSize);
}
ctx.stroke();
}
if(borders.iv.s !== c_oAscBorderStyles.None)
{
ctx.setStrokeStyle(borders.iv.c);
for(var n = 1; n < 5; n++)
{
ctx.lineVer(stepX*n, 0, ySize);
}
ctx.stroke();
}
}
if (styleInfo.TotalsRowCount)//total row
{
color = null;
if (styleOptions.totalRow && styleOptions.totalRow.dxf.fill && null != styleOptions.totalRow.dxf.fill.bg) {
color = styleOptions.totalRow.dxf.fill.bg;
}
}
if (color !== null) {
ctx.setFillStyle(color);
ctx.fillRect(0, stepY * 4, xSize, stepY);
}
}
var border;
if(styleInfo.ShowRowStripes)
{
if(styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.border)
border = styleOptions.firstRowStripe.dxf.border;
else if(styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.border)
border = styleOptions.secondRowStripe.dxf.border;
if(border)
{
for(n = 1; n < 5; n++)
{
ctx.lineHor(0, stepY*n, xSize);
}
ctx.stroke();
}
}
if(styleOptions.totalRow && styleInfo.TotalsRowCount && styleOptions.totalRow.dxf.border)
{
border = styleOptions.totalRow.dxf.border;
if(border.t.s !== c_oAscBorderStyles.None)
{
ctx.setStrokeStyle(border.t.c);
ctx.lineVer(0, xSize, ySize);
}
}
if(styleOptions.headerRow && styleOptions.headerRow.dxf.border && styleInfo.HeaderRowCount)//header row
{
border = styleOptions.headerRow.dxf.border;
if(border.t.s !== c_oAscBorderStyles.None)
{
ctx.setStrokeStyle(border.t.c);
ctx.lineHor(0, 0, xSize);
}
if(border.b.s !== c_oAscBorderStyles.None)
{
ctx.setStrokeStyle(border.b.c);
ctx.lineHor(0, stepY, xSize);
}
ctx.stroke();
}
ctx.closePath();
//первая ячейка
if (styleOptions.firstHeaderCell && styleInfo.ShowFirstColumn) {
if (styleOptions.firstHeaderCell && styleOptions.firstHeaderCell.dxf.fill &&
null != styleOptions.firstHeaderCell.dxf.fill.bg) {
ctx.setFillStyle(styleOptions.firstHeaderCell.dxf.fill.bg);
} else {
ctx.setFillStyle(defaultColorBackground);
}
ctx.fillRect(0, 0, stepX, stepY);
}
//последняя в первой строке
if (styleOptions.lastHeaderCell && styleInfo.ShowLastColumn) {
if (styleOptions.lastHeaderCell && styleOptions.lastHeaderCell.dxf.fill &&
null != styleOptions.lastHeaderCell.dxf.fill.bg) {
ctx.setFillStyle(styleOptions.lastHeaderCell.dxf.fill.bg);
} else {
ctx.setFillStyle(defaultColorBackground);
}
ctx.fillRect(4 * stepX, 0, stepX, stepY);
}
//первая в последней строке
if (styleOptions.firstTotalCell && styleInfo.TotalsRowCount && styleInfo.ShowFirstColumn) {
if (styleOptions.firstTotalCell && styleOptions.firstTotalCell.dxf.fill &&
null != styleOptions.firstTotalCell.dxf.fill.bg) {
ctx.setFillStyle(styleOptions.firstTotalCell.dxf.fill.bg);
} else {
ctx.setFillStyle(defaultColorBackground);
}
ctx.fillRect(0, 4 * stepY, stepX, stepY);
}
//последняя ячейка
if (styleOptions.lastTotalCell && styleInfo.TotalsRowCount && styleInfo.ShowLastColumn) {
if (styleOptions.lastTotalCell && styleOptions.lastTotalCell.dxf.fill &&
null != styleOptions.lastTotalCell.dxf.fill.bg) {
ctx.setFillStyle(styleOptions.lastTotalCell.dxf.fill.bg);
} else {
ctx.setFillStyle(defaultColorBackground);
}
ctx.fillRect(4 * stepX, 4 * stepY, stepX, ySize);
}
//**draw marks line**
var defaultColor;
if(!styleOptions || !styleOptions.wholeTable || !styleOptions.wholeTable.dxf.font)
defaultColor = blackColor;
else
defaultColor = styleOptions.wholeTable.dxf.font.c;
for(var n = 1; n < 6; n++)
{
ctx.beginPath();
color = null;
if(n == 1 && styleOptions && styleOptions.headerRow && styleOptions.headerRow.dxf.font)
color = styleOptions.headerRow.dxf.font.c;
else if(n == 5 && styleOptions && styleOptions.totalRow && styleOptions.totalRow.dxf.font)
color = styleOptions.totalRow.dxf.font.c;
else if(styleOptions && styleOptions.headerRow && styleInfo.ShowRowStripes)
{
if((n == 2 || (n == 5 && !styleOptions.totalRow)) && styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.font)
color = styleOptions.firstRowStripe.dxf.font.c;
else if(n == 3 && styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.font)
color = styleOptions.secondRowStripe.dxf.font.c;
else
color = defaultColor
}
else if(styleOptions && !styleOptions.headerRow && styleInfo.ShowRowStripes)
{
if((n == 1 || n == 3 || (n == 5 && !styleOptions.totalRow)) && styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.font)
color = styleOptions.firstRowStripe.dxf.font.c;
else if((n == 2 || n == 4) && styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.font)
color = styleOptions.secondRowStripe.dxf.font.c;
else
color = defaultColor
}
else
color = defaultColor;
ctx.setStrokeStyle(color);
var k = 0;
var strY = n*stepY - stepY/2;
while(k < 6)
{
ctx.lineHor(k*stepX + 3 * pxToMM, strY, (k + 1)*stepX - 2 * pxToMM);
k++;
}
ctx.stroke();
ctx.closePath();
} else {
ctx.setFillStyle(whiteColor);
ctx.fillRect(0, 0, xSize, ySize);
}
//**draw vertical and horizontal lines**
if (styleOptions != undefined) {
ctx.setLineWidth(1);
ctx.beginPath();
if (styleOptions.wholeTable && styleOptions.wholeTable.dxf.border) {
var borders = styleOptions.wholeTable.dxf.border;
if (borders.t.s !== c_oAscBorderStyles.None) {
ctx.setStrokeStyle(borders.t.c);
ctx.lineHor(0, 0, xSize);
}
if (borders.b.s !== c_oAscBorderStyles.None) {
ctx.setStrokeStyle(borders.b.c);
ctx.lineHor(0, ySize, xSize);
}
if (borders.l.s !== c_oAscBorderStyles.None) {
ctx.setStrokeStyle(borders.l.c);
ctx.lineVer(0, 0, ySize);
}
if (borders.r.s !== c_oAscBorderStyles.None) {
ctx.setStrokeStyle(borders.r.c);
ctx.lineVer(xSize - 1, 0, ySize);
}
if (borders.ih.s !== c_oAscBorderStyles.None) {
ctx.setStrokeStyle(borders.ih.c);
for (var n = 1; n < 5; n++) {
ctx.lineHor(0, stepY * n, xSize);
}
ctx.stroke();
}
if (borders.iv.s !== c_oAscBorderStyles.None) {
ctx.setStrokeStyle(borders.iv.c);
for (var n = 1; n < 5; n++) {
ctx.lineVer(stepX * n, 0, ySize);
}
ctx.stroke();
}
return canvas.toDataURL("image/png");
};
}
var border;
if (styleInfo.ShowRowStripes) {
if (styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.border) {
border = styleOptions.firstRowStripe.dxf.border;
} else if (styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.border) {
border = styleOptions.secondRowStripe.dxf.border;
}
if (border) {
for (n = 1; n < 5; n++) {
ctx.lineHor(0, stepY * n, xSize);
}
ctx.stroke();
}
}
if (styleOptions.totalRow && styleInfo.TotalsRowCount && styleOptions.totalRow.dxf.border) {
border = styleOptions.totalRow.dxf.border;
if (border.t.s !== c_oAscBorderStyles.None) {
ctx.setStrokeStyle(border.t.c);
ctx.lineVer(0, xSize, ySize);
}
}
if (styleOptions.headerRow && styleOptions.headerRow.dxf.border && styleInfo.HeaderRowCount)//header row
{
border = styleOptions.headerRow.dxf.border;
if (border.t.s !== c_oAscBorderStyles.None) {
ctx.setStrokeStyle(border.t.c);
ctx.lineHor(0, 0, xSize);
}
if (border.b.s !== c_oAscBorderStyles.None) {
ctx.setStrokeStyle(border.b.c);
ctx.lineHor(0, stepY, xSize);
}
ctx.stroke();
}
ctx.closePath();
}
//**draw marks line**
var defaultColor;
if (!styleOptions || !styleOptions.wholeTable || !styleOptions.wholeTable.dxf.font) {
defaultColor = blackColor;
} else {
defaultColor = styleOptions.wholeTable.dxf.font.c;
}
for (var n = 1; n < 6; n++) {
ctx.beginPath();
color = null;
if (n == 1 && styleOptions && styleOptions.headerRow && styleOptions.headerRow.dxf.font) {
color = styleOptions.headerRow.dxf.font.c;
} else if (n == 5 && styleOptions && styleOptions.totalRow && styleOptions.totalRow.dxf.font) {
color = styleOptions.totalRow.dxf.font.c;
} else if (styleOptions && styleOptions.headerRow && styleInfo.ShowRowStripes) {
if ((n == 2 || (n == 5 && !styleOptions.totalRow)) && styleOptions.firstRowStripe &&
styleOptions.firstRowStripe.dxf.font) {
color = styleOptions.firstRowStripe.dxf.font.c;
} else if (n == 3 && styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.font) {
color = styleOptions.secondRowStripe.dxf.font.c;
} else {
color = defaultColor
}
} else if (styleOptions && !styleOptions.headerRow && styleInfo.ShowRowStripes) {
if ((n == 1 || n == 3 || (n == 5 && !styleOptions.totalRow)) && styleOptions.firstRowStripe &&
styleOptions.firstRowStripe.dxf.font) {
color = styleOptions.firstRowStripe.dxf.font.c;
} else if ((n == 2 || n == 4) && styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.font) {
color = styleOptions.secondRowStripe.dxf.font.c;
} else {
color = defaultColor
}
} else {
color = defaultColor;
}
ctx.setStrokeStyle(color);
var k = 0;
var strY = n * stepY - stepY / 2;
while (k < 6) {
ctx.lineHor(k * stepX + 3 * pxToMM, strY, (k + 1) * stepX - 2 * pxToMM);
k++;
}
ctx.stroke();
ctx.closePath();
}
return canvas.toDataURL("image/png");
};
//------------------------------------------------------------export---------------------------------------------------
window['AscCommonExcel'] = window['AscCommonExcel'] || {};
......
......@@ -753,14 +753,13 @@
return;
}
var cc = Math.min(t._colWidthToCharCount(w), Asc.c_oAscMaxColumnWidth);
var cw = t._charCountToModelColWidth(cc);
var onChangeWidthCallback = function (isSuccess) {
if (false === isSuccess) {
return;
}
t.model.setColWidth(cw, col, col);
t.model.setColWidth(cc, col, col);
t._cleanCache(new asc_Range(0, 0, t.cols.length - 1, t.rows.length - 1));
t.changeWorksheet("update", {reinitRanges: true});
t._updateVisibleColsCount();
......@@ -1200,13 +1199,13 @@
WorksheetView.prototype._initWorksheetDefaultWidth = function () {
this.nBaseColWidth = this.model.oSheetFormatPr.nBaseColWidth || this.nBaseColWidth;
// Теперь рассчитываем число px
var defaultColWidthChars = this._charCountToModelColWidth( this.nBaseColWidth );
var defaultColWidthChars = this.model.charCountToModelColWidth( this.nBaseColWidth );
this.defaultColWidthPx = this._modelColWidthToColWidth( defaultColWidthChars ) * asc_getcvt( 1/*pt*/, 0/*px*/, 96 );
// Делаем кратным 8 (http://support.microsoft.com/kb/214123)
this.defaultColWidthPx = asc_ceil( this.defaultColWidthPx / 8 ) * 8;
this.defaultColWidthChars = this._colWidthToCharCount( this.defaultColWidthPx * asc_getcvt( 0/*px*/, 1/*pt*/, 96 ) );
AscCommonExcel.oDefaultMetrics.ColWidthChars = this._charCountToModelColWidth(this.defaultColWidthChars);
AscCommonExcel.oDefaultMetrics.ColWidthChars = this.model.charCountToModelColWidth(this.defaultColWidthChars);
this.defaultColWidth = this._modelColWidthToColWidth(AscCommonExcel.oDefaultMetrics.ColWidthChars);
var defaultFontSize = this.model.getDefaultFontSize();
......@@ -1293,18 +1292,6 @@
}
};
/**
* Вычисляет ширину столбца для заданного количества символов
* @param {Number} count Количество символов
* @returns {Number} Ширина столбца в символах
*/
WorksheetView.prototype._charCountToModelColWidth = function ( count ) {
if ( count <= 0 ) {
return 0;
}
return asc_floor( (count * this.maxDigitWidth + this.settings.cells.paddingPlusBorder) / this.maxDigitWidth * 256 ) / 256;
};
/**
* Вычисляет ширину столбца в пунктах
* @param {Number} mcw Количество символов
......@@ -1354,14 +1341,13 @@
/** Вычисляет ширину колонки заголовков (в pt) */
WorksheetView.prototype._calcHeaderColumnWidth = function () {
if ( false === this.model.sheetViews[0].asc_getShowRowColHeaders() ) {
if (false === this.model.sheetViews[0].asc_getShowRowColHeaders()) {
this.headersWidth = 0;
}
else {
} else {
// Ширина колонки заголовков считается - max число знаков в строке - перевести в символы - перевести в пикселы
var numDigit = Math.max( calcDecades( this.visibleRange.r2 + 1 ), 3 );
var nCharCount = this._charCountToModelColWidth( numDigit );
this.headersWidth = this._modelColWidthToColWidth( nCharCount );
var numDigit = Math.max(calcDecades(this.visibleRange.r2 + 1), 3);
var nCharCount = this.model.charCountToModelColWidth(numDigit);
this.headersWidth = this._modelColWidthToColWidth(nCharCount);
}
//var w = this.emSize * Math.max( calcDecades(this.visibleRange.r2 + 1), 3) * 1.25;
......@@ -4675,7 +4661,7 @@
WorksheetView.prototype._changeColWidth = function ( col, width, pad ) {
var cc = Math.min( this._colWidthToCharCount( width + pad ), Asc.c_oAscMaxColumnWidth );
var modelw = this._charCountToModelColWidth( cc );
var modelw = this.model.charCountToModelColWidth( cc );
var colw = this._calcColWidth( modelw );
if ( colw.width > this.cols[col].width ) {
......@@ -10343,14 +10329,14 @@
return true;
};
WorksheetView.prototype.changeWorksheet = function ( prop, val ) {
WorksheetView.prototype.changeWorksheet = function (prop, val) {
// Проверка глобального лока
if ( this.collaborativeEditing.getGlobalLock() ) {
if (this.collaborativeEditing.getGlobalLock()) {
return;
}
var t = this;
var arn = t.activeRange.clone( true );
var arn = t.activeRange.clone(true);
var checkRange = arn.getAllRange();
var range;
......@@ -10358,169 +10344,171 @@
var reinitRanges = false;
var updateDrawingObjectsInfo = null;
var updateDrawingObjectsInfo2 = null;//{bInsert: false, operType: c_oAscInsertOptions.InsertColumns, updateRange: arn}
var cw;
var isUpdateCols = false, isUpdateRows = false;
var isCheckChangeAutoFilter;
var functionModelAction = null;
var lockDraw = false; // Параметр, при котором не будет отрисовки (т.к. мы просто обновляем информацию на неактивном листе)
var oChangeData = new AscFormat.CChangeTableData( null, null, null, null ); // Обновление для диаграмм
var oChangeData = new AscFormat.CChangeTableData(null, null, null, null); // Обновление для диаграмм
var onChangeWorksheetCallback = function ( isSuccess ) {
if ( false === isSuccess ) {
var onChangeWorksheetCallback = function (isSuccess) {
if (false === isSuccess) {
return;
}
asc_applyFunction( functionModelAction );
asc_applyFunction(functionModelAction);
t._initCellsArea( fullRecalc );
if ( fullRecalc ) {
t._initCellsArea(fullRecalc);
if (fullRecalc) {
t.cache.reset();
}
t._cleanCellsTextMetricsCache();
t._prepareCellTextMetricsCache();
if(t.objectRender) {
if ( reinitRanges && t.objectRender.drawingArea ) {
if (t.objectRender) {
if (reinitRanges && t.objectRender.drawingArea) {
t.objectRender.drawingArea.reinitRanges();
}
if ( null !== updateDrawingObjectsInfo) {
t.objectRender.updateSizeDrawingObjects( updateDrawingObjectsInfo );
if (null !== updateDrawingObjectsInfo) {
t.objectRender.updateSizeDrawingObjects(updateDrawingObjectsInfo);
}
if ( null !== updateDrawingObjectsInfo2 ) {
t.objectRender.updateDrawingObject(updateDrawingObjectsInfo2.bInsert, updateDrawingObjectsInfo2.operType, updateDrawingObjectsInfo2.updateRange);
if (null !== updateDrawingObjectsInfo2) {
t.objectRender.updateDrawingObject(updateDrawingObjectsInfo2.bInsert,
updateDrawingObjectsInfo2.operType, updateDrawingObjectsInfo2.updateRange);
}
t.objectRender.rebuildChartGraphicObjects( oChangeData );
t.objectRender.rebuildChartGraphicObjects(oChangeData);
}
t.draw( lockDraw );
t.draw(lockDraw);
t.handlers.trigger( "reinitializeScroll" );
t.handlers.trigger("reinitializeScroll");
if ( isUpdateCols ) {
if (isUpdateCols) {
t._updateVisibleColsCount();
}
if ( isUpdateRows ) {
if (isUpdateRows) {
t._updateVisibleRowsCount();
}
t.handlers.trigger( "selectionChanged", t.getSelectionInfo() );
t.handlers.trigger( "selectionMathInfoChanged", t.getSelectionMathInfo() );
t.handlers.trigger("selectionChanged", t.getSelectionInfo());
t.handlers.trigger("selectionMathInfoChanged", t.getSelectionMathInfo());
};
switch ( prop ) {
switch (prop) {
case "colWidth":
functionModelAction = function () {
cw = t._charCountToModelColWidth( val );
t.model.setColWidth( cw, checkRange.c1, checkRange.c2 );
t.model.setColWidth(val, checkRange.c1, checkRange.c2);
isUpdateCols = true;
fullRecalc = true;
reinitRanges = true;
updateDrawingObjectsInfo = {target: c_oTargetType.ColumnResize, col: checkRange.c1};
};
this._isLockedAll( onChangeWorksheetCallback );
this._isLockedAll(onChangeWorksheetCallback);
break;
case "showCols":
functionModelAction = function () {
t.model.setColHidden( /*bHidden*/false, arn.c1, arn.c2 );
t.model.setColHidden(/*bHidden*/false, arn.c1, arn.c2);
fullRecalc = true;
reinitRanges = true;
updateDrawingObjectsInfo = {target: c_oTargetType.ColumnResize, col: arn.c1};
};
oChangeData.hided = new asc_Range( arn.c1, 0, arn.c2, gc_nMaxRow0 );
this._isLockedAll( onChangeWorksheetCallback );
oChangeData.hided = new asc_Range(arn.c1, 0, arn.c2, gc_nMaxRow0);
this._isLockedAll(onChangeWorksheetCallback);
break;
case "hideCols":
functionModelAction = function () {
t.model.setColHidden( /*bHidden*/true, arn.c1, arn.c2 );
t.model.setColHidden(/*bHidden*/true, arn.c1, arn.c2);
fullRecalc = true;
reinitRanges = true;
updateDrawingObjectsInfo = {target: c_oTargetType.ColumnResize, col: arn.c1};
};
oChangeData.hided = new asc_Range( arn.c1, 0, arn.c2, gc_nMaxRow0 );
this._isLockedAll( onChangeWorksheetCallback );
oChangeData.hided = new asc_Range(arn.c1, 0, arn.c2, gc_nMaxRow0);
this._isLockedAll(onChangeWorksheetCallback);
break;
case "rowHeight":
functionModelAction = function () {
// Приводим к px (чтобы было ровно)
val = val / 0.75;
val = (val | val) * 0.75; // 0.75 - это размер 1px в pt (можно было 96/72)
t.model.setRowHeight( Math.min( val, t.maxRowHeight ), checkRange.r1, checkRange.r2, true );
t.model.setRowHeight(Math.min(val, t.maxRowHeight), checkRange.r1, checkRange.r2, true);
isUpdateRows = true;
fullRecalc = true;
reinitRanges = true;
updateDrawingObjectsInfo = {target: c_oTargetType.RowResize, row: checkRange.r1};
};
return this._isLockedAll( onChangeWorksheetCallback );
return this._isLockedAll(onChangeWorksheetCallback);
case "showRows":
functionModelAction = function () {
t.model.setRowHidden( /*bHidden*/false, arn.r1, arn.r2 );
t.model.autoFilters.reDrawFilter( arn );
t.model.setRowHidden(/*bHidden*/false, arn.r1, arn.r2);
t.model.autoFilters.reDrawFilter(arn);
fullRecalc = true;
reinitRanges = true;
updateDrawingObjectsInfo = {target: c_oTargetType.RowResize, row: arn.r1};
};
oChangeData.hided = new asc_Range( 0, arn.r1, gc_nMaxCol0, arn.r2 );
this._isLockedAll( onChangeWorksheetCallback );
oChangeData.hided = new asc_Range(0, arn.r1, gc_nMaxCol0, arn.r2);
this._isLockedAll(onChangeWorksheetCallback);
break;
case "hideRows":
functionModelAction = function () {
t.model.setRowHidden( /*bHidden*/true, arn.r1, arn.r2 );
t.model.autoFilters.reDrawFilter( arn );
t.model.setRowHidden(/*bHidden*/true, arn.r1, arn.r2);
t.model.autoFilters.reDrawFilter(arn);
fullRecalc = true;
reinitRanges = true;
updateDrawingObjectsInfo = {target: c_oTargetType.RowResize, row: arn.r1};
};
oChangeData.hided = new asc_Range( 0, arn.r1, gc_nMaxCol0, arn.r2 );
this._isLockedAll( onChangeWorksheetCallback );
oChangeData.hided = new asc_Range(0, arn.r1, gc_nMaxCol0, arn.r2);
this._isLockedAll(onChangeWorksheetCallback);
break;
case "insCell":
range = t.model.getRange3( arn.r1, arn.c1, arn.r2, arn.c2 );
switch ( val ) {
range = t.model.getRange3(arn.r1, arn.c1, arn.r2, arn.c2);
switch (val) {
case c_oAscInsertOptions.InsertCellsAndShiftRight:
isCheckChangeAutoFilter = t.af_checkInsDelCells( arn, c_oAscInsertOptions.InsertCellsAndShiftRight, prop );
if ( isCheckChangeAutoFilter === false ) {
isCheckChangeAutoFilter =
t.af_checkInsDelCells(arn, c_oAscInsertOptions.InsertCellsAndShiftRight, prop);
if (isCheckChangeAutoFilter === false) {
return;
}
functionModelAction = function () {
History.Create_NewPoint();
History.StartTransaction();
if ( range.addCellsShiftRight() ) {
if (range.addCellsShiftRight()) {
fullRecalc = true;
reinitRanges = true;
t.cellCommentator.updateCommentsDependencies( true, val, arn );
t.cellCommentator.updateCommentsDependencies(true, val, arn);
updateDrawingObjectsInfo2 = {bInsert: true, operType: val, updateRange: arn};
}
History.EndTransaction();
};
oChangeData.changedRange = new asc_Range( arn.c1, arn.r1, gc_nMaxCol0, arn.r2 );
this._isLockedCells( oChangeData.changedRange, null, onChangeWorksheetCallback );
oChangeData.changedRange = new asc_Range(arn.c1, arn.r1, gc_nMaxCol0, arn.r2);
this._isLockedCells(oChangeData.changedRange, null, onChangeWorksheetCallback);
break;
case c_oAscInsertOptions.InsertCellsAndShiftDown:
isCheckChangeAutoFilter = t.af_checkInsDelCells( arn, c_oAscInsertOptions.InsertCellsAndShiftDown, prop );
if ( isCheckChangeAutoFilter === false ) {
isCheckChangeAutoFilter =
t.af_checkInsDelCells(arn, c_oAscInsertOptions.InsertCellsAndShiftDown, prop);
if (isCheckChangeAutoFilter === false) {
return;
}
functionModelAction = function () {
History.Create_NewPoint();
History.StartTransaction();
if ( range.addCellsShiftBottom() ) {
if (range.addCellsShiftBottom()) {
fullRecalc = true;
reinitRanges = true;
t.cellCommentator.updateCommentsDependencies( true, val, arn );
t.cellCommentator.updateCommentsDependencies(true, val, arn);
updateDrawingObjectsInfo2 = {bInsert: true, operType: val, updateRange: arn};
}
History.EndTransaction();
};
oChangeData.changedRange = new asc_Range( arn.c1, arn.r1, arn.c2, gc_nMaxRow0 );
this._isLockedCells( oChangeData.changedRange, null, onChangeWorksheetCallback );
oChangeData.changedRange = new asc_Range(arn.c1, arn.r1, arn.c2, gc_nMaxRow0);
this._isLockedCells(oChangeData.changedRange, null, onChangeWorksheetCallback);
break;
case c_oAscInsertOptions.InsertColumns:
isCheckChangeAutoFilter = t.model.autoFilters.isRangeIntersectionSeveralTableParts( arn );
if ( isCheckChangeAutoFilter === true ) {
this.model.workbook.handlers.trigger("asc_onError", c_oAscError.ID.AutoFilterChangeFormatTableError, c_oAscError.Level.NoCritical);
isCheckChangeAutoFilter = t.model.autoFilters.isRangeIntersectionSeveralTableParts(arn);
if (isCheckChangeAutoFilter === true) {
this.model.workbook.handlers.trigger("asc_onError",
c_oAscError.ID.AutoFilterChangeFormatTableError, c_oAscError.Level.NoCritical);
return;
}
......@@ -10529,73 +10517,79 @@
History.StartTransaction();
fullRecalc = true;
reinitRanges = true;
t.model.insertColsBefore( arn.c1, arn.c2 - arn.c1 + 1 );
t.model.insertColsBefore(arn.c1, arn.c2 - arn.c1 + 1);
updateDrawingObjectsInfo2 = {bInsert: true, operType: val, updateRange: arn};
t.cellCommentator.updateCommentsDependencies( true, val, arn );
t.cellCommentator.updateCommentsDependencies(true, val, arn);
History.EndTransaction();
};
oChangeData.added = new asc_Range( arn.c1, 0, arn.c2, gc_nMaxRow0 );
this._isLockedCells( oChangeData.added, c_oAscLockTypeElemSubType.InsertColumns, onChangeWorksheetCallback );
oChangeData.added = new asc_Range(arn.c1, 0, arn.c2, gc_nMaxRow0);
this._isLockedCells(oChangeData.added, c_oAscLockTypeElemSubType.InsertColumns,
onChangeWorksheetCallback);
break;
case c_oAscInsertOptions.InsertRows:
functionModelAction = function () {
fullRecalc = true;
reinitRanges = true;
t.model.insertRowsBefore( arn.r1, arn.r2 - arn.r1 + 1 );
t.model.insertRowsBefore(arn.r1, arn.r2 - arn.r1 + 1);
updateDrawingObjectsInfo2 = {bInsert: true, operType: val, updateRange: arn};
t.cellCommentator.updateCommentsDependencies( true, val, arn );
t.cellCommentator.updateCommentsDependencies(true, val, arn);
};
oChangeData.added = new asc_Range( 0, arn.r1, gc_nMaxCol0, arn.r2 );
this._isLockedCells( oChangeData.added, c_oAscLockTypeElemSubType.InsertRows, onChangeWorksheetCallback );
oChangeData.added = new asc_Range(0, arn.r1, gc_nMaxCol0, arn.r2);
this._isLockedCells(oChangeData.added, c_oAscLockTypeElemSubType.InsertRows,
onChangeWorksheetCallback);
break;
}
break;
case "delCell":
range = t.model.getRange3( checkRange.r1, checkRange.c1, checkRange.r2, checkRange.c2 );
switch ( val ) {
range = t.model.getRange3(checkRange.r1, checkRange.c1, checkRange.r2, checkRange.c2);
switch (val) {
case c_oAscDeleteOptions.DeleteCellsAndShiftLeft:
isCheckChangeAutoFilter = t.af_checkInsDelCells( arn, c_oAscDeleteOptions.DeleteCellsAndShiftLeft, prop );
if ( isCheckChangeAutoFilter === false ) {
isCheckChangeAutoFilter =
t.af_checkInsDelCells(arn, c_oAscDeleteOptions.DeleteCellsAndShiftLeft, prop);
if (isCheckChangeAutoFilter === false) {
return;
}
functionModelAction = function () {
History.Create_NewPoint();
History.StartTransaction();
if ( isCheckChangeAutoFilter === true ) {
t.model.autoFilters.isEmptyAutoFilters( arn, c_oAscDeleteOptions.DeleteCellsAndShiftLeft );
if (isCheckChangeAutoFilter === true) {
t.model.autoFilters.isEmptyAutoFilters(arn,
c_oAscDeleteOptions.DeleteCellsAndShiftLeft);
}
if ( range.deleteCellsShiftLeft( function () {
t._cleanCache( oChangeData.changedRange );
t.cellCommentator.updateCommentsDependencies( false, val, checkRange );
} ) ) {
if (range.deleteCellsShiftLeft(function () {
t._cleanCache(oChangeData.changedRange);
t.cellCommentator.updateCommentsDependencies(false, val, checkRange);
})) {
updateDrawingObjectsInfo2 = {bInsert: false, operType: val, updateRange: arn};
}
History.EndTransaction();
reinitRanges = true;
};
oChangeData.changedRange = new asc_Range( checkRange.c1, checkRange.r1, gc_nMaxCol0, checkRange.r2 );
this._isLockedCells( oChangeData.changedRange, null, onChangeWorksheetCallback );
oChangeData.changedRange =
new asc_Range(checkRange.c1, checkRange.r1, gc_nMaxCol0, checkRange.r2);
this._isLockedCells(oChangeData.changedRange, null, onChangeWorksheetCallback);
break;
case c_oAscDeleteOptions.DeleteCellsAndShiftTop:
isCheckChangeAutoFilter = t.af_checkInsDelCells( arn, c_oAscDeleteOptions.DeleteCellsAndShiftTop, prop );
if ( isCheckChangeAutoFilter === false ) {
isCheckChangeAutoFilter =
t.af_checkInsDelCells(arn, c_oAscDeleteOptions.DeleteCellsAndShiftTop, prop);
if (isCheckChangeAutoFilter === false) {
return;
}
functionModelAction = function () {
History.Create_NewPoint();
History.StartTransaction();
if ( isCheckChangeAutoFilter === true ) {
t.model.autoFilters.isEmptyAutoFilters( arn, c_oAscDeleteOptions.DeleteCellsAndShiftTop );
if (isCheckChangeAutoFilter === true) {
t.model.autoFilters.isEmptyAutoFilters(arn, c_oAscDeleteOptions.DeleteCellsAndShiftTop);
}
if ( range.deleteCellsShiftUp( function () {
t._cleanCache( oChangeData.changedRange );
t.cellCommentator.updateCommentsDependencies( false, val, checkRange );
} ) ) {
if (range.deleteCellsShiftUp(function () {
t._cleanCache(oChangeData.changedRange);
t.cellCommentator.updateCommentsDependencies(false, val, checkRange);
})) {
updateDrawingObjectsInfo2 = {bInsert: false, operType: val, updateRange: arn};
}
History.EndTransaction();
......@@ -10603,12 +10597,14 @@
reinitRanges = true;
};
oChangeData.changedRange = new asc_Range( checkRange.c1, checkRange.r1, checkRange.c2, gc_nMaxRow0 );
this._isLockedCells( oChangeData.changedRange, null, onChangeWorksheetCallback );
oChangeData.changedRange =
new asc_Range(checkRange.c1, checkRange.r1, checkRange.c2, gc_nMaxRow0);
this._isLockedCells(oChangeData.changedRange, null, onChangeWorksheetCallback);
break;
case c_oAscDeleteOptions.DeleteColumns:
isCheckChangeAutoFilter = t.model.autoFilters.isActiveCellsCrossHalfFTable( checkRange, c_oAscDeleteOptions.DeleteColumns, prop );
if ( isCheckChangeAutoFilter === false ) {
isCheckChangeAutoFilter = t.model.autoFilters.isActiveCellsCrossHalfFTable(checkRange,
c_oAscDeleteOptions.DeleteColumns, prop);
if (isCheckChangeAutoFilter === false) {
return;
}
......@@ -10617,19 +10613,22 @@
reinitRanges = true;
History.Create_NewPoint();
History.StartTransaction();
t.cellCommentator.updateCommentsDependencies( false, val, checkRange );
t.model.autoFilters.isEmptyAutoFilters( arn, c_oAscDeleteOptions.DeleteColumns );
t.model.removeCols( checkRange.c1, checkRange.c2 );
t.cellCommentator.updateCommentsDependencies(false, val, checkRange);
t.model.autoFilters.isEmptyAutoFilters(arn, c_oAscDeleteOptions.DeleteColumns);
t.model.removeCols(checkRange.c1, checkRange.c2);
updateDrawingObjectsInfo2 = {bInsert: false, operType: val, updateRange: arn};
History.EndTransaction();
};
oChangeData.removed = new asc_Range( checkRange.c1, 0, checkRange.c2, gc_nMaxRow0 );
this._isLockedCells( oChangeData.removed, c_oAscLockTypeElemSubType.DeleteColumns, onChangeWorksheetCallback );
oChangeData.removed = new asc_Range(checkRange.c1, 0, checkRange.c2, gc_nMaxRow0);
this._isLockedCells(oChangeData.removed, c_oAscLockTypeElemSubType.DeleteColumns,
onChangeWorksheetCallback);
break;
case c_oAscDeleteOptions.DeleteRows:
isCheckChangeAutoFilter = t.model.autoFilters.isActiveCellsCrossHalfFTable( checkRange, c_oAscDeleteOptions.DeleteRows, prop );
if ( isCheckChangeAutoFilter === false ) {
isCheckChangeAutoFilter =
t.model.autoFilters.isActiveCellsCrossHalfFTable(checkRange, c_oAscDeleteOptions.DeleteRows,
prop);
if (isCheckChangeAutoFilter === false) {
return;
}
......@@ -10638,22 +10637,23 @@
reinitRanges = true;
History.Create_NewPoint();
History.StartTransaction();
t.cellCommentator.updateCommentsDependencies( false, val, checkRange );
t.model.autoFilters.isEmptyAutoFilters( arn, c_oAscDeleteOptions.DeleteRows );
t.model.removeRows( checkRange.r1, checkRange.r2 );
t.cellCommentator.updateCommentsDependencies(false, val, checkRange);
t.model.autoFilters.isEmptyAutoFilters(arn, c_oAscDeleteOptions.DeleteRows);
t.model.removeRows(checkRange.r1, checkRange.r2);
updateDrawingObjectsInfo2 = {bInsert: false, operType: val, updateRange: arn};
History.EndTransaction();
};
oChangeData.removed = new asc_Range( 0, checkRange.r1, gc_nMaxCol0, checkRange.r2 );
this._isLockedCells( oChangeData.removed, c_oAscLockTypeElemSubType.DeleteRows, onChangeWorksheetCallback );
oChangeData.removed = new asc_Range(0, checkRange.r1, gc_nMaxCol0, checkRange.r2);
this._isLockedCells(oChangeData.removed, c_oAscLockTypeElemSubType.DeleteRows,
onChangeWorksheetCallback);
break;
}
this.handlers.trigger( "selectionNameChanged", t.getSelectionName( /*bRangeText*/false ) );
this.handlers.trigger("selectionNameChanged", t.getSelectionName(/*bRangeText*/false));
break;
case "sheetViewSettings":
functionModelAction = function () {
t.model.setSheetViewSettings( val );
t.model.setSheetViewSettings(val);
isUpdateCols = true;
isUpdateRows = true;
......@@ -10661,15 +10661,15 @@
reinitRanges = true;
};
this._isLockedAll( onChangeWorksheetCallback );
this._isLockedAll(onChangeWorksheetCallback);
break;
case "update":
if ( val !== undefined ) {
if (val !== undefined) {
fullRecalc = !!val.fullRecalc;
lockDraw = true === val.lockDraw;
reinitRanges = !!val.reinitRanges;
}
onChangeWorksheetCallback( true );
onChangeWorksheetCallback(true);
break;
}
};
......@@ -10806,7 +10806,7 @@
if (width > 0) {
pad = this.width_padding * 2 + this.width_1px;
cc = Math.min(this._colWidthToCharCount(width + pad), Asc.c_oAscMaxColumnWidth);
cw = this._charCountToModelColWidth(cc);
cw = this.model.charCountToModelColWidth(cc);
} else {
cw = AscCommonExcel.oDefaultMetrics.ColWidthChars;
cc = this.defaultColWidthChars;
......
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