Skip to content

Commit

Permalink
[de] Add ability to create temporary history points
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillovIlya committed Jul 27, 2023
1 parent 76dae27 commit 41a4c29
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 16 deletions.
41 changes: 30 additions & 11 deletions word/Drawing/Rulers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1218,13 +1218,15 @@ function CHorRuler()
if (newVal > _margin_right)
newVal = _margin_right;
}

this.m_dIndentRight = _margin_right - newVal;
word_control.UpdateHorRulerBack();

var pos = left + (_margin_right - this.m_dIndentRight) * dKoef_mm_to_pix;
word_control.m_oOverlayApi.VertLine(pos);

// if (!this.SimpleChanges.IsSimple)
// this.SetPrProperties(true);

break;
}
case 7:
Expand Down Expand Up @@ -2270,18 +2272,35 @@ function CHorRuler()
}
}

this.SetPrProperties = function()
this.SetPrProperties = function(isTemporary)
{
if (false === this.m_oWordControl.m_oLogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_Paragraph_Properties))
let left = this.m_dIndentLeft;
let right = this.m_dIndentRight;
let firstLine = this.m_dIndentLeftFirst - this.m_dIndentLeft;

let logicDocument = this.m_oWordControl.m_oLogicDocument;
if (logicDocument.IsSelectionLocked(AscCommon.changestype_Paragraph_Properties))
return;

isTemporary = isTemporary && logicDocument.IsDocumentEditor();

if (isTemporary)
logicDocument.TurnOff_InterfaceEvents();

logicDocument.StartAction(AscDFH.historydescription_Document_SetParagraphIndentFromRulers);
logicDocument.SetParagraphIndent({
Left : left,
Right : right,
FirstLine : firstLine
});
logicDocument.UpdateInterface();
logicDocument.Recalculate();
logicDocument.FinalizeAction();

if (isTemporary)
{
this.m_oWordControl.m_oLogicDocument.StartAction(AscDFH.historydescription_Document_SetParagraphIndentFromRulers);
this.m_oWordControl.m_oLogicDocument.SetParagraphIndent({
Left : this.m_dIndentLeft,
Right : this.m_dIndentRight,
FirstLine : (this.m_dIndentLeftFirst - this.m_dIndentLeft)
});
this.m_oWordControl.m_oLogicDocument.Document_UpdateInterfaceState();
this.m_oWordControl.m_oLogicDocument.FinalizeAction();
AscCommon.History.SetLastPointTemporary();
logicDocument.TurnOn_InterfaceEvents();
}
}
this.SetMarginProperties = function()
Expand Down
4 changes: 4 additions & 0 deletions word/Editor/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -12333,7 +12333,11 @@ CDocument.prototype.SetWatermarkProps = function(oProps)
*/
CDocument.prototype.TurnOff_InterfaceEvents = function()
{
if (this.TurnOffInterfaceEvents)
return false;

this.TurnOffInterfaceEvents = true;
return true;
};
/**
* Включаем отсылку сообщений в интерфейс.
Expand Down
26 changes: 25 additions & 1 deletion word/Editor/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ CHistory.prototype =
{
if ( 0 !== this.TurnOffHistory )
return false;


this.RemoveLastTemporaryPoint();

if (this.Document && this.Document.ClearListsCache)
this.Document.ClearListsCache();

Expand All @@ -337,6 +339,7 @@ CHistory.prototype =
Items : Items, // Массив изменений, начиная с текущего момента
Time : Time, // Текущее время
Additional : {}, // Дополнительная информация
Temporary : false,
Description: nDescription
};

Expand Down Expand Up @@ -1094,6 +1097,27 @@ CHistory.prototype =
if (this.Points[this.Index] && this.Points[this.Index].Additional.FormFilling)
delete this.Points[this.Index].Additional.FormFilling;
};
CHistory.prototype.SetLastPointTemporary = function()
{
if (this.Index < 0)
return;

this.Points[this.Index].Temporary = true;
};
CHistory.prototype.RemoveLastTemporaryPoint = function()
{
if (this.Index < 0
|| !this.Document.IsDocumentEditor()
|| !this.Points[this.Index].Temporary)
return;

let needOn = this.Document.TurnOff_InterfaceEvents();
let changes = this.Undo();
this.Document.UpdateAfterUndoRedo(changes);

if (needOn)
this.Document.TurnOn_InterfaceEvents();
};
CHistory.prototype.ClearAdditional = function()
{
if (this.Index >= 0)
Expand Down
2 changes: 0 additions & 2 deletions word/Editor/Paragraph/TextHyphenator.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
}
CTextHyphenator.prototype.Hyphenate = function(paragraph)
{
console.log(`Start hyphenate paragraph ${paragraph.GetId()}`);

let self = this;
paragraph.CheckRunContent(function(run, startPos, endPos)
{
Expand Down
2 changes: 0 additions & 2 deletions word/Editor/Paragraph_Recalculate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3413,7 +3413,6 @@ CParagraphRecalculateStateWrap.prototype =
if (!this.LastHyphenItem)
return;

console.log("Reset ");
this.LastHyphenItem.SetTemporaryHyphenAfter(false);
this.LastHyphenItem = null;
},
Expand All @@ -3431,7 +3430,6 @@ CParagraphRecalculateStateWrap.prototype =
if (X + hyphenWidth > XEnd)
return;

console.log("Check " + String.fromCodePoint(item.GetCodePoint()));
this.LastHyphenItem = item;
item.SetTemporaryHyphenAfter(true);
},
Expand Down

0 comments on commit 41a4c29

Please sign in to comment.