"use strict"; /** * User: Ilja.Kirillov * Date: 11.11.11 * Time: 14:46 */ var EvenAndOddHeaders = false; var Default_Tab_Stop = 12.5; var Default_Heading_Font = "Arial"; var Default_Font = "Arial"; var align_Right = 0; var align_Left = 1; var align_Center = 2; var align_Justify = 3; var vertalign_Baseline = 0; var vertalign_SuperScript = 1; var vertalign_SubScript = 2; var highlight_None = -1; var shd_Clear = 0; var shd_Nil = 1; var vertalign_Koef_Size = 0.65; // Коэффициент изменения размера текста для верхнего и нижнего индексов var vertalign_Koef_Super = 0.35; // Позиция верхнего индекса (относительно размера текста) var vertalign_Koef_Sub = -0.141; // Позиция нижнего индекса (относительно размера текста) var smallcaps_Koef = 0.8; // Коэффициент изменения размера шрифта для малых прописных букв var smallcaps_and_script_koef = vertalign_Koef_Size * smallcaps_Koef; // суммарный коэффициент, когда текст одновременно и в индексе, и написан малыми прописными var g_dKoef_pt_to_mm = 25.4 / 72; var g_dKoef_pc_to_mm = g_dKoef_pt_to_mm / 12; var g_dKoef_in_to_mm = 25.4; var g_dKoef_twips_to_mm = g_dKoef_pt_to_mm / 20; var g_dKoef_mm_to_pt = 1 / g_dKoef_pt_to_mm; var g_dKoef_mm_to_twips = 1 / g_dKoef_twips_to_mm; var tblwidth_Auto = 0x00; var tblwidth_Mm = 0x01; var tblwidth_Nil = 0x02; var tblwidth_Pct = 0x03; var tbllayout_Fixed = 0x00; var tbllayout_AutoFit = 0x01; var border_None = 0x0000; var border_Single = 0x0001; var heightrule_AtLeast = 0x00; var heightrule_Auto = 0x01; var heightrule_Exact = 0x02; var vertalignjc_Top = 0x00; var vertalignjc_Center = 0x01; var vertalignjc_Bottom = 0x02; var vmerge_Restart = 0x01; var vmerge_Continue = 0x02; var spacing_Auto = -1; var styletype_Paragraph = 0x01; var styletype_Numbering = 0x02; var styletype_Table = 0x03; var styletype_Character = 0x04; function CTableStylePr() { this.TextPr = new CTextPr(); this.ParaPr = new CParaPr(); this.TablePr = new CTablePr(); this.TableRowPr = new CTableRowPr(); this.TableCellPr = new CTableCellPr(); } CTableStylePr.prototype = { Merge : function(TableStylePr) { this.TextPr.Merge( TableStylePr.TextPr ); this.ParaPr.Merge( TableStylePr.ParaPr ); this.TablePr.Merge( TableStylePr.TablePr ); this.TableRowPr.Merge( TableStylePr.TableRowPr ); this.TableCellPr.Merge( TableStylePr.TableCellPr ); }, Copy : function() { var TableStylePr = new CTableStylePr(); TableStylePr.TextPr = this.TextPr.Copy(); TableStylePr.ParaPr = this.ParaPr.Copy(); TableStylePr.TablePr = this.TablePr.Copy(); TableStylePr.TableRowPr = this.TableRowPr.Copy(); TableStylePr.TableCellPr = this.TableCellPr.Copy(); return TableStylePr; }, Check_PresentationPr : function(Theme) { this.TextPr.Check_PresentationPr(); this.TableCellPr.Check_PresentationPr(Theme); }, Set_FromObject : function(Obj) { if ( undefined != Obj.TextPr ) this.TextPr.Set_FromObject( Obj.TextPr ); if ( undefined != Obj.ParaPr ) this.ParaPr.Set_FromObject( Obj.ParaPr ); if ( undefined != Obj.TablePr ) this.TablePr.Set_FromObject( Obj.TablePr ); if ( undefined != Obj.TableRowPr ) this.TableRowPr.Set_FromObject( Obj.TableRowPr ); if ( undefined != Obj.TableCellPr ) this.TableCellPr.Set_FromObject( Obj.TableCellPr ); }, Write_ToBinary : function(Writer) { this.TextPr.Write_ToBinary( Writer ); this.ParaPr.Write_ToBinary( Writer ); this.TablePr.Write_ToBinary( Writer ); this.TableRowPr.Write_ToBinary( Writer ); this.TableCellPr.Write_ToBinary( Writer ); }, Read_FromBinary : function(Reader) { this.TextPr.Read_FromBinary( Reader ); this.ParaPr.Read_FromBinary( Reader ); this.TablePr.Read_FromBinary( Reader ); this.TableRowPr.Read_FromBinary( Reader ); this.TableCellPr.Read_FromBinary( Reader ); } } function CStyle(Name, BasedOnId, NextId, type) { this.Id = g_oIdCounter.Get_NewId(); this.Name = Name; this.BasedOn = BasedOnId; this.Next = NextId; if(null != type) this.Type = type; else this.Type = styletype_Paragraph; this.qFormat = null;// false this.uiPriority = null;// -1 this.hidden = null;// false this.semiHidden = null;// false this.unhideWhenUsed = null;// false this.TextPr = new CTextPr(); this.ParaPr = new CParaPr(); this.TablePr = new CTablePr(); this.TableRowPr = new CTableRowPr(); this.TableCellPr = new CTableCellPr(); // Условные типы форматирования стилей таблицы this.TableBand1Horz = new CTableStylePr(); this.TableBand1Vert = new CTableStylePr(); this.TableBand2Horz = new CTableStylePr(); this.TableBand2Vert = new CTableStylePr(); this.TableFirstCol = new CTableStylePr(); this.TableFirstRow = new CTableStylePr(); this.TableLastCol = new CTableStylePr(); this.TableLastRow = new CTableStylePr(); this.TableTLCell = new CTableStylePr(); this.TableTRCell = new CTableStylePr(); this.TableBLCell = new CTableStylePr(); this.TableBRCell = new CTableStylePr(); this.TableWholeTable = new CTableStylePr(); // Добавляем данный класс в таблицу Id (обязательно в конце конструктора) g_oTableId.Add( this, this.Id ); } CStyle.prototype = { //----------------------------------------------------------------------------------- // Работаем с Id данного объекта //----------------------------------------------------------------------------------- GetId : function() { return this.Id; }, SetId : function(newId) { g_oTableId.Reset_Id( this, newId, this.Id ); this.Id = newId; }, Get_Id : function() { return this.GetId(); }, Set_Id : function(newId) { return this.SetId( newId ); }, //----------------------------------------------------------------------------------- // Базовые функции для работы со стилем //----------------------------------------------------------------------------------- Set_TextPr : function(Value) { var Old = this.TextPr; var New = new CTextPr(); New.Set_FromObject(Value); this.TextPr = New; History.Add( this, { Type : historyitem_Style_TextPr, Old : Old, New : New } ); }, Set_ParaPr : function(Value) { var Old = this.ParaPr; var New = new CParaPr(); New.Set_FromObject(Value); this.ParaPr = New; History.Add( this, { Type : historyitem_Style_ParaPr, Old : Old, New : New } ); }, Set_TablePr : function(Value) { var Old = this.TablePr; var New = new CTablePr(); New.Set_FromObject(Value); this.TablePr = New; History.Add( this, { Type : historyitem_Style_TablePr, Old : Old, New : New } ); }, Set_TableRowPr : function(Value) { var Old = this.TableRowPr; var New = new CTableRowPr(); New.Set_FromObject(Value); this.TableRowPr = New; History.Add( this, { Type : historyitem_Style_TableRowPr, Old : Old, New : New } ); }, Set_TableCellPr : function(Value) { var Old = this.TableCellPr; var New = new CTableCellPr(); New.Set_FromObject(Value); this.TableCellPr = New; History.Add( this, { Type : historyitem_Style_TableCellPr, Old : Old, New : New } ); }, Set_TableBand1Horz : function(Value) { var Old = this.TableBand1Horz; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableBand1Horz = New; History.Add( this, { Type : historyitem_Style_TableBand1Horz, Old : Old, New : New } ); }, Set_TableBand1Vert : function(Value) { var Old = this.TableBand1Vert; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableBand1Vert = New; History.Add( this, { Type : historyitem_Style_TableBand1Vert, Old : Old, New : New } ); }, Set_TableBand2Horz : function(Value) { var Old = this.TableBand2Horz; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableBand2Horz = New; History.Add( this, { Type : historyitem_Style_TableBand2Horz, Old : Old, New : New } ); }, Set_TableBand2Vert : function(Value) { var Old = this.TableBand2Vert; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableBand2Vert = New; History.Add( this, { Type : historyitem_Style_TableBand2Vert, Old : Old, New : New } ); }, Set_TableFirstCol : function(Value) { var Old = this.TableFirstCol; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableFirstCol = New; History.Add( this, { Type : historyitem_Style_TableFirstCol, Old : Old, New : New } ); }, Set_TableFirstRow : function(Value) { var Old = this.TableFirstRow; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableFirstRow = New; History.Add( this, { Type : historyitem_Style_TableFirstRow, Old : Old, New : New } ); }, Set_TableLastCol : function(Value) { var Old = this.TableLastCol; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableLastCol = New; History.Add( this, { Type : historyitem_Style_TableLastCol, Old : Old, New : New } ); }, Set_TableLastRow : function(Value) { var Old = this.TableLastRow; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableLastRow = New; History.Add( this, { Type : historyitem_Style_TableLastRow, Old : Old, New : New } ); }, Set_TableTLCell : function(Value) { var Old = this.TableTLCell; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableTLCell = New; History.Add( this, { Type : historyitem_Style_TableTLCell, Old : Old, New : New } ); }, Set_TableTRCell : function(Value) { var Old = this.TableTRCell; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableTRCell = New; History.Add( this, { Type : historyitem_Style_TableTRCell, Old : Old, New : New } ); }, Set_TableBLCell : function(Value) { var Old = this.TableBLCell; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableBLCell = New; History.Add( this, { Type : historyitem_Style_TableBLCell, Old : Old, New : New } ); }, Set_TableBRCell : function(Value) { var Old = this.TableBRCell; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableBRCell = New; History.Add( this, { Type : historyitem_Style_TableBRCell, Old : Old, New : New } ); }, Set_TableWholeTable : function(Value) { var Old = this.TableWholeTable; var New = new CTableStylePr(); New.Set_FromObject(Value); this.TableWholeTable = New; History.Add( this, { Type : historyitem_Style_TableWholeTable, Old : Old, New : New } ); }, Set_Name : function(Value) { History.Add( this, { Type : historyitem_Style_Name, Old : this.Name, New : Value } ); this.Name = Value; }, Set_BasedOn : function(Value) { History.Add( this, { Type : historyitem_Style_BasedOn, Old : this.BasedOn, New : Value } ); this.BasedOn = Value; }, Set_Next : function(Value) { History.Add( this, { Type : historyitem_Style_Next, Old : this.Next, New : Value } ); this.Next = Value; }, Set_Type : function(Value) { History.Add( this, { Type : historyitem_Style_Type, Old : this.Type, New : Value } ); this.Type = Value; }, Set_QFormat : function(Value) { History.Add( this, { Type : historyitem_Style_QFormat, Old : this.qFormat, New : Value } ); this.qFormat = Value; }, Set_UiPriority : function(Value) { History.Add( this, { Type : historyitem_Style_UiPriority, Old : this.uiPriority, New : Value } ); this.uiPriority = Value; }, Set_Hidden : function(Value) { History.Add( this, { Type : historyitem_Style_Hidden, Old : this.hidden, New : Value } ); this.hidden = Value; }, Set_SemiHidden : function(Value) { History.Add( this, { Type : historyitem_Style_SemiHidden, Old : this.semiHidden, New : Value } ); this.semiHidden = Value; }, Set_UnhideWhenUsed : function(Value) { History.Add( this, { Type : historyitem_Style_UnhideWhenUsed, Old : this.unhideWhenUsed, New : Value } ); this.unhideWhenUsed = Value; }, //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- Document_Get_AllFontNames : function(AllFonts) { if ( undefined != this.TextPr ) this.TextPr.Document_Get_AllFontNames(AllFonts); }, Create_Default_Paragraph : function() { var TextPr = { FontFamily: { Name : "Arial", Index : -1 }, Color : { r : 0, g : 0, b : 0 }, Unifill : CreateUnfilFromRGB(0,0,0) }; this.Set_QFormat( true ); this.Set_TextPr( TextPr ); }, Create_Default_Character : function() { this.Set_UiPriority( 1 ); this.Set_SemiHidden( true ); this.Set_UnhideWhenUsed( true ); }, Create_Default_Numbering : function() { this.Set_UiPriority( 99 ); this.Set_SemiHidden( true ); this.Set_UnhideWhenUsed( true ); }, Create_Heading1 : function() { var ParaPr = { KeepNext : true, KeepLines: true, Spacing : { Before : 24 * g_dKoef_pt_to_mm, After : 0 }, OutlineLvl : 0 }; var TextPr = { FontSize : 24, FontFamily : { Name : Default_Heading_Font, Index : -1 }, Bold : true, Color : { r : 0, g : 0, b : 0 } }; this.Set_QFormat( true ); this.Set_UiPriority( 9 ); this.Set_ParaPr( ParaPr ); this.Set_TextPr( TextPr ); }, Create_Heading2 : function() { var ParaPr = { KeepNext : true, KeepLines: true, Spacing : { Before : 10 * g_dKoef_pt_to_mm, After : 0 }, OutlineLvl : 1 }; var TextPr = { FontSize : 20, FontFamily : { Name : Default_Heading_Font, Index : -1 }, Bold : true, Color : { r : 0, g : 0, b : 0 } }; this.Set_QFormat( true ); this.Set_UiPriority( 9 ); this.Set_UnhideWhenUsed( true ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Heading3 : function() { var ParaPr = { KeepNext : true, KeepLines: true, Spacing : { Before : 10 * g_dKoef_pt_to_mm, After : 0 }, OutlineLvl : 2 }; var TextPr = { FontSize : 18, FontFamily : { Name : Default_Heading_Font, Index : -1 }, Bold : true, Italic : true, Color : { r : 0, g : 0, b : 0 } }; this.Set_QFormat( true ); this.Set_UiPriority( 9 ); this.Set_UnhideWhenUsed( true ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Heading4 : function() { var ParaPr = { KeepNext : true, KeepLines: true, Spacing : { Before : 10 * g_dKoef_pt_to_mm, After : 0 }, OutlineLvl : 3 }; var TextPr = { FontSize : 16, FontFamily : { Name : Default_Heading_Font, Index : -1 }, Color : { r : 0x23, g : 0x23, b : 0x23 } }; this.Set_QFormat( true ); this.Set_UiPriority( 9 ); this.Set_UnhideWhenUsed( true ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Heading5 : function() { var ParaPr = { KeepNext : true, KeepLines: true, Spacing : { Before : 10 * g_dKoef_pt_to_mm, After : 0 }, OutlineLvl : 4 }; var TextPr = { FontSize : 14, FontFamily : { Name : Default_Heading_Font, Index : -1 }, Bold : true, Color : { r : 0x44, g : 0x44, b : 0x44 } }; this.Set_QFormat( true ); this.Set_UiPriority( 9 ); this.Set_UnhideWhenUsed( true ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Heading6 : function() { var ParaPr = { KeepNext : true, KeepLines: true, Spacing : { Before : 10 * g_dKoef_pt_to_mm, After : 0 }, OutlineLvl : 5 }; var TextPr = { FontSize : 14, Italic : true, FontFamily : { Name : Default_Heading_Font, Index : -1 }, Color : { r : 0x23, g : 0x23, b : 0x23 } }; this.Set_QFormat( true ); this.Set_UiPriority( 9 ); this.Set_UnhideWhenUsed( true ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Heading7 : function() { var ParaPr = { KeepNext : true, KeepLines: true, Spacing : { Before : 10 * g_dKoef_pt_to_mm, After : 0 }, OutlineLvl : 6 }; var TextPr = { FontSize : 12, FontFamily : { Name : Default_Heading_Font, Index : -1 }, Bold : true, Color : { r : 0x60, g : 0x60, b : 0x60 } }; this.Set_QFormat( true ); this.Set_UiPriority( 9 ); this.Set_UnhideWhenUsed( true ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Heading8 : function() { var ParaPr = { KeepNext : true, KeepLines: true, Spacing : { Before : 10 * g_dKoef_pt_to_mm, After : 0 }, OutlineLvl : 7 }; var TextPr = { FontSize : 12, FontFamily : { Name : Default_Heading_Font, Index : -1 }, Color : { r : 0x44, g : 0x44, b : 0x44 } }; this.Set_QFormat( true ); this.Set_UiPriority( 9 ); this.Set_UnhideWhenUsed( true ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Heading9 : function() { var ParaPr = { KeepNext : true, KeepLines: true, Spacing : { Before : 10 * g_dKoef_pt_to_mm, After : 0 }, OutlineLvl : 8 }; var TextPr = { FontSize : 11.5, FontFamily : { Name : Default_Heading_Font, Index : -1 }, Italic : true, Color : { r : 0x44, g : 0x44, b : 0x44 } }; this.Set_QFormat( true ); this.Set_UiPriority( 9 ); this.Set_UnhideWhenUsed( true ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_ListParagraph : function() { var ParaPr = { Ind : { Left : 36 * g_dKoef_pt_to_mm }, ContextualSpacing : true }; this.Set_QFormat( true ); this.Set_UiPriority( 34 ); this.Set_ParaPr( ParaPr ); }, Create_NoSpacing : function() { this.uiPriority = 1; this.qFormat = true; var ParaPr = { Spacing : { Line : 1, LineRule : linerule_Auto, After : 0 } }; var TextPr = { FontFamily : { Name : "Arial", Index : -1 }, Color : { r : 0x00, g : 0x00, b : 0x00 } }; this.Set_QFormat( true ); this.Set_UiPriority( 1 ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Header : function() { var RPos = 297 - 30 - 15; // Ширина страницы - левое поле - правое поле var CPos = RPos / 2; var ParaPr = { Spacing: { After : 0, Line : 1, LineRule : linerule_Auto }, Tabs : { Tabs : [ { Value : tab_Center, Pos : CPos }, { Value : tab_Right, Pos : RPos } ] } }; var TextPr = { FontSize : 11, FontFamily: { Name : "Arial", Index : -1 }, Color : { r : 0x00, g : 0x00, b : 0x00 } }; this.Set_UiPriority( 99 ); this.Set_UnhideWhenUsed( true ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Footer : function() { var RPos = 297 - 30 - 15; // Ширина страницы - левое поле - правое поле var CPos = RPos / 2; var ParaPr = { Spacing: { After : 0, Line : 1, LineRule : linerule_Auto }, Tabs : { Tabs : [ { Value : tab_Center, Pos : CPos }, { Value : tab_Right, Pos : RPos } ] } }; var TextPr = { FontSize : 11, FontFamily: { Name : "Arial", Index : -1 }, Color : { r : 0x00, g : 0x00, b : 0x00 } }; this.Set_UiPriority( 99 ); this.Set_UnhideWhenUsed( true ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_NormalTable : function() { var TablePr = { TableInd : { W : 0, Type : tblwidth_Mm }, TableCellMar : { Top : { W : 0, Type : tblwidth_Mm }, Left : { W : 1.9, // 5.4pt Type : tblwidth_Mm }, Bottom : { W : 0, Type : tblwidth_Mm }, Right : { W : 1.9, // 5.4pt Type : tblwidth_Mm } } }; this.Set_UiPriority( 99 ); this.Set_SemiHidden( true ); this.Set_UnhideWhenUsed( true ); this.Set_TablePr( TablePr ); }, Create_TableGrid : function() { var ParaPr = { Spacing : { After : 0, Line : 1, LineRule : linerule_Auto } }; var TablePr = { TableInd : 0, TableBorders : { Top : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 0.5 * g_dKoef_pt_to_mm, Value : border_Single }, Left : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 0.5 * g_dKoef_pt_to_mm, Value : border_Single }, Bottom : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 0.5 * g_dKoef_pt_to_mm, Value : border_Single }, Right : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 0.5 * g_dKoef_pt_to_mm, Value : border_Single }, InsideH : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 0.5 * g_dKoef_pt_to_mm, Value : border_Single }, InsideV : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 0.5 * g_dKoef_pt_to_mm, Value : border_Single } }, TableCellMar : { Top : { W : 0, Type : tblwidth_Mm }, Left : { W : 1.9, // 5.4pt Type : tblwidth_Mm }, Bottom : { W : 0, Type : tblwidth_Mm }, Right : { W : 1.9, // 5.4pt Type : tblwidth_Mm } } }; this.Set_UiPriority( 59 ); this.Set_TablePr( TablePr ); this.Set_ParaPr( ParaPr ); }, Create_Quote : function() { var ParaPr = { Ind : { Left : 60 // 6 см }, Brd : { Bottom : { Color : { r : 0xA6, g : 0xA6, b : 0xA6 }, Space : 1, Size : 1.5 * g_dKoef_pt_to_mm, Value : border_Single }, Left : { Color : { r : 0xA6, g : 0xA6, b : 0xA6 }, Space : 4, Size : 1.5 * g_dKoef_pt_to_mm, Value : border_Single } } }; var TextPr = { FontSize : 9, FontFamily : { Name : "Arial", Index : -1 }, Italic : true, Color : { r : 0x37, g : 0x37, b : 0x37 } }; this.Set_QFormat( true ); this.Set_UiPriority( 29 ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Subtitle : function() { this.uiPriority = 11; this.qFormat = true; var ParaPr = { Spacing : { Line : 1, LineRule : linerule_Auto }, OutlineLvl : 0 }; var TextPr = { FontSize : 26, FontFamily : { Name : "Arial", Index : -1 }, Italic : true, Color : { r : 0x44, g : 0x44, b : 0x44 } }; this.Set_QFormat( true ); this.Set_UiPriority( 11 ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_IntenseQuote : function() { var ParaPr = { Ind : { Left : 10, // 1 cm Right : 10 // 1 cm }, Shd : { Value : shd_Clear, Color : { r : 0xD9, g : 0xD9, b : 0xD9 } }, Brd : { Bottom : { Color : { r : 0x80, g : 0x80, b : 0x80 }, Space : 1, Size : 0.5 * g_dKoef_pt_to_mm, Value : border_Single }, Left : { Color : { r : 0x80, g : 0x80, b : 0x80 }, Space : 4, Size : 0.5 * g_dKoef_pt_to_mm, Value : border_Single }, Right : { Color : { r : 0x80, g : 0x80, b : 0x80 }, Space : 4, Size : 0.5 * g_dKoef_pt_to_mm, Value : border_Single }, Top : { Color : { r : 0x80, g : 0x80, b : 0x80 }, Space : 1, Size : 0.5 * g_dKoef_pt_to_mm, Value : border_Single } } }; var TextPr = { FontSize : 9.5, FontFamily : { Name : "Arial", Index : -1 }, Italic : true, Color : { r : 0x60, g : 0x60, b : 0x60 } }; this.Set_QFormat( true ); this.Set_UiPriority( 30 ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Title : function() { this.uiPriority = 10; this.qFormat = true; var ParaPr = { Spacing : { Line : 1, LineRule : linerule_Auto, Before : 15 * g_dKoef_pt_to_mm, After : 4 * g_dKoef_pt_to_mm }, Brd : { Bottom : { Color : { r : 0x00, g : 0x00, b : 0x00 }, Space : 0, Size : 3 * g_dKoef_pt_to_mm, Value : border_Single } }, OutlineLvl : 0 }; var TextPr = { FontSize : 36, FontFamily : { Name : "Arial", Index : -1 }, Bold : true, Color : { r : 0x00, g : 0x00, b : 0x00 } }; this.Set_QFormat( true ); this.Set_UiPriority( 10 ); this.Set_TextPr( TextPr ); this.Set_ParaPr( ParaPr ); }, Create_Table_LightShading : function() { this.uiPriority = 60; var ParaPr = { Spacing : { After : 0, Line : 1, LineRule : linerule_Auto } }; var TablePr = { TableStyleColBandSize : 1, TableStyleRowBandSize : 1, TableInd : 0, TableBorders : { Top : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 18 / 8 * g_dKoef_pt_to_mm, Value : border_Single }, Bottom : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 18 / 8 * g_dKoef_pt_to_mm, Value : border_Single } }, TableCellMar : { Top : { W : 0, Type : tblwidth_Mm }, Left : { W : 5.75 * g_dKoef_pt_to_mm, // 0.08 inch Type : tblwidth_Mm }, Bottom : { W : 0, Type : tblwidth_Mm }, Right : { W : 5.75 * g_dKoef_pt_to_mm, // 0.08 inch Type : tblwidth_Mm } } }; var TableFirstRow = { TextPr : { Bold : true, Color : { r : 255, g : 255, b : 255 } }, ParaPr : { Spacing : { After : 0, Before : 0, Line : 1, LineRule : linerule_Auto } }, TableCellPr : { TableCellBorders : { Bottom : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 18 / 8 * g_dKoef_pt_to_mm, Value : border_Single }, Left : { Value : border_None }, Right : { Value : border_None }, Top : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 18 / 8 * g_dKoef_pt_to_mm, Value : border_Single } }, Shd : { Value : shd_Clear, Color : { r : 0x4F, g : 0x81, b : 0xBD } } } }; var TableLastRow = { TextPr : { Color : { r : 0, g : 0, b : 0 } }, TableCellPr : { TableCellBorders : { Bottom : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 18 / 8 * g_dKoef_pt_to_mm, Value : border_Single }, Left : { Value : border_None }, Right : { Value : border_None }, Top : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 12 / 8 * g_dKoef_pt_to_mm, Value : border_Single } }, Shd : { Value : shd_Clear, Color : { r : 0xFF, g : 0xFF, b : 0xFF } } } }; var TableFirstCol = { TextPr : { Bold : true, Color : { r : 255, g : 255, b : 255 } }, ParaPr : { Spacing : { After : 0, Before : 0, Line : 1, LineRule : linerule_Auto } }, TableCellPr : { TableCellBorder : { Bottom : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 18 / 8 * g_dKoef_pt_to_mm, Value : border_Single }, Left : { Value : border_None }, Right : { Value : border_None }, Top : { Value : border_None } }, Shd : { Value : shd_Clear, Color : { r : 0x4F, g : 0x81, b : 0xBD } } } }; var TableLastCol = { TextPr : { Bold : true, Color : { r : 255, g : 255, b : 255 } }, TableCellPr : { TableCellBorders : { Left : { Value : border_None }, Right : { Value : border_None } }, Shd : { Value : shd_Clear, Color : { r : 0x4F, g : 0x81, b : 0xBD } } } }; var TableBand1Vert = { TableCellPr : { TableCellBorders : { Left : { Value : border_None }, Right : { Value : border_None } }, Shd : { Value : shd_Clear, Color : { r : 0xD8, g : 0xD8, b : 0xD8 } } } }; var TableBand1Horz = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : 0xD8, g : 0xD8, b : 0xD8 } } } }; var TableTRCell = { TableCellPr : { TableCellBorders: { Bottom : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 18 / 8 * g_dKoef_pt_to_mm, Value : border_Single }, Left : { Value : border_None }, Right : { Value : border_None }, Top : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 18 / 8 * g_dKoef_pt_to_mm, Value : border_Single } }, Shd : { Value : shd_Clear, Color : { r : 0, g : 255, b : 0 } } } }; var TableTLCell = { TextPr : { Color : { r : 255, g : 255, b : 255 } }, TableCellPr : { TableCellBorders: { Bottom : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 18 / 8 * g_dKoef_pt_to_mm, Value : border_Single }, Left : { Value : border_None }, Right : { Value : border_None }, Top : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 18 / 8 * g_dKoef_pt_to_mm, Value : border_Single } } , Shd : { Value : shd_Clear, Color : { r : 255, g : 0, b : 0 } } } }; this.Set_UiPriority( 60 ); this.Set_ParaPr( ParaPr ); this.Set_TablePr( TablePr ); this.Set_TableFirstRow( TableFirstRow ); this.Set_TableLastRow( TableLastRow ); this.Set_TableFirstCol( TableFirstCol ); this.Set_TableLastCol( TableLastCol ); this.Set_TableBand1Horz( TableBand1Horz ); this.Set_TableBand1Vert( TableBand1Vert ); this.Set_TableTRCell( TableTRCell ); this.Set_TableTLCell( TableTLCell ); }, Create_Table_ColorfulListAccent6 : function() { this.uiPriority = 72; var ParaPr = { Spacing : { After : 0, Line : 1, LineRule : linerule_Auto } }; var TextPr = { Color : { r : 0, g : 0, b : 0 } }; var TablePr = { TableStyleColBandSize : 1, TableStyleRowBandSize : 1, TableInd : 0, TableCellMar : { TableCellMar : { Top : { W : 0, Type : tblwidth_Mm }, Left : { W : 5.75 * g_dKoef_pt_to_mm, // 0.08 inch Type : tblwidth_Mm }, Bottom : { W : 0, Type : tblwidth_Mm }, Right : { W : 5.75 * g_dKoef_pt_to_mm, // 0.08 inch Type : tblwidth_Mm } } } }; var TableCellPr = { Shd : { Value : shd_Clear, Color : { r : 0xFE, g : 0xF4, b : 0xEC } } }; var TableFirstRow = { TextPr : { Bold : true, Color : { r : 0xFF, g : 0xFF, b : 0xFF } }, TableCellPr : { TableCellBorders : { Bottom : { Color : { r : 0xFF, g : 0xFF, b : 0xFF }, Space : 0, Size : 12 / 8 * g_dKoef_pt_to_mm, Value : border_Single } }, Shd : { Value : shd_Clear, Color : { r : 0x34, g : 0x8D, b : 0xA5 } } } }; var TableLastRow = { TextPr : { Bold : true, Color : { r : 0x34, g : 0x8D, b : 0xA5 } }, TableCellPr : { TableCellBorders : { Top : { Color : { r : 0, g : 0, b : 0 }, Space : 0, Size : 12 / 8 * g_dKoef_pt_to_mm, Value : border_Single } }, Shd : { Value : shd_Clear, Color : { r : 0xFF, g : 0xFF, b : 0xFF } } } }; var TableFirstCol = { TextPr : { Bold : true } }; var TableLastCol = { TextPr : { Bold : true } }; var TableBand1Vert = { TableCellPr : { TableCellBorders : { Top : { Value : border_None }, Left : { Value : border_None }, Bottom : { Value : border_None }, Right : { Value : border_None }, InsideH : { Value : border_None }, InsideV : { Value : border_None } }, Shd : { Value : shd_Clear, Color : { r : 0xFD, g : 0xE4, b : 0xD0 } } } }; var TableBand1Horz = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : 0xFD, g : 0xE9, b : 0xD9 } } } }; this.Set_UiPriority( 72 ); this.Set_ParaPr( ParaPr ); this.Set_TextPr( TextPr ); this.Set_TablePr( TablePr ); this.Set_TableCellPr( TableCellPr ); this.Set_TableFirstRow( TableFirstRow ); this.Set_TableLastRow( TableLastRow ); this.Set_TableFirstCol( TableFirstCol ); this.Set_TableLastCol( TableLastCol ); this.Set_TableBand1Horz( TableBand1Horz ); this.Set_TableBand1Vert( TableBand1Vert ); }, Create_Table_Lined : function(Color1, Color2) { this.uiPriority = 99; // ParaPr var ParaPr = { Spacing : { After : 0, Line : 1, LineRule : linerule_Auto } }; // TablePr var TablePr = { TableStyleColBandSize : 1, TableStyleRowBandSize : 1, TableInd : 0, TableCellMar : { Top : new CTableMeasurement( tblwidth_Auto, 0 ), Left : new CTableMeasurement( tblwidth_Auto, 5.4 * g_dKoef_pt_to_mm ), Bottom : new CTableMeasurement( tblwidth_Auto, 0 ), Right : new CTableMeasurement( tblwidth_Auto, 5.4 * g_dKoef_pt_to_mm ) } }; // TableFirstRow var TableFirstRow = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color1.r, g : Color1.g, b : Color1.b} } } }; // TableLastRow var TableLastRow = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color1.r, g : Color1.g, b : Color1.b} } } }; // TableFirstCol var TableFirstCol = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color1.r, g : Color1.g, b : Color1.b} } } }; // TableLastCol var TableLastCol = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color1.r, g : Color1.g, b : Color1.b} } } }; // TableBand2Vert var TableBand2Vert = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color2.r, g : Color2.g, b : Color2.b} } } }; // TableBand2Horz var TableBand2Horz = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color2.r, g : Color2.g, b : Color2.b} } } }; this.Set_UiPriority( 99 ); this.Set_ParaPr( ParaPr ); this.Set_TablePr( TablePr ); this.Set_TableFirstRow( TableFirstRow ); this.Set_TableLastRow( TableLastRow ); this.Set_TableFirstCol( TableFirstCol ); this.Set_TableLastCol( TableLastCol ); this.Set_TableBand2Horz( TableBand2Horz ); this.Set_TableBand2Vert( TableBand2Vert ); }, Create_Table_Bordered : function(Color1, Color2) { // ParaPr var ParaPr = { Spacing : { After : 0, Line : 1, LineRule : linerule_Auto } }; // TablePr var TablePr = { TableInd : 0, TableBorders : { Top : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 }, Left : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 }, Bottom : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 }, Right : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 }, InsideH : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 }, InsideV : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 } }, TableCellMar : { Top : new CTableMeasurement( tblwidth_Auto, 0 ), Left : new CTableMeasurement( tblwidth_Auto, 5.4 * g_dKoef_pt_to_mm ), Bottom : new CTableMeasurement( tblwidth_Auto, 0 ), Right : new CTableMeasurement( tblwidth_Auto, 5.4 * g_dKoef_pt_to_mm ) } }; // TableFirstRow var TableFirstRow = { TableCellPr : { TableCellBorders : { Bottom : { Color : { r : Color2.r, g : Color2.g, b : Color2.b }, Value : border_Single, Size : 2.25 * g_dKoef_pt_to_mm, Space : 0 } } } }; // TableLastRow var TableLastRow = { TableCellPr : { TableCellBorders : { Top : { Color : { r : Color2.r, g : Color2.g, b : Color2.b }, Value : border_Single, Size : 2.25 * g_dKoef_pt_to_mm, Space : 0 } } } }; // TableFirstCol var TableFirstCol = { TableCellPr : { TableCellBorders : { Right : { Color : { r : Color2.r, g : Color2.g, b : Color2.b }, Value : border_Single, Size : 2.25 * g_dKoef_pt_to_mm, Space : 0 } } } }; // TableLastCol var TableLastCol = { TableCellPr : { TableCellBorders : { Left : { Color : { r : Color2.r, g : Color2.g, b : Color2.b }, Value : border_Single, Size : 2.25 * g_dKoef_pt_to_mm, Space : 0 } } } }; this.Set_UiPriority( 99 ); this.Set_ParaPr( ParaPr ); this.Set_TablePr( TablePr ); this.Set_TableFirstRow( TableFirstRow ); this.Set_TableLastRow( TableLastRow ); this.Set_TableFirstCol( TableFirstCol ); this.Set_TableLastCol( TableLastCol ); }, Create_Table_BorderedAndLined : function(Color1, Color2, Color3) { this.uiPriority = 99; // ParaPr var ParaPr = { Spacing : { After : 0, Line : 1, LineRule : linerule_Auto } }; // TablePr var TablePr = { TableStyleColBandSize : 1, TableStyleRowBandSize : 1, TableInd : 0, TableCellMar : { Top : new CTableMeasurement( tblwidth_Auto, 0 ), Left : new CTableMeasurement( tblwidth_Auto, 5.4 * g_dKoef_pt_to_mm ), Bottom : new CTableMeasurement( tblwidth_Auto, 0 ), Right : new CTableMeasurement( tblwidth_Auto, 5.4 * g_dKoef_pt_to_mm ) }, TableBorders : { Top : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 }, Left : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 }, Bottom : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 }, Right : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 }, InsideH : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 }, InsideV : { Color : { r : Color1.r, g : Color1.g, b : Color1.b }, Value : border_Single, Size : 0.5 * g_dKoef_pt_to_mm, Space : 0 } } }; // TableFirstRow var TableFirstRow = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color2.r, g : Color2.g, b : Color2.b} } } }; // TableLastRow var TableLastRow = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color2.r, g : Color2.g, b : Color2.b} } } }; // TableFirstCol var TableFirstCol = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color2.r, g : Color2.g, b : Color2.b} } } }; // TableLastCol var TableLastCol = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color2.r, g : Color2.g, b : Color2.b} } } }; // TableBand2Vert var TableBand2Vert = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color3.r, g : Color3.g, b : Color3.b} } } }; // TableBand2Horz var TableBand2Horz = { TableCellPr : { Shd : { Value : shd_Clear, Color : { r : Color3.r, g : Color3.g, b : Color3.b} } } }; this.Set_UiPriority( 99 ); this.Set_ParaPr( ParaPr ); this.Set_TablePr( TablePr ); this.Set_TableFirstRow( TableFirstRow ); this.Set_TableLastRow( TableLastRow ); this.Set_TableFirstCol( TableFirstCol ); this.Set_TableLastCol( TableLastCol ); this.Set_TableBand2Horz( TableBand2Horz ); this.Set_TableBand2Vert( TableBand2Vert ); }, Create_Character_Hyperlink : function() { var TextPr = { Color : { r : 0x00, g : 0x00, b : 0xFF }, Underline : true, Unifill : CreateUniFillSchemeColorWidthTint(11, 0) }; this.Set_UiPriority( 99 ); this.Set_UnhideWhenUsed( true ); this.Set_TextPr( TextPr ); }, isEqual: function(cStyles) { var result = false; if(this.BasedOn == cStyles.BasedOn && this.Name == cStyles.Name && this.Next == cStyles.Next && this.Type == cStyles.Type && this.hidden == cStyles.hidden) { if(this.qFormat == cStyles.qFormat && this.semiHidden == cStyles.semiHidden && this.uiPriority == cStyles.uiPriority && this.unhideWhenUsed == cStyles.unhideWhenUsed) { var isEqualParaPr = this.ParaPr.isEqual(this.ParaPr, cStyles.ParaPr); var isEqualTextPr = this.TextPr.isEqual(this.TextPr, cStyles.TextPr); if(isEqualParaPr && isEqualTextPr) result = true; } } return result; }, //----------------------------------------------------------------------------------- // Undo/Redo функции //----------------------------------------------------------------------------------- Undo : function(Data) { var Type = Data.Type; switch ( Type ) { case historyitem_Style_TextPr: { this.TextPr = Data.Old; break; } case historyitem_Style_ParaPr: { this.ParaPr = Data.Old; break; } case historyitem_Style_TablePr: { this.TablePr = Data.Old; break; } case historyitem_Style_TableRowPr: { this.TableRowPr = Data.Old; break; } case historyitem_Style_TableCellPr: { this.TableCellPr = Data.Old; break; } case historyitem_Style_TableBand1Horz: { this.TableBand1Horz = Data.Old; break; } case historyitem_Style_TableBand1Vert: { this.TableBand1Vert = Data.Old; break; } case historyitem_Style_TableBand2Horz: { this.TableBand2Horz = Data.Old; break; } case historyitem_Style_TableBand2Vert: { this.TableBand2Vert = Data.Old; break; } case historyitem_Style_TableFirstCol: { this.TableFirstCol = Data.Old; break; } case historyitem_Style_TableFirstRow: { this.TableFirstRow = Data.Old; break; } case historyitem_Style_TableLastCol: { this.TableLastCol = Data.Old; break; } case historyitem_Style_TableLastRow: { this.TableLastRow = Data.Old; break; } case historyitem_Style_TableTLCell: { this.TableTLCell = Data.Old; break; } case historyitem_Style_TableTRCell: { this.TableTRCell = Data.Old; break; } case historyitem_Style_TableBLCell: { this.TableBLCell = Data.Old; break; } case historyitem_Style_TableBRCell: { this.TableBRCell = Data.Old; break; } case historyitem_Style_TableWholeTable: { this.TableWholeTable = Data.Old; break; } case historyitem_Style_Name: { this.Name = Data.Old; break; } case historyitem_Style_BasedOn: { this.BasedOn = Data.Old; break; } case historyitem_Style_Next: { this.Next = Data.Old; break; } case historyitem_Style_Type: { this.Type = Data.Old; break; } case historyitem_Style_QFormat: { this.qFormat = Data.Old; break; } case historyitem_Style_UiPriority: { this.uiPriority = Data.Old; break; } case historyitem_Style_Hidden: { this.hidden = Data.Old; break; } case historyitem_Style_SemiHidden: { this.semiHidden = Data.Old; break; } case historyitem_Style_UnhideWhenUsed: { this.unhideWhenUsed = Data.Old; break; } } }, Redo : function(Data) { var Type = Data.Type; switch ( Type ) { case historyitem_Style_TextPr: { this.TextPr = Data.New; break; } case historyitem_Style_ParaPr: { this.ParaPr = Data.New; break; } case historyitem_Style_TablePr: { this.TablePr = Data.New; break; } case historyitem_Style_TableRowPr: { this.TableRowPr = Data.New; break; } case historyitem_Style_TableCellPr: { this.TableCellPr = Data.New; break; } case historyitem_Style_TableBand1Horz: { this.TableBand1Horz = Data.New; break; } case historyitem_Style_TableBand1Vert: { this.TableBand1Vert = Data.New; break; } case historyitem_Style_TableBand2Horz: { this.TableBand2Horz = Data.New; break; } case historyitem_Style_TableBand2Vert: { this.TableBand2Vert = Data.New; break; } case historyitem_Style_TableFirstCol: { this.TableFirstCol = Data.New; break; } case historyitem_Style_TableFirstRow: { this.TableFirstRow = Data.New; break; } case historyitem_Style_TableLastCol: { this.TableLastCol = Data.New; break; } case historyitem_Style_TableLastRow: { this.TableLastRow = Data.New; break; } case historyitem_Style_TableTLCell: { this.TableTLCell = Data.New; break; } case historyitem_Style_TableTRCell: { this.TableTRCell = Data.New; break; } case historyitem_Style_TableBLCell: { this.TableBLCell = Data.New; break; } case historyitem_Style_TableBRCell: { this.TableBRCell = Data.New; break; } case historyitem_Style_TableWholeTable: { this.TableWholeTable = Data.New; break; } case historyitem_Style_Name: { this.Name = Data.New; break; } case historyitem_Style_BasedOn: { this.BasedOn = Data.New; break; } case historyitem_Style_Next: { this.Next = Data.New; break; } case historyitem_Style_Type: { this.Type = Data.New; break; } case historyitem_Style_QFormat: { this.qFormat = Data.New; break; } case historyitem_Style_UiPriority: { this.uiPriority = Data.New; break; } case historyitem_Style_Hidden: { this.hidden = Data.New; break; } case historyitem_Style_SemiHidden: { this.semiHidden = Data.New; break; } case historyitem_Style_UnhideWhenUsed: { this.unhideWhenUsed = Data.New; break; } } }, Get_SelectionState : function() { }, Set_SelectionState : function(State, StateIndex) { }, Get_ParentObject_or_DocumentPos : function() { return { Type : historyrecalctype_Inline, Data : 0 }; }, Refresh_RecalcData : function(Data) { var Type = Data.Type; var bNeedRecalc = false; switch ( Type ) { case historyitem_Style_TextPr : case historyitem_Style_ParaPr : case historyitem_Style_TablePr : case historyitem_Style_TableRowPr : case historyitem_Style_TableCellPr : case historyitem_Style_TableBand1Horz : case historyitem_Style_TableBand1Vert : case historyitem_Style_TableBand2Horz : case historyitem_Style_TableBand2Vert : case historyitem_Style_TableFirstCol : case historyitem_Style_TableFirstRow : case historyitem_Style_TableLastCol : case historyitem_Style_TableLastRow : case historyitem_Style_TableTLCell : case historyitem_Style_TableTRCell : case historyitem_Style_TableBLCell : case historyitem_Style_TableBRCell : case historyitem_Style_TableWholeTable : case historyitem_Style_Name : case historyitem_Style_BasedOn : case historyitem_Style_Next : case historyitem_Style_Type : case historyitem_Style_QFormat : case historyitem_Style_UiPriority : case historyitem_Style_Hidden : case historyitem_Style_SemiHidden : case historyitem_Style_UnhideWhenUsed : { break; } } if ( true === bNeedRecalc ) { // Сообщаем родительскому классу, что изменения произошли в элементе с номером this.Index и на странице this.PageNum return this.Refresh_RecalcData2(); } }, Refresh_RecalcData2 : function() { //editor.WordControl.m_oLogicDocument.Refresh_RecalcData2( 0, 0 ); }, //----------------------------------------------------------------------------------- // Функции для совместного редактирования //----------------------------------------------------------------------------------- Document_Is_SelectionLocked : function(CheckType) { switch ( CheckType ) { case changestype_Paragraph_Content: case changestype_Paragraph_Properties: case changestype_Document_Content: case changestype_Document_Content_Add: case changestype_Image_Properties: case changestype_Remove: case changestype_Delete: case changestype_Document_SectPr: case changestype_Table_Properties: case changestype_Table_RemoveCells: case changestype_HdrFtr: { CollaborativeEditing.Add_CheckLock(true); break; } } }, Save_Changes : function(Data, Writer) { // Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл. // Long : тип класса // Long : тип изменений Writer.WriteLong( historyitem_type_Style ); var Type = Data.Type; // Пишем тип Writer.WriteLong( Type ); switch ( Type ) { case historyitem_Style_TextPr: case historyitem_Style_ParaPr: case historyitem_Style_TablePr: case historyitem_Style_TableRowPr: case historyitem_Style_TableCellPr: case historyitem_Style_TableBand1Horz: case historyitem_Style_TableBand1Vert: case historyitem_Style_TableBand2Horz: case historyitem_Style_TableBand2Vert: case historyitem_Style_TableFirstCol: case historyitem_Style_TableFirstRow: case historyitem_Style_TableLastCol: case historyitem_Style_TableLastRow: case historyitem_Style_TableTLCell: case historyitem_Style_TableTRCell: case historyitem_Style_TableBLCell: case historyitem_Style_TableBRCell: case historyitem_Style_TableWholeTable: { // Variable Data.New.Write_ToBinary( Writer ); break; } case historyitem_Style_Name: case historyitem_Style_BasedOn: case historyitem_Style_Next: { // Bool : is undefined // (false) // Bool : is null // (false) // String : value if ( undefined === Data.New ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); if ( null === Data.New ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); Writer.WriteString2( Data.New ); } } break; } case historyitem_Style_Type: { // Long : value Writer.WriteLong( Data.New ); break; } case historyitem_Style_QFormat: case historyitem_Style_Hidden: case historyitem_Style_SemiHidden: case historyitem_Style_UnhideWhenUsed: { // Bool : is undefined // (false) // Bool : is null // (false) // Bool : value if ( undefined === Data.New ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); if ( null === Data.New ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); Writer.WriteBool( Data.New ); } } break; } case historyitem_Style_UiPriority: { // Bool : is undefined // (false) // Bool : is null // (false) // Long : value if ( undefined === Data.New ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); if ( null === Data.New ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); Writer.WriteLong( Data.New ); } } break; } } return Writer; }, Load_Changes : function(Reader) { // Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл. // Long : тип класса // Long : тип изменений var ClassType = Reader.GetLong(); if ( historyitem_type_Style != ClassType ) return; var Type = Reader.GetLong(); switch ( Type ) { case historyitem_Style_TextPr: { // Variable this.TextPr = new CTextPr(); this.TextPr.Read_FromBinary( Reader ); break; } case historyitem_Style_ParaPr: { // Variable this.ParaPr = new CParaPr(); this.ParaPr.Read_FromBinary( Reader ); break; } case historyitem_Style_TablePr: { // Variable this.TablePr = new CTablePr(); this.TablePr.Read_FromBinary( Reader ); break; } case historyitem_Style_TableRowPr: { // Variable this.TableRowPr = new CTableRowPr(); this.TableRowPr.Read_FromBinary( Reader ); break; } case historyitem_Style_TableCellPr: { // Variable this.TableCellPr = new CTableCellPr(); this.TableCellPr.Read_FromBinary( Reader ); break; } case historyitem_Style_TableBand1Horz: { // Variable this.TableBand1Horz = new CTableStylePr(); this.TableBand1Horz.Read_FromBinary( Reader ); break; } case historyitem_Style_TableBand1Vert: { // Variable this.TableBand1Vert = new CTableStylePr(); this.TableBand1Vert.Read_FromBinary( Reader ); break; } case historyitem_Style_TableBand2Horz: { // Variable this.TableBand2Horz = new CTableStylePr(); this.TableBand2Horz.Read_FromBinary( Reader ); break; } case historyitem_Style_TableBand2Vert: { // Variable this.TableBand2Vert = new CTableStylePr(); this.TableBand2Vert.Read_FromBinary( Reader ); break; } case historyitem_Style_TableFirstCol: { // Variable this.TableFirstCol = new CTableStylePr(); this.TableFirstCol.Read_FromBinary( Reader ); break; } case historyitem_Style_TableFirstRow: { // Variable this.TableFirstRow = new CTableStylePr(); this.TableFirstRow.Read_FromBinary( Reader ); break; } case historyitem_Style_TableLastCol: { // Variable this.TableLastCol = new CTableStylePr(); this.TableLastCol.Read_FromBinary( Reader ); break; } case historyitem_Style_TableLastRow: { // Variable this.TableLastRow = new CTableStylePr(); this.TableLastRow.Read_FromBinary( Reader ); break; } case historyitem_Style_TableTLCell: { // Variable this.TableTLCell = new CTableStylePr(); this.TableTLCell.Read_FromBinary( Reader ); break; } case historyitem_Style_TableTRCell: { // Variable this.TableTRCell = new CTableStylePr(); this.TableTRCell.Read_FromBinary( Reader ); break; } case historyitem_Style_TableBLCell: { // Variable this.TableBLCell = new CTableStylePr(); this.TableBLCell.Read_FromBinary( Reader ); break; } case historyitem_Style_TableBRCell: { // Variable this.TableBRCell = new CTableStylePr(); this.TableBRCell.Read_FromBinary( Reader ); break; } case historyitem_Style_TableWholeTable: { // Variable this.TableWholeTable = new CTableStylePr(); this.TableWholeTable.Read_FromBinary( Reader ); break; } case historyitem_Style_Name: { // Bool : is undefined // (false) // Bool : is null // (false) // String : value if ( true === Reader.GetBool() ) this.Name = undefined; else if ( true === Reader.GetBool() ) this.Name = null; else this.Name = Reader.GetString2(); break; } case historyitem_Style_BasedOn: { // Bool : is undefined // (false) // Bool : is null // (false) // String : value if ( true === Reader.GetBool() ) this.BasedOn = undefined; else if ( true === Reader.GetBool() ) this.BasedOn = null; else this.BasedOn = Reader.GetString2(); break; } case historyitem_Style_Next: { // Bool : is undefined // (false) // Bool : is null // (false) // String : value if ( true === Reader.GetBool() ) this.Next = undefined; else if ( true === Reader.GetBool() ) this.Next = null; else this.Next = Reader.GetString2(); break; } case historyitem_Style_Type: { // Long : value this.Type = Reader.GetLong(); break; } case historyitem_Style_QFormat: { // Bool : is undefined // (false) // Bool : is null // (false) // Bool : value if ( true === Reader.GetBool() ) this.qFormat = undefined; else if ( true === Reader.GetBool() ) this.qFormat = null; else this.qFormat = Reader.GetBool(); break; } case historyitem_Style_Hidden: { // Bool : is undefined // (false) // Bool : is null // (false) // Bool : value if ( true === Reader.GetBool() ) this.hidden = undefined; else if ( true === Reader.GetBool() ) this.hidden = null; else this.hidden = Reader.GetBool(); break; } case historyitem_Style_SemiHidden: { // Bool : is undefined // (false) // Bool : is null // (false) // Bool : value if ( true === Reader.GetBool() ) this.semiHidden = undefined; else if ( true === Reader.GetBool() ) this.semiHidden = null; else this.semiHidden = Reader.GetBool(); break; } case historyitem_Style_UnhideWhenUsed: { // Bool : is undefined // (false) // Bool : is null // (false) // Bool : value if ( true === Reader.GetBool() ) this.unhideWhenUsed = undefined; else if ( true === Reader.GetBool() ) this.unhideWhenUsed = null; else this.unhideWhenUsed = Reader.GetBool(); break; } case historyitem_Style_UiPriority: { // Bool : is undefined // (false) // Bool : is null // (false) // Long : value if ( true === Reader.GetBool() ) this.uiPriority = undefined; else if ( true === Reader.GetBool() ) this.uiPriority = null; else this.uiPriority = Reader.GetLong(); break; } } }, Write_ToBinary2 : function(Writer) { Writer.WriteLong( historyitem_type_Style ); // String : Id // Bool(und) -> Bool(null) -> String : Name // Bool(und) -> Bool(null) -> String : BasedOn // Bool(und) -> Bool(null) -> String : Next // Long : Type // Bool(und) -> Bool(null) -> Long : uiPriority // Bool(und) -> Bool(null) -> Bool : qFormat // Bool(und) -> Bool(null) -> Bool : hidden // Bool(und) -> Bool(null) -> Bool : semiHidden // Bool(und) -> Bool(null) -> Bool : unhideWhenUsed // Variable(CTextPr) : TextPr // Variable(CParaPr) : ParaPr // Variable(CTablePr) : TablePr // Variable(CTableRowPr) : TableRowPr // Variable(CTableCellPr) : TableCellPr // Variable(CTableStylePr) : TableBand1Horz // Variable(CTableStylePr) : TableBand1Vert // Variable(CTableStylePr) : TableBand2Horz // Variable(CTableStylePr) : TableBand2Vert // Variable(CTableStylePr) : TableFirstCol // Variable(CTableStylePr) : TableFirstRow // Variable(CTableStylePr) : TableLastCol // Variable(CTableStylePr) : TableLastRow // Variable(CTableStylePr) : TableTLCell // Variable(CTableStylePr) : TableTRCell // Variable(CTableStylePr) : TableBLCell // Variable(CTableStylePr) : TableBRCell // Variable(CTableStylePr) : TableWholeTable Writer.WriteString2( this.Id ); if ( undefined === this.Name ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); if ( null === this.Name ) Writer.WriteBool( true ); else Writer.WriteString2( this.Name ); } if ( undefined === this.BasedOn ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); if ( null === this.BasedOn ) Writer.WriteBool( true ); else Writer.WriteString2( this.BasedOn ); } if ( undefined === this.Next ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); if ( null === this.Next ) Writer.WriteBool( true ); else Writer.WriteString2( this.Next ); } Writer.WriteLong( this.Type ); if ( undefined === this.uiPriority ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); if ( null === this.uiPriority ) Writer.WriteBool( true ); else Writer.WriteLong( this.uiPriority ); } if ( undefined === this.qFormat ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); if ( null === this.qFormat ) Writer.WriteBool( true ); else Writer.WriteBool( this.qFormat ); } if ( undefined === this.hidden ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); if ( null === this.hidden ) Writer.WriteBool( true ); else Writer.WriteBool( this.hidden ); } if ( undefined === this.semiHidden ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); if ( null === this.semiHidden ) Writer.WriteBool( true ); else Writer.WriteBool( this.semiHidden ); } if ( undefined === this.unhideWhenUsed ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); if ( null === this.unhideWhenUsed ) Writer.WriteBool( true ); else Writer.WriteBool( this.unhideWhenUsed ); } this.TextPr.Write_ToBinary(Writer); this.ParaPr.Write_ToBinary(Writer); this.TablePr.Write_ToBinary(Writer); this.TableRowPr.Write_ToBinary(Writer); this.TableCellPr.Write_ToBinary(Writer); this.TableBand1Horz.Write_ToBinary(Writer); this.TableBand1Vert.Write_ToBinary(Writer); this.TableBand2Horz.Write_ToBinary(Writer); this.TableBand2Vert.Write_ToBinary(Writer); this.TableFirstCol.Write_ToBinary(Writer); this.TableFirstRow.Write_ToBinary(Writer); this.TableLastCol.Write_ToBinary(Writer); this.TableLastRow.Write_ToBinary(Writer); this.TableTLCell.Write_ToBinary(Writer); this.TableTRCell.Write_ToBinary(Writer); this.TableBLCell.Write_ToBinary(Writer); this.TableBRCell.Write_ToBinary(Writer); this.TableWholeTable.Write_ToBinary(Writer); }, Read_FromBinary2 : function(Reader) { // String : Id // Bool(und) -> Bool(null) -> String : Name // Bool(und) -> Bool(null) -> String : BasedOn // Bool(und) -> Bool(null) -> String : Next // Long : Type // Bool(und) -> Bool(null) -> Long : uiPriority // Bool(und) -> Bool(null) -> Bool : qFormat // Bool(und) -> Bool(null) -> Bool : hidden // Bool(und) -> Bool(null) -> Bool : semiHidden // Bool(und) -> Bool(null) -> Bool : unhideWhenUsed // Variable(CTextPr) : TextPr // Variable(CParaPr) : ParaPr // Variable(CTablePr) : TablePr // Variable(CTableRowPr) : TableRowPr // Variable(CTableCellPr) : TableCellPr // Variable(CTableStylePr) : TableBand1Horz // Variable(CTableStylePr) : TableBand1Vert // Variable(CTableStylePr) : TableBand2Horz // Variable(CTableStylePr) : TableBand2Vert // Variable(CTableStylePr) : TableFirstCol // Variable(CTableStylePr) : TableFirstRow // Variable(CTableStylePr) : TableLastCol // Variable(CTableStylePr) : TableLastRow // Variable(CTableStylePr) : TableTLCell // Variable(CTableStylePr) : TableTRCell // Variable(CTableStylePr) : TableBLCell // Variable(CTableStylePr) : TableBRCell // Variable(CTableStylePr) : TableWholeTable this.Id = Reader.GetString2(); if ( true === Reader.GetBool() ) this.Name = undefined; else if ( true === Reader.GetBool() ) this.Name = null; else this.Name = Reader.GetString2(); if ( true === Reader.GetBool() ) this.BasedOn = undefined; else if ( true === Reader.GetBool() ) this.BasedOn = null; else this.BasedOn = Reader.GetString2(); if ( true === Reader.GetBool() ) this.Next = undefined; else if ( true === Reader.GetBool() ) this.Next = null; else this.Next = Reader.GetString2(); this.Type = Reader.GetLong(); if ( true === Reader.GetBool() ) this.uiPriority = undefined; else if ( true === Reader.GetBool() ) this.uiPriority = null; else this.uiPriority = Reader.GetLong(); if ( true === Reader.GetBool() ) this.qFormat = undefined; else if ( true === Reader.GetBool() ) this.qFormat = null; else this.qFormat = Reader.GetBool(); if ( true === Reader.GetBool() ) this.hidden = undefined; else if ( true === Reader.GetBool() ) this.hidden = null; else this.hidden = Reader.GetBool(); if ( true === Reader.GetBool() ) this.semiHidden = undefined; else if ( true === Reader.GetBool() ) this.semiHidden = null; else this.semiHidden = Reader.GetBool(); if ( true === Reader.GetBool() ) this.unhideWhenUsed = undefined; else if ( true === Reader.GetBool() ) this.unhideWhenUsed = null; else this.unhideWhenUsed = Reader.GetBool(); this.TextPr.Read_FromBinary(Reader); this.ParaPr.Read_FromBinary(Reader); this.TablePr.Read_FromBinary(Reader); this.TableRowPr.Read_FromBinary(Reader); this.TableCellPr.Read_FromBinary(Reader); this.TableBand1Horz.Read_FromBinary(Reader); this.TableBand1Vert.Read_FromBinary(Reader); this.TableBand2Horz.Read_FromBinary(Reader); this.TableBand2Vert.Read_FromBinary(Reader); this.TableFirstCol.Read_FromBinary(Reader); this.TableFirstRow.Read_FromBinary(Reader); this.TableLastCol.Read_FromBinary(Reader); this.TableLastRow.Read_FromBinary(Reader); this.TableTLCell.Read_FromBinary(Reader); this.TableTRCell.Read_FromBinary(Reader); this.TableBLCell.Read_FromBinary(Reader); this.TableBRCell.Read_FromBinary(Reader); this.TableWholeTable.Read_FromBinary(Reader); }, Load_LinkData : function(LinkData) { } }; function CStyles() { this.Id = g_oIdCounter.Get_NewId(); this.Default = { ParaPr : new CParaPr(), TextPr : new CTextPr(), TablePr : new CTablePr(), TableRowPr : new CTableRowPr(), TableCellPr : new CTableCellPr(), Paragraph : null, Character : null, Numbering : null, Table : null, TableGrid : null, Headings : [], ParaList : null, Header : null, Footer : null, Hyperlink : null }; // Заполняем значения по умолчанию this.Default.ParaPr.Init_Default(); this.Default.TextPr.Init_Default(); this.Default.TablePr.Init_Default(); this.Default.TableRowPr.Init_Default(); this.Default.TableCellPr.Init_Default(); this.Style = []; // Создадим стандартные стили // Дефолтовый стиль для параграфа var Style_Para_Def = new CStyle( "Normal", null, null, styletype_Paragraph ); Style_Para_Def.Create_Default_Paragraph(); this.Default.Paragraph = this.Add( Style_Para_Def ); // Дефолтовый стиль для текста var Style_Char_Def = new CStyle( "Default Paragraph Font", null, null, styletype_Character ); Style_Char_Def.Create_Default_Character(); this.Default.Character = this.Add( Style_Char_Def ); // Дефолтовый стиль для нумерации в списках var Style_Num_Def = new CStyle( "No List", null, null, styletype_Numbering ); Style_Num_Def.Create_Default_Numbering(); this.Default.Numbering = this.Add( Style_Num_Def ); // Создаем стандартные стили для заголовков var Style_H1 = new CStyle("Heading 1", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_H1.Create_Heading1(); this.Default.Headings[0] = this.Add( Style_H1 ); // Создаем стандартные стили для заголовков var Style_H2 = new CStyle("Heading 2", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_H2.Create_Heading2(); this.Default.Headings[1] = this.Add( Style_H2 ); // Создаем стандартные стили для заголовков var Style_H3 = new CStyle("Heading 3", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_H3.Create_Heading3(); this.Default.Headings[2] = this.Add( Style_H3 ); // Создаем стандартные стили для заголовков var Style_H4 = new CStyle("Heading 4", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_H4.Create_Heading4(); this.Default.Headings[3] = this.Add( Style_H4 ); // Создаем стандартные стили для заголовков var Style_H5 = new CStyle("Heading 5", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_H5.Create_Heading5(); this.Default.Headings[4] = this.Add( Style_H5 ); // Создаем стандартные стили для заголовков var Style_H6 = new CStyle("Heading 6", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_H6.Create_Heading6(); this.Default.Headings[5] = this.Add( Style_H6 ); // Создаем стандартные стили для заголовков var Style_H7 = new CStyle("Heading 7", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_H7.Create_Heading7(); this.Default.Headings[6] = this.Add( Style_H7 ); // Создаем стандартные стили для заголовков var Style_H8 = new CStyle("Heading 8", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_H8.Create_Heading8(); this.Default.Headings[7] = this.Add( Style_H8 ); // Создаем стандартные стили для заголовков var Style_H9 = new CStyle("Heading 9", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_H9.Create_Heading9(); this.Default.Headings[8] = this.Add( Style_H9 ); // Создаем стандартный стиль для нумерованных параграфов var Style_Para_List = new CStyle("List Paragraph", this.Default.Paragraph, null, styletype_Paragraph ); Style_Para_List.Create_ListParagraph(); this.Default.ParaList = this.Add( Style_Para_List ); // Создаем стандартный стиль для таблиц var Style_Table = new CStyle("Normal Table", null, null, styletype_Table ); Style_Table.Create_NormalTable(); this.Default.Table = this.Add( Style_Table ); // Создаем стиль "Без интервала" var Style_NoSpacing = new CStyle("No Spacing", null, null, styletype_Paragraph ); Style_NoSpacing.Create_NoSpacing(); this.Add( Style_NoSpacing ); // Создаем стиль "Заголовок" var Style_Title = new CStyle("Title", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_Title.Create_Title(); this.Add( Style_Title ); // Создаем стиль "Подзаголовок" var Style_Subtitle = new CStyle("Subtitle", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_Subtitle.Create_Subtitle(); this.Add( Style_Subtitle ); // Создаем стиль "Цитата" var Style_Quote = new CStyle("Quote", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_Quote.Create_Quote(); this.Add( Style_Quote ); // Создаем стиль "Выделенная цитата" var Style_IntenseQuote = new CStyle("Intense Quote", this.Default.Paragraph, this.Default.Paragraph, styletype_Paragraph ); Style_IntenseQuote.Create_IntenseQuote(); this.Add( Style_IntenseQuote ); // Создаем стандартный стиль верхнего колонтитула var Style_Header = new CStyle("Header", this.Default.Paragraph, null, styletype_Paragraph ); Style_Header.Create_Header(); this.Default.Header = this.Add( Style_Header ); // Создаем стандартный стиль нижнего колонтитула var Style_Footer = new CStyle("Footer", this.Default.Paragraph, null, styletype_Paragraph ); Style_Footer.Create_Footer(); this.Default.Footer = this.Add( Style_Footer ); // Создаем стиль для таблиц, который будет применяться к новым таблицам var Style_TableGrid = new CStyle("Table Grid", this.Default.Table, null, styletype_Table ); Style_TableGrid.Create_TableGrid(); this.Default.TableGrid = this.Add( Style_TableGrid ); /* // Создаем стандартный стиль для таблиц var Style_Table = new CStyle("LightShading", this.Default.Table, null, styletype_Table ); Style_Table.Create_Table_LightShading(); this.Add( Style_Table ); // Создаем стандартный стиль для таблиц var Style_Table = new CStyle("ColorfulListAccent6", this.Default.Table, null, styletype_Table ); Style_Table.Create_Table_ColorfulListAccent6(); this.Add( Style_Table ); */ // Стандартные стили таблиц var Style_Table_Lined = new CStyle("Lined", this.Default.Table, null, styletype_Table ); Style_Table_Lined.Create_Table_Lined( new CDocumentColor( 0xA6, 0xA6, 0xA6 ), new CDocumentColor( 0xD9, 0xD9, 0xD9 ) ); this.Add( Style_Table_Lined ); var Style_Table_Lined_Accent1 = new CStyle("Lined - Accent 1", this.Default.Table, null, styletype_Table ); Style_Table_Lined_Accent1.Create_Table_Lined( new CDocumentColor( 0x95, 0xB3, 0xD7 ), new CDocumentColor( 0xDB, 0xE5, 0xF1 ) ); this.Add( Style_Table_Lined_Accent1 ); var Style_Table_Lined_Accent2 = new CStyle("Lined - Accent 2", this.Default.Table, null, styletype_Table ); Style_Table_Lined_Accent2.Create_Table_Lined( new CDocumentColor( 0xD9, 0x95, 0x94 ), new CDocumentColor( 0xF2, 0xDB, 0xDB ) ); this.Add( Style_Table_Lined_Accent2 ); var Style_Table_Lined_Accent3 = new CStyle("Lined - Accent 3", this.Default.Table, null, styletype_Table ); Style_Table_Lined_Accent3.Create_Table_Lined( new CDocumentColor( 0xC2, 0xD6, 0x9B ), new CDocumentColor( 0xEA, 0xF1, 0xDD ) ); this.Add( Style_Table_Lined_Accent3 ); var Style_Table_Lined_Accent4 = new CStyle("Lined - Accent 4", this.Default.Table, null, styletype_Table ); Style_Table_Lined_Accent4.Create_Table_Lined( new CDocumentColor( 0xB2, 0xA1, 0xC7 ), new CDocumentColor( 0xE5, 0xDF, 0xEC ) ); this.Add( Style_Table_Lined_Accent4 ); var Style_Table_Lined_Accent5 = new CStyle("Lined - Accent 5", this.Default.Table, null, styletype_Table ); Style_Table_Lined_Accent5.Create_Table_Lined( new CDocumentColor( 0x92, 0xCD, 0xDC ), new CDocumentColor( 0xDA, 0xEE, 0xF3 ) ); this.Add( Style_Table_Lined_Accent5 ); var Style_Table_Lined_Accent6 = new CStyle("Lined - Accent 6", this.Default.Table, null, styletype_Table ); Style_Table_Lined_Accent6.Create_Table_Lined( new CDocumentColor( 0xFA, 0xBF, 0x8F ), new CDocumentColor( 0xFD, 0xE9, 0xE9 ) ); this.Add( Style_Table_Lined_Accent6 ); var Style_Table_Bordered = new CStyle("Bordered", this.Default.Table, null, styletype_Table ); Style_Table_Bordered.Create_Table_Bordered( new CDocumentColor( 0xBF, 0xBF, 0xBF ), new CDocumentColor( 0x00, 0x00, 0x00 ) ); this.Add( Style_Table_Bordered ); var Style_Table_Bordered_Accent_1 = new CStyle("Bordered - Accent 1", this.Default.Table, null, styletype_Table ); Style_Table_Bordered_Accent_1.Create_Table_Bordered( new CDocumentColor( 0xB8, 0xCC, 0xE4 ), new CDocumentColor( 0x36, 0x5F, 0x91 ) ); this.Add( Style_Table_Bordered_Accent_1 ); var Style_Table_Bordered_Accent_2 = new CStyle("Bordered - Accent 2", this.Default.Table, null, styletype_Table ); Style_Table_Bordered_Accent_2.Create_Table_Bordered( new CDocumentColor( 0xE5, 0xB8, 0xB7 ), new CDocumentColor( 0x94, 0x36, 0x34 ) ); this.Add( Style_Table_Bordered_Accent_2 ); var Style_Table_Bordered_Accent_3 = new CStyle("Bordered - Accent 3", this.Default.Table, null, styletype_Table ); Style_Table_Bordered_Accent_3.Create_Table_Bordered( new CDocumentColor( 0xD6, 0xE3, 0xBC ), new CDocumentColor( 0x76, 0x92, 0x3C ) ); this.Add( Style_Table_Bordered_Accent_3 ); var Style_Table_Bordered_Accent_4 = new CStyle("Bordered - Accent 4", this.Default.Table, null, styletype_Table ); Style_Table_Bordered_Accent_4.Create_Table_Bordered( new CDocumentColor( 0xCC, 0xC0, 0xD9 ), new CDocumentColor( 0x5F, 0x49, 0x7A ) ); this.Add( Style_Table_Bordered_Accent_4 ); var Style_Table_Bordered_Accent_5 = new CStyle("Bordered - Accent 5", this.Default.Table, null, styletype_Table ); Style_Table_Bordered_Accent_5.Create_Table_Bordered( new CDocumentColor( 0xB6, 0xDD, 0xE8 ), new CDocumentColor( 0x31, 0x84, 0x9B ) ); this.Add( Style_Table_Bordered_Accent_5 ); var Style_Table_Bordered_Accent_6 = new CStyle("Bordered - Accent 6", this.Default.Table, null, styletype_Table ); Style_Table_Bordered_Accent_6.Create_Table_Bordered( new CDocumentColor( 0xFB, 0xD4, 0xB4 ), new CDocumentColor( 0xE3, 0x6C, 0x0A ) ); this.Add( Style_Table_Bordered_Accent_6 ); var Style_Table_BorderedLined = new CStyle("Bordered & Lined", this.Default.Table, null, styletype_Table ); Style_Table_BorderedLined.Create_Table_BorderedAndLined( new CDocumentColor( 0x00, 0x00, 0x00 ), new CDocumentColor( 0xA6, 0xA6, 0xA6 ), new CDocumentColor( 0xD9, 0xD9, 0xD9 ) ); this.Add( Style_Table_BorderedLined ); var Style_Table_BorderedLined_Accent1 = new CStyle("Bordered & Lined - Accent 1", this.Default.Table, null, styletype_Table ); Style_Table_BorderedLined_Accent1.Create_Table_BorderedAndLined( new CDocumentColor( 0x17, 0x36, 0x5D ), new CDocumentColor( 0x8D, 0xB3, 0xE2 ), new CDocumentColor( 0xDB, 0xE5, 0xF1 ) ); this.Add( Style_Table_BorderedLined_Accent1 ); var Style_Table_BorderedLined_Accent2 = new CStyle("Bordered & Lined - Accent 2", this.Default.Table, null, styletype_Table ); Style_Table_BorderedLined_Accent2.Create_Table_BorderedAndLined( new CDocumentColor( 0x94, 0x36, 0x34 ), new CDocumentColor( 0xD9, 0x95, 0x94 ), new CDocumentColor( 0xF2, 0xDB, 0xDB ) ); this.Add( Style_Table_BorderedLined_Accent2 ); var Style_Table_BorderedLined_Accent3 = new CStyle("Bordered & Lined - Accent 3", this.Default.Table, null, styletype_Table ); Style_Table_BorderedLined_Accent3.Create_Table_BorderedAndLined( new CDocumentColor( 0x76, 0x92, 0x3C ), new CDocumentColor( 0xC2, 0xD6, 0x9B ), new CDocumentColor( 0xEA, 0xF1, 0xDD ) ); this.Add( Style_Table_BorderedLined_Accent3 ); var Style_Table_BorderedLined_Accent4 = new CStyle("Bordered & Lined - Accent 4", this.Default.Table, null, styletype_Table ); Style_Table_BorderedLined_Accent4.Create_Table_BorderedAndLined( new CDocumentColor( 0x5F, 0x49, 0x7A ), new CDocumentColor( 0xB2, 0xA1, 0xC7 ), new CDocumentColor( 0xE5, 0xDF, 0xEC ) ); this.Add( Style_Table_BorderedLined_Accent4 ); var Style_Table_BorderedLined_Accent5 = new CStyle("Bordered & Lined - Accent 5", this.Default.Table, null, styletype_Table ); Style_Table_BorderedLined_Accent5.Create_Table_BorderedAndLined( new CDocumentColor( 0x31, 0x84, 0x9B ), new CDocumentColor( 0x92, 0xCD, 0xDC ), new CDocumentColor( 0xDA, 0xEE, 0xF3 ) ); this.Add( Style_Table_BorderedLined_Accent5 ); var Style_Table_BorderedLined_Accent6 = new CStyle("Bordered & Lined - Accent 6", this.Default.Table, null, styletype_Table ); Style_Table_BorderedLined_Accent6.Create_Table_BorderedAndLined( new CDocumentColor( 0xE3, 0x6C, 0x0A ), new CDocumentColor( 0xFA, 0xBF, 0x8F ), new CDocumentColor( 0xFD, 0xE9, 0xD9 ) ); this.Add( Style_Table_BorderedLined_Accent6 ); // Создаем стиль гиперссылки var Style_Hyperlink = new CStyle("Hyperlink", null, null, styletype_Character ); Style_Hyperlink.Create_Character_Hyperlink(); this.Default.Hyperlink = this.Add( Style_Hyperlink ); // Добавляем данный класс в таблицу Id (обязательно в конце конструктора) g_oTableId.Add( this, this.Id ); } CStyles.prototype = { //----------------------------------------------------------------------------------- // Работаем с Id данного объекта //----------------------------------------------------------------------------------- GetId : function() { return this.Id; }, SetId : function(newId) { g_oTableId.Reset_Id( this, newId, this.Id ); this.Id = newId; }, Get_Id : function() { return this.GetId(); }, Set_Id : function(newId) { return this.SetId( newId ); }, //----------------------------------------------------------------------------------- // Базовые функции для работы со стилем //----------------------------------------------------------------------------------- Add : function(Style) { var Id = Style.Get_Id(); History.Add( this, { Type : historyitem_Styles_Add, Id : Id, Style : Style } ); this.Style[Id] = Style; return Id; }, Remove : function(Id) { History.Add( this, { Type : historyitem_Styles_Remove, Id : Id, Style : this.Style[Id] } ); delete this.Style[Id]; }, //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- Get_Pr : function(StyleId, Type, TableStyle, ShapeStyle) { var Pr = {TextPr: new CTextPr(), ParaPr: new CParaPr()}; // Сначала копируем параметры заданные в табличном стиле switch ( Type ) { case styletype_Paragraph: { if(TableStyle != null || ShapeStyle != null) { if(ShapeStyle != null) { Pr.TextPr.Merge(ShapeStyle.TextPr); Pr.ParaPr.Merge(ShapeStyle.ParaPr); } if(TableStyle != null) { Pr.TextPr.Merge(TableStyle.TextPr); Pr.ParaPr.Merge(TableStyle.ParaPr); } } else { Pr.TextPr.Merge(this.Default.TextPr); Pr.ParaPr.Merge(this.Default.ParaPr); } break; } case styletype_Table: { // Сначала копируем параметры по умолчанию Pr.TextPr = this.Default.TextPr.Copy(); Pr.ParaPr = this.Default.ParaPr.Copy(); // Наложим настройки по умолчанию для параграфа var DefId = this.Default.Paragraph; if ( undefined != DefId && null != DefId ) { Pr.ParaPr.Merge( this.Style[DefId].ParaPr ); Pr.TextPr.Merge( this.Style[DefId].TextPr ); } Pr.TablePr = this.Default.TablePr.Copy(); Pr.TableRowPr = this.Default.TableRowPr.Copy(); Pr.TableCellPr = this.Default.TableCellPr.Copy(); Pr.TableFirstCol = new CTableStylePr(); Pr.TableFirstRow = new CTableStylePr(); Pr.TableLastCol = new CTableStylePr(); Pr.TableLastRow = new CTableStylePr(); Pr.TableBand1Horz = new CTableStylePr(); Pr.TableBand1Vert = new CTableStylePr(); Pr.TableBand2Horz = new CTableStylePr(); Pr.TableBand2Vert = new CTableStylePr(); Pr.TableTLCell = new CTableStylePr(); Pr.TableTRCell = new CTableStylePr(); Pr.TableBLCell = new CTableStylePr(); Pr.TableBRCell = new CTableStylePr(); Pr.TableWholeTable = new CTableStylePr(); break; } case styletype_Character: { Pr.TextPr = new CTextPr(); /* if ( null != TableStyle ) Pr.TextPr = TableStyle.TextPr.Copy(); else Pr.TextPr = this.Default.TextPr.Copy(); */ break; } } // Рассчитываем стиль this.Internal_Get_Pr( Pr, StyleId, Type, ( null === TableStyle && null == ShapeStyle ? true : false ) ); if ( styletype_Table === Type ) { // Кроме того настройки для параграфа и текста, дополняются дефолтовыми настройками параграфа var DefParaId = this.Default.Paragraph; Pr.ParaPr.Merge( this.Style[DefParaId].ParaPr ); Pr.TextPr.Merge( this.Style[DefParaId].TextPr ); // Соединим настройки для всей таблицы в одну общую настройку и удалим одну из них за ненадобностью Pr.ParaPr.Merge( Pr.TableWholeTable.ParaPr ); Pr.TextPr.Merge( Pr.TableWholeTable.TextPr ); Pr.TablePr.Merge( Pr.TableWholeTable.TablePr ); Pr.TableRowPr.Merge( Pr.TableWholeTable.TableRowPr ); Pr.TableCellPr.Merge( Pr.TableWholeTable.TableCellPr ); delete Pr.TableWholeTable; } return Pr; }, Get_Next : function(StyleId) { var NextId = this.Style[StyleId].Next; if (null !== NextId && undefined !== this.Style[NextId]) return NextId; return null; }, Get_Name : function(StyleId) { if ( undefined != this.Style[StyleId] ) return this.Style[StyleId].Name; return ""; }, Get_Default_Paragraph : function() { return this.Default.Paragraph; }, Get_Default_Character : function() { return this.Default.Character; }, Get_Default_Numbering : function() { return this.Default.Numbering; }, Get_Default_Table : function() { return this.Default.Table; }, Get_Default_TableGrid : function() { return this.Default.TableGrid; }, Get_Default_Heading : function(Lvl) { Lvl = Math.max( Math.min( Lvl, 8 ), 0 ); return this.Default.Headings[Lvl]; }, Get_Default_ParaList : function() { return this.Default.ParaList; }, Get_Default_Header : function() { return this.Default.Header; }, Get_Default_Footer : function() { return this.Default.Footer; }, Get_Default_Hyperlink : function() { return this.Default.Hyperlink; }, Get_StyleIdByName : function (Name) { for ( var Id in this.Style ) { var Style = this.Style[Id]; if ( Style.Name === Name ) return Id; } return this.Default.Paragraph; }, Internal_Get_Pr : function(Pr, StyleId, Type, bUseDefault) { var Style = this.Style[StyleId]; if ( undefined == StyleId || undefined === Style ) { if ( true === bUseDefault ) { // Копируем свойства по умолчанию для данного типа switch ( Type ) { case styletype_Paragraph: { var DefId = this.Default.Paragraph; Pr.ParaPr.Merge( this.Style[DefId].ParaPr ); Pr.TextPr.Merge( this.Style[DefId].TextPr ); break; } case styletype_Numbering: { var DefId = this.Default.Numbering; break; } case styletype_Table: { var DefId = this.Default.Table; Pr.ParaPr.Merge( this.Style[DefId].ParaPr ); Pr.TextPr.Merge( this.Style[DefId].TextPr ); Pr.TablePr.Merge( this.Styles[DefId].TablePr ); Pr.TableRowPr.Merge( this.Styles[DefId].TableRowPr ); Pr.TableCellPr.Merge( this.Styles[DefId].TableCellPr ); break; } case styletype_Character: { var DefId = this.Default.Character; Pr.TextPr.Merge( this.Style[DefId].TextPr ); break; } } } return; } if ( null === Style.BasedOn ) { // TODO: Проверить нужно ли копировать стили по умолчанию для данного типа стиля, когда сам стиль задан // Для параграфа, вроде как не нужно (см. ivanova_veronica.docx стиль "Colon") // Копируем свойства по умолчанию для данного типа if ( true === bUseDefault ) { // Копируем свойства по умолчанию для данного типа switch ( Type ) { case styletype_Paragraph: { // var DefId = this.Default.Paragraph; // // Pr.ParaPr.Merge( this.Style[DefId].ParaPr ); // Pr.TextPr.Merge( this.Style[DefId].TextPr ); break; } case styletype_Numbering: { var DefId = this.Default.Numbering; break; } case styletype_Table: { var DefId = this.Default.Table; /* Pr.ParaPr.Merge( this.Style[DefId].ParaPr ); Pr.TextPr.Merge( this.Style[DefId].TextPr ); Pr.TablePr.Merge( this.Styles[DefId].TablePr ); Pr.TableRowPr.Merge( this.Styles[DefId].TableRowPr ); Pr.TableCellPr.Merge( this.Styles[DefId].TableCellPr ); */ break; } case styletype_Character: { var DefId = this.Default.Character; Pr.TextPr.Merge( this.Style[DefId].TextPr ); break; } } } // Копируем свойства текущего стиля switch ( Type ) { case styletype_Paragraph: { Pr.ParaPr.Merge( Style.ParaPr ); Pr.TextPr.Merge( Style.TextPr ); break; } case styletype_Numbering: { break; } case styletype_Table: { Pr.ParaPr.Merge( Style.ParaPr ); Pr.TextPr.Merge( Style.TextPr ); // Заглушка на случай, если в табличные стили начнут объединять с не табличными стилями if ( undefined != Style.TablePr ) { Pr.TablePr.Merge( Style.TablePr ); Pr.TableRowPr.Merge( Style.TableRowPr ); Pr.TableCellPr.Merge( Style.TableCellPr ); Pr.TableBand1Horz.Merge( Style.TableBand1Horz ); Pr.TableBand1Vert.Merge( Style.TableBand1Vert ); Pr.TableBand2Horz.Merge( Style.TableBand2Horz ); Pr.TableBand2Vert.Merge( Style.TableBand2Vert ); Pr.TableFirstCol.Merge( Style.TableFirstCol ); Pr.TableFirstRow.Merge( Style.TableFirstRow ); Pr.TableLastCol.Merge( Style.TableLastCol ); Pr.TableLastRow.Merge( Style.TableLastRow ); Pr.TableTLCell.Merge( Style.TableTLCell ); Pr.TableTRCell.Merge( Style.TableTRCell ); Pr.TableBLCell.Merge( Style.TableBLCell ); Pr.TableBRCell.Merge( Style.TableBRCell ); Pr.TableWholeTable.Merge( Style.TableWholeTable ); } break; } case styletype_Character: { Pr.TextPr.Merge( Style.TextPr ); break; } } } else { // Копируем свойства родительского стиля this.Internal_Get_Pr( Pr, Style.BasedOn, Type ); // Копируем свойства из стиля нумерации, если она задана if ( (styletype_Paragraph === Type || styletype_Table === Type) && ( undefined != Style.ParaPr.NumPr ) ) { var Numbering = editor.WordControl.m_oLogicDocument.Get_Numbering(); if ( undefined != Style.ParaPr.NumPr.NumId && 0 != Style.ParaPr.NumPr.NumId ) { var AbstractNum = Numbering.Get_AbstractNum( Style.ParaPr.NumPr.NumId ); var Lvl = AbstractNum.Get_LvlByStyle( StyleId ); if ( -1 != Lvl ) Pr.ParaPr.Merge( Numbering.Get_ParaPr( Style.ParaPr.NumPr.NumId, Lvl ) ); else Pr.ParaPr.NumPr = undefined; } } // Копируем свойства текущего стиля switch ( Type ) { case styletype_Paragraph: { Pr.ParaPr.Merge( Style.ParaPr ); Pr.TextPr.Merge( Style.TextPr ); break; } case styletype_Numbering: { break; } case styletype_Table: { Pr.ParaPr.Merge( Style.ParaPr ); Pr.TextPr.Merge( Style.TextPr ); if ( undefined != Style.TablePr ) { Pr.TablePr.Merge( Style.TablePr ); Pr.TableRowPr.Merge( Style.TableRowPr ); Pr.TableCellPr.Merge( Style.TableCellPr ); Pr.TableBand1Horz.Merge( Style.TableBand1Horz ); Pr.TableBand1Vert.Merge( Style.TableBand1Vert ); Pr.TableBand2Horz.Merge( Style.TableBand2Horz ); Pr.TableBand2Vert.Merge( Style.TableBand2Vert ); Pr.TableFirstCol.Merge( Style.TableFirstCol ); Pr.TableFirstRow.Merge( Style.TableFirstRow ); Pr.TableLastCol.Merge( Style.TableLastCol ); Pr.TableLastRow.Merge( Style.TableLastRow ); Pr.TableTLCell.Merge( Style.TableTLCell ); Pr.TableTRCell.Merge( Style.TableTRCell ); Pr.TableBLCell.Merge( Style.TableBLCell ); Pr.TableBRCell.Merge( Style.TableBRCell ); Pr.TableWholeTable.Merge( Style.TableWholeTable ); } break; } case styletype_Character: { Pr.TextPr.Merge( Style.TextPr ); break; } } } }, Document_Get_AllFontNames : function(AllFonts) { for ( var Id in this.Style ) { var Style = this.Style[Id]; Style.Document_Get_AllFontNames(AllFonts); } this.Default.TextPr.Document_Get_AllFontNames(AllFonts); }, Get_AllTableStyles : function() { var TableStyles = []; for ( var Id in this.Style ) { var Style = this.Style[Id]; if ( styletype_Table === Style.Type ) TableStyles.push( Id ); } return TableStyles; }, //----------------------------------------------------------------------------------- // Undo/Redo функции //----------------------------------------------------------------------------------- Undo : function(Data) { var Type = Data.Type; switch ( Type ) { case historyitem_Styles_Add: { delete this.Style[Data.Id]; break; } case historyitem_Styles_Remove: { this.Style[Data.Id] = Data.Style; break; } } }, Redo : function(Data) { var Type = Data.Type; switch ( Type ) { case historyitem_Styles_Add: { this.Style[Data.Id] = Data.Style; break; } case historyitem_Styles_Remove: { delete this.Style[Data.Id]; break; } } }, Get_SelectionState : function() { }, Set_SelectionState : function(State, StateIndex) { }, Get_ParentObject_or_DocumentPos : function() { return { Type : historyrecalctype_Inline, Data : 0 }; }, Refresh_RecalcData : function(Data) { var Type = Data.Type; var bNeedRecalc = false; switch ( Type ) { case historyitem_Style_TextPr : case historyitem_Style_ParaPr : case historyitem_Style_TablePr : case historyitem_Style_TableRowPr : case historyitem_Style_TableCellPr : case historyitem_Style_TableBand1Horz : case historyitem_Style_TableBand1Vert : case historyitem_Style_TableBand2Horz : case historyitem_Style_TableBand2Vert : case historyitem_Style_TableFirstCol : case historyitem_Style_TableFirstRow : case historyitem_Style_TableLastCol : case historyitem_Style_TableLastRow : case historyitem_Style_TableTLCell : case historyitem_Style_TableTRCell : case historyitem_Style_TableBLCell : case historyitem_Style_TableBRCell : case historyitem_Style_TableWholeTable : case historyitem_Style_Name : case historyitem_Style_BasedOn : case historyitem_Style_Next : case historyitem_Style_Type : case historyitem_Style_QFormat : case historyitem_Style_UiPriority : case historyitem_Style_Hidden : case historyitem_Style_SemiHidden : case historyitem_Style_UnhideWhenUsed : { break; } } if ( true === bNeedRecalc ) { // Сообщаем родительскому классу, что изменения произошли в элементе с номером this.Index и на странице this.PageNum return this.Refresh_RecalcData2(); } }, Refresh_RecalcData2 : function() { //editor.WordControl.m_oLogicDocument.Refresh_RecalcData2( 0, 0 ); }, //----------------------------------------------------------------------------------- // Функции для совместного редактирования //----------------------------------------------------------------------------------- Document_Is_SelectionLocked : function(CheckType) { switch ( CheckType ) { case changestype_Paragraph_Content: case changestype_Paragraph_Properties: case changestype_Document_Content: case changestype_Document_Content_Add: case changestype_Image_Properties: case changestype_Remove: case changestype_Delete: case changestype_Document_SectPr: case changestype_Table_Properties: case changestype_Table_RemoveCells: case changestype_HdrFtr: { CollaborativeEditing.Add_CheckLock(true); break; } } }, Save_Changes : function(Data, Writer) { // Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл. // Long : тип класса // Long : тип изменений Writer.WriteLong( historyitem_type_Styles ); var Type = Data.Type; // Пишем тип Writer.WriteLong( Type ); switch ( Type ) { case historyitem_Styles_Add: case historyitem_Styles_Remove: { // String : Id стиля Writer.WriteString2( Data.Id ); break; } } return Writer; }, Load_Changes : function(Reader) { // Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл. // Long : тип класса // Long : тип изменений var ClassType = Reader.GetLong(); if ( historyitem_type_Styles != ClassType ) return; var Type = Reader.GetLong(); switch ( Type ) { case historyitem_Styles_Add: { // String : Id стиля // Спокойно добавляем стиль по Id, т.к. сначала стиль создается и только // потом он добавляется в список стилей. var Id = Reader.GetString2(); this.Style[Id] = g_oTableId.Get_ById( Id ); break; } case historyitem_Styles_Remove: { // String : Id стиля var Id = Reader.GetString2(); delete this.Style[Id]; break; } } } }; function CDocumentColor(r,g,b, Auto) { this.r = r; this.g = g; this.b = b; this.Auto = ( Auto === undefined ? false : Auto ); } CDocumentColor.prototype = { Copy : function() { return new CDocumentColor(this.r, this.g, this.b, this.Auto); }, Write_ToBinary : function(Writer) { // Byte : r // Byte : g // Byte : b // Bool : Auto Writer.WriteByte( this.r ); Writer.WriteByte( this.g ); Writer.WriteByte( this.b ); Writer.WriteBool( this.Auto ); }, Read_FromBinary : function(Reader) { // Byte : r // Byte : g // Byte : b // Bool : Auto this.r = Reader.GetByte(); this.g = Reader.GetByte(); this.b = Reader.GetByte(); this.Auto = Reader.GetBool(); }, Set : function(r, g, b, Auto) { this.r = r; this.g = g; this.b = b; this.Auto = ( Auto === undefined ? false : Auto ); }, Compare : function(Color) { if ( this.r === Color.r && this.g === Color.g && this.b === Color.b && ( this.Auto === Color.Auto || ( false === this.Auto && Color.Auto === undefined ) ) ) return true; return false; }, Check_BlackAutoColor : function() { // TODO: Коэффициенты подобраны опытным путем. В некоторых "пограничных" случаях // может быть несовпадение с Word (когда изменение на 1 одного из каналов // меняет цвет), чтобы такого не было надо более точно подобрать коэффициенты. if ( 0.5 * this.r + this.g + 0.195 * this.b < 103 ) return false; return true; } }; function CDocumentShd() { this.Value = shd_Nil; this.Color = new CDocumentColor(255, 255, 255); this.Unifill = undefined; this.FillRef = undefined; }; CDocumentShd.prototype = { Copy : function() { var Shd = new CDocumentShd(); Shd.Value = this.Value; if ( undefined !== this.Color ) Shd.Color.Set( this.Color.r, this.Color.g, this.Color.b, this.Color.Auto ); if( undefined !== this.Unifill ) Shd.Unifill = this.Unifill.createDuplicate(); if( undefined !== this.FillRef ) Shd.FillRef = this.FillRef.createDuplicate(); return Shd; }, Compare : function(Shd) { if ( undefined === Shd ) return false; if ( this.Value === Shd.Value ) { switch ( this.Value ) { case shd_Nil: return true; case shd_Clear: { return this.Color.Compare( Shd.Color ) && CompareUnifillBool(this.Unifill, Shd.Unifill); } } } return false; }, Get_Color : function(Paragraph) { if ( undefined !== this.Unifill ) { this.Unifill.check(Paragraph.Get_Theme(), Paragraph.Get_ColorMap()); var RGBA = this.Unifill.getRGBAColor(); return new CDocumentColor( RGBA.R, RGBA.G, RGBA.B, false ); } else return this.Color; }, Get_Color2 : function(Theme, ColorMap) { if ( undefined !== this.Unifill ) { this.Unifill.check(Theme, ColorMap); var RGBA = this.Unifill.getRGBAColor(); return new CDocumentColor( RGBA.R, RGBA.G, RGBA.B, false ); } else return this.Color; }, Get_Color3 : function(Theme, ColorMap) { if ( undefined !== this.Unifill ) { this.Unifill.check(Theme, ColorMap); return this.Unifill.getRGBAColor(); } else { return {R: 255, G: 255, B: 255, A: 255}; } }, Init_Default : function() { this.Value = shd_Nil; this.Color.Set( 0, 0, 0, false ); this.Unifill = undefined; this.FillRef = undefined; }, Set_FromObject : function(Shd) { if ( undefined === Shd ) { this.Value = shd_Nil; return; } this.Value = Shd.Value; if ( shd_Nil != Shd.Value ) { if( undefined != Shd.Color ) this.Color.Set( Shd.Color.r, Shd.Color.g, Shd.Color.b ); if(undefined != Shd.Unifill) { this.Unifill = Shd.Unifill.createDuplicate(); } if(undefined != Shd.FillRef) { this.FillRef = Shd.FillRef.createDuplicate(); } } else if ( undefined === Shd.Color ) this.Color = undefined; }, Check_PresentationPr : function(Theme) { if(this.FillRef) { this.Unifill = Theme.getFillStyle(this.FillRef.idx); this.FillRef = undefined; } }, Write_ToBinary : function(Writer) { // Byte : Value // // Если shd_Clear // Variable : Color Writer.WriteByte( this.Value ); if ( shd_Clear === this.Value ) { this.Color.Write_ToBinary(Writer); if(this.Unifill) { Writer.WriteBool(true); this.Unifill.Write_ToBinary(Writer); } else { Writer.WriteBool(false); } if(this.FillRef) { Writer.WriteBool(true); this.FillRef.Write_ToBinary(Writer); } else { Writer.WriteBool(false); } } }, Read_FromBinary : function(Reader) { // Byte : Value // // Если shd_Clear // Variable : Color this.Value = Reader.GetByte(); if ( shd_Clear === this.Value ) { this.Color.Read_FromBinary(Reader); if(Reader.GetBool()) { this.Unifill = new CUniFill(); this.Unifill.Read_FromBinary(Reader); } if(Reader.GetBool()) { this.FillRef = new StyleRef(); this.FillRef.Read_FromBinary(Reader); } } else this.Color.Set(0, 0, 0); } }; function CDocumentBorder() { this.Color = new CDocumentColor( 0, 0, 0 ); this.Unifill = undefined; this.LineRef = undefined; this.Space = 0; this.Size = 0.5 * g_dKoef_pt_to_mm; this.Value = border_None; } CDocumentBorder.prototype = { Copy : function() { var Border = new CDocumentBorder(); if ( undefined === this.Color ) Border.Color = undefined; else Border.Color.Set(this.Color.r, this.Color.g, this.Color.b); if(undefined === this.Unifill) Border.Unifill = undefined; else Border.Unifill = this.Unifill.createDuplicate(); if(undefined === this.LineRef) { Border.LineRef = undefined; } else { Border.LineRef = this.LineRef.createDuplicate(); } if ( undefined === this.Space ) Border.Space = undefined; else Border.Space = this.Space; if ( undefined === this.Size ) Border.Size = undefined; else Border.Size = this.Size; if ( undefined === this.Value ) Border.Value = undefined; else Border.Value = this.Value; return Border; }, Compare : function(Border) { if ( false === this.Color.Compare(Border.Color) ) return false; if(CompareUnifillBool(this.Unifill, Border.Unifill) === false) return false; if(this.LineRef !== undefined && Border.LineRef === undefined || Border.LineRef !== undefined && this.LineRef === undefined) return false; if(this.LineRef !== undefined && !this.LineRef.compare(Border.LineRef)) { return false; } if ( Math.abs( this.Size - Border.Size ) > 0.001 ) return false; if ( Math.abs( this.Space - Border.Space ) > 0.001 ) return false; if ( this.Value != Border.Value ) return false; return true; }, Get_Color : function(Paragraph) { if ( undefined !== this.Unifill ) { this.Unifill.check(Paragraph.Get_Theme(), Paragraph.Get_ColorMap()); var RGBA = this.Unifill.getRGBAColor(); return new CDocumentColor( RGBA.R, RGBA.G, RGBA.B, false ); } else return this.Color; }, Get_Color2 : function(Theme, ColorMap) { if ( undefined !== this.Unifill ) { this.Unifill.check(Theme, ColorMap); var RGBA = this.Unifill.getRGBAColor(); return new CDocumentColor( RGBA.R, RGBA.G, RGBA.B, false ); } else return this.Color; }, Check_PresentationPr : function(Theme) { if(this.LineRef) { var pen = Theme.getLnStyle(this.LineRef.idx); this.Size = isRealNumber(pen.w) ? pen.w / 36000 : 12700 /36000; this.Unifill = pen.Fill; this.LineRef = undefined; } }, Set_FromObject : function(Border) { this.Space = Border.Space; this.Size = Border.Size; this.Value = Border.Value; if ( undefined != Border.Color ) this.Color = new CDocumentColor( Border.Color.r, Border.Color.g, Border.Color.b ); else this.Color = undefined; if(undefined != Border.Unifill) { this.Unifill = Border.Unifill.createDuplicate(); } if(undefined != Border.LineRef) { this.LineRef = Border.LineRef.createDuplicate(); } }, Check_Null : function() { if ( undefined === this.Space || undefined === this.Size || undefined === this.Value || undefined === this.Color || undefined === this.Unifill || undefined === this.LineRef) return false; return true; }, Write_ToBinary : function(Writer) { // Double : Size // Long : Space // Byte : Value // Variable : Color Writer.WriteDouble( this.Size ); Writer.WriteLong( this.Space ); Writer.WriteByte( this.Value ); this.Color.Write_ToBinary( Writer ); if(this.Unifill) { Writer.WriteBool(true); this.Unifill.Write_ToBinary(Writer); } else { Writer.WriteBool(false); } if(this.LineRef) { Writer.WriteBool(true); this.LineRef.Write_ToBinary(Writer); } else { Writer.WriteBool(false); } }, Read_FromBinary : function(Reader) { // Double : Size // Long : Space // Byte : Value // Variable : Color this.Size = Reader.GetDouble(); this.Space = Reader.GetLong(); this.Value = Reader.GetByte(); this.Color.Read_FromBinary( Reader ); if(Reader.GetBool()) { this.Unifill = new CUniFill(); this.Unifill.Read_FromBinary(Reader); } if(Reader.GetBool()) { this.LineRef = new StyleRef(); this.LineRef.Read_FromBinary(Reader); } } }; function CTableMeasurement(Type, W) { this.Type = Type; this.W = W; } CTableMeasurement.prototype = { Copy : function() { return new CTableMeasurement(this.Type, this.W); }, Write_ToBinary : function(Writer) { // Double : W // Long : Type Writer.WriteDouble( this.W ); Writer.WriteLong( this.Type ); }, Read_FromBinary : function(Reader) { // Double : W // Long : Type this.W = Reader.GetDouble(); this.Type = Reader.GetLong(); }, Set_FromObject : function(Obj) { this.W = Obj.W; this.Type = Obj.Type; } } function CTablePr() { this.TableStyleColBandSize = undefined; this.TableStyleRowBandSize = undefined; this.Jc = undefined; this.Shd = undefined; this.TableBorders = { Bottom : undefined, Left : undefined, Right : undefined, Top : undefined, InsideH : undefined, InsideV : undefined }; this.TableCellMar = { Bottom : undefined, Left : undefined, Right : undefined, Top : undefined }; this.TableCellSpacing = undefined; this.TableInd = undefined; this.TableW = undefined; this.TableLayout = undefined; } CTablePr.prototype = { Copy : function() { var TablePr = new CTablePr(); TablePr.TableStyleColBandSize = this.TableStyleColBandSize; TablePr.TableStyleRowBandSize = this.TableStyleRowBandSize; TablePr.Jc = this.Jc; if ( undefined != this.Shd ) TablePr.Shd = this.Shd.Copy(); // TableBorders if ( undefined != this.TableBorders.Bottom ) TablePr.TableBorders.Bottom = this.TableBorders.Bottom.Copy(); if ( undefined != this.TableBorders.Left ) TablePr.TableBorders.Left = this.TableBorders.Left.Copy(); if ( undefined != this.TableBorders.Right ) TablePr.TableBorders.Right = this.TableBorders.Right.Copy(); if ( undefined != this.TableBorders.Top ) TablePr.TableBorders.Top = this.TableBorders.Top.Copy(); if ( undefined != this.TableBorders.InsideH ) TablePr.TableBorders.InsideH = this.TableBorders.InsideH.Copy(); if ( undefined != this.TableBorders.InsideV ) TablePr.TableBorders.InsideV = this.TableBorders.InsideV.Copy(); // TableCellMar if ( undefined != this.TableCellMar.Bottom ) TablePr.TableCellMar.Bottom = this.TableCellMar.Bottom.Copy(); if ( undefined != this.TableCellMar.Left ) TablePr.TableCellMar.Left = this.TableCellMar.Left.Copy(); if ( undefined != this.TableCellMar.Right ) TablePr.TableCellMar.Right = this.TableCellMar.Right.Copy(); if ( undefined != this.TableCellMar.Top ) TablePr.TableCellMar.Top = this.TableCellMar.Top.Copy(); TablePr.TableCellSpacing = this.TableCellSpacing; TablePr.TableInd = this.TableInd; if ( undefined != this.TableW ) TablePr.TableW = this.TableW.Copy(); TablePr.TableLayout = this.TableLayout; return TablePr; }, Merge : function(TablePr) { if ( undefined != TablePr.TableStyleColBandSize ) this.TableStyleColBandSize = TablePr.TableStyleColBandSize; if ( undefined != TablePr.TableStyleRowBandSize ) this.TableStyleRowBandSize = TablePr.TableStyleRowBandSize; if ( undefined != TablePr.Jc ) this.Jc = TablePr.Jc; if ( undefined != TablePr.Shd ) this.Shd = TablePr.Shd.Copy(); // TableBorders if ( undefined != TablePr.TableBorders.Bottom ) this.TableBorders.Bottom = TablePr.TableBorders.Bottom.Copy(); if ( undefined != TablePr.TableBorders.Left ) this.TableBorders.Left = TablePr.TableBorders.Left.Copy(); if ( undefined != TablePr.TableBorders.Right ) this.TableBorders.Right = TablePr.TableBorders.Right.Copy(); if ( undefined != TablePr.TableBorders.Top ) this.TableBorders.Top = TablePr.TableBorders.Top.Copy(); if ( undefined != TablePr.TableBorders.InsideH ) this.TableBorders.InsideH = TablePr.TableBorders.InsideH.Copy(); if ( undefined != TablePr.TableBorders.InsideV ) this.TableBorders.InsideV = TablePr.TableBorders.InsideV.Copy(); // TableCellMar if ( undefined != TablePr.TableCellMar.Bottom ) this.TableCellMar.Bottom = TablePr.TableCellMar.Bottom.Copy(); if ( undefined != TablePr.TableCellMar.Left ) this.TableCellMar.Left = TablePr.TableCellMar.Left.Copy(); if ( undefined != TablePr.TableCellMar.Right ) this.TableCellMar.Right = TablePr.TableCellMar.Right.Copy(); if ( undefined != TablePr.TableCellMar.Top ) this.TableCellMar.Top = TablePr.TableCellMar.Top.Copy(); if ( undefined != TablePr.TableCellMar ) this.TableCellSpacing = TablePr.TableCellSpacing; if ( undefined != TablePr.TableInd ) this.TableInd = TablePr.TableInd; if ( undefined != TablePr.TableW ) this.TableW = TablePr.TableW.Copy(); if ( undefined != TablePr.TableLayout ) this.TableLayout = TablePr.TableLayout; }, Init_Default : function() { this.TableStyleColBandSize = 1; this.TableStyleRowBandSize = 1; this.Jc = align_Left; this.Shd = new CDocumentShd(); this.TableBorders.Bottom = new CDocumentBorder(); this.TableBorders.Left = new CDocumentBorder(); this.TableBorders.Right = new CDocumentBorder(); this.TableBorders.Top = new CDocumentBorder(); this.TableBorders.InsideH = new CDocumentBorder(); this.TableBorders.InsideV = new CDocumentBorder(); this.TableCellMar.Bottom = new CTableMeasurement(tblwidth_Mm, 0); this.TableCellMar.Left = new CTableMeasurement(tblwidth_Mm, 1.9/*5.4 * g_dKoef_pt_to_mm*/); // 5.4pt this.TableCellMar.Right = new CTableMeasurement(tblwidth_Mm, 1.9/*5.4 * g_dKoef_pt_to_mm*/); // 5.4pt this.TableCellMar.Top = new CTableMeasurement(tblwidth_Mm, 0); this.TableCellSpacing = null; this.TableInd = 0; this.TableW = new CTableMeasurement(tblwidth_Auto, 0); this.TableLayout = tbllayout_AutoFit; }, Set_FromObject : function(TablePr) { this.TableStyleColBandSize = TablePr.TableStyleColBandSize; this.TableStyleRowBandSize = TablePr.TableStyleRowBandSize; this.Jc = TablePr.Jc; if ( undefined != TablePr.Shd ) { this.Shd = new CDocumentShd(); this.Shd.Set_FromObject(TablePr.Shd); } else this.Shd = undefined; if ( undefined != TablePr.TableBorders ) { if ( undefined != TablePr.TableBorders.Bottom ) { this.TableBorders.Bottom = new CDocumentBorder(); this.TableBorders.Bottom.Set_FromObject( TablePr.TableBorders.Bottom ); } else this.TableBorders.Bottom = undefined; if ( undefined != TablePr.TableBorders.Left ) { this.TableBorders.Left = new CDocumentBorder(); this.TableBorders.Left.Set_FromObject( TablePr.TableBorders.Left ); } else this.TableBorders.Left = undefined; if ( undefined != TablePr.TableBorders.Right ) { this.TableBorders.Right = new CDocumentBorder(); this.TableBorders.Right.Set_FromObject( TablePr.TableBorders.Right ); } else this.TableBorders.Right = undefined; if ( undefined != TablePr.TableBorders.Top ) { this.TableBorders.Top = new CDocumentBorder(); this.TableBorders.Top.Set_FromObject( TablePr.TableBorders.Top ); } else this.TableBorders.Top = undefined; if ( undefined != TablePr.TableBorders.InsideH ) { this.TableBorders.InsideH = new CDocumentBorder(); this.TableBorders.InsideH.Set_FromObject( TablePr.TableBorders.InsideH ); } else this.TableBorders.InsideH = undefined; if ( undefined != TablePr.TableBorders.InsideV ) { this.TableBorders.InsideV = new CDocumentBorder(); this.TableBorders.InsideV.Set_FromObject( TablePr.TableBorders.InsideV ); } else this.TableBorders.InsideV = undefined; } else { this.TableBorders.Bottom = undefined; this.TableBorders.Left = undefined; this.TableBorders.Right = undefined; this.TableBorders.Top = undefined; this.TableBorders.InsideH = undefined; this.TableBorders.InsideV = undefined; } if ( undefined != TablePr.TableCellMar ) { if ( undefined != TablePr.TableCellMar.Bottom ) this.TableCellMar.Bottom = new CTableMeasurement( TablePr.TableCellMar.Bottom.Type, TablePr.TableCellMar.Bottom.W ); else this.TableCellMar.Bottom = undefined; if ( undefined != TablePr.TableCellMar.Left ) this.TableCellMar.Left = new CTableMeasurement( TablePr.TableCellMar.Left.Type, TablePr.TableCellMar.Left.W ); else this.TableCellMar.Left = undefined; if ( undefined != TablePr.TableCellMar.Right ) this.TableCellMar.Right = new CTableMeasurement( TablePr.TableCellMar.Right.Type, TablePr.TableCellMar.Right.W ); else this.TableCellMar.Right = undefined; if ( undefined != TablePr.TableCellMar.Top ) this.TableCellMar.Top = new CTableMeasurement( TablePr.TableCellMar.Top.Type, TablePr.TableCellMar.Top.W ); else this.TableCellMar.Top = undefined; } else { this.TableCellMar.Bottom = undefined; this.TableCellMar.Left = undefined; this.TableCellMar.Right = undefined; this.TableCellMar.Top = undefined; } this.TableCellSpacing = TablePr.TableCellSpacing; this.TableInd = TablePr.TableInd; if ( undefined != TablePr.TableW ) this.TableW = new CTableMeasurement( TablePr.TableW.Type, TablePr.TableW.W ); else this.TableW = undefined; this.TableLayout = TablePr.TableLayout; }, Write_ToBinary : function(Writer) { var StartPos = Writer.GetCurPosition(); Writer.Skip(4); var Flags = 0; if ( undefined != this.TableStyleColBandSize ) { Writer.WriteLong( this.TableStyleColBandSize ); Flags |= 1; } if ( undefined != this.TableStyleRowBandSize ) { Writer.WriteLong( this.TableStyleRowBandSize ); Flags |= 2; } if ( undefined != this.Jc ) { Writer.WriteLong( this.Jc ); Flags |= 4; } if ( undefined != this.Shd ) { this.Shd.Write_ToBinary( Writer ); Flags |= 8; } if ( undefined != this.TableBorders.Bottom ) { this.TableBorders.Bottom.Write_ToBinary( Writer ); Flags |= 16; } if ( undefined != this.TableBorders.Left ) { this.TableBorders.Left.Write_ToBinary( Writer ); Flags |= 32; } if ( undefined != this.TableBorders.Right ) { this.TableBorders.Right.Write_ToBinary( Writer ); Flags |= 64; } if ( undefined != this.TableBorders.Top ) { this.TableBorders.Top.Write_ToBinary( Writer ); Flags |= 128; } if ( undefined != this.TableBorders.InsideH ) { this.TableBorders.InsideH.Write_ToBinary( Writer ); Flags |= 256; } if ( undefined != this.TableBorders.InsideV ) { this.TableBorders.InsideV.Write_ToBinary( Writer ); Flags |= 512; } if ( undefined != this.TableCellMar.Bottom ) { this.TableCellMar.Bottom.Write_ToBinary( Writer ); Flags |= 1024; } if ( undefined != this.TableCellMar.Left ) { this.TableCellMar.Left.Write_ToBinary( Writer ); Flags |= 2048; } if ( undefined != this.TableCellMar.Right ) { this.TableCellMar.Right.Write_ToBinary( Writer ); Flags |= 4096; } if ( undefined != this.TableCellMar.Top ) { this.TableCellMar.Top.Write_ToBinary( Writer ); Flags |= 8192; } if ( undefined != this.TableCellSpacing ) { if ( null === this.TableCellSpacing ) Writer.WriteBool(true); else { Writer.WriteBool(false); Writer.WriteDouble(this.TableCellSpacing); } Flags |= 16384; } if ( undefined != this.TableInd ) { Writer.WriteDouble(this.TableInd); Flags |= 32768; } if ( undefined != this.TableW ) { this.TableW.Write_ToBinary( Writer ); Flags |= 65536; } if ( undefined != this.TableLayout ) { Writer.WriteLong( this.TableLayout ); Flags |= 131072; } var EndPos = Writer.GetCurPosition(); Writer.Seek( StartPos ); Writer.WriteLong( Flags ); Writer.Seek( EndPos ); }, Read_FromBinary : function(Reader) { var Flags = Reader.GetLong(); if ( 1 & Flags ) this.TableStyleColBandSize = Reader.GetLong(); if ( 2 & Flags ) this.TableStyleRowBandSize = Reader.GetLong(); if ( 4 & Flags ) this.Jc = Reader.GetLong(); if ( 8 & Flags ) { this.Shd = new CDocumentShd(); this.Shd.Read_FromBinary(Reader); } if ( 16 & Flags ) { this.TableBorders.Bottom = new CDocumentBorder(); this.TableBorders.Bottom.Read_FromBinary( Reader ); } if ( 32 & Flags ) { this.TableBorders.Left = new CDocumentBorder(); this.TableBorders.Left.Read_FromBinary( Reader ); } if ( 64 & Flags ) { this.TableBorders.Right = new CDocumentBorder(); this.TableBorders.Right.Read_FromBinary( Reader ); } if ( 128 & Flags ) { this.TableBorders.Top = new CDocumentBorder(); this.TableBorders.Top.Read_FromBinary( Reader ); } if ( 256 & Flags ) { this.TableBorders.InsideH = new CDocumentBorder(); this.TableBorders.InsideH.Read_FromBinary( Reader ); } if ( 512 & Flags ) { this.TableBorders.InsideV = new CDocumentBorder(); this.TableBorders.InsideV.Read_FromBinary( Reader ); } if ( 1024 & Flags ) { this.TableCellMar.Bottom = new CTableMeasurement(tblwidth_Auto, 0); this.TableCellMar.Bottom.Read_FromBinary(Reader); } if ( 2048 & Flags ) { this.TableCellMar.Left = new CTableMeasurement(tblwidth_Auto, 0); this.TableCellMar.Left.Read_FromBinary(Reader); } if ( 4096 & Flags ) { this.TableCellMar.Right = new CTableMeasurement(tblwidth_Auto, 0); this.TableCellMar.Right.Read_FromBinary(Reader); } if ( 8192 & Flags ) { this.TableCellMar.Top = new CTableMeasurement(tblwidth_Auto, 0); this.TableCellMar.Top.Read_FromBinary(Reader); } if ( 16384 & Flags ) { if ( true === Reader.GetBool() ) this.TableCellSpacing = null; else this.TableCellSpacing = Reader.GetDouble() } if ( 32768 & Flags ) this.TableInd = Reader.GetDouble(); if ( 65536 & Flags ) { this.TableW = new CTableMeasurement(tblwidth_Auto, 0); this.TableW.Read_FromBinary(Reader); } if ( 131072 & Flags ) this.TableLayout = Reader.GetLong(); } } function CTableRowHeight(Value, HRule) { this.Value = Value; this.HRule = HRule; } CTableRowHeight.prototype = { Copy : function() { return new CTableRowHeight(this.Value, this.HRule); }, Write_ToBinary : function(Writer) { // Double : Value // Long : HRule Writer.WriteDouble( this.Value ); Writer.WriteLong( this.HRule ); }, Read_FromBinary : function(Reader) { // Double : Value // Long : HRule this.Value = Reader.GetDouble(); this.HRule = Reader.GetLong(); } } function CTableRowPr() { this.CantSplit = undefined; this.GridAfter = undefined; this.GridBefore = undefined; this.Jc = undefined; this.TableCellSpacing = undefined; this.Height = undefined; this.WAfter = undefined; this.WBefore = undefined; this.TableHeader = undefined; } CTableRowPr.prototype = { Copy : function() { var RowPr = new CTableRowPr(); RowPr.CantSplit = this.CantSplit; RowPr.GridAfter = this.GridAfter; RowPr.GridBefore = this.GridBefore; RowPr.Jc = this.Jc; RowPr.TableCellSpacing = this.TableCellSpacing; if ( undefined != this.Height ) RowPr.Height = this.Height.Copy(); if ( undefined != this.WAfter ) RowPr.WAfter = this.WAfter.Copy(); if ( undefined != this.WBefore ) RowPr.WBefore = this.WBefore.Copy(); RowPr.TableHeader = this.TableHeader; return RowPr; }, Merge : function(RowPr) { if ( undefined != RowPr.CantSplit ) this.CantSplit = RowPr.CantSplit; if ( undefined != RowPr.GridAfter ) this.GridAfter = RowPr.GridAfter; if ( undefined != RowPr.GridBefore ) this.GridBefore = RowPr.GridBefore; if ( undefined != RowPr.Jc ) this.Jc = RowPr.Jc; if ( undefined != RowPr.TableCellSpacing ) this.TableCellSpacing = RowPr.TableCellSpacing; if ( undefined != RowPr.Height ) this.Height = RowPr.Height.Copy(); if ( undefined != RowPr.WAfter ) this.WAfter = RowPr.WAfter.Copy(); if ( undefined != RowPr.WBefore ) this.WBefore = RowPr.WBefore.Copy(); if ( undefined != RowPr.TableHeader ) this.TableHeader = RowPr.TableHeader; }, Init_Default : function() { this.CantSplit = false; this.GridAfter = 0; this.GridBefore = 0; this.Jc = align_Left; this.TableCellSpacing = null; this.Height = new CTableRowHeight(0, heightrule_Auto); this.WAfter = new CTableMeasurement(tblwidth_Auto, 0); this.WBefore = new CTableMeasurement(tblwidth_Auto, 0); this.TableHeader = false; }, Set_FromObject : function(RowPr) { this.CantSplit = RowPr.CantSplit; this.GridAfter = RowPr.GridAfter; this.GridBefore = RowPr.GridBefore; this.Jc = RowPr.Jc; this.TableCellSpacing = RowPr.TableCellSpacing; if ( undefined != RowPr.Height ) this.Height = new CTableRowHeight( RowPr.Height.Value, RowPr.Height.HRule ); else this.Height = undefined; if ( undefined != RowPr.WAfter ) this.WAfter = new CTableMeasurement( RowPr.WAfter.Type, RowPr.WAfter.W ); else this.WAfter = undefined; if ( undefined != RowPr.WBefore ) this.WBefore = new CTableMeasurement( RowPr.WBefore.Type, RowPr.WBefore.W ); else this.WBefore = undefined; this.TableHeader = RowPr.TableHeader; }, Write_ToBinary : function(Writer) { var StartPos = Writer.GetCurPosition(); Writer.Skip(4); var Flags = 0; if ( undefined != this.CantSplit ) { Writer.WriteBool( this.CantSplit ); Flags |= 1; } if ( undefined != this.GridAfter ) { Writer.WriteLong( this.GridAfter ); Flags |= 2; } if ( undefined != this.GridBefore ) { Writer.WriteLong( this.GridBefore ); Flags |= 4; } if ( undefined != this.Jc ) { Writer.WriteLong( this.Jc ); Flags |= 8; } if ( undefined != this.TableCellSpacing ) { if ( null === this.TableCellSpacing ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); Writer.WriteDouble( this.TableCellSpacing ); } Flags |= 16; } if ( undefined != this.Height ) { this.Height.Write_ToBinary( Writer ); Flags |= 32; } if ( undefined != this.WAfter ) { this.WAfter.Write_ToBinary(Writer); Flags |= 64; } if ( undefined != this.WBefore ) { this.WBefore.Write_ToBinary(Writer); Flags |= 128; } if ( undefined != this.TableHeader ) { Writer.WriteBool( this.TableHeader ); Flags |= 256; } var EndPos = Writer.GetCurPosition(); Writer.Seek( StartPos ); Writer.WriteLong( Flags ); Writer.Seek( EndPos ); }, Read_FromBinary : function(Reader) { var Flags = Reader.GetLong(); if ( 1 & Flags ) this.CantSplit = Reader.GetBool(); if ( 2 & Flags ) this.GridAfter = Reader.GetLong(); if ( 4 & Flags ) this.GridBefore = Reader.GetLong(); if ( 8 & Flags ) this.Jc = Reader.GetLong(); if ( 16 & Flags ) { if ( true === Reader.GetBool() ) this.TableCellSpacing = Reader.GetLong(); else this.TableCellSpacing = Reader.GetDouble(); } if ( 32 & Flags ) { this.Height = new CTableRowHeight(0, heightrule_Auto); this.Height.Read_FromBinary(Reader); } if ( 64 & Flags ) { this.WAfter = new CTableMeasurement(tblwidth_Auto, 0); this.WAfter.Read_FromBinary(Reader); } if ( 128 & Flags ) { this.WBefore = new CTableMeasurement(tblwidth_Auto, 0); this.WBefore.Read_FromBinary(Reader); } if ( 256 & Flags ) this.TableHeader = Reader.GetBool(); } } function CTableCellPr() { this.GridSpan = undefined; this.Shd = undefined; this.TableCellMar = undefined; // undefined/null/{Top, Left, Right, Bottom} this.TableCellBorders = { Bottom : undefined, Left : undefined, Right : undefined, Top : undefined }; this.TableCellW = undefined; this.VAlign = undefined; this.VMerge = undefined; } CTableCellPr.prototype = { Copy : function() { var CellPr = new CTableCellPr(); CellPr.GridSpan = this.GridSpan; if ( undefined != this.Shd ) CellPr.Shd = this.Shd.Copy(); if ( undefined === this.TableCellMar ) CellPr.TableCellMar = undefined; else if ( null === this.TableCellMar ) CellPr.TableCellMar = null; else { CellPr.TableCellMar = {}; CellPr.TableCellMar.Bottom = undefined != this.TableCellMar.Bottom ? this.TableCellMar.Bottom.Copy() : undefined; CellPr.TableCellMar.Left = undefined != this.TableCellMar.Left ? this.TableCellMar.Left.Copy() : undefined; CellPr.TableCellMar.Right = undefined != this.TableCellMar.Right ? this.TableCellMar.Right.Copy() : undefined; CellPr.TableCellMar.Top = undefined != this.TableCellMar.Top ? this.TableCellMar.Top.Copy() : undefined; } if ( undefined != this.TableCellBorders.Bottom ) CellPr.TableCellBorders.Bottom = this.TableCellBorders.Bottom.Copy(); if ( undefined != this.TableCellBorders.Left ) CellPr.TableCellBorders.Left = this.TableCellBorders.Left.Copy(); if ( undefined != this.TableCellBorders.Right ) CellPr.TableCellBorders.Right = this.TableCellBorders.Right.Copy(); if ( undefined != this.TableCellBorders.Top ) CellPr.TableCellBorders.Top = this.TableCellBorders.Top.Copy(); if ( undefined != this.TableCellW ) CellPr.TableCellW = this.TableCellW.Copy(); CellPr.VAlign = this.VAlign; CellPr.VMerge = this.VMerge; return CellPr; }, Merge : function(CellPr) { if ( undefined != CellPr.GridSpan ) this.GridSpan = CellPr.GridSpan; if ( undefined != CellPr.Shd ) this.Shd = CellPr.Shd.Copy(); if ( undefined === CellPr.TableCellMar ) {} else if ( null === CellPr.TableCellMar ) this.TableCellMar = null; else { this.TableCellMar = {}; this.TableCellMar.Bottom = undefined != CellPr.TableCellMar.Bottom ? CellPr.TableCellMar.Bottom.Copy() : undefined; this.TableCellMar.Left = undefined != CellPr.TableCellMar.Left ? CellPr.TableCellMar.Left.Copy() : undefined; this.TableCellMar.Right = undefined != CellPr.TableCellMar.Right ? CellPr.TableCellMar.Right.Copy() : undefined; this.TableCellMar.Top = undefined != CellPr.TableCellMar.Top ? CellPr.TableCellMar.Top.Copy() : undefined; } if ( undefined != CellPr.TableCellBorders.Bottom ) this.TableCellBorders.Bottom = CellPr.TableCellBorders.Bottom.Copy(); if ( undefined != CellPr.TableCellBorders.Left ) this.TableCellBorders.Left = CellPr.TableCellBorders.Left.Copy(); if ( undefined != CellPr.TableCellBorders.Right ) this.TableCellBorders.Right = CellPr.TableCellBorders.Right.Copy(); if ( undefined != CellPr.TableCellBorders.Top ) this.TableCellBorders.Top = CellPr.TableCellBorders.Top.Copy(); if ( undefined != CellPr.TableCellW ) this.TableCellW = CellPr.TableCellW.Copy(); if ( undefined != CellPr.VAlign ) this.VAlign = CellPr.VAlign; if ( undefined != CellPr.VMerge ) this.VMerge = CellPr.VMerge; }, Init_Default : function() { this.GridSpan = 1; this.Shd = new CDocumentShd(); this.TableCellMar = null; this.TableCellBorders.Bottom = undefined; this.TableCellBorders.Left = undefined; this.TableCellBorders.Right = undefined; this.TableCellBorders.Top = undefined; this.TableCellW = new CTableMeasurement(tblwidth_Auto, 0); this.VAlign = vertalignjc_Top; this.VMerge = vmerge_Restart; }, Set_FromObject : function(CellPr) { this.GridSpan = CellPr.GridSpan; if ( undefined != CellPr.Shd ) { this.Shd = new CDocumentShd(); this.Shd.Set_FromObject( CellPr.Shd ); } else this.Shd = undefined; if ( undefined === CellPr.TableCellMar ) this.TableCellMar = undefined; else if ( null === CellPr.TableCellMar ) this.TableCellMar = null; else { this.TableCellMar = {}; if ( undefined != CellPr.TableCellMar.Bottom ) this.TableCellMar.Bottom = new CTableMeasurement( CellPr.TableCellMar.Bottom.Type, CellPr.TableCellMar.Bottom.W ); else this.TableCellMar.Bottom = undefined; if ( undefined != CellPr.TableCellMar.Left ) this.TableCellMar.Left = new CTableMeasurement( CellPr.TableCellMar.Left.Type, CellPr.TableCellMar.Left.W ); else this.TableCellMar.Left = undefined; if ( undefined != CellPr.TableCellMar.Right ) this.TableCellMar.Right = new CTableMeasurement( CellPr.TableCellMar.Right.Type, CellPr.TableCellMar.Right.W ); else this.TableCellMar.Right = undefined; if ( undefined != CellPr.TableCellMar.Top ) this.TableCellMar.Top = new CTableMeasurement( CellPr.TableCellMar.Top.Type, CellPr.TableCellMar.Top.W ); else this.TableCellMar.Top = undefined; } if ( undefined != CellPr.TableCellBorders ) { if ( undefined != CellPr.TableCellBorders.Bottom ) { this.TableCellBorders.Bottom = new CDocumentBorder(); this.TableCellBorders.Bottom.Set_FromObject( CellPr.TableCellBorders.Bottom ); } else this.TableCellBorders.Bottom = undefined; if ( undefined != CellPr.TableCellBorders.Left ) { this.TableCellBorders.Left = new CDocumentBorder(); this.TableCellBorders.Left.Set_FromObject( CellPr.TableCellBorders.Left ); } else this.TableCellBorders.Left = undefined; if ( undefined != CellPr.TableCellBorders.Right ) { this.TableCellBorders.Right = new CDocumentBorder(); this.TableCellBorders.Right.Set_FromObject( CellPr.TableCellBorders.Right ); } else this.TableCellBorders.Right = undefined; if ( undefined != CellPr.TableCellBorders.Top ) { this.TableCellBorders.Top = new CDocumentBorder(); this.TableCellBorders.Top.Set_FromObject( CellPr.TableCellBorders.Top ); } else this.TableCellBorders.Top = undefined; } else { this.TableCellBorders.Bottom = undefined; this.TableCellBorders.Left = undefined; this.TableCellBorders.Right = undefined; this.TableCellBorders.Top = undefined; } if ( undefined != this.TableCellW ) this.TableCellW = new CTableMeasurement( CellPr.TableCellW.Type, CellPr.TableCellW.W ); else this.TableCellW = undefined; this.VAlign = CellPr.VAlign; this.VMerge = CellPr.VMerge; }, Check_PresentationPr : function(Theme) { if(this.Shd) { this.Shd.Check_PresentationPr(Theme); } if(this.TableCellBorders.Bottom) { this.TableCellBorders.Bottom.Check_PresentationPr(Theme); } if(this.TableCellBorders.Left) { this.TableCellBorders.Left.Check_PresentationPr(Theme); } if(this.TableCellBorders.Right) { this.TableCellBorders.Right.Check_PresentationPr(Theme); } if(this.TableCellBorders.Top) { this.TableCellBorders.Top.Check_PresentationPr(Theme); } }, Write_ToBinary : function(Writer) { var StartPos = Writer.GetCurPosition(); Writer.Skip(4); var Flags = 0; if ( undefined != this.GridSpan ) { Writer.WriteLong( this.GridSpan ); Flags |= 1; } if ( undefined != this.Shd ) { this.Shd.Write_ToBinary( Writer ); Flags |= 2; } if ( undefined != this.TableCellMar ) { if ( null === this.TableCellMar ) { Flags |= 4; } else { if ( undefined != this.TableCellMar.Bottom ) { this.TableCellMar.Bottom.Write_ToBinary(Writer); Flags |= 8; } if ( undefined != this.TableCellMar.Left ) { this.TableCellMar.Left.Write_ToBinary(Writer); Flags |= 16; } if ( undefined != this.TableCellMar.Right ) { this.TableCellMar.Right.Write_ToBinary(Writer); Flags |= 32; } if ( undefined != this.TableCellMar.Top ) { this.TableCellMar.Top.Write_ToBinary(Writer); Flags |= 64; } Flags |= 128; } } if ( undefined != this.TableCellBorders.Bottom ) { this.TableCellBorders.Bottom.Write_ToBinary( Writer ); Flags |= 256; } if ( undefined != this.TableCellBorders.Left ) { this.TableCellBorders.Left.Write_ToBinary( Writer ); Flags |= 512; } if ( undefined != this.TableCellBorders.Right ) { this.TableCellBorders.Right.Write_ToBinary( Writer ); Flags |= 1024; } if ( undefined != this.TableCellBorders.Top ) { this.TableCellBorders.Top.Write_ToBinary( Writer ); Flags |= 2048; } if ( undefined != this.TableCellW ) { this.TableCellW.Write_ToBinary(Writer); Flags |= 4096; } if ( undefined != this.VAlign ) { Writer.WriteLong( this.VAlign ); Flags |= 8192; } if ( undefined != this.VMerge ) { Writer.WriteLong( this.VMerge ); Flags |= 16384; } var EndPos = Writer.GetCurPosition(); Writer.Seek( StartPos ); Writer.WriteLong( Flags ); Writer.Seek( EndPos ); }, Read_FromBinary : function(Reader) { var Flags = Reader.GetLong(); if ( 1 & Flags ) this.GridSpan = Reader.GetLong(); if ( 2 & Flags ) { this.Shd = new CDocumentShd(); this.Shd.Read_FromBinary( Reader ); } if ( 4 & Flags ) this.TableCellMar = null; else if ( 128 & Flags ) { this.TableCellMar = {}; if ( 8 & Flags ) { this.TableCellMar.Bottom = new CTableMeasurement(tblwidth_Auto, 0); this.TableCellMar.Bottom.Read_FromBinary( Reader ); } if ( 16 & Flags ) { this.TableCellMar.Left = new CTableMeasurement(tblwidth_Auto, 0); this.TableCellMar.Left.Read_FromBinary( Reader ); } if ( 32 & Flags ) { this.TableCellMar.Right = new CTableMeasurement(tblwidth_Auto, 0); this.TableCellMar.Right.Read_FromBinary( Reader ); } if ( 64 & Flags ) { this.TableCellMar.Top = new CTableMeasurement(tblwidth_Auto, 0); this.TableCellMar.Top.Read_FromBinary( Reader ); } } if ( 256 & Flags ) { this.TableCellBorders.Bottom = new CDocumentBorder(); this.TableCellBorders.Bottom.Read_FromBinary( Reader ); } if ( 512 & Flags ) { this.TableCellBorders.Left = new CDocumentBorder(); this.TableCellBorders.Left.Read_FromBinary( Reader ); } if ( 1024 & Flags ) { this.TableCellBorders.Right = new CDocumentBorder(); this.TableCellBorders.Right.Read_FromBinary( Reader ); } if ( 2048 & Flags ) { this.TableCellBorders.Top = new CDocumentBorder(); this.TableCellBorders.Top.Read_FromBinary( Reader ); } if ( 4096 & Flags ) { this.TableCellW = new CTableMeasurement(tblwidth_Auto, 0); this.TableCellW.Read_FromBinary( Reader ); } if ( 8192 & Flags ) this.VAlign = Reader.GetLong(); if ( 16384 & Flags ) this.VMerge = Reader.GetLong(); } } function CRFonts() { this.Ascii = undefined; this.EastAsia = undefined; this.HAnsi = undefined; this.CS = undefined; this.Hint = undefined; } CRFonts.prototype = { Set_All : function(FontName, FontIndex) { this.Ascii = { Name : FontName, Index : FontIndex }; this.EastAsia = { Name : FontName, Index : FontIndex }; this.HAnsi = { Name : FontName, Index : FontIndex }; this.CS = { Name : FontName, Index : FontIndex }; this.Hint = fonthint_Default; }, Copy : function() { var RFonts = new CRFonts(); RFonts.Ascii = this.Ascii; RFonts.EastAsia = this.EastAsia; RFonts.HAnsi = this.HAnsi; RFonts.CS = this.CS; RFonts.Hint = this.Hint; return RFonts; }, Merge : function(RFonts) { if ( undefined !== RFonts.Ascii ) this.Ascii = RFonts.Ascii; if ( undefined != RFonts.EastAsia ) this.EastAsia = RFonts.EastAsia; if ( undefined != RFonts.HAnsi ) this.HAnsi = RFonts.HAnsi; if ( undefined != RFonts.CS ) this.CS = RFonts.CS; if ( undefined != RFonts.Hint ) this.Hint = RFonts.Hint; }, Init_Default : function() { this.Ascii = { Name : "Arial", Index : -1 }; this.EastAsia = { Name : "Arial", Index : -1 }; this.HAnsi = { Name : "Arial", Index : -1 }; this.CS = { Name : "Arial", Index : -1 }; this.Hint = fonthint_Default; }, Set_FromObject : function(RFonts) { if ( undefined != RFonts.Ascii ) { this.Ascii = { Name : RFonts.Ascii.Name, Index : RFonts.Ascii.Index }; } else this.Ascii = undefined; if ( undefined != RFonts.EastAsia ) { this.EastAsia = { Name : RFonts.EastAsia.Name, Index : RFonts.EastAsia.Index }; } else this.EastAsia = undefined; if ( undefined != RFonts.HAnsi ) { this.HAnsi = { Name : RFonts.HAnsi.Name, Index : RFonts.HAnsi.Index }; } else this.HAnsi = undefined; if ( undefined != RFonts.CS ) { this.CS = { Name : RFonts.CS.Name, Index : RFonts.CS.Index }; } else this.CS = undefined; this.Hint = RFonts.Hint; }, Compare : function(RFonts) { // Ascii if ( undefined !== this.Ascii && ( undefined === RFonts.Ascii || this.Ascii.Name !== RFonts.Ascii.Name ) ) this.Ascii = undefined; // EastAsia if ( undefined !== this.EastAsia && ( undefined === RFonts.EastAsia || this.EastAsia.Name !== RFonts.EastAsia.Name ) ) this.EastAsia = undefined; // HAnsi if ( undefined !== this.HAnsi && ( undefined === RFonts.HAnsi || this.HAnsi.Name !== RFonts.HAnsi.Name ) ) this.HAnsi = undefined; // CS if ( undefined !== this.CS && ( undefined === RFonts.CS || this.CS.Name !== RFonts.CS.Name ) ) this.CS = undefined; // Hint if ( undefined !== this.Hint && ( undefined === RFonts.Hint || this.Hint !== RFonts.Hint ) ) this.Hint = undefined; }, Write_ToBinary : function(Writer) { var StartPos = Writer.GetCurPosition(); Writer.Skip(4); var Flags = 0; if ( undefined != this.Ascii ) { Writer.WriteString2( this.Ascii.Name ); Flags |= 1; } if ( undefined != this.EastAsia ) { Writer.WriteString2( this.EastAsia.Name ); Flags |= 2; } if ( undefined != this.HAnsi ) { Writer.WriteString2( this.HAnsi.Name ); Flags |= 4; } if ( undefined != this.CS ) { Writer.WriteString2( this.CS.Name ); Flags |= 8; } if ( undefined != this.Hint ) { Writer.WriteLong( this.Hint ); Flags |= 16; } var EndPos = Writer.GetCurPosition(); Writer.Seek( StartPos ); Writer.WriteLong( Flags ); Writer.Seek( EndPos ); }, Read_FromBinary : function(Reader) { var Flags = Reader.GetLong(); // Ascii if ( Flags & 1 ) this.Ascii = { Name : Reader.GetString2(), Index : -1 }; // EastAsia if ( Flags & 2 ) this.EastAsia = { Name : Reader.GetString2(), Index : -1 }; // HAnsi if ( Flags & 4 ) this.HAnsi = { Name : Reader.GetString2(), Index : -1 }; // CS if ( Flags & 8 ) this.CS = { Name : Reader.GetString2(), Index : -1 }; // Hint if ( Flags & 16 ) this.Hint = Reader.GetLong(); } }; function CLang() { this.Bidi = undefined; this.EastAsia = undefined; this.Val = undefined; } CLang.prototype = { Copy : function() { var Lang = new CLang(); Lang.Bidi = this.Bidi; Lang.EastAsia = this.EastAsia; Lang.Val = this.Val; return Lang; }, Merge : function(Lang) { if ( undefined !== Lang.Bidi ) this.Bidi = Lang.Bidi; if ( undefined !== Lang.EastAsia ) this.EastAsia = Lang.EastAsia; if ( undefined !== Lang.Val ) this.Val = Lang.Val; }, Init_Default : function() { this.Bidi = lcid_enUS; this.EastAsia = lcid_enUS; this.Val = lcid_enUS; }, Set_FromObject : function(Lang) { this.Bidi = Lang.Bidi; this.EastAsia = Lang.EastAsia; this.Val = Lang.Val; }, Compare : function(Lang) { // Bidi if ( undefined !== this.Bidi && this.Bidi !== Lang.Bidi ) this.Bidi = undefined; // EastAsia if ( undefined !== this.EastAsia && this.EastAsia !== Lang.EastAsia ) this.EastAsia = undefined; // Val if ( undefined !== this.Val && this.Val !== Lang.Val ) this.Val = undefined; }, Write_ToBinary : function(Writer) { var StartPos = Writer.GetCurPosition(); Writer.Skip(4); var Flags = 0; if ( undefined != this.Bidi ) { Writer.WriteLong( this.Bidi ); Flags |= 1; } if ( undefined != this.EastAsia ) { Writer.WriteLong( this.EastAsia ); Flags |= 2; } if ( undefined != this.Val ) { Writer.WriteLong( this.Val ); Flags |= 4; } var EndPos = Writer.GetCurPosition(); Writer.Seek( StartPos ); Writer.WriteLong( Flags ); Writer.Seek( EndPos ); }, Read_FromBinary : function(Reader) { var Flags = Reader.GetLong(); // Bidi if ( Flags & 1 ) this.Bidi = Reader.GetLong(); // EastAsia if ( Flags & 2 ) this.EastAsia = Reader.GetLong(); // Val if ( Flags & 4 ) this.Val = Reader.GetLong(); } }; function CTextPr() { this.Bold = undefined; // Жирный текст this.Italic = undefined; // Наклонный текст this.Strikeout = undefined; // Зачеркивание this.Underline = undefined; this.FontFamily = undefined; this.FontSize = undefined; this.Color = undefined; this.VertAlign = undefined; this.HighLight = undefined; // highlight_None/Color this.RStyle = undefined; this.Spacing = undefined; // Дополнительное расстояние между символвами this.DStrikeout = undefined; // Двойное зачеркивание this.Caps = undefined; this.SmallCaps = undefined; this.Position = undefined; // Смещение по Y this.RFonts = new CRFonts(); this.BoldCS = undefined; this.ItalicCS = undefined; this.FontSizeCS = undefined; this.CS = undefined; this.RTL = undefined; this.Lang = new CLang(); this.Unifill = undefined; this.FontRef = undefined; this.Shd = undefined; this.Vanish = undefined; } CTextPr.prototype = { Clear : function() { this.Bold = undefined; this.Italic = undefined; this.Strikeout = undefined; this.Underline = undefined; this.FontFamily = undefined; this.FontSize = undefined; this.Color = undefined; this.VertAlign = undefined; this.HighLight = undefined; this.RStyle = undefined; this.Spacing = undefined; this.DStrikeout = undefined; this.Caps = undefined; this.SmallCaps = undefined; this.Position = undefined; this.RFonts = new CRFonts(); this.BoldCS = undefined; this.ItalicCS = undefined; this.FontSizeCS = undefined; this.CS = undefined; this.RTL = undefined; this.Lang = new CLang(); this.Unifill = undefined; this.FontRef = undefined; this.Shd = undefined; this.Vanish = undefined; }, Copy : function() { var TextPr = new CTextPr(); TextPr.Bold = this.Bold; TextPr.Italic = this.Italic; TextPr.Strikeout = this.Strikeout; TextPr.Underline = this.Underline; if ( undefined != this.FontFamily ) { TextPr.FontFamily = {}; TextPr.FontFamily.Name = this.FontFamily.Name; TextPr.FontFamily.Index = this.FontFamily.Index; } TextPr.FontSize = this.FontSize; if ( undefined != this.Color ) TextPr.Color = new CDocumentColor(this.Color.r, this.Color.g, this.Color.b, this.Color.Auto); TextPr.VertAlign = this.VertAlign; if ( undefined === this.HighLight ) TextPr.HighLight = undefined; else if ( highlight_None === this.HighLight ) TextPr.HighLight = highlight_None; else TextPr.HighLight = this.HighLight.Copy(); TextPr.RStyle = this.RStyle; TextPr.Spacing = this.Spacing; TextPr.DStrikeout = this.DStrikeout; TextPr.Caps = this.Caps; TextPr.SmallCaps = this.SmallCaps; TextPr.Position = this.Position; TextPr.RFonts = this.RFonts.Copy(); TextPr.BoldCS = this.BoldCS; TextPr.ItalicCS = this.ItalicCS; TextPr.FontSizeCS = this.FontSizeCS; TextPr.CS = this.CS; TextPr.RTL = this.RTL; TextPr.Lang = this.Lang.Copy(); if(undefined != this.Unifill) TextPr.Unifill = this.Unifill.createDuplicate(); if(undefined != this.FontRef) TextPr.FontRef = this.FontRef.createDuplicate(); if (undefined !== this.Shd ) TextPr.Shd = this.Shd.Copy(); TextPr.Vanish = this.Vanish; return TextPr; }, Merge : function(TextPr) { if ( undefined != TextPr.Bold ) this.Bold = TextPr.Bold; if ( undefined != TextPr.Italic ) this.Italic = TextPr.Italic; if ( undefined != TextPr.Strikeout ) this.Strikeout = TextPr.Strikeout; if ( undefined != TextPr.Underline ) this.Underline = TextPr.Underline; if ( undefined != TextPr.FontFamily ) { this.FontFamily = {}; this.FontFamily.Name = TextPr.FontFamily.Name; this.FontFamily.Index = TextPr.FontFamily.Index; } if ( undefined != TextPr.FontSize ) this.FontSize = TextPr.FontSize; if ( undefined != TextPr.Color ) this.Color = TextPr.Color.Copy(); if ( undefined != TextPr.VertAlign ) this.VertAlign = TextPr.VertAlign; if ( undefined === TextPr.HighLight ) {} else if ( highlight_None === TextPr.HighLight ) this.HighLight = highlight_None; else this.HighLight = TextPr.HighLight.Copy(); if ( undefined != TextPr.RStyle ) this.RStyle = TextPr.RStyle; if ( undefined != TextPr.Spacing ) this.Spacing = TextPr.Spacing; if ( undefined != TextPr.DStrikeout ) this.DStrikeout = TextPr.DStrikeout; if ( undefined != TextPr.SmallCaps ) this.SmallCaps = TextPr.SmallCaps; if ( undefined != TextPr.Caps ) this.Caps = TextPr.Caps; if ( undefined != TextPr.Position ) this.Position = TextPr.Position; this.RFonts.Merge( TextPr.RFonts ); if ( undefined != TextPr.BoldCS ) this.BoldCS = TextPr.BoldCS; if ( undefined != TextPr.ItalicCS ) this.ItalicCS = TextPr.ItalicCS; if ( undefined != TextPr.FontSizeCS ) this.FontSizeCS = TextPr.FontSizeCS; if ( undefined != TextPr.CS ) this.CS = TextPr.CS; if ( undefined != TextPr.RTL ) this.RTL = TextPr.RTL; this.Lang.Merge( TextPr.Lang ); if(undefined != TextPr.Unifill) this.Unifill = TextPr.Unifill.createDuplicate(); else { if(undefined != TextPr.Color) { this.Unifill = undefined; } } if(undefined != TextPr.FontRef) { this.FontRef = TextPr.FontRef.createDuplicate(); } if ( undefined !== TextPr.Shd ) this.Shd = TextPr.Shd.Copy(); if ( undefined !== TextPr.Vanish ) this.Vanish = TextPr.Vanish; }, Init_Default : function() { this.Bold = false; this.Italic = false; this.Underline = false; this.Strikeout = false; this.FontFamily = { Name : "Arial", Index : -1 }; this.FontSize = 11; this.Color = new CDocumentColor(0, 0, 0, true); this.VertAlign = vertalign_Baseline; this.HighLight = highlight_None; this.RStyle = undefined; this.Spacing = 0; this.DStrikeout = false; this.SmallCaps = false; this.Caps = false; this.Position = 0; this.RFonts.Init_Default(); this.BoldCS = false; this.ItalicCS = false; this.FontSizeCS = 11; this.CS = false; this.RTL = false; this.Lang.Init_Default(); this.Unifill = undefined; this.FontRef = undefined; this.Shd = undefined; this.Vanish = false; }, Set_FromObject : function(TextPr) { this.Bold = TextPr.Bold; this.Italic = TextPr.Italic; this.Strikeout = TextPr.Strikeout; this.Underline = TextPr.Underline; if ( undefined != TextPr.FontFamily ) { this.FontFamily = {}; this.FontFamily.Name = TextPr.FontFamily.Name; this.FontFamily.Index = TextPr.FontFamily.Index; } else this.FontFamily = undefined; this.FontSize = TextPr.FontSize; if ( undefined != TextPr.Color ) this.Color = new CDocumentColor( TextPr.Color.r, TextPr.Color.g, TextPr.Color.b, TextPr.Color.Auto ); else this.Color = undefined; this.VertAlign = TextPr.VertAlign; if ( undefined === TextPr.HighLight ) this.HighLight = undefined; else if ( highlight_None === TextPr.HighLight ) this.HighLight = highlight_None; else this.HighLight = new CDocumentColor( TextPr.HighLight.r, TextPr.HighLight.g, TextPr.HighLight.b ); if ( undefined != TextPr.RStyle ) this.RStyle = TextPr.RStyle; this.Spacing = TextPr.Spacing; this.DStrikeout = TextPr.DStrikeout; this.Caps = TextPr.Caps; this.SmallCaps = TextPr.SmallCaps; this.Position = TextPr.Position; if ( undefined != TextPr.RFonts ) this.RFonts.Set_FromObject( TextPr.RFonts ); this.BoldCS = TextPr.BoldCS; this.ItalicCS = TextPr.ItalicCS; this.FontSizeCS = TextPr.FontSizeCS; this.CS = TextPr.CS; this.RTL = TextPr.RTL; if ( undefined != TextPr.Lang ) this.Lang.Set_FromObject( TextPr.Lang ); if ( undefined != TextPr.Unifill ) this.Unifill = TextPr.Unifill ; if( undefined != TextPr.FontRef ) { this.FontRef = TextPr.FontRef; } if ( undefined !== TextPr.Shd ) { this.Shd = new CDocumentShd(); this.Shd.Set_FromObject( TextPr.Shd ); } else this.Shd = undefined; this.Vanish = TextPr.Vanish; }, Check_PresentationPr: function() { if(this.FontRef) { var prefix; if(this.FontRef.idx === fntStyleInd_minor) { prefix = "+mn-"; } else { prefix = "+mj-"; } this.RFonts.Set_FromObject( { Ascii: { Name: prefix+"lt", Index: -1 }, EastAsia: { Name: prefix+"ea", Index: -1 }, HAnsi: { Name: prefix+"lt", Index: -1 }, CS: { Name: prefix+"lt", Index: -1 } } ); if(this.FontRef.Color && !this.Unifill) { this.Unifill = CreateUniFillByUniColorCopy(this.FontRef.Color); } } }, Compare : function(TextPr) { // Bold if ( undefined !== this.Bold && this.Bold !== TextPr.Bold ) this.Bold = undefined; // Italic if ( undefined !== this.Italic && this.Italic !== TextPr.Italic ) this.Italic = undefined; // Strikeout if ( undefined !== this.Strikeout && this.Strikeout !== TextPr.Strikeout ) this.Strikeout = undefined; // Underline if ( undefined !== this.Underline && this.Underline !== TextPr.Underline ) this.Underline = undefined; // FontFamily if ( undefined !== this.FontFamily && ( undefined === TextPr.FontFamily || this.FontFamily.Name !== TextPr.FontFamily.Name ) ) this.FontFamily = undefined; // FontSize if ( undefined !== this.FontSize && ( undefined === TextPr.FontSize || Math.abs( this.FontSize - TextPr.FontSize ) >= 0.001 ) ) this.FontSize = undefined; // Color if ( undefined !== this.Color && ( undefined === TextPr.Color || true !== this.Color.Compare(TextPr.Color) ) ) this.Color = undefined; // VertAlign if ( undefined !== this.VertAlign && this.VertAlign !== TextPr.VertAlign ) this.VertAlign = undefined; // HighLight if ( undefined !== this.HighLight && ( undefined === TextPr.HighLight || ( highlight_None === this.HighLight && highlight_None !== TextPr.HighLight ) || ( highlight_None !== this.HighLight && highlight_None === TextPr.HighLight ) || ( highlight_None !== this.HighLight && highlight_None !== TextPr.HighLight && true !== this.HighLight.Compare( TextPr.HighLight ) ) ) ) this.HighLight = undefined; // RStyle if ( undefined !== this.RStyle && ( undefined === TextPr.RStyle || this.RStyle !== TextPr.RStyle ) ) this.RStyle = undefined; // Spacing if ( undefined !== this.Spacing && ( undefined === TextPr.Spacing || Math.abs(this.Spacing - TextPr.Spacing) >= 0.001 ) ) this.Spacing = undefined; // DStrikeout if ( undefined !== this.DStrikeout && ( undefined === TextPr.DStrikeout || this.DStrikeout !== TextPr.DStrikeout ) ) this.DStrikeout = undefined; // Caps if ( undefined !== this.Caps && ( undefined === TextPr.Caps || this.Caps !== TextPr.Caps ) ) this.Caps = undefined; // SmallCaps if ( undefined !== this.SmallCaps && ( undefined === TextPr.SmallCaps || this.SmallCaps !== TextPr.SmallCaps ) ) this.SmallCaps = undefined; // Position if ( undefined !== this.Position && ( undefined === TextPr.Position || Math.abs(this.Position - TextPr.Position) >= 0.001 ) ) this.Position = undefined; // RFonts this.RFonts.Compare( TextPr.RFonts ); // BoldCS if ( undefined !== this.BoldCS && this.BoldCS !== TextPr.BoldCS ) this.BoldCS = undefined; // ItalicCS if ( undefined !== this.ItalicCS && this.ItalicCS !== TextPr.ItalicCS ) this.ItalicCS = undefined; // FontSizeCS if ( undefined !== this.FontSizeCS && ( undefined === TextPr.FontSizeCS || Math.abs( this.FontSizeCS - TextPr.FontSizeCS ) >= 0.001 ) ) this.FontSizeCS = undefined; // CS if ( undefined !== this.CS && this.CS !== TextPr.CS ) this.CS = undefined; // RTL if ( undefined !== this.RTL && this.RTL !== TextPr.RTL ) this.RTL = undefined; // Lang this.Lang.Compare( TextPr.Lang ); //Result_TextPr.Unifill = CompareUniFill(this.Unifill, TextPr.Unifill); // Vanish if ( undefined !== this.Vanish && this.Vanish !== TextPr.Vanish ) this.Vanish = undefined; return this; }, Write_ToBinary : function(Writer) { var StartPos = Writer.GetCurPosition(); Writer.Skip(4); var Flags = 0; if ( undefined != this.Bold ) { Writer.WriteBool( this.Bold ); Flags |= 1; } if ( undefined != this.Italic ) { Writer.WriteBool( this.Italic ); Flags |= 2; } if ( undefined != this.Underline ) { Writer.WriteBool( this.Underline ); Flags |= 4; } if ( undefined != this.Strikeout ) { Writer.WriteBool( this.Strikeout ); Flags |= 8; } if ( undefined != this.FontFamily ) { Writer.WriteString2( this.FontFamily.Name ); Flags |= 16; } if ( undefined != this.FontSize ) { Writer.WriteDouble( this.FontSize ); Flags |= 32; } if ( undefined != this.Color ) { this.Color.Write_ToBinary(Writer); Flags |= 64; } if ( undefined != this.VertAlign ) { Writer.WriteLong( this.VertAlign ); Flags |= 128; } if ( undefined != this.HighLight ) { if ( highlight_None === this.HighLight ) { Writer.WriteLong( highlight_None ); } else { Writer.WriteLong( 0 ); this.HighLight.Write_ToBinary( Writer ); } Flags |= 256; } if ( undefined != this.RStyle ) { Writer.WriteString2( this.RStyle ); Flags |= 512; } if ( undefined != this.Spacing ) { Writer.WriteDouble( this.Spacing ); Flags |= 1024; } if ( undefined != this.DStrikeout ) { Writer.WriteBool( this.DStrikeout ); Flags |= 2048; } if ( undefined != this.Caps ) { Writer.WriteBool( this.Caps ); Flags |= 4096; } if ( undefined != this.SmallCaps ) { Writer.WriteBool( this.SmallCaps ); Flags |= 8192; } if ( undefined != this.Position ) { Writer.WriteDouble( this.Position ); Flags |= 16384; } if ( undefined != this.RFonts ) { this.RFonts.Write_ToBinary( Writer ); Flags |= 32768; } if ( undefined != this.BoldCS ) { Writer.WriteBool( this.BoldCS ); Flags |= 65536; } if ( undefined != this.ItalicCS ) { Writer.WriteBool( this.ItalicCS ); Flags |= 131072; } if ( undefined != this.FontSizeCS ) { Writer.WriteDouble( this.FontSizeCS ); Flags |= 262144; } if ( undefined != this.CS ) { Writer.WriteBool( this.CS ); Flags |= 524288; } if ( undefined != this.RTL ) { Writer.WriteBool( this.RTL ); Flags |= 1048576; } if ( undefined != this.Lang ) { this.Lang.Write_ToBinary( Writer ); Flags |= 2097152; } if(undefined != this.Unifill) { this.Unifill.Write_ToBinary(Writer); Flags |= 4194304; } if ( undefined !== this.Shd ) { this.Shd.Write_ToBinary(Writer); Flags |= 8388608; } if ( undefined !== this.Vanish ) { Writer.WriteBool( this.Vanish ); Flags |= 16777216; } if( undefined !== this.FontRef ) { this.FontRef.Write_ToBinary(Writer); Flags |= 33554432; } var EndPos = Writer.GetCurPosition(); Writer.Seek( StartPos ); Writer.WriteLong( Flags ); Writer.Seek( EndPos ); }, Read_FromBinary : function(Reader) { var Flags = Reader.GetLong(); // Bold if ( Flags & 1 ) this.Bold = Reader.GetBool(); // Italic if ( Flags & 2 ) this.Italic = Reader.GetBool(); // Underline if ( Flags & 4 ) this.Underline = Reader.GetBool(); // Strikeout if ( Flags & 8 ) this.Strikeout = Reader.GetBool(); // FontFamily if ( Flags & 16 ) this.FontFamily = { Name : Reader.GetString2(), Index : -1 }; // FontSize if ( Flags & 32 ) this.FontSize = Reader.GetDouble(); // Color if ( Flags & 64 ) { this.Color = new CDocumentColor(0, 0, 0); this.Color.Read_FromBinary(Reader); } // VertAlign if ( Flags & 128 ) this.VertAlign = Reader.GetLong(); // HighLight if ( Flags & 256 ) { var HL_type = Reader.GetLong(); if ( highlight_None == HL_type ) this.HighLight = highlight_None; else { this.HighLight = new CDocumentColor(0, 0, 0); this.HighLight.Read_FromBinary(Reader); } } // RStyle if ( Flags & 512 ) this.RStyle = Reader.GetString2(); // Spacing if ( Flags & 1024 ) this.Spacing = Reader.GetDouble(); // DStrikeout if ( Flags & 2048 ) this.DStrikeout = Reader.GetBool(); // Caps if ( Flags & 4096 ) this.Caps = Reader.GetBool(); // SmallCaps if ( Flags & 8192 ) this.SmallCaps = Reader.GetBool(); // Position if ( Flags & 16384 ) this.Position = Reader.GetDouble(); // RFonts if ( Flags & 32768 ) this.RFonts.Read_FromBinary( Reader ); // BoldCS if ( Flags & 65536 ) this.BoldCS = Reader.GetBool(); // ItalicCS if ( Flags & 131072 ) this.ItalicCS = Reader.GetBool(); // FontSizeCS if ( Flags & 262144 ) this.FontSizeCS = Reader.GetDouble(); // CS if ( Flags & 524288 ) this.CS = Reader.GetBool(); // RTL if ( Flags & 1048576 ) this.RTL = Reader.GetBool(); // Lang if ( Flags & 2097152 ) this.Lang.Read_FromBinary( Reader ); // Unifill if ( Flags & 4194304 ) { this.Unifill = new CUniFill() this.Unifill.Read_FromBinary( Reader ); } // Shd if ( Flags & 8388608 ) { this.Shd = new CDocumentShd(); this.Shd.Read_FromBinary( Reader ); } // Vanish if ( Flags & 16777216 ) this.Vanish = Reader.GetBool(); if ( Flags & 33554432 ) { this.FontRef = new FontRef(); this.FontRef.Read_FromBinary(Reader); } }, Check_NeedRecalc : function() { // Потому что в параграфе внутри Internal_recalculate_0 кэшируются ParaTextPr return true; if ( undefined != this.Bold ) return true; if ( undefined != this.Italic ) return true; if ( undefined != this.FontFamily ) return true; if ( undefined != this.FontSize ) return true; if ( undefined != this.VertAlign ) return true; if ( undefined != this.Spacing ) return true; if ( undefined != this.Caps ) return true; if ( undefined != this.SmallCaps ) return true; if ( undefined != this.Position ) return true; if ( undefined != this.RFonts.Ascii ) return true; if ( undefined != this.RFonts.EastAsia ) return true; if ( undefined != this.RFonts.HAnsi ) return true; if ( undefined != this.RFonts.CS ) return true; if ( undefined != this.RTL || undefined != this.CS || undefined != this.BoldCS || undefined != this.ItalicCS || undefined != this.FontSizeCS ) return true; if ( undefined != this.Lang.Val ) return true; // Потому что в параграфе внутри Internal_recalculate_0 кэшируются ParaTextPr if ( undefined != this.Color ) return true; if ( undefined != this.HighLight ) return true; if ( undefined != this.Shd ) return true; return false; }, Get_FontKoef : function() { var dFontKoef = 1; switch ( this.VertAlign ) { case vertalign_Baseline: { dFontKoef = 1; break; } case vertalign_SubScript: case vertalign_SuperScript: { dFontKoef = vertalign_Koef_Size; break; } } return dFontKoef; }, Document_Get_AllFontNames : function(AllFonts) { if ( undefined != this.RFonts.Ascii ) AllFonts[this.RFonts.Ascii.Name] = true; if ( undefined != this.RFonts.HAnsi ) AllFonts[this.RFonts.HAnsi.Name] = true; if ( undefined != this.RFonts.EastAsia ) AllFonts[this.RFonts.EastAsia.Name] = true; if ( undefined != this.RFonts.CS ) AllFonts[this.RFonts.CS.Name] = true; }, Document_CreateFontMap : function(FontMap, FontScheme) { var Style = ( true === this.Bold ? 1 : 0 ) + ( true === this.Italic ? 2 : 0 ); var StyleCS = ( true === this.BoldCS ? 1 : 0 ) + ( true === this.ItalicCS ? 2 : 0 ); var Size = this.FontSize; var SizeCS = this.FontSizeCS; var RFonts = this.RFonts; var CheckedName; if ( undefined != RFonts.Ascii ) { CheckedName = FontScheme.checkFont(RFonts.Ascii.Name); var Key = "" + CheckedName + "_" + Style + "_" + Size; FontMap[Key] = { Name : CheckedName, Style : Style, Size : Size }; } if ( undefined != RFonts.EastAsia ) { CheckedName = FontScheme.checkFont(RFonts.EastAsia.Name); var Key = "" + CheckedName + "_" + Style + "_" + Size; FontMap[Key] = { Name : CheckedName, Style : Style, Size : Size }; } if ( undefined != RFonts.HAnsi ) { CheckedName = FontScheme.checkFont(RFonts.HAnsi.Name); var Key = "" + CheckedName + "_" + Style + "_" + Size; FontMap[Key] = { Name : CheckedName, Style : Style, Size : Size }; } if ( undefined != RFonts.CS ) { CheckedName = FontScheme.checkFont(RFonts.CS.Name); var Key = "" + CheckedName + "_" + StyleCS + "_" + SizeCS; FontMap[Key] = { Name : CheckedName, Style : StyleCS, Size : SizeCS }; } }, isEqual: function(TextPrOld, TextPrNew) { if(TextPrOld == undefined || TextPrNew == undefined) return false; for(var TextPr in TextPrOld) { if(typeof TextPrOld[TextPr] == 'object') { /*for(var cpPr in TextPrOld[TextPr]) { if(TextPrOld[TextPr][cpPr] != TextPrNew[TextPr][cpPr]) return false; }*/ this.isEqual(TextPrOld[TextPr],TextPrNew[TextPr]); } else { if(typeof TextPrOld[TextPr] == "number" && typeof TextPrNew[TextPr] == "number") { if(Math.abs(TextPrOld[TextPr] - TextPrNew[TextPr]) > 0.001) return false; } else if(TextPrOld[TextPr] != TextPrNew[TextPr]) return false; } } return true; } } function CParaTab(Value, Pos) { this.Value = Value; this.Pos = Pos; } CParaTab.prototype = { Copy : function() { return new CParaTab(this.Value, this.Pos); } } function CParaTabs() { this.Tabs = []; }; CParaTabs.prototype = { Add : function(_Tab) { var Index = 0; for (Index = 0; Index < this.Tabs.length; Index++ ) { var Tab = this.Tabs[Index]; if ( Math.abs( Tab.Pos - _Tab.Pos ) < 0.001 ) { this.Tabs.splice( Index, 1, _Tab ); break; } if ( Tab.Pos > _Tab.Pos ) break; } if ( -1 != Index ) this.Tabs.splice( Index, 0, _Tab ); }, Merge : function(Tabs) { var _Tabs = Tabs.Tabs; for ( var Index = 0; Index < _Tabs.length; Index++ ) { var _Tab = _Tabs[Index]; var Index2 = 0; var Flag = 0; for (Index2 = 0; Index2 < this.Tabs.length; Index2++ ) { var Tab = this.Tabs[Index2]; if ( Math.abs( Tab.Pos - _Tab.Pos ) < 0.001 ) { if ( tab_Clear === _Tab.Value ) Flag = -2; // таб нужно удалить else Flag = -1; // табы совпали, не надо новый добавлять break; } if ( Tab.Pos > _Tab.Pos ) break; } if ( -2 === Flag ) this.Tabs.splice( Index2, 1 ); else if ( -1 != Flag ) this.Tabs.splice( Index2, 0, _Tab ); } }, Copy : function() { var Tabs = new CParaTabs(); var Count = this.Tabs.length; for ( var Index = 0; Index < Count; Index++ ) Tabs.Add( this.Tabs[Index].Copy() ); return Tabs; }, Set_FromObject : function(Tabs) { if ( Tabs instanceof Array ) { var Count = Tabs.length; for ( var Index = 0; Index < Count; Index++ ) this.Add( new CParaTab( Tabs[Index].Value, Tabs[Index].Pos ) ); } }, Get_Count : function() { return this.Tabs.length; }, Get : function(Index) { return this.Tabs[Index]; }, Get_Value : function(Pos) { var Count = this.Tabs.length; for ( var Index = 0; Index < Count; Index++ ) { var Tab = this.Tabs[Index]; if ( Math.abs(Tab.Pos - Pos) < 0.001 ) return Tab.Value; } return -1; }, Write_ToBinary : function(Writer) { // Long : количество (если 0, удаляем элемент) // Массив // Byte : Value // Double : Pos var Count = this.Tabs.length; Writer.WriteLong( Count ); for ( var Index = 0; Index < Count; Index++ ) { Writer.WriteByte( this.Tabs[Index].Value ); Writer.WriteDouble( this.Tabs[Index].Pos ); } }, Read_FromBinary : function(Reader) { // Long : количество (если 0, удаляем элемент) // Массив // Byte : Value // Double : Pos var Count = Reader.GetLong(); this.Tabs = []; for ( var Index = 0; Index < Count; Index++ ) { var Value = Reader.GetByte(); var Pos = Reader.GetDouble(); this.Add( new CParaTab( Value, Pos ) ); } } } function CParaInd() { this.Left = undefined; // Левый отступ this.Right = undefined; // Правый отступ this.FirstLine = undefined; // Первая строка } CParaInd.prototype = { Copy : function() { var Ind = new CParaInd(); Ind.Left = this.Left; Ind.Right = this.Right; Ind.FirstLine = this.FirstLine; return Ind; }, Merge : function(Ind) { if ( undefined != Ind.Left ) this.Left = Ind.Left; if ( undefined != Ind.Right ) this.Right = Ind.Right; if ( undefined != Ind.FirstLine ) this.FirstLine = Ind.FirstLine; }, Set_FromObject : function(Ind) { if ( undefined != Ind.Left ) this.Left = Ind.Left; else this.Left = undefined; if ( undefined != Ind.Right ) this.Right = Ind.Right; else this.Right = undefined; if ( undefined != Ind.FirstLine ) this.FirstLine = Ind.FirstLine; else this.FirstLine = undefined; }, Write_ToBinary : function(Writer) { var StartPos = Writer.GetCurPosition(); Writer.Skip(4); var Flags = 0; if ( undefined != this.Left ) { Writer.WriteDouble( this.Left ); Flags |= 1; } if ( undefined != this.Right ) { Writer.WriteDouble( this.Right ); Flags |= 2; } if ( undefined != this.FirstLine ) { Writer.WriteDouble( this.FirstLine ); Flags |= 4; } var EndPos = Writer.GetCurPosition(); Writer.Seek( StartPos ); Writer.WriteLong( Flags ); Writer.Seek( EndPos ); }, Read_FromBinary : function(Reader) { var Flags = Reader.GetLong(); if ( Flags & 1 ) this.Left = Reader.GetDouble(); if ( Flags & 2 ) this.Right = Reader.GetDouble(); if ( Flags & 4 ) this.FirstLine = Reader.GetDouble(); } } function CParaSpacing() { this.Line = undefined; // Расстояние между строками внутри абзаца this.LineRule = undefined; // Тип расстрояния между строками this.Before = undefined; // Дополнительное расстояние до абзаца this.BeforeAutoSpacing = undefined; // Использовать ли автоматический расчет расстояния до параграфа this.After = undefined; // Дополнительное расстояние после абзаца this.AfterAutoSpacing = undefined; // Использовать ли автоматический расчет расстояния после параграфа } CParaSpacing.prototype = { Copy : function() { var Spacing = new CParaSpacing(); Spacing.Line = this.Line; Spacing.LineRule = this.LineRule; Spacing.Before = this.Before; Spacing.BeforeAutoSpacing = this.BeforeAutoSpacing; Spacing.After = this.After; Spacing.AfterAutoSpacing = this.AfterAutoSpacing; return Spacing; }, Merge : function(Spacing) { if ( undefined != Spacing.Line ) this.Line = Spacing.Line; if ( undefined != Spacing.LineRule ) this.LineRule = Spacing.LineRule; if ( undefined != Spacing.Before ) this.Before = Spacing.Before; if ( undefined != Spacing.BeforeAutoSpacing ) this.BeforeAutoSpacing = Spacing.BeforeAutoSpacing; if ( undefined != Spacing.After ) this.After = Spacing.After; if ( undefined != Spacing.AfterAutoSpacing ) this.AfterAutoSpacing = Spacing.AfterAutoSpacing; }, Set_FromObject : function(Spacing) { this.Line = Spacing.Line; this.LineRule = Spacing.LineRule; this.Before = Spacing.Before; this.BeforeAutoSpacing = Spacing.BeforeAutoSpacing; this.After = Spacing.After; this.AfterAutoSpacing = Spacing.AfterAutoSpacing; }, Write_ToBinary : function(Writer) { var StartPos = Writer.GetCurPosition(); Writer.Skip(4); var Flags = 0; if ( undefined != this.Line ) { Writer.WriteDouble( this.Line ); Flags |= 1; } if ( undefined != this.LineRule ) { Writer.WriteByte( this.LineRule ); Flags |= 2; } if ( undefined != this.Before ) { Writer.WriteDouble( this.Before ); Flags |= 4; } if ( undefined != this.After ) { Writer.WriteDouble( this.After ); Flags |= 8; } if ( undefined != this.AfterAutoSpacing ) { Writer.WriteBool( this.AfterAutoSpacing ); Flags |= 16; } if ( undefined != this.BeforeAutoSpacing ) { Writer.WriteBool( this.BeforeAutoSpacing ); Flags |= 32; } var EndPos = Writer.GetCurPosition(); Writer.Seek( StartPos ); Writer.WriteLong( Flags ); Writer.Seek( EndPos ); }, Read_FromBinary : function(Reader) { var Flags = Reader.GetLong(); if ( Flags & 1 ) this.Line = Reader.GetDouble(); if ( Flags & 2 ) this.LineRule = Reader.GetByte(); if ( Flags & 4 ) this.Before = Reader.GetDouble(); if ( Flags & 8 ) this.After = Reader.GetDouble(); if ( Flags & 16 ) this.AfterAutoSpacing = Reader.GetBool(); if ( Flags & 32 ) this.BeforeAutoSpacing = Reader.GetBool(); } } function CNumPr() { this.NumId = "-1"; this.Lvl = 0; } CNumPr.prototype = { Copy : function() { var NumPr = new CNumPr(); NumPr.NumId = this.NumId; NumPr.Lvl = this.Lvl; return NumPr; }, Merge : function(NumPr) { if ( undefined != NumPr.NumId ) this.NumId = NumPr.NumId; if ( undefined != NumPr.Lvl ) this.Lvl = NumPr.Lvl; }, Set : function(NumId, Lvl) { this.NumId = NumId; this.Lvl = Lvl; }, Set_FromObject : function(NumPr) { this.NumId = NumPr.NumId; this.Lvl = NumPr.Lvl; }, Write_ToBinary : function(Writer) { // Bool : Is NumId undefined // String : NumId // Bool : IsLvl undefined // Byte : Lvl if ( undefined === this.NumId ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); Writer.WriteString2( this.NumId ); } if ( undefined === this.Lvl ) Writer.WriteBool( true ); else { Writer.WriteBool( false ); Writer.WriteByte( this.Lvl ); } }, Read_FromBinary : function(Reader) { // Bool : Is NumId undefined // String : NumId // Byte : Lvl if ( true === Reader.GetBool() ) this.NumId = undefined; else this.NumId = Reader.GetString2(); if ( true === Reader.GetBool() ) this.Lvl = undefined; else this.Lvl = Reader.GetByte(); } }; var dropcap_None = 0x00; var dropcap_Drop = 0x01; var dropcap_Margin = 0x02; var wrap_Around = 0x01; var wrap_Auto = 0x02; var wrap_None = 0x03; var wrap_NotBeside = 0x04; var wrap_Through = 0x05; var wrap_Tight = 0x06; function CFramePr() { this.DropCap = undefined; // Является ли данный элемент буквицей this.H = undefined; this.HAnchor = undefined; this.HRule = undefined; this.HSpace = undefined; this.Lines = undefined; this.VAnchor = undefined; this.VSpace = undefined; this.W = undefined; this.Wrap = undefined; this.X = undefined; this.XAlign = undefined; this.Y = undefined; this.YAlign = undefined; } CFramePr.prototype = { Copy : function() { var FramePr = new CFramePr(); FramePr.DropCap = this.DropCap; FramePr.H = this.H; FramePr.HAnchor = this.HAnchor; FramePr.HRule = this.HRule; FramePr.HSpace = this.HSpace; FramePr.Lines = this.Lines; FramePr.VAnchor = this.VAnchor; FramePr.VSpace = this.VSpace; FramePr.W = this.W; FramePr.Wrap = this.Wrap; FramePr.X = this.X; FramePr.XAlign = this.XAlign; FramePr.Y = this.Y; FramePr.YAlign = this.YAlign; return FramePr; }, Compare : function(FramePr) { if ( this.DropCap != FramePr.DropCap || Math.abs(this.H - FramePr.H) > 0.001 || this.HAnchor != FramePr.HAnchor || this.HRule != FramePr.HRule || this.HSpace != FramePr.HSpace || this.Lines != FramePr.Lines || this.VAnchor != FramePr.VAnchor || this.VSpace != FramePr.VSpace || Math.abs( this.W - FramePr.W ) > 0.001 || this.Wrap != FramePr.Wrap || Math.abs( this.X - FramePr.X ) > 0.001 || this.XAlign != FramePr.XAlign || Math.abs( this.Y - FramePr.Y ) > 0.001 || this.YAlign != FramePr.YAlign ) return false; return true; }, Set_FromObject : function(FramePr) { this.DropCap = FramePr.DropCap; this.H = FramePr.H; this.HAnchor = FramePr.HAnchor; this.HRule = FramePr.HRule; this.HSpace = FramePr.HSpace; this.Lines = FramePr.Lines; this.VAnchor = FramePr.VAnchor; this.VSpace = FramePr.VSpace; this.W = FramePr.W; this.Wrap = FramePr.Wrap; this.X = FramePr.X; this.XAlign = FramePr.XAlign; this.Y = FramePr.Y; this.YAlign = FramePr.YAlign; }, Write_ToBinary : function(Writer) { var StartPos = Writer.GetCurPosition(); Writer.Skip(4); var Flags = 0; if ( undefined != this.DropCap ) { Writer.WriteLong( this.DropCap ); Flags |= 1; } if ( undefined != this.H ) { Writer.WriteDouble( this.H ); Flags |= 2; } if ( undefined != this.HAnchor ) { Writer.WriteLong( this.HAnchor ); Flags |= 4; } if ( undefined != this.HRule ) { Writer.WriteLong( this.HRule ); Flags |= 8; } if ( undefined != this.HSpace ) { Writer.WriteDouble( this.HSpace ); Flags |= 16; } if ( undefined != this.Lines ) { Writer.WriteLong( this.Lines ); Flags |= 32; } if ( undefined != this.VAnchor ) { Writer.WriteLong( this.VAnchor ); Flags |= 64; } if ( undefined != this.VSpace ) { Writer.WriteDouble( this.VSpace ); Flags |= 128; } if ( undefined != this.W ) { Writer.WriteDouble( this.W ); Flags |= 256; } if ( undefined != this.X ) { Writer.WriteDouble( this.X ); Flags |= 512; } if ( undefined != this.XAlign ) { Writer.WriteLong( this.XAlign ); Flags |= 1024; } if ( undefined != this.Y ) { Writer.WriteDouble( this.Y ); Flags |= 2048; } if ( undefined != this.YAlign ) { Writer.WriteLong( this.YAlign ); Flags |= 4096; } var EndPos = Writer.GetCurPosition(); Writer.Seek( StartPos ); Writer.WriteLong( Flags ); Writer.Seek( EndPos ); }, Read_FromBinary : function(Reader) { var Flags = Reader.GetLong(); if ( Flags & 1 ) this.DropCap = Reader.GetLong(); if ( Flags & 2 ) this.H = Reader.GetDouble(); if ( Flags & 4 ) this.HAnchor = Reader.GetLong(); if ( Flags & 8 ) this.HRule = Reader.GetLong(); if ( Flags & 16 ) this.HSpace = Reader.GetDouble(); if ( Flags & 32 ) this.Lines = Reader.GetLong(); if ( Flags & 64 ) this.VAnchor = Reader.GetLong(); if ( Flags & 128 ) this.VSpace = Reader.GetDouble(); if ( Flags & 256 ) this.W = Reader.GetDouble(); if ( Flags & 512 ) this.X = Reader.GetDouble(); if ( Flags & 1024 ) this.XAlign = Reader.GetLong(); if ( Flags & 2048 ) this.Y = Reader.GetDouble(); if ( Flags & 4096 ) this.YAlign = Reader.GetLong(); }, Init_Default_DropCap : function(bInside) { this.DropCap = ( true === bInside ? dropcap_Drop : dropcap_Margin ); this.Lines = 3; this.Wrap = wrap_Around; this.VAnchor = c_oAscVAnchor.Text; this.HAnchor = ( true === bInside ? c_oAscHAnchor.Text : c_oAscHAnchor.Page ); this.X = undefined; this.XAlign = undefined; this.Y = undefined; this.YAlign = undefined; this.H = undefined; this.W = undefined; this.HRule = undefined; }, Get_W : function() { return this.W; }, Get_H : function() { return this.H; }, Is_DropCap : function() { if ( dropcap_Margin === this.DropCap || dropcap_Drop === this.DropCap ) return true; return false; } }; function CParaPr() { this.ContextualSpacing = undefined; // Удалять ли интервал между параграфами одинакового стиля this.Ind = new CParaInd(); // Отступы this.Jc = undefined; // Прилегание параграфа this.KeepLines = undefined; // Неразрывный параграф this.KeepNext = undefined; // Не разъединять со следующим параграфом this.PageBreakBefore = undefined; // Разрыв страницы перед параграфом this.Spacing = new CParaSpacing(); // Расстояния между строками внутри параграфа и между параграфами this.Shd = undefined; // Заливка параграфа this.Brd = { First : undefined, // Является ли данный параграф первым в группе параграфов с одинаковыми краями и настройками границ Last : undefined, // Является ли данный параграф последним в группе параграфов с одинаковыми краями и настройками границ Between : undefined, Bottom : undefined, Left : undefined, Right : undefined, Top : undefined }; this.WidowControl = undefined; // Запрет висячих строк this.Tabs = undefined; // Заданные табы this.NumPr = undefined; // Нумерация this.PStyle = undefined; // Стиль параграфа this.FramePr = undefined; this.DefaultRunPr = undefined; this.Bullet = undefined; this.Lvl = undefined; } CParaPr.prototype = { Copy : function() { var ParaPr = new CParaPr(); ParaPr.ContextualSpacing = this.ContextualSpacing; if ( undefined != this.Ind ) ParaPr.Ind = this.Ind.Copy(); ParaPr.Jc = this.Jc; ParaPr.KeepLines = this.KeepLines; ParaPr.KeepNext = this.KeepNext; ParaPr.PageBreakBefore = this.PageBreakBefore; if ( undefined != this.Spacing ) ParaPr.Spacing = this.Spacing.Copy(); if ( undefined != this.Shd ) ParaPr.Shd = this.Shd.Copy(); ParaPr.Brd.First = this.Brd.First; ParaPr.Brd.Last = this.Brd.Last; if ( undefined != this.Brd.Between ) ParaPr.Brd.Between = this.Brd.Between.Copy(); if ( undefined != this.Brd.Bottom ) ParaPr.Brd.Bottom = this.Brd.Bottom.Copy(); if ( undefined != this.Brd.Left ) ParaPr.Brd.Left = this.Brd.Left.Copy(); if ( undefined != this.Brd.Right ) ParaPr.Brd.Right = this.Brd.Right.Copy(); if ( undefined != this.Brd.Top ) ParaPr.Brd.Top = this.Brd.Top.Copy(); ParaPr.WidowControl = this.WidowControl; if ( undefined != this.Tabs ) ParaPr.Tabs = this.Tabs.Copy(); if ( undefined != this.NumPr ) ParaPr.NumPr = this.NumPr.Copy(); if ( undefined != this.PStyle ) ParaPr.PStyle = this.PStyle; if ( undefined != this.FramePr ) ParaPr.FramePr = this.FramePr.Copy(); else ParaPr.FramePr = undefined; if( undefined != this.DefaultRunPr) ParaPr.DefaultRunPr = this.DefaultRunPr.Copy(); if( undefined != this.Bullet) ParaPr.Bullet = this.Bullet.createDuplicate(); if(undefined != this.Lvl) ParaPr.Lvl = this.Lvl; return ParaPr; }, Merge : function(ParaPr) { if ( undefined != ParaPr.ContextualSpacing ) this.ContextualSpacing = ParaPr.ContextualSpacing; if ( undefined != ParaPr.Ind ) this.Ind.Merge( ParaPr.Ind ); if ( undefined != ParaPr.Jc ) this.Jc = ParaPr.Jc; if ( undefined != ParaPr.KeepLines ) this.KeepLines = ParaPr.KeepLines; if ( undefined != ParaPr.KeepNext ) this.KeepNext = ParaPr.KeepNext; if ( undefined != ParaPr.PageBreakBefore ) this.PageBreakBefore = ParaPr.PageBreakBefore; if ( undefined != ParaPr.Spacing ) this.Spacing.Merge( ParaPr.Spacing ); if ( undefined != ParaPr.Shd ) this.Shd = ParaPr.Shd.Copy(); if ( undefined != ParaPr.Brd.First ) this.Brd.First = ParaPr.Brd.First; if ( undefined != ParaPr.Brd.Last ) this.Brd.Last = ParaPr.Brd.Last; if ( undefined != ParaPr.Brd.Between ) this.Brd.Between = ParaPr.Brd.Between.Copy(); if ( undefined != ParaPr.Brd.Bottom ) this.Brd.Bottom = ParaPr.Brd.Bottom.Copy(); if ( undefined != ParaPr.Brd.Left ) this.Brd.Left = ParaPr.Brd.Left.Copy(); if ( undefined != ParaPr.Brd.Right ) this.Brd.Right = ParaPr.Brd.Right.Copy(); if ( undefined != ParaPr.Brd.Top ) this.Brd.Top = ParaPr.Brd.Top.Copy(); if ( undefined != ParaPr.WidowControl ) this.WidowControl = ParaPr.WidowControl; if ( undefined != ParaPr.Tabs ) { if ( undefined === this.Tabs ) this.Tabs = ParaPr.Tabs.Copy(); else this.Tabs.Merge( ParaPr.Tabs ); } if ( undefined != ParaPr.NumPr ) { if ( undefined === this.NumPr ) this.NumPr = ParaPr.NumPr.Copy(); else this.NumPr.Merge( ParaPr.NumPr ); if ( undefined != this.NumPr && this.NumPr.Lvl > 8 ) this.NumPr = undefined; } if ( undefined != ParaPr.PStyle ) this.PStyle = ParaPr.PStyle; this.FramePr = undefined; if( undefined != ParaPr.DefaultRunPr ) { if( undefined == this.DefaultRunPr ) this.DefaultRunPr = new CTextPr(); this.DefaultRunPr.Merge(ParaPr.DefaultRunPr); } if( undefined != ParaPr.Bullet && ParaPr.Bullet.isBullet()) this.Bullet = ParaPr.Bullet.createDuplicate(); if(undefined != ParaPr.Lvl) this.Lvl = ParaPr.Lvl; }, Init_Default : function() { this.ContextualSpacing = false; this.Ind = new CParaInd(); this.Ind.Left = 0; this.Ind.Right = 0; this.Ind.FirstLine = 0; this.Jc = align_Left; this.KeepLines = false; this.KeepNext = false; this.PageBreakBefore = false; this.Spacing = new CParaSpacing(); this.Spacing.Line = 1.15; this.Spacing.LineRule = linerule_Auto; this.Spacing.Before = 0; this.Spacing.BeforeAutoSpacing = false; this.Spacing.After = 10 * g_dKoef_pt_to_mm; this.Spacing.AfterAutoSpacing = false; this.Shd = new CDocumentShd(); this.Brd.First = true; this.Brd.Last = true; this.Brd.Between = new CDocumentBorder(); this.Brd.Bottom = new CDocumentBorder(); this.Brd.Left = new CDocumentBorder(); this.Brd.Right = new CDocumentBorder(); this.Brd.Top = new CDocumentBorder(); this.WidowControl = true; this.Tabs = new CParaTabs(); this.NumPr = undefined; this.PStyle = undefined; this.FramePr = undefined; this.DefaultRunPr = undefined; this.Bullet = undefined; }, Set_FromObject : function(ParaPr) { this.ContextualSpacing = ParaPr.ContextualSpacing; if ( undefined != ParaPr.Ind ) { this.Ind = new CParaInd(); this.Ind.Set_FromObject( ParaPr.Ind ); } else this.Ind = undefined; this.Jc = ParaPr.Jc; this.KeepLines = ParaPr.KeepLines; this.KeepNext = ParaPr.KeepNext; this.PageBreakBefore = ParaPr.PageBreakBefore; if ( undefined != ParaPr.Spacing ) { this.Spacing = new CParaSpacing(); this.Spacing.Set_FromObject( ParaPr.Spacing ); } else this.Spacing = undefined; if ( undefined != ParaPr.Shd ) { this.Shd = new CDocumentShd(); this.Shd.Set_FromObject( ParaPr.Shd ); } else this.Shd = undefined; if ( undefined != ParaPr.Brd ) { if ( undefined != ParaPr.Brd.Between ) { this.Brd.Between = new CDocumentBorder(); this.Brd.Between.Set_FromObject( ParaPr.Brd.Between ); } else this.Brd.Between = undefined; if ( undefined != ParaPr.Brd.Bottom ) { this.Brd.Bottom = new CDocumentBorder(); this.Brd.Bottom.Set_FromObject( ParaPr.Brd.Bottom ); } else this.Brd.Bottom = undefined; if ( undefined != ParaPr.Brd.Left ) { this.Brd.Left = new CDocumentBorder(); this.Brd.Left.Set_FromObject( ParaPr.Brd.Left ); } else this.Brd.Left = undefined; if ( undefined != ParaPr.Brd.Right ) { this.Brd.Right = new CDocumentBorder(); this.Brd.Right.Set_FromObject( ParaPr.Brd.Right ); } else this.Brd.Right = undefined; if ( undefined != ParaPr.Brd.Top ) { this.Brd.Top = new CDocumentBorder(); this.Brd.Top.Set_FromObject( ParaPr.Brd.Top ); } else this.Brd.Top = undefined; } else { this.Brd.Between = undefined; this.Brd.Bottom = undefined; this.Brd.Left = undefined; this.Brd.Right = undefined; this.Brd.Top = undefined; } this.WidowControl = ParaPr.WidowControl; if ( undefined != ParaPr.Tabs ) { this.Tabs = new CParaTabs(); this.Tabs.Set_FromObject( ParaPr.Tabs.Tabs ); } else this.Tabs = undefined; if ( undefined != ParaPr.NumPr ) { this.NumPr = new CNumPr(); this.NumPr.Set_FromObject( ParaPr.NumPr ); } else this.NumPr = undefined; if ( undefined != ParaPr.FramePr ) { this.FramePr = new CFramePr(); this.FramePr.Set_FromObject( ParaPr.FramePr ); } else this.FramePr = undefined; if( undefined != ParaPr.DefaultRunPr ) { this.DefaultRunPr = new CTextPr(); this.DefaultRunPr.Set_FromObject(ParaPr.DefaultRunPr); } if( undefined != ParaPr.Bullet ) { this.Bullet = new CBullet(); this.Bullet.Set_FromObject(ParaPr.Bullet); } }, Compare : function(ParaPr) { // При сравнении добавляем 1 элемент Locked var Result_ParaPr = new CParaPr(); Result_ParaPr.Locked = false; if ( ParaPr.ContextualSpacing === this.ContextualSpacing ) Result_ParaPr.ContextualSpacing = ParaPr.ContextualSpacing; Result_ParaPr.Ind = new CParaInd(); if ( undefined != ParaPr.Ind && undefined != this.Ind ) { if ( undefined != ParaPr.Ind.Left && undefined != this.Ind.Left && Math.abs( ParaPr.Ind.Left - this.Ind.Left ) < 0.001 ) Result_ParaPr.Ind.Left = ParaPr.Ind.Left; if ( undefined != ParaPr.Ind.Right && undefined != this.Ind.Right && Math.abs( ParaPr.Ind.Right - this.Ind.Right ) < 0.001 ) Result_ParaPr.Ind.Right = ParaPr.Ind.Right; if ( undefined != ParaPr.Ind.FirstLine && undefined != this.Ind.FirstLine && Math.abs( ParaPr.Ind.FirstLine - this.Ind.FirstLine ) < 0.001 ) Result_ParaPr.Ind.FirstLine = ParaPr.Ind.FirstLine; } if ( ParaPr.Jc === this.Jc ) Result_ParaPr.Jc = ParaPr.Jc; if ( ParaPr.KeepLines === this.KeepLines ) Result_ParaPr.KeepLines = ParaPr.KeepLines; if ( ParaPr.KeepNext === this.KeepNext ) Result_ParaPr.KeepNext = ParaPr.KeepNext; if ( ParaPr.PageBreakBefore === this.PageBreakBefore ) Result_ParaPr.PageBreakBefore = ParaPr.PageBreakBefore; Result_ParaPr.Spacing = new CParaSpacing(); if ( undefined != this.Spacing && undefined != ParaPr.Spacing ) { if ( undefined != this.Spacing.After && undefined != ParaPr.Spacing.After && Math.abs( this.Spacing.After - ParaPr.Spacing.After ) < 0.001 ) Result_ParaPr.Spacing.After = ParaPr.Spacing.After; if ( this.Spacing.AfterAutoSpacing === ParaPr.Spacing.AfterAutoSpacing ) Result_ParaPr.Spacing.AfterAutoSpacing = ParaPr.Spacing.AfterAutoSpacing; if ( undefined != this.Spacing.Before && undefined != ParaPr.Spacing.Before && Math.abs( this.Spacing.Before - ParaPr.Spacing.Before ) < 0.001 ) Result_ParaPr.Spacing.Before = ParaPr.Spacing.Before; if ( this.Spacing.BeforeAutoSpacing === ParaPr.Spacing.BeforeAutoSpacing ) Result_ParaPr.Spacing.BeforeAutoSpacing = ParaPr.Spacing.BeforeAutoSpacing; if ( undefined != this.Spacing.Line && undefined != ParaPr.Spacing.Line && Math.abs( this.Spacing.Line - ParaPr.Spacing.Line ) < 0.001 ) Result_ParaPr.Spacing.Line = ParaPr.Spacing.Line; if ( this.Spacing.LineRule === ParaPr.Spacing.LineRule ) Result_ParaPr.Spacing.LineRule = ParaPr.Spacing.LineRule; } if ( undefined != this.Shd && undefined != ParaPr.Shd && true === this.Shd.Compare(ParaPr.Shd) ) Result_ParaPr.Shd = ParaPr.Shd.Copy(); if ( undefined != this.Brd.Between && undefined != ParaPr.Brd.Between && true === this.Brd.Between.Compare( ParaPr.Brd.Between ) ) Result_ParaPr.Brd.Between = ParaPr.Brd.Between.Copy(); if ( undefined != this.Brd.Bottom && undefined != ParaPr.Brd.Bottom && true === this.Brd.Bottom.Compare( ParaPr.Brd.Bottom ) ) Result_ParaPr.Brd.Bottom = ParaPr.Brd.Bottom.Copy(); if ( undefined != this.Brd.Left && undefined != ParaPr.Brd.Left && true === this.Brd.Left.Compare( ParaPr.Brd.Left ) ) Result_ParaPr.Brd.Left = ParaPr.Brd.Left.Copy(); if ( undefined != this.Brd.Right && undefined != ParaPr.Brd.Right && true === this.Brd.Right.Compare( ParaPr.Brd.Right ) ) Result_ParaPr.Brd.Right = ParaPr.Brd.Right.Copy(); if ( undefined != this.Brd.Top && undefined != ParaPr.Brd.Top && true === this.Brd.Top.Compare( ParaPr.Brd.Top ) ) Result_ParaPr.Brd.Top = ParaPr.Brd.Top.Copy(); if ( ParaPr.WidowControl === this.WidowControl ) Result_ParaPr.WidowControl = ParaPr.WidowControl; // PStyle if ( undefined != this.PStyle && undefined != ParaPr.PStyle && this.PStyle === ParaPr.PStyle ) Result_ParaPr.PStyle = ParaPr.PStyle; // NumPr if ( undefined != this.NumPr && undefined != ParaPr.NumPr && this.NumPr.NumId === ParaPr.NumPr.NumId ) { Result_ParaPr.NumPr = new CParaPr(); Result_ParaPr.NumPr.NumId = ParaPr.NumPr.NumId; Result_ParaPr.NumPr.Lvl = Math.max( this.NumPr.Lvl, ParaPr.NumPr.Lvl ); } // Locked if ( undefined != this.Locked && undefined != ParaPr.Locked ) { if ( this.Locked != ParaPr.Locked ) Result_ParaPr.Locked = true; else Result_ParaPr.Locked = ParaPr.Locked; } // FramePr if ( undefined != this.FramePr && undefined != ParaPr.FramePr && true === this.FramePr.Compare(ParaPr.FramePr) ) Result_ParaPr.FramePr = this.FramePr; if(undefined != this.Bullet && undefined != ParaPr.Bullet ) Result_ParaPr.Bullet = CompareBullets(ParaPr.Bullet, this.Bullet); if(undefined != this.DefaultRunPr && undefined != ParaPr.DefaultRunPr) Result_ParaPr.DefaultRunPr = this.DefaultRunPr.Compare(ParaPr.DefaultRunPr); if(undefined != this.Lvl && undefined != ParaPr.Lvl && ParaPr.Lvl === this.Lvl) Result_ParaPr.Lvl = this.Lvl; return Result_ParaPr; }, Write_ToBinary : function(Writer) { var StartPos = Writer.GetCurPosition(); Writer.Skip(4); var Flags = 0; if ( undefined != this.ContextualSpacing ) { Writer.WriteBool( this.ContextualSpacing ); Flags |= 1; } if ( undefined != this.Ind ) { this.Ind.Write_ToBinary(Writer); Flags |= 2; } if ( undefined != this.Jc ) { Writer.WriteByte( this.Jc ); Flags |= 4; } if ( undefined != this.KeepLines ) { Writer.WriteBool( this.KeepLines ); Flags |= 8; } if ( undefined != this.KeepNext ) { Writer.WriteBool( this.KeepNext ); Flags |= 16; } if ( undefined != this.PageBreakBefore ) { Writer.WriteBool( this.PageBreakBefore ); Flags |= 32; } if ( undefined != this.Spacing ) { this.Spacing.Write_ToBinary(Writer); Flags |= 64; } if ( undefined != this.Shd ) { this.Shd.Write_ToBinary(Writer); Flags |= 128; } if ( undefined != this.Brd.Between ) { this.Brd.Between.Write_ToBinary( Writer ); Flags |= 256; } if ( undefined != this.Brd.Bottom ) { this.Brd.Bottom.Write_ToBinary( Writer ); Flags |= 512; } if ( undefined != this.Brd.Left ) { this.Brd.Left.Write_ToBinary( Writer ); Flags |= 1024; } if ( undefined != this.Brd.Right ) { this.Brd.Right.Write_ToBinary( Writer ); Flags |= 2048; } if ( undefined != this.Brd.Top ) { this.Brd.Top.Write_ToBinary( Writer ); Flags |= 4096; } if ( undefined != this.WidowControl ) { Writer.WriteBool( this.WidowControl ); Flags |= 8192; } if ( undefined != this.Tabs ) { this.Tabs.Write_ToBinary( Writer ); Flags |= 16384; } if ( undefined != this.NumPr ) { this.NumPr.Write_ToBinary( Writer ); Flags |= 32768; } if ( undefined != this.PStyle ) { Writer.WriteString2( this.PStyle ); Flags |= 65536; } if ( undefined != this.FramePr ) { this.FramePr.Write_ToBinary( Writer ); Flags |= 131072; } if(undefined != this.DefaultRunPr) { this.DefaultRunPr.Write_ToBinary( Writer ); Flags |= 262144; } if(undefined != this.Bullet) { this.Bullet.Write_ToBinary( Writer ); Flags |= 524288; } if(undefined != this.Lvl) { Writer.WriteByte(this.Lvl); Flags |= 1048576; } var EndPos = Writer.GetCurPosition(); Writer.Seek( StartPos ); Writer.WriteLong( Flags ); Writer.Seek( EndPos ); }, Read_FromBinary : function(Reader) { var Flags = Reader.GetLong(); if ( Flags & 1 ) this.ContextualSpacing = Reader.GetBool(); if ( Flags & 2 ) { this.Ind = new CParaInd(); this.Ind.Read_FromBinary( Reader ); } if ( Flags & 4 ) this.Jc = Reader.GetByte(); if ( Flags & 8 ) this.KeepLines = Reader.GetBool(); if ( Flags & 16 ) this.KeepNext = Reader.GetBool(); if ( Flags & 32 ) this.PageBreakBefore = Reader.GetBool(); if ( Flags & 64 ) { this.Spacing = new CParaSpacing(); this.Spacing.Read_FromBinary( Reader ); } if ( Flags & 128 ) { this.Shd = new CDocumentShd(); this.Shd.Read_FromBinary( Reader ); } if ( Flags & 256 ) { this.Brd.Between = new CDocumentBorder(); this.Brd.Between.Read_FromBinary( Reader ); } if ( Flags & 512 ) { this.Brd.Bottom = new CDocumentBorder(); this.Brd.Bottom.Read_FromBinary( Reader ); } if ( Flags & 1024 ) { this.Brd.Left = new CDocumentBorder(); this.Brd.Left.Read_FromBinary( Reader ); } if ( Flags & 2048 ) { this.Brd.Right = new CDocumentBorder(); this.Brd.Right.Read_FromBinary( Reader ); } if ( Flags & 4096 ) { this.Brd.Top = new CDocumentBorder(); this.Brd.Top.Read_FromBinary( Reader ); } if ( Flags & 8192 ) this.WidowControl = Reader.GetBool(); if ( Flags & 16384 ) { this.Tabs = new CParaTabs(); this.Tabs.Read_FromBinary( Reader ); } if ( Flags & 32768 ) { this.NumPr = new CNumPr(); this.NumPr.Read_FromBinary( Reader ); } if ( Flags & 65536 ) this.PStyle = Reader.GetString2(); if ( Flags & 131072 ) { this.FramePr = new CFramePr(); this.FramePr.Read_FromBinary( Reader ); } if(Flags & 262144) { this.DefaultRunPr = new CTextPr(); this.DefaultRunPr.Read_FromBinary(Reader); } if(Flags & 524288) { this.Bullet = new CBullet(); this.Bullet.Read_FromBinary(Reader); } if(Flags & 1048576) { this.Lvl = Reader.GetByte(); } }, isEqual: function(ParaPrUOld,ParaPrNew) { if(ParaPrUOld == undefined || ParaPrNew == undefined) return false; for(var pPr in ParaPrUOld) { if(typeof ParaPrUOld[pPr] == 'object') { if(!this.isEqual(ParaPrUOld[pPr],ParaPrNew[pPr])) return false } else { if(typeof ParaPrUOld[pPr] == "number" && typeof ParaPrNew[pPr] == "number") { if(Math.abs(ParaPrUOld[pPr] - ParaPrNew[pPr]) > 0.001) return false; } else if(ParaPrUOld[pPr] != ParaPrNew[pPr]) return false; } } return true; }, Get_PresentationBullet: function() { var Bullet = new CPresentationBullet(); if(this.Bullet && this.Bullet.isBullet()) { switch(this.Bullet.bulletType.type) { case BULLET_TYPE_BULLET_CHAR: { Bullet.m_nType = numbering_presentationnumfrmt_Char; Bullet.m_sChar = this.Bullet.bulletType.Char; if(this.Bullet.bulletTypeface && this.Bullet.bulletTypeface.type == BULLET_TYPE_TYPEFACE_BUFONT) { Bullet.m_bFontTx = false; Bullet.m_sFont = this.Bullet.bulletTypeface.typeface; } break; } case BULLET_TYPE_BULLET_AUTONUM : { Bullet.m_nType = g_NumberingArr[this.Bullet.bulletType.AutoNumType]; Bullet.m_nStartAt = this.Bullet.bulletType.startAt; if(this.Bullet.bulletTypeface && this.Bullet.bulletTypeface.type == BULLET_TYPE_TYPEFACE_BUFONT) { Bullet.m_bFontTx = false; Bullet.m_sFont = this.Bullet.bulletTypeface.typeface; } break; } case BULLET_TYPE_BULLET_NONE : { break; } case BULLET_TYPE_BULLET_BLIP : { Bullet.m_nType = numbering_presentationnumfrmt_Char; Bullet.m_sChar = "•"; break; } } } return Bullet; } } function Copy_Bounds(Bounds) { if ( undefined === Bounds ) return {}; var Bounds_new = {}; Bounds_new.Bottom = Bounds.Bottom; Bounds_new.Left = Bounds.Left; Bounds_new.Right = Bounds.Right; Bounds_new.Top = Bounds.Top; return Bounds_new; }