spreadsheet_ods/style/
tablestyle.rs

1use crate::attrmap2::AttrMap2;
2use crate::color::Rgb;
3use crate::style::units::{
4    Length, Margin, PageBreak, PageNumber, RelativeScale, TableAlign, TableBorderModel, TextKeep,
5    WritingMode,
6};
7use crate::style::AnyStyleRef;
8use crate::style::{color_string, shadow_string, MasterPageRef, StyleOrigin, StyleUse};
9use core::borrow::Borrow;
10use get_size2::GetSize;
11
12style_ref2!(TableStyleRef);
13
14/// Describes the style information for a table.
15///
16#[derive(Debug, Clone, GetSize)]
17pub struct TableStyle {
18    /// From where did we get this style.
19    origin: StyleOrigin,
20    /// Which tag contains this style.
21    styleuse: StyleUse,
22    /// Style name
23    name: String,
24    /// General attributes
25    attr: AttrMap2,
26    /// Table style properties
27    tablestyle: AttrMap2,
28}
29
30styles_styles2!(TableStyle, TableStyleRef);
31
32impl TableStyle {
33    /// empty
34    pub fn new_empty() -> Self {
35        Self {
36            origin: Default::default(),
37            styleuse: Default::default(),
38            name: Default::default(),
39            attr: Default::default(),
40            tablestyle: Default::default(),
41        }
42    }
43
44    /// Creates a new Style.
45    pub fn new<S: AsRef<str>>(name: S) -> Self {
46        Self {
47            origin: Default::default(),
48            styleuse: Default::default(),
49            name: String::from(name.as_ref()),
50            attr: Default::default(),
51            tablestyle: Default::default(),
52        }
53    }
54
55    style_master_page!(attr);
56
57    /// Access to all stored attributes.
58    pub fn attrmap(&self) -> &AttrMap2 {
59        &self.attr
60    }
61
62    /// Access to all stored attributes.
63    pub fn attrmap_mut(&mut self) -> &mut AttrMap2 {
64        &mut self.attr
65    }
66
67    /// Access to all style attributes.
68    pub fn tablestyle(&self) -> &AttrMap2 {
69        &self.tablestyle
70    }
71
72    /// Access to all style attributes.
73    pub fn tablestyle_mut(&mut self) -> &mut AttrMap2 {
74        &mut self.tablestyle
75    }
76
77    fo_background_color!(tablestyle);
78    fo_break!(tablestyle);
79    fo_keep_with_next!(tablestyle);
80    fo_margin!(tablestyle);
81    style_may_break_between_rows!(tablestyle);
82    style_page_number!(tablestyle);
83    style_rel_width!(tablestyle);
84    style_width!(tablestyle);
85    style_shadow!(tablestyle);
86    style_writing_mode!(tablestyle);
87
88    table_align!(tablestyle);
89    table_border_model!(tablestyle);
90    table_display!(tablestyle);
91    table_tab_color!(tablestyle);
92}