protected function _replaceTableWidth()
 {
     $matches = array();
     if (empty($this->temp_table_style) || empty($this->temp_cols)) {
         return;
     }
     // Search through all column styles for the column width ('style:width="..."').
     // If every column has a absolute width set, add them all and replace the table
     // width with the result.
     // Abort if a column has a percentage width or no width.
     $sum = 0;
     for ($index = 0; $index < $this->temp_maxcols; $index++) {
         $style_name = $this->temp_table_column_styles[$index];
         $style_obj = $this->docHandler->getStyle($style_name);
         if ($style_obj != NULL && $style_obj->getProperty('column-width') != NULL) {
             $width = $style_obj->getProperty('column-width');
             $length = strlen($width);
             $width = $this->units->toPoints($width, 'x');
             $sum += (double) trim($width, 'pt');
         } else {
             return;
         }
     }
     $style_obj = $this->docHandler->getStyle($this->temp_table_style);
     if ($style_obj != NULL) {
         $style_obj->setProperty('width', $sum . 'pt');
     }
 }
Exemple #2
0
 protected function _replaceTableWidth()
 {
     $matches = array();
     $table = $this->state->findClosestWithClass('table', 'table');
     if ($table == NULL) {
         // ??? Should not happen.
         return;
     }
     $table_style = $table->getTableStyle();
     $column_defs = $table->getTableColumnDefs();
     if (empty($table_style) || empty($column_defs)) {
         return;
     }
     // Search through all column styles for the column width ('style:width="..."').
     // If every column has a absolute width set, add them all and replace the table
     // width with the result.
     // Abort if a column has a percentage width or no width.
     $sum = 0;
     $table_column_styles = $table->getTableColumnStyles();
     for ($index = 0; $index < $table->getTableMaxColumns(); $index++) {
         $style_name = $table_column_styles[$index];
         $style_obj = $this->docHandler->getStyle($style_name);
         if ($style_obj != NULL && $style_obj->getProperty('column-width') != NULL) {
             $width = $style_obj->getProperty('column-width');
             $length = strlen($width);
             $width = $this->units->toPoints($width, 'x');
             $sum += (double) trim($width, 'pt');
         } else {
             return;
         }
     }
     $style_obj = $this->docHandler->getStyle($table_style);
     if ($style_obj != NULL) {
         $style_obj->setProperty('width', $sum . 'pt');
     }
 }