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

Pass a content fragment to AddLexReferences() #60

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
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
Next Next commit
Pass a content fragment to AddLexReferences()
Converting the fragment to a string was resulting in the
loss of all styling for Word Export.  Now we pass the
content fragment to AddLexReferences() and let the xhtml
and json generators do the conversion to a string.

Change-Id: I0574ae94317c1580894e944429432ea4d56c99c6
mark-sil committed May 22, 2024
commit bd6e4b0b21d3484b7f9c52f8c5b133c22009f0ab
26 changes: 15 additions & 11 deletions Src/xWorks/ConfiguredLcmGenerator.cs
Original file line number Diff line number Diff line change
@@ -149,10 +149,10 @@ internal static StringBuilder GenerateLetterHeaderIfNeeded(ICmObject entry,
}

/// <summary>
/// This method uses a ThreadPool to execute the given individualActions in parallel.
/// It waits for all the individualActions to complete and then returns.
/// </summary>
internal static void SpawnEntryGenerationThreadsAndWait(List<Action> individualActions, IThreadedProgress progress)
/// This method uses a ThreadPool to execute the given individualActions in parallel.
/// It waits for all the individualActions to complete and then returns.
/// </summary>
internal static void SpawnEntryGenerationThreadsAndWait(List<Action> individualActions, IThreadedProgress progress)
{
var actionCount = individualActions.Count;
//Note that our COM classes all implement the STA threading model, while the ThreadPool always uses MTA model threads.
@@ -1580,29 +1580,33 @@ private static void GenerateContentForLexEntryRefsByType(ConfigurableDictionaryN
// Generate XHTML by Type
foreach (var typeGuid in lexEntryTypesFiltered)
{
var innerBldr = new StringBuilder();
var combinedContent = settings.ContentGenerator.CreateFragment();
bool first = true;
foreach (var lexEntRef in lerCollection)
{
if (isComplex ? lexEntRef.ComplexEntryTypesRS.Any(t => t.Guid == typeGuid) : lexEntRef.VariantEntryTypesRS.Any(t => t.Guid == typeGuid))
{
innerBldr.Append(GenerateCollectionItemContent(config, pubDecorator, lexEntRef, collectionOwner, settings, first, typeNode));
first = false;
var content = GenerateCollectionItemContent(config, pubDecorator, lexEntRef, collectionOwner, settings, first, typeNode);
if (!content.IsNullOrEmpty())
{
combinedContent.Append(content);
first = false;
}
}
}

if (innerBldr.Length > 0)
if (!first)
{
var lexEntryType = lexEntryTypes.First(t => t.Guid.Equals(typeGuid));
// Display the Type iff there were refs of this Type (and we are factoring)
// Display the Type if there were refs of this Type (and we are factoring)
var generateLexType = typeNode != null;
var lexTypeContent = generateLexType
? GenerateCollectionItemContent(typeNode, pubDecorator, lexEntryType,
lexEntryType.Owner, settings, first)
lexEntryType.Owner, settings, false)
: null;
var className = generateLexType ? settings.StylesGenerator.AddStyles(typeNode).Trim('.') : null;
var refsByType = settings.ContentGenerator.AddLexReferences(generateLexType,
lexTypeContent, config, className, innerBldr.ToString(), IsTypeBeforeForm(config));
lexTypeContent, config, className, combinedContent, IsTypeBeforeForm(config));
bldr.Append(refsByType);
}
}
2 changes: 1 addition & 1 deletion Src/xWorks/ILcmContentGenerator.cs
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ IFragment GenerateGroupingNode(object field, string className, ConfigurableDicti
IFragment AddImage(string classAttribute, string srcAttribute, string pictureGuid);
IFragment AddImageCaption(string captionContent);
IFragment GenerateSenseNumber(string formattedSenseNumber, string senseNumberWs, ConfigurableDictionaryNode config);
IFragment AddLexReferences(bool generateLexType, IFragment lexTypeContent, ConfigurableDictionaryNode config, string className, string referencesContent, bool typeBefore);
IFragment AddLexReferences(bool generateLexType, IFragment lexTypeContent, ConfigurableDictionaryNode config, string className, IFragment referencesContent, bool typeBefore);
void BeginCrossReference(IFragmentWriter writer, bool isBlockProperty, string className);
void EndCrossReference(IFragmentWriter writer);
IFragment WriteProcessedSenses(bool isBlock, IFragment senseContent, ConfigurableDictionaryNode config, string className, IFragment sharedCollectionInfo);
4 changes: 2 additions & 2 deletions Src/xWorks/LcmJsonGenerator.cs
Original file line number Diff line number Diff line change
@@ -364,7 +364,7 @@ public IFragment GenerateSenseNumber(string formattedSenseNumber, string wsId, C
}

public IFragment AddLexReferences(bool generateLexType, IFragment lexTypeContent, ConfigurableDictionaryNode config, string className,
string referencesContent, bool typeBefore)
IFragment referencesContent, bool typeBefore)
{
var bldr = new StringBuilder();
var fragment = new StringFragment(bldr);
@@ -382,7 +382,7 @@ public IFragment AddLexReferences(bool generateLexType, IFragment lexTypeContent
// Write an array with the references.
xw.WritePropertyName("references");
xw.WriteStartArray();
xw.WriteRaw(referencesContent);
xw.WriteRaw(referencesContent.ToString());
xw.WriteEndArray();
// Write properties related to the factored type (if any and if after).
if (generateLexType && !typeBefore)
4 changes: 2 additions & 2 deletions Src/xWorks/LcmWordGenerator.cs
Original file line number Diff line number Diff line change
@@ -1381,7 +1381,7 @@ public IFragment GenerateSenseNumber(string formattedSenseNumber, string senseNu
senseNum.AddStyleLink(WordStylesGenerator.SenseNumberStyleName, senseConfigNode, ConfigurableDictionaryNode.StyleTypes.Character);
return senseNum;
}
public IFragment AddLexReferences(bool generateLexType, IFragment lexTypeContent, ConfigurableDictionaryNode config, string className, string referencesContent, bool typeBefore)
public IFragment AddLexReferences(bool generateLexType, IFragment lexTypeContent, ConfigurableDictionaryNode config, string className, IFragment referencesContent, bool typeBefore)
{
var fragment = new DocFragment();
// Generate the factored ref types element (if before).
@@ -1390,7 +1390,7 @@ public IFragment AddLexReferences(bool generateLexType, IFragment lexTypeContent
fragment.Append(WriteProcessedObject(false, lexTypeContent, config, className));
}
// Then add all the contents for the LexReferences (e.g. headwords)
fragment.Append(new DocFragment(referencesContent));
fragment.Append(referencesContent);
// Generate the factored ref types element (if after).
if (generateLexType && !typeBefore)
{
4 changes: 2 additions & 2 deletions Src/xWorks/LcmXhtmlGenerator.cs
Original file line number Diff line number Diff line change
@@ -961,7 +961,7 @@ public IFragment GenerateSenseNumber(string formattedSenseNumber, string senseNu
}

public IFragment AddLexReferences(bool generateLexType, IFragment lexTypeContent, ConfigurableDictionaryNode config, string className,
string referencesContent, bool typeBefore)
IFragment referencesContent, bool typeBefore)
{
var bldr = new StringBuilder(100);
var fragment = new StringFragment(bldr);
@@ -971,7 +971,7 @@ public IFragment AddLexReferences(bool generateLexType, IFragment lexTypeContent
bldr.Append(WriteProcessedObject(false, lexTypeContent, config, className));
}
// Then add all the contents for the LexReferences (e.g. headwords)
bldr.Append(referencesContent);
bldr.Append(referencesContent.ToString());
// Generate the factored ref types element (if after).
if (generateLexType && !typeBefore)
{

Unchanged files with check annotations Beta

#if !defined GRAPHITE2_NTRACING
if (dbgout)
dbgout->setenv(1, reinterpret_cast<void *>(j));

Check warning on line 512 in Lib/src/graphite2/src/Collider.cpp

GitHub Actions / Build Debug and run Tests

'reinterpret_cast': conversion from 'int' to 'void *' of greater size
#endif
if (omin > otmax)
_ranges[i].weightedAxis(i, vmin - _margin, vmax + _margin, 0, 0, 0, 0, 0,
<< json::close;
}
#endif
if (seg->currdir() != m_dir)

Check warning on line 397 in Lib/src/graphite2/src/Silf.cpp

GitHub Actions / Build Debug and run Tests

'!=': unsafe mix of type 'bool' and type 'const graphite2::uint8' in operation
seg->reverseSlots();
if (m_aMirror && (seg->dir() & 3) == 3)
seg->doMirror(m_aMirror);
* It is called from main(). Programmers can supply their own version to
* replace this null version.
*/
void GlobalSetup(bool verbose)

Check warning on line 12 in Lib/src/unit++/GlobalSetup.cc

GitHub Actions / Build Debug and run Tests

'verbose': unreferenced formal parameter
{
}
vector<string> ss(vectorize(id, '.'));
test* tp = this;
for (vector<string>::iterator p = ss.begin(); p != ss.end(); ++p)
if (!(tp = tp->get_child(*p)))

Check warning on line 74 in Lib/src/unit++/unit++.cc

GitHub Actions / Build Debug and run Tests

assignment within conditional expression
break;
return tp;
}