Commit 39627783 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Поправил рассчет ширины ячейки (паддинги теперь зависят от maxDigitWidth)

http://social.msdn.microsoft.com/Forums/en-US/9a6a9785-66ad-4b6b-bb9f-74429381bd72/margin-padding-in-cell-excel?forum=os_binaryfile

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57979 954022d7-b5bf-4e40-9824-e11837661b57
parent e33c0598
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
this.reFormula = /^([a-z_][a-z0-9_]*)/i; this.reFormula = /^([a-z_][a-z0-9_]*)/i;
this.defaults = { this.defaults = {
padding : 2, padding : -1,
selectColor : new CColor(190, 190, 255, 0.5), selectColor : new CColor(190, 190, 255, 0.5),
canvasZIndex : 500, canvasZIndex : 500,
...@@ -161,6 +161,7 @@ ...@@ -161,6 +161,7 @@
CellEditor.prototype._init = function (settings) { CellEditor.prototype._init = function (settings) {
var t = this; var t = this;
var z = t.defaults.canvasZIndex; var z = t.defaults.canvasZIndex;
this.defaults.padding = settings.padding;
if (null != this.element) { if (null != this.element) {
t.canvasOuter = document.createElement('div'); t.canvasOuter = document.createElement('div');
......
...@@ -69,7 +69,8 @@ ...@@ -69,7 +69,8 @@
border: new CColor(212, 212, 212), border: new CColor(212, 212, 212),
color: new CColor(0, 0, 0) color: new CColor(0, 0, 0)
}, },
padding: 2/*px horizontal padding*/ padding: -1, /*px horizontal padding*/
paddingPlusBorder: -1
}; };
this.activeCellBorderColor = new CColor(126, 152, 63); this.activeCellBorderColor = new CColor(126, 152, 63);
this.activeCellBorderColor2 = new CColor(255, 255, 255, 0.75); this.activeCellBorderColor2 = new CColor(255, 255, 255, 0.75);
...@@ -390,7 +391,8 @@ ...@@ -390,7 +391,8 @@
"updateEditorSelectionInfo" : function (info) {self.handlers.trigger("asc_onEditorSelectionChanged", info);} "updateEditorSelectionInfo" : function (info) {self.handlers.trigger("asc_onEditorSelectionChanged", info);}
}, },
/*settings*/{ /*settings*/{
font: this.defaultFont font: this.defaultFont,
padding: this.defaults.worksheetView.cells.padding
}); });
this.popUpSelector = new asc.PopUpSelector(this.element, /*handlers*/{ this.popUpSelector = new asc.PopUpSelector(this.element, /*handlers*/{
...@@ -2098,6 +2100,10 @@ ...@@ -2098,6 +2100,10 @@
// Проверка для Calibri 11 должно быть this.maxDigitWidth = 7 // Проверка для Calibri 11 должно быть this.maxDigitWidth = 7
if (!this.maxDigitWidth) {throw "Error: can't measure text string";} if (!this.maxDigitWidth) {throw "Error: can't measure text string";}
// Padding рассчитывается исходя из maxDigitWidth (http://social.msdn.microsoft.com/Forums/en-US/9a6a9785-66ad-4b6b-bb9f-74429381bd72/margin-padding-in-cell-excel?forum=os_binaryfile)
this.defaults.worksheetView.cells.padding = Math.max(asc.ceil(this.maxDigitWidth / 4), 2);
this.defaults.worksheetView.cells.paddingPlusBorder = 2 * this.defaults.worksheetView.cells.padding + 1;
}; };
/* /*
......
...@@ -1156,7 +1156,7 @@ ...@@ -1156,7 +1156,7 @@
*/ */
WorksheetView.prototype._charCountToModelColWidth = function (count) { WorksheetView.prototype._charCountToModelColWidth = function (count) {
if (count <= 0) { return 0; } if (count <= 0) { return 0; }
return asc_floor((count * this.maxDigitWidth + 5) / this.maxDigitWidth * 256) / 256; // 5 - Это padding + border return asc_floor((count * this.maxDigitWidth + this.settings.cells.paddingPlusBorder) / this.maxDigitWidth * 256) / 256;
}; };
/** /**
...@@ -1176,7 +1176,7 @@ ...@@ -1176,7 +1176,7 @@
*/ */
WorksheetView.prototype._colWidthToCharCount = function (w) { WorksheetView.prototype._colWidthToCharCount = function (w) {
var px = w * asc_getcvt( 1/*pt*/, 0/*px*/, 96 ); var px = w * asc_getcvt( 1/*pt*/, 0/*px*/, 96 );
return px <= 5 ? 0 : asc_floor( (px - 5) / asc_round(this.maxDigitWidth) * 100 + 0.5 ) / 100; return px <= this.settings.cells.paddingPlusBorder ? 0 : asc_floor( (px - this.settings.cells.paddingPlusBorder) / asc_round(this.maxDigitWidth) * 100 + 0.5 ) / 100;
}; };
/** /**
......
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