protected static function fetch_supported_formats() {
        global $CFG;

        if (!isset(self::$formats)) {
            // Ask unoconv for it's list of supported document formats.
            $cmd = escapeshellcmd(trim($CFG->pathtounoconv)) . ' --show';
            $pipes = array();
            $pipesspec = array(2 => array('pipe', 'w'));
            $proc = proc_open($cmd, $pipesspec, $pipes);
            $programoutput = stream_get_contents($pipes[2]);
            fclose($pipes[2]);
            proc_close($proc);
            $matches = array();
            preg_match_all('/\[\.(.*)\]/', $programoutput, $matches);

            $formats = $matches[1];
            self::$formats = array_unique($formats);
        }

        return self::$formats;
    }