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,6 +11,15 @@ | ||
| 11 | 11 | ||
| 12 | #DEFAULT_OPENOFFICE_PORT = 8100 | 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 | import uno | 23 | import uno |
| 15 | from os.path import abspath, splitext | 24 | from os.path import abspath, splitext |
| 16 | from com.sun.star.beans import PropertyValue | 25 | from com.sun.star.beans import PropertyValue |
| @@ -79,7 +88,7 @@ def _unoProps(**args): | @@ -79,7 +88,7 @@ def _unoProps(**args): | ||
| 79 | 88 | ||
| 80 | 89 | ||
| 81 | class DocumentConverter: | 90 | class DocumentConverter: |
| 82 | - | 91 | + |
| 83 | def __init__(self, host, port): | 92 | def __init__(self, host, port): |
| 84 | localContext = uno.getComponentContext() | 93 | localContext = uno.getComponentContext() |
| 85 | resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext) | 94 | resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext) |
| @@ -97,7 +106,7 @@ class DocumentConverter: | @@ -97,7 +106,7 @@ class DocumentConverter: | ||
| 97 | 106 | ||
| 98 | inputUrl = self._fileUrl(argv[1]) | 107 | inputUrl = self._fileUrl(argv[1]) |
| 99 | outputUrl = self._fileUrl(argv[2]) | 108 | outputUrl = self._fileUrl(argv[2]) |
| 100 | - | 109 | + |
| 101 | document = self.desktop.loadComponentFromURL(inputUrl, "_blank", 0, _unoProps(Hidden=True, ReadOnly=True)) | 110 | document = self.desktop.loadComponentFromURL(inputUrl, "_blank", 0, _unoProps(Hidden=True, ReadOnly=True)) |
| 102 | document.storeToURL(outputUrl, _unoProps(FilterName=filterName)) | 111 | document.storeToURL(outputUrl, _unoProps(FilterName=filterName)) |
| 103 | document.close(True) | 112 | document.close(True) |
| @@ -120,20 +129,20 @@ class DocumentConverter: | @@ -120,20 +129,20 @@ class DocumentConverter: | ||
| 120 | ext = splitext(path)[1] | 129 | ext = splitext(path)[1] |
| 121 | if ext is not None: | 130 | if ext is not None: |
| 122 | return ext[1:].lower() | 131 | return ext[1:].lower() |
| 123 | - | 132 | + |
| 124 | def _fileUrl(self, path): | 133 | def _fileUrl(self, path): |
| 125 | return uno.systemPathToFileUrl(abspath(path)) | 134 | return uno.systemPathToFileUrl(abspath(path)) |
| 126 | 135 | ||
| 127 | 136 | ||
| 128 | if __name__ == "__main__": | 137 | if __name__ == "__main__": |
| 129 | from sys import argv, exit | 138 | from sys import argv, exit |
| 130 | - | 139 | + |
| 131 | if len(argv) < 3: | 140 | if len(argv) < 3: |
| 132 | print "USAGE: " + argv[0] + " <input-file> <output-file> <host> <port>" | 141 | print "USAGE: " + argv[0] + " <input-file> <output-file> <host> <port>" |
| 133 | exit(255) | 142 | exit(255) |
| 134 | 143 | ||
| 135 | try: | 144 | try: |
| 136 | - converter = DocumentConverter(argv[3],argv[4]) | 145 | + converter = DocumentConverter(argv[3],argv[4]) |
| 137 | converter.convert(argv[1], argv[2]) | 146 | converter.convert(argv[1], argv[2]) |
| 138 | except DocumentConversionException, exception: | 147 | except DocumentConversionException, exception: |
| 139 | print "ERROR! " + str(exception) | 148 | print "ERROR! " + str(exception) |
search2/indexing/extractorCore.inc.php
| @@ -339,6 +339,8 @@ abstract class DocumentExtractor | @@ -339,6 +339,8 @@ abstract class DocumentExtractor | ||
| 339 | */ | 339 | */ |
| 340 | abstract class ExternalDocumentExtractor extends DocumentExtractor | 340 | abstract class ExternalDocumentExtractor extends DocumentExtractor |
| 341 | { | 341 | { |
| 342 | + protected $allowOutput = false; | ||
| 343 | + | ||
| 342 | /** | 344 | /** |
| 343 | * Initialise the extractor. | 345 | * Initialise the extractor. |
| 344 | * | 346 | * |
| @@ -347,6 +349,14 @@ abstract class ExternalDocumentExtractor extends DocumentExtractor | @@ -347,6 +349,14 @@ abstract class ExternalDocumentExtractor extends DocumentExtractor | ||
| 347 | { | 349 | { |
| 348 | parent::__construct(); | 350 | parent::__construct(); |
| 349 | putenv('LANG=en_US.UTF-8'); | 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,7 +429,7 @@ abstract class ExternalDocumentExtractor extends DocumentExtractor | ||
| 419 | @unlink($script_out); | 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 | /** |