Hello Ryan
2010/2/13 Ryan Prior <[email protected]>
> Hey there all,
>
> I am trying to set up an automatic word-count script that takes a
> document in a wide array of formats (.doc, .odt, .rtf, etc) and prints
> the number of words contained therein. I have been searching for a
> library that handles a wide array of text formats, and the most
> comprehensive tool seems to be OOo. However, I'm having a lot of
> trouble scripting it using Uno.
>
> First of all, I'm currently trying to use PyUno for the scripting.
> Here's what my session looks like:
>
> > r...@ryan-desktop:~$ openoffice.org -headless
> -accept="socket,host=localhost,port=2002;urp;"
> > r...@ryan-desktop:~$ python
> > Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55)
> > [GCC 4.4.1] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import uno
> > >>> localContext = uno.getComponentContext()
> > >>> resolver =
> localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver",localContext)
> > >>> remoteContext =
> resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
> > >>> desktop =
> remoteContext.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop",remoteContext)
> > >>> document = desktop.getCurrentComponent()
> > >>> controller = document.getCurrentController()
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > AttributeError: 'NoneType' object has no attribute 'getCurrentController'
>
> The commands I entered come from these sources:
> http://www.devshed.com/c/a/Python/Python-and-OpenOfficeorg/1/
>
> http://codesnippets.services.openoffice.org/Office/Office.FetchingServicesFromDesktop.snip
>
> I'm using Python 2.6.4, PyUno 1.9, and OOo 3.1.1 on Ubuntu Karmic.
>
>
> So, my questions are these:
>
> * Is there a better way to do word counting than using PyUno, as I'm
> trying to do?
> * How can I use PyUno (or another tool) to connect to OOo, load a
> document, and retrieve the word count?
>
>
you should ask this questions in [email protected]
This is a general user mailing list, not for programming in UNO using OOo
API.
Regards
Ariel