/usr/lib/libreoffice/share/extensions/DmathsAddon/OOoTep/InsereExpression.xba is in libreoffice-dmaths 3.4+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="InsereExpression" script:language="StarBasic">'OOoTep
'Copyright (C) 2005-2006 Gilles Daurat
'This program is free software; you can redistribute it and/or
'modify it under the terms of the GNU General Public License
'as published by the Free Software Foundation; either version 2
'of the License, or (at your option) any later version.
'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
'GNU General Public License for more details.
'You should have received a copy of the GNU General Public License
'along with this program; if not, write to the Free Software
'Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
option explicit
public oDoc as object
Sub Main()
End Sub
Function Coller1() as Object
Dim oDispatcher as Object
Dim oEmptyShapeCollection as Object
Dim oDrawDocView as Object
' Get a dispatcher, because we'll need it later.
oDispatcher = createUnoService( "com.sun.star.frame.DispatchHelper" )
' Get an empty collection of shapes. We'll need it later.
oEmptyShapeCollection = createUnoService( "com.sun.star.drawing.ShapeCollection" )
' Get the document's controller
oDrawDocView = oDocumentDessin.getCurrentController()
' Select nothing - - i.e. an empty collection of shapes.
' If you stopped the macro right now and looked at the drawing - - nothing is selected.
oDrawDocView.select( oEmptyShapeCollection )
oDrawDocView.Frame.ContainerWindow.toFront
' Now paste whatever is in the clipboard (the shape parameter) onto current page.
oDispatcher.executeDispatch(oDrawDocView.Frame, ".uno:Paste", "", 0, Array() )
Coller1() = oDocumentDessin.CurrentSelection(0)
End Function
Function InsereTexteBis(UnTexte as string, x0, y0, Optional AngleRot, Optional AlignH as integer, Optional AlignV as integer) as object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
Dim xShape as object
Dim oTexte as Object
dim ocursor as Object
Dim oDispatcher as Object
' on ouvre un document texte invisible pour mettre en forme
Dim mFileProperties(0) As New com.sun.star.beans.PropertyValue
Dim Array()
mFileProperties(0).Name = "Hidden"
mFileProperties(0).Value = True
oDocumentTexte = StarDesktop.LoadComponentFromURL("private:factory/swriter", "_blank", 0, mFileProperties())
xShape = InsereExpression(oDocumentTexte, unTexte)
oDocumentTexte.CurrentController.Select(xShape)
' On copie la formle obtnue dans le document
oDispatcher = createUnoService( "com.sun.star.frame.DispatchHelper" )
oDispatcher.executeDispatch( oDocumentTexte.getCurrentController().Frame, ".uno:Cut", "", 0, Array() )
' On ferme le fichier texte : on n'en a plus besoin
on error resume next
oDocumentTexte.close(true)
on error goto 0
' On colle le contenu du presse-papier dans le document dessin
xShape = Coller1()
aSize = xShape.Size
if not ismissing(AlignH) then
select case AlignH
case -1
aPoint.x = x0-aSize.Width
case 0
aPoint.x = x0-aSize.Width / 2
case 1
aPoint.x = x0
end Select
end if
if not ismissing(AlignV) then
select case AlignV
case -1
aPoint.y = y0-aSize.Height
case 0
aPoint.y = y0-aSize.Height / 2
case 1
aPoint.y = y0
end Select
end if
xShape.Position = aPoint
If Not IsMissing(AngleRot) and AngleRot <> 0 Then xShape.RotateAngle = AngleRot
oGroupeDessin.Add(xShape)
InsereTexteBis() = xShape
end Function
Function InsereEquation(oDoc) as Object
dim odocument as object
dim odispatcher as object
dim lesObjets as Object
dim i
odocument = oDoc.getcurrentController().Frame
odispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
odispatcher.executeDispatch(odocument, ".uno:InsertObjectStarMath", "", 0, Array())
odispatcher.executeDispatch(odocument, ".uno:Escape", "", 0, Array())
lesObjets = oDoc.EmbeddedObjects
For i = 0 to lesObjets.Count - 1
if lesObjets(i).supportsService("com.sun.star.text.TextEmbeddedObject") then
if (lesObjets(i).embeddedObject.supportsService("com.sun.star.formula.FormulaProperties")) then InsereEquation = lesObjets(i)
end if
next i
End Function
Function InsereExpression(oDoc as Object, Texte as String) as object
dim oCursor, oText
Dim xShape as Object
oCursor = oDoc.currentcontroller.getViewCursor()
oText = oDoc.Text
oText.insertString(oCursor, Texte, True)
xShape = InsereEquation(oDoc)
InsereExpression() = xShape
End Function
</script:module>
|