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,11 +2555,10 @@ ...@@ -2555,11 +2555,10 @@
// 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) {
...@@ -2574,14 +2573,10 @@ ...@@ -2574,14 +2573,10 @@
var result = []; var result = [];
var options; var options;
var n = 0; var n = 0;
if(customStyles) if (customStyles) {
{ for (var i in customStyles) {
for(var i in customStyles) if (customStyles[i].table) {
{ options = {
if(customStyles[i].table)
{
options =
{
name: i, name: i,
displayName: customStyles[i].displayName, displayName: customStyles[i].displayName,
type: 'custom', type: 'custom',
...@@ -2593,14 +2588,10 @@ ...@@ -2593,14 +2588,10 @@
} }
} }
var defaultStyles = wb.TableStyles.DefaultStyles; var defaultStyles = wb.TableStyles.DefaultStyles;
if(defaultStyles) if (defaultStyles) {
{ for (var i in defaultStyles) {
for(var i in defaultStyles) if (defaultStyles[i].table) {
{ options = {
if(defaultStyles[i].table)
{
options =
{
name: i, name: i,
displayName: defaultStyles[i].displayName, displayName: defaultStyles[i].displayName,
type: 'default', type: 'default',
...@@ -2614,17 +2605,14 @@ ...@@ -2614,17 +2605,14 @@
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; var styleInfo;
if(props) if (props) {
{ styleInfo = {
styleInfo =
{
ShowColumnStripes: props.asc_getBandVer(), ShowColumnStripes: props.asc_getBandVer(),
ShowFirstColumn: props.asc_getFirstCol(), ShowFirstColumn: props.asc_getFirstCol(),
ShowLastColumn: props.asc_getLastCol(), ShowLastColumn: props.asc_getLastCol(),
...@@ -2632,11 +2620,8 @@ ...@@ -2632,11 +2620,8 @@
HeaderRowCount: props.asc_getFirstRow(), HeaderRowCount: props.asc_getFirstRow(),
TotalsRowCount: props.asc_getLastRow() TotalsRowCount: props.asc_getLastRow()
}; };
} } else {
else styleInfo = {
{
styleInfo =
{
ShowColumnStripes: false, ShowColumnStripes: false,
ShowFirstColumn: false, ShowFirstColumn: false,
ShowLastColumn: false, ShowLastColumn: false,
...@@ -2658,146 +2643,134 @@ ...@@ -2658,146 +2643,134 @@
//**draw background** //**draw background**
var defaultColorBackground; var defaultColorBackground;
if(styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill) if (styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill) {
defaultColorBackground = styleOptions.wholeTable.dxf.fill.bg; defaultColorBackground = styleOptions.wholeTable.dxf.fill.bg;
else } else {
defaultColorBackground = whiteColor; defaultColorBackground = whiteColor;
}
var color; var color;
if(styleOptions != undefined) if (styleOptions != undefined) {
{ if (styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill && null != styleOptions.wholeTable.dxf.fill.bg) {
if(styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill && null != styleOptions.wholeTable.dxf.fill.bg)
{
ctx.setFillStyle(styleOptions.wholeTable.dxf.fill.bg); ctx.setFillStyle(styleOptions.wholeTable.dxf.fill.bg);
ctx.fillRect(0, 0, xSize, ySize); ctx.fillRect(0, 0, xSize, ySize);
} } else {
else
{
ctx.setFillStyle(whiteColor); ctx.setFillStyle(whiteColor);
ctx.fillRect(0, 0, xSize, ySize); ctx.fillRect(0, 0, xSize, ySize);
} }
if(styleInfo.ShowColumnStripes)//column stripes if (styleInfo.ShowColumnStripes)//column stripes
{
for(k = 0; k < 6; k++)
{ {
for (k = 0; k < 6; k++) {
color = defaultColorBackground; color = defaultColorBackground;
if(k % 2 == 0) if (k % 2 == 0) {
{ if (styleOptions.firstColumnStripe && styleOptions.firstColumnStripe.dxf.fill &&
if(styleOptions.firstColumnStripe && styleOptions.firstColumnStripe.dxf.fill && null != styleOptions.firstColumnStripe.dxf.fill.bg) null != styleOptions.firstColumnStripe.dxf.fill.bg) {
color = 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) } else if (styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill &&
null != styleOptions.wholeTable.dxf.fill.bg) {
color = styleOptions.wholeTable.dxf.fill.bg; color = styleOptions.wholeTable.dxf.fill.bg;
} }
else } else {
{ if (styleOptions.secondColumnStripe && styleOptions.secondColumnStripe.dxf.fill &&
if(styleOptions.secondColumnStripe && styleOptions.secondColumnStripe.dxf.fill && null != styleOptions.secondColumnStripe.dxf.fill.bg) null != styleOptions.secondColumnStripe.dxf.fill.bg) {
color = 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) } else if (styleOptions.wholeTable && styleOptions.wholeTable.dxf.fill &&
null != styleOptions.wholeTable.dxf.fill.bg) {
color = styleOptions.wholeTable.dxf.fill.bg; color = styleOptions.wholeTable.dxf.fill.bg;
} }
}
ctx.setFillStyle(color); ctx.setFillStyle(color);
ctx.fillRect(k * stepX, 0, stepX, ySize); ctx.fillRect(k * stepX, 0, stepX, ySize);
} }
} }
if(styleInfo.ShowRowStripes)//row stripes if (styleInfo.ShowRowStripes)//row stripes
{
for(var k = 0; k < 6; k++)
{ {
for (var k = 0; k < 6; k++) {
color = null; color = null;
if(k == 0 && styleInfo.HeaderRowCount) if (k == 0 && styleInfo.HeaderRowCount) {
continue; continue;
}
if(styleInfo.HeaderRowCount) if (styleInfo.HeaderRowCount) {
{ if (k % 2 != 0) {
if(k % 2 != 0) if (styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.fill &&
{ null != styleOptions.firstRowStripe.dxf.fill.bg) {
if(styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.fill && null != styleOptions.firstRowStripe.dxf.fill.bg)
{
color = styleOptions.firstRowStripe.dxf.fill.bg; color = styleOptions.firstRowStripe.dxf.fill.bg;
} }
} } else {
else if (styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.fill &&
{ null != styleOptions.secondRowStripe.dxf.fill.bg) {
if(styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.fill && null != styleOptions.secondRowStripe.dxf.fill.bg)
{
color = styleOptions.secondRowStripe.dxf.fill.bg; color = styleOptions.secondRowStripe.dxf.fill.bg;
} }
} }
} } else {
else if (k % 2 != 0) {
{ if (styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.fill &&
if(k % 2 != 0) null != styleOptions.secondRowStripe.dxf.fill.bg) {
{
if(styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.fill && null != styleOptions.secondRowStripe.dxf.fill.bg)
{
color = styleOptions.secondRowStripe.dxf.fill.bg; color = styleOptions.secondRowStripe.dxf.fill.bg;
} }
} } else {
else if (styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.fill &&
{ null != styleOptions.firstRowStripe.dxf.fill.bg) {
if(styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.fill && null != styleOptions.firstRowStripe.dxf.fill.bg)
{
color = styleOptions.firstRowStripe.dxf.fill.bg; color = styleOptions.firstRowStripe.dxf.fill.bg;
} }
} }
} }
if(color != null) if (color != null) {
{
ctx.setFillStyle(color); ctx.setFillStyle(color);
ctx.fillRect(0, k * stepY, xSize, stepY); ctx.fillRect(0, k * stepY, xSize, stepY);
} }
} }
} }
if(styleInfo.ShowFirstColumn && styleOptions.firstColumn)//first column if (styleInfo.ShowFirstColumn && styleOptions.firstColumn)//first column
{ {
color = null; color = null;
if(styleOptions.firstColumn && styleOptions.firstColumn.dxf.fill && null != styleOptions.firstColumn.dxf.fill.bg) if (styleOptions.firstColumn && styleOptions.firstColumn.dxf.fill &&
null != styleOptions.firstColumn.dxf.fill.bg) {
color = styleOptions.firstColumn.dxf.fill.bg; color = styleOptions.firstColumn.dxf.fill.bg;
}
if(color != null) if (color != null) {
{
ctx.setFillStyle(color); ctx.setFillStyle(color);
ctx.fillRect(0, 0, stepX, ySize); ctx.fillRect(0, 0, stepX, ySize);
} }
} }
if(styleInfo.ShowLastColumn)//last column if (styleInfo.ShowLastColumn)//last column
{ {
color = null; color = null;
if(styleOptions.lastColumn && styleOptions.lastColumn.dxf.fill && null != styleOptions.lastColumn.dxf.fill.bg) if (styleOptions.lastColumn && styleOptions.lastColumn.dxf.fill &&
color =styleOptions.lastColumn.dxf.fill.bg; null != styleOptions.lastColumn.dxf.fill.bg) {
color = styleOptions.lastColumn.dxf.fill.bg;
}
if(color != null) if (color != null) {
{
ctx.setFillStyle(color); ctx.setFillStyle(color);
ctx.fillRect(4*stepX + 1, 0, stepX, ySize); ctx.fillRect(4 * stepX + 1, 0, stepX, ySize);
} }
} }
if(styleInfo.HeaderRowCount)//header row if (styleInfo.HeaderRowCount)//header row
{
if(styleOptions.headerRow && styleOptions.headerRow.dxf.fill && null != styleOptions.headerRow.dxf.fill.bg)
{ {
if (styleOptions.headerRow && styleOptions.headerRow.dxf.fill && null != styleOptions.headerRow.dxf.fill.bg) {
ctx.setFillStyle(styleOptions.headerRow.dxf.fill.bg); ctx.setFillStyle(styleOptions.headerRow.dxf.fill.bg);
} } else {
else
{
ctx.setFillStyle(defaultColorBackground); ctx.setFillStyle(defaultColorBackground);
} }
ctx.fillRect(0, 0, xSize, stepY); ctx.fillRect(0, 0, xSize, stepY);
} }
if(styleInfo.TotalsRowCount)//total row if (styleInfo.TotalsRowCount)//total row
{ {
color = null; color = null;
if(styleOptions.totalRow && styleOptions.totalRow.dxf.fill && null != styleOptions.totalRow.dxf.fill.bg) if (styleOptions.totalRow && styleOptions.totalRow.dxf.fill && null != styleOptions.totalRow.dxf.fill.bg) {
color = styleOptions.totalRow.dxf.fill.bg; color = styleOptions.totalRow.dxf.fill.bg;
}
if(color !== null) if (color !== null) {
{
ctx.setFillStyle(color); ctx.setFillStyle(color);
ctx.fillRect(0, stepY * 4, xSize, stepY); ctx.fillRect(0, stepY * 4, xSize, stepY);
} }
...@@ -2805,94 +2778,85 @@ ...@@ -2805,94 +2778,85 @@
//первая ячейка //первая ячейка
if(styleOptions.firstHeaderCell && styleInfo.ShowFirstColumn) if (styleOptions.firstHeaderCell && styleInfo.ShowFirstColumn) {
{ if (styleOptions.firstHeaderCell && styleOptions.firstHeaderCell.dxf.fill &&
if(styleOptions.firstHeaderCell && styleOptions.firstHeaderCell.dxf.fill && null != styleOptions.firstHeaderCell.dxf.fill.bg) null != styleOptions.firstHeaderCell.dxf.fill.bg) {
ctx.setFillStyle(styleOptions.firstHeaderCell.dxf.fill.bg); ctx.setFillStyle(styleOptions.firstHeaderCell.dxf.fill.bg);
else } else {
ctx.setFillStyle(defaultColorBackground); ctx.setFillStyle(defaultColorBackground);
ctx.fillRect(0,0,stepX,stepY); }
ctx.fillRect(0, 0, stepX, stepY);
} }
//последняя в первой строке //последняя в первой строке
if(styleOptions.lastHeaderCell && styleInfo.ShowLastColumn) if (styleOptions.lastHeaderCell && styleInfo.ShowLastColumn) {
{ if (styleOptions.lastHeaderCell && styleOptions.lastHeaderCell.dxf.fill &&
if(styleOptions.lastHeaderCell && styleOptions.lastHeaderCell.dxf.fill && null != styleOptions.lastHeaderCell.dxf.fill.bg) null != styleOptions.lastHeaderCell.dxf.fill.bg) {
ctx.setFillStyle(styleOptions.lastHeaderCell.dxf.fill.bg); ctx.setFillStyle(styleOptions.lastHeaderCell.dxf.fill.bg);
else } else {
ctx.setFillStyle(defaultColorBackground); ctx.setFillStyle(defaultColorBackground);
ctx.fillRect(4*stepX,0,stepX,stepY); }
ctx.fillRect(4 * stepX, 0, stepX, stepY);
} }
//первая в последней строке //первая в последней строке
if(styleOptions.firstTotalCell && styleInfo.TotalsRowCount && styleInfo.ShowFirstColumn) if (styleOptions.firstTotalCell && styleInfo.TotalsRowCount && styleInfo.ShowFirstColumn) {
{ if (styleOptions.firstTotalCell && styleOptions.firstTotalCell.dxf.fill &&
if(styleOptions.firstTotalCell && styleOptions.firstTotalCell.dxf.fill && null != styleOptions.firstTotalCell.dxf.fill.bg) null != styleOptions.firstTotalCell.dxf.fill.bg) {
ctx.setFillStyle(styleOptions.firstTotalCell.dxf.fill.bg); ctx.setFillStyle(styleOptions.firstTotalCell.dxf.fill.bg);
else } else {
ctx.setFillStyle(defaultColorBackground); ctx.setFillStyle(defaultColorBackground);
ctx.fillRect(0,4*stepY,stepX,stepY); }
ctx.fillRect(0, 4 * stepY, stepX, stepY);
} }
//последняя ячейка //последняя ячейка
if(styleOptions.lastTotalCell && styleInfo.TotalsRowCount && styleInfo.ShowLastColumn) if (styleOptions.lastTotalCell && styleInfo.TotalsRowCount && styleInfo.ShowLastColumn) {
{ if (styleOptions.lastTotalCell && styleOptions.lastTotalCell.dxf.fill &&
if(styleOptions.lastTotalCell && styleOptions.lastTotalCell.dxf.fill && null != styleOptions.lastTotalCell.dxf.fill.bg) null != styleOptions.lastTotalCell.dxf.fill.bg) {
ctx.setFillStyle(styleOptions.lastTotalCell.dxf.fill.bg); ctx.setFillStyle(styleOptions.lastTotalCell.dxf.fill.bg);
else } else {
ctx.setFillStyle(defaultColorBackground); ctx.setFillStyle(defaultColorBackground);
ctx.fillRect(4*stepX,4*stepY,stepX,ySize);
} }
ctx.fillRect(4 * stepX, 4 * stepY, stepX, ySize);
} }
else
{ } else {
ctx.setFillStyle(whiteColor); ctx.setFillStyle(whiteColor);
ctx.fillRect(0,0,xSize,ySize); ctx.fillRect(0, 0, xSize, ySize);
} }
//**draw vertical and horizontal lines** //**draw vertical and horizontal lines**
if(styleOptions != undefined) if (styleOptions != undefined) {
{
ctx.setLineWidth(1); ctx.setLineWidth(1);
ctx.beginPath(); ctx.beginPath();
if(styleOptions.wholeTable && styleOptions.wholeTable.dxf.border) if (styleOptions.wholeTable && styleOptions.wholeTable.dxf.border) {
{
var borders = styleOptions.wholeTable.dxf.border; var borders = styleOptions.wholeTable.dxf.border;
if(borders.t.s !== c_oAscBorderStyles.None) if (borders.t.s !== c_oAscBorderStyles.None) {
{
ctx.setStrokeStyle(borders.t.c); ctx.setStrokeStyle(borders.t.c);
ctx.lineHor(0, 0, xSize); ctx.lineHor(0, 0, xSize);
} }
if(borders.b.s !== c_oAscBorderStyles.None) if (borders.b.s !== c_oAscBorderStyles.None) {
{
ctx.setStrokeStyle(borders.b.c); ctx.setStrokeStyle(borders.b.c);
ctx.lineHor(0, ySize, xSize); ctx.lineHor(0, ySize, xSize);
} }
if(borders.l.s !== c_oAscBorderStyles.None) if (borders.l.s !== c_oAscBorderStyles.None) {
{
ctx.setStrokeStyle(borders.l.c); ctx.setStrokeStyle(borders.l.c);
ctx.lineVer(0, 0, ySize); ctx.lineVer(0, 0, ySize);
} }
if(borders.r.s !== c_oAscBorderStyles.None) if (borders.r.s !== c_oAscBorderStyles.None) {
{
ctx.setStrokeStyle(borders.r.c); ctx.setStrokeStyle(borders.r.c);
ctx.lineVer(xSize - 1, 0, ySize); ctx.lineVer(xSize - 1, 0, ySize);
} }
if(borders.ih.s !== c_oAscBorderStyles.None) if (borders.ih.s !== c_oAscBorderStyles.None) {
{
ctx.setStrokeStyle(borders.ih.c); ctx.setStrokeStyle(borders.ih.c);
for(var n = 1; n < 5; n++) for (var n = 1; n < 5; n++) {
{ ctx.lineHor(0, stepY * n, xSize);
ctx.lineHor(0, stepY*n, xSize);
} }
ctx.stroke(); ctx.stroke();
} }
if(borders.iv.s !== c_oAscBorderStyles.None) if (borders.iv.s !== c_oAscBorderStyles.None) {
{
ctx.setStrokeStyle(borders.iv.c); ctx.setStrokeStyle(borders.iv.c);
for(var n = 1; n < 5; n++) for (var n = 1; n < 5; n++) {
{ ctx.lineVer(stepX * n, 0, ySize);
ctx.lineVer(stepX*n, 0, ySize);
} }
ctx.stroke(); ctx.stroke();
} }
...@@ -2900,41 +2864,35 @@ ...@@ -2900,41 +2864,35 @@
} }
var border; var border;
if(styleInfo.ShowRowStripes) if (styleInfo.ShowRowStripes) {
{ if (styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.border) {
if(styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.border)
border = styleOptions.firstRowStripe.dxf.border; border = styleOptions.firstRowStripe.dxf.border;
else if(styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.border) } else if (styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.border) {
border = styleOptions.secondRowStripe.dxf.border; border = styleOptions.secondRowStripe.dxf.border;
}
if(border) if (border) {
{ for (n = 1; n < 5; n++) {
for(n = 1; n < 5; n++) ctx.lineHor(0, stepY * n, xSize);
{
ctx.lineHor(0, stepY*n, xSize);
} }
ctx.stroke(); ctx.stroke();
} }
} }
if(styleOptions.totalRow && styleInfo.TotalsRowCount && styleOptions.totalRow.dxf.border) if (styleOptions.totalRow && styleInfo.TotalsRowCount && styleOptions.totalRow.dxf.border) {
{
border = styleOptions.totalRow.dxf.border; border = styleOptions.totalRow.dxf.border;
if(border.t.s !== c_oAscBorderStyles.None) if (border.t.s !== c_oAscBorderStyles.None) {
{
ctx.setStrokeStyle(border.t.c); ctx.setStrokeStyle(border.t.c);
ctx.lineVer(0, xSize, ySize); ctx.lineVer(0, xSize, ySize);
} }
} }
if(styleOptions.headerRow && styleOptions.headerRow.dxf.border && styleInfo.HeaderRowCount)//header row if (styleOptions.headerRow && styleOptions.headerRow.dxf.border && styleInfo.HeaderRowCount)//header row
{ {
border = styleOptions.headerRow.dxf.border; border = styleOptions.headerRow.dxf.border;
if(border.t.s !== c_oAscBorderStyles.None) if (border.t.s !== c_oAscBorderStyles.None) {
{
ctx.setStrokeStyle(border.t.c); ctx.setStrokeStyle(border.t.c);
ctx.lineHor(0, 0, xSize); ctx.lineHor(0, 0, xSize);
} }
if(border.b.s !== c_oAscBorderStyles.None) if (border.b.s !== c_oAscBorderStyles.None) {
{
ctx.setStrokeStyle(border.b.c); ctx.setStrokeStyle(border.b.c);
ctx.lineHor(0, stepY, xSize); ctx.lineHor(0, stepY, xSize);
} }
...@@ -2945,44 +2903,44 @@ ...@@ -2945,44 +2903,44 @@
//**draw marks line** //**draw marks line**
var defaultColor; var defaultColor;
if(!styleOptions || !styleOptions.wholeTable || !styleOptions.wholeTable.dxf.font) if (!styleOptions || !styleOptions.wholeTable || !styleOptions.wholeTable.dxf.font) {
defaultColor = blackColor; defaultColor = blackColor;
else } else {
defaultColor = styleOptions.wholeTable.dxf.font.c; defaultColor = styleOptions.wholeTable.dxf.font.c;
for(var n = 1; n < 6; n++) }
{ for (var n = 1; n < 6; n++) {
ctx.beginPath(); ctx.beginPath();
color = null; color = null;
if(n == 1 && styleOptions && styleOptions.headerRow && styleOptions.headerRow.dxf.font) if (n == 1 && styleOptions && styleOptions.headerRow && styleOptions.headerRow.dxf.font) {
color = styleOptions.headerRow.dxf.font.c; color = styleOptions.headerRow.dxf.font.c;
else if(n == 5 && styleOptions && styleOptions.totalRow && styleOptions.totalRow.dxf.font) } else if (n == 5 && styleOptions && styleOptions.totalRow && styleOptions.totalRow.dxf.font) {
color = styleOptions.totalRow.dxf.font.c; color = styleOptions.totalRow.dxf.font.c;
else if(styleOptions && styleOptions.headerRow && styleInfo.ShowRowStripes) } else if (styleOptions && styleOptions.headerRow && styleInfo.ShowRowStripes) {
{ if ((n == 2 || (n == 5 && !styleOptions.totalRow)) && styleOptions.firstRowStripe &&
if((n == 2 || (n == 5 && !styleOptions.totalRow)) && styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.font) styleOptions.firstRowStripe.dxf.font) {
color = styleOptions.firstRowStripe.dxf.font.c; color = styleOptions.firstRowStripe.dxf.font.c;
else if(n == 3 && styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.font) } else if (n == 3 && styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.font) {
color = styleOptions.secondRowStripe.dxf.font.c; color = styleOptions.secondRowStripe.dxf.font.c;
else } else {
color = defaultColor color = defaultColor
} }
else if(styleOptions && !styleOptions.headerRow && styleInfo.ShowRowStripes) } else if (styleOptions && !styleOptions.headerRow && styleInfo.ShowRowStripes) {
{ if ((n == 1 || n == 3 || (n == 5 && !styleOptions.totalRow)) && styleOptions.firstRowStripe &&
if((n == 1 || n == 3 || (n == 5 && !styleOptions.totalRow)) && styleOptions.firstRowStripe && styleOptions.firstRowStripe.dxf.font) styleOptions.firstRowStripe.dxf.font) {
color = styleOptions.firstRowStripe.dxf.font.c; color = styleOptions.firstRowStripe.dxf.font.c;
else if((n == 2 || n == 4) && styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.font) } else if ((n == 2 || n == 4) && styleOptions.secondRowStripe && styleOptions.secondRowStripe.dxf.font) {
color = styleOptions.secondRowStripe.dxf.font.c; color = styleOptions.secondRowStripe.dxf.font.c;
else } else {
color = defaultColor color = defaultColor
} }
else } else {
color = defaultColor; color = defaultColor;
}
ctx.setStrokeStyle(color); ctx.setStrokeStyle(color);
var k = 0; var k = 0;
var strY = n*stepY - stepY/2; var strY = n * stepY - stepY / 2;
while(k < 6) while (k < 6) {
{ ctx.lineHor(k * stepX + 3 * pxToMM, strY, (k + 1) * stepX - 2 * pxToMM);
ctx.lineHor(k*stepX + 3 * pxToMM, strY, (k + 1)*stepX - 2 * pxToMM);
k++; k++;
} }
ctx.stroke(); ctx.stroke();
......
...@@ -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 () { }
t._cleanCache( oChangeData.changedRange ); if (range.deleteCellsShiftLeft(function () {
t.cellCommentator.updateCommentsDependencies( false, val, checkRange ); t._cleanCache(oChangeData.changedRange);
} ) ) { 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