From 4a3400c5b2d1a2b8527e22b952b2ae40fdc06567 Mon Sep 17 00:00:00 2001
From: Ivan Lanin <ivanlanin@gmail.com>
Date: Wed, 30 Apr 2014 08:54:38 +0700
Subject: [PATCH] Refactor: Create writers' `Part` folders and remove all
 static parts

---
 src/PhpWord/Element/AbstractContainer.php     |   2 +-
 src/PhpWord/Reader/ODText/AbstractPart.php    |  49 ++----
 src/PhpWord/Writer/ODText.php                 |  23 ++-
 .../Writer/ODText/AbstractWriterPart.php      |  17 ---
 src/PhpWord/Writer/ODText/Element/Element.php |   6 +-
 src/PhpWord/Writer/ODText/Element/TextRun.php |   1 +
 .../{Base.php => Part/AbstractPart.php}       |   8 +-
 .../Writer/ODText/{ => Part}/Content.php      |   4 +-
 .../Writer/ODText/{ => Part}/Manifest.php     |   4 +-
 src/PhpWord/Writer/ODText/{ => Part}/Meta.php |   4 +-
 .../Writer/ODText/{ => Part}/Mimetype.php     |   4 +-
 .../Writer/ODText/{ => Part}/Styles.php       |   4 +-
 src/PhpWord/Writer/Word2007.php               |  48 ++----
 .../Writer/Word2007/AbstractWriterPart.php    |  72 ---------
 .../Writer/Word2007/Element/Element.php       |   6 +-
 .../{Base.php => Part/AbstractPart.php}       |  61 +++++++-
 .../Word2007/{ => Part}/ContentTypes.php      |   4 +-
 .../Writer/Word2007/{ => Part}/DocProps.php   |   4 +-
 .../Writer/Word2007/{ => Part}/Document.php   |   4 +-
 src/PhpWord/Writer/Word2007/Part/Endnotes.php |  44 ++++++
 .../Word2007/Part/FontTable.php}              |  29 +++-
 .../Writer/Word2007/{ => Part}/Footer.php     |   4 +-
 .../{Notes.php => Part/Footnotes.php}         |  71 +++++----
 .../Writer/Word2007/{ => Part}/Header.php     |   4 +-
 .../Writer/Word2007/{ => Part}/Numbering.php  |   4 +-
 .../Writer/Word2007/{ => Part}/Rels.php       |   4 +-
 .../Writer/Word2007/{ => Part}/Settings.php   |   4 +-
 .../Writer/Word2007/{ => Part}/Styles.php     |   4 +-
 .../Word2007/Part/Theme.php}                  |  29 +++-
 .../Word2007/{ => Part}/WebSettings.php       |   2 +-
 .../_doc.png => resources/doc.png}            | Bin
 .../_ppt.png => resources/ppt.png}            | Bin
 .../_xls.png => resources/xls.png}            | Bin
 .../AbstractPartTest.php}                     |  12 +-
 .../Writer/ODText/{ => Part}/ContentTest.php  |  12 +-
 .../Writer/ODText/{ => Part}/MetaTest.php     |   8 +-
 .../Writer/ODText/{ => Part}/StylesTest.php   |   8 +-
 tests/PhpWord/Tests/Writer/ODTextTest.php     |   2 +-
 .../Tests/Writer/Word2007/DocumentTest.php    | 141 ------------------
 .../AbstractPartTest.php}                     |  12 +-
 .../Word2007/{ => Part}/DocPropsTest.php      |   8 +-
 .../{BaseTest.php => Part/DocumentTest.php}   | 132 ++++++++++++++--
 .../Writer/Word2007/{ => Part}/FooterTest.php |  10 +-
 .../{NotesTest.php => Part/FootnotesTest.php} |  11 +-
 .../Writer/Word2007/{ => Part}/HeaderTest.php |   8 +-
 .../Word2007/{ => Part}/NumberingTest.php     |   8 +-
 .../Writer/Word2007/{ => Part}/StylesTest.php |   8 +-
 tests/PhpWord/Tests/Writer/Word2007Test.php   |   6 +-
 48 files changed, 459 insertions(+), 451 deletions(-)
 delete mode 100644 src/PhpWord/Writer/ODText/AbstractWriterPart.php
 rename src/PhpWord/Writer/ODText/{Base.php => Part/AbstractPart.php} (96%)
 rename src/PhpWord/Writer/ODText/{ => Part}/Content.php (99%)
 rename src/PhpWord/Writer/ODText/{ => Part}/Manifest.php (96%)
 rename src/PhpWord/Writer/ODText/{ => Part}/Meta.php (97%)
 rename src/PhpWord/Writer/ODText/{ => Part}/Mimetype.php (83%)
 rename src/PhpWord/Writer/ODText/{ => Part}/Styles.php (98%)
 delete mode 100755 src/PhpWord/Writer/Word2007/AbstractWriterPart.php
 rename src/PhpWord/Writer/Word2007/{Base.php => Part/AbstractPart.php} (62%)
 mode change 100644 => 100755
 rename src/PhpWord/Writer/Word2007/{ => Part}/ContentTypes.php (97%)
 rename src/PhpWord/Writer/Word2007/{ => Part}/DocProps.php (97%)
 rename src/PhpWord/Writer/Word2007/{ => Part}/Document.php (98%)
 create mode 100644 src/PhpWord/Writer/Word2007/Part/Endnotes.php
 rename src/PhpWord/{_staticDocParts/fontTable.xml => Writer/Word2007/Part/FontTable.php} (78%)
 rename src/PhpWord/Writer/Word2007/{ => Part}/Footer.php (95%)
 rename src/PhpWord/Writer/Word2007/{Notes.php => Part/Footnotes.php} (72%)
 rename src/PhpWord/Writer/Word2007/{ => Part}/Header.php (95%)
 rename src/PhpWord/Writer/Word2007/{ => Part}/Numbering.php (98%)
 rename src/PhpWord/Writer/Word2007/{ => Part}/Rels.php (98%)
 rename src/PhpWord/Writer/Word2007/{ => Part}/Settings.php (98%)
 rename src/PhpWord/Writer/Word2007/{ => Part}/Styles.php (99%)
 rename src/PhpWord/{_staticDocParts/theme1.xml => Writer/Word2007/Part/Theme.php} (93%)
 rename src/PhpWord/Writer/Word2007/{ => Part}/WebSettings.php (95%)
 rename src/PhpWord/{_staticDocParts/_doc.png => resources/doc.png} (100%)
 rename src/PhpWord/{_staticDocParts/_ppt.png => resources/ppt.png} (100%)
 rename src/PhpWord/{_staticDocParts/_xls.png => resources/xls.png} (100%)
 rename tests/PhpWord/Tests/Writer/ODText/{AbstractWriterPartTest.php => Part/AbstractPartTest.php} (71%)
 rename tests/PhpWord/Tests/Writer/ODText/{ => Part}/ContentTest.php (88%)
 rename tests/PhpWord/Tests/Writer/ODText/{ => Part}/MetaTest.php (71%)
 rename tests/PhpWord/Tests/Writer/ODText/{ => Part}/StylesTest.php (71%)
 delete mode 100644 tests/PhpWord/Tests/Writer/Word2007/DocumentTest.php
 rename tests/PhpWord/Tests/Writer/Word2007/{AbstractWriterPartTest.php => Part/AbstractPartTest.php} (71%)
 rename tests/PhpWord/Tests/Writer/Word2007/{ => Part}/DocPropsTest.php (79%)
 rename tests/PhpWord/Tests/Writer/Word2007/{BaseTest.php => Part/DocumentTest.php} (73%)
 rename tests/PhpWord/Tests/Writer/Word2007/{ => Part}/FooterTest.php (78%)
 rename tests/PhpWord/Tests/Writer/Word2007/{NotesTest.php => Part/FootnotesTest.php} (73%)
 rename tests/PhpWord/Tests/Writer/Word2007/{ => Part}/HeaderTest.php (82%)
 rename tests/PhpWord/Tests/Writer/Word2007/{ => Part}/NumberingTest.php (86%)
 rename tests/PhpWord/Tests/Writer/Word2007/{ => Part}/StylesTest.php (91%)

diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php
index 72b642bbe7..8af70d421d 100644
--- a/src/PhpWord/Element/AbstractContainer.php
+++ b/src/PhpWord/Element/AbstractContainer.php
@@ -277,7 +277,7 @@ public function addObject($src, $style = null)
             if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
                 $ext = substr($ext, 0, -1);
             }
-            $icon = realpath(__DIR__ . "/../_staticDocParts/_{$ext}.png");
+            $icon = realpath(__DIR__ . "/../resources/{$ext}.png");
             $rId = Media::addElement($elementDocPart, 'object', $src);
             $object->setRelationId($rId);
             $rIdimg = Media::addElement($elementDocPart, 'image', $icon, new Image($icon));
diff --git a/src/PhpWord/Reader/ODText/AbstractPart.php b/src/PhpWord/Reader/ODText/AbstractPart.php
index a0cc75de6e..232b53a79d 100644
--- a/src/PhpWord/Reader/ODText/AbstractPart.php
+++ b/src/PhpWord/Reader/ODText/AbstractPart.php
@@ -9,59 +9,42 @@
 
 namespace PhpOffice\PhpWord\Reader\ODText;
 
-use PhpOffice\PhpWord\PhpWord;
 use PhpOffice\PhpWord\Shared\XMLReader;
 
 /**
  * Abstract part reader
  */
-abstract class AbstractPart
+abstract class AbstractPart extends \PhpOffice\PhpWord\Reader\Word2007\AbstractPart
 {
     /**
-     * Document file
+     * Read w:r (override)
      *
-     * @var string
+     * @param mixed $parent
+     * @param string $docPart
+     * @param mixed $pStyle
      */
-    protected $docFile;
-
-    /**
-     * XML file
-     *
-     * @var string
-     */
-    protected $xmlFile;
-
-    /**
-     * Part relationships
-     *
-     * @var array
-     */
-    protected $rels = array();
+    protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, &$parent, $docPart, $pStyle = null)
+    {
+    }
 
     /**
-     * Read part
+     * Read w:pPr (override)
      */
-    abstract public function read(PhpWord &$phpWord);
+    protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode)
+    {
+    }
 
     /**
-     * Create new instance
-     *
-     * @param string $docFile
-     * @param string $xmlFile
+     * Read w:rPr (override)
      */
-    public function __construct($docFile, $xmlFile)
+    protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode)
     {
-        $this->docFile = $docFile;
-        $this->xmlFile = $xmlFile;
     }
 
     /**
-     * Set relationships
-     *
-     * @param array $value
+     * Read w:tblPr (override)
      */
-    public function setRels($value)
+    protected function readTableStyle(XMLReader $xmlReader, \DOMElement $domNode)
     {
-        $this->rels = $value;
     }
 }
diff --git a/src/PhpWord/Writer/ODText.php b/src/PhpWord/Writer/ODText.php
index 7b99d050f7..0eb6c5452e 100755
--- a/src/PhpWord/Writer/ODText.php
+++ b/src/PhpWord/Writer/ODText.php
@@ -12,11 +12,6 @@
 use PhpOffice\PhpWord\Media;
 use PhpOffice\PhpWord\PhpWord;
 use PhpOffice\PhpWord\Exception\Exception;
-use PhpOffice\PhpWord\Writer\ODText\Content;
-use PhpOffice\PhpWord\Writer\ODText\Manifest;
-use PhpOffice\PhpWord\Writer\ODText\Meta;
-use PhpOffice\PhpWord\Writer\ODText\Mimetype;
-use PhpOffice\PhpWord\Writer\ODText\Styles;
 
 /**
  * ODText writer
@@ -35,14 +30,16 @@ public function __construct(PhpWord $phpWord = null)
         // Assign PhpWord
         $this->setPhpWord($phpWord);
 
-        // Set writer parts
-        $this->writerParts['content'] = new Content();
-        $this->writerParts['manifest'] = new Manifest();
-        $this->writerParts['meta'] = new Meta();
-        $this->writerParts['mimetype'] = new Mimetype();
-        $this->writerParts['styles'] = new Styles();
-        foreach ($this->writerParts as $writer) {
-            $writer->setParentWriter($this);
+        // Create parts
+        $parts = array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles');
+        foreach ($parts as $part) {
+            $partName = strtolower($part);
+            $partClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Part\\' . $part;
+            if (class_exists($partClass)) {
+                $partObject = new $partClass();
+                $partObject->setParentWriter($this);
+                $this->writerParts[$partName] = $partObject;
+            }
         }
 
         // Set package paths
diff --git a/src/PhpWord/Writer/ODText/AbstractWriterPart.php b/src/PhpWord/Writer/ODText/AbstractWriterPart.php
deleted file mode 100644
index 1a5831e0c5..0000000000
--- a/src/PhpWord/Writer/ODText/AbstractWriterPart.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-/**
- * PHPWord
- *
- * @link        https://github.com/PHPOffice/PHPWord
- * @copyright   2014 PHPWord
- * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- */
-
-namespace PhpOffice\PhpWord\Writer\ODText;
-
-/**
- * ODText writer part abstract
- */
-abstract class AbstractWriterPart extends \PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart
-{
-}
diff --git a/src/PhpWord/Writer/ODText/Element/Element.php b/src/PhpWord/Writer/ODText/Element/Element.php
index 081aa95c6f..67ee9c2023 100644
--- a/src/PhpWord/Writer/ODText/Element/Element.php
+++ b/src/PhpWord/Writer/ODText/Element/Element.php
@@ -11,7 +11,7 @@
 
 use PhpOffice\PhpWord\Element\AbstractElement;
 use PhpOffice\PhpWord\Shared\XMLWriter;
-use PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart;
+use PhpOffice\PhpWord\Writer\ODText\Part\AbstractPart;
 
 /**
  * Generic element writer
@@ -30,7 +30,7 @@ class Element
     /**
      * Parent writer
      *
-     * @var \PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart
+     * @var \PhpOffice\PhpWord\Writer\ODText\AbstractPart
      */
     protected $parentWriter;
 
@@ -53,7 +53,7 @@ class Element
      *
      * @param bool $withoutP
      */
-    public function __construct(XMLWriter $xmlWriter, AbstractWriterPart $parentWriter, AbstractElement $element, $withoutP = false)
+    public function __construct(XMLWriter $xmlWriter, AbstractPart $parentWriter, AbstractElement $element, $withoutP = false)
     {
         $this->xmlWriter = $xmlWriter;
         $this->parentWriter = $parentWriter;
diff --git a/src/PhpWord/Writer/ODText/Element/TextRun.php b/src/PhpWord/Writer/ODText/Element/TextRun.php
index 591875838a..be4de23903 100644
--- a/src/PhpWord/Writer/ODText/Element/TextRun.php
+++ b/src/PhpWord/Writer/ODText/Element/TextRun.php
@@ -10,6 +10,7 @@
 namespace PhpOffice\PhpWord\Writer\ODText\Element;
 
 use PhpOffice\PhpWord\Element\Text as TextElement;
+use PhpOffice\PhpWord\Element\Link as LinkElement;
 use PhpOffice\PhpWord\Writer\ODText\Element\Element as ElementWriter;
 
 /**
diff --git a/src/PhpWord/Writer/ODText/Base.php b/src/PhpWord/Writer/ODText/Part/AbstractPart.php
similarity index 96%
rename from src/PhpWord/Writer/ODText/Base.php
rename to src/PhpWord/Writer/ODText/Part/AbstractPart.php
index d38aef2309..4aa5d79f9f 100644
--- a/src/PhpWord/Writer/ODText/Base.php
+++ b/src/PhpWord/Writer/ODText/Part/AbstractPart.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\ODText;
+namespace PhpOffice\PhpWord\Writer\ODText\Part;
 
 use PhpOffice\PhpWord\PhpWord;
 use PhpOffice\PhpWord\Style;
@@ -15,11 +15,9 @@
 use PhpOffice\PhpWord\Shared\XMLWriter;
 
 /**
- * ODT base part writer
- *
- * @since 0.10.0
+ * ODText writer part abstract
  */
-class Base extends AbstractWriterPart
+abstract class AbstractPart extends \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart
 {
     /**
      * Write common root attributes
diff --git a/src/PhpWord/Writer/ODText/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php
similarity index 99%
rename from src/PhpWord/Writer/ODText/Content.php
rename to src/PhpWord/Writer/ODText/Part/Content.php
index 69754e817a..6b4a86df11 100644
--- a/src/PhpWord/Writer/ODText/Content.php
+++ b/src/PhpWord/Writer/ODText/Part/Content.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\ODText;
+namespace PhpOffice\PhpWord\Writer\ODText\Part;
 
 use PhpOffice\PhpWord\Media;
 use PhpOffice\PhpWord\Style;
@@ -23,7 +23,7 @@
 /**
  * ODText content part writer
  */
-class Content extends Base
+class Content extends AbstractPart
 {
     /**
      * Write content file to XML format
diff --git a/src/PhpWord/Writer/ODText/Manifest.php b/src/PhpWord/Writer/ODText/Part/Manifest.php
similarity index 96%
rename from src/PhpWord/Writer/ODText/Manifest.php
rename to src/PhpWord/Writer/ODText/Part/Manifest.php
index c3fef79e64..4462e7ef62 100755
--- a/src/PhpWord/Writer/ODText/Manifest.php
+++ b/src/PhpWord/Writer/ODText/Part/Manifest.php
@@ -7,14 +7,14 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\ODText;
+namespace PhpOffice\PhpWord\Writer\ODText\Part;
 
 use PhpOffice\PhpWord\Media;
 
 /**
  * ODText manifest part writer
  */
-class Manifest extends AbstractWriterPart
+class Manifest extends AbstractPart
 {
     /**
      * Write Manifest file to XML format
diff --git a/src/PhpWord/Writer/ODText/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php
similarity index 97%
rename from src/PhpWord/Writer/ODText/Meta.php
rename to src/PhpWord/Writer/ODText/Part/Meta.php
index 3e04234c3f..355e288ba7 100644
--- a/src/PhpWord/Writer/ODText/Meta.php
+++ b/src/PhpWord/Writer/ODText/Part/Meta.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\ODText;
+namespace PhpOffice\PhpWord\Writer\ODText\Part;
 
 use PhpOffice\PhpWord\Exception\Exception;
 use PhpOffice\PhpWord\PhpWord;
@@ -15,7 +15,7 @@
 /**
  * ODText meta part writer
  */
-class Meta extends AbstractWriterPart
+class Meta extends AbstractPart
 {
     /**
      * Write Meta file to XML format
diff --git a/src/PhpWord/Writer/ODText/Mimetype.php b/src/PhpWord/Writer/ODText/Part/Mimetype.php
similarity index 83%
rename from src/PhpWord/Writer/ODText/Mimetype.php
rename to src/PhpWord/Writer/ODText/Part/Mimetype.php
index 269c377f5d..3c3af1a502 100644
--- a/src/PhpWord/Writer/ODText/Mimetype.php
+++ b/src/PhpWord/Writer/ODText/Part/Mimetype.php
@@ -7,12 +7,12 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\ODText;
+namespace PhpOffice\PhpWord\Writer\ODText\Part;
 
 /**
  * ODText mimetype part writer
  */
-class Mimetype extends AbstractWriterPart
+class Mimetype extends AbstractPart
 {
     /**
      * Write Mimetype to Text format
diff --git a/src/PhpWord/Writer/ODText/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php
similarity index 98%
rename from src/PhpWord/Writer/ODText/Styles.php
rename to src/PhpWord/Writer/ODText/Part/Styles.php
index f21502fc64..f53e1bf835 100644
--- a/src/PhpWord/Writer/ODText/Styles.php
+++ b/src/PhpWord/Writer/ODText/Part/Styles.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\ODText;
+namespace PhpOffice\PhpWord\Writer\ODText\Part;
 
 use PhpOffice\PhpWord\PhpWord;
 use PhpOffice\PhpWord\Style;
@@ -16,7 +16,7 @@
 /**
  * ODText styloes part writer
  */
-class Styles extends Base
+class Styles extends AbstractPart
 {
     /**
      * Write Styles file to XML format
diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php
index 6db8bcfcbb..b87f1d2441 100755
--- a/src/PhpWord/Writer/Word2007.php
+++ b/src/PhpWord/Writer/Word2007.php
@@ -13,17 +13,6 @@
 use PhpOffice\PhpWord\Media;
 use PhpOffice\PhpWord\Element\Section;
 use PhpOffice\PhpWord\Exception\Exception;
-use PhpOffice\PhpWord\Writer\Word2007\ContentTypes;
-use PhpOffice\PhpWord\Writer\Word2007\DocProps;
-use PhpOffice\PhpWord\Writer\Word2007\Document;
-use PhpOffice\PhpWord\Writer\Word2007\Footer;
-use PhpOffice\PhpWord\Writer\Word2007\Header;
-use PhpOffice\PhpWord\Writer\Word2007\Notes;
-use PhpOffice\PhpWord\Writer\Word2007\Numbering;
-use PhpOffice\PhpWord\Writer\Word2007\Rels;
-use PhpOffice\PhpWord\Writer\Word2007\Settings;
-use PhpOffice\PhpWord\Writer\Word2007\Styles;
-use PhpOffice\PhpWord\Writer\Word2007\WebSettings;
 
 /**
  * Word2007 writer
@@ -54,21 +43,18 @@ public function __construct(PhpWord $phpWord = null)
         // Assign PhpWord
         $this->setPhpWord($phpWord);
 
-        // Set writer parts
-        $this->writerParts['contenttypes'] = new ContentTypes();
-        $this->writerParts['rels'] = new Rels();
-        $this->writerParts['docprops'] = new DocProps();
-        $this->writerParts['document'] = new Document();
-        $this->writerParts['styles'] = new Styles();
-        $this->writerParts['numbering'] = new Numbering();
-        $this->writerParts['settings'] = new Settings();
-        $this->writerParts['websettings'] = new WebSettings();
-        $this->writerParts['header'] = new Header();
-        $this->writerParts['footer'] = new Footer();
-        $this->writerParts['footnotes'] = new Notes();
-        $this->writerParts['endnotes'] = new Notes();
-        foreach ($this->writerParts as $writer) {
-            $writer->setParentWriter($this);
+        // Create parts
+        $parts = array('ContentTypes', 'Rels', 'DocProps', 'Document', 'Styles',
+            'Numbering', 'Settings', 'WebSettings', 'Header', 'Footer', 'Footnotes',
+            'Endnotes', 'FontTable', 'Theme');
+        foreach ($parts as $part) {
+            $partName = strtolower($part);
+            $partClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Part\\' . $part;
+            if (class_exists($partClass)) {
+                $partObject = new $partClass();
+                $partObject->setParentWriter($this);
+                $this->writerParts[$partName] = $partObject;
+            }
         }
 
         // Set package paths
@@ -117,7 +103,7 @@ public function save($filename = null)
             $this->addNotes($objZip, $rId, 'footnote');
             $this->addNotes($objZip, $rId, 'endnote');
 
-            // Write dynamic files
+            // Write parts
             $objZip->addFromString('[Content_Types].xml', $this->getWriterPart('contenttypes')->writeContentTypes($this->cTypes));
             $objZip->addFromString('_rels/.rels', $this->getWriterPart('rels')->writeMainRels());
             $objZip->addFromString('docProps/app.xml', $this->getWriterPart('docprops')->writeDocPropsApp($this->phpWord));
@@ -128,10 +114,8 @@ public function save($filename = null)
             $objZip->addFromString('word/numbering.xml', $this->getWriterPart('numbering')->writeNumbering());
             $objZip->addFromString('word/settings.xml', $this->getWriterPart('settings')->writeSettings());
             $objZip->addFromString('word/webSettings.xml', $this->getWriterPart('websettings')->writeWebSettings());
-
-            // Write static files
-            $objZip->addFile(__DIR__ . '/../_staticDocParts/theme1.xml', 'word/theme/theme1.xml');
-            $objZip->addFile(__DIR__ . '/../_staticDocParts/fontTable.xml', 'word/fontTable.xml');
+            $objZip->addFromString('word/fontTable.xml', $this->getWriterPart('fonttable')->write());
+            $objZip->addFromString('word/theme/theme1.xml', $this->getWriterPart('theme')->write());
 
             // Close file
             if ($objZip->close() === false) {
@@ -215,7 +199,7 @@ private function addNotes($objZip, &$rId, $notesType = 'footnote')
                 $objZip->addFromString($relsFile, $this->getWriterPart('rels')->writeMediaRels($media));
             }
             $elements = $collection::getElements();
-            $objZip->addFromString($xmlPath, $this->getWriterPart($notesTypes)->writeNotes($elements, $notesTypes));
+            $objZip->addFromString($xmlPath, $this->getWriterPart($notesTypes)->write($elements));
             $this->cTypes['override']["/{$xmlPath}"] = $notesTypes;
             $this->docRels[] = array('target' => $xmlFile, 'type' => $notesTypes, 'rID' => ++$rId);
         }
diff --git a/src/PhpWord/Writer/Word2007/AbstractWriterPart.php b/src/PhpWord/Writer/Word2007/AbstractWriterPart.php
deleted file mode 100755
index bef7bd8bff..0000000000
--- a/src/PhpWord/Writer/Word2007/AbstractWriterPart.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-/**
- * PHPWord
- *
- * @link        https://github.com/PHPOffice/PHPWord
- * @copyright   2014 PHPWord
- * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- */
-
-namespace PhpOffice\PhpWord\Writer\Word2007;
-
-use PhpOffice\PhpWord\Exception\Exception;
-use PhpOffice\PhpWord\Shared\XMLWriter;
-use PhpOffice\PhpWord\Writer\WriterInterface;
-
-/**
- * Word2007 writer part abstract class
- */
-abstract class AbstractWriterPart
-{
-    /**
-     * Parent writer
-     *
-     * @var \PhpOffice\PhpWord\Writer\WriterInterface
-     */
-    protected $parentWriter;
-
-    /**
-     * Set parent writer
-     *
-     * @param \PhpOffice\PhpWord\Writer\WriterInterface $pWriter
-     */
-    public function setParentWriter(WriterInterface $pWriter = null)
-    {
-        $this->parentWriter = $pWriter;
-    }
-
-    /**
-     * Get parent writer
-     *
-     * @return \PhpOffice\PhpWord\Writer\WriterInterface
-     * @throws \PhpOffice\PhpWord\Exception\Exception
-     */
-    public function getParentWriter()
-    {
-        if (!is_null($this->parentWriter)) {
-            return $this->parentWriter;
-        } else {
-            throw new Exception("No parent WriterInterface assigned.");
-        }
-    }
-
-    /**
-     * Get XML Writer
-     *
-     * @return \PhpOffice\PhpWord\Shared\XMLWriter
-     */
-    protected function getXmlWriter()
-    {
-        $useDiskCaching = false;
-        if (!is_null($this->parentWriter)) {
-            if ($this->parentWriter->getUseDiskCaching()) {
-                $useDiskCaching = true;
-            }
-        }
-        if ($useDiskCaching) {
-            return new XMLWriter(XMLWriter::STORAGE_DISK, $this->parentWriter->getDiskCachingDirectory());
-        } else {
-            return new XMLWriter(XMLWriter::STORAGE_MEMORY);
-        }
-    }
-}
diff --git a/src/PhpWord/Writer/Word2007/Element/Element.php b/src/PhpWord/Writer/Word2007/Element/Element.php
index f456a10655..9c91beb781 100644
--- a/src/PhpWord/Writer/Word2007/Element/Element.php
+++ b/src/PhpWord/Writer/Word2007/Element/Element.php
@@ -11,7 +11,7 @@
 
 use PhpOffice\PhpWord\Element\AbstractElement;
 use PhpOffice\PhpWord\Shared\XMLWriter;
-use PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart;
+use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart;
 
 /**
  * Generic element writer
@@ -30,7 +30,7 @@ class Element
     /**
      * Parent writer
      *
-     * @var \PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart
+     * @var \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart
      */
     protected $parentWriter;
 
@@ -53,7 +53,7 @@ class Element
      *
      * @param bool $withoutP
      */
-    public function __construct(XMLWriter $xmlWriter, AbstractWriterPart $parentWriter, AbstractElement $element, $withoutP = false)
+    public function __construct(XMLWriter $xmlWriter, AbstractPart $parentWriter, AbstractElement $element, $withoutP = false)
     {
         $this->xmlWriter = $xmlWriter;
         $this->parentWriter = $parentWriter;
diff --git a/src/PhpWord/Writer/Word2007/Base.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
old mode 100644
new mode 100755
similarity index 62%
rename from src/PhpWord/Writer/Word2007/Base.php
rename to src/PhpWord/Writer/Word2007/Part/AbstractPart.php
index bae184109f..afa84caf8f
--- a/src/PhpWord/Writer/Word2007/Base.php
+++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\PhpWord;
 use PhpOffice\PhpWord\Element\AbstractElement;
@@ -15,14 +15,65 @@
 use PhpOffice\PhpWord\Exception\Exception;
 use PhpOffice\PhpWord\Shared\XMLWriter;
 use PhpOffice\PhpWord\Writer\Word2007\Element\Element as ElementWriter;
+use PhpOffice\PhpWord\Writer\WriterInterface;
 
 /**
- * Word2007 base part writer
- *
- * Write common parts of document.xml, headerx.xml, and footerx.xml
+ * Word2007 writer part abstract class
  */
-class Base extends AbstractWriterPart
+abstract class AbstractPart
 {
+    /**
+     * Parent writer
+     *
+     * @var \PhpOffice\PhpWord\Writer\WriterInterface
+     */
+    protected $parentWriter;
+
+    /**
+     * Set parent writer
+     *
+     * @param \PhpOffice\PhpWord\Writer\WriterInterface $pWriter
+     */
+    public function setParentWriter(WriterInterface $pWriter = null)
+    {
+        $this->parentWriter = $pWriter;
+    }
+
+    /**
+     * Get parent writer
+     *
+     * @return \PhpOffice\PhpWord\Writer\WriterInterface
+     * @throws \PhpOffice\PhpWord\Exception\Exception
+     */
+    public function getParentWriter()
+    {
+        if (!is_null($this->parentWriter)) {
+            return $this->parentWriter;
+        } else {
+            throw new Exception("No parent WriterInterface assigned.");
+        }
+    }
+
+    /**
+     * Get XML Writer
+     *
+     * @return \PhpOffice\PhpWord\Shared\XMLWriter
+     */
+    protected function getXmlWriter()
+    {
+        $useDiskCaching = false;
+        if (!is_null($this->parentWriter)) {
+            if ($this->parentWriter->getUseDiskCaching()) {
+                $useDiskCaching = true;
+            }
+        }
+        if ($useDiskCaching) {
+            return new XMLWriter(XMLWriter::STORAGE_DISK, $this->parentWriter->getDiskCachingDirectory());
+        } else {
+            return new XMLWriter(XMLWriter::STORAGE_MEMORY);
+        }
+    }
+
     /**
      * Write container elements
      *
diff --git a/src/PhpWord/Writer/Word2007/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php
similarity index 97%
rename from src/PhpWord/Writer/Word2007/ContentTypes.php
rename to src/PhpWord/Writer/Word2007/Part/ContentTypes.php
index 05f4b4b933..00e05c7619 100755
--- a/src/PhpWord/Writer/Word2007/ContentTypes.php
+++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\Exception\Exception;
 use PhpOffice\PhpWord\Shared\XMLWriter;
@@ -15,7 +15,7 @@
 /**
  * Word2007 contenttypes part writer
  */
-class ContentTypes extends AbstractWriterPart
+class ContentTypes extends AbstractPart
 {
     /**
      * Write [Content_Types].xml
diff --git a/src/PhpWord/Writer/Word2007/DocProps.php b/src/PhpWord/Writer/Word2007/Part/DocProps.php
similarity index 97%
rename from src/PhpWord/Writer/Word2007/DocProps.php
rename to src/PhpWord/Writer/Word2007/Part/DocProps.php
index 28102e18c5..ade15c0afd 100644
--- a/src/PhpWord/Writer/Word2007/DocProps.php
+++ b/src/PhpWord/Writer/Word2007/Part/DocProps.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\PhpWord;
 use PhpOffice\PhpWord\Exception\Exception;
@@ -15,7 +15,7 @@
 /**
  * Word2007 document properties part writer
  */
-class DocProps extends AbstractWriterPart
+class DocProps extends AbstractPart
 {
     /**
      * Write docProps/app.xml
diff --git a/src/PhpWord/Writer/Word2007/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php
similarity index 98%
rename from src/PhpWord/Writer/Word2007/Document.php
rename to src/PhpWord/Writer/Word2007/Part/Document.php
index cb64168ec5..2b30ee54b4 100644
--- a/src/PhpWord/Writer/Word2007/Document.php
+++ b/src/PhpWord/Writer/Word2007/Part/Document.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\PhpWord;
 use PhpOffice\PhpWord\Element\Section;
@@ -17,7 +17,7 @@
 /**
  * Word2007 document part writer
  */
-class Document extends Base
+class Document extends AbstractPart
 {
     /**
      * Write word/document.xml
diff --git a/src/PhpWord/Writer/Word2007/Part/Endnotes.php b/src/PhpWord/Writer/Word2007/Part/Endnotes.php
new file mode 100644
index 0000000000..9cecf4028d
--- /dev/null
+++ b/src/PhpWord/Writer/Word2007/Part/Endnotes.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * PHPWord
+ *
+ * @link        https://github.com/PHPOffice/PHPWord
+ * @copyright   2014 PHPWord
+ * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ */
+
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
+
+/**
+ * Word2007 endnotes part writer
+ */
+class Endnotes extends Footnotes
+{
+    /**
+     * Name of XML root element
+     *
+     * @var string
+     */
+    protected $rootNode = 'w:endnotes';
+
+    /**
+     * Name of XML node element
+     *
+     * @var string
+     */
+    protected $elementNode = 'w:endnote';
+
+    /**
+     * Name of XML reference element
+     *
+     * @var string
+     */
+    protected $refNode = 'w:endnoteRef';
+
+    /**
+     * Reference style name
+     *
+     * @var string
+     */
+    protected $refStyle = 'EndnoteReference';
+}
diff --git a/src/PhpWord/_staticDocParts/fontTable.xml b/src/PhpWord/Writer/Word2007/Part/FontTable.php
similarity index 78%
rename from src/PhpWord/_staticDocParts/fontTable.xml
rename to src/PhpWord/Writer/Word2007/Part/FontTable.php
index a2e183c453..9493dc0731 100644
--- a/src/PhpWord/_staticDocParts/fontTable.xml
+++ b/src/PhpWord/Writer/Word2007/Part/FontTable.php
@@ -1,2 +1,27 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<w:fonts xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:font w:name="Times New Roman"><w:panose1 w:val="02020603050405020304"/><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="E0002AFF" w:usb1="C0007841" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Courier New"><w:panose1 w:val="02070309020205020404"/><w:charset w:val="00"/><w:family w:val="modern"/><w:pitch w:val="fixed"/><w:sig w:usb0="E0002AFF" w:usb1="C0007843" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Wingdings"><w:panose1 w:val="05000000000000000000"/><w:charset w:val="02"/><w:family w:val="auto"/><w:pitch w:val="variable"/><w:sig w:usb0="00000000" w:usb1="10000000" w:usb2="00000000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000"/></w:font><w:font w:name="Symbol"><w:panose1 w:val="05050102010706020507"/><w:charset w:val="02"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="00000000" w:usb1="10000000" w:usb2="00000000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000"/></w:font><w:font w:name="Arial"><w:panose1 w:val="020B0604020202020204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/><w:sig w:usb0="E0002AFF" w:usb1="C0007843" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Cambria"><w:panose1 w:val="02040503050406030204"/><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="A00002EF" w:usb1="4000004B" w:usb2="00000000" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/></w:font><w:font w:name="Calibri"><w:panose1 w:val="020F0502020204030204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/><w:sig w:usb0="E10002FF" w:usb1="4000ACFF" w:usb2="00000009" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/></w:font></w:fonts>
\ No newline at end of file
+<?php
+/**
+ * PHPWord
+ *
+ * @link        https://github.com/PHPOffice/PHPWord
+ * @copyright   2014 PHPWord
+ * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ */
+
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
+
+/**
+ * Word2007 font table writer
+ *
+ * @since 0.10.0
+ */
+class FontTable extends AbstractPart
+{
+    /**
+     * Write fontTable.xml
+     */
+    public function write()
+    {
+        return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<w:fonts xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:font w:name="Times New Roman"><w:panose1 w:val="02020603050405020304"/><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="E0002AFF" w:usb1="C0007841" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Courier New"><w:panose1 w:val="02070309020205020404"/><w:charset w:val="00"/><w:family w:val="modern"/><w:pitch w:val="fixed"/><w:sig w:usb0="E0002AFF" w:usb1="C0007843" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Wingdings"><w:panose1 w:val="05000000000000000000"/><w:charset w:val="02"/><w:family w:val="auto"/><w:pitch w:val="variable"/><w:sig w:usb0="00000000" w:usb1="10000000" w:usb2="00000000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000"/></w:font><w:font w:name="Symbol"><w:panose1 w:val="05050102010706020507"/><w:charset w:val="02"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="00000000" w:usb1="10000000" w:usb2="00000000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000"/></w:font><w:font w:name="Arial"><w:panose1 w:val="020B0604020202020204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/><w:sig w:usb0="E0002AFF" w:usb1="C0007843" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Cambria"><w:panose1 w:val="02040503050406030204"/><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="A00002EF" w:usb1="4000004B" w:usb2="00000000" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/></w:font><w:font w:name="Calibri"><w:panose1 w:val="020F0502020204030204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/><w:sig w:usb0="E10002FF" w:usb1="4000ACFF" w:usb2="00000009" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/></w:font></w:fonts>';
+    }
+}
diff --git a/src/PhpWord/Writer/Word2007/Footer.php b/src/PhpWord/Writer/Word2007/Part/Footer.php
similarity index 95%
rename from src/PhpWord/Writer/Word2007/Footer.php
rename to src/PhpWord/Writer/Word2007/Part/Footer.php
index 76a66cc078..f31ece860c 100644
--- a/src/PhpWord/Writer/Word2007/Footer.php
+++ b/src/PhpWord/Writer/Word2007/Part/Footer.php
@@ -7,14 +7,14 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\Element\Footer as FooterElement;
 
 /**
  * Word2007 footer part writer
  */
-class Footer extends Base
+class Footer extends AbstractPart
 {
     /**
      * Write word/footnotes.xml
diff --git a/src/PhpWord/Writer/Word2007/Notes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php
similarity index 72%
rename from src/PhpWord/Writer/Word2007/Notes.php
rename to src/PhpWord/Writer/Word2007/Part/Footnotes.php
index cb86628293..2356849e07 100644
--- a/src/PhpWord/Writer/Word2007/Notes.php
+++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php
@@ -7,33 +7,56 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\Element\Footnote;
-use PhpOffice\PhpWord\Element\Endnote;
 use PhpOffice\PhpWord\Shared\XMLWriter;
 use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;
 
 /**
  * Word2007 footnotes part writer
  */
-class Notes extends Base
+class Footnotes extends AbstractPart
 {
+    /**
+     * Name of XML root element
+     *
+     * @var string
+     */
+    protected $rootNode = 'w:footnotes';
+
+    /**
+     * Name of XML node element
+     *
+     * @var string
+     */
+    protected $elementNode = 'w:footnote';
+
+    /**
+     * Name of XML reference element
+     *
+     * @var string
+     */
+    protected $refNode = 'w:footnoteRef';
+
+    /**
+     * Reference style name
+     *
+     * @var string
+     */
+    protected $refStyle = 'FootnoteReference';
+
     /**
      * Write word/(footnotes|endnotes).xml
      *
      * @param array $elements
-     * @param string $notesTypes
      */
-    public function writeNotes($elements, $notesTypes = 'footnotes')
+    public function write($elements)
     {
-        $isFootnote = $notesTypes == 'footnotes';
-        $rootNode = $isFootnote ? 'w:footnotes' : 'w:endnotes';
-        $elementNode = $isFootnote ? 'w:footnote' : 'w:endnote';
         $xmlWriter = $this->getXmlWriter();
 
         $xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
-        $xmlWriter->startElement($rootNode);
+        $xmlWriter->startElement($this->rootNode);
         $xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
         $xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
         $xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
@@ -45,7 +68,7 @@ public function writeNotes($elements, $notesTypes = 'footnotes')
         $xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
 
         // Separator and continuation separator
-        $xmlWriter->startElement($elementNode);
+        $xmlWriter->startElement($this->elementNode);
         $xmlWriter->writeAttribute('w:id', -1);
         $xmlWriter->writeAttribute('w:type', 'separator');
         $xmlWriter->startElement('w:p');
@@ -54,8 +77,8 @@ public function writeNotes($elements, $notesTypes = 'footnotes')
         $xmlWriter->endElement(); // w:separator
         $xmlWriter->endElement(); // w:r
         $xmlWriter->endElement(); // w:p
-        $xmlWriter->endElement(); // $elementNode
-        $xmlWriter->startElement($elementNode);
+        $xmlWriter->endElement(); // $this->elementNode
+        $xmlWriter->startElement($this->elementNode);
         $xmlWriter->writeAttribute('w:id', 0);
         $xmlWriter->writeAttribute('w:type', 'continuationSeparator');
         $xmlWriter->startElement('w:p');
@@ -64,16 +87,16 @@ public function writeNotes($elements, $notesTypes = 'footnotes')
         $xmlWriter->endElement(); // w:continuationSeparator
         $xmlWriter->endElement(); // w:r
         $xmlWriter->endElement(); // w:p
-        $xmlWriter->endElement(); // $elementNode
+        $xmlWriter->endElement(); // $this->elementNode
 
         // Content
         foreach ($elements as $element) {
-            if ($element instanceof Footnote || $element instanceof Endnote) {
-                $this->writeNote($xmlWriter, $element, $notesTypes);
+            if ($element instanceof Footnote) {
+                $this->writeNote($xmlWriter, $element);
             }
         }
 
-        $xmlWriter->endElement(); // $rootNode
+        $xmlWriter->endElement(); // $this->rootNode
 
         return $xmlWriter->getData();
     }
@@ -83,16 +106,10 @@ public function writeNotes($elements, $notesTypes = 'footnotes')
      *
      * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
      * @param \PhpOffice\PhpWord\Element\Footnote|\PhpOffice\PhpWord\Element\Endnote $element
-          * @param string $notesTypes
      */
-    protected function writeNote(XMLWriter $xmlWriter, $element, $notesTypes = 'footnotes')
+    protected function writeNote(XMLWriter $xmlWriter, $element)
     {
-        $isFootnote = ($notesTypes == 'footnotes');
-        $elementNode = $isFootnote ? 'w:footnote' : 'w:endnote';
-        $refNode = $isFootnote ? 'w:footnoteRef' : 'w:endnoteRef';
-        $styleName = $isFootnote ? 'FootnoteReference' : 'EndnoteReference';
-
-        $xmlWriter->startElement($elementNode);
+        $xmlWriter->startElement($this->elementNode);
         $xmlWriter->writeAttribute('w:id', $element->getRelationId());
         $xmlWriter->startElement('w:p');
 
@@ -105,10 +122,10 @@ protected function writeNote(XMLWriter $xmlWriter, $element, $notesTypes = 'foot
         $xmlWriter->startElement('w:r');
         $xmlWriter->startElement('w:rPr');
         $xmlWriter->startElement('w:rStyle');
-        $xmlWriter->writeAttribute('w:val', $styleName);
+        $xmlWriter->writeAttribute('w:val', $this->refStyle);
         $xmlWriter->endElement(); // w:rStyle
         $xmlWriter->endElement(); // w:rPr
-        $xmlWriter->writeElement($refNode);
+        $xmlWriter->writeElement($this->refNode);
         $xmlWriter->endElement(); // w:r
 
         // Empty space after refence symbol
@@ -122,6 +139,6 @@ protected function writeNote(XMLWriter $xmlWriter, $element, $notesTypes = 'foot
         $this->writeContainerElements($xmlWriter, $element);
 
         $xmlWriter->endElement(); // w:p
-        $xmlWriter->endElement(); // $elementNode
+        $xmlWriter->endElement(); // $this->elementNode
     }
 }
diff --git a/src/PhpWord/Writer/Word2007/Header.php b/src/PhpWord/Writer/Word2007/Part/Header.php
similarity index 95%
rename from src/PhpWord/Writer/Word2007/Header.php
rename to src/PhpWord/Writer/Word2007/Part/Header.php
index 6823c434d7..d2af19da29 100644
--- a/src/PhpWord/Writer/Word2007/Header.php
+++ b/src/PhpWord/Writer/Word2007/Part/Header.php
@@ -7,14 +7,14 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\Element\Header as HeaderElement;
 
 /**
  * Word2007 header part writer
  */
-class Header extends Base
+class Header extends AbstractPart
 {
     /**
      * Write word/headerx.xml
diff --git a/src/PhpWord/Writer/Word2007/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php
similarity index 98%
rename from src/PhpWord/Writer/Word2007/Numbering.php
rename to src/PhpWord/Writer/Word2007/Part/Numbering.php
index 26d86ef5aa..ea1b699bf6 100644
--- a/src/PhpWord/Writer/Word2007/Numbering.php
+++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\Style;
 use PhpOffice\PhpWord\Style\Numbering as NumberingStyle;
@@ -16,7 +16,7 @@
 /**
  * Word2007 numbering part writer
  */
-class Numbering extends Base
+class Numbering extends AbstractPart
 {
     /**
      * Write word/numbering.xml
diff --git a/src/PhpWord/Writer/Word2007/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php
similarity index 98%
rename from src/PhpWord/Writer/Word2007/Rels.php
rename to src/PhpWord/Writer/Word2007/Part/Rels.php
index 58e510fd06..8771b0f6ab 100755
--- a/src/PhpWord/Writer/Word2007/Rels.php
+++ b/src/PhpWord/Writer/Word2007/Part/Rels.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\Exception\Exception;
 use PhpOffice\PhpWord\Shared\XMLWriter;
@@ -17,7 +17,7 @@
  *
  * @since 0.10.0
  */
-class Rels extends AbstractWriterPart
+class Rels extends AbstractPart
 {
     /**
      * Base relationship URL
diff --git a/src/PhpWord/Writer/Word2007/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php
similarity index 98%
rename from src/PhpWord/Writer/Word2007/Settings.php
rename to src/PhpWord/Writer/Word2007/Part/Settings.php
index 918229c112..81a5967929 100644
--- a/src/PhpWord/Writer/Word2007/Settings.php
+++ b/src/PhpWord/Writer/Word2007/Part/Settings.php
@@ -7,14 +7,14 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\Shared\XMLWriter;
 
 /**
  * Word2007 settings part writer
  */
-class Settings extends AbstractWriterPart
+class Settings extends AbstractPart
 {
     /**
      * Write word/settings.xml
diff --git a/src/PhpWord/Writer/Word2007/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php
similarity index 99%
rename from src/PhpWord/Writer/Word2007/Styles.php
rename to src/PhpWord/Writer/Word2007/Part/Styles.php
index dd48aa7d34..579ae8e5c8 100644
--- a/src/PhpWord/Writer/Word2007/Styles.php
+++ b/src/PhpWord/Writer/Word2007/Part/Styles.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\PhpWord;
 use PhpOffice\PhpWord\Style;
@@ -25,7 +25,7 @@
  *
  * @todo Do something with the numbering style introduced in 0.10.0
  */
-class Styles extends Base
+class Styles extends AbstractPart
 {
     /**
      * Write word/styles.xml
diff --git a/src/PhpWord/_staticDocParts/theme1.xml b/src/PhpWord/Writer/Word2007/Part/Theme.php
similarity index 93%
rename from src/PhpWord/_staticDocParts/theme1.xml
rename to src/PhpWord/Writer/Word2007/Part/Theme.php
index 4fab507b66..2e0b4c9911 100644
--- a/src/PhpWord/_staticDocParts/theme1.xml
+++ b/src/PhpWord/Writer/Word2007/Part/Theme.php
@@ -1,2 +1,27 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink><a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS ゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Angsana New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS 明朝"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Cordia New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>
\ No newline at end of file
+<?php
+/**
+ * PHPWord
+ *
+ * @link        https://github.com/PHPOffice/PHPWord
+ * @copyright   2014 PHPWord
+ * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ */
+
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
+
+/**
+ * Word2007 theme writer
+ *
+ * @since 0.10.0
+ */
+class Theme extends AbstractPart
+{
+    /**
+     * Write theme/theme1.xml
+     */
+    public function write()
+    {
+        return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink><a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS ゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Angsana New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS 明朝"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Cordia New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>';
+    }
+}
diff --git a/src/PhpWord/Writer/Word2007/WebSettings.php b/src/PhpWord/Writer/Word2007/Part/WebSettings.php
similarity index 95%
rename from src/PhpWord/Writer/Word2007/WebSettings.php
rename to src/PhpWord/Writer/Word2007/Part/WebSettings.php
index f52be90980..b1b5cc15cb 100644
--- a/src/PhpWord/Writer/Word2007/WebSettings.php
+++ b/src/PhpWord/Writer/Word2007/Part/WebSettings.php
@@ -7,7 +7,7 @@
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
 
-namespace PhpOffice\PhpWord\Writer\Word2007;
+namespace PhpOffice\PhpWord\Writer\Word2007\Part;
 
 /**
  * Word2007 web settings part writer
diff --git a/src/PhpWord/_staticDocParts/_doc.png b/src/PhpWord/resources/doc.png
similarity index 100%
rename from src/PhpWord/_staticDocParts/_doc.png
rename to src/PhpWord/resources/doc.png
diff --git a/src/PhpWord/_staticDocParts/_ppt.png b/src/PhpWord/resources/ppt.png
similarity index 100%
rename from src/PhpWord/_staticDocParts/_ppt.png
rename to src/PhpWord/resources/ppt.png
diff --git a/src/PhpWord/_staticDocParts/_xls.png b/src/PhpWord/resources/xls.png
similarity index 100%
rename from src/PhpWord/_staticDocParts/_xls.png
rename to src/PhpWord/resources/xls.png
diff --git a/tests/PhpWord/Tests/Writer/ODText/AbstractWriterPartTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php
similarity index 71%
rename from tests/PhpWord/Tests/Writer/ODText/AbstractWriterPartTest.php
rename to tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php
index a88630878f..bde6b4136a 100644
--- a/tests/PhpWord/Tests/Writer/ODText/AbstractWriterPartTest.php
+++ b/tests/PhpWord/Tests/Writer/ODText/Part/AbstractPartTest.php
@@ -6,18 +6,18 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\ODText;
+namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part;
 
 use PhpOffice\PhpWord\Writer\ODText;
 use PhpWord\Tests\TestHelperDOCX;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart
+ * Test class for PhpOffice\PhpWord\Writer\ODText\Part\AbstractPart
  *
- * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart
+ * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Part\AbstractPart
  * @runTestsInSeparateProcesses
  */
-class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
+class AbstractPartTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * covers   ::setParentWriter
@@ -26,7 +26,7 @@ class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
     public function testSetGetParentWriter()
     {
         $object = $this->getMockForAbstractClass(
-            'PhpOffice\\PhpWord\\Writer\\ODText\\AbstractWriterPart'
+            'PhpOffice\\PhpWord\\Writer\\ODText\\Part\\AbstractPart'
         );
         $object->setParentWriter(new ODText());
         $this->assertEquals(
@@ -43,7 +43,7 @@ public function testSetGetParentWriter()
     public function testSetGetParentWriterNull()
     {
         $object = $this->getMockForAbstractClass(
-            'PhpOffice\\PhpWord\\Writer\\ODText\\AbstractWriterPart'
+            'PhpOffice\\PhpWord\\Writer\\ODText\\Part\\AbstractPart'
         );
         $object->getParentWriter();
     }
diff --git a/tests/PhpWord/Tests/Writer/ODText/ContentTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php
similarity index 88%
rename from tests/PhpWord/Tests/Writer/ODText/ContentTest.php
rename to tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php
index e4f67102cd..ebbfe470b6 100644
--- a/tests/PhpWord/Tests/Writer/ODText/ContentTest.php
+++ b/tests/PhpWord/Tests/Writer/ODText/Part/ContentTest.php
@@ -6,16 +6,16 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\ODText;
+namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part;
 
 use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Writer\ODText\Content;
+use PhpOffice\PhpWord\Writer\ODText\Part\Content;
 use PhpOffice\PhpWord\Tests\TestHelperDOCX;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\ODText\Content
+ * Test class for PhpOffice\PhpWord\Writer\ODText\Part\Content
  *
- * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Content
+ * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Part\Content
  * @runTestsInSeparateProcesses
  */
 class ContentTest extends \PHPUnit_Framework_TestCase
@@ -45,8 +45,8 @@ public function testConstructNoPhpWord()
      */
     public function testWriteContent()
     {
-        $imageSrc = __DIR__ . "/../../_files/images/PhpWord.png";
-        $objectSrc = __DIR__ . "/../../_files/documents/sheet.xls";
+        $imageSrc = __DIR__ . "/../../../_files/images/PhpWord.png";
+        $objectSrc = __DIR__ . "/../../../_files/documents/sheet.xls";
         $expected = 'Expected';
 
         $phpWord = new PhpWord();
diff --git a/tests/PhpWord/Tests/Writer/ODText/MetaTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php
similarity index 71%
rename from tests/PhpWord/Tests/Writer/ODText/MetaTest.php
rename to tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php
index 9be324116d..fde045793f 100644
--- a/tests/PhpWord/Tests/Writer/ODText/MetaTest.php
+++ b/tests/PhpWord/Tests/Writer/ODText/Part/MetaTest.php
@@ -6,14 +6,14 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\ODText;
+namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part;
 
-use PhpOffice\PhpWord\Writer\ODText\Meta;
+use PhpOffice\PhpWord\Writer\ODText\Part\Meta;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\ODText\Meta
+ * Test class for PhpOffice\PhpWord\Writer\ODText\Part\Meta
  *
- * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Meta
+ * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Part\Meta
  * @runTestsInSeparateProcesses
  */
 class MetaTest extends \PHPUnit_Framework_TestCase
diff --git a/tests/PhpWord/Tests/Writer/ODText/StylesTest.php b/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php
similarity index 71%
rename from tests/PhpWord/Tests/Writer/ODText/StylesTest.php
rename to tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php
index aa2ce0fae3..556bc80473 100644
--- a/tests/PhpWord/Tests/Writer/ODText/StylesTest.php
+++ b/tests/PhpWord/Tests/Writer/ODText/Part/StylesTest.php
@@ -6,14 +6,14 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\ODText;
+namespace PhpOffice\PhpWord\Tests\Writer\Part\ODText;
 
-use PhpOffice\PhpWord\Writer\ODText\Styles;
+use PhpOffice\PhpWord\Writer\ODText\Part\Styles;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\ODText\Styles
+ * Test class for PhpOffice\PhpWord\Writer\ODText\Part\Styles
  *
- * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Styles
+ * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Part\Styles
  * @runTestsInSeparateProcesses
  */
 class StylesTest extends \PHPUnit_Framework_TestCase
diff --git a/tests/PhpWord/Tests/Writer/ODTextTest.php b/tests/PhpWord/Tests/Writer/ODTextTest.php
index fad3a6c062..b02c3f9f19 100644
--- a/tests/PhpWord/Tests/Writer/ODTextTest.php
+++ b/tests/PhpWord/Tests/Writer/ODTextTest.php
@@ -30,7 +30,7 @@ public function testConstruct()
         $this->assertEquals('./', $object->getDiskCachingDirectory());
         foreach (array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles') as $part) {
             $this->assertInstanceOf(
-                "PhpOffice\\PhpWord\\Writer\\ODText\\{$part}",
+                "PhpOffice\\PhpWord\\Writer\\ODText\\Part\\{$part}",
                 $object->getWriterPart($part)
             );
             $this->assertInstanceOf(
diff --git a/tests/PhpWord/Tests/Writer/Word2007/DocumentTest.php b/tests/PhpWord/Tests/Writer/Word2007/DocumentTest.php
deleted file mode 100644
index 6b783dea5e..0000000000
--- a/tests/PhpWord/Tests/Writer/Word2007/DocumentTest.php
+++ /dev/null
@@ -1,141 +0,0 @@
-<?php
-/**
- * PHPWord
- *
- * @link        https://github.com/PHPOffice/PHPWord
- * @copyright   2014 PHPWord
- * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- */
-namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
-
-use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Style\Font;
-use PhpOffice\PhpWord\Tests\TestHelperDOCX;
-use PhpOffice\PhpWord\Writer\Word2007\Document;
-
-/**
- * Test class for PhpOffice\PhpWord\Writer\Word2007\Document
- *
- * @runTestsInSeparateProcesses
- */
-class DocumentTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * Executed before each method of the class
-     */
-    public function tearDown()
-    {
-        TestHelperDOCX::clear();
-    }
-
-    /**
-     * Test write word/document.xm with no PhpWord
-     *
-     * @expectedException \PhpOffice\PhpWord\Exception\Exception
-     * @expectedExceptionMessage No PhpWord assigned.
-     */
-    public function testWriteDocumentNoPhpWord()
-    {
-        $object = new Document();
-        $object->writeDocument();
-    }
-
-    /**
-     * Write end section page numbering
-     */
-    public function testWriteEndSectionPageNumbering()
-    {
-        $phpWord = new PhpWord();
-        $section = $phpWord->addSection();
-        $settings = $section->getSettings();
-        $settings->setLandscape();
-        $settings->setPageNumberingStart(2);
-        $settings->setBorderSize(240);
-        $settings->setBreakType('nextPage');
-
-        $doc = TestHelperDOCX::getDocument($phpWord);
-        $element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType');
-
-        $this->assertEquals(2, $element->getAttribute('w:start'));
-    }
-
-    /**
-     * Write elements
-     */
-    public function testElements()
-    {
-        $objectSrc = __DIR__ . "/../../_files/documents/sheet.xls";
-
-        $phpWord = new PhpWord();
-        $phpWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true));
-        $phpWord->addTitleStyle(2, array('color'=>'666666'));
-        $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->addSection();
-        $section->addTitle('Title 2', 2);
-        $section->addObject($objectSrc);
-        $doc = TestHelperDOCX::getDocument($phpWord);
-
-        // TOC
-        $element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:tabs/w:tab');
-        $this->assertEquals('right', $element->getAttribute('w:val'));
-        $this->assertEquals('dot', $element->getAttribute('w:leader'));
-        $this->assertEquals(9062, $element->getAttribute('w:pos'));
-
-        // Page break
-        $element = $doc->getElement('/w:document/w:body/w:p[4]/w:r/w:br');
-        $this->assertEquals('page', $element->getAttribute('w:type'));
-
-        // Title
-        $element = $doc->getElement('/w:document/w:body/w:p[5]/w:pPr/w:pStyle');
-        $this->assertEquals('Heading1', $element->getAttribute('w:val'));
-
-        // List item
-        $element = $doc->getElement('/w:document/w:body/w:p[6]/w:pPr/w:numPr/w:numId');
-        $this->assertEquals(3, $element->getAttribute('w:val'));
-
-        // Object
-        $element = $doc->getElement('/w:document/w:body/w:p[11]/w:r/w:object/o:OLEObject');
-        $this->assertEquals('Embed', $element->getAttribute('Type'));
-    }
-
-    /**
-     * Write element with some styles
-     */
-    public function testElementStyles()
-    {
-        $objectSrc = __DIR__ . "/../../_files/documents/sheet.xls";
-
-        $phpWord = new PhpWord();
-        $phpWord->addParagraphStyle('pStyle', array('align' => 'center')); // Style #1
-        $phpWord->addFontStyle('fStyle', array('size' => '20')); // Style #2
-        $phpWord->addTitleStyle(1, array('color' => '333333', 'bold' => true)); // Style #3
-        $fontStyle = new Font('text', array('align' => 'center'));
-        $section = $phpWord->addSection();
-        $section->addListItem('List Item', 0, null, null, 'pStyle'); // Style #4
-        $section->addObject($objectSrc, array('align' => 'center'));
-        $section->addTOC($fontStyle);
-        $section->addTitle('Title 1', 1);
-        $section->addTOC('fStyle');
-        $doc = TestHelperDOCX::getDocument($phpWord);
-
-        // List item
-        $element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:numPr/w:numId');
-        $this->assertEquals(4, $element->getAttribute('w:val'));
-
-        // Object
-        $element = $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject');
-        $this->assertEquals('Embed', $element->getAttribute('Type'));
-
-        // TOC
-        $element = $doc->getElement('/w:document/w:body/w:p[3]/w:pPr/w:tabs/w:tab');
-        $this->assertEquals('right', $element->getAttribute('w:val'));
-        $this->assertEquals('dot', $element->getAttribute('w:leader'));
-        $this->assertEquals(9062, $element->getAttribute('w:pos'));
-    }
-}
diff --git a/tests/PhpWord/Tests/Writer/Word2007/AbstractWriterPartTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php
similarity index 71%
rename from tests/PhpWord/Tests/Writer/Word2007/AbstractWriterPartTest.php
rename to tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php
index 33051d6f33..81786b145a 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/AbstractWriterPartTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/AbstractPartTest.php
@@ -6,16 +6,16 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
+namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
 
-use PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart;
+use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractWriterPart;
 use PhpOffice\PhpWord\Writer\Word2007;
 use PhpWord\Tests\TestHelperDOCX;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart
+ * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\AbstractWriterPart
  *
- * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart
+ * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractWriterPart
  * @runTestsInSeparateProcesses
  */
 class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
@@ -27,7 +27,7 @@ class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
     public function testSetGetParentWriter()
     {
         $object = $this->getMockForAbstractClass(
-            'PhpOffice\\PhpWord\\Writer\\Word2007\\AbstractWriterPart'
+            'PhpOffice\\PhpWord\\Writer\\Word2007\\Part\\AbstractPart'
         );
         $object->setParentWriter(new Word2007());
         $this->assertEquals(
@@ -44,7 +44,7 @@ public function testSetGetParentWriter()
     public function testSetGetParentWriterNull()
     {
         $object = $this->getMockForAbstractClass(
-            'PhpOffice\\PhpWord\\Writer\\Word2007\\AbstractWriterPart'
+            'PhpOffice\\PhpWord\\Writer\\Word2007\\Part\\AbstractPart'
         );
         $object->getParentWriter();
     }
diff --git a/tests/PhpWord/Tests/Writer/Word2007/DocPropsTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php
similarity index 79%
rename from tests/PhpWord/Tests/Writer/Word2007/DocPropsTest.php
rename to tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php
index e4a7d03e13..e6db4bf53a 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/DocPropsTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocPropsTest.php
@@ -6,14 +6,14 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
+namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
 
-use PhpOffice\PhpWord\Writer\Word2007\DocProps;
+use PhpOffice\PhpWord\Writer\Word2007\Part\DocProps;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\Word2007\DocProps
+ * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\DocProps
  *
- * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\DocProps
+ * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\DocProps
  * @runTestsInSeparateProcesses
  */
 class DocPropsTest extends \PHPUnit_Framework_TestCase
diff --git a/tests/PhpWord/Tests/Writer/Word2007/BaseTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php
similarity index 73%
rename from tests/PhpWord/Tests/Writer/Word2007/BaseTest.php
rename to tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php
index ba01cb3e98..f84aff428b 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/BaseTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/DocumentTest.php
@@ -6,18 +6,19 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
+namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\PhpWord;
+use PhpOffice\PhpWord\Style\Font;
 use PhpOffice\PhpWord\Tests\TestHelperDOCX;
+use PhpOffice\PhpWord\Writer\Word2007\Part\Document;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\Word2007\Base
+ * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Document
  *
- * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Base
  * @runTestsInSeparateProcesses
  */
-class BaseTest extends \PHPUnit_Framework_TestCase
+class DocumentTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * Executed before each method of the class
@@ -27,6 +28,117 @@ public function tearDown()
         TestHelperDOCX::clear();
     }
 
+    /**
+     * Test write word/document.xm with no PhpWord
+     *
+     * @expectedException \PhpOffice\PhpWord\Exception\Exception
+     * @expectedExceptionMessage No PhpWord assigned.
+     */
+    public function testWriteDocumentNoPhpWord()
+    {
+        $object = new Document();
+        $object->writeDocument();
+    }
+
+    /**
+     * Write end section page numbering
+     */
+    public function testWriteEndSectionPageNumbering()
+    {
+        $phpWord = new PhpWord();
+        $section = $phpWord->addSection();
+        $settings = $section->getSettings();
+        $settings->setLandscape();
+        $settings->setPageNumberingStart(2);
+        $settings->setBorderSize(240);
+        $settings->setBreakType('nextPage');
+
+        $doc = TestHelperDOCX::getDocument($phpWord);
+        $element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType');
+
+        $this->assertEquals(2, $element->getAttribute('w:start'));
+    }
+
+    /**
+     * Write elements
+     */
+    public function testElements()
+    {
+        $objectSrc = __DIR__ . "/../../../_files/documents/sheet.xls";
+
+        $phpWord = new PhpWord();
+        $phpWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true));
+        $phpWord->addTitleStyle(2, array('color'=>'666666'));
+        $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->addSection();
+        $section->addTitle('Title 2', 2);
+        $section->addObject($objectSrc);
+        $doc = TestHelperDOCX::getDocument($phpWord);
+
+        // TOC
+        $element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:tabs/w:tab');
+        $this->assertEquals('right', $element->getAttribute('w:val'));
+        $this->assertEquals('dot', $element->getAttribute('w:leader'));
+        $this->assertEquals(9062, $element->getAttribute('w:pos'));
+
+        // Page break
+        $element = $doc->getElement('/w:document/w:body/w:p[4]/w:r/w:br');
+        $this->assertEquals('page', $element->getAttribute('w:type'));
+
+        // Title
+        $element = $doc->getElement('/w:document/w:body/w:p[5]/w:pPr/w:pStyle');
+        $this->assertEquals('Heading1', $element->getAttribute('w:val'));
+
+        // List item
+        $element = $doc->getElement('/w:document/w:body/w:p[6]/w:pPr/w:numPr/w:numId');
+        $this->assertEquals(3, $element->getAttribute('w:val'));
+
+        // Object
+        $element = $doc->getElement('/w:document/w:body/w:p[11]/w:r/w:object/o:OLEObject');
+        $this->assertEquals('Embed', $element->getAttribute('Type'));
+    }
+
+    /**
+     * Write element with some styles
+     */
+    public function testElementStyles()
+    {
+        $objectSrc = __DIR__ . "/../../../_files/documents/sheet.xls";
+
+        $phpWord = new PhpWord();
+        $phpWord->addParagraphStyle('pStyle', array('align' => 'center')); // Style #1
+        $phpWord->addFontStyle('fStyle', array('size' => '20')); // Style #2
+        $phpWord->addTitleStyle(1, array('color' => '333333', 'bold' => true)); // Style #3
+        $fontStyle = new Font('text', array('align' => 'center'));
+        $section = $phpWord->addSection();
+        $section->addListItem('List Item', 0, null, null, 'pStyle'); // Style #4
+        $section->addObject($objectSrc, array('align' => 'center'));
+        $section->addTOC($fontStyle);
+        $section->addTitle('Title 1', 1);
+        $section->addTOC('fStyle');
+        $doc = TestHelperDOCX::getDocument($phpWord);
+
+        // List item
+        $element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:numPr/w:numId');
+        $this->assertEquals(4, $element->getAttribute('w:val'));
+
+        // Object
+        $element = $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject');
+        $this->assertEquals('Embed', $element->getAttribute('Type'));
+
+        // TOC
+        $element = $doc->getElement('/w:document/w:body/w:p[3]/w:pPr/w:tabs/w:tab');
+        $this->assertEquals('right', $element->getAttribute('w:val'));
+        $this->assertEquals('dot', $element->getAttribute('w:leader'));
+        $this->assertEquals(9062, $element->getAttribute('w:pos'));
+    }
+
     /**
      * Test write text element
      */
@@ -55,7 +167,7 @@ public function testWriteTextRun()
     {
         $pStyle = 'pStyle';
         $aStyle = array('align' => 'justify', 'spaceBefore' => 120, 'spaceAfter' => 120);
-        $imageSrc = __DIR__ . "/../../_files/images/earth.jpg";
+        $imageSrc = __DIR__ . "/../../../_files/images/earth.jpg";
 
         $phpWord = new PhpWord();
         $phpWord->addParagraphStyle($pStyle, $aStyle);
@@ -156,10 +268,10 @@ public function testWriteImage()
         $section = $phpWord->addSection();
         foreach ($wraps as $wrap) {
             $styles['wrappingStyle'] = $wrap;
-            $section->addImage(__DIR__ . "/../../_files/images/earth.jpg", $styles);
+            $section->addImage(__DIR__ . "/../../../_files/images/earth.jpg", $styles);
         }
 
-        $archiveFile = realpath(__DIR__ . '/../../_files/documents/reader.docx');
+        $archiveFile = realpath(__DIR__ . '/../../../_files/documents/reader.docx');
         $imageFile = 'word/media/image1.jpeg';
         $source = 'zip://' . $archiveFile . '#' . $imageFile;
         $section->addImage($source);
@@ -181,7 +293,7 @@ public function testWriteImage()
      */
     public function testWriteWatermark()
     {
-        $imageSrc = __DIR__ . "/../../_files/images/earth.jpg";
+        $imageSrc = __DIR__ . "/../../../_files/images/earth.jpg";
 
         $phpWord = new PhpWord();
         $section = $phpWord->addSection();
@@ -305,8 +417,8 @@ public function testWriteTableStyle()
         $tWidth = 120;
         $rHeight = 120;
         $cWidth = 120;
-        $imageSrc = __DIR__ . "/../../_files/images/earth.jpg";
-        $objectSrc = __DIR__ . "/../../_files/documents/sheet.xls";
+        $imageSrc = __DIR__ . "/../../../_files/images/earth.jpg";
+        $objectSrc = __DIR__ . "/../../../_files/documents/sheet.xls";
 
         $tStyles["width"] = 50;
         $tStyles["cellMarginTop"] = 120;
diff --git a/tests/PhpWord/Tests/Writer/Word2007/FooterTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php
similarity index 78%
rename from tests/PhpWord/Tests/Writer/Word2007/FooterTest.php
rename to tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php
index b1bff02b1c..513d4d2c20 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/FooterTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/FooterTest.php
@@ -6,16 +6,16 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
+namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
 
-use PhpOffice\PhpWord\Writer\Word2007\Footer;
+use PhpOffice\PhpWord\Writer\Word2007\Part\Footer;
 use PhpOffice\PhpWord\Writer\Word2007;
 use PhpOffice\PhpWord\Tests\TestHelperDOCX;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\Word2007\Footer
+ * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Footer
  *
- * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Footer
+ * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\Footer
  * @runTestsInSeparateProcesses
  */
 class FooterTest extends \PHPUnit_Framework_TestCase
@@ -27,7 +27,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase
      */
     public function testWriteFooter()
     {
-        $imageSrc = __DIR__ . "/../../_files/images/PhpWord.png";
+        $imageSrc = __DIR__ . "/../../../_files/images/PhpWord.png";
         $container = new \PhpOffice\PhpWord\Element\Footer(1);
         $container->addText('');
         $container->addPreserveText('');
diff --git a/tests/PhpWord/Tests/Writer/Word2007/NotesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php
similarity index 73%
rename from tests/PhpWord/Tests/Writer/Word2007/NotesTest.php
rename to tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php
index f883314aca..3f9aaae7e9 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/NotesTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/FootnotesTest.php
@@ -6,17 +6,17 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
+namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\PhpWord;
 use PhpOffice\PhpWord\Tests\TestHelperDOCX;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\Word2007\Notes
+ * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Notes
  *
  * @runTestsInSeparateProcesses
  */
-class NotesTest extends \PHPUnit_Framework_TestCase
+class FootnotesTest extends \PHPUnit_Framework_TestCase
 {
     /**
      * Executed before each method of the class
@@ -39,10 +39,11 @@ public function testWriteFootnotes()
         $footnote1->addText('Footnote');
         $footnote1->addTextBreak();
         $footnote1->addLink('http://google.com');
-        $footnote2 = $section->addFootnote(array('align' => 'left'));
-        $footnote2->addText('Footnote');
+        $footnote2 = $section->addEndnote(array('align' => 'left'));
+        $footnote2->addText('Endnote');
         $doc = TestHelperDOCX::getDocument($phpWord);
 
         $this->assertTrue($doc->elementExists("/w:document/w:body/w:p/w:r/w:footnoteReference"));
+        $this->assertTrue($doc->elementExists("/w:document/w:body/w:p/w:r/w:endnoteReference"));
     }
 }
diff --git a/tests/PhpWord/Tests/Writer/Word2007/HeaderTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php
similarity index 82%
rename from tests/PhpWord/Tests/Writer/Word2007/HeaderTest.php
rename to tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php
index b836b61941..c3ca6b6bb6 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/HeaderTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/HeaderTest.php
@@ -6,14 +6,14 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
+namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
 
-use PhpOffice\PhpWord\Writer\Word2007\Header;
+use PhpOffice\PhpWord\Writer\Word2007\Part\Header;
 use PhpOffice\PhpWord\Writer\Word2007;
 use PhpOffice\PhpWord\Tests\TestHelperDOCX;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\Word2007\Header
+ * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Header
  *
  * @runTestsInSeparateProcesses
  */
@@ -24,7 +24,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase
      */
     public function testWriteHeader()
     {
-        $imageSrc = __DIR__ . "/../../_files/images/PhpWord.png";
+        $imageSrc = __DIR__ . "/../../../_files/images/PhpWord.png";
 
         $container = new \PhpOffice\PhpWord\Element\Header(1);
         $container->addText('Test');
diff --git a/tests/PhpWord/Tests/Writer/Word2007/NumberingTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php
similarity index 86%
rename from tests/PhpWord/Tests/Writer/Word2007/NumberingTest.php
rename to tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php
index c6a6f7a75d..8d76f016d0 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/NumberingTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/NumberingTest.php
@@ -6,18 +6,18 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
+namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\PhpWord;
 use PhpOffice\PhpWord\Style\Numbering as NumberingStyle;
 use PhpOffice\PhpWord\Style\NumberingLevel;
 use PhpOffice\PhpWord\Tests\TestHelperDOCX;
-use PhpOffice\PhpWord\Writer\Word2007\Numbering;
+use PhpOffice\PhpWord\Writer\Word2007\Part\Numbering;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\Word2007\Numbering
+ * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Numbering
  *
- * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Numbering
+ * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\Numbering
  * @runTestsInSeparateProcesses
  * @since 0.10.0
  */
diff --git a/tests/PhpWord/Tests/Writer/Word2007/StylesTest.php b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php
similarity index 91%
rename from tests/PhpWord/Tests/Writer/Word2007/StylesTest.php
rename to tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php
index 0d333601cc..42c32bbca2 100644
--- a/tests/PhpWord/Tests/Writer/Word2007/StylesTest.php
+++ b/tests/PhpWord/Tests/Writer/Word2007/Part/StylesTest.php
@@ -6,16 +6,16 @@
  * @copyright   2014 PHPWord
  * @license     http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  */
-namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
+namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
 
 use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Writer\Word2007\Styles;
+use PhpOffice\PhpWord\Writer\Word2007\Part\Styles;
 use PhpOffice\PhpWord\Tests\TestHelperDOCX;
 
 /**
- * Test class for PhpOffice\PhpWord\Writer\Word2007\Styles
+ * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Styles
  *
- * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Styles
+ * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\Styles
  * @runTestsInSeparateProcesses
  */
 class StylesTest extends \PHPUnit_Framework_TestCase
diff --git a/tests/PhpWord/Tests/Writer/Word2007Test.php b/tests/PhpWord/Tests/Writer/Word2007Test.php
index ce850c2149..74f3b1fda0 100644
--- a/tests/PhpWord/Tests/Writer/Word2007Test.php
+++ b/tests/PhpWord/Tests/Writer/Word2007Test.php
@@ -45,12 +45,12 @@ public function testConstruct()
             'WebSettings' => 'WebSettings',
             'Header' => 'Header',
             'Footer' => 'Footer',
-            'Footnotes' => 'Notes',
-            'Endnotes' => 'Notes',
+            'Footnotes' => 'Footnotes',
+            'Endnotes' => 'Footnotes',
         );
         foreach ($writerParts as $part => $type) {
             $this->assertInstanceOf(
-                "PhpOffice\\PhpWord\\Writer\\Word2007\\{$type}",
+                "PhpOffice\\PhpWord\\Writer\\Word2007\\Part\\{$type}",
                 $object->getWriterPart($part)
             );
             $this->assertInstanceOf(