Commit fcf44cc0 authored by Alexander.Trofimov's avatar Alexander.Trofimov

refactoring drawing context

parent a96ef04b
...@@ -973,7 +973,7 @@ ...@@ -973,7 +973,7 @@
*/ */
StringRender.prototype._doRender = function(drawingCtx, x, y, maxWidth, textColor) { StringRender.prototype._doRender = function(drawingCtx, x, y, maxWidth, textColor) {
var self = this; var self = this;
var ctx = (undefined !== drawingCtx) ? drawingCtx : this.drawingCtx; var ctx = drawingCtx || this.drawingCtx;
var ppix = ctx.getPPIX(); var ppix = ctx.getPPIX();
var ppiy = ctx.getPPIY(); var ppiy = ctx.getPPIY();
var align = this.flags ? this.flags.textAlign : null; var align = this.flags ? this.flags.textAlign : null;
......
...@@ -2212,7 +2212,7 @@ ...@@ -2212,7 +2212,7 @@
} }
} }
var ctx = (drawingCtx) ? drawingCtx : this.drawingCtx; var ctx = drawingCtx || this.drawingCtx;
var st = this.settings.header.style[style]; var st = this.settings.header.style[style];
var x2 = x + w; var x2 = x + w;
var y2 = y + h; var y2 = y + h;
...@@ -2257,19 +2257,17 @@ ...@@ -2257,19 +2257,17 @@
var bl = y2WithoutBorder - (isColHeader ? this.defaultRowDescender : this.rows[index].descender); var bl = y2WithoutBorder - (isColHeader ? this.defaultRowDescender : this.rows[index].descender);
var textX = this._calcTextHorizPos(x, x2WithoutBorder, tm, tm.width < w ? AscCommon.align_Center : AscCommon.align_Left); var textX = this._calcTextHorizPos(x, x2WithoutBorder, tm, tm.width < w ? AscCommon.align_Center : AscCommon.align_Left);
var textY = this._calcTextVertPos(y, y2WithoutBorder, bl, tm, Asc.c_oAscVAlign.Bottom); var textY = this._calcTextVertPos(y, y2WithoutBorder, bl, tm, Asc.c_oAscVAlign.Bottom);
if (drawingCtx) {
ctx.AddClipRect(x, y, w, h); if (drawingCtx) {
ctx.setFillStyle(st.color) ctx.AddClipRect(x, y, w, h);
.fillText(text, textX, textY + tm.baseline, undefined, sr.charWidths); } else {
ctx.RemoveClipRect(); ctx.save().beginPath().rect(x, y, w, h).clip();
}
ctx.setFillStyle(st.color).fillText(text, textX, textY + tm.baseline, undefined, sr.charWidths);
if (drawingCtx) {
ctx.RemoveClipRect();
} else { } else {
ctx.save() ctx.restore();
.beginPath()
.rect(x, y, w, h)
.clip()
.setFillStyle(st.color)
.fillText(text, textX, textY + tm.baseline, undefined, sr.charWidths)
.restore();
} }
}; };
...@@ -2352,7 +2350,7 @@ ...@@ -2352,7 +2350,7 @@
if ( range === undefined ) { if ( range === undefined ) {
range = this.visibleRange; range = this.visibleRange;
} }
var ctx = (drawingCtx) ? drawingCtx : this.drawingCtx; var ctx = drawingCtx || this.drawingCtx;
var c = this.cols; var c = this.cols;
var r = this.rows; var r = this.rows;
var widthCtx = (width) ? width : ctx.getWidth(); var widthCtx = (width) ? width : ctx.getWidth();
...@@ -2437,8 +2435,8 @@ ...@@ -2437,8 +2435,8 @@
/** Рисует спарклайны */ /** Рисует спарклайны */
WorksheetView.prototype._drawSparklines = function(drawingCtx, range, offsetX, offsetY) { WorksheetView.prototype._drawSparklines = function(drawingCtx, range, offsetX, offsetY) {
var ctx = (undefined === drawingCtx) ? this.drawingCtx : drawingCtx; this.objectRender.drawSparkLineGroups(drawingCtx || this.drawingCtx, this.model.aSparklineGroups, range,
this.objectRender.drawSparkLineGroups(ctx, this.model.aSparklineGroups, range, offsetX, offsetY); offsetX, offsetY);
}; };
/** Рисует ячейки таблицы */ /** Рисует ячейки таблицы */
...@@ -2470,7 +2468,7 @@ ...@@ -2470,7 +2468,7 @@
return mergedCells; return mergedCells;
} }
var ctx = (undefined === drawingCtx) ? this.drawingCtx : drawingCtx; var ctx = drawingCtx || this.drawingCtx;
for ( var col = colStart; col <= colEnd; ++col ) { for ( var col = colStart; col <= colEnd; ++col ) {
if ( this.cols[col].width < this.width_1px && null === oMergedCell ) { if ( this.cols[col].width < this.width_1px && null === oMergedCell ) {
continue; continue;
...@@ -2581,7 +2579,7 @@ ...@@ -2581,7 +2579,7 @@
} }
var isMerged = ct.flags.isMerged(), range = undefined, isWrapped = ct.flags.wrapText; var isMerged = ct.flags.isMerged(), range = undefined, isWrapped = ct.flags.wrapText;
var ctx = (undefined === drawingCtx) ? this.drawingCtx : drawingCtx; var ctx = drawingCtx || this.drawingCtx;
if ( isMerged ) { if ( isMerged ) {
range = ct.flags.merged; range = ct.flags.merged;
...@@ -2889,7 +2887,7 @@ ...@@ -2889,7 +2887,7 @@
return; return;
} }
var nextCell = -1; var nextCell = -1;
var ctx = (drawingCtx) ? drawingCtx : this.drawingCtx; var ctx = drawingCtx || this.drawingCtx;
ctx.setFillStyle( this.settings.cells.defaultState.background ); ctx.setFillStyle( this.settings.cells.defaultState.background );
for ( var col = colBeg; col < colEnd; ++col ) { for ( var col = colBeg; col < colEnd; ++col ) {
var c = -1 !== nextCell ? nextCell : this._getCell( col, row ); var c = -1 !== nextCell ? nextCell : this._getCell( col, row );
...@@ -2912,7 +2910,7 @@ ...@@ -2912,7 +2910,7 @@
WorksheetView.prototype._drawCellsBorders = function (drawingCtx, range, offsetX, offsetY, mergedCells) { WorksheetView.prototype._drawCellsBorders = function (drawingCtx, range, offsetX, offsetY, mergedCells) {
//TODO: использовать стили линий при рисовании границ //TODO: использовать стили линий при рисовании границ
var t = this; var t = this;
var ctx = (drawingCtx) ? drawingCtx : this.drawingCtx; var ctx = drawingCtx || this.drawingCtx;
var c = this.cols; var c = this.cols;
var r = this.rows; var r = this.rows;
...@@ -3261,7 +3259,7 @@ ...@@ -3261,7 +3259,7 @@
/** Рисует закрепление областей */ /** Рисует закрепление областей */
WorksheetView.prototype._drawFrozenPaneLines = function (drawingCtx) { WorksheetView.prototype._drawFrozenPaneLines = function (drawingCtx) {
// Возможно стоит отрисовывать на overlay, а не на основной канве // Возможно стоит отрисовывать на overlay, а не на основной канве
var ctx = drawingCtx ? drawingCtx : this.drawingCtx; var ctx = drawingCtx || this.drawingCtx;
var lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Object, null, this.model.getId(), var lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Object, null, this.model.getId(),
AscCommonExcel.c_oAscLockNameFrozenPane); AscCommonExcel.c_oAscLockNameFrozenPane);
var isLocked = this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther, false); var isLocked = this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther, false);
...@@ -5128,7 +5126,7 @@ ...@@ -5128,7 +5126,7 @@
}; };
WorksheetView.prototype._setFont = function (drawingCtx, name, size) { WorksheetView.prototype._setFont = function (drawingCtx, name, size) {
var ctx = (drawingCtx) ? drawingCtx : this.drawingCtx; var ctx = drawingCtx || this.drawingCtx;
ctx.setFont(new asc.FontProperties(name, size)); ctx.setFont(new asc.FontProperties(name, size));
}; };
......
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