spreadsheet_ods/style/
textstyle.rs1use crate::attrmap2::AttrMap2;
2use crate::color::Rgb;
3use crate::style::units::{
4 Angle, FontSize, FontStyle, FontVariant, FontWeight, Length, LetterSpacing, LineMode,
5 LineStyle, LineType, LineWidth, Percent, RotationScale, TextCombine, TextCondition,
6 TextDisplay, TextEmphasize, TextEmphasizePosition, TextPosition, TextRelief, TextTransform,
7};
8use crate::style::AnyStyleRef;
9use crate::style::{color_string, shadow_string, text_position, StyleOrigin, StyleUse};
10use core::borrow::Borrow;
11use get_size2::GetSize;
12use icu_locale_core::Locale;
13
14style_ref2!(TextStyleRef);
15
16#[derive(Debug, Clone, GetSize)]
20pub struct TextStyle {
21 origin: StyleOrigin,
23 styleuse: StyleUse,
25 name: String,
27 attr: AttrMap2,
29 textstyle: AttrMap2,
31}
32
33styles_styles2!(TextStyle, TextStyleRef);
34
35impl TextStyle {
36 pub fn new_empty() -> Self {
38 Self {
39 origin: Default::default(),
40 styleuse: Default::default(),
41 name: Default::default(),
42 attr: Default::default(),
43 textstyle: Default::default(),
44 }
45 }
46
47 pub fn new<S: AsRef<str>>(name: S) -> Self {
49 Self {
50 origin: Default::default(),
51 styleuse: Default::default(),
52 name: name.as_ref().to_string(),
53 attr: Default::default(),
54 textstyle: Default::default(),
55 }
56 }
57
58 pub fn attrmap(&self) -> &AttrMap2 {
60 &self.attr
61 }
62
63 pub fn attrmap_mut(&mut self) -> &mut AttrMap2 {
65 &mut self.attr
66 }
67
68 pub fn textstyle(&self) -> &AttrMap2 {
70 &self.textstyle
71 }
72
73 pub fn textstyle_mut(&mut self) -> &mut AttrMap2 {
75 &mut self.textstyle
76 }
77
78 fo_background_color!(textstyle);
79 fo_color!(textstyle);
80 fo_locale!(textstyle);
81 style_font_name!(textstyle);
82 fo_font_size!(textstyle);
83 fo_font_size_rel!(textstyle);
84 fo_font_style!(textstyle);
85 fo_font_weight!(textstyle);
86 fo_font_variant!(textstyle);
87 fo_font_attr!(textstyle);
88 style_locale_asian!(textstyle);
89 style_font_name_asian!(textstyle);
90 style_font_size_asian!(textstyle);
91 style_font_size_rel_asian!(textstyle);
92 style_font_style_asian!(textstyle);
93 style_font_weight_asian!(textstyle);
94 style_font_attr_asian!(textstyle);
95 style_locale_complex!(textstyle);
96 style_font_name_complex!(textstyle);
97 style_font_size_complex!(textstyle);
98 style_font_size_rel_complex!(textstyle);
99 style_font_style_complex!(textstyle);
100 style_font_weight_complex!(textstyle);
101 style_font_attr_complex!(textstyle);
102 fo_hyphenate!(textstyle);
103 fo_hyphenation_push_char_count!(textstyle);
104 fo_hyphenation_remain_char_count!(textstyle);
105 fo_letter_spacing!(textstyle);
106 fo_text_shadow!(textstyle);
107 fo_text_transform!(textstyle);
108 style_font_relief!(textstyle);
109 style_text_position!(textstyle);
110 style_rotation_angle!(textstyle);
111 style_rotation_scale!(textstyle);
112 style_letter_kerning!(textstyle);
113 style_text_combine!(textstyle);
114 style_text_combine_start_char!(textstyle);
115 style_text_combine_end_char!(textstyle);
116 style_text_emphasize!(textstyle);
117 style_text_line_through!(textstyle);
118 style_text_outline!(textstyle);
119 style_text_overline!(textstyle);
120 style_text_underline!(textstyle);
121 style_use_window_font_color!(textstyle);
122 text_condition!(textstyle);
123 text_display!(textstyle);
124}