Skip to content

Commit 01e13a5

Browse files
committed
#88 - Improve LibreOffice output by overriding the registry modifications
1 parent 4fbe84e commit 01e13a5

File tree

2 files changed

+387
-0
lines changed

2 files changed

+387
-0
lines changed

src/Engine/Convert/LibreOffice.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@ class LibreOffice extends EngineBase {
1616
protected $cmd_source_safe = FALSE;
1717

1818
public function getConvertFileShell($source, &$destination) {
19+
// Attempt to initialize and override registrymodifications.xcu
20+
if (!is_dir($this->settings['temp_dir']) . '/libreoffice') {
21+
// Run a basic conversion to attempt to init the system.
22+
$tmp = $this->getTempFile('txt');
23+
file_put_contents($tmp, "Init LibreOffice configs");
24+
$this->shell(array(
25+
Shell::arg('export HOME=' . escapeshellarg($this->settings['temp_dir']) . ';', Shell::SHELL_SAFE),
26+
$this->cmd,
27+
'--headless',
28+
'--convert-to',
29+
$this->conversion[1],
30+
'--outdir',
31+
$this->settings['temp_dir'],
32+
$tmp
33+
));
34+
@unlink($tmp);
35+
@unlink(str_replace('.txt', "." . $this->conversion[1], $tmp));
36+
37+
// Update the registry, if it was properly initialized.
38+
$reg = $this->settings['temp_dir'] . "/libreoffice/4/user/registrymodifications.xcu";
39+
if (is_file($reg)) {
40+
copy(__DIR__ . "/Resources/LibreOffice-registrymodifications.xcu", $reg);
41+
}
42+
}
43+
44+
// Build the conversion command.
1945
$destination = str_replace('.' . $this->conversion[0], '.'
2046
. $this->conversion[1], $source);
2147
return array(

0 commit comments

Comments
 (0)