Commit b5872b42 authored by Ilya Kirillov's avatar Ilya Kirillov

Added the new field of CParaTab class - Leader.

parent 5d49f5ed
...@@ -1418,21 +1418,35 @@ ...@@ -1418,21 +1418,35 @@
}; };
/** @constructor */ /** @constructor */
function asc_CParagraphTab(Pos, Value) { function asc_CParagraphTab(Pos, Value, Leader)
{
this.Pos = Pos; this.Pos = Pos;
this.Value = Value; this.Value = Value;
this.Leader = Leader;
} }
asc_CParagraphTab.prototype.asc_getValue = function()
asc_CParagraphTab.prototype = { {
asc_getValue: function () {
return this.Value; return this.Value;
}, asc_putValue: function (v) { };
asc_CParagraphTab.prototype.asc_putValue = function(v)
{
this.Value = v; this.Value = v;
}, asc_getPos: function () { };
asc_CParagraphTab.prototype.asc_getPos = function()
{
return this.Pos; return this.Pos;
}, asc_putPos: function (v) { };
asc_CParagraphTab.prototype.asc_putPos = function(v)
{
this.Pos = v; this.Pos = v;
} };
asc_CParagraphTab.prototype.asc_getLeader = function()
{
return this.Leader;
};
asc_CParagraphTab.prototype.asc_putLeader = function(v)
{
this.Leader = v;
}; };
/** @constructor */ /** @constructor */
...@@ -1442,7 +1456,7 @@ ...@@ -1442,7 +1456,7 @@
if (undefined != obj) { if (undefined != obj) {
var Count = obj.Tabs.length; var Count = obj.Tabs.length;
for (var Index = 0; Index < Count; Index++) { for (var Index = 0; Index < Count; Index++) {
this.Tabs.push(new asc_CParagraphTab(obj.Tabs[Index].Pos, obj.Tabs[Index].Value)); this.Tabs.push(new asc_CParagraphTab(obj.Tabs[Index].Pos, obj.Tabs[Index].Value, obj.Tabs[Index].Leader));
} }
} }
} }
...@@ -3800,6 +3814,8 @@ ...@@ -3800,6 +3814,8 @@
prot["put_Value"] = prot["asc_putValue"] = prot.asc_putValue; prot["put_Value"] = prot["asc_putValue"] = prot.asc_putValue;
prot["get_Pos"] = prot["asc_getPos"] = prot.asc_getPos; prot["get_Pos"] = prot["asc_getPos"] = prot.asc_getPos;
prot["put_Pos"] = prot["asc_putPos"] = prot.asc_putPos; prot["put_Pos"] = prot["asc_putPos"] = prot.asc_putPos;
prot["get_Leader"] = prot["asc_getPos"] = prot.asc_getLeader;
prot["put_Leader"] = prot["asc_putPos"] = prot.asc_putLeader;
window["Asc"]["asc_CParagraphTabs"] = window["Asc"].asc_CParagraphTabs = asc_CParagraphTabs; window["Asc"]["asc_CParagraphTabs"] = window["Asc"].asc_CParagraphTabs = asc_CParagraphTabs;
prot = asc_CParagraphTabs.prototype; prot = asc_CParagraphTabs.prototype;
......
...@@ -279,7 +279,7 @@ CComplexField.prototype.Update = function() ...@@ -279,7 +279,7 @@ CComplexField.prototype.Update = function()
// Значение таба зависит от текущей секции // Значение таба зависит от текущей секции
var oTabs = new CParaTabs(); var oTabs = new CParaTabs();
oTabs.Add(new CParaTab(tab_Right, 9345 / 20 / 72 * 25.4)); oTabs.Add(new CParaTab(tab_Right, 9345 / 20 / 72 * 25.4, c_oAscTabLeader.Dot));
oPara.Set_Tabs(oTabs); oPara.Set_Tabs(oTabs);
var oTabRun = new ParaRun(oPara, false); var oTabRun = new ParaRun(oPara, false);
......
...@@ -8418,74 +8418,71 @@ CTextPr.prototype['Get_Lang'] = CTextPr.prototype.Get_Lang; ...@@ -8418,74 +8418,71 @@ CTextPr.prototype['Get_Lang'] = CTextPr.prototype.Get_Lang;
CTextPr.prototype['Get_Shd'] = CTextPr.prototype.Get_Shd; CTextPr.prototype['Get_Shd'] = CTextPr.prototype.Get_Shd;
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
function CParaTab(Value, Pos) function CParaTab(Value, Pos, Leader)
{ {
this.Value = Value; this.Value = Value;
this.Pos = Pos; this.Pos = Pos;
this.Leader = Leader ? Leader : c_oAscTabLeader.None;
} }
CParaTab.prototype.Copy = function()
CParaTab.prototype =
{ {
Copy : function() return new CParaTab(this.Value, this.Pos, this.Leader);
{ };
return new CParaTab(this.Value, this.Pos); CParaTab.prototype.Is_Equal = function(Tab)
}, {
return this.IsEqual(Tab);
Is_Equal : function(Tab) };
{ CParaTab.prototype.IsEqual = function(Tab)
{
// TODO: Если таб точно такого же типа и в той же позиции, то неясно нужно ли проверять совпадение Tab.Leader
if (this.Value !== Tab.Value if (this.Value !== Tab.Value
|| this.Pos !== Tab.Pos) || this.Pos !== Tab.Pos)
return false; return false;
return true; return true;
}
}; };
function CParaTabs() function CParaTabs()
{ {
this.Tabs = []; this.Tabs = [];
} }
CParaTabs.prototype.Add = function(_Tab)
CParaTabs.prototype =
{ {
Add : function(_Tab)
{
var Index = 0; var Index = 0;
for (Index = 0; Index < this.Tabs.length; Index++ ) for (Index = 0; Index < this.Tabs.length; Index++)
{ {
var Tab = this.Tabs[Index]; var Tab = this.Tabs[Index];
if ( Math.abs( Tab.Pos - _Tab.Pos ) < 0.001 ) if (Math.abs(Tab.Pos - _Tab.Pos) < 0.001)
{ {
this.Tabs.splice( Index, 1, _Tab ); this.Tabs.splice(Index, 1, _Tab);
break; break;
} }
if ( Tab.Pos > _Tab.Pos ) if (Tab.Pos > _Tab.Pos)
break; break;
} }
if ( -1 != Index ) if (-1 != Index)
this.Tabs.splice( Index, 0, _Tab ); this.Tabs.splice(Index, 0, _Tab);
}, };
CParaTabs.prototype.Merge = function(Tabs)
Merge : function(Tabs) {
{
var _Tabs = Tabs.Tabs; var _Tabs = Tabs.Tabs;
for ( var Index = 0; Index < _Tabs.length; Index++ ) for (var Index = 0; Index < _Tabs.length; Index++)
{ {
var _Tab = _Tabs[Index]; var _Tab = _Tabs[Index];
var Index2 = 0; var Index2 = 0;
var Flag = 0; var Flag = 0;
for (Index2 = 0; Index2 < this.Tabs.length; Index2++ ) for (Index2 = 0; Index2 < this.Tabs.length; Index2++)
{ {
var Tab = this.Tabs[Index2]; var Tab = this.Tabs[Index2];
if ( Math.abs( Tab.Pos - _Tab.Pos ) < 0.001 ) if (Math.abs(Tab.Pos - _Tab.Pos) < 0.001)
{ {
if ( tab_Clear === _Tab.Value ) if (tab_Clear === _Tab.Value)
Flag = -2; // таб нужно удалить Flag = -2; // таб нужно удалить
else else
Flag = -1; // табы совпали, не надо новый добавлять Flag = -1; // табы совпали, не надо новый добавлять
...@@ -8493,108 +8490,111 @@ CParaTabs.prototype = ...@@ -8493,108 +8490,111 @@ CParaTabs.prototype =
break; break;
} }
if ( Tab.Pos > _Tab.Pos ) if (Tab.Pos > _Tab.Pos)
break; break;
} }
if ( -2 === Flag ) if (-2 === Flag)
this.Tabs.splice( Index2, 1 ); this.Tabs.splice(Index2, 1);
else if ( -1 != Flag ) else if (-1 != Flag)
this.Tabs.splice( Index2, 0, _Tab ); this.Tabs.splice(Index2, 0, _Tab);
} }
}, };
CParaTabs.prototype.IsEqual = function(Tabs)
Is_Equal : function(Tabs) {
{
if (this.Tabs.length !== Tabs.Tabs.length) if (this.Tabs.length !== Tabs.Tabs.length)
return false; return false;
for(var CurTab = 0, TabsCount = this.Tabs.length; CurTab < TabsCount; CurTab++) for (var CurTab = 0, TabsCount = this.Tabs.length; CurTab < TabsCount; CurTab++)
{ {
if (true !== this.Tabs[CurTab].Is_Equal(Tabs.Tabs[CurTab])) if (true !== this.Tabs[CurTab].IsEqual(Tabs.Tabs[CurTab]))
return false; return false;
} }
return true; return true;
}, };
CParaTabs.prototype.Is_Equal = function(Tabs)
Copy : function() {
{ return this.IsEqual(Tabs);
};
CParaTabs.prototype.Copy = function()
{
var Tabs = new CParaTabs(); var Tabs = new CParaTabs();
var Count = this.Tabs.length; var Count = this.Tabs.length;
for ( var Index = 0; Index < Count; Index++ ) for (var Index = 0; Index < Count; Index++)
Tabs.Add( this.Tabs[Index].Copy() ); Tabs.Add(this.Tabs[Index].Copy());
return Tabs; return Tabs;
}, };
CParaTabs.prototype.Set_FromObject = function(Tabs)
Set_FromObject : function(Tabs) {
{ if (Tabs instanceof Array)
if ( Tabs instanceof Array )
{ {
var Count = Tabs.length; var Count = Tabs.length;
for ( var Index = 0; Index < Count; Index++ ) for (var Index = 0; Index < Count; Index++)
this.Add( new CParaTab( Tabs[Index].Value, Tabs[Index].Pos ) ); this.Add(new CParaTab(Tabs[Index].Value, Tabs[Index].Pos, Tabs[nIndex].Leader));
} }
}, };
CParaTabs.prototype.GetCount = function()
Get_Count : function() {
{
return this.Tabs.length; return this.Tabs.length;
}, };
CParaTabs.prototype.Get_Count = function()
Get : function(Index) {
{ return this.GetCount();
};
CParaTabs.prototype.Get = function(Index)
{
return this.Tabs[Index]; return this.Tabs[Index];
}, };
CParaTabs.prototype.Get_Value = function(Pos)
Get_Value : function(Pos) {
{
var Count = this.Tabs.length; var Count = this.Tabs.length;
for ( var Index = 0; Index < Count; Index++ ) for (var Index = 0; Index < Count; Index++)
{ {
var Tab = this.Tabs[Index]; var Tab = this.Tabs[Index];
if ( Math.abs(Tab.Pos - Pos) < 0.001 ) if (Math.abs(Tab.Pos - Pos) < 0.001)
return Tab.Value; return Tab.Value;
} }
return -1; return -1;
}, };
CParaTabs.prototype.Write_ToBinary = function(Writer)
Write_ToBinary : function(Writer) {
{
// Long : количество (если 0, удаляем элемент) // Long : количество (если 0, удаляем элемент)
// Массив // Массив
// Byte : Value // Byte : Value
// Double : Pos // Double : Pos
// Long : Leader
var Count = this.Tabs.length; var Count = this.Tabs.length;
Writer.WriteLong( Count ); Writer.WriteLong(Count);
for ( var Index = 0; Index < Count; Index++ ) for (var Index = 0; Index < Count; Index++)
{ {
Writer.WriteByte( this.Tabs[Index].Value ); Writer.WriteByte(this.Tabs[Index].Value);
Writer.WriteDouble( this.Tabs[Index].Pos ); Writer.WriteDouble(this.Tabs[Index].Pos);
Writer.WriteLong(this.Tabs[Index].Leader);
} }
}, };
CParaTabs.prototype.Read_FromBinary = function(Reader)
Read_FromBinary : function(Reader) {
{
// Long : количество (если 0, удаляем элемент) // Long : количество (если 0, удаляем элемент)
// Массив // Массив
// Byte : Value // Byte : Value
// Double : Pos // Double : Pos
// Long : Leader
var Count = Reader.GetLong(); var Count = Reader.GetLong();
this.Tabs = []; this.Tabs = [];
for ( var Index = 0; Index < Count; Index++ ) for (var Index = 0; Index < Count; Index++)
{ {
var Value = Reader.GetByte(); var Value = Reader.GetByte();
var Pos = Reader.GetDouble(); var Pos = Reader.GetDouble();
this.Add( new CParaTab( Value, Pos ) ); var Leader = Reader.GetLong();
} this.Add(new CParaTab(Value, Pos, Leader));
} }
}; };
......
...@@ -206,6 +206,14 @@ var c_oAscNumberingFormat = { ...@@ -206,6 +206,14 @@ var c_oAscNumberingFormat = {
DecimalZero : 0x2007 // numbering_numfmt_DecimalZero DecimalZero : 0x2007 // numbering_numfmt_DecimalZero
}; };
var c_oAscTabLeader = {
None : 0x00,
Dot : 0x01,
Hyphen : 0x02,
MiddleDot : 0x03,
Underscore : 0x04
};
window["flat_desine"] = false; window["flat_desine"] = false;
//------------------------------------------------------------export--------------------------------------------------- //------------------------------------------------------------export---------------------------------------------------
...@@ -304,6 +312,13 @@ prot['LowerLetter'] = c_oAscNumberingFormat.LowerLetter; ...@@ -304,6 +312,13 @@ prot['LowerLetter'] = c_oAscNumberingFormat.LowerLetter;
prot['UpperLetter'] = c_oAscNumberingFormat.UpperLetter; prot['UpperLetter'] = c_oAscNumberingFormat.UpperLetter;
prot['DecimalZero'] = c_oAscNumberingFormat.DecimalZero; prot['DecimalZero'] = c_oAscNumberingFormat.DecimalZero;
prot = window['Asc']['c_oAscTabLeader'] = c_oAscTabLeader;
prot["None"] = c_oAscTabLeader.None;
prot["Dot"] = c_oAscTabLeader.Dot;
prot["Hyphen"] = c_oAscTabLeader.Hyphen;
prot["MiddleDot"] = c_oAscTabLeader.MiddleDot;
prot["Underscore"] = c_oAscTabLeader.Underscore;
window['AscCommon'] = window['AscCommon'] || {}; window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].c_oSerFormat = c_oSerFormat; window['AscCommon'].c_oSerFormat = c_oSerFormat;
......
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