From 34dd5b1741a6d4783c7b0917ca849c950398df35 Mon Sep 17 00:00:00 2001 From: Ariel Rorabaugh Date: Mon, 25 Mar 2024 11:25:37 -0400 Subject: [PATCH 1/2] LT-21633: Improve Bidi handling in Word Export - Remove unneeded TextDirection property. - Create Writing System styles so that they are based on styles that they should inherit from. Change-Id: I199bb153c039acf78932f990117ad513398807af --- Src/xWorks/WordStylesGenerator.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Src/xWorks/WordStylesGenerator.cs b/Src/xWorks/WordStylesGenerator.cs index c5d1419c01..94b1962c20 100644 --- a/Src/xWorks/WordStylesGenerator.cs +++ b/Src/xWorks/WordStylesGenerator.cs @@ -264,6 +264,7 @@ internal static Style GenerateWordStyleFromLcmStyleSheet( if (exportStyleInfo.HasTrailingIndent) { + // Check bidirectional flag to determine correct orientation for indent if (exportStyleInfo.DirectionIsRightToLeft == TriStateBool.triTrue) parProps.Append(new Indentation() { Left = MilliPtToTwentiPt(exportStyleInfo.TrailingIndent).ToString() }); else @@ -279,6 +280,7 @@ internal static Style GenerateWordStyleFromLcmStyleSheet( ancestorIndents = CalculateParagraphIndentsFromAncestors(ancestorIndents.Ancestor, styleSheet, new AncestorIndents(0f, 0f)); var leadingIndent = CalculateMarginLeft(exportStyleInfo, ancestorIndents, hangingIndent); + // Check bidirectional flag to determine correct orientation for indent if (exportStyleInfo.DirectionIsRightToLeft == TriStateBool.triTrue) parProps.Append(new Indentation() { Right = leadingIndent.ToString() }); else @@ -286,16 +288,13 @@ internal static Style GenerateWordStyleFromLcmStyleSheet( } } - // If text direction is specified, add specification to paragraph properties + // If text direction is right to left, add BiDi property to the paragraph. if (exportStyleInfo.DirectionIsRightToLeft != TriStateBool.triNotSet) { - parProps.Append(new BiDi()); - if (exportStyleInfo.DirectionIsRightToLeft == TriStateBool.triTrue) - parProps.Append(new TextDirection() { Val = TextDirectionValues.TopToBottomRightToLeft }); - - else - parProps.Append(new TextDirection() { Val = TextDirectionValues.LefToRightTopToBottom }); + { + parProps.Append(new BiDi());//BiDi = new BiDi()); + } } exportStyle.Append(parProps); } @@ -441,12 +440,18 @@ private static Style GenerateWordStyleFromWsOptions(ConfigurableDictionaryNode c // if the writing system isn't a magic name just use it otherwise find the right one from the magic list var wsIdString = possiblyMagic == 0 ? ws.Id : WritingSystemServices.GetWritingSystemList(cache, possiblyMagic, true).First().Id; var wsId = cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr(wsIdString); + var wsString = String.Format("[lang=\'{0}\']", wsIdString).Trim('.'); var wsStyle = new Style(); + if (!string.IsNullOrEmpty(configNode.Style)) wsStyle = GenerateWordStyleFromLcmStyleSheet(configNode.Style, wsId, propertyTable); - wsStyle.StyleId = configNode.Style + (String.Format("[lang=\'{0}\']", wsIdString)).Trim('.'); + //style should be based on the span for the current ws as well as the style info for the current node that is independent from the ws + wsStyle.Append(new BasedOn() { Val = "span" + wsString }); + wsStyle.Append(new BasedOn() { Val = configNode.Style }); + + wsStyle.StyleId = configNode.Style + wsString; if (!IsEmptyStyle(wsStyle)) return wsStyle; From cf12cbcaee98c46973d34959712dd5adc4b602ac Mon Sep 17 00:00:00 2001 From: Ariel Rorabaugh Date: Mon, 25 Mar 2024 11:25:37 -0400 Subject: [PATCH 2/2] LT-21633: Improve Bidi handling in Word Export - Remove unneeded TextDirection property. - Create Writing System styles so that they are based on styles that they should inherit from. Change-Id: I199bb153c039acf78932f990117ad513398807af --- Src/xWorks/WordStylesGenerator.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Src/xWorks/WordStylesGenerator.cs b/Src/xWorks/WordStylesGenerator.cs index 94b1962c20..d48bba8f7c 100644 --- a/Src/xWorks/WordStylesGenerator.cs +++ b/Src/xWorks/WordStylesGenerator.cs @@ -289,12 +289,9 @@ internal static Style GenerateWordStyleFromLcmStyleSheet( } // If text direction is right to left, add BiDi property to the paragraph. - if (exportStyleInfo.DirectionIsRightToLeft != TriStateBool.triNotSet) + if (exportStyleInfo.DirectionIsRightToLeft == TriStateBool.triTrue) { - if (exportStyleInfo.DirectionIsRightToLeft == TriStateBool.triTrue) - { - parProps.Append(new BiDi());//BiDi = new BiDi()); - } + parProps.Append(new BiDi()); } exportStyle.Append(parProps); }