/** * @access public * @param string $sheet * @param object $core * @param object $xpath * @return object */ public function __construct($sheet = '', $core = '', $xpath = '') { if ($sheet && $core && $xpath) { $this->load('calc-table', $core, $xpath); $this->cells = array(); $this->pictures = array(); $this->sheetName = $sheet; $this->root = $xpath->query('//office:spreadsheet')->item(0); $this->obj = $this->_addElement('table', 'table'); $this->obj->setAttribute('table:name', Fonction::checkAttribute($this->sheetName)); } }
/** * Ajoute un meta utilisateur particulier * * @access public * @param string $attr L'attribut du meta * @param string $str Le contenu du meta * @return void */ public function addUserDefined($attr, $str) { $new = $this->_addMetaElement('user-defined', $str); $new->setAttribute('meta:name', Fonction::checkAttribute($attr)); }
/** * @access public * @param string $media_type * @param string $full_path * @return void */ public function addFileEntry($media_type, $full_path) { $new = $this->_addManifestElement('file-entry'); $new->setAttribute('manifest:media-type', Fonction::checkAttribute($media_type)); $new->setAttribute('manifest:full-path', Fonction::checkAttribute($full_path)); }
/** * @access protected * @return boolean */ protected function _beforeSave() { $styles = array('col' => array(), 'colused' => array(), 'row' => array(), 'rowused' => array(), 'cel' => array(), 'celused' => array(), 'gra' => array(), 'graused' => array(), 'leg' => array(), 'legused' => array(), 'tab' => array(), 'tabused' => array(), 'num' => array(), 'numused' => array()); $sheetsCols = array(); $fonts = array(); $maxCol = 0; $colDef = 'co1'; foreach ($this->sheets as $key => $sheet) { $cells = $sheet->getCells(); $cols = array(); foreach ($cells as $row => $obj) { foreach ($obj as $col => $cell) { $used = $this->_getUsedCellStyles($cell, $styles); $cell->setStyleName($used); $fonts[] = $cell->getFontFamily(); if (!isset($cols[$col]) || $cols[$col] == '' || $used['col'] != $colDef) { $cols[$col] = $used['col']; } } } if ($maxCol < $sheet->getNbColsMax()) { $maxCol = $sheet->getNbColsMax(); } $sheetsCols[$key] = Fonction::array_count_followed_values($cols, $colDef, $maxCol); foreach ($sheet->getPictures() as $pict) { $used = $this->_getUsedGraphStyles($pict, $styles); $pict->setStyle = $used['gra']; $pict->setTextStyle = $used['text']; } } $this->_insertFontFamilies($fonts); $this->_insertStyles($styles); foreach ($this->sheets as $key => $sheet) { $cells = $sheet->getCells(); foreach ($sheetsCols[$key] as $col) { $tbCol = $this->_addTableElement('table-column', null, $sheet->getXML()); $tbCol->setAttribute('table:style-name', $col['value']); if ($col['nb'] > 1) { $tbCol->setAttribute('table:number-columns-repeated', $col['nb']); } } $rowCourant = 0; ksort($cells); foreach ($cells as $row => $obj) { ksort($obj); $cell = current($obj); $st = $cell->getStyleName(); if ($rowCourant < $row - 1) { $tbRow = $this->_addTableElement('table-row', null, $sheet->getXML()); $tbRow->setAttribute('table:number-rows-repeated', $row - $rowCourant - 1); $tbCell = $this->_addTableElement('table-cell', null, $tbRow); $tbCell->setAttribute('table:style-name', 'ce1'); } $tbRow = $this->_addTableElement('table-row', null, $sheet->getXML()); $tbRow->setAttribute('table:style-name', $st['row']); $colCourant = 0; foreach ($obj as $col => $cell) { $st = $cell->getStyleName(); if ($colCourant < $col - 1) { $tbCell = $this->_addTableElement('table-cell', null, $tbRow); $tbCell->setAttribute('table:number-columns-repeated', $col - $colCourant - 1); } $tbCell = $this->_addTableElement('table-cell', null, $tbRow); $tbCell->setAttribute('table:style-name', $st['cel']); if ($cell->getFormula() != '') { $tbCell->setAttribute('table:formula', 'oooc:' . $cell->getFormula()); } if ($cell->getSpannedRows() > 1) { $tbCell->setAttribute('table:number-rows-spanned', $cell->getSpannedRows()); } if ($cell->getSpannedCols() > 1) { $tbCell->setAttribute('table:number-columns-spanned', $cell->getSpannedCols()); } if ($cell->getType() == 'float') { $tbCell->setAttribute('office:value-type', $cell->getType()); $tbCell->setAttribute('office:value', $cell->getContent()); } if ($cell->getContent() != '') { $content = $this->_addTextElement('p', $cell->getContent(), $tbCell); } $colCourant = $col; } $rowCourant = $row; } foreach ($sheet->getPictures() as $pict) { //copy($pict->getPathName(), $this->pathSave.'/Pictures/'.$pict->getName()); copy($pict->getPathName(), $this->pathSave . '/Pictures/' . $pict->getName()); //copy('/home/sanjeewa/public_html/sahana-phase2/mod/rs/S4010230.JPG', $this->pathSave.'/Pictures/'.$pict->getName()); $this->parent->manifest->addFileEntry($pict->getType(), 'Pictures/' . $pict->getName()); $tbFrame = $this->_addDrawElement('frame', null, $tbCell); $tbFrame->setAttribute('table:end-cell-address', Fonction::checkAttribute($pict->getCellAddress())); $tbFrame->setAttribute('table:end-x', $pict->getXEnd()); $tbFrame->setAttribute('table:end-y', $pict->getYEnd()); $tbFrame->setAttribute('draw:z-index', $pict->getZIndex()); $tbFrame->setAttribute('draw:name', Fonction::checkAttribute($pict->getName())); $tbFrame->setAttribute('draw:style-name', $pict->getStyle()); $tbFrame->setAttribute('draw:text-style-name', $pict->getTextStyle()); $tbFrame->setAttribute('svg:width', $pict->getWidth()); $tbFrame->setAttribute('svg:height', $pict->getHeight()); $tbFrame->setAttribute('svg:x', $pict->getSVGX()); $tbFrame->setAttribute('svg:y', $pict->getSVGY()); $tbImage = $this->_addDrawElement('image', null, $tbFrame); $tbImage->setAttribute('xlink:href', $pict->getPath() . '/' . $pict->getName()); //Fonction::checkAttribute($pict->getPath()) $tbImage->setAttribute('xlink:type', $pict->getType()); $tbImage->setAttribute('xlink:show', $pict->getShow()); $tbImage->setAttribute('xlink:actuate', $pict->getActuate()); } } return true; }