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
|
/* -*- 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 <vcl/svapp.hxx>
#include "scitems.hxx"
#include <sfx2/viewfrm.hxx>
#include <sfx2/bindings.hxx>
#include <vcl/help.hxx>
#include <vcl/settings.hxx>
#include "tabview.hxx"
#include "tabvwsh.hxx"
#include "document.hxx"
#include "gridwin.hxx"
#include "olinewin.hxx"
#include "olinetab.hxx"
#include "tabsplit.hxx"
#include "colrowba.hxx"
#include "tabcont.hxx"
#include "scmod.hxx"
#include "sc.hrc"
#include "viewutil.hxx"
#include "globstr.hrc"
#include "drawview.hxx"
#include "docsh.hxx"
#include "viewuno.hxx"
#include "AccessibilityHints.hxx"
#include "appoptio.hxx"
#include "attrib.hxx"
#include "hintwin.hxx"
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
#include <string>
#include <algorithm>
#include <basegfx/tools/zoomtools.hxx>
#define SPLIT_MARGIN 30
#define SPLIT_HANDLE_SIZE 5
#define SC_ICONSIZE 36
#define SC_SCROLLBAR_MIN 30
#define SC_TABBAR_MIN 6
using namespace ::com::sun::star;
// Corner-Button
ScCornerButton::ScCornerButton( Window* pParent, ScViewData* pData, bool bAdditional ) :
Window( pParent, WinBits( 0 ) ),
pViewData( pData ),
bAdd( bAdditional )
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
SetBackground( rStyleSettings.GetFaceColor() );
EnableRTL( false );
}
ScCornerButton::~ScCornerButton()
{
}
void ScCornerButton::Paint( const Rectangle& rRect )
{
Size aSize = GetOutputSizePixel();
long nPosX = aSize.Width()-1;
long nPosY = aSize.Height()-1;
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
Window::Paint(rRect);
bool bLayoutRTL = pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
long nDarkX = bLayoutRTL ? 0 : nPosX;
if ( !bAdd )
{
// match the shaded look of column/row headers
Color aFace( rStyleSettings.GetFaceColor() );
Color aWhite( COL_WHITE );
Color aCenter( aFace );
aCenter.Merge( aWhite, 0xd0 ); // lighten up a bit
Color aOuter( aFace );
aOuter.Merge( aWhite, 0xa0 ); // lighten up more
long nCenterX = (aSize.Width() / 2) - 1;
long nCenterY = (aSize.Height() / 2) - 1;
SetLineColor();
SetFillColor(aCenter);
DrawRect( Rectangle( nCenterX, nCenterY, nCenterX, nPosY ) );
DrawRect( Rectangle( nCenterX, nCenterY, nDarkX, nCenterY ) );
SetFillColor(aOuter);
DrawRect( Rectangle( 0, 0, nPosX, nCenterY-1 ) );
if ( bLayoutRTL )
DrawRect( Rectangle( nCenterX+1, nCenterY, nPosX, nPosY ) );
else
DrawRect( Rectangle( 0, nCenterY, nCenterX-1, nPosY ) );
}
// both buttons have the same look now - only dark right/bottom lines
SetLineColor( rStyleSettings.GetDarkShadowColor() );
DrawLine( Point(0,nPosY), Point(nPosX,nPosY) );
DrawLine( Point(nDarkX,0), Point(nDarkX,nPosY) );
}
void ScCornerButton::StateChanged( StateChangedType nType )
{
Window::StateChanged( nType );
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
SetBackground( rStyleSettings.GetFaceColor() );
Invalidate();
}
void ScCornerButton::DataChanged( const DataChangedEvent& rDCEvt )
{
Window::DataChanged( rDCEvt );
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
SetBackground( rStyleSettings.GetFaceColor() );
Invalidate();
}
void ScCornerButton::Resize()
{
Invalidate();
}
void ScCornerButton::MouseButtonDown( const MouseEvent& rMEvt )
{
ScModule* pScMod = SC_MOD();
bool bDisable = pScMod->IsFormulaMode() || pScMod->IsModalMode();
if (!bDisable)
{
ScTabViewShell* pViewSh = pViewData->GetViewShell();
pViewSh->SetActive(); // Appear und SetViewFrame
pViewSh->ActiveGrabFocus();
bool bControl = rMEvt.IsMod1();
pViewSh->SelectAll( bControl );
}
}
static bool lcl_HasColOutline( const ScViewData& rViewData )
{
const ScOutlineTable* pTable = rViewData.GetDocument()->GetOutlineTable(rViewData.GetTabNo());
if (pTable)
{
const ScOutlineArray& rArray = pTable->GetColArray();
if ( rArray.GetDepth() > 0 )
return true;
}
return false;
}
static bool lcl_HasRowOutline( const ScViewData& rViewData )
{
const ScOutlineTable* pTable = rViewData.GetDocument()->GetOutlineTable(rViewData.GetTabNo());
if (pTable)
{
const ScOutlineArray& rArray = pTable->GetRowArray();
if ( rArray.GetDepth() > 0 )
return true;
}
return false;
}
ScTabView::ScTabView( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) :
pFrameWin( pParent ),
aViewData( &rDocSh, pViewShell ),
pSelEngine( NULL ),
aFunctionSet( &aViewData ),
pHdrSelEng( NULL ),
aHdrFunc( &aViewData ),
pDrawView( NULL ),
aVScrollTop( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ),
aVScrollBottom( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ),
aHScrollLeft( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ),
aHScrollRight( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ),
aCornerButton( pFrameWin, &aViewData, false ),
aTopButton( pFrameWin, &aViewData, true ),
aScrollBarBox( pFrameWin, WB_SIZEABLE ),
mpInputHintWindow( NULL ),
pPageBreakData( NULL ),
pBrushDocument( NULL ),
pDrawBrushSet( NULL ),
pTimerWindow( NULL ),
nTipVisible( 0 ),
nPrevDragPos( 0 ),
meBlockMode(None),
nBlockStartX( 0 ),
nBlockStartXOrig( 0 ),
nBlockEndX( 0 ),
nBlockStartY( 0 ),
nBlockStartYOrig( 0 ),
nBlockEndY( 0 ),
nBlockStartZ( 0 ),
nBlockEndZ( 0 ),
nOldCurX( 0 ),
nOldCurY( 0 ),
mfPendingTabBarWidth( -1.0 ),
bMinimized( false ),
bInUpdateHeader( false ),
bInActivatePart( false ),
bInZoomUpdate( false ),
bMoveIsShift( false ),
bDrawSelMode( false ),
bLockPaintBrush( false ),
bDragging( false ),
bBlockNeg( false ),
bBlockCols( false ),
bBlockRows( false )
{
Init();
}
void ScTabView::InitScrollBar( ScrollBar& rScrollBar, long nMaxVal )
{
rScrollBar.SetRange( Range( 0, nMaxVal ) );
rScrollBar.SetLineSize( 1 );
rScrollBar.SetPageSize( 1 ); // wird getrennt abgefragt
rScrollBar.SetVisibleSize( 10 ); // wird bei Resize neu gesetzt
rScrollBar.SetScrollHdl( LINK(this, ScTabView, ScrollHdl) );
rScrollBar.SetEndScrollHdl( LINK(this, ScTabView, EndScrollHdl) );
rScrollBar.EnableRTL( aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() ) );
}
// Scroll-Timer
void ScTabView::SetTimer( ScGridWindow* pWin, const MouseEvent& rMEvt )
{
pTimerWindow = pWin;
aTimerMEvt = rMEvt;
aScrollTimer.Start();
}
void ScTabView::ResetTimer()
{
aScrollTimer.Stop();
pTimerWindow = NULL;
}
IMPL_LINK_NOARG(ScTabView, TimerHdl)
{
if (pTimerWindow)
pTimerWindow->MouseMove( aTimerMEvt );
return 0;
}
// --- Resize ---------------------------------------------------------------------
static void lcl_SetPosSize( Window& rWindow, const Point& rPos, const Size& rSize,
long nTotalWidth, bool bLayoutRTL )
{
Point aNewPos = rPos;
if ( bLayoutRTL )
{
aNewPos.X() = nTotalWidth - rPos.X() - rSize.Width();
if ( aNewPos == rWindow.GetPosPixel() && rSize.Width() != rWindow.GetSizePixel().Width() )
{
// Document windows are manually painted right-to-left, so they need to
// be repainted if the size changes.
rWindow.Invalidate();
}
}
rWindow.SetPosSizePixel( aNewPos, rSize );
}
void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner )
{
HideListBox();
bool bHasHint = HasHintWindow();
if (bHasHint)
RemoveHintWindow();
bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
long nTotalWidth = rSize.Width();
if ( bLayoutRTL )
nTotalWidth += 2*rOffset.X();
bool bVScroll = aViewData.IsVScrollMode();
bool bHScroll = aViewData.IsHScrollMode();
bool bTabControl = aViewData.IsTabMode();
bool bHeaders = aViewData.IsHeaderMode();
bool bOutlMode = aViewData.IsOutlineMode();
bool bHOutline = bOutlMode && lcl_HasColOutline(aViewData);
bool bVOutline = bOutlMode && lcl_HasRowOutline(aViewData);
if ( aViewData.GetDocShell()->IsPreview() )
bHScroll = bVScroll = bTabControl = bHeaders = bOutlMode = bHOutline = bVOutline = false;
long nBarX = 0;
long nBarY = 0;
long nOutlineX = 0;
long nOutlineY = 0;
long nOutPosX;
long nOutPosY;
long nPosX = rOffset.X();
long nPosY = rOffset.Y();
long nSizeX = rSize.Width();
long nSizeY = rSize.Height();
bMinimized = ( nSizeX<=SC_ICONSIZE || nSizeY<=SC_ICONSIZE );
if ( bMinimized )
return;
long nSplitSizeX = SPLIT_HANDLE_SIZE;
if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
nSplitSizeX = 1;
long nSplitSizeY = SPLIT_HANDLE_SIZE;
if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
nSplitSizeY = 1;
const long nOverlap = 0; // ScrollBar::GetWindowOverlapPixel();
aBorderPos = rOffset;
aFrameSize = rSize;
if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
if ( aViewData.GetHSplitPos() > nSizeX - SPLIT_MARGIN )
{
aViewData.SetHSplitMode( SC_SPLIT_NONE );
if ( WhichH( aViewData.GetActivePart() ) == SC_SPLIT_RIGHT )
ActivatePart( SC_SPLIT_BOTTOMLEFT );
InvalidateSplit();
}
if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
if ( aViewData.GetVSplitPos() > nSizeY - SPLIT_MARGIN )
{
aViewData.SetVSplitMode( SC_SPLIT_NONE );
if ( WhichV( aViewData.GetActivePart() ) == SC_SPLIT_TOP )
ActivatePart( SC_SPLIT_BOTTOMLEFT );
InvalidateSplit();
}
UpdateShow();
if (bHScroll || bVScroll) // Scrollbars horizontal oder vertikal
{
long nScrollBarSize = pFrameWin->GetSettings().GetStyleSettings().GetScrollBarSize();
if (bVScroll)
{
nBarX = nScrollBarSize;
nSizeX -= nBarX - nOverlap;
}
if (bHScroll)
{
nBarY = nScrollBarSize;
nSizeY -= nBarY - nOverlap;
}
// window at the bottom right
lcl_SetPosSize( aScrollBarBox, Point( nPosX+nSizeX, nPosY+nSizeY ), Size( nBarX, nBarY ),
nTotalWidth, bLayoutRTL );
if (bHScroll) // Scrollbars horizontal
{
long nSizeLt = 0; // left scroll bar
long nSizeRt = 0; // right scroll bar
long nSizeSp = 0; // splitter
switch (aViewData.GetHSplitMode())
{
case SC_SPLIT_NONE:
nSizeSp = nSplitSizeX;
nSizeLt = nSizeX - nSizeSp + nOverlap; // Ecke ueberdecken
break;
case SC_SPLIT_NORMAL:
nSizeSp = nSplitSizeX;
nSizeLt = aViewData.GetHSplitPos();
break;
case SC_SPLIT_FIX:
nSizeSp = 0;
nSizeLt = 0;
break;
}
nSizeRt = nSizeX - nSizeLt - nSizeSp;
long nTabSize = 0;
if (bTabControl)
{
// pending relative tab bar width from extended document options
if( mfPendingTabBarWidth >= 0.0 )
{
SetRelTabBarWidth( mfPendingTabBarWidth );
mfPendingTabBarWidth = -1.0;
}
nTabSize = pTabControl->GetSizePixel().Width()-nOverlap;
if ( aViewData.GetHSplitMode() != SC_SPLIT_FIX ) // bei linkem Scrollbar
{
if (nTabSize > nSizeLt-SC_SCROLLBAR_MIN) nTabSize = nSizeLt-SC_SCROLLBAR_MIN;
if (nTabSize < SC_TABBAR_MIN) nTabSize = SC_TABBAR_MIN;
nSizeLt -= nTabSize;
}
else // bei rechtem Scrollbar
{
if (nTabSize > nSizeRt-SC_SCROLLBAR_MIN) nTabSize = nSizeRt-SC_SCROLLBAR_MIN;
if (nTabSize < SC_TABBAR_MIN) nTabSize = SC_TABBAR_MIN;
nSizeRt -= nTabSize;
}
}
lcl_SetPosSize( *pTabControl, Point(nPosX-nOverlap, nPosY+nSizeY),
Size(nTabSize+nOverlap, nBarY), nTotalWidth, bLayoutRTL );
pTabControl->SetSheetLayoutRTL( bLayoutRTL );
lcl_SetPosSize( aHScrollLeft, Point(nPosX+nTabSize-nOverlap, nPosY+nSizeY),
Size(nSizeLt+2*nOverlap, nBarY), nTotalWidth, bLayoutRTL );
lcl_SetPosSize( *pHSplitter, Point( nPosX+nTabSize+nSizeLt, nPosY+nSizeY ),
Size( nSizeSp, nBarY ), nTotalWidth, bLayoutRTL );
lcl_SetPosSize( aHScrollRight, Point(nPosX+nTabSize+nSizeLt+nSizeSp-nOverlap,
nPosY+nSizeY),
Size(nSizeRt+2*nOverlap, nBarY), nTotalWidth, bLayoutRTL );
// SetDragRectPixel is done below
}
if (bVScroll) // Scrollbars vertikal
{
long nSizeUp = 0; // upper scroll bar
long nSizeSp = 0; // splitter
long nSizeDn; // unterer Scrollbar
switch (aViewData.GetVSplitMode())
{
case SC_SPLIT_NONE:
nSizeUp = 0;
nSizeSp = nSplitSizeY;
break;
case SC_SPLIT_NORMAL:
nSizeUp = aViewData.GetVSplitPos();
nSizeSp = nSplitSizeY;
break;
case SC_SPLIT_FIX:
nSizeUp = 0;
nSizeSp = 0;
break;
}
nSizeDn = nSizeY - nSizeUp - nSizeSp;
lcl_SetPosSize( aVScrollTop, Point(nPosX+nSizeX, nPosY-nOverlap),
Size(nBarX,nSizeUp+2*nOverlap), nTotalWidth, bLayoutRTL );
lcl_SetPosSize( *pVSplitter, Point( nPosX+nSizeX, nPosY+nSizeUp ),
Size( nBarX, nSizeSp ), nTotalWidth, bLayoutRTL );
lcl_SetPosSize( aVScrollBottom, Point(nPosX+nSizeX,
nPosY+nSizeUp+nSizeSp-nOverlap),
Size(nBarX, nSizeDn+2*nOverlap), nTotalWidth, bLayoutRTL );
// SetDragRectPixel is done below
}
}
// SetDragRectPixel auch ohne Scrollbars etc., wenn schon gesplittet ist
if ( bHScroll || aViewData.GetHSplitMode() != SC_SPLIT_NONE )
pHSplitter->SetDragRectPixel(
Rectangle( nPosX, nPosY, nPosX+nSizeX, nPosY+nSizeY ), pFrameWin );
if ( bVScroll || aViewData.GetVSplitMode() != SC_SPLIT_NONE )
pVSplitter->SetDragRectPixel(
Rectangle( nPosX, nPosY, nPosX+nSizeX, nPosY+nSizeY ), pFrameWin );
if (bTabControl && ! bHScroll )
{
nBarY = aHScrollLeft.GetSizePixel().Height();
nBarX = aVScrollBottom.GetSizePixel().Width();
long nSize1 = nSizeX + nOverlap;
long nTabSize = nSize1;
if (nTabSize < 0) nTabSize = 0;
lcl_SetPosSize( *pTabControl, Point(nPosX-nOverlap, nPosY+nSizeY-nBarY),
Size(nTabSize+nOverlap, nBarY), nTotalWidth, bLayoutRTL );
nSizeY -= nBarY - nOverlap;
lcl_SetPosSize( aScrollBarBox, Point( nPosX+nSizeX, nPosY+nSizeY ), Size( nBarX, nBarY ),
nTotalWidth, bLayoutRTL );
if( bVScroll )
{
Size aVScrSize = aVScrollBottom.GetSizePixel();
aVScrSize.Height() -= nBarY;
aVScrollBottom.SetSizePixel( aVScrSize );
}
}
nOutPosX = nPosX;
nOutPosY = nPosY;
// Outline-Controls
if (bVOutline && pRowOutline[SC_SPLIT_BOTTOM])
{
nOutlineX = pRowOutline[SC_SPLIT_BOTTOM]->GetDepthSize();
nSizeX -= nOutlineX;
nPosX += nOutlineX;
}
if (bHOutline && pColOutline[SC_SPLIT_LEFT])
{
nOutlineY = pColOutline[SC_SPLIT_LEFT]->GetDepthSize();
nSizeY -= nOutlineY;
nPosY += nOutlineY;
}
if (bHeaders) // Spalten/Zeilen-Header
{
nBarX = pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width();
nBarY = pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height();
nSizeX -= nBarX;
nSizeY -= nBarY;
nPosX += nBarX;
nPosY += nBarY;
}
else
nBarX = nBarY = 0;
// Splitter auswerten
long nLeftSize = nSizeX;
long nRightSize = 0;
long nTopSize = 0;
long nBottomSize = nSizeY;
long nSplitPosX = nPosX;
long nSplitPosY = nPosY;
if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
{
long nSplitHeight = rSize.Height();
if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
{
// Fixier-Splitter nicht mit Scrollbar/TabBar ueberlappen lassen
if ( bHScroll )
nSplitHeight -= aHScrollLeft.GetSizePixel().Height();
else if ( bTabControl && pTabControl )
nSplitHeight -= pTabControl->GetSizePixel().Height();
}
nSplitPosX = aViewData.GetHSplitPos();
lcl_SetPosSize( *pHSplitter,
Point( nSplitPosX, nOutPosY ), Size( nSplitSizeX, nSplitHeight ), nTotalWidth, bLayoutRTL );
nLeftSize = nSplitPosX - nPosX;
nSplitPosX += nSplitSizeX;
nRightSize = nSizeX - nLeftSize - nSplitSizeX;
}
if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
{
long nSplitWidth = rSize.Width();
if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX && bVScroll )
nSplitWidth -= aVScrollBottom.GetSizePixel().Width();
nSplitPosY = aViewData.GetVSplitPos();
lcl_SetPosSize( *pVSplitter,
Point( nOutPosX, nSplitPosY ), Size( nSplitWidth, nSplitSizeY ), nTotalWidth, bLayoutRTL );
nTopSize = nSplitPosY - nPosY;
nSplitPosY += nSplitSizeY;
nBottomSize = nSizeY - nTopSize - nSplitSizeY;
}
// ShowHide fuer pColOutline / pRowOutline passiert in UpdateShow
if (bHOutline) // Outline-Controls
{
if (pColOutline[SC_SPLIT_LEFT])
{
pColOutline[SC_SPLIT_LEFT]->SetHeaderSize( nBarX );
lcl_SetPosSize( *pColOutline[SC_SPLIT_LEFT],
Point(nPosX-nBarX,nOutPosY), Size(nLeftSize+nBarX,nOutlineY), nTotalWidth, bLayoutRTL );
}
if (pColOutline[SC_SPLIT_RIGHT])
{
pColOutline[SC_SPLIT_RIGHT]->SetHeaderSize( 0 ); // always call to update RTL flag
lcl_SetPosSize( *pColOutline[SC_SPLIT_RIGHT],
Point(nSplitPosX,nOutPosY), Size(nRightSize,nOutlineY), nTotalWidth, bLayoutRTL );
}
}
if (bVOutline)
{
if (nTopSize)
{
if (pRowOutline[SC_SPLIT_TOP] && pRowOutline[SC_SPLIT_BOTTOM])
{
pRowOutline[SC_SPLIT_TOP]->SetHeaderSize( nBarY );
lcl_SetPosSize( *pRowOutline[SC_SPLIT_TOP],
Point(nOutPosX,nPosY-nBarY), Size(nOutlineX,nTopSize+nBarY), nTotalWidth, bLayoutRTL );
pRowOutline[SC_SPLIT_BOTTOM]->SetHeaderSize( 0 );
lcl_SetPosSize( *pRowOutline[SC_SPLIT_BOTTOM],
Point(nOutPosX,nSplitPosY), Size(nOutlineX,nBottomSize), nTotalWidth, bLayoutRTL );
}
}
else if (pRowOutline[SC_SPLIT_BOTTOM])
{
pRowOutline[SC_SPLIT_BOTTOM]->SetHeaderSize( nBarY );
lcl_SetPosSize( *pRowOutline[SC_SPLIT_BOTTOM],
Point(nOutPosX,nSplitPosY-nBarY), Size(nOutlineX,nBottomSize+nBarY), nTotalWidth, bLayoutRTL );
}
}
if (bHOutline && bVOutline)
{
lcl_SetPosSize( aTopButton, Point(nOutPosX,nOutPosY), Size(nOutlineX,nOutlineY), nTotalWidth, bLayoutRTL );
aTopButton.Show();
}
else
aTopButton.Hide();
if (bHeaders) // Spalten/Zeilen-Header
{
lcl_SetPosSize( *pColBar[SC_SPLIT_LEFT],
Point(nPosX,nPosY-nBarY), Size(nLeftSize,nBarY), nTotalWidth, bLayoutRTL );
if (pColBar[SC_SPLIT_RIGHT])
lcl_SetPosSize( *pColBar[SC_SPLIT_RIGHT],
Point(nSplitPosX,nPosY-nBarY), Size(nRightSize,nBarY), nTotalWidth, bLayoutRTL );
if (pRowBar[SC_SPLIT_TOP])
lcl_SetPosSize( *pRowBar[SC_SPLIT_TOP],
Point(nPosX-nBarX,nPosY), Size(nBarX,nTopSize), nTotalWidth, bLayoutRTL );
lcl_SetPosSize( *pRowBar[SC_SPLIT_BOTTOM],
Point(nPosX-nBarX,nSplitPosY), Size(nBarX,nBottomSize), nTotalWidth, bLayoutRTL );
lcl_SetPosSize( aCornerButton, Point(nPosX-nBarX,nPosY-nBarY), Size(nBarX,nBarY), nTotalWidth, bLayoutRTL );
aCornerButton.Show();
pColBar[SC_SPLIT_LEFT]->Show();
pRowBar[SC_SPLIT_BOTTOM]->Show();
}
else
{
aCornerButton.Hide();
pColBar[SC_SPLIT_LEFT]->Hide(); // immer da
pRowBar[SC_SPLIT_BOTTOM]->Hide();
}
// Grid-Windows
if (bInner)
{
long nInnerPosX = bLayoutRTL ? ( nTotalWidth - nPosX - nLeftSize ) : nPosX;
pGridWin[SC_SPLIT_BOTTOMLEFT]->SetPosPixel( Point(nInnerPosX,nSplitPosY) );
}
else
{
lcl_SetPosSize( *pGridWin[SC_SPLIT_BOTTOMLEFT],
Point(nPosX,nSplitPosY), Size(nLeftSize,nBottomSize), nTotalWidth, bLayoutRTL );
if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
lcl_SetPosSize( *pGridWin[SC_SPLIT_BOTTOMRIGHT],
Point(nSplitPosX,nSplitPosY), Size(nRightSize,nBottomSize), nTotalWidth, bLayoutRTL );
if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
lcl_SetPosSize( *pGridWin[SC_SPLIT_TOPLEFT],
Point(nPosX,nPosY), Size(nLeftSize,nTopSize), nTotalWidth, bLayoutRTL );
if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE && aViewData.GetVSplitMode() != SC_SPLIT_NONE )
lcl_SetPosSize( *pGridWin[SC_SPLIT_TOPRIGHT],
Point(nSplitPosX,nPosY), Size(nRightSize,nTopSize), nTotalWidth, bLayoutRTL );
}
// Scrollbars updaten
if (!bInUpdateHeader)
{
UpdateScrollBars(); // Scrollbars nicht beim Scrollen neu setzen
UpdateHeaderWidth();
InterpretVisible(); // have everything calculated before painting
}
if (bHasHint)
TestHintWindow(); // neu positionieren
UpdateVarZoom(); // update variable zoom types (after resizing GridWindows)
if (aViewData.GetViewShell()->HasAccessibilityObjects())
aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_WINDOWRESIZED));
}
void ScTabView::UpdateVarZoom()
{
// update variable zoom types
SvxZoomType eZoomType = GetZoomType();
if ( eZoomType != SVX_ZOOM_PERCENT && !bInZoomUpdate )
{
bInZoomUpdate = true;
const Fraction& rOldX = GetViewData().GetZoomX();
const Fraction& rOldY = GetViewData().GetZoomY();
long nOldPercent = ( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator();
sal_uInt16 nNewZoom = CalcZoom( eZoomType, (sal_uInt16)nOldPercent );
Fraction aNew( nNewZoom, 100 );
if ( aNew != rOldX || aNew != rOldY )
{
SetZoom( aNew, aNew, false ); // always separately per sheet
PaintGrid();
PaintTop();
PaintLeft();
aViewData.GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
aViewData.GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
}
bInZoomUpdate = false;
}
}
void ScTabView::UpdateFixPos()
{
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(false);
}
void ScTabView::RepeatResize( bool bUpdateFix )
{
if ( bUpdateFix )
{
ScSplitMode eHSplit = aViewData.GetHSplitMode();
ScSplitMode eVSplit = aViewData.GetVSplitMode();
// #i46796# UpdateFixX / UpdateFixY uses GetGridOffset, which requires the
// outline windows to be available. So UpdateShow has to be called before
// (also called from DoResize).
if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX )
UpdateShow();
if ( eHSplit == SC_SPLIT_FIX )
aViewData.UpdateFixX();
if ( eVSplit == SC_SPLIT_FIX )
aViewData.UpdateFixY();
}
DoResize( aBorderPos, aFrameSize );
//! Border muss neu gesetzt werden ???
}
void ScTabView::GetBorderSize( SvBorder& rBorder, const Size& /* rSize */ )
{
bool bScrollBars = aViewData.IsVScrollMode();
bool bHeaders = aViewData.IsHeaderMode();
bool bOutlMode = aViewData.IsOutlineMode();
bool bHOutline = bOutlMode && lcl_HasColOutline(aViewData);
bool bVOutline = bOutlMode && lcl_HasRowOutline(aViewData);
bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
rBorder = SvBorder();
if (bScrollBars) // Scrollbars horizontal oder vertikal
{
rBorder.Right() += aVScrollBottom.GetSizePixel().Width();
rBorder.Bottom() += aHScrollLeft.GetSizePixel().Height();
}
// Outline-Controls
if (bVOutline && pRowOutline[SC_SPLIT_BOTTOM])
rBorder.Left() += pRowOutline[SC_SPLIT_BOTTOM]->GetDepthSize();
if (bHOutline && pColOutline[SC_SPLIT_LEFT])
rBorder.Top() += pColOutline[SC_SPLIT_LEFT]->GetDepthSize();
if (bHeaders) // Spalten/Zeilen-Header
{
rBorder.Left() += pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width();
rBorder.Top() += pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height();
}
if ( bLayoutRTL )
::std::swap( rBorder.Left(), rBorder.Right() );
}
IMPL_LINK_NOARG(ScTabView, TabBarResize)
{
if (aViewData.IsHScrollMode())
{
const long nOverlap = 0; // ScrollBar::GetWindowOverlapPixel();
long nSize = pTabControl->GetSplitSize();
if (aViewData.GetHSplitMode() != SC_SPLIT_FIX)
{
long nMax = pHSplitter->GetPosPixel().X();
if( pTabControl->IsEffectiveRTL() )
nMax = pFrameWin->GetSizePixel().Width() - nMax;
--nMax;
if (nSize>nMax) nSize = nMax;
}
if ( nSize != pTabControl->GetSizePixel().Width() )
{
pTabControl->SetSizePixel( Size( nSize+nOverlap,
pTabControl->GetSizePixel().Height() ) );
RepeatResize();
}
}
return 0;
}
void ScTabView::SetTabBarWidth( long nNewWidth )
{
Size aSize = pTabControl->GetSizePixel();
if ( aSize.Width() != nNewWidth )
{
aSize.Width() = nNewWidth;
pTabControl->SetSizePixel( aSize );
}
}
void ScTabView::SetRelTabBarWidth( double fRelTabBarWidth )
{
if( (0.0 <= fRelTabBarWidth) && (fRelTabBarWidth <= 1.0) )
if( long nFrameWidth = pFrameWin->GetSizePixel().Width() )
SetTabBarWidth( static_cast< long >( fRelTabBarWidth * nFrameWidth + 0.5 ) );
}
void ScTabView::SetPendingRelTabBarWidth( double fRelTabBarWidth )
{
mfPendingTabBarWidth = fRelTabBarWidth;
SetRelTabBarWidth( fRelTabBarWidth );
}
long ScTabView::GetTabBarWidth() const
{
return pTabControl->GetSizePixel().Width();
}
double ScTabView::GetRelTabBarWidth() const
{
if( long nFrameWidth = pFrameWin->GetSizePixel().Width() )
return static_cast< double >( GetTabBarWidth() ) / nFrameWidth;
return 0.0;
}
ScGridWindow* ScTabView::GetActiveWin()
{
ScSplitPos ePos = aViewData.GetActivePart();
OSL_ENSURE(pGridWin[ePos],"kein aktives Fenster");
return pGridWin[ePos];
}
void ScTabView::SetActivePointer( const Pointer& rPointer )
{
for (sal_uInt16 i=0; i<4; i++)
if (pGridWin[i])
pGridWin[i]->SetPointer( rPointer );
}
void ScTabView::ActiveGrabFocus()
{
ScSplitPos ePos = aViewData.GetActivePart();
if (pGridWin[ePos])
pGridWin[ePos]->GrabFocus();
}
ScSplitPos ScTabView::FindWindow( Window* pWindow ) const
{
ScSplitPos eVal = SC_SPLIT_BOTTOMLEFT; // Default
for (sal_uInt16 i=0; i<4; i++)
if ( pGridWin[i] == pWindow )
eVal = (ScSplitPos) i;
return eVal;
}
Point ScTabView::GetGridOffset() const
{
Point aPos;
// Groessen hier wie in DoResize
bool bHeaders = aViewData.IsHeaderMode();
bool bOutlMode = aViewData.IsOutlineMode();
bool bHOutline = bOutlMode && lcl_HasColOutline(aViewData);
bool bVOutline = bOutlMode && lcl_HasRowOutline(aViewData);
// Outline-Controls
if (bVOutline && pRowOutline[SC_SPLIT_BOTTOM])
aPos.X() += pRowOutline[SC_SPLIT_BOTTOM]->GetDepthSize();
if (bHOutline && pColOutline[SC_SPLIT_LEFT])
aPos.Y() += pColOutline[SC_SPLIT_LEFT]->GetDepthSize();
if (bHeaders) // Spalten/Zeilen-Header
{
if (pRowBar[SC_SPLIT_BOTTOM])
aPos.X() += pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width();
if (pColBar[SC_SPLIT_LEFT])
aPos.Y() += pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height();
}
return aPos;
}
// --- Scroll-Bars --------------------------------------------------------
bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos )
{
HideNoteMarker();
bool bDone = false;
const CommandWheelData* pData = rCEvt.GetWheelData();
if ( pData && (pData->GetMode() == COMMAND_WHEEL_ZOOM ||
pData->GetMode() == COMMAND_WHEEL_ZOOM_SCALE ) )
{
if ( !aViewData.GetViewShell()->GetViewFrame()->GetFrame().IsInPlace() )
{
// for ole inplace editing, the scale is defined by the visarea and client size
// and can't be changed directly
const Fraction& rOldY = aViewData.GetZoomY();
long nOld = (long)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
long nNew = nOld;
if ( pData->GetMode() == COMMAND_WHEEL_ZOOM_SCALE )
{
nNew = 100 * (long) ((nOld / 100.0) * (pData->GetDelta() / 100.0));
} else
{
if ( pData->GetDelta() < 0 )
nNew = std::max( (long) MINZOOM, basegfx::zoomtools::zoomOut( nOld ));
else
nNew = std::min( (long) MAXZOOM, basegfx::zoomtools::zoomIn( nOld ));
}
if ( nNew != nOld )
{
// scroll wheel doesn't set the AppOptions default
bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom();
SetZoomType( SVX_ZOOM_PERCENT, bSyncZoom );
Fraction aFract( nNew, 100 );
SetZoom( aFract, aFract, bSyncZoom );
PaintGrid();
PaintTop();
PaintLeft();
aViewData.GetBindings().Invalidate( SID_ATTR_ZOOM );
aViewData.GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
}
bDone = true;
}
}
else
{
ScHSplitPos eHPos = WhichH(ePos);
ScVSplitPos eVPos = WhichV(ePos);
ScrollBar* pHScroll = ( eHPos == SC_SPLIT_LEFT ) ? &aHScrollLeft : &aHScrollRight;
ScrollBar* pVScroll = ( eVPos == SC_SPLIT_TOP ) ? &aVScrollTop : &aVScrollBottom;
if ( pGridWin[ePos] )
bDone = pGridWin[ePos]->HandleScrollCommand( rCEvt, pHScroll, pVScroll );
}
return bDone;
}
IMPL_LINK_NOARG(ScTabView, EndScrollHdl)
{
if ( bDragging )
{
UpdateScrollBars();
bDragging = false;
}
return 0;
}
IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll )
{
bool bHoriz = ( pScroll == &aHScrollLeft || pScroll == &aHScrollRight );
long nViewPos;
if ( bHoriz )
nViewPos = aViewData.GetPosX( (pScroll == &aHScrollLeft) ?
SC_SPLIT_LEFT : SC_SPLIT_RIGHT );
else
nViewPos = aViewData.GetPosY( (pScroll == &aVScrollTop) ?
SC_SPLIT_TOP : SC_SPLIT_BOTTOM );
bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
ScrollType eType = pScroll->GetType();
if ( eType == SCROLL_DRAG )
{
if (!bDragging)
{
bDragging = true;
nPrevDragPos = nViewPos;
}
// Scroll-Position anzeigen
// (nur QuickHelp, in der Statuszeile gibt es keinen Eintrag dafuer)
if (Help::IsQuickHelpEnabled())
{
Size aSize = pScroll->GetSizePixel();
/* Convert scrollbar mouse position to screen position. If RTL
mode of scrollbar differs from RTL mode of its parent, then the
direct call to Window::OutputToNormalizedScreenPixel() will
give unusable results, because calcualtion of screen position
is based on parent orientation and expects equal orientation of
the child position. Need to mirror mouse position before. */
Point aMousePos = pScroll->GetPointerPosPixel();
if( pScroll->IsRTLEnabled() != pScroll->GetParent()->IsRTLEnabled() )
aMousePos.X() = aSize.Width() - aMousePos.X() - 1;
aMousePos = pScroll->OutputToNormalizedScreenPixel( aMousePos );
// convert top-left position of scrollbar to screen position
Point aPos = pScroll->OutputToNormalizedScreenPixel( Point() );
// get scrollbar scroll position for help text (row number/column name)
long nScrollMin = 0; // RangeMin simulieren
if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == &aHScrollRight )
nScrollMin = aViewData.GetFixPosX();
if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == &aVScrollBottom )
nScrollMin = aViewData.GetFixPosY();
long nScrollPos = GetScrollBarPos( *pScroll ) + nScrollMin;
OUString aHelpStr;
Rectangle aRect;
sal_uInt16 nAlign;
if (bHoriz)
{
aHelpStr = ScGlobal::GetRscString(STR_COLUMN) +
" " + ScColToAlpha((SCCOL) nScrollPos);
aRect.Left() = aMousePos.X();
aRect.Top() = aPos.Y() - 4;
nAlign = QUICKHELP_BOTTOM|QUICKHELP_CENTER;
}
else
{
aHelpStr = ScGlobal::GetRscString(STR_ROW) +
" " + OUString::number(nScrollPos + 1);
// show quicktext always inside sheet area
aRect.Left() = bLayoutRTL ? (aPos.X() + aSize.Width() + 8) : (aPos.X() - 8);
aRect.Top() = aMousePos.Y();
nAlign = (bLayoutRTL ? QUICKHELP_LEFT : QUICKHELP_RIGHT) | QUICKHELP_VCENTER;
}
aRect.Right() = aRect.Left();
aRect.Bottom() = aRect.Top();
Help::ShowQuickHelp(pScroll->GetParent(), aRect, aHelpStr, nAlign);
}
}
long nDelta = pScroll->GetDelta();
switch ( eType )
{
case SCROLL_LINEUP:
nDelta = -1;
break;
case SCROLL_LINEDOWN:
nDelta = 1;
break;
case SCROLL_PAGEUP:
if ( pScroll == &aHScrollLeft ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_LEFT );
if ( pScroll == &aHScrollRight ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_RIGHT );
if ( pScroll == &aVScrollTop ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_TOP );
if ( pScroll == &aVScrollBottom ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_BOTTOM );
if (nDelta==0) nDelta=-1;
break;
case SCROLL_PAGEDOWN:
if ( pScroll == &aHScrollLeft ) nDelta = aViewData.VisibleCellsX( SC_SPLIT_LEFT );
if ( pScroll == &aHScrollRight ) nDelta = aViewData.VisibleCellsX( SC_SPLIT_RIGHT );
if ( pScroll == &aVScrollTop ) nDelta = aViewData.VisibleCellsY( SC_SPLIT_TOP );
if ( pScroll == &aVScrollBottom ) nDelta = aViewData.VisibleCellsY( SC_SPLIT_BOTTOM );
if (nDelta==0) nDelta=1;
break;
case SCROLL_DRAG:
{
// nur in die richtige Richtung scrollen, nicht um ausgeblendete
// Bereiche herumzittern
long nScrollMin = 0; // RangeMin simulieren
if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == &aHScrollRight )
nScrollMin = aViewData.GetFixPosX();
if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == &aVScrollBottom )
nScrollMin = aViewData.GetFixPosY();
long nScrollPos = GetScrollBarPos( *pScroll ) + nScrollMin;
nDelta = nScrollPos - nViewPos;
if ( nScrollPos > nPrevDragPos )
{
if (nDelta<0) nDelta=0;
}
else if ( nScrollPos < nPrevDragPos )
{
if (nDelta>0) nDelta=0;
}
else
nDelta = 0;
nPrevDragPos = nScrollPos;
}
break;
default:
{
// added to avoid warnings
}
}
if (nDelta)
{
bool bUpdate = ( eType != SCROLL_DRAG ); // bei Drag die Ranges nicht aendern
if ( bHoriz )
ScrollX( nDelta, (pScroll == &aHScrollLeft) ? SC_SPLIT_LEFT : SC_SPLIT_RIGHT, bUpdate );
else
ScrollY( nDelta, (pScroll == &aVScrollTop) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM, bUpdate );
}
return 0;
}
void ScTabView::ScrollX( long nDeltaX, ScHSplitPos eWhich, bool bUpdBars )
{
SCCOL nOldX = aViewData.GetPosX(eWhich);
SCsCOL nNewX = static_cast<SCsCOL>(nOldX) + static_cast<SCsCOL>(nDeltaX);
if ( nNewX < 0 )
{
nDeltaX -= nNewX;
nNewX = 0;
}
if ( nNewX > MAXCOL )
{
nDeltaX -= nNewX - MAXCOL;
nNewX = MAXCOL;
}
SCsCOL nDir = ( nDeltaX > 0 ) ? 1 : -1;
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
while ( pDoc->ColHidden(nNewX, nTab) &&
nNewX+nDir >= 0 && nNewX+nDir <= MAXCOL )
nNewX = sal::static_int_cast<SCsCOL>( nNewX + nDir );
// Fixierung
if (aViewData.GetHSplitMode() == SC_SPLIT_FIX)
{
if (eWhich == SC_SPLIT_LEFT)
nNewX = static_cast<SCsCOL>(nOldX); // links immer stehenlassen
else
{
SCsCOL nFixX = static_cast<SCsCOL>(aViewData.GetFixPosX());
if (nNewX < nFixX)
nNewX = nFixX;
}
}
if (nNewX == static_cast<SCsCOL>(nOldX))
return;
HideAllCursors();
if ( nNewX >= 0 && nNewX <= MAXCOL && nDeltaX )
{
SCCOL nTrackX = std::max( nOldX, static_cast<SCCOL>(nNewX) );
// Mit VCL wirkt Update() im Moment immer auf alle Fenster, beim Update
// nach dem Scrollen des GridWindow's wuerde darum der Col-/RowBar evtl.
// mit schon geaenderter Pos. gepainted werden -
// darum vorher einmal Update am Col-/RowBar
if (pColBar[eWhich])
pColBar[eWhich]->Update();
long nOldPos = aViewData.GetScrPos( nTrackX, 0, eWhich ).X();
aViewData.SetPosX( eWhich, static_cast<SCCOL>(nNewX) );
long nDiff = aViewData.GetScrPos( nTrackX, 0, eWhich ).X() - nOldPos;
if ( eWhich==SC_SPLIT_LEFT )
{
pGridWin[SC_SPLIT_BOTTOMLEFT]->ScrollPixel( nDiff, 0 );
if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
pGridWin[SC_SPLIT_TOPLEFT]->ScrollPixel( nDiff, 0 );
}
else
{
pGridWin[SC_SPLIT_BOTTOMRIGHT]->ScrollPixel( nDiff, 0 );
if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
pGridWin[SC_SPLIT_TOPRIGHT]->ScrollPixel( nDiff, 0 );
}
if (pColBar[eWhich]) { pColBar[eWhich]->Scroll( nDiff,0 ); pColBar[eWhich]->Update(); }
if (pColOutline[eWhich]) pColOutline[eWhich]->ScrollPixel( nDiff );
if (bUpdBars)
UpdateScrollBars();
else
UpdateGrid();
}
if (nDeltaX==1 || nDeltaX==-1)
pGridWin[aViewData.GetActivePart()]->Update();
ShowAllCursors();
SetNewVisArea(); // MapMode muss schon gesetzt sein
TestHintWindow();
}
void ScTabView::ScrollY( long nDeltaY, ScVSplitPos eWhich, bool bUpdBars )
{
SCROW nOldY = aViewData.GetPosY(eWhich);
SCsROW nNewY = static_cast<SCsROW>(nOldY) + static_cast<SCsROW>(nDeltaY);
if ( nNewY < 0 )
{
nDeltaY -= nNewY;
nNewY = 0;
}
if ( nNewY > MAXROW )
{
nDeltaY -= nNewY - MAXROW;
nNewY = MAXROW;
}
SCsROW nDir = ( nDeltaY > 0 ) ? 1 : -1;
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
while ( pDoc->RowHidden(nNewY, nTab) &&
nNewY+nDir >= 0 && nNewY+nDir <= MAXROW )
nNewY += nDir;
// Fixierung
if (aViewData.GetVSplitMode() == SC_SPLIT_FIX)
{
if (eWhich == SC_SPLIT_TOP)
nNewY = static_cast<SCsROW>(nOldY); // oben immer stehenlassen
else
{
SCsROW nFixY = static_cast<SCsROW>(aViewData.GetFixPosY());
if (nNewY < nFixY)
nNewY = nFixY;
}
}
if (nNewY == static_cast<SCsROW>(nOldY))
return;
HideAllCursors();
if ( nNewY >= 0 && nNewY <= MAXROW && nDeltaY )
{
SCROW nTrackY = std::max( nOldY, static_cast<SCROW>(nNewY) );
// Zeilenkoepfe anpassen vor dem eigentlichen Scrolling, damit nicht
// doppelt gepainted werden muss
// PosY darf dann auch noch nicht umgesetzt sein, neuen Wert uebergeben
SCROW nUNew = static_cast<SCROW>(nNewY);
UpdateHeaderWidth( &eWhich, &nUNew ); // Zeilenkoepfe anpassen
if (pRowBar[eWhich])
pRowBar[eWhich]->Update();
long nOldPos = aViewData.GetScrPos( 0, nTrackY, eWhich ).Y();
aViewData.SetPosY( eWhich, static_cast<SCROW>(nNewY) );
long nDiff = aViewData.GetScrPos( 0, nTrackY, eWhich ).Y() - nOldPos;
if ( eWhich==SC_SPLIT_TOP )
{
pGridWin[SC_SPLIT_TOPLEFT]->ScrollPixel( 0, nDiff );
if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
pGridWin[SC_SPLIT_TOPRIGHT]->ScrollPixel( 0, nDiff );
}
else
{
pGridWin[SC_SPLIT_BOTTOMLEFT]->ScrollPixel( 0, nDiff );
if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
pGridWin[SC_SPLIT_BOTTOMRIGHT]->ScrollPixel( 0, nDiff );
}
if (pRowBar[eWhich]) { pRowBar[eWhich]->Scroll( 0,nDiff ); pRowBar[eWhich]->Update(); }
if (pRowOutline[eWhich]) pRowOutline[eWhich]->ScrollPixel( nDiff );
if (bUpdBars)
UpdateScrollBars();
else
UpdateGrid();
}
if (nDeltaY==1 || nDeltaY==-1)
pGridWin[aViewData.GetActivePart()]->Update();
ShowAllCursors();
SetNewVisArea(); // MapMode muss schon gesetzt sein
TestHintWindow();
}
void ScTabView::ScrollLines( long nDeltaX, long nDeltaY )
{
ScSplitPos eWhich = aViewData.GetActivePart();
if (nDeltaX)
ScrollX(nDeltaX,WhichH(eWhich));
if (nDeltaY)
ScrollY(nDeltaY,WhichV(eWhich));
}
static SCROW lcl_LastVisible( ScViewData& rViewData )
{
// wenn am Dokumentende viele Zeilen ausgeblendet sind (welcher Trottel macht sowas?),
// soll dadurch nicht auf breite Zeilenkoepfe geschaltet werden
//! als Member ans Dokument ???
ScDocument* pDoc = rViewData.GetDocument();
SCTAB nTab = rViewData.GetTabNo();
SCROW nVis = MAXROW;
while ( nVis > 0 && pDoc->GetRowHeight( nVis, nTab ) == 0 )
--nVis;
return nVis;
}
void ScTabView::UpdateHeaderWidth( const ScVSplitPos* pWhich, const SCROW* pPosY )
{
if ( !pRowBar[SC_SPLIT_BOTTOM] || MAXROW < 10000 )
return;
SCROW nEndPos = MAXROW;
if ( !aViewData.GetViewShell()->GetViewFrame()->GetFrame().IsInPlace() )
{
// fuer OLE Inplace immer MAXROW
if ( pWhich && *pWhich == SC_SPLIT_BOTTOM && pPosY )
nEndPos = *pPosY;
else
nEndPos = aViewData.GetPosY( SC_SPLIT_BOTTOM );
nEndPos += aViewData.CellsAtY( nEndPos, 1, SC_SPLIT_BOTTOM, SC_SIZE_NONE ); // VisibleCellsY
if (nEndPos > MAXROW)
nEndPos = lcl_LastVisible( aViewData );
if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
{
SCROW nTopEnd;
if ( pWhich && *pWhich == SC_SPLIT_TOP && pPosY )
nTopEnd = *pPosY;
else
nTopEnd = aViewData.GetPosY( SC_SPLIT_TOP );
nTopEnd += aViewData.CellsAtY( nTopEnd, 1, SC_SPLIT_TOP, SC_SIZE_NONE );// VisibleCellsY
if (nTopEnd > MAXROW)
nTopEnd = lcl_LastVisible( aViewData );
if ( nTopEnd > nEndPos )
nEndPos = nTopEnd;
}
}
long nSmall = pRowBar[SC_SPLIT_BOTTOM]->GetSmallWidth();
long nBig = pRowBar[SC_SPLIT_BOTTOM]->GetBigWidth();
long nDiff = nBig - nSmall;
if (nEndPos>10000)
nEndPos = 10000;
else if (nEndPos<1) // avoid extra step at 0 (when only one row is visible)
nEndPos = 1;
long nWidth = nBig - ( 10000 - nEndPos ) * nDiff / 10000;
if ( nWidth != pRowBar[SC_SPLIT_BOTTOM]->GetWidth() && !bInUpdateHeader )
{
bInUpdateHeader = true;
pRowBar[SC_SPLIT_BOTTOM]->SetWidth( nWidth );
if (pRowBar[SC_SPLIT_TOP])
pRowBar[SC_SPLIT_TOP]->SetWidth( nWidth );
RepeatResize();
// auf VCL gibt's Update ohne Ende (jedes Update gilt fuer alle Fenster)
//aCornerButton.Update(); // der bekommt sonst nie ein Update
bInUpdateHeader = false;
}
}
inline void ShowHide( Window* pWin, bool bShow )
{
OSL_ENSURE(pWin || !bShow, "Fenster ist nicht da");
if (pWin)
pWin->Show(bShow);
}
void ScTabView::UpdateShow()
{
bool bHScrollMode = aViewData.IsHScrollMode();
bool bVScrollMode = aViewData.IsVScrollMode();
bool bTabMode = aViewData.IsTabMode();
bool bOutlMode = aViewData.IsOutlineMode();
bool bHOutline = bOutlMode && lcl_HasColOutline(aViewData);
bool bVOutline = bOutlMode && lcl_HasRowOutline(aViewData);
bool bHeader = aViewData.IsHeaderMode();
bool bShowH = ( aViewData.GetHSplitMode() != SC_SPLIT_NONE );
bool bShowV = ( aViewData.GetVSplitMode() != SC_SPLIT_NONE );
if ( aViewData.GetDocShell()->IsPreview() )
bHScrollMode = bVScrollMode = bTabMode = bHeader = bOutlMode = bHOutline = bVOutline = false;
// Windows anlegen
if (bShowH && !pGridWin[SC_SPLIT_BOTTOMRIGHT])
{
pGridWin[SC_SPLIT_BOTTOMRIGHT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_BOTTOMRIGHT );
DoAddWin( pGridWin[SC_SPLIT_BOTTOMRIGHT] );
}
if (bShowV && !pGridWin[SC_SPLIT_TOPLEFT])
{
pGridWin[SC_SPLIT_TOPLEFT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_TOPLEFT );
DoAddWin( pGridWin[SC_SPLIT_TOPLEFT] );
}
if (bShowH && bShowV && !pGridWin[SC_SPLIT_TOPRIGHT])
{
pGridWin[SC_SPLIT_TOPRIGHT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_TOPRIGHT );
DoAddWin( pGridWin[SC_SPLIT_TOPRIGHT] );
}
if (bHOutline && !pColOutline[SC_SPLIT_LEFT])
pColOutline[SC_SPLIT_LEFT] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_HOR, &aViewData, SC_SPLIT_BOTTOMLEFT );
if (bShowH && bHOutline && !pColOutline[SC_SPLIT_RIGHT])
pColOutline[SC_SPLIT_RIGHT] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_HOR, &aViewData, SC_SPLIT_BOTTOMRIGHT );
if (bVOutline && !pRowOutline[SC_SPLIT_BOTTOM])
pRowOutline[SC_SPLIT_BOTTOM] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_BOTTOMLEFT );
if (bShowV && bVOutline && !pRowOutline[SC_SPLIT_TOP])
pRowOutline[SC_SPLIT_TOP] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_TOPLEFT );
if (bShowH && bHeader && !pColBar[SC_SPLIT_RIGHT])
pColBar[SC_SPLIT_RIGHT] = new ScColBar( pFrameWin, &aViewData, SC_SPLIT_RIGHT,
&aHdrFunc, pHdrSelEng );
if (bShowV && bHeader && !pRowBar[SC_SPLIT_TOP])
pRowBar[SC_SPLIT_TOP] = new ScRowBar( pFrameWin, &aViewData, SC_SPLIT_TOP,
&aHdrFunc, pHdrSelEng );
// Windows anzeigen
ShowHide( &aHScrollLeft, bHScrollMode );
ShowHide( &aHScrollRight, bShowH && bHScrollMode );
ShowHide( &aVScrollBottom, bVScrollMode );
ShowHide( &aVScrollTop, bShowV && bVScrollMode );
ShowHide( &aScrollBarBox, bVScrollMode || bHScrollMode );
ShowHide( pHSplitter, bHScrollMode || bShowH ); // immer angelegt
ShowHide( pVSplitter, bVScrollMode || bShowV );
ShowHide( pTabControl, bTabMode );
// ab hier dynamisch angelegte
ShowHide( pGridWin[SC_SPLIT_BOTTOMRIGHT], bShowH );
ShowHide( pGridWin[SC_SPLIT_TOPLEFT], bShowV );
ShowHide( pGridWin[SC_SPLIT_TOPRIGHT], bShowH && bShowV );
ShowHide( pColOutline[SC_SPLIT_LEFT], bHOutline );
ShowHide( pColOutline[SC_SPLIT_RIGHT], bShowH && bHOutline );
ShowHide( pRowOutline[SC_SPLIT_BOTTOM], bVOutline );
ShowHide( pRowOutline[SC_SPLIT_TOP], bShowV && bVOutline );
ShowHide( pColBar[SC_SPLIT_RIGHT], bShowH && bHeader );
ShowHide( pRowBar[SC_SPLIT_TOP], bShowV && bHeader );
//! neue Gridwindows eintragen
}
bool ScTabView::UpdateVisibleRange()
{
bool bChanged = false;
for (int i = 0; i < 4; ++i)
{
if (!pGridWin[i] || !pGridWin[i]->IsVisible())
continue;
if (pGridWin[i]->UpdateVisibleRange())
bChanged = true;
}
return bChanged;
}
// --- Splitter --------------------------------------------------------
IMPL_LINK( ScTabView, SplitHdl, Splitter*, pSplitter )
{
if ( pSplitter == pHSplitter )
DoHSplit( pHSplitter->GetSplitPosPixel() );
else
DoVSplit( pVSplitter->GetSplitPosPixel() );
if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX || aViewData.GetVSplitMode() == SC_SPLIT_FIX )
FreezeSplitters( true );
DoResize( aBorderPos, aFrameSize );
return 0;
}
void ScTabView::DoHSplit(long nSplitPos)
{
// nSplitPos is the real pixel position on the frame window,
// mirroring for RTL has to be done here.
bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
if ( bLayoutRTL )
nSplitPos = pFrameWin->GetOutputSizePixel().Width() - nSplitPos - 1;
long nMinPos;
long nMaxPos;
SCCOL nOldDelta;
SCCOL nNewDelta;
nMinPos = SPLIT_MARGIN;
if ( pRowBar[SC_SPLIT_BOTTOM] && pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width() >= nMinPos )
nMinPos = pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width() + 1;
nMaxPos = aFrameSize.Width() - SPLIT_MARGIN;
ScSplitMode aOldMode = aViewData.GetHSplitMode();
ScSplitMode aNewMode = SC_SPLIT_NORMAL;
aViewData.SetHSplitPos( nSplitPos );
if ( nSplitPos < nMinPos || nSplitPos > nMaxPos )
aNewMode = SC_SPLIT_NONE;
aViewData.SetHSplitMode( aNewMode );
if ( aNewMode != aOldMode )
{
UpdateShow(); // vor ActivatePart !!
if ( aNewMode == SC_SPLIT_NONE )
{
if (aViewData.GetActivePart() == SC_SPLIT_TOPRIGHT)
ActivatePart( SC_SPLIT_TOPLEFT );
if (aViewData.GetActivePart() == SC_SPLIT_BOTTOMRIGHT)
ActivatePart( SC_SPLIT_BOTTOMLEFT );
}
else
{
nOldDelta = aViewData.GetPosX( SC_SPLIT_LEFT );
long nLeftWidth = nSplitPos - pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width();
if ( nLeftWidth < 0 ) nLeftWidth = 0;
nNewDelta = nOldDelta + aViewData.CellsAtX( nOldDelta, 1, SC_SPLIT_LEFT,
(sal_uInt16) nLeftWidth );
if ( nNewDelta > MAXCOL )
nNewDelta = MAXCOL;
aViewData.SetPosX( SC_SPLIT_RIGHT, nNewDelta );
if ( nNewDelta > aViewData.GetCurX() )
ActivatePart( (WhichV(aViewData.GetActivePart()) == SC_SPLIT_BOTTOM) ?
SC_SPLIT_BOTTOMLEFT : SC_SPLIT_TOPLEFT );
else
ActivatePart( (WhichV(aViewData.GetActivePart()) == SC_SPLIT_BOTTOM) ?
SC_SPLIT_BOTTOMRIGHT : SC_SPLIT_TOPRIGHT );
}
// Form-Layer muss den sichtbaren Ausschnitt aller Fenster 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();
InvalidateSplit();
}
}
void ScTabView::DoVSplit(long nSplitPos)
{
long nMinPos;
long nMaxPos;
SCROW nOldDelta;
SCROW nNewDelta;
nMinPos = SPLIT_MARGIN;
if ( pColBar[SC_SPLIT_LEFT] && pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height() >= nMinPos )
nMinPos = pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height() + 1;
nMaxPos = aFrameSize.Height() - SPLIT_MARGIN;
ScSplitMode aOldMode = aViewData.GetVSplitMode();
ScSplitMode aNewMode = SC_SPLIT_NORMAL;
aViewData.SetVSplitPos( nSplitPos );
if ( nSplitPos < nMinPos || nSplitPos > nMaxPos )
aNewMode = SC_SPLIT_NONE;
aViewData.SetVSplitMode( aNewMode );
if ( aNewMode != aOldMode )
{
UpdateShow(); // vor ActivatePart !!
if ( aNewMode == SC_SPLIT_NONE )
{
nOldDelta = aViewData.GetPosY( SC_SPLIT_TOP );
aViewData.SetPosY( SC_SPLIT_BOTTOM, nOldDelta );
if (aViewData.GetActivePart() == SC_SPLIT_TOPLEFT)
ActivatePart( SC_SPLIT_BOTTOMLEFT );
if (aViewData.GetActivePart() == SC_SPLIT_TOPRIGHT)
ActivatePart( SC_SPLIT_BOTTOMRIGHT );
}
else
{
if ( aOldMode == SC_SPLIT_NONE )
nOldDelta = aViewData.GetPosY( SC_SPLIT_BOTTOM );
else
nOldDelta = aViewData.GetPosY( SC_SPLIT_TOP );
aViewData.SetPosY( SC_SPLIT_TOP, nOldDelta );
long nTopHeight = nSplitPos - pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height();
if ( nTopHeight < 0 ) nTopHeight = 0;
nNewDelta = nOldDelta + aViewData.CellsAtY( nOldDelta, 1, SC_SPLIT_TOP,
(sal_uInt16) nTopHeight );
if ( nNewDelta > MAXROW )
nNewDelta = MAXROW;
aViewData.SetPosY( SC_SPLIT_BOTTOM, nNewDelta );
if ( nNewDelta > aViewData.GetCurY() )
ActivatePart( (WhichH(aViewData.GetActivePart()) == SC_SPLIT_LEFT) ?
SC_SPLIT_TOPLEFT : SC_SPLIT_TOPRIGHT );
else
ActivatePart( (WhichH(aViewData.GetActivePart()) == SC_SPLIT_LEFT) ?
SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT );
}
// Form-Layer muss den sichtbaren Ausschnitt aller Fenster 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();
PaintLeft();
InvalidateSplit();
}
}
Point ScTabView::GetInsertPos()
{
ScDocument* pDoc = aViewData.GetDocument();
SCCOL nCol = aViewData.GetCurX();
SCROW nRow = aViewData.GetCurY();
SCTAB nTab = aViewData.GetTabNo();
long nPosX = 0;
for (SCCOL i=0; i<nCol; i++)
nPosX += pDoc->GetColWidth(i,nTab);
nPosX = (long)(nPosX * HMM_PER_TWIPS);
if ( pDoc->IsNegativePage( nTab ) )
nPosX = -nPosX;
long nPosY = (long) pDoc->GetRowHeight( 0, nRow-1, nTab);
nPosY = (long)(nPosY * HMM_PER_TWIPS);
return Point(nPosX,nPosY);
}
Point ScTabView::GetChartInsertPos( const Size& rSize, const ScRange& rCellRange )
{
Point aInsertPos;
const long nBorder = 100; // leave 1mm for border
long nNeededWidth = rSize.Width() + 2 * nBorder;
long nNeededHeight = rSize.Height() + 2 * nBorder;
// use the active window, or lower/right if frozen (as in CalcZoom)
ScSplitPos eUsedPart = aViewData.GetActivePart();
if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
eUsedPart = (WhichV(eUsedPart)==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT;
if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
eUsedPart = (WhichH(eUsedPart)==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
ScGridWindow* pWin = pGridWin[eUsedPart];
OSL_ENSURE( pWin, "Window not found" );
if (pWin)
{
ActivatePart( eUsedPart );
// get the visible rectangle in logic units
MapMode aDrawMode = pWin->GetDrawMapMode();
Rectangle aVisible( pWin->PixelToLogic( Rectangle( Point(0,0), pWin->GetOutputSizePixel() ), aDrawMode ) );
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
long nLayoutSign = bLayoutRTL ? -1 : 1;
long nDocX = (long)( (double) pDoc->GetColOffset( MAXCOL + 1, nTab ) * HMM_PER_TWIPS ) * nLayoutSign;
long nDocY = (long)( (double) pDoc->GetRowOffset( MAXROW + 1, nTab ) * HMM_PER_TWIPS );
if ( aVisible.Left() * nLayoutSign > nDocX * nLayoutSign )
aVisible.Left() = nDocX;
if ( aVisible.Right() * nLayoutSign > nDocX * nLayoutSign )
aVisible.Right() = nDocX;
if ( aVisible.Top() > nDocY )
aVisible.Top() = nDocY;
if ( aVisible.Bottom() > nDocY )
aVisible.Bottom() = nDocY;
// get the logic position of the selection
Rectangle aSelection = pDoc->GetMMRect( rCellRange.aStart.Col(), rCellRange.aStart.Row(),
rCellRange.aEnd.Col(), rCellRange.aEnd.Row(), nTab );
long nLeftSpace = aSelection.Left() - aVisible.Left();
long nRightSpace = aVisible.Right() - aSelection.Right();
long nTopSpace = aSelection.Top() - aVisible.Top();
long nBottomSpace = aVisible.Bottom() - aSelection.Bottom();
bool bFitLeft = ( nLeftSpace >= nNeededWidth );
bool bFitRight = ( nRightSpace >= nNeededWidth );
if ( bFitLeft || bFitRight )
{
// first preference: completely left or right of the selection
// if both fit, prefer left in RTL mode, right otherwise
bool bPutLeft = bFitLeft && ( bLayoutRTL || !bFitRight );
if ( bPutLeft )
aInsertPos.X() = aSelection.Left() - nNeededWidth;
else
aInsertPos.X() = aSelection.Right() + 1;
// align with top of selection (is moved again if it doesn't fit)
aInsertPos.Y() = std::max( aSelection.Top(), aVisible.Top() );
}
else if ( nTopSpace >= nNeededHeight || nBottomSpace >= nNeededHeight )
{
// second preference: completely above or below the selection
if ( nBottomSpace > nNeededHeight ) // bottom is preferred
aInsertPos.Y() = aSelection.Bottom() + 1;
else
aInsertPos.Y() = aSelection.Top() - nNeededHeight;
// align with (logic) left edge of selection (moved again if it doesn't fit)
if ( bLayoutRTL )
aInsertPos.X() = std::min( aSelection.Right(), aVisible.Right() ) - nNeededWidth + 1;
else
aInsertPos.X() = std::max( aSelection.Left(), aVisible.Left() );
}
else
{
// place to the (logic) right of the selection and move so it fits
if ( bLayoutRTL )
aInsertPos.X() = aSelection.Left() - nNeededWidth;
else
aInsertPos.X() = aSelection.Right() + 1;
aInsertPos.Y() = std::max( aSelection.Top(), aVisible.Top() );
}
// move the position if the object doesn't fit in the screen
Rectangle aCompareRect( aInsertPos, Size( nNeededWidth, nNeededHeight ) );
if ( aCompareRect.Right() > aVisible.Right() )
aInsertPos.X() -= aCompareRect.Right() - aVisible.Right();
if ( aCompareRect.Bottom() > aVisible.Bottom() )
aInsertPos.Y() -= aCompareRect.Bottom() - aVisible.Bottom();
if ( aInsertPos.X() < aVisible.Left() )
aInsertPos.X() = aVisible.Left();
if ( aInsertPos.Y() < aVisible.Top() )
aInsertPos.Y() = aVisible.Top();
// nNeededWidth / nNeededHeight includes all borders - move aInsertPos to the
// object position, inside the border
aInsertPos.X() += nBorder;
aInsertPos.Y() += nBorder;
}
return aInsertPos;
}
Point ScTabView::GetChartDialogPos( const Size& rDialogSize, const Rectangle& rLogicChart )
{
// rDialogSize must be in pixels, rLogicChart in 1/100 mm. Return value is in pixels.
Point aRet;
// use the active window, or lower/right if frozen (as in CalcZoom)
ScSplitPos eUsedPart = aViewData.GetActivePart();
if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
eUsedPart = (WhichV(eUsedPart)==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT;
if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
eUsedPart = (WhichH(eUsedPart)==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
ScGridWindow* pWin = pGridWin[eUsedPart];
OSL_ENSURE( pWin, "Window not found" );
if (pWin)
{
MapMode aDrawMode = pWin->GetDrawMapMode();
Rectangle aObjPixel = pWin->LogicToPixel( rLogicChart, aDrawMode );
Rectangle aObjAbs( pWin->OutputToAbsoluteScreenPixel( aObjPixel.TopLeft() ),
pWin->OutputToAbsoluteScreenPixel( aObjPixel.BottomRight() ) );
Rectangle aDesktop = pWin->GetDesktopRectPixel();
Size aSpace = pWin->LogicToPixel( Size( 8, 12 ), MAP_APPFONT );
ScDocument* pDoc = aViewData.GetDocument();
SCTAB nTab = aViewData.GetTabNo();
bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
bool bCenterHor = false;
if ( aDesktop.Bottom() - aObjAbs.Bottom() >= rDialogSize.Height() + aSpace.Height() )
{
// first preference: below the chart
aRet.Y() = aObjAbs.Bottom() + aSpace.Height();
bCenterHor = true;
}
else if ( aObjAbs.Top() - aDesktop.Top() >= rDialogSize.Height() + aSpace.Height() )
{
// second preference: above the chart
aRet.Y() = aObjAbs.Top() - rDialogSize.Height() - aSpace.Height();
bCenterHor = true;
}
else
{
bool bFitLeft = ( aObjAbs.Left() - aDesktop.Left() >= rDialogSize.Width() + aSpace.Width() );
bool bFitRight = ( aDesktop.Right() - aObjAbs.Right() >= rDialogSize.Width() + aSpace.Width() );
if ( bFitLeft || bFitRight )
{
// if both fit, prefer right in RTL mode, left otherwise
bool bPutRight = bFitRight && ( bLayoutRTL || !bFitLeft );
if ( bPutRight )
aRet.X() = aObjAbs.Right() + aSpace.Width();
else
aRet.X() = aObjAbs.Left() - rDialogSize.Width() - aSpace.Width();
// center vertically
aRet.Y() = aObjAbs.Top() + ( aObjAbs.GetHeight() - rDialogSize.Height() ) / 2;
}
else
{
// doesn't fit on any edge - put at the bottom of the screen
aRet.Y() = aDesktop.Bottom() - rDialogSize.Height();
bCenterHor = true;
}
}
if ( bCenterHor )
aRet.X() = aObjAbs.Left() + ( aObjAbs.GetWidth() - rDialogSize.Width() ) / 2;
// limit to screen (centering might lead to invalid positions)
if ( aRet.X() + rDialogSize.Width() - 1 > aDesktop.Right() )
aRet.X() = aDesktop.Right() - rDialogSize.Width() + 1;
if ( aRet.X() < aDesktop.Left() )
aRet.X() = aDesktop.Left();
if ( aRet.Y() + rDialogSize.Height() - 1 > aDesktop.Bottom() )
aRet.Y() = aDesktop.Bottom() - rDialogSize.Height() + 1;
if ( aRet.Y() < aDesktop.Top() )
aRet.Y() = aDesktop.Top();
}
return aRet;
}
void ScTabView::LockModifiers( sal_uInt16 nModifiers )
{
pSelEngine->LockModifiers( nModifiers );
pHdrSelEng->LockModifiers( nModifiers );
}
sal_uInt16 ScTabView::GetLockedModifiers() const
{
return pSelEngine->GetLockedModifiers();
}
Point ScTabView::GetMousePosPixel()
{
Point aPos;
ScGridWindow* pWin = (ScGridWindow*)GetActiveWin();
if ( pWin )
aPos = pWin->GetMousePosPixel();
return aPos;
}
static bool lcl_MouseIsOverWin( const Point& rScreenPosPixel, Window* pWin )
{
if (pWin)
{
// SPLIT_HANDLE_SIZE draufaddieren, damit das Einrasten genau
// auf dem Splitter nicht aussetzt
Point aRel = pWin->NormalizedScreenToOutputPixel( rScreenPosPixel );
Size aWinSize = pWin->GetOutputSizePixel();
if ( aRel.X() >= 0 && aRel.X() < aWinSize.Width() + SPLIT_HANDLE_SIZE &&
aRel.Y() >= 0 && aRel.Y() < aWinSize.Height() + SPLIT_HANDLE_SIZE )
return true;
}
return false;
}
void ScTabView::SnapSplitPos( Point& rScreenPosPixel )
{
bool bOverWin = false;
sal_uInt16 i;
for (i=0; i<4; i++)
if (lcl_MouseIsOverWin(rScreenPosPixel,pGridWin[i]))
bOverWin = true;
if (!bOverWin)
return;
// don't snap to cells if the scale will be modified afterwards
if ( GetZoomType() != SVX_ZOOM_PERCENT )
return;
ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
ePos = SC_SPLIT_TOPLEFT;
Window* pWin = pGridWin[ePos];
if (!pWin)
{
OSL_FAIL("Window NULL");
return;
}
Point aMouse = pWin->NormalizedScreenToOutputPixel( rScreenPosPixel );
SCsCOL nPosX;
SCsROW nPosY;
// bNextIfLarge=FALSE: nicht auf naechste Zelle, wenn ausserhalb des Fensters
aViewData.GetPosFromPixel( aMouse.X(), aMouse.Y(), ePos, nPosX, nPosY, true, false, false );
bool bLeft;
bool bTop;
aViewData.GetMouseQuadrant( aMouse, ePos, nPosX, nPosY, bLeft, bTop );
if (!bLeft)
++nPosX;
if (!bTop)
++nPosY;
aMouse = aViewData.GetScrPos( static_cast<SCCOL>(nPosX), static_cast<SCROW>(nPosY), ePos, true );
rScreenPosPixel = pWin->OutputToNormalizedScreenPixel( aMouse );
}
void ScTabView::FreezeSplitters( bool bFreeze )
{
ScSplitMode eOldH = aViewData.GetHSplitMode();
ScSplitMode eOldV = aViewData.GetVSplitMode();
ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
if ( eOldV != SC_SPLIT_NONE )
ePos = SC_SPLIT_TOPLEFT;
Window* pWin = pGridWin[ePos];
bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
if ( bFreeze )
{
Point aWinStart = pWin->GetPosPixel();
aViewData.GetDocShell()->SetDocumentModified();
Point aSplit;
SCsCOL nPosX;
SCsROW nPosY;
if (eOldH != SC_SPLIT_NONE || eOldV != SC_SPLIT_NONE)
{
if (eOldH != SC_SPLIT_NONE)
{
long nSplitPos = aViewData.GetHSplitPos();
if ( bLayoutRTL )
nSplitPos = pFrameWin->GetOutputSizePixel().Width() - nSplitPos - 1;
aSplit.X() = nSplitPos - aWinStart.X();
}
if (eOldV != SC_SPLIT_NONE)
aSplit.Y() = aViewData.GetVSplitPos() - aWinStart.Y();
aViewData.GetPosFromPixel( aSplit.X(), aSplit.Y(), ePos, nPosX, nPosY );
bool bLeft;
bool bTop;
aViewData.GetMouseQuadrant( aSplit, ePos, nPosX, nPosY, bLeft, bTop );
if (!bLeft)
++nPosX;
if (!bTop)
++nPosY;
}
else
{
nPosX = static_cast<SCsCOL>( aViewData.GetCurX());
nPosY = static_cast<SCsROW>( aViewData.GetCurY());
}
SCCOL nLeftPos = aViewData.GetPosX(SC_SPLIT_LEFT);
SCROW nTopPos = aViewData.GetPosY(SC_SPLIT_BOTTOM);
SCCOL nRightPos = static_cast<SCCOL>(nPosX);
SCROW nBottomPos = static_cast<SCROW>(nPosY);
if (eOldH != SC_SPLIT_NONE)
if (aViewData.GetPosX(SC_SPLIT_RIGHT) > nRightPos)
nRightPos = aViewData.GetPosX(SC_SPLIT_RIGHT);
if (eOldV != SC_SPLIT_NONE)
{
nTopPos = aViewData.GetPosY(SC_SPLIT_TOP);
if (aViewData.GetPosY(SC_SPLIT_BOTTOM) > nBottomPos)
nBottomPos = aViewData.GetPosY(SC_SPLIT_BOTTOM);
}
aSplit = aViewData.GetScrPos( static_cast<SCCOL>(nPosX), static_cast<SCROW>(nPosY), ePos, true );
if (nPosX > aViewData.GetPosX(SC_SPLIT_LEFT)) // (aSplit.X() > 0) doesn't work for RTL
{
long nSplitPos = aSplit.X() + aWinStart.X();
if ( bLayoutRTL )
nSplitPos = pFrameWin->GetOutputSizePixel().Width() - nSplitPos - 1;
aViewData.SetHSplitMode( SC_SPLIT_FIX );
aViewData.SetHSplitPos( nSplitPos );
aViewData.SetFixPosX( nPosX );
aViewData.SetPosX(SC_SPLIT_LEFT, nLeftPos);
aViewData.SetPosX(SC_SPLIT_RIGHT, nRightPos);
}
else
aViewData.SetHSplitMode( SC_SPLIT_NONE );
if (aSplit.Y() > 0)
{
aViewData.SetVSplitMode( SC_SPLIT_FIX );
aViewData.SetVSplitPos( aSplit.Y() + aWinStart.Y() );
aViewData.SetFixPosY( nPosY );
aViewData.SetPosY(SC_SPLIT_TOP, nTopPos);
aViewData.SetPosY(SC_SPLIT_BOTTOM, nBottomPos);
}
else
aViewData.SetVSplitMode( SC_SPLIT_NONE );
}
else // Fixierung aufheben
{
if ( eOldH == SC_SPLIT_FIX )
aViewData.SetHSplitMode( SC_SPLIT_NORMAL );
if ( eOldV == SC_SPLIT_FIX )
aViewData.SetVSplitMode( SC_SPLIT_NORMAL );
}
// Form-Layer muss den sichtbaren Ausschnitt aller Fenster 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();
RepeatResize(false);
UpdateShow();
PaintLeft();
PaintTop();
PaintGrid();
// SC_FOLLOW_NONE: only update active part
AlignToCursor( aViewData.GetCurX(), aViewData.GetCurY(), SC_FOLLOW_NONE );
UpdateAutoFillMark();
InvalidateSplit();
}
void ScTabView::RemoveSplit()
{
DoHSplit( 0 );
DoVSplit( 0 );
RepeatResize();
}
void ScTabView::SplitAtCursor()
{
ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
ePos = SC_SPLIT_TOPLEFT;
Window* pWin = pGridWin[ePos];
Point aWinStart = pWin->GetPosPixel();
SCCOL nPosX = aViewData.GetCurX();
SCROW nPosY = aViewData.GetCurY();
Point aSplit = aViewData.GetScrPos( nPosX, nPosY, ePos, true );
if ( nPosX > 0 )
DoHSplit( aSplit.X() + aWinStart.X() );
else
DoHSplit( 0 );
if ( nPosY > 0 )
DoVSplit( aSplit.Y() + aWinStart.Y() );
else
DoVSplit( 0 );
RepeatResize();
}
void ScTabView::SplitAtPixel( const Point& rPixel, bool bHor, bool bVer )
{
// Pixel ist auf die ganze View bezogen, nicht auf das erste GridWin
if (bHor)
{
if ( rPixel.X() > 0 )
DoHSplit( rPixel.X() );
else
DoHSplit( 0 );
}
if (bVer)
{
if ( rPixel.Y() > 0 )
DoVSplit( rPixel.Y() );
else
DoVSplit( 0 );
}
RepeatResize();
}
void ScTabView::InvalidateSplit()
{
SfxBindings& rBindings = aViewData.GetBindings();
rBindings.Invalidate( SID_WINDOW_SPLIT );
rBindings.Invalidate( SID_WINDOW_FIX );
pHSplitter->SetFixed( aViewData.GetHSplitMode() == SC_SPLIT_FIX );
pVSplitter->SetFixed( aViewData.GetVSplitMode() == SC_SPLIT_FIX );
}
void ScTabView::SetNewVisArea()
{
// fuer die Controls muss bei VisAreaChanged der Draw-MapMode eingestellt sein
// (auch wenn ansonsten der Edit-MapMode gesetzt ist)
MapMode aOldMode[4];
MapMode aDrawMode[4];
sal_uInt16 i;
for (i=0; i<4; i++)
if (pGridWin[i])
{
aOldMode[i] = pGridWin[i]->GetMapMode();
aDrawMode[i] = pGridWin[i]->GetDrawMapMode();
if (aDrawMode[i] != aOldMode[i])
pGridWin[i]->SetMapMode(aDrawMode[i]);
}
Window* pActive = pGridWin[aViewData.GetActivePart()];
if (pActive)
aViewData.GetViewShell()->VisAreaChanged(
pActive->PixelToLogic(Rectangle(Point(),pActive->GetOutputSizePixel())) );
if (pDrawView)
pDrawView->VisAreaChanged(); // kein Window uebergeben -> alle Fenster
UpdateAllOverlays(); // #i79909# with drawing MapMode set
for (i=0; i<4; i++)
if (pGridWin[i] && aDrawMode[i] != aOldMode[i])
{
pGridWin[i]->flushOverlayManager(); // #i79909# flush overlays before switching to edit MapMode
pGridWin[i]->SetMapMode(aOldMode[i]);
}
SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
if (pViewFrame)
{
SfxFrame& rFrame = pViewFrame->GetFrame();
com::sun::star::uno::Reference<com::sun::star::frame::XController> xController = rFrame.GetController();
if (xController.is())
{
ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
if (pImp)
pImp->VisAreaChanged();
}
}
if (aViewData.GetViewShell()->HasAccessibilityObjects())
aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_VISAREACHANGED));
}
bool ScTabView::HasPageFieldDataAtCursor() const
{
ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
SCCOL nCol = aViewData.GetCurX();
SCROW nRow = aViewData.GetCurY();
if (pWin)
return pWin->GetDPFieldOrientation( nCol, nRow ) == sheet::DataPilotFieldOrientation_PAGE;
return false;
}
void ScTabView::StartDataSelect()
{
ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
SCCOL nCol = aViewData.GetCurX();
SCROW nRow = aViewData.GetCurY();
if (!pWin)
return;
switch (pWin->GetDPFieldOrientation(nCol, nRow))
{
case sheet::DataPilotFieldOrientation_PAGE:
// #i36598# If the cursor is on a page field's data cell,
// no meaningful input is possible anyway, so this function
// can be used to select a page field entry.
pWin->LaunchPageFieldMenu( nCol, nRow );
return;
case sheet::DataPilotFieldOrientation_COLUMN:
case sheet::DataPilotFieldOrientation_ROW:
pWin->LaunchDPFieldMenu( nCol, nRow );
return;
default:
;
}
// Do autofilter if the current cell has autofilter button. Otherwise do
// a normal data select popup.
const ScMergeFlagAttr* pAttr = static_cast<const ScMergeFlagAttr*>(
aViewData.GetDocument()->GetAttr(
nCol, nRow, aViewData.GetTabNo(), ATTR_MERGE_FLAG));
if (pAttr->HasAutoFilter())
pWin->LaunchAutoFilterMenu(nCol, nRow);
else
pWin->LaunchDataSelectMenu(nCol, nRow, true);
}
void ScTabView::EnableRefInput(bool bFlag)
{
aHScrollLeft.EnableInput(bFlag);
aHScrollRight.EnableInput(bFlag);
aVScrollBottom.EnableInput(bFlag);
aVScrollTop.EnableInput(bFlag);
aScrollBarBox.EnableInput(bFlag);
// ab hier dynamisch angelegte
if(pTabControl!=NULL) pTabControl->EnableInput(bFlag,true);
if(pGridWin[SC_SPLIT_BOTTOMLEFT]!=NULL)
pGridWin[SC_SPLIT_BOTTOMLEFT]->EnableInput(bFlag,false);
if(pGridWin[SC_SPLIT_BOTTOMRIGHT]!=NULL)
pGridWin[SC_SPLIT_BOTTOMRIGHT]->EnableInput(bFlag,false);
if(pGridWin[SC_SPLIT_TOPLEFT]!=NULL)
pGridWin[SC_SPLIT_TOPLEFT]->EnableInput(bFlag,false);
if(pGridWin[SC_SPLIT_TOPRIGHT]!=NULL)
pGridWin[SC_SPLIT_TOPRIGHT]->EnableInput(bFlag,false);
if(pColBar[SC_SPLIT_RIGHT]!=NULL)
pColBar[SC_SPLIT_RIGHT]->EnableInput(bFlag,false);
if(pRowBar[SC_SPLIT_TOP]!=NULL)
pRowBar[SC_SPLIT_TOP]->EnableInput(bFlag,false);
}
void ScTabView::SetInRefMode( bool bRefMode )
{
if(pGridWin[SC_SPLIT_BOTTOMLEFT])
pGridWin[SC_SPLIT_BOTTOMLEFT]->SetInRefMode( bRefMode );
if(pGridWin[SC_SPLIT_BOTTOMRIGHT])
pGridWin[SC_SPLIT_BOTTOMRIGHT]->SetInRefMode( bRefMode );
if(pGridWin[SC_SPLIT_TOPLEFT])
pGridWin[SC_SPLIT_TOPLEFT]->SetInRefMode( bRefMode );
if(pGridWin[SC_SPLIT_TOPRIGHT])
pGridWin[SC_SPLIT_TOPRIGHT]->SetInRefMode( bRefMode );
}
bool ScTabView::ContinueOnlineSpelling()
{
bool bChanged = false;
for (int i = 0; i < 4; ++i)
{
if (!pGridWin[i] || !pGridWin[i]->IsVisible())
continue;
if (pGridWin[i]->ContinueOnlineSpelling())
bChanged = true;
}
return bChanged;
}
void ScTabView::EnableAutoSpell( bool bEnable )
{
for (int i = 0; i < 4; ++i)
{
if (!pGridWin[i])
continue;
pGridWin[i]->EnableAutoSpell(bEnable);
}
}
void ScTabView::ResetAutoSpell()
{
for (int i = 0; i < 4; ++i)
{
if (!pGridWin[i])
continue;
pGridWin[i]->ResetAutoSpell();
}
}
void ScTabView::SetAutoSpellData( SCCOL nPosX, SCROW nPosY, const std::vector<editeng::MisspellRanges>* pRanges )
{
for (int i = 0; i < 4; ++i)
{
if (!pGridWin[i])
continue;
pGridWin[i]->SetAutoSpellData(nPosX, nPosY, pRanges);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|