ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
|
|
|
|
* word processing documents.
|
|
|
|
|
*
|
|
|
|
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
|
|
|
|
* General Public License version 3 as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* For the full copyright and license information, please read the LICENSE
|
|
|
|
|
* file that was distributed with this source code. For the full list of
|
|
|
|
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
|
|
|
|
*
|
|
|
|
|
* @see https://github.com/PHPOffice/PHPWord
|
2022-09-16 11:45:45 +02:00
|
|
|
*
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace PhpOffice\PhpWord\Writer\ODText\Style;
|
|
|
|
|
|
2020-02-06 19:20:13 -08:00
|
|
|
use PhpOffice\PhpWord\Style\Font;
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
use PhpOffice\PhpWord\TestHelperDOCX;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-09-16 11:45:45 +02:00
|
|
|
* Test class for Headers, Footers, Tabs in ODT.
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
*/
|
|
|
|
|
class FontTest extends \PHPUnit\Framework\TestCase
|
|
|
|
|
{
|
|
|
|
|
/**
|
2022-09-16 11:45:45 +02:00
|
|
|
* Executed after each method of the class.
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
*/
|
2022-09-16 11:45:45 +02:00
|
|
|
protected function tearDown(): void
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
{
|
|
|
|
|
TestHelperDOCX::clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-09-16 11:45:45 +02:00
|
|
|
* Test colors.
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
*/
|
2022-09-16 11:45:45 +02:00
|
|
|
public function testColors(): void
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
{
|
|
|
|
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
|
|
|
|
$section = $phpWord->addSection();
|
2022-09-16 11:45:45 +02:00
|
|
|
$section->addText('This is red (800) in rtf/html, default in docx/odt', ['color' => '800']);
|
|
|
|
|
$section->addText('This should be cyanish (008787)', ['color' => '008787']);
|
|
|
|
|
$section->addText('This should be dark green (FGCOLOR_DARKGREEN)', ['color' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_DARKGREEN]);
|
|
|
|
|
$section->addText('This color is default (unknow)', ['color' => 'unknow']);
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
|
|
|
|
|
$doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
|
|
|
|
|
$s2a = '/office:document-content/office:automatic-styles';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($s2a));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$s2t = '/office:document-content/office:body/office:text/text:section';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($s2t));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
|
|
|
|
|
$element = "$s2a/style:style[5]";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$style = $doc->getElementAttribute($element, 'style:name');
|
|
|
|
|
$element .= '/style:text-properties';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
|
|
|
|
self::assertEquals('#008787', $doc->getElementAttribute($element, 'fo:color'));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$span = "$s2t/text:p[3]/text:span";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($span));
|
|
|
|
|
self::assertEquals($style, $doc->getElementAttribute($span, 'text:style-name'));
|
|
|
|
|
self::assertEquals('This should be cyanish (008787)', $doc->getElement($span)->nodeValue);
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
|
|
|
|
|
$element = "$s2a/style:style[7]";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$style = $doc->getElementAttribute($element, 'style:name');
|
|
|
|
|
$element .= '/style:text-properties';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
|
|
|
|
self::assertEquals('#006400', $doc->getElementAttribute($element, 'fo:color'));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$span = "$s2t/text:p[4]/text:span";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($span));
|
|
|
|
|
self::assertEquals($style, $doc->getElementAttribute($span, 'text:style-name'));
|
|
|
|
|
self::assertEquals('This should be dark green (FGCOLOR_DARKGREEN)', $doc->getElement($span)->nodeValue);
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
}
|
|
|
|
|
|
2020-02-06 19:20:13 -08:00
|
|
|
public function providerAllNamedColors()
|
|
|
|
|
{
|
2022-09-16 11:45:45 +02:00
|
|
|
return [
|
|
|
|
|
[Font::FGCOLOR_YELLOW, 'FFFF00'],
|
|
|
|
|
[Font::FGCOLOR_LIGHTGREEN, '90EE90'],
|
|
|
|
|
[Font::FGCOLOR_CYAN, '00FFFF'],
|
|
|
|
|
[Font::FGCOLOR_MAGENTA, 'FF00FF'],
|
|
|
|
|
[Font::FGCOLOR_BLUE, '0000FF'],
|
|
|
|
|
[Font::FGCOLOR_RED, 'FF0000'],
|
|
|
|
|
[Font::FGCOLOR_DARKBLUE, '00008B'],
|
|
|
|
|
[Font::FGCOLOR_DARKCYAN, '008B8B'],
|
|
|
|
|
[Font::FGCOLOR_DARKGREEN, '006400'],
|
|
|
|
|
[Font::FGCOLOR_DARKMAGENTA, '8B008B'],
|
|
|
|
|
[Font::FGCOLOR_DARKRED, '8B0000'],
|
|
|
|
|
[Font::FGCOLOR_DARKYELLOW, '8B8B00'],
|
|
|
|
|
[Font::FGCOLOR_DARKGRAY, 'A9A9A9'],
|
|
|
|
|
[Font::FGCOLOR_LIGHTGRAY, 'D3D3D3'],
|
|
|
|
|
[Font::FGCOLOR_BLACK, '000000'],
|
|
|
|
|
['unknow', 'unknow'],
|
|
|
|
|
['unknown', 'unknown'],
|
|
|
|
|
];
|
2020-02-06 19:20:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider providerAllNamedColors
|
|
|
|
|
*
|
|
|
|
|
* @param string $namedColor
|
|
|
|
|
* @param string $rgbColor
|
|
|
|
|
*/
|
2022-09-16 11:45:45 +02:00
|
|
|
public function testAllNamedColors($namedColor, $rgbColor): void
|
2020-02-06 19:20:13 -08:00
|
|
|
{
|
|
|
|
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
|
|
|
|
$section = $phpWord->addSection();
|
2022-09-16 11:45:45 +02:00
|
|
|
$section->addText('This is red (800) in rtf/html, default in docx/odt', ['color' => '800']);
|
|
|
|
|
$section->addText('This should be cyanish (008787)', ['color' => '008787']);
|
|
|
|
|
$section->addText($namedColor, ['color' => $namedColor]);
|
2020-02-06 19:20:13 -08:00
|
|
|
|
|
|
|
|
$doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
|
|
|
|
|
$s2a = '/office:document-content/office:automatic-styles';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($s2a));
|
2020-02-06 19:20:13 -08:00
|
|
|
$s2t = '/office:document-content/office:body/office:text/text:section';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($s2t));
|
2020-02-06 19:20:13 -08:00
|
|
|
|
|
|
|
|
$element = "$s2a/style:style[7]";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
2020-02-06 19:20:13 -08:00
|
|
|
$style = $doc->getElementAttribute($element, 'style:name');
|
|
|
|
|
$element .= '/style:text-properties';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
|
|
|
|
self::assertEquals("#$rgbColor", $doc->getElementAttribute($element, 'fo:color'));
|
2020-02-06 19:20:13 -08:00
|
|
|
$span = "$s2t/text:p[4]/text:span";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($span));
|
|
|
|
|
self::assertEquals($style, $doc->getElementAttribute($span, 'text:style-name'));
|
|
|
|
|
self::assertEquals($namedColor, $doc->getElement($span)->nodeValue);
|
2020-02-06 19:20:13 -08:00
|
|
|
}
|
|
|
|
|
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
/**
|
2022-09-16 11:45:45 +02:00
|
|
|
* Test noproof.
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
*/
|
2022-09-16 11:45:45 +02:00
|
|
|
public function testNoProof(): void
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
{
|
|
|
|
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
|
|
|
|
$section = $phpWord->addSection();
|
2022-09-16 11:45:45 +02:00
|
|
|
$section->addText('Noproof not specified', ['color' => 'black']);
|
|
|
|
|
$section->addText('Noproof is true', ['color' => 'black', 'noproof' => true]);
|
|
|
|
|
$section->addText('Noproof is false', ['color' => 'black', 'noproof' => false]);
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
|
|
|
|
|
$doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
|
|
|
|
|
$s2a = '/office:document-content/office:automatic-styles';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($s2a));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$s2t = '/office:document-content/office:body/office:text/text:section';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($s2t));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
|
|
|
|
|
$element = "$s2a/style:style[3]";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$style = $doc->getElementAttribute($element, 'style:name');
|
|
|
|
|
$element .= '/style:text-properties';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
|
|
|
|
self::assertEquals('', $doc->getElementAttribute($element, 'fo:language'));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$span = "$s2t/text:p[2]/text:span";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($span));
|
|
|
|
|
self::assertEquals($style, $doc->getElementAttribute($span, 'text:style-name'));
|
|
|
|
|
self::assertEquals('Noproof not specified', $doc->getElement($span)->nodeValue);
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
|
|
|
|
|
$element = "$s2a/style:style[5]";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$style = $doc->getElementAttribute($element, 'style:name');
|
|
|
|
|
$element .= '/style:text-properties';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
|
|
|
|
self::assertEquals('zxx', $doc->getElementAttribute($element, 'fo:language'));
|
|
|
|
|
self::assertEquals('zxx', $doc->getElementAttribute($element, 'style:language-asian'));
|
|
|
|
|
self::assertEquals('zxx', $doc->getElementAttribute($element, 'style:language-complex'));
|
|
|
|
|
self::assertEquals('none', $doc->getElementAttribute($element, 'fo:country'));
|
|
|
|
|
self::assertEquals('none', $doc->getElementAttribute($element, 'style:country-asian'));
|
|
|
|
|
self::assertEquals('none', $doc->getElementAttribute($element, 'style:country-complex'));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$span = "$s2t/text:p[3]/text:span";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($span));
|
|
|
|
|
self::assertEquals($style, $doc->getElementAttribute($span, 'text:style-name'));
|
|
|
|
|
self::assertEquals('Noproof is true', $doc->getElement($span)->nodeValue);
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
|
|
|
|
|
$element = "$s2a/style:style[7]";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$style = $doc->getElementAttribute($element, 'style:name');
|
|
|
|
|
$element .= '/style:text-properties';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
|
|
|
|
self::assertEquals('', $doc->getElementAttribute($element, 'fo:language'));
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
$span = "$s2t/text:p[4]/text:span";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($span));
|
|
|
|
|
self::assertEquals($style, $doc->getElementAttribute($span, 'text:style-name'));
|
|
|
|
|
self::assertEquals('Noproof is false', $doc->getElement($span)->nodeValue);
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
}
|
2020-02-06 19:20:13 -08:00
|
|
|
|
|
|
|
|
/**
|
2022-09-16 11:45:45 +02:00
|
|
|
* Test using object with a name as font style for addText.
|
2020-02-06 19:20:13 -08:00
|
|
|
*/
|
2022-09-16 11:45:45 +02:00
|
|
|
public function testNamedStyleAsObject(): void
|
2020-02-06 19:20:13 -08:00
|
|
|
{
|
|
|
|
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
2022-09-16 11:45:45 +02:00
|
|
|
$named = $phpWord->addFontStyle('namedobject', ['color' => '008787']);
|
2020-02-06 19:20:13 -08:00
|
|
|
$section = $phpWord->addSection();
|
|
|
|
|
$section->addText('Let us see what color we wind up with', $named);
|
|
|
|
|
|
|
|
|
|
$doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
|
|
|
|
|
$s2t = '/office:document-content/office:body/office:text/text:section';
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($s2t));
|
2020-02-06 19:20:13 -08:00
|
|
|
$element = "$s2t/text:p[2]/text:span";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertTrue($doc->elementExists($element));
|
|
|
|
|
self::assertEquals('namedobject', $doc->getElementAttribute($element, 'text:style-name'));
|
2020-02-06 19:20:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-09-16 11:45:45 +02:00
|
|
|
* Test supplying field font style as array or object or string.
|
2020-02-06 19:20:13 -08:00
|
|
|
*/
|
2022-09-16 11:45:45 +02:00
|
|
|
public function testFieldStyles(): void
|
2020-02-06 19:20:13 -08:00
|
|
|
{
|
|
|
|
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
2022-09-16 11:45:45 +02:00
|
|
|
$namedstyle = $phpWord->addFontStyle('namedstyle', ['color' => '800000']);
|
2020-02-06 19:20:13 -08:00
|
|
|
$section = $phpWord->addSection();
|
|
|
|
|
$textrun = $section->addTextRun();
|
|
|
|
|
$fld = $textrun->addField('DATE');
|
|
|
|
|
$fld->setFontStyle('namedstyle');
|
|
|
|
|
$textrun = $section->addTextRun();
|
|
|
|
|
$fld = $textrun->addField('DATE');
|
2022-09-16 11:45:45 +02:00
|
|
|
$fld->setFontStyle(['color' => '008000']);
|
2020-02-06 19:20:13 -08:00
|
|
|
$textrun = $section->addTextRun();
|
|
|
|
|
$fld = $textrun->addField('DATE');
|
|
|
|
|
$font = new \PhpOffice\PhpWord\Style\Font();
|
|
|
|
|
$font->setColor('000080');
|
|
|
|
|
$fld->setFontStyle($font);
|
2020-02-06 23:34:24 -08:00
|
|
|
$textrun = $section->addTextRun();
|
|
|
|
|
$fld = $textrun->addField('DATE');
|
|
|
|
|
$fld->setFontStyle($namedstyle);
|
2020-02-06 19:20:13 -08:00
|
|
|
|
|
|
|
|
$doc = TestHelperDOCX::getDocument($phpWord, 'ODText');
|
|
|
|
|
$s2a = '/office:document-content/office:automatic-styles';
|
|
|
|
|
$s2t = '/office:document-content/office:body/office:text/text:section';
|
|
|
|
|
|
|
|
|
|
$element = "$s2a/style:style[5]";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertEquals('T1', $doc->getElementAttribute($element, 'style:name'));
|
|
|
|
|
self::assertEquals('#008000', $doc->getElementAttribute("$element/style:text-properties", 'fo:color'));
|
2020-02-06 19:20:13 -08:00
|
|
|
$element = "$s2a/style:style[7]";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertEquals('T2', $doc->getElementAttribute($element, 'style:name'));
|
|
|
|
|
self::assertEquals('#000080', $doc->getElementAttribute("$element/style:text-properties", 'fo:color'));
|
2020-02-06 19:20:13 -08:00
|
|
|
|
|
|
|
|
$element = "$s2t/text:p[2]/text:span";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertEquals('namedstyle', $doc->getElementAttribute($element, 'text:style-name'));
|
|
|
|
|
self::assertTrue($doc->elementExists("$element/text:date"));
|
2020-02-06 19:20:13 -08:00
|
|
|
$element = "$s2t/text:p[3]/text:span";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertEquals('T1', $doc->getElementAttribute($element, 'text:style-name'));
|
|
|
|
|
self::assertTrue($doc->elementExists("$element/text:date"));
|
2020-02-06 19:20:13 -08:00
|
|
|
$element = "$s2t/text:p[4]/text:span";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertEquals('T2', $doc->getElementAttribute($element, 'text:style-name'));
|
|
|
|
|
self::assertTrue($doc->elementExists("$element/text:date"));
|
2020-02-06 23:34:24 -08:00
|
|
|
$element = "$s2t/text:p[5]/text:span";
|
2022-09-16 11:45:45 +02:00
|
|
|
self::assertEquals('namedstyle', $doc->getElementAttribute($element, 'text:style-name'));
|
2020-02-06 19:20:13 -08:00
|
|
|
}
|
ODT Changes
Implement a number of features implemented in PhpWord,
but not yet supported in PhpWord ODT Writer.
1. Add default file to tests/PhpWord/_includes/XmlDocument.php to make it
considerably easier to test ODT changes (and Word2007 changes involving
files other that document.xml).
2. Page break before each section.
3. Page numbering start.
4. Font style for Headings.
5. Alignment for images.
6. Paragraph style for TextRun.
7. "Hide grammatical errors" for whole document.
8. Page layout for each section.
9. For each page layout, support user-specified page width, page height,
orientation, margin top, margin bottom, margin left, margin right.
10. Page header and footer.
11. Named colors.
12. NoProof font style.
13. Paragraph Style - spaceBefore, spaceAfter, lineHeight, pageBreakBefore,
indentation, text alignment.
14. Tab stops.
15. Basic support for some Fields (DATE, PAGE, NUMPAGES).
16. Link had an error in how it was handling internal links (needs leading #).
17. In addition to tests for all the above, added some tests for Tables.
Item 11 above needs 1 module from Pull Request 1775, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Item 15 above needs 1 module from Pull Request 1774, which is targeted
for v0.18.0 but not yet merged, so the relevant module is also here.
Testing change from Pull Request 1771 is included here, but was
merged after my fork.
2020-01-05 10:27:45 -08:00
|
|
|
}
|