Skip to content

Commit 33129fc

Browse files
authored
Word Export: LT-21673: Fix color for RTL Before/After (#356)
We were not getting a writing system so we were using the wrong style for the Before/After content. Added an additional way to get a writing system for Before/After content.
1 parent 4ae850b commit 33129fc

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Src/xWorks/LcmWordGenerator.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,43 @@ private IFragment WriteProcessedElementContent(List<ConfigurableDictionaryNode>
11171117
wsId = runElem?.WritingSystemId;
11181118
}
11191119

1120+
// If we still don't have a writing system, then try getting it from the leaf node.
1121+
if (wsId == null)
1122+
{
1123+
if (nodeList.Last().DictionaryNodeOptions != null &&
1124+
nodeList.Last().DictionaryNodeOptions is DictionaryNodeWritingSystemOptions wsOptions)
1125+
{
1126+
// If only one ws options is enabled then use it.
1127+
var enabledWsOptions = wsOptions.Options.Where(opt => opt.IsEnabled);
1128+
if (enabledWsOptions.Count() == 1)
1129+
{
1130+
string enabledWsName = enabledWsOptions.First().Id;
1131+
string wsIdString = null;
1132+
var possiblyMagic = WritingSystemServices.GetMagicWsIdFromName(enabledWsName);
1133+
// If the writing system name isn't a magic name just use it.
1134+
if (possiblyMagic == 0)
1135+
{
1136+
wsIdString = enabledWsName;
1137+
}
1138+
// Else get the writing system name from the magic list.
1139+
else
1140+
{
1141+
var wsList = WritingSystemServices.GetWritingSystemList(Cache, possiblyMagic, false);
1142+
if (wsList.Count != 0)
1143+
{
1144+
wsIdString = wsList.First().Id;
1145+
}
1146+
}
1147+
1148+
if (!string.IsNullOrEmpty(wsIdString))
1149+
{
1150+
wsId = Cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr(wsIdString);
1151+
wsId = wsId == 0 ? null : wsId;
1152+
}
1153+
}
1154+
}
1155+
}
1156+
11201157
// Add Before text, if it is not going to be displayed in a paragraph.
11211158
if (!eachInAParagraph && !string.IsNullOrEmpty(config.Before))
11221159
{

0 commit comments

Comments
 (0)