Hallo zusammen,
wenn das Clipboard MathML enthält, dann soll dies in StarMath umgeformt
und sofort als Math-OLE object in das Textdokument eingefügt werden. Das
will ich zunächst als Makro probieren.
Meine bisherige Lösung ist am Ende der Mail. Das funktioniert im
Prinzip. Aber es ist optisch nicht schön, dass zwischendurch die UI von
StarMath erscheint. Gibt es eine Möglichkeit das Kommando
.uno:InsertMathMLClipboard auch ohne die UI durchzuführen? Auf das
Kommando kann ich leider nicht verzichten, weil dort die ganze Umformung
drinsteckt.
Langfristig möchte ich das Ganze im Code haben. Wenn jemand dazu Tipps
oder Hinweise hat, würde mich das auch freuen.
Mit freundlichem Gruß
Regina
Sub PasteSpecialMathML
dim bOK as boolean: bOK = FALSE
dim oDocument as variant: oDocument = ThisComponent
dim oCurrentController as variant: oCurrentController =
oDocument.getCurrentController()
dim oXCOEO as variant
dim oMathOLE as variant
dim oMathFrame as variant
dim oDispatcher as variant
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem Verify, that clipboard contains MathML
dim oService as variant
oService =
createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
dim oContents as variant
oContents = oService.Contents
dim oVecTransferDataFlavors() as variant
oVecTransferDataFlavors = oContents.TransferDataFlavors
dim nIter as integer
dim nEnd as integer: nEnd = UBound(oVecTransferDataFlavors)
dim oCssDatatransferDataFlavor as variant
dim sMime as string
dim sHuman as string
dim nDataFlavorIndex as integer: nDataFlavorIndex = nEnd+1
For nIter=0 to nEnd
oCssDatatransferDataFlavor = oVecTransferDataFlavors(nIter)
sMime = oCssDatatransferDataFlavor.MimeType
sHuman = oCssDatatransferDataFlavor.HumanPresentableName
if sMime = "application/mathml-presentation+xml" or sMime =
"application/mathml+xml" or _
sHuman = "MathML" or sHuman = "MathML Presentation" then
nDataFlavorIndex = nIter
exit for
end if
next nIter
if nDataFlavorIndex > nEnd then
msgbox("No MathML in Clipboard")
else
oMathOLE =
oDocument.createInstance("com.sun.star.text.TextEmbeddedObject")
oMathOLE.CLSID = "078B7ABA-54FC-457F-8551-6147e776a997"
oMathOLE.AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER
rem Actually insert oMathOLE at cursor position in the document
oMathOLE.attach(oCurrentController.Selection.getByIndex(0) )
oMathOLE.LeftMargin = 0
oMathOLE.RightMargin = 0
oMathOLE.Model.BaseFontHeight = oMathOLE.Anchor.CharHeight
rem Use the command ".uno:ImportMathMLClipboard" which does the convertion
rem from MathML to StarMath
oXCOEO = oMathOLE.ExtendedControlOverEmbeddedObject
oXCOEO.doVerb(com.sun.star.embed.EmbedVerbs.MS_OLEVERB_OPEN)
oMathFrame = oMathOLE.Model.CurrentController.Frame
oDispatcher.executeDispatch(oMathFrame, ".uno:ImportMathMLClipboard",
"", 0, Array())
bOK = oMathOLE.Model.Formula<>""
oDispatcher.executeDispatch(oMathFrame, ".uno:CloseDoc", "", 0, Array())
if NOT bOK then
msgbox("Convertion to StarMath is not possible.")
oDispatcher.executeDispatch(oCurrentController.Frame,
".uno:SwBackspace", "", 0, Array())
end if
end if
End Sub
--
Liste abmelden mit E-Mail an: users+unsubscribe@de.libreoffice.org
Probleme? http://de.libreoffice.org/hilfe-kontakt/mailing-listen/abmeldung-liste/
Tipps zu Listenmails: http://wiki.documentfoundation.org/Netiquette/de
Listenarchiv: http://listarchives.libreoffice.org/de/users/
Alle E-Mails an diese Liste werden unlöschbar öffentlich archiviert
Context
- [de-users] Makro für .uno:Command in Math-OLE object · Regina Henschel
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.