PageRenderTime 83ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/lib/odslib.class.php

https://bitbucket.org/moodle/moodle
PHP | 1491 lines | 1047 code | 109 blank | 335 comment | 156 complexity | 8d8ead476ebb13569d69bc8e00fbb0f7 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1, BSD-3-Clause, MIT, GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * ODS file writer.
  18. * The xml used here is derived from output of LibreOffice 3.6.4
  19. *
  20. * The design is based on Excel writer abstraction by Eloy Lafuente and others.
  21. *
  22. * @package core
  23. * @copyright 2006 Petr Skoda {@link http://skodak.org}
  24. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25. */
  26. defined('MOODLE_INTERNAL') || die();
  27. /**
  28. * ODS workbook abstraction.
  29. *
  30. * @package core
  31. * @copyright 2006 Petr Skoda {@link http://skodak.org}
  32. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33. */
  34. class MoodleODSWorkbook {
  35. protected $worksheets = array();
  36. protected $filename;
  37. public function __construct($filename) {
  38. $this->filename = $filename;
  39. }
  40. /**
  41. * Create one Moodle Worksheet.
  42. *
  43. * @param string $name Name of the sheet
  44. * @return MoodleODSWorksheet
  45. */
  46. public function add_worksheet($name = '') {
  47. $ws = new MoodleODSWorksheet($name, $this->worksheets);
  48. $this->worksheets[] = $ws;
  49. return $ws;
  50. }
  51. /**
  52. * Create one Moodle Format.
  53. *
  54. * @param array $properties array of properties [name]=value;
  55. * valid names are set_XXXX existing
  56. * functions without the set_ part
  57. * i.e: [bold]=1 for set_bold(1)...Optional!
  58. * @return MoodleODSFormat
  59. */
  60. public function add_format($properties = array()) {
  61. return new MoodleODSFormat($properties);
  62. }
  63. /**
  64. * Close the Moodle Workbook.
  65. */
  66. public function close() {
  67. global $CFG;
  68. require_once($CFG->libdir . '/filelib.php');
  69. $writer = new MoodleODSWriter($this->worksheets);
  70. $contents = $writer->get_file_content();
  71. send_file($contents, $this->filename, 0, 0, true, true, $writer->get_ods_mimetype());
  72. }
  73. /**
  74. * Not required to use.
  75. * @param string $filename Name of the downloaded file
  76. */
  77. public function send($filename) {
  78. $this->filename = $filename;
  79. }
  80. }
  81. /**
  82. * ODS Cell abstraction.
  83. *
  84. * @package core
  85. * @copyright 2013 Petr Skoda {@link http://skodak.org}
  86. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  87. */
  88. class MoodleODSCell {
  89. public $value;
  90. public $type;
  91. public $format;
  92. public $formula;
  93. }
  94. /**
  95. * ODS Worksheet abstraction.
  96. *
  97. * @package core
  98. * @copyright 2006 Petr Skoda {@link http://skodak.org}
  99. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  100. */
  101. class MoodleODSWorksheet {
  102. public $data = array();
  103. public $columns = array();
  104. public $rows = array();
  105. public $showgrid = true;
  106. public $name;
  107. /**
  108. * Constructs one Moodle Worksheet.
  109. *
  110. * @param string $name The name of the file
  111. * @param array $worksheets existing worksheets
  112. */
  113. public function __construct($name, array $worksheets) {
  114. // Replace any characters in the name that Excel cannot cope with.
  115. $name = strtr($name, '[]*/\?:', ' ');
  116. if ($name === '') {
  117. // Name is required!
  118. $name = 'Sheet'.(count($worksheets)+1);
  119. }
  120. $this->name = $name;
  121. }
  122. /**
  123. * Write one string somewhere in the worksheet.
  124. *
  125. * @param integer $row Zero indexed row
  126. * @param integer $col Zero indexed column
  127. * @param string $str The string to write
  128. * @param mixed $format The XF format for the cell
  129. */
  130. public function write_string($row, $col, $str, $format = null) {
  131. if (!isset($this->data[$row][$col])) {
  132. $this->data[$row][$col] = new MoodleODSCell();
  133. }
  134. if (is_array($format)) {
  135. $format = new MoodleODSFormat($format);
  136. }
  137. $this->data[$row][$col]->value = $str;
  138. $this->data[$row][$col]->type = 'string';
  139. $this->data[$row][$col]->format = $format;
  140. $this->data[$row][$col]->formula = null;
  141. }
  142. /**
  143. * Write one number somewhere in the worksheet.
  144. *
  145. * @param integer $row Zero indexed row
  146. * @param integer $col Zero indexed column
  147. * @param float $num The number to write
  148. * @param mixed $format The XF format for the cell
  149. */
  150. public function write_number($row, $col, $num, $format = null) {
  151. if (!isset($this->data[$row][$col])) {
  152. $this->data[$row][$col] = new MoodleODSCell();
  153. }
  154. if (is_array($format)) {
  155. $format = new MoodleODSFormat($format);
  156. }
  157. $this->data[$row][$col]->value = $num;
  158. $this->data[$row][$col]->type = 'float';
  159. $this->data[$row][$col]->format = $format;
  160. $this->data[$row][$col]->formula = null;
  161. }
  162. /**
  163. * Write one url somewhere in the worksheet.
  164. *
  165. * @param integer $row Zero indexed row
  166. * @param integer $col Zero indexed column
  167. * @param string $url The url to write
  168. * @param mixed $format The XF format for the cell
  169. */
  170. public function write_url($row, $col, $url, $format = null) {
  171. if (!isset($this->data[$row][$col])) {
  172. $this->data[$row][$col] = new MoodleODSCell();
  173. }
  174. if (is_array($format)) {
  175. $format = new MoodleODSFormat($format);
  176. }
  177. $this->data[$row][$col]->value = $url;
  178. $this->data[$row][$col]->type = 'string';
  179. $this->data[$row][$col]->format = $format;
  180. $this->data[$row][$col]->formula = null;
  181. }
  182. /**
  183. * Write one date somewhere in the worksheet.
  184. *
  185. * @param integer $row Zero indexed row
  186. * @param integer $col Zero indexed column
  187. * @param string $date The url to write
  188. * @param mixed $format The XF format for the cell
  189. */
  190. public function write_date($row, $col, $date, $format = null) {
  191. if (!isset($this->data[$row][$col])) {
  192. $this->data[$row][$col] = new MoodleODSCell();
  193. }
  194. if (is_array($format)) {
  195. $format = new MoodleODSFormat($format);
  196. }
  197. $this->data[$row][$col]->value = $date;
  198. $this->data[$row][$col]->type = 'date';
  199. $this->data[$row][$col]->format = $format;
  200. $this->data[$row][$col]->formula = null;
  201. }
  202. /**
  203. * Write one formula somewhere in the worksheet.
  204. *
  205. * @param integer $row Zero indexed row
  206. * @param integer $col Zero indexed column
  207. * @param string $formula The formula to write
  208. * @param mixed $format The XF format for the cell
  209. */
  210. public function write_formula($row, $col, $formula, $format = null) {
  211. if (!isset($this->data[$row][$col])) {
  212. $this->data[$row][$col] = new MoodleODSCell();
  213. }
  214. if (is_array($format)) {
  215. $format = new MoodleODSFormat($format);
  216. }
  217. $this->data[$row][$col]->formula = $formula;
  218. $this->data[$row][$col]->format = $format;
  219. $this->data[$row][$col]->value = null;
  220. $this->data[$row][$col]->format = null;
  221. }
  222. /**
  223. * Write one blank somewhere in the worksheet.
  224. *
  225. * @param integer $row Zero indexed row
  226. * @param integer $col Zero indexed column
  227. * @param mixed $format The XF format for the cell
  228. */
  229. public function write_blank($row, $col, $format = null) {
  230. if (is_array($format)) {
  231. $format = new MoodleODSFormat($format);
  232. }
  233. $this->write_string($row, $col, '', $format);
  234. }
  235. /**
  236. * Write anything somewhere in the worksheet,
  237. * type will be automatically detected.
  238. *
  239. * @param integer $row Zero indexed row
  240. * @param integer $col Zero indexed column
  241. * @param mixed $token What we are writing
  242. * @param mixed $format The XF format for the cell
  243. */
  244. public function write($row, $col, $token, $format = null) {
  245. // Analyse what are we trying to send.
  246. if (preg_match("/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/", $token)) {
  247. // Match number
  248. return $this->write_number($row, $col, $token, $format);
  249. } elseif (preg_match("/^[fh]tt?p:\/\//", $token)) {
  250. // Match http or ftp URL
  251. return $this->write_url($row, $col, $token, '', $format);
  252. } elseif (preg_match("/^mailto:/", $token)) {
  253. // Match mailto:
  254. return $this->write_url($row, $col, $token, '', $format);
  255. } elseif (preg_match("/^(?:in|ex)ternal:/", $token)) {
  256. // Match internal or external sheet link
  257. return $this->write_url($row, $col, $token, '', $format);
  258. } elseif (preg_match("/^=/", $token)) {
  259. // Match formula
  260. return $this->write_formula($row, $col, $token, $format);
  261. } elseif (preg_match("/^@/", $token)) {
  262. // Match formula
  263. return $this->write_formula($row, $col, $token, $format);
  264. } elseif ($token == '') {
  265. // Match blank
  266. return $this->write_blank($row, $col, $format);
  267. } else {
  268. // Default: match string
  269. return $this->write_string($row, $col, $token, $format);
  270. }
  271. }
  272. /**
  273. * Sets the height (and other settings) of one row.
  274. *
  275. * @param integer $row The row to set
  276. * @param integer $height Height we are giving to the row (null to set just format without setting the height)
  277. * @param mixed $format The optional format we are giving to the row
  278. * @param bool $hidden The optional hidden attribute
  279. * @param integer $level The optional outline level (0-7)
  280. */
  281. public function set_row($row, $height, $format = null, $hidden = false, $level = 0) {
  282. if (is_array($format)) {
  283. $format = new MoodleODSFormat($format);
  284. }
  285. if ($level < 0) {
  286. $level = 0;
  287. } else if ($level > 7) {
  288. $level = 7;
  289. }
  290. if (!isset($this->rows[$row])) {
  291. $this->rows[$row] = new stdClass();
  292. }
  293. if (isset($height)) {
  294. $this->rows[$row]->height = $height;
  295. }
  296. $this->rows[$row]->format = $format;
  297. $this->rows[$row]->hidden = $hidden;
  298. $this->rows[$row]->level = $level;
  299. }
  300. /**
  301. * Sets the width (and other settings) of one column.
  302. *
  303. * @param integer $firstcol first column on the range
  304. * @param integer $lastcol last column on the range
  305. * @param integer $width width to set (null to set just format without setting the width)
  306. * @param mixed $format The optional format to apply to the columns
  307. * @param bool $hidden The optional hidden attribute
  308. * @param integer $level The optional outline level (0-7)
  309. */
  310. public function set_column($firstcol, $lastcol, $width, $format = null, $hidden = false, $level = 0) {
  311. if (is_array($format)) {
  312. $format = new MoodleODSFormat($format);
  313. }
  314. if ($level < 0) {
  315. $level = 0;
  316. } else if ($level > 7) {
  317. $level = 7;
  318. }
  319. for($i=$firstcol; $i<=$lastcol; $i++) {
  320. if (!isset($this->columns[$i])) {
  321. $this->columns[$i] = new stdClass();
  322. }
  323. if (isset($width)) {
  324. $this->columns[$i]->width = $width*6.15; // 6.15 is a magic constant here!
  325. }
  326. $this->columns[$i]->format = $format;
  327. $this->columns[$i]->hidden = $hidden;
  328. $this->columns[$i]->level = $level;
  329. }
  330. }
  331. /**
  332. * Set the option to hide gridlines on the printed page.
  333. */
  334. public function hide_gridlines() {
  335. // Not implemented - always off.
  336. }
  337. /**
  338. * Set the option to hide gridlines on the worksheet (as seen on the screen).
  339. */
  340. public function hide_screen_gridlines() {
  341. $this->showgrid = false;
  342. }
  343. /**
  344. * Insert a 24bit bitmap image in a worksheet.
  345. *
  346. * @param integer $row The row we are going to insert the bitmap into
  347. * @param integer $col The column we are going to insert the bitmap into
  348. * @param string $bitmap The bitmap filename
  349. * @param integer $x The horizontal position (offset) of the image inside the cell.
  350. * @param integer $y The vertical position (offset) of the image inside the cell.
  351. * @param integer $scale_x The horizontal scale
  352. * @param integer $scale_y The vertical scale
  353. */
  354. public function insert_bitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) {
  355. // Not implemented.
  356. }
  357. /**
  358. * Merges the area given by its arguments.
  359. *
  360. * @param integer $first_row First row of the area to merge
  361. * @param integer $first_col First column of the area to merge
  362. * @param integer $last_row Last row of the area to merge
  363. * @param integer $last_col Last column of the area to merge
  364. */
  365. public function merge_cells($first_row, $first_col, $last_row, $last_col) {
  366. if ($first_row > $last_row or $first_col > $last_col) {
  367. return;
  368. }
  369. if (!isset($this->data[$first_row][$first_col])) {
  370. $this->data[$first_row][$first_col] = new MoodleODSCell();
  371. }
  372. $this->data[$first_row][$first_col]->merge = array('rows'=>($last_row-$first_row+1), 'columns'=>($last_col-$first_col+1));
  373. }
  374. }
  375. /**
  376. * ODS cell format abstraction.
  377. *
  378. * @package core
  379. * @copyright 2006 Petr Skoda {@link http://skodak.org}
  380. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  381. */
  382. class MoodleODSFormat {
  383. public $id;
  384. public $properties = array();
  385. /**
  386. * Constructs one Moodle Format.
  387. *
  388. * @param array $properties
  389. */
  390. public function __construct($properties = array()) {
  391. static $fid = 1;
  392. $this->id = $fid++;
  393. foreach($properties as $property => $value) {
  394. if (method_exists($this, "set_$property")) {
  395. $aux = 'set_'.$property;
  396. $this->$aux($value);
  397. }
  398. }
  399. }
  400. /**
  401. * Set the size of the text in the format (in pixels).
  402. * By default all texts in generated sheets are 10pt.
  403. *
  404. * @param integer $size Size of the text (in points)
  405. */
  406. public function set_size($size) {
  407. $this->properties['size'] = $size;
  408. }
  409. /**
  410. * Set weight of the format.
  411. *
  412. * @param integer $weight Weight for the text, 0 maps to 400 (normal text),
  413. * 1 maps to 700 (bold text). Valid range is: 100-1000.
  414. * It's Optional, default is 1 (bold).
  415. */
  416. public function set_bold($weight = 1) {
  417. if ($weight == 1) {
  418. $weight = 700;
  419. }
  420. $this->properties['bold'] = ($weight > 400);
  421. }
  422. /**
  423. * Set underline of the format.
  424. *
  425. * @param integer $underline The value for underline. Possible values are:
  426. * 1 => underline, 2 => double underline
  427. */
  428. public function set_underline($underline = 1) {
  429. if ($underline == 1) {
  430. $this->properties['underline'] = 1;
  431. } else if ($underline == 2) {
  432. $this->properties['underline'] = 2;
  433. } else {
  434. unset($this->properties['underline']);
  435. }
  436. }
  437. /**
  438. * Set italic of the format.
  439. */
  440. public function set_italic() {
  441. $this->properties['italic'] = true;
  442. }
  443. /**
  444. * Set strikeout of the format
  445. */
  446. public function set_strikeout() {
  447. $this->properties['strikeout'] = true;
  448. }
  449. /**
  450. * Set outlining of the format.
  451. */
  452. public function set_outline() {
  453. // Not implemented.
  454. }
  455. /**
  456. * Set shadow of the format.
  457. */
  458. public function set_shadow() {
  459. // Not implemented.
  460. }
  461. /**
  462. * Set the script of the text.
  463. *
  464. * @param integer $script The value for script type. Possible values are:
  465. * 1 => superscript, 2 => subscript
  466. */
  467. public function set_script($script) {
  468. if ($script == 1) {
  469. $this->properties['super_script'] = true;
  470. unset($this->properties['sub_script']);
  471. } else if ($script == 2) {
  472. $this->properties['sub_script'] = true;
  473. unset($this->properties['super_script']);
  474. } else {
  475. unset($this->properties['sub_script']);
  476. unset($this->properties['super_script']);
  477. }
  478. }
  479. /**
  480. * Set color of the format.
  481. *
  482. * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63])
  483. */
  484. public function set_color($color) {
  485. $this->properties['color'] = $this->parse_color($color);
  486. }
  487. /**
  488. * Not used.
  489. *
  490. * @param mixed $color
  491. */
  492. public function set_fg_color($color) {
  493. // Not implemented.
  494. }
  495. /**
  496. * Set background color of the cell.
  497. *
  498. * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63])
  499. */
  500. public function set_bg_color($color) {
  501. $this->properties['bg_color'] = $this->parse_color($color);
  502. }
  503. /**
  504. * Set the cell fill pattern.
  505. *
  506. * @deprecated use set_bg_color() instead.
  507. * @param integer
  508. */
  509. public function set_pattern($pattern=1) {
  510. if ($pattern > 0) {
  511. if (!isset($this->properties['bg_color'])) {
  512. $this->properties['bg_color'] = $this->parse_color('black');
  513. }
  514. } else {
  515. unset($this->properties['bg_color']);
  516. }
  517. }
  518. /**
  519. * Set text wrap of the format
  520. */
  521. public function set_text_wrap() {
  522. $this->properties['wrap'] = true;
  523. }
  524. /**
  525. * Set the cell alignment of the format.
  526. *
  527. * @param string $location alignment for the cell ('left', 'right', 'justify', etc...)
  528. */
  529. public function set_align($location) {
  530. if (in_array($location, array('left', 'centre', 'center', 'right', 'fill', 'merge', 'justify', 'equal_space'))) {
  531. $this->set_h_align($location);
  532. } else if (in_array($location, array('top', 'vcentre', 'vcenter', 'bottom', 'vjustify', 'vequal_space'))) {
  533. $this->set_v_align($location);
  534. }
  535. }
  536. /**
  537. * Set the cell horizontal alignment of the format.
  538. *
  539. * @param string $location alignment for the cell ('left', 'right', 'justify', etc...)
  540. */
  541. public function set_h_align($location) {
  542. switch ($location) {
  543. case 'left':
  544. $this->properties['align'] = 'start';
  545. break;
  546. case 'center':
  547. case 'centre':
  548. $this->properties['align'] = 'center';
  549. break;
  550. case 'right':
  551. $this->properties['align'] = 'end';
  552. break;
  553. }
  554. }
  555. /**
  556. * Set the cell vertical alignment of the format.
  557. *
  558. * @param string $location alignment for the cell ('top', 'bottom', 'center', 'justify')
  559. */
  560. public function set_v_align($location) {
  561. switch ($location) {
  562. case 'top':
  563. $this->properties['v_align'] = 'top';
  564. break;
  565. case 'vcentre':
  566. case 'vcenter':
  567. case 'centre':
  568. case 'center':
  569. $this->properties['v_align'] = 'middle';
  570. break;
  571. default:
  572. $this->properties['v_align'] = 'bottom';
  573. }
  574. }
  575. /**
  576. * Set the top border of the format.
  577. *
  578. * @param integer $style style for the cell. 1 => thin, 2 => thick
  579. */
  580. public function set_top($style) {
  581. if ($style == 1) {
  582. $style = 0.2;
  583. } else if ($style == 2) {
  584. $style = 0.5;
  585. } else {
  586. return;
  587. }
  588. $this->properties['border_top'] = $style;
  589. }
  590. /**
  591. * Set the bottom border of the format.
  592. *
  593. * @param integer $style style for the cell. 1 => thin, 2 => thick
  594. */
  595. public function set_bottom($style) {
  596. if ($style == 1) {
  597. $style = 0.2;
  598. } else if ($style == 2) {
  599. $style = 0.5;
  600. } else {
  601. return;
  602. }
  603. $this->properties['border_bottom'] = $style;
  604. }
  605. /**
  606. * Set the left border of the format.
  607. *
  608. * @param integer $style style for the cell. 1 => thin, 2 => thick
  609. */
  610. public function set_left($style) {
  611. if ($style == 1) {
  612. $style = 0.2;
  613. } else if ($style == 2) {
  614. $style = 0.5;
  615. } else {
  616. return;
  617. }
  618. $this->properties['border_left'] = $style;
  619. }
  620. /**
  621. * Set the right border of the format.
  622. *
  623. * @param integer $style style for the cell. 1 => thin, 2 => thick
  624. */
  625. public function set_right($style) {
  626. if ($style == 1) {
  627. $style = 0.2;
  628. } else if ($style == 2) {
  629. $style = 0.5;
  630. } else {
  631. return;
  632. }
  633. $this->properties['border_right'] = $style;
  634. }
  635. /**
  636. * Set cells borders to the same style
  637. * @param integer $style style to apply for all cell borders. 1 => thin, 2 => thick.
  638. */
  639. public function set_border($style) {
  640. $this->set_top($style);
  641. $this->set_bottom($style);
  642. $this->set_left($style);
  643. $this->set_right($style);
  644. }
  645. /**
  646. * Set the numerical format of the format.
  647. * It can be date, time, currency, etc...
  648. *
  649. * @param mixed $num_format The numeric format
  650. */
  651. public function set_num_format($num_format) {
  652. $numbers = array();
  653. $numbers[1] = '0';
  654. $numbers[2] = '0.00';
  655. $numbers[3] = '#,##0';
  656. $numbers[4] = '#,##0.00';
  657. $numbers[11] = '0.00E+00';
  658. $numbers[12] = '# ?/?';
  659. $numbers[13] = '# ??/??';
  660. $numbers[14] = 'mm-dd-yy';
  661. $numbers[15] = 'd-mmm-yy';
  662. $numbers[16] = 'd-mmm';
  663. $numbers[17] = 'mmm-yy';
  664. $numbers[22] = 'm/d/yy h:mm';
  665. $numbers[49] = '@';
  666. if ($num_format !== 0 and in_array($num_format, $numbers)) {
  667. $flipped = array_flip($numbers);
  668. $this->properties['num_format'] = $flipped[$num_format];
  669. }
  670. if (!isset($numbers[$num_format])) {
  671. return;
  672. }
  673. $this->properties['num_format'] = $num_format;
  674. }
  675. /**
  676. * Standardise colour name.
  677. *
  678. * @param mixed $color name of the color (i.e.: 'blue', 'red', etc..), or an integer (range is [8...63]).
  679. * @return string the RGB color value
  680. */
  681. protected function parse_color($color) {
  682. if (strpos($color, '#') === 0) {
  683. // No conversion should be needed.
  684. return $color;
  685. }
  686. if ($color > 7 and $color < 53) {
  687. $numbers = array(
  688. 8 => 'black',
  689. 12 => 'blue',
  690. 16 => 'brown',
  691. 15 => 'cyan',
  692. 23 => 'gray',
  693. 17 => 'green',
  694. 11 => 'lime',
  695. 14 => 'magenta',
  696. 18 => 'navy',
  697. 53 => 'orange',
  698. 33 => 'pink',
  699. 20 => 'purple',
  700. 10 => 'red',
  701. 22 => 'silver',
  702. 9 => 'white',
  703. 13 => 'yellow',
  704. );
  705. if (isset($numbers[$color])) {
  706. $color = $numbers[$color];
  707. } else {
  708. $color = 'black';
  709. }
  710. }
  711. $colors = array(
  712. 'aqua' => '00FFFF',
  713. 'black' => '000000',
  714. 'blue' => '0000FF',
  715. 'brown' => 'A52A2A',
  716. 'cyan' => '00FFFF',
  717. 'fuchsia' => 'FF00FF',
  718. 'gray' => '808080',
  719. 'grey' => '808080',
  720. 'green' => '00FF00',
  721. 'lime' => '00FF00',
  722. 'magenta' => 'FF00FF',
  723. 'maroon' => '800000',
  724. 'navy' => '000080',
  725. 'orange' => 'FFA500',
  726. 'olive' => '808000',
  727. 'pink' => 'FAAFBE',
  728. 'purple' => '800080',
  729. 'red' => 'FF0000',
  730. 'silver' => 'C0C0C0',
  731. 'teal' => '008080',
  732. 'white' => 'FFFFFF',
  733. 'yellow' => 'FFFF00',
  734. );
  735. if (isset($colors[$color])) {
  736. return('#'.$colors[$color]);
  737. }
  738. return('#'.$colors['black']);
  739. }
  740. }
  741. /**
  742. * ODS file writer.
  743. *
  744. * @package core
  745. * @copyright 2013 Petr Skoda {@link http://skodak.org}
  746. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  747. */
  748. class MoodleODSWriter {
  749. protected $worksheets;
  750. public function __construct(array $worksheets) {
  751. $this->worksheets = $worksheets;
  752. }
  753. /**
  754. * Fetch the file ocntnet for the ODS.
  755. *
  756. * @return string
  757. */
  758. public function get_file_content() {
  759. $dir = make_request_directory();
  760. $filename = $dir . '/result.ods';
  761. $files = [
  762. 'mimetype' => [$this->get_ods_mimetype()],
  763. 'content.xml' => [$this->get_ods_content($this->worksheets)],
  764. 'meta.xml' => [$this->get_ods_meta()],
  765. 'styles.xml' => [$this->get_ods_styles()],
  766. 'settings.xml' => [$this->get_ods_settings()],
  767. 'META-INF/manifest.xml' => [$this->get_ods_manifest()],
  768. ];
  769. $packer = get_file_packer('application/zip');
  770. $packer->archive_to_pathname($files, $filename);
  771. $contents = file_get_contents($filename);
  772. remove_dir($dir);
  773. return $contents;
  774. }
  775. protected function get_ods_content() {
  776. // Find out the size of worksheets and used styles.
  777. $formats = array();
  778. $formatstyles = '';
  779. $rowstyles = '';
  780. $colstyles = '';
  781. foreach($this->worksheets as $wsnum=>$ws) {
  782. $this->worksheets[$wsnum]->maxr = 0;
  783. $this->worksheets[$wsnum]->maxc = 0;
  784. foreach($ws->data as $rnum=>$row) {
  785. if ($rnum > $this->worksheets[$wsnum]->maxr) {
  786. $this->worksheets[$wsnum]->maxr = $rnum;
  787. }
  788. foreach($row as $cnum=>$cell) {
  789. if ($cnum > $this->worksheets[$wsnum]->maxc) {
  790. $this->worksheets[$wsnum]->maxc = $cnum;
  791. }
  792. if (!empty($cell->format)) {
  793. if (!array_key_exists($cell->format->id, $formats)) {
  794. $formats[$cell->format->id] = $cell->format;
  795. }
  796. }
  797. }
  798. }
  799. foreach($ws->rows as $rnum=>$row) {
  800. if (!empty($row->format)) {
  801. if (!array_key_exists($row->format->id, $formats)) {
  802. $formats[$row->format->id] = $row->format;
  803. }
  804. }
  805. if ($rnum > $this->worksheets[$wsnum]->maxr) {
  806. $this->worksheets[$wsnum]->maxr = $rnum;
  807. }
  808. // Define all column styles.
  809. if (!empty($ws->rows[$rnum])) {
  810. $rowstyles .= '<style:style style:name="ws'.$wsnum.'ro'.$rnum.'" style:family="table-row">';
  811. if (isset($row->height)) {
  812. $rowstyles .= '<style:table-row-properties style:row-height="'.$row->height.'pt"/>';
  813. }
  814. $rowstyles .= '</style:style>';
  815. }
  816. }
  817. foreach($ws->columns as $cnum=>$col) {
  818. if (!empty($col->format)) {
  819. if (!array_key_exists($col->format->id, $formats)) {
  820. $formats[$col->format->id] = $col->format;
  821. }
  822. }
  823. if ($cnum > $this->worksheets[$wsnum]->maxc) {
  824. $this->worksheets[$wsnum]->maxc = $cnum;
  825. }
  826. // Define all column styles.
  827. if (!empty($ws->columns[$cnum])) {
  828. $colstyles .= '<style:style style:name="ws'.$wsnum.'co'.$cnum.'" style:family="table-column">';
  829. if (isset($col->width)) {
  830. $colstyles .= '<style:table-column-properties style:column-width="'.$col->width.'pt"/>';
  831. }
  832. $colstyles .= '</style:style>';
  833. }
  834. }
  835. }
  836. foreach($formats as $format) {
  837. $textprop = '';
  838. $cellprop = '';
  839. $parprop = '';
  840. $dataformat = '';
  841. foreach($format->properties as $pname=>$pvalue) {
  842. switch ($pname) {
  843. case 'size':
  844. if (!empty($pvalue)) {
  845. $textprop .= ' fo:font-size="'.$pvalue.'pt"';
  846. }
  847. break;
  848. case 'bold':
  849. if (!empty($pvalue)) {
  850. $textprop .= ' fo:font-weight="bold"';
  851. }
  852. break;
  853. case 'italic':
  854. if (!empty($pvalue)) {
  855. $textprop .= ' fo:font-style="italic"';
  856. }
  857. break;
  858. case 'underline':
  859. if (!empty($pvalue)) {
  860. $textprop .= ' style:text-underline-color="font-color" style:text-underline-style="solid" style:text-underline-width="auto"';
  861. if ($pvalue == 2) {
  862. $textprop .= ' style:text-underline-type="double"';
  863. }
  864. }
  865. break;
  866. case 'strikeout':
  867. if (!empty($pvalue)) {
  868. $textprop .= ' style:text-line-through-style="solid"';
  869. }
  870. break;
  871. case 'color':
  872. if ($pvalue !== false) {
  873. $textprop .= ' fo:color="'.$pvalue.'"';
  874. }
  875. break;
  876. case 'bg_color':
  877. if ($pvalue !== false) {
  878. $cellprop .= ' fo:background-color="'.$pvalue.'"';
  879. }
  880. break;
  881. case 'align':
  882. $parprop .= ' fo:text-align="'.$pvalue.'"';
  883. break;
  884. case 'v_align':
  885. $cellprop .= ' style:vertical-align="'.$pvalue.'"';
  886. break;
  887. case 'wrap':
  888. if ($pvalue) {
  889. $cellprop .= ' fo:wrap-option="wrap"';
  890. }
  891. break;
  892. case 'border_top':
  893. $cellprop .= ' fo:border-top="'.$pvalue.'pt solid #000000"';
  894. break;
  895. case 'border_left':
  896. $cellprop .= ' fo:border-left="'.$pvalue.'pt solid #000000"';
  897. break;
  898. case 'border_bottom':
  899. $cellprop .= ' fo:border-bottom="'.$pvalue.'pt solid #000000"';
  900. break;
  901. case 'border_right':
  902. $cellprop .= ' fo:border-right="'.$pvalue.'pt solid #000000"';
  903. break;
  904. case 'num_format':
  905. $dataformat = ' style:data-style-name="NUM'.$pvalue.'"';
  906. break;
  907. }
  908. }
  909. if (!empty($textprop)) {
  910. $textprop = '
  911. <style:text-properties'.$textprop.'/>';
  912. }
  913. if (!empty($cellprop)) {
  914. $cellprop = '
  915. <style:table-cell-properties'.$cellprop.'/>';
  916. }
  917. if (!empty($parprop)) {
  918. $parprop = '
  919. <style:paragraph-properties'.$parprop.'/>';
  920. }
  921. $formatstyles .= '
  922. <style:style style:name="format'.$format->id.'" style:family="table-cell"'.$dataformat.'>'.$textprop.$cellprop.$parprop.'
  923. </style:style>';
  924. }
  925. // The text styles may be breaking older ODF validators.
  926. $scriptstyles ='
  927. <style:style style:name="T1" style:family="text">
  928. <style:text-properties style:text-position="33% 58%"/>
  929. </style:style>
  930. <style:style style:name="T2" style:family="text">
  931. <style:text-properties style:text-position="-33% 58%"/>
  932. </style:style>
  933. ';
  934. // Header.
  935. $buffer =
  936. '<?xml version="1.0" encoding="UTF-8"?>
  937. <office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  938. xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  939. xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  940. xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  941. xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  942. xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  943. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/"
  944. xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
  945. xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  946. xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
  947. xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  948. xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  949. xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  950. xmlns:math="http://www.w3.org/1998/Math/MathML"
  951. xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  952. xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  953. xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer"
  954. xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events"
  955. xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  956. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  957. xmlns:rpt="http://openoffice.org/2005/report"
  958. xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
  959. xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#"
  960. xmlns:tableooo="http://openoffice.org/2009/table"
  961. xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
  962. xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0"
  963. xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
  964. xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2">
  965. <office:scripts/>
  966. <office:font-face-decls>
  967. <style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="swiss"
  968. style:font-pitch="variable"/>
  969. <style:font-face style:name="Arial Unicode MS" svg:font-family="&apos;Arial Unicode MS&apos;"
  970. style:font-family-generic="system" style:font-pitch="variable"/>
  971. <style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system"
  972. style:font-pitch="variable"/>
  973. </office:font-face-decls>
  974. <office:automatic-styles>';
  975. $buffer .= $this->get_num_styles();
  976. $buffer .= '
  977. <style:style style:name="ta1" style:family="table" style:master-page-name="Standard1">
  978. <style:table-properties table:display="true"/>
  979. </style:style>';
  980. $buffer .= $formatstyles;
  981. $buffer .= $rowstyles;
  982. $buffer .= $colstyles;
  983. $buffer .= $scriptstyles;
  984. $buffer .= '
  985. </office:automatic-styles>
  986. <office:body>
  987. <office:spreadsheet>
  988. ';
  989. foreach($this->worksheets as $wsnum=>$ws) {
  990. // Worksheet header.
  991. $buffer .= '<table:table table:name="' . htmlspecialchars($ws->name, ENT_QUOTES, 'utf-8') . '" table:style-name="ta1">'."\n";
  992. // Define column properties.
  993. $level = 0;
  994. for($c=0; $c<=$ws->maxc; $c++) {
  995. if (array_key_exists($c, $ws->columns)) {
  996. $column = $ws->columns[$c];
  997. if ($column->level > $level) {
  998. while ($column->level > $level) {
  999. $buffer .= '<table:table-column-group>';
  1000. $level++;
  1001. }
  1002. } else if ($column->level < $level) {
  1003. while ($column->level < $level) {
  1004. $buffer .= '</table:table-column-group>';
  1005. $level--;
  1006. }
  1007. }
  1008. $extra = '';
  1009. if (!empty($column->format)) {
  1010. $extra .= ' table:default-cell-style-name="format'.$column->format->id.'"';
  1011. }
  1012. if ($column->hidden) {
  1013. $extra .= ' table:visibility="collapse"';
  1014. }
  1015. $buffer .= '<table:table-column table:style-name="ws'.$wsnum.'co'.$c.'"'.$extra.'/>'."\n";
  1016. } else {
  1017. while ($level > 0) {
  1018. $buffer .= '</table:table-column-group>';
  1019. $level--;
  1020. }
  1021. $buffer .= '<table:table-column/>'."\n";
  1022. }
  1023. }
  1024. while ($level > 0) {
  1025. $buffer .= '</table:table-column-group>';
  1026. $level--;
  1027. }
  1028. // Print all rows.
  1029. $level = 0;
  1030. for($r=0; $r<=$ws->maxr; $r++) {
  1031. if (array_key_exists($r, $ws->rows)) {
  1032. $row = $ws->rows[$r];
  1033. if ($row->level > $level) {
  1034. while ($row->level > $level) {
  1035. $buffer .= '<table:table-row-group>';
  1036. $level++;
  1037. }
  1038. } else if ($row->level < $level) {
  1039. while ($row->level < $level) {
  1040. $buffer .= '</table:table-row-group>';
  1041. $level--;
  1042. }
  1043. }
  1044. $extra = '';
  1045. if (!empty($row->format)) {
  1046. $extra .= ' table:default-cell-style-name="format'.$row->format->id.'"';
  1047. }
  1048. if ($row->hidden) {
  1049. $extra .= ' table:visibility="collapse"';
  1050. }
  1051. $buffer .= '<table:table-row table:style-name="ws'.$wsnum.'ro'.$r.'"'.$extra.'>'."\n";
  1052. } else {
  1053. while ($level > 0) {
  1054. $buffer .= '</table:table-row-group>';
  1055. $level--;
  1056. }
  1057. $buffer .= '<table:table-row>'."\n";
  1058. }
  1059. for($c=0; $c<=$ws->maxc; $c++) {
  1060. if (isset($ws->data[$r][$c])) {
  1061. $cell = $ws->data[$r][$c];
  1062. $extra = '';
  1063. if (!empty($cell->format)) {
  1064. $extra .= ' table:style-name="format'.$cell->format->id.'"';
  1065. }
  1066. if (!empty($cell->merge)) {
  1067. $extra .= ' table:number-columns-spanned="'.$cell->merge['columns'].'" table:number-rows-spanned="'.$cell->merge['rows'].'"';
  1068. }
  1069. $pretext = '<text:p>';
  1070. $posttext = '</text:p>';
  1071. if (!empty($cell->format->properties['sub_script'])) {
  1072. $pretext = $pretext.'<text:span text:style-name="T2">';
  1073. $posttext = '</text:span>'.$posttext;
  1074. } else if (!empty($cell->format->properties['super_script'])) {
  1075. $pretext = $pretext.'<text:span text:style-name="T1">';
  1076. $posttext = '</text:span>'.$posttext;
  1077. }
  1078. if (isset($cell->formula)) {
  1079. $buffer .= '<table:table-cell table:formula="of:'.$cell->formula.'"'.$extra.'></table:table-cell>'."\n";
  1080. } else if ($cell->type == 'date') {
  1081. $buffer .= '<table:table-cell office:value-type="date" office:date-value="' . strftime('%Y-%m-%dT%H:%M:%S', $cell->value) . '"'.$extra.'>'
  1082. . $pretext . strftime('%Y-%m-%dT%H:%M:%S', $cell->value) . $posttext
  1083. . '</table:table-cell>'."\n";
  1084. } else if ($cell->type == 'float') {
  1085. $buffer .= '<table:table-cell office:value-type="float" office:value="' . htmlspecialchars($cell->value, ENT_QUOTES, 'utf-8') . '"'.$extra.'>'
  1086. . $pretext . htmlspecialchars($cell->value, ENT_QUOTES, 'utf-8') . $posttext
  1087. . '</table:table-cell>'."\n";
  1088. } else if ($cell->type == 'string') {
  1089. $buffer .= '<table:table-cell office:value-type="string"'.$extra.'>'
  1090. . $pretext . htmlspecialchars($cell->value, ENT_QUOTES, 'utf-8') . $posttext
  1091. . '</table:table-cell>'."\n";
  1092. } else {
  1093. $buffer .= '<table:table-cell office:value-type="string"'.$extra.'>'
  1094. . $pretext . '!!Error - unknown type!!' . $posttext
  1095. . '</table:table-cell>'."\n";
  1096. }
  1097. } else {
  1098. $buffer .= '<table:table-cell/>'."\n";
  1099. }
  1100. }
  1101. $buffer .= '</table:table-row>'."\n";
  1102. }
  1103. while ($level > 0) {
  1104. $buffer .= '</table:table-row-group>';
  1105. $level--;
  1106. }
  1107. $buffer .= '</table:table>'."\n";
  1108. }
  1109. // Footer.
  1110. $buffer .= '
  1111. </office:spreadsheet>
  1112. </office:body>
  1113. </office:document-content>';
  1114. return $buffer;
  1115. }
  1116. public function get_ods_mimetype() {
  1117. return 'application/vnd.oasis.opendocument.spreadsheet';
  1118. }
  1119. protected function get_ods_settings() {
  1120. $buffer =
  1121. '<?xml version="1.0" encoding="UTF-8"?>
  1122. <office:document-settings xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  1123. xmlns:xlink="http://www.w3.org/1999/xlink"
  1124. xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
  1125. xmlns:ooo="http://openoffice.org/2004/office" office:version="1.2">
  1126. <office:settings>
  1127. <config:config-item-set config:name="ooo:view-settings">
  1128. <config:config-item config:name="VisibleAreaTop" config:type="int">0</config:config-item>
  1129. <config:config-item config:name="VisibleAreaLeft" config:type="int">0</config:config-item>
  1130. <config:config-item-map-indexed config:name="Views">
  1131. <config:config-item-map-entry>
  1132. <config:config-item config:name="ViewId" config:type="string">view1</config:config-item>
  1133. <config:config-item-map-named config:name="Tables">
  1134. ';
  1135. foreach ($this->worksheets as $ws) {
  1136. $buffer .= ' <config:config-item-map-entry config:name="'.htmlspecialchars($ws->name, ENT_QUOTES, 'utf-8').'">'."\n";
  1137. $buffer .= ' <config:config-item config:name="ShowGrid" config:type="boolean">'.($ws->showgrid ? 'true' : 'false').'</config:config-item>'."\n";
  1138. $buffer .= ' </config:config-item-map-entry>."\n"';
  1139. }
  1140. $buffer .=
  1141. ' </config:config-item-map-named>
  1142. </config:config-item-map-entry>
  1143. </config:config-item-map-indexed>
  1144. </config:config-item-set>
  1145. <config:config-item-set config:name="ooo:configuration-settings">
  1146. <config:config-item config:name="ShowGrid" config:type="boolean">true</config:config-item>
  1147. </config:config-item-set>
  1148. </office:settings>
  1149. </office:document-settings>';
  1150. return $buffer;
  1151. }
  1152. protected function get_ods_meta() {
  1153. global $CFG, $USER;
  1154. return
  1155. '<?xml version="1.0" encoding="UTF-8"?>
  1156. <office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  1157. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/"
  1158. xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
  1159. xmlns:ooo="http://openoffice.org/2004/office" xmlns:grddl="http://www.w3.org/2003/g/data-view#"
  1160. office:version="1.2">
  1161. <office:meta>
  1162. <meta:generator>Moodle '.$CFG->release.'</meta:generator>
  1163. <meta:initial-creator>' . htmlspecialchars(fullname($USER, true), ENT_QUOTES, 'utf-8') . '</meta:initial-creator>
  1164. <meta:creation-date>'.strftime('%Y-%m-%dT%H:%M:%S').'</meta:creation-date>
  1165. <meta:document-statistic meta:table-count="1" meta:cell-count="0" meta:object-count="0"/>
  1166. </office:meta>
  1167. </office:document-meta>';
  1168. }
  1169. protected function get_ods_styles() {
  1170. return
  1171. '<?xml version="1.0" encoding="UTF-8"?>
  1172. <office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  1173. xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  1174. xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  1175. xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  1176. xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  1177. xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  1178. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/"
  1179. xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
  1180. xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  1181. xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
  1182. xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  1183. xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  1184. xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  1185. xmlns:math="http://www.w3.org/1998/Math/MathML"
  1186. xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  1187. xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  1188. xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer"
  1189. xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events"
  1190. xmlns:rpt="http://openoffice.org/2005/report"
  1191. xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
  1192. xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#"
  1193. xmlns:tableooo="http://openoffice.org/2009/table"
  1194. xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
  1195. xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2">
  1196. <office:font-face-decls>
  1197. <style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="swiss"
  1198. style:font-pitch="variable"/>
  1199. <style:font-face style:name="Arial Unicode MS" svg:font-family="&apos;Arial Unicode MS&apos;"
  1200. style:font-family-generic="system" style:font-pitch="variable"/>
  1201. <style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system"
  1202. style:font-pitch="variable"/>
  1203. </office:font-face-decls>
  1204. <office:styles>
  1205. <style:default-style style:family="table-cell">
  1206. <style:paragraph-properties style:tab-stop-distance="1.25cm"/>
  1207. </style:default-style>
  1208. <number:number-style style:name="N0">
  1209. <number:number number:min-integer-digits="1"/>
  1210. </number:number-style>
  1211. <style:style style:name="Default" style:family="table-cell">
  1212. <style:text-p

Large files files are truncated, but you can click here to view the full file