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

Перенес Controls.js в Common

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@62545 954022d7-b5bf-4e40-9824-e11837661b57
parent d58c6161
......@@ -74,6 +74,7 @@
"../../Common/Drawings/Format/Geometry.js",
"../../Common/Drawings/Format/Path.js",
"../../Common/Drawings/Format/TextBody.js",
"../../Common/Drawings/TextDrawer.js",
"../../Word/Editor/GraphicObjects/Format/ShapePrototype.js",
"../../Word/Editor/GraphicObjects/Format/ImagePrototype.js",
......@@ -117,7 +118,7 @@
"../../Word/Drawing/GraphicsEvents.js",
"../../Common/Scrolls/iscroll.js",
"../../Word/Drawing/WorkEvents.js",
"../../Word/Drawing/Controls.js",
"../../Common/Controls.js",
"../../Word/Drawing/Rulers.js",
"../../Word/Drawing/documentrenderer.js",
......
......@@ -110,12 +110,13 @@
"../../Common/Drawings/Format/ChartSpace.js",
"../../Common/Drawings/Format/ChartFormat.js",
"../../Common/Drawings/Format/TextBody.js",
"../../Common/Drawings/TextDrawer.js",
"../../Common/wordcopypaste.js",
"../../Excel/view/DrawingObjectsController.js",
"../../Excel/model/DrawingObjects/Graphics.js",
"../../Excel/model/DrawingObjects/Private/Graphics.js",
"../../Excel/model/DrawingObjects/Overlay.js",
"../../Excel/model/DrawingObjects/Controls.js",
"../../Common/Controls.js",
"../../Excel/model/DrawingObjects/ShapeDrawer.js",
"../../Excel/model/DrawingObjects/DrawingDocument.js",
"../../Excel/model/DrawingObjects/Format/ShapePrototype.js",
......
......@@ -55,7 +55,7 @@
"../../Word/Drawing/GraphicsEvents.js",
"../../Word/Drawing/WorkEvents.js",
"../../Word/Drawing/Controls.js",
"../../Common/Controls.js",
"../../Word/Drawing/Rulers.js",
"../../Word/Editor/Table.js",
"../../Word/Editor/Common.js",
......@@ -109,6 +109,7 @@
"../../Common/Drawings/Format/ChartSpace.js",
"../../Common/Drawings/Format/ChartFormat.js",
"../../Common/Drawings/Format/TextBody.js",
"../../Common/Drawings/TextDrawer.js",
"../../PowerPoint/Editor/Format/Slide.js",
"../../PowerPoint/Editor/Format/SlideMaster.js",
"../../PowerPoint/Editor/Format/Layout.js",
......
......@@ -76,6 +76,7 @@
"../../Common/Drawings/Format/Geometry.js",
"../../Common/Drawings/Format/Path.js",
"../../Common/Drawings/Format/TextBody.js",
"../../Common/Drawings/TextDrawer.js",
"../../Word/Editor/GraphicObjects/Format/ShapePrototype.js",
"../../Word/Editor/GraphicObjects/Format/ImagePrototype.js",
"../../Word/Editor/GraphicObjects/Format/GroupPrototype.js",
......@@ -119,7 +120,7 @@
"../../Word/Drawing/GraphicsEvents.js",
"../../Common/Scrolls/iscroll.js",
"../../Word/Drawing/WorkEvents.js",
"../../Word/Drawing/Controls.js",
"../../Common/Controls.js",
"../../Word/Drawing/Rulers.js",
"../../Word/Drawing/HtmlPage.js",
"../../Word/Drawing/documentrenderer.js",
......
"use strict";
function CBounds()
{
this.L = 0; // ����� �������
this.T = 0; // ������� �������
this.R = 0; // ������ ������� (���� ������ ���� isAbsR, �� ��� ���������� ������, � �� R)
this.B = 0; // ������� ������� (���� ������ ���� isAbsB, �� ��� ���������� ������, � �� B)
this.isAbsL = false;
this.isAbsT = false;
this.isAbsR = false;
this.isAbsB = false;
this.AbsW = -1;
this.AbsH = -1;
this.SetParams = function(_l,_t,_r,_b,abs_l,abs_t,abs_r,abs_b,absW,absH)
{
this.L = _l;
this.T = _t;
this.R = _r;
this.B = _b;
this.isAbsL = abs_l;
this.isAbsT = abs_t;
this.isAbsR = abs_r;
this.isAbsB = abs_b;
this.AbsW = absW;
this.AbsH = absH;
}
}
function CAbsolutePosition()
{
this.L = 0;
this.T = 0;
this.R = 0;
this.B = 0;
}
var g_anchor_left = 1;
var g_anchor_top = 2;
var g_anchor_right = 4;
var g_anchor_bottom = 8;
function CControl()
{
this.Bounds = new CBounds();
this.Anchor = g_anchor_left | g_anchor_top;
this.Name = null;
this.Parent = null;
this.TabIndex = null;
this.HtmlElement = null;
this.AbsolutePosition = new CBounds();
this.Resize = function(_width,_height,api)
{
if ((null == this.Parent) || (null == this.HtmlElement))
return;
var _x = 0;
var _y = 0;
var _r = 0;
var _b = 0;
var hor_anchor = (this.Anchor & 0x05);
var ver_anchor = (this.Anchor & 0x0A);
if (g_anchor_left == hor_anchor)
{
if (this.Bounds.isAbsL)
_x = this.Bounds.L;
else
_x = (this.Bounds.L * _width / 1000);
if (-1 != this.Bounds.AbsW)
_r = _x + this.Bounds.AbsW;
else
{
if (this.Bounds.isAbsR)
_r = (_width - this.Bounds.R);
else
_r = this.Bounds.R * _width / 1000;
}
}
else if (g_anchor_right == hor_anchor)
{
if (this.Bounds.isAbsR)
_r = (_width - this.Bounds.R);
else
_r = (this.Bounds.R * _width / 1000);
if (-1 != this.Bounds.AbsW)
_x = _r - this.Bounds.AbsW;
else
{
if (this.Bounds.isAbsL)
_x = this.Bounds.L;
else
_x = this.Bounds.L * _width / 1000;
}
}
else if ((g_anchor_left | g_anchor_right) == hor_anchor)
{
if (this.Bounds.isAbsL)
_x = this.Bounds.L;
else
_x = (this.Bounds.L * _width / 1000);
if (this.Bounds.isAbsR)
_r = (_width - this.Bounds.R);
else
_r = (this.Bounds.R * _width / 1000);
}
else
{
_x = this.Bounds.L;
_r = this.Bounds.R;
}
if (g_anchor_top == ver_anchor)
{
if (this.Bounds.isAbsT)
_y = this.Bounds.T;
else
_y = (this.Bounds.T * _height / 1000);
if (-1 != this.Bounds.AbsH)
_b = _y + this.Bounds.AbsH;
else
{
if (this.Bounds.isAbsB)
_b = (_height - this.Bounds.B);
else
_b = this.Bounds.B * _height / 1000;
}
}
else if (g_anchor_bottom == ver_anchor)
{
if (this.Bounds.isAbsB)
_b = (_height - this.Bounds.B);
else
_b = (this.Bounds.B * _height / 1000);
if (-1 != this.Bounds.AbsH)
_y = _b - this.Bounds.AbsH;
else
{
if (this.Bounds.isAbsT)
_y = this.Bounds.T;
else
_y = this.Bounds.T * _height / 1000;
}
}
else if ((g_anchor_top | g_anchor_bottom) == ver_anchor)
{
if (this.Bounds.isAbsT)
_y = this.Bounds.T;
else
_y = (this.Bounds.T * _height / 1000);
if (this.Bounds.isAbsB)
_b = (_height - this.Bounds.B);
else
_b = (this.Bounds.B * _height / 1000);
}
else
{
_y = this.Bounds.T;
_b = this.Bounds.B;
}
if (_r < _x)
_r = _x;
if (_b < _y)
_b = _y;
this.AbsolutePosition.L = _x;
this.AbsolutePosition.T = _y;
this.AbsolutePosition.R = _r;
this.AbsolutePosition.B = _b;
this.HtmlElement.style.left = ((_x * g_dKoef_mm_to_pix + 0.5) >> 0) + "px";
this.HtmlElement.style.top = ((_y * g_dKoef_mm_to_pix + 0.5) >> 0) + "px";
this.HtmlElement.style.width = (((_r - _x) * g_dKoef_mm_to_pix + 0.5) >> 0) + "px";
this.HtmlElement.style.height = (((_b - _y) * g_dKoef_mm_to_pix + 0.5) >> 0) + "px";
if (api !== undefined && api.CheckRetinaElement && api.CheckRetinaElement(this.HtmlElement))
{
var _W = ((_r - _x) * g_dKoef_mm_to_pix + 0.5) >> 0;
var _H = ((_b - _y) * g_dKoef_mm_to_pix + 0.5) >> 0;
this.HtmlElement.width = _W << 1;
this.HtmlElement.height = _H << 1;
}
else
{
this.HtmlElement.width = ((_r - _x) * g_dKoef_mm_to_pix + 0.5) >> 0;
this.HtmlElement.height = ((_b - _y) * g_dKoef_mm_to_pix + 0.5) >> 0;
}
};
this.GetCSS_width = function()
{
return ((this.AbsolutePosition.R - this.AbsolutePosition.L) * g_dKoef_mm_to_pix + 0.5) >> 0;
};
this.GetCSS_height = function()
{
return ((this.AbsolutePosition.B - this.AbsolutePosition.T) * g_dKoef_mm_to_pix + 0.5) >> 0;
};
}
function CControlContainer()
{
this.Bounds = new CBounds();
this.Anchor = g_anchor_left | g_anchor_top;
this.Name = null;
this.Parent = null;
this.TabIndex = null;
this.HtmlElement = null;
this.AbsolutePosition = new CBounds();
this.Controls = [];
this.AddControl = function(ctrl)
{
ctrl.Parent = this;
this.Controls[this.Controls.length] = ctrl;
};
this.Resize = function(_width,_height,api)
{
if (null == this.Parent)
{
this.AbsolutePosition.L = 0;
this.AbsolutePosition.T = 0;
this.AbsolutePosition.R = _width;
this.AbsolutePosition.B = _height;
if (null != this.HtmlElement)
{
var lCount = this.Controls.length;
for (var i = 0; i < lCount; i++)
{
this.Controls[i].Resize(_width,_height,api);
}
}
return;
}
var _x = 0;
var _y = 0;
var _r = 0;
var _b = 0;
var hor_anchor = (this.Anchor & 0x05);
var ver_anchor = (this.Anchor & 0x0A);
if (g_anchor_left == hor_anchor)
{
if (this.Bounds.isAbsL)
_x = this.Bounds.L;
else
_x = (this.Bounds.L * _width / 1000);
if (-1 != this.Bounds.AbsW)
_r = _x + this.Bounds.AbsW;
else
{
if (this.Bounds.isAbsR)
_r = (_width - this.Bounds.R);
else
_r = this.Bounds.R * _width / 1000;
}
}
else if (g_anchor_right == hor_anchor)
{
if (this.Bounds.isAbsR)
_r = (_width - this.Bounds.R);
else
_r = (this.Bounds.R * _width / 1000);
if (-1 != this.Bounds.AbsW)
_x = _r - this.Bounds.AbsW;
else
{
if (this.Bounds.isAbsL)
_x = this.Bounds.L;
else
_x = this.Bounds.L * _width / 1000;
}
}
else if ((g_anchor_left | g_anchor_right) == hor_anchor)
{
if (this.Bounds.isAbsL)
_x = this.Bounds.L;
else
_x = (this.Bounds.L * _width / 1000);
if (this.Bounds.isAbsR)
_r = (_width - this.Bounds.R);
else
_r = (this.Bounds.R * _width / 1000);
}
else
{
_x = this.Bounds.L;
_r = this.Bounds.R;
}
if (g_anchor_top == ver_anchor)
{
if (this.Bounds.isAbsT)
_y = this.Bounds.T;
else
_y = (this.Bounds.T * _height / 1000);
if (-1 != this.Bounds.AbsH)
_b = _y + this.Bounds.AbsH;
else
{
if (this.Bounds.isAbsB)
_b = (_height - this.Bounds.B);
else
_b = this.Bounds.B * _height / 1000;
}
}
else if (g_anchor_bottom == ver_anchor)
{
if (this.Bounds.isAbsB)
_b = (_height - this.Bounds.B);
else
_b = (this.Bounds.B * _height / 1000);
if (-1 != this.Bounds.AbsH)
_y = _b - this.Bounds.AbsH;
else
{
if (this.Bounds.isAbsT)
_y = this.Bounds.T;
else
_y = this.Bounds.T * _height / 1000;
}
}
else if ((g_anchor_top | g_anchor_bottom) == ver_anchor)
{
if (this.Bounds.isAbsT)
_y = this.Bounds.T;
else
_y = (this.Bounds.T * _height / 1000);
if (this.Bounds.isAbsB)
_b = (_height - this.Bounds.B);
else
_b = (this.Bounds.B * _height / 1000);
}
else
{
_y = this.Bounds.T;
_b = this.Bounds.B;
}
if (_r < _x)
_r = _x;
if (_b < _y)
_b = _y;
this.AbsolutePosition.L = _x;
this.AbsolutePosition.T = _y;
this.AbsolutePosition.R = _r;
this.AbsolutePosition.B = _b;
this.HtmlElement.style.left = ((_x * g_dKoef_mm_to_pix + 0.5) >> 0) + "px";
this.HtmlElement.style.top = ((_y * g_dKoef_mm_to_pix + 0.5) >> 0) + "px";
this.HtmlElement.style.width = (((_r - _x) * g_dKoef_mm_to_pix + 0.5) >> 0) + "px";
this.HtmlElement.style.height = (((_b - _y) * g_dKoef_mm_to_pix + 0.5) >> 0) + "px";
var lCount = this.Controls.length;
for (var i = 0; i < lCount; i++)
{
this.Controls[i].Resize(_r - _x,_b - _y, api);
}
};
this.GetCSS_width = function()
{
return ((this.AbsolutePosition.R - this.AbsolutePosition.L) * g_dKoef_mm_to_pix + 0.5) >> 0;
};
this.GetCSS_height = function()
{
return ((this.AbsolutePosition.B - this.AbsolutePosition.T) * g_dKoef_mm_to_pix + 0.5) >> 0;
};
}
function CreateControlContainer(name)
{
var ctrl = new CControlContainer();
ctrl.Name = name;
ctrl.HtmlElement = document.getElementById(name);
return ctrl;
}
function CreateControl(name)
{
var ctrl = new CControl();
ctrl.Name = name;
ctrl.HtmlElement = document.getElementById(name);
return ctrl;
}
\ No newline at end of file
var PATH_DIV_EPSILON = 0.1;
function CDocContentStructure()
{
this.m_nType = DRAW_COMMAND_CONTENT;
this.m_aContent = [];
this.m_aByLines = null;
}
CDocContentStructure.prototype.Recalculate = function(oTheme, oColorMap, dWidth, dHeight, oShape)
{
for(var i = 0; i < this.m_aContent.length; ++i)
{
this.m_aContent[i].Recalculate(oTheme, oColorMap, dWidth, dHeight, oShape);
}
};
CDocContentStructure.prototype.draw = function(graphics, transform)
{
for(var i = 0; i < this.m_aContent.length; ++i)
{
this.m_aContent[i].draw(graphics, transform);
}
};
CDocContentStructure.prototype.checkByWarpStruct = function(oWarpStruct)
{
var i, j, t;
switch(oWarpStruct.pathLst.length)
{
case 1:
{
break;
}
case 2:
case 4:
case 6:
{
var nDivCount = oWarpStruct.pathLst.length >> 1;
var aByPaths = oWarpStruct.getArrayPolygonsByPaths(PATH_DIV_EPSILON);
var nLastIndex = 0, aIndex = [], aWarpedObjects = [], dTmp, oBoundsChecker, oTemp, nIndex;
oBoundsChecker = new CSlideBoundsChecker();
oBoundsChecker.init(100, 100, 100, 100);
var bCheckBounds = false, dMinX, dMaxX;
if(oWarpStruct.pathLst.length > 2)
{
bCheckBounds = true;
for(j = 0; j < this.m_aByLines.length; ++j)
{
oTemp = this.m_aByLines[j];
for(t = 0; t < oTemp.length; ++t)
{
oTemp[t].GetAllWarped(aWarpedObjects);
oTemp[t].CheckBoundsWarped(oBoundsChecker);
}
}
dMinX = oBoundsChecker.Bounds.min_x;
dMaxX = oBoundsChecker.Bounds.max_x;
}
for( i = 0; i < nDivCount; ++i)
{
dTmp = (this.m_aByLines.length - nLastIndex)/(nDivCount - i);
nIndex = nLastIndex + (dTmp >> 0) + ((dTmp - (dTmp >> 0)) > 0 ? 1 : 0);
aWarpedObjects.length = 0;
oBoundsChecker.Bounds.ClearNoAttack();
for(j = nLastIndex; j < nIndex; ++j)
{
oTemp = this.m_aByLines[j];
for(t = 0; t < oTemp.length; ++t)
{
oTemp[t].GetAllWarped(aWarpedObjects);
oTemp[t].CheckBoundsWarped(oBoundsChecker);
}
}
if(bCheckBounds)
{
if(oBoundsChecker.Bounds.min_x > dMinX)
{
oBoundsChecker.Bounds.min_x = dMinX;
}
if(oBoundsChecker.Bounds.max_x < dMaxX)
{
oBoundsChecker.Bounds.max_x = dMaxX;
}
}
ObjectsToDrawBetweenTwoPolygons(aWarpedObjects, oBoundsChecker.Bounds, new PolygonWrapper(aByPaths[i << 1]), new PolygonWrapper(aByPaths[(i << 1) + 1]));
nLastIndex = nIndex;
}
break;
}
case 3:
{
break;
}
default://без формы
{
break;
}
}
};
function CParagraphStructure()
{
this.m_nType = DRAW_COMMAND_PARAGRAPH;
this.m_aContent = [];
}
CParagraphStructure.prototype.Recalculate = function(oTheme, oColorMap, dWidth, dHeight, oShape)
{
var i;
for(i = 0; i < this.m_aContent.length; ++i)
{
this.m_aContent[i].Recalculate(oTheme, oColorMap, dWidth, dHeight, oShape);
}
};
CParagraphStructure.prototype.draw = function(graphics, transform)
{
var i;
for(i = 0; i < this.m_aContent.length; ++i)
{
this.m_aContent[i].draw(graphics, transform);
}
};
function CTableStructure()
{
this.m_nType = DRAW_COMMAND_TABLE;
this.m_aContent = [];
this.m_aBorders = [];
}
CTableStructure.prototype.Recalculate = function(oTheme, oColorMap, dWidth, dHeight, oShape)
{
var i;
for(i = 0; i < this.m_aContent.length; ++i)
{
this.m_aContent[i].Recalculate(oTheme, oColorMap, dWidth, dHeight, oShape);
}
for(i = 0; i < this.m_aBorders.length; ++i)
{
this.m_aBorders[i].Recalculate(oTheme, oColorMap, dWidth, dHeight, oShape);
}
};
CTableStructure.prototype.draw = function(graphics)
{
var i;
for(i = 0; i < this.m_aBorders.length; ++i)
{
this.m_aBorders[i].draw(graphics);
}
for(i = 0; i < this.m_aContent.length; ++i)
{
this.m_aContent[i].draw(graphics, transform);
}
};
function CLineStructure(oLine)
{
this.m_nType = DRAW_COMMAND_LINE;
this.m_oLine = oLine;
this.m_aContent = [];//ObjectToDraw
this.m_aBorders = [];
this.m_aBackgrounds = [];
this.m_aUnderlinesStrileouts = [];
this.m_aParagraphBackgrounds = [];
this.m_nDrawType = 0;// 0 - content, 1 - borders, 2 - backgrounds, 3 - underlinestrikeouts, 4 - paragraphbackrounds
}
CLineStructure.prototype.Recalculate = function(oTheme, oColorMap, dWidth, dHeight, oShape)
{
var i;
for(i = 0; i < this.m_aContent.length; ++i)
{
this.m_aContent[i].Recalculate(oTheme, oColorMap, dWidth, dHeight, oShape, this.m_oLine);
}
for(i = 0; i < this.m_aBorders.length; ++i)
{
this.m_aBorders[i].Recalculate(oTheme, oColorMap, dWidth, dHeight, oShape, this.m_oLine);
}
for(i = 0; i < this.m_aBackgrounds.length; ++i)
{
this.m_aBackgrounds[i].Recalculate(oTheme, oColorMap, dWidth, dHeight, oShape, this.m_oLine);
}
for(i = 0; i < this.m_aUnderlinesStrileouts.length; ++i)
{
this.m_aUnderlinesStrileouts[i].Recalculate(oTheme, oColorMap, dWidth, dHeight, oShape, this.m_oLine);
}
for(i = 0; i < this.m_aParagraphBackgrounds.length; ++i)
{
this.m_aParagraphBackgrounds[i].Recalculate(oTheme, oColorMap, dWidth, dHeight, oShape, this.m_oLine);
}
};
CLineStructure.prototype.GetAllWarped = function(aWarpedObjects)
{
var i;
for(i = 0; i < this.m_aContent.length; ++i)
{
aWarpedObjects.push(this.m_aContent[i]);
}
for(i = 0; i < this.m_aBackgrounds.length; ++i)
{
aWarpedObjects.push(this.m_aBackgrounds[i]);
}
for(i = 0; i < this.m_aUnderlinesStrileouts.length; ++i)
{
aWarpedObjects.push(this.m_aUnderlinesStrileouts[i]);
}
};
CLineStructure.prototype.CheckBoundsWarped = function(graphics)
{
var i;
for(i = 0; i < this.m_aContent.length; ++i)
{
this.m_aContent[i].draw(graphics, true);
}
for(i = 0; i < this.m_aBackgrounds.length; ++i)
{
this.m_aBackgrounds[i].draw(graphics, true);
}
for(i = 0; i < this.m_aUnderlinesStrileouts.length; ++i)
{
this.m_aUnderlinesStrileouts[i].draw(graphics, true);
}
};
CLineStructure.prototype.draw = function(graphics, transform)
{
var i;
for(i = 0; i < this.m_aParagraphBackgrounds.length; ++i)
{
this.m_aParagraphBackgrounds[i].draw(graphics, undefined, transform);
}
for(i = 0; i < this.m_aBorders.length; ++i)
{
this.m_aBorders[i].draw(graphics);
}
for(i = 0; i < this.m_aBackgrounds.length; ++i)
{
this.m_aBackgrounds[i].draw(graphics, undefined, transform);
}
for(i = 0; i < this.m_aContent.length; ++i)
{
this.m_aContent[i].draw(graphics, undefined, transform);
}
for(i = 0; i < this.m_aUnderlinesStrileouts.length; ++i)
{
this.m_aUnderlinesStrileouts[i].draw(graphics, undefined, transform);
}
};
function CTextDrawer(dWidth, dHeight, bDivByLInes)
{
this.m_oFont =
{
Name : "",
FontSize : -1,
Style : -1
};
this.Width = dWidth;
this.Height = dHeight;
this.m_oTransform = new CMatrix();
this.pathW = 43200;
this.pathH = 43200;
this.xKoeff = this.pathW/this.Width;
this.yKoeff = this.pathH/this.Height;
this.m_aStack = [];
this.m_oDocContentStructure = null;
this.m_aCommands = [];
// RFonts
this.m_oTextPr = null;
this.m_oGrFonts = new CGrRFonts();
this.m_oPen = new CPen();
this.m_oBrush = new CBrush();
this.BrushType = MetaBrushType.Solid;
// чтобы выставилось в первый раз
this.m_oPen.Color.R = -1;
this.m_oBrush.Color1.R = -1;
this.m_oBrush.Color2.R = -1;
// просто чтобы не создавать каждый раз
this.m_oFontSlotFont = new CFontSetup();
this.LastFontOriginInfo = { Name : "", Replace : null };
this.GrState = new CGrState();
this.GrState.Parent = this;
this.m_bDivByLines = bDivByLInes === true;
this.m_aByLines = null;
this.m_nCurLineIndex = -1;
this.m_aStackLineIndex = null;
this.m_aStackCurRowMaxIndex = null;
this.m_aByParagraphs = null;
if(this.m_bDivByLines)
{
this.m_aByLines = [];
this.m_aStackLineIndex = [];
this.m_aStackCurRowMaxIndex = [];
}
else
{
this.m_aByParagraphs = [];
}
}
var DRAW_COMMAND_TABLE = 0x01;
var DRAW_COMMAND_CONTENT = 0x02;
var DRAW_COMMAND_PARAGRAPH = 0x03;
var DRAW_COMMAND_LINE = 0x04;
var DRAW_COMMAND_DRAWING = 0x05;
var DRAW_COMMAND_HIDDEN_ELEM = 0x06;
var DRAW_COMMAND_NO_CREATE_GEOM = 0x07;
var DRAW_COMMAND_TABLE_ROW = 0x08;
function GetConstDescription(nConst)
{
switch (nConst)
{
case DRAW_COMMAND_TABLE:
{
return "DRAW_COMMAND_TABLE";
}
case DRAW_COMMAND_CONTENT:
{
return "DRAW_COMMAND_CONTENT";
}
case DRAW_COMMAND_PARAGRAPH:
{
return "DRAW_COMMAND_PARAGRAPH";
}
case DRAW_COMMAND_LINE:
{
return "DRAW_COMMAND_LINE";
}
case DRAW_COMMAND_DRAWING:
{
return "DRAW_COMMAND_DRAWING";
}
case DRAW_COMMAND_HIDDEN_ELEM:
{
return "DRAW_COMMAND_HIDDEN_ELEM";
}
case DRAW_COMMAND_NO_CREATE_GEOM:
{
return "DRAW_COMMAND_NO_CREATE_GEOM";
}
case DRAW_COMMAND_TABLE_ROW:
{
return "DRAW_COMMAND_TABLE_ROW";
}
default :
{
return "Unknown";
}
}
}
function CreatePenFromParams(oUnifill, nStyle, nLineCap, nLineJoin, dLineWidth, dSize)
{
var oLine = new CLn();
oLine.setW(dSize * 36000 >> 0);
oLine.setFill(oUnifill);
//TODO
// this.Color = { R : 255, G : 255, B : 255, A : 255 };
// this.Style = 0;
// this.LineCap = 0;
// this.LineJoin = 0;
//
// this.LineWidth = 1;
return oLine;
}
CTextDrawer.prototype =
{
// pen methods
p_color : function(r,g,b,a)
{
if (this.m_oPen.Color.R != r || this.m_oPen.Color.G != g || this.m_oPen.Color.B != b)
{
this.m_oPen.Color.R = r;
this.m_oPen.Color.G = g;
this.m_oPen.Color.B = b;
}
if (this.m_oPen.Color.A != a)
{
this.m_oPen.Color.A = a;
}
this.Get_PathToDraw(false, true);
},
p_width : function(w)
{
var val = w / 1000;
if (this.m_oPen.Size != val)
{
this.m_oPen.Size = val;
}
this.Get_PathToDraw(false, true);
},
// brush methods
b_color1 : function(r,g,b,a)
{
if (this.m_oBrush.Color1.R != r || this.m_oBrush.Color1.G != g || this.m_oBrush.Color1.B != b)
{
this.m_oBrush.Color1.R = r;
this.m_oBrush.Color1.G = g;
this.m_oBrush.Color1.B = b;
}
if (this.m_oBrush.Color1.A != a)
{
this.m_oBrush.Color1.A = a;
}
this.Get_PathToDraw(false, true);
},
b_color2 : function(r,g,b,a)
{
if (this.m_oBrush.Color2.R != r || this.m_oBrush.Color2.G != g || this.m_oBrush.Color2.B != b)
{
this.m_oBrush.Color2.R = r;
this.m_oBrush.Color2.G = g;
this.m_oBrush.Color2.B = b;
}
if (this.m_oBrush.Color2.A != a)
{
this.m_oBrush.Color2.A = a;
}
this.Get_PathToDraw(false, true);
},
put_brushTexture : function(src, mode)
{
this.m_oBrush.Color1.R = -1;
this.m_oBrush.Color1.G = -1;
this.m_oBrush.Color1.B = -1;
this.m_oBrush.Color1.A = -1;
this.Get_PathToDraw(false, true);
},
put_BrushTextureAlpha : function(alpha)
{
},
put_BrushGradient : function(gradFill, points, transparent)
{
},
StartCheckTableDraw: function()
{
this.Start_Command(DRAW_COMMAND_TABLE);
},
EndCheckTableDraw: function()
{
this.End_Command();
},
Start_Command : function(commandId, param, index, nType)
{
//console.log(GetConstDescription(commandId) + " Start ");
//console.log("--------Start------");
//console.log("CurLineIndex " + this.m_nCurLineIndex);
//console.log("--------Start------");
this.m_aCommands.push(commandId);
var oNewStructure = null;
switch(commandId)
{
case DRAW_COMMAND_NO_CREATE_GEOM:
{
break;
}
case DRAW_COMMAND_CONTENT:
{
oNewStructure = new CDocContentStructure();
this.m_aStackLineIndex.push(this.m_nCurLineIndex);
break;
}
case DRAW_COMMAND_PARAGRAPH:
{
oNewStructure = new CParagraphStructure();
if(!this.m_bDivByLines)
{
this.m_aByParagraphs[this.m_aByParagraphs.length] = [];
}
break;
}
case DRAW_COMMAND_LINE:
{
var oPrevStruct = this.m_aStack[this.m_aStack.length - 1];
if(oPrevStruct.m_nType === DRAW_COMMAND_PARAGRAPH && oPrevStruct.m_aContent[index])
{
oPrevStruct.m_aContent[index].m_nDrawType = nType;
this.m_aStack.push(oPrevStruct.m_aContent[index]);
}
else
{
oNewStructure = new CLineStructure(param);
oNewStructure.m_nDrawType = nType;
if(this.m_bDivByLines)
{
++this.m_nCurLineIndex;
if(!Array.isArray(this.m_aByLines[this.m_nCurLineIndex]))
{
this.m_aByLines[this.m_nCurLineIndex] = [];
}
this.m_aByLines[this.m_nCurLineIndex].push(oNewStructure);
if(this.m_aStackCurRowMaxIndex[this.m_aStackCurRowMaxIndex.length - 1] < this.m_nCurLineIndex)
{
this.m_aStackCurRowMaxIndex[this.m_aStackCurRowMaxIndex.length - 1] = this.m_nCurLineIndex;
}
}
else
{
this.m_aByParagraphs[this.m_aByParagraphs.length - 1].push(oNewStructure);
}
}
break;
}
case DRAW_COMMAND_TABLE:
{
oNewStructure = new CTableStructure();
break;
}
case DRAW_COMMAND_DRAWING:
{
break;
}
case DRAW_COMMAND_HIDDEN_ELEM:
{
break;
}
case DRAW_COMMAND_TABLE_ROW:
{
this.m_aStackCurRowMaxIndex[this.m_aStackCurRowMaxIndex.length] = -1;
break;
}
}
//console.log("--------End------");
//console.log("CurLineIndex " + this.m_nCurLineIndex);
//console.log("--------End------");
if(oNewStructure)
{
if(this.m_aStack[this.m_aStack.length - 1])
{
this.m_aStack[this.m_aStack.length - 1].m_aContent.push(oNewStructure);
}
this.m_aStack.push(oNewStructure);
}
},
End_Command : function()
{
var nCommandId = this.m_aCommands.pop();
//console.log(GetConstDescription(nCommandId) + " End");
switch(nCommandId)
{
case DRAW_COMMAND_NO_CREATE_GEOM:
{
break;
}
case DRAW_COMMAND_CONTENT:
{
var oDocContentStructure = this.m_aStack.pop();
if(this.m_aStack.length === 0)
{
this.m_oDocContentStructure = oDocContentStructure;
this.m_oDocContentStructure.m_aByLines = this.m_aByLines;
this.m_oDocContentStructure.m_aByParagraphs = this.m_aByParagraphs;
this.m_aByLines = [];
this.m_aByParagraphs = [];
}
if(this.m_bDivByLines)
{
this.m_nCurLineIndex = this.m_aStackLineIndex.pop();
}
break;
}
case DRAW_COMMAND_PARAGRAPH:
{
this.m_aStack.pop();
break;
}
case DRAW_COMMAND_LINE:
{
this.m_aStack.pop();
break;
}
case DRAW_COMMAND_TABLE:
{
this.m_aStack.pop();
break;
}
case DRAW_COMMAND_DRAWING:
{
break;
}
case DRAW_COMMAND_HIDDEN_ELEM:
{
break;
}
case DRAW_COMMAND_TABLE_ROW:
{
this.m_nCurLineIndex = this.m_aStackCurRowMaxIndex.pop();
break;
}
}
},
Get_PathToDraw : function(bStart, bStart2)
{
var oPath = null;
var oLastCommand = this.m_aStack[this.m_aStack.length - 1];
var oLastObjectToDraw, oBrushColor = this.m_oBrush.Color1, oPenColor = this.m_oPen.Color;
if(oLastCommand)
{
switch(oLastCommand.m_nType)
{
case DRAW_COMMAND_LINE:
{
switch(oLastCommand.m_nDrawType)
{
case 0://content
{
if(oLastCommand.m_aContent.length === 0)
{
oLastCommand.m_aContent.push(new ObjectToDraw(this.m_oTextPr.Unifill, this.m_oTextPr.Outline, this.Width, this.Height, new Geometry(), this.m_oTransform, this));
}
oLastObjectToDraw = oLastCommand.m_aContent[oLastCommand.m_aContent.length - 1];
if(bStart2)
{
if(oLastObjectToDraw.geometry.pathLst.length === 0 || (oLastObjectToDraw.geometry.pathLst.length === 1 && oLastObjectToDraw.geometry.pathLst[0].ArrPathCommandInfo.length === 0))
{
oLastObjectToDraw.resetBrushPen(this.m_oTextPr.Unifill, this.m_oTextPr.Outline)
}
else
{
oLastCommand.m_aContent.push(new ObjectToDraw(this.m_oTextPr.Unifill, this.m_oTextPr.Outline, this.Width, this.Height, new Geometry(), this.m_oTransform, this));
oLastObjectToDraw = oLastCommand.m_aContent[oLastCommand.m_aContent.length - 1];
}
}
break;
}
case 1://borders
{
if(oLastCommand.m_aBorders.length === 0)
{
oLastCommand.m_aBorders.push(new ObjectToDraw(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size), this.Width, this.Height, new Geometry(), this.m_oTransform, this))
}
oLastObjectToDraw = oLastCommand.m_aBorders[oLastCommand.m_aBorders.length - 1];
if(bStart2)
{
if(oLastObjectToDraw.geometry.pathLst.length === 0 || (oLastObjectToDraw.geometry.pathLst.length === 1 && oLastObjectToDraw.geometry.pathLst[0].ArrPathCommandInfo.length === 0))
{
oLastObjectToDraw.resetBrushPen(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size));
}
else
{
oLastCommand.m_aBorders.push(new ObjectToDraw(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size), this.Width, this.Height, new Geometry(), this.m_oTransform, this));
oLastObjectToDraw = oLastCommand.m_aBorders[oLastCommand.m_aBorders.length - 1];
}
}
break;
}
case 2://backgrounds
{
if(oLastCommand.m_aBackgrounds.length === 0)
{
oLastCommand.m_aBackgrounds.push(new ObjectToDraw(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size), this.Width, this.Height, new Geometry(), this.m_oTransform, this))
}
oLastObjectToDraw = oLastCommand.m_aBackgrounds[oLastCommand.m_aBackgrounds.length - 1];
if(bStart2)
{
if(oLastObjectToDraw.geometry.pathLst.length === 0 || (oLastObjectToDraw.geometry.pathLst.length === 1 && oLastObjectToDraw.geometry.pathLst[0].ArrPathCommandInfo.length === 0))
{
oLastObjectToDraw.resetBrushPen(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size));
}
else
{
oLastCommand.m_aBackgrounds.push(new ObjectToDraw(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size), this.Width, this.Height, new Geometry(), this.m_oTransform, this));
oLastObjectToDraw = oLastCommand.m_aBackgrounds[oLastCommand.m_aBackgrounds.length - 1];
}
}
break;
}
case 3:
{
if(oLastCommand.m_aUnderlinesStrileouts.length === 0)
{
oBrushColor = this.m_oBrush.Color1;
oPenColor = this.m_oPen.Color;
oLastCommand.m_aUnderlinesStrileouts.push(new ObjectToDraw(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size), this.Width, this.Height, new Geometry(), this.m_oTransform, this))
}
oLastObjectToDraw = oLastCommand.m_aUnderlinesStrileouts[oLastCommand.m_aUnderlinesStrileouts.length - 1];
if(bStart2)
{
if(oLastObjectToDraw.geometry.pathLst.length === 0 || (oLastObjectToDraw.geometry.pathLst.length === 1 && oLastObjectToDraw.geometry.pathLst[0].ArrPathCommandInfo.length === 0))
{
oLastObjectToDraw.resetBrushPen(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size));
}
else
{
oLastCommand.m_aUnderlinesStrileouts.push(new ObjectToDraw(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size), this.Width, this.Height, new Geometry(), this.m_oTransform, this));
oLastObjectToDraw = oLastCommand.m_aUnderlinesStrileouts[oLastCommand.m_aUnderlinesStrileouts.length - 1];
}
}
break;
}
case 4:
{
if(oLastCommand.m_aParagraphBackgrounds.length === 0)
{
oLastCommand.m_aParagraphBackgrounds.push(new ObjectToDraw(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size), this.Width, this.Height, new Geometry(), this.m_oTransform, this))
}
oLastObjectToDraw = oLastCommand.m_aParagraphBackgrounds[oLastCommand.m_aParagraphBackgrounds.length - 1];
if(bStart2)
{
if(oLastObjectToDraw.geometry.pathLst.length === 0 || (oLastObjectToDraw.geometry.pathLst.length === 1 && oLastObjectToDraw.geometry.pathLst[0].ArrPathCommandInfo.length === 0))
{
oLastObjectToDraw.resetBrushPen(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size));
}
else
{
oLastCommand.m_aParagraphBackgrounds.push(new ObjectToDraw(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size), this.Width, this.Height, new Geometry(), this.m_oTransform, this));
oLastObjectToDraw = oLastCommand.m_aParagraphBackgrounds[oLastCommand.m_aParagraphBackgrounds.length - 1];
}
}
break;
}
}
break;
}
case DRAW_COMMAND_TABLE:
{
if(oLastCommand.m_aBorders.length === 0 || bStart2)
{
oBrushColor = this.m_oBrush.Color1;
oPenColor = this.m_oPen.Color;
oLastCommand.m_aBorders.push(new ObjectToDraw(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size), this.Width, this.Height, new Geometry(), this.m_oTransform, this))
}
oLastObjectToDraw = oLastCommand.m_aBorders[oLastCommand.m_aBorders.length - 1];
if(bStart2)
{
if(oLastObjectToDraw.geometry.pathLst.length === 0 || (oLastObjectToDraw.geometry.pathLst.length === 1 && oLastObjectToDraw.geometry.pathLst[0].ArrPathCommandInfo.length === 0))
{
oLastObjectToDraw.resetBrushPen(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size));
}
else
{
oLastCommand.m_aBorders.push(new ObjectToDraw(CreateUnfilFromRGB(oBrushColor.R, oBrushColor.G, oBrushColor.B), CreatePenFromParams(CreateUnfilFromRGB(oPenColor.R, oPenColor.G, oPenColor.B), this.m_oPen.Style, this.m_oPen.LineCap, this.m_oPen.LineJoin, this.m_oPen.LineWidth, this.m_oPen.Size), this.Width, this.Height, new Geometry(), this.m_oTransform, this));
oLastObjectToDraw = oLastCommand.m_aBorders[oLastCommand.m_aBorders.length - 1];
}
}
break;
}
case DRAW_COMMAND_PARAGRAPH:
{
break;
}
}
}
if(oLastObjectToDraw && oLastObjectToDraw.geometry)
{
if(oLastObjectToDraw.geometry.pathLst.length === 0 || bStart)
{
oPath = new Path();
oPath.setPathW(this.pathW);
oPath.setPathH(this.pathH);
oPath.setExtrusionOk(false);
oPath.setFill("norm");
oPath.setStroke(true);
oLastObjectToDraw.geometry.AddPath(oPath)
}
else
{
oPath = oLastObjectToDraw.geometry.pathLst[oLastObjectToDraw.geometry.pathLst.length-1];
}
}
return oPath;
},
transform : function(sx,shy,shx,sy,tx,ty)
{
if (this.m_oTransform.sx != sx || this.m_oTransform.shx != shx || this.m_oTransform.shy != shy ||
this.m_oTransform.sy != sy || this.m_oTransform.tx != tx || this.m_oTransform.ty != ty)
{
this.m_oTransform.sx = sx;
this.m_oTransform.shx = shx;
this.m_oTransform.shy = shy;
this.m_oTransform.sy = sy;
this.m_oTransform.tx = tx;
this.m_oTransform.ty = ty;
}
},
// path commands
_s : function()
{
this.Get_PathToDraw(true);
},
_e : function()
{
},
_z : function()
{
var oPathToDraw = this.Get_PathToDraw();
if(oPathToDraw)
{
oPathToDraw.close();
}
},
_m : function(x,y)
{
var oPathToDraw = this.Get_PathToDraw();
if(oPathToDraw)
{
oPathToDraw.moveTo(this.xKoeff*x, this.yKoeff*y);
}
},
_l : function(x,y)
{
var oPathToDraw = this.Get_PathToDraw();
if(oPathToDraw)
{
oPathToDraw.lnTo(this.xKoeff*x, this.yKoeff*y);
}
},
_c : function(x1,y1,x2,y2,x3,y3)
{
var oPathToDraw = this.Get_PathToDraw();
if(oPathToDraw)
{
oPathToDraw.cubicBezTo(this.xKoeff*x1, this.yKoeff*y1, this.xKoeff*x2, this.yKoeff*y2, this.xKoeff*x3, this.yKoeff*y3);
}
},
_c2 : function(x1,y1,x2,y2)
{
var oPathToDraw = this.Get_PathToDraw();
if(oPathToDraw)
{
oPathToDraw.quadBezTo(this.xKoeff*x1, this.yKoeff*y1, this.xKoeff*x2, this.yKoeff*y2);
}
},
ds : function()
{
},
df : function()
{
},
drawpath : function(type)
{
},
// canvas state
save : function()
{
},
restore : function()
{
},
clip : function()
{
},
SetIntegerGrid: function()
{
},
// images
drawImage : function(img,x,y,w,h)
{
},
SetFont : function(font)
{
if (null == font)
return;
var style = 0;
if (font.Italic == true)
style += 2;
if (font.Bold == true)
style += 1;
var fontinfo = g_fontApplication.GetFontInfo(font.FontFamily.Name, style, this.LastFontOriginInfo);
style = fontinfo.GetBaseStyle(style);
if (this.m_oFont.Name != fontinfo.Name)
{
this.m_oFont.Name = fontinfo.Name;
}
if (this.m_oFont.FontSize != font.FontSize)
{
this.m_oFont.FontSize = font.FontSize;
}
if (this.m_oFont.Style != style)
{
this.m_oFont.Style = style;
}
},
FillText : function(x,y,text)
{
this.FillTextCode(x, y, text.charCodeAt(0));
},
FillTextCode : function(x,y,code)
{
var _font_info = window.g_font_infos[window.g_map_font_index[this.m_oFont.Name]];
//var _is_face_index_no_0 = (_font_info.faceIndexR <= 0 && _font_info.faceIndexI <= 0 && _font_info.faceIndexB <= 0 && _font_info.faceIndexBI <= 0);
//
//if (code < 0xFFFF && (_is_face_index_no_0 || window["native"] !== undefined))
// return;
g_fontApplication.LoadFont(_font_info.Name, window.g_font_loader, g_oTextMeasurer.m_oManager, this.m_oFont.FontSize, Math.max(this.m_oFont.Style, 0), 72, 72);
if (null != this.LastFontOriginInfo.Replace)
{
code = g_fontApplication.GetReplaceGlyph(code, this.LastFontOriginInfo.Replace);
}
g_oTextMeasurer.m_oManager.LoadStringPathCode(code, false, x, y, this);
},
tg : function(gid,x,y)
{
g_fontApplication.LoadFont(this.m_oFont.Name, window.g_font_loader, g_oTextMeasurer.m_oManager, this.m_oFont.FontSize, Math.max(this.m_oFont.Style, 0), 72, 72);
g_oTextMeasurer.m_oManager.LoadStringPathCode(gid, true, x, y, this);
},
charspace : function(space)
{
},
beginCommand : function(command)
{
},
endCommand : function(command)
{
},
put_PenLineJoin : function(_join)
{
},
put_TextureBounds : function(x, y, w, h)
{
},
put_TextureBoundsEnabled : function(bIsEnabled)
{
},
SetFontSlot : function(slot, fontSizeKoef)
{
var _rfonts = this.m_oGrFonts;
var _lastFont = this.m_oFontSlotFont;
switch (slot)
{
case fontslot_ASCII:
{
_lastFont.Name = _rfonts.Ascii.Name;
_lastFont.Size = this.m_oTextPr.FontSize;
_lastFont.Bold = this.m_oTextPr.Bold;
_lastFont.Italic = this.m_oTextPr.Italic;
break;
}
case fontslot_CS:
{
_lastFont.Name = _rfonts.CS.Name;
_lastFont.Size = this.m_oTextPr.FontSizeCS;
_lastFont.Bold = this.m_oTextPr.BoldCS;
_lastFont.Italic = this.m_oTextPr.ItalicCS;
break;
}
case fontslot_EastAsia:
{
_lastFont.Name = _rfonts.EastAsia.Name;
_lastFont.Size = this.m_oTextPr.FontSize;
_lastFont.Bold = this.m_oTextPr.Bold;
_lastFont.Italic = this.m_oTextPr.Italic;
break;
}
case fontslot_HAnsi:
default:
{
_lastFont.Name = _rfonts.HAnsi.Name;
_lastFont.Size = this.m_oTextPr.FontSize;
_lastFont.Bold = this.m_oTextPr.Bold;
_lastFont.Italic = this.m_oTextPr.Italic;
break;
}
}
if (undefined !== fontSizeKoef)
_lastFont.Size *= fontSizeKoef;
var style = 0;
if (_lastFont.Italic == true)
style += 2;
if (_lastFont.Bold == true)
style += 1;
var fontinfo = g_fontApplication.GetFontInfo(_lastFont.Name, style, this.LastFontOriginInfo);
style = fontinfo.GetBaseStyle(style);
if (this.m_oFont.Name != fontinfo.Name)
{
this.m_oFont.Name = fontinfo.Name;
}
if (this.m_oFont.FontSize != _lastFont.Size)
{
this.m_oFont.FontSize = _lastFont.Size;
}
if (this.m_oFont.Style != style)
{
this.m_oFont.Style = style;
}
},
BeginPage : function(width,height)
{
},
EndPage : function()
{
},
transform3 : function(m)
{
this.transform(m.sx, m.shy, m.shx, m.sy, m.tx, m.ty);
},
reset : function()
{
this.transform(1, 0, 0, 1, 0, 0);
},
FillText2 : function(x,y,text)
{
this.FillText(x,y,text);
},
GetIntegerGrid : function()
{
},
GetFont : function()
{
return this.m_oFont;
},
put_GlobalAlpha : function(enable, alpha)
{
},
Start_GlobalAlpha : function()
{
},
End_GlobalAlpha : function()
{
},
DrawHeaderEdit : function(yPos)
{
},
DrawFooterEdit : function(yPos)
{
},
drawCollaborativeChanges : function(x, y, w, h)
{
},
drawSearchResult : function(x, y, w, h)
{
},
DrawEmptyTableLine : function(x1,y1,x2,y2)
{
// эта функция не для печати или сохранения вообще
},
DrawLockParagraph : function(lock_type, x, y1, y2)
{
// эта функция не для печати или сохранения вообще
},
DrawLockObjectRect : function(lock_type, x, y, w, h)
{
// эта функция не для печати или сохранения вообще
},
DrawSpellingLine : function(y0, x0, x1, w)
{
},
// smart methods for horizontal / vertical lines
drawHorLine : function(align, y, x, r, penW)
{
this.p_width(1000 * penW);
this._s();
var _y = y;
switch (align)
{
case 0:
{
_y = y + penW / 2;
break;
}
case 1:
{
break;
}
case 2:
{
_y = y - penW / 2;
}
}
this._m(x, y);
this._l(r, y);
this.ds();
this._e();
},
drawHorLine2 : function(align, y, x, r, penW)
{
this.p_width(1000 * penW);
var _y = y;
switch (align)
{
case 0:
{
_y = y + penW / 2;
break;
}
case 1:
{
break;
}
case 2:
{
_y = y - penW / 2;
break;
}
}
this._s();
this._m(x, (_y - penW));
this._l(r, (_y - penW));
this.ds();
this._s();
this._m(x, (_y + penW));
this._l(r, (_y + penW));
this.ds();
this._e();
},
drawVerLine : function(align, x, y, b, penW)
{
this.p_width(1000 * penW);
this._s();
var _x = x;
switch (align)
{
case 0:
{
_x = x + penW / 2;
break;
}
case 1:
{
break;
}
case 2:
{
_x = x - penW / 2;
}
}
this._m(_x, y);
this._l(_x, b);
this.ds();
},
// мега крутые функции для таблиц
drawHorLineExt : function(align, y, x, r, penW, leftMW, rightMW)
{
this.drawHorLine(align, y, x + leftMW, r + rightMW, penW);
},
rect : function(x,y,w,h)
{
var _x = x;
var _y = y;
var _r = (x + w);
var _b = (y + h);
this._s();
this._m(_x, _y);
this._l(_r, _y);
this._l(_r, _b);
this._l(_x, _b);
this._l(_x, _y);
},
TableRect : function(x,y,w,h)
{
this.rect(x,y,w,h);
this.df();
},
// функции клиппирования
AddClipRect : function(x, y, w, h)
{
/*
this.b_color1(0, 0, 0, 255);
this.rect(x, y, w, h);
this.df();
return;
*/
var __rect = new _rect();
__rect.x = x;
__rect.y = y;
__rect.w = w;
__rect.h = h;
this.GrState.AddClipRect(__rect);
},
RemoveClipRect : function()
{
//this.ClipManager.RemoveRect();
},
SetClip : function(r)
{
//this._s();
},
RemoveClip : function()
{
},
GetTransform : function()
{
return this.m_oTransform;
},
GetLineWidth : function()
{
return 0;
},
GetPen : function()
{
return 0;
},
GetBrush : function()
{
return 0;
},
drawFlowAnchor : function(x, y)
{
},
SavePen : function()
{
this.GrState.SavePen();
},
RestorePen : function()
{
this.GrState.RestorePen();
},
SaveBrush : function()
{
this.GrState.SaveBrush();
},
RestoreBrush : function()
{
this.GrState.RestoreBrush();
},
SavePenBrush : function()
{
this.GrState.SavePenBrush();
},
RestorePenBrush : function()
{
this.GrState.RestorePenBrush();
},
SaveGrState : function()
{
this.GrState.SaveGrState();
},
RestoreGrState : function()
{
this.GrState.RestoreGrState();
},
StartClipPath : function()
{
this.private_removeVectors();
},
EndClipPath : function()
{
this.private_restoreVectors();
},
SetTextPr : function(textPr, theme)
{
this.m_oTextPr = textPr;
if (theme)
this.m_oGrFonts.checkFromTheme(theme.themeElements.fontScheme, this.m_oTextPr.RFonts);
else
this.m_oGrFonts = this.m_oTextPr.RFonts;
this.Get_PathToDraw(false, true);
},
GetTextPr : function()
{
return this.m_oTextPr;
},
DrawPresentationComment : function(type, x, y, w, h)
{
},
private_removeVectors : function()
{
},
private_restoreVectors : function()
{
}
};
function PolygonWrapper(oPolygon)
{
this.oPolygon = oPolygon;
var dCurLen = 0;
this.aLength = [];
this.aLength[0] = 0;
var oPrevPoint = oPolygon[0], oCurPoint, dDX, dDY;
for(var i = 1; i < oPolygon.length; ++i)
{
oCurPoint = oPolygon[i];
dDX = oCurPoint.x - oPrevPoint.x;
dDY = oCurPoint.y - oPrevPoint.y;
dCurLen += Math.sqrt(dDX* dDX + dDY*dDY);
this.aLength[i] = dCurLen;
oPrevPoint = oCurPoint;
}
this.dLen = dCurLen;
this.nPointsCount = this.aLength.length;
}
PolygonWrapper.prototype.getPointOnPolygon = function(dCT)
{
var dFindLen = this.dLen * dCT;
var nIndex = this.nPointsCount >> 1;
var nStartIndex = 0, nDelta = nIndex - nStartIndex, dNextBool, nTempIndex;
nTempIndex = nIndex + 1;
dNextBool = (nTempIndex < this.nPointsCount) && (this.aLength[nTempIndex] <= dFindLen);
while(nDelta > 0 && (this.aLength[nIndex] > dFindLen || dNextBool))
{
if(dNextBool)
{
nStartIndex = nIndex;
}
nIndex = nStartIndex + (nDelta >> 1);
nTempIndex = nIndex + 1;
dNextBool = (nTempIndex < this.nPointsCount) && (this.aLength[nTempIndex] <= dFindLen);
nDelta = nIndex - nStartIndex;
}
if(nTempIndex === this.nPointsCount)
{
--nTempIndex;
--nIndex;
}
var t;
var dDiv = this.aLength[nTempIndex] - this.aLength[nIndex];
if(dDiv !== 0)
{
t = (dFindLen - this.aLength[nIndex])/dDiv;
}
else
{
t = 0;
}
var oPoint1 = this.oPolygon[nIndex], oPoint2 = this.oPolygon[nTempIndex];
return {x: oPoint1.x + t*(oPoint2.x - oPoint1.x ), y: oPoint1.y + t*(oPoint2.y - oPoint1.y )};
};
function CheckPointByPaths(dX, dY, dWidth, dHeight, dMinX, dMinY, oPolygonWrapper1, oPolygonWrapper2)
{
var cX, cY, point, topX, topY, bottomX, bottomY;
cX = (dX - dMinX)/dWidth;
cY = (dY - dMinY)/dHeight;
if(cX > 1)
{
cX = 1;
}
if(cX < 0)
{
cX = 0;
}
point = oPolygonWrapper1.getPointOnPolygon(cX);
topX = point.x;
topY = point.y;
point = oPolygonWrapper2.getPointOnPolygon(cX);
bottomX = point.x;
bottomY = point.y;
return {x: topX + cY*(bottomX - topX), y: topY + cY*(bottomY - topY)};
}
function ObjectsToDrawBetweenTwoPolygons(aObjectsToDraw, oBoundsController, oPolygonWrapper1, oPolygonWrapper2)
{
var i, j, t, dMinX = oBoundsController.min_x, dMinY = oBoundsController.min_y, aPathLst, dWidth = oBoundsController.max_x - oBoundsController.min_x, dHeight = oBoundsController.max_y - oBoundsController.min_y;
var oCommand, oPoint, oPath;
for(i = 0; i < aObjectsToDraw.length; ++i)
{
aPathLst = aObjectsToDraw[i].geometry.pathLst;
for(t = 0; t < aPathLst.length; ++t)
{
oPath = aPathLst[t];
for(j = 0; j < oPath.ArrPathCommand.length; ++j)
{
oCommand = oPath.ArrPathCommand[j];
switch(oCommand.id)
{
case moveTo:
case lineTo:
{
oPoint = CheckPointByPaths(oCommand.X, oCommand.Y, dWidth, dHeight, dMinX, dMinY, oPolygonWrapper1, oPolygonWrapper2);
oCommand.X = oPoint.x;
oCommand.Y = oPoint.y;
break;
}
case bezier3:
{
oPoint = CheckPointByPaths(oCommand.X0, oCommand.Y0, dWidth, dHeight, dMinX, dMinY, oPolygonWrapper1, oPolygonWrapper2);
oCommand.X0 = oPoint.x;
oCommand.Y0 = oPoint.y;
oPoint = CheckPointByPaths(oCommand.X1, oCommand.Y1, dWidth, dHeight, dMinX, dMinY, oPolygonWrapper1, oPolygonWrapper2);
oCommand.X1 = oPoint.x;
oCommand.Y1 = oPoint.y;
break;
}
case bezier4:
{
oPoint = CheckPointByPaths(oCommand.X0, oCommand.Y0, dWidth, dHeight, dMinX, dMinY, oPolygonWrapper1, oPolygonWrapper2);
oCommand.X0 = oPoint.x;
oCommand.Y0 = oPoint.y;
oPoint = CheckPointByPaths(oCommand.X1, oCommand.Y1, dWidth, dHeight, dMinX, dMinY, oPolygonWrapper1, oPolygonWrapper2);
oCommand.X1 = oPoint.x;
oCommand.Y1 = oPoint.y;
oPoint = CheckPointByPaths(oCommand.X2, oCommand.Y2, dWidth, dHeight, dMinX, dMinY, oPolygonWrapper1, oPolygonWrapper2);
oCommand.X2 = oPoint.x;
oCommand.Y2 = oPoint.y;
break;
}
case arcTo:
{
break;
}
case close:
{
break;
}
}
}
}
}
}
\ No newline at end of file
......@@ -160,7 +160,7 @@
<script src="../Excel/model/DrawingObjects/Graphics.js"></script>
<script src="model/DrawingObjects/Overlay.js"></script>
<script src="../Word/Drawing/Controls.js"></script>
<script src="../Common/Controls.js"></script>
<script src="../Excel/model/DrawingObjects/ShapeDrawer.js"></script>
<!--<script src="../Word/Editor/CollaborativeEditing.js"></script>-->
......
......@@ -145,7 +145,7 @@
<script src="../Excel/model/DrawingObjects/Graphics.js"></script>
<script src="model/DrawingObjects/Overlay.js"></script>
<script src="../Word/Drawing/Controls.js"></script>
<script src="../Common/Controls.js"></script>
<script src="../Excel/model/DrawingObjects/ShapeDrawer.js"></script>
<!--<script src="../Word/Editor/CollaborativeEditing.js"></script>-->
......
......@@ -356,7 +356,9 @@
<script src="../../../../OfficeWeb/Common/Drawings/Format/ChartSpace.js"></script>
<script src="../../../../OfficeWeb/Common/Drawings/Format/ChartFormat.js"></script>
<script src="../../../../OfficeWeb/Common/Drawings/Format/TextBody.js"></script>
<script src="../../../../OfficeWeb/Word/Drawing/Controls.js"></script>
<script src="../../../../OfficeWeb/Common/Drawings/TextDrawer.js"></script>
<script src="../../../../OfficeWeb/Common/Controls.js"></script>
<script src="../../../../OfficeWeb/Excel/view/DrawingObjectsController.js"></script>
......
......@@ -321,7 +321,7 @@
<script src="../../../../OfficeWeb/Common/Drawings/Format/ChartSpace.js"></script>
<script src="../../../../OfficeWeb/Common/Drawings/Format/ChartFormat.js"></script>
<script src="../../../../OfficeWeb/Common/Drawings/Format/TextBody.js"></script>
<script src="../../../../OfficeWeb/Word/Drawing/Controls.js"></script>
<script src="../../../../OfficeWeb/Common/Controls.js"></script>
<script src="../../../../OfficeWeb/Excel/view/DrawingObjectsController.js"></script>
......
......@@ -79,7 +79,7 @@
<script type="text/javascript" src="../Word/Drawing/GraphicsEvents.js"></script>
<script type="text/javascript" src="../Word/Drawing/WorkEvents.js"></script>
<script type="text/javascript" src="../Word/Drawing/Controls.js"></script>
<script type="text/javascript" src="../Common/Controls.js"></script>
<script type="text/javascript" src="../Word/Drawing/Rulers.js"></script>
<script type="text/javascript" src="../Word/Editor/Table.js"></script>
<script type="text/javascript" src="../Word/Editor/Common.js"></script>
......
......@@ -286,7 +286,7 @@
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/GraphicsEvents.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/WorkEvents.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/Controls.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/Controls.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/Rulers.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Editor/Table.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Editor/Common.js"></script>
......@@ -350,8 +350,10 @@
<script src="../../../../OfficeWeb/Common/Drawings/Format/ChartSpace.js"></script>
<script src="../../../../OfficeWeb/Common/Drawings/Format/ChartFormat.js"></script>
<script src="../../../../OfficeWeb/Common/Drawings/Format/TextBody.js"></script>
<script src="../../../../OfficeWeb/Common/Drawings/TextDrawer.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/PowerPoint/Editor/Format/Slide.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/PowerPoint/Editor/Format/Slide.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/PowerPoint/Editor/Format/SlideMaster.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/PowerPoint/Editor/Format/Layout.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/PowerPoint/Editor/Format/Comments.js"></script>
......
......@@ -93,7 +93,7 @@
<script type="text/javascript" src="Drawing/GraphicsEvents.js"></script>
<script type="text/javascript" src="../Common/Scrolls/iscroll.js"></script>
<script type="text/javascript" src="Drawing/WorkEvents.js"></script>
<script type="text/javascript" src="Drawing/Controls.js"></script>
<script type="text/javascript" src="../Common/Controls.js"></script>
<script type="text/javascript" src="Drawing/Rulers.js"></script>
<script type="text/javascript" src="Drawing/HtmlPage.js"></script>
<script type="text/javascript" src="Drawing/documentrenderer.js"></script>
......
......@@ -172,7 +172,7 @@
<script type="text/javascript" src="Drawing/GraphicsEvents.js"></script>
<script type="text/javascript" src="../Common/Scrolls/iscroll.js"></script>
<script type="text/javascript" src="Drawing/WorkEvents.js"></script>
<script type="text/javascript" src="Drawing/Controls.js"></script>
<script type="text/javascript" src="../Common/Controls.js"></script>
<script type="text/javascript" src="Drawing/Rulers.js"></script>
<script type="text/javascript" src="Drawing/HtmlPage.js"></script>
<script type="text/javascript" src="Drawing/documentrenderer.js"></script>
......
......@@ -321,6 +321,7 @@
<script type="text/javascript" src="../../../../OfficeWeb/Common/Drawings/Format/Geometry.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/Drawings/Format/Path.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/Drawings/Format/TextBody.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/Drawings/TextDrawer.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Editor/GraphicObjects/Format/ShapePrototype.js"></script>
......@@ -374,7 +375,7 @@
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/GraphicsEvents.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/Scrolls/iscroll.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/WorkEvents.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/Controls.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/Controls.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/Rulers.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/HtmlPage.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/documentrenderer.js"></script>
......
......@@ -163,7 +163,7 @@
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/GraphicsEvents.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/Scrolls/iscroll.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/WorkEvents.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/Controls.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/Controls.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/Rulers.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/HtmlPage.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Word/Drawing/documentrenderer.js"></script>
......
......@@ -99,7 +99,7 @@
<script type="text/javascript" src="../../OfficeWeb/Word/Drawing/GraphicsEvents.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Common/Scrolls/iscroll.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Word/Drawing/WorkEvents.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Word/Drawing/Controls.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Common/Controls.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Word/Drawing/Rulers.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Word/Drawing/HtmlPage.js"></script>
<script type="text/javascript" src="../../OfficeWeb/Word/Drawing/documentrenderer.js"></script>
......
......@@ -140,7 +140,7 @@
<script type="text/javascript" src="Drawing/GraphicsEvents.js"></script>
<script type="text/javascript" src="../Common/Scrolls/iscroll.js"></script>
<script type="text/javascript" src="Drawing/WorkEvents.js"></script>
<script type="text/javascript" src="Drawing/Controls.js"></script>
<script type="text/javascript" src="../Common/Controls.js"></script>
<script type="text/javascript" src="Drawing/Rulers.js"></script>
<script type="text/javascript" src="Drawing/HtmlPage.js"></script>
<script type="text/javascript" src="Drawing/documentrenderer.js"></script>
......
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