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
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include <tools/rc.h>
#include <vcl/decoview.hxx>
#include <vcl/event.hxx>
#include <vcl/cursor.hxx>
#include <vcl/virdev.hxx>
#include <vcl/menu.hxx>
#include <vcl/cmdevt.h>
#include <vcl/edit.hxx>
#include <vcl/svapp.hxx>
#include <vcl/msgbox.hxx>
#include <window.h>
#include <svdata.hxx>
#include <svids.hrc>
#include <subedit.hxx>
#include <controldata.hxx>
#include <osl/mutex.hxx>
#include <com/sun/star/i18n/XBreakIterator.hpp>
#include <com/sun/star/i18n/CharacterIteratorMode.hpp>
#include <com/sun/star/i18n/WordType.hpp>
#include <cppuhelper/weak.hxx>
#include <com/sun/star/datatransfer/XTransferable.hpp>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp>
#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
#include <com/sun/star/i18n/XExtendedInputSequenceChecker.hpp>
#include <com/sun/star/i18n/InputSequenceCheckMode.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/uno/Any.hxx>
#include <comphelper/configurationhelper.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
#include <sot/exchange.hxx>
#include <sot/formats.hxx>
#include <rtl/memory.h>
#include <sal/macros.h>
#include <vcl/unohelp.hxx>
#include <vcl/unohelp2.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::rtl;
// - Redo
// - Bei Tracking-Cancel DefaultSelection wieder herstellen
// =======================================================================
static FncGetSpecialChars pImplFncGetSpecialChars = NULL;
// =======================================================================
#define EDIT_ALIGN_LEFT 1
#define EDIT_ALIGN_CENTER 2
#define EDIT_ALIGN_RIGHT 3
#define EDIT_DEL_LEFT 1
#define EDIT_DEL_RIGHT 2
#define EDIT_DELMODE_SIMPLE 11
#define EDIT_DELMODE_RESTOFWORD 12
#define EDIT_DELMODE_RESTOFCONTENT 13
// =======================================================================
struct DDInfo
{
Cursor aCursor;
Selection aDndStartSel;
xub_StrLen nDropPos;
sal_Bool bStarterOfDD;
sal_Bool bDroppedInMe;
sal_Bool bVisCursor;
sal_Bool bIsStringSupported;
DDInfo()
{
aCursor.SetStyle( CURSOR_SHADOW );
nDropPos = 0;
bStarterOfDD = sal_False;
bDroppedInMe = sal_False;
bVisCursor = sal_False;
bIsStringSupported = sal_False;
}
};
// =======================================================================
struct Impl_IMEInfos
{
String aOldTextAfterStartPos;
sal_uInt16* pAttribs;
xub_StrLen nPos;
xub_StrLen nLen;
sal_Bool bCursor;
sal_Bool bWasCursorOverwrite;
Impl_IMEInfos( xub_StrLen nPos, const String& rOldTextAfterStartPos );
~Impl_IMEInfos();
void CopyAttribs( const xub_StrLen* pA, xub_StrLen nL );
void DestroyAttribs();
};
// -----------------------------------------------------------------------
Impl_IMEInfos::Impl_IMEInfos( xub_StrLen nP, const String& rOldTextAfterStartPos )
: aOldTextAfterStartPos( rOldTextAfterStartPos )
{
nPos = nP;
nLen = 0;
bCursor = sal_True;
pAttribs = NULL;
bWasCursorOverwrite = sal_False;
}
// -----------------------------------------------------------------------
Impl_IMEInfos::~Impl_IMEInfos()
{
delete[] pAttribs;
}
// -----------------------------------------------------------------------
void Impl_IMEInfos::CopyAttribs( const xub_StrLen* pA, xub_StrLen nL )
{
nLen = nL;
delete[] pAttribs;
pAttribs = new sal_uInt16[ nL ];
rtl_copyMemory( pAttribs, pA, nL*sizeof(sal_uInt16) );
}
// -----------------------------------------------------------------------
void Impl_IMEInfos::DestroyAttribs()
{
delete[] pAttribs;
pAttribs = NULL;
nLen = 0;
}
// =======================================================================
Edit::Edit( WindowType nType ) :
Control( nType )
{
ImplInitEditData();
}
// -----------------------------------------------------------------------
Edit::Edit( Window* pParent, WinBits nStyle ) :
Control( WINDOW_EDIT )
{
ImplInitEditData();
ImplInit( pParent, nStyle );
}
// -----------------------------------------------------------------------
Edit::Edit( Window* pParent, const ResId& rResId ) :
Control( WINDOW_EDIT )
{
ImplInitEditData();
rResId.SetRT( RSC_EDIT );
WinBits nStyle = ImplInitRes( rResId );
ImplInit( pParent, nStyle );
ImplLoadRes( rResId );
// Derived MultiLineEdit takes care to call Show only after MultiLineEdit
// ctor has already started:
if ( !(nStyle & WB_HIDE) && rResId.GetRT() != RSC_MULTILINEEDIT )
Show();
}
// -----------------------------------------------------------------------
Edit::Edit( Window* pParent, const ResId& rResId, bool bDisableAccessibleLabeledByRelation ) :
Control( WINDOW_EDIT )
{
ImplInitEditData();
rResId.SetRT( RSC_EDIT );
WinBits nStyle = ImplInitRes( rResId );
ImplInit( pParent, nStyle );
ImplLoadRes( rResId );
if ( bDisableAccessibleLabeledByRelation )
ImplGetWindowImpl()->mbDisableAccessibleLabeledByRelation = sal_True;
// Derived MultiLineEdit takes care to call Show only after MultiLineEdit
// ctor has already started:
if ( !(nStyle & WB_HIDE) && rResId.GetRT() != RSC_MULTILINEEDIT )
Show();
}
// -----------------------------------------------------------------------
Edit::~Edit()
{
delete mpDDInfo;
Cursor* pCursor = GetCursor();
if ( pCursor )
{
SetCursor( NULL );
delete pCursor;
}
delete mpIMEInfos;
delete mpUpdateDataTimer;
if ( mxDnDListener.is() )
{
if ( GetDragGestureRecognizer().is() )
{
uno::Reference< datatransfer::dnd::XDragGestureListener> xDGL( mxDnDListener, uno::UNO_QUERY );
GetDragGestureRecognizer()->removeDragGestureListener( xDGL );
}
if ( GetDropTarget().is() )
{
uno::Reference< datatransfer::dnd::XDropTargetListener> xDTL( mxDnDListener, uno::UNO_QUERY );
GetDropTarget()->removeDropTargetListener( xDTL );
}
uno::Reference< lang::XEventListener> xEL( mxDnDListener, uno::UNO_QUERY );
xEL->disposing( lang::EventObject() ); // #95154# #96585# Empty Source means it's the Client
}
}
// -----------------------------------------------------------------------
void Edit::ImplInitEditData()
{
mpSubEdit = NULL;
mpUpdateDataTimer = NULL;
mnXOffset = 0;
mnAlign = EDIT_ALIGN_LEFT;
mnMaxTextLen = EDIT_NOLIMIT;
meAutocompleteAction = AUTOCOMPLETE_KEYINPUT;
mbModified = sal_False;
mbInternModified = sal_False;
mbReadOnly = sal_False;
mbInsertMode = sal_True;
mbClickedInSelection = sal_False;
mbActivePopup = sal_False;
mbIsSubEdit = sal_False;
mbInMBDown = sal_False;
mpDDInfo = NULL;
mpIMEInfos = NULL;
mcEchoChar = 0;
// --- RTL --- no default mirroring for Edit controls
// note: controls that use a subedit will revert this (SpinField, ComboBox)
EnableRTL( sal_False );
vcl::unohelper::DragAndDropWrapper* pDnDWrapper = new vcl::unohelper::DragAndDropWrapper( this );
mxDnDListener = pDnDWrapper;
}
// -----------------------------------------------------------------------
bool Edit::ImplUseNativeBorder( WinBits nStyle )
{
bool bRet =
IsNativeControlSupported(ImplGetNativeControlType(), HAS_BACKGROUND_TEXTURE)
&& ((nStyle&WB_BORDER) && !(nStyle&WB_NOBORDER));
if( ! bRet && mbIsSubEdit )
{
Window* pWindow = GetParent();
nStyle = pWindow->GetStyle();
bRet = pWindow->IsNativeControlSupported(ImplGetNativeControlType(), HAS_BACKGROUND_TEXTURE)
&& ((nStyle&WB_BORDER) && !(nStyle&WB_NOBORDER));
}
return bRet;
}
void Edit::ImplInit( Window* pParent, WinBits nStyle )
{
nStyle = ImplInitStyle( nStyle );
if ( !(nStyle & (WB_CENTER | WB_RIGHT)) )
nStyle |= WB_LEFT;
Control::ImplInit( pParent, nStyle, NULL );
mbReadOnly = (nStyle & WB_READONLY) != 0;
mnAlign = EDIT_ALIGN_LEFT;
// --- RTL --- hack: right align until keyinput and cursor travelling works
if( IsRTLEnabled() )
mnAlign = EDIT_ALIGN_RIGHT;
if ( nStyle & WB_RIGHT )
mnAlign = EDIT_ALIGN_RIGHT;
else if ( nStyle & WB_CENTER )
mnAlign = EDIT_ALIGN_CENTER;
SetCursor( new Cursor );
SetPointer( Pointer( POINTER_TEXT ) );
ImplInitSettings( sal_True, sal_True, sal_True );
uno::Reference< datatransfer::dnd::XDragGestureListener> xDGL( mxDnDListener, uno::UNO_QUERY );
uno::Reference< datatransfer::dnd::XDragGestureRecognizer > xDGR = GetDragGestureRecognizer();
if ( xDGR.is() )
{
xDGR->addDragGestureListener( xDGL );
uno::Reference< datatransfer::dnd::XDropTargetListener> xDTL( mxDnDListener, uno::UNO_QUERY );
GetDropTarget()->addDropTargetListener( xDTL );
GetDropTarget()->setActive( sal_True );
GetDropTarget()->setDefaultActions( datatransfer::dnd::DNDConstants::ACTION_COPY_OR_MOVE );
}
}
// -----------------------------------------------------------------------
WinBits Edit::ImplInitStyle( WinBits nStyle )
{
if ( !(nStyle & WB_NOTABSTOP) )
nStyle |= WB_TABSTOP;
if ( !(nStyle & WB_NOGROUP) )
nStyle |= WB_GROUP;
return nStyle;
}
// -----------------------------------------------------------------------
sal_Bool Edit::IsCharInput( const KeyEvent& rKeyEvent )
{
// In the future we must use new Unicode functions for this
xub_Unicode cCharCode = rKeyEvent.GetCharCode();
return ((cCharCode >= 32) && (cCharCode != 127) &&
!rKeyEvent.GetKeyCode().IsMod3() &&
!rKeyEvent.GetKeyCode().IsMod2() &&
!rKeyEvent.GetKeyCode().IsMod1() );
}
// -----------------------------------------------------------------------
void Edit::ImplModified()
{
mbModified = sal_True;
Modify();
}
// -----------------------------------------------------------------------
void Edit::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
if ( bFont )
{
Font aFont = rStyleSettings.GetFieldFont();
if ( IsControlFont() )
aFont.Merge( GetControlFont() );
SetZoomedPointFont( aFont );
ImplClearLayoutData();
}
if ( bFont || bForeground )
{
Color aTextColor = rStyleSettings.GetFieldTextColor();
if ( IsControlForeground() )
aTextColor = GetControlForeground();
SetTextColor( aTextColor );
}
if ( bBackground )
{
if ( ImplUseNativeBorder( GetStyle() ) || IsPaintTransparent() )
{
// Transparent background
SetBackground();
SetFillColor();
}
else if ( IsControlBackground() )
{
SetBackground( GetControlBackground() );
SetFillColor( GetControlBackground() );
}
else
{
SetBackground( rStyleSettings.GetFieldColor() );
SetFillColor( rStyleSettings.GetFieldColor() );
}
}
}
// -----------------------------------------------------------------------
long Edit::ImplGetExtraOffset() const
{
// MT 09/2002: nExtraOffsetX should become a member, instead of checking every time,
// but I need an incompatible update for this...
// #94095# Use extra offset only when edit has a border
long nExtraOffset = 0;
if( ( GetStyle() & WB_BORDER ) || ( mbIsSubEdit && ( GetParent()->GetStyle() & WB_BORDER ) ) )
nExtraOffset = 2;
return nExtraOffset;
}
// -----------------------------------------------------------------------
XubString Edit::ImplGetText() const
{
if ( mcEchoChar || (GetStyle() & WB_PASSWORD) )
{
XubString aText;
xub_Unicode cEchoChar;
if ( mcEchoChar )
cEchoChar = mcEchoChar;
else
cEchoChar = '*';
aText.Fill( maText.Len(), cEchoChar );
return aText;
}
else
return maText;
}
// -----------------------------------------------------------------------
void Edit::ImplInvalidateOrRepaint( xub_StrLen nStart, xub_StrLen nEnd )
{
if( IsPaintTransparent() )
{
Invalidate();
// FIXME: this is currently only on aqua
if( ImplGetSVData()->maNWFData.mbNoFocusRects )
Update();
}
else
ImplRepaint( nStart, nEnd );
}
// -----------------------------------------------------------------------
long Edit::ImplGetTextYPosition() const
{
if ( GetStyle() & WB_TOP )
return ImplGetExtraOffset();
else if ( GetStyle() & WB_BOTTOM )
return GetOutputSizePixel().Height() - GetTextHeight() - ImplGetExtraOffset();
return ( GetOutputSizePixel().Height() - GetTextHeight() ) / 2;
}
// -----------------------------------------------------------------------
void Edit::ImplRepaint( xub_StrLen nStart, xub_StrLen nEnd, bool bLayout )
{
if ( !IsReallyVisible() )
return;
XubString aText = ImplGetText();
nStart = 0;
nEnd = aText.Len();
sal_Int32 nDXBuffer[256];
sal_Int32* pDXBuffer = NULL;
sal_Int32* pDX = nDXBuffer;
if( aText.Len() )
{
if( 2*aText.Len() > xub_StrLen(SAL_N_ELEMENTS(nDXBuffer)) )
{
pDXBuffer = new sal_Int32[2*(aText.Len()+1)];
pDX = pDXBuffer;
}
GetCaretPositions( aText, pDX, nStart, nEnd );
}
long nTH = GetTextHeight();
Point aPos( mnXOffset, ImplGetTextYPosition() );
if( bLayout )
{
long nPos = nStart ? pDX[2*nStart] : 0;
aPos.X() = nPos + mnXOffset + ImplGetExtraOffset();
MetricVector* pVector = &mpControlData->mpLayoutData->m_aUnicodeBoundRects;
String* pDisplayText = &mpControlData->mpLayoutData->m_aDisplayText;
DrawText( aPos, aText, nStart, nEnd - nStart, pVector, pDisplayText );
if( pDXBuffer )
delete [] pDXBuffer;
return;
}
Cursor* pCursor = GetCursor();
sal_Bool bVisCursor = pCursor ? pCursor->IsVisible() : sal_False;
if ( pCursor )
pCursor->Hide();
ImplClearBackground( 0, GetOutputSizePixel().Width() );
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
if ( IsEnabled() )
ImplInitSettings( sal_False, sal_True, sal_False );
else
SetTextColor( rStyleSettings.GetDisableColor() );
// Set background color of the normal text
if( (GetStyle() & WB_FORCECTRLBACKGROUND) != 0 && IsControlBackground() )
{
// check if we need to set ControlBackground even in NWF case
Push( PUSH_FILLCOLOR | PUSH_LINECOLOR );
SetLineColor();
SetFillColor( GetControlBackground() );
DrawRect( Rectangle( aPos, Size( GetOutputSizePixel().Width() - 2*mnXOffset, nTH ) ) );
Pop();
SetTextFillColor( GetControlBackground() );
}
else if( IsPaintTransparent() || ImplUseNativeBorder( GetStyle() ) )
SetTextFillColor();
else
SetTextFillColor( IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor() );
sal_Bool bDrawSelection = maSelection.Len() && ( HasFocus() || ( GetStyle() & WB_NOHIDESELECTION ) || mbActivePopup );
long nPos = nStart ? pDX[2*nStart] : 0;
aPos.X() = nPos + mnXOffset + ImplGetExtraOffset();
if ( !bDrawSelection && !mpIMEInfos )
{
DrawText( aPos, aText, nStart, nEnd - nStart );
}
else
{
// save graphics state
Push();
// first calculate higlighted and non highlighted clip regions
Region aHiglightClipRegion;
Region aNormalClipRegion;
Selection aTmpSel( maSelection );
aTmpSel.Justify();
// selection is highlighted
int i;
for( i = 0; i < aText.Len(); i++ )
{
Rectangle aRect( aPos, Size( 10, nTH ) );
aRect.Left() = pDX[2*i] + mnXOffset + ImplGetExtraOffset();
aRect.Right() = pDX[2*i+1] + mnXOffset + ImplGetExtraOffset();
aRect.Justify();
bool bHighlight = false;
if( i >= aTmpSel.Min() && i < aTmpSel.Max() )
bHighlight = true;
if( mpIMEInfos && mpIMEInfos->pAttribs &&
i >= mpIMEInfos->nPos && i < (mpIMEInfos->nPos+mpIMEInfos->nLen ) &&
( mpIMEInfos->pAttribs[i-mpIMEInfos->nPos] & EXTTEXTINPUT_ATTR_HIGHLIGHT) )
bHighlight = true;
if( bHighlight )
aHiglightClipRegion.Union( aRect );
else
aNormalClipRegion.Union( aRect );
}
// draw normal text
Color aNormalTextColor = GetTextColor();
SetClipRegion( aNormalClipRegion );
if( IsPaintTransparent() )
SetTextFillColor();
else
{
// Set background color when part of the text is selected
if ( ImplUseNativeBorder( GetStyle() ) )
{
if( (GetStyle() & WB_FORCECTRLBACKGROUND) != 0 && IsControlBackground() )
SetTextFillColor( GetControlBackground() );
else
SetTextFillColor();
}
else
SetTextFillColor( IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor() );
}
DrawText( aPos, aText, nStart, nEnd - nStart );
// draw highlighted text
SetClipRegion( aHiglightClipRegion );
SetTextColor( rStyleSettings.GetHighlightTextColor() );
SetTextFillColor( rStyleSettings.GetHighlightColor() );
DrawText( aPos, aText, nStart, nEnd - nStart );
// if IME info exists loop over portions and output different font attributes
if( mpIMEInfos && mpIMEInfos->pAttribs )
{
for( int n = 0; n < 2; n++ )
{
Region aRegion;
if( n == 0 )
{
SetTextColor( aNormalTextColor );
if( IsPaintTransparent() )
SetTextFillColor();
else
SetTextFillColor( IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor() );
aRegion = aNormalClipRegion;
}
else
{
SetTextColor( rStyleSettings.GetHighlightTextColor() );
SetTextFillColor( rStyleSettings.GetHighlightColor() );
aRegion = aHiglightClipRegion;
}
for( i = 0; i < mpIMEInfos->nLen; )
{
sal_uInt16 nAttr = mpIMEInfos->pAttribs[i];
Region aClip;
int nIndex = i;
while( nIndex < mpIMEInfos->nLen && mpIMEInfos->pAttribs[nIndex] == nAttr) // #112631# check nIndex before using it
{
Rectangle aRect( aPos, Size( 10, nTH ) );
aRect.Left() = pDX[2*(nIndex+mpIMEInfos->nPos)] + mnXOffset + ImplGetExtraOffset();
aRect.Right() = pDX[2*(nIndex+mpIMEInfos->nPos)+1] + mnXOffset + ImplGetExtraOffset();
aRect.Justify();
aClip.Union( aRect );
nIndex++;
}
i = nIndex;
if( aClip.Intersect( aRegion ) && nAttr )
{
Font aFont = GetFont();
if ( nAttr & EXTTEXTINPUT_ATTR_UNDERLINE )
aFont.SetUnderline( UNDERLINE_SINGLE );
else if ( nAttr & EXTTEXTINPUT_ATTR_BOLDUNDERLINE )
aFont.SetUnderline( UNDERLINE_BOLD );
else if ( nAttr & EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE )
aFont.SetUnderline( UNDERLINE_DOTTED );
else if ( nAttr & EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE )
aFont.SetUnderline( UNDERLINE_DOTTED );
else if ( nAttr & EXTTEXTINPUT_ATTR_GRAYWAVELINE )
{
aFont.SetUnderline( UNDERLINE_WAVE );
SetTextLineColor( Color( COL_LIGHTGRAY ) );
}
SetFont( aFont );
if ( nAttr & EXTTEXTINPUT_ATTR_REDTEXT )
SetTextColor( Color( COL_RED ) );
else if ( nAttr & EXTTEXTINPUT_ATTR_HALFTONETEXT )
SetTextColor( Color( COL_LIGHTGRAY ) );
SetClipRegion( aClip );
DrawText( aPos, aText, nStart, nEnd - nStart );
}
}
}
}
// restore graphics state
Pop();
}
if ( bVisCursor && ( !mpIMEInfos || mpIMEInfos->bCursor ) )
pCursor->Show();
if( pDXBuffer )
delete [] pDXBuffer;
}
// -----------------------------------------------------------------------
void Edit::ImplDelete( const Selection& rSelection, sal_uInt8 nDirection, sal_uInt8 nMode )
{
XubString aText = ImplGetText();
// loeschen moeglich?
if ( !rSelection.Len() &&
(((rSelection.Min() == 0) && (nDirection == EDIT_DEL_LEFT)) ||
((rSelection.Max() == aText.Len()) && (nDirection == EDIT_DEL_RIGHT))) )
return;
ImplClearLayoutData();
Selection aSelection( rSelection );
aSelection.Justify();
if ( !aSelection.Len() )
{
uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
if ( nDirection == EDIT_DEL_LEFT )
{
if ( nMode == EDIT_DELMODE_RESTOFWORD )
{
i18n::Boundary aBoundary = xBI->getWordBoundary( maText, aSelection.Min(), GetSettings().GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True );
if ( aBoundary.startPos == aSelection.Min() )
aBoundary = xBI->previousWord( maText, aSelection.Min(), GetSettings().GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
aSelection.Min() = aBoundary.startPos;
}
else if ( nMode == EDIT_DELMODE_RESTOFCONTENT )
{
aSelection.Min() = 0;
}
else
{
sal_Int32 nCount = 1;
aSelection.Min() = xBI->previousCharacters( maText, aSelection.Min(), GetSettings().GetLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );
}
}
else
{
if ( nMode == EDIT_DELMODE_RESTOFWORD )
{
i18n::Boundary aBoundary = xBI->nextWord( maText, aSelection.Max(), GetSettings().GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
aSelection.Max() = aBoundary.startPos;
}
else if ( nMode == EDIT_DELMODE_RESTOFCONTENT )
{
aSelection.Max() = aText.Len();
}
else
{
sal_Int32 nCount = 1;
aSelection.Max() = xBI->nextCharacters( maText, aSelection.Max(), GetSettings().GetLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );;
}
}
}
maText.Erase( (xub_StrLen)aSelection.Min(), (xub_StrLen)aSelection.Len() );
maSelection.Min() = aSelection.Min();
maSelection.Max() = aSelection.Min();
ImplAlignAndPaint();
mbInternModified = sal_True;
}
// -----------------------------------------------------------------------
String Edit::ImplGetValidString( const String& rString ) const
{
rtl::OUString aValidString( rString );
aValidString = comphelper::string::remove(aValidString, _LF);
aValidString = comphelper::string::remove(aValidString, _CR);
aValidString = aValidString.replace('\t', ' ');
return aValidString;
}
// -----------------------------------------------------------------------
uno::Reference < i18n::XBreakIterator > Edit::ImplGetBreakIterator() const
{
//!! since we don't want to become incompatible in the next minor update
//!! where this code will get integrated into, xISC will be a local
//!! variable instead of a class member!
uno::Reference < i18n::XBreakIterator > xBI;
// if ( !xBI.is() )
{
uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
uno::Reference < XInterface > xI = xMSF->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.BreakIterator")) );
if ( xI.is() )
{
Any x = xI->queryInterface( ::getCppuType((const uno::Reference< i18n::XBreakIterator >*)0) );
x >>= xBI;
}
}
return xBI;
}
// -----------------------------------------------------------------------
uno::Reference < i18n::XExtendedInputSequenceChecker > Edit::ImplGetInputSequenceChecker() const
{
//!! since we don't want to become incompatible in the next minor update
//!! where this code will get integrated into, xISC will be a local
//!! variable instead of a class member!
uno::Reference < i18n::XExtendedInputSequenceChecker > xISC;
// if ( !xISC.is() )
{
uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
uno::Reference < XInterface > xI = xMSF->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.InputSequenceChecker")) );
if ( xI.is() )
{
Any x = xI->queryInterface( ::getCppuType((const uno::Reference< i18n::XExtendedInputSequenceChecker >*)0) );
x >>= xISC;
}
}
return xISC;
}
// -----------------------------------------------------------------------
void Edit::ShowTruncationWarning( Window* pParent )
{
ResMgr* pResMgr = ImplGetResMgr();
if( pResMgr )
{
WarningBox aBox( pParent, ResId( SV_EDIT_WARNING_BOX, *pResMgr ) );
aBox.Execute();
}
}
// -----------------------------------------------------------------------
bool Edit::ImplTruncateToMaxLen( rtl::OUString& rStr, sal_uInt32 nSelectionLen ) const
{
bool bWasTruncated = false;
const sal_uInt32 nMaxLen = mnMaxTextLen < 65534 ? mnMaxTextLen : 65534;
sal_uInt32 nLenAfter = static_cast<sal_uInt32>(maText.Len()) + rStr.getLength() - nSelectionLen;
if ( nLenAfter > nMaxLen )
{
sal_uInt32 nErasePos = nMaxLen - static_cast<sal_uInt32>(maText.Len()) + nSelectionLen;
rStr = rStr.copy( 0, nErasePos );
bWasTruncated = true;
}
return bWasTruncated;
}
// -----------------------------------------------------------------------
void Edit::ImplInsertText( const XubString& rStr, const Selection* pNewSel, sal_Bool bIsUserInput )
{
Selection aSelection( maSelection );
aSelection.Justify();
rtl::OUString aNewText( ImplGetValidString( rStr ) );
ImplTruncateToMaxLen( aNewText, aSelection.Len() );
ImplClearLayoutData();
if ( aSelection.Len() )
maText.Erase( (xub_StrLen)aSelection.Min(), (xub_StrLen)aSelection.Len() );
else if ( !mbInsertMode && (aSelection.Max() < maText.Len()) )
maText.Erase( (xub_StrLen)aSelection.Max(), 1 );
// take care of input-sequence-checking now
if (bIsUserInput && rStr.Len())
{
DBG_ASSERT( rStr.Len() == 1, "unexpected string length. User input is expected to providse 1 char only!" );
// determine if input-sequence-checking should be applied or not
//
static OUString sModule( RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.Common/I18N") );
static OUString sRelNode( RTL_CONSTASCII_USTRINGPARAM("CTL") );
static OUString sCTLSequenceChecking( RTL_CONSTASCII_USTRINGPARAM("CTLSequenceChecking") );
static OUString sCTLSequenceCheckingRestricted( RTL_CONSTASCII_USTRINGPARAM("CTLSequenceCheckingRestricted") );
static OUString sCTLSequenceCheckingTypeAndReplace( RTL_CONSTASCII_USTRINGPARAM("CTLSequenceCheckingTypeAndReplace") );
static OUString sCTLFont( RTL_CONSTASCII_USTRINGPARAM("CTLFont") );
//
sal_Bool bCTLSequenceChecking = sal_False;
sal_Bool bCTLSequenceCheckingRestricted = sal_False;
sal_Bool bCTLSequenceCheckingTypeAndReplace = sal_False;
sal_Bool bCTLFontEnabled = sal_False;
sal_Bool bIsInputSequenceChecking = sal_False;
//
// get access to the configuration of this office module
try
{
uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
uno::Reference< container::XNameAccess > xModuleCfg( ::comphelper::ConfigurationHelper::openConfig(
xMSF,
sModule,
::comphelper::ConfigurationHelper::E_READONLY ),
uno::UNO_QUERY );
//!! get values from configuration.
//!! we can't use SvtCTLOptions here since vcl must not be linked
//!! against svtools. (It is already the other way around.)
Any aCTLSequenceChecking = ::comphelper::ConfigurationHelper::readRelativeKey( xModuleCfg, sRelNode, sCTLSequenceChecking );
Any aCTLSequenceCheckingRestricted = ::comphelper::ConfigurationHelper::readRelativeKey( xModuleCfg, sRelNode, sCTLSequenceCheckingRestricted );
Any aCTLSequenceCheckingTypeAndReplace = ::comphelper::ConfigurationHelper::readRelativeKey( xModuleCfg, sRelNode, sCTLSequenceCheckingTypeAndReplace );
Any aCTLFontEnabled = ::comphelper::ConfigurationHelper::readRelativeKey( xModuleCfg, sRelNode, sCTLFont );
aCTLSequenceChecking >>= bCTLSequenceChecking;
aCTLSequenceCheckingRestricted >>= bCTLSequenceCheckingRestricted;
aCTLSequenceCheckingTypeAndReplace >>= bCTLSequenceCheckingTypeAndReplace;
aCTLFontEnabled >>= bCTLFontEnabled;
}
catch(...)
{
bIsInputSequenceChecking = sal_False; // continue with inserting the new text
}
//
uno::Reference < i18n::XBreakIterator > xBI( ImplGetBreakIterator(), UNO_QUERY );
bIsInputSequenceChecking = rStr.Len() == 1 &&
bCTLFontEnabled &&
bCTLSequenceChecking &&
aSelection.Min() > 0 && /* first char needs not to be checked */
xBI.is() && i18n::ScriptType::COMPLEX == xBI->getScriptType( rStr, 0 );
uno::Reference < i18n::XExtendedInputSequenceChecker > xISC;
if (bIsInputSequenceChecking && (xISC = ImplGetInputSequenceChecker()).is())
{
sal_Unicode cChar = rStr.GetChar(0);
xub_StrLen nTmpPos = static_cast< xub_StrLen >( aSelection.Min() );
sal_Int16 nCheckMode = bCTLSequenceCheckingRestricted ?
i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC;
// the text that needs to be checked is only the one
// before the current cursor position
rtl::OUString aOldText( maText.Copy(0, nTmpPos) );
rtl::OUString aTmpText( aOldText );
if (bCTLSequenceCheckingTypeAndReplace)
{
xISC->correctInputSequence( aTmpText, nTmpPos - 1, cChar, nCheckMode );
// find position of first character that has changed
sal_Int32 nOldLen = aOldText.getLength();
sal_Int32 nTmpLen = aTmpText.getLength();
const sal_Unicode *pOldTxt = aOldText.getStr();
const sal_Unicode *pTmpTxt = aTmpText.getStr();
sal_Int32 nChgPos = 0;
while ( nChgPos < nOldLen && nChgPos < nTmpLen &&
pOldTxt[nChgPos] == pTmpTxt[nChgPos] )
++nChgPos;
String aChgText( aTmpText.copy( nChgPos ) );
// remove text from first pos to be changed to current pos
maText.Erase( static_cast< xub_StrLen >( nChgPos ), static_cast< xub_StrLen >( nTmpPos - nChgPos ) );
if (aChgText.Len())
{
aNewText = aChgText;
aSelection.Min() = nChgPos; // position for new text to be inserted
}
else
aNewText = String::EmptyString();
}
else
{
// should the character be ignored (i.e. not get inserted) ?
if (!xISC->checkInputSequence( aOldText, nTmpPos - 1, cChar, nCheckMode ))
aNewText = String::EmptyString();
}
}
// at this point now we will insert the non-empty text 'normally' some lines below...
}
if ( aNewText.getLength() )
maText.Insert( String( aNewText ), (xub_StrLen)aSelection.Min() );
if ( !pNewSel )
{
maSelection.Min() = aSelection.Min() + aNewText.getLength();
maSelection.Max() = maSelection.Min();
}
else
{
maSelection = *pNewSel;
if ( maSelection.Min() > maText.Len() )
maSelection.Min() = maText.Len();
if ( maSelection.Max() > maText.Len() )
maSelection.Max() = maText.Len();
}
ImplAlignAndPaint();
mbInternModified = sal_True;
}
// -----------------------------------------------------------------------
void Edit::ImplSetText( const XubString& rText, const Selection* pNewSelection )
{
// Der Text wird dadurch geloescht das der alte Text komplett 'selektiert'
// wird, dann InsertText, damit flackerfrei.
if ( ( rText.Len() <= mnMaxTextLen ) && ( (rText != maText) || (pNewSelection && (*pNewSelection != maSelection)) ) )
{
ImplClearLayoutData();
maSelection.Min() = 0;
maSelection.Max() = maText.Len();
if ( mnXOffset || HasPaintEvent() )
{
mnXOffset = 0;
maText = ImplGetValidString( rText );
// #i54929# recalculate mnXOffset before ImplSetSelection,
// else cursor ends up in wrong position
ImplAlign();
if ( pNewSelection )
ImplSetSelection( *pNewSelection, sal_False );
if ( mnXOffset && !pNewSelection )
maSelection.Max() = 0;
Invalidate();
}
else
ImplInsertText( rText, pNewSelection );
ImplCallEventListeners( VCLEVENT_EDIT_MODIFY );
}
}
// -----------------------------------------------------------------------
int Edit::ImplGetNativeControlType()
{
int nCtrl = 0;
Window *pControl = mbIsSubEdit ? GetParent() : this;
switch( pControl->GetType() )
{
case WINDOW_COMBOBOX:
case WINDOW_PATTERNBOX:
case WINDOW_NUMERICBOX:
case WINDOW_METRICBOX:
case WINDOW_CURRENCYBOX:
case WINDOW_DATEBOX:
case WINDOW_TIMEBOX:
case WINDOW_LONGCURRENCYBOX:
nCtrl = CTRL_COMBOBOX;
break;
case WINDOW_MULTILINEEDIT:
if ( GetWindow( WINDOW_BORDER ) != this )
nCtrl = CTRL_MULTILINE_EDITBOX;
else
nCtrl = CTRL_EDITBOX_NOBORDER;
break;
case WINDOW_EDIT:
case WINDOW_PATTERNFIELD:
case WINDOW_METRICFIELD:
case WINDOW_CURRENCYFIELD:
case WINDOW_DATEFIELD:
case WINDOW_TIMEFIELD:
case WINDOW_LONGCURRENCYFIELD:
case WINDOW_NUMERICFIELD:
case WINDOW_SPINFIELD:
if( pControl->GetStyle() & WB_SPIN )
nCtrl = CTRL_SPINBOX;
else
{
if ( GetWindow( WINDOW_BORDER ) != this )
nCtrl = CTRL_EDITBOX;
else
nCtrl = CTRL_EDITBOX_NOBORDER;
}
break;
default:
nCtrl = CTRL_EDITBOX;
}
return nCtrl;
}
void Edit::ImplClearBackground( long nXStart, long nXEnd )
{
/*
* note: at this point the cursor must be switched off already
*/
Point aTmpPoint;
Rectangle aRect( aTmpPoint, GetOutputSizePixel() );
aRect.Left() = nXStart;
aRect.Right() = nXEnd;
if( ImplUseNativeBorder( GetStyle() ) || IsPaintTransparent() )
{
// draw the inner part by painting the whole control using its border window
Window *pControl = this;
Window *pBorder = GetWindow( WINDOW_BORDER );
if( pBorder == this )
{
// we have no border, use parent
pControl = mbIsSubEdit ? GetParent() : this;
pBorder = pControl->GetWindow( WINDOW_BORDER );
if( pBorder == this )
pBorder = GetParent();
}
if( pBorder )
{
// set proper clipping region to not overdraw the whole control
Region aClipRgn = GetPaintRegion();
if( !aClipRgn.IsNull() )
{
// transform clipping region to border window's coordinate system
if( IsRTLEnabled() != pBorder->IsRTLEnabled() && Application::GetSettings().GetLayoutRTL() )
{
// need to mirror in case border is not RTL but edit is (or vice versa)
// mirror
Rectangle aBounds( aClipRgn.GetBoundRect() );
int xNew = GetOutputSizePixel().Width() - aBounds.GetWidth() - aBounds.Left();
aClipRgn.Move( xNew - aBounds.Left(), 0 );
// move offset of border window
Point aBorderOffs;
aBorderOffs = pBorder->ScreenToOutputPixel( OutputToScreenPixel( aBorderOffs ) );
aClipRgn.Move( aBorderOffs.X(), aBorderOffs.Y() );
}
else
{
// normal case
Point aBorderOffs;
aBorderOffs = pBorder->ScreenToOutputPixel( OutputToScreenPixel( aBorderOffs ) );
aClipRgn.Move( aBorderOffs.X(), aBorderOffs.Y() );
}
Region oldRgn( pBorder->GetClipRegion() );
pBorder->SetClipRegion( aClipRgn );
pBorder->Paint( Rectangle() );
pBorder->SetClipRegion( oldRgn );
}
else
pBorder->Paint( Rectangle() );
}
}
else
Erase( aRect );
}
// -----------------------------------------------------------------------
void Edit::ImplShowCursor( sal_Bool bOnlyIfVisible )
{
if ( !IsUpdateMode() || ( bOnlyIfVisible && !IsReallyVisible() ) )
return;
Cursor* pCursor = GetCursor();
XubString aText = ImplGetText();
long nTextPos = 0;
sal_Int32 nDXBuffer[256];
sal_Int32* pDXBuffer = NULL;
sal_Int32* pDX = nDXBuffer;
if( aText.Len() )
{
if( 2*aText.Len() > xub_StrLen(SAL_N_ELEMENTS(nDXBuffer)) )
{
pDXBuffer = new sal_Int32[2*(aText.Len()+1)];
pDX = pDXBuffer;
}
GetCaretPositions( aText, pDX, 0, aText.Len() );
if( maSelection.Max() < aText.Len() )
nTextPos = pDX[ 2*maSelection.Max() ];
else
nTextPos = pDX[ 2*aText.Len()-1 ];
}
long nCursorWidth = 0;
if ( !mbInsertMode && !maSelection.Len() && (maSelection.Max() < aText.Len()) )
nCursorWidth = GetTextWidth( aText, (xub_StrLen)maSelection.Max(), 1 );
long nCursorPosX = nTextPos + mnXOffset + ImplGetExtraOffset();
// Cursor muss im sichtbaren Bereich landen:
const Size aOutSize = GetOutputSizePixel();
if ( (nCursorPosX < 0) || (nCursorPosX >= aOutSize.Width()) )
{
long nOldXOffset = mnXOffset;
if ( nCursorPosX < 0 )
{
mnXOffset = - nTextPos;
long nMaxX = 0;
mnXOffset += aOutSize.Width() / 5;
if ( mnXOffset > nMaxX )
mnXOffset = nMaxX;
}
else
{
mnXOffset = (aOutSize.Width()-ImplGetExtraOffset()) - nTextPos;
// Etwas mehr?
if ( (aOutSize.Width()-ImplGetExtraOffset()) < nTextPos )
{
long nMaxNegX = (aOutSize.Width()-ImplGetExtraOffset()) - GetTextWidth( aText );
mnXOffset -= aOutSize.Width() / 5;
if ( mnXOffset < nMaxNegX ) // beides negativ...
mnXOffset = nMaxNegX;
}
}
nCursorPosX = nTextPos + mnXOffset + ImplGetExtraOffset();
if ( nCursorPosX == aOutSize.Width() ) // dann nicht sichtbar...
nCursorPosX--;
if ( mnXOffset != nOldXOffset )
ImplInvalidateOrRepaint();
}
const long nTextHeight = GetTextHeight();
const long nCursorPosY = ImplGetTextYPosition();
pCursor->SetPos( Point( nCursorPosX, nCursorPosY ) );
pCursor->SetSize( Size( nCursorWidth, nTextHeight ) );
pCursor->Show();
if( pDXBuffer )
delete [] pDXBuffer;
}
// -----------------------------------------------------------------------
void Edit::ImplAlign()
{
long nTextWidth = GetTextWidth( ImplGetText() );
long nOutWidth = GetOutputSizePixel().Width();
if ( mnAlign == EDIT_ALIGN_LEFT )
{
if( mnXOffset && ( nTextWidth < nOutWidth ) )
mnXOffset = 0;
}
else if ( mnAlign == EDIT_ALIGN_RIGHT )
{
long nMinXOffset = nOutWidth - nTextWidth - 1 - ImplGetExtraOffset();
bool bRTL = IsRTLEnabled();
if( mbIsSubEdit && GetParent() )
bRTL = GetParent()->IsRTLEnabled();
if( bRTL )
{
if( nTextWidth < nOutWidth )
mnXOffset = nMinXOffset;
}
else
{
if( nTextWidth < nOutWidth )
mnXOffset = nMinXOffset;
else if ( mnXOffset < nMinXOffset )
mnXOffset = nMinXOffset;
}
}
else if( mnAlign == EDIT_ALIGN_CENTER )
{
// Mit Abfrage schoener, wenn gescrollt, dann aber nicht zentriert im gescrollten Zustand...
// if ( nTextWidth < nOutWidth )
mnXOffset = (nOutWidth - nTextWidth) / 2;
}
}
// -----------------------------------------------------------------------
void Edit::ImplAlignAndPaint()
{
ImplAlign();
ImplInvalidateOrRepaint( 0, STRING_LEN );
ImplShowCursor();
}
// -----------------------------------------------------------------------
xub_StrLen Edit::ImplGetCharPos( const Point& rWindowPos ) const
{
xub_StrLen nIndex = STRING_LEN;
String aText = ImplGetText();
sal_Int32 nDXBuffer[256];
sal_Int32* pDXBuffer = NULL;
sal_Int32* pDX = nDXBuffer;
if( 2*aText.Len() > xub_StrLen(SAL_N_ELEMENTS(nDXBuffer)) )
{
pDXBuffer = new sal_Int32[2*(aText.Len()+1)];
pDX = pDXBuffer;
}
GetCaretPositions( aText, pDX, 0, aText.Len() );
long nX = rWindowPos.X() - mnXOffset - ImplGetExtraOffset();
for( int i = 0; i < aText.Len(); i++ )
{
if( (pDX[2*i] >= nX && pDX[2*i+1] <= nX) ||
(pDX[2*i+1] >= nX && pDX[2*i] <= nX))
{
nIndex = sal::static_int_cast<xub_StrLen>(i);
if( pDX[2*i] < pDX[2*i+1] )
{
if( nX > (pDX[2*i]+pDX[2*i+1])/2 )
nIndex++;
}
else
{
if( nX < (pDX[2*i]+pDX[2*i+1])/2 )
nIndex++;
}
break;
}
}
if( nIndex == STRING_LEN )
{
nIndex = 0;
long nDiff = Abs( pDX[0]-nX );
for( int i = 1; i < aText.Len(); i++ )
{
long nNewDiff = Abs( pDX[2*i]-nX );
if( nNewDiff < nDiff )
{
nIndex = sal::static_int_cast<xub_StrLen>(i);
nDiff = nNewDiff;
}
}
if( nIndex == aText.Len()-1 && Abs( pDX[2*nIndex+1] - nX ) < nDiff )
nIndex = STRING_LEN;
}
if( pDXBuffer )
delete [] pDXBuffer;
return nIndex;
}
// -----------------------------------------------------------------------
void Edit::ImplSetCursorPos( xub_StrLen nChar, sal_Bool bSelect )
{
Selection aSelection( maSelection );
aSelection.Max() = nChar;
if ( !bSelect )
aSelection.Min() = aSelection.Max();
ImplSetSelection( aSelection );
}
// -----------------------------------------------------------------------
void Edit::ImplLoadRes( const ResId& rResId )
{
Control::ImplLoadRes( rResId );
xub_StrLen nTextLength = ReadShortRes();
if ( nTextLength )
SetMaxTextLen( nTextLength );
}
// -----------------------------------------------------------------------
void Edit::ImplCopyToSelectionClipboard()
{
if ( GetSelection().Len() )
{
::com::sun::star::uno::Reference<com::sun::star::datatransfer::clipboard::XClipboard> aSelection(GetPrimarySelection());
ImplCopy( aSelection );
}
}
void Edit::ImplCopy( uno::Reference< datatransfer::clipboard::XClipboard >& rxClipboard )
{
::vcl::unohelper::TextDataObject::CopyStringTo( GetSelected(), rxClipboard );
}
// -----------------------------------------------------------------------
void Edit::ImplPaste( uno::Reference< datatransfer::clipboard::XClipboard >& rxClipboard )
{
if ( rxClipboard.is() )
{
uno::Reference< datatransfer::XTransferable > xDataObj;
const sal_uInt32 nRef = Application::ReleaseSolarMutex();
try
{
xDataObj = rxClipboard->getContents();
}
catch( const ::com::sun::star::uno::Exception& )
{
}
Application::AcquireSolarMutex( nRef );
if ( xDataObj.is() )
{
datatransfer::DataFlavor aFlavor;
SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
try
{
uno::Any aData = xDataObj->getTransferData( aFlavor );
::rtl::OUString aText;
aData >>= aText;
if( ImplTruncateToMaxLen( aText, maSelection.Len() ) )
ShowTruncationWarning( const_cast<Edit*>(this) );
ReplaceSelected( aText );
}
catch( const ::com::sun::star::uno::Exception& )
{
}
}
}
}
// -----------------------------------------------------------------------
void Edit::MouseButtonDown( const MouseEvent& rMEvt )
{
if ( mpSubEdit )
{
Control::MouseButtonDown( rMEvt );
return;
}
xub_StrLen nChar = ImplGetCharPos( rMEvt.GetPosPixel() );
Selection aSelection( maSelection );
aSelection.Justify();
if ( rMEvt.GetClicks() < 4 )
{
mbClickedInSelection = sal_False;
if ( rMEvt.GetClicks() == 3 )
{
ImplSetSelection( Selection( 0, 0xFFFF ) );
ImplCopyToSelectionClipboard();
}
else if ( rMEvt.GetClicks() == 2 )
{
uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
i18n::Boundary aBoundary = xBI->getWordBoundary( maText, aSelection.Max(), GetSettings().GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True );
ImplSetSelection( Selection( aBoundary.startPos, aBoundary.endPos ) );
ImplCopyToSelectionClipboard();
}
else if ( !rMEvt.IsShift() && HasFocus() && aSelection.IsInside( nChar ) )
mbClickedInSelection = sal_True;
else if ( rMEvt.IsLeft() )
ImplSetCursorPos( nChar, rMEvt.IsShift() );
if ( !mbClickedInSelection && rMEvt.IsLeft() && ( rMEvt.GetClicks() == 1 ) )
StartTracking( STARTTRACK_SCROLLREPEAT );
}
mbInMBDown = sal_True; // Dann im GetFocus nicht alles selektieren
GrabFocus();
mbInMBDown = sal_False;
}
// -----------------------------------------------------------------------
void Edit::MouseButtonUp( const MouseEvent& rMEvt )
{
if ( mbClickedInSelection && rMEvt.IsLeft() )
{
xub_StrLen nChar = ImplGetCharPos( rMEvt.GetPosPixel() );
ImplSetCursorPos( nChar, sal_False );
mbClickedInSelection = sal_False;
}
else if ( rMEvt.IsMiddle() && !mbReadOnly &&
( GetSettings().GetMouseSettings().GetMiddleButtonAction() == MOUSE_MIDDLE_PASTESELECTION ) )
{
::com::sun::star::uno::Reference<com::sun::star::datatransfer::clipboard::XClipboard> aSelection(Window::GetPrimarySelection());
ImplPaste( aSelection );
ImplModified();
}
}
// -----------------------------------------------------------------------
void Edit::Tracking( const TrackingEvent& rTEvt )
{
if ( rTEvt.IsTrackingEnded() )
{
if ( mbClickedInSelection )
{
xub_StrLen nChar = ImplGetCharPos( rTEvt.GetMouseEvent().GetPosPixel() );
ImplSetCursorPos( nChar, sal_False );
mbClickedInSelection = sal_False;
}
else if ( rTEvt.GetMouseEvent().IsLeft() )
{
ImplCopyToSelectionClipboard();
}
}
else
{
if( !mbClickedInSelection )
{
xub_StrLen nChar = ImplGetCharPos( rTEvt.GetMouseEvent().GetPosPixel() );
ImplSetCursorPos( nChar, sal_True );
}
}
if ( mpUpdateDataTimer && !mbIsSubEdit && mpUpdateDataTimer->IsActive() )
mpUpdateDataTimer->Start();//do not update while the user is still travelling in the control
}
// -----------------------------------------------------------------------
sal_Bool Edit::ImplHandleKeyEvent( const KeyEvent& rKEvt )
{
sal_Bool bDone = sal_False;
sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
mbInternModified = sal_False;
if ( eFunc != KEYFUNC_DONTKNOW )
{
switch ( eFunc )
{
case KEYFUNC_CUT:
{
if ( !mbReadOnly && maSelection.Len() && !(GetStyle() & WB_PASSWORD) )
{
Cut();
ImplModified();
bDone = sal_True;
}
}
break;
case KEYFUNC_COPY:
{
if ( !(GetStyle() & WB_PASSWORD) )
{
Copy();
bDone = sal_True;
}
}
break;
case KEYFUNC_PASTE:
{
if ( !mbReadOnly )
{
Paste();
bDone = sal_True;
}
}
break;
case KEYFUNC_UNDO:
{
if ( !mbReadOnly )
{
Undo();
bDone = sal_True;
}
}
break;
default: // wird dann evtl. unten bearbeitet.
eFunc = KEYFUNC_DONTKNOW;
}
}
if ( !bDone && rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsMod2() )
{
if ( nCode == KEY_A )
{
ImplSetSelection( Selection( 0, maText.Len() ) );
bDone = sal_True;
}
else if ( rKEvt.GetKeyCode().IsShift() && (nCode == KEY_S) )
{
if ( pImplFncGetSpecialChars )
{
Selection aSaveSel = GetSelection(); // Falls jemand in Get/LoseFocus die Selektion verbiegt, z.B. URL-Zeile...
XubString aChars = pImplFncGetSpecialChars( this, GetFont() );
SetSelection( aSaveSel );
if ( aChars.Len() )
{
ImplInsertText( aChars );
ImplModified();
}
bDone = sal_True;
}
}
}
if ( eFunc == KEYFUNC_DONTKNOW && ! bDone )
{
switch ( nCode )
{
case com::sun::star::awt::Key::SELECT_ALL:
{
ImplSetSelection( Selection( 0, maText.Len() ) );
bDone = sal_True;
}
break;
case KEY_LEFT:
case KEY_RIGHT:
case KEY_HOME:
case KEY_END:
case com::sun::star::awt::Key::MOVE_WORD_FORWARD:
case com::sun::star::awt::Key::SELECT_WORD_FORWARD:
case com::sun::star::awt::Key::MOVE_WORD_BACKWARD:
case com::sun::star::awt::Key::SELECT_WORD_BACKWARD:
case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_LINE:
case com::sun::star::awt::Key::MOVE_TO_END_OF_LINE:
case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_LINE:
case com::sun::star::awt::Key::SELECT_TO_END_OF_LINE:
case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH:
case com::sun::star::awt::Key::MOVE_TO_END_OF_PARAGRAPH:
case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH:
case com::sun::star::awt::Key::SELECT_TO_END_OF_PARAGRAPH:
case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT:
case com::sun::star::awt::Key::MOVE_TO_END_OF_DOCUMENT:
case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT:
case com::sun::star::awt::Key::SELECT_TO_END_OF_DOCUMENT:
{
if ( !rKEvt.GetKeyCode().IsMod2() )
{
ImplClearLayoutData();
uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator();
Selection aSel( maSelection );
bool bWord = rKEvt.GetKeyCode().IsMod1();
bool bSelect = rKEvt.GetKeyCode().IsShift();
bool bGoLeft = (nCode == KEY_LEFT);
bool bGoRight = (nCode == KEY_RIGHT);
bool bGoHome = (nCode == KEY_HOME);
bool bGoEnd = (nCode == KEY_END);
switch( nCode )
{
case com::sun::star::awt::Key::MOVE_WORD_FORWARD:
bGoRight = bWord = true;break;
case com::sun::star::awt::Key::SELECT_WORD_FORWARD:
bGoRight = bSelect = bWord = true;break;
case com::sun::star::awt::Key::MOVE_WORD_BACKWARD:
bGoLeft = bWord = true;break;
case com::sun::star::awt::Key::SELECT_WORD_BACKWARD:
bGoLeft = bSelect = bWord = true;break;
case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_LINE:
case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_PARAGRAPH:
case com::sun::star::awt::Key::SELECT_TO_BEGIN_OF_DOCUMENT:
bSelect = true;
// fallthrough intended
case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_LINE:
case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_PARAGRAPH:
case com::sun::star::awt::Key::MOVE_TO_BEGIN_OF_DOCUMENT:
bGoHome = true;break;
case com::sun::star::awt::Key::SELECT_TO_END_OF_LINE:
case com::sun::star::awt::Key::SELECT_TO_END_OF_PARAGRAPH:
case com::sun::star::awt::Key::SELECT_TO_END_OF_DOCUMENT:
bSelect = true;
// fallthrough intended
case com::sun::star::awt::Key::MOVE_TO_END_OF_LINE:
case com::sun::star::awt::Key::MOVE_TO_END_OF_PARAGRAPH:
case com::sun::star::awt::Key::MOVE_TO_END_OF_DOCUMENT:
bGoEnd = true;break;
default:
break;
};
// Range wird in ImplSetSelection geprueft...
if ( bGoLeft && aSel.Max() )
{
if ( bWord )
{
i18n::Boundary aBoundary = xBI->getWordBoundary( maText, aSel.Max(), GetSettings().GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True );
if ( aBoundary.startPos == aSel.Max() )
aBoundary = xBI->previousWord( maText, aSel.Max(), GetSettings().GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
aSel.Max() = aBoundary.startPos;
}
else
{
sal_Int32 nCount = 1;
aSel.Max() = xBI->previousCharacters( maText, aSel.Max(), GetSettings().GetLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );
}
}
else if ( bGoRight && ( aSel.Max() < maText.Len() ) )
{
if ( bWord )
{
i18n::Boundary aBoundary = xBI->nextWord( maText, aSel.Max(), GetSettings().GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES );
aSel.Max() = aBoundary.startPos;
}
else
{
sal_Int32 nCount = 1;
aSel.Max() = xBI->nextCharacters( maText, aSel.Max(), GetSettings().GetLocale(), i18n::CharacterIteratorMode::SKIPCHARACTER, nCount, nCount );
}
}
else if ( bGoHome )
{
aSel.Max() = 0;
}
else if ( bGoEnd )
{
aSel.Max() = 0xFFFF;
}
if ( !bSelect )
aSel.Min() = aSel.Max();
if ( aSel != GetSelection() )
{
ImplSetSelection( aSel );
ImplCopyToSelectionClipboard();
}
if ( bGoEnd && maAutocompleteHdl.IsSet() && !rKEvt.GetKeyCode().GetModifier() )
{
if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.Len()) )
{
meAutocompleteAction = AUTOCOMPLETE_KEYINPUT;
maAutocompleteHdl.Call( this );
}
}
bDone = sal_True;
}
}
break;
case com::sun::star::awt::Key::DELETE_WORD_BACKWARD:
case com::sun::star::awt::Key::DELETE_WORD_FORWARD:
case com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_LINE:
case com::sun::star::awt::Key::DELETE_TO_END_OF_LINE:
case KEY_BACKSPACE:
case KEY_DELETE:
{
if ( !mbReadOnly && !rKEvt.GetKeyCode().IsMod2() )
{
sal_uInt8 nDel = (nCode == KEY_DELETE) ? EDIT_DEL_RIGHT : EDIT_DEL_LEFT;
sal_uInt8 nMode = rKEvt.GetKeyCode().IsMod1() ? EDIT_DELMODE_RESTOFWORD : EDIT_DELMODE_SIMPLE;
if ( (nMode == EDIT_DELMODE_RESTOFWORD) && rKEvt.GetKeyCode().IsShift() )
nMode = EDIT_DELMODE_RESTOFCONTENT;
switch( nCode )
{
case com::sun::star::awt::Key::DELETE_WORD_BACKWARD:
nDel = EDIT_DEL_LEFT;
nMode = EDIT_DELMODE_RESTOFWORD;
break;
case com::sun::star::awt::Key::DELETE_WORD_FORWARD:
nDel = EDIT_DEL_RIGHT;
nMode = EDIT_DELMODE_RESTOFWORD;
break;
case com::sun::star::awt::Key::DELETE_TO_BEGIN_OF_LINE:
nDel = EDIT_DEL_LEFT;
nMode = EDIT_DELMODE_RESTOFCONTENT;
break;
case com::sun::star::awt::Key::DELETE_TO_END_OF_LINE:
nDel = EDIT_DEL_RIGHT;
nMode = EDIT_DELMODE_RESTOFCONTENT;
break;
default: break;
}
xub_StrLen nOldLen = maText.Len();
ImplDelete( maSelection, nDel, nMode );
if ( maText.Len() != nOldLen )
ImplModified();
bDone = sal_True;
}
}
break;
case KEY_INSERT:
{
if ( !mpIMEInfos && !mbReadOnly && !rKEvt.GetKeyCode().IsMod2() )
{
SetInsertMode( !mbInsertMode );
bDone = sal_True;
}
}
break;
/* #i101255# disable autocomplete tab forward/backward
users expect tab/shif-tab to move the focus to other controls
not suddenly to cycle the autocompletion
case KEY_TAB:
{
if ( !mbReadOnly && maAutocompleteHdl.IsSet() &&
maSelection.Min() && (maSelection.Min() == maText.Len()) &&
!rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsMod2() )
{
// Kein Autocomplete wenn alles Selektiert oder Edit leer, weil dann
// keine vernuenftige Tab-Steuerung!
if ( rKEvt.GetKeyCode().IsShift() )
meAutocompleteAction = AUTOCOMPLETE_TABBACKWARD;
else
meAutocompleteAction = AUTOCOMPLETE_TABFORWARD;
maAutocompleteHdl.Call( this );
// Wurde nichts veraendert, dann TAB fuer DialogControl
if ( GetSelection().Len() )
bDone = sal_True;
}
}
break;
*/
default:
{
if ( IsCharInput( rKEvt ) )
{
bDone = sal_True; // Auch bei ReadOnly die Zeichen schlucken.
if ( !mbReadOnly )
{
ImplInsertText( rKEvt.GetCharCode(), 0, sal_True );
if ( maAutocompleteHdl.IsSet() )
{
if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.Len()) )
{
meAutocompleteAction = AUTOCOMPLETE_KEYINPUT;
maAutocompleteHdl.Call( this );
}
}
}
}
}
}
}
if ( mbInternModified )
ImplModified();
return bDone;
}
// -----------------------------------------------------------------------
void Edit::KeyInput( const KeyEvent& rKEvt )
{
if ( mpUpdateDataTimer && !mbIsSubEdit && mpUpdateDataTimer->IsActive() )
mpUpdateDataTimer->Start();//do not update while the user is still travelling in the control
if ( mpSubEdit || !ImplHandleKeyEvent( rKEvt ) )
Control::KeyInput( rKEvt );
}
// -----------------------------------------------------------------------
void Edit::FillLayoutData() const
{
mpControlData->mpLayoutData = new vcl::ControlLayoutData();
const_cast<Edit*>(this)->ImplRepaint( 0, STRING_LEN, true );
}
// -----------------------------------------------------------------------
void Edit::Paint( const Rectangle& )
{
if ( !mpSubEdit )
ImplRepaint();
}
// -----------------------------------------------------------------------
void Edit::Resize()
{
if ( !mpSubEdit && IsReallyVisible() )
{
Control::Resize();
// Wegen vertikaler Zentrierung...
mnXOffset = 0;
ImplAlign();
Invalidate();
ImplShowCursor();
}
}
// -----------------------------------------------------------------------
void Edit::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags )
{
ImplInitSettings( sal_True, sal_True, sal_True );
Point aPos = pDev->LogicToPixel( rPos );
Size aSize = pDev->LogicToPixel( rSize );
Font aFont = GetDrawPixelFont( pDev );
OutDevType eOutDevType = pDev->GetOutDevType();
pDev->Push();
pDev->SetMapMode();
pDev->SetFont( aFont );
pDev->SetTextFillColor();
// Border/Background
pDev->SetLineColor();
pDev->SetFillColor();
sal_Bool bBorder = !(nFlags & WINDOW_DRAW_NOBORDER ) && (GetStyle() & WB_BORDER);
sal_Bool bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && IsControlBackground();
if ( bBorder || bBackground )
{
Rectangle aRect( aPos, aSize );
if ( bBorder )
{
ImplDrawFrame( pDev, aRect );
}
if ( bBackground )
{
pDev->SetFillColor( GetControlBackground() );
pDev->DrawRect( aRect );
}
}
// Inhalt
if ( ( nFlags & WINDOW_DRAW_MONO ) || ( eOutDevType == OUTDEV_PRINTER ) )
pDev->SetTextColor( Color( COL_BLACK ) );
else
{
if ( !(nFlags & WINDOW_DRAW_NODISABLE ) && !IsEnabled() )
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
pDev->SetTextColor( rStyleSettings.GetDisableColor() );
}
else
{
pDev->SetTextColor( GetTextColor() );
}
}
XubString aText = ImplGetText();
long nTextHeight = pDev->GetTextHeight();
long nTextWidth = pDev->GetTextWidth( aText );
long nOnePixel = GetDrawPixel( pDev, 1 );
long nOffX = 3*nOnePixel;
long nOffY = (aSize.Height() - nTextHeight) / 2;
// Clipping?
if ( (nOffY < 0) ||
((nOffY+nTextHeight) > aSize.Height()) ||
((nOffX+nTextWidth) > aSize.Width()) )
{
Rectangle aClip( aPos, aSize );
if ( nTextHeight > aSize.Height() )
aClip.Bottom() += nTextHeight-aSize.Height()+1; // Damit HP-Drucker nicht 'weg-optimieren'
pDev->IntersectClipRegion( aClip );
}
if ( GetStyle() & WB_CENTER )
{
aPos.X() += (aSize.Width() - nTextWidth) / 2;
nOffX = 0;
}
else if ( GetStyle() & WB_RIGHT )
{
aPos.X() += aSize.Width() - nTextWidth;
nOffX = -nOffX;
}
pDev->DrawText( Point( aPos.X() + nOffX, aPos.Y() + nOffY ), aText );
pDev->Pop();
if ( GetSubEdit() )
{
GetSubEdit()->Draw( pDev, rPos, rSize, nFlags );
}
}
// -----------------------------------------------------------------------
void Edit::ImplInvalidateOutermostBorder( Window* pWin )
{
// allow control to show focused state
Window *pInvalWin = pWin, *pBorder = pWin;
while( ( pBorder = pInvalWin->GetWindow( WINDOW_BORDER ) ) != pInvalWin && pBorder &&
pInvalWin->ImplGetFrame() == pBorder->ImplGetFrame() )
{
pInvalWin = pBorder;
}
pInvalWin->Invalidate( INVALIDATE_CHILDREN | INVALIDATE_UPDATE );
}
void Edit::GetFocus()
{
if ( mpSubEdit )
mpSubEdit->ImplGrabFocus( GetGetFocusFlags() );
else if ( !mbActivePopup )
{
maUndoText = maText;
sal_uLong nSelOptions = GetSettings().GetStyleSettings().GetSelectionOptions();
if ( !( GetStyle() & (WB_NOHIDESELECTION|WB_READONLY) )
&& ( GetGetFocusFlags() & (GETFOCUS_INIT|GETFOCUS_TAB|GETFOCUS_CURSOR|GETFOCUS_MNEMONIC) ) )
{
if ( nSelOptions & SELECTION_OPTION_SHOWFIRST )
{
maSelection.Min() = maText.Len();
maSelection.Max() = 0;
}
else
{
maSelection.Min() = 0;
maSelection.Max() = maText.Len();
}
if ( mbIsSubEdit )
((Edit*)GetParent())->ImplCallEventListeners( VCLEVENT_EDIT_SELECTIONCHANGED );
else
ImplCallEventListeners( VCLEVENT_EDIT_SELECTIONCHANGED );
}
ImplShowCursor();
// FIXME: this is currently only on aqua
// check for other platforms that need similar handling
if( ImplGetSVData()->maNWFData.mbNoFocusRects &&
IsNativeWidgetEnabled() &&
IsNativeControlSupported( CTRL_EDITBOX, PART_ENTIRE_CONTROL ) )
{
ImplInvalidateOutermostBorder( mbIsSubEdit ? GetParent() : this );
}
else if ( maSelection.Len() )
{
// Selektion malen
if ( !HasPaintEvent() )
ImplInvalidateOrRepaint();
else
Invalidate();
}
SetInputContext( InputContext( GetFont(), !IsReadOnly() ? INPUTCONTEXT_TEXT|INPUTCONTEXT_EXTTEXTINPUT : 0 ) );
}
Control::GetFocus();
}
// -----------------------------------------------------------------------
Window* Edit::GetPreferredKeyInputWindow()
{
if ( mpSubEdit )
return mpSubEdit->GetPreferredKeyInputWindow();
else
return this;
}
// -----------------------------------------------------------------------
void Edit::LoseFocus()
{
if ( mpUpdateDataTimer && !mbIsSubEdit && mpUpdateDataTimer->IsActive() )
{
//notify an update latest when the focus is lost
mpUpdateDataTimer->Stop();
mpUpdateDataTimer->Timeout();
}
if ( !mpSubEdit )
{
// FIXME: this is currently only on aqua
// check for other platforms that need similar handling
if( ImplGetSVData()->maNWFData.mbNoFocusRects &&
IsNativeWidgetEnabled() &&
IsNativeControlSupported( CTRL_EDITBOX, PART_ENTIRE_CONTROL ) )
{
ImplInvalidateOutermostBorder( mbIsSubEdit ? GetParent() : this );
}
if ( !mbActivePopup && !( GetStyle() & WB_NOHIDESELECTION ) && maSelection.Len() )
ImplInvalidateOrRepaint(); // Selektion malen
}
Control::LoseFocus();
}
// -----------------------------------------------------------------------
void Edit::Command( const CommandEvent& rCEvt )
{
if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
{
PopupMenu* pPopup = Edit::CreatePopupMenu();
if ( !maSelection.Len() )
{
pPopup->EnableItem( SV_MENU_EDIT_CUT, sal_False );
pPopup->EnableItem( SV_MENU_EDIT_COPY, sal_False );
pPopup->EnableItem( SV_MENU_EDIT_DELETE, sal_False );
}
if ( IsReadOnly() )
{
pPopup->EnableItem( SV_MENU_EDIT_CUT, sal_False );
pPopup->EnableItem( SV_MENU_EDIT_PASTE, sal_False );
pPopup->EnableItem( SV_MENU_EDIT_DELETE, sal_False );
pPopup->EnableItem( SV_MENU_EDIT_INSERTSYMBOL, sal_False );
}
else
{
// Paste nur, wenn Text im Clipboard
sal_Bool bData = sal_False;
uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetClipboard();
if ( xClipboard.is() )
{
const sal_uInt32 nRef = Application::ReleaseSolarMutex();
uno::Reference< datatransfer::XTransferable > xDataObj = xClipboard->getContents();
Application::AcquireSolarMutex( nRef );
if ( xDataObj.is() )
{
datatransfer::DataFlavor aFlavor;
SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
bData = xDataObj->isDataFlavorSupported( aFlavor );
}
}
pPopup->EnableItem( SV_MENU_EDIT_PASTE, bData );
}
if ( maUndoText == maText )
pPopup->EnableItem( SV_MENU_EDIT_UNDO, sal_False );
if ( ( maSelection.Min() == 0 ) && ( maSelection.Max() == maText.Len() ) )
pPopup->EnableItem( SV_MENU_EDIT_SELECTALL, sal_False );
if ( !pImplFncGetSpecialChars )
{
sal_uInt16 nPos = pPopup->GetItemPos( SV_MENU_EDIT_INSERTSYMBOL );
pPopup->RemoveItem( nPos );
pPopup->RemoveItem( nPos-1 );
}
mbActivePopup = sal_True;
Selection aSaveSel = GetSelection(); // Falls jemand in Get/LoseFocus die Selektion verbiegt, z.B. URL-Zeile...
Point aPos = rCEvt.GetMousePosPixel();
if ( !rCEvt.IsMouseEvent() )
{
// !!! Irgendwann einmal Menu zentriert in der Selektion anzeigen !!!
Size aSize = GetOutputSizePixel();
aPos = Point( aSize.Width()/2, aSize.Height()/2 );
}
sal_uInt16 n = pPopup->Execute( this, aPos );
Edit::DeletePopupMenu( pPopup );
SetSelection( aSaveSel );
switch ( n )
{
case SV_MENU_EDIT_UNDO:
Undo();
ImplModified();
break;
case SV_MENU_EDIT_CUT:
Cut();
ImplModified();
break;
case SV_MENU_EDIT_COPY:
Copy();
break;
case SV_MENU_EDIT_PASTE:
Paste();
ImplModified();
break;
case SV_MENU_EDIT_DELETE:
DeleteSelected();
ImplModified();
break;
case SV_MENU_EDIT_SELECTALL:
ImplSetSelection( Selection( 0, maText.Len() ) );
break;
case SV_MENU_EDIT_INSERTSYMBOL:
{
XubString aChars = pImplFncGetSpecialChars( this, GetFont() );
SetSelection( aSaveSel );
if ( aChars.Len() )
{
ImplInsertText( aChars );
ImplModified();
}
}
break;
}
mbActivePopup = sal_False;
}
else if ( rCEvt.GetCommand() == COMMAND_VOICE )
{
const CommandVoiceData* pData = rCEvt.GetVoiceData();
if ( pData->GetType() == VOICECOMMANDTYPE_DICTATION )
{
switch ( pData->GetCommand() )
{
case DICTATIONCOMMAND_UNKNOWN:
{
ReplaceSelected( pData->GetText() );
}
break;
case DICTATIONCOMMAND_LEFT:
{
ImplHandleKeyEvent( KeyEvent( 0, KeyCode( KEY_LEFT, KEY_MOD1 ) ) );
}
break;
case DICTATIONCOMMAND_RIGHT:
{
ImplHandleKeyEvent( KeyEvent( 0, KeyCode( KEY_RIGHT, KEY_MOD1 ) ) );
}
break;
case DICTATIONCOMMAND_UNDO:
{
Undo();
}
break;
case DICTATIONCOMMAND_DEL:
{
ImplHandleKeyEvent( KeyEvent( 0, KeyCode( KEY_LEFT, KEY_MOD1|KEY_SHIFT ) ) );
DeleteSelected();
}
break;
}
}
}
else if ( rCEvt.GetCommand() == COMMAND_STARTEXTTEXTINPUT )
{
DeleteSelected();
delete mpIMEInfos;
xub_StrLen nPos = (xub_StrLen)maSelection.Max();
mpIMEInfos = new Impl_IMEInfos( nPos, maText.Copy( nPos ) );
mpIMEInfos->bWasCursorOverwrite = !IsInsertMode();
}
else if ( rCEvt.GetCommand() == COMMAND_ENDEXTTEXTINPUT )
{
sal_Bool bInsertMode = !mpIMEInfos->bWasCursorOverwrite;
delete mpIMEInfos;
mpIMEInfos = NULL;
// Font wieder ohne Attribute einstellen, wird jetzt im Repaint nicht
// mehr neu initialisiert
ImplInitSettings( sal_True, sal_False, sal_False );
SetInsertMode( bInsertMode );
ImplModified();
// #i25161# call auto complete handler for ext text commit also
if ( maAutocompleteHdl.IsSet() )
{
if ( (maSelection.Min() == maSelection.Max()) && (maSelection.Min() == maText.Len()) )
{
meAutocompleteAction = AUTOCOMPLETE_KEYINPUT;
maAutocompleteHdl.Call( this );
}
}
}
else if ( rCEvt.GetCommand() == COMMAND_EXTTEXTINPUT )
{
const CommandExtTextInputData* pData = rCEvt.GetExtTextInputData();
maText.Erase( mpIMEInfos->nPos, mpIMEInfos->nLen );
maText.Insert( pData->GetText(), mpIMEInfos->nPos );
if ( mpIMEInfos->bWasCursorOverwrite )
{
sal_uInt16 nOldIMETextLen = mpIMEInfos->nLen;
sal_uInt16 nNewIMETextLen = pData->GetText().Len();
if ( ( nOldIMETextLen > nNewIMETextLen ) &&
( nNewIMETextLen < mpIMEInfos->aOldTextAfterStartPos.Len() ) )
{
// restore old characters
sal_uInt16 nRestore = nOldIMETextLen - nNewIMETextLen;
maText.Insert( mpIMEInfos->aOldTextAfterStartPos.Copy( nNewIMETextLen, nRestore ), mpIMEInfos->nPos + nNewIMETextLen );
}
else if ( ( nOldIMETextLen < nNewIMETextLen ) &&
( nOldIMETextLen < mpIMEInfos->aOldTextAfterStartPos.Len() ) )
{
// overwrite
sal_uInt16 nOverwrite = nNewIMETextLen - nOldIMETextLen;
if ( ( nOldIMETextLen + nOverwrite ) > mpIMEInfos->aOldTextAfterStartPos.Len() )
nOverwrite = mpIMEInfos->aOldTextAfterStartPos.Len() - nOldIMETextLen;
maText.Erase( mpIMEInfos->nPos + nNewIMETextLen, nOverwrite );
}
}
if ( pData->GetTextAttr() )
{
mpIMEInfos->CopyAttribs( pData->GetTextAttr(), pData->GetText().Len() );
mpIMEInfos->bCursor = pData->IsCursorVisible();
}
else
{
mpIMEInfos->DestroyAttribs();
}
ImplAlignAndPaint();
xub_StrLen nCursorPos = mpIMEInfos->nPos + pData->GetCursorPos();
SetSelection( Selection( nCursorPos, nCursorPos ) );
SetInsertMode( !pData->IsCursorOverwrite() );
if ( pData->IsCursorVisible() )
GetCursor()->Show();
else
GetCursor()->Hide();
}
else if ( rCEvt.GetCommand() == COMMAND_CURSORPOS )
{
if ( mpIMEInfos )
{
xub_StrLen nCursorPos = (sal_uInt16)GetSelection().Max();
SetCursorRect( NULL, GetTextWidth(
maText, nCursorPos, mpIMEInfos->nPos+mpIMEInfos->nLen-nCursorPos ) );
}
else
{
SetCursorRect();
}
}
else if ( rCEvt.GetCommand() == COMMAND_SELECTIONCHANGE )
{
const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData();
Selection aSelection( pData->GetStart(), pData->GetEnd() );
SetSelection(aSelection);
}
else
Control::Command( rCEvt );
}
// -----------------------------------------------------------------------
void Edit::StateChanged( StateChangedType nType )
{
if ( nType == STATE_CHANGE_INITSHOW )
{
if ( !mpSubEdit )
{
mnXOffset = 0; // Falls vorher GrabFocus, als Groesse noch falsch.
ImplAlign();
if ( !mpSubEdit )
ImplShowCursor( sal_False );
}
// update background (eventual SetPaintTransparent)
ImplInitSettings( sal_False, sal_False, sal_True );
}
else if ( nType == STATE_CHANGE_ENABLE )
{
if ( !mpSubEdit )
{
// Es aendert sich nur die Textfarbe...
ImplInvalidateOrRepaint( 0, 0xFFFF );
}
}
else if ( nType == STATE_CHANGE_STYLE || nType == STATE_CHANGE_MIRRORING )
{
WinBits nStyle = GetStyle();
if( nType == STATE_CHANGE_STYLE )
{
nStyle = ImplInitStyle( GetStyle() );
SetStyle( nStyle );
}
sal_uInt16 nOldAlign = mnAlign;
mnAlign = EDIT_ALIGN_LEFT;
// --- RTL --- hack: right align until keyinput and cursor travelling works
// edits are always RTL disabled
// however the parent edits contain the correct setting
if( mbIsSubEdit && GetParent()->IsRTLEnabled() )
{
if( GetParent()->GetStyle() & WB_LEFT )
mnAlign = EDIT_ALIGN_RIGHT;
if ( nType == STATE_CHANGE_MIRRORING )
SetLayoutMode( TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT );
}
else if( mbIsSubEdit && !GetParent()->IsRTLEnabled() )
{
if ( nType == STATE_CHANGE_MIRRORING )
SetLayoutMode( TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_TEXTORIGIN_LEFT );
}
if ( nStyle & WB_RIGHT )
mnAlign = EDIT_ALIGN_RIGHT;
else if ( nStyle & WB_CENTER )
mnAlign = EDIT_ALIGN_CENTER;
if ( maText.Len() && ( mnAlign != nOldAlign ) )
{
ImplAlign();
Invalidate();
}
}
else if ( nType == STATE_CHANGE_ZOOM )
{
if ( !mpSubEdit )
{
ImplInitSettings( sal_True, sal_False, sal_False );
ImplShowCursor( sal_True );
Invalidate();
}
}
else if ( nType == STATE_CHANGE_CONTROLFONT )
{
if ( !mpSubEdit )
{
ImplInitSettings( sal_True, sal_False, sal_False );
ImplShowCursor();
Invalidate();
}
}
else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
{
if ( !mpSubEdit )
{
ImplInitSettings( sal_False, sal_True, sal_False );
Invalidate();
}
}
else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
{
if ( !mpSubEdit )
{
ImplInitSettings( sal_False, sal_False, sal_True );
Invalidate();
}
}
Control::StateChanged( nType );
}
// -----------------------------------------------------------------------
void Edit::DataChanged( const DataChangedEvent& rDCEvt )
{
if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
(rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
(rDCEvt.GetFlags() & SETTINGS_STYLE)) )
{
if ( !mpSubEdit )
{
ImplInitSettings( sal_True, sal_True, sal_True );
ImplShowCursor( sal_True );
Invalidate();
}
}
Control::DataChanged( rDCEvt );
}
// -----------------------------------------------------------------------
void Edit::ImplShowDDCursor()
{
if ( !mpDDInfo->bVisCursor )
{
long nTextWidth = GetTextWidth( maText, 0, mpDDInfo->nDropPos );
long nTextHeight = GetTextHeight();
Rectangle aCursorRect( Point( nTextWidth + mnXOffset, (GetOutputSize().Height()-nTextHeight)/2 ), Size( 2, nTextHeight ) );
mpDDInfo->aCursor.SetWindow( this );
mpDDInfo->aCursor.SetPos( aCursorRect.TopLeft() );
mpDDInfo->aCursor.SetSize( aCursorRect.GetSize() );
mpDDInfo->aCursor.Show();
mpDDInfo->bVisCursor = sal_True;
}
}
// -----------------------------------------------------------------------
void Edit::ImplHideDDCursor()
{
if ( mpDDInfo && mpDDInfo->bVisCursor )
{
mpDDInfo->aCursor.Hide();
mpDDInfo->bVisCursor = sal_False;
}
}
// -----------------------------------------------------------------------
void Edit::Modify()
{
if ( mbIsSubEdit )
{
((Edit*)GetParent())->Modify();
}
else
{
if ( mpUpdateDataTimer )
mpUpdateDataTimer->Start();
if ( ImplCallEventListenersAndHandler( VCLEVENT_EDIT_MODIFY, maModifyHdl, this ) )
// have been destroyed while calling into the handlers
return;
// #i13677# notify edit listeners about caret position change
ImplCallEventListeners( VCLEVENT_EDIT_SELECTIONCHANGED );
// FIXME: this is currently only on aqua
// check for other platforms that need similar handling
if( ImplGetSVData()->maNWFData.mbNoFocusRects &&
IsNativeWidgetEnabled() &&
IsNativeControlSupported( CTRL_EDITBOX, PART_ENTIRE_CONTROL ) )
{
ImplInvalidateOutermostBorder( this );
}
}
}
// -----------------------------------------------------------------------
void Edit::UpdateData()
{
maUpdateDataHdl.Call( this );
}
// -----------------------------------------------------------------------
IMPL_LINK( Edit, ImplUpdateDataHdl, Timer*, EMPTYARG )
{
UpdateData();
return 0;
}
// -----------------------------------------------------------------------
void Edit::EnableUpdateData( sal_uLong nTimeout )
{
if ( !nTimeout )
DisableUpdateData();
else
{
if ( !mpUpdateDataTimer )
{
mpUpdateDataTimer = new Timer;
mpUpdateDataTimer->SetTimeoutHdl( LINK( this, Edit, ImplUpdateDataHdl ) );
}
mpUpdateDataTimer->SetTimeout( nTimeout );
}
}
// -----------------------------------------------------------------------
void Edit::SetEchoChar( xub_Unicode c )
{
mcEchoChar = c;
if ( mpSubEdit )
mpSubEdit->SetEchoChar( c );
}
// -----------------------------------------------------------------------
void Edit::SetReadOnly( sal_Bool bReadOnly )
{
if ( mbReadOnly != bReadOnly )
{
mbReadOnly = bReadOnly;
if ( mpSubEdit )
mpSubEdit->SetReadOnly( bReadOnly );
StateChanged( STATE_CHANGE_READONLY );
}
}
// -----------------------------------------------------------------------
void Edit::SetAutocompleteHdl( const Link& rHdl )
{
maAutocompleteHdl = rHdl;
if ( mpSubEdit )
mpSubEdit->SetAutocompleteHdl( rHdl );
}
// -----------------------------------------------------------------------
void Edit::SetInsertMode( sal_Bool bInsert )
{
if ( bInsert != mbInsertMode )
{
mbInsertMode = bInsert;
if ( mpSubEdit )
mpSubEdit->SetInsertMode( bInsert );
else
ImplShowCursor();
}
}
// -----------------------------------------------------------------------
sal_Bool Edit::IsInsertMode() const
{
if ( mpSubEdit )
return mpSubEdit->IsInsertMode();
else
return mbInsertMode;
}
// -----------------------------------------------------------------------
void Edit::SetMaxTextLen( xub_StrLen nMaxLen )
{
mnMaxTextLen = nMaxLen ? nMaxLen : EDIT_NOLIMIT;
if ( mpSubEdit )
mpSubEdit->SetMaxTextLen( mnMaxTextLen );
else
{
if ( maText.Len() > mnMaxTextLen )
ImplDelete( Selection( mnMaxTextLen, maText.Len() ), EDIT_DEL_RIGHT, EDIT_DELMODE_SIMPLE );
}
}
// -----------------------------------------------------------------------
void Edit::SetSelection( const Selection& rSelection )
{
// Wenn von aussen z.B. im MouseButtonDown die Selektion geaendert wird,
// soll nicht gleich ein Tracking() zuschlagen und die Selektion aendern.
if ( IsTracking() )
EndTracking();
else if ( mpSubEdit && mpSubEdit->IsTracking() )
mpSubEdit->EndTracking();
ImplSetSelection( rSelection );
}
// -----------------------------------------------------------------------
void Edit::ImplSetSelection( const Selection& rSelection, sal_Bool bPaint )
{
if ( mpSubEdit )
mpSubEdit->ImplSetSelection( rSelection );
else
{
if ( rSelection != maSelection )
{
Selection aOld( maSelection );
Selection aNew( rSelection );
if ( aNew.Min() > maText.Len() )
aNew.Min() = maText.Len();
if ( aNew.Max() > maText.Len() )
aNew.Max() = maText.Len();
if ( aNew.Min() < 0 )
aNew.Min() = 0;
if ( aNew.Max() < 0 )
aNew.Max() = 0;
if ( aNew != maSelection )
{
ImplClearLayoutData();
maSelection = aNew;
if ( bPaint && ( aOld.Len() || aNew.Len() || IsPaintTransparent() ) )
ImplInvalidateOrRepaint( 0, maText.Len() );
ImplShowCursor();
if ( mbIsSubEdit )
((Edit*)GetParent())->ImplCallEventListeners( VCLEVENT_EDIT_SELECTIONCHANGED );
else
ImplCallEventListeners( VCLEVENT_EDIT_SELECTIONCHANGED );
// #103511# notify combobox listeners of deselection
if( !maSelection && GetParent() && GetParent()->GetType() == WINDOW_COMBOBOX )
((Edit*)GetParent())->ImplCallEventListeners( VCLEVENT_COMBOBOX_DESELECT );
}
}
}
}
// -----------------------------------------------------------------------
const Selection& Edit::GetSelection() const
{
if ( mpSubEdit )
return mpSubEdit->GetSelection();
else
return maSelection;
}
// -----------------------------------------------------------------------
void Edit::ReplaceSelected( const XubString& rStr )
{
if ( mpSubEdit )
mpSubEdit->ReplaceSelected( rStr );
else
ImplInsertText( rStr );
}
// -----------------------------------------------------------------------
void Edit::DeleteSelected()
{
if ( mpSubEdit )
mpSubEdit->DeleteSelected();
else
{
if ( maSelection.Len() )
ImplDelete( maSelection, EDIT_DEL_RIGHT, EDIT_DELMODE_SIMPLE );
}
}
// -----------------------------------------------------------------------
XubString Edit::GetSelected() const
{
if ( mpSubEdit )
return mpSubEdit->GetSelected();
else
{
Selection aSelection( maSelection );
aSelection.Justify();
return maText.Copy( (xub_StrLen)aSelection.Min(), (xub_StrLen)aSelection.Len() );
}
}
// -----------------------------------------------------------------------
void Edit::Cut()
{
if ( !(GetStyle() & WB_PASSWORD ) )
{
Copy();
ReplaceSelected( ImplGetSVEmptyStr() );
}
}
// -----------------------------------------------------------------------
void Edit::Copy()
{
if ( !(GetStyle() & WB_PASSWORD ) )
{
::com::sun::star::uno::Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipboard(GetClipboard());
ImplCopy( aClipboard );
}
}
// -----------------------------------------------------------------------
void Edit::Paste()
{
::com::sun::star::uno::Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipboard(GetClipboard());
ImplPaste( aClipboard );
}
// -----------------------------------------------------------------------
void Edit::Undo()
{
if ( mpSubEdit )
mpSubEdit->Undo();
else
{
XubString aText( maText );
ImplDelete( Selection( 0, aText.Len() ), EDIT_DEL_RIGHT, EDIT_DELMODE_SIMPLE );
ImplInsertText( maUndoText );
ImplSetSelection( Selection( 0, maUndoText.Len() ) );
maUndoText = aText;
}
}
// -----------------------------------------------------------------------
void Edit::SetText( const XubString& rStr )
{
if ( mpSubEdit )
mpSubEdit->SetText( rStr ); // Nicht direkt ImplSetText, falls SetText ueberladen
else
{
Selection aNewSel( 0, 0 ); // Damit nicht gescrollt wird
ImplSetText( rStr, &aNewSel );
}
}
// -----------------------------------------------------------------------
void Edit::SetText( const XubString& rStr, const Selection& rSelection )
{
if ( mpSubEdit )
mpSubEdit->SetText( rStr, rSelection );
else
ImplSetText( rStr, &rSelection );
}
// -----------------------------------------------------------------------
XubString Edit::GetText() const
{
if ( mpSubEdit )
return mpSubEdit->GetText();
else
return maText;
}
// -----------------------------------------------------------------------
void Edit::SetModifyFlag()
{
if ( mpSubEdit )
mpSubEdit->mbModified = sal_True;
else
mbModified = sal_True;
}
// -----------------------------------------------------------------------
void Edit::ClearModifyFlag()
{
if ( mpSubEdit )
mpSubEdit->mbModified = sal_False;
else
mbModified = sal_False;
}
// -----------------------------------------------------------------------
void Edit::SetSubEdit( Edit* pEdit )
{
mpSubEdit = pEdit;
if ( mpSubEdit )
{
SetPointer( POINTER_ARROW ); // Nur das SubEdit hat den BEAM...
mpSubEdit->mbIsSubEdit = sal_True;
mpSubEdit->SetReadOnly( mbReadOnly );
}
}
// -----------------------------------------------------------------------
Size Edit::CalcMinimumSize() const
{
Size aSize ( GetTextWidth( GetText() ), GetTextHeight() );
// do not create edit fields in which one cannot enter anything
// a default minimum width should exist for at least 3 characters
Size aMinSize ( CalcSize( 3 ) );
if( aSize.Width() < aMinSize.Width() )
aSize.Width() = aMinSize.Width();
// add some space between text entry and border
aSize.Height() += 4;
aSize = CalcWindowSize( aSize );
// ask NWF what if it has an opinion, too
ImplControlValue aControlValue;
Rectangle aRect( Point( 0, 0 ), aSize );
Rectangle aContent, aBound;
if( const_cast<Edit*>(this)->GetNativeControlRegion(
CTRL_EDITBOX, PART_ENTIRE_CONTROL,
aRect, 0, aControlValue, rtl::OUString(), aBound, aContent) )
{
if( aBound.GetHeight() > aSize.Height() )
aSize.Height() = aBound.GetHeight();
}
return aSize;
}
Size Edit::GetMinimumEditSize()
{
Window* pDefWin = ImplGetDefaultWindow();
Edit aEdit( pDefWin, WB_BORDER );
Size aSize( aEdit.CalcMinimumSize() );
return aSize;
}
// -----------------------------------------------------------------------
Size Edit::GetOptimalSize(WindowSizeType eType) const
{
switch (eType) {
case WINDOWSIZE_MINIMUM:
return CalcMinimumSize();
default:
return Control::GetOptimalSize( eType );
}
}
// -----------------------------------------------------------------------
Size Edit::CalcSize( xub_StrLen nChars ) const
{
// Breite fuer n Zeichen, unabhaengig vom Inhalt.
// Funktioniert nur bei FixedFont richtig, sonst Mittelwert.
Size aSz( GetTextWidth( XubString( 'x' ) ), GetTextHeight() );
aSz.Width() *= nChars;
aSz = CalcWindowSize( aSz );
return aSz;
}
// -----------------------------------------------------------------------
xub_StrLen Edit::GetMaxVisChars() const
{
const Window* pW = mpSubEdit ? mpSubEdit : this;
long nOutWidth = pW->GetOutputSizePixel().Width();
long nCharWidth = GetTextWidth( XubString( 'x' ) );
return nCharWidth ? (xub_StrLen)(nOutWidth/nCharWidth) : 0;
}
// -----------------------------------------------------------------------
xub_StrLen Edit::GetCharPos( const Point& rWindowPos ) const
{
return ImplGetCharPos( rWindowPos );
}
// -----------------------------------------------------------------------
void Edit::SetGetSpecialCharsFunction( FncGetSpecialChars fn )
{
pImplFncGetSpecialChars = fn;
}
// -----------------------------------------------------------------------
FncGetSpecialChars Edit::GetGetSpecialCharsFunction()
{
return pImplFncGetSpecialChars;
}
// -----------------------------------------------------------------------
PopupMenu* Edit::CreatePopupMenu()
{
ResMgr* pResMgr = ImplGetResMgr();
if( ! pResMgr )
return new PopupMenu();
PopupMenu* pPopup = new PopupMenu( ResId( SV_RESID_MENU_EDIT, *pResMgr ) );
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
if ( rStyleSettings.GetHideDisabledMenuItems() )
pPopup->SetMenuFlags( MENU_FLAG_HIDEDISABLEDENTRIES );
else
pPopup->SetMenuFlags ( MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
if ( rStyleSettings.GetAcceleratorsInContextMenus() )
{
pPopup->SetAccelKey( SV_MENU_EDIT_UNDO, KeyCode( KEYFUNC_UNDO ) );
pPopup->SetAccelKey( SV_MENU_EDIT_CUT, KeyCode( KEYFUNC_CUT ) );
pPopup->SetAccelKey( SV_MENU_EDIT_COPY, KeyCode( KEYFUNC_COPY ) );
pPopup->SetAccelKey( SV_MENU_EDIT_PASTE, KeyCode( KEYFUNC_PASTE ) );
pPopup->SetAccelKey( SV_MENU_EDIT_DELETE, KeyCode( KEYFUNC_DELETE ) );
pPopup->SetAccelKey( SV_MENU_EDIT_SELECTALL, KeyCode( KEY_A, sal_False, sal_True, sal_False, sal_False ) );
pPopup->SetAccelKey( SV_MENU_EDIT_INSERTSYMBOL, KeyCode( KEY_S, sal_True, sal_True, sal_False, sal_False ) );
}
return pPopup;
}
// -----------------------------------------------------------------------
void Edit::DeletePopupMenu( PopupMenu* pMenu )
{
delete pMenu;
}
// ::com::sun::star::datatransfer::dnd::XDragGestureListener
void Edit::dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& rDGE ) throw (::com::sun::star::uno::RuntimeException)
{
SolarMutexGuard aVclGuard;
if ( !IsTracking() && maSelection.Len() &&
!(GetStyle() & WB_PASSWORD) && (!mpDDInfo || mpDDInfo->bStarterOfDD == sal_False) ) // Kein Mehrfach D&D
{
Selection aSel( maSelection );
aSel.Justify();
// Nur wenn Maus in der Selektion...
Point aMousePos( rDGE.DragOriginX, rDGE.DragOriginY );
xub_StrLen nChar = ImplGetCharPos( aMousePos );
if ( (nChar >= aSel.Min()) && (nChar < aSel.Max()) )
{
if ( !mpDDInfo )
mpDDInfo = new DDInfo;
mpDDInfo->bStarterOfDD = sal_True;
mpDDInfo->aDndStartSel = aSel;
if ( IsTracking() )
EndTracking(); // Vor D&D Tracking ausschalten
::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( GetSelected() );
sal_Int8 nActions = datatransfer::dnd::DNDConstants::ACTION_COPY;
if ( !IsReadOnly() )
nActions |= datatransfer::dnd::DNDConstants::ACTION_MOVE;
rDGE.DragSource->startDrag( rDGE, nActions, 0 /*cursor*/, 0 /*image*/, pDataObj, mxDnDListener );
if ( GetCursor() )
GetCursor()->Hide();
}
}
}
// ::com::sun::star::datatransfer::dnd::XDragSourceListener
void Edit::dragDropEnd( const ::com::sun::star::datatransfer::dnd::DragSourceDropEvent& rDSDE ) throw (::com::sun::star::uno::RuntimeException)
{
SolarMutexGuard aVclGuard;
if ( rDSDE.DropSuccess && ( rDSDE.DropAction & datatransfer::dnd::DNDConstants::ACTION_MOVE ) )
{
Selection aSel( mpDDInfo->aDndStartSel );
if ( mpDDInfo->bDroppedInMe )
{
if ( aSel.Max() > mpDDInfo->nDropPos )
{
long nLen = aSel.Len();
aSel.Min() += nLen;
aSel.Max() += nLen;
}
}
ImplDelete( aSel, EDIT_DEL_RIGHT, EDIT_DELMODE_SIMPLE );
ImplModified();
}
ImplHideDDCursor();
delete mpDDInfo;
mpDDInfo = NULL;
}
// ::com::sun::star::datatransfer::dnd::XDropTargetListener
void Edit::drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& rDTDE ) throw (::com::sun::star::uno::RuntimeException)
{
SolarMutexGuard aVclGuard;
sal_Bool bChanges = sal_False;
if ( !mbReadOnly && mpDDInfo )
{
ImplHideDDCursor();
Selection aSel( maSelection );
aSel.Justify();
if ( aSel.Len() && !mpDDInfo->bStarterOfDD )
ImplDelete( aSel, EDIT_DEL_RIGHT, EDIT_DELMODE_SIMPLE );
mpDDInfo->bDroppedInMe = sal_True;
aSel.Min() = mpDDInfo->nDropPos;
aSel.Max() = mpDDInfo->nDropPos;
ImplSetSelection( aSel );
uno::Reference< datatransfer::XTransferable > xDataObj = rDTDE.Transferable;
if ( xDataObj.is() )
{
datatransfer::DataFlavor aFlavor;
SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
if ( xDataObj->isDataFlavorSupported( aFlavor ) )
{
uno::Any aData = xDataObj->getTransferData( aFlavor );
::rtl::OUString aText;
aData >>= aText;
ImplInsertText( aText );
bChanges = sal_True;
ImplModified();
}
}
if ( !mpDDInfo->bStarterOfDD )
{
delete mpDDInfo;
mpDDInfo = NULL;
}
}
rDTDE.Context->dropComplete( bChanges );
}
void Edit::dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& rDTDE ) throw (::com::sun::star::uno::RuntimeException)
{
if ( !mpDDInfo )
{
mpDDInfo = new DDInfo;
}
// search for string data type
const Sequence< com::sun::star::datatransfer::DataFlavor >& rFlavors( rDTDE.SupportedDataFlavors );
sal_Int32 nEle = rFlavors.getLength();
mpDDInfo->bIsStringSupported = sal_False;
for( sal_Int32 i = 0; i < nEle; i++ )
{
sal_Int32 nIndex = 0;
rtl::OUString aMimetype = rFlavors[i].MimeType.getToken( 0, ';', nIndex );
if( aMimetype.equalsAscii( "text/plain" ) )
{
mpDDInfo->bIsStringSupported = sal_True;
break;
}
}
}
void Edit::dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& ) throw (::com::sun::star::uno::RuntimeException)
{
SolarMutexGuard aVclGuard;
ImplHideDDCursor();
}
void Edit::dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& rDTDE ) throw (::com::sun::star::uno::RuntimeException)
{
SolarMutexGuard aVclGuard;
Point aMousePos( rDTDE.LocationX, rDTDE.LocationY );
xub_StrLen nPrevDropPos = mpDDInfo->nDropPos;
mpDDInfo->nDropPos = ImplGetCharPos( aMousePos );
/*
Size aOutSize = GetOutputSizePixel();
if ( ( aMousePos.X() < 0 ) || ( aMousePos.X() > aOutSize.Width() ) )
{
// Scroll?
// No, I will not receive events in this case....
}
*/
Selection aSel( maSelection );
aSel.Justify();
// Don't accept drop in selection or read-only field...
if ( IsReadOnly() || aSel.IsInside( mpDDInfo->nDropPos ) || ! mpDDInfo->bIsStringSupported )
{
ImplHideDDCursor();
rDTDE.Context->rejectDrag();
}
else
{
// Alten Cursor wegzeichnen...
if ( !mpDDInfo->bVisCursor || ( nPrevDropPos != mpDDInfo->nDropPos ) )
{
ImplHideDDCursor();
ImplShowDDCursor();
}
rDTDE.Context->acceptDrag( rDTDE.DropAction );
}
}
ImplSubEdit::ImplSubEdit( Edit* pParent, WinBits nStyle ) :
Edit( pParent, nStyle )
{
pParent->SetSubEdit( this );
}
// -----------------------------------------------------------------------
void ImplSubEdit::Modify()
{
GetParent()->Modify();
}
XubString Edit::GetSurroundingText() const
{
if ( mpSubEdit )
return mpSubEdit->GetSurroundingText();
else
return maText;
}
Selection Edit::GetSurroundingTextSelection() const
{
return GetSelection();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|