File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
src/PhpWord/Writer/RTF/Part
tests/PhpWordTests/Writer/RTF Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -157,7 +157,11 @@ private function writeColorTable()
157157 $ content .= '{ ' ;
158158 $ content .= '\colortbl; ' ;
159159 foreach ($ this ->colorTable as $ color ) {
160- [$ red , $ green , $ blue ] = Converter::htmlToRgb ($ color );
160+ $ temp = Converter::htmlToRgb ($ color );
161+ $ red = $ green = $ blue = 0 ;
162+ if (is_array ($ temp )) {
163+ [$ red , $ green , $ blue ] = $ temp ;
164+ }
161165 $ content .= "\\red {$ red }\\green {$ green }\\blue {$ blue }; " ;
162166 }
163167 $ content .= '} ' ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * This file is part of PHPWord - A pure PHP library for reading and writing
5+ * word processing documents.
6+ *
7+ * PHPWord is free software distributed under the terms of the GNU Lesser
8+ * General Public License version 3 as published by the Free Software Foundation.
9+ *
10+ * For the full copyright and license information, please read the LICENSE
11+ * file that was distributed with this source code. For the full list of
12+ * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
13+ *
14+ * @see https://github.com/PHPOffice/PHPWord
15+ *
16+ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
17+ */
18+
19+ namespace PhpOffice \PhpWordTests \Writer \RTF ;
20+
21+ use PhpOffice \PhpWord \IOFactory ;
22+ use PhpOffice \PhpWord \Writer \RTF ;
23+
24+ /**
25+ * Test class for PhpOffice\PhpWord\Writer\RTF\Style subnamespace.
26+ */
27+ class Sample11Test extends \PHPUnit \Framework \TestCase
28+ {
29+ public function testSample11 (): void
30+ {
31+ $ source = 'samples/resources/Sample_11_ReadWord2007.docx ' ;
32+ $ phpWord = IOFactory::load ($ source );
33+ $ writer = new RTF ($ phpWord );
34+ $ content = $ writer ->getContent ();
35+ $ expected = '{\colortbl;\red255\green0\blue0;\red0\green0\blue0;\red0\green0\blue255;} ' ;
36+ self ::assertStringContainsString ($ expected , $ content );
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments