Skip to content

Commit

Permalink
[de] Fix test with adding line break
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillovIlya committed Jan 15, 2025
1 parent aa65aed commit ea7c600
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tests/word/shortcuts/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,10 @@
TurnOnRecalculate();
ClearDocumentAndAddParagraph('');
const complexForm = AddComplexForm();
AscTest.Recalculate();
assert.strictEqual(complexForm.GetLinesCount(), 1, "Check line count before adding line break");
ExecuteHotkey(testHotkeyActions.addBreakLineInlineLvlSdt);
assert.strictEqual(complexForm.Lines[0], 2, "Check add break line");
assert.strictEqual(complexForm.GetLinesCount(), 2, "Check line count after adding line break");
TurnOffRecalculate();
});

Expand Down
20 changes: 19 additions & 1 deletion word/Editor/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -9750,8 +9750,21 @@ CDocument.prototype.executeShortcut = function(type)
{
if (!this.IsSelectionLocked(AscCommon.changestype_Paragraph_Content, null, false, this.IsFormFieldEditing()))
{
let selectedInfo = this.GetSelectedElementsInfo();
let math = selectedInfo.GetMath();

this.StartAction(AscDFH.historydescription_Document_EnterButton);
this.AddToParagraph(new AscWord.CRunBreak(AscWord.break_Line));
if (math && math.Is_InInnerContent())
{
math.Handle_AddNewLine();
math.ProcessAutoCorrect();
// TODO: Implement case !math.Is_InInnerContent()
}
else
{
this.AddToParagraph(new AscWord.CRunBreak(AscWord.break_Line));
}
this.Recalculate();
this.FinalizeAction();
result = true;
}
Expand Down Expand Up @@ -11841,9 +11854,14 @@ CDocument.prototype.EndFormEditing = function()
if (oInlineSdt && oInlineSdt.IsForm())
{
if (oInlineSdt.IsFixedForm())
{
this.EndDrawingEditing();
}
else
{
this.RemoveSelection();
oInlineSdt.MoveCursorOutsideElement(true);
}

this.UpdateSelection();
this.UpdateInterface();
Expand Down
8 changes: 8 additions & 0 deletions word/Editor/ParagraphContentBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ CParagraphContentBase.prototype.GetLogicDocument = function()
{
return this.Paragraph ? this.Paragraph.GetLogicDocument() : null;
};
CParagraphContentBase.prototype.GetLinesCount = function()
{
return 0;
};
CParagraphContentBase.prototype.CanSplit = function()
{
return false;
Expand Down Expand Up @@ -1062,6 +1066,10 @@ CParagraphContentWithContentBase.prototype.getRangePos = function(line, range)
this.protected_GetRangeEndPos(_line, _range),
];
};
CParagraphContentWithContentBase.prototype.GetLinesCount = function()
{
return this.protected_GetLinesCount();
};

// Здесь предполагается, что строки с номерами меньше, чем LineIndex заданы, а также заданы и отрезки в строке
// LineIndex, с номерами меньшими, чем RangeIndex. В данной функции удаляются все записи, которые идут после LineIndex,
Expand Down

0 comments on commit ea7c600

Please sign in to comment.