Skip to content

Commit

Permalink
Word Export LT-21891: Output double-column format
Browse files Browse the repository at this point in the history
Change-Id: I156123da68ec416ffa7396a56ee969c84c57ed71
  • Loading branch information
mark-sil committed Nov 20, 2024
1 parent f714113 commit d563158
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Src/xWorks/LcmWordGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ public static void SavePublishedDocx(int[] entryHvos, DictionaryPublicationDecor
}
col?.Dispose();

// Set the last section of the document to be two columns. (The last section is all the
// entries after the last letter header.) For the last section this information is stored
// different than all the other sections. It is stored as the last child element of the body.
var sectProps = new SectionProperties(
new Columns() { EqualWidth = true, ColumnCount = 2 },
new SectionType() { Val = SectionMarkValues.Continuous }
);
fragment.DocBody.Append(sectProps);

if (progress != null)
progress.Message = xWorksStrings.ksGeneratingStyleInfo;

Expand Down Expand Up @@ -288,13 +297,31 @@ internal static DocFragment GenerateLetterHeaderDocFragment(string str, string s
// Only create paragraph, run, and text objects if string is nonempty
if (!string.IsNullOrEmpty(str))
{
// Everything other than the Letter Header should be 2 columns. Create a empty
// paragraph with two columns for the last paragraph in the section that uses 2
// columns. (The section is all the entries after the previous letter header.)
var sectProps2 = new SectionProperties(
new Columns() { EqualWidth = true, ColumnCount = 2 },
new SectionType() { Val = SectionMarkValues.Continuous }
);
docFrag.DocBody.AppendChild(new WP.Paragraph(new WP.ParagraphProperties(sectProps2)));

// Create the letter header in a paragraph.
WP.ParagraphProperties paragraphProps = new WP.ParagraphProperties(new ParagraphStyleId() { Val = styleDisplayName });
WP.Paragraph para = docFrag.DocBody.AppendChild(new WP.Paragraph(paragraphProps));
WP.Run run = para.AppendChild(new WP.Run());
// For spaces to show correctly, set preserve spaces on the text element
WP.Text txt = new WP.Text(str);
txt.Space = SpaceProcessingModeValues.Preserve;
run.AppendChild(txt);

// Only the Letter Header should be 1 column. Create a empty paragraph with one
// column so the previous letter header paragraph uses 1 column.
var sectProps1 = new SectionProperties(
new Columns() { EqualWidth = true, ColumnCount = 1 },
new SectionType() { Val = SectionMarkValues.Continuous }
);
docFrag.DocBody.AppendChild(new WP.Paragraph(new WP.ParagraphProperties(sectProps1)));
}
return docFrag;
}
Expand Down

0 comments on commit d563158

Please sign in to comment.