File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -520,6 +520,12 @@ private static function parseStyle($attribute, $styles)
520
520
case 'background-color ' :
521
521
$ styles ['bgColor ' ] = trim ($ cValue , '# ' );
522
522
break ;
523
+ case 'line-height ' :
524
+ $ styles ['lineHeight ' ] = $ cValue ;
525
+ break ;
526
+ case 'text-indent ' :
527
+ $ styles ['indentation ' ]['firstLine ' ] = Converter::cssToTwip ($ cValue );
528
+ break ;
523
529
case 'font-weight ' :
524
530
$ tValue = false ;
525
531
if (preg_match ('#bold# ' , $ cValue )) {
Original file line number Diff line number Diff line change @@ -114,6 +114,34 @@ public function testParseTextDecoration()
114
114
$ this ->assertEquals ('single ' , $ doc ->getElementAttribute ('/w:document/w:body/w:p/w:r/w:rPr/w:u ' , 'w:val ' ));
115
115
}
116
116
117
+ /**
118
+ * Test line-height style
119
+ */
120
+ public function testParseLineHeight ()
121
+ {
122
+ $ phpWord = new \PhpOffice \PhpWord \PhpWord ();
123
+ $ section = $ phpWord ->addSection ();
124
+ Html::addHtml ($ section , '<p style="line-height: 1.5;">test</p> ' );
125
+
126
+ $ doc = TestHelperDOCX::getDocument ($ phpWord , 'Word2007 ' );
127
+ $ this ->assertTrue ($ doc ->elementExists ('/w:document/w:body/w:p/w:pPr/w:spacing ' ));
128
+ $ this ->assertEquals (240 * 1.5 , $ doc ->getElementAttribute ('/w:document/w:body/w:p/w:pPr/w:spacing ' , 'w:line ' ));
129
+ }
130
+
131
+ /**
132
+ * Test text-indent style
133
+ */
134
+ public function testParseTextIndent ()
135
+ {
136
+ $ phpWord = new \PhpOffice \PhpWord \PhpWord ();
137
+ $ section = $ phpWord ->addSection ();
138
+ Html::addHtml ($ section , '<p style="text-indent: 50px;">test</p> ' );
139
+
140
+ $ doc = TestHelperDOCX::getDocument ($ phpWord , 'Word2007 ' );
141
+ $ this ->assertTrue ($ doc ->elementExists ('/w:document/w:body/w:p/w:pPr/w:ind ' ));
142
+ $ this ->assertEquals (750 , $ doc ->getElementAttribute ('/w:document/w:body/w:p/w:pPr/w:ind ' , 'w:firstLine ' ));
143
+ }
144
+
117
145
/**
118
146
* Test text-align style
119
147
*/
You can’t perform that action at this time.
0 commit comments