Activate Math OLE without window?

Creating a macro - Writing a Script - Using the API

Activate Math OLE without window?

Postby regina » Thu Sep 07, 2017 12:16 pm

Hi all,

I want to import MathML from Clipboard in Writer in one go, using a macro. Doing it manually, you have to insert a formula, then use the command "Import MathML from Clipboard" from its Tools menu (which is .uno:ImportMathMLClipboard), and finally click into the text document to leave Math.
I can insert a Math-object into the text document and when I activate it (MS_OLEVERB_OPEN), then I can use the dispatcher to execute the uno command. That works, but opening the Math-object generates a window. Although it will be closed in a short time, that is not nice.

Is there a way to activate a Math OLE without visible window?

The relevant part of the macro is
Code: Select all   Expand viewCollapse view
dim oDispatcher as variant
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim oXCOEO as variant   
oXCOEO = oMathOLE.ExtendedControlOverEmbeddedObject
oXCOEO.doVerb(com.sun.star.embed.EmbedVerbs.MS_OLEVERB_OPEN)
dim oMathFrame as variant
oMathFrame = oMathOLE.Model.CurrentController.Frame
oDispatcher.executeDispatch(oMathFrame, ".uno:ImportMathMLClipboard", "", 0, Array())
oDispatcher.executeDispatch(oMathFrame, ".uno:CloseDoc", "", 0, Array())
regina
 
Posts: 67
Joined: Sat Apr 05, 2008 4:55 pm

Re: Activate Math OLE without window?

Postby Zizi64 » Sun Sep 24, 2017 8:37 am

You had use the Dispatcher in your macro code. Try to write the code without usage the Dispatcher, based on the API functions...

Here is an example for the Calc:
https://forum.openoffice.org/en/forum/v ... hp?t=45282

and two for the Writer:
https://forum.openoffice.org/en/forum/v ... hp?t=57298
http://140.211.11.67/en/forum/viewtopic ... 45&t=14342

and please download and study Andrew Pitonyak's free macro books.
Tibor Kovacs, Hungary; LO4.4.7, LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.4; AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 7964
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Activate Math OLE without window?

Postby regina » Sun Sep 24, 2017 5:25 pm

The problem is not the MathOLE object itself. The problem is, that inserting MathML from clipboard is only possible by the command .uno:ImportMathMLClipboard, and that needs the dispatcher. Or do I miss something?

I will upload the entire macro. Then the problem might be clearer.
Attachments
CreateMathfromClipboardInWriter.txt
Rename to .bas and insert into an empty module
(2.9 KiB) Downloaded 206 times
regina
 
Posts: 67
Joined: Sat Apr 05, 2008 4:55 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 1 guest