This file is indexed.

/usr/lib/libreoffice/share/extensions/DmathsAddon/OOoGdmath/AdditionCode.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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<?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="AdditionCode" script:language="StarBasic">&apos;OOoGdmath
&apos;Copyright (C) 2005-2009  Gilles Daurat

&apos;This program is free software; you can redistribute it and/or
&apos;modify it under the terms of the GNU General Public License
&apos;as published by the Free Software Foundation; either version 2
&apos;of the License, or (at your option) any later version.

&apos;This program is distributed in the hope that it will be useful,
&apos;but WITHOUT ANY WARRANTY; without even the implied warranty of
&apos;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
&apos;GNU General Public License for more details.

&apos;You should have received a copy of the GNU General Public License
&apos;along with this program; if not, write to the Free Software
&apos;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Option Explicit
Dim oAdditionForm as Object

Sub Main
	oAdditionForm = LoadDialog(&quot;OOoGdmath&quot;,&quot;AdditionForm&quot;)
	ChangeTitreDialog(oAdditionForm)
&apos;	RestaureForm(oAdditionForm)
	oAdditionForm.Execute()
End Sub

Private Sub AdditionCode_CheckBox1_Click()
    oAdditionForm.Model.TextBox3.Enabled = oAdditionForm.Model.CheckBox1.State
End Sub

Private Sub AdditionCode_CommandButton1_Click()
    oAdditionForm.EndExecute()
    SauveForm(oAdditionForm)
    Operation(oAdditionForm.Model.TextBox1.Text, oAdditionForm.Model.CheckBox1.State)
End Sub

Private Sub AdditionCode_CommandButton2_Click()
    oAdditionForm.EndExecute()
End Sub

Private Sub AdditionCode_Image1_Click()
    ChangeCouleur oAdditionForm.Model.Image1
End Sub

Private Sub AdditionCode_TextBox3_Change()
    oAdditionForm.Model.TextBox3.Text = Left$(oAdditionForm.Model.TextBox3.Text, 1)
End Sub

Sub InsereAdditionSoustractionSexa(tableau$(), Operation)
Dim Resultat$(3)
Dim l,h, retenue, i, resnum, terme1, terme2, resul
Dim Shapes as Object

    InitialiseDessin(False)
    Shapes=InitialiseGroupe()
    DimensionTexte &quot;8&quot;,12,l,h
    Select Case Operation
    Case &quot;+&quot;
        retenue = 0
        For i = 2 To 0 Step -1
	    	tableau$(0,i)=right(&quot;00&quot; &amp; tableau$(0,i),2)
	    	tableau$(1,i)=right(&quot;00&quot; &amp; tableau$(1,i),2)
            resnum = Val(tableau$(0, i)) + Val(tableau$(1, i)) + retenue
            If resnum &gt; 59 Then
                resnum = resnum - 60
                retenue = 1
            else
            	retenue = 0
            End If
            Resultat$(i) = Right$(&quot;00&quot; + Trim(Str(resnum)), 2)
        Next i
    Case &quot;-&quot;
        retenue = 0
        For i = 2 To 0 Step -1
	    	tableau$(0,i)=right(&quot;00&quot; &amp; tableau$(0,i),2)
	    	tableau$(1,i)=right(&quot;00&quot; &amp; tableau$(1,i),2)
            If Val(tableau$(0, i)) &lt; Val(tableau$(1, i)) Then
                resnum = 60 + Val(tableau$(0, i)) - (Val(tableau$(1, i)) + retenue)
                retenue = 1
            Else
                resnum = Val(tableau$(0, i)) - (Val(tableau$(1, i)) + retenue)
                retenue = 0
            End If
            Resultat$(i) = Right$(&quot;00&quot; + Trim(Str(resnum)), 2)
        Next i
    End Select
    if tableau$(0,0)=&quot;00&quot; and tableau$(1,0)=&quot;00&quot; then
	    terme1 = MIif(Left$(tableau$(0, 1), 1) = &quot;0&quot;, Right$(tableau$(0, 1), 1), tableau$(0, 1)) &amp; &quot;m&quot; &amp; tableau$(0, 2) &amp; &quot;s&quot;
	    terme2 = Operation &amp; MIif(Left$(tableau$(1, 1), 1) = &quot;0&quot;, Right$(tableau$(1, 1), 1), tableau$(1, 1)) &amp; &quot;m&quot; &amp; tableau$(1, 2) &amp; &quot;s&quot;
	    resul = MIif(Left$(Resultat$(1), 1) = &quot;0&quot;, Right$(Resultat$(1), 1), Resultat$(1)) &amp; &quot;m&quot; &amp; Resultat$(2) &amp; &quot;s&quot;
    else
	    terme1 = MIif(Left$(tableau$(0, 0) = &quot;0&quot;, Right$(tableau$(0, 0), 1), tableau$(0, 0)) &amp; &quot;h&quot; &amp; tableau$(0, 1) &amp; &quot;m&quot; &amp; tableau$(0, 2) &amp; &quot;s&quot;
	    terme2 = Operation &amp; MIif(Left$(tableau$(1, 0), 1) = &quot;0&quot;, Right$(tableau$(1, 0), 1), tableau$(1, 0)) &amp; &quot;h&quot; &amp; tableau$(1, 1) &amp; &quot;m&quot; &amp; tableau$(1, 2) &amp; &quot;s&quot;
	    resul = MIif(Left$(Resultat$(0), 1) = &quot;0&quot;, Right$(Resultat$(0), 1), Resultat$(0)) &amp; &quot;h&quot; &amp; Resultat$(1) &amp; &quot;m&quot; &amp; Resultat$(2) &amp; &quot;s&quot;
	End If
    AfficheTexte 10, 1, terme1, False, 0, Shapes, l, h
    AfficheTexte 10, 2, terme2, False, 0, Shapes, l, h
    
    TraceLigneGroupe Shapes, &quot;s&quot;, oAdditionForm.Model.Image1

    AfficheTexte 10, 3, resul, False, 0, Shapes, l, h

	GroupeObjet(Shapes)
	TermineDessin()
End Sub

Sub DimensionTexte(texte,taillefonte,l,h)
Dim xShape As Object
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size

	xShape = oDocumentDessin.createInstance(&quot;com.sun.star.drawing.TextShape&quot;)
	aPoint.x = 0
	aPoint.y = 0
	aSize.Width = 10
	aSize.Height = 10
	xShape.Position = aPoint
	xShape.Size=aSize
	oDocumentDessin.DrawPages.GetByIndex(0).add(xShape)
    xShape.String = texte
	xShape.Text.CharHeight=taillefonte
	xShape.Text.TextAutoGrowWidth=True
	xShape.Text.TextAutoGrowHeight=True
	l=xShape.Size.Width
	h=xShape.Size.Height
	oDocumentDessin.DrawPages.GetByIndex(0).remove(xShape)
End Sub

Function AfficheRetenue(x, y, t, sgroupe As Object,l,h) as Object
Dim j As Integer
Dim c As String
Dim xShape As Object
Dim aPoint As New com.sun.star.awt.Point
Dim n

    For j = 1 To Len(t)
        c = Mid$(t, Len(t) + 1 - j, 1)
        if c&lt;&gt;&quot;0&quot; then
			xShape = oDocumentDessin.createInstance(&quot;com.sun.star.drawing.TextShape&quot;)
			oDocumentDessin.DrawPages.GetByIndex(0).add(xShape)
	        xShape.String = c
	        xShape.Text.CharFontName = OOoGdmath_NomPolice
			xShape.Text.CharHeight = OOoGdmath_TaillePolice/2.4

			xShape.Text.CharPosture=com.sun.star.awt.FontSlant.ITALIC

			xShape.Text.TextAutoGrowWidth=True
			xShape.Text.TextAutoGrowHeight=True
			aPoint.x = (x-j)*l*2
			aPoint.y = y*h
			xShape.Position = aPoint
			If Not IsMissing(sgroupe) Then sgroupe.add(xShape)
			n=1
		End if
    Next j
    if n=1 then
		AfficheRetenue()=xShape
	else
		AfficheRetenue()=Nothing
	end if
End Function

Function AfficheTexte(x, y, t, virgule, place, sgroupe As Object,l,h) as Object
Dim j As Integer
Dim c As String
Dim xShape As Object
Dim aPoint As New com.sun.star.awt.Point

    If virgule Then
        While place &gt;= Len(t)
            t = &quot;0&quot; &amp; t
        Wend
    End If
    For j = 1 To Len(t)
        c = Mid$(t, Len(t) + 1 - j, 1)
        If c = &quot;m&quot; Then c = &quot;min&quot;
		xShape = oDocumentDessin.createInstance(&quot;com.sun.star.drawing.TextShape&quot;)
		oDocumentDessin.DrawPages.GetByIndex(0).add(xShape)
        If virgule And j - 1 = place Then
            xShape.String = c &amp; &quot;,&quot;
        Else
            xShape.String = c
        End If
        if c=chr(180) then 
        	xShape.Text.CharFontName=&quot;Symbol&quot;
        else
        	xShape.Text.CharFontName = OOoGdmath_NomPolice
        end if
		xShape.Text.CharHeight = OOoGdmath_TaillePolice
		xShape.Text.TextAutoGrowWidth=True
		xShape.Text.TextAutoGrowHeight=True
		aPoint.x = (x-j)*l*2
		aPoint.y = y*h
		xShape.Position = aPoint

		If Not IsMissing(sgroupe) Then sgroupe.add(xShape)
    Next j
	AfficheTexte()=xShape
End Function


Sub RemplaceChiffreCaractere(texte$, Caractere)
Dim k, nTexte$, j
Dim a$

    k = Len(texte$)
    nTexte$ = &quot;&quot;
    For j = 1 To k
        a$ = Mid$(texte$, j, 1)
        If a$ &gt;= &quot;0&quot; And a$ &lt;= &quot;9&quot; Then
            nTexte$ = nTexte$ &amp; Caractere
        Else
            nTexte$ = nTexte$ &amp; a$
        End If
    Next j
    texte$ = nTexte$
End Sub

Sub Operation(UnTexte As String, Optional Resultat as Boolean)
Dim Param$(2, 3)
Dim parametre() as string
Dim operande() as string
Dim texte$, a, b, texte1$, texte2$, noperande1, i, noperande2, MM, m, terme1, terme2
Dim uneOperation

	if instr(1,unTexte,&quot;+&quot;)&lt;&gt;0 then UneOperation=&quot;+&quot;
	if instr(1,unTexte,&quot;-&quot;)&lt;&gt;0 then UneOperation=&quot;-&quot;
	if instr(1,unTexte,&quot;*&quot;)&lt;&gt;0 then UneOperation=&quot;*&quot;
	if instr(1,unTexte,&quot;/&quot;)&lt;&gt;0 then UneOperation=&quot;/&quot;
	if ismissing(Resultat) then Resultat=False

    texte$ = unTexte

    If InStr(1, texte$, &quot;:&quot;) Then
        SupprimeEspace texte$
        &apos; Operations sexegesimales
        ChargeParametre texte$, operande(), UneOperation
		ChargeParametre operande(0), parametre(), &quot;:&quot;
		for i=lbound(parametre()) to ubound(parametre())
			parametre(i)=left(&quot;00&quot;, 2-len(parametre(i))) &amp; parametre(i)
			param$(0,i + 2 - ubound(parametre()))=parametre(i)
		next i
		ChargeParametre operande(1), parametre(), &quot;:&quot;
		for i=lbound(parametre()) to ubound(parametre())
			parametre(i)=left(&quot;00&quot;, 2-len(parametre(i))) &amp; parametre(i)
			param$(1,i + 2 - ubound(parametre()))=parametre(i)
		next i
        
		InsereAdditionSoustractionSexa Param$(), UneOperation
	Else
		MM = Left$(texte$, InStr(1, texte$, UneOperation) - 1)
		m = Right$(texte$, Len(texte$) - InStr(1, texte$, UneOperation))
		Select Case UneOperation
		Case &quot;*&quot;
&apos;			InsereMultiplication MM, m, False
		Case &quot;+&quot;
			InsereAdditionSoustraction MM, m, &quot;+&quot;, MIif(Resultat, oAdditionForm.Model.TextBox3.Text, &quot;&quot;)
		Case &quot;-&quot;
			If Val(MM) &lt; Val(m) Then
				MsgBoxP &quot;message1&quot;
			Else
				InsereAdditionSoustraction MM, m, &quot;-&quot;, MIif(Resultat, oAdditionForm.Model.TextBox3.Text, &quot;&quot;)
			End If
		Case &quot;/&quot;
			InsereDivisionEntiere MM, m, False
		End Select
	End If
End Sub

Sub InsereAdditionSoustraction(terme1, terme2, Operation, OperationTrou)
Dim terme(10) As String
Dim sterme(10) As String
Dim retenue as string
Dim retenues as string
Dim pemax as Integer
Dim ncmax as integer
Dim nchiffre(10) As Integer
Dim pechiffre(10) as integer
Dim l,h, i, j, k, ResultatN, Resultat$, imax, imaxd, Signe
Dim Shapes as Object
Dim tot as integer
    
    terme(1) = terme1
    terme(2) = terme2
    RemplaceVirgulePoint terme(1)
    RemplaceVirgulePoint terme(2)
    i = 1
    k = 2
    While InStr(i, terme2, &quot;+&quot;) &lt;&gt; 0
        j = InStr(i, terme2, &quot;+&quot;)
        terme(k) = Mid$(terme2, i, j - i)
        RemplaceVirgulePoint terme(k)
        i = j + 1
        k = k + 1
    Wend
    terme(k) = Right$(terme2, Len(terme2) - i + 1)
    RemplaceVirgulePoint terme(k)
    k = k + 1
    If Operation = &quot;+&quot; Then
        ResultatN = 0
        For i = 1 To k
            ResultatN = ResultatN + Val(terme(i))
        Next i
        Resultat$ = Str(ResultatN)
    End If
    If Operation = &quot;-&quot; Then Resultat$ = Str(Val(terme(1)) - Val(terme(2)))
    Resultat$ = Right$(Resultat$, Len(Resultat$) - 1)
    terme(k) = Resultat$
    pemax = 0
    ncmax = 0
    For i = 1 To k
        nchiffre(i) = InStr(1, terme(i), &quot;.&quot;)
        if nchiffre(i) = 0 then
	        pechiffre(i) = len(terme(i))
        else
        	pechiffre(i) = nchiffre(i) - 1
        end if
        if pemax &lt; pechiffre(i) then pemax = pechiffre(i)
        If nchiffre(i) &gt; 0 Then nchiffre(i) = Len(terme(i)) - nchiffre(i)
        If nchiffre(i) &gt; 0 Then terme(i) = Left$(terme(i), Len(terme(i)) - 1 - nchiffre(i)) &amp; Right$(terme(i), nchiffre(i))
        if ncmax &lt; nchiffre(i) then ncmax = nchiffre(i)
    Next i

	For i=1 to k
		sterme(i) = left$(&quot;0000000000&quot;, pemax-pechiffre(i)) &amp; terme(i) &amp; left$(&quot;0000000000&quot;, ncmax-nchiffre(i))
	next i
	
	if oAdditionForm.Model.CheckBox2.State Then 
		if Operation=&quot;+&quot; then
			retenue = &quot;&quot;
			for i = 1 to len(sterme(1))
				tot = 0
				for j= 1 to k-1
					tot = tot + val(mid(sterme(j),i,1)
				next j
				retenue = retenue &amp; trim(str(int(tot/10)))
			next i
			retenue = retenue &amp; &quot;0&quot;
		else
			retenue = &quot;&quot;
			retenues = &quot;&quot;
			for i = 1 to len(sterme(1))
				if val(mid(sterme(1),i,1)) &lt; val(mid(sterme(2),i,1)) then
					retenue = retenue &amp; &quot;1&quot;
					retenues = retenues &amp; &quot;1&quot;
				else
					retenue = retenue &amp; &quot;0&quot;
					retenues = retenues &amp; &quot;0&quot;
				end if
			next i
			retenues = retenues &amp; &quot;0&quot;
		End if
	End if
	
    InitialiseDessin(False)
    Shapes=InitialiseGroupe()
    DimensionTexte &quot;8&quot;,12,l,h

	if oAdditionForm.Model.CheckBox2.State Then 
		AfficheRetenue 9.8 + ncmax, 0.8, retenue, Shapes, l, h
		if Operation &lt;&gt; &quot;+&quot; then AfficheRetenue 9.7 + ncmax, 2.7, retenues, Shapes, l, h
	End if
	
    AfficheTexte 10 + nchiffre(1), 1, terme(1), nchiffre(1) &gt; 0, nchiffre(1), Shapes, l, h
    imax = Len(terme(1)) - nchiffre(1)
    imaxd = nchiffre(1)
    For i = 2 To k
        If imax &lt; Len(terme(i)) - nchiffre(i) Then
            imax = Len(terme(i)) - nchiffre(i)
        End If
        If imaxd &lt; nchiffre(i) Then
            imaxd = nchiffre(i)
        End If
    Next i
    For i = 2 To k-1
       AfficheTexte 10 + nchiffre(i), i, Operation &amp; left(&quot;          &quot;, pemax - pechiffre(i)) &amp; terme(i), nchiffre(i) &gt; 0, nchiffre(i), Shapes,l,h
    Next i

	TraceLigneGroupe Shapes, &quot;s&quot;,  oAdditionForm.Model.Image1

    If OperationTrou &lt;&gt; &quot;&quot; Then RemplaceChiffreCaractere terme(k), OperationTrou
    AfficheTexte 10 + nchiffre(k), k, terme(k), nchiffre(k) &gt; 0, nchiffre(k), Shapes,l,h

    GroupeObjet(Shapes)
    TermineDessin()
End Sub


</script:module>