Back to index

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

List of all members.

Public Member Functions

def __init__
def convert
def html

Public Attributes

 fullname
 outputfile

Detailed Description

Definition at line 9 of file office_uno.py.


Constructor & Destructor Documentation

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

Definition at line 11 of file office_uno.py.

00011 
00012     def __init__(self, name, data):
00013         """ Initialization: create tmp work directory and copy the
00014         document into a file"""
00015  
00016         commandtransform.__init__(self, name)
00017         name = self.name()
00018         self.tmpdir, self.fullname = self.initialize_tmpdir(data, filename=name)
00019         self.outputfile = self.fullname + '.html'

Here is the call graph for this function:


Member Function Documentation

Convert the document

Definition at line 20 of file office_uno.py.

00020 
00021     def convert(self):
00022         """Convert the document"""
00023 
00024         localContext = uno.getComponentContext()
00025         resolver = localContext.ServiceManager.createInstanceWithContext(
00026                        'com.sun.star.bridge.UnoUrlResolver', localContext )
00027         ctx = resolver.resolve(
00028                        'uno:socket,host=localhost,port=2002;'
00029                        'urp;StarOffice.ComponentContext')
00030         smgr = ctx.ServiceManager
00031         desktop = smgr.createInstanceWithContext(
00032                        'com.sun.star.frame.Desktop', ctx)
00033 
00034         # load the document
00035         url = unohelper.systemPathToFileUrl(self.fullname)
00036         doc = desktop.loadComponentFromURL(url, '_blank', 0, ())
00037 
00038         filterName = 'swriter: HTML (StarWriter)'
00039         storeProps = (
00040                        PropertyValue('FilterName', 0, filterName, 0),
00041                       )
00042 
00043         # pre-create a empty file for security reason
00044         url = unohelper.systemPathToFileUrl(self.outputfile)
00045         doc.storeToURL(url, storeProps)
00046 
00047         try:
00048             doc.close(True)
00049         except com.sun.star.util.CloseVetoException:
00050             pass
00051 
00052         # maigic to release some resource
00053         ctx.ServiceManager

Definition at line 54 of file office_uno.py.

00054 
00055     def html(self):
00056         htmlfile = open(self.outputfile, 'r')
00057         html = htmlfile.read()
00058         htmlfile.close()
00059         html = scrubHTML(html)
00060         body = bodyfinder(html)
00061         return body

Here is the call graph for this function:


Member Data Documentation

Definition at line 17 of file office_uno.py.

Definition at line 18 of file office_uno.py.


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