From d563158773e19d55279adc6e4d424698c082ba8c Mon Sep 17 00:00:00 2001 From: mark-sil Date: Wed, 20 Nov 2024 12:13:26 -0500 Subject: [PATCH] Word Export LT-21891: Output double-column format Change-Id: I156123da68ec416ffa7396a56ee969c84c57ed71 --- Src/xWorks/LcmWordGenerator.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Src/xWorks/LcmWordGenerator.cs b/Src/xWorks/LcmWordGenerator.cs index cec10d4303..c1ee7f79ef 100644 --- a/Src/xWorks/LcmWordGenerator.cs +++ b/Src/xWorks/LcmWordGenerator.cs @@ -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; @@ -288,6 +297,16 @@ 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()); @@ -295,6 +314,14 @@ internal static DocFragment GenerateLetterHeaderDocFragment(string str, string s 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; }