spreadsheet_ods/style/
rowstyle.rs

1use crate::color::Rgb;
2use get_size2::GetSize;
3
4use crate::attrmap2::AttrMap2;
5use crate::style::units::{Length, PageBreak, TextKeep};
6use crate::style::AnyStyleRef;
7use crate::style::ParseStyleAttr;
8use crate::style::{color_string, StyleOrigin, StyleUse};
9use crate::OdsError;
10use std::borrow::Borrow;
11
12style_ref2!(RowStyleRef);
13
14/// Describes the style information for a table row.
15/// Hardly ever used. It's easier to set the row_height via
16/// Sheet::set_row_height.
17///
18#[derive(Debug, Clone, GetSize)]
19pub struct RowStyle {
20    /// From where did we get this style.
21    origin: StyleOrigin,
22    /// Which tag contains this style.
23    styleuse: StyleUse,
24    /// Style name
25    name: String,
26    /// General attributes
27    attr: AttrMap2,
28    /// Table style properties
29    rowstyle: AttrMap2,
30}
31
32styles_styles2!(RowStyle, RowStyleRef);
33
34impl RowStyle {
35    /// empty
36    pub fn new_empty() -> Self {
37        Self {
38            origin: Default::default(),
39            styleuse: Default::default(),
40            name: Default::default(),
41            attr: Default::default(),
42            rowstyle: Default::default(),
43        }
44    }
45
46    /// New Style.
47    pub fn new<S: AsRef<str>>(name: S) -> Self {
48        Self {
49            origin: Default::default(),
50            styleuse: Default::default(),
51            name: name.as_ref().to_string(),
52            attr: Default::default(),
53            rowstyle: Default::default(),
54        }
55    }
56
57    /// General attributes.
58    pub fn attrmap(&self) -> &AttrMap2 {
59        &self.attr
60    }
61
62    /// General attributes.
63    pub fn attrmap_mut(&mut self) -> &mut AttrMap2 {
64        &mut self.attr
65    }
66
67    /// Style attributes.
68    pub fn rowstyle(&self) -> &AttrMap2 {
69        &self.rowstyle
70    }
71
72    /// Style attributes.
73    pub fn rowstyle_mut(&mut self) -> &mut AttrMap2 {
74        &mut self.rowstyle
75    }
76
77    fo_background_color!(rowstyle);
78    fo_break!(rowstyle);
79    fo_keep_together!(rowstyle);
80    style_min_row_height!(rowstyle);
81    style_row_height!(rowstyle);
82    style_use_optimal_row_height!(rowstyle);
83}