mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-02-10 18:15:19 +08:00
The "Leader" field for ParaTab were implemented.
This commit is contained in:
@ -5694,15 +5694,15 @@ function CDrawingDocument()
|
||||
for (var i = 0; i < _len; i++)
|
||||
{
|
||||
if (__tabs[i].Value == tab_Left)
|
||||
_ar[i] = new CTab(__tabs[i].Pos, AscCommon.g_tabtype_left);
|
||||
_ar[i] = new CTab(__tabs[i].Pos, AscCommon.g_tabtype_left, __tabs[i].Leader);
|
||||
else if (__tabs[i].Value == tab_Center)
|
||||
_ar[i] = new CTab(__tabs[i].Pos, AscCommon.g_tabtype_center);
|
||||
_ar[i] = new CTab(__tabs[i].Pos, AscCommon.g_tabtype_center, __tabs[i].Leader);
|
||||
else if (__tabs[i].Value == tab_Right)
|
||||
_ar[i] = new CTab(__tabs[i].Pos, AscCommon.g_tabtype_right);
|
||||
_ar[i] = new CTab(__tabs[i].Pos, AscCommon.g_tabtype_right, __tabs[i].Leader);
|
||||
else
|
||||
{
|
||||
// не должно такого быть. но приходит
|
||||
_ar[i] = new CTab(__tabs[i].Pos, AscCommon.g_tabtype_left);
|
||||
_ar[i] = new CTab(__tabs[i].Pos, AscCommon.g_tabtype_left, __tabs[i].Leader);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -38,10 +38,11 @@ var global_mouseEvent = AscCommon.global_mouseEvent;
|
||||
var g_dKoef_pix_to_mm = AscCommon.g_dKoef_pix_to_mm;
|
||||
var g_dKoef_mm_to_pix = AscCommon.g_dKoef_mm_to_pix;
|
||||
|
||||
function CTab(pos,type)
|
||||
function CTab(pos, type, leader)
|
||||
{
|
||||
this.pos = pos;
|
||||
this.type = type;
|
||||
this.pos = pos;
|
||||
this.type = type;
|
||||
this.leader = leader;
|
||||
}
|
||||
|
||||
var g_array_objects_length = 1;
|
||||
@ -2214,26 +2215,26 @@ function CHorRuler()
|
||||
}
|
||||
|
||||
this.SetTabsProperties = function()
|
||||
{
|
||||
// потом заменить на объекты CTab (когда Илюха реализует не только левые табы)
|
||||
var _arr = new CParaTabs();
|
||||
var _c = this.m_arrTabs.length;
|
||||
for (var i = 0; i < _c; i++)
|
||||
{
|
||||
if (this.m_arrTabs[i].type == AscCommon.g_tabtype_left)
|
||||
_arr.Add( new CParaTab( tab_Left, this.m_arrTabs[i].pos ) );
|
||||
else if (this.m_arrTabs[i].type == AscCommon.g_tabtype_right)
|
||||
_arr.Add( new CParaTab( tab_Right, this.m_arrTabs[i].pos ) );
|
||||
else if (this.m_arrTabs[i].type == AscCommon.g_tabtype_center)
|
||||
_arr.Add( new CParaTab( tab_Center, this.m_arrTabs[i].pos ) );
|
||||
}
|
||||
|
||||
if ( false === this.m_oWordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Properties) )
|
||||
{
|
||||
this.m_oWordControl.m_oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_SetParagraphTabs);
|
||||
this.m_oWordControl.m_oLogicDocument.SetParagraphTabs(_arr);
|
||||
}
|
||||
}
|
||||
{
|
||||
// потом заменить на объекты CTab (когда Илюха реализует не только левые табы)
|
||||
var _arr = new CParaTabs();
|
||||
var _c = this.m_arrTabs.length;
|
||||
for (var i = 0; i < _c; i++)
|
||||
{
|
||||
if (this.m_arrTabs[i].type == AscCommon.g_tabtype_left)
|
||||
_arr.Add(new CParaTab(tab_Left, this.m_arrTabs[i].pos, this.m_arrTabs[i].leader));
|
||||
else if (this.m_arrTabs[i].type == AscCommon.g_tabtype_right)
|
||||
_arr.Add(new CParaTab(tab_Right, this.m_arrTabs[i].pos, this.m_arrTabs[i].leader));
|
||||
else if (this.m_arrTabs[i].type == AscCommon.g_tabtype_center)
|
||||
_arr.Add(new CParaTab(tab_Center, this.m_arrTabs[i].pos, this.m_arrTabs[i].leader));
|
||||
}
|
||||
|
||||
if (false === this.m_oWordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Properties))
|
||||
{
|
||||
this.m_oWordControl.m_oLogicDocument.Create_NewHistoryPoint(AscDFH.historydescription_Document_SetParagraphTabs);
|
||||
this.m_oWordControl.m_oLogicDocument.SetParagraphTabs(_arr);
|
||||
}
|
||||
}
|
||||
|
||||
this.SetPrProperties = function()
|
||||
{
|
||||
|
||||
@ -181,7 +181,7 @@ function CRunElementBase()
|
||||
CRunElementBase.prototype.Type = para_RunBase;
|
||||
CRunElementBase.prototype.Get_Type = function()
|
||||
{
|
||||
return para_RunBase;
|
||||
return this.Type;
|
||||
};
|
||||
CRunElementBase.prototype.Draw = function(X, Y, Context, PDSE)
|
||||
{
|
||||
@ -1214,90 +1214,108 @@ var tab_Center = 0x03;
|
||||
|
||||
var tab_Symbol = 0x0022;//0x2192;
|
||||
|
||||
// Класс ParaTab
|
||||
/**
|
||||
* Класс представляющий элемент табуляции.
|
||||
* @constructor
|
||||
* @extends {CRunElementBase}
|
||||
*/
|
||||
function ParaTab()
|
||||
{
|
||||
this.TabType = tab_Left;
|
||||
CRunElementBase.call(this);
|
||||
|
||||
this.Width = 0;
|
||||
this.WidthVisible = 0;
|
||||
this.RealWidth = 0;
|
||||
this.Width = 0;
|
||||
this.WidthVisible = 0;
|
||||
this.RealWidth = 0;
|
||||
|
||||
this.DotWidth = 0;
|
||||
this.UnderscoreWidth = 0;
|
||||
this.HyphenWidth = 0;
|
||||
this.Leader = Asc.c_oAscTabLeader.None;
|
||||
}
|
||||
|
||||
ParaTab.prototype =
|
||||
ParaTab.prototype = Object.create(CRunElementBase.prototype);
|
||||
ParaTab.prototype.constructor = ParaTab;
|
||||
ParaTab.prototype.Type = para_Tab;
|
||||
ParaTab.prototype.Draw = function(X, Y, Context)
|
||||
{
|
||||
Type : para_Tab,
|
||||
if (this.WidthVisible > 0.01)
|
||||
{
|
||||
var sChar = null, nCharWidth = 0;
|
||||
switch (this.Leader)
|
||||
{
|
||||
case Asc.c_oAscTabLeader.Dot:
|
||||
sChar = '.';
|
||||
nCharWidth = this.DotWidth;
|
||||
break;
|
||||
case Asc.c_oAscTabLeader.Hyphen:
|
||||
sChar = '_';
|
||||
nCharWidth = this.UnderscoreWidth;
|
||||
break;
|
||||
case Asc.c_oAscTabLeader.MiddleDot:
|
||||
sChar = '-';
|
||||
nCharWidth = this.HyphenWidth;
|
||||
break;
|
||||
case Asc.c_oAscTabLeader.Underscore:
|
||||
sChar = '·';
|
||||
nCharWidth = this.MiddleDotWidth;
|
||||
break;
|
||||
}
|
||||
|
||||
Get_Type : function()
|
||||
{
|
||||
return para_Tab;
|
||||
},
|
||||
|
||||
Draw : function(X,Y,Context)
|
||||
{
|
||||
if ( typeof (editor) !== "undefined" && editor.ShowParaMarks )
|
||||
{
|
||||
var X0 = this.Width / 2 - this.RealWidth / 2;
|
||||
if (null !== sChar && nCharWidth > 0.001)
|
||||
{
|
||||
Context.SetFontSlot(fontslot_ASCII, 1);
|
||||
var nCharsCount = Math.floor(this.WidthVisible / nCharWidth);
|
||||
|
||||
Context.SetFont( {FontFamily: { Name : "ASCW3", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
|
||||
var _X = X + (this.WidthVisible - nCharsCount * nCharWidth) / 2;
|
||||
for (var nIndex = 0; nIndex < nCharsCount; ++nIndex, _X += nCharWidth)
|
||||
Context.FillText(_X, Y, sChar);
|
||||
}
|
||||
}
|
||||
|
||||
if ( X0 > 0 )
|
||||
Context.FillText2( X + X0, Y, String.fromCharCode( tab_Symbol ), 0, this.Width );
|
||||
else
|
||||
Context.FillText2( X, Y, String.fromCharCode( tab_Symbol ), this.RealWidth - this.Width, this.Width );
|
||||
if (editor && editor.ShowParaMarks)
|
||||
{
|
||||
var X0 = this.Width / 2 - this.RealWidth / 2;
|
||||
|
||||
}
|
||||
},
|
||||
Context.SetFont({FontFamily : {Name : "ASCW3", Index : -1}, FontSize : 10, Italic : false, Bold : false});
|
||||
|
||||
Measure : function (Context)
|
||||
{
|
||||
Context.SetFont( {FontFamily: { Name : "ASCW3", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
|
||||
this.RealWidth = Context.Measure( String.fromCharCode( tab_Symbol ) ).Width;
|
||||
},
|
||||
|
||||
Get_Width : function()
|
||||
{
|
||||
return this.Width;
|
||||
},
|
||||
|
||||
Get_WidthVisible : function()
|
||||
{
|
||||
return this.WidthVisible;
|
||||
},
|
||||
|
||||
Set_WidthVisible : function(WidthVisible)
|
||||
{
|
||||
this.WidthVisible = WidthVisible;
|
||||
},
|
||||
|
||||
Is_RealContent : function()
|
||||
{
|
||||
return true;
|
||||
},
|
||||
|
||||
Can_AddNumbering : function()
|
||||
{
|
||||
return true;
|
||||
},
|
||||
|
||||
Copy : function()
|
||||
{
|
||||
return new ParaTab();
|
||||
},
|
||||
|
||||
Write_ToBinary : function(Writer)
|
||||
{
|
||||
// Long : Type
|
||||
// Long : TabType
|
||||
Writer.WriteLong( para_Tab );
|
||||
Writer.WriteLong( this.TabType );
|
||||
},
|
||||
|
||||
Read_FromBinary : function(Reader)
|
||||
{
|
||||
this.TabType = Reader.GetLong();
|
||||
}
|
||||
if (X0 > 0)
|
||||
Context.FillText2(X + X0, Y, String.fromCharCode(tab_Symbol), 0, this.Width);
|
||||
else
|
||||
Context.FillText2(X, Y, String.fromCharCode(tab_Symbol), this.RealWidth - this.Width, this.Width);
|
||||
}
|
||||
};
|
||||
ParaTab.prototype.Measure = function(Context)
|
||||
{
|
||||
this.DotWidth = Context.Measure(".").Width;
|
||||
this.UnderscoreWidth = Context.Measure("_").Width;
|
||||
this.HyphenWidth = Context.Measure("-").Width * 1.5;
|
||||
this.MiddleDotWidth = Context.Measure("·").Width;
|
||||
|
||||
Context.SetFont({FontFamily : {Name : "ASCW3", Index : -1}, FontSize : 10, Italic : false, Bold : false});
|
||||
this.RealWidth = Context.Measure(String.fromCharCode(tab_Symbol)).Width;
|
||||
};
|
||||
ParaTab.prototype.SetLeader = function(nLeaderType)
|
||||
{
|
||||
this.Leader = nLeaderType;
|
||||
};
|
||||
ParaTab.prototype.Get_Width = function()
|
||||
{
|
||||
return this.Width;
|
||||
};
|
||||
ParaTab.prototype.Get_WidthVisible = function()
|
||||
{
|
||||
return this.WidthVisible;
|
||||
};
|
||||
ParaTab.prototype.Set_WidthVisible = function(WidthVisible)
|
||||
{
|
||||
this.WidthVisible = WidthVisible;
|
||||
};
|
||||
ParaTab.prototype.Copy = function()
|
||||
{
|
||||
return new ParaTab();
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Класс ParaPageNum
|
||||
function ParaPageNum()
|
||||
|
||||
@ -2056,7 +2056,12 @@ Paragraph.prototype.private_RecalculateGetTabPos = function(X, ParaPr, CurPage,
|
||||
NewX = Tab.Pos + PageStart.X;
|
||||
}
|
||||
|
||||
return { NewX : NewX, TabValue : ( null === Tab ? tab_Left : Tab.Value ), DefaultTab : (null === Tab ? true : false) };
|
||||
return {
|
||||
NewX : NewX,
|
||||
TabValue : Tab ? Tab.Value : tab_Left,
|
||||
DefaultTab : Tab ? false : true,
|
||||
TabLeader : Tab ? Tab.Leader : Asc.c_oAscTabLeader.None
|
||||
};
|
||||
};
|
||||
|
||||
Paragraph.prototype.private_CheckSkipKeepLinesAndWidowControl = function(CurPage)
|
||||
|
||||
@ -3097,10 +3097,12 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
|
||||
SpaceLen = 0;
|
||||
WordLen = 0;
|
||||
|
||||
var TabPos = Para.private_RecalculateGetTabPos(X, ParaPr, PRS.Page, false);
|
||||
var NewX = TabPos.NewX;
|
||||
var TabPos = Para.private_RecalculateGetTabPos(X, ParaPr, PRS.Page, false);
|
||||
var NewX = TabPos.NewX;
|
||||
var TabValue = TabPos.TabValue;
|
||||
|
||||
Item.SetLeader(TabPos.TabLeader);
|
||||
|
||||
// Если таб не левый, значит он не может быть сразу рассчитан, а если левый, тогда
|
||||
// рассчитываем его сразу здесь
|
||||
if (tab_Left !== TabValue)
|
||||
|
||||
@ -8422,7 +8422,7 @@ function CParaTab(Value, Pos, Leader)
|
||||
{
|
||||
this.Value = Value;
|
||||
this.Pos = Pos;
|
||||
this.Leader = Leader ? Leader : Asc.c_oAscTabLeader.None;
|
||||
this.Leader = undefined !== Leader ? Leader : Asc.c_oAscTabLeader.None;
|
||||
}
|
||||
CParaTab.prototype.Copy = function()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user