This file is indexed.

/usr/lib/libreoffice/share/extensions/DmathsAddon/Dmaths2/FractionFunctions.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
<?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="FractionFunctions" script:language="StarBasic">&apos;************************************************
&apos;Copyright (C) Andy Lewis.  (lewiss@ntlworld.com)
&apos;téléchargé sur www.ooomacros.org
&apos;
&apos;This library is free software; you can redistribute it and/or
&apos;modify it under the terms of the GNU Lesser General Public Licence (LGPL)
&apos;as published by the Free Software Foundation; either
&apos;version 2.1 of the License, or (at your option) any later version.

&apos;This library 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 GNU
&apos;General Public License for more details.

&apos;You should have received a copy of the GNU General Public Licence (GPL)
&apos;along with this library; if not, write to the Free Software
&apos;Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
&apos;************************************************
&apos;Routines to handle fractions.  These are stored in arrays &quot;Frac(1) as Long&quot; with Frac(0)
&apos; as the numerator and Frac(1) as the denominator
option explicit

&apos;___________________________________________________________________________________________
&apos;Returns the HCF (or GCD) of a and b

Function HCF(byval a as long, byval b as long) as long
	Dim remainder as long, temp as long
	if a=0 or b=0 then HCF=1:exit function
	a=abs(a) : b=abs(b)
	if b&gt;a then temp=a : a=b : b=temp
	do
		remainder = a mod b
		if remainder=0 then
			HCF = b
		else
			a=b: b=remainder
		end if
	loop until remainder = 0
End Function

&apos;___________________________________________________________________________________________
&apos;Reduce Frac() to its lowest terms

Sub Cancel(frac() as long)
	Dim nHCF as long
	nHCF = HCF(frac(0),frac(1))
	frac(0)=frac(0)/nHCF : frac(1) = frac(1)/nHCF
End Sub

&apos;___________________________________________________________________________________________
&apos;Perform arithmetic on Frac1() and Frac2(); result is stored in Fracresult

Sub AddFracs(frac1() as long, frac2() as long, fracresult() as long)
	fracresult(0)=frac1(0)*frac2(1) + frac2(0)*frac1(1)
	fracresult(1)=frac1(1)*frac2(1)
	Cancel(fracresult())
End Sub

Sub SubtractFracs(frac1() as long, frac2() as long, fracresult() as long)
	fracresult(0)=frac1(0)*frac2(1) - frac2(0)*frac1(1)
	fracresult(1)=frac1(1)*frac2(1)
	Cancel(fracresult())
End Sub

Sub MultiplyFracs(frac1() as long, frac2() as long, fracresult() as long)
	fracresult(0)=frac1(0)*frac2(0)
	fracresult(1)=frac1(1)*frac2(1)
	Cancel(fracresult())
End Sub

Sub DivideFracs(frac1() as long, frac2() as long, fracresult() as long)
	fracresult(0)=frac1(0)*frac2(1)
	fracresult(1)=frac1(1)*frac2(0)
	Cancel(fracresult())
End Sub

&apos;___________________________________________________________________________________________
&apos;Convert frac1() to a whole number part and a fractional remainder stored in fracresult()

Sub FractionToMixed(frac1() as long,wholeno as long, fracresult() as long)
	Dim temp as long
	temp=frac1(0) Mod frac1(1)
	wholeno = (frac1(0) - temp)/frac1(1)
	fracresult(0) = temp
	fracresult(1) = frac1(1)
	Cancel(fracresult())
End Sub

&apos;___________________________________________________________________________________________
&apos;Convert a mixed number stored in wholeno and frac1() to an improper fraction in fracresult()

Sub MixedToFraction(wholeno as long, frac1() as long, fracresult() as long)
	fracresult(0)=wholeno*frac1(1) + frac1(0)
	fracresult(1) = frac1(1)
	Cancel(fracresult())
End Sub

&apos;___________________________________________________________________________________________
&apos;fracresult() = 1/frac1()

Sub Reciprocal(frac1() as long, fracresult() as long)
	Dim temp as long
	temp=frac1(0)
	fracresult(0)=frac1(1): fracresult(1)=temp
End Sub

&apos;___________________________________________________________________________________________
&apos;Approximate frac1() by the closest fraction with denominator &lt;= maxdenom;
&apos;Result is stored in fracresult()

Sub ApproximateFraction(frac1() as long,maxdenom as long, fracresult() as long)
	Dim latestA as long
	Dim previousP as long, latestP as long, tempP as long
	Dim previousQ as long, latestQ as long, tempQ as long
	Dim latestFrac(1) as long, sign as integer
	
	sign=sgn(frac1(0)) : frac1(0)=abs(frac1(0))
	FractionToMixed(frac1(), previousP, latestfrac())
	previousQ = 1
	if latestfrac(0)=0 then
		fracresult(0) = sign*previousP : fracresult(1) = previousQ
		exit sub
	end if
 
	Reciprocal(latestFrac(),latestFrac())
	FractionToMixed(latestFrac(), latestQ, latestfrac())
	latestP = latestQ*previousP+1
	do until latestQ &gt; maxdenom or latestFrac(0)=0
		Reciprocal(latestFrac(),latestFrac())
		FractionToMixed(latestFrac(), latestA, latestfrac())
		tempP = latestA*latestP+previousP
		previousP=latestP : latestP = tempP
		tempQ = latestA*latestQ+previousQ
		previousQ=latestQ : latestQ = tempQ
	loop
	if latestQ&gt;maxdenom then	
		fracresult(0) = sign*previousP : fracresult(1) = previousQ
	else
		fracresult(0) = sign*latestP : fracresult(1) = latestQ
	endif	
end sub

&apos;___________________________________________________________________________________________
&apos;Convert a decimal number to a whole number and a fraction in lowest terms

Sub DecimaltoMixed(decimal as double,wholeno as long, fracresult() as long)
	Dim decimalstring as string, afterpoint as string, pointposition as integer
	
	decimalstring = cstr(decimal)
	pointposition=instr(decimalstring,&quot;.&quot;)
	if pointposition = 0 then
		fracresult(0)=decimal : fracresult(1)=1
	else
		beforepoint = left(decimalstring,pointposition-1)
		wholeno=cLng(beforepoint)
		afterpoint = mid(decimalstring,pointposition+1
		fracresult(0)=cLng(afterpoint)
		fracresult(1)=10^len(afterpoint)
		Cancel(fracresult())
	end if
end sub
		
&apos;___________________________________________________________________________________________
&apos;Convert a decimal number to an improper fraction in lowest terms

Sub DecimaltoFraction(decimal as double, fracresult() as long)
	Dim decimalstring as string, afterpoint as string, beforepoint as string
	Dim pointposition as integer
	
	decimalstring = format(decimal, &quot;0.######&quot;)
	pointposition=instr(decimalstring,&quot;.&quot;)
	if pointposition = 0 then
		fracresult(0)=decimal : fracresult(1)=1
	else
		beforepoint = left(decimalstring,pointposition-1)
		afterpoint = mid(decimalstring,pointposition+1)
		fracresult(0)=cLng(beforepoint &amp; afterpoint)
		fracresult(1)=10^len(afterpoint)
		Cancel(fracresult())
	end if
end sub
		
&apos;___________________________________________________________________________________________
&apos;Approximate a decimal number by the closest improper fraction with denominator &lt;= maxdenom;
&apos;Result is stored in fracresult()

Sub ApproxDecimaltoFraction(decimal as double, maxdenom as long, fracresult() as long)
	DecimaltoFraction(decimal, fracresult())
	ApproximateFraction(fracresult(),maxdenom, fracresult())
end sub

</script:module>