Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word Export: Add missing Before/After/Between content #155

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Src/xWorks/ConfiguredLcmGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2005,9 +2005,12 @@ private static void GenerateContentForLexRefCollection(ConfigurableDictionaryNod
var organizedRefs = SortAndFilterLexRefsAndTargets(collection, cmOwner, config);

// Now that we have things in the right order, try outputting one type at a time
bool firstIteration = true;
foreach (var referenceList in organizedRefs)
{
var xBldr = GenerateCrossReferenceChildren(config, pubDecorator, referenceList, cmOwner, settings);
settings.ContentGenerator.BetweenCrossReferenceType(xBldr, config, firstIteration);
firstIteration = false;
bldr.Append(xBldr);
}
}
Expand Down Expand Up @@ -2119,7 +2122,7 @@ private static IFragment GenerateCrossReferenceChildren(ConfigurableDictionaryNo
if (!content.IsNullOrEmpty())
{
// targets
settings.ContentGenerator.AddCollection(xw, config, IsBlockProperty(child),
settings.ContentGenerator.AddCollection(xw, child, IsBlockProperty(child),
CssGenerator.GetClassAttributeForConfig(child), content);
settings.StylesGenerator.AddStyles(child);
}
Expand Down
1 change: 1 addition & 0 deletions Src/xWorks/ILcmContentGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ IFragment GenerateGroupingNode(ConfigurableDictionaryNode config, object field,
IFragment AddLexReferences(ConfigurableDictionaryNode config, bool generateLexType, IFragment lexTypeContent, string className, IFragment referencesContent, bool typeBefore);
void BeginCrossReference(IFragmentWriter writer, ConfigurableDictionaryNode config, bool isBlockProperty, string className);
void EndCrossReference(IFragmentWriter writer);
void BetweenCrossReferenceType(IFragment content, ConfigurableDictionaryNode node, bool firstItem);
IFragment WriteProcessedSenses(ConfigurableDictionaryNode config, bool isBlock, IFragment senseContent, string className, IFragment sharedCollectionInfo);
IFragment AddAudioWsContent(string wsId, Guid linkTarget, IFragment fileContent);
IFragment GenerateErrorContent(StringBuilder badStrBuilder);
Expand Down
4 changes: 4 additions & 0 deletions Src/xWorks/LcmJsonGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ public void EndCrossReference(IFragmentWriter writer)
((JsonFragmentWriter)writer).InsertRawJson(",");
}

public void BetweenCrossReferenceType(IFragment content, ConfigurableDictionaryNode node, bool firstItem)
{
}

/// <summary>
/// Generates data for all senses of an entry. For better processing of json add sharedGramInfo as a separate property object
/// </summary>
Expand Down
25 changes: 25 additions & 0 deletions Src/xWorks/LcmWordGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1440,10 +1440,24 @@ public void EndEntry(IFragmentWriter writer)
}
public void AddCollection(IFragmentWriter writer, ConfigurableDictionaryNode config, bool isBlockProperty, string className, IFragment content)
{
// Add Before text.
if (!string.IsNullOrEmpty(config.Before))
{
var beforeRun = CreateBeforeAfterBetweenRun(config.Before);
((WordFragmentWriter)writer).WordFragment.DocBody.Append(beforeRun);
}

if (!content.IsNullOrEmpty())
{
((WordFragmentWriter)writer).WordFragment.Append(content);
}

// Add After text.
if (!string.IsNullOrEmpty(config.After))
{
var afterRun = CreateBeforeAfterBetweenRun(config.After);
((WordFragmentWriter)writer).WordFragment.DocBody.Append(afterRun);
}
}
public void BeginObjectProperty(IFragmentWriter writer, ConfigurableDictionaryNode config, bool isBlockProperty, string getCollectionItemClassAttribute)
{
Expand Down Expand Up @@ -1606,6 +1620,17 @@ public void EndCrossReference(IFragmentWriter writer)
{
return;
}

public void BetweenCrossReferenceType(IFragment content, ConfigurableDictionaryNode node, bool firstItem)
{
// Add Between text if it is not the first item in the collection.
if (!firstItem && !string.IsNullOrEmpty(node.Between))
{
var betweenRun = CreateBeforeAfterBetweenRun(node.Between);
((DocFragment)content).DocBody.PrependChild(betweenRun);
}
}

public IFragment WriteProcessedSenses(ConfigurableDictionaryNode config, bool isBlock, IFragment senseContent, string className, IFragment sharedGramInfo)
{
// Add Before text for the senses.
Expand Down
4 changes: 4 additions & 0 deletions Src/xWorks/LcmXhtmlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,10 @@ public void EndCrossReference(IFragmentWriter writer)
EndObject(writer);
}

public void BetweenCrossReferenceType(IFragment content, ConfigurableDictionaryNode node, bool firstItem)
{
}

public IFragment WriteProcessedSenses(ConfigurableDictionaryNode config, bool isBlock, IFragment sensesContent, string classAttribute, IFragment sharedGramInfo)
{
sharedGramInfo.Append(sensesContent);
Expand Down
Loading