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

Переделал отрисовку линий для редактора таблиц (бордеров, сетки, выделения,...

Переделал отрисовку линий для редактора таблиц (бордеров, сетки, выделения, заголовков, автофильтров, диаграмм)
Добавил это и при печати.

Нужно доделать отрисовку бордеров на стыках (особый случай), отрисовку иконок для автофильтров и отрисовку стилей ячеек


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@50844 954022d7-b5bf-4e40-9824-e11837661b57
parent e14ab1ac
......@@ -4618,8 +4618,7 @@ function DrawingObjects() {
overlayCtx.setStrokeStyle(strokeColor);
overlayCtx.beginPath();
overlayCtx.moveTo(x, y, -0.5, -0.5);
overlayCtx.lineTo(x + w, y, -0.5, -0.5);
overlayCtx.lineHor(x, y - worksheet.height_1px, x + w);
overlayCtx.stroke();
}
// Left
......@@ -4633,8 +4632,7 @@ function DrawingObjects() {
overlayCtx.setStrokeStyle(strokeColor);
overlayCtx.beginPath();
overlayCtx.moveTo(x, y, -0.5, -0.5);
overlayCtx.lineTo(x, y + h, -0.5, -0.5);
overlayCtx.lineVer(x - worksheet.width_1px, y, y + h);
overlayCtx.stroke();
}
......
......@@ -996,40 +996,40 @@ DrawingContext.prototype = {
return this;
},
moveTo: function (x, y, dx, dy) {
moveTo: function (x, y) {
var r = this._calcRect(x, y);
this.ctx.moveTo(r.x + (dx !== undefined ? dx : 0), r.y + (dy !== undefined ? dy : 0));
//console.log("moveTo: (" + r.x + ", " + r.y + ")" + " (" + dx + ", " + dy + ")");
this.ctx.moveTo(r.x, r.y);
return this;
},
lineTo: function (x, y, dx, dy) {
lineTo: function (x, y) {
var r = this._calcRect(x, y);
this.ctx.lineTo(r.x + (dx !== undefined ? dx : 0), r.y + (dy !== undefined ? dy : 0));
//console.log("lineTo: (" + r.x + ", " + r.y + ")" + " (" + dx + ", " + dy + ")");
this.ctx.lineTo(r.x, r.y);
return this;
},
lineDiag : function (x1, y1, x2, y2) {
var isEven = 0 !== this.ctx.lineWidth % 2 ? 0.5 : 0;
var r1 = this._calcRect(x1, y1);
var r2 = this._calcRect(x2, y2);
this.ctx.moveTo(r1.x + 0.5, r1.y + 0.5);
this.ctx.lineTo(r2.x + 0.5, r2.y + 0.5);
this.ctx.moveTo(r1.x + isEven, r1.y + isEven);
this.ctx.lineTo(r2.x + isEven, r2.y + isEven);
return this;
},
lineHor : function (x1, y, x2) {
var isEven = 0 !== this.ctx.lineWidth % 2 ? 0.5 : 0;
var r1 = this._calcRect(x1, y);
var r2 = this._calcRect(x2, y);
this.ctx.moveTo(r1.x, r1.y + 0.5);
this.ctx.lineTo(r2.x, r2.y + 0.5);
this.ctx.moveTo(r1.x, r1.y + isEven);
this.ctx.lineTo(r2.x, r2.y + isEven);
return this;
},
lineVer : function (x, y1, y2) {
var isEven = 0 !== this.ctx.lineWidth % 2 ? 0.5 : 0;
var r1 = this._calcRect(x, y1);
var r2 = this._calcRect(x, y2);
this.ctx.moveTo(r1.x + 0.5, r1.y);
this.ctx.lineTo(r2.x + 0.5, r2.y);
this.ctx.moveTo(r1.x + isEven, r1.y);
this.ctx.lineTo(r2.x + isEven, r2.y);
return this;
},
......@@ -1151,27 +1151,9 @@ DrawingContext.prototype = {
this.dashLine(x3, y3, x1, y1, w_dot, w_dist);
},
rect: function (x, y, w, h, dx, dy) {
rect: function (x, y, w, h) {
var r = this._calcRect(x, y, w, h);
var hasDx = typeof dx !== "undefined";
var hasDy = typeof dy !== "undefined";
if (hasDx || hasDy) {
var x1 = r.x;
var x2 = r.x + r.w;
var y1 = r.y;
var y2 = r.y + r.h;
dx = hasDx ? dx : 0;
dy = hasDy ? dy : 0;
this.ctx.moveTo(x1 + dx, y1 + dy); // move to start point
this.ctx.lineTo(x2, y1 + dy); // top line
this.ctx.lineTo(x2 - dx, y1 + dy); // move to right top point
this.ctx.lineTo(x2 - dx, y2 - dy); // right line
this.ctx.lineTo(x1 + dx, y2 - dy); // bottom line
this.ctx.lineTo(x1 + dx, y1); // left line
this.ctx.lineTo(x1 + dx, y1 + dy); // close shape
} else {
this.ctx.rect(r.x, r.y, r.w, r.h);
}
this.ctx.rect(r.x, r.y, r.w, r.h);
return this;
},
......
......@@ -299,44 +299,35 @@ CPdfPrinter.prototype =
return this;
},
moveTo : function(x, y, dx, dy)
moveTo : function(x, y)
{
if (0 == dx && 0 == dy)
this.DocumentRenderer._m(x * vector_koef, y * vector_koef);
else
{
var _x = this.Transform.TransformPointX(x, y);
var _y = this.Transform.TransformPointY(x, y);
_x += (72 * dx / this.dpiX);
_y += (72 * dy / this.dpiY);
var xSrc = this.InvertTransform.TransformPointX(_x, _y);
var ySrc = this.InvertTransform.TransformPointY(_x, _y);
this.DocumentRenderer._m(xSrc * vector_koef, ySrc * vector_koef);
}
this.DocumentRenderer._m(x * vector_koef, y * vector_koef);
return this;
},
lineTo : function(x, y, dx, dy)
lineTo : function(x, y)
{
if (0 == dx && 0 == dy)
this.DocumentRenderer._l(x * vector_koef, y * vector_koef);
else
{
var _x = this.Transform.TransformPointX(x, y);
var _y = this.Transform.TransformPointY(x, y);
_x += (72 * dx / this.dpiX);
_y += (72 * dy / this.dpiY);
var xSrc = this.InvertTransform.TransformPointX(_x, _y);
var ySrc = this.InvertTransform.TransformPointY(_x, _y);
this.DocumentRenderer._l(xSrc * vector_koef, ySrc * vector_koef);
}
this.DocumentRenderer._l(x * vector_koef, y * vector_koef);
return this;
},
lineDiag : function (x1, y1, x2, y2)
{
this.DocumentRenderer._m(x1 * vector_koef, y1 * vector_koef);
this.DocumentRenderer._l(x2 * vector_koef, y2 * vector_koef);
return this;
},
lineHor : function (x1, y, x2)
{
this.DocumentRenderer._m(x1 * vector_koef, y * vector_koef);
this.DocumentRenderer._l(x2 * vector_koef, y * vector_koef);
return this;
},
lineVer : function (x, y1, y2)
{
this.DocumentRenderer._m(x * vector_koef, y1 * vector_koef);
this.DocumentRenderer._l(x * vector_koef, y2 * vector_koef);
return this;
},
rect : function(x, y, w, h)
{
if (this.bIsSimpleCommands)
......
......@@ -1340,8 +1340,7 @@ asc_CCellCommentator.prototype = {
_this.overlayCtx.ctx.globalAlpha = 0.2;
_this.overlayCtx.beginPath();
_this.overlayCtx.clearRect(x, y, w, h, .5, .5);
_this.overlayCtx.rect(x, y, w, h, .5, .5);
_this.overlayCtx.clearRect(x, y, w, h);
_this.overlayCtx.setFillStyle(_this.commentFillColor);
_this.overlayCtx.fillRect(x, y, w, h);
_this.overlayCtx.ctx.globalAlpha = 1;
......
......@@ -829,23 +829,24 @@ function DependencyGraph(wb) {
var dx = tox - fromx;
var dy = toy - fromy;
var angle = Math.atan2(dy, dx), _a = Math.PI / 18;
// ToDo посмотреть на четкость moveTo, lineTo
context.save()
.setLineWidth(1)
.beginPath()
.moveTo(_cc.pxToPt(fromx), _cc.pxToPt(fromy),-0.5,-0.5)
.lineTo(_cc.pxToPt(tox), _cc.pxToPt(toy),-0.5,-0.5)
.moveTo(_cc.pxToPt(fromx), _cc.pxToPt(fromy))
.lineTo(_cc.pxToPt(tox), _cc.pxToPt(toy));
// .dashLine(_cc.pxToPt(fromx-.5), _cc.pxToPt(fromy-.5), _cc.pxToPt(tox-.5), _cc.pxToPt(toy-.5), 15, 5)
context
.moveTo(
_cc.pxToPt(tox - headlen * Math.cos(angle - _a)),
_cc.pxToPt(toy - headlen * Math.sin(angle - _a)),-0.5,-0.5)
.lineTo(_cc.pxToPt(tox), _cc.pxToPt(toy),-0.5,-0.5)
_cc.pxToPt(toy - headlen * Math.sin(angle - _a)))
.lineTo(_cc.pxToPt(tox), _cc.pxToPt(toy))
.lineTo(
_cc.pxToPt(tox - headlen * Math.cos(angle + _a)),
_cc.pxToPt(toy - headlen * Math.sin(angle + _a)),-0.5,-0.5)
_cc.pxToPt(toy - headlen * Math.sin(angle + _a)))
.lineTo(
_cc.pxToPt(tox - headlen * Math.cos(angle - _a)),
_cc.pxToPt(toy - headlen * Math.sin(angle - _a)),-0.5,-0.5)
_cc.pxToPt(toy - headlen * Math.sin(angle - _a)))
.setStrokeStyle("#0000FF")
.setFillStyle("#0000FF")
.stroke()
......@@ -866,12 +867,13 @@ function DependencyGraph(wb) {
if( x1<0 && x2<0 || y1<0 && y2<0)
continue;
// ToDo посмотреть на четкость rect
if( m2.apl > 0 && m2.apt >0)
ctx.save()
.setLineWidth(1)
.setStrokeStyle("#0000FF")
.rect( _cc.pxToPt(m2.l),_cc.pxToPt(m2.t),_cc.pxToPt(m2.w-1),_cc.pxToPt(m2.h-1), -.5, -.5 )
.rect( _cc.pxToPt(m2.l),_cc.pxToPt(m2.t),_cc.pxToPt(m2.w-1),_cc.pxToPt(m2.h-1) )
.stroke()
.restore();
if(y1<0 && x1 != x2)
......
......@@ -2865,14 +2865,15 @@
var ws = this.worksheet;
var shift = 0.5;
var size = 4*index;
// ToDo переделать
ws.drawingCtx
.beginPath()
.moveTo(x, y, 0, 0)
.lineTo(x,y - size/2, 0, 0)
.lineTo(x - 2.5*index,y - size, 0, 0)
.lineTo(x + 3*index,y - size, 0, 0)
.lineTo(x + shift,y - size/2, 0, 0)
.lineTo(x + shift,y, 0, 0)
.moveTo(x, y)
.lineTo(x,y - size/2)
.lineTo(x - 2.5*index,y - size)
.lineTo(x + 3*index,y - size)
.lineTo(x + shift,y - size/2)
.lineTo(x + shift,y)
.setFillStyle('#787878')
.fill();
},
......@@ -2882,12 +2883,13 @@
var ws = this.worksheet;
var size = 4*index;
var shift = 0.5;
// ToDo переделать
ws.drawingCtx
.beginPath()
.moveTo(x , y , -shift, 0)
.lineTo(x + size,y, -shift,0.5)
.lineTo(x + size/2,y + size/2 + shift,-shift,0)
.lineTo(x , y , -shift, 0)
.moveTo(x , y)
.lineTo(x + size,y)
.lineTo(x + size/2,y + size/2)
.lineTo(x , y)
.setFillStyle('#787878')
.fill();
},
......
......@@ -896,6 +896,7 @@
bw = t.oBorderUtils.calcBorderWidth(b);
if (0 < bw) {
// ToDo поправить
oGraphics.setLineWidth(bw).beginPath().moveTo(x1, y1).lineTo(x2, y2).stroke();
}
}
......@@ -903,14 +904,10 @@
// borders
var oBorders = oStyle.getBorder();
drawBorder(oBorders.l, 0, nOffsetY,
0, nOffsetY + this.styleThumbnailHeightPt);
drawBorder(oBorders.r, this.styleThumbnailWidthPt, nOffsetY,
this.styleThumbnailWidthPt, nOffsetY + this.styleThumbnailHeightPt);
drawBorder(oBorders.t, 0, nOffsetY,
this.styleThumbnailWidthPt, nOffsetY);
drawBorder(oBorders.b, 0, nOffsetY + this.styleThumbnailHeightPt,
this.styleThumbnailWidthPt, nOffsetY + this.styleThumbnailHeightPt);
drawBorder(oBorders.l, 0, nOffsetY, 0, nOffsetY + this.styleThumbnailHeightPt);
drawBorder(oBorders.r, this.styleThumbnailWidthPt, nOffsetY, this.styleThumbnailWidthPt, nOffsetY + this.styleThumbnailHeightPt);
drawBorder(oBorders.t, 0, nOffsetY, this.styleThumbnailWidthPt, nOffsetY);
drawBorder(oBorders.b, 0, nOffsetY + this.styleThumbnailHeightPt, this.styleThumbnailWidthPt, nOffsetY + this.styleThumbnailHeightPt);
// Draw text
var fc = oStyle.getFontColor();
......
......@@ -846,7 +846,7 @@
var ul = prop.font.Underline;
var isSO = so === true;
var isUL = ul === true || !( ul === undefined || ul === false || ul.search(/\w/) < 0 || ul.search(/\s*none\s*/i) >= 0 );
var fsz, x2, y, lw, dy, i, b, x_, cp;
var fsz, x2, y, lw, dy, i, b, x_, cp, w_1px, h_1px;
if (align !== "justify" || dx < 0.000001) {
ctx.fillText(self.chars.slice(begin, end), x1, y1 + l.bl + dh, undefined, self.charWidths.slice(begin, end), angle);
......@@ -872,17 +872,17 @@
ctx.setStrokeStyle(prop.c || textColor)
.setLineWidth(lw)
.beginPath();
w_1px = asc_calcnpt(0, ppix, 1/*px*/);
h_1px = asc_calcnpt(0, ppiy, 1/*px*/);
dy = (lw / 2); dy = dy >> 0;
if (isSO) {
dy += 1;
y = asc_calcnpt(y1 + l.bl - prop.lm.a * 0.275, ppiy);
dy = -lw / 2;
ctx.moveTo(x1, y, 0, dy)
.lineTo(x2, y, 1, dy);
ctx.lineHor(x1, y - dy * h_1px, x2 + w_1px);
}
if (isUL) {
y = asc_calcnpt(y1 + l.bl + prop.lm.d * 0.4, ppiy);
dy = +lw / 2;
ctx.moveTo(x1, y, 0, dy)
.lineTo(x2, y, 1, dy);
ctx.lineHor(x1, y + dy * h_1px, x2 + w_1px);
}
ctx.stroke();
}
......
This diff is collapsed.
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