spreadsheet_ods/style/
rowstyle.rs

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