Commit 523f6840 authored by Ilya Kirillov's avatar Ilya Kirillov Committed by Alexander.Trofimov

В билдере сделана работа с нумерацией параграфа.

parent aeb7a743
......@@ -1111,6 +1111,7 @@ var historyitem_HdrFtr_BoundY2 = 1; // Изменяем отступ колон
// Типы изменений в классе CAbstractNum
var historyitem_AbstractNum_LvlChange = 1; // Изменили заданный уровень
var historyitem_AbstractNum_TextPrChange = 2; // Изменили текстовую настройку у заданного уровня
var historyitem_AbstractNum_ParaPrChange = 3; // Изменили настройку параграфа у заданного уровня
// Типы изменений в классе CTableId
var historyitem_TableId_Add = 1; // Добавили новую ссылку в глобальную таблицу
......
......@@ -258,7 +258,7 @@ CAbstractNum.prototype =
{
Set_Id : function(newId)
{
AscCommon.g_oTableId.Reset_Id( this, newId, this.Id );
AscCommon.g_oTableId.Reset_Id(this, newId, this.Id);
this.Id = newId;
},
......@@ -274,11 +274,11 @@ CAbstractNum.prototype =
this.StyleLink = AbstractNum.StyleLink;
this.NumStyleLink = AbstractNum.NumStyleLink;
for ( var Index = 0; Index < 9; Index++ )
for (var Index = 0; Index < 9; Index++)
{
var Lvl_new = this.Internal_CopyLvl( AbstractNum.Lvl[Index] );
var Lvl_new = this.Internal_CopyLvl(AbstractNum.Lvl[Index]);
var Lvl_old = this.Lvl[Index];
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new});
this.Lvl[Index] = Lvl_new;
}
......@@ -288,35 +288,35 @@ CAbstractNum.prototype =
Change_LeftInd : function(NewLeft)
{
var OldLeft = this.Lvl[0].ParaPr.Ind.Left;
for ( var Index = 0; Index < 9; Index++ )
for (var Index = 0; Index < 9; Index++)
{
var Lvl_new = this.Internal_CopyLvl( this.Lvl[Index] );
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
var Lvl_new = this.Internal_CopyLvl(this.Lvl[Index]);
var Lvl_old = this.Internal_CopyLvl(this.Lvl[Index]);
Lvl_new.ParaPr.Ind.Left = Lvl_old.ParaPr.Ind.Left - OldLeft + NewLeft;
this.Internal_SetLvl( Index, Lvl_new );
this.Internal_SetLvl(Index, Lvl_new);
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new});
}
var LogicDocument = editor.WordControl.m_oLogicDocument;
var AllParagraphs = LogicDocument.Get_AllParagraphsByNumbering( { NumId : this.Id, Lvl : undefined } );
var AllParagraphs = LogicDocument.Get_AllParagraphsByNumbering({NumId : this.Id, Lvl : undefined});
var Count = AllParagraphs.length;
for ( var Index = 0; Index < Count; Index++ )
for (var Index = 0; Index < Count; Index++)
{
var Para = AllParagraphs[Index];
var Para = AllParagraphs[Index];
Para.CompiledPr.NeedRecalc = true;
}
},
Get_LvlByStyle : function(StyleId)
{
for ( var Index = 0; Index < 9; Index++ )
for (var Index = 0; Index < 9; Index++)
{
var Lvl = this.Lvl[Index];
if ( StyleId === Lvl.PStyle )
if (StyleId === Lvl.PStyle)
return Index;
}
......@@ -325,45 +325,45 @@ CAbstractNum.prototype =
Get_Lvl : function(Lvl)
{
if ( undefined === this.Lvl[Lvl] )
if (undefined === this.Lvl[Lvl])
return this.Lvl[0];
return this.Lvl[Lvl];
},
Set_Lvl : function(iLvl, Lvl_new)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl_old = this.Lvl[iLvl];
var Lvl_old = this.Lvl[iLvl];
this.Lvl[iLvl] = Lvl_new;
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new});
},
// Определяем многоуровненый список по умолчанию
Create_Default_Numbered : function()
{
for ( var Index = 0; Index < 9; Index++ )
for (var Index = 0; Index < 9; Index++)
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
var Lvl_old = this.Internal_CopyLvl(this.Lvl[Index]);
this.Lvl[Index] = {};
var Lvl = 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 Left = 36 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
if ( 0 == Index % 3 )
if (0 == Index % 3)
{
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Decimal;
}
else if ( 1 == Index % 3 )
else if (1 == Index % 3)
{
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_LowerLetter;
......@@ -376,43 +376,43 @@ CAbstractNum.prototype =
}
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( Index ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.LvlText.push(new CLvlText_Num(Index));
Lvl.LvlText.push(new CLvlText_Text("."));
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
var Lvl_new = this.Internal_CopyLvl(Lvl);
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new});
}
},
Create_Default_Multilevel_1 : function()
{
for ( var Index = 0; Index < 9; Index++ )
for (var Index = 0; Index < 9; Index++)
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
var Lvl_old = this.Internal_CopyLvl(this.Lvl[Index]);
this.Lvl[Index] = {};
var Lvl = 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 Left = 18 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
Lvl.Jc = align_Left;
Lvl.Jc = align_Left;
if ( 0 == Index % 3 )
if (0 == Index % 3)
{
Lvl.Format = numbering_numfmt_Decimal;
}
else if ( 1 == Index % 3 )
else if (1 == Index % 3)
{
Lvl.Format = numbering_numfmt_LowerLetter;
}
......@@ -422,74 +422,74 @@ CAbstractNum.prototype =
}
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( Index ) );
Lvl.LvlText.push( new CLvlText_Text( ")" ) );
Lvl.LvlText.push(new CLvlText_Num(Index));
Lvl.LvlText.push(new CLvlText_Text(")"));
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
var Lvl_new = this.Internal_CopyLvl(Lvl);
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new});
}
},
Create_Default_Multilevel_2 : function()
{
for ( var Index = 0; Index < 9; Index++ )
for (var Index = 0; Index < 9; Index++)
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
var Lvl_old = this.Internal_CopyLvl(this.Lvl[Index]);
this.Lvl[Index] = {};
var Lvl = 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;
var Left = 0;
var FirstLine = 0;
switch ( Index )
switch (Index)
{
case 0 :
Left = 18 * g_dKoef_pt_to_mm;
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;
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;
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;
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;
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;
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;
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;
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;
Left = 216 * g_dKoef_pt_to_mm;
FirstLine = -72 * g_dKoef_pt_to_mm;
break;
}
......@@ -497,105 +497,105 @@ CAbstractNum.prototype =
Lvl.Format = numbering_numfmt_Decimal;
Lvl.LvlText = [];
for ( var Index2 = 0; Index2 <= Index; Index2++ )
for (var Index2 = 0; Index2 <= Index; Index2++)
{
Lvl.LvlText.push( new CLvlText_Num( Index2 ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.LvlText.push(new CLvlText_Num(Index2));
Lvl.LvlText.push(new CLvlText_Text("."));
}
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
var Lvl_new = this.Internal_CopyLvl(Lvl);
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new});
}
},
Create_Default_Multilevel_3 : function()
{
for ( var Index = 0; Index < 9; Index++ )
for (var Index = 0; Index < 9; Index++)
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
var Lvl_old = this.Internal_CopyLvl(this.Lvl[Index]);
this.Lvl[Index] = {};
var Lvl = 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 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;
Lvl.Format = numbering_numfmt_Bullet;
Lvl.Jc = align_Left;
Lvl.LvlText = [];
switch( Index )
switch (Index)
{
case 0:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x0076 ) ) );
Lvl.LvlText.push(new CLvlText_Text(String.fromCharCode(0x0076)));
break;
case 1:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00D8 ) ) );
Lvl.LvlText.push(new CLvlText_Text(String.fromCharCode(0x00D8)));
break;
case 2:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A7 ) ) );
Lvl.LvlText.push(new CLvlText_Text(String.fromCharCode(0x00A7)));
break;
case 3:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00B7 ) ) );
Lvl.LvlText.push(new CLvlText_Text(String.fromCharCode(0x00B7)));
break;
case 4:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A8 ) ) );
Lvl.LvlText.push(new CLvlText_Text(String.fromCharCode(0x00A8)));
break;
case 5:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00D8 ) ) );
Lvl.LvlText.push(new CLvlText_Text(String.fromCharCode(0x00D8)));
break;
case 6:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A7 ) ) );
Lvl.LvlText.push(new CLvlText_Text(String.fromCharCode(0x00A7)));
break;
case 7:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00B7 ) ) );
Lvl.LvlText.push(new CLvlText_Text(String.fromCharCode(0x00B7)));
break;
case 8:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A8 ) ) );
Lvl.LvlText.push(new CLvlText_Text(String.fromCharCode(0x00A8)));
break;
}
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
if ( 3 === Index || 4 === Index || 7 === Index || 8 === Index )
TextPr.RFonts.Set_All( "Symbol", -1 );
if (3 === Index || 4 === Index || 7 === Index || 8 === Index)
TextPr.RFonts.Set_All("Symbol", -1);
else
TextPr.RFonts.Set_All( "Wingdings", -1 );
TextPr.RFonts.Set_All("Wingdings", -1);
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
var Lvl_new = this.Internal_CopyLvl(Lvl);
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new});
}
},
Create_Default_Bullet : function()
{
for ( var Index = 0; Index < 9; Index++ )
for (var Index = 0; Index < 9; Index++)
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
var Lvl_old = this.Internal_CopyLvl(this.Lvl[Index]);
this.Lvl[Index] = {};
var Lvl = 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 Left = 36 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
Lvl.Jc = align_Left;
......@@ -603,239 +603,330 @@ CAbstractNum.prototype =
Lvl.LvlText = [];
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
if ( 0 == Index % 3 )
if (0 == Index % 3)
{
TextPr.RFonts.Set_All( "Symbol", -1 );
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00B7 ) ) );
TextPr.RFonts.Set_All("Symbol", -1);
Lvl.LvlText.push(new CLvlText_Text(String.fromCharCode(0x00B7)));
}
else if ( 1 == Index % 3 )
else if (1 == Index % 3)
{
TextPr.RFonts.Set_All( "Courier New", -1 );
Lvl.LvlText.push( new CLvlText_Text( "o" ) );
TextPr.RFonts.Set_All("Courier New", -1);
Lvl.LvlText.push(new CLvlText_Text("o"));
}
else
{
TextPr.RFonts.Set_All( "Wingdings", -1 );
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A7 ) ) );
TextPr.RFonts.Set_All("Wingdings", -1);
Lvl.LvlText.push(new CLvlText_Text(String.fromCharCode(0x00A7)));
}
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
var Lvl_new = this.Internal_CopyLvl(Lvl);
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new});
}
},
Set_Lvl_None : function(iLvl)
{
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_None;
Lvl.LvlText = [];
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl(Lvl);
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new});
},
Set_Lvl_Bullet : function(iLvl, LvlText, TextPr)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Format = numbering_numfmt_Bullet;
Lvl.Format = numbering_numfmt_Bullet;
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Text( 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 } );
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 )
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_Decimal;
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.LvlText.push(new CLvlText_Num(iLvl));
Lvl.LvlText.push(new CLvlText_Text(")"));
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
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 )
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_Decimal;
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.LvlText.push(new CLvlText_Num(iLvl));
Lvl.LvlText.push(new CLvlText_Text("."));
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
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 )
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Decimal;
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.LvlText.push(new CLvlText_Num(iLvl));
Lvl.LvlText.push(new CLvlText_Text("."));
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
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 )
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Decimal;
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.LvlText.push(new CLvlText_Num(iLvl));
Lvl.LvlText.push(new CLvlText_Text(")"));
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
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 )
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_UpperRoman;
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.LvlText.push(new CLvlText_Num(iLvl));
Lvl.LvlText.push(new CLvlText_Text("."));
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
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 )
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_UpperLetter;
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.LvlText.push(new CLvlText_Num(iLvl));
Lvl.LvlText.push(new CLvlText_Text("."));
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
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 )
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_LowerLetter;
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.LvlText.push(new CLvlText_Num(iLvl));
Lvl.LvlText.push(new CLvlText_Text(")"));
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
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 )
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_LowerLetter;
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.LvlText.push(new CLvlText_Num(iLvl));
Lvl.LvlText.push(new CLvlText_Text("."));
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
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 )
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_LowerRoman;
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.LvlText.push(new CLvlText_Num(iLvl));
Lvl.LvlText.push(new CLvlText_Text("."));
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
var Lvl_new = this.Internal_CopyLvl(Lvl);
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new});
},
Set_Lvl_ByFormat : function(iLvl, nType, sFormatText, nAlign)
{
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Jc = nAlign;
Lvl.Format = nType;
Lvl.LvlText = [];
var nLastPos = 0;
var nPos = 0;
while (-1 !== (nPos = sFormatText.indexOf("%", nPos)) && nPos < sFormatText.length)
{
if (nPos < sFormatText.length - 1 && sFormatText.charCodeAt(nPos + 1) >= 48 && sFormatText.charCodeAt(nPos + 1) <= 48 + iLvl)
{
if (nPos > nLastPos)
Lvl.LvlText.push(new CLvlText_Text(sFormatText.substring(nLastPos, nPos)));
Lvl.LvlText.push(new CLvlText_Num(sFormatText.charCodeAt(nPos + 1) - 48));
nPos += 2;
nLastPos = nPos;
}
else
{
nPos++;
}
}
nPos = sFormatText.length;
if (nPos > nLastPos)
Lvl.LvlText.push(new CLvlText_Text(sFormatText.substring(nLastPos, nPos)));
Lvl.TextPr = new CTextPr();
var Lvl_new = this.Internal_CopyLvl(Lvl);
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new});
},
Set_Lvl_Restart : function(iLvl, isRestart)
{
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Restart = (isRestart ? -1 : 0);
var Lvl_new = this.Internal_CopyLvl(Lvl);
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new});
},
Set_Lvl_Start : function(iLvl, nStart)
{
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Start = nStart;
var Lvl_new = this.Internal_CopyLvl(Lvl);
History.Add(this, {Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new});
},
Set_Lvl_Suff : function(iLvl, nSuff)
{
if ("number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9)
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl(Lvl);
Lvl.Suff = nSuff;
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 - параметры для рисование
......@@ -1374,6 +1465,17 @@ CAbstractNum.prototype =
History.Add( this, { Type : historyitem_AbstractNum_TextPrChange, Index : Lvl, Old : TextPr_old, New : TextPr_new } );
},
Set_TextPr : function(Lvl, TextPr)
{
History.Add(this, {Type : historyitem_AbstractNum_TextPrChange, Index : Lvl, Old : this.Lvl[Lvl].TextPr, New : TextPr});
this.Lvl[Lvl].TextPr = TextPr;
},
Set_ParaPr : function(Lvl, ParaPr)
{
History.Add(this, {Type : historyitem_AbstractNum_ParaPrChange, Index : Lvl, Old : this.Lvl[Lvl].ParaPr, New : ParaPr});
this.Lvl[Lvl].ParaPr = ParaPr;
},
//-----------------------------------------------------------------------------------
// Undo/Redo функции
//-----------------------------------------------------------------------------------
......@@ -1495,6 +1597,16 @@ CAbstractNum.prototype =
this.Recalc_CompiledPr(Data.Index);
break;
}
case historyitem_AbstractNum_ParaPrChange:
{
this.Lvl[Data.Index].ParaPr = Data.Old;
// Пересчитываем стили у все параграфов с данной нумерацией
this.Recalc_CompiledPr(Data.Index);
break;
}
}
},
......@@ -1521,6 +1633,15 @@ CAbstractNum.prototype =
this.Recalc_CompiledPr(Data.Index);
break;
}
case historyitem_AbstractNum_ParaPrChange:
{
this.Lvl[Data.Index].ParaPr = Data.New;
// Пересчитываем стили у все параграфов с данной нумерацией
this.Recalc_CompiledPr(Data.Index);
break;
}
}
},
......@@ -1579,6 +1700,17 @@ CAbstractNum.prototype =
break;
}
case historyitem_AbstractNum_ParaPrChange:
{
// Long : iLvl
// Vairable : ParaPr
Writer.WriteLong(Data.Index);
Data.New.Write_ToBinary(Writer);
break;
}
}
......@@ -1628,6 +1760,18 @@ CAbstractNum.prototype =
break;
}
case historyitem_AbstractNum_ParaPrChange:
{
// Long : iLvl
// Vairable : ParaPr
iLvl = Reader.GetLong();
this.Lvl[iLvl].ParaPr = new CParaPr();
this.Lvl[iLvl].ParaPr.Read_FromBinary(Reader);
break;
}
}
// Сразу нельзя запускать пересчет, т.к. возможно еще не все ссылки проставлены
......
......@@ -110,7 +110,7 @@
* Class representing a numbering properties.
* @constructor
*/
function ApiNumPr(Num)
function ApiNumbering(Num)
{
this.Num = Num;
}
......@@ -119,10 +119,11 @@
* Class representing a reference to a specified level of the numbering.
* @constructor
*/
function ApiNumPrLvl(NumPr, Lvl)
function ApiNumberingLevel(Num, Lvl)
{
this.Num = NumPr;
this.Lvl = Math.max(0, Math.min(8, Lvl));
this.Num = Num;
this.Lvl = Math.max(0, Math.min(8, Lvl));
this.NumLvl = this.Num.Lvl[this.Lvl];
}
/**
......@@ -413,6 +414,24 @@
{
this.Document.Set_DocumentEvenAndOddHeaders(isEvenAndOdd);
};
/**
* Creating an abstract multilevel numbering with specified type.
* @param {("bullet" | "numbered")} [sType="bullet"]
* @returns {ApiNumbering}
*/
ApiDocument.prototype.CreateNumbering = function(sType)
{
var oGlobalNumbering = this.Document.Get_Numbering();
var oNumberingId = oGlobalNumbering.Create_AbstractNum();
var oNumbering = oGlobalNumbering.Get_AbstractNum(oNumberingId);
if ("numbered" === sType)
oNumbering.Create_Default_Numbered();
else
oNumbering.Create_Default_Bullet();
return new ApiNumbering(oNumbering);
};
//------------------------------------------------------------------------------------------------------------------
//
......@@ -730,7 +749,7 @@
/**
* Specifies that the current paragraph references a numbering definition instance in the current document.
* @see {@link ApiParagraph#GetParaPr} and {@link SetNumPr#SetTabs}
* @param {ApiNumPr} oNumPr - Specifies a numbering definition.
* @param {ApiNumbering} oNumPr - Specifies a numbering definition.
* @param {number} nLvl - Specifies a numbering level reference.
*/
ApiParagraph.prototype.SetNumPr = function(oNumPr, nLvl)
......@@ -739,7 +758,7 @@
};
/**
* Get a numbering defenition and numbering level.
* @returns {?ApiNumPrLvl}
* @returns {?ApiNumberingLevel}
*/
ApiParagraph.prototype.GetNumPr = function()
{
......@@ -753,7 +772,19 @@
if (!oNumbering)
return null;
return new ApiNumPrLvl(oNumbering, oNumPr.Lvl);
return new ApiNumberingLevel(oNumbering, oNumPr.Lvl);
};
/**
* Specifies that the current paragraph references a numbering definition instance in the current document.
* @see Same as {@link ApiParagraph#SetNumPr}
* @param oNumberingLevel
*/
ApiParagraph.prototype.SetNumbering = function(oNumberingLevel)
{
if (!(oNumberingLevel instanceof ApiNumberingLevel))
return;
this.SetNumPr(oNumberingLevel.GetNumbering(), oNumberingLevel.GetLevelIndex());
};
//------------------------------------------------------------------------------------------------------------------
......@@ -1990,14 +2021,14 @@
};
/**
* Specifies that the current paragraph references a numbering definition instance in the current document.
* @param {ApiNumPr} oNumPr - Specifies a numbering definition.
* @param {ApiNumbering} oNumPr - Specifies a numbering definition.
* @param {number} [nLvl=0] - Specifies a numbering level reference. If the current instance of the class ApiParaPr is
* direct formatting of a paragraph, then this parameter <b>MUST BE</b> specified. Otherwise if the current instance
* of the class ApiParaPr is the part of ApiStyle properties, then this parameter will be ignored.
*/
ApiParaPr.prototype.SetNumPr = function(oNumPr, nLvl)
{
if (!(oNumPr instanceof ApiNumPr))
if (!(oNumPr instanceof ApiNumbering))
return;
this.ParaPr.NumPr = new CNumPr();
......@@ -2013,41 +2044,151 @@
//------------------------------------------------------------------------------------------------------------------
//
// ApiNumPr
// ApiNumbering
//
//------------------------------------------------------------------------------------------------------------------
/**
* Get the specified level of the current numbering.
* @param {number} nLevel - Index of the numbering level. This value MUST BE from 0 to 8.
* @returns {ApiNumberingLevel}
*/
ApiNumbering.prototype.GetLevel = function(nLevel)
{
return new ApiNumberingLevel(this.Num, nLevel);
};
//------------------------------------------------------------------------------------------------------------------
//
// ApiNumPr
// ApiNumberingLevel
//
//------------------------------------------------------------------------------------------------------------------
/**
* Get a numbering defenition.
* @returns {ApiNumPr}
* @returns {ApiNumbering}
*/
ApiNumPrLvl.prototype.GetNumbering = function()
ApiNumberingLevel.prototype.GetNumbering = function()
{
return new ApiNumPr(this.Num);
return new ApiNumbering(this.Num);
};
/**
* Get level index.
* @returns {number}
*/
ApiNumPrLvl.prototype.GetLevel = function()
ApiNumberingLevel.prototype.GetLevelIndex = function()
{
return this.Lvl;
};
/**
* Set level index.
* @param {number} nLevel - Index of the level in the current numbering. This value MUST BE from 0 to 8.
* Specifies the run properties which shall be applied to the numbering level's text.
* @returns {ApiTextPr}
*/
ApiNumberingLevel.prototype.GetTextPr = function()
{
return new ApiTextPr(this.NumLvl.TextPr.Copy());
};
/**
* This paragraph properties are applied to any numbered paragraph that references the given numbering definition
* and numbering level.
* @returns {ApiParaPr}
*/
ApiNumPrLvl.prototype.SetLevel = function(nLevel)
ApiNumberingLevel.prototype.GetParaPr = function()
{
this.Lvl = Math.max(0, Math.min(8, nLevel));
return new ApiParaPr(this.NumPr.ParaPr.Copy());
};
/**
* Set one of the predefined numbering templates.
* @param {("none" | "bullet" | "1)" | "1." | "I." | "A." | "a)" | "a." | "i." )} sType - Type of the numbering
* @param {string} [sSymbol=""] - This parameter have a meaning only if <code>sType="bullet"</code>
*/
ApiNumberingLevel.prototype.SetTemplateType = function(sType, sSymbol)
{
switch (sType)
{
case "none" : this.Num.Set_Lvl_None(this.Lvl); break;
case "bullet": this.Num.Set_Lvl_Bullet(this.Lvl, sSymbol, new CTextPr()); break;
case "1)" : this.Num.Set_Lvl_Numbered_1(this.Lvl); break;
case "1." : this.Num.Set_Lvl_Numbered_2(this.Lvl); break;
case "I." : this.Num.Set_Lvl_Numbered_5(this.Lvl); break;
case "A." : this.Num.Set_Lvl_Numbered_6(this.Lvl); break;
case "a)" : this.Num.Set_Lvl_Numbered_7(this.Lvl); break;
case "a." : this.Num.Set_Lvl_Numbered_8(this.Lvl); break;
case "i." : this.Num.Set_Lvl_Numbered_9(this.Lvl); break;
}
};
/**
* Set the custom type of the numbering.
* @param {("none" | "bullet" | "decimal" | "lowerRoman" | "upperRoman" | "lowerLetter" | "upperLetter" | "decimalZero")} sType
* @param {string} sTextFormatString - All text in this parameter shall be taken as literal text to be repeated in
* each instance of this numbering level, except for any use of the percent symbol (%) followed by a number,
* which shall be used to indicate the one-based index of the number to be used at this level. Any number of a level
* higher than this level shall be ignored.
* @param {("left" | "right" | "center")} sAlign - Type of justification used on a numbering level's text.
*/
ApiNumberingLevel.prototype.SetCustomType = function(sType, sTextFormatString, sAlign)
{
var nType = numbering_numfmt_None;
if ("none" === sType)
nType = numbering_numfmt_None;
else if ("bullet" === sType)
nType = numbering_numfmt_Bullet;
else if ("decimal" === sType)
nType = numbering_numfmt_Decimal;
else if ("lowerRoman" === sType)
nType = numbering_numfmt_LowerRoman;
else if ("upperRoman" === sType)
nType = numbering_numfmt_UpperRoman;
else if ("lowerLetter" === sType)
nType = numbering_numfmt_LowerLetter;
else if ("upperLetter" === sType)
nType = numbering_numfmt_UpperLetter;
else if ("decimalZero" === sType)
nType = numbering_numfmt_DecimalZero;
var nAlign = AscCommon.align_Left;
if ("left" === sAlign)
nAlign = AscCommon.align_Left;
else if ("right" === sAlign)
nAlign = AscCommon.align_Right;
else if ("center" === sAlign)
nAlign = AscCommon.align_Center;
this.Num.Set_Lvl_ByFormat(this.Lvl, nType, sTextFormatString, nAlign);
};
/**
* This element specifies a one-based index which determines when a numbering level should restart to its start
* value. A numbering level restarts when an instance of the specified numbering level, which shall be
* higher (earlier than the this level) is used in the given document's contents. By default this value is true.
* @param {boolean} isRestart
*/
ApiNumberingLevel.prototype.SetRestart = function(isRestart)
{
this.Num.Set_Lvl_Restart(this.Lvl, private_GetBoolean(isRestart, true));
};
/**
* This element specifies the starting value for the numbering used by the parent numbering level within a given
* numbering level definition. By default this value is 1.
* @param {number} nStart
*/
ApiNumberingLevel.prototype.SetStart = function(nStart)
{
this.Num.Set_Lvl_Start(this.Lvl, private_GetInt(nStart));
};
/**
* Specifies the content which shall be added between a given numbering level's text and the text of every numbered
* paragraph which references that numbering level. By default this value is "tab".
* @param {("space" | "tab" | "none")} sType
*/
ApiNumberingLevel.prototype.SetSuff = function(sType)
{
if ("space" === sType)
this.Num.Set_Lvl_Suff(this.Lvl, numbering_suff_Space);
else if ("tab" === sType)
this.Num.Set_Lvl_Suff(this.Lvl, numbering_suff_Tab);
else if ("none" === sType)
this.Num.Set_Lvl_Suff(this.Lvl, numbering_suff_Nothing);
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Export
......@@ -2070,6 +2211,7 @@
ApiDocument.prototype["GetFinalSection"] = ApiDocument.prototype.GetFinalSection;
ApiDocument.prototype["CreateSection"] = ApiDocument.prototype.CreateSection;
ApiDocument.prototype["SetEvenAndOddHdrFtr"] = ApiDocument.prototype.SetEvenAndOddHdrFtr;
ApiDocument.prototype["CreateNumbering"] = ApiDocument.prototype.CreateNumbering;
ApiParagraph.prototype["AddText"] = ApiParagraph.prototype.AddText;
ApiParagraph.prototype["AddPageBreak"] = ApiParagraph.prototype.AddPageBreak;
......@@ -2201,9 +2343,18 @@
ApiParaPr.prototype["SetTabs"] = ApiParaPr.prototype.SetTabs;
ApiParaPr.prototype["SetNumPr"] = ApiParaPr.prototype.SetNumPr;
ApiNumPrLvl.prototype["GetNumbering"] = ApiNumPrLvl.prototype.GetNumbering;
ApiNumPrLvl.prototype["GetLevel"] = ApiNumPrLvl.prototype.GetLevel;
ApiNumPrLvl.prototype["SetLevel"] = ApiNumPrLvl.prototype.SetLevel;
ApiNumbering.prototype["GetLevel"] = ApiNumbering.prototype.GetLevel;
ApiNumberingLevel.prototype["GetNumbering"] = ApiNumberingLevel.prototype.GetNumbering;
ApiNumberingLevel.prototype["GetLevelIndex"] = ApiNumberingLevel.prototype.GetLevelIndex;
ApiNumberingLevel.prototype["GetTextPr"] = ApiNumberingLevel.prototype.GetTextPr;
ApiNumberingLevel.prototype["GetParaPr"] = ApiNumberingLevel.prototype.GetParaPr;
ApiNumberingLevel.prototype["SetTemplateType"] = ApiNumberingLevel.prototype.SetTemplateType;
ApiNumberingLevel.prototype["SetCustomType"] = ApiNumberingLevel.prototype.SetCustomType;
ApiNumberingLevel.prototype["SetRestart"] = ApiNumberingLevel.prototype.SetRestart;
ApiNumberingLevel.prototype["SetStart"] = ApiNumberingLevel.prototype.SetStart;
ApiNumberingLevel.prototype["SetSuff"] = ApiNumberingLevel.prototype.SetSuff;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Private area
......@@ -2272,14 +2423,23 @@
{
var oBorder = new CDocumentBorder();
if ("single" === sType)
oBorder.Value = border_Single;
else if ("none" === sType)
if ("none" === sType)
{
oBorder.Value = border_None;
oBorder.Size = 0;
oBorder.Space = 0;
oBorder.Color.Set(0, 0, 0, true);
}
else
{
if ("single" === sType)
oBorder.Value = border_Single;
oBorder.Size = private_Pt_8ToMM(nSize);
oBorder.Space = private_PtToMM(nSpace);
oBorder.Color.Set(r, g, b);
}
oBorder.Size = private_Pt_8ToMM(nSize);
oBorder.Space = private_PtToMM(nSpace);
oBorder.Color.Set(r, g, b);
return oBorder;
}
......@@ -2306,6 +2466,11 @@
return (undefined !== bDefValue ? bDefValue : false);
}
function private_GetInt(nValue)
{
return nValue | 0;
}
function private_PtToMM(pt)
{
return 25.4 / 72.0 * pt;
......@@ -2361,6 +2526,16 @@
this.Style.Set_ParaPr(oApiParaPr.ParaPr);
oApiParaPr.ParaPr = this.Style.ParaPr.Copy();
};
ApiNumberingLevel.prototype.OnChangeTextPr = function(oApiTextPr)
{
this.Num.Set_TextPr(this.Lvl, oApiTextPr.TextPr);
oApiTextPr.TextPr = this.Num.Lvl[this.Lvl].TextPr.Copy();
};
ApiNumberingLevel.prototype.OnChangeParaPr = function(oApiParaPr)
{
this.Num.Set_ParaPr(this.Lvl, oApiParaPr.ParaPr);
oApiParaPr.ParaPr = this.Num.Lvl[this.Lvl].ParaPr.Copy();
};
ApiTextPr.prototype.private_OnChange = function()
{
this.Parent.OnChangeTextPr(this);
......@@ -2791,6 +2966,14 @@ function TEST_BUILDER()
oTable.SetWidth("auto");
oTable.SetJc("right");
oTable.SetTableLook(true, true, false, false, true, false);
oTable.SetTableBorderLeft("none");
oTable.SetTableBorderRight("none");
oTable.SetTableBorderTop("none");
oTable.SetTableBorderBottom("none");
oTable.SetTableBorderInsideV("none");
oRow = oTable.GetRow(0);
if (oRow)
{
......@@ -3019,7 +3202,77 @@ function TEST_BUILDER2()
oParagraph.AddText("Custom tabs (center, left, right)");
oDocument.Push(oParagraph);
//TODO: Сделать примеры параграфов с нумерацей
var oNumbering = oDocument.CreateNumbering("bullet");
var oNumLvl;
for (var nLvl = 0; nLvl < 8; ++nLvl)
{
oNumLvl = oNumbering.GetLevel(nLvl);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Default bullet lvl " + (nLvl + 1));
oParagraph.SetNumbering(oNumLvl);
oParagraph.SetContextualSpacing(true);
oDocument.Push(oParagraph);
}
oNumbering = oDocument.CreateNumbering("numbered");
for (var nLvl = 0; nLvl < 8; ++nLvl)
{
oNumLvl = oNumbering.GetLevel(nLvl);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Default numbered lvl " + (nLvl + 1));
oParagraph.SetNumbering(oNumLvl);
oParagraph.SetContextualSpacing(true);
oDocument.Push(oParagraph);
}
oNumbering = oDocument.CreateNumbering("numbered");
for (var nLvl = 0; nLvl < 8; ++nLvl)
{
oNumLvl = oNumbering.GetLevel(nLvl);
var sFormatString = "";
for (var nTempLvl = 0; nTempLvl <= nLvl; ++nTempLvl)
sFormatString += "%" + nTempLvl + ".";
oNumLvl.SetCustomType("lowerRoman", sFormatString, "left");
oNumLvl.SetStart(nLvl + 1);
oNumLvl.SetSuff("space");
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Custom numbered lvl " + (nLvl + 1));
oParagraph.SetNumbering(oNumLvl);
oParagraph.SetContextualSpacing(true);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Custom numbered lvl " + (nLvl + 1));
oParagraph.SetNumbering(oNumLvl);
oParagraph.SetContextualSpacing(true);
oDocument.Push(oParagraph);
}
oNumbering = oDocument.CreateNumbering("bullet");
for (var nLvl = 0; nLvl < 8; ++nLvl)
{
oNumLvl = oNumbering.GetLevel(nLvl);
var sSymbolCharCode = 'a'.charCodeAt(0) + nLvl;
oNumLvl.SetTemplateType("bullet", String.fromCharCode(sSymbolCharCode));
oNumLvl.SetSuff("none");
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Template bullet lvl " + (nLvl + 1));
oParagraph.SetNumbering(oNumLvl);
oParagraph.SetContextualSpacing(true);
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Template bullet lvl " + (nLvl + 1));
oParagraph.SetNumbering(oNumLvl);
oParagraph.SetContextualSpacing(true);
oDocument.Push(oParagraph);
}
var oSection = oDocument.GetFinalSection();
var oHeader = oSection.GetHeader("default", true);
......
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