... | ... |
@@ -143,6 +143,25 @@ function write_comparaison () { |
143 | 143 |
typevotes=$(sqlite_request "select nom from votes") |
144 | 144 |
nb_cols=$(( $(wc -w <<< $id_cols) + $(wc -w <<< $typevotes) * ${#groupe[@]} )) |
145 | 145 |
last_col=$(awk -v n=$nb_cols 'BEGIN{printf("%c%c", n < 27 ? "" : int(n/26) + 64, (n % 26) + (n % 26 == 0 ? 26 : 0) + 64)}' | tr -d '\0') |
146 |
+ function write_cell () { |
|
147 |
+ case $1 in |
|
148 |
+ url) |
|
149 |
+ cell='<table:table-cell office:value-type="string" calcext:value-type="string">' |
|
150 |
+ cell+="<text:p><text:a xlink:href=\"$2\" xlink:type=\"simple\">$3</text:a></text:p>";; |
|
151 |
+ texte) |
|
152 |
+ cell='<table:table-cell office:value-type="string" calcext:value-type="string">' |
|
153 |
+ cell+="<text:p>$2</text:p>" |
|
154 |
+ ;; |
|
155 |
+ nombre) |
|
156 |
+ cell="<table:table-cell office:value-type=\"float\" office:value=\"$2\" calcext:value-type=\"float\">" |
|
157 |
+ cell+="<text:p>$2</text:p>" |
|
158 |
+ ;; |
|
159 |
+ *) |
|
160 |
+ return 1;; |
|
161 |
+ esac |
|
162 |
+ cell+='</table:table-cell>' |
|
163 |
+ echo $cell >> "$content" |
|
164 |
+ } |
|
146 | 165 |
|
147 | 166 |
echo "génération du fichier $result" |
148 | 167 |
|
... | ... |
@@ -213,20 +232,12 @@ EOcontent |
213 | 232 |
|
214 | 233 |
IFS=$IFS_ |
215 | 234 |
for colonne in $id_cols; do |
216 |
- cat >> "$content" << EOcontent |
|
217 |
- <table:table-cell office:value-type="string" calcext:value-type="string"> |
|
218 |
- <text:p>$colonne</text:p> |
|
219 |
- </table:table-cell> |
|
220 |
-EOcontent |
|
235 |
+ write_cell texte $colonne |
|
221 | 236 |
done |
222 | 237 |
|
223 | 238 |
for typevote in $typevotes; do |
224 | 239 |
for g in "${groupe[@]}"; do |
225 |
- cat >> "$content" << EOcontent |
|
226 |
- <table:table-cell office:value-type="string" calcext:value-type="string"> |
|
227 |
- <text:p>$typevote - $g</text:p> |
|
228 |
- </table:table-cell> |
|
229 |
-EOcontent |
|
240 |
+ write_cell texte "$typevote - $g" |
|
230 | 241 |
done |
231 | 242 |
done |
232 | 243 |
|
... | ... |
@@ -246,33 +257,16 @@ EOcontent |
246 | 257 |
url=$(cut -d'|' -sf 4 <<< $data) |
247 | 258 |
test $adoption -eq 1 && adoption='oui' || adoption='non' |
248 | 259 |
|
249 |
- cat >> "$content" << EOcontent |
|
250 |
- <table:table-row table:style-name="ro1"> |
|
251 |
-EOcontent |
|
260 |
+ echo '<table:table-row table:style-name="ro1">' >> "$content" |
|
261 |
+ |
|
252 | 262 |
if test -n "$url"; then |
253 |
- cat >> "$content" << EOcontent |
|
254 |
- <table:table-cell office:value-type="string" calcext:value-type="string"> |
|
255 |
- <text:p><text:a xlink:href="$url" xlink:type="simple">$scrutin</text:a></text:p> |
|
256 |
- </table:table-cell> |
|
257 |
-EOcontent |
|
263 |
+ write_cell url "$url" $scrutin |
|
258 | 264 |
else |
259 |
- cat >> "$content" << EOcontent |
|
260 |
- <table:table-cell office:value-type="float" office:value="$scrutin" calcext:value-type="float"> |
|
261 |
- <text:p>$scrutin</text:p> |
|
262 |
- </table:table-cell> |
|
263 |
-EOcontent |
|
265 |
+ write_cell nombre $scrutin |
|
264 | 266 |
fi |
265 |
- cat >> "$content" << EOcontent |
|
266 |
- <table:table-cell office:value-type="string" calcext:value-type="string"> |
|
267 |
- <text:p>$date</text:p> |
|
268 |
- </table:table-cell> |
|
269 |
- <table:table-cell office:value-type="string" calcext:value-type="string"> |
|
270 |
- <text:p>${title//\'/'}</text:p> |
|
271 |
- </table:table-cell> |
|
272 |
- <table:table-cell office:value-type="string" calcext:value-type="string"> |
|
273 |
- <text:p>${adoption}</text:p> |
|
274 |
- </table:table-cell> |
|
275 |
-EOcontent |
|
267 |
+ write_cell texte "$date" |
|
268 |
+ write_cell texte "${title//\'/'}" |
|
269 |
+ write_cell texte "$adoption" |
|
276 | 270 |
|
277 | 271 |
for typevote in 0 1 2 3; do |
278 | 272 |
vote_cible[$typevote]=$(sqlite_request "select |
... | ... |
@@ -292,11 +286,7 @@ EOcontent |
292 | 286 |
else |
293 | 287 |
panurge=0 |
294 | 288 |
fi |
295 |
- cat >> "$content" << EOcontent |
|
296 |
- <table:table-cell office:value-type="float" office:value="$panurge" calcext:value-type="float"> |
|
297 |
- <text:p>$panurge</text:p> |
|
298 |
- </table:table-cell> |
|
299 |
-EOcontent |
|
289 |
+ write_cell nombre $panurge |
|
300 | 290 |
|
301 | 291 |
if test -n "$nom"; then |
302 | 292 |
for typevote in 0 1; do |
... | ... |
@@ -317,22 +307,12 @@ EOcontent |
317 | 307 |
else |
318 | 308 |
loyaute=0 |
319 | 309 |
fi |
320 |
- cat >> "$content" << EOcontent |
|
321 |
- <table:table-cell office:value-type="float" office:value="$participation" calcext:value-type="float"> |
|
322 |
- <text:p>$participation</text:p> |
|
323 |
- </table:table-cell> |
|
324 |
- <table:table-cell office:value-type="float" office:value="$loyaute" calcext:value-type="float"> |
|
325 |
- <text:p>$loyaute</text:p> |
|
326 |
- </table:table-cell> |
|
327 |
-EOcontent |
|
310 |
+ write_cell nombre $participation |
|
311 |
+ write_cell nombre $loyaute |
|
328 | 312 |
fi |
329 | 313 |
|
330 | 314 |
for typevote in 0 1 2 3; do |
331 |
- cat >> "$content" << EOcontent |
|
332 |
- <table:table-cell office:value-type="float" office:value="${vote_cible[$typevote]}" calcext:value-type="float"> |
|
333 |
- <text:p>${vote_cible[$typevote]}</text:p> |
|
334 |
- </table:table-cell> |
|
335 |
-EOcontent |
|
315 |
+ write_cell nombre ${vote_cible[$typevote]} |
|
336 | 316 |
for (( g = 1; g < ${#groupe_id[@]}; g++ )); do |
337 | 317 |
votes=$(sqlite_request "select |
338 | 318 |
count(député) |
... | ... |
@@ -344,11 +324,7 @@ EOcontent |
344 | 324 |
vote is $typevote |
345 | 325 |
and |
346 | 326 |
groupe is ${groupe_id[$g]}") |
347 |
- cat >> "$content" << EOcontent |
|
348 |
- <table:table-cell office:value-type="float" office:value="$votes" calcext:value-type="float"> |
|
349 |
- <text:p>$votes</text:p> |
|
350 |
- </table:table-cell> |
|
351 |
-EOcontent |
|
327 |
+ write_cell nombre $votes |
|
352 | 328 |
done |
353 | 329 |
done |
354 | 330 |
echo '</table:table-row>' >> "$content" |