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
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include <xmloff/autolayout.hxx>
#include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmlnmspe.hxx>
#include <xmloff/xmluconv.hxx>
#include <xmloff/xmltoken.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/presentation/XPresentationSupplier.hpp>
#include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
#include <com/sun/star/geometry/RealPoint2D.hpp>
#include <com/sun/star/office/XAnnotationAccess.hpp>
#include <com/sun/star/uno/Any.hxx>
#include "sdxmlexp_impl.hxx"
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
#include <com/sun/star/presentation/XHandoutMasterSupplier.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/view/PaperOrientation.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>

#include <com/sun/star/form/XFormsSupplier2.hpp>
#include <com/sun/star/presentation/XPresentationPage.hpp>
#include <com/sun/star/drawing/XMasterPageTarget.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/util/Duration.hpp>
#include <com/sun/star/util/MeasureUnit.hpp>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
#include <tools/gen.hxx>
#include <sax/tools/converter.hxx>
#include <xmloff/xmlaustp.hxx>
#include <xmloff/families.hxx>
#include <xmloff/styleexp.hxx>
#include <xmloff/settingsstore.hxx>
#include <xmloff/table/XMLTableExport.hxx>
#include <xmloff/ProgressBarHelper.hxx>
#include "sdpropls.hxx"
#include <xmloff/xmlexppr.hxx>

#include <comphelper/processfactory.hxx>
#include <PropertySetMerger.hxx>
#include "layerexp.hxx"

#include "XMLNumberStylesExport.hxx"

#include <xmloff/animationexport.hxx>

#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::office;
using namespace ::com::sun::star::presentation;
using namespace ::com::sun::star::geometry;
using namespace ::com::sun::star::text;
using namespace ::xmloff::token;

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 Reference<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 Reference<XDrawPage>& xPage)
:   mnBorderBottom(0),
    mnBorderLeft(0),
    mnBorderRight(0),
    mnBorderTop(0),
    mnWidth(0),
    mnHeight(0),
    meOrientation(rExp.IsDraw() ? view::PaperOrientation_PORTRAIT : view::PaperOrientation_LANDSCAPE)
{
    Reference <beans::XPropertySet> xPropSet(xPage, UNO_QUERY);
    if(xPropSet.is())
    {
        Any aAny;

        Reference< beans::XPropertySetInfo > xPropsInfo( xPropSet->getPropertySetInfo() );
        if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("BorderBottom"))
        {
            aAny = xPropSet->getPropertyValue("BorderBottom");
            aAny >>= mnBorderBottom;<--- aAny is assigned

            aAny = xPropSet->getPropertyValue("BorderLeft");<--- aAny is overwritten
            aAny >>= mnBorderLeft;<--- aAny is assigned

            aAny = xPropSet->getPropertyValue("BorderRight");<--- aAny is overwritten
            aAny >>= mnBorderRight;<--- aAny is assigned

            aAny = xPropSet->getPropertyValue("BorderTop");<--- aAny is overwritten<--- Variable 'aAny' is assigned a value that is never used.
            aAny >>= mnBorderTop;<--- Variable 'aAny' is assigned a value that is never used.
        }

        if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("Width"))
        {
            aAny = xPropSet->getPropertyValue("Width");
            aAny >>= mnWidth;<--- aAny is assigned

            aAny = xPropSet->getPropertyValue("Height");<--- aAny is overwritten<--- Variable 'aAny' is assigned a value that is never used.
            aAny >>= mnHeight;<--- Variable 'aAny' is assigned a value that is never used.
        }

        if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("Orientation"))
        {
            aAny = xPropSet->getPropertyValue("Orientation");<--- Variable 'aAny' is assigned a value that is never used.
            aAny >>= meOrientation;<--- Variable 'aAny' is assigned a value that is never used.
        }
    }

    Reference <container::XNamed> xMasterNamed(xPage, 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;
}

#define IMP_AUTOLAYOUT_INFO_MAX         (35L)

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

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

    sal_uInt16 GetLayoutType() const { return mnType; }
    ImpXMLEXPPageMasterInfo* GetPageMasterInfo() const { return mpPageMasterInfo; }
    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 tools::Rectangle& GetTitleRectangle() const { return maTitleRect; }
    const tools::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;
}

ImpXMLAutoLayoutInfo::ImpXMLAutoLayoutInfo(sal_uInt16 nTyp, ImpXMLEXPPageMasterInfo* pInf)
    : mnType(nTyp)
    , mpPageMasterInfo(pInf)
    , mnGapX(0)
    , mnGapY(0)
{
    // create full info (initialize 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.AdjustWidth(-(mpPageMasterInfo->GetBorderLeft() + mpPageMasterInfo->GetBorderRight()));
        aPageInnerSize.AdjustHeight(-(mpPageMasterInfo->GetBorderTop() + mpPageMasterInfo->GetBorderBottom()));
    }

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

    if(mnType == 21 /* AUTOLAYOUT_NOTES */)
    {
        aTitleSize.setHeight(static_cast<long>(aTitleSize.Height() / 2.5));
        Point aPos = aTitlePos;
        aPos.AdjustY( long( aTitleSize.Height() * 0.083 ) );
        Size aPartArea = aTitleSize;
        Size aSize;

        // scale handout rectangle using actual page size
        double fH = static_cast<double>(aPartArea.Width())  / aPageSize.Width();
        double fV = static_cast<double>(aPartArea.Height()) / aPageSize.Height();

        if ( fH > fV )
            fH = fV;
        aSize.setWidth( static_cast<long>(fH * aPageSize.Width()) );
        aSize.setHeight( static_cast<long>(fH * aPageSize.Height()) );

        aPos.AdjustX((aPartArea.Width() - aSize.Width()) / 2);
        aPos.AdjustY((aPartArea.Height()- aSize.Height())/ 2);

        aTitlePos = aPos;
        aTitleSize = aSize;
    }
    else if(mnType == AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT || mnType == AUTOLAYOUT_VTITLE_VCONTENT)
    {
        Point aClassicTPos(
            aTitlePos.X() + long( aTitleSize.Width() * 0.0735 ),
            aTitlePos.Y() + long( aTitleSize.Height() * 0.083 ));
        Size aClassicTSize(
            long( aTitleSize.Width() * 0.854 ),
            long( aTitleSize.Height() * 0.167 ));
        Point aLPos(aPagePos);
        Size aLSize(aPageInnerSize);
        Point aClassicLPos(
            aLPos.X() + long( aLSize.Width() * 0.0735 ),
            aLPos.Y() + long( aLSize.Height() * 0.472 ));
        Size aClassicLSize(
            long( aLSize.Width() * 0.854 ),
            long( aLSize.Height() * 0.444 ));

        aTitlePos.setX( (aClassicTPos.X() + aClassicTSize.Width()) - aClassicTSize.Height() );
        aTitlePos.setY( aClassicTPos.Y() );
        aTitleSize.setWidth( aClassicTSize.Height() );
        aTitleSize.setHeight( (aClassicLPos.Y() + aClassicLSize.Height()) - aClassicTPos.Y() );
    }
    else
    {
        aTitlePos.AdjustX( long( aTitleSize.Width() * 0.0735 ) );
        aTitlePos.AdjustY( long( aTitleSize.Height() * 0.083 ) );
        aTitleSize.setWidth( long( aTitleSize.Width() * 0.854 ) );
        aTitleSize.setHeight( 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.AdjustX( long( aLayoutSize.Width() * 0.0735 ) );
        aLayoutPos.AdjustY( long( aLayoutSize.Height() * 0.472 ) );
        aLayoutSize.setWidth( long( aLayoutSize.Width() * 0.854 ) );
        aLayoutSize.setHeight( long( aLayoutSize.Height() * 0.444 ) );
    }
    else if((mnType >= 22 && mnType <= 26) || (mnType == 31)) // 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 if(mnType == AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT || mnType == AUTOLAYOUT_VTITLE_VCONTENT)
    {
        Point aClassicTPos(
            aTitlePos.X() + long( aTitleSize.Width() * 0.0735 ),
            aTitlePos.Y() + long( aTitleSize.Height() * 0.083 ));
        Size aClassicTSize(
            long( aTitleSize.Width() * 0.854 ),
            long( aTitleSize.Height() * 0.167 ));
        Point aClassicLPos(
            aLayoutPos.X() + long( aLayoutSize.Width() * 0.0735 ),
            aLayoutPos.Y() + long( aLayoutSize.Height() * 0.472 ));
        Size aClassicLSize(
            long( aLayoutSize.Width() * 0.854 ),
            long( aLayoutSize.Height() * 0.444 ));

        aLayoutPos.setX( aClassicLPos.X() );
        aLayoutPos.setY( aClassicTPos.Y() );
        aLayoutSize.setWidth( (aClassicLPos.X() + aClassicLSize.Width())
            - (aClassicTSize.Height() + (aClassicLPos.Y() - (aClassicTPos.Y() + aClassicTSize.Height()))));
        aLayoutSize.setHeight( (aClassicLPos.Y() + aClassicLSize.Height()) - aClassicTPos.Y() );
    }
    else if( mnType == AUTOLAYOUT_ONLY_TEXT )
    {
        aLayoutPos = aTitlePos;
        aLayoutSize.setWidth( aTitleSize.Width() );
        aLayoutSize.setHeight( long( aLayoutSize.Height() * 0.825 ) );
    }
    else
    {
        aLayoutPos.AdjustX( long( aLayoutSize.Width() * 0.0735 ) );
        aLayoutPos.AdjustY( long( aLayoutSize.Height() * 0.278 ) );
        aLayoutSize.setWidth( long( aLayoutSize.Width() * 0.854 ) );
        aLayoutSize.setHeight( long( aLayoutSize.Height() * 0.630 ) );
    }

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

static const OUStringLiteral gsPageLayoutNames( "PageLayoutNames" );

SdXMLExport::SdXMLExport(
    const css::uno::Reference< css::uno::XComponentContext >& xContext,
    OUString const & implementationName,
    bool bIsDraw, SvXMLExportFlags nExportFlags )
:   SvXMLExport( util::MeasureUnit::CM, xContext, implementationName,
        bIsDraw ? XML_GRAPHICS : XML_PRESENTATION, nExportFlags ),
    mnDocMasterPageCount(0),
    mnDocDrawPageCount(0),
    mnObjectCount(0),
    mpHandoutPageMaster(nullptr),
    mbIsDraw(bIsDraw)
{

}

// XExporter
void SAL_CALL SdXMLExport::setSourceDocument( const Reference< lang::XComponent >& xDoc )
{
    SvXMLExport::setSourceDocument( xDoc );

    // prepare factory parts
    mpSdPropHdlFactory = new XMLSdPropHdlFactory( GetModel(), *this );

    // construct PropertySetMapper
    rtl::Reference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( mpSdPropHdlFactory.get(), true);

    // get or create text paragraph export
    GetTextParagraphExport();
    mpPropertySetMapper = new XMLShapeExportPropertyMapper( xMapper, *this );

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

    // construct PresPagePropsMapper
    xMapper = new XMLPropertySetMapper(aXMLSDPresPageProps, mpSdPropHdlFactory.get(), true);

    mpPresPagePropsMapper = new XMLPageExportPropertyMapper( xMapper, *this  );

    // add family name
    GetAutoStylePool()->AddFamily(
        XmlStyleFamily::SD_GRAPHICS_ID,
        OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME),
          GetPropertySetMapper(),
          OUString(XML_STYLE_FAMILY_SD_GRAPHICS_PREFIX));
    GetAutoStylePool()->AddFamily(
        XmlStyleFamily::SD_PRESENTATION_ID,
        OUString(XML_STYLE_FAMILY_SD_PRESENTATION_NAME),
          GetPropertySetMapper(),
          OUString(XML_STYLE_FAMILY_SD_PRESENTATION_PREFIX));
    GetAutoStylePool()->AddFamily(
        XmlStyleFamily::SD_DRAWINGPAGE_ID,
        OUString(XML_STYLE_FAMILY_SD_DRAWINGPAGE_NAME),
          GetPresPagePropsMapper(),
          OUString(XML_STYLE_FAMILY_SD_DRAWINGPAGE_PREFIX));
    // prepare access to styles
    Reference< style::XStyleFamiliesSupplier > xFamSup( GetModel(), UNO_QUERY );
    if(xFamSup.is())
    {
        mxDocStyleFamilies = xFamSup->getStyleFamilies();
    }

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

    // prepare access to draw pages
    Reference <XDrawPagesSupplier> xDrawPagesSupplier(GetModel(), UNO_QUERY);
    if(xDrawPagesSupplier.is())
    {
        mxDocDrawPages = xDrawPagesSupplier->getDrawPages();
        if(mxDocDrawPages.is())
        {
            mnDocDrawPageCount = mxDocDrawPages->getCount();
            maDrawPagesStyleNames.insert( maDrawPagesStyleNames.begin(), mnDocDrawPageCount, "" );
            maDrawNotesPagesStyleNames.insert( maDrawNotesPagesStyleNames.begin(), mnDocDrawPageCount, "" );
            if( !mbIsDraw )
                maDrawPagesAutoLayoutNames.realloc( mnDocDrawPageCount + 1 );

            HeaderFooterPageSettingsImpl aEmptySettings;
            maDrawPagesHeaderFooterSettings.insert( maDrawPagesHeaderFooterSettings.begin(), mnDocDrawPageCount, aEmptySettings );
            maDrawNotesPagesHeaderFooterSettings.insert( maDrawNotesPagesHeaderFooterSettings.begin(), mnDocDrawPageCount, aEmptySettings );
        }
    }

    // #82003# count all draw objects for use with progress bar.
    // #88245# init mnObjectCount once, use counter itself as flag. It
    // is initialized to 0.
    if(!mnObjectCount)
    {
        if( IsImpress() )
        {
             // #91587# add handout master count
            Reference<presentation::XHandoutMasterSupplier> xHandoutSupp(GetModel(), UNO_QUERY);
            if(xHandoutSupp.is())
            {
                Reference<XDrawPage> xHandoutPage(xHandoutSupp->getHandoutMasterPage());
                if(xHandoutPage.is() && xHandoutPage->getCount())
                    mnObjectCount += ImpRecursiveObjectCount(xHandoutPage);
            }
        }

        if(mxDocMasterPages.is())
        {
            for(sal_Int32 a(0); a < mnDocMasterPageCount; a++)
            {
                Any aAny(mxDocMasterPages->getByIndex(a));
                Reference< drawing::XShapes > xMasterPage;

                if((aAny >>= xMasterPage) && xMasterPage.is())
                {
                    mnObjectCount += ImpRecursiveObjectCount(xMasterPage);
                }

                if( IsImpress() )
                {
                    // #91587# take notes pages from master pages into account
                    Reference<presentation::XPresentationPage> xPresPage;
                    if((aAny >>= xPresPage) && xPresPage.is())
                    {
                        Reference<XDrawPage> xNotesPage(xPresPage->getNotesPage());
                        if(xNotesPage.is() && xNotesPage->getCount())
                            mnObjectCount += ImpRecursiveObjectCount(xNotesPage);
                    }
                }
            }
        }

        if(mxDocDrawPages.is())
        {
            for(sal_Int32 a(0); a < mnDocDrawPageCount; a++)
            {
                Any aAny(mxDocDrawPages->getByIndex(a));
                Reference< drawing::XShapes > xPage;

                if((aAny >>= xPage) && xPage.is())
                {
                    mnObjectCount += ImpRecursiveObjectCount(xPage);
                }

                if( IsImpress() )
                {
                    // #91587# take notes pages from draw pages into account
                    Reference<presentation::XPresentationPage> xPresPage;
                    if((aAny >>= xPresPage) && xPresPage.is())
                    {
                        Reference<XDrawPage> xNotesPage(xPresPage->getNotesPage());
                        if(xNotesPage.is() && xNotesPage->getCount())
                            mnObjectCount += ImpRecursiveObjectCount(xNotesPage);
                    }
                }
            }
        }

        // #82003# init progress bar
        GetProgressBarHelper()->SetReference(mnObjectCount);
    }

    // add namespaces
    GetNamespaceMap_().Add(
        GetXMLToken(XML_NP_PRESENTATION),
        GetXMLToken(XML_N_PRESENTATION),
        XML_NAMESPACE_PRESENTATION);

    GetNamespaceMap_().Add(
        GetXMLToken(XML_NP_SMIL),
        GetXMLToken(XML_N_SMIL_COMPAT),
        XML_NAMESPACE_SMIL);

    GetNamespaceMap_().Add(
        GetXMLToken(XML_NP_ANIMATION),
        GetXMLToken(XML_N_ANIMATION),
        XML_NAMESPACE_ANIMATION);

    if (getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED)
    {
        GetNamespaceMap_().Add(
            GetXMLToken(XML_NP_OFFICE_EXT),
            GetXMLToken(XML_N_OFFICE_EXT),
            XML_NAMESPACE_OFFICE_EXT);
    }

    GetShapeExport()->enableLayerExport();

    // #88546# enable progress bar increments
    GetShapeExport()->enableHandleProgressBar();
}

// #82003# helper function for recursive object count
sal_uInt32 SdXMLExport::ImpRecursiveObjectCount(const Reference< drawing::XShapes >& xShapes)
{
    sal_uInt32 nRetval(0);

    if(xShapes.is())
    {
        sal_Int32 nCount = xShapes->getCount();

        for(sal_Int32 a(0); a < nCount; a++)
        {
            Any aAny(xShapes->getByIndex(a));
            Reference< drawing::XShapes > xGroup;

            if((aAny >>= xGroup) && xGroup.is())
            {
                // #93180# count group objects, too.
                nRetval += 1 + ImpRecursiveObjectCount(xGroup);
            }
            else
            {
                nRetval++;
            }
        }
    }

    return nRetval;
}

SdXMLExport::~SdXMLExport()
{
    // cleanup factory, decrease refcount. Should lead to destruction.
    mpSdPropHdlFactory.clear();

    // cleanup mapper, decrease refcount. Should lead to destruction.
    mpPropertySetMapper.clear();

    // cleanup presPage mapper, decrease refcount. Should lead to destruction.
    mpPresPagePropsMapper.clear();

    mvPageMasterInfoList.clear();

    // clear auto-layout infos
    mvAutoLayoutInfoList.clear();
}

void SdXMLExport::ImpPrepAutoLayoutInfos()
{
    if(IsImpress())
    {
        OUString aStr;

        Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
        if( xHandoutSupp.is() )
        {
            Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
            if( xHandoutPage.is() )
            {
                if(ImpPrepAutoLayoutInfo(xHandoutPage, aStr))
                    maDrawPagesAutoLayoutNames[0] = aStr;
            }
        }

        // prepare name creation
        for (sal_Int32 nCnt = 0; nCnt < mnDocDrawPageCount; nCnt++)
        {
            Any aAny(mxDocDrawPages->getByIndex(nCnt));
            Reference<XDrawPage> xDrawPage;

            if((aAny >>= xDrawPage) && xDrawPage.is())
            {
                if(ImpPrepAutoLayoutInfo(xDrawPage, aStr))
                    maDrawPagesAutoLayoutNames[nCnt+1] = aStr;
            }
        }
    }
}

bool SdXMLExport::ImpPrepAutoLayoutInfo(const Reference<XDrawPage>& xPage, OUString& rName)
{
    rName.clear();
    bool bRetval(false);

    Reference <beans::XPropertySet> xPropSet(xPage, UNO_QUERY);
    if(xPropSet.is())
    {
        sal_uInt16 nType = sal_uInt16();
        Any aAny = xPropSet->getPropertyValue("Layout");
        if(aAny >>= nType)<--- Variable 'aAny' is assigned a value that is never used.
        {
            if(ImpXMLAutoLayoutInfo::IsCreateNecessary(nType))
            {
                ImpXMLEXPPageMasterInfo* pInfo = nullptr;

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

                // create entry and look for existence
                ImpXMLAutoLayoutInfo* pNew;
                auto it = std::find_if(mvAutoLayoutInfoList.begin(), mvAutoLayoutInfoList.end(),
                            [=](std::unique_ptr<ImpXMLAutoLayoutInfo> const & rInfo) { return nType == rInfo->GetLayoutType() && pInfo == rInfo->GetPageMasterInfo(); });
                if (it != mvAutoLayoutInfoList.end())
                {
                    pNew = it->get();
                }
                else
                {
                    pNew = new ImpXMLAutoLayoutInfo(nType, pInfo);
                    mvAutoLayoutInfoList.emplace_back( pNew );
                    OUString sNewName =
                        "AL" + OUString::number(mvAutoLayoutInfoList.size() - 1) +
                        "T" + OUString::number(nType);
                    pNew->SetLayoutName(sNewName);
                }

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

    return bRetval;
}

void SdXMLExport::ImpWriteAutoLayoutInfos()
{
    for(const auto & pInfo : mvAutoLayoutInfoList)
    {
        if(pInfo)
        {
            // prepare presentation-page layout attributes, style-name
            AddAttribute(XML_NAMESPACE_STYLE, XML_NAME, pInfo->GetLayoutName());

            // write draw-style attributes
            SvXMLElementExport aDSE(*this, XML_NAMESPACE_STYLE, XML_PRESENTATION_PAGE_LAYOUT, true, true);

            // write presentation placeholders
            switch(pInfo->GetLayoutType())
            {
                case AUTOLAYOUT_TITLE :
                {
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderSubtitle, pInfo->GetPresRectangle());
                    break;
                }
                case AUTOLAYOUT_TITLE_CONTENT :
                {
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, pInfo->GetPresRectangle());
                    break;
                }
                case AUTOLAYOUT_CHART :
                {
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, pInfo->GetPresRectangle());
                    break;
                }
                case AUTOLAYOUT_TITLE_2CONTENT :
                {
                    tools::Rectangle aLeft(pInfo->GetPresRectangle());
                    aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
                    tools::Rectangle aRight(aLeft);
                    aRight.SetLeft(long(aRight.Left() + aRight.GetWidth() * 1.05));

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

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

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

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

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

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

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

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

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

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

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

                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderOutline, aTop);
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderObject, aBottom);
                    break;
                }
                case AUTOLAYOUT_TITLE_4CONTENT :
                {
                    tools::Rectangle aTopLeft(pInfo->GetPresRectangle());
                    aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
                    aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.488));
                    tools::Rectangle aBottomLeft(aTopLeft);
                    aBottomLeft.SetTop(long(aBottomLeft.Top() + aBottomLeft.GetHeight() * 1.095));
                    tools::Rectangle aTopRight(aTopLeft);
                    aTopRight.SetLeft(long(aTopRight.Left() + aTopRight.GetWidth() * 1.05));
                    tools::Rectangle aBottomRight(aTopRight);
                    aBottomRight.SetTop(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 AUTOLAYOUT_TITLE_ONLY :
                {
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                    break;
                }
                case AUTOLAYOUT_NOTES :
                {
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderPage, pInfo->GetTitleRectangle());
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderNotes, pInfo->GetPresRectangle());
                    break;
                }
                case AUTOLAYOUT_HANDOUT1 :
                case AUTOLAYOUT_HANDOUT2 :
                case AUTOLAYOUT_HANDOUT3 :
                case AUTOLAYOUT_HANDOUT4 :
                case AUTOLAYOUT_HANDOUT6 :
                case AUTOLAYOUT_HANDOUT9 :
                {
                    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 = 2; break;
                        case 31 : nColCnt = 3; nRowCnt = 3; break;
                        default:  nColCnt = 0; nRowCnt = 0; break;  // FIXME - What is correct values?
                    }

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

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

                    if (nColCnt == 0 || nRowCnt == 0)
                        break;

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

                    Point aTmpPos(aPartPos);

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

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

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

                        aTmpPos.AdjustY( aPartSize.Height() + nGapY );
                    }
                    break;
                }
                case AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT :
                {
                    tools::Rectangle aTop(pInfo->GetPresRectangle());
                    aTop.setHeight(long(aTop.GetHeight() * 0.488));
                    tools::Rectangle aBottom(aTop);
                    aBottom.SetTop(long(aBottom.Top() + aBottom.GetHeight() * 1.05));

                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalTitle, pInfo->GetTitleRectangle());
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, aTop);
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderChart, aBottom);
                    break;
                }
                case AUTOLAYOUT_VTITLE_VCONTENT :
                {
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalTitle, pInfo->GetTitleRectangle());
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, pInfo->GetPresRectangle());
                    break;
                }
                case AUTOLAYOUT_TITLE_VCONTENT :
                {
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, pInfo->GetPresRectangle());
                    break;
                }
                case AUTOLAYOUT_TITLE_2VTEXT :
                {
                    tools::Rectangle aLeft(pInfo->GetPresRectangle());
                    aLeft.setWidth(long(aLeft.GetWidth() * 0.488));
                    tools::Rectangle aRight(aLeft);
                    aRight.SetLeft(long(aRight.Left() + aRight.GetWidth() * 1.05));

                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aLeft);
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderVerticalOutline, aRight);
                    break;
                }
                case AUTOLAYOUT_ONLY_TEXT :
                {
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderSubtitle, pInfo->GetPresRectangle());
                    break;
                }

                case AUTOLAYOUT_4CLIPART :
                {
                    tools::Rectangle aTopLeft(pInfo->GetPresRectangle());
                    aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
                    aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.488));
                    tools::Rectangle aBottomLeft(aTopLeft);
                    aBottomLeft.SetTop(long(aBottomLeft.Top() + aBottomLeft.GetHeight() * 1.095));
                    tools::Rectangle aTopRight(aTopLeft);
                    aTopRight.SetLeft(long(aTopRight.Left() + aTopRight.GetWidth() * 1.05));
                    tools::Rectangle aBottomRight(aTopRight);
                    aBottomRight.SetTop(long(aBottomRight.Top() + aBottomRight.GetHeight() * 1.095));

                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopLeft);
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopRight);
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomLeft);
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomRight);
                    break;
                }

                case AUTOLAYOUT_TITLE_6CONTENT :
                {
                    tools::Rectangle aTopLeft(pInfo->GetPresRectangle());
                    aTopLeft.setHeight(long(aTopLeft.GetHeight() * 0.477));
                    aTopLeft.setWidth(long(aTopLeft.GetWidth() * 0.322));
                    tools::Rectangle aTopCenter(aTopLeft);
                    aTopCenter.SetLeft(long(aTopCenter.Left() + aTopCenter.GetWidth() * 1.05));
                    tools::Rectangle aTopRight(aTopLeft);
                    aTopRight.SetLeft(long(aTopRight.Left() + aTopRight.GetWidth() * 2 * 1.05));

                    tools::Rectangle aBottomLeft(aTopLeft);
                    aBottomLeft.SetTop(long(aBottomLeft.Top() + aBottomLeft.GetHeight() * 1.095));
                    tools::Rectangle aBottomCenter(aTopCenter);
                    aBottomCenter.SetTop(long(aBottomCenter.Top() + aBottomCenter.GetHeight() * 1.095));
                    tools::Rectangle aBottomRight(aTopRight);
                    aBottomRight.SetTop(long(aBottomRight.Top() + aBottomRight.GetHeight() * 1.095));

                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderTitle, pInfo->GetTitleRectangle());
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopLeft);
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopCenter);
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aTopRight);
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomLeft);
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomCenter);
                    ImpWriteAutoLayoutPlaceholder(XmlPlaceholderGraphic, aBottomRight);
                    break;
                }
                default:
                {
                    OSL_FAIL("XMLEXP: unknown autolayout export");
                    break;
                }
            }
        }
    }
}

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

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

    AddAttribute(XML_NAMESPACE_PRESENTATION, XML_OBJECT, aStr);

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

    GetMM100UnitConverter().convertMeasureToXML(sStringBuffer, rRect.Top());
    aStr = sStringBuffer.makeStringAndClear();
    AddAttribute(XML_NAMESPACE_SVG, XML_Y, aStr);

    GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
            rRect.GetWidth());
    aStr = sStringBuffer.makeStringAndClear();
    AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, aStr);

    GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
            rRect.GetHeight());
    aStr = sStringBuffer.makeStringAndClear();
    AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, aStr);

    // write presentation-placeholder
    SvXMLElementExport aPPL(*this, XML_NAMESPACE_PRESENTATION, XML_PLACEHOLDER, true, true);
}

ImpXMLEXPPageMasterInfo* SdXMLExport::ImpGetOrCreatePageMasterInfo( const Reference< XDrawPage >& xMasterPage )
{
    bool bDoesExist = false;

    ImpXMLEXPPageMasterInfo* pNewInfo = new ImpXMLEXPPageMasterInfo(*this, xMasterPage);

    // compare with prev page-master infos
    for( size_t a = 0; !bDoesExist && a < mvPageMasterInfoList.size(); a++)
    {
        if (   mvPageMasterInfoList.at(a)
           && *mvPageMasterInfoList.at(a) == *pNewInfo
           )
        {
            delete pNewInfo;
            pNewInfo = mvPageMasterInfoList.at(a).get();
            bDoesExist = true;
        }
    }
    // add entry when not found same page-master infos
    if(!bDoesExist)
        mvPageMasterInfoList.emplace_back( pNewInfo );

    return pNewInfo;
}

void SdXMLExport::ImpPrepPageMasterInfos()
{
    if( IsImpress() )
    {
        // create page master info for handout master page

        Reference< XHandoutMasterSupplier > xHMS( GetModel(), UNO_QUERY );
        if( xHMS.is() )
        {
            Reference< XDrawPage > xMasterPage( xHMS->getHandoutMasterPage() );
            if( xMasterPage.is() )
                mpHandoutPageMaster = ImpGetOrCreatePageMasterInfo(xMasterPage);
        }
    }

    // create page master infos for master pages
    if(mnDocMasterPageCount)
    {
        // look for needed page-masters, create these
        for (sal_Int32 nMPageId = 0; nMPageId < mnDocMasterPageCount; nMPageId++)
        {
            Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );
            ImpXMLEXPPageMasterInfo* pNewInfo = nullptr;

            if(xMasterPage.is())
                pNewInfo = ImpGetOrCreatePageMasterInfo(xMasterPage);

            mvPageMasterUsageList.push_back( pNewInfo );

            // look for page master of handout page
            if(IsImpress())
            {
                pNewInfo = nullptr;
                Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
                if(xPresPage.is())
                {
                    Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
                    if(xNotesPage.is())
                    {
                        pNewInfo = ImpGetOrCreatePageMasterInfo(xNotesPage);
                    }
                }
                mvNotesPageMasterUsageList.push_back( pNewInfo );
            }
        }
    }
}

void SdXMLExport::ImpWritePageMasterInfos()
{
    // write created page-masters, create names for these
    for( size_t nCnt = 0; nCnt < mvPageMasterInfoList.size(); nCnt++)
    {
        ImpXMLEXPPageMasterInfo* pInfo = mvPageMasterInfoList.at(nCnt).get();
        if(pInfo)
        {
            // create name
            OUString sNewName = "PM" + OUString::number(nCnt);
            pInfo->SetName(sNewName);

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

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

            // write page-layout
            SvXMLElementExport aPME(*this, XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT, true, true);

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

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

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

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

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

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

            if(pInfo->GetOrientation() == view::PaperOrientation_PORTRAIT)
                AddAttribute(XML_NAMESPACE_STYLE, XML_PRINT_ORIENTATION, XML_PORTRAIT);
            else
                AddAttribute(XML_NAMESPACE_STYLE, XML_PRINT_ORIENTATION, XML_LANDSCAPE);

            // write style:properties
            SvXMLElementExport aPMF(*this, XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_PROPERTIES, true, true);
        }
    }
}

ImpXMLEXPPageMasterInfo* SdXMLExport::ImpGetPageMasterInfoByName(const OUString& rName)
{
    if(!rName.isEmpty())
    {
        for(const auto & pInfo : mvPageMasterInfoList)
        {
            if(pInfo)
            {
                if(!pInfo->GetMasterPageName().isEmpty() && rName == pInfo->GetMasterPageName())
                {
                    return pInfo.get();
                }
            }
        }
    }
    return nullptr;
}

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)

    sal_Int32 nCnt;
    for(nCnt = 0; nCnt < mnDocDrawPageCount; nCnt++)
    {
        Reference<XDrawPage> xDrawPage;
        mxDocDrawPages->getByIndex(nCnt) >>= xDrawPage;
        maDrawPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xDrawPage );

        Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
        if(xPresPage.is())
        {
            maDrawNotesPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xPresPage->getNotesPage(), false );

            maDrawPagesHeaderFooterSettings[nCnt] = ImpPrepDrawPageHeaderFooterDecls( xDrawPage );
            maDrawNotesPagesHeaderFooterSettings[nCnt] = ImpPrepDrawPageHeaderFooterDecls( xPresPage->getNotesPage() );
        }
    }
}

static OUString findOrAppendImpl( std::vector< OUString >& rVector, const OUString& rText, const char* pPrefix )
{
    // search rVector if there is already a string that equals rText
    auto aIter = std::find(rVector.begin(), rVector.end(), rText);
    sal_Int32 nIndex = std::distance(rVector.begin(), aIter) + 1;

    // if nothing is found, append the string at the end of rVector
    if( aIter == rVector.end() )
        rVector.push_back( rText );

    // create a reference string with pPrefix and the index of the
    // found or created rText
    return OUString::createFromAscii( pPrefix ) + OUString::number( nIndex );
}

static OUString findOrAppendImpl( std::vector< DateTimeDeclImpl >& rVector, const OUString& rText, bool bFixed, sal_Int32 nFormat, const char* pPrefix )
{
    // search rVector if there is already a DateTimeDeclImpl with rText,bFixed and nFormat
    auto aIter = std::find_if(rVector.begin(), rVector.end(),
        [bFixed, &rText, nFormat](const DateTimeDeclImpl& rDecl) {
            return (rDecl.mbFixed == bFixed) &&
                (!bFixed || (rDecl.maStrText == rText)) &&
                (bFixed || (rDecl.mnFormat == nFormat));
        });
    sal_Int32 nIndex = std::distance(rVector.begin(), aIter) + 1;

    // if nothing is found, append a new DateTimeDeclImpl
    if( aIter == rVector.end() )
    {
        DateTimeDeclImpl aDecl;
        aDecl.maStrText = rText;
        aDecl.mbFixed = bFixed;
        aDecl.mnFormat = nFormat;
        rVector.push_back( aDecl );
    }

    // create a reference string with pPrefix and the index of the
    // found or created DateTimeDeclImpl
    return OUString::createFromAscii( pPrefix ) + OUString::number( nIndex );
}

static const char gpStrHeaderTextPrefix[] = "hdr";
static const char gpStrFooterTextPrefix[] = "ftr";
static const char gpStrDateTimeTextPrefix[] = "dtd";

HeaderFooterPageSettingsImpl SdXMLExport::ImpPrepDrawPageHeaderFooterDecls( const Reference<XDrawPage>& xDrawPage )
{
    HeaderFooterPageSettingsImpl aSettings;

    if( xDrawPage.is() ) try
    {
        Reference< XPropertySet > xSet( xDrawPage, UNO_QUERY_THROW );
        Reference< XPropertySetInfo > xInfo( xSet->getPropertySetInfo() );

        OUString aStrText;

        const OUString aStrHeaderTextProp( "HeaderText" );
        if( xInfo->hasPropertyByName( aStrHeaderTextProp ) )
        {
            xSet->getPropertyValue( aStrHeaderTextProp  ) >>= aStrText;
            if( !aStrText.isEmpty() )
                aSettings.maStrHeaderDeclName = findOrAppendImpl( maHeaderDeclsVector, aStrText, gpStrHeaderTextPrefix );
        }

        const OUString aStrFooterTextProp( "FooterText" );
        if( xInfo->hasPropertyByName( aStrFooterTextProp ) )
        {
            xSet->getPropertyValue( aStrFooterTextProp ) >>= aStrText;
            if( !aStrText.isEmpty() )
                aSettings.maStrFooterDeclName = findOrAppendImpl( maFooterDeclsVector, aStrText, gpStrFooterTextPrefix );
        }

        const OUString aStrDateTimeTextProp( "DateTimeText" );
        if( xInfo->hasPropertyByName( aStrDateTimeTextProp ) )
        {
            bool bFixed = false;<--- Assignment 'bFixed=false', assigned value is 0<--- Assignment 'bFixed=false', assigned value is 0
            sal_Int32 nFormat = 0;
            xSet->getPropertyValue( aStrDateTimeTextProp ) >>= aStrText;
            xSet->getPropertyValue("IsDateTimeFixed") >>= bFixed;
            xSet->getPropertyValue("DateTimeFormat") >>= nFormat;

            if( !bFixed || !aStrText.isEmpty() )<--- Condition '!bFixed' is always true
            {
                aSettings.maStrDateTimeDeclName = findOrAppendImpl( maDateTimeDeclsVector, aStrText, bFixed, nFormat, gpStrDateTimeTextPrefix );
                if( !bFixed )<--- Condition '!bFixed' is always true
                    addDataStyle( nFormat );
            }
        }
    }
    catch(const Exception&)
    {
        OSL_FAIL( "SdXMLExport::ImpPrepDrawPageHeaderFooterDecls(), unexpected exception caught!" );
    }

    return aSettings;
}

void SdXMLExport::ImpWriteHeaderFooterDecls()
{
    OUStringBuffer sBuffer;

    if( !maHeaderDeclsVector.empty() )
    {
        // export header decls
        const OUString aPrefix( gpStrHeaderTextPrefix );
        sal_Int32 nIndex = 1;
        for( const auto& rDecl : maHeaderDeclsVector )
        {
            sBuffer.append( aPrefix );
            sBuffer.append( nIndex );
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());

            SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_HEADER_DECL, true, true);
            Characters(rDecl);
            ++nIndex;
        }
    }

    if( !maFooterDeclsVector.empty() )
    {
        // export footer decls
        const OUString aPrefix( gpStrFooterTextPrefix );
        sal_Int32 nIndex = 1;
        for( const auto& rDecl : maFooterDeclsVector )
        {
            sBuffer.append( aPrefix );
            sBuffer.append( nIndex );
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());

            SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_FOOTER_DECL, false, false);
            Characters(rDecl);
            ++nIndex;
        }
    }

    if( !maDateTimeDeclsVector.empty() )
    {
        // export footer decls
        const OUString aPrefix( gpStrDateTimeTextPrefix );
        sal_Int32 nIndex = 1;
        for( const auto& rDecl : maDateTimeDeclsVector )
        {
            sBuffer.append( aPrefix );
            sBuffer.append( nIndex );
            AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear());

            AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SOURCE, rDecl.mbFixed ? XML_FIXED : XML_CURRENT_DATE );

            if( !rDecl.mbFixed )
                AddAttribute( XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, getDataStyleName( rDecl.mnFormat ) );

            SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_DATE_TIME_DECL, false, false);
            if( rDecl.mbFixed )
                Characters(rDecl.maStrText);

            ++nIndex;
        }
    }
}

void SdXMLExport::ImplExportHeaderFooterDeclAttributes( const HeaderFooterPageSettingsImpl& aSettings )
{
    if( !aSettings.maStrHeaderDeclName.isEmpty() )
        AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_HEADER_NAME, aSettings.maStrHeaderDeclName );

    if( !aSettings.maStrFooterDeclName.isEmpty() )
        AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_FOOTER_NAME, aSettings.maStrFooterDeclName );

    if( !aSettings.maStrDateTimeDeclName.isEmpty() )
        AddAttribute( XML_NAMESPACE_PRESENTATION, XML_USE_DATE_TIME_NAME, aSettings.maStrDateTimeDeclName );
}

OUString SdXMLExport::ImpCreatePresPageStyleName( const Reference<XDrawPage>& xDrawPage, bool bExportBackground /* = true */ )
{
    // create name
    OUString sStyleName;

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

    Reference< beans::XPropertySet > xPropSet1(xDrawPage, UNO_QUERY);
    if(xPropSet1.is())
    {
        Reference< beans::XPropertySet > xPropSet;

        if( bExportBackground )
        {
            // 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("Background");
            Reference< beans::XPropertySet > xPropSet2;
            Reference< beans::XPropertySetInfo > xInfo( xPropSet1->getPropertySetInfo() );
            if( xInfo.is() && xInfo->hasPropertyByName( aBackground ) )
            {
                Any aAny( xPropSet1->getPropertyValue( aBackground ) );
                aAny >>= xPropSet2;<--- Variable 'aAny' is assigned a value that is never used.
            }

            if( xPropSet2.is() )
                xPropSet = PropertySetMerger_CreateInstance( xPropSet1, xPropSet2 );
            else
                xPropSet = xPropSet1;
        }
        else
        {
            xPropSet = xPropSet1;
        }

        const rtl::Reference< SvXMLExportPropertyMapper > aMapperRef( GetPresPagePropsMapper() );

        std::vector< XMLPropertyState > aPropStates( aMapperRef->Filter( xPropSet ) );

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

            if(sStyleName.isEmpty())
            {
                // Style did not exist, add it to AutoStalePool
                sStyleName = GetAutoStylePool()->Add(XmlStyleFamily::SD_DRAWINGPAGE_ID, sStyleName, aPropStates);
            }
        }
    }

    return sStyleName;
}

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)

    sal_Int32 nCnt;
    for( nCnt = 0; nCnt < mnDocMasterPageCount; nCnt++)
    {
        Reference<XDrawPage> xDrawPage;
        mxDocMasterPages->getByIndex(nCnt) >>= xDrawPage;
        maMasterPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xDrawPage );
    }

    if( IsImpress() )
    {
        Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
        if( xHandoutSupp.is() )
        {
            Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
            if( xHandoutPage.is() )
            {
                maHandoutPageHeaderFooterSettings = ImpPrepDrawPageHeaderFooterDecls( xHandoutPage );
                maHandoutMasterStyleName = ImpCreatePresPageStyleName( xHandoutPage, false );
            }
        }
    }
}

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

            if(aAny >>= xNamed)
            {
                // write presentation styles (ONLY if presentation)
                if(IsImpress() && mxDocStyleFamilies.is() && xNamed.is())
                {
                    rtl::Reference<XMLStyleExport> aStEx(new XMLStyleExport(*this, GetAutoStylePool().get()));
                    const rtl::Reference< SvXMLExportPropertyMapper > aMapperRef( GetPropertySetMapper() );

                    OUString aPrefix( xNamed->getName() + "-" );

                    aStEx->exportStyleFamily(xNamed->getName(),
                        OUString(XML_STYLE_FAMILY_SD_PRESENTATION_NAME),
                        aMapperRef, false,
                        XmlStyleFamily::SD_PRESENTATION_ID, &aPrefix);
                }
            }
        }
    }
}

void SdXMLExport::ExportMeta_()
{
    uno::Sequence<beans::NamedValue> stats { { "ObjectCount", uno::makeAny(mnObjectCount) } };

    // update document statistics at the model
    uno::Reference<document::XDocumentPropertiesSupplier> xPropSup(GetModel(),
        uno::UNO_QUERY_THROW);
    uno::Reference<document::XDocumentProperties> xDocProps(
        xPropSup->getDocumentProperties());
    if (xDocProps.is()) {
        xDocProps->setDocumentStatistics(stats);
    }

    // call parent
    SvXMLExport::ExportMeta_();
}

void SdXMLExport::ExportFontDecls_()
{
    GetFontAutoStylePool(); // make sure the pool is created
    SvXMLExport::ExportFontDecls_();
}

void SdXMLExport::ExportContent_()
{
    // export <pres:header-decl>, <pres:footer-decl> and <pres:date-time-decl> elements
    ImpWriteHeaderFooterDecls();

    // page export
    for(sal_Int32 nPageInd(0); nPageInd < mnDocDrawPageCount; nPageInd++)
    {
        uno::Reference<drawing::XDrawPage> xDrawPage( mxDocDrawPages->getByIndex(nPageInd), uno::UNO_QUERY );

        // set progress view
        if(GetStatusIndicator().is())
            GetStatusIndicator()->setValue(((nPageInd + 1) * 100) / mnDocDrawPageCount);

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

            // draw:style-name (presentation page attributes AND background attributes)
            if( !maDrawPagesStyleNames[nPageInd].isEmpty() )
                AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME,
                        maDrawPagesStyleNames[nPageInd]);

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

            // presentation:page-layout-name
            if( IsImpress() && !maDrawPagesAutoLayoutNames[nPageInd+1].isEmpty())
            {
                AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, maDrawPagesAutoLayoutNames[nPageInd+1] );
            }

            Reference< beans::XPropertySet > xProps( xDrawPage, UNO_QUERY );
            if( xProps.is() )
            {
                try
                {
                    OUString aBookmarkURL;
                    xProps->getPropertyValue("BookmarkURL") >>= aBookmarkURL;

                    if( !aBookmarkURL.isEmpty() )
                    {
                        sal_Int32 nIndex = aBookmarkURL.lastIndexOf( '#' );
                        if( nIndex != -1 )
                        {
                            OUString aFileName( aBookmarkURL.copy( 0, nIndex ) );
                            OUString aBookmarkName( aBookmarkURL.copy( nIndex+1 ) );

                            aBookmarkURL = GetRelativeReference( aFileName ) + "#" + aBookmarkName;
                        }

                        AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, aBookmarkURL);
                        AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
                        AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_REPLACE );
                        AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
                    }
                }
                catch(const Exception&)
                {
                    OSL_FAIL(" no \"BookmarkURL\" property at page?" );
                }
            }

            if( IsImpress() )
                ImplExportHeaderFooterDeclAttributes( maDrawPagesHeaderFooterSettings[nPageInd] );

            OUString sNavigationOrder( getNavigationOrder( xDrawPage ) );
            if( !sNavigationOrder.isEmpty() )
                AddAttribute ( XML_NAMESPACE_DRAW, XML_NAV_ORDER, sNavigationOrder );

            rtl::Reference< xmloff::AnimationsExporter >  xAnimationsExporter;
            uno::Reference< css::animations::XAnimationNodeSupplier > xAnimNodeSupplier;

            // prepare animation export
            if(IsImpress())
            {
                if( getExportFlags() & SvXMLExportFlags::OASIS )
                {
                    // export new animations for oasis format
                    xAnimNodeSupplier.set( xDrawPage, UNO_QUERY );

                    // prepare animations exporter if impress
                    if(xAnimNodeSupplier.is())
                    {
                        xAnimationsExporter = new xmloff::AnimationsExporter( *this, xProps );
                        xAnimationsExporter->prepare( xAnimNodeSupplier->getAnimationNode() );
                    }
                }
                else
                {
                    // export old animations for ooo format
                    rtl::Reference< XMLAnimationsExporter > xAnimExport = new XMLAnimationsExporter();
                    GetShapeExport()->setAnimationsExporter( xAnimExport );
                }
            }

            // write draw:id
            const OUString aPageId = getInterfaceToIdentifierMapper().getIdentifier( xDrawPage );
            if( !aPageId.isEmpty() )
            {
                AddAttributeIdLegacy(XML_NAMESPACE_DRAW, aPageId);
            }

            // write page
            SvXMLElementExport aDPG(*this, XML_NAMESPACE_DRAW, XML_PAGE, true, true);

            // write optional office:forms
            exportFormsElement( xDrawPage );

            // write graphic objects on this page (if any)
            if(xDrawPage.is() && xDrawPage->getCount())
                GetShapeExport()->exportShapes( xDrawPage );

            // write animations and presentation notes (ONLY if presentation)
            if(IsImpress())
            {
                if(xAnimNodeSupplier.is())
                {
                    xAnimationsExporter->exportAnimations( xAnimNodeSupplier->getAnimationNode() );
                }
                else
                {
                    // animations
                    rtl::Reference< XMLAnimationsExporter > xAnimExport( GetShapeExport()->getAnimationsExporter() );
                    if( xAnimExport.is() )
                        xAnimExport->exportAnimations( *this );

                    xAnimExport = nullptr;
                    GetShapeExport()->setAnimationsExporter( xAnimExport );
                }

                // presentations
                Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
                if(xPresPage.is())
                {
                    Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
                    if(xNotesPage.is())
                    {
                        if( !maDrawNotesPagesStyleNames[nPageInd].isEmpty() )
                            AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, maDrawNotesPagesStyleNames[nPageInd]);

                        ImplExportHeaderFooterDeclAttributes( maDrawNotesPagesHeaderFooterSettings[nPageInd] );

                        // write presentation notes
                        SvXMLElementExport aPSY(*this, XML_NAMESPACE_PRESENTATION, XML_NOTES, true, true);

                        // write optional office:forms
                        exportFormsElement( xNotesPage );

                        // write shapes per se
                        GetShapeExport()->exportShapes( xNotesPage );
                    }
                }
            }

            exportAnnotations( xDrawPage );
        }
    }

    if( IsImpress() )
        exportPresentationSettings();
}

void SdXMLExport::exportPresentationSettings()
{
    try
    {
        Reference< XPresentationSupplier > xPresSupplier( GetModel(), UNO_QUERY );
        if( !xPresSupplier.is() )
            return;

        Reference< XPropertySet > xPresProps( xPresSupplier->getPresentation(), UNO_QUERY );
        if( !xPresProps.is() )
            return;

        bool bHasAttr = false;

        bool bTemp = false;<--- Assignment 'bTemp=false', assigned value is 0<--- Assignment 'bTemp=false', assigned value is 0

        // export range
        xPresProps->getPropertyValue("IsShowAll") >>= bTemp;
        if( !bTemp )<--- Condition '!bTemp' is always true
        {
            OUString aFirstPage;
            xPresProps->getPropertyValue("FirstPage") >>= aFirstPage;
            if( !aFirstPage.isEmpty() )
            {
                AddAttribute(XML_NAMESPACE_PRESENTATION, XML_START_PAGE, aFirstPage );
                bHasAttr = true;
            }
            else
            {
                OUString aCustomShow;
                xPresProps->getPropertyValue("CustomShow") >>= aCustomShow;
                if( !aCustomShow.isEmpty() )
                {
                    AddAttribute(XML_NAMESPACE_PRESENTATION, XML_SHOW, aCustomShow );
                    bHasAttr = true;
                }
            }
        }

        xPresProps->getPropertyValue("IsEndless") >>= bTemp;
        if( bTemp )<--- Condition 'bTemp' is always false
        {
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_ENDLESS, XML_TRUE );
            bHasAttr = true;

            sal_Int32 nPause = 0;
            xPresProps->getPropertyValue("Pause") >>= nPause;

            util::Duration aDuration;
            aDuration.Seconds = static_cast<sal_uInt16>(nPause);

            OUStringBuffer aOut;
            ::sax::Converter::convertDuration(aOut, aDuration);
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PAUSE, aOut.makeStringAndClear() );
        }

        xPresProps->getPropertyValue("AllowAnimations") >>= bTemp;
        if( !bTemp )
        {
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_ANIMATIONS, XML_DISABLED );
            bHasAttr = true;
        }

        xPresProps->getPropertyValue("IsAlwaysOnTop") >>= bTemp;
        if( bTemp )
        {
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_STAY_ON_TOP, XML_TRUE );
            bHasAttr = true;
        }

        xPresProps->getPropertyValue("IsAutomatic") >>= bTemp;
        if( bTemp )
        {
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_FORCE_MANUAL, XML_TRUE );
            bHasAttr = true;
        }

        xPresProps->getPropertyValue("IsFullScreen") >>= bTemp;
        if( !bTemp )
        {
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_FULL_SCREEN, XML_FALSE );
            bHasAttr = true;
        }

        // We need to always export this attribute, because the import had the wrong default (tdf#108824)
        xPresProps->getPropertyValue("IsMouseVisible") >>= bTemp;
        AddAttribute(XML_NAMESPACE_PRESENTATION, XML_MOUSE_VISIBLE, bTemp ? XML_TRUE : XML_FALSE);
        bHasAttr = true;

        xPresProps->getPropertyValue("StartWithNavigator") >>= bTemp;
        if( bTemp )
        {
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_START_WITH_NAVIGATOR, XML_TRUE );
            bHasAttr = true;
        }

        xPresProps->getPropertyValue("UsePen") >>= bTemp;
        if( bTemp )
        {
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_MOUSE_AS_PEN, XML_TRUE );
            bHasAttr = true;
        }

        xPresProps->getPropertyValue("IsTransitionOnClick") >>= bTemp;
        if( !bTemp )
        {
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_TRANSITION_ON_CLICK, XML_DISABLED );
            bHasAttr = true;
        }

        xPresProps->getPropertyValue("IsShowLogo") >>= bTemp;
        if( bTemp )
        {
            AddAttribute(XML_NAMESPACE_PRESENTATION, XML_SHOW_LOGO, XML_TRUE );
            bHasAttr = true;
        }

        Reference< container::XNameContainer > xShows;
        Sequence< OUString > aShowNames;
        bool bHasNames = false;

        Reference< XCustomPresentationSupplier > xSup( GetModel(), UNO_QUERY );
        if( xSup.is() )
        {
            xShows = xSup->getCustomPresentations();
            if( xShows.is() )
            {
                aShowNames = xShows->getElementNames();
                bHasNames = aShowNames.hasElements();
            }
        }

        if( bHasAttr || bHasNames )
        {
            SvXMLElementExport aSettings(*this, XML_NAMESPACE_PRESENTATION, XML_SETTINGS, true, true);

            if( !bHasNames )
                return;

            Reference< XIndexContainer > xShow;
            Reference< XNamed > xPageName;

            OUStringBuffer sTmp;

            for( const auto& rShowName : std::as_const(aShowNames) )
            {
                AddAttribute(XML_NAMESPACE_PRESENTATION, XML_NAME, rShowName );

                xShows->getByName( rShowName ) >>= xShow;
                SAL_WARN_IF( !xShow.is(), "xmloff", "invalid custom show!" );
                if( !xShow.is() )
                    continue;

                const sal_Int32 nPageCount = xShow->getCount();
                for( sal_Int32 nPage = 0; nPage < nPageCount; nPage++ )
                {
                    xShow->getByIndex( nPage ) >>= xPageName;

                    if( !xPageName.is() )
                        continue;

                    if( !sTmp.isEmpty() )
                        sTmp.append(  ',' );
                    sTmp.append( xPageName->getName() );

                }

                if( !sTmp.isEmpty() )
                    AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PAGES, sTmp.makeStringAndClear() );

                SvXMLElementExport aShows(*this, XML_NAMESPACE_PRESENTATION, XML_SHOW, true, true);
            }
        }
    }
    catch(const uno::Exception&)
    {
        OSL_FAIL( "uno::Exception while exporting <presentation:settings>" );
    }
}

void SdXMLExport::ExportStyles_(bool bUsed)
{
    GetPropertySetMapper()->SetAutoStyles( false );

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

    // write draw:style-name for object graphic-styles
    GetShapeExport()->ExportGraphicDefaults();

    // do not export in ODF 1.1 or older
    if (getSaneDefaultVersion() >= SvtSaveOptions::ODFSVER_012)
        GetShapeExport()->GetShapeTableExport()->exportTableStyles();

    // write presentation styles
    ImpWritePresentationStyles();

    // prepare draw:auto-layout-name for page export
    ImpPrepAutoLayoutInfos();

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

    Reference< beans::XPropertySet > xInfoSet( getExportInfo() );
    if( xInfoSet.is() )
    {
        Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );

        if( xInfoSetInfo->hasPropertyByName( gsPageLayoutNames ) )
        {
            xInfoSet->setPropertyValue( gsPageLayoutNames, Any(maDrawPagesAutoLayoutNames) );
        }
    }
}

void SdXMLExport::collectAutoStyles()
{
    SvXMLExport::collectAutoStyles();
    if (mbAutoStylesCollected)
        return;

    Reference< beans::XPropertySet > xInfoSet( getExportInfo() );
    if( xInfoSet.is() )
    {
        Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() );

        if( xInfoSetInfo->hasPropertyByName( gsPageLayoutNames ) )
        {
            xInfoSet->getPropertyValue( gsPageLayoutNames ) >>= maDrawPagesAutoLayoutNames;
        }
    }

    GetPropertySetMapper()->SetAutoStyles( true );

    if( getExportFlags() & SvXMLExportFlags::STYLES )
    {
        // #80012# PageMaster export moved from _ExportStyles
        // prepare page-master infos
        ImpPrepPageMasterInfos();

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

    if( getExportFlags() & SvXMLExportFlags::CONTENT )
    {
        // prepare draw:style-name for page export
        ImpPrepDrawPageInfos();
    }

    if( getExportFlags() & SvXMLExportFlags::STYLES )
    {
        // create auto style infos for shapes on master handout page
        if( IsImpress() )
        {
            Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
            if( xHandoutSupp.is() )
            {
                Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
                if( xHandoutPage.is() && xHandoutPage->getCount())
                    GetShapeExport()->collectShapesAutoStyles( xHandoutPage );
            }
        }

        // create auto style infos for objects on master pages
        for(sal_Int32 nMPageId(0); nMPageId < mnDocMasterPageCount; nMPageId++)
        {
            Reference< XDrawPage > xMasterPage(mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );

            if( xMasterPage.is() )
            {
                // collect layer information
                GetFormExport()->examineForms( xMasterPage );

                // get MasterPage Name
                OUString aMasterPageNamePrefix;
                Reference < container::XNamed > xNamed(xMasterPage, UNO_QUERY);
                if(xNamed.is())
                {
                    aMasterPageNamePrefix = xNamed->getName();
                }
                if(!aMasterPageNamePrefix.isEmpty())
                {
                    aMasterPageNamePrefix += "-";
                }
                GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix );

                if(xMasterPage.is() && xMasterPage->getCount())
                    GetShapeExport()->collectShapesAutoStyles( xMasterPage );

                if(IsImpress())
                {
                    Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
                    if(xPresPage.is())
                    {
                        Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
                        if(xNotesPage.is())
                        {
                            // collect layer information
                            GetFormExport()->examineForms( xNotesPage );

                            if(xNotesPage->getCount())
                                GetShapeExport()->collectShapesAutoStyles( xNotesPage );
                        }
                    }
                }
                collectAnnotationAutoStyles(xMasterPage);
            }
        }
    }

    if( getExportFlags() & SvXMLExportFlags::CONTENT )
    {
        // prepare animations exporter if impress
        if(IsImpress() && (!(getExportFlags() & SvXMLExportFlags::OASIS)) )
        {
            rtl::Reference< XMLAnimationsExporter > xAnimExport = new XMLAnimationsExporter();
            GetShapeExport()->setAnimationsExporter( xAnimExport );
        }

        // create auto style infos for objects on pages
        for(sal_Int32 nPageInd(0); nPageInd < mnDocDrawPageCount; nPageInd++)
        {
            Reference<XDrawPage> xDrawPage( mxDocDrawPages->getByIndex(nPageInd), UNO_QUERY );
            if( xDrawPage.is() )
            {
                // collect layer information
                GetFormExport()->examineForms( xDrawPage );

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

                GetShapeExport()->setPresentationStylePrefix( aMasterPageNamePrefix );

                // prepare object infos
                if(xDrawPage.is() && xDrawPage->getCount())
                    GetShapeExport()->collectShapesAutoStyles( xDrawPage );

                // prepare presentation notes page object infos (ONLY if presentation)
                if(IsImpress())
                {
                    Reference< presentation::XPresentationPage > xPresPage(xDrawPage, UNO_QUERY);
                    if(xPresPage.is())
                    {
                        Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
                        if(xNotesPage.is())
                        {
                            // collect layer information
                            GetFormExport()->examineForms( xNotesPage );

                            if(xNotesPage->getCount())
                                GetShapeExport()->collectShapesAutoStyles( xNotesPage );
                        }
                    }
                }

                collectAnnotationAutoStyles( xDrawPage );
            }
        }
        if (IsImpress())
        {
            rtl::Reference< XMLAnimationsExporter > xAnimExport;
            GetShapeExport()->setAnimationsExporter( xAnimExport );
        }
    }

    mbAutoStylesCollected = true;
}

void SdXMLExport::ExportAutoStyles_()
{
    collectAutoStyles();

    if( getExportFlags() & SvXMLExportFlags::STYLES )
    {
        // write page-master infos
        ImpWritePageMasterInfos();
    }

    // export draw-page styles
    GetAutoStylePool()->exportXML( XmlStyleFamily::SD_DRAWINGPAGE_ID );

    exportAutoDataStyles();

    GetShapeExport()->exportAutoStyles();

    SvXMLExportFlags nContentAutostyles = SvXMLExportFlags::CONTENT | SvXMLExportFlags::AUTOSTYLES;
    if ( ( getExportFlags() & nContentAutostyles ) == nContentAutostyles )
        GetFormExport()->exportAutoStyles( );

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

void SdXMLExport::ExportMasterStyles_()
{
    // export layer
    SdXMLayerExporter::exportLayer( *this );

    // export handout master page if impress
    if( IsImpress() )
    {
        Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY );
        if( xHandoutSupp.is() )
        {
            Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() );
            if( xHandoutPage.is() )
            {
                // presentation:page-layout-name
                if( IsImpress() && !maDrawPagesAutoLayoutNames[0].isEmpty())
                {
                    AddAttribute(XML_NAMESPACE_PRESENTATION, XML_PRESENTATION_PAGE_LAYOUT_NAME, EncodeStyleName( maDrawPagesAutoLayoutNames[0] ));
                }

                ImpXMLEXPPageMasterInfo* pInfo = mpHandoutPageMaster;
                if(pInfo)
                {
                    const OUString& sString = pInfo->GetName();
                    AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString );
                }

                // draw:style-name
                if( !maHandoutMasterStyleName.isEmpty() )
                    AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME, maHandoutMasterStyleName);

                ImplExportHeaderFooterDeclAttributes( maHandoutPageHeaderFooterSettings );

                // write masterpage
                SvXMLElementExport aMPG(*this, XML_NAMESPACE_STYLE, XML_HANDOUT_MASTER, true, true);

                // write graphic objects on this master page (if any)
                if(xHandoutPage.is() && xHandoutPage->getCount())
                    GetShapeExport()->exportShapes( xHandoutPage );
            }
        }
    }

    // export MasterPages in master-styles section
    for (sal_Int32 nMPageId = 0; nMPageId < mnDocMasterPageCount; nMPageId++)
    {
        Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY );
        if(xMasterPage.is())
        {
            // prepare masterpage attributes
            OUString sMasterPageName;
            Reference < container::XNamed > xNamed(xMasterPage, UNO_QUERY);
            if(xNamed.is())
            {
                bool bEncoded = false;
                sMasterPageName = xNamed->getName();
                AddAttribute(XML_NAMESPACE_STYLE, XML_NAME,
                    EncodeStyleName( sMasterPageName, &bEncoded ));
                if( bEncoded )
                    AddAttribute(
                        XML_NAMESPACE_STYLE, XML_DISPLAY_NAME,
                        sMasterPageName );
            }

            ImpXMLEXPPageMasterInfo* pInfo = mvPageMasterUsageList.at( nMPageId );
            if(pInfo)
            {
                const OUString& sString = pInfo->GetName();
                AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString );
            }

            // draw:style-name (background attributes)
            if( !maMasterPagesStyleNames[nMPageId].isEmpty() )
                AddAttribute(XML_NAMESPACE_DRAW, XML_STYLE_NAME,
                        maMasterPagesStyleNames[nMPageId]);

            // write masterpage
            SvXMLElementExport aMPG(*this, XML_NAMESPACE_STYLE, XML_MASTER_PAGE, true, true);

            // write optional office:forms
            exportFormsElement( xMasterPage );

            // write graphic objects on this master page (if any)
            if(xMasterPage.is() && xMasterPage->getCount())
                GetShapeExport()->exportShapes( xMasterPage );

            // write presentation notes (ONLY if presentation)
            if(IsImpress())
            {
                Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY);
                if(xPresPage.is())
                {
                    Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage());
                    if(xNotesPage.is())
                    {
                        ImpXMLEXPPageMasterInfo* pMasterInfo = mvNotesPageMasterUsageList.at( nMPageId );
                        if(pMasterInfo)
                        {
                            const OUString& sString = pMasterInfo->GetName();
                            AddAttribute(XML_NAMESPACE_STYLE, XML_PAGE_LAYOUT_NAME, sString);
                        }

                        // write presentation notes
                        SvXMLElementExport aPSY(*this, XML_NAMESPACE_PRESENTATION, XML_NOTES, true, true);

                        // write optional office:forms
                        exportFormsElement( xNotesPage );

                        // write shapes per se
                        GetShapeExport()->exportShapes( xNotesPage );
                    }
                }
            }
            exportAnnotations( xMasterPage );
        }
    }
}

void SdXMLExport::exportFormsElement( const Reference< XDrawPage >& xDrawPage )
{
    if( xDrawPage.is() )
    {
        Reference< form::XFormsSupplier2 > xFormsSupplier( xDrawPage, UNO_QUERY );
        if ( xFormsSupplier.is() && xFormsSupplier->hasForms() )
        {
            // write masterpage
            ::xmloff::OOfficeFormsExport aForms(*this);
            GetFormExport()->exportForms( xDrawPage );
        }

        if(! GetFormExport()->seekPage( xDrawPage ) )
        {
            OSL_FAIL( "OFormLayerXMLExport::seekPage failed!" );
        }
    }
}

void SdXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>& rProps)
{
    Reference< beans::XPropertySet > xPropSet( GetModel(), UNO_QUERY );
    if( !xPropSet.is() )
        return;

    awt::Rectangle aVisArea;
    xPropSet->getPropertyValue("VisibleArea") >>= aVisArea;

    rProps.realloc(4);
    beans::PropertyValue* pProps = rProps.getArray();

    pProps[0].Name = "VisibleAreaTop";
    pProps[0].Value <<= aVisArea.Y;
    pProps[1].Name = "VisibleAreaLeft";
    pProps[1].Value <<= aVisArea.X;
    pProps[2].Name = "VisibleAreaWidth";
    pProps[2].Value <<= aVisArea.Width;
    pProps[3].Name = "VisibleAreaHeight";
    pProps[3].Value <<= aVisArea.Height;

}

void SdXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& rProps)
{
    Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
    if( xFac.is() )
    {
        Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
        if( xProps.is() )
            SvXMLUnitConverter::convertPropertySet( rProps, xProps );
        DocumentSettingsSerializer *pFilter(dynamic_cast<DocumentSettingsSerializer *>(xProps.get()));
        if (!pFilter)
            return;
        const uno::Reference< embed::XStorage > xStorage(GetTargetStorage());
        if (!xStorage.is())
            return;
        rProps = pFilter->filterStreamsToStorage(xStorage, rProps);
    }
}

void SdXMLExport::addDataStyle(const sal_Int32 nNumberFormat, bool bTimeFormat )
{
    sal_Int32 nFormat = nNumberFormat;
    if( (nNumberFormat > 1) && (nNumberFormat <= 0x0f) )
        nFormat -= 2;

    if( bTimeFormat )
    {
        if( maUsedTimeStyles.count( nFormat ) == 0 )
            maUsedTimeStyles.insert( nFormat );<--- Searching before insertion is not necessary.
    }
    else
    {
        if( maUsedDateStyles.count( nFormat ) == 0 )
            maUsedDateStyles.insert( nFormat );<--- Searching before insertion is not necessary.
    }
}

void SdXMLExport::exportDataStyles()
{
    // there are no data styles to export in draw/impress yet
}

void SdXMLExport::exportAutoDataStyles()
{
    for( const auto& rUsedDateStyle : maUsedDateStyles )
        SdXMLNumberStylesExporter::exportDateStyle( *this, rUsedDateStyle );

    for( const auto& rUsedTimeStyle : maUsedTimeStyles )
        SdXMLNumberStylesExporter::exportTimeStyle( *this, rUsedTimeStyle );

    if(HasFormExport())
        GetFormExport()->exportAutoControlNumberStyles();
}

OUString SdXMLExport::getDataStyleName(const sal_Int32 nNumberFormat, bool bTimeFormat ) const
{
    if( bTimeFormat )
    {
        return SdXMLNumberStylesExporter::getTimeStyleName( nNumberFormat );
    }
    else
    {
        return SdXMLNumberStylesExporter::getDateStyleName( nNumberFormat );
    }
}

OUString SdXMLExport::getNavigationOrder( const Reference< XDrawPage >& xDrawPage )
{
    OUStringBuffer sNavOrder;
    try
    {
        Reference< XPropertySet > xSet( xDrawPage, UNO_QUERY_THROW );
        Reference< XIndexAccess > xNavOrder( xSet->getPropertyValue("NavigationOrder"), UNO_QUERY_THROW );

        Reference< XIndexAccess > xZOrderAccess = xDrawPage;

        // only export navigation order if it is different from the z-order
        if( (xNavOrder.get() != xZOrderAccess.get()) && (xNavOrder->getCount() == xDrawPage->getCount())  )
        {
            sal_Int32 nIndex;
            const sal_Int32 nCount = xNavOrder->getCount();
            for( nIndex = 0; nIndex < nCount; ++nIndex )
            {
                OUString sId( getInterfaceToIdentifierMapper().registerReference( Reference< XInterface >( xNavOrder->getByIndex( nIndex ), UNO_QUERY ) ) );
                if( !sId.isEmpty() )
                {
                    if( !sNavOrder.isEmpty() )
                        sNavOrder.append( ' ' );
                    sNavOrder.append( sId );
                }
            }
        }
    }
    catch(const Exception&)
    {
    }
    return sNavOrder.makeStringAndClear();
}

void SdXMLExport::collectAnnotationAutoStyles( const Reference<XDrawPage>& xDrawPage )
{
    Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY );
    if( xAnnotationAccess.is() ) try
    {
        Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
        if( xAnnotationEnumeration.is() )
        {
            while( xAnnotationEnumeration->hasMoreElements() )
            {
                Reference< XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement(), UNO_SET_THROW );
                Reference< XText > xText( xAnnotation->getTextRange() );
                if(xText.is() && !xText->getString().isEmpty())
                    GetTextParagraphExport()->collectTextAutoStyles( xText );
            }
        }
    }
    catch(const Exception&)
    {
        OSL_FAIL("SdXMLExport::collectAnnotationAutoStyles(), exception caught during export of annotation auto styles");
    }
}

void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage )
{
    // do not export in standard ODF 1.3 or older
    if ((getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED) == 0)
    {
        return;
    }

    Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY );
    if( xAnnotationAccess.is() ) try
    {
        Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
        if( xAnnotationEnumeration.is() && xAnnotationEnumeration->hasMoreElements() )
        {
            OUStringBuffer sStringBuffer;
            do
            {
                Reference< XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement(), UNO_SET_THROW );

                RealPoint2D aPosition( xAnnotation->getPosition() );

                GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
                        static_cast<sal_Int32>( aPosition.X * 100 ) );
                AddAttribute(XML_NAMESPACE_SVG, XML_X, sStringBuffer.makeStringAndClear());

                GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
                        static_cast<sal_Int32>( aPosition.Y * 100 ) );
                AddAttribute(XML_NAMESPACE_SVG, XML_Y, sStringBuffer.makeStringAndClear());

                RealSize2D aSize( xAnnotation->getSize() );

                if( aSize.Width || aSize.Height )
                {
                    GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
                            static_cast<sal_Int32>( aSize.Width * 100 ) );
                    AddAttribute(XML_NAMESPACE_SVG, XML_WIDTH, sStringBuffer.makeStringAndClear());
                    GetMM100UnitConverter().convertMeasureToXML(sStringBuffer,
                            static_cast<sal_Int32>( aSize.Height * 100 ) );
                    AddAttribute(XML_NAMESPACE_SVG, XML_HEIGHT, sStringBuffer.makeStringAndClear());
                }

                // annotation element + content
                SvXMLElementExport aElem(*this, XML_NAMESPACE_OFFICE_EXT, XML_ANNOTATION, false, true);

                // author
                OUString aAuthor( xAnnotation->getAuthor() );
                if( !aAuthor.isEmpty() )
                {
                    SvXMLElementExport aCreatorElem( *this, XML_NAMESPACE_DC, XML_CREATOR, true, false );
                    Characters(aAuthor);
                }

                // initials
                OUString aInitials( xAnnotation->getInitials() );
                if( !aInitials.isEmpty() )
                {
                    // OFFICE-3776 export meta:creator-initials for ODF 1.3
                    SvXMLElementExport aInitialsElem( *this,
                            (SvtSaveOptions::ODFSVER_013 <= getSaneDefaultVersion())
                                ? XML_NAMESPACE_META
                                : XML_NAMESPACE_LO_EXT,
                            (SvtSaveOptions::ODFSVER_013 <= getSaneDefaultVersion())
                                ? XML_CREATOR_INITIALS
                                : XML_SENDER_INITIALS,
                            true, false );
                    Characters(aInitials);
                }

                {
                    // date time
                    css::util::DateTime aDate( xAnnotation->getDateTime() );
                    ::sax::Converter::convertDateTime(sStringBuffer, aDate, nullptr, true);
                    SvXMLElementExport aDateElem( *this, XML_NAMESPACE_DC, XML_DATE, true, false );
                    Characters(sStringBuffer.makeStringAndClear());
                }

                css::uno::Reference < css::text::XText > xText( xAnnotation->getTextRange() );
                if( xText.is() )
                    GetTextParagraphExport()->exportText( xText );
            }
            while( xAnnotationEnumeration->hasMoreElements() );
        }
    }
    catch(const Exception&)
    {
        OSL_FAIL("SdXMLExport::exportAnnotations(), exception caught during export of annotations");
    }
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLOasisExporter_get_implementation(<--- The function 'com_sun_star_comp_Impress_XMLOasisExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(
        pCtx, "XMLImpressExportOasis", false,
        SvXMLExportFlags::OASIS | SvXMLExportFlags::META | SvXMLExportFlags::STYLES
            | SvXMLExportFlags::MASTERSTYLES | SvXMLExportFlags::AUTOSTYLES
            | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS | SvXMLExportFlags::SETTINGS
            | SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::EMBEDDED));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLOasisStylesExporter_get_implementation(<--- The function 'com_sun_star_comp_Impress_XMLOasisStylesExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(
        pCtx, "XMLImpressStylesExportOasis", false,
        SvXMLExportFlags::OASIS | SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES
            | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::FONTDECLS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLOasisContentExporter_get_implementation(<--- The function 'com_sun_star_comp_Impress_XMLOasisContentExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(pCtx, "XMLImpressContentExportOasis", false,
                                         SvXMLExportFlags::OASIS | SvXMLExportFlags::AUTOSTYLES
                                             | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS
                                             | SvXMLExportFlags::FONTDECLS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLOasisMetaExporter_get_implementation(<--- The function 'com_sun_star_comp_Impress_XMLOasisMetaExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(pCtx, "XMLImpressMetaExportOasis", false,
                                         SvXMLExportFlags::OASIS | SvXMLExportFlags::META));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLOasisSettingsExporter_get_implementation(<--- The function 'com_sun_star_comp_Impress_XMLOasisSettingsExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(pCtx, "XMLImpressSettingsExportOasis", false,
                                         SvXMLExportFlags::OASIS | SvXMLExportFlags::SETTINGS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLStylesExporter_get_implementation(<--- The function 'com_sun_star_comp_Impress_XMLStylesExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(pCtx, "XMLImpressStylesExportOOO", false,
                                         SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES
                                             | SvXMLExportFlags::AUTOSTYLES
                                             | SvXMLExportFlags::FONTDECLS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLContentExporter_get_implementation(<--- The function 'com_sun_star_comp_Impress_XMLContentExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(pCtx, "XMLImpressContentExportOOO", false,
                                         SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT
                                             | SvXMLExportFlags::SCRIPTS
                                             | SvXMLExportFlags::FONTDECLS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLMetaExporter_get_implementation(<--- The function 'com_sun_star_comp_Impress_XMLMetaExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(
        new SdXMLExport(pCtx, "XMLImpressMetaExportOOO", false, SvXMLExportFlags::META));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLSettingsExporter_get_implementation(<--- The function 'com_sun_star_comp_Impress_XMLSettingsExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(
        new SdXMLExport(pCtx, "XMLImpressSettingsExportOOO", false, SvXMLExportFlags::SETTINGS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLExporter_get_implementation(uno::XComponentContext* pCtx,<--- The function 'com_sun_star_comp_Impress_XMLExporter_get_implementation' is never used.
                                                         uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(
        pCtx, "XMLImpressExportOOO", false,
        SvXMLExportFlags::META | SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES
            | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS
            | SvXMLExportFlags::SETTINGS | SvXMLExportFlags::FONTDECLS
            | SvXMLExportFlags::EMBEDDED));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Draw_XMLExporter_get_implementation(uno::XComponentContext* pCtx,<--- The function 'com_sun_star_comp_Draw_XMLExporter_get_implementation' is never used.
                                                      uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(
        pCtx, "XMLDrawExportOOO", true,
        SvXMLExportFlags::META | SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES
            | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS
            | SvXMLExportFlags::SETTINGS | SvXMLExportFlags::FONTDECLS
            | SvXMLExportFlags::EMBEDDED));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Draw_XMLStylesExporter_get_implementation(uno::XComponentContext* pCtx,<--- The function 'com_sun_star_comp_Draw_XMLStylesExporter_get_implementation' is never used.
                                                            uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(pCtx, "XMLDrawStylesExportOOO", true,
                                         SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES
                                             | SvXMLExportFlags::AUTOSTYLES
                                             | SvXMLExportFlags::FONTDECLS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Draw_XMLContentExporter_get_implementation(uno::XComponentContext* pCtx,<--- The function 'com_sun_star_comp_Draw_XMLContentExporter_get_implementation' is never used.
                                                            uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(pCtx, "XMLDrawContentExportOOO", true,
                                         SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT
                                             | SvXMLExportFlags::SCRIPTS
                                             | SvXMLExportFlags::FONTDECLS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Draw_XMLMetaExporter_get_implementation(uno::XComponentContext* pCtx,<--- The function 'com_sun_star_comp_Draw_XMLMetaExporter_get_implementation' is never used.
                                                            uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(
        new SdXMLExport(pCtx, "XMLDrawMetaExportOOO", true, SvXMLExportFlags::META));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Draw_XMLSettingsExporter_get_implementation(<--- The function 'com_sun_star_comp_Draw_XMLSettingsExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(
        new SdXMLExport(pCtx, "XMLDrawSettingsExportOOO", true, SvXMLExportFlags::SETTINGS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Draw_XMLOasisSettingsExporter_get_implementation(<--- The function 'com_sun_star_comp_Draw_XMLOasisSettingsExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(pCtx, "XMLDrawSettingsExportOasis", true,
                                         SvXMLExportFlags::OASIS | SvXMLExportFlags::SETTINGS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Draw_XMLOasisMetaExporter_get_implementation(<--- The function 'com_sun_star_comp_Draw_XMLOasisMetaExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(pCtx, "XMLDrawMetaExportOasis", true,
                                         SvXMLExportFlags::OASIS | SvXMLExportFlags::META));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Draw_XMLOasisContentExporter_get_implementation(<--- The function 'com_sun_star_comp_Draw_XMLOasisContentExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(pCtx, "XMLDrawContentExportOasis", true,
                                         SvXMLExportFlags::OASIS | SvXMLExportFlags::AUTOSTYLES
                                             | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS
                                             | SvXMLExportFlags::FONTDECLS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Draw_XMLOasisStylesExporter_get_implementation(<--- The function 'com_sun_star_comp_Draw_XMLOasisStylesExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(
        pCtx, "XMLDrawStylesExportOasis", true,
        SvXMLExportFlags::OASIS | SvXMLExportFlags::STYLES | SvXMLExportFlags::MASTERSTYLES
            | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::FONTDECLS));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Draw_XMLOasisExporter_get_implementation(uno::XComponentContext* pCtx,<--- The function 'com_sun_star_comp_Draw_XMLOasisExporter_get_implementation' is never used.
                                                           uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(new SdXMLExport(
        pCtx, "XMLDrawExportOasis", true,
        SvXMLExportFlags::OASIS | SvXMLExportFlags::META | SvXMLExportFlags::STYLES
            | SvXMLExportFlags::MASTERSTYLES | SvXMLExportFlags::AUTOSTYLES
            | SvXMLExportFlags::CONTENT | SvXMLExportFlags::SCRIPTS | SvXMLExportFlags::SETTINGS
            | SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::EMBEDDED));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_DrawingLayer_XMLExporter_get_implementation(<--- The function 'com_sun_star_comp_DrawingLayer_XMLExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(
        new SdXMLExport(pCtx, "XMLDrawingLayerExport", true,
                        SvXMLExportFlags::OASIS | SvXMLExportFlags::STYLES
                            | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT
                            | SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::EMBEDDED));
}

extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
com_sun_star_comp_Impress_XMLClipboardExporter_get_implementation(<--- The function 'com_sun_star_comp_Impress_XMLClipboardExporter_get_implementation' is never used.
    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
{
    return cppu::acquire(
        new SdXMLExport(pCtx, "XMLImpressClipboardExport", /*bIsDraw=*/false,
                        SvXMLExportFlags::OASIS | SvXMLExportFlags::STYLES
                            | SvXMLExportFlags::AUTOSTYLES | SvXMLExportFlags::CONTENT
                            | SvXMLExportFlags::FONTDECLS | SvXMLExportFlags::EMBEDDED));
}

XMLFontAutoStylePool* SdXMLExport::CreateFontAutoStylePool()
{
    bool bEmbedFonts = false;
    bool bEmbedUsedOnly = false;
    bool bEmbedLatinScript = true;
    bool bEmbedAsianScript = true;
    bool bEmbedComplexScript = true;

    if (getExportFlags() & SvXMLExportFlags::CONTENT)
    {
        try
        {
            Reference<lang::XMultiServiceFactory> xFactory(GetModel(), UNO_QUERY);
            Reference<beans::XPropertySet> xProps;
            Reference<beans::XPropertySetInfo> xInfo;

            if (xFactory.is())
                xProps.set(xFactory->createInstance("com.sun.star.document.Settings"), UNO_QUERY);
            if (xProps.is())
                xInfo =  xProps->getPropertySetInfo();
            if (xInfo.is() && xProps.is())
            {
                if (xInfo->hasPropertyByName("EmbedFonts"))
                    xProps->getPropertyValue("EmbedFonts") >>= bEmbedFonts;
                if (xInfo->hasPropertyByName("EmbedOnlyUsedFonts"))
                    xProps->getPropertyValue("EmbedOnlyUsedFonts") >>= bEmbedUsedOnly;
                if (xInfo->hasPropertyByName("EmbedLatinScriptFonts"))
                    xProps->getPropertyValue("EmbedLatinScriptFonts") >>= bEmbedLatinScript;
                if (xInfo->hasPropertyByName("EmbedAsianScriptFonts"))
                    xProps->getPropertyValue("EmbedAsianScriptFonts") >>= bEmbedAsianScript;
                if (xInfo->hasPropertyByName("EmbedComplexScriptFonts"))
                    xProps->getPropertyValue("EmbedComplexScriptFonts") >>= bEmbedComplexScript;
            }
        } catch(...)
        {
            // clipboard document doesn't have shell so throws from getPropertyValue
            // gallery elements may not support com.sun.star.document.Settings so throws from createInstance
        }
    }

    XMLFontAutoStylePool *pPool = new XMLFontAutoStylePool( *this, bEmbedFonts );
    pPool->setEmbedOnlyUsedFonts(bEmbedUsedOnly);
    pPool->setEmbedFontScripts(bEmbedLatinScript, bEmbedAsianScript, bEmbedComplexScript);

    Reference< beans::XPropertySet > xProps( GetModel(), UNO_QUERY );
    if ( xProps.is() ) {
        Sequence<Any> aAnySeq;
        if( xProps->getPropertyValue("Fonts") >>= aAnySeq )
        {
            if( aAnySeq.getLength() % 5 == 0 )
            {
                int nLen = aAnySeq.getLength() / 5;
                int nSeqIndex = 0;
                for( int i = 0; i < nLen; i++ )
                {
                    OUString sFamilyName, sStyleName;
                    sal_Int16 eFamily(FAMILY_DONTKNOW),
                        ePitch(PITCH_DONTKNOW),
                        eCharSet(RTL_TEXTENCODING_DONTKNOW);

                    aAnySeq[nSeqIndex++] >>= sFamilyName;
                    aAnySeq[nSeqIndex++] >>= sStyleName;
                    aAnySeq[nSeqIndex++] >>= eFamily;
                    aAnySeq[nSeqIndex++] >>= ePitch;
                    aAnySeq[nSeqIndex++] >>= eCharSet;

                    pPool->Add( sFamilyName, sStyleName, FontFamily( eFamily ), FontPitch( ePitch ), rtl_TextEncoding( eCharSet ) );
                }
            }
        }
    }

    return pPool;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */