spreadsheet_ods/style/
colstyle.rs

1use get_size2::GetSize;
2
3use crate::attrmap2::AttrMap2;
4use crate::style::units::{Length, PageBreak};
5use crate::style::AnyStyleRef;
6use crate::style::ParseStyleAttr;
7use crate::style::{rel_width_string, StyleOrigin, StyleUse};
8use crate::OdsError;
9use std::borrow::Borrow;
10
11style_ref2!(ColStyleRef);
12
13/// Describes the style information for a table column.
14/// Hardly ever used. It's easier to set the col_width via
15/// Sheet::set_col_width
16///
17#[derive(Debug, Clone, GetSize)]
18pub struct ColStyle {
19    /// From where did we get this style.
20    origin: StyleOrigin,
21    /// Which tag contains this style.
22    styleuse: StyleUse,
23    /// Style name
24    name: String,
25
26    /// General attributes
27    attr: AttrMap2,
28    /// Column style properties
29    colstyle: AttrMap2,
30}
31
32styles_styles2!(ColStyle, ColStyleRef);
33
34impl ColStyle {
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            colstyle: 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            colstyle: Default::default(),
54        }
55    }
56
57    /// Attributes
58    pub fn attrmap(&self) -> &AttrMap2 {
59        &self.attr
60    }
61
62    /// Attributes
63    pub fn attrmap_mut(&mut self) -> &mut AttrMap2 {
64        &mut self.attr
65    }
66
67    /// Style attributes
68    pub fn colstyle(&self) -> &AttrMap2 {
69        &self.colstyle
70    }
71
72    /// Style attributes
73    pub fn colstyle_mut(&mut self) -> &mut AttrMap2 {
74        &mut self.colstyle
75    }
76
77    fo_break!(colstyle);
78    style_column_width!(colstyle);
79    style_rel_column_width!(colstyle);
80    style_use_optimal_column_width!(colstyle);
81}