示例#1
0
 /**
  * Applies the given $style to the $odtElement.
  *
  * $style is an array of style information as produced by {@link 
  * ezcDocumentPcssStyleInferencer::inferenceFormattingRules()}. The styling 
  * information given in this array is applied to the $odtElement by 
  * creating a new anonymous style in the ODT style section and applying the 
  * corresponding attributes to reference this style.
  * 
  * @param ezcDocumentLocateable $docBookElement
  * @param DOMElement $odtElement
  * @throws ezcDocumentOdtStylerNotInitializedException
  * @access private
  */
 public function applyStyles(ezcDocumentLocateable $docBookElement, DOMElement $odtElement)
 {
     $styles = $this->preProcessStyles($docBookElement, $odtElement, $this->styleInferencer->inferenceFormattingRules($docBookElement));
     foreach ($this->styleGenerators as $generator) {
         if ($generator->handles($odtElement)) {
             $generator->createStyle($this->styleInfo, $odtElement, $styles);
         }
     }
 }
示例#2
0
 protected function assertCorrectMerge($property, $styles, $expected)
 {
     $inferencer = new ezcDocumentPcssStyleInferencer(false);
     $element = $this->xpath->query('//doc:article')->item(0);
     $inferencer->appendStyleDirectives(array(new ezcDocumentPcssLayoutDirective(array('article'), $styles)));
     $rules = $inferencer->inferenceFormattingRules($element);
     $this->assertTrue(isset($rules[$property]), "Missing property {$property} in inferenced rules.");
     $this->assertEquals(1, count($rules), "Wrong number of inferenced rules");
     $this->assertEquals($expected, (string) $rules[$property]);
 }
示例#3
0
文件: wrapper.php 项目: bmdevel/ezc
 /**
  * Create and append a new page.
  *
  * @param ezcDocumentPcssStyleInferencer $inferencer
  */
 public function appendPage(ezcDocumentPcssStyleInferencer $inferencer)
 {
     $current = $this->transactions[$this->transaction]->currentPage;
     // Check if the next page already exists
     if (isset($this->pages[$current + 1])) {
         $current = ++$this->transactions[$this->transaction]->currentPage;
         return $this->pages[$current];
     }
     $current = ++$this->transactions[$this->transaction]->currentPage;
     $styles = $inferencer->inferenceFormattingRules(new ezcDocumentPdfPage(0, 0, 0, 0, 0));
     $page = ezcDocumentPdfPage::createFromSpecification($current, $styles['page-size']->value, $styles['page-orientation']->value, $styles['margin']->value, $styles['padding']->value);
     // Store in which transaction the page has been created
     $this->pages[$current] = $page;
     $this->transactions[$this->transaction]->pageCreations[] = $current;
     // Tell driver about new page
     $this->createPage($page->width, $page->height);
     return $page;
 }