spreadsheet_ods/style/
paragraphstyle.rs1use crate::attrmap2::AttrMap2;
2use crate::color::Rgb;
3use crate::style::tabstop::TabStop;
4use crate::style::units::{
5 Border, FontSize, FontStyle, FontVariant, FontWeight, Hyphenation, HyphenationLadderCount,
6 Indent, Length, LetterSpacing, LineBreak, LineHeight, LineMode, LineStyle, LineType, LineWidth,
7 Margin, PageBreak, PageNumber, ParaAlignVertical, Percent, PunctuationWrap, RotationScale,
8 TextAlign, TextAlignLast, TextAutoSpace, TextCombine, TextCondition, TextDisplay,
9 TextEmphasize, TextEmphasizePosition, TextKeep, TextPosition, TextRelief, TextTransform,
10 WritingMode,
11};
12use crate::style::AnyStyleRef;
13use crate::style::MasterPageRef;
14use crate::style::{
15 border_line_width_string, border_string, color_string, shadow_string, text_position,
16 StyleOrigin, StyleUse, TextStyleRef,
17};
18use get_size2::GetSize;
19use icu_locale_core::Locale;
20use std::borrow::Borrow;
21
22style_ref2!(ParagraphStyleRef);
23
24#[derive(Debug, Clone, GetSize)]
30pub struct ParagraphStyle {
31 origin: StyleOrigin,
33 styleuse: StyleUse,
35 name: String,
37 attr: AttrMap2,
39 paragraphstyle: AttrMap2,
41 textstyle: AttrMap2,
43 tabstops: Option<Vec<TabStop>>,
45}
46
47styles_styles2!(ParagraphStyle, ParagraphStyleRef);
48
49impl ParagraphStyle {
50 pub fn new_empty() -> Self {
52 Self {
53 origin: Default::default(),
54 styleuse: Default::default(),
55 name: Default::default(),
56 attr: Default::default(),
57 paragraphstyle: Default::default(),
58 textstyle: Default::default(),
59 tabstops: None,
60 }
61 }
62
63 pub fn new<S: AsRef<str>>(name: S) -> Self {
65 Self {
66 origin: Default::default(),
67 styleuse: Default::default(),
68 name: name.as_ref().to_string(),
69 attr: Default::default(),
70 paragraphstyle: Default::default(),
71 textstyle: Default::default(),
72 tabstops: None,
73 }
74 }
75
76 pub fn attrmap(&self) -> &AttrMap2 {
78 &self.attr
79 }
80
81 pub fn attrmap_mut(&mut self) -> &mut AttrMap2 {
83 &mut self.attr
84 }
85
86 pub fn paragraphstyle(&self) -> &AttrMap2 {
88 &self.paragraphstyle
89 }
90
91 pub fn paragraphstyle_mut(&mut self) -> &mut AttrMap2 {
93 &mut self.paragraphstyle
94 }
95
96 pub fn textstyle(&self) -> &AttrMap2 {
98 &self.textstyle
99 }
100
101 pub fn textstyle_mut(&mut self) -> &mut AttrMap2 {
103 &mut self.textstyle
104 }
105
106 style_default_outline_level!(attr);
107 style_master_page!(attr);
108 style_next_style!(attr);
109
110 pub fn add_tabstop(&mut self, ts: TabStop) {
112 let tabstops = self.tabstops.get_or_insert_with(Vec::new);
113 tabstops.push(ts);
114 }
115
116 pub fn tabstops(&self) -> Option<&Vec<TabStop>> {
118 self.tabstops.as_ref()
119 }
120
121 fo_background_color!(paragraphstyle);
122 fo_border!(paragraphstyle);
123 fo_break!(paragraphstyle);
124 fo_hyphenation!(paragraphstyle);
125 fo_keep_together!(paragraphstyle);
126 fo_keep_with_next!(paragraphstyle);
127 fo_line_height!(paragraphstyle);
128 fo_margin!(paragraphstyle);
129 fo_orphans!(paragraphstyle);
130 fo_padding!(paragraphstyle);
131 fo_text_align!(paragraphstyle);
132 fo_text_align_last!(paragraphstyle);
133 fo_text_indent!(paragraphstyle);
134 fo_widows!(paragraphstyle);
135 style_auto_text_indent!(paragraphstyle);
136 style_background_transparency!(paragraphstyle);
137 fo_border_line_width!(paragraphstyle);
138 style_contextual_spacing!(paragraphstyle);
139 style_font_independent_line_spacing!(paragraphstyle);
140 style_join_border!(paragraphstyle);
141 style_justify_single_word!(paragraphstyle);
142 style_line_break!(paragraphstyle);
143 style_line_height_at_least!(paragraphstyle);
144 style_line_spacing!(paragraphstyle);
145 style_page_number!(paragraphstyle);
146 style_punctuation_wrap!(paragraphstyle);
147 style_register_true!(paragraphstyle);
148 style_shadow!(paragraphstyle);
149 style_snap_to_layout_grid!(paragraphstyle);
150 style_tab_stop_distance!(paragraphstyle);
151 style_text_autospace!(paragraphstyle);
152 style_vertical_align_para!(paragraphstyle);
153 style_writing_mode!(paragraphstyle);
154 style_writing_mode_automatic!(paragraphstyle);
155 style_line_number!(paragraphstyle);
156 style_number_lines!(paragraphstyle);
157
158 fo_color!(textstyle);
163 fo_locale!(textstyle);
164 style_font_name!(textstyle);
165 fo_font_size!(textstyle);
166 fo_font_size_rel!(textstyle);
167 fo_font_style!(textstyle);
168 fo_font_weight!(textstyle);
169 fo_font_variant!(textstyle);
170 fo_font_attr!(textstyle);
171 style_locale_asian!(textstyle);
172 style_font_name_asian!(textstyle);
173 style_font_size_asian!(textstyle);
174 style_font_size_rel_asian!(textstyle);
175 style_font_style_asian!(textstyle);
176 style_font_weight_asian!(textstyle);
177 style_font_attr_asian!(textstyle);
178 style_locale_complex!(textstyle);
179 style_font_name_complex!(textstyle);
180 style_font_size_complex!(textstyle);
181 style_font_size_rel_complex!(textstyle);
182 style_font_style_complex!(textstyle);
183 style_font_weight_complex!(textstyle);
184 style_font_attr_complex!(textstyle);
185 fo_hyphenate!(textstyle);
186 fo_hyphenation_push_char_count!(textstyle);
187 fo_hyphenation_remain_char_count!(textstyle);
188 fo_letter_spacing!(textstyle);
189 fo_text_shadow!(textstyle);
190 fo_text_transform!(textstyle);
191 style_font_relief!(textstyle);
192 style_text_position!(textstyle);
193 style_rotation_scale!(textstyle);
195 style_letter_kerning!(textstyle);
196 style_text_combine!(textstyle);
197 style_text_combine_start_char!(textstyle);
198 style_text_combine_end_char!(textstyle);
199 style_text_emphasize!(textstyle);
200 style_text_line_through!(textstyle);
201 style_text_outline!(textstyle);
202 style_text_overline!(textstyle);
203 style_text_underline!(textstyle);
204 style_use_window_font_color!(textstyle);
205 text_condition!(textstyle);
206 text_display!(textstyle);
207}