Howto read MathML from Windows clipboard

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
regina
Posts: 67
Joined: Sat Apr 05, 2008 4:55 pm

Howto read MathML from Windows clipboard

Post by regina »

Hi all,

the "Math Input Panel" (Windows 7 or later; mip.exe) puts its result as MathML into the clipboard. I want to get access to that MathML item, but it is not detected as DataFlavor. Other kind of items are detected with the following macro and I can get the data. But in case of "Math Input Panel" only the MathML item exists in the clipboard. Look at the clipboard with a clipboard Viewer, e.g. "Free Clipboard Viewer" or old WinXP clipbrd.exe.

Code: Select all

Sub ReadFromClipboard
Dim null As Object
Dim sClipName As String
Dim oClip as variant
Dim oClipContents as variant
sClipName = "com.sun.star.datatransfer.clipboard.SystemClipboard"
oClip = createUnoService(sClipName)
oClipContents = oClip.getContents()
Dim flavors as variant
flavors = oClipContents.getTransferDataFlavors()
Dim aDataFlavor as new com.sun.star.datatransfer.DataFlavor
Dim i as integer
Dim nCount as integer: nCount = UBound (flavors)+1
msgbox "Count = " & nCount
dim sMessage as string
For i = LBound (flavors) To UBound (flavors)
	sMessage =  "[" & i & "] "
	aDataFlavor = flavors(i)
	sMessage = sMessage & aDataFlavor.MimeType & CHR$(13) & aDataFlavor.HumanPresentableName
	msgbox sMessage
Next
End Sub
Has someone a working macro for that task? If not possible with com.sun.star.datatransfer.clipboard.SystemClipboard, then perhaps with the Windows API? The result should be a byte array.
User avatar
karolus
Volunteer
Posts: 1226
Joined: Sat Jul 02, 2011 9:47 am

Re: Howto read MathML from Windows clipboard

Post by karolus »

Hi Regina

Without Win 7 or later I cannot really work on it, but maybe you'll find some hints on this sites

( Sorry - no offence - I'm pretty sure youre able to use SearchEngines )
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 24.8… flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
regina
Posts: 67
Joined: Sat Apr 05, 2008 4:55 pm

Re: Howto read MathML from Windows clipboard

Post by regina »

I have solved the problem for me, not by using a macro, but by implementing a new feature. You can test it in a build from master. You get a new item "Insert MathML from clipboard" in menu Tools in Math module in a current build from master.
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Howto read MathML from Windows clipboard

Post by Villeroy »

Wow. Thank you very much.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply