Commit 72285717 authored by Ilya Kirillov's avatar Ilya Kirillov

В апи билдера добавлена функция InsertContent для вставки содержимого в...

В апи билдера добавлена функция InsertContent для вставки содержимого в текущую позицию документа. Исправлен баг со вставкой, если первым элементом вставки идет таблица.
parent deb7375c
......@@ -10425,6 +10425,10 @@ CDocument.prototype.Insert_Content = function(SelectedContent, NearPo
ParaS.Selection.StartPos = ParaS.Content.length - _ParaSContentLen;
ParaS.Selection.EndPos = ParaS.Content.length - 1;
}
else if (true !== Para.Cursor_IsStart())
{
DstIndex++;
}
var EndIndex = ElementsCount - 1;
if (true === bConcatE && StartIndex < EndIndex)
......
......@@ -1184,6 +1184,51 @@
return new ApiNumbering(oNumbering);
};
/**
* Insert an array of elements in the current position of the document.
* @param {DocumentElement[]} arrContent - An array of elements to insert.
* @returns {boolean} Success?
*/
ApiDocument.prototype.InsertContent = function(arrContent)
{
var oParagraph = this.Document.Content[this.Document.CurPos.ContentPos];
if (!oParagraph || !(oParagraph instanceof Paragraph))
return false;
var oNearestPos = {
Paragraph : oParagraph,
ContentPos : oParagraph.Get_ParaContentPos(false, false)
};
oParagraph.Check_NearestPos(oNearestPos);
var oSelectedContent = new CSelectedContent();
for (var nIndex = 0, nCount = arrContent.length; nIndex < nCount; ++nIndex)
{
var oElement = arrContent[nIndex];
if (oElement instanceof ApiParagraph || oElement instanceof ApiTable)
{
oSelectedContent.Add(new CSelectedElement(oElement.private_GetImpl(), true));
}
}
if (!this.Document.Can_InsertContent(oSelectedContent, oNearestPos))
return false;
if (this.Document.Is_SelectionUse())
{
this.Document.Start_SilentMode();
this.Document.Remove(1, false, false, false);
this.Document.End_SilentMode();
this.Document.Selection_Remove(true);
}
this.Document.Insert_Content(oSelectedContent, oNearestPos);
this.Document.Selection_Remove(true);
oParagraph.Clear_NearestPosArray();
return true;
};
//------------------------------------------------------------------------------------------------------------------
//
// ApiParagraph
......@@ -3951,6 +3996,7 @@
ApiDocument.prototype["CreateSection"] = ApiDocument.prototype.CreateSection;
ApiDocument.prototype["SetEvenAndOddHdrFtr"] = ApiDocument.prototype.SetEvenAndOddHdrFtr;
ApiDocument.prototype["CreateNumbering"] = ApiDocument.prototype.CreateNumbering;
ApiDocument.prototype["InsertContent"] = ApiDocument.prototype.InsertContent;
ApiParagraph.prototype["GetClassType"] = ApiParagraph.prototype.GetClassType;
ApiParagraph.prototype["AddText"] = ApiParagraph.prototype.AddText;
......@@ -4620,4 +4666,4 @@
this.private_OnChange();
};
}(window, null));
\ No newline at end of file
}(window, null));
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