/**
  * Load and imports CSS.
  */
 protected function load_css()
 {
     /** @var helper_plugin_odt_dwcssloader $loader */
     $loader = plugin_load('helper', 'odt_dwcssloader');
     if ($loader != NULL) {
         $this->css = $loader->load('odt', 'odt', $this->config->getParam('css_template'), $this->config->getParam('usestyles'));
     }
     $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'));
 }
 /**
  * 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();
 }
    /**
     * Test some more  wrap CSS.
     * Part 4.
     */
    public function test_wrap_css_part2()
    {
        $properties = array();
        $css_code = '@media screen {
/*____________ help ____________*/
.dokuwiki .wrap_help { background-color: #dcc2ef; }
.dokuwiki .wrap__dark.wrap_help { background-color: #3c1757; }
.dokuwiki div.wrap_help { background-image: url(images/note/48/help.png); }
.dokuwiki span.wrap_help { background-image: url(images/note/16/help.png); }
}
@media print {
/* boxes and notes with icons
********************************************************************/

.dokuwiki div.wrap_box,
.dokuwiki div.wrap_danger, .dokuwiki div.wrap_warning, .dokuwiki div.wrap_caution, .dokuwiki div.wrap_notice, .dokuwiki div.wrap_safety,
.dokuwiki div.wrap_info, .dokuwiki div.wrap_important, .dokuwiki div.wrap_alert, .dokuwiki div.wrap_tip, .dokuwiki div.wrap_help, .dokuwiki div.wrap_todo, .dokuwiki div.wrap_download {
    border: 2px solid #999;
    padding: 1em 1em .5em;
    margin-bottom: 1.5em;
}
.dokuwiki span.wrap_box,
.dokuwiki span.wrap_danger, .dokuwiki span.wrap_warning, .dokuwiki span.wrap_caution, .dokuwiki span.wrap_notice, .dokuwiki span.wrap_safety,
.dokuwiki span.wrap_info, .dokuwiki span.wrap_important, .dokuwiki span.wrap_alert, .dokuwiki span.wrap_tip, .dokuwiki span.wrap_help, .dokuwiki span.wrap_todo, .dokuwiki span.wrap_download {
    border: 1px solid #999;
    padding: 0 .3em;
}
}';
        $import = new helper_plugin_odt_cssimport();
        $import->importFromString($css_code);
        $import->getPropertiesForElement($properties, 'span', 'dokuwiki wrap_help', 'print');
        // For debugging: this will write the parsed/imported CSS in the file
        // _test/data/tmp/odt_parsed.css
        $handle = fopen('./data/tmp/odt_parsed.css', 'w');
        fwrite($handle, $import->rulesToString());
        fclose($handle);
        // We shouldn't get any properties
        $this->assertEquals(25, count($properties));
        $this->assertEquals('1px solid #999', $properties['border']);
        $this->assertEquals('1px solid #999', $properties['border-left']);
        $this->assertEquals('1px solid #999', $properties['border-right']);
        $this->assertEquals('1px solid #999', $properties['border-top']);
        $this->assertEquals('1px solid #999', $properties['border-bottom']);
        $this->assertEquals('1px', $properties['border-width']);
        $this->assertEquals('1px', $properties['border-left-width']);
        $this->assertEquals('1px', $properties['border-right-width']);
        $this->assertEquals('1px', $properties['border-top-width']);
        $this->assertEquals('1px', $properties['border-bottom-width']);
        $this->assertEquals('solid', $properties['border-style']);
        $this->assertEquals('solid', $properties['border-left-style']);
        $this->assertEquals('solid', $properties['border-right-style']);
        $this->assertEquals('solid', $properties['border-top-style']);
        $this->assertEquals('solid', $properties['border-bottom-style']);
        $this->assertEquals('#999', $properties['border-color']);
        $this->assertEquals('#999', $properties['border-left-color']);
        $this->assertEquals('#999', $properties['border-right-color']);
        $this->assertEquals('#999', $properties['border-top-color']);
        $this->assertEquals('#999', $properties['border-bottom-color']);
        $this->assertEquals('0 .3em', $properties['padding']);
        $this->assertEquals('0', $properties['padding-top']);
        $this->assertEquals('.3em', $properties['padding-right']);
        $this->assertEquals('.3em', $properties['padding-left']);
        $this->assertEquals('0', $properties['padding-bottom']);
    }