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
|
/* -*- 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 <cstdlib>
#include <hintids.hxx>
#include <svl/itemiter.hxx>
#include <svl/eitem.hxx>
#include <unotools/syslocale.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/numitem.hxx>
#include <editeng/lrspitem.hxx>
#include <drawdoc.hxx>
#include <fmtcol.hxx>
#include <uitool.hxx>
#include <swmodule.hxx>
#include <wrtsh.hxx>
#include <docsh.hxx>
#include <frmfmt.hxx>
#include <charfmt.hxx>
#include <tblafmt.hxx>
#include <poolfmt.hxx>
#include <pagedesc.hxx>
#include <docstyle.hxx>
#include <docary.hxx>
#include <ccoll.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentStylePoolAccess.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentDrawModelAccess.hxx>
#include <IDocumentState.hxx>
#include <cmdid.h>
#include <swstyle.h>
#include <app.hrc>
#include <paratr.hxx>
#include <SwStyleNameMapper.hxx>
#include <svl/cjkoptions.hxx>
#include <comphelper/processfactory.hxx>
#include <unotools/localedatawrapper.hxx>
#include <unotools/intlwrapper.hxx>
#include <numrule.hxx>
#include <fmthdft.hxx>
#include <svx/svxids.hrc>
#include <svx/xdef.hxx>
#include <SwRewriter.hxx>
#include <svx/xfillit0.hxx>
#include <svx/xflftrit.hxx>
#include <svx/svdmodel.hxx>
#include <svx/drawitem.hxx>
// The Format names in the list of all names have the
// following family as their first character:
#define cCHAR (sal_Unicode)'c'
#define cPARA (sal_Unicode)'p'
#define cFRAME (sal_Unicode)'f'
#define cPAGE (sal_Unicode)'g'
#define cNUMRULE (sal_Unicode)'n'
#define cTABSTYLE (sal_Unicode)'t'
#define cCELLSTYLE (sal_Unicode)'b'
using namespace com::sun::star;
// At the names' publication, this character is removed again and the
// family is newly generated.
// In addition now there is the Bit bPhysical. In case this Bit is
// TRUE, the Pool-Formatnames are not being submitted.
class SwImplShellAction
{
SwWrtShell* pSh;
CurrShell* pCurrSh;
public:
explicit SwImplShellAction( SwDoc& rDoc );
~SwImplShellAction();
SwImplShellAction(const SwImplShellAction&) = delete;
SwImplShellAction& operator=(const SwImplShellAction&) = delete;
};
SwImplShellAction::SwImplShellAction( SwDoc& rDoc )
: pCurrSh( nullptr )
{
if( rDoc.GetDocShell() )
pSh = rDoc.GetDocShell()->GetWrtShell();
else
pSh = nullptr;
if( pSh )
{
pCurrSh = new CurrShell( pSh );
pSh->StartAllAction();
}
}
SwImplShellAction::~SwImplShellAction()
{
if( pCurrSh )
{
pSh->EndAllAction();
delete pCurrSh;
}
}
// find/create SwCharFormate
// possibly fill Style
static SwCharFormat* lcl_FindCharFormat( SwDoc& rDoc,
const OUString& rName,
SwDocStyleSheet* pStyle = nullptr,
bool bCreate = true )
{
SwCharFormat* pFormat = nullptr;
if (!rName.isEmpty())
{
pFormat = rDoc.FindCharFormatByName( rName );
if( !pFormat && rName == SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
RES_POOLCOLL_TEXT_BEGIN ] )
{
// Standard-Character template
pFormat = rDoc.GetDfltCharFormat();
}
if( !pFormat && bCreate )
{ // explore Pool
const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, SwGetPoolIdFromName::ChrFmt);
if(nId != USHRT_MAX)
pFormat = rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool(nId);
}
}
if(pStyle)
{
if(pFormat)
{
pStyle->SetPhysical(true);
SwFormat* p = pFormat->DerivedFrom();
if( p && !p->IsDefault() )
pStyle->PresetParent( p->GetName() );
else
pStyle->PresetParent( OUString() );
}
else
pStyle->SetPhysical(false);
}
return pFormat;
}
// find/create ParaFormats
// fill Style
static SwTextFormatColl* lcl_FindParaFormat( SwDoc& rDoc,
const OUString& rName,
SwDocStyleSheet* pStyle = nullptr,
bool bCreate = true )
{
SwTextFormatColl* pColl = nullptr;
if (!rName.isEmpty())
{
pColl = rDoc.FindTextFormatCollByName( rName );
if( !pColl && bCreate )
{ // explore Pool
const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, SwGetPoolIdFromName::TxtColl);
if(nId != USHRT_MAX)
pColl = rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool(nId);
}
}
if(pStyle)
{
if(pColl)
{
pStyle->SetPhysical(true);
if( pColl->DerivedFrom() && !pColl->DerivedFrom()->IsDefault() )
pStyle->PresetParent( pColl->DerivedFrom()->GetName() );
else
pStyle->PresetParent( OUString() );
SwTextFormatColl& rNext = pColl->GetNextTextFormatColl();
pStyle->PresetFollow(rNext.GetName());
}
else
pStyle->SetPhysical(false);
}
return pColl;
}
// Border formats
static SwFrameFormat* lcl_FindFrameFormat( SwDoc& rDoc,
const OUString& rName,
SwDocStyleSheet* pStyle = nullptr,
bool bCreate = true )
{
SwFrameFormat* pFormat = nullptr;
if( !rName.isEmpty() )
{
pFormat = rDoc.FindFrameFormatByName( rName );
if( !pFormat && bCreate )
{ // explore Pool
const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, SwGetPoolIdFromName::FrmFmt);
if(nId != USHRT_MAX)
pFormat = rDoc.getIDocumentStylePoolAccess().GetFrameFormatFromPool(nId);
}
}
if(pStyle)
{
if(pFormat)
{
pStyle->SetPhysical(true);
if( pFormat->DerivedFrom() && !pFormat->DerivedFrom()->IsDefault() )
pStyle->PresetParent( pFormat->DerivedFrom()->GetName() );
else
pStyle->PresetParent( OUString() );
}
else
pStyle->SetPhysical(false);
}
return pFormat;
}
// Page descriptors
static const SwPageDesc* lcl_FindPageDesc( SwDoc& rDoc,
const OUString& rName,
SwDocStyleSheet* pStyle = nullptr,
bool bCreate = true )
{
const SwPageDesc* pDesc = nullptr;
if (!rName.isEmpty())
{
pDesc = rDoc.FindPageDesc(rName);
if( !pDesc && bCreate )
{
sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, SwGetPoolIdFromName::PageDesc);
if(nId != USHRT_MAX)
pDesc = rDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(nId);
}
}
if(pStyle)
{
if(pDesc)
{
pStyle->SetPhysical(true);
if(pDesc->GetFollow())
pStyle->PresetFollow(pDesc->GetFollow()->GetName());
else
pStyle->PresetParent( OUString() );
}
else
pStyle->SetPhysical(false);
}
return pDesc;
}
static const SwNumRule* lcl_FindNumRule( SwDoc& rDoc,
const OUString& rName,
SwDocStyleSheet* pStyle = nullptr,
bool bCreate = true )
{
const SwNumRule* pRule = nullptr;
if (!rName.isEmpty())
{
pRule = rDoc.FindNumRulePtr( rName );
if( !pRule && bCreate )
{
sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(rName, SwGetPoolIdFromName::NumRule);
if(nId != USHRT_MAX)
pRule = rDoc.getIDocumentStylePoolAccess().GetNumRuleFromPool(nId);
}
}
if(pStyle)
{
if(pRule)
{
pStyle->SetPhysical(true);
pStyle->PresetParent( OUString() );
}
else
pStyle->SetPhysical(false);
}
return pRule;
}
static SwTableAutoFormat* lcl_FindTableStyle(SwDoc& rDoc, const OUString& rName, SwDocStyleSheet *pStyle = nullptr, bool bCreate = true)
{
SwTableAutoFormat* pFormat = nullptr;
if (!rName.isEmpty())
{
pFormat = rDoc.GetTableStyles().FindAutoFormat(rName);
if (!pFormat && bCreate)
{
SwTableAutoFormat aNew(rName);
rDoc.GetTableStyles().AddAutoFormat(aNew);
}
}
if(pStyle)
{
if(pFormat)
{
pStyle->SetPhysical(true);
pStyle->PresetParent(OUString());
}
else
pStyle->SetPhysical(false);
}
return pFormat;
}
static const SwBoxAutoFormat* lcl_FindCellStyle(SwDoc& rDoc, const OUString& rName, SwDocStyleSheet *pStyle)
{
const SwBoxAutoFormat* pFormat = rDoc.GetCellStyles().GetBoxFormat(rName);
if (!pFormat)
{
const auto& aTableTemplateMap = SwTableAutoFormat::GetTableTemplateMap();
SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
for (size_t i=0; i < rTableStyles.size() && !pFormat; ++i)
{
const SwTableAutoFormat& rTableStyle = rTableStyles[i];
for (size_t nBoxFormat=0; nBoxFormat < aTableTemplateMap.size() && !pFormat; ++nBoxFormat)
{
const sal_uInt32 nBoxIndex = aTableTemplateMap[nBoxFormat];
const SwBoxAutoFormat& rBoxFormat = rTableStyle.GetBoxFormat(nBoxIndex);
OUString sBoxFormatName;
SwStyleNameMapper::FillProgName(rTableStyle.GetName(), sBoxFormatName, SwGetPoolIdFromName::CellStyle, true);
sBoxFormatName += rTableStyle.GetTableTemplateCellSubName(rBoxFormat);
if (rName == sBoxFormatName)
pFormat = &rBoxFormat;
}
}
}
if(pStyle)
{
if(pFormat)
{
pStyle->SetPhysical(true);
pStyle->PresetParent(OUString());
}
else
pStyle->SetPhysical(false);
}
return pFormat;
}
sal_uInt32 SwStyleSheetIterator::SwPoolFormatList::FindName(SfxStyleFamily eFam,
const OUString &rName)
{
if(!maImpl.empty())
{
sal_Unicode cStyle(0);
switch( eFam )
{
case SfxStyleFamily::Char:
cStyle = cCHAR;
break;
case SfxStyleFamily::Para:
cStyle = cPARA;
break;
case SfxStyleFamily::Frame:
cStyle = cFRAME;
break;
case SfxStyleFamily::Page:
cStyle = cPAGE;
break;
case SfxStyleFamily::Pseudo:
cStyle = cNUMRULE;
break;
case SfxStyleFamily::Table:
cStyle = cTABSTYLE;
break;
case SfxStyleFamily::Cell:
cStyle = cCELLSTYLE;
break;
default:
cStyle = ' ';
break;
}
const OUString sSrch = OUStringLiteral1(cStyle) + rName;
UniqueHash::const_iterator it = maUnique.find(sSrch);
if (it != maUnique.end())
{
sal_uInt32 nIdx = it->second;
assert (nIdx < maImpl.size());
assert (maImpl.size() == maUnique.size());
return nIdx;
}
}
return SAL_MAX_UINT32;
}
void SwStyleSheetIterator::SwPoolFormatList::rehash()
{
maUnique.clear();
for (size_t i = 0; i < maImpl.size(); i++)
maUnique[maImpl[i]] = i;
assert (maImpl.size() == maUnique.size());
}
void SwStyleSheetIterator::SwPoolFormatList::RemoveName(SfxStyleFamily eFam,
const OUString &rName)
{
sal_uInt32 nTmpPos = FindName( eFam, rName );
if( nTmpPos < maImpl.size() )
maImpl.erase(maImpl.begin() + nTmpPos);
// assumption: this seldom occurs, the iterator is built, then emptied.
rehash();
assert (maImpl.size() == maUnique.size());
}
// Add Strings to the list of templates
void SwStyleSheetIterator::SwPoolFormatList::Append( char cChar, const OUString& rStr )
{
const OUString aStr = OUString(cChar) + rStr;
UniqueHash::const_iterator it = maUnique.find(aStr);
if (it != maUnique.end())
return;
maUnique[aStr] = (sal_uInt32)maImpl.size();
maImpl.push_back(aStr);
}
// UI-sided implementation of StyleSheets
// uses the Core-Engine
SwDocStyleSheet::SwDocStyleSheet( SwDoc& rDocument,
const OUString& rName,
SwDocStyleSheetPool* _rPool) :
SfxStyleSheetBase( rName, _rPool, SfxStyleFamily::Char, 0 ),
pCharFormat(nullptr),
pColl(nullptr),
pFrameFormat(nullptr),
pDesc(nullptr),
pNumRule(nullptr),
pTableFormat(nullptr),
pBoxFormat(nullptr),
rDoc(rDocument),
aCoreSet(GetPool().GetPool(), // sorted by indices, one double removed
RES_CHRATR_BEGIN, RES_CHRATR_END - 1, // [1
RES_PARATR_BEGIN, RES_PARATR_END - 1, // [60
RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1, // [77
RES_FRMATR_BEGIN, RES_FRMATR_END - 1, // [82
RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, // [143
// FillAttribute support
XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014
SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, // [10023
SID_ATTR_PAGE, SID_ATTR_PAGE_EXT1, // [10050
SID_ATTR_PAGE_HEADERSET,SID_ATTR_PAGE_FOOTERSET, // [10058
SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL, // [10065
// items to hand over XPropertyList things like
// XColorList, XHatchList, XGradientList and XBitmapList
// to the Area TabPage
SID_COLOR_TABLE, SID_PATTERN_LIST, // [10179
SID_SWREGISTER_COLLECTION, SID_SWREGISTER_COLLECTION, // [10451
SID_ATTR_PARA_PAGENUM, SID_ATTR_PARA_PAGENUM, // [10457
SID_SWREGISTER_MODE, SID_SWREGISTER_MODE, // [10467
SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR, // [10590
SID_ATTR_NUMBERING_RULE, SID_ATTR_NUMBERING_RULE, // [10855
SID_ATTR_AUTO_STYLE_UPDATE, SID_ATTR_AUTO_STYLE_UPDATE, // [12065
FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO, // [21123
FN_COND_COLL, FN_COND_COLL, // [22401
0),
bPhysical(false)
{
nHelpId = UCHAR_MAX;
}
SwDocStyleSheet::SwDocStyleSheet( const SwDocStyleSheet& rOrg) :
SfxStyleSheetBase(rOrg),
pCharFormat(rOrg.pCharFormat),
pColl(rOrg.pColl),
pFrameFormat(rOrg.pFrameFormat),
pDesc(rOrg.pDesc),
pNumRule(rOrg.pNumRule),
pTableFormat(rOrg.pTableFormat),
pBoxFormat(rOrg.pBoxFormat),
rDoc(rOrg.rDoc),
aCoreSet(rOrg.aCoreSet),
bPhysical(rOrg.bPhysical)
{
}
SwDocStyleSheet::~SwDocStyleSheet()
{
}
void SwDocStyleSheet::Reset()
{
aName.clear();
aFollow.clear();
aParent.clear();
SetPhysical(false);
}
void SwDocStyleSheet::SetGrabBagItem(const uno::Any& rVal)
{
bool bChg = false;
if (!bPhysical)
FillStyleSheet(FillPhysical);
SwFormat* pFormat = nullptr;
switch (nFamily)
{
case SfxStyleFamily::Char:
pFormat = rDoc.FindCharFormatByName(aName);
if (pFormat)
{
pFormat->SetGrabBagItem(rVal);
bChg = true;
}
break;
case SfxStyleFamily::Para:
pFormat = rDoc.FindTextFormatCollByName(aName);
if (pFormat)
{
pFormat->SetGrabBagItem(rVal);
bChg = true;
}
break;
case SfxStyleFamily::Pseudo:
{
SwNumRule* pRule = rDoc.FindNumRulePtr(aName);
if (pRule)
{
pRule->SetGrabBagItem(rVal);
bChg = true;
}
}
break;
default:
break;
}
if (bChg)
{
dynamic_cast<SwDocStyleSheetPool&>(*pPool).InvalidateIterator();
pPool->Broadcast(SfxStyleSheetHint(SfxHintId::StyleSheetModified, *this));
SwEditShell* pSh = rDoc.GetEditShell();
if (pSh)
pSh->CallChgLnk();
}
}
void SwDocStyleSheet::GetGrabBagItem(uno::Any& rVal) const
{
SwFormat* pFormat = nullptr;
switch (nFamily)
{
case SfxStyleFamily::Char:
pFormat = rDoc.FindCharFormatByName(aName);
if (pFormat)
pFormat->GetGrabBagItem(rVal);
break;
case SfxStyleFamily::Para:
pFormat = rDoc.FindTextFormatCollByName(aName);
if (pFormat)
pFormat->GetGrabBagItem(rVal);
break;
case SfxStyleFamily::Pseudo:
{
SwNumRule* pRule = rDoc.FindNumRulePtr(aName);
if (pRule)
pRule->GetGrabBagItem(rVal);
}
break;
default:
break;
}
}
// virtual methods
void SwDocStyleSheet::SetHidden( bool bValue )
{
bool bChg = false;
if(!bPhysical)
FillStyleSheet( FillPhysical );
SwFormat* pFormat = nullptr;
switch(nFamily)
{
case SfxStyleFamily::Char:
pFormat = rDoc.FindCharFormatByName( aName );
if ( pFormat )
{
pFormat->SetHidden( bValue );
bChg = true;
}
break;
case SfxStyleFamily::Para:
pFormat = rDoc.FindTextFormatCollByName( aName );
if ( pFormat )
{
pFormat->SetHidden( bValue );
bChg = true;
}
break;
case SfxStyleFamily::Frame:
pFormat = rDoc.FindFrameFormatByName( aName );
if ( pFormat )
{
pFormat->SetHidden( bValue );
bChg = true;
}
break;
case SfxStyleFamily::Page:
{
SwPageDesc* pPgDesc = rDoc.FindPageDesc(aName);
if ( pPgDesc )
{
pPgDesc->SetHidden( bValue );
bChg = true;
}
}
break;
case SfxStyleFamily::Pseudo:
{
SwNumRule* pRule = rDoc.FindNumRulePtr( aName );
if ( pRule )
{
pRule->SetHidden( bValue );
bChg = true;
}
}
break;
case SfxStyleFamily::Table:
{
SwTableAutoFormat* pTableAutoFormat = rDoc.GetTableStyles().FindAutoFormat( aName );
if ( pTableAutoFormat )
{
pTableAutoFormat->SetHidden( bValue );
bChg = true;
}
}
break;
default:
break;
}
if( bChg )
{
// calling pPool->First() here would be quite slow...
dynamic_cast<SwDocStyleSheetPool&>(*pPool).InvalidateIterator(); // internal list has to be updated
pPool->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified, *this ) );
SwEditShell* pSh = rDoc.GetEditShell();
if( pSh )
pSh->CallChgLnk();
}
}
bool SwDocStyleSheet::IsHidden( ) const
{
bool bRet = false;
SwFormat* pFormat = nullptr;
switch(nFamily)
{
case SfxStyleFamily::Char:
pFormat = rDoc.FindCharFormatByName( aName );
bRet = pFormat && pFormat->IsHidden( );
break;
case SfxStyleFamily::Para:
pFormat = rDoc.FindTextFormatCollByName( aName );
bRet = pFormat && pFormat->IsHidden( );
break;
case SfxStyleFamily::Frame:
pFormat = rDoc.FindFrameFormatByName( aName );
bRet = pFormat && pFormat->IsHidden( );
break;
case SfxStyleFamily::Page:
{
SwPageDesc* pPgDesc = rDoc.FindPageDesc(aName);
bRet = pPgDesc && pPgDesc->IsHidden( );
}
break;
case SfxStyleFamily::Pseudo:
{
SwNumRule* pRule = rDoc.FindNumRulePtr( aName );
bRet = pRule && pRule->IsHidden( );
}
break;
case SfxStyleFamily::Table:
{
SwTableAutoFormat* pTableAutoFormat = rDoc.GetTableStyles().FindAutoFormat( aName );
bRet = pTableAutoFormat && pTableAutoFormat->IsHidden( );
}
break;
default:
break;
}
return bRet;
}
const OUString& SwDocStyleSheet::GetParent() const
{
if( !bPhysical )
{
// check if it's already in document
SwFormat* pFormat = nullptr;
SwGetPoolIdFromName eGetType;
switch(nFamily)
{
case SfxStyleFamily::Char:
pFormat = rDoc.FindCharFormatByName( aName );
eGetType = SwGetPoolIdFromName::ChrFmt;
break;
case SfxStyleFamily::Para:
pFormat = rDoc.FindTextFormatCollByName( aName );
eGetType = SwGetPoolIdFromName::TxtColl;
break;
case SfxStyleFamily::Frame:
pFormat = rDoc.FindFrameFormatByName( aName );
eGetType = SwGetPoolIdFromName::FrmFmt;
break;
case SfxStyleFamily::Page:
case SfxStyleFamily::Pseudo:
default:
return aEmptyOUStr; // there's no parent
}
OUString sTmp;
if( !pFormat ) // not yet there, so default Parent
{
sal_uInt16 i = SwStyleNameMapper::GetPoolIdFromUIName( aName, eGetType );
i = ::GetPoolParent( i );
if( i && USHRT_MAX != i )
SwStyleNameMapper::FillUIName( i, sTmp );
}
else
{
SwFormat* p = pFormat->DerivedFrom();
if( p && !p->IsDefault() )
sTmp = p->GetName();
}
SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
pThis->aParent = sTmp;
}
return aParent;
}
// Follower
const OUString& SwDocStyleSheet::GetFollow() const
{
if( !bPhysical )
{
SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
pThis->FillStyleSheet( FillAllInfo );
}
return aFollow;
}
// What Linkage is possible
bool SwDocStyleSheet::HasFollowSupport() const
{
switch(nFamily)
{
case SfxStyleFamily::Para :
case SfxStyleFamily::Page : return true;
case SfxStyleFamily::Frame:
case SfxStyleFamily::Char :
case SfxStyleFamily::Pseudo: return false;
default:
OSL_ENSURE(false, "unknown style family");
}
return false;
}
// Parent ?
bool SwDocStyleSheet::HasParentSupport() const
{
bool bRet = false;
switch(nFamily)
{
case SfxStyleFamily::Char :
case SfxStyleFamily::Para :
case SfxStyleFamily::Frame: bRet = true;
break;
default:; //prevent warning
}
return bRet;
}
bool SwDocStyleSheet::HasClearParentSupport() const
{
bool bRet = false;
switch(nFamily)
{
case SfxStyleFamily::Para :
case SfxStyleFamily::Char :
case SfxStyleFamily::Frame: bRet = true;
break;
default:; //prevent warning
}
return bRet;
}
// determine textual description
OUString SwDocStyleSheet::GetDescription(MapUnit eUnit)
{
IntlWrapper aIntlWrapper( SvtSysLocale().GetLanguageTag() );
const OUString sPlus(" + ");
if ( SfxStyleFamily::Page == nFamily )
{
if( !pSet )
GetItemSet();
SfxItemIter aIter( *pSet );
OUString aDesc;
for (const SfxPoolItem* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem())
{
if(!IsInvalidItem(pItem))
{
switch ( pItem->Which() )
{
case RES_LR_SPACE:
case SID_ATTR_PAGE_SIZE:
case SID_ATTR_PAGE_MAXSIZE:
case SID_ATTR_PAGE_PAPERBIN:
case SID_ATTR_BORDER_INNER:
break;
default:
{
OUString aItemPresentation;
if ( !IsInvalidItem( pItem ) &&
pPool->GetPool().GetPresentation(
*pItem, eUnit, aItemPresentation, &aIntlWrapper ) )
{
if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
aDesc += sPlus;
aDesc += aItemPresentation;
}
}
}
}
}
return aDesc;
}
if ( SfxStyleFamily::Frame == nFamily || SfxStyleFamily::Para == nFamily)
{
if( !pSet )
GetItemSet();
SfxItemIter aIter( *pSet );
OUString aDesc;
OUString sPageNum;
OUString sModel;
OUString sBreak;
bool bHasWesternFontPrefix = false;
bool bHasCJKFontPrefix = false;
SvtCJKOptions aCJKOptions;
// Get currently used FillStyle and remember, also need the XFillFloatTransparenceItem
// to decide if gradient transparence is used
const drawing::FillStyle eFillStyle(static_cast< const XFillStyleItem& >(pSet->Get(XATTR_FILLSTYLE)).GetValue());
const bool bUseFloatTransparence(static_cast< const XFillFloatTransparenceItem& >(pSet->Get(XATTR_FILLFLOATTRANSPARENCE)).IsEnabled());
for ( const SfxPoolItem* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem() )
{
if(!IsInvalidItem(pItem))
{
switch ( pItem->Which() )
{
case SID_ATTR_AUTO_STYLE_UPDATE:
case RES_PAGEDESC:
//CTL not yet supported
case RES_CHRATR_CTL_FONT:
case RES_CHRATR_CTL_FONTSIZE:
case RES_CHRATR_CTL_LANGUAGE:
case RES_CHRATR_CTL_POSTURE:
case RES_CHRATR_CTL_WEIGHT:
break;
default:
{
OUString aItemPresentation;
if ( !IsInvalidItem( pItem ) &&
pPool->GetPool().GetPresentation(
*pItem, eUnit, aItemPresentation, &aIntlWrapper ) )
{
bool bIsDefault = false;
switch ( pItem->Which() )
{
case XATTR_FILLCOLOR:
{
// only use active FillStyle information
bIsDefault = (drawing::FillStyle_SOLID == eFillStyle);
break;
}
case XATTR_FILLGRADIENT:
{
// only use active FillStyle information
bIsDefault = (drawing::FillStyle_GRADIENT == eFillStyle);
break;
}
case XATTR_FILLHATCH:
{
// only use active FillStyle information
bIsDefault = (drawing::FillStyle_HATCH == eFillStyle);
break;
}
case XATTR_FILLBITMAP:
{
// only use active FillStyle information
bIsDefault = (drawing::FillStyle_BITMAP == eFillStyle);
break;
}
case XATTR_FILLTRANSPARENCE:
{
// only active when not FloatTransparence
bIsDefault = !bUseFloatTransparence;
break;
}
case XATTR_FILLFLOATTRANSPARENCE:
{
// only active when FloatTransparence
bIsDefault = bUseFloatTransparence;
break;
}
case SID_ATTR_PARA_PAGENUM:
sPageNum = aItemPresentation;
break;
case SID_ATTR_PARA_MODEL:
sModel = aItemPresentation;
break;
case RES_BREAK:
sBreak = aItemPresentation;
break;
case RES_CHRATR_CJK_FONT:
case RES_CHRATR_CJK_FONTSIZE:
case RES_CHRATR_CJK_LANGUAGE:
case RES_CHRATR_CJK_POSTURE:
case RES_CHRATR_CJK_WEIGHT:
if(aCJKOptions.IsCJKFontEnabled())
bIsDefault = true;
if(!bHasCJKFontPrefix)
{
aItemPresentation = SW_RESSTR(STR_CJK_FONT) + aItemPresentation;
bHasCJKFontPrefix = true;
}
break;
case RES_CHRATR_FONT:
case RES_CHRATR_FONTSIZE:
case RES_CHRATR_LANGUAGE:
case RES_CHRATR_POSTURE:
case RES_CHRATR_WEIGHT:
if(!bHasWesternFontPrefix)
{
aItemPresentation = SW_RESSTR(STR_WESTERN_FONT) + aItemPresentation;
bHasWesternFontPrefix = true;
}
SAL_FALLTHROUGH;
default:
bIsDefault = true;
}
if(bIsDefault)
{
if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() )
aDesc += sPlus;
aDesc += aItemPresentation;
}
}
}
}
}
}
// Special treatment for Break, Page template and Site offset
if (!sModel.isEmpty())
{
if (!aDesc.isEmpty())
aDesc += sPlus;
aDesc += SW_RESSTR(STR_PAGEBREAK) + sPlus + sModel;
if (sPageNum != "0")
{
aDesc += sPlus + SW_RESSTR(STR_PAGEOFFSET) + sPageNum;
}
}
else if (!sBreak.isEmpty()) // Break can be valid only when NO Model
{
if (!aDesc.isEmpty())
aDesc += sPlus;
aDesc += sBreak;
}
return aDesc;
}
if( SfxStyleFamily::Pseudo == nFamily )
{
return OUString();
}
return SfxStyleSheetBase::GetDescription(eUnit);
}
// Set names
bool SwDocStyleSheet::SetName(const OUString& rStr, bool bReindexNow)
{
if( rStr.isEmpty() )
return false;
if( aName != rStr )
{
if( !SfxStyleSheetBase::SetName(rStr, bReindexNow))
return false;
}
else if(!bPhysical)
FillStyleSheet( FillPhysical );
bool bChg = false;
switch(nFamily)
{
case SfxStyleFamily::Char :
{
OSL_ENSURE(pCharFormat, "SwCharFormat missing!");
if( pCharFormat && pCharFormat->GetName() != rStr )
{
if (!pCharFormat->GetName().isEmpty())
rDoc.RenameFormat(*pCharFormat, rStr);
else
pCharFormat->SetName(rStr);
bChg = true;
}
break;
}
case SfxStyleFamily::Para :
{
OSL_ENSURE(pColl, "Collection missing!");
if( pColl && pColl->GetName() != rStr )
{
if (!pColl->GetName().isEmpty())
rDoc.RenameFormat(*pColl, rStr);
else
pColl->SetName(rStr);
bChg = true;
}
break;
}
case SfxStyleFamily::Frame:
{
OSL_ENSURE(pFrameFormat, "FrameFormat missing!");
if( pFrameFormat && pFrameFormat->GetName() != rStr )
{
if (!pFrameFormat->GetName().isEmpty())
rDoc.RenameFormat(*pFrameFormat, rStr);
else
pFrameFormat->SetName( rStr );
bChg = true;
}
break;
}
case SfxStyleFamily::Page :
OSL_ENSURE(pDesc, "PageDesc missing!");
if( pDesc && pDesc->GetName() != rStr )
{
// Set PageDesc - copy with earlier one - probably not
// necessary for setting the name. So here we allow a
// cast.
SwPageDesc aPageDesc(*const_cast<SwPageDesc*>(pDesc));
const OUString aOldName(aPageDesc.GetName());
aPageDesc.SetName( rStr );
bool const bDoesUndo = rDoc.GetIDocumentUndoRedo().DoesUndo();
rDoc.GetIDocumentUndoRedo().DoUndo(!aOldName.isEmpty());
rDoc.ChgPageDesc(aOldName, aPageDesc);
rDoc.GetIDocumentUndoRedo().DoUndo(bDoesUndo);
rDoc.getIDocumentState().SetModified();
bChg = true;
}
break;
case SfxStyleFamily::Pseudo:
OSL_ENSURE(pNumRule, "NumRule missing!");
if (pNumRule)
{
OUString aOldName = pNumRule->GetName();
if (!aOldName.isEmpty())
{
if ( aOldName != rStr &&
rDoc.RenameNumRule(aOldName, rStr))
{
pNumRule = rDoc.FindNumRulePtr(rStr);
rDoc.getIDocumentState().SetModified();
bChg = true;
}
}
else
{
// #i91400#
const_cast<SwNumRule*>(pNumRule)->SetName( rStr, rDoc.getIDocumentListsAccess() );
rDoc.getIDocumentState().SetModified();
bChg = true;
}
}
break;
default:
OSL_ENSURE(false, "unknown style family");
}
if( bChg )
{
pPool->First(); // internal list has to be updated
pPool->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified, *this ) );
SwEditShell* pSh = rDoc.GetEditShell();
if( pSh )
pSh->CallChgLnk();
}
return true;
}
// hierarchy of deduction
bool SwDocStyleSheet::SetParent( const OUString& rStr)
{
SwFormat* pFormat = nullptr, *pParent = nullptr;
switch(nFamily)
{
case SfxStyleFamily::Char :
OSL_ENSURE( pCharFormat, "SwCharFormat missing!" );
if( nullptr != ( pFormat = pCharFormat ) && !rStr.isEmpty() )
pParent = lcl_FindCharFormat(rDoc, rStr);
break;
case SfxStyleFamily::Para :
OSL_ENSURE( pColl, "Collection missing!");
if( nullptr != ( pFormat = pColl ) && !rStr.isEmpty() )
pParent = lcl_FindParaFormat( rDoc, rStr );
break;
case SfxStyleFamily::Frame:
OSL_ENSURE(pFrameFormat, "FrameFormat missing!");
if( nullptr != ( pFormat = pFrameFormat ) && !rStr.isEmpty() )
pParent = lcl_FindFrameFormat( rDoc, rStr );
break;
case SfxStyleFamily::Page:
case SfxStyleFamily::Pseudo:
break;
default:
OSL_ENSURE(false, "unknown style family");
}
bool bRet = false;
if( pFormat && pFormat->DerivedFrom() &&
pFormat->DerivedFrom()->GetName() != rStr )
{
{
SwImplShellAction aTmp( rDoc );
bRet = pFormat->SetDerivedFrom( pParent );
}
if( bRet )
{
aParent = rStr;
pPool->Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified,
*this ) );
}
}
return bRet;
}
// Set Follower
bool SwDocStyleSheet::SetFollow( const OUString& rStr)
{
if( !rStr.isEmpty() && !SfxStyleSheetBase::SetFollow( rStr ))
return false;
SwImplShellAction aTmpSh( rDoc );
switch(nFamily)
{
case SfxStyleFamily::Para :
{
OSL_ENSURE(pColl, "Collection missing!");
if( pColl )
{
SwTextFormatColl* pFollow = pColl;
if( !rStr.isEmpty() && nullptr == (pFollow = lcl_FindParaFormat(rDoc, rStr) ))
pFollow = pColl;
pColl->SetNextTextFormatColl(*pFollow);
}
break;
}
case SfxStyleFamily::Page :
{
OSL_ENSURE(pDesc, "PageDesc missing!");
if( pDesc )
{
const SwPageDesc* pFollowDesc = !rStr.isEmpty()
? lcl_FindPageDesc(rDoc, rStr)
: nullptr;
size_t nId = 0;
if (pFollowDesc != pDesc->GetFollow() && rDoc.FindPageDesc(pDesc->GetName(), &nId))
{
SwPageDesc aDesc( *pDesc );
aDesc.SetFollow( pFollowDesc );
rDoc.ChgPageDesc( nId, aDesc );
pDesc = &rDoc.GetPageDesc( nId );
}
}
break;
}
case SfxStyleFamily::Char:
case SfxStyleFamily::Frame:
case SfxStyleFamily::Pseudo:
break;
default:
OSL_ENSURE(false, "unknown style family");
}
return true;
}
static
std::unique_ptr<SfxItemSet> lcl_SwFormatToFlatItemSet(SwFormat *const pFormat)
{
// note: we don't add the odd items that GetItemSet() would add
// because they don't seem relevant for preview
std::vector<SfxItemSet const*> sets;
sets.push_back(&pFormat->GetAttrSet());
while (SfxItemSet const*const pParent = sets.back()->GetParent())
{
sets.push_back(pParent);
}
// start by copying top-level parent set
std::unique_ptr<SfxItemSet> pRet(new SfxItemSet(*sets.back()));
sets.pop_back();
for (auto iter = sets.rbegin(); iter != sets.rend(); ++iter)
{ // in reverse so child overrides parent
pRet->Put(**iter);
}
return pRet;
}
std::unique_ptr<SfxItemSet> SwDocStyleSheet::GetItemSetForPreview()
{
if (SfxStyleFamily::Page == nFamily || SfxStyleFamily::Pseudo == nFamily || SfxStyleFamily::Table == nFamily)
{
SAL_WARN("sw.ui", "GetItemSetForPreview not implemented for page or number or table style");
return std::unique_ptr<SfxItemSet>();
}
if (!bPhysical)
{
// because not only this style, but also any number of its parents
// (or follow style) may not actually exist in the document at this
// time, return one "flattened" item set that contains all items from
// all parents.
std::unique_ptr<SfxItemSet> pRet;
FillStyleSheet(FillPreview, &pRet);
assert(pRet);
return pRet;
}
else
{
switch (nFamily)
{
case SfxStyleFamily::Char:
return lcl_SwFormatToFlatItemSet(pCharFormat);
case SfxStyleFamily::Para:
return lcl_SwFormatToFlatItemSet(pColl);
case SfxStyleFamily::Frame:
return lcl_SwFormatToFlatItemSet(pFrameFormat);
default:
std::abort();
}
}
}
// extract ItemSet to Name and Family, Mask
SfxItemSet& SwDocStyleSheet::GetItemSet()
{
if(!bPhysical)
FillStyleSheet( FillPhysical );
switch(nFamily)
{
case SfxStyleFamily::Char:
case SfxStyleFamily::Para:
case SfxStyleFamily::Frame:
{
SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
aBoxInfo.SetTable( false );
aBoxInfo.SetDist( true ); // always show gap field
aBoxInfo.SetMinDist( true );// set minimum size in tables and paragraphs
aBoxInfo.SetDefDist( MIN_BORDER_DIST );// always set Default-Gap
// Single lines can only have DontCare-Status in tables
aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE );
if( nFamily == SfxStyleFamily::Char )
{
SAL_WARN_IF(!pCharFormat, "sw.ui", "Where's SwCharFormat");
aCoreSet.Put(pCharFormat->GetAttrSet());
aCoreSet.Put( aBoxInfo );
if(pCharFormat->DerivedFrom())
aCoreSet.SetParent(&pCharFormat->DerivedFrom()->GetAttrSet());
}
else if ( nFamily == SfxStyleFamily::Para )
{
OSL_ENSURE(pColl, "Where's Collection");
aCoreSet.Put(pColl->GetAttrSet());
aCoreSet.Put( aBoxInfo );
aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pColl->IsAutoUpdateFormat()));
if(pColl->DerivedFrom())
aCoreSet.SetParent(&pColl->DerivedFrom()->GetAttrSet());
}
else
{
OSL_ENSURE(pFrameFormat, "Where's FrameFormat");
aCoreSet.Put(pFrameFormat->GetAttrSet());
aCoreSet.Put( aBoxInfo );
aCoreSet.Put(SfxBoolItem(SID_ATTR_AUTO_STYLE_UPDATE, pFrameFormat->IsAutoUpdateFormat()));
if(pFrameFormat->DerivedFrom())
aCoreSet.SetParent(&pFrameFormat->DerivedFrom()->GetAttrSet());
// create needed items for XPropertyList entries from the DrawModel so that
// the Area TabPage can access them
const SwDrawModel* pDrawModel = rDoc.getIDocumentDrawModelAccess().GetDrawModel();
aCoreSet.Put(SvxColorListItem(pDrawModel->GetColorList(), SID_COLOR_TABLE));
aCoreSet.Put(SvxGradientListItem(pDrawModel->GetGradientList(), SID_GRADIENT_LIST));
aCoreSet.Put(SvxHatchListItem(pDrawModel->GetHatchList(), SID_HATCH_LIST));
aCoreSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapList(), SID_BITMAP_LIST));
aCoreSet.Put(SvxPatternListItem(pDrawModel->GetPatternList(), SID_PATTERN_LIST));
}
}
break;
case SfxStyleFamily::Page :
{
// set correct parent to get the drawing::FillStyle_NONE FillStyle as needed
if(!aCoreSet.GetParent())
{
aCoreSet.SetParent(&rDoc.GetDfltFrameFormat()->GetAttrSet());
}
OSL_ENSURE(pDesc, "No PageDescriptor");
::PageDescToItemSet(*const_cast<SwPageDesc*>(pDesc), aCoreSet);
}
break;
case SfxStyleFamily::Pseudo:
{
OSL_ENSURE(pNumRule, "No NumRule");
SvxNumRule aRule = pNumRule->MakeSvxNumRule();
aCoreSet.Put(SvxNumBulletItem(aRule));
}
break;
default:
OSL_ENSURE(false, "unknown style family");
}
// Member of Baseclass
pSet = &aCoreSet;
return aCoreSet;
}
void SwDocStyleSheet::MergeIndentAttrsOfListStyle( SfxItemSet& rSet )
{
if ( nFamily != SfxStyleFamily::Para )
{
return;
}
OSL_ENSURE( pColl, "<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - missing paragraph style");
if ( pColl->AreListLevelIndentsApplicable() )
{
OSL_ENSURE( pColl->GetItemState( RES_PARATR_NUMRULE ) == SfxItemState::SET,
"<SwDocStyleSheet::MergeIndentAttrsOfListStyle(..)> - list level indents are applicable at paragraph style, but no list style found. Serious defect." );
const OUString sNumRule = pColl->GetNumRule().GetValue();
if (!sNumRule.isEmpty())
{
const SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
if( pRule )
{
const SwNumFormat& rFormat = pRule->Get( 0 );
if ( rFormat.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
{
SvxLRSpaceItem aLR( RES_LR_SPACE );
aLR.SetTextLeft( rFormat.GetIndentAt() );
aLR.SetTextFirstLineOfst( static_cast<short>(rFormat.GetFirstLineIndent()) );
rSet.Put( aLR );
}
}
}
}
}
// handling of parameter <bResetIndentAttrsAtParagraphStyle>
void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
const bool bResetIndentAttrsAtParagraphStyle )
{
// if applicable determine format first
if(!bPhysical)
FillStyleSheet( FillPhysical );
SwImplShellAction aTmpSh( rDoc );
OSL_ENSURE( &rSet != &aCoreSet, "SetItemSet with own Set is not allowed" );
if (rDoc.GetIDocumentUndoRedo().DoesUndo())
{
SwRewriter aRewriter;
aRewriter.AddRule( UndoArg1, GetName() );
rDoc.GetIDocumentUndoRedo().StartUndo( SwUndoId::INSFMTATTR, &aRewriter );
}
SwFormat* pFormat = nullptr;
SwPageDesc* pNewDsc = nullptr;
size_t nPgDscPos = 0;
switch(nFamily)
{
case SfxStyleFamily::Char :
{
OSL_ENSURE(pCharFormat, "Where's CharFormat");
pFormat = pCharFormat;
}
break;
case SfxStyleFamily::Para :
{
OSL_ENSURE(pColl, "Where's Collection");
const SfxPoolItem* pAutoUpdate;
if(SfxItemState::SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,false, &pAutoUpdate ))
{
pColl->SetAutoUpdateFormat(static_cast<const SfxBoolItem*>(pAutoUpdate)->GetValue());
}
const SwCondCollItem* pCondItem;
if( SfxItemState::SET != rSet.GetItemState( FN_COND_COLL, false,
reinterpret_cast<const SfxPoolItem**>(&pCondItem) ))
pCondItem = nullptr;
if( RES_CONDTXTFMTCOLL == pColl->Which() && pCondItem )
{
const CommandStruct* pCmds = SwCondCollItem::GetCmds();
for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
{
SwCollCondition aCond( nullptr, pCmds[ i ].nCnd, pCmds[ i ].nSubCond );
static_cast<SwConditionTextFormatColl*>(pColl)->RemoveCondition( aCond );
const OUString sStyle = pCondItem->GetStyle( i );
if (sStyle.isEmpty())
continue;
SwFormat *const pFindFormat = lcl_FindParaFormat( rDoc, sStyle );
if (pFindFormat)
{
aCond.RegisterToFormat( *pFindFormat );
static_cast<SwConditionTextFormatColl*>(pColl)->InsertCondition( aCond );
}
}
// Update document to new conditions
SwCondCollCondChg aMsg( pColl );
pColl->ModifyNotification( &aMsg, &aMsg );
}
else if( pCondItem && !pColl->HasWriterListeners() )
{
// no conditional template, then first create and adopt
// all important values
SwConditionTextFormatColl* pCColl = rDoc.MakeCondTextFormatColl(
pColl->GetName(), static_cast<SwTextFormatColl*>(pColl->DerivedFrom()) );
if( pColl != &pColl->GetNextTextFormatColl() )
pCColl->SetNextTextFormatColl( pColl->GetNextTextFormatColl() );
if( pColl->IsAssignedToListLevelOfOutlineStyle())
pCColl->AssignToListLevelOfOutlineStyle(pColl->GetAssignedOutlineStyleLevel());
else
pCColl->DeleteAssignmentToListLevelOfOutlineStyle();
const CommandStruct* pCmds = SwCondCollItem::GetCmds();
for( sal_uInt16 i = 0; i < COND_COMMAND_COUNT; ++i )
{
const OUString sStyle = pCondItem->GetStyle( i );
if (sStyle.isEmpty())
continue;
SwTextFormatColl *const pFindFormat = lcl_FindParaFormat( rDoc, sStyle );
if (pFindFormat)
{
pCColl->InsertCondition( SwCollCondition( pFindFormat,
pCmds[ i ].nCnd, pCmds[ i ].nSubCond ) );
}
}
rDoc.DelTextFormatColl( pColl );
pColl = pCColl;
}
if ( bResetIndentAttrsAtParagraphStyle &&
rSet.GetItemState( RES_PARATR_NUMRULE, false ) == SfxItemState::SET &&
rSet.GetItemState( RES_LR_SPACE, false ) != SfxItemState::SET &&
pColl->GetItemState( RES_LR_SPACE, false ) == SfxItemState::SET )
{
rDoc.ResetAttrAtFormat( RES_LR_SPACE, *pColl );
}
// #i56252: If a standard numbering style is assigned to a standard paragraph style
// we have to create a physical instance of the numbering style. If we do not and
// neither the paragraph style nor the numbering style is used in the document
// the numbering style will not be saved with the document and the assignment got lost.
const SfxPoolItem* pNumRuleItem = nullptr;
if( SfxItemState::SET == rSet.GetItemState( RES_PARATR_NUMRULE, false, &pNumRuleItem ) )
{ // Setting a numbering rule?
const OUString sNumRule = static_cast<const SwNumRuleItem*>(pNumRuleItem)->GetValue();
if (!sNumRule.isEmpty())
{
SwNumRule* pRule = rDoc.FindNumRulePtr( sNumRule );
if( !pRule )
{ // Numbering rule not in use yet.
sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( sNumRule, SwGetPoolIdFromName::NumRule );
if( USHRT_MAX != nPoolId ) // It's a standard numbering rule
{
rDoc.getIDocumentStylePoolAccess().GetNumRuleFromPool( nPoolId ); // Create numbering rule (physical)
}
}
}
}
pFormat = pColl;
sal_uInt16 nId = pColl->GetPoolFormatId() &
~ ( COLL_GET_RANGE_BITS | POOLGRP_NOCOLLID );
switch( GetMask() & ( 0x0fff & ~SWSTYLEBIT_CONDCOLL ) )
{
case SWSTYLEBIT_TEXT:
nId |= COLL_TEXT_BITS;
break;
case SWSTYLEBIT_CHAPTER:
nId |= COLL_DOC_BITS;
break;
case SWSTYLEBIT_LIST:
nId |= COLL_LISTS_BITS;
break;
case SWSTYLEBIT_IDX:
nId |= COLL_REGISTER_BITS;
break;
case SWSTYLEBIT_EXTRA:
nId |= COLL_EXTRA_BITS;
break;
case SWSTYLEBIT_HTML:
nId |= COLL_HTML_BITS;
break;
}
pColl->SetPoolFormatId( nId );
break;
}
case SfxStyleFamily::Frame:
{
OSL_ENSURE(pFrameFormat, "Where's FrameFormat");
const SfxPoolItem* pAutoUpdate;
if(SfxItemState::SET == rSet.GetItemState(SID_ATTR_AUTO_STYLE_UPDATE,false, &pAutoUpdate ))
{
pFrameFormat->SetAutoUpdateFormat(static_cast<const SfxBoolItem*>(pAutoUpdate)->GetValue());
}
pFormat = pFrameFormat;
}
break;
case SfxStyleFamily::Page :
{
OSL_ENSURE(pDesc, "Where's PageDescriptor");
if (rDoc.FindPageDesc(pDesc->GetName(), &nPgDscPos))
{
pNewDsc = new SwPageDesc( *pDesc );
// #i48949# - no undo actions for the
// copy of the page style
::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
rDoc.CopyPageDesc(*pDesc, *pNewDsc); // #i7983#
pFormat = &pNewDsc->GetMaster();
}
}
break;
case SfxStyleFamily::Pseudo:
{
OSL_ENSURE(pNumRule, "Where's NumRule");
if (!pNumRule)
break;
const SfxPoolItem* pItem;
switch( rSet.GetItemState( SID_ATTR_NUMBERING_RULE, false, &pItem ))
{
case SfxItemState::SET:
{
SvxNumRule* pSetRule = static_cast<const SvxNumBulletItem*>(pItem)->GetNumRule();
pSetRule->UnLinkGraphics();
SwNumRule aSetRule(*pNumRule);
aSetRule.SetSvxRule(*pSetRule, &rDoc);
rDoc.ChgNumRuleFormats( aSetRule );
}
break;
case SfxItemState::DONTCARE:
// set NumRule to default values
// what are the default values?
{
SwNumRule aRule( pNumRule->GetName(),
// #i89178#
numfunc::GetDefaultPositionAndSpaceMode() );
rDoc.ChgNumRuleFormats( aRule );
}
break;
default: break;
}
}
break;
default:
OSL_ENSURE(false, "unknown style family");
}
if( pFormat && rSet.Count())
{
SfxItemIter aIter( rSet );
const SfxPoolItem* pItem = aIter.GetCurItem();
while( true )
{
if( IsInvalidItem( pItem ) ) // Clear
{
// use method <SwDoc::ResetAttrAtFormat(..)> in order to
// create an Undo object for the attribute reset.
rDoc.ResetAttrAtFormat( rSet.GetWhichByPos(aIter.GetCurPos()),
*pFormat );
}
if( aIter.IsAtEnd() )
break;
pItem = aIter.NextItem();
}
SfxItemSet aSet(rSet);
aSet.ClearInvalidItems();
if(SfxStyleFamily::Frame == nFamily)
{
// Need to check for unique item for DrawingLayer items of type NameOrIndex
// and evtl. correct that item to ensure unique names for that type. This call may
// modify/correct entries inside of the given SfxItemSet
rDoc.CheckForUniqueItemForLineFillNameOrIndex(aSet);
}
aCoreSet.ClearItem();
if( pNewDsc )
{
::ItemSetToPageDesc( aSet, *pNewDsc );
rDoc.ChgPageDesc( nPgDscPos, *pNewDsc );
pDesc = &rDoc.GetPageDesc( nPgDscPos );
rDoc.PreDelPageDesc(pNewDsc); // #i7983#
delete pNewDsc;
}
else
rDoc.ChgFormat(*pFormat, aSet); // put all that is set
}
else
{
aCoreSet.ClearItem();
if( pNewDsc ) // we still need to delete it
{
rDoc.PreDelPageDesc(pNewDsc); // #i7983#
delete pNewDsc;
}
}
if (rDoc.GetIDocumentUndoRedo().DoesUndo())
{
rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::END, nullptr);
}
}
static void lcl_SaveStyles( SfxStyleFamily nFamily, std::vector<void*>& rArr, SwDoc& rDoc )
{
switch( nFamily )
{
case SfxStyleFamily::Char:
{
const SwCharFormats& rTable = *rDoc.GetCharFormats();
for( size_t n = 0, nCnt = rTable.size(); n < nCnt; ++n )
{
rArr.push_back( rTable[ n ] );
}
}
break;
case SfxStyleFamily::Para:
{
const SwTextFormatColls& rTable = *rDoc.GetTextFormatColls();
for( size_t n = 0, nCnt = rTable.size(); n < nCnt; ++n )
{
rArr.push_back( rTable[ n ] );
}
}
break;
case SfxStyleFamily::Frame:
{
const SwFrameFormats& rTable = *rDoc.GetFrameFormats();
for( size_t n = 0, nCnt = rTable.size(); n < nCnt; ++n )
{
rArr.push_back( rTable[ n ] );
}
}
break;
case SfxStyleFamily::Page:
{
for( size_t n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
{
rArr.push_back( &rDoc.GetPageDesc( n ) );
}
}
break;
case SfxStyleFamily::Pseudo:
{
const SwNumRuleTable& rTable = rDoc.GetNumRuleTable();
for( size_t n = 0, nCnt = rTable.size(); n < nCnt; ++n )
{
rArr.push_back( rTable[ n ] );
}
}
break;
default: break;
}
}
static bool lcl_Contains(const std::vector<void*>& rArr, const void* p)
{
return std::find( rArr.begin(), rArr.end(), p ) != rArr.end();
}
static void lcl_DeleteInfoStyles( SfxStyleFamily nFamily, std::vector<void*>& rArr, SwDoc& rDoc )
{
size_t n, nCnt;
switch( nFamily )
{
case SfxStyleFamily::Char:
{
std::deque<sal_uInt16> aDelArr;
const SwCharFormats& rTable = *rDoc.GetCharFormats();
for( n = 0, nCnt = rTable.size(); n < nCnt; ++n )
{
if( !lcl_Contains( rArr, rTable[ n ] ))
aDelArr.push_front( n );
}
for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
rDoc.DelCharFormat( aDelArr[ n ] );
}
break;
case SfxStyleFamily::Para :
{
std::deque<sal_uInt16> aDelArr;
const SwTextFormatColls& rTable = *rDoc.GetTextFormatColls();
for( n = 0, nCnt = rTable.size(); n < nCnt; ++n )
{
if( !lcl_Contains( rArr, rTable[ n ] ))
aDelArr.push_front( n );
}
for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
rDoc.DelTextFormatColl( aDelArr[ n ] );
}
break;
case SfxStyleFamily::Frame:
{
std::deque<SwFrameFormat*> aDelArr;
const SwFrameFormats& rTable = *rDoc.GetFrameFormats();
for( n = 0, nCnt = rTable.size(); n < nCnt; ++n )
{
if( !lcl_Contains( rArr, rTable[ n ] ))
aDelArr.push_front( rTable[ n ] );
}
for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
rDoc.DelFrameFormat( aDelArr[ n ] );
}
break;
case SfxStyleFamily::Page:
{
std::deque<size_t> aDelArr;
for( n = 0, nCnt = rDoc.GetPageDescCnt(); n < nCnt; ++n )
{
if( !lcl_Contains( rArr, &rDoc.GetPageDesc( n ) ))
aDelArr.push_front( n );
}
for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
rDoc.DelPageDesc( aDelArr[ n ] );
}
break;
case SfxStyleFamily::Pseudo:
{
std::deque<SwNumRule*> aDelArr;
const SwNumRuleTable& rTable = rDoc.GetNumRuleTable();
for( n = 0, nCnt = rTable.size(); n < nCnt; ++n )
{
if( !lcl_Contains( rArr, rTable[ n ] ))
aDelArr.push_front( rTable[ n ] );
}
for( n = 0, nCnt = aDelArr.size(); n < nCnt; ++n )
rDoc.DelNumRule( aDelArr[ n ]->GetName() );
}
break;
default: break;
}
}
// determine the format
bool SwDocStyleSheet::FillStyleSheet(
FillStyleType const eFType, std::unique_ptr<SfxItemSet> *const o_ppFlatSet)
{
bool bRet = false;
sal_uInt16 nPoolId = USHRT_MAX;
SwFormat* pFormat = nullptr;
bool bCreate = FillPhysical == eFType;
bool bDeleteInfo = false;
bool bFillOnlyInfo = FillAllInfo == eFType || FillPreview == eFType;
std::vector<void*> aDelArr;
bool const isModified(rDoc.getIDocumentState().IsModified());
switch(nFamily)
{
case SfxStyleFamily::Char:
pCharFormat = lcl_FindCharFormat(rDoc, aName, this, bCreate );
bPhysical = nullptr != pCharFormat;
if( bFillOnlyInfo && !bPhysical )
{
// create style (plus all needed parents) and clean it up
// later - without affecting the undo/redo stack
::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
bDeleteInfo = true;
::lcl_SaveStyles( nFamily, aDelArr, rDoc );
pCharFormat = lcl_FindCharFormat(rDoc, aName, this );
}
pFormat = pCharFormat;
if( !bCreate && !pFormat )
{
if( aName == SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
RES_POOLCOLL_TEXT_BEGIN ] )
nPoolId = 0;
else
nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::ChrFmt );
}
bRet = nullptr != pCharFormat || USHRT_MAX != nPoolId;
if( bDeleteInfo )
pCharFormat = nullptr;
break;
case SfxStyleFamily::Para:
{
pColl = lcl_FindParaFormat(rDoc, aName, this, bCreate);
bPhysical = nullptr != pColl;
if( bFillOnlyInfo && !bPhysical )
{
::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
bDeleteInfo = true;
::lcl_SaveStyles( nFamily, aDelArr, rDoc );
pColl = lcl_FindParaFormat(rDoc, aName, this );
}
pFormat = pColl;
if( pColl )
PresetFollow( pColl->GetNextTextFormatColl().GetName() );
else if( !bCreate )
nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::TxtColl );
bRet = nullptr != pColl || USHRT_MAX != nPoolId;
if( bDeleteInfo )
pColl = nullptr;
}
break;
case SfxStyleFamily::Frame:
pFrameFormat = lcl_FindFrameFormat(rDoc, aName, this, bCreate);
bPhysical = nullptr != pFrameFormat;
if (bFillOnlyInfo && !bPhysical)
{
::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
bDeleteInfo = true;
::lcl_SaveStyles( nFamily, aDelArr, rDoc );
pFrameFormat = lcl_FindFrameFormat(rDoc, aName, this );
}
pFormat = pFrameFormat;
if( !bCreate && !pFormat )
nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::FrmFmt );
bRet = nullptr != pFrameFormat || USHRT_MAX != nPoolId;
if( bDeleteInfo )
pFrameFormat = nullptr;
break;
case SfxStyleFamily::Page:
pDesc = lcl_FindPageDesc(rDoc, aName, this, bCreate);
bPhysical = nullptr != pDesc;
if( bFillOnlyInfo && !pDesc )
{
::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
bDeleteInfo = true;
::lcl_SaveStyles( nFamily, aDelArr, rDoc );
pDesc = lcl_FindPageDesc( rDoc, aName, this );
}
if( pDesc )
{
nPoolId = pDesc->GetPoolFormatId();
nHelpId = pDesc->GetPoolHelpId();
if( pDesc->GetPoolHlpFileId() != UCHAR_MAX )
aHelpFile = *rDoc.GetDocPattern( pDesc->GetPoolHlpFileId() );
else
aHelpFile.clear();
}
else if( !bCreate )
nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::PageDesc );
SetMask( (USER_FMT & nPoolId) ? SFXSTYLEBIT_USERDEF : 0 );
bRet = nullptr != pDesc || USHRT_MAX != nPoolId;
if( bDeleteInfo )
pDesc = nullptr;
break;
case SfxStyleFamily::Pseudo:
pNumRule = lcl_FindNumRule(rDoc, aName, this, bCreate);
bPhysical = nullptr != pNumRule;
if( bFillOnlyInfo && !pNumRule )
{
::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
bDeleteInfo = true;
::lcl_SaveStyles( nFamily, aDelArr, rDoc );
pNumRule = lcl_FindNumRule( rDoc, aName, this );
}
if( pNumRule )
{
nPoolId = pNumRule->GetPoolFormatId();
nHelpId = pNumRule->GetPoolHelpId();
if( pNumRule->GetPoolHlpFileId() != UCHAR_MAX )
aHelpFile = *rDoc.GetDocPattern( pNumRule->GetPoolHlpFileId() );
else
aHelpFile.clear();
}
else if( !bCreate )
nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::NumRule );
SetMask( (USER_FMT & nPoolId) ? SFXSTYLEBIT_USERDEF : 0 );
bRet = nullptr != pNumRule || USHRT_MAX != nPoolId;
if( bDeleteInfo )
pNumRule = nullptr;
break;
case SfxStyleFamily::Table:
pTableFormat = lcl_FindTableStyle(rDoc, aName, this, bCreate);
SetMask((pTableFormat && pTableFormat->IsUserDefined()) ? SFXSTYLEBIT_USERDEF : 0);
bRet = bPhysical = (nullptr != pTableFormat);
break;
case SfxStyleFamily::Cell:
pBoxFormat = lcl_FindCellStyle(rDoc, aName, this);
bRet = bPhysical = (nullptr != pBoxFormat);
break;
default:; //prevent warning
}
if( SfxStyleFamily::Char == nFamily ||
SfxStyleFamily::Para == nFamily ||
SfxStyleFamily::Frame == nFamily )
{
if( pFormat )
nPoolId = pFormat->GetPoolFormatId();
sal_uInt16 _nMask = 0;
if( pFormat == rDoc.GetDfltCharFormat() )
_nMask |= SFXSTYLEBIT_READONLY;
else if( USER_FMT & nPoolId )
_nMask |= SFXSTYLEBIT_USERDEF;
switch ( COLL_GET_RANGE_BITS & nPoolId )
{
case COLL_TEXT_BITS: _nMask |= SWSTYLEBIT_TEXT; break;
case COLL_DOC_BITS : _nMask |= SWSTYLEBIT_CHAPTER; break;
case COLL_LISTS_BITS: _nMask |= SWSTYLEBIT_LIST; break;
case COLL_REGISTER_BITS: _nMask |= SWSTYLEBIT_IDX; break;
case COLL_EXTRA_BITS: _nMask |= SWSTYLEBIT_EXTRA; break;
case COLL_HTML_BITS: _nMask |= SWSTYLEBIT_HTML; break;
}
if( pFormat )
{
OSL_ENSURE( bPhysical, "Format not found" );
nHelpId = pFormat->GetPoolHelpId();
if( pFormat->GetPoolHlpFileId() != UCHAR_MAX )
aHelpFile = *rDoc.GetDocPattern( pFormat->GetPoolHlpFileId() );
else
aHelpFile.clear();
if( RES_CONDTXTFMTCOLL == pFormat->Which() )
_nMask |= SWSTYLEBIT_CONDCOLL;
if (FillPreview == eFType)
{
assert(o_ppFlatSet);
*o_ppFlatSet = lcl_SwFormatToFlatItemSet(pFormat);
}
}
SetMask( _nMask );
}
if( bDeleteInfo && bFillOnlyInfo )
{
::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
::lcl_DeleteInfoStyles( nFamily, aDelArr, rDoc );
if (!isModified)
{
rDoc.getIDocumentState().ResetModified();
}
}
return bRet;
}
// Create new format in Core
void SwDocStyleSheet::Create()
{
switch(nFamily)
{
case SfxStyleFamily::Char :
pCharFormat = lcl_FindCharFormat( rDoc, aName );
if( !pCharFormat )
pCharFormat = rDoc.MakeCharFormat(aName,
rDoc.GetDfltCharFormat());
pCharFormat->SetAuto(false);
break;
case SfxStyleFamily::Para :
pColl = lcl_FindParaFormat( rDoc, aName );
if( !pColl )
{
SwTextFormatColl *pPar = (*rDoc.GetTextFormatColls())[0];
if( nMask & SWSTYLEBIT_CONDCOLL )
pColl = rDoc.MakeCondTextFormatColl( aName, pPar );
else
pColl = rDoc.MakeTextFormatColl( aName, pPar );
}
break;
case SfxStyleFamily::Frame:
pFrameFormat = lcl_FindFrameFormat( rDoc, aName );
if( !pFrameFormat )
pFrameFormat = rDoc.MakeFrameFormat(aName, rDoc.GetDfltFrameFormat(), false, false);
break;
case SfxStyleFamily::Page :
pDesc = lcl_FindPageDesc( rDoc, aName );
if( !pDesc )
{
pDesc = rDoc.MakePageDesc(aName);
}
break;
case SfxStyleFamily::Pseudo:
pNumRule = lcl_FindNumRule( rDoc, aName );
if( !pNumRule )
{
const OUString sTmpNm( aName.isEmpty() ? rDoc.GetUniqueNumRuleName() : aName );
SwNumRule* pRule = rDoc.GetNumRuleTable()[
rDoc.MakeNumRule( sTmpNm, nullptr, false,
// #i89178#
numfunc::GetDefaultPositionAndSpaceMode() ) ];
pRule->SetAutoRule( false );
if( aName.isEmpty() )
{
// #i91400#
pRule->SetName( aName, rDoc.getIDocumentListsAccess() );
}
pNumRule = pRule;
}
break;
case SfxStyleFamily::Table:
if (aName.isEmpty())
return;
pTableFormat = lcl_FindTableStyle(rDoc, aName);
if (!pTableFormat)
{
rDoc.MakeTableStyle(aName);
pTableFormat = rDoc.GetTableStyles().FindAutoFormat(aName);
SAL_WARN_IF(!pTableFormat, "sw.ui", "Recently added auto format not found");
}
break;
default:; //prevent warning
}
bPhysical = true;
aCoreSet.ClearItem();
}
SwCharFormat* SwDocStyleSheet::GetCharFormat()
{
if(!bPhysical)
FillStyleSheet( FillPhysical );
return pCharFormat;
}
SwTextFormatColl* SwDocStyleSheet::GetCollection()
{
if(!bPhysical)
FillStyleSheet( FillPhysical );
return pColl;
}
const SwPageDesc* SwDocStyleSheet::GetPageDesc()
{
if(!bPhysical)
FillStyleSheet( FillPhysical );
return pDesc;
}
const SwNumRule * SwDocStyleSheet::GetNumRule()
{
if(!bPhysical)
FillStyleSheet( FillPhysical );
return pNumRule;
}
void SwDocStyleSheet::SetNumRule(const SwNumRule& rRule)
{
OSL_ENSURE(pNumRule, "Wo ist die NumRule");
rDoc.ChgNumRuleFormats( rRule );
}
SwTableAutoFormat* SwDocStyleSheet::GetTableFormat()
{
if(!bPhysical)
FillStyleSheet( FillPhysical );
assert(pTableFormat && "SwDocStyleSheet table style, SwTableAutoFormat not found");
return pTableFormat;
}
// re-generate Name AND Family from String
// First() and Next() (see below) insert an identification letter at Pos.1
void SwDocStyleSheet::PresetNameAndFamily(const OUString& rName)
{
switch( rName[0] )
{
case cPARA: nFamily = SfxStyleFamily::Para; break;
case cFRAME: nFamily = SfxStyleFamily::Frame; break;
case cPAGE: nFamily = SfxStyleFamily::Page; break;
case cNUMRULE: nFamily = SfxStyleFamily::Pseudo; break;
case cTABSTYLE: nFamily = SfxStyleFamily::Table; break;
default: nFamily = SfxStyleFamily::Char; break;
}
aName = rName.copy(1);
}
// Is the format physically present yet
void SwDocStyleSheet::SetPhysical(bool bPhys)
{
bPhysical = bPhys;
if(!bPhys)
{
pCharFormat = nullptr;
pColl = nullptr;
pFrameFormat = nullptr;
pDesc = nullptr;
}
}
SwFrameFormat* SwDocStyleSheet::GetFrameFormat()
{
if(!bPhysical)
FillStyleSheet( FillPhysical );
return pFrameFormat;
}
bool SwDocStyleSheet::IsUsed() const
{
if( !bPhysical )
{
SwDocStyleSheet* pThis = const_cast<SwDocStyleSheet*>(this);
pThis->FillStyleSheet( FillOnlyName );
}
if( !bPhysical )
return false;
const SwModify* pMod;
switch( nFamily )
{
case SfxStyleFamily::Char : pMod = pCharFormat; break;
case SfxStyleFamily::Para : pMod = pColl; break;
case SfxStyleFamily::Frame: pMod = pFrameFormat; break;
case SfxStyleFamily::Page : pMod = pDesc; break;
case SfxStyleFamily::Pseudo:
return pNumRule && SwDoc::IsUsed( *pNumRule );
case SfxStyleFamily::Table:
return pTableFormat && rDoc.IsUsed( *pTableFormat );
default:
OSL_ENSURE(false, "unknown style family");
return false;
}
return rDoc.IsUsed( *pMod );
}
sal_uLong SwDocStyleSheet::GetHelpId( OUString& rFile )
{
sal_uInt16 nId = 0;
sal_uInt16 nPoolId = 0;
unsigned char nFileId = UCHAR_MAX;
rFile = "swrhlppi.hlp";
const SwFormat* pTmpFormat = nullptr;
switch( nFamily )
{
case SfxStyleFamily::Char :
if( !pCharFormat &&
nullptr == (pCharFormat = lcl_FindCharFormat( rDoc, aName, nullptr, false )) )
{
nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::ChrFmt );
return USHRT_MAX == nId ? 0 : nId;
}
pTmpFormat = pCharFormat;
break;
case SfxStyleFamily::Para:
if( !pColl &&
nullptr == ( pColl = lcl_FindParaFormat( rDoc, aName, nullptr, false )) )
{
nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::TxtColl );
return USHRT_MAX == nId ? 0 : nId;
}
pTmpFormat = pColl;
break;
case SfxStyleFamily::Frame:
if( !pFrameFormat &&
nullptr == ( pFrameFormat = lcl_FindFrameFormat( rDoc, aName, nullptr, false ) ) )
{
nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::FrmFmt );
return USHRT_MAX == nId ? 0 : nId;
}
pTmpFormat = pFrameFormat;
break;
case SfxStyleFamily::Page:
if( !pDesc &&
nullptr == ( pDesc = lcl_FindPageDesc( rDoc, aName, nullptr, false ) ) )
{
nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::PageDesc );
return USHRT_MAX == nId ? 0 : nId;
}
nId = pDesc->GetPoolHelpId();
nFileId = pDesc->GetPoolHlpFileId();
nPoolId = pDesc->GetPoolFormatId();
break;
case SfxStyleFamily::Pseudo:
if( !pNumRule &&
nullptr == ( pNumRule = lcl_FindNumRule( rDoc, aName, nullptr, false ) ) )
{
nId = SwStyleNameMapper::GetPoolIdFromUIName( aName, SwGetPoolIdFromName::NumRule );
return USHRT_MAX == nId ? 0 : nId;
}
nId = pNumRule->GetPoolHelpId();
nFileId = pNumRule->GetPoolHlpFileId();
nPoolId = pNumRule->GetPoolFormatId();
break;
default:
OSL_ENSURE(false, "unknown style family");
return 0;
}
if( pTmpFormat )
{
nId = pTmpFormat->GetPoolHelpId();
nFileId = pTmpFormat->GetPoolHlpFileId();
nPoolId = pTmpFormat->GetPoolFormatId();
}
if( UCHAR_MAX != nFileId )
{
const OUString *pTemplate = rDoc.GetDocPattern( nFileId );
if( pTemplate )
{
rFile = *pTemplate;
}
}
else if( !IsPoolUserFormat( nPoolId ) )
{
nId = nPoolId;
}
// because SFX acts like that, with HelpId:
if( USHRT_MAX == nId )
nId = 0; // don't show Help accordingly
return nId;
}
void SwDocStyleSheet::SetHelpId( const OUString& r, sal_uLong nId )
{
sal_uInt8 nFileId = static_cast< sal_uInt8 >(rDoc.SetDocPattern( r ));
sal_uInt16 nHId = static_cast< sal_uInt16 >(nId); //!! SFX changed over to ULONG arbitrarily!
SwFormat* pTmpFormat = nullptr;
switch( nFamily )
{
case SfxStyleFamily::Char : pTmpFormat = pCharFormat; break;
case SfxStyleFamily::Para : pTmpFormat = pColl; break;
case SfxStyleFamily::Frame: pTmpFormat = pFrameFormat; break;
case SfxStyleFamily::Page :
const_cast<SwPageDesc*>(pDesc)->SetPoolHelpId( nHId );
const_cast<SwPageDesc*>(pDesc)->SetPoolHlpFileId( nFileId );
break;
case SfxStyleFamily::Pseudo:
const_cast<SwNumRule*>(pNumRule)->SetPoolHelpId( nHId );
const_cast<SwNumRule*>(pNumRule)->SetPoolHlpFileId( nFileId );
break;
default:
OSL_ENSURE(false, "unknown style family");
return ;
}
if( pTmpFormat )
{
pTmpFormat->SetPoolHelpId( nHId );
pTmpFormat->SetPoolHlpFileId( nFileId );
}
}
// methods for DocStyleSheetPool
SwDocStyleSheetPool::SwDocStyleSheetPool( SwDoc& rDocument, bool bOrg )
: SfxStyleSheetBasePool( rDocument.GetAttrPool() )
, mxStyleSheet( new SwDocStyleSheet( rDocument, OUString(), this ) )
, rDoc( rDocument )
{
bOrganizer = bOrg;
}
SwDocStyleSheetPool::~SwDocStyleSheetPool()
{
}
SfxStyleSheetBase& SwDocStyleSheetPool::Make( const OUString& rName,
SfxStyleFamily eFam,
sal_uInt16 _nMask)
{
mxStyleSheet->PresetName(rName);
mxStyleSheet->PresetParent(OUString());
mxStyleSheet->PresetFollow(OUString());
mxStyleSheet->SetMask(_nMask) ;
mxStyleSheet->SetFamily(eFam);
mxStyleSheet->SetPhysical(true);
mxStyleSheet->Create();
return *mxStyleSheet.get();
}
SfxStyleSheetBase* SwDocStyleSheetPool::Create( const SfxStyleSheetBase& /*rOrg*/)
{
OSL_ENSURE(false , "Create im SW-Stylesheet-Pool geht nicht" );
return nullptr;
}
SfxStyleSheetBase* SwDocStyleSheetPool::Create( const OUString &,
SfxStyleFamily, sal_uInt16 )
{
OSL_ENSURE( false, "Create im SW-Stylesheet-Pool geht nicht" );
return nullptr;
}
std::shared_ptr<SfxStyleSheetIterator> SwDocStyleSheetPool::CreateIterator( SfxStyleFamily eFam, sal_uInt16 _nMask )
{
return std::shared_ptr<SfxStyleSheetIterator>(new SwStyleSheetIterator( this, eFam, _nMask ));
}
void SwDocStyleSheetPool::dispose()
{
mxStyleSheet.clear();
}
void SwDocStyleSheetPool::Remove( SfxStyleSheetBase* pStyle)
{
if( !pStyle )
return;
bool bBroadcast = true;
SwImplShellAction aTmpSh( rDoc );
const OUString sName = pStyle->GetName();
switch( pStyle->GetFamily() )
{
case SfxStyleFamily::Char:
{
SwCharFormat* pFormat = lcl_FindCharFormat(rDoc, sName, nullptr, false );
if(pFormat)
rDoc.DelCharFormat(pFormat);
}
break;
case SfxStyleFamily::Para:
{
SwTextFormatColl* pColl = lcl_FindParaFormat(rDoc, sName, nullptr, false );
if(pColl)
rDoc.DelTextFormatColl(pColl);
}
break;
case SfxStyleFamily::Frame:
{
SwFrameFormat* pFormat = lcl_FindFrameFormat(rDoc, sName, nullptr, false );
if(pFormat)
rDoc.DelFrameFormat(pFormat);
}
break;
case SfxStyleFamily::Page :
{
rDoc.DelPageDesc(sName);
}
break;
case SfxStyleFamily::Pseudo:
{
if( !rDoc.DelNumRule( sName ) )
// Only send Broadcast, when something was deleted
bBroadcast = false;
}
break;
case SfxStyleFamily::Table:
{
rDoc.DelTableStyle(sName);
}
break;
default:
OSL_ENSURE(false, "unknown style family");
bBroadcast = false;
}
if( bBroadcast )
Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetErased, *pStyle ) );
}
bool SwDocStyleSheetPool::SetParent( SfxStyleFamily eFam,
const OUString &rStyle, const OUString &rParent )
{
SwFormat* pFormat = nullptr, *pParent = nullptr;
switch( eFam )
{
case SfxStyleFamily::Char :
if( nullptr != ( pFormat = lcl_FindCharFormat( rDoc, rStyle ) ) && !rParent.isEmpty() )
pParent = lcl_FindCharFormat(rDoc, rParent );
break;
case SfxStyleFamily::Para :
if( nullptr != ( pFormat = lcl_FindParaFormat( rDoc, rStyle ) ) && !rParent.isEmpty() )
pParent = lcl_FindParaFormat( rDoc, rParent );
break;
case SfxStyleFamily::Frame:
if( nullptr != ( pFormat = lcl_FindFrameFormat( rDoc, rStyle ) ) && !rParent.isEmpty() )
pParent = lcl_FindFrameFormat( rDoc, rParent );
break;
case SfxStyleFamily::Page:
case SfxStyleFamily::Pseudo:
break;
default:
OSL_ENSURE(false, "unknown style family");
}
bool bRet = false;
if( pFormat && pFormat->DerivedFrom() &&
pFormat->DerivedFrom()->GetName() != rParent )
{
{
SwImplShellAction aTmpSh( rDoc );
bRet = pFormat->SetDerivedFrom( pParent );
}
if( bRet )
{
// only for Broadcasting
mxStyleSheet->PresetName( rStyle );
mxStyleSheet->PresetParent( rParent );
if( SfxStyleFamily::Para == eFam )
mxStyleSheet->PresetFollow( static_cast<SwTextFormatColl*>(pFormat)->
GetNextTextFormatColl().GetName() );
else
mxStyleSheet->PresetFollow( OUString() );
Broadcast( SfxStyleSheetHint( SfxHintId::StyleSheetModified,
*(mxStyleSheet.get()) ) );
}
}
return bRet;
}
SfxStyleSheetBase* SwDocStyleSheetPool::Find( const OUString& rName,
SfxStyleFamily eFam, sal_uInt16 n )
{
sal_uInt16 nSMask = n;
if( SfxStyleFamily::Para == eFam && rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) )
{
// then only HTML-Templates are of interest
if( USHRT_MAX == nSMask )
nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF | SFXSTYLEBIT_USED;
else
nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
if( !nSMask )
nSMask = SWSTYLEBIT_HTML;
}
const bool bSearchUsed = ( n != SFXSTYLEBIT_ALL && n & SFXSTYLEBIT_USED );
const SwModify* pMod = nullptr;
mxStyleSheet->SetPhysical( false );
mxStyleSheet->PresetName( rName );
mxStyleSheet->SetFamily( eFam );
bool bFnd = mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
if( mxStyleSheet->IsPhysical() )
{
switch( eFam )
{
case SfxStyleFamily::Char:
pMod = mxStyleSheet->GetCharFormat();
break;
case SfxStyleFamily::Para:
pMod = mxStyleSheet->GetCollection();
break;
case SfxStyleFamily::Frame:
pMod = mxStyleSheet->GetFrameFormat();
break;
case SfxStyleFamily::Page:
pMod = mxStyleSheet->GetPageDesc();
break;
case SfxStyleFamily::Pseudo:
{
const SwNumRule* pRule = mxStyleSheet->GetNumRule();
if( pRule &&
!bSearchUsed &&
(( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
? !(pRule->GetPoolFormatId() & USER_FMT)
// searched for used and found none
: bSearchUsed ))
bFnd = false;
}
break;
case SfxStyleFamily::Table:
case SfxStyleFamily::Cell:
break;
default:
OSL_ENSURE(false, "unknown style family");
}
}
// then evaluate the mask:
if( pMod && !bSearchUsed )
{
const sal_uInt16 nId = SfxStyleFamily::Page == eFam
? static_cast<const SwPageDesc*>(pMod)->GetPoolFormatId()
: static_cast<const SwFormat*>(pMod)->GetPoolFormatId();
if( ( nSMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
? !(nId & USER_FMT)
// searched for used and found none
: bSearchUsed )
bFnd = false;
}
return bFnd ? mxStyleSheet.get() : nullptr;
}
SwStyleSheetIterator::SwStyleSheetIterator( SwDocStyleSheetPool* pBase,
SfxStyleFamily eFam, sal_uInt16 n )
: SfxStyleSheetIterator( pBase, eFam, n ),
mxIterSheet( new SwDocStyleSheet( pBase->GetDoc(), OUString(), pBase ) ),
mxStyleSheet( new SwDocStyleSheet( pBase->GetDoc(), OUString(), pBase ) )
{
bFirstCalled = false;
nLastPos = 0;
StartListening( *pBase );
}
SwStyleSheetIterator::~SwStyleSheetIterator()
{
EndListening( mxIterSheet->GetPool() );
}
sal_uInt16 SwStyleSheetIterator::Count()
{
// let the list fill correctly!!
if( !bFirstCalled )
First();
return aLst.size();
}
SfxStyleSheetBase* SwStyleSheetIterator::operator[]( sal_uInt16 nIdx )
{
// found
if( !bFirstCalled )
First();
mxStyleSheet->PresetNameAndFamily( aLst[ nIdx ] );
mxStyleSheet->SetPhysical( false );
mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
return mxStyleSheet.get();
}
SfxStyleSheetBase* SwStyleSheetIterator::First()
{
// Delete old list
bFirstCalled = true;
nLastPos = 0;
aLst.clear();
// Delete current
mxIterSheet->Reset();
SwDoc& rDoc = static_cast<SwDocStyleSheetPool*>(pBasePool)->GetDoc();
const sal_uInt16 nSrchMask = nMask;
const bool bIsSearchUsed = SearchUsed();
bool bSearchHidden = ( nMask & SFXSTYLEBIT_HIDDEN );
bool bOnlyHidden = nMask == SFXSTYLEBIT_HIDDEN;
const bool bOrganizer = static_cast<SwDocStyleSheetPool*>(pBasePool)->IsOrganizerMode();
bool bAll = ( nSrchMask & SFXSTYLEBIT_ALL_VISIBLE ) == SFXSTYLEBIT_ALL_VISIBLE;
if( nSearchFamily == SfxStyleFamily::Char
|| nSearchFamily == SfxStyleFamily::All )
{
const size_t nArrLen = rDoc.GetCharFormats()->size();
for( size_t i = 0; i < nArrLen; i++ )
{
SwCharFormat* pFormat = (*rDoc.GetCharFormats())[ i ];
const bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(*pFormat));
if( ( !bSearchHidden && pFormat->IsHidden() && !bUsed ) || ( pFormat->IsDefault() && pFormat != rDoc.GetDfltCharFormat() ) )
continue;
if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !pFormat->IsHidden( ) )
continue;
if( !bUsed )
{
// Standard is no User template
const sal_uInt16 nId = rDoc.GetDfltCharFormat() == pFormat ?
sal_uInt16( RES_POOLCHR_INET_NORMAL ):
pFormat->GetPoolFormatId();
if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
? !(nId & USER_FMT)
// searched for used and found none
: bIsSearchUsed )
{
continue;
}
if( rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) && !(nId & USER_FMT) &&
!( RES_POOLCHR_HTML_BEGIN <= nId &&
nId < RES_POOLCHR_HTML_END ) &&
RES_POOLCHR_INET_NORMAL != nId &&
RES_POOLCHR_INET_VISIT != nId &&
RES_POOLCHR_FOOTNOTE != nId &&
RES_POOLCHR_ENDNOTE != nId )
continue;
}
aLst.Append( cCHAR, pFormat == rDoc.GetDfltCharFormat()
? SwStyleNameMapper::GetTextUINameArray()[ RES_POOLCOLL_STANDARD -
RES_POOLCOLL_TEXT_BEGIN ]
: pFormat->GetName() );
}
// PoolFormat
if( bAll )
{
if( ! rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) )
AppendStyleList(SwStyleNameMapper::GetChrFormatUINameArray(),
bIsSearchUsed, bSearchHidden, bOnlyHidden,
SwGetPoolIdFromName::ChrFmt, cCHAR);
else
{
aLst.Append( cCHAR, SwStyleNameMapper::GetChrFormatUINameArray()[
RES_POOLCHR_INET_NORMAL - RES_POOLCHR_BEGIN ] );
aLst.Append( cCHAR, SwStyleNameMapper::GetChrFormatUINameArray()[
RES_POOLCHR_INET_VISIT - RES_POOLCHR_BEGIN ] );
aLst.Append( cCHAR, SwStyleNameMapper::GetChrFormatUINameArray()[
RES_POOLCHR_ENDNOTE - RES_POOLCHR_BEGIN ] );
aLst.Append( cCHAR, SwStyleNameMapper::GetChrFormatUINameArray()[
RES_POOLCHR_FOOTNOTE - RES_POOLCHR_BEGIN ] );
}
AppendStyleList(SwStyleNameMapper::GetHTMLChrFormatUINameArray(),
bIsSearchUsed, bSearchHidden, bOnlyHidden,
SwGetPoolIdFromName::ChrFmt, cCHAR);
}
}
if( nSearchFamily == SfxStyleFamily::Para ||
nSearchFamily == SfxStyleFamily::All )
{
sal_uInt16 nSMask = nSrchMask;
if( rDoc.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) )
{
// then only HTML-Template are of interest
if( SFXSTYLEBIT_ALL_VISIBLE == ( nSMask & SFXSTYLEBIT_ALL_VISIBLE ) )
nSMask = SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF |
SFXSTYLEBIT_USED;
else
nSMask &= SFXSTYLEBIT_USED | SFXSTYLEBIT_USERDEF |
SWSTYLEBIT_CONDCOLL | SWSTYLEBIT_HTML;
if( !nSMask )
nSMask = SWSTYLEBIT_HTML;
}
const size_t nArrLen = rDoc.GetTextFormatColls()->size();
for( size_t i = 0; i < nArrLen; i++ )
{
SwTextFormatColl* pColl = (*rDoc.GetTextFormatColls())[ i ];
const bool bUsed = bOrganizer || rDoc.IsUsed(*pColl);
if ( ( !bSearchHidden && pColl->IsHidden( ) && !bUsed ) || pColl->IsDefault() )
continue;
if ( nSMask == SFXSTYLEBIT_HIDDEN && !pColl->IsHidden( ) )
continue;
if( !(bIsSearchUsed && bUsed ))
{
const sal_uInt16 nId = pColl->GetPoolFormatId();
switch ( (nSMask & ~SFXSTYLEBIT_USED) )
{
case SFXSTYLEBIT_USERDEF:
if(!IsPoolUserFormat(nId)) continue;
break;
case SWSTYLEBIT_TEXT:
if((nId & COLL_GET_RANGE_BITS) != COLL_TEXT_BITS) continue;
break;
case SWSTYLEBIT_CHAPTER:
if((nId & COLL_GET_RANGE_BITS) != COLL_DOC_BITS) continue;
break;
case SWSTYLEBIT_LIST:
if((nId & COLL_GET_RANGE_BITS) != COLL_LISTS_BITS) continue;
break;
case SWSTYLEBIT_IDX:
if((nId & COLL_GET_RANGE_BITS) != COLL_REGISTER_BITS) continue;
break;
case SWSTYLEBIT_EXTRA:
if((nId & COLL_GET_RANGE_BITS) != COLL_EXTRA_BITS) continue;
break;
case SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF:
if(IsPoolUserFormat(nId))
break;
SAL_FALLTHROUGH;
case SWSTYLEBIT_HTML:
if( (nId & COLL_GET_RANGE_BITS) != COLL_HTML_BITS)
{
// but some we also want to see in this section
bool bContinue = true;
switch( nId )
{
case RES_POOLCOLL_SENDADRESS: // --> ADDRESS
case RES_POOLCOLL_TABLE_HDLN: // --> TH
case RES_POOLCOLL_TABLE: // --> TD
case RES_POOLCOLL_TEXT: // --> P
case RES_POOLCOLL_HEADLINE_BASE:// --> H
case RES_POOLCOLL_HEADLINE1: // --> H1
case RES_POOLCOLL_HEADLINE2: // --> H2
case RES_POOLCOLL_HEADLINE3: // --> H3
case RES_POOLCOLL_HEADLINE4: // --> H4
case RES_POOLCOLL_HEADLINE5: // --> H5
case RES_POOLCOLL_HEADLINE6: // --> H6
case RES_POOLCOLL_STANDARD: // --> P
case RES_POOLCOLL_FOOTNOTE:
case RES_POOLCOLL_ENDNOTE:
bContinue = false;
break;
}
if( bContinue )
continue;
}
break;
case SWSTYLEBIT_CONDCOLL:
if( RES_CONDTXTFMTCOLL != pColl->Which() ) continue;
break;
default:
// searched for used and found none
if( bIsSearchUsed )
continue;
}
}
aLst.Append( cPARA, pColl->GetName() );
}
bAll = ( nSMask & SFXSTYLEBIT_ALL_VISIBLE ) == SFXSTYLEBIT_ALL_VISIBLE;
if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_TEXT )
AppendStyleList(SwStyleNameMapper::GetTextUINameArray(),
bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, cPARA );
if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CHAPTER )
AppendStyleList(SwStyleNameMapper::GetDocUINameArray(),
bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, cPARA ) ;
if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_LIST )
AppendStyleList(SwStyleNameMapper::GetListsUINameArray(),
bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, cPARA ) ;
if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_IDX )
AppendStyleList(SwStyleNameMapper::GetRegisterUINameArray(),
bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, cPARA ) ;
if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_EXTRA )
AppendStyleList(SwStyleNameMapper::GetExtraUINameArray(),
bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, cPARA ) ;
if ( bAll || (nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_CONDCOLL )
{
if( !bIsSearchUsed ||
rDoc.getIDocumentStylePoolAccess().IsPoolTextCollUsed( RES_POOLCOLL_TEXT ))
aLst.Append( cPARA, SwStyleNameMapper::GetTextUINameArray()[
RES_POOLCOLL_TEXT - RES_POOLCOLL_TEXT_BEGIN ] );
}
if ( bAll ||
(nSMask & ~SFXSTYLEBIT_USED) == SWSTYLEBIT_HTML ||
(nSMask & ~SFXSTYLEBIT_USED) ==
(SWSTYLEBIT_HTML | SFXSTYLEBIT_USERDEF) )
{
AppendStyleList(SwStyleNameMapper::GetHTMLUINameArray(),
bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::TxtColl, cPARA ) ;
if( !bAll )
{
// then also the ones, that we are mapping:
static sal_uInt16 aPoolIds[] = {
RES_POOLCOLL_SENDADRESS, // --> ADDRESS
RES_POOLCOLL_TABLE_HDLN, // --> TH
RES_POOLCOLL_TABLE, // --> TD
RES_POOLCOLL_STANDARD, // --> P
RES_POOLCOLL_TEXT, // --> P
RES_POOLCOLL_HEADLINE_BASE, // --> H
RES_POOLCOLL_HEADLINE1, // --> H1
RES_POOLCOLL_HEADLINE2, // --> H2
RES_POOLCOLL_HEADLINE3, // --> H3
RES_POOLCOLL_HEADLINE4, // --> H4
RES_POOLCOLL_HEADLINE5, // --> H5
RES_POOLCOLL_HEADLINE6, // --> H6
RES_POOLCOLL_FOOTNOTE,
RES_POOLCOLL_ENDNOTE,
0
};
sal_uInt16* pPoolIds = aPoolIds;
OUString s;
while( *pPoolIds )
{
if( !bIsSearchUsed || rDoc.getIDocumentStylePoolAccess().IsPoolTextCollUsed( *pPoolIds ) )
aLst.Append( cPARA,
s = SwStyleNameMapper::GetUIName( *pPoolIds, s ));
++pPoolIds;
}
}
}
}
if( nSearchFamily == SfxStyleFamily::Frame ||
nSearchFamily == SfxStyleFamily::All )
{
const size_t nArrLen = rDoc.GetFrameFormats()->size();
for( size_t i = 0; i < nArrLen; i++ )
{
const SwFrameFormat* pFormat = (*rDoc.GetFrameFormats())[ i ];
bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(*pFormat));
if( ( !bSearchHidden && pFormat->IsHidden( ) && !bUsed ) || pFormat->IsDefault() || pFormat->IsAuto() )
continue;
if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !pFormat->IsHidden( ) )
continue;
const sal_uInt16 nId = pFormat->GetPoolFormatId();
if( !bUsed )
{
if( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
? !(nId & USER_FMT)
// searched for used and found none
: bIsSearchUsed )
{
continue;
}
}
aLst.Append( cFRAME, pFormat->GetName() );
}
// PoolFormat
if ( bAll )
AppendStyleList(SwStyleNameMapper::GetFrameFormatUINameArray(),
bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::FrmFmt, cFRAME);
}
if( nSearchFamily == SfxStyleFamily::Page ||
nSearchFamily == SfxStyleFamily::All )
{
const size_t nCount = rDoc.GetPageDescCnt();
for(size_t i = 0; i < nCount; ++i)
{
const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
const sal_uInt16 nId = rDesc.GetPoolFormatId();
bool bUsed = bIsSearchUsed && ( bOrganizer || rDoc.IsUsed(rDesc));
if( !bUsed )
{
if ( ( !bSearchHidden && rDesc.IsHidden() ) ||
( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
? !(nId & USER_FMT)
// searched for used and found none
: bIsSearchUsed ) )
continue;
}
if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !rDesc.IsHidden( ) )
continue;
aLst.Append( cPAGE, rDesc.GetName() );
}
if ( bAll )
AppendStyleList(SwStyleNameMapper::GetPageDescUINameArray(),
bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::PageDesc, cPAGE);
}
if( nSearchFamily == SfxStyleFamily::Pseudo ||
nSearchFamily == SfxStyleFamily::All )
{
const SwNumRuleTable& rNumTable = rDoc.GetNumRuleTable();
for(size_t i = 0; i < rNumTable.size(); ++i)
{
const SwNumRule& rRule = *rNumTable[ i ];
if( !rRule.IsAutoRule() )
{
if ( nSrchMask == SFXSTYLEBIT_HIDDEN && !rRule.IsHidden( ) )
continue;
bool bUsed = bIsSearchUsed && ( bOrganizer || SwDoc::IsUsed(rRule) );
if( !bUsed )
{
if( ( !bSearchHidden && rRule.IsHidden() ) ||
( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
? !(rRule.GetPoolFormatId() & USER_FMT)
// searched for used and found none
: bIsSearchUsed ) )
continue;
}
aLst.Append( cNUMRULE, rRule.GetName() );
}
}
if ( bAll )
AppendStyleList(SwStyleNameMapper::GetNumRuleUINameArray(),
bIsSearchUsed, bSearchHidden, bOnlyHidden, SwGetPoolIdFromName::NumRule, cNUMRULE);
}
if( nSearchFamily == SfxStyleFamily::Table ||
nSearchFamily == SfxStyleFamily::All )
{
const SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
for(size_t i = 0; i < rTableStyles.size(); ++i)
{
const SwTableAutoFormat& rTableStyle = rTableStyles[i];
bool bUsed = bIsSearchUsed && (bOrganizer || rDoc.IsUsed(rTableStyle));
if(!bUsed)
{
if(nSrchMask == SFXSTYLEBIT_HIDDEN && !rTableStyle.IsHidden())
continue;
if( (!bSearchHidden && rTableStyle.IsHidden() ) ||
( (nSrchMask & ~SFXSTYLEBIT_USED) == SFXSTYLEBIT_USERDEF
? !rTableStyle.IsUserDefined()
// searched for used and found none
: bIsSearchUsed ) )
continue;
}
aLst.Append( cTABSTYLE, rTableStyle.GetName() );
}
}
if( nSearchFamily == SfxStyleFamily::Cell ||
nSearchFamily == SfxStyleFamily::All )
{
const auto& aTableTemplateMap = SwTableAutoFormat::GetTableTemplateMap();
const SwTableAutoFormatTable& rTableStyles = rDoc.GetTableStyles();
for(size_t i = 0; i < rTableStyles.size(); ++i)
{
const SwTableAutoFormat& rTableStyle = rTableStyles[i];
for(size_t nBoxFormat = 0; nBoxFormat < aTableTemplateMap.size(); ++nBoxFormat)
{
const sal_uInt32 nBoxIndex = aTableTemplateMap[nBoxFormat];
const SwBoxAutoFormat& rBoxFormat = rTableStyle.GetBoxFormat(nBoxIndex);
OUString sBoxFormatName;
SwStyleNameMapper::FillProgName(rTableStyle.GetName(), sBoxFormatName, SwGetPoolIdFromName::CellStyle, true);
sBoxFormatName += rTableStyle.GetTableTemplateCellSubName(rBoxFormat);
aLst.Append( cCELLSTYLE, sBoxFormatName );
}
}
const SwCellStyleTable& rCellStyles = rDoc.GetCellStyles();
for(size_t i = 0; i < rCellStyles.size(); ++i)
aLst.Append( cCELLSTYLE, rCellStyles[i].GetName() );
}
if(!aLst.empty())
{
nLastPos = SAL_MAX_UINT32;
return Next();
}
return nullptr;
}
SfxStyleSheetBase* SwStyleSheetIterator::Next()
{
assert(bFirstCalled);
++nLastPos;
if(nLastPos < aLst.size())
{
mxIterSheet->PresetNameAndFamily(aLst[nLastPos]);
mxIterSheet->SetPhysical( false );
mxIterSheet->SetMask( nMask );
if(mxIterSheet->pSet)
{
mxIterSheet->pSet->ClearItem();
mxIterSheet->pSet= nullptr;
}
return mxIterSheet.get();
}
return nullptr;
}
SfxStyleSheetBase* SwStyleSheetIterator::Find(const OUString& rName)
{
// searching
if( !bFirstCalled )
First();
nLastPos = aLst.FindName( nSearchFamily, rName );
if( SAL_MAX_UINT32 != nLastPos )
{
// found
mxStyleSheet->PresetNameAndFamily(aLst[nLastPos]);
// new name is set, so determine its Data
mxStyleSheet->FillStyleSheet( SwDocStyleSheet::FillOnlyName );
if( !mxStyleSheet->IsPhysical() )
mxStyleSheet->SetPhysical( false );
return mxStyleSheet.get();
}
return nullptr;
}
void SwStyleSheetIterator::AppendStyleList(const std::vector<OUString>& rList,
bool bTestUsed, bool bTestHidden, bool bOnlyHidden,
SwGetPoolIdFromName nSection, char cType )
{
SwDoc& rDoc = static_cast<SwDocStyleSheetPool*>(pBasePool)->GetDoc();
bool bUsed = false;
for (const auto & i : rList)
{
bool bHidden = false;
sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(i, nSection);
switch ( nSection )
{
case SwGetPoolIdFromName::TxtColl:
{
bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolTextCollUsed( nId );
SwFormat* pFormat = rDoc.FindTextFormatCollByName( i );
bHidden = pFormat && pFormat->IsHidden( );
}
break;
case SwGetPoolIdFromName::ChrFmt:
{
bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolFormatUsed( nId );
SwFormat* pFormat = rDoc.FindCharFormatByName( i );
bHidden = pFormat && pFormat->IsHidden( );
}
break;
case SwGetPoolIdFromName::FrmFmt:
{
bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolFormatUsed( nId );
SwFormat* pFormat = rDoc.FindFrameFormatByName( i );
bHidden = pFormat && pFormat->IsHidden( );
}
break;
case SwGetPoolIdFromName::PageDesc:
{
bUsed = rDoc.getIDocumentStylePoolAccess().IsPoolPageDescUsed( nId );
SwPageDesc* pPgDesc = rDoc.FindPageDesc(i);
bHidden = pPgDesc && pPgDesc->IsHidden( );
}
break;
case SwGetPoolIdFromName::NumRule:
{
SwNumRule* pRule = rDoc.FindNumRulePtr( i );
bUsed = pRule && SwDoc::IsUsed( *pRule );
bHidden = pRule && pRule->IsHidden( );
}
break;
default:
OSL_ENSURE( false, "unknown PoolFormat-Id" );
}
bool bMatchHidden = ( bTestHidden && ( bHidden || !bOnlyHidden ) ) || ( !bTestHidden && ( !bHidden || bUsed ) );
if ( ( !bTestUsed && bMatchHidden ) || ( bTestUsed && bUsed ) )
aLst.Append( cType, i );
}
}
void SwDocStyleSheetPool::InvalidateIterator()
{
dynamic_cast<SwStyleSheetIterator&>(GetIterator_Impl()).InvalidateIterator();
}
void SwStyleSheetIterator::InvalidateIterator()
{
// potentially we could send an SfxHint to Notify but currently it's
// iterating over the vector anyway so would still be slow - why does
// this iterator not use a map?
bFirstCalled = false;
nLastPos = 0;
aLst.clear();
}
void SwStyleSheetIterator::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
// search and remove from View-List!!
const SfxStyleSheetHint* pStyleSheetHint = dynamic_cast<const SfxStyleSheetHint*>(&rHint);
if( pStyleSheetHint &&
SfxHintId::StyleSheetErased == pStyleSheetHint->GetId() )
{
SfxStyleSheetBase* pStyle = pStyleSheetHint->GetStyleSheet();
if (pStyle)
aLst.RemoveName(pStyle->GetFamily(), pStyle->GetName());
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|