/** */ public function testPixelsCentimeters() { $value = rand(1, 100); $this->assertEquals(0, Drawing::pixelsToCentimeters()); $this->assertEquals($value / Drawing::DPI_96 * 2.54, Drawing::pixelsToCentimeters($value)); $this->assertEquals(0, Drawing::centimetersToPixels()); $this->assertEquals($value / 2.54 * Drawing::DPI_96, Drawing::centimetersToPixels($value)); }
/** * 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); } }