Skip to content

Commit b4be4bb

Browse files
authored
Support adjust line height in table (#522)
* fix: support adjust_line_height_in_table in settings * fix: read adjust in table * fix
1 parent 753c6d4 commit b4be4bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+86
-39
lines changed

docx-core/src/documents/settings.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct Settings {
1313
doc_id: Option<DocId>,
1414
doc_vars: Vec<DocVar>,
1515
even_and_odd_headers: bool,
16+
adjust_line_height_in_table: bool,
1617
}
1718

1819
impl Settings {
@@ -39,6 +40,11 @@ impl Settings {
3940
self.even_and_odd_headers = true;
4041
self
4142
}
43+
44+
pub fn adjust_line_height_in_table(mut self) -> Self {
45+
self.adjust_line_height_in_table = true;
46+
self
47+
}
4248
}
4349

4450
impl Default for Settings {
@@ -49,6 +55,7 @@ impl Default for Settings {
4955
doc_id: None,
5056
doc_vars: vec![],
5157
even_and_odd_headers: false,
58+
adjust_line_height_in_table: false,
5259
}
5360
}
5461
}
@@ -66,8 +73,13 @@ impl BuildXML for Settings {
6673
.balance_single_byte_double_byte_width()
6774
.do_not_leave_backslash_alone()
6875
.ul_trail_space()
69-
.do_not_expand_shift_return()
70-
.adjust_line_height_table()
76+
.do_not_expand_shift_return();
77+
78+
if self.adjust_line_height_in_table {
79+
b = b.adjust_line_height_table();
80+
}
81+
82+
b = b
7183
.use_fe_layout()
7284
.compat_setting(
7385
"compatibilityMode",
@@ -138,7 +150,6 @@ mod tests {
138150
<w:doNotLeaveBackslashAlone />
139151
<w:ulTrailSpace />
140152
<w:doNotExpandShiftReturn />
141-
<w:adjustLineHeightInTable />
142153
<w:useFELayout />
143154
<w:compatSetting w:name="compatibilityMode" w:uri="http://schemas.microsoft.com/office/word" w:val="15" />
144155
<w:compatSetting w:name="overrideTableStyleFontSizeAndJustification" w:uri="http://schemas.microsoft.com/office/word" w:val="1" />

docx-core/src/reader/settings.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ impl FromXML for Settings {
4949
}
5050
}
5151
}
52+
XMLElement::AdjustLineHeightInTable => {
53+
settings = settings.adjust_line_height_in_table();
54+
}
5255
_ => {}
5356
}
5457
}

docx-core/src/reader/xml_element.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ pub enum XMLElement {
140140
DocDefaults,
141141
DefaultTabStop,
142142
RunPropertyDefault,
143+
AdjustLineHeightInTable,
143144
SectionProperty,
144145
PageSize,
145146
PageMargin,
@@ -353,6 +354,7 @@ impl FromStr for XMLElement {
353354
"docDefaults" => Ok(XMLElement::DocDefaults),
354355
"docGrid" => Ok(XMLElement::DocGrid),
355356
"rPrDefault" => Ok(XMLElement::RunPropertyDefault),
357+
"adjustLineHeightInTable" => Ok(XMLElement::AdjustLineHeightInTable),
356358
"defaultTabStop" => Ok(XMLElement::DefaultTabStop),
357359
"divId" => Ok(XMLElement::DivId),
358360
"div" => Ok(XMLElement::Div),

docx-core/tests/snapshots/lib__reader__line_spacing.snap

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docx-core/tests/snapshots/lib__reader__read_bom.snap

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docx-core/tests/snapshots/lib__reader__read_bookmark.snap

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docx-core/tests/snapshots/lib__reader__read_comment.snap

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docx-core/tests/snapshots/lib__reader__read_decoration.snap

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docx-core/tests/snapshots/lib__reader__read_extended_comments.snap

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docx-core/tests/snapshots/lib__reader__read_from_doc.snap

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)