/**
  * Get hash code
  *
  * @return string    Hash code
  */
 public function getHashCode()
 {
     return md5($this->_renderingFunction . $this->_mimeType . $this->_uniqueName . parent::getHashCode() . __CLASS__);
 }
Esempio n. 2
0
 /**
  * Get hash code
  *
  * @return string	Hash code
  */
 public function getHashCode()
 {
     return md5($this->_path . parent::getHashCode() . __CLASS__);
 }
Esempio n. 3
0
 /**
  * Write drawings to XML format
  *
  * @param 	PHPExcel_Shared_XMLWriter			$objWriter 		XML Writer
  * @param 	PHPExcel_Worksheet_BaseDrawing		$pDrawing
  * @param 	int									$pRelationId
  * @throws 	PHPExcel_Writer_Exception
  */
 public function _writeDrawing(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet_BaseDrawing $pDrawing = null, $pRelationId = -1)
 {
     if ($pRelationId >= 0) {
         // xdr:oneCellAnchor
         $objWriter->startElement('xdr:oneCellAnchor');
         // Image location
         $aCoordinates = PHPExcel_Cell::coordinateFromString($pDrawing->getCoordinates());
         $aCoordinates[0] = PHPExcel_Cell::columnIndexFromString($aCoordinates[0]);
         // xdr:from
         $objWriter->startElement('xdr:from');
         $objWriter->writeElement('xdr:col', $aCoordinates[0] - 1);
         $objWriter->writeElement('xdr:colOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetX()));
         $objWriter->writeElement('xdr:row', $aCoordinates[1] - 1);
         $objWriter->writeElement('xdr:rowOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetY()));
         $objWriter->endElement();
         // xdr:ext
         $objWriter->startElement('xdr:ext');
         $objWriter->writeAttribute('cx', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getWidth()));
         $objWriter->writeAttribute('cy', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getHeight()));
         $objWriter->endElement();
         // xdr:pic
         $objWriter->startElement('xdr:pic');
         // xdr:nvPicPr
         $objWriter->startElement('xdr:nvPicPr');
         // xdr:cNvPr
         $objWriter->startElement('xdr:cNvPr');
         $objWriter->writeAttribute('id', $pRelationId);
         $objWriter->writeAttribute('name', $pDrawing->getName());
         $objWriter->writeAttribute('descr', $pDrawing->getDescription());
         $objWriter->endElement();
         // xdr:cNvPicPr
         $objWriter->startElement('xdr:cNvPicPr');
         // a:picLocks
         $objWriter->startElement('a:picLocks');
         $objWriter->writeAttribute('noChangeAspect', '1');
         $objWriter->endElement();
         $objWriter->endElement();
         $objWriter->endElement();
         // xdr:blipFill
         $objWriter->startElement('xdr:blipFill');
         // a:blip
         $objWriter->startElement('a:blip');
         $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
         $objWriter->writeAttribute('r:embed', 'rId' . $pRelationId);
         $objWriter->endElement();
         // a:stretch
         $objWriter->startElement('a:stretch');
         $objWriter->writeElement('a:fillRect', null);
         $objWriter->endElement();
         $objWriter->endElement();
         // xdr:spPr
         $objWriter->startElement('xdr:spPr');
         // a:xfrm
         $objWriter->startElement('a:xfrm');
         $objWriter->writeAttribute('rot', PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getRotation()));
         $objWriter->endElement();
         // a:prstGeom
         $objWriter->startElement('a:prstGeom');
         $objWriter->writeAttribute('prst', 'rect');
         // a:avLst
         $objWriter->writeElement('a:avLst', null);
         $objWriter->endElement();
         //						// a:solidFill
         //						$objWriter->startElement('a:solidFill');
         //							// a:srgbClr
         //							$objWriter->startElement('a:srgbClr');
         //							$objWriter->writeAttribute('val', 'FFFFFF');
         ///* SHADE
         //								// a:shade
         //								$objWriter->startElement('a:shade');
         //								$objWriter->writeAttribute('val', '85000');
         //								$objWriter->endElement();
         //*/
         //							$objWriter->endElement();
         //						$objWriter->endElement();
         /*
         						// a:ln
         						$objWriter->startElement('a:ln');
         						$objWriter->writeAttribute('w', '88900');
         						$objWriter->writeAttribute('cap', 'sq');
         
         							// a:solidFill
         							$objWriter->startElement('a:solidFill');
         
         								// a:srgbClr
         								$objWriter->startElement('a:srgbClr');
         								$objWriter->writeAttribute('val', 'FFFFFF');
         								$objWriter->endElement();
         
         							$objWriter->endElement();
         
         							// a:miter
         							$objWriter->startElement('a:miter');
         							$objWriter->writeAttribute('lim', '800000');
         							$objWriter->endElement();
         
         						$objWriter->endElement();
         */
         if ($pDrawing->getShadow()->getVisible()) {
             // a:effectLst
             $objWriter->startElement('a:effectLst');
             // a:outerShdw
             $objWriter->startElement('a:outerShdw');
             $objWriter->writeAttribute('blurRad', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getBlurRadius()));
             $objWriter->writeAttribute('dist', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getDistance()));
             $objWriter->writeAttribute('dir', PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getShadow()->getDirection()));
             $objWriter->writeAttribute('algn', $pDrawing->getShadow()->getAlignment());
             $objWriter->writeAttribute('rotWithShape', '0');
             // a:srgbClr
             $objWriter->startElement('a:srgbClr');
             $objWriter->writeAttribute('val', $pDrawing->getShadow()->getColor()->getRGB());
             // a:alpha
             $objWriter->startElement('a:alpha');
             $objWriter->writeAttribute('val', $pDrawing->getShadow()->getAlpha() * 1000);
             $objWriter->endElement();
             $objWriter->endElement();
             $objWriter->endElement();
             $objWriter->endElement();
         }
         /*
         
         						// a:scene3d
         						$objWriter->startElement('a:scene3d');
         
         							// a:camera
         							$objWriter->startElement('a:camera');
         							$objWriter->writeAttribute('prst', 'orthographicFront');
         							$objWriter->endElement();
         
         							// a:lightRig
         							$objWriter->startElement('a:lightRig');
         							$objWriter->writeAttribute('rig', 'twoPt');
         							$objWriter->writeAttribute('dir', 't');
         
         								// a:rot
         								$objWriter->startElement('a:rot');
         								$objWriter->writeAttribute('lat', '0');
         								$objWriter->writeAttribute('lon', '0');
         								$objWriter->writeAttribute('rev', '0');
         								$objWriter->endElement();
         
         							$objWriter->endElement();
         
         						$objWriter->endElement();
         */
         /*
         						// a:sp3d
         						$objWriter->startElement('a:sp3d');
         
         							// a:bevelT
         							$objWriter->startElement('a:bevelT');
         							$objWriter->writeAttribute('w', '25400');
         							$objWriter->writeAttribute('h', '19050');
         							$objWriter->endElement();
         
         							// a:contourClr
         							$objWriter->startElement('a:contourClr');
         
         								// a:srgbClr
         								$objWriter->startElement('a:srgbClr');
         								$objWriter->writeAttribute('val', 'FFFFFF');
         								$objWriter->endElement();
         
         							$objWriter->endElement();
         
         						$objWriter->endElement();
         */
         $objWriter->endElement();
         $objWriter->endElement();
         // xdr:clientData
         $objWriter->writeElement('xdr:clientData', null);
         $objWriter->endElement();
     } else {
         throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
     }
 }
Esempio n. 4
0
 /**
  * Build the Worksheet Escher objects
  *
  */
 private function _buildWorksheetEschers()
 {
     // 1-based index to BstoreContainer
     $blipIndex = 0;
     $lastReducedSpId = 0;
     $lastSpId = 0;
     foreach ($this->_phpExcel->getAllsheets() as $sheet) {
         // sheet index
         $sheetIndex = $sheet->getParent()->getIndex($sheet);
         $escher = null;
         // check if there are any shapes for this sheet
         $filterRange = $sheet->getAutoFilter()->getRange();
         if (count($sheet->getDrawingCollection()) == 0 && empty($filterRange)) {
             continue;
         }
         // create intermediate Escher object
         $escher = new PHPExcel_Shared_Escher();
         // dgContainer
         $dgContainer = new PHPExcel_Shared_Escher_DgContainer();
         // set the drawing index (we use sheet index + 1)
         $dgId = $sheet->getParent()->getIndex($sheet) + 1;
         $dgContainer->setDgId($dgId);
         $escher->setDgContainer($dgContainer);
         // spgrContainer
         $spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();
         $dgContainer->setSpgrContainer($spgrContainer);
         // add one shape which is the group shape
         $spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
         $spContainer->setSpgr(true);
         $spContainer->setSpType(0);
         $spContainer->setSpId($sheet->getParent()->getIndex($sheet) + 1 << 10);
         $spgrContainer->addChild($spContainer);
         // add the shapes
         $countShapes[$sheetIndex] = 0;
         // count number of shapes (minus group shape), in sheet
         foreach ($sheet->getDrawingCollection() as $drawing) {
             ++$blipIndex;
             ++$countShapes[$sheetIndex];
             // add the shape
             $spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
             // set the shape type
             $spContainer->setSpType(0x4b);
             // set the shape flag
             $spContainer->setSpFlag(0x2);
             // set the shape index (we combine 1-based sheet index and $countShapes to create unique shape index)
             $reducedSpId = $countShapes[$sheetIndex];
             $spId = $reducedSpId | $sheet->getParent()->getIndex($sheet) + 1 << 10;
             $spContainer->setSpId($spId);
             // keep track of last reducedSpId
             $lastReducedSpId = $reducedSpId;
             // keep track of last spId
             $lastSpId = $spId;
             // set the BLIP index
             $spContainer->setOPT(0x4104, $blipIndex);
             // set coordinates and offsets, client anchor
             $coordinates = $drawing->getCoordinates();
             $offsetX = $drawing->getOffsetX();
             $offsetY = $drawing->getOffsetY();
             $width = $drawing->getWidth();
             $height = $drawing->getHeight();
             $twoAnchor = PHPExcel_Shared_Excel5::oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height);
             $spContainer->setStartCoordinates($twoAnchor['startCoordinates']);
             $spContainer->setStartOffsetX($twoAnchor['startOffsetX']);
             $spContainer->setStartOffsetY($twoAnchor['startOffsetY']);
             $spContainer->setEndCoordinates($twoAnchor['endCoordinates']);
             $spContainer->setEndOffsetX($twoAnchor['endOffsetX']);
             $spContainer->setEndOffsetY($twoAnchor['endOffsetY']);
             $spgrContainer->addChild($spContainer);
         }
         // AutoFilters
         if (!empty($filterRange)) {
             $rangeBounds = PHPExcel_Cell::rangeBoundaries($filterRange);
             $iNumColStart = $rangeBounds[0][0];
             $iNumColEnd = $rangeBounds[1][0];
             $iInc = $iNumColStart;
             while ($iInc <= $iNumColEnd) {
                 ++$countShapes[$sheetIndex];
                 // create an Drawing Object for the dropdown
                 $oDrawing = new PHPExcel_Worksheet_BaseDrawing();
                 // get the coordinates of drawing
                 $cDrawing = PHPExcel_Cell::stringFromColumnIndex($iInc - 1) . $rangeBounds[0][1];
                 $oDrawing->setCoordinates($cDrawing);
                 $oDrawing->setWorksheet($sheet);
                 // add the shape
                 $spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
                 // set the shape type
                 $spContainer->setSpType(0xc9);
                 // set the shape flag
                 $spContainer->setSpFlag(0x1);
                 // set the shape index (we combine 1-based sheet index and $countShapes to create unique shape index)
                 $reducedSpId = $countShapes[$sheetIndex];
                 $spId = $reducedSpId | $sheet->getParent()->getIndex($sheet) + 1 << 10;
                 $spContainer->setSpId($spId);
                 // keep track of last reducedSpId
                 $lastReducedSpId = $reducedSpId;
                 // keep track of last spId
                 $lastSpId = $spId;
                 $spContainer->setOPT(0x7f, 0x1040104);
                 // Protection -> fLockAgainstGrouping
                 $spContainer->setOPT(0xbf, 0x80008);
                 // Text -> fFitTextToShape
                 $spContainer->setOPT(0x1bf, 0x10000);
                 // Fill Style -> fNoFillHitTest
                 $spContainer->setOPT(0x1ff, 0x80000);
                 // Line Style -> fNoLineDrawDash
                 $spContainer->setOPT(0x3bf, 0xa0000);
                 // Group Shape -> fPrint
                 // set coordinates and offsets, client anchor
                 $endCoordinates = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::stringFromColumnIndex($iInc - 1));
                 $endCoordinates .= $rangeBounds[0][1] + 1;
                 $spContainer->setStartCoordinates($cDrawing);
                 $spContainer->setStartOffsetX(0);
                 $spContainer->setStartOffsetY(0);
                 $spContainer->setEndCoordinates($endCoordinates);
                 $spContainer->setEndOffsetX(0);
                 $spContainer->setEndOffsetY(0);
                 $spgrContainer->addChild($spContainer);
                 $iInc++;
             }
         }
         // identifier clusters, used for workbook Escher object
         $this->_IDCLs[$dgId] = $lastReducedSpId;
         // set last shape index
         $dgContainer->setLastSpId($lastSpId);
         // set the Escher object
         $this->_writerWorksheets[$sheetIndex]->setEscher($escher);
     }
 }