/usr/share/php/Horde/Mime/Viewer/Ooo/export/xhtml/body.xsl is in php-horde-mime-viewer 2.2.2-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 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 | <?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
Copyright 2000, 2010 Oracle and/or its affiliates.
OpenOffice.org - a multi-platform office productivity suite
This file is part of OpenOffice.org.
OpenOffice.org is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
only, as published by the Free Software Foundation.
OpenOffice.org 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 Lesser General Public License version 3 for more details
(a copy is included in the LICENSE file that accompanied this code).
You should have received a copy of the GNU Lesser General Public License
version 3 along with OpenOffice.org. If not, see
<http://www.openoffice.org/license.html>
for a copy of the LGPLv3 License.
-->
<!--
For further documentation and updates visit http://xml.openoffice.org/odf2xhtml
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xt="http://www.jclark.com/xt" xmlns:common="http://exslt.org/common" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xforms xlink xsd xsi xt common xalan" xmlns="http://www.w3.org/1999/xhtml">
<!--+++++ INCLUDED XSL MODULES +++++-->
<!-- helper collection, to convert measures (e.g. inch to pixel using DPI (dots per inch) parameter)-->
<xsl:import href="../../common/measure_conversion.xsl"/>
<!-- common office body element handling -->
<xsl:import href="../common/body.xsl"/>
<!-- common table handling -->
<xsl:import href="../common/table/table.xsl"/>
<!-- xhtml table handling -->
<xsl:include href="table.xsl"/>
<!-- Useful in case of 'style:map', conditional formatting, where a style references to another -->
<xsl:key name="styles" match="/*/office:styles/style:style | /*/office:automatic-styles/style:style" use="@style:name"/>
<!-- ************ -->
<!-- *** body *** -->
<!-- ************ -->
<xsl:key match="style:style/@style:master-page-name" name="masterPage" use="'count'"/>
<xsl:key match="style:master-page" name="masterPageElements" use="@style:name"/>
<xsl:key match="style:page-layout" name="pageLayoutElements" use="@style:name"/>
<xsl:key name="writingModeStyles" match="/*/office:styles/style:style/style:paragraph-properties/@style:writing-mode | /*/office:automatic-styles/style:style/style:paragraph-properties/@style:writing-mode" use="'test'"/>
<xsl:template name="create-body">
<xsl:param name="globalData"/>
<xsl:call-template name="create-body.collect-page-properties">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="create-body.collect-page-properties">
<xsl:param name="globalData"/>
<!-- approximation to find the correct master page style (with page dimensions) -->
<xsl:variable name="masterPageNames">
<!-- Loop over every style:style containing a @style:master-page-name attribute -->
<xsl:for-each select="key('masterPage','count')">
<!-- Check if this style is being used in the body -->
<xsl:if test="key('elementUsingStyle', ../@style:name)">
<!-- Check every master-page-name if it is not emtpy and return as ';' separated list -->
<xsl:if test="string-length(../@style:master-page-name) > 0">
<xsl:value-of select="../@style:master-page-name"/>;
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<!-- Take the first of the masterpage list and get the according style:master-page element and find the @style:page-layout-name -->
<xsl:variable name="pageLayoutName" select="key('masterPageElements', substring-before($masterPageNames,';'))/@style:page-layout-name"/>
<xsl:variable name="pagePropertiesRTF">
<xsl:choose>
<xsl:when test="not($pageLayoutName) or $pageLayoutName = ''">
<xsl:copy-of select="$globalData/styles-file/*/office:automatic-styles/style:page-layout[1]/style:page-layout-properties"/>
</xsl:when>
<xsl:otherwise>
<!-- Find the according style:page-layout and store the properties in a variable -->
<xsl:copy-of select="key('pageLayoutElements', $pageLayoutName)/style:page-layout-properties"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="function-available('common:node-set')">
<xsl:call-template name="create-body.create">
<xsl:with-param name="globalData" select="common:node-set($globalData)"/>
<xsl:with-param name="pageProperties" select="common:node-set($pagePropertiesRTF)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="function-available('xalan:nodeset')">
<xsl:call-template name="create-body.create">
<xsl:with-param name="globalData" select="xalan:nodeset($globalData)"/>
<xsl:with-param name="pageProperties" select="xalan:nodeset($pagePropertiesRTF)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="function-available('xt:node-set')">
<xsl:call-template name="create-body.create">
<xsl:with-param name="globalData" select="xt:node-set($globalData)"/>
<xsl:with-param name="pageProperties" select="xt:node-set($pagePropertiesRTF)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="create-body.create">
<xsl:param name="globalData"/>
<xsl:param name="pageProperties"/>
<xsl:element name="body">
<!-- direction of text flow -->
<xsl:variable name="writingMode" select="$pageProperties/style:page-layout-properties/@style:writing-mode"/>
<xsl:choose>
<xsl:when test="$writingMode">
<xsl:choose>
<xsl:when test="contains($writingMode, 'lr')">
<xsl:attribute name="dir">ltr</xsl:attribute>
</xsl:when>
<xsl:when test="contains($writingMode, 'rl')">
<xsl:attribute name="dir">rtl</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<!-- As CSS writing-mode is not implemented by all browsers, a heuristic is done -->
<xsl:variable name="writingModeTest" select="key('writingModeStyles', 'test')"/>
<xsl:if test="contains($writingModeTest, 'rl')">
<xsl:attribute name="dir">rtl</xsl:attribute>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<!-- adapt page size -->
<xsl:variable name="pageWidth" select="$pageProperties/style:page-layout-properties/@fo:page-width"/>
<!-- multiple backgroundimages for different page styles (never used in html) -->
<xsl:variable name="backgroundImage" select="$pageProperties/style:page-layout-properties/style:background-image"/>
<!-- page margins & background image -->
<xsl:if test="$pageWidth or $pageProperties/style:page-layout-properties/@fo:* or $backgroundImage/@xlink:href">
<xsl:attribute name="style">
<xsl:if test="$pageWidth">
<xsl:text>max-width:</xsl:text>
<xsl:value-of select="$pageWidth"/>
<xsl:text>;</xsl:text>
</xsl:if>
<xsl:if test="$pageProperties/style:page-layout-properties/@fo:* or $backgroundImage/@xlink:href">
<xsl:apply-templates select="$pageProperties/style:page-layout-properties/@fo:*"/>
<xsl:if test="$backgroundImage/@xlink:href">
<xsl:text>background-image:url(</xsl:text>
<xsl:call-template name="create-href">
<xsl:with-param name="href" select="$backgroundImage/@xlink:href"/>
</xsl:call-template>
<xsl:text>);</xsl:text>
<xsl:if test="$backgroundImage/@style:repeat">
<xsl:choose>
<xsl:when test="$backgroundImage/@style:repeat = 'no-repeat'">
<xsl:text>background-repeat:no-repeat;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>background-repeat:repeat;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="$backgroundImage/@style:position">
<xsl:text>background-position:</xsl:text>
<xsl:value-of select="$backgroundImage/@style:position"/>
<xsl:text>;</xsl:text>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:attribute>
</xsl:if>
<!-- processing the content of the OpenDocument content file -->
<xsl:apply-templates select="/*/office:body/*">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<!-- processing the content of the OpenDocument content file -->
<xsl:template match="office:body/*">
<xsl:param name="globalData"/>
<!-- not using of 'apply-styles-and-content' as the content table information migth have been added to 'globalData' variable -->
<xsl:apply-templates select="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name -->
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
<xsl:apply-templates>
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
<!-- writing the footer- and endnotes beyond the body -->
<xsl:call-template name="write-text-nodes">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:template>
<!-- ******************************* -->
<!-- *** User Field Declarations *** -->
<!-- ******************************* -->
<xsl:template match="text:user-field-get | text:user-field-input">
<xsl:param name="globalData"/>
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="text:conditional-text">
<xsl:param name="globalData"/>
<xsl:value-of select="."/>
</xsl:template>
<!-- ODF text fields -->
<xsl:template match="text:author-initials | text:author-name | text:chapter | text:character-count | text:creation-date | text:creation-time | text:creator | text:date | text:description | text:editing-cycles | text:editing-duration | text:file-name | text:image-count | text:initial-creator | text:keywords | text:modification-date | text:modification-time | text:object-count | text:page-continuation | text:page-count | text:page-number | text:paragraph-count | text:print-date | text:print-time | text:printed-by | text:sender-city | text:sender-company | text:sender-country | text:sender-email | text:sender-fax | text:sender-firstname | text:sender-initials | text:sender-lastname | text:sender-phone-private | text:sender-phone-work | text:sender-position | text:sender-postal-code | text:sender-state-or-province | text:sender-street | text:sender-title | text:sheet-name | text:subject | text:table-count | text:time | text:title | text:user-defined | text:word-count">
<xsl:param name="globalData"/>
<xsl:element name="span">
<xsl:attribute name="title">
<xsl:value-of select="local-name()"/>
</xsl:attribute>
<xsl:apply-templates>
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<!-- *************** -->
<!-- *** Textbox *** -->
<!-- *************** -->
<xsl:template match="draw:text-box">
<xsl:param name="globalData"/>
<xsl:comment>Next 'div' was a 'draw:text-box'.</xsl:comment>
<xsl:element name="div">
<xsl:variable name="dimension">
<xsl:apply-templates select="@fo:min-width"/>
<xsl:apply-templates select="@fo:max-width"/>
<xsl:apply-templates select="@fo:min-height"/>
<xsl:apply-templates select="@fo:max-height"/>
</xsl:variable>
<xsl:if test="$dimension">
<xsl:attribute name="style">
<xsl:value-of select="$dimension"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="@draw:name">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
<xsl:apply-templates select="node()">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<xsl:template match="@fo:min-width">
<xsl:text>min-width:</xsl:text>
<xsl:value-of select="."/>
<xsl:text>;</xsl:text>
</xsl:template>
<xsl:template match="@fo:max-width">
<xsl:text>max-width:</xsl:text>
<xsl:value-of select="."/>
<xsl:text>;</xsl:text>
</xsl:template>
<xsl:template match="@fo:min-height">
<xsl:text>min-height:</xsl:text>
<xsl:value-of select="."/>
<xsl:text>;</xsl:text>
</xsl:template>
<xsl:template match="@fo:max-height">
<xsl:text>max-height:</xsl:text>
<xsl:value-of select="."/>
<xsl:text>;</xsl:text>
</xsl:template>
<!-- inline style helper for the 'div' boxes -->
<xsl:template name="svg:height">
<xsl:text>height:</xsl:text>
<xsl:choose>
<!-- changing the distance measure: inch to in -->
<xsl:when test="contains(@svg:height, 'inch')">
<xsl:value-of select="substring-before(@svg:height, 'ch')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@svg:height"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>;</xsl:text>
</xsl:template>
<!-- inline style helper for the 'div' boxes -->
<xsl:template name="svg:width">
<xsl:text>width:</xsl:text>
<xsl:choose>
<!-- changing the distance measure: inch to in -->
<xsl:when test="contains(@svg:width, 'inch')">
<xsl:value-of select="substring-before(@svg:width, 'ch')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@svg:width"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>;</xsl:text>
</xsl:template>
<!-- ****************** -->
<!-- *** Paragraphs *** -->
<!-- ****************** -->
<xsl:template match="text:p | draw:page">
<xsl:param name="globalData"/>
<!-- The footnote symbol is the prefix for a footnote in the footer -->
<xsl:param name="footnotePrefix"/>
<!-- 1) In ODF sometimes the followig children are nested
<text:p>
<draw:frame>
<draw:text-box>
<text:p>
Which results in a paragraphs (the last text:p) having a paragraph as its anchestor.
In HTML a 'p' can only have inline documents (no other 'p' as children'),
a 'div' will be given for the ancestors instead.
2) ODF images are embedded in a paragraph, but CSS is not able to express a horizontal alignment for an HTML image (text:align is only valid for block elements).
A surrounding 'div' element taking over the image style solves that problem, but the div is invalid as child of a paragraph
Therefore the paragraph has to be exchanged with a HTML div element
-->
<!-- 2DO page alignment fix - PART1 -->
<xsl:variable name="childText"><xsl:apply-templates mode="getAllTextChildren"/></xsl:variable>
<xsl:choose>
<xsl:when test="name() = 'text:p' and not(*) and (normalize-space($childText) = '')">
<!-- WorkAround: Test if the empty paragraph was added after an image, which OOO often does -->
<xsl:variable name="isFollowingImage">
<xsl:call-template name="follows-empty-paragraphs-and-image">
<xsl:with-param name="precedingElement" select="preceding-sibling::node()[1]"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="$isFollowingImage = 'no'">
<xsl:call-template name="create-paragraph">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="draw:frame and ((normalize-space($childText) != '') or (((count(*) - count(text:soft-page-break)) > 1)))">
<!-- If there is a 'draw:frame' child with text (not being whitespace alone) and more than the draw:frame alone and
not the draw:frame and a soft-page-break alone (which is quite often) -->
<!-- If there is a frame within the text:p or draw:page, its siblings are surrounded as well by a div and are floating (CSS float) -->
<!-- But it makes no sense to create floating if the frame is alone or only together with a soft-page-break not usable for HTML -->
<!-- The paragraph is written as DIV as there might be nested paragraphs (see above choose block) -->
<xsl:choose>
<xsl:when test="name() = 'text:p'">
<xsl:comment>Next 'div' was a 'text:p'.</xsl:comment>
</xsl:when>
<xsl:otherwise>
<xsl:comment>Next 'div' was a 'draw:page'.</xsl:comment>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="div">
<xsl:apply-templates select="@*">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
<!-- the footnote symbol is the prefix for a footnote in the footer -->
<xsl:copy-of select="$footnotePrefix"/>
<!-- start floating of frame (and siblings) -->
<xsl:apply-templates select="node()[1]" mode="frameFloating">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="previousFrameWidths" select="0"/>
<xsl:with-param name="previousFrameHeights" select="0"/>
<!-- 2DO for me (Svante) - Not used, uncertain 4now..
<xsl:with-param name="pageMarginLeft">
<xsl:call-template name="getPageMarginLeft"/>
</xsl:with-param>-->
</xsl:apply-templates>
</xsl:element>
<!-- after the last draw:frame sibling the CSS float is disabled
  is an unbreakable whitespace to give conent to the element and force a browser not to ignore the element -->
<div style="clear:both; line-height:0; width:0; height:0; margin:0; padding:0;"> </div>
</xsl:when>
<xsl:when test="text:tab and not(ancestor::text:index-body)">
<!-- If there is a tabulator (ie. text:tab) within a paragraph, a heuristic for ODF tabulators creates a
span for every text:tab embracing the following text nodes aligning them according to the tabulator.
A line break or another text:tab starts a new text:span, line break even the tab counter for the line.
-->
<xsl:element name="p">
<xsl:apply-templates select="@*">
<xsl:with-param name="globalData" select="$globalData" />
</xsl:apply-templates>
<!-- start with first child of the paragraph -->
<xsl:variable name="firstChildNode" select="node()[1]" />
<xsl:apply-templates select="$firstChildNode" mode="tabHandling">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="tabStops" select="$globalData/all-doc-styles/style[@style:name = current()/@text:style-name]/*/style:tab-stops"/>
<xsl:with-param name="parentMarginLeft">
<!-- Styles of first paragraph in list item, including ancestor styles (inheritance) -->
<xsl:variable name="paragraphName" select="@text:style-name" />
<xsl:variable name="imageParagraphStyle" select="$globalData/all-styles/style[@style:name = $paragraphName]/final-properties"/>
<!-- Only the left margin of the first paragraph of a list item will be added to the margin of the complete list (all levels)-->
<!-- 2DO: left-margin in order with bidirectional -->
<xsl:choose>
<xsl:when test="contains($imageParagraphStyle, 'margin-left:')">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="normalize-space(substring-before(substring-after($imageParagraphStyle, 'margin-left:'), ';'))"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="pageMarginLeft">
<xsl:call-template name="getPageMarginLeft"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<!-- !!Check if paragraph is empty!!
OOo writes out empty paragraphs layouted behind an image (= draw:image within draw:frame)
those have to be neglected in HTML -->
<xsl:when test="name() = 'text:p' and not($childText) and not(*)">
<xsl:variable name="isFollowingImage">
<xsl:call-template name="follows-empty-paragraphs-and-image">
<xsl:with-param name="precedingElement" select="preceding-sibling::node()[1]"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="$isFollowingImage = 'no'">
<xsl:call-template name="create-paragraph">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="create-paragraph">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Return the text -->
<xsl:template match="text()" mode="getAllTextChildren">
<xsl:value-of select="."/>
</xsl:template>
<!-- A span will be created for every text:tab embracing the following text nodes.
A line break or another text:tab starts a new text:span -->
<xsl:template match="* | text()" mode="tabHandling">
<xsl:param name="globalData"/>
<xsl:param name="tabStops"/>
<!-- there can be multiple tabs in one line, tabNo guesses the one to apply. By default the first i.e. "1" -->
<xsl:param name="tabCount" select="0"/>
<xsl:param name="parentMarginLeft" />
<xsl:param name="pageMarginLeft" />
<!-- 2DO: EXCHANGE FOLLOING SIBLING BY VARIABLE -->
<xsl:variable name="followingSiblingNode" select="following-sibling::node()[1]"/>
<!--
Every tabulator indents its following content, encapuslated in a span
element.
This template have two modes:
1) Before the first tabulator it will match as usually paragraph content
to HTML.
2) After the first paragraph it will always triggers two recursions.
One embraces the following content of a paragraph element into a span.
(tabContentHandling)
The other calls this template and will now ignore anything else than
TAB and LINE-BREAK.
The tabulators and linebreaks are being iterated, one by one to keep track of the tab number
-->
<xsl:choose>
<xsl:when test="name() = 'text:tab'">
<!-- every frame sibling have to be incapuslated within a div with left indent -->
<xsl:element name="span">
<xsl:choose>
<xsl:when test="count($tabStops/style:tab-stop) > 0 and count($tabStops/style:tab-stop) < 3">
<!-- only allow the heuristic when the style has less than 3 TABS -->
<!-- ignore heuristics if no TABS are defined -->
<xsl:attribute name="style">
<xsl:call-template name="createTabIndent">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="tabStops" select="$tabStops"/>
<xsl:with-param name="tabCount" select="$tabCount + 1"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
<xsl:with-param name="pageMarginLeft" select="$pageMarginLeft"/>
</xsl:call-template>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<!-- if there are more than 3 TABS in the style, create a none-breakable-space as whitespace -->
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="following-sibling::node()[1]" mode="tabContentHandling">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:element>
<xsl:apply-templates select="following-sibling::node()[1]" mode="tabHandling">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="tabStops" select="$tabStops"/>
<xsl:with-param name="tabCount" select="$tabCount + 1"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
<xsl:with-param name="pageMarginLeft" select="$pageMarginLeft"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="name() = 'text:line-break'">
<!-- A line-break resets the tabCount to '0' -->
<br/>
<xsl:apply-templates select="following-sibling::node()[1]" mode="tabHandling">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="tabStops" select="$tabStops"/>
<xsl:with-param name="tabCount" select="0"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
<xsl:with-param name="pageMarginLeft" select="$pageMarginLeft"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<!-- only before the first tab all content is written out -->
<xsl:if test="$tabCount = 0">
<xsl:apply-templates select=".">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:if>
<xsl:apply-templates select="following-sibling::node()[1]" mode="tabHandling">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="tabStops" select="$tabStops"/>
<xsl:with-param name="tabCount" select="$tabCount"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
<xsl:with-param name="pageMarginLeft" select="$pageMarginLeft"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
This recursion creates the content of a tab (i.e. following siblings
till next TAB or LINE BREAK) and ends with the next
TAB, LINE-BREAK or with the end of the paragraph.
-->
<xsl:template match="* | text()" mode="tabContentHandling">
<xsl:param name="globalData"/>
<xsl:if test="(name() != 'text:tab') and (name() != 'text:line-break')">
<!-- Write out content -->
<xsl:apply-templates select=".">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
<!-- Apply for the next node -->
<xsl:apply-templates select="following-sibling::node()[1]" mode="tabContentHandling">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<xsl:template name="createTabIndent">
<xsl:param name="globalData"/>
<xsl:param name="tabStops"/>
<xsl:param name="tabCount"/>
<xsl:param name="parentMarginLeft" />
<xsl:param name="pageMarginLeft" />
<xsl:text>position:absolute;left:</xsl:text>
<xsl:variable name="tabPosition">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="$tabStops/style:tab-stop[$tabCount]/@style:position"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="tabIndent">
<xsl:choose>
<xsl:when test="$tabStops/style:tab-stop[$tabCount]/@style:type = 'center'">
<!-- in case of style:type 'center' the text is even before the tab stop,
centered around the beginning. As I see currently no way in mapping this,
therefore I do some HEURISTIC (minus -2.5cm) -->
<xsl:value-of select="$tabPosition + $parentMarginLeft + $pageMarginLeft - 2.5"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$tabPosition + $parentMarginLeft + $pageMarginLeft"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--<xsl:message>TAB: tabCount=
<xsl:value-of select="$tabCount"/>, tabPosition=
<xsl:value-of select="$tabPosition"/>, tabIndent=
<xsl:value-of select="$tabIndent"/>
</xsl:message>-->
<xsl:choose>
<xsl:when test="$tabIndent='NaN'">
<xsl:variable name="tabPositionTmp">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="$tabStops/style:tab-stop[last()]/@style:position"/>
</xsl:call-template>
</xsl:variable>
<!-- Heuristic: for every tab that is more than specified give a further 1 cm -->
<xsl:value-of select="$parentMarginLeft + $tabPositionTmp + count($tabStops/style:tab-stop) - $tabCount"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$tabIndent"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>cm;</xsl:text>
<xsl:apply-templates select="$tabStops/style:tab-stop[$tabCount]/@style:type"/>
</xsl:template>
<!-- OOo writes out empty paragraphs layouted behind an image,
those have to be neglected in HTML
This method checks if an empty paragraph is of that kind! -->
<xsl:template name="follows-empty-paragraphs-and-image">
<xsl:param name="precedingElement" />
<xsl:param name="elementToCheck" select="1"/>
<xsl:choose>
<!-- OOo writes out empty paragraphs layouted behind the image,
those have to be neglected in HTML
<xsl:when test="name() = 'text:p' and (normalize-space($childText) = '')"> -->
<!-- WorkAround: Test if the empty paragraph was added after an image, which OOO often does -->
<xsl:when test="(name($precedingElement) = 'text:p' and not($precedingElement/text()) and not($precedingElement/*))">
<xsl:call-template name="follows-empty-paragraphs-and-image">
<xsl:with-param name="precedingElement" select="preceding-sibling::*[$elementToCheck]"/>
<xsl:with-param name="elementToCheck" select="$elementToCheck +1"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$precedingElement/draw:frame">yes</xsl:when>
<xsl:otherwise>no</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="create-paragraph">
<xsl:param name="globalData"/>
<!-- the footnote symbol is the prefix for a footnote in the footer -->
<xsl:param name="footnotePrefix"/>
<!-- xhtml:p may only contain inline elements.
If there is one frame beyond, div must be used! -->
<xsl:variable name="elementName">
<xsl:choose>
<xsl:when test="descendant::draw:frame[1] or descendant::text:p[1]">div</xsl:when>
<xsl:otherwise>p</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="{$elementName}">
<xsl:choose>
<!-- in ODF borders of paragraphs will be merged by default. Merging means the adjactend paragraphs are building a unit,
where only the first and the last will have have a border to the surrounding (top / bottom border)
<xsl:variable name="precedingParagraphStyle" select="preceding-sibling::*[1][name() = 'text:p']/@text:style-name"/>
<xsl:variable name="followingParagraphStyle" select="following-sibling::*[1][name() = 'text:p']/@text:style-name"/>
-->
<xsl:when test="$globalData/all-styles/style[@style:name = current()/@text:style-name]/@mergedBorders">
<xsl:variable name="precedingParagraphStyle" select="preceding-sibling::*[1][name() = 'text:p']/@text:style-name"/>
<xsl:variable name="followingParagraphStyle" select="following-sibling::*[1][name() = 'text:p']/@text:style-name"/>
<xsl:choose>
<xsl:when test="$precedingParagraphStyle or $followingParagraphStyle">
<xsl:variable name="isPrecedingBorderParagraph" select="$globalData/all-styles/style[@style:name = $precedingParagraphStyle]/@mergedBorders"/>
<xsl:variable name="isFollowingBorderParagraph" select="$globalData/all-styles/style[@style:name = $followingParagraphStyle]/@mergedBorders"/>
<xsl:choose>
<xsl:when test="not($isPrecedingBorderParagraph) and $isFollowingBorderParagraph">
<xsl:attribute name="class">
<xsl:value-of select="concat(translate(@text:style-name, '.,;: %()[]/\+', '_____________'), '_borderStart')"/>
</xsl:attribute>
<xsl:apply-templates>
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$isPrecedingBorderParagraph and not($isFollowingBorderParagraph)">
<xsl:attribute name="class">
<xsl:value-of select="concat(translate(@text:style-name, '.,;: %()[]/\+', '_____________'), '_borderEnd')"/>
</xsl:attribute>
<xsl:apply-templates>
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
</xsl:attribute>
<xsl:apply-templates>
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="write-paragraph">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="write-paragraph">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<xsl:template name="write-paragraph">
<xsl:param name="globalData"/>
<!-- the footnote symbol is the prefix for a footnote in the footer -->
<xsl:param name="footnotePrefix" />
<!-- empty paragraph tags does not provoke an carridge return,
therefore an non breakable space ( ) have been inserted.-->
<xsl:choose>
<xsl:when test="node()">
<xsl:call-template name="apply-styles-and-content">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="apply-styles-and-content">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="footnotePrefix" select="$footnotePrefix" />
</xsl:call-template>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="style:tab-stop/@style:type">
<xsl:text>text-align:</xsl:text>
<xsl:choose>
<xsl:when test=". = 'left'">left</xsl:when>
<xsl:when test=". = 'right'">right</xsl:when>
<xsl:when test=". = 'center'">center</xsl:when>
<xsl:otherwise>justify</xsl:otherwise>
</xsl:choose>
<xsl:text>;</xsl:text>
</xsl:template>
<!-- As soon a frame is within a paragraph (text:p) or page:frame, every child element is floating (CSS) and worked out in sequence.
Accumulating prior frame width and adding parent's left margin -->
<!-- Matching all elements and text beyond a paragraph/text:page which are sibling of a draw:frame -->
<xsl:template match="* | text()" mode="frameFloating">
<xsl:param name="globalData"/>
<xsl:param name="previousFrameWidths" select="0"/>
<xsl:param name="previousFrameHeights" select="0" />
<!-- it becomes true for siblings after a draw:frame -->
<xsl:param name="createDiv" select="false()"/>
<xsl:param name="noDivBefore" select="true()"/>
<xsl:param name="leftPosition" />
<xsl:param name="parentMarginLeft" />
<xsl:param name="frameAlignedToParagraphWithSvgY" />
<xsl:choose>
<xsl:when test="name() = 'draw:frame'">
<xsl:copy-of select="$frameAlignedToParagraphWithSvgY"/>
<!-- if the first node is a draw:frame create a div -->
<xsl:call-template name="createDrawFrame">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
<xsl:with-param name="previousFrameHeights" select="$previousFrameHeights"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
</xsl:call-template>
<!-- next elements will be called after the creation with the new indent (plus width of frame) -->
</xsl:when>
<xsl:otherwise>
<xsl:variable name="nextSiblingIsFrame" select="name(following-sibling::node()[1]) = 'draw:frame'"/>
<xsl:choose>
<xsl:when test="$createDiv and normalize-space(.) != ''">
<!-- every following frame sibling till the next draw:frame
have to be incapuslated within a div with left indent.
To be moved alltogether arcording the indent (usually right) -->
<xsl:comment>Next 'div' added for floating.</xsl:comment>
<xsl:element name="div">
<xsl:attribute name="style">
<xsl:text>position:relative; left:</xsl:text>
<xsl:value-of select="$leftPosition"/>
<xsl:text>cm;</xsl:text>
</xsl:attribute>
<xsl:apply-templates select=".">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
<!-- if it is a frame sibling it will be NOT incapuslated within the div (as already within one) -->
<xsl:if test="not($nextSiblingIsFrame)">
<xsl:apply-templates select="following-sibling::node()[1]" mode="frameFloating">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
<xsl:with-param name="previousFrameHeights" select="$previousFrameHeights"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
<xsl:with-param name="leftPosition" select="$leftPosition"/>
<xsl:with-param name="createDiv" select="false()"/>
<xsl:with-param name="noDivBefore" select="$noDivBefore"/>
<xsl:with-param name="frameAlignedToParagraphWithSvgY" select="$frameAlignedToParagraphWithSvgY"/>
</xsl:apply-templates>
</xsl:if>
</xsl:element>
<xsl:copy-of select="$frameAlignedToParagraphWithSvgY"/>
<!-- Other draw:frame will be created outside of the div element -->
<xsl:apply-templates select="following-sibling::draw:frame[1]" mode="frameFloating">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
<xsl:with-param name="previousFrameHeights" select="$previousFrameHeights"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
<xsl:with-param name="leftPosition" select="$leftPosition"/>
<xsl:with-param name="frameAlignedToParagraphWithSvgY" select="$frameAlignedToParagraphWithSvgY"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="not($createDiv)">
<xsl:apply-templates select=".">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="frameAlignedToParagraphWithSvgY" select="$frameAlignedToParagraphWithSvgY"/>
</xsl:apply-templates>
<xsl:if test="not($nextSiblingIsFrame) or $noDivBefore">
<xsl:apply-templates select="following-sibling::node()[1]" mode="frameFloating">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
<xsl:with-param name="previousFrameHeights" select="$previousFrameHeights"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
<xsl:with-param name="leftPosition" select="$leftPosition"/>
<xsl:with-param name="createDiv" select="false()"/>
<xsl:with-param name="noDivBefore" select="$noDivBefore"/>
<xsl:with-param name="frameAlignedToParagraphWithSvgY" select="$frameAlignedToParagraphWithSvgY"/>
</xsl:apply-templates>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- A XML node other than text or element (e.g. commment) should not stop the recursion -->
<xsl:template match="comment()" mode="frameFloating">
<xsl:param name="globalData"/>
<xsl:param name="previousFrameWidths" select="0"/>
<xsl:param name="previousFrameHeights" select="0" />
<!-- it becomes true for siblings after a draw:frame -->
<xsl:param name="createDiv" select="false()"/>
<xsl:param name="noDivBefore" select="true()"/>
<xsl:param name="leftPosition" />
<xsl:param name="parentMarginLeft" />
<xsl:param name="frameAlignedToParagraphWithSvgY" />
<xsl:apply-templates select="following-sibling::node()[1]" mode="frameFloating">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeft"/>
<xsl:with-param name="leftPosition" select="$leftPosition"/>
<xsl:with-param name="createDiv" select="$createDiv"/>
<xsl:with-param name="noDivBefore" select="$noDivBefore"/>
</xsl:apply-templates>
</xsl:template>
<!-- As draw:frame may occur within more elements than in text:p and draw:page -->
<xsl:template match="draw:frame">
<xsl:param name="globalData"/>
<xsl:param name="previousFrameWidths" select="0"/>
<xsl:param name="previousFrameHeights" select="0" />
<xsl:call-template name="createDrawFrame">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="previousFrameWidths" select="$previousFrameWidths"/>
<xsl:with-param name="previousFrameHeights" select="$previousFrameHeights"/>
</xsl:call-template>
<!-- after the last draw:frame sibling the CSS float is disabled -->
<xsl:if test="@text:anchor-type!='as-char'">
<div style="clear:both; line-height:0; width:0; height:0; margin:0; padding:0;"> </div>
</xsl:if>
</xsl:template>
<xsl:template name="getPageMarginLeft">
<!-- approximation to find the correct master page style (with page dimensions) -->
<xsl:variable name="masterPageNames">
<!-- Loop over every style:style containing a @style:master-page-name attribute -->
<xsl:for-each select="key('masterPage','count')">
<!-- Check if this style is being used in the body -->
<xsl:if test="key('elementUsingStyle', ../@style:name)">
<!-- Check every master-page-name if it is not emtpy and return as ';' separated list -->
<xsl:if test="string-length(../@style:master-page-name) > 0">
<xsl:value-of select="../@style:master-page-name"/>;
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<!-- Take the first of the masterpage list and get the according style:master-page element and find the @style:page-layout-name -->
<xsl:variable name="pageLayoutName" select="key('masterPageElements', substring-before($masterPageNames,';'))/@style:page-layout-name"/>
<!-- Find the according style:page-layout and store the properties in a variable -->
<xsl:variable name="pageMarginLeftAttr" select="key('pageLayoutElements', $pageLayoutName)/style:page-layout-properties/@fo:margin-left"/>
<xsl:choose>
<xsl:when test="$pageMarginLeftAttr">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="$pageMarginLeftAttr"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Elements and text aside of a draw:frame are floating, here a div is being created.
Either for a draw:frame or for text and other elements floating aside -->
<xsl:template name="createDrawFrame">
<xsl:param name="globalData"/>
<xsl:param name="previousFrameWidths" select="0"/>
<xsl:param name="previousFrameHeights" select="0" />
<xsl:param name="parentMarginLeft"/>
<xsl:variable name="parentMarginLeftNew">
<xsl:choose>
<xsl:when test="string-length(normalize-space($parentMarginLeft)) < 1">
<!-- Styles of first paragraph in list item, including ancestor styles (inheritance) -->
<xsl:variable name="paragraphName" select="parent::*/@text:style-name" />
<xsl:variable name="imageParagraphStyle" select="$globalData/all-styles/style[@style:name = $paragraphName]/final-properties"/>
<!-- Only the left margin of the first paragraph of a list item will be added to the margin of the complete list (all levels)-->
<xsl:choose>
<xsl:when test="contains($imageParagraphStyle, 'margin-left:')">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="normalize-space(substring-before(substring-after($imageParagraphStyle, 'margin-left:'), ';'))"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$parentMarginLeft"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="svgWidth">
<xsl:choose>
<xsl:when test="@svg:width">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="@svg:width"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="svgX">
<xsl:choose>
<xsl:when test="@svg:x">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="@svg:x"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="leftPosition" select="$svgX - $parentMarginLeftNew - $previousFrameWidths"/>
<xsl:variable name="svgY">
<xsl:choose>
<xsl:when test="@svg:y">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="@svg:y"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- if the frame is anchored on a paragraph -->
<xsl:if test="@text:anchor-type='paragraph'">
<xsl:comment>Next 'div' is emulating the top hight of a draw:frame.</xsl:comment>
<!-- When the svg:y is set relative to the paragraph content, the best way to emulate a positive height,
is to add an invisbile division inbetween with a height.
Often text will flow into this 'gap', which is handled separately!
-->
<xsl:if test="$svgY > 0">
<xsl:element name="div">
<xsl:attribute name="style">
<xsl:text>height:</xsl:text>
<xsl:value-of select="$svgY"/>
<xsl:text>cm;</xsl:text>
</xsl:attribute>
<xsl:text> </xsl:text>
</xsl:element>
</xsl:if>
</xsl:if>
<!--
<xsl:variable name="followingSibling" select="following-sibling::node()[1]"/>
<xsl:choose>
HEURISTIC: if the frame is anchored on a paragraph and the above gab is big enough to hold a text line,
move it behind the text
<xsl:when test="@text:anchor-type='paragraph' and
(
($svgY > 0.5) or
($svgX > 4)
) and normalize-space($followingSibling) != ''">
<xsl:apply-templates select="$followingSibling" mode="frameFloating">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="previousFrameWidths" select="$previousFrameWidths + $svgWidth"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeftNew"/>
<xsl:with-param name="leftPosition" select="$leftPosition"/>
<xsl:with-param name="createDiv" select="true()"/>
<xsl:with-param name="noDivBefore" select="false()"/>
<xsl:with-param name="frameAlignedToParagraphWithSvgY">
<xsl:call-template name="createDrawFrame2">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="previousFrameWidths" select="$previousFrameWidths + $svgWidth"/>
<xsl:with-param name="parentMarginLeftNew" select="$parentMarginLeftNew"/>
<xsl:with-param name="leftPosition" select="$leftPosition"/>
<xsl:with-param name="svgY" select="$svgY"/>
</xsl:call-template>
</xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>-->
<xsl:call-template name="createDrawFrame2">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="previousFrameWidths" select="$previousFrameWidths + $svgWidth"/>
<xsl:with-param name="parentMarginLeftNew" select="$parentMarginLeftNew"/>
<xsl:with-param name="leftPosition" select="$leftPosition"/>
<xsl:with-param name="svgY" select="$svgY"/>
</xsl:call-template>
<xsl:apply-templates select="following-sibling::node()[1]" mode="frameFloating">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="previousFrameWidths" select="$previousFrameWidths + $svgWidth"/>
<xsl:with-param name="parentMarginLeft" select="$parentMarginLeftNew"/>
<xsl:with-param name="leftPosition" select="$leftPosition"/>
<xsl:with-param name="createDiv" select="true()"/>
<xsl:with-param name="noDivBefore" select="false()"/>
</xsl:apply-templates>
<!--
</xsl:otherwise>
</xsl:choose> -->
</xsl:template>
<xsl:template name="createDrawFrame2">
<xsl:param name="globalData"/>
<xsl:param name="previousFrameWidths" />
<xsl:param name="parentMarginLeftNew"/>
<xsl:param name="leftPosition" />
<xsl:param name="svgY" />
<xsl:variable name="elem-name">
<xsl:choose>
<xsl:when test="@text:anchor-type='as-char'">span</xsl:when>
<xsl:otherwise>div</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:comment>Next '
<xsl:value-of select="$elem-name"/>' is a draw:frame.
</xsl:comment>
<xsl:element name="{$elem-name}">
<xsl:attribute name="style">
<xsl:call-template name="widthAndHeight"/>
<xsl:text> padding:0; </xsl:text>
<xsl:if test="@text:anchor-type!='as-char'">
<!-- all images float (CSS float reltaive) with a left position calculated by svg:x - parentMarginLeft - previousFrameWidths -->
<xsl:text> float:left; position:relative; left:</xsl:text>
<xsl:value-of select="$leftPosition"/>
<xsl:text>cm; </xsl:text>
<!-- if the frame is anchored on a char -->
<xsl:if test="@text:anchor-type='char'">
<xsl:text>top:</xsl:text>
<xsl:value-of select="$svgY"/>
<xsl:text>cm; </xsl:text>
</xsl:if>
</xsl:if>
</xsl:attribute>
<xsl:apply-templates select="@*">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
<xsl:apply-templates select="node()">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<xsl:template match="svg:desc"/>
<xsl:template name="widthAndHeight">
<xsl:if test="@svg:height | @svg:width">
<xsl:choose>
<xsl:when test="not(@svg:width)">
<xsl:call-template name="svg:height"/>
</xsl:when>
<xsl:when test="not(@svg:height)">
<xsl:call-template name="svg:width"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="svg:height"/>
<xsl:call-template name="svg:width"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<!-- ***************** -->
<!-- *** Text Span *** -->
<!-- ***************** -->
<xsl:template match="text:span">
<xsl:param name="globalData"/>
<xsl:choose>
<xsl:when test="draw:frame">
<!-- sometimes an ODF image is anchored as character and the
image frame appears within a span (which is not valid for HTML)
Heuristic: Neglecting the span assuming no text content aside
of frame within span -->
<xsl:apply-templates>
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:element name="span">
<xsl:call-template name="apply-styles-and-content">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- **************** -->
<!-- *** Headings *** -->
<!-- **************** -->
<xsl:template match="text:h">
<xsl:param name="globalData"/>
<!-- no creation of empty headings (without text content) -->
<xsl:if test="text() or descendant::text()">
<!-- The URL linking of an table-of-content is due to a bug (cp. bug id# 102311) not mapped as URL in the XML.
Linking of the table-of-content can therefore only be archieved by a work-around in HTML -->
<xsl:call-template name="create-heading">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- default matching for header elements -->
<xsl:template name="create-heading">
<xsl:param name="globalData"/>
<xsl:variable name="headingLevel">
<xsl:choose>
<xsl:when test="@text:outline-level < 6">
<xsl:value-of select="@text:outline-level"/>
</xsl:when>
<xsl:otherwise>6</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="headertyp" select="concat('h', $headingLevel)"/>
<xsl:element name="{$headertyp}">
<!-- outline style 'text:min-label-width' is interpreted as a CSS 'margin-right' attribute
NOTE: Should be handled as CSS style in style header -->
<xsl:variable name="min-label" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/*/@text:min-label-width"/>
<xsl:attribute name="class">
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
</xsl:attribute>
<xsl:call-template name="create-heading-anchor">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
<xsl:apply-templates>
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<xsl:template name="create-heading-anchor">
<xsl:param name="globalData"/>
<!-- writing out a heading number if desired.-->
<!-- if a corresponding 'text:outline-style' exist or is not empty -->
<xsl:choose>
<xsl:when test="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@style:num-format != ''">
<!-- Every heading element will get an unique anchor for its file, from its hiearchy level and name:
For example: The heading title 'My favorite heading' might get <a name="1_2_2_My_favorite_heading" /> -->
<!-- creating an anchor for referencing the heading (e.g. from content table) -->
<xsl:variable name="headingNumber">
<xsl:call-template name="get-heading-number">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="create-heading-anchor2">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="headingNumber" select="$headingNumber"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="create-heading-anchor2">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="get-heading-number">
<xsl:param name="globalData"/>
<!-- write number prefix -->
<xsl:value-of select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@style:num-prefix"/>
<xsl:call-template name="write-heading-number">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
<!-- write number suffix -->
<xsl:value-of select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@style:num-suffix"/>
</xsl:template>
<!-- creating an anchor for referencing the heading -->
<xsl:template name="create-heading-anchor2">
<xsl:param name="globalData"/>
<xsl:param name="headingNumber" />
<xsl:variable name="title">
<xsl:apply-templates mode="concatenate"/>
</xsl:variable>
<!-- REFERENCE HANDLING - ANCHOR -->
<xsl:element namespace="{$namespace}" name="a">
<xsl:attribute name="id">
<xsl:value-of select="translate(concat('a_',$headingNumber, '_', normalize-space($title)), '
&<>.,;: %()[]/\+', '___________________________')"/>
</xsl:attribute>
<xsl:element name="span">
<!-- outline style 'text:min-label-distance' is interpreted as a CSS 'margin-right' attribute
NOTE: Should be handled as CSS style in style header -->
<xsl:variable name="minLabelDistance" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/*/@text:min-label-distance"/>
<xsl:variable name="minLabelWidth" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/*/@text:min-label-width"/>
<xsl:if test="$minLabelDistance | $minLabelWidth">
<xsl:attribute name="style">
<xsl:if test="$minLabelDistance">
<xsl:text>margin-right:</xsl:text>
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="$minLabelDistance"/>
</xsl:call-template>
<xsl:text>cm;</xsl:text>
</xsl:if>
<xsl:if test="$minLabelWidth">
<xsl:text>min-width:</xsl:text>
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="$minLabelWidth"/>
</xsl:call-template>
<xsl:text>cm;</xsl:text>
</xsl:if>
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="$headingNumber"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template name="write-heading-number">
<xsl:param name="globalData"/>
<!-- By default heading start with '1', the parameter 'textStartValue' will only be set, if the attribute @text:start-value exist -->
<xsl:choose>
<xsl:when test="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@text:start-value">
<xsl:call-template name="calc-heading-number">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="outlineLevel" select="@text:outline-level"/>
<xsl:with-param name="textStartValue" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:outline-level]/@text:start-value"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="calc-heading-number">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="outlineLevel" select="@text:outline-level"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
Find the correct heading no., which is the sum of 'text:start-value'
and preceding siblings of 'text:h' with the same 'text:outline-level' (until a text:outline-level with lower value is found).
If the 'text:start-value is not set the default value of '1' has to be taken.
If a heading number is found (e.g. text:outline-level='3') all heading numbers
for the higher levels have to be written out -->
<xsl:template name="calc-heading-number">
<xsl:param name="globalData"/>
<xsl:param name="outlineLevel"/><!-- text level of the heading -->
<xsl:param name="iOutlineLevel" select="1"/><!-- iterator, counts from 1 to the text level of the heading -->
<xsl:param name="textStartValue" select="1"/><!-- text level to start with, default is '1' -->
<xsl:choose>
<!-- iText levels counts up from '1' to outlineLevel
Which means writing a heading number from left to right -->
<xsl:when test="$iOutlineLevel < $outlineLevel">
<!-- Write preceding heading numbers -->
<xsl:call-template name="writeNumber">
<xsl:with-param name="numberDigit">
<xsl:call-template name="calc-heading-digit">
<xsl:with-param name="value" select="0"/>
<xsl:with-param name="currentoutlineLevel" select="$iOutlineLevel"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="numberFormat" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = ($outlineLevel)]/@style:num-format"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = ($iOutlineLevel + 1)]/@text:start-value">
<xsl:call-template name="calc-heading-number">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="outlineLevel" select="$outlineLevel"/>
<xsl:with-param name="iOutlineLevel" select="$iOutlineLevel + 1"/>
<xsl:with-param name="textStartValue" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = ($iOutlineLevel + 1)]/@text:start-value"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="calc-heading-number">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="outlineLevel" select="$outlineLevel"/>
<xsl:with-param name="iOutlineLevel" select="$iOutlineLevel + 1"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<!-- Write preceding heading numbers -->
<xsl:call-template name="writeNumber">
<xsl:with-param name="numberDigit">
<xsl:call-template name="calc-heading-digit">
<xsl:with-param name="value" select="$textStartValue"/>
<xsl:with-param name="currentoutlineLevel" select="$iOutlineLevel"/>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="numberFormat" select="$globalData/office:styles/text:outline-style/text:outline-level-style[@text:level = $outlineLevel]/@style:num-format"/>
<xsl:with-param name="last" select="true()"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="writeNumber">
<xsl:param name="numberDigit"/>
<xsl:param name="numberFormat"/>
<xsl:param name="last"/>
<xsl:choose>
<xsl:when test="not($numberFormat)">
<xsl:number value="$numberDigit" format="1."/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$last">
<xsl:number value="$numberDigit" format="{$numberFormat}"/>
</xsl:when>
<xsl:otherwise>
<xsl:number value="$numberDigit" format="{$numberFormat}."/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="calc-heading-digit">
<xsl:param name="value"/>
<xsl:param name="currentoutlineLevel"/>
<xsl:param name="i" select="1"/>
<xsl:variable name="precedingoutlineLevel" select="preceding-sibling::text:h[$i]/@text:outline-level"/>
<xsl:choose>
<xsl:when test="$currentoutlineLevel = $precedingoutlineLevel">
<xsl:call-template name="calc-heading-digit">
<xsl:with-param name="value" select="$value + 1"/>
<xsl:with-param name="currentoutlineLevel" select="$currentoutlineLevel"/>
<xsl:with-param name="i" select="$i + 1"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$currentoutlineLevel < $precedingoutlineLevel">
<xsl:call-template name="calc-heading-digit">
<xsl:with-param name="value" select="$value"/>
<xsl:with-param name="currentoutlineLevel" select="$currentoutlineLevel"/>
<xsl:with-param name="i" select="$i + 1"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Neglect Annotations -->
<xsl:template match="office:annotation" mode="concatenate"/>
<!-- Match text:placeholder child nodes (e.g. text) -->
<xsl:template match="text:placeholder">
<xsl:param name="globalData"/>
<xsl:call-template name="apply-styles-and-content">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:template>
<!-- ************* -->
<!-- *** Link *** -->
<!-- ************* -->
<xsl:template match="text:a | draw:a">
<xsl:param name="globalData"/>
<xsl:call-template name="create-common-anchor-link">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="create-common-anchor-link">
<xsl:param name="globalData"/>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:call-template name="create-href">
<xsl:with-param name="href" select="@xlink:href"/>
</xsl:call-template>
</xsl:attribute>
<xsl:call-template name="apply-styles-and-content">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:element>
</xsl:template>
<!-- ******************* -->
<!-- *** Image Link *** -->
<!-- ******************* -->
<!-- currently suggesting that all draw:object-ole elements are images -->
<xsl:template match="draw:image | draw:object-ole">
<xsl:param name="globalData"/>
<xsl:choose>
<xsl:when test="ancestor::text:p or parent::text:span or parent::text:h or parent::draw:a or parent::text:a or text:ruby-base">
<!-- XHTML does not allow the mapped elements to contain paragraphs -->
<xsl:call-template name="create-image-element">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- images are embedded in a paragraph, but are in CSS not able to express a horizontal alignment for themself.
A 'div' element taking over the image style would solve that problem, but is invalid as child of a paragraph -->
<xsl:element name="p">
<xsl:apply-templates select="@draw:style-name">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
<xsl:call-template name="create-image-element">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="create-image-element">
<xsl:param name="globalData"/>
<xsl:element name="img">
<xsl:if test="../@svg:width or ../@svg:height">
<xsl:attribute name="style">
<xsl:if test="../@svg:height">
<xsl:text>height:</xsl:text>
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="../@svg:height"/>
</xsl:call-template>
<xsl:text>cm;</xsl:text>
</xsl:if>
<xsl:if test="../@svg:width">
<xsl:text>width:</xsl:text>
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="../@svg:width"/>
</xsl:call-template>
<xsl:text>cm;</xsl:text>
</xsl:if>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="alt">
<xsl:choose>
<xsl:when test="../svg:title">
<xsl:value-of select="../svg:title"/>
</xsl:when>
<xsl:otherwise>
<xsl:message>
Accessibility Warning:
No alternate text ('svg:title' element) set for
image '
<xsl:value-of select="@xlink:href"/>'!
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="src">
<xsl:call-template name="create-href">
<xsl:with-param name="href" select="@xlink:href"/>
</xsl:call-template>
</xsl:attribute>
<!-- style interpretation only, as no subelements are allowed for img in XHTML -->
<xsl:apply-templates select="@draw:style-name">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<!-- ************ -->
<!-- *** list *** -->
<!-- ************ -->
<!--
Due to the requirements below the ODF list functionality is not handled by CSS, but the list labels calculated and written by XSLT.
REQUIREMENTS:
=============
A)
One significant difference between XHTML and Office List elements is that a list without text nodes but only further list children
would not show a list symbol in the Office, but in the browser from XHTML.
B)
Since OASIS Open Document XML (implemented in OOo2.0) only one parent type exists for list items
the 'text:list' element. The XHTML element 'ol', 'ul' will be choosen upon the list style type.
C)
An Office list may be spread over the whole document. Linked by their style and text:continue-numbering='true'.
D)
An Office list can use characters or images as list label.
E)
An Office list can have a prefix and suffix around the list label.
F)
An Office list style may have the attribute consecutive numbering, which resolves in a list counting for all levels
G)
An Office list may (re)start on any arbitrary value by using @text:start-value on the text:list-item
INDENDATION:
============
The indent of a list label is not only calculated by using the text:space-before of the list level (listLevelStyle), but
as well taking the left margin of the first paragraph (or heading) of the list into account as loy match="" name="" use=""/>ng it is not negative.
| MARGIN LEFT | LABEL |
| text:space-before (listlevelstyle) | text:min-label-width |
| + fo:left-margin (firstParagraph) | |
Further details beyond text:list-list..
-->
<xsl:key name="listStyles" match=" /*/office:styles/text:list-style | /*/office:automatic-styles/text:list-style | /*/office:styles/style:graphic-properties/text:list-style | /*/office:automatic-styles/style:graphic-properties/text:list-style | /*/office:styles/text:list-style | /*/office:automatic-styles/text:list-style | /*/office:styles/style:graphic-properties/text:list-style | /*/office:automatic-styles/style:graphic-properties/text:list-style" use="@style:name"/>
<!--
A text list may only have text:list-item and text:list-header as children.
-->
<xsl:template match="text:list">
<xsl:param name="globalData"/>
<xsl:param name="isListNumberingReset"/>
<xsl:param name="isNextLevelNumberingReset"/>
<xsl:param name="listLevel" select="1"/>
<xsl:param name="listRestart" select="false()"/>
<xsl:param name="itemLabel" select="''"/>
<xsl:param name="listStyle"/>
<xsl:param name="listStyleName" select="@text:style-name"/>
<!-- To choose list type - get the list style, with the same 'text:style-name' and same 'text:level' >-->
<xsl:variable name="listStyleRTF">
<xsl:variable name="listStyleInContentFile" select="key('listStyles', $listStyleName)"/>
<xsl:choose>
<xsl:when test="$listStyleInContentFile">
<xsl:copy-of select="$listStyleInContentFile"/>
</xsl:when>
<xsl:when test="$globalData/office:styles/text:list-style[@style:name = $listStyleName]">
<xsl:copy-of select="$globalData/office:styles/text:list-style[@style:name = $listStyleName]"/>
</xsl:when>
<xsl:when test="$globalData/office:styles/style:graphic-properties/text:list-style[@style:name = $listStyleName]">
<xsl:copy-of select="$globalData/office:styles/style:graphic-properties/text:list-style[@style:name = $listStyleName]"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="function-available('common:node-set')">
<xsl:call-template name="create-list-type">
<xsl:with-param name="listStyle" select="common:node-set($listStyleRTF)" />
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listRestart" select="$listRestart"/>
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="listStyleName" select="$listStyleName" />
</xsl:call-template>
</xsl:when>
<xsl:when test="function-available('xalan:nodeset')">
<xsl:call-template name="create-list-type">
<xsl:with-param name="listStyle" select="xalan:nodeset($listStyleRTF)" />
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listRestart" select="$listRestart"/>
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="listStyleName" select="$listStyleName" />
</xsl:call-template>
</xsl:when>
<xsl:when test="function-available('xt:node-set')">
<xsl:call-template name="create-list-type">
<xsl:with-param name="listStyle" select="xt:node-set($listStyleRTF)" />
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listRestart" select="$listRestart"/>
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="listStyleName" select="$listStyleName" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">The required node-set function was not found!</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="create-list-type">
<xsl:param name="globalData"/>
<xsl:param name="isListNumberingReset"/>
<xsl:param name="isNextLevelNumberingReset"/>
<xsl:param name="listLevel" />
<xsl:param name="listRestart" />
<xsl:param name="itemLabel"/>
<xsl:param name="listStyle"/>
<xsl:param name="listStyleName" />
<!-- $globalData/styles-file/*/office:styles/ -->
<xsl:variable name="listLevelStyle" select="$listStyle/*/*[@text:level = number($listLevel)]"/>
<xsl:variable name="listIndent">
<xsl:call-template name="getListIndent">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="firstPara" select="*[1]/*[name() = 'text:p' or name() = 'text:h'][1]"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="isEmptyList" select="not(*[1]/*[name() = 'text:h' or name() = 'text:p' or name() = 'text:name'])"/>
<xsl:variable name="listType">
<xsl:choose>
<!-- ordered list -->
<xsl:when test="name($listLevelStyle) = 'text:list-level-style-number'">
<xsl:text>ol</xsl:text>
</xsl:when>
<!-- unordered list (bullet or image) -->
<xsl:otherwise>
<xsl:text>ul</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="{$listType}">
<xsl:apply-templates select="*[1]" mode="listItemSibling">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isEmptyList" select="$isEmptyList"/>
<xsl:with-param name="isListNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="isNextLevelNumberingReset">
<xsl:choose>
<xsl:when test="$isListNumberingReset">
<xsl:value-of select="true()"/>
</xsl:when>
<xsl:otherwise>
<!-- A list is empty if a text:list does not have a text:list-header or text:list-item (wildcard as only those can exist beyond a text:list), which contains a text:h or text:p -->
<xsl:value-of select="not($isEmptyList)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="listIndent" select="$listIndent"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listRestart">
<xsl:choose>
<xsl:when test="$listRestart">
<xsl:value-of select="$listRestart"/>
</xsl:when>
<xsl:otherwise>
<!-- descdendants restart their list numbering, when an ancestor is not empty -->
<xsl:value-of select="not($isEmptyList)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
<xsl:with-param name="minLabelDist">
<xsl:choose>
<xsl:when test="$listLevelStyle/*/@text:min-label-distance">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="$listLevelStyle/*/@text:min-label-distance"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="minLabelWidth">
<xsl:choose>
<xsl:when test="$listLevelStyle/*/@text:min-label-width">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="$listLevelStyle/*/@text:min-label-width"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:apply-templates>
</xsl:element>
</xsl:template>
<!-- See comment before text:list template -->
<xsl:template name="getListIndent">
<xsl:param name="globalData"/>
<xsl:param name="listLevelStyle"/>
<!-- The first paragraph of the list item (heading is special paragraph in ODF) -->
<xsl:param name="firstPara" />
<!-- Styles of first paragraph in list item, including ancestor styles (inheritance) -->
<xsl:variable name="firstParaStyles" select="$globalData/all-styles/style[@style:name = $firstPara/@text:style-name]/final-properties"/>
<!-- Only the left margin of the first paragraph of a list item will be added to the margin of the complete list (all levels)-->
<xsl:variable name="firstParaLeftMargin">
<xsl:choose>
<xsl:when test="contains($firstParaStyles, 'margin-left:')">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="normalize-space(substring-before(substring-after($firstParaStyles, 'margin-left:'), ';'))"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="spaceBefore">
<xsl:choose>
<xsl:when test="$listLevelStyle/*/@text:space-before">
<xsl:call-template name="convert2cm">
<xsl:with-param name="value" select="$listLevelStyle/*/@text:space-before"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Only if the left-margin of the first paragraph is positive the sum
text:space-before and fo:left-margin is taken as list indent -->
<xsl:choose>
<xsl:when test="$firstParaLeftMargin > 0">
<xsl:value-of select="$firstParaLeftMargin + $spaceBefore"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$spaceBefore"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ****************** -->
<!-- *** list item *** -->
<!-- ****************** -->
<!--
Left margin of the complete list:
The space between left page and the list symbol (left-margin) is in the Office implemented by
the sum of three values:
1) 'text:space-before', which is part of the 'text:list-style' element.
2) 'margin:left' from the style of the first child (e.g. paragraph).
3) 'fo:text-indent' the indent of the first line of some child (e.g. paragraph) (applied by CSS class style)
Possible list children:
<!ELEMENT text:list-item (text:p|text:h|text:list)+>
In the Office the list label before the text depends on two attributes:
- 'text:min-label-width': the distance between list label and all text of the list item.
- 'text:min-label-distance': the distance between list label and text of the first line,
only used, when text does not fit in text:min-label-width (ignored)
-->
<xsl:template match="text:list-item | text:list-header" mode="listItemSibling">
<xsl:param name="globalData"/>
<xsl:param name="firstitemLabelWidth"/>
<xsl:param name="isEmptyList" select="not(*[name() = 'text:h' or name() = 'text:p' or name() = 'text:name'])"/>
<xsl:param name="isListNumberingReset"/>
<xsl:param name="isNextLevelNumberingReset"/>
<xsl:param name="itemNumber"/>
<xsl:param name="itemLabel"/>
<xsl:param name="listLevel"/>
<xsl:param name="listLevelStyle"/>
<xsl:param name="listRestart"/>
<xsl:param name="listStyle"/>
<xsl:param name="listStyleName"/>
<xsl:param name="minLabelDist"/>
<xsl:param name="minLabelWidth"/>
<xsl:param name="listIndent" />
<!-- The text:list-header shall not be labeled. According to ODF specification (sect. 4.3.2):
"The <text:list-header> element represents a list header and is a special kind of list item. It
contains one or more paragraphs that are displayed before a list. The paragraphs are formatted
like list items but they do not have a preceding number or bullet." -->
<xsl:variable name="isListHeader" select="boolean(self::text:list-header)"/>
<xsl:variable name="listIndentNew">
<xsl:choose>
<xsl:when test="$listIndent">
<xsl:value-of select="$listIndent"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="getListIndent">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="firstPara" select="*[name() = 'text:p' or name() = 'text:h'][1]" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="itemNumberNew">
<xsl:if test="$listStyle/text:list-style/text:list-level-style-number">
<xsl:choose>
<xsl:when test="$isListHeader">0</xsl:when>
<xsl:when test="$isEmptyList">
<!-- An empty list item (no text:h/text:p as child), will not count as item and does not increment the count. -->
<xsl:variable name="tempItemNumber">
<xsl:choose>
<!-- siblings will be incremented by one -->
<xsl:when test="$itemNumber">
<xsl:if test="not($isListHeader)">
<xsl:value-of select="$itemNumber + 1"/>
</xsl:if>
</xsl:when>
<!-- if a higher list level had content the numbering starts with 1 -->
<xsl:when test="$isListNumberingReset and $listLevel > 1">
<xsl:value-of select="1"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="getItemNumber">
<xsl:with-param name="listStyleName" select="$listStyleName"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<!-- in case the empty list-item is the first list-item in document -->
<xsl:when test="$tempItemNumber = 1">
<xsl:value-of select="1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$tempItemNumber - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="@text:start-value">
<xsl:value-of select="@text:start-value"/>
</xsl:when>
<!-- text:start-value from list level style will only be taken on the first list-item of a list -->
<xsl:when test="$listLevelStyle/@text:start-value and count(preceding-sibling::text:list-item) = 0">
<xsl:value-of select="$listLevelStyle/@text:start-value"/>
</xsl:when>
<!-- siblings will be incremented by one -->
<xsl:when test="$itemNumber">
<xsl:value-of select="$itemNumber + 1"/>
</xsl:when>
<!-- if a higher list level had content the numbering starts with 1 -->
<xsl:when test="$isListNumberingReset and $listLevel > 1">
<xsl:value-of select="1"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="getItemNumber">
<xsl:with-param name="listStyleName" select="$listStyleName"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:variable>
<xsl:variable name="itemLabelNew">
<xsl:if test="$listStyle/text:list-style/text:list-level-style-number">
<!--
A numbered label (e.g. 2.C.III) is created for every text:list-item/header.
Above list levels are listed in the label, if the list-style requires this. Levels are separated by a '.'
Formatation is dependent for every list level depth.
The label is passed from anchestor text:list-item/header and if requrired truncated.
The prefix/suffix (as well list level dependent) comes before and after the complete label (after truncation)
-->
<!-- Numbered label will be generated -->
<xsl:call-template name="createItemLabel">
<xsl:with-param name="itemNumber" select="$itemNumberNew"/>
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="listLevelsToDisplay">
<xsl:variable name="display" select="$listLevelStyle/@text:display-levels"/>
<xsl:choose>
<xsl:when test="$display">
<xsl:value-of select="$display"/>
</xsl:when>
<xsl:when test="$isListHeader">0</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
</xsl:call-template>
</xsl:if>
</xsl:variable>
<xsl:element name="li">
<xsl:choose>
<xsl:when test="$isEmptyList or $isListHeader">
<xsl:apply-templates>
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="itemLabel" select="$itemLabelNew"/>
<xsl:with-param name="listLevel" select="$listLevel + 1"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<!-- Possible following children are text:h, text:p, list:text, text:soft-page-break -->
<xsl:apply-templates mode="list-item-children" select="*[1]">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isEmptyList" select="$isEmptyList"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isListHeader or $isNextLevelNumberingReset"/>
<!-- The new created label is given to the children -->
<xsl:with-param name="itemLabel" select="$itemLabelNew"/>
<xsl:with-param name="listLabelElement">
<xsl:choose>
<xsl:when test="name() = 'text:list-header'"/>
<xsl:otherwise>
<xsl:variable name="listLabelWidth">
<xsl:choose>
<xsl:when test="$minLabelWidth > $minLabelDist">
<xsl:value-of select="$minLabelWidth"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$minLabelDist"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Numbering is being done by this transformation creating a HTML span representing the number label
The html:span represents the list item/header label (e.g. 1.A.III)
As the html:span is usually a inline element is formated by CSS as block element to use width upon it,
to disable the caridge return float:left is used and later neglected -->
<xsl:element name="span">
<xsl:if test="$listLevelStyle/@text:style-name">
<xsl:attribute name="class">
<xsl:value-of select="$listLevelStyle/@text:style-name"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="style">
<xsl:text>display:block;float:</xsl:text>
<!-- 2DO: Svante - copy this functionality for other used margin:left (in western country 'left') -->
<xsl:call-template name="getOppositeWritingDirection">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="paraStyleName" select="descendant-or-self::*/@text:style-name"/>
</xsl:call-template>
<xsl:text>;min-width:</xsl:text>
<xsl:value-of select="$listLabelWidth"/>
<xsl:text>cm</xsl:text>
</xsl:attribute>
<xsl:variable name="labelContent">
<xsl:choose>
<xsl:when test="text:number">
<xsl:apply-templates select="text:number" mode="listnumber"/>
</xsl:when>
<xsl:when test="name($listLevelStyle) = 'text:list-level-style-bullet'">
<xsl:value-of select="$listLevelStyle/@style:num-prefix"/>
<xsl:value-of select="$listLevelStyle/@text:bullet-char"/>
<xsl:value-of select="$listLevelStyle/@style:num-suffix"/>
</xsl:when>
<xsl:when test="name($listLevelStyle) = 'text:list-level-style-number'">
<xsl:value-of select="$listLevelStyle/@style:num-prefix"/>
<xsl:value-of select="$itemLabelNew"/>
<xsl:value-of select="$listLevelStyle/@style:num-suffix"/>
</xsl:when>
<xsl:otherwise>
<!-- Listing with image as bullets, taken from the list style's href -->
<xsl:value-of select="$listLevelStyle/@xlink:href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Some browsers have problem with stand-alone elements (e.g. <span/>)
Therefore a comment is being inserted into an empty label -->
<xsl:choose>
<xsl:when test="$labelContent != ''">
<xsl:value-of select="$labelContent"/>
</xsl:when>
<xsl:otherwise>
<xsl:comment> </xsl:comment>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="listLabelEmptyElement">
<xsl:variable name="listLabelWidth">
<xsl:choose>
<xsl:when test="$minLabelWidth > $minLabelDist">
<xsl:value-of select="$minLabelWidth"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$minLabelDist"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="span">
<xsl:if test="$listLevelStyle/@text:style-name">
<xsl:attribute name="class">
<xsl:value-of select="$listLevelStyle/@text:style-name"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="style">
<xsl:text>display:block;float:</xsl:text>
<xsl:call-template name="getOppositeWritingDirection">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="paraStyleName" select="descendant-or-self::*/@text:style-name"/>
</xsl:call-template>
<xsl:text>;min-width:</xsl:text>
<xsl:value-of select="$listLabelWidth"/>
<xsl:text>cm</xsl:text>
</xsl:attribute>
<xsl:comment> </xsl:comment>
</xsl:element>
</xsl:with-param>
<xsl:with-param name="listLevel" select="$listLevel + 1"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listRestart" select="$listRestart"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
<xsl:with-param name="listIndent" select="$listIndentNew"/>
<xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<xsl:apply-templates select="following-sibling::*[1]" mode="listItemSibling">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="itemNumber" select="$itemNumberNew"/>
<xsl:with-param name="listIndent">
<xsl:choose>
<xsl:when test="not($isEmptyList)">
<xsl:value-of select="$listIndentNew"/>
</xsl:when>
</xsl:choose>
</xsl:with-param>
<!-- Receives the same parent label -->
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
<xsl:with-param name="minLabelDist" select="$minLabelDist"/>
<xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template name="getOppositeWritingDirection">
<xsl:param name="globalData"/>
<xsl:param name="paraStyleName"/>
<xsl:variable name="imageParagraphStyle" select="$globalData/all-styles/style[@style:name = $paraStyleName]/final-properties"/>
<xsl:choose>
<xsl:when test="contains($imageParagraphStyle, 'writing-mode:')">
<xsl:choose>
<xsl:when test="contains(substring-before(substring-after($imageParagraphStyle, 'writing-mode:'), ';'), 'rl')">right</xsl:when>
<xsl:otherwise>left</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>left</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text:number" mode="listnumber">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="text:number" mode="list-item-children">
<xsl:param name="globalData"/>
<xsl:param name="listLabelElement"/>
<xsl:param name="listLabelEmptyElement"/>
<xsl:param name="isEmptyList"/>
<xsl:param name="isListNumberingReset"/>
<xsl:param name="isNextLevelNumberingReset"/>
<xsl:param name="itemLabel"/>
<xsl:param name="itemNumber"/>
<xsl:param name="listIndent"/>
<xsl:param name="listLevel"/>
<xsl:param name="listLevelStyle" />
<xsl:param name="listRestart"/>
<xsl:param name="listStyle"/>
<xsl:param name="listStyleName"/>
<xsl:param name="minLabelWidth"/>
<xsl:apply-templates mode="list-item-children" select="following-sibling::*[1]">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isEmptyList" select="$isEmptyList"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="listLabelElement" select="$listLabelElement"/>
<xsl:with-param name="listLabelEmptyElement" select="$listLabelEmptyElement"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listRestart" select="$listRestart"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
<xsl:with-param name="listIndent" select="$listIndent"/>
<xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
</xsl:apply-templates>
</xsl:template>
<!-- Each key element holds the set of all text:list-item/text:list-header of a certain level and a certain style -->
<xsl:key name="getListItemsByLevelAndStyle" use="concat(count(ancestor::text:list), ancestor::text:list/@text:style-name)" match="text:list-item | text:list-header"/>
<!-- Each key element holds the set of all text:list-item/text:list-header of a certain style -->
<xsl:key name="getListItemsByStyle" use="ancestor::text:list/@text:style-name" match="text:list-item | text:list-header"/>
<!-- The Numbering start value (or offset from regular counteing) is used at the first item of offset,
but have to be reused on following items with no text:start-value -->
<xsl:template name="getItemNumber">
<xsl:param name="listLevel"/>
<xsl:param name="listLevelStyle"/>
<xsl:param name="listStyleName"/>
<xsl:param name="listStyle"/>
<xsl:call-template name="countListItemTillStartValue">
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="preceding::text:list-item[generate-id(key('getListItemsByLevelAndStyle', concat($listLevel, $listStyleName))) = generate-id(key('getListItemsByLevelAndStyle', concat(count(ancestor::text:list), ancestor::text:list/@text:style-name)))]"/>
<xsl:with-param name="precedingListItemsOfSameStyle" select="preceding::text:list-item[generate-id(key('getListItemsByStyle', $listStyleName)) = generate-id(key('getListItemsByStyle', ancestor::text:list/@text:style-name))]"/>
</xsl:call-template>
</xsl:template>
<!-- When there is a text:start-value the last have to be found and added to the number -->
<xsl:template name="countListItemTillStartValue">
<xsl:param name="IteratorSameLevelAndStyle" select="1"/>
<xsl:param name="IteratorSameStyle" select="1"/>
<xsl:param name="itemNumber" select="1"/>
<xsl:param name="listLevel"/>
<xsl:param name="listLevelStyle"/>
<xsl:param name="listStyle"/>
<xsl:param name="listStyleName"/>
<xsl:param name="precedingListItemsOfSameLevelAndStyle" />
<xsl:param name="precedingListItemsOfSameLevelAndStyleCount" select="count($precedingListItemsOfSameLevelAndStyle)"/>
<xsl:param name="precedingListItemsOfSameStyle" />
<xsl:param name="precedingListItemsOfSameStyleCount" select="count($precedingListItemsOfSameStyle)"/>
<!-- E.g.: If a list level 2 number is searched, a level 3 with content found with only a level 1 parent with content,
the level 3 gets a 'pseudoLevel' -->
<xsl:param name="pseudoLevel" select="0" />
<xsl:variable name="isListHeader" select="boolean(self::text:list-header)"/>
<xsl:variable name="isEmptyList" select="not(*[name() = 'text:h' or name() = 'text:p'])"/>
<!-- set the next of preceding list items. Starting from the current to the next previous text:list-item -->
<xsl:variable name="precedingListItemOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle[$precedingListItemsOfSameLevelAndStyleCount - $IteratorSameLevelAndStyle + 1]"/>
<xsl:variable name="precedingListItemOfSameStyle" select="$precedingListItemsOfSameStyle[$precedingListItemsOfSameStyleCount - $IteratorSameStyle + 1]"/>
<xsl:choose>
<xsl:when test="($precedingListItemOfSameStyle and $precedingListItemOfSameLevelAndStyle) or ($precedingListItemOfSameStyle and $listStyle/text:list-style/@text:consecutive-numbering)">
<xsl:for-each select="$precedingListItemOfSameStyle">
<xsl:choose>
<!-- if it is a higher list level element -->
<xsl:when test="$listStyle/text:list-style/@text:consecutive-numbering">
<xsl:call-template name="countListItem">
<xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
<xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
<xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
<xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
<xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- NOT CONSECUTIVE NUMBERING -->
<xsl:variable name="currentListLevel" select="count(ancestor::text:list)"/>
<xsl:choose>
<!-- IF IT IS A HIGHER LIST LEVEL ELEMENT -->
<xsl:when test="$currentListLevel < $listLevel">
<xsl:choose>
<!-- if it has content the counting is ended -->
<xsl:when test="*[name() = 'text:h' or name() = 'text:p'] or $isListHeader">
<!-- 2DO: Perhaps the children still have to be processed -->
<xsl:value-of select="$itemNumber + $pseudoLevel"/>
</xsl:when>
<xsl:otherwise>
<!-- if it is empty the counting continues -->
<xsl:call-template name="countListItemTillStartValue">
<xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
<xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
<xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
<xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
<xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- IF IT IS A LIST LEVEL ELEMENT OF THE COUNTING LEVEL -->
<xsl:when test="$currentListLevel = $listLevel">
<xsl:call-template name="countListItem">
<xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
<xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
<xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
<xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
<xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- list item below the current level does not count -->
<xsl:call-template name="countListItemTillStartValue">
<xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle" />
<xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
<xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
<xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
<xsl:with-param name="pseudoLevel">
<xsl:choose>
<!-- empty list item does not count -->
<xsl:when test="not(*[name() = 'text:h' or name() = 'text:p']) or $isListHeader">
<xsl:value-of select="$pseudoLevel"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$itemNumber"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="countListItem">
<xsl:param name="IteratorSameLevelAndStyle"/>
<xsl:param name="IteratorSameStyle"/>
<xsl:param name="itemNumber"/>
<xsl:param name="listLevel"/>
<xsl:param name="listLevelStyle"/>
<xsl:param name="listStyle"/>
<xsl:param name="listStyleName"/>
<xsl:param name="precedingListItemsOfSameLevelAndStyle"/>
<xsl:param name="precedingListItemsOfSameLevelAndStyleCount"/>
<xsl:param name="precedingListItemsOfSameStyle"/>
<xsl:param name="precedingListItemsOfSameStyleCount"/>
<xsl:param name="pseudoLevel" />
<xsl:variable name="isListHeader" select="boolean(self::text:list-header)"/>
<xsl:variable name="isEmptyList" select="not(*[name() = 'text:h' or name() = 'text:p'])"/>
<xsl:choose>
<xsl:when test="@text:start-value">
<xsl:choose>
<xsl:when test="$isEmptyList or $isListHeader">
<!-- empty list item does not count. neither does list header -->
<xsl:call-template name="countListItemTillStartValue">
<xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
<xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
<xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
<xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
<xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$itemNumber + @text:start-value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$listLevelStyle/@text:start-value">
<xsl:choose>
<xsl:when test="$isEmptyList or $isListHeader">
<!-- empty list item does not count. neither does list header -->
<xsl:call-template name="countListItemTillStartValue">
<xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
<xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
<xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
<xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
<xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$itemNumber + $listLevelStyle/@text:start-value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$isEmptyList or $isListHeader">
<!-- empty list item does not count. neither does list header -->
<xsl:call-template name="countListItemTillStartValue">
<xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
<xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
<xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
<xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
<xsl:with-param name="pseudoLevel" select="$pseudoLevel" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- count on till you find a start-value or the end is reached -->
<xsl:call-template name="countListItemTillStartValue">
<xsl:with-param name="IteratorSameLevelAndStyle" select="$IteratorSameLevelAndStyle + 1" />
<xsl:with-param name="IteratorSameStyle" select="$IteratorSameStyle + 1"/>
<xsl:with-param name="itemNumber" select="$itemNumber + 1"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyle" select="$precedingListItemsOfSameLevelAndStyle"/>
<xsl:with-param name="precedingListItemsOfSameLevelAndStyleCount" select="$precedingListItemsOfSameLevelAndStyleCount"/>
<xsl:with-param name="precedingListItemsOfSameStyle" select="$precedingListItemsOfSameStyle"/>
<xsl:with-param name="precedingListItemsOfSameStyleCount" select="$precedingListItemsOfSameStyleCount"/>
<xsl:with-param name="pseudoLevel" select="0" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Creates the list label containing the number, which is separated by '.' between the levels.
Depending on the levels to display (listLevelsToDisplay) -->
<xsl:template name="createItemLabel">
<xsl:param name="itemLabel" select="''"/>
<xsl:param name="itemNumber" />
<xsl:param name="listLevel" />
<xsl:param name="listLevelStyle" />
<xsl:param name="listLevelsToDisplay" />
<xsl:choose>
<xsl:when test="$listLevelsToDisplay < $listLevel">
<xsl:call-template name="truncLabel">
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="itemNumber" select="$itemNumber" />
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle" />
<xsl:with-param name="listLevelsToDisplay" select="$listLevelsToDisplay"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="numberedSymbol">
<xsl:comment> </xsl:comment>
<!-- only give out a number when number format is not empty -->
<xsl:if test="$listLevelStyle/@style:num-format != ''">
<xsl:number value="$itemNumber" format="{$listLevelStyle/@style:num-format}"/>
</xsl:if>
</xsl:variable>
<xsl:choose>
<xsl:when test="$listLevelsToDisplay != 1">
<xsl:value-of select="concat($itemLabel, '.' , $numberedSymbol)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$numberedSymbol"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="truncLabel">
<xsl:param name="itemLabel" />
<xsl:param name="itemNumber" />
<xsl:param name="listLevel" />
<xsl:param name="listLevelStyle" />
<xsl:param name="listLevelsToDisplay" />
<xsl:param name="listStyle" />
<xsl:param name="listStyleName" />
<xsl:call-template name="createItemLabel">
<xsl:with-param name="itemLabel">
<xsl:if test="contains($itemLabel, '.')">
<xsl:value-of select="substring-after($itemLabel, '.')"/>
</xsl:if>
</xsl:with-param>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listLevel" select="$listLevel - 1"/>
<xsl:with-param name="listLevelStyle" select="$listLevelStyle"/>
<xsl:with-param name="listLevelsToDisplay" select="$listLevelsToDisplay"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="text:p" mode="list-item-children">
<xsl:param name="globalData"/>
<xsl:param name="listLabelElement"/>
<xsl:param name="listLabelEmptyElement"/>
<xsl:param name="isEmptyList"/>
<xsl:param name="isListNumberingReset"/>
<xsl:param name="isNextLevelNumberingReset"/>
<xsl:param name="itemLabel"/>
<xsl:param name="itemNumber"/>
<xsl:param name="listIndent"/>
<xsl:param name="listLevel"/>
<xsl:param name="listRestart"/>
<xsl:param name="listStyle"/>
<xsl:param name="listStyleName"/>
<xsl:param name="minLabelWidth"/>
<!-- 2DO page alignment fix - PART1 -->
<!-- xhtml:p may only contain inline elements.
If there is one frame beyond, div must be used! -->
<xsl:variable name="elementName">
<xsl:choose>
<xsl:when test="descendant::draw:frame[1] or descendant::text:p[1]">div</xsl:when>
<xsl:otherwise>p</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="{$elementName}">
<xsl:call-template name="create-list-style">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="listIndent" select="$listIndent"/>
<xsl:with-param name="styleName" select="@text:style-name"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="$listLabelElement">
<xsl:copy-of select="$listLabelElement"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$listLabelEmptyElement"/>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates>
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="listIndent" select="$minLabelWidth"/>
</xsl:apply-templates>
<!-- this span disables the float necessary to bring two block elements on one line. It contains a space as IE6 bug workaround -->
<span class="odfLiEnd"></span>
<xsl:text> </xsl:text>
</xsl:element>
<xsl:apply-templates mode="list-item-children" select="following-sibling::*[1]">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isEmptyList" select="$isEmptyList"/>
<xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listLabelEmptyElement" select="$listLabelEmptyElement"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listRestart" select="$listRestart"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
<xsl:with-param name="listIndent" select="$listIndent"/>
<xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
</xsl:apply-templates>
</xsl:template>
<!-- Neglecting the left margin behavior for headings for now -->
<xsl:template match="text:h" mode="list-item-children">
<xsl:param name="globalData"/>
<xsl:param name="listLabelElement"/>
<xsl:param name="listLabelEmptyElement"/>
<xsl:param name="isEmptyList"/>
<xsl:param name="isListNumberingReset"/>
<xsl:param name="isNextLevelNumberingReset"/>
<xsl:param name="itemLabel"/>
<xsl:param name="itemNumber"/>
<xsl:param name="listIndent"/>
<xsl:param name="listLevel"/>
<xsl:param name="listRestart"/>
<xsl:param name="listStyle"/>
<xsl:param name="listStyleName"/>
<xsl:param name="minLabelWidth"/>
<xsl:element name="h">
<xsl:call-template name="create-list-style">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="listIndent" select="$listIndent"/>
<xsl:with-param name="styleName" select="@text:style-name"/>
</xsl:call-template>
<xsl:variable name="title">
<xsl:apply-templates mode="concatenate"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$listLabelElement">
<xsl:copy-of select="$listLabelElement"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$listLabelEmptyElement"/>
</xsl:otherwise>
</xsl:choose>
<!-- REFERENCE HANDLING - ANCHOR -->
<xsl:element namespace="{$namespace}" name="a">
<xsl:attribute name="id">
<xsl:value-of select="translate(concat('a_',$listLabelElement, '_', normalize-space($title)), '
&<>.,;: %()[]/\+', '___________________________')"/>
</xsl:attribute>
<xsl:apply-templates>
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="listIndent" select="$minLabelWidth"/>
</xsl:apply-templates>
</xsl:element>
<!-- this span disables the float necessary to bring two block elements on one line. It contains a space as IE6 bug workaround -->
<span class="odfLiEnd"></span>
<xsl:text> </xsl:text>
</xsl:element>
<xsl:apply-templates mode="list-item-children" select="following-sibling::*[1]">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isEmptyList" select="$isEmptyList"/>
<xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listLabelEmptyElement" select="$listLabelEmptyElement"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listRestart" select="$listRestart"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
<xsl:with-param name="listIndent" select="$listIndent"/>
<xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*" mode="list-item-children">
<xsl:param name="globalData"/>
<xsl:param name="isEmptyList"/>
<xsl:param name="listLabelEmptyElement"/>
<xsl:param name="isListNumberingReset"/>
<xsl:param name="isNextLevelNumberingReset"/>
<xsl:param name="itemLabel"/>
<xsl:param name="itemNumber"/>
<xsl:param name="listIndent"/>
<xsl:param name="listLevel"/>
<xsl:param name="listRestart"/>
<xsl:param name="listStyle"/>
<xsl:param name="listStyleName"/>
<xsl:param name="minLabelWidth"/>
<xsl:apply-templates select="self::*">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isEmptyList" select="$isEmptyList"/>
<xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="listLabelEmptyElement" select="$listLabelEmptyElement"/>
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listIndent" select="$listIndent"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listRestart" select="$listRestart"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
</xsl:apply-templates>
<xsl:apply-templates mode="list-item-children" select="following-sibling::*[1]">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isEmptyList" select="$isEmptyList"/>
<xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listLabelEmptyElement" select="$listLabelEmptyElement"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listRestart" select="$listRestart"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
<xsl:with-param name="listIndent" select="$listIndent"/>
<xsl:with-param name="minLabelWidth" select="$minLabelWidth"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*" mode="listItemSibling">
<xsl:param name="globalData"/>
<xsl:param name="isEmptyList"/>
<xsl:param name="isListNumberingReset"/>
<xsl:param name="isNextLevelNumberingReset"/>
<xsl:param name="itemLabel"/>
<xsl:param name="itemNumber"/>
<xsl:param name="listIndent"/>
<xsl:param name="listLevel"/>
<xsl:param name="listRestart"/>
<xsl:param name="listStyle"/>
<xsl:param name="listStyleName"/>
<xsl:apply-templates select="self::*">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isEmptyList" select="$isEmptyList"/>
<xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listIndent" select="$listIndent"/>
<!-- receives the same parent label, only with a different itemNumber -->
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
</xsl:apply-templates>
<xsl:apply-templates select="following-sibling::*[1]" mode="listItemSibling">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="isEmptyList" select="$isEmptyList"/>
<xsl:with-param name="isListNumberingReset" select="$isListNumberingReset"/>
<xsl:with-param name="isNextLevelNumberingReset" select="$isNextLevelNumberingReset"/>
<xsl:with-param name="itemNumber" select="$itemNumber"/>
<xsl:with-param name="listIndent" select="$listIndent"/>
<!-- receives the same parent label, only with a different itemNumber -->
<xsl:with-param name="itemLabel" select="$itemLabel"/>
<xsl:with-param name="listLevel" select="$listLevel"/>
<xsl:with-param name="listStyle" select="$listStyle"/>
<xsl:with-param name="listStyleName" select="$listStyleName"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="text()" mode="list-item-children">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template name="create-list-style">
<xsl:param name="globalData"/>
<xsl:param name="listIndent" select="0"/>
<xsl:param name="styleName"/>
<xsl:if test="$styleName">
<xsl:attribute name="class">
<xsl:value-of select="translate($styleName, '.,;: %()[]/\+', '_____________')"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="style">
<xsl:text>margin-</xsl:text>
<xsl:call-template name="getOppositeWritingDirection">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="paraStyleName" select="descendant-or-self::*/@text:style-name"/>
</xsl:call-template>
<xsl:text>:</xsl:text>
<xsl:value-of select="$listIndent"/>
<xsl:text>cm;</xsl:text>
</xsl:attribute>
</xsl:template>
<!-- ********************************************** -->
<!-- *** Text Section (contains: draw:text-box) *** -->
<!-- ********************************************** -->
<xsl:template match="text:section">
<xsl:param name="globalData"/>
<xsl:if test="not(contains(@text:display, 'none'))">
<xsl:comment>Next 'div' was a 'text:section'.</xsl:comment>
<xsl:element name="div">
<xsl:call-template name="apply-styles-and-content">
<xsl:with-param name="globalData" select="$globalData"/>
</xsl:call-template>
</xsl:element>
</xsl:if>
</xsl:template>
<!-- Hidden text dependend on Office variables:
The text is not shown, if condition is 'true'.
Implemented solely for conditons as '<VARIABLE>==0' or '<VARIABLE>==1'
-->
<xsl:key match="text:variable-set" name="varSet" use="@text:name"/>
<xsl:template match="text:hidden-text">
<xsl:param name="globalData"/>
<xsl:variable name="varName" select="substring-before(@text:condition, '==')"/>
<xsl:variable name="varValue" select="substring-after(@text:condition, '==')"/>
<xsl:choose>
<xsl:when test="key('varSet', $varName)/@text:value != $varValue">
<xsl:value-of select="@text:string-value"/>
</xsl:when>
<xsl:otherwise>
<xsl:comment>
<xsl:value-of select="$varName"/>
<xsl:value-of select="@text:string-value"/>
<xsl:value-of select="$varName"/>
</xsl:comment>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name-->
<xsl:param name="globalData"/>
<xsl:attribute name="class">
<xsl:value-of select="translate(., '.,;: %()[]/\+', '_____________')"/>
</xsl:attribute>
</xsl:template>
<!-- ***************** -->
<!-- *** Footnotes *** -->
<!-- ***************** -->
<xsl:template match="text:note">
<xsl:param name="globalData"/>
<!-- get style configuration -->
<xsl:variable name="footnoteConfig" select="$globalData/office:styles/text:notes-configuration[@text:note-class=current()/@text:note-class]" />
<xsl:variable name="titlePrefix">
<xsl:choose>
<xsl:when test="@text:note-class = 'footnote'">
<xsl:text>Footnote: </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Endnote: </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- write anchor -->
<xsl:element name="span">
<xsl:attribute name="class">
<xsl:value-of select="$footnoteConfig/@text:citation-body-style-name"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="$titlePrefix"/>
<xsl:apply-templates mode="textOnly" select="text:note-body"/>
</xsl:attribute>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="concat('#', @text:id)"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="concat('body_', @text:id)"/>
</xsl:attribute>
<xsl:apply-templates mode="textOnly" select="text:note-citation"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="*" mode="textOnly">
<xsl:apply-templates select="* | text()" mode="textOnly" />
</xsl:template>
<xsl:template match="text()" mode="textOnly">
<xsl:value-of select="."/>
</xsl:template>
<!-- Useful in case of 'style:map', conditional formatting, where a style references to another -->
<xsl:key name="textNotes" match="text:note" use="@text:note-class"/>
<!-- writing the footer- and endnotes beyond the body -->
<xsl:template name="write-text-nodes">
<xsl:param name="globalData"/>
<!-- write footnote body -->
<xsl:for-each select="key('textNotes', 'footnote')">
<xsl:call-template name="write-text-node">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="footnoteConfig" select="$globalData/office:styles/text:notes-configuration[@text:note-class=current()/@text:note-class]" />
</xsl:call-template>
</xsl:for-each>
<!-- write endnote body -->
<xsl:for-each select="key('textNotes', 'endnote')">
<xsl:call-template name="write-text-node">
<xsl:with-param name="globalData" select="$globalData"/>
<xsl:with-param name="footnoteConfig" select="$globalData/office:styles/text:notes-configuration[@text:note-class=current()/@text:note-class]" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="write-text-node">
<xsl:param name="globalData"/>
<xsl:param name="footnoteConfig"/>
<xsl:apply-templates select="text:note-body/*[1]">
<xsl:with-param name="globalData" select="$globalData" />
<xsl:with-param name="footnotePrefix">
<xsl:element name="span">
<xsl:attribute name="class">footnodeNumber</xsl:attribute>
<xsl:element name="a">
<xsl:attribute name="class">
<xsl:value-of select="$footnoteConfig/@text:citation-style-name"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="@text:id"/>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="concat('#body_', @text:id)"/>
</xsl:attribute>
<xsl:apply-templates mode="textOnly" select="text:note-citation"/>
</xsl:element>
</xsl:element>
</xsl:with-param>
</xsl:apply-templates>
<xsl:apply-templates select="text:note-body/*[position()>1]">
<xsl:with-param name="globalData" select="$globalData" />
</xsl:apply-templates>
</xsl:template>
<!-- ***************** -->
<!-- *** Bookmarks *** -->
<!-- ***************** -->
<xsl:template match="text:bookmark|text:bookmark-start">
<xsl:element name="a">
<xsl:attribute name="name">
<xsl:value-of select="@text:name"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="text:bookmark-end"/>
<!-- DISABLING this tab handling as the tab width is only relative
<xsl:template match="text:tab">
<xsl:param name="globalData"/>
<xsl:variable name="tabNo">
<xsl:choose>
<xsl:when test="preceding-sibling::text:line-break">
<xsl:call-template name="countTextTab"/>
</xsl:when>
<xsl:when test="preceding-sibling::text:tab">
<xsl:value-of select="count(preceding-sibling::text:tab)"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="span">
<xsl:attribute name="style">margin-left:<xsl:value-of select="$globalData/all-doc-styles/style[@style:name = current()/parent::*/@text:style-name]/*/style:tab-stops/style:tab-stop[$tabNo]/@style:position"/>;</xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template name="countTextTab">
<xsl:param name="tabCount" select="1"/>
<xsl:param name="context" select="."/>
<xsl:choose>
<xsl:when test="preceding-sibling::*[1]">
<xsl:for-each select="preceding-sibling::*[1]">
<xsl:call-template name="countTextTab">
<xsl:with-param name="tabCout">
<xsl:choose>
<xsl:when test="name(.) = 'text:tab'">
<xsl:value-of select="$tabCount + 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$tabCount"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="context" select="preceding-sibling::*[1]" />
</xsl:call-template>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$tabCount"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-->
<!-- MathML -->
<xsl:template match="draw:object[math:math]">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<xsl:apply-templates select="math:math/math:semantics/*" mode="math"/>
</math>
</xsl:template>
<xsl:template match="*" mode="math">
<xsl:element name="{local-name()}" namespace="http://www.w3.org/1998/Math/MathML">
<xsl:apply-templates select="@*|node()" mode="math"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*" mode="math">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
<xsl:template match="math:annotation" mode="math"/>
</xsl:stylesheet>
|