Just for fun with graphics

Well, it looks like this has turned into really fun :upside_down_face:

sokol92

Unfortunately your code snippet does not work…

Sub GetDataFromClipBoard()

    Dim oClip As Object, aDataFlavours As Object, oClipContents As Object
    Dim aBytes() As Byte, oData As Object, i%, j%
	
    oClip = createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
    If IsNull(oClip.getContents) Or IsEmpty(oClip.getContents)  Then Exit Sub
    oClipContents = oClip.getContents()
    aDataFlavours = oClipContents.getTransferDataFlavors

    For i = LBound(aDataFlavours) To UBound(aDataFlavours)    
        If aDataFlavours(i).MimeType Like "*FileList*"  Then
            oData = oClipContents.getTransferData(aDataFlavours(i))
            If IsArray(oData) Then
                Redim aBytes(Ubound(oData))
                For j = 0 To UBound(oData) Step 2
                    aBytes(j+1) = oData(j+1)
                    On Error Resume Next
                    aBytes(j) = IIf(oData(j) = 0 And oData(j+1) = 0, 10, oData(j))
                    If Err <> 0 Then Err.Clear
                Next j
                MsgBox CStr(aBytes) ' does not show scandinavian charachters
            End If
        End If
    Next  i
End Sub

Yes, interestingly, it displays Cyrillic letters correctly for me.
Let’s figure it out and find the culprit!

It didn’t take long to find the culprit.

aBytes(j) = IIf(oData(j) < 0, 256 + oData(j), IIf(oData(j) = 0 And oData(j+1) = 0, 10, oData(j)))

2025-11-01 143858

1 Like

sokol92

It works perfectly!

Näyttökuva 2025-11-01 134831
:wink:

1 Like

I’m done with this thing.
PoorMan’s ClipBoardDrop.odt (22.2 KB)

1 Like

@sokol92 that can’t be a correct code to handle UTF-16! Sorry, it can!

Finally, I found a way to copy the image data from an image object in a dialog box to the clipboard. But unfortunately I cannot paste the image data elsewhere. For example, save as a file from the clipboard to the desktop.

In this case transferring the imagedata via clipboard is only possible within LibreOffice, for example from a Writer project to another Writer project. The reason for this is that LibreOffice cannot save the filename in UTF-16 format, which the clipboard needs for understanding what is being done with the stored data when right clicking and selecting paste.

Assuming you are interested you can download the test projects from the links below…
ClipBoardTest.odt (26.0 KB)
2ndClipBoardTest.odt (21.4 KB)