Fernand Vanrie wrote:
hallo,

need some help with creating the right "context" in BASIC for accessing the ClipBoardManager object

so far if found:

oClipboard = ServiceManager.createInstanceWithContext("com.sun.star.datatransfer.clipboard.ClipboardManager",oContext)

how do i create the oContext ?

Hi Fernand.

Not sure what you are trying to do, but perhaps there is a simpler way like the way I get the clipboard text below. Instead of using ServiceManager.createInstanceWithContext() you can just use CreateUnoService() ?

Otherwise GetDefaultContext() may be the function you are looking for.

Cheers
-- Jan

' Adapted from http://www.mail-archive.com/[email protected]/msg08376.html, found as "ConvertClipToText"
Function ClipboardAsText As String
 Dim oClip As Variant, oClipContents As Variant, oTypes As Variant
 Dim oConverter, convertedString As String
 Dim i As Integer, iPlainLoc As Integer

 iPlainLoc = -1

oClip = createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
 oConverter = createUnoService("com.sun.star.script.Converter")

 oClipContents = oClip.getContents()
 oTypes = oClipContents.getTransferDataFlavors()

 Dim msg As String
 msg = ""
 For i=LBound(oTypes) To UBound(oTypes)
   If oTypes(i).MimeType = "text/plain;charset=utf-16" Then
     iPlainLoc = i
     Exit For
   End If
 Next i
 If (iPlainLoc >= 0) Then
convertedString = oConverter.convertToSimpleType(oClipContents.getTransferData(oTypes(iPlainLoc)), com.sun.star.uno.TypeClass.STRING)
   ClipboardAsText=convertedString
 End If
End Function

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to