spreadsheet_ods/style/
ruby.rs

1use crate::attrmap2::AttrMap2;
2use crate::style::AnyStyleRef;
3use crate::style::{StyleOrigin, StyleUse};
4use get_size2::GetSize;
5use std::borrow::Borrow;
6
7style_ref2!(RubyStyleRef);
8
9/// Text style.
10/// This is not used for cell-formatting. Use CellStyle instead.
11///
12#[derive(Debug, Clone, GetSize)]
13pub struct RubyStyle {
14    /// From where did we get this style.
15    origin: StyleOrigin,
16    /// Which tag contains this style.
17    styleuse: StyleUse,
18    /// Style name
19    name: String,
20    /// General attributes
21    attr: AttrMap2,
22    /// Specific attributes
23    rubystyle: AttrMap2,
24}
25
26styles_styles2!(RubyStyle, RubyStyleRef);
27
28impl RubyStyle {
29    /// Empty.
30    pub fn new_empty() -> Self {
31        Self {
32            origin: Default::default(),
33            styleuse: Default::default(),
34            name: Default::default(),
35            attr: Default::default(),
36            rubystyle: Default::default(),
37        }
38    }
39
40    /// A new named style.
41    pub fn new<S: AsRef<str>>(name: S) -> Self {
42        Self {
43            origin: Default::default(),
44            styleuse: Default::default(),
45            name: name.as_ref().to_string(),
46            attr: Default::default(),
47            rubystyle: Default::default(),
48        }
49    }
50
51    /// General attributes for the style.
52    pub fn attrmap(&self) -> &AttrMap2 {
53        &self.attr
54    }
55
56    /// General attributes for the style.
57    pub fn attrmap_mut(&mut self) -> &mut AttrMap2 {
58        &mut self.attr
59    }
60
61    /// All text-attributes for the style.
62    pub fn rubystyle(&self) -> &AttrMap2 {
63        &self.rubystyle
64    }
65
66    /// All text-attributes for the style.
67    pub fn rubystyle_mut(&mut self) -> &mut AttrMap2 {
68        &mut self.rubystyle
69    }
70}