/usr/lib/libreoffice/share/extensions/DmathsAddon/Dmaths2/GraphDialogFns.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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | <?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="GraphDialogFns" script:language="StarBasic">'************************************************
'Copyright (C) Andy Lewis. (lewiss@ntlworld.com)
'téléchargé sur www.ooomacros.org
'
'This library is free software; you can redistribute it and/or
'modify it under the terms of the GNU Lesser General Public Licence (LGPL)
'as published by the Free Software Foundation; either
'version 2.1 of the License, or (at your option) any later version.
'This library 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 Licence (GPL)
'along with this library; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'************************************************
'Routines required by the GraphDialog box
'This module requires modules "AxesDrawing" and "GraphDrawing"
option explicit
private goGraphDialog as object
private GraphDialogExists as boolean
'___________________________________________________________________________________________
sub OpenGraphDialog()
DialogLibraries.loadLibrary( "Dmaths" )
DialogLibraries.loadLibrary( "Dmaths2" )
if not GraphDialogExists then
goGraphDialog = Dmaths.LoadDialog("Dmaths2","GraphDialog")
GraphDialogExists=TRUE
end if
goGraphDialog.SetVisible(TRUE)
goGraphDialog.SetPosSize(0,0,0,0,com.sun.star.awt.PosSize.POS)
If getguitype = 1 Then oDocumentCourant.CurrentController.Frame.ContainerWindow.Visible = False
do
loop
end sub
'___________________________________________________________________________________________
sub GraphDialog_Close_Click()
goGraphDialog.SetVisible(FALSE)
end sub
'___________________________________________________________________________________________
sub GraphDialog_SetupAxes_Click()
if not AxesDialogExists then
goAxesDialog=LoadDialog("Dmaths2","AxesDialog")
AxesDialogExists=TRUE
end if
AutoScaleAxes()
SetUpDefaultTicks()
goAxesDialog.SetVisible(TRUE)
goAxesDialog.SetPosSize(0,0,0,0,com.sun.star.awt.PosSize.POS)
end sub
'___________________________________________________________________________________________
sub GraphDialog_DrawGraph_Click()
Dim stFunction as String, xMin as single, xMax as single
Dim m as single, c as single, ineq as string, index as integer
Dim k as single
Dim oIntersection as object
'-----------------------------------------------------------------------
'determine si les axes ont ete parametres
If AxesParametres = FALSE Then
MsgBox sVocab(iLang,368),48,"Dmaths"
Goto Fin
Endif
goShadings = createUnoService( "com.sun.star.drawing.ShapeCollection" )
For index=1 to 2
if goGraphDialog.getControl("fCheck" & cStr(index)).getState() = 1 then
stFunction = goGraphDialog.getControl("Function" & cStr(index)).Peer.getText()
stFunction = ChangeVirgulePoint(stFunction) rem modifié par Didier Dorange-Pattoret
xMin = goGraphDialog.getControl("xmin" & cStr(index)).getValue()
xMax = goGraphDialog.getControl("xmax" & cStr(index)).getValue()
ineq = goGraphDialog.getControl("fIneq" & cStr(index)).Peer.getText()
If stFunction <> "" then DrawGraph(stFunction,xMin,xMax,ineq)
End If
Next index
For index=1 to 3
if goGraphDialog.getControl("slgCheck" & cStr(index)).getState() = 1 then
m = goGraphDialog.getControl("m" & cStr(index)).getValue()
c = goGraphDialog.getControl("c" & cStr(index)).getValue()
ineq = goGraphDialog.getControl("slgIneq" & cStr(index)).Peer.getText()
StraightLineGraph(m,c,ineq)
End If
Next index
For index=1 to 2
if goGraphDialog.getControl("vlCheck" & cStr(index)).getState() = 1 then
k = goGraphDialog.getControl("k" & cStr(index)).getValue()
ineq = goGraphDialog.getControl("vlIneq" & cStr(index)).Peer.getText()
VerticalStraightLineGraph(k,ineq)
End If
Next index
if goGraphDialog.getControl("IntersectCheck").getState() = 1 and goshadings.count>1 then
oIntersection = Intersection(goDoc,goShadings)
oIntersection.Zorder=0
end if
Call GraphDrawing.Grouper rem fait grouper les objets
Fin:
end sub
'___________________________________________________________________________________________
Sub AutoScaleAxes()
Dim stFunction(2) as String, xMin(2) as single, xMax(2) as single
Dim sgap as single, yMin(2) as single, yMax(2) as single
Dim TempyMin1 as single,TempyMin2 as single,TempyMax1 as single,TempyMax2 as single
Dim x as single, y as single, index as integer, erflag as integer, nLog as integer
Dim oNull as object
For index=1 to 2
if goGraphDialog.getControl("fCheck" & cStr(index)).getState() = 1 then
stFunction(index) = ChangeVirgulePoint(goGraphDialog.getControl("Function" & cStr(index)).Peer.getText())
' modifié par Didier Dorange-Pattoret
xMin(index) = goGraphDialog.getControl("xmin" & cStr(index)).getValue()
xMax(index) = goGraphDialog.getControl("xmax" & cStr(index)).getValue()
else
xMin(index)=notdef:xMax(index)=notdef
endif
Next index
If min(xMin(1),xMin(2)) = notdef then exit sub
gsScaleLeft=min(xMin(1), xMin(2))
gsScaleRight=max(xMax(1),xMax(2))
sgap=(gsScaleRight-gsScaleLeft)/200
For index=1 to 2
if goGraphDialog.getControl("fCheck" & cStr(index)).getState() = 1 then
parse (stFunction(index),erflag)
TempyMin1=notdef : TempyMin2=notdef
TempyMax1=-notdef : TempyMax2=-notdef
x=xMin(index)
Do while x<=xMax(index)
y=f(x)
if y<>notdef then
if y<Tempymin1 then
TempyMin2=TempyMin1 : TempyMin1=y
elseif y<tempyMin2 then
Tempymin2=y
end if
if y>TempyMax1 then
TempyMax2=TempyMax1 : TempyMax1=y
elseif y>tempyMax2 then
Tempymax2=y
end if
end if
x=x+sgap
loop
if abs(TempyMin1)>1.5*abs(TempyMin2) then yMin(index)=TempyMin2 else yMin(index)=TempyMin1
if abs(TempyMax1)>1.5*abs(TempyMax2) then yMax(index)=TempyMax2 else yMax(index)=TempyMax1
endif
Next index
gsScaleBottom = min(yMin(1),yMin(2))
gsScaleTop = max(ymax(1), ymax(2))
nLog=int(log10(gsScaleTop-gsScaleBottom))
gsScaleBottom = RoundDown(gsScaleBottom,-nLog)
gsScaleTop = RoundUp(gsScaleTop,-nLog)
goAxesDialog.getControl("ScaleLeft").setText(CStr(gsScaleLeft))
' goAxesDialog.getControl("ScaleLeft").TextChanged(oNull)
goAxesDialog.getControl("ScaleRight").setText(CStr(gsScaleRight))
' goAxesDialog.getControl("ScaleRight").TextChanged(oNull)
goAxesDialog.getControl("ScaleTop").setText(CStr(gsScaleTop))
' goAxesDialog.getControl("ScaleTop").TextChanged(oNull)
goAxesDialog.getControl("ScaleBottom").setText(CStr(gsScaleBottom))
' goAxesDialog.getControl("ScaleBottom").TextChanged(oNull)
End Sub
rem macro ajoutée par Didier Dorange-Pattoret
Function ChangeVirgulePoint(sFunction as String) 'tranforme la virgule d'un chaine en un point
Dim I as integer
For I=1 To Len(sFunction)
If Mid(sFunction,I,1)="," Then Mid(sFunction,I,1,".")
Next I
ChangeVirgulePoint=sFunction
End Function
</script:module>
|