@@ -4,7 +4,7 @@ use crate::xml::Element;
4
4
5
5
#[ derive( PartialEq ) ]
6
6
pub struct Font {
7
- pub family : Option < String > ,
7
+ pub name : Option < String > ,
8
8
pub size : Option < String > ,
9
9
pub color : Option < String > ,
10
10
pub bold : bool ,
@@ -65,12 +65,12 @@ pub struct StyleTable {
65
65
pub fonts : Vec < Font > ,
66
66
pub fills : Vec < Fill > ,
67
67
pub borders : Vec < Border > ,
68
- pub xfs : Vec < Option < XSFProps > > ,
68
+ pub xfs : Vec < XFSProps > ,
69
69
pub custom_formats : HashMap < String , u32 > ,
70
70
next_custom_format : u32 ,
71
71
}
72
72
73
- pub struct XSFProps {
73
+ pub struct XFSProps {
74
74
pub font_id : Option < usize > ,
75
75
pub border_id : Option < usize > ,
76
76
pub fill_id : Option < usize > ,
@@ -85,23 +85,22 @@ impl StyleTable {
85
85
fonts : vec ! [ Font :: new( ) ] ,
86
86
fills : vec ! [ Fill :: new( None , "none" ) , Fill :: new( None , "gray125" ) ] ,
87
87
borders : vec ! [ Border :: new( ) ] ,
88
- xfs : vec ! [ ] ,
88
+ xfs : vec ! [ XFSProps :: new ( ) ] ,
89
89
custom_formats : HashMap :: new ( ) ,
90
90
next_custom_format : 164 ,
91
91
} ;
92
- match css {
93
- Some ( map ) => {
94
- for style in map {
95
- table . add ( style ) ;
96
- }
92
+ table . custom_formats . insert ( String :: from ( "General" ) , 164 ) ;
93
+
94
+ css . map ( |map| {
95
+ for style in map {
96
+ table . add ( style ) ;
97
97
}
98
- None => table. xfs . push ( Some ( XSFProps :: new ( ) ) ) ,
99
- }
98
+ } ) ;
100
99
101
100
table
102
101
}
103
102
pub fn add ( & mut self , style : HashMap < String , String > ) {
104
- let mut xsf_props: XSFProps = XSFProps :: new ( ) ;
103
+ let mut xsf_props: XFSProps = XFSProps :: new ( ) ;
105
104
let st = style_to_props ( & style) ;
106
105
107
106
xsf_props. font_id = st
@@ -151,7 +150,7 @@ impl StyleTable {
151
150
i as usize
152
151
} ) ;
153
152
154
- self . xfs . push ( Some ( xsf_props) ) ;
153
+ self . xfs . push ( xsf_props) ;
155
154
}
156
155
}
157
156
@@ -167,7 +166,7 @@ impl Fill {
167
166
impl Font {
168
167
pub fn new ( ) -> Font {
169
168
Font {
170
- family : None ,
169
+ name : None ,
171
170
size : None ,
172
171
color : None ,
173
172
bold : false ,
@@ -233,9 +232,9 @@ impl StyleProps {
233
232
}
234
233
}
235
234
236
- impl XSFProps {
237
- pub fn new ( ) -> XSFProps {
238
- XSFProps {
235
+ impl XFSProps {
236
+ pub fn new ( ) -> XFSProps {
237
+ XFSProps {
239
238
font_id : None ,
240
239
fill_id : None ,
241
240
border_id : None ,
@@ -260,7 +259,7 @@ fn style_to_props(styles: &HashMap<String, String>) -> StyleProps {
260
259
"color" => font. color = color_to_argb ( value) ,
261
260
"fontWeight" => font. bold = value == "bold" ,
262
261
"fontStyle" => font. italic = value == "italic" ,
263
- "fontFamily" => font. family = Some ( value. to_string ( ) ) ,
262
+ "fontFamily" => font. name = Some ( value. to_string ( ) ) ,
264
263
"textDecoration" => {
265
264
font. underline = value. contains ( "underline" ) ;
266
265
font. strike = value. contains ( "line-through" ) ;
@@ -435,7 +434,7 @@ fn str_to_border(v: &str, pos: BorderPosition) -> Option<BorderProps> {
435
434
"dashed" => BorderStyle :: Dashed ,
436
435
"solid" => {
437
436
let mut st = BorderStyle :: Thin ;
438
-
437
+
439
438
if size == 0.5 {
440
439
st = BorderStyle :: Thin
441
440
} else if size == 1.0 {
@@ -486,7 +485,7 @@ fn style_to_props_test() {
486
485
assert_eq ! ( font. size, Some ( String :: from( "18" ) ) ) ;
487
486
assert_eq ! ( font. color, Some ( String :: from( "FFFFFF00" ) ) ) ;
488
487
assert_eq ! ( font. bold, true ) ;
489
- assert_eq ! ( font. family , Some ( String :: from( "Calibri" ) ) ) ;
488
+ assert_eq ! ( font. name , Some ( String :: from( "Calibri" ) ) ) ;
490
489
assert_eq ! ( font. italic, true ) ;
491
490
assert_eq ! ( font. underline, true ) ;
492
491
assert_eq ! ( st. fill. unwrap( ) . color, Some ( String :: from( "FFFF0000" ) ) ) ;
0 commit comments