예제 #1
0
 /**
  * Get hash code
  *
  * @return string Hash code
  */
 public function getHashCode()
 {
     $hashElements = '';
     foreach ($this->cells as $cell) {
         $hashElements .= $cell->getHashCode();
     }
     return md5($hashElements . $this->fill->getHashCode() . $this->height . __CLASS__);
 }
예제 #2
0
 /**
  * Get hash code
  *
  * @return string Hash code
  */
 public function getHashCode()
 {
     $hashElements = '';
     foreach ($this->richTextParagraphs as $element) {
         $hashElements .= $element->getHashCode();
     }
     return md5($hashElements . $this->fill->getHashCode() . $this->borders->getHashCode() . $this->width . __CLASS__);
 }
예제 #3
0
 /**
  * Test get/set hash index
  */
 public function testSetGetHashIndex()
 {
     $object = new Fill();
     $value = rand(1, 100);
     $object->setHashIndex($value);
     $this->assertEquals($value, $object->getHashIndex());
 }
예제 #4
0
 /**
  * Get hash code
  *
  * @return string Hash code
  */
 public function getHashCode()
 {
     return md5((is_null($this->fill) ? 'null' : $this->fill->getHashCode()) . (is_null($this->font) ? 'null' : $this->font->getHashCode()) . var_export($this->values, true) . var_export($this, true) . __CLASS__);
 }
예제 #5
0
 /**
  * @param Chart $chart
  * @param Chart\Series $series
  * @throws \Exception
  */
 private function writeSeries(Chart $chart, Chart\Series $series)
 {
     $chartType = $chart->getPlotArea()->getType();
     $numRange = count($series->getValues());
     // chart:series
     $this->xmlContent->startElement('chart:series');
     $this->xmlContent->writeAttribute('chart:values-cell-range-address', 'table-local.$' . $this->rangeCol . '$2:.$' . $this->rangeCol . '$' . ($numRange + 1));
     $this->xmlContent->writeAttribute('chart:label-cell-address', 'table-local.$' . $this->rangeCol . '$1');
     if ($chartType instanceof Area) {
         $this->xmlContent->writeAttribute('chart:class', 'chart:area');
     } elseif ($chartType instanceof AbstractTypeBar) {
         $this->xmlContent->writeAttribute('chart:class', 'chart:bar');
     } elseif ($chartType instanceof Line) {
         $this->xmlContent->writeAttribute('chart:class', 'chart:line');
     } elseif ($chartType instanceof AbstractTypePie) {
         $this->xmlContent->writeAttribute('chart:class', 'chart:circle');
     } elseif ($chartType instanceof Scatter) {
         $this->xmlContent->writeAttribute('chart:class', 'chart:scatter');
     }
     $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries' . $this->numSeries);
     if ($chartType instanceof Area || $chartType instanceof AbstractTypeBar || $chartType instanceof Line || $chartType instanceof Scatter) {
         $dataPointFills = $series->getDataPointFills();
         if (empty($dataPointFills)) {
             $incRepeat = $numRange;
         } else {
             $inc = 0;
             $incRepeat = 0;
             $newFill = new Fill();
             do {
                 if ($series->getDataPointFill($inc)->getHashCode() != $newFill->getHashCode()) {
                     // chart:data-point
                     $this->xmlContent->startElement('chart:data-point');
                     $this->xmlContent->writeAttribute('chart:repeated', $incRepeat);
                     // > chart:data-point
                     $this->xmlContent->endElement();
                     $incRepeat = 0;
                     // chart:data-point
                     $this->xmlContent->startElement('chart:data-point');
                     $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries' . $this->numSeries . '_' . $inc);
                     // > chart:data-point
                     $this->xmlContent->endElement();
                 }
                 $inc++;
                 $incRepeat++;
             } while ($inc < $numRange);
             $incRepeat--;
         }
         // chart:data-point
         $this->xmlContent->startElement('chart:data-point');
         $this->xmlContent->writeAttribute('chart:repeated', $incRepeat);
         // > chart:data-point
         $this->xmlContent->endElement();
     } elseif ($chartType instanceof AbstractTypePie) {
         $count = count($series->getDataPointFills());
         for ($inc = 0; $inc < $count; $inc++) {
             // chart:data-point
             $this->xmlContent->startElement('chart:data-point');
             $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries' . $this->numSeries . '_' . $inc);
             // > chart:data-point
             $this->xmlContent->endElement();
         }
     }
     // > chart:series
     $this->xmlContent->endElement();
 }
 /**
  * Write Pattern Fill
  *
  * @param  \PhpOffice\Common\XMLWriter $objWriter XML Writer
  * @param  \PhpOffice\PhpPresentation\Style\Fill       $pFill     Fill style
  * @throws \Exception
  */
 protected function writePatternFill(XMLWriter $objWriter, Fill $pFill)
 {
     // a:pattFill
     $objWriter->startElement('a:pattFill');
     // fgClr
     $objWriter->startElement('a:fgClr');
     $this->writeColor($objWriter, $pFill->getStartColor());
     $objWriter->endElement();
     // bgClr
     $objWriter->startElement('a:bgClr');
     $this->writeColor($objWriter, $pFill->getEndColor());
     $objWriter->endElement();
     $objWriter->endElement();
 }
예제 #7
0
    $shape->getView3D()->setRotationX(30);
    $shape->getView3D()->setPerspective(30);
    $shape->getLegend()->getBorder()->setLineStyle(Border::LINE_SINGLE);
    $shape->getLegend()->getFont()->setItalic(true);
}
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$objPHPPresentation->getProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 07 Title')->setSubject('Sample 07 Subject')->setDescription('Sample 07 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
// Remove first slide
echo date('H:i:s') . ' Remove first slide' . EOL;
$objPHPPresentation->removeSlideByIndex(0);
// Set Style
$oFill = new Fill();
$oFill->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFE06B20'));
$oShadow = new Shadow();
$oShadow->setVisible(true)->setDirection(45)->setDistance(10);
fnSlide_Area($objPHPPresentation);
fnSlide_Bar($objPHPPresentation);
fnSlide_BarStacked($objPHPPresentation);
fnSlide_BarPercentStacked($objPHPPresentation);
fnSlide_BarHorizontal($objPHPPresentation);
fnSlide_Bar3D($objPHPPresentation);
fnSlide_Bar3DHorizontal($objPHPPresentation);
fnSlide_Pie3D($objPHPPresentation);
fnSlide_Pie($objPHPPresentation);
fnSlide_Scatter($objPHPPresentation);
// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
예제 #8
0
 /**
  * Write the gradient style
  * @param XMLWriter $objWriter
  * @param Fill $oFill
  */
 protected function writeGradientFill(XMLWriter $objWriter, Fill $oFill)
 {
     $objWriter->startElement('draw:gradient');
     $objWriter->writeAttribute('draw:name', 'gradient_' . $oFill->getHashCode());
     $objWriter->writeAttribute('draw:display-name', 'gradient_' . $oFill->getHashCode());
     $objWriter->writeAttribute('draw:style', 'linear');
     $objWriter->writeAttribute('draw:start-intensity', '100%');
     $objWriter->writeAttribute('draw:end-intensity', '100%');
     $objWriter->writeAttribute('draw:start-color', '#' . $oFill->getStartColor()->getRGB());
     $objWriter->writeAttribute('draw:end-color', '#' . $oFill->getEndColor()->getRGB());
     $objWriter->writeAttribute('draw:border', '0%');
     $objWriter->writeAttribute('draw:angle', $oFill->getRotation() - 90);
     $objWriter->endElement();
     $this->arrayGradient[] = $oFill->getHashCode();
 }
예제 #9
0
 public function testTableCellFill()
 {
     $oColor = new Color();
     $oColor->setRGB(Color::COLOR_BLUE);
     $oFill = new Fill();
     $oFill->setFillType(Fill::FILL_SOLID)->setStartColor($oColor);
     $phpPresentation = new PhpPresentation();
     $oSlide = $phpPresentation->getActiveSlide();
     $oShape = $oSlide->createTableShape();
     $oRow = $oShape->createRow();
     $oCell = $oRow->getCell();
     $oCell->setFill($oFill);
     $pres = TestHelperDOCX::getDocument($phpPresentation, 'ODPresentation');
     $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'gr1r0c0\']';
     $this->assertTrue($pres->elementExists($element, 'content.xml'));
     $this->assertEquals('table-cell', $pres->getElementAttribute($element, 'style:family', 'content.xml'));
     $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'gr1r0c0\']/style:graphic-properties';
     $this->assertTrue($pres->elementExists($element, 'content.xml'));
     $this->assertEquals('solid', $pres->getElementAttribute($element, 'draw:fill', 'content.xml'));
     $this->assertStringStartsWith('#', $pres->getElementAttribute($element, 'draw:fill-color', 'content.xml'));
     $this->assertStringEndsWith($oColor->getRGB(), $pres->getElementAttribute($element, 'draw:fill-color', 'content.xml'));
 }
예제 #10
0
 /**
  * Write Pattern Fill
  *
  * @param  \PhpOffice\Common\XMLWriter $objWriter XML Writer
  * @param  \PhpOffice\PhpPresentation\Style\Fill       $pFill     Fill style
  * @throws \Exception
  */
 protected function writePatternFill(XMLWriter $objWriter, Fill $pFill)
 {
     // a:pattFill
     $objWriter->startElement('a:pattFill');
     // fgClr
     $objWriter->startElement('a:fgClr');
     // srgbClr
     $objWriter->startElement('a:srgbClr');
     $objWriter->writeAttribute('val', $pFill->getStartColor()->getRGB());
     $objWriter->endElement();
     $objWriter->endElement();
     // bgClr
     $objWriter->startElement('a:bgClr');
     // srgbClr
     $objWriter->startElement('a:srgbClr');
     $objWriter->writeAttribute('val', $pFill->getEndColor()->getRGB());
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
 }
예제 #11
0
 /**
  * Get hash code
  *
  * @return string Hash code
  */
 public function getHashCode()
 {
     return md5($this->position . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->font->getHashCode() . $this->border->getHashCode() . $this->fill->getHashCode() . $this->alignment->getHashCode() . ($this->visible ? 't' : 'f') . __CLASS__);
 }