/usr/lib/libreoffice/share/extensions/DmathsAddon/OOoGdmath/SauveFormCode.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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | <?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="SauveFormCode" script:language="StarBasic">'OOoGdmath
'Copyright (C) 2005-2009 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
Sub Main
Dim a, ok as Boolean
EcritFonction("sqr(x)")
a = Gdmath_Fonction.Fonction(1, ok)
a = Gdmath_Fonction.Fonction(2, ok)
End Sub
Sub InitialiseForm(uneDialogue as Object)
Dim aTexte() as String
Dim unObjet as Object
Dim i
Dim unTexte as String
aTexte = uneDialogue.Model.getElementNames()
for i=lbound(aTexte()) to ubound(aTexte())
unObjet = uneDialogue.GetControl(aTexte(i))
If instr(1, aTexte(i), "Image") Then
If left(unObjet.Model.HelpText,1)="&" Then
unTexte = Ressource(unObjet.Model, rHelpText)
unObjet.Model.HelpText = unTexte
End if
End If
If instr(1, aTexte(i), "Text") or instr(1, aTexte(i), "Echelle") or instr(1, aTexte(i), "val") or instr(1, aTexte(i), "Sommet") Then
If left(unObjet.Model.Text,1)="&" Then
unTexte = Ressource(unObjet.Model, rText)
unObjet.Model.Text = unTexte
End if
End If
If instr(1, aTexte(i), "Label") Then
If left(unObjet.Model.Label,1)="&" Then
unTexte = Ressource(unObjet.Model, rLabel)
unObjet.Model.Label = unTexte
End if
End If
next i
End Sub
Sub SauveForm(uneDialogue as Object)
if uneDialogue.GetControl("sauve").Model.State then
RemplaceConstante uneDialogue.Model.Name & "_Sauve", GetTexteForm(uneDialogue)
else
RemplaceConstante uneDialogue.Model.Name & "_Sauve", ""
end if
End Sub
Sub RestaureForm(uneDialogue as Object)
Dim uneListe as String
on error resume next
uneListe = ""
Select case uneDialogue.Model.Name
case "AdditionForm"
uneListe = AdditionForm_Sauve
case "AngleDDForm"
uneListe = AngleDDForm_Sauve
case "ArcDCForm"
uneListe = ArcDCForm_Sauve
case "CammForm"
uneListe = CammForm_Sauve
case "CarreForm"
uneListe = CarreForm_Sauve
case "CercleForm"
uneListe = CercleForm_Sauve
case "ConiquesForm"
uneListe = ConiquesForm_Sauve
case "DebugForm"
uneListe = DebugForm_Sauve
case "DivisionForm"
uneListe = DivisionForm_Sauve
case "DroiteGForm"
uneListe = DroiteGForm_Sauve
case "LosangeForm"
uneListe = LosangeForm_Sauve
case "MultiForm"
uneListe = MultiForm_Sauve
case "ParalleloForm"
uneListe = ParalleloForm_Sauve
case "QuadrillageForm"
uneListe = QuadrillageForm_Sauve
case "RapporteurForm"
uneListe = RapporteurForm_Sauve
case "RectangleForm"
uneListe = RectangleForm_Sauve
case "RepereForm"
uneListe = RepereForm_Sauve
case "RepFractionForm"
uneListe = RepFractionForm_Sauve
case "ReseauForm"
uneListe = ReseauForm_Sauve
case "TriangleForm"
uneListe = TriangleForm_Sauve
case "PolygoneRegulierForm"
uneListe = PolygoneRegulierForm_Sauve
case "TrapezeForm"
uneListe = TrapezeForm_Sauve
End Select
if uneListe<>"" then
SetTexteForm uneDialogue, uneListe
End if
End Sub
Function Ressource(unObjet as Object, typeRessource) as String
Dim unTexte
Dim tObjet
tObjet = unObjet
Select case typeRessource
case rText
unTexte = tObjet.Text
case rLabel
unTexte = tObjet.Label
case rHelpText
unTexte = tObjet.HelpText
case rTitle
unTexte = tObjet.Title
tObjet = tObjet.Model
End Select
if left(unTexte,1)="&" then
Ressource = tObjet.ResourceResolver.resolveString(mid(unTexte,2))
else
Ressource = unTexte
end if
End Function
Function GetTexteForm(uneDialogueForm as Object) as String
Dim i,j
Dim unNom as String
Dim unParam as String
Dim param as String
Dim unObjet as Object
Dim tObjet() as String
tObjet = uneDialogueForm.Model.getElementNames()
for i=lbound(tObjet()) to ubound(tObjet())
unObjet = uneDialogueForm.GetControl(tObjet(i)).Model
unParam = ""
Select Case left(unObjet.Name, 3)
case "Ima"
if (unObjet.HelpText <> "") Then unParam = unObjet.HelpText & "¤" & unObjet.BackgroundColor
case "Che", "sau"
unParam = unObjet.State
case "Tex", "val", "Som", "Ech"
unParam = unObjet.Text
case "Lab"
unParam = unObjet.Label
case "Opt"
unParam = unObjet.State
case "Lis", "Com"
if left(unObjet.Name, 4)<>"Comm" and left(unObjet.Name, 6)<>"ListeO" Then
for j = 0 to ListCount(uneDialogueForm, tObjet(i))-1
unParam = unParam & "¤" & GetList(uneDialogueForm, tObjet(i), j)
next j
unParam = mid(unParam, 2)
End if
End Select
if unParam <> "" then
RemplaceTexte unParam, chr(10), "\n"
RemplaceTexte unParam, chr(34), "\*"
RemplaceTexte unParam, ":", "\$"
RemplaceTexte unParam, ";", "\£"
If Not unObjet.Enabled then unParam = unParam & "#"
unNom = unNom & ";" & tObjet(i) & ":" & unParam
End if
next i
GetTexteForm() = mid(unNom,2)
End Function
Sub SetTexteForm(uneDialogueForm as Object, uneListe as String)
Dim i,j
Dim param() as String
Dim param1() as String
Dim param2() as String
ChargeParametre uneListe, param(), ";"
For i=lbound(param()) to ubound(param())
ChargeParametre param(i), param1(), ":"
if ubound(param1())=1 then
RemplaceTexte param1(1), "\$", ":"
RemplaceTexte param1(1), "\£", ";"
RemplaceTexte param1(1), "\n", chr(10)
RemplaceTexte param1(1), "\*", chr(34)
If right(param1(1), 1)="#" Then
uneDialogueForm.GetControl(param1(0)).Model.Enabled = False
param1(1) = left(param1(1), len(param1(1)) - 1
Else
uneDialogueForm.GetControl(param1(0)).Model.Enabled = True
End if
Select Case left(param1(0), 3)
case "Che"
uneDialogueForm.GetControl(param1(0)).Model.State = param1(1)
case "Tex", "val", "Som"
uneDialogueForm.GetControl(param1(0)).Model.Text = param1(1)
case "Lab"
uneDialogueForm.GetControl(param1(0)).Model.Label = param1(1)
case "Opt"
uneDialogueForm.GetControl(param1(0)).Model.State = param1(1)
case "Ima"
ChargeParametre param1(1), param2(), "¤"
uneDialogueForm.GetControl(param1(0)).Model.HelpText = param2(0)
uneDialogueForm.GetControl(param1(0)).Model.BackgroundColor = val(param2(1))
case "Lis", "Com"
ChargeParametre param1(1), param2(), "¤"
for j = lbound(param2()) to ubound(param2())
Add uneDialogueForm, param1(0), param2(j)
next j
End Select
End if
next i
End Sub
Sub RemplaceConstante(nomConstante, valeur)
Dim unTexte
Dim a,b,c
Dim num as Boolean
unTexte = getModuleText("Standard", "Gdmath_Dyn")
num = False
if left(nomConstante,2)="n_" then
nomConstante = mid(nomConstante, 3)
num = True
End if
a = instr(1, unTexte, nomConstante)
if a = 0 then
if num Then
unTexte = "Public Const " & nomConstante & " = " & valeur & chr(10) & unTexte
Else
unTexte = "Public Const " & nomConstante & " = " & chr(34) & valeur & chr(34) & chr(10) & unTexte
End if
Else
if num then
b = instr(a, unTexte, "=") + 1
c = instr(b + 1, unTexte, chr(10))
else
b = instr(a, unTexte, chr(34))
c = instr(b+1, unTexte, chr(34))
end if
unTexte = left(unTexte, b) & valeur & mid(unTexte, c)
End if
saveModuleText("Standard", "Gdmath_Dyn", unTexte)
End Sub
Sub EcritFonction(unTexte as String)
Dim unModule as String
unModule = "Function Fonction(x as double, ok as Boolean) as double" & chr(10) & " on error goto fin" & chr(10) & " ok = False" & chr(10) & " Fonction() =" & unTexte & chr(10) & "ok = True" & chr(10) & "fin:" & chr(10) & "End Function" & chr(10)
saveModuleText("Standard", "Gdmath_Fonction", unModule)
End Sub
Sub InitialiseGdmath()
Dim a
a = getModuleText("Standard", "Gdmath_Dyn")
End Sub
</script:module>
|