From f0ee25f3437fd8101d55c2afe8372ab62133fc99 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 2 Apr 2014 11:02:56 +0700 Subject: [PATCH] Deprecate `createSection` in favor of `addSection` --- CHANGELOG.md | 1 + README.md | 2 +- docs/containers.rst | 18 ++++----- docs/elements.rst | 24 +++++------ docs/general.rst | 4 +- samples/Sample_01_SimpleText.php | 2 +- samples/Sample_02_TabStops.php | 2 +- samples/Sample_03_Sections.php | 12 +++--- samples/Sample_04_Textrun.php | 4 +- samples/Sample_05_Multicolumn.php | 10 ++--- samples/Sample_06_Footnote.php | 8 ++-- samples/Sample_08_ParagraphPagination.php | 2 +- samples/Sample_09_Tables.php | 2 +- samples/Sample_10_EastAsianFontStyle.php | 2 +- samples/Sample_12_HeaderFooter.php | 12 +++--- samples/Sample_13_Images.php | 2 +- samples/Sample_14_ListItem.php | 2 +- samples/Sample_15_Link.php | 2 +- samples/Sample_16_Object.php | 2 +- samples/Sample_17_TitleTOC.php | 2 +- samples/Sample_18_Watermark.php | 4 +- samples/Sample_19_TextBreak.php | 2 +- samples/Sample_20_BGColor.php | 2 +- samples/Sample_21_TableRowRules.php | 2 +- samples/Sample_22_CheckBox.php | 2 +- src/PhpWord/PhpWord.php | 27 +++++++++---- src/PhpWord/Reader/Word2007.php | 4 +- tests/PhpWord/Tests/Container/FooterTest.php | 2 +- tests/PhpWord/Tests/Container/HeaderTest.php | 2 +- tests/PhpWord/Tests/Container/SectionTest.php | 4 +- .../PhpWord/Tests/Element/Table/CellTest.php | 2 +- tests/PhpWord/Tests/Element/TextRunTest.php | 2 +- tests/PhpWord/Tests/PhpWordTest.php | 4 +- tests/PhpWord/Tests/Style/FontTest.php | 2 +- tests/PhpWord/Tests/Style/ParagraphTest.php | 2 +- .../Tests/Writer/ODText/ContentTest.php | 4 +- tests/PhpWord/Tests/Writer/ODTextTest.php | 8 ++-- tests/PhpWord/Tests/Writer/RTFTest.php | 8 ++-- .../Tests/Writer/Word2007/BaseTest.php | 40 +++++++++---------- .../Tests/Writer/Word2007/DocumentTest.php | 8 ++-- .../Tests/Writer/Word2007/FooterTest.php | 2 +- .../Tests/Writer/Word2007/FootnotesTest.php | 6 +-- .../Tests/Writer/Word2007/HeaderTest.php | 2 +- tests/PhpWord/Tests/Writer/Word2007Test.php | 20 +++++----- 44 files changed, 145 insertions(+), 131 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84952a3c..28b6326b 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers - `createFootnote` replaced by `addFootnote` - `createHeader` replaced by `addHeader` - `createFooter` replaced by `addFooter` +- `createSection` replaced by `addSection` ### Miscellaneous diff --git a/README.md b/README.md index 8d5370eb..95d5947e 100755 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Every element you want to append to the word document is placed in a section. // To create a basic section: -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); // After creating a section, you can append elements: $section->addText('Hello world!'); diff --git a/docs/containers.rst b/docs/containers.rst index dc8f2f9a..53579537 100644 --- a/docs/containers.rst +++ b/docs/containers.rst @@ -16,7 +16,7 @@ section, use the following code: .. code-block:: php - $section = $phpWord->createSection($sectionSettings); + $section = $phpWord->addSection($sectionSettings); The ``$sectionSettings`` is an optional associative array that sets the section. Example: @@ -70,10 +70,10 @@ property of the section. .. code-block:: php // Method 1 - $section = $phpWord->createSection(array('pageNumberingStart' => 1)); + $section = $phpWord->addSection(array('pageNumberingStart' => 1)); // Method 2 - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->getSettings()->setPageNumberingStart(1); Multicolumn @@ -85,10 +85,10 @@ using the ``breakType`` and ``colsNum`` property of the section. .. code-block:: php // Method 1 - $section = $phpWord->createSection(array('breakType' => 'continuous', 'colsNum' => 2)); + $section = $phpWord->addSection(array('breakType' => 'continuous', 'colsNum' => 2)); // Method 2 - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->getSettings()->setBreakType('continuous'); $section->getSettings()->setColsNum(2); @@ -96,11 +96,11 @@ Headers ------- Each section can have its own header reference. To create a header use -the ``createHeader`` method: +the ``addHeader`` method: .. code-block:: php - $header = $section->createHeader(); + $header = $section->addHeader(); Be sure to save the result in a local object. You can use all elements that are available for the footer. See "Footer" section for detail. @@ -111,11 +111,11 @@ Footers ------- Each section can have its own footer reference. To create a footer, use -the ``createFooter`` method: +the ``addFooter`` method: .. code-block:: php - $footer = $section->createFooter(); + $footer = $section->addFooter(); Be sure to save the result in a local object to add elements to a footer. You can add the following elements to footers: diff --git a/docs/elements.rst b/docs/elements.rst index d1634bf4..da2038e5 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -51,9 +51,9 @@ Legend: Texts ----- -Text can be added by using ``addText`` and ``createTextRun`` method. +Text can be added by using ``addText`` and ``addTextRun`` method. ``addText`` is used for creating simple paragraphs that only contain -texts with the same style. ``createTextRun`` is used for creating +texts with the same style. ``addTextRun`` is used for creating complex paragraphs that contain text with different style (some bold, other italics, etc) or other elements, e.g. images or links. The syntaxes are as follow: @@ -61,7 +61,7 @@ syntaxes are as follow: .. code-block:: php $section->addText($text, [$fontStyle], [$paragraphStyle]); - $textrun = $section->createTextRun([$paragraphStyle]); + $textrun = $section->addTextRun([$paragraphStyle]); Text styles ~~~~~~~~~~~ @@ -79,7 +79,7 @@ Inline style examples: $paragraphStyle = array('align' => 'both'); $section->addText('I am simple paragraph', $fontStyle, $paragraphStyle); - $textrun = $section->createTextRun(); + $textrun = $section->addTextRun(); $textrun->addText('I am bold', array('bold' => true)); $textrun->addText('I am italic', array('italic' => true)); $textrun->addText('I am colored, array('color' => 'AACC00')); @@ -300,7 +300,7 @@ Examples: .. code-block:: php - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addImage( 'mars.jpg', array( @@ -311,9 +311,9 @@ Examples: 'wrappingStyle' => 'behind' ) ); - $footer = $section->createFooter(); + $footer = $section->addFooter(); $footer->addImage('http://example.com/image.php'); - $textrun = $section->createTextRun(); + $textrun = $section->addTextRun(); $textrun->addImage('http://php.net/logo.jpg'); Image styles @@ -338,8 +338,8 @@ header reference. After creating a header, you can use the .. code-block:: php - $section = $phpWord->createSection(); - $header = $section->createHeader(); + $section = $phpWord->addSection(); + $header = $section->addHeader(); $header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55)); Objects @@ -380,9 +380,9 @@ On textrun: .. code-block:: php - $textrun = $section->createTextRun(); + $textrun = $section->addTextRun(); $textrun->addText('Lead text.'); - $footnote = $textrun->createFootnote(); + $footnote = $textrun->addFootnote(); $footnote->addText('Footnote text can have '); $footnote->addLink('http://test.com', 'links'); $footnote->addText('.'); @@ -395,7 +395,7 @@ On text: .. code-block:: php $section->addText('Lead text.'); - $footnote = $section->createFootnote(); + $footnote = $section->addFootnote(); $footnote->addText('Footnote text.'); The footnote reference number will be displayed with decimal number starting diff --git a/docs/general.rst b/docs/general.rst index 1c810722..e1545a04 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -19,7 +19,7 @@ folder `__. // Every element you want to append to the word document is placed in a section. // To create a basic section: - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); // After creating a section, you can append elements: $section->addText('Hello world!'); @@ -136,7 +136,7 @@ points to twips. 'spaceAfter' => \PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6)) ); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $sectionStyle = $section->getSettings(); // half inch left margin $sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5)); diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index 7ada399a..4405eaeb 100755 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -9,7 +9,7 @@ $phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => $phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240)); // New portrait section -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); // Simple text $section->addTitle('Welcome to PhpWord', 1); diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php index f08f1e15..01dc7617 100755 --- a/samples/Sample_02_TabStops.php +++ b/samples/Sample_02_TabStops.php @@ -25,7 +25,7 @@ $phpWord->addParagraphStyle('centerTab', array( )); // New portrait section -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); // Add listitem elements $section->addText("Multiple Tabs:\tOne\tTwo\tThree", NULL, 'multipleTab'); diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php index c16b73db..7289fef0 100755 --- a/samples/Sample_03_Sections.php +++ b/samples/Sample_03_Sections.php @@ -6,24 +6,24 @@ echo date('H:i:s') , ' Create new PhpWord object' , \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // New portrait section -$section = $phpWord->createSection(array('borderColor' => '00FF00', 'borderSize' => 12)); +$section = $phpWord->addSection(array('borderColor' => '00FF00', 'borderSize' => 12)); $section->addText('I am placed on a default section.'); // New landscape section -$section = $phpWord->createSection(array('orientation' => 'landscape')); +$section = $phpWord->addSection(array('orientation' => 'landscape')); $section->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.'); $section->addPageBreak(); $section->addPageBreak(); // New portrait section -$section = $phpWord->createSection(array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)); +$section = $phpWord->addSection(array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)); $section->addText('This section uses other margins.'); // New portrait section with Header & Footer -$section = $phpWord->createSection(array('marginLeft' => 200, 'marginRight' => 200, 'marginTop' => 200, 'marginBottom' => 200, 'headerHeight' => 50, 'footerHeight' => 50,)); +$section = $phpWord->addSection(array('marginLeft' => 200, 'marginRight' => 200, 'marginTop' => 200, 'marginBottom' => 200, 'headerHeight' => 50, 'footerHeight' => 50,)); $section->addText('This section and we play with header/footer height.'); -$section->createHeader()->addText('Header'); -$section->createFooter()->addText('Footer'); +$section->addHeader()->addText('Header'); +$section->addFooter()->addText('Footer'); // Save file $name = basename(__FILE__, '.php'); diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php index d95297b8..6c13a84f 100644 --- a/samples/Sample_04_Textrun.php +++ b/samples/Sample_04_Textrun.php @@ -12,10 +12,10 @@ $phpWord->addFontStyle('ColoredText', array('color'=>'FF8080')); $phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); // New portrait section -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); // Add text run -$textrun = $section->createTextRun('pStyle'); +$textrun = $section->addTextRun('pStyle'); $textrun->addText('Each textrun can contain native text, link elements or an image.'); $textrun->addText(' No break is placed after adding an element.', 'BoldText'); diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php index 541e2e8a..4d81766e 100644 --- a/samples/Sample_05_Multicolumn.php +++ b/samples/Sample_05_Multicolumn.php @@ -10,29 +10,29 @@ $filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' . 'Suspendisse congue congue leo sed pellentesque.'; // Normal -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); $section->addText('Normal paragraph. ' . $filler); // Two columns -$section = $phpWord->createSection(array( +$section = $phpWord->addSection(array( 'colsNum' => 2, 'colsSpace' => 1440, 'breakType' => 'continuous')); $section->addText('Three columns, one inch (1440 twips) spacing. ' . $filler); // Normal -$section = $phpWord->createSection(array('breakType' => 'continuous')); +$section = $phpWord->addSection(array('breakType' => 'continuous')); $section->addText('Normal paragraph again. ' . $filler); // Three columns -$section = $phpWord->createSection(array( +$section = $phpWord->addSection(array( 'colsNum' => 3, 'colsSpace' => 720, 'breakType' => 'continuous')); $section->addText('Three columns, half inch (720 twips) spacing. ' . $filler); // Normal -$section = $phpWord->createSection(array('breakType' => 'continuous')); +$section = $phpWord->addSection(array('breakType' => 'continuous')); $section->addText('Normal paragraph again.'); // Save file diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php index 57421eff..270573d9 100755 --- a/samples/Sample_06_Footnote.php +++ b/samples/Sample_06_Footnote.php @@ -7,7 +7,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord(); \PhpOffice\PhpWord\Settings::setCompatibility(false); // New portrait section -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); // Add style definitions $phpWord->addParagraphStyle('pStyle', array('spacing'=>100)); @@ -16,10 +16,10 @@ $phpWord->addFontStyle('ColoredText', array('color'=>'FF8080')); $phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); // Add text elements -$textrun = $section->createTextRun('pStyle'); +$textrun = $section->addTextRun('pStyle'); $textrun->addText('This is some lead text in a paragraph with a following footnote. ','pStyle'); -$footnote = $textrun->createFootnote(); +$footnote = $textrun->addFootnote(); $footnote->addText('Just like a textrun, a footnote can contain native texts. '); $footnote->addText('No break is placed after adding an element. ', 'BoldText'); $footnote->addText('All elements are placed inside a paragraph. ', 'ColoredText'); @@ -34,7 +34,7 @@ $footnote->addObject('resources/_sheet.xls'); $footnote->addText('But you can only put footnote in section, not in header or footer.'); $section->addText('You can also create the footnote directly from the section making it wrap in a paragraph like the footnote below this paragraph. But is is best used from within a textrun.'); -$footnote = $section->createFootnote(); +$footnote = $section->addFootnote(); $footnote->addText('The reference for this is wrapped in its own line'); // Save file diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php index eeef6058..4b184cfd 100644 --- a/samples/Sample_08_ParagraphPagination.php +++ b/samples/Sample_08_ParagraphPagination.php @@ -11,7 +11,7 @@ $phpWord->setDefaultParagraphStyle(array( )); // Sample -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); $section->addText('Below are the samples on how to control your paragraph ' . 'pagination. See "Line and Page Break" tab on paragraph properties ' . diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index 0c9fbeb5..d841092c 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -4,7 +4,7 @@ include_once 'Sample_Header.php'; // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); $header = array('size' => 16, 'bold' => true); // 1. Basic table diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php index 6e8b26a0..d4ea2c4a 100644 --- a/samples/Sample_10_EastAsianFontStyle.php +++ b/samples/Sample_10_EastAsianFontStyle.php @@ -4,7 +4,7 @@ include_once 'Sample_Header.php'; // New Word Document echo date('H:i:s') , ' Create new PhpWord object' , \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); $header = array('size' => 16, 'bold' => true); //1.Use EastAisa FontStyle $section->addText('中文楷体样式测试',array('name' => '楷体', 'size' => 16, 'color' => '1B2232')); diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php index 19139ab2..a30358f2 100644 --- a/samples/Sample_12_HeaderFooter.php +++ b/samples/Sample_12_HeaderFooter.php @@ -6,10 +6,10 @@ echo date('H:i:s') , " Create new PhpWord object" , \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // New portrait section -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); // Add first page header -$header = $section->createHeader(); +$header = $section->addHeader(); $header->firstPage(); $table = $header->addTable(); $table->addRow(); @@ -23,11 +23,11 @@ $table->addCell(4500)->addImage( ); // Add header for all other pages -$subsequent = $section->createHeader(); +$subsequent = $section->addHeader(); $subsequent->addText("Subsequent pages in Section 1 will Have this!"); // Add footer -$footer = $section->createFooter(); +$footer = $section->addFooter(); $footer->addPreserveText('Page {PAGE} of {NUMPAGES}.', array('align' => 'center')); $footer->addLink('http://google.com', 'Direct Google'); @@ -50,9 +50,9 @@ $section->addTextBreak(); $section->addText('Some text...'); // New portrait section -$section2 = $phpWord->createSection(); +$section2 = $phpWord->addSection(); -$sec2Header = $section2->createHeader(); +$sec2Header = $section2->addHeader(); $sec2Header->addText("All pages in Section 2 will Have this!"); // Write some text diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index cf467464..405f653b 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -6,7 +6,7 @@ echo date('H:i:s'), " Create new PhpWord object", \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); $section->addText('Local image without any styles:'); $section->addImage('resources/_mars.jpg'); $section->addTextBreak(2); diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php index 45cb73ab..a7dc48ff 100644 --- a/samples/Sample_14_ListItem.php +++ b/samples/Sample_14_ListItem.php @@ -6,7 +6,7 @@ echo date('H:i:s'), " Create new PhpWord object", \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); // Add listitem elements $section->addListItem('List Item 1', 0); diff --git a/samples/Sample_15_Link.php b/samples/Sample_15_Link.php index 06628de5..a2e4f9e1 100644 --- a/samples/Sample_15_Link.php +++ b/samples/Sample_15_Link.php @@ -6,7 +6,7 @@ echo date('H:i:s'), " Create new PhpWord object", \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); // Add hyperlink elements $section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); diff --git a/samples/Sample_16_Object.php b/samples/Sample_16_Object.php index 1a7f557a..ec2dbce4 100644 --- a/samples/Sample_16_Object.php +++ b/samples/Sample_16_Object.php @@ -6,7 +6,7 @@ echo date('H:i:s'), " Create new PhpWord object", \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); $section->addText('You can open this OLE object by double clicking on the icon:'); $section->addTextBreak(2); $section->addObject('resources/_sheet.xls'); diff --git a/samples/Sample_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php index 27982921..951632af 100644 --- a/samples/Sample_17_TitleTOC.php +++ b/samples/Sample_17_TitleTOC.php @@ -6,7 +6,7 @@ echo date('H:i:s'), " Create new PhpWord object", \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); // Define the TOC font style $fontStyle = array('spaceAfter'=>60, 'size'=>12); diff --git a/samples/Sample_18_Watermark.php b/samples/Sample_18_Watermark.php index ff299c97..96fe5c99 100644 --- a/samples/Sample_18_Watermark.php +++ b/samples/Sample_18_Watermark.php @@ -7,8 +7,8 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code -$section = $phpWord->createSection(); -$header = $section->createHeader(); +$section = $phpWord->addSection(); +$header = $section->addHeader(); $header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55)); $section->addText('The header reference to the current section includes a watermark image.'); diff --git a/samples/Sample_19_TextBreak.php b/samples/Sample_19_TextBreak.php index 9433222c..b594bebd 100644 --- a/samples/Sample_19_TextBreak.php +++ b/samples/Sample_19_TextBreak.php @@ -12,7 +12,7 @@ $phpWord->addFontStyle('fontStyle', array('size' => 9)); $phpWord->addParagraphStyle('paragraphStyle', array('spacing' => 480)); $fontStyle = array('size' => 24); -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); $section->addText('Text break with no style:'); $section->addTextBreak(); $section->addText('Text break with defined font style:'); diff --git a/samples/Sample_20_BGColor.php b/samples/Sample_20_BGColor.php index 46a232f7..ed6ec320 100644 --- a/samples/Sample_20_BGColor.php +++ b/samples/Sample_20_BGColor.php @@ -4,7 +4,7 @@ include_once 'Sample_Header.php'; // New Word document echo date('H:i:s'), " Create new PhpWord object", \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); $section->addText("This is some text highlighted using fgColor (limited to 15 colors) ", array("fgColor" => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $section->addText("This one uses bgColor and is using hex value (0xfbbb10)", array("bgColor" => "fbbb10")); diff --git a/samples/Sample_21_TableRowRules.php b/samples/Sample_21_TableRowRules.php index c02ac2ba..6f3575cd 100644 --- a/samples/Sample_21_TableRowRules.php +++ b/samples/Sample_21_TableRowRules.php @@ -4,7 +4,7 @@ include_once 'Sample_Header.php'; // New Word document echo date('H:i:s'), " Create new PhpWord object", \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); $section->addText("By default, when you insert an image, it adds a textbreak after its content."); $section->addText("If we want a simple border around an image, we wrap the image inside a table->row->cell"); diff --git a/samples/Sample_22_CheckBox.php b/samples/Sample_22_CheckBox.php index 505d3518..3c2b64e5 100644 --- a/samples/Sample_22_CheckBox.php +++ b/samples/Sample_22_CheckBox.php @@ -5,7 +5,7 @@ include_once 'Sample_Header.php'; echo date('H:i:s'), " Create new PhpWord object", \EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); -$section = $phpWord->createSection(); +$section = $phpWord->addSection(); $section->addText('Check box in section'); $section->addCheckBox('chkBox1', 'Checkbox 1'); $section->addText('Check box in table cell'); diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 894d7df7..89ee8d94 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -23,6 +23,7 @@ class PhpWord const DEFAULT_FONT_COLOR = '000000'; // HEX const DEFAULT_FONT_CONTENT_TYPE = 'default'; // default|eastAsia|cs const DEFAULT_FONT_NAME = 'Arial'; + /** * Default font size, in points. * @@ -34,7 +35,7 @@ class PhpWord /** * Document properties object * - * @var \PhpOffice\PhpWord\DocumentProperties + * @var DocumentProperties */ private $_documentProperties; @@ -54,7 +55,7 @@ class PhpWord /** * Collection of sections * - * @var \PhpOffice\PhpWord\Section[] + * @var Section[] */ private $_sections = array(); @@ -71,7 +72,7 @@ class PhpWord /** * Get document properties object * - * @return \PhpOffice\PhpWord\DocumentProperties + * @return DocumentProperties */ public function getDocumentProperties() { @@ -95,9 +96,9 @@ class PhpWord * Create new section * * @param \PhpOffice\PhpWord\Container\Settings $settings - * @return \PhpOffice\PhpWord\Container\Section + * @return Section */ - public function createSection($settings = null) + public function addSection($settings = null) { $section = new Section(\count($this->_sections) + 1, $settings); $this->_sections[] = $section; @@ -227,8 +228,8 @@ class PhpWord * Load template by filename * * @param string $filename Fully qualified filename. - * @return \PhpOffice\PhpWord\Template - * @throws \PhpOffice\PhpWord\Exception\Exception + * @return Template + * @throws Exception */ public function loadTemplate($filename) { @@ -238,4 +239,16 @@ class PhpWord throw new Exception("Template file {$filename} not found."); } } + + /** + * Create new section + * + * @param \PhpOffice\PhpWord\Container\Settings $settings + * @return Section + * @deprecated 0.9.2 + */ + public function createSection($settings = null) + { + return $this->addSection($settings); + } } diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php index 36ff79e3..be84d636 100644 --- a/src/PhpWord/Reader/Word2007.php +++ b/src/PhpWord/Reader/Word2007.php @@ -173,7 +173,7 @@ class Word2007 extends Reader implements IReader ); $xmlDoc = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}", true)); if (is_object($xmlDoc)) { - $section = $word->createSection(); + $section = $word->addSection(); foreach ($xmlDoc->body->children() as $elm) { $elmName = $elm->getName(); @@ -181,7 +181,7 @@ class Word2007 extends Reader implements IReader // Create new section if section setting found if ($elm->pPr->sectPr) { $section->setSettings($this->loadSectionSettings($elm->pPr)); - $section = $word->createSection(); + $section = $word->addSection(); continue; } // Has w:r? It's either text or textrun diff --git a/tests/PhpWord/Tests/Container/FooterTest.php b/tests/PhpWord/Tests/Container/FooterTest.php index 74a09a51..ba712903 100644 --- a/tests/PhpWord/Tests/Container/FooterTest.php +++ b/tests/PhpWord/Tests/Container/FooterTest.php @@ -73,7 +73,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase public function testCreateTextRun() { $oFooter = new Footer(1); - $element = $oFooter->createTextRun(); + $element = $oFooter->addTextRun(); $this->assertCount(1, $oFooter->getElements()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\TextRun', $element); diff --git a/tests/PhpWord/Tests/Container/HeaderTest.php b/tests/PhpWord/Tests/Container/HeaderTest.php index 9d479ade..dab67048 100644 --- a/tests/PhpWord/Tests/Container/HeaderTest.php +++ b/tests/PhpWord/Tests/Container/HeaderTest.php @@ -84,7 +84,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase public function testCreateTextRun() { $oHeader = new Header(1); - $element = $oHeader->createTextRun(); + $element = $oHeader->addTextRun(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\TextRun', $element); $this->assertCount(1, $oHeader->getElements()); } diff --git a/tests/PhpWord/Tests/Container/SectionTest.php b/tests/PhpWord/Tests/Container/SectionTest.php index 0517399c..a289df49 100644 --- a/tests/PhpWord/Tests/Container/SectionTest.php +++ b/tests/PhpWord/Tests/Container/SectionTest.php @@ -86,8 +86,8 @@ class SectionTest extends \PHPUnit_Framework_TestCase $section->addImage($imageSource); $section->addMemoryImage($imageUrl); $section->addTitle(utf8_decode('ä'), 1); - $section->createTextRun(); - $section->createFootnote(); + $section->addTextRun(); + $section->addFootnote(); $section->addCheckBox(utf8_decode('chkä'), utf8_decode('Contentä')); $section->addTOC(); diff --git a/tests/PhpWord/Tests/Element/Table/CellTest.php b/tests/PhpWord/Tests/Element/Table/CellTest.php index d16f275a..bc0a8db1 100644 --- a/tests/PhpWord/Tests/Element/Table/CellTest.php +++ b/tests/PhpWord/Tests/Element/Table/CellTest.php @@ -276,7 +276,7 @@ class CellTest extends \PHPUnit_Framework_TestCase public function testCreateTextRun() { $oCell = new Cell('section', 1); - $element = $oCell->createTextRun(); + $element = $oCell->addTextRun(); $this->assertCount(1, $oCell->getElements()); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\TextRun', $element); diff --git a/tests/PhpWord/Tests/Element/TextRunTest.php b/tests/PhpWord/Tests/Element/TextRunTest.php index e71ce108..6f277e82 100644 --- a/tests/PhpWord/Tests/Element/TextRunTest.php +++ b/tests/PhpWord/Tests/Element/TextRunTest.php @@ -138,7 +138,7 @@ class TextRunTest extends \PHPUnit_Framework_TestCase public function testCreateFootnote() { $oTextRun = new TextRun(); - $element = $oTextRun->createFootnote(); + $element = $oTextRun->addFootnote(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Footnote', $element); $this->assertCount(1, $oTextRun->getElements()); diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index 2cf5ae62..829ddfff 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -51,8 +51,8 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase public function testCreateGetSections() { $phpWord = new PhpWord(); - $this->assertEquals(new Section(1), $phpWord->createSection()); - $phpWord->createSection(); + $this->assertEquals(new Section(1), $phpWord->addSection()); + $phpWord->addSection(); $this->assertEquals(2, \count($phpWord->getSections())); } diff --git a/tests/PhpWord/Tests/Style/FontTest.php b/tests/PhpWord/Tests/Style/FontTest.php index 47ed57f4..d26b97fe 100644 --- a/tests/PhpWord/Tests/Style/FontTest.php +++ b/tests/PhpWord/Tests/Style/FontTest.php @@ -103,7 +103,7 @@ class FontTest extends \PHPUnit_Framework_TestCase public function testLineHeight() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); // Test style array $text = $section->addText('This is a test', array( diff --git a/tests/PhpWord/Tests/Style/ParagraphTest.php b/tests/PhpWord/Tests/Style/ParagraphTest.php index 4c424a93..10a74dae 100644 --- a/tests/PhpWord/Tests/Style/ParagraphTest.php +++ b/tests/PhpWord/Tests/Style/ParagraphTest.php @@ -105,7 +105,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase public function testLineHeight() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); // Test style array $text = $section->addText('This is a test', array(), array( diff --git a/tests/PhpWord/Tests/Writer/ODText/ContentTest.php b/tests/PhpWord/Tests/Writer/ODText/ContentTest.php index 377f07c2..4808de9e 100644 --- a/tests/PhpWord/Tests/Writer/ODText/ContentTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/ContentTest.php @@ -41,7 +41,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase $phpWord->setDefaultFontName('Verdana'); $phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addText($expected); $section->addText('Test font style', 'Font'); $section->addText('Test paragraph style', null, 'Paragraph'); @@ -54,7 +54,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase $section->addImage($imageSrc); $section->addObject($objectSrc); $section->addTOC(); - $textrun = $section->createTextRun(); + $textrun = $section->addTextRun(); $textrun->addText('Test text run'); $doc = TestHelperDOCX::getDocument($phpWord, 'ODText'); diff --git a/tests/PhpWord/Tests/Writer/ODTextTest.php b/tests/PhpWord/Tests/Writer/ODTextTest.php index 82263c0f..743907be 100644 --- a/tests/PhpWord/Tests/Writer/ODTextTest.php +++ b/tests/PhpWord/Tests/Writer/ODTextTest.php @@ -64,7 +64,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addText('Test 1', 'Font'); $section->addTextBreak(); $section->addText('Test 2', null, 'Paragraph'); @@ -76,8 +76,8 @@ class ODTextTest extends \PHPUnit_Framework_TestCase $section->addImage($imageSrc); $section->addObject($objectSrc); $section->addTOC(); - $section = $phpWord->createSection(); - $textrun = $section->createTextRun(); + $section = $phpWord->addSection(); + $textrun = $section->addTextRun(); $textrun->addText('Test 3'); $writer = new ODText($phpWord); $writer->save($file); @@ -95,7 +95,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase public function testSavePhpOutput() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addText('Test'); $writer = new ODText($phpWord); $writer->save('php://output'); diff --git a/tests/PhpWord/Tests/Writer/RTFTest.php b/tests/PhpWord/Tests/Writer/RTFTest.php index 4872ef39..1abeeefa 100644 --- a/tests/PhpWord/Tests/Writer/RTFTest.php +++ b/tests/PhpWord/Tests/Writer/RTFTest.php @@ -52,7 +52,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000')); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addText('Test 1', 'Font', 'Paragraph'); $section->addTextBreak(); $section->addText('Test 2', array('name' => 'Tahoma', 'bold' => true, 'italic' => true)); @@ -64,8 +64,8 @@ class RTFTest extends \PHPUnit_Framework_TestCase $section->addImage($imageSrc); $section->addObject($objectSrc); $section->addTOC(); - $section = $phpWord->createSection(); - $textrun = $section->createTextRun(); + $section = $phpWord->addSection(); + $textrun = $section->addTextRun(); $textrun->addText('Test 3'); $textrun->addTextBreak(); $writer = new RTF($phpWord); @@ -84,7 +84,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase public function testSavePhpOutput() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addText('Test'); $writer = new RTF($phpWord); $writer->save('php://output'); diff --git a/tests/PhpWord/Tests/Writer/Word2007/BaseTest.php b/tests/PhpWord/Tests/Writer/Word2007/BaseTest.php index 18524f58..d9d1b3c5 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/BaseTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/BaseTest.php @@ -38,7 +38,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $phpWord->addFontStyle($rStyle, array('bold' => true)); $phpWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120)); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addText('Test', $rStyle, $pStyle); $doc = TestHelperDOCX::getDocument($phpWord); @@ -59,14 +59,14 @@ class BaseTest extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $phpWord->addParagraphStyle($pStyle, $aStyle); - $section = $phpWord->createSection('Test'); - $textrun = $section->createTextRun($pStyle); + $section = $phpWord->addSection('Test'); + $textrun = $section->addTextRun($pStyle); $textrun->addText('Test'); $textrun->addTextBreak(); - $textrun = $section->createTextRun($aStyle); + $textrun = $section->addTextRun($aStyle); $textrun->addLink('http://test.com'); $textrun->addImage($imageSrc, array('align' => 'top')); - $textrun->createFootnote(); + $textrun->addFootnote(); $doc = TestHelperDOCX::getDocument($phpWord); $parent = "/w:document/w:body/w:p"; @@ -79,7 +79,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase public function testWriteLink() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $fontStyleArray = array('bold' => true); $fontStyleName = 'Font Style'; $paragraphStyleArray = array('align' => 'center'); @@ -102,8 +102,8 @@ class BaseTest extends \PHPUnit_Framework_TestCase public function testWritePreserveText() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); - $footer = $section->createFooter(); + $section = $phpWord->addSection(); + $footer = $section->addFooter(); $fontStyleArray = array('bold' => true); $fontStyleName = 'Font'; $paragraphStyleArray = array('align' => 'right'); @@ -133,7 +133,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $phpWord->addFontStyle($fName, $fArray); $phpWord->addParagraphStyle($pName, $pArray); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addTextBreak(); $section->addTextBreak(1, $fArray, $pArray); $section->addTextBreak(1, $fName, $pName); @@ -151,7 +151,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase public function testWriteParagraphStyleAlign() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addText('This is my text', null, array('align' => 'right')); @@ -168,7 +168,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase { // Create the doc $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $attributes = array( 'widowControl' => false, 'keepNext' => true, @@ -209,7 +209,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase $styles['bgColor'] = 'FFFF00'; $styles['hint'] = 'eastAsia'; - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addText('Test', $styles); $doc = TestHelperDOCX::getDocument($phpWord); @@ -257,7 +257,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase $cStyles["borderRightColor"] = 'FF0000'; $cStyles["vMerge"] = 'restart'; - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $table = $section->addTable($tStyles); $table->setWidth = 100; $table->addRow($rHeight, $rStyles); @@ -268,7 +268,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase $cell->addListItem('Test'); $cell->addImage($imageSrc); $cell->addObject($objectSrc); - $textrun = $cell->createTextRun(); + $textrun = $cell->addTextRun(); $textrun->addText('Test'); $doc = TestHelperDOCX::getDocument($phpWord); @@ -296,7 +296,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase public function testWriteCellStyleCellGridSpan() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $table = $section->addTable(); @@ -323,7 +323,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase public function testWriteImagePosition() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addImage( __DIR__ . "/../../_files/images/earth.jpg", array( @@ -350,8 +350,8 @@ class BaseTest extends \PHPUnit_Framework_TestCase $imageSrc = __DIR__ . "/../../_files/images/earth.jpg"; $phpWord = new PhpWord(); - $section = $phpWord->createSection(); - $header = $section->createHeader(); + $section = $phpWord->addSection(); + $header = $section->addHeader(); $header->addWatermark($imageSrc); $doc = TestHelperDOCX::getDocument($phpWord); @@ -366,7 +366,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase { $phpWord = new PhpWord(); $phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240)); - $phpWord->createSection()->addTitle('Test', 1); + $phpWord->addSection()->addTitle('Test', 1); $doc = TestHelperDOCX::getDocument($phpWord); $element = "/w:document/w:body/w:p/w:pPr/w:pStyle"; @@ -386,7 +386,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $phpWord->addFontStyle($rStyle, array('bold' => true)); $phpWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120)); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addCheckbox('Check1', 'Test', $rStyle, $pStyle); $doc = TestHelperDOCX::getDocument($phpWord); diff --git a/tests/PhpWord/Tests/Writer/Word2007/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/DocumentTest.php index 5318ac81..8cceecb3 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/DocumentTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/DocumentTest.php @@ -33,7 +33,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase public function testWriteEndSectionPageNumbering() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $settings = $section->getSettings(); $settings->setLandscape(); $settings->setPageNumberingStart(2); @@ -56,14 +56,14 @@ class DocumentTest extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $phpWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true)); $phpWord->addTitleStyle(2, array('color'=>'666666')); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addTOC(); $section->addPageBreak(); $section->addTitle('Title 1', 1); $section->addListItem('List Item 1', 0); $section->addListItem('List Item 2', 0); $section->addListItem('List Item 3', 0); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addTitle('Title 2', 2); $section->addObject($objectSrc); $doc = TestHelperDOCX::getDocument($phpWord); @@ -103,7 +103,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase $phpWord->addFontStyle('fStyle', array('size' => '20')); $phpWord->addTitleStyle(1, array('color' => '333333', 'bold' => true)); $fontStyle = new Font('text', array('align' => 'center')); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addListItem('List Item', 0, null, null, 'pStyle'); $section->addObject($objectSrc, array('align' => 'center')); $section->addTOC($fontStyle); diff --git a/tests/PhpWord/Tests/Writer/Word2007/FooterTest.php b/tests/PhpWord/Tests/Writer/Word2007/FooterTest.php index c0f94de6..04e86832 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/FooterTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/FooterTest.php @@ -32,7 +32,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase $container->addText(''); $container->addPreserveText(''); $container->addTextBreak(); - $container->createTextRun(); + $container->addTextRun(); $container->addTable()->addRow()->addCell()->addText(''); $container->addImage($imageSrc); diff --git a/tests/PhpWord/Tests/Writer/Word2007/FootnotesTest.php b/tests/PhpWord/Tests/Writer/Word2007/FootnotesTest.php index 6baba0ac..11817962 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/FootnotesTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/FootnotesTest.php @@ -34,13 +34,13 @@ class FootnotesTest extends \PHPUnit_Framework_TestCase { $phpWord = new PhpWord(); $phpWord->addParagraphStyle('pStyle', array('align' => 'left')); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addText('Text'); - $footnote1 = $section->createFootnote('pStyle'); + $footnote1 = $section->addFootnote('pStyle'); $footnote1->addText('Footnote'); $footnote1->addTextBreak(); $footnote1->addLink('http://google.com'); - $footnote2 = $section->createFootnote(array('align' => 'left')); + $footnote2 = $section->addFootnote(array('align' => 'left')); $footnote2->addText('Footnote'); $doc = TestHelperDOCX::getDocument($phpWord); diff --git a/tests/PhpWord/Tests/Writer/Word2007/HeaderTest.php b/tests/PhpWord/Tests/Writer/Word2007/HeaderTest.php index 253f663e..c468d7a7 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/HeaderTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/HeaderTest.php @@ -30,7 +30,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase $container->addText('Test'); $container->addPreserveText(''); $container->addTextBreak(); - $container->createTextRun(); + $container->addTextRun(); $container->addTable()->addRow()->addCell()->addText(''); $container->addImage($imageSrc); $container->addWatermark($imageSrc); diff --git a/tests/PhpWord/Tests/Writer/Word2007Test.php b/tests/PhpWord/Tests/Writer/Word2007Test.php index f486d18d..7b722a9c 100644 --- a/tests/PhpWord/Tests/Writer/Word2007Test.php +++ b/tests/PhpWord/Tests/Writer/Word2007Test.php @@ -68,18 +68,18 @@ class Word2007Test extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addText('Test 1', 'Font', 'Paragraph'); $section->addTextBreak(); $section->addText('Test 2'); - $section = $phpWord->createSection(); - $textrun = $section->createTextRun(); + $section = $phpWord->addSection(); + $textrun = $section->addTextRun(); $textrun->addText('Test 3'); - $footnote = $textrun->createFootnote(); + $footnote = $textrun->addFootnote(); $footnote->addLink('http://test.com'); - $header = $section->createHeader(); + $header = $section->addHeader(); $header->addImage($localImage); - $footer = $section->createFooter(); + $footer = $section->addFooter(); $footer->addImage($remoteImage); $writer = new Word2007($phpWord); @@ -97,9 +97,9 @@ class Word2007Test extends \PHPUnit_Framework_TestCase public function testSaveUseDiskCaching() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $section->addText('Test'); - $footnote = $section->createFootnote(); + $footnote = $section->addFootnote(); $footnote->addText('Test'); $writer = new Word2007($phpWord); @@ -138,7 +138,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase 'angela_merkel.tif' => '6.tif', ); $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); foreach ($images as $source => $target) { $section->addImage(__DIR__ . "/../_files/images/{$source}"); } @@ -169,7 +169,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase public function testSetGetUseDiskCaching() { $phpWord = new PhpWord(); - $section = $phpWord->createSection(); + $section = $phpWord->addSection(); $object = new Word2007($phpWord); $object->setUseDiskCaching(true, \PHPWORD_TESTS_BASE_DIR); $writer = new Word2007($phpWord);