Commit 5965a15b authored by Alexander.Trofimov's avatar Alexander.Trofimov

add dash border cell styles

parent 4d7d067c
...@@ -776,6 +776,11 @@ ...@@ -776,6 +776,11 @@
return this; return this;
}; };
DrawingContext.prototype.setLineDash = function (segments) {
this.ctx.setLineDash(segments);
return this;
};
DrawingContext.prototype.fillRect = function (x, y, w, h) { DrawingContext.prototype.fillRect = function (x, y, w, h) {
var r = this._calcRect(x, y, w, h); var r = this._calcRect(x, y, w, h);
this.ctx.fillRect(r.x, r.y, r.w, r.h); this.ctx.fillRect(r.x, r.y, r.w, r.h);
......
...@@ -214,6 +214,14 @@ CPdfPrinter.prototype = ...@@ -214,6 +214,14 @@ CPdfPrinter.prototype =
this.DocumentRenderer.p_width(val * 1000 * vector_koef); this.DocumentRenderer.p_width(val * 1000 * vector_koef);
return this; return this;
}, },
setLineDash : function(params)
{
var tmp = [];
for (var i = 0; i < params.length; ++i) {
tmp.push(params[i] * vector_koef);
}
return this.DocumentRenderer.p_dash(tmp);
},
setLineCap : function(cap) setLineCap : function(cap)
{ {
return this; return this;
...@@ -458,7 +466,7 @@ CPdfPrinter.prototype = ...@@ -458,7 +466,7 @@ CPdfPrinter.prototype =
}, },
p_dash : function(params) p_dash : function(params)
{ {
// TODO: return this.DocumentRenderer.p_dash(params);
}, },
// brush methods // brush methods
b_color1 : function(r,g,b,a) b_color1 : function(r,g,b,a)
......
...@@ -856,19 +856,18 @@ Fill.prototype = ...@@ -856,19 +856,18 @@ Fill.prototype =
} }
} }
}; };
var g_oBorderPropProperties = { var g_oBorderPropProperties = {
s: 0, s: 0, c: 1
c: 1
}; };
function BorderProp()
{ function BorderProp() {
this.Properties = g_oBorderPropProperties; this.Properties = g_oBorderPropProperties;
this.s = c_oAscBorderStyles.None; this.s = c_oAscBorderStyles.None;
this.w = c_oAscBorderWidth.None; this.w = c_oAscBorderWidth.None;
this.c = g_oColorManager.getThemeColor(1); this.c = g_oColorManager.getThemeColor(1);
} }
BorderProp.prototype = {
setStyle : function (style) { BorderProp.prototype.setStyle = function (style) {
this.s = style; this.s = style;
switch (this.s) { switch (this.s) {
case c_oAscBorderStyles.Thin: case c_oAscBorderStyles.Thin:
...@@ -894,63 +893,94 @@ BorderProp.prototype = { ...@@ -894,63 +893,94 @@ BorderProp.prototype = {
this.w = c_oAscBorderWidth.None; this.w = c_oAscBorderWidth.None;
break; break;
} }
}, };
getRgbOrNull : function() BorderProp.prototype.getDashSegments = function () {
{ var res;
switch (this.s) {
case c_oAscBorderStyles.Hair:
res = [1, 1];
break;
case c_oAscBorderStyles.Dotted:
res = [2, 2];
break;
case c_oAscBorderStyles.DashDotDot:
case c_oAscBorderStyles.MediumDashDotDot:
res = [3, 3, 3, 3, 9, 3];
break;
case c_oAscBorderStyles.DashDot:
case c_oAscBorderStyles.MediumDashDot:
case c_oAscBorderStyles.SlantDashDot:
res = [3, 3, 9, 3];
break;
case c_oAscBorderStyles.Dashed:
res = [3, 1];
break;
case c_oAscBorderStyles.MediumDashed:
res = [9, 3];
break;
case c_oAscBorderStyles.Thin:
case c_oAscBorderStyles.Medium:
case c_oAscBorderStyles.Thick:
case c_oAscBorderStyles.Double:
default:
res = [];
break;
}
return res;
};
BorderProp.prototype.getRgbOrNull = function () {
var nRes = null; var nRes = null;
if(null != this.c) if (null != this.c) {
nRes = this.c.getRgb(); nRes = this.c.getRgb();
}
return nRes; return nRes;
}, };
isEmpty : function() BorderProp.prototype.isEmpty = function () {
{
return c_oAscBorderStyles.None === this.s; return c_oAscBorderStyles.None === this.s;
}, };
isEqual : function(val) BorderProp.prototype.isEqual = function (val) {
{
return this.s === val.s && g_oColorManager.isEqual(this.c, val.c); return this.s === val.s && g_oColorManager.isEqual(this.c, val.c);
}, };
clone : function() BorderProp.prototype.clone = function () {
{
var res = new BorderProp(); var res = new BorderProp();
res.merge(this); res.merge(this);
return res; return res;
}, };
merge : function(oBorderProp) BorderProp.prototype.merge = function (oBorderProp) {
{ if (null != oBorderProp.s && c_oAscBorderStyles.None !== oBorderProp.s) {
if(null != oBorderProp.s && c_oAscBorderStyles.None !== oBorderProp.s)
{
this.s = oBorderProp.s; this.s = oBorderProp.s;
this.w = oBorderProp.w; this.w = oBorderProp.w;
if(null != oBorderProp.c) if (null != oBorderProp.c) {
this.c = oBorderProp.c; this.c = oBorderProp.c;
}
} }
}, };
getType : function() BorderProp.prototype.getType = function () {
{
return UndoRedoDataTypes.StyleBorderProp; return UndoRedoDataTypes.StyleBorderProp;
}, };
getProperties : function() BorderProp.prototype.getProperties = function () {
{
return this.Properties; return this.Properties;
}, };
getProperty : function(nType) BorderProp.prototype.getProperty = function (nType) {
{ switch (nType) {
switch(nType) case this.Properties.s:
{ return this.s;
case this.Properties.s: return this.s;break; break;
case this.Properties.c: return this.c;break; case this.Properties.c:
return this.c;
break;
} }
}, };
setProperty : function(nType, value) BorderProp.prototype.setProperty = function (nType, value) {
{ switch (nType) {
switch(nType) case this.Properties.s:
{ this.setStyle(value);
case this.Properties.s: this.setStyle(value);break; break;
case this.Properties.c: this.c = value;break; case this.Properties.c:
this.c = value;
break;
} }
} };
};
var g_oBorderProperties = { var g_oBorderProperties = {
l: 0, l: 0,
t: 1, t: 1,
......
...@@ -2933,233 +2933,252 @@ ...@@ -2933,233 +2933,252 @@
} }
}; };
/** Рисует рамки для ячеек */ /** Рисует рамки для ячеек */
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) ? drawingCtx : this.drawingCtx;
var c = this.cols; var c = this.cols;
var r = this.rows; var r = this.rows;
var objectMergedCells = {}; // Двумерный map вида строка-колонка {1: {1: range, 4: range}} var objectMergedCells = {}; // Двумерный map вида строка-колонка {1: {1: range, 4: range}}
var i, mergeCellInfo, startCol, endRow, endCol, col, row; var i, mergeCellInfo, startCol, endRow, endCol, col, row;
for ( i in mergedCells ) { for (i in mergedCells) {
mergeCellInfo = mergedCells[i]; mergeCellInfo = mergedCells[i];
startCol = Math.max( range.c1, mergeCellInfo.c1 ); startCol = Math.max(range.c1, mergeCellInfo.c1);
endRow = Math.min( mergeCellInfo.r2, range.r2, this.nRowsCount ); endRow = Math.min(mergeCellInfo.r2, range.r2, this.nRowsCount);
endCol = Math.min( mergeCellInfo.c2, range.c2, this.nColsCount ); endCol = Math.min(mergeCellInfo.c2, range.c2, this.nColsCount);
for ( row = Math.max( range.r1, mergeCellInfo.r1 ); row <= endRow; ++row ) { for (row = Math.max(range.r1, mergeCellInfo.r1); row <= endRow; ++row) {
if ( !objectMergedCells.hasOwnProperty( row ) ) { if (!objectMergedCells.hasOwnProperty(row)) {
objectMergedCells[row] = {}; objectMergedCells[row] = {};
} }
for ( col = startCol; col <= endCol; ++col ) for (col = startCol; col <= endCol; ++col) {
objectMergedCells[row][col] = mergeCellInfo; objectMergedCells[row][col] = mergeCellInfo;
} }
} }
}
var bc = null, bw = -1, isNotFirst = false; // cached border color
function drawBorder( type, border, x1, y1, x2, y2 ) {
var isStroke = false, isNewColor = !AscCommonExcel.g_oColorManager.isEqual( bc, border.c ), isNewWidth = bw !== border.w;
if ( isNotFirst && (isNewColor || isNewWidth) ) {
ctx.stroke();
isStroke = true;
}
if ( isNewColor ) {
bc = border.c;
ctx.setStrokeStyle( bc );
}
if ( isNewWidth ) {
bw = border.w;
ctx.setLineWidth( border.w );
}
if ( isStroke || false === isNotFirst ) {
isNotFirst = true;
ctx.beginPath();
}
switch ( type ) {
case c_oAscBorderType.Hor:
ctx.lineHor( x1, y1, x2 );
break;
case c_oAscBorderType.Ver:
ctx.lineVer( x1, y1, y2 );
break;
case c_oAscBorderType.Diag:
ctx.lineDiag( x1, y1, x2, y2 );
break;
}
}
function drawVerticalBorder( borderLeftObject, borderRightObject, x, y1, y2 ) { var bc = null, bs = c_oAscBorderStyles.None, isNotFirst = false; // cached border color
var border, borderLeft = borderLeftObject ? borderLeftObject.borders : null, borderRight = borderRightObject ? borderRightObject.borders : null;
if ( borderLeft && borderLeft.r.w ) { function drawBorder(type, border, x1, y1, x2, y2) {
border = borderLeft.r; var isStroke = false, isNewColor = !AscCommonExcel.g_oColorManager.isEqual(bc,
} border.c), isNewStyle = bs !== border.s;
else if ( borderRight && borderRight.l.w ) { if (isNotFirst && (isNewColor || isNewStyle)) {
border = borderRight.l; ctx.stroke();
} isStroke = true;
if ( !border || border.w < 1 ) { }
return;
}
// ToDo переделать рассчет if (isNewColor) {
var tbw = t._calcMaxBorderWidth( borderLeftObject && borderLeftObject.getTopBorder(), borderRightObject && borderRightObject.getTopBorder() ); // top border width bc = border.c;
var bbw = t._calcMaxBorderWidth( borderLeftObject && borderLeftObject.getBottomBorder(), borderRightObject && borderRightObject.getBottomBorder() ); // bottom border width ctx.setStrokeStyle(bc);
var dy1 = tbw > border.w ? tbw - 1 : (tbw > 1 ? -1 : 0); }
var dy2 = bbw > border.w ? -2 : (bbw > 2 ? 1 : 0); if (isNewStyle) {
bs = border.s;
ctx.setLineWidth(border.w);
ctx.setLineDash(border.getDashSegments());
}
drawBorder( c_oAscBorderType.Ver, border, x, y1 + (-1 + dy1) * t.height_1px, x, y2 + (1 + dy2) * t.height_1px ); if (isStroke || false === isNotFirst) {
} isNotFirst = true;
ctx.beginPath();
}
function drawHorizontalBorder( borderTopObject, borderBottomObject, x1, y, x2 ) { switch (type) {
var border, borderTop = borderTopObject ? borderTopObject.borders : null, borderBottom = borderBottomObject ? borderBottomObject.borders : null; case c_oAscBorderType.Hor:
ctx.lineHor(x1, y1, x2);
break;
case c_oAscBorderType.Ver:
ctx.lineVer(x1, y1, y2);
break;
case c_oAscBorderType.Diag:
ctx.lineDiag(x1, y1, x2, y2);
break;
}
}
if ( borderTop && borderTop.b.w ) { function drawVerticalBorder(borderLeftObject, borderRightObject, x, y1, y2) {
border = borderTop.b; var border, borderLeft = borderLeftObject ? borderLeftObject.borders :
} null, borderRight = borderRightObject ? borderRightObject.borders : null;
else if ( borderBottom && borderBottom.t.w ) {
border = borderBottom.t;
}
if ( border && border.w > 0 ) { if (borderLeft && borderLeft.r.w) {
// ToDo переделать рассчет border = borderLeft.r;
var lbw = t._calcMaxBorderWidth( borderTopObject && borderTopObject.getLeftBorder(), borderBottomObject && borderBottomObject.getLeftBorder() ); } else if (borderRight && borderRight.l.w) {
var rbw = t._calcMaxBorderWidth( borderTopObject && borderTopObject.getRightBorder(), borderTopObject && borderTopObject.getRightBorder() ); border = borderRight.l;
var dx1 = border.w > lbw ? (lbw > 1 ? -1 : 0) : (lbw > 2 ? 2 : 1); }
var dx2 = border.w > rbw ? (rbw > 2 ? 1 : 0) : (rbw > 1 ? -2 : -1); if (!border || border.w < 1) {
drawBorder( c_oAscBorderType.Hor, border, x1 + (-1 + dx1) * t.width_1px, y, x2 + (1 + dx2) * t.width_1px, y ); return;
} }
}
var arrPrevRow = [], arrCurrRow = [], arrNextRow = []; // ToDo переделать рассчет
var objMCPrevRow = null, objMCRow = null, objMCNextRow = null; var tbw = t._calcMaxBorderWidth(borderLeftObject && borderLeftObject.getTopBorder(),
var bCur, bPrev, bNext, bTopCur, bTopPrev, bTopNext, bBotCur, bBotPrev, bBotNext; borderRightObject && borderRightObject.getTopBorder()); // top border width
bCur = bPrev = bNext = bTopCur = bTopNext = bBotCur = bBotNext = null; var bbw = t._calcMaxBorderWidth(borderLeftObject && borderLeftObject.getBottomBorder(),
row = range.r1 - 1; borderRightObject && borderRightObject.getBottomBorder()); // bottom border width
var prevCol = range.c1 - 1; var dy1 = tbw > border.w ? tbw - 1 : (tbw > 1 ? -1 : 0);
// Определим первую колонку (т.к. могут быть скрытые колонки) var dy2 = bbw > border.w ? -2 : (bbw > 2 ? 1 : 0);
while ( 0 <= prevCol && c[prevCol].width < t.width_1px )
--prevCol;
// Сначала пройдемся по верхней строке (над отрисовываемым диапазоном) drawBorder(c_oAscBorderType.Ver, border, x, y1 + (-1 + dy1) * t.height_1px, x,
while ( 0 <= row ) { y2 + (1 + dy2) * t.height_1px);
if ( r[row].height >= t.height_1px ) { }
objMCPrevRow = objectMergedCells[row];
for ( col = prevCol; col <= range.c2 && col < t.nColsCount; ++col ) {
if ( 0 > col || c[col].width < t.width_1px ) {
continue;
}
arrPrevRow[col] = new CellBorderObject( t._getVisibleCell( col, row ).getBorder(), objMCPrevRow ? objMCPrevRow[col] : null, col, row );
}
break;
}
--row;
}
var mc = null, nextRow, isFirstRow = true; function drawHorizontalBorder(borderTopObject, borderBottomObject, x1, y, x2) {
var isPrevColExist = (0 <= prevCol); var border, borderTop = borderTopObject ? borderTopObject.borders :
for ( row = range.r1; row <= range.r2 && row < t.nRowsCount; row = nextRow ) { null, borderBottom = borderBottomObject ? borderBottomObject.borders : null;
nextRow = row + 1;
if ( r[row].height < t.height_1px ) {
continue;
}
// Нужно отсеять пустые снизу
for ( ; nextRow <= range.r2 && nextRow < t.nRowsCount; ++nextRow )
if ( r[nextRow].height >= t.height_1px ) {
break;
}
var isFirstRowTmp = isFirstRow, isLastRow = nextRow > range.r2 || nextRow >= t.nRowsCount; if (borderTop && borderTop.b.w) {
isFirstRow = false; // Это уже не первая строка (определяем не по совпадению с range.r1, а по видимости) border = borderTop.b;
} else if (borderBottom && borderBottom.t.w) {
border = borderBottom.t;
}
objMCRow = isFirstRowTmp ? objectMergedCells[row] : objMCNextRow; if (border && border.w > 0) {
objMCNextRow = objectMergedCells[nextRow]; // ToDo переделать рассчет
var lbw = t._calcMaxBorderWidth(borderTopObject && borderTopObject.getLeftBorder(),
borderBottomObject && borderBottomObject.getLeftBorder());
var rbw = t._calcMaxBorderWidth(borderTopObject && borderTopObject.getRightBorder(),
borderTopObject && borderTopObject.getRightBorder());
var dx1 = border.w > lbw ? (lbw > 1 ? -1 : 0) : (lbw > 2 ? 2 : 1);
var dx2 = border.w > rbw ? (rbw > 2 ? 1 : 0) : (rbw > 1 ? -2 : -1);
drawBorder(c_oAscBorderType.Hor, border, x1 + (-1 + dx1) * t.width_1px, y, x2 + (1 + dx2) * t.width_1px,
y);
}
}
var rowCache = t._fetchRowCache( row ); var arrPrevRow = [], arrCurrRow = [], arrNextRow = [];
var y1 = r[row].top - offsetY; var objMCPrevRow = null, objMCRow = null, objMCNextRow = null;
var y2 = y1 + r[row].height - t.height_1px; var bCur, bPrev, bNext, bTopCur, bTopPrev, bTopNext, bBotCur, bBotPrev, bBotNext;
bCur = bPrev = bNext = bTopCur = bTopNext = bBotCur = bBotNext = null;
row = range.r1 - 1;
var prevCol = range.c1 - 1;
// Определим первую колонку (т.к. могут быть скрытые колонки)
while (0 <= prevCol && c[prevCol].width < t.width_1px)
--prevCol;
// Сначала пройдемся по верхней строке (над отрисовываемым диапазоном)
while (0 <= row) {
if (r[row].height >= t.height_1px) {
objMCPrevRow = objectMergedCells[row];
for (col = prevCol; col <= range.c2 && col < t.nColsCount; ++col) {
if (0 > col || c[col].width < t.width_1px) {
continue;
}
arrPrevRow[col] =
new CellBorderObject(t._getVisibleCell(col, row).getBorder(), objMCPrevRow ? objMCPrevRow[col] :
null, col, row);
}
break;
}
--row;
}
var nextCol, isFirstCol = true; var mc = null, nextRow, isFirstRow = true;
for ( col = range.c1; col <= range.c2 && col < t.nColsCount; col = nextCol ) { var isPrevColExist = (0 <= prevCol);
nextCol = col + 1; for (row = range.r1; row <= range.r2 && row < t.nRowsCount; row = nextRow) {
if ( c[col].width < t.width_1px ) { nextRow = row + 1;
continue; if (r[row].height < t.height_1px) {
} continue;
// Нужно отсеять пустые справа }
for ( ; nextCol <= range.c2 && nextCol < t.nColsCount; ++nextCol ) // Нужно отсеять пустые снизу
if ( c[nextCol].width >= t.width_1px ) { for (; nextRow <= range.r2 && nextRow < t.nRowsCount; ++nextRow) {
break; if (r[nextRow].height >= t.height_1px) {
} break;
}
}
var isFirstColTmp = isFirstCol, isLastCol = nextCol > range.c2 || nextCol >= t.nColsCount; var isFirstRowTmp = isFirstRow, isLastRow = nextRow > range.r2 || nextRow >= t.nRowsCount;
isFirstCol = false; // Это уже не первая колонка (определяем не по совпадению с range.c1, а по видимости) isFirstRow = false; // Это уже не первая строка (определяем не по совпадению с range.r1, а по видимости)
mc = objMCRow ? objMCRow[col] : null; objMCRow = isFirstRowTmp ? objectMergedCells[row] : objMCNextRow;
objMCNextRow = objectMergedCells[nextRow];
var x1 = c[col].left - offsetX; var rowCache = t._fetchRowCache(row);
var x2 = x1 + c[col].width - this.width_1px; var y1 = r[row].top - offsetY;
var y2 = y1 + r[row].height - t.height_1px;
if ( row === t.nRowsCount ) { var nextCol, isFirstCol = true;
bBotPrev = bBotCur = bBotNext = null; for (col = range.c1; col <= range.c2 && col < t.nColsCount; col = nextCol) {
} nextCol = col + 1;
else { if (c[col].width < t.width_1px) {
if ( isFirstColTmp ) { continue;
bBotPrev = arrNextRow[prevCol] = new CellBorderObject( isPrevColExist ? t._getVisibleCell( prevCol, nextRow ).getBorder() : null, objMCNextRow ? objMCNextRow[prevCol] : null, prevCol, nextRow ); }
bBotCur = arrNextRow[col] = new CellBorderObject( t._getVisibleCell( col, nextRow ).getBorder(), objMCNextRow ? objMCNextRow[col] : null, col, nextRow ); // Нужно отсеять пустые справа
} for (; nextCol <= range.c2 && nextCol < t.nColsCount; ++nextCol) {
else { if (c[nextCol].width >= t.width_1px) {
bBotPrev = bBotCur; break;
bBotCur = bBotNext; }
} }
}
if ( isFirstColTmp ) { var isFirstColTmp = isFirstCol, isLastCol = nextCol > range.c2 || nextCol >= t.nColsCount;
bPrev = arrCurrRow[prevCol] = new CellBorderObject( isPrevColExist ? t._getVisibleCell( prevCol, row ).getBorder() : null, objMCRow ? objMCRow[prevCol] : null, prevCol, row ); isFirstCol = false; // Это уже не первая колонка (определяем не по совпадению с range.c1, а по видимости)
bCur = arrCurrRow[col] = new CellBorderObject( t._getVisibleCell( col, row ).getBorder(), mc, col, row );
bTopPrev = arrPrevRow[prevCol]; mc = objMCRow ? objMCRow[col] : null;
bTopCur = arrPrevRow[col];
} var x1 = c[col].left - offsetX;
else { var x2 = x1 + c[col].width - this.width_1px;
bPrev = bCur;
bCur = bNext; if (row === t.nRowsCount) {
bTopPrev = bTopCur; bBotPrev = bBotCur = bBotNext = null;
bTopCur = bTopNext; } else {
} if (isFirstColTmp) {
bBotPrev = arrNextRow[prevCol] =
new CellBorderObject(isPrevColExist ? t._getVisibleCell(prevCol, nextRow).getBorder() :
null, objMCNextRow ? objMCNextRow[prevCol] : null, prevCol, nextRow);
bBotCur = arrNextRow[col] =
new CellBorderObject(t._getVisibleCell(col, nextRow).getBorder(), objMCNextRow ?
objMCNextRow[col] : null, col, nextRow);
} else {
bBotPrev = bBotCur;
bBotCur = bBotNext;
}
}
if ( col === t.nColsCount ) { if (isFirstColTmp) {
bNext = null; bPrev = arrCurrRow[prevCol] =
bTopNext = null; new CellBorderObject(isPrevColExist ? t._getVisibleCell(prevCol, row).getBorder() :
} null, objMCRow ? objMCRow[prevCol] : null, prevCol, row);
else { bCur =
bNext = arrCurrRow[nextCol] = new CellBorderObject( t._getVisibleCell( nextCol, row ).getBorder(), objMCRow ? objMCRow[nextCol] : null, nextCol, row ); arrCurrRow[col] = new CellBorderObject(t._getVisibleCell(col, row).getBorder(), mc, col, row);
bTopNext = arrPrevRow[nextCol]; bTopPrev = arrPrevRow[prevCol];
bTopCur = arrPrevRow[col];
} else {
bPrev = bCur;
bCur = bNext;
bTopPrev = bTopCur;
bTopCur = bTopNext;
}
if ( row === t.nRowsCount ) { if (col === t.nColsCount) {
bBotNext = null; bNext = null;
} bTopNext = null;
else { } else {
bBotNext = arrNextRow[nextCol] = new CellBorderObject( t._getVisibleCell( nextCol, nextRow ).getBorder(), objMCNextRow ? objMCNextRow[nextCol] : null, nextCol, nextRow ); bNext = arrCurrRow[nextCol] =
} new CellBorderObject(t._getVisibleCell(nextCol, row).getBorder(), objMCRow ? objMCRow[nextCol] :
} null, nextCol, row);
bTopNext = arrPrevRow[nextCol];
if (row === t.nRowsCount) {
bBotNext = null;
} else {
bBotNext = arrNextRow[nextCol] =
new CellBorderObject(t._getVisibleCell(nextCol, nextRow).getBorder(), objMCNextRow ?
objMCNextRow[nextCol] : null, nextCol, nextRow);
}
}
if ( mc && row !== mc.r1 && row !== mc.r2 && col !== mc.c1 && col !== mc.c2 ) { if (mc && row !== mc.r1 && row !== mc.r2 && col !== mc.c1 && col !== mc.c2) {
continue; continue;
} }
// draw diagonal borders // draw diagonal borders
if ( (bCur.borders.dd || bCur.borders.du) && (!mc || (row === mc.r1 && col === mc.c1)) ) { if ((bCur.borders.dd || bCur.borders.du) && (!mc || (row === mc.r1 && col === mc.c1))) {
var x2Diagonal = x2; var x2Diagonal = x2;
var y2Diagonal = y2; var y2Diagonal = y2;
if ( mc ) { if (mc) {
// Merge cells // Merge cells
x2Diagonal = c[mc.c2].left + c[mc.c2].width - offsetX - t.width_1px; x2Diagonal = c[mc.c2].left + c[mc.c2].width - offsetX - t.width_1px;
y2Diagonal = r[mc.r2].top + r[mc.r2].height - offsetY - t.height_1px; y2Diagonal = r[mc.r2].top + r[mc.r2].height - offsetY - t.height_1px;
} }
// ToDo Clip diagonal borders // ToDo Clip diagonal borders
/*ctx.save() /*ctx.save()
.beginPath() .beginPath()
.rect(x1 + this.width_1px * (lb.w < 1 ? -1 : (lb.w < 3 ? 0 : +1)), .rect(x1 + this.width_1px * (lb.w < 1 ? -1 : (lb.w < 3 ? 0 : +1)),
...@@ -3168,58 +3187,60 @@ ...@@ -3168,58 +3187,60 @@
r[row].height + this.height_1px * ( -1 + (tb.w < 1 ? +1 : (tb.w < 3 ? 0 : -1)) + (bb.w < 1 ? +1 : (bb.w < 2 ? 0 : -1)) )) r[row].height + this.height_1px * ( -1 + (tb.w < 1 ? +1 : (tb.w < 3 ? 0 : -1)) + (bb.w < 1 ? +1 : (bb.w < 2 ? 0 : -1)) ))
.clip(); .clip();
*/ */
if ( bCur.borders.dd ) { if (bCur.borders.dd) {
// draw diagonal line l,t - r,b // draw diagonal line l,t - r,b
drawBorder( c_oAscBorderType.Diag, bCur.borders.d, x1 - t.width_1px, y1 - t.height_1px, x2Diagonal, y2Diagonal ); drawBorder(c_oAscBorderType.Diag, bCur.borders.d, x1 - t.width_1px, y1 - t.height_1px,
} x2Diagonal, y2Diagonal);
if ( bCur.borders.du ) { }
// draw diagonal line l,b - r,t if (bCur.borders.du) {
drawBorder( c_oAscBorderType.Diag, bCur.borders.d, x1 - t.width_1px, y2Diagonal, x2Diagonal, y1 - t.height_1px ); // draw diagonal line l,b - r,t
} drawBorder(c_oAscBorderType.Diag, bCur.borders.d, x1 - t.width_1px, y2Diagonal, x2Diagonal,
// ToDo Clip diagonal borders y1 - t.height_1px);
//ctx.restore(); }
// canvas context has just been restored, so destroy border color cache // ToDo Clip diagonal borders
//bc = undefined; //ctx.restore();
} // canvas context has just been restored, so destroy border color cache
//bc = undefined;
}
// draw left border // draw left border
if ( isFirstColTmp && !t._isLeftBorderErased( col, rowCache ) ) { if (isFirstColTmp && !t._isLeftBorderErased(col, rowCache)) {
drawVerticalBorder( bPrev, bCur, x1 - t.width_1px, y1, y2 ); drawVerticalBorder(bPrev, bCur, x1 - t.width_1px, y1, y2);
// Если мы в печати и печатаем первый столбец, то нужно напечатать бордеры // Если мы в печати и печатаем первый столбец, то нужно напечатать бордеры
// if (lb.w >= 1 && drawingCtx && 0 === col) { // if (lb.w >= 1 && drawingCtx && 0 === col) {
// Иначе они будут не такой ширины // Иначе они будут не такой ширины
// ToDo посмотреть что с этим ? в печати будет обрезка // ToDo посмотреть что с этим ? в печати будет обрезка
// drawVerticalBorder(lb, tb, tbPrev, bb, bbPrev, x1, y1, y2); // drawVerticalBorder(lb, tb, tbPrev, bb, bbPrev, x1, y1, y2);
// } // }
} }
// draw right border // draw right border
if ( (!mc || col === mc.c2) && !t._isRightBorderErased( col, rowCache ) ) { if ((!mc || col === mc.c2) && !t._isRightBorderErased(col, rowCache)) {
drawVerticalBorder( bCur, bNext, x2, y1, y2 ); drawVerticalBorder(bCur, bNext, x2, y1, y2);
} }
// draw top border // draw top border
if ( isFirstRowTmp ) { if (isFirstRowTmp) {
drawHorizontalBorder( bTopCur, bCur, x1, y1 - t.height_1px, x2 ); drawHorizontalBorder(bTopCur, bCur, x1, y1 - t.height_1px, x2);
// Если мы в печати и печатаем первую строку, то нужно напечатать бордеры // Если мы в печати и печатаем первую строку, то нужно напечатать бордеры
// if (tb.w > 0 && drawingCtx && 0 === row) { // if (tb.w > 0 && drawingCtx && 0 === row) {
// ToDo посмотреть что с этим ? в печати будет обрезка // ToDo посмотреть что с этим ? в печати будет обрезка
// drawHorizontalBorder.call(this, tb, lb, lbPrev, rb, rbPrev, x1, y1, x2); // drawHorizontalBorder.call(this, tb, lb, lbPrev, rb, rbPrev, x1, y1, x2);
// } // }
} }
if ( !mc || row === mc.r2 ) { if (!mc || row === mc.r2) {
// draw bottom border // draw bottom border
drawHorizontalBorder( bCur, bBotCur, x1, y2, x2 ); drawHorizontalBorder(bCur, bBotCur, x1, y2, x2);
} }
} }
arrPrevRow = arrCurrRow; arrPrevRow = arrCurrRow;
arrCurrRow = arrNextRow; arrCurrRow = arrNextRow;
arrNextRow = []; arrNextRow = [];
} }
if ( isNotFirst ) { if (isNotFirst) {
ctx.stroke(); ctx.stroke();
} }
}; };
/** Рисует закрепленные области областей */ /** Рисует закрепленные области областей */
WorksheetView.prototype._drawFrozenPane = function ( noCells ) { WorksheetView.prototype._drawFrozenPane = function ( noCells ) {
......
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