Fix adding a textArt to a paragraph with RTL direction
This commit is contained in:
Ilya Kirillov
2025-03-28 18:58:26 +03:00
parent 9ea9f80a2e
commit c49bb46e40
3 changed files with 45 additions and 42 deletions

View File

@ -6310,9 +6310,48 @@ CDocument.prototype.EditOleObject = function(oOleObject, sData, sImageUrl, fWidt
{
oOleObject.editExternal(sData, sImageUrl, fWidth, fHeight, nPixWidth, nPixHeight, arrImagesForAddToHistory);
};
CDocument.prototype.AddTextArt = function(nStyle)
CDocument.prototype.AddTextArt = function(textArtStyle)
{
this.Controller.AddTextArt(nStyle);
let curParagraph = this.GetCurrentParagraph();
if (!curParagraph)
return;
let drawing = new AscWord.ParaDrawing(1828800 / 36000, 1828800 / 36000, null, this.DrawingDocument, this, null);
let textArt = this.DrawingObjects.createTextArt(textArtStyle, true);
textArt.setParent(drawing);
drawing.Set_GraphicObject(textArt);
drawing.Set_DrawingType(drawing_Anchor);
drawing.Set_WrappingType(WRAPPING_TYPE_NONE);
drawing.Set_BehindDoc(false);
drawing.Set_Distance(3.2, 0, 3.2, 0);
drawing.Set_PositionV(Asc.c_oAscRelativeFromV.Paragraph, false, 0, false);
if (curParagraph.isRtlDirection())
drawing.Set_PositionH(Asc.c_oAscRelativeFromH.Column, true, Asc.c_oAscAlignH.Right, false);
else
drawing.Set_PositionH(Asc.c_oAscRelativeFromH.Column, false, 0, false);
let docContent = textArt.getDocContent();
let directParaPr = curParagraph.GetDirectParaPr(false);
if (undefined !== directParaPr.Bidi)
{
docContent.GetAllParagraphs().forEach(function(p){
p.SetParagraphBidi(directParaPr.Bidi);
});
}
this.RemoveBeforePaste();
this.AddToParagraph(drawing);
if (textArt.bSelectedText)
{
this.Select_DrawingObject(drawing.GetId());
}
else
{
docContent.SelectAll();
docContent.SetThisElementCurrent();
}
};
CDocument.prototype.AddSignatureLine = function(oSignatureDrawing){
@ -19756,42 +19795,6 @@ CDocument.prototype.controller_AddOleObject = function(W, H, nWidthPix, nHeightP
}
return Drawing;
};
CDocument.prototype.controller_AddTextArt = function(nStyle)
{
var Item = this.Content[this.CurPos.ContentPos];
if (type_Paragraph == Item.GetType())
{
var Drawing = new ParaDrawing(1828800 / 36000, 1828800 / 36000, null, this.DrawingDocument, this, null);
var TextArt = this.DrawingObjects.createTextArt(nStyle, true);
TextArt.setParent(Drawing);
Drawing.Set_GraphicObject(TextArt);
Drawing.Set_DrawingType(drawing_Anchor);
Drawing.Set_WrappingType(WRAPPING_TYPE_NONE);
Drawing.Set_BehindDoc(false);
Drawing.Set_Distance(3.2, 0, 3.2, 0);
Drawing.Set_PositionH(Asc.c_oAscRelativeFromH.Column, false, 0, false);
Drawing.Set_PositionV(Asc.c_oAscRelativeFromV.Paragraph, false, 0, false);
if (true == this.Selection.Use)
this.Remove(1, true);
this.AddToParagraph(Drawing);
if (TextArt.bSelectedText)
{
this.Select_DrawingObject(Drawing.Get_Id());
}
else
{
var oContent = Drawing.GraphicObj.getDocContent();
oContent.Content[0].Document_SetThisElementCurrent(false);
this.SelectAll();
}
}
else
{
Item.AddTextArt(nStyle);
}
};
CDocument.prototype.controller_AddSignatureLine = function(oSignatureDrawing)
{
var Item = this.Content[this.CurPos.ContentPos];

View File

@ -73,10 +73,6 @@ CLogicDocumentController.prototype.AddOleObject = function(nW, nH, nWidthPix, nH
{
return this.LogicDocument.controller_AddOleObject(nW, nH, nWidthPix, nHeightPix, oImage, oData, sApplicationId, bSelect, arrImagesForAddToHistory);
};
CLogicDocumentController.prototype.AddTextArt = function(nStyle)
{
this.LogicDocument.controller_AddTextArt(nStyle);
};
CLogicDocumentController.prototype.EditChart = function(Chart)
{
// Ничего не делаем

View File

@ -4272,3 +4272,7 @@ CAnchorPosition.prototype.Calculate_Y_Value = function(RelativeFrom)
//--------------------------------------------------------export----------------------------------------------------
window['AscCommonWord'] = window['AscCommonWord'] || {};
window['AscCommonWord'].ParaDrawing = ParaDrawing;
window['AscWord'] = window['AscWord'] || {};
window['AscWord'].ParaDrawing = ParaDrawing;