Commit ae87bc88 authored by Oleg.Korshul's avatar Oleg.Korshul

печать шейпов

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@49021 954022d7-b5bf-4e40-9824-e11837661b57
parent 3c7b8506
......@@ -3128,7 +3128,7 @@ function DrawingObjects() {
// Shape render
if ( obj.isGraphicObject() ) {
obj.graphicObject.draw( printOptions ? printOptions.ctx : shapeCtx);
obj.graphicObject.draw( printOptions ? printOptions.ctx.DocumentRenderer : shapeCtx);
continue;
}
}
......
......@@ -6,136 +6,6 @@
this.h = 0;
}
//TODO: Такой код уже есть. Убрать переопределение кода.
function CMatrix()
{
this.sx = 1.0;
this.shx = 0.0;
this.shy = 0.0;
this.sy = 1.0;
this.tx = 0.0;
this.ty = 0.0;
this.Reset = function(){
this.sx = 1.0;
this.shx = 0.0;
this.shy = 0.0;
this.sy = 1.0;
this.tx = 0.0;
this.ty = 0.0;
}
this.Multiply = function(matrix,order){
if (MATRIX_ORDER_PREPEND == order)
{
var m = new CMatrix();
m.sx = matrix.sx;
m.shx = matrix.shx;
m.shy = matrix.shy;
m.sy = matrix.sy;
m.tx = matrix.tx;
m.ty = matrix.ty;
m.Multiply(this,MATRIX_ORDER_APPEND);
this.sx = m.sx;
this.shx = m.shx;
this.shy = m.shy;
this.sy = m.sy;
this.tx = m.tx;
this.ty = m.ty;
}
else
{
var t0 = this.sx * matrix.sx + this.shy * matrix.shx;
var t2 = this.shx * matrix.sx + this.sy * matrix.shx;
var t4 = this.tx * matrix.sx + this.ty * matrix.shx + matrix.tx;
this.shy = this.sx * matrix.shy + this.shy * matrix.sy;
this.sy = this.shx * matrix.shy + this.sy * matrix.sy;
this.ty = this.tx * matrix.shy + this.ty * matrix.sy + matrix.ty;
this.sx = t0;
this.shx = t2;
this.tx = t4;
}
}
this.Translate = function(x,y,order){
var m = new CMatrix();
m.tx = x;
m.ty = y;
this.Multiply(m,order);
}
this.Scale = function(x,y,order){
var m = new CMatrix();
m.sx = x;
m.sy = y;
this.Multiply(m,order);
}
this.Rotate = function(a,order){
var m = new CMatrix();
var rad = deg2rad(a);
m.sx = Math.cos(rad);
m.shx = Math.sin(rad);
m.shy = -Math.sin(rad);
m.sy = Math.cos(rad);
this.Multiply(m,order);
}
this.RotateAt = function(a,x,y,order){
this.Translate(-x,-y,order);
this.Rotate(a,order);
this.Translate(x,y,order);
}
// determinant
this.Determinant = function(){
return this.sx * this.sy - this.shy * this.shx;
}
// invert
this.Invert = function(){
var det = this.Determinant();
if (0.0001 > Math.abs(det))
return;
var d = 1 / det;
var t0 = this.sy * d;
this.sy = this.sx * d;
this.shy = -this.shy * d;
this.shx = -this.shx * d;
var t4 = -this.tx * t0 - this.ty * this.shx;
this.ty = -this.tx * this.shy - this.ty * this.sy;
this.sx = t0;
this.tx = t4;
}
// transform point
this.TransformPointX = function(x,y){
return x * this.sx + y * this.shx + this.tx;
}
this.TransformPointY = function(x,y){
return x * this.shy + y * this.sy + this.ty;
}
// calculate rotate angle
this.GetRotation = function(){
var x1 = 0.0;
var y1 = 0.0;
var x2 = 1.0;
var y2 = 0.0;
this.TransformPoint(x1, y1);
this.TransformPoint(x2, y2);
var a = Math.atan2(y2-y1,x2-x1);
return rad2deg(a);
}
this.CreateDublicate = function(){
var m = new CMatrix();
m.sx = this.sx;
m.shx = this.shx;
m.shy = this.shy;
m.sy = this.sy;
m.tx = this.tx;
m.ty = this.ty;
return m;
}
}
//TODO: Такой код уже есть. Убрать переопределение кода.
function Common_CopyObj(Obj)
{
......@@ -166,106 +36,11 @@ function Common_CopyObj(Obj)
var vector_koef = 25.4 / 72;
function CClipManager()
{
this.clipRects = [];
this.curRect = new _rect();
this.BaseObject = null;
this.AddRect = function(x, y, w, h)
{
var _count = this.clipRects.length;
if (0 == _count)
{
this.curRect.x = x;
this.curRect.y = y;
this.curRect.w = w;
this.curRect.h = h;
var _r = new _rect();
_r.x = x;
_r.y = y;
_r.w = w;
_r.h = h;
this.clipRects[_count] = _r;
this.BaseObject.SetClip(this.curRect);
}
else
{
this.BaseObject.RemoveClip();
var _r = new _rect();
_r.x = x;
_r.y = y;
_r.w = w;
_r.h = h;
this.clipRects[_count] = _r;
this.curRect = this.IntersectRect(this.curRect, _r);
this.BaseObject.SetClip(this.curRect);
}
}
this.RemoveRect = function()
{
var _count = this.clipRects.length;
if (0 != _count)
{
this.clipRects.splice(_count - 1, 1);
--_count;
this.BaseObject.RemoveClip();
if (0 != _count)
{
this.curRect.x = this.clipRects[0].x;
this.curRect.y = this.clipRects[0].y;
this.curRect.w = this.clipRects[0].w;
this.curRect.h = this.clipRects[0].h;
for (var i = 1; i < _count; i++)
this.curRect = this.IntersectRect(this.curRect, this.clipRects[i]);
this.BaseObject.SetClip(this.curRect);
}
}
}
this.IntersectRect = function(r1, r2)
{
var res = new _rect();
res.x = Math.max(r1.x, r2.x);
res.y = Math.max(r1.y, r2.y);
res.w = Math.min(r1.x + r1.w, r2.x + r2.w) - res.x;
res.h = Math.min(r1.y + r1.h, r2.y + r2.h) - res.y;
if (0 > res.w)
res.w = 0;
if (0 > res.h)
res.h = 0;
return res;
}
}
//TODO: Такой код уже есть. Убрать переопределение кода.
function CPen()
{
this.Color = { R : 255, G : 255, B : 255, A : 255 };
this.Style = 0;
this.LineCap = 0;
this.LineJoin = 0;
}
//TODO: Такой код уже есть. Убрать переопределение кода.
function CBrush()
{
this.Color1 = { R : 255, G : 255, B : 255, A : 255 };
this.Color2 = { R : 255, G : 255, B : 255, A : 255 };
this.Type = 0;
}
function CPdfPrinter(sUrlPath)
{
this.DocumentRenderer = new CDocumentRenderer();
this.DocumentRenderer.VectorMemoryForPrint = new CMemory();
this.font = new window["Asc"].FontProperties("Arial", 11);
this.asc_round = window["Asc"].round;
this.Transform = new CMatrix();
......@@ -281,107 +56,98 @@ function CPdfPrinter(sUrlPath)
this.dpiY = this.asc_round(ppiTest[0].offsetHeight * 0.1);
ppiTest.remove();
this.BeginPage = function(width,height)
this.bIsSimpleCommands = false;
this.parseColor = window["Asc"].parseColor;
}
CPdfPrinter.prototype =
{
BeginPage : function(width,height)
{
this.DocumentRenderer.BeginPage(width,height);
}
this.EndPage = function()
},
EndPage : function()
{
this.DocumentRenderer.EndPage();
}
},
this.getWidth = function(units)
getWidth : function(units)
{
console.log("error");
return 0;
}
this.getHeight = function(units)
},
getHeight : function(units)
{
console.log("error");
return 0;
}
},
this.getCanvas = function()
getCanvas : function()
{
console.log("error");
return null;
}
this.getPPIX = function()
},
getPPIX : function()
{
return 72.0;
}
this.getPPIY = function()
},
getPPIY : function()
{
return 72.0;
}
},
this.getUnits = function()
getUnits : function()
{
return 3;
}
},
this.changeUnits = function()
changeUnits : function()
{
return this;
}
},
this.getZoom = function()
getZoom : function()
{
console.log("error");
return 1;
}
this.changeZoom = function()
{
console.log("error");
return this;
}
this.resetSize = function()
},
changeZoom : function()
{
console.log("error");
return this;
}
},
this.expand = function(width, heigth)
resetSize : function()
{
console.log("error");
return this;
}
},
this.clear = function()
expand : function(width, heigth)
{
console.log("error");
return this;
}
},
this.save = function()
{
console.log("error");
return this;
}
this.restore = function()
clear : function()
{
console.log("error");
return this;
}
},
this.scale = function()
{
console.log("error");
return this;
}
this.translate = function()
scale : function()
{
console.log("error");
return this;
}
this.transform = function()
},
translate : function()
{
console.log("error");
return this;
}
},
this.setTransform = function(sx, shy, shx, sy, tx, ty)
setTransform : function(sx, shy, shx, sy, tx, ty)
{
this.Transform.sx = sx;
this.Transform.shy = shy;
......@@ -395,116 +161,116 @@ function CPdfPrinter(sUrlPath)
this.DocumentRenderer.transform(sx, shy, shx, sy, tx, ty);
return this;
}
},
this.getFillStyle = function()
getFillStyle : function()
{
return "#000000";
}
this.getStrokeStyle = function()
},
getStrokeStyle : function()
{
return "#000000";
}
this.getLineWidth = function()
},
getLineWidth : function()
{
return 1;
}
},
this.getLineCap = function()
getLineCap : function()
{
return "butt";
}
},
this.getLineJoin = function()
getLineJoin : function()
{
return "miter";
}
},
this.setFillStyle = function(val)
setFillStyle : function(val)
{
var c = this.parseColor(val);
this.DocumentRenderer.b_color1(c.r, c.g, c.b, (c.a * 255 + 0.5) >> 0);
return this;
}
this.setFillPattern = function(val)
},
setFillPattern : function(val)
{
return this;
}
this.setStrokeStyle = function(val)
},
setStrokeStyle : function(val)
{
var c = this.parseColor(val);
this.DocumentRenderer.p_color(c.r, c.g, c.b, (c.a * 255 + 0.5) >> 0);
return this;
}
this.setLineWidth = function(val)
},
setLineWidth : function(val)
{
this.DocumentRenderer.p_width(val * 1000 * vector_koef);
return this;
}
this.setLineCap = function(cap)
},
setLineCap : function(cap)
{
return this;
}
this.setLineJoin = function(join)
},
setLineJoin : function(join)
{
return this;
}
},
this.fillRect = function(x, y, w, h)
fillRect : function(x, y, w, h)
{
this.DocumentRenderer.rect(x * vector_koef, y * vector_koef, w * vector_koef, h * vector_koef);
this.DocumentRenderer.df();
return this;
}
},
this.strokeRect = function(x, y, w, h)
strokeRect : function(x, y, w, h)
{
this.DocumentRenderer.rect(x * vector_koef, y * vector_koef, w * vector_koef, h * vector_koef);
this.DocumentRenderer.ds();
return this;
}
},
this.clearRect = function(x, y, w, h)
clearRect : function(x, y, w, h)
{
return this;
}
},
this.getFont = function()
getFont : function()
{
return this.font.clone();
}
this.getFontFamily = function()
},
getFontFamily : function()
{
return this.font.FontFamily.Name;
}
this.getFontSize = function()
},
getFontSize : function()
{
return this.font.FontSize;
}
},
this.getFontMetrix = function()
getFontMetrix : function()
{
console.log("error");
return new FontMetrics(0, 0, 0);
}
this.setFont = function(font)
},
setFont : function(font)
{
this.DocumentRenderer.SetFont(font);
return this;
}
},
this.measureChar = function(text, units)
measureChar : function(text, units)
{
console.log("error");
return null;
}
this.measureText = function(text, units)
},
measureText : function(text, units)
{
console.log("error");
return null;
}
},
this.fillText = function(text, x, y, maxWidth, charWidths)
fillText : function(text, x, y, maxWidth, charWidths)
{
//this.DocumentRenderer.FillText(x * vector_koef, y * vector_koef, text);
var _len = text.length;
......@@ -520,20 +286,20 @@ function CPdfPrinter(sUrlPath)
}
}
return this;
}
},
this.beginPath = function()
beginPath : function()
{
this.DocumentRenderer._s();
return this;
}
this.closePath = function()
},
closePath : function()
{
this.DocumentRenderer._z();
return this;
}
},
this.moveTo = function(x, y, dx, dy)
moveTo : function(x, y, dx, dy)
{
if (0 == dx && 0 == dy)
this.DocumentRenderer._m(x * vector_koef, y * vector_koef);
......@@ -551,8 +317,8 @@ function CPdfPrinter(sUrlPath)
this.DocumentRenderer._m(xSrc * vector_koef, ySrc * vector_koef);
}
return this;
}
this.lineTo = function(x, y, dx, dy)
},
lineTo : function(x, y, dx, dy)
{
if (0 == dx && 0 == dy)
this.DocumentRenderer._l(x * vector_koef, y * vector_koef);
......@@ -570,41 +336,47 @@ function CPdfPrinter(sUrlPath)
this.DocumentRenderer._l(xSrc * vector_koef, ySrc * vector_koef);
}
return this;
}
this.rect = function(x, y, w, h)
},
rect : function(x, y, w, h)
{
if (this.bIsSimpleCommands)
return this.DocumentRenderer.rect(x, y, w, h);
this.DocumentRenderer.rect(x * vector_koef, y * vector_koef, w * vector_koef, h * vector_koef);
return this;
}
},
this.arc = function(x, y, radius, startAngle, endAngle, antiClockwise)
arc : function(x, y, radius, startAngle, endAngle, antiClockwise)
{
// TODO:
return this;
}
this.bezierCurveTo = function(x1, y1, x2, y2, x3, y3)
},
bezierCurveTo : function(x1, y1, x2, y2, x3, y3)
{
this.DocumentRenderer._c(x1 * vector_koef, y1 * vector_koef, x2 * vector_koef, y2 * vector_koef, x3 * vector_koef, y3 * vector_koef);
return this;
}
},
this.fill = function()
fill : function()
{
this.DocumentRenderer.df();
return this;
}
this.stroke = function()
},
stroke : function()
{
this.DocumentRenderer.ds();
return this;
}
},
this.clip = function()
clip : function()
{
return this;
}
this.drawImage = function(_src, sx, sy, sw, sh, dx, dy, dw, dh, src_w, src_h)
},
drawImage : function(_src, sx, sy, sw, sh, dx, dy, dw, dh, src_w, src_h)
{
if (this.bIsSimpleCommands)
return this.DocumentRenderer.drawImage(_src, sx, sy, sw, sh, dx, dy);
if(0 == _src.indexOf(this.sUrlPath))
_src = _src.substring(this.sUrlPath.length);
if (0 == sx && 0 == sy && sw == src_w && sh == src_h)
......@@ -638,27 +410,319 @@ function CPdfPrinter(sUrlPath)
this.RemoveClipRect();
}
return this;
}
},
this.AddClipRect = function(x, y, w, h)
AddClipRect : function(x, y, w, h)
{
if (this.bIsSimpleCommands)
return this.DocumentRenderer.AddClipRect(x, y, w, h);
this.DocumentRenderer.SaveGrState();
this.DocumentRenderer.AddClipRect(x * vector_koef, y * vector_koef, w * vector_koef, h * vector_koef);
}
this.RemoveClipRect = function()
},
RemoveClipRect : function()
{
if (this.bIsSimpleCommands)
return this.DocumentRenderer.RemoveClipRect();
//this.DocumentRenderer.RemoveClipRect();
this.DocumentRenderer.RestoreGrState();
}
},
this.SetClip = function(r)
SetClip : function(r)
{
this.DocumentRenderer.SetClip(r);
}
this.RemoveClip = function()
},
RemoveClip : function()
{
this.DocumentRenderer.RemoveClip();
},
//////////////////////////////////////////////////////////////
p_color : function(r,g,b,a)
{
return this.DocumentRenderer.p_color(r, g, b, a);
},
p_width : function(w)
{
return this.DocumentRenderer.p_width(w);
},
// brush methods
b_color1 : function(r,g,b,a)
{
return this.DocumentRenderer.b_color1(r, g, b, a);
},
b_color2 : function(r,g,b,a)
{
return this.DocumentRenderer.b_color2(r, g, b, a);
},
transform : function(sx,shy,shx,sy,tx,ty)
{
return this.DocumentRenderer.transform(sx,shy,shx,sy,tx,ty);
},
transform3 : function(m)
{
return this.DocumentRenderer.transform3(m);
},
reset : function()
{
return this.DocumentRenderer.reset();
},
// path commands
_s : function()
{
return this.DocumentRenderer._s();
},
_e : function()
{
return this.DocumentRenderer._e();
},
_z : function()
{
return this.DocumentRenderer._z();
},
_m : function(x,y)
{
return this.DocumentRenderer._m(x, y);
},
_l : function(x,y)
{
return this.DocumentRenderer._l(x, y);
},
_c : function(x1,y1,x2,y2,x3,y3)
{
return this.DocumentRenderer._c(x1,y1,x2,y2,x3,y3);
},
_c2 : function(x1,y1,x2,y2)
{
return this.DocumentRenderer._c(x1,y1,x2,y2);
},
ds : function()
{
return this.DocumentRenderer.ds();
},
df : function()
{
return this.DocumentRenderer.df();
},
drawpath : function(type)
{
return this.DocumentRenderer.drawpath(type);
},
// canvas state
save : function()
{
return this.DocumentRenderer.save();
},
restore : function()
{
return this.DocumentRenderer.restore();
},
clip : function()
{
return this.DocumentRenderer.clip();
},
SetFont : function(font)
{
return this.DocumentRenderer.SetFont(font);
},
FillText : function(x,y,text,cropX,cropW)
{
return this.DocumentRenderer.FillText(x,y,text,cropX,cropW);
},
FillText2 : function(x,y,text)
{
return this.DocumentRenderer.FillText2(x,y,text);
},
charspace : function(space)
{
return this.DocumentRenderer.charspace(space);
},
SetIntegerGrid : function(param)
{
return this.DocumentRenderer.SetIntegerGrid(param);
},
GetIntegerGrid : function()
{
return this.DocumentRenderer.GetIntegerGrid();
},
GetFont : function()
{
return this.DocumentRenderer.GetFont();
},
put_GlobalAlpha : function(enable, alpha)
{
return this.DocumentRenderer.put_GlobalAlpha(enable, alpha);
},
Start_GlobalAlpha : function()
{
return this.DocumentRenderer.Start_GlobalAlpha();
},
End_GlobalAlpha : function()
{
return this.DocumentRenderer.End_GlobalAlpha();
},
DrawHeaderEdit : function(yPos)
{
return this.DocumentRenderer.DrawHeaderEdit(yPos);
},
DrawFooterEdit : function(yPos)
{
return this.DocumentRenderer.DrawFooterEdit(yPos);
},
drawCollaborativeChanges : function(x, y, w, h)
{
return this.DocumentRenderer.drawCollaborativeChanges(x, y, w, h);
},
DrawEmptyTableLine : function(x1,y1,x2,y2)
{
return this.DocumentRenderer.DrawEmptyTableLine(x1,y1,x2,y2);
},
DrawLockParagraph : function(lock_type, x, y1, y2)
{
return this.DocumentRenderer.DrawLockParagraph(lock_type, x, y1, y2);
},
DrawLockObjectRect : function(lock_type, x, y, w, h)
{
return this.DocumentRenderer.DrawLockObjectRect(lock_type, x, y, w, h);
},
// smart methods for horizontal / vertical lines
drawHorLine : function(align, y, x, r, penW)
{
return this.DocumentRenderer.drawHorLine(align, y, x, r, penW);
},
drawHorLine2 : function(align, y, x, r, penW)
{
return this.DocumentRenderer.drawHorLine(align, y, x, r, penW);
},
drawVerLine : function(align, x, y, b, penW)
{
return this.DocumentRenderer.drawVerLine(align, x, y, b, penW);
},
// мега крутые функции для таблиц
drawHorLineExt : function(align, y, x, r, penW, leftMW, rightMW)
{
return this.DocumentRenderer.drawHorLineExt(align, y, x, r, penW, leftMW, rightMW);
},
TableRect : function(x,y,w,h)
{
return this.DocumentRenderer.TableRect(x,y,w,h);
},
put_PenLineJoin : function(_join)
{
return this.DocumentRenderer.put_PenLineJoin(_join);
},
put_TextureBounds : function(x, y, w, h)
{
return this.DocumentRenderer.put_TextureBounds(x, y, w, h);
},
put_TextureBoundsEnabled : function(val)
{
return this.DocumentRenderer.put_TextureBoundsEnabled(val);
},
put_brushTexture : function(src, mode)
{
return this.DocumentRenderer.put_brushTexture(src, mode);
},
put_BrushTextureAlpha : function(alpha)
{
return this.DocumentRenderer.put_BrushTextureAlpha(alpha);
},
put_BrushGradient : function(gradFill, points)
{
return this.DocumentRenderer.put_BrushGradient(gradFill, points);
},
GetTransform : function()
{
return this.DocumentRenderer.GetTransform();
},
GetLineWidth : function()
{
return this.DocumentRenderer.GetLineWidth();
},
GetPen : function()
{
return this.DocumentRenderer.GetPen();
},
GetBrush : function()
{
return this.DocumentRenderer.GetBrush();
},
drawFlowAnchor : function(x, y)
{
return this.DocumentRenderer.drawFlowAnchor(x, y);
},
SavePen : function()
{
return this.DocumentRenderer.SavePen();
},
RestorePen : function()
{
return this.DocumentRenderer.RestorePen();
},
SaveBrush : function()
{
return this.DocumentRenderer.SaveBrush();
},
RestoreBrush : function()
{
return this.DocumentRenderer.RestoreBrush();
},
SavePenBrush : function()
{
return this.DocumentRenderer.SavePenBrush();
},
RestorePenBrush : function()
{
return this.DocumentRenderer.RestorePenBrush();
},
SaveGrState : function()
{
return this.DocumentRenderer.SaveGrState();
},
RestoreGrState : function()
{
return this.DocumentRenderer.RestoreGrState();
},
StartClipPath : function()
{
return this.DocumentRenderer.StartClipPath();
},
EndClipPath : function()
{
return this.DocumentRenderer.EndClipPath();
},
SetTextPr : function(textPr)
{
return this.DocumentRenderer.SetTextPr(textPr);
},
SetFontSlot : function(slot, fontSizeKoef)
{
return this.DocumentRenderer.SetFontSlot(slot, fontSizeKoef);
},
GetTextPr : function()
{
return this.DocumentRenderer.GetTextPr();
}
};
this.parseColor = window["Asc"].parseColor;
}
\ No newline at end of file
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