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

#include <o3tl/safeint.hxx>
#include <sal/macros.h>
#include <sal/log.hxx>
#include <fmobj.hxx>
#include <fmpgeimp.hxx>
#include <svx/fmtools.hxx>
#include <fmprop.hxx>
#include <fmservs.hxx>
#include <fmshimp.hxx>
#include <fmtextcontrolshell.hxx>
#include <fmundo.hxx>
#include <fmurl.hxx>
#include <fmvwimp.hxx>
#include <gridcols.hxx>
#include <svx/svditer.hxx>
#include <svx/dialmgr.hxx>
#include <svx/strings.hrc>
#include <svx/svdobjkind.hxx>
#include <svx/fmmodel.hxx>
#include <svx/fmpage.hxx>
#include <svx/fmshell.hxx>
#include <svx/fmview.hxx>
#include <svx/obj3d.hxx>
#include <svx/sdrpagewindow.hxx>
#include <svx/svdpagv.hxx>
#include <svx/svxdlg.hxx>
#include <svx/svxids.hrc>
#include <bitmaps.hlst>
#include <formnavi.hrc>

#include <com/sun/star/awt/XWindow2.hpp>
#include <com/sun/star/awt/XCheckBox.hpp>
#include <com/sun/star/awt/XListBox.hpp>
#include <com/sun/star/awt/XTextComponent.hpp>
#include <com/sun/star/beans/theIntrospection.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/container/XContainer.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/form/ListSourceType.hpp>
#include <com/sun/star/form/TabOrderDialog.hpp>
#include <com/sun/star/form/XGrid.hpp>
#include <com/sun/star/form/XGridPeer.hpp>
#include <com/sun/star/form/XLoadable.hpp>
#include <com/sun/star/form/XReset.hpp>
#include <com/sun/star/form/binding/XBindableValue.hpp>
#include <com/sun/star/form/binding/XListEntrySink.hpp>
#include <com/sun/star/frame/FrameSearchFlag.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/script/XEventAttacherManager.hpp>
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/util/XModeSelector.hpp>
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>

#include <comphelper/evtmethodhelper.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/property.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/solarmutex.hxx>
#include <comphelper/string.hxx>
#include <comphelper/types.hxx>
#include <connectivity/dbtools.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/frame.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/viewsh.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
#include <vcl/window.hxx>

#include <algorithm>
#include <map>
#include <memory>
#include <string_view>
#include <vector>

// is used for Invalidate -> maintain it as well
const sal_uInt16 DatabaseSlotMap[] =
{
    SID_FM_RECORD_FIRST,
    SID_FM_RECORD_NEXT,
    SID_FM_RECORD_PREV,
    SID_FM_RECORD_LAST,
    SID_FM_RECORD_NEW,
    SID_FM_RECORD_DELETE,
    SID_FM_RECORD_ABSOLUTE,
    SID_FM_RECORD_TOTAL,
    SID_FM_RECORD_SAVE,
    SID_FM_RECORD_UNDO,
    SID_FM_REMOVE_FILTER_SORT,
    SID_FM_SORTUP,
    SID_FM_SORTDOWN,
    SID_FM_ORDERCRIT,
    SID_FM_AUTOFILTER,
    SID_FM_FORM_FILTERED,
    SID_FM_REFRESH,
    SID_FM_REFRESH_FORM_CONTROL,
    SID_FM_SEARCH,
    SID_FM_FILTER_START,
    SID_FM_VIEW_AS_GRID,
    0
};

// is used for Invalidate -> maintain it as well
// sort ascending !!!!!!
const sal_Int16 DlgSlotMap[] =    // slots of the controller
{
    SID_FM_CTL_PROPERTIES,
    SID_FM_PROPERTIES,
    SID_FM_TAB_DIALOG,
    SID_FM_ADD_FIELD,
    SID_FM_SHOW_FMEXPLORER,
    SID_FM_FIELDS_CONTROL,
    SID_FM_SHOW_PROPERTIES,
    SID_FM_PROPERTY_CONTROL,
    SID_FM_FMEXPLORER_CONTROL,
    SID_FM_SHOW_DATANAVIGATOR,
    SID_FM_DATANAVIGATOR_CONTROL,
    0
};

const sal_Int16 SelObjectSlotMap[] =  // slots depending on the SelObject
{
    SID_FM_CONVERTTO_EDIT,
    SID_FM_CONVERTTO_BUTTON,
    SID_FM_CONVERTTO_FIXEDTEXT,
    SID_FM_CONVERTTO_LISTBOX,
    SID_FM_CONVERTTO_CHECKBOX,
    SID_FM_CONVERTTO_RADIOBUTTON,
    SID_FM_CONVERTTO_GROUPBOX,
    SID_FM_CONVERTTO_COMBOBOX,
    SID_FM_CONVERTTO_IMAGEBUTTON,
    SID_FM_CONVERTTO_FILECONTROL,
    SID_FM_CONVERTTO_DATE,
    SID_FM_CONVERTTO_TIME,
    SID_FM_CONVERTTO_NUMERIC,
    SID_FM_CONVERTTO_CURRENCY,
    SID_FM_CONVERTTO_PATTERN,
    SID_FM_CONVERTTO_IMAGECONTROL,
    SID_FM_CONVERTTO_FORMATTED,
    SID_FM_CONVERTTO_SCROLLBAR,
    SID_FM_CONVERTTO_SPINBUTTON,
    SID_FM_CONVERTTO_NAVIGATIONBAR,

    SID_FM_FMEXPLORER_CONTROL,
    SID_FM_DATANAVIGATOR_CONTROL,

    0
};

// the following arrays must be consistent, i.e., corresponding entries should
// be at the same relative position within their respective arrays
static const char* aConvertSlots[] =
{
    "ConvertToEdit",
    "ConvertToButton",
    "ConvertToFixed",
    "ConvertToList",
    "ConvertToCheckBox",
    "ConvertToRadio",
    "ConvertToGroup",
    "ConvertToCombo",
    "ConvertToImageBtn",
    "ConvertToFileControl",
    "ConvertToDate",
    "ConvertToTime",
    "ConvertToNumeric",
    "ConvertToCurrency",
    "ConvertToPattern",
    "ConvertToImageControl",
    "ConvertToFormatted",
    "ConvertToScrollBar",
    "ConvertToSpinButton",
    "ConvertToNavigationBar"
};

constexpr rtl::OUStringConstExpr aImgIds[] =
{
    RID_SVXBMP_EDITBOX,
    RID_SVXBMP_BUTTON,
    RID_SVXBMP_FIXEDTEXT,
    RID_SVXBMP_LISTBOX,
    RID_SVXBMP_CHECKBOX,
    RID_SVXBMP_RADIOBUTTON,
    RID_SVXBMP_GROUPBOX,
    RID_SVXBMP_COMBOBOX,
    RID_SVXBMP_IMAGEBUTTON,
    RID_SVXBMP_FILECONTROL,
    RID_SVXBMP_DATEFIELD,
    RID_SVXBMP_TIMEFIELD,
    RID_SVXBMP_NUMERICFIELD,
    RID_SVXBMP_CURRENCYFIELD,
    RID_SVXBMP_PATTERNFIELD,
    RID_SVXBMP_IMAGECONTROL,
    RID_SVXBMP_FORMATTEDFIELD,
    RID_SVXBMP_SCROLLBAR,
    RID_SVXBMP_SPINBUTTON,
    RID_SVXBMP_NAVIGATIONBAR
};

const SdrObjKind nObjectTypes[] =
{
    SdrObjKind::FormEdit,
    SdrObjKind::FormButton,
    SdrObjKind::FormFixedText,
    SdrObjKind::FormListbox,
    SdrObjKind::FormCheckbox,
    SdrObjKind::FormRadioButton,
    SdrObjKind::FormGroupBox,
    SdrObjKind::FormCombobox,
    SdrObjKind::FormImageButton,
    SdrObjKind::FormFileControl,
    SdrObjKind::FormDateField,
    SdrObjKind::FormTimeField,
    SdrObjKind::FormNumericField,
    SdrObjKind::FormCurrencyField,
    SdrObjKind::FormPatternField,
    SdrObjKind::FormImageControl,
    SdrObjKind::FormFormattedField,
    SdrObjKind::FormScrollbar,
    SdrObjKind::FormSpinButton,
    SdrObjKind::FormNavigationBar
};

using namespace ::com::sun::star;
using namespace ::com::sun::star::ui;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::form;
using namespace ::com::sun::star::form::binding;
using namespace ::com::sun::star::form::runtime;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::view;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::script;
using namespace ::svxform;
using namespace ::svx;
using namespace ::dbtools;


//= helper

namespace
{

    void collectInterfacesFromMarkList( const SdrMarkList& _rMarkList, InterfaceBag& /* [out] */ _rInterfaces )
    {
        _rInterfaces.clear();

        const size_t nMarkCount = _rMarkList.GetMarkCount();
        for ( size_t i = 0; i < nMarkCount; ++i)
        {
            SdrObject* pCurrent = _rMarkList.GetMark( i )->GetMarkedSdrObj();

            std::unique_ptr<SdrObjListIter> pGroupIterator;
            if ( pCurrent->IsGroupObject() )
            {
                pGroupIterator.reset(new SdrObjListIter( pCurrent->GetSubList() ));
                pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr;
            }

            while ( pCurrent )
            {
                FmFormObj* pAsFormObject = FmFormObj::GetFormObject( pCurrent );
                    // note this will de-reference virtual objects, if necessary/possible
                if ( pAsFormObject )
                {
                    Reference< XInterface > xControlModel( pAsFormObject->GetUnoControlModel(), UNO_QUERY );
                        // the UNO_QUERY is important for normalization
                    if ( xControlModel.is() )
                        _rInterfaces.insert( xControlModel );
                }

                // next element
                pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr;
            }
        }
    }


    sal_Int32 GridView2ModelPos(const Reference< XIndexAccess>& rColumns, sal_Int16 nViewPos)
    {
        try
        {
            if (rColumns.is())
            {
                // loop through all columns
                sal_Int32 i;
                Reference< XPropertySet> xCur;
                for (i=0; i<rColumns->getCount(); ++i)
                {
                    rColumns->getByIndex(i) >>= xCur;
                    if (!::comphelper::getBOOL(xCur->getPropertyValue(FM_PROP_HIDDEN)))
                    {
                        // for every visible col : if nViewPos is greater zero, decrement it, else we
                        // have found the model position
                        if (!nViewPos)
                            break;
                        else
                            --nViewPos;
                    }
                }
                if (i<rColumns->getCount())
                    return i;
            }
        }
        catch(const Exception&)
        {
            DBG_UNHANDLED_EXCEPTION("svx");
        }
        return -1;
    }


    void TransferEventScripts(const Reference< XControlModel>& xModel, const Reference< XControl>& xControl,
        const Sequence< ScriptEventDescriptor>& rTransferIfAvailable)
    {
        // first check if we have a XEventAttacherManager for the model
        Reference< XChild> xModelChild(xModel, UNO_QUERY);
        if (!xModelChild.is())
            return; // nothing to do

        Reference< XEventAttacherManager> xEventManager(xModelChild->getParent(), UNO_QUERY);
        if (!xEventManager.is())
            return; // nothing to do

        if (!rTransferIfAvailable.hasElements())
            return; // nothing to do

        // check for the index of the model within its parent
        Reference< XIndexAccess> xParentIndex(xModelChild->getParent(), UNO_QUERY);
        if (!xParentIndex.is())
            return; // nothing to do
        sal_Int32 nIndex = getElementPos(xParentIndex, xModel);
        if (nIndex<0 || nIndex>=xParentIndex->getCount())
            return; // nothing to do

        // then we need information about the listeners supported by the control and the model
        Sequence< Type> aModelListeners;
        Sequence< Type> aControlListeners;

        Reference< XIntrospection> xIntrospection = theIntrospection::get(::comphelper::getProcessComponentContext());

        if (xModel.is())
        {
            Any aModel(xModel);
            aModelListeners = xIntrospection->inspect(aModel)->getSupportedListeners();
        }

        if (xControl.is())
        {
            Any aControl(xControl);
            aControlListeners = xIntrospection->inspect(aControl)->getSupportedListeners();
        }

        sal_Int32 nMaxNewLen = aModelListeners.getLength() + aControlListeners.getLength();
        if (!nMaxNewLen)
            return; // the model and the listener don't support any listeners (or we were unable to retrieve these infos)

        Sequence< ScriptEventDescriptor>    aTransferable(nMaxNewLen);
        ScriptEventDescriptor* pTransferable = aTransferable.getArray();

        for (const ScriptEventDescriptor& rCurrent : rTransferIfAvailable)
        {
            // search the model/control idl classes for the event described by pCurrent
            for (const Sequence< Type>* pCurrentArray : { &aModelListeners, &aControlListeners })
            {
                for (const Type& rCurrentListener : *pCurrentArray)
                {
                    OUString aListener = rCurrentListener.getTypeName();
                    if (!aListener.isEmpty())
                        aListener = aListener.copy(aListener.lastIndexOf('.')+1);

                    if (aListener == rCurrent.ListenerType)
                        // the current ScriptEventDescriptor doesn't match the current listeners class
                        continue;

                    // now check the methods
                    Sequence< OUString> aMethodsNames = ::comphelper::getEventMethodsForType(rCurrentListener);

                    if (comphelper::findValue(aMethodsNames, rCurrent.EventMethod) != -1)
                    {
                        // we can transfer the script event : the model (control) supports it
                        *pTransferable = rCurrent;
                        ++pTransferable;
                        break;
                    }
                }
            }
        }

        sal_Int32 nRealNewLen = pTransferable - aTransferable.getArray();
        aTransferable.realloc(nRealNewLen);

        xEventManager->registerScriptEvents(nIndex, aTransferable);
    }


    OUString getServiceNameByControlType(SdrObjKind nType)
    {
        switch (nType)
        {
            case SdrObjKind::FormEdit            : return FM_COMPONENT_TEXTFIELD;
            case SdrObjKind::FormButton          : return FM_COMPONENT_COMMANDBUTTON;
            case SdrObjKind::FormFixedText       : return FM_COMPONENT_FIXEDTEXT;
            case SdrObjKind::FormListbox         : return FM_COMPONENT_LISTBOX;
            case SdrObjKind::FormCheckbox        : return FM_COMPONENT_CHECKBOX;
            case SdrObjKind::FormRadioButton     : return FM_COMPONENT_RADIOBUTTON;
            case SdrObjKind::FormGroupBox        : return FM_COMPONENT_GROUPBOX;
            case SdrObjKind::FormCombobox        : return FM_COMPONENT_COMBOBOX;
            case SdrObjKind::FormGrid            : return FM_COMPONENT_GRIDCONTROL;
            case SdrObjKind::FormImageButton     : return FM_COMPONENT_IMAGEBUTTON;
            case SdrObjKind::FormFileControl     : return FM_COMPONENT_FILECONTROL;
            case SdrObjKind::FormDateField       : return FM_COMPONENT_DATEFIELD;
            case SdrObjKind::FormTimeField       : return FM_COMPONENT_TIMEFIELD;
            case SdrObjKind::FormNumericField    : return FM_COMPONENT_NUMERICFIELD;
            case SdrObjKind::FormCurrencyField   : return FM_COMPONENT_CURRENCYFIELD;
            case SdrObjKind::FormPatternField    : return FM_COMPONENT_PATTERNFIELD;
            case SdrObjKind::FormHidden          : return FM_COMPONENT_HIDDENCONTROL;
            case SdrObjKind::FormImageControl    : return FM_COMPONENT_IMAGECONTROL;
            case SdrObjKind::FormFormattedField  : return FM_COMPONENT_FORMATTEDFIELD;
            case SdrObjKind::FormScrollbar       : return FM_SUN_COMPONENT_SCROLLBAR;
            case SdrObjKind::FormSpinButton      : return FM_SUN_COMPONENT_SPINBUTTON;
            case SdrObjKind::FormNavigationBar   : return FM_SUN_COMPONENT_NAVIGATIONBAR;
            default:;
        }
        return OUString();
    }

}


// check if the control has one of the interfaces we can use for searching
// *_pCurrentText will be filled with the current text of the control (as used when searching this control)
bool IsSearchableControl( const css::uno::Reference< css::uno::XInterface>& _rxControl,
    OUString* _pCurrentText )
{
    if ( !_rxControl.is() )
        return false;

    Reference< XTextComponent > xAsText( _rxControl, UNO_QUERY );
    if ( xAsText.is() )
    {
        if ( _pCurrentText )
            *_pCurrentText = xAsText->getText();
        return true;
    }

    Reference< XListBox > xListBox( _rxControl, UNO_QUERY );
    if ( xListBox.is() )
    {
        if ( _pCurrentText )
            *_pCurrentText = xListBox->getSelectedItem();
        return true;
    }

    Reference< XCheckBox > xCheckBox( _rxControl, UNO_QUERY );
    if ( xCheckBox.is() )
    {
        if ( _pCurrentText )
        {
            switch ( static_cast<::TriState>(xCheckBox->getState()) )
            {
                case TRISTATE_FALSE: *_pCurrentText = "0"; break;
                case TRISTATE_TRUE: *_pCurrentText = "1"; break;
                default: _pCurrentText->clear(); break;
            }
        }
        return true;
    }

    return false;
}


bool FmXBoundFormFieldIterator::ShouldStepInto(const Reference< XInterface>& _rContainer) const
{
    if (_rContainer == m_xStartingPoint)
        // would be quite stupid to step over the root...
        return true;

    return Reference< XControlModel>(_rContainer, UNO_QUERY).is();
}


bool FmXBoundFormFieldIterator::ShouldHandleElement(const Reference< XInterface>& _rElement)
{
    if (!_rElement.is())
        // NULL element
        return false;

    if (Reference< XForm>(_rElement, UNO_QUERY).is() || Reference< XGrid>(_rElement, UNO_QUERY).is())
        // a forms or a grid
        return false;

    Reference< XPropertySet> xSet(_rElement, UNO_QUERY);
    if (!xSet.is() || !::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
        // no "BoundField" property
        return false;

    Any aVal( xSet->getPropertyValue(FM_PROP_BOUNDFIELD) );
    if (aVal.getValueTypeClass() != TypeClass_INTERFACE)
        // void or invalid property value
        return false;

    return aVal.hasValue();
}


static bool isControlList(const SdrMarkList& rMarkList)
{
    // the list contains only controls and at least one control
    const size_t nMarkCount = rMarkList.GetMarkCount();
    bool  bControlList = nMarkCount != 0;

    bool bHadAnyLeafs = false;

    for (size_t i = 0; i < nMarkCount && bControlList; ++i)
    {
        SdrObject *pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
        E3dObject* pAs3DObject = dynamic_cast< E3dObject* >( pObj);
        // E3dObject's do not contain any 2D-objects (by definition)
        // we need this extra check here : an E3dObject->IsGroupObject says "YES", but an SdrObjListIter working
        // with an E3dObject doesn't give me any Nodes (E3dObject has a sub list, but no members in that list,
        // cause there implementation differs from the one of "normal" SdrObject's. Unfortunally SdrObject::IsGroupObject
        // doesn't check the element count of the sub list, which is simply a bug in IsGroupObject we can't fix at the moment).
        // So at the end of this function bControlList would have the same value it was initialized with above : sal_True
        // And this would be wrong :)
        // 03.02.00 - 72529 - FS
        if (!pAs3DObject)
        {
            if (pObj->IsGroupObject())
            {
                SdrObjListIter aIter(pObj->GetSubList());
                while (aIter.IsMore() && bControlList)
                {
                    bControlList = SdrInventor::FmForm == aIter.Next()->GetObjInventor();
                    bHadAnyLeafs = true;
                }
            }
            else
            {
                bHadAnyLeafs = true;
                bControlList = SdrInventor::FmForm == pObj->GetObjInventor();
            }
        }
    }

    return bControlList && bHadAnyLeafs;
}


static Reference< XForm > GetForm(const Reference< XInterface>& _rxElement)
{
    Reference< XForm > xForm( _rxElement, UNO_QUERY );
    if ( xForm.is() )
        return xForm;

    Reference< XChild > xChild( _rxElement, UNO_QUERY );
    if ( xChild.is() )
        return GetForm( xChild->getParent() );

    return Reference< XForm >();
}

FmXFormShell_Base_Disambiguation::FmXFormShell_Base_Disambiguation( ::osl::Mutex& _rMutex )
    :FmXFormShell_BD_BASE( _rMutex )
{
}

FmXFormShell::FmXFormShell( FmFormShell& _rShell, SfxViewFrame* _pViewFrame )
        :FmXFormShell_BASE(m_aMutex)
        ,FmXFormShell_CFGBASE("Office.Common/Misc", ConfigItemMode::NONE)
        ,m_aMarkTimer("svx::FmXFormShell m_aMarkTimer")
        ,m_eNavigate( NavigationBarMode_NONE )
        ,m_nInvalidationEvent( nullptr )
        ,m_nActivationEvent( nullptr )
        ,m_pShell( &_rShell )
        ,m_pTextShell( new svx::FmTextControlShell( _pViewFrame ) )
        ,m_aActiveControllerFeatures( this )
        ,m_aNavControllerFeatures( this )
        ,m_eDocumentType( eUnknownDocumentType )
        ,m_nLockSlotInvalidation( 0 )
        ,m_bHadPropertyBrowserInDesignMode( false )
        ,m_bTrackProperties( true )
        ,m_bUseWizards( true )
        ,m_bDatabaseBar( false )
        ,m_bInActivate( false )
        ,m_bSetFocus( false )
        ,m_bFilterMode( false )
        ,m_bChangingDesignMode( false )
        ,m_bPreparedClose( false )
        ,m_bFirstActivation( true )
{
    m_aMarkTimer.SetTimeout(100);
    m_aMarkTimer.SetInvokeHandler(LINK(this, FmXFormShell, OnTimeOut_Lock));

    m_xAttachedFrame = _pViewFrame->GetFrame().GetFrameInterface();

    // to prevent deletion of this we acquire our refcounter once
    osl_atomic_increment(&m_refCount);

    // correct the refcounter
    osl_atomic_decrement(&m_refCount);

    // cache the current configuration settings we're interested in
    implAdjustConfigCache_Lock();
    // and register for changes on this settings
    Sequence< OUString > aNames { "FormControlPilotsEnabled" };
    EnableNotification(aNames);
}


FmXFormShell::~FmXFormShell()
{
}


Reference< css::frame::XModel > FmXFormShell::getContextDocument_Lock() const
{
    Reference< css::frame::XModel > xModel;

    // determine the type of document we live in
    try
    {
        Reference< css::frame::XController > xController;
        if ( m_xAttachedFrame.is() )
            xController = m_xAttachedFrame->getController();
        if ( xController.is() )
            xModel = xController->getModel();
    }
    catch( const Exception& )
    {
        DBG_UNHANDLED_EXCEPTION("svx");
    }
    return xModel;
}


bool FmXFormShell::isEnhancedForm_Lock() const
{
    return getDocumentType_Lock() == eEnhancedForm;
}


bool FmXFormShell::impl_checkDisposed_Lock() const
{
    DBG_TESTSOLARMUTEX();
    if ( !m_pShell )
    {
        OSL_FAIL( "FmXFormShell::impl_checkDisposed: already disposed!" );
        return true;
    }
    return false;
}


::svxform::DocumentType FmXFormShell::getDocumentType_Lock() const
{
    if ( m_eDocumentType != eUnknownDocumentType )
        return m_eDocumentType;

    // determine the type of document we live in
    Reference<css::frame::XModel> xModel = getContextDocument_Lock();
    if ( xModel.is() )
        m_eDocumentType = DocumentClassification::classifyDocument( xModel );
    else
    {
        OSL_FAIL( "FmXFormShell::getDocumentType: can't determine the document type!" );
        m_eDocumentType = eTextDocument;
            // fallback, just to have a defined state
    }

    return m_eDocumentType;
}


bool FmXFormShell::IsReadonlyDoc_Lock() const
{
    if (impl_checkDisposed_Lock())
        return true;

    FmFormModel* pModel = m_pShell->GetFormModel();
    if ( pModel && pModel->GetObjectShell() )
        return pModel->GetObjectShell()->IsReadOnly() || pModel->GetObjectShell()->IsReadOnlyUI();
    return true;
}

//  EventListener

void SAL_CALL FmXFormShell::disposing(const lang::EventObject& e)
{
    SolarMutexGuard g;

    if (m_xActiveController == e.Source)
    {
        // the controller will release, then release everything
        stopListening_Lock();
        m_xActiveForm = nullptr;
        m_xActiveController = nullptr;
        m_xNavigationController = nullptr;

        m_aActiveControllerFeatures.dispose();
        m_aNavControllerFeatures.dispose();

        if ( m_pShell )
            m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
    }

    if (e.Source != m_xExternalViewController)
        return;

    Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY );
    OSL_ENSURE( xFormController.is(), "FmXFormShell::disposing: invalid external view controller!" );
    if (xFormController.is())
        xFormController->removeActivateListener(static_cast<XFormControllerListener*>(this));

    if (m_xExternalViewController.is())
        m_xExternalViewController->removeEventListener(static_cast<XEventListener*>(static_cast<XPropertyChangeListener*>(this)));

    m_xExternalViewController = nullptr;
    m_xExternalDisplayedForm = nullptr;
    m_xExtViewTriggerController = nullptr;

    InvalidateSlot_Lock( SID_FM_VIEW_AS_GRID, false );
}


void SAL_CALL FmXFormShell::propertyChange(const PropertyChangeEvent& evt)
{
    SolarMutexGuard g;

    if (impl_checkDisposed_Lock())
        return;

    if (evt.PropertyName == FM_PROP_ROWCOUNT)
    {
        // The update following this forces a re-painting of the corresponding
        // slots. But if I am not in the MainThread of the application (because,
        // for example, a cursor is counting data sets at the moment and always
        // gives me this PropertyChanges), this can clash with normal paints in
        // the MainThread of the application. (Such paints happen, for example,
        // if one simply places another application over the office and switches
        // back again).
        // Therefore the use of the SolarMutex, which safeguards that.
        comphelper::SolarMutex& rSolarSafety = Application::GetSolarMutex();
        if (rSolarSafety.tryToAcquire())
        {
            m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_RECORD_TOTAL, true);
            m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Update(SID_FM_RECORD_TOTAL);
            rSolarSafety.release();
        }
        else
        {
            // with the following the slot is invalidated asynchron
            LockSlotInvalidation_Lock(true);
            InvalidateSlot_Lock(SID_FM_RECORD_TOTAL, false);
            LockSlotInvalidation_Lock(false);
        }
    }

    // this may be called from a non-main-thread so invalidate the shell asynchronously
    LockSlotInvalidation_Lock(true);
    InvalidateSlot_Lock(0, false); // special meaning : invalidate m_pShell
    LockSlotInvalidation_Lock(false);
}


void FmXFormShell::invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures )
{
    SolarMutexGuard g;

    if (impl_checkDisposed_Lock())
        return;

    OSL_ENSURE( !_rFeatures.empty(), "FmXFormShell::invalidateFeatures: invalid arguments!" );

    if ( !(m_pShell->GetViewShell() && m_pShell->GetViewShell()->GetViewFrame()) )
        return;

    // unfortunately, SFX requires sal_uInt16
    ::std::vector< sal_uInt16 > aSlotIds( _rFeatures.begin(), _rFeatures.end() );

    // furthermore, SFX wants a terminating 0
    aSlotIds.push_back( 0 );

    // and, last but not least, SFX wants the ids to be sorted
    ::std::sort( aSlotIds.begin(), aSlotIds.end() - 1 );

    sal_uInt16 *pSlotIds = aSlotIds.data();
    m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( pSlotIds );
}


void SAL_CALL FmXFormShell::formActivated(const lang::EventObject& rEvent)
{
    SolarMutexGuard g;

    if (impl_checkDisposed_Lock())
        return;

    Reference< runtime::XFormController > xController( rEvent.Source, UNO_QUERY_THROW );
    m_pTextShell->formActivated( xController );
    setActiveController_Lock(xController);
}


void SAL_CALL FmXFormShell::formDeactivated(const lang::EventObject& rEvent)
{
    SolarMutexGuard g;

    if (impl_checkDisposed_Lock())
        return;

    Reference< runtime::XFormController > xController( rEvent.Source, UNO_QUERY_THROW );
    m_pTextShell->formDeactivated( xController );
}


void FmXFormShell::disposing()
{
    SolarMutexGuard g;

    FmXFormShell_BASE::disposing();

    if ( m_pShell && !m_pShell->IsDesignMode() )
        setActiveController_Lock(nullptr, true);
        // do NOT save the content of the old form (the second parameter tells this)
        // if we're here, then we expect that PrepareClose has been called, and thus the user
        // got a chance to commit or reject any changes. So in case we're here and there
        // are still uncommitted changes, the user explicitly wanted this.

    m_pTextShell->dispose();

    m_xAttachedFrame = nullptr;

    CloseExternalFormViewer_Lock();

    while ( !m_aLoadingPages.empty() )
    {
        Application::RemoveUserEvent( m_aLoadingPages.front().nEventId );
        m_aLoadingPages.pop();
    }

    {
        if (m_nInvalidationEvent)
        {
            Application::RemoveUserEvent(m_nInvalidationEvent);
            m_nInvalidationEvent = nullptr;
        }
        if ( m_nActivationEvent )
        {
            Application::RemoveUserEvent( m_nActivationEvent );
            m_nActivationEvent = nullptr;
        }
    }

    {
        DBG_ASSERT(!m_nInvalidationEvent, "FmXFormShell::~FmXFormShell : still have an invalidation event !");
            // should have been deleted while being disposed

        m_aMarkTimer.Stop();
    }

    DisableNotification();

    RemoveElement_Lock(m_xForms);
    m_xForms.clear();

    impl_switchActiveControllerListening_Lock(false);
    m_xActiveController         = nullptr;
    m_xActiveForm               = nullptr;

    m_pShell                    = nullptr;
    m_xNavigationController     = nullptr;
    m_xCurrentForm              = nullptr;
    m_xLastGridFound            = nullptr;
    m_xAttachedFrame            = nullptr;
    m_xExternalViewController   = nullptr;
    m_xExtViewTriggerController = nullptr;
    m_xExternalDisplayedForm    = nullptr;

    InterfaceBag().swap(m_aCurrentSelection);

    m_aActiveControllerFeatures.dispose();
    m_aNavControllerFeatures.dispose();
}


void FmXFormShell::UpdateSlot_Lock(sal_Int16 _nId)
{
    if (impl_checkDisposed_Lock())
        return;

    if ( m_nLockSlotInvalidation )
    {
        OSL_FAIL( "FmXFormShell::UpdateSlot: cannot update if invalidation is currently locked!" );
        InvalidateSlot_Lock(_nId, false);
    }
    else
    {
        OSL_ENSURE( _nId, "FmXFormShell::UpdateSlot: can't update the complete shell!" );
        m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( _nId, true, true );
        m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Update( _nId );
    }
}


void FmXFormShell::InvalidateSlot_Lock(sal_Int16 nId, bool bWithId)
{
    if (impl_checkDisposed_Lock())
        return;

    if (m_nLockSlotInvalidation)
    {
        sal_uInt8 nFlags = ( bWithId ? 0x01 : 0 );
        m_arrInvalidSlots.emplace_back(nId, nFlags );
    }
    else
        if (nId)
            m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(nId, true, bWithId);
        else
            m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
}


void FmXFormShell::LockSlotInvalidation_Lock(bool bLock)
{
    if (impl_checkDisposed_Lock())
        return;

    DBG_ASSERT(bLock || m_nLockSlotInvalidation>0, "FmXFormShell::LockSlotInvalidation : invalid call !");

    if (bLock)
        ++m_nLockSlotInvalidation;
    else if (!--m_nLockSlotInvalidation)
    {
        // (asynchronously) invalidate everything accumulated during the locked phase
        if (!m_nInvalidationEvent)
            m_nInvalidationEvent = Application::PostUserEvent(LINK(this, FmXFormShell, OnInvalidateSlots_Lock));
    }
}


IMPL_LINK_NOARG(FmXFormShell, OnInvalidateSlots_Lock, void*,void)
{
    if (impl_checkDisposed_Lock())
        return;

    m_nInvalidationEvent = nullptr;

    for (const auto& rInvalidSlot : m_arrInvalidSlots)
    {
        if (rInvalidSlot.id)
            m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(rInvalidSlot.id, true, (rInvalidSlot.flags & 0x01));
        else
            m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
    }
    m_arrInvalidSlots.clear();
}


void FmXFormShell::ForceUpdateSelection_Lock()
{
    if (impl_checkDisposed_Lock())
        return;

    if (IsSelectionUpdatePending_Lock())
    {
        m_aMarkTimer.Stop();

        // optionally turn off the invalidation of slots which is implicitly done by SetSelection
        LockSlotInvalidation_Lock(true);

        SetSelection_Lock(m_pShell->GetFormView()->GetMarkedObjectList());

        LockSlotInvalidation_Lock(false);
    }
}

void FmXFormShell::GetConversionMenu_Lock(weld::Menu& rNewMenu)
{
    for (size_t i = 0; i < SAL_N_ELEMENTS(aConvertSlots); ++i)
    {
        // the corresponding image at it
        rNewMenu.append(OUString::createFromAscii(aConvertSlots[i]), SvxResId(RID_SVXSW_CONVERTMENU[i]), aImgIds[i]);
    }
}

OString FmXFormShell::SlotToIdent(sal_uInt16 nSlot)
{
    static_assert(SAL_N_ELEMENTS(SelObjectSlotMap) >= SAL_N_ELEMENTS(aConvertSlots));

    for (size_t i = 0; i < SAL_N_ELEMENTS(aConvertSlots); ++i)
    {
        if (nSlot == SelObjectSlotMap[i])
            return aConvertSlots[i];
    }

    return OString();
}

bool FmXFormShell::isControlConversionSlot(std::string_view rIdent)
{
    for (const auto& rConvertSlot : aConvertSlots)
        if (rIdent == rConvertSlot)
            return true;
    return false;
}

void FmXFormShell::executeControlConversionSlot_Lock(std::string_view rIdent)
{
    OSL_PRECOND( canConvertCurrentSelectionToControl_Lock(rIdent), "FmXFormShell::executeControlConversionSlot: illegal call!" );
    InterfaceBag::const_iterator aSelectedElement = m_aCurrentSelection.begin();
    if ( aSelectedElement == m_aCurrentSelection.end() )
        return;

    executeControlConversionSlot_Lock(Reference<XFormComponent>(*aSelectedElement, UNO_QUERY), rIdent);
}

bool FmXFormShell::executeControlConversionSlot_Lock(const Reference<XFormComponent>& _rxObject, std::string_view rIdent)
{
    if (impl_checkDisposed_Lock())
        return false;

    OSL_ENSURE( _rxObject.is(), "FmXFormShell::executeControlConversionSlot: invalid object!" );
    if ( !_rxObject.is() )
        return false;

    SdrPage* pPage = m_pShell->GetCurPage();
    FmFormPage* pFormPage = dynamic_cast< FmFormPage* >( pPage );
    OSL_ENSURE( pFormPage, "FmXFormShell::executeControlConversionSlot: no current (form) page!" );
    if ( !pFormPage )
        return false;

    OSL_ENSURE( isSolelySelected_Lock(_rxObject),
        "FmXFormShell::executeControlConversionSlot: hmm ... shouldn't this parameter be redundant?" );

    for (size_t lookupSlot = 0; lookupSlot < SAL_N_ELEMENTS(aConvertSlots); ++lookupSlot)
    {
        if (rIdent == aConvertSlots[lookupSlot])
        {
            Reference< XInterface > xNormalizedObject( _rxObject, UNO_QUERY );

            FmFormObj* pFormObject = nullptr;
            SdrObjListIter aPageIter( pFormPage );
            while ( aPageIter.IsMore() )
            {
                SdrObject* pCurrent = aPageIter.Next();
                pFormObject = FmFormObj::GetFormObject( pCurrent );
                if ( !pFormObject )
                    continue;

                Reference< XInterface > xCurrentNormalized( pFormObject->GetUnoControlModel(), UNO_QUERY );
                if ( xCurrentNormalized.get() == xNormalizedObject.get() )
                    break;

                pFormObject = nullptr;
            }

            if ( !pFormObject )
                return false;

            OUString sNewName( getServiceNameByControlType( nObjectTypes[ lookupSlot ] ) );
            Reference<XComponentContext> xContext = comphelper::getProcessComponentContext();
            Reference< XControlModel> xNewModel( xContext->getServiceManager()->createInstanceWithContext(sNewName, xContext), UNO_QUERY );
            if (!xNewModel.is())
                return false;

            Reference< XControlModel> xOldModel( pFormObject->GetUnoControlModel() );

            // transfer properties
            Reference< XPropertySet> xOldSet(xOldModel, UNO_QUERY);
            Reference< XPropertySet> xNewSet(xNewModel, UNO_QUERY);


            lang::Locale aNewLanguage = Application::GetSettings().GetUILanguageTag().getLocale();
            TransferFormComponentProperties(xOldSet, xNewSet, aNewLanguage);

            Sequence< css::script::ScriptEventDescriptor> aOldScripts;
            Reference< XChild> xChild(xOldModel, UNO_QUERY);
            if (xChild.is())
            {
                Reference< XIndexAccess> xParent(xChild->getParent(), UNO_QUERY);

                // remember old script events
                Reference< css::script::XEventAttacherManager> xEvManager(xChild->getParent(), UNO_QUERY);
                if (xParent.is() && xEvManager.is())
                {
                    sal_Int32 nIndex = getElementPos(xParent, xOldModel);
                    if (nIndex>=0 && nIndex<xParent->getCount())
                        aOldScripts = xEvManager->getScriptEvents(nIndex);
                }

                // replace the model within the parent container
                Reference< XIndexContainer> xIndexParent(xChild->getParent(), UNO_QUERY);
                if (xIndexParent.is())
                {
                    // the form container works with FormComponents
                    Reference< XFormComponent> xComponent(xNewModel, UNO_QUERY);
                    DBG_ASSERT(xComponent.is(), "FmXFormShell::executeControlConversionSlot: the new model is no form component !");
                    Any aNewModel(xComponent);
                    try
                    {

                        sal_Int32 nIndex = getElementPos(xParent, xOldModel);
                        if (nIndex>=0 && nIndex<xParent->getCount())
                            xIndexParent->replaceByIndex(nIndex, aNewModel);
                        else
                        {
                            OSL_FAIL("FmXFormShell::executeControlConversionSlot: could not replace the model !");
                            Reference< css::lang::XComponent> xNewComponent(xNewModel, UNO_QUERY);
                            if (xNewComponent.is())
                                xNewComponent->dispose();
                            return false;
                        }
                    }
                    catch(Exception&)
                    {
                        OSL_FAIL("FmXFormShell::executeControlConversionSlot: could not replace the model !");
                        Reference< css::lang::XComponent> xNewComponent(xNewModel, UNO_QUERY);
                        if (xNewComponent.is())
                            xNewComponent->dispose();
                        return false;
                    }

                }
            }

            // special handling for the LabelControl-property : can only be set when the model is placed
            // within the forms hierarchy
            if (::comphelper::hasProperty(FM_PROP_CONTROLLABEL, xOldSet) && ::comphelper::hasProperty(FM_PROP_CONTROLLABEL, xNewSet))
            {
                try
                {
                    xNewSet->setPropertyValue(FM_PROP_CONTROLLABEL, xOldSet->getPropertyValue(FM_PROP_CONTROLLABEL));
                }
                catch(Exception&)
                {
                }

            }

            // set new model
            pFormObject->SetChanged();
            pFormObject->SetUnoControlModel(xNewModel);

            // transfer script events
            // (do this _after_ SetUnoControlModel as we need the new (implicitly created) control)
            if (aOldScripts.hasElements())
            {
                // find the control for the model
                Reference<XControlContainer> xControlContainer(getControlContainerForView_Lock());

                const Sequence< Reference< XControl> > aControls( xControlContainer->getControls() );

                Reference< XControl> xControl;
                auto pControl = std::find_if(aControls.begin(), aControls.end(),
                    [&xNewModel](const Reference< XControl>& rControl) { return rControl->getModel() == xNewModel; });
                if (pControl != aControls.end())
                    xControl = *pControl;
                TransferEventScripts(xNewModel, xControl, aOldScripts);
            }

            // transfer value bindings, if possible
            {
                Reference< XBindableValue > xOldBindable( xOldModel, UNO_QUERY );
                Reference< XBindableValue > xNewBindable( xNewModel, UNO_QUERY );
                if ( xOldBindable.is() )
                {
                    try
                    {
                        if ( xNewBindable.is() )
                            xNewBindable->setValueBinding( xOldBindable->getValueBinding() );
                        xOldBindable->setValueBinding( nullptr );
                    }
                    catch(const Exception&)
                    {
                        DBG_UNHANDLED_EXCEPTION("svx");
                    }
                }
            }
            // same for list entry sources
            {
                Reference< XListEntrySink > xOldSink( xOldModel, UNO_QUERY );
                Reference< XListEntrySink > xNewSink( xNewModel, UNO_QUERY );
                if ( xOldSink.is() )
                {
                    try
                    {
                        if ( xNewSink.is() )
                            xNewSink->setListEntrySource( xOldSink->getListEntrySource() );
                        xOldSink->setListEntrySource( nullptr );
                    }
                    catch(const Exception&)
                    {
                        DBG_UNHANDLED_EXCEPTION("svx");
                    }
                }
            }

            // create an undo action
            FmFormModel* pModel = m_pShell->GetFormModel();
            DBG_ASSERT(pModel != nullptr, "FmXFormShell::executeControlConversionSlot: my shell has no model !");
            if (pModel && pModel->IsUndoEnabled() )
            {
                pModel->AddUndo(std::make_unique<FmUndoModelReplaceAction>(*pModel, pFormObject, xOldModel));
            }
            else
            {
                FmUndoModelReplaceAction::DisposeElement( xOldModel );
            }

            return true;
        }
    }
    return false;
}

bool FmXFormShell::canConvertCurrentSelectionToControl_Lock(std::string_view rIdent)
{
    if ( m_aCurrentSelection.empty() )
        return false;

    InterfaceBag::const_iterator aCheck = m_aCurrentSelection.begin();
    Reference< lang::XServiceInfo > xElementInfo( *aCheck, UNO_QUERY );
    if ( !xElementInfo.is() )
        // no service info -> cannot determine this
        return false;

    if (  ++aCheck != m_aCurrentSelection.end() )
        // more than one element
        return false;

    if ( Reference< XForm >::query( xElementInfo ).is() )
        // it's a form
        return false;

    SdrObjKind nObjectType = getControlTypeByObject( xElementInfo );

    if (  ( SdrObjKind::FormHidden == nObjectType )
       || ( SdrObjKind::FormControl == nObjectType )
       || ( SdrObjKind::FormGrid == nObjectType )
       )
        return false;   // those types cannot be converted

    DBG_ASSERT(SAL_N_ELEMENTS(aConvertSlots) == SAL_N_ELEMENTS(nObjectTypes),
        "FmXFormShell::canConvertCurrentSelectionToControl: aConvertSlots & nObjectTypes must have the same size !");

    for (size_t i = 0; i < SAL_N_ELEMENTS(aConvertSlots); ++i)
        if (rIdent == aConvertSlots[i])
            return nObjectTypes[i] != nObjectType;

    return true;    // all other slots: assume "yes"
}

void FmXFormShell::checkControlConversionSlotsForCurrentSelection_Lock(weld::Menu& rMenu)
{
    for (int i = 0, nCount = rMenu.n_children(); i < nCount; ++i)
    {
        // the context is already of a type that corresponds to the entry -> disable
        OString sIdent(aConvertSlots[i]);
        rMenu.set_sensitive(sIdent, canConvertCurrentSelectionToControl_Lock(sIdent));
    }
}

void FmXFormShell::LoopGrids_Lock(LoopGridsSync nSync, LoopGridsFlags nFlags)
{
    if (impl_checkDisposed_Lock())
        return;

    Reference< XIndexContainer> xControlModels(m_xActiveForm, UNO_QUERY);
    if (!xControlModels.is())
        return;

    for (sal_Int32 i=0; i<xControlModels->getCount(); ++i)
    {
        Reference< XPropertySet> xModelSet;
        xControlModels->getByIndex(i) >>= xModelSet;
        if (!xModelSet.is())
            continue;

        if (!::comphelper::hasProperty(FM_PROP_CLASSID, xModelSet))
            continue;
        sal_Int16 nClassId = ::comphelper::getINT16(xModelSet->getPropertyValue(FM_PROP_CLASSID));
        if (FormComponentType::GRIDCONTROL != nClassId)
            continue;

        if (!::comphelper::hasProperty(FM_PROP_CURSORCOLOR, xModelSet) || !::comphelper::hasProperty(FM_PROP_ALWAYSSHOWCURSOR, xModelSet) || !::comphelper::hasProperty(FM_PROP_DISPLAYSYNCHRON, xModelSet))
            continue;

        switch (nSync)
        {
            case LoopGridsSync::DISABLE_SYNC:
            {
                xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(false));
            }
            break;
            case LoopGridsSync::FORCE_SYNC:
            {
                Any aOldVal( xModelSet->getPropertyValue(FM_PROP_DISPLAYSYNCHRON) );
                xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(true));
                xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, aOldVal);
            }
            break;
            case LoopGridsSync::ENABLE_SYNC:
            {
                xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(true));
            }
            break;
        }

        if (nFlags & LoopGridsFlags::DISABLE_ROCTRLR)
        {
            xModelSet->setPropertyValue(FM_PROP_ALWAYSSHOWCURSOR, Any(false));
            Reference< XPropertyState> xModelPropState(xModelSet, UNO_QUERY);
            if (xModelPropState.is())
                xModelPropState->setPropertyToDefault(FM_PROP_CURSORCOLOR);
            else
                xModelSet->setPropertyValue(FM_PROP_CURSORCOLOR, Any());        // this should be the default
        }
    }
}


Reference< XControlContainer > FmXFormShell::getControlContainerForView_Lock() const
{
    if (impl_checkDisposed_Lock())
        return nullptr;

    SdrPageView* pPageView = nullptr;
    if ( m_pShell && m_pShell->GetFormView() )
        pPageView = m_pShell->GetFormView()->GetSdrPageView();

    Reference< XControlContainer> xControlContainer;
    if ( pPageView )
        xControlContainer = pPageView->GetPageWindow(0)->GetControlContainer();

    return xControlContainer;
}


void FmXFormShell::ExecuteTabOrderDialog_Lock(const Reference<XTabControllerModel>& _rxForForm)
{
    if (impl_checkDisposed_Lock())
        return;

    OSL_PRECOND( _rxForForm.is(), "FmXFormShell::ExecuteTabOrderDialog: invalid tabbing model!" );
    if ( !_rxForForm.is() )
        return;

    try
    {
        Reference< XWindow > xParentWindow;
        if ( m_pShell->GetViewShell() && m_pShell->GetViewShell()->GetViewFrame() )
            xParentWindow = VCLUnoHelper::GetInterface ( &m_pShell->GetViewShell()->GetViewFrame()->GetWindow() );

        Reference< dialogs::XExecutableDialog > xDialog = form::TabOrderDialog::createWithModel(
                comphelper::getProcessComponentContext(),
                _rxForForm, getControlContainerForView_Lock(), xParentWindow
            );

        xDialog->execute();
    }
    catch( const Exception& )
    {
        TOOLS_WARN_EXCEPTION( "svx", "FmXFormShell::ExecuteTabOrderDialog" );
    }
}


void FmXFormShell::ExecuteSearch_Lock()
{
    if (impl_checkDisposed_Lock())
        return;

    // a collection of all (logical) forms
    FmFormArray().swap(m_aSearchForms);
    ::std::vector< OUString > aContextNames;
    impl_collectFormSearchContexts_nothrow_Lock(
        m_pShell->GetCurPage()->GetForms(), u"",
        m_aSearchForms, aContextNames);

    if ( m_aSearchForms.size() != aContextNames.size() )
    {
        SAL_WARN ( "svx.form", "FmXFormShell::ExecuteSearch: nonsense!" );
        return;
    }

    // filter out the forms which do not contain valid controls at all
    {
        FmFormArray aValidForms;
        ::std::vector< OUString > aValidContexts;
        FmFormArray::const_iterator form = m_aSearchForms.begin();
        ::std::vector< OUString >::const_iterator contextName = aContextNames.begin();
        for ( ; form != m_aSearchForms.end(); ++form, ++contextName )
        {
            FmSearchContext aTestContext;
            aTestContext.nContext = static_cast< sal_Int16 >( form - m_aSearchForms.begin() );
            sal_uInt32 nValidControls = OnSearchContextRequest_Lock(aTestContext);
            if ( nValidControls > 0 )
            {
                aValidForms.push_back( *form );
                aValidContexts.push_back( *contextName );
            }
        }

        m_aSearchForms.swap( aValidForms );
        aContextNames.swap( aValidContexts );
    }

    if (m_aSearchForms.empty() )
    {
        // there are no controls that meet all the conditions for a search
        std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
                                                                 VclMessageType::Warning, VclButtonsType::Ok,
                                                                 SvxResId(RID_STR_NODATACONTROLS)));
        xBox->run();
        return;
    }

    // now I need another 'initial context'
    sal_Int16 nInitialContext = 0;
    Reference<XForm> xActiveForm(getActiveForm_Lock());
    for ( size_t i=0; i<m_aSearchForms.size(); ++i )
    {
        if (m_aSearchForms.at(i) == xActiveForm)
        {
            nInitialContext = static_cast<sal_Int16>(i);
            break;
        }
    }

    // If the dialog should initially offer the text of the active control,
    // this must have an XTextComponent interface. An addition, this makes
    // sense only if the current field is also bound to a table (or whatever) field.
    OUString strActiveField;
    OUString strInitialText;
    // ... this I get from my FormController
    DBG_ASSERT(m_xActiveController.is(), "FmXFormShell::ExecuteSearch : no active controller !");
    Reference< XControl> xActiveControl( m_xActiveController->getCurrentControl());
    if (xActiveControl.is())
    {
        // the control can tell me its model ...
        Reference< XControlModel> xActiveModel( xActiveControl->getModel());
        DBG_ASSERT(xActiveModel.is(), "FmXFormShell::ExecuteSearch : active control has no model !");

        // I ask the model for the ControlSource property ...
        Reference< XPropertySet> xProperties(xActiveControl->getModel(), UNO_QUERY);
        if (::comphelper::hasProperty(FM_PROP_CONTROLSOURCE, xProperties) && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xProperties))
        {
            Reference< XPropertySet> xField;
            xProperties->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
            if (xField.is())    // (only when the thing is really bound)
            {
                // and the control itself for a TextComponent interface (so that I can pick up the text there)
                Reference< XTextComponent> xText(xActiveControl, UNO_QUERY);
                if (xText.is())
                {
                    strActiveField = getLabelName(xProperties);
                    strInitialText = xText->getText();
                }
            }
        }
        else
        {
            // the control itself has no ControlSource, but maybe it is a GridControl
            Reference< XGrid> xGrid(xActiveControl, UNO_QUERY);
            if (xGrid.is())
            {
                // for strActiveField I need the ControlSource of the column,
                // for that the columns container, for that the GridPeer
                Reference< XGridPeer> xGridPeer(xActiveControl->getPeer(), UNO_QUERY);
                Reference< XIndexAccess> xColumns;
                if (xGridPeer.is())
                    xColumns = xGridPeer->getColumns();

                sal_Int16 nViewCol = xGrid->getCurrentColumnPosition();
                sal_Int32 nModelCol = GridView2ModelPos(xColumns, nViewCol);
                Reference< XPropertySet> xCurrentCol;
                if(xColumns.is())
                    xColumns->getByIndex(nModelCol) >>= xCurrentCol;
                if (xCurrentCol.is())
                    strActiveField = ::comphelper::getString(xCurrentCol->getPropertyValue(FM_PROP_LABEL));

                // the text of the current column
                Reference< XIndexAccess> xColControls(xGridPeer, UNO_QUERY);
                Reference< XInterface> xCurControl;
                xColControls->getByIndex(nViewCol) >>= xCurControl;
                OUString sInitialText;
                if (IsSearchableControl(xCurControl, &sInitialText))
                    strInitialText = sInitialText;
            }
        }
    }

    // taking care of possible GridControls that I know
    LoopGrids_Lock(LoopGridsSync::DISABLE_SYNC);

    // Now I am ready for the dialogue.
    // When the potential deadlocks caused by the use of the solar mutex in
    // MTs VCLX... classes are eventually cleared, an SM_USETHREAD should be
    // placed here, because the search in a separate thread is nevertheless
    // somewhat more fluid. Should be, however, somehow made dependent of the
    // underlying cursor. DAO for example is not thread-safe.
    SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
    ScopedVclPtr<AbstractFmSearchDialog> pDialog(
            pFact->CreateFmSearchDialog(
                m_pShell->GetViewShell()->GetViewFrame()->GetFrameWeld(),
                strInitialText, aContextNames, nInitialContext,
                LINK(this, FmXFormShell, OnSearchContextRequest_Lock) ));
    pDialog->SetActiveField( strActiveField );
    pDialog->SetFoundHandler(LINK(this, FmXFormShell, OnFoundData_Lock));
    pDialog->SetCanceledNotFoundHdl(LINK(this, FmXFormShell, OnCanceledNotFound_Lock));
    pDialog->Execute();
    pDialog.disposeAndClear();

    // restore GridControls again
    LoopGrids_Lock(LoopGridsSync::ENABLE_SYNC, LoopGridsFlags::DISABLE_ROCTRLR);

    m_pShell->GetFormView()->UnMarkAll(m_pShell->GetFormView()->GetSdrPageView());
        // because I marked controls in OnFoundData (if I was there)
}


bool FmXFormShell::GetY2KState_Lock(sal_uInt16& n)
{
    if (impl_checkDisposed_Lock())
        return false;

    if (m_pShell->IsDesignMode())
        // in the design mode (without active controls) the main document is to take care of it
        return false;

    Reference<XForm> xForm(getActiveForm_Lock());
    if (!xForm.is())
        // no current form (in particular no current control) -> the main document is to take care
        return false;

    Reference< XRowSet> xDB(xForm, UNO_QUERY);
    DBG_ASSERT(xDB.is(), "FmXFormShell::GetY2KState : current form has no dbform-interface !");

    Reference< XNumberFormatsSupplier> xSupplier( getNumberFormats(getConnection(xDB)));
    if (xSupplier.is())
    {
        Reference< XPropertySet> xSet(xSupplier->getNumberFormatSettings());
        if (xSet.is())
        {
            try
            {
                Any aVal( xSet->getPropertyValue("TwoDigitDateStart") );
                aVal >>= n;
                return true;
            }
            catch(Exception&)
            {
            }

        }
    }
    return false;
}


void FmXFormShell::SetY2KState_Lock(sal_uInt16 n)
{
    if (impl_checkDisposed_Lock())
        return;

    Reference<XForm> xActiveForm(getActiveForm_Lock());
    Reference< XRowSet > xActiveRowSet( xActiveForm, UNO_QUERY );
    if ( xActiveRowSet.is() )
    {
        Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( getConnection( xActiveRowSet ) ) );
        if (xSupplier.is())
        {
            Reference< XPropertySet> xSet(xSupplier->getNumberFormatSettings());
            if (xSet.is())
            {
                try
                {
                    xSet->setPropertyValue("TwoDigitDateStart", Any(sal_uInt16(n)));
                }
                catch(Exception&)
                {
                    TOOLS_WARN_EXCEPTION("svx.form", "");
                }

            }
            return;
        }
    }

    // no active form found -> iterate through all current forms
    Reference< XIndexAccess> xCurrentForms( m_xForms);
    if (!xCurrentForms.is())
    {   // in the alive mode, my forms are not set, but the ones on the page are
        if (m_pShell->GetCurPage())
            xCurrentForms = m_pShell->GetCurPage()->GetForms( false );
    }
    if (!xCurrentForms.is())
        return;

    ::comphelper::IndexAccessIterator aIter(xCurrentForms);
    Reference< XInterface> xCurrentElement( aIter.Next());
    while (xCurrentElement.is())
    {
        // is the current element a DatabaseForm?
        Reference< XRowSet> xElementAsRowSet( xCurrentElement, UNO_QUERY );
        if ( xElementAsRowSet.is() )
        {
            Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( getConnection( xElementAsRowSet ) ) );
            if (!xSupplier.is())
                continue;

            Reference< XPropertySet> xSet(xSupplier->getNumberFormatSettings());
            if (xSet.is())
            {
                try
                {
                    xSet->setPropertyValue("TwoDigitDateStart", Any(sal_uInt16(n)));
                }
                catch(Exception&)
                {
                    TOOLS_WARN_EXCEPTION("svx.form", "");
                }

            }
        }
        xCurrentElement = aIter.Next();
    }
}


void FmXFormShell::CloseExternalFormViewer_Lock()
{
    if (impl_checkDisposed_Lock())
        return;

    if (!m_xExternalViewController.is())
        return;

    Reference< css::frame::XFrame> xExternalViewFrame( m_xExternalViewController->getFrame());
    Reference< css::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY);
    if (!xCommLink.is())
        return;

    xExternalViewFrame->setComponent(nullptr,nullptr);
    ::comphelper::disposeComponent(xExternalViewFrame);
    m_xExternalViewController   = nullptr;
    m_xExtViewTriggerController = nullptr;
    m_xExternalDisplayedForm    = nullptr;
}


Reference<XResultSet> FmXFormShell::getInternalForm_Lock(const Reference<XResultSet>& _xForm) const
{
    if (impl_checkDisposed_Lock())
        return nullptr;

    Reference< runtime::XFormController> xExternalCtrlr(m_xExternalViewController, UNO_QUERY);
    if (xExternalCtrlr.is() && (_xForm == xExternalCtrlr->getModel()))
    {
        DBG_ASSERT(m_xExternalDisplayedForm.is(), "FmXFormShell::getInternalForm : invalid external form !");
        return m_xExternalDisplayedForm;
    }
    return _xForm;
}


Reference<XForm> FmXFormShell::getInternalForm_Lock(const Reference<XForm>& _xForm) const
{
    if (impl_checkDisposed_Lock())
        return nullptr;

    Reference< runtime::XFormController > xExternalCtrlr(m_xExternalViewController, UNO_QUERY);
    if (xExternalCtrlr.is() && (_xForm == xExternalCtrlr->getModel()))
    {
        DBG_ASSERT(m_xExternalDisplayedForm.is(), "FmXFormShell::getInternalForm : invalid external form !");
        return Reference< XForm>(m_xExternalDisplayedForm, UNO_QUERY);
    }
    return _xForm;
}


namespace
{
    bool lcl_isNavigationRelevant( sal_Int32 _nWhich )
    {
        return  ( _nWhich == SID_FM_RECORD_FIRST )
            ||  ( _nWhich == SID_FM_RECORD_PREV )
            ||  ( _nWhich == SID_FM_RECORD_NEXT )
            ||  ( _nWhich == SID_FM_RECORD_LAST )
            ||  ( _nWhich == SID_FM_RECORD_NEW );
    }
}


bool FmXFormShell::IsFormSlotEnabled( sal_Int32 _nSlot, FeatureState* _pCompleteState ) const
{
    const svx::ControllerFeatures& rController =
            lcl_isNavigationRelevant( _nSlot )
        ?   getNavControllerFeatures_Lock()
        :   getActiveControllerFeatures_Lock();

    if ( !_pCompleteState )
        return rController->isEnabled( _nSlot );

    rController->getState( _nSlot, *_pCompleteState );
    return _pCompleteState->Enabled;
}


void FmXFormShell::ExecuteFormSlot_Lock( sal_Int32 _nSlot )
{
    const svx::ControllerFeatures& rController =
            lcl_isNavigationRelevant( _nSlot )
        ?   getNavControllerFeatures_Lock()
        :   getActiveControllerFeatures_Lock();

    rController->execute( _nSlot );

    if ( _nSlot != SID_FM_RECORD_UNDO )
        return;

    // if we're doing an UNDO, *and* if the affected form is the form which we also display
    // as external view, then we need to reset the controls of the external form, too
    if (getInternalForm_Lock(getActiveForm_Lock()) != m_xExternalDisplayedForm)
        return;

    Reference< XIndexAccess > xContainer( m_xExternalDisplayedForm, UNO_QUERY );
    if ( !xContainer.is() )
        return;

    Reference< XReset > xReset;
    for ( sal_Int32 i = 0; i < xContainer->getCount(); ++i )
    {
        if ( ( xContainer->getByIndex( i ) >>= xReset ) && xReset.is() )
        {
            // no resets on sub forms
            Reference< XForm > xAsForm( xReset, UNO_QUERY );
            if ( !xAsForm.is() )
                xReset->reset();
        }
    }
}


void FmXFormShell::impl_switchActiveControllerListening_Lock(const bool _bListen)
{
    if ( !m_xActiveController.is() )
        return;

    if ( _bListen )
        m_xActiveController->addEventListener( static_cast<XFormControllerListener*>(this) );
    else
        m_xActiveController->removeEventListener( static_cast<XFormControllerListener*>(this) );
}


void FmXFormShell::setActiveController_Lock(const Reference<runtime::XFormController>& xController, bool _bNoSaveOldContent)
{
    if (impl_checkDisposed_Lock())
        return;

    if (m_bChangingDesignMode)
        return;
    DBG_ASSERT(!m_pShell->IsDesignMode(), "only to be used in alive mode");

    // if the routine has been called a second time,
    // the focus should no longer be transferred
    if (m_bInActivate)
    {
        m_bSetFocus = xController != m_xActiveController;
        return;
    }

    if (xController == m_xActiveController)
        return;

    // switch all nav dispatchers belonging to the form of the current nav controller to 'non active'
    Reference< XResultSet> xNavigationForm;
    if (m_xNavigationController.is())
        xNavigationForm.set(m_xNavigationController->getModel(), UNO_QUERY);

    m_bInActivate = true;

    // check if the 2 controllers serve different forms
    Reference< XResultSet> xOldForm;
    if (m_xActiveController.is())
        xOldForm.set(m_xActiveController->getModel(), UNO_QUERY);
    Reference< XResultSet> xNewForm;
    if (xController.is())
        xNewForm = Reference< XResultSet>(xController->getModel(), UNO_QUERY);
    xOldForm = getInternalForm_Lock(xOldForm);
    xNewForm = getInternalForm_Lock(xNewForm);

    bool bDifferentForm = ( xOldForm.get() != xNewForm.get() );
    bool bNeedSave = bDifferentForm && !_bNoSaveOldContent;
        // we save the content of the old form if we move to a new form, and saving old content is allowed

    if ( m_xActiveController.is() && bNeedSave )
    {
        // save content on change of the controller; a commit has already been executed
        if ( m_aActiveControllerFeatures->commitCurrentControl() )
        {
            m_bSetFocus = true;
            if ( m_aActiveControllerFeatures->isModifiedRow() )
            {
                bool bIsNew = m_aActiveControllerFeatures->isInsertionRow();
                bool bResult = m_aActiveControllerFeatures->commitCurrentRecord();
                if ( !bResult && m_bSetFocus )
                {
                    // if we couldn't save the current record, set the focus back to the
                    // current control
                    Reference< XWindow > xWindow( m_xActiveController->getCurrentControl(), UNO_QUERY );
                    if ( xWindow.is() )
                        xWindow->setFocus();
                    m_bInActivate = false;
                    return;
                }
                else if ( bResult && bIsNew )
                {
                    Reference< XResultSet > xCursor( m_aActiveControllerFeatures->getCursor() );
                    if ( xCursor.is() )
                    {
                        DO_SAFE( xCursor->last(); );
                    }
                }
            }
        }
    }

    stopListening_Lock();

    impl_switchActiveControllerListening_Lock(false);

    m_aActiveControllerFeatures.dispose();
    m_xActiveController = xController;
    if ( m_xActiveController.is() )
        m_aActiveControllerFeatures.assign( m_xActiveController );

    impl_switchActiveControllerListening_Lock(true);

    if ( m_xActiveController.is() )
        m_xActiveForm = getInternalForm_Lock(Reference<XForm>(m_xActiveController->getModel(), UNO_QUERY));
    else
        m_xActiveForm = nullptr;

    startListening_Lock();

    // activate all dispatchers belonging to form of the new navigation controller
    xNavigationForm = nullptr;
    if (m_xNavigationController.is())
        xNavigationForm.set(m_xNavigationController->getModel(), UNO_QUERY);

    m_bInActivate = false;

    m_pShell->UIFeatureChanged();
    m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);

    InvalidateSlot_Lock(SID_FM_FILTER_NAVIGATOR_CONTROL, true);
}


void FmXFormShell::getCurrentSelection_Lock(InterfaceBag& /* [out] */ _rSelection) const
{
    _rSelection = m_aCurrentSelection;
}


bool FmXFormShell::setCurrentSelectionFromMark_Lock(const SdrMarkList& _rMarkList)
{
    m_aLastKnownMarkedControls.clear();

    if ( ( _rMarkList.GetMarkCount() > 0 ) && isControlList( _rMarkList ) )
        collectInterfacesFromMarkList( _rMarkList, m_aLastKnownMarkedControls );

    return setCurrentSelection_Lock(o3tl::sorted_vector(m_aLastKnownMarkedControls));
}


bool FmXFormShell::selectLastMarkedControls_Lock()
{
    return setCurrentSelection_Lock(o3tl::sorted_vector(m_aLastKnownMarkedControls));
}


bool FmXFormShell::setCurrentSelection_Lock( InterfaceBag&& _rSelection )
{
    if (impl_checkDisposed_Lock())
        return false;

    DBG_ASSERT( m_pShell->IsDesignMode(), "FmXFormShell::setCurrentSelection: only to be used in design mode!" );

    if ( _rSelection.empty() && m_aCurrentSelection.empty() )
        // nothing to do
        return false;

    if ( _rSelection.size() == m_aCurrentSelection.size() )
    {
        InterfaceBag::const_iterator aNew = _rSelection.begin();
        InterfaceBag::const_iterator aOld = m_aCurrentSelection.begin();
        for ( ; aNew != _rSelection.end(); ++aNew, ++aOld )
        {
            OSL_ENSURE( Reference< XInterface >( *aNew, UNO_QUERY ).get() == aNew->get(), "FmXFormShell::setCurrentSelection: new interface not normalized!" );
            OSL_ENSURE( Reference< XInterface >( *aOld, UNO_QUERY ).get() == aOld->get(), "FmXFormShell::setCurrentSelection: old interface not normalized!" );

            if ( aNew->get() != aOld->get() )
                break;
        }

        if ( aNew == _rSelection.end() )
            // both bags equal
            return false;
    }

    // the following is some strange code to ensure that when you have two grid controls in a document,
    // only one of them can have a selected column.
    // TODO: this should happen elsewhere, but not here - shouldn't it?
    if ( !m_aCurrentSelection.empty() )
    {
        Reference< XChild > xCur; if ( m_aCurrentSelection.size() == 1 ) xCur.set(*m_aCurrentSelection.begin(), css::uno::UNO_QUERY);
        Reference< XChild > xNew; if ( _rSelection.size() == 1 ) xNew.set(*_rSelection.begin(), css::uno::UNO_QUERY);

        // is there nothing to be selected, or the parents differ, and the parent of the current object
        // is a selection supplier, then deselect
        if ( xCur.is() && ( !xNew.is() || ( xCur->getParent() != xNew->getParent() ) ) )
        {
            Reference< XSelectionSupplier > xSel( xCur->getParent(), UNO_QUERY );
            if ( xSel.is() )
                xSel->select( Any() );
        }
    }

    m_aCurrentSelection = _rSelection;

    // determine the form which all the selected objects belong to, if any
    Reference< XForm > xNewCurrentForm;
    for (const auto& rpSelection : m_aCurrentSelection)
    {
        Reference< XForm > xThisRoundsForm( GetForm( rpSelection ) );
        OSL_ENSURE( xThisRoundsForm.is(), "FmXFormShell::setCurrentSelection: *everything* should belong to a form!" );

        if ( !xNewCurrentForm.is() )
        {   // the first form we encountered
            xNewCurrentForm = xThisRoundsForm;
        }
        else if ( xNewCurrentForm != xThisRoundsForm )
        {   // different forms -> no "current form" at all
            xNewCurrentForm.clear();
            break;
        }
    }

    if ( !m_aCurrentSelection.empty() )
        impl_updateCurrentForm_Lock(xNewCurrentForm);

    // ensure some slots are updated
    for (sal_Int16 i : SelObjectSlotMap)
        InvalidateSlot_Lock(i, false);

    return true;
}


bool FmXFormShell::isSolelySelected_Lock(const Reference<XInterface>& _rxObject)
{
    return ( m_aCurrentSelection.size() == 1 ) && ( *m_aCurrentSelection.begin() == _rxObject );
}


void FmXFormShell::forgetCurrentForm_Lock()
{
    if ( !m_xCurrentForm.is() )
        return;

    // reset ...
    impl_updateCurrentForm_Lock(nullptr);

    // ... and try finding a new current form
    // #i88186# / 2008-04-12 / frank.schoenheit@sun.com
    impl_defaultCurrentForm_nothrow_Lock();
}


void FmXFormShell::impl_updateCurrentForm_Lock(const Reference<XForm>& _rxNewCurForm)
{
    if (impl_checkDisposed_Lock())
        return;

    m_xCurrentForm = _rxNewCurForm;

    // propagate to the FormPage(Impl)
    FmFormPage* pPage = m_pShell->GetCurPage();
    if ( pPage )
        pPage->GetImpl().setCurForm( m_xCurrentForm );

    // ensure the UI which depends on the current form is up-to-date
    for (sal_Int16 i : DlgSlotMap)
        InvalidateSlot_Lock(i, false);
}


void FmXFormShell::startListening_Lock()
{
    if (impl_checkDisposed_Lock())
        return;

    Reference< XRowSet> xDatabaseForm(m_xActiveForm, UNO_QUERY);
    if (xDatabaseForm.is() && getConnection(xDatabaseForm).is())
    {
        Reference< XPropertySet> xActiveFormSet(m_xActiveForm, UNO_QUERY);
        if (xActiveFormSet.is())
        {
            // if there is a data source, then build the listener
            // TODO: this is strange - shouldn't this depend on a isLoaded instead of
            // a "has command value"? Finally, the command value only means that it was
            // intended to be loaded, not that it actually *is* loaded
            OUString aSource = ::comphelper::getString(xActiveFormSet->getPropertyValue(FM_PROP_COMMAND));
            if (!aSource.isEmpty())
            {
                m_bDatabaseBar = true;

                xActiveFormSet->getPropertyValue(FM_PROP_NAVIGATION) >>= m_eNavigate;

                switch (m_eNavigate)
                {
                    case NavigationBarMode_PARENT:
                    {
                        // search for the controller via which navigation is possible
                        Reference< XChild> xChild = m_xActiveController;
                        Reference< runtime::XFormController > xParent;
                        while (xChild.is())
                        {
                            xChild.set(xChild->getParent(), UNO_QUERY);
                            xParent.set(xChild, UNO_QUERY);
                            Reference< XPropertySet> xParentSet;
                            if (xParent.is())
                                xParentSet.set(xParent->getModel(), UNO_QUERY);
                            if (xParentSet.is())
                            {
                                xParentSet->getPropertyValue(FM_PROP_NAVIGATION) >>= m_eNavigate;
                                if (m_eNavigate == NavigationBarMode_CURRENT)
                                    break;
                            }
                        }
                        m_xNavigationController = xParent;
                    }
                    break;

                    case NavigationBarMode_CURRENT:
                        m_xNavigationController = m_xActiveController;
                        break;

                    default:
                        m_xNavigationController = nullptr;
                        m_bDatabaseBar = false;
                }

                m_aNavControllerFeatures.dispose();
                if ( m_xNavigationController.is() && ( m_xNavigationController != m_xActiveController ) )
                    m_aNavControllerFeatures.assign( m_xNavigationController );

                // because of RecordCount, listen at the controller which controls the navigation
                Reference< XPropertySet> xNavigationSet;
                if (m_xNavigationController.is())
                {
                    xNavigationSet.set(m_xNavigationController->getModel(), UNO_QUERY);
                    if (xNavigationSet.is())
                        xNavigationSet->addPropertyChangeListener(FM_PROP_ROWCOUNT,this);
                }
                return;
            }
        }
    }

    m_eNavigate  = NavigationBarMode_NONE;
    m_bDatabaseBar = false;
    m_xNavigationController = nullptr;
}


void FmXFormShell::stopListening_Lock()
{
    if (impl_checkDisposed_Lock())
        return;

    Reference< XRowSet> xDatabaseForm(m_xActiveForm, UNO_QUERY);
    if ( xDatabaseForm.is() )
    {
        if (m_xNavigationController.is())
        {
            Reference< XPropertySet> xSet(m_xNavigationController->getModel(), UNO_QUERY);
            if (xSet.is())
                xSet->removePropertyChangeListener(FM_PROP_ROWCOUNT, this);

        }
    }

    m_bDatabaseBar = false;
    m_eNavigate  = NavigationBarMode_NONE;
    m_xNavigationController = nullptr;
}


void FmXFormShell::ShowSelectionProperties_Lock(bool bShow)
{
    if (impl_checkDisposed_Lock())
        return;

    // if the window is already visible, only update the state
    bool bHasChild = m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_SHOW_PROPERTIES );
    if ( bHasChild && bShow )
        UpdateSlot_Lock(SID_FM_PROPERTY_CONTROL);

    // else toggle state
    else
        m_pShell->GetViewShell()->GetViewFrame()->ToggleChildWindow(SID_FM_SHOW_PROPERTIES);

    InvalidateSlot_Lock(SID_FM_PROPERTIES, false);
    InvalidateSlot_Lock(SID_FM_CTL_PROPERTIES, false);
}


IMPL_LINK(FmXFormShell, OnFoundData_Lock, FmFoundRecordInformation&, rfriWhere, void)
{
    if (impl_checkDisposed_Lock())
        return;

    DBG_ASSERT((rfriWhere.nContext >= 0) && (o3tl::make_unsigned(rfriWhere.nContext) < m_aSearchForms.size()),
        "FmXFormShell::OnFoundData : invalid context!");
    Reference< XForm> xForm( m_aSearchForms.at(rfriWhere.nContext));
    DBG_ASSERT(xForm.is(), "FmXFormShell::OnFoundData : invalid form!");

    Reference< XRowLocate> xCursor(xForm, UNO_QUERY);
    if (!xCursor.is())
        return;       // what should I do there?

    // to the record
    try
    {
        xCursor->moveToBookmark(rfriWhere.aPosition);
    }
    catch(const SQLException&)
    {
        OSL_FAIL("Can position on bookmark!");
    }

    LoopGrids_Lock(LoopGridsSync::FORCE_SYNC);

    // and to the field (for that, I collected the XVclComponent interfaces before the start of the search)
    SAL_WARN_IF(o3tl::make_unsigned(rfriWhere.nFieldPos) >=
            m_arrSearchedControls.size(),
        "svx.form", "FmXFormShell::OnFoundData : invalid index!");
    SdrObject* pObject = m_arrSearchedControls.at(rfriWhere.nFieldPos);

    m_pShell->GetFormView()->UnMarkAll(m_pShell->GetFormView()->GetSdrPageView());
    m_pShell->GetFormView()->MarkObj(pObject, m_pShell->GetFormView()->GetSdrPageView());

    FmFormObj* pFormObject = FmFormObj::GetFormObject( pObject );
    Reference< XControlModel > xControlModel( pFormObject ? pFormObject->GetUnoControlModel() : Reference< XControlModel >() );
    DBG_ASSERT( xControlModel.is(), "FmXFormShell::OnFoundData: invalid control!" );
    if ( !xControlModel.is() )
        return;

    // disable the permanent cursor for the last grid we found a record
    if (m_xLastGridFound.is() && (m_xLastGridFound != xControlModel))
    {
        Reference< XPropertySet> xOldSet(m_xLastGridFound, UNO_QUERY);
        xOldSet->setPropertyValue(FM_PROP_ALWAYSSHOWCURSOR, Any( false ) );
        Reference< XPropertyState> xOldSetState(xOldSet, UNO_QUERY);
        if (xOldSetState.is())
            xOldSetState->setPropertyToDefault(FM_PROP_CURSORCOLOR);
        else
            xOldSet->setPropertyValue(FM_PROP_CURSORCOLOR, Any());
    }

    // if the field is in a GridControl, I have to additionally go into the corresponding column there
    sal_Int32 nGridColumn = m_arrRelativeGridColumn[rfriWhere.nFieldPos];
    if (nGridColumn != -1)
    {   // unfortunately, I have to first get the control again
        Reference<XControl> xControl(pFormObject ? impl_getControl_Lock(xControlModel, *pFormObject) : Reference<XControl>());
        Reference< XGrid> xGrid(xControl, UNO_QUERY);
        DBG_ASSERT(xGrid.is(), "FmXFormShell::OnFoundData : invalid control!");
        // if one of the asserts fires, I probably did something wrong on building of m_arrSearchedControls

        // enable a permanent cursor for the grid so we can see the found text
        Reference< XPropertySet> xModelSet(xControlModel, UNO_QUERY);
        DBG_ASSERT(xModelSet.is(), "FmXFormShell::OnFoundData : invalid control model (no property set) !");
        xModelSet->setPropertyValue( FM_PROP_ALWAYSSHOWCURSOR, Any( true ) );
        xModelSet->setPropertyValue( FM_PROP_CURSORCOLOR, Any( COL_LIGHTRED ) );
        m_xLastGridFound = xControlModel;

        if ( xGrid.is() )
            xGrid->setCurrentColumnPosition(static_cast<sal_Int16>(nGridColumn));
    }

    // As the cursor has been repositioned, I have (in positioned) invalidated
    // my form bar slots. But that does not take effect here unfortunately, as
    // generally the (modal) search dialog is of course at the top ... So, force ...
    sal_uInt16 nPos = 0;
    while (DatabaseSlotMap[nPos])
        m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Update(DatabaseSlotMap[nPos++]);
        // unfortunately the update goes against the invalidate with only individual slots
}


IMPL_LINK(FmXFormShell, OnCanceledNotFound_Lock, FmFoundRecordInformation&, rfriWhere, void)
{
    if (impl_checkDisposed_Lock())
        return;

    DBG_ASSERT((rfriWhere.nContext >= 0) && (o3tl::make_unsigned(rfriWhere.nContext) < m_aSearchForms.size()),
        "FmXFormShell::OnCanceledNotFound : invalid context!");
    Reference< XForm> xForm( m_aSearchForms.at(rfriWhere.nContext));
    DBG_ASSERT(xForm.is(), "FmXFormShell::OnCanceledNotFound : invalid form!");

    Reference< XRowLocate> xCursor(xForm, UNO_QUERY);
    if (!xCursor.is())
        return;       // what should I do there?

    // to the record
    try
    {
        xCursor->moveToBookmark(rfriWhere.aPosition);
    }
    catch(const SQLException&)
    {
        OSL_FAIL("Can position on bookmark!");
    }


    m_pShell->GetFormView()->UnMarkAll(m_pShell->GetFormView()->GetSdrPageView());
}


IMPL_LINK(FmXFormShell, OnSearchContextRequest_Lock, FmSearchContext&, rfmscContextInfo, sal_uInt32)
{
    if (impl_checkDisposed_Lock())
        return 0;

    DBG_ASSERT(rfmscContextInfo.nContext < static_cast<sal_Int16>(m_aSearchForms.size()), "FmXFormShell::OnSearchContextRequest : invalid parameter !");
    Reference< XForm> xForm( m_aSearchForms.at(rfmscContextInfo.nContext));
    DBG_ASSERT(xForm.is(), "FmXFormShell::OnSearchContextRequest : unexpected : invalid context !");

    Reference< XResultSet> xIter(xForm, UNO_QUERY);
    DBG_ASSERT(xIter.is(), "FmXFormShell::OnSearchContextRequest : unexpected : context has no iterator !");


    // assemble the list of fields to involve (that is, the ControlSources of all fields that have such a property)
    OUString strFieldList, sFieldDisplayNames;
    m_arrSearchedControls.clear();
    m_arrRelativeGridColumn.clear();

    // small problem: To mark found fields, I need SdrObjects. To determine which controls
    // to include in the search, I need Controls (that is, XControl interfaces). So I have
    // to iterate over one of them and get the other in some way. Unfortunately, there is
    // no direct connection between the two worlds (except from a GetUnoControl to a
    // SdrUnoObject, but this requires an OutputDevice I can not do anything with.
    // However I can get to the Model from the Control and also from the SdrObject, and in
    // this way the assignment SdrObject<->Control is possible with a double loop.
    // The alternative to this (ugly but certainly not entirely fixable) solution would be
    // to renounce the caching of the SdrObjects, which would lead to significant extra
    // work in OnFoundData (since there I'd have to get the SdrObject first thing every
    // time). But since OnFoundData is usually called more often than ExecuteSearch, I'll
    // do that here.

    Reference< XNameAccess> xValidFormFields;
    Reference< XColumnsSupplier> xSupplyCols(xIter, UNO_QUERY);
    DBG_ASSERT(xSupplyCols.is(), "FmXFormShell::OnSearchContextRequest : invalid cursor : no columns supplier !");
    if (xSupplyCols.is())
        xValidFormFields = xSupplyCols->getColumns();
    DBG_ASSERT(xValidFormFields.is(), "FmXFormShell::OnSearchContextRequest : form has no fields !");

    // current Page/Controller
    FmFormPage* pCurrentPage = m_pShell->GetCurPage();
    assert(pCurrentPage && "FmXFormShell::OnSearchContextRequest : no page !");
    // Search all SdrControls of this page...
    OUString sControlSource, aName;

    SdrObjListIter aPageIter( pCurrentPage );
    while ( aPageIter.IsMore() )
    {
        SdrObject* pCurrent = aPageIter.Next();
        FmFormObj* pFormObject = FmFormObj::GetFormObject( pCurrent );
        // note that in case pCurrent is a virtual object, pFormObject points to the referenced object

        if ( !pFormObject )
            continue;

        // the current object's model, in different tastes
        Reference< XControlModel> xControlModel( pFormObject->GetUnoControlModel() );
        Reference< XFormComponent > xCurrentFormComponent( xControlModel, UNO_QUERY );
        DBG_ASSERT( xCurrentFormComponent.is(), "FmXFormShell::OnSearchContextRequest: invalid objects!" );
        if ( !xCurrentFormComponent.is() )
            continue;

        // does the component belong to the form which we're interested in?
        if ( xCurrentFormComponent->getParent() != xForm )
            continue;

        // ... ask for the ControlSource property
        SearchableControlIterator iter( xCurrentFormComponent );
        Reference< XControl> xControl;
        // the control that has model xControlModel
        // (the following while can be passed through several times, without the Control
        // being modified, so I don't have to search every time from scratch)

        Reference< XInterface > xSearchable( iter.Next() );
        while ( xSearchable.is() )
        {
            sControlSource = iter.getCurrentValue();
            if ( sControlSource.isEmpty() )
            {
                // the current element has no ControlSource, so it is a GridControl (that
                // is the only thing that still permits the SearchableControlIteratore)
                xControl = impl_getControl_Lock(xControlModel, *pFormObject);
                DBG_ASSERT(xControl.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !");

                Reference< XGridPeer> xGridPeer;
                if ( xControl.is() )
                    xGridPeer.set( xControl->getPeer(), UNO_QUERY );
                do
                {
                    if (!xGridPeer.is())
                        break;

                    Reference< XIndexAccess> xPeerContainer(xGridPeer, UNO_QUERY);
                    if (!xPeerContainer.is())
                        break;

                    Reference< XIndexAccess> xModelColumns = xGridPeer->getColumns();
                    DBG_ASSERT(xModelColumns.is(), "FmXFormShell::OnSearchContextRequest : there is a grid control without columns !");
                    // the case 'no columns' should be indicated with an empty container, I think ...
                    DBG_ASSERT(xModelColumns->getCount() >= xPeerContainer->getCount(), "FmXFormShell::OnSearchContextRequest : impossible : have more view than model columns !");

                    Reference< XInterface> xCurrentColumn;
                    for (sal_Int32 nViewPos=0; nViewPos<xPeerContainer->getCount(); ++nViewPos)
                    {
                        xPeerContainer->getByIndex(nViewPos) >>= xCurrentColumn;
                        if (!xCurrentColumn.is())
                            continue;

                        // can we use this column control for searching ?
                        if (!IsSearchableControl(xCurrentColumn))
                            continue;

                        sal_Int32 nModelPos = GridView2ModelPos(xModelColumns, nViewPos);
                        Reference< XPropertySet> xCurrentColModel;
                        xModelColumns->getByIndex(nModelPos) >>= xCurrentColModel;
                        aName = ::comphelper::getString(xCurrentColModel->getPropertyValue(FM_PROP_CONTROLSOURCE));
                        // the cursor has a field matching the control source ?
                        if (xValidFormFields->hasByName(aName))
                        {
                            strFieldList += aName + ";";

                            sFieldDisplayNames +=
                                    ::comphelper::getString(xCurrentColModel->getPropertyValue(FM_PROP_LABEL)) +
                                    ";";

                            rfmscContextInfo.arrFields.push_back(xCurrentColumn);

                            // and the SdrOject to the Field
                            m_arrSearchedControls.push_back(pCurrent);
                            // the number of the column
                            m_arrRelativeGridColumn.push_back(nViewPos);
                        }
                    }
                } while (false);
            }
            else
            {
                if (!sControlSource.isEmpty() && xValidFormFields->hasByName(sControlSource))
                {
                    // now I need the Control to SdrObject
                    if (!xControl.is())
                    {
                        xControl = impl_getControl_Lock(xControlModel, *pFormObject);
                        DBG_ASSERT(xControl.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !");
                    }

                    if (IsSearchableControl(xControl))
                    {
                        // all tests passed -> take along in the list
                        strFieldList += sControlSource + ";";

                        // the label which should appear for the control :
                        sFieldDisplayNames +=
                                getLabelName(Reference< XPropertySet>(xControlModel, UNO_QUERY)) +
                                ";";

                        // mark the SdrObject (accelerates the treatment in OnFoundData)
                        m_arrSearchedControls.push_back(pCurrent);

                        // the number of the column (here a dummy, since it is only interesting for GridControls)
                        m_arrRelativeGridColumn.push_back(-1);

                        // and for the formatted search...
                        rfmscContextInfo.arrFields.emplace_back( xControl, UNO_QUERY );
                    }
                }
            }

            xSearchable = iter.Next();
        }
    }

    strFieldList = comphelper::string::stripEnd(strFieldList, ';');
    sFieldDisplayNames = comphelper::string::stripEnd(sFieldDisplayNames, ';');

    if (rfmscContextInfo.arrFields.empty())
    {
        rfmscContextInfo.arrFields.clear();
        rfmscContextInfo.xCursor = nullptr;
        rfmscContextInfo.strUsedFields.clear();
        return 0;
    }

    rfmscContextInfo.xCursor = xIter;
    rfmscContextInfo.strUsedFields = strFieldList;
    rfmscContextInfo.sFieldDisplayNames = sFieldDisplayNames;

    // 66463 - 31.05.99 - FS
    // when the cursor is a non-STANDARD RecordMode, set it back
    Reference< XPropertySet> xCursorSet(rfmscContextInfo.xCursor, UNO_QUERY);
    Reference< XResultSetUpdate> xUpdateCursor(rfmscContextInfo.xCursor, UNO_QUERY);
    if (xUpdateCursor.is() && xCursorSet.is())
    {
        if (::comphelper::getBOOL(xCursorSet->getPropertyValue(FM_PROP_ISNEW)))
            xUpdateCursor->moveToCurrentRow();
        else if (::comphelper::getBOOL(xCursorSet->getPropertyValue(FM_PROP_ISMODIFIED)))
            xUpdateCursor->cancelRowUpdates();
    }

    return rfmscContextInfo.arrFields.size();
}

  // XContainerListener

void SAL_CALL FmXFormShell::elementInserted(const ContainerEvent& evt)
{
    SolarMutexGuard g;

    if (impl_checkDisposed_Lock())
        return;

    // new object to listen to
    Reference< XInterface> xTemp;
    evt.Element >>= xTemp;
    AddElement_Lock(xTemp);

    m_pShell->DetermineForms(true);
}


void SAL_CALL FmXFormShell::elementReplaced(const ContainerEvent& evt)
{
    SolarMutexGuard g;

    if (impl_checkDisposed_Lock() )
        return;

    Reference< XInterface> xTemp;
    evt.ReplacedElement >>= xTemp;
    RemoveElement_Lock(xTemp);
    evt.Element >>= xTemp;
    AddElement_Lock(xTemp);
}


void SAL_CALL FmXFormShell::elementRemoved(const ContainerEvent& evt)
{
    SolarMutexGuard g;

    if (impl_checkDisposed_Lock())
        return;

    Reference< XInterface> xTemp;
    evt.Element >>= xTemp;
    RemoveElement_Lock(xTemp);

    m_pShell->DetermineForms(true);
}


void FmXFormShell::UpdateForms_Lock(bool _bInvalidate)
{
    if (impl_checkDisposed_Lock())
        return;

    Reference< XIndexAccess > xForms;

    FmFormPage* pPage = m_pShell->GetCurPage();
    if ( pPage && m_pShell->m_bDesignMode )
        xForms = pPage->GetForms( false );

    if ( m_xForms != xForms )
    {
        RemoveElement_Lock( m_xForms );
        m_xForms = xForms;
        AddElement_Lock(m_xForms);
    }

    SolarMutexGuard g;
    m_pShell->DetermineForms( _bInvalidate );
}


void FmXFormShell::AddElement_Lock(const Reference<XInterface>& _xElement)
{
    if (impl_checkDisposed_Lock())
        return;
    impl_AddElement_nothrow(_xElement);
}

void FmXFormShell::impl_AddElement_nothrow(const Reference< XInterface>& Element)
{
    // listen at the container
    const Reference< XIndexContainer> xContainer(Element, UNO_QUERY);
    if (xContainer.is())
    {
        const sal_uInt32 nCount = xContainer->getCount();
        Reference< XInterface> xElement;
        for (sal_uInt32 i = 0; i < nCount; ++i)
        {
            xElement.set(xContainer->getByIndex(i),UNO_QUERY);
            impl_AddElement_nothrow(xElement);
        }

        const Reference< XContainer> xCont(Element, UNO_QUERY);
        if (xCont.is())
            xCont->addContainerListener(this);
    }

    const Reference< css::view::XSelectionSupplier> xSelSupplier(Element, UNO_QUERY);
    if (xSelSupplier.is())
        xSelSupplier->addSelectionChangeListener(this);
}


void FmXFormShell::RemoveElement_Lock(const Reference<XInterface>& Element)
{
    if (impl_checkDisposed_Lock())
        return;
    impl_RemoveElement_nothrow_Lock(Element);
}

void FmXFormShell::impl_RemoveElement_nothrow_Lock(const Reference<XInterface>& Element)
{
    const Reference< css::view::XSelectionSupplier> xSelSupplier(Element, UNO_QUERY);
    if (xSelSupplier.is())
        xSelSupplier->removeSelectionChangeListener(this);

    // remove connection to children
    const Reference< XIndexContainer> xContainer(Element, UNO_QUERY);
    if (xContainer.is())
    {
        const Reference< XContainer> xCont(Element, UNO_QUERY);
        if (xCont.is())
            xCont->removeContainerListener(this);

        const sal_uInt32 nCount = xContainer->getCount();
        Reference< XInterface> xElement;
        for (sal_uInt32 i = 0; i < nCount; i++)
        {
            xElement.set(xContainer->getByIndex(i),UNO_QUERY);
            impl_RemoveElement_nothrow_Lock(xElement);
        }
    }

    auto wasSelectedPos = m_aCurrentSelection.find( Element );
    if ( wasSelectedPos != m_aCurrentSelection.end() )
        m_aCurrentSelection.erase( wasSelectedPos );
}


void SAL_CALL FmXFormShell::selectionChanged(const lang::EventObject& rEvent)
{
    SolarMutexGuard g;

    if (impl_checkDisposed_Lock())
        return;

    Reference< XSelectionSupplier > xSupplier( rEvent.Source, UNO_QUERY );
    Reference< XInterface > xSelObj( xSupplier->getSelection(), UNO_QUERY );
    // a selection was removed, this can only be done by the shell
    if ( !xSelObj.is() )
        return;

    EnableTrackProperties_Lock(false);

    bool bMarkChanged = m_pShell->GetFormView()->checkUnMarkAll(rEvent.Source);

    InterfaceBag aNewSelection;
    aNewSelection.insert( Reference<XInterface>( xSelObj, UNO_QUERY ) );

    if (setCurrentSelection_Lock(std::move(aNewSelection)) && IsPropBrwOpen_Lock())
        ShowSelectionProperties_Lock(true);

    EnableTrackProperties_Lock(true);

    if ( bMarkChanged )
        m_pShell->NotifyMarkListChanged( m_pShell->GetFormView() );
}


IMPL_LINK_NOARG(FmXFormShell, OnTimeOut_Lock, Timer*, void)
{
    if (impl_checkDisposed_Lock())
        return;

    if (m_pShell->IsDesignMode() && m_pShell->GetFormView())
        SetSelection_Lock(m_pShell->GetFormView()->GetMarkedObjectList());
}


void FmXFormShell::SetSelectionDelayed_Lock()
{
    if (impl_checkDisposed_Lock())
        return;

    if (m_pShell->IsDesignMode() && IsTrackPropertiesEnabled_Lock() && !m_aMarkTimer.IsActive())
        m_aMarkTimer.Start();
}


void FmXFormShell::SetSelection_Lock(const SdrMarkList& rMarkList)
{
    if (impl_checkDisposed_Lock())
        return;

    DetermineSelection_Lock(rMarkList);
    m_pShell->NotifyMarkListChanged(m_pShell->GetFormView());
}


void FmXFormShell::DetermineSelection_Lock(const SdrMarkList& rMarkList)
{
    if (setCurrentSelectionFromMark_Lock(rMarkList) && IsPropBrwOpen_Lock())
        ShowSelectionProperties_Lock(true);
}


bool FmXFormShell::IsPropBrwOpen_Lock() const
{
    if (impl_checkDisposed_Lock())
        return false;

    return m_pShell->GetViewShell() && m_pShell->GetViewShell()->GetViewFrame()
        && m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow(SID_FM_SHOW_PROPERTIES);
}


class FmXFormShell::SuspendPropertyTracking
{
private:
    FmXFormShell&   m_rShell;
    bool            m_bEnabled;

public:
    explicit SuspendPropertyTracking( FmXFormShell& _rShell )
        :m_rShell( _rShell )
        ,m_bEnabled( false )
    {
        if (m_rShell.IsTrackPropertiesEnabled_Lock())
        {
            m_rShell.EnableTrackProperties_Lock(false);
            m_bEnabled = true;
        }
    }

    ~SuspendPropertyTracking( )
    {
        if ( m_bEnabled )   // note that ( false != m_bEnabled ) implies ( NULL != m_pShell )
            m_rShell.EnableTrackProperties_Lock(true);
    }
};


void FmXFormShell::SetDesignMode_Lock(bool bDesign)
{
    if (impl_checkDisposed_Lock())
        return;

    DBG_ASSERT(m_pShell->GetFormView(), "FmXFormShell::SetDesignMode : invalid call (have no shell or no view) !");
    m_bChangingDesignMode = true;

    // 67506 - 15.07.99 - FS
    // if we're switching off the design mode we have to force the property browser to be closed
    // so it can commit it's changes _before_ we load the forms
    if (!bDesign)
    {
        m_bHadPropertyBrowserInDesignMode = m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow(SID_FM_SHOW_PROPERTIES);
        if (m_bHadPropertyBrowserInDesignMode)
            m_pShell->GetViewShell()->GetViewFrame()->ToggleChildWindow(SID_FM_SHOW_PROPERTIES);
    }

    FmFormView* pFormView = m_pShell->GetFormView();
    if (bDesign)
    {
        // we are currently filtering, so stop filtering
        if (m_bFilterMode)
            stopFiltering_Lock(false);

        // unsubscribe from the objects of my MarkList
        pFormView->GetImpl()->stopMarkListWatching();
    }
    else
    {
        m_aMarkTimer.Stop();

        SuspendPropertyTracking aSuspend( *this );
        pFormView->GetImpl()->saveMarkList();
    }

    if (bDesign && m_xExternalViewController.is())
        CloseExternalFormViewer_Lock();

    pFormView->ChangeDesignMode(bDesign);

    // notify listeners
    FmDesignModeChangedHint aChangedHint( bDesign );
    m_pShell->Broadcast(aChangedHint);

    m_pShell->m_bDesignMode = bDesign;
    UpdateForms_Lock(false);

    m_pTextShell->designModeChanged();

    if (bDesign)
    {
        SdrMarkList aList;
        {
            // during changing the mark list, don't track the selected objects in the property browser
            SuspendPropertyTracking aSuspend( *this );
            // restore the marks
            pFormView->GetImpl()->restoreMarkList( aList );
        }

        // synchronize with the restored mark list
        if ( aList.GetMarkCount() )
            SetSelection_Lock(aList);
    }
    else
    {
        // subscribe to the model of the view (so that I'm informed when someone deletes
        // during the alive mode controls that I had saved in the saveMarklist (60343)
        pFormView->GetImpl()->startMarkListWatching();
    }

    m_pShell->UIFeatureChanged();

    // 67506 - 15.07.99 - FS
    if (bDesign && m_bHadPropertyBrowserInDesignMode)
    {
        // The UIFeatureChanged performs an update (a check of the available features) asynchronously.
        // So we can't call ShowSelectionProperties directly as the according feature isn't enabled yet.
        // That's why we use an asynchron execution on the dispatcher.
        // (And that's why this has to be done AFTER the UIFeatureChanged.)
        m_pShell->GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_SHOW_PROPERTY_BROWSER, SfxCallMode::ASYNCHRON );
    }
    m_bChangingDesignMode = false;
}


Reference< XControl> FmXFormShell::impl_getControl_Lock(const Reference<XControlModel>& i_rxModel, const FmFormObj& i_rKnownFormObj)
{
    if (impl_checkDisposed_Lock())
        return nullptr;

    Reference< XControl > xControl;
    try
    {
        Reference< XControlContainer> xControlContainer(getControlContainerForView_Lock(), UNO_SET_THROW);

        const Sequence< Reference< XControl > > seqControls( xControlContainer->getControls() );
        // ... that I can then search
        for (Reference< XControl > const & control : seqControls)
        {
            xControl.set( control, UNO_SET_THROW );
            Reference< XControlModel > xCurrentModel( xControl->getModel() );
            if ( xCurrentModel == i_rxModel )
                break;
            xControl.clear();
        }

        if ( !xControl.is() )
        {
            // fallback (some controls might not have been created, yet, since they were never visible so far)
            Reference< XControl > xContainerControl( xControlContainer, UNO_QUERY_THROW );
            const vcl::Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerControl->getPeer() );
            ENSURE_OR_THROW( pContainerWindow, "unexpected control container implementation" );

            const SdrView* pSdrView = m_pShell ? m_pShell->GetFormView() : nullptr;
            ENSURE_OR_THROW( pSdrView, "no current view" );

            xControl.set( i_rKnownFormObj.GetUnoControl( *pSdrView, *pContainerWindow->GetOutDev() ), UNO_SET_THROW );
        }
    }
    catch( const Exception& )
    {
        DBG_UNHANDLED_EXCEPTION("svx");
    }

    OSL_ENSURE( xControl.is(), "FmXFormShell::impl_getControl: no control found!" );
    return xControl;
}

// note: _out_rForms is a member so needs lock
void FmXFormShell::impl_collectFormSearchContexts_nothrow_Lock( const Reference<XInterface>& _rxStartingPoint,
    std::u16string_view _rCurrentLevelPrefix, FmFormArray& _out_rForms, ::std::vector< OUString >& _out_rNames )
{
    try
    {
        Reference< XIndexAccess> xContainer( _rxStartingPoint, UNO_QUERY );
        if ( !xContainer.is() )
            return;

        sal_Int32 nCount( xContainer->getCount() );
        if ( nCount == 0 )
            return;

        OUString sCurrentFormName;
        OUStringBuffer aNextLevelPrefix;
        for ( sal_Int32 i=0; i<nCount; ++i )
        {
            // is the current child a form?
            Reference< XForm > xCurrentAsForm( xContainer->getByIndex(i), UNO_QUERY );
            if ( !xCurrentAsForm.is() )
                continue;

            Reference< XNamed > xNamed( xCurrentAsForm, UNO_QUERY_THROW );
            sCurrentFormName = xNamed->getName();

            // the name of the current form
            OUString sCompleteCurrentName( sCurrentFormName );
            if ( !_rCurrentLevelPrefix.empty() )
            {
                sCompleteCurrentName += OUString::Concat(" (") + _rCurrentLevelPrefix + ")";
            }

            // the prefix for the next level
            aNextLevelPrefix = _rCurrentLevelPrefix;
            if ( !_rCurrentLevelPrefix.empty() )
                aNextLevelPrefix.append( '/' );
            aNextLevelPrefix.append( sCurrentFormName );

            // remember both the form and its "display name"
            _out_rForms.push_back( xCurrentAsForm );
            _out_rNames.push_back( sCompleteCurrentName );

            // and descend
            impl_collectFormSearchContexts_nothrow_Lock(
                xCurrentAsForm, aNextLevelPrefix,
                _out_rForms, _out_rNames);
            aNextLevelPrefix.setLength(0);
        }
    }
    catch( const Exception& )
    {
        DBG_UNHANDLED_EXCEPTION("svx");
    }
}


void FmXFormShell::startFiltering_Lock()
{
    if (impl_checkDisposed_Lock())
        return;

    // setting all forms in filter mode
    FmXFormView* pXView = m_pShell->GetFormView()->GetImpl();

    // if the active controller is our external one we have to use the trigger controller
    Reference< XControlContainer> xContainer;
    if (getActiveController_Lock() == m_xExternalViewController)
    {
        DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::startFiltering : inconsistent : active external controller, but no one triggered this !");
        xContainer = m_xExtViewTriggerController->getContainer();
    }
    else
        xContainer = getActiveController_Lock()->getContainer();

    rtl::Reference< FormViewPageWindowAdapter > pAdapter = pXView->findWindow( xContainer );
    if ( pAdapter.is() )
    {
        const ::std::vector< Reference< runtime::XFormController> >& rControllerList = pAdapter->GetList();
        for (const auto& rpController : rControllerList)
        {
            Reference< XModeSelector> xModeSelector(rpController, UNO_QUERY);
            if (xModeSelector.is())
                xModeSelector->setMode( "FilterMode" );
        }
    }

    m_bFilterMode = true;

    m_pShell->UIFeatureChanged();
    SfxViewFrame* pViewFrame = m_pShell->GetViewShell()->GetViewFrame();
    pViewFrame->GetBindings().InvalidateShell( *m_pShell );

    if  (   pViewFrame->KnowsChildWindow( SID_FM_FILTER_NAVIGATOR )
        &&  !pViewFrame->HasChildWindow( SID_FM_FILTER_NAVIGATOR )
        )
    {
        pViewFrame->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR );
    }
}


static void saveFilter(const Reference< runtime::XFormController >& _rxController)
{
    Reference< XPropertySet> xFormAsSet(_rxController->getModel(), UNO_QUERY);
    Reference< XPropertySet> xControllerAsSet(_rxController, UNO_QUERY);

    // call the subcontroller
    Reference< runtime::XFormController > xController;
    for (sal_Int32 i = 0, nCount = _rxController->getCount(); i < nCount; ++i)
    {
        _rxController->getByIndex(i) >>= xController;
        saveFilter(xController);
    }

    try
    {

        xFormAsSet->setPropertyValue(FM_PROP_FILTER, xControllerAsSet->getPropertyValue(FM_PROP_FILTER));
        xFormAsSet->setPropertyValue(FM_PROP_APPLYFILTER, Any( true ) );
    }
    catch (const Exception& )
    {
        DBG_UNHANDLED_EXCEPTION("svx");
    }

}


void FmXFormShell::stopFiltering_Lock(bool bSave)
{
    if (impl_checkDisposed_Lock())
        return;

    m_bFilterMode = false;

    FmXFormView* pXView = m_pShell->GetFormView()->GetImpl();

    // if the active controller is our external one we have to use the trigger controller
    Reference< XControlContainer> xContainer;
    if (getActiveController_Lock() == m_xExternalViewController)
    {
        DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::stopFiltering : inconsistent : active external controller, but no one triggered this !");
        xContainer = m_xExtViewTriggerController->getContainer();
    }
    else
        xContainer = getActiveController_Lock()->getContainer();

    rtl::Reference< FormViewPageWindowAdapter > pAdapter = pXView->findWindow(xContainer);
    if ( pAdapter.is() )
    {
        const ::std::vector< Reference< runtime::XFormController > >& rControllerList = pAdapter->GetList();
        ::std::vector < OUString >   aOriginalFilters;
        ::std::vector < bool >       aOriginalApplyFlags;

        if (bSave)
        {
            for (const auto& rpController : rControllerList)
            {
                // remember the current filter settings in case we're going to reload the forms below (which may fail)
                try
                {
                    Reference< XPropertySet > xFormAsSet(rpController->getModel(), UNO_QUERY);
                    aOriginalFilters.push_back(::comphelper::getString(xFormAsSet->getPropertyValue(FM_PROP_FILTER)));
                    aOriginalApplyFlags.push_back(::comphelper::getBOOL(xFormAsSet->getPropertyValue(FM_PROP_APPLYFILTER)));
                }
                catch(Exception&)
                {
                    OSL_FAIL("FmXFormShell::stopFiltering : could not get the original filter !");
                    // put dummies into the arrays so the they have the right size

                    if (aOriginalFilters.size() == aOriginalApplyFlags.size())
                        // the first getPropertyValue failed -> use two dummies
                        aOriginalFilters.emplace_back( );
                    aOriginalApplyFlags.push_back( false );
                }
                saveFilter(rpController);
            }
        }
        for (const auto& rController : rControllerList)
        {

            Reference< XModeSelector> xModeSelector(rController, UNO_QUERY);
            if (xModeSelector.is())
                xModeSelector->setMode( "DataMode" );
        }
        if (bSave)  // execute the filter
        {
            const ::std::vector< Reference< runtime::XFormController > > & rControllers = pAdapter->GetList();
            for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllers.begin();
                 j != rControllers.end(); ++j)
            {
                Reference< XLoadable> xReload((*j)->getModel(), UNO_QUERY);
                if (!xReload.is())
                    continue;
                Reference< XPropertySet > xFormSet(xReload, UNO_QUERY);

                try
                {
                    xReload->reload();
                }
                catch(Exception&)
                {
                    TOOLS_WARN_EXCEPTION("svx.form", "");
                }

                if (!isRowSetAlive(xFormSet))
                {   // something went wrong -> restore the original state
                    OUString sOriginalFilter = aOriginalFilters[ j - rControllers.begin() ];
                    bool bOriginalApplyFlag = aOriginalApplyFlags[ j - rControllers.begin() ];
                    try
                    {
                        xFormSet->setPropertyValue(FM_PROP_FILTER, Any(sOriginalFilter));
                        xFormSet->setPropertyValue(FM_PROP_APPLYFILTER, Any(bOriginalApplyFlag));
                        xReload->reload();
                    }
                    catch(const Exception&)
                    {
                        DBG_UNHANDLED_EXCEPTION("svx");
                    }
                }
            }
        }
    }

    m_pShell->UIFeatureChanged();
    m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
}


void FmXFormShell::CreateExternalView_Lock()
{
    if (impl_checkDisposed_Lock())
        return;

    DBG_ASSERT(m_xAttachedFrame.is(), "FmXFormShell::CreateExternalView : no frame !");

    // the frame the external view is displayed in
    bool bAlreadyExistent = m_xExternalViewController.is();
    Reference< css::frame::XFrame> xExternalViewFrame;

    Reference<runtime::XFormController> xCurrentNavController(getNavController_Lock());
        // the creation of the "partwindow" may cause a deactivate of the document which will result in our nav controller to be set to NULL

    // _first_ check if we have any valid fields we can use for the grid view
    // FS - 21.10.99 - 69219
    {
        FmXBoundFormFieldIterator aModelIterator(xCurrentNavController->getModel());
        bool bHaveUsableControls = false;
        for (;;)
        {
            Reference< XPropertySet> xCurrentModelSet(aModelIterator.Next(), UNO_QUERY);
            if (!xCurrentModelSet.is())
                break;
            // the FmXBoundFormFieldIterator only supplies controls with a valid control source
            // so we just have to check the field type
            sal_Int16 nClassId = ::comphelper::getINT16(xCurrentModelSet->getPropertyValue(FM_PROP_CLASSID));
            switch (nClassId)
            {
                case FormComponentType::IMAGECONTROL:
                case FormComponentType::CONTROL:
                    continue;
            }
            bHaveUsableControls = true;
            break;
        }

        if (!bHaveUsableControls)
        {
            std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
                                                                     VclMessageType::Warning, VclButtonsType::Ok,
                                                                     SvxResId(RID_STR_NOCONTROLS_FOR_EXTERNALDISPLAY)));
            xBox->run();
            return;
        }
    }

    // load the component for external form views
    if (!bAlreadyExistent)
    {
        OUString sFrameName("_beamer");
        URL aWantToDispatch;
        aWantToDispatch.Complete = FMURL_COMPONENT_FORMGRIDVIEW;

        Reference< css::frame::XDispatchProvider> xProv(m_xAttachedFrame, UNO_QUERY);
        Reference< css::frame::XDispatch> xDisp;
        if (xProv.is())
            xDisp = xProv->queryDispatch(aWantToDispatch, sFrameName,
                                         css::frame::FrameSearchFlag::CHILDREN | css::frame::FrameSearchFlag::CREATE);
        if (xDisp.is())
        {
            xDisp->dispatch(aWantToDispatch, Sequence< PropertyValue>());
        }

        // with this the component should be loaded, now search the frame where it resides in
        xExternalViewFrame = m_xAttachedFrame->findFrame(sFrameName, css::frame::FrameSearchFlag::CHILDREN);
        if (xExternalViewFrame.is())
        {
            m_xExternalViewController = xExternalViewFrame->getController();
            if (m_xExternalViewController.is())
                m_xExternalViewController->addEventListener(static_cast<XEventListener*>(static_cast<XPropertyChangeListener*>(this)));
        }
    }
    else
    {
        xExternalViewFrame = m_xExternalViewController->getFrame();
        Reference< css::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY);

        // if we display the active form we interpret the slot as "remove it"
        Reference< XForm> xCurrentModel(xCurrentNavController->getModel(), UNO_QUERY);
        if ((xCurrentModel == m_xExternalDisplayedForm) || (getInternalForm_Lock(xCurrentModel) == m_xExternalDisplayedForm))
        {
            if (m_xExternalViewController == getActiveController_Lock())
            {
                Reference< runtime::XFormController > xAsFormController( m_xExternalViewController, UNO_QUERY );
                ControllerFeatures aHelper( xAsFormController );
                (void)aHelper->commitCurrentControl();
            }

            Reference< runtime::XFormController > xNewController(m_xExtViewTriggerController);
            CloseExternalFormViewer_Lock();
            setActiveController_Lock(xNewController);
            return;
        }

        URL aClearURL;
        aClearURL.Complete = FMURL_GRIDVIEW_CLEARVIEW;

        Reference< css::frame::XDispatch> xClear( xCommLink->queryDispatch(aClearURL, OUString(), 0));
        if (xClear.is())
            xClear->dispatch(aClearURL, Sequence< PropertyValue>());
    }

    // TODO: We need an interceptor at the xSupplier, which forwards all queryDispatch requests to the FormController
    // instance for which this "external view" was triggered

    // get the dispatch interface of the frame so we can communicate (interceptable) with the controller
    Reference< css::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY);

    if (m_xExternalViewController.is())
    {
        DBG_ASSERT(xCommLink.is(), "FmXFormShell::CreateExternalView : the component doesn't have the necessary interfaces !");
        // collect the dispatchers we will need
        URL aAddColumnURL;
        aAddColumnURL.Complete = FMURL_GRIDVIEW_ADDCOLUMN;
        Reference< css::frame::XDispatch> xAddColumnDispatch( xCommLink->queryDispatch(aAddColumnURL, OUString(), 0));
        URL aAttachURL;
        aAttachURL.Complete = FMURL_GRIDVIEW_ATTACHTOFORM;
        Reference< css::frame::XDispatch> xAttachDispatch( xCommLink->queryDispatch(aAttachURL, OUString(), 0));

        if (xAddColumnDispatch.is() && xAttachDispatch.is())
        {
            DBG_ASSERT(xCurrentNavController.is(), "FmXFormShell::CreateExternalView : invalid call : have no nav controller !");
            // first : dispatch the descriptions for the columns to add
            sal_Int16 nAddedColumns = 0;

            // for radio buttons we need some special structures
            typedef std::map< OUString, Sequence< OUString> > MapUString2UstringSeq;
            typedef std::map< OUString, OUString > FmMapUString2UString;
            typedef std::map< OUString, sal_Int16 > FmMapUString2Int16;

            MapUString2UstringSeq   aRadioValueLists;
            MapUString2UstringSeq   aRadioListSources;
            FmMapUString2UString    aRadioControlSources;
            FmMapUString2Int16      aRadioPositions;

            FmXBoundFormFieldIterator aModelIterator(xCurrentNavController->getModel());
            OUString sColumnType,aGroupName,sControlSource;
            Sequence< Property> aProps;
            for (;;)
            {
                Reference< XPropertySet> xCurrentModelSet(aModelIterator.Next(), UNO_QUERY);
                if (!xCurrentModelSet.is())
                    break;
                OSL_ENSURE(xCurrentModelSet.is(),"xCurrentModelSet is null!");
                // create a description of the column to be created
                // first : determine it's type

                sal_Int16 nClassId = ::comphelper::getINT16(xCurrentModelSet->getPropertyValue(FM_PROP_CLASSID));
                switch (nClassId)
                {
                    case FormComponentType::RADIOBUTTON:
                    {
                        // get the label of the button (this is the access key for our structures)
                        aGroupName = getLabelName(xCurrentModelSet);

                        // add the reference value of the radio button to the list source sequence
                        Sequence< OUString>& aThisGroupLabels = aRadioListSources[aGroupName];
                        sal_Int32 nNewSizeL = aThisGroupLabels.getLength() + 1;
                        aThisGroupLabels.realloc(nNewSizeL);
                        aThisGroupLabels.getArray()[nNewSizeL - 1] = ::comphelper::getString(xCurrentModelSet->getPropertyValue(FM_PROP_REFVALUE));

                        // add the label to the value list sequence
                        Sequence< OUString>& aThisGroupControlSources = aRadioValueLists[aGroupName];
                        sal_Int32 nNewSizeC = aThisGroupControlSources.getLength() + 1;
                        aThisGroupControlSources.realloc(nNewSizeC);
                        aThisGroupControlSources.getArray()[nNewSizeC - 1] = ::comphelper::getString(xCurrentModelSet->getPropertyValue(FM_PROP_LABEL));

                        // remember the controls source of the radio group
                        sControlSource = ::comphelper::getString(xCurrentModelSet->getPropertyValue(FM_PROP_CONTROLSOURCE));
                        if (aRadioControlSources.find(aGroupName) == aRadioControlSources.end())
                            aRadioControlSources[aGroupName] = sControlSource;
#ifdef DBG_UTIL
                        else
                            DBG_ASSERT(aRadioControlSources[aGroupName] == sControlSource,
                            "FmXFormShell::CreateExternalView : inconsistent radio buttons detected !");
                            // (radio buttons with the same name should have the same control source)
#endif
                        // remember the position within the columns
                        if (aRadioPositions.find(aGroupName) == aRadioPositions.end())
                            aRadioPositions[aGroupName] = nAddedColumns;

                        // any further handling is done below
                    }
                    continue;

                    case FormComponentType::IMAGECONTROL:
                    case FormComponentType::CONTROL:
                        // no grid columns for these types (though they have a control source)
                        continue;
                    case FormComponentType::CHECKBOX:
                        sColumnType = FM_COL_CHECKBOX; break;
                    case FormComponentType::LISTBOX:
                        sColumnType = FM_COL_LISTBOX; break;
                    case FormComponentType::COMBOBOX:
                        sColumnType = FM_COL_COMBOBOX; break;
                    case FormComponentType::DATEFIELD:
                        sColumnType = FM_COL_DATEFIELD; break;
                    case FormComponentType::TIMEFIELD:
                        sColumnType = FM_COL_TIMEFIELD; break;
                    case FormComponentType::NUMERICFIELD:
                        sColumnType = FM_COL_NUMERICFIELD; break;
                    case FormComponentType::CURRENCYFIELD:
                        sColumnType = FM_COL_CURRENCYFIELD; break;
                    case FormComponentType::PATTERNFIELD:
                        sColumnType = FM_COL_PATTERNFIELD; break;

                    case FormComponentType::TEXTFIELD:
                        {
                            sColumnType = FM_COL_TEXTFIELD;
                            // we know at least two different controls which are TextFields : the basic edit field and the formatted
                            // field. we distinguish them by their service name
                            Reference< lang::XServiceInfo> xInfo(xCurrentModelSet, UNO_QUERY);
                            if (xInfo.is())
                            {
                                SdrObjKind nObjectType = getControlTypeByObject(xInfo);
                                if (SdrObjKind::FormFormattedField == nObjectType)
                                    sColumnType = FM_COL_FORMATTEDFIELD;
                            }
                        }
                        break;
                    default:
                        sColumnType = FM_COL_TEXTFIELD; break;
                }

                const sal_Int16 nDispatchArgs = 3;
                Sequence< PropertyValue> aDispatchArgs(nDispatchArgs);
                PropertyValue* pDispatchArgs = aDispatchArgs.getArray();

                // properties describing "meta data" about the column
                // the type
                pDispatchArgs->Name = FMARG_ADDCOL_COLUMNTYPE;
                pDispatchArgs->Value <<= sColumnType;
                ++pDispatchArgs;

                // the pos : append the col
                pDispatchArgs->Name = FMARG_ADDCOL_COLUMNPOS;
                pDispatchArgs->Value <<= nAddedColumns;
                ++pDispatchArgs;

                // the properties to forward to the new column
                Sequence< PropertyValue> aColumnProps(1);
                PropertyValue* pColumnProps = aColumnProps.getArray();

                // the label
                pColumnProps->Name = FM_PROP_LABEL;
                pColumnProps->Value <<= getLabelName(xCurrentModelSet);
                ++pColumnProps;

                // for all other props : transfer them
                Reference< XPropertySetInfo> xControlModelInfo( xCurrentModelSet->getPropertySetInfo());
                DBG_ASSERT(xControlModelInfo.is(), "FmXFormShell::CreateExternalView : the control model has no property info ! This will crash !");
                aProps = xControlModelInfo->getProperties();

                // realloc the control description sequence
                sal_Int32 nExistentDescs = pColumnProps - aColumnProps.getArray();
                aColumnProps.realloc(nExistentDescs + aProps.getLength());
                pColumnProps = aColumnProps.getArray() + nExistentDescs;

                for (const Property& rProp : std::as_const(aProps))
                {
                    if (rProp.Name == FM_PROP_LABEL)
                        // already set
                        continue;
                    if (rProp.Name == FM_PROP_DEFAULTCONTROL)
                        // allow the column's own "default control"
                        continue;
                    if (rProp.Attributes & PropertyAttribute::READONLY)
                        // assume that properties which are readonly for the control are ro for the column to be created, too
                        continue;

                    pColumnProps->Name = rProp.Name;
                    pColumnProps->Value = xCurrentModelSet->getPropertyValue(rProp.Name);
                    ++pColumnProps;
                }
                aColumnProps.realloc(pColumnProps - aColumnProps.getArray());

                // columns props are a dispatch argument
                pDispatchArgs->Name = "ColumnProperties"; // TODO : fmurl.*
                pDispatchArgs->Value <<= aColumnProps;
                ++pDispatchArgs;
                DBG_ASSERT(nDispatchArgs == (pDispatchArgs - aDispatchArgs.getConstArray()),
                    "FmXFormShell::CreateExternalView : forgot to adjust nDispatchArgs ?");

                // dispatch the "add column"
                xAddColumnDispatch->dispatch(aAddColumnURL, aDispatchArgs);
                ++nAddedColumns;
            }

            // now for the radio button handling
            sal_Int16 nOffset(0);
            // properties describing the "direct" column properties
            const sal_Int16 nListBoxDescription = 6;
            Sequence< PropertyValue> aListBoxDescription(nListBoxDescription);
            for (const auto& rCtrlSource : aRadioControlSources)
            {
                PropertyValue* pListBoxDescription = aListBoxDescription.getArray();
                // label
                pListBoxDescription->Name = FM_PROP_LABEL;
                pListBoxDescription->Value <<= rCtrlSource.first;
                ++pListBoxDescription;

                // control source
                pListBoxDescription->Name = FM_PROP_CONTROLSOURCE;
                pListBoxDescription->Value <<= rCtrlSource.second;
                ++pListBoxDescription;

                // bound column
                pListBoxDescription->Name = FM_PROP_BOUNDCOLUMN;
                pListBoxDescription->Value <<= sal_Int16(1);
                ++pListBoxDescription;

                // content type
                pListBoxDescription->Name = FM_PROP_LISTSOURCETYPE;
                pListBoxDescription->Value <<= ListSourceType_VALUELIST;
                ++pListBoxDescription;

                // list source
                MapUString2UstringSeq::const_iterator aCurrentListSource = aRadioListSources.find(rCtrlSource.first);
                DBG_ASSERT(aCurrentListSource != aRadioListSources.end(),
                    "FmXFormShell::CreateExternalView : inconsistent radio descriptions !");
                pListBoxDescription->Name = FM_PROP_LISTSOURCE;
                pListBoxDescription->Value <<= (*aCurrentListSource).second;
                ++pListBoxDescription;

                // value list
                MapUString2UstringSeq::const_iterator aCurrentValueList = aRadioValueLists.find(rCtrlSource.first);
                DBG_ASSERT(aCurrentValueList != aRadioValueLists.end(),
                    "FmXFormShell::CreateExternalView : inconsistent radio descriptions !");
                pListBoxDescription->Name = FM_PROP_STRINGITEMLIST;
                pListBoxDescription->Value <<= (*aCurrentValueList).second;
                ++pListBoxDescription;

                DBG_ASSERT(nListBoxDescription == (pListBoxDescription - aListBoxDescription.getConstArray()),
                    "FmXFormShell::CreateExternalView : forgot to adjust nListBoxDescription ?");

                // properties describing the column "meta data"
                const sal_Int16 nDispatchArgs = 3;
                Sequence< PropertyValue> aDispatchArgs(nDispatchArgs);
                PropertyValue* pDispatchArgs = aDispatchArgs.getArray();

                // column type : listbox
                pDispatchArgs->Name = FMARG_ADDCOL_COLUMNTYPE;
                pDispatchArgs->Value <<= OUString(FM_COL_LISTBOX);
//              pDispatchArgs->Value <<= (OUString)FM_COL_LISTBOX;
                ++pDispatchArgs;

                // column position
                pDispatchArgs->Name = FMARG_ADDCOL_COLUMNPOS;
                FmMapUString2Int16::const_iterator aOffset = aRadioPositions.find(rCtrlSource.first);
                DBG_ASSERT(aOffset != aRadioPositions.end(),
                    "FmXFormShell::CreateExternalView : inconsistent radio descriptions !");
                sal_Int16 nPosition = (*aOffset).second;
                nPosition = nPosition + nOffset;
                    // we already inserted nOffset additional columns...
                pDispatchArgs->Value <<= nPosition;
                ++pDispatchArgs;

                // the
                pDispatchArgs->Name = "ColumnProperties"; // TODO : fmurl.*
                pDispatchArgs->Value <<= aListBoxDescription;
                ++pDispatchArgs;
                DBG_ASSERT(nDispatchArgs == (pDispatchArgs - aDispatchArgs.getConstArray()),
                    "FmXFormShell::CreateExternalView : forgot to adjust nDispatchArgs ?");

                // dispatch the "add column"
                xAddColumnDispatch->dispatch(aAddColumnURL, aDispatchArgs);
                ++nAddedColumns;
                ++nOffset;
            }


            DBG_ASSERT(nAddedColumns > 0, "FmXFormShell::CreateExternalView : no controls (inconsistent) !");
                // we should have checked if we have any usable controls (see above).

            // "load" the "form" of the external view
            PropertyValue aArg;
            aArg.Name = FMARG_ATTACHTO_MASTERFORM;
            Reference< XResultSet> xForm(xCurrentNavController->getModel(), UNO_QUERY);
            aArg.Value <<= xForm;

            m_xExternalDisplayedForm = xForm;
                // do this before dispatching the "attach" command, as the attach may result in a call to our queryDispatch (for the FormSlots)
                // which needs the m_xExternalDisplayedForm

            xAttachDispatch->dispatch(aAttachURL, Sequence< PropertyValue>(&aArg, 1));

            m_xExtViewTriggerController = xCurrentNavController;

            // we want to know modifications done in the external view
            // if the external controller is a XFormController we can use all our default handlings for it
            Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY );
            OSL_ENSURE( xFormController.is(), "FmXFormShell::CreateExternalView:: invalid external view controller!" );
            if (xFormController.is())
                xFormController->addActivateListener(static_cast<XFormControllerListener*>(this));
        }
    }
#ifdef DBG_UTIL
    else
    {
        OSL_FAIL("FmXFormShell::CreateExternalView : could not create the external form view !");
    }
#endif
    InvalidateSlot_Lock(SID_FM_VIEW_AS_GRID, false);
}


void FmXFormShell::implAdjustConfigCache_Lock()
{
    // get (cache) the wizard usage flag
    Sequence< OUString > aNames { "FormControlPilotsEnabled" };
    Sequence< Any > aFlags = GetProperties(aNames);
    if (1 == aFlags.getLength())
        m_bUseWizards = ::cppu::any2bool(aFlags[0]);
}


void FmXFormShell::Notify( const css::uno::Sequence< OUString >& _rPropertyNames)
{
    DBG_TESTSOLARMUTEX();
    if (impl_checkDisposed_Lock())
        return;

    for (const OUString& rName : _rPropertyNames)
        if (rName == "FormControlPilotsEnabled")
        {
            implAdjustConfigCache_Lock();
            InvalidateSlot_Lock(SID_FM_USE_WIZARDS, true);
        }
}

void FmXFormShell::ImplCommit()
{
}


void FmXFormShell::SetWizardUsing_Lock(bool _bUseThem)
{
    m_bUseWizards = _bUseThem;

    Sequence< OUString > aNames { "FormControlPilotsEnabled" };
    Sequence< Any > aValues{ Any(m_bUseWizards) };
    PutProperties(aNames, aValues);
}


void FmXFormShell::viewDeactivated_Lock(FmFormView& _rCurrentView, bool _bDeactivateController)
{

    if ( _rCurrentView.GetImpl() && !_rCurrentView.IsDesignMode() )
    {
        _rCurrentView.GetImpl()->Deactivate( _bDeactivateController );
    }

    // if we have an async load operation pending for the 0-th page for this view,
    // we need to cancel this
    if (FmFormPage* pPage = _rCurrentView.GetCurPage())
    {
        // move all events from our queue to a new one, omit the events for the deactivated
        // page
        ::std::queue< FmLoadAction > aNewEvents;
        while ( !m_aLoadingPages.empty() )
        {
            FmLoadAction aAction = m_aLoadingPages.front();
            m_aLoadingPages.pop();
            if ( pPage != aAction.pPage )
            {
                aNewEvents.push( aAction );
            }
            else
            {
                Application::RemoveUserEvent( aAction.nEventId );
            }
        }
        m_aLoadingPages = aNewEvents;

        // remove callbacks at the page
        pPage->GetImpl().SetFormsCreationHdl( Link<FmFormPageImpl&,void>() );
    }
    UpdateForms_Lock(true);
}


IMPL_LINK_NOARG( FmXFormShell, OnFirstTimeActivation_Lock, void*, void )
{
    if (impl_checkDisposed_Lock())
        return;

    m_nActivationEvent = nullptr;
    SfxObjectShell* pDocument = m_pShell->GetObjectShell();

    if  ( pDocument && !pDocument->HasName() )
    {
        if (isEnhancedForm_Lock())
        {
            // show the data navigator
            if ( !m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_SHOW_DATANAVIGATOR ) )
                m_pShell->GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_SHOW_DATANAVIGATOR );
        }
    }
}


IMPL_LINK_NOARG( FmXFormShell, OnFormsCreated_Lock, FmFormPageImpl&, void )
{
    UpdateForms_Lock(true);
}


void FmXFormShell::viewActivated_Lock(FmFormView& _rCurrentView, bool _bSyncAction)
{
    FmFormPage* pPage = _rCurrentView.GetCurPage();

    // activate our view if we are activated ourself
    // FS - 30.06.99 - 67308
    if ( _rCurrentView.GetImpl() && !_rCurrentView.IsDesignMode() )
    {
        // load forms for the page the current view belongs to
        if ( pPage )
        {
            if ( !pPage->GetImpl().hasEverBeenActivated() )
                loadForms_Lock(pPage, LoadFormsFlags::Load
                                      | (_bSyncAction ? LoadFormsFlags::Sync
                                                      : LoadFormsFlags::Async));
            pPage->GetImpl().setHasBeenActivated( );
        }

        // first-time initializations for the views
        if ( !_rCurrentView.GetImpl()->hasEverBeenActivated( ) )
        {
            _rCurrentView.GetImpl()->onFirstViewActivation( dynamic_cast<FmFormModel*>( _rCurrentView.GetModel() )  );
            _rCurrentView.GetImpl()->setHasBeenActivated( );
        }

        // activate the current view
        _rCurrentView.GetImpl()->Activate( _bSyncAction );
    }

    // set callbacks at the page
    if ( pPage )
    {
        pPage->GetImpl().SetFormsCreationHdl(LINK(this, FmXFormShell, OnFormsCreated_Lock));
    }

    UpdateForms_Lock(true);

    if ( m_bFirstActivation )
    {
        m_nActivationEvent = Application::PostUserEvent(LINK(this, FmXFormShell, OnFirstTimeActivation_Lock));
        m_bFirstActivation = false;
    }

    // find a default "current form", if there is none, yet
    // #i88186# / 2008-04-12 / frank.schoenheit@sun.com
    impl_defaultCurrentForm_nothrow_Lock();
}


void FmXFormShell::impl_defaultCurrentForm_nothrow_Lock()
{
    if (impl_checkDisposed_Lock())
        return;

    if ( m_xCurrentForm.is() )
        // no action required
        return;

    FmFormView* pFormView = m_pShell->GetFormView();
    FmFormPage* pPage = pFormView ? pFormView->GetCurPage() : nullptr;
    if ( !pPage )
        return;

    try
    {
        Reference< XIndexAccess > xForms = pPage->GetForms( false );
        if ( !xForms.is() || !xForms->hasElements() )
            return;

        Reference< XForm > xNewCurrentForm( xForms->getByIndex(0), UNO_QUERY_THROW );
        impl_updateCurrentForm_Lock(xNewCurrentForm);
    }
    catch( const Exception& )
    {
        DBG_UNHANDLED_EXCEPTION("svx");
    }
}


void FmXFormShell::smartControlReset( const Reference< XIndexAccess >& _rxModels )
{
    if (!_rxModels.is())
    {
        OSL_FAIL("FmXFormShell::smartControlReset: invalid container!");
        return;
    }

    sal_Int32 nCount = _rxModels->getCount();
    Reference< XPropertySet > xCurrent;
    Reference< XPropertySetInfo > xCurrentInfo;
    Reference< XPropertySet > xBoundField;

    for (sal_Int32 i=0; i<nCount; ++i)
    {
        _rxModels->getByIndex(i) >>= xCurrent;
        if (xCurrent.is())
            xCurrentInfo = xCurrent->getPropertySetInfo();
        else
            xCurrentInfo.clear();
        if (!xCurrentInfo.is())
            continue;

        if (xCurrentInfo->hasPropertyByName(FM_PROP_CLASSID))
        {   // it's a control model

            // check if this control is bound to a living database field
            if (xCurrentInfo->hasPropertyByName(FM_PROP_BOUNDFIELD))
                xCurrent->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xBoundField;
            else
                xBoundField.clear();

            // reset only if it's *not* bound
            bool bReset = !xBoundField.is();

            // and additionally, check if it has an external value binding
            Reference< XBindableValue > xBindable( xCurrent, UNO_QUERY );
            if ( xBindable.is() && xBindable->getValueBinding().is() )
                bReset = false;

            if ( bReset )
            {
                Reference< XReset > xControlReset( xCurrent, UNO_QUERY );
                if ( xControlReset.is() )
                    xControlReset->reset();
            }
        }
        else
        {
            Reference< XIndexAccess > xContainer(xCurrent, UNO_QUERY);
            if (xContainer.is())
                smartControlReset(xContainer);
        }
    }
}


IMPL_LINK_NOARG( FmXFormShell, OnLoadForms_Lock, void*, void )
{
    FmLoadAction aAction = m_aLoadingPages.front();
    m_aLoadingPages.pop();

    loadForms_Lock(aAction.pPage, aAction.nFlags & ~LoadFormsFlags::Async);
}


namespace
{
    bool lcl_isLoadable( const Reference< XInterface >& _rxLoadable )
    {
        // determines whether a form should be loaded or not
        // if there is no datasource or connection there is no reason to load a form
        Reference< XPropertySet > xSet( _rxLoadable, UNO_QUERY );
        if ( !xSet.is() )
            return false;
        try
        {
            Reference< XConnection > xConn;
            if ( isEmbeddedInDatabase( _rxLoadable, xConn ) )
                return true;

            // is there already an active connection
            xSet->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConn;
            if ( xConn.is() )
                return true;

            OUString sPropertyValue;
            OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DATASOURCE ) >>= sPropertyValue );
            if ( !sPropertyValue.isEmpty() )
                return true;

            OSL_VERIFY( xSet->getPropertyValue( FM_PROP_URL ) >>= sPropertyValue );
            if ( !sPropertyValue.isEmpty() )
                return true;
        }
        catch(const Exception&)
        {
            DBG_UNHANDLED_EXCEPTION("svx");
        }
        return false;
    }
}


void FmXFormShell::loadForms_Lock(FmFormPage* _pPage, const LoadFormsFlags _nBehaviour /* LoadFormsFlags::Load | LoadFormsFlags::Sync */)
{
    DBG_ASSERT( ( _nBehaviour & ( LoadFormsFlags::Async | LoadFormsFlags::Unload ) )  != ( LoadFormsFlags::Async | LoadFormsFlags::Unload ),
        "FmXFormShell::loadForms: async loading not supported - this will heavily fail!" );

    if ( _nBehaviour & LoadFormsFlags::Async )
    {
        m_aLoadingPages.push( FmLoadAction(
            _pPage,
            _nBehaviour,
            Application::PostUserEvent(LINK(this, FmXFormShell, OnLoadForms_Lock), _pPage)
        ) );
        return;
    }

    DBG_ASSERT( _pPage, "FmXFormShell::loadForms: invalid page!" );
    if ( !_pPage )
        return;

    // lock the undo env so the forms can change non-transient properties while loading
    // (without this my doc's modified flag would be set)
    FmFormModel& rFmFormModel(dynamic_cast< FmFormModel& >(_pPage->getSdrModelFromSdrPage()));
    rFmFormModel.GetUndoEnv().Lock();

    // load all forms
    Reference< XIndexAccess >  xForms = _pPage->GetForms( false );

    if ( xForms.is() )
    {
        Reference< XLoadable >  xForm;
        for ( sal_Int32 j = 0, nCount = xForms->getCount(); j < nCount; ++j )
        {
            xForms->getByIndex( j ) >>= xForm;
            bool bFormWasLoaded = false;
            // a database form must be loaded for
            try
            {
                if ( !( _nBehaviour & LoadFormsFlags::Unload ) )
                {
                    if ( lcl_isLoadable( xForm ) && !xForm->isLoaded() )
                        xForm->load();
                }
                else
                {
                    if ( xForm->isLoaded() )
                    {
                        bFormWasLoaded = true;
                        xForm->unload();
                    }
                }
            }
            catch( const Exception& )
            {
                DBG_UNHANDLED_EXCEPTION("svx");
            }

            // reset the form if it was loaded
            if ( bFormWasLoaded )
            {
                Reference< XIndexAccess > xContainer( xForm, UNO_QUERY );
                DBG_ASSERT( xContainer.is(), "FmXFormShell::loadForms: the form is no container!" );
                if ( xContainer.is() )
                    smartControlReset( xContainer );
            }
        }
    }

    // unlock the environment
    rFmFormModel.GetUndoEnv().UnLock();
}


void FmXFormShell::ExecuteTextAttribute_Lock(SfxRequest& _rReq)
{
    DBG_TESTSOLARMUTEX();
    m_pTextShell->ExecuteTextAttribute( _rReq );
}


void FmXFormShell::GetTextAttributeState_Lock(SfxItemSet& _rSet)
{
    DBG_TESTSOLARMUTEX();
    m_pTextShell->GetTextAttributeState( _rSet );
}


bool FmXFormShell::IsActiveControl_Lock(bool _bCountRichTextOnly ) const
{
    DBG_TESTSOLARMUTEX();
    return m_pTextShell->IsActiveControl( _bCountRichTextOnly );
}


void FmXFormShell::ForgetActiveControl_Lock()
{
    DBG_TESTSOLARMUTEX();
    m_pTextShell->ForgetActiveControl();
}


void FmXFormShell::SetControlActivationHandler_Lock(const Link<LinkParamNone*,void>& _rHdl)
{
    DBG_TESTSOLARMUTEX();
    m_pTextShell->SetControlActivationHandler( _rHdl );
}

void FmXFormShell::handleShowPropertiesRequest_Lock()
{
    if (onlyControlsAreMarked_Lock())
        ShowSelectionProperties_Lock( true );
}


void FmXFormShell::handleMouseButtonDown_Lock(const SdrViewEvent& _rViewEvent)
{
    // catch simple double clicks
    if (_rViewEvent.mnMouseClicks == 2 && _rViewEvent.mnMouseCode == MOUSE_LEFT)
    {
        if ( _rViewEvent.meHit == SdrHitKind::MarkedObject )
        {
            if (onlyControlsAreMarked_Lock())
                ShowSelectionProperties_Lock( true );
        }
    }
}


bool FmXFormShell::HasControlFocus_Lock() const
{
    bool bHasControlFocus = false;

    try
    {
        Reference<runtime::XFormController> xController(getActiveController_Lock());
        Reference< XControl > xCurrentControl;
        if ( xController.is() )
            xCurrentControl.set( xController->getCurrentControl() );
        if ( xCurrentControl.is() )
        {
            Reference< XWindow2 > xPeerWindow( xCurrentControl->getPeer(), UNO_QUERY_THROW );
            bHasControlFocus = xPeerWindow->hasFocus();
        }
    }
    catch( const Exception& )
    {
        DBG_UNHANDLED_EXCEPTION("svx");
    }

    return bHasControlFocus;
}


SearchableControlIterator::SearchableControlIterator(Reference< XInterface> const & xStartingPoint)
    :IndexAccessIterator(xStartingPoint)
{
}


bool SearchableControlIterator::ShouldHandleElement(const Reference< XInterface>& xElement)
{
    // if the thing has a ControlSource and a BoundField property
    Reference< XPropertySet> xProperties(xElement, UNO_QUERY);
    if (::comphelper::hasProperty(FM_PROP_CONTROLSOURCE, xProperties) && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xProperties))
    {
        // and the BoundField is valid
        Reference< XPropertySet> xField;
        xProperties->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
        if (xField.is())
        {
            // we take it
            m_sCurrentValue = ::comphelper::getString(xProperties->getPropertyValue(FM_PROP_CONTROLSOURCE));
            return true;
        }
    }

    // if it is a grid control
    if (::comphelper::hasProperty(FM_PROP_CLASSID, xProperties))
    {
        Any aClassId( xProperties->getPropertyValue(FM_PROP_CLASSID) );
        if (::comphelper::getINT16(aClassId) == FormComponentType::GRIDCONTROL)
        {
            m_sCurrentValue.clear();
            return true;
        }
    }

    return false;
}


bool SearchableControlIterator::ShouldStepInto(const Reference< XInterface>& /*xContainer*/) const
{
    return true;
}

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