summaryrefslogtreecommitdiff
path: root/xmloff/source/draw/sdxmlexp.cxx
blob: f40f5f1f0ba577a667e7ac397280605d9f87c813 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
/*************************************************************************
 *
 *  $RCSfile: sdxmlexp.cxx,v $
 *
 *  $Revision: 1.27 $
 *
 *  last change: $Author: cl $ $Date: 2000-12-05 23:21:20 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#pragma hdrstop

#ifndef _XMLOFF_NMSPMAP_HXX
#include "nmspmap.hxx"
#endif

#ifndef _XMLOFF_XMLNMSPE_HXX
#include "xmlnmspe.hxx"
#endif

#ifndef _XMLOFF_XMLUCONV_HXX
#include "xmluconv.hxx"
#endif

#ifndef _XMLOFF_XMLKYWD_HXX
#include "xmlkywd.hxx"
#endif

#ifndef _LANG_HXX
#include <tools/lang.hxx>
#endif

#ifndef _XMLOFF_XMLMETAE_HXX
#include "xmlmetae.hxx"
#endif

#ifndef _COM_SUN_STAR_DOCUMENT_XDOCUMENTINFOSUPPLIER_HPP_
#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
#endif

#ifndef _COM_SUN_STAR_TASK_XSTATUSINDICATORSUPPLIER_HPP_
#include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
#endif

#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
#include <com/sun/star/lang/Locale.hpp>
#endif

#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
#include <com/sun/star/uno/Any.hxx>
#endif

#ifndef _SDXMLEXP_HXX
#include "sdxmlexp.hxx"
#endif

#ifndef _SDXMLEXP_IMPL_HXX
#include "sdxmlexp_impl.hxx"
#endif

#ifndef _COM_SUN_STAR_DRAWING_XDRAWPAGESSUPPLIER_HPP_
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#endif

#ifndef _COM_SUN_STAR_DRAWING_XMASTERPAGESSUPPLIER_HPP_
#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
#endif

#ifndef _COM_SUN_STAR_VIEW_PAPERORIENTATION_HPP_
#include <com/sun/star/view/PaperOrientation.hpp>
#endif

#ifndef _COM_SUN_STAR_STYLE_XSTYLEFAMILIESSUPPLIER_HPP_
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#endif

#ifndef _COM_SUN_STAR_STYLE_XSTYLE_HPP_
#include <com/sun/star/style/XStyle.hpp>
#endif

#ifndef _COM_SUN_STAR_PRESENTATION_XPRESENTATIONPAGE_HPP_
#include <com/sun/star/presentation/XPresentationPage.hpp>
#endif

#ifndef _COM_SUN_STAR_DRAWING_XMASTERPAGETARGET_HPP_
#include <com/sun/star/drawing/XMasterPageTarget.hpp>
#endif

#ifndef _COM_SUN_STAR_DRAWING_CONNECTORTYPE_HPP_
#include <com/sun/star/drawing/ConnectorType.hpp>
#endif

#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_
#include <com/sun/star/text/XText.hpp>
#endif

#ifndef _COM_SUN_STAR_CHART_XCHARTDOCUMENT_HPP_
#include <com/sun/star/chart/XChartDocument.hpp>
#endif

#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
#include <com/sun/star/container/XNamed.hpp>
#endif

#ifndef _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
#endif

#ifndef _SV_GEN_HXX
#include <tools/gen.hxx>
#endif

#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif

#ifndef _XMLOFF_XMLASTPLP_HXX
#include "xmlaustp.hxx"
#endif

#ifndef _XMLOFF_FAMILIES_HXX_
#include "families.hxx"
#endif

#ifndef _XMLOFF_STYLEEXP_HXX_
#include "styleexp.hxx"
#endif

#ifndef _SDPROPLS_HXX
#include "sdpropls.hxx"
#endif

#ifndef _XMLOFF_XMLEXPPR_HXX
#include "xmlexppr.hxx"
#endif

#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
#include <com/sun/star/beans/XPropertyState.hpp>
#endif

#ifndef _XEXPTRANSFORM_HXX
#include "xexptran.hxx"
#endif

#ifndef _COM_SUN_STAR_DRAWING_POLYPOLYGONBEZIERCOORDS_HPP_
#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
#endif

#ifndef _ISOLANG_HXX
#include <tools/isolang.hxx>
#endif

#ifndef _CPPUHELPER_IMPLBASE1_HXX
#include <cppuhelper/implbase1.hxx>
#endif

#ifndef _CPPUHELPER_EXTRACT_HXX_
#include <cppuhelper/extract.hxx>
#endif

#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif

#ifndef _B3D_HMATRIX_HXX
#include <goodies/hmatrix.hxx>
#endif

#ifndef _COM_SUN_STAR_DRAWING_HOMOGENMATRIX_HPP_
#include <com/sun/star/drawing/HomogenMatrix.hpp>
#endif

#ifndef _COM_SUN_STAR_DRAWING_POLYPOLYGONSHAPE3D_HPP_
#include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
#endif

#ifndef _COM_SUN_STAR_DRAWING_DOUBLESEQUENCE_HPP_
#include <com/sun/star/drawing/DoubleSequence.hpp>
#endif

#ifndef _COM_SUN_STAR_DRAWING_PROJECTIONMODE_HPP_
#include <com/sun/star/drawing/ProjectionMode.hpp>
#endif

#ifndef _COM_SUN_STAR_DRAWING_SHADEMODE_HPP_
#include <com/sun/star/drawing/ShadeMode.hpp>
#endif

#ifndef _COM_SUN_STAR_DRAWING_DIRECTION3D_HPP_
#include <com/sun/star/drawing/Direction3D.hpp>
#endif

#ifndef _XMLOFF_PROPERTYSETMERGER_HXX_
#include "PropertySetMerger.hxx"
#endif

#ifndef _COM_SUN_STAR_DRAWING_CAMERAGEOMETRY_HPP_
#include <com/sun/star/drawing/CameraGeometry.hpp>
#endif

using namespace ::rtl;
using namespace ::com::sun::star;

//////////////////////////////////////////////////////////////////////////////

inline sal_Int32 FRound( double fVal )
{
    return( fVal > 0.0 ? (sal_Int32) ( fVal + 0.5 ) : -(sal_Int32) ( -fVal + 0.5 ) );
}

//////////////////////////////////////////////////////////////////////////////
// wrapper to have control for virtual function calls to handle all kinds
// of possible item specialities

class ImpPresPageDrawStylePropMapper : public SvXMLExportPropertyMapper
{
    /** this method is called for every item that has the MID_FLAG_NO_ITEM_EXPORT flag set */
    virtual void handleNoItem(
        SvXMLAttributeList& rAttrList, const XMLPropertyState& rProperty,
        const SvXMLUnitConverter& rUnitConverter, const SvXMLNamespaceMap& rNamespaceMap,
        const ::std::vector< XMLPropertyState > *pProperties = 0,
        sal_uInt32 nIdx = 0 ) const;

    /** this method is called for every item that has the MID_FLAG_ELEMENT_EXPORT flag set */
    virtual void handleElementItem(
        const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > & rHandler,
        const XMLPropertyState& rProperty, const SvXMLUnitConverter& rUnitConverter,
        const SvXMLNamespaceMap& rNamespaceMap, sal_uInt16 nFlags,
        const ::std::vector< XMLPropertyState > *pProperties = 0,
        sal_uInt32 nIdx = 0 ) const;

    /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_EXPORT flag set */
    virtual void handleSpecialItem(
        SvXMLAttributeList& rAttrList, const XMLPropertyState& rProperty,
        const SvXMLUnitConverter& rUnitConverter, const SvXMLNamespaceMap& rNamespaceMap,
        const ::std::vector< XMLPropertyState > *pProperties = 0,
        sal_uInt32 nIdx = 0 ) const;

public:
    ImpPresPageDrawStylePropMapper( const UniReference< XMLPropertySetMapper >& rMapper );
    virtual ~ImpPresPageDrawStylePropMapper();
};

ImpPresPageDrawStylePropMapper::ImpPresPageDrawStylePropMapper(
    const UniReference< XMLPropertySetMapper >& rMapper )
:   SvXMLExportPropertyMapper( rMapper )
{
}

ImpPresPageDrawStylePropMapper::~ImpPresPageDrawStylePropMapper()
{
}

void ImpPresPageDrawStylePropMapper::handleNoItem(
    SvXMLAttributeList& rAttrList, const XMLPropertyState& rProperty,
    const SvXMLUnitConverter& rUnitConverter, const SvXMLNamespaceMap& rNamespaceMap,
    const ::std::vector< XMLPropertyState > *pProperties,
    sal_uInt32 nIdx ) const
{
    // call parent
    SvXMLExportPropertyMapper::handleNoItem(rAttrList, rProperty, rUnitConverter, rNamespaceMap, pProperties, nIdx );
}

void ImpPresPageDrawStylePropMapper::handleElementItem(
    const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > & rHandler,
    const XMLPropertyState& rProperty, const SvXMLUnitConverter& rUnitConverter,
    const SvXMLNamespaceMap& rNamespaceMap, sal_uInt16 nFlags,
    const ::std::vector< XMLPropertyState > *pProperties,
    sal_uInt32 nIdx) const
{
    // call parent
    SvXMLExportPropertyMapper::handleElementItem(rHandler, rProperty, rUnitConverter, rNamespaceMap, nFlags, pProperties, nIdx );
}

void ImpPresPageDrawStylePropMapper::handleSpecialItem(
    SvXMLAttributeList& rAttrList, const XMLPropertyState& rProperty,
    const SvXMLUnitConverter& rUnitConverter, const SvXMLNamespaceMap& rNamespaceMap,
    const ::std::vector< XMLPropertyState > *pProperties,
    sal_uInt32 nIdx ) const
{
    // call parent
    SvXMLExportPropertyMapper::handleSpecialItem(rAttrList, rProperty, rUnitConverter, rNamespaceMap, pProperties, nIdx );
}

//////////////////////////////////////////////////////////////////////////////

class ImpXMLShapeStyleInfo
{
    OUString                            msStyleName;
    sal_Int32                           mnFamily;

public:
    ImpXMLShapeStyleInfo(
        const OUString& rStyStr,
        sal_Int32 nFam);

    const OUString& GetStyleName() const { return msStyleName; }
    sal_Int32 GetFamily() const { return mnFamily; }
};

ImpXMLShapeStyleInfo::ImpXMLShapeStyleInfo(
    const OUString& rStyStr,
    sal_Int32 nFam)
:   msStyleName(rStyStr),
    mnFamily(nFam)
{
}

DECLARE_LIST(ImpXMLShapeStyleInfoList, ImpXMLShapeStyleInfo*);

//////////////////////////////////////////////////////////////////////////////

class ImpXMLDrawPageInfo
{
    OUString                        msStyleName;
    OUString                        msPageLayoutName;

public:
    ImpXMLDrawPageInfo(const OUString& rStyStr);

    void SetPageLayoutName(const OUString& rStr);

    const OUString& GetStyleName() const { return msStyleName; }
    const OUString& GetPageLayoutName() const { return msPageLayoutName; }
};

ImpXMLDrawPageInfo::ImpXMLDrawPageInfo(const OUString& rStyStr)
:   msStyleName(rStyStr)
{
}

void ImpXMLDrawPageInfo::SetPageLayoutName(const OUString& rStr)
{
    msPageLayoutName = rStr;
}

DECLARE_LIST(ImpXMLDrawPageInfoList, ImpXMLDrawPageInfo*);

//////////////////////////////////////////////////////////////////////////////

class ImpXMLEXPPageMasterInfo
{
    sal_Int32                   mnBorderBottom;
    sal_Int32                   mnBorderLeft;
    sal_Int32                   mnBorderRight;
    sal_Int32                   mnBorderTop;
    sal_Int32                   mnWidth;
    sal_Int32                   mnHeight;
    view::PaperOrientation      meOrientation;
    OUString                    msName;
    OUString                    msMasterPageName;

public:
    ImpXMLEXPPageMasterInfo(const SdXMLExport& rExp, const uno::Reference<drawing::XDrawPage>& xPage);
    BOOL operator==(const ImpXMLEXPPageMasterInfo& rInfo) const;
    void SetName(const OUString& rStr);

    const OUString& GetName() const { return msName; }
    const OUString& GetMasterPageName() const { return msMasterPageName; }

    sal_Int32 GetBorderBottom() const { return mnBorderBottom; }
    sal_Int32 GetBorderLeft() const { return mnBorderLeft; }
    sal_Int32 GetBorderRight() const { return mnBorderRight; }
    sal_Int32 GetBorderTop() const { return mnBorderTop; }
    sal_Int32 GetWidth() const { return mnWidth; }
    sal_Int32 GetHeight() const { return mnHeight; }
    view::PaperOrientation GetOrientation() const { return meOrientation; }
};

ImpXMLEXPPageMasterInfo::ImpXMLEXPPageMasterInfo(
    const SdXMLExport& rExp,
    const uno::Reference<drawing::XDrawPage>& xPage)
:   mnBorderBottom(0),
    mnBorderLeft(0),
    mnBorderRight(0),
    mnBorderTop(0),
    mnWidth(0),
    mnHeight(0),
    meOrientation(rExp.IsDraw() ? view::PaperOrientation_PORTRAIT : view::PaperOrientation_LANDSCAPE)
{
    uno::Reference <beans::XPropertySet> xPropSet(xPage, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        uno::Any aAny;

        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderBottom")));
        aAny >>= mnBorderBottom;

        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderLeft")));
        aAny >>= mnBorderLeft;

        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderRight")));
        aAny >>= mnBorderRight;

        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BorderTop")));
        aAny >>= mnBorderTop;

        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Width")));
        aAny >>= mnWidth;

        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Height")));
        aAny >>= mnHeight;

        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Orientation")));
        aAny >>= meOrientation;
    }

    uno::Reference <container::XNamed> xMasterNamed(xPage, uno::UNO_QUERY);
    if(xMasterNamed.is())
    {
        msMasterPageName = xMasterNamed->getName();
    }
}

BOOL ImpXMLEXPPageMasterInfo::operator==(const ImpXMLEXPPageMasterInfo& rInfo) const
{
    return ((mnBorderBottom == rInfo.mnBorderBottom)
        && (mnBorderLeft == rInfo.mnBorderLeft)
        && (mnBorderRight == rInfo.mnBorderRight)
        && (mnBorderTop == rInfo.mnBorderTop)
        && (mnWidth == rInfo.mnWidth)
        && (mnHeight == rInfo.mnHeight)
        && (meOrientation == rInfo.meOrientation));
}

void ImpXMLEXPPageMasterInfo::SetName(const OUString& rStr)
{
    msName = rStr;
}

DECLARE_LIST(ImpXMLEXPPageMasterList, ImpXMLEXPPageMasterInfo*);

//////////////////////////////////////////////////////////////////////////////

#define IMP_AUTOLAYOUT_INFO_MAX         (27L)

class ImpXMLAutoLayoutInfo
{
    sal_uInt16                  mnType;
    ImpXMLEXPPageMasterInfo*    mpPageMasterInfo;
    OUString                    msLayoutName;
    Rectangle                   maTitleRect;
    Rectangle                   maPresRect;
    sal_Int32                   mnGapX;
    sal_Int32                   mnGapY;

public:
    ImpXMLAutoLayoutInfo(sal_uInt16 nTyp, ImpXMLEXPPageMasterInfo* pInf);

    BOOL operator==(const ImpXMLAutoLayoutInfo& rInfo) const;

    sal_uInt16 GetLayoutType() const { return mnType; }
    sal_Int32 GetGapX() const { return mnGapX; }
    sal_Int32 GetGapY() const { return mnGapY; }

    const OUString& GetLayoutName() const { return msLayoutName; }
    void SetLayoutName(const OUString& rNew) { msLayoutName = rNew; }

    const Rectangle& GetTitleRectangle() const { return maTitleRect; }
    const Rectangle& GetPresRectangle() const { return maPresRect; }

    static BOOL IsCreateNecessary(sal_uInt16 nTyp);
};

BOOL ImpXMLAutoLayoutInfo::IsCreateNecessary(sal_uInt16 nTyp)
{
    if(nTyp == 5 /* AUTOLAYOUT_ORG */
        || nTyp == 20 /* AUTOLAYOUT_NONE */
        || nTyp >= IMP_AUTOLAYOUT_INFO_MAX)
        return FALSE;
    return TRUE;
}

BOOL ImpXMLAutoLayoutInfo::operator==(const ImpXMLAutoLayoutInfo& rInfo) const
{
    return ((mnType == rInfo.mnType
        && mpPageMasterInfo == rInfo.mpPageMasterInfo));
}

ImpXMLAutoLayoutInfo::ImpXMLAutoLayoutInfo(sal_uInt16 nTyp, ImpXMLEXPPageMasterInfo* pInf)
:   mnType(nTyp),
    mpPageMasterInfo(pInf)
{
    // create full info (initialze with typical values)
    Point aPagePos(0,0);
    Size aPageSize(28000, 21000);
    Size aPageInnerSize(28000, 21000);

    if(mpPageMasterInfo)
    {
        aPagePos = Point(mpPageMasterInfo->GetBorderLeft(), mpPageMasterInfo->GetBorderTop());
        aPageSize = Size(mpPageMasterInfo->GetWidth(), mpPageMasterInfo->GetHeight());
        aPageInnerSize = aPageSize;
        aPageInnerSize.Width() -= mpPageMasterInfo->GetBorderLeft() + mpPageMasterInfo->GetBorderRight();
        aPageInnerSize.Height() -= mpPageMasterInfo->GetBorderTop() + mpPageMasterInfo->GetBorderBottom();
    }

    // title rectangle aligning
    Point aTitlePos(aPagePos);
    Size aTitleSize(aPageInnerSize);

    if(mnType == 21 /* AUTOLAYOUT_NOTES */)
    {
        aTitleSize.Height() = (long) (aTitleSize.Height() / 2.5);
        Point aPos = aTitlePos;
        aPos.Y() += long( aTitleSize.Height() * 0.083 );
        Size aPartArea = aTitleSize;
        Size aSize;

        // tatsaechliche Seitengroesse in das Handout-Rechteck skalieren
        double fH = (double) aPartArea.Width()  / aPageSize.Width();
        double fV = (double) aPartArea.Height() / aPageSize.Height();

        if ( fH > fV )
            fH = fV;
        aSize.Width()  = (long) (fH * aPageSize.Width());
        aSize.Height() = (long) (fH * aPageSize.Height());

        aPos.X() += (aPartArea.Width() - aSize.Width()) / 2;
        aPos.Y() += (aPartArea.Height()- aSize.Height())/ 2;

        aTitlePos = aPos;
        aTitleSize = aSize;
    }
    else
    {
        aTitlePos.X() += long( aTitleSize.Width() * 0.0735 );
        aTitlePos.Y() += long( aTitleSize.Height() * 0.083 );
        aTitleSize.Width() = long( aTitleSize.Width() * 0.854 );
        aTitleSize.Height() = long( aTitleSize.Height() * 0.167 );
    }

    maTitleRect.SetPos(aTitlePos);
    maTitleRect.SetSize(aTitleSize);

    // layout rectangle aligning
    Point aLayoutPos(aPagePos);
    Size aLayoutSize(aPageInnerSize);

    if(mnType == 21 /* AUTOLAYOUT_NOTES */)
    {
        aLayoutPos.X() += long( aLayoutSize.Width() * 0.0735 );
        aLayoutPos.Y() += long( aLayoutSize.Height() * 0.472 );
        aLayoutSize.Width() = long( aLayoutSize.Width() * 0.854 );
        aLayoutSize.Height() = long( aLayoutSize.Height() * 0.444 );
    }
    else if(mnType >= 22 && mnType <= 26) // AUTOLAYOUT_HANDOUT
    {
        // keep info for inner area in maPresRect, put info for gap size
        // to maTitleRect position
        mnGapX = (aPageSize.Width() - aPageInnerSize.Width()) / 2;
        mnGapY = (aPageSize.Height() - aPageInnerSize.Height()) / 2;

        if(!mnGapX)
            mnGapX = aPageSize.Width() / 10;

        if(!mnGapY)
            mnGapY = aPageSize.Height() / 10;

        if(mnGapX < aPageInnerSize.Width() / 10)
            mnGapX = aPageInnerSize.Width() / 10;

        if(mnGapY < aPageInnerSize.Height() / 10)
            mnGapY = aPageInnerSize.Height() / 10;
    }
    else
    {
        aLayoutPos.X() += long( aLayoutSize.Width() * 0.0735 );
        aLayoutPos.Y() += long( aLayoutSize.Height() * 0.278 );
        aLayoutSize.Width() = long( aLayoutSize.Width() * 0.854 );
        aLayoutSize.Height() = long( aLayoutSize.Height() * 0.630 );
    }

    maPresRect.SetPos(aLayoutPos);
    maPresRect.SetSize(aLayoutSize);
}

DECLARE_LIST(ImpXMLAutoLayoutInfoList, ImpXMLAutoLayoutInfo*);

//////////////////////////////////////////////////////////////////////////////

SdXMLExport::SdXMLExport(
    const uno::Reference<frame::XModel>& rMod,
    const OUString& rFileName,
    const uno::Reference<xml::sax::XDocumentHandler>& rHandler,
    const uno::Reference< ::com::sun::star::container::XIndexContainer > & rEGO,
    BOOL bShowProgr,
    BOOL bIsDraw)
:   SvXMLExport( rFileName, rHandler, rMod, rEGO, MAP_CM ),
    mpPageMasterInfoList(new ImpXMLEXPPageMasterList(1, 4, 4)),
    mpPageMaterUsageList(new ImpXMLEXPPageMasterList(1, 4, 4)),
    mpDrawPageInfoList(new ImpXMLDrawPageInfoList(4, 8, 8)),
    mpMasterPageInfoList(new ImpXMLDrawPageInfoList(4, 8, 8)),
    mpShapeStyleInfoList(new ImpXMLShapeStyleInfoList(16, 64, 64)),
    mpAutoLayoutInfoList(new ImpXMLAutoLayoutInfoList(1, 4, 4)),
    mpPropertySetMapper(0L),
    mpPresPagePropsMapper(0L),
    mnDocMasterPageCount(0L),
    mnDocDrawPageCount(0L),
    mnShapeStyleInfoIndex(0L),
    mbIsDraw(bIsDraw),
    mbFamilyGraphicUsed(FALSE),
    mbFamilyPresentationUsed(FALSE),
    msZIndex( RTL_CONSTASCII_USTRINGPARAM(sXML_zindex) ),
    msEmptyPres( RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ),
    msModel( RTL_CONSTASCII_USTRINGPARAM("Model") ),
    msStartShape( RTL_CONSTASCII_USTRINGPARAM("StartShape") ),
    msEndShape( RTL_CONSTASCII_USTRINGPARAM("EndShape") )
{
    // prepare factory parts
    mpSdPropHdlFactory = new XMLSdPropHdlFactory( rMod );
    if(mpSdPropHdlFactory)
    {
        // set lock to avoid deletion
        mpSdPropHdlFactory->acquire();

        // build one ref
        const UniReference< XMLPropertyHandlerFactory > aFactoryRef = mpSdPropHdlFactory;

        // construct PropertySetMapper
        UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( aFactoryRef);

        mpPropertySetMapper = new XMLShapeExportPropertyMapper( xMapper, (XMLTextListAutoStylePool*)&GetTextParagraphExport()->GetListAutoStylePool(), *this );
        // set lock to avoid deletion
        mpPropertySetMapper->acquire();

        // chain text attributes
        mpPropertySetMapper->ChainExportMapper(XMLTextParagraphExport::CreateCharExtPropMapper(*this));

        // construct PresPagePropsMapper
        xMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLSDPresPageProps, aFactoryRef);

        mpPresPagePropsMapper = new ImpPresPageDrawStylePropMapper( xMapper );
        if(mpPresPagePropsMapper)
        {
            // set lock to avoid deletion
            mpPresPagePropsMapper->acquire();
        }
    }

    // add family name
      GetAutoStylePool()->AddFamily(
        XML_STYLE_FAMILY_SD_GRAPHICS_ID,
        OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)),
          GetPropertySetMapper(),
          OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX)));
    GetAutoStylePool()->AddFamily(
        XML_STYLE_FAMILY_SD_PRESENTATION_ID,
        OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_NAME)),
          GetPropertySetMapper(),
          OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_PRESENTATION_PREFIX)));
    GetAutoStylePool()->AddFamily(
        XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID,
        OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME)),
          GetPresPagePropsMapper(),
          OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_DRAWINGPAGE_PREFIX)));

    // prepare access to styles
    uno::Reference< style::XStyleFamiliesSupplier > xFamSup( GetModel(), uno::UNO_QUERY );
    if(xFamSup.is())
    {
        mxDocStyleFamilies = xFamSup->getStyleFamilies();
    }

    // prepare access to master pages
    uno::Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), uno::UNO_QUERY);
    if(xMasterPagesSupplier.is())
    {
        mxDocMasterPages = mxDocMasterPages.query( xMasterPagesSupplier->getMasterPages() );
        if(mxDocMasterPages.is())
        {
            mnDocMasterPageCount = mxDocMasterPages->getCount();
        }
    }

    // prepare access to draw pages
    uno::Reference <drawing::XDrawPagesSupplier> xDrawPagesSupplier(GetModel(), uno::UNO_QUERY);
    if(xDrawPagesSupplier.is())
    {
        mxDocDrawPages = mxDocDrawPages.query( xDrawPagesSupplier->getDrawPages() );
        if(mxDocDrawPages.is())
        {
            mnDocDrawPageCount = mxDocDrawPages->getCount();
        }
    }

    // add namespaces
    _GetNamespaceMap().AddAtIndex(
        XML_NAMESPACE_PRESENTATION, sXML_np_presentation, sXML_n_presentation, XML_NAMESPACE_PRESENTATION);

    // get status indicator (if intended)
    if(bShowProgr)
    {
        uno::Reference<frame::XController> xController(rMod->getCurrentController());
        if(xController.is())
        {
            uno::Reference<frame::XFrame> xFrame(xController->getFrame());
            if(xFrame.is())
            {
                uno::Reference<task::XStatusIndicatorSupplier> xFactory(xFrame, uno::UNO_QUERY);
                if(xFactory.is())
                {
                    mxStatusIndicator = xFactory->getStatusIndicator();
                }
            }
        }
    }

    // add progress view
    if(mxStatusIndicator.is())
    {
        const OUString aText(RTL_CONSTASCII_USTRINGPARAM("XML Export"));
        mxStatusIndicator->start(aText, 100);
    }
}

//////////////////////////////////////////////////////////////////////////////

__EXPORT SdXMLExport::~SdXMLExport()
{
    // cleanup factory, decrease refcount. Should lead to destruction.
    if(mpSdPropHdlFactory)
    {
        mpSdPropHdlFactory->release();
        mpSdPropHdlFactory = 0L;
    }

    // cleanup mapper, decrease refcount. Should lead to destruction.
    if(mpPropertySetMapper)
    {
        mpPropertySetMapper->release();
        mpPropertySetMapper = 0L;
    }

    // cleanup presPage mapper, decrease refcount. Should lead to destruction.
    if(mpPresPagePropsMapper)
    {
        mpPresPagePropsMapper->release();
        mpPresPagePropsMapper = 0L;
    }

    // clear evtl. temporary page master infos
    if(mpPageMasterInfoList)
    {
        while(mpPageMasterInfoList->Count())
            delete mpPageMasterInfoList->Remove(mpPageMasterInfoList->Count() - 1L);
        delete mpPageMasterInfoList;
        mpPageMasterInfoList = 0L;
    }
    if(mpPageMaterUsageList)
    {
        delete mpPageMaterUsageList;
        mpPageMaterUsageList = 0L;
    }

    // clear draw style infos
    if(mpDrawPageInfoList)
    {
        while(mpDrawPageInfoList->Count())
            delete mpDrawPageInfoList->Remove(mpDrawPageInfoList->Count() - 1L);
        delete mpDrawPageInfoList;
        mpDrawPageInfoList = 0L;
    }

    // clear draw style infos
    if(mpMasterPageInfoList)
    {
        while(mpMasterPageInfoList->Count())
            delete mpMasterPageInfoList->Remove(mpMasterPageInfoList->Count() - 1L);
        delete mpMasterPageInfoList;
        mpMasterPageInfoList = 0L;
    }

    // clear shape style infos
    if(mpShapeStyleInfoList)
    {
        while(mpShapeStyleInfoList->Count())
            delete mpShapeStyleInfoList->Remove(mpShapeStyleInfoList->Count() - 1L);
        delete mpShapeStyleInfoList;
        mpShapeStyleInfoList = 0L;
    }

    // clear auto-layout infos
    if(mpAutoLayoutInfoList)
    {
        while(mpAutoLayoutInfoList->Count())
            delete mpAutoLayoutInfoList->Remove(mpAutoLayoutInfoList->Count() - 1L);
        delete mpAutoLayoutInfoList;
        mpAutoLayoutInfoList = 0L;
    }

    // stop progress view
    if(mxStatusIndicator.is())
    {
        mxStatusIndicator->end();
        mxStatusIndicator->reset();
    }
}

//////////////////////////////////////////////////////////////////////////////
// to get default values in XPropertySet use this wrapper class

class ImpDefaultMapper : public ::cppu::WeakAggImplHelper1< beans::XPropertySet >
{
    uno::Reference< beans::XPropertyState >     mxState;
    uno::Reference< beans::XPropertySet >       mxSet;

public:
    ImpDefaultMapper( uno::Reference< beans::XPropertyState >& rxState );

    // Methods
    virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(uno::RuntimeException);
    virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException);
    virtual uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);

    // empty implementations
    virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
    virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
    virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
    virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException);
};

ImpDefaultMapper::ImpDefaultMapper( uno::Reference< beans::XPropertyState >& rxState )
:   mxState( rxState ),
    mxSet( rxState, uno::UNO_QUERY )
{
}

uno::Reference< beans::XPropertySetInfo > SAL_CALL ImpDefaultMapper::getPropertySetInfo() throw(uno::RuntimeException)
{
    return mxSet->getPropertySetInfo();
}

void SAL_CALL ImpDefaultMapper::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
{
    mxState->setPropertyToDefault( aPropertyName /*, aValue */ );
}

uno::Any SAL_CALL ImpDefaultMapper::getPropertyValue( const OUString& PropertyName ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
{
    return mxState->getPropertyDefault(  PropertyName  );
}

// empty implementations
void SAL_CALL ImpDefaultMapper::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
void SAL_CALL ImpDefaultMapper::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
void SAL_CALL ImpDefaultMapper::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
void SAL_CALL ImpDefaultMapper::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpWriteDefaultStyleInfos()
{
    // create annd write pool defaults
    AddAttribute(XML_NAMESPACE_STYLE, sXML_name, OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_drawpool)));
    AddAttribute(XML_NAMESPACE_STYLE, sXML_family, OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_POOL_NAME)));

    // write drawpool style
    SvXMLElementExport aPSY(*this, XML_NAMESPACE_STYLE, sXML_style, sal_True, sal_True);

    // write graphics style properites
    uno::Any aAny(mxDocStyleFamilies->getByName(OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME))));
    uno::Reference< container::XIndexAccess > xGraphicStyles;

    if(aAny >>= xGraphicStyles)
    {
        BOOL bDone(FALSE);
        const sal_Int32 nNum = xGraphicStyles->getCount();

        for(sal_Int32 a(0L); !bDone && a < nNum; a++)
        {
            aAny = xGraphicStyles->getByIndex(a);
            uno::Reference< style::XStyle > xSingleStyle;

            if(aAny >>= xSingleStyle)
            {
                OUString aParentStyle = xSingleStyle->getParentStyle();
                if(!aParentStyle.getLength())
                {
                    // style without parent found
                    uno::Reference< beans::XPropertyState > xPropState(xSingleStyle, uno::UNO_QUERY);
                    if(xPropState.is())
                    {
                        uno::Reference< beans::XPropertySet > xImpDefaultMapper( new ImpDefaultMapper( xPropState ) );
                        const UniReference< SvXMLExportPropertyMapper > aMapperRef = GetPropertySetMapper();
                        std::vector< XMLPropertyState > xPropStates = aMapperRef->Filter( xImpDefaultMapper );

                        if(xPropStates.size())
                        {
                            aMapperRef->exportXML(GetDocHandler(), xPropStates,
                                GetMM100UnitConverter(), GetNamespaceMap());
                            bDone = TRUE;
                        }
                    }
                }
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpWriteObjGraphicStyleInfos()
{
    XMLStyleExport aStEx(*this,
        OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_drawpool)), GetAutoStylePool().get());
    const UniReference< SvXMLExportPropertyMapper > aMapperRef = GetPropertySetMapper();

    aStEx.exportStyleFamily(XML_STYLE_FAMILY_SD_GRAPHICS_NAME, XML_STYLE_FAMILY_SD_GRAPHICS_NAME,
        aMapperRef, FALSE, XML_STYLE_FAMILY_SD_GRAPHICS_ID);
}

//////////////////////////////////////////////////////////////////////////////

BOOL SdXMLExport::ImpPrepAutoLayoutInfo(const uno::Reference<drawing::XDrawPage>& xPage, OUString& rName)
{
    rName = OUString();
    BOOL bRetval(FALSE);

    uno::Reference <beans::XPropertySet> xPropSet(xPage, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        sal_uInt16 nType;
        uno::Any aAny;

        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Layout")));
        if(aAny >>= nType)
        {
            if(ImpXMLAutoLayoutInfo::IsCreateNecessary(nType))
            {
                ImpXMLEXPPageMasterInfo* pInfo = 0L;

                // get master-page info
                uno::Reference < drawing::XMasterPageTarget > xMasterPageInt(xPage, uno::UNO_QUERY);
                if(xMasterPageInt.is())
                {
                    uno::Reference<drawing::XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
                    if(xUsedMasterPage.is())
                    {
                        uno::Reference < container::XNamed > xMasterNamed(xUsedMasterPage, uno::UNO_QUERY);
                        if(xMasterNamed.is())
                        {
                            OUString sMasterPageName = xMasterNamed->getName();
                            pInfo = ImpGetPageMasterInfoByName(sMasterPageName);
                        }
                    }
                }

                // create entry and look for existance
                ImpXMLAutoLayoutInfo* pNew = new ImpXMLAutoLayoutInfo(nType, pInfo);
                BOOL bDidExist(FALSE);

                for(sal_uInt32 nCnt = 0L; !bDidExist && nCnt < mpAutoLayoutInfoList->Count(); nCnt++)
                {
                    if(*mpAutoLayoutInfoList->GetObject(nCnt) == *pNew)
                    {
                        delete pNew;
                        pNew = mpAutoLayoutInfoList->GetObject(nCnt);
                        bDidExist = TRUE;
                    }
                }

                if(!bDidExist)
                {
                    mpAutoLayoutInfoList->Insert(pNew, LIST_APPEND);
                    OUString sNewName = OUString(RTL_CONSTASCII_USTRINGPARAM("AL"));
                    sNewName += OUString::valueOf(sal_Int32(mpAutoLayoutInfoList->Count() - 1));
                    sNewName += OUString(RTL_CONSTASCII_USTRINGPARAM("T"));
                    sNewName += OUString::valueOf(sal_Int32(nType));
                    pNew->SetLayoutName(sNewName);
                }

                rName = pNew->GetLayoutName();
                bRetval = TRUE;
            }
        }
    }

    return bRetval;
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpWriteAutoLayoutInfos()
{
    if(mpAutoLayoutInfoList->Count())
    {
        for(sal_uInt32 nCnt = 0L; nCnt < mpAutoLayoutInfoList->Count(); nCnt++)
        {
            ImpXMLAutoLayoutInfo* pInfo = mpAutoLayoutInfoList->GetObject(nCnt);
            if(pInfo)
            {
                // prepare presentation-page layout attributes, style-name
                AddAttribute(XML_NAMESPACE_STYLE, sXML_name, pInfo->GetLayoutName());

                // write draw-style attributes
                SvXMLElementExport aDSE(*this, XML_NAMESPACE_STYLE, sXML_presentation_page_layout, sal_True, sal_True);

                // write presentation placeholders
                switch(pInfo->GetLayoutType())
                {
                    case 0 : // AUTOLAYOUT_TITLE
                    {
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderSubtitle, pInfo->GetPresRectangle());
                        break;
                    }
                    case 1 : // AUTOLAYOUT_ENUM
                    {
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, pInfo->GetPresRectangle());
                        break;
                    }
                    case 2 : // AUTOLAYOUT_CHART
                    {
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, pInfo->GetPresRectangle());
                        break;
                    }
                    case 3 : // AUTOLAYOUT_2TEXT
                    {
                        Rectangle aLeft(pInfo->GetPresRectangle());
                        aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
                        Rectangle aRight(aLeft);
                        aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
                        break;
                    }
                    case 4 : // AUTOLAYOUT_TEXTCHART
                    {
                        Rectangle aLeft(pInfo->GetPresRectangle());
                        aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
                        Rectangle aRight(aLeft);
                        aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aRight);
                        break;
                    }
                    case 6 : // AUTOLAYOUT_TEXTCLIP
                    {
                        Rectangle aLeft(pInfo->GetPresRectangle());
                        aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
                        Rectangle aRight(aLeft);
                        aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aRight);
                        break;
                    }
                    case 7 : // AUTOLAYOUT_CHARTTEXT
                    {
                        Rectangle aLeft(pInfo->GetPresRectangle());
                        aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
                        Rectangle aRight(aLeft);
                        aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aLeft);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
                        break;
                    }
                    case 8 : // AUTOLAYOUT_TAB
                    {
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTable, pInfo->GetPresRectangle());
                        break;
                    }
                    case 9 : // AUTOLAYOUT_CLIPTEXT
                    {
                        Rectangle aLeft(pInfo->GetPresRectangle());
                        aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
                        Rectangle aRight(aLeft);
                        aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aLeft);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
                        break;
                    }
                    case 10 : // AUTOLAYOUT_TEXTOBJ
                    {
                        Rectangle aLeft(pInfo->GetPresRectangle());
                        aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
                        Rectangle aRight(aLeft);
                        aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRight);
                        break;
                    }
                    case 11 : // AUTOLAYOUT_OBJ
                    {
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, pInfo->GetPresRectangle());
                        break;
                    }
                    case 12 : // AUTOLAYOUT_TEXT2OBJ
                    {
                        Rectangle aLeft(pInfo->GetPresRectangle());
                        aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
                        Rectangle aRightTop(aLeft);
                        aRightTop.Left() = long(aRightTop.Left() + aRightTop.GetWidth() * 1.05);
                        aRightTop.setHeight(long(aRightTop.GetHeight() * 0.477));
                        Rectangle aRightBottom(aRightTop);
                        aRightBottom.Top() = long(aRightBottom.Top() + aRightBottom.GetHeight() * 1.095);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aLeft);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRightTop);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aRightBottom);
                        break;
                    }
                    case 13 : // AUTOLAYOUT_OBJTEXT
                    {
                        Rectangle aLeft(pInfo->GetPresRectangle());
                        aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
                        Rectangle aRight(aLeft);
                        aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeft);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
                        break;
                    }
                    case 14 : // AUTOLAYOUT_OBJOVERTEXT
                    {
                        Rectangle aTop(pInfo->GetPresRectangle());
                        aTop.setHeight(long(aTop.GetHeight() * 0.477));
                        Rectangle aBottom(aTop);
                        aBottom.Top() = long(aBottom.Top() + aBottom.GetHeight() * 1.095);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTop);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aBottom);
                        break;
                    }
                    case 15 : // AUTOLAYOUT_2OBJTEXT
                    {
                        Rectangle aLeftTop(pInfo->GetPresRectangle());
                        aLeftTop.setWidth(long(aLeftTop.GetWidth() * 0.488));
                        Rectangle aRight(aLeftTop);
                        aRight.Left() = long(aRight.Left() + aRight.GetWidth() * 1.05);
                        aLeftTop.setHeight(long(aLeftTop.GetHeight() * 0.477));
                        Rectangle aLeftBottom(aLeftTop);
                        aLeftBottom.Top() = long(aLeftBottom.Top() + aLeftBottom.GetHeight() * 1.095);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeftTop);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aLeftBottom);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aRight);
                        break;
                    }
                    case 16 : // AUTOLAYOUT_2OBJOVERTEXT
                    {
                        Rectangle aTopLeft(pInfo->GetPresRectangle());
                        aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
                        Rectangle aBottom(aTopLeft);
                        aBottom.Top() = long(aBottom.Top() + aBottom.GetHeight() * 1.095);
                        aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.488));
                        Rectangle aTopRight(aTopLeft);
                        aTopRight.Left() = long(aTopRight.Left() + aTopRight.GetWidth() * 1.05);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopLeft);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopRight);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aBottom);
                        break;
                    }
                    case 17 : // AUTOLAYOUT_TEXTOVEROBJ
                    {
                        Rectangle aTop(pInfo->GetPresRectangle());
                        aTop.setHeight(long(aTop.GetHeight() * 0.477));
                        Rectangle aBottom(aTop);
                        aBottom.Top() = long(aBottom.Top() + aBottom.GetHeight() * 1.095);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aTop);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottom);
                        break;
                    }
                    case 18 : // AUTOLAYOUT_4OBJ
                    {
                        Rectangle aTopLeft(pInfo->GetPresRectangle());
                        aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
                        aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.488));
                        Rectangle aBottomLeft(aTopLeft);
                        aBottomLeft.Top() = long(aBottomLeft.Top() + aBottomLeft.GetHeight() * 1.095);
                        Rectangle aTopRight(aTopLeft);
                        aTopRight.Left() = long(aTopRight.Left() + aTopRight.GetWidth() * 1.05);
                        Rectangle aBottomRight(aTopRight);
                        aBottomRight.Top() = long(aBottomRight.Top() + aBottomRight.GetHeight() * 1.095);

                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopLeft);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aTopRight);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottomLeft);
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottomRight);
                        break;
                    }
                    case 19 : // AUTOLAYOUT_ONLY_TITLE
                    {
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                        break;
                    }
                    case 21 : // AUTOLAYOUT_NOTES
                    {
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderPage, pInfo->GetTitleRectangle());
                        ImpWriteAutoLayoutPlaceholder(XmlPlaceholderNotes, pInfo->GetPresRectangle());
                        break;
                    }
                    case 22 : // AUTOLAYOUT_HANDOUT1
                    case 23 : // AUTOLAYOUT_HANDOUT2
                    case 24 : // AUTOLAYOUT_HANDOUT3
                    case 25 : // AUTOLAYOUT_HANDOUT4
                    case 26 : // AUTOLAYOUT_HANDOUT6
                    {
                        sal_Int32 nColCnt, nRowCnt;
                        sal_Int32 nGapX = pInfo->GetGapX();
                        sal_Int32 nGapY = pInfo->GetGapY();

                        switch(pInfo->GetLayoutType())
                        {
                            case 22 : nColCnt = 1; nRowCnt = 1; break;
                            case 23 : nColCnt = 1; nRowCnt = 2; break;
                            case 24 : nColCnt = 1; nRowCnt = 3; break;
                            case 25 : nColCnt = 2; nRowCnt = 2; break;
                            case 26 : nColCnt = 3; nRowCnt = 3; break;
                        }

                        Size aPartSize(pInfo->GetTitleRectangle().GetSize());
                        Point aPartPos(pInfo->GetTitleRectangle().TopLeft());

                        if(aPartSize.Width() > aPartSize.Height())
                        {
                            sal_Int32 nZwi(nColCnt);
                            nColCnt = nRowCnt;
                            nRowCnt = nZwi;
                        }

                        aPartSize.Width() = (aPartSize.Width() - ((nColCnt - 1) * nGapX)) / nColCnt;
                        aPartSize.Height() = (aPartSize.Height() - ((nRowCnt - 1) * nGapY)) / nRowCnt;

                        Point aTmpPos(aPartPos);

                        for(sal_Int32 a = 0L; a < nRowCnt; a++)
                        {
                            aTmpPos.X() = aPartPos.X();

                            for(sal_Int32 b = 0L; b < nColCnt; b++)
                            {
                                Rectangle aTmpRect(aTmpPos, aPartSize);

                                ImpWriteAutoLayoutPlaceholder(XmlPlaceholderHandout, aTmpRect);
                                aTmpPos.X() += aPartSize.Width() + nGapX;
                            }

                            aTmpPos.Y() += aPartSize.Height() + nGapY;
                        }
                        break;
                    }
                    default:
                    {
                        DBG_ERROR("XMLEXP: unknown autolayout export");
                        break;
                    }
                }
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpWriteAutoLayoutPlaceholder(XmlPlaceholder ePl, const Rectangle& rRect)
{
    OUString aStr;
    OUStringBuffer sStringBuffer;

    // prepare presentation-placeholder attributes, presentation:object
    switch(ePl)
    {
        case XmlPlaceholderTitle: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("title")); break;
        case XmlPlaceholderOutline: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("outline")); break;
        case XmlPlaceholderSubtitle: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("subtitle")); break;
        case XmlPlaceholderText: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("text")); break;
        case XmlPlaceholderGraphic: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("graphic")); break;
        case XmlPlaceholderObject: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("object")); break;
        case XmlPlaceholderChart: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("chart")); break;
        case XmlPlaceholderOrgchart: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("orgchart")); break;
        case XmlPlaceholderTable: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("table")); break;
        case XmlPlaceholderPage: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("page")); break;
        case XmlPlaceholderNotes: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("notes")); break;
        case XmlPlaceholderHandout: aStr = OUString(RTL_CONSTASCII_USTRINGPARAM("handout")); break;
    }

    AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_object, aStr);

    // svg:x,y,width,height
    GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.Left());
    aStr = sStringBuffer.makeStringAndClear();
    AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr);

    GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.Top());
    aStr = sStringBuffer.makeStringAndClear();
    AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr);

    GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.GetWidth());
    aStr = sStringBuffer.makeStringAndClear();
    AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr);

    GetMM100UnitConverter().convertMeasure(sStringBuffer, rRect.GetHeight());
    aStr = sStringBuffer.makeStringAndClear();
    AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr);

    // write presentation-placeholder
    SvXMLElementExport aPPL(*this, XML_NAMESPACE_PRESENTATION, sXML_placeholder, sal_True, sal_True);
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpPrepPageMasterInfos()
{
    if(mnDocMasterPageCount)
    {
        // look for needed page-masters, create these
        for(sal_Int32 nMPageId = 0L; nMPageId < mnDocMasterPageCount; nMPageId++)
        {
            uno::Any aAny(mxDocMasterPages->getByIndex(nMPageId));
            uno::Reference< drawing::XDrawPage > xMasterPage;
            ImpXMLEXPPageMasterInfo* pNewInfo = 0L;
            BOOL bDoesExist(FALSE);

            if(aAny >>= xMasterPage)
            {
                pNewInfo = new ImpXMLEXPPageMasterInfo(*this, xMasterPage);

                // compare with prev page-master infos
                for(sal_uInt32 a = 0; !bDoesExist && a < mpPageMasterInfoList->Count(); a++)
                {
                    if(mpPageMasterInfoList->GetObject(a)
                        && *mpPageMasterInfoList->GetObject(a) == *pNewInfo)
                    {
                        delete pNewInfo;
                        pNewInfo = mpPageMasterInfoList->GetObject(a);
                        bDoesExist = TRUE;
                    }
                }
            }

            // add entry when not found same page-master infos
            if(!bDoesExist)
                mpPageMasterInfoList->Insert(pNewInfo, LIST_APPEND);
            mpPageMaterUsageList->Insert(pNewInfo, LIST_APPEND);
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpWritePageMasterInfos()
{
    // write created page-masters, create names for these
    for(sal_uInt32 nCnt = 0L; nCnt < mpPageMasterInfoList->Count(); nCnt++)
    {
        ImpXMLEXPPageMasterInfo* pInfo = mpPageMasterInfoList->GetObject(nCnt);
        if(pInfo)
        {
            // create name
            OUString sNewName = OUString(RTL_CONSTASCII_USTRINGPARAM("PM"));

            sNewName += OUString::valueOf((sal_Int32)nCnt);
            pInfo->SetName(sNewName);

            // prepare page-master attributes
            OUString sString;
            OUStringBuffer sStringBuffer;

            sString = sNewName;
            AddAttribute(XML_NAMESPACE_STYLE, sXML_name, sString);

            // write page-master
            SvXMLElementExport aPME(*this, XML_NAMESPACE_STYLE, sXML_page_master, sal_True, sal_True);

            // prepare style:properties inside page-master
            GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderTop());
            sString = sStringBuffer.makeStringAndClear();
            AddAttribute(XML_NAMESPACE_FO, sXML_margin_top, sString);

            GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderBottom());
            sString = sStringBuffer.makeStringAndClear();
            AddAttribute(XML_NAMESPACE_FO, sXML_margin_bottom, sString);

            GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderLeft());
            sString = sStringBuffer.makeStringAndClear();
            AddAttribute(XML_NAMESPACE_FO, sXML_margin_left, sString);

            GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetBorderRight());
            sString = sStringBuffer.makeStringAndClear();
            AddAttribute(XML_NAMESPACE_FO, sXML_margin_right, sString);

            GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetWidth());
            sString = sStringBuffer.makeStringAndClear();
            AddAttribute(XML_NAMESPACE_FO, sXML_page_width, sString);

            GetMM100UnitConverter().convertMeasure(sStringBuffer, pInfo->GetHeight());
            sString = sStringBuffer.makeStringAndClear();
            AddAttribute(XML_NAMESPACE_FO, sXML_page_height, sString);

            if(pInfo->GetOrientation() == view::PaperOrientation_PORTRAIT)
                AddAttributeASCII(XML_NAMESPACE_STYLE, sXML_print_orientation, sXML_portrait);
            else
                AddAttributeASCII(XML_NAMESPACE_STYLE, sXML_print_orientation, sXML_landscape);

            // write style:properties
            SvXMLElementExport aPMF(*this, XML_NAMESPACE_STYLE, sXML_properties, sal_True, sal_True);
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

ImpXMLEXPPageMasterInfo* SdXMLExport::ImpGetPageMasterInfoByName(const OUString& rName)
{
    if(rName.getLength() && mpPageMasterInfoList->Count())
    {
        for(sal_uInt32 nCnt = 0L; nCnt < mpPageMasterInfoList->Count(); nCnt++)
        {
            ImpXMLEXPPageMasterInfo* pInfo = mpPageMasterInfoList->GetObject(nCnt);
            if(pInfo)
            {
                if(pInfo->GetMasterPageName().getLength() && rName.equals(pInfo->GetMasterPageName()))
                {
                    return pInfo;
                }
            }
        }
    }
    return 0L;
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpPrepDrawPageInfos()
{
    // create draw:style-name entries for page export
    // containing presentation page attributes AND background attributes
    // fixed family for page-styles is "drawing-page" (XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME)
    if(mnDocDrawPageCount)
    {
        // prepare name creation
        for(sal_Int32 nCnt = 0L; nCnt < mnDocDrawPageCount; nCnt++)
        {
            uno::Any aAny(mxDocDrawPages->getByIndex(nCnt));
            uno::Reference<drawing::XDrawPage> xDrawPage;

            if(aAny >>= xDrawPage)
            {
                // create name
                OUString sStyleName;

                // create style for this page and add to auto style pool

                uno::Reference< beans::XPropertySet > xPropSet1(xDrawPage, uno::UNO_QUERY);
                if(xPropSet1.is())
                {
                    // since the background items are in a different propertyset
                    // which itself is a property of the pages property set
                    // we now merge these two propertysets if possible to simulate
                    // a single propertyset with all draw page properties
                    const OUString aBackground(RTL_CONSTASCII_USTRINGPARAM("Background"));
                    uno::Reference< beans::XPropertySet > xPropSet2;
                    uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet1->getPropertySetInfo() );
                    if( xInfo.is() && xInfo->hasPropertyByName( aBackground ) )
                    {
                        uno::Any aAny( xPropSet1->getPropertyValue( aBackground ) );
                        aAny >>= xPropSet2;
                    }

                    uno::Reference< beans::XPropertySet > xPropSet;
                    if( xPropSet2.is() )
                        xPropSet = PropertySetMerger_CreateInstance( xPropSet1, xPropSet2 );
                    else
                        xPropSet = xPropSet1;

                    const UniReference< SvXMLExportPropertyMapper > aMapperRef( GetPresPagePropsMapper() );
                    std::vector< XMLPropertyState > xPropStates( aMapperRef->Filter( xPropSet ) );

                    if( !xPropStates.empty() )
                    {
                        // there are filtered properties -> hard attributes
                        // try to find this style in AutoStylePool
                        sStyleName = GetAutoStylePool()->Find(XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID, sStyleName, xPropStates);

                        if(!sStyleName.getLength())
                        {
                            // Style did not exist, add it to AutoStalePool
                            sStyleName = GetAutoStylePool()->Add(XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID, sStyleName, xPropStates);
                        }
                    }
                }

                // create Info object
                ImpXMLDrawPageInfo* pInfo = new ImpXMLDrawPageInfo(sStyleName);
                mpDrawPageInfoList->Insert(pInfo, LIST_APPEND);

                if(IsImpress())
                {
                    // create presentation-page-layout
                    OUString aStr;

                    if(ImpPrepAutoLayoutInfo(xDrawPage, aStr))
                    {
                        pInfo->SetPageLayoutName(aStr);
                    }
                }
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpPrepMasterPageInfos()
{
    // create draw:style-name entries for master page export
    // containing only background attributes
    // fixed family for page-styles is "drawing-page" (XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME)
    if(mnDocMasterPageCount)
    {
        // prepare name creation
        for(sal_Int32 nCnt = 0L; nCnt < mnDocMasterPageCount; nCnt++)
        {
            uno::Any aAny(mxDocMasterPages->getByIndex(nCnt));
            uno::Reference<drawing::XDrawPage> xDrawPage;

            if(aAny >>= xDrawPage)
            {
                // create name
                OUString sStyleName;

                // create style for this page and add to auto style pool
                uno::Reference< beans::XPropertySet > xPropSet1(xDrawPage, uno::UNO_QUERY);
                if(xPropSet1.is())
                {
                    // since the background items are in a different propertyset
                    // which itself is a property of the pages property set
                    // we now merge these two propertysets if possible to simulate
                    // a single propertyset with all draw page properties
                    const OUString aBackground(RTL_CONSTASCII_USTRINGPARAM("Background"));
                    uno::Reference< beans::XPropertySet > xPropSet2;
                    uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet1->getPropertySetInfo() );
                    if( xInfo.is() && xInfo->hasPropertyByName( aBackground ) )
                    {
                        uno::Any aAny( xPropSet1->getPropertyValue( aBackground ) );
                        aAny >>= xPropSet2;
                    }

                    if( xPropSet2.is() )
                    {
                        const UniReference< SvXMLExportPropertyMapper > aMapperRef( GetPresPagePropsMapper() );
                        std::vector< XMLPropertyState > xPropStates( aMapperRef->Filter( xPropSet2 ) );

                        if( !xPropStates.empty() )
                        {
                            // there are filtered properties -> hard attributes
                            // try to find this style in AutoStylePool
                            sStyleName = GetAutoStylePool()->Find(XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID, sStyleName, xPropStates);

                            if(!sStyleName.getLength())
                            {
                                // Style did not exist, add it to AutoStalePool
                                sStyleName = GetAutoStylePool()->Add(XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID, sStyleName, xPropStates);
                            }
                        }
                    }
                }

                // create Info object
                ImpXMLDrawPageInfo* pInfo = new ImpXMLDrawPageInfo(sStyleName);
                mpMasterPageInfoList->Insert(pInfo, LIST_APPEND);
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////
void SdXMLExport::ImpWritePresentationStyles()
{
    if(IsImpress())
    {
        for(sal_Int32 nCnt = 0L; nCnt < mnDocMasterPageCount; nCnt++)
        {
            uno::Any aAny(mxDocMasterPages->getByIndex(nCnt));
            uno::Reference<container::XNamed> xNamed;

            if(aAny >>= xNamed)
            {
                // write presentation styles (ONLY if presentation)
                if(IsImpress() && mxDocStyleFamilies.is() && xNamed.is())
                {
                    XMLStyleExport aStEx(*this,
                        OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_drawpool)), GetAutoStylePool().get());
                    const UniReference< SvXMLExportPropertyMapper > aMapperRef( GetPropertySetMapper() );

                    OUString aPrefix = xNamed->getName();
                    aPrefix += OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
                    aStEx.exportStyleFamily(xNamed->getName(),
                        XML_STYLE_FAMILY_SD_PRESENTATION_NAME, aMapperRef, FALSE,
                        XML_STYLE_FAMILY_SD_PRESENTATION_ID, &aPrefix);
                }
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::SetProgress(sal_Int32 nProg)
{
    // set progress view
    if(mxStatusIndicator.is())
        mxStatusIndicator->setValue(nProg);
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::_ExportContent()
{
    // page export
    for(sal_Int32 nPageInd(0); nPageInd < mnDocDrawPageCount; nPageInd++)
    {
        uno::Any aAny(mxDocDrawPages->getByIndex(nPageInd));
        uno::Reference<drawing::XDrawPage> xDrawPage;

        SetProgress(((nPageInd + 1) * 100) / mnDocDrawPageCount);

        if(aAny >>= xDrawPage)
        {
            // prepare page attributes, name of page
            uno::Reference < container::XNamed > xNamed(xDrawPage, uno::UNO_QUERY);
            if(xNamed.is())
                AddAttribute(XML_NAMESPACE_DRAW, sXML_name, xNamed->getName());

            // draw:style-name (presentation page attributes AND background attributes)
            ImpXMLDrawPageInfo* pInfo = mpDrawPageInfoList->GetObject(nPageInd);
            if(pInfo)
            {
                OUString sString = pInfo->GetStyleName();
                if( sString.getLength() )
                    AddAttribute(XML_NAMESPACE_DRAW, sXML_style_name, sString);
            }

            // draw:master-page-name
            uno::Reference < drawing::XMasterPageTarget > xMasterPageInt(xDrawPage, uno::UNO_QUERY);
            if(xMasterPageInt.is())
            {
                uno::Reference<drawing::XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
                if(xUsedMasterPage.is())
                {
                    uno::Reference < container::XNamed > xMasterNamed(xUsedMasterPage, uno::UNO_QUERY);
                    if(xMasterNamed.is())
                    {
                        AddAttribute(XML_NAMESPACE_DRAW, sXML_master_page_name, xMasterNamed->getName());
                    }
                }
            }

            // presentation:page-layout-name
            if(pInfo && IsImpress() && pInfo->GetPageLayoutName().getLength())
            {
                OUString sString = pInfo->GetPageLayoutName();
                AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_presentation_page_layout_name, sString);
            }

            // write page
            SvXMLElementExport aDPG(*this, XML_NAMESPACE_DRAW, sXML_page, sal_True, sal_True);

            // write graphic objects on this page (if any)
            uno::Reference< container::XIndexAccess > xShapes(xDrawPage, uno::UNO_QUERY);
            if(xShapes.is() && xShapes->getCount())
            {
                // write shapes per se
                ImpWriteSingleShapeStyleInfos(xShapes);
            }

            // write presentation notes (ONLY if presentation)
            if(IsImpress())
            {
                uno::Reference< presentation::XPresentationPage > xPresPage(xDrawPage, uno::UNO_QUERY);
                if(xPresPage.is())
                {
                    uno::Reference< drawing::XDrawPage > xNotesPage(xPresPage->getNotesPage());
                    if(xNotesPage.is())
                    {
                        uno::Reference< container::XIndexAccess > xShapes(xNotesPage, uno::UNO_QUERY);
                        if(xShapes.is() && xShapes->getCount())
                        {
                            // write presentation notes
                            SvXMLElementExport aPSY(*this, XML_NAMESPACE_PRESENTATION, sXML_notes, sal_True, sal_True);

                            // write shapes per se
                            ImpWriteSingleShapeStyleInfos(xShapes);
                        }
                    }
                }
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportTextBoxShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ )
{
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );

        SdXMLImExTransform2D aTransform;
        OUString aStr;
        OUStringBuffer sStringBuffer;

        // presentation attribute (if presentation)
        sal_Bool bIsPresShape(FALSE);
        sal_Bool bIsEmptyPresObj(FALSE);
        sal_Bool bIsPlaceholderDependant(TRUE);

        switch(eShapeType)
        {
            case XmlShapeTypePresSubtitleShape:
            {
                aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_subtitle));
                bIsPresShape = TRUE;
                break;
            }
            case XmlShapeTypePresTitleTextShape:
            {
                aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_title));
                bIsPresShape = TRUE;
                break;
            }
            case XmlShapeTypePresOutlinerShape:
            {
                aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_outline));
                bIsPresShape = TRUE;
                break;
            }
            case XmlShapeTypePresNotesShape:
            {
                aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_notes));
                bIsPresShape = TRUE;
                break;
            }
        }

        if(bIsPresShape)
        {
            // is empty pes shape?
            if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))))
            {
                uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))) );
                aAny >>= bIsEmptyPresObj;
            }

            // is user-transformed?
            if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent"))))
            {
                uno::Any aAny( xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent"))) );
                aAny >>= bIsPlaceholderDependant;
            }

            // write presentation class entry
            rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class, aStr);

            // write presentation placeholder entry
            if(bIsEmptyPresObj)
                rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_placeholder,
                OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true)));

            // write user-transformed entry
            if(!bIsPlaceholderDependant)
                rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_user_transformed,
                OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true)));
        }

        // text shape, prepare parameters
        awt::Point aPoint( xShape->getPosition() );
        if( pRefPoint )
        {
            aPoint.X -= pRefPoint->X;
            aPoint.Y -= pRefPoint->Y;
        }

        awt::Size aSize( xShape->getSize() );

        if( nFeatures & SEF_EXPORT_X )
        {
            // svg: x
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr);
        }

        if( nFeatures & SEF_EXPORT_Y )
        {
            // svg: y
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr);
        }

        if( nFeatures & SEF_EXPORT_WIDTH )
        {
            // svg: width
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr);
        }

        if( nFeatures & SEF_EXPORT_HEIGHT )
        {
            // svg: height
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr);
        }

        // evtl. rotation (100'th degree, part of transformation)?
        sal_Int32 nRotAngle(0L);
        uno::Any aAny = xPropSet->getPropertyValue(
            OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle")));
        aAny >>= nRotAngle;
        if(nRotAngle)
            aTransform.AddRotate(nRotAngle / 100.0);

        // does transformation need to be exported?
        if(aTransform.NeedsAction())
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter()));

        // write text-box
        SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_text_box, sal_True, sal_True);

        // export text
        if(!bIsEmptyPresObj)
        {
            uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
            if( xText.is() )
                rExp.GetTextParagraphExport()->exportText( xText );
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportRectangleShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /*= SEF_DEFAULT */,    com::sun::star::awt::Point* pRefPoint /* = NULL */ )
{
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        SdXMLImExTransform2D aTransform;
        OUString aStr;
        OUStringBuffer sStringBuffer;

        // rectangle, prepare parameters
        awt::Point aPoint = xShape->getPosition();
        if( pRefPoint )
        {
            aPoint.X -= pRefPoint->X;
            aPoint.Y -= pRefPoint->Y;
        }

        awt::Size aSize = xShape->getSize();

        if( nFeatures & SEF_EXPORT_X )
        {
            // svg: x
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr);
        }

        if( nFeatures & SEF_EXPORT_Y )
        {
            // svg: y
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr);
        }

        if( nFeatures & SEF_EXPORT_WIDTH )
        {
            // svg: width
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr);
        }

        if( nFeatures & SEF_EXPORT_HEIGHT )
        {
            // svg: height
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr);
        }

        // evtl. rotation (100'th degree, part of transformation)?
        sal_Int32 nRotAngle(0L);
        uno::Any aAny = xPropSet->getPropertyValue(
            OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle")));
        aAny >>= nRotAngle;
        if(nRotAngle)
            aTransform.AddRotate(nRotAngle / 100.0);

        // does transformation need to be exported?
        if(aTransform.NeedsAction())
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter()));

        // evtl. corner radius?
        sal_Int32 nCornerRadius(0L);
        aAny = xPropSet->getPropertyValue(
            OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")));
        aAny >>= nCornerRadius;
        if(nCornerRadius)
        {
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nCornerRadius);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_corner_radius, aStr);
        }

        // write rectangle
        SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_rect, sal_True, sal_True);

        // export text
        uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
        if( xText.is() )
            rExp.GetTextParagraphExport()->exportText( xText );
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportLineShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ )
{
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        SdXMLImExTransform2D aTransform;
        OUString aStr;
        OUStringBuffer sStringBuffer;
        awt::Point aStart(0,0);
        awt::Point aEnd(1,1);

        drawing::PointSequenceSequence* pSourcePolyPolygon = 0L;
        uno::Any aAny = xPropSet->getPropertyValue(
            OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygon")));
        pSourcePolyPolygon = (drawing::PointSequenceSequence*)aAny.getValue();

        if(pSourcePolyPolygon)
        {
            drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray();
            if(pOuterSequence)
            {
                drawing::PointSequence* pInnerSequence = pOuterSequence++;
                if(pInnerSequence)
                {
                    awt::Point* pArray = pInnerSequence->getArray();
                    if(pArray)
                    {
                        if(pInnerSequence->getLength() > 0)
                        {
                            aStart = awt::Point(pArray->X, pArray->Y);
                            pArray++;
                        }

                        if(pInnerSequence->getLength() > 1)
                        {
                            aEnd = awt::Point(pArray->X, pArray->Y);
                        }
                    }
                }
            }
        }

        if( pRefPoint )
        {
            aStart.X -= pRefPoint->X;
            aStart.Y -= pRefPoint->Y;
            aEnd.X -= pRefPoint->X;
            aEnd.Y -= pRefPoint->Y;
        }

        // svg: x1
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x1, aStr);

        // svg: y1
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y1, aStr);

        // svg: x2
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x2, aStr);

        // svg: y2
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y2, aStr);

        // evtl. rotation (100'th degree, part of transformation)?
        sal_Int32 nRotAngle(0L);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle")));
        aAny >>= nRotAngle;
        if(nRotAngle)
            aTransform.AddRotate(nRotAngle / 100.0);

        // does transformation need to be exported?
        if(aTransform.NeedsAction())
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter()));

        // write line
        SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_line, sal_True, sal_True);

        // export text
        uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
        if( xText.is() )
            rExp.GetTextParagraphExport()->exportText( xText );
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportEllipseShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        SdXMLImExTransform2D aTransform;
        // get size to decide between Circle and Ellipse
        awt::Point aPoint = xShape->getPosition();
        if( pRefPoint )
        {
            aPoint.X -= pRefPoint->X;
            aPoint.Y -= pRefPoint->Y;
        }

        awt::Size aSize = xShape->getSize();
        sal_Int32 nRx((aSize.Width + 1) / 2);
        sal_Int32 nRy((aSize.Height + 1) / 2);
        BOOL bCircle(nRx == nRy);
        OUString aStr;
        OUStringBuffer sStringBuffer;

        if( nFeatures & SEF_EXPORT_X )
        {
            // svg: cx
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X + nRx);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_cx, aStr);
        }

        if( nFeatures & SEF_EXPORT_Y )
        {
            // svg: cy
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y + nRy);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_cy, aStr);
        }

        // evtl. rotation (100'th degree, part of transformation)?
        sal_Int32 nRotAngle(0L);
        uno::Any aAny = xPropSet->getPropertyValue(
            OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle")));
        aAny >>= nRotAngle;
        if(nRotAngle)
            aTransform.AddRotate(nRotAngle / 100.0);

        // does transformation need to be exported?
        if(aTransform.NeedsAction())
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter()));

        if(bCircle)
        {
            // svg: r
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nRx);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_r, aStr);

            // write circle
            SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_circle, sal_True, sal_True);

            // export text
            uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
            if( xText.is() )
                rExp.GetTextParagraphExport()->exportText( xText );
        }
        else
        {
            // svg: rx
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nRx);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_rx, aStr);

            // svg: ry
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nRy);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_ry, aStr);

            // write ellipse
            SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_ellipse, sal_True, sal_True);

            // export text
            uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
            if( xText.is() )
                rExp.GetTextParagraphExport()->exportText( xText );
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportPolygonShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        BOOL bClosed(eShapeType == XmlShapeTypeDrawPolyPolygonShape
            || eShapeType == XmlShapeTypeDrawClosedBezierShape);
        BOOL bBezier(eShapeType == XmlShapeTypeDrawClosedBezierShape
            || eShapeType == XmlShapeTypeDrawOpenBezierShape);
        SdXMLImExTransform2D aTransform;
        OUString aStr;
        OUStringBuffer sStringBuffer;

        // prepare posistion and size parameters
        awt::Point aPoint = xShape->getPosition();
        if( pRefPoint )
        {
            aPoint.X -= pRefPoint->X;
            aPoint.Y -= pRefPoint->Y;
        }

        awt::Size aSize = xShape->getSize();

        if( nFeatures & SEF_EXPORT_X )
        {
            // svg: x
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr);
        }

        if( nFeatures & SEF_EXPORT_Y )
        {
            // svg: y
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr);
        }

        // svg: width
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr);

        // svg: height
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr);

        // evtl. rotation (100'th degree, part of transformation)?
        sal_Int32 nRotAngle(0L);
        uno::Any aAny = xPropSet->getPropertyValue(
            OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle")));
        aAny >>= nRotAngle;
        if(nRotAngle)
            aTransform.AddRotate(nRotAngle / 100.0);

        // does transformation need to be exported?
        if(aTransform.NeedsAction())
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter()));

        // create and export ViewBox
        SdXMLImExViewBox aViewBox(0, 0, aSize.Width, aSize.Height);
        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_viewBox, aViewBox.GetExportString(rExp.GetMM100UnitConverter()));


        if(bBezier)
        {
            // get PolygonBezier
            aAny = xPropSet->getPropertyValue(
                OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier")));
            drawing::PolyPolygonBezierCoords* pSourcePolyPolygon =
                (drawing::PolyPolygonBezierCoords*)aAny.getValue();

            if(pSourcePolyPolygon && pSourcePolyPolygon->Coordinates.getLength())
            {
                sal_Int32 nOuterCnt(pSourcePolyPolygon->Coordinates.getLength());
                drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->Coordinates.getArray();
                drawing::FlagSequence*  pOuterFlags = pSourcePolyPolygon->Flags.getArray();

                if(pOuterSequence && pOuterFlags)
                {
                    // prepare svx:d element export
                    SdXMLImExSvgDElement aSvgDElement(aViewBox);

                    for(sal_Int32 a(0L); a < nOuterCnt; a++)
                    {
                        drawing::PointSequence* pSequence = pOuterSequence++;
                        drawing::FlagSequence* pFlags = pOuterFlags++;

                        if(pSequence && pFlags)
                        {
                            aSvgDElement.AddPolygon(pSequence, pFlags,
                                aPoint, aSize, rExp.GetMM100UnitConverter(), bClosed);
                        }
                    }

                    // write point array
                    rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_d, aSvgDElement.GetExportString());
                }

                // write object now
                SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_path, sal_True, sal_True);

                // export text
                uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
                if( xText.is() )
                    rExp.GetTextParagraphExport()->exportText( xText );
            }
        }
        else
        {
            // get non-bezier polygon
            aAny = xPropSet->getPropertyValue(
                OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygon")));
            drawing::PointSequenceSequence* pSourcePolyPolygon =
                (drawing::PointSequenceSequence*)aAny.getValue();

            if(pSourcePolyPolygon && pSourcePolyPolygon->getLength())
            {
                sal_Int32 nOuterCnt(pSourcePolyPolygon->getLength());

                if(1L == nOuterCnt && !bBezier)
                {
                    // simple polygon shape, can be written as svg:points sequence
                    drawing::PointSequence* pSequence = pSourcePolyPolygon->getArray();
                    if(pSequence)
                    {
                        SdXMLImExPointsElement aPoints(pSequence, aViewBox, aPoint, aSize, rExp.GetMM100UnitConverter());

                        // write point array
                        rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_points, aPoints.GetExportString());
                    }

                    // write object now
                    SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW,
                        bClosed ? sXML_polygon : sXML_polyline , sal_True, sal_True);

                    // export text
                    uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
                    if( xText.is() )
                        rExp.GetTextParagraphExport()->exportText( xText );
                }
                else
                {
                    // polypolygon or bezier, needs to be written as a svg:path sequence
                    drawing::PointSequence* pOuterSequence = pSourcePolyPolygon->getArray();
                    if(pOuterSequence)
                    {
                        // prepare svx:d element export
                        SdXMLImExSvgDElement aSvgDElement(aViewBox);

                        for(sal_Int32 a(0L); a < nOuterCnt; a++)
                        {
                            drawing::PointSequence* pSequence = pOuterSequence++;
                            if(pSequence)
                            {
                                aSvgDElement.AddPolygon(pSequence, 0L, aPoint,
                                    aSize, rExp.GetMM100UnitConverter(), bClosed);
                            }
                        }

                        // write point array
                        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_d, aSvgDElement.GetExportString());
                    }

                    // write object now
                    SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_path, sal_True, sal_True);

                    // export text
                    uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
                    if( xText.is() )
                        rExp.GetTextParagraphExport()->exportText( xText );
                }
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportGraphicObjectShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        SdXMLImExTransform2D aTransform;
        OUString aStr;
        OUStringBuffer sStringBuffer;

        sal_Bool bIsEmptyPresObj = sal_False;
        uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );

        // prepare posistion and size parameters
        awt::Point aPoint = xShape->getPosition();
        if( pRefPoint )
        {
            aPoint.X -= pRefPoint->X;
            aPoint.Y -= pRefPoint->Y;
        }

        awt::Size aSize = xShape->getSize();

        if( nFeatures & SEF_EXPORT_X )
        {
            // svg: x
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr);
        }

        if( nFeatures & SEF_EXPORT_Y )
        {
            // svg: y
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr);
        }

        // svg: width
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr);

        // svg: height
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr);

        // evtl. rotation (100'th degree, part of transformation)?
        sal_Int32 nRotAngle(0L);
        uno::Any aAny = xPropSet->getPropertyValue(
            OUString(RTL_CONSTASCII_USTRINGPARAM("RotateAngle")));
        aAny >>= nRotAngle;
        if(nRotAngle)
            aTransform.AddRotate(nRotAngle / 100.0);

        // does transformation need to be exported?
        if(aTransform.NeedsAction())
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter()));

        if(eShapeType == XmlShapeTypePresGraphicObjectShape)
        {
            if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))))
            {
                uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject")));
                aAny >>= bIsEmptyPresObj;
            }

            // write presentation class entry
            rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class,
                OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_graphic)));

            // write presentation placeholder entry
            if(bIsEmptyPresObj)
                rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_placeholder,
                OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true)));
        }

        if( !bIsEmptyPresObj )
        {
            aAny = xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")));
            aAny >>= aStr;
            rExp.AddAttribute(XML_NAMESPACE_XLINK, sXML_href, rExp.AddEmbeddedGraphicObject( aStr ) );

            aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_simple));
            rExp.AddAttribute(XML_NAMESPACE_XLINK, sXML_type, aStr );

            aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_embed));
            rExp.AddAttribute(XML_NAMESPACE_XLINK, sXML_show, aStr );

            aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_onLoad));
            rExp.AddAttribute(XML_NAMESPACE_XLINK, sXML_actuate, aStr );
        }
        // write graphic object
        SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_image, sal_True, sal_True);
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportChartShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );

        sal_Bool bIsEmptyPresObj = sal_False;
        if(eShapeType == XmlShapeTypePresChartShape)
        {
            if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))))
            {
                uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject")));
                aAny >>= bIsEmptyPresObj;
            }

            // write presentation class entry
            rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class,
                OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_chart)));

            // write presentation placeholder entry
            if(bIsEmptyPresObj)
                rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_placeholder,
                OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true)));
        }

        OUString aStr;
        OUStringBuffer sStringBuffer;

        // rectangle, prepare parameters
        awt::Point aPoint( xShape->getPosition());
        if( pRefPoint )
        {
            aPoint.X -= pRefPoint->X;
            aPoint.Y -= pRefPoint->Y;
        }

        awt::Size aSize( xShape->getSize());

        if( nFeatures & SEF_EXPORT_X )
        {
            // svg: x
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr);
        }

        if( nFeatures & SEF_EXPORT_Y )
        {
            // svg: y
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr);
        }

        // svg: width
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr);

        // svg: height
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr);

        uno::Reference< chart::XChartDocument > xChartDoc;
        if( !bIsEmptyPresObj )
        {
            uno::Any aAny( xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) );
            aAny >>= xChartDoc;
        }

        if( xChartDoc.is() )
        {
            rExp.GetChartExport()->exportChart( xChartDoc, sal_False );
        }
        else
        {
            // write chart object (fake for now, replace later)
            SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_CHART, sXML_chart, sal_True, sal_True);
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportSpreadsheetShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );

        if(eShapeType == XmlShapeTypePresTableShape)
        {
            sal_Bool bIsEmptyPresObj = sal_False;

            if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))))
            {
                uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject")));
                aAny >>= bIsEmptyPresObj;
            }

            // write presentation class entry
            rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class,
                OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_table)));

            // write presentation placeholder entry
            if(bIsEmptyPresObj)
                rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_placeholder,
                OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true)));
        }

        // write spreadsheet object (fake for now, replace later)
        SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML__unknown_, sal_True, sal_True);
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportControlShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    // this is a control shape, in this place the database team
    // would have to export the control abilities. Add Export later
    SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_control, sal_True, sal_True);
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportConnectorShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );

    OUString aStr;
    OUStringBuffer sStringBuffer;

    // export connection kind
    drawing::ConnectorType eType = drawing::ConnectorType_STANDARD;
    uno::Any aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeKind")));
    aAny >>= eType;

    if( eType != drawing::ConnectorType_STANDARD )
    {
        SvXMLUnitConverter::convertEnum( sStringBuffer, (sal_uInt16)eType, aXML_ConnectionKind_EnumMap );
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_type, aStr);
    }

    // export line skew
    sal_Int32 nDelta1 = 0, nDelta2 = 0, nDelta3 = 0;

    aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta")));
    aAny >>= nDelta1;
    aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta")));
    aAny >>= nDelta2;
    aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta")));
    aAny >>= nDelta3;

    if( nDelta1 != 0 || nDelta2 != 0 || nDelta3 != 0 )
    {
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta1);
        if( nDelta2 != 0 || nDelta3 != 0 )
        {
            const char aSpace = ' ';
            sStringBuffer.appendAscii( &aSpace, 1 );
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta2);
            if( nDelta3 != 0 )
            {
                sStringBuffer.appendAscii( &aSpace, 1 );
                rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDelta3);
            }
        }

        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_line_skew, aStr);
    }

    // export start and end point
    awt::Point aStart(0,0);
    awt::Point aEnd(1,1);

    aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")));
    aAny >>= aStart;

    aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")));
    aAny >>= aEnd;

    if( pRefPoint )
    {
        aStart.X -= pRefPoint->X;
        aStart.Y -= pRefPoint->Y;
        aEnd.X -= pRefPoint->X;
        aEnd.Y -= pRefPoint->Y;
    }

    // svg: x1
    rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X);
    aStr = sStringBuffer.makeStringAndClear();
    rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x1, aStr);

    // svg: y1
    rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y);
    aStr = sStringBuffer.makeStringAndClear();
    rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y1, aStr);

    // svg: x2
    rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X);
    aStr = sStringBuffer.makeStringAndClear();
    rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x2, aStr);

    // svg: y2
    rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y);
    aStr = sStringBuffer.makeStringAndClear();
    rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y2, aStr);

    uno::Reference< drawing::XShape > xTempShape;

    // export start connection
    aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartShape") ) );
    if( aAny >>= xTempShape )
    {
        sal_Int32 nShapeId = rExp.GetShapeExport()->getShapeId( xTempShape );
        rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_start_shape, OUString::valueOf( nShapeId ));

        aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartGluePointIndex")) );
        sal_Int32 nGluePointId;
        if( aAny >>= nGluePointId )
        {
            if( nGluePointId != -1 )
            {
                rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_start_glue_point, OUString::valueOf( nGluePointId ));
            }
        }
    }

    // export end connection
    aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndShape")) );
    if( aAny >>= xTempShape )
    {
        sal_Int32 nShapeId = rExp.GetShapeExport()->getShapeId( xTempShape );
        rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_end_shape, OUString::valueOf( nShapeId ));

        aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndGluePointIndex")) );
        sal_Int32 nGluePointId;
        if( aAny >>= nGluePointId )
        {
            if( nGluePointId != -1 )
            {
                rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_end_glue_point, OUString::valueOf( nGluePointId ));
            }
        }
    }

    // write connector shape. Add Export later.
    SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_connector, sal_True, sal_True);

    // export text
    uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
    if( xText.is() )
        rExp.GetTextParagraphExport()->exportText( xText );
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportMeasureShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    uno::Reference< beans::XPropertySet > xProps( xShape, uno::UNO_QUERY );

    OUString aStr;
    OUStringBuffer sStringBuffer;

    // export start and end point
    awt::Point aStart(0,0);
    awt::Point aEnd(1,1);

    uno::Any aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")));
    aAny >>= aStart;

    aAny = xProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")));
    aAny >>= aEnd;

    if( pRefPoint )
    {
        aStart.X -= pRefPoint->X;
        aStart.Y -= pRefPoint->Y;
        aEnd.X -= pRefPoint->X;
        aEnd.Y -= pRefPoint->Y;
    }

    // svg: x1
    rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.X);
    aStr = sStringBuffer.makeStringAndClear();
    rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x1, aStr);

    // svg: y1
    rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aStart.Y);
    aStr = sStringBuffer.makeStringAndClear();
    rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y1, aStr);

    // svg: x2
    rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.X);
    aStr = sStringBuffer.makeStringAndClear();
    rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x2, aStr);

    // svg: y2
    rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aEnd.Y);
    aStr = sStringBuffer.makeStringAndClear();
    rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y2, aStr);

    // write measure shape. Add Export later.
    SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_measure, sal_True, sal_True);

    // export text
    uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
    if( xText.is() )
        rExp.GetTextParagraphExport()->exportText( xText );
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportOLE2Shape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );

        if(eShapeType == XmlShapeTypePresOLE2Shape)
        {
            sal_Bool bIsEmptyPresObj = sal_False;

            if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject"))))
            {
                uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject")));
                aAny >>= bIsEmptyPresObj;
            }

            // write presentation class entry
            rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class,
                OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_object)));

            // write presentation placeholder entry
            if(bIsEmptyPresObj)
                rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_placeholder,
                OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_true)));
        }

        // write spreadsheet object (fake for now, replace later)
        SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML__unknown_, sal_True, sal_True);
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportPageShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    OUString aStr;

    // a presentation page shape, normally used on notes pages only. If
    // it is used not as presentation shape, it may have been created with
    // copy-paste exchange between draw and impress (this IS possible...)
    if(eShapeType == XmlShapeTypePresPageShape)
    {
        rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_class,
            OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_presentation_page)));
    }

    // write Page shape
    SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_page_thumbnail, sal_True, sal_True);
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExportCaptionShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    // write Caption shape. Add export later.
    SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DRAW, sXML_caption, sal_True, sal_True);

    // export text
    uno::Reference< text::XText > xText( xShape, uno::UNO_QUERY );
    if( xText.is() )
        rExp.GetTextParagraphExport()->exportText( xText );
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExport3DShape(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */)
{
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        OUString aStr;
        OUStringBuffer sStringBuffer;

        // transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix")
        uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DTransformMatrix")));
        drawing::HomogenMatrix xHomMat;
        aAny >>= xHomMat;
        SdXMLImExTransform3D aTransform;
        aTransform.AddHomogenMatrix(xHomMat);
        if(aTransform.NeedsAction())
            rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter()));

        switch(eShapeType)
        {
            case XmlShapeTypeDraw3DCubeObject:
            {
                // write 3DCube shape
                SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DR3D, sXML_3DCube, sal_True, sal_True);

                // minEdge
                aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition")));
                drawing::Position3D aPosition3D;
                aAny >>= aPosition3D;
                Vector3D aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ);

                // maxEdge
                aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize")));
                drawing::Direction3D aDirection3D;
                aAny >>= aDirection3D;
                Vector3D aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ);

                // transform maxEdge from distance to pos
                aDir3D = aPos3D + aDir3D;

                // write minEdge
                if(aPos3D != Vector3D(-2500.0, -2500.0, -2500.0)) // write only when not default
                {
                    rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aPos3D);
                    aStr = sStringBuffer.makeStringAndClear();
                    rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_min_edge, aStr);
                }

                // write maxEdge
                if(aDir3D != Vector3D(2500.0, 2500.0, 2500.0)) // write only when not default
                {
                    rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aDir3D);
                    aStr = sStringBuffer.makeStringAndClear();
                    rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_max_edge, aStr);
                }

                break;
            }
            case XmlShapeTypeDraw3DSphereObject:
            {
                // write 3DSphere shape
                SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DR3D, sXML_3DSphere, sal_True, sal_True);

                // Center
                aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPosition")));
                drawing::Position3D aPosition3D;
                aAny >>= aPosition3D;
                Vector3D aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ);

                // Size
                aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSize")));
                drawing::Direction3D aDirection3D;
                aAny >>= aDirection3D;
                Vector3D aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ);

                // write Center
                if(aPos3D != Vector3D(0.0, 0.0, 0.0)) // write only when not default
                {
                    rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aPos3D);
                    aStr = sStringBuffer.makeStringAndClear();
                    rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_center, aStr);
                }

                // write Size
                if(aDir3D != Vector3D(5000.0, 5000.0, 5000.0)) // write only when not default
                {
                    rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aDir3D);
                    aStr = sStringBuffer.makeStringAndClear();
                    rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_size, aStr);
                }

                break;
            }
            case XmlShapeTypeDraw3DLatheObject:
            case XmlShapeTypeDraw3DExtrudeObject:
            {
                // write special 3DLathe/3DExtrude attributes
                uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DPolyPolygon3D")));
                drawing::PolyPolygonShape3D xPolyPolygon3D;
                aAny >>= xPolyPolygon3D;

                // look for maximal values
                double fXMin, fXMax, fYMin, fYMax;
                BOOL bInit(FALSE);
                sal_Int32 nOuterSequenceCount(xPolyPolygon3D.SequenceX.getLength());
                drawing::DoubleSequence* pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray();
                drawing::DoubleSequence* pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray();

                for(sal_Int32 a(0L); a < nOuterSequenceCount; a++)
                {
                    sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength());
                    double* pArrayX = pInnerSequenceX->getArray();
                    double* pArrayY = pInnerSequenceY->getArray();

                    for(sal_Int32 b(0L); b < nInnerSequenceCount; b++)
                    {
                        double fX = *pArrayX++;
                        double fY = *pArrayY++;

                        if(bInit)
                        {
                            if(fX > fXMax)
                                fXMax = fX;

                            if(fX < fXMin)
                                fXMin = fX;

                            if(fY > fYMax)
                                fYMax = fY;

                            if(fY < fYMin)
                                fYMin = fY;
                        }
                        else
                        {
                            fXMin = fXMax = fX;
                            fYMin = fYMax = fY;
                            bInit = TRUE;
                        }
                    }

                    pInnerSequenceX++;
                    pInnerSequenceY++;
                }

                // export ViewBox
                awt::Point aMinPoint(FRound(fXMin), FRound(fYMin));
                awt::Size aMaxSize(FRound(fXMax) - aMinPoint.X, FRound(fYMax) - aMinPoint.Y);
                SdXMLImExViewBox aViewBox(
                    aMinPoint.X, aMinPoint.Y, aMaxSize.Width, aMaxSize.Height);
                rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_viewBox,
                    aViewBox.GetExportString(rExp.GetMM100UnitConverter()));

                // prepare svx:d element export
                SdXMLImExSvgDElement aSvgDElement(aViewBox);
                pInnerSequenceX = xPolyPolygon3D.SequenceX.getArray();
                pInnerSequenceY = xPolyPolygon3D.SequenceY.getArray();

                for(a = 0L; a < nOuterSequenceCount; a++)
                {
                    sal_Int32 nInnerSequenceCount(pInnerSequenceX->getLength());
                    double* pArrayX = pInnerSequenceX->getArray();
                    double* pArrayY = pInnerSequenceY->getArray();
                    drawing::PointSequence aPoly(nInnerSequenceCount);
                    awt::Point* pInnerSequence = aPoly.getArray();

                    for(sal_Int32 b(0L); b < nInnerSequenceCount; b++)
                    {
                        double fX = *pArrayX++;
                        double fY = *pArrayY++;

                        *pInnerSequence = awt::Point(FRound(fX), FRound(fY));
                        pInnerSequence++;
                    }

                    // calculate closed flag
                    awt::Point* pFirst = aPoly.getArray();
                    awt::Point* pLast = pFirst + (nInnerSequenceCount - 1);
                    BOOL bClosed = (pFirst->X == pLast->X && pFirst->Y == pLast->Y);

                    aSvgDElement.AddPolygon(&aPoly, 0L, aMinPoint,
                        aMaxSize, rExp.GetMM100UnitConverter(), bClosed);
                }

                // write point array
                rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_d, aSvgDElement.GetExportString());

                if(eShapeType == XmlShapeTypeDraw3DLatheObject)
                {
                    // write 3DLathe shape
                    SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DR3D, sXML_3DLathe, sal_True, sal_True);
                }
                else
                {
                    // write 3DExtrude shape
                    SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DR3D, sXML_3DExtrude, sal_True, sal_True);
                }
                break;
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpPrepareExport3DScene(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
{
    // write 3DScene attributes
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        OUString aStr;
        OUStringBuffer sStringBuffer;

        // rectangle, prepare parameters
        awt::Point aPoint = xShape->getPosition();
        awt::Size aSize = xShape->getSize();
        if( pRefPoint )
        {
            aPoint.X -= pRefPoint->X;
            aPoint.Y -= pRefPoint->Y;
        }

        // svg: x
        if( nFeatures & SEF_EXPORT_X )
        {
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.X);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_x, aStr);
        }

        // svg: y
        if( nFeatures & SEF_EXPORT_Y )
        {
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aPoint.Y);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_y, aStr);
        }

        // svg: width
        if( nFeatures & SEF_EXPORT_WIDTH )
        {
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Width);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_width, aStr);
        }

        // svg: height
        if( nFeatures & SEF_EXPORT_HEIGHT )
        {
            rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, aSize.Height);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_SVG, sXML_height, aStr);
        }

        // world transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix")
        uno::Any aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DTransformMatrix")));
        drawing::HomogenMatrix xHomMat;
        aAny >>= xHomMat;
        SdXMLImExTransform3D aTransform;
        aTransform.AddHomogenMatrix(xHomMat);
        if(aTransform.NeedsAction())
            rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_transform, aTransform.GetExportString(rExp.GetMM100UnitConverter()));

        // VRP, VPN, VUP
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DCameraGeometry")));
        drawing::CameraGeometry aCamGeo;
        aAny >>= aCamGeo;

        Vector3D aVRP(aCamGeo.vrp.PositionX, aCamGeo.vrp.PositionY, aCamGeo.vrp.PositionZ);
        if(aVRP != Vector3D(0.0, 0.0, 1.0)) // write only when not default
        {
            rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVRP);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_vrp, aStr);
        }

        Vector3D aVPN(aCamGeo.vpn.DirectionX, aCamGeo.vpn.DirectionY, aCamGeo.vpn.DirectionZ);
        if(aVPN != Vector3D(0.0, 0.0, 1.0)) // write only when not default
        {
            rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVPN);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_vpn, aStr);
        }

        Vector3D aVUP(aCamGeo.vup.DirectionX, aCamGeo.vup.DirectionY, aCamGeo.vup.DirectionZ);
        if(aVUP != Vector3D(0.0, 1.0, 0.0)) // write only when not default
        {
            rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aVUP);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_vup, aStr);
        }

        // projection "D3DScenePerspective" drawing::ProjectionMode
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DScenePerspective")));
        drawing::ProjectionMode xPrjMode;
        aAny >>= xPrjMode;
        if(xPrjMode == drawing::ProjectionMode_PARALLEL)
            aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_parallel));
        else
            aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_perspective));
        rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_projection, aStr);

        // distance
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneDistance")));
        sal_Int32 nDistance;
        aAny >>= nDistance;
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nDistance);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_distance, aStr);

        // focalLength
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneFocalLength")));
        sal_Int32 nFocalLength;
        aAny >>= nFocalLength;
        rExp.GetMM100UnitConverter().convertMeasure(sStringBuffer, nFocalLength);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_focal_length, aStr);

        // shadowSlant
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadowSlant")));
        sal_Int16 nShadowSlant;
        aAny >>= nShadowSlant;
        rExp.GetMM100UnitConverter().convertNumber(sStringBuffer, (sal_Int32)nShadowSlant);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_shadow_slant, aStr);

        // shadeMode
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneShadeMode")));
        drawing::ShadeMode xShadeMode;
        aAny >>= xShadeMode;
        if(xShadeMode == drawing::ShadeMode_FLAT)
            aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_flat));
        else if(xShadeMode == drawing::ShadeMode_PHONG)
            aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_phong));
        else if(xShadeMode == drawing::ShadeMode_SMOOTH)
            aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_gouraud));
        else
            aStr = OUString(RTL_CONSTASCII_USTRINGPARAM(sXML_draft));
        rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_shade_mode, aStr);

        // ambientColor
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor")));
        sal_Int32 aColTemp;
        Color aAmbientColor;
        aAny >>= aColTemp; aAmbientColor.SetColor(aColTemp);
        rExp.GetMM100UnitConverter().convertColor(sStringBuffer, aAmbientColor);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_ambient_color, aStr);

        // lightingMode
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneTwoSidedLighting")));
        sal_Bool bTwoSidedLighting;
        aAny >>= bTwoSidedLighting;
        rExp.GetMM100UnitConverter().convertBool(sStringBuffer, bTwoSidedLighting);
        aStr = sStringBuffer.makeStringAndClear();
        rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_lighting_mode, aStr);
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpExport3DLamps(SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType eShapeType, sal_Int32 nFeatures, awt::Point* pRefPoint)
{
    const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        // write lamps 1..8 as content
        uno::Any aAny;
        OUString aStr;
        OUStringBuffer sStringBuffer;

        // lightcolor
        Color aLightColor[8];
        sal_Int32 aColTemp;
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor1")));
        aAny >>= aColTemp; aLightColor[0].SetColor(aColTemp);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor2")));
        aAny >>= aColTemp; aLightColor[1].SetColor(aColTemp);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor3")));
        aAny >>= aColTemp; aLightColor[2].SetColor(aColTemp);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor4")));
        aAny >>= aColTemp; aLightColor[3].SetColor(aColTemp);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor5")));
        aAny >>= aColTemp; aLightColor[4].SetColor(aColTemp);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor6")));
        aAny >>= aColTemp; aLightColor[5].SetColor(aColTemp);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor7")));
        aAny >>= aColTemp; aLightColor[6].SetColor(aColTemp);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor8")));
        aAny >>= aColTemp; aLightColor[7].SetColor(aColTemp);

        // lightdirection
        Vector3D aLightDirection[8];
        drawing::Direction3D xLightDir;
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection1")));
        aAny >>= xLightDir; aLightDirection[0] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection2")));
        aAny >>= xLightDir; aLightDirection[1] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection3")));
        aAny >>= xLightDir; aLightDirection[2] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection4")));
        aAny >>= xLightDir; aLightDirection[3] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection5")));
        aAny >>= xLightDir; aLightDirection[4] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection6")));
        aAny >>= xLightDir; aLightDirection[5] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection7")));
        aAny >>= xLightDir; aLightDirection[6] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ);
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection8")));
        aAny >>= xLightDir; aLightDirection[7] = Vector3D(xLightDir.DirectionX, xLightDir.DirectionY, xLightDir.DirectionZ);

        // lighton
        sal_Bool bLightOnOff[8];
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn1")));
        aAny >>= bLightOnOff[0];
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn2")));
        aAny >>= bLightOnOff[1];
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn3")));
        aAny >>= bLightOnOff[2];
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn4")));
        aAny >>= bLightOnOff[3];
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn5")));
        aAny >>= bLightOnOff[4];
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn6")));
        aAny >>= bLightOnOff[5];
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn7")));
        aAny >>= bLightOnOff[6];
        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn8")));
        aAny >>= bLightOnOff[7];

        for(sal_uInt32 a(0L); a < 8; a++)
        {
            // lightcolor
            rExp.GetMM100UnitConverter().convertColor(sStringBuffer, aLightColor[a]);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_diffuse_color, aStr);

            // lightdirection
            rExp.GetMM100UnitConverter().convertVector3D(sStringBuffer, aLightDirection[a]);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_direction, aStr);

            // lighton
            rExp.GetMM100UnitConverter().convertBool(sStringBuffer, bLightOnOff[a]);
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_enabled, aStr);

            // specular
            rExp.GetMM100UnitConverter().convertBool(sStringBuffer, (BOOL)(a == 0L));
            aStr = sStringBuffer.makeStringAndClear();
            rExp.AddAttribute(XML_NAMESPACE_DR3D, sXML_specular, aStr);

            // write light entry
            SvXMLElementExport aOBJ(rExp, XML_NAMESPACE_DR3D, sXML_light, sal_True, sal_True);
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpWriteSingleShapeStyleInfo(const uno::Reference< drawing::XShape >& xShape, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ )
{
    // get correct shape-style info
    ImpXMLShapeStyleInfo* pInfo =
        (mnShapeStyleInfoIndex < mpShapeStyleInfoList->Count()) ?
        mpShapeStyleInfoList->GetObject(mnShapeStyleInfoIndex) : 0L;
    mnShapeStyleInfoIndex++;

    if(pInfo && pInfo->GetStyleName().getLength())
    {
        XmlShapeType eShapeType(XmlShapeTypeNotYetSet);

        ImpCalcShapeType(xShape, eShapeType);
        ImpWriteSingleShapeStyleInfo(*this, xShape,
            pInfo->GetFamily(), pInfo->GetStyleName(), eShapeType, nFeatures, pRefPoint );
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpCalcShapeType(const uno::Reference< drawing::XShape >& xShape,
    XmlShapeType& eShapeType)
{
    // set in every case, so init here
    eShapeType = XmlShapeTypeUnknown;

    uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY);
    if(xShapeDescriptor.is())
    {
        String aType((OUString)xShapeDescriptor->getShapeType());

        if(aType.EqualsAscii((const sal_Char*)"com.sun.star.", 0, 13))
        {
            if(aType.EqualsAscii("drawing.", 13, 8))
            {
                // drawing shapes
                if     (aType.EqualsAscii("Rectangle", 21, 9)) { eShapeType = XmlShapeTypeDrawRectangleShape; }
                else if(aType.EqualsAscii("Ellipse", 21, 7)) { eShapeType = XmlShapeTypeDrawEllipseShape; }
                else if(aType.EqualsAscii("Control", 21, 7)) { eShapeType = XmlShapeTypeDrawControlShape; }
                else if(aType.EqualsAscii("Connector", 21, 9)) { eShapeType = XmlShapeTypeDrawConnectorShape; }
                else if(aType.EqualsAscii("Measure", 21, 7)) { eShapeType = XmlShapeTypeDrawMeasureShape; }
                else if(aType.EqualsAscii("Line", 21, 4)) { eShapeType = XmlShapeTypeDrawLineShape; }
                else if(aType.EqualsAscii("PolyPolygon", 21, 11)) { eShapeType = XmlShapeTypeDrawPolyPolygonShape; }
                else if(aType.EqualsAscii("PolyLine", 21, 8)) { eShapeType = XmlShapeTypeDrawPolyLineShape; }
                else if(aType.EqualsAscii("OpenBezier", 21, 10)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; }
                else if(aType.EqualsAscii("ClosedBezier", 21, 12)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; }
                else if(aType.EqualsAscii("GraphicObject", 21, 13)) { eShapeType = XmlShapeTypeDrawGraphicObjectShape; }
                else if(aType.EqualsAscii("Group", 21, 5)) { eShapeType = XmlShapeTypeDrawGroupShape; }
                else if(aType.EqualsAscii("Text", 21, 4)) { eShapeType = XmlShapeTypeDrawTextShape; }
                else if(aType.EqualsAscii("OLE2", 21, 4))
                {
                    eShapeType = XmlShapeTypeDrawOLE2Shape;

                    // get info about presentation shape
                    uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);

                    if(xPropSet.is())
                    {
                        uno::Any aAny;
                        aAny = xPropSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Model")));
                        uno::Reference <lang::XServiceInfo> xObjectInfo;

                        if(aAny >>= xObjectInfo)
                        {
                            if(xObjectInfo->supportsService(OUString(RTL_CONSTASCII_USTRINGPARAM
                                ("com.sun.star.chart.ChartDocument"))))
                            {
                                eShapeType = XmlShapeTypeDrawChartShape;
                            }
                            else if(xObjectInfo->supportsService(OUString(RTL_CONSTASCII_USTRINGPARAM
                                ("com.sun.star.sheet.SpreadsheetDocument"))))
                            {
                                eShapeType = XmlShapeTypeDrawTableShape;
                            }
                            else
                            {
                                // general OLE2 Object
                            }
                        }
                    }
                }
                else if(aType.EqualsAscii("Page", 21, 4)) { eShapeType = XmlShapeTypeDrawPageShape; }
                else if(aType.EqualsAscii("Frame", 21, 5)) { eShapeType = XmlShapeTypeDrawFrameShape; }
                else if(aType.EqualsAscii("Caption", 21, 6)) { eShapeType = XmlShapeTypeDrawCaptionShape; }

                // 3D shapes
                else if(aType.EqualsAscii("Scene", 21 + 7, 5)) { eShapeType = XmlShapeTypeDraw3DSceneObject; }
                else if(aType.EqualsAscii("Cube", 21 + 7, 4)) { eShapeType = XmlShapeTypeDraw3DCubeObject; }
                else if(aType.EqualsAscii("Sphere", 21 + 7, 6)) { eShapeType = XmlShapeTypeDraw3DSphereObject; }
                else if(aType.EqualsAscii("Lathe", 21 + 7, 5)) { eShapeType = XmlShapeTypeDraw3DLatheObject; }
                else if(aType.EqualsAscii("Extrude", 21 + 7, 7)) { eShapeType = XmlShapeTypeDraw3DExtrudeObject; }
            }
            else if(aType.EqualsAscii("presentation.", 13, 13))
            {
                // presentation shapes
                if     (aType.EqualsAscii("TitleText", 26, 9)) { eShapeType = XmlShapeTypePresTitleTextShape; }
                else if(aType.EqualsAscii("Outliner", 26, 8)) { eShapeType = XmlShapeTypePresOutlinerShape;  }
                else if(aType.EqualsAscii("Subtitle", 26, 8)) { eShapeType = XmlShapeTypePresSubtitleShape;  }
                else if(aType.EqualsAscii("GraphicObject", 26, 13)) { eShapeType = XmlShapeTypePresGraphicObjectShape;  }
                else if(aType.EqualsAscii("Page", 26, 4)) { eShapeType = XmlShapeTypePresPageShape;  }
                else if(aType.EqualsAscii("OLE2", 26, 4)) { eShapeType = XmlShapeTypePresOLE2Shape; }
                else if(aType.EqualsAscii("Chart", 26, 5)) { eShapeType = XmlShapeTypePresChartShape;  }
                else if(aType.EqualsAscii("Table", 26, 5)) { eShapeType = XmlShapeTypePresTableShape;  }
                else if(aType.EqualsAscii("OrgChart", 26, 8)) { eShapeType = XmlShapeTypePresOrgChartShape;  }
                else if(aType.EqualsAscii("Notes", 26, 5)) { eShapeType = XmlShapeTypePresNotesShape;  }
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpWriteSingleShapeStyleInfo(
    SvXMLExport& rExp,
    const uno::Reference< drawing::XShape >& xShape,
    sal_uInt16 nFamily, const OUString& rStyleName, XmlShapeType eShapeType,
    sal_Int32 nFeatures /* = SEF_DEFAULT */,
    com::sun::star::awt::Point* pRefPoint /* = NULL */ )
{
    if( rStyleName.getLength() )
    {
        // add style-name attribute (REQUIRED) Style-name, evtl. auto-style
        if(XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily)
            rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_style_name, rStyleName);
        else
            rExp.AddAttribute(XML_NAMESPACE_PRESENTATION, sXML_style_name, rStyleName);
    }

    // export shape name if he has one
    uno::Reference< container::XNamed > xNamed( xShape, uno::UNO_QUERY );
    if( xNamed.is() )
    {
        const OUString aName( xNamed->getName() );
        if( aName.getLength() )
            rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_name, aName );
    }

    // export shape id if needed
    sal_Int32 nShapeId = rExp.GetShapeExport()->getShapeId( xShape );
    if( nShapeId != -1 )
    {
        const OUString sId( OUString::valueOf( nShapeId ) );
        rExp.AddAttribute(XML_NAMESPACE_DRAW, sXML_id, sId );
    }

    switch(eShapeType)
    {
        case XmlShapeTypeDrawRectangleShape:
        {
            ImpExportRectangleShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }
        case XmlShapeTypeDrawEllipseShape:
        {
            ImpExportEllipseShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }
        case XmlShapeTypeDrawLineShape:
        {
            ImpExportLineShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }
        case XmlShapeTypeDrawPolyPolygonShape:  // closed PolyPolygon
        case XmlShapeTypeDrawPolyLineShape:     // open PolyPolygon
        case XmlShapeTypeDrawClosedBezierShape: // closed PolyPolygon containing curves
        case XmlShapeTypeDrawOpenBezierShape:   // open PolyPolygon containing curves
        {
            ImpExportPolygonShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }

        case XmlShapeTypeDrawTextShape:
        case XmlShapeTypePresTitleTextShape:
        case XmlShapeTypePresOutlinerShape:
        case XmlShapeTypePresSubtitleShape:
        case XmlShapeTypePresNotesShape:
        {
            ImpExportTextBoxShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }

        case XmlShapeTypeDrawGraphicObjectShape:
        case XmlShapeTypePresGraphicObjectShape:
        {
            ImpExportGraphicObjectShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }

        case XmlShapeTypeDrawChartShape:
        case XmlShapeTypePresChartShape:
        {
            ImpExportChartShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }

        case XmlShapeTypeDrawTableShape:
        case XmlShapeTypePresTableShape:
        {
            ImpExportSpreadsheetShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }

        case XmlShapeTypeDrawControlShape:
        {
            ImpExportControlShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }

        case XmlShapeTypeDrawConnectorShape:
        {
            ImpExportConnectorShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }

        case XmlShapeTypeDrawMeasureShape:
        {
            ImpExportMeasureShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }

        case XmlShapeTypeDrawOLE2Shape:
        case XmlShapeTypePresOLE2Shape:
        {
            ImpExportOLE2Shape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }

        case XmlShapeTypeDrawPageShape:
        case XmlShapeTypePresPageShape:
        {
            ImpExportPageShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }

        case XmlShapeTypeDrawCaptionShape:
        {
            ImpExportCaptionShape(rExp, xShape, eShapeType, nFeatures, pRefPoint );
            break;
        }

        case XmlShapeTypeDraw3DCubeObject:
        case XmlShapeTypeDraw3DSphereObject:
        case XmlShapeTypeDraw3DLatheObject:
        case XmlShapeTypeDraw3DExtrudeObject:
        {
            ImpExport3DShape((SdXMLExport&)rExp, xShape, eShapeType);
            break;
        }

        case XmlShapeTypeDraw3DSceneObject:
        {
            // empty 3dscene
            DBG_ASSERT(FALSE, "XMLEXP: WriteShape: empty 3DScene in export, not exported.");
            break;
        }

        case XmlShapeTypeDrawGroupShape:
        {
            // empty group
            DBG_ASSERT(FALSE, "XMLEXP: WriteShape: empty GroupShape in export, not exported.");
            break;
        }

        case XmlShapeTypePresOrgChartShape:
        case XmlShapeTypeDrawFrameShape:
        case XmlShapeTypeUnknown:
        case XmlShapeTypeNotYetSet:
        default:
        {
            // this should never happen and is an error
            DBG_ERROR("XMLEXP: WriteShape: unknown or unexpected type of shape in export!");
            break;
        }
    }
}

void SdXMLExport::ImpWriteSingleShapeStyleInfos(uno::Reference< container::XIndexAccess >& xShapes, sal_Int32 nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */ )
{
    const sal_Int32 nShapeCount(xShapes->getCount());
    sal_Int32 nShapeId;

    // loop over shapes
    for(nShapeId = 0L; nShapeId < nShapeCount; nShapeId++)
    {
        uno::Any aAny(xShapes->getByIndex(nShapeId));
        uno::Reference< drawing::XShape > xShape;

        if(aAny >>= xShape)
        {
            uno::Reference< container::XIndexAccess > xShapes(xShape, uno::UNO_QUERY);
            if(xShapes.is() && xShapes->getCount())
            {
                // group shape or 3Dscene?
                sal_Bool bIsScene(FALSE);
                uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY);
                if(xShapeDescriptor.is())
                {
                    String aType((OUString)xShapeDescriptor->getShapeType());
                    if(aType.EqualsAscii((const sal_Char*)"com.sun.star.drawing.Shape3DSceneObject"))
                    {
                        bIsScene = TRUE;
                    }
                }

                if(bIsScene)
                {
                    // prepare write 3DScene
                    ImpPrepareExport3DScene(*this, xShape, XmlShapeTypeDraw3DSceneObject, nFeatures, pRefPoint);

                    // write 3DScene shape
                    SvXMLElementExport aOBJ(*this, XML_NAMESPACE_DR3D, sXML_3DScene, sal_True, sal_True);

                    // write 3DSceneLights
                    ImpExport3DLamps(*this, xShape, XmlShapeTypeDraw3DSceneObject, nFeatures, pRefPoint);

                    // write members
                    ImpWriteSingleShapeStyleInfos(xShapes, nFeatures, pRefPoint );
                }
                else
                {
                    // write group shape
                    SvXMLElementExport aPGR(*this, XML_NAMESPACE_DRAW, sXML_g, sal_True, sal_True);

                    // write members
                    ImpWriteSingleShapeStyleInfos(xShapes, nFeatures, pRefPoint);
                }
            }
            else
            {
                // single shape
                ImpWriteSingleShapeStyleInfo(xShape, nFeatures, pRefPoint );
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::ImpPrepSingleShapeStyleInfo(uno::Reference< drawing::XShape >& xShape,
    const OUString& rPrefix)
{
    uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY);
    if(xPropSet.is())
    {
        OUString aParentName;
        OUString aNewName;
        uno::Reference< style::XStyle > xStyle;
        sal_Int32 nFamily(XML_STYLE_FAMILY_SD_GRAPHICS_ID);

        uno::Any aAny = xPropSet->getPropertyValue(
            OUString(RTL_CONSTASCII_USTRINGPARAM("Style")));
        if((aAny >>= xStyle) && xStyle.is())
        {
            // get family ID
            uno::Reference< beans::XPropertySet > xStylePropSet(xStyle, uno::UNO_QUERY);
            if(xStylePropSet.is())
            {
                OUString aFamilyName;
                aAny = xStylePropSet->getPropertyValue(
                    OUString(RTL_CONSTASCII_USTRINGPARAM("Family")));
                if(aAny >>= aFamilyName)
                {
                    if(aFamilyName.getLength() && aFamilyName.equals(
                        OUString(RTL_CONSTASCII_USTRINGPARAM("presentation"))))
                    {
                        nFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID;
                    }
                }
            }

            // get parent-style name
            if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == nFamily && rPrefix.getLength())
            {
                aParentName = rPrefix;
                aParentName += xStyle->getName();
            }
            else
                aParentName = xStyle->getName();
        }

        // filter propset
        std::vector< XMLPropertyState > xPropStates = GetPropertySetMapper()->Filter( xPropSet );

        if(!xPropStates.size())
        {
            // no hard attributes, use parent style name for export
            aNewName = aParentName;
        }
        else
        {
            // there are filtered properties -> hard attributes
            // try to find this style in AutoStylePool
            aNewName = GetAutoStylePool()->Find(nFamily, aParentName, xPropStates);

            if(!aNewName.getLength())
            {
                // Style did not exist, add it to AutoStalePool
                aNewName = GetAutoStylePool()->Add(nFamily, aParentName, xPropStates);
            }
        }

        // in aNewName is the StyleInfo to be used for exporting this object.
        // Remember: String maybe still empty due to objects without style,
        // like PageObjects(!)
        // Now remember this association in helper class for later export
        ImpXMLShapeStyleInfo* pInfo = new ImpXMLShapeStyleInfo(aNewName, nFamily);
        mpShapeStyleInfoList->Insert(pInfo, LIST_APPEND);

        const OUString aShapeType( xShape->getShapeType() );

        // prep text styles
        uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
        if(xText.is())
        {
            uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );

            sal_Bool bIsEmptyPresObj = sal_False;

            if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(msEmptyPres))
            {
                uno::Any aAny = xPropSet->getPropertyValue(msEmptyPres);
                aAny >>= bIsEmptyPresObj;
            }

            if(!bIsEmptyPresObj)
            {
                if( !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GraphicObjectShape")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.ChartShape")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.GraphicObjectShape")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OLE2Shape")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ControlShape")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GroupShape")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PageShape")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSceneObject")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DCubeObject")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSphereObject")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DLatheObject")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DExtrudeObject")) &&
                    !aShapeType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.PageShape")) )
                {
                    GetTextParagraphExport()->collectTextAutoStyles( xText );
                }
            }
        }

        // check for calc ole
        if( aShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.OLE2Shape" )) ||
            aShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.presentation.ChartShape" )) )
        {
            uno::Reference< chart::XChartDocument > xChartDoc;
            uno::Any aAny( xPropSet->getPropertyValue( msModel ) );
            aAny >>= xChartDoc;
            if( xChartDoc.is() )
            {
                GetChartExport()->collectAutoStyles( xChartDoc );
            }
        }

        // check for connector
        if( aShapeType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.ConnectorShape" ) ) )
        {
            uno::Reference< drawing::XShape > xConnection;

            // create shape ids for export later
            if( xPropSet->getPropertyValue( msStartShape ) >>= xConnection )
            {
                GetShapeExport()->createShapeId( xConnection );
            }
            if( xPropSet->getPropertyValue( msEndShape ) >>= xConnection )
            {
                GetShapeExport()->createShapeId( xConnection );
            }
        }
    }
}

void SdXMLExport::ImpPrepSingleShapeStyleInfos(uno::Reference< container::XIndexAccess >& xShapes,
    const OUString& rPrefix)
{
    const sal_Int32 nShapeCount(xShapes->getCount());
    sal_Int32 nShapeId;

    // loop over shapes
    for(nShapeId = 0L; nShapeId < nShapeCount; nShapeId++)
    {
        uno::Any aAny(xShapes->getByIndex(nShapeId));
        uno::Reference< drawing::XShape > xShape;

        if(aAny >>= xShape)
        {
            uno::Reference< container::XIndexAccess > xShapes(xShape, uno::UNO_QUERY);
            if(xShapes.is() && xShapes->getCount())
            {
                // group shape
                ImpPrepSingleShapeStyleInfos(xShapes, rPrefix);
            }
            else
            {
                // single shape
                ImpPrepSingleShapeStyleInfo(xShape, rPrefix);
            }
        }
    }
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::_ExportStyles(BOOL bUsed)
{
    GetPropertySetMapper()->SetAutoStyles( sal_False );

    // export fill styles
    SvXMLExport::_ExportStyles( bUsed );

    // prepare and write default-draw-style-pool
    ImpWriteDefaultStyleInfos();

    // write draw:style-name for object graphic-styles
    ImpWriteObjGraphicStyleInfos();

    // write presentation styles
    ImpWritePresentationStyles();

    // write draw:auto-layout-name for page export
    ImpWriteAutoLayoutInfos();
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::_ExportAutoStyles()
{
    GetPropertySetMapper()->SetAutoStyles( sal_True );

    // #80012# PageMaster export moved from _ExportStyles
    // prepare page-master infos
    ImpPrepPageMasterInfos();

    // write page-master infos
    ImpWritePageMasterInfos();

    // prepare draw:style-name for master page export
    ImpPrepMasterPageInfos();

    // prepare draw:style-name for page export
    ImpPrepDrawPageInfos();

    // export draw-page styles
    GetAutoStylePool()->exportXML(
        XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID,
        GetDocHandler(),
        GetMM100UnitConverter(),
        GetNamespaceMap());

    // create auto style infos for objects on master pages
    for(sal_Int32 nMPageId(0L); nMPageId < mnDocMasterPageCount; nMPageId++)
    {
        uno::Any aAny(mxDocMasterPages->getByIndex(nMPageId));
        uno::Reference< drawing::XDrawPage > xMasterPage;

        if(aAny >>= xMasterPage)
        {
            // get MasterPage Name
            OUString aMasterPageNamePrefix;
            uno::Reference < container::XNamed > xNamed(xMasterPage, uno::UNO_QUERY);
            if(xNamed.is())
            {
                aMasterPageNamePrefix = xNamed->getName();
            }
            if(aMasterPageNamePrefix.getLength())
            {
                aMasterPageNamePrefix += OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
            }

            uno::Reference< container::XIndexAccess > xShapes(xMasterPage, uno::UNO_QUERY);
            if(xShapes.is() && xShapes->getCount())
                ImpPrepSingleShapeStyleInfos(xShapes, aMasterPageNamePrefix);

            if(IsImpress())
            {
                uno::Reference< presentation::XPresentationPage > xPresPage(xMasterPage, uno::UNO_QUERY);
                if(xPresPage.is())
                {
                    uno::Reference< drawing::XDrawPage > xNotesPage(xPresPage->getNotesPage());
                    if(xNotesPage.is())
                    {
                        uno::Reference< container::XIndexAccess > xShapes(xNotesPage, uno::UNO_QUERY);
                        if(xShapes.is() && xShapes->getCount())
                            ImpPrepSingleShapeStyleInfos(xShapes, aMasterPageNamePrefix);
                    }
                }
            }
        }
    }

    // create auto style infos for objects on pages
    for(sal_Int32 nPageInd(0); nPageInd < mnDocDrawPageCount; nPageInd++)
    {
        uno::Any aAny(mxDocDrawPages->getByIndex(nPageInd));
        uno::Reference<drawing::XDrawPage> xDrawPage;

        if(aAny >>= xDrawPage)
        {
            // get MasterPage Name
            OUString aMasterPageNamePrefix;
            uno::Reference < drawing::XMasterPageTarget > xMasterPageInt(xDrawPage, uno::UNO_QUERY);
            if(xMasterPageInt.is())
            {
                uno::Reference<drawing::XDrawPage> xUsedMasterPage(xMasterPageInt->getMasterPage());
                if(xUsedMasterPage.is())
                {
                    uno::Reference < container::XNamed > xMasterNamed(xUsedMasterPage, uno::UNO_QUERY);
                    if(xMasterNamed.is())
                    {
                        aMasterPageNamePrefix = xMasterNamed->getName();
                    }
                }
            }
            if(aMasterPageNamePrefix.getLength())
            {
                aMasterPageNamePrefix += OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
            }

            // prepare object infos
            uno::Reference< container::XIndexAccess > xShapes(xDrawPage, uno::UNO_QUERY);
            if(xShapes.is() && xShapes->getCount())
                ImpPrepSingleShapeStyleInfos(xShapes, aMasterPageNamePrefix);

            // prepare presentation notes page object infos (ONLY if presentation)
            if(IsImpress())
            {
                uno::Reference< presentation::XPresentationPage > xPresPage(xDrawPage, uno::UNO_QUERY);
                if(xPresPage.is())
                {
                    uno::Reference< drawing::XDrawPage > xNotesPage(xPresPage->getNotesPage());
                    if(xNotesPage.is())
                    {
                        uno::Reference< container::XIndexAccess > xShapes(xNotesPage, uno::UNO_QUERY);
                        if(xShapes.is() && xShapes->getCount())
                            ImpPrepSingleShapeStyleInfos(xShapes, aMasterPageNamePrefix);
                    }
                }
            }
        }
    }

    GetShapeExport()->exportAutoStyles();

    // ...for text
    GetTextParagraphExport()->exportTextAutoStyles();

    // ...for chart
    GetChartExport()->exportAutoStyles();
}

//////////////////////////////////////////////////////////////////////////////

void SdXMLExport::_ExportMasterStyles()
{
    // export MasterPages in master-styles section
    for(sal_Int32 nMPageId = 0L; nMPageId < mnDocMasterPageCount; nMPageId++)
    {
        uno::Any aAny(mxDocMasterPages->getByIndex(nMPageId));
        uno::Reference< drawing::XDrawPage > xMasterPage;

        if(aAny >>= xMasterPage)
        {
            // prepare masterpage attributes
            OUString sMasterPageName;
            uno::Reference < container::XNamed > xNamed(xMasterPage, uno::UNO_QUERY);
            if(xNamed.is())
            {
                sMasterPageName = xNamed->getName();
                AddAttribute(XML_NAMESPACE_STYLE, sXML_name, sMasterPageName);
            }

            ImpXMLEXPPageMasterInfo* pInfo = mpPageMaterUsageList->GetObject(nMPageId);
            if(pInfo)
            {
                OUString sString = pInfo->GetName();
                AddAttribute(XML_NAMESPACE_STYLE, sXML_page_master_name, sString);
            }

            // draw:style-name (background attributes)
            ImpXMLDrawPageInfo* pStyleInfo = mpMasterPageInfoList->GetObject(nMPageId);
            if(pInfo)
            {
                OUString sString = pStyleInfo->GetStyleName();
                if( sString.getLength() )
                    AddAttribute(XML_NAMESPACE_DRAW, sXML_style_name, sString);
            }

            // write masterpage
            SvXMLElementExport aMPG(*this, XML_NAMESPACE_STYLE, sXML_master_page, sal_True, sal_True);

            // write graphic objects on this master page (if any)
            uno::Reference< container::XIndexAccess > xShapes(xMasterPage, uno::UNO_QUERY);
            if(xShapes.is() && xShapes->getCount())
                ImpWriteSingleShapeStyleInfos(xShapes);

            // write presentation notes (ONLY if presentation)
            if(IsImpress())
            {
                uno::Reference< presentation::XPresentationPage > xPresPage(xMasterPage, uno::UNO_QUERY);
                if(xPresPage.is())
                {
                    uno::Reference< drawing::XDrawPage > xNotesPage(xPresPage->getNotesPage());
                    if(xNotesPage.is())
                    {
                        uno::Reference< container::XIndexAccess > xShapes(xNotesPage, uno::UNO_QUERY);
                        if(xShapes.is() && xShapes->getCount())
                        {
                            // write presentation notes
                            SvXMLElementExport aPSY(*this, XML_NAMESPACE_PRESENTATION, sXML_notes, sal_True, sal_True);

                            // write shapes per se
                            ImpWriteSingleShapeStyleInfos(xShapes);
                        }
                    }
                }
            }
        }
    }
}


sal_uInt32 SdXMLExportDoc(
        const com::sun::star::uno::Reference<com::sun::star::frame::XModel>& rMod,
        const rtl::OUString& rFileName,
        const com::sun::star::uno::Reference<com::sun::star::xml::sax::XDocumentHandler>& rHandler,
        const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rGrfContainer,
        com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator >& rStatusIndicator,
        BOOL bShowProgr, BOOL bIsDraw )
{
    SdXMLExport aExp( rMod, rFileName, rHandler, rGrfContainer, bShowProgr, bIsDraw );
    return aExp.exportDoc( bIsDraw ? sXML_drawing : sXML_presentation );
}