From f6c097edbba5986b2c1e818f4f60a0a63dc6803b Mon Sep 17 00:00:00 2001 From: "Vladimir.Khudoshin" Date: Tue, 13 Oct 2020 12:00:38 +0300 Subject: [PATCH 1/2] add left, right, insideH, insideV borders for table property --- src/formatting/border/insideh_border.rs | 44 +++++++++++++++++++++++++ src/formatting/border/insidev_border.rs | 44 +++++++++++++++++++++++++ src/formatting/border/mod.rs | 4 ++- src/formatting/borders.rs | 12 ++++++- src/formatting/table_borders.rs | 22 ++++++++++++- 5 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 src/formatting/border/insideh_border.rs create mode 100644 src/formatting/border/insidev_border.rs diff --git a/src/formatting/border/insideh_border.rs b/src/formatting/border/insideh_border.rs new file mode 100644 index 0000000..fd7ee5d --- /dev/null +++ b/src/formatting/border/insideh_border.rs @@ -0,0 +1,44 @@ +use std::borrow::Cow; +use strong_xml::{XmlRead, XmlWrite}; + +use crate::{__setter, __xml_test_suites, formatting::BorderStyle}; + +#[derive(Debug, Default, XmlRead, XmlWrite)] +#[cfg_attr(test, derive(PartialEq))] +#[xml(tag = "w:insideH")] +pub struct InsideHBorder<'a> { + #[xml(attr = "w:color")] + pub color: Option>, + #[xml(attr = "w:shadow")] + pub shadow: Option, + #[xml(attr = "w:space")] + pub space: Option, + #[xml(attr = "w:sz")] + pub size: Option, + #[xml(attr = "w:val")] + pub style: Option, +} + +impl<'a> InsideHBorder<'a> { + __setter!(color: Option>); + __setter!(shadow: Option); + __setter!(space: Option); + __setter!(size: Option); + __setter!(style: Option); +} + +__xml_test_suites!( + InsideHBorder, + InsideHBorder::default(), + r#""#, + InsideHBorder::default().color("000000"), + r#""#, + InsideHBorder::default().shadow(false), + r#""#, + InsideHBorder::default().space(40usize), + r#""#, + InsideHBorder::default().size(20usize), + r#""#, + InsideHBorder::default().style(BorderStyle::Dotted), + r#""#, +); diff --git a/src/formatting/border/insidev_border.rs b/src/formatting/border/insidev_border.rs new file mode 100644 index 0000000..93fc02a --- /dev/null +++ b/src/formatting/border/insidev_border.rs @@ -0,0 +1,44 @@ +use std::borrow::Cow; +use strong_xml::{XmlRead, XmlWrite}; + +use crate::{__setter, __xml_test_suites, formatting::BorderStyle}; + +#[derive(Debug, Default, XmlRead, XmlWrite)] +#[cfg_attr(test, derive(PartialEq))] +#[xml(tag = "w:insideV")] +pub struct insideVBorder<'a> { + #[xml(attr = "w:color")] + pub color: Option>, + #[xml(attr = "w:shadow")] + pub shadow: Option, + #[xml(attr = "w:space")] + pub space: Option, + #[xml(attr = "w:sz")] + pub size: Option, + #[xml(attr = "w:val")] + pub style: Option, +} + +impl<'a> insideVBorder<'a> { + __setter!(color: Option>); + __setter!(shadow: Option); + __setter!(space: Option); + __setter!(size: Option); + __setter!(style: Option); +} + +__xml_test_suites!( + insideVBorder, + insideVBorder::default(), + r#""#, + insideVBorder::default().color("000000"), + r#""#, + insideVBorder::default().shadow(false), + r#""#, + insideVBorder::default().space(40usize), + r#""#, + insideVBorder::default().size(20usize), + r#""#, + insideVBorder::default().style(BorderStyle::Dotted), + r#""#, +); diff --git a/src/formatting/border/mod.rs b/src/formatting/border/mod.rs index 9c7c5d2..63e6f34 100644 --- a/src/formatting/border/mod.rs +++ b/src/formatting/border/mod.rs @@ -4,8 +4,10 @@ mod bottom_border; mod left_border; mod right_border; mod top_border; +mod insideh_border; +mod insidev_border; pub use self::{ between_border::*, border_style::*, bottom_border::*, left_border::*, right_border::*, - top_border::*, + top_border::*, insideh_border::*, insidev_border::*, }; diff --git a/src/formatting/borders.rs b/src/formatting/borders.rs index 57b8df0..be7132d 100644 --- a/src/formatting/borders.rs +++ b/src/formatting/borders.rs @@ -2,7 +2,7 @@ use strong_xml::{XmlRead, XmlWrite}; use crate::{ __setter, __xml_test_suites, - formatting::{BetweenBorder, BottomBorder, LeftBorder, RightBorder, TopBorder}, + formatting::{BetweenBorder, BottomBorder, LeftBorder, RightBorder, TopBorder, InsideHBorder, InsideVBorder}, }; /// Borders @@ -20,6 +20,10 @@ pub struct Borders<'a> { pub right: Option>, #[xml(child = "w:between")] pub between: Option>, + #[xml(child = "w:insideH")] + pub insideH: Option>, + #[xml(child = "w:insideV")] + pub insideV: Option>, } impl<'a> Borders<'a> { @@ -28,6 +32,8 @@ impl<'a> Borders<'a> { __setter!(left: Option>); __setter!(right: Option>); __setter!(between: Option>); + __setter!(insideH: Option>); + __setter!(insideV: Option>); } __xml_test_suites!( @@ -44,4 +50,8 @@ __xml_test_suites!( r#""#, Borders::default().between(BetweenBorder::default()), r#""#, + Borders::default().insideH(InsideHBorder::default()), + r#""#, + Borders::default().insideV(InsideVBorder::default()), + r#""#, ); diff --git a/src/formatting/table_borders.rs b/src/formatting/table_borders.rs index c93ecda..8bb149d 100644 --- a/src/formatting/table_borders.rs +++ b/src/formatting/table_borders.rs @@ -2,7 +2,7 @@ use strong_xml::{XmlRead, XmlWrite}; use crate::{ __setter, __xml_test_suites, - formatting::{BottomBorder, TopBorder}, + formatting::{BottomBorder, TopBorder, LeftBorder, RightBorder, InsideHBorder, InsideVBorder}, }; #[derive(Debug, Default, XmlRead, XmlWrite)] @@ -13,11 +13,23 @@ pub struct TableBorders<'a> { pub top: Option>, #[xml(child = "w:bottom")] pub bottom: Option>, + #[xml(child = "w:left")] + pub left: Option>, + #[xml(child = "w:right")] + pub right: Option>, + #[xml(child = "w:insideH")] + pub insideH: Option>, + #[xml(child = "w:insideV")] + pub insideV: Option>, } impl<'a> TableBorders<'a> { __setter!(top: Option>); __setter!(bottom: Option>); + __setter!(left: Option>); + __setter!(right: Option>); + __setter!(insideH: Option>); + __setter!(insideV: Option>); } __xml_test_suites!( @@ -28,4 +40,12 @@ __xml_test_suites!( r#""#, TableBorders::default().bottom(BottomBorder::default()), r#""#, + TableBorders::default().left(LeftBorder::default()), + r#""#, + TableBorders::default().right(RightBorder::default()), + r#""#, + TableBorders::default().insideH(InsideHBorder::default()), + r#""#, + TableBorders::default().insideV(InsideVBorder::default()), + r#""#, ); From dc5103668492eb0d6823f7e6f06c3e6d6f67d244 Mon Sep 17 00:00:00 2001 From: "Vladimir.Khudoshin" Date: Tue, 13 Oct 2020 12:22:21 +0300 Subject: [PATCH 2/2] fix typo --- src/formatting/border/insidev_border.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/formatting/border/insidev_border.rs b/src/formatting/border/insidev_border.rs index 93fc02a..56cca96 100644 --- a/src/formatting/border/insidev_border.rs +++ b/src/formatting/border/insidev_border.rs @@ -6,7 +6,7 @@ use crate::{__setter, __xml_test_suites, formatting::BorderStyle}; #[derive(Debug, Default, XmlRead, XmlWrite)] #[cfg_attr(test, derive(PartialEq))] #[xml(tag = "w:insideV")] -pub struct insideVBorder<'a> { +pub struct InsideVBorder<'a> { #[xml(attr = "w:color")] pub color: Option>, #[xml(attr = "w:shadow")] @@ -19,7 +19,7 @@ pub struct insideVBorder<'a> { pub style: Option, } -impl<'a> insideVBorder<'a> { +impl<'a> InsideVBorder<'a> { __setter!(color: Option>); __setter!(shadow: Option); __setter!(space: Option); @@ -28,17 +28,17 @@ impl<'a> insideVBorder<'a> { } __xml_test_suites!( - insideVBorder, - insideVBorder::default(), + InsideVBorder, + InsideVBorder::default(), r#""#, - insideVBorder::default().color("000000"), + InsideVBorder::default().color("000000"), r#""#, - insideVBorder::default().shadow(false), + InsideVBorder::default().shadow(false), r#""#, - insideVBorder::default().space(40usize), + InsideVBorder::default().space(40usize), r#""#, - insideVBorder::default().size(20usize), + InsideVBorder::default().size(20usize), r#""#, - insideVBorder::default().style(BorderStyle::Dotted), + InsideVBorder::default().style(BorderStyle::Dotted), r#""#, );