You are here

private function PHPExcel_Reader_Excel2007::_readRibbon in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php \PHPExcel_Reader_Excel2007::_readRibbon()
1 call to PHPExcel_Reader_Excel2007::_readRibbon()
PHPExcel_Reader_Excel2007::load in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php
* Loads PHPExcel from file * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php, line 1995

Class

PHPExcel_Reader_Excel2007
PHPExcel_Reader_Excel2007

Code

private function _readRibbon($excel, $customUITarget, $zip) {
  $baseDir = dirname($customUITarget);
  $nameCustomUI = basename($customUITarget);

  // get the xml file (ribbon)
  $localRibbon = $this
    ->_getFromZipArchive($zip, $customUITarget);
  $customUIImagesNames = array();
  $customUIImagesBinaries = array();

  // something like customUI/_rels/customUI.xml.rels
  $pathRels = $baseDir . '/_rels/' . $nameCustomUI . '.rels';
  $dataRels = $this
    ->_getFromZipArchive($zip, $pathRels);
  if ($dataRels) {

    // exists and not empty if the ribbon have some pictures (other than internal MSO)
    $UIRels = simplexml_load_string($this
      ->securityScan($dataRels), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
    if ($UIRels) {

      // we need to save id and target to avoid parsing customUI.xml and "guess" if it's a pseudo callback who load the image
      foreach ($UIRels->Relationship as $ele) {
        if ($ele["Type"] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image') {

          // an image ?
          $customUIImagesNames[(string) $ele['Id']] = (string) $ele['Target'];
          $customUIImagesBinaries[(string) $ele['Target']] = $this
            ->_getFromZipArchive($zip, $baseDir . '/' . (string) $ele['Target']);
        }
      }
    }
  }
  if ($localRibbon) {
    $excel
      ->setRibbonXMLData($customUITarget, $localRibbon);
    if (count($customUIImagesNames) > 0 && count($customUIImagesBinaries) > 0) {
      $excel
        ->setRibbonBinObjects($customUIImagesNames, $customUIImagesBinaries);
    }
    else {
      $excel
        ->setRibbonBinObjects(NULL);
    }
  }
  else {
    $excel
      ->setRibbonXMLData(NULL);
    $excel
      ->setRibbonBinObjects(NULL);
  }
}