mirror of
https://github.com/ONLYOFFICE/sdkjs.git
synced 2026-04-07 14:09:12 +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++)
|
for (var i = 0; i < _len; i++)
|
||||||
{
|
{
|
||||||
if (__tabs[i].Value == tab_Left)
|
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)
|
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)
|
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
|
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_pix_to_mm = AscCommon.g_dKoef_pix_to_mm;
|
||||||
var g_dKoef_mm_to_pix = AscCommon.g_dKoef_mm_to_pix;
|
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.pos = pos;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
this.leader = leader;
|
||||||
}
|
}
|
||||||
|
|
||||||
var g_array_objects_length = 1;
|
var g_array_objects_length = 1;
|
||||||
@ -2214,26 +2215,26 @@ function CHorRuler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.SetTabsProperties = function()
|
this.SetTabsProperties = function()
|
||||||
{
|
{
|
||||||
// потом заменить на объекты CTab (когда Илюха реализует не только левые табы)
|
// потом заменить на объекты CTab (когда Илюха реализует не только левые табы)
|
||||||
var _arr = new CParaTabs();
|
var _arr = new CParaTabs();
|
||||||
var _c = this.m_arrTabs.length;
|
var _c = this.m_arrTabs.length;
|
||||||
for (var i = 0; i < _c; i++)
|
for (var i = 0; i < _c; i++)
|
||||||
{
|
{
|
||||||
if (this.m_arrTabs[i].type == AscCommon.g_tabtype_left)
|
if (this.m_arrTabs[i].type == AscCommon.g_tabtype_left)
|
||||||
_arr.Add( new CParaTab( tab_Left, this.m_arrTabs[i].pos ) );
|
_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)
|
else if (this.m_arrTabs[i].type == AscCommon.g_tabtype_right)
|
||||||
_arr.Add( new CParaTab( tab_Right, this.m_arrTabs[i].pos ) );
|
_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)
|
else if (this.m_arrTabs[i].type == AscCommon.g_tabtype_center)
|
||||||
_arr.Add( new CParaTab( tab_Center, this.m_arrTabs[i].pos ) );
|
_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) )
|
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.Create_NewHistoryPoint(AscDFH.historydescription_Document_SetParagraphTabs);
|
||||||
this.m_oWordControl.m_oLogicDocument.SetParagraphTabs(_arr);
|
this.m_oWordControl.m_oLogicDocument.SetParagraphTabs(_arr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.SetPrProperties = function()
|
this.SetPrProperties = function()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -181,7 +181,7 @@ function CRunElementBase()
|
|||||||
CRunElementBase.prototype.Type = para_RunBase;
|
CRunElementBase.prototype.Type = para_RunBase;
|
||||||
CRunElementBase.prototype.Get_Type = function()
|
CRunElementBase.prototype.Get_Type = function()
|
||||||
{
|
{
|
||||||
return para_RunBase;
|
return this.Type;
|
||||||
};
|
};
|
||||||
CRunElementBase.prototype.Draw = function(X, Y, Context, PDSE)
|
CRunElementBase.prototype.Draw = function(X, Y, Context, PDSE)
|
||||||
{
|
{
|
||||||
@ -1214,90 +1214,108 @@ var tab_Center = 0x03;
|
|||||||
|
|
||||||
var tab_Symbol = 0x0022;//0x2192;
|
var tab_Symbol = 0x0022;//0x2192;
|
||||||
|
|
||||||
// Класс ParaTab
|
/**
|
||||||
|
* Класс представляющий элемент табуляции.
|
||||||
|
* @constructor
|
||||||
|
* @extends {CRunElementBase}
|
||||||
|
*/
|
||||||
function ParaTab()
|
function ParaTab()
|
||||||
{
|
{
|
||||||
this.TabType = tab_Left;
|
CRunElementBase.call(this);
|
||||||
|
|
||||||
this.Width = 0;
|
this.Width = 0;
|
||||||
this.WidthVisible = 0;
|
this.WidthVisible = 0;
|
||||||
this.RealWidth = 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()
|
if (null !== sChar && nCharWidth > 0.001)
|
||||||
{
|
{
|
||||||
return para_Tab;
|
Context.SetFontSlot(fontslot_ASCII, 1);
|
||||||
},
|
var nCharsCount = Math.floor(this.WidthVisible / nCharWidth);
|
||||||
|
|
||||||
Draw : function(X,Y,Context)
|
|
||||||
{
|
|
||||||
if ( typeof (editor) !== "undefined" && editor.ShowParaMarks )
|
|
||||||
{
|
|
||||||
var X0 = this.Width / 2 - this.RealWidth / 2;
|
|
||||||
|
|
||||||
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 )
|
if (editor && editor.ShowParaMarks)
|
||||||
Context.FillText2( X + X0, Y, String.fromCharCode( tab_Symbol ), 0, this.Width );
|
{
|
||||||
else
|
var X0 = this.Width / 2 - this.RealWidth / 2;
|
||||||
Context.FillText2( X, Y, String.fromCharCode( tab_Symbol ), this.RealWidth - this.Width, this.Width );
|
|
||||||
|
|
||||||
}
|
Context.SetFont({FontFamily : {Name : "ASCW3", Index : -1}, FontSize : 10, Italic : false, Bold : false});
|
||||||
},
|
|
||||||
|
|
||||||
Measure : function (Context)
|
if (X0 > 0)
|
||||||
{
|
Context.FillText2(X + X0, Y, String.fromCharCode(tab_Symbol), 0, this.Width);
|
||||||
Context.SetFont( {FontFamily: { Name : "ASCW3", Index : -1 }, FontSize: 10, Italic: false, Bold : false} );
|
else
|
||||||
this.RealWidth = Context.Measure( String.fromCharCode( tab_Symbol ) ).Width;
|
Context.FillText2(X, Y, String.fromCharCode(tab_Symbol), this.RealWidth - this.Width, this.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();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
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
|
// Класс ParaPageNum
|
||||||
function ParaPageNum()
|
function ParaPageNum()
|
||||||
|
|||||||
@ -2056,7 +2056,12 @@ Paragraph.prototype.private_RecalculateGetTabPos = function(X, ParaPr, CurPage,
|
|||||||
NewX = Tab.Pos + PageStart.X;
|
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)
|
Paragraph.prototype.private_CheckSkipKeepLinesAndWidowControl = function(CurPage)
|
||||||
|
|||||||
@ -3097,10 +3097,12 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
|
|||||||
SpaceLen = 0;
|
SpaceLen = 0;
|
||||||
WordLen = 0;
|
WordLen = 0;
|
||||||
|
|
||||||
var TabPos = Para.private_RecalculateGetTabPos(X, ParaPr, PRS.Page, false);
|
var TabPos = Para.private_RecalculateGetTabPos(X, ParaPr, PRS.Page, false);
|
||||||
var NewX = TabPos.NewX;
|
var NewX = TabPos.NewX;
|
||||||
var TabValue = TabPos.TabValue;
|
var TabValue = TabPos.TabValue;
|
||||||
|
|
||||||
|
Item.SetLeader(TabPos.TabLeader);
|
||||||
|
|
||||||
// Если таб не левый, значит он не может быть сразу рассчитан, а если левый, тогда
|
// Если таб не левый, значит он не может быть сразу рассчитан, а если левый, тогда
|
||||||
// рассчитываем его сразу здесь
|
// рассчитываем его сразу здесь
|
||||||
if (tab_Left !== TabValue)
|
if (tab_Left !== TabValue)
|
||||||
|
|||||||
@ -8422,7 +8422,7 @@ function CParaTab(Value, Pos, Leader)
|
|||||||
{
|
{
|
||||||
this.Value = Value;
|
this.Value = Value;
|
||||||
this.Pos = Pos;
|
this.Pos = Pos;
|
||||||
this.Leader = Leader ? Leader : Asc.c_oAscTabLeader.None;
|
this.Leader = undefined !== Leader ? Leader : Asc.c_oAscTabLeader.None;
|
||||||
}
|
}
|
||||||
CParaTab.prototype.Copy = function()
|
CParaTab.prototype.Copy = function()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user