spreadsheet_ods/format/
stylemap.rs

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