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
|
/* -*- 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 <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/accessibility/AccessibleTextType.hpp>
#include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
#include <com/sun/star/accessibility/AccessibleEventObject.hpp>
#include <com/sun/star/awt/FocusEvent.hpp>
#include <com/sun/star/awt/XFocusListener.hpp>
#include <unotools/accessiblerelationsethelper.hxx>
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
#include <com/sun/star/i18n/WordType.hpp>
#include <unotools/accessiblestatesethelper.hxx>
#include <comphelper/accessibleeventnotifier.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <osl/diagnose.h>
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
#include <vcl/unohelp2.hxx>
#include <vcl/settings.hxx>
#include <tools/gen.hxx>
#include <osl/mutex.hxx>
#include <svl/itemset.hxx>
#include <editeng/editobj.hxx>
#include <editeng/editdata.hxx>
#include <editeng/editview.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/outliner.hxx>
#include <editeng/unoedhlp.hxx>
#include "accessibility.hxx"
#include <unomodel.hxx>
#include <document.hxx>
#include <view.hxx>
using namespace com::sun::star;
using namespace com::sun::star::lang;
using namespace com::sun::star::uno;
using namespace com::sun::star::accessibility;
static awt::Rectangle lcl_GetBounds( Window *pWin )
{
// !! see VCLXAccessibleComponent::implGetBounds()
//! the coordinates returned are relativ to the parent window !
//! Thus the top-left point may be different from (0, 0) !
awt::Rectangle aBounds;
if (pWin)
{
Rectangle aRect = pWin->GetWindowExtentsRelative( NULL );
aBounds.X = aRect.Left();
aBounds.Y = aRect.Top();
aBounds.Width = aRect.GetWidth();
aBounds.Height = aRect.GetHeight();
Window* pParent = pWin->GetAccessibleParentWindow();
if (pParent)
{
Rectangle aParentRect = pParent->GetWindowExtentsRelative( NULL );
awt::Point aParentScreenLoc( aParentRect.Left(), aParentRect.Top() );
aBounds.X -= aParentScreenLoc.X;
aBounds.Y -= aParentScreenLoc.Y;
}
}
return aBounds;
}
static awt::Point lcl_GetLocationOnScreen( Window *pWin )
{
// !! see VCLXAccessibleComponent::getLocationOnScreen()
awt::Point aPos;
if (pWin)
{
Rectangle aRect = pWin->GetWindowExtentsRelative( NULL );
aPos.X = aRect.Left();
aPos.Y = aRect.Top();
}
return aPos;
}
SmGraphicAccessible::SmGraphicAccessible( SmGraphicWindow *pGraphicWin ) :
aAccName (SM_RESSTR(RID_DOCUMENTSTR)),
nClientId (0),
pWin (pGraphicWin)
{
OSL_ENSURE( pWin, "SmGraphicAccessible: window missing" );
}
SmGraphicAccessible::SmGraphicAccessible( const SmGraphicAccessible &rSmAcc ) :
SmGraphicAccessibleBaseClass(),
aAccName (SM_RESSTR(RID_DOCUMENTSTR)),
nClientId (0)
{
pWin = rSmAcc.pWin;
OSL_ENSURE( pWin, "SmGraphicAccessible: window missing" );
}
SmGraphicAccessible::~SmGraphicAccessible()
{
}
SmDocShell * SmGraphicAccessible::GetDoc_Impl()
{
SmViewShell *pView = pWin ? pWin->GetView() : 0;
return pView ? pView->GetDoc() : 0;
}
OUString SmGraphicAccessible::GetAccessibleText_Impl()
{
OUString aTxt;
SmDocShell *pDoc = GetDoc_Impl();
if (pDoc)
aTxt = pDoc->GetAccessibleText();
return aTxt;
}
void SmGraphicAccessible::ClearWin()
{
pWin = 0; // implicitly results in AccessibleStateType::DEFUNC set
if ( nClientId )
{
comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, *this );
nClientId = 0;
}
}
void SmGraphicAccessible::LaunchEvent(
const sal_Int16 nAccesibleEventId,
const uno::Any &rOldVal,
const uno::Any &rNewVal)
{
AccessibleEventObject aEvt;
aEvt.Source = (XAccessible *) this;
aEvt.EventId = nAccesibleEventId;
aEvt.OldValue = rOldVal;
aEvt.NewValue = rNewVal ;
// pass event on to event-listener's
if (nClientId)
comphelper::AccessibleEventNotifier::addEvent( nClientId, aEvt );
}
uno::Reference< XAccessibleContext > SAL_CALL SmGraphicAccessible::getAccessibleContext()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return this;
}
sal_Bool SAL_CALL SmGraphicAccessible::containsPoint( const awt::Point& aPoint )
throw (RuntimeException, std::exception)
{
//! the arguments coordinates are relativ to the current window !
//! Thus the top-left point is (0, 0)
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
Size aSz( pWin->GetSizePixel() );
return aPoint.X >= 0 && aPoint.Y >= 0 &&
aPoint.X < aSz.Width() && aPoint.Y < aSz.Height();
}
uno::Reference< XAccessible > SAL_CALL SmGraphicAccessible::getAccessibleAtPoint(
const awt::Point& aPoint )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
XAccessible *pRes = 0;
if (containsPoint( aPoint ))
pRes = this;
return pRes;
}
awt::Rectangle SAL_CALL SmGraphicAccessible::getBounds()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
"mismatch of window parent and accessible parent" );
return lcl_GetBounds( pWin );
}
awt::Point SAL_CALL SmGraphicAccessible::getLocation()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
"mismatch of window parent and accessible parent" );
awt::Rectangle aRect( lcl_GetBounds( pWin ) );
return awt::Point( aRect.X, aRect.Y );
}
awt::Point SAL_CALL SmGraphicAccessible::getLocationOnScreen()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
"mismatch of window parent and accessible parent" );
return lcl_GetLocationOnScreen( pWin );
}
awt::Size SAL_CALL SmGraphicAccessible::getSize()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
"mismatch of window parent and accessible parent" );
Size aSz( pWin->GetSizePixel() );
#if OSL_DEBUG_LEVEL > 1
awt::Rectangle aRect( lcl_GetBounds( pWin ) );
Size aSz2( aRect.Width, aRect.Height );
OSL_ENSURE( aSz == aSz2, "mismatch in width" );
#endif
return awt::Size( aSz.Width(), aSz.Height() );
}
void SAL_CALL SmGraphicAccessible::grabFocus()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
pWin->GrabFocus();
}
sal_Int32 SAL_CALL SmGraphicAccessible::getForeground()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
return (sal_Int32) pWin->GetTextColor().GetColor();
}
sal_Int32 SAL_CALL SmGraphicAccessible::getBackground()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
Wallpaper aWall( pWin->GetDisplayBackground() );
ColorData nCol;
if (aWall.IsBitmap() || aWall.IsGradient())
nCol = pWin->GetSettings().GetStyleSettings().GetWindowColor().GetColor();
else
nCol = aWall.GetColor().GetColor();
return (sal_Int32) nCol;
}
sal_Int32 SAL_CALL SmGraphicAccessible::getAccessibleChildCount()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return 0;
}
Reference< XAccessible > SAL_CALL SmGraphicAccessible::getAccessibleChild(
sal_Int32 /*i*/ )
throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
throw IndexOutOfBoundsException(); // there is no child...
}
Reference< XAccessible > SAL_CALL SmGraphicAccessible::getAccessibleParent()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
Window *pAccParent = pWin->GetAccessibleParentWindow();
OSL_ENSURE( pAccParent, "accessible parent missing" );
return pAccParent ? pAccParent->GetAccessible() : Reference< XAccessible >();
}
sal_Int32 SAL_CALL SmGraphicAccessible::getAccessibleIndexInParent()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 nIdx = -1;
Window *pAccParent = pWin ? pWin->GetAccessibleParentWindow() : 0;
if (pAccParent)
{
sal_uInt16 nCnt = pAccParent->GetAccessibleChildWindowCount();
for (sal_uInt16 i = 0; i < nCnt && nIdx == -1; ++i)
if (pAccParent->GetAccessibleChildWindow( i ) == pWin)
nIdx = i;
}
return nIdx;
}
sal_Int16 SAL_CALL SmGraphicAccessible::getAccessibleRole()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return AccessibleRole::DOCUMENT;
}
OUString SAL_CALL SmGraphicAccessible::getAccessibleDescription()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
SmDocShell *pDoc = GetDoc_Impl();
return pDoc ? OUString(pDoc->GetText()) : OUString();
}
OUString SAL_CALL SmGraphicAccessible::getAccessibleName()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return aAccName;
}
Reference< XAccessibleRelationSet > SAL_CALL SmGraphicAccessible::getAccessibleRelationSet()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
Reference< XAccessibleRelationSet > xRelSet = new utl::AccessibleRelationSetHelper();
return xRelSet; // empty relation set
}
Reference< XAccessibleStateSet > SAL_CALL SmGraphicAccessible::getAccessibleStateSet()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
::utl::AccessibleStateSetHelper *pStateSet =
new ::utl::AccessibleStateSetHelper;
Reference<XAccessibleStateSet> xStateSet( pStateSet );
if (!pWin)
pStateSet->AddState( AccessibleStateType::DEFUNC );
else
{
pStateSet->AddState( AccessibleStateType::ENABLED );
pStateSet->AddState( AccessibleStateType::FOCUSABLE );
if (pWin->HasFocus())
pStateSet->AddState( AccessibleStateType::FOCUSED );
if (pWin->IsActive())
pStateSet->AddState( AccessibleStateType::ACTIVE );
if (pWin->IsVisible())
pStateSet->AddState( AccessibleStateType::SHOWING );
if (pWin->IsReallyVisible())
pStateSet->AddState( AccessibleStateType::VISIBLE );
if (COL_TRANSPARENT != pWin->GetBackground().GetColor().GetColor())
pStateSet->AddState( AccessibleStateType::OPAQUE );
}
return xStateSet;
}
Locale SAL_CALL SmGraphicAccessible::getLocale()
throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
// should be the document language...
// We use the language of the localized symbol names here.
return Application::GetSettings().GetUILanguageTag().getLocale();
}
void SAL_CALL SmGraphicAccessible::addAccessibleEventListener(
const Reference< XAccessibleEventListener >& xListener )
throw (RuntimeException, std::exception)
{
if (xListener.is())
{
SolarMutexGuard aGuard;
if (pWin)
{
if (!nClientId)
nClientId = comphelper::AccessibleEventNotifier::registerClient( );
comphelper::AccessibleEventNotifier::addEventListener( nClientId, xListener );
}
}
}
void SAL_CALL SmGraphicAccessible::removeAccessibleEventListener(
const Reference< XAccessibleEventListener >& xListener )
throw (RuntimeException, std::exception)
{
if (xListener.is())
{
SolarMutexGuard aGuard;
sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( nClientId, xListener );
if ( !nListenerCount )
{
// no listeners anymore
// -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
// and at least to us not firing any events anymore, in case somebody calls
// NotifyAccessibleEvent, again
comphelper::AccessibleEventNotifier::revokeClient( nClientId );
nClientId = 0;
}
}
}
sal_Int32 SAL_CALL SmGraphicAccessible::getCaretPosition()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return 0;
}
sal_Bool SAL_CALL SmGraphicAccessible::setCaretPosition( sal_Int32 nIndex )
throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
OUString aTxt( GetAccessibleText_Impl() );
if (!(nIndex < aTxt.getLength()))
throw IndexOutOfBoundsException();
return sal_False;
}
sal_Unicode SAL_CALL SmGraphicAccessible::getCharacter( sal_Int32 nIndex )
throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
OUString aTxt( GetAccessibleText_Impl() );
if (!(nIndex < aTxt.getLength()))
throw IndexOutOfBoundsException();
return aTxt[nIndex];
}
Sequence< beans::PropertyValue > SAL_CALL SmGraphicAccessible::getCharacterAttributes(
sal_Int32 nIndex,
const uno::Sequence< OUString > & /*rRequestedAttributes*/ )
throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 nLen = GetAccessibleText_Impl().getLength();
if (!(0 <= nIndex && nIndex < nLen))
throw IndexOutOfBoundsException();
return Sequence< beans::PropertyValue >();
}
awt::Rectangle SAL_CALL SmGraphicAccessible::getCharacterBounds( sal_Int32 nIndex )
throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
awt::Rectangle aRes;
if (!pWin)
throw RuntimeException();
else
{
// get accessible text
SmViewShell *pView = pWin->GetView();
SmDocShell *pDoc = pView ? pView->GetDoc() : 0;
if (!pDoc)
throw RuntimeException();
OUString aTxt( GetAccessibleText_Impl() );
if (!(0 <= nIndex && nIndex <= aTxt.getLength())) // aTxt.getLength() is valid
throw IndexOutOfBoundsException();
// find a reasonable rectangle for position aTxt.getLength().
bool bWasBehindText = (nIndex == aTxt.getLength());
if (bWasBehindText && nIndex)
--nIndex;
const SmNode *pTree = pDoc->GetFormulaTree();
const SmNode *pNode = pTree->FindNodeWithAccessibleIndex( nIndex );
//! pNode may be 0 if the index belongs to a char that was inserted
//! only for the accessible text!
if (pNode)
{
sal_Int32 nAccIndex = pNode->GetAccessibleIndex();
OSL_ENSURE( nAccIndex >= 0, "invalid accessible index" );
OSL_ENSURE( nIndex >= nAccIndex, "index out of range" );
OUStringBuffer aBuf;
pNode->GetAccessibleText(aBuf);
OUString aNodeText = aBuf.makeStringAndClear();
sal_Int32 nNodeIndex = nIndex - nAccIndex;
if (0 <= nNodeIndex && nNodeIndex < aNodeText.getLength())
{
// get appropriate rectangle
Point aOffset(pNode->GetTopLeft() - pTree->GetTopLeft());
Point aTLPos (pWin->GetFormulaDrawPos() + aOffset);
aTLPos.X() -= 0;
Size aSize (pNode->GetSize());
sal_Int32 *pXAry = new sal_Int32[ aNodeText.getLength() ];
pWin->SetFont( pNode->GetFont() );
pWin->GetTextArray( aNodeText, pXAry, 0, aNodeText.getLength() );
aTLPos.X() += nNodeIndex > 0 ? pXAry[nNodeIndex - 1] : 0;
aSize.Width() = nNodeIndex > 0 ? pXAry[nNodeIndex] - pXAry[nNodeIndex - 1] : pXAry[nNodeIndex];
delete[] pXAry;
aTLPos = pWin->LogicToPixel( aTLPos );
aSize = pWin->LogicToPixel( aSize );
aRes.X = aTLPos.X();
aRes.Y = aTLPos.Y();
aRes.Width = aSize.Width();
aRes.Height = aSize.Height();
}
}
// take rectangle from last character and move it to the right
if (bWasBehindText)
aRes.X += aRes.Width;
}
return aRes;
}
sal_Int32 SAL_CALL SmGraphicAccessible::getCharacterCount()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return GetAccessibleText_Impl().getLength();
}
sal_Int32 SAL_CALL SmGraphicAccessible::getIndexAtPoint( const awt::Point& aPoint )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 nRes = -1;
if (pWin)
{
const SmNode *pTree = pWin->GetView()->GetDoc()->GetFormulaTree();
// can be NULL! e.g. if one clicks within the window already during loading of the
// document (before the parser even started)
if (!pTree)
return nRes;
// get position relative to formula draw position
Point aPos( aPoint.X, aPoint.Y );
aPos = pWin->PixelToLogic( aPos );
aPos -= pWin->GetFormulaDrawPos();
// if it was inside the formula then get the appropriate node
const SmNode *pNode = 0;
if (pTree->OrientedDist(aPos) <= 0)
pNode = pTree->FindRectClosestTo(aPos);
if (pNode)
{
// get appropriate rectangle
Point aOffset( pNode->GetTopLeft() - pTree->GetTopLeft() );
Point aTLPos ( aOffset );
aTLPos.X() -= 0;
Size aSize( pNode->GetSize() );
Rectangle aRect( aTLPos, aSize );
if (aRect.IsInside( aPos ))
{
OSL_ENSURE( pNode->IsVisible(), "node is not a leaf" );
OUStringBuffer aBuf;
pNode->GetAccessibleText(aBuf);
OUString aTxt = aBuf.makeStringAndClear();
OSL_ENSURE( !aTxt.isEmpty(), "no accessible text available" );
long nNodeX = pNode->GetLeft();
sal_Int32 *pXAry = new sal_Int32[ aTxt.getLength() ];
pWin->SetFont( pNode->GetFont() );
pWin->GetTextArray( aTxt, pXAry, 0, aTxt.getLength() );
for (sal_Int32 i = 0; i < aTxt.getLength() && nRes == -1; ++i)
{
if (pXAry[i] + nNodeX > aPos.X())
nRes = i;
}
delete[] pXAry;
OSL_ENSURE( nRes >= 0 && nRes < aTxt.getLength(), "index out of range" );
OSL_ENSURE( pNode->GetAccessibleIndex() >= 0,
"invalid accessible index" );
nRes = pNode->GetAccessibleIndex() + nRes;
}
}
}
return nRes;
}
OUString SAL_CALL SmGraphicAccessible::getSelectedText()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return OUString();
}
sal_Int32 SAL_CALL SmGraphicAccessible::getSelectionStart()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return -1;
}
sal_Int32 SAL_CALL SmGraphicAccessible::getSelectionEnd()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return -1;
}
sal_Bool SAL_CALL SmGraphicAccessible::setSelection(
sal_Int32 nStartIndex,
sal_Int32 nEndIndex )
throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 nLen = GetAccessibleText_Impl().getLength();
if (!(0 <= nStartIndex && nStartIndex < nLen) ||
!(0 <= nEndIndex && nEndIndex < nLen))
throw IndexOutOfBoundsException();
return sal_False;
}
OUString SAL_CALL SmGraphicAccessible::getText()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return GetAccessibleText_Impl();
}
OUString SAL_CALL SmGraphicAccessible::getTextRange(
sal_Int32 nStartIndex,
sal_Int32 nEndIndex )
throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
//!! nEndIndex may be the string length per definition of the interface !!
//!! text should be copied exclusive that end index though. And arguments
//!! may be switched.
SolarMutexGuard aGuard;
OUString aTxt( GetAccessibleText_Impl() );
sal_Int32 nStart = std::min(nStartIndex, nEndIndex);
sal_Int32 nEnd = std::max(nStartIndex, nEndIndex);
if (!(nStart <= aTxt.getLength()) ||
!(nEnd <= aTxt.getLength()))
throw IndexOutOfBoundsException();
return aTxt.copy( nStart, nEnd - nStart );
}
::com::sun::star::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
OUString aTxt( GetAccessibleText_Impl() );
//!! nIndex is allowed to be the string length
if (!(nIndex <= aTxt.getLength()))
throw IndexOutOfBoundsException();
::com::sun::star::accessibility::TextSegment aResult;
aResult.SegmentStart = -1;
aResult.SegmentEnd = -1;
if ( (AccessibleTextType::CHARACTER == aTextType) && (nIndex < aTxt.getLength()) )
{
aResult.SegmentText = aTxt.copy(nIndex, 1);
aResult.SegmentStart = nIndex;
aResult.SegmentEnd = nIndex+1;
}
return aResult;
}
::com::sun::star::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
OUString aTxt( GetAccessibleText_Impl() );
//!! nIndex is allowed to be the string length
if (!(nIndex <= aTxt.getLength()))
throw IndexOutOfBoundsException();
::com::sun::star::accessibility::TextSegment aResult;
aResult.SegmentStart = -1;
aResult.SegmentEnd = -1;
if ( (AccessibleTextType::CHARACTER == aTextType) && nIndex )
{
aResult.SegmentText = aTxt.copy(nIndex-1, 1);
aResult.SegmentStart = nIndex-1;
aResult.SegmentEnd = nIndex;
}
return aResult;
}
::com::sun::star::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
OUString aTxt( GetAccessibleText_Impl() );
//!! nIndex is allowed to be the string length
if (!(nIndex <= aTxt.getLength()))
throw IndexOutOfBoundsException();
::com::sun::star::accessibility::TextSegment aResult;
aResult.SegmentStart = -1;
aResult.SegmentEnd = -1;
nIndex++; // text *behind*
if ( (AccessibleTextType::CHARACTER == aTextType) && (nIndex < aTxt.getLength()) )
{
aResult.SegmentText = aTxt.copy(nIndex, 1);
aResult.SegmentStart = nIndex;
aResult.SegmentEnd = nIndex+1;
}
return aResult;
}
sal_Bool SAL_CALL SmGraphicAccessible::copyText(
sal_Int32 nStartIndex,
sal_Int32 nEndIndex )
throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
bool bReturn = false;
if (!pWin)
throw RuntimeException();
else
{
Reference< datatransfer::clipboard::XClipboard > xClipboard = pWin->GetClipboard();
if ( xClipboard.is() )
{
OUString sText( getTextRange(nStartIndex, nEndIndex) );
::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
const sal_uInt32 nRef = Application::ReleaseSolarMutex();
xClipboard->setContents( pDataObj, NULL );
Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
if( xFlushableClipboard.is() )
xFlushableClipboard->flushClipboard();
Application::AcquireSolarMutex( nRef );
bReturn = true;
}
}
return bReturn;
}
OUString SAL_CALL SmGraphicAccessible::getImplementationName()
throw (RuntimeException, std::exception)
{
return OUString("SmGraphicAccessible");
}
sal_Bool SAL_CALL SmGraphicAccessible::supportsService(
const OUString& rServiceName )
throw (RuntimeException, std::exception)
{
return cppu::supportsService(this, rServiceName);
}
Sequence< OUString > SAL_CALL SmGraphicAccessible::getSupportedServiceNames()
throw (RuntimeException, std::exception)
{
Sequence< OUString > aNames(4);
OUString *pNames = aNames.getArray();
pNames[0] = "com::sun::star::accessibility::Accessible";
pNames[1] = "com::sun::star::accessibility::AccessibleComponent";
pNames[2] = "com::sun::star::accessibility::AccessibleContext";
pNames[3] = "com::sun::star::accessibility::AccessibleText";
return aNames;
}
SmEditSource::SmEditSource( SmEditWindow * /*pWin*/, SmEditAccessible &rAcc ) :
aViewFwd (rAcc),
aTextFwd (rAcc, *this),
aEditViewFwd(rAcc),
rEditAcc (rAcc)
{
}
SmEditSource::SmEditSource( const SmEditSource &rSrc ) :
SvxEditSource(),
aViewFwd (rSrc.rEditAcc),
aTextFwd (rSrc.rEditAcc, *this),
aEditViewFwd(rSrc.rEditAcc),
rEditAcc (rSrc.rEditAcc)
{
}
SmEditSource::~SmEditSource()
{
}
SvxEditSource* SmEditSource::Clone() const
{
return new SmEditSource( *this );
}
SvxTextForwarder* SmEditSource::GetTextForwarder()
{
return &aTextFwd;
}
SvxViewForwarder* SmEditSource::GetViewForwarder()
{
return &aViewFwd;
}
SvxEditViewForwarder* SmEditSource::GetEditViewForwarder( bool /*bCreate*/ )
{
return &aEditViewFwd;
}
void SmEditSource::UpdateData()
{
// would possibly only by needed if the XText interface is implemented
// and its text needs to be updated.
}
SfxBroadcaster & SmEditSource::GetBroadcaster() const
{
return ((SmEditSource *) this)->aBroadCaster;
}
SmViewForwarder::SmViewForwarder( SmEditAccessible &rAcc ) :
rEditAcc(rAcc)
{
}
SmViewForwarder::~SmViewForwarder()
{
}
bool SmViewForwarder::IsValid() const
{
return rEditAcc.GetEditView() != 0;
}
Rectangle SmViewForwarder::GetVisArea() const
{
EditView *pEditView = rEditAcc.GetEditView();
OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
if( pOutDev && pEditView)
{
Rectangle aVisArea = pEditView->GetVisArea();
// figure out map mode from edit engine
EditEngine* pEditEngine = pEditView->GetEditEngine();
if( pEditEngine )
{
MapMode aMapMode(pOutDev->GetMapMode());
aVisArea = OutputDevice::LogicToLogic( aVisArea,
pEditEngine->GetRefMapMode(),
aMapMode.GetMapUnit() );
aMapMode.SetOrigin(Point());
return pOutDev->LogicToPixel( aVisArea, aMapMode );
}
}
return Rectangle();
}
Point SmViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
{
EditView *pEditView = rEditAcc.GetEditView();
OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
if( pOutDev )
{
MapMode aMapMode(pOutDev->GetMapMode());
Point aPoint( OutputDevice::LogicToLogic( rPoint, rMapMode,
aMapMode.GetMapUnit() ) );
aMapMode.SetOrigin(Point());
return pOutDev->LogicToPixel( aPoint, aMapMode );
}
return Point();
}
Point SmViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
{
EditView *pEditView = rEditAcc.GetEditView();
OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
if( pOutDev )
{
MapMode aMapMode(pOutDev->GetMapMode());
aMapMode.SetOrigin(Point());
Point aPoint( pOutDev->PixelToLogic( rPoint, aMapMode ) );
return OutputDevice::LogicToLogic( aPoint,
aMapMode.GetMapUnit(),
rMapMode );
}
return Point();
}
SmTextForwarder::SmTextForwarder( SmEditAccessible& rAcc, SmEditSource & rSource) :
rEditAcc ( rAcc ),
rEditSource (rSource)
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
pEditEngine->SetNotifyHdl( LINK(this, SmTextForwarder, NotifyHdl) );
}
SmTextForwarder::~SmTextForwarder()
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
pEditEngine->SetNotifyHdl( Link() );
}
IMPL_LINK(SmTextForwarder, NotifyHdl, EENotify*, aNotify)
{
if (aNotify)
{
::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify );
if (aHint.get())
rEditSource.GetBroadcaster().Broadcast( *aHint.get() );
}
return 0;
}
sal_Int32 SmTextForwarder::GetParagraphCount() const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->GetParagraphCount() : 0;
}
sal_Int32 SmTextForwarder::GetTextLen( sal_Int32 nParagraph ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->GetTextLen( nParagraph ) : 0;
}
OUString SmTextForwarder::GetText( const ESelection& rSel ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
OUString aRet;
if (pEditEngine)
aRet = pEditEngine->GetText( rSel, LINEEND_LF );
return convertLineEnd(aRet, GetSystemLineEnd());
}
SfxItemSet SmTextForwarder::GetAttribs( const ESelection& rSel, EditEngineAttribs nOnlyHardAttrib ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
OSL_ENSURE( pEditEngine, "EditEngine missing" );
if( rSel.nStartPara == rSel.nEndPara )
{
sal_uInt8 nFlags = 0;
switch( nOnlyHardAttrib )
{
case EditEngineAttribs_All:
nFlags = GETATTRIBS_ALL;
break;
case EditEngineAttribs_HardAndPara:
nFlags = GETATTRIBS_PARAATTRIBS|GETATTRIBS_CHARATTRIBS;
break;
case EditEngineAttribs_OnlyHard:
nFlags = GETATTRIBS_CHARATTRIBS;
break;
default:
SAL_WARN("starmath", "unknown flags for SmTextForwarder::GetAttribs");
}
return pEditEngine->GetAttribs( rSel.nStartPara, rSel.nStartPos, rSel.nEndPos, nFlags );
}
else
{
return pEditEngine->GetAttribs( rSel, nOnlyHardAttrib );
}
}
SfxItemSet SmTextForwarder::GetParaAttribs( sal_Int32 nPara ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
OSL_ENSURE( pEditEngine, "EditEngine missing" );
SfxItemSet aSet( pEditEngine->GetParaAttribs( nPara ) );
sal_uInt16 nWhich = EE_PARA_START;
while( nWhich <= EE_PARA_END )
{
if( aSet.GetItemState( nWhich, true ) != SFX_ITEM_ON )
{
if( pEditEngine->HasParaAttrib( nPara, nWhich ) )
aSet.Put( pEditEngine->GetParaAttrib( nPara, nWhich ) );
}
nWhich++;
}
return aSet;
}
void SmTextForwarder::SetParaAttribs( sal_Int32 nPara, const SfxItemSet& rSet )
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
pEditEngine->SetParaAttribs( nPara, rSet );
}
SfxItemPool* SmTextForwarder::GetPool() const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->GetEmptyItemSet().GetPool() : 0;
}
void SmTextForwarder::RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich )
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
pEditEngine->RemoveAttribs( rSelection, bRemoveParaAttribs, nWhich );
}
void SmTextForwarder::GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& rList ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
pEditEngine->GetPortions( nPara, rList );
}
void SmTextForwarder::QuickInsertText( const OUString& rText, const ESelection& rSel )
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
pEditEngine->QuickInsertText( rText, rSel );
}
void SmTextForwarder::QuickInsertLineBreak( const ESelection& rSel )
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
pEditEngine->QuickInsertLineBreak( rSel );
}
void SmTextForwarder::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel )
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
pEditEngine->QuickInsertField( rFld, rSel );
}
void SmTextForwarder::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel )
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
pEditEngine->QuickSetAttribs( rSet, rSel );
}
bool SmTextForwarder::IsValid() const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
// cannot reliably query EditEngine state
// while in the middle of an update
return pEditEngine && pEditEngine->GetUpdateMode();
}
OUString SmTextForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, Color*& rpTxtColor, Color*& rpFldColor )
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->CalcFieldValue(rField, nPara, nPos, rpTxtColor, rpFldColor) : OUString();
}
void SmTextForwarder::FieldClicked(const SvxFieldItem&, sal_Int32, sal_Int32)
{
}
static sal_uInt16 GetSvxEditEngineItemState( EditEngine& rEditEngine, const ESelection& rSel, sal_uInt16 nWhich )
{
std::vector<EECharAttrib> aAttribs;
const SfxPoolItem* pLastItem = NULL;
SfxItemState eState = SFX_ITEM_DEFAULT;
// check all paragraphs inside the selection
for( sal_Int32 nPara = rSel.nStartPara; nPara <= rSel.nEndPara; nPara++ )
{
SfxItemState eParaState = SFX_ITEM_DEFAULT;
// calculate start and endpos for this paragraph
sal_Int32 nPos = 0;
if( rSel.nStartPara == nPara )
nPos = rSel.nStartPos;
sal_Int32 nEndPos = rSel.nEndPos;
if( rSel.nEndPara != nPara )
nEndPos = rEditEngine.GetTextLen( nPara );
// get list of char attribs
rEditEngine.GetCharAttribs( nPara, aAttribs );
bool bEmpty = true; // we found no item inside the selection of this paragraph
bool bGaps = false; // we found items but theire gaps between them
sal_Int32 nLastEnd = nPos;
const SfxPoolItem* pParaItem = NULL;
for(std::vector<EECharAttrib>::const_iterator i = aAttribs.begin(); i < aAttribs.end(); ++i)
{
OSL_ENSURE( i->pAttr, "GetCharAttribs gives corrupt data" );
const bool bEmptyPortion = (i->nStart == i->nEnd);
if( (!bEmptyPortion && (i->nStart >= nEndPos)) || (bEmptyPortion && (i->nStart > nEndPos)) )
break; // break if we are already behind our selection
if( (!bEmptyPortion && (i->nEnd <= nPos)) || (bEmptyPortion && (i->nEnd < nPos)) )
continue; // or if the attribute ends before our selection
if( i->pAttr->Which() != nWhich )
continue; // skip if is not the searched item
// if we already found an item
if( pParaItem )
{
// ... and its different to this one than the state is dont care
if( *pParaItem != *(i->pAttr) )
return SFX_ITEM_DONTCARE;
}
else
{
pParaItem = i->pAttr;
}
if( bEmpty )
bEmpty = false;
if( !bGaps && i->nStart > nLastEnd )
bGaps = true;
nLastEnd = i->nEnd;
}
if( !bEmpty && !bGaps && nLastEnd < ( nEndPos - 1 ) )
bGaps = true;
if( bEmpty )
eParaState = SFX_ITEM_DEFAULT;
else if( bGaps )
eParaState = SFX_ITEM_DONTCARE;
else
eParaState = SFX_ITEM_SET;
// if we already found an item check if we found the same
if( pLastItem )
{
if( (pParaItem == NULL) || (*pLastItem != *pParaItem) )
return SFX_ITEM_DONTCARE;
}
else
{
pLastItem = pParaItem;
eState = eParaState;
}
}
return eState;
}
sal_uInt16 SmTextForwarder::GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const
{
sal_uInt16 nState = SFX_ITEM_DISABLED;
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
nState = GetSvxEditEngineItemState( *pEditEngine, rSel, nWhich );
return nState;
}
sal_uInt16 SmTextForwarder::GetItemState( sal_Int32 nPara, sal_uInt16 nWhich ) const
{
sal_uInt16 nState = SFX_ITEM_DISABLED;
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
{
const SfxItemSet& rSet = pEditEngine->GetParaAttribs( nPara );
nState = rSet.GetItemState( nWhich );
}
return nState;
}
LanguageType SmTextForwarder::GetLanguage( sal_Int32 nPara, sal_Int32 nIndex ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->GetLanguage(nPara, nIndex) : LANGUAGE_NONE;
}
sal_Int32 SmTextForwarder::GetFieldCount( sal_Int32 nPara ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->GetFieldCount(nPara) : 0;
}
EFieldInfo SmTextForwarder::GetFieldInfo( sal_Int32 nPara, sal_uInt16 nField ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->GetFieldInfo( nPara, nField ) : EFieldInfo();
}
EBulletInfo SmTextForwarder::GetBulletInfo( sal_Int32 /*nPara*/ ) const
{
return EBulletInfo();
}
Rectangle SmTextForwarder::GetCharBounds( sal_Int32 nPara, sal_Int32 nIndex ) const
{
Rectangle aRect(0,0,0,0);
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
{
// Handle virtual position one-past-the end of the string
if( nIndex >= pEditEngine->GetTextLen(nPara) )
{
if( nIndex )
aRect = pEditEngine->GetCharacterBounds( EPosition(nPara, nIndex-1) );
aRect.Move( aRect.Right() - aRect.Left(), 0 );
aRect.SetSize( Size(1, pEditEngine->GetTextHeight()) );
}
else
{
aRect = pEditEngine->GetCharacterBounds( EPosition(nPara, nIndex) );
}
}
return aRect;
}
Rectangle SmTextForwarder::GetParaBounds( sal_Int32 nPara ) const
{
Rectangle aRect(0,0,0,0);
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
{
const Point aPnt = pEditEngine->GetDocPosTopLeft( nPara );
const sal_uLong nWidth = pEditEngine->CalcTextWidth();
const sal_uLong nHeight = pEditEngine->GetTextHeight( nPara );
aRect = Rectangle( aPnt.X(), aPnt.Y(), aPnt.X() + nWidth, aPnt.Y() + nHeight );
}
return aRect;
}
MapMode SmTextForwarder::GetMapMode() const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->GetRefMapMode() : MapMode( MAP_100TH_MM );
}
OutputDevice* SmTextForwarder::GetRefDevice() const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->GetRefDevice() : 0;
}
bool SmTextForwarder::GetIndexAtPoint( const Point& rPos, sal_Int32& nPara, sal_Int32& nIndex ) const
{
bool bRes = false;
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
{
EPosition aDocPos = pEditEngine->FindDocPosition( rPos );
nPara = aDocPos.nPara;
nIndex = aDocPos.nIndex;
bRes = true;
}
return bRes;
}
bool SmTextForwarder::GetWordIndices( sal_Int32 nPara, sal_Int32 nIndex, sal_Int32& nStart, sal_Int32& nEnd ) const
{
bool bRes = false;
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
{
ESelection aRes = pEditEngine->GetWord( ESelection(nPara, nIndex, nPara, nIndex), com::sun::star::i18n::WordType::DICTIONARY_WORD );
if( aRes.nStartPara == nPara &&
aRes.nStartPara == aRes.nEndPara )
{
nStart = aRes.nStartPos;
nEnd = aRes.nEndPos;
bRes = true;
}
}
return bRes;
}
bool SmTextForwarder::GetAttributeRun( sal_Int32& nStartIndex, sal_Int32& nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, bool bInCell ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine &&
SvxEditSourceHelper::GetAttributeRun( nStartIndex, nEndIndex, *pEditEngine, nPara, nIndex, bInCell );
}
sal_Int32 SmTextForwarder::GetLineCount( sal_Int32 nPara ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->GetLineCount(nPara) : 0;
}
sal_Int32 SmTextForwarder::GetLineLen( sal_Int32 nPara, sal_Int32 nLine ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->GetLineLen(nPara, nLine) : 0;
}
void SmTextForwarder::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 nPara, sal_Int32 nLine ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
pEditEngine->GetLineBoundaries(rStart, rEnd, nPara, nLine);
else
rStart = rEnd = 0;
}
sal_Int32 SmTextForwarder::GetLineNumberAtIndex( sal_Int32 nPara, sal_Int32 nIndex ) const
{
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
return pEditEngine ? pEditEngine->GetLineNumberAtIndex(nPara, nIndex) : 0;
}
bool SmTextForwarder::QuickFormatDoc( bool /*bFull*/ )
{
bool bRes = false;
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
{
pEditEngine->QuickFormatDoc();
bRes = true;
}
return bRes;
}
sal_Int16 SmTextForwarder::GetDepth( sal_Int32 /*nPara*/ ) const
{
// math has no outliner...
return -1;
}
bool SmTextForwarder::SetDepth( sal_Int32 /*nPara*/, sal_Int16 nNewDepth )
{
// math has no outliner...
return -1 == nNewDepth; // is it the value from 'GetDepth' ?
}
bool SmTextForwarder::Delete( const ESelection& rSelection )
{
bool bRes = false;
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
{
pEditEngine->QuickDelete( rSelection );
pEditEngine->QuickFormatDoc();
bRes = true;
}
return bRes;
}
bool SmTextForwarder::InsertText( const OUString& rStr, const ESelection& rSelection )
{
bool bRes = false;
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
{
pEditEngine->QuickInsertText( rStr, rSelection );
pEditEngine->QuickFormatDoc();
bRes = true;
}
return bRes;
}
const SfxItemSet* SmTextForwarder::GetEmptyItemSetPtr()
{
const SfxItemSet *pItemSet = 0;
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
{
pItemSet = &pEditEngine->GetEmptyItemSet();
}
return pItemSet;
}
void SmTextForwarder::AppendParagraph()
{
// append an empty paragraph
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine)
{
sal_Int32 nParaCount = pEditEngine->GetParagraphCount();
pEditEngine->InsertParagraph( nParaCount, OUString() );
}
}
sal_Int32 SmTextForwarder::AppendTextPortion( sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet )
{
sal_uInt16 nRes = 0;
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine && nPara < pEditEngine->GetParagraphCount())
{
// append text
ESelection aSel( nPara, pEditEngine->GetTextLen( nPara ) );
pEditEngine->QuickInsertText( rText, aSel );
// set attributes for new appended text
nRes = aSel.nEndPos = pEditEngine->GetTextLen( nPara );
pEditEngine->QuickSetAttribs( rSet, aSel );
}
return nRes;
}
void SmTextForwarder::CopyText(const SvxTextForwarder& rSource)
{
const SmTextForwarder* pSourceForwarder = dynamic_cast< const SmTextForwarder* >( &rSource );
if( !pSourceForwarder )
return;
EditEngine* pSourceEditEngine = pSourceForwarder->rEditAcc.GetEditEngine();
EditEngine *pEditEngine = rEditAcc.GetEditEngine();
if (pEditEngine && pSourceEditEngine )
{
EditTextObject* pNewTextObject = pSourceEditEngine->CreateTextObject();
pEditEngine->SetText( *pNewTextObject );
delete pNewTextObject;
}
}
SmEditViewForwarder::SmEditViewForwarder( SmEditAccessible& rAcc ) :
rEditAcc( rAcc )
{
}
SmEditViewForwarder::~SmEditViewForwarder()
{
}
bool SmEditViewForwarder::IsValid() const
{
return rEditAcc.GetEditView() != 0;
}
Rectangle SmEditViewForwarder::GetVisArea() const
{
Rectangle aRect(0,0,0,0);
EditView *pEditView = rEditAcc.GetEditView();
OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
if( pOutDev && pEditView)
{
Rectangle aVisArea = pEditView->GetVisArea();
// figure out map mode from edit engine
EditEngine* pEditEngine = pEditView->GetEditEngine();
if( pEditEngine )
{
MapMode aMapMode(pOutDev->GetMapMode());
aVisArea = OutputDevice::LogicToLogic( aVisArea,
pEditEngine->GetRefMapMode(),
aMapMode.GetMapUnit() );
aMapMode.SetOrigin(Point());
aRect = pOutDev->LogicToPixel( aVisArea, aMapMode );
}
}
return aRect;
}
Point SmEditViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
{
EditView *pEditView = rEditAcc.GetEditView();
OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
if( pOutDev )
{
MapMode aMapMode(pOutDev->GetMapMode());
Point aPoint( OutputDevice::LogicToLogic( rPoint, rMapMode,
aMapMode.GetMapUnit() ) );
aMapMode.SetOrigin(Point());
return pOutDev->LogicToPixel( aPoint, aMapMode );
}
return Point();
}
Point SmEditViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
{
EditView *pEditView = rEditAcc.GetEditView();
OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
if( pOutDev )
{
MapMode aMapMode(pOutDev->GetMapMode());
aMapMode.SetOrigin(Point());
Point aPoint( pOutDev->PixelToLogic( rPoint, aMapMode ) );
return OutputDevice::LogicToLogic( aPoint,
aMapMode.GetMapUnit(),
rMapMode );
}
return Point();
}
bool SmEditViewForwarder::GetSelection( ESelection& rSelection ) const
{
bool bRes = false;
EditView *pEditView = rEditAcc.GetEditView();
if (pEditView)
{
rSelection = pEditView->GetSelection();
bRes = true;
}
return bRes;
}
bool SmEditViewForwarder::SetSelection( const ESelection& rSelection )
{
bool bRes = false;
EditView *pEditView = rEditAcc.GetEditView();
if (pEditView)
{
pEditView->SetSelection( rSelection );
bRes = true;
}
return bRes;
}
bool SmEditViewForwarder::Copy()
{
bool bRes = false;
EditView *pEditView = rEditAcc.GetEditView();
if (pEditView)
{
pEditView->Copy();
bRes = true;
}
return bRes;
}
bool SmEditViewForwarder::Cut()
{
bool bRes = false;
EditView *pEditView = rEditAcc.GetEditView();
if (pEditView)
{
pEditView->Cut();
bRes = true;
}
return bRes;
}
bool SmEditViewForwarder::Paste()
{
bool bRes = false;
EditView *pEditView = rEditAcc.GetEditView();
if (pEditView)
{
pEditView->Paste();
bRes = true;
}
return bRes;
}
SmEditAccessible::SmEditAccessible( SmEditWindow *pEditWin ) :
aAccName (SM_RESSTR(STR_CMDBOXWINDOW)),
pTextHelper (0),
pWin (pEditWin)
{
OSL_ENSURE( pWin, "SmEditAccessible: window missing" );
}
SmEditAccessible::SmEditAccessible( const SmEditAccessible &rSmAcc )
: SmEditAccessibleBaseClass()
, aAccName(SM_RESSTR(STR_CMDBOXWINDOW))
, pTextHelper(NULL)
{
pWin = rSmAcc.pWin;
OSL_ENSURE( pWin, "SmEditAccessible: window missing" );
}
SmEditAccessible::~SmEditAccessible()
{
delete pTextHelper;
}
void SmEditAccessible::Init()
{
OSL_ENSURE( pWin, "SmEditAccessible: window missing" );
if (pWin)
{
EditEngine *pEditEngine = pWin->GetEditEngine();
EditView *pEditView = pWin->GetEditView();
if (pEditEngine && pEditView)
{
::std::auto_ptr< SvxEditSource > pEditSource(
new SmEditSource( pWin, *this ) );
pTextHelper = new ::accessibility::AccessibleTextHelper( pEditSource );
pTextHelper->SetEventSource( this );
}
}
}
void SmEditAccessible::ClearWin()
{
// remove handler before current object gets destroyed
// (avoid handler being called for already dead object)
EditEngine *pEditEngine = GetEditEngine();
if (pEditEngine)
pEditEngine->SetNotifyHdl( Link() );
pWin = 0; // implicitly results in AccessibleStateType::DEFUNC set
//! make TextHelper implicitly release C++ references to some core objects
SAL_WNODEPRECATED_DECLARATIONS_PUSH
pTextHelper->SetEditSource( ::std::auto_ptr<SvxEditSource>(NULL) );
SAL_WNODEPRECATED_DECLARATIONS_POP
//! make TextHelper release references
//! (e.g. the one set by the 'SetEventSource' call)
pTextHelper->Dispose();
delete pTextHelper; pTextHelper = 0;
}
// XAccessible
uno::Reference< XAccessibleContext > SAL_CALL SmEditAccessible::getAccessibleContext( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return this;
}
// XAccessibleComponent
sal_Bool SAL_CALL SmEditAccessible::containsPoint( const awt::Point& aPoint )
throw (RuntimeException, std::exception)
{
//! the arguments coordinates are relativ to the current window !
//! Thus the top left-point is (0, 0)
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
Size aSz( pWin->GetSizePixel() );
return aPoint.X >= 0 && aPoint.Y >= 0 &&
aPoint.X < aSz.Width() && aPoint.Y < aSz.Height();
}
uno::Reference< XAccessible > SAL_CALL SmEditAccessible::getAccessibleAtPoint( const awt::Point& aPoint )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pTextHelper)
throw RuntimeException();
return pTextHelper->GetAt( aPoint );
}
awt::Rectangle SAL_CALL SmEditAccessible::getBounds( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
"mismatch of window parent and accessible parent" );
return lcl_GetBounds( pWin );
}
awt::Point SAL_CALL SmEditAccessible::getLocation( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
"mismatch of window parent and accessible parent" );
awt::Rectangle aRect( lcl_GetBounds( pWin ) );
return awt::Point( aRect.X, aRect.Y );
}
awt::Point SAL_CALL SmEditAccessible::getLocationOnScreen( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
"mismatch of window parent and accessible parent" );
return lcl_GetLocationOnScreen( pWin );
}
awt::Size SAL_CALL SmEditAccessible::getSize( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
"mismatch of window parent and accessible parent" );
Size aSz( pWin->GetSizePixel() );
#if OSL_DEBUG_LEVEL > 1
awt::Rectangle aRect( lcl_GetBounds( pWin ) );
Size aSz2( aRect.Width, aRect.Height );
OSL_ENSURE( aSz == aSz2, "mismatch in width" );
#endif
return awt::Size( aSz.Width(), aSz.Height() );
}
void SAL_CALL SmEditAccessible::grabFocus( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
pWin->GrabFocus();
}
sal_Int32 SAL_CALL SmEditAccessible::getForeground()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
return (sal_Int32) pWin->GetTextColor().GetColor();
}
sal_Int32 SAL_CALL SmEditAccessible::getBackground()
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
Wallpaper aWall( pWin->GetDisplayBackground() );
ColorData nCol;
if (aWall.IsBitmap() || aWall.IsGradient())
nCol = pWin->GetSettings().GetStyleSettings().GetWindowColor().GetColor();
else
nCol = aWall.GetColor().GetColor();
return (sal_Int32) nCol;
}
// XAccessibleContext
sal_Int32 SAL_CALL SmEditAccessible::getAccessibleChildCount( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pTextHelper)
throw RuntimeException();
return pTextHelper->GetChildCount();
}
uno::Reference< XAccessible > SAL_CALL SmEditAccessible::getAccessibleChild( sal_Int32 i )
throw (IndexOutOfBoundsException, RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pTextHelper)
throw RuntimeException();
return pTextHelper->GetChild( i );
}
uno::Reference< XAccessible > SAL_CALL SmEditAccessible::getAccessibleParent( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
if (!pWin)
throw RuntimeException();
Window *pAccParent = pWin->GetAccessibleParentWindow();
OSL_ENSURE( pAccParent, "accessible parent missing" );
return pAccParent ? pAccParent->GetAccessible() : Reference< XAccessible >();
}
sal_Int32 SAL_CALL SmEditAccessible::getAccessibleIndexInParent( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
sal_Int32 nIdx = -1;
Window *pAccParent = pWin ? pWin->GetAccessibleParentWindow() : 0;
if (pAccParent)
{
sal_uInt16 nCnt = pAccParent->GetAccessibleChildWindowCount();
for (sal_uInt16 i = 0; i < nCnt && nIdx == -1; ++i)
if (pAccParent->GetAccessibleChildWindow( i ) == pWin)
nIdx = i;
}
return nIdx;
}
sal_Int16 SAL_CALL SmEditAccessible::getAccessibleRole( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return AccessibleRole::PANEL /*TEXT ?*/;
}
OUString SAL_CALL SmEditAccessible::getAccessibleDescription( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
return OUString(); // empty as agreed with product-management
}
OUString SAL_CALL SmEditAccessible::getAccessibleName( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
// same name as displayed by the window when not docked
return aAccName;
}
uno::Reference< XAccessibleRelationSet > SAL_CALL SmEditAccessible::getAccessibleRelationSet( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
Reference< XAccessibleRelationSet > xRelSet = new utl::AccessibleRelationSetHelper();
return xRelSet; // empty relation set
}
uno::Reference< XAccessibleStateSet > SAL_CALL SmEditAccessible::getAccessibleStateSet( )
throw (RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
::utl::AccessibleStateSetHelper *pStateSet =
new ::utl::AccessibleStateSetHelper;
Reference<XAccessibleStateSet> xStateSet( pStateSet );
if (!pWin || !pTextHelper)
pStateSet->AddState( AccessibleStateType::DEFUNC );
else
{
pStateSet->AddState( AccessibleStateType::MULTI_LINE );
pStateSet->AddState( AccessibleStateType::ENABLED );
pStateSet->AddState( AccessibleStateType::FOCUSABLE );
if (pWin->HasFocus())
pStateSet->AddState( AccessibleStateType::FOCUSED );
if (pWin->IsActive())
pStateSet->AddState( AccessibleStateType::ACTIVE );
if (pWin->IsVisible())
pStateSet->AddState( AccessibleStateType::SHOWING );
if (pWin->IsReallyVisible())
pStateSet->AddState( AccessibleStateType::VISIBLE );
if (COL_TRANSPARENT != pWin->GetBackground().GetColor().GetColor())
pStateSet->AddState( AccessibleStateType::OPAQUE );
}
return xStateSet;
}
Locale SAL_CALL SmEditAccessible::getLocale( )
throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
// should be the document language...
// We use the language of the localized symbol names here.
return Application::GetSettings().GetUILanguageTag().getLocale();
}
// XAccessibleEventBroadcaster
void SAL_CALL SmEditAccessible::addAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
throw (RuntimeException, std::exception)
{
if (pTextHelper) // not disposing (about to destroy view shell)
pTextHelper->AddEventListener( xListener );
}
void SAL_CALL SmEditAccessible::removeAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
throw (RuntimeException, std::exception)
{
if (pTextHelper) // not disposing (about to destroy view shell)
pTextHelper->RemoveEventListener( xListener );
}
OUString SAL_CALL SmEditAccessible::getImplementationName()
throw (RuntimeException, std::exception)
{
return OUString("SmEditAccessible");
}
sal_Bool SAL_CALL SmEditAccessible::supportsService(
const OUString& rServiceName )
throw (RuntimeException, std::exception)
{
return cppu::supportsService(this, rServiceName);
}
Sequence< OUString > SAL_CALL SmEditAccessible::getSupportedServiceNames()
throw (RuntimeException, std::exception)
{
Sequence< OUString > aNames(3);
OUString *pNames = aNames.getArray();
pNames[0] = "com::sun::star::accessibility::Accessible";
pNames[1] = "com::sun::star::accessibility::AccessibleComponent";
pNames[2] = "com::sun::star::accessibility::AccessibleContext";
return aNames;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|