Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
PortalTransforms.transforms.office_com.document Class Reference
Inheritance diagram for PortalTransforms.transforms.office_com.document:
Inheritance graph
[legend]
Collaboration diagram for PortalTransforms.transforms.office_com.document:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def convert
def html

Public Attributes

 fullname

Detailed Description

Definition at line 15 of file office_com.py.


Constructor & Destructor Documentation

def PortalTransforms.transforms.office_com.document.__init__ (   self,
  name,
  data 
)
Initialization: create tmp work
directory and copy the document into a file

Definition at line 17 of file office_com.py.

00017 
00018     def __init__(self, name, data):
00019         """Initialization: create tmp work
00020         directory and copy the document into a file"""
00021         commandtransform.__init__(self, name)
00022         name = self.name()
00023         if not name.endswith('.doc'):
00024             name = name + ".doc"
00025         self.tmpdir, self.fullname = self.initialize_tmpdir(data, filename=name)

Here is the call graph for this function:


Member Function Documentation

Definition at line 26 of file office_com.py.

00026 
00027     def convert(self):
00028         try:
00029             # initialize COM for multi-threading, ignoring any errors
00030             # when someone else has already initialized differently.
00031             pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)
00032         except pythoncom.com_error:
00033             pass
00034 
00035         word = Dispatch("Word.Application")
00036         word.Visible = 0
00037         word.DisplayAlerts = 0
00038         doc = word.Documents.Open(self.fullname)
00039         # Let's set up some html saving options for this document
00040         doc.WebOptions.RelyOnCSS = 1
00041         doc.WebOptions.OptimizeForBrowser = 1
00042         doc.WebOptions.BrowserLevel = 0 # constants.wdBrowserLevelV4
00043         doc.WebOptions.OrganizeInFolder = 0
00044         doc.WebOptions.UseLongFileNames = 1
00045         doc.WebOptions.RelyOnVML = 0
00046         doc.WebOptions.AllowPNG = 1
00047         # And then save the document into HTML
00048         doc.SaveAs(FileName = "%s.htm" % (self.fullname),
00049                    FileFormat = 8) # constants.wdFormatHTML)
00050 
00051         # TODO -- Extract Metadata (author, title, keywords) so we
00052         # can populate the dublin core
00053         # Converter will need to be extended to return a dict of
00054         # possible MD fields
00055 
00056         doc.Close()
00057         # word.Quit()

Definition at line 58 of file office_com.py.

00058 
00059     def html(self):
00060         htmlfile = open(self.fullname + '.htm', 'r')
00061         html = htmlfile.read()
00062         htmlfile.close()
00063         html = scrubHTML(html)
00064         body = bodyfinder(html)
00065         return body

Here is the call graph for this function:


Member Data Documentation

Definition at line 24 of file office_com.py.


The documentation for this class was generated from the following file: