Atte André Jensen wrote:
Hi
I'm working with the python api and am trying to repeat part of a
document, but can't figure out how to.
Supposed I have the following in my document:
###BEGIN_MARKER###
This should be repeated 3 times
###END_MARKER###
Using the SearchDescriptor service I'm able to find the markers and
I've created a TextCursor which is set to the found text:
range = text.createTextCursor()
groupLoopBegin = doc.createSearchDescriptor()
groupLoopEnd = doc.createSearchDescriptor()
groupLoopBegin.setSearchString('###BEGIN_MARKER###')
groupLoopEnd.setSearchString('###END_MARKER###')
begin = doc.findFirst(groupLoopBegin)
while begin:
end = doc.findNext(begin.End,groupLoopEnd)
if end:
range.gotoRange(begin,False)
range.gotoRange(end,True)
# Here range contains the text to be repeated
begin = doc.findNext(end.End,groupLoopBegin)
But how do I:
I do it with the "dispatcher " but in my case i copy "all" text in
the document, there must be a way that you select only your range
>>dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
>>dispatcher.executeDispatch(oControllFrame, ".uno:SelectAll", "", 0,
Array())
then use the viewcursor and place the viewcursor at the wanted
position is your documernt
>> dispatcher.executeDispatch(oControllFrame, ".uno:Copy", "", 0, Array())
hope it helps
Fernand
1) repeat range three times?
2) search/replace only in range?
Thanks in advance for any response...
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]