spreadsheet_ods/style/
ruby.rs

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