[Solved] [Python] Read Writer text paragraph by paragraph
Posted: Wed Aug 07, 2013 1:52 pm
I would like to remotely read the content of a loaded document, paragraph by paragraph. After the initial connect to OO
So far I've gotten to
but that gives me the whole text plainly.
What I would like to do is go from paragraph to paragraph, query the kind/type of the paragraph, and then read the text for that one paragraph only. Even better, could I noodle through the text of the paragraph and find formatting, like bolding or italic?
Any help is appreciated Thanks!
Code: Select all
>>> import uno
>>> local = uno.getComponentContext()
>>> resolver = local.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local)
>>> context = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
>>> desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
>>> document = desktop.loadComponentFromURL("file:///bla.doc", "_blank", 0, ())
>>> cursor = document.Text.createTextCursor()
Code: Select all
>>> document.Text.getString()
What I would like to do is go from paragraph to paragraph, query the kind/type of the paragraph, and then read the text for that one paragraph only. Even better, could I noodle through the text of the paragraph and find formatting, like bolding or italic?
Any help is appreciated Thanks!