Re: [api-dev] copy/paste with dispatcher

2008-05-04 Thread Atte André Jensen

Mathias Bauer wrote:


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)


I'm gonna try this, thanks!

--
peace, love  harmony
Atte

http://atte.dk   | http://myspace.com/attejensen
http://anagrammer.dk | http://modlys.dk

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



Re: [api-dev] copy/paste with dispatcher

2008-04-28 Thread Mathias Bauer
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]



Re: [api-dev] copy/paste with dispatcher

2008-04-24 Thread Bernard Marcelly

Message de Atte André Jensen  date 2008-04-24 11:49 :

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)



Hi,
Your Copy and Paste instructions work on the same range...
You have to select the origin range, Copy, select the destination range, 
Paste.


   Bernard


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



Re: [api-dev] copy/paste with dispatcher

2008-04-24 Thread Atte André Jensen

Bernard Marcelly wrote:


Hi,


Hi, thanks for your comments!


Your Copy and Paste instructions work on the same range...
You have to select the origin range, Copy, select the destination range, 
Paste.


I don't think this is the problem, unfortunately. This is a modified 
version of my code, where I select something (nothing) at the end of the 
document before pasting. The second print prints nothing, as I would 
have expected. Also the final insertString actually inserts (as 
expected) the string THE END at the end of the document...


So I guess the problem must be something else...

print rangeCursor.String
controller = doc.getCurrentController()
controller.select(rangeCursor)
frame = controller.getFrame()
properties = ()
dispatch_helper.executeDispatch(frame, .uno:Copy, , 0, properties)
rangeCursor.gotoEnd(False)
print rangeCursor.String
dispatch_helper.executeDispatch(frame, .uno:Paste, , 0, properties)
text.insertString(rangeCursor, THE END, True)

--
peace, love  harmony
Atte

http://atte.dk   | http://myspace.com/attejensen
http://anagrammer.dk | http://modlys.dk

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



Re: [api-dev] copy/paste with dispatcher

2008-04-24 Thread Bernard Marcelly

Message de Atte André Jensen  date 2008-04-24 13:56 :

Bernard Marcelly wrote:


Your Copy and Paste instructions work on the same range...
You have to select the origin range, Copy, select the destination range, 


Another angle (that also suggests something else is wrong): I recorded a 
simple macro (select all, 2x paste) in openoffice, and it looks like this:

( ... )

This suggests that selecting a range, and dispatching Paste two times 
should indeed copy the selected text, something I cannot make my example 
do.


So another question: Don't I need to tell dispatcher which range I want 
to copy from? In my code I did:


controller = doc.getCurrentController()
controller.select(rangeCursor)
frame = controller.getFrame()
properties = ()
dispatch_helper.executeDispatch(frame, .uno:Copy, , 0, properties)

and assumed that this would set the range. Is that infact the problem 
with my code? How do control which range the dispatcher uses for it's 
copy/paste operation?




My answer is the same as previous.
Here is a recorded macro that works :
Start record, selection of A2:B4, Copy, click D7 of the same sheet, 
Paste, click C15 of the same sheet, Paste, End record.

I have suppressed superfluous comment lines.

dim document   as object
dim dispatcher as object

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(com.sun.star.frame.DispatchHelper)

dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = ToPoint
args2(0).Value = $A$2:$B$4
dispatcher.executeDispatch(document, .uno:GoToCell, , 0, args2())

dispatcher.executeDispatch(document, .uno:Copy, , 0, Array())

dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = ToPoint
args4(0).Value = $D$7
dispatcher.executeDispatch(document, .uno:GoToCell, , 0, args4())

dispatcher.executeDispatch(document, .uno:Paste, , 0, Array())

dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = ToPoint
args6(0).Value = $C$15
dispatcher.executeDispatch(document, .uno:GoToCell, , 0, args6())

dispatcher.executeDispatch(document, .uno:Paste, , 0, Array())


   Bernard

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



Re: [api-dev] copy/paste with dispatcher

2008-04-24 Thread Fernand Vanrie

Atte André Jensen wrote:

Hi


this code works in basic

first select the textportion  and then uses this code:

yourdocument = oDoc.CurrentController.Frame
dispatcher = createUnoService(com.sun.star.frame.DispatchHelper)

dispatcher.executeDispatch(yourdocument, .uno:Copy, , 0, Array())  
copies only yhe selected portion


dispatcher.executeDispatch(yourdocument, .uno:Paste, , 0, Array()) 
 paste at the viewcursor


hope it helps

fernand


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!




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



Re: [api-dev] copy/paste with dispatcher

2008-04-24 Thread Atte André Jensen

Fernand Vanrie wrote:


this code works in basic


I know, cause you showed me that before. However I'm in python so I need 
to understand a it more of what's going on. Esp a more detailed 
explanation about select the textpotion is unclear to me. How do I 
tell the dispatcher which textRange I want to copy from?


As mantioned in another post, I did:

controller = doc.getCurrentController()
controller.select(rangeCursor)
frame = controller.getFrame()
properties = ()
dispatch_helper.executeDispatch(frame, .uno:Copy, , 0, properties)

and assumed that this would set the range, which apparently wasn't the 
case...


I really hope someone can help me.

--
peace, love  harmony
Atte

http://atte.dk   | http://myspace.com/attejensen
http://anagrammer.dk | http://modlys.dk

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