Skip to content

Commit

Permalink
Merge branch 'release/9.1' into LT-20854
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeOliver28 authored May 9, 2024
2 parents 07542f9 + cb98e32 commit bb342e1
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 21 deletions.
Binary file modified DistFiles/xample64.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Src/LexText/Interlinear/ITextDll.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="BIRDInterlinearImporter.cs" />
<Compile Include="ChooseAnalysisHander.cs">
<Compile Include="ChooseAnalysisHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ChooseTextWritingSystemDlg.cs">
Expand Down
7 changes: 3 additions & 4 deletions Src/LexText/Interlinear/InterlinVc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public class InterlinVc : FwBaseVc, IDisposable
private InterlinLineChoices m_lineChoices;
protected IVwStylesheet m_stylesheet;
private IParaDataLoader m_loader;
private readonly HashSet<int> m_vernWss; // all vernacular writing systems
private readonly int m_selfFlid;

private int m_leftPadding;
Expand Down Expand Up @@ -184,8 +183,7 @@ public InterlinVc(LcmCache cache) : base(cache.DefaultAnalWs)
m_tssEmptyPara = TsStringUtils.MakeString(ITextStrings.ksEmptyPara, m_wsAnalysis);
m_tssSpace = TsStringUtils.MakeString(" ", m_wsAnalysis);
m_msaVc = new MoMorphSynAnalysisUi.MsaVc(m_cache);
m_vernWss = WritingSystemServices.GetAllWritingSystems(m_cache, "all vernacular",
null, 0, 0);

// This usually gets overridden, but ensures default behavior if not.
m_lineChoices = InterlinLineChoices.DefaultChoices(m_cache.LangProject,
WritingSystemServices.kwsVernInParagraph, WritingSystemServices.kwsAnal);
Expand Down Expand Up @@ -227,7 +225,8 @@ protected virtual void GetSegmentLevelTags(LcmCache cache)
/// </summary>
internal bool CanBeAnalyzed(AnalysisOccurrence occurrence)
{
return !(occurrence.Analysis is IPunctuationForm) && m_vernWss.Contains(occurrence.BaselineWs);
return !(occurrence.Analysis is IPunctuationForm) &&
WritingSystemServices.GetAllWritingSystems(m_cache, "all vernacular", null, 0, 0).Contains(occurrence.BaselineWs);
}

internal IVwStylesheet StyleSheet
Expand Down
21 changes: 13 additions & 8 deletions Src/xWorks/LcmWordGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,12 @@ public static string GetWsStyleName(string styleName, ConfigurableDictionaryNode
{
if (opt.IsEnabled)
{
if (opt.Id == "vernacular" || opt.Id == "all vernacular")
// If it's magic then don't return a language tag specific style.
var possiblyMagic = WritingSystemServices.GetMagicWsIdFromName(opt.Id);
if (possiblyMagic != 0)
{
return styleName;

}
// else, the DictionaryNodeOption Id specifies a particular writing system
// if there is no base style, return just the ws style
if (styleName == null)
Expand Down Expand Up @@ -468,12 +471,12 @@ public void AppendToParagraph(IFragment fragToCopy, OpenXmlElement run, bool for
if (forceNewParagraph)
{
// When forcing a new paragraph use a 'continuation' style for the new paragraph.
// The continuation style is based on the style used in the last paragraph.
// The continuation style is based on the style used in the first paragraph.
string style = null;
WP.Paragraph lastParagraph = DocBody.OfType<WP.Paragraph>().LastOrDefault();
if (lastParagraph != null)
WP.Paragraph firstParagraph = DocBody.OfType<WP.Paragraph>().FirstOrDefault();
if (firstParagraph != null)
{
WP.ParagraphProperties paraProps = lastParagraph.OfType<WP.ParagraphProperties>().FirstOrDefault();
WP.ParagraphProperties paraProps = firstParagraph.OfType<WP.ParagraphProperties>().FirstOrDefault();
if (paraProps != null)
{
ParagraphStyleId styleId = paraProps.OfType<WP.ParagraphStyleId>().FirstOrDefault();
Expand Down Expand Up @@ -1206,14 +1209,16 @@ public void AddEntryData(IFragmentWriter writer, List<ConfiguredLcmGenerator.Con
{
if (pieceHasImage)
{
wordWriter.WordFragment.AppendToParagraph(frag, new Run(), true);
wordWriter.WordFragment.GetNewParagraph();
wordWriter.WordFragment.AppendToParagraph(frag, new Run(), false);
}

// We have now added at least one image from this piece.
pieceHasImage = true;
}

wordWriter.WordFragment.AppendToParagraph(frag, run, wordWriter.ForceNewParagraph);
wordWriter.WordFragment.GetNewParagraph();
wordWriter.WordFragment.AppendToParagraph(frag, run, false);
wordWriter.WordFragment.LinkParaStyle(WordStylesGenerator.PictureAndCaptionTextframeStyle);
}

Expand Down
28 changes: 20 additions & 8 deletions Src/xWorks/WordStylesGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ internal static Style GenerateWordStyleFromLcmStyleSheet(
// alignment is always a paragraph property
parProps.Append(alignmentStyle);
}
if (exportStyleInfo.HasBorder)

// TODO:
// The code below works to handle borders for the word export.
// However, borders do not currently display in FLEx, and once a border has been added in FLEx,
// deselecting the border does not actually remove it from the styles object in FLEx.
// Until this is fixed, it is better not to display borders in the word export.
/*if (exportStyleInfo.HasBorder)
{
// create borders to add to the paragraph properties
ParagraphBorders border = new ParagraphBorders();
Expand Down Expand Up @@ -173,7 +179,8 @@ internal static Style GenerateWordStyleFromLcmStyleSheet(
border.Append(BottomBorder);
parProps.Append(border);
}
}*/

if (exportStyleInfo.HasFirstLineIndent)
{
// Handles both first-line and hanging indent, hanging-indent will result in a negative text-indent value
Expand Down Expand Up @@ -453,20 +460,25 @@ private static Style GenerateWordStyleFromWsOptions(ConfigurableDictionaryNode c
var cache = propertyTable.GetValue<LcmCache>("cache");
foreach (var ws in wsOptions.Options.Where(opt => opt.IsEnabled))
{
var possiblyMagic = WritingSystemServices.GetMagicWsIdFromName(ws.Id);
// if the writing system isn't a magic name just use it otherwise find the right one from the magic list
var wsIdString = possiblyMagic == 0 ? ws.Id : WritingSystemServices.GetWritingSystemList(cache, possiblyMagic, true).First().Id;
var wsId = cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr(wsIdString);
var wsString = GetWsString(wsIdString).Trim('.');

var wsStyle = new Style();

// If it's magic then don't add a specific style for the language tag.
var possiblyMagic = WritingSystemServices.GetMagicWsIdFromName(ws.Id);
if (possiblyMagic != 0)
{
return wsStyle;
}

if (!string.IsNullOrEmpty(configNode.Style))
{
var wsId = cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr(ws.Id);
wsStyle = GenerateWordStyleFromLcmStyleSheet(configNode.Style, wsId, propertyTable);
}

// Any given style can only be based on one style.
// This style should be based on the span for the current ws;
// style info for the current node (independent of WS) should be added during creation of this style.
var wsString = GetWsString(ws.Id).Trim('.');
wsStyle.Append(new BasedOn() { Val = "span" + wsString });

wsStyle.StyleId = configNode.Style + wsString;
Expand Down

0 comments on commit bb342e1

Please sign in to comment.