Commit 7ca36eaf authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander.Trofimov

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54304 954022d7-b5bf-4e40-9824-e11837661b57
parent d6ce1323
......@@ -115,7 +115,12 @@ CDrawingDocument.prototype =
// convert coords
ConvertCoordsToCursorWR : function(x, y, pageIndex, transform)
{
var _return = this.Native["ConvertCoordsToCursor"](x, y, pageIndex, transform);
var _return = null;
if (!transform)
_return = this.Native["ConvertCoordsToCursor"](x, y, pageIndex);
else
_return = this.Native["ConvertCoordsToCursor"](x, y, pageIndex,
transform.sx, transform.shy, transform.shx, transform.sy, transform.tx, transform.ty);
return { X : _return[0], Y : _return[1], Error: _return[2] };
},
......
function CDrawingStream()
{
this.Native = null;
}
\ No newline at end of file
this.m_oTextPr = null;
this.m_oLastFont = new CFontSetup();
this.IsUseFonts2 = false;
this.m_oLastFont2 = null;
this.m_bIntegerGrid = true;
}
CDrawingStream.prototype =
{
EndDraw : function()
{
// not used
},
put_GlobalAlpha : function(enable, alpha)
{
this.Native["put_GlobalAlpha"](enable, alpha);
},
Start_GlobalAlpha : function()
{
// nothing
},
End_GlobalAlpha : function()
{
this.Native["End_GlobalAlpha"]();
},
// pen methods
p_color : function(r,g,b,a)
{
this.Native["p_color"](r,g,b,a);
},
p_width : function(w)
{
this.Native["p_width"](w);
},
// brush methods
b_color1 : function(r,g,b,a)
{
this.Native["b_color1"](r,g,b,a);
},
b_color2 : function(r,g,b,a)
{
this.Native["b_color2"](r,g,b,a);
},
transform : function(sx,shy,shx,sy,tx,ty)
{
this.Native["transform"](sx,shy,shx,sy,tx,ty);
},
CalculateFullTransform : function(isInvertNeed)
{
this.Native["CalculateFullTransform"](isInvertNeed);
},
// path commands
_s : function()
{
this.Native["_s"]();
},
_e : function()
{
this.Native["_e"]();
},
_z : function()
{
this.Native["_z"]();
},
_m : function(x,y)
{
this.Native["_m"](x,y);
},
_l : function(x,y)
{
this.Native["_l"](x,y);
},
_c : function(x1,y1,x2,y2,x3,y3)
{
this.Native["_c"](x1,y1,x2,y2,x3,y3);
},
_c2 : function(x1,y1,x2,y2)
{
this.Native["_c2"](x1,y1,x2,y2);
},
ds : function()
{
this.Native["ds"]();
},
df : function()
{
this.Native["df"]();
},
// canvas state
save : function()
{
this.Native["save"]();
},
restore : function()
{
this.Native["restore"]();
},
clip : function()
{
this.Native["clip"]();
},
reset : function()
{
this.Native["reset"]();
},
transform3 : function(m, isNeedInvert)
{
this.Native["transform3"](m.sx,m.shy,m.shx,m.sy,m.tx,m.ty,isNeedInvert);
},
FreeFont : function()
{
this.Native["FreeFont"]();
},
// images
drawImage : function(img,x,y,w,h,alpha,srcRect)
{
if (!srcRect)
return this.Native["drawImage"](img,x,y,w,h,alpha);
return this.Native["drawImage"](img,x,y,w,h,alpha,srcRect.l,srcRect.t,srcRect.r,srcRect.b);
},
// text
GetFont : function()
{
return this.m_oCurFont;
},
font : function(font_id,font_size)
{
this.Native["font"](font_id, font_size);
},
SetFont : function(font)
{
if (null == font)
return;
this.m_oCurFont =
{
FontFamily :
{
Index : font.FontFamily.Index,
Name : font.FontFamily.Name
},
FontSize : font.FontSize,
Bold : font.Bold,
Italic : font.Italic
};
if (-1 == font.FontFamily.Index || undefined === font.FontFamily.Index || null == font.FontFamily.Index)
font.FontFamily.Index = window.g_map_font_index[font.FontFamily.Name];
if (font.FontFamily.Index == undefined || font.FontFamily.Index == -1)
return;
var bItalic = true === font.Italic;
var bBold = true === font.Bold;
var oFontStyle = FontStyle.FontStyleRegular;
if ( !bItalic && bBold )
oFontStyle = FontStyle.FontStyleBold;
else if ( bItalic && !bBold )
oFontStyle = FontStyle.FontStyleItalic;
else if ( bItalic && bBold )
oFontStyle = FontStyle.FontStyleBoldItalic;
var _info = GetLoadInfoForMeasurer(window.g_font_infos[font.FontFamily.Index], oFontStyle);
var flag = 0;
if (_info.NeedBold) flag |= 0x01;
if (_info.NeedItalic) flag |= 0x02;
if (_info.SrcBold) flag |= 0x04;
if (_info.SrcItalic) flag |= 0x08;
this.Native["LoadFont"](_info.Path, _info.FaceIndex, font.FontSize, flag);
},
SetTextPr : function(textPr)
{
this.m_oTextPr = textPr;
},
GetTextPr : function()
{
return this.m_oTextPr;
},
SetFontSlot : function(slot, fontSizeKoef)
{
var _rfonts = this.m_oTextPr.RFonts;
var _lastFont = this.IsUseFonts2 ? this.m_oLastFont2 : this.m_oLastFont;
switch (slot)
{
case fontslot_ASCII:
{
_lastFont.Name = _rfonts.Ascii.Name;
_lastFont.Index = _rfonts.Ascii.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.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.Index = _rfonts.CS.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.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.Index = _rfonts.EastAsia.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.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.Index = _rfonts.HAnsi.Index;
if (_lastFont.Index == -1 || _lastFont.Index === undefined)
{
_lastFont.Index = window.g_map_font_index[_lastFont.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)
_style += 2;
if (_lastFont.Bold)
_style += 1;
if (_lastFont.Index != _lastFont.SetUpIndex || _lastFont.Size != _lastFont.SetUpSize || _style != _lastFont.SetUpStyle)
{
_lastFont.SetUpIndex = _lastFont.Index;
_lastFont.SetUpSize = _lastFont.Size;
_lastFont.SetUpStyle = _style;
var _info = GetLoadInfoForMeasurer(window.g_font_infos[_lastFont.SetUpIndexx], _style);
var flag = 0;
if (_info.NeedBold) flag |= 0x01;
if (_info.NeedItalic) flag |= 0x02;
if (_info.SrcBold) flag |= 0x04;
if (_info.SrcItalic) flag |= 0x08;
this.Native["LoadFont"](_info.Path, _info.FaceIndex, font.FontSize, flag);
}
},
FillText : function(x,y,text)
{
this.Native["FillText"](x,y,text.charCodeAt(0));
},
t : function(text,x,y)
{
var _arr = [];
var _len = text.length;
for (var i = 0; i < _len; i++)
_arr.push(text.charCodeAt(i));
this.Native["Text"](x,y,_arr);
},
FillText2 : function(x,y,text,cropX,cropW)
{
this.Native["FillText2"](x,y,text.charCodeAt(0),cropX,cropW);
},
t2 : function(text,x,y,cropX,cropW)
{
var _arr = [];
var _len = text.length;
for (var i = 0; i < _len; i++)
_arr.push(text.charCodeAt(i));
this.Native["Text2"](x,y,_arr,cropX,cropW);
},
FillTextCode : function(x,y,lUnicode)
{
this.Native["FillText"](x,y,lUnicode);
},
tg : function(text,x,y)
{
this.Native["FillTextG"](x,y,text);
},
charspace : function(space)
{
// nothing
},
SetIntegerGrid : function(param)
{
this.m_bIntegerGrid = param;
this.Native["SetIntegerGrid"](param);
},
GetIntegerGrid : function()
{
return this.m_bIntegerGrid;
},
DrawHeaderEdit : function(yPos, lock_type)
{
this.Native["DrawHeaderEdit"](yPos, lock_type);
},
DrawFooterEdit : function(yPos, lock_type)
{
this.Native["DrawFooterEdit"](yPos, lock_type);
},
DrawLockParagraph : function(lock_type, x, y1, y2)
{
this.Native["DrawLockParagraph"](lock_type, x, y1, y2);
},
DrawLockObjectRect : function(lock_type, x, y, w, h)
{
this.Native["DrawLockObjectRect"](lock_type, x, y, w, h);
},
DrawEmptyTableLine : function(x1,y1,x2,y2)
{
this.Native["DrawEmptyTableLine"](x1,y1,x2,y2);
},
DrawSpellingLine : function(y0, x0, x1, w)
{
this.Native["DrawSpellingLine"](y0, x0, x1, w);
},
// smart methods for horizontal / vertical lines
drawHorLine : function(align, y, x, r, penW)
{
this.Native["drawHorLine"](align, y, x, r, penW);
},
drawHorLine2 : function(align, y, x, r, penW)
{
this.Native["drawHorLine2"](align, y, x, r, penW);
},
drawVerLine : function(align, x, y, b, penW)
{
this.Native["drawVerLine"](align, x, y, b, penW);
},
// мега крутые функции для таблиц
drawHorLineExt : function(align, y, x, r, penW, leftMW, rightMW)
{
this.Native["drawHorLineExt"](align, y, x, r, penW, leftMW, rightMW);
},
rect : function(x,y,w,h)
{
this.Native["rect"](x,y,w,h);
},
TableRect : function(x,y,w,h)
{
this.Native["TableRect"](x,y,w,h);
},
// функции клиппирования
AddClipRect : function(x, y, w, h)
{
this.Native["AddClipRect"](x,y,w,h);
},
RemoveClipRect : function()
{
// nothing
},
SetClip : function(r)
{
this.Native["SetClip"](r.x, r.y, r.w, r.h);
},
RemoveClip : function()
{
this.Native["RemoveClip"]();
},
drawCollaborativeChanges : function(x, y, w, h)
{
this.Native["drawCollaborativeChanges"](x, y, w, h);
},
drawSearchResult : function(x, y, w, h)
{
this.Native["drawSearchResult"](x, y, w, h);
},
drawFlowAnchor : function(x, y)
{
this.Native["drawFlowAnchor"](x, y);
},
SavePen : function()
{
this.Native["SavePen"]();
},
RestorePen : function()
{
this.Native["RestorePen"]();
},
SaveBrush : function()
{
this.Native["SaveBrush"]();
},
RestoreBrush : function()
{
this.Native["RestoreBrush"]();
},
SavePenBrush : function()
{
this.Native["SavePenBrush"]();
},
RestorePenBrush : function()
{
this.Native["RestorePenBrush"]();
},
SaveGrState : function()
{
this.Native["SaveGrState"]();
},
RestoreGrState : function()
{
this.Native["RestoreGrState"]();
},
StartClipPath : function()
{
// nothing
},
EndClipPath : function()
{
this.Native["Clip"]();
},
StartCheckTableDraw : function()
{
return this.Native["StartCheckTableDraw"]();
},
EndCheckTableDraw : function(bIsRestore)
{
return this.Native["EndCheckTableDraw"](bIsRestore);
},
SetTextClipRect : function(_l, _t, _r, _b)
{
return this.Native["SetTextClipRect"](_l, _t, _r, _b);
},
AddSmartRect : function(x, y, w, h, pen_w)
{
return this.Native["SetTextClipRect"](x, y, w, h, pen_w);
},
CheckUseFonts2 : function(m)
{
this.IsUseFonts2 = this.Native["CheckUseFonts2"](m.sx,m.shy,m.shx,m.sy,m.tx,m.ty);
if (this.IsUseFonts2)
{
if (null == this.m_oLastFont2)
this.m_oLastFont2 = new CFontSetup();
}
},
UncheckUseFonts2 : function()
{
this.IsUseFonts2 = false;
},
Drawing_StartCheckBounds : function(x, y, w, h)
{
},
Drawing_EndCheckBounds : function()
{
},
DrawPresentationComment : function(type, x, y, w, h)
{
return this.Native["DrawPresentationComment"](type, x, y, w, h);
}
};
\ No newline at end of file
function CShapeDrawer()
{
this.Shape = null;
this.Graphics = null;
this.UniFill = null;
this.Ln = null;
this.Transform = null;
this.bIsTexture = false;
this.bIsNoFillAttack = false;
this.bIsNoStrokeAttack = false;
this.FillUniColor = null;
this.StrokeUniColor = null;
this.StrokeWidth = 0;
this.min_x = 0xFFFF;
this.min_y = 0xFFFF;
this.max_x = -0xFFFF;
this.max_y = -0xFFFF;
this.bIsCheckBounds = false;
this.IsRectShape = false;
}
CShapeDrawer.prototype =
{
Clear : function()
{
this.Shape = null;
this.Graphics = null;
this.UniFill = null;
this.Ln = null;
this.Transform = null;
this.bIsTexture = false;
this.bIsNoFillAttack = false;
this.bIsNoStrokeAttack = false;
this.FillUniColor = null;
this.StrokeUniColor = null;
this.StrokeWidth = 0;
this.min_x = 0xFFFF;
this.min_y = 0xFFFF;
this.max_x = -0xFFFF;
this.max_y = -0xFFFF;
this.bIsCheckBounds = false;
this.IsRectShape = false;
},
CheckPoint : function(x, y)
{
if (x < this.min_x)
this.min_x = x;
if (y < this.min_y)
this.min_y = y;
if (x > this.max_x)
this.max_x = x;
if (y > this.max_y)
this.max_y = y;
},
fromShape2 : function(shape, graphics, geom)
{
this.fromShape(shape, graphics);
if (!geom)
{
this.IsRectShape = true;
}
else
{
if (geom.preset == "rect")
this.IsRectShape = true;
}
},
fromShape : function(shape, graphics)
{
this.IsRectShape = false;
this.Shape = shape;
this.Graphics = graphics;
this.UniFill = shape.brush;
this.Ln = shape.pen;
this.Transform = shape.TransformMatrix;
this.min_x = 0xFFFF;
this.min_y = 0xFFFF;
this.max_x = -0xFFFF;
this.max_y = -0xFFFF;
var bIsCheckBounds = false;
if (this.UniFill == null || this.UniFill.fill == null)
this.bIsNoFillAttack = true;
else
{
var _fill = this.UniFill.fill;
switch (_fill.type)
{
case FILL_TYPE_BLIP:
{
this.bIsTexture = true;
break;
}
case FILL_TYPE_SOLID:
{
this.FillUniColor = _fill.color.RGBA;
break;
}
case FILL_TYPE_GRAD:
{
bIsCheckBounds = true;
break;
}
case FILL_TYPE_PATT:
{
bIsCheckBounds = true;
break;
}
case FILL_TYPE_NOFILL:
{
this.bIsNoFillAttack = true;
break;
}
default:
{
this.bIsNoFillAttack = true;
break;
}
}
}
if (this.Ln == null || this.Ln.Fill == null || this.Ln.Fill.fill == null)
this.bIsNoStrokeAttack = true;
else
{
var _fill = this.Ln.Fill.fill;
switch (_fill.type)
{
case FILL_TYPE_BLIP:
{
this.StrokeUniColor = new CUniColor().RGBA;
break;
}
case FILL_TYPE_SOLID:
{
this.StrokeUniColor = _fill.color.RGBA;
break;
}
case FILL_TYPE_GRAD:
{
var _c = _fill.colors;
if (_c == 0)
this.StrokeUniColor = new CUniColor().RGBA;
else
this.StrokeUniColor = _fill.colors[0].color.RGBA;
break;
}
case FILL_TYPE_PATT:
{
this.StrokeUniColor = _fill.fgClr.RGBA;
break;
}
case FILL_TYPE_NOFILL:
{
this.bIsNoStrokeAttack = true;
break;
}
default:
{
this.bIsNoStrokeAttack = true;
break;
}
}
this.StrokeWidth = (this.Ln.w == null) ? 12700 : parseInt(this.Ln.w);
this.StrokeWidth /= 36000.0;
}
if (this.bIsTexture || bIsCheckBounds)
{
// сначала нужно определить границы
this.bIsCheckBounds = true;
this.check_bounds();
this.bIsCheckBounds = false;
}
},
draw : function(geom)
{
if (this.bIsNoStrokeAttack && this.bIsNoFillAttack)
return;
this.Graphics["StartShapeDraw"](this.IsRectShape);
if(geom)
{
geom.draw(this);
}
else
{
this._s();
this._m(0, 0);
this._l(this.Shape.extX, 0);
this._l(this.Shape.extX, this.Shape.extY);
this._l(0, this.Shape.extY);
this._z();
this.drawFillStroke(true, "norm", true && !this.bIsNoStrokeAttack);
this._e();
}
this.Graphics["EndShapeDraw"]();
},
p_width : function(w)
{
this.Graphics["p_width"](w);
},
_m : function(x, y)
{
if (this.bIsCheckBounds)
{
this.CheckPoint(x, y);
return;
}
this.Graphics["_m"](x, y);
},
_l : function(x, y)
{
if (this.bIsCheckBounds)
{
this.CheckPoint(x, y);
return;
}
this.Graphics["_l"](x, y);
},
_c : function(x1, y1, x2, y2, x3, y3)
{
if (this.bIsCheckBounds)
{
this.CheckPoint(x1, y1);
this.CheckPoint(x2, y2);
this.CheckPoint(x3, y3);
return;
}
this.Graphics["_c"](x1, y1, x2, y2, x3, y3);
},
_c2 : function(x1, y1, x2, y2)
{
if (this.bIsCheckBounds)
{
this.CheckPoint(x1, y1);
this.CheckPoint(x2, y2);
return;
}
this.Graphics["_c2"](x1, y1, x2, y2);
},
_z : function()
{
if (this.bIsCheckBounds)
return;
this.Graphics["_z"]();
},
_s : function()
{
this.Graphics["_s"]();
},
_e : function()
{
this.Graphics["_e"]();
},
df : function(mode)
{
if (mode == "none" || this.bIsNoFillAttack)
return;
var _fill = this.UniFill.fill;
switch (_fill.type)
{
case FILL_TYPE_BLIP:
{
if (!_fill.srcRect)
this.Graphics["put_BrushTextute"](_fill.RasterImageId);
else
{
var _sR = _fill.srcRect;
this.Graphics["put_BrushTextute"](_fill.RasterImageId, _sR.l, _sR.t, _sR.r, _sR.b);
}
this.Graphics["put_BrushTextureMode"]((null == _fill.tile) ? 1 : 2);
this.Graphics["put_BrushBounds"](this.min_x, this.min_y, (this.max_x - this.min_x), (this.max_y - this.min_y));
break;
}
case FILL_TYPE_SOLID:
{
var rgba = this.FillUniColor;
if (mode == "darken")
{
var _color1 = new CShapeColor(rgba.R, rgba.G, rgba.B);
var rgb = _color1.darken();
rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A };
}
else if (mode == "darkenLess")
{
var _color1 = new CShapeColor(rgba.R, rgba.G, rgba.B);
var rgb = _color1.darkenLess();
rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A };
}
else if (mode == "lighten")
{
var _color1 = new CShapeColor(rgba.R, rgba.G, rgba.B);
var rgb = _color1.lighten();
rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A };
}
else if (mode == "lightenLess")
{
var _color1 = new CShapeColor(rgba.R, rgba.G, rgba.B);
var rgb = _color1.lightenLess();
rgba = { R: rgb.r, G: rgb.g, B: rgb.b, A: rgba.A };
}
if (rgba)
{
if (this.UniFill.transparent != null)
rgba.A = this.UniFill.transparent;
this.Graphics["b_color1"](rgba.R, rgba.G, rgba.B, rgba.A);
}
break;
}
case FILL_TYPE_GRAD:
{
var points = null;
if (_fill.lin)
{
points = this.getGradientPoints(this.min_x, this.min_y, this.max_x, this.max_y, _fill.lin.angle, _fill.lin.scale);
this.Graphics["put_BrushGradientLinear"](points.x0, points.y0, points.x1, points.y1);
}
else if (_fill.path)
{
var _cx = (this.min_x + this.max_x) / 2;
var _cy = (this.min_y + this.max_y) / 2;
var _r = Math.max(this.max_x - this.min_x, this.max_y - this.min_y) / 2;
gradObj = _ctx.createRadialGradient(_cx, _cy, 1, _cx, _cy, _r);
}
else
{
//gradObj = _ctx.createLinearGradient(this.min_x, this.min_y, this.max_x, this.min_y);
points = this.getGradientPoints(this.min_x, this.min_y, this.max_x, this.max_y, 90 * 60000, false);
this.Graphics["put_BrushGradientLinear"](points.x0, points.y0, points.x1, points.y1);
}
var arr_pos = [];
var arr_colors = [];
for (var i = 0; i < _fill.colors.length; i++)
{
arr_pos.push(_fill.colors[i].pos / 100000);
var _c = _fill.colors[i].color.RGBA;
arr_colors.push(_c.R * 256*256*256 + _c.G * 256*256 + _c.B * 256 + _c.A);
}
this.Graphics["put_BrushGragientColors"](arr_pos, arr_colors);
break;
}
case FILL_TYPE_PATT:
{
var _patt_name = global_hatch_names[_fill.ftype];
if (undefined == _patt_name)
_patt_name = "cross";
var _fc = _fill.fgClr.RGBA;
var _bc = _fill.bgClr.RGBA;
var __fa = (null === this.UniFill.transparent) ? _fc.A : 255;
var __ba = (null === this.UniFill.transparent) ? _bc.A : 255;
this.Graphics["put_BrushPattern"](_patt_name);
this.Graphics["b_color1"](_fc.R, _fc.G, _fc.B, __fa);
this.Graphics["b_color2"](_bc.R, _bc.G, _bc.B, __ba);
break;
}
default:
break;
}
this.Graphics["df"]();
},
ds : function()
{
if (this.bIsNoStrokeAttack)
return;
if (this.Ln.Join != null && this.Ln.Join.type != null)
{
switch (this.Ln.Join.type)
{
case LineJoinType.Round:
{
this.Graphics["lineJoin"]("round");
break;
}
case LineJoinType.Bevel:
{
this.Graphics["lineJoin"]("bevel");
break;
}
case LineJoinType.Empty:
{
this.Graphics["lineJoin"]("miter");
break;
}
case LineJoinType.Miter:
{
this.Graphics["lineJoin"]("miter");
break;
}
}
}
var rgba = this.StrokeUniColor;
this.Graphics["p_width"](this.StrokeWidth);
this.Graphics["p_color"](rgba.R, rgba.G, rgba.B, rgba.A);
this.Graphics["ds"]();
},
drawFillStroke : function(bIsFill, fill_mode, bIsStroke)
{
if (bIsFill)
this.df(fill_mode);
if (bIsStroke)
this.ds();
},
check_bounds : function()
{
this.Shape.check_bounds(this);
},
// common funcs
getNormalPoint : function(x0, y0, angle, x1, y1)
{
// точка - пересечение прямой, проходящей через точку (x0, y0) под углом angle и
// перпендикуляра к первой прямой, проведенной из точки (x1, y1)
var ex1 = Math.cos(angle);
var ey1 = Math.sin(angle);
var ex2 = -ey1;
var ey2 = ex1;
var a = ex1 / ey1;
var b = ex2 / ey2;
var x = ((a * b * y1 - a * b * y0) - (a * x1 - b * x0)) / (b - a);
var y = (x - x0) / a + y0;
return { X : x, Y : y };
},
getGradientPoints : function(min_x, min_y, max_x, max_y, _angle, scale)
{
var points = { x0 : 0, y0 : 0, x1 : 0, y1 : 0 };
var angle = _angle / 60000;
while (angle < 0)
angle += 360;
while (angle >= 360)
angle -= 360;
if (Math.abs(angle) < 1)
{
points.x0 = min_x;
points.y0 = min_y;
points.x1 = max_x;
points.y1 = min_y;
return points;
}
else if (Math.abs(angle - 90) < 1)
{
points.x0 = min_x;
points.y0 = min_y;
points.x1 = min_x;
points.y1 = max_y;
return points;
}
else if (Math.abs(angle - 180) < 1)
{
points.x0 = max_x;
points.y0 = min_y;
points.x1 = min_x;
points.y1 = min_y;
return points;
}
else if (Math.abs(angle - 270) < 1)
{
points.x0 = min_x;
points.y0 = max_y;
points.x1 = min_x;
points.y1 = min_y;
return points;
}
var grad_a = deg2rad(angle);
if (!scale)
{
if (angle > 0 && angle < 90)
{
var p = this.getNormalPoint(min_x, min_y, grad_a, max_x, max_y);
points.x0 = min_x;
points.y0 = min_y;
points.x1 = p.X;
points.y1 = p.Y;
return points;
}
if (angle > 90 && angle < 180)
{
var p = this.getNormalPoint(max_x, min_y, grad_a, min_x, max_y);
points.x0 = max_x;
points.y0 = min_y;
points.x1 = p.X;
points.y1 = p.Y;
return points;
}
if (angle > 180 && angle < 270)
{
var p = this.getNormalPoint(max_x, max_y, grad_a, min_x, min_y);
points.x0 = max_x;
points.y0 = max_y;
points.x1 = p.X;
points.y1 = p.Y;
return points;
}
if (angle > 270 && angle < 360)
{
var p = this.getNormalPoint(min_x, max_y, grad_a, max_x, min_y);
points.x0 = min_x;
points.y0 = max_y;
points.x1 = p.X;
points.y1 = p.Y;
return points;
}
// никогда сюда не зайдем
return points;
}
// scale == true
var _grad_45 = (Math.PI / 2) - Math.atan2(max_y - min_y, max_x - min_x);
var _grad_90_45 = (Math.PI / 2) - _grad_45;
if (angle > 0 && angle < 90)
{
if (angle <= 45)
{
grad_a = (_grad_45 * angle / 45);
}
else
{
grad_a = _grad_45 + _grad_90_45 * (angle - 45) / 45;
}
var p = this.getNormalPoint(min_x, min_y, grad_a, max_x, max_y);
points.x0 = min_x;
points.y0 = min_y;
points.x1 = p.X;
points.y1 = p.Y;
return points;
}
if (angle > 90 && angle < 180)
{
if (angle <= 135)
{
grad_a = Math.PI / 2 + _grad_90_45 * (angle - 90) / 45;
}
else
{
grad_a = Math.PI - _grad_45 * (angle - 135) / 45;
}
var p = this.getNormalPoint(max_x, min_y, grad_a, min_x, max_y);
points.x0 = max_x;
points.y0 = min_y;
points.x1 = p.X;
points.y1 = p.Y;
return points;
}
if (angle > 180 && angle < 270)
{
if (angle <= 225)
{
grad_a = Math.PI + _grad_45 * (angle - 180) / 45;
}
else
{
grad_a = 3 * Math.PI / 2 - _grad_90_45 * (angle - 225) / 45;
}
var p = this.getNormalPoint(max_x, max_y, grad_a, min_x, min_y);
points.x0 = max_x;
points.y0 = max_y;
points.x1 = p.X;
points.y1 = p.Y;
return points;
}
if (angle > 270 && angle < 360)
{
if (angle <= 315)
{
grad_a = 3 * Math.PI / 2 + _grad_90_45 * (angle - 270) / 45;
}
else
{
grad_a = 2 * Math.PI - _grad_45 * (angle - 315) / 45;
}
var p = this.getNormalPoint(min_x, max_y, grad_a, max_x, min_y);
points.x0 = min_x;
points.y0 = max_y;
points.x1 = p.X;
points.y1 = p.Y;
return points;
}
// никогда сюда не зайдем
return points;
},
DrawPresentationComment : function(type, x, y, w, h)
{
}
};
\ No newline at end of file
......@@ -53,7 +53,7 @@ CTextMeasurerWrapper.prototype =
_lastSetUp.SetUpSize = font.FontSize;
_lastSetUp.SetUpStyle = oFontStyle;
var _info = this.GetLoadInfoForMeasurer(window.g_font_infos[_lastSetUp.SetUpIndex], _lastSetUp.SetUpStyle);
var _info = GetLoadInfoForMeasurer(window.g_font_infos[_lastSetUp.SetUpIndex], _lastSetUp.SetUpStyle);
var flag = 0;
if (_info.NeedBold) flag |= 0x01;
if (_info.NeedItalic) flag |= 0x02;
......@@ -164,7 +164,7 @@ CTextMeasurerWrapper.prototype =
_lastFont.SetUpSize = _lastFont.Size;
_lastFont.SetUpStyle = _style;
var _info = this.GetLoadInfoForMeasurer(window.g_font_infos[_lastFont.SetUpIndex], _lastFont.SetUpStyle);
var _info = GetLoadInfoForMeasurer(window.g_font_infos[_lastFont.SetUpIndex], _lastFont.SetUpStyle);
var flag = 0;
if (_info.NeedBold) flag |= 0x01;
if (_info.NeedItalic) flag |= 0x02;
......@@ -226,150 +226,150 @@ CTextMeasurerWrapper.prototype =
GetHeight : function()
{
return this.Height;
},
}
};
GetLoadInfoForMeasurer : function(info, lStyle)
{
// подбираем шрифт по стилю
var sReturnName = info.Name;
var bNeedBold = false;
var bNeedItalic = false;
function GetLoadInfoForMeasurer(info, lStyle)
{
// подбираем шрифт по стилю
var sReturnName = info.Name;
var bNeedBold = false;
var bNeedItalic = false;
var index = -1;
var faceIndex = 0;
var index = -1;
var faceIndex = 0;
var bSrcItalic = false;
var bSrcBold = false;
var bSrcItalic = false;
var bSrcBold = false;
switch (lStyle)
switch (lStyle)
{
case FontStyle.FontStyleBoldItalic:
{
case FontStyle.FontStyleBoldItalic:
bSrcItalic = true;
bSrcBold = true;
bNeedBold = true;
bNeedItalic = true;
if (-1 != info.indexBI)
{
index = info.indexBI;
faceIndex = info.faceIndexBI;
bNeedBold = false;
bNeedItalic = false;
}
else if (-1 != info.indexB)
{
bSrcItalic = true;
bSrcBold = true;
index = info.indexB;
faceIndex = info.faceIndexB;
bNeedBold = false;
}
else if (-1 != info.indexI)
{
index = info.indexI;
faceIndex = info.faceIndexI;
bNeedItalic = false;
}
else
{
index = info.indexR;
faceIndex = info.faceIndexR;
}
break;
}
case FontStyle.FontStyleBold:
{
bSrcBold = true;
bNeedBold = true;
bNeedItalic = true;
if (-1 != info.indexBI)
{
index = info.indexBI;
faceIndex = info.faceIndexBI;
bNeedBold = false;
bNeedItalic = false;
}
else if (-1 != info.indexB)
{
index = info.indexB;
faceIndex = info.faceIndexB;
bNeedBold = false;
}
else if (-1 != info.indexI)
{
index = info.indexI;
faceIndex = info.faceIndexI;
bNeedItalic = false;
}
else
{
index = info.indexR;
faceIndex = info.faceIndexR;
}
break;
bNeedBold = true;
bNeedItalic = false;
if (-1 != info.indexB)
{
index = info.indexB;
faceIndex = info.faceIndexB;
bNeedBold = false;
}
else if (-1 != info.indexR)
{
index = info.indexR;
faceIndex = info.faceIndexR;
}
case FontStyle.FontStyleBold:
else if (-1 != info.indexBI)
{
bSrcBold = true;
index = info.indexBI;
faceIndex = info.faceIndexBI;
bNeedBold = false;
}
else
{
index = info.indexI;
faceIndex = info.faceIndexI;
}
break;
}
case FontStyle.FontStyleItalic:
{
bSrcItalic = true;
bNeedBold = true;
bNeedBold = false;
bNeedItalic = true;
if (-1 != info.indexI)
{
index = info.indexI;
faceIndex = info.faceIndexI;
bNeedItalic = false;
if (-1 != info.indexB)
{
index = info.indexB;
faceIndex = info.faceIndexB;
bNeedBold = false;
}
else if (-1 != info.indexR)
{
index = info.indexR;
faceIndex = info.faceIndexR;
}
else if (-1 != info.indexBI)
{
index = info.indexBI;
faceIndex = info.faceIndexBI;
bNeedBold = false;
}
else
{
index = info.indexI;
faceIndex = info.faceIndexI;
}
break;
}
case FontStyle.FontStyleItalic:
else if (-1 != info.indexR)
{
bSrcItalic = true;
bNeedBold = false;
bNeedItalic = true;
if (-1 != info.indexI)
{
index = info.indexI;
faceIndex = info.faceIndexI;
bNeedItalic = false;
}
else if (-1 != info.indexR)
{
index = info.indexR;
faceIndex = info.faceIndexR;
}
else if (-1 != info.indexBI)
{
index = info.indexBI;
faceIndex = info.faceIndexBI;
bNeedItalic = false;
}
else
{
index = info.indexB;
faceIndex = info.faceIndexB;
}
break;
index = info.indexR;
faceIndex = info.faceIndexR;
}
case FontStyle.FontStyleRegular:
else if (-1 != info.indexBI)
{
bNeedBold = false;
index = info.indexBI;
faceIndex = info.faceIndexBI;
bNeedItalic = false;
if (-1 != info.indexR)
{
index = info.indexR;
faceIndex = info.faceIndexR;
}
else if (-1 != info.indexI)
{
index = info.indexI;
faceIndex = info.faceIndexI;
}
else if (-1 != info.indexB)
{
index = info.indexB;
faceIndex = info.faceIndexB;
}
else
{
index = info.indexBI;
faceIndex = info.faceIndexBI;
}
}
else
{
index = info.indexB;
faceIndex = info.faceIndexB;
}
break;
}
case FontStyle.FontStyleRegular:
{
bNeedBold = false;
bNeedItalic = false;
if (-1 != info.indexR)
{
index = info.indexR;
faceIndex = info.faceIndexR;
}
else if (-1 != info.indexI)
{
index = info.indexI;
faceIndex = info.faceIndexI;
}
else if (-1 != info.indexB)
{
index = info.indexB;
faceIndex = info.faceIndexB;
}
else
{
index = info.indexBI;
faceIndex = info.faceIndexBI;
}
}
return {
Path : window.g_font_files[index].Id,
FaceIndex : faceIndex,
NeedBold : bNeedBold,
NeedItalic : bNeedItalic,
SrcBold : bSrcBold,
SrcItalic : bSrcItalic
};
}
};
\ No newline at end of file
return {
Path : window.g_font_files[index].Id,
FaceIndex : faceIndex,
NeedBold : bNeedBold,
NeedItalic : bNeedItalic,
SrcBold : bSrcBold,
SrcItalic : bSrcItalic
};
}
\ 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