Skip to content

Commit

Permalink
#88 - Improve LibreOffice output by overriding the registry modificat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
stackpr committed Feb 24, 2017
1 parent 4fbe84e commit 01e13a5
Show file tree
Hide file tree
Showing 2 changed files with 387 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Engine/Convert/LibreOffice.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,32 @@ class LibreOffice extends EngineBase {
protected $cmd_source_safe = FALSE;

public function getConvertFileShell($source, &$destination) {
// Attempt to initialize and override registrymodifications.xcu
if (!is_dir($this->settings['temp_dir']) . '/libreoffice') {
// Run a basic conversion to attempt to init the system.
$tmp = $this->getTempFile('txt');
file_put_contents($tmp, "Init LibreOffice configs");
$this->shell(array(
Shell::arg('export HOME=' . escapeshellarg($this->settings['temp_dir']) . ';', Shell::SHELL_SAFE),
$this->cmd,
'--headless',
'--convert-to',
$this->conversion[1],
'--outdir',
$this->settings['temp_dir'],
$tmp
));
@unlink($tmp);
@unlink(str_replace('.txt', "." . $this->conversion[1], $tmp));

// Update the registry, if it was properly initialized.
$reg = $this->settings['temp_dir'] . "/libreoffice/4/user/registrymodifications.xcu";
if (is_file($reg)) {
copy(__DIR__ . "/Resources/LibreOffice-registrymodifications.xcu", $reg);
}
}

// Build the conversion command.
$destination = str_replace('.' . $this->conversion[0], '.'
. $this->conversion[1], $source);
return array(
Expand Down
Loading

0 comments on commit 01e13a5

Please sign in to comment.