Jonas T.
Jonas T.

Reputation: 172

Remove carriage return in python macro for libre or open office

I try to write a macro for libre/Open office in python.

i use this for replace some string and it's work :

document = XSCRIPTCONTEXT.getDocument()
search = document.createSearchDescriptor()
search.SearchString = "\:\Z"
search.SearchAll = True
search.SearchCaseSensitive = False
search.SearchRegularExpression = True
selsFound = document.findAll(search)

if selsFound.getCount() == 0:
    return
for selIndex in range(0, selsFound.getCount()):
    selFound = selsFound.getByIndex(selIndex)

    selFound.setString("")

But now i want to remove a carriage after and i can't find how. for exemple :

Mister Dean :
blablablalblal lbbla

to

Mister Dean : blablablablabla

I try with \n or \r but libre-office does not recognize the term.

Thanks for all :)

Upvotes: 0

Views: 264

Answers (1)

ngulam
ngulam

Reputation: 1075

My (LO 4.1.6.2/Linux) Online Help tells me to use a \n to search for a newline character entered with Ctrl+Enter.

If a replace instruction is not given, I get what you want. I'm pretty sure this will work for you with Python (I actually tested it with StarBasic).

edit: corrected keyboard combination

Upvotes: 0

Related Questions