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`
- `createHeader` replaced by `addHeader`
- `createFooter` replaced by `addFooter`
- `createSection` replaced by `addSection`
### 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.
// To create a basic section:
$section = $phpWord->createSection();
$section = $phpWord->addSection();
// After creating a section, you can append elements:
$section->addText('Hello world!');

View File

@ -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:

View File

@ -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

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.
// 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));

View File

@ -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);

View File

@ -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');

View File

@ -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');

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));
// 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');

View File

@ -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

View File

@ -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

View File

@ -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 ' .

View File

@ -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

View File

@ -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'));

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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');

View File

@ -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);

View File

@ -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.');

View File

@ -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:');

View File

@ -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"));

View File

@ -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");

View File

@ -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');

View File

@ -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);
}
}

View File

@ -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

View File

@ -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);

View File

@ -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());
}

View File

@ -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();

View File

@ -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);

View File

@ -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());

View File

@ -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()));
}

View File

@ -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(

View File

@ -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(

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);