Commit f0a6e378 authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented bounding path around the CInlineLevelSdt.

parent 7f04d9bc
......@@ -1104,6 +1104,7 @@
window['AscDFH'].historyitem_type_Presentation = 58 << 16;
window['AscDFH'].historyitem_type_BlockLevelSdt = 59 << 16;
window['AscDFH'].historyitem_type_SdtPr = 60 << 16;
window['AscDFH'].historyitem_type_InlineLevelSdt = 61 << 16;
window['AscDFH'].historyitem_type_CommonShape = 1000 << 16; // Этот класс добавлен для элементов, у которых нет конкретного класса
......
......@@ -262,6 +262,7 @@
this.m_oFactoryClass[AscDFH.historyitem_type_deg_subsup] = AscCommonWord.CDegreeSubSup;
this.m_oFactoryClass[AscDFH.historyitem_type_deg] = AscCommonWord.CDegree;
this.m_oFactoryClass[AscDFH.historyitem_type_BlockLevelSdt] = AscCommonWord.CBlockLevelSdt;
this.m_oFactoryClass[AscDFH.historyitem_type_InlineLevelSdt] = AscCommonWord.CInlineLevelSdt;
if (window['AscCommonSlide'])
......
......@@ -8138,8 +8138,12 @@ CDocument.prototype.private_UpdateTracks = function(bSelection, bEmptySelection)
else
this.DrawingDocument.Update_MathTrack(false);
var oBlockLevelSdt = oSelectedInfo.GetBlockLevelSdt();
if (oBlockLevelSdt)
var oBlockLevelSdt = oSelectedInfo.GetBlockLevelSdt();
var oInlineLevelSdt = oSelectedInfo.GetInlineLevelSdt();
if (oInlineLevelSdt)
oInlineLevelSdt.DrawContentControlsTrack(false);
else if (oBlockLevelSdt)
oBlockLevelSdt.DrawContentControlsTrack(false);
else
this.DrawingDocument.OnDrawContentControl(null, c_oContentControlTrack.In);
......
......@@ -48,7 +48,7 @@ function CInlineLevelSdt()
this.Pr = new CSdtPr();
this.Type = para_InlineLevelSdt;
this.BoundsPath = [];
this.BoundsPaths = null;
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add(this, this.Id);
......@@ -198,9 +198,10 @@ CInlineLevelSdt.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _C
if (0 === CurLine && 0 === CurRange && true !== PRSA.RecalcFast)
this.Bounds = {};
var X0 = PRSA.X;
var Y0 = PRSA.Y0;
var Y1 = PRSA.Y1;
var oParagraph = PRSA.Paragraph;
var Y0 = oParagraph.Lines[_CurLine].Top + oParagraph.Pages[_CurPage].Y;
var Y1 = oParagraph.Lines[_CurLine].Bottom + oParagraph.Pages[_CurPage].Y;
var X0 = PRSA.X;
CParagraphContentWithParagraphLikeContent.prototype.Recalculate_Range_Spaces.apply(this, arguments);
......@@ -214,8 +215,7 @@ CInlineLevelSdt.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _C
Page : PRSA.Paragraph.Get_AbsolutePage(_CurPage)
};
this.BoundsPath[_CurPage] = null;
this.BoundsPath.length = _CurPage;
this.BoundsPath = null;
};
CInlineLevelSdt.prototype.Get_LeftPos = function(SearchPos, ContentPos, Depth, UseContentPos)
{
......@@ -324,30 +324,30 @@ CInlineLevelSdt.prototype.Get_WordEndPos = function(SearchPos, ContentPos, Depth
};
CInlineLevelSdt.prototype.GetBoundingPolygon = function()
{
var arrRects = [];
for (var Key in this.Bounds)
if (null === this.BoundsPaths)
{
arrRects.push(this.Bounds[Key]);
}
var arrRects = [];
for (var Key in this.Bounds)
{
arrRects.push(this.Bounds[Key]);
}
var oPolygon = new CPolygon();
oPolygon.fill([arrRects]);
var oPolygon = new CPolygon();
oPolygon.fill([arrRects]);
return oPolygon.GetPaths(0);
};
CInlineLevelSdt.prototype.DrawBoundingPolygon = function(pGraphics, arrPaths)
{
pGraphics.p_color(255, 0, 0, 255);
for (var nIndex = 0, nCount = arrPaths.length; nIndex < nCount; ++nIndex)
{
pGraphics.DrawPolygon(arrPaths[nIndex], 1, 0);
this.BoundsPaths = oPolygon.GetPaths(0);
}
return this.BoundsPaths;
};
CInlineLevelSdt.prototype.Draw_Lines = function(PDSL)
CInlineLevelSdt.prototype.DrawContentControlsTrack = function(isHover)
{
CParagraphContentWithParagraphLikeContent.prototype.Draw_Lines.apply(this, arguments);
if (!this.Paragraph)
return;
this.DrawBoundingPolygon(PDSL.Graphics, this.GetBoundingPolygon());
var oDrawingDocument = this.Paragraph.Get_DrawingDocument();
oDrawingDocument.OnDrawContentControl(this.GetId(), isHover ? c_oContentControlTrack.Hover : c_oContentControlTrack.In, this.GetBoundingPolygon(), this.Get_ParentTextTransform());
};
//----------------------------------------------------------------------------------------------------------------------
// Выставление настроек
......@@ -424,7 +424,7 @@ CInlineLevelSdt.prototype.GetContentControlLock = function()
//----------------------------------------------------------------------------------------------------------------------
CInlineLevelSdt.prototype.Write_ToBinary2 = function(Writer)
{
Writer.WriteLong(AscDFH.historyitem_type_Field);
Writer.WriteLong(AscDFH.historyitem_type_InlineLevelSdt);
// String : Id
// Long : Количество элементов
......@@ -469,6 +469,9 @@ CInlineLevelSdt.prototype.UpdatePath = function(CurPage, oPath)
{
this.BoundsPath[CurPage] = oPath;
};
//--------------------------------------------------------export--------------------------------------------------------
window['AscCommonWord'] = window['AscCommonWord'] || {};
window['AscCommonWord'].CInlineLevelSdt = CInlineLevelSdt;
function TEST_ADD_SDT()
{
......@@ -485,7 +488,8 @@ function TEST_ADD_SDT()
oInlineContentControl.Add_ToContent(0, oRun);
var oPara = oLogicDocument.GetCurrentParagraph();
oPara.Add_ToContent(0, oInlineContentControl);
oPara.Add_ToContent(0, new ParaRun());
oPara.Add_ToContent(1, oInlineContentControl);
oLogicDocument.Recalculate();
......
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