Commit 35a44256e83b0367b72af51558900e4e90228266
1 parent
ac46000f
Merged in from STABLE trunk...
KTS-3232 "Uno module appears to require editing document conversion scripts" Fixed. Allow ooProgramPath to be set as an environment variable. Committed By: Conrad Vermeulen Reviewed By: Megan Watson git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.5.3-Release-Branch@8842 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
25 additions
and
6 deletions
bin/openoffice/DocumentConverter.py
| ... | ... | @@ -11,6 +11,15 @@ |
| 11 | 11 | |
| 12 | 12 | #DEFAULT_OPENOFFICE_PORT = 8100 |
| 13 | 13 | |
| 14 | +import sys | |
| 15 | +import os | |
| 16 | + | |
| 17 | +ooProgramPath = os.environ.get('ooProgramPath') | |
| 18 | +if ooProgramPath is None: | |
| 19 | + ooProgramPath = "/usr/lib64/ooo-2.0/program" | |
| 20 | + | |
| 21 | +sys.path.append(ooProgramPath) | |
| 22 | + | |
| 14 | 23 | import uno |
| 15 | 24 | from os.path import abspath, splitext |
| 16 | 25 | from com.sun.star.beans import PropertyValue |
| ... | ... | @@ -79,7 +88,7 @@ def _unoProps(**args): |
| 79 | 88 | |
| 80 | 89 | |
| 81 | 90 | class DocumentConverter: |
| 82 | - | |
| 91 | + | |
| 83 | 92 | def __init__(self, host, port): |
| 84 | 93 | localContext = uno.getComponentContext() |
| 85 | 94 | resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext) |
| ... | ... | @@ -97,7 +106,7 @@ class DocumentConverter: |
| 97 | 106 | |
| 98 | 107 | inputUrl = self._fileUrl(argv[1]) |
| 99 | 108 | outputUrl = self._fileUrl(argv[2]) |
| 100 | - | |
| 109 | + | |
| 101 | 110 | document = self.desktop.loadComponentFromURL(inputUrl, "_blank", 0, _unoProps(Hidden=True, ReadOnly=True)) |
| 102 | 111 | document.storeToURL(outputUrl, _unoProps(FilterName=filterName)) |
| 103 | 112 | document.close(True) |
| ... | ... | @@ -120,20 +129,20 @@ class DocumentConverter: |
| 120 | 129 | ext = splitext(path)[1] |
| 121 | 130 | if ext is not None: |
| 122 | 131 | return ext[1:].lower() |
| 123 | - | |
| 132 | + | |
| 124 | 133 | def _fileUrl(self, path): |
| 125 | 134 | return uno.systemPathToFileUrl(abspath(path)) |
| 126 | 135 | |
| 127 | 136 | |
| 128 | 137 | if __name__ == "__main__": |
| 129 | 138 | from sys import argv, exit |
| 130 | - | |
| 139 | + | |
| 131 | 140 | if len(argv) < 3: |
| 132 | 141 | print "USAGE: " + argv[0] + " <input-file> <output-file> <host> <port>" |
| 133 | 142 | exit(255) |
| 134 | 143 | |
| 135 | 144 | try: |
| 136 | - converter = DocumentConverter(argv[3],argv[4]) | |
| 145 | + converter = DocumentConverter(argv[3],argv[4]) | |
| 137 | 146 | converter.convert(argv[1], argv[2]) |
| 138 | 147 | except DocumentConversionException, exception: |
| 139 | 148 | print "ERROR! " + str(exception) | ... | ... |
search2/indexing/extractorCore.inc.php
| ... | ... | @@ -339,6 +339,8 @@ abstract class DocumentExtractor |
| 339 | 339 | */ |
| 340 | 340 | abstract class ExternalDocumentExtractor extends DocumentExtractor |
| 341 | 341 | { |
| 342 | + protected $allowOutput = false; | |
| 343 | + | |
| 342 | 344 | /** |
| 343 | 345 | * Initialise the extractor. |
| 344 | 346 | * |
| ... | ... | @@ -347,6 +349,14 @@ abstract class ExternalDocumentExtractor extends DocumentExtractor |
| 347 | 349 | { |
| 348 | 350 | parent::__construct(); |
| 349 | 351 | putenv('LANG=en_US.UTF-8'); |
| 352 | + | |
| 353 | + $config = KTConfig::getSingleton(); | |
| 354 | + putenv('ooProgramPath=' . $config->get('openoffice/ProgramPath', '/usr/lib64/ooo-2.0/program2')); | |
| 355 | + } | |
| 356 | + | |
| 357 | + public function setAllowOutput($allowOutput) | |
| 358 | + { | |
| 359 | + $this->allowOutput = $allowOutput; | |
| 350 | 360 | } |
| 351 | 361 | |
| 352 | 362 | /** |
| ... | ... | @@ -419,7 +429,7 @@ abstract class ExternalDocumentExtractor extends DocumentExtractor |
| 419 | 429 | @unlink($script_out); |
| 420 | 430 | } |
| 421 | 431 | |
| 422 | - return ($res == 0) && empty($this->output); | |
| 432 | + return ($res == 0) && (empty($this->output) || $this->allowOutput); | |
| 423 | 433 | } |
| 424 | 434 | |
| 425 | 435 | /** | ... | ... |