Skip to content

Commit

Permalink
LT-21785: Add more style support (#77)
Browse files Browse the repository at this point in the history
* LT-21785: Add more style support

- When a run is created set the style name. (It may get modified
  with basedOn information as we get other notifications.)
- Add styles during run creation.
- Allow styles to be based on other styles, which can be based on
  other styles…
- Support different styles on different document fragments.

TODO:
A remaining task is to change the style names from the
config.Style to the config.DisplayLabel.  This will improve
the style names that appear in Word. At that time we will need
to add additional code to generate a unique style name if the
properties of a style are different.
  • Loading branch information
mark-sil authored Jun 13, 2024
1 parent 4962c35 commit f8043a2
Show file tree
Hide file tree
Showing 6 changed files with 309 additions and 250 deletions.
4 changes: 2 additions & 2 deletions Src/xWorks/ConfiguredLcmGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2807,7 +2807,7 @@ private static IFragment GenerateAudioWsContent(string wsId,
private static void GenerateRunWithPossibleLink(GeneratorSettings settings, string writingSystem, IFragmentWriter writer, string style,
string text, Guid linkDestination, bool rightToLeft, ConfigurableDictionaryNode config, string externalLink = null)
{
settings.ContentGenerator.StartRun(writer, writingSystem);
settings.ContentGenerator.StartRun(writer, config, settings.PropertyTable, writingSystem);
var wsRtl = settings.Cache.WritingSystemFactory.get_Engine(writingSystem).RightToLeftScript;
if (rightToLeft != wsRtl)
{
Expand Down Expand Up @@ -3031,7 +3031,7 @@ private static void GenerateTableRow(ITsString rowUSFM, IFragmentWriter writer,
private static void GenerateError(string text, IFragmentWriter writer, GeneratorSettings settings)
{
var writingSystem = settings.Cache.WritingSystemFactory.GetStrFromWs(settings.Cache.WritingSystemFactory.UserWs);
settings.ContentGenerator.StartRun(writer, writingSystem);
settings.ContentGenerator.StartRun(writer, null, settings.PropertyTable, writingSystem);
settings.ContentGenerator.SetRunStyle(writer, null, settings.PropertyTable, writingSystem, null, true);
if (text.Contains(TxtLineSplit))
{
Expand Down
2 changes: 1 addition & 1 deletion Src/xWorks/ILcmContentGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ IFragment GenerateGroupingNode(object field, string className, ConfigurableDicti
void EndMultiRunString(IFragmentWriter writer);
void StartBiDiWrapper(IFragmentWriter writer, bool rightToLeft);
void EndBiDiWrapper(IFragmentWriter writer);
void StartRun(IFragmentWriter writer, string writingSystem);
void StartRun(IFragmentWriter writer, ConfigurableDictionaryNode config, ReadOnlyPropertyTable propTable, string writingSystem);
void EndRun(IFragmentWriter writer);
void SetRunStyle(IFragmentWriter writer, ConfigurableDictionaryNode config, ReadOnlyPropertyTable propertyTable, string writingSystem, string runStyle, bool error);
void StartLink(IFragmentWriter writer, ConfigurableDictionaryNode config, Guid destination);
Expand Down
2 changes: 1 addition & 1 deletion Src/xWorks/LcmJsonGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void EndBiDiWrapper(IFragmentWriter writer)
{
}

public void StartRun(IFragmentWriter writer, string writingSystem)
public void StartRun(IFragmentWriter writer, ConfigurableDictionaryNode config, ReadOnlyPropertyTable propTable, string writingSystem)
{
var jsonWriter = (JsonFragmentWriter)writer;
jsonWriter.StartObject();
Expand Down
Loading

0 comments on commit f8043a2

Please sign in to comment.