OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

putting simple text (string variable) to clipboard

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Peter
OOo Enthusiast
OOo Enthusiast


Joined: 28 May 2004
Posts: 105
Location: Berlin / Germany

PostPosted: Tue Jul 04, 2006 11:54 pm    Post subject: putting simple text (string variable) to clipboard Reply with quote

Hi,

found
http://www.oooforum.org/forum/viewtopic.phtml?t=6065
but I want to do that in BASIC without using the Dispatcher.

Any hints?

Peter
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1313

PostPosted: Wed Jul 05, 2006 1:09 pm    Post subject: Reply with quote

Take this as a starter - it is rather straightforward

Good luck,

ms777

Code:
Private oTRX

Sub Main
Dim null as Object
oClip = createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
oTRX = createUnoListener("TR_", "com.sun.star.datatransfer.XTransferable")
oClipContents = oClip.setContents(oTRX, null)
End Sub

function TR_getTransferData( aFlavor as com.sun.star.datatransfer.DataFlavor ) as Any
if (aFlavor.MimeType = "text/plain;charset=utf-16") then
  TR_getTransferData = "From OO with love ..."
  endif
end function
 
function TR_getTransferDataFlavors() as any
Dim aF as new com.sun.star.datatransfer.DataFlavor
aF.MimeType =    "text/plain;charset=utf-16"
aF.HumanPresentableName = "Unicode-Text"
TR_getTransferDataFlavors = Array(aF)
end function
 
function TR_isDataFlavorSupported( aFlavor as com.sun.star.datatransfer.DataFlavor ) as Boolean
'call MyPlaySoundSystem("SystemAsterisk", true) 'My XP system beep - shows that this routine is called every 2 seconds
TR_isDataFlavorSupported = (aFlavor.MimeType = "text/plain;charset=utf-16")
end function
Back to top
View user's profile Send private message
Peter
OOo Enthusiast
OOo Enthusiast


Joined: 28 May 2004
Posts: 105
Location: Berlin / Germany

PostPosted: Mon Jul 10, 2006 3:19 am    Post subject: Reply with quote

Thanks, you helped me again a lot.

But - I have a generally understanding question. How can I see, which interfaces can work as listeners and which not?

Regards

Peter
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1313

PostPosted: Mon Jul 10, 2006 7:24 am    Post subject: Reply with quote

Hi,

all interfaces can be used with the createUnoListener method. I am quite sure that this is not really the intended use of createUnoListener, but it works ...

ms777
Back to top
View user's profile Send private message
xuedm
General User
General User


Joined: 25 Sep 2006
Posts: 7

PostPosted: Sun Feb 11, 2007 2:34 am    Post subject: Reply with quote

Dear both,

Thanks for your code. I can modify text in clipboard.

Now, I have another question. How to set a textfield or checkbox into clipboard like your code?

Any hints?

Dingmeng
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group