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
|
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: metafileprimitive2d.cxx,v $
*
* $Revision: 1.6 $
*
* last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_drawinglayer.hxx"
#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
#include <basegfx/tools/canvastools.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
#include <basegfx/color/bcolor.hxx>
#include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx>
#include <vcl/lineinfo.hxx>
#include <drawinglayer/attribute/lineattribute.hxx>
#include <drawinglayer/attribute/strokeattribute.hxx>
#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
#include <vcl/metaact.hxx>
#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
#include <vcl/salbtype.hxx>
#include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx>
#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
#include <vcl/svapp.hxx>
#include <drawinglayer/primitive2d/alphaprimitive2d.hxx>
#include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx>
#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
#include <basegfx/polygon/b2dpolygonclipper.hxx>
#include <drawinglayer/primitive2d/invertprimitive2d.hxx>
#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/wallpaperprimitive2d.hxx>
#include <drawinglayer/primitive2d/textprimitive2d.hxx>
#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
#include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
#include <i18npool/mslangid.hxx>
#include <drawinglayer/primitive2d/textlineprimitive2d.hxx>
#include <drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx>
#include <drawinglayer/primitive2d/epsprimitive2d.hxx>
#include <numeric>
//////////////////////////////////////////////////////////////////////////////
using namespace com::sun::star;
//////////////////////////////////////////////////////////////////////////////
namespace
{
/** helper class for graphic context
This class allows to hold a complete status of classic
VCL OutputDevice stati. This data is needed for correct
interpretation of the MetaFile action flow.
*/
class PropertyHolder
{
private:
/// current transformation (aka MapMode)
basegfx::B2DHomMatrix maTransformation;
MapUnit maMapUnit;
/// current colors
basegfx::BColor maLineColor;
basegfx::BColor maFillColor;
basegfx::BColor maTextColor;
basegfx::BColor maTextFillColor;
basegfx::BColor maTextLineColor;
basegfx::BColor maOverlineColor;
/// clipping, font, etc.
Region maRegion;
Font maFont;
RasterOp maRasterOp;
sal_uInt32 mnLayoutMode;
LanguageType maLanguageType;
sal_uInt16 mnPushFlags;
/// bitfield
/// contains all active markers
bool mbLineColor : 1;
bool mbFillColor : 1;
bool mbTextColor : 1;
bool mbTextFillColor : 1;
bool mbTextLineColor : 1;
bool mbOverlineColor : 1;
bool mbRegion : 1;
public:
PropertyHolder()
: maTransformation(),
maMapUnit(MAP_100TH_MM),
maLineColor(),
maFillColor(),
maTextColor(COL_BLACK),
maTextFillColor(),
maTextLineColor(),
maOverlineColor(),
maRegion(),
maFont(),
maRasterOp(ROP_OVERPAINT),
mnLayoutMode(0),
maLanguageType(0),
mnPushFlags(0),
mbLineColor(false),
mbFillColor(false),
mbTextColor(true),
mbTextFillColor(false),
mbTextLineColor(false),
mbOverlineColor(false),
mbRegion(false)
{
}
~PropertyHolder()
{
}
/// read/write accesses
const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; }
void setTransformation(const basegfx::B2DHomMatrix& rNew) { if(rNew != maTransformation) maTransformation = rNew; }
MapUnit getMapUnit() const { return maMapUnit; }
void setMapUnit(MapUnit eNew) { if(eNew != maMapUnit) maMapUnit = eNew; }
const basegfx::BColor& getLineColor() const { return maLineColor; }
void setLineColor(const basegfx::BColor& rNew) { if(rNew != maLineColor) maLineColor = rNew; }
bool getLineColorActive() const { return mbLineColor; }
void setLineColorActive(bool bNew) { if(bNew != mbLineColor) mbLineColor = bNew; }
const basegfx::BColor& getFillColor() const { return maFillColor; }
void setFillColor(const basegfx::BColor& rNew) { if(rNew != maFillColor) maFillColor = rNew; }
bool getFillColorActive() const { return mbFillColor; }
void setFillColorActive(bool bNew) { if(bNew != mbFillColor) mbFillColor = bNew; }
const basegfx::BColor& getTextColor() const { return maTextColor; }
void setTextColor(const basegfx::BColor& rNew) { if(rNew != maTextColor) maTextColor = rNew; }
bool getTextColorActive() const { return mbTextColor; }
void setTextColorActive(bool bNew) { if(bNew != mbTextColor) mbTextColor = bNew; }
const basegfx::BColor& getTextFillColor() const { return maTextFillColor; }
void setTextFillColor(const basegfx::BColor& rNew) { if(rNew != maTextFillColor) maTextFillColor = rNew; }
bool getTextFillColorActive() const { return mbTextFillColor; }
void setTextFillColorActive(bool bNew) { if(bNew != mbTextFillColor) mbTextFillColor = bNew; }
const basegfx::BColor& getTextLineColor() const { return maTextLineColor; }
void setTextLineColor(const basegfx::BColor& rNew) { if(rNew != maTextLineColor) maTextLineColor = rNew; }
bool getTextLineColorActive() const { return mbTextLineColor; }
void setTextLineColorActive(bool bNew) { if(bNew != mbTextLineColor) mbTextLineColor = bNew; }
const basegfx::BColor& getOverlineColor() const { return maOverlineColor; }
void setOverlineColor(const basegfx::BColor& rNew) { if(rNew != maOverlineColor) maOverlineColor = rNew; }
bool getOverlineColorActive() const { return mbOverlineColor; }
void setOverlineColorActive(bool bNew) { if(bNew != mbOverlineColor) mbOverlineColor = bNew; }
const Region& getRegion() const { return maRegion; }
void setRegion(const Region& rRegion) { if(rRegion != maRegion) maRegion = rRegion; }
bool getRegionActive() const { return mbRegion; }
void setRegionActive(bool bNew) { if(bNew != mbRegion) mbRegion = bNew; }
const Font& getFont() const { return maFont; }
void setFont(const Font& rFont) { if(rFont != maFont) maFont = rFont; }
const RasterOp& getRasterOp() const { return maRasterOp; }
void setRasterOp(const RasterOp& rRasterOp) { if(rRasterOp != maRasterOp) maRasterOp = rRasterOp; }
bool isRasterOpInvert() const { return (ROP_XOR == maRasterOp || ROP_INVERT == maRasterOp); }
bool isRasterOpForceBlack() const { return ROP_0 == maRasterOp; }
bool isRasterOpActive() const { return isRasterOpInvert() || isRasterOpForceBlack(); }
sal_uInt32 getLayoutMode() const { return mnLayoutMode; }
void setLayoutMode(sal_uInt32 nNew) { if(nNew != mnLayoutMode) mnLayoutMode = nNew; }
LanguageType getLanguageType() const { return maLanguageType; }
void setLanguageType(LanguageType aNew) { if(aNew != maLanguageType) maLanguageType = aNew; }
sal_uInt16 getPushFlags() const { return mnPushFlags; }
void setPushFlags(sal_uInt16 nNew) { if(nNew != mnPushFlags) mnPushFlags = nNew; }
bool getLineOrFillActive() const { return (mbLineColor || mbFillColor); }
};
} // end of anonymous namespace
//////////////////////////////////////////////////////////////////////////////
namespace
{
/** stack for properites
This class builds a stack based on the PropertyHolder
class. It encapsulates the pointer/new/delete usage to
make it safe and implements the push/pop as needed by a
VCL Metafile interpreter. The critical part here are the
flag values VCL OutputDevice uses here; not all stuff is
pushed and thus needs to be copied at pop.
*/
class PropertyHolders
{
private:
std::vector< PropertyHolder* > maPropertyHolders;
public:
PropertyHolders()
{
maPropertyHolders.push_back(new PropertyHolder());
}
sal_uInt32 size()
{
return maPropertyHolders.size();
}
void Push(sal_uInt16 nPushFlags)
{
if(nPushFlags)
{
OSL_ENSURE(maPropertyHolders.size(), "PropertyHolders: PUSH with no property holders (!)");
PropertyHolder* pNew = new PropertyHolder(*maPropertyHolders.back());
pNew->setPushFlags(nPushFlags);
maPropertyHolders.push_back(pNew);
}
}
void Pop()
{
OSL_ENSURE(maPropertyHolders.size(), "PropertyHolders: POP with no property holders (!)");
const sal_uInt32 nSize(maPropertyHolders.size());
if(nSize)
{
const PropertyHolder* pTip = maPropertyHolders.back();
const sal_uInt16 nPushFlags(pTip->getPushFlags());
if(nPushFlags)
{
if(nSize > 1)
{
// copy back content for all non-set flags
PropertyHolder* pLast = maPropertyHolders[nSize - 2];
if(PUSH_ALL != nPushFlags)
{
if(!(nPushFlags & PUSH_LINECOLOR ))
{
pLast->setLineColor(pTip->getLineColor());
pLast->setLineColorActive(pTip->getLineColorActive());
}
if(!(nPushFlags & PUSH_FILLCOLOR ))
{
pLast->setFillColor(pTip->getFillColor());
pLast->setFillColorActive(pTip->getFillColorActive());
}
if(!(nPushFlags & PUSH_FONT ))
{
pLast->setFont(pTip->getFont());
}
if(!(nPushFlags & PUSH_TEXTCOLOR ))
{
pLast->setTextColor(pTip->getTextColor());
pLast->setTextColorActive(pTip->getTextColorActive());
}
if(!(nPushFlags & PUSH_MAPMODE ))
{
pLast->setTransformation(pTip->getTransformation());
pLast->setMapUnit(pTip->getMapUnit());
}
if(!(nPushFlags & PUSH_CLIPREGION ))
{
pLast->setRegion(pTip->getRegion());
pLast->setRegionActive(pTip->getRegionActive());
}
if(!(nPushFlags & PUSH_RASTEROP ))
{
pLast->setRasterOp(pTip->getRasterOp());
}
if(!(nPushFlags & PUSH_TEXTFILLCOLOR ))
{
pLast->setTextFillColor(pTip->getTextFillColor());
pLast->setTextFillColorActive(pTip->getTextFillColorActive());
}
if(!(nPushFlags & PUSH_TEXTALIGN ))
{
if(pLast->getFont().GetAlign() != pTip->getFont().GetAlign())
{
Font aFont(pLast->getFont());
aFont.SetAlign(pTip->getFont().GetAlign());
pLast->setFont(aFont);
}
}
if(!(nPushFlags & PUSH_REFPOINT ))
{
// not supported
}
if(!(nPushFlags & PUSH_TEXTLINECOLOR ))
{
pLast->setTextLineColor(pTip->getTextLineColor());
pLast->setTextLineColorActive(pTip->getTextLineColorActive());
}
if(!(nPushFlags & PUSH_TEXTLAYOUTMODE ))
{
pLast->setLayoutMode(pTip->getLayoutMode());
}
if(!(nPushFlags & PUSH_TEXTLANGUAGE ))
{
pLast->setLanguageType(pTip->getLanguageType());
}
if(!(nPushFlags & PUSH_OVERLINECOLOR ))
{
pLast->setOverlineColor(pTip->getOverlineColor());
pLast->setOverlineColorActive(pTip->getOverlineColorActive());
}
}
}
// execute the pop
delete maPropertyHolders.back();
maPropertyHolders.pop_back();
}
}
}
PropertyHolder& Current()
{
OSL_ENSURE(maPropertyHolders.size(), "PropertyHolders: CURRENT with no property holders (!)");
return *maPropertyHolders.back();
}
~PropertyHolders()
{
while(maPropertyHolders.size())
{
delete maPropertyHolders.back();
maPropertyHolders.pop_back();
}
}
};
} // end of anonymous namespace
//////////////////////////////////////////////////////////////////////////////
namespace
{
/** helper to convert a Region to a B2DPolyPolygon
when it does not yet contain one. In the future
this may be expanded to merge the polygons created
from rectangles or use a special algo to directly turn
the spans of regions to a single, already merged
PolyPolygon.
*/
basegfx::B2DPolyPolygon getB2DPolyPolygonFromRegion(const Region& rRegion)
{
basegfx::B2DPolyPolygon aRetval;
if(!rRegion.IsEmpty())
{
Region aRegion(rRegion);
aRetval = aRegion.GetB2DPolyPolygon();
if(!aRetval.count())
{
RegionHandle aRegionHandle(aRegion.BeginEnumRects());
Rectangle aRegionRectangle;
while(aRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
{
if(!aRegionRectangle.IsEmpty())
{
const basegfx::B2DRange aRegionRange(
aRegionRectangle.Left(), aRegionRectangle.Top(),
aRegionRectangle.Right(), aRegionRectangle.Bottom());
aRetval.append(basegfx::tools::createPolygonFromRect(aRegionRange));
}
}
aRegion.EndEnumRects(aRegionHandle);
}
}
return aRetval;
}
} // end of anonymous namespace
//////////////////////////////////////////////////////////////////////////////
namespace
{
/** Helper class to buffer and hold a Primive target vector. It
encapsulates the new/delete functionality and aloows to work
on pointers of the implementation classes. All data will
be converted to uno sequences of uno references when accessing the
data.
*/
class TargetHolder
{
private:
std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aTargets;
public:
TargetHolder()
: aTargets()
{
}
~TargetHolder()
{
const sal_uInt32 nCount(aTargets.size());
for(sal_uInt32 a(0); a < nCount; a++)
{
delete aTargets[a];
}
}
sal_uInt32 size()
{
return aTargets.size();
}
void append(drawinglayer::primitive2d::BasePrimitive2D* pCandidate)
{
if(pCandidate)
{
aTargets.push_back(pCandidate);
}
}
drawinglayer::primitive2d::Primitive2DSequence getPrimitive2DSequence(const PropertyHolder& rPropertyHolder)
{
const sal_uInt32 nCount(aTargets.size());
drawinglayer::primitive2d::Primitive2DSequence xRetval(nCount);
for(sal_uInt32 a(0); a < nCount; a++)
{
xRetval[a] = aTargets[a];
}
// All Targets were pointers, but do not need to be deleted since they
// were converted to UNO API references now, so they stay as long as
// referenced. Do NOT delete the C++ implementation classes here, but clear
// the buffer to not delete them in the destructor.
aTargets.clear();
if(xRetval.hasElements() && rPropertyHolder.getRegionActive())
{
const Region& rRegion = rPropertyHolder.getRegion();
if(!rRegion.IsEmpty())
{
basegfx::B2DPolyPolygon aClipPolyPolygon(getB2DPolyPolygonFromRegion(rRegion));
if(aClipPolyPolygon.count())
{
aClipPolyPolygon.transform(rPropertyHolder.getTransformation());
const drawinglayer::primitive2d::Primitive2DReference xMask(
new drawinglayer::primitive2d::MaskPrimitive2D(
aClipPolyPolygon,
xRetval));
xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xMask, 1);
}
}
}
return xRetval;
}
};
} // end of anonymous namespace
//////////////////////////////////////////////////////////////////////////////
namespace
{
/** Helper class which builds a stack on the TargetHolder class */
class TargetHolders
{
private:
std::vector< TargetHolder* > maTargetHolders;
public:
TargetHolders()
{
maTargetHolders.push_back(new TargetHolder());
}
sal_uInt32 size()
{
return maTargetHolders.size();
}
void Push()
{
maTargetHolders.push_back(new TargetHolder());
}
void Pop()
{
OSL_ENSURE(maTargetHolders.size(), "TargetHolders: POP with no property holders (!)");
if(maTargetHolders.size())
{
delete maTargetHolders.back();
maTargetHolders.pop_back();
}
}
TargetHolder& Current()
{
OSL_ENSURE(maTargetHolders.size(), "TargetHolders: CURRENT with no property holders (!)");
return *maTargetHolders.back();
}
~TargetHolders()
{
while(maTargetHolders.size())
{
delete maTargetHolders.back();
maTargetHolders.pop_back();
}
}
};
} // end of anonymous namespace
//////////////////////////////////////////////////////////////////////////////
namespace drawinglayer
{
namespace primitive2d
{
/** NonOverlappingFillGradientPrimitive2D class
This is a special version of the FillGradientPrimitive2D which decomposes
to a non-overlapping geometry version of the gradient. This needs to be
used to support the old XOR paint-'trick'.
It does not need an own identifier since a renderer who wants to interpret
it itself may do so. It just overloads the decomposition of the C++
implementation class to do an alternative decomposition.
*/
class NonOverlappingFillGradientPrimitive2D : public FillGradientPrimitive2D
{
protected:
/// local decomposition.
virtual Primitive2DSequence create2DDecomposition(
const geometry::ViewInformation2D& rViewInformation) const;
public:
/// constructor
NonOverlappingFillGradientPrimitive2D(
const basegfx::B2DRange& rObjectRange,
const attribute::FillGradientAttribute& rFillGradient)
: FillGradientPrimitive2D(rObjectRange, rFillGradient)
{
}
};
Primitive2DSequence NonOverlappingFillGradientPrimitive2D::create2DDecomposition(
const geometry::ViewInformation2D& /*rViewInformation*/) const
{
return createFill(false);
}
} // end of namespace primitive2d
} // end of namespace drawinglayer
//////////////////////////////////////////////////////////////////////////////
namespace
{
/** helper to convert a MapMode to a transformation */
basegfx::B2DHomMatrix getTransformFromMapMode(const MapMode& rMapMode)
{
basegfx::B2DHomMatrix aMapping;
const Fraction aNoScale(1, 1);
const Point& rOrigin(rMapMode.GetOrigin());
if(0 != rOrigin.X() || 0 != rOrigin.Y())
{
aMapping.translate(rOrigin.X(), rOrigin.Y());
}
if(rMapMode.GetScaleX() != aNoScale || rMapMode.GetScaleY() != aNoScale)
{
aMapping.scale(
double(rMapMode.GetScaleX()),
double(rMapMode.GetScaleY()));
}
return aMapping;
}
/** helper to create a PointArrayPrimitive2D based on current context */
void createPointArrayPrimitive(
const std::vector< basegfx::B2DPoint >& rPositions,
TargetHolder& rTarget,
PropertyHolder& rProperties,
basegfx::BColor aBColor)
{
if(rPositions.size())
{
if(rProperties.getTransformation().isIdentity())
{
rTarget.append(
new drawinglayer::primitive2d::PointArrayPrimitive2D(
rPositions,
aBColor));
}
else
{
std::vector< basegfx::B2DPoint > aPositions(rPositions);
for(sal_uInt32 a(0); a < aPositions.size(); a++)
{
aPositions[a] = rProperties.getTransformation() * aPositions[a];
}
rTarget.append(
new drawinglayer::primitive2d::PointArrayPrimitive2D(
aPositions,
aBColor));
}
}
}
/** helper to create a PolygonHairlinePrimitive2D based on current context */
void createHairlinePrimitive(
const basegfx::B2DPolygon& rLinePolygon,
TargetHolder& rTarget,
PropertyHolder& rProperties)
{
if(rLinePolygon.count())
{
basegfx::B2DPolygon aLinePolygon(rLinePolygon);
aLinePolygon.transform(rProperties.getTransformation());
rTarget.append(
new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
aLinePolygon,
rProperties.getLineColor()));
}
}
/** helper to create a PolyPolygonColorPrimitive2D based on current context */
void createFillPrimitive(
const basegfx::B2DPolyPolygon& rFillPolyPolygon,
TargetHolder& rTarget,
PropertyHolder& rProperties)
{
if(rFillPolyPolygon.count())
{
basegfx::B2DPolyPolygon aFillPolyPolygon(rFillPolyPolygon);
aFillPolyPolygon.transform(rProperties.getTransformation());
rTarget.append(
new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
aFillPolyPolygon,
rProperties.getFillColor()));
}
}
/** helper to create a PolygonStrokePrimitive2D based on current context */
void createLinePrimitive(
const basegfx::B2DPolygon& rLinePolygon,
const LineInfo& rLineInfo,
TargetHolder& rTarget,
PropertyHolder& rProperties)
{
if(rLinePolygon.count())
{
const bool bDashDotUsed(LINE_DASH == rLineInfo.GetStyle());
const bool bWidthUsed(rLineInfo.GetWidth() > 1);
if(bDashDotUsed || bWidthUsed)
{
basegfx::B2DPolygon aLinePolygon(rLinePolygon);
aLinePolygon.transform(rProperties.getTransformation());
const drawinglayer::attribute::LineAttribute aLineAttribute(
rProperties.getLineColor(),
bWidthUsed ? rLineInfo.GetWidth() : 0.0,
rLineInfo.GetLineJoin());
if(bDashDotUsed)
{
::std::vector< double > fDotDashArray;
const double fDashLen(rLineInfo.GetDashLen());
const double fDotLen(rLineInfo.GetDotLen());
const double fDistance(rLineInfo.GetDistance());
for(sal_uInt16 a(0); a < rLineInfo.GetDashCount(); a++)
{
fDotDashArray.push_back(fDashLen);
fDotDashArray.push_back(fDistance);
}
for(sal_uInt16 b(0); b < rLineInfo.GetDotCount(); b++)
{
fDotDashArray.push_back(fDotLen);
fDotDashArray.push_back(fDistance);
}
const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0));
const drawinglayer::attribute::StrokeAttribute aStrokeAttribute(
fDotDashArray,
fAccumulated);
rTarget.append(
new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
aLinePolygon,
aLineAttribute,
aStrokeAttribute));
}
else
{
rTarget.append(
new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
aLinePolygon,
aLineAttribute));
}
}
else
{
createHairlinePrimitive(rLinePolygon, rTarget, rProperties);
}
}
}
/** helper to create needed line and fill primitives based on current context */
void createHairlineAndFillPrimitive(
const basegfx::B2DPolygon& rPolygon,
TargetHolder& rTarget,
PropertyHolder& rProperties)
{
if(rProperties.getFillColorActive())
{
createFillPrimitive(basegfx::B2DPolyPolygon(rPolygon), rTarget, rProperties);
}
if(rProperties.getLineColorActive())
{
createHairlinePrimitive(rPolygon, rTarget, rProperties);
}
}
/** helper to create needed line and fill primitives based on current context */
void createHairlineAndFillPrimitive(
const basegfx::B2DPolyPolygon& rPolyPolygon,
TargetHolder& rTarget,
PropertyHolder& rProperties)
{
if(rProperties.getFillColorActive())
{
createFillPrimitive(rPolyPolygon, rTarget, rProperties);
}
if(rProperties.getLineColorActive())
{
for(sal_uInt32 a(0); a < rPolyPolygon.count(); a++)
{
createHairlinePrimitive(rPolyPolygon.getB2DPolygon(a), rTarget, rProperties);
}
}
}
/** helper to create DiscreteBitmapPrimitive2D based on current context.
The DiscreteBitmapPrimitive2D is especially created for this usage
since no other usage defines a bitmap visualisation based on top-left
position and size in pixels. At the end it will create a view-dependent
transformed embedding of a BitmapPrimitive2D.
*/
void createBitmapExPrimitive(
const BitmapEx& rBitmapEx,
const Point& rPoint,
TargetHolder& rTarget,
PropertyHolder& rProperties)
{
if(!rBitmapEx.IsEmpty())
{
basegfx::B2DPoint aPoint(rPoint.X(), rPoint.Y());
aPoint = rProperties.getTransformation() * aPoint;
rTarget.append(
new drawinglayer::primitive2d::DiscreteBitmapPrimitive2D(
rBitmapEx,
aPoint));
}
}
/** helper to create BitmapPrimitive2D based on current context */
void createBitmapExPrimitive(
const BitmapEx& rBitmapEx,
const Point& rPoint,
const Size& rSize,
TargetHolder& rTarget,
PropertyHolder& rProperties)
{
if(!rBitmapEx.IsEmpty())
{
basegfx::B2DHomMatrix aObjectTransform;
aObjectTransform.set(0, 0, rSize.Width());
aObjectTransform.set(1, 1, rSize.Height());
aObjectTransform.set(0, 2, rPoint.X());
aObjectTransform.set(1, 2, rPoint.Y());
aObjectTransform = rProperties.getTransformation() * aObjectTransform;
rTarget.append(
new drawinglayer::primitive2d::BitmapPrimitive2D(
rBitmapEx,
aObjectTransform));
}
}
/** helper to create a regular BotmapEx from a MaskAction (definitions
which use a bitmap without alpha but define one of the colors as
transparent)
*/
BitmapEx createMaskBmpEx(const Bitmap& rBitmap, const Color& rMaskColor)
{
const Color aWhite(COL_WHITE);
BitmapPalette aBiLevelPalette(2);
aBiLevelPalette[0] = aWhite;
aBiLevelPalette[1] = rMaskColor;
Bitmap aMask(rBitmap.CreateMask(aWhite));
Bitmap aSolid(rBitmap.GetSizePixel(), 1, &aBiLevelPalette);
aSolid.Erase(rMaskColor);
return BitmapEx(aSolid, aMask);
}
/** helper to convert from a VCL Gradient definition to the corresponding
data for primitive representation
*/
drawinglayer::attribute::FillGradientAttribute createFillGradientAttribute(const Gradient& rGradient)
{
const Color aStartColor(rGradient.GetStartColor());
const sal_uInt16 nStartIntens(rGradient.GetStartIntensity());
basegfx::BColor aStart(aStartColor.getBColor());
if(nStartIntens != 100)
{
const basegfx::BColor aBlack;
aStart = interpolate(aBlack, aStart, (double)nStartIntens * 0.01);
}
const Color aEndColor(rGradient.GetEndColor());
const sal_uInt16 nEndIntens(rGradient.GetEndIntensity());
basegfx::BColor aEnd(aEndColor.getBColor());
if(nEndIntens != 100)
{
const basegfx::BColor aBlack;
aEnd = interpolate(aBlack, aEnd, (double)nEndIntens * 0.01);
}
drawinglayer::attribute::GradientStyle aGradientStyle(drawinglayer::attribute::GRADIENTSTYLE_RECT);
switch(rGradient.GetStyle())
{
case GRADIENT_LINEAR :
{
aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_LINEAR;
break;
}
case GRADIENT_AXIAL :
{
aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_AXIAL;
break;
}
case GRADIENT_RADIAL :
{
aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_RADIAL;
break;
}
case GRADIENT_ELLIPTICAL :
{
aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_ELLIPTICAL;
break;
}
case GRADIENT_SQUARE :
{
aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_SQUARE;
break;
}
default : // GRADIENT_RECT
{
aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_RECT;
break;
}
}
return drawinglayer::attribute::FillGradientAttribute(
aGradientStyle,
(double)rGradient.GetBorder() * 0.01,
(double)rGradient.GetOfsX() * 0.01,
(double)rGradient.GetOfsY() * 0.01,
(double)rGradient.GetAngle() * F_PI1800,
aStart,
aEnd,
rGradient.GetSteps());
}
/** helper to convert from a VCL Hatch definition to the corresponding
data for primitive representation
*/
drawinglayer::attribute::FillHatchAttribute createFillHatchAttribute(const Hatch& rHatch)
{
drawinglayer::attribute::HatchStyle aHatchStyle(drawinglayer::attribute::HATCHSTYLE_SINGLE);
switch(rHatch.GetStyle())
{
default : // case HATCH_SINGLE :
{
aHatchStyle = drawinglayer::attribute::HATCHSTYLE_SINGLE;
}
case HATCH_DOUBLE :
{
aHatchStyle = drawinglayer::attribute::HATCHSTYLE_DOUBLE;
}
case HATCH_TRIPLE :
{
aHatchStyle = drawinglayer::attribute::HATCHSTYLE_TRIPLE;
}
}
return drawinglayer::attribute::FillHatchAttribute(
aHatchStyle,
(double)rHatch.GetDistance(),
(double)rHatch.GetAngle() * F_PI1800,
rHatch.GetColor().getBColor(),
false);
}
/** helper to take needed action on ClipRegion change. This method needs to be called
on any Region change, e.g. at the obvious actions doing this, but also at pop-calls
whcih change the Region of the current context. It takes care of creating the
current embeddec context, set the new Region at the context and eventually prepare
a new target for embracing new geometry to the current region
*/
void HandleNewClipRegion(
const Region* pRegion,
TargetHolders& rTargetHolders,
PropertyHolders& rPropertyHolders)
{
// process evtl. created primitives which belong to the current region settings
if(rPropertyHolders.Current().getRegionActive() && rTargetHolders.size() > 1)
{
drawinglayer::primitive2d::Primitive2DSequence aSubContent;
if(!rPropertyHolders.Current().getRegion().IsEmpty() && rTargetHolders.Current().size())
{
aSubContent = rTargetHolders.Current().getPrimitive2DSequence(rPropertyHolders.Current());
}
rTargetHolders.Pop();
if(aSubContent.hasElements())
{
rTargetHolders.Current().append(
new drawinglayer::primitive2d::GroupPrimitive2D(
aSubContent));
}
}
// apply new settings
const bool bNewActive(pRegion && !pRegion->IsEmpty());
rPropertyHolders.Current().setRegionActive(bNewActive);
if(bNewActive)
{
rPropertyHolders.Current().setRegion(*pRegion);
// prepare new content holder for new active region
rTargetHolders.Push();
}
}
/** helper to handle the change of RasterOp. It takes care of encapsulating all current
geometry to the current RasterOp (if changed) and needs to be called on any RasterOp
change. It will also start a new geometry target to embrace to the new RasterOp if
a changuing RasterOp is used. Currently, ROP_XOR and ROP_INVERT are supported using
InvertPrimitive2D, and ROP_0 by using a ModifiedColorPrimitive2D to force to black paint
*/
void HandleNewRasterOp(
RasterOp aRasterOp,
TargetHolders& rTargetHolders,
PropertyHolders& rPropertyHolders)
{
// check if currently active
if(rPropertyHolders.Current().isRasterOpActive() && rTargetHolders.size() > 1)
{
drawinglayer::primitive2d::Primitive2DSequence aSubContent;
if(rTargetHolders.Current().size())
{
aSubContent = rTargetHolders.Current().getPrimitive2DSequence(rPropertyHolders.Current());
}
rTargetHolders.Pop();
if(aSubContent.hasElements())
{
if(rPropertyHolders.Current().isRasterOpForceBlack())
{
// force content to black
rTargetHolders.Current().append(
new drawinglayer::primitive2d::ModifiedColorPrimitive2D(
aSubContent,
basegfx::BColorModifier(basegfx::BColor(0.0, 0.0, 0.0))));
}
else // if(rPropertyHolders.Current().isRasterOpInvert())
{
// invert content
rTargetHolders.Current().append(
new drawinglayer::primitive2d::InvertPrimitive2D(
aSubContent));
}
}
}
// apply new settings
rPropertyHolders.Current().setRasterOp(aRasterOp);
// check if now active
if(rPropertyHolders.Current().isRasterOpActive())
{
// prepare new content holder for new invert
rTargetHolders.Push();
}
}
/** helper to create needed data to emulate the VCL Wallpaper Metafile action.
It is a quite mighty action. This helper is for simple color filled background.
*/
drawinglayer::primitive2d::BasePrimitive2D* CreateColorWallpaper(
const basegfx::B2DRange& rRange,
const basegfx::BColor& rColor,
PropertyHolder& rPropertyHolder)
{
basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(rRange));
aOutline.transform(rPropertyHolder.getTransformation());
return new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
basegfx::B2DPolyPolygon(aOutline),
rColor);
}
/** helper to create needed data to emulate the VCL Wallpaper Metafile action.
It is a quite mighty action. This helper is for gradient filled background.
*/
drawinglayer::primitive2d::BasePrimitive2D* CreateGradientWallpaper(
const basegfx::B2DRange& rRange,
const Gradient& rGradient,
PropertyHolder& rPropertyHolder)
{
const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient));
if(aAttribute.getStartColor() == aAttribute.getEndColor())
{
// not really a gradient. Create filled rectangle
return CreateColorWallpaper(rRange, aAttribute.getStartColor(), rPropertyHolder);
}
else
{
// really a gradient
drawinglayer::primitive2d::BasePrimitive2D* pRetval =
new drawinglayer::primitive2d::FillGradientPrimitive2D(
rRange,
aAttribute);
if(!rPropertyHolder.getTransformation().isIdentity())
{
const drawinglayer::primitive2d::Primitive2DReference xPrim(pRetval);
const drawinglayer::primitive2d::Primitive2DSequence xSeq(&xPrim, 1);
pRetval = new drawinglayer::primitive2d::TransformPrimitive2D(
rPropertyHolder.getTransformation(),
xSeq);
}
return pRetval;
}
}
/** helper to create needed data to emulate the VCL Wallpaper Metafile action.
It is a quite mighty action. This helper decides if color and/or gradient
background is needed for the wnated bitmap fill and then creates the needed
WallpaperBitmapPrimitive2D. This primitive was created for this purpose and
takes over all needed logic of orientations and tiling.
*/
void CreateAndAppendBitmapWallpaper(
basegfx::B2DRange aWallpaperRange,
const Wallpaper& rWallpaper,
TargetHolder& rTarget,
PropertyHolder& rProperty)
{
const BitmapEx aBitmapEx(rWallpaper.GetBitmap());
const WallpaperStyle eWallpaperStyle(rWallpaper.GetStyle());
// if bitmap visualisation is transparent, maybe background
// needs to be filled. Create background
if(aBitmapEx.IsTransparent()
|| (WALLPAPER_TILE != eWallpaperStyle && WALLPAPER_SCALE != eWallpaperStyle))
{
if(rWallpaper.IsGradient())
{
rTarget.append(
CreateGradientWallpaper(
aWallpaperRange,
rWallpaper.GetGradient(),
rProperty));
}
else if(!rWallpaper.GetColor().GetTransparency())
{
rTarget.append(
CreateColorWallpaper(
aWallpaperRange,
rWallpaper.GetColor().getBColor(),
rProperty));
}
}
// use wallpaper rect if set
if(rWallpaper.IsRect() && !rWallpaper.GetRect().IsEmpty())
{
aWallpaperRange = basegfx::B2DRange(
rWallpaper.GetRect().Left(), rWallpaper.GetRect().Top(),
rWallpaper.GetRect().Right(), rWallpaper.GetRect().Bottom());
}
drawinglayer::primitive2d::BasePrimitive2D* pBitmapWallpaperFill =
new drawinglayer::primitive2d::WallpaperBitmapPrimitive2D(
aWallpaperRange,
aBitmapEx,
eWallpaperStyle);
if(rProperty.getTransformation().isIdentity())
{
// add directly
rTarget.append(pBitmapWallpaperFill);
}
else
{
// when a transformation is set, embed to it
const drawinglayer::primitive2d::Primitive2DReference xPrim(pBitmapWallpaperFill);
rTarget.append(
new drawinglayer::primitive2d::TransformPrimitive2D(
rProperty.getTransformation(),
drawinglayer::primitive2d::Primitive2DSequence(&xPrim, 1)));
}
}
/** helper to decide UnderlineAbove for text primitives */
bool isUnderlineAbove(const Font& rFont)
{
if(!rFont.IsVertical())
{
return false;
}
if((LANGUAGE_JAPANESE == rFont.GetLanguage()) || (LANGUAGE_JAPANESE == rFont.GetCJKContextLanguage()))
{
// the underline is right for Japanese only
return true;
}
return false;
}
void createFontAttributeTransformAndAlignment(
drawinglayer::attribute::FontAttribute& rFontAttribute,
basegfx::B2DHomMatrix& rTextTransform,
basegfx::B2DVector& rAlignmentOffset,
PropertyHolder& rProperty)
{
const Font& rFont = rProperty.getFont();
basegfx::B2DVector aFontScaling;
rFontAttribute = drawinglayer::attribute::FontAttribute(
drawinglayer::primitive2d::getFontAttributeFromVclFont(
aFontScaling,
rFont,
0 != (rProperty.getLayoutMode() & TEXT_LAYOUT_BIDI_RTL),
0 != (rProperty.getLayoutMode() & TEXT_LAYOUT_BIDI_STRONG)));
// add FontScaling
rTextTransform.scale(aFontScaling.getX(), aFontScaling.getY());
// take text align into account
if(ALIGN_BASELINE != rFont.GetAlign())
{
drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice;
aTextLayouterDevice.setFont(rFont);
if(ALIGN_TOP == rFont.GetAlign())
{
rAlignmentOffset.setY(aTextLayouterDevice.getFontAscent());
}
else // ALIGN_BOTTOM
{
rAlignmentOffset.setY(-aTextLayouterDevice.getFontDescent());
}
rTextTransform.translate(rAlignmentOffset.getX(), rAlignmentOffset.getY());
}
// add FontRotation (if used)
if(rFont.GetOrientation())
{
rTextTransform.rotate(-rFont.GetOrientation() * F_PI1800);
}
}
/** helper which takes complete care for creating the needed text primitives. It
takes care of decorated stuff and all the geometry adaptions needed
*/
void proccessMetaTextAction(
const Point& rTextStartPosition,
const XubString& rText,
sal_uInt16 nTextStart,
sal_uInt16 nTextLength,
sal_Int32* pDXArray,
TargetHolder& rTarget,
PropertyHolder& rProperty)
{
drawinglayer::primitive2d::BasePrimitive2D* pResult = 0;
const Font& rFont = rProperty.getFont();
std::vector< double > aDXArray;
basegfx::B2DVector aAlignmentOffset(0.0, 0.0);
if(nTextLength)
{
drawinglayer::attribute::FontAttribute aFontAttribute;
basegfx::B2DHomMatrix aTextTransform;
// fill parameters derived from current font
createFontAttributeTransformAndAlignment(
aFontAttribute,
aTextTransform,
aAlignmentOffset,
rProperty);
// add TextStartPosition
aTextTransform.translate(rTextStartPosition.X(), rTextStartPosition.Y());
// preapare DXArray (if used)
if(pDXArray && nTextLength)
{
aDXArray.reserve(nTextLength);
for(xub_StrLen a(0); a < nTextLength; a++)
{
aDXArray.push_back((double)(*(pDXArray + a)));
}
}
// prepare FontColor and Locale
const basegfx::BColor aFontColor(rProperty.getTextColor());
const com::sun::star::lang::Locale aLocale(MsLangId::convertLanguageToLocale(rProperty.getLanguageType()));
const bool bWordLineMode(rFont.IsWordLineMode());
const bool bDecoratedIsNeeded(
UNDERLINE_NONE != rFont.GetOverline()
|| UNDERLINE_NONE != rFont.GetUnderline()
|| STRIKEOUT_NONE != rFont.GetStrikeout()
|| EMPHASISMARK_NONE != (rFont.GetEmphasisMark() & EMPHASISMARK_STYLE)
|| RELIEF_NONE != rFont.GetRelief()
|| rFont.IsShadow()
|| bWordLineMode);
if(bDecoratedIsNeeded)
{
// prepare overline, underline and srikeout data
const drawinglayer::primitive2d::TextLine eFontOverline(drawinglayer::primitive2d::mapFontUnderlineToTextLine(rFont.GetOverline()));
const drawinglayer::primitive2d::TextLine eFontUnderline(drawinglayer::primitive2d::mapFontUnderlineToTextLine(rFont.GetUnderline()));
const drawinglayer::primitive2d::TextStrikeout eTextStrikeout(drawinglayer::primitive2d::mapFontStrikeoutToTextStrikeout(rFont.GetStrikeout()));
// check UndelineAbove
const bool bUnderlineAbove(drawinglayer::primitive2d::TEXT_LINE_NONE != eFontUnderline && isUnderlineAbove(rFont));
// prepare emphasis mark data
drawinglayer::primitive2d::TextEmphasisMark eTextEmphasisMark(drawinglayer::primitive2d::TEXT_EMPHASISMARK_NONE);
switch(rFont.GetEmphasisMark() & EMPHASISMARK_STYLE)
{
case EMPHASISMARK_DOT : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_DOT; break;
case EMPHASISMARK_CIRCLE : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_CIRCLE; break;
case EMPHASISMARK_DISC : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_DISC; break;
case EMPHASISMARK_ACCENT : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_ACCENT; break;
}
const bool bEmphasisMarkAbove(rFont.GetEmphasisMark() & EMPHASISMARK_POS_ABOVE);
const bool bEmphasisMarkBelow(rFont.GetEmphasisMark() & EMPHASISMARK_POS_BELOW);
// prepare font relief data
drawinglayer::primitive2d::TextRelief eTextRelief(drawinglayer::primitive2d::TEXT_RELIEF_NONE);
switch(rFont.GetRelief())
{
case RELIEF_EMBOSSED : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_EMBOSSED; break;
case RELIEF_ENGRAVED : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_ENGRAVED; break;
default : break; // RELIEF_NONE, FontRelief_FORCE_EQUAL_SIZE
}
// prepare shadow/outline data
const bool bShadow(rFont.IsShadow());
// TextDecoratedPortionPrimitive2D is needed, create one
pResult = new drawinglayer::primitive2d::TextDecoratedPortionPrimitive2D(
// attributes for TextSimplePortionPrimitive2D
aTextTransform,
rText,
nTextStart,
nTextLength,
aDXArray,
aFontAttribute,
aLocale,
aFontColor,
// attributes for TextDecoratedPortionPrimitive2D
rProperty.getOverlineColorActive() ? rProperty.getOverlineColor() : aFontColor,
rProperty.getTextLineColorActive() ? rProperty.getTextLineColor() : aFontColor,
eFontOverline,
eFontUnderline,
bUnderlineAbove,
eTextStrikeout,
bWordLineMode,
eTextEmphasisMark,
bEmphasisMarkAbove,
bEmphasisMarkBelow,
eTextRelief,
bShadow);
}
else
{
// TextSimplePortionPrimitive2D is enough
pResult = new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
aTextTransform,
rText,
nTextStart,
nTextLength,
aDXArray,
aFontAttribute,
aLocale,
aFontColor);
}
}
if(pResult && rProperty.getTextFillColorActive())
{
// text background is requested, add and encapsulate both to new primitive
drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice;
aTextLayouterDevice.setFont(rFont);
// get text width
double fTextWidth(0.0);
if(aDXArray.empty())
{
fTextWidth = aTextLayouterDevice.getTextWidth(rText, nTextStart, nTextLength);
}
else
{
fTextWidth = aDXArray.back();
}
if(basegfx::fTools::more(fTextWidth, 0.0))
{
// build text range
const basegfx::B2DRange aTextRange(
0.0, -aTextLayouterDevice.getFontAscent(),
fTextWidth, aTextLayouterDevice.getFontDescent());
// create Transform
basegfx::B2DHomMatrix aTextTransform;
aTextTransform.translate(aAlignmentOffset.getX(), aAlignmentOffset.getY());
if(rFont.GetOrientation())
{
aTextTransform.rotate(-rFont.GetOrientation() * F_PI1800);
}
aTextTransform.translate(rTextStartPosition.X(), rTextStartPosition.Y());
// prepare Primitive2DSequence, put text in foreground
drawinglayer::primitive2d::Primitive2DSequence aSequence(2);
aSequence[1] = drawinglayer::primitive2d::Primitive2DReference(pResult);
// prepare filled polygon
basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aTextRange));
aOutline.transform(aTextTransform);
aSequence[0] = drawinglayer::primitive2d::Primitive2DReference(
new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
basegfx::B2DPolyPolygon(aOutline),
rProperty.getTextFillColor()));
// set as group at pResult
pResult = new drawinglayer::primitive2d::GroupPrimitive2D(aSequence);
}
}
if(pResult)
{
// add created text primitive to target
if(rProperty.getTransformation().isIdentity())
{
rTarget.append(pResult);
}
else
{
// when a transformation is set, embed to it
const drawinglayer::primitive2d::Primitive2DReference aReference(pResult);
rTarget.append(
new drawinglayer::primitive2d::TransformPrimitive2D(
rProperty.getTransformation(),
drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1)));
}
}
}
/** helper which takes complete care for creating the needed textLine primitives */
void proccessMetaTextLineAction(
const MetaTextLineAction& rAction,
TargetHolder& rTarget,
PropertyHolder& rProperty)
{
const double fLineWidth(fabs((double)rAction.GetWidth()));
if(fLineWidth > 0.0)
{
const drawinglayer::primitive2d::TextLine aOverlineMode(drawinglayer::primitive2d::mapFontUnderlineToTextLine(rAction.GetOverline()));
const drawinglayer::primitive2d::TextLine aUnderlineMode(drawinglayer::primitive2d::mapFontUnderlineToTextLine(rAction.GetUnderline()));
const drawinglayer::primitive2d::TextStrikeout aTextStrikeout(drawinglayer::primitive2d::mapFontStrikeoutToTextStrikeout(rAction.GetStrikeout()));
const bool bOverlineUsed(drawinglayer::primitive2d::TEXT_LINE_NONE != aOverlineMode);
const bool bUnderlineUsed(drawinglayer::primitive2d::TEXT_LINE_NONE != aUnderlineMode);
const bool bStrikeoutUsed(drawinglayer::primitive2d::TEXT_STRIKEOUT_NONE != aTextStrikeout);
if(bUnderlineUsed || bStrikeoutUsed || bOverlineUsed)
{
std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aTargetVector;
basegfx::B2DVector aAlignmentOffset(0.0, 0.0);
drawinglayer::attribute::FontAttribute aFontAttribute;
basegfx::B2DHomMatrix aTextTransform;
// fill parameters derived from current font
createFontAttributeTransformAndAlignment(
aFontAttribute,
aTextTransform,
aAlignmentOffset,
rProperty);
// add TextStartPosition
aTextTransform.translate(rAction.GetStartPoint().X(), rAction.GetStartPoint().Y());
// prepare TextLayouter (used in most cases)
drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
aTextLayouter.setFont(rProperty.getFont());
if(bOverlineUsed)
{
// create primitive geometry for overline
aTargetVector.push_back(
new drawinglayer::primitive2d::TextLinePrimitive2D(
aTextTransform,
fLineWidth,
aTextLayouter.getOverlineOffset(),
aTextLayouter.getOverlineHeight(),
aOverlineMode,
rProperty.getOverlineColor()));
}
if(bUnderlineUsed)
{
// create primitive geometry for underline
aTargetVector.push_back(
new drawinglayer::primitive2d::TextLinePrimitive2D(
aTextTransform,
fLineWidth,
aTextLayouter.getUnderlineOffset(),
aTextLayouter.getUnderlineHeight(),
aUnderlineMode,
rProperty.getTextLineColor()));
}
if(bStrikeoutUsed)
{
// create primitive geometry for strikeout
if(drawinglayer::primitive2d::TEXT_STRIKEOUT_SLASH == aTextStrikeout
|| drawinglayer::primitive2d::TEXT_STRIKEOUT_X == aTextStrikeout)
{
// strikeout with character
const sal_Unicode aStrikeoutChar(
drawinglayer::primitive2d::TEXT_STRIKEOUT_SLASH == aTextStrikeout ? '/' : 'X');
const com::sun::star::lang::Locale aLocale(MsLangId::convertLanguageToLocale(
rProperty.getLanguageType()));
aTargetVector.push_back(
new drawinglayer::primitive2d::TextCharacterStrikeoutPrimitive2D(
aTextTransform,
fLineWidth,
rProperty.getTextColor(),
aStrikeoutChar,
aFontAttribute,
aLocale));
}
else
{
// strikeout with geometry
aTargetVector.push_back(
new drawinglayer::primitive2d::TextGeometryStrikeoutPrimitive2D(
aTextTransform,
fLineWidth,
rProperty.getTextColor(),
aTextLayouter.getUnderlineHeight(),
aTextLayouter.getStrikeoutOffset(),
aTextStrikeout));
}
}
if(aTargetVector.size())
{
// add created text primitive to target
if(rProperty.getTransformation().isIdentity())
{
for(sal_uInt32 a(0); a < aTargetVector.size(); a++)
{
rTarget.append(aTargetVector[a]);
}
}
else
{
// when a transformation is set, embed to it
drawinglayer::primitive2d::Primitive2DSequence xTargets(aTargetVector.size());
for(sal_uInt32 a(0); a < aTargetVector.size(); a++)
{
xTargets[a] = drawinglayer::primitive2d::Primitive2DReference(aTargetVector[a]);
}
rTarget.append(
new drawinglayer::primitive2d::TransformPrimitive2D(
rProperty.getTransformation(),
xTargets));
}
}
}
}
}
/** This is the main interpreter method. It is designed to handle the given Metafile
completely inside the given context and target. It may use and modify the context and
target. This design allows to call itself recursively wich adapted contexts and
targets as e.g. needed for the META_FLOATTRANSPARENT_ACTION where the content is expressed
as a metafile as sub-content.
This interpreter is as free of VCL functionality as possible. It uses VCL data classes
(else reading the data would not be possible), but e.g. does NOT use a local OutputDevice
as most other MetaFile interpreters/exporters do to hold and work with the current context.
This is necessary to be able to get away from the strong internal VCL-binding.
It tries to combine e.g. pixel and/or point actions and to stitch together single line primitives
where possible (which is not trivial with the possible line geometry definitions).
It tries to handle clipping no longer as Regions and spans of Rectangles, but as PolyPolygon
ClipRegions with (where possible) high precision by using the best possible data quality
from the Region. The Region is unavoidable as data container, but nowadays allows the transport
of Polygon-based clip regions. Where this is not used, a Polygon is constructed from the
Region ranges. All primitive clipping uses the MaskPrimitive2D with Polygon-based clipping.
I have marked the single MetaActions with:
SIMPLE, DONE:
Simple, e.g nothing to do or value setting in the context
CHECKED, WORKS WELL:
Thoroughly tested with extra written test code which created a replacement
Metafile just to test this action in various combinations
NEEDS IMPLEMENTATION:
Not implemented and asserted, but also no usage found, neither in own Metafile
creations, nor in EMF/WMF imports (checked with a whole bunch of critical EMF/WMF
bugdocs)
For more commens, see the single action implementations.
*/
void interpretMetafile(
const GDIMetaFile& rMetaFile,
TargetHolders& rTargetHolders,
PropertyHolders& rPropertyHolders,
const drawinglayer::geometry::ViewInformation2D& rViewInformation)
{
const sal_uInt32 nCount(rMetaFile.GetActionCount());
for(sal_uInt32 nAction(0); nAction < nCount; nAction++)
{
MetaAction* pAction = rMetaFile.GetAction(nAction);
switch(pAction->GetType())
{
case META_NULL_ACTION :
{
/** SIMPLE, DONE */
break;
}
case META_PIXEL_ACTION :
{
/** CHECKED, WORKS WELL */
std::vector< basegfx::B2DPoint > aPositions;
Color aLastColor(COL_BLACK);
while(META_PIXEL_ACTION == pAction->GetType() && nAction < nCount)
{
const MetaPixelAction* pA = (const MetaPixelAction*)pAction;
if(pA->GetColor() != aLastColor)
{
if(aPositions.size())
{
createPointArrayPrimitive(aPositions, rTargetHolders.Current(), rPropertyHolders.Current(), aLastColor.getBColor());
aPositions.clear();
}
aLastColor = pA->GetColor();
}
const Point& rPoint = pA->GetPoint();
aPositions.push_back(basegfx::B2DPoint(rPoint.X(), rPoint.Y()));
nAction++; if(nAction < nCount) pAction = rMetaFile.GetAction(nAction);
}
nAction--;
if(aPositions.size())
{
createPointArrayPrimitive(aPositions, rTargetHolders.Current(), rPropertyHolders.Current(), aLastColor.getBColor());
}
break;
}
case META_POINT_ACTION :
{
/** CHECKED, WORKS WELL */
if(rPropertyHolders.Current().getLineColorActive())
{
std::vector< basegfx::B2DPoint > aPositions;
while(META_POINT_ACTION == pAction->GetType() && nAction < nCount)
{
const MetaPointAction* pA = (const MetaPointAction*)pAction;
const Point& rPoint = pA->GetPoint();
aPositions.push_back(basegfx::B2DPoint(rPoint.X(), rPoint.Y()));
nAction++; if(nAction < nCount) pAction = rMetaFile.GetAction(nAction);
}
nAction--;
if(aPositions.size())
{
createPointArrayPrimitive(aPositions, rTargetHolders.Current(), rPropertyHolders.Current(), rPropertyHolders.Current().getLineColor());
}
}
break;
}
case META_LINE_ACTION :
{
/** CHECKED, WORKS WELL */
if(rPropertyHolders.Current().getLineColorActive())
{
basegfx::B2DPolygon aLinePolygon;
LineInfo aLineInfo;
while(META_LINE_ACTION == pAction->GetType() && nAction < nCount)
{
const MetaLineAction* pA = (const MetaLineAction*)pAction;
const Point& rStartPoint = pA->GetStartPoint();
const Point& rEndPoint = pA->GetEndPoint();
const basegfx::B2DPoint aStart(rStartPoint.X(), rStartPoint.Y());
const basegfx::B2DPoint aEnd(rEndPoint.X(), rEndPoint.Y());
if(aLinePolygon.count())
{
if(pA->GetLineInfo() == aLineInfo
&& aStart == aLinePolygon.getB2DPoint(aLinePolygon.count() - 1))
{
aLinePolygon.append(aEnd);
}
else
{
aLineInfo.SetLineJoin(basegfx::B2DLINEJOIN_NONE); // It were lines; force to NONE
createLinePrimitive(aLinePolygon, aLineInfo, rTargetHolders.Current(), rPropertyHolders.Current());
aLinePolygon.clear();
aLineInfo = pA->GetLineInfo();
aLinePolygon.append(aStart);
aLinePolygon.append(aEnd);
}
}
else
{
aLineInfo = pA->GetLineInfo();
aLinePolygon.append(aStart);
aLinePolygon.append(aEnd);
}
nAction++; if(nAction < nCount) pAction = rMetaFile.GetAction(nAction);
}
nAction--;
if(aLinePolygon.count())
{
aLineInfo.SetLineJoin(basegfx::B2DLINEJOIN_NONE); // It were lines; force to NONE
createLinePrimitive(aLinePolygon, aLineInfo, rTargetHolders.Current(), rPropertyHolders.Current());
}
}
break;
}
case META_RECT_ACTION :
{
/** CHECKED, WORKS WELL */
if(rPropertyHolders.Current().getLineOrFillActive())
{
const MetaRectAction* pA = (const MetaRectAction*)pAction;
const Rectangle& rRectangle = pA->GetRect();
if(!rRectangle.IsEmpty())
{
const basegfx::B2DRange aRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom());
if(!aRange.isEmpty())
{
const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange));
createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current());
}
}
}
break;
}
case META_ROUNDRECT_ACTION :
{
/** CHECKED, WORKS WELL */
/** The original OutputDevice::DrawRect paints nothing when nHor or nVer is zero; but just
because the tools::Polygon operator creating the rounding does produce nonsense. I assume
this an error and create an unrounded rectangle in that case (implicit in
createPolygonFromRect)
*/
if(rPropertyHolders.Current().getLineOrFillActive())
{
const MetaRoundRectAction* pA = (const MetaRoundRectAction*)pAction;
const Rectangle& rRectangle = pA->GetRect();
if(!rRectangle.IsEmpty())
{
const basegfx::B2DRange aRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom());
if(!aRange.isEmpty())
{
const sal_uInt32 nHor(pA->GetHorzRound());
const sal_uInt32 nVer(pA->GetVertRound());
basegfx::B2DPolygon aOutline;
if(nHor || nVer)
{
double fRadiusX((nHor * 2.0) / (aRange.getWidth() > 0.0 ? aRange.getWidth() : 1.0));
double fRadiusY((nVer * 2.0) / (aRange.getHeight() > 0.0 ? aRange.getHeight() : 1.0));
fRadiusX = std::max(0.0, std::min(1.0, fRadiusX));
fRadiusY = std::max(0.0, std::min(1.0, fRadiusY));
aOutline = basegfx::tools::createPolygonFromRect(aRange, fRadiusX, fRadiusY);
}
else
{
aOutline = basegfx::tools::createPolygonFromRect(aRange);
}
createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current());
}
}
}
break;
}
case META_ELLIPSE_ACTION :
{
/** CHECKED, WORKS WELL */
if(rPropertyHolders.Current().getLineOrFillActive())
{
const MetaEllipseAction* pA = (const MetaEllipseAction*)pAction;
const Rectangle& rRectangle = pA->GetRect();
if(!rRectangle.IsEmpty())
{
const basegfx::B2DRange aRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom());
if(!aRange.isEmpty())
{
const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromEllipse(
aRange.getCenter(), aRange.getWidth() * 0.5, aRange.getHeight() * 0.5));
createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current());
}
}
}
break;
}
case META_ARC_ACTION :
{
/** CHECKED, WORKS WELL */
if(rPropertyHolders.Current().getLineColorActive())
{
const MetaArcAction* pA = (const MetaArcAction*)pAction;
const Polygon aToolsPoly(pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_ARC);
const basegfx::B2DPolygon aOutline(aToolsPoly.getB2DPolygon());
createHairlinePrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current());
}
break;
}
case META_PIE_ACTION :
{
/** CHECKED, WORKS WELL */
if(rPropertyHolders.Current().getLineOrFillActive())
{
const MetaPieAction* pA = (const MetaPieAction*)pAction;
const Polygon aToolsPoly(pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_PIE);
const basegfx::B2DPolygon aOutline(aToolsPoly.getB2DPolygon());
createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current());
}
break;
}
case META_CHORD_ACTION :
{
/** CHECKED, WORKS WELL */
if(rPropertyHolders.Current().getLineOrFillActive())
{
const MetaChordAction* pA = (const MetaChordAction*)pAction;
const Polygon aToolsPoly(pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_CHORD);
const basegfx::B2DPolygon aOutline(aToolsPoly.getB2DPolygon());
createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current());
}
break;
}
case META_POLYLINE_ACTION :
{
/** CHECKED, WORKS WELL */
if(rPropertyHolders.Current().getLineColorActive())
{
const MetaPolyLineAction* pA = (const MetaPolyLineAction*)pAction;
createLinePrimitive(pA->GetPolygon().getB2DPolygon(), pA->GetLineInfo(), rTargetHolders.Current(), rPropertyHolders.Current());
}
break;
}
case META_POLYGON_ACTION :
{
/** CHECKED, WORKS WELL */
if(rPropertyHolders.Current().getLineOrFillActive())
{
const MetaPolygonAction* pA = (const MetaPolygonAction*)pAction;
basegfx::B2DPolygon aOutline(pA->GetPolygon().getB2DPolygon());
// the metafile play interprets the polygons from MetaPolygonAction
// always as closed and always paints an edge from last to first point,
// so force to closed here to emulate that
if(aOutline.count() > 1 && !aOutline.isClosed())
{
aOutline.setClosed(true);
}
createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current());
}
break;
}
case META_POLYPOLYGON_ACTION :
{
/** CHECKED, WORKS WELL */
if(rPropertyHolders.Current().getLineOrFillActive())
{
const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*)pAction;
basegfx::B2DPolyPolygon aPolyPolygonOutline(pA->GetPolyPolygon().getB2DPolyPolygon());
// the metafile play interprets the single polygons from MetaPolyPolygonAction
// always as closed and always paints an edge from last to first point,
// so force to closed here to emulate that
for(sal_uInt32 b(0); b < aPolyPolygonOutline.count(); b++)
{
basegfx::B2DPolygon aPolygonOutline(aPolyPolygonOutline.getB2DPolygon(b));
if(aPolygonOutline.count() > 1 && !aPolygonOutline.isClosed())
{
aPolygonOutline.setClosed(true);
aPolyPolygonOutline.setB2DPolygon(b, aPolygonOutline);
}
}
createHairlineAndFillPrimitive(aPolyPolygonOutline, rTargetHolders.Current(), rPropertyHolders.Current());
}
break;
}
case META_TEXT_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaTextAction* pA = (const MetaTextAction*)pAction;
if(pA->GetLen() && rPropertyHolders.Current().getTextColorActive())
{
proccessMetaTextAction(
pA->GetPoint(),
pA->GetText(),
pA->GetIndex(),
pA->GetLen(),
0,
rTargetHolders.Current(),
rPropertyHolders.Current());
}
break;
}
case META_TEXTARRAY_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaTextArrayAction* pA = (const MetaTextArrayAction*)pAction;
if(pA->GetLen() && rPropertyHolders.Current().getTextColorActive())
{
proccessMetaTextAction(
pA->GetPoint(),
pA->GetText(),
pA->GetIndex(),
pA->GetLen(),
pA->GetDXArray(),
rTargetHolders.Current(),
rPropertyHolders.Current());
}
break;
}
case META_STRETCHTEXT_ACTION :
{
/** NEEDS IMPLEMENTATION */
OSL_ENSURE(false, "META_STRETCHTEXT_ACTION requested (!)");
// use OutputDevice::GetTextArray() to map the...
// const MetaStretchTextAction* pA = (const MetaStretchTextAction*)pAction;
break;
}
case META_TEXTRECT_ACTION :
{
/** CHECKED, WORKS WELL */
// OSL_ENSURE(false, "META_TEXTRECT_ACTION requested (!)");
const MetaTextRectAction* pA = (const MetaTextRectAction*)pAction;
const Rectangle& rRectangle = pA->GetRect();
if(!rRectangle.IsEmpty() && 0 != pA->GetText().Len())
{
// The problem with this action is that it describes unlayouted text
// and the layout capabilities are in EditEngine/Outliner in SVX. The
// same problem is true for VCL which internally has implementations
// to layout text in this case. There exists even a call
// OutputDevice::AddTextRectActions(...) to create the needed actions
// as 'sub-content' of a Metafile. Unfortunately i do not have an
// OutputDevice here since this interpreter tries to work without
// VCL AFAP.
// Since AddTextRectActions is the only way as long as we do not have
// a simple text layouter available, i will try to add it to the
// TextLayouterDevice isloation.
drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice;
aTextLayouterDevice.setFont(rPropertyHolders.Current().getFont());
GDIMetaFile aGDIMetaFile;
aTextLayouterDevice.addTextRectActions(
rRectangle, pA->GetText(), pA->GetStyle(), aGDIMetaFile);
if(aGDIMetaFile.GetActionCount())
{
// cerate sub-content
drawinglayer::primitive2d::Primitive2DSequence xSubContent;
{
rTargetHolders.Push();
interpretMetafile(aGDIMetaFile, rTargetHolders, rPropertyHolders, rViewInformation);
xSubContent = rTargetHolders.Current().getPrimitive2DSequence(rPropertyHolders.Current());
rTargetHolders.Pop();
}
if(xSubContent.hasElements())
{
// add with transformation
rTargetHolders.Current().append(
new drawinglayer::primitive2d::TransformPrimitive2D(
rPropertyHolders.Current().getTransformation(),
xSubContent));
}
}
}
break;
}
case META_BMP_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaBmpAction* pA = (const MetaBmpAction*)pAction;
const BitmapEx aBitmapEx(pA->GetBitmap());
createBitmapExPrimitive(aBitmapEx, pA->GetPoint(), rTargetHolders.Current(), rPropertyHolders.Current());
break;
}
case META_BMPSCALE_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*)pAction;
const Bitmap aBitmapEx(pA->GetBitmap());
createBitmapExPrimitive(aBitmapEx, pA->GetPoint(), pA->GetSize(), rTargetHolders.Current(), rPropertyHolders.Current());
break;
}
case META_BMPSCALEPART_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*)pAction;
const Bitmap& rBitmap = pA->GetBitmap();
if(!rBitmap.IsEmpty())
{
Bitmap aCroppedBitmap(rBitmap);
const Rectangle aCropRectangle(pA->GetSrcPoint(), pA->GetSrcSize());
if(!aCropRectangle.IsEmpty())
{
aCroppedBitmap.Crop(aCropRectangle);
}
const BitmapEx aCroppedBitmapEx(aCroppedBitmap);
createBitmapExPrimitive(aCroppedBitmapEx, pA->GetDestPoint(), pA->GetDestSize(), rTargetHolders.Current(), rPropertyHolders.Current());
}
break;
}
case META_BMPEX_ACTION :
{
/** CHECKED, WORKS WELL: Simply same as META_BMP_ACTION */
const MetaBmpExAction* pA = (const MetaBmpExAction*)pAction;
const BitmapEx& rBitmapEx = pA->GetBitmapEx();
createBitmapExPrimitive(rBitmapEx, pA->GetPoint(), rTargetHolders.Current(), rPropertyHolders.Current());
break;
}
case META_BMPEXSCALE_ACTION :
{
/** CHECKED, WORKS WELL: Simply same as META_BMPSCALE_ACTION */
const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*)pAction;
const BitmapEx& rBitmapEx = pA->GetBitmapEx();
createBitmapExPrimitive(rBitmapEx, pA->GetPoint(), pA->GetSize(), rTargetHolders.Current(), rPropertyHolders.Current());
break;
}
case META_BMPEXSCALEPART_ACTION :
{
/** CHECKED, WORKS WELL: Simply same as META_BMPSCALEPART_ACTION */
const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*)pAction;
const BitmapEx& rBitmapEx = pA->GetBitmapEx();
if(!rBitmapEx.IsEmpty())
{
BitmapEx aCroppedBitmapEx(rBitmapEx);
const Rectangle aCropRectangle(pA->GetSrcPoint(), pA->GetSrcSize());
if(!aCropRectangle.IsEmpty())
{
aCroppedBitmapEx.Crop(aCropRectangle);
}
createBitmapExPrimitive(aCroppedBitmapEx, pA->GetDestPoint(), pA->GetDestSize(), rTargetHolders.Current(), rPropertyHolders.Current());
}
break;
}
case META_MASK_ACTION :
{
/** CHECKED, WORKS WELL: Simply same as META_BMP_ACTION */
const MetaMaskAction* pA = (const MetaMaskAction*)pAction;
const BitmapEx aBitmapEx(createMaskBmpEx(pA->GetBitmap(), pA->GetColor()));
createBitmapExPrimitive(aBitmapEx, pA->GetPoint(), rTargetHolders.Current(), rPropertyHolders.Current());
break;
}
case META_MASKSCALE_ACTION :
{
/** CHECKED, WORKS WELL: Simply same as META_BMPSCALE_ACTION */
const MetaMaskScaleAction* pA = (const MetaMaskScaleAction*)pAction;
const BitmapEx aBitmapEx(createMaskBmpEx(pA->GetBitmap(), pA->GetColor()));
createBitmapExPrimitive(aBitmapEx, pA->GetPoint(), pA->GetSize(), rTargetHolders.Current(), rPropertyHolders.Current());
break;
}
case META_MASKSCALEPART_ACTION :
{
/** CHECKED, WORKS WELL: Simply same as META_BMPSCALEPART_ACTION */
const MetaMaskScalePartAction* pA = (const MetaMaskScalePartAction*)pAction;
const Bitmap& rBitmap = pA->GetBitmap();
if(!rBitmap.IsEmpty())
{
Bitmap aCroppedBitmap(rBitmap);
const Rectangle aCropRectangle(pA->GetSrcPoint(), pA->GetSrcSize());
if(!aCropRectangle.IsEmpty())
{
aCroppedBitmap.Crop(aCropRectangle);
}
const BitmapEx aCroppedBitmapEx(createMaskBmpEx(aCroppedBitmap, pA->GetColor()));
createBitmapExPrimitive(aCroppedBitmapEx, pA->GetDestPoint(), pA->GetDestSize(), rTargetHolders.Current(), rPropertyHolders.Current());
}
break;
}
case META_GRADIENT_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaGradientAction* pA = (const MetaGradientAction*)pAction;
const Rectangle& rRectangle = pA->GetRect();
if(!rRectangle.IsEmpty())
{
basegfx::B2DRange aRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom());
if(!aRange.isEmpty())
{
const Gradient& rGradient = pA->GetGradient();
const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient));
if(aAttribute.getStartColor() == aAttribute.getEndColor())
{
// not really a gradient. Create filled rectangle
const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange));
createFillPrimitive(basegfx::B2DPolyPolygon(aOutline), rTargetHolders.Current(), rPropertyHolders.Current());
}
else
{
// really a gradient
aRange.transform(rPropertyHolders.Current().getTransformation());
if(rPropertyHolders.Current().isRasterOpInvert())
{
// use a special version of FillGradientPrimitive2D which creates
// non-overlapping geometry on decomposition to makethe old XOR
// paint 'trick' work.
rTargetHolders.Current().append(
new drawinglayer::primitive2d::NonOverlappingFillGradientPrimitive2D(
aRange,
aAttribute));
}
else
{
rTargetHolders.Current().append(
new drawinglayer::primitive2d::FillGradientPrimitive2D(
aRange,
aAttribute));
}
}
}
}
break;
}
case META_HATCH_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaHatchAction* pA = (const MetaHatchAction*)pAction;
basegfx::B2DPolyPolygon aOutline(pA->GetPolyPolygon().getB2DPolyPolygon());
if(aOutline.count())
{
const Hatch& rHatch = pA->GetHatch();
const drawinglayer::attribute::FillHatchAttribute aAttribute(createFillHatchAttribute(rHatch));
aOutline.transform(rPropertyHolders.Current().getTransformation());
const basegfx::B2DRange aObjectRange(aOutline.getB2DRange());
const drawinglayer::primitive2d::Primitive2DReference aFillHatch(
new drawinglayer::primitive2d::FillHatchPrimitive2D(
aObjectRange,
basegfx::BColor(),
aAttribute));
rTargetHolders.Current().append(
new drawinglayer::primitive2d::MaskPrimitive2D(
aOutline,
drawinglayer::primitive2d::Primitive2DSequence(&aFillHatch, 1)));
}
break;
}
case META_WALLPAPER_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaWallpaperAction* pA = (const MetaWallpaperAction*)pAction;
Rectangle aWallpaperRectangle(pA->GetRect());
if(!aWallpaperRectangle.IsEmpty())
{
const Wallpaper& rWallpaper = pA->GetWallpaper();
const WallpaperStyle eWallpaperStyle(rWallpaper.GetStyle());
basegfx::B2DRange aWallpaperRange(
aWallpaperRectangle.Left(), aWallpaperRectangle.Top(),
aWallpaperRectangle.Right(), aWallpaperRectangle.Bottom());
if(WALLPAPER_NULL != eWallpaperStyle)
{
if(rWallpaper.IsBitmap())
{
// create bitmap background. Caution: This
// also will create gradient/color background(s)
// when the bitmap is transparent or not tiled
CreateAndAppendBitmapWallpaper(
aWallpaperRange,
rWallpaper,
rTargetHolders.Current(),
rPropertyHolders.Current());
}
else if(rWallpaper.IsGradient())
{
// create gradient background
rTargetHolders.Current().append(
CreateGradientWallpaper(
aWallpaperRange,
rWallpaper.GetGradient(),
rPropertyHolders.Current()));
}
else if(!rWallpaper.GetColor().GetTransparency())
{
// create color background
rTargetHolders.Current().append(
CreateColorWallpaper(
aWallpaperRange,
rWallpaper.GetColor().getBColor(),
rPropertyHolders.Current()));
}
}
}
break;
}
case META_CLIPREGION_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaClipRegionAction* pA = (const MetaClipRegionAction*)pAction;
if(pA->IsClipping())
{
// new clipping
HandleNewClipRegion(&pA->GetRegion(), rTargetHolders, rPropertyHolders);
}
else
{
// end clipping
HandleNewClipRegion(0, rTargetHolders, rPropertyHolders);
}
break;
}
case META_ISECTRECTCLIPREGION_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaISectRectClipRegionAction* pA = (const MetaISectRectClipRegionAction*)pAction;
const Rectangle& rRectangle = pA->GetRect();
if(rRectangle.IsEmpty())
{
// intersect with empty rectangle will always give empty
// region; start new clipping with empty region
const Region aNewRegion;
HandleNewClipRegion(&aNewRegion, rTargetHolders, rPropertyHolders);
}
else
{
if(rPropertyHolders.Current().getRegionActive())
{
if(rPropertyHolders.Current().getRegion().IsEmpty())
{
// nothing to do, empty active clip region will stay
// empty when intersecting
}
else
{
// AND existing region and new rectangle
const basegfx::B2DPolyPolygon aOriginalPolyPolygon(
getB2DPolyPolygonFromRegion(rPropertyHolders.Current().getRegion()));
basegfx::B2DPolyPolygon aClippedPolyPolygon;
if(aOriginalPolyPolygon.count())
{
const basegfx::B2DRange aIntersectRange(
rRectangle.Left(), rRectangle.Top(),
rRectangle.Right(), rRectangle.Bottom());
aClippedPolyPolygon = basegfx::tools::clipPolyPolygonOnRange(
aOriginalPolyPolygon, aIntersectRange, true, false);
}
if(aClippedPolyPolygon != aOriginalPolyPolygon)
{
// start new clipping with intersected region
const Region aNewRegion(aClippedPolyPolygon);
HandleNewClipRegion(&aNewRegion, rTargetHolders, rPropertyHolders);
}
}
}
else
{
// start new clipping with rectangle
const Region aNewRegion(rRectangle);
HandleNewClipRegion(&aNewRegion, rTargetHolders, rPropertyHolders);
}
}
break;
}
case META_ISECTREGIONCLIPREGION_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaISectRegionClipRegionAction* pA = (const MetaISectRegionClipRegionAction*)pAction;
const Region& rNewRegion = pA->GetRegion();
if(rNewRegion.IsEmpty())
{
// intersect with empty region will always give empty
// region; start new clipping with empty region
const Region aNewRegion;
HandleNewClipRegion(&aNewRegion, rTargetHolders, rPropertyHolders);
}
else
{
if(rPropertyHolders.Current().getRegionActive())
{
if(rPropertyHolders.Current().getRegion().IsEmpty())
{
// nothing to do, empty active clip region will stay empty
// when intersecting with any region
}
else
{
// AND existing and new region
const basegfx::B2DPolyPolygon aOriginalPolyPolygon(
getB2DPolyPolygonFromRegion(rPropertyHolders.Current().getRegion()));
basegfx::B2DPolyPolygon aClippedPolyPolygon;
if(aOriginalPolyPolygon.count())
{
const basegfx::B2DPolyPolygon aClipPolyPolygon(
getB2DPolyPolygonFromRegion(rNewRegion));
if(aClipPolyPolygon.count())
{
aClippedPolyPolygon = basegfx::tools::clipPolyPolygonOnPolyPolygon(
aOriginalPolyPolygon, aClipPolyPolygon, true, false);
}
}
if(aClippedPolyPolygon != aOriginalPolyPolygon)
{
// start new clipping with intersected region
const Region aNewRegion(aClippedPolyPolygon);
HandleNewClipRegion(&aNewRegion, rTargetHolders, rPropertyHolders);
}
}
}
else
{
// start new clipping with new region
HandleNewClipRegion(&rNewRegion, rTargetHolders, rPropertyHolders);
}
}
break;
}
case META_MOVECLIPREGION_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaMoveClipRegionAction* pA = (const MetaMoveClipRegionAction*)pAction;
if(rPropertyHolders.Current().getRegionActive())
{
if(rPropertyHolders.Current().getRegion().IsEmpty())
{
// nothing to do
}
else
{
// move using old interface
Region aRegion(rPropertyHolders.Current().getRegion());
const sal_Int32 nHor(pA->GetHorzMove());
const sal_Int32 nVer(pA->GetVertMove());
if(0 != nHor || 0 != nVer)
{
aRegion.Move(nHor, nVer);
HandleNewClipRegion(&aRegion, rTargetHolders, rPropertyHolders);
}
}
}
break;
}
case META_LINECOLOR_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaLineColorAction* pA = (const MetaLineColorAction*)pAction;
const bool bActive(pA->IsSetting());
rPropertyHolders.Current().setLineColorActive(bActive);
if(bActive)
rPropertyHolders.Current().setLineColor(pA->GetColor().getBColor());
break;
}
case META_FILLCOLOR_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaFillColorAction* pA = (const MetaFillColorAction*)pAction;
const bool bActive(pA->IsSetting());
rPropertyHolders.Current().setFillColorActive(bActive);
if(bActive)
rPropertyHolders.Current().setFillColor(pA->GetColor().getBColor());
break;
}
case META_TEXTCOLOR_ACTION :
{
/** SIMPLE, DONE */
const MetaTextColorAction* pA = (const MetaTextColorAction*)pAction;
const bool bActivate(COL_TRANSPARENT != pA->GetColor().GetColor());
rPropertyHolders.Current().setTextColorActive(bActivate);
rPropertyHolders.Current().setTextColor(pA->GetColor().getBColor());
break;
}
case META_TEXTFILLCOLOR_ACTION :
{
/** SIMPLE, DONE */
const MetaTextFillColorAction* pA = (const MetaTextFillColorAction*)pAction;
const bool bWithColorArgument(pA->IsSetting());
if(bWithColorArgument)
{
// emulate OutputDevice::SetTextFillColor(...) WITH argument
const Color& rFontFillColor = pA->GetColor();
rPropertyHolders.Current().setTextFillColor(rFontFillColor.getBColor());
rPropertyHolders.Current().setTextFillColorActive(COL_TRANSPARENT != rFontFillColor.GetColor());
}
else
{
// emulate SetFillColor() <- NO argument (!)
rPropertyHolders.Current().setTextFillColorActive(false);
}
break;
}
case META_TEXTALIGN_ACTION :
{
/** SIMPLE, DONE */
const MetaTextAlignAction* pA = (const MetaTextAlignAction*)pAction;
const TextAlign aNewTextAlign = pA->GetTextAlign();
// TextAlign is applied to the current font (as in
// OutputDevice::SetTextAlign which would be used when
// playing the Metafile)
if(rPropertyHolders.Current().getFont().GetAlign() != aNewTextAlign)
{
Font aNewFont(rPropertyHolders.Current().getFont());
aNewFont.SetAlign(aNewTextAlign);
rPropertyHolders.Current().setFont(aNewFont);
}
break;
}
case META_MAPMODE_ACTION :
{
/** CHECKED, WORKS WELL */
// the most necessary MapMode to be interpreted is MAP_RELATIVE,
// but also the others may occur. Even not yet supported ones
// may need to be added here later
const MetaMapModeAction* pA = (const MetaMapModeAction*)pAction;
const MapMode& rMapMode = pA->GetMapMode();
basegfx::B2DHomMatrix aMapping;
if(MAP_RELATIVE == rMapMode.GetMapUnit())
{
aMapping = getTransformFromMapMode(rMapMode);
}
else
{
switch(rMapMode.GetMapUnit())
{
case MAP_100TH_MM :
{
if(MAP_TWIP == rPropertyHolders.Current().getMapUnit())
{
// MAP_TWIP -> MAP_100TH_MM
const double fTwipTo100thMm(127.0 / 72.0);
aMapping.scale(fTwipTo100thMm, fTwipTo100thMm);
}
break;
}
case MAP_TWIP :
{
if(MAP_100TH_MM == rPropertyHolders.Current().getMapUnit())
{
// MAP_100TH_MM -> MAP_TWIP
const double f100thMmToTwip(72.0 / 127.0);
aMapping.scale(f100thMmToTwip, f100thMmToTwip);
}
break;
}
default :
{
OSL_ENSURE(false, "interpretMetafile: META_MAPMODE_ACTION with unsupported MapUnit (!)");
break;
}
}
aMapping = getTransformFromMapMode(rMapMode) * aMapping;
rPropertyHolders.Current().setMapUnit(rMapMode.GetMapUnit());
}
if(!aMapping.isIdentity())
{
aMapping = aMapping * rPropertyHolders.Current().getTransformation();
rPropertyHolders.Current().setTransformation(aMapping);
}
break;
}
case META_FONT_ACTION :
{
/** SIMPLE, DONE */
const MetaFontAction* pA = (const MetaFontAction*)pAction;
rPropertyHolders.Current().setFont(pA->GetFont());
Size aFontSize(pA->GetFont().GetSize());
if(0 == aFontSize.Height())
{
// this should not happen but i got Metafiles where this was the
// case. A height needs to be guessed (similar to OutputDevice::ImplNewFont())
Font aCorrectedFont(pA->GetFont());
// guess 16 pixel (as in VCL)
aFontSize = Size(0, 16);
// convert to target MapUnit if not pixels
aFontSize = Application::GetDefaultDevice()->LogicToLogic(
aFontSize, MAP_PIXEL, rPropertyHolders.Current().getMapUnit());
aCorrectedFont.SetSize(aFontSize);
rPropertyHolders.Current().setFont(aCorrectedFont);
}
// older Metafiles have no META_TEXTCOLOR_ACTION which defines
// the FontColor now, so use the Font's color when not transparent
const Color& rFontColor = pA->GetFont().GetColor();
const bool bActivate(COL_TRANSPARENT != rFontColor.GetColor());
if(bActivate)
{
rPropertyHolders.Current().setTextColor(rFontColor.getBColor());
}
// caution: do NOT decativate here on transparet, see
// OutputDevice::SetFont(..) for more info
// rPropertyHolders.Current().setTextColorActive(bActivate);
// for fill color emulate a MetaTextFillColorAction with !transparent as bool,
// see OutputDevice::SetFont(..) the if(mpMetaFile) case
if(bActivate)
{
const Color& rFontFillColor = pA->GetFont().GetFillColor();
rPropertyHolders.Current().setTextFillColor(rFontFillColor.getBColor());
rPropertyHolders.Current().setTextFillColorActive(COL_TRANSPARENT != rFontFillColor.GetColor());
}
else
{
rPropertyHolders.Current().setTextFillColorActive(false);
}
break;
}
case META_PUSH_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaPushAction* pA = (const MetaPushAction*)pAction;
rPropertyHolders.Push(pA->GetFlags());
break;
}
case META_POP_ACTION :
{
/** CHECKED, WORKS WELL */
const bool bRegionMayChange(rPropertyHolders.Current().getPushFlags() & PUSH_CLIPREGION);
const bool bRasterOpMayChange(rPropertyHolders.Current().getPushFlags() & PUSH_RASTEROP);
if(bRegionMayChange && rPropertyHolders.Current().getRegionActive())
{
// end evtl. clipping
HandleNewClipRegion(0, rTargetHolders, rPropertyHolders);
}
if(bRasterOpMayChange && rPropertyHolders.Current().isRasterOpActive())
{
// end evtl. RasterOp
HandleNewRasterOp(ROP_OVERPAINT, rTargetHolders, rPropertyHolders);
}
rPropertyHolders.Pop();
if(bRasterOpMayChange && rPropertyHolders.Current().isRasterOpActive())
{
// start evtl. RasterOp
HandleNewRasterOp(rPropertyHolders.Current().getRasterOp(), rTargetHolders, rPropertyHolders);
}
if(bRegionMayChange && rPropertyHolders.Current().getRegionActive())
{
// start evtl. clipping
HandleNewClipRegion(&rPropertyHolders.Current().getRegion(), rTargetHolders, rPropertyHolders);
}
break;
}
case META_RASTEROP_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaRasterOpAction* pA = (const MetaRasterOpAction*)pAction;
const RasterOp aRasterOp = pA->GetRasterOp();
HandleNewRasterOp(aRasterOp, rTargetHolders, rPropertyHolders);
break;
}
case META_TRANSPARENT_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaTransparentAction* pA = (const MetaTransparentAction*)pAction;
const basegfx::B2DPolyPolygon aOutline(pA->GetPolyPolygon().getB2DPolyPolygon());
if(aOutline.count())
{
const sal_uInt16 nTransparence(pA->GetTransparence());
if(0 == nTransparence)
{
// not transparent
createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current());
}
else if(nTransparence >= 100)
{
// fully or more than transparent
}
else
{
// transparent. Create new target
rTargetHolders.Push();
// create primitives there and get them
createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current());
const drawinglayer::primitive2d::Primitive2DSequence aSubContent(
rTargetHolders.Current().getPrimitive2DSequence(rPropertyHolders.Current()));
// back to old target
rTargetHolders.Pop();
if(aSubContent.hasElements())
{
rTargetHolders.Current().append(
new drawinglayer::primitive2d::UnifiedAlphaPrimitive2D(
aSubContent,
nTransparence * 0.01));
}
}
}
break;
}
case META_EPS_ACTION :
{
/** CHECKED, WORKS WELL */
// To support this action, i have added a EpsPrimitive2D which will
// by default decompose to the Metafile replacement data. To support
// this EPS on screen, the renderer visualizing this has to support
// that primitive and visualize the Eps file (e.g. printing)
const MetaEPSAction* pA = (const MetaEPSAction*)pAction;
const Rectangle aRectangle(pA->GetPoint(), pA->GetSize());
if(!aRectangle.IsEmpty())
{
// create object transform
basegfx::B2DHomMatrix aObjectTransform;
aObjectTransform.set(0, 0, aRectangle.GetWidth());
aObjectTransform.set(1, 1, aRectangle.GetHeight());
aObjectTransform.set(0, 2, aRectangle.Left());
aObjectTransform.set(1, 2, aRectangle.Top());
// add current transformation
aObjectTransform = rPropertyHolders.Current().getTransformation() * aObjectTransform;
// embed using EpsPrimitive
rTargetHolders.Current().append(
new drawinglayer::primitive2d::EpsPrimitive2D(
aObjectTransform,
pA->GetLink(),
pA->GetSubstitute()));
}
break;
}
case META_REFPOINT_ACTION :
{
/** SIMPLE, DONE */
// only used for hatch and line pattern offsets, pretty much no longer
// supported today
// const MetaRefPointAction* pA = (const MetaRefPointAction*)pAction;
break;
}
case META_TEXTLINECOLOR_ACTION :
{
/** SIMPLE, DONE */
const MetaTextLineColorAction* pA = (const MetaTextLineColorAction*)pAction;
const bool bActive(pA->IsSetting());
rPropertyHolders.Current().setTextLineColorActive(bActive);
if(bActive)
rPropertyHolders.Current().setTextLineColor(pA->GetColor().getBColor());
break;
}
case META_TEXTLINE_ACTION :
{
/** CHECKED, WORKS WELL */
// actually creates overline, underline and strikeouts, so
// these should be isolated from TextDecoratedPortionPrimitive2D
// to own primitives. Done, available now.
//
// This Metaaction seems not to be used (was not used in any
// checked files). It's used in combination with the current
// Font.
const MetaTextLineAction* pA = (const MetaTextLineAction*)pAction;
proccessMetaTextLineAction(
*pA,
rTargetHolders.Current(),
rPropertyHolders.Current());
break;
}
case META_FLOATTRANSPARENT_ACTION :
{
/** CHECKED, WORKS WELL */
const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*)pAction;
const Rectangle aTargetRectangle(pA->GetPoint(), pA->GetSize());
if(!aTargetRectangle.IsEmpty())
{
const GDIMetaFile& rContent = pA->GetGDIMetaFile();
if(rContent.GetActionCount())
{
// create the sub-content with no embedding specific to the
// sub-metafile, this seems not to be used.
drawinglayer::primitive2d::Primitive2DSequence xSubContent;
{
rTargetHolders.Push();
interpretMetafile(rContent, rTargetHolders, rPropertyHolders, rViewInformation);
xSubContent = rTargetHolders.Current().getPrimitive2DSequence(rPropertyHolders.Current());
rTargetHolders.Pop();
}
if(xSubContent.hasElements())
{
// check if gradient is a real gradient
const Gradient& rGradient = pA->GetGradient();
const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient));
if(aAttribute.getStartColor() == aAttribute.getEndColor())
{
// not really a gradient; create UnifiedAlphaPrimitive2D
rTargetHolders.Current().append(
new drawinglayer::primitive2d::UnifiedAlphaPrimitive2D(
xSubContent,
aAttribute.getStartColor().luminance()));
}
else
{
// really a gradient. Create gradient sub-content (with correct scaling)
basegfx::B2DRange aRange(
aTargetRectangle.Left(), aTargetRectangle.Top(),
aTargetRectangle.Right(), aTargetRectangle.Bottom());
aRange.transform(rPropertyHolders.Current().getTransformation());
// prepare gradient for alpha content
const drawinglayer::primitive2d::Primitive2DReference xAlpha(
new drawinglayer::primitive2d::FillGradientPrimitive2D(
aRange,
aAttribute));
// create alpha primitive
rTargetHolders.Current().append(
new drawinglayer::primitive2d::AlphaPrimitive2D(
xSubContent,
drawinglayer::primitive2d::Primitive2DSequence(&xAlpha, 1)));
}
}
}
}
break;
}
case META_GRADIENTEX_ACTION :
{
/** SIMPLE, DONE */
// This is only a data holder which is interpreted inside comment actions,
// see META_COMMENT_ACTION for more info
// const MetaGradientExAction* pA = (const MetaGradientExAction*)pAction;
break;
}
case META_LAYOUTMODE_ACTION :
{
/** SIMPLE, DONE */
const MetaLayoutModeAction* pA = (const MetaLayoutModeAction*)pAction;
rPropertyHolders.Current().setLayoutMode(pA->GetLayoutMode());
break;
}
case META_TEXTLANGUAGE_ACTION :
{
/** SIMPLE, DONE */
const MetaTextLanguageAction* pA = (const MetaTextLanguageAction*)pAction;
rPropertyHolders.Current().setLanguageType(pA->GetTextLanguage());
break;
}
case META_OVERLINECOLOR_ACTION :
{
/** SIMPLE, DONE */
const MetaOverlineColorAction* pA = (const MetaOverlineColorAction*)pAction;
const bool bActive(pA->IsSetting());
rPropertyHolders.Current().setOverlineColorActive(bActive);
if(bActive)
rPropertyHolders.Current().setOverlineColor(pA->GetColor().getBColor());
break;
}
case META_COMMENT_ACTION :
{
/** CHECKED, WORKS WELL */
// I already implemented
// XPATHFILL_SEQ_BEGIN, XPATHFILL_SEQ_END
// XPATHSTROKE_SEQ_BEGIN, XPATHSTROKE_SEQ_END,
// but opted to remove these again; it works well without them
// and makes the code less dependent from those Metafile Add-Ons
const MetaCommentAction* pA = (const MetaCommentAction*)pAction;
if(COMPARE_EQUAL == pA->GetComment().CompareIgnoreCaseToAscii("XGRAD_SEQ_BEGIN"))
{
// XGRAD_SEQ_BEGIN, XGRAD_SEQ_END should be supported since the
// pure recorded paint of the gradients uses the XOR paint functionality
// ('trick'). This is (and will be) broblematic with AntAliasing, so it's
// better to use this info
const MetaGradientExAction* pMetaGradientExAction = 0;
bool bDone(false);
sal_uInt32 b(nAction + 1);
for(; !bDone && b < nCount; b++)
{
pAction = rMetaFile.GetAction(b);
if(META_GRADIENTEX_ACTION == pAction->GetType())
{
pMetaGradientExAction = (const MetaGradientExAction*)pAction;
}
else if(META_COMMENT_ACTION == pAction->GetType())
{
if(COMPARE_EQUAL == ((const MetaCommentAction*)pAction)->GetComment().CompareIgnoreCaseToAscii("XGRAD_SEQ_END"))
{
bDone = true;
}
}
}
if(bDone && pMetaGradientExAction)
{
// consume actions and skip forward
nAction = b - 1;
// get geometry data
basegfx::B2DPolyPolygon aPolyPolygon(pMetaGradientExAction->GetPolyPolygon().getB2DPolyPolygon());
if(aPolyPolygon.count())
{
// transform geometry
aPolyPolygon.transform(rPropertyHolders.Current().getTransformation());
// get and check if gradient is a real gradient
const Gradient& rGradient = pMetaGradientExAction->GetGradient();
const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient));
if(aAttribute.getStartColor() == aAttribute.getEndColor())
{
// not really a gradient
rTargetHolders.Current().append(
new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
aPolyPolygon,
aAttribute.getStartColor()));
}
else
{
// really a gradient
rTargetHolders.Current().append(
new drawinglayer::primitive2d::PolyPolygonGradientPrimitive2D(
aPolyPolygon,
aAttribute));
}
}
}
}
break;
}
default:
{
OSL_ENSURE(false, "Unknown MetaFile Action (!)");
break;
}
}
}
}
} // end of anonymous namespace
//////////////////////////////////////////////////////////////////////////////
namespace drawinglayer
{
namespace primitive2d
{
Primitive2DSequence MetafilePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
{
// prepare target and porperties; each will have one default entry
TargetHolders aTargetHolders;
PropertyHolders aPropertyHolders;
// set target MapUnit at Properties
aPropertyHolders.Current().setMapUnit(getMetaFile().GetPrefMapMode().GetMapUnit());
// interpret the Metafile
interpretMetafile(getMetaFile(), aTargetHolders, aPropertyHolders, rViewInformation);
// get the content. There should be ony one target, as in the start condition,
// but iterating will be the right thing to do when some push/pop is not closed
Primitive2DSequence xRetval;
while(aTargetHolders.size() > 1)
{
appendPrimitive2DSequenceToPrimitive2DSequence(xRetval,
aTargetHolders.Current().getPrimitive2DSequence(aPropertyHolders.Current()));
aTargetHolders.Pop();
}
appendPrimitive2DSequenceToPrimitive2DSequence(xRetval,
aTargetHolders.Current().getPrimitive2DSequence(aPropertyHolders.Current()));
if(xRetval.hasElements())
{
// get target size
const Rectangle aMtfTarget(getMetaFile().GetPrefMapMode().GetOrigin(), getMetaFile().GetPrefSize());
// create transformation
basegfx::B2DHomMatrix aAdaptedTransform;
aAdaptedTransform.translate(-aMtfTarget.Left(), -aMtfTarget.Top());
aAdaptedTransform.scale(
aMtfTarget.getWidth() ? 1.0 / aMtfTarget.getWidth() : 1.0,
aMtfTarget.getHeight() ? 1.0 / aMtfTarget.getHeight() : 1.0);
aAdaptedTransform = getTransform() * aAdaptedTransform;
// embed to target transformation
const Primitive2DReference aEmbeddedTransform(
new TransformPrimitive2D(
aAdaptedTransform,
xRetval));
xRetval = Primitive2DSequence(&aEmbeddedTransform, 1);
}
return xRetval;
}
MetafilePrimitive2D::MetafilePrimitive2D(
const basegfx::B2DHomMatrix& rMetaFileTransform,
const GDIMetaFile& rMetaFile)
: BufferedDecompositionPrimitive2D(),
maMetaFileTransform(rMetaFileTransform),
maMetaFile(rMetaFile)
{
}
bool MetafilePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
{
if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
{
const MetafilePrimitive2D& rCompare = (MetafilePrimitive2D&)rPrimitive;
return (getTransform() == rCompare.getTransform()
&& getMetaFile() == rCompare.getMetaFile());
}
return false;
}
basegfx::B2DRange MetafilePrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
{
// use own implementation to quickly answer the getB2DRange question. The
// MetafilePrimitive2D assumes that all geometry is inside of the shape. If
// this is not the case (i have already seen some wrong Metafiles) it should
// be embedded to a MaskPrimitive2D
basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0);
aRetval.transform(getTransform());
return aRetval;
}
// provide unique ID
ImplPrimitrive2DIDBlock(MetafilePrimitive2D, PRIMITIVE2D_ID_METAFILEPRIMITIVE2D)
} // end of namespace primitive2d
} // end of namespace drawinglayer
//////////////////////////////////////////////////////////////////////////////
// eof
|