Deprecate `createSection` in favor of `addSection`

This commit is contained in:
Ivan Lanin 2014-04-02 11:02:56 +07:00
parent a2a00393c1
commit f0ee25f343
44 changed files with 145 additions and 131 deletions

View File

@ -31,6 +31,7 @@ This is the changelog between releases of PHPWord. Releases are listed in revers
- `createFootnote` replaced by `addFootnote` - `createFootnote` replaced by `addFootnote`
- `createHeader` replaced by `addHeader` - `createHeader` replaced by `addHeader`
- `createFooter` replaced by `addFooter` - `createFooter` replaced by `addFooter`
- `createSection` replaced by `addSection`
### Miscellaneous ### Miscellaneous

View File

@ -71,7 +71,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Every element you want to append to the word document is placed in a section. // Every element you want to append to the word document is placed in a section.
// To create a basic section: // To create a basic section:
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// After creating a section, you can append elements: // After creating a section, you can append elements:
$section->addText('Hello world!'); $section->addText('Hello world!');

View File

@ -16,7 +16,7 @@ section, use the following code:
.. code-block:: php .. code-block:: php
$section = $phpWord->createSection($sectionSettings); $section = $phpWord->addSection($sectionSettings);
The ``$sectionSettings`` is an optional associative array that sets the The ``$sectionSettings`` is an optional associative array that sets the
section. Example: section. Example:
@ -70,10 +70,10 @@ property of the section.
.. code-block:: php .. code-block:: php
// Method 1 // Method 1
$section = $phpWord->createSection(array('pageNumberingStart' => 1)); $section = $phpWord->addSection(array('pageNumberingStart' => 1));
// Method 2 // Method 2
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->getSettings()->setPageNumberingStart(1); $section->getSettings()->setPageNumberingStart(1);
Multicolumn Multicolumn
@ -85,10 +85,10 @@ using the ``breakType`` and ``colsNum`` property of the section.
.. code-block:: php .. code-block:: php
// Method 1 // Method 1
$section = $phpWord->createSection(array('breakType' => 'continuous', 'colsNum' => 2)); $section = $phpWord->addSection(array('breakType' => 'continuous', 'colsNum' => 2));
// Method 2 // Method 2
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->getSettings()->setBreakType('continuous'); $section->getSettings()->setBreakType('continuous');
$section->getSettings()->setColsNum(2); $section->getSettings()->setColsNum(2);
@ -96,11 +96,11 @@ Headers
------- -------
Each section can have its own header reference. To create a header use Each section can have its own header reference. To create a header use
the ``createHeader`` method: the ``addHeader`` method:
.. code-block:: php .. code-block:: php
$header = $section->createHeader(); $header = $section->addHeader();
Be sure to save the result in a local object. You can use all elements 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. 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 Each section can have its own footer reference. To create a footer, use
the ``createFooter`` method: the ``addFooter`` method:
.. code-block:: php .. code-block:: php
$footer = $section->createFooter(); $footer = $section->addFooter();
Be sure to save the result in a local object to add elements to a Be sure to save the result in a local object to add elements to a
footer. You can add the following elements to footers: footer. You can add the following elements to footers:

View File

@ -51,9 +51,9 @@ Legend:
Texts 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 ``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, complex paragraphs that contain text with different style (some bold,
other italics, etc) or other elements, e.g. images or links. The other italics, etc) or other elements, e.g. images or links. The
syntaxes are as follow: syntaxes are as follow:
@ -61,7 +61,7 @@ syntaxes are as follow:
.. code-block:: php .. code-block:: php
$section->addText($text, [$fontStyle], [$paragraphStyle]); $section->addText($text, [$fontStyle], [$paragraphStyle]);
$textrun = $section->createTextRun([$paragraphStyle]); $textrun = $section->addTextRun([$paragraphStyle]);
Text styles Text styles
~~~~~~~~~~~ ~~~~~~~~~~~
@ -79,7 +79,7 @@ Inline style examples:
$paragraphStyle = array('align' => 'both'); $paragraphStyle = array('align' => 'both');
$section->addText('I am simple paragraph', $fontStyle, $paragraphStyle); $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 bold', array('bold' => true));
$textrun->addText('I am italic', array('italic' => true)); $textrun->addText('I am italic', array('italic' => true));
$textrun->addText('I am colored, array('color' => 'AACC00')); $textrun->addText('I am colored, array('color' => 'AACC00'));
@ -300,7 +300,7 @@ Examples:
.. code-block:: php .. code-block:: php
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addImage( $section->addImage(
'mars.jpg', 'mars.jpg',
array( array(
@ -311,9 +311,9 @@ Examples:
'wrappingStyle' => 'behind' 'wrappingStyle' => 'behind'
) )
); );
$footer = $section->createFooter(); $footer = $section->addFooter();
$footer->addImage('http://example.com/image.php'); $footer->addImage('http://example.com/image.php');
$textrun = $section->createTextRun(); $textrun = $section->addTextRun();
$textrun->addImage('http://php.net/logo.jpg'); $textrun->addImage('http://php.net/logo.jpg');
Image styles Image styles
@ -338,8 +338,8 @@ header reference. After creating a header, you can use the
.. code-block:: php .. code-block:: php
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$header = $section->createHeader(); $header = $section->addHeader();
$header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55)); $header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55));
Objects Objects
@ -380,9 +380,9 @@ On textrun:
.. code-block:: php .. code-block:: php
$textrun = $section->createTextRun(); $textrun = $section->addTextRun();
$textrun->addText('Lead text.'); $textrun->addText('Lead text.');
$footnote = $textrun->createFootnote(); $footnote = $textrun->addFootnote();
$footnote->addText('Footnote text can have '); $footnote->addText('Footnote text can have ');
$footnote->addLink('http://test.com', 'links'); $footnote->addLink('http://test.com', 'links');
$footnote->addText('.'); $footnote->addText('.');
@ -395,7 +395,7 @@ On text:
.. code-block:: php .. code-block:: php
$section->addText('Lead text.'); $section->addText('Lead text.');
$footnote = $section->createFootnote(); $footnote = $section->addFootnote();
$footnote->addText('Footnote text.'); $footnote->addText('Footnote text.');
The footnote reference number will be displayed with decimal number starting The footnote reference number will be displayed with decimal number starting

View File

@ -19,7 +19,7 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
// Every element you want to append to the word document is placed in a section. // Every element you want to append to the word document is placed in a section.
// To create a basic section: // To create a basic section:
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// After creating a section, you can append elements: // After creating a section, you can append elements:
$section->addText('Hello world!'); $section->addText('Hello world!');
@ -136,7 +136,7 @@ points to twips.
'spaceAfter' => \PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6)) 'spaceAfter' => \PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6))
); );
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$sectionStyle = $section->getSettings(); $sectionStyle = $section->getSettings();
// half inch left margin // half inch left margin
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5)); $sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5));

View File

@ -9,7 +9,7 @@ $phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' =>
$phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240)); $phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
// New portrait section // New portrait section
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// Simple text // Simple text
$section->addTitle('Welcome to PhpWord', 1); $section->addTitle('Welcome to PhpWord', 1);

View File

@ -25,7 +25,7 @@ $phpWord->addParagraphStyle('centerTab', array(
)); ));
// New portrait section // New portrait section
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// Add listitem elements // Add listitem elements
$section->addText("Multiple Tabs:\tOne\tTwo\tThree", NULL, 'multipleTab'); $section->addText("Multiple Tabs:\tOne\tTwo\tThree", NULL, 'multipleTab');

View File

@ -6,24 +6,24 @@ echo date('H:i:s') , ' Create new PhpWord object' , \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
// New portrait section // 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.'); $section->addText('I am placed on a default section.');
// New landscape 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->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.');
$section->addPageBreak(); $section->addPageBreak();
$section->addPageBreak(); $section->addPageBreak();
// New portrait section // 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.'); $section->addText('This section uses other margins.');
// New portrait section with Header & Footer // 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->addText('This section and we play with header/footer height.');
$section->createHeader()->addText('Header'); $section->addHeader()->addText('Header');
$section->createFooter()->addText('Footer'); $section->addFooter()->addText('Footer');
// Save file // Save file
$name = basename(__FILE__, '.php'); $name = basename(__FILE__, '.php');

View File

@ -12,10 +12,10 @@ $phpWord->addFontStyle('ColoredText', array('color'=>'FF8080'));
$phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); $phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
// New portrait section // New portrait section
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// Add text run // 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('Each textrun can contain native text, link elements or an image.');
$textrun->addText(' No break is placed after adding an element.', 'BoldText'); $textrun->addText(' No break is placed after adding an element.', 'BoldText');

View File

@ -10,29 +10,29 @@ $filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' .
'Suspendisse congue congue leo sed pellentesque.'; 'Suspendisse congue congue leo sed pellentesque.';
// Normal // Normal
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Normal paragraph. ' . $filler); $section->addText('Normal paragraph. ' . $filler);
// Two columns // Two columns
$section = $phpWord->createSection(array( $section = $phpWord->addSection(array(
'colsNum' => 2, 'colsNum' => 2,
'colsSpace' => 1440, 'colsSpace' => 1440,
'breakType' => 'continuous')); 'breakType' => 'continuous'));
$section->addText('Three columns, one inch (1440 twips) spacing. ' . $filler); $section->addText('Three columns, one inch (1440 twips) spacing. ' . $filler);
// Normal // Normal
$section = $phpWord->createSection(array('breakType' => 'continuous')); $section = $phpWord->addSection(array('breakType' => 'continuous'));
$section->addText('Normal paragraph again. ' . $filler); $section->addText('Normal paragraph again. ' . $filler);
// Three columns // Three columns
$section = $phpWord->createSection(array( $section = $phpWord->addSection(array(
'colsNum' => 3, 'colsNum' => 3,
'colsSpace' => 720, 'colsSpace' => 720,
'breakType' => 'continuous')); 'breakType' => 'continuous'));
$section->addText('Three columns, half inch (720 twips) spacing. ' . $filler); $section->addText('Three columns, half inch (720 twips) spacing. ' . $filler);
// Normal // Normal
$section = $phpWord->createSection(array('breakType' => 'continuous')); $section = $phpWord->addSection(array('breakType' => 'continuous'));
$section->addText('Normal paragraph again.'); $section->addText('Normal paragraph again.');
// Save file // Save file

View File

@ -7,7 +7,7 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
\PhpOffice\PhpWord\Settings::setCompatibility(false); \PhpOffice\PhpWord\Settings::setCompatibility(false);
// New portrait section // New portrait section
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// Add style definitions // Add style definitions
$phpWord->addParagraphStyle('pStyle', array('spacing'=>100)); $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)); $phpWord->addLinkStyle('NLink', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));
// Add text elements // 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'); $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('Just like a textrun, a footnote can contain native texts. ');
$footnote->addText('No break is placed after adding an element. ', 'BoldText'); $footnote->addText('No break is placed after adding an element. ', 'BoldText');
$footnote->addText('All elements are placed inside a paragraph. ', 'ColoredText'); $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.'); $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.'); $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'); $footnote->addText('The reference for this is wrapped in its own line');
// Save file // Save file

View File

@ -11,7 +11,7 @@ $phpWord->setDefaultParagraphStyle(array(
)); ));
// Sample // Sample
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Below are the samples on how to control your paragraph ' . $section->addText('Below are the samples on how to control your paragraph ' .
'pagination. See "Line and Page Break" tab on paragraph properties ' . 'pagination. See "Line and Page Break" tab on paragraph properties ' .

View File

@ -4,7 +4,7 @@ include_once 'Sample_Header.php';
// New Word Document // New Word Document
echo date('H:i:s') , ' Create new PhpWord object' , \EOL; echo date('H:i:s') , ' Create new PhpWord object' , \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$header = array('size' => 16, 'bold' => true); $header = array('size' => 16, 'bold' => true);
// 1. Basic table // 1. Basic table

View File

@ -4,7 +4,7 @@ include_once 'Sample_Header.php';
// New Word Document // New Word Document
echo date('H:i:s') , ' Create new PhpWord object' , \EOL; echo date('H:i:s') , ' Create new PhpWord object' , \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$header = array('size' => 16, 'bold' => true); $header = array('size' => 16, 'bold' => true);
//1.Use EastAisa FontStyle //1.Use EastAisa FontStyle
$section->addText('中文楷体样式测试',array('name' => '楷体', 'size' => 16, 'color' => '1B2232')); $section->addText('中文楷体样式测试',array('name' => '楷体', 'size' => 16, 'color' => '1B2232'));

View File

@ -6,10 +6,10 @@ echo date('H:i:s') , " Create new PhpWord object" , \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
// New portrait section // New portrait section
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// Add first page header // Add first page header
$header = $section->createHeader(); $header = $section->addHeader();
$header->firstPage(); $header->firstPage();
$table = $header->addTable(); $table = $header->addTable();
$table->addRow(); $table->addRow();
@ -23,11 +23,11 @@ $table->addCell(4500)->addImage(
); );
// Add header for all other pages // Add header for all other pages
$subsequent = $section->createHeader(); $subsequent = $section->addHeader();
$subsequent->addText("Subsequent pages in Section 1 will Have this!"); $subsequent->addText("Subsequent pages in Section 1 will Have this!");
// Add footer // Add footer
$footer = $section->createFooter(); $footer = $section->addFooter();
$footer->addPreserveText('Page {PAGE} of {NUMPAGES}.', array('align' => 'center')); $footer->addPreserveText('Page {PAGE} of {NUMPAGES}.', array('align' => 'center'));
$footer->addLink('http://google.com', 'Direct Google'); $footer->addLink('http://google.com', 'Direct Google');
@ -50,9 +50,9 @@ $section->addTextBreak();
$section->addText('Some text...'); $section->addText('Some text...');
// New portrait section // 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!"); $sec2Header->addText("All pages in Section 2 will Have this!");
// Write some text // Write some text

View File

@ -6,7 +6,7 @@ echo date('H:i:s'), " Create new PhpWord object", \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Begin code // Begin code
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Local image without any styles:'); $section->addText('Local image without any styles:');
$section->addImage('resources/_mars.jpg'); $section->addImage('resources/_mars.jpg');
$section->addTextBreak(2); $section->addTextBreak(2);

View File

@ -6,7 +6,7 @@ echo date('H:i:s'), " Create new PhpWord object", \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Begin code // Begin code
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// Add listitem elements // Add listitem elements
$section->addListItem('List Item 1', 0); $section->addListItem('List Item 1', 0);

View File

@ -6,7 +6,7 @@ echo date('H:i:s'), " Create new PhpWord object", \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Begin code // Begin code
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// Add hyperlink elements // Add hyperlink elements
$section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE)); $section->addLink('http://www.google.com', 'Best search engine', array('color'=>'0000FF', 'underline' => \PhpOffice\PhpWord\Style\Font::UNDERLINE_SINGLE));

View File

@ -6,7 +6,7 @@ echo date('H:i:s'), " Create new PhpWord object", \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Begin code // Begin code
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('You can open this OLE object by double clicking on the icon:'); $section->addText('You can open this OLE object by double clicking on the icon:');
$section->addTextBreak(2); $section->addTextBreak(2);
$section->addObject('resources/_sheet.xls'); $section->addObject('resources/_sheet.xls');

View File

@ -6,7 +6,7 @@ echo date('H:i:s'), " Create new PhpWord object", \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Begin code // Begin code
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// Define the TOC font style // Define the TOC font style
$fontStyle = array('spaceAfter'=>60, 'size'=>12); $fontStyle = array('spaceAfter'=>60, 'size'=>12);

View File

@ -7,8 +7,8 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
// Begin code // Begin code
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$header = $section->createHeader(); $header = $section->addHeader();
$header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55)); $header->addWatermark('resources/_earth.jpg', array('marginTop' => 200, 'marginLeft' => 55));
$section->addText('The header reference to the current section includes a watermark image.'); $section->addText('The header reference to the current section includes a watermark image.');

View File

@ -12,7 +12,7 @@ $phpWord->addFontStyle('fontStyle', array('size' => 9));
$phpWord->addParagraphStyle('paragraphStyle', array('spacing' => 480)); $phpWord->addParagraphStyle('paragraphStyle', array('spacing' => 480));
$fontStyle = array('size' => 24); $fontStyle = array('size' => 24);
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Text break with no style:'); $section->addText('Text break with no style:');
$section->addTextBreak(); $section->addTextBreak();
$section->addText('Text break with defined font style:'); $section->addText('Text break with defined font style:');

View File

@ -4,7 +4,7 @@ include_once 'Sample_Header.php';
// New Word document // New Word document
echo date('H:i:s'), " Create new PhpWord object", \EOL; echo date('H:i:s'), " Create new PhpWord object", \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $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 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")); $section->addText("This one uses bgColor and is using hex value (0xfbbb10)", array("bgColor" => "fbbb10"));

View File

@ -4,7 +4,7 @@ include_once 'Sample_Header.php';
// New Word document // New Word document
echo date('H:i:s'), " Create new PhpWord object", \EOL; echo date('H:i:s'), " Create new PhpWord object", \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $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("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"); $section->addText("If we want a simple border around an image, we wrap the image inside a table->row->cell");

View File

@ -5,7 +5,7 @@ include_once 'Sample_Header.php';
echo date('H:i:s'), " Create new PhpWord object", \EOL; echo date('H:i:s'), " Create new PhpWord object", \EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Check box in section'); $section->addText('Check box in section');
$section->addCheckBox('chkBox1', 'Checkbox 1'); $section->addCheckBox('chkBox1', 'Checkbox 1');
$section->addText('Check box in table cell'); $section->addText('Check box in table cell');

View File

@ -23,6 +23,7 @@ class PhpWord
const DEFAULT_FONT_COLOR = '000000'; // HEX const DEFAULT_FONT_COLOR = '000000'; // HEX
const DEFAULT_FONT_CONTENT_TYPE = 'default'; // default|eastAsia|cs const DEFAULT_FONT_CONTENT_TYPE = 'default'; // default|eastAsia|cs
const DEFAULT_FONT_NAME = 'Arial'; const DEFAULT_FONT_NAME = 'Arial';
/** /**
* Default font size, in points. * Default font size, in points.
* *
@ -34,7 +35,7 @@ class PhpWord
/** /**
* Document properties object * Document properties object
* *
* @var \PhpOffice\PhpWord\DocumentProperties * @var DocumentProperties
*/ */
private $_documentProperties; private $_documentProperties;
@ -54,7 +55,7 @@ class PhpWord
/** /**
* Collection of sections * Collection of sections
* *
* @var \PhpOffice\PhpWord\Section[] * @var Section[]
*/ */
private $_sections = array(); private $_sections = array();
@ -71,7 +72,7 @@ class PhpWord
/** /**
* Get document properties object * Get document properties object
* *
* @return \PhpOffice\PhpWord\DocumentProperties * @return DocumentProperties
*/ */
public function getDocumentProperties() public function getDocumentProperties()
{ {
@ -95,9 +96,9 @@ class PhpWord
* Create new section * Create new section
* *
* @param \PhpOffice\PhpWord\Container\Settings $settings * @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); $section = new Section(\count($this->_sections) + 1, $settings);
$this->_sections[] = $section; $this->_sections[] = $section;
@ -227,8 +228,8 @@ class PhpWord
* Load template by filename * Load template by filename
* *
* @param string $filename Fully qualified filename. * @param string $filename Fully qualified filename.
* @return \PhpOffice\PhpWord\Template * @return Template
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws Exception
*/ */
public function loadTemplate($filename) public function loadTemplate($filename)
{ {
@ -238,4 +239,16 @@ class PhpWord
throw new Exception("Template file {$filename} not found."); 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);
}
} }

View File

@ -173,7 +173,7 @@ class Word2007 extends Reader implements IReader
); );
$xmlDoc = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}", true)); $xmlDoc = simplexml_load_string($this->getFromZipArchive($zip, "{$rel['Target']}", true));
if (is_object($xmlDoc)) { if (is_object($xmlDoc)) {
$section = $word->createSection(); $section = $word->addSection();
foreach ($xmlDoc->body->children() as $elm) { foreach ($xmlDoc->body->children() as $elm) {
$elmName = $elm->getName(); $elmName = $elm->getName();
@ -181,7 +181,7 @@ class Word2007 extends Reader implements IReader
// Create new section if section setting found // Create new section if section setting found
if ($elm->pPr->sectPr) { if ($elm->pPr->sectPr) {
$section->setSettings($this->loadSectionSettings($elm->pPr)); $section->setSettings($this->loadSectionSettings($elm->pPr));
$section = $word->createSection(); $section = $word->addSection();
continue; continue;
} }
// Has w:r? It's either text or textrun // Has w:r? It's either text or textrun

View File

@ -73,7 +73,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase
public function testCreateTextRun() public function testCreateTextRun()
{ {
$oFooter = new Footer(1); $oFooter = new Footer(1);
$element = $oFooter->createTextRun(); $element = $oFooter->addTextRun();
$this->assertCount(1, $oFooter->getElements()); $this->assertCount(1, $oFooter->getElements());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\TextRun', $element); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\TextRun', $element);

View File

@ -84,7 +84,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase
public function testCreateTextRun() public function testCreateTextRun()
{ {
$oHeader = new Header(1); $oHeader = new Header(1);
$element = $oHeader->createTextRun(); $element = $oHeader->addTextRun();
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\TextRun', $element); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\TextRun', $element);
$this->assertCount(1, $oHeader->getElements()); $this->assertCount(1, $oHeader->getElements());
} }

View File

@ -86,8 +86,8 @@ class SectionTest extends \PHPUnit_Framework_TestCase
$section->addImage($imageSource); $section->addImage($imageSource);
$section->addMemoryImage($imageUrl); $section->addMemoryImage($imageUrl);
$section->addTitle(utf8_decode('ä'), 1); $section->addTitle(utf8_decode('ä'), 1);
$section->createTextRun(); $section->addTextRun();
$section->createFootnote(); $section->addFootnote();
$section->addCheckBox(utf8_decode('chkä'), utf8_decode('Contentä')); $section->addCheckBox(utf8_decode('chkä'), utf8_decode('Contentä'));
$section->addTOC(); $section->addTOC();

View File

@ -276,7 +276,7 @@ class CellTest extends \PHPUnit_Framework_TestCase
public function testCreateTextRun() public function testCreateTextRun()
{ {
$oCell = new Cell('section', 1); $oCell = new Cell('section', 1);
$element = $oCell->createTextRun(); $element = $oCell->addTextRun();
$this->assertCount(1, $oCell->getElements()); $this->assertCount(1, $oCell->getElements());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\TextRun', $element); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\TextRun', $element);

View File

@ -138,7 +138,7 @@ class TextRunTest extends \PHPUnit_Framework_TestCase
public function testCreateFootnote() public function testCreateFootnote()
{ {
$oTextRun = new TextRun(); $oTextRun = new TextRun();
$element = $oTextRun->createFootnote(); $element = $oTextRun->addFootnote();
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Footnote', $element); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Footnote', $element);
$this->assertCount(1, $oTextRun->getElements()); $this->assertCount(1, $oTextRun->getElements());

View File

@ -51,8 +51,8 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
public function testCreateGetSections() public function testCreateGetSections()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$this->assertEquals(new Section(1), $phpWord->createSection()); $this->assertEquals(new Section(1), $phpWord->addSection());
$phpWord->createSection(); $phpWord->addSection();
$this->assertEquals(2, \count($phpWord->getSections())); $this->assertEquals(2, \count($phpWord->getSections()));
} }

View File

@ -103,7 +103,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
public function testLineHeight() public function testLineHeight()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// Test style array // Test style array
$text = $section->addText('This is a test', array( $text = $section->addText('This is a test', array(

View File

@ -105,7 +105,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
public function testLineHeight() public function testLineHeight()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
// Test style array // Test style array
$text = $section->addText('This is a test', array(), array( $text = $section->addText('This is a test', array(), array(

View File

@ -41,7 +41,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase
$phpWord->setDefaultFontName('Verdana'); $phpWord->setDefaultFontName('Verdana');
$phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addFontStyle('Font', array('size' => 11));
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText($expected); $section->addText($expected);
$section->addText('Test font style', 'Font'); $section->addText('Test font style', 'Font');
$section->addText('Test paragraph style', null, 'Paragraph'); $section->addText('Test paragraph style', null, 'Paragraph');
@ -54,7 +54,7 @@ class ContentTest extends \PHPUnit_Framework_TestCase
$section->addImage($imageSrc); $section->addImage($imageSrc);
$section->addObject($objectSrc); $section->addObject($objectSrc);
$section->addTOC(); $section->addTOC();
$textrun = $section->createTextRun(); $textrun = $section->addTextRun();
$textrun->addText('Test text run'); $textrun->addText('Test text run');
$doc = TestHelperDOCX::getDocument($phpWord, 'ODText'); $doc = TestHelperDOCX::getDocument($phpWord, 'ODText');

View File

@ -64,7 +64,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addFontStyle('Font', array('size' => 11));
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Test 1', 'Font'); $section->addText('Test 1', 'Font');
$section->addTextBreak(); $section->addTextBreak();
$section->addText('Test 2', null, 'Paragraph'); $section->addText('Test 2', null, 'Paragraph');
@ -76,8 +76,8 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
$section->addImage($imageSrc); $section->addImage($imageSrc);
$section->addObject($objectSrc); $section->addObject($objectSrc);
$section->addTOC(); $section->addTOC();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$textrun = $section->createTextRun(); $textrun = $section->addTextRun();
$textrun->addText('Test 3'); $textrun->addText('Test 3');
$writer = new ODText($phpWord); $writer = new ODText($phpWord);
$writer->save($file); $writer->save($file);
@ -95,7 +95,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
public function testSavePhpOutput() public function testSavePhpOutput()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Test'); $section->addText('Test');
$writer = new ODText($phpWord); $writer = new ODText($phpWord);
$writer->save('php://output'); $writer->save('php://output');

View File

@ -52,7 +52,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000')); $phpWord->addFontStyle('Font', array('name' => 'Verdana', 'size' => 11, 'color' => 'FF0000', 'fgColor' => 'FF0000'));
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Test 1', 'Font', 'Paragraph'); $section->addText('Test 1', 'Font', 'Paragraph');
$section->addTextBreak(); $section->addTextBreak();
$section->addText('Test 2', array('name' => 'Tahoma', 'bold' => true, 'italic' => true)); $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->addImage($imageSrc);
$section->addObject($objectSrc); $section->addObject($objectSrc);
$section->addTOC(); $section->addTOC();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$textrun = $section->createTextRun(); $textrun = $section->addTextRun();
$textrun->addText('Test 3'); $textrun->addText('Test 3');
$textrun->addTextBreak(); $textrun->addTextBreak();
$writer = new RTF($phpWord); $writer = new RTF($phpWord);
@ -84,7 +84,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
public function testSavePhpOutput() public function testSavePhpOutput()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Test'); $section->addText('Test');
$writer = new RTF($phpWord); $writer = new RTF($phpWord);
$writer->save('php://output'); $writer->save('php://output');

View File

@ -38,7 +38,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addFontStyle($rStyle, array('bold' => true)); $phpWord->addFontStyle($rStyle, array('bold' => true));
$phpWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120)); $phpWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120));
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Test', $rStyle, $pStyle); $section->addText('Test', $rStyle, $pStyle);
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);
@ -59,14 +59,14 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addParagraphStyle($pStyle, $aStyle); $phpWord->addParagraphStyle($pStyle, $aStyle);
$section = $phpWord->createSection('Test'); $section = $phpWord->addSection('Test');
$textrun = $section->createTextRun($pStyle); $textrun = $section->addTextRun($pStyle);
$textrun->addText('Test'); $textrun->addText('Test');
$textrun->addTextBreak(); $textrun->addTextBreak();
$textrun = $section->createTextRun($aStyle); $textrun = $section->addTextRun($aStyle);
$textrun->addLink('http://test.com'); $textrun->addLink('http://test.com');
$textrun->addImage($imageSrc, array('align' => 'top')); $textrun->addImage($imageSrc, array('align' => 'top'));
$textrun->createFootnote(); $textrun->addFootnote();
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);
$parent = "/w:document/w:body/w:p"; $parent = "/w:document/w:body/w:p";
@ -79,7 +79,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
public function testWriteLink() public function testWriteLink()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$fontStyleArray = array('bold' => true); $fontStyleArray = array('bold' => true);
$fontStyleName = 'Font Style'; $fontStyleName = 'Font Style';
$paragraphStyleArray = array('align' => 'center'); $paragraphStyleArray = array('align' => 'center');
@ -102,8 +102,8 @@ class BaseTest extends \PHPUnit_Framework_TestCase
public function testWritePreserveText() public function testWritePreserveText()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$footer = $section->createFooter(); $footer = $section->addFooter();
$fontStyleArray = array('bold' => true); $fontStyleArray = array('bold' => true);
$fontStyleName = 'Font'; $fontStyleName = 'Font';
$paragraphStyleArray = array('align' => 'right'); $paragraphStyleArray = array('align' => 'right');
@ -133,7 +133,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addFontStyle($fName, $fArray); $phpWord->addFontStyle($fName, $fArray);
$phpWord->addParagraphStyle($pName, $pArray); $phpWord->addParagraphStyle($pName, $pArray);
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addTextBreak(); $section->addTextBreak();
$section->addTextBreak(1, $fArray, $pArray); $section->addTextBreak(1, $fArray, $pArray);
$section->addTextBreak(1, $fName, $pName); $section->addTextBreak(1, $fName, $pName);
@ -151,7 +151,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
public function testWriteParagraphStyleAlign() public function testWriteParagraphStyleAlign()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('This is my text', null, array('align' => 'right')); $section->addText('This is my text', null, array('align' => 'right'));
@ -168,7 +168,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
{ {
// Create the doc // Create the doc
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$attributes = array( $attributes = array(
'widowControl' => false, 'widowControl' => false,
'keepNext' => true, 'keepNext' => true,
@ -209,7 +209,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$styles['bgColor'] = 'FFFF00'; $styles['bgColor'] = 'FFFF00';
$styles['hint'] = 'eastAsia'; $styles['hint'] = 'eastAsia';
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Test', $styles); $section->addText('Test', $styles);
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);
@ -257,7 +257,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$cStyles["borderRightColor"] = 'FF0000'; $cStyles["borderRightColor"] = 'FF0000';
$cStyles["vMerge"] = 'restart'; $cStyles["vMerge"] = 'restart';
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$table = $section->addTable($tStyles); $table = $section->addTable($tStyles);
$table->setWidth = 100; $table->setWidth = 100;
$table->addRow($rHeight, $rStyles); $table->addRow($rHeight, $rStyles);
@ -268,7 +268,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$cell->addListItem('Test'); $cell->addListItem('Test');
$cell->addImage($imageSrc); $cell->addImage($imageSrc);
$cell->addObject($objectSrc); $cell->addObject($objectSrc);
$textrun = $cell->createTextRun(); $textrun = $cell->addTextRun();
$textrun->addText('Test'); $textrun->addText('Test');
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);
@ -296,7 +296,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
public function testWriteCellStyleCellGridSpan() public function testWriteCellStyleCellGridSpan()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$table = $section->addTable(); $table = $section->addTable();
@ -323,7 +323,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
public function testWriteImagePosition() public function testWriteImagePosition()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addImage( $section->addImage(
__DIR__ . "/../../_files/images/earth.jpg", __DIR__ . "/../../_files/images/earth.jpg",
array( array(
@ -350,8 +350,8 @@ class BaseTest extends \PHPUnit_Framework_TestCase
$imageSrc = __DIR__ . "/../../_files/images/earth.jpg"; $imageSrc = __DIR__ . "/../../_files/images/earth.jpg";
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$header = $section->createHeader(); $header = $section->addHeader();
$header->addWatermark($imageSrc); $header->addWatermark($imageSrc);
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);
@ -366,7 +366,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240)); $phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240));
$phpWord->createSection()->addTitle('Test', 1); $phpWord->addSection()->addTitle('Test', 1);
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);
$element = "/w:document/w:body/w:p/w:pPr/w:pStyle"; $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 = new PhpWord();
$phpWord->addFontStyle($rStyle, array('bold' => true)); $phpWord->addFontStyle($rStyle, array('bold' => true));
$phpWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120)); $phpWord->addParagraphStyle($pStyle, array('hanging' => 120, 'indent' => 120));
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addCheckbox('Check1', 'Test', $rStyle, $pStyle); $section->addCheckbox('Check1', 'Test', $rStyle, $pStyle);
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);

View File

@ -33,7 +33,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
public function testWriteEndSectionPageNumbering() public function testWriteEndSectionPageNumbering()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$settings = $section->getSettings(); $settings = $section->getSettings();
$settings->setLandscape(); $settings->setLandscape();
$settings->setPageNumberingStart(2); $settings->setPageNumberingStart(2);
@ -56,14 +56,14 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true)); $phpWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true));
$phpWord->addTitleStyle(2, array('color'=>'666666')); $phpWord->addTitleStyle(2, array('color'=>'666666'));
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addTOC(); $section->addTOC();
$section->addPageBreak(); $section->addPageBreak();
$section->addTitle('Title 1', 1); $section->addTitle('Title 1', 1);
$section->addListItem('List Item 1', 0); $section->addListItem('List Item 1', 0);
$section->addListItem('List Item 2', 0); $section->addListItem('List Item 2', 0);
$section->addListItem('List Item 3', 0); $section->addListItem('List Item 3', 0);
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addTitle('Title 2', 2); $section->addTitle('Title 2', 2);
$section->addObject($objectSrc); $section->addObject($objectSrc);
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);
@ -103,7 +103,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
$phpWord->addFontStyle('fStyle', array('size' => '20')); $phpWord->addFontStyle('fStyle', array('size' => '20'));
$phpWord->addTitleStyle(1, array('color' => '333333', 'bold' => true)); $phpWord->addTitleStyle(1, array('color' => '333333', 'bold' => true));
$fontStyle = new Font('text', array('align' => 'center')); $fontStyle = new Font('text', array('align' => 'center'));
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addListItem('List Item', 0, null, null, 'pStyle'); $section->addListItem('List Item', 0, null, null, 'pStyle');
$section->addObject($objectSrc, array('align' => 'center')); $section->addObject($objectSrc, array('align' => 'center'));
$section->addTOC($fontStyle); $section->addTOC($fontStyle);

View File

@ -32,7 +32,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase
$container->addText(''); $container->addText('');
$container->addPreserveText(''); $container->addPreserveText('');
$container->addTextBreak(); $container->addTextBreak();
$container->createTextRun(); $container->addTextRun();
$container->addTable()->addRow()->addCell()->addText(''); $container->addTable()->addRow()->addCell()->addText('');
$container->addImage($imageSrc); $container->addImage($imageSrc);

View File

@ -34,13 +34,13 @@ class FootnotesTest extends \PHPUnit_Framework_TestCase
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addParagraphStyle('pStyle', array('align' => 'left')); $phpWord->addParagraphStyle('pStyle', array('align' => 'left'));
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Text'); $section->addText('Text');
$footnote1 = $section->createFootnote('pStyle'); $footnote1 = $section->addFootnote('pStyle');
$footnote1->addText('Footnote'); $footnote1->addText('Footnote');
$footnote1->addTextBreak(); $footnote1->addTextBreak();
$footnote1->addLink('http://google.com'); $footnote1->addLink('http://google.com');
$footnote2 = $section->createFootnote(array('align' => 'left')); $footnote2 = $section->addFootnote(array('align' => 'left'));
$footnote2->addText('Footnote'); $footnote2->addText('Footnote');
$doc = TestHelperDOCX::getDocument($phpWord); $doc = TestHelperDOCX::getDocument($phpWord);

View File

@ -30,7 +30,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase
$container->addText('Test'); $container->addText('Test');
$container->addPreserveText(''); $container->addPreserveText('');
$container->addTextBreak(); $container->addTextBreak();
$container->createTextRun(); $container->addTextRun();
$container->addTable()->addRow()->addCell()->addText(''); $container->addTable()->addRow()->addCell()->addText('');
$container->addImage($imageSrc); $container->addImage($imageSrc);
$container->addWatermark($imageSrc); $container->addWatermark($imageSrc);

View File

@ -68,18 +68,18 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$phpWord->addFontStyle('Font', array('size' => 11)); $phpWord->addFontStyle('Font', array('size' => 11));
$phpWord->addParagraphStyle('Paragraph', array('align' => 'center')); $phpWord->addParagraphStyle('Paragraph', array('align' => 'center'));
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Test 1', 'Font', 'Paragraph'); $section->addText('Test 1', 'Font', 'Paragraph');
$section->addTextBreak(); $section->addTextBreak();
$section->addText('Test 2'); $section->addText('Test 2');
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$textrun = $section->createTextRun(); $textrun = $section->addTextRun();
$textrun->addText('Test 3'); $textrun->addText('Test 3');
$footnote = $textrun->createFootnote(); $footnote = $textrun->addFootnote();
$footnote->addLink('http://test.com'); $footnote->addLink('http://test.com');
$header = $section->createHeader(); $header = $section->addHeader();
$header->addImage($localImage); $header->addImage($localImage);
$footer = $section->createFooter(); $footer = $section->addFooter();
$footer->addImage($remoteImage); $footer->addImage($remoteImage);
$writer = new Word2007($phpWord); $writer = new Word2007($phpWord);
@ -97,9 +97,9 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
public function testSaveUseDiskCaching() public function testSaveUseDiskCaching()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$section->addText('Test'); $section->addText('Test');
$footnote = $section->createFootnote(); $footnote = $section->addFootnote();
$footnote->addText('Test'); $footnote->addText('Test');
$writer = new Word2007($phpWord); $writer = new Word2007($phpWord);
@ -138,7 +138,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
'angela_merkel.tif' => '6.tif', 'angela_merkel.tif' => '6.tif',
); );
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
foreach ($images as $source => $target) { foreach ($images as $source => $target) {
$section->addImage(__DIR__ . "/../_files/images/{$source}"); $section->addImage(__DIR__ . "/../_files/images/{$source}");
} }
@ -169,7 +169,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
public function testSetGetUseDiskCaching() public function testSetGetUseDiskCaching()
{ {
$phpWord = new PhpWord(); $phpWord = new PhpWord();
$section = $phpWord->createSection(); $section = $phpWord->addSection();
$object = new Word2007($phpWord); $object = new Word2007($phpWord);
$object->setUseDiskCaching(true, \PHPWORD_TESTS_BASE_DIR); $object->setUseDiskCaching(true, \PHPWORD_TESTS_BASE_DIR);
$writer = new Word2007($phpWord); $writer = new Word2007($phpWord);