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.Value = Value; this.Pos = Pos;
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; {
}, asc_getPos: function () { this.Value = v;
return this.Pos; };
}, asc_putPos: function (v) { asc_CParagraphTab.prototype.asc_getPos = function()
this.Pos = v; {
} return this.Pos;
};
asc_CParagraphTab.prototype.asc_putPos = function(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,184 +8418,184 @@ CTextPr.prototype['Get_Lang'] = CTextPr.prototype.Get_Lang; ...@@ -8418,184 +8418,184 @@ 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)
if (this.Value !== Tab.Value {
|| this.Pos !== Tab.Pos) // TODO: Если таб точно такого же типа и в той же позиции, то неясно нужно ли проверять совпадение Tab.Leader
return false; if (this.Value !== Tab.Value
|| this.Pos !== Tab.Pos)
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;
{ for (Index = 0; Index < this.Tabs.length; Index++)
var Index = 0; {
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 )
{
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 ) if (Math.abs(Tab.Pos - _Tab.Pos) < 0.001)
this.Tabs.splice( Index2, 1 ); {
else if ( -1 != Flag ) this.Tabs.splice(Index, 1, _Tab);
this.Tabs.splice( Index2, 0, _Tab ); break;
} }
},
Is_Equal : function(Tabs) if (Tab.Pos > _Tab.Pos)
{ break;
if (this.Tabs.length !== Tabs.Tabs.length) }
return false;
for(var CurTab = 0, TabsCount = this.Tabs.length; CurTab < TabsCount; CurTab++) if (-1 != Index)
{ this.Tabs.splice(Index, 0, _Tab);
if (true !== this.Tabs[CurTab].Is_Equal(Tabs.Tabs[CurTab])) };
return false; CParaTabs.prototype.Merge = function(Tabs)
} {
var _Tabs = Tabs.Tabs;
return true; for (var Index = 0; Index < _Tabs.length; Index++)
}, {
var _Tab = _Tabs[Index];
Copy : function() var Index2 = 0;
{ var Flag = 0;
var Tabs = new CParaTabs(); for (Index2 = 0; Index2 < this.Tabs.length; Index2++)
var Count = this.Tabs.length; {
var Tab = this.Tabs[Index2];
for ( var Index = 0; Index < Count; Index++ ) if (Math.abs(Tab.Pos - _Tab.Pos) < 0.001)
Tabs.Add( this.Tabs[Index].Copy() ); {
if (tab_Clear === _Tab.Value)
Flag = -2; // таб нужно удалить
else
Flag = -1; // табы совпали, не надо новый добавлять
return Tabs; break;
}, }
Set_FromObject : function(Tabs) if (Tab.Pos > _Tab.Pos)
{ break;
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() if (-2 === Flag)
{ this.Tabs.splice(Index2, 1);
return this.Tabs.length; else if (-1 != Flag)
}, this.Tabs.splice(Index2, 0, _Tab);
}
};
CParaTabs.prototype.IsEqual = function(Tabs)
{
if (this.Tabs.length !== Tabs.Tabs.length)
return false;
Get : function(Index) for (var CurTab = 0, TabsCount = this.Tabs.length; CurTab < TabsCount; CurTab++)
{ {
return this.Tabs[Index]; if (true !== this.Tabs[CurTab].IsEqual(Tabs.Tabs[CurTab]))
}, return false;
}
Get_Value : function(Pos) return true;
{ };
var Count = this.Tabs.length; CParaTabs.prototype.Is_Equal = function(Tabs)
for ( var Index = 0; Index < Count; Index++ ) {
{ return this.IsEqual(Tabs);
var Tab = this.Tabs[Index]; };
if ( Math.abs(Tab.Pos - Pos) < 0.001 ) CParaTabs.prototype.Copy = function()
return Tab.Value; {
} var Tabs = new CParaTabs();
var Count = this.Tabs.length;
return -1; for (var Index = 0; Index < Count; Index++)
}, Tabs.Add(this.Tabs[Index].Copy());
Write_ToBinary : function(Writer) return Tabs;
{ };
// Long : количество (если 0, удаляем элемент) CParaTabs.prototype.Set_FromObject = function(Tabs)
// Массив {
// Byte : Value if (Tabs instanceof Array)
// Double : Pos {
var Count = Tabs.length;
for (var Index = 0; Index < Count; Index++)
this.Add(new CParaTab(Tabs[Index].Value, Tabs[Index].Pos, Tabs[nIndex].Leader));
}
};
CParaTabs.prototype.GetCount = function()
{
return this.Tabs.length;
};
CParaTabs.prototype.Get_Count = function()
{
return this.GetCount();
};
CParaTabs.prototype.Get = function(Index)
{
return this.Tabs[Index];
};
CParaTabs.prototype.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;
}
var Count = this.Tabs.length; return -1;
Writer.WriteLong( Count ); };
CParaTabs.prototype.Write_ToBinary = function(Writer)
{
// Long : количество (если 0, удаляем элемент)
// Массив
// Byte : Value
// Double : Pos
// Long : Leader
for ( var Index = 0; Index < Count; Index++ ) var Count = this.Tabs.length;
{ Writer.WriteLong(Count);
Writer.WriteByte( this.Tabs[Index].Value );
Writer.WriteDouble( this.Tabs[Index].Pos );
}
},
Read_FromBinary : function(Reader) for (var Index = 0; Index < Count; Index++)
{ {
// Long : количество (если 0, удаляем элемент) Writer.WriteByte(this.Tabs[Index].Value);
// Массив Writer.WriteDouble(this.Tabs[Index].Pos);
// Byte : Value Writer.WriteLong(this.Tabs[Index].Leader);
// Double : Pos }
};
CParaTabs.prototype.Read_FromBinary = function(Reader)
{
// Long : количество (если 0, удаляем элемент)
// Массив
// Byte : Value
// 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));
} }
}; };
function CParaInd() function CParaInd()
......
...@@ -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