Commit f2ec9d54 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

remove Drawing

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58061 954022d7-b5bf-4e40-9824-e11837661b57
parent e07bb3c8
This diff is collapsed.
"use strict";
function CompareImageProperties(imgProps1, imgProps2)
{
var _result_image_properties = {};
if(imgProps1.Width == null || imgProps2.Width == null)
{
_result_image_properties.Width = null;
}
else
{
_result_image_properties.Width = (imgProps1.Width === imgProps2.Width) ? imgProps1.Width : null;
}
if(imgProps1.Height == null || imgProps2.Height == null)
{
_result_image_properties.Height = null;
}
else
{
_result_image_properties.Height = (imgProps1.Height === imgProps2.Height) ? imgProps1.Height : null;
}
_result_image_properties.Paddings = ComparePaddings(imgProps1.Paddings, imgProps2.Paddings);
_result_image_properties.Position = CompareImgPosition(imgProps1.Position, imgProps2.Position);
if(!(typeof imgProps1.ImageUrl === "string") || !(typeof imgProps2.ImageUrl === "string") || imgProps1.ImageUrl !== imgProps2.ImageUrl)
{
_result_image_properties.ImageUrl = null;
}
else
{
_result_image_properties = imgProps1.ImageUrl;
}
_result_image_properties.IsLocked = imgProps1.IsLocked === true || imgProps2.IsLocked === true;
return _result_image_properties;
}
function ComparePaddings(paddings1, paddings2)
{
if((paddings1 === null || !(typeof paddings1 === "object")) || (paddings2 === null || !(typeof paddings2 === "object")) )
{
return null;
}
var _result_paddings = {};
if(!(typeof paddings1.Left === "number") && !(typeof paddings2.Left === "number") || (paddings1.Left !== paddings2.Left))
{
_result_paddings.Left = null;
}
else
{
_result_paddings.Left = paddings1.Left;
}
if(!(typeof paddings1.Top === "number") && !(typeof paddings2.Top === "number") || (paddings1.Top !== paddings2.Top))
{
_result_paddings.Top = null;
}
else
{
_result_paddings.Top = paddings1.Top;
}
if(!(typeof paddings1.Right === "number") && !(typeof paddings2.Right === "number") || (paddings1.Right !== paddings2.Right))
{
_result_paddings.Right = null;
}
else
{
_result_paddings.Right = paddings1.Right;
}
if(!(typeof paddings1.Bottom === "number") && !(typeof paddings2.Bottom === "number") || (paddings1.Bottom !== paddings2.Bottom))
{
_result_paddings.Bottom = null;
}
else
{
_result_paddings.Bottom = paddings1.Bottom;
}
return _result_paddings;
}
function CompareImgPosition(pos1, pos2)
{
if((pos1 === null || !(typeof pos1 === "object")) || (pos2 === null || !(typeof pos2 === "object")) )
{
return null;
}
var _result_position = {};
if(!(typeof pos1.X === "number") && !(typeof pos1.X === "number") || (pos1.X !== pos1.X))
{
_result_position.X = null;
}
else
{
_result_position.X = pos1.X;
}
if(!(typeof pos1.Y === "number") && !(typeof pos1.Y === "number") || (pos1.Y !== pos1.Y))
{
_result_position.Y = null;
}
else
{
_result_position.Y = pos1.Y;
}
return _result_position;
}
"use strict";
function clone(obj) {
if(obj == null || typeof(obj) != 'object')
{
return obj;
}
if(obj.constructor == Array) {
var clonedArray = [];
for(var i= 0, length = obj.length; i < length; ++i) {
clonedArray[i] = clone(obj[i]);
}
return clonedArray;
}
var clonedObject = {};
var copyFunc = function(obj){return obj;}
var nullFunc = function(obj){return null;}
var undefinedFunc = function(obj ){return undefined;}
var FuncMap = {
Parent: copyFunc,
DrawingDocument: copyFunc,
Document: copyFunc,
Container: copyFunc,
parent: copyFunc,
slide: copyFunc,
slideLayout: copyFunc,
LogicDocument: copyFunc,
table: nullFunc,
txBody: undefinedFunc,
graphicObject: nullFunc
};
for(var key in obj)
{
if(undefined !== FuncMap[key])
{
clonedObject[key] = FuncMap[key](obj[key]);
}
else
{
clonedObject[key] = clone(obj[key]);
}
if(clonedObject.IsGroup && clonedObject.IsGroup())
{
for(i = 0; i < clonedObject.ArrGlyph.length; ++i)
{
clonedObject.ArrGlyph[i].Container = clonedObject;
}
}
}
return clonedObject;
}
function cloneDC(obj) {
if(obj == null || typeof(obj) != 'object') {
return obj;
}
if(obj.constructor == Array) {
var t=[];
for(var i=0; i < obj.length; ++i) {
t[i]=clone(obj[i]);
}
return t;
}
var temp = {};
var copyFunc = function(obj){return obj;}
var FuncMap = {
Parent: copyFunc,
DrawingDocument: copyFunc,
Document: copyFunc,
DocumentContent: copyFunc,
Container: copyFunc
};
for( var key in obj ) {
if(undefined !== FuncMap[key])
{
temp[key]=FuncMap[key](obj[key]);
}
else
{
temp[key] = clone(obj[key]);
}
}
return temp;
}
function clonePrototype(obj) {
if(obj == null || typeof(obj) != 'object') {
return obj;
}
if(obj.constructor == Array) {
var clonedArray=[];
for(var i=0; i < obj.length; ++i) {
clonedArray[i] = clone(obj[i]);
}
return clonedArray;
}
var clonedObj = {};
for( var key in obj ) {
clonedObj[key] = clone(obj[key]);
}
return clonedObj;
}
"use strict";
/**
* Created by JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 2/24/12
* Time: 12:41 PM
* To change this template use File | Settings | File Templates.
*/
function CShapeColor(r, g, b)
{
this.r = r;
this.g = g;
this.b = b;
this.darken = function()
{
var hslColor = RGBToHSL(this);
hslColor.l*=0.9;
return HSLToRGB(hslColor);
};
this.darkenLess = function()
{
var hslColor = RGBToHSL(this);
hslColor.l*=0.85;
return HSLToRGB(hslColor);
};
this.lighten = function()
{
var hslColor = RGBToHSL(this);
hslColor.l*= 1.1;
if(hslColor.l > 1)
{
hslColor.l = 1;
}
return HSLToRGB(hslColor);
};
this.lightenLess = function()
{
var hslColor = RGBToHSL(this);
hslColor.l*= 1.1;
if(hslColor.l > 1)
{
hslColor.l = 1;
}
return HSLToRGB(hslColor);
};
this.norm = function(a){
return this;
};
}
function RGBToHSL(RGBColor)//{r : 0..255, g : 0..255, b: 0..255}
{
var r, g, b;
r = RGBColor.r/255;
g = RGBColor.g/255;
b = RGBColor.b/255;
var max, min;
max = Math.max(r, g, b);
min = Math.min(r, g, b);
var h, s, l;
h = max === min ? 0
: (max == r && g>=b) ? 60*(g-b)/(max-min)
: (max == r && g < b) ? 60*(g-b)/(max-min)+360
: (max == g) ? 60*(b-r)/(max - min)+120
: 60*(r-g)/(max-min)+240;
l = (max + min)*0.5;
s = l > 0.5 ? (max -min) / (2 - max - min) : (max -min) / (max + min);
while(h<0)
{
h+=360;
}
while(h>=360)
{
h-=360;
}
return {h : h, s : s, l : l}; //{h : 0..360, s : 0..1, l : 0..1}
}
function HSLToRGB(HSLColor) { //{h : 0..360, s : 0..1, l : 0..1}
var h, s, l, r, g, b;
h = HSLColor.h/360;
s = HSLColor.s;
l = HSLColor.l;
var q, p, tr, tg, tb;
q = l < 0.5 ? (l*(1+s)): l+s-l*s;
p = 2*l - q;
tr = h+1/3;
tg = h;
tb = h-1/3;
if(tr < 0) {
tr+=1;
}
if(tr > 1) {
tr-=1;
}
if(tg < 0) {
tg+=1;
}
if(tg > 1) {
tg-=1;
}
if(tb < 0) {
tb+=1;
}
if(tb > 1) {
tb-=1;
}
r = Math.round(255*(tr < 1/6 ? p + ((q-p)*6*tr) : (1/6 < tr && tr <1/2) ? q : (1/2 < tr && tr < 2/3) ? (p+((q-p)*(2/3-tr)*6)) : p));
g = Math.round(255*(tg < 1/6 ? p + ((q-p)*6*tg) : (1/6 < tg && tg <1/2) ? q : (1/2 < tg && tg < 2/3) ? (p+((q-p)*(2/3-tg)*6)) : p));
b = Math.round(255*(tb < 1/6 ? p + ((q-p)*6*tb) : (1/6 < tb && tb <1/2) ? q : (1/2 < tb && tb < 2/3) ? (p+((q-p)*(2/3-tb)*6)) : p));
if(r>255) r=255;
if(g>255) g=255;
if(b>255) b=255;
return {r : r, g : g, b : b};//{r : 0..255, g : 0..255, b : 0..255}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
"use strict";
/**
* Created by JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 3/30/12
* Time: 5:21 PM
* To change graphics template use File | Settings | File Templates.
*/
function circle(graphics, xc, yc, r)
{
graphics._s();
ArcToCurvers(graphics, xc+r, yc, r, r, 0, 2*Math.PI);
graphics._z();
graphics.ds();
graphics.df();
}
function diamond(graphics, xc, yc, d)
{
d*=0.5;
graphics._s();
graphics._m(xc, yc-d);
graphics._l(xc+d, yc);
graphics._l(xc, yc+d);
graphics._l(xc-d, yc);
graphics._z();
graphics.ds();
graphics.df();
}
function square(graphics, xc, yc, d)
{
graphics._s();
graphics._m(xc-d, yc-d);
graphics._l(xc+d, yc-d);
graphics._l(xc+d, yc+d);
graphics._l(xc-d, yc+d);
graphics._z();
graphics.ds();
graphics.df();
}
"use strict";
function HitInLine(context, px, py, x0, y0, x1, y1)
{
var tx, ty, dx, dy, d;
tx=x1-x0;
ty=y1-y0;
d=1.5/Math.sqrt(tx*tx+ty*ty);
dx=-ty*d;
dy=tx*d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0+dx, y0+dy);
context.lineTo(x1+dx, y1+dy);
context.lineTo(x1-dx, y1-dy);
context.lineTo(x0-dx, y0-dy);
context.closePath();
return context.isPointInPath(px, py);
}
function HitInBezier4(context, px, py, x0, y0, x1, y1, x2, y2, x3, y3)
{
var tx, ty, dx, dy, d;
tx=x3-x0;
ty=y3-y0;
d=1.5/Math.sqrt(tx*tx+ty*ty);
dx=-ty*d;
dy=tx*d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0+dx, y0+dy);
context.bezierCurveTo(x1+dx, y1+dy, x2+dx, y2+dy, x3+dx, y3+dy);
context.lineTo(x3-dx, y3-dy);
context.bezierCurveTo(x2-dx, y2-dy, x1-dx, y1-dy, x0-dx, y0-dy);
context.closePath();
return context.isPointInPath(px, py);
}
function HitInBezier3(context, px, py, x0, y0, x1, y1, x2, y2)
{
var tx, ty, dx, dy, d;
tx=x2-x0;
ty=y2-y0;
d=1.5/Math.sqrt(tx*tx+ty*ty);
dx=-ty*d;
dy=tx*d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0+dx, y0+dy);
context.quadraticCurveTo(x1+dx, y1+dy, x2+dx, y2+dy);
context.lineTo(x2-dx, y2-dy);
context.quadraticCurveTo(x1-dx, y1-dy, x0-dx, y0-dy);
context.closePath();
return context.isPointInPath(px, py);
}
"use strict";
var min_distance_joined=2;
function JoinedH(shape1, shape2)
{
var l, r, l2, r2;
l=shape1.x;
r=l+shape1.extX;
l2=shape2.x;
r2=l2+shape2.extX;
var d=l-l2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=l-r2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=r-l2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=r-r2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
return 0;
}
function JoinedV(shape1, shape2)
{
var t, b, t2, b2;
t=shape1.y;
b=t+shape1.extY;
t2=shape2.y;
b2=t2+shape2.extY;
var d=t-t2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=t-b2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=b-t2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=b-b2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
return 0;
}
function JoinedPointH(X, shape2)
{
var l2, r2;
l2=shape2.x;
r2=l2+shape2.extX;
var d=X-l2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=X-r2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
return 0;
}
function JoinedPointV(Y, shape2)
{
var t2, b2;
t2=shape2.y;
b2=t2+shape2.extY;
var d=Y-t2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=Y-b2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
return 0;
}
\ No newline at end of file
"use strict";
/**
* Created by JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 2/24/12
* Time: 10:06 AM
* To change this template use File | Settings | File Templates.
*/
var cToRad = Math.PI/(60000*180);
var cToDeg = 1/cToRad;
function Cos(angle)
{
return Math.cos(cToRad*angle);
}
function Sin(angle)
{
return Math.sin(cToRad*angle);
}
function Tan(angle)
{
return Math.tan(cToRad*angle);
}
function ATan(x)
{
return cToDeg*Math.atan(x);
}
function ATan2(y, x)
{
return cToDeg*Math.atan2(y, x);
}
function CAt2(x, y, z)
{
return x*(Cos(ATan2(z, y)));
}
function SAt2(x, y, z)
{
return x*(Sin(ATan2(z, y)));
}
\ No newline at end of file
This diff is collapsed.
"use strict";
function PolyLine (drawingObjects)
{
this.drawingObjects = drawingObjects;
this.arrPoint = [];
this.Matrix = new CMatrixL();
this.TransformMatrix = new CMatrixL();
this.style = CreateDefaultShapeStyle();
var _calculated_line;
var theme = drawingObjects.Layout.Master.Theme;
var slide = drawingObjects;
var layout = drawingObjects.Layout;
var masterSlide = drawingObjects.Layout.Master;
var RGBA = {R: 0, G: 0, B: 0, A: 255};
if(isRealObject(theme) && typeof theme.getLnStyle === "function"
&& isRealObject(this.style) && isRealObject(this.style.lnRef) && isRealNumber(this.style.lnRef.idx)
&& isRealObject(this.style.lnRef.Color) && typeof this.style.lnRef.Color.Calculate === "function")
{
_calculated_line = theme.getLnStyle(this.style.lnRef.idx);
this.style.lnRef.Color.Calculate(theme, slide, layout, masterSlide, RGBA);
RGBA = this.style.lnRef.Color.RGBA;
}
else
{
_calculated_line = new CLn();
}
if(isRealObject(_calculated_line.Fill))
{
_calculated_line.Fill.calculate(theme, slide, layout, masterSlide, RGBA) ;
}
this.pen = _calculated_line;
this.polylineForDrawer = new PolylineForDrawer(this);
this.Draw = function(graphics)
{
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function(g)
{
this.polylineForDrawer.Draw(g);
return;
if(this.arrPoint.length < 2)
{
return;
}
g._m(this.arrPoint[0].x, this.arrPoint[0].y);
for(var i = 1; i < this.arrPoint.length; ++i)
{
g._l(this.arrPoint[i].x, this.arrPoint[i].y);
}
g.ds();
};
this.getLeftTopPoint = function()
{
if(this.arrPoint.length < 1)
return {x: 0, y: 0};
var xMax = this.arrPoint[0].x, yMax = this.arrPoint[0].y, xMin = xMax, yMin = yMax;
var i;
for( i = 1; i<this.arrPoint.length; ++i)
{
if(this.arrPoint[i].x > xMax)
{
xMax = this.arrPoint[i].x;
}
if(this.arrPoint[i].y > yMax)
{
yMax = this.arrPoint[i].y;
}
if(this.arrPoint[i].x < xMin)
{
xMin = this.arrPoint[i].x;
}
if(this.arrPoint[i].y < yMin)
{
yMin = this.arrPoint[i].y;
}
}
return {x: xMin, y: yMin};
};
this.createShape = function(document)
{
var xMax = this.arrPoint[0].x, yMax = this.arrPoint[0].y, xMin = xMax, yMin = yMax;
var i;
var bClosed = false;
if(this.arrPoint.length > 2)
{
var dx = this.arrPoint[0].x - this.arrPoint[this.arrPoint.length-1].x;
var dy = this.arrPoint[0].y - this.arrPoint[this.arrPoint.length-1].y;
var dd = editor.WordControl.m_oDrawingDocument;
if(Math.sqrt(dx*dx +dy*dy) < dd.GetMMPerDot(3))
{
bClosed = true;
}
}
var _n = bClosed ? this.arrPoint.length - 1 : this.arrPoint.length;
for( i = 1; i<_n; ++i)
{
if(this.arrPoint[i].x > xMax)
{
xMax = this.arrPoint[i].x;
}
if(this.arrPoint[i].y > yMax)
{
yMax = this.arrPoint[i].y;
}
if(this.arrPoint[i].x < xMin)
{
xMin = this.arrPoint[i].x;
}
if(this.arrPoint[i].y < yMin)
{
yMin = this.arrPoint[i].y;
}
}
var shape = new CShape(this.drawingObjects);
shape.setOffset(xMin, yMin);
shape.setExtents(xMax-xMin, yMax-yMin);
shape.setStyle(CreateDefaultShapeStyle());
var geometry = new Geometry();
geometry.AddPathCommand(0, undefined, bClosed ? "norm": "none", undefined, xMax - xMin, yMax-yMin);
geometry.AddRect("l", "t", "r", "b");
geometry.AddPathCommand(1, (this.arrPoint[0].x - xMin) + "", (this.arrPoint[0].y - yMin) + "");
for(i = 1; i< _n; ++i)
{
geometry.AddPathCommand(2, (this.arrPoint[i].x - xMin) + "", (this.arrPoint[i].y - yMin) + "");
}
if(bClosed)
{
geometry.AddPathCommand(6);
}
shape.setGeometry(geometry);
return shape;
}
}
function PolylineForDrawer(polyline)
{
this.polyline = polyline;
this.pen = polyline.pen;
this.brush = polyline.brush;
this.TransformMatrix = polyline.TransformMatrix;
this.Matrix = polyline.Matrix;
this.Draw = function(graphics)
{
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function(g)
{
g._e();
if(this.polyline.arrPoint.length < 2)
{
return;
}
g._m(this.polyline.arrPoint[0].x, this.polyline.arrPoint[0].y);
for(var i = 1; i < this.polyline.arrPoint.length; ++i)
{
g._l(this.polyline.arrPoint[i].x, this.polyline.arrPoint[i].y);
}
g.ds();
};
}
\ No newline at end of file
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