spreadsheet_ods/format/
stylemap.rs

1//!
2//! Conditional styles.
3//!
4
5use crate::condition::ValueCondition;
6use get_size2::GetSize;
7
8/// A style-map is one way for conditional formatting of value formats.
9#[derive(Clone, Debug, Default, GetSize)]
10pub struct ValueStyleMap {
11    condition: ValueCondition,
12    applied_style: String, // todo:
13}
14
15impl ValueStyleMap {
16    /// Create a stylemap for a ValueFormat. When the condition is fullfilled the style
17    /// applied_style is used.
18    pub fn new<T: AsRef<str>>(condition: ValueCondition, applied_style: T) -> Self {
19        Self {
20            condition,
21            applied_style: applied_style.as_ref().to_string(),
22        }
23    }
24
25    /// Condition
26    pub fn condition(&self) -> &ValueCondition {
27        &self.condition
28    }
29
30    /// Condition
31    pub fn set_condition(&mut self, cond: ValueCondition) {
32        self.condition = cond;
33    }
34
35    /// The applied style.
36    pub fn applied_style(&self) -> &String {
37        &self.applied_style
38    }
39
40    /// Sets the applied style.
41    pub fn set_applied_style<S: AsRef<str>>(&mut self, style: S) {
42        self.applied_style = style.as_ref().to_string();
43    }
44}