|
Revision 30163, 1.1 kB
(checked in by rspivak, 4 years ago)
|
Added Id keyword
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 |
# $Id$ |
|---|
| 2 |
from Products.PortalTransforms.interfaces import itransform |
|---|
| 3 |
|
|---|
| 4 |
EXTRACT_BODY = 1 |
|---|
| 5 |
EXTRACT_STYLE = 0 |
|---|
| 6 |
|
|---|
| 7 |
FIX_IMAGES = 1 |
|---|
| 8 |
IMAGE_PREFIX = "img_" |
|---|
| 9 |
|
|---|
| 10 |
import os |
|---|
| 11 |
if os.name == 'posix': |
|---|
| 12 |
try: |
|---|
| 13 |
import PyUNO |
|---|
| 14 |
from office_uno import document |
|---|
| 15 |
except: |
|---|
| 16 |
from office_wvware import document |
|---|
| 17 |
else: |
|---|
| 18 |
#from office_com import document |
|---|
| 19 |
from office_wvware import document |
|---|
| 20 |
|
|---|
| 21 |
from os.path import basename |
|---|
| 22 |
|
|---|
| 23 |
class word_to_html: |
|---|
| 24 |
__implements__ = itransform |
|---|
| 25 |
|
|---|
| 26 |
__name__ = 'word_to_html' |
|---|
| 27 |
inputs = ('application/msword',) |
|---|
| 28 |
output = 'text/html' |
|---|
| 29 |
|
|---|
| 30 |
def name(self): |
|---|
| 31 |
return self.__name__ |
|---|
| 32 |
|
|---|
| 33 |
def convert(self, data, cache, **kwargs): |
|---|
| 34 |
orig_file = basename((kwargs.get('filename') or 'unknown.doc')) |
|---|
| 35 |
|
|---|
| 36 |
doc = document(orig_file, data) |
|---|
| 37 |
doc.convert() |
|---|
| 38 |
html = doc.html() |
|---|
| 39 |
|
|---|
| 40 |
path, images = doc.subObjects(doc.tmpdir) |
|---|
| 41 |
objects = {} |
|---|
| 42 |
if images: |
|---|
| 43 |
doc.fixImages(path, images, objects) |
|---|
| 44 |
doc.cleanDir(doc.tmpdir) |
|---|
| 45 |
|
|---|
| 46 |
cache.setData(html) |
|---|
| 47 |
cache.setSubObjects(objects) |
|---|
| 48 |
return cache |
|---|
| 49 |
|
|---|
| 50 |
def register(): |
|---|
| 51 |
return word_to_html() |
|---|