Commit 1c1a75fe authored by Alexander.Trofimov's avatar Alexander.Trofimov

new calculate pages for print (speed)

parent 63bcb19b
...@@ -932,33 +932,32 @@ var g_oBorderProperties = { ...@@ -932,33 +932,32 @@ var g_oBorderProperties = {
dd: 7, dd: 7,
du: 8 du: 8
}; };
/** @constructor */
function Border(val) /** @constructor */
{ function Border(val) {
if(null == val) if (null == val) {
val = g_oDefaultFormat.BorderAbs; val = g_oDefaultFormat.BorderAbs;
this.Properties = g_oBorderProperties; }
this.l = val.l.clone(); this.Properties = g_oBorderProperties;
this.t = val.t.clone(); this.l = val.l.clone();
this.r = val.r.clone(); this.t = val.t.clone();
this.b = val.b.clone(); this.r = val.r.clone();
this.d = val.d.clone(); this.b = val.b.clone();
this.ih = val.ih.clone(); this.d = val.d.clone();
this.iv = val.iv.clone(); this.ih = val.ih.clone();
this.dd = val.dd; this.iv = val.iv.clone();
this.du = val.du; this.dd = val.dd;
} this.du = val.du;
Border.prototype = }
{
_mergeProperty : function(first, second, def) Border.prototype._mergeProperty = function (first, second, def) {
{ if ((null != def.isEqual && false == def.isEqual(first)) || (null == def.isEqual && def != first)) {
if((null != def.isEqual && false == def.isEqual(first)) || (null == def.isEqual && def != first))
return first; return first;
else } else {
return second; return second;
}, }
merge : function(border) };
{ Border.prototype.merge = function (border) {
var defaultBorder = g_oDefaultFormat.Border; var defaultBorder = g_oDefaultFormat.Border;
var oRes = new Border(); var oRes = new Border();
oRes.l = this._mergeProperty(this.l, border.l, defaultBorder.l).clone(); oRes.l = this._mergeProperty(this.l, border.l, defaultBorder.l).clone();
...@@ -971,60 +970,67 @@ Border.prototype = ...@@ -971,60 +970,67 @@ Border.prototype =
oRes.dd = this._mergeProperty(this.dd, border.dd, defaultBorder.dd); oRes.dd = this._mergeProperty(this.dd, border.dd, defaultBorder.dd);
oRes.du = this._mergeProperty(this.du, border.du, defaultBorder.du); oRes.du = this._mergeProperty(this.du, border.du, defaultBorder.du);
return oRes; return oRes;
}, };
getDif : function(val) Border.prototype.getDif = function (val) {
{
var oRes = new Border(this); var oRes = new Border(this);
var bEmpty = true; var bEmpty = true;
if(true == this.l.isEqual(val.l)) if (true == this.l.isEqual(val.l)) {
oRes.l = null; oRes.l = null;
else } else {
bEmpty = false; bEmpty = false;
if(true == this.t.isEqual(val.t)) }
oRes.t = null; if (true == this.t.isEqual(val.t)) {
else oRes.t = null;
} else {
bEmpty = false; bEmpty = false;
if(true == this.r.isEqual(val.r)) }
oRes.r = null; if (true == this.r.isEqual(val.r)) {
else oRes.r = null;
} else {
bEmpty = false; bEmpty = false;
if(true == this.b.isEqual(val.b)) }
oRes.b = null; if (true == this.b.isEqual(val.b)) {
else oRes.b = null;
} else {
bEmpty = false; bEmpty = false;
if(true == this.d.isEqual(val.d)) }
oRes.d = null; if (true == this.d.isEqual(val.d)) {
if(true == this.ih.isEqual(val.ih)) oRes.d = null;
oRes.ih = null; }
else if (true == this.ih.isEqual(val.ih)) {
oRes.ih = null;
} else {
bEmpty = false; bEmpty = false;
if(true == this.iv.isEqual(val.iv)) }
oRes.iv = null; if (true == this.iv.isEqual(val.iv)) {
else oRes.iv = null;
} else {
bEmpty = false; bEmpty = false;
if(this.dd == val.dd) }
oRes.dd = null; if (this.dd == val.dd) {
else oRes.dd = null;
} else {
bEmpty = false; bEmpty = false;
if(this.du == val.du) }
oRes.du = null; if (this.du == val.du) {
else oRes.du = null;
} else {
bEmpty = false; bEmpty = false;
if(bEmpty) }
if (bEmpty) {
oRes = null; oRes = null;
}
return oRes; return oRes;
}, };
isEqual : function(val) Border.prototype.isEqual = function (val) {
{ return this.l.isEqual(val.l) && this.t.isEqual(val.t) && this.r.isEqual(val.r) && this.b.isEqual(val.b) &&
return this.l.isEqual(val.l) && this.t.isEqual(val.t) && this.r.isEqual(val.r) && this.b.isEqual(val.b) && this.d.isEqual(val.d) && this.d.isEqual(val.d) && this.ih.isEqual(val.ih) && this.iv.isEqual(val.iv) && this.dd == val.dd &&
this.ih.isEqual(val.ih) && this.iv.isEqual(val.iv) && this.dd == val.dd && this.du == val.du; this.du == val.du;
}, };
clone : function() Border.prototype.clone = function () {
{ return new Border(this);
return new Border(this); };
}, Border.prototype.clean = function () {
clean : function()
{
var defaultBorder = g_oDefaultFormat.Border; var defaultBorder = g_oDefaultFormat.Border;
this.l = defaultBorder.l.clone(); this.l = defaultBorder.l.clone();
this.t = defaultBorder.t.clone(); this.t = defaultBorder.t.clone();
...@@ -1035,68 +1041,111 @@ Border.prototype = ...@@ -1035,68 +1041,111 @@ Border.prototype =
this.iv = defaultBorder.iv.clone(); this.iv = defaultBorder.iv.clone();
this.dd = defaultBorder.dd; this.dd = defaultBorder.dd;
this.du = defaultBorder.du; this.du = defaultBorder.du;
}, };
mergeInner : function(border){ Border.prototype.mergeInner = function (border) {
if(border){ if (border) {
if(border.l) if (border.l) {
this.l.merge(border.l); this.l.merge(border.l);
if(border.t) }
this.t.merge(border.t); if (border.t) {
if(border.r) this.t.merge(border.t);
this.r.merge(border.r); }
if(border.b) if (border.r) {
this.b.merge(border.b); this.r.merge(border.r);
if(border.d) }
this.d.merge(border.d); if (border.b) {
if(border.ih) this.b.merge(border.b);
}
if (border.d) {
this.d.merge(border.d);
}
if (border.ih) {
this.ih.merge(border.ih); this.ih.merge(border.ih);
if(border.iv) }
this.iv.merge(border.iv); if (border.iv) {
if(null != border.dd) this.iv.merge(border.iv);
this.dd = this.dd || border.dd; }
if(null != border.du) if (null != border.dd) {
this.du = this.du || border.du; this.dd = this.dd || border.dd;
} }
}, if (null != border.du) {
getType : function() this.du = this.du || border.du;
{ }
}
};
Border.prototype.getType = function () {
return UndoRedoDataTypes.StyleBorder; return UndoRedoDataTypes.StyleBorder;
}, };
getProperties : function() Border.prototype.getProperties = function () {
{
return this.Properties; return this.Properties;
}, };
getProperty : function(nType) Border.prototype.getProperty = function (nType) {
{ switch (nType) {
switch(nType) case this.Properties.l:
{ return this.l;
case this.Properties.l: return this.l;break; break;
case this.Properties.t: return this.t;break; case this.Properties.t:
case this.Properties.r: return this.r;break; return this.t;
case this.Properties.b: return this.b;break; break;
case this.Properties.d: return this.d;break; case this.Properties.r:
case this.Properties.ih: return this.ih;break; return this.r;
case this.Properties.iv: return this.iv;break; break;
case this.Properties.dd: return this.dd;break; case this.Properties.b:
case this.Properties.du: return this.du;break; return this.b;
break;
case this.Properties.d:
return this.d;
break;
case this.Properties.ih:
return this.ih;
break;
case this.Properties.iv:
return this.iv;
break;
case this.Properties.dd:
return this.dd;
break;
case this.Properties.du:
return this.du;
break;
} }
}, };
setProperty : function(nType, value) Border.prototype.setProperty = function (nType, value) {
{ switch (nType) {
switch(nType) case this.Properties.l:
{ this.l = value;
case this.Properties.l: this.l = value;break; break;
case this.Properties.t: this.t = value;break; case this.Properties.t:
case this.Properties.r: this.r = value;break; this.t = value;
case this.Properties.b: this.b = value;break; break;
case this.Properties.d: this.d = value;break; case this.Properties.r:
case this.Properties.ih: this.ih = value;break; this.r = value;
case this.Properties.iv: this.iv = value;break; break;
case this.Properties.dd: this.dd = value;break; case this.Properties.b:
case this.Properties.du: this.du = value;break; this.b = value;
break;
case this.Properties.d:
this.d = value;
break;
case this.Properties.ih:
this.ih = value;
break;
case this.Properties.iv:
this.iv = value;
break;
case this.Properties.dd:
this.dd = value;
break;
case this.Properties.du:
this.du = value;
break;
} }
} };
}; Border.prototype.notEmpty = function () {
return (this.l && c_oAscBorderStyles.None !== this.l.s) || (this.r && c_oAscBorderStyles.None !== this.r.s) ||
(this.t && c_oAscBorderStyles.None !== this.t.s) || (this.b && c_oAscBorderStyles.None !== this.b.s) ||
(this.dd && c_oAscBorderStyles.None !== this.dd.s) || (this.du && c_oAscBorderStyles.None !== this.du.s);
};
var g_oNumProperties = { var g_oNumProperties = {
f: 0 f: 0
}; };
......
...@@ -1297,9 +1297,9 @@ ...@@ -1297,9 +1297,9 @@
* @param {Number} mcw Количество символов * @param {Number} mcw Количество символов
* @returns {Number} Ширина столбца в пунктах (pt) * @returns {Number} Ширина столбца в пунктах (pt)
*/ */
WorksheetView.prototype._modelColWidthToColWidth = function ( mcw ) { WorksheetView.prototype._modelColWidthToColWidth = function (mcw) {
var px = asc_floor( ((256 * mcw + asc_floor( 128 / this.maxDigitWidth )) / 256) * this.maxDigitWidth ); var px = asc_floor(((256 * mcw + asc_floor(128 / this.maxDigitWidth)) / 256) * this.maxDigitWidth);
return px * asc_getcvt( 0/*px*/, 1/*pt*/, 96 ); return px * asc_getcvt(0/*px*/, 1/*pt*/, 96);
}; };
/** /**
...@@ -1319,14 +1319,15 @@ ...@@ -1319,14 +1319,15 @@
* @param {Number} w Ширина столбца в символах * @param {Number} w Ширина столбца в символах
* @returns {Number} Ширина столбца в пунктах (pt) * @returns {Number} Ширина столбца в пунктах (pt)
*/ */
WorksheetView.prototype._calcColWidth = function ( w ) { WorksheetView.prototype._calcColWidth = function (w) {
var t = this; var t = this;
var res = {}; var res = {};
var useDefault = w === undefined || w === null || w === -1; var useDefault = w === undefined || w === null || w === -1;
var width; var width;
res.width = useDefault ? t.defaultColWidth : (width = t._modelColWidthToColWidth( w ), (width < t.width_1px ? 0 : width)); res.width =
res.innerWidth = Math.max( res.width - this.width_padding * 2 - this.width_1px, 0 ); useDefault ? t.defaultColWidth : (width = t._modelColWidthToColWidth(w), (width < t.width_1px ? 0 : width));
res.charCount = t._colWidthToCharCount( res.width ); res.innerWidth = Math.max(res.width - this.width_padding * 2 - this.width_1px, 0);
res.charCount = t._colWidthToCharCount(res.width);
return res; return res;
}; };
...@@ -1654,19 +1655,41 @@ ...@@ -1654,19 +1655,41 @@
if (null === selectionRange) { if (null === selectionRange) {
range = new asc_Range(0, 0, maxCols, maxRows); range = new asc_Range(0, 0, maxCols, maxRows);
this._prepareCellTextMetricsCache(range); this._prepareCellTextMetricsCache(range);
for (var c = 0; c < maxCols; ++c) {
for (var r = 0; r < maxRows; ++r) { var rowModel, rowCells, rowCache, rightSide, c;
if (!this._isCellEmptyOrMergedOrBackgroundColorOrBorders(c, r)) { for (var r = 0; r <= maxRows; ++r) {
var rightSide = 0; if (this.height_1px > this.rows[r].height) {
continue;
}
// Теперь получаем только не пустые ячейки для строки
rowModel = this.model._getRowNoEmpty(r);
if (null === rowModel) {
continue;
}
rowCache = this._getRowCache(r);
rowCells = rowModel.getCells();
for (c in rowCells) {
c = c - 0;
if (this.width_1px > this.cols[c].width) {
continue;
}
var style = rowCells[c].getStyle();
if (style && (null !== style.fill || (null !== style.border && style.border.notEmpty()))) {
lastC = Math.max(lastC, c);
lastR = Math.max(lastR, r);
}
if (rowCache && rowCache.columnsWithText[c]) {
rightSide = 0;
var ct = this._getCellTextCache(c, r); var ct = this._getCellTextCache(c, r);
if (ct !== undefined) { if (ct !== undefined) {
if (!ct.flags.isMerged() && !ct.flags.wrapText) { if (!ct.flags.isMerged() && !ct.flags.wrapText) {
rightSide = ct.sideR; rightSide = ct.sideR;
} }
}
lastC = Math.max(lastC, c + rightSide); lastC = Math.max(lastC, c + rightSide);
lastR = Math.max(lastR, r); lastR = Math.max(lastR, r);
}
} }
} }
} }
......
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