Skip to content

Removed fake namespacing from tests and reformatted code to PSR-2 coding standards #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 99 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
891798b
Unix format
ivanlanin Dec 31, 2013
3037fbf
Read README.md
ivanlanin Jan 1, 2014
3fa49ee
section breakType
ivanlanin Jan 1, 2014
abbd288
https://github.com/PHPOffice/PHPWord/issues/46
Jan 1, 2014
0edaaaa
Tidy up for pull request
ivanlanin Jan 1, 2014
72e8f3f
Fix comment error
ivanlanin Jan 1, 2014
d3e8b69
Remove (int) since there's a possibility for fraction
ivanlanin Jan 1, 2014
d55db9d
Patch branch
ivanlanin Jan 9, 2014
4d94d57
(1) new width property for table; (2) allow table cell width to be null
ivanlanin Jan 13, 2014
194940d
Width: dxa > pct
ivanlanin Jan 16, 2014
2c5fed6
https://github.com/PHPOffice/PHPWord/issues/52
Jan 16, 2014
b0a2470
`Table Row` allows `tblHeader` and `cantSplit`
ivanlanin Feb 22, 2014
eb6b44e
Use constant instead of hardcoded 'Arial' name.
ivanlanin Feb 22, 2014
a915e05
Merge remote-tracking branch 'upstream/master'
ivanlanin Feb 22, 2014
ab2b2de
Change default font to Times New Roman 12pt
ivanlanin Feb 23, 2014
e5a4e2d
https://github.com/PHPOffice/PHPWord/issues/46
Mar 1, 2014
b579007
https://github.com/PHPOffice/PHPWord/issues/46
Mar 1, 2014
8480753
https://github.com/PHPOffice/PHPWord/issues/46
Mar 2, 2014
6ed2b11
https://github.com/PHPOffice/PHPWord/issues/46
Mar 2, 2014
a016570
https://github.com/PHPOffice/PHPWord/issues/46
Mar 2, 2014
27b7d67
https://github.com/PHPOffice/PHPWord/issues/46
Mar 2, 2014
fb5ef65
https://github.com/PHPOffice/PHPWord/issues/46
Mar 2, 2014
d324a64
https://github.com/PHPOffice/PHPWord/issues/46
Mar 2, 2014
a765d61
https://github.com/PHPOffice/PHPWord/issues/46
Mar 2, 2014
9f434c7
https://github.com/PHPOffice/PHPWord/issues/46
Mar 2, 2014
e0e4893
https://github.com/PHPOffice/PHPWord/issues/46
Mar 2, 2014
1c3ebe1
https://github.com/PHPOffice/PHPWord/issues/46
Mar 3, 2014
bdcbd14
https://github.com/PHPOffice/PHPWord/issues/46
Mar 3, 2014
ec5322d
https://github.com/PHPOffice/PHPWord/issues/46
Mar 3, 2014
bfe7da6
https://github.com/PHPOffice/PHPWord/issues/46
Mar 3, 2014
a8b73b9
https://github.com/PHPOffice/PHPWord/issues/46
Mar 3, 2014
b765312
https://github.com/PHPOffice/PHPWord/issues/46
Mar 3, 2014
d1e16a6
GH-5 : Word2007 : Added support for page header & page footer height
Progi1984 Mar 3, 2014
670765f
https://github.com/PHPOffice/PHPWord/issues/46
Mar 4, 2014
d0b4ed6
Ability to use images in a text run
hskrtich Mar 4, 2014
4ad5cf0
Merge pull request #84 from bskrtich/textrunimage
Progi1984 Mar 5, 2014
c173a71
Changelog (GH-6 GH-66 GH-84)
Progi1984 Mar 5, 2014
2d3725c
Merge pull request #85 from RomanSyroeshko/PHPWord#52
Progi1984 Mar 5, 2014
1f4a18d
Changelog (GH-52 GH-53 GH-85)
Progi1984 Mar 5, 2014
d3f6256
Merge remote-tracking branch 'remotes/upstream/develop' into develop
ivanlanin Mar 6, 2014
7533d30
Changes:
ivanlanin Mar 6, 2014
f1c2c2f
Copyright year
ivanlanin Mar 6, 2014
938d78f
Samples: (1) Superscript and subscript; (2) Multicolumn
ivanlanin Mar 6, 2014
1361278
Revert
ivanlanin Mar 6, 2014
22afd14
Update change log
ivanlanin Mar 6, 2014
350e7a6
Revert Tests/bootstrap.php and samples/Sample_03_Sections.php
ivanlanin Mar 6, 2014
626ea08
Merge pull request #86 from ivanlanin/develop
Progi1984 Mar 6, 2014
55a5b7e
Changelog : Feature for columns in section, continuous section break,…
Progi1984 Mar 6, 2014
545cbc6
GH-51 : Adding a value that contains "&" in a template breaks it
Progi1984 Mar 6, 2014
be4b01b
PHPWord_Shared_Font::pointSizeToTwips
ivanlanin Mar 7, 2014
09ba95b
Paragraph: Ability to define (1) normal paragraph style with PHPWord:…
ivanlanin Mar 7, 2014
5889313
php syntax higlighting on README.md
ivanlanin Mar 7, 2014
0d1c368
setNormalStyle > setDefaultParagraphStyle
ivanlanin Mar 7, 2014
60c21a2
https://github.com/PHPOffice/PHPWord/issues/46
Mar 7, 2014
657e834
https://github.com/PHPOffice/PHPWord/issues/46
Mar 7, 2014
19636a0
https://github.com/PHPOffice/PHPWord/issues/46
Mar 7, 2014
379e5ce
https://github.com/PHPOffice/PHPWord/issues/46
Mar 7, 2014
4c414c8
https://github.com/PHPOffice/PHPWord/issues/46
Mar 7, 2014
b5f7131
Create table rows on the fly with cloneRow() when using templates.
jeroenmoors Dec 16, 2013
21589ff
Renamed the output file to 'Sample_03_TemplateCloneRow_result.docx'.
jeroenmoors Dec 16, 2013
590f08c
Update cloneRow function to support vertical spanned cells.
jeroenmoors Jan 10, 2014
57f330c
Handle the cases were there's no whitespace after <w:tr.
jeroenmoors Jan 27, 2014
43a00b1
Renamed sample files.
jeroenmoors Mar 7, 2014
50ae8f3
Merge pull request #83 from RomanSyroeshko/PHPWord#46
Progi1984 Mar 7, 2014
f92e577
GH-46 : Ability to apply XSL style sheet to Template
Progi1984 Mar 7, 2014
35c48dc
Merge remote-tracking branch 'upstream/develop' into develop
ivanlanin Mar 7, 2014
307f568
Add unit tests for Shared/Font and Writer/Word2007/Styles
ivanlanin Mar 7, 2014
0ed956a
Merge pull request #87 from ivanlanin/develop
Progi1984 Mar 7, 2014
07a6794
Changelog : GH-87 : Point to twip converter, set normal paragraph sty…
Progi1984 Mar 7, 2014
3ed2588
Merge pull request #88 from jeroenmoors/develop
Progi1984 Mar 7, 2014
ebb7d04
Changelog : GH-88 : Clone table rows on the fly when using a template…
Progi1984 Mar 7, 2014
db52525
GH-89 : Example in README.md is broken
Progi1984 Mar 7, 2014
86abe7e
GH-16 : Initial addition of basic footnote support
Progi1984 Mar 7, 2014
db08572
GH-16 : Initial addition of basic footnote support
Progi1984 Mar 7, 2014
47c7fab
Replace call to save with saveAs to save the document.
jeroenmoors Mar 7, 2014
3bc7f98
Merge pull request #90 from jeroenmoors/develop
Progi1984 Mar 7, 2014
423c334
Fix bug in directory whitelist. Run `phpunit --coverage-html` to repr…
ivanlanin Mar 8, 2014
d1f34fc
Merge pull request #91 from ivanlanin/develop
Progi1984 Mar 8, 2014
df7083b
Ability to define paragraph pagination: widow control, keep next, kee…
ivanlanin Mar 8, 2014
0e26da9
Fix issue number on changelog.txt
ivanlanin Mar 8, 2014
9042bb5
Merge pull request #92 from ivanlanin/develop
Progi1984 Mar 8, 2014
b39f9da
Refactor and unit test PHPWord_Style_Font
ivanlanin Mar 8, 2014
074dfab
Add section settings documentation
ivanlanin Mar 8, 2014
9fd1384
Constants explanation
ivanlanin Mar 9, 2014
9bae85e
Merge pull request #93 from ivanlanin/develop
Progi1984 Mar 9, 2014
4dcde8c
PHPWord_Shared_Drawing::centimetersToPixels() conversion
ivanlanin Mar 9, 2014
537f49e
Fix non-existing functions in Writer/ODText/Content.php
ivanlanin Mar 9, 2014
d177b47
New function PHPWord_Style_Paragraph::setTabs() and unit test for PHP…
ivanlanin Mar 9, 2014
68a4387
Reformat code samples on README.md to max 80 char per line
ivanlanin Mar 9, 2014
2633080
Fix parameter input for testWriteParagraphStyle_Pagination
ivanlanin Mar 9, 2014
c364490
Remove PHPWord_Style_Cell::setHeight() since it's irrelevant and neve…
ivanlanin Mar 9, 2014
fa1663a
PHP method IS NOT case sensitive :)
ivanlanin Mar 9, 2014
3d8f09d
PHPWord_Style_CellTest 100% code coverage
ivanlanin Mar 9, 2014
34d9121
Change normal value for cell style tests
ivanlanin Mar 9, 2014
712e09a
Basic README for `addText` and `createTextRun`
ivanlanin Mar 9, 2014
63a535b
Merge pull request #94 from ivanlanin/develop
Progi1984 Mar 9, 2014
c163ca4
Reformatted Tests to PSR-2 coding standards
gabrielbull Mar 2, 2014
59bff8a
Removed fake namespace from tests class names because we use real nam…
gabrielbull Mar 2, 2014
1330112
Added line height methods to mirror the line height settings in Word …
gabrielbull Mar 2, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions Classes/PHPWord.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@
class PHPWord
{

/**
* Default font name (Arial)
*/
const DEFAULT_FONT_NAME = 'Arial';

/**
* Default font size in points (10pt)
*
* OOXML defined font size values in halfpoints, i.e. twice of what PHPWord
* use, and the conversion will be conducted during XML writing.
*/
const DEFAULT_FONT_SIZE = 10;

/**
* Default font color (black)
*/
const DEFAULT_FONT_COLOR = '000000';

/**
* Document properties
*
Expand Down Expand Up @@ -74,8 +92,8 @@ class PHPWord
public function __construct()
{
$this->_properties = new PHPWord_DocumentProperties();
$this->_defaultFontName = 'Arial';
$this->_defaultFontSize = 20;
$this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME;
$this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE;
}

/**
Expand Down Expand Up @@ -195,6 +213,16 @@ public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
}

/**
* Set default paragraph style definition to styles.xml
*
* @param array $styles Paragraph style definition
*/
public function setDefaultParagraphStyle($styles)
{
PHPWord_Style::setDefaultParagraphStyle($styles);
}

/**
* Adds a hyperlink style to styles.xml
*
Expand Down
15 changes: 15 additions & 0 deletions Classes/PHPWord/Exceptions/InvalidStyleException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace PHPWord\Exceptions;

use InvalidArgumentException;

/**
* InvalidStyleException
*
* Exception used for when a style value is invalid
*
* @package PHPWord
*/
class InvalidStyleException extends InvalidArgumentException
{
}
125 changes: 125 additions & 0 deletions Classes/PHPWord/Footnote.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php
/**
* PHPWord
*
* Copyright (c) 2011 PHPWord
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPWord
* @package PHPWord
* @copyright Copyright (c) 010 PHPWord
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version Beta 0.6.3, 08.07.2011
*/


/**
* PHPWord_Footnote
*
* @category PHPWord
* @package PHPWord
* @copyright Copyright (c) 2011 PHPWord
*/
class PHPWord_Footnote {

/**
* Footnote Elements
*
* @var array
*/
private static $_footnoteCollection = array();

/**
* Footnote Link Elements
*
* @var array
*/
private static $_footnoteLink = array();

/**
* Add new Footnote Element
*
* @param string $linkSrc
* @param string $linkName
*
* @return mixed
*/
public static function addFootnoteElement(PHPWord_Section_Footnote $footnote) {
$refID = self::countFootnoteElements() + 2;

self::$_footnoteCollection[] = $footnote;

return $refID;
}

/**
* Get Footnote Elements
*
* @return array
*/
public static function getFootnoteElements() {
return self::$_footnoteCollection;
}

/**
* Get Footnote Elements Count
*
* @return int
*/
public static function countFootnoteElements() {
return count(self::$_footnoteCollection);
}

/**
* Add new Footnote Link Element
*
* @param string $src
* @param string $type
*
* @return mixed
*/
public static function addFootnoteLinkElement($linkSrc) {
$rID = self::countFootnoteLinkElements() + 1;

$link = array();
$link['target'] = $linkSrc;
$link['rID'] = $rID;
$link['type'] = 'hyperlink';

self::$_footnoteLink[] = $link;

return $rID;
}

/**
* Get Footnote Link Elements
*
* @return array
*/
public static function getFootnoteLinkElements() {
return self::$_footnoteLink;
}

/**
* Get Footnote Link Elements Count
*
* @return int
*/
public static function countFootnoteLinkElements() {
return count(self::$_footnoteLink);
}

}
14 changes: 14 additions & 0 deletions Classes/PHPWord/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,18 @@ public function getFooter()
{
return $this->_footer;
}

/**
* Create a new Footnote Element
*
* @param string $text
* @return PHPWord_Section_Footnote
*/
public function createFootnote($styleParagraph = null) {
$footnote = new PHPWord_Section_Footnote($styleParagraph);
$refID = PHPWord_Footnote::addFootnoteElement($footnote);
$footnote->setReferenceId($refID);
$this->_elementCollection[] = $footnote;
return $footnote;
}
}
148 changes: 148 additions & 0 deletions Classes/PHPWord/Section/Footnote.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?php
/**
* PHPWord
*
* Copyright (c) 2011 PHPWord
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPWord
* @package PHPWord
* @copyright Copyright (c) 010 PHPWord
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version Beta 0.6.3, 08.07.2011
*/


/**
* PHPWord_Section_Footnote
*
* @category PHPWord
* @package PHPWord_Section
* @copyright Copyright (c) 2011 PHPWord
*/
class PHPWord_Section_Footnote {

/**
* Paragraph style
*
* @var PHPWord_Style_Font
*/
private $_styleParagraph;

/**
* Footnote Reference ID
*
* @var string
*/
private $_refId;

/**
* Text collection
*
* @var array
*/
private $_elementCollection;

/**
* Create a new Footnote Element
*/
public function __construct($styleParagraph = null) {
$this->_elementCollection = array();

// Set paragraph style
if(is_array($styleParagraph)) {
$this->_styleParagraph = new PHPWord_Style_Paragraph();

foreach($styleParagraph as $key => $value) {
if(substr($key, 0, 1) != '_') {
$key = '_'.$key;
}
$this->_styleParagraph->setStyleValue($key, $value);
}
} else {
$this->_styleParagraph = $styleParagraph;
}
}


/**
* Add a Text Element
*
* @var string $text
* @var mixed $styleFont
* @return PHPWord_Section_Text
*/
public function addText($text = null, $styleFont = null) {
$givenText = $text;
$text = new PHPWord_Section_Text($givenText, $styleFont);
$this->_elementCollection[] = $text;
return $text;
}

/**
* Add a Link Element
*
* @param string $linkSrc
* @param string $linkName
* @param mixed $styleFont
* @return PHPWord_Section_Link
*/
public function addLink($linkSrc, $linkName = null, $styleFont = null) {

$link = new PHPWord_Section_Link($linkSrc, $linkName, $styleFont);
$rID = PHPWord_Footnote::addFootnoteLinkElement($linkSrc);
$link->setRelationId($rID);

$this->_elementCollection[] = $link;
return $link;
}

/**
* Get Footnote content
*
* @return string
*/
public function getElements() {
return $this->_elementCollection;
}

/**
* Get Paragraph style
*
* @return PHPWord_Style_Paragraph
*/
public function getParagraphStyle() {
return $this->_styleParagraph;
}

/**
* Get Footnote Reference ID
*
* @return int
*/
public function getReferenceId() {
return $this->_refId;
}

/**
* Set Footnote Reference ID
*
* @param int $refId
*/
public function setReferenceId($refId) {
$this->_refId = $refId;
}
}
Loading