@@ -1410,8 +1410,12 @@ private static IFragment GenerateContentForCollection(object collectionField, Co
1410
1410
Debug . Assert ( config . DictionaryNodeOptions == null ,
1411
1411
"double calls to GenerateContentForLexEntryRefsByType don't play nicely with ListOptions. Everything will be generated twice (if it doesn't crash)" ) ;
1412
1412
// Display typeless refs
1413
+ bool first = true ;
1413
1414
foreach ( var entry in lerCollection . Where ( item => ! item . ComplexEntryTypesRS . Any ( ) && ! item . VariantEntryTypesRS . Any ( ) ) )
1414
- bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , entry , collectionOwner , settings , lexEntryTypeNode ) ) ;
1415
+ {
1416
+ bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , entry , collectionOwner , settings , first , lexEntryTypeNode ) ) ;
1417
+ first = false ;
1418
+ }
1415
1419
// Display refs of each type
1416
1420
GenerateContentForLexEntryRefsByType ( config , lerCollection , collectionOwner , pubDecorator , settings , bldr , lexEntryTypeNode ,
1417
1421
true ) ; // complex
@@ -1421,8 +1425,12 @@ private static IFragment GenerateContentForCollection(object collectionField, Co
1421
1425
else
1422
1426
{
1423
1427
Debug . WriteLine ( "Unable to group " + config . FieldDescription + " by LexRefType; generating sequentially" ) ;
1428
+ bool first = true ;
1424
1429
foreach ( var item in lerCollection )
1425
- bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , item , collectionOwner , settings ) ) ;
1430
+ {
1431
+ bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , item , collectionOwner , settings , first ) ) ;
1432
+ first = false ;
1433
+ }
1426
1434
}
1427
1435
}
1428
1436
else if ( config . FieldDescription . StartsWith ( "Subentries" ) )
@@ -1435,8 +1443,12 @@ private static IFragment GenerateContentForCollection(object collectionField, Co
1435
1443
}
1436
1444
else
1437
1445
{
1446
+ bool first = true ;
1438
1447
foreach ( var item in collection )
1439
- bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , item , collectionOwner , settings ) ) ;
1448
+ {
1449
+ bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , item , collectionOwner , settings , first ) ) ;
1450
+ first = false ;
1451
+ }
1440
1452
}
1441
1453
}
1442
1454
@@ -1528,16 +1540,24 @@ private static IFragment GenerateContentForEntryRefCollection(ConfigurableDictio
1528
1540
if ( typeNode . IsEnabled && typeNode . ReferencedOrDirectChildren != null && typeNode . ReferencedOrDirectChildren . Any ( y => y . IsEnabled ) )
1529
1541
{
1530
1542
// Display typeless refs
1543
+ bool first = true ;
1531
1544
foreach ( var entry in lerCollection . Where ( item => ! item . ComplexEntryTypesRS . Any ( ) && ! item . VariantEntryTypesRS . Any ( ) ) )
1532
- bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , entry , collectionOwner , settings , typeNode ) ) ;
1545
+ {
1546
+ bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , entry , collectionOwner , settings , first , typeNode ) ) ;
1547
+ first = false ;
1548
+ }
1533
1549
// Display refs of each type
1534
1550
GenerateContentForLexEntryRefsByType ( config , lerCollection , collectionOwner , pubDecorator , settings , bldr , typeNode , isComplex ) ;
1535
1551
}
1536
1552
else
1537
1553
{
1538
1554
Debug . WriteLine ( "Unable to group " + config . FieldDescription + " by LexRefType; generating sequentially" ) ;
1555
+ bool first = true ;
1539
1556
foreach ( var item in lerCollection )
1540
- bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , item , collectionOwner , settings ) ) ;
1557
+ {
1558
+ bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , item , collectionOwner , settings , first ) ) ;
1559
+ first = false ;
1560
+ }
1541
1561
}
1542
1562
return bldr ;
1543
1563
}
@@ -1561,11 +1581,13 @@ private static void GenerateContentForLexEntryRefsByType(ConfigurableDictionaryN
1561
1581
foreach ( var typeGuid in lexEntryTypesFiltered )
1562
1582
{
1563
1583
var innerBldr = new StringBuilder ( ) ;
1584
+ bool first = true ;
1564
1585
foreach ( var lexEntRef in lerCollection )
1565
1586
{
1566
1587
if ( isComplex ? lexEntRef . ComplexEntryTypesRS . Any ( t => t . Guid == typeGuid ) : lexEntRef . VariantEntryTypesRS . Any ( t => t . Guid == typeGuid ) )
1567
1588
{
1568
- innerBldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , lexEntRef , collectionOwner , settings , typeNode ) ) ;
1589
+ innerBldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , lexEntRef , collectionOwner , settings , first , typeNode ) ) ;
1590
+ first = false ;
1569
1591
}
1570
1592
}
1571
1593
@@ -1576,7 +1598,7 @@ private static void GenerateContentForLexEntryRefsByType(ConfigurableDictionaryN
1576
1598
var generateLexType = typeNode != null ;
1577
1599
var lexTypeContent = generateLexType
1578
1600
? GenerateCollectionItemContent ( typeNode , pubDecorator , lexEntryType ,
1579
- lexEntryType . Owner , settings )
1601
+ lexEntryType . Owner , settings , first )
1580
1602
: null ;
1581
1603
var className = generateLexType ? settings . StylesGenerator . AddStyles ( typeNode ) . Trim ( '.' ) : null ;
1582
1604
var refsByType = settings . ContentGenerator . AddLexReferences ( generateLexType ,
@@ -1600,11 +1622,13 @@ private static void GenerateContentForSubentries(ConfigurableDictionaryNode conf
1600
1622
. Select ( le => new Tuple < ILexEntryRef , ILexEntry > ( EntryRefForSubentry ( le , collectionOwner ) , le ) ) . ToList ( ) ;
1601
1623
1602
1624
// Generate any Subentries with no ComplexFormType
1625
+ bool first = true ;
1603
1626
for ( var i = 0 ; i < subentries . Count ; i ++ )
1604
1627
{
1605
1628
if ( subentries [ i ] . Item1 == null || ! subentries [ i ] . Item1 . ComplexEntryTypesRS . Any ( ) )
1606
1629
{
1607
- bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , subentries [ i ] . Item2 , collectionOwner , settings ) ) ;
1630
+ bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , subentries [ i ] . Item2 , collectionOwner , settings , first ) ) ;
1631
+ first = false ;
1608
1632
subentries . RemoveAt ( i -- ) ;
1609
1633
}
1610
1634
}
@@ -1615,7 +1639,8 @@ private static void GenerateContentForSubentries(ConfigurableDictionaryNode conf
1615
1639
{
1616
1640
if ( subentries [ i ] . Item1 . ComplexEntryTypesRS . Any ( t => t . Guid == typeGuid ) )
1617
1641
{
1618
- bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , subentries [ i ] . Item2 , collectionOwner , settings ) ) ;
1642
+ bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , subentries [ i ] . Item2 , collectionOwner , settings , first ) ) ;
1643
+ first = false ;
1619
1644
subentries . RemoveAt ( i -- ) ;
1620
1645
}
1621
1646
}
@@ -1624,8 +1649,12 @@ private static void GenerateContentForSubentries(ConfigurableDictionaryNode conf
1624
1649
else
1625
1650
{
1626
1651
Debug . WriteLine ( "Unable to group " + config . FieldDescription + " by LexRefType; generating sequentially" ) ;
1652
+ bool first = true ;
1627
1653
foreach ( var item in collection )
1628
- bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , item , collectionOwner , settings ) ) ;
1654
+ {
1655
+ bldr . Append ( GenerateCollectionItemContent ( config , pubDecorator , item , collectionOwner , settings , first ) ) ;
1656
+ first = false ;
1657
+ }
1629
1658
}
1630
1659
}
1631
1660
@@ -1702,35 +1731,13 @@ private static IFragment GenerateContentForSenses(ConfigurableDictionaryNode con
1702
1731
var isThisSenseNumbered = ShouldThisSenseBeNumbered ( filteredSenseCollection [ 0 ] , config , filteredSenseCollection ) ;
1703
1732
var bldr = settings . ContentGenerator . CreateFragment ( ) ;
1704
1733
1705
- // TODO: Can handle separate sense paragraph styling here; likely will make the most sense to be handled wherever we deal with before/after content for senses.
1706
- // TODO: If handled here (or elsewhere w/in LcmGenerator), remove sense paragraph handling from the CssGenerator, otherwise sense paragraphs will be separated by two lines in the xhtml export.
1707
- /*// Only need to check once whether DisplayEachSenseInAParagraph is true -- value will be the same for each item in the loop
1708
- bool newParagraphPerSense;
1709
- if (senseNode?.DisplayEachSenseInAParagraph == true)
1710
- newParagraphPerSense = true;
1711
- else
1712
- newParagraphPerSense = false;
1713
-
1714
- //If the first sense must be inline, we append the first sense without a preceding line break
1715
- int startSense = 0;
1716
- if (senseNode?.DisplayFirstSenseInline == true)
1717
- {
1718
- bldr.Append(GenerateSenseContent(config, publicationDecorator, filteredSenseCollection[startSense], isThisSenseNumbered, settings, isSameGrammaticalInfo, info));
1719
- startSense++;
1720
- }
1721
-
1722
- for (int i = startSense; i < filteredSenseCollection.Count; i++)*/
1723
-
1734
+ bool first = true ;
1724
1735
foreach ( var item in filteredSenseCollection )
1725
1736
{
1726
1737
info . SenseCounter ++ ;
1727
-
1728
- // TODO: sense paragraphs
1729
- /*// If each sense belongs in a new paragraph, append a line break before the sense content.
1730
- if (newParagraphPerSense)
1731
- bldr.AppendBreak();*/
1732
-
1733
- bldr . Append ( GenerateSenseContent ( config , publicationDecorator , item , isThisSenseNumbered , settings , isSameGrammaticalInfo , info ) ) ;
1738
+ bldr . Append ( GenerateSenseContent ( config , publicationDecorator , item , isThisSenseNumbered , settings ,
1739
+ isSameGrammaticalInfo , info , first ) ) ;
1740
+ first = false ;
1734
1741
}
1735
1742
settings . StylesGenerator . AddStyles ( config ) ;
1736
1743
return bldr ;
@@ -1876,7 +1883,7 @@ private static bool CheckIfAllGramInfoTheSame(ConfigurableDictionaryNode config,
1876
1883
}
1877
1884
1878
1885
private static IFragment GenerateSenseContent ( ConfigurableDictionaryNode config , DictionaryPublicationDecorator publicationDecorator ,
1879
- object item , bool isThisSenseNumbered , GeneratorSettings settings , bool isSameGrammaticalInfo , SenseInfo info )
1886
+ object item , bool isThisSenseNumbered , GeneratorSettings settings , bool isSameGrammaticalInfo , SenseInfo info , bool first )
1880
1887
{
1881
1888
var senseNumberSpan = GenerateSenseNumberSpanIfNeeded ( config , isThisSenseNumbered , ref info , settings ) ;
1882
1889
var bldr = settings . ContentGenerator . CreateFragment ( ) ;
@@ -1893,8 +1900,7 @@ private static IFragment GenerateSenseContent(ConfigurableDictionaryNode config,
1893
1900
if ( bldr . Length ( ) == 0 )
1894
1901
return bldr ;
1895
1902
1896
- return settings . ContentGenerator . AddSenseData ( senseNumberSpan , IsBlockProperty ( config ) , ( ( ICmObject ) item ) . Owner . Guid ,
1897
- bldr , GetCollectionItemClassAttribute ( config ) ) ;
1903
+ return settings . ContentGenerator . AddSenseData ( senseNumberSpan , ( ( ICmObject ) item ) . Owner . Guid , config , bldr , first ) ;
1898
1904
}
1899
1905
1900
1906
private static IFragment GeneratePictureContent ( ConfigurableDictionaryNode config , DictionaryPublicationDecorator publicationDecorator ,
@@ -1945,7 +1951,7 @@ private static IFragment GeneratePictureContent(ConfigurableDictionaryNode confi
1945
1951
}
1946
1952
1947
1953
private static IFragment GenerateCollectionItemContent ( ConfigurableDictionaryNode config , DictionaryPublicationDecorator publicationDecorator ,
1948
- object item , object collectionOwner , GeneratorSettings settings , ConfigurableDictionaryNode factoredTypeField = null )
1954
+ object item , object collectionOwner , GeneratorSettings settings , bool first , ConfigurableDictionaryNode factoredTypeField = null )
1949
1955
{
1950
1956
if ( item is IMultiStringAccessor )
1951
1957
return GenerateContentForStrings ( ( IMultiStringAccessor ) item , config , settings ) ;
@@ -1979,7 +1985,7 @@ private static IFragment GenerateCollectionItemContent(ConfigurableDictionaryNod
1979
1985
if ( bldr . Length ( ) == 0 )
1980
1986
return bldr ;
1981
1987
var collectionContent = bldr ;
1982
- return settings . ContentGenerator . AddCollectionItem ( IsBlockProperty ( config ) , GetCollectionItemClassAttribute ( config ) , config , collectionContent ) ;
1988
+ return settings . ContentGenerator . AddCollectionItem ( IsBlockProperty ( config ) , GetCollectionItemClassAttribute ( config ) , config , collectionContent , first ) ;
1983
1989
}
1984
1990
1985
1991
private static void GenerateContentForLexRefCollection ( ConfigurableDictionaryNode config ,
@@ -2087,6 +2093,8 @@ private static IFragment GenerateCrossReferenceChildren(ConfigurableDictionaryNo
2087
2093
{
2088
2094
return settings . ContentGenerator . CreateFragment ( ) ;
2089
2095
}
2096
+
2097
+ bool first = true ;
2090
2098
foreach ( var child in config . ReferencedOrDirectChildren . Where ( c => c . IsEnabled ) )
2091
2099
{
2092
2100
switch ( child . FieldDescription )
@@ -2097,7 +2105,8 @@ private static IFragment GenerateCrossReferenceChildren(ConfigurableDictionaryNo
2097
2105
{
2098
2106
var referenceItem = referenceListItem . Item2 ;
2099
2107
var targetItem = referenceListItem . Item1 ;
2100
- contentBldr . Append ( GenerateCollectionItemContent ( child , publicationDecorator , targetItem , referenceItem , settings ) ) ;
2108
+ contentBldr . Append ( GenerateCollectionItemContent ( child , publicationDecorator , targetItem , referenceItem , settings , first ) ) ;
2109
+ first = false ;
2101
2110
}
2102
2111
if ( contentBldr . Length > 0 )
2103
2112
{
@@ -2252,7 +2261,7 @@ private static IFragment GenerateContentForICmObject(ICmObject propertyValue, Co
2252
2261
}
2253
2262
2254
2263
/// <summary>Write the class element in the span for an individual item in the collection</summary>
2255
- private static string GetCollectionItemClassAttribute ( ConfigurableDictionaryNode config )
2264
+ internal static string GetCollectionItemClassAttribute ( ConfigurableDictionaryNode config )
2256
2265
{
2257
2266
var classAtt = CssGenerator . GetClassAttributeForCollectionItem ( config ) ;
2258
2267
if ( config . ReferencedNode != null )
@@ -2487,8 +2496,7 @@ private static IFragment GenerateContentForValue(object field, object propertyVa
2487
2496
if ( propertyValue is int )
2488
2497
{
2489
2498
var cssClassName = settings . StylesGenerator . AddStyles ( config ) . Trim ( '.' ) ; ;
2490
- return settings . ContentGenerator . AddProperty ( cssClassName , false ,
2491
- propertyValue . ToString ( ) ) ;
2499
+ return settings . ContentGenerator . AddProperty ( cssClassName , false , propertyValue . ToString ( ) ) ;
2492
2500
}
2493
2501
if ( propertyValue is DateTime )
2494
2502
{
0 commit comments