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
|
/* -*- 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 <svx/svdmrkv.hxx>
#include <svx/svdetc.hxx>
#include <svx/svdoedge.hxx>
#include "svdglob.hxx"
#include <svx/svdview.hxx>
#include <svx/svdpagv.hxx>
#include <svx/svdpage.hxx>
#include "svddrgm1.hxx"
#ifdef DBG_UTIL
#include <svdibrow.hxx>
#endif
#include <svx/svdoole2.hxx>
#include <svx/xgrad.hxx>
#include <svx/xflgrit.hxx>
#include "gradtrns.hxx"
#include <svx/xflftrit.hxx>
#include <svx/dialmgr.hxx>
#include "svx/svdstr.hrc"
#include <svx/svdundo.hxx>
#include <svx/svdopath.hxx>
#include <svx/scene3d.hxx>
#include <svx/svdovirt.hxx>
#include <sdr/overlay/overlayrollingrectangle.hxx>
#include <svx/sdr/overlay/overlaymanager.hxx>
#include <svx/sdrpaintwindow.hxx>
#include <svx/sdrpagewindow.hxx>
#include <svx/sdrhittesthelper.hxx>
#include <svx/svdocapt.hxx>
#include <svx/svdograf.hxx>
#include <editeng/editdata.hxx>
// Migrate Marking of Objects, Points and GluePoints
class ImplMarkingOverlay
{
// The OverlayObjects
::sdr::overlay::OverlayObjectList maObjects;
// The remembered second position in logical coordinates
basegfx::B2DPoint maSecondPosition;
// bitfield
// A flag to remember if the action is for unmarking.
bool mbUnmarking : 1;
public:
ImplMarkingOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos, bool bUnmarking = false);
~ImplMarkingOverlay();
void SetSecondPosition(const basegfx::B2DPoint& rNewPosition);
bool IsUnmarking() const { return mbUnmarking; }
};
ImplMarkingOverlay::ImplMarkingOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos, bool bUnmarking)
: maSecondPosition(rStartPos),
mbUnmarking(bUnmarking)
{
for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
{
SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
rtl::Reference< ::sdr::overlay::OverlayManager > xTargetOverlay = pCandidate->GetOverlayManager();
if (xTargetOverlay.is())
{
::sdr::overlay::OverlayRollingRectangleStriped* pNew = new ::sdr::overlay::OverlayRollingRectangleStriped(
rStartPos, rStartPos, false);
xTargetOverlay->add(*pNew);
maObjects.append(*pNew);
}
}
}
ImplMarkingOverlay::~ImplMarkingOverlay()
{
// The OverlayObjects are cleared using the destructor of OverlayObjectList.
// That destructor calls clear() at the list which removes all objects from the
// OverlayManager and deletes them.
}
void ImplMarkingOverlay::SetSecondPosition(const basegfx::B2DPoint& rNewPosition)
{
if(rNewPosition != maSecondPosition)
{
// apply to OverlayObjects
for(sal_uInt32 a(0L); a < maObjects.count(); a++)
{
::sdr::overlay::OverlayRollingRectangleStriped& rCandidate = (::sdr::overlay::OverlayRollingRectangleStriped&)maObjects.getOverlayObject(a);
rCandidate.setSecondPosition(rNewPosition);
}
// remember new position
maSecondPosition = rNewPosition;
}
}
// MarkView
void SdrMarkView::ImpClearVars()
{
eDragMode=SDRDRAG_MOVE;
bRefHdlShownOnly=false;
eEditMode=SDREDITMODE_EDIT;
eEditMode0=SDREDITMODE_EDIT;
bDesignMode=false;
pMarkedObj=NULL;
pMarkedPV=NULL;
bForceFrameHandles=false;
bPlusHdlAlways=false;
nFrameHandlesLimit=50;
bInsPolyPoint=false;
mnInsPointNum = 0L;
bMarkedObjRectDirty=false;
bMarkedPointsRectsDirty=false;
mbMarkHandlesHidden = false;
bMrkPntDirty=false;
bMarkHdlWhenTextEdit=false;
bMarkableObjCountDirty=false; // not yet implemented
nMarkableObjCount=0; // not yet implemented
// Migrate selections
BrkMarkObj();
BrkMarkPoints();
BrkMarkGluePoints();
}
SdrMarkView::SdrMarkView(SdrModel* pModel1, OutputDevice* pOut)
: SdrSnapView(pModel1,pOut),
mpMarkObjOverlay(0L),
mpMarkPointsOverlay(0L),
mpMarkGluePointsOverlay(0L),
aHdl(this),
mpSdrViewSelection(new sdr::ViewSelection())
{
ImpClearVars();
StartListening(*pModel1);
}
SdrMarkView::~SdrMarkView()
{
// Migrate selections
BrkMarkObj();
BrkMarkPoints();
BrkMarkGluePoints();
delete mpSdrViewSelection;
}
void SdrMarkView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
{
SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint);
if (pSdrHint!=NULL)
{
SdrHintKind eKind=pSdrHint->GetKind();
if (eKind==HINT_OBJCHG || eKind==HINT_OBJINSERTED || eKind==HINT_OBJREMOVED)
{
bMarkedObjRectDirty=true;
bMarkedPointsRectsDirty=true;
}
}
SdrSnapView::Notify(rBC,rHint);
}
void SdrMarkView::ModelHasChanged()
{
SdrPaintView::ModelHasChanged();
GetMarkedObjectListWriteAccess().SetNameDirty();
bMarkedObjRectDirty=true;
bMarkedPointsRectsDirty=true;
// Example: Obj is selected and maMarkedObjectList is sorted.
// In another View 2, the ObjOrder is changed (e. g. MovToTop())
// Then we need to re-sort MarkList.
GetMarkedObjectListWriteAccess().SetUnsorted();
SortMarkedObjects();
bMrkPntDirty=true;
UndirtyMrkPnt();
SdrView* pV=(SdrView*)this;
if (pV!=NULL && !pV->IsDragObj() && !pV->IsInsObjPoint()) {
AdjustMarkHdl();
}
}
bool SdrMarkView::IsAction() const
{
return SdrSnapView::IsAction() || IsMarkObj() || IsMarkPoints() || IsMarkGluePoints();
}
void SdrMarkView::MovAction(const Point& rPnt)
{
SdrSnapView::MovAction(rPnt);
if(IsMarkObj())
{
MovMarkObj(rPnt);
}
else if(IsMarkPoints())
{
MovMarkPoints(rPnt);
}
else if(IsMarkGluePoints())
{
MovMarkGluePoints(rPnt);
}
}
void SdrMarkView::EndAction()
{
if(IsMarkObj())
{
EndMarkObj();
}
else if(IsMarkPoints())
{
EndMarkPoints();
}
else if(IsMarkGluePoints())
{
EndMarkGluePoints();
}
SdrSnapView::EndAction();
}
void SdrMarkView::BckAction()
{
SdrSnapView::BckAction();
BrkMarkObj();
BrkMarkPoints();
BrkMarkGluePoints();
}
void SdrMarkView::BrkAction()
{
SdrSnapView::BrkAction();
BrkMarkObj();
BrkMarkPoints();
BrkMarkGluePoints();
}
void SdrMarkView::TakeActionRect(Rectangle& rRect) const
{
if(IsMarkObj() || IsMarkPoints() || IsMarkGluePoints())
{
rRect = Rectangle(aDragStat.GetStart(), aDragStat.GetNow());
}
else
{
SdrSnapView::TakeActionRect(rRect);
}
}
void SdrMarkView::ClearPageView()
{
UnmarkAllObj();
SdrSnapView::ClearPageView();
}
void SdrMarkView::HideSdrPage()
{
bool bMrkChg(false);
SdrPageView* pPageView = GetSdrPageView();
if (pPageView)
{
// break all creation actions when hiding page (#75081#)
BrkAction();
// Discard all selections on this page
bMrkChg = GetMarkedObjectListWriteAccess().DeletePageView(*pPageView);
}
SdrSnapView::HideSdrPage();
if(bMrkChg)
{
MarkListHasChanged();
AdjustMarkHdl();
}
}
bool SdrMarkView::BegMarkObj(const Point& rPnt, bool bUnmark)
{
BrkAction();
DBG_ASSERT(0L == mpMarkObjOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkObjOverlay (!)");
basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
mpMarkObjOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
aDragStat.Reset(rPnt);
aDragStat.NextPoint();
aDragStat.SetMinMove(nMinMovLog);
return true;
}
void SdrMarkView::MovMarkObj(const Point& rPnt)
{
if(IsMarkObj() && aDragStat.CheckMinMoved(rPnt))
{
aDragStat.NextMove(rPnt);
DBG_ASSERT(mpMarkObjOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
basegfx::B2DPoint aNewPos(rPnt.X(), rPnt.Y());
mpMarkObjOverlay->SetSecondPosition(aNewPos);
}
}
bool SdrMarkView::EndMarkObj()
{
bool bRetval(false);
if(IsMarkObj())
{
if(aDragStat.IsMinMoved())
{
Rectangle aRect(aDragStat.GetStart(), aDragStat.GetNow());
aRect.Justify();
MarkObj(aRect, mpMarkObjOverlay->IsUnmarking());
bRetval = true;
}
// cleanup
BrkMarkObj();
}
return bRetval;
}
void SdrMarkView::BrkMarkObj()
{
if(IsMarkObj())
{
DBG_ASSERT(mpMarkObjOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
delete mpMarkObjOverlay;
mpMarkObjOverlay = 0L;
}
}
bool SdrMarkView::BegMarkPoints(const Point& rPnt, bool bUnmark)
{
if(HasMarkablePoints())
{
BrkAction();
DBG_ASSERT(0L == mpMarkPointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkPointsOverlay (!)");
basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
mpMarkPointsOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
aDragStat.Reset(rPnt);
aDragStat.NextPoint();
aDragStat.SetMinMove(nMinMovLog);
return true;
}
return false;
}
void SdrMarkView::MovMarkPoints(const Point& rPnt)
{
if(IsMarkPoints() && aDragStat.CheckMinMoved(rPnt))
{
aDragStat.NextMove(rPnt);
DBG_ASSERT(mpMarkPointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
basegfx::B2DPoint aNewPos(rPnt.X(), rPnt.Y());
mpMarkPointsOverlay->SetSecondPosition(aNewPos);
}
}
bool SdrMarkView::EndMarkPoints()
{
bool bRetval(false);
if(IsMarkPoints())
{
if(aDragStat.IsMinMoved())
{
Rectangle aRect(aDragStat.GetStart(), aDragStat.GetNow());
aRect.Justify();
MarkPoints(aRect, mpMarkPointsOverlay->IsUnmarking());
bRetval = true;
}
// cleanup
BrkMarkPoints();
}
return bRetval;
}
void SdrMarkView::BrkMarkPoints()
{
if(IsMarkPoints())
{
DBG_ASSERT(mpMarkPointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
delete mpMarkPointsOverlay;
mpMarkPointsOverlay = 0L;
}
}
bool SdrMarkView::BegMarkGluePoints(const Point& rPnt, bool bUnmark)
{
if(HasMarkableGluePoints())
{
BrkAction();
DBG_ASSERT(0L == mpMarkGluePointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkGluePointsOverlay (!)");
basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
mpMarkGluePointsOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
aDragStat.Reset(rPnt);
aDragStat.NextPoint();
aDragStat.SetMinMove(nMinMovLog);
return true;
}
return false;
}
void SdrMarkView::MovMarkGluePoints(const Point& rPnt)
{
if(IsMarkGluePoints() && aDragStat.CheckMinMoved(rPnt))
{
aDragStat.NextMove(rPnt);
DBG_ASSERT(mpMarkGluePointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
basegfx::B2DPoint aNewPos(rPnt.X(), rPnt.Y());
mpMarkGluePointsOverlay->SetSecondPosition(aNewPos);
}
}
bool SdrMarkView::EndMarkGluePoints()
{
bool bRetval(false);
if(IsMarkGluePoints())
{
if(aDragStat.IsMinMoved())
{
Rectangle aRect(aDragStat.GetStart(),aDragStat.GetNow());
aRect.Justify();
MarkGluePoints(&aRect, mpMarkGluePointsOverlay->IsUnmarking());
bRetval = true;
}
// cleanup
BrkMarkGluePoints();
}
return bRetval;
}
void SdrMarkView::BrkMarkGluePoints()
{
if(IsMarkGluePoints())
{
DBG_ASSERT(mpMarkGluePointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
delete mpMarkGluePointsOverlay;
mpMarkGluePointsOverlay = 0L;
}
}
sal_uIntPtr SdrMarkView::GetMarkableObjCount() const
{
sal_uIntPtr nCount=0;
SdrPageView* pPV = GetSdrPageView();
if(pPV)
{
SdrObjList* pOL=pPV->GetObjList();
sal_uIntPtr nObjAnz=pOL->GetObjCount();
for (sal_uIntPtr nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
SdrObject* pObj=pOL->GetObj(nObjNum);
if (IsObjMarkable(pObj,pPV)) {
nCount++;
}
}
}
return nCount;
}
bool SdrMarkView::HasMarkableObj() const
{
sal_uIntPtr nCount=0;
SdrPageView* pPV = GetSdrPageView();
if(pPV)
{
SdrObjList* pOL=pPV->GetObjList();
sal_uIntPtr nObjAnz=pOL->GetObjCount();
for (sal_uIntPtr nObjNum=0; nObjNum<nObjAnz && nCount==0; nObjNum++) {
SdrObject* pObj=pOL->GetObj(nObjNum);
if (IsObjMarkable(pObj,pPV)) {
nCount++;
}
}
}
return nCount!=0;
}
void SdrMarkView::hideMarkHandles()
{
if(!mbMarkHandlesHidden)
{
mbMarkHandlesHidden = true;
AdjustMarkHdl();
}
}
void SdrMarkView::showMarkHandles()
{
if(mbMarkHandlesHidden)
{
mbMarkHandlesHidden = false;
AdjustMarkHdl();
}
}
bool SdrMarkView::ImpIsFrameHandles() const
{
sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
bool bFrmHdl=nMarkAnz>nFrameHandlesLimit || bForceFrameHandles;
bool bStdDrag=eDragMode==SDRDRAG_MOVE;
if (nMarkAnz==1 && bStdDrag && bFrmHdl)
{
const SdrObject* pObj=GetMarkedObjectByIndex(0);
if (pObj->GetObjInventor()==SdrInventor)
{
sal_uInt16 nIdent=pObj->GetObjIdentifier();
if (nIdent==OBJ_LINE || nIdent==OBJ_EDGE || nIdent==OBJ_CAPTION || nIdent==OBJ_MEASURE || nIdent==OBJ_CUSTOMSHAPE || nIdent==OBJ_TABLE )
{
bFrmHdl=false;
}
}
}
if (!bStdDrag && !bFrmHdl) {
// all other drag modes only with FrameHandles
bFrmHdl=true;
if (eDragMode==SDRDRAG_ROTATE) {
// when rotating, use ObjOwn drag, if there's at least 1 PolyObj
for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz && bFrmHdl; nMarkNum++) {
const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
const SdrObject* pObj=pM->GetMarkedSdrObj();
bFrmHdl=!pObj->IsPolyObj();
}
}
}
if (!bFrmHdl) {
// FrameHandles, if at least 1 Obj can't do SpecialDrag
for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz && !bFrmHdl; nMarkNum++) {
const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
const SdrObject* pObj=pM->GetMarkedSdrObj();
bFrmHdl=!pObj->hasSpecialDrag();
}
}
// no FrameHdl for crop
if(bFrmHdl && SDRDRAG_CROP == eDragMode)
{
bFrmHdl = false;
}
return bFrmHdl;
}
void SdrMarkView::SetMarkHandles()
{
// remember old focus handle values to search for it again
const SdrHdl* pSaveOldFocusHdl = aHdl.GetFocusHdl();
bool bSaveOldFocus(false);
sal_uInt32 nSavePolyNum(0L), nSavePointNum(0L);
SdrHdlKind eSaveKind(HDL_MOVE);
SdrObject* pSaveObj = NULL;
if(pSaveOldFocusHdl
&& pSaveOldFocusHdl->GetObj()
&& pSaveOldFocusHdl->GetObj()->ISA(SdrPathObj)
&& (pSaveOldFocusHdl->GetKind() == HDL_POLY || pSaveOldFocusHdl->GetKind() == HDL_BWGT))
{
bSaveOldFocus = true;
nSavePolyNum = pSaveOldFocusHdl->GetPolyNum();
nSavePointNum = pSaveOldFocusHdl->GetPointNum();
pSaveObj = pSaveOldFocusHdl->GetObj();
eSaveKind = pSaveOldFocusHdl->GetKind();
}
// delete/clear all handles. This will always be done, even with areMarkHandlesHidden()
aHdl.Clear();
aHdl.SetRotateShear(eDragMode==SDRDRAG_ROTATE);
aHdl.SetDistortShear(eDragMode==SDRDRAG_SHEAR);
pMarkedObj=NULL;
pMarkedPV=NULL;
// are handles enabled at all? Create only then
if(!areMarkHandlesHidden())
{
sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
bool bStdDrag=eDragMode==SDRDRAG_MOVE;
bool bSingleTextObjMark=false;
if (nMarkAnz==1)
{
pMarkedObj=GetMarkedObjectByIndex(0);
bSingleTextObjMark =
pMarkedObj &&
pMarkedObj->ISA(SdrTextObj) &&
static_cast<SdrTextObj*>(pMarkedObj)->IsTextFrame();
}
bool bFrmHdl=ImpIsFrameHandles();
if (nMarkAnz>0)
{
pMarkedPV=GetSdrPageViewOfMarkedByIndex(0);
for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz && (pMarkedPV!=NULL || !bFrmHdl); nMarkNum++)
{
const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
if (pMarkedPV!=pM->GetPageView())
{
pMarkedPV=NULL;
}
}
}
// apply calc offset to marked object rect
// ( necessary for handles to be displayed in
// correct position )
Point aGridOff = GetGridOffset();
// check if text edit or ole is active and handles need to be suppressed. This may be the case
// when a single object is selected
// Using a strict return statement is okay here; no handles means *no* handles.
if(pMarkedObj)
{
// formally #i33755#: If TextEdit is active the EditEngine will directly paint
// to the window, so suppress Overlay and handles completely; a text frame for
// the active text edit will be painted by the repaitnt mechanism in
// SdrObjEditView::ImpPaintOutlinerView in this case. This needs to be reworked
// in the future
// Also formally #122142#: Pretty much the same for SdrCaptionObj's in calc.
if(((SdrView*)this)->IsTextEdit())
{
const SdrTextObj* pSdrTextObj = dynamic_cast< const SdrTextObj* >(pMarkedObj);
if(pSdrTextObj && pSdrTextObj->IsInEditMode())
{
return;
}
}
// formally #i118524#: if inplace activated OLE is selected, suppress handles
const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pMarkedObj);
if(pSdrOle2Obj && (pSdrOle2Obj->isInplaceActive() || pSdrOle2Obj->isUiActive()))
{
return;
}
}
if (bFrmHdl)
{
Rectangle aRect(GetMarkedObjRect());
if(!aRect.IsEmpty())
{ // otherwise nothing is found
if( bSingleTextObjMark )
{
const sal_uIntPtr nSiz0=aHdl.GetHdlCount();
pMarkedObj->AddToHdlList(aHdl);
const sal_uIntPtr nSiz1=aHdl.GetHdlCount();
for (sal_uIntPtr i=nSiz0; i<nSiz1; i++)
{
SdrHdl* pHdl=aHdl.GetHdl(i);
pHdl->SetObj(pMarkedObj);
pHdl->SetPos( pHdl->GetPos() + aGridOff );
pHdl->SetPageView(pMarkedPV);
pHdl->SetObjHdlNum(sal_uInt16(i-nSiz0));
}
}
else
{
bool bWdt0=aRect.Left()==aRect.Right();
bool bHgt0=aRect.Top()==aRect.Bottom();
if (bWdt0 && bHgt0)
{
aHdl.AddHdl(new SdrHdl(aRect.TopLeft(),HDL_UPLFT));
}
else if (!bStdDrag && (bWdt0 || bHgt0))
{
aHdl.AddHdl(new SdrHdl(aRect.TopLeft() ,HDL_UPLFT));
aHdl.AddHdl(new SdrHdl(aRect.BottomRight(),HDL_LWRGT));
}
else
{
if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.TopLeft() ,HDL_UPLFT));
if ( !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.TopCenter() ,HDL_UPPER));
if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.TopRight() ,HDL_UPRGT));
if (!bWdt0 ) aHdl.AddHdl(new SdrHdl(aRect.LeftCenter() ,HDL_LEFT ));
if (!bWdt0 ) aHdl.AddHdl(new SdrHdl(aRect.RightCenter() ,HDL_RIGHT));
if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.BottomLeft() ,HDL_LWLFT));
if ( !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.BottomCenter(),HDL_LOWER));
if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.BottomRight() ,HDL_LWRGT));
}
}
}
}
else
{
bool bDone(false);
// moved crop handling to non-frame part and the handle creation to SdrGrafObj
if(1 == nMarkAnz && pMarkedObj && SDRDRAG_CROP == eDragMode)
{
const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pMarkedObj);
if(pSdrGrafObj)
{
pSdrGrafObj->addCropHandles(aHdl);
bDone = true;
}
}
if(!bDone)
{
for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++)
{
const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
SdrObject* pObj=pM->GetMarkedSdrObj();
SdrPageView* pPV=pM->GetPageView();
const sal_uIntPtr nSiz0=aHdl.GetHdlCount();
pObj->AddToHdlList(aHdl);
const sal_uIntPtr nSiz1=aHdl.GetHdlCount();
bool bPoly=pObj->IsPolyObj();
const SdrUShortCont* pMrkPnts=pM->GetMarkedPoints();
for (sal_uIntPtr i=nSiz0; i<nSiz1; i++)
{
SdrHdl* pHdl=aHdl.GetHdl(i);
pHdl->SetPos( pHdl->GetPos() + aGridOff );
pHdl->SetObj(pObj);
pHdl->SetPageView(pPV);
pHdl->SetObjHdlNum(sal_uInt16(i-nSiz0));
if (bPoly)
{
bool bSelected=pMrkPnts!=NULL
&& pMrkPnts->find( sal_uInt16(i-nSiz0) ) != pMrkPnts->end();
pHdl->SetSelected(bSelected);
if (bPlusHdlAlways || bSelected)
{
sal_uInt32 nPlusAnz=pObj->GetPlusHdlCount(*pHdl);
for (sal_uInt32 nPlusNum=0; nPlusNum<nPlusAnz; nPlusNum++)
{
SdrHdl* pPlusHdl=pObj->GetPlusHdl(*pHdl,nPlusNum);
if (pPlusHdl!=NULL)
{
pPlusHdl->SetObj(pObj);
pPlusHdl->SetPageView(pPV);
pPlusHdl->SetPlusHdl(true);
aHdl.AddHdl(pPlusHdl);
}
}
}
}
}
}
}
}
// GluePoint handles
for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++)
{
const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
SdrObject* pObj=pM->GetMarkedSdrObj();
SdrPageView* pPV=pM->GetPageView();
const SdrUShortCont* pMrkGlue=pM->GetMarkedGluePoints();
if (pMrkGlue!=NULL)
{
const SdrGluePointList* pGPL=pObj->GetGluePointList();
if (pGPL!=NULL)
{
for(SdrUShortCont::const_iterator it = pMrkGlue->begin(); it != pMrkGlue->end(); ++it)
{
sal_uInt16 nId=*it;
//nNum changed to nNumGP because already used in for loop
sal_uInt16 nNumGP=pGPL->FindGluePoint(nId);
if (nNumGP!=SDRGLUEPOINT_NOTFOUND)
{
const SdrGluePoint& rGP=(*pGPL)[nNumGP];
Point aPos(rGP.GetAbsolutePos(*pObj));
SdrHdl* pGlueHdl=new SdrHdl(aPos,HDL_GLUE);
pGlueHdl->SetObj(pObj);
pGlueHdl->SetPageView(pPV);
pGlueHdl->SetObjHdlNum(nId);
aHdl.AddHdl(pGlueHdl);
}
}
}
}
}
// rotation point/axis of reflection
AddDragModeHdl(eDragMode);
// sort handles
aHdl.Sort();
// add custom handles (used by other apps, e.g. AnchorPos)
AddCustomHdl();
// try to restore focus handle index from remembered values
if(bSaveOldFocus)
{
for(sal_uInt32 a(0); a < aHdl.GetHdlCount(); a++)
{
SdrHdl* pCandidate = aHdl.GetHdl(a);
if(pCandidate->GetObj()
&& pCandidate->GetObj() == pSaveObj
&& pCandidate->GetKind() == eSaveKind
&& pCandidate->GetPolyNum() == nSavePolyNum
&& pCandidate->GetPointNum() == nSavePointNum)
{
aHdl.SetFocusHdl(pCandidate);
break;
}
}
}
}
}
void SdrMarkView::AddCustomHdl()
{
// add custom handles (used by other apps, e.g. AnchorPos)
}
void SdrMarkView::SetDragMode(SdrDragMode eMode)
{
SdrDragMode eMode0=eDragMode;
eDragMode=eMode;
if (eDragMode==SDRDRAG_RESIZE) eDragMode=SDRDRAG_MOVE;
if (eDragMode!=eMode0) {
ForceRefToMarked();
SetMarkHandles();
{
if (AreObjectsMarked()) MarkListHasChanged();
}
}
}
void SdrMarkView::AddDragModeHdl(SdrDragMode eMode)
{
switch(eMode)
{
case SDRDRAG_ROTATE:
{
// add rotation center
SdrHdl* pHdl = new SdrHdl(aRef1, HDL_REF1);
aHdl.AddHdl(pHdl);
break;
}
case SDRDRAG_MIRROR:
{
// add axis of reflection
SdrHdl* pHdl3 = new SdrHdl(aRef2, HDL_REF2);
SdrHdl* pHdl2 = new SdrHdl(aRef1, HDL_REF1);
SdrHdl* pHdl1 = new SdrHdlLine(*pHdl2, *pHdl3, HDL_MIRX);
pHdl1->SetObjHdlNum(1); // for sorting
pHdl2->SetObjHdlNum(2); // for sorting
pHdl3->SetObjHdlNum(3); // for sorting
aHdl.AddHdl(pHdl1); // line comes first, so it is the last in HitTest
aHdl.AddHdl(pHdl2);
aHdl.AddHdl(pHdl3);
break;
}
case SDRDRAG_TRANSPARENCE:
{
// add interactive transparency handle
sal_uIntPtr nMarkAnz = GetMarkedObjectCount();
if(nMarkAnz == 1)
{
SdrObject* pObj = GetMarkedObjectByIndex(0);
SdrModel* pModel = GetModel();
const SfxItemSet& rSet = pObj->GetMergedItemSet();
if(SFX_ITEM_SET != rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE, false))
{
// add this item, it's not yet there
XFillFloatTransparenceItem aNewItem(
(const XFillFloatTransparenceItem&)rSet.Get(XATTR_FILLFLOATTRANSPARENCE));
XGradient aGrad = aNewItem.GetGradientValue();
aNewItem.SetEnabled(true);
aGrad.SetStartIntens(100);
aGrad.SetEndIntens(100);
aNewItem.SetGradientValue(aGrad);
// add undo to allow user to take back this step
if( pModel->IsUndoEnabled() )
{
pModel->BegUndo(SVX_RESSTR(SIP_XA_FILLTRANSPARENCE));
pModel->AddUndo(pModel->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
pModel->EndUndo();
}
SfxItemSet aNewSet(pModel->GetItemPool());
aNewSet.Put(aNewItem);
pObj->SetMergedItemSetAndBroadcast(aNewSet);
}
// set values and transform to vector set
GradTransformer aGradTransformer;
GradTransVector aGradTransVector;
GradTransGradient aGradTransGradient;
aGradTransGradient.aGradient = ((XFillFloatTransparenceItem&)rSet.Get(XATTR_FILLFLOATTRANSPARENCE)).GetGradientValue();
aGradTransformer.GradToVec(aGradTransGradient, aGradTransVector, pObj);
// build handles
const Point aTmpPos1(basegfx::fround(aGradTransVector.maPositionA.getX()), basegfx::fround(aGradTransVector.maPositionA.getY()));
const Point aTmpPos2(basegfx::fround(aGradTransVector.maPositionB.getX()), basegfx::fround(aGradTransVector.maPositionB.getY()));
SdrHdlColor* pColHdl1 = new SdrHdlColor(aTmpPos1, aGradTransVector.aCol1, SDR_HANDLE_COLOR_SIZE_NORMAL, true);
SdrHdlColor* pColHdl2 = new SdrHdlColor(aTmpPos2, aGradTransVector.aCol2, SDR_HANDLE_COLOR_SIZE_NORMAL, true);
SdrHdlGradient* pGradHdl = new SdrHdlGradient(aTmpPos1, aTmpPos2, false);
DBG_ASSERT(pColHdl1 && pColHdl2 && pGradHdl, "Could not get all necessary handles!");
// link them
pGradHdl->SetColorHandles(pColHdl1, pColHdl2);
pGradHdl->SetObj(pObj);
pColHdl1->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
pColHdl2->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
// insert them
aHdl.AddHdl(pColHdl1);
aHdl.AddHdl(pColHdl2);
aHdl.AddHdl(pGradHdl);
}
break;
}
case SDRDRAG_GRADIENT:
{
// add interactive gradient handle
sal_uIntPtr nMarkAnz = GetMarkedObjectCount();
if(nMarkAnz == 1)
{
SdrObject* pObj = GetMarkedObjectByIndex(0);
const SfxItemSet& rSet = pObj->GetMergedItemSet();
XFillStyle eFillStyle = ((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue();
if(eFillStyle == XFILL_GRADIENT)
{
// set values and transform to vector set
GradTransformer aGradTransformer;
GradTransVector aGradTransVector;
GradTransGradient aGradTransGradient;
Size aHdlSize(15, 15);
aGradTransGradient.aGradient = ((XFillGradientItem&)rSet.Get(XATTR_FILLGRADIENT)).GetGradientValue();
aGradTransformer.GradToVec(aGradTransGradient, aGradTransVector, pObj);
// build handles
const Point aTmpPos1(basegfx::fround(aGradTransVector.maPositionA.getX()), basegfx::fround(aGradTransVector.maPositionA.getY()));
const Point aTmpPos2(basegfx::fround(aGradTransVector.maPositionB.getX()), basegfx::fround(aGradTransVector.maPositionB.getY()));
SdrHdlColor* pColHdl1 = new SdrHdlColor(aTmpPos1, aGradTransVector.aCol1, aHdlSize, false);
SdrHdlColor* pColHdl2 = new SdrHdlColor(aTmpPos2, aGradTransVector.aCol2, aHdlSize, false);
SdrHdlGradient* pGradHdl = new SdrHdlGradient(aTmpPos1, aTmpPos2, true);
DBG_ASSERT(pColHdl1 && pColHdl2 && pGradHdl, "Could not get all necessary handles!");
// link them
pGradHdl->SetColorHandles(pColHdl1, pColHdl2);
pGradHdl->SetObj(pObj);
pColHdl1->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
pColHdl2->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
// insert them
aHdl.AddHdl(pColHdl1);
aHdl.AddHdl(pColHdl2);
aHdl.AddHdl(pGradHdl);
}
}
break;
}
case SDRDRAG_CROP:
{
// TODO
break;
}
default: break;
}
}
/** handle mouse over effects for handles */
bool SdrMarkView::MouseMove(const MouseEvent& rMEvt, Window* pWin)
{
if(aHdl.GetHdlCount())
{
SdrHdl* pMouseOverHdl = 0;
if( !rMEvt.IsLeaveWindow() && pWin )
{
Point aMDPos( pWin->PixelToLogic( rMEvt.GetPosPixel() ) );
pMouseOverHdl = PickHandle(aMDPos);
}
// notify last mouse over handle that he lost the mouse
const sal_uIntPtr nHdlCount = aHdl.GetHdlCount();
for(sal_uIntPtr nHdl = 0; nHdl < nHdlCount; nHdl++ )
{
SdrHdl* pCurrentHdl = GetHdl(nHdl);
if( pCurrentHdl->mbMouseOver )
{
if( pCurrentHdl != pMouseOverHdl )
{
pCurrentHdl->mbMouseOver = false;
pCurrentHdl->onMouseLeave();
}
break;
}
}
// notify current mouse over handle
if( pMouseOverHdl )
{
pMouseOverHdl->mbMouseOver = true;
pMouseOverHdl->onMouseEnter(rMEvt);
}
}
return SdrSnapView::MouseMove(rMEvt, pWin);
}
void SdrMarkView::ForceRefToMarked()
{
switch(eDragMode)
{
case SDRDRAG_ROTATE:
{
Rectangle aR(GetMarkedObjRect());
aRef1 = aR.Center();
break;
}
case SDRDRAG_MIRROR:
{
// first calculate the length of the axis of reflection
long nOutMin=0;
long nOutMax=0;
long nMinLen=0;
long nObjDst=0;
long nOutHgt=0;
OutputDevice* pOut=GetFirstOutputDevice();
if (pOut!=NULL) {
// minimum length: 50 pixels
nMinLen=pOut->PixelToLogic(Size(0,50)).Height();
// 20 pixels distance to the Obj for the reference point
nObjDst=pOut->PixelToLogic(Size(0,20)).Height();
// MinY/MaxY
// margin = minimum length = 10 pixels
long nDst=pOut->PixelToLogic(Size(0,10)).Height();
nOutMin=-pOut->GetMapMode().GetOrigin().Y();
nOutMax=pOut->GetOutputSize().Height()-1+nOutMin;
nOutMin+=nDst;
nOutMax-=nDst;
// absolute minimum length, however, is 10 pixels
if (nOutMax-nOutMin<nDst) {
nOutMin+=nOutMax+1;
nOutMin/=2;
nOutMin-=(nDst+1)/2;
nOutMax=nOutMin+nDst;
}
nOutHgt=nOutMax-nOutMin;
// otherwise minimum length = 1/4 OutHgt
long nTemp=nOutHgt/4;
if (nTemp>nMinLen) nMinLen=nTemp;
}
Rectangle aR(GetMarkedObjBoundRect());
Point aCenter(aR.Center());
long nMarkHgt=aR.GetHeight()-1;
long nHgt=nMarkHgt+nObjDst*2; // 20 pixels overlapping above and below
if (nHgt<nMinLen) nHgt=nMinLen; // minimum length 50 pixels or 1/4 OutHgt, respectively
long nY1=aCenter.Y()-(nHgt+1)/2;
long nY2=nY1+nHgt;
if (pOut!=NULL && nMinLen>nOutHgt) nMinLen=nOutHgt; // TODO: maybe shorten this a little
if (pOut!=NULL) { // now move completely into the visible area
if (nY1<nOutMin) {
nY1=nOutMin;
if (nY2<nY1+nMinLen) nY2=nY1+nMinLen;
}
if (nY2>nOutMax) {
nY2=nOutMax;
if (nY1>nY2-nMinLen) nY1=nY2-nMinLen;
}
}
aRef1.X()=aCenter.X();
aRef1.Y()=nY1;
aRef2.X()=aCenter.X();
aRef2.Y()=nY2;
break;
}
case SDRDRAG_TRANSPARENCE:
case SDRDRAG_GRADIENT:
case SDRDRAG_CROP:
{
Rectangle aRect(GetMarkedObjBoundRect());
aRef1 = aRect.TopLeft();
aRef2 = aRect.BottomRight();
break;
}
default: break;
}
}
void SdrMarkView::SetRef1(const Point& rPt)
{
if(eDragMode == SDRDRAG_ROTATE || eDragMode == SDRDRAG_MIRROR)
{
aRef1 = rPt;
SdrHdl* pH = aHdl.GetHdl(HDL_REF1);
if(pH)
pH->SetPos(rPt);
}
}
void SdrMarkView::SetRef2(const Point& rPt)
{
if(eDragMode == SDRDRAG_MIRROR)
{
aRef2 = rPt;
SdrHdl* pH = aHdl.GetHdl(HDL_REF2);
if(pH)
pH->SetPos(rPt);
}
}
void SdrMarkView::CheckMarked()
{
for (sal_uIntPtr nm=GetMarkedObjectCount(); nm>0;) {
nm--;
SdrMark* pM=GetSdrMarkByIndex(nm);
SdrObject* pObj=pM->GetMarkedSdrObj();
SdrPageView* pPV=pM->GetPageView();
SdrLayerID nLay=pObj->GetLayer();
bool bRaus=!pObj->IsInserted(); // Obj deleted?
if (!pObj->Is3DObj()) {
bRaus=bRaus || pObj->GetPage()!=pPV->GetPage(); // Obj suddenly in different Page or Group
}
bRaus=bRaus || pPV->GetLockedLayers().IsSet(nLay) || // Layer locked?
!pPV->GetVisibleLayers().IsSet(nLay); // Layer invisible?
if( !bRaus )
bRaus = !pObj->IsVisible(); // invisible objects can not be selected
if (!bRaus) {
// Grouped objects can now be selected.
// After EnterGroup the higher-level objects,
// have to be deselected, though.
const SdrObjList* pOOL=pObj->GetObjList();
const SdrObjList* pVOL=pPV->GetObjList();
while (pOOL!=NULL && pOOL!=pVOL) {
pOOL=pOOL->GetUpList();
}
bRaus=pOOL!=pVOL;
}
if (bRaus)
{
GetMarkedObjectListWriteAccess().DeleteMark(nm);
}
else
{
if (!IsGluePointEditMode()) { // selected glue points only in GlueEditMode
SdrUShortCont* pPts=pM->GetMarkedGluePoints();
if (pPts!=NULL) {
pPts->clear();
}
}
}
}
// at least reset the remembered BoundRect to prevent handle
// generation if bForceFrameHandles is TRUE.
bMarkedObjRectDirty = true;
}
void SdrMarkView::SetMarkRects()
{
SdrPageView* pPV = GetSdrPageView();
if(pPV)
{
pPV->SetHasMarkedObj(GetSnapRectFromMarkedObjects(pPV, pPV->MarkSnap()));
GetBoundRectFromMarkedObjects(pPV, pPV->MarkBound());
}
}
void SdrMarkView::SetFrameHandles(bool bOn)
{
if (bOn!=bForceFrameHandles) {
bool bOld=ImpIsFrameHandles();
bForceFrameHandles=bOn;
bool bNew=ImpIsFrameHandles();
if (bNew!=bOld) {
AdjustMarkHdl();
MarkListHasChanged();
}
}
}
void SdrMarkView::SetEditMode(SdrViewEditMode eMode)
{
if (eMode!=eEditMode) {
bool bGlue0=eEditMode==SDREDITMODE_GLUEPOINTEDIT;
bool bEdge0=((SdrCreateView*)this)->IsEdgeTool();
eEditMode0=eEditMode;
eEditMode=eMode;
bool bGlue1=eEditMode==SDREDITMODE_GLUEPOINTEDIT;
bool bEdge1=((SdrCreateView*)this)->IsEdgeTool();
// avoid flickering when switching between GlueEdit and EdgeTool
if (bGlue1 && !bGlue0) ImpSetGlueVisible2(bGlue1);
if (bEdge1!=bEdge0) ImpSetGlueVisible3(bEdge1);
if (!bGlue1 && bGlue0) ImpSetGlueVisible2(bGlue1);
if (bGlue0 && !bGlue1) UnmarkAllGluePoints();
}
}
bool SdrMarkView::IsObjMarkable(SdrObject* pObj, SdrPageView* pPV) const
{
if (pObj)
{
if (pObj->IsMarkProtect() ||
(!bDesignMode && pObj->IsUnoObj()))
{
// object not selectable or
// SdrUnoObj not in DesignMode
return false;
}
}
return pPV==NULL || pPV->IsObjMarkable(pObj);
}
bool SdrMarkView::IsMarkedObjHit(const Point& rPnt, short nTol) const
{
bool bRet=false;
nTol=ImpGetHitTolLogic(nTol,NULL);
Point aPt(rPnt);
for (sal_uIntPtr nm=0; nm<GetMarkedObjectCount() && !bRet; nm++) {
SdrMark* pM=GetSdrMarkByIndex(nm);
bRet = 0 != CheckSingleSdrObjectHit(aPt,sal_uInt16(nTol),pM->GetMarkedSdrObj(),pM->GetPageView(),0,0);
}
return bRet;
}
SdrHdl* SdrMarkView::PickHandle(const Point& rPnt, sal_uIntPtr nOptions, SdrHdl* pHdl0) const
{
if (bSomeObjChgdFlag) { // recalculate handles, if necessary
FlushComeBackTimer();
}
bool bBack=(nOptions & SDRSEARCH_BACKWARD) !=0;
bool bNext=(nOptions & SDRSEARCH_NEXT) !=0;
Point aPt(rPnt);
return aHdl.IsHdlListHit(aPt,bBack,bNext,pHdl0);
}
bool SdrMarkView::MarkObj(const Point& rPnt, short nTol, bool bToggle, bool bDeep)
{
SdrObject* pObj;
SdrPageView* pPV;
nTol=ImpGetHitTolLogic(nTol,NULL);
sal_uIntPtr nOptions=SDRSEARCH_PICKMARKABLE;
if (bDeep) nOptions=nOptions|SDRSEARCH_DEEP;
bool bRet=PickObj(rPnt,(sal_uInt16)nTol,pObj,pPV,nOptions);
if (bRet) {
bool bUnmark=bToggle && IsObjMarked(pObj);
MarkObj(pObj,pPV,bUnmark);
}
return bRet;
}
bool SdrMarkView::MarkNextObj(bool bPrev)
{
SdrPageView* pPageView = GetSdrPageView();
if(!pPageView)
{
return false;
}
SortMarkedObjects();
sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
sal_uIntPtr nChgMarkNum = ULONG_MAX; // number of the MarkEntry we want to replace
sal_uIntPtr nSearchObjNum = bPrev ? 0 : ULONG_MAX;
if (nMarkAnz!=0) {
nChgMarkNum=bPrev ? 0 : sal_uIntPtr(nMarkAnz-1);
SdrMark* pM=GetSdrMarkByIndex(nChgMarkNum);
OSL_ASSERT(pM!=NULL);
if (pM->GetMarkedSdrObj() != NULL)
nSearchObjNum = pM->GetMarkedSdrObj()->GetNavigationPosition();
}
SdrObject* pMarkObj=NULL;
SdrObjList* pSearchObjList=pPageView->GetObjList();
sal_uIntPtr nObjAnz=pSearchObjList->GetObjCount();
if (nObjAnz!=0) {
if (nSearchObjNum>nObjAnz) nSearchObjNum=nObjAnz;
while (pMarkObj==NULL && ((!bPrev && nSearchObjNum>0) || (bPrev && nSearchObjNum<nObjAnz)))
{
if (!bPrev)
nSearchObjNum--;
SdrObject* pSearchObj = pSearchObjList->GetObjectForNavigationPosition(nSearchObjNum);
if (IsObjMarkable(pSearchObj,pPageView))
{
if (TryToFindMarkedObject(pSearchObj)==CONTAINER_ENTRY_NOTFOUND)
{
pMarkObj=pSearchObj;
}
}
if (bPrev) nSearchObjNum++;
}
}
if(!pMarkObj)
{
return false;
}
if (nChgMarkNum!=ULONG_MAX)
{
GetMarkedObjectListWriteAccess().DeleteMark(nChgMarkNum);
}
MarkObj(pMarkObj,pPageView); // also calls MarkListHasChanged(), AdjustMarkHdl()
return true;
}
bool SdrMarkView::MarkNextObj(const Point& rPnt, short nTol, bool bPrev)
{
SortMarkedObjects();
nTol=ImpGetHitTolLogic(nTol,NULL);
Point aPt(rPnt);
SdrMark* pTopMarkHit=NULL;
SdrMark* pBtmMarkHit=NULL;
sal_uIntPtr nTopMarkHit=0;
sal_uIntPtr nBtmMarkHit=0;
// find topmost of the selected objects that is hit by rPnt
sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
sal_uIntPtr nm=0;
for (nm=nMarkAnz; nm>0 && pTopMarkHit==NULL;) {
nm--;
SdrMark* pM=GetSdrMarkByIndex(nm);
if(CheckSingleSdrObjectHit(aPt,sal_uInt16(nTol),pM->GetMarkedSdrObj(),pM->GetPageView(),0,0))
{
pTopMarkHit=pM;
nTopMarkHit=nm;
}
}
// nothing found, in this case, just select an object
if (pTopMarkHit==NULL) return MarkObj(rPnt,sal_uInt16(nTol),false);
SdrObject* pTopObjHit=pTopMarkHit->GetMarkedSdrObj();
SdrObjList* pObjList=pTopObjHit->GetObjList();
SdrPageView* pPV=pTopMarkHit->GetPageView();
// find lowermost of the selected objects that is hit by rPnt
// and is placed on the same PageView as pTopMarkHit
for (nm=0; nm<nMarkAnz && pBtmMarkHit==NULL; nm++) {
SdrMark* pM=GetSdrMarkByIndex(nm);
SdrPageView* pPV2=pM->GetPageView();
if (pPV2==pPV && CheckSingleSdrObjectHit(aPt,sal_uInt16(nTol),pM->GetMarkedSdrObj(),pPV2,0,0))
{
pBtmMarkHit=pM;
nBtmMarkHit=nm;
}
}
if (pBtmMarkHit==NULL) { pBtmMarkHit=pTopMarkHit; nBtmMarkHit=nTopMarkHit; }
SdrObject* pBtmObjHit=pBtmMarkHit->GetMarkedSdrObj();
sal_uIntPtr nObjAnz=pObjList->GetObjCount();
sal_uInt32 nSearchBeg;
E3dScene* pScene = NULL;
SdrObject* pObjHit = (bPrev) ? pBtmObjHit : pTopObjHit;
bool bRemap = pObjHit->ISA(E3dCompoundObject)
? ((E3dCompoundObject*)pObjHit)->IsAOrdNumRemapCandidate(pScene)
: false;
if(bPrev)
{
sal_uInt32 nOrdNumBtm(pBtmObjHit->GetOrdNum());
if(bRemap)
{
nOrdNumBtm = pScene->RemapOrdNum(nOrdNumBtm);
}
nSearchBeg = nOrdNumBtm + 1;
}
else
{
sal_uInt32 nOrdNumTop(pTopObjHit->GetOrdNum());
if(bRemap)
{
nOrdNumTop = pScene->RemapOrdNum(nOrdNumTop);
}
nSearchBeg = nOrdNumTop;
}
sal_uIntPtr no=nSearchBeg;
SdrObject* pFndObj=NULL;
while (pFndObj==NULL && ((!bPrev && no>0) || (bPrev && no<nObjAnz))) {
if (!bPrev) no--;
SdrObject* pObj;
if(bRemap)
{
pObj = pObjList->GetObj(pScene->RemapOrdNum(no));
}
else
{
pObj = pObjList->GetObj(no);
}
if (CheckSingleSdrObjectHit(aPt,sal_uInt16(nTol),pObj,pPV,SDRSEARCH_TESTMARKABLE,0))
{
if (TryToFindMarkedObject(pObj)==CONTAINER_ENTRY_NOTFOUND) {
pFndObj=pObj;
} else {
// TODO: for performance reasons set on to Top or Btm, if necessary
}
}
if (bPrev) no++;
}
if (pFndObj!=NULL)
{
GetMarkedObjectListWriteAccess().DeleteMark(bPrev?nBtmMarkHit:nTopMarkHit);
GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pFndObj,pPV));
MarkListHasChanged();
AdjustMarkHdl();
}
return pFndObj!=NULL;
}
bool SdrMarkView::MarkObj(const Rectangle& rRect, bool bUnmark)
{
bool bFnd=false;
Rectangle aR(rRect);
SdrObjList* pObjList;
BrkAction();
SdrPageView* pPV = GetSdrPageView();
if(pPV)
{
pObjList=pPV->GetObjList();
Rectangle aFrm1(aR);
sal_uIntPtr nObjAnz=pObjList->GetObjCount();
SdrObject* pObj;
for (sal_uIntPtr nO=0; nO<nObjAnz; nO++) {
pObj=pObjList->GetObj(nO);
Rectangle aRect(pObj->GetCurrentBoundRect());
if (aFrm1.IsInside(aRect)) {
if (!bUnmark) {
if (IsObjMarkable(pObj,pPV))
{
GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pObj,pPV));
bFnd=true;
}
} else {
sal_uIntPtr nPos=TryToFindMarkedObject(pObj);
if (nPos!=CONTAINER_ENTRY_NOTFOUND)
{
GetMarkedObjectListWriteAccess().DeleteMark(nPos);
bFnd=true;
}
}
}
}
}
if (bFnd) {
SortMarkedObjects();
MarkListHasChanged();
AdjustMarkHdl();
}
return bFnd;
}
void SdrMarkView::MarkObj(SdrObject* pObj, SdrPageView* pPV, bool bUnmark, bool bImpNoSetMarkHdl)
{
if (pObj!=NULL && pPV!=NULL && IsObjMarkable(pObj, pPV)) {
BrkAction();
if (!bUnmark)
{
GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pObj,pPV));
}
else
{
sal_uIntPtr nPos=TryToFindMarkedObject(pObj);
if (nPos!=CONTAINER_ENTRY_NOTFOUND)
{
GetMarkedObjectListWriteAccess().DeleteMark(nPos);
}
}
if (!bImpNoSetMarkHdl) {
MarkListHasChanged();
AdjustMarkHdl();
}
}
}
bool SdrMarkView::IsObjMarked(SdrObject* pObj) const
{
// Hack: Because FindObject() is not const,
// I have to cast myself to non-const.
sal_uIntPtr nPos=((SdrMarkView*)this)->TryToFindMarkedObject(pObj);
return nPos!=CONTAINER_ENTRY_NOTFOUND;
}
sal_uInt16 SdrMarkView::GetMarkHdlSizePixel() const
{
return aHdl.GetHdlSize()*2+1;
}
void SdrMarkView::SetMarkHdlSizePixel(sal_uInt16 nSiz)
{
if (nSiz<3) nSiz=3;
nSiz/=2;
if (nSiz!=aHdl.GetHdlSize()) {
aHdl.SetHdlSize(nSiz);
}
}
#define SDRSEARCH_IMPISMASTER 0x80000000 /* MasterPage is being searched right now */
SdrObject* SdrMarkView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, sal_uIntPtr nOptions, const SetOfByte* pMVisLay) const
{
if(((nOptions & SDRSEARCH_IMPISMASTER) && pObj->IsNotVisibleAsMaster()) || (!pObj->IsVisible()))
{
return NULL;
}
const bool bCheckIfMarkable(nOptions & SDRSEARCH_TESTMARKABLE);
const bool bDeep(nOptions & SDRSEARCH_DEEP);
const bool bOLE(pObj->ISA(SdrOle2Obj));
const bool bTXT(pObj->ISA(SdrTextObj) && ((SdrTextObj*)pObj)->IsTextFrame());
SdrObject* pRet=NULL;
Rectangle aRect(pObj->GetCurrentBoundRect());
// hack for calc grid sync
aRect += pObj->GetGridOffset();
sal_uInt16 nTol2(nTol);
// double tolerance for OLE, text frames and objects in
// active text edit
if(bOLE || bTXT || pObj==((SdrObjEditView*)this)->GetTextEditObject())
{
nTol2*=2;
}
aRect.Left ()-=nTol2; // add 1 tolerance for all objects
aRect.Top ()-=nTol2;
aRect.Right ()+=nTol2;
aRect.Bottom()+=nTol2;
if (aRect.IsInside(rPnt))
{
if ((!bCheckIfMarkable || IsObjMarkable(pObj,pPV)))
{
SdrObjList* pOL=pObj->GetSubList();
if (pOL!=NULL && pOL->GetObjCount()!=0)
{
SdrObject* pTmpObj;
// adjustment hit point for virtual objects
Point aPnt( rPnt );
if ( pObj->ISA(SdrVirtObj) )
{
Point aOffset = static_cast<SdrVirtObj*>(pObj)->GetOffset();
aPnt.Move( -aOffset.X(), -aOffset.Y() );
}
pRet=CheckSingleSdrObjectHit(aPnt,nTol,pOL,pPV,nOptions,pMVisLay,pTmpObj);
}
else
{
if(!pMVisLay || pMVisLay->IsSet(pObj->GetLayer()))
{
pRet = SdrObjectPrimitiveHit(*pObj, rPnt, nTol2, *pPV, &pPV->GetVisibleLayers(), false);
}
}
}
}
if (!bDeep && pRet!=NULL)
{
pRet=pObj;
}
return pRet;
}
SdrObject* SdrMarkView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList* pOL, SdrPageView* pPV, sal_uIntPtr nOptions, const SetOfByte* pMVisLay, SdrObject*& rpRootObj) const
{
return (*this).CheckSingleSdrObjectHit(rPnt,nTol,pOL,pPV,nOptions,pMVisLay,rpRootObj,NULL);
}
SdrObject* SdrMarkView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList* pOL, SdrPageView* pPV, sal_uIntPtr nOptions, const SetOfByte* pMVisLay, SdrObject*& rpRootObj,const SdrMarkList * pMarkList) const
{
bool bBack=(nOptions & SDRSEARCH_BACKWARD)!=0;
bool bBefMrk=(nOptions & SDRSEARCH_BEFOREMARK)!=0;
SdrObject* pRet=NULL;
rpRootObj=NULL;
if (pOL!=NULL)
{
bool bRemap(pOL->GetOwnerObj() && pOL->GetOwnerObj()->ISA(E3dScene));
E3dScene* pRemapScene = (bRemap ? (E3dScene*)pOL->GetOwnerObj() : 0L);
sal_uIntPtr nObjAnz=pOL->GetObjCount();
sal_uIntPtr nObjNum=bBack ? 0 : nObjAnz;
while (pRet==NULL && (bBack ? nObjNum<nObjAnz : nObjNum>0)) {
if (!bBack) nObjNum--;
SdrObject* pObj;
if(bRemap)
{
pObj = pOL->GetObj(pRemapScene->RemapOrdNum(nObjNum));
}
else
{
pObj = pOL->GetObj(nObjNum);
}
if (bBefMrk)
{
if ((pMarkList)!=NULL)
{
if ((*pMarkList).FindObject(pObj)!=CONTAINER_ENTRY_NOTFOUND)
{
return NULL;
}
}
}
pRet=CheckSingleSdrObjectHit(rPnt,nTol,pObj,pPV,nOptions,pMVisLay);
if (pRet!=NULL) rpRootObj=pObj;
if (bBack) nObjNum++;
}
}
return pRet;
}
bool SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, sal_uIntPtr nOptions) const
{
return PickObj(rPnt,nTol,rpObj,rpPV,nOptions,NULL,NULL,NULL);
}
bool SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, sal_uIntPtr nOptions, SdrObject** ppRootObj, sal_uIntPtr* pnMarkNum, sal_uInt16* pnPassNum) const
{ // TODO: lacks a Pass2,Pass3
SortMarkedObjects();
if (ppRootObj!=NULL) *ppRootObj=NULL;
if (pnMarkNum!=NULL) *pnMarkNum=CONTAINER_ENTRY_NOTFOUND;
if (pnPassNum!=NULL) *pnPassNum=0;
rpObj=NULL;
rpPV=NULL;
bool bWholePage=(nOptions & SDRSEARCH_WHOLEPAGE) !=0;
bool bMarked=(nOptions & SDRSEARCH_MARKED) !=0;
bool bMasters=!bMarked && (nOptions & SDRSEARCH_ALSOONMASTER) !=0;
bool bBack=(nOptions & SDRSEARCH_BACKWARD) !=0;
#if OSL_DEBUG_LEVEL > 0
bool bNext=(nOptions & SDRSEARCH_NEXT) !=0; (void)bNext; // n.i.
bool bBoundCheckOn2ndPass=(nOptions & SDRSEARCH_PASS2BOUND) !=0; (void)bBoundCheckOn2ndPass;// n.i.
bool bCheckNearestOn3rdPass=(nOptions & SDRSEARCH_PASS3NEAREST) !=0; (void)bCheckNearestOn3rdPass;// n.i.
#endif
if (nTol<0) nTol=ImpGetHitTolLogic(nTol,NULL);
Point aPt(rPnt);
SdrObject* pObj=NULL;
SdrObject* pHitObj=NULL;
SdrPageView* pPV=NULL;
if (!bBack && ((SdrObjEditView*)this)->IsTextEditFrameHit(rPnt)) {
pObj=((SdrObjEditView*)this)->GetTextEditObject();
pHitObj=pObj;
pPV=((SdrObjEditView*)this)->GetTextEditPageView();
}
if (bMarked) {
sal_uIntPtr nMrkAnz=GetMarkedObjectCount();
sal_uIntPtr nMrkNum=bBack ? 0 : nMrkAnz;
while (pHitObj==NULL && (bBack ? nMrkNum<nMrkAnz : nMrkNum>0)) {
if (!bBack) nMrkNum--;
SdrMark* pM=GetSdrMarkByIndex(nMrkNum);
pObj=pM->GetMarkedSdrObj();
pPV=pM->GetPageView();
pHitObj=CheckSingleSdrObjectHit(aPt,nTol,pObj,pPV,nOptions,NULL);
if (bBack) nMrkNum++;
}
}
else
{
pPV = GetSdrPageView();
if(pPV)
{
SdrPage* pPage=pPV->GetPage();
sal_uInt16 nPgAnz=1;
if(bMasters && pPage->TRG_HasMasterPage())
{
nPgAnz++;
}
bool bExtraPassForWholePage=bWholePage && pPage!=pPV->GetObjList();
if (bExtraPassForWholePage) nPgAnz++; // First search in AktObjList, then on the entire page
sal_uInt16 nPgNum=bBack ? 0 : nPgAnz;
while (pHitObj==NULL && (bBack ? nPgNum<nPgAnz : nPgNum>0)) {
sal_uIntPtr nTmpOptions=nOptions;
if (!bBack) nPgNum--;
const SetOfByte* pMVisLay=NULL;
SdrObjList* pObjList=NULL;
if (pnPassNum!=NULL) *pnPassNum&=~(SDRSEARCHPASS_MASTERPAGE|SDRSEARCHPASS_INACTIVELIST);
if (nPgNum>=nPgAnz-1 || (bExtraPassForWholePage && nPgNum>=nPgAnz-2))
{
pObjList=pPV->GetObjList();
if (bExtraPassForWholePage && nPgNum==nPgAnz-2) {
pObjList=pPage;
if (pnPassNum!=NULL) *pnPassNum|=SDRSEARCHPASS_INACTIVELIST;
}
}
else
{
// otherwise MasterPage
SdrPage& rMasterPage = pPage->TRG_GetMasterPage();
pMVisLay = &pPage->TRG_GetMasterPageVisibleLayers();
pObjList = &rMasterPage;
if (pnPassNum!=NULL) *pnPassNum|=SDRSEARCHPASS_MASTERPAGE;
nTmpOptions=nTmpOptions | SDRSEARCH_IMPISMASTER;
}
pHitObj=CheckSingleSdrObjectHit(aPt,nTol,pObjList,pPV,nTmpOptions,pMVisLay,pObj,&(GetMarkedObjectList()));
if (bBack) nPgNum++;
}
}
}
if (pHitObj!=NULL) {
if (ppRootObj!=NULL) *ppRootObj=pObj;
if ((nOptions & SDRSEARCH_DEEP) !=0) pObj=pHitObj;
if ((nOptions & SDRSEARCH_TESTTEXTEDIT) !=0) {
if (!pObj->HasTextEdit() || pPV->GetLockedLayers().IsSet(pObj->GetLayer())) {
pObj=NULL;
}
}
if (pObj!=NULL && (nOptions & SDRSEARCH_TESTMACRO) !=0) {
SdrObjMacroHitRec aHitRec;
aHitRec.aPos=aPt;
aHitRec.aDownPos=aPt;
aHitRec.nTol=nTol;
aHitRec.pVisiLayer=&pPV->GetVisibleLayers();
aHitRec.pPageView=pPV;
if (!pObj->HasMacro() || !pObj->IsMacroHit(aHitRec)) pObj=NULL;
}
if (pObj!=NULL && (nOptions & SDRSEARCH_WITHTEXT) !=0 && pObj->GetOutlinerParaObject()==NULL) pObj=NULL;
if (pObj!=NULL && (nOptions & SDRSEARCH_TESTTEXTAREA) !=0 && pPV)
{
if(!SdrObjectPrimitiveHit(*pObj, aPt, 0, *pPV, 0, true))
{
pObj = 0;
}
}
if (pObj!=NULL) {
rpObj=pObj;
rpPV=pPV;
if (pnPassNum!=NULL) *pnPassNum|=SDRSEARCHPASS_DIRECT;
}
}
return rpObj!=NULL;
}
bool SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageView*& rpPV, sal_uIntPtr* pnMarkNum, sal_uIntPtr nOptions) const
{
SortMarkedObjects();
bool bBoundCheckOn2ndPass=(nOptions & SDRSEARCH_PASS2BOUND) !=0;
bool bCheckNearestOn3rdPass=(nOptions & SDRSEARCH_PASS3NEAREST) !=0;
rpObj=NULL;
rpPV=NULL;
if (pnMarkNum!=NULL) *pnMarkNum=CONTAINER_ENTRY_NOTFOUND;
Point aPt(rPnt);
sal_uInt16 nTol=(sal_uInt16)nHitTolLog;
bool bFnd=false;
sal_uIntPtr nMarkAnz=GetMarkedObjectCount();
sal_uIntPtr nMarkNum;
for (nMarkNum=nMarkAnz; nMarkNum>0 && !bFnd;) {
nMarkNum--;
SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
SdrPageView* pPV=pM->GetPageView();
SdrObject* pObj=pM->GetMarkedSdrObj();
bFnd = 0 != CheckSingleSdrObjectHit(aPt,nTol,pObj,pPV,SDRSEARCH_TESTMARKABLE,0);
if (bFnd) {
rpObj=pObj;
rpPV=pPV;
if (pnMarkNum!=NULL) *pnMarkNum=nMarkNum;
}
}
if ((bBoundCheckOn2ndPass || bCheckNearestOn3rdPass) && !bFnd) {
SdrObject* pBestObj=NULL;
SdrPageView* pBestPV=NULL;
sal_uIntPtr nBestMarkNum=0;
sal_uIntPtr nBestDist=ULONG_MAX;
for (nMarkNum=nMarkAnz; nMarkNum>0 && !bFnd;) {
nMarkNum--;
SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
SdrPageView* pPV=pM->GetPageView();
SdrObject* pObj=pM->GetMarkedSdrObj();
Rectangle aRect(pObj->GetCurrentBoundRect());
aRect.Left ()-=nTol;
aRect.Top ()-=nTol;
aRect.Right ()+=nTol;
aRect.Bottom()+=nTol;
if (aRect.IsInside(aPt)) {
bFnd=true;
rpObj=pObj;
rpPV=pPV;
if (pnMarkNum!=NULL) *pnMarkNum=nMarkNum;
} else if (bCheckNearestOn3rdPass) {
sal_uIntPtr nDist=0;
if (aPt.X()<aRect.Left()) nDist+=aRect.Left()-aPt.X();
if (aPt.X()>aRect.Right()) nDist+=aPt.X()-aRect.Right();
if (aPt.Y()<aRect.Top()) nDist+=aRect.Top()-aPt.Y();
if (aPt.Y()>aRect.Bottom()) nDist+=aPt.Y()-aRect.Bottom();
if (nDist<nBestDist) {
pBestObj=pObj;
pBestPV=pPV;
nBestMarkNum=nMarkNum;
}
}
}
if (bCheckNearestOn3rdPass && !bFnd) {
rpObj=pBestObj;
rpPV=pBestPV;
if (pnMarkNum!=NULL) *pnMarkNum=nBestMarkNum;
bFnd=pBestObj!=NULL;
}
}
return bFnd;
}
void SdrMarkView::UnmarkAllObj(SdrPageView* pPV)
{
if (GetMarkedObjectCount()!=0) {
BrkAction();
if (pPV!=NULL)
{
GetMarkedObjectListWriteAccess().DeletePageView(*pPV);
}
else
{
GetMarkedObjectListWriteAccess().Clear();
}
pMarkedObj=NULL;
pMarkedPV=NULL;
MarkListHasChanged();
AdjustMarkHdl();
}
}
void SdrMarkView::MarkAllObj(SdrPageView* _pPV)
{
BrkAction();
if(!_pPV)
{
_pPV = GetSdrPageView();
}
// #i69171# _pPV may still be NULL if there is no SDrPageView (!), e.g. when inserting
// other files
if(_pPV)
{
const bool bMarkChg(GetMarkedObjectListWriteAccess().InsertPageView(*_pPV));
if(bMarkChg)
{
MarkListHasChanged();
}
}
if(GetMarkedObjectCount())
{
AdjustMarkHdl();
}
}
void SdrMarkView::AdjustMarkHdl()
{
CheckMarked();
SetMarkRects();
SetMarkHandles();
}
Rectangle SdrMarkView::GetMarkedObjBoundRect() const
{
Rectangle aRect;
for (sal_uIntPtr nm=0; nm<GetMarkedObjectCount(); nm++) {
SdrMark* pM=GetSdrMarkByIndex(nm);
SdrObject* pO=pM->GetMarkedSdrObj();
Rectangle aR1(pO->GetCurrentBoundRect());
// Ensure marked area includes the calc offset
// ( if applicable ) to sync to grid
aR1 += pO->GetGridOffset();
if (aRect.IsEmpty()) aRect=aR1;
else aRect.Union(aR1);
}
return aRect;
}
Point SdrMarkView::GetGridOffset() const
{
Point aOffset;
// calculate the area occupied by the union of each marked object
// ( synced to grid ) and compare to the same unsynced area to calculate
// the offset. Hopefully that's the sensible thing to do
const Rectangle& aGroupSyncedRect = GetMarkedObjRect();
aOffset = aGroupSyncedRect.TopLeft() - aMarkedObjRectNoOffset.TopLeft();
return aOffset;
}
const Rectangle& SdrMarkView::GetMarkedObjRect() const
{
if (bMarkedObjRectDirty) {
((SdrMarkView*)this)->bMarkedObjRectDirty=false;
Rectangle aRect;
Rectangle aRect2;
for (sal_uIntPtr nm=0; nm<GetMarkedObjectCount(); nm++) {
SdrMark* pM=GetSdrMarkByIndex(nm);
SdrObject* pO=pM->GetMarkedSdrObj();
Rectangle aR1(pO->GetSnapRect());
// apply calc offset to marked object rect
// ( necessary for handles to be displayed in
// correct position )
if (aRect2.IsEmpty()) aRect2=aR1;
else aRect2.Union( aR1 );
aR1 += pO->GetGridOffset();
if (aRect.IsEmpty()) aRect=aR1;
else aRect.Union(aR1);
}
((SdrMarkView*)this)->aMarkedObjRect=aRect;
((SdrMarkView*)this)->aMarkedObjRectNoOffset=aRect2;
}
return aMarkedObjRect;
}
void SdrMarkView::ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, OUString& rStr, sal_uInt16 nVal, sal_uInt16 nOpt) const
{
rStr = ImpGetResStr(nStrCacheID);
sal_Int32 nPos = rStr.indexOf("%1");
if(nPos != -1)
{
if(nOpt == IMPSDR_POINTSDESCRIPTION)
{
rStr = rStr.replaceAt(nPos, 2, GetDescriptionOfMarkedPoints());
}
else if(nOpt == IMPSDR_GLUEPOINTSDESCRIPTION)
{
rStr = rStr.replaceAt(nPos, 2, GetDescriptionOfMarkedGluePoints());
}
else
{
rStr = rStr.replaceAt(nPos, 2, GetDescriptionOfMarkedObjects());
}
}
rStr = rStr.replaceFirst("%2", OUString::number( nVal ));
}
bool SdrMarkView::EnterMarkedGroup()
{
bool bRet=false;
// We enter only the first group found (in only one PageView), because
// PageView::EnterGroup calls an AdjustMarkHdl.
// TODO: I'll have to prevent that via a flag.
SdrPageView* pPV = GetSdrPageView();
if(pPV)
{
bool bEnter=false;
for (sal_uInt32 nm(GetMarkedObjectCount()); nm > 0 && !bEnter;)
{
nm--;
SdrMark* pM=GetSdrMarkByIndex(nm);
if (pM->GetPageView()==pPV) {
SdrObject* pObj=pM->GetMarkedSdrObj();
if (pObj->IsGroupObject()) {
if (pPV->EnterGroup(pObj)) {
bRet=true;
bEnter=true;
}
}
}
}
}
return bRet;
}
void SdrMarkView::MarkListHasChanged()
{
GetMarkedObjectListWriteAccess().SetNameDirty();
SetEdgesOfMarkedNodesDirty();
bMarkedObjRectDirty=true;
bMarkedPointsRectsDirty=true;
#ifdef DBG_UTIL
if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
#endif
bool bOneEdgeMarked=false;
if (GetMarkedObjectCount()==1) {
const SdrObject* pObj=GetMarkedObjectByIndex(0);
if (pObj->GetObjInventor()==SdrInventor) {
sal_uInt16 nIdent=pObj->GetObjIdentifier();
bOneEdgeMarked=nIdent==OBJ_EDGE;
}
}
ImpSetGlueVisible4(bOneEdgeMarked);
}
void SdrMarkView::SetMoveOutside(bool bOn)
{
aHdl.SetMoveOutside(bOn);
}
void SdrMarkView::SetDesignMode( bool _bOn )
{
if ( bDesignMode != _bOn )
{
bDesignMode = _bOn;
SdrPageView* pPageView = GetSdrPageView();
if ( pPageView )
pPageView->SetDesignMode( _bOn );
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|