/** * Add a OLE-Object Element * * @param string $src * @param mixed $style * @return PHPWord_Section_Object */ public function addObject($src, $style = null) { require_once __DIR__ . '/Section/Object.php'; require_once __DIR__ . '/Media.php'; $object = new Document_Word_Writer_Section_Object($src, $style); if (!is_null($object->getSource())) { $inf = pathinfo($src); $ext = $inf['extension']; if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { $ext = substr($ext, 0, -1); } $iconSrc = __DIR__ . '/_staticDocParts/'; if (!file_exists($iconSrc . '_' . $ext . '.png')) { $iconSrc = $iconSrc . '_default.png'; } else { $iconSrc .= '_' . $ext . '.png'; } $rIDimg = Document_Word_Writer_Media::addSectionMediaElement($iconSrc, 'image'); $data = Document_Word_Writer_Media::addSectionMediaElement($src, 'oleObject'); $rID = $data[0]; $objectId = $data[1]; $object->setRelationId($rID); $object->setObjectId($objectId); $object->setImageRelationId($rIDimg); $this->_elementCollection[] = $object; return $object; } else { trigger_error('Source does not exist or unsupported object type.'); } }