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

delete

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58062 954022d7-b5bf-4e40-9824-e11837661b57
parent f2ec9d54
/**
* 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_alphaLcParenBoth = 0x2007;
var numbering_numfmt_alphaLcParenR = 0x2008;
var numbering_numfmt_alphaLcPeriod = 0x2009;
var numbering_numfmt_alphaUcParenBoth = 0x200A;
var numbering_numfmt_alphaUcParenR = 0x200B;
var numbering_numfmt_alphaUcPeriod = 0x200C;
var numbering_numfmt_arabicParenBoth = 0x200D;
var numbering_numfmt_arabicParenR = 0x200E;
var numbering_numfmt_arabicPeriod = 0x200F;
var numbering_numfmt_romanLcParenBoth = 0x2010;
var numbering_numfmt_romanLcParenR = 0x2011;
var numbering_numfmt_romanLcPeriod = 0x2012;
var numbering_numfmt_romanUcParenBoth = 0x2013;
var numbering_numfmt_romanUcParenR = 0x2014;
var numbering_numfmt_romanUcPeriod = 0x2015;
var numbering_numfmt_arabic1Minus = 0x2016;
var numbering_numfmt_arabic2Minus = 0x2017;
var numbering_numfmt_hebrew2Minus = 0x2016;
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;
var g_NumberingArr = [];
g_NumberingArr[0] = numbering_numfmt_alphaLcParenBoth;
g_NumberingArr[1] = numbering_numfmt_alphaLcParenR;
g_NumberingArr[2] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[3] = numbering_numfmt_alphaUcParenBoth;
g_NumberingArr[4] = numbering_numfmt_alphaUcParenR;
g_NumberingArr[5] = numbering_numfmt_alphaUcPeriod;
g_NumberingArr[6] = numbering_numfmt_arabic1Minus;
g_NumberingArr[7] = numbering_numfmt_arabic2Minus;
g_NumberingArr[8] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[9] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[10] = numbering_numfmt_arabicParenBoth;
g_NumberingArr[11] = numbering_numfmt_arabicParenR;
g_NumberingArr[12] = numbering_numfmt_arabicPeriod;
g_NumberingArr[13] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[14] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[15] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[16] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[17] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[18] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[19] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[20] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[21] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[22] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[23] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[24] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[25] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[26] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[27] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[28] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[29] = numbering_numfmt_romanLcParenBoth;
g_NumberingArr[30] = numbering_numfmt_romanLcParenR;
g_NumberingArr[31] = numbering_numfmt_romanLcPeriod;
g_NumberingArr[32] = numbering_numfmt_romanUcParenBoth;
g_NumberingArr[33] = numbering_numfmt_romanUcParenR;
g_NumberingArr[34] = numbering_numfmt_romanUcPeriod;
g_NumberingArr[35] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[36] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[37] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[38] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[39] = numbering_numfmt_alphaLcPeriod;
g_NumberingArr[40] = numbering_numfmt_alphaLcPeriod;
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 : FirstTextPr.Bold,
Italic : FirstTextPr.Italic
};
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, Heigth)
{
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;
if(Context.IsNoSupportTextDraw)
{
var _heigth = Heigth!= undefined ? Heigth : 0;
for ( var Index2 = 0; Index2 < sT.length; Index2++ )
{
var Char = sT.charAt(Index2);
var w = g_oTextMeasurer.Measure( Char ).Width;
Context.rect(X, Y, w, _heigth);
X += w;
}
}
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();
};
};
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;
}
};
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;
}
};
function CAbstractNum(Type)
{
if ( "undefined" == typeof(Type) )
Type = numbering_numfmt_Bullet;
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add( this, this.Id );
this.Lvl = [];
for ( var Index = 0; Index < 9; Index++ )
{
this.Lvl[Index] = {};
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 = [];
Lvl.ParaPr = {};
/*Lvl.ParaPr.Ind =
{
Left : Left,
FirstLine : FirstLine
}; */
var TextPr = {};
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 ) ) );
}
TextPr.FontSize = 10;
TextPr.Italic = false;
TextPr.Bold = false;
Lvl.TextPr = TextPr;
}
}
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++ )
{
this.Lvl[Index] = this.Internal_CopyLvl( AbstractNum.Lvl[Index] );
}
},
// Определяем многоуровненый список по умолчанию
Create_Default_Numbered : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
this.Lvl[Index] = {};
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 = [];
Lvl.LvlText.push( new CLvlText_Num( Index ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.ParaPr = {};
/* Lvl.ParaPr.Ind =
{
Left : Left,
FirstLine : FirstLine
}; */
var TextPr = {};
TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
Lvl.TextPr = TextPr;
}
},
Create_Default_Multilevel_1 : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
this.Lvl[Index] = {};
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 = [];
Lvl.LvlText.push( new CLvlText_Num( Index ) );
Lvl.LvlText.push( new CLvlText_Text( ")" ) );
Lvl.ParaPr = {};
/* Lvl.ParaPr.Ind =
{
Left : Left,
FirstLine : FirstLine
}; */
var TextPr = {};
TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
Lvl.TextPr = TextPr;
}
},
Create_Default_Multilevel_2 : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
this.Lvl[Index] = {};
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 = [];
for ( var Index2 = 0; Index2 <= Index; Index2++ )
{
Lvl.LvlText.push( new CLvlText_Num( Index2 ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
}
Lvl.ParaPr = {};
/*Lvl.ParaPr.Ind =
{
Left : Left,
FirstLine : FirstLine
};*/
var TextPr = {};
TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
Lvl.TextPr = TextPr;
}
},
Create_Default_Multilevel_3 : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
this.Lvl[Index] = {};
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 = [];
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 = {};
/* Lvl.ParaPr.Ind =
{
Left : Left,
FirstLine : FirstLine
}; */
var TextPr = {};
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;
}
},
Create_Default_Bullet : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
this.Lvl[Index] = {};
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 = [];
Lvl.ParaPr = {};
/*Lvl.ParaPr.Ind =
{
Left : Left,
FirstLine : FirstLine
}; */
var TextPr = {};
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;
}
},
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 = [];
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 } );
},
Set_Lvl_Numbered_33 : 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 = [];
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
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_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 = [];
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 = [];
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 = [];
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 = [];
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 = [];
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 = [];
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 = [];
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 = [];
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 = [];
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 - рассчитанные настройки для символов нумерации (уже с учетом настроек текущего уровня)
Save_Changes : function()
{},
Write_ToBinary2 : function()
{},
Draw : function(X,Y, Context, Lvl, NumInfo, NumTextPr)
{
var Text = this.Lvl[Lvl].LvlText;
var OldFont = Context.GetFont();
var OldFont2 = g_oTextMeasurer.GetFont();
var textPr = clone(NumTextPr);
if(Text[0] && Text[0].Type == numbering_lvltext_Text)
{
if(textPr.Bold)
textPr.Bold = false;
if(textPr.Italic)
textPr.Italic = false;
if(textPr.Underline)
textPr.Underline = false;
}
Context.SetFont( textPr );
g_oTextMeasurer.SetFont( textPr );
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_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_romanLcParenBoth:
case numbering_numfmt_romanLcParenR:
case numbering_numfmt_romanLcPeriod:
case numbering_numfmt_romanUcParenBoth:
case numbering_numfmt_romanUcParenR:
case numbering_numfmt_romanUcPeriod:
{
if ( CurLvl < NumInfo.length )
{
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl];
// Переводим число Num в римскую систему исчисления
var Rims;
if ( numbering_numfmt_romanLcParenBoth === this.Lvl[CurLvl].Format
|| numbering_numfmt_romanLcParenR === this.Lvl[CurLvl].Format
|| numbering_numfmt_romanLcPeriod === 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;
}
switch (this.Lvl[CurLvl].Format)
{
case numbering_numfmt_romanLcParenBoth:
case numbering_numfmt_romanUcParenBoth:
{
T = "(" + T + ")";
break;
}
case numbering_numfmt_romanLcParenR:
case numbering_numfmt_romanUcParenR:
{
T = T + ")";
break;
}
case numbering_numfmt_romanLcPeriod:
case numbering_numfmt_romanUcPeriod:
{
T = T + ".";
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;
}
case numbering_numfmt_alphaLcParenBoth:
case numbering_numfmt_alphaLcParenR:
case numbering_numfmt_alphaLcPeriod:
case numbering_numfmt_alphaUcParenBoth:
case numbering_numfmt_alphaUcParenR:
case numbering_numfmt_alphaUcPeriod:
{
if ( CurLvl < NumInfo.length )
{
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_alphaLcParenBoth === this.Lvl[CurLvl].Format
|| numbering_numfmt_alphaLcParenR === this.Lvl[CurLvl].Format
|| numbering_numfmt_alphaLcPeriod === 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;
switch (this.Lvl[CurLvl].Format)
{
case numbering_numfmt_alphaLcParenBoth:
case numbering_numfmt_alphaUcParenBoth:
{
T += "("+Letter+ ")";
break;
}
case numbering_numfmt_alphaLcParenR:
case numbering_numfmt_alphaUcParenR:
{
T += Letter+ ")";
break;
}
case numbering_numfmt_alphaLcPeriod:
case numbering_numfmt_alphaUcPeriod:
{
T += Letter+ ".";
break;
}
}
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_arabicParenBoth:
{
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_arabicParenR:
{
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_arabicPeriod:
{
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_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;
}
case numbering_numfmt_arabic1Minus :
{
var arabicAlphabet = [];
arabicAlphabet[0] = String.fromCharCode(0x0623);
arabicAlphabet[1] = String.fromCharCode(0x0628);
for(var i = 0; i < 17; ++i)
{
arabicAlphabet[i+2] = String.fromCharCode(0x062A+i);
}
for(i = 0; i < 8; ++i)
{
arabicAlphabet[i+19] = String.fromCharCode(0x0641+i);
}
arabicAlphabet[27] = String.fromCharCode(0x064A);
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] - 1;
var Count = (Num - Num % 27) / 27;
var Ost = Num % 27;
var T = "";
var Letter;
Letter = arabicAlphabet[Ost];
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_arabic2Minus :
{
arabicAlphabet = [];
arabicAlphabet[0] = String.fromCharCode(0x0623);
arabicAlphabet[1] = String.fromCharCode(0x0628);
arabicAlphabet[2] = String.fromCharCode(0x062C);
arabicAlphabet[3] = String.fromCharCode(0x062F);
arabicAlphabet[4] = String.fromCharCode(0x0647);
arabicAlphabet[5] = String.fromCharCode(0x0648);
arabicAlphabet[6] = String.fromCharCode(0x0632);
arabicAlphabet[7] = String.fromCharCode(0x062D);
arabicAlphabet[8] = String.fromCharCode(0x0637);
arabicAlphabet[9] = String.fromCharCode(0x064A);
arabicAlphabet[10] = String.fromCharCode(0x0643);
arabicAlphabet[11] = String.fromCharCode(0x0644);
arabicAlphabet[12] = String.fromCharCode(0x0645);
arabicAlphabet[13] = String.fromCharCode(0x0646);
arabicAlphabet[14] = String.fromCharCode(0x0633);
arabicAlphabet[15] = String.fromCharCode(0x0639);
arabicAlphabet[15] = String.fromCharCode(0x0641);
arabicAlphabet[16] = String.fromCharCode(0x0635);
arabicAlphabet[17] = String.fromCharCode(0x0642);
arabicAlphabet[18] = String.fromCharCode(0x0631);
arabicAlphabet[19] = String.fromCharCode(0x0634);
arabicAlphabet[20] = String.fromCharCode(0x062A);
arabicAlphabet[21] = String.fromCharCode(0x062B);
arabicAlphabet[22] = String.fromCharCode(0x062E);
arabicAlphabet[23] = String.fromCharCode(0x0630);
arabicAlphabet[24] = String.fromCharCode(0x0636);
arabicAlphabet[25] = String.fromCharCode(0x063A);
arabicAlphabet[26] = String.fromCharCode(0x0638);
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] - 1;
var Count = (Num - Num % 27) / 27;
var Ost = Num % 27;
var T = "";
var Letter;
Letter = arabicAlphabet[Ost];
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;
}
}
}
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_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_romanLcParenBoth:
case numbering_numfmt_romanLcParenR:
case numbering_numfmt_romanLcPeriod:
case numbering_numfmt_romanUcParenBoth:
case numbering_numfmt_romanUcParenR:
case numbering_numfmt_romanUcPeriod:
{
if ( CurLvl < NumInfo.length )
{
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl];
// Переводим число Num в римскую систему исчисления
var Rims;
if ( numbering_numfmt_romanLcParenBoth === this.Lvl[CurLvl].Format
|| numbering_numfmt_romanLcParenR === this.Lvl[CurLvl].Format
|| numbering_numfmt_romanLcPeriod === 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;
}
switch (this.Lvl[CurLvl].Format)
{
case numbering_numfmt_romanLcParenBoth:
case numbering_numfmt_romanUcParenBoth:
{
T = "(" + T + ")";
break;
}
case numbering_numfmt_romanLcParenR:
case numbering_numfmt_romanUcParenR:
{
T = T + ")";
break;
}
case numbering_numfmt_romanLcPeriod:
case numbering_numfmt_romanUcPeriod:
{
T = T + ".";
break;
}
}
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += g_oTextMeasurer.Measure( T.charAt(Index2) ).Width;
}
}
break;
}
case numbering_numfmt_alphaLcParenBoth:
case numbering_numfmt_alphaLcParenR:
case numbering_numfmt_alphaLcPeriod:
case numbering_numfmt_alphaUcParenBoth:
case numbering_numfmt_alphaUcParenR:
case numbering_numfmt_alphaUcPeriod:
{
if ( CurLvl < NumInfo.length )
{
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_alphaLcParenBoth === this.Lvl[CurLvl].Format
|| numbering_numfmt_alphaLcParenR === this.Lvl[CurLvl].Format
|| numbering_numfmt_alphaLcPeriod === 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;
switch (this.Lvl[CurLvl].Format)
{
case numbering_numfmt_alphaLcParenBoth:
case numbering_numfmt_alphaUcParenBoth:
{
T += "("+Letter+ ")";
break;
}
case numbering_numfmt_alphaLcParenR:
case numbering_numfmt_alphaUcParenR:
{
T += Letter+ ")";
break;
}
case numbering_numfmt_alphaLcPeriod:
case numbering_numfmt_alphaUcPeriod:
{
T += Letter+ ".";
break;
}
}
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += g_oTextMeasurer.Measure( Char ).Width;
}
}
break;
}
case numbering_numfmt_arabicParenBoth:
{
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 += g_oTextMeasurer.Measure( Char ).Width;
}
}
break;
}
case numbering_numfmt_arabicParenR:
{
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 += g_oTextMeasurer.Measure( Char ).Width;
}
}
break;
}
case numbering_numfmt_arabicPeriod:
{
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 += 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);
X += g_oTextMeasurer.Measure( T.charAt(Index2) ).Width;
}
}
break;
}
case numbering_numfmt_arabic1Minus :
{
var arabicAlphabet = [];
arabicAlphabet[0] = String.fromCharCode(0x0623);
arabicAlphabet[1] = String.fromCharCode(0x0628);
for(var i = 0; i < 17; ++i)
{
arabicAlphabet[i+2] = String.fromCharCode(0x062A+i);
}
for(i = 0; i < 8; ++i)
{
arabicAlphabet[i+19] = String.fromCharCode(0x0641+i);
}
arabicAlphabet[27] = String.fromCharCode(0x064A);
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] - 1;
var Count = (Num - Num % 27) / 27;
var Ost = Num % 27;
var T = "";
var Letter;
Letter = arabicAlphabet[Ost];
for ( var Index2 = 0; Index2 < Count + 1; Index2++ )
T += Letter;
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += g_oTextMeasurer.Measure( Char ).Width;
}
break;
}
case numbering_numfmt_arabic2Minus :
{
arabicAlphabet = [];
arabicAlphabet[0] = String.fromCharCode(0x0623);
arabicAlphabet[1] = String.fromCharCode(0x0628);
arabicAlphabet[2] = String.fromCharCode(0x062C);
arabicAlphabet[3] = String.fromCharCode(0x062F);
arabicAlphabet[4] = String.fromCharCode(0x0647);
arabicAlphabet[5] = String.fromCharCode(0x0648);
arabicAlphabet[6] = String.fromCharCode(0x0632);
arabicAlphabet[7] = String.fromCharCode(0x062D);
arabicAlphabet[8] = String.fromCharCode(0x0637);
arabicAlphabet[9] = String.fromCharCode(0x064A);
arabicAlphabet[10] = String.fromCharCode(0x0643);
arabicAlphabet[11] = String.fromCharCode(0x0644);
arabicAlphabet[12] = String.fromCharCode(0x0645);
arabicAlphabet[13] = String.fromCharCode(0x0646);
arabicAlphabet[14] = String.fromCharCode(0x0633);
arabicAlphabet[15] = String.fromCharCode(0x0639);
arabicAlphabet[15] = String.fromCharCode(0x0641);
arabicAlphabet[16] = String.fromCharCode(0x0635);
arabicAlphabet[17] = String.fromCharCode(0x0642);
arabicAlphabet[18] = String.fromCharCode(0x0631);
arabicAlphabet[19] = String.fromCharCode(0x0634);
arabicAlphabet[20] = String.fromCharCode(0x062A);
arabicAlphabet[21] = String.fromCharCode(0x062B);
arabicAlphabet[22] = String.fromCharCode(0x062E);
arabicAlphabet[23] = String.fromCharCode(0x0630);
arabicAlphabet[24] = String.fromCharCode(0x0636);
arabicAlphabet[25] = String.fromCharCode(0x063A);
arabicAlphabet[26] = String.fromCharCode(0x0638);
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] - 1;
var Count = (Num - Num % 27) / 27;
var Ost = Num % 27;
var T = "";
var Letter;
Letter = arabicAlphabet[Ost];
for ( var Index2 = 0; Index2 < Count + 1; Index2++ )
T += Letter;
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += g_oTextMeasurer.Measure( Char ).Width;
}
}
}
break;
}
}
}
Context.SetFont( OldFont );
return { Width : X, Ascent : Ascent };
},
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 = Styles_Copy_TextPr( CurTextPr );
Common_CopyObj2( CurTextPr, TextPr );
var TextPr_new = Styles_Copy_TextPr( CurTextPr );
History.Add( this, { Type : historyitem_AbstractNum_TextPrChange, Index : Lvl, Old : TextPr_old, New : TextPr_new } );
},
//-----------------------------------------------------------------------------------
// Undo/Redo функции
//-----------------------------------------------------------------------------------
// Копируем информацию о заданном уровне
Internal_CopyLvl : function(Lvl)
{
var Lvl_new = {};
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 = [];
for ( var Index = 0; Index < Lvl.LvlText.length; Index++ )
{
var Item = Lvl.LvlText[Index];
Lvl_new.LvlText.push( Item.Copy() );
}
Lvl_new.TextPr = Styles_Copy_TextPr( Lvl.TextPr );
Lvl_new.ParaPr = Styles_Copy_ParaPr( Lvl.ParaPr );
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;
},
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;
}
}
}
};
function CNumbering()
{
this.AbstractNum = [];
this.Num = [];
}
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];
return AbstractId.Lvl[Lvl].ParaPr;
},
Get_Format : function(NumId, Lvl)
{
var AbstractId = this.AbstractNum[NumId];
return AbstractId.Lvl[Lvl].Format;
},
// Проверяем по типам 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 );
}
};
\ No newline at end of file
// Содержимое параграфа должно иметь:
//
// 1. Type - тип
// 2. Draw - рисуем на контексте
// 3. Measure - измеряем
// 4. Is_RealContent - является ли данный элемент реальным элементом параграфа
//---- после использования Measure -----
// 1. Width - ширина (для рассчетов)
// 2. Height - высота
// 3. WidthVisible - видимая ширина
// TODO: Добавить во все элементы функции типа Is_RealContent, чтобы при добавлении
// нового элемента не надо было бы просматривать каждый раз все функции класса
// CParagraph.
var para_Unknown = -1; //
var para_Empty = 0x0000; // Пустой элемент (таким элементом должен заканчиваться каждый параграф)
var para_Text = 0x0001; // Текст
var para_Space = 0x0002; // Пробелы
var para_TextPr = 0x0003; // Свойства текста
var para_End = 0x0004; // Конец параграфа
var para_NewLine = 0x0010; // Новая строка
var para_NewLineRendered = 0x0011; // Рассчитанный перенос строки
var para_InlineBreak = 0x0012; // Перенос внутри строки (для обтекания)
var para_PageBreakRendered = 0x0013; // Рассчитанный перенос страницы
var para_Numbering = 0x0014; // Элемент, обозначающий нумерацию для списков
var para_Tab = 0x0015; // Табуляция
var para_Drawing = 0x0016; // Графика (картинки, автофигуры, диаграммы, графики)
var para_PageNum = 0x0017; // Нумерация страницы
var para_FlowObjectAnchor = 0x0018; // Привязка для "плавающих" объектов
var para_HyperlinkStart = 0x0019; // Начало гиперссылки
var para_HyperlinkEnd = 0x0020; // Конец гиперссылки
var para_CollaborativeChangesStart = 0x0021; // Начало изменений другого редактора
var para_CollaborativeChangesEnd = 0x0022; // Конец изменений другого редактора
var para_CommentStart = 0x0023; // Начало комментария
var para_CommentEnd = 0x0024; // Начало комментария
var para_PresentationNumbering = 0x0025; // Элемент, обозначающий нумерацию для списков в презентациях
var break_Line = 0x01;
var break_Page = 0x02;
var nbsp_string = String.fromCharCode( 0x00A0 );
var sp_string = String.fromCharCode( 0x0032 );
var g_aPunctuation =
[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0
];
// Класс ParaText
function ParaText(value)
{
this.Value = value;
this.Type = para_Text;
this.SpaceAfter = false;
if ( "-" === this.Value )
this.SpaceAfter = true;
}
ParaText.prototype =
{
Draw : function(X,Y,Context)
{
try
{
if ( true === this.Is_NBSP() && editor.ShowParaMarks )
Context.FillText( X, Y, String.fromCharCode( 0x00B0 ) );
else
Context.FillText( X, Y, this.Value );
}
catch(e)
{
}
},
Measure : function(Context)
{
try
{
var Temp = Context.Measure( this.Value );
this.Width = Temp.Width;
this.Height = Temp.Height;
this.WidthVisible = Temp.Width;
}
catch(e)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
}
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Is_NBSP : function()
{
return (this.Value === nbsp_string ? true : false);
},
Is_Punctuation : function()
{
var CharCode = this.Value.charCodeAt(0);
if ( 1 === this.Value.length && 1 === g_aPunctuation[this.Value.charCodeAt(0)] )
return true;
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// Long : Value
// Bool : SpaceAfter
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Value );
Writer.WriteBool( this.SpaceAfter );
},
Read_FromBinary : function(Reader)
{
this.Value = Reader.GetString2();
this.SpaceAfter = Reader.GetBool();
}
};
// Класс ParaSpace
function ParaSpace(Count)
{
if ( "number" != typeof(Count) )
this.Value = 1;
else
this.Value = Count;
this.Type = para_Space;
}
ParaSpace.prototype =
{
Draw : function(X,Y, Context)
{
var sString = "";
if ( 1 == this.Value )
sString = String.fromCharCode( 0x00B7 );
else
{
for ( var Index = 0; Index < this.Value; Index++ )
{
sString += String.fromCharCode( 0x00B7 );
}
}
try
{
if ( editor.ShowParaMarks )
Context.FillText( X, Y, sString );
}
catch(e)
{
}
},
Measure : function(Context)
{
var sString = "";
if ( 1 == this.Value )
sString = " ";
else
{
for ( var Index = 0; Index < this.Value; Index++ )
{
sString += " ";
}
}
try
{
var Temp = Context.Measure( sString );
this.Width = Temp.Width;
this.Height = Temp.Height;
this.WidthVisible = Temp.Width;
}
catch(e)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
}
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// Long : Value
Writer.WriteLong( this.Type );
Writer.WriteLong( this.Value );
},
Read_FromBinary : function(Reader)
{
this.Value = Reader.GetLong();
}
};
// Класс ParaTextPr
function ParaTextPr(Props)
{
this.Id = g_oIdCounter.Get_NewId();
this.Type = para_TextPr;
this.Value = {};
this.Parent = null;
if ( "object" == typeof(Props) )
{
for(var Prop in Props)
{
this.Value[Prop] = Common_CopyObj( Props[Prop] );
}
}
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
}
ParaTextPr.prototype =
{
Draw : function()//(X,Y,Context)
{
// Ничего не делаем
},
Measure : function()//(Context)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Set_Id : function(newId)
{
g_oTableId.Reset_Id( this, newId, this.Id );
this.Id = newId;
},
Get_Id : function()
{
return this.Id;
},
//-----------------------------------------------------------------------------------
// Функции для изменения свойств
//-----------------------------------------------------------------------------------
Set_Prop : function(Prop, Value)
{
var OldValue = null;
if ( "undefined" != typeof(this.Value[Prop]) )
OldValue = this.Value[Prop];
this.Value[Prop] = Value;
History.Add( this, { Type : historyitem_TextPr_Change, Prop : Prop, New : Value, Old : OldValue } );
},
Delete_Prop : function(Prop)
{
if ( "undefined" === typeof(this.Value[Prop]) )
return;
var OldValue = this.Value[Prop];
delete this.Value[Prop];
History.Add( this, { Type : historyitem_TextPr_Change, Prop : Prop, New : null, Old : OldValue } );
},
Set_FontSize : function(Value)
{
var OldValue = null;
if ( "undefined" != typeof(this.Value.FontSize) )
OldValue = this.Value.FontSize;
if ( null != Value )
this.Value.FontSize = Value;
else
delete this.Value.FontSize;
History.Add( this, { Type : historyitem_TextPr_FontSize, New : Value, Old : OldValue } );
},
Set_Color : function(Value)
{
var OldValue = null;
if ( "undefined" != typeof(this.Value.Color) )
OldValue = this.Value.Color;
if ( null != Value )
this.Value.Color = Value;
else
delete this.Value.Color;
History.Add( this, { Type : historyitem_TextPr_Color, New : Value, Old : OldValue } );
},
Set_Underline : function(Value)
{
var OldValue = null;
if ( "undefined" != typeof(this.Value.Underline) )
OldValue = this.Value.Underline;
if ( null != Value )
this.Value.Underline = Value;
else
delete this.Value.Underline;
History.Add( this, { Type : historyitem_TextPr_Underline, New : Value, Old : OldValue } );
},
//-----------------------------------------------------------------------------------
// Undo/Redo функции
//-----------------------------------------------------------------------------------
Undo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_TextPr_Change:
{
if ( null != Data.Old )
this.Value[Data.Prop] = Data.Old;
else
delete this.Value[Data.Prop];
break;
}
case historyitem_TextPr_FontSize:
{
if ( null != Data.Old )
this.Value.FontSize = Data.Old;
else
delete this.Value.FontSize;
break;
}
case historyitem_TextPr_Color:
{
if ( null != Data.Old )
this.Value.Color = Data.Old;
else
delete this.Value.Color;
break;
}
case historyitem_TextPr_Underline:
{
if ( null != Data.Old )
this.Value.Underline = Data.Old;
else
delete this.Value.Underline;
break;
}
}
History.RecalcData_Add( this.Get_ParentObject_or_DocumentPos() );
},
Redo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_TextPr_Change:
{
if ( null != Data.New )
this.Value[Data.Prop] = Data.New;
else
delete this.Value[Data.Prop];
break;
}
case historyitem_TextPr_FontSize:
{
if ( null != Data.New )
this.Value.FontSize = Data.New;
else
delete this.Value.FontSize;
break;
}
case historyitem_TextPr_Color:
{
if ( null != Data.New )
this.Value.Color = Data.New;
else
delete this.Value.Color;
break;
}
case historyitem_TextPr_Underline:
{
if ( null != Data.New )
this.Value.Underline = Data.New;
else
delete this.Value.Underline;
break;
}
}
History.RecalcData_Add( this.Get_ParentObject_or_DocumentPos() );
},
Get_ParentObject_or_DocumentPos : function()
{
if ( null != this.Parent )
return this.Parent.Get_ParentObject_or_DocumentPos();
},
//-----------------------------------------------------------------------------------
// Функции для работы с совместным редактирования
//-----------------------------------------------------------------------------------
Write_ToBinary : function(Writer)
{
// Long : Type
// String : Id
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
},
Write_ToBinary2 : function(Writer)
{
Writer.WriteLong( historyitem_type_TextPr );
// Long : Type
// String : Id
// Long : Value
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
Styles_Write_TextPr_ToBinary( this.Value, Writer );
},
Read_FromBinary2 : function(Reader)
{
this.Type = Reader.GetLong();
this.Id = Reader.GetString2();
this.Value = {};
Styles_Read_TextPr_FromBinary( this.Value, Reader );
},
Save_Changes : function(Data, Writer)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
Writer.WriteLong( historyitem_type_TextPr );
var Type = Data.Type;
// Пишем тип
Writer.WriteLong( Type );
switch ( Type )
{
case historyitem_TextPr_Change:
{
// Variable : TextPr
var TextPr = {};
TextPr[Data.Prop] = Data.New;
Styles_Write_TextPr_ToBinary( TextPr, Writer );
break;
}
case historyitem_TextPr_FontSize:
{
// Bool : null?
// Double : FontSize
if ( null != Data.New )
{
Writer.WriteBool(false);
Writer.WriteDouble( Data.New );
}
else
Writer.WriteBool(true);
break;
}
case historyitem_TextPr_Color:
{
// Bool : null?
// Byte : Color.r
// Byte : Color.g
// Byte : Color.b
if ( null != Data.New )
{
Writer.WriteBool(false);
Writer.WriteByte(Data.New.r);
Writer.WriteByte(Data.New.g);
Writer.WriteByte(Data.New.b);
}
else
Writer.WriteBool(true);
break;
}
case historyitem_TextPr_Underline:
{
// Bool : null?
// Bool : Underline
if ( null != Data.New )
{
Writer.WriteBool(false);
Writer.WriteBool(Data.New);
}
else
Writer.WriteBool(true);
break;
}
}
return Writer;
},
Load_Changes : function(Reader)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
var ClassType = Reader.GetLong();
if ( historyitem_type_TextPr != ClassType )
return;
var Type = Reader.GetLong();
switch ( Type )
{
case historyitem_TextPr_Change:
{
// Variable : TextPr
var TextPr = {};
Styles_Read_TextPr_FromBinary( TextPr, Reader );
Common_CopyObj2( this.Value, TextPr );
break;
}
case historyitem_TextPr_FontSize:
{
// Bool : null?
// Double : FontSize
var bNull = Reader.GetBool();
if ( true != bNull )
this.Value.FontSize = Reader.GetDouble();
else
delete this.Value.FontSize;
break;
}
case historyitem_TextPr_Color:
{
// Bool : null?
// Byte : Color.r
// Byte : Color.g
// Byte : Color.b
var bNull = Reader.GetBool();
if ( true != bNull )
{
this.Value.Color = {};
this.Value.Color.r = Reader.GetByte();
this.Value.Color.g = Reader.GetByte();
this.Value.Color.b = Reader.GetByte();
}
else
delete this.Value.Color;
break;
}
case historyitem_TextPr_Underline:
{
// Bool : null?
// Bool : Underline
var bNull = Reader.GetBool();
if ( true != bNull )
this.Value.Underline = Reader.GetBool();
else
delete this.Value.Underline;
break;
}
}
}
};
// Класс окончание параграфа ParaEnd
function ParaEnd()
{
this.Type = para_End;
}
ParaEnd.prototype =
{
Draw : function(X,Y,Context, bEndCell)
{
if ( editor.ShowParaMarks )
{
if ( true === bEndCell )
Context.FillText( X, Y, String.fromCharCode( 0x00A4 ) );
else
Context.FillText( X, Y, String.fromCharCode( 0x00B6 ) );
}
},
Measure : function(Context, bEndCell)
{
this.Width = 0;
this.Height = 0;
if ( true === bEndCell )
this.WidthVisible = Context.Measure( String.fromCharCode( 0x00A4 ) ).Width;
else
this.WidthVisible = Context.Measure( String.fromCharCode( 0x00B6 ) ).Width;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaNewLine
function ParaNewLine(BreakType)
{
this.Type = para_NewLine;
this.BreakType = BreakType;
this.Flags = {}; // специальные флаги для разных break
if ( break_Page === this.BreakType )
this.Flags.NewLine = true;
}
ParaNewLine.prototype =
{
Draw : function(X,Y,Context)
{
if ( editor.ShowParaMarks )
{
switch( this.BreakType )
{
case break_Line:
{
var oldFont = Context.GetFont();
Context.SetFont( {FontFamily: { Name : "Wingdings 3", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
Context.FillText( X, Y, String.fromCharCode( 0x0038/*0x21B5*/ ) );
Context.SetFont( oldFont );
break;
}
case break_Page:
{
var PageBreak_String = "";
for ( var Index = 0; Index < 41; Index++ )
{
if ( 20 != Index )
PageBreak_String += String.fromCharCode("0x00B7");
else
PageBreak_String += "PageBreak";
}
var oldFont = Context.GetFont();
var OldColor = Common_CopyObj( Context.m_oBrush.Color1 );
Context.b_color1( 0, 0 , 0, 255);
g_oTextMeasurer.SetFont( {FontFamily: { Name : "Arial", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
Context.SetFont( {FontFamily: { Name : "Arial", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
for ( var Index = 0; Index < PageBreak_String.length; Index++ )
{
Context.FillText( X, Y, PageBreak_String[Index] );
X += g_oTextMeasurer.Measure( PageBreak_String[Index] ).Width;
}
Context.SetFont( oldFont );
Context.b_color1( OldColor.R, OldColor.G, OldColor.B, OldColor.A);
g_oTextMeasurer.SetFont( oldFont );
break;
}
}
}
},
Measure : function(Context)
{
switch( this.BreakType )
{
case break_Line:
{
this.Width = 0;
this.Height = 0;
var oldFont = Context.GetFont();
Context.SetFont( {FontFamily: { Name : "Wingdings 3", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
var Temp = Context.Measure( String.fromCharCode( 0x0038 ) );
Context.SetFont( oldFont );
// Почему-то в шрифте Wingding 3 символ 0x0038 имеет неправильную ширину
this.WidthVisible = Temp.Width * 1.7;
break;
}
case break_Page:
{
this.Width = 0;
this.Height = 0;
var PageBreak_String = "";
for ( var Index = 0; Index < 41; Index++ )
{
if ( 20 != Index )
PageBreak_String += String.fromCharCode("0x00B7");
else
PageBreak_String += "PageBreak";
}
var oldFont = g_oTextMeasurer.GetFont();
g_oTextMeasurer.SetFont( {FontFamily: { Name : "Arial", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
var W = 0;
for ( var Index = 0; Index < PageBreak_String.length; Index++ )
W += g_oTextMeasurer.Measure( PageBreak_String[Index] ).Width;
g_oTextMeasurer.SetFont( oldFont );
this.WidthVisible = W;
break;
}
}
return { Width : this.Width, Height : this.Height , WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
// Функция проверяет особый случай, когда у нас PageBreak, после которого в параграфе ничего не идет
Is_NewLine : function()
{
if ( break_Line === this.BreakType || ( break_Page === this.BreakType && true === this.Flags.NewLine ) )
return true;
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// Long : BreakType
// Optional :
// Long : Flags (breakPage)
Writer.WriteLong( this.Type );
Writer.WriteLong( this.BreakType );
if ( break_Page === this.BreakType )
{
Writer.WriteBool( this.Flags.NewLine );
}
},
Read_FromBinary : function(Reader)
{
this.BreakType = Reader.GetLong();
if ( break_Page === this.BreakType )
this.Flags = { NewLine : Reader.GetBool() };
}
};
// Класс ParaNewLineRendered
function ParaNewLineRendered()
{
this.Type = para_NewLineRendered;
}
ParaNewLineRendered.prototype =
{
Draw : function()//(X,Y,Context)
{
// Ничего не делаем
},
Measure : function()//(Context)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaInlineBreak
function ParaInlineBreak()
{
this.Type = para_InlineBreak;
}
ParaInlineBreak.prototype =
{
Draw : function()
{
// Ничего не делаем
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaPageBreakRenderer
function ParaPageBreakRenderer()
{
this.Type = para_PageBreakRendered;
}
ParaPageBreakRenderer.prototype =
{
Draw : function()
{
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaEmpty
function ParaEmpty(bDelete)
{
this.Type = para_Empty;
this.NeedToDelete = false; // Нужно ли удалить данный элемент при пересчете параграфа
if ( "undefined" != typeof(bDelete) && null != bDelete )
this.NeedToDelete = bDelete;
}
ParaEmpty.prototype =
{
Draw : function()
{
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Check_Delete : function()
{
return this.NeedToDelete;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// Bool : NeedToDelete
Writer.WriteLong( this.Type );
Writer.WriteBool( this.NeedToDelete );
},
Read_FromBinary : function(Reader)
{
this.NeedToDelete = Reader.GetBool();
}
};
// Класс ParaNumbering
function ParaNumbering(NumPr)
{
this.Type = para_Numbering;
this.NumPr =
{
NumId : 0,
Lvl : 0
};
if ( NumPr && NumPr.NumId )
this.NumPr.NumId = NumPr.NumId;
if ( NumPr && NumPr.Lvl )
this.NumPr.Lvl = NumPr.Lvl;
}
ParaNumbering.prototype =
{
Draw : function(X,Y,Context, Numbering, NumInfo, TextPr)
{
Numbering.Draw( this.NumPr.NumId, this.NumPr.Lvl, X, Y, Context, NumInfo, TextPr );
},
Measure : function (Context, Numbering, NumInfo, TextPr)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
this.WidthNum = 0;
this.WidthSuff = 0;
if ( "undefined" === typeof(Numbering) )
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
var Temp = Numbering.Measure( this.NumPr.NumId, this.NumPr.Lvl, Context, NumInfo, TextPr );
this.Width = Temp.Width;
this.WidthVisible = Temp.Width;
this.WidthNum = Temp.Width;
this.WidthSuff = 0;
this.Height = Temp.Ascent; // Это не вся высота, а только высота над BaseLine
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// String : NumId
// Long : NumLvl
Writer.WriteLong( this.Type );
Writer.WriteString2( this.NumPr.NumId );
Writer.WriteLong( this.NumPr.Lvl );
},
Read_FromBinary : function(Reader)
{
this.NumPr.NumId = Reader.GetString2();
this.NumPr.Lvl = Reader.GetLong();
}
};
// TODO: Реализовать табы правые, центральные, по точке и с чертой.
var tab_Left = 0x01;
var tab_Right = 0x02;
var tab_Center = 0x03;
var tab_Symbol = 0x0022;//0x2192;
// Класс ParaTab
function ParaTab()
{
this.Type = para_Tab;
this.TabType = tab_Left;
}
ParaTab.prototype =
{
Draw : function(X,Y,Context)
{
if ( editor.ShowParaMarks )
{
var X0 = this.Width / 2 - this.RealWidth / 2;
var oldFont = Context.GetFont();
Context.SetFont( {FontFamily: { Name : "Wingdings 3", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
if ( X0 > 0 )
Context.FillText2( X + X0, Y, String.fromCharCode( tab_Symbol ), 0, this.Width );
else
Context.FillText2( X, Y, String.fromCharCode( tab_Symbol ), this.RealWidth - this.Width, this.Width );
Context.SetFont( oldFont );
}
},
Measure : function (Context)
{
var oldFont = Context.GetFont();
Context.SetFont( {FontFamily: { Name : "Wingdings 3", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
this.RealWidth = Context.Measure( String.fromCharCode( tab_Symbol ) ).Width;
Context.SetFont( oldFont );
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// Long : TabType
Writer.WriteLong( this.Type );
Writer.WriteLong( this.TabType );
},
Read_FromBinary : function(Reader)
{
this.TabType = Reader.GetLong();
}
};
var drawing_Inline = 0x01;
var drawing_Anchor = 0x02;
// Класс ParaDrawing
function ParaDrawing(W, H, GraphicObj, DrawingDocument, DocumentContent, Parent)
{
this.Id = g_oIdCounter.Get_NewId();
this.Type = para_Drawing;
this.Distance =
{
T : 0,
B : 0,
L : 0,
R : 0
};
this.Lock = new CLock();
if ( false === g_oIdCounter.m_bLoad )
{
this.Lock.Set_Type( locktype_Mine, false );
CollaborativeEditing.Add_Unlock2( this );
}
this.DrawingType = drawing_Inline;
this.GraphicObj = GraphicObj;
this.X = 0;
this.Y = 0;
this.W = W;
this.H = H;
this.PageNum = 0;
this.DocumentContent = DocumentContent;
this.DrawingDocument = DrawingDocument;
this.Parent = Parent;
this.Focused = false;
this.ImageTrackType = 1;
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
}
ParaDrawing.prototype =
{
Draw : function(X,Y,Context)
{
// координаты графического объекта должны обновляться через функцию
// Update_Position, а приходящие здесь координаты мы не учитываем
this.GraphicObj.Draw( Context, this.X, this.Y, this.W, this.H );
},
Measure : function(Context)
{
this.Width = this.W;
this.Height = this.H;
this.WidthVisible = this.W;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
//--------------------------------------------
Set_Id : function(newId)
{
g_oTableId.Reset_Id( this, newId, this.Id );
this.Id = newId;
},
Get_Id : function()
{
return this.Id;
},
Update_Position : function(X,Y, PageNum)
{
this.X = X;
this.Y = Y;
this.PageNum = PageNum;
if ( true === this.Focused )
this.DrawingDocument.StartTrackImage( this, this.X, this.Y, this.W, this.H, this.ImageTrackType, this.PageNum );
},
Update_Size : function(W,H)
{
History.Add( this, { Type : historyitem_Drawing_Size, New : { W : W, H : H }, Old : { W : this.W, H : this.H } } );
this.W = W;
this.H = H;
},
Set_Url : function(Img)
{
History.Add( this, { Type : historyitem_Drawing_Url, New : Img, Old : this.GraphicObj.Img } );
this.GraphicObj.Img = Img;
},
IsPointIn : function(X, Y, PageIndex)
{
if ( X >= this.X && X <= this.X + this.W && Y >= this.Y && Y <= this.Y + this.H && null != this.Parent && "undefined" != typeof(this.Parent) && PageIndex === this.Parent.Get_DrawingObject_Page( this.Id ) )
return true;
return false;
},
Get_DrawingType : function()
{
return this.DrawingType;
},
// Устанавливаем фокус на данном объекте
Focus : function()
{
this.Focused = true;
this.DrawingDocument.StartTrackImage( this, this.X, this.Y, this.W, this.H, this.ImageTrackType );
},
// Убираем фокус с данного объекта
Blur : function()
{
if ( true === this.Focused )
{
this.Focused = false;
this.DrawingDocument.EndTrack();
}
},
// Интерфейс для треков
Track_Draw : function(Left, Top, Right, Bottom)
{
this.DrawingDocument.m_oTrackObject.DrawImageInTrack( this.GraphicObj.Img, Left, Top, Right, Bottom );
},
// Трек закончил работу на странице PageNum, c новыми координатами X, Y, W, H
Track_End : function(PageNum, X, Y, W, H)
{
var LogicDocument = editor.WordControl.m_oLogicDocument;
if ( W < 0 || H < 0 )
{
if ( false === LogicDocument.Document_Is_SelectionLocked(changestype_Image_Properties, { Type : changestype_2_InlineObjectMove, PageNum : PageNum, X : X, Y : Y } ) )
{
LogicDocument.Create_NewHistoryPoint();
this.DocumentContent.InlineObject_Move( this.Id, X, Y, PageNum );
}
else
{
LogicDocument.Document_UpdateSelectionState();
}
}
else
{
// Проверяем, залочено ли данное изображение
if ( false === editor.WordControl.m_oLogicDocument.Document_Is_SelectionLocked(changestype_Image_Properties) )
{
LogicDocument.Create_NewHistoryPoint();
this.DocumentContent.InlineObject_Resize( this.Id, W, H );
}
else
{
LogicDocument.Document_UpdateSelectionState();
}
}
},
Update_CursorType : function(X, Y, PageIndex)
{
this.DrawingDocument.SetCursorType( "move", new CMouseMoveData() );
if ( null != this.Parent )
{
var Lock = this.Parent.Lock;
if ( true === Lock.Is_Locked() )
{
var PNum = Math.max( 0, Math.min( PageIndex - this.Parent.PageNum, this.Parent.Pages.length - 1 ) );
var _X = this.Parent.Pages[PNum].X;
var _Y = this.Parent.Pages[PNum].Y;
var MMData = new CMouseMoveData();
var Coords = this.DrawingDocument.ConvertCoordsToCursorWR( _X, _Y, this.Parent.Get_StartPage_Absolute() + ( PageIndex - this.Parent.PageNum ) );
MMData.X_abs = Coords.X - 5;
MMData.Y_abs = Coords.Y;
MMData.Type = c_oAscMouseMoveDataTypes.LockedObject;
MMData.UserId = Lock.Get_UserId();
MMData.HaveChanges = Lock.Have_Changes();
MMData.LockedObjectType = c_oAscMouseMoveLockedObjectType.Common;
editor.sync_MouseMoveCallback( MMData );
}
}
},
//-----------------------------------------------------------------------------------
// Undo/Redo функции
//-----------------------------------------------------------------------------------
Undo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_Drawing_Size:
{
this.W = Data.Old.W;
this.H = Data.Old.H;
break;
}
case historyitem_Drawing_Url:
{
this.GraphicObj.Img = Data.Old;
break;
}
}
History.RecalcData_Add( this.Get_ParentObject_or_DocumentPos() );
},
Redo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_Drawing_Size:
{
this.W = Data.New.W;
this.H = Data.New.H;
break;
}
case historyitem_Drawing_Url:
{
this.GraphicObj.Img = Data.New;
break;
}
}
History.RecalcData_Add( this.Get_ParentObject_or_DocumentPos() );
},
Get_ParentObject_or_DocumentPos : function()
{
return this.Parent.Get_ParentObject_or_DocumentPos();
},
//-----------------------------------------------------------------------------------
// Функции для совместного редактирования
//-----------------------------------------------------------------------------------
Document_Is_SelectionLocked : function(CheckType)
{
},
Save_Changes : function(Data, Writer)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
Writer.WriteLong( historyitem_type_Drawing );
var Type = Data.Type;
// Пишем тип
Writer.WriteLong( Type );
switch ( Type )
{
case historyitem_Drawing_Size:
{
// Double : W
// Double : H
Writer.WriteDouble( Data.New.W );
Writer.WriteDouble( Data.New.H );
break;
}
case historyitem_Drawing_Url:
{
// String : указатель на картинку
Writer.WriteString2( Data.New );
break;
}
}
return Writer;
},
Load_Changes : function(Reader)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
var ClassType = Reader.GetLong();
if ( historyitem_type_Drawing != ClassType )
return;
var Type = Reader.GetLong();
switch ( Type )
{
case historyitem_Drawing_Size:
{
// Double : W
// Double : H
this.W = Reader.GetDouble();
this.H = Reader.GetDouble();
break;
}
case historyitem_Drawing_Url:
{
// String : указатель на картинку
this.GraphicObj.Img = Reader.GetString2();
break;
}
}
},
//-----------------------------------------------------------------------------------
// Функции для записи/чтения в поток
//-----------------------------------------------------------------------------------
Write_ToBinary : function(Writer)
{
// Long : Type
// String : Id
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
},
Write_ToBinary2 : function(Writer)
{
Writer.WriteLong( historyitem_type_Drawing );
// Long : Type
// String : Id
// String : ParentId
// Byte : DrawingType
// Long : W
// Long : H
// Long : Distance.T
// Long : Distance.B
// Long : Distance.L
// Long : Distance.R
// String : Указатель на картинку
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
Writer.WriteByte( this.DrawingType );
Writer.WriteDouble( this.W );
Writer.WriteDouble( this.H );
Writer.WriteDouble( this.Distance.T );
Writer.WriteDouble( this.Distance.B );
Writer.WriteDouble( this.Distance.L );
Writer.WriteDouble( this.Distance.R );
Writer.WriteString2( this.GraphicObj.Img );
},
Read_FromBinary2 : function(Reader)
{
this.DrawingDocument = editor.WordControl.m_oLogicDocument.DrawingDocument;
this.Type = Reader.GetLong();
this.Id = Reader.GetString2();
this.DrawingType = Reader.GetByte();
this.W = Reader.GetDouble();
this.H = Reader.GetDouble();
this.Distance.T = Reader.GetDouble();
this.Distance.B = Reader.GetDouble();
this.Distance.L = Reader.GetDouble();
this.Distance.R = Reader.GetDouble();
this.GraphicObj = new GraphicPicture( Reader.GetString2() );
CollaborativeEditing.Add_NewImage( this.GraphicObj.Img );
},
Load_LinkData : function(LinkData)
{
}
};
// Класс GraphicPicture
function GraphicPicture(Img)
{
this.Img = Img;
}
GraphicPicture.prototype =
{
Draw : function(Context, X, Y, W, H)
{
Context.drawImage( this.Img, X, Y, W, H );
}
};
// Класс ParaPageNum
function ParaPageNum()
{
this.Type = para_PageNum;
}
ParaPageNum.prototype =
{
Draw : function(X,Y,Context, Value, Align)
{
// Value - реальное значение, которое должно быть отрисовано.
// Align - прилегание параграфа, в котором лежит данный номер страницы.
var sValue = "" + (Value + 1);
var oldFont = g_oTextMeasurer.GetFont();
g_oTextMeasurer.SetFont( Context.GetFont() );
var RealWidth = 0;
for ( var Index = 0; Index < sValue.length; Index++ )
{
var Char = sValue.charAt(Index);
RealWidth += g_oTextMeasurer.Measure( Char ).Width;
}
var _X = X;
var _Y = Y;
switch(Align)
{
case align_Left:
{
_X = X;
break;
}
case align_Right:
{
_X = X + this.Width - RealWidth;
break;
}
case align_Center:
{
_X = X + (this.Width - RealWidth) / 2;
break;
}
}
for ( var Index = 0; Index < sValue.length; Index++ )
{
var Char = sValue.charAt(Index);
Context.FillText( _X, _Y, Char );
_X += g_oTextMeasurer.Measure( Char ).Width;
}
g_oTextMeasurer.SetFont( oldFont );
},
Measure : function (Context)
{
var Width = 0;
for ( var Index = 0; Index < 10; Index++ )
{
var TempW = Context.Measure( "" + Index ).Width;
if ( Width < TempW )
Width = TempW;
}
// Выделяем место под 4 знака
Width *= 4;
this.Width = Width;
this.Height = 0;
this.WidthVisible = Width;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaFlowObjectAnchor
function ParaFlowObjectAnchor(FlowObject)
{
this.Type = para_FlowObjectAnchor;
this.FlowObject = FlowObject;
}
ParaFlowObjectAnchor.prototype =
{
Draw : function(X,Y,Context, Value, Align)
{
},
Measure : function (Context)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : 0, Height : 0, WidthVisible : 0 };
},
Is_RealContent : function()
{
return false;
},
Set_FlowObject : function(Object)
{
this.FlowObject = Object;
},
Get_FlowObject : function()
{
return this.FlowObject;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс начало гиперссылки
function ParaHyperlinkStart()
{
this.Type = para_HyperlinkStart;
this.Value = "";
this.Visited = false;
this.ToolTip = null;
}
ParaHyperlinkStart.prototype =
{
Draw : function(X, Y, Context)
{
},
Measure : function(Context)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : 0, Height : 0, WidthVisible : 0 };
},
Is_RealContent : function()
{
return true;
},
Set_Visited : function(Value)
{
this.Visited = Value;
},
Get_Visited : function()
{
return this.Visited;
},
Set_ToolTip : function(ToolTip)
{
this.ToolTip = ToolTip;
},
Get_ToolTip : function()
{
if ( null === this.ToolTip )
{
if ( "string" === typeof(this.Value) )
return this.Value;
else
return "";
}
else
return this.ToolTip;
},
Get_Value : function()
{
return this.Value;
},
Set_Value : function(Value)
{
this.Value = Value;
},
Copy : function()
{
var Hyperlink_new = new ParaHyperlinkStart();
Hyperlink_new.Value = this.Value;
Hyperlink_new.Visited = this.Visited;
Hyperlink_new.ToolTip = this.ToolTip;
return Hyperlink_new;
},
Write_ToBinary : function(Writer)
{
// Long : Type
// String : Value
// String : ToolTip
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Value );
Writer.WriteString2( this.ToolTip == null ? "" : this.ToolTip );
},
Read_FromBinary : function(Reader)
{
this.Value = Reader.GetString2();
this.ToolTip = Reader.GetString2();
if ( "" == this.ToolTip )
this.ToolTip = null;
}
};
// Класс конец гиперссылки
function ParaHyperlinkEnd()
{
this.Type = para_HyperlinkEnd;
}
ParaHyperlinkEnd.prototype =
{
Draw : function(X, Y, Context)
{
},
Measure : function(Context)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : 0, Height : 0, WidthVisible : 0 };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaCollaborativeChangesStart
function ParaCollaborativeChangesStart()
{
this.Type = para_CollaborativeChangesStart;
}
ParaCollaborativeChangesStart.prototype =
{
Draw : function()
{
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaCollaborativeChangesEnd
function ParaCollaborativeChangesEnd()
{
this.Type = para_CollaborativeChangesEnd;
}
ParaCollaborativeChangesEnd.prototype =
{
Draw : function()
{
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
// Класс ParaCommentStart
function ParaCommentStart(Id)
{
this.Type = para_CommentStart;
this.Id = Id;
}
ParaCommentStart.prototype =
{
Draw : function()
{
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
},
Read_FromBinary : function(Reader)
{
this.Id = Reader.GetString2();
}
};
// Класс ParaCommentEnd
function ParaCommentEnd(Id)
{
this.Type = para_CommentEnd;
this.Id = Id;
}
ParaCommentEnd.prototype =
{
Draw : function()
{
},
Measure : function()
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
},
Read_FromBinary : function(Reader)
{
this.Id = Reader.GetString2();
}
};
// Класс ParaPresentationNumbering
function ParaPresentationNumbering()
{
this.Type = para_PresentationNumbering;
// Эти данные заполняются во время пересчета, перед вызовом Measure
this.Bullet = null;
this.BulletNum = null;
}
ParaPresentationNumbering.prototype =
{
Draw : function(X, Y, Context, FirstTextPr)
{
this.Bullet.Draw( X, Y, Context, FirstTextPr );
},
Measure : function (Context, FirstTextPr)
{
this.Width = 0;
this.Height = 0;
this.WidthVisible = 0;
var Temp = this.Bullet.Measure( Context, FirstTextPr, this.BulletNum );
this.Width = Temp.Width;
this.WidthVisible = Temp.Width;
return { Width : this.Width, Height : this.Height, WidthVisible : this.WidthVisible };
},
Is_RealContent : function()
{
return true;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
}
};
function ParagraphContent_Read_FromBinary(Reader)
{
var ElementType = Reader.GetLong();
var Element = null;
switch ( ElementType )
{
case para_TextPr :
case para_Drawing :
{
var ElementId = Reader.GetString2();
Element = g_oTableId.Get_ById( ElementId );
return Element;
}
case para_Text : Element = new ParaText(); break;
case para_Space : Element = new ParaSpace(); break;
case para_End : Element = new ParaEnd(); break;
case para_NewLine : Element = new ParaNewLine(); break;
case para_NewLineRendered : Element = new ParaNewLineRendered(); break;
case para_InlineBreak : Element = new ParaInlineBreak(); break;
case para_PageBreakRendered : Element = new ParaPageBreakRenderer(); break;
case para_Empty : Element = new ParaEmpty(); break;
case para_Numbering : Element = new ParaNumbering(); break;
case para_Tab : Element = new ParaTab(); break;
case para_PageNum : Element = new ParaPageNum(); break;
case para_FlowObjectAnchor : Element = new ParaFlowObjectAnchor(); break;
case para_HyperlinkStart : Element = new ParaHyperlinkStart(); break;
case para_HyperlinkEnd : Element = new ParaHyperlinkEnd(); break;
case para_CommentStart : Element = new ParaCommentStart(); break;
case para_CommentEnd : Element = new ParaCommentEnd(); break;
case para_PresentationNumbering : Element = new ParaPresentationNumbering(); break;
}
if ( null != Element )
Element.Read_FromBinary(Reader);
return Element;
}
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.
var moveTo=0,
lineTo=1,
arcTo=2,
bezier3=3,
bezier4=4,
close=5;
var cToRad = 1/(60000*57.295779513);
var cToDeg = 1/cToRad;
function Path(extrusionOk, fill, stroke, w, h)
{
if(stroke!=undefined)
this.stroke = stroke;
else
this.stroke = true;
this.extrusionOk = extrusionOk||false;
this.fill = fill||'norm';
this.pathW = w != undefined ? w : undefined;
this.pathH = h != undefined ? h : undefined;
this.ArrPathCommandInfo = [];
this.ArrPathCommandLocal = [];
this.ArrPathCommand = [];
this.createDuplicate = function()
{
var duplicate = new Path(this.extrusionOk, this.fill, this.stroke, this.pathW, this.pathH);
for(var i = 0; i<this.ArrPathCommandInfo.length; ++i)
{
duplicate.ArrPathCommandInfo[i] = clonePrototype(this.ArrPathCommandInfo[i]);
}
for (i = 0; i < this.ArrPathCommand.length; ++i)
{
duplicate.ArrPathCommand[i] = clonePrototype(this.ArrPathCommand[i]);
}
return duplicate;
}
}
Path.prototype = {
moveTo: function(x, y)
{
if(!isNaN(parseInt(x,10)))
x=parseInt(x,10);
if(!isNaN(parseInt(y,10)))
y=parseInt(y,10);
this.ArrPathCommandInfo.push({id:moveTo, X:x, Y:y});
},
lnTo: function(x, y)
{
if(!isNaN(parseInt(x,10)))
x=parseInt(x,10);
if(!isNaN(parseInt(y,10)))
y=parseInt(y,10);
this.ArrPathCommandInfo.push({id:lineTo, X:x, Y:y});
},
arcTo: function(wR, hR, stAng, swAng)
{
if(!isNaN(parseInt(wR,10)))
wR=parseInt(wR,10);
if(!isNaN(parseInt(hR,10)))
hR=parseInt(hR,10);
if(!isNaN(parseInt(stAng,10)))
stAng=parseInt(stAng,10);
if(!isNaN(parseInt(swAng,10)))
swAng=parseInt(swAng,10);
this.ArrPathCommandInfo.push({id: arcTo, wR: wR, hR: hR, stAng: stAng, swAng: swAng});
},
quadBezTo: function(x0, y0, x1, y1)
{
if(!isNaN(parseInt(x0,10)))
x0=parseInt(x0,10);
if(!isNaN(parseInt(y0,10)))
y0=parseInt(y0,10);
if(!isNaN(parseInt(x1,10)))
x1=parseInt(x1,10);
if(!isNaN(parseInt(y1,10)))
y1=parseInt(y1,10);
this.ArrPathCommandInfo.push({id:bezier3, X0:x0, Y0:y0, X1:x1, Y1:y1});
},
cubicBezTo: function(x0, y0, x1, y1, x2, y2)
{
if(!isNaN(parseInt(x0,10)))
x0=parseInt(x0,10);
if(!isNaN(parseInt(y0,10)))
y0=parseInt(y0,10);
if(!isNaN(parseInt(x1,10)))
x1=parseInt(x1,10);
if(!isNaN(parseInt(y1,10)))
y1=parseInt(y1,10);
if(!isNaN(parseInt(x2,10)))
x2=parseInt(x2,10);
if(!isNaN(parseInt(y2,10)))
y2=parseInt(y2,10);
this.ArrPathCommandInfo.push({id:bezier4, X0:x0, Y0:y0, X1:x1, Y1:y1, X2:x2, Y2:y2});
},
close: function()
{
this.ArrPathCommandInfo.push({id:close});
},
init: function(gdLst)
{
var multH, multW;
multH = this.pathH == undefined ? 43200/gdLst["h"] : 43200/this.pathH;
multW = this.pathW == undefined ? 43200/gdLst["w"] : 43200/this.pathW;
var APCI=this.ArrPathCommandInfo, n = APCI.length, cmd;
var x0, y0, x1, y1, x2, y2, wR, hR, stAng, swAng, lastX, lastY;
for(var i=0; i<n; i++)
{
cmd=APCI[i];
switch(cmd.id)
{
case moveTo:
case lineTo:
{
x0=parseInt(cmd.X);
if(isNaN(x0))
{
x0=gdLst[cmd.X];
}
y0=parseInt(cmd.Y);
if(isNaN(y0))
{
y0=gdLst[cmd.Y];
}
this.ArrPathCommandLocal.push({id:cmd.id, X:x0*multW, Y:y0*multH});
lastX=x0*multW;
lastY=y0*multH;
break;
}
case bezier3:
{
x0=parseInt(cmd.X0);
if(isNaN(x0))
{
x0=gdLst[cmd.X0];
}
y0=parseInt(cmd.Y0);
if(isNaN(y0))
{
y0=gdLst[cmd.Y0];
}
x1=parseInt(cmd.X1);
if(isNaN(x1))
{
x1=gdLst[cmd.X1];
}
y1=parseInt(cmd.Y1);
if(isNaN(y1))
{
y1=gdLst[cmd.Y1];
}
this.ArrPathCommandLocal.push({id:bezier3, X0:x0*multW, Y0: y0*multH, X1:x1*multW, Y1:y1*multH});
lastX=x1*multW;
lastY=y1*multH;
break;
}
case bezier4:
{
x0=parseInt(cmd.X0);
if(isNaN(x0))
{
x0=gdLst[cmd.X0];
}
y0=parseInt(cmd.Y0);
if(isNaN(y0))
{
y0=gdLst[cmd.Y0];
}
x1=parseInt(cmd.X1);
if(isNaN(x1))
{
x1=gdLst[cmd.X1];
}
y1=parseInt(cmd.Y1);
if(isNaN(y1))
{
y1=gdLst[cmd.Y1];
}
x2=parseInt(cmd.X2);
if(isNaN(x2))
{
x2=gdLst[cmd.X2];
}
y2=parseInt(cmd.Y2);
if(isNaN(y2))
{
y2=gdLst[cmd.Y2];
}
this.ArrPathCommandLocal.push({id:bezier3, X0:x0*multW, Y0: y0*multH, X1:x1*multW, Y1:y1*multH, X2:x2*multW, Y2:y2*multH});
lastX=x2*multW;
lastY=y2*multH;
break;
}
case arcTo:
{
hR=parseInt(cmd.hR);
if(isNaN(hR))
{
hR=gdLst[cmd.hR];
}
wR=parseInt(cmd.wR);
if(isNaN(wR))
{
wR=gdLst[cmd.wR];
}
stAng=parseInt(cmd.stAng);
if(isNaN(stAng))
{
stAng=gdLst[cmd.stAng];
}
swAng=parseInt(cmd.swAng);
if(isNaN(swAng))
{
swAng=gdLst[cmd.swAng];
}
this.ArrPathCommandLocal.push({id: arcTo,
stX: lastX,
stY: lastY,
wR: wR*multW,
hR: hR*multH,
stAng: stAng*cToRad,
swAng: swAng*cToRad});
var sin1 = Math.sin((stAng)*cToRad);
var cos1 = Math.cos((stAng)*cToRad);
var __x = cos1 / (wR*multW);
var __y = sin1 / (hR*multH);
var l = 1 / Math.sqrt(__x * __x + __y * __y);
var xc = lastX - l * cos1;
var yc = lastY - l * sin1;
lastX=(xc+multW*wR*Math.cos(AngToEllPrm((stAng+swAng)*cToRad, wR*multW, hR*multH)));
lastY=(yc+multH*hR*Math.sin(AngToEllPrm((stAng+swAng)*cToRad, wR*multW, hR*multH)));
break;
}
case close:
{
this.ArrPathCommandLocal.push({id: close});
break;
}
default:
{
break;
}
}
}
},
recalculate: function(gdLst)
{
var multH, multW;
multH = this.pathH == undefined ? 43200/gdLst["h"] : 43200/this.pathH;
multW = this.pathW == undefined ? 43200/gdLst["w"] : 43200/this.pathW;
var APCI=this.ArrPathCommandInfo, n = APCI.length, cmd;
var x0, y0, x1, y1, x2, y2, wR, hR, stAng, swAng, lastX, lastY;
for(var i=0; i<n; i++)
{
cmd=APCI[i];
switch(cmd.id)
{
case moveTo:
case lineTo:
{
x0=parseInt(cmd.X);
if(isNaN(x0))
{
x0=gdLst[cmd.X];
}
y0=parseInt(cmd.Y);
if(isNaN(y0))
{
y0=gdLst[cmd.Y];
}
this.ArrPathCommandLocal[i] = ({id:cmd.id, X:x0*multW, Y:y0*multH});
lastX=x0*multW;
lastY=y0*multH;
break;
}
case bezier3:
{
x0=parseInt(cmd.X0);
if(isNaN(x0))
{
x0=gdLst[cmd.X0];
}
y0=parseInt(cmd.Y0);
if(isNaN(y0))
{
y0=gdLst[cmd.Y0];
}
x1=parseInt(cmd.X1);
if(isNaN(x1))
{
x1=gdLst[cmd.X1];
}
y1=parseInt(cmd.Y1);
if(isNaN(y1))
{
y1=gdLst[cmd.Y1];
}
this.ArrPathCommandLocal[i] = ({id:bezier3, X0:x0*multW, Y0: y0*multH, X1:x1*multW, Y1:y1*multH});
lastX=x1*multW;
lastY=y1*multH;
break;
}
case bezier4:
{
x0=parseInt(cmd.X0);
if(isNaN(x0))
{
x0=gdLst[cmd.X0];
}
y0=parseInt(cmd.Y0);
if(isNaN(y0))
{
y0=gdLst[cmd.Y0];
}
x1=parseInt(cmd.X1);
if(isNaN(x1))
{
x1=gdLst[cmd.X1];
}
y1=parseInt(cmd.Y1);
if(isNaN(y1))
{
y1=gdLst[cmd.Y1];
}
x2=parseInt(cmd.X2);
if(isNaN(x2))
{
x2=gdLst[cmd.X2];
}
y2=parseInt(cmd.Y2);
if(isNaN(y2))
{
y2=gdLst[cmd.Y2];
}
this.ArrPathCommandLocal[i] = ({id:bezier3, X0:x0*multW, Y0: y0*multH, X1:x1*multW, Y1:y1*multH, X2:x2*multW, Y2:y2*multH});
lastX=x2*multW;
lastY=y2*multH;
break;
}
case arcTo:
{
hR=parseInt(cmd.hR);
if(isNaN(hR))
{
hR=gdLst[cmd.hR];
}
wR=parseInt(cmd.wR);
if(isNaN(wR))
{
wR=gdLst[cmd.wR];
}
stAng=parseInt(cmd.stAng);
if(isNaN(stAng))
{
stAng=gdLst[cmd.stAng];
}
swAng=parseInt(cmd.swAng);
if(isNaN(swAng))
{
swAng=gdLst[cmd.swAng];
}
this.ArrPathCommandLocal[i] = ({id: arcTo,
stX: lastX,
stY: lastY,
wR: wR*multW,
hR: hR*multH,
stAng: stAng*cToRad,
swAng: swAng*cToRad});
var sin1 = Math.sin((stAng)*cToRad);
var cos1 = Math.cos((stAng)*cToRad);
var __x = cos1 / (wR*multW);
var __y = sin1 / (hR*multH);
var l = 1 / Math.sqrt(__x * __x + __y * __y);
var xc = lastX - l * cos1;
var yc = lastY - l * sin1;
lastX=(xc+multW*wR*Math.cos(AngToEllPrm((stAng+swAng)*cToRad, wR*multW, hR*multH)));
lastY=(yc+multH*hR*Math.sin(AngToEllPrm((stAng+swAng)*cToRad, wR*multW, hR*multH)));
break;
}
case close:
{
this.ArrPathCommandLocal[i] = ({id: close});
break;
}
default:
{
break;
}
}
}
},
/*
draw: function(graphics, line_color, line_width, fill_color, alpha, fillAlpha, lineAlpha)
{
var path=this.ArrPathCommand;
graphics._s();
graphics.p_width(line_width*100);
for(var j=0, l=path.length; j<l; ++j)
{
var cmd=path[j];
switch(cmd.id)
{
case moveTo:
{
graphics._m(cmd.X, cmd.Y);
break;
}
case lineTo:
{
graphics._l(cmd.X, cmd.Y);
break;
}
case bezier3:
{
graphics._c2(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1);
break;
}
case bezier4:
{
graphics._c(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1, cmd.X2, cmd.Y2);
break;
}
case arcTo:
{
Arc(graphics, cmd.stX, cmd.stY, cmd.wR, cmd.hR, cmd.stAng, cmd.swAng);
break;
}
case close:
{
graphics._z();
if(this.fill != 'none' && fill_color != null)
{
var finalFillColor;
switch (this.fill)
{
case "norm":
{
finalFillColor = fill_color;
break;
}
case "darken":
{
finalFillColor = fill_color.darken();
break;
}
case "darkenLess":
{
finalFillColor = fill_color.darkenLess();
break;
}
case "lighten":
{
finalFillColor = fill_color.lighten();
break;
}
case "lightenLess":
{
finalFillColor = fill_color.lightenLess();
break;
}
}
graphics.b_color1(finalFillColor. r, finalFillColor.g, finalFillColor.b, fill_color.a);
graphics.df();
}
if(this.stroke && line_color != null)
{
var tmpColor = line_color.norm(lineAlpha);
graphics.p_color(line_color.r, line_color.g, line_color.b, fill_color.a);
graphics.ds();
}
if(j<l-1)
graphics._s();
break;
}
}
}
if(this.fill!='none' && fill_color!=null)
{
switch (this.fill)
{
case "norm":
{
finalFillColor = fill_color;
break;
}
case "darken":
{
finalFillColor = fill_color.darken();
break;
}
case "darkenLess":
{
finalFillColor = fill_color.darkenLess();
break;
}
case "lighten":
{
finalFillColor = fill_color.lighten();
break;
}
case "lightenLess":
{
finalFillColor = fill_color.lightenLess();
break;
}
}
graphics.b_color1(finalFillColor. r, finalFillColor.g, finalFillColor.b, fill_color.a);
graphics.df();
}
if(this.stroke && line_color!=null)
{
tmpColor = line_color.norm(lineAlpha);
graphics.p_color(line_color.r, line_color.g, line_color.b, fill_color.a);
graphics.ds();
}
},
*/
draw: function(shape_drawer, w, h)
{
var multH1 = this.pathH == undefined ? 43200/h : 43200*43200/(h*this.pathH);
var multW1 = this.pathW == undefined ? 43200/w : 43200*43200/(w*this.pathW);
var multH = 100/multH1;
var multW = 100/multW1;
var path=this.ArrPathCommandLocal;
shape_drawer._s();
for(var j=0, l=path.length; j<l; ++j)
{
var cmd=path[j];
switch(cmd.id)
{
case moveTo:
{
shape_drawer._m(cmd.X*multW, cmd.Y*multH);
break;
}
case lineTo:
{
shape_drawer._l(cmd.X*multW, cmd.Y*multH);
break;
}
case bezier3:
{
shape_drawer._c2(cmd.X0*multW, cmd.Y0*multH, cmd.X1*multW, cmd.Y1*multH);
break;
}
case bezier4:
{
shape_drawer._c(cmd.X0*multW, cmd.Y0*multH, cmd.X1*multW, cmd.Y1*multH, cmd.X2*multW, cmd.Y2*multH);
break;
}
case arcTo:
{
Arc3(shape_drawer, cmd.stX*multW, cmd.stY*multH, cmd.wR*multW, cmd.hR*multH, cmd.stAng, cmd.swAng);
break;
}
case close:
{
shape_drawer._z();
shape_drawer.df(this.fill);
if (this.stroke && !shape_drawer.bIsNoStrokeAttack)
{
shape_drawer.ds();
}
if (j < (l-1))
shape_drawer._s();
break;
}
}
}
shape_drawer.df(this.fill);
if (this.stroke && !shape_drawer.bIsNoStrokeAttack)
{
shape_drawer.ds();
}
},
check_bounds: function(checker)
{
var path=this.ArrPathCommand;
for(var j=0, l=path.length; j<l; ++j)
{
var cmd=path[j];
switch(cmd.id)
{
case moveTo:
{
checker._m(cmd.X, cmd.Y);
break;
}
case lineTo:
{
checker._l(cmd.X, cmd.Y);
break;
}
case bezier3:
{
checker._c2(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1);
break;
}
case bezier4:
{
checker._c(cmd.X0, cmd.Y0, cmd.X1, cmd.Y1, cmd.X2, cmd.Y2);
break;
}
case arcTo:
{
Arc(checker, cmd.stX, cmd.stY, cmd.wR, cmd.hR, cmd.stAng, cmd.swAng);
break;
}
case close:
{
checker._z();
break;
}
}
}
}
};
This source diff could not be displayed because it is too large. You can view the blob instead.
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