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
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <rangelst.hxx>
#include "scitems.hxx"
#include <editeng/eeitem.hxx>
#include <editeng/brshitem.hxx>
#include <editeng/editview.hxx>
#include <svx/fmshell.hxx>
#include <svx/svdoole2.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/viewfrm.hxx>
#include <vcl/cursor.hxx>
#include "tabview.hxx"
#include "tabvwsh.hxx"
#include "docsh.hxx"
#include "gridwin.hxx"
#include "olinewin.hxx"
#include "colrowba.hxx"
#include "tabcont.hxx"
#include "scmod.hxx"
#include "uiitems.hxx"
#include "sc.hrc"
#include "viewutil.hxx"
#include "editutil.hxx"
#include "inputhdl.hxx"
#include "inputwin.hxx"
#include "validat.hxx"
#include "hintwin.hxx"
#include "inputopt.hxx"
#include "rfindlst.hxx"
#include "hiranges.hxx"
#include "viewuno.hxx"
#include "chartarr.hxx"
#include "anyrefdg.hxx"
#include "dpobject.hxx"
#include "patattr.hxx"
#include "dociter.hxx"
#include "seltrans.hxx"
#include "fillinfo.hxx"
#include "AccessibilityHints.hxx"
#include "rangeutl.hxx"
#include "client.hxx"
#include "tabprotection.hxx"
#include "markdata.hxx"
#include "formula/FormulaCompiler.hxx"
#include <com/sun/star/chart2/data/HighlightedRange.hpp>
namespace
{
ScRange lcl_getSubRangeByIndex( const ScRange& rRange, sal_Int32 nIndex )
{
ScAddress aResult( rRange.aStart );
SCCOL nWidth = rRange.aEnd.Col() - rRange.aStart.Col() + 1;
SCROW nHeight = rRange.aEnd.Row() - rRange.aStart.Row() + 1;
SCTAB nDepth = rRange.aEnd.Tab() - rRange.aStart.Tab() + 1;
if( (nWidth > 0) && (nHeight > 0) && (nDepth > 0) )
{
// row by row from first to last sheet
sal_Int32 nArea = nWidth * nHeight;
aResult.IncCol( static_cast< SCsCOL >( nIndex % nWidth ) );
aResult.IncRow( static_cast< SCsROW >( (nIndex % nArea) / nWidth ) );
aResult.IncTab( static_cast< SCsTAB >( nIndex / nArea ) );
if( !rRange.In( aResult ) )
aResult = rRange.aStart;
}
return ScRange( aResult );
}
} // anonymous namespace
using namespace com::sun::star;
// -----------------------------------------------------------------------
//
// --- Public-Funktionen
//
void ScTabView::ClickCursor( SCCOL nPosX, SCROW nPosY, bool bControl )
{
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
pDoc->SkipOverlapped(nPosX, nPosY, nTab);
bool bRefMode = SC_MOD()->IsFormulaMode();
if ( bRefMode )
{
DoneRefMode( false );
if (bControl)
SC_MOD()->AddRefEntry();
InitRefMode( nPosX, nPosY, nTab, SC_REFTYPE_REF );
}
else
{
DoneBlockMode( bControl );
aViewData.ResetOldCursor();
SetCursor( (SCCOL) nPosX, (SCROW) nPosY );
}
}
void ScTabView::UpdateAutoFillMark()
{
// single selection or cursor
ScRange aMarkRange;
bool bMarked = (aViewData.GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE);
sal_uInt16 i;
for (i=0; i<4; i++)
if (pGridWin[i] && pGridWin[i]->IsVisible())
pGridWin[i]->UpdateAutoFillMark( bMarked, aMarkRange );
for (i=0; i<2; i++)
{
if (pColBar[i] && pColBar[i]->IsVisible())
pColBar[i]->SetMark( bMarked, aMarkRange.aStart.Col(), aMarkRange.aEnd.Col() );
if (pRowBar[i] && pRowBar[i]->IsVisible())
pRowBar[i]->SetMark( bMarked, aMarkRange.aStart.Row(), aMarkRange.aEnd.Row() );
}
// selection transfer object is checked together with AutoFill marks,
// because it has the same requirement of a single continuous block.
CheckSelectionTransfer(); // update selection transfer object
}
void ScTabView::FakeButtonUp( ScSplitPos eWhich )
{
if (pGridWin[eWhich])
pGridWin[eWhich]->FakeButtonUp();
}
void ScTabView::HideAllCursors()
{
for (sal_uInt16 i=0; i<4; i++)
if (pGridWin[i])
if (pGridWin[i]->IsVisible())
{
Cursor* pCur = pGridWin[i]->GetCursor();
if (pCur)
if (pCur->IsVisible())
pCur->Hide();
pGridWin[i]->HideCursor();
}
}
void ScTabView::ShowAllCursors()
{
for (sal_uInt16 i=0; i<4; i++)
if (pGridWin[i])
if (pGridWin[i]->IsVisible())
{
pGridWin[i]->ShowCursor();
// #114409#
pGridWin[i]->CursorChanged();
}
}
void ScTabView::ShowCursor()
{
pGridWin[aViewData.GetActivePart()]->ShowCursor();
// #114409#
pGridWin[aViewData.GetActivePart()]->CursorChanged();
}
void ScTabView::InvalidateAttribs()
{
SfxBindings& rBindings = aViewData.GetBindings();
rBindings.Invalidate( SID_STYLE_APPLY );
rBindings.Invalidate( SID_STYLE_FAMILY2 );
// StarCalc kennt nur Absatz- bzw. Zellformat-Vorlagen
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_ATTR_CHAR_OVERLINE );
rBindings.Invalidate( SID_ALIGNLEFT );
rBindings.Invalidate( SID_ALIGNRIGHT );
rBindings.Invalidate( SID_ALIGNBLOCK );
rBindings.Invalidate( SID_ALIGNCENTERHOR );
rBindings.Invalidate( SID_ALIGNTOP );
rBindings.Invalidate( SID_ALIGNBOTTOM );
rBindings.Invalidate( SID_ALIGNCENTERVER );
rBindings.Invalidate( SID_BACKGROUND_COLOR );
rBindings.Invalidate( SID_ATTR_ALIGN_LINEBREAK );
rBindings.Invalidate( SID_NUMBER_FORMAT );
rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
// pseudo slots for Format menu
rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
rBindings.Invalidate( SID_ALIGN_ANY_TOP );
rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
rBindings.Invalidate( SID_NUMBER_CURRENCY );
rBindings.Invalidate( SID_NUMBER_SCIENTIFIC );
rBindings.Invalidate( SID_NUMBER_DATE );
rBindings.Invalidate( SID_NUMBER_CURRENCY );
rBindings.Invalidate( SID_NUMBER_PERCENT );
rBindings.Invalidate( SID_NUMBER_TIME );
}
// SetCursor - Cursor setzen, zeichnen, InputWin updaten
// oder Referenz verschicken
// ohne Optimierung wegen BugId 29307
#ifdef _MSC_VER
#pragma optimize ( "", off )
#endif
void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
{
SCCOL nOldX = aViewData.GetCurX();
SCROW nOldY = aViewData.GetCurY();
// DeactivateIP nur noch bei MarkListHasChanged
if ( nPosX != nOldX || nPosY != nOldY || bNew )
{
ScTabViewShell* pViewShell = aViewData.GetViewShell();
bool bRefMode = ( pViewShell ? pViewShell->IsRefInputMode() : false );
if ( aViewData.HasEditView( aViewData.GetActivePart() ) && !bRefMode ) // 23259 oder so
{
UpdateInputLine();
}
HideAllCursors();
aViewData.SetCurX( nPosX );
aViewData.SetCurY( nPosY );
ShowAllCursors();
CursorPosChanged();
}
}
#ifdef _MSC_VER
#pragma optimize ( "", on )
#endif
void ScTabView::CheckSelectionTransfer()
{
if ( aViewData.IsActive() ) // only for active view
{
ScModule* pScMod = SC_MOD();
ScSelectionTransferObj* pOld = pScMod->GetSelectionTransfer();
if ( pOld && pOld->GetView() == this && pOld->StillValid() )
{
// selection not changed - nothing to do
}
else
{
ScSelectionTransferObj* pNew = ScSelectionTransferObj::CreateFromView( this );
if ( pNew )
{
// create new selection
if (pOld)
pOld->ForgetView();
uno::Reference<datatransfer::XTransferable> xRef( pNew );
pScMod->SetSelectionTransfer( pNew );
pNew->CopyToSelection( GetActiveWin() ); // may delete pOld
}
else if ( pOld && pOld->GetView() == this )
{
// remove own selection
pOld->ForgetView();
pScMod->SetSelectionTransfer( NULL );
TransferableHelper::ClearSelection( GetActiveWin() ); // may delete pOld
}
// else: selection from outside: leave unchanged
}
}
}
// Eingabezeile / Menues updaten
// CursorPosChanged ruft SelectionChanged
// SelectionChanged ruft CellContentChanged
void ScTabView::CellContentChanged()
{
SfxBindings& rBindings = aViewData.GetBindings();
rBindings.Invalidate( SID_ATTR_SIZE ); // -> Fehlermeldungen anzeigen
rBindings.Invalidate( SID_THESAURUS );
rBindings.Invalidate( SID_HYPERLINK_GETLINK );
InvalidateAttribs(); // Attribut-Updates
aViewData.GetViewShell()->UpdateInputHandler();
}
void ScTabView::SelectionChanged()
{
SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
if (pViewFrame)
{
uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
if (xController.is())
{
ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
if (pImp)
pImp->SelectionChanged();
}
}
UpdateAutoFillMark(); // also calls CheckSelectionTransfer
SfxBindings& rBindings = aViewData.GetBindings();
rBindings.Invalidate( SID_CURRENTCELL ); // -> Navigator
rBindings.Invalidate( SID_AUTO_FILTER ); // -> Menue
rBindings.Invalidate( FID_NOTE_VISIBLE );
rBindings.Invalidate( SID_DELETE_NOTE );
// Funktionen, die evtl disabled werden muessen
rBindings.Invalidate( FID_INS_ROWBRK );
rBindings.Invalidate( FID_INS_COLBRK );
rBindings.Invalidate( FID_DEL_ROWBRK );
rBindings.Invalidate( FID_DEL_COLBRK );
rBindings.Invalidate( FID_MERGE_ON );
rBindings.Invalidate( FID_MERGE_OFF );
rBindings.Invalidate( FID_MERGE_TOGGLE );
rBindings.Invalidate( SID_AUTOFILTER_HIDE );
rBindings.Invalidate( SID_UNFILTER );
rBindings.Invalidate( SID_REIMPORT_DATA );
rBindings.Invalidate( SID_REFRESH_DBAREA );
rBindings.Invalidate( SID_OUTLINE_SHOW );
rBindings.Invalidate( SID_OUTLINE_HIDE );
rBindings.Invalidate( SID_OUTLINE_REMOVE );
rBindings.Invalidate( FID_FILL_TO_BOTTOM );
rBindings.Invalidate( FID_FILL_TO_RIGHT );
rBindings.Invalidate( FID_FILL_TO_TOP );
rBindings.Invalidate( FID_FILL_TO_LEFT );
rBindings.Invalidate( FID_FILL_SERIES );
rBindings.Invalidate( SID_SCENARIOS );
rBindings.Invalidate( SID_AUTOFORMAT );
rBindings.Invalidate( SID_OPENDLG_TABOP );
rBindings.Invalidate( SID_DATA_SELECT );
rBindings.Invalidate( SID_CUT );
rBindings.Invalidate( SID_COPY );
rBindings.Invalidate( SID_PASTE );
rBindings.Invalidate( SID_PASTE_SPECIAL );
rBindings.Invalidate( FID_INS_ROW );
rBindings.Invalidate( FID_INS_COLUMN );
rBindings.Invalidate( FID_INS_CELL );
rBindings.Invalidate( FID_INS_CELLSDOWN );
rBindings.Invalidate( FID_INS_CELLSRIGHT );
rBindings.Invalidate( FID_CHG_COMMENT );
// nur wegen Zellschutz:
rBindings.Invalidate( SID_CELL_FORMAT_RESET );
rBindings.Invalidate( SID_DELETE );
rBindings.Invalidate( SID_DELETE_CONTENTS );
rBindings.Invalidate( FID_DELETE_CELL );
rBindings.Invalidate( FID_CELL_FORMAT );
rBindings.Invalidate( SID_ENABLE_HYPHENATION );
rBindings.Invalidate( SID_INSERT_POSTIT );
rBindings.Invalidate( SID_CHARMAP );
rBindings.Invalidate( SID_OPENDLG_FUNCTION );
rBindings.Invalidate( FID_VALIDATION );
rBindings.Invalidate( SID_EXTERNAL_SOURCE );
rBindings.Invalidate( SID_TEXT_TO_COLUMNS );
rBindings.Invalidate( SID_SORT_ASCENDING );
rBindings.Invalidate( SID_SORT_DESCENDING );
if (aViewData.GetViewShell()->HasAccessibilityObjects())
aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_CURSORCHANGED));
CellContentChanged();
}
void ScTabView::CursorPosChanged()
{
bool bRefMode = SC_MOD()->IsFormulaMode();
if ( !bRefMode ) // Abfrage, damit RefMode bei Tabellenwechsel funktioniert
aViewData.GetDocShell()->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
// Broadcast, damit andere Views des Dokuments auch umschalten
ScDocument* pDoc = aViewData.GetDocument();
bool bDP = NULL != pDoc->GetDPAtCursor(
aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
aViewData.GetViewShell()->SetPivotShell(bDP);
// UpdateInputHandler jetzt in CellContentChanged
SelectionChanged();
aViewData.SetTabStartCol( SC_TABSTART_NONE );
}
namespace {
Point calcHintWindowPosition(
const Point& rCellPos, const Size& rCellSize, const Size& rFrameWndSize, const Size& rHintWndSize)
{
const long nMargin = 20;
long nMLeft = rCellPos.X();
long nMRight = rFrameWndSize.Width() - rCellPos.X() - rCellSize.Width();
long nMTop = rCellPos.Y();
long nMBottom = rFrameWndSize.Height() - rCellPos.Y() - rCellSize.Height();
// First, see if we can fit the entire hint window in the visible region.
if (nMRight - nMargin >= rHintWndSize.Width())
{
// Right margin is wide enough.
if (rFrameWndSize.Height() >= rHintWndSize.Height())
{
// The frame has enough height. Take it.
Point aPos = rCellPos;
aPos.X() += rCellSize.Width() + nMargin;
if (aPos.Y() + rHintWndSize.Height() > rFrameWndSize.Height())
{
// Push the hint window up a bit to make it fit.
aPos.Y() = rFrameWndSize.Height() - rHintWndSize.Height();
}
return aPos;
}
}
if (nMBottom - nMargin >= rHintWndSize.Height())
{
// Bottom margin is high enough.
if (rFrameWndSize.Width() >= rHintWndSize.Width())
{
// The frame has enough width. Take it.
Point aPos = rCellPos;
aPos.Y() += rCellSize.Height() + nMargin;
if (aPos.X() + rHintWndSize.Width() > rFrameWndSize.Width())
{
// Move the hint window to the left to make it fit.
aPos.X() = rFrameWndSize.Width() - rHintWndSize.Width();
}
return aPos;
}
}
if (nMLeft - nMargin >= rHintWndSize.Width())
{
// Left margin is wide enough.
if (rFrameWndSize.Height() >= rHintWndSize.Height())
{
// The frame is high enough. Take it.
Point aPos = rCellPos;
aPos.X() -= rHintWndSize.Width() + nMargin;
if (aPos.Y() + rHintWndSize.Height() > rFrameWndSize.Height())
{
// Push the hint window up a bit to make it fit.
aPos.Y() = rFrameWndSize.Height() - rHintWndSize.Height();
}
return aPos;
}
}
if (nMTop - nMargin >= rHintWndSize.Height())
{
// Top margin is high enough.
if (rFrameWndSize.Width() >= rHintWndSize.Width())
{
// The frame is wide enough. Take it.
Point aPos = rCellPos;
aPos.Y() -= rHintWndSize.Height() + nMargin;
if (aPos.X() + rHintWndSize.Width() > rFrameWndSize.Width())
{
// Move the hint window to the left to make it fit.
aPos.X() = rFrameWndSize.Width() - rHintWndSize.Width();
}
return aPos;
}
}
// The popup doesn't fit in any direction in its entirety. Do our best.
if (nMRight - nMargin >= rHintWndSize.Width())
{
// Right margin is good enough.
Point aPos = rCellPos;
aPos.X() += nMargin + rCellSize.Width();
aPos.Y() = 0;
return aPos;
}
if (nMBottom - nMargin >= rHintWndSize.Height())
{
// Bottom margin is good enough.
Point aPos = rCellPos;
aPos.Y() += nMargin + rCellSize.Height();
aPos.X() = 0;
return aPos;
}
if (nMLeft - nMargin >= rHintWndSize.Width())
{
// Left margin is good enough.
Point aPos = rCellPos;
aPos.X() -= rHintWndSize.Width() + nMargin;
aPos.Y() = 0;
return aPos;
}
if (nMTop - nMargin >= rHintWndSize.Height())
{
// Top margin is good enough.
Point aPos = rCellPos;
aPos.Y() -= rHintWndSize.Height() + nMargin;
aPos.X() = 0;
return aPos;
}
// None of the above. Hopeless. At least try not to cover the current
// cell.
Point aPos = rCellPos;
aPos.X() += rCellSize.Width();
return aPos;
}
}
void ScTabView::TestHintWindow()
{
// show input help window and list drop-down button for validity
bool bListValButton = false;
ScAddress aListValPos;
ScDocument* pDoc = aViewData.GetDocument();
const SfxUInt32Item* pItem = (const SfxUInt32Item*)
pDoc->GetAttr( aViewData.GetCurX(),
aViewData.GetCurY(),
aViewData.GetTabNo(),
ATTR_VALIDDATA );
if ( pItem->GetValue() )
{
const ScValidationData* pData = pDoc->GetValidationEntry( pItem->GetValue() );
OSL_ENSURE(pData,"ValidationData nicht gefunden");
String aTitle, aMessage;
if ( pData && pData->GetInput( aTitle, aMessage ) && aMessage.Len() > 0 )
{
//! Abfrage, ob an gleicher Stelle !!!!
mpInputHintWindow.reset();
ScSplitPos eWhich = aViewData.GetActivePart();
ScGridWindow* pWin = pGridWin[eWhich];
SCCOL nCol = aViewData.GetCurX();
SCROW nRow = aViewData.GetCurY();
Point aPos = aViewData.GetScrPos( nCol, nRow, eWhich );
Size aWinSize = pWin->GetOutputSizePixel();
// Cursor sichtbar?
if ( nCol >= aViewData.GetPosX(WhichH(eWhich)) &&
nRow >= aViewData.GetPosY(WhichV(eWhich)) &&
aPos.X() < aWinSize.Width() && aPos.Y() < aWinSize.Height() )
{
// HintWindow anlegen, bestimmt seine Groesse selbst
mpInputHintWindow.reset(new ScHintWindow(pWin, aTitle, aMessage));
Size aHintWndSize = mpInputHintWindow->GetSizePixel();
long nCellSizeX = 0;
long nCellSizeY = 0;
aViewData.GetMergeSizePixel(nCol, nRow, nCellSizeX, nCellSizeY);
Point aHintPos = calcHintWindowPosition(
aPos, Size(nCellSizeX,nCellSizeY), aWinSize, aHintWndSize);
mpInputHintWindow->SetPosPixel( aHintPos );
mpInputHintWindow->ToTop();
mpInputHintWindow->Show();
}
}
else
mpInputHintWindow.reset();
// list drop-down button
if ( pData && pData->HasSelectionList() )
{
aListValPos.Set( aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
bListValButton = true;
}
}
else
mpInputHintWindow.reset();
for ( sal_uInt16 i=0; i<4; i++ )
if ( pGridWin[i] && pGridWin[i]->IsVisible() )
pGridWin[i]->UpdateListValPos( bListValButton, aListValPos );
}
bool ScTabView::HasHintWindow() const
{
return mpInputHintWindow.get() != NULL;
}
void ScTabView::RemoveHintWindow()
{
mpInputHintWindow.reset();
}
// find window that should not be over the cursor
static Window* lcl_GetCareWin(SfxViewFrame* pViewFrm)
{
//! auch Spelling ??? (dann beim Aufruf Membervariable setzen)
// Suchen & Ersetzen
if ( pViewFrm->HasChildWindow(SID_SEARCH_DLG) )
{
SfxChildWindow* pChild = pViewFrm->GetChildWindow(SID_SEARCH_DLG);
if (pChild)
{
Window* pWin = pChild->GetWindow();
if (pWin && pWin->IsVisible())
return pWin;
}
}
// Aenderungen uebernehmen
if ( pViewFrm->HasChildWindow(FID_CHG_ACCEPT) )
{
SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_CHG_ACCEPT);
if (pChild)
{
Window* pWin = pChild->GetWindow();
if (pWin && pWin->IsVisible())
return pWin;
}
}
return NULL;
}
//
// Bildschirm an Cursorposition anpassen
//
void ScTabView::AlignToCursor( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
const ScSplitPos* pWhich )
{
//
// aktiven Teil umschalten jetzt hier
//
ScSplitPos eActive = aViewData.GetActivePart();
ScHSplitPos eActiveX = WhichH(eActive);
ScVSplitPos eActiveY = WhichV(eActive);
bool bHFix = (aViewData.GetHSplitMode() == SC_SPLIT_FIX);
bool bVFix = (aViewData.GetVSplitMode() == SC_SPLIT_FIX);
if (bHFix)
if (eActiveX == SC_SPLIT_LEFT && nCurX >= (SCsCOL)aViewData.GetFixPosX())
{
ActivatePart( (eActiveY==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT );
eActiveX = SC_SPLIT_RIGHT;
}
if (bVFix)
if (eActiveY == SC_SPLIT_TOP && nCurY >= (SCsROW)aViewData.GetFixPosY())
{
ActivatePart( (eActiveX==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT );
eActiveY = SC_SPLIT_BOTTOM;
}
//
// eigentliches Align
//
if ( eMode != SC_FOLLOW_NONE )
{
ScSplitPos eAlign;
if (pWhich)
eAlign = *pWhich;
else
eAlign = aViewData.GetActivePart();
ScHSplitPos eAlignX = WhichH(eAlign);
ScVSplitPos eAlignY = WhichV(eAlign);
SCsCOL nDeltaX = (SCsCOL) aViewData.GetPosX(eAlignX);
SCsROW nDeltaY = (SCsROW) aViewData.GetPosY(eAlignY);
SCsCOL nSizeX = (SCsCOL) aViewData.VisibleCellsX(eAlignX);
SCsROW nSizeY = (SCsROW) aViewData.VisibleCellsY(eAlignY);
long nCellSizeX;
long nCellSizeY;
if ( nCurX >= 0 && nCurY >= 0 )
aViewData.GetMergeSizePixel( (SCCOL)nCurX, (SCROW)nCurY, nCellSizeX, nCellSizeY );
else
nCellSizeX = nCellSizeY = 0;
Size aScrSize = aViewData.GetScrSize();
long nSpaceX = ( aScrSize.Width() - nCellSizeX ) / 2;
long nSpaceY = ( aScrSize.Height() - nCellSizeY ) / 2;
// nSpaceY: desired start position of cell for FOLLOW_JUMP, modified if dialog interferes
bool bForceNew = false; // force new calculation of JUMP position (vertical only)
// VisibleCellsY == CellsAtY( GetPosY( eWhichY ), 1, eWhichY )
//-------------------------------------------------------------------------------
// falls z.B. Suchen-Dialog offen ist, Cursor nicht hinter den Dialog stellen
// wenn moeglich, die Zeile mit dem Cursor oberhalb oder unterhalb des Dialogs
//! nicht, wenn schon komplett sichtbar
if ( eMode == SC_FOLLOW_JUMP )
{
Window* pCare = lcl_GetCareWin( aViewData.GetViewShell()->GetViewFrame() );
if (pCare)
{
bool bLimit = false;
Rectangle aDlgPixel;
Size aWinSize;
Window* pWin = GetActiveWin();
if (pWin)
{
aDlgPixel = pCare->GetWindowExtentsRelative( pWin );
aWinSize = pWin->GetOutputSizePixel();
// ueberdeckt der Dialog das GridWin?
if ( aDlgPixel.Right() >= 0 && aDlgPixel.Left() < aWinSize.Width() )
{
if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX ||
nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY )
bLimit = true; // es wird sowieso gescrollt
else
{
// Cursor ist auf dem Bildschirm
Point aStart = aViewData.GetScrPos( nCurX, nCurY, eAlign );
long nCSX, nCSY;
aViewData.GetMergeSizePixel( nCurX, nCurY, nCSX, nCSY );
Rectangle aCursor( aStart, Size( nCSX, nCSY ) );
if ( aCursor.IsOver( aDlgPixel ) )
bLimit = true; // Zelle vom Dialog ueberdeckt
}
}
}
if (bLimit)
{
bool bBottom = false;
long nTopSpace = aDlgPixel.Top();
long nBotSpace = aWinSize.Height() - aDlgPixel.Bottom();
if ( nBotSpace > 0 && nBotSpace > nTopSpace )
{
long nDlgBot = aDlgPixel.Bottom();
SCsCOL nWPosX;
SCsROW nWPosY;
aViewData.GetPosFromPixel( 0,nDlgBot, eAlign, nWPosX, nWPosY );
++nWPosY; // unter der letzten betroffenen Zelle
SCsROW nDiff = nWPosY - nDeltaY;
if ( nCurY >= nDiff ) // Pos. kann nicht negativ werden
{
nSpaceY = nDlgBot + ( nBotSpace - nCellSizeY ) / 2;
bBottom = true;
bForceNew = true;
}
}
if ( !bBottom && nTopSpace > 0 )
{
nSpaceY = ( nTopSpace - nCellSizeY ) / 2;
bForceNew = true;
}
}
}
}
//-------------------------------------------------------------------------------
SCsCOL nNewDeltaX = nDeltaX;
SCsROW nNewDeltaY = nDeltaY;
bool bDoLine = false;
switch (eMode)
{
case SC_FOLLOW_JUMP:
if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX )
{
nNewDeltaX = nCurX - static_cast<SCsCOL>(aViewData.CellsAtX( nCurX, -1, eAlignX, static_cast<sal_uInt16>(nSpaceX) ));
if (nNewDeltaX < 0) nNewDeltaX = 0;
nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
}
if ( nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY || bForceNew )
{
nNewDeltaY = nCurY - static_cast<SCsROW>(aViewData.CellsAtY( nCurY, -1, eAlignY, static_cast<sal_uInt16>(nSpaceY) ));
if (nNewDeltaY < 0) nNewDeltaY = 0;
nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
}
bDoLine = true;
break;
case SC_FOLLOW_LINE:
bDoLine = true;
break;
case SC_FOLLOW_FIX:
if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX )
{
nNewDeltaX = nDeltaX + nCurX - aViewData.GetCurX();
if (nNewDeltaX < 0) nNewDeltaX = 0;
nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
}
if ( nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY )
{
nNewDeltaY = nDeltaY + nCurY - aViewData.GetCurY();
if (nNewDeltaY < 0) nNewDeltaY = 0;
nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
}
// like old version of SC_FOLLOW_JUMP:
if ( nCurX < nNewDeltaX || nCurX >= nNewDeltaX+nSizeX )
{
nNewDeltaX = nCurX - (nSizeX / 2);
if (nNewDeltaX < 0) nNewDeltaX = 0;
nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
}
if ( nCurY < nNewDeltaY || nCurY >= nNewDeltaY+nSizeY )
{
nNewDeltaY = nCurY - (nSizeY / 2);
if (nNewDeltaY < 0) nNewDeltaY = 0;
nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
}
bDoLine = true;
break;
case SC_FOLLOW_NONE:
break;
default:
OSL_FAIL("Falscher Cursormodus");
break;
}
if (bDoLine)
{
while ( nCurX >= nNewDeltaX+nSizeX )
{
nNewDeltaX = nCurX-nSizeX+1;
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
while ( nNewDeltaX < MAXCOL && !pDoc->GetColWidth( nNewDeltaX, nTab ) )
++nNewDeltaX;
nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
}
while ( nCurY >= nNewDeltaY+nSizeY )
{
nNewDeltaY = nCurY-nSizeY+1;
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
while ( nNewDeltaY < MAXROW && !pDoc->GetRowHeight( nNewDeltaY, nTab ) )
++nNewDeltaY;
nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
}
if ( nCurX < nNewDeltaX ) nNewDeltaX = nCurX;
if ( nCurY < nNewDeltaY ) nNewDeltaY = nCurY;
}
if ( nNewDeltaX != nDeltaX )
nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
if (nNewDeltaX+nSizeX-1 > MAXCOL) nNewDeltaX = MAXCOL-nSizeX+1;
if (nNewDeltaX < 0) nNewDeltaX = 0;
if ( nNewDeltaY != nDeltaY )
nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
if (nNewDeltaY+nSizeY-1 > MAXROW) nNewDeltaY = MAXROW-nSizeY+1;
if (nNewDeltaY < 0) nNewDeltaY = 0;
if ( nNewDeltaX != nDeltaX ) ScrollX( nNewDeltaX - nDeltaX, eAlignX );
if ( nNewDeltaY != nDeltaY ) ScrollY( nNewDeltaY - nDeltaY, eAlignY );
}
//
// nochmal aktiven Teil umschalten
//
if (bHFix)
if (eActiveX == SC_SPLIT_RIGHT && nCurX < (SCsCOL)aViewData.GetFixPosX())
{
ActivatePart( (eActiveY==SC_SPLIT_TOP) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT );
eActiveX = SC_SPLIT_LEFT;
}
if (bVFix)
if (eActiveY == SC_SPLIT_BOTTOM && nCurY < (SCsROW)aViewData.GetFixPosY())
{
ActivatePart( (eActiveX==SC_SPLIT_LEFT) ? SC_SPLIT_TOPLEFT : SC_SPLIT_TOPRIGHT );
eActiveY = SC_SPLIT_TOP;
}
}
bool ScTabView::SelMouseButtonDown( const MouseEvent& rMEvt )
{
bool bRet = false;
// #i3875# *Hack*
bool bMod1Locked = aViewData.GetViewShell()->GetLockedModifiers() & KEY_MOD1 ? true : false;
aViewData.SetSelCtrlMouseClick( rMEvt.IsMod1() || bMod1Locked );
if ( pSelEngine )
{
bMoveIsShift = rMEvt.IsShift();
bRet = pSelEngine->SelMouseButtonDown( rMEvt );
bMoveIsShift = false;
}
aViewData.SetSelCtrlMouseClick( false ); // #i3875# *Hack*
return bRet;
}
//
// MoveCursor - mit Anpassung des Bildausschnitts
//
void ScTabView::MoveCursorAbs( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
bool bShift, bool bControl, bool bKeepOld, bool bKeepSel )
{
if (!bKeepOld)
aViewData.ResetOldCursor();
if (nCurX < 0) nCurX = 0;
if (nCurY < 0) nCurY = 0;
if (nCurX > MAXCOL) nCurX = MAXCOL;
if (nCurY > MAXROW) nCurY = MAXROW;
HideAllCursors();
// aktiven Teil umschalten jetzt in AlignToCursor
AlignToCursor( nCurX, nCurY, eMode );
//! auf OS/2: SC_FOLLOW_JUMP statt SC_FOLLOW_LINE, um Nachlaufen zu verhindern ???
if (bKeepSel)
{
SetCursor( nCurX, nCurY ); // Markierung stehenlassen
// If the cursor is in existing selection, it's a cursor movement by
// ENTER or TAB. If not, then it's a new selection during ADD
// selection mode.
const ScMarkData& rMark = aViewData.GetMarkData();
ScRangeList aSelList;
rMark.FillRangeListWithMarks(&aSelList, false);
if (!aSelList.In(ScRange(nCurX, nCurY, aViewData.GetTabNo())))
// Cursor not in existing selection. Start a new selection.
DoneBlockMode(true);
}
else
{
if (!bShift)
{
// Remove all marked data on cursor movement unless the Shift is locked.
ScMarkData aData(aViewData.GetMarkData());
aData.ResetMark();
SetMarkData(aData);
}
bool bSame = ( nCurX == aViewData.GetCurX() && nCurY == aViewData.GetCurY() );
bMoveIsShift = bShift;
pSelEngine->CursorPosChanging( bShift, bControl );
bMoveIsShift = false;
aFunctionSet.SetCursorAtCell( nCurX, nCurY, false );
// Wenn der Cursor nicht bewegt wurde, muss das SelectionChanged fuer das
// Aufheben der Selektion hier einzeln passieren:
if (bSame)
SelectionChanged();
}
ShowAllCursors();
TestHintWindow();
}
void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
bool bShift, bool bKeepSel )
{
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
bool bSkipProtected = false, bSkipUnprotected = false;
ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
if ( pProtect && pProtect->isProtected() )
{
bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
}
if ( bSkipProtected && bSkipUnprotected )
return;
SCsCOL nOldX;
SCsROW nOldY;
SCsCOL nCurX;
SCsROW nCurY;
if ( aViewData.IsRefMode() )
{
nOldX = (SCsCOL) aViewData.GetRefEndX();
nOldY = (SCsROW) aViewData.GetRefEndY();
nCurX = nOldX + nMovX;
nCurY = nOldY + nMovY;
}
else
{
nOldX = (SCsCOL) aViewData.GetCurX();
nOldY = (SCsROW) aViewData.GetCurY();
nCurX = (nMovX != 0) ? nOldX+nMovX : (SCsCOL) aViewData.GetOldCurX();
nCurY = (nMovY != 0) ? nOldY+nMovY : (SCsROW) aViewData.GetOldCurY();
}
aViewData.ResetOldCursor();
if (nMovX != 0 && VALIDCOLROW(nCurX,nCurY))
SkipCursorHorizontal(nCurX, nCurY, nOldX, nMovX);
if (nMovY != 0 && VALIDCOLROW(nCurX,nCurY))
SkipCursorVertical(nCurX, nCurY, nOldY, nMovY);
MoveCursorAbs( nCurX, nCurY, eMode, bShift, false, true, bKeepSel );
}
void ScTabView::MoveCursorPage( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift, bool bKeepSel )
{
SCsCOL nPageX;
SCsROW nPageY;
GetPageMoveEndPosition(nMovX, nMovY, nPageX, nPageY);
MoveCursorRel( nPageX, nPageY, eMode, bShift, bKeepSel );
}
void ScTabView::MoveCursorArea( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift, bool bKeepSel )
{
SCsCOL nNewX;
SCsROW nNewY;
GetAreaMoveEndPosition(nMovX, nMovY, eMode, nNewX, nNewY, eMode);
MoveCursorRel(nNewX, nNewY, eMode, bShift, bKeepSel);
}
void ScTabView::MoveCursorEnd( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift, bool bKeepSel )
{
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
SCCOL nCurX;
SCROW nCurY;
aViewData.GetMoveCursor( nCurX,nCurY );
SCCOL nNewX = nCurX;
SCROW nNewY = nCurY;
SCCOL nUsedX = 0;
SCROW nUsedY = 0;
if ( nMovX > 0 || nMovY > 0 )
pDoc->GetPrintArea( nTab, nUsedX, nUsedY ); // Ende holen
if (nMovX<0)
nNewX=0;
else if (nMovX>0)
nNewX=nUsedX; // letzter benutzter Bereich
if (nMovY<0)
nNewY=0;
else if (nMovY>0)
nNewY=nUsedY;
aViewData.ResetOldCursor();
MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY, eMode, bShift, bKeepSel );
}
void ScTabView::MoveCursorScreen( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift )
{
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
SCCOL nCurX;
SCROW nCurY;
aViewData.GetMoveCursor( nCurX,nCurY );
SCCOL nNewX = nCurX;
SCROW nNewY = nCurY;
ScSplitPos eWhich = aViewData.GetActivePart();
SCCOL nPosX = aViewData.GetPosX( WhichH(eWhich) );
SCROW nPosY = aViewData.GetPosY( WhichV(eWhich) );
SCCOL nAddX = aViewData.VisibleCellsX( WhichH(eWhich) );
if (nAddX != 0)
--nAddX;
SCROW nAddY = aViewData.VisibleCellsY( WhichV(eWhich) );
if (nAddY != 0)
--nAddY;
if (nMovX<0)
nNewX=nPosX;
else if (nMovX>0)
nNewX=nPosX+nAddX;
if (nMovY<0)
nNewY=nPosY;
else if (nMovY>0)
nNewY=nPosY+nAddY;
aViewData.SetOldCursor( nNewX,nNewY );
pDoc->SkipOverlapped(nNewX, nNewY, nTab);
MoveCursorAbs( nNewX, nNewY, eMode, bShift, false, true );
}
void ScTabView::MoveCursorEnter( bool bShift ) // bShift -> hoch/runter
{
const ScInputOptions& rOpt = SC_MOD()->GetInputOptions();
if (!rOpt.GetMoveSelection())
{
aViewData.UpdateInputHandler(true);
return;
}
SCsCOL nMoveX = 0;
SCsROW nMoveY = 0;
switch ((ScDirection)rOpt.GetMoveDir())
{
case DIR_BOTTOM:
nMoveY = bShift ? -1 : 1;
break;
case DIR_RIGHT:
nMoveX = bShift ? -1 : 1;
break;
case DIR_TOP:
nMoveY = bShift ? 1 : -1;
break;
case DIR_LEFT:
nMoveX = bShift ? 1 : -1;
break;
}
ScMarkData& rMark = aViewData.GetMarkData();
if (rMark.IsMarked() || rMark.IsMultiMarked())
{
SCCOL nCurX;
SCROW nCurY;
aViewData.GetMoveCursor( nCurX,nCurY );
SCCOL nNewX = nCurX;
SCROW nNewY = nCurY;
SCTAB nTab = aViewData.GetTabNo();
ScDocument* pDoc = aViewData.GetDocument();
pDoc->GetNextPos( nNewX,nNewY, nTab, nMoveX,nMoveY, true, false, rMark );
MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY,
SC_FOLLOW_LINE, false, true );
// update input line even if cursor was not moved
if ( nNewX == nCurX && nNewY == nCurY )
aViewData.UpdateInputHandler(true);
}
else
{
if ( nMoveY != 0 && !nMoveX )
{
// nach Tab und Enter wieder zur Ausgangsspalte
SCCOL nTabCol = aViewData.GetTabStartCol();
if (nTabCol != SC_TABSTART_NONE)
{
SCCOL nCurX;
SCROW nCurY;
aViewData.GetMoveCursor( nCurX,nCurY );
nMoveX = ((SCsCOL)nTabCol)-(SCsCOL)nCurX;
}
}
MoveCursorRel( nMoveX,nMoveY, SC_FOLLOW_LINE, false );
}
}
bool ScTabView::MoveCursorKeyInput( const KeyEvent& rKeyEvent )
{
const KeyCode& rKCode = rKeyEvent.GetKeyCode();
enum { MOD_NONE, MOD_CTRL, MOD_ALT, MOD_BOTH } eModifier =
rKCode.IsMod1() ?
(rKCode.IsMod2() ? MOD_BOTH : MOD_CTRL) :
(rKCode.IsMod2() ? MOD_ALT : MOD_NONE);
bool bSel = rKCode.IsShift();
sal_uInt16 nCode = rKCode.GetCode();
// CURSOR keys
SCsCOL nDX = 0;
SCsROW nDY = 0;
switch( nCode )
{
case KEY_LEFT: nDX = -1; break;
case KEY_RIGHT: nDX = 1; break;
case KEY_UP: nDY = -1; break;
case KEY_DOWN: nDY = 1; break;
}
if( nDX != 0 || nDY != 0 )
{
switch( eModifier )
{
case MOD_NONE: MoveCursorRel( nDX, nDY, SC_FOLLOW_LINE, bSel ); break;
case MOD_CTRL: MoveCursorArea( nDX, nDY, SC_FOLLOW_JUMP, bSel ); break;
default:
{
// added to avoid warnings
}
}
// always true to suppress changes of col/row size (ALT+CURSOR)
return true;
}
// PAGEUP/PAGEDOWN
if( (nCode == KEY_PAGEUP) || (nCode == KEY_PAGEDOWN) )
{
nDX = (nCode == KEY_PAGEUP) ? -1 : 1;
switch( eModifier )
{
case MOD_NONE: MoveCursorPage( 0, static_cast<SCsCOLROW>(nDX), SC_FOLLOW_FIX, bSel ); break;
case MOD_ALT: MoveCursorPage( nDX, 0, SC_FOLLOW_FIX, bSel ); break;
case MOD_CTRL: SelectNextTab( nDX ); break;
default:
{
// added to avoid warnings
}
}
return true;
}
// HOME/END
if( (nCode == KEY_HOME) || (nCode == KEY_END) )
{
nDX = (nCode == KEY_HOME) ? -1 : 1;
ScFollowMode eMode = (nCode == KEY_HOME) ? SC_FOLLOW_LINE : SC_FOLLOW_JUMP;
switch( eModifier )
{
case MOD_NONE: MoveCursorEnd( nDX, 0, eMode, bSel ); break;
case MOD_CTRL: MoveCursorEnd( nDX, static_cast<SCsCOLROW>(nDX), eMode, bSel ); break;
default:
{
// added to avoid warnings
}
}
return true;
}
return false;
}
// naechste/vorherige nicht geschuetzte Zelle
void ScTabView::FindNextUnprot( bool bShift, bool bInSelection )
{
short nMove = bShift ? -1 : 1;
ScMarkData& rMark = aViewData.GetMarkData();
bool bMarked = bInSelection && (rMark.IsMarked() || rMark.IsMultiMarked());
SCCOL nCurX;
SCROW nCurY;
aViewData.GetMoveCursor( nCurX,nCurY );
SCCOL nNewX = nCurX;
SCROW nNewY = nCurY;
SCTAB nTab = aViewData.GetTabNo();
ScDocument* pDoc = aViewData.GetDocument();
pDoc->GetNextPos( nNewX,nNewY, nTab, nMove,0, bMarked, true, rMark );
SCCOL nTabCol = aViewData.GetTabStartCol();
if ( nTabCol == SC_TABSTART_NONE )
nTabCol = nCurX; // auf diese Spalte zurueck bei Enter
MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY,
SC_FOLLOW_LINE, false, true );
// in MoveCursorRel wird die TabCol zurueckgesetzt...
aViewData.SetTabStartCol( nTabCol );
}
void ScTabView::MarkColumns()
{
SCCOL nStartCol;
SCCOL nEndCol;
ScMarkData& rMark = aViewData.GetMarkData();
if (rMark.IsMarked())
{
ScRange aMarkRange;
rMark.GetMarkArea( aMarkRange );
nStartCol = aMarkRange.aStart.Col();
nEndCol = aMarkRange.aEnd.Col();
}
else
{
SCROW nDummy;
aViewData.GetMoveCursor( nStartCol, nDummy );
nEndCol=nStartCol;
}
SCTAB nTab = aViewData.GetTabNo();
DoneBlockMode();
InitBlockMode( nStartCol,0, nTab );
MarkCursor( nEndCol,MAXROW, nTab );
SelectionChanged();
}
void ScTabView::MarkRows()
{
SCROW nStartRow;
SCROW nEndRow;
ScMarkData& rMark = aViewData.GetMarkData();
if (rMark.IsMarked())
{
ScRange aMarkRange;
rMark.GetMarkArea( aMarkRange );
nStartRow = aMarkRange.aStart.Row();
nEndRow = aMarkRange.aEnd.Row();
}
else
{
SCCOL nDummy;
aViewData.GetMoveCursor( nDummy, nStartRow );
nEndRow=nStartRow;
}
SCTAB nTab = aViewData.GetTabNo();
DoneBlockMode();
InitBlockMode( 0,nStartRow, nTab );
MarkCursor( MAXCOL,nEndRow, nTab );
SelectionChanged();
}
void ScTabView::MarkDataArea( bool bIncludeCursor )
{
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
SCCOL nStartCol = aViewData.GetCurX();
SCROW nStartRow = aViewData.GetCurY();
SCCOL nEndCol = nStartCol;
SCROW nEndRow = nStartRow;
pDoc->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, bIncludeCursor, false );
HideAllCursors();
DoneBlockMode();
InitBlockMode( nStartCol, nStartRow, nTab );
MarkCursor( nEndCol, nEndRow, nTab );
ShowAllCursors();
SelectionChanged();
}
void ScTabView::MarkMatrixFormula()
{
ScDocument* pDoc = aViewData.GetDocument();
ScAddress aCursor( aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
ScRange aMatrix;
if ( pDoc->GetMatrixFormulaRange( aCursor, aMatrix ) )
{
MarkRange( aMatrix, false ); // cursor is already within the range
}
}
void ScTabView::MarkRange( const ScRange& rRange, bool bSetCursor, bool bContinue )
{
SCTAB nTab = rRange.aStart.Tab();
SetTabNo( nTab );
HideAllCursors();
DoneBlockMode( bContinue ); // bContinue==true -> clear old mark
if (bSetCursor) // Wenn Cursor gesetzt wird, immer auch alignen
{
SCCOL nAlignX = rRange.aStart.Col();
SCROW nAlignY = rRange.aStart.Row();
bool bCol = ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL ) && !aViewData.GetDocument()->IsInVBAMode();
bool bRow = ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW );
if ( bCol )
nAlignX = aViewData.GetPosX(WhichH(aViewData.GetActivePart()));
if ( bRow )
nAlignY = aViewData.GetPosY(WhichV(aViewData.GetActivePart()));
AlignToCursor( nAlignX, nAlignY, SC_FOLLOW_JUMP );
}
InitBlockMode( rRange.aStart.Col(), rRange.aStart.Row(), nTab );
MarkCursor( rRange.aEnd.Col(), rRange.aEnd.Row(), nTab );
if (bSetCursor)
{
SCCOL nPosX = rRange.aStart.Col();
SCROW nPosY = rRange.aStart.Row();
ScDocument* pDoc = aViewData.GetDocument();
pDoc->SkipOverlapped(nPosX, nPosY, nTab);
aViewData.ResetOldCursor();
SetCursor( nPosX, nPosY );
}
ShowAllCursors();
SelectionChanged();
}
void ScTabView::Unmark()
{
ScMarkData& rMark = aViewData.GetMarkData();
if ( rMark.IsMarked() || rMark.IsMultiMarked() )
{
SCCOL nCurX;
SCROW nCurY;
aViewData.GetMoveCursor( nCurX,nCurY );
MoveCursorAbs( nCurX, nCurY, SC_FOLLOW_NONE, false, false );
SelectionChanged();
}
}
void ScTabView::SetMarkData( const ScMarkData& rNew )
{
DoneBlockMode();
InitOwnBlockMode();
aViewData.GetMarkData() = rNew;
MarkDataChanged();
}
void ScTabView::MarkDataChanged()
{
// has to be called after making direct changes to mark data (not via MarkCursor etc)
UpdateSelectionOverlay();
}
void ScTabView::SelectNextTab( short nDir, bool bExtendSelection )
{
if (!nDir) return;
OSL_ENSURE( nDir==-1 || nDir==1, "SelectNextTab: falscher Wert");
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
if (nDir<0)
{
if (!nTab) return;
--nTab;
while (!pDoc->IsVisible(nTab))
{
if (!nTab) return;
--nTab;
}
}
else
{
SCTAB nCount = pDoc->GetTableCount();
++nTab;
if (nTab >= nCount) return;
while (!pDoc->IsVisible(nTab))
{
++nTab;
if (nTab >= nCount) return;
}
}
SetTabNo( nTab, false, bExtendSelection );
PaintExtras();
}
// SetTabNo - angezeigte Tabelle
void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSameTabButMoved )
{
if ( !ValidTab(nTab) )
{
OSL_FAIL("SetTabNo: falsche Tabelle");
return;
}
if ( nTab != aViewData.GetTabNo() || bNew )
{
// Die FormShell moechte vor dem Umschalten benachrichtigt werden
FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell();
if (pFormSh)
{
bool bAllowed = static_cast<bool>(pFormSh->PrepareClose(true));
if (!bAllowed)
{
//! Fehlermeldung? oder macht das die FormShell selber?
//! Fehler-Flag zurueckgeben und Aktionen abbrechen
return; // Die FormShell sagt, es kann nicht umgeschaltet werden
}
}
// nicht InputEnterHandler wegen Referenzeingabe !
ScDocument* pDoc = aViewData.GetDocument();
pDoc->MakeTable( nTab );
// Update pending row heights before switching the sheet, so Reschedule from the progress bar
// doesn't paint the new sheet with old heights
aViewData.GetDocShell()->UpdatePendingRowHeights( nTab );
SCTAB nTabCount = pDoc->GetTableCount();
SCTAB nOldPos = nTab;
while (!pDoc->IsVisible(nTab)) // naechste sichtbare suchen
{
bool bUp = (nTab>=nOldPos);
if (bUp)
{
++nTab;
if (nTab>=nTabCount)
{
nTab = nOldPos;
bUp = false;
}
}
if (!bUp)
{
if (nTab != 0)
--nTab;
else
{
OSL_FAIL("keine sichtbare Tabelle");
pDoc->SetVisible( 0, true );
}
}
}
// #i71490# Deselect drawing objects before changing the sheet number in view data,
// so the handling of notes still has the sheet selected on which the notes are.
DrawDeselectAll();
ScModule* pScMod = SC_MOD();
bool bRefMode = pScMod->IsFormulaMode();
if ( !bRefMode ) // Abfrage, damit RefMode bei Tabellenwechsel funktioniert
{
DoneBlockMode();
pSelEngine->Reset(); // reset all flags, including locked modifiers
aViewData.SetRefTabNo( nTab );
}
ScSplitPos eOldActive = aViewData.GetActivePart(); // before switching
bool bFocus = pGridWin[eOldActive]->HasFocus();
aViewData.SetTabNo( nTab );
// UpdateShow noch vor SetCursor, damit UpdateAutoFillMark die richtigen
// Fenster findet (wird aus SetCursor gerufen)
UpdateShow();
aViewData.ResetOldCursor();
SfxBindings& rBindings = aViewData.GetBindings();
ScMarkData& rMark = aViewData.GetMarkData();
bool bAllSelected = true;
for (SCTAB nSelTab = 0; nSelTab < nTabCount; ++nSelTab)
{
if (!pDoc->IsVisible(nSelTab) || rMark.GetTableSelect(nSelTab))
{
if (nTab == nSelTab)
// This tab is already in selection. Keep the current
// selection.
bExtendSelection = true;
}
else
{
bAllSelected = false;
if (bExtendSelection)
// We got what we need. No need to stay in the loop.
break;
}
}
if (bAllSelected && !bNew)
// #i6327# if all tables are selected, a selection event (#i6330#) will deselect all
// (not if called with bNew to update settings)
bExtendSelection = false;
if (bExtendSelection)
rMark.SelectTable( nTab, true );
else
{
rMark.SelectOneTable( nTab );
rBindings.Invalidate( FID_FILL_TAB );
rBindings.Invalidate( FID_TAB_DESELECTALL );
}
SetCursor( aViewData.GetCurX(), aViewData.GetCurY(), true );
bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
// recalc zoom-dependent values (before TabChanged, before UpdateEditViewPos)
RefreshZoom();
UpdateVarZoom();
if ( bRefMode ) // hide EditView if necessary (after aViewData.SetTabNo !)
{
for (sal_uInt16 i = 0; i < 4; ++i)
if (pGridWin[i] && pGridWin[i]->IsVisible())
pGridWin[i]->UpdateEditViewPos();
}
TabChanged(bSameTabButMoved); // DrawView
UpdateVisibleRange();
aViewData.GetViewShell()->WindowChanged(); // falls das aktive Fenster anders ist
if ( !bUnoRefDialog )
aViewData.GetViewShell()->DisconnectAllClients(); // important for floating frames
else
{
// hide / show inplace client
ScClient* pClient = static_cast<ScClient*>(aViewData.GetViewShell()->GetIPClient());
if ( pClient && pClient->IsObjectInPlaceActive() )
{
Rectangle aObjArea = pClient->GetObjArea();
if ( nTab == aViewData.GetRefTabNo() )
{
// move to its original position
SdrOle2Obj* pDrawObj = pClient->GetDrawObj();
if ( pDrawObj )
{
Rectangle aRect = pDrawObj->GetLogicRect();
MapMode aMapMode( MAP_100TH_MM );
Size aOleSize = pDrawObj->GetOrigObjSize( &aMapMode );
aRect.SetSize( aOleSize );
aObjArea = aRect;
}
}
else
{
// move to an invisible position
aObjArea.SetPos( Point( 0, -2*aObjArea.GetHeight() ) );
}
pClient->SetObjArea( aObjArea );
}
}
if ( bFocus && aViewData.GetActivePart() != eOldActive && !bRefMode )
ActiveGrabFocus(); // grab focus to the pane that's active now
// Fixierungen
bool bResize = false;
if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
if (aViewData.UpdateFixX())
bResize = true;
if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
if (aViewData.UpdateFixY())
bResize = true;
if (bResize)
RepeatResize();
InvalidateSplit();
if ( aViewData.IsPagebreakMode() )
UpdatePageBreakData(); //! asynchron ??
// Form-Layer muss den sichtbaren Ausschnitt der neuen Tabelle kennen
// dafuer muss hier schon der MapMode stimmen
for (sal_uInt16 i=0; i<4; i++)
if (pGridWin[i])
pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() );
SetNewVisArea();
PaintGrid();
PaintTop();
PaintLeft();
PaintExtras();
DoResize( aBorderPos, aFrameSize );
rBindings.Invalidate( SID_DELETE_PRINTAREA ); // Menue
rBindings.Invalidate( FID_DEL_MANUALBREAKS );
rBindings.Invalidate( FID_RESET_PRINTZOOM );
rBindings.Invalidate( SID_STATUS_DOCPOS ); // Statusbar
rBindings.Invalidate( SID_STATUS_PAGESTYLE ); // Statusbar
rBindings.Invalidate( SID_CURRENTTAB ); // Navigator
rBindings.Invalidate( SID_STYLE_FAMILY2 ); // Gestalter
rBindings.Invalidate( SID_STYLE_FAMILY4 ); // Gestalter
rBindings.Invalidate( SID_TABLES_COUNT );
if(pScMod->IsRefDialogOpen())
{
sal_uInt16 nCurRefDlgId=pScMod->GetCurRefDlgId();
SfxViewFrame* pViewFrm = aViewData.GetViewShell()->GetViewFrame();
SfxChildWindow* pChildWnd = pViewFrm->GetChildWindow( nCurRefDlgId );
if ( pChildWnd )
{
IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
pRefDlg->ViewShellChanged();
}
}
}
}
//
// Paint-Funktionen - nur fuer diese View
//
void ScTabView::MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW nRow )
{
DrawDeselectAll();
if (pDrawView)
DrawEnableAnim( false );
EditView* pSpellingView = aViewData.GetSpellingView();
for (sal_uInt16 i=0; i<4; i++)
if (pGridWin[i])
if ( pGridWin[i]->IsVisible() && !aViewData.HasEditView((ScSplitPos)i) )
{
ScHSplitPos eHWhich = WhichH( (ScSplitPos) i );
ScVSplitPos eVWhich = WhichV( (ScSplitPos) i );
SCCOL nScrX = aViewData.GetPosX( eHWhich );
SCROW nScrY = aViewData.GetPosY( eVWhich );
bool bPosVisible =
( nCol >= nScrX && nCol <= nScrX + aViewData.VisibleCellsX(eHWhich) + 1 &&
nRow >= nScrY && nRow <= nScrY + aViewData.VisibleCellsY(eVWhich) + 1 );
// for the active part, create edit view even if outside the visible area,
// so input isn't lost (and the edit view may be scrolled into the visible area)
// #i26433# during spelling, the spelling view must be active
if ( bPosVisible || aViewData.GetActivePart() == (ScSplitPos) i ||
( pSpellingView && aViewData.GetEditView((ScSplitPos) i) == pSpellingView ) )
{
pGridWin[i]->HideCursor();
pGridWin[i]->DeleteCursorOverlay();
pGridWin[i]->DeleteAutoFillOverlay();
pGridWin[i]->DeleteCopySourceOverlay();
// flush OverlayManager before changing MapMode to text edit
pGridWin[i]->flushOverlayManager();
// MapMode must be set after HideCursor
pGridWin[i]->SetMapMode(aViewData.GetLogicMode());
aViewData.SetEditEngine( (ScSplitPos) i, pEngine, pGridWin[i], nCol, nRow );
if ( !bPosVisible )
{
// move the edit view area to the real (possibly negative) position,
// or hide if completely above or left of the window
pGridWin[i]->UpdateEditViewPos();
}
}
}
if (aViewData.GetViewShell()->HasAccessibilityObjects())
aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_ENTEREDITMODE));
}
void ScTabView::UpdateEditView()
{
ScSplitPos eActive = aViewData.GetActivePart();
for (sal_uInt16 i=0; i<4; i++)
if (aViewData.HasEditView( (ScSplitPos) i ))
{
EditView* pEditView = aViewData.GetEditView( (ScSplitPos) i );
aViewData.SetEditEngine( (ScSplitPos) i,
static_cast<ScEditEngineDefaulter*>(pEditView->GetEditEngine()),
pGridWin[i], GetViewData()->GetCurX(), GetViewData()->GetCurY() );
if ( (ScSplitPos)i == eActive )
pEditView->ShowCursor( false );
}
}
void ScTabView::KillEditView( bool bNoPaint )
{
sal_uInt16 i;
SCCOL nCol1 = aViewData.GetEditStartCol();
SCROW nRow1 = aViewData.GetEditStartRow();
SCCOL nCol2 = aViewData.GetEditEndCol();
SCROW nRow2 = aViewData.GetEditEndRow();
bool bPaint[4];
bool bNotifyAcc = false;
bool bExtended = nRow1 != nRow2; // Col wird sowieso bis zum Ende gezeichnet
bool bAtCursor = nCol1 <= aViewData.GetCurX() &&
nCol2 >= aViewData.GetCurX() &&
nRow1 == aViewData.GetCurY();
for (i=0; i<4; i++)
{
bPaint[i] = aViewData.HasEditView( (ScSplitPos) i );
if (bPaint[i])
bNotifyAcc = true;
}
// #108931#; notify accessibility before all things happen
if ((bNotifyAcc) && (aViewData.GetViewShell()->HasAccessibilityObjects()))
aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_LEAVEEDITMODE));
aViewData.ResetEditView();
for (i=0; i<4; i++)
if (pGridWin[i] && bPaint[i])
if (pGridWin[i]->IsVisible())
{
pGridWin[i]->ShowCursor();
pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode());
// #i73567# the cell still has to be repainted
if (bExtended || ( bAtCursor && !bNoPaint ))
{
pGridWin[i]->Draw( nCol1, nRow1, nCol2, nRow2 );
pGridWin[i]->UpdateSelectionOverlay();
}
}
if (pDrawView)
DrawEnableAnim( true );
// GrabFocus immer dann, wenn diese View aktiv ist und
// die Eingabezeile den Focus hat
bool bGrabFocus = false;
if (aViewData.IsActive())
{
ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
if ( pInputHdl )
{
ScInputWindow* pInputWin = pInputHdl->GetInputWindow();
if (pInputWin && pInputWin->IsInputActive())
bGrabFocus = true;
}
}
if (bGrabFocus)
{
// So soll es gemacht werden, damit der Sfx es mitbekommt, klappt aber nicht:
//! aViewData.GetViewShell()->GetViewFrame()->GetWindow().GrabFocus();
// deshalb erstmal so:
GetActiveWin()->GrabFocus();
}
// Cursor-Abfrage erst nach GrabFocus
for (i=0; i<4; i++)
if (pGridWin[i] && pGridWin[i]->IsVisible())
{
Cursor* pCur = pGridWin[i]->GetCursor();
if (pCur && pCur->IsVisible())
pCur->Hide();
if(bPaint[i])
{
pGridWin[i]->UpdateCursorOverlay();
pGridWin[i]->UpdateAutoFillOverlay();
}
}
}
void ScTabView::UpdateFormulas()
{
if ( aViewData.GetDocument()->IsAutoCalcShellDisabled() )
return ;
sal_uInt16 i;
for (i=0; i<4; i++)
if (pGridWin[i])
if (pGridWin[i]->IsVisible())
pGridWin[i]->UpdateFormulas();
if ( aViewData.IsPagebreakMode() )
UpdatePageBreakData(); //! asynchron
UpdateHeaderWidth();
// if in edit mode, adjust edit view area because widths/heights may have changed
if ( aViewData.HasEditView( aViewData.GetActivePart() ) )
UpdateEditView();
}
// PaintArea -Block neu zeichnen
void ScTabView::PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
ScUpdateMode eMode )
{
SCCOL nCol1;
SCROW nRow1;
SCCOL nCol2;
SCROW nRow2;
PutInOrder( nStartCol, nEndCol );
PutInOrder( nStartRow, nEndRow );
for (size_t i = 0; i < 4; ++i)
{
if (!pGridWin[i] || !pGridWin[i]->IsVisible())
continue;
ScHSplitPos eHWhich = WhichH( (ScSplitPos) i );
ScVSplitPos eVWhich = WhichV( (ScSplitPos) i );
bool bOut = false;
nCol1 = nStartCol;
nRow1 = nStartRow;
nCol2 = nEndCol;
nRow2 = nEndRow;
SCCOL nScrX = aViewData.GetPosX( eHWhich );
SCROW nScrY = aViewData.GetPosY( eVWhich );
if (nCol1 < nScrX) nCol1 = nScrX;
if (nCol2 < nScrX)
{
if ( eMode == SC_UPDATE_ALL ) // for UPDATE_ALL, paint anyway
nCol2 = nScrX; // (because of extending strings to the right)
else
bOut = true; // completely outside the window
}
if (nRow1 < nScrY) nRow1 = nScrY;
if (nRow2 < nScrY) bOut = true;
SCCOL nLastX = nScrX + aViewData.VisibleCellsX( eHWhich ) + 1;
SCROW nLastY = nScrY + aViewData.VisibleCellsY( eVWhich ) + 1;
if (nCol1 > nLastX) bOut = true;
if (nCol2 > nLastX) nCol2 = nLastX;
if (nRow1 > nLastY) bOut = true;
if (nRow2 > nLastY) nRow2 = nLastY;
if (bOut)
continue;
if ( eMode == SC_UPDATE_CHANGED )
pGridWin[i]->Draw( nCol1, nRow1, nCol2, nRow2, eMode );
else // ALL oder MARKS
{
bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
long nLayoutSign = bLayoutRTL ? -1 : 1;
Point aStart = aViewData.GetScrPos( nCol1, nRow1, (ScSplitPos) i );
Point aEnd = aViewData.GetScrPos( nCol2+1, nRow2+1, (ScSplitPos) i );
if ( eMode == SC_UPDATE_ALL )
aEnd.X() = bLayoutRTL ? 0 : (pGridWin[i]->GetOutputSizePixel().Width());
aEnd.X() -= nLayoutSign;
aEnd.Y() -= 1;
// #i85232# include area below cells (could be done in GetScrPos?)
if ( eMode == SC_UPDATE_ALL && nRow2 >= MAXROW )
aEnd.Y() = pGridWin[i]->GetOutputSizePixel().Height();
bool bShowChanges = true; //! ...
if (bShowChanges)
{
aStart.X() -= nLayoutSign; // include change marks
aStart.Y() -= 1;
}
bool bMarkClipped = aViewData.GetOptions().GetOption( VOPT_CLIPMARKS );
if (bMarkClipped)
{
// dazu muesste ScColumn::IsEmptyBlock optimiert werden
// (auf Search() umstellen)
//!if ( nCol1 > 0 && !aViewData.GetDocument()->IsBlockEmpty(
//! aViewData.GetTabNo(),
//! 0, nRow1, nCol1-1, nRow2 ) )
{
long nMarkPixel = (long)( SC_CLIPMARK_SIZE * aViewData.GetPPTX() );
aStart.X() -= nMarkPixel * nLayoutSign;
if (!bShowChanges)
aStart.X() -= nLayoutSign; // cell grid
}
}
pGridWin[i]->Invalidate( pGridWin[i]->PixelToLogic( Rectangle( aStart,aEnd ) ) );
}
}
// #i79909# Calling UpdateAllOverlays here isn't necessary and would lead to overlay calls from a timer,
// with a wrong MapMode if editing in a cell (reference input).
// #i80499# Overlays need updates in a lot of cases, e.g. changing row/column size,
// or showing/hiding outlines. TODO: selections in inactive windows are vanishing.
// #i84689# With relative conditional formats, PaintArea may be called often (for each changed cell),
// so UpdateAllOverlays was moved to ScTabViewShell::Notify and is called only if PAINT_LEFT/PAINT_TOP
// is set (width or height changed).
}
void ScTabView::PaintRangeFinderEntry (ScRangeFindData* pData, const SCTAB nTab)
{
ScRange aRef = pData->aRef;
aRef.Justify(); // Justify fuer die Abfragen unten
if ( aRef.aStart == aRef.aEnd ) //! Tab ignorieren?
aViewData.GetDocument()->ExtendMerge(aRef);
if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab )
{
SCCOL nCol1 = aRef.aStart.Col();
SCROW nRow1 = aRef.aStart.Row();
SCCOL nCol2 = aRef.aEnd.Col();
SCROW nRow2 = aRef.aEnd.Row();
// wegnehmen -> Repaint
// SC_UPDATE_MARKS: Invalidate, nicht bis zum Zeilenende
bool bHiddenEdge = false;
SCROW nTmp;
ScDocument* pDoc = aViewData.GetDocument();
while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab) )
{
--nCol1;
bHiddenEdge = true;
}
while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab) )
{
++nCol2;
bHiddenEdge = true;
}
nTmp = pDoc->LastVisibleRow(0, nRow1, nTab);
if (!ValidRow(nTmp))
nTmp = 0;
if (nTmp < nRow1)
{
nRow1 = nTmp;
bHiddenEdge = true;
}
nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab);
if (!ValidRow(nTmp))
nTmp = MAXROW;
if (nTmp > nRow2)
{
nRow2 = nTmp;
bHiddenEdge = true;
}
if ( nCol2 - nCol1 > 1 && nRow2 - nRow1 > 1 && !bHiddenEdge )
{
// nur an den Raendern entlang
PaintArea( nCol1, nRow1, nCol2, nRow1, SC_UPDATE_MARKS );
PaintArea( nCol1, nRow1+1, nCol1, nRow2-1, SC_UPDATE_MARKS );
PaintArea( nCol2, nRow1+1, nCol2, nRow2-1, SC_UPDATE_MARKS );
PaintArea( nCol1, nRow2, nCol2, nRow2, SC_UPDATE_MARKS );
}
else // alles am Stueck
PaintArea( nCol1, nRow1, nCol2, nRow2, SC_UPDATE_MARKS );
}
}
void ScTabView::PaintRangeFinder( long nNumber )
{
ScInputHandler* pHdl = SC_MOD()->GetInputHdl( aViewData.GetViewShell() );
if (pHdl)
{
ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList();
if ( pRangeFinder && pRangeFinder->GetDocName() == aViewData.GetDocShell()->GetTitle() )
{
SCTAB nTab = aViewData.GetTabNo();
sal_uInt16 nCount = (sal_uInt16)pRangeFinder->Count();
if (nNumber < 0)
{
for (sal_uInt16 i=0; i<nCount; i++)
PaintRangeFinderEntry(pRangeFinder->GetObject(i),nTab);
}
else
{
sal_uInt16 idx = nNumber;
if (idx < nCount)
PaintRangeFinderEntry(pRangeFinder->GetObject(idx),nTab);
}
}
}
}
// fuer Chart-Daten-Markierung
void ScTabView::AddHighlightRange( const ScRange& rRange, const Color& rColor )
{
maHighlightRanges.push_back( ScHighlightEntry( rRange, rColor ) );
SCTAB nTab = aViewData.GetTabNo();
if ( nTab >= rRange.aStart.Tab() && nTab <= rRange.aEnd.Tab() )
PaintArea( rRange.aStart.Col(), rRange.aStart.Row(),
rRange.aEnd.Col(), rRange.aEnd.Row(), SC_UPDATE_MARKS );
}
void ScTabView::ClearHighlightRanges()
{
SCTAB nTab = aViewData.GetTabNo();
std::vector<ScHighlightEntry>::const_iterator pIter;
for ( pIter = maHighlightRanges.begin(); pIter != maHighlightRanges.end(); ++pIter)
{
ScRange aRange = pIter->aRef;
if ( nTab >= aRange.aStart.Tab() && nTab <= aRange.aEnd.Tab() )
PaintArea( aRange.aStart.Col(), aRange.aStart.Row(),
aRange.aEnd.Col(), aRange.aEnd.Row(), SC_UPDATE_MARKS );
}
maHighlightRanges.clear();
}
void ScTabView::DoChartSelection(
const uno::Sequence< chart2::data::HighlightedRange > & rHilightRanges )
{
ClearHighlightRanges();
const sal_Unicode sep = ::formula::FormulaCompiler::GetNativeSymbol(ocSep).GetChar(0);
for( sal_Int32 i=0; i<rHilightRanges.getLength(); ++i )
{
Color aSelColor( rHilightRanges[i].PreferredColor );
ScRangeList aRangeList;
ScDocument* pDoc = aViewData.GetDocShell()->GetDocument();
if( ScRangeStringConverter::GetRangeListFromString(
aRangeList, rHilightRanges[i].RangeRepresentation, pDoc, pDoc->GetAddressConvention(), sep ))
{
size_t nListSize = aRangeList.size();
for ( size_t j = 0; j < nListSize; ++j )
{
ScRange* p = aRangeList[j];
if( rHilightRanges[i].Index == - 1 )
AddHighlightRange( *p, aSelColor );
else
AddHighlightRange( lcl_getSubRangeByIndex( *p, rHilightRanges[i].Index ), aSelColor );
}
}
}
}
// PaintGrid - Datenbereiche neu zeichnen
void ScTabView::PaintGrid()
{
sal_uInt16 i;
for (i=0; i<4; i++)
if (pGridWin[i])
if (pGridWin[i]->IsVisible())
pGridWin[i]->Invalidate();
}
// PaintTop - obere Kontrollelemente neu zeichnen
void ScTabView::PaintTop()
{
sal_uInt16 i;
for (i=0; i<2; i++)
{
if (pColBar[i])
pColBar[i]->Invalidate();
if (pColOutline[i])
pColOutline[i]->Invalidate();
}
}
void ScTabView::CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress)
{
sal_uInt16 i;
for(i=0; i<4; i++)
{
if(pGridWin[i])
{
if(pGridWin[i]->IsVisible())
{
pGridWin[i]->CreateAnchorHandle(rHdl, rAddress);
}
}
}
}
void ScTabView::PaintTopArea( SCCOL nStartCol, SCCOL nEndCol )
{
// Pixel-Position der linken Kante
if ( nStartCol < aViewData.GetPosX(SC_SPLIT_LEFT) ||
nStartCol < aViewData.GetPosX(SC_SPLIT_RIGHT) )
aViewData.RecalcPixPos();
// Fixierung anpassen (UpdateFixX setzt HSplitPos neu)
if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX && nStartCol < aViewData.GetFixPosX() )
if (aViewData.UpdateFixX())
RepeatResize();
// zeichnen
if (nStartCol>0)
--nStartCol; //! allgemeiner ?
bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
long nLayoutSign = bLayoutRTL ? -1 : 1;
for (sal_uInt16 i=0; i<2; i++)
{
ScHSplitPos eWhich = (ScHSplitPos) i;
if (pColBar[eWhich])
{
Size aWinSize = pColBar[eWhich]->GetSizePixel();
long nStartX = aViewData.GetScrPos( nStartCol, 0, eWhich ).X();
long nEndX;
if (nEndCol >= MAXCOL)
nEndX = bLayoutRTL ? 0 : ( aWinSize.Width()-1 );
else
nEndX = aViewData.GetScrPos( nEndCol+1, 0, eWhich ).X() - nLayoutSign;
pColBar[eWhich]->Invalidate(
Rectangle( nStartX, 0, nEndX, aWinSize.Height()-1 ) );
}
if (pColOutline[eWhich])
pColOutline[eWhich]->Invalidate();
}
}
// PaintLeft - linke Kontrollelemente neu zeichnen
void ScTabView::PaintLeft()
{
sal_uInt16 i;
for (i=0; i<2; i++)
{
if (pRowBar[i])
pRowBar[i]->Invalidate();
if (pRowOutline[i])
pRowOutline[i]->Invalidate();
}
}
void ScTabView::PaintLeftArea( SCROW nStartRow, SCROW nEndRow )
{
// Pixel-Position der oberen Kante
if ( nStartRow < aViewData.GetPosY(SC_SPLIT_TOP) ||
nStartRow < aViewData.GetPosY(SC_SPLIT_BOTTOM) )
aViewData.RecalcPixPos();
// Fixierung anpassen (UpdateFixY setzt VSplitPos neu)
if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX && nStartRow < aViewData.GetFixPosY() )
if (aViewData.UpdateFixY())
RepeatResize();
// zeichnen
if (nStartRow>0)
--nStartRow;
for (sal_uInt16 i=0; i<2; i++)
{
ScVSplitPos eWhich = (ScVSplitPos) i;
if (pRowBar[eWhich])
{
Size aWinSize = pRowBar[eWhich]->GetSizePixel();
long nStartY = aViewData.GetScrPos( 0, nStartRow, eWhich ).Y();
long nEndY;
if (nEndRow >= MAXROW)
nEndY = aWinSize.Height()-1;
else
nEndY = aViewData.GetScrPos( 0, nEndRow+1, eWhich ).Y() - 1;
pRowBar[eWhich]->Invalidate(
Rectangle( 0, nStartY, aWinSize.Width()-1, nEndY ) );
}
if (pRowOutline[eWhich])
pRowOutline[eWhich]->Invalidate();
}
}
bool ScTabView::PaintExtras()
{
bool bRet = false;
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
if (!pDoc->HasTable(nTab)) // Tabelle geloescht ?
{
SCTAB nCount = pDoc->GetTableCount();
aViewData.SetTabNo(nCount-1);
bRet = true;
}
pTabControl->UpdateStatus(); // true = active
return bRet;
}
void ScTabView::RecalcPPT()
{
// called after changes that require the PPT values to be recalculated
// (currently from detective operations)
double nOldX = aViewData.GetPPTX();
double nOldY = aViewData.GetPPTY();
aViewData.RefreshZoom(); // pre-calculate new PPT values
bool bChangedX = ( aViewData.GetPPTX() != nOldX );
bool bChangedY = ( aViewData.GetPPTY() != nOldY );
if ( bChangedX || bChangedY )
{
// call view SetZoom (including draw scale, split update etc)
// and paint only if values changed
Fraction aZoomX = aViewData.GetZoomX();
Fraction aZoomY = aViewData.GetZoomY();
SetZoom( aZoomX, aZoomY, false );
PaintGrid();
if (bChangedX)
PaintTop();
if (bChangedY)
PaintLeft();
}
}
void ScTabView::ActivateView( bool bActivate, bool bFirst )
{
if ( bActivate == aViewData.IsActive() && !bFirst )
{
// keine Assertion mehr - kommt vor, wenn vorher im Drag&Drop
// auf ein anderes Dokument umgeschaltet wurde
return;
}
// wird nur bei MDI-(De)Activate gerufen
// aViewData.Activate hinten wegen Cursor-Show bei KillEditView
// Markierung nicht mehr loeschen - wenn an der ViewData Activate(false) gesetzt ist,
// wird die Markierung nicht ausgegeben
if (!bActivate)
{
ScModule* pScMod = SC_MOD();
bool bRefMode = pScMod->IsFormulaMode();
// Referenzeingabe nicht abbrechen, um Referenzen auf
// andere Dokumente zuzulassen
if (!bRefMode)
{
// pass view to GetInputHdl, this view may not be current anymore
ScInputHandler* pHdl = SC_MOD()->GetInputHdl(aViewData.GetViewShell());
if (pHdl)
pHdl->EnterHandler();
}
}
PaintExtras();
aViewData.Activate(bActivate);
PaintBlock(false); // Repaint, Markierung je nach Active-Status
if (!bActivate)
HideAllCursors(); // Cursor
else if (!bFirst)
ShowAllCursors();
if (bActivate)
{
if ( bFirst )
{
ScSplitPos eWin = aViewData.GetActivePart();
OSL_ENSURE( pGridWin[eWin], "rottes Dokument, nicht alle SplitPos in GridWin" );
if ( !pGridWin[eWin] )
{
eWin = SC_SPLIT_BOTTOMLEFT;
if ( !pGridWin[eWin] )
{
short i;
for ( i=0; i<4; i++ )
{
if ( pGridWin[i] )
{
eWin = (ScSplitPos) i;
break; // for
}
}
OSL_ENSURE( i<4, "und BUMM" );
}
aViewData.SetActivePart( eWin );
}
}
// hier nicht mehr selber GrabFocus rufen!
// Wenn das Doc bearbeitet wird, ruft der Sfx selber GrabFocus am Fenster der Shell.
// Wenn es z.B. ein Mailbody ist, darf es den Focus nicht bekommen (Bug #43638#)
UpdateInputContext();
}
else
pGridWin[aViewData.GetActivePart()]->ClickExtern();
}
void ScTabView::ActivatePart( ScSplitPos eWhich )
{
ScSplitPos eOld = aViewData.GetActivePart();
if ( eOld != eWhich )
{
bInActivatePart = true;
bool bRefMode = SC_MOD()->IsFormulaMode();
// the HasEditView call during SetCursor would fail otherwise
if ( aViewData.HasEditView(eOld) && !bRefMode )
UpdateInputLine();
ScHSplitPos eOldH = WhichH(eOld);
ScVSplitPos eOldV = WhichV(eOld);
ScHSplitPos eNewH = WhichH(eWhich);
ScVSplitPos eNewV = WhichV(eWhich);
bool bTopCap = pColBar[eOldH] && pColBar[eOldH]->IsMouseCaptured();
bool bLeftCap = pRowBar[eOldV] && pRowBar[eOldV]->IsMouseCaptured();
bool bFocus = pGridWin[eOld]->HasFocus();
bool bCapture = pGridWin[eOld]->IsMouseCaptured();
if (bCapture)
pGridWin[eOld]->ReleaseMouse();
pGridWin[eOld]->ClickExtern();
pGridWin[eOld]->HideCursor();
pGridWin[eWhich]->HideCursor();
aViewData.SetActivePart( eWhich );
ScTabViewShell* pShell = aViewData.GetViewShell();
pShell->WindowChanged();
pSelEngine->SetWindow(pGridWin[eWhich]);
pSelEngine->SetWhich(eWhich);
pSelEngine->SetVisibleArea( Rectangle(Point(), pGridWin[eWhich]->GetOutputSizePixel()) );
pGridWin[eOld]->MoveMouseStatus(*pGridWin[eWhich]);
if ( bCapture || pGridWin[eWhich]->IsMouseCaptured() )
{
// Tracking statt CaptureMouse, damit sauber abgebrochen werden kann
// (SelectionEngine ruft CaptureMouse beim SetWindow)
//! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?!
pGridWin[eWhich]->ReleaseMouse();
pGridWin[eWhich]->StartTracking();
}
if ( bTopCap && pColBar[eNewH] )
{
pColBar[eOldH]->SetIgnoreMove(true);
pColBar[eNewH]->SetIgnoreMove(false);
pHdrSelEng->SetWindow( pColBar[eNewH] );
long nWidth = pColBar[eNewH]->GetOutputSizePixel().Width();
pHdrSelEng->SetVisibleArea( Rectangle( 0, LONG_MIN, nWidth-1, LONG_MAX ) );
pColBar[eNewH]->CaptureMouse();
}
if ( bLeftCap && pRowBar[eNewV] )
{
pRowBar[eOldV]->SetIgnoreMove(true);
pRowBar[eNewV]->SetIgnoreMove(false);
pHdrSelEng->SetWindow( pRowBar[eNewV] );
long nHeight = pRowBar[eNewV]->GetOutputSizePixel().Height();
pHdrSelEng->SetVisibleArea( Rectangle( LONG_MIN, 0, LONG_MAX, nHeight-1 ) );
pRowBar[eNewV]->CaptureMouse();
}
aHdrFunc.SetWhich(eWhich);
pGridWin[eOld]->ShowCursor();
pGridWin[eWhich]->ShowCursor();
SfxInPlaceClient* pClient = aViewData.GetViewShell()->GetIPClient();
bool bOleActive = ( pClient && pClient->IsObjectInPlaceActive() );
// don't switch ViewShell's active window during RefInput, because the focus
// might change, and subsequent SetReference calls wouldn't find the right EditView
if ( !bRefMode && !bOleActive )
aViewData.GetViewShell()->SetWindow( pGridWin[eWhich] );
if ( bFocus && !aViewData.IsAnyFillMode() && !bRefMode )
{
// GrabFocus nur, wenn vorher das andere GridWindow den Focus hatte
// (z.B. wegen Suchen & Ersetzen)
pGridWin[eWhich]->GrabFocus();
}
bInActivatePart = false;
}
}
void ScTabView::HideListBox()
{
for (sal_uInt16 i=0; i<4; i++)
if (pGridWin[i])
pGridWin[i]->ClickExtern();
}
void ScTabView::UpdateInputContext()
{
ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
if (pWin)
pWin->UpdateInputContext();
if (pTabControl)
pTabControl->UpdateInputContext();
}
// GetGridWidth - Breite eines Ausgabebereichs (fuer ViewData)
long ScTabView::GetGridWidth( ScHSplitPos eWhich )
{
ScSplitPos eGridWhich = ( eWhich == SC_SPLIT_LEFT ) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
if (pGridWin[eGridWhich])
return pGridWin[eGridWhich]->GetSizePixel().Width();
else
return 0;
}
// GetGridHeight - Hoehe eines Ausgabebereichs (fuer ViewData)
long ScTabView::GetGridHeight( ScVSplitPos eWhich )
{
ScSplitPos eGridWhich = ( eWhich == SC_SPLIT_TOP ) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
if (pGridWin[eGridWhich])
return pGridWin[eGridWhich]->GetSizePixel().Height();
else
return 0;
}
void ScTabView::UpdateInputLine()
{
SC_MOD()->InputEnterHandler();
}
void ScTabView::ZoomChanged()
{
ScInputHandler* pHdl = SC_MOD()->GetInputHdl(aViewData.GetViewShell());
if (pHdl)
pHdl->SetRefScale( aViewData.GetZoomX(), aViewData.GetZoomY() );
UpdateFixPos();
UpdateScrollBars();
// VisArea...
// AW: Discussed with NN if there is a reason that new map mode was only set for one window,
// but is not. Setting only on one window causes the first repaint to have the old mapMode
// in three of four views, so the overlay will save the wrong content e.g. when zooming out.
// Changing to setting map mode at all windows.
sal_uInt32 a;
for(a = 0L; a < 4L; a++)
{
if(pGridWin[a])
{
pGridWin[a]->SetMapMode(pGridWin[a]->GetDrawMapMode());
}
}
SetNewVisArea();
InterpretVisible(); // have everything calculated before painting
SfxBindings& rBindings = aViewData.GetBindings();
rBindings.Invalidate( SID_ATTR_ZOOM );
rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
HideNoteMarker();
// AW: To not change too much, use pWin here
ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
if ( pWin && aViewData.HasEditView( aViewData.GetActivePart() ) )
{
// flush OverlayManager before changing the MapMode
pWin->flushOverlayManager();
// make sure the EditView's position and size are updated
// with the right (logic, not drawing) MapMode
pWin->SetMapMode( aViewData.GetLogicMode() );
UpdateEditView();
}
}
void ScTabView::CheckNeedsRepaint()
{
sal_uInt16 i;
for (i=0; i<4; i++)
if ( pGridWin[i] && pGridWin[i]->IsVisible() )
pGridWin[i]->CheckNeedsRepaint();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|