Skip to content

Commit

Permalink
Merge branch 'release/9.1' into RootNames
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-sil authored Jun 20, 2024
2 parents 5a8c960 + 05ef16a commit 7d54524
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
14 changes: 13 additions & 1 deletion Src/xWorks/LcmWordGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using SIL.FieldWorks.Common.FwUtils;
using SIL.FieldWorks.Common.Widgets;
using SIL.LCModel;
using SIL.LCModel.Core.WritingSystems;
using SIL.LCModel.DomainServices;
using SIL.LCModel.Utils;
using Style = DocumentFormat.OpenXml.Wordprocessing.Style;
Expand Down Expand Up @@ -699,6 +700,17 @@ public void AddRun(LcmCache cache, ConfigurableDictionaryNode config, ReadOnlyPr
public IFragment GenerateWsPrefixWithString(ConfigurableDictionaryNode config, ConfiguredLcmGenerator.GeneratorSettings settings,
bool displayAbbreviation, int wsId, IFragment content)
{
if (displayAbbreviation)
{
// Prepend the run with the abbreviation content and abbreviation style.
string abbrev = ((CoreWritingSystemDefinition)settings.Cache.WritingSystemFactory.get_EngineOrNull(wsId)).Abbreviation;
var abbrevRun = CreateRun(abbrev, WordStylesGenerator.WritingSystemDisplayName);
((DocFragment)content).DocBody.PrependChild(abbrevRun);

// Add the abbreviation style to the _styleDictionary (if not already added).
GetOrCreateCharacterStyle(WordStylesGenerator.WritingSystemStyleName, WordStylesGenerator.WritingSystemDisplayName, _propertyTable);
}

return content;
}

Expand Down Expand Up @@ -1501,7 +1513,7 @@ public string AddStyles(ConfigurableDictionaryNode node, bool addEntryContinuati
}
else
{
styleContent = WordStylesGenerator.CheckRangeOfStylesForEmpties(WordStylesGenerator.GenerateWordStylesFromConfigurationNode(node, className, _propertyTable));
styleContent = WordStylesGenerator.CheckRangeOfStylesForEmpties(WordStylesGenerator.GenerateWordStylesFromConfigurationNode(node, _propertyTable));
}

if (styleContent == null)
Expand Down
34 changes: 4 additions & 30 deletions Src/xWorks/WordStylesGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public class WordStylesGenerator
internal const string BeforeAfterBetweenStyleName = "Dictionary-Context";
internal const string BeforeAfterBetweenDisplayName = "Context";
internal const string LetterHeadingStyleName = "Dictionary-LetterHeading";
internal const string LetterHeadingDisplayName = "LetterHeading";
internal const string LetterHeadingDisplayName = "Letter Heading";
internal const string SenseNumberStyleName = "Dictionary-SenseNumber";
internal const string SenseNumberDisplayName = "SenseNumber";
internal const string SenseNumberDisplayName = "Sense Number";
internal const string DictionaryNormal = "Dictionary-Normal";
internal const string DictionaryMinor = "Dictionary-Minor";
internal const string WritingSystemPrefix = "writingsystemprefix";
internal const string WritingSystemStyleName = "Writing System Abbreviation";
internal const string WritingSystemDisplayName = "Writing System Abbreviation";
internal const string PictureAndCaptionTextframeStyle = "Image-Textframe-Style";
internal const string EntryStyleContinue = "-Continue";
internal const string StyleSeparator = " : ";
Expand Down Expand Up @@ -313,8 +313,7 @@ internal static Style GenerateWordStyleFromLcmStyleSheet(
/// Generates openxml styles for a configuration node and adds them to the given stylesheet (recursive).
/// </summary>
public static Styles GenerateWordStylesFromConfigurationNode(
ConfigurableDictionaryNode configNode, string styleName,
ReadOnlyPropertyTable propertyTable)
ConfigurableDictionaryNode configNode, ReadOnlyPropertyTable propertyTable)
{
var cache = propertyTable.GetValue<LcmCache>("cache");
switch (configNode.DictionaryNodeOptions)
Expand All @@ -336,15 +335,6 @@ public static Styles GenerateWordStylesFromConfigurationNode(
var rule = new Style();
var rules = new Styles();

var wsOptions = configNode.DictionaryNodeOptions as DictionaryNodeWritingSystemOptions;
if (wsOptions != null)
{
if (wsOptions.DisplayWritingSystemAbbreviations)
{
rules = AddRange(rules, GenerateWordStylesForWritingSystemPrefix(configNode, styleName, propertyTable));
}
}

// if the configuration node defines a style then add all the rules generated from that style
if (!string.IsNullOrEmpty(configNode.Style))
{
Expand Down Expand Up @@ -519,22 +509,6 @@ private static Styles GenerateWordStylesFromListAndParaOptions(ConfigurableDicti
return null;
}

private static Styles GenerateWordStylesForWritingSystemPrefix(ConfigurableDictionaryNode configNode, string baseSelection, ReadOnlyPropertyTable propertyTable)
{
var styleRules = new Styles();
var wsRule1 = GetOnlyCharacterStyle(GenerateWordStyleFromLcmStyleSheet(WritingSystemStyleName, 0, configNode, propertyTable));
wsRule1.StyleId = (string.Format("{0}.{1}", baseSelection, WritingSystemPrefix)).Trim('.');
wsRule1.StyleName = new StyleName() { Val = wsRule1.StyleId };
styleRules = AddRange(styleRules, wsRule1);

// TODO: Determine how to handle after content in Word export (can't add content via a style)
/*var wsRule2 = new Style { StyleId = string.Format("{0}.{1}:after", baseSelection, WritingSystemPrefix) };
wsRule2.Declarations.Properties.Add(new Property("content") { Term = new PrimitiveTerm(UnitType.String, " ") });
styleRules.Add(wsRule2);*/

return styleRules;
}

/// <summary>
/// Create the 'continuation' style for the entry, which is needed when an entry contains multiple paragraphs. This
/// style will be used for all but the first paragraph. It is the same as the style for the first paragraph except
Expand Down

0 comments on commit 7d54524

Please sign in to comment.