Commit 8ebc6778 authored by Thibaut Deheunynck's avatar Thibaut Deheunynck

Add New chain for PortalTransform. These Chains allow to extract content.xml...

Add New chain for PortalTransform. These Chains allow to extract content.xml file from odt file (zip file)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24247 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4f817b0f
from Products.PortalTransforms.interfaces import itransform
from oood_commandtransform import OOOdCommandTransform, OOoDocumentDataStream
from Products.ERP5.Document.File import _unpackData
from zLOG import LOG
from Products.ERP5OOo.OOoUtils import OOoBuilder
import re
class OdtToXml:
"""Transforms ODT to Doc by using oood"""
__implements__ = itransform
__name__ = 'odt_to_xml'
inputs = ('application/vnd.oasis.opendocument.text',)
output = 'text/xml'
tranform_engine = OOOdCommandTransform.__module__
def name(self):
return self.__name__
def __getattr__(self, attr):
if attr == 'inputs':
return self.config['inputs']
if attr == 'output':
return self.config['output']
raise AttributeError(attr)
def convert(self, orig, data, cache=None, filename=None, context=None, **kwargs):
data = _unpackData(orig)
doc = OOOdCommandTransform(context, filename, data, self.inputs[0])
doc.convert()
builder = OOoBuilder(doc)
content = builder.extract('content.xml')
if cache is not None:
cache.setData(content)
return cache
else:
stream = OOoDocumentDataStream()
stream.setData(content)
return stream
def register():
return OdtToXml()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment