use crate::attrmap2::AttrMap2;
use crate::color::Rgb;
use crate::format::ValueFormatRef;
use crate::style::stylemap::StyleMap;
use crate::style::units::{
Angle, Border, CellAlignVertical, CellProtect, FontSize, FontStyle, FontVariant, FontWeight,
GlyphOrientation, Hyphenation, HyphenationLadderCount, Indent, Length, LetterSpacing,
LineBreak, LineHeight, LineMode, LineStyle, LineType, LineWidth, Margin, PageBreak, PageNumber,
ParaAlignVertical, Percent, PunctuationWrap, RotationAlign, TextAlign, TextAlignLast,
TextAlignSource, TextAutoSpace, TextCombine, TextCondition, TextDisplay, TextEmphasize,
TextEmphasizePosition, TextKeep, TextPosition, TextRelief, TextTransform, WrapOption,
WritingDirection, WritingMode,
};
use crate::style::{
border_line_width_string, border_string, color_string, shadow_string, text_position,
StyleOrigin, StyleUse, TextStyleRef,
};
use icu_locid::Locale;
use std::fmt::{Display, Formatter};
style_ref!(CellStyleRef);
#[derive(Debug, Clone)]
pub struct CellStyle {
origin: StyleOrigin,
styleuse: StyleUse,
name: String,
attr: AttrMap2,
cellstyle: AttrMap2,
paragraphstyle: AttrMap2,
textstyle: AttrMap2,
stylemaps: Option<Vec<StyleMap>>,
}
styles_styles!(CellStyle, CellStyleRef);
impl CellStyle {
pub fn new_empty() -> Self {
Self {
origin: Default::default(),
styleuse: Default::default(),
name: Default::default(),
attr: Default::default(),
cellstyle: Default::default(),
paragraphstyle: Default::default(),
textstyle: Default::default(),
stylemaps: None,
}
}
pub fn new<S: Into<String>>(name: S, value_format: &ValueFormatRef) -> Self {
let mut s = Self {
origin: Default::default(),
styleuse: Default::default(),
name: name.into(),
attr: Default::default(),
cellstyle: Default::default(),
paragraphstyle: Default::default(),
textstyle: Default::default(),
stylemaps: None,
};
s.set_value_format(value_format);
s
}
pub fn value_format(&self) -> Option<&String> {
self.attr.attr("style:data-style-name")
}
pub fn set_value_format(&mut self, name: &ValueFormatRef) {
self.attr
.set_attr("style:data-style-name", name.to_string());
}
pub fn attrmap(&self) -> &AttrMap2 {
&self.attr
}
pub fn attrmap_mut(&mut self) -> &mut AttrMap2 {
&mut self.attr
}
pub fn cellstyle(&self) -> &AttrMap2 {
&self.cellstyle
}
pub fn cellstyle_mut(&mut self) -> &mut AttrMap2 {
&mut self.cellstyle
}
pub fn paragraphstyle(&self) -> &AttrMap2 {
&self.paragraphstyle
}
pub fn paragraphstyle_mut(&mut self) -> &mut AttrMap2 {
&mut self.paragraphstyle
}
pub fn textstyle(&self) -> &AttrMap2 {
&self.textstyle
}
pub fn textstyle_mut(&mut self) -> &mut AttrMap2 {
&mut self.textstyle
}
pub fn push_stylemap(&mut self, stylemap: StyleMap) {
self.stylemaps.get_or_insert_with(Vec::new).push(stylemap);
}
pub fn stylemaps(&self) -> Option<&Vec<StyleMap>> {
self.stylemaps.as_ref()
}
pub fn stylemaps_mut(&mut self) -> &mut Vec<StyleMap> {
self.stylemaps.get_or_insert_with(Vec::new)
}
fo_background_color!(cellstyle);
fo_border!(cellstyle);
fo_padding!(cellstyle);
fo_wrap_option!(cellstyle);
fo_border_line_width!(cellstyle);
style_cell_protect!(cellstyle);
style_decimal_places!(cellstyle);
style_diagonal!(cellstyle);
style_direction!(cellstyle);
style_glyph_orientation_vertical!(cellstyle);
style_print_content!(cellstyle);
style_repeat_content!(cellstyle);
style_rotation_align!(cellstyle);
style_rotation_angle!(cellstyle);
style_shadow!(cellstyle);
style_shrink_to_fit!(cellstyle);
style_text_align_source!(cellstyle);
style_vertical_align!(cellstyle);
style_writing_mode!(cellstyle);
fo_break!(paragraphstyle);
fo_hyphenation!(paragraphstyle);
fo_keep_together!(paragraphstyle);
fo_keep_with_next!(paragraphstyle);
fo_line_height!(paragraphstyle);
fo_margin!(paragraphstyle);
fo_orphans!(paragraphstyle);
fo_text_align!(paragraphstyle);
fo_text_align_last!(paragraphstyle);
fo_text_indent!(paragraphstyle);
fo_widows!(paragraphstyle);
style_auto_text_indent!(paragraphstyle);
style_background_transparency!(paragraphstyle);
style_contextual_spacing!(paragraphstyle);
style_font_independent_line_spacing!(paragraphstyle);
style_join_border!(paragraphstyle);
style_justify_single_word!(paragraphstyle);
style_line_break!(paragraphstyle);
style_line_height_at_least!(paragraphstyle);
style_line_spacing!(paragraphstyle);
style_page_number!(paragraphstyle);
style_punctuation_wrap!(paragraphstyle);
style_register_true!(paragraphstyle);
style_snap_to_layout_grid!(paragraphstyle);
style_tab_stop_distance!(paragraphstyle);
style_text_autospace!(paragraphstyle);
style_vertical_align_para!(paragraphstyle);
style_writing_mode_automatic!(paragraphstyle);
style_line_number!(paragraphstyle);
style_number_lines!(paragraphstyle);
fo_color!(textstyle);
fo_locale!(textstyle);
style_font_name!(textstyle);
fo_font_size!(textstyle);
fo_font_size_rel!(textstyle);
fo_font_style!(textstyle);
fo_font_weight!(textstyle);
fo_font_variant!(textstyle);
fo_font_attr!(textstyle);
style_locale_asian!(textstyle);
style_font_name_asian!(textstyle);
style_font_size_asian!(textstyle);
style_font_size_rel_asian!(textstyle);
style_font_style_asian!(textstyle);
style_font_weight_asian!(textstyle);
style_font_attr_asian!(textstyle);
style_locale_complex!(textstyle);
style_font_name_complex!(textstyle);
style_font_size_complex!(textstyle);
style_font_size_rel_complex!(textstyle);
style_font_style_complex!(textstyle);
style_font_weight_complex!(textstyle);
style_font_attr_complex!(textstyle);
fo_hyphenate!(textstyle);
fo_hyphenation_push_char_count!(textstyle);
fo_hyphenation_remain_char_count!(textstyle);
fo_letter_spacing!(textstyle);
fo_text_shadow!(textstyle);
fo_text_transform!(textstyle);
style_font_relief!(textstyle);
style_text_position!(textstyle);
style_letter_kerning!(textstyle);
style_text_combine!(textstyle);
style_text_combine_start_char!(textstyle);
style_text_combine_end_char!(textstyle);
style_text_emphasize!(textstyle);
style_text_line_through!(textstyle);
style_text_outline!(textstyle);
style_text_overline!(textstyle);
style_text_underline!(textstyle);
style_use_window_font_color!(textstyle);
text_condition!(textstyle);
text_display!(textstyle);
}