Skip to content

Commit

Permalink
[de] Implement set/get rtl direction with paragraph properties
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillovIlya committed Jan 31, 2025
1 parent b6f7198 commit 3d288ac
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
12 changes: 11 additions & 1 deletion common/apiCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2680,6 +2680,7 @@ function (window, undefined) {
function asc_CParagraphProperty(obj) {

if (obj) {
this.Bidi = undefined !== obj.Bidi ? obj.Bidi : undefined;
this.ContextualSpacing = (undefined != obj.ContextualSpacing) ? obj.ContextualSpacing : null;
this.Ind = (undefined != obj.Ind && null != obj.Ind) ? new asc_CParagraphInd(obj.Ind) : null;
this.KeepLines = (undefined != obj.KeepLines) ? obj.KeepLines : null;
Expand Down Expand Up @@ -2741,6 +2742,7 @@ function (window, undefined) {
//
// PageBreakBefore : false, // начинать параграф с новой страницы

this.Bidi = undefined;
this.ContextualSpacing = undefined;
this.Ind = new asc_CParagraphInd();
this.KeepLines = undefined;
Expand Down Expand Up @@ -2776,7 +2778,13 @@ function (window, undefined) {
this.CanEditInlineCC = true;
}
}


asc_CParagraphProperty.prototype.asc_getRtlDirection = function() {
return this.Bidi;
};
asc_CParagraphProperty.prototype.asc_putRtlDirection = function(v) {
this.Bidi = v;
};
asc_CParagraphProperty.prototype.asc_getContextualSpacing = function () {
return this.ContextualSpacing;
};
Expand Down Expand Up @@ -6515,6 +6523,8 @@ function (window, undefined) {

window["Asc"]["asc_CParagraphProperty"] = window["Asc"].asc_CParagraphProperty = asc_CParagraphProperty;
prot = asc_CParagraphProperty.prototype;
prot["get_RtlDirection"] = prot["asc_getRtlDirection"] = prot.asc_getRtlDirection;
prot["put_RtlDirection"] = prot["asc_putRtlDirection"] = prot.asc_putRtlDirection;
prot["get_ContextualSpacing"] = prot["asc_getContextualSpacing"] = prot.asc_getContextualSpacing;
prot["put_ContextualSpacing"] = prot["asc_putContextualSpacing"] = prot.asc_putContextualSpacing;
prot["get_Ind"] = prot["asc_getInd"] = prot.asc_getInd;
Expand Down
12 changes: 12 additions & 0 deletions word/Editor/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -7060,6 +7060,18 @@ CDocument.prototype.GoToPage = function(nPageAbs)

return nCurPage;
};
CDocument.prototype.SetParagraphBidi = function(isRtl)
{
let paragraphs = this.GetSelectedParagraphs();
for (let i = 0; i < paragraphs.length; ++i)
{
paragraphs[i].SetParagraphBidi(isRtl);
}

this.Recalculate();
this.UpdateInterface();
this.UpdateSelection();
};
CDocument.prototype.SetParagraphAlign = function(Align)
{
var SelectedInfo = this.GetSelectedElementsInfo();
Expand Down
4 changes: 1 addition & 3 deletions word/Editor/Styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -16668,9 +16668,7 @@ CParaPr.prototype.Compare = function(ParaPr)
var Result_ParaPr = new CParaPr();
Result_ParaPr.Locked = false;

if (undefined !== this.Bidi)
Result_ParaPr.Bidi = this.Bidi;
else
if (ParaPr.Bidi === this.Bidi)
Result_ParaPr.Bidi = ParaPr.Bidi;

if (ParaPr.ContextualSpacing === this.ContextualSpacing)
Expand Down
15 changes: 5 additions & 10 deletions word/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3535,15 +3535,7 @@ background-repeat: no-repeat;\
return;

logicDocument.StartAction(AscDFH.historydescription_Document_SetParagraphBidi);

let paragraphs = logicDocument.GetSelectedParagraphs();
for (let i = 0; i < paragraphs.length; ++i)
{
paragraphs[i].SetParagraphBidi(isRtl);
}

logicDocument.Recalculate();
logicDocument.UpdateInterface();
logicDocument.SetParagraphBidi(isRtl);
logicDocument.FinalizeAction();
};
asc_docs_api.prototype._addRemoveSpaceBeforeAfterParagraph = function(event)
Expand Down Expand Up @@ -4089,6 +4081,9 @@ background-repeat: no-repeat;\

if (undefined !== Props.SuppressLineNumbers)
oLogicDocument.SetParagraphSuppressLineNumbers(Props.SuppressLineNumbers);

if (undefined !== Props.Bidi)
oLogicDocument.SetParagraphBidi(Props.Bidi);

// TODO: как только разъединят настройки параграфа и текста переделать тут
var TextPr = new AscCommonWord.CTextPr();
Expand Down Expand Up @@ -4134,7 +4129,7 @@ background-repeat: no-repeat;\

if (undefined !== Props.Ligatures)
TextPr.Ligatures = Props.Ligatures;

oLogicDocument.AddToParagraph(new AscCommonWord.ParaTextPr(TextPr));
oLogicDocument.Recalculate();
oLogicDocument.UpdateInterface();
Expand Down

0 comments on commit 3d288ac

Please sign in to comment.