Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word Export LT-21891: Output double-column format #212

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading