@@ -138,10 +138,14 @@ internal WP.Paragraph CreateParagraph(FF.Paragraph ffP)
138138 var paragraphStyleId = new WP . ParagraphStyleId { Val = ffP . Style } ;
139139 paragraphProperties . Append ( paragraphStyleId ) ;
140140 if ( Enum . TryParse < ParagraphAlignment > ( ffP . Alignment , true , out var alignmentEnum ) )
141- {
141+ {
142142 WP . JustificationValues justificationValue = MapAlignmentToJustification ( alignmentEnum ) ;
143143 paragraphProperties . Append ( new WP . Justification { Val = justificationValue } ) ;
144144 }
145+ if ( ffP . Indentation != null )
146+ {
147+ SetIndentation ( paragraphProperties , ffP . Indentation ) ;
148+ }
145149 wpParagraph . Append ( paragraphProperties ) ;
146150 }
147151
@@ -206,6 +210,33 @@ internal WP.Paragraph CreateParagraph(FF.Paragraph ffP)
206210 }
207211 }
208212
213+ private void SetIndentation ( WP . ParagraphProperties paragraphProperties , FF . Indentation ffIndentation )
214+ {
215+ var indentation = new WP . Indentation ( ) ;
216+
217+ if ( ffIndentation . Left > 0 )
218+ {
219+ indentation . Left = ( ffIndentation . Left * 1440 ) . ToString ( ) ;
220+ }
221+
222+ if ( ffIndentation . Right > 0 )
223+ {
224+ indentation . Right = ( ffIndentation . Right * 1440 ) . ToString ( ) ;
225+ }
226+
227+ if ( ffIndentation . FirstLine > 0 )
228+ {
229+ indentation . FirstLine = ( ffIndentation . FirstLine * 1440 ) . ToString ( ) ;
230+ }
231+
232+ if ( ffIndentation . Hanging > 0 )
233+ {
234+ indentation . Hanging = ( ffIndentation . FirstLine * 1440 ) . ToString ( ) ;
235+ }
236+
237+ paragraphProperties . Append ( indentation ) ;
238+ }
239+
209240 private WP . JustificationValues MapAlignmentToJustification ( ParagraphAlignment alignment )
210241 {
211242 switch ( alignment )
@@ -494,6 +525,14 @@ internal FF.Paragraph LoadParagraph(WP.Paragraph wpPara, int id)
494525 {
495526 ffP . Alignment = MapJustificationToAlignment ( justificationElement . Val ) ;
496527 }
528+ var Indentation = paraProps . Elements < WP . Indentation > ( ) . FirstOrDefault ( ) ;
529+ if ( Indentation != null )
530+ {
531+ ffP . Indentation . Left = int . Parse ( Indentation . Left ) ;
532+ ffP . Indentation . Right = int . Parse ( Indentation . Right ) ;
533+ ffP . Indentation . Hanging = int . Parse ( Indentation . Hanging ) ;
534+ ffP . Indentation . FirstLine = int . Parse ( Indentation . FirstLine ) ;
535+ }
497536 var runs = wpPara . Elements < WP . Run > ( ) ;
498537
499538 foreach ( var wpR in runs )
@@ -534,9 +573,9 @@ private string MapJustificationToAlignment(WP.JustificationValues justificationV
534573 case WP . JustificationValues . Center :
535574 return "Center" ;
536575 case WP . JustificationValues . Right :
537- return "Right" ;
538- case WP . JustificationValues . Both
539- return "Justify"
576+ return "Right" ;
577+ case WP . JustificationValues . Both :
578+ return "Justify" ;
540579 default :
541580 return "Left" ;
542581 }
0 commit comments