Hi,

Atte André Jensen wrote:

> Hi
> 
> I'm trying to copy a part of a document while preserving the formatting 
> with python. Here's the code I have:
> 
> print rangeCursor.String
> controller = doc.getCurrentController()
> controller.select(rangeCursor)
> frame = controller.getFrame()
> properties = ()
> dispatch_helper.executeDispatch(frame, ".uno:Copy", "", 0, properties)
> dispatch_helper.executeDispatch(frame, ".uno:Paste", "", 0, properties)
> dispatch_helper.executeDispatch(frame, ".uno:Paste", "", 0, properties)
> 
> The print ensures me that rangeCursor is infact containing the desired 
> text, but still no copying is happening. I'm thinking the problem is the 
> dispatch is not using the desired text... Anyone able to help me a bit 
> further?
> 
> Also, I'm quite confused about the documentation, in this case I'd like 
> to see a list of that properties could be/do. I guess it should be 
> different for Copy and Paste, but where is this documented?
> 
> Thanks in advance for any input!
> 

If having this for Writer or Calc only is enough, there is a simpler way
of copying/pasting code. You can get the current selection into a
clipboard object by calling

obj = ThisComponent.CurrentController.getTransferable()

and (after moving the cursor to the desired destination) copy it by calling

ThisComponent.CurrentController.insertTransferable(obj)

Ciao,
Mathias

-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "[EMAIL PROTECTED]".
I use it for the OOo lists and only rarely read other mails sent to it.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to