Skip to content

Commit

Permalink
LT-21778: Fix image textframe styles (#44)
Browse files Browse the repository at this point in the history
Fixed the problem with the continuation style being written to
paragraphs containing images/captions (instead of the textframe
style being written).
Also, to prevent the problem with the paragraph following the
image/caption from using the textframe style, we now base the
continuation style on the first paragraph instead of the last.
  • Loading branch information
mark-sil authored May 7, 2024
1 parent 3c13042 commit 540ff24
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Src/xWorks/LcmWordGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,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 +1206,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

0 comments on commit 540ff24

Please sign in to comment.