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

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47735 954022d7-b5bf-4e40-9824-e11837661b57
parent 871a2a12
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -190,30 +190,32 @@ CGroupShape.prototype =
getResizeCoefficients: function(numHandle, x, y)
{
var t_x, t_y;
var cx, cy;
cx= this.extX > 0 ? this.extX : 0.01;
cy= this.extY > 0 ? this.extY : 0.01;
var p = this.transformPointRelativeShape(x, y);
var invert_transform = this.getInvertTransform();
var t_x = invert_transform.TransformPointX(x, y);
var t_y = invert_transform.TransformPointY(x, y);
switch(numHandle)
{
case 0:
return {kd1: (cx-p.x)/cx, kd2: (cy-p.y)/cy};
return {kd1: (cx-t_x)/cx, kd2: (cy-t_y)/cy};
case 1:
return {kd1: (cy-p.y)/cy, kd2: 0};
return {kd1: (cy-t_y)/cy, kd2: 0};
case 2:
return {kd1: (cy-p.y)/cy, kd2: p.x/cx};
return {kd1: (cy-t_y)/cy, kd2: t_x/cx};
case 3:
return {kd1: p.x/cx, kd2: 0};
return {kd1: t_x/cx, kd2: 0};
case 4:
return {kd1: p.x/cx, kd2: p.y/cy};
return {kd1: t_x/cx, kd2: t_y/cy};
case 5:
return {kd1: p.y/cy, kd2: 0};
return {kd1: t_y/cy, kd2: 0};
case 6:
return {kd1: p.y/cy, kd2:(cx-p.x)/cx};
return {kd1: t_y/cy, kd2:(cx-t_x)/cx};
case 7:
return {kd1:(cx-p.x)/cx, kd2: 0};
return {kd1:(cx-t_x)/cx, kd2: 0};
}
return {kd1: 1, kd2: 1};
},
......
......@@ -201,6 +201,8 @@ CImage.prototype =
this.flipH = xfrm.flipH === true;
this.flipV = xfrm.flipV === true;
}
if(isRealObject(this.spPr.geometry))
this.spPr.geometry.Recalculate(this.extX, this.extY);
this.transform.Reset();
var hc, vc;
hc = this.extX*0.5;
......@@ -215,8 +217,9 @@ CImage.prototype =
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
if(isRealObject(this.group))
{
global_MatrixTransformer.MultiplyAppend(t, this.group.getTransform());
global_MatrixTransformer.MultiplyAppend(this.transform, this.group.getTransform());
}
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
},
normalize: function()
......@@ -335,6 +338,13 @@ CImage.prototype =
return this.group.getFullFlipV() ? !this.flipV : this.flipV;
},
getAspect: function(num)
{
var _tmp_x = this.extX != 0 ? this.extX : 0.1;
var _tmp_y = this.extY != 0 ? this.extY : 0.1;
return num === 0 || num === 4 ? _tmp_x/_tmp_y : _tmp_y/_tmp_x;
},
setGroup: function(group)
{
this.group = group;
......@@ -515,13 +525,39 @@ CImage.prototype =
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
var _hit_context = this.drawingDocument.CanvasHitContext;
var _hit_context = this.drawingObjects.getCanvasContext();
return (HitInLine(_hit_context, x_t, y_t, 0, 0, this.extX, 0) ||
HitInLine(_hit_context, x_t, y_t, this.extX, 0, this.extX, this.extY)||
HitInLine(_hit_context, x_t, y_t, this.extX, this.extY, 0, this.extY)||
HitInLine(_hit_context, x_t, y_t, 0, this.extY, 0, 0) ||
HitInLine(_hit_context, x_t, y_t, this.extX*0.5, 0, this.extX*0.5, -this.drawingDocument.GetMMPerDot(TRACK_DISTANCE_ROTATE)));
HitInLine(_hit_context, x_t, y_t, 0, this.extY, 0, 0) /*||
HitInLine(_hit_context, x_t, y_t, this.extX*0.5, 0, this.extX*0.5, -this.drawingDocument.GetMMPerDot(TRACK_DISTANCE_ROTATE))*/);
},
hitInInnerArea: function(x, y)
{
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
if(isRealObject(this.spPr.geometry))
return this.spPr.geometry.hitInInnerArea(this.drawingObjects.getCanvasContext(), x_t, y_t);
return x_t > 0 && x_t < this.extX && y_t > 0 && y_t < this.extY;
},
hitInPath: function(x, y)
{
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
if(isRealObject(this.spPr.geometry))
return this.spPr.geometry.hitInPath(this.drawingObjects.getCanvasContext(), x_t, y_t);
return false;
},
hitInTextRect: function(x, y)
{
return false;
},
canRotate: function()
......@@ -586,50 +622,79 @@ CImage.prototype =
var rot_x_t = transform.TransformPointX(hc, - rotate_distance);
var rot_y_t = transform.TransformPointY(hc, - rotate_distance);
var invert_transform = this.getInvertTransform();
var rel_x = invert_transform.TransformPointX(x, y);
var v1_x, v1_y, v2_x, v2_y;
v1_x = x - xc_t;
v1_y = y - yc_t;
v2_x = rot_x_t - xc_t;
v2_y = rot_y_t - yc_t;
return Math.atan2( Math.abs(v1_x*v2_y - v1_y*v2_x), v1_x*v2_x + v1_y*v2_y);
var flip_h = this.getFullFlipH();
var flip_v = this.getFullFlipV();
var same_flip = flip_h && flip_v || !flip_h && !flip_v;
var angle = rel_x > this.extX*0.5 ? Math.atan2( Math.abs(v1_x*v2_y - v1_y*v2_x), v1_x*v2_x + v1_y*v2_y) : -Math.atan2( Math.abs(v1_x*v2_y - v1_y*v2_x), v1_x*v2_x + v1_y*v2_y);
return same_flip ? angle : -angle;
},
getResizeCoefficients: function(numHandle, x, y)
{
var t_x, t_y;
var cx, cy;
cx= this.extX > 0 ? this.extX : 0.01;
cy= this.extY > 0 ? this.extY : 0.01;
var p = this.transformPointRelativeShape(x, y);
var invert_transform = this.getInvertTransform();
var t_x = invert_transform.TransformPointX(x, y);
var t_y = invert_transform.TransformPointY(x, y);
switch(numHandle)
{
case 0:
return {kd1: (cx-p.x)/cx, kd2: (cy-p.y)/cy};
return {kd1: (cx-t_x)/cx, kd2: (cy-t_y)/cy};
case 1:
return {kd1: (cy-p.y)/cy, kd2: 0};
return {kd1: (cy-t_y)/cy, kd2: 0};
case 2:
return {kd1: (cy-p.y)/cy, kd2: p.x/cx};
return {kd1: (cy-t_y)/cy, kd2: t_x/cx};
case 3:
return {kd1: p.x/cx, kd2: 0};
return {kd1: t_x/cx, kd2: 0};
case 4:
return {kd1: p.x/cx, kd2: p.y/cy};
return {kd1: t_x/cx, kd2: t_y/cy};
case 5:
return {kd1: p.y/cy, kd2: 0};
return {kd1: t_y/cy, kd2: 0};
case 6:
return {kd1: p.y/cy, kd2:(cx-p.x)/cx};
return {kd1: t_y/cy, kd2:(cx-t_x)/cx};
case 7:
return {kd1:(cx-p.x)/cx, kd2: 0};
return {kd1:(cx-t_x)/cx, kd2: 0};
}
return {kd1: 1, kd2: 1};
},
getFullRotate: function()
{
return !isRealObject(this.group) ? this.rot : this.rot + this.group.getFullRotate();
},
getBoundsInGroup: function()
{
var r = this.rot;
if((r >= 0 && r < Math.PI*0.25)
|| (r > 3*Math.PI*0.25 && r < 5*Math.PI*0.25)
|| (r > 7*Math.PI*0.25 && r < 2*Math.PI))
{
return {minX: this.x, minY: this.y, maxX: this.x + this.extX, maxY: this.y + this.extY};
}
else
{
var hc = this.extX*0.5;
var vc = this.extY*0.5;
var xc = this.x + hc;
var yc = this.y + vc;
return {minX: xc - vc, minY: yc - hc, maxX: xc + vc, maxY: yc + hc};
}
},
drawAdjustments: function(drawingDocument)
{
......
/**
* User: Ilja.Kirillov
* Date: 07.11.11
* Time: 14:49
*/
var numbering_numfmt_None = 0x0000;
var numbering_numfmt_Bullet = 0x1001;
var numbering_numfmt_Decimal = 0x2002;
var numbering_numfmt_LowerRoman = 0x2003;
var numbering_numfmt_UpperRoman = 0x2004;
var numbering_numfmt_LowerLetter = 0x2005;
var numbering_numfmt_UpperLetter = 0x2006;
var numbering_numfmt_DecimalZero = 0x2007;
var numbering_lvltext_Text = 1;
var numbering_lvltext_Num = 2;
var numbering_suff_Tab = 1;
var numbering_suff_Space = 2;
var numbering_suff_Nothing = 3;
// Преобразовываем число в буквенную строку :
// 1 -> a
// 2 -> b
// ...
// 26 -> z
// 27 -> aa
// ...
// 52 -> zz
// 53 -> aaa
// ...
function Numbering_Number_To_Alpha(Num, bLowerCase)
{
var _Num = Num - 1;
var Count = (_Num - _Num % 26) / 26;
var Ost = _Num % 26;
var T = "";
var Letter;
if ( true === bLowerCase )
Letter = String.fromCharCode( Ost + 97 );
else
Letter = String.fromCharCode( Ost + 65 );
for ( var Index2 = 0; Index2 < Count + 1; Index2++ )
T += Letter;
return T;
}
// Преобразовываем число в обычную строку :
function Numbering_Number_To_String(Num)
{
return "" + Num;
}
// Преобразовываем число в римскую систему исчисления :
// 1 -> i
// 4 -> iv
// 5 -> v
// 9 -> ix
// 10 -> x
// 40 -> xl
// 50 -> l
// 90 -> xc
// 100 -> c
// 400 -> cd
// 500 -> d
// 900 -> cm
// 1000 -> m
function Numbering_Number_To_Roman(Num, bLowerCase)
{
// Переводим число Num в римскую систему исчисления
var Rims;
if ( true === bLowerCase )
Rims = [ 'm', 'cm', 'd', 'cd', 'c', 'xc', 'l', 'xl', 'x', 'ix', 'v', 'iv', 'i', ' '];
else
Rims = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I', ' '];
var Vals = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1, 0];
var T = "";
var Index2 = 0;
while ( Num > 0 )
{
while ( Vals[Index2] <= Num )
{
T += Rims[Index2];
Num -= Vals[Index2];
}
Index2++;
if ( Index2 >= Rims.length )
break;
}
return T;
}
function LvlText_Read_FromBinary(Reader)
{
var ElementType = Reader.GetLong();
var Element = null;
if ( numbering_lvltext_Num === ElementType )
Element = new CLvlText_Num();
else if ( numbering_lvltext_Text === ElementType )
Element = new CLvlText_Text();
Element.Read_FromBinary(Reader);
return Element;
}
function CLvlText_Text(Val)
{
if ( "string" == typeof(Val) )
this.Value = Val;
else
this.Value = "";
this.Type = numbering_lvltext_Text;
}
CLvlText_Text.prototype =
{
Copy : function()
{
var Obj = new CLvlText_Text( this.Value );
return Obj;
},
Write_ToBinary : function(Writer)
{
// Long : numbering_lvltext_Text
// String : Value
Writer.WriteLong( numbering_lvltext_Text );
Writer.WriteString2( this.Value );
},
Read_FromBinary : function(Reader)
{
this.Value = Reader.GetString2();
}
};
function CLvlText_Num(Lvl)
{
if ( "number" == typeof(Lvl) )
this.Value = Lvl;
else
this.Value = 0;
this.Type = numbering_lvltext_Num;
}
CLvlText_Num.prototype =
{
Copy : function()
{
var Obj = new CLvlText_Num( this.Value );
return Obj;
},
Write_ToBinary : function(Writer)
{
// Long : numbering_lvltext_Text
// Long : Value
Writer.WriteLong( numbering_lvltext_Num );
Writer.WriteLong( this.Value );
},
Read_FromBinary : function(Reader)
{
this.Value = Reader.GetLong();
}
};
function CAbstractNum(Type)
{
this.Id = g_oIdCounter.Get_NewId();
if ( "undefined" == typeof(Type) )
Type = numbering_numfmt_Bullet;
this.Lock = new CLock();
if ( false === g_oIdCounter.m_bLoad )
{
this.Lock.Set_Type( locktype_Mine, false );
CollaborativeEditing.Add_Unlock2( this );
}
this.Lvl = new Array();
for ( var Index = 0; Index < 9; Index++ )
{
this.Lvl[Index] = new Object();
var Lvl = this.Lvl[Index];
Lvl.PStyle = undefined;
Lvl.Start = 1;
Lvl.Restart = -1; // -1 - делаем нумерацию сначала всегда, 0 - никогда не начинаем нумерацию заново
Lvl.Suff = numbering_suff_Tab;
var Left = 36 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Bullet;
Lvl.LvlText = new Array();
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
if ( 0 == Index % 3 )
{
TextPr.FontFamily = { Name : "Symbol", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00B7 ) ) );
}
else if ( 1 == Index % 3 )
{
TextPr.FontFamily = { Name : "Courier New", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( "o" ) );
}
else
{
TextPr.FontFamily = { Name : "Wingdings", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A7 ) ) );
}
Lvl.TextPr = TextPr;
}
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
}
CAbstractNum.prototype =
{
Set_Id : function(newId)
{
g_oTableId.Reset_Id( this, newId, this.Id );
this.Id = newId;
},
Get_Id : function()
{
return this.Id;
},
// Копируем информацию из другой нумерации
Copy : function(AbstractNum)
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_new = this.Internal_CopyLvl( AbstractNum.Lvl[Index] );
var Lvl_old = this.Lvl[Index];
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
this.Lvl[Index] = Lvl_new;
}
},
Get_LvlByStyle : function(StyleId)
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl = this.Lvl[Index];
if ( StyleId === Lvl.PStyle )
return Index;
}
return -1;
},
Get_Lvl : function(Lvl)
{
if ( undefined === this.Lvl[Lvl] )
return this.Lvl[0];
return this.Lvl[Lvl];
},
// Определяем многоуровненый список по умолчанию
Create_Default_Numbered : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
this.Lvl[Index] = new Object();
var Lvl = this.Lvl[Index];
Lvl.Start = 1;
Lvl.Restart = -1; // -1 - делаем нумерацию сначала всегда, 0 - никогда не начинаем нумерацию заново
Lvl.Suff = numbering_suff_Tab;
var Left = 36 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
if ( 0 == Index % 3 )
{
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Decimal;
}
else if ( 1 == Index % 3 )
{
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_LowerLetter;
}
else
{
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_LowerRoman;
FirstLine = -9 * g_dKoef_pt_to_mm;
}
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Num( Index ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
}
},
Create_Default_Multilevel_1 : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
this.Lvl[Index] = new Object();
var Lvl = this.Lvl[Index];
Lvl.Start = 1;
Lvl.Restart = -1;
Lvl.Suff = numbering_suff_Tab;
var Left = 18 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
Lvl.Jc = align_Left;
if ( 0 == Index % 3 )
{
Lvl.Format = numbering_numfmt_Decimal;
}
else if ( 1 == Index % 3 )
{
Lvl.Format = numbering_numfmt_LowerLetter;
}
else
{
Lvl.Format = numbering_numfmt_LowerRoman;
}
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Num( Index ) );
Lvl.LvlText.push( new CLvlText_Text( ")" ) );
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
}
},
Create_Default_Multilevel_2 : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
this.Lvl[Index] = new Object();
var Lvl = this.Lvl[Index];
Lvl.Start = 1;
Lvl.Restart = -1; // -1 - делаем нумерацию сначала всегда, 0 - никогда не начинаем нумерацию заново
Lvl.Suff = numbering_suff_Tab;
var Left = 0;
var FirstLine = 0;
switch ( Index )
{
case 0 :
Left = 18 * g_dKoef_pt_to_mm;
FirstLine = -18 * g_dKoef_pt_to_mm;
break;
case 1 :
Left = 39.6 * g_dKoef_pt_to_mm;
FirstLine = -21.6 * g_dKoef_pt_to_mm;
break;
case 2 :
Left = 61.2 * g_dKoef_pt_to_mm;
FirstLine = -25.2 * g_dKoef_pt_to_mm;
break;
case 3 :
Left = 86.4 * g_dKoef_pt_to_mm;
FirstLine = -32.4 * g_dKoef_pt_to_mm;
break;
case 4 :
Left = 111.6 * g_dKoef_pt_to_mm;
FirstLine = -39.6 * g_dKoef_pt_to_mm;
break;
case 5 :
Left = 136.8 * g_dKoef_pt_to_mm;
FirstLine = -46.8 * g_dKoef_pt_to_mm;
break;
case 6 :
Left = 162 * g_dKoef_pt_to_mm;
FirstLine = -54 * g_dKoef_pt_to_mm;
break;
case 7 :
Left = 187.2 * g_dKoef_pt_to_mm;
FirstLine = -61.2 * g_dKoef_pt_to_mm;
break;
case 8 :
Left = 216 * g_dKoef_pt_to_mm;
FirstLine = -72 * g_dKoef_pt_to_mm;
break;
}
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Decimal;
Lvl.LvlText = new Array();
for ( var Index2 = 0; Index2 <= Index; Index2++ )
{
Lvl.LvlText.push( new CLvlText_Num( Index2 ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
}
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
}
},
Create_Default_Multilevel_3 : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
this.Lvl[Index] = new Object();
var Lvl = this.Lvl[Index];
Lvl.Start = 1;
Lvl.Restart = -1; // -1 - делаем нумерацию сначала всегда, 0 - никогда не начинаем нумерацию заново
Lvl.Suff = numbering_suff_Tab;
var Left = 18 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
Lvl.Format = numbering_numfmt_Bullet;
Lvl.Jc = align_Left;
if ( 0 == Index % 3 )
{
Lvl.Jc = align_Left;
}
else if ( 1 == Index % 3 )
{
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_LowerLetter;
}
else
{
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_LowerRoman;
FirstLine = -9 * g_dKoef_pt_to_mm;
}
Lvl.LvlText = new Array();
switch( Index )
{
case 0:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x0076 ) ) );
break;
case 1:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00D8 ) ) );
break;
case 2:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A7 ) ) );
break;
case 3:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00B7 ) ) );
break;
case 4:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A8 ) ) );
break;
case 5:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00D8 ) ) );
break;
case 6:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A7 ) ) );
break;
case 7:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00B7 ) ) );
break;
case 8:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A8 ) ) );
break;
}
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
if ( 3 === Index || 4 === Index || 7 === Index || 8 === Index )
TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
else
TextPr.FontFamily = { Name : "Wingdings", Index : -1 };
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
}
},
Create_Default_Bullet : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
this.Lvl[Index] = new Object();
var Lvl = this.Lvl[Index];
Lvl.Start = 1;
Lvl.Restart = -1; // -1 - делаем нумерацию сначала всегда, 0 - никогда не начинаем нумерацию заново
Lvl.Suff = numbering_suff_Tab;
var Left = 36 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Bullet;
Lvl.LvlText = new Array();
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
if ( 0 == Index % 3 )
{
TextPr.FontFamily = { Name : "Symbol", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00B7 ) ) );
}
else if ( 1 == Index % 3 )
{
TextPr.FontFamily = { Name : "Courier New", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( "o" ) );
}
else
{
TextPr.FontFamily = { Name : "Wingdings", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A7 ) ) );
}
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
}
},
Set_Lvl_Bullet : function(iLvl, LvlText, TextPr)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Format = numbering_numfmt_Bullet;
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Text( LvlText ) );
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// 1) right
Set_Lvl_Numbered_1 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_Decimal;
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( ")" ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// 1. right
Set_Lvl_Numbered_2 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_Decimal;
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// 1. left
Set_Lvl_Numbered_3 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Decimal;
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// 1) left
Set_Lvl_Numbered_4 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Decimal;
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( ")" ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// I. right
Set_Lvl_Numbered_5 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_UpperRoman;
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// A. left
Set_Lvl_Numbered_6 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_UpperLetter;
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// a) left
Set_Lvl_Numbered_7 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_LowerLetter;
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( ")" ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// a. left
Set_Lvl_Numbered_8 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_LowerLetter;
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// i. left
Set_Lvl_Numbered_9 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_LowerRoman;
Lvl.LvlText = new Array();
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// X, Y, Context - параметры для рисование
// Lvl - уровень, с которого мы берем текст и настройки для текста
// NumInfo - информация о номере данного элемента в списке (массив из Lvl элементов)
// NumTextPr - рассчитанные настройки для символов нумерации (уже с учетом настроек текущего уровня)
Draw : function(X,Y, Context, Lvl, NumInfo, NumTextPr)
{
var Text = this.Lvl[Lvl].LvlText;
var OldFont = Context.GetFont();
var OldFont2 = g_oTextMeasurer.GetFont();
Context.SetFont( NumTextPr );
g_oTextMeasurer.SetFont( NumTextPr );
for ( var Index = 0; Index < Text.length; Index++ )
{
switch( Text[Index].Type )
{
case numbering_lvltext_Text:
{
Context.FillText( X, Y, Text[Index].Value );
X += g_oTextMeasurer.Measure( Text[Index].Value ).Width;
break;
}
case numbering_lvltext_Num:
{
var CurLvl = Text[Index].Value;
switch( this.Lvl[CurLvl].Format )
{
case numbering_numfmt_Bullet:
{
break;
}
case numbering_numfmt_Decimal:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( Char ).Width;
}
}
break;
}
case numbering_numfmt_DecimalZero:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
if ( 1 === T.length )
{
Context.FillText( X, Y, '0' );
X += g_oTextMeasurer.Measure( '0' ).Width;
var Char = T.charAt(0);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( Char ).Width;
}
else
{
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( Char ).Width;
}
}
}
break;
}
case numbering_numfmt_LowerLetter:
case numbering_numfmt_UpperLetter:
{
if ( CurLvl < NumInfo.length )
{
// Формат: a,..,z,aa,..,zz,aaa,...,zzz,...
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] - 1;
var Count = (Num - Num % 26) / 26;
var Ost = Num % 26;
var T = "";
var Letter;
if ( numbering_numfmt_LowerLetter === this.Lvl[CurLvl].Format )
Letter = String.fromCharCode( Ost + 97 );
else
Letter = String.fromCharCode( Ost + 65 );
for ( var Index2 = 0; Index2 < Count + 1; Index2++ )
T += Letter;
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( Char ).Width;
}
}
break;
}
case numbering_numfmt_LowerRoman:
case numbering_numfmt_UpperRoman:
{
if ( CurLvl < NumInfo.length )
{
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl];
// Переводим число Num в римскую систему исчисления
var Rims;
if ( numbering_numfmt_LowerRoman === this.Lvl[CurLvl].Format )
Rims = [ 'm', 'cm', 'd', 'cd', 'c', 'xc', 'l', 'xl', 'x', 'ix', 'v', 'iv', 'i', ' '];
else
Rims = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I', ' '];
var Vals = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1, 0];
var T = "";
var Index2 = 0;
while ( Num > 0 )
{
while ( Vals[Index2] <= Num )
{
T += Rims[Index2];
Num -= Vals[Index2];
}
Index2++;
if ( Index2 >= Rims.length )
break;
}
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( T.charAt(Index2) ).Width;
}
}
break;
}
}
break;
}
}
}
Context.SetFont( OldFont );
g_oTextMeasurer.SetFont( OldFont2 );
},
Measure : function(Context, Lvl, NumInfo, NumTextPr)
{
var X = 0;
var Text = this.Lvl[Lvl].LvlText;
var OldFont = Context.GetFont();
Context.SetFont( NumTextPr );
var Ascent = Context.GetAscender();
for ( var Index = 0; Index < Text.length; Index++ )
{
switch( Text[Index].Type )
{
case numbering_lvltext_Text:
{
X += Context.Measure( Text[Index].Value ).Width;
break;
}
case numbering_lvltext_Num:
{
var CurLvl = Text[Index].Value;
switch( this.Lvl[CurLvl].Format )
{
case numbering_numfmt_Bullet:
{
break;
}
case numbering_numfmt_Decimal:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += Context.Measure( Char ).Width;
}
}
break;
}
case numbering_numfmt_DecimalZero:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
if ( 1 === T.length )
{
X += Context.Measure( '0' ).Width;
var Char = T.charAt(0);
X += Context.Measure( Char ).Width;
}
else
{
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += Context.Measure( Char ).Width;
}
}
}
break;
}
case numbering_numfmt_LowerLetter:
case numbering_numfmt_UpperLetter:
{
if ( CurLvl < NumInfo.length )
{
// Формат: a,..,z,aa,..,zz,aaa,...,zzz,...
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] - 1;
var Count = (Num - Num % 26) / 26;
var Ost = Num % 26;
var T = "";
var Letter;
if ( numbering_numfmt_LowerLetter === this.Lvl[CurLvl].Format )
Letter = String.fromCharCode( Ost + 97 );
else
Letter = String.fromCharCode( Ost + 65 );
for ( var Index2 = 0; Index2 < Count + 1; Index2++ )
T += Letter;
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += Context.Measure( Char ).Width;
}
}
break;
}
case numbering_numfmt_LowerRoman:
case numbering_numfmt_UpperRoman:
{
if ( CurLvl < NumInfo.length )
{
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl];
// Переводим число Num в римскую систему исчисления
var Rims;
if ( numbering_numfmt_LowerRoman === this.Lvl[CurLvl].Format )
Rims = [ 'm', 'cm', 'd', 'cd', 'c', 'xc', 'l', 'xl', 'x', 'ix', 'v', 'iv', 'i', ' '];
else
Rims = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I', ' '];
var Vals = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1, 0];
var T = "";
var Index2 = 0;
while ( Num > 0 )
{
while ( Vals[Index2] <= Num )
{
T += Rims[Index2];
Num -= Vals[Index2];
}
Index2++;
if ( Index2 >= Rims.length )
break;
}
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += Context.Measure( T.charAt(Index2) ).Width;
}
}
break;
}
}
break;
}
}
}
Context.SetFont( OldFont );
return { Width : X, Ascent : Ascent };
},
Document_CreateFontCharMap : function(FontCharMap, Lvl, NumInfo, NumTextPr)
{
FontCharMap.StartFont( NumTextPr.FontFamily.Name, NumTextPr.Bold, NumTextPr.Italic, NumTextPr.FontSize );
var Text = this.Lvl[Lvl].LvlText;
for ( var Index = 0; Index < Text.length; Index++ )
{
switch( Text[Index].Type )
{
case numbering_lvltext_Text:
{
FontCharMap.AddChar( Text[Index].Value );
break;
}
case numbering_lvltext_Num:
{
var CurLvl = Text[Index].Value;
switch( this.Lvl[CurLvl].Format )
{
case numbering_numfmt_Bullet:
{
break;
}
case numbering_numfmt_Decimal:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
FontCharMap.AddChar( Char );
}
}
break;
}
case numbering_numfmt_DecimalZero:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
if ( 1 === T.length )
{
FontCharMap.AddChar( '0' );
var Char = T.charAt(0);
FontCharMap.AddChar( Char );
}
else
{
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
FontCharMap.AddChar( Char );
}
}
}
break;
}
case numbering_numfmt_LowerLetter:
case numbering_numfmt_UpperLetter:
{
if ( CurLvl < NumInfo.length )
{
// Формат: a,..,z,aa,..,zz,aaa,...,zzz,...
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] - 1;
var Count = (Num - Num % 26) / 26;
var Ost = Num % 26;
var T = "";
var Letter;
if ( numbering_numfmt_LowerLetter === this.Lvl[CurLvl].Format )
Letter = String.fromCharCode( Ost + 97 );
else
Letter = String.fromCharCode( Ost + 65 );
for ( var Index2 = 0; Index2 < Count + 1; Index2++ )
T += Letter;
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
FontCharMap.AddChar( Char );
}
}
break;
}
case numbering_numfmt_LowerRoman:
case numbering_numfmt_UpperRoman:
{
if ( CurLvl < NumInfo.length )
{
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl];
// Переводим число Num в римскую систему исчисления
var Rims;
if ( numbering_numfmt_LowerRoman === this.Lvl[CurLvl].Format )
Rims = [ 'm', 'cm', 'd', 'cd', 'c', 'xc', 'l', 'xl', 'x', 'ix', 'v', 'iv', 'i', ' '];
else
Rims = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I', ' '];
var Vals = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1, 0];
var T = "";
var Index2 = 0;
while ( Num > 0 )
{
while ( Vals[Index2] <= Num )
{
T += Rims[Index2];
Num -= Vals[Index2];
}
Index2++;
if ( Index2 >= Rims.length )
break;
}
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
FontCharMap.AddChar( Char );
}
}
break;
}
}
break;
}
}
}
},
Document_Get_AllFontNames : function(AllFonts)
{
var Count = this.Lvl.length;
for ( var Index = 0; Index < Count; Index++ )
{
var Lvl = this.Lvl[Index];
if ( undefined != Lvl.TextPr && undefined != Lvl.TextPr.FontFamily )
AllFonts[Lvl.TextPr.FontFamily.Name] = true;
}
},
DocumentStatistics : function(Lvl, Stats)
{
var Text = this.Lvl[Lvl].LvlText;
var bWord = false;
for ( var Index = 0; Index < Text.length; Index++ )
{
var bSymbol = false;
var bSpace = false;
var bNewWord = false;
if ( numbering_lvltext_Text === Text[Index].Type && ( sp_string === Text[Index].Value || nbsp_string === Text[Index].Value ) )
{
bWord = false;
bSymbol = true;
bSpace = true;
}
else
{
if ( false === bWord )
bNewWord = true;
bWord = true;
bSymbol = true;
bSpace = false;
}
if ( true === bSymbol )
Stats.Add_Symbol( bSpace );
if ( true === bNewWord )
Stats.Add_Word();
}
if ( numbering_suff_Tab === this.Lvl[Lvl].Suff || numbering_suff_Space === this.Lvl[Lvl].Suff )
Stats.Add_Symbol( true );
},
// Применяем новые тектовые настройки к данной нумерации на заданном уровне
Apply_TextPr : function(Lvl, TextPr)
{
var CurTextPr = this.Lvl[Lvl].TextPr;
var TextPr_old = CurTextPr.Copy();
CurTextPr.Merge(TextPr);
var TextPr_new = CurTextPr.Copy();
History.Add( this, { Type : historyitem_AbstractNum_TextPrChange, Index : Lvl, Old : TextPr_old, New : TextPr_new } );
},
//-----------------------------------------------------------------------------------
// Undo/Redo функции
//-----------------------------------------------------------------------------------
// Копируем информацию о заданном уровне
Internal_CopyLvl : function(Lvl)
{
var Lvl_new = new Object();
Lvl_new.Start = Lvl.Start;
Lvl_new.Restart = Lvl.Restart;
Lvl_new.Suff = Lvl.Suff;
Lvl_new.Jc = Lvl.Jc;
Lvl_new.Format = Lvl.Format;
Lvl_new.LvlText = new Array();
for ( var Index = 0; Index < Lvl.LvlText.length; Index++ )
{
var Item = Lvl.LvlText[Index];
Lvl_new.LvlText.push( Item.Copy() );
}
Lvl_new.TextPr = Lvl.TextPr.Copy();
Lvl_new.ParaPr = Lvl.ParaPr.Copy();
return Lvl_new;
},
Internal_SetLvl : function(iLvl, Lvl_new)
{
var Lvl = this.Lvl[iLvl];
Lvl.Jc = Lvl_new.Jc;
Lvl.Format = Lvl_new.Format;
Lvl.LvlText = Lvl_new.LvlText;
Lvl.TextPr = Lvl_new.TextPr;
Lvl.ParaPr = Lvl_new.ParaPr;
},
Write_Lvl_ToBinary : function(Lvl, Writer)
{
// Long : Jc
// Long : Format
// Variable : TextPr
// Variable : ParaPr
// Long : количество элементов в LvlText
// Array of variables : массив LvlText
Writer.WriteLong( Lvl.Jc );
Writer.WriteLong( Lvl.Format );
Lvl.TextPr.Write_ToBinary(Writer);
Lvl.ParaPr.Write_ToBinary(Writer);
var Count = Lvl.LvlText.length;
Writer.WriteLong( Count );
for ( var Index = 0; Index < Count; Index++ )
Lvl.LvlText[Index].Write_ToBinary( Writer );
},
Read_Lvl_FromBinary : function(Lvl, Reader)
{
// Long : Jc
// Long : Format
// Variable : TextPr
// Variable : ParaPr
// Long : количество элементов в LvlText
// Array of variables : массив LvlText
Lvl.Jc = Reader.GetLong();
Lvl.Format = Reader.GetLong();
Lvl.TextPr = new CTextPr();
Lvl.ParaPr = new CParaPr();
Lvl.TextPr.Read_FromBinary( Reader );
Lvl.ParaPr.Read_FromBinary( Reader );
var Count = Reader.GetLong();
Lvl.LvlText = new Array();
for ( var Index = 0; Index < Count; Index++ )
{
var Element = LvlText_Read_FromBinary(Reader);
Lvl.LvlText.push(Element);
}
},
Undo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_AbstractNum_LvlChange:
{
this.Internal_SetLvl( Data.Index, Data.Old );
break;
}
case historyitem_AbstractNum_TextPrChange:
{
this.Lvl[Data.Index].TextPr = Data.Old;
break;
}
}
},
Redo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_AbstractNum_LvlChange:
{
this.Internal_SetLvl( Data.Index, Data.New );
break;
}
case historyitem_AbstractNum_TextPrChange:
{
this.Lvl[Data.Index].TextPr = Data.New;
break;
}
}
},
Refresh_RecalcData : function(Data)
{
var NumPr = new CNumPr();
NumPr.NumId = this.Id;
NumPr.Lvl = Data.Index;
var LogicDocument = editor.WordControl.m_oLogicDocument;
var AllParagraphs = LogicDocument.Get_AllParagraphs_ByNumbering( NumPr );
var Count = AllParagraphs.length;
for ( var Index = 0; Index < Count; Index++ )
{
var Para = AllParagraphs[Index];
Para.Refresh_RecalcData( { Type : historyitem_Paragraph_Numbering } );
}
},
//-----------------------------------------------------------------------------------
// Функции для работы с совместным редактирования
//-----------------------------------------------------------------------------------
Document_Is_SelectionLocked : function(CheckType)
{
switch ( CheckType )
{
case changestype_Paragraph_Content:
case changestype_Paragraph_Properties:
{
this.Lock.Check( this.Get_Id() );
break;
}
case changestype_Document_Content:
case changestype_Document_Content_Add:
case changestype_Image_Properties:
case changestype_Remove:
{
CollaborativeEditing.Add_CheckLock(true);
break;
}
}
},
Save_Changes : function(Data, Writer)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
Writer.WriteLong( historyitem_type_AbstractNum );
var Type = Data.Type;
// Пишем тип
Writer.WriteLong( Type );
switch ( Type )
{
case historyitem_AbstractNum_LvlChange:
{
// Long : iLvl
// Variable : Lvl
Writer.WriteLong(Data.Index);
this.Write_Lvl_ToBinary( Data.New, Writer );
break;
}
case historyitem_AbstractNum_TextPrChange:
{
// Long : iLvl
// Vairable : TextPr
Writer.WriteLong(Data.Index);
Data.New.Write_ToBinary(Writer);
break;
}
}
return Writer;
},
Save_Changes2 : function(Data, Writer)
{
return false;
},
Load_Changes : function(Reader, Reader2)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
var ClassType = Reader.GetLong();
if ( historyitem_type_AbstractNum != ClassType )
return;
var Type = Reader.GetLong();
switch ( Type )
{
case historyitem_AbstractNum_LvlChange:
{
// Long : iLvl
// Variable : Lvl
var iLvl = Reader.GetLong();
this.Read_Lvl_FromBinary( this.Lvl[iLvl], Reader );
break;
}
case historyitem_AbstractNum_TextPrChange:
{
// Long : iLvl
// Vairable : TextPr
var iLvl = Reader.GetLong();
this.Lvl[iLvl].TextPr = new CTextPr();
this.Lvl[iLvl].TextPr.Read_FromBinary(Reader);
break;
}
}
},
Write_ToBinary2 : function(Writer)
{
Writer.WriteLong( historyitem_type_AbstractNum );
// String : Id
// Variable[9 Lvl] : 9 уровней
Writer.WriteString2( this.Id );
for ( var Index = 0; Index < 9; Index++ )
this.Write_Lvl_ToBinary(this.Lvl[Index], Writer );
},
Read_FromBinary2 : function(Reader)
{
// String : Id
// Variable[9 Lvl] : 9 уровней
this.Id = Reader.GetString2();
for ( var Index = 0; Index < 9; Index++ )
this.Read_Lvl_FromBinary( this.Lvl[Index], Reader );
// Добавим данный список в нумерацию
var Numbering = editor.WordControl.m_oLogicDocument.Get_Numbering();
Numbering.AbstractNum[this.Id] = this;
},
Load_LinkData : function(LinkData)
{
}
};
function CNumbering()
{
this.AbstractNum = new Array();
this.Num = new Array();
}
CNumbering.prototype =
{
Create_AbstractNum : function(Type)
{
// TODO: переделать работу с ID
var AbstractNum = new CAbstractNum(Type);
var Id = AbstractNum.Get_Id();
this.AbstractNum[Id] = AbstractNum;
return Id;
},
Get_AbstractNum : function(Id)
{
return this.AbstractNum[Id];
},
Get_ParaPr : function(NumId, Lvl)
{
var AbstractId = this.AbstractNum[NumId];
if ( undefined != AbstractId )
return AbstractId.Lvl[Lvl].ParaPr;
return new CParaPr();
},
Get_Format : function(NumId, Lvl)
{
var AbstractId = this.AbstractNum[NumId];
if ( undefined != AbstractId )
return AbstractId.Lvl[Lvl].Format;
return numbering_numfmt_Bullet;
},
// Проверяем по типам Numbered и Bullet
Check_Format : function(NumId, Lvl, Type)
{
var Format = this.Get_Format( NumId, Lvl );
if ( ( 0x1000 & Format && 0x1000 & Type ) || ( 0x2000 & Format && 0x2000 & Type ) )
return true;
return false;
},
Draw : function(NumId, Lvl, X, Y, Context, NumInfo, TextPr)
{
var AbstractId = this.AbstractNum[NumId];
return AbstractId.Draw(X,Y, Context, Lvl, NumInfo, TextPr);
},
Measure : function(NumId, Lvl, Context, NumInfo, TextPr)
{
var AbstractId = this.AbstractNum[NumId];
return AbstractId.Measure( Context, Lvl, NumInfo, TextPr );
},
Document_CreateFontCharMap : function(FontCharMap, NumTextPr, NumPr, NumInfo)
{
var AbstractId = this.AbstractNum[NumPr.NumId];
AbstractId.Document_CreateFontCharMap( FontCharMap, NumPr.Lvl, NumInfo, NumTextPr );
},
Document_Get_AllFontNames : function(AllFonts)
{
for ( var Id in this.AbstractNum )
{
var AbstractNum = this.AbstractNum[Id];
AbstractNum.Document_Get_AllFontNames( AllFonts );
}
AllFonts["Symbol"] = true;
AllFonts["Courier New"] = true;
AllFonts["Wingdings"] = true;
AllFonts["Times New Roman"] = true;
}
};
var numbering_presentationnumfrmt_None = 0;
var numbering_presentationnumfrmt_Char = 1;
var numbering_presentationnumfrmt_ArabicPeriod = 100; // 1., 2., 3., ...
var numbering_presentationnumfrmt_ArabicParenR = 101; // 1), 2), 3), ...
var numbering_presentationnumfrmt_RomanUcPeriod = 102; // I., II., III., ...
var numbering_presentationnumfrmt_RomanLcPeriod = 103; // i., ii., iii., ...
var numbering_presentationnumfrmt_AlphaLcParenR = 104; // a), b), c), ...
var numbering_presentationnumfrmt_AlphaLcPeriod = 105; // a., b., c.,
var numbering_presentationnumfrmt_AlphaUcParenR = 106; // A), B), C), ...
var numbering_presentationnumfrmt_AlphaUcPeriod = 107; // A., B., C., ...
// Класс для работы с нумерацией в презентациях
function CPresentationBullet()
{
this.m_nType = numbering_presentationnumfrmt_None; // Тип
this.m_nStartAt = null; // Стартовое значение для нумерованных списков
this.m_sChar = null; // Значение для символьных списков
this.m_oColor = { r : 0, g : 0, b : 0 }; // Цвет
this.m_bColorTx = true; // Использовать ли цвет первого рана в параграфе
this.m_sFont = "Arial"; // Шрифт
this.m_bFontTx = true; // Использовать ли шрифт первого рана в параграфе
this.m_dSize = 1; // Размер шрифта, в пунктах или в процентах (зависит от флага m_bSizePct)
this.m_bSizeTx = false; // Использовать ли размер шрифта первого рана в параграфе
this.m_bSizePct = true; // Задан ли размер шрифта в процентах
this.m_oTextPr = null;
this.m_nNum = null;
this.m_sString = null;
this.Get_Type = function()
{
return this.m_nType;
};
this.Get_StartAt = function()
{
return this.m_nStartAt;
};
this.Measure = function(Context, FirstTextPr, _Num)
{
var dFontSize = FirstTextPr.FontSize;
if ( false === this.m_bSizeTx )
{
if ( true === this.m_bSizePct )
dFontSize *= this.m_dSize;
else
dFontSize = this.m_dSize;
}
var sFontName = ( true === this.m_bFontTx ? FirstTextPr.FontFamily.Name : this.m_sFont );
this.m_oTextPr =
{
FontFamily :
{
Name : sFontName,
Index : -1
},
FontSize : dFontSize,
Bold : ( this.m_nType >= numbering_presentationnumfrmt_ArabicPeriod ? FirstTextPr.Bold : false ),
Italic : ( this.m_nType >= numbering_presentationnumfrmt_ArabicPeriod ? FirstTextPr.Italic : false )
};
var Num = _Num + this.m_nStartAt - 1;
this.m_nNum = Num;
var X = 0;
var OldFont = Context.GetFont();
Context.SetFont( this.m_oTextPr );
var sT = "";
switch ( this.m_nType )
{
case numbering_presentationnumfrmt_Char:
{
if ( null != this.m_sChar )
sT = this.m_sChar;
break;
}
case numbering_presentationnumfrmt_AlphaLcParenR:
{
sT = Numbering_Number_To_Alpha( Num, true ) + ")";
break;
}
case numbering_presentationnumfrmt_AlphaLcPeriod:
{
sT = Numbering_Number_To_Alpha( Num, true ) + ".";
break;
}
case numbering_presentationnumfrmt_AlphaUcParenR:
{
sT = Numbering_Number_To_Alpha( Num, false ) + ")";
break;
}
case numbering_presentationnumfrmt_AlphaUcPeriod:
{
sT = Numbering_Number_To_Alpha( Num, false ) + ".";
break;
}
case numbering_presentationnumfrmt_ArabicParenR:
{
sT += Numbering_Number_To_String(Num) + ")";
break;
}
case numbering_presentationnumfrmt_ArabicPeriod:
{
sT += Numbering_Number_To_String(Num) + ".";
break;
}
case numbering_presentationnumfrmt_RomanLcPeriod:
{
sT += Numbering_Number_To_Roman(Num, true) + ".";
break;
}
case numbering_presentationnumfrmt_RomanUcPeriod:
{
sT += Numbering_Number_To_Roman(Num, false) + ".";
break;
}
}
this.m_sString = sT;
for ( var Index2 = 0; Index2 < sT.length; Index2++ )
{
var Char = sT.charAt(Index2);
X += Context.Measure( Char ).Width;
}
Context.SetFont( OldFont );
return { Width : X };
};
this.Copy = function()
{
var Bullet = new CPresentationBullet();
Bullet.m_nType = this.m_nType;
Bullet.m_nStartAt = this.m_nStartAt;
Bullet.m_sChar = this.m_sChar;
Bullet.m_oColor.r = this.m_oColor.r;
Bullet.m_oColor.g = this.m_oColor.g;
Bullet.m_oColor.b = this.m_oColor.b;
Bullet.m_bColorTx = this.m_bColorTx;
Bullet.m_sFont = this.m_sFont;
Bullet.m_bFontTx = this.m_bFontTx;
Bullet.m_dSize = this.m_dSize;
Bullet.m_bSizeTx = this.m_bSizeTx;
Bullet.m_bSizePct = this.m_bSizePct;
return Bullet;
};
this.Draw = function(X, Y, Context, FirstTextPr)
{
if ( null === this.m_oTextPr || null === this.m_nNum )
return;
var oColor = { r : this.m_oColor.r, g : this.m_oColor.g, b : this.m_oColor.b };
if ( true === this.m_bColorTx )
{
oColor.r = FirstTextPr.Color.r;
oColor.g = FirstTextPr.Color.g;
oColor.b = FirstTextPr.Color.b;
}
Context.p_color( oColor.r, oColor.g, oColor.b, 255 );
Context.b_color1( oColor.r, oColor.g, oColor.b, 255 );
var OldFont = Context.GetFont();
var OldFont2 = g_oTextMeasurer.GetFont();
Context.SetFont( this.m_oTextPr );
g_oTextMeasurer.SetFont( this.m_oTextPr );
var sT = this.m_sString;
for ( var Index2 = 0; Index2 < sT.length; Index2++ )
{
var Char = sT.charAt(Index2);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( Char ).Width;
}
Context.SetFont( OldFont );
g_oTextMeasurer.SetFont( OldFont2 );
};
this.Write_ToBinary = function(Writer)
{
// Long : m_nType
// Long : m_nStartAt (-1 == null)
// String : m_sChar ("" == null)
// Byte : m_oColor.r
// Byte : m_oColor.g
// Byte : m_oColor.b
// Bool : m_bColorTx
// String : m_sFont
// Bool : m_bFont
// Double : m_dSize
// Bool : m_bSizeTx
// Bool : m_bSizePct
Writer.WriteLong( this.m_nType );
Writer.WriteLong( ( null != this.m_nStartAt ? this.m_nStartAt : -1 ) );
Writer.WriteString2( ( null != this.m_sChar ? this.m_sChar : "" ) );
Writer.WriteByte( this.m_oColor.r );
Writer.WriteByte( this.m_oColor.g );
Writer.WriteByte( this.m_oColor.b );
Writer.WriteBool( this.m_bColorTx );
Writer.WriteString2( this.m_sFont );
Writer.WriteBool( this.m_bFontTx );
Writer.WriteDouble( this.m_dSize );
Writer.WriteBool( this.m_bSizeTx );
Writer.WriteBool( this.m_bSizePct );
};
this.Read_FromBinary = function(Reader)
{
// Long : m_nType
// Long : m_nStartAt (-1 == null)
// String : m_sChar ("" == null)
// Byte : m_oColor.r
// Byte : m_oColor.g
// Byte : m_oColor.b
// Bool : m_bColorTx
// String : m_sFont
// Bool : m_bFont
// Double : m_dSize
// Bool : m_bSizeTx
// Bool : m_bSizePct
this.m_nType = Reader.GetLong();
this.m_nStartAt = Reader.GetLong();
if ( -1 === this.m_nStartAt )
this.m_nStartAt = null;
this.m_sChar = Reader.GetString2();
if ( "" === this.m_sChar )
this.m_sChar = null;
this.m_oColor.r = Reader.GetByte();
this.m_oColor.g = Reader.GetByte();
this.m_oColor.b = Reader.GetByte();
this.m_bColorTx = Reader.GetBool();
this.m_sFont = Reader.GetString2();
this.m_bFontTx = Reader.GetBool();
this.m_dSize = Reader.GetDouble();
this.m_bSizeTx = Reader.GetBool();
this.m_bSizePct = Reader.GetBool();
};
};
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* Created with JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 7/4/13
* Time: 5:25 PM
* To change this template use File | Settings | File Templates.
*/
function CTxBody(shape)
{
this.shape = shape;
this.bodyPr = new CBodyPr();
this.lstStyle = null;
this.content = new CDocumentContent(this, editor.WordControl.m_oLogicDocument.DrawingDocument, 0, 0, 0, 20000, false, false);
}
CTxBody.prototype =
{
recalculate: function()
{
},
draw: function(graphics)
{
this.content.Draw(graphics);
},
Get_Styles: function(level)
{
return this.shape.Get_Styles(level);
},
paragraphAdd: function()
{}
};
\ No newline at end of file
......@@ -28,6 +28,7 @@ var STATES_ID_RESIZE_IN_GROUP = 0x18;
var STATES_ID_PRE_MOVE_IN_GROUP = 0x19;
var STATES_ID_MOVE_IN_GROUP = 0x20;
var STATES_ID_START_ADD_POLY_LINE = 0x21;
var STATES_ID_SPLINE_BEZIER = 0x22;
var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
......@@ -612,6 +613,7 @@ function TrackNewShapeState(drawingObjectsController, drawingObjects)
{
this.drawingObjectsController.trackNewShape(e, x, y);
this.drawingObjects.showOverlayGraphicObjects();
this.drawingObjects.selectGraphicObject();
};
this.onMouseUp = function(e, x, y)
......@@ -1293,7 +1295,10 @@ function MoveInGroupState(drawingObjectsController, drawingObjects, group, start
this.group.recalculateTransform();
this.drawingObjectsController.clearTrackObjects();
this.drawingObjects.showDrawingObjects(true);
this.drawingObjects.selectGraphicObject();
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group));
};
this.drawSelection = function(drawingDocument)
......@@ -1360,6 +1365,7 @@ function ChangeAdjInGroupState(drawingObjectsController, drawingObjects, group)
{
this.drawingObjectsController.trackEnd();
this.drawingObjectsController.clearTrackObjects();
this.drawingObjects.selectGraphicObject();
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group));
};
......@@ -1431,6 +1437,7 @@ function RotateInGroupState(drawingObjectsController, drawingObjects, group, maj
this.group.updateCoordinatesAfterInternalResize();
this.group.recalculateTransform();
this.drawingObjectsController.clearTrackObjects();
this.drawingObjects.selectGraphicObject();
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group));
};
......@@ -1506,6 +1513,7 @@ function ResizeInGroupState(drawingObjectsController, drawingObjects, group, maj
this.group.updateCoordinatesAfterInternalResize();
this.group.recalculateTransform();
this.drawingObjectsController.clearTrackObjects();
this.drawingObjects.selectGraphicObject();
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group));
};
......@@ -1520,33 +1528,877 @@ function ResizeInGroupState(drawingObjectsController, drawingObjects, group, maj
};
}
function StartAddPolyLineState(drawingObjectsController, drawingObjects)
function SplineBezierState(drawingObjectsController, drawingObjects)
{
this.id = STATES_ID_START_ADD_POLY_LINE;
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.id = STATES_ID_SPLINE_BEZIER;
this.graphicObjects = graphicObjects;
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex)
{
this.graphicObjects.startTrackPos = {x: x, y: y, pageIndex: pageIndex};
this.graphicObjects.spline = new Spline(pageIndex, this.graphicObjects.document);
this.graphicObjects.spline.path.push(new SplineCommandMoveTo(x, y));
this.graphicObjects.changeCurrentState(new SplineBezierState33(this.graphicObjects, x, y));
var sel_arr = this.graphicObjects.selectionInfo.selectionArray;
for(var i = 0; i < sel_arr.length; ++i)
{
sel_arr[i].deselect();
}
sel_arr.length = 0;
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
};
this.onMouseDown = function(e, x, y)
this.OnMouseMove = function(e, X, Y, pageIndex)
{
};
this.OnMouseUp = function(e, X, Y, pageIndex)
{
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
};
this.updateCursorType = function(pageIndex, x, y)
{
return false;
}
}
function SplineBezierState33(graphicObjects, startX, startY)
{
this.id = STATES_ID_SPLINE_BEZIER33;
this.graphicObjects = graphicObjects;
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex)
{
};
this.OnMouseMove = function(e, x, y, pageIndex)
{
var startPos = this.graphicObjects.startTrackPos;
if(startPos.x === x && startPos.y === y && startPos.pageIndex === pageIndex)
return;
var tr_x, tr_y;
if(pageIndex === startPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, startPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
this.graphicObjects.spline.path.push(new SplineCommandLineTo(tr_x, tr_y));
this.graphicObjects.changeCurrentState(new SplineBezierState2(this.graphicObjects));
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
};
this.OnMouseUp = function(e, x, y, pageIndex)
{
};
this.updateCursorType = function(pageIndex, x, y)
{
return false;
}
}
function SplineBezierState2(graphicObjects)
{
this.id = STATES_ID_SPLINE_BEZIER2;
this.graphicObjects = graphicObjects;
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex)
{
if(e.ClickCount >= 2)
{
var lt = this.graphicObjects.spline.getLeftTopPoint();
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null);
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex;
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
}
};
this.OnMouseMove = function(e, x, y, pageIndex)
{
var startPos = this.graphicObjects.startTrackPos;
var tr_x, tr_y;
if(pageIndex === startPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, startPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
this.graphicObjects.spline.path[1].changePoint(tr_x, tr_y);
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
};
this.OnMouseUp = function(e, x, y, pageIndex)
{
if( e.ClickCount < 2)
{
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.x;
tr_y = tr_point.y;
}
this.graphicObjects.changeCurrentState(new SplineBezierState3(this.graphicObjects,tr_x, tr_y));
}
};
this.updateCursorType = function(pageIndex, x, y)
{
return false;
}
}
function SplineBezierState3(graphicObjects, startX, startY)
{
this.id = STATES_ID_SPLINE_BEZIER3;
this.graphicObjects = graphicObjects;
this.startX = startX;
this.startY = startY;
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex)
{
if(e.ClickCount >= 2)
{
var lt = this.graphicObjects.spline.getLeftTopPoint();
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null);
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex;
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
}
};
this.OnMouseMove = function(e, x, y, pageIndex)
{
if(x === this.startX && y === this.startY && pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
return;
}
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
var spline = this.graphicObjects.spline;
x0 = spline.path[0].x;
y0 = spline.path[0].y;
x3 = spline.path[1].x;
y3 = spline.path[1].y;
x6 = tr_x;
y6 = tr_y;
var vx = (x6 - x0)/6;
var vy = (y6 - y0)/6;
x2 = x3 - vx;
y2 = y3 - vy;
x4 = x3 + vx;
y4 = y3 + vy;
x1 = (x0 + x2)*0.5;
y1 = (y0 + y2)*0.5;
x5 = (x4 + x6)*0.5;
y5 = (y4 + y6)*0.5;
spline.path.length = 1;
spline.path.push(new SplineCommandBezier(x1, y1, x2, y2, x3, y3));
spline.path.push(new SplineCommandBezier(x4, y4, x5, y5, x6, y6));
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
this.graphicObjects.changeCurrentState(new SplineBezierState4(this.graphicObjects));
};
this.OnMouseUp = function(e, x, y, pageIndex)
{
if(e.ClickCount >= 2)
{
var lt = this.graphicObjects.spline.getLeftTopPoint();
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null);
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex;
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
}
};
this.updateCursorType = function(pageIndex, x, y)
{
return false;
}
}
function SplineBezierState4(graphicObjects)
{
this.id = STATES_ID_SPLINE_BEZIER4;
this.graphicObjects = graphicObjects;
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex)
{
if(e.ClickCount >= 2)
{
var lt = this.graphicObjects.spline.getLeftTopPoint();
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null);
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex;
if(near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
}
};
this.OnMouseMove = function(e, x, y, pageIndex)
{
var spline = this.graphicObjects.spline;
var lastCommand = spline.path[spline.path.length-1];
var preLastCommand = spline.path[spline.path.length-2];
var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
if(spline.path[spline.path.length-3].id == 0)
{
x0 = spline.path[spline.path.length-3].x;
y0 = spline.path[spline.path.length-3].y;
}
else
{
x0 = spline.path[spline.path.length-3].x3;
y0 = spline.path[spline.path.length-3].y3;
}
x3 = preLastCommand.x3;
y3 = preLastCommand.y3;
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
x6 = tr_x;
y6 = tr_y;
var vx = (x6 - x0)/6;
var vy = (y6 - y0)/6;
x2 = x3 - vx;
y2 = y3 - vy;
x4 = x3 + vx;
y4 = y3 + vy;
x5 = (x4 + x6)*0.5;
y5 = (y4 + y6)*0.5;
if(spline.path[spline.path.length-3].id == 0)
{
preLastCommand.x1 = (x0 + x2)*0.5;
preLastCommand.y1 = (y0 + y2)*0.5;
}
preLastCommand.x2 = x2;
preLastCommand.y2 = y2;
preLastCommand.x3 = x3;
preLastCommand.y3 = y3;
lastCommand.x1 = x4;
lastCommand.y1 = y4;
lastCommand.x2 = x5;
lastCommand.y2 = y5;
lastCommand.x3 = x6;
lastCommand.y3 = y6;
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
};
this.OnMouseUp = function(e, x, y, pageIndex)
{
if(e.ClickCount < 2 )
{
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
this.graphicObjects.changeCurrentState(new SplineBezierState5(graphicObjects, tr_x, tr_y));
}
};
this.updateCursorType = function(pageIndex, x, y)
{
return false;
}
}
function SplineBezierState5(graphicObjects, startX, startY)
{
this.id = STATES_ID_SPLINE_BEZIER5;
this.graphicObjects = graphicObjects;
this.startX = startX;
this.startY = startY;
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex)
{
if(e.ClickCount >= 2)
{
var lt = this.graphicObjects.spline.getLeftTopPoint();
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null);
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex;
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
}
};
this.OnMouseMove = function(e, x, y, pageIndex)
{
if(x === this.startX && y === this.startY && pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
return;
}
var spline = this.graphicObjects.spline;
var lastCommand = spline.path[spline.path.length-1];
var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
if(spline.path[spline.path.length-2].id == 0)
{
x0 = spline.path[spline.path.length-2].x;
y0 = spline.path[spline.path.length-2].y;
}
else
{
x0 = spline.path[spline.path.length-2].x3;
y0 = spline.path[spline.path.length-2].y3;
}
x3 = lastCommand.x3;
y3 = lastCommand.y3;
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
x6 = tr_x;
y6 = tr_y;
var vx = (x6 - x0)/6;
var vy = (y6 - y0)/6;
x2 = x3 - vx;
y2 = y3 - vy;
x1 = (x2+x1)*0.5;
y1 = (y2+y1)*0.5;
x4 = x3 + vx;
y4 = y3 + vy;
x5 = (x4 + x6)*0.5;
y5 = (y4 + y6)*0.5;
if(spline.path[spline.path.length-2].id == 0)
{
lastCommand.x1 = x1;
lastCommand.y1 = y1;
}
lastCommand.x2 = x2;
lastCommand.y2 = y2;
spline.path.push(new SplineCommandBezier(x4, y4, x5, y5, x6, y6));
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
this.graphicObjects.changeCurrentState(new SplineBezierState4(this.graphicObjects));
};
this.OnMouseUp = function(e, x, y, pageIndex)
{
if(e.ClickCount >= 2)
{
var lt = this.graphicObjects.spline.getLeftTopPoint();
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null);
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex;
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
}
};
this.updateCursorType = function(pageIndex, x, y)
{
return false;
}
}
//Состояния прия работе с полилиниями
function PolyLineAddState(graphicObjects)
{
this.graphicObjects = graphicObjects;
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex)
{
this.graphicObjects.startTrackPos = {x: x, y: y, pageIndex:pageIndex};
this.graphicObjects.polyline = new PolyLine(this.graphicObjects.document, pageIndex);
this.graphicObjects.polyline.arrPoint.push({x : x, y: y});
var sel_arr = this.graphicObjects.selectionInfo.selectionArray;
for(var i = 0; i < sel_arr.length; ++i)
{
sel_arr[i].deselect();
}
sel_arr.length = 0;
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
var _min_distance = this.graphicObjects.drawingDocument.GetMMPerDot(1);
this.graphicObjects.changeCurrentState(new PolyLineAddState2(this.graphicObjects, _min_distance));
};
this.OnMouseMove = function(e, x, y, pageIndex)
{
};
this.OnMouseUp = function(e, x, y, pageIndex)
{
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
this.graphicObjects.polyline = null;
};
this.updateCursorType = function(pageIndex, x, y)
{
return false;
}
}
function PolyLineAddState2(graphicObjects, minDistance)
{
this.graphicObjects = graphicObjects;
this.minDistance = minDistance;
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex)
{
};
this.OnMouseMove = function(e, x, y, pageIndex)
{
var _last_point = this.graphicObjects.polyline.arrPoint[this.graphicObjects.polyline.arrPoint.length - 1];
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
var dx = tr_x - _last_point.x;
var dy = tr_y - _last_point.y;
if(Math.sqrt(dx*dx + dy*dy) >= this.minDistance)
{
this.graphicObjects.polyline.arrPoint.push({x : tr_x, y : tr_y});
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
}
};
this.OnMouseUp = function(e, x, y, pageIndex)
{
if(this.graphicObjects.polyline.arrPoint.length > 1)
{
var lt = this.graphicObjects.polyline.getLeftTopPoint();
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex,lt.x, lt.y);
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex;
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.polyline.createShape(this.graphicObjects.document);
this.graphicObjects.arrTrackObjects.length = 0;
// this.graphicObjects.resetSelection();
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
_new_word_graphic_object.recalculateWrapPolygon();
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
this.graphicObjects.polyline = null;
}
else
{
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
this.graphicObjects.drawingDocument.OnRecalculatePage(this.graphicObjects.startTrackPos.pageIndex, this.graphicObjects.document.Pages[this.graphicObjects.startTrackPos.pageIndex]);
this.graphicObjects.polyline = null;
}
};
this.updateCursorType = function(pageIndex, x, y)
{
return false;
}
}
function AddPolyLine2State(graphicObjects)
{
this.graphicObjects = graphicObjects;
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex)
{
this.graphicObjects.startTrackPos = {x: x, y: y, pageIndex : pageIndex};
var sel_arr = this.graphicObjects.selectionInfo.selectionArray;
for(var sel_index = 0; sel_index < sel_arr.length; ++sel_index)
{
sel_arr[sel_index].deselect();
}
sel_arr.length = 0;
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
this.graphicObjects.polyline = new PolyLine(this.graphicObjects.document, pageIndex);
this.graphicObjects.polyline.arrPoint.push({x : x, y: y});
this.graphicObjects.changeCurrentState(new AddPolyLine2State2(this.graphicObjects, x, y));
};
this.OnMouseMove = function(AutoShapes, e, X, Y)
{};
this.onMouseMove = function(e, x, y)
this.OnMouseUp = function(AutoShapes, e, X, Y)
{
var resize_coefficients = this.majorObject.getResizeCoefficients(this.handleNum, x, y);
this.drawingObjectsController.trackResizeObjects(resize_coefficients.kd1, resize_coefficients.kd2, e);
this.drawingObjects.selectGraphicObject();
this.drawingObjects.showOverlayGraphicObjects();
};
this.updateCursorType = function(pageIndex, x, y)
{
return false;
}
}
this.onMouseUp = function(e, x, y)
function AddPolyLine2State2(graphicObjects, x, y)
{
this.graphicObjects = graphicObjects;
this.X = x;
this.Y = y;
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex)
{
this.drawingObjectsController.trackEnd();
this.group.normalize();
this.group.updateCoordinatesAfterInternalResize();
this.group.recalculateTransform();
this.drawingObjectsController.clearTrackObjects();
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group));
if(e.ClickCount > 1)
{
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
this.graphicObjects.polyline = null;
}
};
this.OnMouseMove = function(e, x, y, pageIndex)
{
if(this.X !== x || this.Y !== y || this.graphicObjects.startTrackPos.pageIndex !== pageIndex)
{
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
this.graphicObjects.polyline.arrPoint.push({x : tr_x, y: tr_y});
this.graphicObjects.changeCurrentState(new AddPolyLine2State3(this.graphicObjects));
}
};
this.OnMouseUp = function(e, x, y, pageIndex)
{
};
this.updateCursorType = function(pageIndex, x, y)
{
return false;
}
}
function AddPolyLine2State3(graphicObjects)
{
this.graphicObjects = graphicObjects;
this.minSize = graphicObjects.drawingDocument.GetMMPerDot(1);
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex)
{
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
this.graphicObjects.polyline.arrPoint.push({x: tr_x, y: tr_y});
if(e.ClickCount > 1)
{
var lt = this.graphicObjects.polyline.getLeftTopPoint();
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y);
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex;
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.polyline.createShape(this.graphicObjects.document);
this.graphicObjects.arrTrackObjects.length = 0;
// this.graphicObjects.resetSelection();
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
_new_word_graphic_object.recalculateWrapPolygon();
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
this.graphicObjects.polyline = null;
}
};
this.OnMouseMove = function(e, x, y, pageIndex)
{
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
if(!e.IsLocked)
{
this.graphicObjects.polyline.arrPoint[this.graphicObjects.polyline.arrPoint.length - 1] = {x: tr_x, y: tr_y};
}
else
{
var _last_point = this.graphicObjects.polyline.arrPoint[this.graphicObjects.polyline.arrPoint.length - 1];
var dx = tr_x - _last_point.x;
var dy = tr_y - _last_point.y;
if(Math.sqrt(dx*dx + dy*dy) >= this.minSize)
{
this.graphicObjects.polyline.arrPoint.push({x: tr_x, y: tr_y});
}
}
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
};
this.OnMouseUp = function(e, x, y, pageIndex)
{
if(e.ClickCount > 1)
{
var lt = this.graphicObjects.polyline.getLeftTopPoint();
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y);
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex;
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.polyline.createShape(this.graphicObjects.document);
this.graphicObjects.arrTrackObjects.length = 0;
// this.graphicObjects.resetSelection();
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
_new_word_graphic_object.recalculateWrapPolygon();
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
this.graphicObjects.polyline = null;
}
};
this.updateCursorType = function(pageIndex, x, y)
{
return false;
}
}
......@@ -1571,6 +2423,10 @@ function DrawGroupSelection(group, drawingDocument)
{
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, group_selected_objects[i].getTransform(), 0, 0, group_selected_objects[i].extX, group_selected_objects[i].extY, false/*, selected_objects[i].canRotate()TODO*/)
}
if(group_selected_objects.length === 1)
{
group_selected_objects[0].drawAdjustments(drawingDocument);
}
}
......
function PolyLine (drawingObjects)
{
this.drawingObjects = drawingObjects;
this.arrPoint = [];
this.Matrix = new CMatrixL();
this.TransformMatrix = new CMatrixL();
this.style = CreateDefaultShapeStyle();
var _calculated_line;
var wb = this.drawingObjects.getWorkbook();
var _theme = wb.theme;
var colorMap = GenerateDefaultColorMap().color_map;
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, colorMap, {R: 0 , G: 0, B: 0, A: 255});
RGBA = this.style.lnRef.Color.RGBA;
}
else
{
_calculated_line = new CLn();
}
if(isRealObject(_calculated_line.Fill))
{
_calculated_line.Fill.calculate(_theme, colorMap, RGBA) ;
}
this.pen = _calculated_line;
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)
{
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;
if(Math.sqrt(dx*dx +dy*dy) < this.document.DrawingDocument.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 wordGraphicObject = new ParaDrawing(null, null, null, document.DrawingDocument, null, document);
var wordShape = new WordShape(wordGraphicObject, document, document.DrawingDocument, null);
/*W, H, GraphicObj, Drawing*/
wordGraphicObject.Set_GraphicObject(wordShape);
wordShape.pageIndex = this.pageIndex;
wordShape.setAbsoluteTransform(xMin, yMin, xMax-xMin, yMax-yMin, 0, false, false);
wordShape.setXfrm(0, 0, xMax-xMin, yMax-yMin, 0, false, false);
wordShape.style = CreateDefaultShapeStyle();
var geometry = new CGeometry();
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);
}
geometry.Init( xMax-xMin, yMax-yMin);
wordShape.spPr.geometry = geometry;
wordShape.calculate();
wordShape.calculateTransformMatrix();
wordGraphicObject.setZIndex();
wordGraphicObject.setPageIndex(this.pageIndex);
var data = {Type:historyitem_CreatePolyine};
data.xMax = xMax;
data.xMin = xMin;
data.yMax = yMax;
data.yMin = yMin;
data.bClosed = bClosed;
data.commands = [];
data.commands.push({id: 1, x: (this.arrPoint[0].x - xMin) + "", y:(this.arrPoint[0].y - yMin) + ""});
for(i = 1; i< _n; ++i)
{
data.commands.push({id: 2, x: (this.arrPoint[i].x - xMin) + "", y:(this.arrPoint[i].y - yMin) + ""});
}
History.Add(wordShape, data);
History.Add(wordGraphicObject, {Type: historyitem_CalculateAfterPaste});
return wordGraphicObject;
}
}
function PolyLineAdapter(drawingObjects)
{
this.polyLine = new PolyLine (drawingObjects);
this.draw = function(graphics)
{
this.polyLine.Draw(graphics);
}
}
\ No newline at end of file
......@@ -1764,30 +1764,6 @@ function ResizeTrackGroup(originalObject, cardDirection, parentTrack)
};
this.updateTransform = function()
{
this.transform.Reset();
var t = this.transform;
global_MatrixTransformer.TranslateAppend(t, -this.extX*0.5, -this.extY*0.5);
if(xfrm.flipH == null ? false : xfrm.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(xfrm.flipV == null ? false : xfrm.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, -this.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
if(this.parentTrack)
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].updateTransform();
}
};
}
function ShapeForResizeInGroup(originalObject, parentTrack)
......@@ -1847,7 +1823,7 @@ function ShapeForResizeInGroup(originalObject, parentTrack)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, this.rot);
global_MatrixTransformer.RotateRadAppend(t, -this.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
};
......
var K=1/4;
var mt=0, lt=1, cb=2, cl=3;
function SplineCommandMoveTo(x, y)
{
this.id = 0;
this.x = x;
this.y = y;
}
function SplineCommandLineTo(x, y)
{
this.id = 1;
this.x = x;
this.y = y;
this.changePoint = function(x, y)
{
this.x = x;
this.y = y;
}
}
function SplineCommandBezier(x1, y1, x2, y2, x3, y3)
{
this.id = 2;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.x3 = x3;
this.y3 = y3;
this.changeLastPoint = function(x, y)
{
this.x3 = x;
this.y3 = y;
this.x2 = this.x1 + (this.x3 - this.x1)*0.5;
this.y2 = this.y1 + (this.y3 - this.y1)*0.5;
}
}
function Spline(drawingObjects)
{
this.path = [];
this.drawingObjects = drawingObjects;
this.Matrix = new CMatrix();
this.TransformMatrix = new CMatrix();
this.style = CreateDefaultShapeStyle();
var _calculated_line;
var _theme = drawingObjects.getWorkbook().theme;
var colorMap = GenerateDefaultColorMap().color_map;
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, colorMap, {R: 0 , G: 0, B: 0, A: 255});
RGBA = this.style.lnRef.Color.RGBA;
}
else
{
_calculated_line = new CLn();
}
if(isRealObject(_calculated_line.Fill))
{
_calculated_line.Fill.calculate(_theme, colorMap, RGBA) ;
}
this.pen = _calculated_line;
this.Draw = function(graphics)
{
graphics.SetCurrentPage(this.pageIndex);
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)
{
for(var i = 0; i < this.path.length; ++i)
{
var lastX, lastY;
switch (this.path[i].id )
{
case 0 :
{
g._m(this.path[i].x, this.path[i].y);
lastX = this.path[i].x;
lastY = this.path[i].y;
break;
}
case 1 :
{
g._l(this.path[i].x, this.path[i].y);
lastX = this.path[i].x;
lastY = this.path[i].y;
break;
}
case 2 :
{
g._c(this.path[i].x1, this.path[i].y1, this.path[i].x2, this.path[i].y2, this.path[i].x3, this.path[i].y3);
lastX = this.path[i].x3;
lastY = this.path[i].y3;
break;
}
}
}
g.ds();
};
this.getLeftTopPoint = function()
{
if(this.path.length < 1)
return {x: 0, y: 0};
var min_x = this.path[0].x;
var max_x = min_x;
var min_y = this.path[0].y;
var max_y = min_y;
var last_x = this.path[0].x, last_y = this.path[0].y;
for(var index = 1; index < this.path.length; ++index)
{
var path_command = this.path[index];
if(path_command.id === 1)
{
if(min_x > path_command.x)
min_x = path_command.x;
if(max_x < path_command.x)
max_x = path_command.x;
if(min_y > path_command.y)
min_y = path_command.y;
if(max_y < path_command.y)
max_y = path_command.y;
}
else
{
var bezier_polygon = partition_bezier4(last_x, last_y, path_command.x1, path_command.y1, path_command.x2, path_command.y2, path_command.x3, path_command.y3, APPROXIMATE_EPSILON);
for(var point_index = 1; point_index < bezier_polygon.length; ++point_index)
{
var cur_point = bezier_polygon[point_index];
if(min_x > cur_point.x)
min_x = cur_point.x;
if(max_x < cur_point.x)
max_x = cur_point.x;
if(min_y > cur_point.y)
min_y = cur_point.y;
if(max_y < cur_point.y)
max_y = cur_point.y;
}
}
}
return {x: min_x, y: min_y};
};
this.createShape = function(document)
{
var xMax = this.path[0].x, yMax = this.path[0].y, xMin = xMax, yMin = yMax;
var i;
var bClosed = false;
if(this.path.length > 2)
{
var dx = this.path[0].x - this.path[this.path.length-1].x3;
var dy = this.path[0].y - this.path[this.path.length-1].y3;
if(Math.sqrt(dx*dx +dy*dy) < 3)
{
bClosed = true;
this.path[this.path.length-1].x3 = this.path[0].x;
this.path[this.path.length-1].y3 = this.path[0].y;
if(this.path.length > 3)
{
var vx = (this.path[1].x3 - this.path[this.path.length-2].x3)/6;
var vy = (this.path[1].y3 - this.path[this.path.length-2].y3)/6;
}
else
{
vx = -(this.path[1].y3 - this.path[0].y)/6;
vy = (this.path[1].x3 - this.path[0].x)/6;
}
this.path[1].x1 = this.path[0].x +vx;
this.path[1].y1 = this.path[0].y +vy;
this.path[this.path.length-1].x2 = this.path[0].x -vx;
this.path[this.path.length-1].y2 = this.path[0].y -vy;
}
}
var min_x = this.path[0].x;
var max_x = min_x;
var min_y = this.path[0].y;
var max_y = min_y;
var last_x = this.path[0].x, last_y = this.path[0].y;
for(var index = 1; index < this.path.length; ++index)
{
var path_command = this.path[index];
if(path_command.id === 1)
{
if(min_x > path_command.x)
min_x = path_command.x;
if(max_x < path_command.x)
max_x = path_command.x;
if(min_y > path_command.y)
min_y = path_command.y;
if(max_y < path_command.y)
max_y = path_command.y;
last_x = path_command.x;
last_y = path_command.y;
}
else
{
var bezier_polygon = partition_bezier4(last_x, last_y, path_command.x1, path_command.y1, path_command.x2, path_command.y2, path_command.x3, path_command.y3, APPROXIMATE_EPSILON);
for(var point_index = 1; point_index < bezier_polygon.length; ++point_index)
{
var cur_point = bezier_polygon[point_index];
if(min_x > cur_point.x)
min_x = cur_point.x;
if(max_x < cur_point.x)
max_x = cur_point.x;
if(min_y > cur_point.y)
min_y = cur_point.y;
if(max_y < cur_point.y)
max_y = cur_point.y;
last_x = path_command.x3;
last_y = path_command.y3;
}
}
}
xMin = min_x;
xMax = max_x;
yMin = min_y;
yMax = max_y;
var wordGraphicObject = new ParaDrawing(null, null, null, document.DrawingDocument, null, document);
var wordShape = new WordShape(wordGraphicObject, document, document.DrawingDocument, null);
wordGraphicObject.Set_GraphicObject(wordShape);
wordShape.pageIndex = this.pageIndex;
wordShape.setAbsoluteTransform(xMin, yMin, xMax-xMin, yMax-yMin, 0, false, false);
wordShape.setXfrm(0, 0, xMax-xMin, yMax-yMin, 0, false, false);
wordShape.style = CreateDefaultShapeStyle();
var geometry = new CGeometry();
geometry.AddPathCommand(0, undefined, bClosed ? "norm": "none", undefined, xMax - xMin, yMax-yMin);
geometry.AddRect("l", "t", "r", "b");
for(i = 0; i< this.path.length; ++i)
{
switch (this.path[i].id)
{
case 0 :
{
geometry.AddPathCommand(1, (this.path[i].x - xMin) + "", (this.path[i].y - yMin) + "");
break;
}
case 1 :
{
geometry.AddPathCommand(2, (this.path[i].x - xMin) + "", (this.path[i].y - yMin) + "");
break;
}
case 2:
{
geometry.AddPathCommand(5, (this.path[i].x1 - xMin) + "", (this.path[i].y1 - yMin) + "", (this.path[i].x2 - xMin) + "", (this.path[i].y2 - yMin) + "", (this.path[i].x3 - xMin) + "", (this.path[i].y3 - yMin) + "");
break;
}
}
}
if(bClosed)
{
geometry.AddPathCommand(6);
}
geometry.Init( xMax-xMin, yMax-yMin);
wordShape.spPr.geometry = geometry;
wordShape.calculate();
wordShape.calculateTransformMatrix();
wordGraphicObject.setZIndex();
wordGraphicObject.setPageIndex(this.pageIndex);
for(i = 0; i< this.path.length; ++i)
{
switch (this.path[i].id)
{
case 0 :
{
data.commands.push({id: 1, x: (this.path[i].x - xMin) + "", y:(this.path[i].y - yMin) + ""});
break;
}
case 1 :
{
data.commands.push({id: 2, x: (this.path[i].x - xMin) + "", y:(this.path[i].y - yMin) + ""});
break;
}
case 2:
{
data.commands.push({id: 5, x0: (this.path[i].x1 - xMin) + "", y0: (this.path[i].y1 - yMin) + "", x1:(this.path[i].x2 - xMin) + "", y1:(this.path[i].y2 - yMin) + "", x2:(this.path[i].x3 - xMin) + "", y2:(this.path[i].y3 - yMin) + ""});
break;
}
}
}
return wordGraphicObject;
}
}
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