Commit 32327c4e authored by Ilya Kirillov's avatar Ilya Kirillov

Breaking a paragraph in a form field or in an inline content control was...

Breaking a paragraph in a form field or in an inline content control was forbidden. Content controls are now working properly in filling form mode.
parent 98fdb987
......@@ -6199,12 +6199,17 @@ CDocument.prototype.OnKeyDown = function(e)
}
else
{
var oSelectedInfo = this.GetSelectedElementsInfo();
var CheckType = ( e.ShiftKey || e.CtrlKey ? changestype_Paragraph_Content : AscCommon.changestype_Document_Content_Add );
if (false === this.Document_Is_SelectionLocked(CheckType))
var bCanPerform = true;
if ((oSelectedInfo.GetInlineLevelSdt() && (!e.ShiftKey || e.CtrlKey)) || (oSelectedInfo.Get_Field() && oSelectedInfo.Get_Field().IsFillingForm()))
bCanPerform = false;
if (bCanPerform && false === this.Document_Is_SelectionLocked(CheckType, null, false, true !== e.CtrlKey && this.IsFormFieldEditing()))
{
this.Create_NewHistoryPoint(AscDFH.historydescription_Document_EnterButton);
var oSelectedInfo = this.GetSelectedElementsInfo();
var oMath = oSelectedInfo.Get_Math();
if (null !== oMath && oMath.Is_InInnerContent())
{
......@@ -15125,11 +15130,13 @@ CDocument.prototype.IsInFormField = function()
{
var oSelectedInfo = this.GetSelectedElementsInfo();
var oField = oSelectedInfo.Get_Field();
var oInlineSdt = oSelectedInfo.GetInlineLevelSdt();
var oBlockSdt = oSelectedInfo.GetBlockLevelSdt();
if (oSelectedInfo.Is_MixedSelection() || !oField || fieldtype_FORMTEXT !== oField.Get_FieldType())
if (oSelectedInfo.Is_MixedSelection())
return false;
return true;
return (oBlockSdt || oInlineSdt || (oField && fieldtype_FORMTEXT === oField.Get_FieldType())) ? true : false;
};
CDocument.prototype.IsFormFieldEditing = function()
{
......
......@@ -428,25 +428,9 @@ ParaField.prototype.Replace_MailMerge = function(_Value)
return true;
};
ParaField.prototype.private_GetMappedRun = function(Value)
ParaField.prototype.private_GetMappedRun = function(sValue)
{
// Создаем ран и набиваем в него заданный текст.
var oRun = new ParaRun();
for (var Index = 0, Count = Value.length; Index < Count; Index++)
{
var Char = Value[Index], oText;
if (0x20 === Char)
oText = new ParaSpace();
else
oText = new ParaText(Value[Index]);
oRun.Add_ToContent(Index, oText);
}
oRun.Set_Pr(this.Get_FirstTextPr());
return oRun;
return this.CreateRunWithText(sValue);
};
ParaField.prototype.SetFormFieldName = function(sName)
{
......@@ -474,11 +458,7 @@ ParaField.prototype.GetValue = function()
};
ParaField.prototype.SetValue = function(sValue)
{
var oRun = this.private_GetMappedRun(sValue);
oRun.Apply_TextPr(this.Get_TextPr(), undefined, true);
this.Remove_FromContent(0, this.Content.length);
this.Add_ToContent(0, oRun);
this.MoveCursorToStartPos();
this.ReplaceAllWithText(sValue);
};
ParaField.prototype.IsFillingForm = function()
{
......
......@@ -2782,6 +2782,31 @@ CParagraphContentWithParagraphLikeContent.prototype.GetSelectedContentControls =
this.Content[this.State.ContentPos].GetSelectedContentControls(arrContentControls);
}
};
CParagraphContentWithParagraphLikeContent.prototype.CreateRunWithText = function(sValue)
{
var oRun = new ParaRun();
for (var nIndex = 0, nCount = sValue.length; nIndex < nCount; ++nIndex)
{
var nChar = sValue.charCodeAt(nIndex), oText;
if (0x20 === nChar)
oText = new ParaSpace();
else
oText = new ParaText(sValue[nIndex]);
oRun.Add_ToContent(nIndex, oText);
}
oRun.Set_Pr(this.Get_FirstTextPr());
return oRun;
};
CParagraphContentWithParagraphLikeContent.prototype.ReplaceAllWithText = function(sValue)
{
var oRun = this.CreateRunWithText(sValue);
oRun.Apply_TextPr(this.Get_TextPr(), undefined, true);
this.Remove_FromContent(0, this.Content.length);
this.Add_ToContent(0, oRun);
this.MoveCursorToStartPos();
};
//----------------------------------------------------------------------------------------------------------------------
// Функции, которые должны быть реализованы в классах наследниках
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -404,7 +404,18 @@ CBlockLevelSdt.prototype.AddInlineTable = function(nCols, nRows)
};
CBlockLevelSdt.prototype.Remove = function(nCount, bOnlyText, bRemoveOnlySelection, bOnAddText)
{
return this.Content.Remove(nCount, bOnlyText, bRemoveOnlySelection, bOnAddText);
var Res = this.Content.Remove(nCount, bOnlyText, bRemoveOnlySelection, bOnAddText);
if (this.Is_Empty() && !bOnAddText && this.LogicDocument && true === this.LogicDocument.IsFillingFormMode())
{
var oParagraph = new Paragraph(this.LogicDocument.Get_DrawingDocument(), this.Content);
this.Content.Add_ToContent(0, oParagraph);
this.Content.Remove_FromContent(1, this.Content.Get_ElementsCount() - 1);
this.Content.MoveCursorToStartPos(false);
return true;
}
return Res;
};
CBlockLevelSdt.prototype.Is_Empty = function()
{
......
......@@ -166,7 +166,7 @@ CInlineLevelSdt.prototype.Remove = function(nDirection, bOnAddText)
if (this.Is_Empty() && !bOnAddText && this.Paragraph && this.Paragraph.LogicDocument && true === this.Paragraph.LogicDocument.IsFillingFormMode())
{
var sDefaultText = " ";
this.SetValue(sDefaultText);
this.ReplaceAllWithText(sDefaultText);
}
};
CInlineLevelSdt.prototype.Shift_Range = function(Dx, Dy, _CurLine, _CurRange)
......
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