macro_rules! valueformat {
($format:ident, $valuetype:expr) => {
#[derive(Debug, Clone, GetSize)]
pub struct $format {
/// Name
name: String,
origin: StyleOrigin,
styleuse: StyleUse,
attr: AttrMap2,
textstyle: AttrMap2,
parts: Vec<FormatPart>,
stylemaps: Option<Vec<ValueStyleMap>>,
}
impl $format {
pub fn new_empty() -> Self {
Self {
name: String::from(""),
origin: Default::default(),
styleuse: Default::default(),
attr: Default::default(),
textstyle: Default::default(),
parts: Default::default(),
stylemaps: None,
}
}
#[deprecated]
pub fn new_with_name<S: AsRef<str>>(name: S) -> Self {
Self::new_named(name)
}
pub fn new_named<S: AsRef<str>>(name: S) -> Self {
Self {
name: name.as_ref().to_string(),
origin: Default::default(),
styleuse: Default::default(),
attr: Default::default(),
textstyle: Default::default(),
parts: Default::default(),
stylemaps: None,
}
}
pub fn new_localized<S: AsRef<str>>(name: S, locale: Locale) -> Self {
let mut v = Self {
name: name.as_ref().to_string(),
origin: Default::default(),
styleuse: Default::default(),
attr: Default::default(),
textstyle: Default::default(),
parts: Default::default(),
stylemaps: None,
};
v.set_locale(locale);
v
}
number_locale!(attr);
number_title!(attr);
number_transliteration_locale!(attr);
number_transliteration_format!(attr);
number_transliteration_style!(attr);
style_display_name!(attr);
style_volatile!(attr);
fo_background_color!(textstyle);
fo_color!(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_rotation_angle!(textstyle);
style_rotation_scale!(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);
}
impl ValueFormatTrait for $format {
fn format_ref(&self) -> ValueFormatRef {
ValueFormatRef::from(self.name().as_str())
}
fn set_name<S: Into<String>>(&mut self, name: S) {
self.name = name.into();
}
fn name(&self) -> &String {
&self.name
}
fn value_type(&self) -> ValueType {
$valuetype
}
fn set_origin(&mut self, origin: StyleOrigin) {
self.origin = origin;
}
fn origin(&self) -> StyleOrigin {
self.origin
}
fn set_styleuse(&mut self, styleuse: StyleUse) {
self.styleuse = styleuse;
}
fn styleuse(&self) -> StyleUse {
self.styleuse
}
fn attrmap(&self) -> &AttrMap2 {
&self.attr
}
fn attrmap_mut(&mut self) -> &mut AttrMap2 {
&mut self.attr
}
fn textstyle(&self) -> &AttrMap2 {
&self.textstyle
}
fn textstyle_mut(&mut self) -> &mut AttrMap2 {
&mut self.textstyle
}
fn push_part(&mut self, part: FormatPart) {
self.parts.push(part);
}
fn push_parts(&mut self, partvec: &mut Vec<FormatPart>) {
self.parts.append(partvec);
}
fn parts(&self) -> &Vec<FormatPart> {
&self.parts
}
fn parts_mut(&mut self) -> &mut Vec<FormatPart> {
&mut self.parts
}
fn push_stylemap(&mut self, stylemap: ValueStyleMap) {
self.stylemaps.get_or_insert_with(Vec::new).push(stylemap);
}
fn stylemaps(&self) -> Option<&Vec<ValueStyleMap>> {
self.stylemaps.as_ref()
}
fn stylemaps_mut(&mut self) -> &mut Vec<ValueStyleMap> {
self.stylemaps.get_or_insert_with(Vec::new)
}
}
};
}
macro_rules! part_number {
() => {
#[must_use]
pub fn part_number(&mut self) -> PartNumberBuilder<'_, Self> {
PartNumberBuilder::new(self)
}
};
}
macro_rules! part_fill_character {
() => {
#[must_use]
pub fn part_fill_character(&mut self) -> PartFillCharacterBuilder<'_, Self> {
PartFillCharacterBuilder::new(self)
}
};
}
macro_rules! part_scientific {
() => {
#[must_use]
pub fn part_scientific(&mut self) -> PartScientificBuilder<'_, Self> {
PartScientificBuilder::new(self)
}
};
}
macro_rules! part_fraction {
() => {
#[must_use]
pub fn part_fraction(&mut self) -> PartFractionBuilder<'_, Self> {
PartFractionBuilder::new(self)
}
};
}
macro_rules! part_currency {
() => {
#[must_use]
pub fn part_currency(&mut self) -> PartCurrencySymbolBuilder<'_, Self> {
PartCurrencySymbolBuilder::new(self)
}
};
}
macro_rules! part_day {
() => {
#[must_use]
pub fn part_day(&mut self) -> PartDayBuilder<'_, Self> {
PartDayBuilder::new(self)
}
};
}
macro_rules! part_month {
() => {
#[must_use]
pub fn part_month(&mut self) -> PartMonthBuilder<'_, Self> {
PartMonthBuilder::new(self)
}
};
}
macro_rules! part_year {
() => {
#[must_use]
pub fn part_year(&mut self) -> PartYearBuilder<'_, Self> {
PartYearBuilder::new(self)
}
};
}
macro_rules! part_era {
() => {
#[must_use]
pub fn part_era(&mut self) -> PartEraBuilder<'_, Self> {
PartEraBuilder::new(self)
}
};
}
macro_rules! part_day_of_week {
() => {
#[must_use]
pub fn part_day_of_week(&mut self) -> PartDayOfWeekBuilder<'_, Self> {
PartDayOfWeekBuilder::new(self)
}
};
}
macro_rules! part_week_of_year {
() => {
#[must_use]
pub fn part_week_of_year(&mut self) -> PartWeekOfYearBuilder<'_, Self> {
PartWeekOfYearBuilder::new(self)
}
};
}
macro_rules! part_quarter {
() => {
#[must_use]
pub fn part_quarter(&mut self) -> PartQuarterBuilder<'_, Self> {
PartQuarterBuilder::new(self)
}
};
}
macro_rules! part_hours {
() => {
#[must_use]
pub fn part_hours(&mut self) -> PartHoursBuilder<'_, Self> {
PartHoursBuilder::new(self)
}
};
}
macro_rules! part_minutes {
() => {
#[must_use]
pub fn part_minutes(&mut self) -> PartMinutesBuilder<'_, Self> {
PartMinutesBuilder::new(self)
}
};
}
macro_rules! part_seconds {
() => {
#[must_use]
pub fn part_seconds(&mut self) -> PartSecondsBuilder<'_, Self> {
PartSecondsBuilder::new(self)
}
};
}
macro_rules! part_am_pm {
() => {
#[must_use]
pub fn part_am_pm(&mut self) -> PartAmPmBuilder<'_, Self> {
PartAmPmBuilder::new(self)
}
};
}
macro_rules! part_boolean {
() => {
#[must_use]
pub fn part_boolean(&mut self) -> PartBooleanBuilder<'_, Self> {
PartBooleanBuilder::new(self)
}
};
}
macro_rules! part_text {
() => {
#[must_use]
pub fn part_text<S: Into<String>>(&mut self, text: S) -> PartTextBuilder<'_, Self> {
PartTextBuilder::new(self).text(text.into())
}
};
}
macro_rules! part_text_content {
() => {
#[must_use]
pub fn part_text_content(&mut self) -> PartTextContentBuilder<'_, Self> {
PartTextContentBuilder::new(self)
}
};
}
macro_rules! push_number {
() => {
#[deprecated]
pub fn push_number(&mut self, decimal_places: u8, grouping: bool) {
self.part_number()
.decimal_places(decimal_places)
.if_then(grouping, |p| p.grouping())
.min_decimal_places(0)
.min_integer_digits(1)
.build();
}
};
}
macro_rules! push_number_fix {
() => {
#[deprecated]
pub fn push_number_fix(&mut self, decimal_places: u8, grouping: bool) {
self.part_number()
.fixed_decimal_places(decimal_places)
.if_then(grouping, |p| p.grouping())
.min_integer_digits(1)
.build();
}
};
}
macro_rules! push_fraction {
() => {
#[deprecated]
pub fn push_fraction(
&mut self,
denominator: i64,
min_denominator_digits: u8,
min_integer_digits: u8,
min_numerator_digits: u8,
grouping: bool,
) {
self.part_fraction()
.denominator(denominator)
.min_denominator_digits(min_denominator_digits)
.min_integer_digits(min_integer_digits)
.min_numerator_digits(min_numerator_digits)
.if_then(grouping, |p| p.grouping())
.build();
}
};
}
macro_rules! push_scientific {
() => {
#[deprecated]
pub fn push_scientific(&mut self, decimal_places: u8) {
self.part_scientific()
.decimal_places(decimal_places)
.build();
}
};
}
macro_rules! push_currency_symbol {
() => {
#[deprecated]
pub fn push_currency_symbol<S>(&mut self, locale: Locale, symbol: S)
where
S: Into<String>,
{
self.part_currency().locale(locale).symbol(symbol).build();
}
};
}
macro_rules! push_day {
() => {
#[deprecated]
pub fn push_day(&mut self, style: FormatNumberStyle) {
self.part_day().style(style).build();
}
};
}
macro_rules! push_month {
() => {
#[deprecated]
pub fn push_month(&mut self, style: FormatNumberStyle, textual: bool) {
self.part_month()
.style(style)
.if_then(textual, |p| p.textual())
.build();
}
};
}
macro_rules! push_year {
() => {
#[deprecated]
pub fn push_year(&mut self, style: FormatNumberStyle) {
self.part_year().style(style).build();
}
};
}
macro_rules! push_era {
() => {
#[deprecated]
pub fn push_era(&mut self, style: FormatNumberStyle, calendar: FormatCalendarStyle) {
self.part_era().style(style).calendar(calendar).build();
}
};
}
macro_rules! push_day_of_week {
() => {
#[deprecated]
pub fn push_day_of_week(
&mut self,
style: FormatNumberStyle,
calendar: FormatCalendarStyle,
) {
self.part_day_of_week()
.style(style)
.calendar(calendar)
.build();
}
};
}
macro_rules! push_week_of_year {
() => {
#[deprecated]
pub fn push_week_of_year(&mut self, calendar: FormatCalendarStyle) {
self.part_week_of_year().calendar(calendar).build();
}
};
}
macro_rules! push_quarter {
() => {
#[deprecated]
pub fn push_quarter(&mut self, style: FormatNumberStyle, calendar: FormatCalendarStyle) {
self.part_quarter().style(style).calendar(calendar).build();
}
};
}
macro_rules! push_hours {
() => {
#[deprecated]
pub fn push_hours(&mut self, style: FormatNumberStyle) {
self.part_hours().style(style).build();
}
};
}
macro_rules! push_minutes {
() => {
#[deprecated]
pub fn push_minutes(&mut self, style: FormatNumberStyle) {
self.part_minutes().style(style).build();
}
};
}
macro_rules! push_seconds {
() => {
#[deprecated]
pub fn push_seconds(&mut self, style: FormatNumberStyle, decimal_places: u8) {
self.part_seconds()
.style(style)
.decimal_places(decimal_places)
.build();
}
};
}
macro_rules! push_am_pm {
() => {
#[deprecated]
pub fn push_am_pm(&mut self) {
self.part_am_pm().build();
}
};
}
macro_rules! push_boolean {
() => {
#[deprecated]
pub fn push_boolean(&mut self) {
self.part_boolean().build();
}
};
}
macro_rules! push_text {
() => {
#[deprecated]
pub fn push_text<S: Into<String>>(&mut self, text: S) {
self.part_text(text).build();
}
};
}
macro_rules! push_text_content {
() => {
#[deprecated]
pub fn push_text_content(&mut self) {
self.part_text_content().build();
}
};
}