Commit 9e2216c4 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

В workbook считаем maxDigitWidth (а не emSize)

ToDo неправильно, что maxDigitWidth постоянно пересчитывается в зависимости от PPIX (переделать)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47458 954022d7-b5bf-4e40-9824-e11837661b57
parent 95d75926
......@@ -85,7 +85,9 @@
this.stringRender = undefined;
this.drawingCtxCharts = undefined;
this.emSize = 0;
// Максимальная ширина числа из 0,1,2...,9, померенная в нормальном шрифте(дефалтовый для книги) в px(целое)
// Ecma-376 Office Open XML Part 1, пункт 18.3.1.13
this.maxDigitWidth = 0;
this.defaultFont = new asc_FP(this.model.getDefaultFont(), this.model.getDefaultSize());
//-----------------------
......@@ -136,7 +138,7 @@
this.stringRender.setDefaultFont(this.defaultFont);
// Мерить нужно только со 100% и один раз для всего документа
this._calcEmSize();
this._calcMaxDigitWidth();
// initialize events controller
this.controller.init(this, this.element, this.canvasOverlay, /*handlers*/{
......@@ -332,7 +334,7 @@
"selectionRangeChanged" : function (val) {self.handlers.trigger("asc_onSelectionRangeChanged", val);},
"getDCForCharts" : function () { return self.drawingCtxCharts; }
});
return new asc_WSV(wsModel, this.buffers, this.stringRender, this.emSize, this.collaborativeEditing, opt);
return new asc_WSV(wsModel, this.buffers, this.stringRender, this.maxDigitWidth, this.collaborativeEditing, opt);
},
_onSelectionNameChanged: function (name) {
......@@ -1417,7 +1419,7 @@
}
},
_calcEmSize: function () {
_calcMaxDigitWidth: function () {
// set default worksheet header font for calculations
this.buffers.main.setFont(this.defaultFont);
// Измеряем в pt
......@@ -1430,11 +1432,11 @@
// Максимальная ширина в Pt
var maxWidthInPt = this.stringRender.getWidestCharWidth();
// Переводим в px и приводим к целому (int), а затем переводим обратно в pt
this.emSize = asc_round(maxWidthInPt * ptConvToPx) * pxConvToPt;
// Проверка для Calibri 11 должно быть asc_round(maxWidthInPt * ptConvToPx) = 7
// Переводим в px и приводим к целому (int)
this.maxDigitWidth = asc_round(maxWidthInPt * ptConvToPx);
// Проверка для Calibri 11 должно быть this.maxDigitWidth = 7
if (!this.emSize) {throw "Error: can't measure text string";}
if (!this.maxDigitWidth) {throw "Error: can't measure text string";}
}
};
......
......@@ -345,16 +345,16 @@
* @param {Worksheet} model Worksheet
* @param {Array} buffers DrawingContext + Overlay
* @param {StringRender} stringRender StringRender
* @param {Number} emSize Размер символа
* @param {Number} maxDigitWidth Максимальный размер цифры
* @param {asc_CCollaborativeEditing} collaborativeEditing
* @param {Object} settings Settings
*
* @constructor
* @memberOf Asc
*/
function WorksheetView(model, buffers, stringRender, emSize, collaborativeEditing, settings) {
function WorksheetView(model, buffers, stringRender, maxDigitWidth, collaborativeEditing, settings) {
if ( !(this instanceof WorksheetView) ) {
return new WorksheetView(model, buffers, stringRender, emSize, collaborativeEditing, settings);
return new WorksheetView(model, buffers, stringRender, maxDigitWidth, collaborativeEditing, settings);
}
this.settings = $.extend(true, {}, this.defaults, settings);
......@@ -387,8 +387,11 @@
this.cache = new Cache();
//---member declaration---
this.emSize = emSize;
this.maxNumWidth = 0;
// Максимальная ширина числа из 0,1,2...,9, померенная в нормальном шрифте(дефалтовый для книги) в px(целое)
// Ecma-376 Office Open XML Part 1, пункт 18.3.1.13
this.maxDigitWidthBase = maxDigitWidth;
this.emSize = this.maxDigitWidthBase * asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIX());
this.maxDigitWidth = 0;
this.defaultColWidth = 0;
this.defaultRowHeight = 0;
this.defaultRowDescender = 0;
......@@ -1128,16 +1131,9 @@
this.height_2px = asc_calcnpt(0, this._getPPIY(), 2/*px*/);
this.height_3px = asc_calcnpt(0, this._getPPIY(), 3/*px*/);
// ToDo разобраться со значениями
// if (this.printMode) {
// Для печати используем алгоритм из спецификации
// Ecma-376 Office Open XML Part 1, пункт 18.3.1.13
// this.maxNumWidth = asc_round( this.emSize * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() ) );
// } else {
// Для отображения нужно более точное значение, иначе будут прыгать строки в ячейках
// http://bugzserver/show_bug.cgi?id=15311
this.maxNumWidth = this.emSize * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() );
// }
// ToDo неправильно, что maxDigitWidth постоянно пересчитывается в зависимости от PPIX (переделать)
this.maxDigitWidth = this.emSize * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() );
gc_dDefaultColWidthCharsAttribute = this._charCountToModelColWidth(gc_dDefaultColWidthChars, true);
this.defaultColWidth = this._modelColWidthToColWidth(gc_dDefaultColWidthCharsAttribute);
this.displayColWidth = this._modelColWidthToColWidth(gc_dDefaultColWidthCharsAttribute, true);
......@@ -1179,7 +1175,7 @@
*/
_charCountToModelColWidth: function (count, displayWidth, noPad) {
if (count <= 0) { return 0; }
var maxw = displayWidth ? asc_round(this.maxNumWidth) : this.maxNumWidth;
var maxw = displayWidth ? asc_round(this.maxDigitWidth) : this.maxDigitWidth;
return asc_floor( ( count * maxw + (!noPad ? 5 : 0) ) / maxw * 256 ) / 256;
},
......@@ -1190,7 +1186,7 @@
* @returns {Number} Ширина столбца в пунктах (pt)
*/
_modelColWidthToColWidth: function (mcw, displayWidth) {
var maxw = displayWidth ? asc_round(this.maxNumWidth) : this.maxNumWidth;
var maxw = displayWidth ? asc_round(this.maxDigitWidth) : this.maxDigitWidth;
var px = asc_floor( (( 256 * mcw + asc_floor(128 / maxw) ) / 256) * maxw );
return px * asc_getcvt( 0/*px*/, 1/*pt*/, this._getPPIX() );
},
......@@ -1202,7 +1198,7 @@
*/
_colWidthToCharCount: function (w) {
var px = w * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() );
return px <= 5 ? 0 : asc_floor( (px - 5) / asc_round(this.maxNumWidth) * 100 + 0.5 ) / 100;
return px <= 5 ? 0 : asc_floor( (px - 5) / asc_round(this.maxDigitWidth) * 100 + 0.5 ) / 100;
},
/**
......@@ -8397,11 +8393,11 @@
fl = t._getCellFlags(c);
if (fl.isMerged) {continue;}
str = c.getValue2();
maxW = ct.metrics.width + t.maxNumWidth;
maxW = ct.metrics.width + t.maxDigitWidth;
while (1) {
tm = t._roundTextMetrics( t.stringRender.measureString(str, fl, maxW) );
if (tm.height <= t.maxRowHeight) {break;}
maxW += t.maxNumWidth;
maxW += t.maxDigitWidth;
}
width = Math.max(width, tm.width);
} else {
......
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