spreadsheet_ods/style/
graphicstyle.rs

1use crate::attrmap2::AttrMap2;
2use crate::style::units::{
3    FontSize, FontStyle, FontVariant, FontWeight, Hyphenation, HyphenationLadderCount, Indent,
4    LetterSpacing, LineBreak, LineHeight, LineMode, LineStyle, LineType, LineWidth, Margin,
5    PageBreak, PageNumber, ParaAlignVertical, Percent, PunctuationWrap, RotationScale, TextAlign,
6    TextAlignLast, TextAutoSpace, TextCombine, TextCondition, TextDisplay, TextEmphasize,
7    TextEmphasizePosition, TextKeep, TextPosition, TextRelief, TextTransform, WritingMode,
8};
9use crate::style::AnyStyleRef;
10use crate::style::{
11    border_line_width_string, border_string, color_string, shadow_string, text_position, Border,
12    Length, Rgb,
13};
14use crate::style::{StyleOrigin, StyleUse, TextStyleRef};
15use get_size::GetSize;
16use get_size_derive::GetSize;
17use icu_locid::Locale;
18use std::borrow::Borrow;
19
20style_ref2!(GraphicStyleRef);
21
22/// Styles of this type can occur in an odt file.
23/// This is only used as a place to put this stuff when reading the ods.
24///
25#[derive(Debug, Clone, GetSize)]
26pub struct GraphicStyle {
27    /// From where did we get this style.
28    origin: StyleOrigin,
29    /// Which tag contains this style.
30    styleuse: StyleUse,
31    /// Style name
32    name: String,
33    /// General attributes
34    attr: AttrMap2,
35    /// Graphics attributes.
36    graphicstyle: AttrMap2,
37    /// Paragraph attributes
38    paragraphstyle: AttrMap2,
39    /// Text attributes
40    textstyle: AttrMap2,
41}
42
43styles_styles2!(GraphicStyle, GraphicStyleRef);
44
45impl GraphicStyle {
46    /// Empty.
47    pub fn new_empty() -> Self {
48        Self {
49            origin: Default::default(),
50            styleuse: Default::default(),
51            name: Default::default(),
52            attr: Default::default(),
53            graphicstyle: Default::default(),
54            paragraphstyle: Default::default(),
55            textstyle: Default::default(),
56        }
57    }
58
59    /// New graphic style.
60    pub fn new<S: AsRef<str>>(name: S) -> Self {
61        Self {
62            origin: Default::default(),
63            styleuse: Default::default(),
64            name: name.as_ref().to_string(),
65            attr: Default::default(),
66            graphicstyle: Default::default(),
67            paragraphstyle: Default::default(),
68            textstyle: Default::default(),
69        }
70    }
71
72    /// General attributes.
73    pub fn attrmap(&self) -> &AttrMap2 {
74        &self.attr
75    }
76
77    /// General attributes.
78    pub fn attrmap_mut(&mut self) -> &mut AttrMap2 {
79        &mut self.attr
80    }
81
82    /// Graphic style attributes.
83    pub fn graphicstyle(&self) -> &AttrMap2 {
84        &self.graphicstyle
85    }
86
87    /// Graphic style attributes.
88    pub fn graphicstyle_mut(&mut self) -> &mut AttrMap2 {
89        &mut self.graphicstyle
90    }
91
92    /// Paragraph style attributes.
93    pub fn paragraphstyle(&self) -> &AttrMap2 {
94        &self.paragraphstyle
95    }
96
97    /// Paragraph style attributes.
98    pub fn paragraphstyle_mut(&mut self) -> &mut AttrMap2 {
99        &mut self.paragraphstyle
100    }
101
102    /// Text style attributes.
103    pub fn textstyle(&self) -> &AttrMap2 {
104        &self.textstyle
105    }
106
107    /// Text style attributes.
108    pub fn textstyle_mut(&mut self) -> &mut AttrMap2 {
109        &mut self.textstyle
110    }
111
112    fo_background_color!(paragraphstyle);
113    fo_border!(paragraphstyle);
114    fo_break!(paragraphstyle);
115    fo_hyphenation!(paragraphstyle);
116    fo_keep_together!(paragraphstyle);
117    fo_keep_with_next!(paragraphstyle);
118    fo_line_height!(paragraphstyle);
119    fo_margin!(paragraphstyle);
120    fo_orphans!(paragraphstyle);
121    fo_padding!(paragraphstyle);
122    fo_text_align!(paragraphstyle);
123    fo_text_align_last!(paragraphstyle);
124    fo_text_indent!(paragraphstyle);
125    fo_widows!(paragraphstyle);
126    style_auto_text_indent!(paragraphstyle);
127    style_background_transparency!(paragraphstyle);
128    fo_border_line_width!(paragraphstyle);
129    style_contextual_spacing!(paragraphstyle);
130    style_font_independent_line_spacing!(paragraphstyle);
131    style_join_border!(paragraphstyle);
132    style_justify_single_word!(paragraphstyle);
133    style_line_break!(paragraphstyle);
134    style_line_height_at_least!(paragraphstyle);
135    style_line_spacing!(paragraphstyle);
136    style_page_number!(paragraphstyle);
137    style_punctuation_wrap!(paragraphstyle);
138    style_register_true!(paragraphstyle);
139    style_shadow!(paragraphstyle);
140    style_snap_to_layout_grid!(paragraphstyle);
141    style_tab_stop_distance!(paragraphstyle);
142    style_text_autospace!(paragraphstyle);
143    style_vertical_align_para!(paragraphstyle);
144    style_writing_mode!(paragraphstyle);
145    style_writing_mode_automatic!(paragraphstyle);
146    style_line_number!(paragraphstyle);
147    style_number_lines!(paragraphstyle);
148
149    // TODO: background-image
150    // TODO: drop-cap
151
152    // fo_background_color!(textstyle);
153    fo_color!(textstyle);
154    fo_locale!(textstyle);
155    style_font_name!(textstyle);
156    fo_font_size!(textstyle);
157    fo_font_size_rel!(textstyle);
158    fo_font_style!(textstyle);
159    fo_font_weight!(textstyle);
160    fo_font_variant!(textstyle);
161    fo_font_attr!(textstyle);
162    style_locale_asian!(textstyle);
163    style_font_name_asian!(textstyle);
164    style_font_size_asian!(textstyle);
165    style_font_size_rel_asian!(textstyle);
166    style_font_style_asian!(textstyle);
167    style_font_weight_asian!(textstyle);
168    style_font_attr_asian!(textstyle);
169    style_locale_complex!(textstyle);
170    style_font_name_complex!(textstyle);
171    style_font_size_complex!(textstyle);
172    style_font_size_rel_complex!(textstyle);
173    style_font_style_complex!(textstyle);
174    style_font_weight_complex!(textstyle);
175    style_font_attr_complex!(textstyle);
176    fo_hyphenate!(textstyle);
177    fo_hyphenation_push_char_count!(textstyle);
178    fo_hyphenation_remain_char_count!(textstyle);
179    fo_letter_spacing!(textstyle);
180    fo_text_shadow!(textstyle);
181    fo_text_transform!(textstyle);
182    style_font_relief!(textstyle);
183    style_text_position!(textstyle);
184    // style_rotation_angle!(textstyle);
185    style_rotation_scale!(textstyle);
186    style_letter_kerning!(textstyle);
187    style_text_combine!(textstyle);
188    style_text_combine_start_char!(textstyle);
189    style_text_combine_end_char!(textstyle);
190    style_text_emphasize!(textstyle);
191    style_text_line_through!(textstyle);
192    style_text_outline!(textstyle);
193    style_text_overline!(textstyle);
194    style_text_underline!(textstyle);
195    style_use_window_font_color!(textstyle);
196    text_condition!(textstyle);
197    text_display!(textstyle);
198}