예제 #1
0
 /**
  * This function creates a style for changin the page format if required.
  * It returns NULL if no page format change is pending or if the current
  * page format is equal to the required page format.
  *
  * @param string  $parent Parent style name.
  * @return string Name of the style to be used for changing page format
  */
 protected function doPageFormatChange($parent = NULL)
 {
     if ($this->changePageFormat == NULL) {
         // Error.
         return NULL;
     }
     $data = $this->changePageFormat;
     $this->changePageFormat = NULL;
     if (empty($parent)) {
         $parent = 'Standard';
     }
     // Create page layout style
     $format_string = $this->page->formatToString($data['format'], $data['orientation'], $data['margin-top'], $data['margin-right'], $data['margin-bottom'], $data['margin-left']);
     $properties['style-name'] = 'Style-Page-' . $format_string;
     $properties['width'] = $data['width'];
     $properties['height'] = $data['height'];
     $properties['margin-top'] = $data['margin-top'];
     $properties['margin-bottom'] = $data['margin-bottom'];
     $properties['margin-left'] = $data['margin-left'];
     $properties['margin-right'] = $data['margin-right'];
     $style_obj = $this->factory->createPageLayoutStyle($properties);
     $style_name = $style_obj->getProperty('style-name');
     // Save style data in page style array, in common styles and set current page format
     $master_page_style_name = $format_string;
     $this->page_styles[$master_page_style_name] = $style_name;
     $this->docHandler->addAutomaticStyle($style_obj);
     $this->page->setFormat($data['format'], $data['orientation'], $data['margin-top'], $data['margin-right'], $data['margin-bottom'], $data['margin-left']);
     // Create paragraph style.
     $properties = array();
     $properties['style-name'] = 'Style-' . $format_string;
     $properties['style-parent'] = $parent;
     $properties['style-master-page-name'] = $master_page_style_name;
     $properties['page-number'] = 'auto';
     $style_obj = $this->factory->createParagraphStyle($properties);
     $style_name = $style_obj->getProperty('style-name');
     $this->docHandler->addAutomaticStyle($style_obj);
     // Save paragraph style name in 'Do not delete array'!
     $this->preventDeletetionStyles[] = $style_name;
     return $style_name;
 }
예제 #2
0
 /**
  * This function sets the page format.
  * The format, orientation and page margins can be changed.
  * See function queryFormat() in ODT/page.php for supported formats.
  *
  * @param string  $format         e.g. 'A4', 'A3'
  * @param string  $orientation    e.g. 'portrait' or 'landscape'
  * @param numeric $margin_top     Top-Margin in cm, default 2
  * @param numeric $margin_right   Right-Margin in cm, default 2
  * @param numeric $margin_bottom  Bottom-Margin in cm, default 2
  * @param numeric $margin_left    Left-Margin in cm, default 2
  */
 public function setPageFormat($format, $orientation, $margin_top = 2, $margin_right = 2, $margin_bottom = 2, $margin_left = 2)
 {
     $data = array();
     // Adjust given parameters, query resulting format data and get format-string
     $this->page->queryFormat($data, $format, $orientation, $margin_top, $margin_right, $margin_bottom, $margin_left);
     $format_string = $this->page->formatToString($data['format'], $data['orientation'], $data['margin-top'], $data['margin-right'], $data['margin-bottom'], $data['margin-left']);
     if ($format_string == $this->page->toString()) {
         // Current page already uses this format, no need to do anything...
         return;
     }
     // Create page layout style
     $properties['style-name'] = 'Style-Page-' . $format_string;
     $properties['width'] = $data['width'];
     $properties['height'] = $data['height'];
     $properties['margin-top'] = $data['margin-top'];
     $properties['margin-bottom'] = $data['margin-bottom'];
     $properties['margin-left'] = $data['margin-left'];
     $properties['margin-right'] = $data['margin-right'];
     $style_name = $this->factory->createPageLayoutStyle($style_content, $properties);
     // Save style data in page style array, in common styles and set current page format
     $master_page_style_name = $format_string;
     $this->page_styles[$master_page_style_name] = $style_name;
     $this->autostyles[$style_name] = $style_content;
     $this->page->setFormat($data['format'], $data['orientation'], $data['margin-top'], $data['margin-right'], $data['margin-bottom'], $data['margin-left']);
     // Create paragraph style.
     $properties = array();
     $properties['style-name'] = 'Style-' . $format_string;
     $properties['master-page-name'] = $master_page_style_name;
     $properties['style-parent'] = 'Standard';
     $properties['page-number'] = 'auto';
     $style_name = $this->factory->createParagraphStyle($style_content, $properties);
     $this->autostyles[$style_name] = $style_content;
     // Save paragraph style name in 'Do not delete array'!
     $this->preventDeletetionStyles[] = $style_name;
     // Open paragraph with new style format
     $this->p_close();
     $this->p_open($style_name);
 }