diff --git a/docx-core/src/documents/elements/mod.rs b/docx-core/src/documents/elements/mod.rs
index 3560355..4e991d0 100644
--- a/docx-core/src/documents/elements/mod.rs
+++ b/docx-core/src/documents/elements/mod.rs
@@ -24,6 +24,8 @@ mod table_cell_width;
mod table_grid;
mod table_indent;
mod table_property;
+mod table_row;
+mod table_row_property;
mod table_width;
mod text;
@@ -53,5 +55,7 @@ pub use table_cell_width::*;
pub use table_grid::*;
pub use table_indent::*;
pub use table_property::*;
+pub use table_row::*;
+pub use table_row_property::*;
pub use table_width::*;
pub use text::*;
diff --git a/docx-core/src/documents/elements/table_cell.rs b/docx-core/src/documents/elements/table_cell.rs
index 2563b4e..784ec4f 100644
--- a/docx-core/src/documents/elements/table_cell.rs
+++ b/docx-core/src/documents/elements/table_cell.rs
@@ -1,4 +1,4 @@
-use super::{Paragraph, Run, TableCellProperty};
+use super::{Paragraph, TableCellProperty};
use crate::documents::BuildXML;
use crate::xml_builder::*;
@@ -14,8 +14,8 @@ pub enum TableCellContent {
}
impl TableCell {
- pub fn new(w: usize) -> TableCell {
- let property = TableCellProperty::new(w);
+ pub fn new() -> TableCell {
+ let property = TableCellProperty::new();
let contents = vec![];
Self { property, contents }
}
@@ -42,6 +42,7 @@ impl BuildXML for TableCell {
#[cfg(test)]
mod tests {
+ use super::super::*;
use super::*;
#[cfg(test)]
use pretty_assertions::assert_eq;
@@ -49,21 +50,21 @@ mod tests {
#[test]
fn test_cell() {
- let b = TableCell::new(200).build();
+ let b = TableCell::new().build();
assert_eq!(
str::from_utf8(&b).unwrap(),
- r#""#
+ r#""#
);
}
#[test]
fn test_cell_add_p() {
- let b = TableCell::new(200)
+ let b = TableCell::new()
.add_paragraph(Paragraph::new().add_run(Run::new("Hello")))
.build();
assert_eq!(
str::from_utf8(&b).unwrap(),
- r#"Hello"#
+ r#"Hello"#
);
}
}
diff --git a/docx-core/src/documents/elements/table_cell_property.rs b/docx-core/src/documents/elements/table_cell_property.rs
index 2a7080b..154595b 100644
--- a/docx-core/src/documents/elements/table_cell_property.rs
+++ b/docx-core/src/documents/elements/table_cell_property.rs
@@ -1,33 +1,33 @@
-use super::{TableCellBorders, TableCellWidth};
+use super::TableCellBorders;
use crate::documents::BuildXML;
-use crate::types::*;
+// use crate::types::*;
use crate::xml_builder::*;
#[derive(Debug, Clone)]
pub struct TableCellProperty {
- width: TableCellWidth,
+ // width: TableCellWidth,
borders: TableCellBorders,
}
impl TableCellProperty {
- pub fn new(w: usize) -> TableCellProperty {
+ pub fn new() -> TableCellProperty {
TableCellProperty {
- width: TableCellWidth::new(w, WidthType::DXA),
+ // width: TableCellWidth::new(w, WidthType::DXA),
borders: TableCellBorders::new(),
}
}
- pub fn width(mut self, v: usize) -> TableCellProperty {
- self.width = TableCellWidth::new(v, WidthType::DXA);
- self
- }
+ // pub fn width(mut self, v: usize) -> TableCellProperty {
+ // self.width = TableCellWidth::new(v, WidthType::DXA);
+ // self
+ // }
}
impl BuildXML for TableCellProperty {
fn build(&self) -> Vec {
XMLBuilder::new()
.open_table_cell_property()
- .add_child(&self.width)
+ // .add_child(&self.width)
.add_child(&self.borders)
.close()
.build()
@@ -44,11 +44,11 @@ mod tests {
#[test]
fn test_default() {
- let c = TableCellProperty::new(200);
+ let c = TableCellProperty::new();
let b = c.build();
assert_eq!(
str::from_utf8(&b).unwrap(),
- r#""#
+ r#""#
);
}
}
diff --git a/docx-core/src/documents/elements/table_row.rs b/docx-core/src/documents/elements/table_row.rs
new file mode 100644
index 0000000..331312c
--- /dev/null
+++ b/docx-core/src/documents/elements/table_row.rs
@@ -0,0 +1,44 @@
+use super::{TableCell, TableRowProperty};
+use crate::documents::BuildXML;
+use crate::xml_builder::*;
+
+#[derive(Debug, Clone)]
+pub struct TableRow {
+ property: TableRowProperty,
+ cells: Vec,
+}
+
+impl TableRow {
+ pub fn new(cells: Vec) -> TableRow {
+ let property = TableRowProperty::new();
+ Self { property, cells }
+ }
+}
+
+impl BuildXML for TableRow {
+ fn build(&self) -> Vec {
+ let b = XMLBuilder::new()
+ .open_table_row()
+ .add_child(&self.property)
+ .add_children(&self.cells);
+ b.close().build()
+ }
+}
+
+#[cfg(test)]
+mod tests {
+
+ use super::*;
+ #[cfg(test)]
+ use pretty_assertions::assert_eq;
+ use std::str;
+
+ #[test]
+ fn test_row() {
+ let b = TableRow::new(vec![TableCell::new()]).build();
+ assert_eq!(
+ str::from_utf8(&b).unwrap(),
+ r#""#
+ );
+ }
+}
diff --git a/docx-core/src/documents/elements/table_row_property.rs b/docx-core/src/documents/elements/table_row_property.rs
new file mode 100644
index 0000000..127e512
--- /dev/null
+++ b/docx-core/src/documents/elements/table_row_property.rs
@@ -0,0 +1,32 @@
+use crate::documents::BuildXML;
+use crate::xml_builder::*;
+
+#[derive(Debug, Clone)]
+pub struct TableRowProperty {}
+
+impl TableRowProperty {
+ pub fn new() -> TableRowProperty {
+ TableRowProperty {}
+ }
+}
+
+impl BuildXML for TableRowProperty {
+ fn build(&self) -> Vec {
+ XMLBuilder::new().open_table_row_property().close().build()
+ }
+}
+
+#[cfg(test)]
+mod tests {
+
+ use super::*;
+ #[cfg(test)]
+ use pretty_assertions::assert_eq;
+ use std::str;
+
+ #[test]
+ fn test_default() {
+ let b = TableRowProperty::new().build();
+ assert_eq!(str::from_utf8(&b).unwrap(), r#""#);
+ }
+}