作者:hxsa
项目:PHPPresentatio
public function testTypeBar()
{
$seriesData = array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2);
$oPhpPresentation = new PhpPresentation();
$oSlide = $oPhpPresentation->getActiveSlide();
$oShape = $oSlide->createChartShape();
$oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
$oBar = new Bar();
$oSeries = new Series('Downloads', $seriesData);
$oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_BLUE));
$oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKBLUE));
$oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKGREEN));
$oSeries->getDataPointFill(3)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKRED));
$oSeries->getDataPointFill(4)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color(Color::COLOR_DARKYELLOW));
$oBar->addSeries($oSeries);
$oShape->getPlotArea()->setType($oBar);
$oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
$element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/slides/slide1.xml'));
$element = '/c:chartSpace/c:chart/c:plotArea/c:barChart';
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
$element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser';
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
$element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dPt/c:spPr';
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
$element = '/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:tx/c:v';
$this->assertEquals($oSeries->getTitle(), $oXMLDoc->getElement($element, 'ppt/charts/' . $oShape->getIndexedFilename())->nodeValue);
}
作者:hxsa
项目:PHPPresentatio
/**
* Get an array of all drawings
*
* @param PhpPresentation $pPhpPresentation
* @return \PhpOffice\PhpPresentation\Shape\AbstractDrawing[] All drawings in PhpPresentation
* @throws \Exception
*/
public function allDrawings(PhpPresentation $pPhpPresentation)
{
// Get an array of all drawings
$aDrawings = array();
// Loop trough PhpPresentation
$slideCount = $pPhpPresentation->getSlideCount();
for ($i = 0; $i < $slideCount; ++$i) {
// Loop trough images and add to array
$iterator = $pPhpPresentation->getSlide($i)->getShapeCollection()->getIterator();
while ($iterator->valid()) {
if ($iterator->current() instanceof AbstractDrawing && !$iterator->current() instanceof Table) {
$aDrawings[] = $iterator->current();
} elseif ($iterator->current() instanceof Group) {
$iterator2 = $iterator->current()->getShapeCollection()->getIterator();
while ($iterator2->valid()) {
if ($iterator2->current() instanceof AbstractDrawing && !$iterator2->current() instanceof Table) {
$aDrawings[] = $iterator2->current();
}
$iterator2->next();
}
}
$iterator->next();
}
}
return $aDrawings;
}
作者:hxsa
项目:PHPPresentatio
/**
* Save PhpPresentation to file
*
* @param string $pFilename
* @throws \Exception
*/
public function save($pFilename)
{
if (empty($pFilename)) {
throw new \Exception("Filename is empty.");
}
if (!is_null($this->presentation)) {
// Create new ZIP file and open it for writing
$objZip = new \ZipArchive();
// Try opening the ZIP file
if ($objZip->open($pFilename, \ZipArchive::CREATE) !== true) {
if ($objZip->open($pFilename, \ZipArchive::OVERWRITE) !== true) {
throw new \Exception("Could not open " . $pFilename . " for writing.");
}
}
// Add media
$slideCount = $this->presentation->getSlideCount();
for ($i = 0; $i < $slideCount; ++$i) {
for ($j = 0; $j < $this->presentation->getSlide($i)->getShapeCollection()->count(); ++$j) {
if ($this->presentation->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof AbstractDrawing) {
$imgTemp = $this->presentation->getSlide($i)->getShapeCollection()->offsetGet($j);
$objZip->addFromString('media/' . $imgTemp->getFilename(), file_get_contents($imgTemp->getPath()));
}
}
}
// Add PhpPresentation.xml to the document, which represents a PHP serialized PhpPresentation object
$objZip->addFromString('PhpPresentation.xml', $this->writeSerialized($this->presentation, $pFilename));
// Close file
if ($objZip->close() === false) {
throw new \Exception("Could not close zip file {$pFilename}.");
}
} else {
throw new \Exception("PhpPresentation object unassigned.");
}
}
作者:phpoffic
项目:phppowerpoin
public function testFeatureThumbnail()
{
$imagePath = PHPPRESENTATION_TESTS_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'PhpPresentationLogo.png';
$oPhpPresentation = new PhpPresentation();
$oPhpPresentation->getPresentationProperties()->setThumbnailPath($imagePath);
$oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
$this->assertTrue($oXMLDoc->fileExists('docProps/thumbnail.jpeg'));
}
作者:hxsa
项目:PHPPresentatio
public function testParent()
{
$object = new Note();
$this->assertNull($object->getParent());
$oPhpPresentation = new PhpPresentation();
$oSlide = $oPhpPresentation->createSlide();
$oSlide->setNote($object);
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->getParent());
}
作者:phpoffic
项目:phppowerpoin
public function testCompany()
{
$expected = 'aAbBcDeE';
$oPhpPresentation = new PhpPresentation();
$oPhpPresentation->getDocumentProperties()->setCompany($expected);
$oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
$this->assertTrue($oXMLDoc->fileExists('docProps/app.xml'));
$this->assertTrue($oXMLDoc->elementExists('/Properties/Company', 'docProps/app.xml'));
$this->assertEquals($expected, $oXMLDoc->getElement('/Properties/Company', 'docProps/app.xml')->nodeValue);
}
作者:phpoffic
项目:phppowerpoin
public function testCommentsAuthors()
{
$oAuthor = new Comment\Author();
$oComment = new Comment();
$oComment->setAuthor($oAuthor);
$oPhpPresentation = new PhpPresentation();
$oPhpPresentation->getActiveSlide()->addShape($oComment);
$pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
$this->assertTrue($pres->elementExists('/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors"]', 'ppt/_rels/presentation.xml.rels'));
}
作者:phpoffic
项目:phppowerpoin
public function testLastView()
{
$expectedElement = '/p:viewPr';
$expectedLastView = PresentationProperties::VIEW_OUTLINE;
$oPhpPresentation = new PhpPresentation();
$oPhpPresentation->getPresentationProperties()->setLastView($expectedLastView);
$oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
$this->assertTrue($oXMLDoc->fileExists('ppt/viewProps.xml'));
$this->assertTrue($oXMLDoc->elementExists($expectedElement, 'ppt/viewProps.xml'));
$this->assertEquals($expectedLastView, $oXMLDoc->getElementAttribute($expectedElement, 'lastView', 'ppt/viewProps.xml'));
}
作者:phpoffic
项目:phppowerpoin
public function testDocumentProperties()
{
$expected = 'aAbBcDeE';
$oPhpPresentation = new PhpPresentation();
$oPhpPresentation->getDocumentProperties()->setCreator($expected);
$oPhpPresentation->getDocumentProperties()->setTitle($expected);
$oPhpPresentation->getDocumentProperties()->setDescription($expected);
$oPhpPresentation->getDocumentProperties()->setSubject($expected);
$oPhpPresentation->getDocumentProperties()->setKeywords($expected);
$oPhpPresentation->getDocumentProperties()->setCategory($expected);
$oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
$this->assertTrue($oXMLDoc->fileExists('docProps/core.xml'));
$this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:creator', 'docProps/core.xml'));
$this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:creator', 'docProps/core.xml')->nodeValue);
$this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:title', 'docProps/core.xml'));
$this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:title', 'docProps/core.xml')->nodeValue);
$this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:description', 'docProps/core.xml'));
$this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:description', 'docProps/core.xml')->nodeValue);
$this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:subject', 'docProps/core.xml'));
$this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:subject', 'docProps/core.xml')->nodeValue);
$this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/cp:keywords', 'docProps/core.xml'));
$this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/cp:keywords', 'docProps/core.xml')->nodeValue);
$this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/cp:category', 'docProps/core.xml'));
$this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/cp:category', 'docProps/core.xml')->nodeValue);
}
作者:hxsa
项目:PHPPresentatio
public function testGroup()
{
$oPhpPresentation = new PhpPresentation();
$oSlide = $oPhpPresentation->getActiveSlide();
$oGroup = $oSlide->createGroup();
$oDrawing = new Drawing();
$this->assertInternalType('array', $oDrawing->allDrawings($oPhpPresentation));
$this->assertEmpty($oDrawing->allDrawings($oPhpPresentation));
$oGroup->createDrawingShape();
$oGroup->createDrawingShape();
$oGroup->createDrawingShape();
$this->assertInternalType('array', $oDrawing->allDrawings($oPhpPresentation));
$this->assertCount(3, $oDrawing->allDrawings($oPhpPresentation));
}
作者:hxsa
项目:PHPPresentatio
public function testMemoryDrawing()
{
$oPhpPresentation = new PhpPresentation();
$oSlide = $oPhpPresentation->getActiveSlide();
$oShape = new MemoryDrawing();
$gdImage = @imagecreatetruecolor(140, 20);
$textColor = imagecolorallocate($gdImage, 255, 255, 255);
imagestring($gdImage, 1, 5, 5, 'Created with PhpPresentation', $textColor);
$oShape->setImageResource($gdImage)->setRenderingFunction(MemoryDrawing::RENDERING_JPEG)->setMimeType(MemoryDrawing::MIMETYPE_DEFAULT);
$oSlide->addShape($oShape);
$pres = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation');
$element = '/manifest:manifest/manifest:file-entry[5]';
$this->assertTrue($pres->elementExists($element, 'META-INF/manifest.xml'));
$this->assertEquals('Pictures/' . $oShape->getIndexedFilename(), $pres->getElementAttribute($element, 'manifest:full-path', 'META-INF/manifest.xml'));
}
作者:hxsa
项目:PHPPresentatio
/**
* Write presentation relationships to XML format
*
* @param PhpPresentation $pPhpPresentation
* @return string XML Output
* @throws \Exception
*/
public function writePresentationRelationships(PhpPresentation $pPhpPresentation)
{
// Create XML writer
$objWriter = $this->getXMLWriter();
// XML header
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
// Relation id
$relationId = 1;
$parentWriter = $this->getParentWriter();
if ($parentWriter instanceof PowerPoint2007) {
// Add slide masters
$masterSlides = $parentWriter->getLayoutPack()->getMasterSlides();
foreach ($masterSlides as $masterSlide) {
// Relationship slideMasters/slideMasterX.xml
$this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster', 'slideMasters/slideMaster' . $masterSlide['masterid'] . '.xml');
}
}
// Add slide theme (only one!)
// Relationship theme/theme1.xml
$this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', 'theme/theme1.xml');
// Relationships with slides
$slideCount = $pPhpPresentation->getSlideCount();
for ($i = 0; $i < $slideCount; ++$i) {
$this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slides/slide' . ($i + 1) . '.xml');
}
$this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps', 'presProps.xml');
$this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps', 'viewProps.xml');
$this->writeRelationship($objWriter, $relationId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles', 'tableStyles.xml');
$objWriter->endElement();
// Return
return $objWriter->getData();
}
作者:hxsa
项目:PHPPresentatio
/**
* Test save
*/
public function testSave()
{
$filename = tempnam(sys_get_temp_dir(), 'PhpPresentation');
$imageFile = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/images/PhpPresentationLogo.png';
$oPhpPresentation = new PhpPresentation();
$slide = $oPhpPresentation->getActiveSlide();
$slide->createRichTextShape();
$slide->createLineShape(10, 10, 10, 10);
$slide->createChartShape()->getPlotArea()->setType(new \PhpOffice\PhpPresentation\Shape\Chart\Type\Bar3D());
$slide->createDrawingShape()->setName('Drawing')->setPath($imageFile);
$slide->createTableShape()->createRow();
$object = new ODPresentation($oPhpPresentation);
$object->save($filename);
$this->assertTrue(file_exists($filename));
unlink($filename);
}
作者:hxsa
项目:PHPPresentatio
/**
*/
public function testMethod()
{
$oPhpPresentation = new PhpPresentation();
$oPhpPresentation->addSlide(new Slide());
$object = new Iterator($oPhpPresentation);
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->current());
$this->assertEquals(0, $object->key());
$this->assertNull($object->next());
$this->assertEquals(1, $object->key());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->current());
$this->assertTrue($object->valid());
$this->assertNull($object->next());
$this->assertFalse($object->valid());
$this->assertNull($object->rewind());
$this->assertEquals(0, $object->key());
}
作者:hxsa
项目:PHPPresentatio
public function testTypeArea()
{
$seriesData = array('A' => 1, 'B' => 2, 'C' => 4, 'D' => 3, 'E' => 2);
$oPhpPresentation = new PhpPresentation();
$oSlide = $oPhpPresentation->getActiveSlide();
$oShape = $oSlide->createChartShape();
$oShape->setResizeProportional(false)->setHeight(550)->setWidth(700)->setOffsetX(120)->setOffsetY(80);
$oArea = new Area();
$oSeries = new Series('Downloads', $seriesData);
$oSeries->getFill()->setStartColor(new Color('FFAABBCC'));
$oArea->addSeries($oSeries);
$oShape->getPlotArea()->setType($oArea);
$oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
$element = '/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData';
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/slides/slide1.xml'));
$element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart';
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
$element = '/c:chartSpace/c:chart/c:plotArea/c:areaChart/c:ser';
$this->assertTrue($oXMLDoc->elementExists($element, 'ppt/charts/' . $oShape->getIndexedFilename()));
}
作者:hxsa
项目:PHPPresentatio
/**
* Write Meta file to XML format
*
* @param PhpPresentation $pPhpPresentation
* @return string XML Output
* @throws \Exception
*/
public function writePart(PhpPresentation $pPhpPresentation)
{
// Create XML writer
$objWriter = $this->getXMLWriter();
// XML header
$objWriter->startDocument('1.0', 'UTF-8');
// office:document-meta
$objWriter->startElement('office:document-meta');
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
$objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0');
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
$objWriter->writeAttribute('xmlns:smil', 'urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0');
$objWriter->writeAttribute('xmlns:anim', 'urn:oasis:names:tc:opendocument:xmlns:animation:1.0');
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
$objWriter->writeAttribute('xmlns:officeooo', 'http://openoffice.org/2009/office');
$objWriter->writeAttribute('xmlns:drawooo', 'http://openoffice.org/2010/draw');
$objWriter->writeAttribute('office:version', '1.2');
// office:meta
$objWriter->startElement('office:meta');
// dc:creator
$objWriter->writeElement('dc:creator', $pPhpPresentation->getProperties()->getLastModifiedBy());
// dc:date
$objWriter->writeElement('dc:date', gmdate('Y-m-d\\TH:i:s.000', $pPhpPresentation->getProperties()->getModified()));
// dc:description
$objWriter->writeElement('dc:description', $pPhpPresentation->getProperties()->getDescription());
// dc:subject
$objWriter->writeElement('dc:subject', $pPhpPresentation->getProperties()->getSubject());
// dc:title
$objWriter->writeElement('dc:title', $pPhpPresentation->getProperties()->getTitle());
// meta:creation-date
$objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\\TH:i:s.000', $pPhpPresentation->getProperties()->getCreated()));
// meta:initial-creator
$objWriter->writeElement('meta:initial-creator', $pPhpPresentation->getProperties()->getCreator());
// meta:keyword
$objWriter->writeElement('meta:keyword', $pPhpPresentation->getProperties()->getKeywords());
// @todo : Where these properties are written ?
// $pPhpPresentation->getProperties()->getCategory()
// $pPhpPresentation->getProperties()->getCompany()
$objWriter->endElement();
$objWriter->endElement();
// Return
return $objWriter->getData();
}
作者:phpoffic
项目:phppowerpoin
public function testStrokeDash()
{
$oPhpPresentation = new PhpPresentation();
$oSlide = $oPhpPresentation->getActiveSlide();
$oRichText1 = $oSlide->createRichTextShape();
$oRichText1->getBorder()->setColor(new Color('FF4672A8'))->setLineStyle(Border::LINE_SINGLE);
$arrayDashStyle = array(Border::DASH_DASH, Border::DASH_DASHDOT, Border::DASH_DOT, Border::DASH_LARGEDASH, Border::DASH_LARGEDASHDOT, Border::DASH_LARGEDASHDOTDOT, Border::DASH_SYSDASH, Border::DASH_SYSDASHDOT, Border::DASH_SYSDASHDOTDOT, Border::DASH_SYSDOT);
foreach ($arrayDashStyle as $style) {
$oRichText1->getBorder()->setDashStyle($style);
$pres = TestHelperDOCX::getDocument($oPhpPresentation, 'ODPresentation');
$element = '/office:document-styles/office:styles/draw:stroke-dash[@draw:name=\'strokeDash_' . $style . '\']';
$this->assertTrue($pres->elementExists($element, 'styles.xml'));
$this->assertEquals('rect', $pres->getElementAttribute($element, 'draw:style', 'styles.xml'));
$this->assertTrue($pres->attributeElementExists($element, 'draw:distance', 'styles.xml'));
switch ($style) {
case Border::DASH_DOT:
case Border::DASH_SYSDOT:
$this->assertTrue($pres->attributeElementExists($element, 'draw:dots1', 'styles.xml'));
$this->assertTrue($pres->attributeElementExists($element, 'draw:dots1-length', 'styles.xml'));
break;
case Border::DASH_DASH:
case Border::DASH_LARGEDASH:
case Border::DASH_SYSDASH:
$this->assertTrue($pres->attributeElementExists($element, 'draw:dots2', 'styles.xml'));
$this->assertTrue($pres->attributeElementExists($element, 'draw:dots2-length', 'styles.xml'));
break;
case Border::DASH_DASHDOT:
case Border::DASH_LARGEDASHDOT:
case Border::DASH_LARGEDASHDOTDOT:
case Border::DASH_SYSDASHDOT:
case Border::DASH_SYSDASHDOTDOT:
$this->assertTrue($pres->attributeElementExists($element, 'draw:dots1', 'styles.xml'));
$this->assertTrue($pres->attributeElementExists($element, 'draw:dots1-length', 'styles.xml'));
$this->assertTrue($pres->attributeElementExists($element, 'draw:dots2', 'styles.xml'));
$this->assertTrue($pres->attributeElementExists($element, 'draw:dots2-length', 'styles.xml'));
break;
}
}
}
作者:hxsa
项目:PHPPresentatio
public function testChartArea()
{
$oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
$oSeries->getFill()->setStartColor(new Color('FF93A9CE'));
$oArea = new Area();
$oArea->addSeries($oSeries);
$phpPresentation = new PhpPresentation();
$oSlide = $phpPresentation->getActiveSlide();
$oChart = $oSlide->createChartShape();
$oChart->getPlotArea()->setType($oArea);
$pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
$element = '/office:document-content/office:body/office:chart/chart:chart';
$this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
$this->assertEquals('chart:area', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
$element = '/office:document-content/office:body/office:chart/chart:chart/chart:plot-area/chart:series';
$this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
$this->assertEquals('chart:area', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
$element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'styleSeries0\']/style:graphic-properties';
$this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
$this->assertFalse($pres->attributeElementExists($element, 'draw:fill', 'Object 1/content.xml'));
$this->assertTrue($pres->attributeElementExists($element, 'draw:fill-color', 'Object 1/content.xml'));
$this->assertEquals('#93A9CE', $pres->getElementAttribute($element, 'draw:fill-color', 'Object 1/content.xml'));
}
作者:hxsa
项目:PHPPresentatio
public function testChartBarHorizontal()
{
$oSeries = new Series('Series', array('Jan' => 1, 'Feb' => 5, 'Mar' => 2));
$oSeries->setShowSeriesName(true);
$oSeries->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF4672A8'));
$oSeries->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFAB4744'));
$oSeries->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF8AA64F'));
$oBar = new Bar();
$oBar->setBarDirection(Bar::DIRECTION_HORIZONTAL);
$oBar->addSeries($oSeries);
$phpPresentation = new PhpPresentation();
$oSlide = $phpPresentation->getActiveSlide();
$oChart = $oSlide->createChartShape();
$oChart->getPlotArea()->setType($oBar);
$pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
$element = '/office:document-content/office:body/office:chart/chart:chart';
$this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
$this->assertEquals('chart:bar', $pres->getElementAttribute($element, 'chart:class', 'Object 1/content.xml'));
$element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'stylePlotArea\']/style:chart-properties';
$this->assertTrue($pres->elementExists($element, 'Object 1/content.xml'));
$this->assertEquals('true', $pres->getElementAttribute($element, 'chart:vertical', 'Object 1/content.xml'));
$this->assertFalse($pres->attributeElementExists($element, 'chart:three-dimensional', 'Object 1/content.xml'));
$this->assertFalse($pres->attributeElementExists($element, 'chart:right-angled-axes', 'Object 1/content.xml'));
}
作者:phpoffic
项目:phppowerpoin
/**
* Read Shape RichText
*
* @param \DOMElement $oNodeFrame
*/
protected function loadShapeRichText(\DOMElement $oNodeFrame)
{
// Core
$oShape = $this->oPhpPresentation->getActiveSlide()->createRichTextShape();
$oShape->setParagraphs(array());
$oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:width'), 0, -2))) : '');
$oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:height'), 0, -2))) : '');
$oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:x'), 0, -2))) : '');
$oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? (int) round(CommonDrawing::centimetersToPixels(substr($oNodeFrame->getAttribute('svg:y'), 0, -2))) : '');
foreach ($this->oXMLReader->getElements('draw:text-box/*', $oNodeFrame) as $oNodeParagraph) {
$this->levelParagraph = 0;
if ($oNodeParagraph->nodeName == 'text:p') {
$this->readParagraph($oShape, $oNodeParagraph);
}
if ($oNodeParagraph->nodeName == 'text:list') {
$this->readList($oShape, $oNodeParagraph);
}
}
if (count($oShape->getParagraphs()) > 0) {
$oShape->setActiveParagraph(0);
}
}