@@ -32,6 +32,7 @@ pub enum RunChild {
3232 Tab ( Tab ) ,
3333 PTab ( PositionalTab ) ,
3434 Break ( Break ) ,
35+ CarriageReturn ( CarriageReturn ) ,
3536 Drawing ( Box < Drawing > ) ,
3637 Shape ( Box < Shape > ) ,
3738 CommentStart ( Box < CommentRangeStart > ) ,
@@ -86,6 +87,11 @@ impl Serialize for RunChild {
8687 t. serialize_field ( "data" , s) ?;
8788 t. end ( )
8889 }
90+ RunChild :: CarriageReturn ( _) => {
91+ let mut t = serializer. serialize_struct ( "CarriageReturn" , 1 ) ?;
92+ t. serialize_field ( "type" , "carriageReturn" ) ?;
93+ t. end ( )
94+ }
8995 RunChild :: Drawing ( ref s) => {
9096 let mut t = serializer. serialize_struct ( "Drawing" , 2 ) ?;
9197 t. serialize_field ( "type" , "drawing" ) ?;
@@ -243,6 +249,12 @@ impl Run {
243249 self
244250 }
245251
252+ pub fn add_carriage_return ( mut self ) -> Run {
253+ self . children
254+ . push ( RunChild :: CarriageReturn ( CarriageReturn :: new ( ) ) ) ;
255+ self
256+ }
257+
246258 pub fn add_sym ( mut self , sym : Sym ) -> Run {
247259 self . children . push ( RunChild :: Sym ( sym) ) ;
248260 self
@@ -358,6 +370,7 @@ impl BuildXML for RunChild {
358370 RunChild :: Tab ( t) => t. build_to ( stream) ,
359371 RunChild :: PTab ( t) => t. build_to ( stream) ,
360372 RunChild :: Break ( t) => t. build_to ( stream) ,
373+ RunChild :: CarriageReturn ( t) => t. build_to ( stream) ,
361374 RunChild :: Drawing ( t) => t. build_to ( stream) ,
362375 RunChild :: Shape ( _t) => {
363376 todo ! ( "Support shape writer." )
@@ -439,6 +452,7 @@ mod tests {
439452 RunChild :: Tab ( Tab :: new( ) ) ,
440453 RunChild :: Text ( Text :: new( "Hello" ) ) ,
441454 RunChild :: Break ( Break :: new( BreakType :: Page ) ) ,
455+ RunChild :: CarriageReturn ( CarriageReturn :: new( ) ) ,
442456 RunChild :: DeleteText ( DeleteText :: new( "deleted" ) ) ,
443457 ] ,
444458 run_property : RunProperty {
@@ -458,7 +472,7 @@ mod tests {
458472 } ;
459473 assert_eq ! (
460474 serde_json:: to_string( & run) . unwrap( ) ,
461- r#"{"runProperty":{"sz":30,"szCs":30,"color":"C9211E","highlight":"yellow","underline":"single","bold":true,"boldCs":true,"italic":true,"italicCs":true,"vanish":true,"characterSpacing":100},"children":[{"type":"tab"},{"type":"text","data":{"preserveSpace":true,"text":"Hello"}},{"type":"break","data":{"breakType":"page"}},{"type":"deleteText","data":{"text":"deleted","preserveSpace":true}}]}"# ,
475+ r#"{"runProperty":{"sz":30,"szCs":30,"color":"C9211E","highlight":"yellow","underline":"single","bold":true,"boldCs":true,"italic":true,"italicCs":true,"vanish":true,"characterSpacing":100},"children":[{"type":"tab"},{"type":"text","data":{"preserveSpace":true,"text":"Hello"}},{"type":"break","data":{"breakType":"page"}},{"type":"carriageReturn"},{"type":" deleteText","data":{"text":"deleted","preserveSpace":true}}]}"# ,
462476 ) ;
463477 }
464478
0 commit comments