Commit b5872b42 authored by Ilya Kirillov's avatar Ilya Kirillov

Added the new field of CParaTab class - Leader.

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