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_size::GetSize;
11use get_size_derive::GetSize;
12
13style_ref2!(TableStyleRef);
14
15/// Describes the style information for a table.
16///
17#[derive(Debug, Clone, GetSize)]
18pub struct TableStyle {
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    /// General attributes
26    attr: AttrMap2,
27    /// Table style properties
28    tablestyle: AttrMap2,
29}
30
31styles_styles2!(TableStyle, TableStyleRef);
32
33impl TableStyle {
34    /// empty
35    pub fn new_empty() -> Self {
36        Self {
37            origin: Default::default(),
38            styleuse: Default::default(),
39            name: Default::default(),
40            attr: Default::default(),
41            tablestyle: Default::default(),
42        }
43    }
44
45    /// Creates a new Style.
46    pub fn new<S: AsRef<str>>(name: S) -> Self {
47        Self {
48            origin: Default::default(),
49            styleuse: Default::default(),
50            name: String::from(name.as_ref()),
51            attr: Default::default(),
52            tablestyle: Default::default(),
53        }
54    }
55
56    style_master_page!(attr);
57
58    /// Access to all stored attributes.
59    pub fn attrmap(&self) -> &AttrMap2 {
60        &self.attr
61    }
62
63    /// Access to all stored attributes.
64    pub fn attrmap_mut(&mut self) -> &mut AttrMap2 {
65        &mut self.attr
66    }
67
68    /// Access to all style attributes.
69    pub fn tablestyle(&self) -> &AttrMap2 {
70        &self.tablestyle
71    }
72
73    /// Access to all style attributes.
74    pub fn tablestyle_mut(&mut self) -> &mut AttrMap2 {
75        &mut self.tablestyle
76    }
77
78    fo_background_color!(tablestyle);
79    fo_break!(tablestyle);
80    fo_keep_with_next!(tablestyle);
81    fo_margin!(tablestyle);
82    style_may_break_between_rows!(tablestyle);
83    style_page_number!(tablestyle);
84    style_rel_width!(tablestyle);
85    style_width!(tablestyle);
86    style_shadow!(tablestyle);
87    style_writing_mode!(tablestyle);
88
89    table_align!(tablestyle);
90    table_border_model!(tablestyle);
91    table_display!(tablestyle);
92    table_tab_color!(tablestyle);
93}