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_size::GetSize;
12use get_size_derive::GetSize;
13use icu_locid::Locale;
14
15style_ref2!(TextStyleRef);
16
17#[derive(Debug, Clone, GetSize)]
21pub struct TextStyle {
22 origin: StyleOrigin,
24 styleuse: StyleUse,
26 name: String,
28 attr: AttrMap2,
30 textstyle: AttrMap2,
32}
33
34styles_styles2!(TextStyle, TextStyleRef);
35
36impl TextStyle {
37 pub fn new_empty() -> Self {
39 Self {
40 origin: Default::default(),
41 styleuse: Default::default(),
42 name: Default::default(),
43 attr: Default::default(),
44 textstyle: Default::default(),
45 }
46 }
47
48 pub fn new<S: AsRef<str>>(name: S) -> Self {
50 Self {
51 origin: Default::default(),
52 styleuse: Default::default(),
53 name: name.as_ref().to_string(),
54 attr: Default::default(),
55 textstyle: Default::default(),
56 }
57 }
58
59 pub fn attrmap(&self) -> &AttrMap2 {
61 &self.attr
62 }
63
64 pub fn attrmap_mut(&mut self) -> &mut AttrMap2 {
66 &mut self.attr
67 }
68
69 pub fn textstyle(&self) -> &AttrMap2 {
71 &self.textstyle
72 }
73
74 pub fn textstyle_mut(&mut self) -> &mut AttrMap2 {
76 &mut self.textstyle
77 }
78
79 fo_background_color!(textstyle);
80 fo_color!(textstyle);
81 fo_locale!(textstyle);
82 style_font_name!(textstyle);
83 fo_font_size!(textstyle);
84 fo_font_size_rel!(textstyle);
85 fo_font_style!(textstyle);
86 fo_font_weight!(textstyle);
87 fo_font_variant!(textstyle);
88 fo_font_attr!(textstyle);
89 style_locale_asian!(textstyle);
90 style_font_name_asian!(textstyle);
91 style_font_size_asian!(textstyle);
92 style_font_size_rel_asian!(textstyle);
93 style_font_style_asian!(textstyle);
94 style_font_weight_asian!(textstyle);
95 style_font_attr_asian!(textstyle);
96 style_locale_complex!(textstyle);
97 style_font_name_complex!(textstyle);
98 style_font_size_complex!(textstyle);
99 style_font_size_rel_complex!(textstyle);
100 style_font_style_complex!(textstyle);
101 style_font_weight_complex!(textstyle);
102 style_font_attr_complex!(textstyle);
103 fo_hyphenate!(textstyle);
104 fo_hyphenation_push_char_count!(textstyle);
105 fo_hyphenation_remain_char_count!(textstyle);
106 fo_letter_spacing!(textstyle);
107 fo_text_shadow!(textstyle);
108 fo_text_transform!(textstyle);
109 style_font_relief!(textstyle);
110 style_text_position!(textstyle);
111 style_rotation_angle!(textstyle);
112 style_rotation_scale!(textstyle);
113 style_letter_kerning!(textstyle);
114 style_text_combine!(textstyle);
115 style_text_combine_start_char!(textstyle);
116 style_text_combine_end_char!(textstyle);
117 style_text_emphasize!(textstyle);
118 style_text_line_through!(textstyle);
119 style_text_outline!(textstyle);
120 style_text_overline!(textstyle);
121 style_text_underline!(textstyle);
122 style_use_window_font_color!(textstyle);
123 text_condition!(textstyle);
124 text_display!(textstyle);
125}