1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
|
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx"
#include <boost/scoped_ptr.hpp>
#include "com/sun/star/frame/XComponentLoader.hpp"
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/document/XEventsSupplier.hpp>
#include <com/sun/star/drawing/XMasterPageTarget.hpp>
#include <com/sun/star/container/XNameReplace.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/awt/SystemPointer.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <vos/process.hxx>
#include <svl/aeitem.hxx>
#include <svl/urihelper.hxx>
#include <toolkit/unohlp.hxx>
#include <sfx2/imagemgr.hxx>
#include <sfx2/request.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/app.hxx>
#include <svx/unoapi.hxx>
#include <svx/svdoole2.hxx>
// for child window ids
#include <sfx2/templdlg.hxx>
#include <svx/f3dchild.hxx>
#include <svx/imapdlg.hxx>
#include <svx/fontwork.hxx>
#include <svx/colrctrl.hxx>
#include <svx/bmpmask.hxx>
#include <svx/srchdlg.hxx>
#include <svx/hyprlink.hxx>
#include <svx/hyperdlg.hxx>
#include <svx/galbrws.hxx>
#include "NavigatorChildWindow.hxx"
#include "AnimationChildWindow.hxx"
#include <slideshowimpl.hxx>
#include <slideshowviewimpl.hxx>
#include <pgjump.hxx>
#include "PaneHider.hxx"
#include "glob.hrc"
#include "res_bmp.hrc"
#include "sdresid.hxx"
#include "vcl/canvastools.hxx"
#include "comphelper/anytostring.hxx"
#include "cppuhelper/exc_hlp.hxx"
#include "rtl/ref.hxx"
#include "slideshow.hrc"
#include "canvas/elapsedtime.hxx"
#include "canvas/prioritybooster.hxx"
#include "avmedia/mediawindow.hxx"
#include "svtools/colrdlg.hxx"
#include <boost/noncopyable.hpp>
#include <boost/bind.hpp>
using ::rtl::OUString;
using ::rtl::OString;
using ::cppu::OInterfaceContainerHelper;
using ::comphelper::ImplementationReference;
using ::com::sun::star::animations::XAnimationNode;
using ::com::sun::star::animations::XAnimationListener;
using ::com::sun::star::awt::XWindow;
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::document;
using namespace ::com::sun::star::presentation;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::beans;
extern void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName );
extern String getUiNameFromPageApiNameImpl( const OUString& rApiName );
namespace sd
{
///////////////////////////////////////////////////////////////////////
// Slots, welche im Sfx verwaltet werden und in der SlideShow disabled
// werden sollen (muss in Reihenfolge der SIDs geordnet sein)
static USHORT __READONLY_DATA pAllowed[] =
{
SID_OPENDOC , // 5501 // damit interne Spruenge klappen
SID_JUMPTOMARK , // 5598
// SID_SHOWPOPUPS , // 5929
// SID_GALLERY , // 5960
SID_OPENHYPERLINK , // 6676
// SID_GALLERY_FORMATS , // 10280
SID_NAVIGATOR , // 10366
// SID_FM_DESIGN_MODE , // 10629
SID_PRESENTATION_END , // 27218
SID_NAVIGATOR_PAGENAME , // 27287
SID_NAVIGATOR_STATE , // 27288
SID_NAVIGATOR_INIT , // 27289
SID_NAVIGATOR_PEN , // 27291
SID_NAVIGATOR_PAGE , // 27292
SID_NAVIGATOR_OBJECT // 27293
};
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// AnimationSlideController
///////////////////////////////////////////////////////////////////////
class AnimationSlideController
{
public:
enum Mode { ALL, FROM, CUSTOM, PREVIEW };
public:
AnimationSlideController( Reference< XIndexAccess > xSlides, Mode eMode );
void setStartSlideNumber( sal_Int32 nSlideNumber ) { mnStartSlideNumber = nSlideNumber; }
sal_Int32 getStartSlideIndex() const;
sal_Int32 getCurrentSlideNumber() const;
sal_Int32 getCurrentSlideIndex() const;
sal_Int32 getSlideIndexCount() const { return maSlideNumbers.size(); }
sal_Int32 getSlideNumberCount() const { return mnSlideCount; }
sal_Int32 getSlideNumber( sal_Int32 nSlideIndex ) const;
void insertSlideNumber( sal_Int32 nSlideNumber, bool bVisible = true );
void setPreviewNode( const Reference< XAnimationNode >& xPreviewNode );
bool jumpToSlideIndex( sal_Int32 nNewSlideIndex );
bool jumpToSlideNumber( sal_Int32 nNewSlideIndex );
bool nextSlide();
bool previousSlide();
void displayCurrentSlide( const Reference< XSlideShow >& xShow,
const Reference< XDrawPagesSupplier>& xDrawPages,
const bool bSkipAllMainSequenceEffects );
sal_Int32 getNextSlideIndex() const;
sal_Int32 getPreviousSlideIndex() const;
bool isVisibleSlideNumber( sal_Int32 nSlideNumber ) const;
Reference< XDrawPage > getSlideByNumber( sal_Int32 nSlideNumber ) const;
sal_Int32 getNextSlideNumber() const;
bool hasSlides() const { return !maSlideNumbers.empty(); }
private:
bool getSlideAPI( sal_Int32 nSlideNumber, Reference< XDrawPage >& xSlide, Reference< XAnimationNode >& xAnimNode );
sal_Int32 findSlideIndex( sal_Int32 nSlideNumber ) const;
bool isValidIndex( sal_Int32 nIndex ) const { return (nIndex >= 0) && (nIndex < (sal_Int32)maSlideNumbers.size()); }
bool isValidSlideNumber( sal_Int32 nSlideNumber ) const { return (nSlideNumber >= 0) && (nSlideNumber < mnSlideCount); }
private:
Mode meMode;
sal_Int32 mnStartSlideNumber;
std::vector< sal_Int32 > maSlideNumbers;
std::vector< bool > maSlideVisible;
std::vector< bool > maSlideVisited;
Reference< XAnimationNode > mxPreviewNode;
sal_Int32 mnSlideCount;
sal_Int32 mnCurrentSlideIndex;
sal_Int32 mnHiddenSlideNumber;
Reference< XIndexAccess > mxSlides;
};
Reference< XDrawPage > AnimationSlideController::getSlideByNumber( sal_Int32 nSlideNumber ) const
{
Reference< XDrawPage > xSlide;
if( mxSlides.is() && (nSlideNumber >= 0) && (nSlideNumber < mxSlides->getCount()) )
mxSlides->getByIndex( nSlideNumber ) >>= xSlide;
return xSlide;
}
bool AnimationSlideController::isVisibleSlideNumber( sal_Int32 nSlideNumber ) const
{
sal_Int32 nIndex = findSlideIndex( nSlideNumber );
if( nIndex != -1 )
return maSlideVisible[ nIndex ];
else
return false;
}
void AnimationSlideController::setPreviewNode( const Reference< XAnimationNode >& xPreviewNode )
{
mxPreviewNode = xPreviewNode;
}
AnimationSlideController::AnimationSlideController( Reference< XIndexAccess > xSlides, Mode eMode )
: meMode( eMode )
, mnStartSlideNumber(-1)
, mnSlideCount( 0 )
, mnCurrentSlideIndex(0)
, mnHiddenSlideNumber( -1 )
, mxSlides( xSlides )
{
if( mxSlides.is() )
mnSlideCount = xSlides->getCount();
}
sal_Int32 AnimationSlideController::getStartSlideIndex() const
{
if( mnStartSlideNumber >= 0 )
{
sal_Int32 nIndex;
const sal_Int32 nCount = maSlideNumbers.size();
for( nIndex = 0; nIndex < nCount; nIndex++ )
{
if( maSlideNumbers[nIndex] == mnStartSlideNumber )
return nIndex;
}
}
return 0;
}
sal_Int32 AnimationSlideController::getCurrentSlideNumber() const
{
if( mnHiddenSlideNumber != -1 )
return mnHiddenSlideNumber;
else if( !maSlideNumbers.empty() )
return maSlideNumbers[mnCurrentSlideIndex];
else
return 0;
}
sal_Int32 AnimationSlideController::getCurrentSlideIndex() const
{
if( mnHiddenSlideNumber != -1 )
return -1;
else
return mnCurrentSlideIndex;
}
bool AnimationSlideController::jumpToSlideIndex( sal_Int32 nNewSlideIndex )
{
if( isValidIndex( nNewSlideIndex ) )
{
mnCurrentSlideIndex = nNewSlideIndex;
mnHiddenSlideNumber = -1;
maSlideVisited[mnCurrentSlideIndex] = true;
return true;
}
else
{
return false;
}
}
bool AnimationSlideController::jumpToSlideNumber( sal_Int32 nNewSlideNumber )
{
sal_Int32 nIndex = findSlideIndex( nNewSlideNumber );
if( isValidIndex( nIndex ) )
{
return jumpToSlideIndex( nIndex );
}
else if( (nNewSlideNumber >= 0) && (nNewSlideNumber < mnSlideCount) )
{
// jump to a hidden slide
mnHiddenSlideNumber = nNewSlideNumber;
return true;
}
else
{
return false;
}
}
sal_Int32 AnimationSlideController::getSlideNumber( sal_Int32 nSlideIndex ) const
{
if( isValidIndex( nSlideIndex ) )
return maSlideNumbers[nSlideIndex];
else
return -1;
}
void AnimationSlideController::insertSlideNumber( sal_Int32 nSlideNumber, bool bVisible /* = true */ )
{
DBG_ASSERT( isValidSlideNumber( nSlideNumber ), "sd::AnimationSlideController::insertSlideNumber(), illegal index" );
if( isValidSlideNumber( nSlideNumber ) )
{
maSlideNumbers.push_back( nSlideNumber );
maSlideVisible.push_back( bVisible );
maSlideVisited.push_back( false );
}
}
bool AnimationSlideController::getSlideAPI( sal_Int32 nSlideNumber, Reference< XDrawPage >& xSlide, Reference< XAnimationNode >& xAnimNode )
{
if( isValidSlideNumber( nSlideNumber ) ) try
{
xSlide = Reference< XDrawPage >( mxSlides->getByIndex(nSlideNumber), UNO_QUERY_THROW );
if( meMode == PREVIEW )
{
xAnimNode = mxPreviewNode;
}
else
{
Reference< animations::XAnimationNodeSupplier > xAnimNodeSupplier( xSlide, UNO_QUERY_THROW );
xAnimNode = xAnimNodeSupplier->getAnimationNode();
}
return true;
}
catch( Exception& e )
{
(void)e;
DBG_ERROR(
(OString("sd::AnimationSlideController::getSlideAPI(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
return false;
}
sal_Int32 AnimationSlideController::findSlideIndex( sal_Int32 nSlideNumber ) const
{
sal_Int32 nIndex;
const sal_Int32 nCount = maSlideNumbers.size();
for( nIndex = 0; nIndex < nCount; nIndex++ )
{
if( maSlideNumbers[nIndex] == nSlideNumber )
return nIndex;
}
return -1;
}
sal_Int32 AnimationSlideController::getNextSlideIndex() const
{
switch( meMode )
{
case ALL:
{
sal_Int32 nNewSlideIndex = mnCurrentSlideIndex + 1;
if( isValidIndex( nNewSlideIndex ) )
{
// if the current slide is not excluded, make sure the
// next slide is also not excluded.
// if the current slide is excluded, we want to go
// to the next slide, even if this is also excluded.
if( maSlideVisible[mnCurrentSlideIndex] )
{
while( isValidIndex( nNewSlideIndex ) )
{
if( maSlideVisible[nNewSlideIndex] )
break;
nNewSlideIndex++;
}
}
}
return isValidIndex( nNewSlideIndex ) ? nNewSlideIndex : -1;
}
case FROM:
case CUSTOM:
return mnHiddenSlideNumber == -1 ? mnCurrentSlideIndex + 1 : mnCurrentSlideIndex;
default:
case PREVIEW:
return -1;
}
}
sal_Int32 AnimationSlideController::getNextSlideNumber() const
{
sal_Int32 nNextSlideIndex = getNextSlideIndex();
if( isValidIndex( nNextSlideIndex ) )
{
return maSlideNumbers[nNextSlideIndex];
}
else
{
return -1;
}
}
bool AnimationSlideController::nextSlide()
{
return jumpToSlideIndex( getNextSlideIndex() );
}
sal_Int32 AnimationSlideController::getPreviousSlideIndex() const
{
sal_Int32 nNewSlideIndex = mnCurrentSlideIndex - 1;
switch( meMode )
{
case ALL:
{
// make sure the previous slide is visible
// or was already visited
while( isValidIndex( nNewSlideIndex ) )
{
if( maSlideVisible[nNewSlideIndex] || maSlideVisited[nNewSlideIndex] )
break;
nNewSlideIndex--;
}
break;
}
case PREVIEW:
return -1;
default:
break;
}
return nNewSlideIndex;
}
bool AnimationSlideController::previousSlide()
{
return jumpToSlideIndex( getPreviousSlideIndex() );
}
void AnimationSlideController::displayCurrentSlide( const Reference< XSlideShow >& xShow,
const Reference< XDrawPagesSupplier>& xDrawPages,
const bool bSkipAllMainSequenceEffects )
{
const sal_Int32 nCurrentSlideNumber = getCurrentSlideNumber();
if( xShow.is() && (nCurrentSlideNumber != -1 ) )
{
Reference< XDrawPage > xSlide;
Reference< XAnimationNode > xAnimNode;
::std::vector<PropertyValue> aProperties;
const sal_Int32 nNextSlideNumber = getNextSlideNumber();
if( getSlideAPI( nNextSlideNumber, xSlide, xAnimNode ) )
{
Sequence< Any > aValue(2);
aValue[0] <<= xSlide;
aValue[1] <<= xAnimNode;
aProperties.push_back(
PropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM( "Prefetch" ) ),
-1,
Any(aValue),
PropertyState_DIRECT_VALUE));
}
if (bSkipAllMainSequenceEffects)
{
// Add one property that prevents the slide transition from being
// shown (to speed up the transition to the previous slide) and
// one to show all main sequence effects so that the user can
// continue to undo effects.
aProperties.push_back(
PropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("SkipAllMainSequenceEffects")),
-1,
Any(sal_True),
PropertyState_DIRECT_VALUE));
aProperties.push_back(
PropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("SkipSlideTransition")),
-1,
Any(sal_True),
PropertyState_DIRECT_VALUE));
}
// Convert vector into uno Sequence.
Sequence< PropertyValue > aPropertySequence (aProperties.size());
for (int nIndex=0,nCount=aProperties.size();nIndex<nCount; ++nIndex)
aPropertySequence[nIndex] = aProperties[nIndex];
if( getSlideAPI( nCurrentSlideNumber, xSlide, xAnimNode ) )
xShow->displaySlide( xSlide, xDrawPages, xAnimNode, aPropertySequence );
}
}
///////////////////////////////////////////////////////////////////////
// class SlideshowImpl
///////////////////////////////////////////////////////////////////////
SlideshowImpl::SlideshowImpl( const Reference< XPresentation2 >& xPresentation, ViewShell* pViewSh, ::sd::View* pView, SdDrawDocument* pDoc, ::Window* pParentWindow )
: SlideshowImplBase( m_aMutex )
, mxModel(pDoc->getUnoModel(),UNO_QUERY_THROW)
, mpView(pView)
, mpViewShell(pViewSh)
, mpDocSh(pDoc->GetDocSh())
, mpDoc(pDoc)
, mpNewAttr(0)
, mpParentWindow(pParentWindow)
, mpShowWindow(0)
, mpTimeButton(0)
, mnRestoreSlide(0)
, maPresSize( -1, -1 )
, meAnimationMode(ANIMATIONMODE_SHOW)
, mpOldActiveWindow(0)
, mnChildMask( 0 )
, mbGridVisible(false)
, mbBordVisible(false)
, mbSlideBorderVisible(false)
, mbSetOnlineSpelling(false)
, mbDisposed(false)
, mbRehearseTimings(false)
, mbDesignMode(false)
, mbIsPaused(false)
, mbInputFreeze(false)
, mbActive(sal_False)
, maPresSettings( pDoc->getPresentationSettings() )
, mnUserPaintColor( 0x00000000L ) //User paint color is Black by default
#ifdef ENABLE_PRESENTER_EXTRA_UI
, mbSwitchPenMode(true)
, mbSwitchEraserMode(false)
, mdUserPaintStrokeWidth ( 4.0 )
, mbEraseAllInk(false)
//, mbEraseInk(false)
, mnEraseInkSize(100)
#endif
, mnEntryCounter(0)
, mnLastSlideNumber(-1)
, msOnClick( RTL_CONSTASCII_USTRINGPARAM("OnClick") )
, msBookmark( RTL_CONSTASCII_USTRINGPARAM("Bookmark") )
, msVerb( RTL_CONSTASCII_USTRINGPARAM("Verb") )
, mnEndShowEvent(0)
, mnContextMenuEvent(0)
, mnUpdateEvent(0)
, mxPresentation( xPresentation )
{
if( mpViewShell )
mpOldActiveWindow = mpViewShell->GetActiveWindow();
maUpdateTimer.SetTimeoutHdl(LINK(this, SlideshowImpl, updateHdl));
maDeactivateTimer.SetTimeoutHdl(LINK(this, SlideshowImpl, deactivateHdl));
maDeactivateTimer.SetTimeout( 20 );
maInputFreezeTimer.SetTimeoutHdl( LINK( this, SlideshowImpl, ReadyForNextInputHdl ) );
maInputFreezeTimer.SetTimeout( 20 );
SvtSaveOptions aOptions;
// no autosave during show
if( aOptions.IsAutoSave() )
mbAutoSaveWasOn = true;
Application::AddEventListener( LINK( this, SlideshowImpl, EventListenerHdl ) );
}
SlideshowImpl::~SlideshowImpl()
{
Application::RemoveEventListener( LINK( this, SlideshowImpl, EventListenerHdl ) );
maDeactivateTimer.Stop();
if( !mbDisposed )
{
DBG_ERROR("SlideshowImpl::~SlideshowImpl(), component was not disposed!");
disposing();
}
}
void SAL_CALL SlideshowImpl::disposing()
{
if( mxShow.is() && mpDoc )
NotifyDocumentEvent( mpDoc, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OnEndPresentation") ) );
if( mbAutoSaveWasOn )
setAutoSaveState( true );
if( mnEndShowEvent )
Application::RemoveUserEvent( mnEndShowEvent );
if( mnContextMenuEvent )
Application::RemoveUserEvent( mnContextMenuEvent );
maInputFreezeTimer.Stop();
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( !mxShow.is() )
return;
if( mxPresentation.is() )
mxPresentation->end();
maUpdateTimer.Stop();
if( mnUpdateEvent )
{
Application::RemoveUserEvent( mnUpdateEvent );
mnUpdateEvent = 0;
}
removeShapeEvents();
if( mxListenerProxy.is() )
mxListenerProxy->removeAsSlideShowListener();
try
{
if( mxView.is() )
mxShow->removeView( mxView.getRef() );
Reference< XComponent > xComponent( mxShow, UNO_QUERY );
if( xComponent.is() )
xComponent->dispose();
if( mxView.is() )
mxView->dispose();
}
catch( Exception& e )
{
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::stop(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
mxShow.clear();
mxView.reset();
mxListenerProxy.clear();
mpSlideController.reset();
// der DrawView das Praesentationfenster wegnehmen und ihr dafuer ihre alten Fenster wiedergeben
if( mpShowWindow && mpView )
mpView->DeleteWindowFromPaintView( mpShowWindow );
if( mpView )
mpView->SetAnimationPause( FALSE );
if( mpViewShell )
{
mpViewShell->SetActiveWindow(mpOldActiveWindow);
mpShowWindow->SetViewShell( NULL );
}
if( mpView )
mpView->InvalidateAllWin();
if( maPresSettings.mbFullScreen )
{
// restore StarBASICErrorHdl
StarBASIC::SetGlobalErrorHdl(maStarBASICGlobalErrorHdl);
maStarBASICGlobalErrorHdl = Link();
}
else
{
if( mpShowWindow )
mpShowWindow->Hide();
}
if( meAnimationMode == ANIMATIONMODE_SHOW )
{
mpDocSh->SetSlotFilter();
mpDocSh->ApplySlotFilter();
Help::EnableContextHelp();
Help::EnableExtHelp();
showChildWindows();
mnChildMask = 0UL;
}
// aktuelle Fenster wieder einblenden
if( mpViewShell && !mpViewShell->ISA(PresentationViewShell))
{
if( meAnimationMode == ANIMATIONMODE_SHOW )
{
mpViewShell->GetViewShellBase().ShowUIControls (true);
mpPaneHider.reset();
}
else if( meAnimationMode == ANIMATIONMODE_PREVIEW )
{
mpViewShell->ShowUIControls (true);
}
}
if( mpTimeButton )
{
mpTimeButton->Hide();
delete mpTimeButton;
mpTimeButton = 0;
}
if( mpShowWindow )
mpShowWindow->Hide();
if ( mpViewShell )
{
if( meAnimationMode == ANIMATIONMODE_SHOW )
{
::sd::Window* pActWin = mpViewShell->GetActiveWindow();
if (pActWin)
{
Size aVisSizePixel = pActWin->GetOutputSizePixel();
Rectangle aVisAreaWin = pActWin->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
mpViewShell->VisAreaChanged(aVisAreaWin);
mpView->VisAreaChanged(pActWin);
pActWin->GrabFocus();
}
}
// restart the custom show dialog if he started us
if( mpViewShell->IsStartShowWithDialog() && getDispatcher() )
{
mpViewShell->SetStartShowWithDialog( FALSE );
getDispatcher()->Execute( SID_CUSTOMSHOW_DLG, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
}
mpViewShell->GetViewShellBase().UpdateBorder(true);
}
if( mpShowWindow )
{
delete mpShowWindow;
mpShowWindow = 0;
}
setActiveXToolbarsVisible( sal_True );
Application::EnableNoYieldMode(false);
Application::RemovePostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
mbDisposed = true;
}
bool SlideshowImpl::startPreview(
const Reference< XDrawPage >& xDrawPage,
const Reference< XAnimationNode >& xAnimationNode,
::Window* pParent )
{
bool bRet = false;
try
{
const Reference<lang::XServiceInfo> xServiceInfo( xDrawPage, UNO_QUERY );
if (xServiceInfo.is()) {
const Sequence<OUString> supportedServices(
xServiceInfo->getSupportedServiceNames() );
for ( sal_Int32 pos = supportedServices.getLength(); pos--; ) {
if (supportedServices[pos].equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM(
"com.sun.star.drawing.MasterPage") )) {
DBG_ERROR("sd::SlideshowImpl::startPreview() "
"not allowed on master page!");
return false;
}
}
}
mxPreviewDrawPage = xDrawPage;
mxPreviewAnimationNode = xAnimationNode;
meAnimationMode = ANIMATIONMODE_PREVIEW;
maPresSettings.mbAll = sal_False;
maPresSettings.mbEndless = sal_False;
maPresSettings.mbCustomShow = sal_False;
maPresSettings.mbManual = sal_False;
maPresSettings.mbMouseVisible = sal_False;
maPresSettings.mbMouseAsPen = sal_False;
maPresSettings.mbLockedPages = sal_False;
maPresSettings.mbAlwaysOnTop = sal_False;
maPresSettings.mbFullScreen = sal_False;
maPresSettings.mbAnimationAllowed = sal_True;
maPresSettings.mnPauseTimeout = 0;
maPresSettings.mbShowPauseLogo = sal_False;
maPresSettings.mbStartWithNavigator = sal_False;
Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(), UNO_QUERY_THROW );
Reference< XIndexAccess > xSlides( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
mpSlideController.reset( new AnimationSlideController( xSlides, AnimationSlideController::PREVIEW ) );
sal_Int32 nSlideNumber = 0;
Reference< XPropertySet > xSet( mxPreviewDrawPage, UNO_QUERY_THROW );
xSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Number" ) ) ) >>= nSlideNumber;
mpSlideController->insertSlideNumber( nSlideNumber-1 );
mpSlideController->setPreviewNode( xAnimationNode );
mpShowWindow = new ShowWindow( this, ((pParent == 0) && mpViewShell) ? mpParentWindow : pParent );
if( mpViewShell )
{
mpViewShell->SetActiveWindow( mpShowWindow );
mpShowWindow->SetViewShell (mpViewShell);
mpViewShell->ShowUIControls (false);
}
if( mpView )
{
mpView->AddWindowToPaintView( mpShowWindow );
mpView->SetAnimationPause( TRUE );
}
// call resize handler
if( pParent )
{
maPresSize = pParent->GetSizePixel();
}
else if( mpViewShell )
{
Rectangle aContentRect (mpViewShell->GetViewShellBase().getClientRectangle());
if (Application::GetSettings().GetLayoutRTL())
{
aContentRect.nLeft = aContentRect.nRight;
aContentRect.nRight += aContentRect.nRight;
}
maPresSize = aContentRect.GetSize();
mpShowWindow->SetPosPixel( aContentRect.TopLeft() );
}
else
{
DBG_ERROR("sd::SlideshowImpl::startPreview(), I need either a parent window or a viewshell!");
}
resize( maPresSize );
sal_Int32 nPropertyCount = 1;
if( mxPreviewAnimationNode.is() )
nPropertyCount++;
Sequence< beans::PropertyValue > aProperties(nPropertyCount);
aProperties[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("AutomaticAdvancement") );
aProperties[0].Value = uno::makeAny( (double)1.0 ); // one second timeout
if( mxPreviewAnimationNode.is() )
{
aProperties[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("NoSlideTransitions") );
aProperties[1].Value = uno::makeAny( sal_True );
}
bRet = startShowImpl( aProperties );
if( mpShowWindow != 0 && meAnimationMode == ANIMATIONMODE_PREVIEW )
mpShowWindow->SetPreviewMode();
}
catch( Exception& e )
{
(void)e;
DBG_ERROR(
(OString("sd::SlideshowImpl::startPreview(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
bRet = false;
}
return bRet;
}
bool SlideshowImpl::startShow( PresentationSettingsEx* pPresSettings )
{
const rtl::Reference<SlideshowImpl> this_(this);
DBG_ASSERT( !mxShow.is(), "sd::SlideshowImpl::startShow(), called twice!" );
if( mxShow.is() )
return true;
DBG_ASSERT( mpParentWindow!=NULL, "sd::SlideshowImpl::startShow() called without parent window" );
if (mpParentWindow == NULL)
return false;
bool bRet = false;
try
{
if( pPresSettings )
{
maPresSettings = *pPresSettings;
mbRehearseTimings = pPresSettings->mbRehearseTimings;
}
// ---
String aPresSlide( maPresSettings.maPresPage );
SdPage* pStartPage = mpViewShell ? mpViewShell->GetActualPage() : 0;
bool bStartWithActualSlide = pStartPage &&
( (meAnimationMode != ANIMATIONMODE_SHOW) ||
SD_MOD()->GetSdOptions( mpDoc->GetDocumentType() )->IsStartWithActualPage() );
// sollen Zeiten gestoppt werden?
if( mbRehearseTimings )
{
maPresSettings.mbEndless = sal_False;
maPresSettings.mbManual = sal_True;
maPresSettings.mbMouseVisible = sal_True;
maPresSettings.mbMouseAsPen = sal_False;
maPresSettings.mnPauseTimeout = 0;
maPresSettings.mbShowPauseLogo = sal_False;
maPresSettings.mbStartWithNavigator = sal_False;
}
if( pStartPage )
{
if( pStartPage->GetPageKind() == PK_NOTES )
{
// we are in notes page mode, so get
// the corresponding draw page
const USHORT nPgNum = ( pStartPage->GetPageNum() - 2 ) >> 1;
pStartPage = mpDoc->GetSdPage( nPgNum, PK_STANDARD );
}
}
if( bStartWithActualSlide )
{
if( meAnimationMode != ANIMATIONMODE_SHOW )
{
if( pStartPage->GetPageKind() == PK_STANDARD )
{
aPresSlide = pStartPage->GetName();
maPresSettings.mbAll = false;
}
else
{
bStartWithActualSlide = false;
}
}
}
else
{
if( pStartPage->GetPageKind() != PK_STANDARD )
{
bStartWithActualSlide = false;
}
}
// build page list
createSlideList( maPresSettings.mbAll, false, aPresSlide );
if( bStartWithActualSlide )
{
sal_Int32 nSlideNum = ( pStartPage->GetPageNum() - 1 ) >> 1;
if( !maPresSettings.mbAll && !maPresSettings.mbCustomShow )
{
// its start from dia, find out if it is located before our current Slide
const sal_Int32 nSlideCount = mpDoc->GetSdPageCount( PK_STANDARD );
sal_Int32 nSlide;
for( nSlide = 0; (nSlide < nSlideCount); nSlide++ )
{
if( mpDoc->GetSdPage( (USHORT) nSlide, PK_STANDARD )->GetName() == aPresSlide )
break;
}
if( nSlide > nSlideNum )
nSlideNum = -1;
}
if( nSlideNum != -1 )
mpSlideController->setStartSlideNumber( nSlideNum );
}
// remember Slide number from where the show was started
if( pStartPage )
mnRestoreSlide = ( pStartPage->GetPageNum() - 1 ) / 2;
if( mpSlideController->hasSlides() )
{
// hide child windows
hideChildWindows();
mpShowWindow = new ShowWindow( this, mpParentWindow );
mpShowWindow->SetMouseAutoHide( !maPresSettings.mbMouseVisible );
if( mpViewShell )
{
mpViewShell->SetActiveWindow( mpShowWindow );
mpShowWindow->SetViewShell (mpViewShell);
mpViewShell->GetViewShellBase().ShowUIControls (false);
// Hide the side panes for in-place presentations.
if ( ! maPresSettings.mbFullScreen)
mpPaneHider.reset(new PaneHider(*mpViewShell,this));
if( getViewFrame() )
getViewFrame()->SetChildWindow( SID_NAVIGATOR, maPresSettings.mbStartWithNavigator );
}
// these Slots are forbiden in other views for this document
if( mpDocSh )
{
mpDocSh->SetSlotFilter( TRUE, sizeof( pAllowed ) / sizeof( USHORT ), pAllowed );
mpDocSh->ApplySlotFilter();
}
Help::DisableContextHelp();
Help::DisableExtHelp();
// mpTimeButton = new PushButton( mpShowWindow, SdResId( RID_TIME_BUTTON ) );
// maPencil = Pointer( POINTER_PEN );
// mpTimeButton->Hide();
if( maPresSettings.mbFullScreen )
{
// disable basic ide error handling
maStarBASICGlobalErrorHdl = StarBASIC::GetGlobalErrorHdl();
StarBASIC::SetGlobalErrorHdl( Link() );
}
// call resize handler
maPresSize = mpParentWindow->GetSizePixel();
if( !maPresSettings.mbFullScreen && mpViewShell )
{
const Rectangle& aClientRect = mpViewShell->GetViewShellBase().getClientRectangle();
maPresSize = aClientRect.GetSize();
mpShowWindow->SetPosPixel( aClientRect.TopLeft() );
resize( maPresSize );
}
// #i41824#
// Note: In FullScreen Mode the OS (window manager) sends a resize to
// the WorkWindow once it actually resized it to full size. The
// WorkWindow propagates the resize to the DrawViewShell which calls
// resize() at the SlideShow (this). Calling resize here results in a
// temporary display of a black window in the window's default size
/*
if ( mbRehearseTimings )
{
Size aButtonSizePixel( pTimeButton->GetSizePixel() );
Point aButtonPosPixel( aButtonSizePixel.Width() >> 1, pShowWindow->GetSizePixel().Height() - aButtonSizePixel.Height() * 5 / 2);
pTimeButton->SetPosPixel( aButtonPosPixel );
aTimer.SetTimeoutHdl( LINK( this,FuSlideShow, TimeButtonTimeOutHdl ) );
pTimeButton->SetClickHdl( LINK( this, FuSlideShow, TimeButtonHdl ) );
}
*/
if( mpView )
{
mpView->AddWindowToPaintView( mpShowWindow );
mpView->SetAnimationPause( TRUE );
}
SfxBindings* pBindings = getBindings();
if( pBindings )
{
pBindings->Invalidate( SID_PRESENTATION );
pBindings->Invalidate( SID_REHEARSE_TIMINGS );
}
mpShowWindow->GrabFocus();
std::vector<beans::PropertyValue> aProperties;
aProperties.reserve( 4 );
aProperties.push_back(
beans::PropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("AdvanceOnClick") ),
-1, Any( ! (maPresSettings.mbLockedPages != sal_False) ),
beans::PropertyState_DIRECT_VALUE ) );
aProperties.push_back(
beans::PropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("ImageAnimationsAllowed") ),
-1, Any( maPresSettings.mbAnimationAllowed != sal_False ),
beans::PropertyState_DIRECT_VALUE ) );
const sal_Bool bZOrderEnabled(
SD_MOD()->GetSdOptions( mpDoc->GetDocumentType() )->IsSlideshowRespectZOrder() );
aProperties.push_back(
beans::PropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("DisableAnimationZOrder") ),
-1, Any( bZOrderEnabled == sal_False ),
beans::PropertyState_DIRECT_VALUE ) );
/*
aProperties.push_back(
beans::PropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("MouseVisible") ),
-1, Any( maPresSettings.mbMouseVisible != sal_False ),
beans::PropertyState_DIRECT_VALUE ) );
*/
aProperties.push_back(
beans::PropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("ForceManualAdvance") ),
-1, Any( maPresSettings.mbManual != sal_False ),
beans::PropertyState_DIRECT_VALUE ) );
if( maPresSettings.mbMouseAsPen )
{
aProperties.push_back(
beans::PropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("UserPaintColor") ),
// User paint color is black by default.
-1, Any( static_cast<sal_Int32>(0x00000000L) ),
beans::PropertyState_DIRECT_VALUE ) );
}
if (mbRehearseTimings) {
aProperties.push_back(
beans::PropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("RehearseTimings") ),
-1, Any(true), beans::PropertyState_DIRECT_VALUE ) );
}
bRet = startShowImpl( Sequence<beans::PropertyValue>(
&aProperties[0], aProperties.size() ) );
}
setActiveXToolbarsVisible( sal_False );
}
catch( Exception& e )
{
(void)e;
DBG_ERROR(
(OString("sd::SlideshowImpl::startShow(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
bRet = false;
}
return bRet;
}
bool SlideshowImpl::startShowImpl( const Sequence< beans::PropertyValue >& aProperties )
{
try
{
mxShow = Reference< XSlideShow >( createSlideShow(), UNO_QUERY_THROW );
mxView = mxView.createFromQuery( new SlideShowView(
*mpShowWindow,
mpDoc,
meAnimationMode,
this,
maPresSettings.mbFullScreen) );
// try add wait symbol to properties:
const Reference<rendering::XSpriteCanvas> xSpriteCanvas(
mxView->getCanvas() );
if (xSpriteCanvas.is())
{
BitmapEx waitSymbolBitmap( SdResId(BMP_WAIT_ICON) );
const Reference<rendering::XBitmap> xBitmap(
vcl::unotools::xBitmapFromBitmapEx(
xSpriteCanvas->getDevice(), waitSymbolBitmap ) );
if (xBitmap.is())
{
mxShow->setProperty(
beans::PropertyValue(
OUString( RTL_CONSTASCII_USTRINGPARAM("WaitSymbolBitmap") ),
-1,
makeAny( xBitmap ),
beans::PropertyState_DIRECT_VALUE ) );
}
}
const sal_Int32 nCount = aProperties.getLength();
sal_Int32 nIndex;
for( nIndex = 0; nIndex < nCount; nIndex++ )
mxShow->setProperty( aProperties[nIndex] );
mxShow->addView( mxView.getRef() );
mxListenerProxy.set( new SlideShowListenerProxy( this, mxShow ) );
mxListenerProxy->addAsSlideShowListener();
NotifyDocumentEvent( mpDoc, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OnStartPresentation") ) );
displaySlideIndex( mpSlideController->getStartSlideIndex() );
return true;
}
catch( Exception& e )
{
(void)e;
DBG_ERROR(
(OString("sd::SlideshowImpl::startShowImpl(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
return false;
}
}
/** called only by the slideshow view when the first paint event occurs.
This actually starts the slideshow. */
void SlideshowImpl::onFirstPaint()
{
if( mpShowWindow )
{
mpShowWindow->SetBackground( Wallpaper( Color( COL_BLACK ) ) );
mpShowWindow->Erase();
mpShowWindow->SetBackground();
}
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
maUpdateTimer.SetTimeout( (ULONG)100 );
maUpdateTimer.Start();
}
void SlideshowImpl::paint( const Rectangle& /* rRect */ )
{
if( mxView.is() ) try
{
awt::PaintEvent aEvt;
// aEvt.UpdateRect = TODO
mxView->paint( aEvt );
}
catch( Exception& e )
{
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::paint(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::addSlideShowListener( const Reference< XSlideShowListener >& xListener ) throw (RuntimeException)
{
if( mxListenerProxy.is() )
mxListenerProxy->addSlideShowListener( xListener );
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::removeSlideShowListener( const Reference< XSlideShowListener >& xListener ) throw (RuntimeException)
{
if( mxListenerProxy.is() )
mxListenerProxy->removeSlideShowListener( xListener );
}
// ---------------------------------------------------------
void SlideshowImpl::slideEnded(const bool bReverse)
{
if (bReverse)
gotoPreviousSlide(true);
else
gotoNextSlide();
}
// ---------------------------------------------------------
void SlideshowImpl::removeShapeEvents()
{
if( mxShow.is() && mxListenerProxy.is() ) try
{
WrappedShapeEventImplMap::iterator aIter;
const WrappedShapeEventImplMap::iterator aEnd( maShapeEventMap.end() );
for( aIter = maShapeEventMap.begin(); aIter != aEnd; aIter++ )
{
mxListenerProxy->removeShapeEventListener( (*aIter).first );
mxShow->setShapeCursor( (*aIter).first, awt::SystemPointer::ARROW );
}
maShapeEventMap.clear();
}
catch( Exception& e )
{
(void)e;
DBG_ERROR(
(OString("sd::SlideshowImpl::removeShapeEvents(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
}
// ---------------------------------------------------------
void SlideshowImpl::registerShapeEvents(sal_Int32 nSlideNumber)
{
if( nSlideNumber >= 0 ) try
{
Reference< XDrawPagesSupplier > xDrawPages( mxModel, UNO_QUERY_THROW );
Reference< XIndexAccess > xPages( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
Reference< XShapes > xDrawPage;
xPages->getByIndex(nSlideNumber) >>= xDrawPage;
if( xDrawPage.is() )
{
Reference< XMasterPageTarget > xMasterPageTarget( xDrawPage, UNO_QUERY );
if( xMasterPageTarget.is() )
{
Reference< XShapes > xMasterPage( xMasterPageTarget->getMasterPage(), UNO_QUERY );
if( xMasterPage.is() )
registerShapeEvents( xMasterPage );
}
registerShapeEvents( xDrawPage );
}
}
catch( Exception& e )
{
(void)e;
DBG_ERROR(
(OString("sd::SlideshowImpl::registerShapeEvents(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
}
// ---------------------------------------------------------
void SlideshowImpl::registerShapeEvents( Reference< XShapes >& xShapes ) throw( Exception )
{
try
{
const sal_Int32 nShapeCount = xShapes->getCount();
sal_Int32 nShape;
for( nShape = 0; nShape < nShapeCount; nShape++ )
{
Reference< XShape > xShape;
xShapes->getByIndex( nShape ) >>= xShape;
if( xShape.is() &&
xShape->getShapeType().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GroupShape") ) )
{
Reference< XShapes > xSubShapes( xShape, UNO_QUERY );
if( xSubShapes.is() )
registerShapeEvents( xSubShapes );
}
Reference< XPropertySet > xSet( xShape, UNO_QUERY );
if( !xSet.is() )
continue;
Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
if( !xSetInfo.is() || !xSetInfo->hasPropertyByName( msOnClick ) )
continue;
WrappedShapeEventImplPtr pEvent( new WrappedShapeEventImpl );
xSet->getPropertyValue( msOnClick ) >>= pEvent->meClickAction;
switch( pEvent->meClickAction )
{
case ClickAction_PREVPAGE:
case ClickAction_NEXTPAGE:
case ClickAction_FIRSTPAGE:
case ClickAction_LASTPAGE:
case ClickAction_STOPPRESENTATION:
break;
case ClickAction_BOOKMARK:
if( xSetInfo->hasPropertyByName( msBookmark ) )
xSet->getPropertyValue( msBookmark ) >>= pEvent->maStrBookmark;
if( getSlideNumberForBookmark( pEvent->maStrBookmark ) == -1 )
continue;
break;
case ClickAction_DOCUMENT:
case ClickAction_SOUND:
case ClickAction_PROGRAM:
case ClickAction_MACRO:
if( xSetInfo->hasPropertyByName( msBookmark ) )
xSet->getPropertyValue( msBookmark ) >>= pEvent->maStrBookmark;
break;
case ClickAction_VERB:
if( xSetInfo->hasPropertyByName( msVerb ) )
xSet->getPropertyValue( msVerb ) >>= pEvent->mnVerb;
break;
default:
continue; // skip all others
}
maShapeEventMap[ xShape ] = pEvent;
if( mxListenerProxy.is() )
mxListenerProxy->addShapeEventListener( xShape );
mxShow->setShapeCursor( xShape, awt::SystemPointer::REFHAND );
}
}
catch( Exception& e )
{
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::registerShapeEvents(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
}
// ---------------------------------------------------------
void SlideshowImpl::displayCurrentSlide (const bool bSkipAllMainSequenceEffects)
{
stopSound();
removeShapeEvents();
if( mpSlideController.get() && mxShow.is() )
{
Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(),
UNO_QUERY_THROW );
mpSlideController->displayCurrentSlide( mxShow, xDrawPages, bSkipAllMainSequenceEffects );
registerShapeEvents(mpSlideController->getCurrentSlideNumber());
update();
SfxBindings* pBindings = getBindings();
if( pBindings )
{
pBindings->Invalidate( SID_NAVIGATOR_STATE );
pBindings->Invalidate( SID_NAVIGATOR_PAGENAME );
}
}
}
// ---------------------------------------------------------
void SlideshowImpl::endPresentation()
{
#ifdef ENABLE_PRESENTER_EXTRA_UI
if( maPresSettings.mbMouseAsPen)
{
Reference< XMultiServiceFactory > xDocFactory(mpDoc->getUnoModel(), UNO_QUERY );
if( xDocFactory.is() )
mxShow->registerUserPaintPolygons(xDocFactory);
}
#endif
if( !mnEndShowEvent )
mnEndShowEvent = Application::PostUserEvent( LINK(this, SlideshowImpl, endPresentationHdl) );
}
// ---------------------------------------------------------
IMPL_LINK( SlideshowImpl, endPresentationHdl, void*, EMPTYARG )
{
mnEndShowEvent = 0;
if( mxPresentation.is() )
mxPresentation->end();
return 0;
}
// ---------------------------------------------------------
void SAL_CALL SlideshowImpl::pause() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( !mbIsPaused ) try
{
mbIsPaused = sal_True;
if( mxShow.is() )
{
mxShow->pause(sal_True);
if( mxListenerProxy.is() )
mxListenerProxy->paused();
}
}
catch( Exception& e )
{
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::pause(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
}
// ---------------------------------------------------------
void SAL_CALL SlideshowImpl::resume() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mbIsPaused ) try
{
if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
{
mpShowWindow->RestartShow();
}
else
{
mbIsPaused = sal_False;;
if( mxShow.is() )
{
mxShow->pause(sal_False);
update();
if( mxListenerProxy.is() )
mxListenerProxy->resumed();
}
}
}
catch( Exception& e )
{
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::resume(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
}
// ---------------------------------------------------------
sal_Bool SAL_CALL SlideshowImpl::isPaused() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
return mbIsPaused;
}
// ---------------------------------------------------------
void SAL_CALL SlideshowImpl::blankScreen( sal_Int32 nColor ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mpShowWindow && mpSlideController )
{
if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), nColor ) )
{
pause();
}
}
}
// ---------------------------------------------------------
// XShapeEventListener
// ---------------------------------------------------------
void SlideshowImpl::click( const Reference< XShape >& xShape, const ::com::sun::star::awt::MouseEvent& /* aOriginalEvent */ )
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
WrappedShapeEventImplPtr pEvent = maShapeEventMap[xShape];
if( !pEvent.get() )
return;
switch( pEvent->meClickAction )
{
case ClickAction_PREVPAGE: gotoPreviousSlide(); break;
case ClickAction_NEXTPAGE: gotoNextSlide(); break;
case ClickAction_FIRSTPAGE: gotoFirstSlide(); break;
case ClickAction_LASTPAGE: gotoLastSlide(); break;
case ClickAction_STOPPRESENTATION: endPresentation(); break;
case ClickAction_BOOKMARK:
{
gotoBookmark( pEvent->maStrBookmark );
}
break;
case ClickAction_SOUND:
{
try
{
mxPlayer.set(avmedia::MediaWindow::createPlayer(pEvent->maStrBookmark), uno::UNO_QUERY_THROW );
mxPlayer->start();
}
catch( uno::Exception& e )
{
(void)e;
DBG_ERROR("sd::SlideshowImpl::click(), exception caught!" );
}
}
break;
case ClickAction_DOCUMENT:
{
OUString aBookmark( pEvent->maStrBookmark );
sal_Int32 nPos = aBookmark.indexOf( sal_Unicode('#') );
if( nPos >= 0 )
{
OUString aURL( aBookmark.copy( 0, nPos+1 ) );
OUString aName( aBookmark.copy( nPos+1 ) );
aURL += getUiNameFromPageApiNameImpl( aName );
aBookmark = aURL;
}
mpDocSh->OpenBookmark( aBookmark );
}
break;
case ClickAction_PROGRAM:
{
INetURLObject aURL(
::URIHelper::SmartRel2Abs(
INetURLObject(mpDocSh->GetMedium()->GetBaseURL()),
pEvent->maStrBookmark, ::URIHelper::GetMaybeFileHdl(), true,
false, INetURLObject::WAS_ENCODED,
INetURLObject::DECODE_UNAMBIGUOUS ) );
if( INET_PROT_FILE == aURL.GetProtocol() )
{
SfxStringItem aUrl( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE ) );
SfxBoolItem aBrowsing( SID_BROWSE, TRUE );
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
if (pViewFrm)
pViewFrm->GetDispatcher()->Execute( SID_OPENDOC,
SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
&aUrl,
&aBrowsing,
0L );
}
}
break;
case presentation::ClickAction_MACRO:
{
const String aMacro( pEvent->maStrBookmark );
if ( SfxApplication::IsXScriptURL( aMacro ) )
{
Any aRet;
Sequence< sal_Int16 > aOutArgsIndex;
Sequence< Any > aOutArgs;
Sequence< Any >* pInArgs = new Sequence< Any >(0);
mpDocSh->CallXScript( aMacro, *pInArgs, aRet, aOutArgsIndex, aOutArgs);
}
else
{
// aMacro has the following syntax:
// "Macroname.Modulname.Libname.Dokumentname" or
// "Macroname.Modulname.Libname.Applikationsname"
String aMacroName = aMacro.GetToken(0, sal_Unicode('.'));
String aModulName = aMacro.GetToken(1, sal_Unicode('.'));
String aLibName = aMacro.GetToken(2, sal_Unicode('.'));
String aDocName = aMacro.GetToken(3, sal_Unicode('.'));
// todo: is the limitation still given that only
// Modulname+Macroname can be used here?
String aExecMacro(aModulName);
aExecMacro.Append( sal_Unicode('.') );
aExecMacro.Append( aMacroName );
mpDocSh->GetBasic()->Call(aExecMacro);
}
}
break;
case ClickAction_VERB:
{
// todo, better do it async?
SdrObject* pObj = GetSdrObjectFromXShape( xShape );
SdrOle2Obj* pOleObject = PTR_CAST(SdrOle2Obj, pObj);
if (pOleObject && mpViewShell )
mpViewShell->ActivateObject(pOleObject, pEvent->mnVerb);
}
break;
default:
break;
}
}
// ---------------------------------------------------------
sal_Int32 SlideshowImpl::getSlideNumberForBookmark( const OUString& rStrBookmark )
{
BOOL bIsMasterPage;
OUString aBookmark = getUiNameFromPageApiNameImpl( rStrBookmark );
USHORT nPgNum = mpDoc->GetPageByName( aBookmark, bIsMasterPage );
if( nPgNum == SDRPAGE_NOTFOUND )
{
// Ist das Bookmark ein Objekt?
SdrObject* pObj = mpDoc->GetObj( aBookmark );
if( pObj )
{
nPgNum = pObj->GetPage()->GetPageNum();
bIsMasterPage = (BOOL)pObj->GetPage()->IsMasterPage();
}
}
if( (nPgNum == SDRPAGE_NOTFOUND) || bIsMasterPage || static_cast<SdPage*>(mpDoc->GetPage(nPgNum))->GetPageKind() != PK_STANDARD )
return -1;
return ( nPgNum - 1) >> 1;
}
// ---------------------------------------------------------
void SlideshowImpl::hyperLinkClicked( rtl::OUString const& aHyperLink ) throw (RuntimeException)
{
OUString aBookmark( aHyperLink );
sal_Int32 nPos = aBookmark.indexOf( sal_Unicode('#') );
if( nPos >= 0 )
{
OUString aURL( aBookmark.copy( 0, nPos+1 ) );
OUString aName( aBookmark.copy( nPos+1 ) );
aURL += getUiNameFromPageApiNameImpl( aName );
aBookmark = aURL;
}
mpDocSh->OpenBookmark( aBookmark );
}
// ---------------------------------------------------------
void SlideshowImpl::displaySlideNumber( sal_Int32 nSlideNumber )
{
if( mpSlideController.get() )
{
if( mpSlideController->jumpToSlideNumber( nSlideNumber ) )
{
displayCurrentSlide();
}
}
}
// ---------------------------------------------------------
/** nSlideIndex == -1 displays current slide again */
void SlideshowImpl::displaySlideIndex( sal_Int32 nSlideIndex )
{
if( mpSlideController.get() )
{
if( (nSlideIndex == -1) || mpSlideController->jumpToSlideIndex( nSlideIndex ) )
{
displayCurrentSlide();
}
}
}
// ---------------------------------------------------------
void SlideshowImpl::jumpToBookmark( const String& sBookmark )
{
sal_Int32 nSlideNumber = getSlideNumberForBookmark( sBookmark );
if( nSlideNumber != -1 )
displaySlideNumber( nSlideNumber );
}
// ---------------------------------------------------------
sal_Int32 SlideshowImpl::getCurrentSlideNumber()
{
return mpSlideController.get() ? mpSlideController->getCurrentSlideNumber() : -1;
}
// ---------------------------------------------------------
sal_Int32 SlideshowImpl::getFirstSlideNumber()
{
sal_Int32 nRet = 0;
if( mpSlideController.get() )
{
sal_Int32 nSlideIndexCount = mpSlideController->getSlideIndexCount() - 1;
if( nSlideIndexCount >= 0 )
{
nRet = mpSlideController->getSlideNumber( nSlideIndexCount );
while( nSlideIndexCount-- )
{
sal_Int32 nTemp = mpSlideController->getSlideNumber( nSlideIndexCount );
if( nRet > nTemp )
nRet = nTemp;
}
}
}
return nRet;
}
// ---------------------------------------------------------
sal_Int32 SlideshowImpl::getLastSlideNumber()
{
sal_Int32 nRet = 0;
if( mpSlideController.get() )
{
sal_Int32 nSlideIndexCount = mpSlideController->getSlideIndexCount() - 1;
if( nSlideIndexCount >= 0 )
{
nRet = mpSlideController->getSlideNumber( nSlideIndexCount );
while( nSlideIndexCount-- )
{
sal_Int32 nTemp = mpSlideController->getSlideNumber( nSlideIndexCount );
if( nRet < nTemp )
nRet = nTemp;
}
}
}
return nRet;
}
// ---------------------------------------------------------
sal_Bool SAL_CALL SlideshowImpl::isEndless() throw( RuntimeException )
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
return maPresSettings.mbEndless;
}
// ---------------------------------------------------------
double SlideshowImpl::update()
{
startUpdateTimer();
return -1;
}
// ---------------------------------------------------------
void SlideshowImpl::startUpdateTimer()
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
maUpdateTimer.SetTimeout( 0 );
maUpdateTimer.Start();
}
// ---------------------------------------------------------
/** this timer is called 20ms after a new slide was displayed.
This is used to unfreeze user input that was disabled after
slide change to skip input that was buffered during slide
transition preperation */
IMPL_LINK( SlideshowImpl, ReadyForNextInputHdl, Timer*, EMPTYARG )
{
mbInputFreeze = false;
return 0;
}
// ---------------------------------------------------------
/** if I catch someone someday who calls this method by hand
and not by using the timer, I will personaly punish this
person seriously, even if this person is me.
*/
IMPL_LINK( SlideshowImpl, updateHdl, Timer*, EMPTYARG )
{
mnUpdateEvent = 0;
return updateSlideShow();
}
IMPL_LINK( SlideshowImpl, PostYieldListener, void*, EMPTYARG )
{
Application::EnableNoYieldMode(false);
Application::RemovePostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
if (mbDisposed)
return 0;
return updateSlideShow();
}
sal_Int32 SlideshowImpl::updateSlideShow (void)
{
// doing some nMagic
const rtl::Reference<SlideshowImpl> this_(this);
Reference< XSlideShow > xShow( mxShow );
if ( ! xShow.is())
return 0;
try
{
// TODO(Q3): Evaluate under various systems and setups,
// whether this is really necessary. Under WinXP and Matrox
// G550, the frame rates were much more steadier with this
// tweak, although.
// currently no solution, because this kills sound (at least on Windows)
// // Boost our prio, as long as we're in the render loop
// ::canvas::tools::PriorityBooster aBooster(2);
double fUpdate = 0.0;
if( !xShow->update(fUpdate) )
fUpdate = -1.0;
if (mxShow.is() && (fUpdate >= 0.0))
{
if (::basegfx::fTools::equalZero(fUpdate))
{
// Use post yield listener for short update intervalls.
Application::EnableNoYieldMode(true);
Application::AddPostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
}
else
{
// Avoid busy loop when the previous call to update()
// returns a small positive number but not 0 (which is
// handled above). Also, make sure that calls to update()
// have a minimum frequency.
// => Allow up to 60 frames per second. Call at least once
// every 4 seconds.
const static sal_Int32 mnMaximumFrameCount (60);
const static double mnMinimumTimeout (1.0 / mnMaximumFrameCount);
const static double mnMaximumTimeout (4.0);
fUpdate = ::basegfx::clamp(fUpdate, mnMinimumTimeout, mnMaximumTimeout);
// Make sure that the maximum frame count has not been set
// too high (only then conversion to milliseconds and long
// integer may lead to zero value.)
OSL_ASSERT(static_cast<ULONG>(fUpdate * 1000.0) > 0);
Application::EnableNoYieldMode(false);
Application::RemovePostYieldListener(LINK(this, SlideshowImpl, PostYieldListener));
// Use a timer for the asynchronous callback.
maUpdateTimer.SetTimeout(static_cast<ULONG>(fUpdate * 1000.0));
maUpdateTimer.Start();
}
}
}
catch( Exception& e )
{
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::updateSlideShow(), exception caught: ")
+ rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
return 0;
}
// ---------------------------------------------------------
bool SlideshowImpl::keyInput(const KeyEvent& rKEvt)
{
if( !mxShow.is() || mbInputFreeze )
return false;
bool bRet = true;
try
{
const int nKeyCode = rKEvt.GetKeyCode().GetCode();
switch( nKeyCode )
{
case awt::Key::CONTEXTMENU:
if( !mnContextMenuEvent )
{
if( mpShowWindow )
maPopupMousePos = mpShowWindow->GetPointerState().maPos;
mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl ) );
}
break;
// cancel show
case KEY_ESCAPE:
case KEY_SUBTRACT:
// in case the user cancels the presentation, switch to current slide
// in edit mode
if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) )
{
if( mpSlideController->getCurrentSlideNumber() != -1 )
mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
}
endPresentation();
break;
// advance show
case KEY_PAGEDOWN:
if(rKEvt.GetKeyCode().IsMod2())
{
gotoNextSlide();
break;
}
// warning, fall through!
case KEY_SPACE:
case KEY_RIGHT:
case KEY_DOWN:
case KEY_N:
gotoNextEffect();
break;
case KEY_RETURN:
{
if( maCharBuffer.Len() )
{
if( mpSlideController.get() )
{
if( mpSlideController->jumpToSlideNumber( maCharBuffer.ToInt32() - 1 ) )
displayCurrentSlide();
}
maCharBuffer.Erase();
}
else
{
gotoNextEffect();
}
}
break;
// numeric: add to buffer
case KEY_0:
case KEY_1:
case KEY_2:
case KEY_3:
case KEY_4:
case KEY_5:
case KEY_6:
case KEY_7:
case KEY_8:
case KEY_9:
maCharBuffer.Append( rKEvt.GetCharCode() );
break;
case KEY_PAGEUP:
if(rKEvt.GetKeyCode().IsMod2())
{
gotoPreviousSlide();
break;
}
// warning, fall through!
case KEY_LEFT:
case KEY_UP:
case KEY_P:
case KEY_BACKSPACE:
gotoPreviousEffect();
break;
case KEY_HOME:
gotoFirstSlide();
break;
case KEY_END:
gotoLastSlide();
break;
case KEY_B:
case KEY_W:
case KEY_POINT:
case KEY_COMMA:
{
blankScreen( ((nKeyCode == KEY_W ) || (nKeyCode == KEY_COMMA)) ? 0x00ffffff : 0x00000000 );
}
break;
default:
bRet = false;
break;
}
}
catch( Exception& e )
{
bRet = false;
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::keyInput(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
return bRet;
}
IMPL_LINK( SlideshowImpl, EventListenerHdl, VclSimpleEvent*, pEvent )
{
if( !mxShow.is() || mbInputFreeze )
return 0;
if( pEvent && (pEvent->GetId() == VCLEVENT_WINDOW_COMMAND) && static_cast<VclWindowEvent*>(pEvent)->GetData() )
{
const CommandEvent& rEvent = *(const CommandEvent*)static_cast<VclWindowEvent*>(pEvent)->GetData();
if( rEvent.GetCommand() == COMMAND_MEDIA )
{
switch( rEvent.GetMediaCommand() )
{
#if defined( QUARTZ )
case MEDIA_COMMAND_MENU:
if( !mnContextMenuEvent )
{
if( mpShowWindow )
maPopupMousePos = mpShowWindow->GetPointerState().maPos;
mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl ) );
}
break;
case MEDIA_COMMAND_VOLUME_DOWN:
gotoPreviousSlide();
break;
case MEDIA_COMMAND_VOLUME_UP:
gotoNextEffect();
break;
#endif
case MEDIA_COMMAND_NEXTTRACK:
gotoNextEffect();
break;
case MEDIA_COMMAND_PAUSE:
if( !mbIsPaused )
blankScreen(0);
break;
case MEDIA_COMMAND_PLAY:
if( mbIsPaused )
resume();
break;
case MEDIA_COMMAND_PLAY_PAUSE:
if( mbIsPaused )
resume();
else
blankScreen(0);
break;
case MEDIA_COMMAND_PREVIOUSTRACK:
gotoPreviousSlide();
break;
case MEDIA_COMMAND_NEXTTRACK_HOLD:
gotoLastSlide();
break;
case MEDIA_COMMAND_REWIND:
gotoFirstSlide();
break;
case MEDIA_COMMAND_STOP:
// in case the user cancels the presentation, switch to current slide
// in edit mode
if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) )
{
if( mpSlideController->getCurrentSlideNumber() != -1 )
mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
}
endPresentation();
break;
}
}
}
return 0;
}
// ---------------------------------------------------------
void SlideshowImpl::mouseButtonUp(const MouseEvent& rMEvt)
{
if( rMEvt.IsRight() && !mnContextMenuEvent )
{
maPopupMousePos = rMEvt.GetPosPixel();
mnContextMenuEvent = Application::PostUserEvent( LINK( this, SlideshowImpl, ContextMenuHdl ) );
}
}
// ---------------------------------------------------------
IMPL_LINK( SlideshowImpl, ContextMenuHdl, void*, EMPTYARG )
{
mnContextMenuEvent = 0;
if( mpSlideController.get() == 0 )
return 0;
mbWasPaused = mbIsPaused;
if( !mbWasPaused )
pause();
PopupMenu* pMenu = new PopupMenu( SdResId( RID_SLIDESHOW_CONTEXTMENU ) );
#ifdef ENABLE_PRESENTER_EXTRA_UI
//adding button to contextual menu for erasing functionnalities for UserPaintOverlay
pMenu->EnableItem( CM_ERASE_ALLINK, (maPresSettings.mbMouseAsPen));
// Adding button to contextual menu for changing pen color
pMenu->EnableItem( CM_COLOR_PEN, (maPresSettings.mbMouseAsPen));
// Adding button to display if in Pen mode
pMenu->EnableItem( CM_PEN_MODE, (maPresSettings.mbMouseAsPen));
// Adding button to displau if in Erase Mode
pMenu->EnableItem( CM_ERASE_MODE, (maPresSettings.mbMouseAsPen));
#endif
const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
pMenu->EnableItem( CM_NEXT_SLIDE, ( mpSlideController->getNextSlideIndex() != -1 ) );
pMenu->EnableItem( CM_PREV_SLIDE, ( mpSlideController->getPreviousSlideIndex() != -1 ) || (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) );
PopupMenu* pPageMenu = pMenu->GetPopupMenu( CM_GOTO );
SfxViewFrame* pViewFrame = getViewFrame();
if( pViewFrame )
{
Reference< ::com::sun::star::frame::XFrame > xFrame( pViewFrame->GetFrame().GetFrameInterface() );
if( xFrame.is() )
{
pMenu->SetItemImage( CM_NEXT_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10617") ), FALSE, FALSE ) );
pMenu->SetItemImage( CM_PREV_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10618") ), FALSE, FALSE ) );
if( pPageMenu )
{
pPageMenu->SetItemImage( CM_FIRST_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10616") ), FALSE, FALSE ) );
pPageMenu->SetItemImage( CM_LAST_SLIDE, GetImage( xFrame, OUString( RTL_CONSTASCII_USTRINGPARAM( "slot:10619") ), FALSE, FALSE ) );
}
}
}
// populate slide goto list
if( pPageMenu )
{
const sal_Int32 nPageNumberCount = mpSlideController->getSlideNumberCount();
if( nPageNumberCount <= 1 )
{
pMenu->EnableItem( CM_GOTO, FALSE );
}
else
{
sal_Int32 nCurrentSlideNumber = mpSlideController->getCurrentSlideNumber();
if( (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
nCurrentSlideNumber = -1;
pPageMenu->EnableItem( CM_FIRST_SLIDE, ( mpSlideController->getSlideNumber(0) != nCurrentSlideNumber ) );
pPageMenu->EnableItem( CM_LAST_SLIDE, ( mpSlideController->getSlideNumber( mpSlideController->getSlideIndexCount() - 1) != nCurrentSlideNumber ) );
sal_Int32 nPageNumber;
for( nPageNumber = 0; nPageNumber < nPageNumberCount; nPageNumber++ )
{
if( mpSlideController->isVisibleSlideNumber( nPageNumber ) )
{
SdPage* pPage = mpDoc->GetSdPage((USHORT)nPageNumber, PK_STANDARD);
if (pPage)
{
pPageMenu->InsertItem( (USHORT)(CM_SLIDES + nPageNumber), pPage->GetName() );
if( nPageNumber == nCurrentSlideNumber )
pPageMenu->CheckItem( (USHORT)(CM_SLIDES + nPageNumber) );
}
}
}
}
}
if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
{
PopupMenu* pBlankMenu = pMenu->GetPopupMenu( CM_SCREEN );
if( pBlankMenu )
{
pBlankMenu->CheckItem( ( mpShowWindow->GetBlankColor() == Color( COL_WHITE ) ) ? CM_SCREEN_WHITE : CM_SCREEN_BLACK );
}
}
#ifdef ENABLE_PRESENTER_EXTRA_UI
PopupMenu* pWidthMenu = pMenu->GetPopupMenu( CM_WIDTH_PEN);
// populate color width list
if( pWidthMenu )
{
if(! maPresSettings.mbMouseAsPen)
{
pMenu->EnableItem( CM_WIDTH_PEN, FALSE );
}
else
{
sal_Int32 nIterator;
double nWidth;
nWidth = 4.0;
for( nIterator = 1; nIterator < 6; nIterator++)
{
switch(nIterator)
{
case 1:
nWidth = 4.0;
break;
case 2:
nWidth = 100.0;
break;
case 3:
nWidth = 150.0;
break;
case 4:
nWidth = 200.0;
break;
case 5:
nWidth = 400.0;
break;
default:
break;
}
pWidthMenu->EnableItem( (USHORT)(CM_WIDTH_PEN + nIterator), TRUE);
if( nWidth == mdUserPaintStrokeWidth)
pWidthMenu->CheckItem( (USHORT)(CM_WIDTH_PEN + nIterator) );
}
}
}
PopupMenu* pEraseWidthMenu = pMenu->GetPopupMenu( CM_ERASE_INK_PEN);
// populate eraser width list
if( pEraseWidthMenu )
{
if(! maPresSettings.mbMouseAsPen)
{
pMenu->EnableItem( CM_ERASE_INK_PEN, FALSE );
}
else
{
sal_Int32 nEIterator;
double nEWidth;
nEWidth = 100.0;
for( nEIterator = 1; nEIterator < 6; nEIterator++)
{
switch(nEIterator)
{
case 1:
nEWidth = 100.0;
break;
case 2:
nEWidth = 200.0;
break;
case 3:
nEWidth = 300.0;
break;
case 4:
nEWidth = 400.0;
break;
case 5:
nEWidth = 500.0;
break;
default:
break;
}
pEraseWidthMenu->EnableItem( (USHORT)(CM_ERASE_INK_PEN + nEIterator), TRUE);
if( nEWidth == mnEraseInkSize)
pEraseWidthMenu->CheckItem( (USHORT)(CM_ERASE_INK_PEN + nEIterator) );
if( mbSwitchPenMode )
pMenu->CheckItem( (USHORT)(CM_PEN_MODE));
if( mbSwitchEraserMode )
pMenu->CheckItem( (USHORT)(CM_ERASE_MODE));
}
}
}
#endif
pMenu->SetSelectHdl( LINK( this, SlideshowImpl, ContextMenuSelectHdl ) );
pMenu->Execute( mpShowWindow, maPopupMousePos );
delete pMenu;
if( mxView.is() )
mxView->ignoreNextMouseReleased();
if( !mbWasPaused )
resume();
return 0;
}
// ---------------------------------------------------------
IMPL_LINK( SlideshowImpl, ContextMenuSelectHdl, Menu *, pMenu )
{
if( pMenu )
{
sal_uInt16 nMenuId = pMenu->GetCurItemId();
switch( nMenuId )
{
case CM_PREV_SLIDE:
gotoPreviousSlide();
mbWasPaused = false;
break;
case CM_NEXT_SLIDE:
gotoNextSlide();
mbWasPaused = false;
break;
case CM_FIRST_SLIDE:
gotoFirstSlide();
mbWasPaused = false;
break;
case CM_LAST_SLIDE:
gotoLastSlide();
mbWasPaused = false;
break;
case CM_SCREEN_BLACK:
case CM_SCREEN_WHITE:
{
const Color aBlankColor( (nMenuId == CM_SCREEN_WHITE) ? COL_WHITE : COL_BLACK );
if( mbWasPaused )
{
if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_BLANK )
{
if( mpShowWindow->GetBlankColor() == aBlankColor )
{
mbWasPaused = false;
mpShowWindow->RestartShow();
break;
}
}
mpShowWindow->RestartShow();
}
if( mpShowWindow->SetBlankMode( mpSlideController->getCurrentSlideIndex(), aBlankColor ) )
{
pause();
mbWasPaused = true;
}
}
break;
#ifdef ENABLE_PRESENTER_EXTRA_UI
if( maPresSettings.mbMouseAsPen )
{
case CM_COLOR_PEN:
{
//Open a color picker based on SvColorDialog
::Color aColor( mnUserPaintColor );
SvColorDialog aColorDlg( mpShowWindow);
aColorDlg.SetColor( aColor );
if (aColorDlg.Execute() )
{
aColor = aColorDlg.GetColor();
mnUserPaintColor = aColor.GetColor();
setPenColor(mnUserPaintColor);
}
mbWasPaused = false;
}
break;
case CM_WIDTH_PEN_VERY_THIN:
{
setPenWidth(4.0);
mbWasPaused = false;
}
break;
case CM_WIDTH_PEN_THIN:
{
setPenWidth(100.0);
mbWasPaused = false;
}
break;
case CM_WIDTH_PEN_NORMAL:
{
setPenWidth(150.0);
mbWasPaused = false;
}
break;
case CM_WIDTH_PEN_THICK:
{
setPenWidth(200.0);
mbWasPaused = false;
}
break;
case CM_WIDTH_PEN_VERY_THICK:
{
setPenWidth(400.0);
mbWasPaused = false;
}
break;
case CM_ERASE_ALLINK:
{
setEraseAllInk(true);
mbWasPaused = false;
}
break;
case CM_PEN_MODE:
{
setPenMode(true);
mbWasPaused = false;
}
break;
case CM_ERASE_MODE:
{
setEraserMode(true);
mbWasPaused = false;
}
break;
case CM_ERASE_INK_PEN_VERY_THIN:
{
setEraseInk(100);
mbWasPaused = false;
}
break;
case CM_ERASE_INK_PEN_THIN:
{
setEraseInk(200);
mbWasPaused = false;
}
break;
case CM_ERASE_INK_PEN_NORMAL:
{
setEraseInk(300);
mbWasPaused = false;
}
break;
case CM_ERASE_INK_PEN_THICK:
{
setEraseInk(400);
mbWasPaused = false;
}
break;
case CM_ERASE_INK_PEN_VERY_THICK:
{
setEraseInk(500);
mbWasPaused = false;
}
break;
}
#endif
case CM_ENDSHOW:
// in case the user cancels the presentation, switch to current slide
// in edit mode
if( mpSlideController.get() && (ANIMATIONMODE_SHOW == meAnimationMode) )
{
if( mpSlideController->getCurrentSlideNumber() != -1 )
{
mnRestoreSlide = mpSlideController->getCurrentSlideNumber();
}
}
endPresentation();
break;
default:
sal_Int32 nPageNumber = nMenuId - CM_SLIDES;
const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
if( (eMode == SHOWWINDOWMODE_END) || (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
{
mpShowWindow->RestartShow( nPageNumber );
}
else if( nPageNumber != mpSlideController->getCurrentSlideNumber() )
{
displaySlideNumber( nPageNumber );
}
mbWasPaused = false;
break;
}
}
return 0;
}
// ---------------------------------------------------------
Reference< XSlideShow > SlideshowImpl::createSlideShow() const
{
Reference< XSlideShow > xShow;
try
{
Reference< lang::XMultiServiceFactory > xFactory(
::comphelper::getProcessServiceFactory(),
UNO_QUERY_THROW );
Reference< XInterface > xInt( xFactory->createInstance(
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlideShow")) ) );
xShow.set( xInt, UNO_QUERY_THROW );
}
catch( uno::Exception& e )
{
(void)e;
DBG_ERROR(
(OString("sd::SlideshowImpl::createSlideShow(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
return xShow;
}
// ---------------------------------------------------------
void SlideshowImpl::createSlideList( bool bAll, bool bStartWithActualSlide, const String& rPresSlide )
{
const long nSlideCount = mpDoc->GetSdPageCount( PK_STANDARD );
if( nSlideCount )
{
SdCustomShow* pCustomShow;
if( !bStartWithActualSlide && mpDoc->GetCustomShowList() && maPresSettings.mbCustomShow )
pCustomShow = (SdCustomShow*) mpDoc->GetCustomShowList()->GetCurObject();
else
pCustomShow = NULL;
// create animation slide controller
AnimationSlideController::Mode eMode =
( pCustomShow && pCustomShow->Count() ) ? AnimationSlideController::CUSTOM :
(bAll ? AnimationSlideController::ALL : AnimationSlideController::FROM);
Reference< XDrawPagesSupplier > xDrawPages( mpDoc->getUnoModel(), UNO_QUERY_THROW );
Reference< XIndexAccess > xSlides( xDrawPages->getDrawPages(), UNO_QUERY_THROW );
mpSlideController.reset( new AnimationSlideController( xSlides, eMode ) );
if( eMode != AnimationSlideController::CUSTOM )
{
sal_Int32 nFirstSlide = 0;
// normale Praesentation
if( eMode == AnimationSlideController::FROM )
{
if( rPresSlide.Len() )
{
sal_Int32 nSlide;
BOOL bTakeNextAvailable = FALSE;
for( nSlide = 0, nFirstSlide = -1; ( nSlide < nSlideCount ) && ( -1 == nFirstSlide ); nSlide++ )
{
SdPage* pTestSlide = mpDoc->GetSdPage( (USHORT)nSlide, PK_STANDARD );
if( pTestSlide->GetName() == rPresSlide )
{
if( pTestSlide->IsExcluded() )
bTakeNextAvailable = TRUE;
else
nFirstSlide = nSlide;
}
else if( bTakeNextAvailable && !pTestSlide->IsExcluded() )
nFirstSlide = nSlide;
}
if( -1 == nFirstSlide )
nFirstSlide = 0;
}
}
for( sal_Int32 i = 0; i < nSlideCount; i++ )
{
bool bVisible = ( mpDoc->GetSdPage( (USHORT)i, PK_STANDARD ) )->IsExcluded() ? false : true;
if( bVisible || (eMode == AnimationSlideController::ALL) )
mpSlideController->insertSlideNumber( i, bVisible );
}
mpSlideController->setStartSlideNumber( nFirstSlide );
}
else
{
if( meAnimationMode != ANIMATIONMODE_SHOW && rPresSlide.Len() )
{
sal_Int32 nSlide;
for( nSlide = 0; nSlide < nSlideCount; nSlide++ )
if( rPresSlide == mpDoc->GetSdPage( (USHORT) nSlide, PK_STANDARD )->GetName() )
break;
if( nSlide < nSlideCount )
mpSlideController->insertSlideNumber( (USHORT) nSlide );
}
void* pCustomSlide;
sal_Int32 nSlideIndex;
for( pCustomSlide = pCustomShow->First(),nSlideIndex=0; pCustomSlide; pCustomSlide = pCustomShow->Next(), nSlideIndex++ )
{
const USHORT nSdSlide = ( ( (SdPage*) pCustomSlide )->GetPageNum() - 1 ) / 2;
if( !( mpDoc->GetSdPage( nSdSlide, PK_STANDARD ) )->IsExcluded())
mpSlideController->insertSlideNumber( nSdSlide );
}
}
}
}
// ---------------------------------------------------------
typedef USHORT (*FncGetChildWindowId)();
FncGetChildWindowId aShowChilds[] =
{
&AnimationChildWindow::GetChildWindowId,
&Svx3DChildWindow::GetChildWindowId,
&SvxFontWorkChildWindow::GetChildWindowId,
&SvxColorChildWindow::GetChildWindowId,
&SvxSearchDialogWrapper::GetChildWindowId,
&SvxBmpMaskChildWindow::GetChildWindowId,
&SvxIMapDlgChildWindow::GetChildWindowId,
&SvxHyperlinkDlgWrapper::GetChildWindowId,
&SvxHlinkDlgWrapper::GetChildWindowId,
&SfxTemplateDialogWrapper::GetChildWindowId,
&GalleryChildWindow::GetChildWindowId
};
#define NAVIGATOR_CHILD_MASK 0x80000000UL
void SlideshowImpl::hideChildWindows()
{
mnChildMask = 0UL;
if( ANIMATIONMODE_SHOW == meAnimationMode )
{
SfxViewFrame* pViewFrame = getViewFrame();
if( pViewFrame )
{
if( pViewFrame->GetChildWindow( SID_NAVIGATOR ) != NULL )
mnChildMask |= NAVIGATOR_CHILD_MASK;
for( ULONG i = 0, nCount = sizeof( aShowChilds ) / sizeof( FncGetChildWindowId ); i < nCount; i++ )
{
const USHORT nId = ( *aShowChilds[ i ] )();
if( pViewFrame->GetChildWindow( nId ) )
{
pViewFrame->SetChildWindow( nId, FALSE );
mnChildMask |= 1 << i;
}
}
}
}
}
// ---------------------------------------------------------
void SlideshowImpl::showChildWindows()
{
if( ANIMATIONMODE_SHOW == meAnimationMode )
{
SfxViewFrame* pViewFrame = getViewFrame();
if( pViewFrame )
{
pViewFrame->SetChildWindow( SID_NAVIGATOR, ( mnChildMask & NAVIGATOR_CHILD_MASK ) != 0 );
for( ULONG i = 0, nCount = sizeof( aShowChilds ) / sizeof( FncGetChildWindowId ); i < nCount; i++ )
{
if( mnChildMask & ( 1 << i ) )
pViewFrame->SetChildWindow( ( *aShowChilds[ i ] )(), TRUE );
}
}
}
}
// ---------------------------------------------------------
SfxViewFrame* SlideshowImpl::getViewFrame() const
{
return mpViewShell ? mpViewShell->GetViewFrame() : 0;
}
// ---------------------------------------------------------
SfxDispatcher* SlideshowImpl::getDispatcher() const
{
return (mpViewShell && mpViewShell->GetViewFrame()) ? mpViewShell->GetViewFrame()->GetDispatcher() : 0;
}
// ---------------------------------------------------------
SfxBindings* SlideshowImpl::getBindings() const
{
return (mpViewShell && mpViewShell->GetViewFrame()) ? &mpViewShell->GetViewFrame()->GetBindings() : 0;
}
// ---------------------------------------------------------
void SlideshowImpl::resize( const Size& rSize )
{
maPresSize = rSize;
if( mpShowWindow && (ANIMATIONMODE_VIEW != meAnimationMode) )
{
mpShowWindow->SetSizePixel( maPresSize );
mpShowWindow->Show();
// Call ToTop() to bring the window to top if
// a) the old size is not degenerate (then the window will be closed
// soon) and
// b) the animation mode is not that of a preview (on the one hand
// this leaves the old behaviour for the slide show mode unmodified
// and on the other hand does not move the focus from the document
// to the (preview) window; the ToTop() seems not to be necessary at
// least for the preview).
// if( !aOldSize.Width() && !aOldSize.Height() )
// mpShowWindow->ToTop();
}
if( mxView.is() ) try
{
awt::WindowEvent aEvt;
mxView->windowResized(aEvt);
}
catch( Exception& e )
{
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::resize(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
}
// -----------------------------------------------------------------------------
void SlideshowImpl::setActiveXToolbarsVisible( sal_Bool bVisible )
{
// in case of ActiveX control the toolbars should not be visible if slide show runs in window mode
// actually it runs always in window mode in case of ActiveX control
if ( !maPresSettings.mbFullScreen && mpDocSh && mpDocSh->GetMedium() )
{
SFX_ITEMSET_ARG( mpDocSh->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_VIEWONLY, sal_False );
if ( pItem && pItem->GetValue() )
{
// this is a plugin/activex mode, no toolbars should be visible during slide show
// after the end of slide show they should be visible again
SfxViewFrame* pViewFrame = getViewFrame();
if( pViewFrame )
{
try
{
Reference< frame::XLayoutManager > xLayoutManager;
Reference< beans::XPropertySet > xFrameProps( pViewFrame->GetFrame().GetTopFrame().GetFrameInterface(), UNO_QUERY_THROW );
if ( ( xFrameProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) )
>>= xLayoutManager )
&& xLayoutManager.is() )
{
xLayoutManager->setVisible( bVisible );
}
}
catch( uno::Exception& )
{}
}
}
}
}
// -----------------------------------------------------------------------------
void SAL_CALL SlideshowImpl::activate() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
maDeactivateTimer.Stop();
if( !mbActive && mxShow.is() )
{
mbActive = sal_True;
if( ANIMATIONMODE_SHOW == meAnimationMode )
{
if( mbAutoSaveWasOn )
setAutoSaveState( false );
if( mpShowWindow )
{
SfxViewFrame* pViewFrame = getViewFrame();
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : 0;
hideChildWindows();
if( pDispatcher )
{
// filter all forbiden slots
pDispatcher->SetSlotFilter( TRUE, sizeof(pAllowed) / sizeof(USHORT), pAllowed );
}
if( getBindings() )
getBindings()->InvalidateAll(TRUE);
mpShowWindow->GrabFocus();
}
}
resume();
}
}
// -----------------------------------------------------------------------------
void SAL_CALL SlideshowImpl::deactivate() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mbActive && mxShow.is() )
{
maDeactivateTimer.Start();
}
}
// -----------------------------------------------------------------------------
IMPL_LINK( SlideshowImpl, deactivateHdl, Timer*, EMPTYARG )
{
if( mbActive && mxShow.is() )
{
mbActive = sal_False;
pause();
if( ANIMATIONMODE_SHOW == meAnimationMode )
{
if( mbAutoSaveWasOn )
setAutoSaveState( true );
if( mpShowWindow )
{
showChildWindows();
}
}
}
return 0;
}
// ---------------------------------------------------------
sal_Bool SAL_CALL SlideshowImpl::isActive() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
return mbActive;
}
// -----------------------------------------------------------------------------
void SlideshowImpl::receiveRequest(SfxRequest& rReq)
{
const SfxItemSet* pArgs = rReq.GetArgs();
switch ( rReq.GetSlot() )
{
case SID_NAVIGATOR_PEN:
setUsePen(!maPresSettings.mbMouseAsPen);
break;
case SID_NAVIGATOR_PAGE:
{
PageJump eJump = (PageJump)((SfxAllEnumItem&) pArgs->Get(SID_NAVIGATOR_PAGE)).GetValue();
switch( eJump )
{
case PAGE_FIRST: gotoFirstSlide(); break;
case PAGE_LAST: gotoLastSlide(); break;
case PAGE_NEXT: gotoNextSlide(); break;
case PAGE_PREVIOUS: gotoPreviousSlide(); break;
case PAGE_NONE: break;
}
}
break;
case SID_NAVIGATOR_OBJECT:
{
const String aTarget( ((SfxStringItem&) pArgs->Get(SID_NAVIGATOR_OBJECT)).GetValue() );
// is the bookmark a Slide?
BOOL bIsMasterPage;
USHORT nPgNum = mpDoc->GetPageByName( aTarget, bIsMasterPage );
SdrObject* pObj = NULL;
if( nPgNum == SDRPAGE_NOTFOUND )
{
// is the bookmark an object?
pObj = mpDoc->GetObj( aTarget );
if( pObj )
nPgNum = pObj->GetPage()->GetPageNum();
}
if( nPgNum != SDRPAGE_NOTFOUND )
{
nPgNum = ( nPgNum - 1 ) >> 1;
displaySlideNumber( nPgNum );
}
}
break;
}
}
// ---------------------------------------------------------
void SlideshowImpl::setAutoSaveState( bool bOn)
{
try
{
uno::Reference<lang::XMultiServiceFactory> xFac( ::comphelper::getProcessServiceFactory() );
uno::Reference< util::XURLTransformer > xParser(
xFac->createInstance( OUString::createFromAscii("com.sun.star.util.URLTransformer" ) ),
uno::UNO_QUERY_THROW);
util::URL aURL;
aURL.Complete = OUString::createFromAscii("vnd.sun.star.autorecovery:/setAutoSaveState");
xParser->parseStrict(aURL);
Sequence< beans::PropertyValue > aArgs(1);
aArgs[0].Name = OUString::createFromAscii("AutoSaveState");
aArgs[0].Value <<= bOn ? sal_True : sal_False;
uno::Reference< frame::XDispatch > xAutoSave(
xFac->createInstance(OUString::createFromAscii("com.sun.star.frame.AutoRecovery")),
uno::UNO_QUERY_THROW);
xAutoSave->dispatch(aURL, aArgs);
}
catch( Exception& )
{
DBG_ERROR("sd::SlideshowImpl::setAutoSaveState(), exception caught!");
}
}
// ---------------------------------------------------------
Reference< XDrawPage > SAL_CALL SlideshowImpl::getCurrentSlide() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
Reference< XDrawPage > xSlide;
if( mxShow.is() && mpSlideController.get() )
{
sal_Int32 nSlide = getCurrentSlideNumber();
if( (nSlide >= 0) && (nSlide < mpSlideController->getSlideNumberCount() ) )
xSlide = mpSlideController->getSlideByNumber( nSlide );
}
return xSlide;
}
// ---------------------------------------------------------
sal_Int32 SAL_CALL SlideshowImpl::getNextSlideIndex() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mxShow.is() )
{
return mpSlideController->getNextSlideIndex();
}
else
{
return -1;
}
}
// ---------------------------------------------------------
sal_Int32 SAL_CALL SlideshowImpl::getCurrentSlideIndex() throw (RuntimeException)
{
return mpSlideController.get() ? mpSlideController->getCurrentSlideIndex() : -1;
}
// --------------------------------------------------------------------
// ::com::sun::star::presentation::XSlideShowController:
// --------------------------------------------------------------------
::sal_Int32 SAL_CALL SlideshowImpl::getSlideCount() throw (RuntimeException)
{
return mpSlideController.get() ? mpSlideController->getSlideIndexCount() : 0;
}
// --------------------------------------------------------------------
Reference< XDrawPage > SAL_CALL SlideshowImpl::getSlideByIndex(::sal_Int32 Index) throw (RuntimeException, css::lang::IndexOutOfBoundsException)
{
if( (mpSlideController.get() == 0 ) || (Index < 0) || (Index >= mpSlideController->getSlideIndexCount() ) )
throw IndexOutOfBoundsException();
return mpSlideController->getSlideByNumber( mpSlideController->getSlideNumber( Index ) );
}
sal_Bool SAL_CALL SlideshowImpl::getAlwaysOnTop() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
return maPresSettings.mbAlwaysOnTop;
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::setAlwaysOnTop( sal_Bool bAlways ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( maPresSettings.mbAlwaysOnTop != bAlways )
{
maPresSettings.mbAlwaysOnTop = bAlways;
// todo, can this be changed while running?
}
}
// --------------------------------------------------------------------
sal_Bool SAL_CALL SlideshowImpl::isFullScreen() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
return maPresSettings.mbFullScreen;
}
// --------------------------------------------------------------------
sal_Bool SAL_CALL SlideshowImpl::getMouseVisible() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
return maPresSettings.mbMouseVisible;
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::setMouseVisible( sal_Bool bVisible ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( maPresSettings.mbMouseVisible != bVisible )
{
maPresSettings.mbMouseVisible = bVisible;
if( mpShowWindow )
mpShowWindow->SetMouseAutoHide( !maPresSettings.mbMouseVisible );
}
}
// --------------------------------------------------------------------
sal_Bool SAL_CALL SlideshowImpl::getUsePen() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
return maPresSettings.mbMouseAsPen;
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::setUsePen( sal_Bool bMouseAsPen ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
maPresSettings.mbMouseAsPen = bMouseAsPen;
if( mxShow.is() ) try
{
// For Pencolor;
Any aValue;
if( maPresSettings.mbMouseAsPen )
// TODO: take color from configuration
aValue <<= mnUserPaintColor;
beans::PropertyValue aPenProp;
aPenProp.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "UserPaintColor" ));
aPenProp.Value = aValue;
mxShow->setProperty( aPenProp );
#ifdef ENABLE_PRESENTER_EXTRA_UI
//for StrokeWidth :
Any aValueWidth;
if( maPresSettings.mbMouseAsPen )
aValueWidth <<= mdUserPaintStrokeWidth;
beans::PropertyValue aPenPropWidth;
aPenPropWidth.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "UserPaintStrokeWidth" ));
aPenPropWidth.Value = aValueWidth;
mxShow->setProperty( aPenPropWidth );
// for Pen Mode
Any aValueSwitchPenMode;
if( maPresSettings.mbMouseAsPen )
aValueSwitchPenMode <<= mbSwitchPenMode;
beans::PropertyValue aPenPropSwitchPenMode;
aPenPropSwitchPenMode.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "SwitchPenMode" ));
aPenPropSwitchPenMode.Value = aValueSwitchPenMode;
mxShow->setProperty( aPenPropSwitchPenMode );
//for EraseAllInk :
Any aValueEraseAllInk;
if( maPresSettings.mbMouseAsPen )
aValueEraseAllInk <<= mbEraseAllInk;
beans::PropertyValue aPenPropEraseAllInk;
aPenPropEraseAllInk.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "EraseAllInk" ));
aPenPropEraseAllInk.Value = aValueEraseAllInk;
mxShow->setProperty( aPenPropEraseAllInk );
mbEraseAllInk = false; // sets to false so not to have it applied again
#endif
}
catch( Exception& e )
{
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::setUsePen(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
}
#ifdef ENABLE_PRESENTER_EXTRA_UI
void SAL_CALL SlideshowImpl::setUseEraser( sal_Bool bMouseAsPen ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
maPresSettings.mbMouseAsPen = bMouseAsPen;
if( mxShow.is() ) try
{
//for EraseInk :
Any aValueEraseInk;
if( maPresSettings.mbMouseAsPen )
aValueEraseInk <<= mnEraseInkSize;
beans::PropertyValue aPenPropEraseInk;
aPenPropEraseInk.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "EraseInk" ));
aPenPropEraseInk.Value = aValueEraseInk;
mxShow->setProperty( aPenPropEraseInk );
// for Erase Mode
Any aValueSwitchEraserMode;
if( maPresSettings.mbMouseAsPen )
aValueSwitchEraserMode <<= mbSwitchEraserMode;
beans::PropertyValue aPenPropSwitchEraserMode;
aPenPropSwitchEraserMode.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "SwitchEraserMode" ));
aPenPropSwitchEraserMode.Value = aValueSwitchEraserMode;
mxShow->setProperty( aPenPropSwitchEraserMode );
}
catch( Exception& e )
{
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::setUseEraser(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
}
// --------------------------------------------------------------------
double SAL_CALL SlideshowImpl::getPenWidth() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
return mdUserPaintStrokeWidth;
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::setPenWidth( double dStrokeWidth ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
mdUserPaintStrokeWidth = dStrokeWidth;
mbSwitchPenMode = true;
mbSwitchEraserMode = !mbSwitchPenMode;
if( maPresSettings.mbMouseAsPen )
setUsePen( sal_True ); // update color and width
}
#endif
// --------------------------------------------------------------------
sal_Int32 SAL_CALL SlideshowImpl::getPenColor() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
return mnUserPaintColor;
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::setPenColor( sal_Int32 nColor ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
mnUserPaintColor = nColor;
#ifdef ENABLE_PRESENTER_EXTRA_UI
mbSwitchPenMode = true;
mbSwitchEraserMode = !mbSwitchPenMode;
#endif
if( maPresSettings.mbMouseAsPen )
setUsePen( sal_True ); // update color
}
#ifdef ENABLE_PRESENTER_EXTRA_UI
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::setPenMode( bool bSwitchPenMode ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
mbSwitchPenMode = bSwitchPenMode;
if(mbSwitchPenMode == true){
mbSwitchEraserMode = false;
}else{
mbSwitchEraserMode = true;
}
if( maPresSettings.mbMouseAsPen )
setUsePen( sal_True ); // Switch to Pen Mode
}
void SAL_CALL SlideshowImpl::setEraserMode(bool bSwitchEraserMode ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
mbSwitchEraserMode = bSwitchEraserMode;
if(mbSwitchEraserMode = true){
mbSwitchPenMode = false;
}else{
mbSwitchPenMode = true;
}
if( maPresSettings.mbMouseAsPen )
setUseEraser( sal_True ); // Switch to EraseMode
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::setEraseAllInk( bool bEraseAllInk ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
mbEraseAllInk=bEraseAllInk;
mbSwitchPenMode = true;
mbSwitchEraserMode = false;
if( maPresSettings.mbMouseAsPen )
setUsePen( sal_True ); // update erase all ink bool
}
void SAL_CALL SlideshowImpl::setEraseInk( sal_Int32 nEraseInkSize ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
mnEraseInkSize=nEraseInkSize;
mbSwitchPenMode = false;
mbSwitchEraserMode = true;
if( maPresSettings.mbMouseAsPen )
setUseEraser( sal_True ); // update erase ink size
}
#endif
// --------------------------------------------------------------------
// XSlideShowController Methods
// --------------------------------------------------------------------
sal_Bool SAL_CALL SlideshowImpl::isRunning( ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
return mxShow.is();
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::gotoNextEffect( ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mxShow.is() && mpSlideController.get() && mpShowWindow )
{
if( mbIsPaused )
resume();
const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
if( eMode == SHOWWINDOWMODE_END )
{
endPresentation();
}
else if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
{
mpShowWindow->RestartShow();
}
else
{
mxShow->nextEffect();
update();
}
}
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::gotoPreviousEffect( ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mxShow.is() && mpSlideController.get() && mpShowWindow )
{
if( mbIsPaused )
resume();
const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
{
mpShowWindow->RestartShow();
}
else
{
mxShow->previousEffect();
update();
}
}
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::gotoFirstSlide( ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mpShowWindow && mpSlideController.get() )
{
if( mbIsPaused )
resume();
if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_END )
{
if( mpSlideController->getSlideIndexCount() )
mpShowWindow->RestartShow( 0);
}
else
{
displaySlideIndex( 0 );
}
}
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::gotoNextSlide( ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mbIsPaused )
resume();
const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
{
mpShowWindow->RestartShow();
}
else
{
// if this is a show, ignore user inputs and
// start 20ms timer to reenable inputs to fiter
// buffered inputs during slide transition
if( meAnimationMode == ANIMATIONMODE_SHOW )
{
mbInputFreeze = true;
maInputFreezeTimer.Start();
}
if( mpSlideController.get() )
{
if( mpSlideController->nextSlide() )
{
displayCurrentSlide();
}
else
{
stopSound();
if( meAnimationMode == ANIMATIONMODE_PREVIEW )
{
endPresentation();
}
else if( maPresSettings.mbEndless )
{
if( maPresSettings.mnPauseTimeout )
{
if( mpShowWindow )
{
Graphic aGraphic( SfxApplication::GetApplicationLogo().GetBitmapEx() );
mpShowWindow->SetPauseMode( 0, maPresSettings.mnPauseTimeout, &aGraphic );
}
}
else
{
displaySlideIndex( 0 );
}
}
else
{
if( mpShowWindow )
{
mpShowWindow->SetEndMode();
pause();
}
}
}
}
}
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::gotoPreviousSlide( ) throw (RuntimeException)
{
gotoPreviousSlide(false);
}
void SlideshowImpl::gotoPreviousSlide (const bool bSkipAllMainSequenceEffects)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mxShow.is() && mpSlideController.get() ) try
{
if( mbIsPaused )
resume();
const ShowWindowMode eMode = mpShowWindow->GetShowWindowMode();
if( eMode == SHOWWINDOWMODE_END )
{
const sal_Int32 nLastSlideIndex = mpSlideController->getSlideIndexCount() - 1;
if( nLastSlideIndex >= 0 )
mpShowWindow->RestartShow( nLastSlideIndex );
}
else if( (eMode == SHOWWINDOWMODE_PAUSE) || (eMode == SHOWWINDOWMODE_BLANK) )
{
mpShowWindow->RestartShow();
}
else
{
if( mpSlideController->previousSlide())
displayCurrentSlide(bSkipAllMainSequenceEffects);
else if (bSkipAllMainSequenceEffects)
{
// We could not go to the previous slide (probably because
// the current slide is already the first one). We still
// have to call displayCurrentSlide because the calling
// slideshow can not determine whether there is a previous
// slide or not and has already prepared for a slide change.
// This slide change has to be completed now, even when
// changing to the same slide.
// Note that in this special case we do NOT pass
// bSkipAllMainSequenceEffects because we display the same
// slide as before and do not want to show all its effects.
displayCurrentSlide(false);
}
}
}
catch( Exception& e )
{
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::gotoPreviousSlide(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::gotoLastSlide() throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mpSlideController.get() )
{
if( mbIsPaused )
resume();
const sal_Int32 nLastSlideIndex = mpSlideController->getSlideIndexCount() - 1;
if( nLastSlideIndex >= 0 )
{
if( mpShowWindow->GetShowWindowMode() == SHOWWINDOWMODE_END )
{
mpShowWindow->RestartShow( nLastSlideIndex );
}
else
{
displaySlideIndex( nLastSlideIndex );
}
}
}
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::gotoBookmark( const OUString& rBookmark ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mbIsPaused )
resume();
sal_Int32 nSlideNumber = getSlideNumberForBookmark( rBookmark );
if( nSlideNumber != -1 )
displaySlideNumber( nSlideNumber );
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::gotoSlide( const Reference< XDrawPage >& xSlide )
throw(IllegalArgumentException, RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mpSlideController.get() && xSlide.is() )
{
if( mbIsPaused )
resume();
const sal_Int32 nSlideCount = mpSlideController->getSlideNumberCount();
for( sal_Int32 nSlide = 0; nSlide < nSlideCount; nSlide++ )
{
if( mpSlideController->getSlideByNumber( nSlide ) == xSlide )
{
displaySlideNumber( nSlide );
}
}
}
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::gotoSlideIndex( sal_Int32 nIndex ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mbIsPaused )
resume();
displaySlideIndex( nIndex );
}
// --------------------------------------------------------------------
void SAL_CALL SlideshowImpl::stopSound( ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
try
{
if( mxPlayer.is() )
{
mxPlayer->stop();
mxPlayer.clear();
}
}
catch( Exception& e )
{
static_cast<void>(e);
DBG_ERROR(
(OString("sd::SlideshowImpl::stopSound(), "
"exception caught: ") +
rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ),
RTL_TEXTENCODING_UTF8 )).getStr() );
}
}
// --------------------------------------------------------------------
// XIndexAccess
// --------------------------------------------------------------------
::sal_Int32 SAL_CALL SlideshowImpl::getCount( ) throw (::com::sun::star::uno::RuntimeException)
{
return getSlideCount();
}
// --------------------------------------------------------------------
::com::sun::star::uno::Any SAL_CALL SlideshowImpl::getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
{
return Any( getSlideByIndex( Index ) );
}
// --------------------------------------------------------------------
::com::sun::star::uno::Type SAL_CALL SlideshowImpl::getElementType( ) throw (::com::sun::star::uno::RuntimeException)
{
return XDrawPage::static_type();
}
// --------------------------------------------------------------------
::sal_Bool SAL_CALL SlideshowImpl::hasElements( ) throw (::com::sun::star::uno::RuntimeException)
{
return getSlideCount() != 0;
}
// --------------------------------------------------------------------
Reference< XSlideShow > SAL_CALL SlideshowImpl::getSlideShow() throw (RuntimeException)
{
return mxShow;
}
// --------------------------------------------------------------------
PresentationSettingsEx::PresentationSettingsEx( const PresentationSettingsEx& r )
: PresentationSettings( r )
, mbRehearseTimings(r.mbRehearseTimings)
, mbPreview(r.mbPreview)
, mpParentWindow( 0 )
{
}
PresentationSettingsEx::PresentationSettingsEx( PresentationSettings& r )
: PresentationSettings( r )
, mbRehearseTimings(sal_False)
, mbPreview(sal_False)
, mpParentWindow(0)
{
}
void PresentationSettingsEx::SetArguments( const Sequence< PropertyValue >& rArguments ) throw (IllegalArgumentException)
{
sal_Int32 nArguments = rArguments.getLength();
const PropertyValue* pValue = rArguments.getConstArray();
while( nArguments-- )
{
SetPropertyValue( pValue->Name, pValue->Value );
pValue++;
}
}
void PresentationSettingsEx::SetPropertyValue( const OUString& rProperty, const Any& rValue ) throw (IllegalArgumentException)
{
if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RehearseTimings") ) )
{
if( rValue >>= mbRehearseTimings )
return;
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Preview") ) )
{
if( rValue >>= mbPreview )
return;
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AnimationNode") ) )
{
if( rValue >>= mxAnimationNode )
return;
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ParentWindow") ) )
{
Reference< XWindow > xWindow;
if( rValue >>= xWindow )
{
mpParentWindow = xWindow.is() ? VCLUnoHelper::GetWindow( xWindow ) : 0;
return;
}
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AllowAnimations") ) )
{
if( rValue >>= mbAnimationAllowed )
return;
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("AllowAnimations") ) )
{
if( rValue >>= mbAnimationAllowed )
return;
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("FirstPage") ) )
{
OUString aPresPage;
if( rValue >>= aPresPage )
{
maPresPage = getUiNameFromPageApiNameImpl(aPresPage);
mbCustomShow = sal_False;
mbAll = sal_False;
return;
}
else
{
if( rValue >>= mxStartPage )
return;
}
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsAlwaysOnTop") ) )
{
if( rValue >>= mbAlwaysOnTop )
return;
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsAutomatic") ) )
{
if( rValue >>= mbManual )
return;
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsEndless") ) )
{
if( rValue >>= mbEndless )
return;
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsFullScreen") ) )
{
if( rValue >>= mbFullScreen )
return;
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("IsMouseVisible") ) )
{
if( rValue >>= mbMouseVisible )
return;
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Pause") ) )
{
sal_Int32 nPause = -1;
if( (rValue >>= nPause) && (nPause >= 0) )
{
mnPauseTimeout = nPause;
return;
}
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("StartWithNavigator") ) )
{
if( rValue >>= mbStartWithNavigator )
return;
}
else if( rProperty.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UsePen") ) )
{
if( rValue >>= mbMouseAsPen )
return;
}
throw IllegalArgumentException();
}
////////////////////////////////
// ---------------------------------------------------------
// XAnimationListener
// ---------------------------------------------------------
SlideShowListenerProxy::SlideShowListenerProxy( const rtl::Reference< SlideshowImpl >& xController, const css::uno::Reference< css::presentation::XSlideShow >& xSlideShow )
: maListeners( m_aMutex )
, mxController( xController )
, mxSlideShow( xSlideShow )
{
}
// ---------------------------------------------------------
SlideShowListenerProxy::~SlideShowListenerProxy()
{
}
// ---------------------------------------------------------
void SlideShowListenerProxy::addAsSlideShowListener()
{
if( mxSlideShow.is() )
{
Reference< XSlideShowListener > xSlideShowListener( this );
mxSlideShow->addSlideShowListener( xSlideShowListener );
}
}
// ---------------------------------------------------------
void SlideShowListenerProxy::removeAsSlideShowListener()
{
if( mxSlideShow.is() )
{
Reference< XSlideShowListener > xSlideShowListener( this );
mxSlideShow->removeSlideShowListener( xSlideShowListener );
}
}
// ---------------------------------------------------------
void SlideShowListenerProxy::addShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape )
{
if( mxSlideShow.is() )
{
Reference< XShapeEventListener > xListener( this );
mxSlideShow->addShapeEventListener( xListener, xShape );
}
}
// ---------------------------------------------------------
void SlideShowListenerProxy::removeShapeEventListener( const css::uno::Reference< css::drawing::XShape >& xShape )
{
if( mxSlideShow.is() )
{
Reference< XShapeEventListener > xListener( this );
mxSlideShow->removeShapeEventListener( xListener, xShape );
}
}
// ---------------------------------------------------------
void SlideShowListenerProxy::addSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& xListener )
{
maListeners.addInterface(xListener);
}
// ---------------------------------------------------------
void SlideShowListenerProxy::removeSlideShowListener( const css::uno::Reference< css::presentation::XSlideShowListener >& xListener )
{
maListeners.removeInterface(xListener);
}
// ---------------------------------------------------------
void SAL_CALL SlideShowListenerProxy::beginEvent( const Reference< XAnimationNode >& xNode ) throw (RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
if( maListeners.getLength() >= 0 )
maListeners.forEach<XSlideShowListener>( boost::bind( &XAnimationListener::beginEvent, _1, boost::cref(xNode) ));
}
// ---------------------------------------------------------
void SAL_CALL SlideShowListenerProxy::endEvent( const Reference< XAnimationNode >& xNode ) throw (RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
if( maListeners.getLength() >= 0 )
maListeners.forEach<XSlideShowListener>( boost::bind( &XAnimationListener::endEvent, _1, boost::cref(xNode) ));
}
// ---------------------------------------------------------
void SAL_CALL SlideShowListenerProxy::repeat( const Reference< XAnimationNode >& xNode, ::sal_Int32 nRepeat ) throw (RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
if( maListeners.getLength() >= 0 )
maListeners.forEach<XSlideShowListener>( boost::bind( &XAnimationListener::repeat, _1, boost::cref(xNode), boost::cref(nRepeat) ));
}
// ---------------------------------------------------------
// ::com::sun::star::presentation::XSlideShowListener:
// ---------------------------------------------------------
void SAL_CALL SlideShowListenerProxy::paused( ) throw (::com::sun::star::uno::RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
if( maListeners.getLength() >= 0 )
maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::paused ) );
}
// ---------------------------------------------------------
void SAL_CALL SlideShowListenerProxy::resumed( ) throw (::com::sun::star::uno::RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
if( maListeners.getLength() >= 0 )
maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::resumed ) );
}
// ---------------------------------------------------------
void SAL_CALL SlideShowListenerProxy::slideTransitionStarted( ) throw (RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
if( maListeners.getLength() >= 0 )
maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::slideTransitionStarted ) );
}
// ---------------------------------------------------------
void SAL_CALL SlideShowListenerProxy::slideTransitionEnded( ) throw (::com::sun::star::uno::RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
if( maListeners.getLength() >= 0 )
maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::slideTransitionEnded ) );
}
// ---------------------------------------------------------
void SAL_CALL SlideShowListenerProxy::slideAnimationsEnded( ) throw (::com::sun::star::uno::RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
if( maListeners.getLength() >= 0 )
maListeners.forEach<XSlideShowListener>( boost::mem_fn( &XSlideShowListener::slideAnimationsEnded ) );
}
// ---------------------------------------------------------
void SlideShowListenerProxy::slideEnded(sal_Bool bReverse) throw (RuntimeException)
{
{
::osl::MutexGuard aGuard( m_aMutex );
if( maListeners.getLength() >= 0 )
maListeners.forEach<XSlideShowListener>(
boost::bind( &XSlideShowListener::slideEnded, _1, bReverse) );
}
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mxController.is() )
mxController->slideEnded(bReverse);
}
}
// ---------------------------------------------------------
void SlideShowListenerProxy::hyperLinkClicked( rtl::OUString const& aHyperLink ) throw (RuntimeException)
{
{
::osl::MutexGuard aGuard( m_aMutex );
if( maListeners.getLength() >= 0 )
maListeners.forEach<XSlideShowListener>( boost::bind( &XSlideShowListener::hyperLinkClicked, _1, boost::cref(aHyperLink) ));
}
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mxController.is() )
mxController->hyperLinkClicked(aHyperLink);
}
}
// ---------------------------------------------------------
// XEventListener
// ---------------------------------------------------------
void SAL_CALL SlideShowListenerProxy::disposing( const ::com::sun::star::lang::EventObject& aDisposeEvent ) throw (RuntimeException)
{
maListeners.disposeAndClear( aDisposeEvent );
mxController.clear();
mxSlideShow.clear();
}
// ---------------------------------------------------------
// XShapeEventListener
// ---------------------------------------------------------
void SAL_CALL SlideShowListenerProxy::click( const Reference< XShape >& xShape, const ::com::sun::star::awt::MouseEvent& aOriginalEvent ) throw (RuntimeException)
{
::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
if( mxController.is() )
mxController->click(xShape, aOriginalEvent );
}
} // namespace ::sd
|