umya_spreadsheet/structs/
font_char_set.rs1use std::io::Cursor;
3
4use quick_xml::{
5 Reader,
6 Writer,
7 events::BytesStart,
8};
9
10use super::Int32Value;
11use crate::{
12 reader::driver::{
13 get_attribute,
14 set_string_from_xml,
15 },
16 writer::driver::write_start_tag,
17};
18
19#[derive(Clone, Default, Debug, Eq, Ord, PartialEq, PartialOrd)]
20pub struct FontCharSet {
21 pub(crate) val: Int32Value,
22}
23
24impl FontCharSet {
25 #[inline]
26 #[must_use]
27 pub fn val(&self) -> i32 {
28 self.val.value()
29 }
30
31 #[inline]
32 #[must_use]
33 #[deprecated(since = "3.0.0", note = "Use val()")]
34 pub fn get_val(&self) -> i32 {
35 self.val()
36 }
37
38 #[inline]
39 pub fn set_val(&mut self, value: i32) -> &mut Self {
40 self.val.set_value(value);
41 self
42 }
43
44 #[inline]
45 pub(crate) fn set_attributes<R: std::io::BufRead>(
46 &mut self,
47 _reader: &mut Reader<R>,
48 e: &BytesStart,
49 ) {
50 set_string_from_xml!(self, e, val, "val");
51 }
52
53 #[inline]
54 pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>) {
55 if self.val.has_value() {
57 let mut attributes: crate::structs::AttrCollection = Vec::new();
58 let val = self.val.value_string();
59 attributes.push(("val", &val).into());
60 write_start_tag(writer, "charset", attributes, true);
61 }
62 }
63}