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
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include <svl/smplhint.hxx>
#include <svl/itemiter.hxx>
#include <hints.hxx>
#include <txtftn.hxx>
#include <fmtftn.hxx>
#include <fmtclbl.hxx>
#include "sectfrm.hxx"
#include "section.hxx" // SwSection
#include "frmtool.hxx" // StackHack
#include "doc.hxx" // SwDoc
#include "cntfrm.hxx" // SwCntntFrm
#include "rootfrm.hxx" // SwRootFrm
#include "pagefrm.hxx" // SwPageFrm
#include "fmtpdsc.hxx" // SwFmtPageDesc
#include "fmtcntnt.hxx" // SwFmtCntnt
#include "ndindex.hxx" // SwNodeIndex
#include "ftnidx.hxx"
#include "txtfrm.hxx" // SwTxtFrm
#include "fmtclds.hxx" // SwFmtCol
#include "colfrm.hxx" // SwColumnFrm
#include "tabfrm.hxx" // SwTabFrm
#include "flyfrm.hxx" // SwFlyFrm
#include "ftnfrm.hxx" // SwFtnFrm
#include "layouter.hxx" // SwLayouter
#include "dbg_lay.hxx"
#include "viewsh.hxx"
#include "viewopt.hxx"
#include "viewimp.hxx"
#include <editeng/ulspitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/brshitem.hxx>
#include <fmtftntx.hxx>
// OD 2004-05-24 #i28701#
#include <dflyobj.hxx>
#include <flyfrms.hxx>
#include <sortedobjs.hxx>
SV_IMPL_PTRARR_SORT( SwDestroyList, SwSectionFrmPtr )
/*************************************************************************
|*
|* SwSectionFrm::SwSectionFrm(), ~SwSectionFrm()
|*
|*************************************************************************/
SwSectionFrm::SwSectionFrm( SwSection &rSect, SwFrm* pSib )
: SwLayoutFrm( rSect.GetFmt(), pSib )
, SwFlowFrm( static_cast<SwFrm&>(*this) )
, pSection( &rSect )
, bFtnAtEnd(false)
, bEndnAtEnd(false)
, bCntntLock(false)
, bOwnFtnNum(false)
, bFtnLock(false)
{
nType = FRMC_SECTION;
CalcFtnAtEndFlag();
CalcEndAtEndFlag();
}
SwSectionFrm::SwSectionFrm( SwSectionFrm &rSect, sal_Bool bMaster ) :
SwLayoutFrm( rSect.GetFmt(), rSect.getRootFrm() ),
SwFlowFrm( (SwFrm&)*this ),
pSection( rSect.GetSection() ),
bFtnAtEnd( rSect.IsFtnAtEnd() ),
bEndnAtEnd( rSect.IsEndnAtEnd() ),
bCntntLock( false ),
bOwnFtnNum( false ),
bFtnLock( false )
{
nType = FRMC_SECTION;
PROTOCOL( this, PROT_SECTION, bMaster ? ACT_CREATE_MASTER : ACT_CREATE_FOLLOW, &rSect )
if( bMaster )
{
if( rSect.IsFollow() )
{
SwSectionFrm* pMaster = rSect.FindMaster();
pMaster->SetFollow( this );
}
SetFollow( &rSect );
}
else
{
SetFollow( rSect.GetFollow() );
rSect.SetFollow( this );
if( !GetFollow() )
rSect.SimpleFormat();
if( !rSect.IsColLocked() )
rSect.InvalidateSize();
}
}
// NOTE: call <SwSectionFrm::Init()> directly after creation of a new section
// frame and its insert in the layout.
void SwSectionFrm::Init()
{
OSL_ENSURE( GetUpper(), "SwSectionFrm::Init before insertion?!" );
SWRECTFN( this )
long nWidth = (GetUpper()->Prt().*fnRect->fnGetWidth)();
(Frm().*fnRect->fnSetWidth)( nWidth );
(Frm().*fnRect->fnSetHeight)( 0 );
// #109700# LRSpace for sections
const SvxLRSpaceItem& rLRSpace = GetFmt()->GetLRSpace();
(Prt().*fnRect->fnSetLeft)( rLRSpace.GetLeft() );
(Prt().*fnRect->fnSetWidth)( nWidth - rLRSpace.GetLeft() -
rLRSpace.GetRight() );
(Prt().*fnRect->fnSetHeight)( 0 );
const SwFmtCol &rCol = GetFmt()->GetCol();
if( ( rCol.GetNumCols() > 1 || IsAnyNoteAtEnd() ) && !IsInFtn() )
{
const SwFmtCol *pOld = Lower() ? &rCol : new SwFmtCol;
ChgColumns( *pOld, rCol, IsAnyNoteAtEnd() );
if( pOld != &rCol )
delete pOld;
}
}
SwSectionFrm::~SwSectionFrm()
{
if( GetFmt() && !GetFmt()->GetDoc()->IsInDtor() )
{
SwRootFrm *pRootFrm = getRootFrm();
if( pRootFrm )
pRootFrm->RemoveFromList( this ); //swmod 071108//swmod 071225
if( IsFollow() )
{
SwSectionFrm *pMaster = FindMaster();
if( pMaster )
{
PROTOCOL( this, PROT_SECTION, ACT_DEL_FOLLOW, pMaster )
pMaster->SetFollow( GetFollow() );
// Ein Master greift sich immer den Platz bis zur Unterkante seines
// Uppers. Wenn er keinen Follow mehr hat, kann er diesen ggf. wieder
// freigeben, deshalb wird die Size des Masters invalidiert.
if( !GetFollow() )
pMaster->InvalidateSize();
}
}
else if( HasFollow() )
{
PROTOCOL( this, PROT_SECTION, ACT_DEL_MASTER, GetFollow() )
}
}
}
/*************************************************************************
|*
|* SwSectionFrm::DelEmpty()
|*
|*************************************************************************/
void SwSectionFrm::DelEmpty( sal_Bool bRemove )
{
if( IsColLocked() )
{
OSL_ENSURE( !bRemove, "Don't delete locked SectionFrms" );
return;
}
SwFrm* pUp = GetUpper();
if( pUp )
{
// #i27138#
// notify accessibility paragraphs objects about changed
// CONTENT_FLOWS_FROM/_TO relation.
// Relation CONTENT_FLOWS_FROM for current next paragraph will change
// and relation CONTENT_FLOWS_TO for current previous paragraph will change.
{
ViewShell* pViewShell( getRootFrm()->GetCurrShell() );
if ( pViewShell && pViewShell->GetLayout() &&
pViewShell->GetLayout()->IsAnyShellAccessible() )
{
pViewShell->InvalidateAccessibleParaFlowRelation(
dynamic_cast<SwTxtFrm*>(FindNextCnt( true )),
dynamic_cast<SwTxtFrm*>(FindPrevCnt( true )) );
}
}
_Cut( bRemove );
}
if( IsFollow() )
{
SwSectionFrm *pMaster = FindMaster();
pMaster->SetFollow( GetFollow() );
// Ein Master greift sich immer den Platz bis zur Unterkante seines
// Uppers. Wenn er keinen Follow mehr hat, kann er diesen ggf. wieder
// freigeben, deshalb wird die Size des Masters invalidiert.
if( !GetFollow() && !pMaster->IsColLocked() )
pMaster->InvalidateSize();
}
SetFollow(0);
if( pUp )
{
Frm().Height( 0 );
// Wenn wir sowieso sofort zerstoert werden, brauchen/duerfen wir
// uns gar nicht erst in die Liste eintragen
if( bRemove )
{ // Wenn wir bereits halbtot waren vor diesem DelEmpty, so
// stehen wir vermutlich auch in der Liste und muessen uns
// dort austragen
if( !pSection && getRootFrm() )
getRootFrm()->RemoveFromList( this );
}
else if( getRootFrm() )
getRootFrm()->InsertEmptySct( this ); //swmod 071108//swmod 071225
pSection = NULL; // damit ist allerdings eine Reanimierung quasi ausgeschlossen
}
}
/*************************************************************************
|*
|* SwSectionFrm::Cut()
|*
|*************************************************************************/
void SwSectionFrm::Cut()
{
_Cut( sal_True );
}
void SwSectionFrm::_Cut( sal_Bool bRemove )
{
OSL_ENSURE( GetUpper(), "Cut ohne Upper()." );
PROTOCOL( this, PROT_CUT, 0, GetUpper() )
SwPageFrm *pPage = FindPageFrm();
InvalidatePage( pPage );
SwFrm *pFrm = GetNext();
SwFrm* pPrepFrm = NULL;
while( pFrm && pFrm->IsSctFrm() && !((SwSectionFrm*)pFrm)->GetSection() )
pFrm = pFrm->GetNext();
if( pFrm )
{ //Der alte Nachfolger hat evtl. einen Abstand zum Vorgaenger
//berechnet der ist jetzt wo er der erste wird obsolete
pFrm->_InvalidatePrt();
pFrm->_InvalidatePos();
if( pFrm->IsSctFrm() )
pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
if ( pFrm && pFrm->IsCntntFrm() )
{
pFrm->InvalidatePage( pPage );
if( IsInFtn() && !GetIndPrev() )
pPrepFrm = pFrm;
}
}
else
{
InvalidateNextPos();
//Einer muss die Retusche uebernehmen: Vorgaenger oder Upper
if ( 0 != (pFrm = GetPrev()) )
{ pFrm->SetRetouche();
pFrm->Prepare( PREP_WIDOWS_ORPHANS );
if ( pFrm->IsCntntFrm() )
pFrm->InvalidatePage( pPage );
}
//Wenn ich der einzige FlowFrm in meinem Upper bin (war), so muss
//er die Retouche uebernehmen.
//Ausserdem kann eine Leerseite entstanden sein.
else
{ SwRootFrm *pRoot = (SwRootFrm*)pPage->GetUpper();
pRoot->SetSuperfluous();
GetUpper()->SetCompletePaint();
}
}
//Erst removen, dann Upper Shrinken.
SwLayoutFrm *pUp = GetUpper();
if( bRemove )
{
Remove();
if( pUp && !pUp->Lower() && pUp->IsFtnFrm() && !pUp->IsColLocked() &&
pUp->GetUpper() )
{
pUp->Cut();
delete pUp;
pUp = NULL;
}
}
if( pPrepFrm )
pPrepFrm->Prepare( PREP_FTN );
if ( pUp )
{
SWRECTFN( this );
SwTwips nFrmHeight = (Frm().*fnRect->fnGetHeight)();
if( nFrmHeight > 0 )
{
if( !bRemove )
{
(Frm().*fnRect->fnSetHeight)( 0 );
(Prt().*fnRect->fnSetHeight)( 0 );
}
pUp->Shrink( nFrmHeight );
}
}
}
/*************************************************************************
|*
|* SwSectionFrm::Paste()
|*
|*************************************************************************/
void SwSectionFrm::Paste( SwFrm* pParent, SwFrm* pSibling )
{
OSL_ENSURE( pParent, "Kein Parent fuer Paste." );
OSL_ENSURE( pParent->IsLayoutFrm(), "Parent ist CntntFrm." );
OSL_ENSURE( pParent != this, "Bin selbst der Parent." );
OSL_ENSURE( pSibling != this, "Bin mein eigener Nachbar." );
OSL_ENSURE( !GetPrev() && !GetUpper(),
"Bin noch irgendwo angemeldet." );
PROTOCOL( this, PROT_PASTE, 0, GetUpper() )
//In den Baum einhaengen.
SwSectionFrm* pSect = pParent->FindSctFrm();
// #156927#
// Assure that parent is not inside a table frame, which is inside the found section frame.
if ( pSect )
{
SwTabFrm* pTableFrm = pParent->FindTabFrm();
if ( pTableFrm &&
pSect->IsAnLower( pTableFrm ) )
{
pSect = 0;
}
}
SWRECTFN( pParent )
if( pSect && HasToBreak( pSect ) )
{
if( pParent->IsColBodyFrm() ) // handelt es sich um einen spaltigen Bereich
{
// Falls wir zufaellig am Ende einer Spalte stehen, muss pSibling
// auf den ersten Frame der naechsten Spalte zeigen, damit
// der Inhalt der naechsten Spalte von InsertGroup richtig in den
// neu angelegten pSect umgehaengt wird.
SwColumnFrm *pCol = (SwColumnFrm*)pParent->GetUpper();
while( !pSibling && 0 != ( pCol = (SwColumnFrm*)pCol->GetNext() ) )
pSibling = ((SwLayoutFrm*)((SwColumnFrm*)pCol)->Lower())->Lower();
if( pSibling )
{
// Schlimmer noch: alle folgenden Spalteninhalte muessen
// an die pSibling-Kette angehaengt werden, damit sie
// mitgenommen werden.
SwFrm *pTmp = pSibling;
while ( 0 != ( pCol = (SwColumnFrm*)pCol->GetNext() ) )
{
while ( pTmp->GetNext() )
pTmp = pTmp->GetNext();
SwFrm* pSave = ::SaveCntnt( pCol );
::RestoreCntnt( pSave, pSibling->GetUpper(), pTmp, true );
}
}
}
pParent = pSect;
pSect = new SwSectionFrm( *((SwSectionFrm*)pParent)->GetSection(), pParent );
// Wenn pParent in zwei Teile zerlegt wird, so muss sein Follow am
// neuen, zweiten Teil angebracht werden.
pSect->SetFollow( ((SwSectionFrm*)pParent)->GetFollow() );
((SwSectionFrm*)pParent)->SetFollow( NULL );
if( pSect->GetFollow() )
pParent->_InvalidateSize();
InsertGroupBefore( pParent, pSibling, pSect );
pSect->Init();
(pSect->*fnRect->fnMakePos)( pSect->GetUpper(), pSect->GetPrev(), sal_True);
if( !((SwLayoutFrm*)pParent)->Lower() )
{
SwSectionFrm::MoveCntntAndDelete( (SwSectionFrm*)pParent, sal_False );
pParent = this;
}
}
else
InsertGroupBefore( pParent, pSibling, NULL );
_InvalidateAll();
SwPageFrm *pPage = FindPageFrm();
InvalidatePage( pPage );
if ( pSibling )
{
pSibling->_InvalidatePos();
pSibling->_InvalidatePrt();
if ( pSibling->IsCntntFrm() )
pSibling->InvalidatePage( pPage );
}
SwTwips nFrmHeight = (Frm().*fnRect->fnGetHeight)();
if( nFrmHeight )
pParent->Grow( nFrmHeight );
if ( GetPrev() )
{
if ( !IsFollow() )
{
GetPrev()->InvalidateSize();
if ( GetPrev()->IsCntntFrm() )
GetPrev()->InvalidatePage( pPage );
}
}
}
/*************************************************************************
|*
|* SwSectionFrm::HasToBreak()
|*
|* Hier wird entschieden, ob der this-SectionFrm den uebergebenen
|* (Section)Frm aufbrechen soll oder nicht.
|* Zunaechst werden uebergeordnete Bereiche immer aufgebrochen,
|* spaeter koennte man es einstellbar machen.
|*
|*************************************************************************/
sal_Bool SwSectionFrm::HasToBreak( const SwFrm* pFrm ) const
{
if( !pFrm->IsSctFrm() )
return sal_False;
SwSectionFmt *pTmp = (SwSectionFmt*)GetFmt();
// if( !pTmp->GetSect().GetValue() )
// return sal_False;
const SwFrmFmt *pOtherFmt = ((SwSectionFrm*)pFrm)->GetFmt();
do
{
pTmp = pTmp->GetParent();
if( !pTmp )
return sal_False;
if( pTmp == pOtherFmt )
return sal_True;
} while( sal_True ); // ( pTmp->GetSect().GetValue() );
}
/*************************************************************************
|*
|* SwSectionFrm::MergeNext()
|*
|* Verschmilzt zwei SectionFrms, falls es sich um den
|* gleichen Bereich handelt.
|* Notwendig kann dies sein, wenn ein (Unter-)Bereich geloescht wird, der
|* einen anderen in zwei Teile zerlegt hatte.
|*
|*************************************************************************/
void SwSectionFrm::MergeNext( SwSectionFrm* pNxt )
{
if( !pNxt->IsJoinLocked() && GetSection() == pNxt->GetSection() )
{
PROTOCOL( this, PROT_SECTION, ACT_MERGE, pNxt )
SwFrm* pTmp = ::SaveCntnt( pNxt );
if( pTmp )
{
SwFrm* pLast = Lower();
SwLayoutFrm* pLay = this;
if( pLast )
{
while( pLast->GetNext() )
pLast = pLast->GetNext();
if( pLast->IsColumnFrm() )
{ // Spalten jetzt mit BodyFrm
pLay = (SwLayoutFrm*)((SwLayoutFrm*)pLast)->Lower();
pLast = pLay->Lower();
if( pLast )
while( pLast->GetNext() )
pLast = pLast->GetNext();
}
}
::RestoreCntnt( pTmp, pLay, pLast, true );
}
SetFollow( pNxt->GetFollow() );
pNxt->SetFollow( NULL );
pNxt->Cut();
delete pNxt;
InvalidateSize();
}
}
/*************************************************************************
|*
|* SwSectionFrm::SplitSect()
|*
|* Zerteilt einen SectionFrm in zwei Teile, der zweite Teil beginnt mit dem
|* uebergebenen Frame.
|* Benoetigt wird dies beim Einfuegen eines inneren Bereichs, weil innerhalb
|* von Rahmen oder Tabellenzellen das MoveFwd nicht den erwuenschten Effekt
|* haben kann.
|*
|*************************************************************************/
sal_Bool SwSectionFrm::SplitSect( SwFrm* pFrm, sal_Bool bApres )
{
OSL_ENSURE( pFrm, "SplitSect: Why?" );
SwFrm* pOther = bApres ? pFrm->FindNext() : pFrm->FindPrev();
if( !pOther )
return sal_False;
SwSectionFrm* pSect = pOther->FindSctFrm();
if( pSect != this )
return sal_False;
// Den Inhalt zur Seite stellen
SwFrm* pSav = ::SaveCntnt( this, bApres ? pOther : pFrm );
OSL_ENSURE( pSav, "SplitSect: What's on?" );
if( pSav ) // Robust
{ // Einen neuen SctFrm anlegen, nicht als Follow/Master
SwSectionFrm* pNew = new SwSectionFrm( *pSect->GetSection(), pSect );
pNew->InsertBehind( pSect->GetUpper(), pSect );
pNew->Init();
SWRECTFN( this )
(pNew->*fnRect->fnMakePos)( NULL, pSect, sal_True );
// OD 25.03.2003 #108339# - restore content:
// determine layout frame for restoring content after the initialization
// of the section frame. In the section initialization the columns are
// created.
{
SwLayoutFrm* pLay = pNew;
// Search for last layout frame, e.g. for columned sections.
while( pLay->Lower() && pLay->Lower()->IsLayoutFrm() )
pLay = (SwLayoutFrm*)pLay->Lower();
::RestoreCntnt( pSav, pLay, NULL, true );
}
_InvalidateSize();
if( HasFollow() )
{
pNew->SetFollow( GetFollow() );
SetFollow( NULL );
}
return sal_True;
}
return sal_False;
}
/*************************************************************************
|*
|* SwSectionFrm::MoveCntntAndDelete()
|*
|* MoveCntnt wird zur Zerstoerung eines SectionFrms wg. Aufhebung oder
|* Verstecken des Bereichs gerufen, um den Inhalt umzuhaengen.
|* Wenn der SectionFrm keinen anderen aufbrach, so wird der Inhalt in
|* den Upper bewegt. Anderfalls wird der Inhalt in den anderen SectionFrm
|* umgehaengt, dieser muss ggf. gemergt werden.
|*
|*************************************************************************/
// Wenn ein mehrspaltiger Bereich aufgehoben wird, muessen die ContentFrms
// invalidiert werden
void lcl_InvalidateInfFlags( SwFrm* pFrm, sal_Bool bInva )
{
while ( pFrm )
{
pFrm->InvalidateInfFlags();
if( bInva )
{
pFrm->_InvalidatePos();
pFrm->_InvalidateSize();
pFrm->_InvalidatePrt();
}
if( pFrm->IsLayoutFrm() )
lcl_InvalidateInfFlags( ((SwLayoutFrm*)pFrm)->GetLower(), sal_False );
pFrm = pFrm->GetNext();
}
}
//
// Works like SwCntntFrm::ImplGetNextCntntFrm, but starts with a LayoutFrm
//
SwCntntFrm* lcl_GetNextCntntFrm( const SwLayoutFrm* pLay, bool bFwd )
{
if ( bFwd )
{
if ( pLay->GetNext() && pLay->GetNext()->IsCntntFrm() )
return (SwCntntFrm*)pLay->GetNext();
}
else
{
if ( pLay->GetPrev() && pLay->GetPrev()->IsCntntFrm() )
return (SwCntntFrm*)pLay->GetPrev();
}
// #100926#
const SwFrm* pFrm = pLay;
SwCntntFrm *pCntntFrm = 0;
sal_Bool bGoingUp = sal_True;
do {
const SwFrm *p = 0;
sal_Bool bGoingFwdOrBwd = sal_False, bGoingDown = sal_False;
bGoingDown = !bGoingUp && ( 0 != ( p = pFrm->IsLayoutFrm() ? ((SwLayoutFrm*)pFrm)->Lower() : 0 ) );
if ( !bGoingDown )
{
bGoingFwdOrBwd = ( 0 != ( p = pFrm->IsFlyFrm() ?
( bFwd ? ((SwFlyFrm*)pFrm)->GetNextLink() : ((SwFlyFrm*)pFrm)->GetPrevLink() ) :
( bFwd ? pFrm->GetNext() :pFrm->GetPrev() ) ) );
if ( !bGoingFwdOrBwd )
{
bGoingUp = (0 != (p = pFrm->GetUpper() ) );
if ( !bGoingUp )
return 0;
}
}
bGoingUp = !( bGoingFwdOrBwd || bGoingDown );
if( !bFwd && bGoingDown && p )
while ( p->GetNext() )
p = p->GetNext();
pFrm = p;
} while ( 0 == (pCntntFrm = (pFrm->IsCntntFrm() ? (SwCntntFrm*)pFrm:0) ));
return pCntntFrm;
}
#define FIRSTLEAF( pLayFrm ) ( ( pLayFrm->Lower() && pLayFrm->Lower()->IsColumnFrm() )\
? pLayFrm->GetNextLayoutLeaf() \
: pLayFrm )
void SwSectionFrm::MoveCntntAndDelete( SwSectionFrm* pDel, sal_Bool bSave )
{
sal_Bool bSize = pDel->Lower() && pDel->Lower()->IsColumnFrm();
SwFrm* pPrv = pDel->GetPrev();
SwLayoutFrm* pUp = pDel->GetUpper();
// OD 27.03.2003 #i12711# - initialize local pointer variables.
SwSectionFrm* pPrvSct = NULL;
SwSectionFrm* pNxtSct = NULL;
SwSectionFmt* pParent = static_cast<SwSectionFmt*>(pDel->GetFmt())->GetParent();
if( pDel->IsInTab() && pParent )
{
SwTabFrm *pTab = pDel->FindTabFrm();
// Wenn wir innerhalb einer Tabelle liegen, koennen wir nur Bereiche
// aufgebrochen haben, die ebenfalls innerhalb liegen, nicht etwa
// einen Bereich, der die gesamte Tabelle umfasst.
if( pTab->IsInSct() && pParent == pTab->FindSctFrm()->GetFmt() )
pParent = NULL;
}
// Wenn unser Format einen Parent besitzt, so haben wir vermutlich
// einen anderen SectionFrm aufgebrochen, dies muss geprueft werden,
// dazu besorgen wir uns zunaechst den vorhergehende und den nach-
// folgenden CntntFrm, mal sehen, ob diese in SectionFrms liegen.
// OD 27.03.2003 #i12711# - check, if previous and next section belonging
// together and can be joined, *not* only if deleted section contains content.
if ( pParent )
{
SwFrm* pPrvCntnt = lcl_GetNextCntntFrm( pDel, false );
pPrvSct = pPrvCntnt ? pPrvCntnt->FindSctFrm() : NULL;
SwFrm* pNxtCntnt = lcl_GetNextCntntFrm( pDel, true );
pNxtSct = pNxtCntnt ? pNxtCntnt->FindSctFrm() : NULL;
}
else
{
pParent = NULL;
pPrvSct = pNxtSct = NULL;
}
// Jetzt wird der Inhalt beseite gestellt und der Frame zerstoert
SwFrm *pSave = bSave ? ::SaveCntnt( pDel ) : NULL;
sal_Bool bOldFtn = sal_True;
if( pSave && pUp->IsFtnFrm() )
{
bOldFtn = ((SwFtnFrm*)pUp)->IsColLocked();
((SwFtnFrm*)pUp)->ColLock();
}
pDel->DelEmpty( sal_True );
delete pDel;
if( pParent )
{ // Hier wird die geeignete Einfuegeposition gesucht
if( pNxtSct && pNxtSct->GetFmt() == pParent )
{ // Hier koennen wir uns am Anfang einfuegen
pUp = FIRSTLEAF( pNxtSct );
pPrv = NULL;
if( pPrvSct && !( pPrvSct->GetFmt() == pParent ) )
pPrvSct = NULL; // damit nicht gemergt wird
}
else if( pPrvSct && pPrvSct->GetFmt() == pParent )
{ // Wunderbar, hier koennen wir uns am Ende einfuegen
pUp = pPrvSct;
if( pUp->Lower() && pUp->Lower()->IsColumnFrm() )
{
pUp = static_cast<SwLayoutFrm*>(pUp->GetLastLower());
// Der Body der letzten Spalte
pUp = static_cast<SwLayoutFrm*>(pUp->Lower());
}
// damit hinter dem letzten eingefuegt wird
pPrv = pUp->GetLastLower();
pPrvSct = NULL; // damit nicht gemergt wird
}
else
{
if( pSave )
{ // Folgende Situationen: Vor und hinter dem zu loeschenden Bereich
// ist entweder die Bereichsgrenze des umfassenden Bereichs oder
// es schliesst ein anderer (Geschwister-)Bereich direkt an, der
// vom gleichen Parent abgeleitet ist.
// Dann gibt es (noch) keinen Teil unseres Parents, der den Inhalt
// aufnehmen kann,also bauen wir ihn uns.
pPrvSct = new SwSectionFrm( *pParent->GetSection(), pUp );
pPrvSct->InsertBehind( pUp, pPrv );
pPrvSct->Init();
SWRECTFN( pUp )
(pPrvSct->*fnRect->fnMakePos)( pUp, pPrv, sal_True );
pUp = FIRSTLEAF( pPrvSct );
pPrv = NULL;
}
pPrvSct = NULL; // damit nicht gemergt wird
}
}
// Der Inhalt wird eingefuegt..
if( pSave )
{
lcl_InvalidateInfFlags( pSave, bSize );
::RestoreCntnt( pSave, pUp, pPrv, true );
pUp->FindPageFrm()->InvalidateCntnt();
if( !bOldFtn )
((SwFtnFrm*)pUp)->ColUnlock();
}
// jetzt koennen eventuell zwei Teile des uebergeordneten Bereich verschmelzen
if( pPrvSct && !pPrvSct->IsJoinLocked() )
{
OSL_ENSURE( pNxtSct, "MoveCntnt: No Merge" );
pPrvSct->MergeNext( pNxtSct );
}
}
void SwSectionFrm::MakeAll()
{
if ( IsJoinLocked() || IsColLocked() || StackHack::IsLocked() || StackHack::Count() > 50 )
return;
if( !pSection ) // Durch DelEmpty
{
#ifdef DBG_UTIL
OSL_ENSURE( getRootFrm()->IsInDelList( this ), "SectionFrm without Section" );
#endif
if( !bValidPos )
{
if( GetUpper() )
{
SWRECTFN( GetUpper() )
(this->*fnRect->fnMakePos)( GetUpper(), GetPrev(), sal_False );
}
}
bValidSize = bValidPos = bValidPrtArea = sal_True;
return;
}
LockJoin(); //Ich lass mich nicht unterwegs vernichten.
while( GetNext() && GetNext() == GetFollow() )
{
const SwFrm* pFoll = GetFollow();
MergeNext( (SwSectionFrm*)GetNext() );
if( pFoll == GetFollow() )
break;
}
// OD 2004-03-15 #116561# - In online layout join the follows, if section
// can grow.
const ViewShell *pSh = getRootFrm()->GetCurrShell();
if( pSh && pSh->GetViewOptions()->getBrowseMode() &&
( Grow( LONG_MAX, true ) > 0 ) )
{
while( GetFollow() )
{
const SwFrm* pFoll = GetFollow();
MergeNext( GetFollow() );
if( pFoll == GetFollow() )
break;
}
}
// Ein Bereich mit Follow nimmt allen Platz bis zur Unterkante des Uppers
// in Anspruch. Bewegt er sich, so kann seine Groesse zu- oder abnehmen...
if( !bValidPos && ToMaximize( sal_False ) )
bValidSize = sal_False;
#if OSL_DEBUG_LEVEL > 1
const SwFmtCol &rCol = GetFmt()->GetCol();
(void)rCol;
#endif
SwLayoutFrm::MakeAll();
UnlockJoin();
if( pSection && IsSuperfluous() )
DelEmpty( sal_False );
}
sal_Bool SwSectionFrm::ShouldBwdMoved( SwLayoutFrm *, sal_Bool , sal_Bool & )
{
OSL_FAIL( "Hups, wo ist meine Tarnkappe?" );
return sal_False;
}
const SwSectionFmt* SwSectionFrm::_GetEndSectFmt() const
{
const SwSectionFmt *pFmt = pSection->GetFmt();
while( !pFmt->GetEndAtTxtEnd().IsAtEnd() )
{
if( pFmt->GetRegisteredIn()->ISA( SwSectionFmt ) )
pFmt = (SwSectionFmt*)pFmt->GetRegisteredIn();
else
return NULL;
}
return pFmt;
}
void lcl_FindCntntFrm( SwCntntFrm* &rpCntntFrm, SwFtnFrm* &rpFtnFrm,
SwFrm* pFrm, sal_Bool &rbChkFtn )
{
if( pFrm )
{
while( pFrm->GetNext() )
pFrm = pFrm->GetNext();
while( !rpCntntFrm && pFrm )
{
if( pFrm->IsCntntFrm() )
rpCntntFrm = (SwCntntFrm*)pFrm;
else if( pFrm->IsLayoutFrm() )
{
if( pFrm->IsFtnFrm() )
{
if( rbChkFtn )
{
rpFtnFrm = (SwFtnFrm*)pFrm;
rbChkFtn = rpFtnFrm->GetAttr()->GetFtn().IsEndNote();
}
}
else
lcl_FindCntntFrm( rpCntntFrm, rpFtnFrm,
((SwLayoutFrm*)pFrm)->Lower(), rbChkFtn );
}
pFrm = pFrm->GetPrev();
}
}
}
SwCntntFrm *SwSectionFrm::FindLastCntnt( sal_uInt8 nMode )
{
SwCntntFrm *pRet = NULL;
SwFtnFrm *pFtnFrm = NULL;
SwSectionFrm *pSect = this;
if( nMode )
{
const SwSectionFmt *pFmt = IsEndnAtEnd() ? GetEndSectFmt() :
pSection->GetFmt();
do {
while( pSect->HasFollow() )
pSect = pSect->GetFollow();
SwFrm* pTmp = pSect->FindNext();
while( pTmp && pTmp->IsSctFrm() &&
!((SwSectionFrm*)pTmp)->GetSection() )
pTmp = pTmp->FindNext();
if( pTmp && pTmp->IsSctFrm() &&
((SwSectionFrm*)pTmp)->IsDescendantFrom( pFmt ) )
pSect = (SwSectionFrm*)pTmp;
else
break;
} while( sal_True );
}
sal_Bool bFtnFound = nMode == FINDMODE_ENDNOTE;
do
{
lcl_FindCntntFrm( pRet, pFtnFrm, pSect->Lower(), bFtnFound );
if( pRet || !pSect->IsFollow() || !nMode ||
( FINDMODE_MYLAST == nMode && this == pSect ) )
break;
pSect = pSect->FindMaster();
} while( pSect );
if( ( nMode == FINDMODE_ENDNOTE ) && pFtnFrm )
pRet = pFtnFrm->ContainsCntnt();
return pRet;
}
sal_Bool SwSectionFrm::CalcMinDiff( SwTwips& rMinDiff ) const
{
if( ToMaximize( sal_True ) )
{
SWRECTFN( this )
rMinDiff = (GetUpper()->*fnRect->fnGetPrtBottom)();
rMinDiff = (Frm().*fnRect->fnBottomDist)( rMinDiff );
return sal_True;
}
return sal_False;
}
/*************************************************************************
*
* SwSectionFrm::CollectEndnotes( )
*
* CollectEndnotes looks for endnotes in the sectionfrm and his follows,
* the endnotes will cut off the layout and put into the array.
* If the first endnote is not a master-SwFtnFrm, the whole sectionfrm
* contains only endnotes and it is not necessary to collect them.
*
*************************************************************************/
SwFtnFrm* lcl_FindEndnote( SwSectionFrm* &rpSect, sal_Bool &rbEmpty,
SwLayouter *pLayouter )
{
// if rEmpty is set, the rpSect is already searched
SwSectionFrm* pSect = rbEmpty ? rpSect->GetFollow() : rpSect;
while( pSect )
{
OSL_ENSURE( (pSect->Lower() && pSect->Lower()->IsColumnFrm()) || pSect->GetUpper()->IsFtnFrm(),
"InsertEndnotes: Where's my column?" );
// i73332: Columned section in endnote
SwColumnFrm* pCol = 0;
if(pSect->Lower() && pSect->Lower()->IsColumnFrm())
pCol = (SwColumnFrm*)pSect->Lower();
while( pCol ) // check all columns
{
SwFtnContFrm* pFtnCont = pCol->FindFtnCont();
if( pFtnCont )
{
SwFtnFrm* pRet = (SwFtnFrm*)pFtnCont->Lower();
while( pRet ) // look for endnotes
{
if( pRet->GetAttr()->GetFtn().IsEndNote() )
{
if( pRet->GetMaster() )
{
if( pLayouter )
pLayouter->CollectEndnote( pRet );
else
return 0;
}
else
return pRet; // Found
}
pRet = (SwFtnFrm*)pRet->GetNext();
}
}
pCol = (SwColumnFrm*)pCol->GetNext();
}
rpSect = pSect;
pSect = pLayouter ? pSect->GetFollow() : NULL;
rbEmpty = sal_True;
}
return NULL;
}
void lcl_ColumnRefresh( SwSectionFrm* pSect, sal_Bool bFollow )
{
while( pSect )
{
sal_Bool bOldLock = pSect->IsColLocked();
pSect->ColLock();
if( pSect->Lower() && pSect->Lower()->IsColumnFrm() )
{
SwColumnFrm *pCol = (SwColumnFrm*)pSect->Lower();
do
{ pCol->_InvalidateSize();
pCol->_InvalidatePos();
((SwLayoutFrm*)pCol)->Lower()->_InvalidateSize();
pCol->Calc(); // calculation of column and
((SwLayoutFrm*)pCol)->Lower()->Calc(); // body
pCol = (SwColumnFrm*)pCol->GetNext();
} while ( pCol );
}
if( !bOldLock )
pSect->ColUnlock();
if( bFollow )
pSect = pSect->GetFollow();
else
pSect = NULL;
}
}
void SwSectionFrm::CollectEndnotes( SwLayouter* pLayouter )
{
OSL_ENSURE( IsColLocked(), "CollectEndnotes: You love the risk?" );
// i73332: Section in footnode does not have columns!
OSL_ENSURE( (Lower() && Lower()->IsColumnFrm()) || GetUpper()->IsFtnFrm(), "Where's my column?" );
SwSectionFrm* pSect = this;
SwFtnFrm* pFtn;
sal_Bool bEmpty = sal_False;
// pSect is the last sectionfrm without endnotes or the this-pointer
// the first sectionfrm with endnotes may be destroyed, when the endnotes
// is cutted
while( 0 != (pFtn = lcl_FindEndnote( pSect, bEmpty, pLayouter )) )
pLayouter->CollectEndnote( pFtn );
if( pLayouter->HasEndnotes() )
lcl_ColumnRefresh( this, sal_True );
}
/*************************************************************************
|*
|* SwSectionFrm::_CheckClipping( sal_Bool bGrow, sal_Bool bMaximize )
|*
|* Beschreibung: Passt die Groesse an die Umgebung an.
|* Wer einen Follow oder Fussnoten besitzt, soll bis zur Unterkante
|* des Uppers gehen (bMaximize).
|* Niemand darf ueber den Upper hinausgehen, ggf. darf man versuchen (bGrow)
|* seinen Upper zu growen.
|* Wenn die Groesse veraendert werden musste, wird der Inhalt kalkuliert.
|*
|*************************************************************************/
/// OD 18.09.2002 #100522#
/// perform calculation of content, only if height has changed.
void SwSectionFrm::_CheckClipping( sal_Bool bGrow, sal_Bool bMaximize )
{
SWRECTFN( this )
long nDiff;
SwTwips nDeadLine = (GetUpper()->*fnRect->fnGetPrtBottom)();
if( bGrow && ( !IsInFly() || !GetUpper()->IsColBodyFrm() ||
!FindFlyFrm()->IsLocked() ) )
{
nDiff = -(Frm().*fnRect->fnBottomDist)( nDeadLine );
if( !bMaximize )
nDiff += Undersize();
if( nDiff > 0 )
{
long nAdd = GetUpper()->Grow( nDiff );
if( bVert && !bRev )
nDeadLine -= nAdd;
else
nDeadLine += nAdd;
}
}
nDiff = -(Frm().*fnRect->fnBottomDist)( nDeadLine );
SetUndersized( !bMaximize && nDiff >= 0 );
const bool bCalc = ( IsUndersized() || bMaximize ) &&
( nDiff ||
(Prt().*fnRect->fnGetTop)() > (Frm().*fnRect->fnGetHeight)() );
// OD 03.11.2003 #i19737# - introduce local variable <bExtraCalc> to indicate
// that a calculation has to be done beside the value of <bCalc>.
bool bExtraCalc = false;
if( !bCalc && !bGrow && IsAnyNoteAtEnd() && !IsInFtn() )
{
SwSectionFrm *pSect = this;
sal_Bool bEmpty = sal_False;
SwLayoutFrm* pFtn = IsEndnAtEnd() ?
lcl_FindEndnote( pSect, bEmpty, NULL ) : NULL;
if( pFtn )
{
pFtn = pFtn->FindFtnBossFrm();
SwFrm* pTmp = FindLastCntnt( FINDMODE_LASTCNT );
// OD 08.11.2002 #104840# - use <SwLayoutFrm::IsBefore(..)>
if ( pTmp && pFtn->IsBefore( pTmp->FindFtnBossFrm() ) )
bExtraCalc = true;
}
else if( GetFollow() && !GetFollow()->ContainsAny() )
bExtraCalc = true;
}
if ( bCalc || bExtraCalc )
{
nDiff = (*fnRect->fnYDiff)( nDeadLine, (Frm().*fnRect->fnGetTop)() );
if( nDiff < 0 )
{
nDiff = 0;
nDeadLine = (Frm().*fnRect->fnGetTop)();
}
const Size aOldSz( Prt().SSize() );
long nTop = (this->*fnRect->fnGetTopMargin)();
(Frm().*fnRect->fnSetBottom)( nDeadLine );
nDiff = (Frm().*fnRect->fnGetHeight)();
if( nTop > nDiff )
nTop = nDiff;
(this->*fnRect->fnSetYMargins)( nTop, 0 );
// OD 18.09.2002 #100522#
// Determine, if height has changed.
// Note: In vertical layout the height equals the width value.
bool bHeightChanged = bVert ?
(aOldSz.Width() != Prt().Width()) :
(aOldSz.Height() != Prt().Height());
// Wir haben zu guter Letzt noch einmal die Hoehe geaendert,
// dann wird das innere Layout (Columns) kalkuliert und
// der Inhalt ebenfalls.
// OD 18.09.2002 #100522#
// calculate content, only if height has changed.
// OD 03.11.2003 #i19737# - restriction of content calculation too strong.
// If an endnote has an incorrect position or a follow section contains
// no content except footnotes/endnotes, the content has also been calculated.
if ( ( bHeightChanged || bExtraCalc ) && Lower() )
{
if( Lower()->IsColumnFrm() )
{
lcl_ColumnRefresh( this, sal_False );
::CalcCntnt( this );
}
else
{
ChgLowersProp( aOldSz );
if( !bMaximize && !IsCntntLocked() )
::CalcCntnt( this );
}
}
}
}
void SwSectionFrm::SimpleFormat()
{
if ( IsJoinLocked() || IsColLocked() )
return;
// OSL_ENSURE( pFollow, "SimpleFormat: Follow required" );
LockJoin();
SWRECTFN( this )
if( GetPrev() || GetUpper() )
{
//
// assure notifications on position changes.
const SwLayNotify aNotify( this );
(this->*fnRect->fnMakePos)( GetUpper(), GetPrev(), sal_False );
bValidPos = sal_True;
}
SwTwips nDeadLine = (GetUpper()->*fnRect->fnGetPrtBottom)();
// OD 22.10.2002 #97265# - call always method <lcl_ColumnRefresh(..)>, in
// order to get calculated lowers, not only if there space left in its upper.
if( (Frm().*fnRect->fnBottomDist)( nDeadLine ) >= 0 )
{
(Frm().*fnRect->fnSetBottom)( nDeadLine );
long nHeight = (Frm().*fnRect->fnGetHeight)();
long nTop = CalcUpperSpace();
if( nTop > nHeight )
nTop = nHeight;
(this->*fnRect->fnSetYMargins)( nTop, 0 );
}
lcl_ColumnRefresh( this, sal_False );
UnlockJoin();
}
// #i40147# - helper class to perform extra section format
// to position anchored objects and to keep the position of whose objects locked.
class ExtraFormatToPositionObjs
{
private:
SwSectionFrm* mpSectFrm;
bool mbExtraFormatPerformed;
public:
ExtraFormatToPositionObjs( SwSectionFrm& _rSectFrm)
: mpSectFrm( &_rSectFrm ),
mbExtraFormatPerformed( false )
{}
~ExtraFormatToPositionObjs()
{
if ( mbExtraFormatPerformed )
{
// release keep locked position of lower floating screen objects
SwPageFrm* pPageFrm = mpSectFrm->FindPageFrm();
SwSortedObjs* pObjs = pPageFrm ? pPageFrm->GetSortedObjs() : 0L;
if ( pObjs )
{
sal_uInt32 i = 0;
for ( i = 0; i < pObjs->Count(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
if ( mpSectFrm->IsAnLower( pAnchoredObj->GetAnchorFrm() ) )
{
pAnchoredObj->SetKeepPosLocked( false );
}
}
}
}
}
// #i81555#
void InitObjs( SwFrm& rFrm )
{
SwSortedObjs* pObjs = rFrm.GetDrawObjs();
if ( pObjs )
{
sal_uInt32 i = 0;
for ( i = 0; i < pObjs->Count(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
pAnchoredObj->UnlockPosition();
pAnchoredObj->SetClearedEnvironment( false );
}
}
SwLayoutFrm* pLayoutFrm = dynamic_cast<SwLayoutFrm*>(&rFrm);
if ( pLayoutFrm != 0 )
{
SwFrm* pLowerFrm = pLayoutFrm->GetLower();
while ( pLowerFrm != 0 )
{
InitObjs( *pLowerFrm );
pLowerFrm = pLowerFrm->GetNext();
}
}
}
void FormatSectionToPositionObjs()
{
// perform extra format for multi-columned section.
if ( mpSectFrm->Lower() && mpSectFrm->Lower()->IsColumnFrm() &&
mpSectFrm->Lower()->GetNext() )
{
// grow section till bottom of printing area of upper frame
SWRECTFN( mpSectFrm );
SwTwips nTopMargin = (mpSectFrm->*fnRect->fnGetTopMargin)();
Size aOldSectPrtSize( mpSectFrm->Prt().SSize() );
SwTwips nDiff = (mpSectFrm->Frm().*fnRect->fnBottomDist)(
(mpSectFrm->GetUpper()->*fnRect->fnGetPrtBottom)() );
(mpSectFrm->Frm().*fnRect->fnAddBottom)( nDiff );
(mpSectFrm->*fnRect->fnSetYMargins)( nTopMargin, 0 );
// #i59789#
// suppress formatting, if printing area of section is too narrow
if ( (mpSectFrm->Prt().*fnRect->fnGetHeight)() <= 0 )
{
return;
}
mpSectFrm->ChgLowersProp( aOldSectPrtSize );
// format column frames and its body and footnote container
SwColumnFrm* pColFrm = static_cast<SwColumnFrm*>(mpSectFrm->Lower());
while ( pColFrm )
{
pColFrm->Calc();
pColFrm->Lower()->Calc();
if ( pColFrm->Lower()->GetNext() )
{
pColFrm->Lower()->GetNext()->Calc();
}
pColFrm = static_cast<SwColumnFrm*>(pColFrm->GetNext());
}
// unlock position of lower floating screen objects for the extra format
// #i81555#
// Section frame can already have changed the page and its content
// can still be on the former page.
// Thus, initialize objects via lower-relationship
InitObjs( *mpSectFrm );
// format content - first with collecting its foot-/endnotes before content
// format, second without collecting its foot-/endnotes.
::CalcCntnt( mpSectFrm );
::CalcCntnt( mpSectFrm, true );
// keep locked position of lower floating screen objects
SwPageFrm* pPageFrm = mpSectFrm->FindPageFrm();
SwSortedObjs* pObjs = pPageFrm ? pPageFrm->GetSortedObjs() : 0L;
if ( pObjs )
{
sal_uInt32 i = 0;
for ( i = 0; i < pObjs->Count(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
if ( mpSectFrm->IsAnLower( pAnchoredObj->GetAnchorFrm() ) )
{
pAnchoredObj->SetKeepPosLocked( true );
}
}
}
mbExtraFormatPerformed = true;
}
}
};
/*************************************************************************
|*
|* SwSectionFrm::Format()
|*
|* Beschreibung: "Formatiert" den Frame; Frm und PrtArea.
|*
|*************************************************************************/
void SwSectionFrm::Format( const SwBorderAttrs *pAttr )
{
if( !pSection ) // Durch DelEmpty
{
#ifdef DBG_UTIL
OSL_ENSURE( getRootFrm()->IsInDelList( this ), "SectionFrm without Section" );
#endif
bValidSize = bValidPos = bValidPrtArea = sal_True;
return;
}
SWRECTFN( this )
if ( !bValidPrtArea )
{
PROTOCOL( this, PROT_PRTAREA, 0, 0 )
bValidPrtArea = sal_True;
SwTwips nUpper = CalcUpperSpace();
// #109700# LRSpace for sections
const SvxLRSpaceItem& rLRSpace = GetFmt()->GetLRSpace();
(this->*fnRect->fnSetXMargins)( rLRSpace.GetLeft(), rLRSpace.GetRight() );
if( nUpper != (this->*fnRect->fnGetTopMargin)() )
{
bValidSize = sal_False;
SwFrm* pOwn = ContainsAny();
if( pOwn )
pOwn->_InvalidatePos();
}
(this->*fnRect->fnSetYMargins)( nUpper, 0 );
}
if ( !bValidSize )
{
PROTOCOL_ENTER( this, PROT_SIZE, 0, 0 )
const long nOldHeight = (Frm().*fnRect->fnGetHeight)();
sal_Bool bOldLock = IsColLocked();
ColLock();
bValidSize = sal_True;
//die Groesse wird nur dann vom Inhalt bestimmt, wenn der SectFrm
//keinen Follow hat. Anderfalls fuellt er immer den Upper bis
//zur Unterkante aus. Fuer den Textfluss ist nicht er, sondern sein
//Inhalt selbst verantwortlich.
sal_Bool bMaximize = ToMaximize( sal_False );
// OD 2004-05-17 #i28701# - If the wrapping style has to be considered
// on object positioning, an extra formatting has to be performed
// to determine the correct positions the floating screen objects.
// #i40147#
// use new helper class <ExtraFormatToPositionObjs>.
// This class additionally keep the locked position of the objects
// and releases this position lock keeping on destruction.
ExtraFormatToPositionObjs aExtraFormatToPosObjs( *this );
if ( !bMaximize &&
GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) &&
!GetFmt()->GetBalancedColumns().GetValue() )
{
aExtraFormatToPosObjs.FormatSectionToPositionObjs();
}
// Column widths have to be adjusted before calling _CheckClipping.
// _CheckClipping can cause the formatting of the lower frames
// which still have a width of 0.
const sal_Bool bHasColumns = Lower() && Lower()->IsColumnFrm();
if ( bHasColumns && Lower()->GetNext() )
AdjustColumns( 0, sal_False );
if( GetUpper() )
{
long nWidth = (GetUpper()->Prt().*fnRect->fnGetWidth)();
(aFrm.*fnRect->fnSetWidth)( nWidth );
// #109700# LRSpace for sections
const SvxLRSpaceItem& rLRSpace = GetFmt()->GetLRSpace();
(aPrt.*fnRect->fnSetWidth)( nWidth - rLRSpace.GetLeft() -
rLRSpace.GetRight() );
// OD 15.10.2002 #103517# - allow grow in online layout
// Thus, set <..IsBrowseMode()> as parameter <bGrow> on calling
// method <_CheckClipping(..)>.
const ViewShell *pSh = getRootFrm()->GetCurrShell();
_CheckClipping( pSh && pSh->GetViewOptions()->getBrowseMode(), bMaximize );
bMaximize = ToMaximize( sal_False );
bValidSize = sal_True;
}
//Breite der Spalten pruefen und ggf. einstellen.
if ( bHasColumns && ! Lower()->GetNext() && bMaximize )
((SwColumnFrm*)Lower())->Lower()->Calc();
if ( !bMaximize )
{
SwTwips nRemaining = (this->*fnRect->fnGetTopMargin)();
SwFrm *pFrm = pLower;
if( pFrm )
{
if( pFrm->IsColumnFrm() && pFrm->GetNext() )
{
// #i61435#
// suppress formatting, if upper frame has height <= 0
if ( (GetUpper()->Frm().*fnRect->fnGetHeight)() > 0 )
{
FormatWidthCols( *pAttr, nRemaining, MINLAY );
}
// #126020# - adjust check for empty section
// #130797# - correct fix #126020#
while( HasFollow() && !GetFollow()->ContainsCntnt() &&
!GetFollow()->ContainsAny( true ) )
{
SwFrm* pOld = GetFollow();
GetFollow()->DelEmpty( sal_False );
if( pOld == GetFollow() )
break;
}
bMaximize = ToMaximize( sal_False );
nRemaining += (pFrm->Frm().*fnRect->fnGetHeight)();
}
else
{
if( pFrm->IsColumnFrm() )
{
pFrm->Calc();
pFrm = ((SwColumnFrm*)pFrm)->Lower();
pFrm->Calc();
pFrm = ((SwLayoutFrm*)pFrm)->Lower();
CalcFtnCntnt();
}
// Wenn wir in einem spaltigen Rahmen stehen und dieser
// gerade im FormatWidthCols ein CalcCntnt ruft, muss
// unser Inhalt ggf. kalkuliert werden.
if( pFrm && !pFrm->IsValid() && IsInFly() &&
FindFlyFrm()->IsColLocked() )
::CalcCntnt( this );
nRemaining += InnerHeight();
bMaximize = HasFollow();
}
}
SwTwips nDiff = (Frm().*fnRect->fnGetHeight)() - nRemaining;
if( nDiff < 0)
{
SwTwips nDeadLine = (GetUpper()->*fnRect->fnGetPrtBottom)();
{
long nBottom = (Frm().*fnRect->fnGetBottom)();
nBottom = (*fnRect->fnYInc)( nBottom, -nDiff );
long nTmpDiff = (*fnRect->fnYDiff)( nBottom, nDeadLine );
if( nTmpDiff > 0 )
{
nTmpDiff = GetUpper()->Grow( nTmpDiff, sal_True );
nDeadLine = (*fnRect->fnYInc)( nDeadLine, nTmpDiff );
nTmpDiff = (*fnRect->fnYDiff)( nBottom, nDeadLine );
if( nTmpDiff > 0 )
nDiff += nTmpDiff;
if( nDiff > 0 )
nDiff = 0;
}
}
}
if( nDiff )
{
long nTmp = nRemaining - (Frm().*fnRect->fnGetHeight)();
long nTop = (this->*fnRect->fnGetTopMargin)();
(Frm().*fnRect->fnAddBottom)( nTmp );
(this->*fnRect->fnSetYMargins)( nTop, 0 );
InvalidateNextPos();
if( pLower && ( !pLower->IsColumnFrm() || !pLower->GetNext() ) )
{
// Wenn ein einspaltiger Bereich gerade den Platz geschaffen
// hat, den sich die "undersized" Absaetze gewuenscht haben,
// muessen diese invalidiert und kalkuliert werden, damit
// sie diesen ausfuellen.
pFrm = pLower;
if( pFrm->IsColumnFrm() )
{
pFrm->_InvalidateSize();
pFrm->_InvalidatePos();
pFrm->Calc();
pFrm = ((SwColumnFrm*)pFrm)->Lower();
pFrm->Calc();
pFrm = ((SwLayoutFrm*)pFrm)->Lower();
CalcFtnCntnt();
}
sal_Bool bUnderSz = sal_False;
while( pFrm )
{
if( pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsUndersized() )
{
pFrm->Prepare( PREP_ADJUST_FRM );
bUnderSz = sal_True;
}
pFrm = pFrm->GetNext();
}
if( bUnderSz && !IsCntntLocked() )
::CalcCntnt( this );
}
}
}
//Unterkante des Uppers nicht ueberschreiten. Fuer Sections mit
//Follows die Unterkante auch nicht unterschreiten.
if ( GetUpper() )
_CheckClipping( sal_True, bMaximize );
if( !bOldLock )
ColUnlock();
long nDiff = nOldHeight - (Frm().*fnRect->fnGetHeight)();
if( nDiff > 0 )
{
if( !GetNext() )
SetRetouche(); // Dann muessen wir die Retusche selbst uebernehmen
if( GetUpper() && !GetUpper()->IsFooterFrm() )
GetUpper()->Shrink( nDiff );
}
if( IsUndersized() )
bValidPrtArea = sal_True;
}
}
/*************************************************************************
|*
|* SwFrm::GetNextSctLeaf()
|*
|* Beschreibung Liefert das naechste Layoutblatt in das der Frame
|* gemoved werden kann.
|* Neue Seiten werden nur dann erzeugt, wenn der Parameter sal_True ist.
|*
|*************************************************************************/
SwLayoutFrm *SwFrm::GetNextSctLeaf( MakePageType eMakePage )
{
//Achtung: Geschachtelte Bereiche werden zur Zeit nicht unterstuetzt.
PROTOCOL_ENTER( this, PROT_LEAF, ACT_NEXT_SECT, GetUpper()->FindSctFrm() )
// Abkuerzungen fuer spaltige Bereiche, wenn wir noch nicht in der letzten Spalte sind.
// Koennen wir in die naechste Spalte des Bereichs rutschen?
if( IsColBodyFrm() && GetUpper()->GetNext() )
return (SwLayoutFrm*)((SwLayoutFrm*)GetUpper()->GetNext())->Lower();
if( GetUpper()->IsColBodyFrm() && GetUpper()->GetUpper()->GetNext() )
return (SwLayoutFrm*)((SwLayoutFrm*)GetUpper()->GetUpper()->GetNext())->Lower();
// Innerhalb von Bereichen in Tabellen oder Bereichen in Kopf/Fusszeilen kann
// nur ein Spaltenwechsel erfolgen, eine der oberen Abkuerzungen haette zuschlagen muessen
if( GetUpper()->IsInTab() || FindFooterOrHeader() )
return 0;
//MA 03. Feb. 99: Warum GetUpper()? Das knallt mit Buch.sgl weil im
//FlyAtCnt::MakeFlyPos ein Orient der SectionFrm ist und auf diesen ein
//GetLeaf gerufen wird.
// SwSectionFrm *pSect = GetUpper()->FindSctFrm();
SwSectionFrm *pSect = FindSctFrm();
sal_Bool bWrongPage = sal_False;
OSL_ENSURE( pSect, "GetNextSctLeaf: Missing SectionFrm" );
// Hier eine Abkuerzung fuer Bereiche mit Follows,
// dieser kann akzeptiert werden, wenn keine Spalten oder Seiten (ausser Dummyseiten)
// dazwischen liegen.
// Bei verketteten Rahmen und ind Fussnoten wuerde die Abkuerzung noch aufwendiger
if( pSect->HasFollow() && pSect->IsInDocBody() )
{
if( pSect->GetFollow() == pSect->GetNext() )
{
SwPageFrm *pPg = pSect->GetFollow()->FindPageFrm();
if( WrongPageDesc( pPg ) )
bWrongPage = sal_True;
else
return FIRSTLEAF( pSect->GetFollow() );
}
else
{
SwFrm* pTmp;
if( !pSect->GetUpper()->IsColBodyFrm() ||
0 == ( pTmp = pSect->GetUpper()->GetUpper()->GetNext() ) )
pTmp = pSect->FindPageFrm()->GetNext();
if( pTmp ) // ist jetzt die naechste Spalte oder Seite
{
SwFrm* pTmpX = pTmp;
if( pTmp->IsPageFrm() && ((SwPageFrm*)pTmp)->IsEmptyPage() )
pTmp = pTmp->GetNext(); // Dummyseiten ueberspringen
SwFrm *pUp = pSect->GetFollow()->GetUpper();
// pUp wird die Spalte, wenn der Follow in einer "nicht ersten" Spalte
// liegt, ansonsten die Seite:
if( !pUp->IsColBodyFrm() ||
!( pUp = pUp->GetUpper() )->GetPrev() )
pUp = pUp->FindPageFrm();
// Jetzt muessen pUp und pTmp die gleiche Seite/Spalte sein,
// sonst liegen Seiten oder Spalten zwischen Master und Follow.
if( pUp == pTmp || pUp->GetNext() == pTmpX )
{
SwPageFrm* pNxtPg = pUp->IsPageFrm() ?
(SwPageFrm*)pUp : pUp->FindPageFrm();
if( WrongPageDesc( pNxtPg ) )
bWrongPage = sal_True;
else
return FIRSTLEAF( pSect->GetFollow() );
}
}
}
}
// Immer im gleichen Bereich landen: Body wieder in Body etc.
const sal_Bool bBody = IsInDocBody();
const sal_Bool bFtnPage = FindPageFrm()->IsFtnPage();
SwLayoutFrm *pLayLeaf;
// Eine Abkuerzung fuer TabFrms, damit nicht alle Zellen abgehuehnert werden
if( bWrongPage )
pLayLeaf = 0;
else if( IsTabFrm() )
{
SwCntntFrm* pTmpCnt = ((SwTabFrm*)this)->FindLastCntnt();
pLayLeaf = pTmpCnt ? pTmpCnt->GetUpper() : 0;
}
else
{
pLayLeaf = GetNextLayoutLeaf();
if( IsColumnFrm() )
{
while( pLayLeaf && ((SwColumnFrm*)this)->IsAnLower( pLayLeaf ) )
pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
}
}
SwLayoutFrm *pOldLayLeaf = 0; //Damit bei neu erzeugten Seiten
//nicht wieder vom Anfang gesucht
//wird.
while( sal_True )
{
if( pLayLeaf )
{
// Ein Layoutblatt wurde gefunden, mal sehen, ob er mich aufnehmen kann,
// ob hier ein weiterer SectionFrm eingefuegt werden kann
// oder ob wir weitersuchen muessen.
SwPageFrm* pNxtPg = pLayLeaf->FindPageFrm();
if ( !bFtnPage && pNxtPg->IsFtnPage() )
{ //Wenn ich bei den Endnotenseiten angelangt bin hat sichs.
pLayLeaf = 0;
continue;
}
// Einmal InBody, immer InBody, nicht in Tabellen hinein
// und nicht in fremde Bereiche hinein
if ( (bBody && !pLayLeaf->IsInDocBody()) ||
(IsInFtn() != pLayLeaf->IsInFtn() ) ||
pLayLeaf->IsInTab() ||
( pLayLeaf->IsInSct() && ( !pSect->HasFollow()
|| pSect->GetFollow() != pLayLeaf->FindSctFrm() ) ) )
{
//Er will mich nicht; neuer Versuch, neues Glueck
pOldLayLeaf = pLayLeaf;
pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
continue;
}
if( WrongPageDesc( pNxtPg ) )
{
if( bWrongPage )
break; // there's a column between me and my right page
pLayLeaf = 0;
bWrongPage = sal_True;
pOldLayLeaf = 0;
continue;
}
}
//Es gibt keinen passenden weiteren LayoutFrm, also muss eine
//neue Seite her, allerdings nuetzen uns innerhalb eines Rahmens
//neue Seiten nichts.
else if( !pSect->IsInFly() &&
( eMakePage == MAKEPAGE_APPEND || eMakePage == MAKEPAGE_INSERT ) )
{
InsertPage(pOldLayLeaf ? pOldLayLeaf->FindPageFrm() : FindPageFrm(),
sal_False );
//und nochmal das ganze
pLayLeaf = pOldLayLeaf ? pOldLayLeaf : GetNextLayoutLeaf();
continue;
}
break;
}
if( pLayLeaf )
{
// Das passende Layoutblatt haben wir gefunden, wenn es dort bereits einen
// Follow unseres Bereichs gibt, nehmen wir dessen erstes Layoutblatt,
// andernfalls wird es Zeit, einen Bereichsfollow zu erzeugen
SwSectionFrm* pNew;
//Dies kann entfallen, wenn bei existierenden Follows bereits abgekuerzt wurde
SwFrm* pFirst = pLayLeaf->Lower();
// Auch hier muessen zum Loeschen angemeldete SectionFrms ignoriert werden
while( pFirst && pFirst->IsSctFrm() && !((SwSectionFrm*)pFirst)->GetSection() )
pFirst = pFirst->GetNext();
if( pFirst && pFirst->IsSctFrm() && pSect->GetFollow() == pFirst )
pNew = pSect->GetFollow();
else if( MAKEPAGE_NOSECTION == eMakePage )
return pLayLeaf;
else
{
pNew = new SwSectionFrm( *pSect, sal_False );
pNew->InsertBefore( pLayLeaf, pLayLeaf->Lower() );
pNew->Init();
SWRECTFN( pNew )
(pNew->*fnRect->fnMakePos)( pLayLeaf, NULL, sal_True );
// Wenn unser Bereichsframe einen Nachfolger hat, so muss dieser
// umgehaengt werden hinter den neuen Follow der Bereichsframes.
SwFrm* pTmp = pSect->GetNext();
if( pTmp && pTmp != pSect->GetFollow() )
{
SwFlowFrm* pNxt;
SwCntntFrm* pNxtCntnt = NULL;
if( pTmp->IsCntntFrm() )
{
pNxt = (SwCntntFrm*)pTmp;
pNxtCntnt = (SwCntntFrm*)pTmp;
}
else
{
pNxtCntnt = ((SwLayoutFrm*)pTmp)->ContainsCntnt();
if( pTmp->IsSctFrm() )
pNxt = (SwSectionFrm*)pTmp;
else
{
OSL_ENSURE( pTmp->IsTabFrm(), "GetNextSctLeaf: Wrong Type" );
pNxt = (SwTabFrm*)pTmp;
}
while( !pNxtCntnt && 0 != ( pTmp = pTmp->GetNext() ) )
{
if( pTmp->IsCntntFrm() )
pNxtCntnt = (SwCntntFrm*)pTmp;
else
pNxtCntnt = ((SwLayoutFrm*)pTmp)->ContainsCntnt();
}
}
if( pNxtCntnt )
{
SwFtnBossFrm* pOldBoss = pSect->FindFtnBossFrm( sal_True );
if( pOldBoss == pNxtCntnt->FindFtnBossFrm( sal_True ) )
{
SwSaveFtnHeight aHeight( pOldBoss,
pOldBoss->Frm().Top() + pOldBoss->Frm().Height() );
pSect->GetUpper()->MoveLowerFtns( pNxtCntnt, pOldBoss,
pLayLeaf->FindFtnBossFrm( sal_True ), sal_False );
}
}
((SwFlowFrm*)pNxt)->MoveSubTree( pLayLeaf, pNew->GetNext() );
}
if( pNew->GetFollow() )
pNew->SimpleFormat();
}
// Das gesuchte Layoutblatt ist jetzt das erste des ermittelten SctFrms:
pLayLeaf = FIRSTLEAF( pNew );
}
return pLayLeaf;
}
/*************************************************************************
|*
|* SwFrm::GetPrevSctLeaf()
|*
|* Beschreibung Liefert das vorhergehende LayoutBlatt in das der
|* Frame gemoved werden kann.
|*
|*************************************************************************/
SwLayoutFrm *SwFrm::GetPrevSctLeaf( MakePageType )
{
PROTOCOL_ENTER( this, PROT_LEAF, ACT_PREV_SECT, GetUpper()->FindSctFrm() )
SwLayoutFrm* pCol;
// ColumnFrm beinhalten jetzt stets einen BodyFrm
if( IsColBodyFrm() )
pCol = GetUpper();
else if( GetUpper()->IsColBodyFrm() )
pCol = GetUpper()->GetUpper();
else
pCol = NULL;
sal_Bool bJump = sal_False;
if( pCol )
{
if( pCol->GetPrev() )
{
do
{
pCol = (SwLayoutFrm*)pCol->GetPrev();
// Gibt es dort Inhalt?
if( ((SwLayoutFrm*)pCol->Lower())->Lower() )
{
if( bJump ) // Haben wir eine leere Spalte uebersprungen?
SwFlowFrm::SetMoveBwdJump( sal_True );
return (SwLayoutFrm*)pCol->Lower(); // Der Spaltenbody
}
bJump = sal_True;
} while( pCol->GetPrev() );
// Hier landen wir, wenn alle Spalten leer sind,
// pCol ist jetzt die erste Spalte, wir brauchen aber den Body:
pCol = (SwLayoutFrm*)pCol->Lower();
}
else
pCol = NULL;
}
if( bJump ) // Haben wir eine leere Spalte uebersprungen?
SwFlowFrm::SetMoveBwdJump( sal_True );
// Innerhalb von Bereichen in Tabellen oder Bereichen in Kopf/Fusszeilen kann
// nur ein Spaltenwechsel erfolgen, eine der oberen Abkuerzungen haette
// zuschlagen muessen, ebenso wenn der Bereich einen pPrev hat.
// Jetzt ziehen wir sogar eine leere Spalte in Betracht...
OSL_ENSURE( FindSctFrm(), "GetNextSctLeaf: Missing SectionFrm" );
if( ( IsInTab() && !IsTabFrm() ) || FindFooterOrHeader() )
return pCol;
// === IMPORTANT ===
// Precondition, which needs to be hold, is that the <this> frame can be
// inside a table, but then the found section frame <pSect> is also inside
// this table.
SwSectionFrm *pSect = FindSctFrm();
// #i95698#
// A table cell containing directly a section does not break - see lcl_FindSectionsInRow(..)
// Thus, a table inside a section, which is inside another table can only
// flow backward in the columns of its section.
// Note: The table cell, which contains the section, can not have a master table cell.
if ( IsTabFrm() && pSect->IsInTab() )
{
return pCol;
}
{
SwFrm *pPrv;
if( 0 != ( pPrv = pSect->GetIndPrev() ) )
{
// Herumlungernde, halbtote SectionFrms sollen uns nicht beirren
while( pPrv && pPrv->IsSctFrm() && !((SwSectionFrm*)pPrv)->GetSection() )
pPrv = pPrv->GetPrev();
if( pPrv )
return pCol;
}
}
const sal_Bool bBody = IsInDocBody();
const sal_Bool bFly = IsInFly();
SwLayoutFrm *pLayLeaf = GetPrevLayoutLeaf();
SwLayoutFrm *pPrevLeaf = 0;
while ( pLayLeaf )
{
//In Tabellen oder Bereiche geht's niemals hinein.
if ( pLayLeaf->IsInTab() || pLayLeaf->IsInSct() )
{
pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
}
else if ( bBody && pLayLeaf->IsInDocBody() )
{
// If there is a pLayLeaf has a lower pLayLeaf is the frame we are looking for.
// Exception: pLayLeaf->Lower() is a zombie section frame
const SwFrm* pTmp = pLayLeaf->Lower();
// OD 11.04.2003 #108824# - consider, that the zombie section frame
// can have frame below it in the found layout leaf.
// Thus, skipping zombie section frame, if possible.
while ( pTmp && pTmp->IsSctFrm() &&
!( static_cast<const SwSectionFrm*>(pTmp)->GetSection() ) &&
pTmp->GetNext()
)
{
pTmp = pTmp->GetNext();
}
if ( pTmp &&
( !pTmp->IsSctFrm() ||
( static_cast<const SwSectionFrm*>(pTmp)->GetSection() )
)
)
{
break;
}
pPrevLeaf = pLayLeaf;
pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
if ( pLayLeaf )
SwFlowFrm::SetMoveBwdJump( sal_True );
}
else if ( bFly )
break; //Cntnts in Flys sollte jedes Layout-Blatt recht sein. Warum?
else
pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
}
if( !pLayLeaf )
{
if( !pPrevLeaf )
return pCol;
pLayLeaf = pPrevLeaf;
}
SwSectionFrm* pNew = NULL;
// Zunaechst einmal an das Ende des Layoutblatts gehen
SwFrm *pTmp = pLayLeaf->Lower();
if( pTmp )
{
while( pTmp->GetNext() )
pTmp = pTmp->GetNext();
if( pTmp->IsSctFrm() )
{
// Halbtote stoeren hier nur...
while( !((SwSectionFrm*)pTmp)->GetSection() && pTmp->GetPrev() &&
pTmp->GetPrev()->IsSctFrm() )
pTmp = pTmp->GetPrev();
if( ((SwSectionFrm*)pTmp)->GetFollow() == pSect )
pNew = (SwSectionFrm*)pTmp;
}
}
if( !pNew )
{
pNew = new SwSectionFrm( *pSect, sal_True );
pNew->InsertBefore( pLayLeaf, NULL );
pNew->Init();
SWRECTFN( pNew )
(pNew->*fnRect->fnMakePos)( pLayLeaf, pNew->GetPrev(), sal_True );
pLayLeaf = FIRSTLEAF( pNew );
if( !pNew->Lower() ) // einspaltige Bereiche formatieren
{
pNew->MakePos();
pLayLeaf->Format(); // damit die PrtArea fuers MoveBwd stimmt
}
else
pNew->SimpleFormat();
}
else
{
pLayLeaf = FIRSTLEAF( pNew );
if( pLayLeaf->IsColBodyFrm() )
{
// In existent section columns we're looking for the last not empty
// column.
SwLayoutFrm *pTmpLay = pLayLeaf;
while( pLayLeaf->GetUpper()->GetNext() )
{
pLayLeaf = (SwLayoutFrm*)((SwLayoutFrm*)pLayLeaf->GetUpper()->GetNext())->Lower();
if( pLayLeaf->Lower() )
pTmpLay = pLayLeaf;
}
// If we skipped an empty column, we've to set the jump-flag
if( pLayLeaf != pTmpLay )
{
pLayLeaf = pTmpLay;
SwFlowFrm::SetMoveBwdJump( sal_True );
}
}
}
return pLayLeaf;
}
SwTwips lcl_DeadLine( const SwFrm* pFrm )
{
const SwLayoutFrm* pUp = pFrm->GetUpper();
while( pUp && pUp->IsInSct() )
{
if( pUp->IsSctFrm() )
pUp = pUp->GetUpper();
// Spalten jetzt mit BodyFrm
else if( pUp->IsColBodyFrm() && pUp->GetUpper()->GetUpper()->IsSctFrm() )
pUp = pUp->GetUpper()->GetUpper();
else
break;
}
SWRECTFN( pFrm )
return pUp ? (pUp->*fnRect->fnGetPrtBottom)() :
(pFrm->Frm().*fnRect->fnGetBottom)();
}
// SwSectionFrm::Growable(..) prueft, ob der SectionFrm noch wachsen kann,
// ggf. muss die Umgebung gefragt werden
sal_Bool SwSectionFrm::Growable() const
{
SWRECTFN( this )
if( (*fnRect->fnYDiff)( lcl_DeadLine( this ),
(Frm().*fnRect->fnGetBottom)() ) > 0 )
return sal_True;
return ( GetUpper() && ((SwFrm*)GetUpper())->Grow( LONG_MAX, sal_True ) );
}
/*************************************************************************
|*
|* SwSectionFrm::_Grow(), _Shrink()
|*
|*************************************************************************/
SwTwips SwSectionFrm::_Grow( SwTwips nDist, sal_Bool bTst )
{
if ( !IsColLocked() && !HasFixSize() )
{
SWRECTFN( this )
long nFrmHeight = (Frm().*fnRect->fnGetHeight)();
if( nFrmHeight > 0 && nDist > (LONG_MAX - nFrmHeight) )
nDist = LONG_MAX - nFrmHeight;
if ( nDist <= 0L )
return 0L;
sal_Bool bInCalcCntnt = GetUpper() && IsInFly() && FindFlyFrm()->IsLocked();
// OD 2004-03-15 #116561# - allow grow in online layout
sal_Bool bGrow = !Lower() || !Lower()->IsColumnFrm() || !Lower()->GetNext() ||
GetSection()->GetFmt()->GetBalancedColumns().GetValue();
if( !bGrow )
{
const ViewShell *pSh = getRootFrm()->GetCurrShell();
bGrow = pSh && pSh->GetViewOptions()->getBrowseMode();
}
if( bGrow )
{
SwTwips nGrow;
if( IsInFtn() )
nGrow = 0;
else
{
nGrow = lcl_DeadLine( this );
nGrow = (*fnRect->fnYDiff)( nGrow,
(Frm().*fnRect->fnGetBottom)() );
}
SwTwips nSpace = nGrow;
if( !bInCalcCntnt && nGrow < nDist && GetUpper() )
nGrow += GetUpper()->Grow( LONG_MAX, sal_True );
if( nGrow > nDist )
nGrow = nDist;
if( nGrow <= 0 )
{
nGrow = 0;
if( nDist && !bTst )
{
if( bInCalcCntnt )
_InvalidateSize();
else
InvalidateSize();
}
}
else if( !bTst )
{
if( bInCalcCntnt )
_InvalidateSize();
else if( nSpace < nGrow && nDist != nSpace + GetUpper()->
Grow( nGrow - nSpace, sal_False ) )
InvalidateSize();
else
{
const SvxGraphicPosition ePos =
GetAttrSet()->GetBackground().GetGraphicPos();
if ( GPOS_RT < ePos && GPOS_TILED != ePos )
{
SetCompletePaint();
InvalidatePage();
}
if( GetUpper() && GetUpper()->IsHeaderFrm() )
GetUpper()->InvalidateSize();
}
(Frm().*fnRect->fnAddBottom)( nGrow );
long nPrtHeight = (Prt().*fnRect->fnGetHeight)() + nGrow;
(Prt().*fnRect->fnSetHeight)( nPrtHeight );
if( Lower() && Lower()->IsColumnFrm() && Lower()->GetNext() )
{
SwFrm* pTmp = Lower();
do
{
pTmp->_InvalidateSize();
pTmp = pTmp->GetNext();
} while ( pTmp );
_InvalidateSize();
}
if( GetNext() )
{
SwFrm *pFrm = GetNext();
while( pFrm && pFrm->IsSctFrm() && !((SwSectionFrm*)pFrm)->GetSection() )
pFrm = pFrm->GetNext();
if( pFrm )
{
if( bInCalcCntnt )
pFrm->_InvalidatePos();
else
pFrm->InvalidatePos();
}
}
// #i28701# - Due to the new object positioning
// the frame on the next page/column can flow backward (e.g. it
// was moved forward due to the positioning of its objects ).
// Thus, invalivate this next frame, if document compatibility
// option 'Consider wrapping style influence on object positioning' is ON.
else if ( GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) )
{
InvalidateNextPos();
}
}
return nGrow;
}
if ( !bTst )
{
if( bInCalcCntnt )
_InvalidateSize();
else
InvalidateSize();
}
}
return 0L;
}
SwTwips SwSectionFrm::_Shrink( SwTwips nDist, sal_Bool bTst )
{
if ( Lower() && !IsColLocked() && !HasFixSize() )
{
if( ToMaximize( sal_False ) )
{
if( !bTst )
InvalidateSize();
}
else
{
SWRECTFN( this )
long nFrmHeight = (Frm().*fnRect->fnGetHeight)();
if ( nDist > nFrmHeight )
nDist = nFrmHeight;
if ( Lower()->IsColumnFrm() && Lower()->GetNext() && // FtnAtEnd
!GetSection()->GetFmt()->GetBalancedColumns().GetValue() )
{ //Bei Spaltigkeit ubernimmt das Format die Kontrolle ueber
//das Wachstum (wg. des Ausgleichs).
if ( !bTst )
InvalidateSize();
return nDist;
}
else if( !bTst )
{
const SvxGraphicPosition ePos =
GetAttrSet()->GetBackground().GetGraphicPos();
if ( GPOS_RT < ePos && GPOS_TILED != ePos )
{
SetCompletePaint();
InvalidatePage();
}
(Frm().*fnRect->fnAddBottom)( -nDist );
long nPrtHeight = (Prt().*fnRect->fnGetHeight)() - nDist;
(Prt().*fnRect->fnSetHeight)( nPrtHeight );
// We do not allow a section frame to shrink the its upper
// footer frame. This is because in the calculation of a
// footer frame, the content of the section frame is _not_
// calculated. If there is a fly frame overlapping with the
// footer frame, the section frame is not affected by this
// during the calculation of the footer frame size.
// The footer frame does not grow in its FormatSize function
// but during the calculation of the content of the section
// frame. The section frame grows until some of its text is
// located on top of the fly frame. The next call of CalcCntnt
// tries to shrink the section and here it would also shrink
// the footer. This may not happen, because shrinking the footer
// would cause the top of the section frame to overlap with the
// fly frame again, this would result in a perfect loop.
if( GetUpper() && !GetUpper()->IsFooterFrm() )
GetUpper()->Shrink( nDist, bTst );
if( Lower() && Lower()->IsColumnFrm() && Lower()->GetNext() )
{
SwFrm* pTmp = Lower();
do
{
pTmp->_InvalidateSize();
pTmp = pTmp->GetNext();
} while ( pTmp );
}
if( GetNext() )
{
SwFrm* pFrm = GetNext();
while( pFrm && pFrm->IsSctFrm() && !((SwSectionFrm*)pFrm)->GetSection() )
pFrm = pFrm->GetNext();
if( pFrm )
pFrm->InvalidatePos();
else
SetRetouche();
}
else
SetRetouche();
return nDist;
}
}
}
return 0L;
}
/*************************************************************************
|*
|* SwSectionFrm::MoveAllowed()
|*
|* Wann sind Frms innerhalb eines SectionFrms moveable?
|* Wenn sie noch nicht in der letzten Spalte des SectionFrms sind,
|* wenn es einen Follow gibt,
|* wenn der SectionFrm nicht mehr wachsen kann, wird es komplizierter,
|* dann kommt es darauf an, ob der SectionFrm ein naechstes Layoutblatt
|* finden kann. In (spaltigen/verketteten) Flys wird dies via GetNextLayout
|* geprueft, in Tabellen und in Kopf/Fusszeilen gibt es keins, im DocBody
|* und auch im Fussnoten dagegen immer.
|*
|* Benutzt wird diese Routine im TxtFormatter, um zu entscheiden, ob ein
|* (Absatz-)Follow erzeugt werden darf oder ob der Absatz zusammenhalten muss.
|*
|*************************************************************************/
sal_Bool SwSectionFrm::MoveAllowed( const SwFrm* pFrm) const
{
// Gibt es einen Follow oder ist der Frame nicht in der letzten Spalte?
if( HasFollow() || ( pFrm->GetUpper()->IsColBodyFrm() &&
pFrm->GetUpper()->GetUpper()->GetNext() ) )
return sal_True;
if( pFrm->IsInFtn() )
{
if( IsInFtn() )
{
if( GetUpper()->IsInSct() )
{
if( Growable() )
return sal_False;
return GetUpper()->FindSctFrm()->MoveAllowed( this );
}
else
return sal_True;
}
// The content of footnote inside a columned sectionfrm is moveable
// except in the last column
const SwLayoutFrm *pLay = pFrm->FindFtnFrm()->GetUpper()->GetUpper();
if( pLay->IsColumnFrm() && pLay->GetNext() )
{
// The first paragraph in the first footnote in the first column
// in the sectionfrm at the top of the page is not moveable,
// if the columnbody is empty.
sal_Bool bRet = sal_False;
if( pLay->GetIndPrev() || pFrm->GetIndPrev() ||
pFrm->FindFtnFrm()->GetPrev() )
bRet = sal_True;
else
{
SwLayoutFrm* pBody = ((SwColumnFrm*)pLay)->FindBodyCont();
if( pBody && pBody->Lower() )
bRet = sal_True;
}
if( bRet && ( IsFtnAtEnd() || !Growable() ) )
return sal_True;
}
}
// Oder kann der Bereich noch wachsen?
if( !IsColLocked() && Growable() )
return sal_False;
// Jetzt muss untersucht werden, ob es ein Layoutblatt gibt, in dem
// ein Bereichsfollow erzeugt werden kann.
if( IsInTab() || ( !IsInDocBody() && FindFooterOrHeader() ) )
return sal_False; // In Tabellen/Kopf/Fusszeilen geht es nicht
if( IsInFly() ) // Bei spaltigen oder verketteten Rahmen
return 0 != ((SwFrm*)GetUpper())->GetNextLeaf( MAKEPAGE_NONE );
return sal_True;
}
/** Called for a frame inside a section with no direct previous frame (or only
previous empty section frames) the previous frame of the outer section is
returned, if the frame is the first flowing content of this section.
Note: For a frame inside a table frame, which is inside a section frame,
NULL is returned.
*/
SwFrm* SwFrm::_GetIndPrev() const
{
SwFrm *pRet = NULL;
// #i79774#
// Do not assert, if the frame has a direct previous frame, because it
// could be an empty section frame. The caller has to assure, that the
// frame has no direct previous frame or only empty section frames as
// previous frames.
OSL_ENSURE( /*!pPrev &&*/ IsInSct(), "Why?" );
const SwFrm* pSct = GetUpper();
if( !pSct )
return NULL;
if( pSct->IsSctFrm() )
pRet = pSct->GetIndPrev();
else if( pSct->IsColBodyFrm() && (pSct = pSct->GetUpper()->GetUpper())->IsSctFrm() )
{
// Do not return the previous frame of the outer section, if in one
// of the previous columns is content.
const SwFrm* pCol = GetUpper()->GetUpper()->GetPrev();
while( pCol )
{
OSL_ENSURE( pCol->IsColumnFrm(), "GetIndPrev(): ColumnFrm expected" );
OSL_ENSURE( pCol->GetLower() && pCol->GetLower()->IsBodyFrm(),
"GetIndPrev(): Where's the body?");
if( ((SwLayoutFrm*)((SwLayoutFrm*)pCol)->Lower())->Lower() )
return NULL;
pCol = pCol->GetPrev();
}
pRet = pSct->GetIndPrev();
}
// skip empty section frames
while( pRet && pRet->IsSctFrm() && !((SwSectionFrm*)pRet)->GetSection() )
pRet = pRet->GetIndPrev();
return pRet;
}
SwFrm* SwFrm::_GetIndNext()
{
OSL_ENSURE( !pNext && IsInSct(), "Why?" );
SwFrm* pSct = GetUpper();
if( !pSct )
return NULL;
if( pSct->IsSctFrm() )
return pSct->GetIndNext();
if( pSct->IsColBodyFrm() && (pSct = pSct->GetUpper()->GetUpper())->IsSctFrm() )
{ // Wir duerfen nur den Nachfolger des SectionFrms zurueckliefern,
// wenn in keiner folgenden Spalte mehr Inhalt ist
SwFrm* pCol = GetUpper()->GetUpper()->GetNext();
while( pCol )
{
OSL_ENSURE( pCol->IsColumnFrm(), "GetIndNext(): ColumnFrm expected" );
OSL_ENSURE( pCol->GetLower() && pCol->GetLower()->IsBodyFrm(),
"GetIndNext(): Where's the body?");
if( ((SwLayoutFrm*)((SwLayoutFrm*)pCol)->Lower())->Lower() )
return NULL;
pCol = pCol->GetNext();
}
return pSct->GetIndNext();
}
return NULL;
}
sal_Bool SwSectionFrm::IsDescendantFrom( const SwSectionFmt* pFmt ) const
{
if( !pSection || !pFmt )
return sal_False;
const SwSectionFmt *pMyFmt = pSection->GetFmt();
while( pFmt != pMyFmt )
{
if( pMyFmt->GetRegisteredIn()->ISA( SwSectionFmt ) )
pMyFmt = (SwSectionFmt*)pMyFmt->GetRegisteredIn();
else
return sal_False;
}
return sal_True;
}
void SwSectionFrm::CalcFtnAtEndFlag()
{
SwSectionFmt *pFmt = GetSection()->GetFmt();
sal_uInt16 nVal = pFmt->GetFtnAtTxtEnd( sal_False ).GetValue();
bFtnAtEnd = FTNEND_ATPGORDOCEND != nVal;
bOwnFtnNum = FTNEND_ATTXTEND_OWNNUMSEQ == nVal ||
FTNEND_ATTXTEND_OWNNUMANDFMT == nVal;
while( !bFtnAtEnd && !bOwnFtnNum )
{
if( pFmt->GetRegisteredIn()->ISA( SwSectionFmt ) )
pFmt = (SwSectionFmt*)pFmt->GetRegisteredIn();
else
break;
nVal = pFmt->GetFtnAtTxtEnd( sal_False ).GetValue();
if( FTNEND_ATPGORDOCEND != nVal )
{
bFtnAtEnd = sal_True;
bOwnFtnNum = bOwnFtnNum ||FTNEND_ATTXTEND_OWNNUMSEQ == nVal ||
FTNEND_ATTXTEND_OWNNUMANDFMT == nVal;
}
}
}
bool SwSectionFrm::IsEndnoteAtMyEnd() const
{
return pSection->GetFmt()->GetEndAtTxtEnd( sal_False ).IsAtEnd();
}
void SwSectionFrm::CalcEndAtEndFlag()
{
SwSectionFmt *pFmt = GetSection()->GetFmt();
bEndnAtEnd = pFmt->GetEndAtTxtEnd( sal_False ).IsAtEnd();
while( !bEndnAtEnd )
{
if( pFmt->GetRegisteredIn()->ISA( SwSectionFmt ) )
pFmt = (SwSectionFmt*)pFmt->GetRegisteredIn();
else
break;
bEndnAtEnd = pFmt->GetEndAtTxtEnd( sal_False ).IsAtEnd();
}
}
/*************************************************************************
|*
|* SwSectionFrm::Modify()
|*
|*************************************************************************/
void SwSectionFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
{
sal_uInt8 nInvFlags = 0;
if( pNew && RES_ATTRSET_CHG == pNew->Which() )
{
SfxItemIter aNIter( *((SwAttrSetChg*)pNew)->GetChgSet() );
SfxItemIter aOIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
SwAttrSetChg aOldSet( *(SwAttrSetChg*)pOld );
SwAttrSetChg aNewSet( *(SwAttrSetChg*)pNew );
while( sal_True )
{
_UpdateAttr( (SfxPoolItem*)aOIter.GetCurItem(),
(SfxPoolItem*)aNIter.GetCurItem(), nInvFlags,
&aOldSet, &aNewSet );
if( aNIter.IsAtEnd() )
break;
aNIter.NextItem();
aOIter.NextItem();
}
if ( aOldSet.Count() || aNewSet.Count() )
SwLayoutFrm::Modify( &aOldSet, &aNewSet );
}
else
_UpdateAttr( pOld, pNew, nInvFlags );
if ( nInvFlags != 0 )
{
if ( nInvFlags & 0x01 )
InvalidateSize();
if ( nInvFlags & 0x10 )
SetCompletePaint();
}
}
void SwSectionFrm::SwClientNotify( const SwModify& rMod, const SfxHint& rHint )
{
// #i117863#: The hint needs to indicate whether to keep the SwSectionFrm
// content or not.
const SwSectionFrmMoveAndDeleteHint* pHint =
dynamic_cast<const SwSectionFrmMoveAndDeleteHint*>(&rHint);
if ( pHint && pHint->GetId() == SFX_HINT_DYING && &rMod == GetRegisteredIn() )
{
SwSectionFrm::MoveCntntAndDelete( this, pHint->IsSaveCntnt() );
}
}
void SwSectionFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
sal_uInt8 &rInvFlags,
SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
{
sal_Bool bClear = sal_True;
const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
switch( nWhich )
{ // Mehrspaltigkeit in Fussnoten unterdruecken...
case RES_FMT_CHG:
{
const SwFmtCol& rNewCol = GetFmt()->GetCol();
if( !IsInFtn() )
{
//Dummer Fall. Bei der Zuweisung einer Vorlage k?nnen wir uns
//nicht auf das alte Spaltenattribut verlassen. Da diese
//wenigstens anzahlgemass fuer ChgColumns vorliegen muessen,
//bleibt uns nur einen temporaeres Attribut zu basteln.
SwFmtCol aCol;
if ( Lower() && Lower()->IsColumnFrm() )
{
sal_uInt16 nCol = 0;
SwFrm *pTmp = Lower();
do
{ ++nCol;
pTmp = pTmp->GetNext();
} while ( pTmp );
aCol.Init( nCol, 0, 1000 );
}
bool bChgFtn = IsFtnAtEnd();
bool const bChgEndn = IsEndnAtEnd();
bool const bChgMyEndn = IsEndnoteAtMyEnd();
CalcFtnAtEndFlag();
CalcEndAtEndFlag();
bChgFtn = ( bChgFtn != IsFtnAtEnd() ) ||
( bChgEndn != IsEndnAtEnd() ) ||
( bChgMyEndn != IsEndnoteAtMyEnd() );
ChgColumns( aCol, rNewCol, bChgFtn );
rInvFlags |= 0x10;
}
rInvFlags |= 0x01;
bClear = sal_False;
}
break;
case RES_COL:
if( !IsInFtn() )
{
ChgColumns( *(const SwFmtCol*)pOld, *(const SwFmtCol*)pNew );
rInvFlags |= 0x11;
}
break;
case RES_FTN_AT_TXTEND:
if( !IsInFtn() )
{
bool const bOld = IsFtnAtEnd();
CalcFtnAtEndFlag();
if (bOld != IsFtnAtEnd())
{
const SwFmtCol& rNewCol = GetFmt()->GetCol();
ChgColumns( rNewCol, rNewCol, sal_True );
rInvFlags |= 0x01;
}
}
break;
case RES_END_AT_TXTEND:
if( !IsInFtn() )
{
bool const bOld = IsEndnAtEnd();
bool const bMyOld = IsEndnoteAtMyEnd();
CalcEndAtEndFlag();
if (bOld != IsEndnAtEnd() || bMyOld != IsEndnoteAtMyEnd())
{
const SwFmtCol& rNewCol = GetFmt()->GetCol();
ChgColumns( rNewCol, rNewCol, sal_True );
rInvFlags |= 0x01;
}
}
break;
case RES_COLUMNBALANCE:
rInvFlags |= 0x01;
break;
case RES_FRAMEDIR :
SetDerivedR2L( sal_False );
CheckDirChange();
break;
case RES_PROTECT:
{
ViewShell *pSh = getRootFrm()->GetCurrShell();
if( pSh && pSh->GetLayout()->IsAnyShellAccessible() )
pSh->Imp()->InvalidateAccessibleEditableState( sal_True, this );
}
break;
default:
bClear = sal_False;
}
if ( bClear )
{
if ( pOldSet || pNewSet )
{
if ( pOldSet )
pOldSet->ClearItem( nWhich );
if ( pNewSet )
pNewSet->ClearItem( nWhich );
}
else
SwLayoutFrm::Modify( pOld, pNew );
}
}
/*--------------------------------------------------
* SwSectionFrm::ToMaximize(..): A follow or a ftncontainer at the end of the
* page causes a maximal Size of the sectionframe.
* --------------------------------------------------*/
sal_Bool SwSectionFrm::ToMaximize( sal_Bool bCheckFollow ) const
{
if( HasFollow() )
{
if( !bCheckFollow ) // Don't check superfluous follows
return sal_True;
const SwSectionFrm* pFoll = GetFollow();
while( pFoll && pFoll->IsSuperfluous() )
pFoll = pFoll->GetFollow();
if( pFoll )
return sal_True;
}
if( IsFtnAtEnd() )
return sal_False;
const SwFtnContFrm* pCont = ContainsFtnCont();
if( !IsEndnAtEnd() )
return 0 != pCont;
sal_Bool bRet = sal_False;
while( pCont && !bRet )
{
if( pCont->FindFootNote() )
bRet = sal_True;
else
pCont = ContainsFtnCont( pCont );
}
return bRet;
}
/*--------------------------------------------------
* sal_Bool SwSectionFrm::ContainsFtnCont()
* checks every Column for FtnContFrms.
* --------------------------------------------------*/
SwFtnContFrm* SwSectionFrm::ContainsFtnCont( const SwFtnContFrm* pCont ) const
{
SwFtnContFrm* pRet = NULL;
const SwLayoutFrm* pLay;
if( pCont )
{
pLay = pCont->FindFtnBossFrm( 0 );
OSL_ENSURE( IsAnLower( pLay ), "ConatainsFtnCont: Wrong FtnContainer" );
pLay = (SwLayoutFrm*)pLay->GetNext();
}
else if( Lower() && Lower()->IsColumnFrm() )
pLay = (SwLayoutFrm*)Lower();
else
pLay = NULL;
while ( !pRet && pLay )
{
if( pLay->Lower() && pLay->Lower()->GetNext() )
{
OSL_ENSURE( pLay->Lower()->GetNext()->IsFtnContFrm(),
"ToMaximize: Unexspected Frame" );
pRet = (SwFtnContFrm*)pLay->Lower()->GetNext();
}
OSL_ENSURE( !pLay->GetNext() || pLay->GetNext()->IsLayoutFrm(),
"ToMaximize: ColFrm exspected" );
pLay = (SwLayoutFrm*)pLay->GetNext();
}
return pRet;
}
void SwSectionFrm::InvalidateFtnPos()
{
SwFtnContFrm* pCont = ContainsFtnCont( NULL );
if( pCont )
{
SwFrm *pTmp = pCont->ContainsCntnt();
if( pTmp )
pTmp->_InvalidatePos();
}
}
/*--------------------------------------------------
* SwSectionFrm::Undersize() liefert den Betrag, um den der Bereich gern
* groesser waere, wenn in ihm Undersized TxtFrms liegen, ansonsten Null.
* Das Undersized-Flag wird ggf. korrigiert.
* --------------------------------------------------*/
long SwSectionFrm::Undersize( sal_Bool bOverSize )
{
bUndersized = sal_False;
SWRECTFN( this )
long nRet = InnerHeight() - (Prt().*fnRect->fnGetHeight)();
if( nRet > 0 )
bUndersized = sal_True;
else if( !bOverSize )
nRet = 0;
return nRet;
}
/// OD 01.04.2003 #108446# - determine next frame for footnote/endnote formatting
/// before format of current one, because current one can move backward.
/// After moving backward to a previous page method <FindNext()> will return
/// the text frame presenting the first page footnote, if it exists. Thus, the
/// rest of the footnote/endnote container would not be formatted.
void SwSectionFrm::CalcFtnCntnt()
{
SwFtnContFrm* pCont = ContainsFtnCont();
if( pCont )
{
SwFrm* pFrm = pCont->ContainsAny();
if( pFrm )
pCont->Calc();
while( pFrm && IsAnLower( pFrm ) )
{
SwFtnFrm* pFtn = pFrm->FindFtnFrm();
if( pFtn )
pFtn->Calc();
// OD 01.04.2003 #108446# - determine next frame before format current frame.
SwFrm* pNextFrm = 0;
{
if( pFrm->IsSctFrm() )
{
pNextFrm = static_cast<SwSectionFrm*>(pFrm)->ContainsAny();
}
if( !pNextFrm )
{
pNextFrm = pFrm->FindNext();
}
}
pFrm->Calc();
pFrm = pNextFrm;
}
}
}
/* --------------------------------------------------
* Wenn ein SectionFrm leerlaeuft, z.B. weil sein Inhalt die Seite/Spalte wechselt,
* so wird er nicht sofort zerstoert (es koennte noch jemand auf dem Stack einen Pointer
* auf ihn halten), sondern er traegt sich in eine Liste am RootFrm ein, die spaeter
* abgearbeitet wird (in LayAction::Action u.a.). Seine Groesse wird auf Null gesetzt und
* sein Zeiger auf seine Section ebenfalls. Solche zum Loeschen vorgesehene SectionFrms
* muessen vom Layout/beim Formatieren ignoriert werden.
*
* Mit InsertEmptySct nimmt der RootFrm einen SectionFrm in die Liste auf,
* mit RemoveFromList kann ein SectionFrm wieder aus der Liste entfernt werden (Dtor),
* mit DeleteEmptySct wird die Liste abgearbeitet und die SectionFrms zerstoert
* --------------------------------------------------*/
void SwRootFrm::InsertEmptySct( SwSectionFrm* pDel )
{
if( !pDestroy )
pDestroy = new SwDestroyList;
sal_uInt16 nPos;
if( !pDestroy->Seek_Entry( pDel, &nPos ) )
pDestroy->Insert( pDel );
}
void SwRootFrm::_DeleteEmptySct()
{
OSL_ENSURE( pDestroy, "Keine Liste, keine Kekse" );
while( pDestroy->Count() )
{
SwSectionFrm* pSect = (*pDestroy)[0];
pDestroy->Remove( sal_uInt16(0) );
OSL_ENSURE( !pSect->IsColLocked() && !pSect->IsJoinLocked(),
"DeleteEmptySct: Locked SectionFrm" );
if( !pSect->Frm().HasArea() && !pSect->ContainsCntnt() )
{
SwLayoutFrm* pUp = pSect->GetUpper();
pSect->Remove();
delete pSect;
if( pUp && !pUp->Lower() )
{
if( pUp->IsPageBodyFrm() )
pUp->getRootFrm()->SetSuperfluous();
else if( pUp->IsFtnFrm() && !pUp->IsColLocked() &&
pUp->GetUpper() )
{
pUp->Cut();
delete pUp;
}
}
}
else {
OSL_ENSURE( pSect->GetSection(), "DeleteEmptySct: Halbtoter SectionFrm?!" );
}
}
}
void SwRootFrm::_RemoveFromList( SwSectionFrm* pSct )
{
OSL_ENSURE( pDestroy, "Where's my list?" );
sal_uInt16 nPos;
if( pDestroy->Seek_Entry( pSct, &nPos ) )
pDestroy->Remove( nPos );
}
#ifdef DBG_UTIL
bool SwRootFrm::IsInDelList( SwSectionFrm* pSct ) const
{
sal_uInt16 nPos;
return ( pDestroy && pDestroy->Seek_Entry( pSct, &nPos ) );
}
#endif
bool SwSectionFrm::IsBalancedSection() const
{
bool bRet = false;
if ( GetSection() && Lower() && Lower()->IsColumnFrm() && Lower()->GetNext() )
{
bRet = !GetSection()->GetFmt()->GetBalancedColumns().GetValue();
}
return bRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|