1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
|
/*************************************************************************
*
* $RCSfile: inputhdl.cxx,v $
*
* $Revision: 1.44 $
*
* last change: $Author: nn $ $Date: 2002-12-04 18:53:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifdef PCH
#include "ui_pch.hxx"
#endif
#pragma hdrstop
//------------------------------------------------------------------
#include "scitems.hxx"
#include <svx/eeitem.hxx>
#define ITEMID_FIELD EE_FEATURE_FIELD
#include <svx/algitem.hxx>
#include <svx/adjitem.hxx>
#include <svx/brshitem.hxx>
#include <svx/colorcfg.hxx>
#include <svx/colritem.hxx>
#include <svx/editobj.hxx>
#include <svx/editstat.hxx>
#include <svx/editview.hxx>
#include <svx/escpitem.hxx>
#include <svx/forbiddencharacterstable.hxx>
#include <svx/langitem.hxx>
#include <svx/svxacorr.hxx>
#include <svx/unolingu.hxx>
#include <svx/wghtitem.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/printer.hxx>
#include <offmgr/app.hxx>
#include <svtools/zforlist.hxx>
#include <vcl/sound.hxx>
#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
#include <unotools/localedatawrapper.hxx>
#endif
#ifndef _SV_HELP_HXX //autogen
#include <vcl/help.hxx>
#endif
#ifndef _SV_CURSOR_HXX //autogen
#include <vcl/cursor.hxx>
#endif
#include "inputwin.hxx"
#include "tabvwsh.hxx"
#include "docsh.hxx"
//#include "appmain.hxx"
#include "scmod.hxx"
#include "uiitems.hxx"
#include "global.hxx"
#include "sc.hrc"
#include "globstr.hrc"
#include "patattr.hxx"
#include "viewdata.hxx"
#include "document.hxx"
#include "docpool.hxx"
#include "editutil.hxx"
#include "collect.hxx"
#include "appoptio.hxx"
#include "docoptio.hxx"
#include "validat.hxx"
#include "userlist.hxx"
#include "rfindlst.hxx"
#include "inputopt.hxx"
#include "cell.hxx" // fuer Formel-Preview
#include "compiler.hxx" // fuer Formel-Preview
#include "editable.hxx"
#define _INPUTHDL_CXX
#include "inputhdl.hxx"
// max. Ranges im RangeFinder
#define RANGEFIND_MAX 32
// STATIC DATA -----------------------------------------------------------
BOOL ScInputHandler::bOptLoaded = FALSE; // App-Optionen ausgewertet
BOOL ScInputHandler::bAutoComplete = FALSE; // wird in KeyInput gesetzt
// delimiters (in addition to ScEditUtil) needed for range finder:
// only characters that are allowed in formulas next to references
// and the quotation mark (so string constants can be skipped)
static const sal_Char __FAR_DATA pMinDelimiters[] = " !\"";
extern USHORT nEditAdjust; //! Member an ViewData
//==================================================================
void ScInputHandler::InitRangeFinder( const String& rFormula )
{
DeleteRangeFinder();
if ( !pActiveViewSh || !SC_MOD()->GetInputOptions().GetRangeFinder() )
return;
ScDocShell* pDocSh = pActiveViewSh->GetViewData()->GetDocShell();
ScDocument* pDoc = pDocSh->GetDocument();
// String aDelimiters = pEngine->GetWordDelimiters();
String aDelimiters = ScEditUtil::ModifyDelimiters(
String::CreateFromAscii( pMinDelimiters ) );
xub_StrLen nColon = aDelimiters.Search(':');
if ( nColon != STRING_NOTFOUND )
aDelimiters.Erase( nColon, 1 ); // Delimiter ohne Doppelpunkt
xub_StrLen nDot = aDelimiters.Search('.');
if ( nDot != STRING_NOTFOUND )
aDelimiters.Erase( nDot, 1 ); // Delimiter ohne Punkt
const sal_Unicode* pChar = rFormula.GetBuffer();
xub_StrLen nLen = rFormula.Len();
xub_StrLen nPos = 0;
xub_StrLen nStart = 0;
USHORT nCount = 0;
ScRange aRange;
while ( nPos < nLen && nCount < RANGEFIND_MAX )
{
// Trenner ueberlesen
while ( nPos<nLen && ScGlobal::UnicodeStrChr( aDelimiters.GetBuffer(), pChar[nPos] ) )
{
if ( pChar[nPos] == '"' ) // String
{
++nPos;
while (nPos<nLen && pChar[nPos] != '"') // bis zum Ende ueberlesen
++nPos;
}
++nPos; // Trennzeichen oder schliessender Quote
}
// Text zwischen Trennern
nStart = nPos;
while ( nPos<nLen && !ScGlobal::UnicodeStrChr( aDelimiters.GetBuffer(), pChar[nPos] ) )
++nPos;
if ( nPos > nStart )
{
String aTest = rFormula.Copy( nStart, nPos-nStart );
USHORT nFlags = aRange.ParseAny( aTest, pDoc );
if ( nFlags & SCA_VALID )
{
// Tabelle setzen, wenn nicht angegeben
if ( (nFlags & SCA_TAB_3D) == 0 )
aRange.aStart.SetTab( pActiveViewSh->GetViewData()->GetTabNo() );
if ( (nFlags & SCA_TAB2_3D) == 0 )
aRange.aEnd.SetTab( aRange.aStart.Tab() );
if (!nCount)
{
pEngine->SetUpdateMode( FALSE );
pRangeFindList = new ScRangeFindList( pDocSh->GetTitle() );
}
ScRangeFindData* pNew = new ScRangeFindData( aRange, nFlags, nStart, nPos );
pRangeFindList->Insert( pNew );
ESelection aSel( 0, nStart, 0, nPos );
SfxItemSet aSet( pEngine->GetEmptyItemSet() );
aSet.Put( SvxColorItem( Color( ScRangeFindList::GetColorName( nCount ) ),
EE_CHAR_COLOR ) );
pEngine->QuickSetAttribs( aSet, aSel );
++nCount;
}
}
// letzten Trenner nicht ueberlesen, koennte ja ein Quote sein (?)
}
if (nCount)
{
pEngine->SetUpdateMode( TRUE );
pDocSh->Broadcast( SfxSimpleHint( SC_HINT_SHOWRANGEFINDER ) );
}
}
void lcl_Replace( EditView* pView, const String& rNewStr, const ESelection& rOldSel )
{
if ( pView )
{
ESelection aOldSel = pView->GetSelection();
if (aOldSel.HasRange())
pView->SetSelection( ESelection( aOldSel.nEndPara, aOldSel.nEndPos,
aOldSel.nEndPara, aOldSel.nEndPos ) );
EditEngine* pEngine = pView->GetEditEngine();
pEngine->QuickInsertText( rNewStr, rOldSel );
// Dummy-InsertText fuer Update und Paint
// dafuer muss oben die Selektion aufgehoben werden (vor QuickInsertText)
pView->InsertText( EMPTY_STRING, FALSE );
xub_StrLen nLen = pEngine->GetTextLen(0);
ESelection aSel( 0, nLen, 0, nLen );
pView->SetSelection( aSel ); // Cursor ans Ende
}
}
void ScInputHandler::UpdateRange( USHORT nIndex, const ScRange& rNew )
{
ScTabViewShell* pDocView = pRefViewSh ? pRefViewSh : pActiveViewSh;
if ( pDocView && pRangeFindList && nIndex < pRangeFindList->Count() )
{
ScRangeFindData* pData = pRangeFindList->GetObject( nIndex );
xub_StrLen nOldStart = pData->nSelStart;
xub_StrLen nOldEnd = pData->nSelEnd;
ScRange aJustified = rNew;
aJustified.Justify(); // Ref in der Formel immer richtigherum anzeigen
String aNewStr;
aJustified.Format( aNewStr, pData->nFlags, pDocView->GetViewData()->GetDocument() );
ESelection aOldSel( 0, nOldStart, 0, nOldEnd );
DataChanging();
lcl_Replace( pTopView, aNewStr, aOldSel );
lcl_Replace( pTableView, aNewStr, aOldSel );
bInRangeUpdate = TRUE;
DataChanged();
bInRangeUpdate = FALSE;
long nDiff = aNewStr.Len() - (long)(nOldEnd-nOldStart);
pData->aRef = rNew;
pData->nSelEnd = (xub_StrLen)(pData->nSelEnd + nDiff);
USHORT nCount = (USHORT) pRangeFindList->Count();
for (USHORT i=nIndex+1; i<nCount; i++)
{
ScRangeFindData* pNext = pRangeFindList->GetObject( i );
pNext->nSelStart = (xub_StrLen)(pNext->nSelStart + nDiff);
pNext->nSelEnd = (xub_StrLen)(pNext->nSelEnd + nDiff);
}
}
else
DBG_ERROR("UpdateRange: da fehlt was");
}
void ScInputHandler::DeleteRangeFinder()
{
ScTabViewShell* pPaintView = pRefViewSh ? pRefViewSh : pActiveViewSh;
if ( pRangeFindList && pPaintView )
{
ScDocShell* pDocSh = pActiveViewSh->GetViewData()->GetDocShell();
pRangeFindList->SetHidden(TRUE);
pDocSh->Broadcast( SfxSimpleHint( SC_HINT_SHOWRANGEFINDER ) ); // wegnehmen
DELETEZ(pRangeFindList);
}
}
//==================================================================
inline String GetEditText(EditEngine* pEng)
{
return ScEditUtil::GetSpaceDelimitedString(*pEng);
}
void lcl_RemoveTabs(String& rStr)
{
xub_StrLen nPos;
while ( (nPos=rStr.Search('\t')) != STRING_NOTFOUND )
rStr.SetChar( nPos, ' ' );
}
void lcl_RemoveLineEnd(String& rStr)
{
rStr.ConvertLineEnd(LINEEND_LF);
xub_StrLen nPos;
while ( (nPos=rStr.Search('\n')) != STRING_NOTFOUND )
rStr.SetChar( nPos, ' ' );
}
//==================================================================
ScInputHandler::ScInputHandler()
: eMode( SC_INPUT_NONE ),
bModified( FALSE ),
bFormulaMode( FALSE ),
bSelIsRef( FALSE ),
bInRangeUpdate( FALSE ),
pInputWin( NULL ),
pRefViewSh( NULL ),
pLastPattern( NULL ),
pLastState( NULL ),
bLastIsSymbol( FALSE ),
bProtected( FALSE ),
bTextValid( TRUE ),
bCellHasPercentFormat( FALSE ),
nValidation( 0 ),
nAttrAdjust( SVX_HOR_JUSTIFY_STANDARD ),
aScaleX( 1,1 ),
aScaleY( 1,1 ),
pTopView( NULL ),
pTableView( NULL ),
pEngine( NULL ),
pEditDefaults( NULL ),
pDelayTimer( NULL ),
pColumnData( NULL ),
pFormulaData( NULL ),
nTipVisible( 0 ),
nAutoPos( SCPOS_INVALID ),
bUseTab( FALSE ),
nFormSelStart( 0 ),
nFormSelEnd( 0 ),
nAutoPar( 0 ),
pRangeFindList( NULL ),
bParenthesisShown( FALSE ),
bCreatingFuncView( FALSE ),
bInEnterHandler( FALSE ),
bCommandErrorShown( FALSE ),
bInOwnChange( FALSE )
{
// The InputHandler is constructed with the view, so SfxViewShell::Current
// doesn't have the right view yet. pActiveViewSh is updated in NotifyChange.
pActiveViewSh = NULL;
// Bindings (nur noch fuer Invalidate benutzt) werden bei Bedarf aktuell geholt
}
__EXPORT ScInputHandler::~ScInputHandler()
{
// Wenn dies der Applikations-InputHandler ist, wird der dtor erst nach SfxApplication::Main
// gerufen, darf sich also auf keine Sfx-Funktionen mehr verlassen
if ( !SFX_APP()->IsDowning() ) // inplace
EnterHandler(); // Eingabe noch abschliessen
if (SC_MOD()->GetRefInputHdl()==this)
SC_MOD()->SetRefInputHdl(NULL);
delete pRangeFindList;
delete pEditDefaults;
delete pEngine;
delete pLastState;
delete pDelayTimer;
delete pColumnData;
delete pFormulaData;
}
void ScInputHandler::SetRefScale( const Fraction& rX, const Fraction& rY )
{
if ( rX != aScaleX || rY != aScaleY )
{
aScaleX = rX;
aScaleY = rY;
if (pEngine)
{
MapMode aMode( MAP_100TH_MM, Point(), aScaleX, aScaleY );
pEngine->SetRefMapMode( aMode );
}
}
}
void ScInputHandler::UpdateRefDevice()
{
if (!pEngine)
return;
BOOL bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg();
if ( bTextWysiwyg && pActiveViewSh )
pEngine->SetRefDevice( pActiveViewSh->GetViewData()->GetDocument()->GetPrinter() );
else
pEngine->SetRefDevice( NULL );
MapMode aMode( MAP_100TH_MM, Point(), aScaleX, aScaleY );
pEngine->SetRefMapMode( aMode );
}
void ScInputHandler::ImplCreateEditEngine()
{
if ( !pEngine )
{
if ( pActiveViewSh )
{
const ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
pEngine = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
}
else
pEngine = new ScFieldEditEngine( EditEngine::CreatePool(), NULL, TRUE );
pEngine->SetWordDelimiters( ScEditUtil::ModifyDelimiters( pEngine->GetWordDelimiters() ) );
UpdateRefDevice(); // also sets MapMode
pEngine->SetPaperSize( Size( 1000000, 1000000 ) );
pEditDefaults = new SfxItemSet( pEngine->GetEmptyItemSet() );
pEngine->SetControlWord( pEngine->GetControlWord() | EE_CNTRL_AUTOCORRECT );
pEngine->SetModifyHdl( LINK( this, ScInputHandler, ModifyHdl ) );
}
}
void ScInputHandler::UpdateAutoCorrFlag()
{
ULONG nCntrl = pEngine->GetControlWord();
ULONG nOld = nCntrl;
// don't use pLastPattern here (may be invalid because of AutoStyle)
BOOL bDisable = bLastIsSymbol || bFormulaMode;
if ( bDisable )
nCntrl &= ~EE_CNTRL_AUTOCORRECT;
else
nCntrl |= EE_CNTRL_AUTOCORRECT;
if ( nCntrl != nOld )
pEngine->SetControlWord(nCntrl);
}
void ScInputHandler::UpdateSpellSettings( BOOL bFromStartTab )
{
if ( pActiveViewSh )
{
ScViewData* pViewData = pActiveViewSh->GetViewData();
BOOL bOnlineSpell = pViewData->GetDocument()->GetDocOptions().IsAutoSpell();
BOOL bHideSpell = pViewData->GetOptions().IsHideAutoSpell();
// SetDefaultLanguage is independent of the language attributes,
// ScGlobal::GetEditDefaultLanguage is always used.
// It must be set every time in case the office language was changed.
pEngine->SetDefaultLanguage( ScGlobal::GetEditDefaultLanguage() );
// if called for changed options, update flags only if already editing
// if called from StartTable, always update flags
if ( bFromStartTab || eMode != SC_INPUT_NONE )
{
ULONG nCntrl = pEngine->GetControlWord();
ULONG nOld = nCntrl;
if( bHideSpell )
nCntrl |= EE_CNTRL_NOREDLINES;
else
nCntrl &= ~EE_CNTRL_NOREDLINES;
if( bOnlineSpell )
nCntrl |= EE_CNTRL_ONLINESPELLING;
else
nCntrl &= ~EE_CNTRL_ONLINESPELLING;
// kein AutoCorrect auf Symbol-Font (EditEngine wertet Default nicht aus)
if ( pLastPattern && pLastPattern->IsSymbolFont() )
nCntrl &= ~EE_CNTRL_AUTOCORRECT;
else
nCntrl |= EE_CNTRL_AUTOCORRECT;
if ( nCntrl != nOld )
pEngine->SetControlWord(nCntrl);
ScDocument* pDoc = pViewData->GetDocument();
pEngine->SetForbiddenCharsTable( pDoc->GetForbiddenCharacters() );
pEngine->SetAsianCompressionMode( pDoc->GetAsianCompression() );
pEngine->SetKernAsianPunctuation( pDoc->GetAsianKerning() );
pEngine->SetDefaultHorizontalTextDirection(
(EEHorizontalTextDirection)pDoc->GetEditTextDirection( pViewData->GetTabNo() ) );
}
// language is set separately, so the speller is needed only if online
// spelling is active
if ( bOnlineSpell ) {
com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellChecker1> xXSpellChecker1( LinguMgr::GetSpellChecker() );
pEngine->SetSpeller( xXSpellChecker1 );
}
BOOL bHyphen = pLastPattern && ((const SfxBoolItem&)pLastPattern->GetItem(ATTR_HYPHENATE)).GetValue();
if ( bHyphen ) {
com::sun::star::uno::Reference<com::sun::star::linguistic2::XHyphenator> xXHyphenator( LinguMgr::GetHyphenator() );
pEngine->SetHyphenator( xXHyphenator );
}
}
}
//
// Funktionen/Bereichsnamen etc. als Tip-Hilfe
//
#define SC_STRTYPE_FUNCTIONS 1
// die anderen Typen sind in ScDocument::GetFormulaEntries festgelegt
void ScInputHandler::GetFormulaData()
{
if ( pActiveViewSh )
{
ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
if ( pFormulaData )
pFormulaData->FreeAll();
else
pFormulaData = new TypedStrCollection;
// MRU-Funktionen aus dem Funktions-Autopiloten
// wie in ScPosWnd::FillFunctions (inputwin.cxx)
const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
USHORT nMRUCount = rOpt.GetLRUFuncListCount();
const USHORT* pMRUList = rOpt.GetLRUFuncList();
if (pMRUList)
{
const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
ULONG nListCount = pFuncList->GetCount();
ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
for (USHORT i=0; i<nMRUCount; i++)
{
USHORT nId = pMRUList[i];
for (ULONG j=0; j<nListCount; j++)
{
const ScFuncDesc* pDesc = pFuncList->GetFunction( j );
if ( pDesc->nFIndex == nId && pDesc->pFuncName )
{
String aEntry = *pDesc->pFuncName;
aEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" ));
TypedStrData* pData = new TypedStrData( aEntry, 0.0, SC_STRTYPE_FUNCTIONS );
if (!pFormulaData->Insert(pData))
delete pData;
break; // nicht weitersuchen
}
}
}
}
pDoc->GetFormulaEntries( *pFormulaData );
}
}
void ScInputHandler::HideTip()
{
if ( nTipVisible )
{
Help::HideTip( nTipVisible );
nTipVisible = 0;
}
aManualTip.Erase();
}
void ScInputHandler::ShowTip( const String& rText )
{
// aManualTip muss hinterher von aussen gesetzt werden
HideTip();
EditView* pActiveView = pTopView ? pTopView : pTableView;
if (pActiveView)
{
Point aPos;
Window* pWin = pActiveView->GetWindow();
Cursor* pCur = pActiveView->GetCursor();
if (pCur)
aPos = pWin->LogicToPixel( pCur->GetPos() );
aPos = pWin->OutputToScreenPixel( aPos );
Rectangle aRect( aPos, aPos );
USHORT nAlign = QUICKHELP_LEFT|QUICKHELP_BOTTOM;
nTipVisible = Help::ShowTip(pWin, aRect, rText, nAlign);
}
}
void ScInputHandler::UseFormulaData()
{
EditView* pActiveView = pTopView ? pTopView : pTableView;
// Formeln duerfen nur 1 Absatz haben
if ( pActiveView && pFormulaData && pEngine->GetParagraphCount() == 1 )
{
String aTotal = pEngine->GetText( (USHORT) 0 );
ESelection aSel = pActiveView->GetSelection();
aSel.Adjust();
// #59348# Durch Differenzen zwischen Tabelle und Eingabezeile
// (z.B. Clipboard mit Zeilenumbruechen) kann es sein, dass die Selektion
// nicht mehr zur EditEngine passt. Dann halt kommentarlos abbrechen:
if ( aSel.nEndPos > aTotal.Len() )
return;
// steht der Cursor am Ende eines Wortes?
if ( aSel.nEndPos > 0 && (
aSel.nEndPos == aTotal.Len() ||
pEngine->GetWordDelimiters().Search( aTotal.GetChar(aSel.nEndPos) ) != STRING_NOTFOUND ) )
{
String aText = pEngine->GetWord( 0, aSel.nEndPos-1 );
if (aText.Len())
{
String aNew;
nAutoPos = SCPOS_INVALID; // nix
if ( pFormulaData->FindText( aText, aNew, nAutoPos, FALSE ) )
{
ShowTip( aNew ); // als QuickHelp anzeigen
aAutoSearch = aText; // zum Weitersuchen - nAutoPos ist gesetzt
}
}
}
}
}
void ScInputHandler::NextFormulaEntry( BOOL bBack )
{
EditView* pActiveView = pTopView ? pTopView : pTableView;
if ( pActiveView && pFormulaData )
{
String aNew;
if ( pFormulaData->FindText( aAutoSearch, aNew, nAutoPos, bBack ) )
ShowTip( aNew ); // als QuickHelp anzeigen
}
// bei Tab wird vorher immer HideCursor gerufen
if (pActiveView)
pActiveView->ShowCursor();
}
void lcl_CompleteFunction( EditView* pView, const String& rInsert, BOOL& rParInserted )
{
if (pView)
{
ESelection aSel = pView->GetSelection();
--aSel.nStartPos;
--aSel.nEndPos;
pView->SetSelection(aSel);
pView->SelectCurrentWord();
String aInsStr = rInsert;
xub_StrLen nInsLen = aInsStr.Len();
BOOL bDoParen = ( nInsLen > 1 && aInsStr.GetChar(nInsLen-2) == '('
&& aInsStr.GetChar(nInsLen-1) == ')' );
if ( bDoParen )
{
// Klammern hinter Funktionsnamen nicht einfuegen, wenn direkt dahinter
// schon eine Klammer steht (z.B. wenn der Funktionsname geaendert wurde,
// #39393#).
ESelection aWordSel = pView->GetSelection();
String aOld = pView->GetEditEngine()->GetText((USHORT)0);
sal_Unicode cNext = aOld.GetChar(aWordSel.nEndPos);
if ( cNext == '(' )
{
bDoParen = FALSE;
aInsStr.Erase( nInsLen - 2 ); // Klammern weglassen
}
}
pView->InsertText( aInsStr, FALSE );
if ( bDoParen ) // Cursor zwischen die Klammern setzen
{
aSel = pView->GetSelection();
--aSel.nStartPos;
--aSel.nEndPos;
pView->SetSelection(aSel);
rParInserted = TRUE;
}
}
}
void ScInputHandler::PasteFunctionData()
{
if ( pFormulaData && nAutoPos != SCPOS_INVALID )
{
TypedStrData* pData = (*pFormulaData)[nAutoPos];
if (pData)
{
String aInsert = pData->GetString();
BOOL bParInserted = FALSE;
DataChanging(); // kann nicht neu sein
lcl_CompleteFunction( pTopView, aInsert, bParInserted );
lcl_CompleteFunction( pTableView, aInsert, bParInserted );
DataChanged();
if (bParInserted)
AutoParAdded();
}
}
HideTip();
EditView* pActiveView = pTopView ? pTopView : pTableView;
if (pActiveView)
pActiveView->ShowCursor();
}
//
// Selektion berechnen und als Tip-Hilfe anzeigen
//
String lcl_Calculate( const String& rFormula, ScDocument* pDoc, const ScAddress &rPos )
{
//! mit ScFormulaDlg::CalcValue zusammenfassen und ans Dokument verschieben !!!!
//! (Anfuehrungszeichen bei Strings werden nur hier eingefuegt)
String aValue;
if (rFormula.Len())
{
ScFormulaCell* pCell = new ScFormulaCell( pDoc, rPos, rFormula );
// #35521# HACK! um bei ColRowNames kein #REF! zu bekommen,
// wenn ein Name eigentlich als Bereich in die Gesamt-Formel
// eingefuegt wird, bei der Einzeldarstellung aber als
// single-Zellbezug interpretiert wird
BOOL bColRowName = pCell->HasColRowName();
if ( bColRowName )
{
// ColRowName im RPN-Code?
if ( pCell->GetCode()->GetCodeLen() <= 1 )
{ // ==1: einzelner ist als Parameter immer Bereich
// ==0: es waere vielleicht einer, wenn..
String aBraced( '(' );
aBraced += rFormula;
aBraced += ')';
delete pCell;
pCell = new ScFormulaCell( pDoc, rPos, aBraced );
}
else
bColRowName = FALSE;
}
USHORT nErrCode = pCell->GetErrCode();
if ( nErrCode == 0 )
{
SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable());
Color* pColor;
if ( pCell->IsValue() )
{
double n = pCell->GetValue();
ULONG nFormat = aFormatter.GetStandardFormat( n, 0,
pCell->GetFormatType(), ScGlobal::eLnge );
aFormatter.GetInputLineString( n, nFormat, aValue );
//! display OutputString but insert InputLineString
}
else
{
String aStr;
pCell->GetString( aStr );
ULONG nFormat = aFormatter.GetStandardFormat(
pCell->GetFormatType(), ScGlobal::eLnge);
aFormatter.GetOutputString( aStr, nFormat,
aValue, &pColor );
aValue.Insert('"',0); // in Anfuehrungszeichen
aValue+='"';
//! Anfuehrungszeichen im String escapen ????
}
ScRange aTestRange;
if ( bColRowName || (aTestRange.Parse(rFormula) & SCA_VALID) )
aValue.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ..." )); // Bereich
}
else
aValue = ScGlobal::GetErrorString(nErrCode);
delete pCell;
}
return aValue;
}
void ScInputHandler::FormulaPreview()
{
String aValue;
EditView* pActiveView = pTopView ? pTopView : pTableView;
if ( pActiveView && pActiveViewSh )
{
String aPart = pActiveView->GetSelected();
if (!aPart.Len())
aPart = pEngine->GetText((USHORT)0);
ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
aValue = lcl_Calculate( aPart, pDoc, aCursorPos );
}
if (aValue.Len())
{
ShowTip( aValue ); // als QuickHelp anzeigen
aManualTip = aValue; // nach ShowTip setzen
nAutoPos = SCPOS_INVALID; // Formel-Autocomplete aufheben
}
}
void ScInputHandler::PasteManualTip()
{
// drei Punkte am Ende -> Bereichsreferenz -> nicht einfuegen
// (wenn wir mal Matrix-Konstanten haben, kann das geaendert werden)
xub_StrLen nTipLen = aManualTip.Len();
if ( nTipLen && ( nTipLen < 3 || !aManualTip.Copy( nTipLen-3 ).EqualsAscii("...") ) )
{
DataChanging(); // kann nicht neu sein
String aInsert = aManualTip;
EditView* pActiveView = pTopView ? pTopView : pTableView;
if (!pActiveView->HasSelection())
{
// nichts selektiert -> alles selektieren
xub_StrLen nOldLen = pEngine->GetTextLen(0);
ESelection aAllSel( 0, 0, 0, nOldLen );
if ( pTopView )
pTopView->SetSelection( aAllSel );
if ( pTableView )
pTableView->SetSelection( aAllSel );
}
ESelection aSel = pActiveView->GetSelection();
aSel.Adjust();
DBG_ASSERT( !aSel.nStartPara && !aSel.nEndPara, "Zuviele Absaetze in Formel" );
if ( !aSel.nStartPos ) // Selektion ab Anfang?
{
if ( aSel.nEndPos == pEngine->GetTextLen(0) )
{
// alles selektiert -> Anfuehrungszeichen weglassen
if ( aInsert.GetChar(0) == '"' )
aInsert.Erase(0,1);
xub_StrLen nInsLen = aInsert.Len();
if ( nInsLen && aInsert.GetChar(nInsLen-1) == '"' )
aInsert.Erase( nInsLen-1 );
}
else if ( aSel.nEndPos )
{
// nicht alles selektiert -> Gleichheitszeichen nicht ueberschreiben
//! doppelte Gleichheitszeichen auch ???
aSel.nStartPos = 1;
if ( pTopView )
pTopView->SetSelection( aSel );
if ( pTableView )
pTableView->SetSelection( aSel );
}
}
if ( pTopView )
pTopView->InsertText( aInsert, TRUE );
if ( pTableView )
pTableView->InsertText( aInsert, TRUE );
DataChanged();
}
HideTip();
}
void ScInputHandler::ResetAutoPar()
{
nAutoPar = 0;
}
void ScInputHandler::AutoParAdded()
{
++nAutoPar; // closing parenthesis can be overwritten
}
BOOL ScInputHandler::CursorAtClosingPar()
{
// test if the cursor is before a closing parenthesis
// selection from SetReference has been removed before
EditView* pActiveView = pTopView ? pTopView : pTableView;
if ( pActiveView && !pActiveView->HasSelection() && bFormulaMode )
{
ESelection aSel = pActiveView->GetSelection();
xub_StrLen nPos = aSel.nStartPos;
String aFormula = pEngine->GetText((USHORT)0);
if ( nPos < aFormula.Len() && aFormula.GetChar(nPos) == ')' )
return TRUE;
}
return FALSE;
}
void ScInputHandler::SkipClosingPar()
{
// this is called when a ')' is typed and the cursor is before a ')'
// that can be overwritten -> just set the cursor behind the ')'
EditView* pActiveView = pTopView ? pTopView : pTableView;
if (pActiveView)
{
ESelection aSel = pActiveView->GetSelection();
++aSel.nStartPos;
++aSel.nEndPos;
// this is in a formula (only one paragraph), so the selection
// can be used directly for the TopView
if ( pTopView )
pTopView->SetSelection( aSel );
if ( pTableView )
pTableView->SetSelection( aSel );
}
DBG_ASSERT(nAutoPar, "SkipClosingPar: count is wrong");
--nAutoPar;
}
//
// Auto-Eingabe
//
void ScInputHandler::GetColData()
{
if ( pActiveViewSh )
{
ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
if ( pColumnData )
pColumnData->FreeAll();
else
{
pColumnData = new TypedStrCollection;
pColumnData->SetCaseSensitive( TRUE ); // equal strings are handled in FindText
}
pDoc->GetDataEntries( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(),
*pColumnData, TRUE );
}
}
void ScInputHandler::UseColData() // beim Tippen
{
EditView* pActiveView = pTopView ? pTopView : pTableView;
if ( pActiveView && pColumnData )
{
// nur anpassen, wenn Cursor am Ende steht
ESelection aSel = pActiveView->GetSelection();
aSel.Adjust();
USHORT nParCnt = pEngine->GetParagraphCount();
if ( aSel.nEndPara+1 == nParCnt )
{
xub_StrLen nParLen = pEngine->GetTextLen( aSel.nEndPara );
if ( aSel.nEndPos == nParLen )
{
String aText = GetEditText(pEngine);
if (aText.Len())
{
String aNew;
nAutoPos = SCPOS_INVALID; // nix
if ( pColumnData->FindText( aText, aNew, nAutoPos, FALSE ) )
{
// #45434# durch dBase Import etc. koennen Umbrueche im String sein,
// das wuerde hier mehrere Absaetze ergeben -> nicht gut
//! GetExactMatch funktioniert dann auch nicht
lcl_RemoveLineEnd( aNew );
// Absaetze beibehalten, nur den Rest anfgen
//! genaue Ersetzung im EnterHandler !!!
// ein Space zwischen Absaetzen:
ULONG nEdLen = pEngine->GetTextLen() + nParCnt - 1;
String aIns = aNew.Copy( (xub_StrLen)nEdLen );
// selection must be "backwards", so the cursor stays behind the last
// typed character
ESelection aSelection( aSel.nEndPara, aSel.nEndPos + aIns.Len(),
aSel.nEndPara, aSel.nEndPos );
// when editing in input line, apply to both edit views
if ( pTableView )
{
pTableView->InsertText( aIns, FALSE );
pTableView->SetSelection( aSelection );
}
if ( pTopView )
{
pTopView->InsertText( aIns, FALSE );
pTopView->SetSelection( aSelection );
}
aAutoSearch = aText; // zum Weitersuchen - nAutoPos ist gesetzt
if ( aText.Len() == aNew.Len() )
{
// Wenn der eingegebene Text gefunden wurde, TAB nur dann
// verschlucken, wenn noch etwas kommt
String aDummy;
USHORT nNextPos = nAutoPos;
bUseTab = pColumnData->FindText( aText, aDummy, nNextPos, FALSE );
}
else
bUseTab = TRUE;
}
}
}
}
}
}
void ScInputHandler::NextAutoEntry( BOOL bBack )
{
EditView* pActiveView = pTopView ? pTopView : pTableView;
if ( pActiveView && pColumnData )
{
if ( nAutoPos != SCPOS_INVALID && aAutoSearch.Len() )
{
// stimmt die Selektion noch? (kann per Maus geaendert sein)
ESelection aSel = pActiveView->GetSelection();
aSel.Adjust();
USHORT nParCnt = pEngine->GetParagraphCount();
if ( aSel.nEndPara+1 == nParCnt && aSel.nStartPara == aSel.nEndPara )
{
String aText = GetEditText(pEngine);
xub_StrLen nSelLen = aSel.nEndPos - aSel.nStartPos;
xub_StrLen nParLen = pEngine->GetTextLen( aSel.nEndPara );
if ( aSel.nEndPos == nParLen && aText.Len() == aAutoSearch.Len() + nSelLen )
{
String aNew;
if ( pColumnData->FindText( aAutoSearch, aNew, nAutoPos, bBack ) )
{
bInOwnChange = TRUE; // disable ModifyHdl (reset below)
lcl_RemoveLineEnd( aNew );
String aIns = aNew.Copy( aAutoSearch.Len() );
// when editing in input line, apply to both edit views
if ( pTableView )
{
pTableView->DeleteSelected();
pTableView->InsertText( aIns, FALSE );
pTableView->SetSelection( ESelection(
aSel.nEndPara, aSel.nStartPos + aIns.Len(),
aSel.nEndPara, aSel.nStartPos ) );
}
if ( pTopView )
{
pTopView->DeleteSelected();
pTopView->InsertText( aIns, FALSE );
pTopView->SetSelection( ESelection(
aSel.nEndPara, aSel.nStartPos + aIns.Len(),
aSel.nEndPara, aSel.nStartPos ) );
}
bInOwnChange = FALSE;
}
else
{
// mehr gibts nicht
Sound::Beep();
}
}
}
}
}
// bei Tab wird vorher immer HideCursor gerufen
if (pActiveView)
pActiveView->ShowCursor();
}
//
// Klammern hervorheben
//
xub_StrLen lcl_MatchParenthesis( const String& rStr, xub_StrLen nPos )
{
int nDir;
sal_Unicode c1, c2;
c1 = rStr.GetChar( nPos );
switch ( c1 )
{
case '(' :
c2 = ')';
nDir = 1;
break;
case ')' :
c2 = '(';
nDir = -1;
break;
case '<' :
c2 = '>';
nDir = 1;
break;
case '>' :
c2 = '<';
nDir = -1;
break;
case '{' :
c2 = '}';
nDir = 1;
break;
case '}' :
c2 = '{';
nDir = -1;
break;
case '[' :
c2 = ']';
nDir = 1;
break;
case ']' :
c2 = '[';
nDir = -1;
break;
default:
nDir = 0;
}
if ( !nDir )
return STRING_NOTFOUND;
xub_StrLen nLen = rStr.Len();
const sal_Unicode* p0 = rStr.GetBuffer();
register const sal_Unicode* p;
const sal_Unicode* p1;
USHORT nQuotes = 0;
if ( nPos < nLen / 2 )
{
p = p0;
p1 = p0 + nPos;
}
else
{
p = p0 + nPos;
p1 = p0 + nLen;
}
while ( p < p1 )
{
if ( *p++ == '\"' )
nQuotes++;
}
// ungerade Anzahl Quotes: wir befinden uns in einem String
BOOL bLookInString = ((nQuotes % 2) != 0);
BOOL bInString = bLookInString;
p = p0 + nPos;
p1 = (nDir < 0 ? p0 : p0 + nLen) ;
USHORT nLevel = 1;
while ( p != p1 && nLevel )
{
p += nDir;
if ( *p == '\"' )
{
bInString = !bInString;
if ( bLookInString && !bInString )
p = p1; // das war's dann
}
else if ( bInString == bLookInString )
{
if ( *p == c1 )
nLevel++;
else if ( *p == c2 )
nLevel--;
}
}
if ( nLevel )
return STRING_NOTFOUND;
return (xub_StrLen) (p - p0);
}
void ScInputHandler::UpdateParenthesis()
{
// Klammern suchen
//! Klammer-Hervorhebung einzeln abschaltbar ????
BOOL bFound = FALSE;
if ( bFormulaMode && eMode != SC_INPUT_TOP )
{
if ( pTableView && !pTableView->HasSelection() ) // Selektion ist immer unten
{
ESelection aSel = pTableView->GetSelection();
if (aSel.nStartPos)
{
// Das Zeichen links vom Cursor wird angeschaut
xub_StrLen nPos = aSel.nStartPos - 1;
String aFormula = pEngine->GetText((USHORT)0);
sal_Unicode c = aFormula.GetChar(nPos);
if ( c == '(' || c == ')' )
{
xub_StrLen nOther = lcl_MatchParenthesis( aFormula, nPos );
if ( nOther != STRING_NOTFOUND )
{
SfxItemSet aSet( pEngine->GetEmptyItemSet() );
aSet.Put( SvxWeightItem( WEIGHT_BOLD, EE_CHAR_WEIGHT ) );
//! Unterscheidung, wenn die Zelle schon fett ist !!!!
if (bParenthesisShown)
{
// alte Hervorhebung wegnehmen
USHORT nCount = pEngine->GetParagraphCount();
for (USHORT i=0; i<nCount; i++)
pEngine->QuickRemoveCharAttribs( i, EE_CHAR_WEIGHT );
}
ESelection aSelThis( 0,nPos, 0,nPos+1 );
pEngine->QuickSetAttribs( aSet, aSelThis );
ESelection aSelOther( 0,nOther, 0,nOther+1 );
pEngine->QuickSetAttribs( aSet, aSelOther );
// Dummy-InsertText fuer Update und Paint (Selektion ist leer)
pTableView->InsertText( EMPTY_STRING, FALSE );
bFound = TRUE;
}
}
}
// mark parenthesis right of cursor if it will be overwritten (nAutoPar)
// with different color (COL_LIGHTBLUE) ??
}
}
// alte Hervorhebung wegnehmen, wenn keine neue gesetzt
if ( bParenthesisShown && !bFound && pTableView )
{
USHORT nCount = pEngine->GetParagraphCount();
for (USHORT i=0; i<nCount; i++)
pTableView->RemoveCharAttribs( i, EE_CHAR_WEIGHT );
}
bParenthesisShown = bFound;
}
void ScInputHandler::ViewShellGone(ScTabViewShell* pViewSh) // wird synchron aufgerufen!
{
if ( pViewSh == pActiveViewSh )
{
delete pLastState;
pLastState = NULL;
pLastPattern = NULL;
}
if ( pViewSh == pRefViewSh )
{
//! Die Eingabe kommt aus dem EnterHandler nicht mehr an
// Trotzdem wird immerhin der Editmodus beendet
EnterHandler();
bFormulaMode = FALSE;
pRefViewSh = NULL;
SFX_APP()->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
SC_MOD()->SetRefInputHdl(NULL);
if (pInputWin)
pInputWin->SetFormulaMode(FALSE);
UpdateAutoCorrFlag();
}
pActiveViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
if ( pActiveViewSh && pActiveViewSh == pViewSh )
{
DBG_ERROR("pActiveViewSh weg");
pActiveViewSh = NULL;
}
if ( SC_MOD()->GetInputOptions().GetTextWysiwyg() )
UpdateRefDevice(); // don't keep old document's printer as RefDevice
}
void ScInputHandler::UpdateActiveView()
{
ImplCreateEditEngine();
Window* pShellWin = pActiveViewSh ? pActiveViewSh->GetActiveWin() : NULL;
USHORT nCount = pEngine->GetViewCount();
if (nCount > 0)
{
pTableView = pEngine->GetView(0);
for (USHORT i=1; i<nCount; i++)
{
EditView* pThis = pEngine->GetView(i);
Window* pWin = pThis->GetWindow();
if ( pWin==pShellWin || pWin->HasFocus() )
pTableView = pThis;
}
}
else
pTableView = NULL;
if (pInputWin)
pTopView = pInputWin->GetEditView();
else
pTopView = NULL;
}
void ScInputHandler::StopInputWinEngine( BOOL bAll )
{
if (pInputWin)
pInputWin->StopEditEngine( bAll );
pTopView = NULL; // invalid now
}
void ScInputHandler::ActivateInputWindow( const String& rText,
const ESelection& rSel )
{
if ( pInputWin )
if ( !pInputWin->IsActive() )
pTopView = pInputWin->ActivateEdit( rText, rSel );
}
EditView* ScInputHandler::GetActiveView()
{
UpdateActiveView();
return pTopView ? pTopView : pTableView;
}
void ScInputHandler::ForgetLastPattern()
{
pLastPattern = NULL;
if ( !pLastState && pActiveViewSh )
pActiveViewSh->UpdateInputHandler( TRUE ); // Status neu holen
else
NotifyChange( pLastState, TRUE );
}
void ScInputHandler::UpdateAdjust( sal_Unicode cTyped )
{
SvxAdjust eSvxAdjust;
switch (nAttrAdjust)
{
case SVX_HOR_JUSTIFY_STANDARD:
{
BOOL bNumber = FALSE;
if (cTyped) // neu angefangen
bNumber = (cTyped>='0' && cTyped<='9'); // nur Ziffern sind Zahlen
else if ( pActiveViewSh )
{
ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
bNumber = ( pDoc->GetCellType( aCursorPos ) == CELLTYPE_VALUE );
}
eSvxAdjust = bNumber ? SVX_ADJUST_RIGHT : SVX_ADJUST_LEFT;
}
break;
case SVX_HOR_JUSTIFY_BLOCK:
eSvxAdjust = SVX_ADJUST_BLOCK;
break;
case SVX_HOR_JUSTIFY_CENTER:
eSvxAdjust = SVX_ADJUST_CENTER;
break;
case SVX_HOR_JUSTIFY_RIGHT:
eSvxAdjust = SVX_ADJUST_RIGHT;
break;
default: // SVX_HOR_JUSTIFY_LEFT
eSvxAdjust = SVX_ADJUST_LEFT;
break;
}
BOOL bAsianVertical = pLastPattern &&
(SvxCellOrientation)((const SvxOrientationItem&)
pLastPattern->GetItem(ATTR_ORIENTATION)).GetValue() == SVX_ORIENTATION_STACKED &&
((const SfxBoolItem&)pLastPattern->GetItem( ATTR_VERTICAL_ASIAN )).GetValue();
if ( bAsianVertical )
{
// always edit at top of cell -> LEFT when editing vertically
eSvxAdjust = SVX_ADJUST_LEFT;
}
pEditDefaults->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) );
pEngine->SetDefaults( *pEditDefaults );
nEditAdjust = eSvxAdjust; //! an ViewData setzen oder beim PostEditView
pEngine->SetVertical( bAsianVertical );
}
void ScInputHandler::RemoveAdjust()
{
// harte Ausrichtungs-Attribute loeschen
BOOL bUndo = pEngine->IsUndoEnabled();
if ( bUndo )
pEngine->EnableUndo( FALSE );
// RemoveParaAttribs removes all paragraph attributes, including EE_PARA_JUST
#if 0
BOOL bChange = FALSE;
USHORT nCount = pEngine->GetParagraphCount();
for (USHORT i=0; i<nCount; i++)
{
const SfxItemSet& rOld = pEngine->GetParaAttribs( i );
if ( rOld.GetItemState( EE_PARA_JUST ) == SFX_ITEM_SET )
{
SfxItemSet aNew( rOld );
aNew.ClearItem( EE_PARA_JUST );
pEngine->SetParaAttribs( i, aNew );
bChange = TRUE;
}
}
#endif
// #89403# non-default paragraph attributes (e.g. from clipboard)
// must be turned into character attributes
pEngine->RemoveParaAttribs();
if ( bUndo )
pEngine->EnableUndo( TRUE );
// ER 31.08.00 Only called in EnterHandler, don't change view anymore.
#if 0
if (bChange)
{
EditView* pActiveView = pTopView ? pTopView : pTableView;
pActiveView->ShowCursor( FALSE, TRUE );
}
#endif
}
void ScInputHandler::RemoveRangeFinder()
{
// pRangeFindList und Farben loeschen
pEngine->SetUpdateMode(FALSE);
USHORT nCount = pEngine->GetParagraphCount(); // koennte gerade neu eingefuegt worden sein
for (USHORT i=0; i<nCount; i++)
pEngine->QuickRemoveCharAttribs( i, EE_CHAR_COLOR );
pEngine->SetUpdateMode(TRUE);
EditView* pActiveView = pTopView ? pTopView : pTableView;
pActiveView->ShowCursor( FALSE, TRUE );
DeleteRangeFinder(); // loescht die Liste und die Markierungen auf der Tabelle
}
BOOL ScInputHandler::StartTable( sal_Unicode cTyped, BOOL bFromCommand )
{
// returns TRUE if a new edit mode was started
BOOL bNewTable = FALSE;
if (!bModified && aCursorPos.Col()<=MAXCOL)
{
if (pActiveViewSh)
{
ImplCreateEditEngine();
UpdateActiveView();
SyncViews();
ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
const ScMarkData& rMark = pActiveViewSh->GetViewData()->GetMarkData();
ScEditableTester aTester;
if ( rMark.IsMarked() || rMark.IsMultiMarked() )
aTester.TestSelection( pDoc, rMark );
else
aTester.TestSelectedBlock( pDoc, aCursorPos.Col(),aCursorPos.Row(),
aCursorPos.Col(),aCursorPos.Row(), rMark );
if ( aTester.IsEditable() )
{
// UpdateMode is enabled again in ScViewData::SetEditEngine (and not needed otherwise)
pEngine->SetUpdateMode( FALSE );
// Attribute in EditEngine uebernehmen
const ScPatternAttr* pPattern = pDoc->GetPattern( aCursorPos.Col(),
aCursorPos.Row(),
aCursorPos.Tab() );
if (pPattern != pLastPattern)
{
// Prozent-Format?
const SfxItemSet& rAttrSet = pPattern->GetItemSet();
const SfxPoolItem* pItem;
if ( SFX_ITEM_SET == rAttrSet.GetItemState( ATTR_VALUE_FORMAT, TRUE, &pItem ) )
{
ULONG nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
bCellHasPercentFormat = ( NUMBERFORMAT_PERCENT ==
pDoc->GetFormatTable()->GetType( nFormat ) );
}
else
bCellHasPercentFormat = FALSE; // Default: kein Prozent
// Gueltigkeit angegeben?
if ( SFX_ITEM_SET == rAttrSet.GetItemState( ATTR_VALIDDATA, TRUE, &pItem ) )
nValidation = ((const SfxUInt32Item*)pItem)->GetValue();
else
nValidation = 0;
// EditEngine Defaults
// Hier auf keinen Fall SetParaAttribs, weil die EditEngine evtl.
// schon gefuellt ist (bei Edit-Zellen).
// SetParaAttribs wuerde dann den Inhalt aendern
//! ER 30.08.00 The SetDefaults is now (since MUST/src602
//! EditEngine changes) implemented as a SetParaAttribs.
//! Any problems?
pPattern->FillEditItemSet( pEditDefaults );
pEngine->SetDefaults( *pEditDefaults );
pLastPattern = pPattern;
bLastIsSymbol = pPattern->IsSymbolFont();
// Background color must be known for automatic font color.
// For transparent cell background, the document background color must be used.
Color aBackCol = ((const SvxBrushItem&)
pPattern->GetItem( ATTR_BACKGROUND )).GetColor();
ScModule* pScMod = SC_MOD();
// #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
if ( aBackCol.GetTransparency() > 0 ||
Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
aBackCol.SetColor( pScMod->GetColorConfig().GetColorValue(svx::DOCCOLOR).nColor );
pEngine->SetBackgroundColor( aBackCol );
// Ausrichtung
nAttrAdjust = ((const SvxHorJustifyItem&)pPattern->
GetItem(ATTR_HOR_JUSTIFY)).GetValue();
}
// UpdateSpellSettings enables online spelling if needed
// -> also call if attributes are unchanged
UpdateSpellSettings( TRUE ); // uses pLastPattern
// Edit-Engine fuellen
String aStr;
if (bTextValid)
{
pEngine->SetText(aCurrentText);
aStr = aCurrentText;
bTextValid = FALSE;
aCurrentText.Erase();
}
else
aStr = GetEditText(pEngine);
if (aStr.Len() > 3 && // Matrix-Formel ?
aStr.GetChar(0) == '{' &&
aStr.GetChar(1) == '=' &&
aStr.GetChar(aStr.Len()-1) == '}')
{
aStr.Erase(0,1);
aStr.Erase(aStr.Len()-1,1);
pEngine->SetText(aStr);
if ( pInputWin )
pInputWin->SetTextString(aStr);
}
UpdateAdjust( cTyped );
if ( bAutoComplete )
GetColData();
if ( aStr.GetChar(0) == '=' && !cTyped && !bCreatingFuncView )
InitRangeFinder(aStr); // Formel wird editiert -> RangeFinder
bNewTable = TRUE; // -> PostEditView-Aufruf
}
else
{
bProtected = TRUE;
eMode = SC_INPUT_NONE;
StopInputWinEngine( TRUE );
UpdateFormulaMode();
if ( pActiveViewSh && ( !bFromCommand || !bCommandErrorShown ) )
{
// #97673# Prevent repeated error messages for the same cell from command events
// (for keyboard events, multiple messages are wanted).
// Set the flag before showing the error message because the command handler
// for the next IME command may be called when showing the dialog.
if ( bFromCommand )
bCommandErrorShown = TRUE;
pActiveViewSh->GetActiveWin()->GrabFocus();
pActiveViewSh->ErrorMessage(aTester.GetMessageId());
}
}
}
if (!bProtected && pInputWin)
pInputWin->SetOkCancelMode();
}
return bNewTable;
}
void lcl_SetTopSelection( EditView* pEditView, ESelection& rSel )
{
DBG_ASSERT( rSel.nStartPara==0 && rSel.nEndPara==0, "SetTopSelection: Para != 0" );
EditEngine* pEngine = pEditView->GetEditEngine();
USHORT nCount = pEngine->GetParagraphCount();
if (nCount > 1)
{
xub_StrLen nParLen = pEngine->GetTextLen(rSel.nStartPara);
while (rSel.nStartPos > nParLen && rSel.nStartPara+1 < nCount)
{
rSel.nStartPos -= nParLen + 1; // incl. Leerzeichen vom Umbruch
nParLen = pEngine->GetTextLen(++rSel.nStartPara);
}
nParLen = pEngine->GetTextLen(rSel.nEndPara);
while (rSel.nEndPos > nParLen && rSel.nEndPara+1 < nCount)
{
rSel.nEndPos -= nParLen + 1; // incl. Leerzeichen vom Umbruch
nParLen = pEngine->GetTextLen(++rSel.nEndPara);
}
}
ESelection aSel = pEditView->GetSelection();
if ( rSel.nStartPara != aSel.nStartPara || rSel.nEndPara != aSel.nEndPara
|| rSel.nStartPos != aSel.nStartPos || rSel.nEndPos != aSel.nEndPos )
pEditView->SetSelection( rSel );
}
void ScInputHandler::SyncViews( EditView* pSourceView )
{
ESelection aSel;
if (pSourceView)
{
aSel = pSourceView->GetSelection();
if (pTopView && pTopView != pSourceView)
pTopView->SetSelection( aSel );
if (pTableView && pTableView != pSourceView)
lcl_SetTopSelection( pTableView, aSel );
}
else if (pTopView && pTableView)
{
aSel = pTopView->GetSelection();
lcl_SetTopSelection( pTableView, aSel );
}
}
void ScInputHandler::SetAllUpdateMode( BOOL bUpdate )
{
ImplCreateEditEngine();
pEngine->SetUpdateMode( bUpdate );
}
IMPL_LINK( ScInputHandler, ModifyHdl, void *, EMPTYARG )
{
if ( !bInOwnChange && ( eMode==SC_INPUT_TYPE || eMode==SC_INPUT_TABLE ) &&
pEngine && pEngine->GetUpdateMode() && pInputWin )
{
// #102745# update input line from ModifyHdl for changes that are not
// wrapped by DataChanging/DataChanged calls (like Drag&Drop)
String aText = GetEditText(pEngine);
lcl_RemoveTabs(aText);
pInputWin->SetTextString(aText);
}
return 0;
}
BOOL ScInputHandler::DataChanging( sal_Unicode cTyped, BOOL bFromCommand ) // return TRUE = new view created
{
bInOwnChange = TRUE; // disable ModifyHdl (reset in DataChanged)
if ( eMode == SC_INPUT_NONE )
return StartTable( cTyped, bFromCommand );
else
return FALSE;
}
void ScInputHandler::DataChanged()
{
ImplCreateEditEngine();
if (eMode==SC_INPUT_NONE)
eMode = SC_INPUT_TYPE;
bModified = TRUE;
bSelIsRef = FALSE;
if ( pRangeFindList && !bInRangeUpdate )
RemoveRangeFinder(); // Attribute und Markierung loeschen
UpdateParenthesis(); // Hervorhebung der Klammern neu
// ER 31.08.00 New SetDefaults sets ParaAttribs, don't clear them away ...
// RemoveAdjust(); // #40255# harte Ausrichtungs-Attribute loeschen
if (eMode==SC_INPUT_TYPE || eMode==SC_INPUT_TABLE)
{
String aText = GetEditText(pEngine);
lcl_RemoveTabs(aText);
if ( pInputWin )
pInputWin->SetTextString(aText);
}
// wenn der Cursor vor dem Absatzende steht, werden Teile rechts rausgeschoben
// (unabhaengig von eMode) -> View anpassen!
// wenn der Cursor am Ende steht, reicht der Status-Handler an der ViewData
// #93767# first make sure the status handler is called now if the cursor
// is outside the visible area
pEngine->QuickFormatDoc();
EditView* pActiveView = pTopView ? pTopView : pTableView;
if (pActiveView && pActiveViewSh)
{
BOOL bNeedGrow = ( nEditAdjust != SVX_ADJUST_LEFT ); // rechtsbuendig immer
if (!bNeedGrow)
{
// Cursor vor dem Ende?
ESelection aSel = pActiveView->GetSelection();
aSel.Adjust();
bNeedGrow = ( aSel.nEndPos != pEngine->GetTextLen(aSel.nEndPara) );
}
if (bNeedGrow)
{
// Inplace-View anpassen
pActiveViewSh->GetViewData()->EditGrowY();
pActiveViewSh->GetViewData()->EditGrowX();
}
}
UpdateFormulaMode();
bTextValid = FALSE; // Aenderungen sind nur in der Edit-Engine
bInOwnChange = FALSE;
}
void ScInputHandler::UpdateFormulaMode()
{
SfxApplication* pSfxApp = SFX_APP();
if ( pEngine->GetParagraphCount()==1 && pEngine->GetText((USHORT)0).GetChar(0) == '='
&& !bProtected )
{
if (!bFormulaMode)
{
bFormulaMode = TRUE;
pRefViewSh = pActiveViewSh;
pSfxApp->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
SC_MOD()->SetRefInputHdl(this);
if (pInputWin)
pInputWin->SetFormulaMode(TRUE);
if ( bAutoComplete )
GetFormulaData();
UpdateParenthesis();
UpdateAutoCorrFlag();
}
}
else // ausschalten
{
if (bFormulaMode)
{
ShowRefFrame();
bFormulaMode = FALSE;
pRefViewSh = NULL;
pSfxApp->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
SC_MOD()->SetRefInputHdl(NULL);
if (pInputWin)
pInputWin->SetFormulaMode(FALSE);
UpdateAutoCorrFlag();
}
}
}
void ScInputHandler::ShowRefFrame()
{
pActiveViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
if ( pRefViewSh && pRefViewSh != pActiveViewSh )
{
BOOL bFound = FALSE;
SfxViewFrame* pRefFrame = pRefViewSh->GetViewFrame();
SfxViewFrame* pOneFrame = SfxViewFrame::GetFirst();
while ( pOneFrame && !bFound )
{
if ( pOneFrame == pRefFrame )
bFound = TRUE;
pOneFrame = SfxViewFrame::GetNext( *pOneFrame );
}
if (bFound)
{
// Hier wird sich darauf verlassen, dass Activate synchron funktioniert
// (dabei wird pActiveViewSh umgesetzt)
pRefViewSh->SetActive(); // Appear und SetViewFrame
// pLastState wird im NotifyChange aus dem Activate richtig gesetzt
}
else
DBG_ERROR("ViewFrame fuer Referenzeingabe ist nicht mehr da");
}
}
void ScInputHandler::RemoveSelection()
{
EditView* pActiveView = pTopView ? pTopView : pTableView;
if (!pActiveView)
return;
ESelection aSel = pActiveView->GetSelection();
aSel.nStartPara = aSel.nEndPara;
aSel.nStartPos = aSel.nEndPos;
if (pTableView)
pTableView->SetSelection( aSel );
if (pTopView)
pTopView->SetSelection( aSel );
}
void ScInputHandler::InvalidateAttribs()
{
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
if (pViewFrm)
{
SfxBindings& rBindings = pViewFrm->GetBindings();
rBindings.Invalidate( SID_ATTR_CHAR_FONT );
rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
rBindings.Invalidate( SID_ULINE_VAL_NONE );
rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
rBindings.Invalidate( SID_HYPERLINK_GETLINK );
}
}
//
// --------------- public Methoden --------------------------------------------
//
void ScInputHandler::SetMode( ScInputMode eNewMode )
{
if ( eMode == eNewMode )
return;
ImplCreateEditEngine();
if (bProtected)
{
eMode = SC_INPUT_NONE;
StopInputWinEngine( TRUE );
if (pActiveViewSh)
pActiveViewSh->GetActiveWin()->GrabFocus();
return;
}
bInOwnChange = TRUE; // disable ModifyHdl (reset below)
ScInputMode eOldMode = eMode;
eMode = eNewMode;
if (eOldMode == SC_INPUT_TOP && eNewMode != eOldMode)
StopInputWinEngine( FALSE );
if (eMode==SC_INPUT_TOP || eMode==SC_INPUT_TABLE)
{
if (eOldMode == SC_INPUT_NONE) // not when switching between modes
{
if (StartTable(0, FALSE)) // 0 = look at existing document content for text or number
{
if (pActiveViewSh)
pActiveViewSh->GetViewData()->GetDocShell()->PostEditView( pEngine, aCursorPos );
}
}
USHORT nPara = pEngine->GetParagraphCount()-1;
xub_StrLen nLen = pEngine->GetText(nPara).Len();
USHORT nCount = pEngine->GetViewCount();
for (USHORT i=0; i<nCount; i++)
{
if ( eMode == SC_INPUT_TABLE && eOldMode == SC_INPUT_TOP )
{
// Selektion bleibt
}
else
{
pEngine->GetView(i)->
SetSelection( ESelection( nPara, nLen, nPara, nLen ) );
}
pEngine->GetView(i)->ShowCursor(FALSE);
}
}
UpdateActiveView();
if (eMode==SC_INPUT_TABLE || eMode==SC_INPUT_TYPE)
{
if (pTableView)
pTableView->SetEditEngineUpdateMode(TRUE);
}
else
{
if (pTopView)
pTopView->SetEditEngineUpdateMode(TRUE);
}
if (eNewMode != eOldMode)
UpdateFormulaMode();
bInOwnChange = FALSE;
}
//----------------------------------------------------------------------------------------
// lcl_IsNumber - TRUE, wenn nur Ziffern (dann keine Autokorrektur)
BOOL lcl_IsNumber(const String& rString)
{
xub_StrLen nLen = rString.Len();
for (xub_StrLen i=0; i<nLen; i++)
{
sal_Unicode c = rString.GetChar(i);
if ( c < '0' || c > '9' )
return FALSE;
}
return TRUE;
}
void ScInputHandler::EnterHandler( BYTE nBlockMode )
{
// #62806# Bei Makro-Aufrufen fuer Gueltigkeit kann Tod und Teufel passieren,
// darum dafuer sorgen, dass EnterHandler nicht verschachtelt gerufen wird:
if (bInEnterHandler) return;
bInEnterHandler = TRUE;
bInOwnChange = TRUE; // disable ModifyHdl (reset below)
ImplCreateEditEngine();
BOOL bMatrix = ( nBlockMode == SC_ENTER_MATRIX );
SfxApplication* pSfxApp = SFX_APP();
EditTextObject* pObject = NULL;
ScPatternAttr* pCellAttrs = NULL;
BOOL bAttrib = FALSE; // Formatierung vorhanden ?
BOOL bForget = FALSE; // wegen Gueltigkeit streichen ?
String aString = GetEditText(pEngine);
EditView* pActiveView = pTopView ? pTopView : pTableView;
if (bModified && pActiveView && aString.Len() && !lcl_IsNumber(aString))
{
if (pTopView)
pTopView->CompleteAutoCorrect(); // #59759# CompleteAutoCorrect fuer beide Views
if (pTableView)
pTableView->CompleteAutoCorrect();
aString = GetEditText(pEngine);
}
lcl_RemoveTabs(aString);
// Test, ob zulaessig (immer mit einfachem String)
if ( bModified && nValidation && pActiveViewSh )
{
ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocument();
const ScValidationData* pData = pDoc->GetValidationEntry( nValidation );
if (pData && pData->HasErrMsg())
{
const ScPatternAttr* pPattern = pLastPattern;
if (!pPattern)
{
DBG_ERROR("kein Pattern !??!");
pPattern = pDoc->GetPattern( aCursorPos.Col(), aCursorPos.Row(),
aCursorPos.Tab() );
}
BOOL bOk = pData->IsDataValid( aString, *pPattern, aCursorPos );
if (!bOk)
{
if ( pActiveViewSh ) // falls aus MouseButtonDown gekommen
pActiveViewSh->StopMarking(); // (die InfoBox verschluckt das MouseButtonUp)
//! es gibt noch Probleme, wenn die Eingabe durch Aktivieren einer
//! anderen View ausgeloest wurde
Window* pParent = Application::GetDefDialogParent();
if ( pData->DoError( pParent, aString, aCursorPos ) )
bForget = TRUE; // Eingabe nicht uebernehmen
}
}
}
pEngine->CompleteOnlineSpelling();
BOOL bSpellErrors = !bFormulaMode && pEngine->HasOnlineSpellErrors();
if ( bSpellErrors )
{
// Test, ob Zahl, dann Fehler ignorieren
}
// After RemoveAdjust, the EditView must not be repainted (has wrong font size etc).
// SetUpdateMode must come after CompleteOnlineSpelling.
// The view is hidden in any case below (Broadcast).
pEngine->SetUpdateMode( FALSE );
if ( bModified && !bForget ) // was wird eingeben (Text/Objekt) ?
{
USHORT nParCnt = pEngine->GetParagraphCount();
if ( nParCnt == 0 )
nParCnt = 1;
ESelection aSel( 0, 0, nParCnt-1, pEngine->GetTextLen(nParCnt-1) );
SfxItemSet aOldAttribs = pEngine->GetAttribs( aSel );
const SfxPoolItem* pItem = NULL;
// find common (cell) attributes before RemoveAdjust
if ( pActiveViewSh )
{
SfxItemSet* pCommonAttrs = NULL;
for (USHORT nId = EE_CHAR_START; nId <= EE_CHAR_END; nId++)
{
SfxItemState eState = aOldAttribs.GetItemState( nId, FALSE, &pItem );
if ( eState == SFX_ITEM_SET &&
nId != EE_CHAR_ESCAPEMENT && nId != EE_CHAR_PAIRKERNING &&
nId != EE_CHAR_KERNING && nId != EE_CHAR_XMLATTRIBS &&
*pItem != pEditDefaults->Get(nId) )
{
if ( !pCommonAttrs )
pCommonAttrs = new SfxItemSet( pEngine->GetEmptyItemSet() );
pCommonAttrs->Put( *pItem );
}
}
if ( pCommonAttrs )
{
ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocument();
pCellAttrs = new ScPatternAttr( pDoc->GetPool() );
pCellAttrs->GetFromEditItemSet( pCommonAttrs );
delete pCommonAttrs;
}
}
// clear ParaAttribs (including adjustment)
RemoveAdjust();
// check if EditObject is needed
if ( bSpellErrors || nParCnt > 1 )
bAttrib = TRUE;
else
{
for (USHORT nId = EE_CHAR_START; nId <= EE_CHAR_END && !bAttrib; nId++)
{
SfxItemState eState = aOldAttribs.GetItemState( nId, FALSE, &pItem );
if (eState == SFX_ITEM_DONTCARE)
bAttrib = TRUE;
else if (eState == SFX_ITEM_SET)
{
// keep same items in EditEngine as in ScEditAttrTester
if ( nId == EE_CHAR_ESCAPEMENT || nId == EE_CHAR_PAIRKERNING ||
nId == EE_CHAR_KERNING || nId == EE_CHAR_XMLATTRIBS )
{
if ( *pItem != pEditDefaults->Get(nId) )
bAttrib = TRUE;
}
}
}
// Feldbefehle enthalten?
SfxItemState eFieldState = aOldAttribs.GetItemState( EE_FEATURE_FIELD, FALSE );
if ( eFieldState == SFX_ITEM_DONTCARE || eFieldState == SFX_ITEM_SET )
bAttrib = TRUE;
// not converted characters?
SfxItemState eConvState = aOldAttribs.GetItemState( EE_FEATURE_NOTCONV, FALSE );
if ( eConvState == SFX_ITEM_DONTCARE || eConvState == SFX_ITEM_SET )
bAttrib = TRUE;
// Formeln immer als Formeln erkennen (#38309#)
// (der Test vorher ist trotzdem noetig wegen Zell-Attributen)
if ( bAttrib && bFormulaMode )
bAttrib = FALSE;
}
if (bMatrix)
bAttrib = FALSE;
if (bAttrib)
{
ULONG nCtrl = pEngine->GetControlWord();
ULONG nWantBig = bSpellErrors ? EE_CNTRL_ALLOWBIGOBJS : 0;
if ( ( nCtrl & EE_CNTRL_ALLOWBIGOBJS ) != nWantBig )
pEngine->SetControlWord( (nCtrl & ~EE_CNTRL_ALLOWBIGOBJS) | nWantBig );
pObject = pEngine->CreateTextObject();
}
else if (bAutoComplete) // Gross-/Kleinschreibung anpassen
{
if (pColumnData)
pColumnData->GetExactMatch( aString );
//! effizienter in der Liste suchen (ScUserList, nur einmal ToUpper)
USHORT nIndex;
ScUserListData* pData = ScGlobal::GetUserList()->GetData(aString);
if ( pData && pData->GetSubIndex( aString, nIndex ) )
aString = pData->GetSubStr( nIndex );
}
}
// don't rely on ShowRefFrame switching the active view synchronously
// execute the function directly on the correct view's bindings instead
// pRefViewSh is reset in ShowRefFrame - get pointer before ShowRefFrame call
ScTabViewShell* pExecuteSh = pRefViewSh ? pRefViewSh : pActiveViewSh;
if (bFormulaMode)
{
ShowRefFrame();
if (pExecuteSh)
pExecuteSh->SetTabNo(aCursorPos.Tab());
bFormulaMode = FALSE;
pSfxApp->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
SC_MOD()->SetRefInputHdl(NULL);
if (pInputWin)
pInputWin->SetFormulaMode(FALSE);
UpdateAutoCorrFlag();
}
pRefViewSh = NULL; // auch ohne FormulaMode wegen Funktions-AP
DeleteRangeFinder();
ResetAutoPar();
BOOL bOldMod = bModified;
bModified = FALSE;
bSelIsRef = FALSE;
eMode = SC_INPUT_NONE;
StopInputWinEngine( TRUE );
if (bOldMod && !bProtected && !bForget)
{
// keine typographische Anfuehrungszeichen in Formeln
if ( aString.GetChar(0) == '=' )
{
SvxAutoCorrect* pAuto = OFF_APP()->GetAutoCorrect();
if ( pAuto )
{
sal_Unicode cReplace = pAuto->GetStartDoubleQuote();
if( !cReplace )
cReplace = ScGlobal::pLocaleData->getDoubleQuotationMarkStart().GetChar(0);
if ( cReplace != '"' )
aString.SearchAndReplaceAll( cReplace, '"' );
cReplace = pAuto->GetEndDoubleQuote();
if( !cReplace )
cReplace = ScGlobal::pLocaleData->getDoubleQuotationMarkEnd().GetChar(0);
if ( cReplace != '"' )
aString.SearchAndReplaceAll( cReplace, '"' );
cReplace = pAuto->GetStartSingleQuote();
if( !cReplace )
cReplace = ScGlobal::pLocaleData->getQuotationMarkStart().GetChar(0);
if ( cReplace != '\'' )
aString.SearchAndReplaceAll( cReplace, '\'' );
cReplace = pAuto->GetEndSingleQuote();
if( !cReplace )
cReplace = ScGlobal::pLocaleData->getQuotationMarkEnd().GetChar(0);
if ( cReplace != '\'' )
aString.SearchAndReplaceAll( cReplace, '\'' );
}
}
pSfxApp->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW_NOPAINT ) );
if ( pExecuteSh )
{
SfxBindings& rBindings = pExecuteSh->GetViewFrame()->GetBindings();
USHORT nId = FID_INPUTLINE_ENTER;
if ( nBlockMode == SC_ENTER_BLOCK )
nId = FID_INPUTLINE_BLOCK;
else if ( nBlockMode == SC_ENTER_MATRIX )
nId = FID_INPUTLINE_MATRIX;
ScInputStatusItem aItem( FID_INPUTLINE_STATUS,
aCursorPos, aCursorPos, aCursorPos,
aString, pObject );
const SfxPoolItem* aArgs[2];
aArgs[0] = &aItem;
aArgs[1] = NULL;
rBindings.Execute( nId, aArgs );
}
delete pLastState; // pLastState enthaelt noch den alten Text
pLastState = NULL;
}
else
pSfxApp->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
if ( bOldMod && pExecuteSh && pCellAttrs && !bForget )
{
// mit Eingabe zusammenfassen ?
pExecuteSh->ApplySelectionPattern( *pCellAttrs, TRUE, TRUE );
pExecuteSh->AdjustBlockHeight();
}
delete pCellAttrs;
delete pObject;
HideTip();
nFormSelStart = nFormSelEnd = 0;
aFormText.Erase();
bInOwnChange = FALSE;
bInEnterHandler = FALSE;
}
void ScInputHandler::CancelHandler()
{
bInOwnChange = TRUE; // disable ModifyHdl (reset below)
ImplCreateEditEngine();
bModified = FALSE;
// don't rely on ShowRefFrame switching the active view synchronously
// execute the function directly on the correct view's bindings instead
// pRefViewSh is reset in ShowRefFrame - get pointer before ShowRefFrame call
ScTabViewShell* pExecuteSh = pRefViewSh ? pRefViewSh : pActiveViewSh;
if (bFormulaMode)
{
ShowRefFrame();
if (pExecuteSh)
pExecuteSh->SetTabNo(aCursorPos.Tab());
bFormulaMode = FALSE;
SFX_APP()->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
SC_MOD()->SetRefInputHdl(NULL);
if (pInputWin)
pInputWin->SetFormulaMode(FALSE);
UpdateAutoCorrFlag();
}
pRefViewSh = NULL; // auch ohne FormulaMode wegen Funktions-AP
DeleteRangeFinder();
ResetAutoPar();
eMode = SC_INPUT_NONE;
StopInputWinEngine( TRUE );
if (pExecuteSh)
pExecuteSh->StopEditShell();
aCursorPos.Set(MAXCOL+1,0,0); // Flag, dass ungueltig
pEngine->SetText(String());
if ( !pLastState && pExecuteSh )
pExecuteSh->UpdateInputHandler( TRUE ); // Status neu holen
else
NotifyChange( pLastState, TRUE );
nFormSelStart = nFormSelEnd = 0;
aFormText.Erase();
bInOwnChange = FALSE;
}
BOOL ScInputHandler::IsModalMode( SfxObjectShell* pDocSh )
{
// Referenzen auf unbenanntes Dokument gehen nicht
return bFormulaMode && pRefViewSh
&& pRefViewSh->GetViewData()->GetDocument()->GetDocumentShell() != pDocSh
&& !pDocSh->HasName();
}
void ScInputHandler::AddRefEntry()
{
UpdateActiveView();
if (!pTableView && !pTopView)
return; // z.B. FillMode
DataChanging(); // kann nicht neu sein
RemoveSelection();
if (pTableView)
pTableView->InsertText( ';', FALSE );
if (pTopView)
pTopView->InsertText( ';', FALSE );
DataChanged();
}
void ScInputHandler::SetReference( const ScRange& rRef, ScDocument* pDoc )
{
HideTip();
BOOL bOtherDoc = ( pRefViewSh &&
pRefViewSh->GetViewData()->GetDocument() != pDoc );
if (bOtherDoc)
if (!pDoc->GetDocumentShell()->HasName())
{
// Referenzen auf unbenanntes Dokument gehen nicht
// (SetReference sollte dann auch nicht gerufen werden)
return;
}
UpdateActiveView();
if (!pTableView && !pTopView)
return; // z.B. FillMode
// nie das "=" ueberschreiben!
EditView* pActiveView = pTopView ? pTopView : pTableView;
ESelection aSel = pActiveView->GetSelection();
aSel.Adjust();
if ( aSel.nStartPara == 0 && aSel.nStartPos == 0 )
return;
DataChanging(); // kann nicht neu sein
// Selektion umdrehen, falls rueckwaerts (noetig ???)
if (pTableView)
{
ESelection aSel = pTableView->GetSelection();
if (aSel.nStartPos > aSel.nEndPos && aSel.nStartPara == aSel.nEndPara)
{
aSel.Adjust();
pTableView->SetSelection(aSel);
}
}
if (pTopView)
{
ESelection aSel = pTopView->GetSelection();
if (aSel.nStartPos > aSel.nEndPos && aSel.nStartPara == aSel.nEndPara)
{
aSel.Adjust();
pTopView->SetSelection(aSel);
}
}
// String aus Referenz erzeugen
String aRefStr;
if (bOtherDoc)
{
// Referenz auf anderes Dokument
DBG_ASSERT(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
String aTmp;
rRef.Format( aTmp, SCA_VALID|SCA_TAB_3D, pDoc ); // immer 3d
SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
String aFileName = pObjSh->GetMedium()->GetName();
aRefStr = '\'';
aRefStr += aFileName;
aRefStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "'#" ));
aRefStr += aTmp;
}
else
{
if ( ( rRef.aStart.Tab() != aCursorPos.Tab() ||
rRef.aStart.Tab() != rRef.aEnd.Tab() ) && pDoc )
rRef.Format( aRefStr, SCA_VALID|SCA_TAB_3D, pDoc );
else
rRef.Format( aRefStr, SCA_VALID );
}
if (pTableView || pTopView)
{
if (pTableView)
pTableView->InsertText( aRefStr, TRUE );
if (pTopView)
pTopView->InsertText( aRefStr, TRUE );
DataChanged();
}
bSelIsRef = TRUE;
}
void ScInputHandler::InsertFunction( const String& rFuncName, BOOL bAddPar )
{
if ( eMode == SC_INPUT_NONE )
{
DBG_ERROR("InsertFunction, nicht im Eingabemodus");
return;
}
UpdateActiveView();
if (!pTableView && !pTopView)
return; // z.B. FillMode
DataChanging(); // kann nicht neu sein
String aText = rFuncName;
if (bAddPar)
aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" ));
if (pTableView)
{
pTableView->InsertText( aText, FALSE );
if (bAddPar)
{
ESelection aSel = pTableView->GetSelection();
--aSel.nStartPos;
--aSel.nEndPos;
pTableView->SetSelection(aSel);
}
}
if (pTopView)
{
pTopView->InsertText( aText, FALSE );
if (bAddPar)
{
ESelection aSel = pTopView->GetSelection();
--aSel.nStartPos;
--aSel.nEndPos;
pTopView->SetSelection(aSel);
}
}
DataChanged();
if (bAddPar)
AutoParAdded();
}
void ScInputHandler::ClearText()
{
if ( eMode == SC_INPUT_NONE )
{
DBG_ERROR("ClearText, nicht im Eingabemodus");
return;
}
UpdateActiveView();
if (!pTableView && !pTopView)
return; // z.B. FillMode
DataChanging(); // darf nicht neu sein
String aEmpty;
if (pTableView)
{
pTableView->GetEditEngine()->SetText( aEmpty );
pTableView->SetSelection( ESelection(0,0, 0,0) );
}
if (pTopView)
{
pTopView->GetEditEngine()->SetText( aEmpty );
pTopView->SetSelection( ESelection(0,0, 0,0) );
}
DataChanged();
}
BOOL ScInputHandler::KeyInput( const KeyEvent& rKEvt, BOOL bStartEdit /* = FALSE */ )
{
if (!bOptLoaded)
{
bAutoComplete = SC_MOD()->GetAppOptions().GetAutoComplete();
bOptLoaded = TRUE;
}
KeyCode aCode = rKEvt.GetKeyCode();
USHORT nModi = aCode.GetModifier();
BOOL bShift = aCode.IsShift();
BOOL bControl = aCode.IsMod1();
BOOL bAlt = aCode.IsMod2();
USHORT nCode = aCode.GetCode();
sal_Unicode nChar = rKEvt.GetCharCode();
// Alt-Return wird gebraucht, alle anderen Alt's und Ctrl-Tab nicht:
#ifndef MAC
if (( bAlt && !bControl && nCode != KEY_RETURN ) ||
( bControl && aCode.GetCode() == KEY_TAB ))
return FALSE;
#endif
// auf'm Mac nicht, sonst werden druckbare Zeichen unterdrueckt
BOOL bInputLine = ( eMode==SC_INPUT_TOP );
BOOL bUsed = FALSE;
BOOL bSkip = FALSE;
BOOL bDoEnter = FALSE;
switch ( nCode )
{
case KEY_RETURN:
if (bControl && !bShift && !bInputLine)
bDoEnter = TRUE;
else if ( nModi == 0 && nTipVisible && pFormulaData && nAutoPos != SCPOS_INVALID )
{
PasteFunctionData();
bUsed = TRUE;
}
else if ( nModi == 0 && nTipVisible && aManualTip.Len() )
{
PasteManualTip();
bUsed = TRUE;
}
else
{
BYTE nMode = SC_ENTER_NORMAL;
if ( bShift && bControl )
nMode = SC_ENTER_MATRIX;
else if ( bAlt )
nMode = SC_ENTER_BLOCK;
EnterHandler( nMode );
if (pActiveViewSh)
pActiveViewSh->MoveCursorEnter( bShift && !bControl );
bUsed = TRUE;
}
break;
case KEY_TAB:
if (!bControl && !bAlt)
{
if ( pFormulaData && nTipVisible && nAutoPos != SCPOS_INVALID )
{
// blaettern
NextFormulaEntry( bShift );
}
else if ( pColumnData && bUseTab && nAutoPos != SCPOS_INVALID )
{
// in den Eintraegen der AutoEingabe blaettern
NextAutoEntry( bShift );
}
else
{
EnterHandler();
// TabKeyInput gibt auf manchen Rechnern unter W95 Stackueberlaeufe,
// darum direkter Aufruf:
if (pActiveViewSh)
pActiveViewSh->FindNextUnprot( bShift );
}
bUsed = TRUE;
}
break;
case KEY_ESCAPE:
if ( nTipVisible )
{
HideTip();
bUsed = TRUE;
}
else if (eMode != SC_INPUT_NONE)
{
CancelHandler();
bUsed = TRUE;
}
else
bSkip = TRUE;
break;
case KEY_F2:
if ( !bShift && !bControl && !bAlt && eMode == SC_INPUT_TABLE )
{
eMode = SC_INPUT_TYPE;
bUsed = TRUE;
}
break;
}
// Cursortasten nur ausfuehren, wenn schon im Edit-Modus
// z.B. wegen Shift-Ctrl-PageDn (ist nicht als Accelerator definiert)
BOOL bCursorKey = EditEngine::DoesKeyMoveCursor(rKEvt);
BOOL bInsKey = ( nCode == KEY_INSERT && !nModi ); // Insert wie Cursortasten behandeln
if ( !bUsed && !bSkip && ( bDoEnter || EditEngine::DoesKeyChangeText(rKEvt) ||
( eMode != SC_INPUT_NONE && ( bCursorKey || bInsKey ) ) ) )
{
HideTip();
if (bSelIsRef)
{
RemoveSelection();
bSelIsRef = FALSE;
}
UpdateActiveView();
BOOL bNewView = DataChanging( nChar );
if (bProtected) // Zelle geschuetzt?
bUsed = TRUE; // Key-Event nicht weiterleiten
else // Aenderungen erlaubt
{
if (bNewView ) // neu anlegen
{
if (pActiveViewSh)
pActiveViewSh->GetViewData()->GetDocShell()->PostEditView( pEngine, aCursorPos );
UpdateActiveView();
if (eMode==SC_INPUT_NONE)
if (pTableView || pTopView)
{
String aStrLoP;
if ( bStartEdit && bCellHasPercentFormat && ((nChar >= '0' && nChar <= '9') || nChar == '-') )
aStrLoP = '%';
if (pTableView)
{
pTableView->GetEditEngine()->SetText( aStrLoP );
pTableView->SetSelection( ESelection(0,0, 0,0) );
}
if (pTopView)
{
pTopView->GetEditEngine()->SetText( aStrLoP );
pTopView->SetSelection( ESelection(0,0, 0,0) );
}
}
SyncViews();
}
if (pTableView || pTopView)
{
// pActiveView->SetEditEngineUpdateMode(TRUE); //! gibt Muell !!!!
if (bDoEnter)
{
if (pTableView)
if( pTableView->PostKeyEvent( KeyEvent( CHAR_CR, KeyCode(KEY_RETURN) ) ) )
bUsed = TRUE;
if (pTopView)
if( pTopView->PostKeyEvent( KeyEvent( CHAR_CR, KeyCode(KEY_RETURN) ) ) )
bUsed = TRUE;
}
else if ( nAutoPar && nChar == ')' && CursorAtClosingPar() )
{
SkipClosingPar();
bUsed = TRUE;
}
else
{
if (pTableView)
if ( pTableView->PostKeyEvent( rKEvt ) )
bUsed = TRUE;
if (pTopView)
if ( pTopView->PostKeyEvent( rKEvt ) )
bUsed = TRUE;
}
// Auto-Eingabe:
if ( bUsed && bAutoComplete )
{
bUseTab = FALSE;
nAutoPos = SCPOS_INVALID; // nicht weitersuchen
if ( nChar && nChar != 8 && nChar != 127 ) // nicht BS und Delete
{
if (bFormulaMode)
UseFormulaData();
else
UseColData();
}
}
// when the selection is changed manually or an opening parenthesis
// is typed, stop overwriting parentheses
if ( bUsed && ( nChar == '(' || bCursorKey ) )
ResetAutoPar();
if ( KEY_INSERT == nCode )
{
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
if (pViewFrm)
pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
}
}
DataChanged(); // ruft auch UpdateParenthesis()
InvalidateAttribs(); //! in DataChanged ?
}
}
if (pTopView && eMode != SC_INPUT_NONE)
SyncViews();
return bUsed;
}
BOOL ScInputHandler::InputCommand( const CommandEvent& rCEvt, BOOL bForce )
{
BOOL bUsed = FALSE;
if ( rCEvt.GetCommand() == COMMAND_CURSORPOS )
{
// #90346# for COMMAND_CURSORPOS, do as little as possible, because
// with remote VCL, even a ShowCursor will generate another event.
if ( eMode != SC_INPUT_NONE )
{
UpdateActiveView();
if (pTableView || pTopView)
{
if (pTableView)
pTableView->Command( rCEvt );
else if (pTopView) // call only once
pTopView->Command( rCEvt );
bUsed = TRUE;
}
}
}
else
{
if ( bForce || eMode != SC_INPUT_NONE )
{
if (!bOptLoaded)
{
bAutoComplete = SC_MOD()->GetAppOptions().GetAutoComplete();
bOptLoaded = TRUE;
}
HideTip();
if ( bSelIsRef )
{
RemoveSelection();
bSelIsRef = FALSE;
}
UpdateActiveView();
BOOL bNewView = DataChanging( 0, TRUE );
if (bProtected) // cell protected
bUsed = TRUE; // event is used
else // changes allowed
{
if (bNewView) // create new edit view
{
if (pActiveViewSh)
pActiveViewSh->GetViewData()->GetDocShell()->PostEditView( pEngine, aCursorPos );
UpdateActiveView();
if (eMode==SC_INPUT_NONE)
if (pTableView || pTopView)
{
String aStrLoP;
if (pTableView)
{
pTableView->GetEditEngine()->SetText( aStrLoP );
pTableView->SetSelection( ESelection(0,0, 0,0) );
}
if (pTopView)
{
pTopView->GetEditEngine()->SetText( aStrLoP );
pTopView->SetSelection( ESelection(0,0, 0,0) );
}
}
SyncViews();
}
if (pTableView || pTopView)
{
if (pTableView)
pTableView->Command( rCEvt );
if (pTopView)
pTopView->Command( rCEvt );
bUsed = TRUE;
if ( rCEvt.GetCommand() == COMMAND_ENDEXTTEXTINPUT )
{
// AutoInput after ext text input
nAutoPos = SCPOS_INVALID;
if (bFormulaMode)
UseFormulaData();
else
UseColData();
}
}
DataChanged(); // calls UpdateParenthesis()
InvalidateAttribs(); //! in DataChanged ?
}
}
if (pTopView && eMode != SC_INPUT_NONE)
SyncViews();
}
return bUsed;
}
void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
BOOL bForce, ScTabViewShell* pSourceSh,
BOOL bStopEditing)
{
// #62806# Wenn der Aufruf aus einem Makro-Aufruf im EnterHandler kommt,
// gleich abbrechen und nicht den Status durcheinander bringen
if (bInEnterHandler)
return;
BOOL bRepeat = (pState == pLastState);
if (!bRepeat && pState && pLastState)
bRepeat = (*pState == *pLastState);
if (bRepeat && !bForce)
return;
bInOwnChange = TRUE; // disable ModifyHdl (reset below)
if ( pState && !pLastState ) // wieder enablen
bForce = TRUE;
BOOL bHadObject = pLastState && pLastState->GetEditData();
//! Before EditEngine gets eventually created (so it gets the right pools)
if ( pSourceSh )
pActiveViewSh = pSourceSh;
else
pActiveViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
ImplCreateEditEngine();
if ( pState != pLastState )
{
delete pLastState;
pLastState = pState ? new ScInputHdlState( *pState ) : NULL;
}
if ( pState && pActiveViewSh )
{
ScModule* pScMod = SC_MOD();
if ( pState )
{
BOOL bIgnore = FALSE;
// hier auch fremde Referenzeingabe beruecksichtigen (z.B. Funktions-AP),
// FormEditData falls gerade von der Hilfe auf Calc umgeschaltet wird:
if ( !bFormulaMode && !pScMod->IsFormulaMode() && !pScMod->GetFormEditData() )
{
if ( bModified )
{
if (pState->GetPos() != aCursorPos)
{
if (!bProtected)
EnterHandler();
}
else
bIgnore = TRUE;
}
if ( !bIgnore /* || bRepeat */ )
{
const ScAddress& rSPos = pState->GetStartPos();
const ScAddress& rEPos = pState->GetEndPos();
const EditTextObject* pData = pState->GetEditData();
String aString = pState->GetString();
BOOL bTxtMod = FALSE;
aCursorPos = pState->GetPos();
if ( pData /* || bRepeat */ )
bTxtMod = TRUE;
else if ( bHadObject )
bTxtMod = TRUE;
else if ( bTextValid )
bTxtMod = ( aString != aCurrentText );
else
bTxtMod = ( aString != GetEditText(pEngine) );
if ( bTxtMod || bForce )
{
if (pData)
{
pEngine->SetText( *pData );
aString = GetEditText(pEngine);
lcl_RemoveTabs(aString);
bTextValid = FALSE;
aCurrentText.Erase();
}
else
{
aCurrentText = aString;
bTextValid = TRUE; //! erst nur als String merken
}
if ( pInputWin )
pInputWin->SetTextString(aString);
}
if ( pInputWin ) // Bereichsanzeige
{
String aPosStr;
// Ist der Bereich ein Name?
//! per Timer suchen ???
if ( pActiveViewSh )
pActiveViewSh->GetViewData()->GetDocument()->
GetRangeAtBlock( ScRange( rSPos, rEPos ), &aPosStr );
if ( !aPosStr.Len() ) // kein Name -> formatieren
{
if ( rSPos != rEPos )
{
String aStr;
rSPos.Format( aPosStr, SCA_VALID );
aPosStr += ':';
rEPos.Format( aStr, SCA_VALID );
aPosStr += aStr;
}
else
aCursorPos.Format( aPosStr, SCA_VALID );
}
pInputWin->SetPosString(aPosStr);
pInputWin->SetSumAssignMode();
}
if (bStopEditing)
SFX_APP()->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
// As long as the content is not edited, turn off online spelling.
// Online spelling is turned back on in StartTable, after setting
// the right language from cell attributes.
ULONG nCntrl = pEngine->GetControlWord();
if ( nCntrl & EE_CNTRL_ONLINESPELLING )
pEngine->SetControlWord( nCntrl & ~EE_CNTRL_ONLINESPELLING );
bModified = FALSE;
bSelIsRef = FALSE;
bProtected = FALSE;
bCommandErrorShown = FALSE;
}
}
}
// bProtected = FALSE;
if ( pInputWin)
{
if(!pScMod->IsFormulaMode()&& !pScMod->IsRefDialogOpen()) //BugID 54702
{ //Wenn RefDialog offen, dann nicht enablen
if ( !pInputWin->IsEnabled())
{
pInputWin->Enable();
if(pDelayTimer )
{
DELETEZ( pDelayTimer );
}
}
}
else if(pScMod->IsRefDialogOpen())
{ // Da jedes Dokument eigenes InputWin hat, sollte
if ( !pDelayTimer ) // nochmals Timer gestartet werden, da sonst Ein-
{ // gabezeile evt. noch aktiv ist.
pDelayTimer = new Timer;
pDelayTimer->SetTimeout( 500 ); // 100ms Verzoegerung
pDelayTimer->SetTimeoutHdl( LINK( this, ScInputHandler, DelayTimer ) );
pDelayTimer->Start();
}
}
}
}
else // !pState || !pActiveViewSh
{
if ( !pDelayTimer )
{
pDelayTimer = new Timer;
pDelayTimer->SetTimeout( 500 ); // 100ms Verzoegerung
pDelayTimer->SetTimeoutHdl( LINK( this, ScInputHandler, DelayTimer ) );
pDelayTimer->Start();
}
}
HideTip();
bInOwnChange = FALSE;
}
void ScInputHandler::ResetDelayTimer()
{
if(pDelayTimer!=NULL)
{
DELETEZ( pDelayTimer );
if ( pInputWin)
{
pInputWin->Enable();
}
}
}
IMPL_LINK( ScInputHandler, DelayTimer, Timer*, pTimer )
{
if ( pTimer == pDelayTimer )
{
DELETEZ( pDelayTimer );
if ( NULL == pLastState || SC_MOD()->IsFormulaMode() || SC_MOD()->IsRefDialogOpen())
{
//! new method at ScModule to query if function autopilot is open
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
if ( pViewFrm && pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) )
{
if ( pInputWin)
{
pInputWin->EnableButtons( FALSE );
pInputWin->Disable();
}
}
else if ( !bFormulaMode ) // #39210# Formel auch z.B. bei Hilfe behalten
{
bInOwnChange = TRUE; // disable ModifyHdl (reset below)
pActiveViewSh = NULL;
pEngine->SetText( EMPTY_STRING );
if ( pInputWin )
{
pInputWin->SetPosString( EMPTY_STRING );
pInputWin->SetTextString( EMPTY_STRING );
pInputWin->Disable();
}
bInOwnChange = FALSE;
}
}
}
return 0;
}
void ScInputHandler::InputSelection( EditView* pView )
{
SyncViews( pView );
UpdateParenthesis(); // Selektion geaendert -> Klammer-Hervorhebung neu
// when the selection is changed manually, stop overwriting parentheses
ResetAutoPar();
}
void ScInputHandler::InputChanged( EditView* pView )
{
ESelection aSelection = pView->GetSelection();
UpdateActiveView();
BOOL bNewView = DataChanging(); //! kann das hier ueberhaupt sein?
aCurrentText = pView->GetEditEngine()->GetText(); // auch den String merken
pEngine->SetText( aCurrentText );
DataChanged();
bTextValid = TRUE; // wird in DataChanged auf FALSE gesetzt
if ( pActiveViewSh )
{
ScViewData* pViewData = pActiveViewSh->GetViewData();
if ( bNewView )
pViewData->GetDocShell()->PostEditView( pEngine, aCursorPos );
pViewData->EditGrowY();
pViewData->EditGrowX();
}
SyncViews( pView );
}
const String& ScInputHandler::GetEditString()
{
if (pEngine)
{
aCurrentText = pEngine->GetText(); // immer neu aus Engine
bTextValid = TRUE;
}
return aCurrentText;
}
Size ScInputHandler::GetTextSize()
{
Size aSize;
if ( pEngine )
aSize = Size( pEngine->CalcTextWidth(), pEngine->GetTextHeight() );
return aSize;
}
BOOL ScInputHandler::GetTextAndFields( ScEditEngineDefaulter& rDestEngine )
{
BOOL bRet = FALSE;
if (pEngine)
{
// Feldbefehle enthalten?
USHORT nParCnt = pEngine->GetParagraphCount();
SfxItemSet aSet = pEngine->GetAttribs( ESelection(0,0,nParCnt,0) );
SfxItemState eFieldState = aSet.GetItemState( EE_FEATURE_FIELD, FALSE );
if ( eFieldState == SFX_ITEM_DONTCARE || eFieldState == SFX_ITEM_SET )
{
// Inhalt kopieren
EditTextObject* pObj = pEngine->CreateTextObject();
rDestEngine.SetText(*pObj);
delete pObj;
// Attribute loeschen
for (USHORT i=0; i<nParCnt; i++)
rDestEngine.QuickRemoveCharAttribs( i );
// Absaetze zusammenfassen
while ( nParCnt > 1 )
{
xub_StrLen nLen = rDestEngine.GetTextLen( (USHORT)0 );
ESelection aSel( 0,nLen, 1,0 );
rDestEngine.QuickInsertText( ' ', aSel ); // Umbruch durch Space ersetzen
--nParCnt;
}
bRet = TRUE;
}
}
return bRet;
}
//------------------------------------------------------------------------
// Methoden fuer FunktionsAutopiloten:
// InputGetSelection, InputSetSelection, InputReplaceSelection, InputGetFormulaStr
//------------------------------------------------------------------------
void ScInputHandler::InputGetSelection( xub_StrLen& rStart, xub_StrLen& rEnd )
{
rStart = nFormSelStart;
rEnd = nFormSelEnd;
}
//------------------------------------------------------------------------
EditView* ScInputHandler::GetFuncEditView()
{
UpdateActiveView(); // wegen pTableView
EditView* pView = NULL;
if ( pInputWin )
{
pInputWin->MakeDialogEditView();
pView = pInputWin->GetEditView();
}
else
{
if ( eMode != SC_INPUT_TABLE )
{
bCreatingFuncView = TRUE; // RangeFinder nicht anzeigen
SetMode( SC_INPUT_TABLE );
bCreatingFuncView = FALSE;
if ( pTableView )
pTableView->GetEditEngine()->SetText( EMPTY_STRING );
}
pView = pTableView;
}
return pView;
}
//------------------------------------------------------------------------
void ScInputHandler::InputSetSelection( xub_StrLen nStart, xub_StrLen nEnd )
{
if ( nStart <= nEnd )
{
nFormSelStart = nStart;
nFormSelEnd = nEnd;
}
else
{
nFormSelEnd = nStart;
nFormSelStart = nEnd;
}
EditView* pView = GetFuncEditView();
if (pView)
pView->SetSelection( ESelection(0,nStart, 0,nEnd) );
bModified = TRUE;
}
//------------------------------------------------------------------------
void ScInputHandler::InputReplaceSelection( const String& rStr )
{
if (!pRefViewSh)
pRefViewSh = pActiveViewSh;
DBG_ASSERT(nFormSelEnd>=nFormSelStart,"Selektion kaputt...");
xub_StrLen nOldLen = nFormSelEnd-nFormSelStart;
xub_StrLen nNewLen = rStr.Len();
if (nOldLen)
aFormText.Erase( nFormSelStart, nOldLen );
if (nNewLen)
aFormText.Insert( rStr, nFormSelStart );
nFormSelEnd = nFormSelStart + nNewLen;
EditView* pView = GetFuncEditView();
if (pView)
{
pView->SetEditEngineUpdateMode( FALSE );
// pView->InsertText( rStr, TRUE );
pView->GetEditEngine()->SetText( aFormText );
pView->SetSelection( ESelection(0,nFormSelStart, 0,nFormSelEnd) );
pView->SetEditEngineUpdateMode( TRUE );
}
bModified = TRUE;
}
//------------------------------------------------------------------------
String ScInputHandler::InputGetFormulaStr()
{
return aFormText; //! eigene Membervariable?
}
//========================================================================
// ScInputHdlState
//========================================================================
ScInputHdlState::ScInputHdlState( const ScAddress& rCurPos,
const ScAddress& rStartPos,
const ScAddress& rEndPos,
const String& rString,
const EditTextObject* pData )
: aCursorPos ( rCurPos ),
aStartPos ( rStartPos ),
aEndPos ( rEndPos ),
aString ( rString ),
pEditData ( pData ? pData->Clone() : NULL )
{
}
//------------------------------------------------------------------------
ScInputHdlState::ScInputHdlState( const ScInputHdlState& rCpy )
: pEditData ( NULL )
{
*this = rCpy;
}
//------------------------------------------------------------------------
ScInputHdlState::~ScInputHdlState()
{
delete pEditData;
}
//------------------------------------------------------------------------
int ScInputHdlState::operator==( const ScInputHdlState& r ) const
{
return ( (aStartPos == r.aStartPos)
&& (aEndPos == r.aEndPos)
&& (aCursorPos == r.aCursorPos)
&& (aString == r.aString)
&& ScGlobal::EETextObjEqual( pEditData, r.pEditData ) );
}
//------------------------------------------------------------------------
ScInputHdlState& ScInputHdlState::operator=( const ScInputHdlState& r )
{
delete pEditData;
aCursorPos = r.aCursorPos;
aStartPos = r.aStartPos;
aEndPos = r.aEndPos;
aString = r.aString;
pEditData = r.pEditData ? r.pEditData->Clone() : NULL;
return *this;
}
|