< prev index next >

src/jdk.accessibility/windows/native/libjavaaccessbridge/AccessBridgeJavaEntryPoints.cpp

Print this page

   1 /*
   2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any

  65         PrintDebugString("[ERROR]: FindClass(%s) failed! ->  (ran out of RAM)", className); \
  66         return FALSE; \
  67     }
  68 
  69 
  70 #define FIND_METHOD(methodID, classRef, methodString, methodSignature); \
  71     methodID = jniEnv->GetMethodID(classRef, methodString,  methodSignature); \
  72     if (methodID == (jmethodID) 0) { \
  73         PrintDebugString("[ERROR]: GetMethodID(%s) failed! -> jniEnv = %p; classRef = %p", methodString, jniEnv, classRef); \
  74         return FALSE; \
  75     }
  76 
  77 #define EXCEPTION_CHECK(situationDescription, returnVal)                                        \
  78     if (exception = jniEnv->ExceptionOccurred()) {                                              \
  79         PrintDebugString("[ERROR]: *** Exception occured while doing: %s; returning %d", situationDescription, returnVal);   \
  80         jniEnv->ExceptionDescribe();                                                            \
  81         jniEnv->ExceptionClear();                                                               \
  82         return (returnVal);                                                                     \
  83     }
  84 
















  85 #define EXCEPTION_CHECK_VOID(situationDescription)                                              \
  86     if (exception = jniEnv->ExceptionOccurred()) {                                              \
  87         PrintDebugString("[ERROR]: *** Exception occured while doing: %s", situationDescription);   \
  88         jniEnv->ExceptionDescribe();                                                            \
  89         jniEnv->ExceptionClear();                                                               \
  90         return;                                                                                 \
  91     }
  92 
  93 /**
  94  * Make all of the getClass() & getMethod() calls
  95  *
  96  */
  97 BOOL
  98 AccessBridgeJavaEntryPoints::BuildJavaEntryPoints() {
  99     jclass localClassRef;
 100 
 101     PrintDebugString("[INFO]: Calling BuildJavaEntryPoints():");
 102 
 103     FIND_CLASS(bridgeClass, "com/sun/java/accessibility/internal/AccessBridge");
 104 

1198     }
1199 
1200     jstring js = NULL;
1201     const wchar_t * stringBytes = NULL;
1202     jthrowable exception = NULL;
1203     jsize length = 0;
1204     PrintDebugString("[INFO]:  getVirtualAccessibleName called.");
1205     if (getVirtualAccessibleNameFromContextMethod != (jmethodID) 0)
1206     {
1207         js = (jstring) jniEnv->CallObjectMethod (
1208             accessBridgeObject,
1209             getVirtualAccessibleNameFromContextMethod,
1210             object);
1211         EXCEPTION_CHECK("Getting AccessibleName - call to CallObjectMethod()", FALSE);
1212         if (js != (jstring) 0)
1213         {
1214             stringBytes = (const wchar_t *) jniEnv->GetStringChars (js, 0);
1215             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1216             wcsncpy(name, stringBytes, nameSize - 1);
1217             length = jniEnv->GetStringLength(js);
1218             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringLength()", FALSE);
1219             jniEnv->ReleaseStringChars(js, stringBytes);
1220             EXCEPTION_CHECK("Getting AccessibleName - call to ReleaseStringChars()", FALSE);
1221             jniEnv->CallVoidMethod (
1222                 accessBridgeObject,
1223                 decrementReferenceMethod, js);
1224             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1225             wPrintDebugString(L"  Accessible Name = %ls", name);
1226             jniEnv->DeleteLocalRef(js);
1227             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1228         }
1229         else
1230         {
1231             PrintDebugString("[INFO]:   Accessible Name is null.");
1232         }
1233     }
1234     else
1235     {
1236         PrintDebugString("[INFO]: either jniEnv == 0 or getVirtualAccessibleNameFromContextMethod == 0");
1237         return FALSE;
1238     }
1239     if ( 0 != name [0] )
1240     {

1363     (*len)++;
1364 
1365     for (jint i = startIndex+1; i <= endIndex; i++) {
1366 
1367         AccessibleTextAttributesInfo test_attributes = *attributes;
1368         // Get the full test_attributes string at i
1369         if (getAccessibleAttributesAtIndexFromContextMethod != (jmethodID) 0) {
1370             PrintDebugString("[INFO]:  Getting full test_attributes string from Context...");
1371             js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1372                                                     getAccessibleAttributesAtIndexFromContextMethod,
1373                                                     accessibleContext, i);
1374             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallObjectMethod()", FALSE);
1375             PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
1376             if (js != (jstring) 0) {
1377                 stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1378                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE);
1379                 wcsncpy(test_attributes.fullAttributesString, stringBytes, (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t)));
1380                 length = jniEnv->GetStringLength(js);
1381                 test_attributes.fullAttributesString[length < (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t)) ?
1382                                                      length : (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t))-2] = (wchar_t) 0;
1383                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringLength()", FALSE);
1384                 jniEnv->ReleaseStringChars(js, stringBytes);
1385                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to ReleaseStringChars()", FALSE);
1386                 jniEnv->CallVoidMethod(accessBridgeObject,
1387                                        decrementReferenceMethod, js);
1388                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE);
1389                 wPrintDebugString(L"[INFO]:  Accessible Text attributes = %ls", test_attributes.fullAttributesString);
1390                 jniEnv->DeleteLocalRef(js);
1391                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
1392             } else {
1393                 PrintDebugString("[WARN]:   Accessible Text attributes is null.");
1394                 test_attributes.fullAttributesString[0] = (wchar_t) 0;
1395                 return FALSE;
1396             }
1397         } else {
1398             PrintDebugString("[ERROR]: either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0");
1399             return FALSE;
1400         }
1401 
1402         if(wcscmp(attributes->fullAttributesString,test_attributes.fullAttributesString))
1403             break;
1404         if (result != TRUE) {
1405             return FALSE;

1718     PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleContextInfo(%p):", accessibleContext);
1719 
1720     ZeroMemory(info, sizeof(AccessibleContextInfo));
1721 
1722     if (accessibleContext == (jobject) 0) {
1723         PrintDebugString("[WARN]:  passed in AccessibleContext == null! (oops)");
1724         return (FALSE);
1725     }
1726 
1727     // Get the Accessible Name
1728     if (getAccessibleNameFromContextMethod != (jmethodID) 0) {
1729         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1730                                                 getAccessibleNameFromContextMethod,
1731                                                 accessibleContext);
1732         EXCEPTION_CHECK("Getting AccessibleName - call to CallObjectMethod()", FALSE);
1733         if (js != (jstring) 0) {
1734             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1735             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1736             wcsncpy(info->name, stringBytes, (sizeof(info->name) / sizeof(wchar_t)));
1737             length = jniEnv->GetStringLength(js);

1738             info->name[length < (sizeof(info->name) / sizeof(wchar_t)) ?
1739                        length : (sizeof(info->name) / sizeof(wchar_t))-2] = (wchar_t) 0;
1740             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringLength()", FALSE);
1741             jniEnv->ReleaseStringChars(js, stringBytes);
1742             EXCEPTION_CHECK("Getting AccessibleName - call to ReleaseStringChars()", FALSE);
1743             jniEnv->CallVoidMethod(accessBridgeObject,
1744                                    decrementReferenceMethod, js);
1745             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1746             wPrintDebugString(L"[INFO]:   Accessible Name = %ls", info->name);
1747             jniEnv->DeleteLocalRef(js);
1748             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1749         } else {
1750             PrintDebugString("[WARN]:   Accessible Name is null.");
1751             info->name[0] = (wchar_t) 0;
1752         }
1753     } else {
1754         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleNameFromContextMethod == 0");
1755         return FALSE;
1756     }
1757 
1758 
1759     // Get the Accessible Description
1760     if (getAccessibleDescriptionFromContextMethod != (jmethodID) 0) {
1761         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1762                                                 getAccessibleDescriptionFromContextMethod,
1763                                                 accessibleContext);
1764         EXCEPTION_CHECK("Getting AccessibleDescription - call to CallObjectMethod()", FALSE);
1765         if (js != (jstring) 0) {
1766             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1767             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1768             wcsncpy(info->description, stringBytes, (sizeof(info->description) / sizeof(wchar_t)));
1769             length = jniEnv->GetStringLength(js);

1770             info->description[length < (sizeof(info->description) / sizeof(wchar_t)) ?
1771                               length : (sizeof(info->description) / sizeof(wchar_t))-2] = (wchar_t) 0;
1772             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringLength()", FALSE);
1773             jniEnv->ReleaseStringChars(js, stringBytes);
1774             EXCEPTION_CHECK("Getting AccessibleName - call to ReleaseStringChars()", FALSE);
1775             jniEnv->CallVoidMethod(accessBridgeObject,
1776                                    decrementReferenceMethod, js);
1777             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1778             wPrintDebugString(L"[INFO]:   Accessible Description = %ls", info->description);
1779             jniEnv->DeleteLocalRef(js);
1780             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1781         } else {
1782             PrintDebugString("[WARN]:   Accessible Description is null.");
1783             info->description[0] = (wchar_t) 0;
1784         }
1785     } else {
1786         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleDescriptionFromContextMethod == 0");
1787         return FALSE;
1788     }
1789 
1790 
1791     // Get the Accessible Role String
1792     if (getAccessibleRoleStringFromContextMethod != (jmethodID) 0) {
1793         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1794                                                 getAccessibleRoleStringFromContextMethod,
1795                                                 accessibleContext);
1796         EXCEPTION_CHECK("Getting AccessibleRole - call to CallObjectMethod()", FALSE);
1797         if (js != (jstring) 0) {
1798             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1799             EXCEPTION_CHECK("Getting AccessibleRole - call to GetStringChars()", FALSE);
1800             wcsncpy(info->role, stringBytes, (sizeof(info->role) / sizeof(wchar_t)));
1801             length = jniEnv->GetStringLength(js);

1802             info->role[length < (sizeof(info->role) / sizeof(wchar_t)) ?
1803                        length : (sizeof(info->role) / sizeof(wchar_t))-2] = (wchar_t) 0;
1804             EXCEPTION_CHECK("Getting AccessibleRole - call to GetStringLength()", FALSE);
1805             jniEnv->ReleaseStringChars(js, stringBytes);
1806             EXCEPTION_CHECK("Getting AccessibleRole - call to ReleaseStringChars()", FALSE);
1807             jniEnv->CallVoidMethod(accessBridgeObject,
1808                                    decrementReferenceMethod, js);
1809             EXCEPTION_CHECK("Getting AccessibleRole - call to CallVoidMethod()", FALSE);
1810             wPrintDebugString(L"[INFO]:   Accessible Role = %ls", info->role);
1811             jniEnv->DeleteLocalRef(js);
1812             EXCEPTION_CHECK("Getting AccessibleRole - call to DeleteLocalRef()", FALSE);
1813         } else {
1814             PrintDebugString("[WARN]:   Accessible Role is null.");
1815             info->role[0] = (wchar_t) 0;
1816         }
1817     } else {
1818         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleRoleStringFromContextMethod == 0");
1819         return FALSE;
1820     }
1821 
1822 
1823     // Get the Accessible Role String in the en_US locale
1824     if (getAccessibleRoleStringFromContext_en_USMethod != (jmethodID) 0) {
1825         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1826                                                 getAccessibleRoleStringFromContext_en_USMethod,
1827                                                 accessibleContext);
1828         EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to CallObjectMethod()", FALSE);
1829         if (js != (jstring) 0) {
1830             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1831             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to GetStringChars()", FALSE);
1832             wcsncpy(info->role_en_US, stringBytes, (sizeof(info->role_en_US) / sizeof(wchar_t)));
1833             length = jniEnv->GetStringLength(js);

1834             info->role_en_US[length < (sizeof(info->role_en_US) / sizeof(wchar_t)) ?
1835                              length : (sizeof(info->role_en_US) / sizeof(wchar_t))-2] = (wchar_t) 0;
1836             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to GetStringLength()", FALSE);
1837             jniEnv->ReleaseStringChars(js, stringBytes);
1838             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to ReleaseStringChars()", FALSE);
1839             jniEnv->CallVoidMethod(accessBridgeObject,
1840                                    decrementReferenceMethod, js);
1841             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to CallVoidMethod()", FALSE);
1842             wPrintDebugString(L"[INFO]:   Accessible Role en_US = %ls", info->role_en_US);
1843             jniEnv->DeleteLocalRef(js);
1844             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to DeleteLocalRef()", FALSE);
1845         } else {
1846             PrintDebugString("[WARN]:   Accessible Role en_US is null.");
1847             info->role[0] = (wchar_t) 0;
1848         }
1849     } else {
1850         PrintDebugString("[ERROR]: either env == 0 or getAccessibleRoleStringFromContext_en_USMethod == 0");
1851         return FALSE;
1852     }
1853 
1854     // Get the Accessible States String
1855     if (getAccessibleStatesStringFromContextMethod != (jmethodID) 0) {
1856         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1857                                                 getAccessibleStatesStringFromContextMethod,
1858                                                 accessibleContext);
1859         EXCEPTION_CHECK("Getting AccessibleState - call to CallObjectMethod()", FALSE);
1860         if (js != (jstring) 0) {
1861             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1862             EXCEPTION_CHECK("Getting AccessibleState - call to GetStringChars()", FALSE);
1863             wcsncpy(info->states, stringBytes, (sizeof(info->states) / sizeof(wchar_t)));
1864             length = jniEnv->GetStringLength(js);

1865             info->states[length < (sizeof(info->states) / sizeof(wchar_t)) ?
1866                          length : (sizeof(info->states) / sizeof(wchar_t))-2] = (wchar_t) 0;
1867             EXCEPTION_CHECK("Getting AccessibleState - call to GetStringLength()", FALSE);
1868             jniEnv->ReleaseStringChars(js, stringBytes);
1869             EXCEPTION_CHECK("Getting AccessibleState - call to ReleaseStringChars()", FALSE);
1870             jniEnv->CallVoidMethod(accessBridgeObject,
1871                                    decrementReferenceMethod, js);
1872             EXCEPTION_CHECK("Getting AccessibleState - call to CallVoidMethod()", FALSE);
1873             wPrintDebugString(L"[INFO]:   Accessible States = %ls", info->states);
1874             jniEnv->DeleteLocalRef(js);
1875             EXCEPTION_CHECK("Getting AccessibleState - call to DeleteLocalRef()", FALSE);
1876         } else {
1877             PrintDebugString("[WARN]:   Accessible States is null.");
1878             info->states[0] = (wchar_t) 0;
1879         }
1880     } else {
1881         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleStatesStringFromContextMethod == 0");
1882         return FALSE;
1883     }
1884 
1885     // Get the Accessible States String in the en_US locale
1886     if (getAccessibleStatesStringFromContext_en_USMethod != (jmethodID) 0) {
1887         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1888                                                 getAccessibleStatesStringFromContext_en_USMethod,
1889                                                 accessibleContext);
1890         EXCEPTION_CHECK("Getting AccessibleState_en_US - call to CallObjectMethod()", FALSE);
1891         if (js != (jstring) 0) {
1892             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1893             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to GetStringChars()", FALSE);
1894             wcsncpy(info->states_en_US, stringBytes, (sizeof(info->states_en_US) / sizeof(wchar_t)));
1895             length = jniEnv->GetStringLength(js);

1896             info->states_en_US[length < (sizeof(info->states_en_US) / sizeof(wchar_t)) ?
1897                                length : (sizeof(info->states_en_US) / sizeof(wchar_t))-2] = (wchar_t) 0;
1898             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to GetStringLength()", FALSE);
1899             jniEnv->ReleaseStringChars(js, stringBytes);
1900             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to ReleaseStringChars()", FALSE);
1901             jniEnv->CallVoidMethod(accessBridgeObject,
1902                                    decrementReferenceMethod, js);
1903             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to CallVoidMethod()", FALSE);
1904             wPrintDebugString(L"[INFO]:   Accessible States en_US = %ls", info->states_en_US);
1905             jniEnv->DeleteLocalRef(js);
1906             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to DeleteLocalRef()", FALSE);
1907         } else {
1908             PrintDebugString("[WARN]:   Accessible States en_US is null.");
1909             info->states[0] = (wchar_t) 0;
1910         }
1911     } else {
1912         PrintDebugString("[ERROR]: either env == 0 or getAccessibleStatesStringFromContext_en_USMethod == 0");
1913         return FALSE;
1914     }
1915 
1916 
1917     // Get the index in Parent
1918     if (getAccessibleIndexInParentFromContextMethod != (jmethodID) 0) {
1919         info->indexInParent = jniEnv->CallIntMethod(accessBridgeObject,
1920                                                     getAccessibleIndexInParentFromContextMethod,

2792                                                        getAccessibleRelationCountMethod,
2793                                                        accessibleContext);
2794     EXCEPTION_CHECK("##### Getting AccessibleRelationCount - call to CallIntMethod()", FALSE);
2795     PrintDebugString("[INFO]:   ##### AccessibleRelation count = %d", relationSet->relationCount);
2796 
2797 
2798     // Get the relation set
2799     for (int i = 0; i < relationSet->relationCount && i < MAX_RELATIONS; i++) {
2800 
2801         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
2802                                                        getAccessibleRelationKeyMethod,
2803                                                        accessibleContext,
2804                                                        i);
2805 
2806         EXCEPTION_CHECK("Getting AccessibleRelationKey - call to CallObjectMethod()", FALSE);
2807         if (js != (jstring) 0) {
2808             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
2809             EXCEPTION_CHECK("Getting AccessibleRelation key - call to GetStringChars()", FALSE);
2810             wcsncpy(relationSet->relations[i].key, stringBytes, (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t)));
2811             length = jniEnv->GetStringLength(js);

2812             relationSet->relations[i].key [length < (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t)) ?
2813                                            length : (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t))-2] = (wchar_t) 0;
2814             EXCEPTION_CHECK("Getting AccessibleRelation key - call to GetStringLength()", FALSE);
2815             jniEnv->ReleaseStringChars(js, stringBytes);
2816             EXCEPTION_CHECK("Getting AccessibleRelation key - call to ReleaseStringChars()", FALSE);
2817             // jniEnv->CallVoidMethod(accessBridgeObject,
2818             //                        decrementReferenceMethod, js);
2819             //EXCEPTION_CHECK("Getting AccessibleRelation key - call to CallVoidMethod()", FALSE);
2820             PrintDebugString("[INFO]: ##### AccessibleRelation key = %ls", relationSet->relations[i].key );
2821             jniEnv->DeleteLocalRef(js);
2822             EXCEPTION_CHECK("Getting AccessibleRelation key - call to DeleteLocalRef()", FALSE);
2823         } else {
2824             PrintDebugString("[WARN]:   AccessibleRelation key is null.");
2825             relationSet->relations[i].key [0] = (wchar_t) 0;
2826         }
2827 
2828         relationSet->relations[i].targetCount = jniEnv->CallIntMethod(accessBridgeObject,
2829                                                                       getAccessibleRelationTargetCountMethod,
2830                                                                       accessibleContext,
2831                                                                       i);
2832 
2833         for (int j = 0; j < relationSet->relations[i].targetCount && j < MAX_RELATION_TARGETS; j++) {
2834             jobject target = jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleRelationTargetMethod,
2835                                                       accessibleContext, i, j);
2836             EXCEPTION_CHECK("Getting AccessibleRelationSet - call to CallObjectMethod()", FALSE);

2898         EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to NewGlobalRef()", FALSE);
2899         hypertext->links[i].accessibleHyperlink = (JOBJECT64)globalRef;
2900         PrintDebugString("[INFO]:   ##### AccessibleHyperlink = %p", globalRef);
2901 
2902         // get the hyperlink text
2903         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
2904                                                        getAccessibleHyperlinkTextMethod,
2905                                                        hypertext->links[i].accessibleHyperlink,
2906                                                        i);
2907 
2908         EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
2909         if (js != (jstring) 0) {
2910             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
2911             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
2912             wcsncpy(hypertext->links[i].text, stringBytes, (sizeof(hypertext->links[i].text) / sizeof(wchar_t)));
2913             length = jniEnv->GetStringLength(js);
2914             if (length >= (sizeof(hypertext->links[i].text) / sizeof(wchar_t))) {
2915                 length = (sizeof(hypertext->links[i].text) / sizeof(wchar_t)) - 2;
2916             }
2917             hypertext->links[i].text[length] = (wchar_t) 0;
2918             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringLength()", FALSE);
2919             jniEnv->ReleaseStringChars(js, stringBytes);
2920             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to ReleaseStringChars()", FALSE);
2921             // jniEnv->CallVoidMethod(accessBridgeObject,
2922             //                                     decrementReferenceMethod, js);
2923             //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
2924             PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", hypertext->links[i].text );
2925             jniEnv->DeleteLocalRef(js);
2926             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
2927         } else {
2928             PrintDebugString("[WARN]:   AccessibleHyperlink text is null.");
2929             hypertext->links[i].text[0] = (wchar_t) 0;
2930         }
2931 
2932         hypertext->links[i].startIndex = jniEnv->CallIntMethod(accessBridgeObject,
2933                                                                getAccessibleHyperlinkStartIndexMethod,
2934                                                                hypertext->links[i].accessibleHyperlink,
2935                                                                i);
2936         EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
2937         PrintDebugString("[INFO]:   ##### hyperlink start index = %d", hypertext->links[i].startIndex);
2938 
2939 
2940         hypertext->links[i].endIndex = jniEnv->CallIntMethod(accessBridgeObject,

3035         hypertext->links[bufIndex].accessibleHyperlink = (JOBJECT64)globalRef;
3036         PrintDebugString("[INFO]:   ##### AccessibleHyperlink = %p", globalRef);
3037 
3038         // get the hyperlink text
3039         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3040                                                        getAccessibleHyperlinkTextMethod,
3041                                                        hypertext->links[bufIndex].accessibleHyperlink,
3042                                                        i);
3043 
3044         EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
3045         if (js != (jstring) 0) {
3046             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3047             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
3048             wcsncpy(hypertext->links[bufIndex].text, stringBytes,
3049                     (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t)));
3050             length = jniEnv->GetStringLength(js);
3051             if (length >= (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t))) {
3052                 length = (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t)) - 2;
3053             }
3054             hypertext->links[bufIndex].text[length] = (wchar_t) 0;
3055             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringLength()", FALSE);
3056             jniEnv->ReleaseStringChars(js, stringBytes);
3057             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to ReleaseStringChars()", FALSE);
3058             // jniEnv->CallVoidMethod(accessBridgeObject,
3059             //                        decrementReferenceMethod, js);
3060             //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
3061             PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", hypertext->links[bufIndex].text );
3062             jniEnv->DeleteLocalRef(js);
3063             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
3064 
3065         } else {
3066             PrintDebugString("[WARN]:   AccessibleHyperlink text is null.");
3067             hypertext->links[bufIndex].text[0] = (wchar_t) 0;
3068         }
3069 
3070         hypertext->links[bufIndex].startIndex = jniEnv->CallIntMethod(accessBridgeObject,
3071                                                                       getAccessibleHyperlinkStartIndexMethod,
3072                                                                       hypertext->links[bufIndex].accessibleHyperlink,
3073                                                                       i);
3074         EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
3075         PrintDebugString("[INFO]:   ##### hyperlink start index = %d", hypertext->links[bufIndex].startIndex);
3076 
3077         hypertext->links[bufIndex].endIndex = jniEnv->CallIntMethod(accessBridgeObject,

3154     info->accessibleHyperlink = (JOBJECT64)globalRef;
3155     PrintDebugString("[INFO]:   ##### AccessibleHyperlink = %p", globalRef);
3156 
3157     // get the hyperlink text
3158     jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3159                                                    getAccessibleHyperlinkTextMethod,
3160                                                    info->accessibleHyperlink,
3161                                                    index);
3162 
3163     EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
3164     if (js != (jstring) 0) {
3165         stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3166         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
3167         wcsncpy(info->text, stringBytes,
3168                 (sizeof(info->text) / sizeof(wchar_t)));
3169         length = jniEnv->GetStringLength(js);
3170         if (length >= (sizeof(info->text) / sizeof(wchar_t))) {
3171             length = (sizeof(info->text) / sizeof(wchar_t)) - 2;
3172         }
3173         info->text[length] = (wchar_t) 0;
3174         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringLength()", FALSE);
3175         jniEnv->ReleaseStringChars(js, stringBytes);
3176         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to ReleaseStringChars()", FALSE);
3177         // jniEnv->CallVoidMethod(accessBridgeObject,
3178         //                        decrementReferenceMethod, js);
3179         //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
3180         PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", info->text );
3181         jniEnv->DeleteLocalRef(js);
3182         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
3183 
3184     } else {
3185         PrintDebugString("[WARN]:   AccessibleHyperlink text is null.");
3186         info->text[0] = (wchar_t) 0;
3187     }
3188 
3189     info->startIndex = jniEnv->CallIntMethod(accessBridgeObject,
3190                                              getAccessibleHyperlinkStartIndexMethod,
3191                                              info->accessibleHyperlink,
3192                                              index);
3193     EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
3194     PrintDebugString("[INFO]:   ##### hyperlink start index = %d", info->startIndex);
3195 
3196     info->endIndex = jniEnv->CallIntMethod(accessBridgeObject,

3283 
3284     // get the icons
3285     for (int i = 0; i < icons->iconsCount && i < MAX_ICON_INFO; i++) {
3286 
3287         // get the icon description
3288         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3289                                                        getAccessibleIconDescriptionMethod,
3290                                                        accessibleContext,
3291                                                        i);
3292 
3293         EXCEPTION_CHECK("Getting icon description - call to CallObjectMethod()", FALSE);
3294         if (js != (jstring) 0) {
3295             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3296             EXCEPTION_CHECK("Getting AccessibleIcon description - call to GetStringChars()", FALSE);
3297             wcsncpy(icons->iconInfo[i].description, stringBytes, (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t)));
3298             length = jniEnv->GetStringLength(js);
3299             if (length >= (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t))) {
3300                 length = (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t)) - 2;
3301             }
3302             icons->iconInfo[i].description[length] = (wchar_t) 0;
3303             EXCEPTION_CHECK("Getting AccessibleIcon description - call to GetStringLength()", FALSE);
3304             jniEnv->ReleaseStringChars(js, stringBytes);
3305             EXCEPTION_CHECK("Getting AccessibleIcon description - call to ReleaseStringChars()", FALSE);
3306             // jniEnv->CallVoidMethod(accessBridgeObject,
3307             //                        decrementReferenceMethod, js);
3308             //EXCEPTION_CHECK("Getting AccessibleIcon description - call to CallVoidMethod()", FALSE);
3309             PrintDebugString("[INFO]: ##### AccessibleIcon description = %ls", icons->iconInfo[i].description );
3310             jniEnv->DeleteLocalRef(js);
3311             EXCEPTION_CHECK("Getting AccessibleIcon description - call to DeleteLocalRef()", FALSE);
3312         } else {
3313             PrintDebugString("[WARN]:   AccessibleIcon description is null.");
3314             icons->iconInfo[i].description[0] = (wchar_t) 0;
3315         }
3316 
3317 
3318         // get the icon height
3319         icons->iconInfo[i].height = jniEnv->CallIntMethod(accessBridgeObject,
3320                                                           getAccessibleIconHeightMethod,
3321                                                           accessibleContext,
3322                                                           i);
3323         EXCEPTION_CHECK("##### Getting icon height - call to CallIntMethod()", FALSE);
3324         PrintDebugString("[INFO]:   ##### icon height = %d", icons->iconInfo[i].height);
3325 

3362 
3363     // get the actions
3364     for (int i = 0; i < actions->actionsCount && i < MAX_ACTION_INFO; i++) {
3365 
3366         // get the action name
3367         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3368                                                        getAccessibleActionNameMethod,
3369                                                        accessibleContext,
3370                                                        i);
3371 
3372         EXCEPTION_CHECK("Getting Action Name  - call to CallObjectMethod()", FALSE);
3373         if (js != (jstring) 0) {
3374             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3375             EXCEPTION_CHECK("Getting AccessibleAction Name  - call to GetStringChars()", FALSE);
3376             wcsncpy(actions->actionInfo[i].name , stringBytes, (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t)));
3377             length = jniEnv->GetStringLength(js);
3378             if (length >= (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t))) {
3379                 length = (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t)) - 2;
3380             }
3381             actions->actionInfo[i].name [length] = (wchar_t) 0;
3382             EXCEPTION_CHECK("Getting AccessibleAction name  - call to GetStringLength()", FALSE);
3383             jniEnv->ReleaseStringChars(js, stringBytes);
3384             EXCEPTION_CHECK("Getting AccessibleAction name  - call to ReleaseStringChars()", FALSE);
3385             // jniEnv->CallVoidMethod(accessBridgeObject,
3386             //                        decrementReferenceMethod, js);
3387             //EXCEPTION_CHECK("Getting AccessibleAction name  - call to CallVoidMethod()", FALSE);
3388             PrintDebugString("[INFO]: ##### AccessibleAction name  = %ls", actions->actionInfo[i].name  );
3389             jniEnv->DeleteLocalRef(js);
3390             EXCEPTION_CHECK("Getting AccessibleAction name  - call to DeleteLocalRef()", FALSE);
3391         } else {
3392             PrintDebugString("[WARN]:   AccessibleAction name  is null.");
3393             actions->actionInfo[i].name [0] = (wchar_t) 0;
3394         }
3395     }
3396     return FALSE;
3397 }
3398 
3399 BOOL AccessBridgeJavaEntryPoints::doAccessibleActions(jobject accessibleContext,
3400                                                       AccessibleActionsToDo *actionsToDo,
3401                                                       jint *failure) {
3402 
3403     jthrowable exception;
3404     BOOL returnVal;

3544     } else {
3545         PrintDebugString("[ERROR]: either env == 0 or getAccessibleLetterAtIndexFromContextMethod == 0");
3546         return FALSE;
3547     }
3548 
3549 
3550     // Get the word at index
3551     if (getAccessibleWordAtIndexFromContextMethod != (jmethodID) 0) {
3552         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3553                                                 getAccessibleWordAtIndexFromContextMethod,
3554                                                 accessibleContext, index);
3555         EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to CallIntMethod()", FALSE);
3556         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
3557         if (js != (jstring) 0) {
3558             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3559             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to GetStringChars()", FALSE);
3560             wcsncpy(textItems->word, stringBytes, (sizeof(textItems->word) / sizeof(wchar_t)));
3561             length = jniEnv->GetStringLength(js);
3562             textItems->word[length < (sizeof(textItems->word) / sizeof(wchar_t)) ?
3563                             length : (sizeof(textItems->word) / sizeof(wchar_t))-2] = (wchar_t) 0;
3564             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to GetStringLength()", FALSE);
3565             jniEnv->ReleaseStringChars(js, stringBytes);
3566             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to ReleaseStringChars()", FALSE);
3567             jniEnv->CallVoidMethod(accessBridgeObject,
3568                                    decrementReferenceMethod, js);
3569             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to CallVoidMethod()", FALSE);
3570             wPrintDebugString(L"[INFO]:   Accessible Text word = %ls", textItems->word);
3571             jniEnv->DeleteLocalRef(js);
3572             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to DeleteLocalRef()", FALSE);
3573         } else {
3574             PrintDebugString("[WARN]:   Accessible Text word is null.");
3575             textItems->word[0] = (wchar_t) 0;
3576         }
3577     } else {
3578         PrintDebugString("[ERROR]: either env == 0 or getAccessibleWordAtIndexFromContextMethod == 0");
3579         return FALSE;
3580     }
3581 
3582     // Get the sentence at index
3583     if (getAccessibleSentenceAtIndexFromContextMethod != (jmethodID) 0) {
3584         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3585                                                 getAccessibleSentenceAtIndexFromContextMethod,
3586                                                 accessibleContext, index);
3587         EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to CallObjectMethod()", FALSE);
3588         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
3589         if (js != (jstring) 0) {
3590             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3591             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to GetStringChars()", FALSE);
3592             wcsncpy(textItems->sentence, stringBytes, (sizeof(textItems->sentence) / sizeof(wchar_t))-2);
3593             length = jniEnv->GetStringLength(js);
3594 
3595             if (length < sizeof(textItems->sentence) / sizeof(wchar_t)) {
3596                 textItems->sentence[length] = (wchar_t) 0;
3597             } else {
3598                 textItems->sentence[(sizeof(textItems->sentence) / sizeof(wchar_t))-2] = (wchar_t) 0;
3599             }
3600             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to GetStringLength()", FALSE);
3601             jniEnv->ReleaseStringChars(js, stringBytes);
3602             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to ReleaseStringChars()", FALSE);
3603             jniEnv->CallVoidMethod(accessBridgeObject,
3604                                    decrementReferenceMethod, js);
3605             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to CallVoidMethod()", FALSE);
3606             wPrintDebugString(L"[INFO]:   Accessible Text sentence = %ls", textItems->sentence);
3607             jniEnv->DeleteLocalRef(js);
3608             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to DeleteLocalRef()", FALSE);
3609         } else {
3610             PrintDebugString("[WARN]:   Accessible Text sentence is null.");
3611             textItems->sentence[0] = (wchar_t) 0;
3612         }
3613     } else {
3614         PrintDebugString("[ERROR]: either env == 0 or getAccessibleSentenceAtIndexFromContextMethod == 0");
3615         return FALSE;
3616     }
3617 
3618     return TRUE;
3619 }
3620 
3621 BOOL
3622 AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(jobject accessibleContext,

3656         PrintDebugString("[INFO]:   Selection end = %d", selectionInfo->selectionEndIndex);
3657     } else {
3658         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextSelectionEndFromContextMethod == 0");
3659         return FALSE;
3660     }
3661 
3662     // Get the selected text
3663     if (getAccessibleTextSelectedTextFromContextMethod != (jmethodID) 0) {
3664         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3665                                                 getAccessibleTextSelectedTextFromContextMethod,
3666                                                 accessibleContext);
3667         EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to CallObjectMethod()", FALSE);
3668         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
3669         if (js != (jstring) 0) {
3670             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3671             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to GetStringChars()", FALSE);
3672             wcsncpy(selectionInfo->selectedText, stringBytes, (sizeof(selectionInfo->selectedText) / sizeof(wchar_t)));
3673             length = jniEnv->GetStringLength(js);
3674             selectionInfo->selectedText[length < (sizeof(selectionInfo->selectedText) / sizeof(wchar_t)) ?
3675                                         length : (sizeof(selectionInfo->selectedText) / sizeof(wchar_t))-2] = (wchar_t) 0;
3676             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to GetStringLength()", FALSE);
3677             jniEnv->ReleaseStringChars(js, stringBytes);
3678             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to ReleaseStringChars()", FALSE);
3679             jniEnv->CallVoidMethod(accessBridgeObject,
3680                                    decrementReferenceMethod, js);
3681             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to CallVoidMethod()", FALSE);
3682             PrintDebugString("[INFO]:   Accessible's selected text = %s", selectionInfo->selectedText);
3683             jniEnv->DeleteLocalRef(js);
3684             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to DeleteLocalRef()", FALSE);
3685         } else {
3686             PrintDebugString("[WARN]:   Accessible's selected text is null.");
3687             selectionInfo->selectedText[0] = (wchar_t) 0;
3688         }
3689     } else {
3690         PrintDebugString("[WARN]: either env == 0 or getAccessibleTextSelectedTextFromContextMethod == 0");
3691         return FALSE;
3692     }
3693     return TRUE;
3694 }
3695 
3696 BOOL
3697 AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleContext, jint index, AccessibleTextAttributesInfo *attributes) {
3698     jstring js;

3873         EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to CallVoidMethod()", FALSE);
3874         jniEnv->DeleteLocalRef(AttributeSet);
3875         EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to DeleteLocalRef()", FALSE);
3876         return FALSE;
3877     }
3878 
3879     // Get the backgroundColor setting
3880     if (getBackgroundColorFromAttributeSetMethod != (jmethodID) 0) {
3881         PrintDebugString("[INFO]:  Getting backgroundColor from AttributeSet...");
3882         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3883                                                 getBackgroundColorFromAttributeSetMethod,
3884                                                 AttributeSet);
3885         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallObjectMethod()", FALSE);
3886         if (js != (jstring) 0) {
3887             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3888             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to GetStringChars()", FALSE);
3889             wcsncpy(attributes->backgroundColor, stringBytes, (sizeof(attributes->backgroundColor) / sizeof(wchar_t)));
3890             length = jniEnv->GetStringLength(js);
3891             attributes->backgroundColor[length < (sizeof(attributes->backgroundColor) / sizeof(wchar_t)) ?
3892                                         length : (sizeof(attributes->backgroundColor) / sizeof(wchar_t))-2] = (wchar_t) 0;
3893             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to GetStringLength()", FALSE);
3894             jniEnv->ReleaseStringChars(js, stringBytes);
3895             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to ReleaseStringChars()", FALSE);
3896             jniEnv->CallVoidMethod(accessBridgeObject,
3897                                    decrementReferenceMethod, js);
3898             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3899             wPrintDebugString(L"[INFO]:   AttributeSet's background color = %ls", attributes->backgroundColor);
3900             jniEnv->DeleteLocalRef(js);
3901             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3902         } else {
3903             PrintDebugString("[WARN]:   AttributeSet's background color is null.");
3904             attributes->backgroundColor[0] = (wchar_t) 0;
3905         }
3906     } else {
3907         PrintDebugString("[ERROR]: either env == 0 or getBackgroundColorFromAttributeSetMethod == 0");
3908         jniEnv->CallVoidMethod(accessBridgeObject,
3909                                decrementReferenceMethod, AttributeSet);
3910         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3911         jniEnv->DeleteLocalRef(AttributeSet);
3912         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3913         return FALSE;
3914     }
3915 
3916     // Get the foregroundColor setting
3917     if (getForegroundColorFromAttributeSetMethod != (jmethodID) 0) {
3918         PrintDebugString("[INFO]:  Getting foregroundColor from AttributeSet...");
3919         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3920                                                 getForegroundColorFromAttributeSetMethod,
3921                                                 AttributeSet);
3922         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallObjectMethod()", FALSE);
3923         if (js != (jstring) 0) {
3924             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3925             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to GetStringChars()", FALSE);
3926             wcsncpy(attributes->foregroundColor, stringBytes, (sizeof(attributes->foregroundColor) / sizeof(wchar_t)));
3927             length = jniEnv->GetStringLength(js);
3928             attributes->foregroundColor[length < (sizeof(attributes->foregroundColor) / sizeof(wchar_t)) ?
3929                                         length : (sizeof(attributes->foregroundColor) / sizeof(wchar_t))-2] = (wchar_t) 0;
3930             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to GetStringLength()", FALSE);
3931             jniEnv->ReleaseStringChars(js, stringBytes);
3932             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to ReleaseStringChars()", FALSE);
3933             jniEnv->CallVoidMethod(accessBridgeObject,
3934                                    decrementReferenceMethod, js);
3935             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3936             wPrintDebugString(L"[INFO]:   AttributeSet's foreground color = %ls", attributes->foregroundColor);
3937             jniEnv->DeleteLocalRef(js);
3938             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3939         } else {
3940             PrintDebugString("[WARN]:   AttributeSet's foreground color is null.");
3941             attributes->foregroundColor[0] = (wchar_t) 0;
3942         }
3943     } else {
3944         PrintDebugString("[ERROR]: either env == 0 or getForegroundColorFromAttributeSetMethod == 0");
3945         jniEnv->CallVoidMethod(accessBridgeObject,
3946                                decrementReferenceMethod, AttributeSet);
3947         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3948         jniEnv->DeleteLocalRef(AttributeSet);
3949         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3950         return FALSE;
3951     }
3952 
3953     // Get the fontFamily setting
3954     if (getFontFamilyFromAttributeSetMethod != (jmethodID) 0) {
3955         PrintDebugString("[INFO]:  Getting fontFamily from AttributeSet...");
3956         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3957                                                 getFontFamilyFromAttributeSetMethod,
3958                                                 AttributeSet);
3959         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallObjectMethod()", FALSE);
3960         if (js != (jstring) 0) {
3961             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3962             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to GetStringChars()", FALSE);
3963             wcsncpy(attributes->fontFamily, stringBytes, (sizeof(attributes->fontFamily) / sizeof(wchar_t)));
3964             length = jniEnv->GetStringLength(js);
3965             attributes->fontFamily[length < (sizeof(attributes->fontFamily) / sizeof(wchar_t)) ?
3966                                    length : (sizeof(attributes->fontFamily) / sizeof(wchar_t))-2] = (wchar_t) 0;
3967             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to GetStringLength()", FALSE);
3968             jniEnv->ReleaseStringChars(js, stringBytes);
3969             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to ReleaseStringChars()", FALSE);
3970             jniEnv->CallVoidMethod(accessBridgeObject,
3971                                    decrementReferenceMethod, js);
3972             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallVoidMethod()", FALSE);
3973             wPrintDebugString(L"[INFO]:   AttributeSet's fontFamily = %ls", attributes->fontFamily);
3974             jniEnv->DeleteLocalRef(js);
3975             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to DeleteLocalRef()", FALSE);
3976         } else {
3977             PrintDebugString("[WARN]:   AttributeSet's fontFamily is null.");
3978             attributes->backgroundColor[0] = (wchar_t) 0;
3979         }
3980     } else {
3981         PrintDebugString("[ERROR]: either env == 0 or getFontFamilyFromAttributeSetMethod == 0");
3982         jniEnv->CallVoidMethod(accessBridgeObject,
3983                                decrementReferenceMethod, AttributeSet);
3984         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallVoidMethod()", FALSE);
3985         jniEnv->DeleteLocalRef(AttributeSet);
3986         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to DeleteLocalRef()", FALSE);
3987         return FALSE;
3988     }
3989 

4153         jniEnv->DeleteLocalRef(AttributeSet);
4154         EXCEPTION_CHECK("Releasing AttributeSet object - call to DeleteLocalRef()", FALSE);
4155         return FALSE;
4156     }
4157 
4158     // Get the full attributes string at index
4159     if (getAccessibleAttributesAtIndexFromContextMethod != (jmethodID) 0) {
4160         PrintDebugString("[INFO]:  Getting full attributes string from Context...");
4161         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4162                                                 getAccessibleAttributesAtIndexFromContextMethod,
4163                                                 accessibleContext, index);
4164         EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallObjectMethod()", FALSE);
4165         PrintDebugString("[INFO]:  returned from CallObjectMethod(), js = %p", js);
4166         if (js != (jstring) 0) {
4167             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4168             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE);
4169             wcsncpy(attributes->fullAttributesString, stringBytes, (sizeof(attributes->fullAttributesString) / sizeof(wchar_t)));
4170             length = jniEnv->GetStringLength(js);
4171             attributes->fullAttributesString[length < (sizeof(attributes->fullAttributesString) / sizeof(wchar_t)) ?
4172                                              length : (sizeof(attributes->fullAttributesString) / sizeof(wchar_t))-2] = (wchar_t) 0;
4173             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringLength()", FALSE);
4174             jniEnv->ReleaseStringChars(js, stringBytes);
4175             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to ReleaseStringChars()", FALSE);
4176             jniEnv->CallVoidMethod(accessBridgeObject,
4177                                    decrementReferenceMethod, js);
4178             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE);
4179             wPrintDebugString(L"[INFO]:   Accessible Text attributes = %ls", attributes->fullAttributesString);
4180             jniEnv->DeleteLocalRef(js);
4181             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
4182         } else {
4183             PrintDebugString("[WARN]:   Accessible Text attributes is null.");
4184             attributes->fullAttributesString[0] = (wchar_t) 0;
4185             jniEnv->DeleteLocalRef(AttributeSet);
4186             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
4187             return FALSE;
4188         }
4189     } else {
4190         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0");
4191         jniEnv->DeleteLocalRef(AttributeSet);
4192         return FALSE;
4193     }
4194 
4195     jniEnv->DeleteLocalRef(AttributeSet);

4396         text[0] = (wchar_t) 0;
4397         return FALSE;
4398     }
4399 
4400     // Get the text range within [start, end] inclusive
4401     if (getAccessibleTextRangeFromContextMethod != (jmethodID) 0) {
4402         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4403                                                 getAccessibleTextRangeFromContextMethod,
4404                                                 accessibleContext, start, end);
4405         EXCEPTION_CHECK("Getting AccessibleTextRange - call to CallObjectMethod()", FALSE);
4406         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4407         if (js != (jstring) 0) {
4408             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4409             EXCEPTION_CHECK("Getting AccessibleTextRange - call to GetStringChars()", FALSE);
4410             wPrintDebugString(L"[INFO]:   Accessible Text stringBytes returned from Java = %ls", stringBytes);
4411             wcsncpy(text, stringBytes, len);
4412             length = jniEnv->GetStringLength(js);
4413             PrintDebugString("[INFO]:  Accessible Text stringBytes length = %d", length);
4414             text[length < len ? length : len - 2] = (wchar_t) 0;
4415             wPrintDebugString(L"[INFO]:   Accessible Text 'text' after null termination = %ls", text);
4416             EXCEPTION_CHECK("Getting AccessibleTextRange - call to GetStringLength()", FALSE);
4417             jniEnv->ReleaseStringChars(js, stringBytes);
4418             EXCEPTION_CHECK("Getting AccessibleTextRange - call to ReleaseStringChars()", FALSE);
4419             jniEnv->CallVoidMethod(accessBridgeObject,
4420                                    decrementReferenceMethod, js);
4421             EXCEPTION_CHECK("Getting AccessibleTextRange - call to CallVoidMethod()", FALSE);
4422             wPrintDebugString(L"[INFO]:   Accessible Text range = %ls", text);
4423             jniEnv->DeleteLocalRef(js);
4424             EXCEPTION_CHECK("Getting AccessibleTextRange - call to DeleteLocalRef()", FALSE);
4425         } else {
4426             PrintDebugString("[WARN]:   current Accessible Text range is null.");
4427             text[0] = (wchar_t) 0;
4428             return FALSE;
4429         }
4430     } else {
4431         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextRangeFromContextMethod == 0");
4432         return FALSE;
4433     }
4434     return TRUE;
4435 }
4436 
4437 /********** AccessibleValue routines ***************/
4438 

4441     jstring js;
4442     const wchar_t *stringBytes;
4443     jthrowable exception;
4444     jsize length;
4445 
4446     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getCurrentAccessibleValueFromContext(%p):", accessibleContext);
4447 
4448     // Get the current Accessible Value
4449     if (getCurrentAccessibleValueFromContextMethod != (jmethodID) 0) {
4450         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4451                                                 getCurrentAccessibleValueFromContextMethod,
4452                                                 accessibleContext);
4453         EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to CallObjectMethod()", FALSE);
4454         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4455         if (js != (jstring) 0) {
4456             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4457             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to GetStringChars()", FALSE);
4458             wcsncpy(value, stringBytes, len);
4459             length = jniEnv->GetStringLength(js);
4460             value[length < len ? length : len - 2] = (wchar_t) 0;
4461             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to GetStringLength()", FALSE);
4462             jniEnv->ReleaseStringChars(js, stringBytes);
4463             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to ReleaseStringChars()", FALSE);
4464             jniEnv->CallVoidMethod(accessBridgeObject,
4465                                    decrementReferenceMethod, js);
4466             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to CallVoidMethod()", FALSE);
4467             PrintDebugString("[INFO]:   current Accessible Value = %s", value);
4468             jniEnv->DeleteLocalRef(js);
4469             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to DeleteLocalRef()", FALSE);
4470         } else {
4471             PrintDebugString("[WARN]:   current Accessible Value is null.");
4472             value[0] = (wchar_t) 0;
4473             return FALSE;
4474         }
4475     } else {
4476         PrintDebugString("[ERROR]:  either env == 0 or getCurrentAccessibleValueFromContextMethod == 0");
4477         return FALSE;
4478     }
4479     return TRUE;
4480 }
4481 
4482 BOOL
4483 AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(jobject accessibleContext, wchar_t *value, short len) {
4484     jstring js;
4485     const wchar_t *stringBytes;
4486     jthrowable exception;
4487     jsize length;
4488 
4489     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(%p):", accessibleContext);
4490 
4491     // Get the maximum Accessible Value
4492     if (getMaximumAccessibleValueFromContextMethod != (jmethodID) 0) {
4493         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4494                                                 getMaximumAccessibleValueFromContextMethod,
4495                                                 accessibleContext);
4496         EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to CallObjectMethod()", FALSE);
4497         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4498         if (js != (jstring) 0) {
4499             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4500             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to GetStringChars()", FALSE);
4501             wcsncpy(value, stringBytes, len);
4502             length = jniEnv->GetStringLength(js);
4503             value[length < len ? length : len - 2] = (wchar_t) 0;
4504             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to GetStringLength()", FALSE);
4505             jniEnv->ReleaseStringChars(js, stringBytes);
4506             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to ReleaseStringChars()", FALSE);
4507             jniEnv->CallVoidMethod(accessBridgeObject,
4508                                    decrementReferenceMethod, js);
4509             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to CallVoidMethod()", FALSE);
4510             PrintDebugString("[INFO]:   maximum Accessible Value = %s", value);
4511             jniEnv->DeleteLocalRef(js);
4512             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to DeleteLocalRef()", FALSE);
4513         } else {
4514             PrintDebugString("[WARN]:   maximum Accessible Value is null.");
4515             value[0] = (wchar_t) 0;
4516             return FALSE;
4517         }
4518     } else {
4519         PrintDebugString("[ERROR]: either env == 0 or getMaximumAccessibleValueFromContextMethod == 0");
4520         return FALSE;
4521     }
4522     return TRUE;
4523 }
4524 
4525 BOOL
4526 AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(jobject accessibleContext, wchar_t *value, short len) {
4527     jstring js;
4528     const wchar_t *stringBytes;
4529     jthrowable exception;
4530     jsize length;
4531 
4532     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(%p):", accessibleContext);
4533 
4534     // Get the mimimum Accessible Value
4535     if (getMinimumAccessibleValueFromContextMethod != (jmethodID) 0) {
4536         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4537                                                 getMinimumAccessibleValueFromContextMethod,
4538                                                 accessibleContext);
4539         EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to CallObjectMethod()", FALSE);
4540         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4541         if (js != (jstring) 0) {
4542             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4543             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to GetStringChars()", FALSE);
4544             wcsncpy(value, stringBytes, len);
4545             length = jniEnv->GetStringLength(js);
4546             value[length < len ? length : len - 2] = (wchar_t) 0;
4547             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to GetStringLength()", FALSE);
4548             jniEnv->ReleaseStringChars(js, stringBytes);
4549             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to ReleaseStringChars()", FALSE);
4550             jniEnv->CallVoidMethod(accessBridgeObject,
4551                                    decrementReferenceMethod, js);
4552             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to CallVoidMethod()", FALSE);
4553             PrintDebugString("[INFO]:   mimimum Accessible Value = %s", value);
4554             jniEnv->DeleteLocalRef(js);
4555             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to DeleteLocalRef()", FALSE);
4556         } else {
4557             PrintDebugString("[WARN]:   mimimum Accessible Value is null.");
4558             value[0] = (wchar_t) 0;
4559             return FALSE;
4560         }
4561     } else {
4562         PrintDebugString("[ERROR]: either env == 0 or getMinimumAccessibleValueFromContextMethod == 0");
4563         return FALSE;
4564     }
4565     return TRUE;
4566 }
4567 
4568 
4569 /********** AccessibleSelection routines ***************/

   1 /*
   2  * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any

  65         PrintDebugString("[ERROR]: FindClass(%s) failed! ->  (ran out of RAM)", className); \
  66         return FALSE; \
  67     }
  68 
  69 
  70 #define FIND_METHOD(methodID, classRef, methodString, methodSignature); \
  71     methodID = jniEnv->GetMethodID(classRef, methodString,  methodSignature); \
  72     if (methodID == (jmethodID) 0) { \
  73         PrintDebugString("[ERROR]: GetMethodID(%s) failed! -> jniEnv = %p; classRef = %p", methodString, jniEnv, classRef); \
  74         return FALSE; \
  75     }
  76 
  77 #define EXCEPTION_CHECK(situationDescription, returnVal)                                        \
  78     if (exception = jniEnv->ExceptionOccurred()) {                                              \
  79         PrintDebugString("[ERROR]: *** Exception occured while doing: %s; returning %d", situationDescription, returnVal);   \
  80         jniEnv->ExceptionDescribe();                                                            \
  81         jniEnv->ExceptionClear();                                                               \
  82         return (returnVal);                                                                     \
  83     }
  84 
  85 #define EXCEPTION_CHECK_WITH_RELEASE(situationDescription, returnVal, js, stringBytes)          \
  86     if (exception = jniEnv->ExceptionOccurred()) {                                              \
  87         PrintDebugString("[ERROR]: *** Exception occured while doing: %s - call to GetStringLength; returning %d", situationDescription, returnVal);   \
  88         jniEnv->ExceptionDescribe();                                                            \
  89         jniEnv->ExceptionClear();                                                               \
  90         jniEnv->ReleaseStringChars(js, stringBytes);                                            \
  91         return (returnVal);                                                                     \
  92     }                                                                                           \
  93     jniEnv->ReleaseStringChars(js, stringBytes);                                                \
  94     if (exception = jniEnv->ExceptionOccurred()) {                                              \
  95         PrintDebugString("[ERROR]: *** Exception occured while doing: %s - call to ReleaseStringChars; returning %d", situationDescription, returnVal);   \
  96         jniEnv->ExceptionDescribe();                                                            \
  97         jniEnv->ExceptionClear();                                                               \
  98         return (returnVal);                                                                     \
  99     }
 100 
 101 #define EXCEPTION_CHECK_VOID(situationDescription)                                              \
 102     if (exception = jniEnv->ExceptionOccurred()) {                                              \
 103         PrintDebugString("[ERROR]: *** Exception occured while doing: %s", situationDescription);   \
 104         jniEnv->ExceptionDescribe();                                                            \
 105         jniEnv->ExceptionClear();                                                               \
 106         return;                                                                                 \
 107     }
 108 
 109 /**
 110  * Make all of the getClass() & getMethod() calls
 111  *
 112  */
 113 BOOL
 114 AccessBridgeJavaEntryPoints::BuildJavaEntryPoints() {
 115     jclass localClassRef;
 116 
 117     PrintDebugString("[INFO]: Calling BuildJavaEntryPoints():");
 118 
 119     FIND_CLASS(bridgeClass, "com/sun/java/accessibility/internal/AccessBridge");
 120 

1214     }
1215 
1216     jstring js = NULL;
1217     const wchar_t * stringBytes = NULL;
1218     jthrowable exception = NULL;
1219     jsize length = 0;
1220     PrintDebugString("[INFO]:  getVirtualAccessibleName called.");
1221     if (getVirtualAccessibleNameFromContextMethod != (jmethodID) 0)
1222     {
1223         js = (jstring) jniEnv->CallObjectMethod (
1224             accessBridgeObject,
1225             getVirtualAccessibleNameFromContextMethod,
1226             object);
1227         EXCEPTION_CHECK("Getting AccessibleName - call to CallObjectMethod()", FALSE);
1228         if (js != (jstring) 0)
1229         {
1230             stringBytes = (const wchar_t *) jniEnv->GetStringChars (js, 0);
1231             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1232             wcsncpy(name, stringBytes, nameSize - 1);
1233             length = jniEnv->GetStringLength(js);
1234             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleName", FALSE, js, stringBytes);


1235             jniEnv->CallVoidMethod (
1236                 accessBridgeObject,
1237                 decrementReferenceMethod, js);
1238             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1239             wPrintDebugString(L"  Accessible Name = %ls", name);
1240             jniEnv->DeleteLocalRef(js);
1241             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1242         }
1243         else
1244         {
1245             PrintDebugString("[INFO]:   Accessible Name is null.");
1246         }
1247     }
1248     else
1249     {
1250         PrintDebugString("[INFO]: either jniEnv == 0 or getVirtualAccessibleNameFromContextMethod == 0");
1251         return FALSE;
1252     }
1253     if ( 0 != name [0] )
1254     {

1377     (*len)++;
1378 
1379     for (jint i = startIndex+1; i <= endIndex; i++) {
1380 
1381         AccessibleTextAttributesInfo test_attributes = *attributes;
1382         // Get the full test_attributes string at i
1383         if (getAccessibleAttributesAtIndexFromContextMethod != (jmethodID) 0) {
1384             PrintDebugString("[INFO]:  Getting full test_attributes string from Context...");
1385             js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1386                                                     getAccessibleAttributesAtIndexFromContextMethod,
1387                                                     accessibleContext, i);
1388             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallObjectMethod()", FALSE);
1389             PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
1390             if (js != (jstring) 0) {
1391                 stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1392                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE);
1393                 wcsncpy(test_attributes.fullAttributesString, stringBytes, (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t)));
1394                 length = jniEnv->GetStringLength(js);
1395                 test_attributes.fullAttributesString[length < (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t)) ?
1396                                                      length : (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t))-2] = (wchar_t) 0;
1397                 EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleAttributesAtIndex", FALSE, js, stringBytes);


1398                 jniEnv->CallVoidMethod(accessBridgeObject,
1399                                        decrementReferenceMethod, js);
1400                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE);
1401                 wPrintDebugString(L"[INFO]:  Accessible Text attributes = %ls", test_attributes.fullAttributesString);
1402                 jniEnv->DeleteLocalRef(js);
1403                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
1404             } else {
1405                 PrintDebugString("[WARN]:   Accessible Text attributes is null.");
1406                 test_attributes.fullAttributesString[0] = (wchar_t) 0;
1407                 return FALSE;
1408             }
1409         } else {
1410             PrintDebugString("[ERROR]: either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0");
1411             return FALSE;
1412         }
1413 
1414         if(wcscmp(attributes->fullAttributesString,test_attributes.fullAttributesString))
1415             break;
1416         if (result != TRUE) {
1417             return FALSE;

1730     PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleContextInfo(%p):", accessibleContext);
1731 
1732     ZeroMemory(info, sizeof(AccessibleContextInfo));
1733 
1734     if (accessibleContext == (jobject) 0) {
1735         PrintDebugString("[WARN]:  passed in AccessibleContext == null! (oops)");
1736         return (FALSE);
1737     }
1738 
1739     // Get the Accessible Name
1740     if (getAccessibleNameFromContextMethod != (jmethodID) 0) {
1741         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1742                                                 getAccessibleNameFromContextMethod,
1743                                                 accessibleContext);
1744         EXCEPTION_CHECK("Getting AccessibleName - call to CallObjectMethod()", FALSE);
1745         if (js != (jstring) 0) {
1746             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1747             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1748             wcsncpy(info->name, stringBytes, (sizeof(info->name) / sizeof(wchar_t)));
1749             length = jniEnv->GetStringLength(js);
1750             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleName", FALSE, js, stringBytes);
1751             info->name[length < (sizeof(info->name) / sizeof(wchar_t)) ?
1752                        length : (sizeof(info->name) / sizeof(wchar_t))-2] = (wchar_t) 0;



1753             jniEnv->CallVoidMethod(accessBridgeObject,
1754                                    decrementReferenceMethod, js);
1755             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1756             wPrintDebugString(L"[INFO]:   Accessible Name = %ls", info->name);
1757             jniEnv->DeleteLocalRef(js);
1758             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1759         } else {
1760             PrintDebugString("[WARN]:   Accessible Name is null.");
1761             info->name[0] = (wchar_t) 0;
1762         }
1763     } else {
1764         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleNameFromContextMethod == 0");
1765         return FALSE;
1766     }
1767 
1768 
1769     // Get the Accessible Description
1770     if (getAccessibleDescriptionFromContextMethod != (jmethodID) 0) {
1771         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1772                                                 getAccessibleDescriptionFromContextMethod,
1773                                                 accessibleContext);
1774         EXCEPTION_CHECK("Getting AccessibleDescription - call to CallObjectMethod()", FALSE);
1775         if (js != (jstring) 0) {
1776             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1777             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1778             wcsncpy(info->description, stringBytes, (sizeof(info->description) / sizeof(wchar_t)));
1779             length = jniEnv->GetStringLength(js);
1780             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleName", FALSE, js, stringBytes);
1781             info->description[length < (sizeof(info->description) / sizeof(wchar_t)) ?
1782                               length : (sizeof(info->description) / sizeof(wchar_t))-2] = (wchar_t) 0;



1783             jniEnv->CallVoidMethod(accessBridgeObject,
1784                                    decrementReferenceMethod, js);
1785             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1786             wPrintDebugString(L"[INFO]:   Accessible Description = %ls", info->description);
1787             jniEnv->DeleteLocalRef(js);
1788             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1789         } else {
1790             PrintDebugString("[WARN]:   Accessible Description is null.");
1791             info->description[0] = (wchar_t) 0;
1792         }
1793     } else {
1794         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleDescriptionFromContextMethod == 0");
1795         return FALSE;
1796     }
1797 
1798 
1799     // Get the Accessible Role String
1800     if (getAccessibleRoleStringFromContextMethod != (jmethodID) 0) {
1801         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1802                                                 getAccessibleRoleStringFromContextMethod,
1803                                                 accessibleContext);
1804         EXCEPTION_CHECK("Getting AccessibleRole - call to CallObjectMethod()", FALSE);
1805         if (js != (jstring) 0) {
1806             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1807             EXCEPTION_CHECK("Getting AccessibleRole - call to GetStringChars()", FALSE);
1808             wcsncpy(info->role, stringBytes, (sizeof(info->role) / sizeof(wchar_t)));
1809             length = jniEnv->GetStringLength(js);
1810             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleRole", FALSE, js, stringBytes);
1811             info->role[length < (sizeof(info->role) / sizeof(wchar_t)) ?
1812                        length : (sizeof(info->role) / sizeof(wchar_t))-2] = (wchar_t) 0;



1813             jniEnv->CallVoidMethod(accessBridgeObject,
1814                                    decrementReferenceMethod, js);
1815             EXCEPTION_CHECK("Getting AccessibleRole - call to CallVoidMethod()", FALSE);
1816             wPrintDebugString(L"[INFO]:   Accessible Role = %ls", info->role);
1817             jniEnv->DeleteLocalRef(js);
1818             EXCEPTION_CHECK("Getting AccessibleRole - call to DeleteLocalRef()", FALSE);
1819         } else {
1820             PrintDebugString("[WARN]:   Accessible Role is null.");
1821             info->role[0] = (wchar_t) 0;
1822         }
1823     } else {
1824         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleRoleStringFromContextMethod == 0");
1825         return FALSE;
1826     }
1827 
1828 
1829     // Get the Accessible Role String in the en_US locale
1830     if (getAccessibleRoleStringFromContext_en_USMethod != (jmethodID) 0) {
1831         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1832                                                 getAccessibleRoleStringFromContext_en_USMethod,
1833                                                 accessibleContext);
1834         EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to CallObjectMethod()", FALSE);
1835         if (js != (jstring) 0) {
1836             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1837             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to GetStringChars()", FALSE);
1838             wcsncpy(info->role_en_US, stringBytes, (sizeof(info->role_en_US) / sizeof(wchar_t)));
1839             length = jniEnv->GetStringLength(js);
1840             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleRole_en_US", FALSE, js, stringBytes);
1841             info->role_en_US[length < (sizeof(info->role_en_US) / sizeof(wchar_t)) ?
1842                              length : (sizeof(info->role_en_US) / sizeof(wchar_t))-2] = (wchar_t) 0;



1843             jniEnv->CallVoidMethod(accessBridgeObject,
1844                                    decrementReferenceMethod, js);
1845             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to CallVoidMethod()", FALSE);
1846             wPrintDebugString(L"[INFO]:   Accessible Role en_US = %ls", info->role_en_US);
1847             jniEnv->DeleteLocalRef(js);
1848             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to DeleteLocalRef()", FALSE);
1849         } else {
1850             PrintDebugString("[WARN]:   Accessible Role en_US is null.");
1851             info->role[0] = (wchar_t) 0;
1852         }
1853     } else {
1854         PrintDebugString("[ERROR]: either env == 0 or getAccessibleRoleStringFromContext_en_USMethod == 0");
1855         return FALSE;
1856     }
1857 
1858     // Get the Accessible States String
1859     if (getAccessibleStatesStringFromContextMethod != (jmethodID) 0) {
1860         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1861                                                 getAccessibleStatesStringFromContextMethod,
1862                                                 accessibleContext);
1863         EXCEPTION_CHECK("Getting AccessibleState - call to CallObjectMethod()", FALSE);
1864         if (js != (jstring) 0) {
1865             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1866             EXCEPTION_CHECK("Getting AccessibleState - call to GetStringChars()", FALSE);
1867             wcsncpy(info->states, stringBytes, (sizeof(info->states) / sizeof(wchar_t)));
1868             length = jniEnv->GetStringLength(js);
1869             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleState", FALSE, js, stringBytes);
1870             info->states[length < (sizeof(info->states) / sizeof(wchar_t)) ?
1871                          length : (sizeof(info->states) / sizeof(wchar_t))-2] = (wchar_t) 0;



1872             jniEnv->CallVoidMethod(accessBridgeObject,
1873                                    decrementReferenceMethod, js);
1874             EXCEPTION_CHECK("Getting AccessibleState - call to CallVoidMethod()", FALSE);
1875             wPrintDebugString(L"[INFO]:   Accessible States = %ls", info->states);
1876             jniEnv->DeleteLocalRef(js);
1877             EXCEPTION_CHECK("Getting AccessibleState - call to DeleteLocalRef()", FALSE);
1878         } else {
1879             PrintDebugString("[WARN]:   Accessible States is null.");
1880             info->states[0] = (wchar_t) 0;
1881         }
1882     } else {
1883         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleStatesStringFromContextMethod == 0");
1884         return FALSE;
1885     }
1886 
1887     // Get the Accessible States String in the en_US locale
1888     if (getAccessibleStatesStringFromContext_en_USMethod != (jmethodID) 0) {
1889         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1890                                                 getAccessibleStatesStringFromContext_en_USMethod,
1891                                                 accessibleContext);
1892         EXCEPTION_CHECK("Getting AccessibleState_en_US - call to CallObjectMethod()", FALSE);
1893         if (js != (jstring) 0) {
1894             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1895             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to GetStringChars()", FALSE);
1896             wcsncpy(info->states_en_US, stringBytes, (sizeof(info->states_en_US) / sizeof(wchar_t)));
1897             length = jniEnv->GetStringLength(js);
1898             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleState_en_US", FALSE, js, stringBytes);
1899             info->states_en_US[length < (sizeof(info->states_en_US) / sizeof(wchar_t)) ?
1900                                length : (sizeof(info->states_en_US) / sizeof(wchar_t))-2] = (wchar_t) 0;



1901             jniEnv->CallVoidMethod(accessBridgeObject,
1902                                    decrementReferenceMethod, js);
1903             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to CallVoidMethod()", FALSE);
1904             wPrintDebugString(L"[INFO]:   Accessible States en_US = %ls", info->states_en_US);
1905             jniEnv->DeleteLocalRef(js);
1906             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to DeleteLocalRef()", FALSE);
1907         } else {
1908             PrintDebugString("[WARN]:   Accessible States en_US is null.");
1909             info->states[0] = (wchar_t) 0;
1910         }
1911     } else {
1912         PrintDebugString("[ERROR]: either env == 0 or getAccessibleStatesStringFromContext_en_USMethod == 0");
1913         return FALSE;
1914     }
1915 
1916 
1917     // Get the index in Parent
1918     if (getAccessibleIndexInParentFromContextMethod != (jmethodID) 0) {
1919         info->indexInParent = jniEnv->CallIntMethod(accessBridgeObject,
1920                                                     getAccessibleIndexInParentFromContextMethod,

2792                                                        getAccessibleRelationCountMethod,
2793                                                        accessibleContext);
2794     EXCEPTION_CHECK("##### Getting AccessibleRelationCount - call to CallIntMethod()", FALSE);
2795     PrintDebugString("[INFO]:   ##### AccessibleRelation count = %d", relationSet->relationCount);
2796 
2797 
2798     // Get the relation set
2799     for (int i = 0; i < relationSet->relationCount && i < MAX_RELATIONS; i++) {
2800 
2801         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
2802                                                        getAccessibleRelationKeyMethod,
2803                                                        accessibleContext,
2804                                                        i);
2805 
2806         EXCEPTION_CHECK("Getting AccessibleRelationKey - call to CallObjectMethod()", FALSE);
2807         if (js != (jstring) 0) {
2808             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
2809             EXCEPTION_CHECK("Getting AccessibleRelation key - call to GetStringChars()", FALSE);
2810             wcsncpy(relationSet->relations[i].key, stringBytes, (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t)));
2811             length = jniEnv->GetStringLength(js);
2812             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleRelation key", FALSE, js, stringBytes);
2813             relationSet->relations[i].key [length < (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t)) ?
2814                                            length : (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t))-2] = (wchar_t) 0;



2815             // jniEnv->CallVoidMethod(accessBridgeObject,
2816             //                        decrementReferenceMethod, js);
2817             //EXCEPTION_CHECK("Getting AccessibleRelation key - call to CallVoidMethod()", FALSE);
2818             PrintDebugString("[INFO]: ##### AccessibleRelation key = %ls", relationSet->relations[i].key );
2819             jniEnv->DeleteLocalRef(js);
2820             EXCEPTION_CHECK("Getting AccessibleRelation key - call to DeleteLocalRef()", FALSE);
2821         } else {
2822             PrintDebugString("[WARN]:   AccessibleRelation key is null.");
2823             relationSet->relations[i].key [0] = (wchar_t) 0;
2824         }
2825 
2826         relationSet->relations[i].targetCount = jniEnv->CallIntMethod(accessBridgeObject,
2827                                                                       getAccessibleRelationTargetCountMethod,
2828                                                                       accessibleContext,
2829                                                                       i);
2830 
2831         for (int j = 0; j < relationSet->relations[i].targetCount && j < MAX_RELATION_TARGETS; j++) {
2832             jobject target = jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleRelationTargetMethod,
2833                                                       accessibleContext, i, j);
2834             EXCEPTION_CHECK("Getting AccessibleRelationSet - call to CallObjectMethod()", FALSE);

2896         EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to NewGlobalRef()", FALSE);
2897         hypertext->links[i].accessibleHyperlink = (JOBJECT64)globalRef;
2898         PrintDebugString("[INFO]:   ##### AccessibleHyperlink = %p", globalRef);
2899 
2900         // get the hyperlink text
2901         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
2902                                                        getAccessibleHyperlinkTextMethod,
2903                                                        hypertext->links[i].accessibleHyperlink,
2904                                                        i);
2905 
2906         EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
2907         if (js != (jstring) 0) {
2908             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
2909             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
2910             wcsncpy(hypertext->links[i].text, stringBytes, (sizeof(hypertext->links[i].text) / sizeof(wchar_t)));
2911             length = jniEnv->GetStringLength(js);
2912             if (length >= (sizeof(hypertext->links[i].text) / sizeof(wchar_t))) {
2913                 length = (sizeof(hypertext->links[i].text) / sizeof(wchar_t)) - 2;
2914             }
2915             hypertext->links[i].text[length] = (wchar_t) 0;
2916             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleHyperlink text", FALSE, js, stringBytes);


2917             // jniEnv->CallVoidMethod(accessBridgeObject,
2918             //                                     decrementReferenceMethod, js);
2919             //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
2920             PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", hypertext->links[i].text );
2921             jniEnv->DeleteLocalRef(js);
2922             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
2923         } else {
2924             PrintDebugString("[WARN]:   AccessibleHyperlink text is null.");
2925             hypertext->links[i].text[0] = (wchar_t) 0;
2926         }
2927 
2928         hypertext->links[i].startIndex = jniEnv->CallIntMethod(accessBridgeObject,
2929                                                                getAccessibleHyperlinkStartIndexMethod,
2930                                                                hypertext->links[i].accessibleHyperlink,
2931                                                                i);
2932         EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
2933         PrintDebugString("[INFO]:   ##### hyperlink start index = %d", hypertext->links[i].startIndex);
2934 
2935 
2936         hypertext->links[i].endIndex = jniEnv->CallIntMethod(accessBridgeObject,

3031         hypertext->links[bufIndex].accessibleHyperlink = (JOBJECT64)globalRef;
3032         PrintDebugString("[INFO]:   ##### AccessibleHyperlink = %p", globalRef);
3033 
3034         // get the hyperlink text
3035         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3036                                                        getAccessibleHyperlinkTextMethod,
3037                                                        hypertext->links[bufIndex].accessibleHyperlink,
3038                                                        i);
3039 
3040         EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
3041         if (js != (jstring) 0) {
3042             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3043             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
3044             wcsncpy(hypertext->links[bufIndex].text, stringBytes,
3045                     (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t)));
3046             length = jniEnv->GetStringLength(js);
3047             if (length >= (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t))) {
3048                 length = (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t)) - 2;
3049             }
3050             hypertext->links[bufIndex].text[length] = (wchar_t) 0;
3051             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleHyperlink text", FALSE, js, stringBytes);


3052             // jniEnv->CallVoidMethod(accessBridgeObject,
3053             //                        decrementReferenceMethod, js);
3054             //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
3055             PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", hypertext->links[bufIndex].text );
3056             jniEnv->DeleteLocalRef(js);
3057             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
3058 
3059         } else {
3060             PrintDebugString("[WARN]:   AccessibleHyperlink text is null.");
3061             hypertext->links[bufIndex].text[0] = (wchar_t) 0;
3062         }
3063 
3064         hypertext->links[bufIndex].startIndex = jniEnv->CallIntMethod(accessBridgeObject,
3065                                                                       getAccessibleHyperlinkStartIndexMethod,
3066                                                                       hypertext->links[bufIndex].accessibleHyperlink,
3067                                                                       i);
3068         EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
3069         PrintDebugString("[INFO]:   ##### hyperlink start index = %d", hypertext->links[bufIndex].startIndex);
3070 
3071         hypertext->links[bufIndex].endIndex = jniEnv->CallIntMethod(accessBridgeObject,

3148     info->accessibleHyperlink = (JOBJECT64)globalRef;
3149     PrintDebugString("[INFO]:   ##### AccessibleHyperlink = %p", globalRef);
3150 
3151     // get the hyperlink text
3152     jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3153                                                    getAccessibleHyperlinkTextMethod,
3154                                                    info->accessibleHyperlink,
3155                                                    index);
3156 
3157     EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
3158     if (js != (jstring) 0) {
3159         stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3160         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
3161         wcsncpy(info->text, stringBytes,
3162                 (sizeof(info->text) / sizeof(wchar_t)));
3163         length = jniEnv->GetStringLength(js);
3164         if (length >= (sizeof(info->text) / sizeof(wchar_t))) {
3165             length = (sizeof(info->text) / sizeof(wchar_t)) - 2;
3166         }
3167         info->text[length] = (wchar_t) 0;
3168         EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleHyperlink text", FALSE, js, stringBytes);


3169         // jniEnv->CallVoidMethod(accessBridgeObject,
3170         //                        decrementReferenceMethod, js);
3171         //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
3172         PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", info->text );
3173         jniEnv->DeleteLocalRef(js);
3174         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
3175 
3176     } else {
3177         PrintDebugString("[WARN]:   AccessibleHyperlink text is null.");
3178         info->text[0] = (wchar_t) 0;
3179     }
3180 
3181     info->startIndex = jniEnv->CallIntMethod(accessBridgeObject,
3182                                              getAccessibleHyperlinkStartIndexMethod,
3183                                              info->accessibleHyperlink,
3184                                              index);
3185     EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
3186     PrintDebugString("[INFO]:   ##### hyperlink start index = %d", info->startIndex);
3187 
3188     info->endIndex = jniEnv->CallIntMethod(accessBridgeObject,

3275 
3276     // get the icons
3277     for (int i = 0; i < icons->iconsCount && i < MAX_ICON_INFO; i++) {
3278 
3279         // get the icon description
3280         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3281                                                        getAccessibleIconDescriptionMethod,
3282                                                        accessibleContext,
3283                                                        i);
3284 
3285         EXCEPTION_CHECK("Getting icon description - call to CallObjectMethod()", FALSE);
3286         if (js != (jstring) 0) {
3287             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3288             EXCEPTION_CHECK("Getting AccessibleIcon description - call to GetStringChars()", FALSE);
3289             wcsncpy(icons->iconInfo[i].description, stringBytes, (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t)));
3290             length = jniEnv->GetStringLength(js);
3291             if (length >= (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t))) {
3292                 length = (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t)) - 2;
3293             }
3294             icons->iconInfo[i].description[length] = (wchar_t) 0;
3295             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleIcon description", FALSE, js, stringBytes);


3296             // jniEnv->CallVoidMethod(accessBridgeObject,
3297             //                        decrementReferenceMethod, js);
3298             //EXCEPTION_CHECK("Getting AccessibleIcon description - call to CallVoidMethod()", FALSE);
3299             PrintDebugString("[INFO]: ##### AccessibleIcon description = %ls", icons->iconInfo[i].description );
3300             jniEnv->DeleteLocalRef(js);
3301             EXCEPTION_CHECK("Getting AccessibleIcon description - call to DeleteLocalRef()", FALSE);
3302         } else {
3303             PrintDebugString("[WARN]:   AccessibleIcon description is null.");
3304             icons->iconInfo[i].description[0] = (wchar_t) 0;
3305         }
3306 
3307 
3308         // get the icon height
3309         icons->iconInfo[i].height = jniEnv->CallIntMethod(accessBridgeObject,
3310                                                           getAccessibleIconHeightMethod,
3311                                                           accessibleContext,
3312                                                           i);
3313         EXCEPTION_CHECK("##### Getting icon height - call to CallIntMethod()", FALSE);
3314         PrintDebugString("[INFO]:   ##### icon height = %d", icons->iconInfo[i].height);
3315 

3352 
3353     // get the actions
3354     for (int i = 0; i < actions->actionsCount && i < MAX_ACTION_INFO; i++) {
3355 
3356         // get the action name
3357         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3358                                                        getAccessibleActionNameMethod,
3359                                                        accessibleContext,
3360                                                        i);
3361 
3362         EXCEPTION_CHECK("Getting Action Name  - call to CallObjectMethod()", FALSE);
3363         if (js != (jstring) 0) {
3364             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3365             EXCEPTION_CHECK("Getting AccessibleAction Name  - call to GetStringChars()", FALSE);
3366             wcsncpy(actions->actionInfo[i].name , stringBytes, (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t)));
3367             length = jniEnv->GetStringLength(js);
3368             if (length >= (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t))) {
3369                 length = (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t)) - 2;
3370             }
3371             actions->actionInfo[i].name [length] = (wchar_t) 0;
3372             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleAction name", FALSE, js, stringBytes);


3373             // jniEnv->CallVoidMethod(accessBridgeObject,
3374             //                        decrementReferenceMethod, js);
3375             //EXCEPTION_CHECK("Getting AccessibleAction name  - call to CallVoidMethod()", FALSE);
3376             PrintDebugString("[INFO]: ##### AccessibleAction name  = %ls", actions->actionInfo[i].name  );
3377             jniEnv->DeleteLocalRef(js);
3378             EXCEPTION_CHECK("Getting AccessibleAction name  - call to DeleteLocalRef()", FALSE);
3379         } else {
3380             PrintDebugString("[WARN]:   AccessibleAction name  is null.");
3381             actions->actionInfo[i].name [0] = (wchar_t) 0;
3382         }
3383     }
3384     return FALSE;
3385 }
3386 
3387 BOOL AccessBridgeJavaEntryPoints::doAccessibleActions(jobject accessibleContext,
3388                                                       AccessibleActionsToDo *actionsToDo,
3389                                                       jint *failure) {
3390 
3391     jthrowable exception;
3392     BOOL returnVal;

3532     } else {
3533         PrintDebugString("[ERROR]: either env == 0 or getAccessibleLetterAtIndexFromContextMethod == 0");
3534         return FALSE;
3535     }
3536 
3537 
3538     // Get the word at index
3539     if (getAccessibleWordAtIndexFromContextMethod != (jmethodID) 0) {
3540         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3541                                                 getAccessibleWordAtIndexFromContextMethod,
3542                                                 accessibleContext, index);
3543         EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to CallIntMethod()", FALSE);
3544         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
3545         if (js != (jstring) 0) {
3546             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3547             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to GetStringChars()", FALSE);
3548             wcsncpy(textItems->word, stringBytes, (sizeof(textItems->word) / sizeof(wchar_t)));
3549             length = jniEnv->GetStringLength(js);
3550             textItems->word[length < (sizeof(textItems->word) / sizeof(wchar_t)) ?
3551                             length : (sizeof(textItems->word) / sizeof(wchar_t))-2] = (wchar_t) 0;
3552             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleWordAtIndex", FALSE, js, stringBytes);


3553             jniEnv->CallVoidMethod(accessBridgeObject,
3554                                    decrementReferenceMethod, js);
3555             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to CallVoidMethod()", FALSE);
3556             wPrintDebugString(L"[INFO]:   Accessible Text word = %ls", textItems->word);
3557             jniEnv->DeleteLocalRef(js);
3558             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to DeleteLocalRef()", FALSE);
3559         } else {
3560             PrintDebugString("[WARN]:   Accessible Text word is null.");
3561             textItems->word[0] = (wchar_t) 0;
3562         }
3563     } else {
3564         PrintDebugString("[ERROR]: either env == 0 or getAccessibleWordAtIndexFromContextMethod == 0");
3565         return FALSE;
3566     }
3567 
3568     // Get the sentence at index
3569     if (getAccessibleSentenceAtIndexFromContextMethod != (jmethodID) 0) {
3570         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3571                                                 getAccessibleSentenceAtIndexFromContextMethod,
3572                                                 accessibleContext, index);
3573         EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to CallObjectMethod()", FALSE);
3574         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
3575         if (js != (jstring) 0) {
3576             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3577             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to GetStringChars()", FALSE);
3578             wcsncpy(textItems->sentence, stringBytes, (sizeof(textItems->sentence) / sizeof(wchar_t))-2);
3579             length = jniEnv->GetStringLength(js);
3580 
3581             if (length < sizeof(textItems->sentence) / sizeof(wchar_t)) {
3582                 textItems->sentence[length] = (wchar_t) 0;
3583             } else {
3584                 textItems->sentence[(sizeof(textItems->sentence) / sizeof(wchar_t))-2] = (wchar_t) 0;
3585             }
3586             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleSentenceAtIndex", FALSE, js, stringBytes);


3587             jniEnv->CallVoidMethod(accessBridgeObject,
3588                                    decrementReferenceMethod, js);
3589             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to CallVoidMethod()", FALSE);
3590             wPrintDebugString(L"[INFO]:   Accessible Text sentence = %ls", textItems->sentence);
3591             jniEnv->DeleteLocalRef(js);
3592             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to DeleteLocalRef()", FALSE);
3593         } else {
3594             PrintDebugString("[WARN]:   Accessible Text sentence is null.");
3595             textItems->sentence[0] = (wchar_t) 0;
3596         }
3597     } else {
3598         PrintDebugString("[ERROR]: either env == 0 or getAccessibleSentenceAtIndexFromContextMethod == 0");
3599         return FALSE;
3600     }
3601 
3602     return TRUE;
3603 }
3604 
3605 BOOL
3606 AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(jobject accessibleContext,

3640         PrintDebugString("[INFO]:   Selection end = %d", selectionInfo->selectionEndIndex);
3641     } else {
3642         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextSelectionEndFromContextMethod == 0");
3643         return FALSE;
3644     }
3645 
3646     // Get the selected text
3647     if (getAccessibleTextSelectedTextFromContextMethod != (jmethodID) 0) {
3648         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3649                                                 getAccessibleTextSelectedTextFromContextMethod,
3650                                                 accessibleContext);
3651         EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to CallObjectMethod()", FALSE);
3652         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
3653         if (js != (jstring) 0) {
3654             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3655             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to GetStringChars()", FALSE);
3656             wcsncpy(selectionInfo->selectedText, stringBytes, (sizeof(selectionInfo->selectedText) / sizeof(wchar_t)));
3657             length = jniEnv->GetStringLength(js);
3658             selectionInfo->selectedText[length < (sizeof(selectionInfo->selectedText) / sizeof(wchar_t)) ?
3659                                         length : (sizeof(selectionInfo->selectedText) / sizeof(wchar_t))-2] = (wchar_t) 0;
3660             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleTextSelectedText", FALSE, js, stringBytes);


3661             jniEnv->CallVoidMethod(accessBridgeObject,
3662                                    decrementReferenceMethod, js);
3663             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to CallVoidMethod()", FALSE);
3664             PrintDebugString("[INFO]:   Accessible's selected text = %s", selectionInfo->selectedText);
3665             jniEnv->DeleteLocalRef(js);
3666             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to DeleteLocalRef()", FALSE);
3667         } else {
3668             PrintDebugString("[WARN]:   Accessible's selected text is null.");
3669             selectionInfo->selectedText[0] = (wchar_t) 0;
3670         }
3671     } else {
3672         PrintDebugString("[WARN]: either env == 0 or getAccessibleTextSelectedTextFromContextMethod == 0");
3673         return FALSE;
3674     }
3675     return TRUE;
3676 }
3677 
3678 BOOL
3679 AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleContext, jint index, AccessibleTextAttributesInfo *attributes) {
3680     jstring js;

3855         EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to CallVoidMethod()", FALSE);
3856         jniEnv->DeleteLocalRef(AttributeSet);
3857         EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to DeleteLocalRef()", FALSE);
3858         return FALSE;
3859     }
3860 
3861     // Get the backgroundColor setting
3862     if (getBackgroundColorFromAttributeSetMethod != (jmethodID) 0) {
3863         PrintDebugString("[INFO]:  Getting backgroundColor from AttributeSet...");
3864         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3865                                                 getBackgroundColorFromAttributeSetMethod,
3866                                                 AttributeSet);
3867         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallObjectMethod()", FALSE);
3868         if (js != (jstring) 0) {
3869             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3870             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to GetStringChars()", FALSE);
3871             wcsncpy(attributes->backgroundColor, stringBytes, (sizeof(attributes->backgroundColor) / sizeof(wchar_t)));
3872             length = jniEnv->GetStringLength(js);
3873             attributes->backgroundColor[length < (sizeof(attributes->backgroundColor) / sizeof(wchar_t)) ?
3874                                         length : (sizeof(attributes->backgroundColor) / sizeof(wchar_t))-2] = (wchar_t) 0;
3875             EXCEPTION_CHECK_WITH_RELEASE("Getting BackgroundColorFromAttributeSet", FALSE, js, stringBytes);


3876             jniEnv->CallVoidMethod(accessBridgeObject,
3877                                    decrementReferenceMethod, js);
3878             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3879             wPrintDebugString(L"[INFO]:   AttributeSet's background color = %ls", attributes->backgroundColor);
3880             jniEnv->DeleteLocalRef(js);
3881             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3882         } else {
3883             PrintDebugString("[WARN]:   AttributeSet's background color is null.");
3884             attributes->backgroundColor[0] = (wchar_t) 0;
3885         }
3886     } else {
3887         PrintDebugString("[ERROR]: either env == 0 or getBackgroundColorFromAttributeSetMethod == 0");
3888         jniEnv->CallVoidMethod(accessBridgeObject,
3889                                decrementReferenceMethod, AttributeSet);
3890         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3891         jniEnv->DeleteLocalRef(AttributeSet);
3892         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3893         return FALSE;
3894     }
3895 
3896     // Get the foregroundColor setting
3897     if (getForegroundColorFromAttributeSetMethod != (jmethodID) 0) {
3898         PrintDebugString("[INFO]:  Getting foregroundColor from AttributeSet...");
3899         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3900                                                 getForegroundColorFromAttributeSetMethod,
3901                                                 AttributeSet);
3902         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallObjectMethod()", FALSE);
3903         if (js != (jstring) 0) {
3904             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3905             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to GetStringChars()", FALSE);
3906             wcsncpy(attributes->foregroundColor, stringBytes, (sizeof(attributes->foregroundColor) / sizeof(wchar_t)));
3907             length = jniEnv->GetStringLength(js);
3908             attributes->foregroundColor[length < (sizeof(attributes->foregroundColor) / sizeof(wchar_t)) ?
3909                                         length : (sizeof(attributes->foregroundColor) / sizeof(wchar_t))-2] = (wchar_t) 0;
3910             EXCEPTION_CHECK_WITH_RELEASE("Getting ForegroundColorFromAttributeSet", FALSE, js, stringBytes);


3911             jniEnv->CallVoidMethod(accessBridgeObject,
3912                                    decrementReferenceMethod, js);
3913             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3914             wPrintDebugString(L"[INFO]:   AttributeSet's foreground color = %ls", attributes->foregroundColor);
3915             jniEnv->DeleteLocalRef(js);
3916             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3917         } else {
3918             PrintDebugString("[WARN]:   AttributeSet's foreground color is null.");
3919             attributes->foregroundColor[0] = (wchar_t) 0;
3920         }
3921     } else {
3922         PrintDebugString("[ERROR]: either env == 0 or getForegroundColorFromAttributeSetMethod == 0");
3923         jniEnv->CallVoidMethod(accessBridgeObject,
3924                                decrementReferenceMethod, AttributeSet);
3925         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3926         jniEnv->DeleteLocalRef(AttributeSet);
3927         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3928         return FALSE;
3929     }
3930 
3931     // Get the fontFamily setting
3932     if (getFontFamilyFromAttributeSetMethod != (jmethodID) 0) {
3933         PrintDebugString("[INFO]:  Getting fontFamily from AttributeSet...");
3934         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3935                                                 getFontFamilyFromAttributeSetMethod,
3936                                                 AttributeSet);
3937         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallObjectMethod()", FALSE);
3938         if (js != (jstring) 0) {
3939             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3940             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to GetStringChars()", FALSE);
3941             wcsncpy(attributes->fontFamily, stringBytes, (sizeof(attributes->fontFamily) / sizeof(wchar_t)));
3942             length = jniEnv->GetStringLength(js);
3943             attributes->fontFamily[length < (sizeof(attributes->fontFamily) / sizeof(wchar_t)) ?
3944                                    length : (sizeof(attributes->fontFamily) / sizeof(wchar_t))-2] = (wchar_t) 0;
3945             EXCEPTION_CHECK_WITH_RELEASE("Getting FontFamilyFromAttributeSet", FALSE, js, stringBytes);


3946             jniEnv->CallVoidMethod(accessBridgeObject,
3947                                    decrementReferenceMethod, js);
3948             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallVoidMethod()", FALSE);
3949             wPrintDebugString(L"[INFO]:   AttributeSet's fontFamily = %ls", attributes->fontFamily);
3950             jniEnv->DeleteLocalRef(js);
3951             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to DeleteLocalRef()", FALSE);
3952         } else {
3953             PrintDebugString("[WARN]:   AttributeSet's fontFamily is null.");
3954             attributes->backgroundColor[0] = (wchar_t) 0;
3955         }
3956     } else {
3957         PrintDebugString("[ERROR]: either env == 0 or getFontFamilyFromAttributeSetMethod == 0");
3958         jniEnv->CallVoidMethod(accessBridgeObject,
3959                                decrementReferenceMethod, AttributeSet);
3960         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallVoidMethod()", FALSE);
3961         jniEnv->DeleteLocalRef(AttributeSet);
3962         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to DeleteLocalRef()", FALSE);
3963         return FALSE;
3964     }
3965 

4129         jniEnv->DeleteLocalRef(AttributeSet);
4130         EXCEPTION_CHECK("Releasing AttributeSet object - call to DeleteLocalRef()", FALSE);
4131         return FALSE;
4132     }
4133 
4134     // Get the full attributes string at index
4135     if (getAccessibleAttributesAtIndexFromContextMethod != (jmethodID) 0) {
4136         PrintDebugString("[INFO]:  Getting full attributes string from Context...");
4137         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4138                                                 getAccessibleAttributesAtIndexFromContextMethod,
4139                                                 accessibleContext, index);
4140         EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallObjectMethod()", FALSE);
4141         PrintDebugString("[INFO]:  returned from CallObjectMethod(), js = %p", js);
4142         if (js != (jstring) 0) {
4143             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4144             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE);
4145             wcsncpy(attributes->fullAttributesString, stringBytes, (sizeof(attributes->fullAttributesString) / sizeof(wchar_t)));
4146             length = jniEnv->GetStringLength(js);
4147             attributes->fullAttributesString[length < (sizeof(attributes->fullAttributesString) / sizeof(wchar_t)) ?
4148                                              length : (sizeof(attributes->fullAttributesString) / sizeof(wchar_t))-2] = (wchar_t) 0;
4149             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleAttributesAtIndex", FALSE, js, stringBytes);


4150             jniEnv->CallVoidMethod(accessBridgeObject,
4151                                    decrementReferenceMethod, js);
4152             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE);
4153             wPrintDebugString(L"[INFO]:   Accessible Text attributes = %ls", attributes->fullAttributesString);
4154             jniEnv->DeleteLocalRef(js);
4155             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
4156         } else {
4157             PrintDebugString("[WARN]:   Accessible Text attributes is null.");
4158             attributes->fullAttributesString[0] = (wchar_t) 0;
4159             jniEnv->DeleteLocalRef(AttributeSet);
4160             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
4161             return FALSE;
4162         }
4163     } else {
4164         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0");
4165         jniEnv->DeleteLocalRef(AttributeSet);
4166         return FALSE;
4167     }
4168 
4169     jniEnv->DeleteLocalRef(AttributeSet);

4370         text[0] = (wchar_t) 0;
4371         return FALSE;
4372     }
4373 
4374     // Get the text range within [start, end] inclusive
4375     if (getAccessibleTextRangeFromContextMethod != (jmethodID) 0) {
4376         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4377                                                 getAccessibleTextRangeFromContextMethod,
4378                                                 accessibleContext, start, end);
4379         EXCEPTION_CHECK("Getting AccessibleTextRange - call to CallObjectMethod()", FALSE);
4380         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4381         if (js != (jstring) 0) {
4382             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4383             EXCEPTION_CHECK("Getting AccessibleTextRange - call to GetStringChars()", FALSE);
4384             wPrintDebugString(L"[INFO]:   Accessible Text stringBytes returned from Java = %ls", stringBytes);
4385             wcsncpy(text, stringBytes, len);
4386             length = jniEnv->GetStringLength(js);
4387             PrintDebugString("[INFO]:  Accessible Text stringBytes length = %d", length);
4388             text[length < len ? length : len - 2] = (wchar_t) 0;
4389             wPrintDebugString(L"[INFO]:   Accessible Text 'text' after null termination = %ls", text);
4390             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleTextRange", FALSE, js, stringBytes);


4391             jniEnv->CallVoidMethod(accessBridgeObject,
4392                                    decrementReferenceMethod, js);
4393             EXCEPTION_CHECK("Getting AccessibleTextRange - call to CallVoidMethod()", FALSE);
4394             wPrintDebugString(L"[INFO]:   Accessible Text range = %ls", text);
4395             jniEnv->DeleteLocalRef(js);
4396             EXCEPTION_CHECK("Getting AccessibleTextRange - call to DeleteLocalRef()", FALSE);
4397         } else {
4398             PrintDebugString("[WARN]:   current Accessible Text range is null.");
4399             text[0] = (wchar_t) 0;
4400             return FALSE;
4401         }
4402     } else {
4403         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextRangeFromContextMethod == 0");
4404         return FALSE;
4405     }
4406     return TRUE;
4407 }
4408 
4409 /********** AccessibleValue routines ***************/
4410 

4413     jstring js;
4414     const wchar_t *stringBytes;
4415     jthrowable exception;
4416     jsize length;
4417 
4418     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getCurrentAccessibleValueFromContext(%p):", accessibleContext);
4419 
4420     // Get the current Accessible Value
4421     if (getCurrentAccessibleValueFromContextMethod != (jmethodID) 0) {
4422         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4423                                                 getCurrentAccessibleValueFromContextMethod,
4424                                                 accessibleContext);
4425         EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to CallObjectMethod()", FALSE);
4426         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4427         if (js != (jstring) 0) {
4428             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4429             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to GetStringChars()", FALSE);
4430             wcsncpy(value, stringBytes, len);
4431             length = jniEnv->GetStringLength(js);
4432             value[length < len ? length : len - 2] = (wchar_t) 0;
4433             EXCEPTION_CHECK_WITH_RELEASE("Getting CurrentAccessibleValue", FALSE, js, stringBytes);


4434             jniEnv->CallVoidMethod(accessBridgeObject,
4435                                    decrementReferenceMethod, js);
4436             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to CallVoidMethod()", FALSE);
4437             PrintDebugString("[INFO]:   current Accessible Value = %s", value);
4438             jniEnv->DeleteLocalRef(js);
4439             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to DeleteLocalRef()", FALSE);
4440         } else {
4441             PrintDebugString("[WARN]:   current Accessible Value is null.");
4442             value[0] = (wchar_t) 0;
4443             return FALSE;
4444         }
4445     } else {
4446         PrintDebugString("[ERROR]:  either env == 0 or getCurrentAccessibleValueFromContextMethod == 0");
4447         return FALSE;
4448     }
4449     return TRUE;
4450 }
4451 
4452 BOOL
4453 AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(jobject accessibleContext, wchar_t *value, short len) {
4454     jstring js;
4455     const wchar_t *stringBytes;
4456     jthrowable exception;
4457     jsize length;
4458 
4459     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(%p):", accessibleContext);
4460 
4461     // Get the maximum Accessible Value
4462     if (getMaximumAccessibleValueFromContextMethod != (jmethodID) 0) {
4463         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4464                                                 getMaximumAccessibleValueFromContextMethod,
4465                                                 accessibleContext);
4466         EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to CallObjectMethod()", FALSE);
4467         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4468         if (js != (jstring) 0) {
4469             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4470             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to GetStringChars()", FALSE);
4471             wcsncpy(value, stringBytes, len);
4472             length = jniEnv->GetStringLength(js);
4473             value[length < len ? length : len - 2] = (wchar_t) 0;
4474             EXCEPTION_CHECK_WITH_RELEASE("Getting MaximumAccessibleValue", FALSE, js, stringBytes);


4475             jniEnv->CallVoidMethod(accessBridgeObject,
4476                                    decrementReferenceMethod, js);
4477             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to CallVoidMethod()", FALSE);
4478             PrintDebugString("[INFO]:   maximum Accessible Value = %s", value);
4479             jniEnv->DeleteLocalRef(js);
4480             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to DeleteLocalRef()", FALSE);
4481         } else {
4482             PrintDebugString("[WARN]:   maximum Accessible Value is null.");
4483             value[0] = (wchar_t) 0;
4484             return FALSE;
4485         }
4486     } else {
4487         PrintDebugString("[ERROR]: either env == 0 or getMaximumAccessibleValueFromContextMethod == 0");
4488         return FALSE;
4489     }
4490     return TRUE;
4491 }
4492 
4493 BOOL
4494 AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(jobject accessibleContext, wchar_t *value, short len) {
4495     jstring js;
4496     const wchar_t *stringBytes;
4497     jthrowable exception;
4498     jsize length;
4499 
4500     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(%p):", accessibleContext);
4501 
4502     // Get the mimimum Accessible Value
4503     if (getMinimumAccessibleValueFromContextMethod != (jmethodID) 0) {
4504         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4505                                                 getMinimumAccessibleValueFromContextMethod,
4506                                                 accessibleContext);
4507         EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to CallObjectMethod()", FALSE);
4508         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4509         if (js != (jstring) 0) {
4510             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4511             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to GetStringChars()", FALSE);
4512             wcsncpy(value, stringBytes, len);
4513             length = jniEnv->GetStringLength(js);
4514             value[length < len ? length : len - 2] = (wchar_t) 0;
4515             EXCEPTION_CHECK_WITH_RELEASE("Getting MinimumAccessibleValue", FALSE, js, stringBytes);


4516             jniEnv->CallVoidMethod(accessBridgeObject,
4517                                    decrementReferenceMethod, js);
4518             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to CallVoidMethod()", FALSE);
4519             PrintDebugString("[INFO]:   mimimum Accessible Value = %s", value);
4520             jniEnv->DeleteLocalRef(js);
4521             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to DeleteLocalRef()", FALSE);
4522         } else {
4523             PrintDebugString("[WARN]:   mimimum Accessible Value is null.");
4524             value[0] = (wchar_t) 0;
4525             return FALSE;
4526         }
4527     } else {
4528         PrintDebugString("[ERROR]: either env == 0 or getMinimumAccessibleValueFromContextMethod == 0");
4529         return FALSE;
4530     }
4531     return TRUE;
4532 }
4533 
4534 
4535 /********** AccessibleSelection routines ***************/
< prev index next >