Commit cdcc0209 authored by Ilya Kirillov's avatar Ilya Kirillov

Added new class CFootnotePr.

parent 699eb1bb
......@@ -2231,6 +2231,10 @@
window['AscDFH'].historyitem_Section_Columns_Sep = 25;
window['AscDFH'].historyitem_Section_Columns_Col = 26;
window['AscDFH'].historyitem_Section_Columns_SetCols = 27;
window['AscDFH'].historyitem_Section_Footnote_Pos = 28;
window['AscDFH'].historyitem_Section_Footnote_NumStart = 29;
window['AscDFH'].historyitem_Section_Footnote_NumRestart = 30;
window['AscDFH'].historyitem_Section_Footnote_NumFormat = 31;
// Тип класса, к которому относится данный элемент истории
window['AscDFH'].historyitem_State_Unknown = 0;
......@@ -2366,6 +2370,10 @@
window['AscDFH'].historyitem_Footnotes_SetSeparator = 2;
window['AscDFH'].historyitem_Footnotes_SetContinuationSeparator = 3;
window['AscDFH'].historyitem_Footnotes_SetContinuationNotice = 4;
window['AscDFH'].historyitem_Footnotes_SetFootnotePrPos = 5;
window['AscDFH'].historyitem_Footnotes_SetFootnotePrNumStart = 6;
window['AscDFH'].historyitem_Footnotes_SetFootnotePrNumRestart = 7;
window['AscDFH'].historyitem_Footnotes_SetFootnotePrNumFormat = 8;
window['AscDFH'].historydescription_Cut = 0x0001;
window['AscDFH'].historydescription_PasteButtonIE = 0x0002;
......
......@@ -44,6 +44,9 @@ function CFootnotesController(LogicDocument)
this.Id = LogicDocument.Get_IdCounter().Get_NewId();
this.FootnotePr = new CFootnotePr(); // Глобальные настройки для сносок
this.FootnotePr.InitDefault();
this.Footnote = {}; // Список всех сносок с ключом - Id.
this.Pages = [];
......@@ -114,7 +117,10 @@ CFootnotesController.prototype.CreateFootnote = function()
this.Footnote[NewFootnote.Get_Id()] = NewFootnote;
var oHistory = this.LogicDocument.Get_History();
oHistory.Add(this, {Type : AscDFH.historyitem_Footnotes_AddFootnote, Id : NewFootnote.Get_Id()});
oHistory.Add(this, {
Type : AscDFH.historyitem_Footnotes_AddFootnote,
Id : NewFootnote.Get_Id()
});
return NewFootnote;
};
......@@ -126,7 +132,10 @@ CFootnotesController.prototype.AddFootnote = function(oFootnote)
{
this.Footnote[oFootnote.Get_Id()] = oFootnote;
var oHistory = this.LogicDocument.Get_History();
oHistory.Add(this, {Type : AscDFH.historyitem_Footnotes_AddFootnote, Id : oFootnote.Get_Id()});
oHistory.Add(this, {
Type : AscDFH.historyitem_Footnotes_AddFootnote,
Id : oFootnote.Get_Id()
});
};
CFootnotesController.prototype.SetSeparator = function(oFootnote)
{
......@@ -134,7 +143,11 @@ CFootnotesController.prototype.SetSeparator = function(oFootnote)
var oOldValue = this.SeparatorFootnote ? this.SeparatorFootnote : null;
var oHistory = this.LogicDocument.Get_History();
oHistory.Add(this, {Type : AscDFH.historyitem_Footnotes_SetSeparator, New : oNewValue, Old : oOldValue});
oHistory.Add(this, {
Type : AscDFH.historyitem_Footnotes_SetSeparator,
New : oNewValue,
Old : oOldValue
});
this.SeparatorFootnote = oNewValue;
};
......@@ -144,7 +157,11 @@ CFootnotesController.prototype.SetContinuationSeparator = function(oFootnote)
var oOldValue = this.ContinuationSeparatorFootnote ? this.ContinuationSeparatorFootnote : null;
var oHistory = this.LogicDocument.Get_History();
oHistory.Add(this, {Type : AscDFH.historyitem_Footnotes_SetContinuationSeparator, New : oNewValue, Old : oOldValue});
oHistory.Add(this, {
Type : AscDFH.historyitem_Footnotes_SetContinuationSeparator,
New : oNewValue,
Old : oOldValue
});
this.ContinuationSeparatorFootnote = oNewValue;
};
......@@ -154,10 +171,66 @@ CFootnotesController.prototype.SetContinuationNotice = function(oFootnote)
var oOldValue = this.ContinuationNoticeFootnote ? this.ContinuationNoticeFootnote : null;
var oHistory = this.LogicDocument.Get_History();
oHistory.Add(this, {Type : AscDFH.historyitem_Footnotes_SetContinuationNotice, New : oNewValue, Old : oOldValue});
oHistory.Add(this, {
Type : AscDFH.historyitem_Footnotes_SetContinuationNotice,
New : oNewValue,
Old : oOldValue
});
this.ContinuationNoticeFootnote = oNewValue;
};
CFootnotesController.prototype.SetFootnotePrNumFormat = function(nFormatType)
{
if (undefined !== nFormatType && this.FootnotePr.NumFormat !== nFormatType)
{
var oHistory = this.LogicDocument.Get_History();
oHistory.Add(this, {
Type : AscDFH.historyitem_Footnotes_SetFootnotePrNumFormat,
New : nFormatType,
Old : this.FootnotePr.NumFormat
});
this.FootnotePr.NumFormat = nFormatType;
}
};
CFootnotesController.prototype.SetFootnotePrPos = function(nPos)
{
if (undefined !== nPos && this.FootnotePr.Pos !== nPos)
{
var oHistory = this.LogicDocument.Get_History();
oHistory.Add(this, {
Type : AscDFH.historyitem_Footnotes_SetFootnotePrPos,
New : nPos,
Old : this.FootnotePr.Pos
});
this.FootnotePr.Pos = nPos;
}
};
CFootnotesController.prototype.SetFootnotePrNumStart = function(nStart)
{
if (undefined !== nStart && this.FootnotePr.NumStart !== nStart)
{
var oHistory = this.LogicDocument.Get_History();
oHistory.Add(this, {
Type : AscDFH.historyitem_Footnotes_SetFootnotePrNumStart,
New : nStart,
Old : this.FootnotePr.NumStart
});
this.FootnotePr.NumStart = nStart;
}
};
CFootnotesController.prototype.SetFootnotePrNumRestart = function(nRestartType)
{
if (undefined !== nRestartType && this.FootnotePr.NumRestart !== nRestartType)
{
var oHistory = this.LogicDocument.Get_History();
oHistory.Add(this, {
Type : AscDFH.historyitem_Footnotes_SetFootnotePrNumRestart,
New : nRestartType,
Old : this.FootnotePr.NumRestart
});
this.FootnotePr.NumRestart = nRestartType;
}
};
/**
* Сбрасываем рассчетные данный для заданной страницы.
* @param {number} nPageIndex
......@@ -849,6 +922,26 @@ CFootnotesController.prototype.Undo = function(Data)
this.ContinuationNoticeFootnote = Data.Old;
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrPos:
{
this.FootnotePr.Pos = Data.Old;
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrNumStart:
{
this.FootnotePr.NumStart = Data.Old;
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrNumRestart:
{
this.FootnotePr.NumRestart = Data.Old;
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrNumFormat:
{
this.FootnotePr.NumFormat = Data.Old;
break;
}
}
};
CFootnotesController.prototype.Redo = function(Data)
......@@ -877,6 +970,26 @@ CFootnotesController.prototype.Redo = function(Data)
this.ContinuationNoticeFootnote = Data.New;
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrPos:
{
this.FootnotePr.Pos = Data.New;
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrNumStart:
{
this.FootnotePr.NumStart = Data.New;
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrNumRestart:
{
this.FootnotePr.NumRestart = Data.New;
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrNumFormat:
{
this.FootnotePr.NumFormat = Data.New;
break;
}
}
};
CFootnotesController.prototype.Save_Changes = function(Data, Writer)
......@@ -915,6 +1028,16 @@ CFootnotesController.prototype.Save_Changes = function(Data, Writer)
}
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrPos:
case AscDFH.historyitem_Footnotes_SetFootnotePrNumStart:
case AscDFH.historyitem_Footnotes_SetFootnotePrNumRestart:
case AscDFH.historyitem_Footnotes_SetFootnotePrNumFormat:
{
// Long : value
Writer.WriteLong(Data.New);
break;
}
}
return Writer;
......@@ -982,6 +1105,31 @@ CFootnotesController.prototype.Load_Changes = function(Reader, Reader2)
}
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrPos:
{
// Long : value
this.FootnotePr.Pos = Reader.GetLong();
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrNumStart:
{
// Long : value
this.FootnotePr.NumStart = Reader.GetLong();
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrNumRestart:
{
// Long : value
this.FootnotePr.NumRestart = Reader.GetLong();
break;
}
case AscDFH.historyitem_Footnotes_SetFootnotePrNumFormat:
{
// Long : value
this.FootnotePr.NumFormat = Reader.GetLong();
break;
}
}
return true;
......
......@@ -53,6 +53,15 @@ var section_borders_OffsetFromText = 0x01;
var section_borders_ZOrderBack = 0x00;
var section_borders_ZOrderFront = 0x01;
var section_footnote_RestartContinious = 0x00;
var section_footnote_RestartEachSect = 0x01;
var section_footnote_RestartEachPage = 0x02;
var section_footnote_PosBeneathText = 0x00;
var section_footnote_PosDocEnd = 0x01;
var section_footnote_PosPageBottom = 0x02;
var section_footnote_PosSectEnd = 0x03;
function CSectionPr(LogicDocument)
{
this.Id = AscCommon.g_oIdCounter.Get_NewId();
......@@ -77,7 +86,7 @@ function CSectionPr(LogicDocument)
this.TitlePage = false;
this.Columns = new CSectionColumns(this);
this.FootnotePr = new CFootnotePr();
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
......@@ -963,6 +972,27 @@ CSectionPr.prototype =
this.Columns.Cols = Data.Old;
break;
}
case AscDFH.historyitem_Section_Footnote_Pos:
{
this.FootnotePr.Pos = Data.Old;
break;
}
case AscDFH.historyitem_Section_Footnote_NumStart:
{
this.FootnotePr.NumStart = Data.Old;
break;
}
case AscDFH.historyitem_Section_Footnote_NumRestart:
{
this.FootnotePr.NumRestart = Data.Old;
break;
}
case AscDFH.historyitem_Section_Footnote_NumFormat:
{
this.FootnotePr.NumFormat = Data.Old;
break;
}
}
},
......@@ -1141,6 +1171,27 @@ CSectionPr.prototype =
this.Columns.Cols = Data.New;
break;
}
case AscDFH.historyitem_Section_Footnote_Pos:
{
this.FootnotePr.Pos = Data.New;
break;
}
case AscDFH.historyitem_Section_Footnote_NumStart:
{
this.FootnotePr.NumStart = Data.New;
break;
}
case AscDFH.historyitem_Section_Footnote_NumRestart:
{
this.FootnotePr.NumRestart = Data.New;
break;
}
case AscDFH.historyitem_Section_Footnote_NumFormat:
{
this.FootnotePr.NumFormat = Data.New;
break;
}
}
},
......@@ -1391,8 +1442,25 @@ CSectionPr.prototype =
}
break;
}
}
case AscDFH.historyitem_Section_Footnote_Pos:
case AscDFH.historyitem_Section_Footnote_NumStart:
case AscDFH.historyitem_Section_Footnote_NumRestart:
case AscDFH.historyitem_Section_Footnote_NumFormat:
{
// Bool : undefined ?
// false -> Long : value
if (undefined === Data.New)
Writer.WriteBool(true);
else
{
Writer.WriteBool(false);
Writer.WriteLong(Data.New);
}
break;
}
}
},
Load_Changes : function(Reader)
......@@ -1681,6 +1749,55 @@ CSectionPr.prototype =
}
break;
}
case AscDFH.historyitem_Section_Footnote_Pos:
{
// Bool : undefined ?
// false -> Long : value
if (true === Reader.GetBool())
this.FootnotePr.Pos = undefined;
else
this.FootnotePr.Pos = Reader.GetLong();
break;
}
case AscDFH.historyitem_Section_Footnote_NumStart:
{
// Bool : undefined ?
// false -> Long : value
if (true === Reader.GetBool())
this.FootnotePr.NumStart = undefined;
else
this.FootnotePr.NumStart = Reader.GetLong();
break;
}
case AscDFH.historyitem_Section_Footnote_NumRestart:
{
// Bool : undefined ?
// false -> Long : value
if (true === Reader.GetBool())
this.FootnotePr.NumRestart = undefined;
else
this.FootnotePr.NumRestart = Reader.GetLong();
break;
}
case AscDFH.historyitem_Section_Footnote_NumFormat:
{
// Bool : undefined ?
// false -> Long : value
if (true === Reader.GetBool())
this.FootnotePr.NumFormat = undefined;
else
this.FootnotePr.NumFormat = Reader.GetLong();
break;
}
}
},
......@@ -1697,6 +1814,7 @@ CSectionPr.prototype =
// Колонтитулы не пишем в бинарник, при созданиии класса они всегда null, а TitlePage = false
// Variable : PageNumType
// Variable : CSectionColumns
// Variable : CFootnotePr
Writer.WriteString2( "" + this.Id );
Writer.WriteString2( "" + this.LogicDocument.Get_Id() );
......@@ -1706,6 +1824,7 @@ CSectionPr.prototype =
this.Borders.Write_ToBinary( Writer );
this.PageNumType.Write_ToBinary( Writer );
this.Columns.Write_ToBinary(Writer);
this.FootnotePr.WriteToBinary(Writer);
},
Read_FromBinary2 : function(Reader)
......@@ -1719,6 +1838,7 @@ CSectionPr.prototype =
// Колонтитулы не пишем в бинарник, при созданиии класса они всегда null, а TitlePage = false
// Variable : PageNumType
// Variable : CSectionColumns
// Variable : CFootnotePr
this.Id = Reader.GetString2();
this.LogicDocument = g_oTableId.Get_ById( Reader.GetString2() );
......@@ -1728,8 +1848,93 @@ CSectionPr.prototype =
this.Borders.Read_FromBinary( Reader );
this.PageNumType.Read_FromBinary( Reader );
this.Columns.Read_FromBinary(Reader);
this.FootnotePr.ReadFromBinary(Reader);
}
};
CSectionPr.prototype.SetFootnotePos = function(nPos)
{
if (this.FootnotePr.Pos !== nPos)
{
History.Add(this, {
Type : AscDFH.historyitem_Section_Footnote_Pos,
Old : this.FootnotePr.Pos,
New : nPos
});
this.FootnotePr.Pos = nPos;
}
};
CSectionPr.prototype.GetFootnotePos = function()
{
if (undefined === this.FootnotePr.Pos)
return this.private_GetDocumentWideFootnotePr().Pos;
return this.FootnotePr.Pos;
};
CSectionPr.prototype.SetFootnoteNumStart = function(nStart)
{
if (this.FootnotePr.NumStart !== nStart)
{
History.Add(this, {
Type : AscDFH.historyitem_Section_Footnote_NumStart,
Old : this.FootnotePr.NumStart,
New : nStart
});
this.FootnotePr.NumStart = nStart;
}
};
CSectionPr.prototype.GetFootnoteNumStart = function()
{
if (undefined === this.FootnotePr.NumStart)
return this.private_GetDocumentWideFootnotePr().NumStart;
return this.FootnotePr.NumStart;
};
CSectionPr.prototype.SetFootnoteNumRestart = function(nRestartType)
{
if (this.FootnotePr.NumRestart !== nRestartType)
{
History.Add(this, {
Type : AscDFH.historyitem_Section_Footnote_NumRestart,
Old : this.FootnotePr.NumRestart,
New : nRestartType
});
this.FootnotePr.NumRestart = nRestartType;
}
};
CSectionPr.prototype.GetFootnoteNumRestart = function()
{
if (undefined === this.FootnotePr.NumRestart)
return this.private_GetDocumentWideFootnotePr().NumRestart;
return this.FootnotePr.NumRestart;
};
CSectionPr.prototype.SetFootnoteNumFormat = function(nFormatType)
{
if (this.FootnotePr.NumFormat !== nFormatType)
{
History.Add(this, {
Type : AscDFH.historyitem_Section_Footnote_NumFormat,
Old : this.FootnotePr.NumRestart,
New : nRestartType
});
this.FootnotePr.NumFormat = nFormatType;
}
};
CSectionPr.prototype.GetFootnoteNumFormat = function()
{
if (undefined === this.FootnotePr.NumFormat)
return this.private_GetDocumentWideFootnotePr().NumFormat;
return this.FootnotePr.NumFormat;
};
CSectionPr.prototype.private_GetDocumentWideFootnotePr = function()
{
return this.LogicDocument.Footnotes.FootnotePr;
};
function CSectionPageSize()
{
......@@ -2062,6 +2267,81 @@ function CSectionLayoutInfo(X, Y, XLimit, YLimit)
this.Columns = [];
}
function CFootnotePr()
{
this.NumRestart = undefined;
this.NumFormat = undefined;
this.NumStart = undefined;
this.Pos = undefined;
}
CFootnotePr.prototype.InitDefault = function()
{
this.NumFormat = numbering_numfmt_Decimal;
this.NumRestart = section_footnote_RestartContinious;
this.NumStart = 1;
this.Pos = section_footnote_PosPageBottom;
};
CFootnotePr.prototype.WriteToBinary = function(Writer)
{
var StartPos = Writer.GetCurPosition();
Writer.Skip(4);
var Flags = 0;
if (undefined !== this.NumFormat)
{
Writer.WriteLong(this.NumFormat);
Flags |= 1;
}
if (undefined !== this.NumRestart)
{
Writer.WriteLong(this.NumRestart);
Flags |= 2;
}
if (undefined !== this.NumStart)
{
Writer.WriteLong(this.NumStart);
Flags |= 4;
}
if (undefined !== this.Pos)
{
Writer.WriteLong(this.Pos);
Flags |= 8;
}
var EndPos = Writer.GetCurPosition();
Writer.Seek(StartPos);
Writer.WriteLong(Flags);
Writer.Seek(EndPos);
};
CFootnotePr.prototype.ReadFromBinary = function(Reader)
{
var Flags = Reader.GetLong();
if (Flags & 1)
this.NumFormat = Reader.GetLong();
else
this.NumFormat = undefined;
if (Flags & 2)
this.NumRestart = Reader.GetLong();
else
this.NumRestart = undefined;
if (Flags & 4)
this.NumStart = Reader.GetLong();
else
this.NumStart = undefined;
if (Flags & 8)
this.Pos = Reader.GetLong();
else
this.Pos = undefined;
};
//--------------------------------------------------------export----------------------------------------------------
window['AscCommonWord'] = window['AscCommonWord'] || {};
window['AscCommonWord'].CSectionPr = CSectionPr;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment