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