Commit 27165ad9 authored by Ilya Kirillov's avatar Ilya Kirillov

Добавлены функции для работы с составным вводом.

parent 7a64e0f7
......@@ -1443,6 +1443,9 @@ function CDocument(DrawingDocument, isMainLogicDocument)
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
this.TableId.Add(this, this.Id);
// Объект для составного ввода текста
this.CompositeInput = null;
this.StartTime = 0;
}
AscCommon.extendClass(CDocument, CDocumentContentBase);
......@@ -16845,6 +16848,135 @@ CDocument.prototype.EndPreview_MailMergeResult = function(){};
CDocument.prototype.Continue_TrackRevisions = function(){};
CDocument.prototype.Set_TrackRevisions = function(bTrack){};
//----------------------------------------------------------------------------------------------------------------------
// Функции для работы с составным вводом
//----------------------------------------------------------------------------------------------------------------------
/**
* Сообщаем о начале составного ввода текста.
* @returns {boolean} Начался или нет составной ввод.
*/
CDocument.prototype.Begin_CompositeInput = function()
{
if (false === this.Document_Is_SelectionLocked(changestype_Paragraph_Content, null, true))
{
this.Create_NewHistoryPoint(AscDFH.historydescription_Document_CompositeInput);
this.DrawingDocument.TargetStart();
this.DrawingDocument.TargetShow();
if (true === this.Is_SelectionUse())
this.Remove(1, true, false, true);
var oPara = this.Get_CurrentParagraph();
if (!oPara)
{
this.History.Remove_LastPoint();
return false;
}
var oRun = oPara.Get_ElementByPos(oPara.Get_ParaContentPos(false, false));
if (!oRun || !(oRun instanceof ParaRun))
{
this.History.Remove_LastPoint();
return false;
}
this.CompositeInput = {
Run : oRun,
Pos : oRun.State.ContentPos,
Length : 0
};
oRun.Set_CompositeInput(this.CompositeInput);
return true;
}
return false;
};
CDocument.prototype.Add_CompositeText = function(nCharCode)
{
// TODO: При таком вводе не меняется язык в зависимости от раскладки, не учитывается режим рецензирования.
if (null === this.CompositeInput)
return;
var oRun = this.CompositeInput.Run;
var nPos = this.CompositeInput.Pos + this.CompositeInput.Length;
var oChar = new ParaText();
oChar.Set_CharCode(nCharCode);
oRun.Add_ToContent(nPos, oChar, true);
this.CompositeInput.Length++;
this.Recalculate();
this.Document_UpdateSelectionState();
};
CDocument.prototype.Remove_CompositeText = function(nCount)
{
if (null === this.CompositeInput)
return;
var oRun = this.CompositeInput.Run;
var nPos = this.CompositeInput.Pos + this.CompositeInput.Length;
var nDelCount = Math.min(nCount, this.CompositeInput.Length, oRun.Content.length - 1, nPos);
oRun.Remove_FromContent(nPos - nDelCount, nDelCount, true);
this.CompositeInput.Length -= nDelCount;
this.Recalculate();
this.Document_UpdateSelectionState();
};
CDocument.prototype.Replace_CompositeText = function(arrCharCodes)
{
if (null === this.CompositeInput)
return;
this.Start_SilentMode();
this.Remove_CompositeText(this.CompositeInput.Length);
for (var nIndex = 0, nCount = arrCharCodes.length; nIndex < nCount; ++nIndex)
{
this.Add_CompositeText(arrCharCodes[nIndex]);
}
this.End_SilentMode(false);
this.Recalculate();
this.Document_UpdateSelectionState();
};
CDocument.prototype.Set_CursorPosInCompositeText = function(nPos)
{
if (null === this.CompositeInput)
return;
var oRun = this.CompositeInput.Run;
var nInRunPos = Math.max(Math.min(this.CompositeInput.Pos + nPos, this.CompositeInput.Pos + this.CompositeInput.Length, oRun.Content.length), this.CompositeInput.Pos);
oRun.State.ContentPos = nInRunPos;
this.Document_UpdateSelectionState();
};
CDocument.prototype.Get_CursorPosInCompositeText = function()
{
if (null === this.CompositeInput)
return 0;
var oRun = this.CompositeInput.Run;
var nInRunPos = oRun.State.ContentPos;
var nPos = Math.min(this.CompositeInput.Length, Math.max(0, nInRunPos - this.CompositeInput.Pos));
return nPos;
};
CDocument.prototype.End_CompositeInput = function()
{
if (null === this.CompositeInput)
return;
var oRun = this.CompositeInput.Run;
oRun.Set_CompositeInput(null);
this.CompositeInput = null;
this.Document_UpdateInterfaceState();
this.DrawingDocument.ClearCachePages();
this.DrawingDocument.FirePaint();
};
//----------------------------------------------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------------------------------------------
function CDocumentSelectionState()
......@@ -17826,4 +17958,4 @@ CDocumentSectionProps.prototype["put_BottomMargin"] = CDocumentSectionProps.pr
CDocumentSectionProps.prototype["get_HeaderDistance"] = CDocumentSectionProps.prototype.get_HeaderDistance;
CDocumentSectionProps.prototype["put_HeaderDistance"] = CDocumentSectionProps.prototype.put_HeaderDistance;
CDocumentSectionProps.prototype["get_FooterDistance"] = CDocumentSectionProps.prototype.get_FooterDistance;
CDocumentSectionProps.prototype["put_FooterDistance"] = CDocumentSectionProps.prototype.put_FooterDistance;
CDocumentSectionProps.prototype["put_FooterDistance"] = CDocumentSectionProps.prototype.put_FooterDistance;
\ No newline at end of file
......@@ -79,6 +79,8 @@ function ParaRun(Paragraph, bMathRun)
}
this.StartState = null;
this.CompositeInput = null;
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
if(this.Paragraph && !this.Paragraph.bFromDocument)
......@@ -4729,6 +4731,11 @@ ParaRun.prototype.Draw_Lines = function(PDSL)
case para_Separator:
case para_ContinuationSeparator:
{
if (para_Text === ItemType && null !== this.CompositeInput && Pos >= this.CompositeInput.Pos && Pos < this.CompositeInput.Pos + this.CompositeInput.Length)
{
aUnderline.Add(UnderlineY, UnderlineY, X, X + ItemWidthVisible, LineW, CurColor.r, CurColor.g, CurColor.b, undefined, CurTextPr);
}
if ( para_Drawing != ItemType || Item.Is_Inline() )
{
if (true === bRemReview)
......@@ -10952,6 +10959,10 @@ ParaRun.prototype.Math_UpdateLineMetrics = function(PRS, ParaPr)
}
};
ParaRun.prototype.Set_CompositeInput = function(oCompositeInput)
{
this.CompositeInput = oCompositeInput;
};
function CParaRunStartState(Run)
{
......
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