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,13 +6199,18 @@ CDocument.prototype.OnKeyDown = function(e) ...@@ -6199,13 +6199,18 @@ CDocument.prototype.OnKeyDown = function(e)
} }
else else
{ {
var oSelectedInfo = this.GetSelectedElementsInfo();
var CheckType = ( e.ShiftKey || e.CtrlKey ? changestype_Paragraph_Content : AscCommon.changestype_Document_Content_Add ); 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); this.Create_NewHistoryPoint(AscDFH.historydescription_Document_EnterButton);
var oSelectedInfo = this.GetSelectedElementsInfo(); var oMath = oSelectedInfo.Get_Math();
var oMath = oSelectedInfo.Get_Math();
if (null !== oMath && oMath.Is_InInnerContent()) if (null !== oMath && oMath.Is_InInnerContent())
{ {
if (oMath.Handle_AddNewLine()) if (oMath.Handle_AddNewLine())
...@@ -15125,11 +15130,13 @@ CDocument.prototype.IsInFormField = function() ...@@ -15125,11 +15130,13 @@ CDocument.prototype.IsInFormField = function()
{ {
var oSelectedInfo = this.GetSelectedElementsInfo(); var oSelectedInfo = this.GetSelectedElementsInfo();
var oField = oSelectedInfo.Get_Field(); 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 false;
return true; return (oBlockSdt || oInlineSdt || (oField && fieldtype_FORMTEXT === oField.Get_FieldType())) ? true : false;
}; };
CDocument.prototype.IsFormFieldEditing = function() CDocument.prototype.IsFormFieldEditing = function()
{ {
......
...@@ -428,25 +428,9 @@ ParaField.prototype.Replace_MailMerge = function(_Value) ...@@ -428,25 +428,9 @@ ParaField.prototype.Replace_MailMerge = function(_Value)
return true; return true;
}; };
ParaField.prototype.private_GetMappedRun = function(Value) ParaField.prototype.private_GetMappedRun = function(sValue)
{ {
// Создаем ран и набиваем в него заданный текст. return this.CreateRunWithText(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;
}; };
ParaField.prototype.SetFormFieldName = function(sName) ParaField.prototype.SetFormFieldName = function(sName)
{ {
...@@ -474,11 +458,7 @@ ParaField.prototype.GetValue = function() ...@@ -474,11 +458,7 @@ ParaField.prototype.GetValue = function()
}; };
ParaField.prototype.SetValue = function(sValue) ParaField.prototype.SetValue = function(sValue)
{ {
var oRun = this.private_GetMappedRun(sValue); this.ReplaceAllWithText(sValue);
oRun.Apply_TextPr(this.Get_TextPr(), undefined, true);
this.Remove_FromContent(0, this.Content.length);
this.Add_ToContent(0, oRun);
this.MoveCursorToStartPos();
}; };
ParaField.prototype.IsFillingForm = function() ParaField.prototype.IsFillingForm = function()
{ {
......
...@@ -2782,6 +2782,31 @@ CParagraphContentWithParagraphLikeContent.prototype.GetSelectedContentControls = ...@@ -2782,6 +2782,31 @@ CParagraphContentWithParagraphLikeContent.prototype.GetSelectedContentControls =
this.Content[this.State.ContentPos].GetSelectedContentControls(arrContentControls); 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) ...@@ -404,7 +404,18 @@ CBlockLevelSdt.prototype.AddInlineTable = function(nCols, nRows)
}; };
CBlockLevelSdt.prototype.Remove = function(nCount, bOnlyText, bRemoveOnlySelection, bOnAddText) 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() CBlockLevelSdt.prototype.Is_Empty = function()
{ {
......
...@@ -166,7 +166,7 @@ CInlineLevelSdt.prototype.Remove = function(nDirection, bOnAddText) ...@@ -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()) if (this.Is_Empty() && !bOnAddText && this.Paragraph && this.Paragraph.LogicDocument && true === this.Paragraph.LogicDocument.IsFillingFormMode())
{ {
var sDefaultText = " "; var sDefaultText = " ";
this.SetValue(sDefaultText); this.ReplaceAllWithText(sDefaultText);
} }
}; };
CInlineLevelSdt.prototype.Shift_Range = function(Dx, Dy, _CurLine, _CurRange) 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