Commit ec39bc43 authored by Sergey Luzyanin's avatar Sergey Luzyanin

Composite input

parent cd93e545
......@@ -738,6 +738,12 @@ function CDrawingDocument()
this.AutoShapesTrack = null;
this.TransitionSlide = new CTransitionAnimation(null);
this.MoveTargetInInputContext = function()
{
if (AscCommon.g_inputContext)
AscCommon.g_inputContext.move(this.TargetHtmlElementLeft, this.TargetHtmlElementTop);
}
this.GetTargetStyle = function()
{
return "rgb(" + this.TargetCursorColor.R + "," + this.TargetCursorColor.G + "," + this.TargetCursorColor.B + ")";
......@@ -4331,6 +4337,7 @@ function CThumbnailsManager()
this.m_bIsUpdate = false;
}
this.SetFocusElement = function(type)
{
switch (type)
......
......@@ -474,6 +474,7 @@ function CPresentation(DrawingDocument)
this.LastUpdateTargetTime = 0;
this.NeedUpdateTargetForCollaboration = false;
this.oLastCheckContent = null;
this.CompositeInput = null;
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
//
......@@ -493,6 +494,168 @@ function CPresentation(DrawingDocument)
CPresentation.prototype =
{
//----------------------------------------------------------------------------------------------------------------------
// Функции для работы с составным вводом
//----------------------------------------------------------------------------------------------------------------------
/**
* Сообщаем о начале составного ввода текста.
* @returns {boolean} Начался или нет составной ввод.
*/
Get_TargetDocContent: function(){
if(this.Slides[this.CurPage] && this.Slides[this.CurPage].graphicObjects){
return this.Slides[this.CurPage].graphicObjects.getTargetDocContent();
}
return null;
},
Begin_CompositeInput: function()
{
if (false === this.Document_Is_SelectionLocked(changestype_Drawing_Props, null, true))
{
this.Create_NewHistoryPoint(AscDFH.historydescription_Document_CompositeInput);
this.DrawingDocument.TargetStart();
this.DrawingDocument.TargetShow();
var oContent = this.Get_TargetDocContent();
if (!oContent)
{
this.History.Remove_LastPoint();
return false;
}
var oPara = oContent.Get_CurrentParagraph();
if (!oPara)
{
this.History.Remove_LastPoint();
return false;
}
if (true === oContent.Is_SelectionUse())
oContent.Remove(1, true, false, true);
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;
},
addCompositeText: function(nCharCode){
// TODO: При таком вводе не меняется язык в зависимости от раскладки, не учитывается режим рецензирования.
if (null === this.CompositeInput)
return;
var oRun = this.CompositeInput.Run;
var nPos = this.CompositeInput.Pos + this.CompositeInput.Length;
var oChar;
if (32 == nCharCode || 12288 == nCharCode)
{
oChar = new ParaSpace();
}
else
{
oChar = new ParaText();
oChar.Set_CharCode(nCharCode);
}
oRun.Add_ToContent(nPos, oChar, true);
this.CompositeInput.Length++;
},
Add_CompositeText: function(nCharCode)
{
this.addCompositeText(nCharCode);
this.Recalculate();
this.Document_UpdateSelectionState();
},
removeCompositeText: function(nCount){
if (null === this.CompositeInput)
return;
var oRun = this.CompositeInput.Run;
var nPos = this.CompositeInput.Pos + this.CompositeInput.Length;
var nDelCount = Math.max(0, Math.min(nCount, this.CompositeInput.Length, oRun.Content.length, nPos));
oRun.Remove_FromContent(nPos - nDelCount, nDelCount, true);
this.CompositeInput.Length -= nDelCount;
},
Remove_CompositeText: function(nCount){
this.removeCompositeText(nCount);
this.Recalculate();
this.Document_UpdateSelectionState();
},
Replace_CompositeText: function(arrCharCodes)
{
if (null === this.CompositeInput)
return;
this.removeCompositeText(this.CompositeInput.Length);
for (var nIndex = 0, nCount = arrCharCodes.length; nIndex < nCount; ++nIndex)
{
this.addCompositeText(arrCharCodes[nIndex]);
}
this.Recalculate();
this.Document_UpdateSelectionState();
},
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();
},
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;
},
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();
},
Get_MaxCursorPosInCompositeText: function()
{
if (null === this.CompositeInput)
return 0;
return this.CompositeInput.Length;
},
setShowLoop: function(value){
if(value === false){
if(!this.showPr){
......
......@@ -6049,6 +6049,74 @@ background-repeat: no-repeat;\
}, fCallback, null, oAdditionalData, dataContainer);
};
// input
asc_docs_api.prototype.Begin_CompositeInput = function()
{
if (this.WordControl.m_oLogicDocument)
return this.WordControl.m_oLogicDocument.Begin_CompositeInput();
return null;
};
asc_docs_api.prototype.Add_CompositeText = function(nCharCode)
{
if (this.WordControl.m_oLogicDocument)
return this.WordControl.m_oLogicDocument.Add_CompositeText(nCharCode);
return null;
};
asc_docs_api.prototype.Remove_CompositeText = function(nCount)
{
if (this.WordControl.m_oLogicDocument)
return this.WordControl.m_oLogicDocument.Remove_CompositeText(nCount);
return null;
};
asc_docs_api.prototype.Replace_CompositeText = function(arrCharCodes)
{
if (this.WordControl.m_oLogicDocument)
return this.WordControl.m_oLogicDocument.Replace_CompositeText(arrCharCodes);
return null;
};
asc_docs_api.prototype.Set_CursorPosInCompositeText = function(nPos)
{
if (this.WordControl.m_oLogicDocument)
return this.WordControl.m_oLogicDocument.Set_CursorPosInCompositeText(nPos);
return null;
};
asc_docs_api.prototype.Get_CursorPosInCompositeText = function()
{
if (this.WordControl.m_oLogicDocument)
return this.WordControl.m_oLogicDocument.Get_CursorPosInCompositeText();
return 0;
};
asc_docs_api.prototype.End_CompositeInput = function()
{
if (this.WordControl.m_oLogicDocument)
return this.WordControl.m_oLogicDocument.End_CompositeInput();
return null;
};
asc_docs_api.prototype.Get_MaxCursorPosInCompositeText = function()
{
if (this.WordControl.m_oLogicDocument)
return this.WordControl.m_oLogicDocument.Get_MaxCursorPosInCompositeText();
return 0;
};
asc_docs_api.prototype.Input_UpdatePos = function()
{
if (this.WordControl.m_oLogicDocument)
this.WordControl.m_oDrawingDocument.MoveTargetInInputContext();
};
asc_docs_api.prototype.onKeyDown = function(e)
{
return this.WordControl.onKeyDown(e);
};
asc_docs_api.prototype.onKeyPress = function(e)
{
return this.WordControl.onKeyPress(e);
};
asc_docs_api.prototype.onKeyUp = function(e)
{
return this.WordControl.onKeyUp(e);
};
//test
window["asc_docs_api"] = asc_docs_api;
window["asc_docs_api"].prototype["asc_nativeOpenFile"] = function(base64File, version)
......@@ -6708,6 +6776,20 @@ background-repeat: no-repeat;\
asc_docs_api.prototype["asc_pluginButtonClick"] = asc_docs_api.prototype.asc_pluginButtonClick;
asc_docs_api.prototype["asc_addOleObject"] = asc_docs_api.prototype.asc_addOleObject;
asc_docs_api.prototype["asc_editOleObject"] = asc_docs_api.prototype.asc_editOleObject;
asc_docs_api.prototype["Begin_CompositeInput"] = asc_docs_api.prototype.Begin_CompositeInput;
asc_docs_api.prototype["Add_CompositeText"] = asc_docs_api.prototype.Add_CompositeText;
asc_docs_api.prototype["Remove_CompositeText"] = asc_docs_api.prototype.Remove_CompositeText;
asc_docs_api.prototype["Replace_CompositeText"] = asc_docs_api.prototype.Replace_CompositeText;
asc_docs_api.prototype["Set_CursorPosInCompositeText"] = asc_docs_api.prototype.Set_CursorPosInCompositeText;
asc_docs_api.prototype["Get_CursorPosInCompositeText"] = asc_docs_api.prototype.Get_CursorPosInCompositeText;
asc_docs_api.prototype["End_CompositeInput"] = asc_docs_api.prototype.End_CompositeInput;
asc_docs_api.prototype["Get_MaxCursorPosInCompositeText"] = asc_docs_api.prototype.Get_MaxCursorPosInCompositeText;
asc_docs_api.prototype["Input_UpdatePos"] = asc_docs_api.prototype.Input_UpdatePos;
asc_docs_api.prototype["onKeyDown"] = asc_docs_api.prototype.onKeyDown;
asc_docs_api.prototype["onKeyPress"] = asc_docs_api.prototype.onKeyPress;
asc_docs_api.prototype["onKeyUp"] = asc_docs_api.prototype.onKeyUp;
window['Asc']['asc_CCommentData'] = window['Asc'].asc_CCommentData = asc_CCommentData;
asc_CCommentData.prototype['asc_getText'] = asc_CCommentData.prototype.asc_getText;
......
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