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
|
/* -*- 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 <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include "scitems.hxx"
#include <editeng/borderline.hxx>
#include <editeng/eeitem.hxx>
#include <sfx2/app.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/newstyle.hxx>
#include <sfx2/objface.hxx>
#include <sfx2/request.hxx>
#include <svl/whiter.hxx>
#include <vcl/msgbox.hxx>
#include <svl/stritem.hxx>
#include <svl/zformat.hxx>
#include <svl/languageoptions.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/langitem.hxx>
#include <svx/numinf.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/templdlg.hxx>
#include <sfx2/tplpitem.hxx>
#include <editeng/svxenum.hxx>
#include <svx/algitem.hxx>
#include <editeng/wghtitem.hxx>
#include <editeng/postitem.hxx>
#include <editeng/udlnitem.hxx>
#include <editeng/lineitem.hxx>
#include <editeng/colritem.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/frmdiritem.hxx>
#include <editeng/scripttypeitem.hxx>
#include <svtools/colorcfg.hxx>
#include <editeng/shaditem.hxx>
#include <editeng/justifyitem.hxx>
#include <editeng/fhgtitem.hxx>
#include "formatsh.hxx"
#include "sc.hrc"
#include "globstr.hrc"
#include "docsh.hxx"
#include "patattr.hxx"
#include "scmod.hxx"
#include "stlpool.hxx"
#include "stlsheet.hxx"
#include "printfun.hxx"
#include "docpool.hxx"
#include "scresid.hxx"
#include "tabvwsh.hxx"
#include "undostyl.hxx"
#include "markdata.hxx"
#include "markarr.hxx"
#define ScFormatShell
#define TableFont
#define FormatForSelection
#include "scslots.hxx"
#include "scabstdlg.hxx"
#include <editeng/fontitem.hxx>
#include <sfx2/classificationhelper.hxx>
#include <memory>
using namespace ::com::sun::star;
namespace {
SvxCellHorJustify lclConvertSlotToHAlign( sal_uInt16 nSlot )
{
SvxCellHorJustify eHJustify = SVX_HOR_JUSTIFY_STANDARD;
switch( nSlot )
{
case SID_ALIGN_ANY_HDEFAULT: eHJustify = SVX_HOR_JUSTIFY_STANDARD; break;
case SID_ALIGN_ANY_LEFT: eHJustify = SVX_HOR_JUSTIFY_LEFT; break;
case SID_ALIGN_ANY_HCENTER: eHJustify = SVX_HOR_JUSTIFY_CENTER; break;
case SID_ALIGN_ANY_RIGHT: eHJustify = SVX_HOR_JUSTIFY_RIGHT; break;
case SID_ALIGN_ANY_JUSTIFIED: eHJustify = SVX_HOR_JUSTIFY_BLOCK; break;
default: OSL_FAIL( "lclConvertSlotToHAlign - invalid slot" );
}
return eHJustify;
}
SvxCellVerJustify lclConvertSlotToVAlign( sal_uInt16 nSlot )
{
SvxCellVerJustify eVJustify = SVX_VER_JUSTIFY_STANDARD;
switch( nSlot )
{
case SID_ALIGN_ANY_VDEFAULT: eVJustify = SVX_VER_JUSTIFY_STANDARD; break;
case SID_ALIGN_ANY_TOP: eVJustify = SVX_VER_JUSTIFY_TOP; break;
case SID_ALIGN_ANY_VCENTER: eVJustify = SVX_VER_JUSTIFY_CENTER; break;
case SID_ALIGN_ANY_BOTTOM: eVJustify = SVX_VER_JUSTIFY_BOTTOM; break;
default: OSL_FAIL( "lclConvertSlotToVAlign - invalid slot" );
}
return eVJustify;
}
} // namespace
SFX_IMPL_INTERFACE(ScFormatShell, SfxShell)
void ScFormatShell::InitInterface_Impl()
{
GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_SERVER,
RID_OBJECTBAR_FORMAT);
}
ScFormatShell::ScFormatShell(ScViewData* pData) :
SfxShell(pData->GetViewShell()),
pViewData(pData)
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
SetPool( &pTabViewShell->GetPool() );
::svl::IUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
SetUndoManager( pMgr );
if ( !pViewData->GetDocument()->IsUndoEnabled() )
{
pMgr->SetMaxUndoActionCount( 0 );
}
SetHelpId(HID_SCSHELL_FORMATSH);
SetName("Format");
}
ScFormatShell::~ScFormatShell()
{
}
void ScFormatShell::GetStyleState( SfxItemSet& rSet )
{
ScDocument* pDoc = GetViewData()->GetDocument();
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool();
bool bProtected = false;
SCTAB nTabCount = pDoc->GetTableCount();
for (SCTAB i=0; i<nTabCount; i++)
if (pDoc->IsTabProtected(i)) // look after protected table
bProtected = true;
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
sal_uInt16 nSlotId = 0;
while ( nWhich )
{
nSlotId = SfxItemPool::IsWhich( nWhich )
? GetPool().GetSlotId( nWhich )
: nWhich;
switch ( nSlotId )
{
case SID_STYLE_APPLY:
if ( !pStylePool )
rSet.DisableItem( nSlotId );
break;
case SID_STYLE_FAMILY2: // cell style sheets
{
SfxStyleSheet* pStyleSheet = const_cast<SfxStyleSheet*>(
pTabViewShell->GetStyleSheetFromMarked());
if ( pStyleSheet )
rSet.Put( SfxTemplateItem( nSlotId, pStyleSheet->GetName() ) );
else
rSet.Put( SfxTemplateItem( nSlotId, OUString() ) );
}
break;
case SID_STYLE_FAMILY4: // page style sheets
{
SCTAB nCurTab = GetViewData()->GetTabNo();
OUString aPageStyle = pDoc->GetPageStyle( nCurTab );
SfxStyleSheet* pStyleSheet = pStylePool ? static_cast<SfxStyleSheet*>(pStylePool->
Find( aPageStyle, SfxStyleFamily::Page )) : nullptr;
if ( pStyleSheet )
rSet.Put( SfxTemplateItem( nSlotId, aPageStyle ) );
else
rSet.Put( SfxTemplateItem( nSlotId, OUString() ) );
}
break;
case SID_STYLE_WATERCAN:
{
rSet.Put( SfxBoolItem( nSlotId, SC_MOD()->GetIsWaterCan() ) );
}
break;
case SID_STYLE_UPDATE_BY_EXAMPLE:
{
std::unique_ptr<SfxPoolItem> pItem;
pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
bool bPage = pFamilyItem && SfxStyleFamily::Page == static_cast<SfxStyleFamily>(pFamilyItem->GetValue());
if ( bProtected || bPage )
rSet.DisableItem( nSlotId );
}
break;
case SID_STYLE_EDIT:
case SID_STYLE_DELETE:
case SID_STYLE_HIDE:
case SID_STYLE_SHOW:
{
std::unique_ptr<SfxPoolItem> pItem;
pTabViewShell->GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pItem);
SfxUInt16Item* pFamilyItem = dynamic_cast<SfxUInt16Item*>(pItem.get());
bool bPage = pFamilyItem && SfxStyleFamily::Page == static_cast<SfxStyleFamily>(pFamilyItem->GetValue());
if ( bProtected && !bPage )
rSet.DisableItem( nSlotId );
}
break;
default:
break;
}
nWhich = aIter.NextWhich();
}
}
void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
{
const SfxItemSet* pArgs = rReq.GetArgs();
const sal_uInt16 nSlotId = rReq.GetSlot();
if ( !pArgs && nSlotId != SID_STYLE_NEW_BY_EXAMPLE && nSlotId != SID_STYLE_UPDATE_BY_EXAMPLE )
{
// in case of vertical toolbar
pViewData->GetDispatcher().Execute( SID_STYLE_DESIGNER, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
return;
}
SfxBindings& rBindings = pViewData->GetBindings();
const SCTAB nCurTab = GetViewData()->GetTabNo();
ScDocShell* pDocSh = GetViewData()->GetDocShell();
ScTabViewShell* pTabViewShell= GetViewData()->GetViewShell();
ScDocument& rDoc = pDocSh->GetDocument();
ScMarkData& rMark = GetViewData()->GetMarkData();
ScModule* pScMod = SC_MOD();
OUString aRefName;
bool bUndo = rDoc.IsUndoEnabled();
SfxStyleSheetBasePool* pStylePool = rDoc.GetStyleSheetPool();
if ( (nSlotId == SID_STYLE_PREVIEW)
|| (nSlotId == SID_STYLE_END_PREVIEW) )
{
if (nSlotId == SID_STYLE_PREVIEW)
{
SfxStyleFamily eFamily = SfxStyleFamily::Para;
const SfxPoolItem* pFamItem;
if ( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILY, true, &pFamItem ) )
eFamily = (SfxStyleFamily) static_cast<const SfxUInt16Item*>(pFamItem)->GetValue();
const SfxPoolItem* pNameItem;
OUString aStyleName;
if (pArgs && SfxItemState::SET == pArgs->GetItemState( nSlotId, true, &pNameItem ))
aStyleName = static_cast<const SfxStringItem*>(pNameItem)->GetValue();
if ( eFamily == SfxStyleFamily::Para ) // CellStyles
{
ScMarkData aFuncMark( pViewData->GetMarkData() );
ScViewUtil::UnmarkFiltered( aFuncMark, &rDoc );
aFuncMark.MarkToMulti();
if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
{
SCCOL nCol = pViewData->GetCurX();
SCROW nRow = pViewData->GetCurY();
SCTAB nTab = pViewData->GetTabNo();
ScRange aRange( nCol, nRow, nTab );
aFuncMark.SetMarkArea( aRange );
}
rDoc.SetPreviewSelection( aFuncMark );
ScStyleSheet* pPreviewStyle = static_cast<ScStyleSheet*>( pStylePool->Find( aStyleName, eFamily ) );
rDoc.SetPreviewCellStyle( pPreviewStyle );
ScPatternAttr aAttr( *rDoc.GetSelectionPattern( aFuncMark ) );
aAttr.SetStyleSheet( pPreviewStyle );
SfxItemSet aItemSet( GetPool() );
ScPatternAttr aNewAttrs( GetViewData()->GetDocument()->GetPool() );
SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
rNewSet.Put( aItemSet, false );
rDoc.ApplySelectionPattern( aNewAttrs, rDoc.GetPreviewSelection() );
pTabViewShell->UpdateSelectionArea( aFuncMark, &aAttr );
}
}
else
{
// No mark at all happens when creating a new document, in which
// case the selection pattern obtained would be empty (created of
// GetPool()) anyway and nothing needs to be applied.
ScMarkData aPreviewMark( rDoc.GetPreviewSelection());
if (aPreviewMark.IsMarked() || aPreviewMark.IsMultiMarked())
{
ScPatternAttr aAttr( *rDoc.GetSelectionPattern( aPreviewMark ) );
if ( ScStyleSheet* pPreviewStyle = rDoc.GetPreviewCellStyle() )
aAttr.SetStyleSheet( pPreviewStyle );
rDoc.SetPreviewCellStyle(nullptr);
SfxItemSet aItemSet( GetPool() );
ScPatternAttr aNewAttrs( GetViewData()->GetDocument()->GetPool() );
SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
rNewSet.Put( aItemSet, false );
rDoc.ApplySelectionPattern( aNewAttrs, aPreviewMark );
pTabViewShell->UpdateSelectionArea( aPreviewMark, &aAttr );
}
}
}
else if ( (nSlotId == SID_STYLE_NEW)
|| (nSlotId == SID_STYLE_EDIT)
|| (nSlotId == SID_STYLE_DELETE)
|| (nSlotId == SID_STYLE_HIDE)
|| (nSlotId == SID_STYLE_SHOW)
|| (nSlotId == SID_STYLE_APPLY)
|| (nSlotId == SID_STYLE_WATERCAN)
|| (nSlotId == SID_STYLE_FAMILY)
|| (nSlotId == SID_STYLE_NEW_BY_EXAMPLE)
|| (nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE) )
{
SfxStyleSheetBase* pStyleSheet = nullptr;
bool bStyleToMarked = false;
bool bListAction = false;
bool bAddUndo = false; // add ScUndoModifyStyle (style modified)
ScStyleSaveData aOldData; // for undo/redo
ScStyleSaveData aNewData;
SfxStyleFamily eFamily = SfxStyleFamily::Para;
const SfxPoolItem* pFamItem;
if ( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILY, true, &pFamItem ) )
eFamily = (SfxStyleFamily) static_cast<const SfxUInt16Item*>(pFamItem)->GetValue();
else if ( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME, true, &pFamItem ) )
{
OUString sFamily = static_cast<const SfxStringItem*>(pFamItem)->GetValue();
if (sFamily == "CellStyles")
eFamily = SfxStyleFamily::Para;
else if (sFamily == "PageStyles")
eFamily = SfxStyleFamily::Page;
}
OUString aStyleName;
sal_uInt16 nRetMask = 0xffff;
pStylePool->SetSearchMask( eFamily );
switch ( nSlotId )
{
case SID_STYLE_NEW:
{
const SfxPoolItem* pNameItem;
if (pArgs && SfxItemState::SET == pArgs->GetItemState( nSlotId, true, &pNameItem ))
aStyleName = static_cast<const SfxStringItem*>(pNameItem)->GetValue();
const SfxPoolItem* pRefItem=nullptr;
if (pArgs && SfxItemState::SET == pArgs->GetItemState( SID_STYLE_REFERENCE, true, &pRefItem ))
{
if(pRefItem!=nullptr)
aRefName = static_cast<const SfxStringItem*>(pRefItem)->GetValue();
}
pStyleSheet = &(pStylePool->Make( aStyleName, eFamily,
SFXSTYLEBIT_USERDEF ) );
if ( pStyleSheet && pStyleSheet->HasParentSupport() )
pStyleSheet->SetParent(aRefName);
}
break;
case SID_STYLE_APPLY:
{
const SfxStringItem* pNameItem = rReq.GetArg<SfxStringItem>(SID_APPLY_STYLE);
const SfxStringItem* pFamilyItem = rReq.GetArg<SfxStringItem>(SID_STYLE_FAMILYNAME);
if ( pFamilyItem && pNameItem )
{
css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(pDocSh->GetModel(), css::uno::UNO_QUERY);
try
{
css::uno::Reference< css::container::XNameAccess > xStyles;
css::uno::Reference< css::container::XNameAccess > xCont = xModel->getStyleFamilies();
xCont->getByName(pFamilyItem->GetValue()) >>= xStyles;
css::uno::Reference< css::beans::XPropertySet > xInfo;
xStyles->getByName( pNameItem->GetValue() ) >>= xInfo;
OUString aUIName;
xInfo->getPropertyValue("DisplayName") >>= aUIName;
if ( !aUIName.isEmpty() )
rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) );
}
catch( css::uno::Exception& )
{
}
}
SAL_FALLTHROUGH;
}
case SID_STYLE_EDIT:
case SID_STYLE_DELETE:
case SID_STYLE_HIDE:
case SID_STYLE_SHOW:
case SID_STYLE_NEW_BY_EXAMPLE:
{
const SfxPoolItem* pNameItem;
if (pArgs && SfxItemState::SET == pArgs->GetItemState( nSlotId, true, &pNameItem ))
aStyleName = static_cast<const SfxStringItem*>(pNameItem)->GetValue();
else if ( nSlotId == SID_STYLE_NEW_BY_EXAMPLE )
{
ScopedVclPtrInstance<SfxNewStyleDlg> pDlg( nullptr, *pStylePool );
if ( RET_OK != pDlg->Execute() )
return;
aStyleName = pDlg->GetName();
}
pStyleSheet = pStylePool->Find( aStyleName, eFamily );
aOldData.InitFromStyle( pStyleSheet );
}
break;
case SID_STYLE_WATERCAN:
{
bool bWaterCan = pScMod->GetIsWaterCan();
if( !bWaterCan )
{
const SfxPoolItem* pItem;
if ( SfxItemState::SET ==
pArgs->GetItemState( nSlotId, true, &pItem ) )
{
const SfxStringItem* pStrItem = dynamic_cast< const SfxStringItem *>( pItem );
if ( pStrItem )
{
aStyleName = pStrItem->GetValue();
pStyleSheet = pStylePool->Find( aStyleName, eFamily );
if ( pStyleSheet )
{
static_cast<ScStyleSheetPool*>(pStylePool)->
SetActualStyleSheet( pStyleSheet );
rReq.Done();
}
}
}
}
if ( !bWaterCan && pStyleSheet )
{
pScMod->SetWaterCan( true );
pTabViewShell->SetActivePointer( Pointer(PointerStyle::Fill) );
rReq.Done();
}
else
{
pScMod->SetWaterCan( false );
pTabViewShell->SetActivePointer( Pointer(PointerStyle::Arrow) );
rReq.Done();
}
}
break;
default:
break;
}
// set new style for paintbrush format mode
if ( nSlotId == SID_STYLE_APPLY && pScMod->GetIsWaterCan() && pStyleSheet )
static_cast<ScStyleSheetPool*>(pStylePool)->SetActualStyleSheet( pStyleSheet );
switch ( eFamily )
{
case SfxStyleFamily::Para:
{
switch ( nSlotId )
{
case SID_STYLE_DELETE:
{
if ( pStyleSheet )
{
pTabViewShell->RemoveStyleSheetInUse( pStyleSheet );
pStylePool->Remove( pStyleSheet );
pTabViewShell->InvalidateAttribs();
nRetMask = sal_uInt16(true);
bAddUndo = true;
rReq.Done();
}
else
nRetMask = sal_uInt16(false);
}
break;
case SID_STYLE_HIDE:
case SID_STYLE_SHOW:
{
if ( pStyleSheet )
{
pStyleSheet->SetHidden( nSlotId == SID_STYLE_HIDE );
pTabViewShell->InvalidateAttribs();
rReq.Done();
}
else
nRetMask = sal_uInt16(false);
}
break;
case SID_STYLE_APPLY:
{
if ( pStyleSheet && !pScMod->GetIsWaterCan() )
{
// apply style sheet to document
pTabViewShell->SetStyleSheetToMarked( static_cast<SfxStyleSheet*>(pStyleSheet) );
pTabViewShell->InvalidateAttribs();
rReq.Done();
}
}
break;
case SID_STYLE_NEW_BY_EXAMPLE:
case SID_STYLE_UPDATE_BY_EXAMPLE:
{
// create/replace style sheet by attributes
// at cursor position:
const ScPatternAttr* pAttrItem = nullptr;
// The query if marked, was always wrong here,
// so now no more, and just from the cursor.
// If attributes are to be removed from the selection, still need to be
// cautious not to adopt items from templates
// (GetSelectionPattern also collects items from originals) (# 44748 #)
SCCOL nCol = pViewData->GetCurX();
SCROW nRow = pViewData->GetCurY();
pAttrItem = rDoc.GetPattern( nCol, nRow, nCurTab );
SfxItemSet aAttrSet = pAttrItem->GetItemSet();
aAttrSet.ClearItem( ATTR_MERGE );
aAttrSet.ClearItem( ATTR_MERGE_FLAG );
// Do not adopt conditional formatting and validity,
// because they can not be edited in the template
aAttrSet.ClearItem( ATTR_VALIDDATA );
aAttrSet.ClearItem( ATTR_CONDITIONAL );
if ( SID_STYLE_NEW_BY_EXAMPLE == nSlotId )
{
if ( bUndo )
{
OUString aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE );
pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
bListAction = true;
}
bool bConvertBack = false;
SfxStyleSheet* pSheetInUse = const_cast<SfxStyleSheet*>(
pTabViewShell->GetStyleSheetFromMarked());
// when a new style is present and is used in the selection,
// then the parent can not be adopted:
if ( pStyleSheet && pSheetInUse && pStyleSheet == pSheetInUse )
pSheetInUse = nullptr;
// if already present, first remove ...
if ( pStyleSheet )
{
// style pointer to names before erase,
// otherwise cells will get invalid pointer
//!!! As it happens, a method that does it for a particular style
rDoc.StylesToNames();
bConvertBack = true;
pStylePool->Remove(pStyleSheet);
}
// ...and create new
pStyleSheet = &pStylePool->Make( aStyleName, eFamily,
SFXSTYLEBIT_USERDEF );
// when a style is present, then this will become
// the parent of the new style:
if ( pSheetInUse && pStyleSheet->HasParentSupport() )
pStyleSheet->SetParent( pSheetInUse->GetName() );
if ( bConvertBack )
// Name to style pointer
rDoc.UpdStlShtPtrsFrmNms();
else
rDoc.GetPool()->CellStyleCreated( aStyleName, &rDoc );
// Adopt attribute and use style
pStyleSheet->GetItemSet().Put( aAttrSet );
pTabViewShell->UpdateStyleSheetInUse( pStyleSheet );
// call SetStyleSheetToMarked after adding the ScUndoModifyStyle
// (pStyleSheet pointer is used!)
bStyleToMarked = true;
}
else // ( nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE )
{
pStyleSheet = const_cast<SfxStyleSheet*>(pTabViewShell->GetStyleSheetFromMarked());
if ( pStyleSheet )
{
aOldData.InitFromStyle( pStyleSheet );
if ( bUndo )
{
OUString aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE );
pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
bListAction = true;
}
pStyleSheet->GetItemSet().Put( aAttrSet );
pTabViewShell->UpdateStyleSheetInUse( pStyleSheet );
// call SetStyleSheetToMarked after adding the ScUndoModifyStyle
// (pStyleSheet pointer is used!)
bStyleToMarked = true;
}
}
aNewData.InitFromStyle( pStyleSheet );
bAddUndo = true;
rReq.Done();
}
break;
default:
break;
}
} // case SfxStyleFamily::Para:
break;
case SfxStyleFamily::Page:
{
switch ( nSlotId )
{
case SID_STYLE_DELETE:
{
nRetMask = sal_uInt16( nullptr != pStyleSheet );
if ( pStyleSheet )
{
if ( rDoc.RemovePageStyleInUse( pStyleSheet->GetName() ) )
{
ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(true), nCurTab ).UpdatePages();
rBindings.Invalidate( SID_STATUS_PAGESTYLE );
rBindings.Invalidate( FID_RESET_PRINTZOOM );
}
pStylePool->Remove( pStyleSheet );
rBindings.Invalidate( SID_STYLE_FAMILY4 );
pDocSh->SetDocumentModified();
bAddUndo = true;
rReq.Done();
}
}
break;
case SID_STYLE_HIDE:
case SID_STYLE_SHOW:
{
nRetMask = sal_uInt16( nullptr != pStyleSheet );
if ( pStyleSheet )
{
pStyleSheet->SetHidden( nSlotId == SID_STYLE_HIDE );
rBindings.Invalidate( SID_STYLE_FAMILY4 );
pDocSh->SetDocumentModified();
rReq.Done();
}
}
break;
case SID_STYLE_APPLY:
{
nRetMask = sal_uInt16( nullptr != pStyleSheet );
if ( pStyleSheet && !pScMod->GetIsWaterCan() )
{
ScUndoApplyPageStyle* pUndoAction = nullptr;
SCTAB nTabCount = rDoc.GetTableCount();
ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
for (; itr != itrEnd && *itr < nTabCount; ++itr)
{
OUString aOldName = rDoc.GetPageStyle( *itr );
if ( aOldName != aStyleName )
{
rDoc.SetPageStyle( *itr, aStyleName );
ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(true), *itr ).UpdatePages();
if( !pUndoAction )
pUndoAction = new ScUndoApplyPageStyle( pDocSh, aStyleName );
pUndoAction->AddSheetAction( *itr, aOldName );
}
}
if( pUndoAction )
{
pDocSh->GetUndoManager()->AddUndoAction( pUndoAction );
pDocSh->SetDocumentModified();
rBindings.Invalidate( SID_STYLE_FAMILY4 );
rBindings.Invalidate( SID_STATUS_PAGESTYLE );
rBindings.Invalidate( FID_RESET_PRINTZOOM );
}
rReq.Done();
}
}
break;
case SID_STYLE_NEW_BY_EXAMPLE:
{
const OUString& rStrCurStyle = rDoc.GetPageStyle( nCurTab );
if ( rStrCurStyle != aStyleName )
{
SfxStyleSheetBase* pCurStyle = pStylePool->Find( rStrCurStyle, eFamily );
SfxItemSet aAttrSet = pCurStyle->GetItemSet();
SCTAB nInTab;
bool bUsed = rDoc.IsPageStyleInUse( aStyleName, &nInTab );
// if already present, first remove...
if ( pStyleSheet )
pStylePool->Remove( pStyleSheet );
// ...and create new
pStyleSheet = &pStylePool->Make( aStyleName, eFamily,
SFXSTYLEBIT_USERDEF );
// Adopt attribute
pStyleSheet->GetItemSet().Put( aAttrSet );
pDocSh->SetDocumentModified();
// If being used -> Update
if ( bUsed )
ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(true), nInTab ).UpdatePages();
aNewData.InitFromStyle( pStyleSheet );
bAddUndo = true;
rReq.Done();
nRetMask = sal_uInt16(true);
}
}
break;
default:
break;
} // switch ( nSlotId )
} // case SfxStyleFamily::Page:
break;
default:
break;
} // switch ( eFamily )
// create new or process through Dialog:
if ( nSlotId == SID_STYLE_NEW || nSlotId == SID_STYLE_EDIT )
{
if ( pStyleSheet )
{
SfxStyleFamily eFam = pStyleSheet->GetFamily();
std::unique_ptr<SfxAbstractTabDialog> pDlg;
sal_uInt16 nRsc = 0;
// Store old Items from the style
SfxItemSet aOldSet = pStyleSheet->GetItemSet();
OUString aOldName = pStyleSheet->GetName();
switch ( eFam )
{
case SfxStyleFamily::Page:
nRsc = RID_SCDLG_STYLES_PAGE;
break;
case SfxStyleFamily::Para:
default:
{
SfxItemSet& rSet = pStyleSheet->GetItemSet();
const SfxPoolItem* pItem;
if ( rSet.GetItemState( ATTR_VALUE_FORMAT,
false, &pItem ) == SfxItemState::SET )
{
// Produce and format NumberFormat Value from Value and Language
sal_uLong nFormat =
static_cast<const SfxUInt32Item*>(pItem)->GetValue();
LanguageType eLang =
static_cast<const SvxLanguageItem*>(&rSet.Get(
ATTR_LANGUAGE_FORMAT ))->GetLanguage();
sal_uLong nLangFormat = rDoc.GetFormatTable()->
GetFormatForLanguageIfBuiltIn( nFormat, eLang );
if ( nLangFormat != nFormat )
{
SfxUInt32Item aNewItem( ATTR_VALUE_FORMAT, nLangFormat );
rSet.Put( aNewItem );
aOldSet.Put( aNewItem );
// Also in aOldSet for comparison after the dialog,
// Otherwise might miss a language change
}
}
std::unique_ptr<SvxNumberInfoItem> pNumberInfoItem(
ScTabViewShell::MakeNumberInfoItem(&rDoc, GetViewData()));
pDocSh->PutItem( *pNumberInfoItem );
nRsc = RID_SCDLG_STYLES_PAR;
// Definitely a SvxBoxInfoItem with Table = sal_False in set:
// (If there is no item, the dialogue will also delete the
// BORDER_OUTER SvxBoxItem from the Template Set)
if ( rSet.GetItemState( ATTR_BORDER_INNER, false ) != SfxItemState::SET )
{
SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
aBoxInfoItem.SetTable(false); // no inner lines
aBoxInfoItem.SetDist(true);
aBoxInfoItem.SetMinDist(false);
rSet.Put( aBoxInfoItem );
}
}
break;
}
// If GetDefDialogParent is a dialog, it must be used
// (style catalog)
vcl::Window* pParent = Application::GetDefDialogParent();
if ( !pParent || !pParent->IsDialog() )
{
// GetDefDialogParent dynamically finds the
// topmost parent of the focus window, so IsDialog above is FALSE
// even if called from the style catalog.
// -> Use NULL if a modal dialog is open, to enable the Dialog's
// default parent handling.
if ( Application::IsInModalMode() )
pParent = nullptr;
else
pParent = pTabViewShell->GetDialogParent();
}
pTabViewShell->SetInFormatDialog(true);
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
pDlg.reset(pFact->CreateScStyleDlg( pParent, *pStyleSheet, nRsc, nRsc ));
OSL_ENSURE(pDlg, "Dialog create fail!");
short nResult = pDlg->Execute();
pTabViewShell->SetInFormatDialog(false);
if ( nResult == RET_OK )
{
const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
if ( pOutSet )
{
nRetMask = pStyleSheet->GetMask();
// Attribute comparisons (earlier in ModifyStyleSheet) now here
// with the old values (the style is already changed)
if ( SfxStyleFamily::Para == eFam )
{
SfxItemSet& rNewSet = pStyleSheet->GetItemSet();
bool bNumFormatChanged;
if ( ScGlobal::CheckWidthInvalidate(
bNumFormatChanged, rNewSet, aOldSet ) )
rDoc.InvalidateTextWidth( nullptr, nullptr, bNumFormatChanged );
SCTAB nTabCount = rDoc.GetTableCount();
for (SCTAB nTab=0; nTab<nTabCount; nTab++)
if (rDoc.IsStreamValid(nTab))
rDoc.SetStreamValid(nTab, false);
sal_uLong nOldFormat = static_cast<const SfxUInt32Item&>(aOldSet.
Get( ATTR_VALUE_FORMAT )).GetValue();
sal_uLong nNewFormat = static_cast<const SfxUInt32Item&>(rNewSet.
Get( ATTR_VALUE_FORMAT )).GetValue();
if ( nNewFormat != nOldFormat )
{
SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
const SvNumberformat* pOld = pFormatter->GetEntry( nOldFormat );
const SvNumberformat* pNew = pFormatter->GetEntry( nNewFormat );
if ( pOld && pNew && pOld->GetLanguage() != pNew->GetLanguage() )
rNewSet.Put( SvxLanguageItem(
pNew->GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
}
rDoc.GetPool()->CellStyleCreated( pStyleSheet->GetName(), &rDoc );
}
else
{
//! Here also queries for Page Styles
OUString aNewName = pStyleSheet->GetName();
if ( aNewName != aOldName &&
rDoc.RenamePageStyleInUse( aOldName, aNewName ) )
{
rBindings.Invalidate( SID_STATUS_PAGESTYLE );
rBindings.Invalidate( FID_RESET_PRINTZOOM );
}
rDoc.ModifyStyleSheet( *pStyleSheet, *pOutSet );
rBindings.Invalidate( FID_RESET_PRINTZOOM );
}
pDocSh->SetDocumentModified();
if ( SfxStyleFamily::Para == eFam )
{
ScTabViewShell::UpdateNumberFormatter(
static_cast<const SvxNumberInfoItem&>(
*(pDocSh->GetItem(SID_ATTR_NUMBERFORMAT_INFO)) ));
pTabViewShell->UpdateStyleSheetInUse( pStyleSheet );
pTabViewShell->InvalidateAttribs();
}
aNewData.InitFromStyle( pStyleSheet );
bAddUndo = true;
}
}
else
{
if ( nSlotId == SID_STYLE_NEW )
pStylePool->Remove( pStyleSheet );
else
{
// If in the mean time something was painted with the
// temporary changed item set
pDocSh->PostPaintGridAll();
}
}
}
}
rReq.SetReturnValue( SfxUInt16Item( nSlotId, nRetMask ) );
if ( bAddUndo && bUndo)
pDocSh->GetUndoManager()->AddUndoAction(
new ScUndoModifyStyle( pDocSh, eFamily, aOldData, aNewData ) );
if ( bStyleToMarked )
{
// call SetStyleSheetToMarked after adding the ScUndoModifyStyle,
// so redo will find the modified style
pTabViewShell->SetStyleSheetToMarked( static_cast<SfxStyleSheet*>(pStyleSheet) );
pTabViewShell->InvalidateAttribs();
}
if ( bListAction )
pDocSh->GetUndoManager()->LeaveListAction();
}
else if (nSlotId == SID_CLASSIFICATION_APPLY)
{
const SfxPoolItem* pItem = nullptr;
if (pArgs && pArgs->GetItemState(nSlotId, false, &pItem) == SfxItemState::SET)
{
const OUString& rName = static_cast<const SfxStringItem*>(pItem)->GetValue();
SfxClassificationHelper aHelper(pDocSh->getDocProperties());
auto eType = SfxClassificationPolicyType::IntellectualProperty;
if (pArgs->GetItemState(SID_TYPE_NAME, false, &pItem) == SfxItemState::SET)
{
const OUString& rType = static_cast<const SfxStringItem*>(pItem)->GetValue();
eType = SfxClassificationHelper::stringToPolicyType(rType);
}
aHelper.SetBACName(rName, eType);
}
else
SAL_WARN("sc.ui", "missing parameter for SID_CLASSIFICATION_APPLY");
}
else
{
OSL_FAIL( "Unknown slot (ScViewShell::ExecuteStyle)" );
}
}
void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
{
ScModule* pScMod = SC_MOD();
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
const SfxItemSet* pReqArgs = rReq.GetArgs();
sal_uInt16 nSlot = rReq.GetSlot();
SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
// End input
if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
{
switch ( nSlot )
{
case SID_NUMBER_TWODEC:
case SID_NUMBER_SCIENTIFIC:
case SID_NUMBER_DATE:
case SID_NUMBER_CURRENCY:
case SID_NUMBER_PERCENT:
case SID_NUMBER_STANDARD:
case SID_NUMBER_FORMAT:
case SID_NUMBER_INCDEC:
case SID_NUMBER_DECDEC:
case FID_DEFINE_NAME:
case FID_ADD_NAME:
case FID_USE_NAME:
case FID_INSERT_NAME:
case SID_SPELL_DIALOG:
case SID_HANGUL_HANJA_CONVERSION:
pScMod->InputEnterHandler();
pTabViewShell->UpdateInputHandler();
break;
default:
break;
}
}
short nType = GetCurrentNumberFormatType();
SfxItemSet aSet( GetPool(), nSlot, nSlot );
switch ( nSlot )
{
case SID_NUMBER_TWODEC:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER, 4 ); // Standard+4 = #.##0,00
rReq.Done();
break;
case SID_NUMBER_SCIENTIFIC:
if ((nType & css::util::NumberFormat::SCIENTIFIC))
pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
else
pTabViewShell->SetNumberFormat( css::util::NumberFormat::SCIENTIFIC );
aSet.Put( SfxBoolItem(nSlot, !(nType & css::util::NumberFormat::SCIENTIFIC)) );
rBindings.Invalidate( nSlot );
rReq.Done();
break;
case SID_NUMBER_DATE:
if ((nType & css::util::NumberFormat::DATE))
pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
else
pTabViewShell->SetNumberFormat( css::util::NumberFormat::DATE );
aSet.Put( SfxBoolItem(nSlot, !(nType & css::util::NumberFormat::DATE)) );
rBindings.Invalidate( nSlot );
rReq.Done();
break;
case SID_NUMBER_TIME:
if ((nType & css::util::NumberFormat::TIME))
pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
else
pTabViewShell->SetNumberFormat( css::util::NumberFormat::TIME );
aSet.Put( SfxBoolItem(nSlot, !(nType & css::util::NumberFormat::TIME)) );
rBindings.Invalidate( nSlot );
rReq.Done();
break;
case SID_NUMBER_CURRENCY:
if(pReqArgs)
{
const SfxPoolItem* pItem;
if ( pReqArgs->HasItem( SID_NUMBER_CURRENCY, &pItem ) )
{
sal_uInt32 nNewFormat = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
ScDocument* pDoc = pViewData->GetDocument();
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
const SfxItemSet& rOldSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
LanguageType eOldLang = static_cast<const SvxLanguageItem&>(
rOldSet.Get( ATTR_LANGUAGE_FORMAT ) ).GetLanguage();
sal_uInt32 nOldFormat = static_cast<const SfxUInt32Item&>(
rOldSet.Get( ATTR_VALUE_FORMAT ) ).GetValue();
if ( nOldFormat != nNewFormat )
{
const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
ScPatternAttr aNewAttrs( pDoc->GetPool() );
SfxItemSet& rSet = aNewAttrs.GetItemSet();
LanguageType eNewLang = pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
pTabViewShell->ApplySelectionPattern( aNewAttrs );
}
else
pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
}
}
else
{
if ( ( nType & css::util::NumberFormat::CURRENCY ) )
pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
else
pTabViewShell->SetNumberFormat( css::util::NumberFormat::CURRENCY );
}
rBindings.Invalidate( nSlot );
rReq.Done();
break;
case SID_NUMBER_PERCENT:
if ((nType & css::util::NumberFormat::PERCENT))
pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
else
pTabViewShell->SetNumberFormat( css::util::NumberFormat::PERCENT );
aSet.Put( SfxBoolItem(nSlot, !(nType & css::util::NumberFormat::PERCENT)) );
rBindings.Invalidate( nSlot );
rReq.Done();
break;
case SID_NUMBER_STANDARD:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER );
rReq.Done();
break;
case SID_NUMBER_INCDEC:
pTabViewShell->ChangeNumFmtDecimals( true );
rReq.Done();
break;
case SID_NUMBER_DECDEC:
pTabViewShell->ChangeNumFmtDecimals( false );
rReq.Done();
break;
case SID_NUMBER_FORMAT:
// symphony version with format interpretation
if(pReqArgs)
{
const SfxPoolItem* pItem;
ScDocument* pDoc = pViewData->GetDocument();
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
LanguageType eLanguage = ScGlobal::eLnge;
sal_Int16 eType = -1;
sal_uInt32 nCurrentNumberFormat;
pDoc->GetNumberFormat(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo(), nCurrentNumberFormat);
const SvNumberformat* pEntry = pFormatter->GetEntry(nCurrentNumberFormat);
if(pEntry)
{
eLanguage = pEntry->GetLanguage();
eType = pEntry->GetType();
}
//Just use eType to judge whether the command is fired for NUMBER/PERCENT/CURRENCY/SCIENTIFIC
//In sidebar, users can fire SID_NUMBER_FORMAT command by operating the related UI controls before they are disable
switch(eType)
{
case css::util::NumberFormat::ALL:
case css::util::NumberFormat::NUMBER:
case css::util::NumberFormat::NUMBER| css::util::NumberFormat::DEFINED:
case css::util::NumberFormat::PERCENT:
case css::util::NumberFormat::PERCENT| css::util::NumberFormat::DEFINED:
case css::util::NumberFormat::CURRENCY:
case css::util::NumberFormat::CURRENCY|css::util::NumberFormat::DEFINED:
case css::util::NumberFormat::SCIENTIFIC:
case css::util::NumberFormat::SCIENTIFIC|css::util::NumberFormat::DEFINED:
eType = 0;
break;
default:
eType =-1;
}
if(SfxItemState::SET == pReqArgs->GetItemState(nSlot, true, &pItem) && eType != -1)
{
OUString aCode = static_cast<const SfxStringItem*>(pItem)->GetValue();
sal_uInt16 aLen = aCode.getLength();
OUString* sFormat = new OUString[4];
OUString sTmpStr = "";
sal_uInt16 nCount(0);
sal_uInt16 nStrCount(0);
while(nCount < aLen)
{
sal_Unicode cChar = aCode[nCount];
if(cChar == ',')
{
sFormat[nStrCount] = sTmpStr;
sTmpStr.clear();
nStrCount++;
}
else
{
sTmpStr += OUString(cChar);
}
nCount++;
if(nStrCount > 3)
break;
}
const bool bThousand = (bool)sFormat[0].toInt32();
const bool bNegRed = (bool)sFormat[1].toInt32();
const sal_uInt16 nPrecision = (sal_uInt16)sFormat[2].toInt32();
const sal_uInt16 nLeadZeroes = (sal_uInt16)sFormat[3].toInt32();
aCode = pFormatter->GenerateFormat(
nCurrentNumberFormat,//modify
eLanguage,
bThousand,
bNegRed,
nPrecision,
nLeadZeroes);
pTabViewShell->SetNumFmtByStr(aCode);
delete[] sFormat;
}
}
break;
case SID_ATTR_NUMBERFORMAT_VALUE:
if ( pReqArgs )
{
const SfxPoolItem* pItem;
if ( pReqArgs->GetItemState( ATTR_VALUE_FORMAT, true, &pItem ) == SfxItemState::SET )
{
// We have to accomplish this using ApplyAttributes()
// because we also need the language information to be
// considered.
const SfxItemSet& rOldSet =
pTabViewShell->GetSelectionPattern()->GetItemSet();
SfxItemPool* pDocPool = GetViewData()->GetDocument()->GetPool();
SfxItemSet aNewSet( *pDocPool, ATTR_PATTERN_START, ATTR_PATTERN_END );
aNewSet.Put( *pItem );
pTabViewShell->ApplyAttributes( &aNewSet, &rOldSet );
}
}
break;
case SID_NUMBER_TYPE_FORMAT:
if ( pReqArgs )
{
const SfxPoolItem* pItem;
if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
{
sal_uInt16 nFormat = static_cast<const SfxInt16Item *>(pItem)->GetValue();
switch(nFormat)
{
case 0:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER); //Modify
break;
case 1:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::NUMBER, 2 ); //Modify
break;
case 2:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::PERCENT );
break;
case 3:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::CURRENCY );
break;
case 4:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::DATE );
break;
case 5:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::TIME );
break;
case 6:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::SCIENTIFIC );
break;
case 7:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::FRACTION );
break;
case 8:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::LOGICAL );
break;
case 9:
pTabViewShell->SetNumberFormat( css::util::NumberFormat::TEXT );
break;
default:
;
}
rReq.Done();
}
}
break;
default:
OSL_FAIL("ExecuteEdit: invalid slot");
break;
}
}
void ScFormatShell::ExecuteAlignment( SfxRequest& rReq )
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
SfxBindings& rBindings = pViewData->GetBindings();
const SfxItemSet* pSet = rReq.GetArgs();
sal_uInt16 nSlot = rReq.GetSlot();
pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
switch( nSlot )
{
// pseudo slots for Format menu
case SID_ALIGN_ANY_HDEFAULT:
case SID_ALIGN_ANY_LEFT:
case SID_ALIGN_ANY_HCENTER:
case SID_ALIGN_ANY_RIGHT:
case SID_ALIGN_ANY_JUSTIFIED:
pTabViewShell->ApplyAttr( SvxHorJustifyItem( lclConvertSlotToHAlign( nSlot ), ATTR_HOR_JUSTIFY ) );
break;
case SID_ALIGN_ANY_VDEFAULT:
case SID_ALIGN_ANY_TOP:
case SID_ALIGN_ANY_VCENTER:
case SID_ALIGN_ANY_BOTTOM:
pTabViewShell->ApplyAttr( SvxVerJustifyItem( lclConvertSlotToVAlign( nSlot ), ATTR_VER_JUSTIFY ) );
break;
default:
if( pSet )
{
const SfxPoolItem* pItem = nullptr;
if( pSet->GetItemState(GetPool().GetWhich(nSlot), true, &pItem ) == SfxItemState::SET )
{
switch ( nSlot )
{
case SID_ATTR_ALIGN_HOR_JUSTIFY:
case SID_ATTR_ALIGN_VER_JUSTIFY:
case SID_ATTR_ALIGN_INDENT:
case SID_ATTR_ALIGN_HYPHENATION:
case SID_ATTR_ALIGN_DEGREES:
case SID_ATTR_ALIGN_LOCKPOS:
case SID_ATTR_ALIGN_MARGIN:
case SID_ATTR_ALIGN_STACKED:
pTabViewShell->ApplyAttr( *pItem );
break;
case SID_H_ALIGNCELL:
{
SvxCellHorJustify eJust = (SvxCellHorJustify)static_cast<const SvxHorJustifyItem*>(pItem)->GetValue();
// #i78476# update alignment of text in cell edit mode
pTabViewShell->UpdateInputHandlerCellAdjust( eJust );
pTabViewShell->ApplyAttr( SvxHorJustifyItem( eJust, ATTR_HOR_JUSTIFY ) );
}
break;
case SID_V_ALIGNCELL:
pTabViewShell->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify)static_cast<const SvxVerJustifyItem*>(pItem)->GetValue(), ATTR_VER_JUSTIFY ) );
break;
default:
OSL_FAIL( "ExecuteAlignment: invalid slot" );
return;
}
}
}
}
rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT );
rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT );
rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK );
rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER);
rBindings.Invalidate( SID_ALIGNLEFT );
rBindings.Invalidate( SID_ALIGNRIGHT );
rBindings.Invalidate( SID_ALIGNCENTERHOR );
rBindings.Invalidate( SID_ALIGNBLOCK );
rBindings.Invalidate( SID_ALIGNTOP );
rBindings.Invalidate( SID_ALIGNBOTTOM );
rBindings.Invalidate( SID_ALIGNCENTERVER );
rBindings.Invalidate( SID_V_ALIGNCELL );
rBindings.Invalidate( SID_H_ALIGNCELL );
// pseudo slots for Format menu
rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
rBindings.Invalidate( SID_ALIGN_ANY_TOP );
rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
rBindings.Update();
if( ! rReq.IsAPI() )
rReq.Done();
}
void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
SfxBindings& rBindings = pViewData->GetBindings();
const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
const SfxItemSet* pSet = rReq.GetArgs();
sal_uInt16 nSlot = rReq.GetSlot();
SfxAllItemSet* pNewSet = nullptr;
pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
if ( (nSlot == SID_ATTR_CHAR_WEIGHT)
||(nSlot == SID_ATTR_CHAR_POSTURE)
||(nSlot == SID_ATTR_CHAR_UNDERLINE)
||(nSlot == SID_ULINE_VAL_NONE)
||(nSlot == SID_ULINE_VAL_SINGLE)
||(nSlot == SID_ULINE_VAL_DOUBLE)
||(nSlot == SID_ULINE_VAL_DOTTED) )
{
pNewSet = new SfxAllItemSet( GetPool() );
switch ( nSlot )
{
case SID_ATTR_CHAR_WEIGHT:
{
// #i78017 establish the same behaviour as in Writer
SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
SfxItemPool& rPool = GetPool();
SvxScriptSetItem aSetItem( nSlot, rPool );
if ( pSet )
aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_WEIGHT ) );
else
{
// toggle manually
FontWeight eWeight = WEIGHT_BOLD;
SvxScriptSetItem aOldSetItem( nSlot, rPool );
aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), false );
const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
if ( pCore && static_cast<const SvxWeightItem*>(pCore)->GetWeight() == WEIGHT_BOLD )
eWeight = WEIGHT_NORMAL;
aSetItem.PutItemForScriptType( nScript, SvxWeightItem( eWeight, ATTR_FONT_WEIGHT ) );
}
pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
pNewSet->Put( aSetItem.GetItemSet(), false );
}
break;
case SID_ATTR_CHAR_POSTURE:
{
// #i78017 establish the same behaviour as in Writer
SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
SfxItemPool& rPool = GetPool();
SvxScriptSetItem aSetItem( nSlot, rPool );
if ( pSet )
aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_POSTURE ) );
else
{
// toggle manually
FontItalic eItalic = ITALIC_NORMAL;
SvxScriptSetItem aOldSetItem( nSlot, rPool );
aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), false );
const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
if ( pCore && static_cast<const SvxPostureItem*>(pCore)->GetPosture() == ITALIC_NORMAL )
eItalic = ITALIC_NONE;
aSetItem.PutItemForScriptType( nScript, SvxPostureItem( eItalic, ATTR_FONT_POSTURE ) );
}
pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
pNewSet->Put( aSetItem.GetItemSet(), false );
}
break;
case SID_ATTR_CHAR_UNDERLINE:
{
FontLineStyle eUnderline;
if( pSet )
{
const SfxPoolItem& rUnderline = pSet->Get( ATTR_FONT_UNDERLINE );
if( dynamic_cast<const SvxUnderlineItem*>( &rUnderline) != nullptr )
{
pTabViewShell->ApplyAttr( rUnderline );
pNewSet->Put( rUnderline,rUnderline.Which() );
}
else if ( dynamic_cast<const SvxTextLineItem*>( &rUnderline) != nullptr )
{
// #i106580# also allow SvxTextLineItem (base class of SvxUnderlineItem)
const SvxTextLineItem& rTextLineItem = static_cast<const SvxTextLineItem&>(rUnderline);
SvxUnderlineItem aNewItem( rTextLineItem.GetLineStyle(), rTextLineItem.Which() );
aNewItem.SetColor( rTextLineItem.GetColor() );
pTabViewShell->ApplyAttr( aNewItem );
pNewSet->Put( aNewItem, aNewItem.Which() );
}
}
else
{
SvxUnderlineItem aUnderline( static_cast<const SvxUnderlineItem&>(
pAttrs->GetItem(
ATTR_FONT_UNDERLINE ) ) );
eUnderline = (LINESTYLE_NONE != aUnderline.GetLineStyle())
? LINESTYLE_NONE
: LINESTYLE_SINGLE;
aUnderline.SetLineStyle( eUnderline );
pTabViewShell->ApplyAttr( aUnderline );
pNewSet->Put( aUnderline,aUnderline.Which() );
}
}
break;
case SID_ULINE_VAL_NONE:
pTabViewShell->ApplyAttr( SvxUnderlineItem( LINESTYLE_NONE, ATTR_FONT_UNDERLINE ) );
break;
case SID_ULINE_VAL_SINGLE: // Toggles
case SID_ULINE_VAL_DOUBLE:
case SID_ULINE_VAL_DOTTED:
{
FontLineStyle eOld = static_cast<const SvxUnderlineItem&>(
pAttrs->GetItem(ATTR_FONT_UNDERLINE)).GetLineStyle();
FontLineStyle eNew = eOld;
switch (nSlot)
{
case SID_ULINE_VAL_SINGLE:
eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
break;
case SID_ULINE_VAL_DOUBLE:
eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE;
break;
case SID_ULINE_VAL_DOTTED:
eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED;
break;
}
pTabViewShell->ApplyAttr( SvxUnderlineItem( eNew, ATTR_FONT_UNDERLINE ) );
}
break;
default:
break;
}
rBindings.Invalidate( nSlot );
}
else
{
/*
* "Selbstgemachte" RadioButton-Funktionalitaet
* Beim Toggle gibt es den Standard-State, d.h. kein
* Button ist gedrueckt
*/
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
const SfxPoolItem* pItem = nullptr;
const SvxHorJustifyItem* pHorJustify = nullptr;
const SvxVerJustifyItem* pVerJustify = nullptr;
SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD;
if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, true,&pItem ) == SfxItemState::SET)
{
pHorJustify = static_cast<const SvxHorJustifyItem*>(pItem);
eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
}
if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, true,&pItem ) == SfxItemState::SET)
{
pVerJustify = static_cast<const SvxVerJustifyItem*>(pItem);
eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
}
switch ( nSlot )
{
case SID_ALIGNLEFT:
rReq.SetSlot( SID_H_ALIGNCELL );
rReq.AppendItem( SvxHorJustifyItem(
!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_LEFT) ?
SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
ExecuteSlot( rReq, GetInterface() );
return;
case SID_ALIGNRIGHT:
rReq.SetSlot( SID_H_ALIGNCELL );
rReq.AppendItem( SvxHorJustifyItem(
!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_RIGHT) ?
SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
ExecuteSlot( rReq, GetInterface() );
return;
case SID_ALIGNCENTERHOR:
rReq.SetSlot( SID_H_ALIGNCELL );
rReq.AppendItem( SvxHorJustifyItem(
!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_CENTER) ?
SVX_HOR_JUSTIFY_CENTER : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
ExecuteSlot( rReq, GetInterface() );
return;
case SID_ALIGNBLOCK:
rReq.SetSlot( SID_H_ALIGNCELL );
rReq.AppendItem( SvxHorJustifyItem(
!pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_BLOCK) ?
SVX_HOR_JUSTIFY_BLOCK : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
ExecuteSlot( rReq, GetInterface() );
return;
case SID_ALIGNTOP:
rReq.SetSlot( SID_V_ALIGNCELL );
rReq.AppendItem( SvxVerJustifyItem(
!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_TOP) ?
SVX_VER_JUSTIFY_TOP : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
ExecuteSlot( rReq, GetInterface() );
return;
case SID_ALIGNBOTTOM:
rReq.SetSlot( SID_V_ALIGNCELL );
rReq.AppendItem( SvxVerJustifyItem(
!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_BOTTOM) ?
SVX_VER_JUSTIFY_BOTTOM : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
ExecuteSlot( rReq, GetInterface() );
return;
case SID_ALIGNCENTERVER:
rReq.SetSlot( SID_V_ALIGNCELL );
rReq.AppendItem( SvxVerJustifyItem(
!pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_CENTER) ?
SVX_VER_JUSTIFY_CENTER : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
ExecuteSlot( rReq, GetInterface() );
return;
default:
break;
}
}
rBindings.Update();
if( pNewSet )
{
rReq.Done( *pNewSet );
delete pNewSet;
}
else
{
rReq.Done();
}
}
void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
SfxBindings& rBindings = pViewData->GetBindings();
const SfxItemSet* pNewAttrs = rReq.GetArgs();
sal_uInt16 nSlot = rReq.GetSlot();
pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
ScDocument* pDoc = GetViewData()->GetDocument();
if ( !pNewAttrs )
{
switch ( nSlot )
{
case SID_GROW_FONT_SIZE:
case SID_SHRINK_FONT_SIZE:
{
SfxItemPool& rPool = GetPool();
SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONTHEIGHT, rPool );
aSetItem.GetItemSet().Put( pTabViewShell->GetSelectionPattern()->GetItemSet(), false );
SvtScriptType nScriptTypes = pTabViewShell->GetSelectionScriptType();
const SvxFontHeightItem* pSize( static_cast<const SvxFontHeightItem*>( aSetItem.GetItemOfScript( nScriptTypes ) ) );
if ( pSize )
{
SvxFontHeightItem aSize( *pSize );
sal_uInt32 nSize = aSize.GetHeight();
const sal_uInt32 nFontInc = 40; // 2pt
const sal_uInt32 nFontMaxSz = 19998; // 999.9pt
if ( nSlot == SID_GROW_FONT_SIZE )
nSize = std::min< sal_uInt32 >( nSize + nFontInc, nFontMaxSz );
else
nSize = std::max< sal_Int32 >( nSize - nFontInc, nFontInc );
aSize.SetHeight( nSize );
aSetItem.PutItemForScriptType( nScriptTypes, aSize );
pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
}
rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
}
break;
case SID_ATTR_CHAR_ENDPREVIEW_FONT:
{
pDoc->SetPreviewFont(nullptr);
pTabViewShell->UpdateSelectionArea( pDoc->GetPreviewSelection() );
break;
}
case SID_ATTR_CHAR_COLOR:
case SID_ATTR_CHAR_FONT:
case SID_ATTR_CHAR_FONTHEIGHT:
pTabViewShell->ExecuteCellFormatDlg(rReq, "font"); // when ToolBar is vertical
break;
case SID_BACKGROUND_COLOR:
{
SvxBrushItem aBrushItem( static_cast<const SvxBrushItem&>(
pTabViewShell->GetSelectionPattern()->GetItem( ATTR_BACKGROUND ) ) );
aBrushItem.SetColor( COL_TRANSPARENT );
pTabViewShell->ApplyAttr( aBrushItem );
}
break;
case SID_ATTR_ALIGN_LINEBREAK: // without parameter as toggle
{
const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
bool bOld = static_cast<const SfxBoolItem&>(pAttrs->GetItem(ATTR_LINEBREAK)).GetValue();
SfxBoolItem aBreakItem( ATTR_LINEBREAK, !bOld );
pTabViewShell->ApplyAttr( aBreakItem );
SfxAllItemSet aNewSet( GetPool() );
aNewSet.Put( aBreakItem,aBreakItem.Which() );
rReq.Done( aNewSet );
rBindings.Invalidate( nSlot );
}
break;
}
}
else
{
switch ( nSlot )
{
case SID_ATTR_CHAR_PREVIEW_FONT:
{
SfxItemPool& rPool = GetPool();
sal_uInt16 nWhich = rPool.GetWhich( nSlot );
const SvxFontItem& rFont = static_cast<const SvxFontItem&>(pNewAttrs->Get( nWhich ));
SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, rPool );
SvtScriptType nScript = pTabViewShell->GetSelectionScriptType();
aSetItem.PutItemForScriptType( nScript, rFont );
ScMarkData aFuncMark( pViewData->GetMarkData() );
ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
pDoc->SetPreviewFont( aSetItem.GetItemSet().Clone() );
aFuncMark.MarkToMulti();
if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
{
SCCOL nCol = pViewData->GetCurX();
SCROW nRow = pViewData->GetCurY();
SCTAB nTab = pViewData->GetTabNo();
ScRange aRange( nCol, nRow, nTab );
aFuncMark.SetMarkArea( aRange );
}
pDoc->SetPreviewSelection( aFuncMark );
pTabViewShell->UpdateSelectionArea( aFuncMark );
break;
}
case SID_ATTR_CHAR_OVERLINE:
case SID_ATTR_CHAR_STRIKEOUT:
case SID_ATTR_ALIGN_LINEBREAK:
case SID_ATTR_CHAR_COLOR:
case SID_ATTR_CHAR_CONTOUR:
case SID_ATTR_CHAR_SHADOWED:
case SID_ATTR_CHAR_RELIEF:
case SID_SCATTR_PROTECTION :
pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) ) );
rBindings.Invalidate( nSlot );
rBindings.Update( nSlot );
break;
case SID_ATTR_CHAR_FONT:
case SID_ATTR_CHAR_FONTHEIGHT:
{
// #i78017 establish the same behaviour as in Writer
SvtScriptType nScript = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX;
if (nSlot == SID_ATTR_CHAR_FONT)
nScript = pTabViewShell->GetSelectionScriptType();
SfxItemPool& rPool = GetPool();
SvxScriptSetItem aSetItem( nSlot, rPool );
sal_uInt16 nWhich = rPool.GetWhich( nSlot );
aSetItem.PutItemForScriptType( nScript, pNewAttrs->Get( nWhich ) );
pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
rBindings.Invalidate( nSlot );
rBindings.Update( nSlot );
}
break;
case SID_FRAME_LINESTYLE:
{
// Update default line
const ::editeng::SvxBorderLine* pLine =
static_cast<const SvxLineItem&>(
pNewAttrs->Get( SID_FRAME_LINESTYLE )).
GetLine();
if ( pLine )
{
::editeng::SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
if ( pDefLine )
{
pDefLine->SetBorderLineStyle(
pLine->GetBorderLineStyle());
pDefLine->SetWidth( pLine->GetWidth( ) );
pTabViewShell->SetSelectionFrameLines( pDefLine, false );
}
else
{
pTabViewShell->SetDefaultFrameLine( pLine );
pTabViewShell->GetDefaultFrameLine()->SetColor( COL_BLACK );
pTabViewShell->SetSelectionFrameLines( pLine, false );
}
}
else
{
Color aColorBlack( COL_BLACK );
::editeng::SvxBorderLine aDefLine( &aColorBlack, 20,
table::BorderLineStyle::SOLID );
pTabViewShell->SetDefaultFrameLine( &aDefLine );
pTabViewShell->SetSelectionFrameLines( nullptr, false );
}
}
break;
case SID_FRAME_LINECOLOR:
{
::editeng::SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
const Color& rColor = static_cast<const SvxColorItem&>(
pNewAttrs->Get( SID_FRAME_LINECOLOR )).
GetValue();
// Update default line
if ( pDefLine )
{
pDefLine->SetColor( rColor );
pTabViewShell->SetSelectionFrameLines( pDefLine, true );
}
else
{
::editeng::SvxBorderLine aDefLine( &rColor, 20,
table::BorderLineStyle::SOLID );
pTabViewShell->SetDefaultFrameLine( &aDefLine );
pTabViewShell->SetSelectionFrameLines( &aDefLine, false );
}
}
break;
case SID_ATTR_BORDER_OUTER:
case SID_ATTR_BORDER:
{
::editeng::SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern();
std::unique_ptr<SfxItemSet> pOldSet(
new SfxItemSet(
*(pDoc->GetPool()),
ATTR_PATTERN_START,
ATTR_PATTERN_END ));
std::unique_ptr<SfxItemSet> pNewSet(
new SfxItemSet(
*(pDoc->GetPool()),
ATTR_PATTERN_START,
ATTR_PATTERN_END ));
const SfxPoolItem& rBorderAttr =
pOldAttrs->GetItemSet().
Get( ATTR_BORDER );
// Evaluate border items from controller:
const SfxPoolItem* pItem = nullptr;
if ( pNewAttrs->GetItemState( ATTR_BORDER, true, &pItem )
== SfxItemState::SET )
{
// The SvxFrameToolBoxControl toolbox controller uses a default
// SvxBorderLine (all widths 0) to mark the lines that should be set.
// Macro recording uses a SvxBoxItem with the real values (OutWidth > 0)
// or NULL pointers for no lines.
// -> Substitute existing lines with pDefLine only if widths are 0.
SvxBoxItem aBoxItem ( *static_cast<const SvxBoxItem*>(pItem ));
if ( aBoxItem.GetTop() && aBoxItem.GetTop()->GetOutWidth() == 0 )
aBoxItem.SetLine( pDefLine, SvxBoxItemLine::TOP );
if ( aBoxItem.GetBottom() && aBoxItem.GetBottom()->GetOutWidth() == 0 )
aBoxItem.SetLine( pDefLine, SvxBoxItemLine::BOTTOM );
if ( aBoxItem.GetLeft() && aBoxItem.GetLeft()->GetOutWidth() == 0 )
aBoxItem.SetLine( pDefLine, SvxBoxItemLine::LEFT );
if ( aBoxItem.GetRight() && aBoxItem.GetRight()->GetOutWidth() == 0 )
aBoxItem.SetLine( pDefLine, SvxBoxItemLine::RIGHT );
pNewSet->Put( aBoxItem );
rReq.AppendItem( aBoxItem );
}
if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, true, &pItem )
== SfxItemState::SET )
{
SvxBoxInfoItem aBoxInfoItem( *static_cast<const SvxBoxInfoItem*>(pItem) );
if ( aBoxInfoItem.GetHori() && aBoxInfoItem.GetHori()->GetOutWidth() == 0 )
aBoxInfoItem.SetLine( pDefLine, SvxBoxInfoItemLine::HORI );
if ( aBoxInfoItem.GetVert() && aBoxInfoItem.GetVert()->GetOutWidth() == 0 )
aBoxInfoItem.SetLine( pDefLine, SvxBoxInfoItemLine::VERT );
pNewSet->Put( aBoxInfoItem );
rReq.AppendItem( aBoxInfoItem );
}
else
{
SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
aBoxInfoItem.SetLine( nullptr, SvxBoxInfoItemLine::HORI );
aBoxInfoItem.SetLine( nullptr, SvxBoxInfoItemLine::VERT );
pNewSet->Put( aBoxInfoItem );
}
pOldSet->Put( rBorderAttr );
pTabViewShell->ApplyAttributes( pNewSet.get(), pOldSet.get() );
}
break;
case SID_ATTR_BORDER_DIAG_TLBR:
case SID_ATTR_BORDER_DIAG_BLTR:
{
const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern();
std::unique_ptr<SfxItemSet> pOldSet(new SfxItemSet(pOldAttrs->GetItemSet()));
std::unique_ptr<SfxItemSet> pNewSet(new SfxItemSet(pOldAttrs->GetItemSet()));
const SfxPoolItem* pItem = nullptr;
if(SID_ATTR_BORDER_DIAG_TLBR == nSlot)
{
if(SfxItemState::SET == pNewAttrs->GetItemState(ATTR_BORDER_TLBR, true, &pItem))
{
SvxLineItem aItem(ATTR_BORDER_TLBR);
aItem.SetLine(static_cast<const SvxLineItem&>(pNewAttrs->Get(ATTR_BORDER_TLBR)).GetLine());
pNewSet->Put(aItem);
rReq.AppendItem(aItem);
pTabViewShell->ApplyAttributes(pNewSet.get(), pOldSet.get());
}
}
else // if( nSlot == SID_ATTR_BORDER_DIAG_BLTR )
{
if(SfxItemState::SET == pNewAttrs->GetItemState(ATTR_BORDER_BLTR, true, &pItem ))
{
SvxLineItem aItem(ATTR_BORDER_BLTR);
aItem.SetLine(static_cast<const SvxLineItem&>(pNewAttrs->Get(ATTR_BORDER_BLTR)).GetLine());
pNewSet->Put(aItem);
rReq.AppendItem(aItem);
pTabViewShell->ApplyAttributes(pNewSet.get(), pOldSet.get());
}
}
rBindings.Invalidate(nSlot);
}
break;
// ATTR_BACKGROUND (=SID_ATTR_BRUSH) has to be set to two IDs:
case SID_BACKGROUND_COLOR:
{
const SvxColorItem rNewColorItem = static_cast<const SvxColorItem&>(
pNewAttrs->Get( SID_BACKGROUND_COLOR ) );
SvxBrushItem aBrushItem( static_cast<const SvxBrushItem&>(
pTabViewShell->GetSelectionPattern()->
GetItem( ATTR_BACKGROUND ) ) );
aBrushItem.SetColor( rNewColorItem.GetValue() );
pTabViewShell->ApplyAttr( aBrushItem );
}
break;
case SID_ATTR_BRUSH:
{
SvxBrushItem aBrushItem( static_cast<const SvxBrushItem&>(
pTabViewShell->GetSelectionPattern()->
GetItem( ATTR_BACKGROUND ) ) );
const SvxBrushItem& rNewBrushItem = static_cast<const SvxBrushItem&>(
pNewAttrs->Get( GetPool().GetWhich(nSlot) ) );
aBrushItem.SetColor(rNewBrushItem.GetColor());
pTabViewShell->ApplyAttr( aBrushItem );
}
break;
case SID_ATTR_BORDER_SHADOW:
{
const SvxShadowItem& rNewShadowItem = static_cast<const SvxShadowItem&>(
pNewAttrs->Get( ATTR_SHADOW ) );
pTabViewShell->ApplyAttr( rNewShadowItem );
}
break;
default:
break;
}
if( ! rReq.IsAPI() )
if( ! rReq.IsDone() )
rReq.Done();
}
}
void ScFormatShell::GetAttrState( SfxItemSet& rSet )
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
const SvxBrushItem& rBrushItem = static_cast<const SvxBrushItem&>(rAttrSet.Get( ATTR_BACKGROUND ));
SfxWhichIter aIter( rSet );
sal_uInt16 nWhich = aIter.FirstWhich();
rSet.Put( rAttrSet, false );
// choose font info according to selection script type
SvtScriptType nScript = SvtScriptType::NONE; // GetSelectionScriptType never returns 0
if ( rSet.GetItemState( ATTR_FONT ) != SfxItemState::UNKNOWN )
{
if (nScript == SvtScriptType::NONE) nScript = pTabViewShell->GetSelectionScriptType();
ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT, nScript );
}
if ( rSet.GetItemState( ATTR_FONT_HEIGHT ) != SfxItemState::UNKNOWN )
{
if (nScript == SvtScriptType::NONE) nScript = pTabViewShell->GetSelectionScriptType();
ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_HEIGHT, nScript );
}
while ( nWhich )
{
switch(nWhich)
{
case SID_BACKGROUND_COLOR:
{
rSet.Put( SvxColorItem( rBrushItem.GetColor(), SID_BACKGROUND_COLOR ) );
if(SfxItemState::DONTCARE == rAttrSet.GetItemState(ATTR_BACKGROUND))
{
rSet.InvalidateItem(SID_BACKGROUND_COLOR);
}
}
break;
case SID_FRAME_LINESTYLE:
case SID_FRAME_LINECOLOR:
{
// handled together because both need the cell border information for decisions
Color aCol = 0;
editeng::SvxBorderLine aLine(nullptr,0,0);
bool bCol = false;
bool bColDisable = false, bStyleDisable = false;
SvxBoxItem aBoxItem(ATTR_BORDER);
SvxBoxInfoItem aInfoItem(ATTR_BORDER_INNER);
pTabViewShell->GetSelectionFrame(aBoxItem, aInfoItem);
if( aBoxItem.GetTop() )
{
bCol = true;
aCol = aBoxItem.GetTop()->GetColor() ;
aLine.SetColor(aCol);
aLine.SetWidth( aBoxItem.GetTop()->GetWidth());
aLine.SetBorderLineStyle( aBoxItem.GetTop()->GetBorderLineStyle());
}
if( aBoxItem.GetBottom() )
{
if(!bCol)
{
bCol = true;
aCol = aBoxItem.GetBottom()->GetColor() ;
aLine.SetColor(aCol);
aLine.SetWidth( aBoxItem.GetBottom()->GetWidth());
aLine.SetBorderLineStyle( aBoxItem.GetBottom()->GetBorderLineStyle());
}
else
{
if(aCol != aBoxItem.GetBottom()->GetColor() )
bColDisable = true;
if(!( aLine == *(aBoxItem.GetBottom())) )
bStyleDisable = true;
}
}
if( aBoxItem.GetLeft() )
{
if(!bCol)
{
bCol = true;
aCol = aBoxItem.GetLeft()->GetColor() ;
aLine.SetColor(aCol);
aLine.SetWidth( aBoxItem.GetLeft()->GetWidth());
aLine.SetBorderLineStyle( aBoxItem.GetLeft()->GetBorderLineStyle());
}
else
{
if(aCol != aBoxItem.GetLeft()->GetColor() )
bColDisable = true;
if(!( aLine == *(aBoxItem.GetLeft())) )
bStyleDisable = true;
}
}
if( aBoxItem.GetRight() )
{
if(!bCol)
{
bCol = true;
aCol = aBoxItem.GetRight()->GetColor() ;
aLine.SetColor(aCol);
aLine.SetWidth( aBoxItem.GetRight()->GetWidth());
aLine.SetBorderLineStyle( aBoxItem.GetRight()->GetBorderLineStyle());
}
else
{
if(aCol != aBoxItem.GetRight()->GetColor() )
bColDisable = true;
if(!( aLine == *(aBoxItem.GetRight())) )
bStyleDisable = true;
}
}
if( aInfoItem.GetVert())
{
if(!bCol)
{
bCol = true;
aCol = aInfoItem.GetVert()->GetColor() ;
aLine.SetColor(aCol);
aLine.SetWidth( aInfoItem.GetVert()->GetWidth());
aLine.SetBorderLineStyle( aInfoItem.GetVert()->GetBorderLineStyle());
}
else
{
if(aCol != aInfoItem.GetVert()->GetColor() )
bColDisable = true;
if(!( aLine == *(aInfoItem.GetVert())) )
bStyleDisable = true;
}
}
if( aInfoItem.GetHori())
{
if(!bCol)
{
bCol = true;
aCol = aInfoItem.GetHori()->GetColor() ;
aLine.SetColor(aCol);
aLine.SetWidth( aInfoItem.GetHori()->GetWidth());
aLine.SetBorderLineStyle( aInfoItem.GetHori()->GetBorderLineStyle());
}
else
{
if(aCol != aInfoItem.GetHori()->GetColor() )
bColDisable = true;
if(!( aLine == *(aInfoItem.GetHori())) )
bStyleDisable = true;
}
}
if( !aInfoItem.IsValid( SvxBoxInfoItemValidFlags::VERT )
|| !aInfoItem.IsValid( SvxBoxInfoItemValidFlags::HORI )
|| !aInfoItem.IsValid( SvxBoxInfoItemValidFlags::LEFT )
|| !aInfoItem.IsValid( SvxBoxInfoItemValidFlags::RIGHT )
|| !aInfoItem.IsValid( SvxBoxInfoItemValidFlags::TOP )
|| !aInfoItem.IsValid( SvxBoxInfoItemValidFlags::BOTTOM ) )
{
bColDisable = true;
bStyleDisable = true;
}
if(SID_FRAME_LINECOLOR == nWhich)
{
if(bColDisable) // if different lines have differernt colors
{
aCol = COL_TRANSPARENT;
rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
rSet.InvalidateItem(SID_FRAME_LINECOLOR);
}
else if( !bCol && !bColDisable) // if no line available
{
aCol = COL_AUTO;
rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
}
else
rSet.Put( SvxColorItem(aCol, SID_FRAME_LINECOLOR ) );
}
else // if( nWhich == SID_FRAME_LINESTYLE)
{
if(bStyleDisable) // if have several lines but don't have same style
{
aLine.SetWidth( 1 );
SvxLineItem aItem(SID_FRAME_LINESTYLE);
aItem.SetLine(&aLine);
rSet.Put( aItem );
rSet.InvalidateItem(SID_FRAME_LINESTYLE);
}
else // all the lines have same style or no line available, use initial value (0,0,0,0)
{
SvxLineItem aItem(SID_FRAME_LINESTYLE);
aItem.SetLine(&aLine);
rSet.Put( aItem );
}
}
}
break;
case SID_ATTR_BRUSH:
{
rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) );
}
break;
}
nWhich = aIter.NextWhich();
}
// stuff for sidebar panels
Invalidate(SID_ATTR_ALIGN_DEGREES);
Invalidate(SID_ATTR_ALIGN_LOCKPOS);
Invalidate(SID_ATTR_ALIGN_STACKED);
}
void ScFormatShell::GetTextAttrState( SfxItemSet& rSet )
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
rSet.Put( rAttrSet, false ); // Include ItemStates in copy
// choose font info according to selection script type
SvtScriptType nScript = SvtScriptType::NONE; // GetSelectionScriptType never returns 0
if ( rSet.GetItemState( ATTR_FONT_WEIGHT ) != SfxItemState::UNKNOWN )
{
if (nScript == SvtScriptType::NONE) nScript = pTabViewShell->GetSelectionScriptType();
ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_WEIGHT, nScript );
}
if ( rSet.GetItemState( ATTR_FONT_POSTURE ) != SfxItemState::UNKNOWN )
{
if (nScript == SvtScriptType::NONE) nScript = pTabViewShell->GetSelectionScriptType();
ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_POSTURE, nScript );
}
SfxItemState eState;
// own control on radio button functionallity:
// underline
eState = rAttrSet.GetItemState( ATTR_FONT_UNDERLINE );
if ( eState == SfxItemState::DONTCARE )
{
rSet.InvalidateItem( SID_ULINE_VAL_NONE );
rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
}
else
{
FontLineStyle eUnderline = static_cast<const SvxUnderlineItem&>(
rAttrSet.Get(ATTR_FONT_UNDERLINE)).GetLineStyle();
sal_uInt16 nId = SID_ULINE_VAL_NONE;
switch (eUnderline)
{
case LINESTYLE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break;
case LINESTYLE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break;
case LINESTYLE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break;
default:
break;
}
rSet.Put( SfxBoolItem( nId, true ) );
}
// horizontal alignment
const SvxHorJustifyItem* pHorJustify = nullptr;
const SvxVerJustifyItem* pVerJustify = nullptr;
SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD;
sal_uInt16 nWhich = 0;
bool bJustifyStd = false;
SfxBoolItem aBoolItem ( 0, true );
eState = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY, true,
reinterpret_cast<const SfxPoolItem**>(&pHorJustify) );
switch ( eState )
{
case SfxItemState::SET:
{
switch ( SvxCellHorJustify( pHorJustify->GetValue() ) )
{
case SVX_HOR_JUSTIFY_STANDARD:
break;
case SVX_HOR_JUSTIFY_LEFT:
nWhich = SID_ALIGNLEFT;
break;
case SVX_HOR_JUSTIFY_RIGHT:
nWhich = SID_ALIGNRIGHT;
break;
case SVX_HOR_JUSTIFY_CENTER:
nWhich = SID_ALIGNCENTERHOR;
break;
case SVX_HOR_JUSTIFY_BLOCK:
nWhich = SID_ALIGNBLOCK;
break;
case SVX_HOR_JUSTIFY_REPEAT:
default:
bJustifyStd = true;
break;
}
}
break;
case SfxItemState::DONTCARE:
rSet.InvalidateItem( SID_ALIGNLEFT );
rSet.InvalidateItem( SID_ALIGNRIGHT );
rSet.InvalidateItem( SID_ALIGNCENTERHOR );
rSet.InvalidateItem( SID_ALIGNBLOCK );
break;
default:
bJustifyStd = true;
break;
}
if ( nWhich )
{
aBoolItem.SetWhich( nWhich );
rSet.Put( aBoolItem );
}
else if ( bJustifyStd )
{
aBoolItem.SetValue( false );
aBoolItem.SetWhich( SID_ALIGNLEFT ); rSet.Put( aBoolItem );
aBoolItem.SetWhich( SID_ALIGNRIGHT ); rSet.Put( aBoolItem );
aBoolItem.SetWhich( SID_ALIGNCENTERHOR ); rSet.Put( aBoolItem );
aBoolItem.SetWhich( SID_ALIGNBLOCK ); rSet.Put( aBoolItem );
bJustifyStd = false;
}
// vertical alignment
nWhich = 0;
aBoolItem.SetValue( true );
eState = rAttrSet.GetItemState( ATTR_VER_JUSTIFY, true,
reinterpret_cast<const SfxPoolItem**>(&pVerJustify) );
switch ( eState )
{
case SfxItemState::SET:
{
eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
switch ( eVerJustify )
{
case SVX_VER_JUSTIFY_TOP:
nWhich = SID_ALIGNTOP;
break;
case SVX_VER_JUSTIFY_BOTTOM:
nWhich = SID_ALIGNBOTTOM;
break;
case SVX_VER_JUSTIFY_CENTER:
nWhich = SID_ALIGNCENTERVER;
break;
case SVX_VER_JUSTIFY_STANDARD:
default:
bJustifyStd = true;
break;
}
}
break;
case SfxItemState::DONTCARE:
rSet.InvalidateItem( SID_ALIGNTOP );
rSet.InvalidateItem( SID_ALIGNBOTTOM );
rSet.InvalidateItem( SID_ALIGNCENTERVER );
break;
default:
bJustifyStd = true;
break;
}
if ( nWhich )
{
aBoolItem.SetWhich( nWhich );
rSet.Put( aBoolItem );
}
else if ( bJustifyStd )
{
aBoolItem.SetValue( false );
aBoolItem.SetWhich( SID_ALIGNTOP ); rSet.Put( aBoolItem );
aBoolItem.SetWhich( SID_ALIGNBOTTOM ); rSet.Put( aBoolItem );
aBoolItem.SetWhich( SID_ALIGNCENTERVER ); rSet.Put( aBoolItem );
}
}
void ScFormatShell::GetBorderState( SfxItemSet& rSet )
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
SvxBoxItem aBoxItem( ATTR_BORDER );
SvxBoxInfoItem aInfoItem( ATTR_BORDER_INNER );
pTabViewShell->GetSelectionFrame( aBoxItem, aInfoItem );
if ( rSet.GetItemState( ATTR_BORDER ) != SfxItemState::UNKNOWN )
rSet.Put( aBoxItem );
if ( rSet.GetItemState( ATTR_BORDER_INNER ) != SfxItemState::UNKNOWN )
rSet.Put( aInfoItem );
}
void ScFormatShell::GetAlignState( SfxItemSet& rSet )
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
SvxCellHorJustify eHAlign = SVX_HOR_JUSTIFY_STANDARD;
bool bHasHAlign = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SfxItemState::DONTCARE;
if( bHasHAlign )
eHAlign = (SvxCellHorJustify)static_cast<const SvxHorJustifyItem&>(rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue();
SvxCellVerJustify eVAlign = SVX_VER_JUSTIFY_STANDARD;
bool bHasVAlign = rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SfxItemState::DONTCARE;
if( bHasVAlign )
eVAlign = (SvxCellVerJustify)static_cast<const SvxVerJustifyItem&>(rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue();
while ( nWhich )
{
switch ( nWhich )
{
case SID_H_ALIGNCELL:
if ( bHasHAlign )
rSet.Put( SvxHorJustifyItem( eHAlign, nWhich ));
break;
case SID_V_ALIGNCELL:
if ( bHasVAlign )
rSet.Put( SvxVerJustifyItem( eVAlign, nWhich ));
break;
// pseudo slots for Format menu
case SID_ALIGN_ANY_HDEFAULT:
case SID_ALIGN_ANY_LEFT:
case SID_ALIGN_ANY_HCENTER:
case SID_ALIGN_ANY_RIGHT:
case SID_ALIGN_ANY_JUSTIFIED:
rSet.Put( SfxBoolItem( nWhich, bHasHAlign && (eHAlign == lclConvertSlotToHAlign( nWhich )) ) );
break;
case SID_ALIGN_ANY_VDEFAULT:
case SID_ALIGN_ANY_TOP:
case SID_ALIGN_ANY_VCENTER:
case SID_ALIGN_ANY_BOTTOM:
rSet.Put( SfxBoolItem( nWhich, bHasVAlign && (eVAlign == lclConvertSlotToVAlign( nWhich )) ) );
break;
}
nWhich = aIter.NextWhich();
}
}
void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
ScDocument* pDoc = pViewData->GetDocument();
short nType = GetCurrentNumberFormatType();
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich = aIter.FirstWhich();
while ( nWhich )
{
switch ( nWhich )
{
case SID_NUMBER_FORMAT:
// symphony version with format interpretation
{
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
if(SfxItemState::DONTCARE != rAttrSet.GetItemState(ATTR_VALUE_FORMAT))
{
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
sal_uInt32 nNumberFormat = static_cast<const SfxUInt32Item&>(rAttrSet.Get(ATTR_VALUE_FORMAT)).GetValue();
bool bThousand(false);
bool bNegRed(false);
sal_uInt16 nPrecision(0);
sal_uInt16 nLeadZeroes(0);
pFormatter->GetFormatSpecialInfo(nNumberFormat,bThousand, bNegRed, nPrecision, nLeadZeroes);
const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
if (pFormatEntry && (pFormatEntry->GetType() & css::util::NumberFormat::SCIENTIFIC))
{
// if scientific, bThousand is used for engineering notation
const sal_uInt16 nIntegerDigits = pFormatEntry->GetFormatIntegerDigits();
if (nIntegerDigits > 0 && ((nIntegerDigits % 3) == 0))
bThousand = true;
else
bThousand = false;
}
OUString aFormat;
static OUString sBreak = ",";
const OUString sThousand = OUString::number(static_cast<sal_Int32>(bThousand));
const OUString sNegRed = OUString::number(static_cast<sal_Int32>(bNegRed));
const OUString sPrecision = OUString::number(nPrecision);
const OUString sLeadZeroes = OUString::number(nLeadZeroes);
aFormat += sThousand;
aFormat += sBreak;
aFormat += sNegRed;
aFormat += sBreak;
aFormat += sPrecision;
aFormat += sBreak;
aFormat += sLeadZeroes;
aFormat += sBreak;
rSet.Put(SfxStringItem(nWhich, aFormat));
}
else
{
rSet.InvalidateItem( nWhich );
}
}
break;
case SID_NUMBER_TYPE_FORMAT:
{
sal_Int16 aFormatCode = -1;
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) >= SfxItemState::DEFAULT ) //Modify for more robust
{
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
sal_uInt32 nNumberFormat = pTabViewShell->GetSelectionPattern()->GetNumberFormat( pFormatter );
const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
bool bStandard = false;
if ( pFormatEntry )
{
aFormatCode = pFormatEntry->GetType();
bStandard = pFormatEntry->IsStandard();
}
switch(aFormatCode)
{
case css::util::NumberFormat::NUMBER:
case css::util::NumberFormat::NUMBER| css::util::NumberFormat::DEFINED:
//use format code and standard format code to judge whether it is General,
if (bStandard)
aFormatCode = 0;
else
aFormatCode = 1;
break;
case css::util::NumberFormat::PERCENT:
case css::util::NumberFormat::PERCENT| css::util::NumberFormat::DEFINED:
aFormatCode = 2;
break;
case css::util::NumberFormat::CURRENCY:
case css::util::NumberFormat::CURRENCY| css::util::NumberFormat::DEFINED:
aFormatCode = 3;
break;
case css::util::NumberFormat::DATE:
case css::util::NumberFormat::DATE| css::util::NumberFormat::DEFINED:
//Add
case css::util::NumberFormat::DATETIME:
case css::util::NumberFormat::DATETIME | css::util::NumberFormat::DEFINED:
aFormatCode = 4;
break;
case css::util::NumberFormat::TIME:
case css::util::NumberFormat::TIME| css::util::NumberFormat::DEFINED:
aFormatCode = 5;
break;
case css::util::NumberFormat::SCIENTIFIC:
case css::util::NumberFormat::SCIENTIFIC| css::util::NumberFormat::DEFINED:
aFormatCode = 6;
break;
case css::util::NumberFormat::FRACTION:
case css::util::NumberFormat::FRACTION| css::util::NumberFormat::DEFINED:
aFormatCode = 7;
break;
case css::util::NumberFormat::LOGICAL:
case css::util::NumberFormat::LOGICAL| css::util::NumberFormat::DEFINED:
aFormatCode = 8;
break;
case css::util::NumberFormat::TEXT:
case css::util::NumberFormat::TEXT| css::util::NumberFormat::DEFINED:
aFormatCode = 9;
break;
default:
aFormatCode = -1; //for more robust
}
if( aFormatCode == -1 )
rSet.InvalidateItem( nWhich );
else
rSet.Put( SfxInt16Item( nWhich, aFormatCode ) );
}
else
{
rSet.InvalidateItem( nWhich );
}
}
break;
case SID_NUMBER_CURRENCY:
{
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
if( SfxItemState::DONTCARE != rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) )
{
sal_uInt32 nNumberFormat = static_cast<const SfxUInt32Item&>(
rAttrSet.Get( ATTR_VALUE_FORMAT ) ).GetValue();
rSet.Put( SfxUInt32Item( nWhich, nNumberFormat ) );
}
else
rSet.InvalidateItem( nWhich );
}
break;
case SID_NUMBER_SCIENTIFIC:
rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::SCIENTIFIC)) );
break;
case SID_NUMBER_DATE:
rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::DATE)) );
break;
case SID_NUMBER_PERCENT:
rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::PERCENT)) );
break;
case SID_NUMBER_TIME:
rSet.Put( SfxBoolItem(nWhich, (nType & css::util::NumberFormat::TIME)) );
break;
}
nWhich = aIter.NextWhich();
}
}
void ScFormatShell::ExecuteTextDirection( SfxRequest& rReq )
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
bool bEditMode = false;
if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
{
bEditMode=true;
SC_MOD()->InputEnterHandler();
pTabViewShell->UpdateInputHandler();
}
sal_uInt16 nSlot = rReq.GetSlot();
switch( nSlot )
{
case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
{
bool bVert = (nSlot == SID_TEXTDIRECTION_TOP_TO_BOTTOM);
ScPatternAttr aAttr( GetViewData()->GetDocument()->GetPool() );
SfxItemSet& rItemSet = aAttr.GetItemSet();
rItemSet.Put( SfxBoolItem( ATTR_STACKED, bVert ) );
rItemSet.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN, bVert ) );
pTabViewShell->ApplySelectionPattern( aAttr );
pTabViewShell->AdjustBlockHeight();
}
break;
case SID_ATTR_PARA_LEFT_TO_RIGHT:
case SID_ATTR_PARA_RIGHT_TO_LEFT:
{
SvxFrameDirection eDirection = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ) ?
FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
pTabViewShell->ApplyAttr( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ) );
}
break;
}
if (bEditMode)
SC_MOD()->SetInputMode( SC_INPUT_TABLE );
}
void ScFormatShell::GetTextDirectionState( SfxItemSet& rSet )
{
ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
bool bVertDontCare =
(rAttrSet.GetItemState( ATTR_VERTICAL_ASIAN ) == SfxItemState::DONTCARE) ||
(rAttrSet.GetItemState( ATTR_STACKED ) == SfxItemState::DONTCARE);
bool bLeftRight = !bVertDontCare &&
!static_cast<const SfxBoolItem&>(rAttrSet.Get( ATTR_STACKED )).GetValue();
bool bTopBottom = !bVertDontCare && !bLeftRight &&
static_cast<const SfxBoolItem&>(rAttrSet.Get( ATTR_VERTICAL_ASIAN )).GetValue();
bool bBidiDontCare = (rAttrSet.GetItemState( ATTR_WRITINGDIR ) == SfxItemState::DONTCARE);
EEHorizontalTextDirection eBidiDir = EE_HTEXTDIR_DEFAULT;
if ( !bBidiDontCare )
{
SvxFrameDirection eCellDir = (SvxFrameDirection)static_cast<const SvxFrameDirectionItem&>(
rAttrSet.Get( ATTR_WRITINGDIR )).GetValue();
if ( eCellDir == FRMDIR_ENVIRONMENT )
eBidiDir = (EEHorizontalTextDirection)GetViewData()->GetDocument()->
GetEditTextDirection( GetViewData()->GetTabNo() );
else if ( eCellDir == FRMDIR_HORI_RIGHT_TOP )
eBidiDir = EE_HTEXTDIR_R2L;
else
eBidiDir = EE_HTEXTDIR_L2R;
}
SvtLanguageOptions aLangOpt;
bool bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
SfxWhichIter aIter( rSet );
sal_uInt16 nWhich = aIter.FirstWhich();
while( nWhich )
{
switch( nWhich )
{
case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
if ( bDisableVerticalText )
rSet.DisableItem( nWhich );
else
{
if( bVertDontCare )
rSet.InvalidateItem( nWhich );
else if ( nWhich == SID_TEXTDIRECTION_LEFT_TO_RIGHT )
rSet.Put( SfxBoolItem( nWhich, bLeftRight ) );
else
rSet.Put( SfxBoolItem( nWhich, bTopBottom ) );
}
break;
case SID_ATTR_PARA_LEFT_TO_RIGHT:
case SID_ATTR_PARA_RIGHT_TO_LEFT:
if ( bDisableCTLFont )
rSet.DisableItem( nWhich );
else
{
if ( bTopBottom )
rSet.DisableItem( nWhich );
else if ( bBidiDontCare )
rSet.InvalidateItem( nWhich );
else if ( nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT )
rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_L2R ) );
else
rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_R2L ) );
}
}
nWhich = aIter.NextWhich();
}
}
void ScFormatShell::ExecFormatPaintbrush( SfxRequest& rReq )
{
ScViewFunc* pView = pViewData->GetView();
if ( pView->HasPaintBrush() )
{
// cancel paintbrush mode
pView->ResetBrushDocument();
}
else
{
bool bLock = false;
const SfxItemSet *pArgs = rReq.GetArgs();
if( pArgs && pArgs->Count() >= 1 )
bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
// in case of multi selection, deselect all and use the cursor position
ScRange aDummy;
if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE )
pView->Unmark();
ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP );
pView->CopyToClip( pBrushDoc, false, true );
pView->SetBrushDocument( pBrushDoc, bLock );
}
}
void ScFormatShell::StateFormatPaintbrush( SfxItemSet& rSet )
{
if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
rSet.DisableItem( SID_FORMATPAINTBRUSH );
else
rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, pViewData->GetView()->HasPaintBrush() ) );
}
short ScFormatShell::GetCurrentNumberFormatType()
{
short nType = css::util::NumberFormat::ALL;
ScDocument* pDoc = GetViewData()->GetDocument();
ScMarkData aMark(GetViewData()->GetMarkData());
const SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
if (!pFormatter)
return nType;
// TODO: Find out how to get a selected table range in case multiple tables
// are selected. Currently we only check for the current active table.
if ( aMark.IsMarked() || aMark.IsMultiMarked() )
{
aMark.MarkToMulti();
ScRange aRange;
aMark.GetMultiMarkArea(aRange);
const ScMultiSel& rMultiSel = aMark.GetMultiSelData();
short nComboType = css::util::NumberFormat::ALL;
bool bFirstItem = true;
for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
{
if (!rMultiSel.HasMarks(nCol))
continue;
SCROW nRow1, nRow2;
ScMultiSelIter aMultiIter(rMultiSel, nCol);
while (aMultiIter.Next(nRow1, nRow2))
{
ScRange aColRange(nCol, nRow1, aRange.aStart.Tab());
aColRange.aEnd.SetRow(nRow2);
sal_uInt32 nNumFmt = pDoc->GetNumberFormat(aColRange);
const SvNumberformat* pEntry = pFormatter->GetEntry(nNumFmt);
if (!pEntry)
return 0;
short nThisType = pEntry->GetType();
if (bFirstItem)
{
bFirstItem = false;
nComboType = nThisType;
}
else if (nComboType != nThisType)
// mixed number format type.
return css::util::NumberFormat::ALL;
}
}
nType = nComboType;
}
else
{
sal_uInt32 nNumFmt;
pDoc->GetNumberFormat( pViewData->GetCurX(), pViewData->GetCurY(),
pViewData->GetTabNo(), nNumFmt );
const SvNumberformat* pEntry = pFormatter->GetEntry( nNumFmt );
nType = pEntry ? pEntry->GetType() : 0;
}
return nType;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|