From dfccd54e662253ed4dc35b46dfcd607fe0401f10 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Wed, 26 Mar 2014 15:47:27 +0700 Subject: [PATCH] Update README.md, docs, and version number --- README.md | 17 ++++++++------ docs/general.rst | 23 ++++++++++++------- docs/index.rst | 10 ++++---- docs/intro.rst | 8 +++---- docs/setup.rst | 6 ++--- docs/templates.rst | 2 +- src/PhpWord/Autoloader.php | 2 +- src/PhpWord/DocumentProperties.php | 2 +- src/PhpWord/Exceptions/Exception.php | 11 ++++----- .../Exceptions/InvalidImageException.php | 11 ++++----- .../Exceptions/InvalidObjectException.php | 11 ++++----- .../Exceptions/InvalidStyleException.php | 11 ++++----- .../UnsupportedImageTypeException.php | 11 ++++----- src/PhpWord/Footnote.php | 2 +- src/PhpWord/HashTable.php | 2 +- src/PhpWord/IOFactory.php | 2 +- src/PhpWord/Media.php | 2 +- src/PhpWord/PhpWord.php | 2 +- src/PhpWord/Reader/AbstractReader.php | 2 +- src/PhpWord/Reader/IReader.php | 2 +- src/PhpWord/Reader/Word2007.php | 2 +- src/PhpWord/Section.php | 2 +- src/PhpWord/Section/Footer.php | 2 +- src/PhpWord/Section/Footer/PreserveText.php | 2 +- src/PhpWord/Section/Footnote.php | 2 +- src/PhpWord/Section/Header.php | 2 +- src/PhpWord/Section/Image.php | 2 +- src/PhpWord/Section/Link.php | 2 +- src/PhpWord/Section/ListItem.php | 2 +- src/PhpWord/Section/Object.php | 2 +- src/PhpWord/Section/PageBreak.php | 2 +- src/PhpWord/Section/Settings.php | 2 +- src/PhpWord/Section/Table.php | 2 +- src/PhpWord/Section/Table/Cell.php | 2 +- src/PhpWord/Section/Table/Row.php | 2 +- src/PhpWord/Section/Text.php | 2 +- src/PhpWord/Section/TextBreak.php | 2 +- src/PhpWord/Section/TextRun.php | 2 +- src/PhpWord/Section/Title.php | 2 +- src/PhpWord/Settings.php | 2 +- src/PhpWord/Shared/Drawing.php | 2 +- src/PhpWord/Shared/Font.php | 2 +- src/PhpWord/Shared/String.php | 2 +- src/PhpWord/Shared/XMLWriter.php | 2 +- src/PhpWord/Shared/ZipStreamWrapper.php | 2 +- src/PhpWord/Style.php | 2 +- src/PhpWord/Style/Cell.php | 2 +- src/PhpWord/Style/Font.php | 2 +- src/PhpWord/Style/Image.php | 2 +- src/PhpWord/Style/ListItem.php | 2 +- src/PhpWord/Style/Paragraph.php | 2 +- src/PhpWord/Style/Row.php | 2 +- src/PhpWord/Style/TOC.php | 2 +- src/PhpWord/Style/Tab.php | 2 +- src/PhpWord/Style/Table.php | 2 +- src/PhpWord/Style/Tabs.php | 2 +- src/PhpWord/TOC.php | 2 +- src/PhpWord/Template.php | 2 +- src/PhpWord/Writer/IWriter.php | 2 +- src/PhpWord/Writer/ODText.php | 2 +- src/PhpWord/Writer/ODText/Content.php | 2 +- src/PhpWord/Writer/ODText/Manifest.php | 2 +- src/PhpWord/Writer/ODText/Meta.php | 2 +- src/PhpWord/Writer/ODText/Mimetype.php | 2 +- src/PhpWord/Writer/ODText/Styles.php | 2 +- src/PhpWord/Writer/ODText/WriterPart.php | 2 +- src/PhpWord/Writer/RTF.php | 2 +- src/PhpWord/Writer/Word2007.php | 2 +- src/PhpWord/Writer/Word2007/Base.php | 2 +- src/PhpWord/Writer/Word2007/ContentTypes.php | 2 +- src/PhpWord/Writer/Word2007/DocProps.php | 2 +- src/PhpWord/Writer/Word2007/Document.php | 2 +- src/PhpWord/Writer/Word2007/DocumentRels.php | 2 +- src/PhpWord/Writer/Word2007/Footer.php | 2 +- src/PhpWord/Writer/Word2007/Footnotes.php | 2 +- src/PhpWord/Writer/Word2007/FootnotesRels.php | 2 +- src/PhpWord/Writer/Word2007/Header.php | 2 +- src/PhpWord/Writer/Word2007/Rels.php | 2 +- src/PhpWord/Writer/Word2007/Styles.php | 2 +- src/PhpWord/Writer/Word2007/WriterPart.php | 2 +- 80 files changed, 132 insertions(+), 127 deletions(-) diff --git a/README.md b/README.md index d46ee8d1..5e319d33 100755 --- a/README.md +++ b/README.md @@ -57,11 +57,14 @@ the following lines to your ``composer.json``. The following is a basic example of the PHPWord library. More examples are provided in the [samples folder](samples/). ```php -$PHPWord = new PHPWord(); +require_once 'src/PhpWord/Autoloader.php'; +PhpOffice\PhpWord\Autoloader::register(); + +$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->createSection(); // After creating a section, you can append elements: $section->addText('Hello world!'); @@ -72,13 +75,13 @@ $section->addText('Hello world! I am formatted.', // If you often need the same style again you can create a user defined style // to the word document and give the addText function the name of the style: -$PHPWord->addFontStyle('myOwnStyle', +$phpWord->addFontStyle('myOwnStyle', array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232')); $section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle'); // You can also put the appended element to local object like this: -$fontStyle = new PHPWord_Style_Font(); +$fontStyle = new \PhpOffice\PhpWord\Style\Font(); $fontStyle->setBold(true); $fontStyle->setName('Verdana'); $fontStyle->setSize(22); @@ -86,13 +89,13 @@ $myTextElement = $section->addText('Hello World!'); $myTextElement->setFontStyle($fontStyle); // Finally, write the document: -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); +$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $objWriter->save('helloWorld.docx'); -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'ODText'); +$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText'); $objWriter->save('helloWorld.odt'); -$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'RTF'); +$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF'); $objWriter->save('helloWorld.rtf'); ``` diff --git a/docs/general.rst b/docs/general.rst index 7cbfd4b4..3774abcf 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -6,12 +6,13 @@ General usage Basic example ------------- -The following is a basic example of the PHPWord library. More examples +The following is a basic example of the PhpWord library. More examples are provided in the `samples folder `__. .. code-block:: php - require_once '../src/PhpWord/PhpWord.php'; + require_once 'src/PhpWord/Autoloader.php'; + PhpOffice\PhpWord\Autoloader::register(); $phpWord = new \PhpOffice\PhpWord\PhpWord(); @@ -34,7 +35,7 @@ are provided in the `samples folder setBold(true); $fontStyle->setName('Verdana'); $fontStyle->setSize(22); @@ -42,9 +43,15 @@ are provided in the `samples folder setFontStyle($fontStyle); // Finally, write the document: - $objWriter = PHPWord_IOFactory::createWriter($phpWord, 'Word2007'); + $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $objWriter->save('helloWorld.docx'); + $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'ODText'); + $objWriter->save('helloWorld.odt'); + + $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'RTF'); + $objWriter->save('helloWorld.rtf'); + Default font ------------ @@ -82,19 +89,19 @@ Measurement units The base length unit in Open Office XML is twip. Twip means "TWentieth of an Inch Point", i.e. 1 twip = 1/1440 inch. -You can use PHPWord helper functions to convert inches, centimeters, or +You can use PhpWord helper functions to convert inches, centimeters, or points to twips. .. code-block:: php // Paragraph with 6 points space after $phpWord->addParagraphStyle('My Style', array( - 'spaceAfter' => PHPWord_Shared_Font::pointSizeToTwips(6)) + 'spaceAfter' => \PhpOffice\PhpWord\Shared\Font::pointSizeToTwips(6)) ); $section = $phpWord->createSection(); $sectionStyle = $section->getSettings(); // half inch left margin - $sectionStyle->setMarginLeft(PHPWord_Shared_Font::inchSizeToTwips(.5)); + $sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Font::inchSizeToTwips(.5)); // 2 cm right margin - $sectionStyle->setMarginRight(PHPWord_Shared_Font::centimeterSizeToTwips(2)); + $sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Font::centimeterSizeToTwips(2)); diff --git a/docs/index.rst b/docs/index.rst index 700694a5..4f899fb9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -3,14 +3,14 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to PHPWord's documentation +Welcome to PhpWord's documentation ================================== -|PHPWord| +|PhpWord| -PHPWord is a library written in pure PHP that provides a set of classes to +PhpWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current version of -PHPWord supports Microsoft Office Open XML (OOXML or OpenXML), OASIS Open +PhpWord supports Microsoft Office Open XML (OOXML or OpenXML), OASIS Open Document Format for Office Applications (OpenDocument or ODF), and Rich Text Format (RTF). @@ -35,4 +35,4 @@ Indices and tables * :ref:`modindex` * :ref:`search` -.. |PHPWord| image:: images/phpword.png +.. |PhpWord| image:: images/phpword.png diff --git a/docs/intro.rst b/docs/intro.rst index a30dc553..7ca37313 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -3,9 +3,9 @@ Introduction ============ -PHPWord is a library written in pure PHP that provides a set of classes +PhpWord is a library written in pure PHP that provides a set of classes to write to and read from different document file formats. The current -version of PHPWord supports Microsoft `Office Open +version of PhpWord supports Microsoft `Office Open XML `__ (OOXML or OpenXML), OASIS `Open Document Format for Office Applications `__ @@ -16,8 +16,8 @@ No Windows operating system is needed for usage because the resulting DOCX, ODT, or RTF files can be opened by all major `word processing softwares `__. -PHPWord is an open source project licensed under LGPL. -PHPWord is `unit tested `__ to +PhpWord is an open source project licensed under LGPL. +PhpWord is `unit tested `__ to make sure that the released versions are stable. **Want to contribute?** `Fork diff --git a/docs/setup.rst b/docs/setup.rst index c773756f..d148a99d 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -23,7 +23,7 @@ Optional PHP extensions: Installation ------------ -There are two ways to install PHPWord, i.e. via +There are two ways to install PhpWord, i.e. via `Composer `__ or manually by downloading the library. @@ -44,7 +44,7 @@ To install via Composer, add the following lines to your Manual install ~~~~~~~~~~~~~~ -To install manually, `download PHPWord package from +To install manually, `download PhpWord package from github `__. Extract the package and put the contents to your machine. To use the library, include ``src/PhpWord/Autoloader.php`` in your script and @@ -60,5 +60,5 @@ Using samples After installation, you can browse and use the samples that we've provided, either by command line or using browser. If you can access -your PHPWord library folder using browser, point your browser to the +your PhpWord library folder using browser, point your browser to the ``samples`` folder, e.g. ``http://localhost/PhpWord/samples/``. diff --git a/docs/templates.rst b/docs/templates.rst index 6b627b06..5d06cef6 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -8,7 +8,7 @@ replaced by any value you wish. Only single-line values can be replaced. To load a template file, use the ``loadTemplate`` method. After loading the docx template, you can use the ``setValue`` method to change the value of a search pattern. The search-pattern model is: -``${search-pattern}``. It is not possible to add new PHPWord elements to +``${search-pattern}``. It is not possible to add new PhpWord elements to a loaded template file. Example: diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index 7b34eb75..3186ca97 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -20,7 +20,7 @@ * * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 0.8.0 + * @version 0.9.0 */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/DocumentProperties.php b/src/PhpWord/DocumentProperties.php index 2d8a6cb0..d77fcfd8 100644 --- a/src/PhpWord/DocumentProperties.php +++ b/src/PhpWord/DocumentProperties.php @@ -20,7 +20,7 @@ * * @copyright Copyright (c) 2014 PhpWord * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version 0.8.0 + * @version 0.9.0 */ namespace PhpOffice\PhpWord; diff --git a/src/PhpWord/Exceptions/Exception.php b/src/PhpWord/Exceptions/Exception.php index b2b2fcf1..266e1863 100755 --- a/src/PhpWord/Exceptions/Exception.php +++ b/src/PhpWord/Exceptions/Exception.php @@ -1,8 +1,8 @@