예제 #1
0
 /**
  * Load and configure units helper.
  */
 protected function setupUnits()
 {
     // Load helper class for unit conversion.
     $this->units = plugin_load('helper', 'odt_units');
     $this->units->setPixelPerEm(14);
     $this->units->setTwipsPerPixelX($this->config->getParam('twips_per_pixel_x'));
     $this->units->setTwipsPerPixelY($this->config->getParam('twips_per_pixel_y'));
 }
예제 #2
0
 /**
  * Ensure that conversion to points works correctly.
  */
 public function test_toPoints()
 {
     $units = new helper_plugin_odt_units();
     // Set base values.
     $units->setTwipsPerPixelX(16);
     $units->setTwipsPerPixelY(20);
     $units->setPixelPerEm(14);
     $this->assertEquals($units->getPixelPerEm(), 14);
     $this->assertEquals($units->toPoints('1cm'), '28.346456514353pt');
     $this->assertEquals($units->toPoints('1mm'), '2.8346456514353pt');
     $this->assertEquals($units->toPoints('1in'), '0.089605556pt');
     $this->assertEquals($units->toPoints('1pc'), '12pt');
     $this->assertEquals($units->toPoints('1px', 'x'), '0.8pt');
     $this->assertEquals($units->toPoints('1px', 'y'), '1pt');
     $this->assertEquals($units->toPoints('1em'), '14pt');
 }
예제 #3
0
 /**
  * Constructor. Loads and imports CSS and helper plugins.
  */
 public function __construct()
 {
     $this->factory = plugin_load('helper', 'odt_stylefactory');
     /** @var helper_plugin_odt_dwcssloader $loader */
     $loader = plugin_load('helper', 'odt_dwcssloader');
     if ($loader != NULL) {
         $this->css = $loader->load('odt', 'odt', $this->getConf('template'));
     }
     $this->import = plugin_load('helper', 'odt_cssimport');
     if ($this->import != NULL) {
         $this->import->importFromString($this->css);
     }
     // Call adjustLengthValues to make our callback function being called for every
     // length value imported. This gives us the chance to convert it once from
     // pixel to points.
     $this->import->adjustLengthValues(array($this, 'adjustLengthCallback'));
     // Load helper class for unit conversion.
     $this->units = plugin_load('helper', 'odt_units');
     $this->units->setPixelPerEm(14);
     $this->units->setTwipsPerPixelX($this->getConf('twips_per_pixel_x'));
     $this->units->setTwipsPerPixelY($this->getConf('twips_per_pixel_y'));
     $this->meta = new ODTMeta();
 }