appy.pod: added .docx and .xlsx as conversion formats for converter.py. appy.gen: translation system: if not message is present, the label itself is used for the message.
This commit is contained in:
parent
e5cef2b8a4
commit
41fbedd279
|
@ -1088,9 +1088,13 @@ class BaseMixin:
|
|||
# Fallback to 'en'.
|
||||
translation = getattr(tool, 'en').appy()
|
||||
res = getattr(translation, label, '')
|
||||
# Perform replacements if needed
|
||||
for name, repl in mapping.iteritems():
|
||||
res = res.replace('${%s}' % name, repl)
|
||||
# If still no result, put the label instead of a translated message
|
||||
if not res: res = label
|
||||
else:
|
||||
# Perform replacements
|
||||
res = res.replace('\r\n', '<br/>').replace('\n', '<br/>')
|
||||
for name, repl in mapping.iteritems():
|
||||
res = res.replace('${%s}' % name, repl)
|
||||
return res
|
||||
|
||||
def getPageLayout(self, layoutType):
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
import os.path
|
||||
import appy
|
||||
from appy.shared.utils import executeCommand
|
||||
from appy.gen.plone25.wrappers import AbstractWrapper
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -109,4 +112,14 @@ class ToolWrapper(AbstractWrapper):
|
|||
def getAvailableLanguages(self):
|
||||
'''Returns the list of available languages for this application.'''
|
||||
return [(t.id, t.title) for t in self.translations]
|
||||
|
||||
def convert(self, fileName, format):
|
||||
'''Launches a UNO-enabled Python interpreter as defined in the self for
|
||||
converting, using OpenOffice in server mode, a file named p_fileName
|
||||
into an output p_format.'''
|
||||
convScript = '%s/pod/converter.py' % os.path.dirname(appy.__file__)
|
||||
cmd = '%s %s "%s" %s -p%d' % (self.unoEnabledPython, convScript,
|
||||
fileName, format, self.openOfficePort)
|
||||
self.log('Executing %s...' % cmd)
|
||||
return executeCommand(cmd) # The result can contain an error message
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -291,10 +291,7 @@ class FileWrapper:
|
|||
if format:
|
||||
if not tool: return
|
||||
# Convert the dumped file using OpenOffice
|
||||
convScript = '%s/converter.py' % os.path.dirname(appy.pod.__file__)
|
||||
cmd = '%s %s "%s" %s -p%d' % (tool.unoEnabledPython, convScript,
|
||||
filePath, format, tool.openOfficePort)
|
||||
errorMessage = executeCommand(cmd)
|
||||
errorMessage = tool.convert(filePath, format)
|
||||
# Even if we have an "error" message, it could be a simple warning.
|
||||
# So we will continue here and, as a subsequent check for knowing if
|
||||
# an error occurred or not, we will test the existence of the
|
||||
|
|
|
@ -37,6 +37,8 @@ FILE_TYPES = {'odt': 'writer8',
|
|||
'doc': 'MS Word 97',
|
||||
'xls': 'MS Excel 97',
|
||||
'ppt': 'MS PowerPoint 97',
|
||||
'docx': 'MS Word 2007 XML',
|
||||
'xlsx': 'Calc MS Excel 2007 XML',
|
||||
}
|
||||
# Conversion from odt to odt does not make any conversion, but updates indexes
|
||||
# and linked documents.
|
||||
|
@ -57,7 +59,7 @@ DEFAULT_PORT = 2002
|
|||
|
||||
# ------------------------------------------------------------------------------
|
||||
class Converter:
|
||||
'''Converts an document readable by OpenOffice into pdf, doc, txt or rtf.'''
|
||||
'''Converts a document readable by OpenOffice into pdf, doc, txt, rtf...'''
|
||||
exeVariants = ('soffice.exe', 'soffice')
|
||||
pathReplacements = {'program files': 'progra~1',
|
||||
'openoffice.org 1': 'openof~1',
|
||||
|
@ -194,11 +196,19 @@ class Converter:
|
|||
from com.sun.star.beans import PropertyValue
|
||||
try:
|
||||
# Loads the document to convert in a new hidden frame
|
||||
prop = PropertyValue()
|
||||
prop.Name = 'Hidden'
|
||||
prop.Value = True
|
||||
prop = PropertyValue(); prop.Name = 'Hidden'; prop.Value = True
|
||||
if self.inputType == 'csv':
|
||||
prop2 = PropertyValue()
|
||||
prop2.Name = 'FilterFlags'
|
||||
prop2.Value = '59,34,76,1'
|
||||
#prop2.Name = 'FilterData'
|
||||
#prop2.Value = 'Any'
|
||||
props = (prop, prop2)
|
||||
else:
|
||||
props = (prop,)
|
||||
# Give some additional params if we need to open a CSV file
|
||||
self.doc = self.oo.loadComponentFromURL(self.docUrl, "_blank", 0,
|
||||
(prop,))
|
||||
props)
|
||||
if self.inputType == 'odt':
|
||||
# Perform additional tasks for odt documents
|
||||
self.updateOdtDocument()
|
||||
|
|
Loading…
Reference in a new issue