Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docx-core/src/documents/elements/numbering_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ impl BuildXML for NumberingProperty {
) -> crate::xml::writer::Result<crate::xml::writer::EventWriter<W>> {
XMLBuilder::from(stream)
.open_numbering_property()?
.add_optional_child(&self.id)?
.add_optional_child(&self.level)?
.add_optional_child(&self.id)?
.close()?
.into_inner()
}
Expand Down
1 change: 0 additions & 1 deletion docx-core/src/documents/elements/paragraph_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ impl BuildXML for ParagraphProperty {
) -> crate::xml::writer::Result<crate::xml::writer::EventWriter<W>> {
XMLBuilder::from(stream)
.open_paragraph_property()?
.add_child(&self.run_property)?
.add_optional_child(&self.style)?
.add_optional_child(&self.numbering_property)?
.add_optional_child(&self.frame_property)?
Expand Down
26 changes: 13 additions & 13 deletions docx-core/src/documents/elements/run_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,31 +220,31 @@ impl BuildXML for RunProperty {
) -> crate::xml::writer::Result<crate::xml::writer::EventWriter<W>> {
XMLBuilder::from(stream)
.open_run_property()?
.add_optional_child(&self.sz)?
.add_optional_child(&self.sz_cs)?
.add_optional_child(&self.color)?
.add_optional_child(&self.fonts)?
.add_optional_child(&self.bold)?
.add_optional_child(&self.bold_cs)?
.add_optional_child(&self.caps)?
.add_optional_child(&self.italic)?
.add_optional_child(&self.italic_cs)?
.add_optional_child(&self.caps)?
.add_optional_child(&self.strike)?
.add_optional_child(&self.dstrike)?
.add_optional_child(&self.highlight)?
.add_optional_child(&self.underline)?
.add_optional_child(&self.vanish)?
.add_optional_child(&self.spec_vanish)?
.add_optional_child(&self.fonts)?
.add_optional_child(&self.color)?
.add_optional_child(&self.character_spacing)?
.add_optional_child(&self.sz)?
.add_optional_child(&self.sz_cs)?
.add_optional_child(&self.underline)?
.add_optional_child(&self.text_border)?
.add_optional_child(&self.shading)?
.add_optional_child(&self.fit_text)?
.add_optional_child(&self.vert_align)?
.add_optional_child(&self.spec_vanish)?
.add_optional_child(&self.ins)?
.add_optional_child(&self.del)?
.add_optional_child(&self.vert_align)?
.add_optional_child(&self.character_spacing)?
.add_optional_child(&self.fit_text)?
.add_optional_child(&self.stretch)?
.add_optional_child(&self.style)?
.add_optional_child(&self.positional_tab)?
.add_optional_child(&self.shading)?
.add_optional_child(&self.stretch)?
.add_optional_child(&self.highlight)?
.close()?
.into_inner()
}
Expand Down
10 changes: 5 additions & 5 deletions docx-core/src/documents/elements/section_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,22 +204,22 @@ impl BuildXML for SectionProperty {
) -> crate::xml::writer::Result<crate::xml::writer::EventWriter<W>> {
XMLBuilder::from(stream)
.open_section_property()?
.add_child(&self.page_size)?
.add_child(&self.page_margin)?
.columns(&format!("{}", &self.space), &format!("{}", &self.columns))?
.add_optional_child(&self.doc_grid)?
.add_optional_child(&self.header_reference)?
.add_optional_child(&self.first_header_reference)?
.add_optional_child(&self.even_header_reference)?
.add_optional_child(&self.footer_reference)?
.add_optional_child(&self.first_footer_reference)?
.add_optional_child(&self.even_footer_reference)?
.apply_opt(self.section_type, |t, b| b.type_tag(&t.to_string()))?
.add_child(&self.page_size)?
.add_child(&self.page_margin)?
.add_optional_child(&self.page_num_type)?
.columns(&format!("{}", &self.space), &format!("{}", &self.columns))?
.apply_if(self.text_direction != "lrTb", |b| {
b.text_direction(&self.text_direction)
})?
.apply_opt(self.section_type, |t, b| b.type_tag(&t.to_string()))?
.apply_if(self.title_pg, |b| b.title_pg())?
.add_optional_child(&self.doc_grid)?
.close()?
.into_inner()
}
Expand Down
14 changes: 7 additions & 7 deletions docx-core/src/documents/elements/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,20 +375,20 @@ impl BuildXML for Style {
XMLBuilder::from(stream)
.open_style(self.style_type, &self.style_id)?
.add_child(&self.name)?
.add_child(&self.run_property)?
.add_child(&self.paragraph_property)?
.apply_if(self.style_type == StyleType::Table, |b| {
b.add_child(&self.table_cell_property)?
.add_child(&self.table_property)
})?
.add_optional_child(&self.next)?
.add_optional_child(&self.link)?
.apply_if(self.q_format, |b| b.add_child(&QFormat::new()))?
.apply_if(self.ui_priority.is_some(), |b| {
b.ui_priority(self.ui_priority.unwrap_or_default())
})?
.apply_if(self.q_format, |b| b.add_child(&QFormat::new()))?
.apply_if(self.semi_hidden, |b| b.semi_hidden())?
.apply_if(self.unhide_when_used, |b| b.unhide_when_used())?
.add_child(&self.paragraph_property)?
.add_child(&self.run_property)?
.apply_if(self.style_type == StyleType::Table, |b| {
b.add_child(&self.table_cell_property)?
.add_child(&self.table_property)
})?
.add_optional_child(&self.based_on)?
.close()?
.into_inner()
Expand Down
2 changes: 1 addition & 1 deletion docx-core/src/documents/elements/table_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl BuildXML for TableGrid {
) -> crate::xml::writer::Result<crate::xml::writer::EventWriter<W>> {
XMLBuilder::from(stream)
.open_table_grid()?
.apply_each(&self.grid, |g, b| b.grid_column(*g as i32, WidthType::Dxa))?
.apply_each(&self.grid, |g, b| b.grid_column(*g as i32))?
.close()?
.into_inner()
}
Expand Down
8 changes: 4 additions & 4 deletions docx-core/src/documents/elements/table_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ impl BuildXML for TableProperty {
) -> crate::xml::writer::Result<crate::xml::writer::EventWriter<W>> {
XMLBuilder::from(stream)
.open_table_property()?
.add_optional_child(&self.style)?
.add_optional_child(&self.position)?
.add_child(&self.width)?
.add_child(&self.justification)?
.add_child(&self.borders)?
.add_optional_child(&self.margins)?
.add_optional_child(&self.indent)?
.add_optional_child(&self.style)?
.add_child(&self.borders)?
.add_optional_child(&self.layout)?
.add_optional_child(&self.position)?
.add_optional_child(&self.margins)?
.close()?
.into_inner()
}
Expand Down
2 changes: 1 addition & 1 deletion docx-core/src/documents/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ impl BuildXML for Settings {
XMLBuilder::from(stream)
.declaration(Some(true))?
.open_settings()?
.add_child(&self.default_tab_stop)?
.add_child(&self.zoom)?
.add_child(&self.default_tab_stop)?
.open_compat()?
.space_for_ul()?
.balance_single_byte_double_byte_width()?
Expand Down
2 changes: 1 addition & 1 deletion docx-core/src/xml_builder/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ impl<W: Write> XMLBuilder<W> {
closed_with_str!(table_style, "w:tblStyle");
closed_w_with_type_el!(table_width, "w:tblW");
closed_w_with_type_el!(table_indent, "w:tblInd");
closed_w_with_type_el!(grid_column, "w:gridCol");
closed_w_el!(grid_column, "w:gridCol");
closed_w_with_type_el!(table_cell_width, "w:tcW");

closed!(table_row_height, "w:trHeight", "w:val", "w:hRule");
Expand Down
9 changes: 9 additions & 0 deletions docx-core/src/xml_builder/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,15 @@ macro_rules! closed_w_with_type_el {
};
}

macro_rules! closed_w_el {
($name: ident, $el_name: expr) => {
pub(crate) fn $name(self, w: i32) -> crate::xml::writer::Result<Self> {
self.write(XmlEvent::start_element($el_name).attr("w:w", &format!("{}", w)))?
.close()
}
};
}

macro_rules! closed_border_el {
($name: ident, $el_name: expr) => {
pub(crate) fn $name(
Expand Down
Loading