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 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <string_view>
#include <hintids.hxx>
#include <comphelper/string.hxx>
#include <vcl/svapp.hxx>
#include <svl/whiter.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/crossedoutitem.hxx>
#include <editeng/blinkitem.hxx>
#include <editeng/cmapitem.hxx>
#include <editeng/colritem.hxx>
#include <editeng/fontitem.hxx>
#include <editeng/fhgtitem.hxx>
#include <editeng/postitem.hxx>
#include <editeng/kernitem.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/lspcitem.hxx>
#include <editeng/adjustitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/formatbreakitem.hxx>
#include <editeng/keepitem.hxx>
#include <editeng/widwitem.hxx>
#include <editeng/spltitem.hxx>
#include <editeng/orphitem.hxx>
#include <editeng/charhiddenitem.hxx>
#include <svx/xoutbmp.hxx>
#include <svx/svdobj.hxx>
#include <editeng/langitem.hxx>
#include <editeng/frmdiritem.hxx>
#include <svtools/htmlout.hxx>
#include <svtools/htmlkywd.hxx>
#include <svl/urihelper.hxx>
#include <unotools/charclass.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <charfmt.hxx>
#include <fmtclds.hxx>
#include <fmtcol.hxx>
#include <fmtfsize.hxx>
#include <fmtornt.hxx>
#include <fmtpdsc.hxx>
#include <fmtlsplt.hxx>
#include <pagedesc.hxx>
#include <fmtanchr.hxx>
#include <docary.hxx>
#include <pam.hxx>
#include <viewsh.hxx>
#include <viewopt.hxx>
#include <swtable.hxx>
// NOTES
#include <ftninfo.hxx>
#include <ftnidx.hxx>
#include <txtftn.hxx>
#include <fmtftn.hxx>
// FOOTNOTES
#include <doc.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <swerror.h>
#include <paratr.hxx>
#include <frmatr.hxx>
#include <poolfmt.hxx>
#include "css1kywd.hxx"
#include "wrthtml.hxx"
#include "htmlnum.hxx"
#include "css1atr.hxx"
#include <IDocumentStylePoolAccess.hxx>
#include <numrule.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <o3tl/unit_conversion.hxx>
#include <rtl/strbuf.hxx>
#include <osl/diagnose.h>
using namespace css;
using editeng::SvxBorderLine;
#define HTML_HEADSPACE (12*20)
namespace {
enum class Css1FrameSize {
NONE = 0x00,
Width = 0x01,
MinHeight = 0x02,
FixHeight = 0x04,
Pixel = 0x10,
};
}
namespace o3tl {
template<> struct typed_flags<Css1FrameSize> : is_typed_flags<Css1FrameSize, 0x17> {};
}
#define DOT_LEADERS_MAX_WIDTH 18
static Writer& OutCSS1_SwFormat( Writer& rWrt, const SwFormat& rFormat,
IDocumentStylePoolAccess /*SwDoc*/ *pDoc, SwDoc *pTemplate );
static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rFormat,
IDocumentStylePoolAccess /*SwDoc*/ *pDoc, SwDoc *pTemplate,
sal_uInt16 nRefPoolId, bool bExtRef,
bool bPseudo=true );
static Writer& OutCSS1_SwFootnoteInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
SwDoc *pDoc, bool bHasNotes, bool bEndNote );
static void OutCSS1_SwFormatDropAttrs( SwHTMLWriter& rHWrt,
const SwFormatDrop& rDrop,
const SfxItemSet *pCharFormatItemSet=nullptr );
static Writer& OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( Writer& rWrt,
const SvxUnderlineItem *pUItem,
const SvxOverlineItem *pOItem,
const SvxCrossedOutItem *pCOItem,
const SvxBlinkItem *pBItem );
static Writer& OutCSS1_SvxFontWeight( Writer& rWrt, const SfxPoolItem& rHt );
static Writer& OutCSS1_SvxPosture( Writer& rWrt, const SfxPoolItem& rHt );
static Writer& OutCSS1_SvxULSpace( Writer& rWrt, const SfxPoolItem& rHt );
static Writer& OutCSS1_SvxLRSpace( Writer& rWrt, const SfxPoolItem& rHt );
static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
const SvxULSpaceItem *pULSpace,
const SvxLRSpaceItem *pLRSpace );
static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
const SfxItemSet& rItemSet );
static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
sw::Css1Background nMode,
const OUString *pGraphicName );
static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt );
static Writer& OutCSS1_SwFormatFrameSize( Writer& rWrt, const SfxPoolItem& rHt,
Css1FrameSize nMode );
static Writer& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( Writer& rWrt,
const SfxItemSet& rItemSet,
bool bDeep );
static Writer& OutCSS1_SwFormatLayoutSplit( Writer& rWrt, const SfxPoolItem& rHt );
namespace
{
const char sCSS1_rule_end[] = " }";
const char sCSS1_span_tag_end[] = "\">";
const char cCSS1_style_opt_end = '\"';
const char* const sHTML_FTN_fontheight = "57%";
OString lclConvToHex(sal_uInt16 nHex)
{
char aNToABuf[] = "00";
// set pointer to end of buffer
char *pStr = aNToABuf + (sizeof(aNToABuf)-1);
for( sal_uInt8 n = 0; n < 2; ++n )
{
*(--pStr) = static_cast<char>(nHex & 0xf ) + 48;
if( *pStr > '9' )
*pStr += 39;
nHex >>= 4;
}
return OString(aNToABuf, 2);
}
}
bool IgnorePropertyForReqIF(bool bReqIF, std::string_view rProperty, std::string_view rValue,
std::optional<sw::Css1Background> oMode)
{
if (!bReqIF)
return false;
if (oMode.has_value() && *oMode != sw::Css1Background::TableCell)
{
// Table or row.
if (rProperty == sCSS1_P_background && rValue == "transparent")
{
// This is the default already.
return true;
}
return false;
}
// Only allow these two keys, nothing else in ReqIF mode.
if (rProperty == sCSS1_P_text_decoration)
{
// Deny other text-decoration values (e.g. "none").
if (rValue == "underline" || rValue == "line-through")
{
return false;
}
return true;
}
if (rProperty == sCSS1_P_color)
return false;
return true;
}
OString GetCSS1_Color(const Color& rColor)
{
return "#" + lclConvToHex(rColor.GetRed()) + lclConvToHex(rColor.GetGreen()) + lclConvToHex(rColor.GetBlue());
}
namespace {
class SwCSS1OutMode
{
SwHTMLWriter& rWrt;
sal_uInt16 nOldMode;
public:
SwCSS1OutMode( SwHTMLWriter& rHWrt, sal_uInt16 nMode,
const OUString *pSelector ) :
rWrt( rHWrt ),
nOldMode( rHWrt.m_nCSS1OutMode )
{
rWrt.m_nCSS1OutMode = nMode;
rWrt.m_bFirstCSS1Property = true;
if( pSelector )
rWrt.m_aCSS1Selector = *pSelector;
}
~SwCSS1OutMode()
{
rWrt.m_nCSS1OutMode = nOldMode;
}
};
}
void SwHTMLWriter::OutCSS1_Property( const char *pProp,
std::string_view sVal,
const OUString *pSVal,
std::optional<sw::Css1Background> oMode )
{
OString aPropertyValue(sVal);
if (aPropertyValue.isEmpty() && pSVal)
{
aPropertyValue = pSVal->toUtf8();
}
if (IgnorePropertyForReqIF(mbReqIF, pProp, aPropertyValue, oMode))
return;
OStringBuffer sOut;
if( m_bFirstCSS1Rule && (m_nCSS1OutMode & CSS1_OUTMODE_RULE_ON)!=0 )
{
m_bFirstCSS1Rule = false;
OutNewLine();
sOut.append("<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_style " "
OOO_STRING_SVTOOLS_HTML_O_type "=\"text/css\">");
// Optional CSS2 code for dot leaders (dotted line between the Table of Contents titles and page numbers):
// (More information: http://www.w3.org/Style/Examples/007/leaders.en.html)
//
// p.leaders {
// /* FIXME:
// (1) dots line up vertically only in the paragraphs with the same alignment/level
// (2) max-width = 18 cm instead of 80em; possible improvement with the new CSS3 calc() */
// max-width: 18cm; /* note: need to overwrite max-width with max-width - border-left_of_the_actual_paragraph */
// padding: 0;
// overflow-x: hidden;
// line-height: 120%; /* note: avoid HTML scrollbars and missing descenders of the letters */
// }
// p.leaders:after {
// float: left;
// width: 0;
// white-space: nowrap;
// content: ". . . . . . . . . . . . . . . . . . ...";
// }
// p.leaders span:first-child {
// padding-right: 0.33em;
// background: white;
// }
// p.leaders span + span {
// float: right;
// padding-left: 0.33em;
// background: white;
// position: relative;
// z-index: 1
// }
if (m_bCfgPrintLayout) {
sOut.append(
"p." sCSS2_P_CLASS_leaders "{max-width:" + OString::number(DOT_LEADERS_MAX_WIDTH) +
"cm;padding:0;overflow-x:hidden;line-height:120%}"
"p." sCSS2_P_CLASS_leaders ":after{float:left;width:0;white-space:nowrap;content:\"");
for (int i = 0; i < 100; i++ )
sOut.append(". ");
sOut.append(
"\"}p." sCSS2_P_CLASS_leaders " span:first-child{padding-right:0.33em;background:white}"
"p." sCSS2_P_CLASS_leaders " span+span{float:right;padding-left:0.33em;"
"background:white;position:relative;z-index:1}");
}
Strm().WriteOString( sOut.makeStringAndClear() );
IncIndentLevel();
}
if( m_bFirstCSS1Property )
{
switch( m_nCSS1OutMode & CSS1_OUTMODE_ANY_ON )
{
case CSS1_OUTMODE_SPAN_TAG_ON:
case CSS1_OUTMODE_SPAN_TAG1_ON:
if( m_bTagOn )
{
sOut.append("<" + GetNamespace() + OOO_STRING_SVTOOLS_HTML_span
" " OOO_STRING_SVTOOLS_HTML_O_style "=\"");
}
else
{
HTMLOutFuncs::Out_AsciiTag( Strm(), OStringConcatenation(GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false );
return;
}
break;
case CSS1_OUTMODE_RULE_ON:
{
OutNewLine();
sOut.append(OUStringToOString(m_aCSS1Selector, RTL_TEXTENCODING_UTF8) + " { ");
}
break;
case CSS1_OUTMODE_STYLE_OPT_ON:
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_style "=\"");
break;
}
m_bFirstCSS1Property = false;
}
else
{
sOut.append("; ");
}
sOut.append(pProp + OString::Concat(": "));
if( m_nCSS1OutMode & CSS1_OUTMODE_ENCODE )
{
// for STYLE-Option encode string
Strm().WriteOString( sOut.makeStringAndClear() );
if( !sVal.empty() )
HTMLOutFuncs::Out_String( Strm(), OUString::createFromAscii(sVal) );
else if( pSVal )
HTMLOutFuncs::Out_String( Strm(), *pSVal );
}
else
{
// for STYLE-Tag print string directly
if( !sVal.empty() )
sOut.append(sVal);
else if( pSVal )
sOut.append(OUStringToOString(*pSVal, RTL_TEXTENCODING_UTF8));
}
if (!sOut.isEmpty())
Strm().WriteOString( sOut.makeStringAndClear() );
}
static void AddUnitPropertyValue(OStringBuffer &rOut, tools::Long nVal,
FieldUnit eUnit)
{
if( nVal < 0 )
{
// special-case sign symbol
nVal = -nVal;
rOut.append('-');
}
o3tl::Length eTo;
int nFac; // used to get specific number of decimals
const char *pUnit;
switch( eUnit )
{
case FieldUnit::MM_100TH:
OSL_ENSURE( FieldUnit::MM == eUnit, "Measuring unit not supported" );
[[fallthrough]];
case FieldUnit::MM:
eTo = o3tl::Length::mm;
nFac = 100;
pUnit = sCSS1_UNIT_mm;
break;
case FieldUnit::M:
case FieldUnit::KM:
OSL_ENSURE( FieldUnit::CM == eUnit, "Measuring unit not supported" );
[[fallthrough]];
case FieldUnit::CM:
eTo = o3tl::Length::cm;
nFac = 100;
pUnit = sCSS1_UNIT_cm;
break;
case FieldUnit::TWIP:
OSL_ENSURE( FieldUnit::POINT == eUnit, "Measuring unit not supported" );
[[fallthrough]];
case FieldUnit::POINT:
eTo = o3tl::Length::pt;
nFac = 10;
pUnit = sCSS1_UNIT_pt;
break;
case FieldUnit::PICA:
eTo = o3tl::Length::pc;
nFac = 100;
pUnit = sCSS1_UNIT_pc;
break;
case FieldUnit::NONE:
case FieldUnit::FOOT:
case FieldUnit::MILE:
case FieldUnit::CUSTOM:
case FieldUnit::PERCENT:
case FieldUnit::INCH:
default:
OSL_ENSURE( FieldUnit::INCH == eUnit, "Measuring unit not supported" );
eTo = o3tl::Length::in;
nFac = 100;
pUnit = sCSS1_UNIT_inch;
break;
}
sal_Int64 nResult = o3tl::convert(nVal * nFac, o3tl::Length::twip, eTo);
rOut.append(nResult/nFac);
if ((nResult % nFac) != 0)
{
rOut.append('.');
while (nFac > 1 && (nResult % nFac) != 0)
{
nFac /= 10;
rOut.append((nResult / nFac) % 10);
}
}
rOut.append(pUnit);
}
void SwHTMLWriter::OutCSS1_UnitProperty( const char *pProp, tools::Long nVal )
{
OStringBuffer sOut;
AddUnitPropertyValue(sOut, nVal, m_eCSS1Unit);
OutCSS1_PropertyAscii(pProp, sOut.makeStringAndClear());
}
void SwHTMLWriter::OutCSS1_PixelProperty( const char *pProp, tools::Long nVal,
bool bVert )
{
OString sOut(OString::number(ToPixel(nVal,bVert)) + sCSS1_UNIT_px);
OutCSS1_PropertyAscii(pProp, sOut);
}
void SwHTMLWriter::OutStyleSheet( const SwPageDesc& rPageDesc )
{
m_bFirstCSS1Rule = true;
// Feature: PrintExt
if( IsHTMLMode(HTMLMODE_PRINT_EXT) )
{
const SwPageDesc *pFirstPageDesc = nullptr;
sal_uInt16 nFirstRefPoolId = RES_POOLPAGE_HTML;
m_bCSS1IgnoreFirstPageDesc = true;
// First we try to guess how the document is constructed.
// Allowed are only the templates: HTML, 1st page, left page, and right page.
// A first page is only exported, if it matches the template "1st page".
// Left and right pages are only exported, if their templates are linked.
// If other templates are used, only very simple cases are exported.
const SwPageDesc *pPageDesc = &rPageDesc;
const SwPageDesc *pFollow = rPageDesc.GetFollow();
if( RES_POOLPAGE_FIRST == pPageDesc->GetPoolFormatId() &&
pFollow != pPageDesc &&
!IsPoolUserFormat( pFollow->GetPoolFormatId() ) )
{
// the document has a first page
pFirstPageDesc = pPageDesc;
pPageDesc = pFollow;
pFollow = pPageDesc->GetFollow();
}
IDocumentStylePoolAccess* pStylePoolAccess = &getIDocumentStylePoolAccess();
if( pPageDesc == pFollow )
{
// The document is one-sided; no matter what page, we do not create a 2-sided doc.
// The attribute is exported relative to the HTML page template.
OutCSS1_SwPageDesc( *this, *pPageDesc, pStylePoolAccess, m_xTemplate.get(),
RES_POOLPAGE_HTML, true, false );
nFirstRefPoolId = pFollow->GetPoolFormatId();
}
else if( (RES_POOLPAGE_LEFT == pPageDesc->GetPoolFormatId() &&
RES_POOLPAGE_RIGHT == pFollow->GetPoolFormatId()) ||
(RES_POOLPAGE_RIGHT == pPageDesc->GetPoolFormatId() &&
RES_POOLPAGE_LEFT == pFollow->GetPoolFormatId()) )
{
// the document is double-sided
OutCSS1_SwPageDesc( *this, *pPageDesc, pStylePoolAccess, m_xTemplate.get(),
RES_POOLPAGE_HTML, true );
OutCSS1_SwPageDesc( *this, *pFollow, pStylePoolAccess, m_xTemplate.get(),
RES_POOLPAGE_HTML, true );
nFirstRefPoolId = RES_POOLPAGE_RIGHT;
m_bCSS1IgnoreFirstPageDesc = false;
}
// other cases we miss
if( pFirstPageDesc )
OutCSS1_SwPageDesc( *this, *pFirstPageDesc, pStylePoolAccess, m_xTemplate.get(),
nFirstRefPoolId, false );
}
// The text body style has to be exported always (if it is changed compared
// to the template), because it is used as reference for any style
// that maps to <P>, and that's especially the standard style
getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_TEXT, false );
// the Default-TextStyle is not also exported !!
// 0-Style is the Default; is never exported !!
const size_t nTextFormats = m_pDoc->GetTextFormatColls()->size();
for( size_t i = 1; i < nTextFormats; ++i )
{
const SwTextFormatColl* pColl = (*m_pDoc->GetTextFormatColls())[i];
sal_uInt16 nPoolId = pColl->GetPoolFormatId();
if( nPoolId == RES_POOLCOLL_TEXT || m_pDoc->IsUsed( *pColl ) )
OutCSS1_SwFormat( *this, *pColl, &m_pDoc->getIDocumentStylePoolAccess(), m_xTemplate.get() );
}
// the Default-TextStyle is not also exported !!
const size_t nCharFormats = m_pDoc->GetCharFormats()->size();
for( size_t i = 1; i < nCharFormats; ++i )
{
const SwCharFormat *pCFormat = (*m_pDoc->GetCharFormats())[i];
sal_uInt16 nPoolId = pCFormat->GetPoolFormatId();
if( nPoolId == RES_POOLCHR_INET_NORMAL ||
nPoolId == RES_POOLCHR_INET_VISIT ||
m_pDoc->IsUsed( *pCFormat ) )
OutCSS1_SwFormat( *this, *pCFormat, &m_pDoc->getIDocumentStylePoolAccess(), m_xTemplate.get() );
}
bool bHasEndNotes {false};
bool bHasFootNotes {false};
const SwFootnoteIdxs& rIdxs = m_pDoc->GetFootnoteIdxs();
for( auto pIdx : rIdxs )
{
if( pIdx->GetFootnote().IsEndNote() )
{
bHasEndNotes = true;
if (bHasFootNotes)
break;
}
else
{
bHasFootNotes = true;
if (bHasEndNotes)
break;
}
}
OutCSS1_SwFootnoteInfo( *this, m_pDoc->GetFootnoteInfo(), m_pDoc, bHasFootNotes, false );
OutCSS1_SwFootnoteInfo( *this, m_pDoc->GetEndNoteInfo(), m_pDoc, bHasEndNotes, true );
if( !m_bFirstCSS1Rule )
{
DecIndentLevel();
OutNewLine();
HTMLOutFuncs::Out_AsciiTag( Strm(), OStringConcatenation(GetNamespace() + OOO_STRING_SVTOOLS_HTML_style), false );
}
else
{
m_bFirstCSS1Rule = false;
}
m_nDfltTopMargin = 0;
m_nDfltBottomMargin = 0;
}
// if pPseudo is set, Styles-Sheets will be exported;
// otherwise we only search for Token and Class for a Format
sal_uInt16 SwHTMLWriter::GetCSS1Selector( const SwFormat *pFormat, OString& rToken,
OUString& rClass, sal_uInt16& rRefPoolId,
OUString *pPseudo )
{
sal_uInt16 nDeep = 0;
rToken.clear();
rClass.clear();
rRefPoolId = 0;
if( pPseudo )
pPseudo->clear();
bool bChrFormat = RES_CHRFMT==pFormat->Which();
// search formats above for the nearest standard or HTML-Tag template
const SwFormat *pPFormat = pFormat;
while( pPFormat && !pPFormat->IsDefault() )
{
bool bStop = false;
sal_uInt16 nPoolId = pPFormat->GetPoolFormatId();
if( USER_FMT & nPoolId )
{
// user templates
const OUString& aNm(pPFormat->GetName());
if (!bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_blockquote)
{
rRefPoolId = RES_POOLCOLL_HTML_BLOCKQUOTE;
rToken = OString(OOO_STRING_SVTOOLS_HTML_blockquote);
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_citation)
{
rRefPoolId = RES_POOLCHR_HTML_CITATION;
rToken = OString(OOO_STRING_SVTOOLS_HTML_citation);
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_code)
{
rRefPoolId = RES_POOLCHR_HTML_CODE;
rToken = OString(OOO_STRING_SVTOOLS_HTML_code);
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_definstance)
{
rRefPoolId = RES_POOLCHR_HTML_DEFINSTANCE;
rToken = OString(OOO_STRING_SVTOOLS_HTML_definstance);
}
else if (!bChrFormat && (aNm == OOO_STRING_SVTOOLS_HTML_dd ||
aNm == OOO_STRING_SVTOOLS_HTML_dt))
{
sal_uInt16 nDefListLvl = GetDefListLvl(aNm, nPoolId);
// Export the templates DD 1/DT 1,
// but none of their derived templates,
// also not DD 2/DT 2 etc.
if (nDefListLvl)
{
if (pPseudo && (nDeep || (nDefListLvl & 0x0fff) > 1))
{
bStop = true;
}
else if (nDefListLvl & HTML_DLCOLL_DD)
{
rRefPoolId = RES_POOLCOLL_HTML_DD;
rToken = OString(OOO_STRING_SVTOOLS_HTML_dd);
}
else
{
rRefPoolId = RES_POOLCOLL_HTML_DT;
rToken = OString(OOO_STRING_SVTOOLS_HTML_dt);
}
}
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_emphasis)
{
rRefPoolId = RES_POOLCHR_HTML_EMPHASIS;
rToken = OString(OOO_STRING_SVTOOLS_HTML_emphasis);
}
else if (!bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_horzrule)
{
// do not export HR !
bStop = (nDeep==0);
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_keyboard)
{
rRefPoolId = RES_POOLCHR_HTML_KEYBOARD;
rToken = OString(OOO_STRING_SVTOOLS_HTML_keyboard);
}
else if (!bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_listing)
{
// Export Listings as PRE or PRE-derived template
rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
rRefPoolId = RES_POOLCOLL_HTML_PRE;
nDeep = CSS1_FMT_CMPREF;
}
else if (!bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_preformtxt)
{
rRefPoolId = RES_POOLCOLL_HTML_PRE;
rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_sample)
{
rRefPoolId = RES_POOLCHR_HTML_SAMPLE;
rToken = OString(OOO_STRING_SVTOOLS_HTML_sample);
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_strong)
{
rRefPoolId = RES_POOLCHR_HTML_STRONG;
rToken = OString(OOO_STRING_SVTOOLS_HTML_strong);
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_teletype)
{
rRefPoolId = RES_POOLCHR_HTML_TELETYPE;
rToken = OString(OOO_STRING_SVTOOLS_HTML_teletype);
}
else if (bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_variable)
{
rRefPoolId = RES_POOLCHR_HTML_VARIABLE;
rToken = OString(OOO_STRING_SVTOOLS_HTML_variable);
}
else if (!bChrFormat && aNm == OOO_STRING_SVTOOLS_HTML_xmp)
{
// export XMP as PRE (but not the template as Style)
rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
rRefPoolId = RES_POOLCOLL_HTML_PRE;
nDeep = CSS1_FMT_CMPREF;
}
// if a PoolId is set, the Name of the template is that of the related Token
OSL_ENSURE( (rRefPoolId != 0) == (!rToken.isEmpty()),
"Token missing" );
}
else
{
// Pool templates
switch( nPoolId )
{
// paragraph templates
case RES_POOLCOLL_HEADLINE_BASE:
case RES_POOLCOLL_STANDARD:
// do not export this template
bStop = (nDeep==0);
break;
case RES_POOLCOLL_TEXT:
rToken = OString(OOO_STRING_SVTOOLS_HTML_parabreak);
break;
case RES_POOLCOLL_HEADLINE1:
rToken = OString(OOO_STRING_SVTOOLS_HTML_head1);
break;
case RES_POOLCOLL_HEADLINE2:
rToken = OString(OOO_STRING_SVTOOLS_HTML_head2);
break;
case RES_POOLCOLL_HEADLINE3:
rToken = OString(OOO_STRING_SVTOOLS_HTML_head3);
break;
case RES_POOLCOLL_HEADLINE4:
rToken = OString(OOO_STRING_SVTOOLS_HTML_head4);
break;
case RES_POOLCOLL_HEADLINE5:
rToken = OString(OOO_STRING_SVTOOLS_HTML_head5);
break;
case RES_POOLCOLL_HEADLINE6:
rToken = OString(OOO_STRING_SVTOOLS_HTML_head6);
break;
case RES_POOLCOLL_SEND_ADDRESS:
rToken = OString(OOO_STRING_SVTOOLS_HTML_address);
break;
case RES_POOLCOLL_HTML_BLOCKQUOTE:
rToken = OString(OOO_STRING_SVTOOLS_HTML_blockquote);
break;
case RES_POOLCOLL_HTML_PRE:
rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
break;
case RES_POOLCOLL_HTML_DD:
rToken = OString(OOO_STRING_SVTOOLS_HTML_dd);
break;
case RES_POOLCOLL_HTML_DT:
rToken = OString(OOO_STRING_SVTOOLS_HTML_dt);
break;
case RES_POOLCOLL_TABLE:
if( pPseudo )
{
rToken = OOO_STRING_SVTOOLS_HTML_tabledata " "
OOO_STRING_SVTOOLS_HTML_parabreak;
}
else
rToken = OOO_STRING_SVTOOLS_HTML_parabreak;
break;
case RES_POOLCOLL_TABLE_HDLN:
if( pPseudo )
{
rToken = OOO_STRING_SVTOOLS_HTML_tableheader " "
OOO_STRING_SVTOOLS_HTML_parabreak;
}
else
rToken = OString(OOO_STRING_SVTOOLS_HTML_parabreak);
break;
case RES_POOLCOLL_HTML_HR:
// do not export HR !
bStop = (nDeep==0);
break;
case RES_POOLCOLL_FOOTNOTE:
if( !nDeep )
{
rToken = OString(OOO_STRING_SVTOOLS_HTML_parabreak);
rClass = OOO_STRING_SVTOOLS_HTML_sdfootnote;
rRefPoolId = RES_POOLCOLL_TEXT;
nDeep = CSS1_FMT_CMPREF;
}
break;
case RES_POOLCOLL_ENDNOTE:
if( !nDeep )
{
rToken = OString(OOO_STRING_SVTOOLS_HTML_parabreak);
rClass = OOO_STRING_SVTOOLS_HTML_sdendnote;
rRefPoolId = RES_POOLCOLL_TEXT;
nDeep = CSS1_FMT_CMPREF;
}
break;
// character templates
case RES_POOLCHR_HTML_EMPHASIS:
rToken = OString(OOO_STRING_SVTOOLS_HTML_emphasis);
break;
case RES_POOLCHR_HTML_CITATION:
rToken = OString(OOO_STRING_SVTOOLS_HTML_citation);
break;
case RES_POOLCHR_HTML_STRONG:
rToken = OString(OOO_STRING_SVTOOLS_HTML_strong);
break;
case RES_POOLCHR_HTML_CODE:
rToken = OString(OOO_STRING_SVTOOLS_HTML_code);
break;
case RES_POOLCHR_HTML_SAMPLE:
rToken = OString(OOO_STRING_SVTOOLS_HTML_sample);
break;
case RES_POOLCHR_HTML_KEYBOARD:
rToken = OString(OOO_STRING_SVTOOLS_HTML_keyboard);
break;
case RES_POOLCHR_HTML_VARIABLE:
rToken = OString(OOO_STRING_SVTOOLS_HTML_variable);
break;
case RES_POOLCHR_HTML_DEFINSTANCE:
rToken = OString(OOO_STRING_SVTOOLS_HTML_definstance);
break;
case RES_POOLCHR_HTML_TELETYPE:
rToken = OString(OOO_STRING_SVTOOLS_HTML_teletype);
break;
case RES_POOLCHR_INET_NORMAL:
if( pPseudo )
{
rToken = OString(OOO_STRING_SVTOOLS_HTML_anchor);
*pPseudo = OStringToOUString( sCSS1_link, RTL_TEXTENCODING_ASCII_US );
}
break;
case RES_POOLCHR_INET_VISIT:
if( pPseudo )
{
rToken = OString(OOO_STRING_SVTOOLS_HTML_anchor);
*pPseudo = OStringToOUString( sCSS1_visited, RTL_TEXTENCODING_ASCII_US );
}
break;
}
// if a token is set, PoolId contains the related template
if( !rToken.isEmpty() && !rRefPoolId )
rRefPoolId = nPoolId;
}
if( !rToken.isEmpty() || bStop )
{
// stop if a HTML-Tag template was found
break;
}
else
{
// continue otherwise
nDeep++;
pPFormat = pPFormat->DerivedFrom();
}
}
if( !rToken.isEmpty() )
{
// this is a HTML-Tag template
if( !nDeep )
nDeep = CSS1_FMT_ISTAG;
}
else
{
// this is not a HTML-Tag template nor derived from one
nDeep = 0;
}
if( nDeep > 0 && nDeep < CSS1_FMT_SPECIAL )
{
// If the template is derived from a HTML template,
// we export it as <TOKEN>.<CLASS>, otherwise as .<CLASS>.
// <CLASS> is the name of the template after removing all characters
// before and including the first '.'
rClass = pFormat->GetName();
sal_Int32 nPos = rClass.indexOf( '.' );
if( nPos >= 0 && rClass.getLength() > nPos+1 )
{
rClass = rClass.replaceAt( 0, nPos+1, u"" );
}
rClass = GetAppCharClass().lowercase( rClass );
rClass = rClass.replaceAll( ".", "-" );
rClass = rClass.replaceAll( " ", "-" );
rClass = rClass.replaceAll( "_", "-" );
}
return nDeep;
}
static sal_uInt16 GetCSS1Selector( const SwFormat *pFormat, OUString& rSelector,
sal_uInt16& rRefPoolId )
{
OString aToken;
OUString aClass;
OUString aPseudo;
sal_uInt16 nDeep = SwHTMLWriter::GetCSS1Selector( pFormat, aToken, aClass,
rRefPoolId, &aPseudo );
if( nDeep )
{
if( !aToken.isEmpty() )
rSelector = OStringToOUString(aToken, RTL_TEXTENCODING_ASCII_US);
else
rSelector.clear();
if( !aClass.isEmpty() )
rSelector += "." + aClass;
if( !aPseudo.isEmpty() )
rSelector += ":" + aPseudo;
}
return nDeep;
}
const SwFormat *SwHTMLWriter::GetTemplateFormat( sal_uInt16 nPoolFormatId,
IDocumentStylePoolAccess* pTemplate /*SwDoc *pTemplate*/)
{
const SwFormat *pRefFormat = nullptr;
if( pTemplate )
{
OSL_ENSURE( !(USER_FMT & nPoolFormatId),
"No user templates found" );
if( POOLGRP_NOCOLLID & nPoolFormatId )
pRefFormat = pTemplate->GetCharFormatFromPool( nPoolFormatId );
else
pRefFormat = pTemplate->GetTextCollFromPool( nPoolFormatId, false );
}
return pRefFormat;
}
const SwFormat *SwHTMLWriter::GetParentFormat( const SwFormat& rFormat, sal_uInt16 nDeep )
{
OSL_ENSURE( nDeep != USHRT_MAX, "Called GetParent for HTML-template!" );
const SwFormat *pRefFormat = nullptr;
if( nDeep > 0 )
{
// get the pointer for the HTML-Tag template, from which the template is derived
pRefFormat = &rFormat;
for( sal_uInt16 i=nDeep; i>0; i-- )
pRefFormat = pRefFormat->DerivedFrom();
if( pRefFormat && pRefFormat->IsDefault() )
pRefFormat = nullptr;
}
return pRefFormat;
}
bool swhtml_css1atr_equalFontItems( const SfxPoolItem& r1, const SfxPoolItem& r2 )
{
return static_cast<const SvxFontItem &>(r1).GetFamilyName() ==
static_cast<const SvxFontItem &>(r2).GetFamilyName() &&
static_cast<const SvxFontItem &>(r1).GetFamily() ==
static_cast<const SvxFontItem &>(r2).GetFamily();
}
void SwHTMLWriter::SubtractItemSet( SfxItemSet& rItemSet,
const SfxItemSet& rRefItemSet,
bool bSetDefaults,
bool bClearSame,
const SfxItemSet *pRefScriptItemSet )
{
OSL_ENSURE( bSetDefaults || bClearSame,
"SwHTMLWriter::SubtractItemSet: No action for this Flag" );
SfxItemSet aRefItemSet( *rRefItemSet.GetPool(), rRefItemSet.GetRanges() );
aRefItemSet.Set( rRefItemSet );
// compare with the Attr-Set of the template
SfxWhichIter aIter( rItemSet );
sal_uInt16 nWhich = aIter.FirstWhich();
while( nWhich )
{
const SfxPoolItem *pRefItem, *pItem;
bool bItemSet = ( SfxItemState::SET ==
aIter.GetItemState( false, &pItem) );
bool bRefItemSet;
if( pRefScriptItemSet )
{
switch( nWhich )
{
case RES_CHRATR_FONT:
case RES_CHRATR_FONTSIZE:
case RES_CHRATR_LANGUAGE:
case RES_CHRATR_POSTURE:
case RES_CHRATR_WEIGHT:
case RES_CHRATR_CJK_FONT:
case RES_CHRATR_CJK_FONTSIZE:
case RES_CHRATR_CJK_LANGUAGE:
case RES_CHRATR_CJK_POSTURE:
case RES_CHRATR_CJK_WEIGHT:
case RES_CHRATR_CTL_FONT:
case RES_CHRATR_CTL_FONTSIZE:
case RES_CHRATR_CTL_LANGUAGE:
case RES_CHRATR_CTL_POSTURE:
case RES_CHRATR_CTL_WEIGHT:
bRefItemSet = ( SfxItemState::SET ==
pRefScriptItemSet->GetItemState( nWhich, true, &pRefItem) );
break;
default:
bRefItemSet = ( SfxItemState::SET ==
aRefItemSet.GetItemState( nWhich, false, &pRefItem) );
break;
}
}
else
{
bRefItemSet = ( SfxItemState::SET ==
aRefItemSet.GetItemState( nWhich, false, &pRefItem) );
}
if( bItemSet )
{
if( (bClearSame || pRefScriptItemSet) && bRefItemSet &&
( *pItem == *pRefItem ||
((RES_CHRATR_FONT == nWhich ||
RES_CHRATR_CJK_FONT == nWhich ||
RES_CHRATR_CTL_FONT == nWhich) &&
swhtml_css1atr_equalFontItems( *pItem, *pRefItem )) ) )
{
// the Attribute is in both templates with the same value
// and does not need to be exported
rItemSet.ClearItem( nWhich );
}
}
else
{
if( (bSetDefaults || pRefScriptItemSet) && bRefItemSet )
{
// the Attribute exists only in the reference; the default
// might have to be exported
rItemSet.Put( rItemSet.GetPool()->GetDefaultItem(nWhich) );
}
}
nWhich = aIter.NextWhich();
}
}
void SwHTMLWriter::PrepareFontList( const SvxFontItem& rFontItem,
OUString& rNames,
sal_Unicode cQuote, bool bGeneric )
{
rNames.clear();
const OUString& rName = rFontItem.GetFamilyName();
bool bContainsKeyword = false;
if( !rName.isEmpty() )
{
sal_Int32 nStrPos = 0;
while( nStrPos != -1 )
{
OUString aName = rName.getToken( 0, ';', nStrPos );
aName = comphelper::string::strip(aName, ' ');
if( aName.isEmpty() )
continue;
bool bIsKeyword = false;
switch( aName[0] )
{
case 'c':
case 'C':
bIsKeyword = aName.equalsIgnoreAsciiCaseAscii( sCSS1_PV_cursive );
break;
case 'f':
case 'F':
bIsKeyword = aName.equalsIgnoreAsciiCaseAscii( sCSS1_PV_fantasy );
break;
case 'm':
case 'M':
bIsKeyword = aName.equalsIgnoreAsciiCaseAscii( sCSS1_PV_monospace );
break;
case 's':
case 'S':
bIsKeyword =
aName.equalsIgnoreAsciiCaseAscii( sCSS1_PV_serif ) ||
aName.equalsIgnoreAsciiCaseAscii( sCSS1_PV_sans_serif );
break;
}
bContainsKeyword |= bIsKeyword;
if( !rNames.isEmpty() )
rNames += ", ";
if( cQuote && !bIsKeyword )
rNames += OUStringChar( cQuote );
rNames += aName;
if( cQuote && !bIsKeyword )
rNames += OUStringChar( cQuote );
}
}
if( bContainsKeyword || !bGeneric )
return;
const char *pStr = nullptr;
switch( rFontItem.GetFamily() )
{
case FAMILY_ROMAN: pStr = sCSS1_PV_serif; break;
case FAMILY_SWISS: pStr = sCSS1_PV_sans_serif; break;
case FAMILY_SCRIPT: pStr = sCSS1_PV_cursive; break;
case FAMILY_DECORATIVE: pStr = sCSS1_PV_fantasy; break;
case FAMILY_MODERN: pStr = sCSS1_PV_monospace; break;
default:
;
}
if( pStr )
{
if( !rNames.isEmpty() )
rNames += ", ";
rNames += OStringToOUString( pStr, RTL_TEXTENCODING_ASCII_US );
}
}
bool SwHTMLWriter::HasScriptDependentItems( const SfxItemSet& rItemSet,
bool bCheckDropCap )
{
static const sal_uInt16 aWhichIds[] =
{
RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT,
RES_CHRATR_FONTSIZE, RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CTL_FONTSIZE,
RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
RES_CHRATR_POSTURE, RES_CHRATR_CJK_POSTURE, RES_CHRATR_CTL_POSTURE,
RES_CHRATR_WEIGHT, RES_CHRATR_CJK_WEIGHT, RES_CHRATR_CTL_WEIGHT,
0, 0, 0
};
for( int i=0; aWhichIds[i]; i += 3 )
{
const SfxPoolItem *pItem = nullptr, *pItemCJK = nullptr, *pItemCTL = nullptr, *pTmp;
int nItemCount = 0;
if( SfxItemState::SET == rItemSet.GetItemState( aWhichIds[i], false,
&pTmp ) )
{
pItem = pTmp;
nItemCount++;
}
if( SfxItemState::SET == rItemSet.GetItemState( aWhichIds[i+1], false,
&pTmp ) )
{
pItemCJK = pTmp;
nItemCount++;
}
if( SfxItemState::SET == rItemSet.GetItemState( aWhichIds[i+2], false,
&pTmp ) )
{
pItemCTL = pTmp;
nItemCount++;
}
// If some of the items are set, but not all, we need script dependent
// styles
if( nItemCount > 0 && nItemCount < 3 )
return true;
if( 3 == nItemCount )
{
// If all items are set, but some of them have different values,
// we need script dependent styles, too. For font items, we have
// to take care about their special HTML/CSS1 representation.
if( RES_CHRATR_FONT == aWhichIds[i] )
{
if( !swhtml_css1atr_equalFontItems( *pItem, *pItemCJK ) ||
!swhtml_css1atr_equalFontItems( *pItem, *pItemCTL ) ||
!swhtml_css1atr_equalFontItems( *pItemCJK, *pItemCTL ) )
return true;
}
else
{
if( *pItem != *pItemCJK ||
*pItem != *pItemCTL ||
*pItemCJK != *pItemCTL )
return true;
}
}
}
const SwFormatDrop *pDrop;
if( bCheckDropCap &&
(pDrop = rItemSet.GetItemIfSet( RES_PARATR_DROP )) )
{
const SwCharFormat *pDCCharFormat = pDrop->GetCharFormat();
if( pDCCharFormat )
{
//sequence of (start, end) property ranges we want to
//query
SfxItemSetFixed<
RES_CHRATR_FONT, RES_CHRATR_FONT,
RES_CHRATR_POSTURE, RES_CHRATR_POSTURE,
RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT,
RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
RES_CHRATR_CJK_POSTURE, RES_CHRATR_CTL_FONT,
RES_CHRATR_CTL_POSTURE, RES_CHRATR_CTL_WEIGHT>
aTstItemSet(*pDCCharFormat->GetAttrSet().GetPool());
aTstItemSet.Set( pDCCharFormat->GetAttrSet() );
return HasScriptDependentItems( aTstItemSet, false );
}
}
return false;
}
static bool OutCSS1Rule( SwHTMLWriter& rHTMLWrt, const OUString& rSelector,
const SfxItemSet& rItemSet, bool bHasClass,
bool bCheckForPseudo )
{
bool bScriptDependent = false;
if( SwHTMLWriter::HasScriptDependentItems( rItemSet, bHasClass ) )
{
bScriptDependent = true;
std::u16string_view aSelector( rSelector );
std::u16string_view aPseudo;
if( bCheckForPseudo )
{
size_t nPos = aSelector.rfind( ':' );
if( nPos != std::u16string_view::npos )
{
aPseudo = aSelector.substr( nPos );
aSelector =aSelector.substr( 0, nPos );
}
}
if( !bHasClass )
{
// If we are exporting styles for a tag we have to export a tag
// rule for all properties that aren't style dependent and
// some class rule for the additional style dependen properties
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_NO_SCRIPT|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&rSelector );
rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
}
//sequence of (start, end) property ranges we want to
//query
SfxItemSetFixed<RES_CHRATR_FONT, RES_CHRATR_FONTSIZE,
RES_CHRATR_LANGUAGE, RES_CHRATR_POSTURE,
RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT,
RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_WEIGHT>
aScriptItemSet( *rItemSet.GetPool() );
aScriptItemSet.Put( rItemSet );
OUString aNewSelector = OUString::Concat(aSelector) + ".western" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
rHTMLWrt.OutCSS1_SfxItemSet( aScriptItemSet, false );
}
aNewSelector = OUString::Concat(aSelector) + ".cjk" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
rHTMLWrt.OutCSS1_SfxItemSet( aScriptItemSet, false );
}
aNewSelector = OUString::Concat(aSelector) + ".ctl" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
rHTMLWrt.OutCSS1_SfxItemSet( aScriptItemSet, false );
}
}
else
{
// If there are script dependencies and we are derived from a tag,
// when we have to export a style dependent class for all
// scripts
OUString aNewSelector = OUString::Concat(aSelector) + "-western" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
}
aNewSelector = OUString::Concat(aSelector) + "-cjk" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
}
aNewSelector = OUString::Concat(aSelector) + "-ctl" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aNewSelector );
rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
}
}
}
else
{
// If there are no script dependencies, when all items are
// exported in one step. For hyperlinks only, a script information
// must be there, because these two chr formats don't support
// script dependencies by now.
SwCSS1OutMode aMode( rHTMLWrt,
rHTMLWrt.m_nCSS1Script|CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&rSelector );
rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
}
return bScriptDependent;
}
static void OutCSS1DropCapRule(
SwHTMLWriter& rHTMLWrt, const OUString& rSelector,
const SwFormatDrop& rDrop, bool bHasClass,
bool bHasScriptDependencies )
{
const SwCharFormat *pDCCharFormat = rDrop.GetCharFormat();
if( (bHasScriptDependencies && bHasClass) ||
(pDCCharFormat && SwHTMLWriter::HasScriptDependentItems( pDCCharFormat->GetAttrSet(), false ) ) )
{
std::u16string_view aSelector( rSelector );
std::u16string_view aPseudo;
size_t nPos = aSelector.rfind( ':' );
if( nPos != std::u16string_view::npos )
{
aPseudo = aSelector.substr( nPos );
aSelector = aSelector.substr( 0, nPos );
}
if( !bHasClass )
{
// If we are exporting styles for a tag we have to export a tag
// rule for all properties that aren't style dependent and
// some class rule for the additional style dependen properties
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_NO_SCRIPT|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&rSelector );
OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop );
}
SfxItemSetFixed<RES_CHRATR_FONT, RES_CHRATR_FONTSIZE,
RES_CHRATR_LANGUAGE, RES_CHRATR_POSTURE,
RES_CHRATR_WEIGHT, RES_CHRATR_WEIGHT,
RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_WEIGHT>
aScriptItemSet( rHTMLWrt.m_pDoc->GetAttrPool() );
if( pDCCharFormat )
aScriptItemSet.Set( pDCCharFormat->GetAttrSet() );
OUString aNewSelector = OUString::Concat(aSelector) + ".western" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop, &aScriptItemSet );
}
aNewSelector = OUString::Concat(aSelector) + ".cjk" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop, &aScriptItemSet );
}
aNewSelector = OUString::Concat(aSelector) + ".ctl" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop, &aScriptItemSet );
}
}
else
{
// If there are script dependencies and we are derived from a tag,
// when we have to export a style dependent class for all
// scripts
OUString aNewSelector = OUString::Concat(aSelector) + "-western" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_WESTERN|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop );
}
aNewSelector = OUString::Concat(aSelector) + "-cjk" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CJK|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop );
}
aNewSelector = OUString::Concat(aSelector) + "-ctl" + aPseudo;
{
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_CTL|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&aNewSelector );
OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop );
}
}
}
else
{
// If there are no script dependencies, when all items are
// exported in one step. For hyperlinks only, a script information
// must be there, because these two chr formats don't support
// script dependencies by now.
SwCSS1OutMode aMode( rHTMLWrt,
rHTMLWrt.m_nCSS1Script|CSS1_OUTMODE_RULE|CSS1_OUTMODE_DROPCAP,
&rSelector );
OutCSS1_SwFormatDropAttrs( rHTMLWrt, rDrop );
}
}
static Writer& OutCSS1_SwFormat( Writer& rWrt, const SwFormat& rFormat,
IDocumentStylePoolAccess/*SwDoc*/ *pDoc, SwDoc *pTemplate )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
bool bCharFormat = false;
switch( rFormat.Which() )
{
case RES_CHRFMT:
bCharFormat = true;
break;
case RES_TXTFMTCOLL:
case RES_CONDTXTFMTCOLL:
// these template-types can be exported
break;
default:
// but not these
return rWrt;
}
// determine Selector and the to-be-exported Attr-Set-depth
OUString aSelector;
sal_uInt16 nRefPoolId = 0;
sal_uInt16 nDeep = GetCSS1Selector( &rFormat, aSelector, nRefPoolId );
if( !nDeep )
return rWrt; // not derived from a HTML-template
sal_uInt16 nPoolFormatId = rFormat.GetPoolFormatId();
// Determine the to-be-exported Attr-Set. We have to distinguish 3 cases:
// - HTML-Tag templates (nDeep==USHRT_MAX):
// Export Attrs...
// - that are set in the template, but not in the original of the HTML template
// - the Default-Attrs for the Attrs, that are set in the Original of the
// HTML template, but not in the current template.
// - templates directly derived from HTML templates (nDeep==1):
// Export only Attributes of the template Item-Set w/o its parents.
// - templates in-directly derived from HTML templates (nDeep>1):
// Export Attributes of the template Item-Set incl. its Parents,
// but w/o Attributes that are set in the HTML-Tag template.
// create Item-Set with all Attributes from the template
// (all but for nDeep==1)
const SfxItemSet& rFormatItemSet = rFormat.GetAttrSet();
SfxItemSet aItemSet( *rFormatItemSet.GetPool(), rFormatItemSet.GetRanges() );
aItemSet.Set( rFormatItemSet ); // Was nDeep!=1 that is not working
// for script dependent items but should
// not make a difference for any other
bool bSetDefaults = true, bClearSame = true;
const SwFormat *pRefFormat = nullptr;
const SwFormat *pRefFormatScript = nullptr;
switch( nDeep )
{
case CSS1_FMT_ISTAG:
pRefFormat = SwHTMLWriter::GetTemplateFormat( nRefPoolId, pTemplate == nullptr ? nullptr : &pTemplate->getIDocumentStylePoolAccess() );
break;
case CSS1_FMT_CMPREF:
pRefFormat = SwHTMLWriter::GetTemplateFormat( nRefPoolId, pDoc );
pRefFormatScript = SwHTMLWriter::GetTemplateFormat( nRefPoolId, pTemplate == nullptr ? nullptr : &pTemplate->getIDocumentStylePoolAccess() );
bClearSame = false;
break;
default:
pRefFormat = SwHTMLWriter::GetParentFormat( rFormat, nDeep );
pRefFormatScript = SwHTMLWriter::GetTemplateFormat( nRefPoolId, pTemplate == nullptr ? nullptr : &pTemplate->getIDocumentStylePoolAccess() );
bSetDefaults = false;
break;
}
if( pRefFormat )
{
// subtract Item-Set of the Reference template (incl. its Parents)
SwHTMLWriter::SubtractItemSet( aItemSet, pRefFormat->GetAttrSet(),
bSetDefaults, bClearSame,
pRefFormatScript
? &pRefFormatScript->GetAttrSet()
: nullptr );
if( !bCharFormat )
{
const SvxULSpaceItem& rULItem = pRefFormat->GetULSpace();
rHTMLWrt.m_nDfltTopMargin = rULItem.GetUpper();
rHTMLWrt.m_nDfltBottomMargin = rULItem.GetLower();
}
}
else if( CSS1_FMT_ISTAG==nDeep && !bCharFormat )
{
// set Default-distance above and below (for the
// case that there is no reference template)
rHTMLWrt.m_nDfltTopMargin = 0;
rHTMLWrt.m_nDfltBottomMargin = HTML_PARSPACE;
if( USER_FMT & nPoolFormatId )
{
// user templates
const OUString& aNm(rFormat.GetName());
if (aNm == "DD 1" || aNm == "DT 1")
rHTMLWrt.m_nDfltBottomMargin = 0;
else if (aNm == OOO_STRING_SVTOOLS_HTML_listing)
rHTMLWrt.m_nDfltBottomMargin = 0;
else if (aNm == OOO_STRING_SVTOOLS_HTML_preformtxt)
rHTMLWrt.m_nDfltBottomMargin = 0;
else if (aNm == OOO_STRING_SVTOOLS_HTML_xmp)
rHTMLWrt.m_nDfltBottomMargin = 0;
}
else
{
// Pool templates
switch( nPoolFormatId )
{
case RES_POOLCOLL_HEADLINE1:
case RES_POOLCOLL_HEADLINE2:
case RES_POOLCOLL_HEADLINE3:
case RES_POOLCOLL_HEADLINE4:
case RES_POOLCOLL_HEADLINE5:
case RES_POOLCOLL_HEADLINE6:
rHTMLWrt.m_nDfltTopMargin = HTML_HEADSPACE;
break;
case RES_POOLCOLL_SEND_ADDRESS:
case RES_POOLCOLL_HTML_DT:
case RES_POOLCOLL_HTML_DD:
case RES_POOLCOLL_HTML_PRE:
rHTMLWrt.m_nDfltBottomMargin = 0;
break;
}
}
}
// if nothing is to be exported ...
if( !aItemSet.Count() )
return rWrt;
// There is no support for script dependent hyperlinks by now.
bool bCheckForPseudo = false;
if( bCharFormat &&
(RES_POOLCHR_INET_NORMAL==nRefPoolId ||
RES_POOLCHR_INET_VISIT==nRefPoolId) )
bCheckForPseudo = true;
// export now the Attributes (incl. selector)
bool bHasScriptDependencies = false;
if( OutCSS1Rule( rHTMLWrt, aSelector, aItemSet, CSS1_FMT_ISTAG != nDeep,
bCheckForPseudo ) )
{
if( bCharFormat )
rHTMLWrt.m_aScriptTextStyles.insert( rFormat.GetName() );
else
{
if( nPoolFormatId==RES_POOLCOLL_TEXT )
rHTMLWrt.m_aScriptParaStyles.insert( pDoc->GetTextCollFromPool( RES_POOLCOLL_STANDARD, false )->GetName() );
rHTMLWrt.m_aScriptParaStyles.insert( rFormat.GetName() );
}
bHasScriptDependencies = true;
}
// export Drop-Caps
if( const SwFormatDrop *pDrop = aItemSet.GetItemIfSet( RES_PARATR_DROP, false ) )
{
OUString sOut = aSelector +
":" + OStringToOUString( sCSS1_first_letter, RTL_TEXTENCODING_ASCII_US );
OutCSS1DropCapRule( rHTMLWrt, sOut, *pDrop, CSS1_FMT_ISTAG != nDeep, bHasScriptDependencies );
}
return rWrt;
}
static Writer& OutCSS1_SwPageDesc( Writer& rWrt, const SwPageDesc& rPageDesc,
IDocumentStylePoolAccess/*SwDoc*/ *pDoc, SwDoc *pTemplate,
sal_uInt16 nRefPoolId, bool bExtRef,
bool bPseudo )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
const SwPageDesc* pRefPageDesc = nullptr;
if( !bExtRef )
pRefPageDesc = pDoc->GetPageDescFromPool( nRefPoolId, false );
else if( pTemplate )
pRefPageDesc = pTemplate->getIDocumentStylePoolAccess().GetPageDescFromPool( nRefPoolId, false );
OUString aSelector = "@" + OStringToOUString( sCSS1_page, RTL_TEXTENCODING_ASCII_US );
if( bPseudo )
{
const char *pPseudo = nullptr;
switch( rPageDesc.GetPoolFormatId() )
{
case RES_POOLPAGE_FIRST: pPseudo = sCSS1_first; break;
case RES_POOLPAGE_LEFT: pPseudo = sCSS1_left; break;
case RES_POOLPAGE_RIGHT: pPseudo = sCSS1_right; break;
}
if( pPseudo )
aSelector += ":" + OStringToOUString( pPseudo, RTL_TEXTENCODING_ASCII_US );
}
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_RULE_ON|CSS1_OUTMODE_TEMPLATE,
&aSelector );
// Size: If the only difference is the Landscape-Flag,
// only export Portrait or Landscape. Otherwise export size.
bool bRefLandscape = pRefPageDesc && pRefPageDesc->GetLandscape();
Size aRefSz;
const Size& rSz = rPageDesc.GetMaster().GetFrameSize().GetSize();
if( pRefPageDesc )
{
aRefSz = pRefPageDesc->GetMaster().GetFrameSize().GetSize();
if( bRefLandscape != rPageDesc.GetLandscape() )
{
tools::Long nTmp = aRefSz.Height();
aRefSz.setHeight( aRefSz.Width() );
aRefSz.setWidth( nTmp );
}
}
// TODO: Bad Hack: On the Page-Tabpage there are small rounding errors
// for the page size. Partially because of bug 25535, we stupidly still
// use the Size-Item from Dialog, even if nothing changed.
// Thus: once one visited the Page-Dialog and left it with OK, we get a
// new page size that then gets exported here. To avoid that, we allow
// here small deviations.
if( std::abs( rSz.Width() - aRefSz.Width() ) <= 2 &&
std::abs( rSz.Height() - aRefSz.Height() ) <= 2 )
{
if( bRefLandscape != rPageDesc.GetLandscape() )
{
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_size,
rPageDesc.GetLandscape() ? sCSS1_PV_landscape
: sCSS1_PV_portrait );
}
}
else
{
OStringBuffer sVal;
AddUnitPropertyValue(sVal, rSz.Width(), rHTMLWrt.GetCSS1Unit());
sVal.append(' ');
AddUnitPropertyValue(sVal, rSz.Height(), rHTMLWrt.GetCSS1Unit());
rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_size, sVal.makeStringAndClear());
}
// Export the distance-Attributes as normally
const SwFrameFormat &rMaster = rPageDesc.GetMaster();
SfxItemSetFixed<RES_LR_SPACE, RES_UL_SPACE> aItemSet( *rMaster.GetAttrSet().GetPool() );
aItemSet.Set( rMaster.GetAttrSet() );
if( pRefPageDesc )
{
SwHTMLWriter::SubtractItemSet( aItemSet,
pRefPageDesc->GetMaster().GetAttrSet(),
true );
}
OutCSS1_SvxULSpace_SvxLRSpace( rWrt, aItemSet );
// If for a Pseudo-Selector no Property had been set, we still
// have to export something, so that the corresponding template is
// created on the next import.
if( rHTMLWrt.m_bFirstCSS1Property && bPseudo )
{
rHTMLWrt.OutNewLine();
OString sTmp(OUStringToOString(aSelector, RTL_TEXTENCODING_UTF8));
rWrt.Strm().WriteOString( sTmp ).WriteCharPtr( " {" );
rHTMLWrt.m_bFirstCSS1Property = false;
}
if( !rHTMLWrt.m_bFirstCSS1Property )
rWrt.Strm().WriteCharPtr( sCSS1_rule_end );
return rWrt;
}
static Writer& OutCSS1_SwFootnoteInfo( Writer& rWrt, const SwEndNoteInfo& rInfo,
SwDoc *pDoc, bool bHasNotes, bool bEndNote )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
OUString aSelector;
if( bHasNotes )
{
aSelector = OUString::Concat(OOO_STRING_SVTOOLS_HTML_anchor ".") +
( bEndNote ? std::u16string_view(u"" OOO_STRING_SVTOOLS_HTML_sdendnote_anc)
: std::u16string_view(u"" OOO_STRING_SVTOOLS_HTML_sdfootnote_anc) );
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_RULE|CSS1_OUTMODE_TEMPLATE,
&aSelector );
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_size,
sHTML_FTN_fontheight );
rHTMLWrt.Strm().WriteCharPtr( sCSS1_rule_end );
}
const SwCharFormat *pSymCharFormat = rInfo.GetCharFormat( *pDoc );
if( pSymCharFormat )
{
const SfxItemSet& rFormatItemSet = pSymCharFormat->GetAttrSet();
SfxItemSet aItemSet( *rFormatItemSet.GetPool(), rFormatItemSet.GetRanges() );
aItemSet.Set( rFormatItemSet );
// If there are footnotes or endnotes, then all Attributes have to be
// exported, so that Netscape displays the document correctly.
// Otherwise it is sufficient, to export the differences to the
// footnote and endnote template.
if( !bHasNotes && rHTMLWrt.m_xTemplate.is() )
{
SwFormat *pRefFormat = rHTMLWrt.m_xTemplate->getIDocumentStylePoolAccess().GetCharFormatFromPool(
static_cast< sal_uInt16 >(bEndNote ? RES_POOLCHR_ENDNOTE : RES_POOLCHR_FOOTNOTE) );
if( pRefFormat )
SwHTMLWriter::SubtractItemSet( aItemSet, pRefFormat->GetAttrSet(),
true );
}
if( aItemSet.Count() )
{
aSelector = OUString::Concat(OOO_STRING_SVTOOLS_HTML_anchor ".") +
( bEndNote ? std::u16string_view(u"" OOO_STRING_SVTOOLS_HTML_sdendnote_sym)
: std::u16string_view(
u"" OOO_STRING_SVTOOLS_HTML_sdfootnote_sym));
if( OutCSS1Rule( rHTMLWrt, aSelector, aItemSet, true, false ))
rHTMLWrt.m_aScriptTextStyles.insert( pSymCharFormat->GetName() );
}
}
return rWrt;
}
Writer& OutCSS1_BodyTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT_ON |
CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_BODY, nullptr );
// Only export the attributes of the page template.
// The attributes of the default paragraph template were
// considered already when exporting the paragraph template.
const SfxPoolItem *pItem;
if( SfxItemState::SET == rItemSet.GetItemState( RES_BACKGROUND, false,
&pItem ) )
{
OUString rEmbeddedGraphicName;
OutCSS1_SvxBrush( rWrt, *pItem, sw::Css1Background::Page, &rEmbeddedGraphicName );
}
if( SfxItemState::SET == rItemSet.GetItemState( RES_BOX, false,
&pItem ))
{
OutCSS1_SvxBox( rWrt, *pItem );
}
if( !rHTMLWrt.m_bFirstCSS1Property )
{
// if a Property was exported as part of a Style-Option,
// the Option still needs to be finished
rWrt.Strm().WriteChar( '\"' );
}
return rWrt;
}
Writer& OutCSS1_ParaTagStyleOpt( Writer& rWrt, const SfxItemSet& rItemSet )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
SwCSS1OutMode aMode( rHTMLWrt, rHTMLWrt.m_nCSS1Script|CSS1_OUTMODE_STYLE_OPT |
CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_PARA, nullptr );
rHTMLWrt.OutCSS1_SfxItemSet( rItemSet, false );
return rWrt;
}
Writer& OutCSS1_TableBGStyleOpt( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT_ON |
CSS1_OUTMODE_ENCODE|
CSS1_OUTMODE_TABLEBOX, nullptr );
OutCSS1_SvxBrush( rWrt, rHt, sw::Css1Background::TableRow, nullptr );
if (!rHTMLWrt.m_bFirstCSS1Property)
rWrt.Strm().WriteChar(cCSS1_style_opt_end);
return rWrt;
}
Writer& OutCSS1_NumberBulletListStyleOpt( Writer& rWrt, const SwNumRule& rNumRule,
sal_uInt8 nLevel )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT |
CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_PARA, nullptr );
const SwNumFormat& rNumFormat = rNumRule.Get( nLevel );
tools::Long nLSpace = rNumFormat.GetAbsLSpace();
tools::Long nFirstLineOffset = rNumFormat.GetFirstLineOffset();
tools::Long nDfltFirstLineOffset = HTML_NUMBER_BULLET_INDENT;
if( nLevel > 0 )
{
const SwNumFormat& rPrevNumFormat = rNumRule.Get( nLevel-1 );
nLSpace -= rPrevNumFormat.GetAbsLSpace();
nDfltFirstLineOffset = rPrevNumFormat.GetFirstLineOffset();
}
if( rHTMLWrt.IsHTMLMode(HTMLMODE_LSPACE_IN_NUMBER_BULLET) &&
nLSpace != HTML_NUMBER_BULLET_MARGINLEFT )
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_left, nLSpace );
if( rHTMLWrt.IsHTMLMode(HTMLMODE_FRSTLINE_IN_NUMBER_BULLET) &&
nFirstLineOffset != nDfltFirstLineOffset )
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_text_indent, nFirstLineOffset );
if( !rHTMLWrt.m_bFirstCSS1Property )
rWrt.Strm().WriteChar( '\"' );
return rWrt;
}
void SwHTMLWriter::OutCSS1_FrameFormatOptions( const SwFrameFormat& rFrameFormat,
HtmlFrmOpts nFrameOpts,
const SdrObject *pSdrObj,
const SfxItemSet *pItemSet )
{
SwCSS1OutMode aMode( *this, CSS1_OUTMODE_STYLE_OPT_ON |
CSS1_OUTMODE_ENCODE|
CSS1_OUTMODE_FRAME, nullptr );
const SwFormatHoriOrient& rHoriOri = rFrameFormat.GetHoriOrient();
SvxLRSpaceItem aLRItem( rFrameFormat.GetLRSpace() );
SvxULSpaceItem aULItem( rFrameFormat.GetULSpace() );
if( nFrameOpts & HtmlFrmOpts::SAlign )
{
const SwFormatAnchor& rAnchor = rFrameFormat.GetAnchor();
switch( rAnchor.GetAnchorId() )
{
case RndStdIds::FLY_AT_PARA:
case RndStdIds::FLY_AT_CHAR:
if( text::RelOrientation::FRAME == rHoriOri.GetRelationOrient() ||
text::RelOrientation::PRINT_AREA == rHoriOri.GetRelationOrient() )
{
if( !(nFrameOpts & HtmlFrmOpts::Align) )
{
// float
const char *pStr = text::HoriOrientation::RIGHT==rHoriOri.GetHoriOrient()
? sCSS1_PV_right
: sCSS1_PV_left;
OutCSS1_PropertyAscii( sCSS1_P_float, pStr );
}
break;
}
[[fallthrough]];
case RndStdIds::FLY_AT_PAGE:
case RndStdIds::FLY_AT_FLY:
{
// position
OutCSS1_PropertyAscii( sCSS1_P_position, sCSS1_PV_absolute );
// For top/left we need to subtract the distance to the frame
// from the position, as in CSS1 it is added to the position.
// This works also for automatically aligned frames, even that
// in this case Writer also adds the distance; because in this
// case the Orient-Attribute contains the correct position.
// top
tools::Long nXPos=0, nYPos=0;
bool bOutXPos = false, bOutYPos = false;
if( RES_DRAWFRMFMT == rFrameFormat.Which() )
{
OSL_ENSURE( pSdrObj, "Do not pass a SdrObject. Inefficient" );
if( !pSdrObj )
pSdrObj = rFrameFormat.FindSdrObject();
OSL_ENSURE( pSdrObj, "Where is the SdrObject" );
if( pSdrObj )
{
Point aPos( pSdrObj->GetRelativePos() );
nXPos = aPos.X();
nYPos = aPos.Y();
}
bOutXPos = bOutYPos = true;
}
else
{
bOutXPos = text::RelOrientation::CHAR != rHoriOri.GetRelationOrient();
nXPos = text::HoriOrientation::NONE == rHoriOri.GetHoriOrient()
? rHoriOri.GetPos() : 0;
const SwFormatVertOrient& rVertOri = rFrameFormat.GetVertOrient();
bOutYPos = text::RelOrientation::CHAR != rVertOri.GetRelationOrient();
nYPos = text::VertOrientation::NONE == rVertOri.GetVertOrient()
? rVertOri.GetPos() : 0;
}
if( bOutYPos )
{
if( IsHTMLMode( HTMLMODE_FLY_MARGINS) )
{
nYPos -= aULItem.GetUpper();
if( nYPos < 0 )
{
aULItem.SetUpper( o3tl::narrowing<sal_uInt16>(aULItem.GetUpper() + nYPos) );
nYPos = 0;
}
}
OutCSS1_UnitProperty( sCSS1_P_top, nYPos );
}
if( bOutXPos )
{
// left
if( IsHTMLMode( HTMLMODE_FLY_MARGINS) )
{
nXPos -= aLRItem.GetLeft();
if( nXPos < 0 )
{
aLRItem.SetLeft( o3tl::narrowing<sal_uInt16>(aLRItem.GetLeft() + nXPos) );
nXPos = 0;
}
}
OutCSS1_UnitProperty( sCSS1_P_left, nXPos );
}
}
break;
default:
;
}
}
// width/height
if( nFrameOpts & HtmlFrmOpts::SSize )
{
if( RES_DRAWFRMFMT == rFrameFormat.Which() )
{
OSL_ENSURE( pSdrObj, "Do not pass a SdrObject. Inefficient" );
if( !pSdrObj )
pSdrObj = rFrameFormat.FindSdrObject();
OSL_ENSURE( pSdrObj, "Where is the SdrObject" );
if( pSdrObj )
{
Size aTwipSz( pSdrObj->GetLogicRect().GetSize() );
if( nFrameOpts & HtmlFrmOpts::SWidth )
{
if( nFrameOpts & HtmlFrmOpts::SPixSize )
OutCSS1_PixelProperty( sCSS1_P_width, aTwipSz.Width(),
false );
else
OutCSS1_UnitProperty( sCSS1_P_width, aTwipSz.Width() );
}
if( nFrameOpts & HtmlFrmOpts::SHeight )
{
if( nFrameOpts & HtmlFrmOpts::SPixSize )
OutCSS1_PixelProperty( sCSS1_P_height, aTwipSz.Height(),
true );
else
OutCSS1_UnitProperty( sCSS1_P_height, aTwipSz.Height() );
}
}
}
else
{
OSL_ENSURE( HtmlFrmOpts::AbsSize & nFrameOpts,
"Export absolute size" );
OSL_ENSURE( HtmlFrmOpts::AnySize & nFrameOpts,
"Export every size" );
Css1FrameSize nMode = Css1FrameSize::NONE;
if( nFrameOpts & HtmlFrmOpts::SWidth )
nMode |= Css1FrameSize::Width;
if( nFrameOpts & HtmlFrmOpts::SHeight )
nMode |= Css1FrameSize::MinHeight|Css1FrameSize::FixHeight;
if( nFrameOpts & HtmlFrmOpts::SPixSize )
nMode |= Css1FrameSize::Pixel;
OutCSS1_SwFormatFrameSize( *this, rFrameFormat.GetFrameSize(), nMode );
}
}
const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
// margin-*
if( (nFrameOpts & HtmlFrmOpts::SSpace) &&
IsHTMLMode( HTMLMODE_FLY_MARGINS) )
{
const SvxLRSpaceItem *pLRItem = nullptr;
const SvxULSpaceItem *pULItem = nullptr;
if( SfxItemState::SET == rItemSet.GetItemState( RES_LR_SPACE ) )
pLRItem = &aLRItem;
if( SfxItemState::SET == rItemSet.GetItemState( RES_UL_SPACE ) )
pULItem = &aULItem;
if( pLRItem || pULItem )
OutCSS1_SvxULSpace_SvxLRSpace( *this, pULItem, pLRItem );
}
// border
if( nFrameOpts & HtmlFrmOpts::SBorder )
{
const SfxPoolItem* pItem;
if( nFrameOpts & HtmlFrmOpts::SNoBorder )
OutCSS1_SvxBox( *this, rFrameFormat.GetBox() );
else if( SfxItemState::SET==rItemSet.GetItemState( RES_BOX, true, &pItem ) )
OutCSS1_SvxBox( *this, *pItem );
}
// background (if, then the color must be set also)
if( nFrameOpts & HtmlFrmOpts::SBackground )
OutCSS1_FrameFormatBackground( rFrameFormat );
if( pItemSet )
OutCSS1_SfxItemSet( *pItemSet, false );
if( !m_bFirstCSS1Property )
Strm().WriteChar( '\"' );
}
void SwHTMLWriter::OutCSS1_TableFrameFormatOptions( const SwFrameFormat& rFrameFormat )
{
SwCSS1OutMode aMode( *this, CSS1_OUTMODE_STYLE_OPT_ON |
CSS1_OUTMODE_ENCODE|
CSS1_OUTMODE_TABLE, nullptr );
const SfxPoolItem *pItem;
const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
if( SfxItemState::SET==rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
OutCSS1_SvxBrush( *this, *pItem, sw::Css1Background::Table, nullptr );
if( IsHTMLMode( HTMLMODE_PRINT_EXT ) )
OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( *this, rItemSet, false );
if( SfxItemState::SET==rItemSet.GetItemState( RES_LAYOUT_SPLIT, false, &pItem ) )
OutCSS1_SwFormatLayoutSplit( *this, *pItem );
if( !m_bFirstCSS1Property )
Strm().WriteChar( '\"' );
}
void SwHTMLWriter::OutCSS1_TableCellBordersAndBG(SwFrameFormat const& rFrameFormat, const SvxBrushItem *pBrushItem)
{
SwCSS1OutMode const aMode( *this,
CSS1_OUTMODE_STYLE_OPT_ON|CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_TABLEBOX, nullptr );
if (pBrushItem)
OutCSS1_SvxBrush(*this, *pBrushItem, sw::Css1Background::TableCell, nullptr);
OutCSS1_SvxBox(*this, rFrameFormat.GetBox());
if (!m_bFirstCSS1Property)
Strm().WriteChar(cCSS1_style_opt_end);
}
void SwHTMLWriter::OutCSS1_SectionFormatOptions( const SwFrameFormat& rFrameFormat, const SwFormatCol *pCol )
{
SwCSS1OutMode aMode( *this, CSS1_OUTMODE_STYLE_OPT_ON |
CSS1_OUTMODE_ENCODE|
CSS1_OUTMODE_SECTION, nullptr );
const SfxPoolItem *pItem;
const SfxItemSet& rItemSet = rFrameFormat.GetAttrSet();
if( SfxItemState::SET==rItemSet.GetItemState( RES_BACKGROUND, false, &pItem ) )
OutCSS1_SvxBrush( *this, *pItem, sw::Css1Background::Section, nullptr );
if (mbXHTML)
{
SvxFrameDirection nDir = GetHTMLDirection(rFrameFormat.GetAttrSet());
OString sConvertedDirection = convertDirection(nDir);
if (!sConvertedDirection.isEmpty())
{
OutCSS1_Property(sCSS1_P_dir, sConvertedDirection, nullptr,
sw::Css1Background::Section);
}
}
if (pCol)
{
OString sColumnCount(OString::number(static_cast<sal_Int32>(pCol->GetNumCols())));
OutCSS1_PropertyAscii(sCSS1_P_column_count, sColumnCount);
}
if( !m_bFirstCSS1Property )
Strm().WriteChar( '\"' );
}
static bool OutCSS1_FrameFormatBrush( SwHTMLWriter& rWrt,
const SvxBrushItem& rBrushItem )
{
bool bWritten = false;
/// output brush of frame format, if its background color is not "no fill"/"auto fill"
/// or it has a background graphic.
if( rBrushItem.GetColor() != COL_TRANSPARENT ||
!rBrushItem.GetGraphicLink().isEmpty() ||
0 != rBrushItem.GetGraphicPos() )
{
OutCSS1_SvxBrush( rWrt, rBrushItem, sw::Css1Background::Fly, nullptr );
bWritten = true;
}
return bWritten;
}
void SwHTMLWriter::OutCSS1_FrameFormatBackground( const SwFrameFormat& rFrameFormat )
{
// If the frame itself has a background, then export.
if( OutCSS1_FrameFormatBrush( *this, *rFrameFormat.makeBackgroundBrushItem() ) )
return;
// If the frame is not linked to a page, we use the background of the anchor.
const SwFormatAnchor& rAnchor = rFrameFormat.GetAnchor();
RndStdIds eAnchorId = rAnchor.GetAnchorId();
const SwPosition *pAnchorPos = rAnchor.GetContentAnchor();
if (RndStdIds::FLY_AT_PAGE != eAnchorId && pAnchorPos)
{
const SwNode& rNode = pAnchorPos->nNode.GetNode();
if( rNode.IsContentNode() )
{
// If the frame is linked to a content-node,
// we take the background of the content-node, if it has one.
if( OutCSS1_FrameFormatBrush( *this,
rNode.GetContentNode()->GetSwAttrSet().GetBackground()) )
return;
// Otherwise we also could be in a table
const SwTableNode *pTableNd = rNode.FindTableNode();
if( pTableNd )
{
const SwStartNode *pBoxSttNd = rNode.FindTableBoxStartNode();
const SwTableBox *pBox =
pTableNd->GetTable().GetTableBox( pBoxSttNd->GetIndex() );
// If the box has a background, we take it.
if( OutCSS1_FrameFormatBrush( *this,
*pBox->GetFrameFormat()->makeBackgroundBrushItem() ) )
return;
// Otherwise we use that of the lines
const SwTableLine *pLine = pBox->GetUpper();
while( pLine )
{
if( OutCSS1_FrameFormatBrush( *this,
*pLine->GetFrameFormat()->makeBackgroundBrushItem() ) )
return;
pBox = pLine->GetUpper();
pLine = pBox ? pBox->GetUpper() : nullptr;
}
// If there was none either, we use the background of the table.
if( OutCSS1_FrameFormatBrush( *this,
*pTableNd->GetTable().GetFrameFormat()->makeBackgroundBrushItem() ) )
return;
}
}
// If the anchor is again in a Fly-Frame, use the background of the Fly-Frame.
const SwFrameFormat *pFrameFormat = rNode.GetFlyFormat();
if( pFrameFormat )
{
OutCSS1_FrameFormatBackground( *pFrameFormat );
return;
}
}
// At last there is the background of the page, and as the final rescue
// the value of the Config.
OSL_ENSURE( m_pCurrPageDesc, "no page template found" );
if( OutCSS1_FrameFormatBrush( *this,
*m_pCurrPageDesc->GetMaster().makeBackgroundBrushItem() ) )
return;
Color aColor( COL_WHITE );
// The background color is normally only used in Browse-Mode.
// We always use it for a HTML document, but for a text document
// only if viewed in Browse-Mode.
if( m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) ||
m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE))
{
SwViewShell *pVSh = m_pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
if ( pVSh &&
COL_TRANSPARENT != pVSh->GetViewOptions()->GetRetoucheColor())
aColor = pVSh->GetViewOptions()->GetRetoucheColor();
}
OutCSS1_PropertyAscii(sCSS1_P_background, GetCSS1_Color(aColor));
}
static Writer& OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( Writer& rWrt,
const SvxUnderlineItem *pUItem,
const SvxOverlineItem *pOItem,
const SvxCrossedOutItem *pCOItem,
const SvxBlinkItem *pBItem )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
bool bNone = false;
const char *pUStr = nullptr;
if( pUItem )
{
switch( pUItem->GetLineStyle() )
{
case LINESTYLE_NONE:
bNone = true;
break;
case LINESTYLE_DONTKNOW:
break;
default:
if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT) || rHTMLWrt.mbReqIF,
"write underline as Hint?" );
pUStr = sCSS1_PV_underline;
}
break;
}
}
const char *pOStr = nullptr;
if( pOItem )
{
switch( pOItem->GetLineStyle() )
{
case LINESTYLE_NONE:
bNone = true;
break;
case LINESTYLE_DONTKNOW:
break;
default:
if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write overline as Hint?" );
pOStr = sCSS1_PV_overline;
}
break;
}
}
const char *pCOStr = nullptr;
if( pCOItem )
{
switch( pCOItem->GetStrikeout() )
{
case STRIKEOUT_NONE:
bNone = true;
break;
case STRIKEOUT_DONTKNOW:
break;
default:
if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT) || rHTMLWrt.mbReqIF,
"write crossedOut as Hint?" );
pCOStr = sCSS1_PV_line_through;
}
break;
}
}
const char *pBStr = nullptr;
if( pBItem )
{
if( !pBItem->GetValue() )
{
bNone = true;
}
else if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write blink as Hint?" );
pBStr = sCSS1_PV_blink;
}
}
OStringBuffer sOut;
if( pUStr )
sOut.append(pUStr);
if( pOStr )
{
if (!sOut.isEmpty())
sOut.append(' ');
sOut.append(pOStr);
}
if( pCOStr )
{
if (!sOut.isEmpty())
sOut.append(' ');
sOut.append(pCOStr);
}
if( pBStr )
{
if (!sOut.isEmpty())
sOut.append(' ');
sOut.append(pBStr);
}
if (!sOut.isEmpty())
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_decoration, sOut.makeStringAndClear() );
else if( bNone )
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_decoration, sCSS1_PV_none );
return rWrt;
}
static Writer& OutCSS1_SvxCaseMap( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
switch( static_cast<const SvxCaseMapItem&>(rHt).GetCaseMap() )
{
case SvxCaseMap::NotMapped:
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_variant, sCSS1_PV_normal );
break;
case SvxCaseMap::SmallCaps:
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_variant, sCSS1_PV_small_caps );
break;
case SvxCaseMap::Uppercase:
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_transform, sCSS1_PV_uppercase );
break;
case SvxCaseMap::Lowercase:
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_transform, sCSS1_PV_lowercase );
break;
case SvxCaseMap::Capitalize:
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_transform, sCSS1_PV_capitalize );
break;
default:
;
}
return rWrt;
}
static Writer& OutCSS1_SvxColor( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// Colors do not need to be exported for Style-Option.
if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) &&
!rHTMLWrt.m_bCfgPreferStyles )
return rWrt;
OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write color as Hint?" );
Color aColor( static_cast<const SvxColorItem&>(rHt).GetValue() );
if( COL_AUTO == aColor )
aColor = COL_BLACK;
rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_color, GetCSS1_Color(aColor));
return rWrt;
}
static Writer& OutCSS1_SvxCrossedOut( Writer& rWrt, const SfxPoolItem& rHt )
{
// This function only exports Hints!
// Otherwise OutCSS1_SvxTextLn_SvxCrOut_SvxBlink() is called directly.
if( static_cast<SwHTMLWriter&>(rWrt).IsCSS1Source(CSS1_OUTMODE_HINT) )
OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( rWrt,
nullptr, nullptr, static_cast<const SvxCrossedOutItem *>(&rHt), nullptr );
return rWrt;
}
static Writer& OutCSS1_SvxFont( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// No need to export Fonts for the Style-Option.
if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
return rWrt;
sal_uInt16 nScript = CSS1_OUTMODE_WESTERN;
switch( rHt.Which() )
{
case RES_CHRATR_CJK_FONT: nScript = CSS1_OUTMODE_CJK; break;
case RES_CHRATR_CTL_FONT: nScript = CSS1_OUTMODE_CTL; break;
}
if( !rHTMLWrt.IsCSS1Script( nScript ) )
return rWrt;
OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write Font as Hint?" );
OUString sOut;
// MS IE3b1 has problems with single quotes
sal_uInt16 nMode = rHTMLWrt.m_nCSS1OutMode & CSS1_OUTMODE_ANY_ON;
sal_Unicode cQuote = nMode == CSS1_OUTMODE_RULE_ON ? '\"' : '\'';
SwHTMLWriter::PrepareFontList( static_cast<const SvxFontItem&>(rHt), sOut, cQuote,
true );
rHTMLWrt.OutCSS1_Property( sCSS1_P_font_family, sOut );
return rWrt;
}
static Writer& OutCSS1_SvxFontHeight( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// Font-Height need not be exported in the Style-Option.
// For Drop-Caps another Font-Size is exported.
if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) ||
rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_DROPCAP ) )
return rWrt;
sal_uInt16 nScript = CSS1_OUTMODE_WESTERN;
switch( rHt.Which() )
{
case RES_CHRATR_CJK_FONTSIZE: nScript = CSS1_OUTMODE_CJK; break;
case RES_CHRATR_CTL_FONTSIZE: nScript = CSS1_OUTMODE_CTL; break;
}
if( !rHTMLWrt.IsCSS1Script( nScript ) )
return rWrt;
sal_uInt32 nHeight = static_cast<const SvxFontHeightItem&>(rHt).GetHeight();
OString sHeight(OString::number(nHeight/20) + sCSS1_UNIT_pt);
rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_font_size, sHeight);
return rWrt;
}
static Writer& OutCSS1_SvxPosture( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
sal_uInt16 nScript = CSS1_OUTMODE_WESTERN;
switch( rHt.Which() )
{
case RES_CHRATR_CJK_POSTURE: nScript = CSS1_OUTMODE_CJK; break;
case RES_CHRATR_CTL_POSTURE: nScript = CSS1_OUTMODE_CTL; break;
}
if( !rHTMLWrt.IsCSS1Script( nScript ) )
return rWrt;
const char *pStr = nullptr;
switch( static_cast<const SvxPostureItem&>(rHt).GetPosture() )
{
case ITALIC_NONE: pStr = sCSS1_PV_normal; break;
case ITALIC_OBLIQUE: pStr = sCSS1_PV_oblique; break;
case ITALIC_NORMAL:
if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write italic as Hint?" );
pStr = sCSS1_PV_italic;
}
break;
default:
;
}
if( pStr )
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_style, pStr );
return rWrt;
}
static Writer& OutCSS1_SvxKerning( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
sal_Int16 nValue = static_cast<const SvxKerningItem&>(rHt).GetValue();
if( nValue )
{
OStringBuffer sOut;
if( nValue < 0 )
{
sOut.append('-');
nValue = -nValue;
}
// Width as n.n pt
nValue = (nValue + 1) / 2; // 1/10pt
sOut.append(OString::number(nValue / 10) + "." + OString::number(nValue % 10) +
sCSS1_UNIT_pt);
rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_letter_spacing,
sOut.makeStringAndClear());
}
else
{
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_letter_spacing,
sCSS1_PV_normal );
}
return rWrt;
}
static Writer& OutCSS1_SvxLanguage( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// Only export Language rules
if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
return rWrt;
sal_uInt16 nScript = CSS1_OUTMODE_WESTERN;
switch( rHt.Which() )
{
case RES_CHRATR_CJK_LANGUAGE: nScript = CSS1_OUTMODE_CJK; break;
case RES_CHRATR_CTL_LANGUAGE: nScript = CSS1_OUTMODE_CTL; break;
}
if( !rHTMLWrt.IsCSS1Script( nScript ) )
return rWrt;
OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write Language as Hint?" );
LanguageType eLang = static_cast<const SvxLanguageItem &>(rHt).GetLanguage();
if( LANGUAGE_DONTKNOW == eLang )
return rWrt;
OUString sOut = LanguageTag::convertToBcp47( eLang );
rHTMLWrt.OutCSS1_Property( sCSS1_P_so_language, sOut );
return rWrt;
}
static Writer& OutCSS1_SvxUnderline( Writer& rWrt, const SfxPoolItem& rHt )
{
// This function only exports Hints!
// Otherwise OutCSS1_SvxTextLn_SvxCrOut_SvxBlink() is called directly.
if( static_cast<SwHTMLWriter&>(rWrt).IsCSS1Source(CSS1_OUTMODE_HINT) )
OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( rWrt,
static_cast<const SvxUnderlineItem *>(&rHt), nullptr, nullptr, nullptr );
return rWrt;
}
static Writer& OutCSS1_SvxOverline( Writer& rWrt, const SfxPoolItem& rHt )
{
// This function only exports Hints!
// Otherwise OutCSS1_SvxTextLn_SvxCrOut_SvxBlink() is called directly.
if( static_cast<SwHTMLWriter&>(rWrt).IsCSS1Source(CSS1_OUTMODE_HINT) )
OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( rWrt,
nullptr, static_cast<const SvxOverlineItem *>(&rHt), nullptr, nullptr );
return rWrt;
}
static Writer& OutCSS1_SvxHidden( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
if ( static_cast<const SvxCharHiddenItem&>(rHt).GetValue() )
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_display, sCSS1_PV_none );
return rWrt;
}
static Writer& OutCSS1_SvxFontWeight( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
sal_uInt16 nScript = CSS1_OUTMODE_WESTERN;
switch( rHt.Which() )
{
case RES_CHRATR_CJK_WEIGHT: nScript = CSS1_OUTMODE_CJK; break;
case RES_CHRATR_CTL_WEIGHT: nScript = CSS1_OUTMODE_CTL; break;
}
if( !rHTMLWrt.IsCSS1Script( nScript ) )
return rWrt;
const char *pStr = nullptr;
switch( static_cast<const SvxWeightItem&>(rHt).GetWeight() )
{
case WEIGHT_ULTRALIGHT: pStr = sCSS1_PV_extra_light; break;
case WEIGHT_LIGHT: pStr = sCSS1_PV_light; break;
case WEIGHT_SEMILIGHT: pStr = sCSS1_PV_demi_light; break;
case WEIGHT_NORMAL: pStr = sCSS1_PV_normal; break;
case WEIGHT_SEMIBOLD: pStr = sCSS1_PV_demi_bold; break;
case WEIGHT_BOLD:
if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
{
// this also works in HTML does not need to be written as
// a STYLE-Options, and must not be written as Hint
OSL_ENSURE( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT),
"write bold as Hint?" );
pStr = sCSS1_PV_bold;
}
break;
case WEIGHT_ULTRABOLD: pStr = sCSS1_PV_extra_bold; break;
default:
pStr = sCSS1_PV_normal;
}
if( pStr )
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_font_weight, pStr );
return rWrt;
}
static Writer& OutCSS1_SvxBlink( Writer& rWrt, const SfxPoolItem& rHt )
{
// This function only exports Hints!
// Otherwise OutCSS1_SvxTextLn_SvxCrOut_SvxBlink() is called directly.
if( static_cast<SwHTMLWriter&>(rWrt).IsCSS1Source(CSS1_OUTMODE_HINT) )
OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( rWrt,
nullptr, nullptr, nullptr, static_cast<const SvxBlinkItem *>(&rHt) );
return rWrt;
}
static Writer& OutCSS1_SvxLineSpacing( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// Netscape4 has big problems with cell heights if the line spacing is
// changed within a table and the width of the table is not calculated
// automatically (== if there is a WIDTH-Option)
if( rHTMLWrt.m_bOutTable && rHTMLWrt.m_bCfgNetscape4 )
return rWrt;
const SvxLineSpacingItem& rLSItem = static_cast<const SvxLineSpacingItem&>(rHt);
sal_uInt16 nHeight = 0;
sal_uInt16 nPercentHeight = 0;
SvxLineSpaceRule eLineSpace = rLSItem.GetLineSpaceRule();
switch( rLSItem.GetInterLineSpaceRule() )
{
case SvxInterLineSpaceRule::Off:
case SvxInterLineSpaceRule::Fix:
{
switch( eLineSpace )
{
case SvxLineSpaceRule::Min:
case SvxLineSpaceRule::Fix:
nHeight = rLSItem.GetLineHeight();
break;
case SvxLineSpaceRule::Auto:
nPercentHeight = 100;
break;
default:
;
}
}
break;
case SvxInterLineSpaceRule::Prop:
nPercentHeight = rLSItem.GetPropLineSpace();
break;
default:
;
}
if( nHeight )
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_line_height, static_cast<tools::Long>(nHeight) );
else if( nPercentHeight &&
!(nPercentHeight < 115 && rHTMLWrt.m_bParaDotLeaders )) // avoid HTML scrollbars and missing descenders
{
OString sHeight(OString::number(nPercentHeight) + "%");
rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_line_height, sHeight);
}
return rWrt;
}
static Writer& OutCSS1_SvxAdjust( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// Export Alignment in Style-Option only if the Tag does not allow ALIGN=xxx
if( rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) &&
!rHTMLWrt.m_bNoAlign)
return rWrt;
const char* pStr = nullptr;
switch( static_cast<const SvxAdjustItem&>(rHt).GetAdjust() )
{
case SvxAdjust::Left: pStr = sCSS1_PV_left; break;
case SvxAdjust::Right: pStr = sCSS1_PV_right; break;
case SvxAdjust::Block: pStr = sCSS1_PV_justify; break;
case SvxAdjust::Center: pStr = sCSS1_PV_center; break;
default:
;
}
if( pStr )
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_text_align, pStr );
return rWrt;
}
static Writer& OutCSS1_SvxFormatSplit( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
const char *pStr = static_cast<const SvxFormatSplitItem&>(rHt).GetValue()
? sCSS1_PV_auto
: sCSS1_PV_avoid;
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_inside, pStr );
return rWrt;
}
static Writer& OutCSS1_SwFormatLayoutSplit( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
const char *pStr = static_cast<const SwFormatLayoutSplit&>(rHt).GetValue()
? sCSS1_PV_auto
: sCSS1_PV_avoid;
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_inside, pStr );
return rWrt;
}
static Writer& OutCSS1_SvxWidows( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
OString aStr(OString::number(static_cast<const SvxWidowsItem&>(rHt).GetValue()));
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_widows, aStr );
return rWrt;
}
static Writer& OutCSS1_SvxOrphans( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
OString aStr(OString::number(static_cast<const SvxOrphansItem&>(rHt).GetValue()));
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_orphans, aStr );
return rWrt;
}
static void OutCSS1_SwFormatDropAttrs( SwHTMLWriter& rHWrt,
const SwFormatDrop& rDrop,
const SfxItemSet *pCharFormatItemSet )
{
// Text flows around on right side
rHWrt.OutCSS1_PropertyAscii( sCSS1_P_float, sCSS1_PV_left );
// number of lines -> use % for Font-Height!
OString sOut(OString::number(rDrop.GetLines()*100) + "%");
rHWrt.OutCSS1_PropertyAscii(sCSS1_P_font_size, sOut);
// distance to Text = right margin
sal_uInt16 nDistance = rDrop.GetDistance();
if( nDistance > 0 )
rHWrt.OutCSS1_UnitProperty( sCSS1_P_margin_right, nDistance );
const SwCharFormat *pDCCharFormat = rDrop.GetCharFormat();
if( pCharFormatItemSet )
rHWrt.OutCSS1_SfxItemSet( *pCharFormatItemSet );
else if( pDCCharFormat )
rHWrt.OutCSS1_SfxItemSet( pDCCharFormat->GetAttrSet() );
else if( (rHWrt.m_nCSS1OutMode & CSS1_OUTMODE_ANY_OFF) == CSS1_OUTMODE_RULE_OFF )
rHWrt.Strm().WriteCharPtr( sCSS1_rule_end );
}
static Writer& OutCSS1_SwFormatDrop( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// never export as an Option of a paragraph, but only as Hints
if( !rHTMLWrt.IsCSS1Source(CSS1_OUTMODE_HINT) )
return rWrt;
if( rHTMLWrt.m_bTagOn )
{
SwCSS1OutMode aMode( rHTMLWrt,
rHTMLWrt.m_nCSS1Script|CSS1_OUTMODE_SPAN_TAG1_ON|CSS1_OUTMODE_ENCODE|
CSS1_OUTMODE_DROPCAP, nullptr );
OutCSS1_SwFormatDropAttrs( rHTMLWrt, static_cast<const SwFormatDrop&>(rHt) );
// A "> is already printed by the calling OutCSS1_HintAsSpanTag.
}
else
{
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false );
}
return rWrt;
}
static Writer& OutCSS1_SwFormatFrameSize( Writer& rWrt, const SfxPoolItem& rHt,
Css1FrameSize nMode )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
const SwFormatFrameSize& rFSItem = static_cast<const SwFormatFrameSize&>(rHt);
if( nMode & Css1FrameSize::Width )
{
sal_uInt8 nPercentWidth = rFSItem.GetWidthPercent();
if( nPercentWidth )
{
OString sOut(OString::number(nPercentWidth) + "%");
rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_width, sOut);
}
else if( nMode & Css1FrameSize::Pixel )
{
rHTMLWrt.OutCSS1_PixelProperty( sCSS1_P_width,
rFSItem.GetSize().Width(), false );
}
else
{
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_width,
rFSItem.GetSize().Width() );
}
}
return rWrt;
}
static Writer& OutCSS1_SvxLRSpace( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
const SvxLRSpaceItem& rLRItem = static_cast<const SvxLRSpaceItem&>(rHt);
// No Export of a firm attribute is needed if the new values
// match that of the current template
// A left margin can exist because of a list nearby
tools::Long nLeftMargin = rLRItem.GetTextLeft() - rHTMLWrt.m_nLeftMargin;
if( rHTMLWrt.m_nDfltLeftMargin != nLeftMargin )
{
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_left, nLeftMargin );
// max-width = max-width - margin-left for TOC paragraphs with dot leaders
if( rHTMLWrt.m_bParaDotLeaders )
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_max_width, tools::Long(DOT_LEADERS_MAX_WIDTH/2.54*72*20) - nLeftMargin );
}
if( rHTMLWrt.m_nDfltRightMargin != rLRItem.GetRight() )
{
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_right, rLRItem.GetRight() );
}
// The LineIndent of the first line might contain the room for numbering
tools::Long nFirstLineIndent = static_cast<tools::Long>(rLRItem.GetTextFirstLineOffset()) -
rHTMLWrt.m_nFirstLineIndent;
if( rHTMLWrt.m_nDfltFirstLineIndent != nFirstLineIndent )
{
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_text_indent,
nFirstLineIndent );
}
return rWrt;
}
static Writer& OutCSS1_SvxULSpace( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
const SvxULSpaceItem& rULItem = static_cast<const SvxULSpaceItem&>(rHt);
if( rHTMLWrt.m_nDfltTopMargin != rULItem.GetUpper() )
{
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_top,
static_cast<tools::Long>(rULItem.GetUpper()) );
}
if( rHTMLWrt.m_nDfltBottomMargin != rULItem.GetLower() )
{
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin_bottom,
static_cast<tools::Long>(rULItem.GetLower()) );
}
return rWrt;
}
static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
const SvxULSpaceItem *pULItem,
const SvxLRSpaceItem *pLRItem )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
if( pLRItem && pULItem &&
pLRItem->GetLeft() == pLRItem->GetRight() &&
pLRItem->GetLeft() == pULItem->GetUpper() &&
pLRItem->GetLeft() == pULItem->GetLower() &&
pLRItem->GetLeft() != rHTMLWrt.m_nDfltLeftMargin &&
pLRItem->GetRight() != rHTMLWrt.m_nDfltRightMargin &&
pULItem->GetUpper() != rHTMLWrt.m_nDfltTopMargin &&
pULItem->GetLower() != rHTMLWrt.m_nDfltBottomMargin )
{
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_margin, pLRItem->GetLeft() );
}
else
{
if( pLRItem )
OutCSS1_SvxLRSpace( rWrt, *pLRItem );
if( pULItem )
OutCSS1_SvxULSpace( rWrt, *pULItem );
}
return rWrt;
}
static Writer& OutCSS1_SvxULSpace_SvxLRSpace( Writer& rWrt,
const SfxItemSet& rItemSet )
{
const SvxLRSpaceItem *pLRSpace = rItemSet.GetItemIfSet( RES_LR_SPACE, false/*bDeep*/ );
const SvxULSpaceItem *pULSpace = rItemSet.GetItemIfSet( RES_UL_SPACE, false/*bDeep*/ );
if( pLRSpace || pULSpace )
OutCSS1_SvxULSpace_SvxLRSpace( rWrt, pULSpace, pLRSpace );
return rWrt;
}
static Writer& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( Writer& rWrt,
const SvxFormatBreakItem *pBreakItem,
const SwFormatPageDesc *pPDescItem,
const SvxFormatKeepItem *pKeepItem )
{
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
if( !rHTMLWrt.IsHTMLMode(HTMLMODE_PRINT_EXT) )
return rWrt;
const char *pBreakBefore = nullptr;
const char *pBreakAfter = nullptr;
if( pKeepItem )
{
pBreakAfter = pKeepItem->GetValue() ? sCSS1_PV_avoid : sCSS1_PV_auto;
}
if( pBreakItem )
{
switch( pBreakItem->GetBreak() )
{
case SvxBreak::NONE:
pBreakBefore = sCSS1_PV_auto;
if( !pBreakAfter )
pBreakAfter = sCSS1_PV_auto;
break;
case SvxBreak::PageBefore:
pBreakBefore = sCSS1_PV_always;
break;
case SvxBreak::PageAfter:
pBreakAfter= sCSS1_PV_always;
break;
default:
;
}
}
if( pPDescItem )
{
const SwPageDesc *pPDesc = pPDescItem->GetPageDesc();
if( pPDesc )
{
switch( pPDesc->GetPoolFormatId() )
{
case RES_POOLPAGE_LEFT: pBreakBefore = sCSS1_PV_left; break;
case RES_POOLPAGE_RIGHT: pBreakBefore = sCSS1_PV_right; break;
default: pBreakBefore = sCSS1_PV_always; break;
}
}
else if( !pBreakBefore )
{
pBreakBefore = sCSS1_PV_auto;
}
}
if (rHTMLWrt.mbSkipHeaderFooter)
// No page break when writing only a fragment.
return rWrt;
if( pBreakBefore )
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_before,
pBreakBefore );
if( pBreakAfter )
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_page_break_after,
pBreakAfter );
return rWrt;
}
static Writer& OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( Writer& rWrt,
const SfxItemSet& rItemSet,
bool bDeep )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
const SvxFormatBreakItem *pBreakItem = rItemSet.GetItemIfSet( RES_BREAK, bDeep );
const SwFormatPageDesc *pPDescItem = nullptr;
if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) ||
!rHTMLWrt.m_bCSS1IgnoreFirstPageDesc ||
rHTMLWrt.m_pStartNdIdx->GetIndex() !=
rHTMLWrt.m_pCurrentPam->GetPoint()->nNode.GetIndex() )
pPDescItem = rItemSet.GetItemIfSet( RES_PAGEDESC, bDeep );
const SvxFormatKeepItem *pKeepItem = rItemSet.GetItemIfSet( RES_KEEP, bDeep );
if( pBreakItem || pPDescItem || pKeepItem )
OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( rWrt, pBreakItem,
pPDescItem, pKeepItem );
return rWrt;
}
// Wrapper for OutCSS1_SfxItemSet etc.
static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt )
{
OutCSS1_SvxBrush( rWrt, rHt, sw::Css1Background::Attr, nullptr );
return rWrt;
}
static Writer& OutCSS1_SvxBrush( Writer& rWrt, const SfxPoolItem& rHt,
sw::Css1Background nMode,
const OUString* pGraphicName)
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// The Character-Attribute is skipped, if we are about to
// exporting options
if( rHt.Which() < RES_CHRATR_END &&
rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
return rWrt;
// start getting a few values
// const Brush &rBrush = static_cast<const SvxBrushItem &>(rHt).GetBrush();
const Color & rColor = static_cast<const SvxBrushItem &>(rHt).GetColor();
OUString aLink = pGraphicName ? *pGraphicName
: static_cast<const SvxBrushItem &>(rHt).GetGraphicLink();
SvxGraphicPosition ePos = static_cast<const SvxBrushItem &>(rHt).GetGraphicPos();
if( sw::Css1Background::Page == nMode && !rHTMLWrt.mbEmbedImages )
{
// page style images are exported if not tiled
if( aLink.isEmpty() || GPOS_TILED==ePos )
return rWrt;
}
// get the color
bool bColor = false;
/// set <bTransparent> to true, if color is "no fill"/"auto fill"
bool bTransparent = (rColor == COL_TRANSPARENT);
Color aColor;
if( !bTransparent )
{
aColor = rColor;
bColor = true;
}
// and now the Graphic
OUString aGraphicInBase64;
// Embedded Graphic -> export WriteEmbedded
const Graphic* pGrf = nullptr;
if( rHTMLWrt.mbEmbedImages || aLink.isEmpty())
{
pGrf = static_cast<const SvxBrushItem &>(rHt).GetGraphic();
if( pGrf )
{
if( !XOutBitmap::GraphicToBase64(*pGrf, aGraphicInBase64) )
{
rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
}
}
aLink.clear();
}
else if( !pGraphicName && rHTMLWrt.m_bCfgCpyLinkedGrfs )
{
OUString aGraphicAsLink = aLink;
rWrt.CopyLocalFileToINet( aGraphicAsLink );
aLink = aGraphicAsLink;
}
// In tables we only export something if there is a Graphic
if( (nMode == sw::Css1Background::Table || nMode == sw::Css1Background::TableRow) && !pGrf && !aLink.isEmpty())
return rWrt;
// if necessary, add the orientation of the Graphic
const char *pRepeat = nullptr, *pHori = nullptr, *pVert = nullptr;
if( pGrf || !aLink.isEmpty() )
{
if( GPOS_TILED==ePos )
{
pRepeat = sCSS1_PV_repeat;
}
else
{
switch( ePos )
{
case GPOS_LT:
case GPOS_MT:
case GPOS_RT:
pHori = sCSS1_PV_top;
break;
case GPOS_LM:
case GPOS_MM:
case GPOS_RM:
pHori = sCSS1_PV_middle;
break;
case GPOS_LB:
case GPOS_MB:
case GPOS_RB:
pHori = sCSS1_PV_bottom;
break;
default:
;
}
switch( ePos )
{
case GPOS_LT:
case GPOS_LM:
case GPOS_LB:
pVert = sCSS1_PV_left;
break;
case GPOS_MT:
case GPOS_MM:
case GPOS_MB:
pVert = sCSS1_PV_center;
break;
case GPOS_RT:
case GPOS_RM:
case GPOS_RB:
pVert = sCSS1_PV_right;
break;
default:
;
}
if( pHori || pVert )
pRepeat = sCSS1_PV_no_repeat;
}
}
// now build the string
OUString sOut;
if( !pGrf && aLink.isEmpty() && !bColor )
{
// no color and no Link, but a transparent Brush
if( bTransparent && sw::Css1Background::Fly != nMode )
sOut += OStringToOUString(sCSS1_PV_transparent, RTL_TEXTENCODING_ASCII_US);
}
else
{
if( bColor )
{
OString sTmp(GetCSS1_Color(aColor));
sOut += OStringToOUString(sTmp, RTL_TEXTENCODING_ASCII_US);
}
if( pGrf || !aLink.isEmpty() )
{
if( bColor )
sOut += " ";
if(pGrf)
{
sOut += OStringToOUString(sCSS1_url, RTL_TEXTENCODING_ASCII_US) +
"(\'" OOO_STRING_SVTOOLS_HTML_O_data ":" + aGraphicInBase64 + "\')";
}
else
{
sOut += OStringToOUString(sCSS1_url, RTL_TEXTENCODING_ASCII_US)+
"(" + URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(),
aLink) + ")";
}
if( pRepeat )
{
sOut += " " + OStringToOUString(pRepeat, RTL_TEXTENCODING_ASCII_US);
}
if( pHori )
{
sOut += " " + OStringToOUString(pHori, RTL_TEXTENCODING_ASCII_US);
}
if( pVert )
{
sOut += " " + OStringToOUString(pVert, RTL_TEXTENCODING_ASCII_US);
}
sOut += " " + OStringToOUString(sCSS1_PV_scroll, RTL_TEXTENCODING_ASCII_US) + " ";
}
}
if( !sOut.isEmpty() )
{
rHTMLWrt.OutCSS1_Property(sCSS1_P_background, std::string_view(), &sOut,
nMode);
}
return rWrt;
}
static void OutCSS1_SvxBorderLine( SwHTMLWriter& rHTMLWrt,
const char *pProperty,
const SvxBorderLine *pLine )
{
if( !pLine || pLine->isEmpty() )
{
rHTMLWrt.OutCSS1_PropertyAscii( pProperty, sCSS1_PV_none );
return;
}
sal_Int32 nWidth = pLine->GetWidth();
OStringBuffer sOut;
if( Application::GetDefaultDevice() &&
nWidth <= Application::GetDefaultDevice()->PixelToLogic(
Size( 1, 1 ), MapMode( MapUnit::MapTwip) ).Width() )
{
// If the width is smaller than one pixel, then export as 1px
// so that Netscape and IE show the line.
sOut.append("1px");
}
else
{
nWidth *= 5; // 1/100pt
// width in n.nn pt
sOut.append(OString::number(nWidth / 100) + "." + OString::number((nWidth/10) % 10) +
OString::number(nWidth % 10) + sCSS1_UNIT_pt);
}
// Line-Style: solid or double
sOut.append(' ');
switch (pLine->GetBorderLineStyle())
{
case SvxBorderLineStyle::SOLID:
sOut.append(sCSS1_PV_solid);
break;
case SvxBorderLineStyle::DOTTED:
sOut.append(sCSS1_PV_dotted);
break;
case SvxBorderLineStyle::DASHED:
sOut.append(sCSS1_PV_dashed);
break;
case SvxBorderLineStyle::DOUBLE:
case SvxBorderLineStyle::THINTHICK_SMALLGAP:
case SvxBorderLineStyle::THINTHICK_MEDIUMGAP:
case SvxBorderLineStyle::THINTHICK_LARGEGAP:
case SvxBorderLineStyle::THICKTHIN_SMALLGAP:
case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP:
case SvxBorderLineStyle::THICKTHIN_LARGEGAP:
sOut.append(sCSS1_PV_double);
break;
case SvxBorderLineStyle::EMBOSSED:
sOut.append(sCSS1_PV_ridge);
break;
case SvxBorderLineStyle::ENGRAVED:
sOut.append(sCSS1_PV_groove);
break;
case SvxBorderLineStyle::INSET:
sOut.append(sCSS1_PV_inset);
break;
case SvxBorderLineStyle::OUTSET:
sOut.append(sCSS1_PV_outset);
break;
default:
sOut.append(sCSS1_PV_none);
}
sOut.append(' ');
// and also the color
sOut.append(GetCSS1_Color(pLine->GetColor()));
rHTMLWrt.OutCSS1_PropertyAscii(pProperty, sOut.makeStringAndClear());
}
Writer& OutCSS1_SvxBox( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
// Avoid interference between character and paragraph attributes
if( rHt.Which() < RES_CHRATR_END &&
rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_PARA ) )
return rWrt;
if( rHt.Which() == RES_CHRATR_BOX )
{
if( rHTMLWrt.m_bTagOn )
{
// Inline-block to make the line height changing correspond to the character border
rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_display, "inline-block");
}
else
{
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_span), false );
return rWrt;
}
}
const SvxBoxItem& rBoxItem = static_cast<const SvxBoxItem&>(rHt);
const SvxBorderLine *pTop = rBoxItem.GetTop();
const SvxBorderLine *pBottom = rBoxItem.GetBottom();
const SvxBorderLine *pLeft = rBoxItem.GetLeft();
const SvxBorderLine *pRight = rBoxItem.GetRight();
if( (pTop && pBottom && pLeft && pRight &&
*pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight) ||
(!pTop && !pBottom && !pLeft && !pRight) )
{
// all Lines are set and equal, or all Lines are not set
// => border : ...
OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border, pTop );
}
else
{
// otherwise export all Lines separately
OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_top, pTop );
OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_bottom, pBottom );
OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_left, pLeft );
OutCSS1_SvxBorderLine( rHTMLWrt, sCSS1_P_border_right, pRight );
}
tools::Long nTopDist = pTop ? rBoxItem.GetDistance( SvxBoxItemLine::TOP ) : 0;
tools::Long nBottomDist = pBottom ? rBoxItem.GetDistance( SvxBoxItemLine::BOTTOM ) : 0;
tools::Long nLeftDist = pLeft ? rBoxItem.GetDistance( SvxBoxItemLine::LEFT ) : 0;
tools::Long nRightDist = pRight ? rBoxItem.GetDistance( SvxBoxItemLine::RIGHT ) : 0;
if( nTopDist == nBottomDist && nLeftDist == nRightDist )
{
OStringBuffer sVal;
AddUnitPropertyValue(sVal, nTopDist, rHTMLWrt.GetCSS1Unit());
if( nTopDist != nLeftDist )
{
sVal.append(' ');
AddUnitPropertyValue(sVal, nLeftDist, rHTMLWrt.GetCSS1Unit());
}
rHTMLWrt.OutCSS1_PropertyAscii(sCSS1_P_padding, sVal.makeStringAndClear());
}
else
{
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_top, nTopDist );
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_bottom, nBottomDist );
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_left, nLeftDist );
rHTMLWrt.OutCSS1_UnitProperty( sCSS1_P_padding_right, nRightDist );
}
return rWrt;
}
static Writer& OutCSS1_SvxFrameDirection( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast< SwHTMLWriter& >( rWrt );
// Language will be exported rules only
if( !rHTMLWrt.IsCSS1Source( CSS1_OUTMODE_TEMPLATE ) )
return rWrt;
SvxFrameDirection nDir =
static_cast< const SvxFrameDirectionItem& >( rHt ).GetValue();
const char* pStr = nullptr;
switch( nDir )
{
case SvxFrameDirection::Horizontal_LR_TB:
case SvxFrameDirection::Vertical_LR_TB:
pStr = sCSS1_PV_ltr;
break;
case SvxFrameDirection::Horizontal_RL_TB:
case SvxFrameDirection::Vertical_RL_TB:
pStr = sCSS1_PV_rtl;
break;
case SvxFrameDirection::Environment:
pStr = sCSS1_PV_inherit;
break;
default: break;
}
if( pStr )
rHTMLWrt.OutCSS1_PropertyAscii( sCSS1_P_direction, pStr );
return rWrt;
}
/*
* Place here the table for the HTML-Function-Pointer to the
* Export-Functions.
* They are local structures, only needed within the HTML-DLL.
*/
SwAttrFnTab const aCSS1AttrFnTab = {
/* RES_CHRATR_CASEMAP */ OutCSS1_SvxCaseMap,
/* RES_CHRATR_CHARSETCOLOR */ nullptr,
/* RES_CHRATR_COLOR */ OutCSS1_SvxColor,
/* RES_CHRATR_CONTOUR */ nullptr,
/* RES_CHRATR_CROSSEDOUT */ OutCSS1_SvxCrossedOut,
/* RES_CHRATR_ESCAPEMENT */ nullptr,
/* RES_CHRATR_FONT */ OutCSS1_SvxFont,
/* RES_CHRATR_FONTSIZE */ OutCSS1_SvxFontHeight,
/* RES_CHRATR_KERNING */ OutCSS1_SvxKerning,
/* RES_CHRATR_LANGUAGE */ OutCSS1_SvxLanguage,
/* RES_CHRATR_POSTURE */ OutCSS1_SvxPosture,
/* RES_CHRATR_UNUSED1*/ nullptr,
/* RES_CHRATR_SHADOWED */ nullptr,
/* RES_CHRATR_UNDERLINE */ OutCSS1_SvxUnderline,
/* RES_CHRATR_WEIGHT */ OutCSS1_SvxFontWeight,
/* RES_CHRATR_WORDLINEMODE */ nullptr,
/* RES_CHRATR_AUTOKERN */ nullptr,
/* RES_CHRATR_BLINK */ OutCSS1_SvxBlink,
/* RES_CHRATR_NOHYPHEN */ nullptr, // new: don't separate
/* RES_CHRATR_UNUSED2 */ nullptr,
/* RES_CHRATR_BACKGROUND */ OutCSS1_SvxBrush, // new: character background
/* RES_CHRATR_CJK_FONT */ OutCSS1_SvxFont,
/* RES_CHRATR_CJK_FONTSIZE */ OutCSS1_SvxFontHeight,
/* RES_CHRATR_CJK_LANGUAGE */ OutCSS1_SvxLanguage,
/* RES_CHRATR_CJK_POSTURE */ OutCSS1_SvxPosture,
/* RES_CHRATR_CJK_WEIGHT */ OutCSS1_SvxFontWeight,
/* RES_CHRATR_CTL_FONT */ OutCSS1_SvxFont,
/* RES_CHRATR_CTL_FONTSIZE */ OutCSS1_SvxFontHeight,
/* RES_CHRATR_CTL_LANGUAGE */ OutCSS1_SvxLanguage,
/* RES_CHRATR_CTL_POSTURE */ OutCSS1_SvxPosture,
/* RES_CHRATR_CTL_WEIGHT */ OutCSS1_SvxFontWeight,
/* RES_CHRATR_ROTATE */ nullptr,
/* RES_CHRATR_EMPHASIS_MARK */ nullptr,
/* RES_CHRATR_TWO_LINES */ nullptr,
/* RES_CHRATR_SCALEW */ nullptr,
/* RES_CHRATR_RELIEF */ nullptr,
/* RES_CHRATR_HIDDEN */ OutCSS1_SvxHidden,
/* RES_CHRATR_OVERLINE */ OutCSS1_SvxOverline,
/* RES_CHRATR_RSID */ nullptr,
/* RES_CHRATR_BOX */ OutCSS1_SvxBox,
/* RES_CHRATR_SHADOW */ nullptr,
/* RES_CHRATR_HIGHLIGHT */ nullptr,
/* RES_CHRATR_GRABBAG */ nullptr,
/* RES_CHRATR_BIDIRTL */ nullptr,
/* RES_CHRATR_IDCTHINT */ nullptr,
/* RES_TXTATR_REFMARK */ nullptr,
/* RES_TXTATR_TOXMARK */ nullptr,
/* RES_TXTATR_META */ nullptr,
/* RES_TXTATR_METAFIELD */ nullptr,
/* RES_TXTATR_AUTOFMT */ nullptr,
/* RES_TXTATR_INETFMT */ nullptr,
/* RES_TXTATR_CHARFMT */ nullptr,
/* RES_TXTATR_CJK_RUBY */ nullptr,
/* RES_TXTATR_UNKNOWN_CONTAINER */ nullptr,
/* RES_TXTATR_INPUTFIELD */ nullptr,
/* RES_TXTATR_CONTENTCONTROL */ nullptr,
/* RES_TXTATR_FIELD */ nullptr,
/* RES_TXTATR_FLYCNT */ nullptr,
/* RES_TXTATR_FTN */ nullptr,
/* RES_TXTATR_ANNOTATION */ nullptr,
/* RES_TXTATR_LINEBREAK */ nullptr,
/* RES_TXTATR_DUMMY1 */ nullptr, // Dummy:
/* RES_PARATR_LINESPACING */ OutCSS1_SvxLineSpacing,
/* RES_PARATR_ADJUST */ OutCSS1_SvxAdjust,
/* RES_PARATR_SPLIT */ OutCSS1_SvxFormatSplit,
/* RES_PARATR_ORPHANS */ OutCSS1_SvxOrphans,
/* RES_PARATR_WIDOWS */ OutCSS1_SvxWidows,
/* RES_PARATR_TABSTOP */ nullptr,
/* RES_PARATR_HYPHENZONE*/ nullptr,
/* RES_PARATR_DROP */ OutCSS1_SwFormatDrop,
/* RES_PARATR_REGISTER */ nullptr, // new: register-true
/* RES_PARATR_NUMRULE */ nullptr,
/* RES_PARATR_SCRIPTSPACE */ nullptr,
/* RES_PARATR_HANGINGPUNCTUATION */ nullptr,
/* RES_PARATR_FORBIDDEN_RULES */ nullptr, // new
/* RES_PARATR_VERTALIGN */ nullptr, // new
/* RES_PARATR_SNAPTOGRID*/ nullptr, // new
/* RES_PARATR_CONNECT_TO_BORDER */ nullptr, // new
/* RES_PARATR_OUTLINELEVEL */ nullptr, // new since cws outlinelevel
/* RES_PARATR_RSID */ nullptr, // new
/* RES_PARATR_GRABBAG */ nullptr,
/* RES_PARATR_LIST_ID */ nullptr, // new
/* RES_PARATR_LIST_LEVEL */ nullptr, // new
/* RES_PARATR_LIST_ISRESTART */ nullptr, // new
/* RES_PARATR_LIST_RESTARTVALUE */ nullptr, // new
/* RES_PARATR_LIST_ISCOUNTED */ nullptr, // new
/* RES_PARATR_LIST_AUTOFMT */ nullptr, // new
/* RES_FILL_ORDER */ nullptr,
/* RES_FRM_SIZE */ nullptr,
/* RES_PAPER_BIN */ nullptr,
/* RES_LR_SPACE */ OutCSS1_SvxLRSpace,
/* RES_UL_SPACE */ OutCSS1_SvxULSpace,
/* RES_PAGEDESC */ nullptr,
/* RES_BREAK */ nullptr,
/* RES_CNTNT */ nullptr,
/* RES_HEADER */ nullptr,
/* RES_FOOTER */ nullptr,
/* RES_PRINT */ nullptr,
/* RES_OPAQUE */ nullptr,
/* RES_PROTECT */ nullptr,
/* RES_SURROUND */ nullptr,
/* RES_VERT_ORIENT */ nullptr,
/* RES_HORI_ORIENT */ nullptr,
/* RES_ANCHOR */ nullptr,
/* RES_BACKGROUND */ OutCSS1_SvxBrush,
/* RES_BOX */ OutCSS1_SvxBox,
/* RES_SHADOW */ nullptr,
/* RES_FRMMACRO */ nullptr,
/* RES_COL */ nullptr,
/* RES_KEEP */ nullptr,
/* RES_URL */ nullptr,
/* RES_EDIT_IN_READONLY */ nullptr,
/* RES_LAYOUT_SPLIT */ nullptr,
/* RES_CHAIN */ nullptr,
/* RES_TEXTGRID */ nullptr,
/* RES_LINENUMBER */ nullptr,
/* RES_FTN_AT_TXTEND */ nullptr,
/* RES_END_AT_TXTEND */ nullptr,
/* RES_COLUMNBALANCE */ nullptr,
/* RES_FRAMEDIR */ OutCSS1_SvxFrameDirection,
/* RES_HEADER_FOOTER_EAT_SPACING */ nullptr,
/* RES_ROW_SPLIT */ nullptr,
/* RES_FOLLOW_TEXT_FLOW */ nullptr,
/* RES_COLLAPSING_BORDERS */ nullptr,
/* RES_WRAP_INFLUENCE_ON_OBJPOS */ nullptr,
/* RES_AUTO_STYLE */ nullptr,
/* RES_FRMATR_STYLE_NAME */ nullptr,
/* RES_FRMATR_CONDITIONAL_STYLE_NAME */ nullptr,
/* RES_FRMATR_GRABBAG */ nullptr,
/* RES_TEXT_VERT_ADJUST */ nullptr,
/* RES_GRFATR_MIRRORGRF */ nullptr,
/* RES_GRFATR_CROPGRF */ nullptr,
/* RES_GRFATR_ROTATION */ nullptr,
/* RES_GRFATR_LUMINANCE */ nullptr,
/* RES_GRFATR_CONTRAST */ nullptr,
/* RES_GRFATR_CHANNELR */ nullptr,
/* RES_GRFATR_CHANNELG */ nullptr,
/* RES_GRFATR_CHANNELB */ nullptr,
/* RES_GRFATR_GAMMA */ nullptr,
/* RES_GRFATR_INVERT */ nullptr,
/* RES_GRFATR_TRANSPARENCY */ nullptr,
/* RES_GRFATR_DRWAMODE */ nullptr,
/* RES_GRFATR_DUMMY1 */ nullptr,
/* RES_GRFATR_DUMMY2 */ nullptr,
/* RES_GRFATR_DUMMY3 */ nullptr,
/* RES_GRFATR_DUMMY4 */ nullptr,
/* RES_GRFATR_DUMMY5 */ nullptr,
/* RES_BOXATR_FORMAT */ nullptr,
/* RES_BOXATR_FORMULA */ nullptr,
/* RES_BOXATR_VALUE */ nullptr
};
static_assert(SAL_N_ELEMENTS(aCSS1AttrFnTab) == RES_BOXATR_END);
void SwHTMLWriter::OutCSS1_SfxItemSet( const SfxItemSet& rItemSet,
bool bDeep )
{
// print ItemSet, including all attributes
Out_SfxItemSet( aCSS1AttrFnTab, *this, rItemSet, bDeep );
// some Attributes require special treatment
// Underline, Overline, CrossedOut and Blink form together a CSS1-Property
// (doesn't work of course for Hints)
if( !IsCSS1Source(CSS1_OUTMODE_HINT) )
{
const SvxUnderlineItem *pUnderlineItem =
rItemSet.GetItemIfSet( RES_CHRATR_UNDERLINE, bDeep );
const SvxOverlineItem *pOverlineItem =
rItemSet.GetItemIfSet( RES_CHRATR_OVERLINE, bDeep );
const SvxCrossedOutItem *pCrossedOutItem =
rItemSet.GetItemIfSet( RES_CHRATR_CROSSEDOUT, bDeep );
const SvxBlinkItem *pBlinkItem =
rItemSet.GetItemIfSet( RES_CHRATR_BLINK, bDeep );
if( pUnderlineItem || pOverlineItem || pCrossedOutItem || pBlinkItem )
OutCSS1_SvxTextLn_SvxCrOut_SvxBlink( *this, pUnderlineItem,
pOverlineItem,
pCrossedOutItem,
pBlinkItem );
OutCSS1_SvxFormatBreak_SwFormatPDesc_SvxFormatKeep( *this, rItemSet, bDeep );
}
if( m_bFirstCSS1Property )
return;
// if a Property was exported as part of a Style-Option,
// the Option still needs to be finished
OStringBuffer sOut;
switch( m_nCSS1OutMode & CSS1_OUTMODE_ANY_OFF )
{
case CSS1_OUTMODE_SPAN_TAG_OFF:
sOut.append(sCSS1_span_tag_end);
break;
case CSS1_OUTMODE_STYLE_OPT_OFF:
sOut.append(cCSS1_style_opt_end);
break;
case CSS1_OUTMODE_RULE_OFF:
sOut.append(sCSS1_rule_end);
break;
}
if (!sOut.isEmpty())
Strm().WriteOString( sOut.makeStringAndClear() );
}
Writer& OutCSS1_HintSpanTag( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_SPAN_TAG |
CSS1_OUTMODE_ENCODE|CSS1_OUTMODE_HINT, nullptr );
Out( aCSS1AttrFnTab, rHt, rWrt );
if( !rHTMLWrt.m_bFirstCSS1Property && rHTMLWrt.m_bTagOn )
rWrt.Strm().WriteCharPtr( sCSS1_span_tag_end );
return rWrt;
}
Writer& OutCSS1_HintStyleOpt( Writer& rWrt, const SfxPoolItem& rHt )
{
SwHTMLWriter& rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
SwCSS1OutMode aMode( rHTMLWrt, CSS1_OUTMODE_STYLE_OPT_ON |
CSS1_OUTMODE_ENCODE|
CSS1_OUTMODE_HINT, nullptr );
Out( aCSS1AttrFnTab, rHt, rWrt );
if( !rHTMLWrt.m_bFirstCSS1Property )
rWrt.Strm().WriteChar( '\"' );
return rWrt;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|