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
  23  * questions.
  24  */
  25 
  26 /*
  27  * A class to manage JNI calls into AccessBridge.java
  28  */
  29 
  30 #include "AccessBridgeJavaEntryPoints.h"
  31 #include "AccessBridgeDebug.h"
  32 
  33 
  34 
  35 /**
  36  * Initialize the AccessBridgeJavaEntryPoints class
  37  *
  38  */
  39 AccessBridgeJavaEntryPoints::AccessBridgeJavaEntryPoints(JNIEnv *jniEnvironment,
  40                                                          jobject bridgeObject) {
  41     jniEnv = jniEnvironment;
  42     accessBridgeObject = (jobject)bridgeObject;
  43     PrintDebugString("AccessBridgeJavaEntryPoints(%X, %X) called", jniEnv, accessBridgeObject);
  44 }
  45 
  46 
  47 /**
  48  * Destructor
  49  *
  50  */
  51 AccessBridgeJavaEntryPoints::~AccessBridgeJavaEntryPoints() {
  52 }
  53 
  54 // -----------------------------------
  55 
  56 #define FIND_CLASS(classRef, className) \
  57     localClassRef = jniEnv->FindClass(className); \
  58     if (localClassRef == (jclass) 0) { \
  59         PrintDebugString("  Error! FindClass(%s) failed!", className); \
  60         PrintDebugString("    -> jniEnv = %p", jniEnv); \
  61         return FALSE; \
  62     } \
  63     classRef = (jclass) jniEnv->NewGlobalRef(localClassRef); \
  64     jniEnv->DeleteLocalRef(localClassRef); \
  65     if (classRef == (jclass) 0) { \
  66         PrintDebugString("  Error! FindClass(%s) failed!", className); \
  67         PrintDebugString("    ->  (ran out of RAM)"); \
  68         return FALSE; \
  69     }
  70 
  71 
  72 #define FIND_METHOD(methodID, classRef, methodString, methodSignature); \
  73     methodID = jniEnv->GetMethodID(classRef, methodString,  methodSignature); \
  74     if (methodID == (jmethodID) 0) { \
  75         PrintDebugString("  Error! GetMethodID(%s) failed!", methodString); \
  76         PrintDebugString("    -> jniEnv = %p; classRef = %p", jniEnv, classRef); \
  77         return FALSE; \
  78     }
  79 
  80 #define EXCEPTION_CHECK(situationDescription, returnVal)                                        \
  81     if (exception = jniEnv->ExceptionOccurred()) {                                              \
  82         PrintDebugString("\r\n *** Exception occured while doing: %s; returning %d", situationDescription, returnVal);   \
  83         jniEnv->ExceptionDescribe();                                                            \
  84         jniEnv->ExceptionClear();                                                               \
  85         return (returnVal);                                                                     \
  86     }
  87 
  88 #define EXCEPTION_CHECK_VOID(situationDescription)                                              \
  89     if (exception = jniEnv->ExceptionOccurred()) {                                              \
  90         PrintDebugString("\r\n *** Exception occured while doing: %s", situationDescription);   \
  91         jniEnv->ExceptionDescribe();                                                            \
  92         jniEnv->ExceptionClear();                                                               \
  93         return;                                                                                 \
  94     }
  95 
  96 /**
  97  * Make all of the getClass() & getMethod() calls
  98  *
  99  */
 100 BOOL
 101 AccessBridgeJavaEntryPoints::BuildJavaEntryPoints() {
 102     jclass localClassRef;
 103 
 104     PrintDebugString("Calling BuildJavaEntryPoints():");
 105 
 106     FIND_CLASS(bridgeClass, "com/sun/java/accessibility/AccessBridge");
 107 
 108     // ------- general methods
 109 
 110     // GetMethodID(decrementReference)
 111     FIND_METHOD(decrementReferenceMethod, bridgeClass,
 112                 "decrementReference",
 113                 "(Ljava/lang/Object;)V");
 114 
 115     // GetMethodID(getJavaVersionPropertyMethod)
 116     FIND_METHOD(getJavaVersionPropertyMethod, bridgeClass,
 117                 "getJavaVersionProperty",
 118                 "()Ljava/lang/String;");
 119 
 120     // ------- Window methods
 121 
 122     // GetMethodID(isJavaWindow)
 123     FIND_METHOD(isJavaWindowMethod, bridgeClass,
 124                 "isJavaWindow",
 125                 "(I)Z");
 126 
 127     // GetMethodID(getAccessibleContextFromHWND)
 128     FIND_METHOD(getAccessibleContextFromHWNDMethod, bridgeClass,
 129                 "getContextFromNativeWindowHandle",
 130                 "(I)Ljavax/accessibility/AccessibleContext;");
 131 
 132     // GetMethodID(getHWNDFromAccessibleContext)
 133     FIND_METHOD(getHWNDFromAccessibleContextMethod, bridgeClass,
 134                 "getNativeWindowHandleFromContext",
 135                 "(Ljavax/accessibility/AccessibleContext;)I");
 136 
 137     // GetMethodID(getAccessibleParentFromContext)
 138     FIND_METHOD(getAccessibleParentFromContextMethod, bridgeClass,
 139                 "getAccessibleParentFromContext",
 140                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleContext;");
 141 
 142     // ===== utility methods ===== */
 143 
 144     // GetMethodID(setTextContents)
 145     FIND_METHOD(setTextContentsMethod, bridgeClass,
 146                 "setTextContents",
 147                 "(Ljavax/accessibility/AccessibleContext;Ljava/lang/String;)Z");
 148 
 149     // GetMethodID(getParentWithRole)
 150     FIND_METHOD(getParentWithRoleMethod, bridgeClass,
 151                 "getParentWithRole",
 152                 "(Ljavax/accessibility/AccessibleContext;Ljava/lang/String;)Ljavax/accessibility/AccessibleContext;");
 153 
 154     // GetMethodID(getTopLevelObject)
 155     FIND_METHOD(getTopLevelObjectMethod, bridgeClass,
 156                 "getTopLevelObject",
 157                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleContext;");
 158 
 159     // GetMethodID(getParentWithRoleElseRoot)
 160     FIND_METHOD(getParentWithRoleElseRootMethod, bridgeClass,
 161                 "getParentWithRoleElseRoot",
 162                 "(Ljavax/accessibility/AccessibleContext;Ljava/lang/String;)Ljavax/accessibility/AccessibleContext;");
 163 
 164     // GetMethodID(getObjectDepth)
 165     FIND_METHOD(getObjectDepthMethod, bridgeClass,
 166                 "getObjectDepth",
 167                 "(Ljavax/accessibility/AccessibleContext;)I");
 168 
 169     // GetMethodID(getActiveDescendent)
 170     FIND_METHOD(getActiveDescendentMethod, bridgeClass,
 171                 "getActiveDescendent",
 172                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleContext;");
 173 
 174     // ------- AccessibleContext methods
 175 
 176     // GetMethodID(getAccessibleContextAt)
 177     FIND_METHOD(getAccessibleContextAtMethod, bridgeClass,
 178                 "getAccessibleContextAt",
 179                 "(IILjavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleContext;");
 180 
 181     // GetMethodID(getAccessibleContextWithFocus)
 182     FIND_METHOD(getAccessibleContextWithFocusMethod, bridgeClass,
 183                 "getAccessibleContextWithFocus",
 184                 "()Ljavax/accessibility/AccessibleContext;");
 185 
 186     // GetMethodID(getAccessibleNameFromContext)
 187     FIND_METHOD(getAccessibleNameFromContextMethod, bridgeClass,
 188                 "getAccessibleNameFromContext",
 189                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 190 
 191     // GetMethodID(getAccessibleDescriptionFromContext)
 192     FIND_METHOD(getAccessibleDescriptionFromContextMethod, bridgeClass,
 193                 "getAccessibleDescriptionFromContext",
 194                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 195 
 196     // GetMethodID(getAccessibleRoleStringFromContext)
 197     FIND_METHOD(getAccessibleRoleStringFromContextMethod, bridgeClass,
 198                 "getAccessibleRoleStringFromContext",
 199                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 200 
 201     // GetMethodID(getAccessibleRoleStringFromContext_en_US)
 202     FIND_METHOD(getAccessibleRoleStringFromContext_en_USMethod, bridgeClass,
 203                 "getAccessibleRoleStringFromContext_en_US",
 204                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 205 
 206     // GetMethodID(getAccessibleStatesStringFromContext)
 207     FIND_METHOD(getAccessibleStatesStringFromContextMethod, bridgeClass,
 208                 "getAccessibleStatesStringFromContext",
 209                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 210 
 211     // GetMethodID(getAccessibleStatesStringFromContext_en_US)
 212     FIND_METHOD(getAccessibleStatesStringFromContext_en_USMethod, bridgeClass,
 213                 "getAccessibleStatesStringFromContext_en_US",
 214                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 215 
 216     // GetMethodID(getAccessibleParentFromContext)
 217     FIND_METHOD(getAccessibleParentFromContextMethod, bridgeClass,
 218                 "getAccessibleParentFromContext",
 219                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleContext;");
 220 
 221     // GetMethodID(getAccessibleIndexInParentFromContext)
 222     FIND_METHOD(getAccessibleIndexInParentFromContextMethod, bridgeClass,
 223                 "getAccessibleIndexInParentFromContext",
 224                 "(Ljavax/accessibility/AccessibleContext;)I");
 225 
 226     // GetMethodID(getAccessibleChildrenCountFromContext)
 227     FIND_METHOD(getAccessibleChildrenCountFromContextMethod, bridgeClass,
 228                 "getAccessibleChildrenCountFromContext",
 229                 "(Ljavax/accessibility/AccessibleContext;)I");
 230 
 231     // GetMethodID(getAccessibleChildFromContext)
 232     FIND_METHOD(getAccessibleChildFromContextMethod, bridgeClass,
 233                 "getAccessibleChildFromContext",
 234                 "(Ljavax/accessibility/AccessibleContext;I)Ljavax/accessibility/AccessibleContext;");
 235 
 236     // GetMethodID(getAccessibleBoundsOnScreenFromContext)
 237     FIND_METHOD(getAccessibleBoundsOnScreenFromContextMethod, bridgeClass,
 238                 "getAccessibleBoundsOnScreenFromContext",
 239                 "(Ljavax/accessibility/AccessibleContext;)Ljava/awt/Rectangle;");
 240 
 241     // GetMethodID(getAccessibleXcoordFromContext)
 242     FIND_METHOD(getAccessibleXcoordFromContextMethod, bridgeClass,
 243                 "getAccessibleXcoordFromContext",
 244                 "(Ljavax/accessibility/AccessibleContext;)I");
 245 
 246     // GetMethodID(getAccessibleYcoordFromContext)
 247     FIND_METHOD(getAccessibleYcoordFromContextMethod, bridgeClass,
 248                 "getAccessibleYcoordFromContext",
 249                 "(Ljavax/accessibility/AccessibleContext;)I");
 250 
 251     // GetMethodID(getAccessibleHeightFromContext)
 252     FIND_METHOD(getAccessibleHeightFromContextMethod, bridgeClass,
 253                 "getAccessibleHeightFromContext",
 254                 "(Ljavax/accessibility/AccessibleContext;)I");
 255 
 256     // GetMethodID(getAccessibleWidthFromContext)
 257     FIND_METHOD(getAccessibleWidthFromContextMethod, bridgeClass,
 258                 "getAccessibleWidthFromContext",
 259                 "(Ljavax/accessibility/AccessibleContext;)I");
 260 
 261     // GetMethodID(getAccessibleComponentFromContext)
 262     FIND_METHOD(getAccessibleComponentFromContextMethod, bridgeClass,
 263                 "getAccessibleComponentFromContext",
 264                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleComponent;");
 265 
 266     // GetMethodID(getAccessibleActionFromContext)
 267     FIND_METHOD(getAccessibleActionFromContextMethod, bridgeClass,
 268                 "getAccessibleActionFromContext",
 269                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleAction;");
 270 
 271     // GetMethodID(getAccessibleSelectionFromContext)
 272     FIND_METHOD(getAccessibleSelectionFromContextMethod, bridgeClass,
 273                 "getAccessibleSelectionFromContext",
 274                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleSelection;");
 275 
 276     // GetMethodID(getAccessibleTextFromContext)
 277     FIND_METHOD(getAccessibleTextFromContextMethod, bridgeClass,
 278                 "getAccessibleTextFromContext",
 279                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleText;");
 280 
 281     // GetMethodID(getAccessibleValueFromContext)
 282     FIND_METHOD(getAccessibleValueFromContextMethod, bridgeClass,
 283                 "getAccessibleValueFromContext",
 284                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleValue;");
 285 
 286 
 287     // ------- begin AccessibleTable methods
 288 
 289     // GetMethodID(getAccessibleTableFromContext)
 290     FIND_METHOD(getAccessibleTableFromContextMethod, bridgeClass,
 291                 "getAccessibleTableFromContext",
 292                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleTable;");
 293 
 294     // GetMethodID(getContextFromAccessibleTable)
 295     FIND_METHOD(getContextFromAccessibleTableMethod, bridgeClass,
 296                 "getContextFromAccessibleTable",
 297                 "(Ljavax/accessibility/AccessibleTable;)Ljavax/accessibility/AccessibleContext;");
 298 
 299     // GetMethodID(getAccessibleTableRowHeader)
 300     FIND_METHOD(getAccessibleTableRowHeaderMethod, bridgeClass,
 301                 "getAccessibleTableRowHeader",
 302                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleTable;");
 303 
 304 
 305     // GetMethodID(getAccessibleTableColumnHeader)
 306     FIND_METHOD(getAccessibleTableColumnHeaderMethod, bridgeClass,
 307                 "getAccessibleTableColumnHeader",
 308                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleTable;");
 309 
 310 
 311     // GetMethodID(getAccessibleTableRowCount)
 312     FIND_METHOD(getAccessibleTableRowCountMethod, bridgeClass,
 313                 "getAccessibleTableRowCount",
 314                 "(Ljavax/accessibility/AccessibleContext;)I");
 315 
 316     // GetMethodID(getAccessibleTableColumnCount)
 317     FIND_METHOD(getAccessibleTableColumnCountMethod, bridgeClass,
 318                 "getAccessibleTableColumnCount",
 319                 "(Ljavax/accessibility/AccessibleContext;)I");
 320 
 321     // GetMethodID(getAccessibleTableCellAccessibleContext)
 322     FIND_METHOD(getAccessibleTableCellAccessibleContextMethod, bridgeClass,
 323                 "getAccessibleTableCellAccessibleContext",
 324                 "(Ljavax/accessibility/AccessibleTable;II)Ljavax/accessibility/AccessibleContext;");
 325 
 326     // GetMethodID(getAccessibleTableCellIndex)
 327     FIND_METHOD(getAccessibleTableCellIndexMethod, bridgeClass,
 328                 "getAccessibleTableCellIndex",
 329                 "(Ljavax/accessibility/AccessibleTable;II)I");
 330 
 331     // GetMethodID(getAccessibleTableCellRowExtent)
 332     FIND_METHOD(getAccessibleTableCellRowExtentMethod, bridgeClass,
 333                 "getAccessibleTableCellRowExtent",
 334                 "(Ljavax/accessibility/AccessibleTable;II)I");
 335 
 336     // GetMethodID(getAccessibleTableCellColumnExtent)
 337     FIND_METHOD(getAccessibleTableCellColumnExtentMethod, bridgeClass,
 338                 "getAccessibleTableCellColumnExtent",
 339                 "(Ljavax/accessibility/AccessibleTable;II)I");
 340 
 341     // GetMethodID(isAccessibleTableCellSelected)
 342     FIND_METHOD(isAccessibleTableCellSelectedMethod, bridgeClass,
 343                 "isAccessibleTableCellSelected",
 344                 "(Ljavax/accessibility/AccessibleTable;II)Z");
 345 
 346     // GetMethodID(getAccessibleTableRowHeaderRowCount)
 347     FIND_METHOD(getAccessibleTableRowHeaderRowCountMethod, bridgeClass,
 348                 "getAccessibleTableRowHeaderRowCount",
 349                 "(Ljavax/accessibility/AccessibleContext;)I");
 350 
 351     // GetMethodID(getAccessibleTableColumnHeaderRowCount)
 352     FIND_METHOD(getAccessibleTableColumnHeaderRowCountMethod, bridgeClass,
 353                 "getAccessibleTableColumnHeaderRowCount",
 354                 "(Ljavax/accessibility/AccessibleContext;)I");
 355 
 356     // GetMethodID(getAccessibleTableRowHeaderColumnCount)
 357     FIND_METHOD(getAccessibleTableRowHeaderColumnCountMethod, bridgeClass,
 358                 "getAccessibleTableRowHeaderColumnCount",
 359                 "(Ljavax/accessibility/AccessibleContext;)I");
 360 
 361     // GetMethodID(getAccessibleTableColumnHeaderColumnCount)
 362     FIND_METHOD(getAccessibleTableColumnHeaderColumnCountMethod, bridgeClass,
 363                 "getAccessibleTableColumnHeaderColumnCount",
 364                 "(Ljavax/accessibility/AccessibleContext;)I");
 365 
 366     // GetMethodID(getAccessibleTableRowDescription)
 367     FIND_METHOD(getAccessibleTableRowDescriptionMethod, bridgeClass,
 368                 "getAccessibleTableRowDescription",
 369                 "(Ljavax/accessibility/AccessibleTable;I)Ljavax/accessibility/AccessibleContext;");
 370 
 371     // GetMethodID(getAccessibleTableColumnDescription)
 372     FIND_METHOD(getAccessibleTableColumnDescriptionMethod, bridgeClass,
 373                 "getAccessibleTableColumnDescription",
 374                 "(Ljavax/accessibility/AccessibleTable;I)Ljavax/accessibility/AccessibleContext;");
 375 
 376     // GetMethodID(getAccessibleTableRowSelectionCount)
 377     FIND_METHOD(getAccessibleTableRowSelectionCountMethod, bridgeClass,
 378                 "getAccessibleTableRowSelectionCount",
 379                 "(Ljavax/accessibility/AccessibleTable;)I");
 380 
 381     // GetMethodID(isAccessibleTableRowSelected)
 382     FIND_METHOD(isAccessibleTableRowSelectedMethod, bridgeClass,
 383                 "isAccessibleTableRowSelected",
 384                 "(Ljavax/accessibility/AccessibleTable;I)Z");
 385 
 386     // GetMethodID(getAccessibleTableRowSelections)
 387     FIND_METHOD(getAccessibleTableRowSelectionsMethod, bridgeClass,
 388                 "getAccessibleTableRowSelections",
 389                 "(Ljavax/accessibility/AccessibleTable;I)I");
 390 
 391     // GetMethodID(getAccessibleTableColumnSelectionCount)
 392     FIND_METHOD(getAccessibleTableColumnSelectionCountMethod, bridgeClass,
 393                 "getAccessibleTableColumnSelectionCount",
 394                 "(Ljavax/accessibility/AccessibleTable;)I");
 395 
 396     // GetMethodID(isAccessibleTableColumnSelected)
 397     FIND_METHOD(isAccessibleTableColumnSelectedMethod, bridgeClass,
 398                 "isAccessibleTableColumnSelected",
 399                 "(Ljavax/accessibility/AccessibleTable;I)Z");
 400 
 401     // GetMethodID(getAccessibleTableColumnSelections)
 402     FIND_METHOD(getAccessibleTableColumnSelectionsMethod, bridgeClass,
 403                 "getAccessibleTableColumnSelections",
 404                 "(Ljavax/accessibility/AccessibleTable;I)I");
 405 
 406     // GetMethodID(getAccessibleTableRow)
 407     FIND_METHOD(getAccessibleTableRowMethod, bridgeClass,
 408                 "getAccessibleTableRow",
 409                 "(Ljavax/accessibility/AccessibleTable;I)I");
 410 
 411     // GetMethodID(getAccessibleTableColumn)
 412     FIND_METHOD(getAccessibleTableColumnMethod, bridgeClass,
 413                 "getAccessibleTableColumn",
 414                 "(Ljavax/accessibility/AccessibleTable;I)I");
 415 
 416     // GetMethodID(getAccessibleTableIndex)
 417     FIND_METHOD(getAccessibleTableIndexMethod, bridgeClass,
 418                 "getAccessibleTableIndex",
 419                 "(Ljavax/accessibility/AccessibleTable;II)I");
 420 
 421     /* ------- end AccessibleTable methods */
 422 
 423     /* start AccessibleRelationSet methods ----- */
 424 
 425     // GetMethodID(getAccessibleRelationCount)
 426     FIND_METHOD(getAccessibleRelationCountMethod, bridgeClass,
 427                 "getAccessibleRelationCount",
 428                 "(Ljavax/accessibility/AccessibleContext;)I");
 429 
 430     // GetMethodID(getAccessibleRelationKey)
 431     FIND_METHOD(getAccessibleRelationKeyMethod, bridgeClass,
 432                 "getAccessibleRelationKey",
 433                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 434 
 435     // GetMethodID(getAccessibleRelationTargetCount)
 436     FIND_METHOD(getAccessibleRelationTargetCountMethod, bridgeClass,
 437                 "getAccessibleRelationTargetCount",
 438                 "(Ljavax/accessibility/AccessibleContext;I)I");
 439 
 440     // GetMethodID(getAccessibleRelationTarget)
 441     FIND_METHOD(getAccessibleRelationTargetMethod, bridgeClass,
 442                 "getAccessibleRelationTarget",
 443                 "(Ljavax/accessibility/AccessibleContext;II)Ljavax/accessibility/AccessibleContext;");
 444 
 445 
 446     // ------- AccessibleHypertext methods
 447 
 448     // GetMethodID(getAccessibleHypertext)
 449     FIND_METHOD(getAccessibleHypertextMethod, bridgeClass,
 450                 "getAccessibleHypertext",
 451                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleHypertext;");
 452 
 453     // GetMethodID(activateAccessibleHyperlink)
 454     FIND_METHOD(activateAccessibleHyperlinkMethod, bridgeClass,
 455                 "activateAccessibleHyperlink",
 456                 "(Ljavax/accessibility/AccessibleContext;Ljavax/accessibility/AccessibleHyperlink;)Z");
 457 
 458     // GetMethodID(getAccessibleHyperlinkCount)
 459     FIND_METHOD(getAccessibleHyperlinkCountMethod, bridgeClass,
 460                 "getAccessibleHyperlinkCount",
 461                 "(Ljavax/accessibility/AccessibleContext;)I");
 462 
 463     // GetMethodID(getAccessibleHyperlink)
 464     FIND_METHOD(getAccessibleHyperlinkMethod, bridgeClass,
 465                 "getAccessibleHyperlink",
 466                 "(Ljavax/accessibility/AccessibleHypertext;I)Ljavax/accessibility/AccessibleHyperlink;");
 467 
 468     // GetMethodID(getAccessibleHyperlinkText)
 469     FIND_METHOD(getAccessibleHyperlinkTextMethod, bridgeClass,
 470                 "getAccessibleHyperlinkText",
 471                 "(Ljavax/accessibility/AccessibleHyperlink;)Ljava/lang/String;");
 472 
 473     // GetMethodID(getAccessibleHyperlinkURL)
 474     FIND_METHOD(getAccessibleHyperlinkURLMethod, bridgeClass,
 475                 "getAccessibleHyperlinkURL",
 476                 "(Ljavax/accessibility/AccessibleHyperlink;)Ljava/lang/String;");
 477 
 478     // GetMethodID(getAccessibleHyperlinkStartIndex)
 479     FIND_METHOD(getAccessibleHyperlinkStartIndexMethod, bridgeClass,
 480                 "getAccessibleHyperlinkStartIndex",
 481                 "(Ljavax/accessibility/AccessibleHyperlink;)I");
 482 
 483     // GetMethodID(getAccessibleHyperlinkEndIndex)
 484     FIND_METHOD(getAccessibleHyperlinkEndIndexMethod, bridgeClass,
 485                 "getAccessibleHyperlinkEndIndex",
 486                 "(Ljavax/accessibility/AccessibleHyperlink;)I");
 487 
 488     // GetMethodID(getAccessibleHypertextLinkIndex)
 489     FIND_METHOD(getAccessibleHypertextLinkIndexMethod, bridgeClass,
 490                 "getAccessibleHypertextLinkIndex",
 491                 "(Ljavax/accessibility/AccessibleHypertext;I)I");
 492 
 493     // Accessible KeyBinding, Icon and Action ====================
 494 
 495     // GetMethodID(getAccessibleKeyBindingsCount)
 496     FIND_METHOD(getAccessibleKeyBindingsCountMethod, bridgeClass,
 497                 "getAccessibleKeyBindingsCount",
 498                 "(Ljavax/accessibility/AccessibleContext;)I");
 499 
 500     // GetMethodID(getAccessibleKeyBindingChar)
 501     FIND_METHOD(getAccessibleKeyBindingCharMethod, bridgeClass,
 502                 "getAccessibleKeyBindingChar",
 503                 "(Ljavax/accessibility/AccessibleContext;I)C");
 504 
 505     // GetMethodID(getAccessibleKeyBindingModifiers)
 506     FIND_METHOD(getAccessibleKeyBindingModifiersMethod, bridgeClass,
 507                 "getAccessibleKeyBindingModifiers",
 508                 "(Ljavax/accessibility/AccessibleContext;I)I");
 509 
 510     // GetMethodID(getAccessibleIconsCount)
 511     FIND_METHOD(getAccessibleIconsCountMethod, bridgeClass,
 512                 "getAccessibleIconsCount",
 513                 "(Ljavax/accessibility/AccessibleContext;)I");
 514 
 515     // GetMethodID(getAccessibleIconDescription)
 516     FIND_METHOD(getAccessibleIconDescriptionMethod, bridgeClass,
 517                 "getAccessibleIconDescription",
 518                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 519 
 520     // GetMethodID(getAccessibleIconHeight)
 521     FIND_METHOD(getAccessibleIconHeightMethod, bridgeClass,
 522                 "getAccessibleIconHeight",
 523                 "(Ljavax/accessibility/AccessibleContext;I)I");
 524 
 525     // GetMethodID(getAccessibleIconWidth)
 526     FIND_METHOD(getAccessibleIconWidthMethod, bridgeClass,
 527                 "getAccessibleIconWidth",
 528                 "(Ljavax/accessibility/AccessibleContext;I)I");
 529 
 530     // GetMethodID(getAccessibleActionsCount)
 531     FIND_METHOD(getAccessibleActionsCountMethod, bridgeClass,
 532                 "getAccessibleActionsCount",
 533                 "(Ljavax/accessibility/AccessibleContext;)I");
 534 
 535     // GetMethodID(getAccessibleActionName)
 536     FIND_METHOD(getAccessibleActionNameMethod, bridgeClass,
 537                 "getAccessibleActionName",
 538                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 539 
 540     // GetMethodID(doAccessibleActions)
 541     FIND_METHOD(doAccessibleActionsMethod, bridgeClass,
 542                 "doAccessibleActions",
 543                 "(Ljavax/accessibility/AccessibleContext;Ljava/lang/String;)Z");
 544 
 545     // ------- AccessibleText methods
 546 
 547     // GetMethodID(getAccessibleCharCountFromContext)
 548     FIND_METHOD(getAccessibleCharCountFromContextMethod, bridgeClass,
 549                 "getAccessibleCharCountFromContext",
 550                 "(Ljavax/accessibility/AccessibleContext;)I");
 551 
 552     // GetMethodID(getAccessibleCaretPositionFromContext)
 553     FIND_METHOD(getAccessibleCaretPositionFromContextMethod, bridgeClass,
 554                 "getAccessibleCaretPositionFromContext",
 555                 "(Ljavax/accessibility/AccessibleContext;)I");
 556 
 557     // GetMethodID(getAccessibleIndexAtPointFromContext)
 558     FIND_METHOD(getAccessibleIndexAtPointFromContextMethod, bridgeClass,
 559                 "getAccessibleIndexAtPointFromContext",
 560                 "(Ljavax/accessibility/AccessibleContext;II)I");
 561 
 562     // GetMethodID(getAccessibleLetterAtIndexFromContext)
 563     FIND_METHOD(getAccessibleLetterAtIndexFromContextMethod, bridgeClass,
 564                 "getAccessibleLetterAtIndexFromContext",
 565                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 566 
 567     // GetMethodID(getAccessibleWordAtIndexFromContext)
 568     FIND_METHOD(getAccessibleWordAtIndexFromContextMethod, bridgeClass,
 569                 "getAccessibleWordAtIndexFromContext",
 570                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 571 
 572     // GetMethodID(getAccessibleSentenceAtIndexFromContext)
 573     FIND_METHOD(getAccessibleSentenceAtIndexFromContextMethod, bridgeClass,
 574                 "getAccessibleSentenceAtIndexFromContext",
 575                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 576 
 577     // GetMethodID(getAccessibleTextSelectionStartFromContext)
 578     FIND_METHOD(getAccessibleTextSelectionStartFromContextMethod, bridgeClass,
 579                 "getAccessibleTextSelectionStartFromContext",
 580                 "(Ljavax/accessibility/AccessibleContext;)I");
 581 
 582     // GetMethodID(getAccessibleTextSelectionEndFromContext)
 583     FIND_METHOD(getAccessibleTextSelectionEndFromContextMethod, bridgeClass,
 584                 "getAccessibleTextSelectionEndFromContext",
 585                 "(Ljavax/accessibility/AccessibleContext;)I");
 586 
 587     // GetMethodID(getAccessibleTextSelectedTextFromContext)
 588     FIND_METHOD(getAccessibleTextSelectedTextFromContextMethod, bridgeClass,
 589                 "getAccessibleTextSelectedTextFromContext",
 590                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 591 
 592     // GetMethodID(getAccessibleAttributesAtIndexFromContext)
 593     FIND_METHOD(getAccessibleAttributesAtIndexFromContextMethod, bridgeClass,
 594                 "getAccessibleAttributesAtIndexFromContext",
 595                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 596 
 597     // GetMethodID(getAccessibleAttributeSetAtIndexFromContext)
 598     FIND_METHOD(getAccessibleAttributeSetAtIndexFromContextMethod, bridgeClass,
 599                 "getAccessibleAttributeSetAtIndexFromContext",
 600                 "(Ljavax/accessibility/AccessibleContext;I)Ljavax/swing/text/AttributeSet;");
 601 
 602     // GetMethodID(getAccessibleTextRectAtIndexFromContext)
 603     FIND_METHOD(getAccessibleTextRectAtIndexFromContextMethod, bridgeClass,
 604                 "getAccessibleTextRectAtIndexFromContext",
 605                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/awt/Rectangle;");
 606 
 607     // GetMethodID(getAccessibleXcoordTextRectAtIndexFromContext)
 608     FIND_METHOD(getAccessibleXcoordTextRectAtIndexFromContextMethod, bridgeClass,
 609                 "getAccessibleXcoordTextRectAtIndexFromContext",
 610                 "(Ljavax/accessibility/AccessibleContext;I)I");
 611 
 612     // GetMethodID(getAccessibleYcoordTextRectAtIndexFromContext)
 613     FIND_METHOD(getAccessibleYcoordTextRectAtIndexFromContextMethod, bridgeClass,
 614                 "getAccessibleYcoordTextRectAtIndexFromContext",
 615                 "(Ljavax/accessibility/AccessibleContext;I)I");
 616 
 617     // GetMethodID(getAccessibleHeightTextRectAtIndexFromContext)
 618     FIND_METHOD(getAccessibleHeightTextRectAtIndexFromContextMethod, bridgeClass,
 619                 "getAccessibleHeightTextRectAtIndexFromContext",
 620                 "(Ljavax/accessibility/AccessibleContext;I)I");
 621 
 622     // GetMethodID(getAccessibleWidthTextRectAtIndexFromContext)
 623     FIND_METHOD(getAccessibleWidthTextRectAtIndexFromContextMethod, bridgeClass,
 624                 "getAccessibleWidthTextRectAtIndexFromContext",
 625                 "(Ljavax/accessibility/AccessibleContext;I)I");
 626 
 627     // GetMethodID(getCaretLocationX)
 628     FIND_METHOD(getCaretLocationXMethod, bridgeClass,
 629                 "getCaretLocationX",
 630                 "(Ljavax/accessibility/AccessibleContext;)I");
 631 
 632     // GetMethodID(getCaretLocationY)
 633     FIND_METHOD(getCaretLocationYMethod, bridgeClass,
 634                 "getCaretLocationY",
 635                 "(Ljavax/accessibility/AccessibleContext;)I");
 636 
 637     // GetMethodID(getCaretLocationHeight)
 638     FIND_METHOD(getCaretLocationHeightMethod, bridgeClass,
 639                 "getCaretLocationHeight",
 640                 "(Ljavax/accessibility/AccessibleContext;)I");
 641 
 642     // GetMethodID(getCaretLocationWidth)
 643     FIND_METHOD(getCaretLocationWidthMethod, bridgeClass,
 644                 "getCaretLocationWidth",
 645                 "(Ljavax/accessibility/AccessibleContext;)I");
 646 
 647 
 648     // GetMethodID(getAccessibleTextLineLeftBoundsFromContextMethod)
 649     FIND_METHOD(getAccessibleTextLineLeftBoundsFromContextMethod, bridgeClass,
 650                 "getAccessibleTextLineLeftBoundsFromContext",
 651                 "(Ljavax/accessibility/AccessibleContext;I)I");
 652 
 653     // GetMethodID(getAccessibleTextLineRightBoundsFromContextMethod)
 654     FIND_METHOD(getAccessibleTextLineRightBoundsFromContextMethod, bridgeClass,
 655                 "getAccessibleTextLineRightBoundsFromContext",
 656                 "(Ljavax/accessibility/AccessibleContext;I)I");
 657 
 658     // GetMethodID(getAccessibleTextRangeFromContextMethod)
 659     FIND_METHOD(getAccessibleTextRangeFromContextMethod, bridgeClass,
 660                 "getAccessibleTextRangeFromContext",
 661                 "(Ljavax/accessibility/AccessibleContext;II)Ljava/lang/String;");
 662 
 663 
 664     // ------- AccessibleValue methods
 665 
 666     // GetMethodID(getCurrentAccessibleValueFromContext)
 667     FIND_METHOD(getCurrentAccessibleValueFromContextMethod, bridgeClass,
 668                 "getCurrentAccessibleValueFromContext",
 669                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 670 
 671     // GetMethodID(getMaximumAccessibleValueFromContext)
 672     FIND_METHOD(getMaximumAccessibleValueFromContextMethod, bridgeClass,
 673                 "getMaximumAccessibleValueFromContext",
 674                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 675 
 676     // GetMethodID(getMinimumAccessibleValueFromContext)
 677     FIND_METHOD(getMinimumAccessibleValueFromContextMethod, bridgeClass,
 678                 "getMinimumAccessibleValueFromContext",
 679                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 680 
 681 
 682     // ------- AccessibleSelection methods
 683 
 684     // GetMethodID(addAccessibleSelectionFromContext)
 685     FIND_METHOD(addAccessibleSelectionFromContextMethod, bridgeClass,
 686                 "addAccessibleSelectionFromContext",
 687                 "(Ljavax/accessibility/AccessibleContext;I)V");
 688 
 689     // GetMethodID(clearAccessibleSelectionFromContext)
 690     FIND_METHOD(clearAccessibleSelectionFromContextMethod, bridgeClass,
 691                 "clearAccessibleSelectionFromContext",
 692                 "(Ljavax/accessibility/AccessibleContext;)V");
 693 
 694     // GetMethodID(getAccessibleSelectionFromContext)
 695     FIND_METHOD(getAccessibleSelectionContextFromContextMethod, bridgeClass,
 696                 "getAccessibleSelectionFromContext",
 697                 "(Ljavax/accessibility/AccessibleContext;I)Ljavax/accessibility/AccessibleContext;");
 698 
 699     // GetMethodID(getAccessibleSelectionCountFromContext)
 700     FIND_METHOD(getAccessibleSelectionCountFromContextMethod, bridgeClass,
 701                 "getAccessibleSelectionCountFromContext",
 702                 "(Ljavax/accessibility/AccessibleContext;)I");
 703 
 704     // GetMethodID(isAccessibleChildSelectedFromContext)
 705     FIND_METHOD(isAccessibleChildSelectedFromContextMethod, bridgeClass,
 706                 "isAccessibleChildSelectedFromContext",
 707                 "(Ljavax/accessibility/AccessibleContext;I)Z");
 708 
 709     // GetMethodID(removeAccessibleSelectionFromContext)
 710     FIND_METHOD(removeAccessibleSelectionFromContextMethod, bridgeClass,
 711                 "removeAccessibleSelectionFromContext",
 712                 "(Ljavax/accessibility/AccessibleContext;I)V");
 713 
 714     // GetMethodID(selectAllAccessibleSelectionFromContext)
 715     FIND_METHOD(selectAllAccessibleSelectionFromContextMethod, bridgeClass,
 716                 "selectAllAccessibleSelectionFromContext",
 717                 "(Ljavax/accessibility/AccessibleContext;)V");
 718 
 719 
 720     // ------- Event Notification methods
 721 
 722     // GetMethodID(addJavaEventNotification)
 723     FIND_METHOD(addJavaEventNotificationMethod, bridgeClass,
 724                 "addJavaEventNotification", "(J)V");
 725 
 726     // GetMethodID(removeJavaEventNotification)
 727     FIND_METHOD(removeJavaEventNotificationMethod, bridgeClass,
 728                 "removeJavaEventNotification", "(J)V");
 729 
 730     // GetMethodID(addAccessibilityEventNotification)
 731     FIND_METHOD(addAccessibilityEventNotificationMethod, bridgeClass,
 732                 "addAccessibilityEventNotification", "(J)V");
 733 
 734     // GetMethodID(removeAccessibilityEventNotification)
 735     FIND_METHOD(removeAccessibilityEventNotificationMethod, bridgeClass,
 736                 "removeAccessibilityEventNotification", "(J)V");
 737 
 738 
 739     // ------- AttributeSet methods
 740 
 741     // GetMethodID(getBoldFromAttributeSet)
 742     FIND_METHOD(getBoldFromAttributeSetMethod, bridgeClass,
 743                 "getBoldFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 744 
 745     // GetMethodID(getItalicFromAttributeSet)
 746     FIND_METHOD(getItalicFromAttributeSetMethod, bridgeClass,
 747                 "getItalicFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 748 
 749     // GetMethodID(getUnderlineFromAttributeSet)
 750     FIND_METHOD(getUnderlineFromAttributeSetMethod, bridgeClass,
 751                 "getUnderlineFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 752 
 753     // GetMethodID(getStrikethroughFromAttributeSet)
 754     FIND_METHOD(getStrikethroughFromAttributeSetMethod, bridgeClass,
 755                 "getStrikethroughFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 756 
 757     // GetMethodID(getSuperscriptFromAttributeSet)
 758     FIND_METHOD(getSuperscriptFromAttributeSetMethod, bridgeClass,
 759                 "getSuperscriptFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 760 
 761     // GetMethodID(getSubscriptFromAttributeSet)
 762     FIND_METHOD(getSubscriptFromAttributeSetMethod, bridgeClass,
 763                 "getSubscriptFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 764 
 765     // GetMethodID(getBackgroundColorFromAttributeSet)
 766     FIND_METHOD(getBackgroundColorFromAttributeSetMethod, bridgeClass,
 767                 "getBackgroundColorFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Ljava/lang/String;");
 768 
 769     // GetMethodID(getForegroundColorFromAttributeSet)
 770     FIND_METHOD(getForegroundColorFromAttributeSetMethod, bridgeClass,
 771                 "getForegroundColorFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Ljava/lang/String;");
 772 
 773     // GetMethodID(getFontFamilyFromAttributeSet)
 774     FIND_METHOD(getFontFamilyFromAttributeSetMethod, bridgeClass,
 775                 "getFontFamilyFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Ljava/lang/String;");
 776 
 777     // GetMethodID(getFontSizeFromAttributeSet)
 778     FIND_METHOD(getFontSizeFromAttributeSetMethod, bridgeClass,
 779                 "getFontSizeFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)I");
 780 
 781     // GetMethodID(getAlignmentFromAttributeSet)
 782     FIND_METHOD(getAlignmentFromAttributeSetMethod, bridgeClass,
 783                 "getAlignmentFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)I");
 784 
 785     // GetMethodID(getBidiLevelFromAttributeSet)
 786     FIND_METHOD(getBidiLevelFromAttributeSetMethod, bridgeClass,
 787                 "getBidiLevelFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)I");
 788 
 789     // GetMethodID(getFirstLineIndentFromAttributeSet)
 790     FIND_METHOD(getFirstLineIndentFromAttributeSetMethod, bridgeClass,
 791                 "getFirstLineIndentFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 792 
 793     // GetMethodID(getLeftIndentFromAttributeSet)
 794     FIND_METHOD(getLeftIndentFromAttributeSetMethod, bridgeClass,
 795                 "getLeftIndentFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 796 
 797     // GetMethodID(getRightIndentFromAttributeSet)
 798     FIND_METHOD(getRightIndentFromAttributeSetMethod, bridgeClass,
 799                 "getRightIndentFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 800 
 801     // GetMethodID(getLineSpacingFromAttributeSet)
 802     FIND_METHOD(getLineSpacingFromAttributeSetMethod, bridgeClass,
 803                 "getLineSpacingFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 804 
 805     // GetMethodID(getSpaceAboveFromAttributeSet)
 806     FIND_METHOD(getSpaceAboveFromAttributeSetMethod, bridgeClass,
 807                 "getSpaceAboveFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 808 
 809     // GetMethodID(getSpaceBelowFromAttributeSet)
 810     FIND_METHOD(getSpaceBelowFromAttributeSetMethod, bridgeClass,
 811                 "getSpaceBelowFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 812 
 813 
 814     /**
 815      * Additional methods for Teton
 816      */
 817 
 818     // GetMethodID(requestFocus)
 819     FIND_METHOD(requestFocusMethod, bridgeClass,
 820                 "requestFocus",
 821                 "(Ljavax/accessibility/AccessibleContext;)Z");
 822 
 823     // GetMethodID(selectTextRange)
 824     FIND_METHOD(selectTextRangeMethod, bridgeClass,
 825                 "selectTextRange",
 826                 "(Ljavax/accessibility/AccessibleContext;II)Z");
 827 
 828     // GetMethodID(getVisibleChildrenCount)
 829     FIND_METHOD(getVisibleChildrenCountMethod, bridgeClass,
 830                 "getVisibleChildrenCount",
 831                 "(Ljavax/accessibility/AccessibleContext;)I");
 832 
 833     // GetMethodID(getVisibleChild)
 834     FIND_METHOD(getVisibleChildMethod, bridgeClass,
 835                 "getVisibleChild",
 836                 "(Ljavax/accessibility/AccessibleContext;I)Ljavax/accessibility/AccessibleContext;");
 837 
 838     // GetMethodID(setCaretPosition)
 839     FIND_METHOD(setCaretPositionMethod, bridgeClass,
 840                 "setCaretPosition",
 841                 "(Ljavax/accessibility/AccessibleContext;I)Z");
 842 
 843     // GetMethodID(getVirtualAccessibleNameFromContextMethod) Ben Key
 844     FIND_METHOD(getVirtualAccessibleNameFromContextMethod, bridgeClass,
 845                 "getVirtualAccessibleNameFromContext",
 846                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 847 
 848     return TRUE;
 849 }
 850 
 851 // Note for the following code which makes JNI upcalls...
 852 //
 853 // Problem, bug DB 16818166, JBS DB JDK-8015400
 854 // AccessibleContext is a JOBJECT64 which is a jobject (32 bit pointer)
 855 // for a Legacy (XP) build and a jlong (64 bits) for a -32 or -64 build.
 856 // For the -32 build the lower 32 bits needs to be extracted into a jobject.
 857 // Otherwise, if AccessibleContext is used directly what happens is that
 858 // the JNI code consumes the lower 32 of its 64 bits and that is not a
 859 // problem, but then when the JNI code consumes the next 32 bits for the
 860 // reference to the role String it gets the higher 0x00000000 bits from
 861 // the 64 bit JOBJECT64 AccessibleContext variable and thus a null reference
 862 // is passed as the String reference.
 863 //
 864 // Solution:
 865 // Cast the JOBJECT64 to a jobject.  For a 64 bit compile this is basically
 866 // a noop, i.e. JOBJECT64 is a 64 bit jlong and a jobject is a 64 bit reference.
 867 // For a 32 bit compile the cast drops the high order 32 bits, i.e. JOBJECT64
 868 // is a 64 bit jlong and jobject is a 32 bit reference.  For a Legacy build
 869 // JOBJECT64 is a jobject so this is also basically a noop.  The casts are
 870 // done in the methods in JavaAccessBridge::processPackage.
 871 
 872 // -----------------------------------
 873 
 874 /**
 875  * isJavaWindow - returns whether the HWND is a Java window or not
 876  *
 877  */
 878 BOOL
 879 AccessBridgeJavaEntryPoints::isJavaWindow(jint window) {
 880     jthrowable exception;
 881     BOOL returnVal;
 882 
 883     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::isJavaWindow(%X):", window);
 884 
 885     if (isJavaWindowMethod != (jmethodID) 0) {
 886         returnVal = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject, isJavaWindowMethod, window);
 887         EXCEPTION_CHECK("Getting isJavaWindow - call to CallBooleanMethod()", FALSE);
 888         return returnVal;
 889     } else {
 890         PrintDebugString("\r\n  Error! either jniEnv == 0 or isJavaWindowMethod == 0");
 891         return FALSE;
 892     }
 893 }
 894 
 895 // -----------------------------------
 896 
 897 /**
 898  * isSameObject - returns whether two object reference refer to the same object
 899  *
 900  */
 901 BOOL
 902 AccessBridgeJavaEntryPoints::isSameObject(jobject obj1, jobject obj2) {
 903     jthrowable exception;
 904     BOOL returnVal;
 905 
 906     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::isSameObject(%p %p):", obj1, obj2);
 907 
 908     returnVal = (BOOL) jniEnv->IsSameObject((jobject)obj1, (jobject)obj2);
 909     EXCEPTION_CHECK("Calling IsSameObject", FALSE);
 910 
 911     PrintDebugString("\r\n  isSameObject returning %d", returnVal);
 912     return returnVal;
 913 }
 914 
 915 // -----------------------------------
 916 
 917 /**
 918  * getAccessibleContextFromHWND - returns the AccessibleContext, if any, for an HWND
 919  *
 920  */
 921 jobject
 922 AccessBridgeJavaEntryPoints::getAccessibleContextFromHWND(jint window) {
 923     jobject returnedAccessibleContext;
 924     jobject globalRef;
 925     jthrowable exception;
 926 
 927     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getAccessibleContextFromHWND(%X):", window);
 928 
 929     if (getAccessibleContextFromHWNDMethod != (jmethodID) 0) {
 930         returnedAccessibleContext =
 931             (jobject)jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleContextFromHWNDMethod,
 932                                               window);
 933         EXCEPTION_CHECK("Getting AccessibleContextFromHWND - call to CallObjectMethod()", (jobject) 0);
 934         globalRef = (jobject)jniEnv->NewGlobalRef((jobject)returnedAccessibleContext);
 935         EXCEPTION_CHECK("Getting AccessibleContextFromHWND - call to CallObjectMethod()", (jobject) 0);
 936         return globalRef;
 937     } else {
 938         PrintDebugString("\r\n  Error! either jniEnv == 0 or getAccessibleContextFromHWNDMethod == 0");
 939         return (jobject) 0;
 940     }
 941 }
 942 
 943 // -----------------------------------
 944 
 945 /**
 946  * getHWNDFromAccessibleContext - returns the HWND for an AccessibleContext, if any
 947  *      returns (HWND)0 on error.
 948  */
 949 HWND
 950 AccessBridgeJavaEntryPoints::getHWNDFromAccessibleContext(jobject accessibleContext) {
 951     jthrowable exception;
 952     HWND rHWND;
 953 
 954     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getHWNDFromAccessibleContext(%X):",
 955                      accessibleContext);
 956 
 957     if (getHWNDFromAccessibleContextMethod != (jmethodID) 0) {
 958         rHWND = (HWND)jniEnv->CallIntMethod(accessBridgeObject, getHWNDFromAccessibleContextMethod,
 959                                             accessibleContext);
 960         EXCEPTION_CHECK("Getting HWNDFromAccessibleContext - call to CallIntMethod()", (HWND)0);
 961         PrintDebugString("\r\n    rHWND = %X", rHWND);
 962         return rHWND;
 963     } else {
 964         PrintDebugString("\r\n  Error! either jniEnv == 0 or getHWNDFromAccessibleContextMethod == 0");
 965         return (HWND)0;
 966     }
 967 }
 968 
 969 
 970 /* ====== Utility methods ===== */
 971 
 972 /**
 973  * Sets a text field to the specified string.  Returns whether successful;
 974  */
 975 BOOL
 976 AccessBridgeJavaEntryPoints::setTextContents(const jobject accessibleContext, const wchar_t *text) {
 977     jthrowable exception;
 978     BOOL result = FALSE;
 979 
 980     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::setTextContents(%p, %ls):",
 981                      accessibleContext, text);
 982 
 983     if (setTextContentsMethod != (jmethodID) 0) {
 984 
 985         // create a Java String for the text
 986         jstring textString = jniEnv->NewString(text, (jsize)wcslen(text));
 987         if (textString == 0) {
 988             PrintDebugString("\r    NewString failed");
 989             return FALSE;
 990         }
 991 
 992         result = (BOOL)jniEnv->CallBooleanMethod(accessBridgeObject,
 993                                                  setTextContentsMethod,
 994                                                  accessibleContext, textString);
 995         EXCEPTION_CHECK("setTextContents - call to CallBooleanMethod()", FALSE);
 996         PrintDebugString("\r\n    result = %d", result);
 997         return result;
 998     } else {
 999         PrintDebugString("\r\n  Error! either jniEnv == 0 or setTextContentsMethod == 0");
1000         return result;
1001     }
1002 }
1003 
1004 /**
1005  * Returns the Accessible Context of a Page Tab object that is the
1006  * ancestor of a given object.  If the object is a Page Tab object
1007  * or a Page Tab ancestor object was found, returns the object
1008  * AccessibleContext.
1009  * If there is no ancestor object that has an Accessible Role of Page Tab,
1010  * returns (AccessibleContext)0.
1011  */
1012 jobject
1013 AccessBridgeJavaEntryPoints::getParentWithRole(const jobject accessibleContext, const wchar_t *role) {
1014     jthrowable exception;
1015     jobject rAccessibleContext;
1016 
1017     PrintDebugString("In AccessBridgeJavaEntryPoints::getParentWithRole(%p):",
1018                      accessibleContext);
1019 
1020     if (getParentWithRoleMethod != (jmethodID) 0) {
1021         // create a Java String for the role
1022         jstring roleName = jniEnv->NewString(role, (jsize)wcslen(role));
1023         if (roleName == 0) {
1024             PrintDebugString("    NewString failed");
1025             return FALSE;
1026         }
1027 
1028         rAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1029                                                       getParentWithRoleMethod,
1030                                                       accessibleContext, roleName);
1031         EXCEPTION_CHECK("Getting ParentWithRole - call to CallObjectMethod()", (AccessibleContext)0);
1032         PrintDebugString("    rAccessibleContext = %p", rAccessibleContext);
1033         jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext);
1034         EXCEPTION_CHECK("Getting ParentWithRole - call to NewGlobalRef()", FALSE);
1035         PrintDebugString("  Returning - returnedAccessibleContext = %p; globalRef = %p",
1036                          rAccessibleContext, globalRef);
1037         return globalRef;
1038     } else {
1039         PrintDebugString("\r\n  Error! either jniEnv == 0 or getParentWithRoleMethod == 0");
1040         return 0;
1041     }
1042 }
1043 
1044 /**
1045  * Returns the Accessible Context for the top level object in
1046  * a Java Window.  This is same Accessible Context that is obtained
1047  * from GetAccessibleContextFromHWND for that window.  Returns
1048  * (AccessibleContext)0 on error.
1049  */
1050 jobject
1051 AccessBridgeJavaEntryPoints::getTopLevelObject(const jobject accessibleContext) {
1052     jthrowable exception;
1053     jobject rAccessibleContext;
1054 
1055     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getTopLevelObject(%p):",
1056                      accessibleContext);
1057 
1058     if (getTopLevelObjectMethod != (jmethodID) 0) {
1059         rAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1060                                                       getTopLevelObjectMethod,
1061                                                       accessibleContext);
1062         EXCEPTION_CHECK("Getting TopLevelObject - call to CallObjectMethod()", FALSE);
1063         PrintDebugString("\r\n    rAccessibleContext = %p", rAccessibleContext);
1064         jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext);
1065         EXCEPTION_CHECK("Getting TopLevelObject - call to NewGlobalRef()", FALSE);
1066         PrintDebugString("  Returning - returnedAccessibleContext = %p; globalRef = %p",
1067                          rAccessibleContext, globalRef);
1068         return globalRef;
1069     } else {
1070         PrintDebugString("\r\n  Error! either jniEnv == 0 or getTopLevelObjectMethod == 0");
1071         return 0;
1072     }
1073 }
1074 
1075 /**
1076  * If there is an Ancestor object that has an Accessible Role of
1077  * Internal Frame, returns the Accessible Context of the Internal
1078  * Frame object.  Otherwise, returns the top level object for that
1079  * Java Window.  Returns (AccessibleContext)0 on error.
1080  */
1081 jobject
1082 AccessBridgeJavaEntryPoints::getParentWithRoleElseRoot(const jobject accessibleContext, const wchar_t *role) {
1083     jthrowable exception;
1084     jobject rAccessibleContext;
1085 
1086     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getParentWithRoleElseRoot(%p):",
1087                      accessibleContext);
1088 
1089     if (getParentWithRoleElseRootMethod != (jmethodID) 0) {
1090 
1091         // create a Java String for the role
1092         jstring roleName = jniEnv->NewString(role, (jsize)wcslen(role));
1093         if (roleName == 0) {
1094             PrintDebugString("\r    NewString failed");
1095             return FALSE;
1096         }
1097 
1098         rAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1099                                                       getParentWithRoleElseRootMethod,
1100                                                       accessibleContext, roleName);
1101         EXCEPTION_CHECK("Getting ParentWithRoleElseRoot - call to CallObjectMethod()", (AccessibleContext)0);
1102         PrintDebugString("    rAccessibleContext = %p", rAccessibleContext);
1103         jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext);
1104         EXCEPTION_CHECK("Getting ParentWithRoleElseRoot - call to NewGlobalRef()", FALSE);
1105         PrintDebugString("  Returning - returnedAccessibleContext = %p; globalRef = %p",
1106                          rAccessibleContext, globalRef);
1107         return globalRef;
1108     } else {
1109         PrintDebugString("\r\n  Error! either jniEnv == 0 or getParentWithRoleElseRootMethod == 0");
1110         return 0;
1111     }
1112 }
1113 
1114 /**
1115  * Returns how deep in the object hierarchy a given object is.
1116  * The top most object in the object hierarchy has an object depth of 0.
1117  * Returns -1 on error.
1118  */
1119 jint
1120 AccessBridgeJavaEntryPoints::getObjectDepth(const jobject accessibleContext) {
1121     jthrowable exception;
1122     jint rResult;
1123 
1124     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getObjectDepth(%p):",
1125                      accessibleContext);
1126 
1127     if (getObjectDepthMethod != (jmethodID) 0) {
1128         rResult = jniEnv->CallIntMethod(accessBridgeObject,
1129                                         getObjectDepthMethod,
1130                                         accessibleContext);
1131         EXCEPTION_CHECK("Getting ObjectDepth - call to CallIntMethod()", -1);
1132         PrintDebugString("\r\n    rResult = %d", rResult);
1133         return rResult;
1134     } else {
1135         PrintDebugString("\r\n  Error! either jniEnv == 0 or getObjectDepthMethod == 0");
1136         return -1;
1137     }
1138 }
1139 
1140 
1141 
1142 /**
1143  * Returns the Accessible Context of the current ActiveDescendent of an object.
1144  * Returns 0 on error.
1145  */
1146 jobject
1147 AccessBridgeJavaEntryPoints::getActiveDescendent(const jobject accessibleContext) {
1148     jthrowable exception;
1149     jobject rAccessibleContext;
1150 
1151     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getActiveDescendent(%p):",
1152                      accessibleContext);
1153 
1154     if (getActiveDescendentMethod != (jmethodID) 0) {
1155         rAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1156                                                       getActiveDescendentMethod,
1157                                                       accessibleContext);
1158         EXCEPTION_CHECK("Getting ActiveDescendent - call to CallObjectMethod()", (AccessibleContext)0);
1159         PrintDebugString("\r\n    rAccessibleContext = %p", rAccessibleContext);
1160         jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext);
1161         EXCEPTION_CHECK("Getting ActiveDescendant - call to NewGlobalRef()", FALSE);
1162         PrintDebugString("  Returning - returnedAccessibleContext = %p; globalRef = %p",
1163                          rAccessibleContext, globalRef);
1164         return globalRef;
1165     } else {
1166         PrintDebugString("\r\n  Error! either jniEnv == 0 or getActiveDescendentMethod == 0");
1167         return (AccessibleContext)0;
1168     }
1169 }
1170 
1171 /**
1172  * Additional methods for Teton
1173  */
1174 
1175 /**
1176  * Returns an AccessibleName for a component using an algorithm optimized
1177  * for the JAWS screen reader by Ben Key (Freedom Scientific).  This method
1178  * is only intended for JAWS. All other uses are entirely optional.
1179  *
1180  * Bug ID 4916682 - Implement JAWS AccessibleName policy
1181  */
1182 BOOL
1183 AccessBridgeJavaEntryPoints::getVirtualAccessibleName (
1184     IN const jobject object,
1185     OUT wchar_t * name,
1186     IN const int nameSize)
1187 {
1188     /*
1189       +
1190       Parameter validation
1191       +
1192     */
1193     if ((name == 0) || (nameSize == 0))
1194     {
1195         return FALSE;
1196     }
1197     ::memset (name, 0, nameSize * sizeof (wchar_t));
1198     if (0 == object)
1199     {
1200         return FALSE;
1201     }
1202 
1203     jstring js = NULL;
1204     const wchar_t * stringBytes = NULL;
1205     jthrowable exception = NULL;
1206     jsize length = 0;
1207     PrintDebugString("\r\n  getVirtualAccessibleName called.");
1208     if (getVirtualAccessibleNameFromContextMethod != (jmethodID) 0)
1209     {
1210         js = (jstring) jniEnv->CallObjectMethod (
1211             accessBridgeObject,
1212             getVirtualAccessibleNameFromContextMethod,
1213             object);
1214         EXCEPTION_CHECK("Getting AccessibleName - call to CallObjectMethod()", FALSE);
1215         if (js != (jstring) 0)
1216         {
1217             stringBytes = (const wchar_t *) jniEnv->GetStringChars (js, 0);
1218             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1219             wcsncpy(name, stringBytes, nameSize - 1);
1220             length = jniEnv->GetStringLength(js);
1221             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringLength()", FALSE);
1222             jniEnv->ReleaseStringChars(js, stringBytes);
1223             EXCEPTION_CHECK("Getting AccessibleName - call to ReleaseStringChars()", FALSE);
1224             jniEnv->CallVoidMethod (
1225                 accessBridgeObject,
1226                 decrementReferenceMethod, js);
1227             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1228             wPrintDebugString(L"  Accessible Name = %ls", name);
1229             jniEnv->DeleteLocalRef(js);
1230             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1231         }
1232         else
1233         {
1234             PrintDebugString("  Accessible Name is null.");
1235         }
1236     }
1237     else
1238     {
1239         PrintDebugString("\r\n  Error! either jniEnv == 0 or getVirtualAccessibleNameFromContextMethod == 0");
1240         return FALSE;
1241     }
1242     if ( 0 != name [0] )
1243     {
1244         return TRUE;
1245     }
1246     return FALSE;
1247 }
1248 
1249 
1250 /**
1251  * Request focus for a component. Returns whether successful;
1252  *
1253  * Bug ID 4944757 - requestFocus method needed
1254  */
1255 BOOL
1256 AccessBridgeJavaEntryPoints::requestFocus(const jobject accessibleContext) {
1257 
1258     jthrowable exception;
1259     BOOL result = FALSE;
1260 
1261     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::requestFocus(%p):",
1262                      accessibleContext);
1263 
1264     if (requestFocusMethod != (jmethodID) 0) {
1265         result = (BOOL)jniEnv->CallBooleanMethod(accessBridgeObject,
1266                                                  requestFocusMethod,
1267                                                  accessibleContext);
1268         EXCEPTION_CHECK("requestFocus - call to CallBooleanMethod()", FALSE);
1269         PrintDebugString("\r\n    result = %d", result);
1270         return result;
1271     } else {
1272         PrintDebugString("\r\n  Error! either jniEnv == 0 or requestFocusMethod == 0");
1273         return result;
1274     }
1275 }
1276 
1277 /**
1278  * Selects text between two indices.  Selection includes the text at the start index
1279  * and the text at the end index. Returns whether successful;
1280  *
1281  * Bug ID 4944758 - selectTextRange method needed
1282  */
1283 BOOL
1284 AccessBridgeJavaEntryPoints::selectTextRange(const jobject accessibleContext, int startIndex, int endIndex) {
1285 
1286     jthrowable exception;
1287     BOOL result = FALSE;
1288 
1289     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::selectTextRange(%p start = %d end = %d):",
1290                      accessibleContext, startIndex, endIndex);
1291 
1292     if (selectTextRangeMethod != (jmethodID) 0) {
1293         result = (BOOL)jniEnv->CallBooleanMethod(accessBridgeObject,
1294                                                  selectTextRangeMethod,
1295                                                  accessibleContext,
1296                                                  startIndex, endIndex);
1297         EXCEPTION_CHECK("selectTextRange - call to CallBooleanMethod()", FALSE);
1298         PrintDebugString("\r\n    result = %d", result);
1299         return result;
1300     } else {
1301         PrintDebugString("\r\n  Error! either jniEnv == 0 or selectTextRangeMethod == 0");
1302         return result;
1303     }
1304 }
1305 
1306 /*
1307  * Returns whether two text attributes are the same.
1308  */
1309 static BOOL CompareAccessibleTextAttributesInfo(AccessibleTextAttributesInfo *one,
1310                                                 AccessibleTextAttributesInfo *two) {
1311     return(one->bold == two->bold
1312            && one->italic == two->italic
1313            && one->underline == two->underline
1314            && one->strikethrough == two->strikethrough
1315            && one->superscript == two->superscript
1316            && one->subscript == two->subscript
1317            && one->fontSize == two->fontSize
1318            && one->alignment == two->alignment
1319            && one->bidiLevel == two->bidiLevel
1320            && one->firstLineIndent == two->firstLineIndent
1321            && one->leftIndent == two->leftIndent
1322            && one->rightIndent == two->rightIndent
1323            && one->lineSpacing == two->lineSpacing
1324            && one->spaceAbove == two->spaceAbove
1325            && one->spaceBelow == two->spaceBelow
1326            && !wcscmp(one->backgroundColor,two->backgroundColor)
1327            && !wcscmp(one->foregroundColor,two->foregroundColor)
1328            && !wcscmp(one->fullAttributesString,two->fullAttributesString));
1329 }
1330 
1331 /**
1332  * Get text attributes between two indices.
1333  *
1334  * Only one AccessibleTextAttributesInfo structure is passed - which
1335  * contains the attributes for the first character, the function then goes
1336  * through the following characters in the range specified and stops when the
1337  * attributes are different from the first, it then returns in the passed
1338  * parameter len the number of characters with the attributes returned. In most
1339  * situations this will be all the characters, and if not the calling program
1340  * can easily get the attributes for the next characters with different
1341  * attributes
1342  *
1343  * Bug ID 4944761 - getTextAttributes between two indices method needed
1344  */
1345 
1346 /* NEW FASTER CODE!!*/
1347 BOOL
1348 AccessBridgeJavaEntryPoints::getTextAttributesInRange(const jobject accessibleContext,
1349                                                       int startIndex, int endIndex,
1350                                                       AccessibleTextAttributesInfo *attributes, short *len) {
1351 
1352     jstring js;
1353     const wchar_t *stringBytes;
1354     jthrowable exception;
1355     jsize length;
1356     BOOL result = FALSE;
1357 
1358     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::getTextAttributesInRange(%p start = %d end = %d):",
1359                      accessibleContext, startIndex, endIndex);
1360 
1361     *len = 0;
1362     result = getAccessibleTextAttributes((jobject)accessibleContext, startIndex, attributes);
1363     if (result != TRUE) {
1364         return FALSE;
1365     }
1366     (*len)++;
1367 
1368     for (jint i = startIndex+1; i <= endIndex; i++) {
1369 
1370         AccessibleTextAttributesInfo test_attributes = *attributes;
1371         // Get the full test_attributes string at i
1372         if (getAccessibleAttributesAtIndexFromContextMethod != (jmethodID) 0) {
1373             PrintDebugString(" Getting full test_attributes string from Context...");
1374             js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1375                                                     getAccessibleAttributesAtIndexFromContextMethod,
1376                                                     accessibleContext, i);
1377             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallObjectMethod()", FALSE);
1378             PrintDebugString("  returned from CallObjectMethod(), js = %p", js);
1379             if (js != (jstring) 0) {
1380                 stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1381                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE);
1382                 wcsncpy(test_attributes.fullAttributesString, stringBytes, (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t)));
1383                 length = jniEnv->GetStringLength(js);
1384                 test_attributes.fullAttributesString[length < (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t)) ?
1385                                                      length : (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t))-2] = (wchar_t) 0;
1386                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringLength()", FALSE);
1387                 jniEnv->ReleaseStringChars(js, stringBytes);
1388                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to ReleaseStringChars()", FALSE);
1389                 jniEnv->CallVoidMethod(accessBridgeObject,
1390                                        decrementReferenceMethod, js);
1391                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE);
1392                 wPrintDebugString(L"  Accessible Text attributes = %ls", test_attributes.fullAttributesString);
1393                 jniEnv->DeleteLocalRef(js);
1394                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
1395             } else {
1396                 PrintDebugString("  Accessible Text attributes is null.");
1397                 test_attributes.fullAttributesString[0] = (wchar_t) 0;
1398                 return FALSE;
1399             }
1400         } else {
1401             PrintDebugString("  Error! either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0");
1402             return FALSE;
1403         }
1404 
1405         if(wcscmp(attributes->fullAttributesString,test_attributes.fullAttributesString))
1406             break;
1407         if (result != TRUE) {
1408             return FALSE;
1409         }
1410         (*len)++;
1411     }
1412     return TRUE;
1413 }
1414 
1415 /*
1416  * Returns the number of visible children of a component
1417  *
1418  * Bug ID 4944762- getVisibleChildren for list-like components needed
1419  */
1420 int
1421 AccessBridgeJavaEntryPoints::getVisibleChildrenCount(const jobject accessibleContext) {
1422 
1423     jthrowable exception;
1424     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getVisibleChildrenCount(%p)",
1425                      accessibleContext);
1426 
1427     // get the visible children count
1428     int numChildren = jniEnv->CallIntMethod(accessBridgeObject, getVisibleChildrenCountMethod,
1429                                             accessibleContext);
1430     EXCEPTION_CHECK("##### Getting visible children count - call to CallIntMethod()", FALSE);
1431     PrintDebugString("  ##### visible children count = %d", numChildren);
1432 
1433     return numChildren;
1434 }
1435 
1436 
1437 /*
1438  * This method is used to iterate through the visible children of a component.  It
1439  * returns visible children information for a component starting at nStartIndex.
1440  * No more than MAX_VISIBLE_CHILDREN VisibleChildrenInfo objects will
1441  * be returned for each call to this method. Returns FALSE on error.
1442  *
1443  * Bug ID 4944762- getVisibleChildren for list-like components needed
1444  */
1445 BOOL AccessBridgeJavaEntryPoints::getVisibleChildren(const jobject accessibleContext,
1446                                                      const int nStartIndex,
1447                                                      /* OUT */ VisibleChildrenInfo *visibleChildrenInfo) {
1448 
1449     jthrowable exception;
1450 
1451     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getVisibleChildren(%p, startIndex = %d)",
1452                      accessibleContext, nStartIndex);
1453 
1454     // get the visible children count
1455     int numChildren = jniEnv->CallIntMethod(accessBridgeObject, getVisibleChildrenCountMethod,
1456                                             accessibleContext);
1457     EXCEPTION_CHECK("##### Getting visible children count - call to CallIntMethod()", FALSE);
1458     PrintDebugString("  ##### visible children count = %d", numChildren);
1459 
1460     if (nStartIndex >= numChildren) {
1461         return FALSE;
1462     }
1463 
1464     // get the visible children
1465     int bufIndex = 0;
1466     for (int i = nStartIndex; (i < numChildren) && (i < nStartIndex + MAX_VISIBLE_CHILDREN); i++) {
1467         PrintDebugString("  getting visible child %d ...", i);
1468 
1469         // get the visible child at index i
1470         jobject ac = jniEnv->CallObjectMethod(accessBridgeObject, getVisibleChildMethod,
1471                                               accessibleContext, i);
1472         EXCEPTION_CHECK("##### getVisibleChildMethod - call to CallObjectMethod()", FALSE);
1473         jobject globalRef = jniEnv->NewGlobalRef(ac);
1474         EXCEPTION_CHECK("##### getVisibleChildMethod - call to NewGlobalRef()", FALSE);
1475         visibleChildrenInfo->children[bufIndex] = (JOBJECT64)globalRef;
1476         PrintDebugString("  ##### visible child = %p", globalRef);
1477 
1478         bufIndex++;
1479     }
1480     visibleChildrenInfo->returnedChildrenCount = bufIndex;
1481 
1482     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::getVisibleChildren succeeded");
1483     return TRUE;
1484 }
1485 
1486 /**
1487  * Set the caret to a text position. Returns whether successful;
1488  *
1489  * Bug ID 4944770 - setCaretPosition method needed
1490  */
1491 BOOL
1492 AccessBridgeJavaEntryPoints::setCaretPosition(const jobject accessibleContext, int position) {
1493 
1494     jthrowable exception;
1495     BOOL result = FALSE;
1496 
1497     PrintDebugString("\r\nIn AccessBridgeJavaEntryPoints::setCaretPostion(%p position = %d):",
1498                      accessibleContext, position);
1499 
1500     if (setCaretPositionMethod != (jmethodID) 0) {
1501         result = (BOOL)jniEnv->CallBooleanMethod(accessBridgeObject,
1502                                                  setCaretPositionMethod,
1503                                                  accessibleContext, position);
1504         EXCEPTION_CHECK("setCaretPostion - call to CallBooleanMethod()", FALSE);
1505         PrintDebugString("\r\n    result = %d", result);
1506         return result;
1507     } else {
1508         PrintDebugString("\r\n  Error! either jniEnv == 0 or setCaretPositionMethod == 0");
1509         return result;
1510     }
1511 }
1512 
1513 
1514 // -----------------------------------
1515 
1516 /**
1517  * getVersionInfo - returns the version string of the java.version property
1518  *                  and the AccessBridge.java version
1519  *
1520  */
1521 BOOL
1522 AccessBridgeJavaEntryPoints::getVersionInfo(AccessBridgeVersionInfo *info) {
1523     jstring js;
1524     const wchar_t *stringBytes;
1525     jthrowable exception;
1526     jsize length;
1527 
1528     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getVersionInfo():");
1529 
1530     if (getJavaVersionPropertyMethod != (jmethodID) 0) {
1531         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1532                                                 getJavaVersionPropertyMethod);
1533         EXCEPTION_CHECK("Getting JavaVersionProperty - call to CallObjectMethod()", FALSE);
1534         PrintDebugString("  returned from CallObjectMethod(), js = %p", js);
1535         if (js != (jstring) 0) {
1536             length = jniEnv->GetStringLength(js);
1537             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1538             if (stringBytes == NULL) {
1539                 if (!jniEnv->ExceptionCheck()) {
1540                     PrintDebugString("\r\n *** Exception when getting JavaVersionProperty - call to GetStringChars");
1541                     jniEnv->ExceptionDescribe();
1542                     jniEnv->ExceptionClear();
1543                 }
1544                 return FALSE;
1545             }
1546             wcsncpy(info->bridgeJavaDLLVersion,
1547                     stringBytes,
1548                     sizeof(info->bridgeJavaDLLVersion)  / sizeof(wchar_t));
1549             info->bridgeJavaDLLVersion[length < (sizeof(info->bridgeJavaDLLVersion) / sizeof(wchar_t)) ?
1550                             length : (sizeof(info->bridgeJavaDLLVersion) / sizeof(wchar_t))-2] = (wchar_t) 0;
1551             wcsncpy(info->VMversion,
1552                     stringBytes,
1553                     sizeof(info->VMversion)  / sizeof(wchar_t));
1554             info->VMversion[length < (sizeof(info->VMversion) / sizeof(wchar_t)) ?
1555                             length : (sizeof(info->VMversion) / sizeof(wchar_t))-2] = (wchar_t) 0;
1556             wcsncpy(info->bridgeJavaClassVersion,
1557                     stringBytes,
1558                     sizeof(info->bridgeJavaClassVersion)  / sizeof(wchar_t));
1559             info->bridgeJavaClassVersion[length < (sizeof(info->bridgeJavaClassVersion) / sizeof(wchar_t)) ?
1560                                          length : (sizeof(info->bridgeJavaClassVersion) / sizeof(wchar_t))-2] = (wchar_t) 0;
1561             wcsncpy(info->bridgeWinDLLVersion,
1562                     stringBytes,
1563                     sizeof(info->bridgeWinDLLVersion)  / sizeof(wchar_t));
1564             info->bridgeWinDLLVersion[length < (sizeof(info->bridgeWinDLLVersion) / sizeof(wchar_t)) ?
1565                                          length : (sizeof(info->bridgeWinDLLVersion) / sizeof(wchar_t))-2] = (wchar_t) 0;
1566             jniEnv->ReleaseStringChars(js, stringBytes);
1567             EXCEPTION_CHECK("Getting JavaVersionProperty - call to ReleaseStringChars()", FALSE);
1568             jniEnv->CallVoidMethod(accessBridgeObject,
1569                                    decrementReferenceMethod, js);
1570             EXCEPTION_CHECK("Getting JavaVersionProperty - call to CallVoidMethod()", FALSE);
1571             wPrintDebugString(L"  Java version = %ls", info->VMversion);
1572             jniEnv->DeleteLocalRef(js);
1573             EXCEPTION_CHECK("Getting JavaVersionProperty - call to DeleteLocalRef()", FALSE);
1574         } else {
1575             PrintDebugString("  Java version is null.");
1576             info->VMversion[0] = (wchar_t) 0;
1577             return FALSE;
1578         }
1579     } else {
1580         PrintDebugString("  Error! either env == 0 or getJavaVersionPropertyMethod == 0");
1581         return FALSE;
1582     }
1583 
1584     return TRUE;
1585 }
1586 
1587 
1588 /*
1589  * Verifies the Java VM still exists and obj is an
1590  * instance of AccessibleText
1591  */
1592 BOOL AccessBridgeJavaEntryPoints::verifyAccessibleText(jobject obj) {
1593     JavaVM *vm;
1594     BOOL retval;
1595     jthrowable exception;
1596 
1597     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::verifyAccessibleText");
1598 
1599     if (jniEnv->GetJavaVM(&vm) != 0) {
1600         PrintDebugString("  Error! No Java VM");
1601         return FALSE;
1602     }
1603 
1604     if (obj == (jobject)0) {
1605         PrintDebugString("  Error! Null jobject");
1606         return FALSE;
1607     }
1608 
1609     // Copied from getAccessibleContextInfo
1610     if (getAccessibleTextFromContextMethod != (jmethodID) 0) {
1611         jobject returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
1612                                                            getAccessibleTextFromContextMethod,
1613                                                            (jobject)obj);
1614         EXCEPTION_CHECK("Getting AccessibleText - call to CallObjectMethod()", FALSE);
1615         PrintDebugString("  AccessibleText = %p", returnedJobject);
1616         retval = returnedJobject != (jobject) 0;
1617         jniEnv->DeleteLocalRef(returnedJobject);
1618         EXCEPTION_CHECK("Getting AccessibleText - call to DeleteLocalRef()", FALSE);
1619     } else {
1620         PrintDebugString("  Error! either env == 0 or getAccessibleTextFromContextMethod == 0");
1621         return FALSE;
1622     }
1623     if (retval == FALSE) {
1624         PrintDebugString("  Error! jobject is not an AccessibleText");
1625     }
1626     return retval;
1627 }
1628 
1629 
1630 /********** AccessibleContext routines ***********************************/
1631 
1632 /**
1633  * getAccessibleContextAt - performs the Java method call:
1634  *   Accessible AccessBridge.getAccessibleContextAt(x, y)
1635  *
1636  * Note: this call explicitly goes through the AccessBridge,
1637  * so that it can keep a reference the returned jobject for the JavaVM.
1638  * You must explicity call INTreleaseJavaObject() when you are through using
1639  * the Accessible returned, to let the AccessBridge know it can release the
1640  * object, so that the can then garbage collect it.
1641  *
1642  */
1643 jobject
1644 AccessBridgeJavaEntryPoints::getAccessibleContextAt(jint x, jint y, jobject accessibleContext) {
1645     jobject returnedAccessibleContext;
1646     jobject globalRef;
1647     jthrowable exception;
1648 
1649     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleContextAt(%d, %d, %p):",
1650                      x, y, accessibleContext);
1651 
1652     if (getAccessibleContextAtMethod != (jmethodID) 0) {
1653         returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1654                                                              getAccessibleContextAtMethod,
1655                                                              x, y, accessibleContext);
1656         EXCEPTION_CHECK("Getting AccessibleContextAt - call to CallObjectMethod()", FALSE);
1657         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
1658         EXCEPTION_CHECK("Getting AccessibleContextAt - call to NewGlobalRef()", FALSE);
1659         PrintDebugString("  Returning - returnedAccessibleContext = %p; globalRef = %p",
1660                          returnedAccessibleContext, globalRef);
1661         return globalRef;
1662     } else {
1663         PrintDebugString("  Error! either env == 0 or getAccessibleContextAtMethod == 0");
1664         return (jobject) 0;
1665     }
1666 }
1667 
1668 /**
1669  * getAccessibleWithFocus - performs the Java method calls:
1670  *   Accessible Translator.getAccessible(SwingEventMonitor.getComponentWithFocus();
1671  *
1672  * Note: this call explicitly goes through the AccessBridge,
1673  * so that the AccessBridge can hide expected changes in how this functions
1674  * between JDK 1.1.x w/AccessibilityUtility classes, and JDK 1.2, when some
1675  * of this functionality may be built into the platform
1676  *
1677  */
1678 jobject
1679 AccessBridgeJavaEntryPoints::getAccessibleContextWithFocus() {
1680     jobject returnedAccessibleContext;
1681     jobject globalRef;
1682     jthrowable exception;
1683 
1684     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleContextWithFocus()");
1685 
1686     if (getAccessibleContextWithFocusMethod != (jmethodID) 0) {
1687         returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1688                                                              getAccessibleContextWithFocusMethod);
1689         EXCEPTION_CHECK("Getting AccessibleContextWithFocus - call to CallObjectMethod()", FALSE);
1690         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
1691         EXCEPTION_CHECK("Getting AccessibleContextWithFocus - call to NewGlobalRef()", FALSE);
1692         PrintDebugString("  Returning - returnedAccessibleContext = %p; globalRef = %p",
1693                          returnedAccessibleContext, globalRef);
1694         return globalRef;
1695     } else {
1696         PrintDebugString("  Error! either jniEnv == 0 or getAccessibleContextWithFocusMethod == 0");
1697         return (jobject) 0;
1698     }
1699 }
1700 
1701 /**
1702  * getAccessibleContextInfo - fills a struct with a bunch of information
1703  * contained in the Java Accessibility API
1704  *
1705  * Note: if the AccessibleContext parameter is bogus, this call will blow up
1706  *
1707  * Note: this call explicitly goes through the AccessBridge,
1708  * so that it can keep a reference the returned jobject for the JavaVM.
1709  * You must explicity call releaseJavaObject() when you are through using
1710  * the AccessibleContext returned, to let the AccessBridge know it can release the
1711  * object, so that the JavaVM can then garbage collect it.
1712  */
1713 BOOL
1714 AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, AccessibleContextInfo *info) {
1715     jstring js;
1716     const wchar_t *stringBytes;
1717     jobject returnedJobject;
1718     jthrowable exception;
1719     jsize length;
1720 
1721     PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleContextInfo(%p):", accessibleContext);
1722 
1723     ZeroMemory(info, sizeof(AccessibleContextInfo));
1724 
1725     if (accessibleContext == (jobject) 0) {
1726         PrintDebugString(" passed in AccessibleContext == null! (oops)");
1727         return (FALSE);
1728     }
1729 
1730     // Get the Accessible Name
1731     if (getAccessibleNameFromContextMethod != (jmethodID) 0) {
1732         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1733                                                 getAccessibleNameFromContextMethod,
1734                                                 accessibleContext);
1735         EXCEPTION_CHECK("Getting AccessibleName - call to CallObjectMethod()", FALSE);
1736         if (js != (jstring) 0) {
1737             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1738             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1739             wcsncpy(info->name, stringBytes, (sizeof(info->name) / sizeof(wchar_t)));
1740             length = jniEnv->GetStringLength(js);
1741             info->name[length < (sizeof(info->name) / sizeof(wchar_t)) ?
1742                        length : (sizeof(info->name) / sizeof(wchar_t))-2] = (wchar_t) 0;
1743             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringLength()", FALSE);
1744             jniEnv->ReleaseStringChars(js, stringBytes);
1745             EXCEPTION_CHECK("Getting AccessibleName - call to ReleaseStringChars()", FALSE);
1746             jniEnv->CallVoidMethod(accessBridgeObject,
1747                                    decrementReferenceMethod, js);
1748             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1749             wPrintDebugString(L"  Accessible Name = %ls", info->name);
1750             jniEnv->DeleteLocalRef(js);
1751             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1752         } else {
1753             PrintDebugString("  Accessible Name is null.");
1754             info->name[0] = (wchar_t) 0;
1755         }
1756     } else {
1757         PrintDebugString("  Error! either env == 0 or getAccessibleNameFromContextMethod == 0");
1758         return FALSE;
1759     }
1760 
1761 
1762     // Get the Accessible Description
1763     if (getAccessibleDescriptionFromContextMethod != (jmethodID) 0) {
1764         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1765                                                 getAccessibleDescriptionFromContextMethod,
1766                                                 accessibleContext);
1767         EXCEPTION_CHECK("Getting AccessibleDescription - call to CallObjectMethod()", FALSE);
1768         if (js != (jstring) 0) {
1769             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1770             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1771             wcsncpy(info->description, stringBytes, (sizeof(info->description) / sizeof(wchar_t)));
1772             length = jniEnv->GetStringLength(js);
1773             info->description[length < (sizeof(info->description) / sizeof(wchar_t)) ?
1774                               length : (sizeof(info->description) / sizeof(wchar_t))-2] = (wchar_t) 0;
1775             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringLength()", FALSE);
1776             jniEnv->ReleaseStringChars(js, stringBytes);
1777             EXCEPTION_CHECK("Getting AccessibleName - call to ReleaseStringChars()", FALSE);
1778             jniEnv->CallVoidMethod(accessBridgeObject,
1779                                    decrementReferenceMethod, js);
1780             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1781             wPrintDebugString(L"  Accessible Description = %ls", info->description);
1782             jniEnv->DeleteLocalRef(js);
1783             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1784         } else {
1785             PrintDebugString("  Accessible Description is null.");
1786             info->description[0] = (wchar_t) 0;
1787         }
1788     } else {
1789         PrintDebugString("  Error! either env == 0 or getAccessibleDescriptionFromContextMethod == 0");
1790         return FALSE;
1791     }
1792 
1793 
1794     // Get the Accessible Role String
1795     if (getAccessibleRoleStringFromContextMethod != (jmethodID) 0) {
1796         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1797                                                 getAccessibleRoleStringFromContextMethod,
1798                                                 accessibleContext);
1799         EXCEPTION_CHECK("Getting AccessibleRole - call to CallObjectMethod()", FALSE);
1800         if (js != (jstring) 0) {
1801             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1802             EXCEPTION_CHECK("Getting AccessibleRole - call to GetStringChars()", FALSE);
1803             wcsncpy(info->role, stringBytes, (sizeof(info->role) / sizeof(wchar_t)));
1804             length = jniEnv->GetStringLength(js);
1805             info->role[length < (sizeof(info->role) / sizeof(wchar_t)) ?
1806                        length : (sizeof(info->role) / sizeof(wchar_t))-2] = (wchar_t) 0;
1807             EXCEPTION_CHECK("Getting AccessibleRole - call to GetStringLength()", FALSE);
1808             jniEnv->ReleaseStringChars(js, stringBytes);
1809             EXCEPTION_CHECK("Getting AccessibleRole - call to ReleaseStringChars()", FALSE);
1810             jniEnv->CallVoidMethod(accessBridgeObject,
1811                                    decrementReferenceMethod, js);
1812             EXCEPTION_CHECK("Getting AccessibleRole - call to CallVoidMethod()", FALSE);
1813             wPrintDebugString(L"  Accessible Role = %ls", info->role);
1814             jniEnv->DeleteLocalRef(js);
1815             EXCEPTION_CHECK("Getting AccessibleRole - call to DeleteLocalRef()", FALSE);
1816         } else {
1817             PrintDebugString("  Accessible Role is null.");
1818             info->role[0] = (wchar_t) 0;
1819         }
1820     } else {
1821         PrintDebugString("  Error! either env == 0 or getAccessibleRoleStringFromContextMethod == 0");
1822         return FALSE;
1823     }
1824 
1825 
1826     // Get the Accessible Role String in the en_US locale
1827     if (getAccessibleRoleStringFromContext_en_USMethod != (jmethodID) 0) {
1828         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1829                                                 getAccessibleRoleStringFromContext_en_USMethod,
1830                                                 accessibleContext);
1831         EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to CallObjectMethod()", FALSE);
1832         if (js != (jstring) 0) {
1833             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1834             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to GetStringChars()", FALSE);
1835             wcsncpy(info->role_en_US, stringBytes, (sizeof(info->role_en_US) / sizeof(wchar_t)));
1836             length = jniEnv->GetStringLength(js);
1837             info->role_en_US[length < (sizeof(info->role_en_US) / sizeof(wchar_t)) ?
1838                              length : (sizeof(info->role_en_US) / sizeof(wchar_t))-2] = (wchar_t) 0;
1839             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to GetStringLength()", FALSE);
1840             jniEnv->ReleaseStringChars(js, stringBytes);
1841             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to ReleaseStringChars()", FALSE);
1842             jniEnv->CallVoidMethod(accessBridgeObject,
1843                                    decrementReferenceMethod, js);
1844             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to CallVoidMethod()", FALSE);
1845             wPrintDebugString(L"  Accessible Role en_US = %ls", info->role_en_US);
1846             jniEnv->DeleteLocalRef(js);
1847             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to DeleteLocalRef()", FALSE);
1848         } else {
1849             PrintDebugString("  Accessible Role en_US is null.");
1850             info->role[0] = (wchar_t) 0;
1851         }
1852     } else {
1853         PrintDebugString("  Error! either env == 0 or getAccessibleRoleStringFromContext_en_USMethod == 0");
1854         return FALSE;
1855     }
1856 
1857     // Get the Accessible States String
1858     if (getAccessibleStatesStringFromContextMethod != (jmethodID) 0) {
1859         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1860                                                 getAccessibleStatesStringFromContextMethod,
1861                                                 accessibleContext);
1862         EXCEPTION_CHECK("Getting AccessibleState - call to CallObjectMethod()", FALSE);
1863         if (js != (jstring) 0) {
1864             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1865             EXCEPTION_CHECK("Getting AccessibleState - call to GetStringChars()", FALSE);
1866             wcsncpy(info->states, stringBytes, (sizeof(info->states) / sizeof(wchar_t)));
1867             length = jniEnv->GetStringLength(js);
1868             info->states[length < (sizeof(info->states) / sizeof(wchar_t)) ?
1869                          length : (sizeof(info->states) / sizeof(wchar_t))-2] = (wchar_t) 0;
1870             EXCEPTION_CHECK("Getting AccessibleState - call to GetStringLength()", FALSE);
1871             jniEnv->ReleaseStringChars(js, stringBytes);
1872             EXCEPTION_CHECK("Getting AccessibleState - call to ReleaseStringChars()", FALSE);
1873             jniEnv->CallVoidMethod(accessBridgeObject,
1874                                    decrementReferenceMethod, js);
1875             EXCEPTION_CHECK("Getting AccessibleState - call to CallVoidMethod()", FALSE);
1876             wPrintDebugString(L"  Accessible States = %ls", info->states);
1877             jniEnv->DeleteLocalRef(js);
1878             EXCEPTION_CHECK("Getting AccessibleState - call to DeleteLocalRef()", FALSE);
1879         } else {
1880             PrintDebugString("  Accessible States is null.");
1881             info->states[0] = (wchar_t) 0;
1882         }
1883     } else {
1884         PrintDebugString("  Error! either env == 0 or getAccessibleStatesStringFromContextMethod == 0");
1885         return FALSE;
1886     }
1887 
1888     // Get the Accessible States String in the en_US locale
1889     if (getAccessibleStatesStringFromContext_en_USMethod != (jmethodID) 0) {
1890         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1891                                                 getAccessibleStatesStringFromContext_en_USMethod,
1892                                                 accessibleContext);
1893         EXCEPTION_CHECK("Getting AccessibleState_en_US - call to CallObjectMethod()", FALSE);
1894         if (js != (jstring) 0) {
1895             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1896             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to GetStringChars()", FALSE);
1897             wcsncpy(info->states_en_US, stringBytes, (sizeof(info->states_en_US) / sizeof(wchar_t)));
1898             length = jniEnv->GetStringLength(js);
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             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to GetStringLength()", FALSE);
1902             jniEnv->ReleaseStringChars(js, stringBytes);
1903             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to ReleaseStringChars()", FALSE);
1904             jniEnv->CallVoidMethod(accessBridgeObject,
1905                                    decrementReferenceMethod, js);
1906             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to CallVoidMethod()", FALSE);
1907             wPrintDebugString(L"  Accessible States en_US = %ls", info->states_en_US);
1908             jniEnv->DeleteLocalRef(js);
1909             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to DeleteLocalRef()", FALSE);
1910         } else {
1911             PrintDebugString("  Accessible States en_US is null.");
1912             info->states[0] = (wchar_t) 0;
1913         }
1914     } else {
1915         PrintDebugString("  Error! either env == 0 or getAccessibleStatesStringFromContext_en_USMethod == 0");
1916         return FALSE;
1917     }
1918 
1919 
1920     // Get the index in Parent
1921     if (getAccessibleIndexInParentFromContextMethod != (jmethodID) 0) {
1922         info->indexInParent = jniEnv->CallIntMethod(accessBridgeObject,
1923                                                     getAccessibleIndexInParentFromContextMethod,
1924                                                     accessibleContext);
1925         EXCEPTION_CHECK("Getting AccessibleIndexInParent - call to CallIntMethod()", FALSE);
1926         PrintDebugString("  Index in Parent = %d", info->indexInParent);
1927     } else {
1928         PrintDebugString("  Error! either env == 0 or getAccessibleIndexInParentFromContextMethod == 0");
1929         return FALSE;
1930     }
1931 
1932 
1933     PrintDebugString("*** jniEnv: %p; accessBridgeObject: %p; AccessibleContext: %p ***",
1934                      jniEnv, accessBridgeObject, accessibleContext);
1935 
1936     // Get the children count
1937     if (getAccessibleChildrenCountFromContextMethod != (jmethodID) 0) {
1938         info->childrenCount = jniEnv->CallIntMethod(accessBridgeObject,
1939                                                     getAccessibleChildrenCountFromContextMethod,
1940                                                     accessibleContext);
1941         EXCEPTION_CHECK("Getting AccessibleChildrenCount - call to CallIntMethod()", FALSE);
1942         PrintDebugString("  Children count = %d", info->childrenCount);
1943     } else {
1944         PrintDebugString("  Error! either env == 0 or getAccessibleChildrenCountFromContextMethod == 0");
1945         return FALSE;
1946     }
1947 
1948     PrintDebugString("*** jniEnv: %p; accessBridgeObject: %p; AccessibleContext: %X ***",
1949                      jniEnv, accessBridgeObject, accessibleContext);
1950 
1951 
1952     // Get the x coord
1953     if (getAccessibleXcoordFromContextMethod != (jmethodID) 0) {
1954         info->x = jniEnv->CallIntMethod(accessBridgeObject,
1955                                         getAccessibleXcoordFromContextMethod,
1956                                         accessibleContext);
1957         EXCEPTION_CHECK("Getting AccessibleXcoord - call to CallIntMethod()", FALSE);
1958         PrintDebugString("  X coord = %d", info->x);
1959     } else {
1960         PrintDebugString("  Error! either env == 0 or getAccessibleXcoordFromContextMethod == 0");
1961         return FALSE;
1962     }
1963 
1964     PrintDebugString("*** jniEnv: %X; accessBridgeObject: %X; AccessibleContext: %p ***",
1965                      jniEnv, accessBridgeObject, accessibleContext);
1966 
1967 
1968     // Get the y coord
1969     if (getAccessibleYcoordFromContextMethod != (jmethodID) 0) {
1970         info->y = jniEnv->CallIntMethod(accessBridgeObject,
1971                                         getAccessibleYcoordFromContextMethod,
1972                                         accessibleContext);
1973         EXCEPTION_CHECK("Getting AccessibleYcoord - call to CallIntMethod()", FALSE);
1974         PrintDebugString("  Y coord = %d", info->y);
1975     } else {
1976         PrintDebugString("  Error! either env == 0 or getAccessibleYcoordFromContextMethod == 0");
1977         return FALSE;
1978     }
1979 
1980     // Get the width
1981     if (getAccessibleWidthFromContextMethod != (jmethodID) 0) {
1982         info->width = jniEnv->CallIntMethod(accessBridgeObject,
1983                                             getAccessibleWidthFromContextMethod,
1984                                             accessibleContext);
1985         EXCEPTION_CHECK("Getting AccessibleWidth - call to CallIntMethod()", FALSE);
1986         PrintDebugString("  Width = %d", info->width);
1987     } else {
1988         PrintDebugString("  Error! either env == 0 or getAccessibleWidthFromContextMethod == 0");
1989         return FALSE;
1990     }
1991 
1992     // Get the height
1993     if (getAccessibleHeightFromContextMethod != (jmethodID) 0) {
1994         info->height = jniEnv->CallIntMethod(accessBridgeObject,
1995                                              getAccessibleHeightFromContextMethod,
1996                                              accessibleContext);
1997         EXCEPTION_CHECK("Getting AccessibleHeight - call to CallIntMethod()", FALSE);
1998         PrintDebugString("  Height = %d", info->height);
1999     } else {
2000         PrintDebugString("  Error! either env == 0 or getAccessibleHeightFromContextMethod == 0");
2001         return FALSE;
2002     }
2003 
2004     // Get the AccessibleComponent
2005     if (getAccessibleComponentFromContextMethod != (jmethodID) 0) {
2006         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2007                                                    getAccessibleComponentFromContextMethod,
2008                                                    accessibleContext);
2009         EXCEPTION_CHECK("Getting AccessibleComponent - call to CallObjectMethod()", FALSE);
2010         PrintDebugString("  AccessibleComponent = %p", returnedJobject);
2011         info->accessibleComponent = (returnedJobject != (jobject) 0 ? TRUE : FALSE);
2012         jniEnv->DeleteLocalRef(returnedJobject);
2013         EXCEPTION_CHECK("Getting AccessibleComponent - call to DeleteLocalRef()", FALSE);
2014     } else {
2015         PrintDebugString("  Error! either env == 0 or getAccessibleComponentFromContextMethod == 0");
2016         return FALSE;
2017     }
2018 
2019     // Get the AccessibleAction
2020     if (getAccessibleActionFromContextMethod != (jmethodID) 0) {
2021         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2022                                                    getAccessibleActionFromContextMethod,
2023                                                    accessibleContext);
2024         EXCEPTION_CHECK("Getting AccessibleAction - call to CallObjectMethod()", FALSE);
2025         PrintDebugString("  AccessibleAction = %p", returnedJobject);
2026         info->accessibleAction = (returnedJobject != (jobject) 0 ? TRUE : FALSE);
2027         jniEnv->DeleteLocalRef(returnedJobject);
2028         EXCEPTION_CHECK("Getting AccessibleAction - call to DeleteLocalRef()", FALSE);
2029     } else {
2030         PrintDebugString("  Error! either env == 0 or getAccessibleActionFromContextMethod == 0");
2031         return FALSE;
2032     }
2033 
2034     // Get the AccessibleSelection
2035     if (getAccessibleSelectionFromContextMethod != (jmethodID) 0) {
2036         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2037                                                    getAccessibleSelectionFromContextMethod,
2038                                                    accessibleContext);
2039         EXCEPTION_CHECK("Getting AccessibleSelection - call to CallObjectMethod()", FALSE);
2040         PrintDebugString("  AccessibleSelection = %p", returnedJobject);
2041         info->accessibleSelection = (returnedJobject != (jobject) 0 ? TRUE : FALSE);
2042         jniEnv->DeleteLocalRef(returnedJobject);
2043         EXCEPTION_CHECK("Getting AccessibleSelection - call to DeleteLocalRef()", FALSE);
2044     } else {
2045         PrintDebugString("  Error! either env == 0 or getAccessibleSelectionFromContextMethod == 0");
2046         return FALSE;
2047     }
2048 
2049     // Get the AccessibleTable
2050     if (getAccessibleTableFromContextMethod != (jmethodID) 0) {
2051         PrintDebugString("##### Calling getAccessibleTableFromContextMethod ...");
2052         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2053                                                    getAccessibleTableFromContextMethod,
2054                                                    accessibleContext);
2055         PrintDebugString("##### ... Returned from getAccessibleTableFromContextMethod");
2056         EXCEPTION_CHECK("##### Getting AccessibleTable - call to CallObjectMethod()", FALSE);
2057         PrintDebugString("  ##### AccessibleTable = %p", returnedJobject);
2058         if (returnedJobject != (jobject) 0) {
2059             info->accessibleInterfaces |= cAccessibleTableInterface;
2060         }
2061         jniEnv->DeleteLocalRef(returnedJobject);
2062         EXCEPTION_CHECK("##### Getting AccessibleTable - call to DeleteLocalRef()", FALSE);
2063 
2064         /*
2065           returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2066           getAccessibleTableFromContextMethod,
2067           AccessibleContext);
2068           PrintDebugString("##### ... Returned from getAccessibleTableFromContextMethod");
2069           EXCEPTION_CHECK("##### Getting AccessibleTable - call to CallObjectMethod()", FALSE);
2070           PrintDebugString("  ##### AccessibleTable = %X", returnedJobject);
2071           info->accessibleTable = returnedJobject;
2072         */
2073 
2074     } else {
2075         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableFromContextMethod == 0");
2076         return FALSE;
2077     }
2078 
2079     // Get the AccessibleText
2080     if (getAccessibleTextFromContextMethod != (jmethodID) 0) {
2081         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2082                                                    getAccessibleTextFromContextMethod,
2083                                                    accessibleContext);
2084         EXCEPTION_CHECK("Getting AccessibleText - call to CallObjectMethod()", FALSE);
2085         PrintDebugString("  AccessibleText = %p", returnedJobject);
2086         info->accessibleText = (returnedJobject != (jobject) 0 ? TRUE : FALSE);
2087         jniEnv->DeleteLocalRef(returnedJobject);
2088         EXCEPTION_CHECK("Getting AccessibleText - call to DeleteLocalRef()", FALSE);
2089     } else {
2090         PrintDebugString("  Error! either env == 0 or getAccessibleTextFromContextMethod == 0");
2091         return FALSE;
2092     }
2093 
2094     // Get the AccessibleValue
2095     if (getAccessibleValueFromContextMethod != (jmethodID) 0) {
2096         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2097                                                    getAccessibleValueFromContextMethod,
2098                                                    accessibleContext);
2099         EXCEPTION_CHECK("Getting AccessibleValue - call to CallObjectMethod()", FALSE);
2100         PrintDebugString("  AccessibleValue = %p", returnedJobject);
2101         if (returnedJobject != (jobject) 0) {
2102             info->accessibleInterfaces |= cAccessibleValueInterface;
2103         }
2104         jniEnv->DeleteLocalRef(returnedJobject);
2105         EXCEPTION_CHECK("Getting AccessibleValue - call to DeleteLocalRef()", FALSE);
2106     } else {
2107         PrintDebugString("  Error! either env == 0 or getAccessibleValueFromContextMethod == 0");
2108         return FALSE;
2109     }
2110 
2111     // FIX
2112     // get the AccessibleHypertext
2113     if (getAccessibleHypertextMethod != (jmethodID) 0 &&
2114         getAccessibleHyperlinkCountMethod != (jmethodID) 0 &&
2115         getAccessibleHyperlinkMethod != (jmethodID) 0 &&
2116         getAccessibleHyperlinkTextMethod != (jmethodID) 0 &&
2117         getAccessibleHyperlinkStartIndexMethod != (jmethodID) 0 &&
2118         getAccessibleHyperlinkEndIndexMethod != (jmethodID) 0) {
2119         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2120                                                    getAccessibleHypertextMethod,
2121                                                    accessibleContext);
2122         EXCEPTION_CHECK("Getting AccessibleHypertext - call to CallObjectMethod()", FALSE);
2123         PrintDebugString("  AccessibleHypertext = %p",
2124                          returnedJobject);
2125         if (returnedJobject != (jobject) 0) {
2126             info->accessibleInterfaces |= cAccessibleHypertextInterface;
2127         }
2128         jniEnv->DeleteLocalRef(returnedJobject);
2129         EXCEPTION_CHECK("Getting AccessibleHypertext - call to DeleteLocalRef()", FALSE);
2130     }
2131 
2132     // set new accessibleInterfaces flags from old BOOL values
2133     if(info->accessibleComponent)
2134         info->accessibleInterfaces |= cAccessibleComponentInterface;
2135     if(info->accessibleAction)
2136         info->accessibleInterfaces |= cAccessibleActionInterface;
2137     if(info->accessibleSelection)
2138         info->accessibleInterfaces |= cAccessibleSelectionInterface;
2139     if(info->accessibleText)
2140         info->accessibleInterfaces |= cAccessibleTextInterface;
2141     // FIX END
2142 
2143     return TRUE;
2144 }
2145 
2146 /**
2147  * getAccessibleChildFromContext - performs the Java method call:
2148  *   AccessibleContext AccessBridge.getAccessibleChildContext(AccessibleContext)
2149  *
2150  * Note: if the AccessibleContext parameter is bogus, this call will blow up
2151  *
2152  * Note: this call explicitly goes through the AccessBridge,
2153  * so that it can keep a reference the returned jobject for the JavaVM.
2154  * You must explicity call releaseJavaObject() when you are through using
2155  * the AccessibleContext returned, to let the AccessBridge know it can release the
2156  * object, so that the JavaVM can then garbage collect it.
2157  */
2158 jobject
2159 AccessBridgeJavaEntryPoints::getAccessibleChildFromContext(jobject accessibleContext, jint childIndex) {
2160     jobject returnedAccessibleContext;
2161     jobject globalRef;
2162     jthrowable exception;
2163 
2164     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleChildContext(%p, %d):",
2165                      accessibleContext, childIndex);
2166 
2167     if (getAccessibleChildFromContextMethod != (jmethodID) 0) {
2168         returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
2169                                                              getAccessibleChildFromContextMethod,
2170                                                              accessibleContext, childIndex);
2171         EXCEPTION_CHECK("Getting AccessibleChild - call to CallObjectMethod()", FALSE);
2172         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
2173         EXCEPTION_CHECK("Getting AccessibleChild - call to NewGlobalRef()", FALSE);
2174         jniEnv->DeleteLocalRef(returnedAccessibleContext);
2175         EXCEPTION_CHECK("Getting AccessibleChild - call to DeleteLocalRef()", FALSE);
2176         PrintDebugString("  Returning - returnedAccessibleContext = %p; globalRef = %p",
2177                          returnedAccessibleContext, globalRef);
2178         return globalRef;
2179     } else {
2180         PrintDebugString("  Error! either env == 0 or getAccessibleChildContextMethod == 0");
2181         return (jobject) 0;
2182     }
2183 }
2184 
2185 /**
2186  * getAccessibleParentFromContext - returns the AccessibleContext parent
2187  *
2188  */
2189 jobject
2190 AccessBridgeJavaEntryPoints::getAccessibleParentFromContext(jobject accessibleContext)
2191 {
2192     jobject returnedAccessibleContext;
2193     jobject globalRef;
2194     jthrowable exception;
2195 
2196     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleParentFromContext(%p):", accessibleContext);
2197 
2198     if (getAccessibleParentFromContextMethod != (jmethodID) 0) {
2199         returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
2200                                                              getAccessibleParentFromContextMethod,
2201                                                              accessibleContext);
2202         EXCEPTION_CHECK("Getting AccessibleParent - call to CallObjectMethod()", FALSE);
2203         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
2204         EXCEPTION_CHECK("Getting AccessibleParent - call to NewGlobalRef()", FALSE);
2205         jniEnv->DeleteLocalRef(returnedAccessibleContext);
2206         EXCEPTION_CHECK("Getting AccessibleParent - call to DeleteLocalRef()", FALSE);
2207         PrintDebugString("  Returning - returnedAccessibleContext = %p; globalRef = %p",
2208                          returnedAccessibleContext, globalRef);
2209         return globalRef;
2210     } else {
2211         PrintDebugString("  Error! either env == 0 or getAccessibleParentFromContextMethod == 0");
2212         return (jobject) 0;
2213     }
2214 }
2215 
2216 
2217 /********** AccessibleTable routines **********************************/
2218 
2219 BOOL
2220 AccessBridgeJavaEntryPoints::getAccessibleTableInfo(jobject accessibleContext,
2221                                                     AccessibleTableInfo *tableInfo) {
2222 
2223     jthrowable exception;
2224 
2225     PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableInfo(%p):",
2226                      accessibleContext);
2227 
2228     // get the table row count
2229     if (getAccessibleTableRowCountMethod != (jmethodID) 0) {
2230         tableInfo->rowCount = jniEnv->CallIntMethod(accessBridgeObject,
2231                                                     getAccessibleTableRowCountMethod,
2232                                                     accessibleContext);
2233         EXCEPTION_CHECK("##### Getting AccessibleTableRowCount - call to CallIntMethod()", FALSE);
2234         PrintDebugString("  ##### table row count = %d", tableInfo->rowCount);
2235     } else {
2236         PrintDebugString("  ##### Error! either env == 0 or getAccessibleRowCountMethod == 0");
2237         return FALSE;
2238     }
2239 
2240     // get the table column count
2241     if (getAccessibleTableColumnCountMethod != (jmethodID) 0) {
2242         tableInfo->columnCount = jniEnv->CallIntMethod(accessBridgeObject,
2243                                                        getAccessibleTableColumnCountMethod,
2244                                                        accessibleContext);
2245         EXCEPTION_CHECK("Getting AccessibleTableColumnCount - call to CallIntMethod()", FALSE);
2246         PrintDebugString("  ##### table column count = %d", tableInfo->columnCount);
2247     } else {
2248         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableColumnCountMethod == 0");
2249         return FALSE;
2250     }
2251 
2252     // get the AccessibleTable
2253     if (getAccessibleTableFromContextMethod != (jmethodID) 0) {
2254         PrintDebugString("##### Calling getAccessibleTableFromContextMethod ...");
2255         jobject accTable = jniEnv->CallObjectMethod(accessBridgeObject,
2256                                                     getAccessibleTableFromContextMethod,
2257                                                     accessibleContext);
2258         PrintDebugString("##### ... Returned from getAccessibleTableFromContextMethod");
2259         EXCEPTION_CHECK("##### Getting AccessibleTable - call to CallObjectMethod()", FALSE);
2260         jobject globalRef = jniEnv->NewGlobalRef(accTable);
2261         EXCEPTION_CHECK("##### Getting AccessibleTable - call to NewGlobalRef()", FALSE);
2262         tableInfo->accessibleTable = (JOBJECT64)globalRef;
2263         PrintDebugString("  ##### accessibleTable = %p", globalRef);
2264     } else {
2265         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableFromContextMethod == 0");
2266         return FALSE;
2267     }
2268 
2269     // cache the AccessibleContext
2270     if (getContextFromAccessibleTableMethod != (jmethodID) 0) {
2271         PrintDebugString("##### Calling getContextFromAccessibleTable Method ...");
2272         jobject ac = jniEnv->CallObjectMethod(accessBridgeObject,
2273                                               getContextFromAccessibleTableMethod,
2274                                               accessibleContext);
2275         PrintDebugString("##### ... Returned from getContextFromAccessibleTable Method");
2276         EXCEPTION_CHECK("##### Getting AccessibleTable - call to CallObjectMethod()", FALSE);
2277         jobject globalRef = jniEnv->NewGlobalRef(ac);
2278         EXCEPTION_CHECK("##### Getting AccessibleTable - call to NewGlobalRef()", FALSE);
2279         tableInfo->accessibleContext = (JOBJECT64)globalRef;
2280         PrintDebugString("  ##### accessibleContext = %p", globalRef);
2281     } else {
2282         PrintDebugString("  ##### Error! either env == 0 or getContextFromAccessibleTable Method == 0");
2283         return FALSE;
2284     }
2285 
2286     // FIX - set unused elements
2287     tableInfo->caption = NULL;
2288     tableInfo->summary = NULL;
2289 
2290     PrintDebugString("##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableInfo succeeded");
2291     return TRUE;
2292 }
2293 
2294 BOOL
2295 AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(jobject accessibleTable, jint row, jint column,
2296                                                         AccessibleTableCellInfo *tableCellInfo) {
2297 
2298     jthrowable exception;
2299 
2300     PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(%p): row=%d, column=%d",
2301                      accessibleTable, row, column);
2302 
2303     // FIX
2304     ZeroMemory(tableCellInfo, sizeof(AccessibleTableCellInfo));
2305     tableCellInfo->row = row;
2306     tableCellInfo->column = column;
2307     // FIX END
2308 
2309     // get the table cell index
2310     if (getAccessibleTableCellIndexMethod != (jmethodID) 0) {
2311         tableCellInfo->index = jniEnv->CallIntMethod(accessBridgeObject,
2312                                                      getAccessibleTableCellIndexMethod,
2313                                                      accessibleTable, row, column);
2314         EXCEPTION_CHECK("##### Getting AccessibleTableCellIndex - call to CallIntMethod()", FALSE);
2315         PrintDebugString("  ##### table cell index = %d", tableCellInfo->index);
2316     } else {
2317         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableCellIndexMethod == 0");
2318         return FALSE;
2319     }
2320 
2321     // get the table cell row extent
2322     if (getAccessibleTableCellRowExtentMethod != (jmethodID) 0) {
2323         tableCellInfo->rowExtent = jniEnv->CallIntMethod(accessBridgeObject,
2324                                                          getAccessibleTableCellRowExtentMethod,
2325                                                          accessibleTable, row, column);
2326         EXCEPTION_CHECK("##### Getting AccessibleTableCellRowExtentCount - call to CallIntMethod()", FALSE);
2327         PrintDebugString("  ##### table cell row extent = %d", tableCellInfo->rowExtent);
2328     } else {
2329         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableCellRowExtentMethod == 0");
2330         return FALSE;
2331     }
2332 
2333     // get the table cell column extent
2334     if (getAccessibleTableCellColumnExtentMethod != (jmethodID) 0) {
2335         tableCellInfo->columnExtent = jniEnv->CallIntMethod(accessBridgeObject,
2336                                                             getAccessibleTableCellColumnExtentMethod,
2337                                                             accessibleTable, row, column);
2338         EXCEPTION_CHECK("##### Getting AccessibleTableCellColumnExtentCount - call to CallIntMethod()", FALSE);
2339         PrintDebugString("  ##### table cell column extent = %d", tableCellInfo->columnExtent);
2340     } else {
2341         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableCellColumnExtentMethod == 0");
2342         return FALSE;
2343     }
2344 
2345     // get whether the table cell is selected
2346     if (isAccessibleTableCellSelectedMethod != (jmethodID) 0) {
2347         tableCellInfo->isSelected = jniEnv->CallBooleanMethod(accessBridgeObject,
2348                                                               isAccessibleTableCellSelectedMethod,
2349                                                               accessibleTable, row, column);
2350         EXCEPTION_CHECK("##### Getting isAccessibleTableCellSelected - call to CallBooleanMethod()", FALSE);
2351         PrintDebugString("  ##### table cell isSelected = %d", tableCellInfo->isSelected);
2352     } else {
2353         PrintDebugString("  ##### Error! either env == 0 or isAccessibleTableCellSelectedMethod == 0");
2354         return FALSE;
2355     }
2356 
2357     // get the table cell AccessibleContext
2358     if (getAccessibleTableCellAccessibleContextMethod != (jmethodID) 0) {
2359         jobject tableCellAC = jniEnv->CallObjectMethod(accessBridgeObject,
2360                                                        getAccessibleTableCellAccessibleContextMethod,
2361                                                        accessibleTable, row, column);
2362         EXCEPTION_CHECK("##### Getting AccessibleTableCellAccessibleContext - call to CallObjectMethod()", FALSE);
2363         jobject globalRef = jniEnv->NewGlobalRef(tableCellAC);
2364         EXCEPTION_CHECK("##### Getting AccessibleTableCellAccessibleContext - call to NewGlobalRef()", FALSE);
2365         tableCellInfo->accessibleContext = (JOBJECT64)globalRef;
2366         PrintDebugString("  ##### table cell AccessibleContext = %p", globalRef);
2367     } else {
2368         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableCellAccessibleContextMethod == 0");
2369         return FALSE;
2370     }
2371 
2372     PrintDebugString("  ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo succeeded");
2373     return TRUE;
2374 }
2375 
2376 BOOL
2377 AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader(jobject acParent, AccessibleTableInfo *tableInfo) {
2378 
2379     jthrowable exception;
2380 
2381     PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader(%p):",
2382                      acParent);
2383 
2384     // get the header row count
2385     if (getAccessibleTableRowHeaderRowCountMethod != (jmethodID) 0) {
2386         tableInfo->rowCount = jniEnv->CallIntMethod(accessBridgeObject,
2387                                                     getAccessibleTableRowHeaderRowCountMethod,
2388                                                     acParent);
2389         EXCEPTION_CHECK("##### Getting AccessibleTableRowHeaderRowCount - call to CallIntMethod()", FALSE);
2390         PrintDebugString("  ##### table row count = %d", tableInfo->rowCount);
2391     } else {
2392         PrintDebugString("  ##### Error! either env == 0 or getAccessibleRowHeaderRowCountMethod == 0");
2393         return FALSE;
2394     }
2395 
2396     // get the header column count
2397     if (getAccessibleTableRowHeaderColumnCountMethod != (jmethodID) 0) {
2398         tableInfo->columnCount = jniEnv->CallIntMethod(accessBridgeObject,
2399                                                        getAccessibleTableRowHeaderColumnCountMethod,
2400                                                        acParent);
2401         EXCEPTION_CHECK("Getting AccessibleTableRowHeaderColumnCount - call to CallIntMethod()", FALSE);
2402         PrintDebugString("  ##### table column count = %d", tableInfo->columnCount);
2403     } else {
2404         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableRowHeaderColumnCountMethod == 0");
2405         return FALSE;
2406     }
2407 
2408     // get the header AccessibleTable
2409     if (getAccessibleTableRowHeaderMethod != (jmethodID) 0) {
2410         jobject accTable = jniEnv->CallObjectMethod(accessBridgeObject,
2411                                                     getAccessibleTableRowHeaderMethod,
2412                                                     acParent);
2413         EXCEPTION_CHECK("##### Getting AccessibleTableRowHeader - call to CallObjectMethod()", FALSE);
2414         jobject globalRef = jniEnv->NewGlobalRef(accTable);
2415         EXCEPTION_CHECK("##### Getting AccessibleTableRowHeader - call to NewGlobalRef()", FALSE);
2416         tableInfo->accessibleTable = (JOBJECT64)globalRef;
2417         PrintDebugString("  ##### row header AccessibleTable = %p", globalRef);
2418     } else {
2419         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableRowHeaderMethod == 0");
2420         return FALSE;
2421     }
2422 
2423     // FIX - set unused elements
2424     tableInfo->caption = NULL;
2425     tableInfo->summary = NULL;
2426     tableInfo->accessibleContext = NULL;
2427 
2428     PrintDebugString("  ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader succeeded");
2429     return TRUE;
2430 }
2431 
2432 BOOL
2433 AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader(jobject acParent, AccessibleTableInfo *tableInfo) {
2434     jthrowable exception;
2435 
2436     PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader(%p):",
2437                      acParent);
2438 
2439     // get the header row count
2440     if (getAccessibleTableColumnHeaderRowCountMethod != (jmethodID) 0) {
2441         tableInfo->rowCount = jniEnv->CallIntMethod(accessBridgeObject,
2442                                                     getAccessibleTableColumnHeaderRowCountMethod,
2443                                                     acParent);
2444         EXCEPTION_CHECK("##### Getting AccessibleTableColumnHeaderRowCount - call to CallIntMethod()", FALSE);
2445         PrintDebugString("  ##### table row count = %d", tableInfo->rowCount);
2446     } else {
2447         PrintDebugString("  ##### Error! either env == 0 or getAccessibleColumnHeaderRowCountMethod == 0");
2448         return FALSE;
2449     }
2450 
2451     // get the header column count
2452     if (getAccessibleTableColumnHeaderColumnCountMethod != (jmethodID) 0) {
2453         tableInfo->columnCount = jniEnv->CallIntMethod(accessBridgeObject,
2454                                                        getAccessibleTableColumnHeaderColumnCountMethod,
2455                                                        acParent);
2456         EXCEPTION_CHECK("Getting AccessibleTableColumnHeaderColumnCount - call to CallIntMethod()", FALSE);
2457         PrintDebugString("  ##### table column count = %d", tableInfo->columnCount);
2458     } else {
2459         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableColumnHeaderColumnCountMethod == 0");
2460         return FALSE;
2461     }
2462     // get the header AccessibleTable
2463     if (getAccessibleTableColumnHeaderMethod != (jmethodID) 0) {
2464         jobject accTable = jniEnv->CallObjectMethod(accessBridgeObject,
2465                                                     getAccessibleTableColumnHeaderMethod,
2466                                                     acParent);
2467         EXCEPTION_CHECK("##### Getting AccessibleTableColumnHeader - call to CallObjectMethod()", FALSE);
2468         jobject globalRef = jniEnv->NewGlobalRef(accTable);
2469         EXCEPTION_CHECK("##### Getting AccessibleTableColumnHeader - call to NewGlobalRef()", FALSE);
2470         tableInfo->accessibleTable = (JOBJECT64)globalRef;
2471         PrintDebugString("  ##### column header AccessibleTable = %p", globalRef);
2472     } else {
2473         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableColumnHeaderMethod == 0");
2474         return FALSE;
2475     }
2476 
2477     // FIX - set unused elements
2478     tableInfo->caption = NULL;
2479     tableInfo->summary = NULL;
2480     tableInfo->accessibleContext = NULL;
2481 
2482     PrintDebugString("  ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader succeeded");
2483     return TRUE;
2484 }
2485 
2486 jobject
2487 AccessBridgeJavaEntryPoints::getAccessibleTableRowDescription(jobject acParent, jint row) {
2488 
2489     jobject returnedAccessibleContext;
2490     jobject globalRef;
2491     jthrowable exception;
2492 
2493     PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowDescription(%p):",
2494                      acParent);
2495 
2496     if (getAccessibleTableRowDescriptionMethod != (jmethodID) 0) {
2497         returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
2498                                                              getAccessibleTableRowDescriptionMethod,
2499                                                              acParent, row);
2500         EXCEPTION_CHECK("Getting AccessibleTableRowDescription - call to CallObjectMethod()", FALSE);
2501         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
2502         EXCEPTION_CHECK("Getting AccessibleTableRowDescription - call to NewGlobalRef()", FALSE);
2503         jniEnv->DeleteLocalRef(returnedAccessibleContext);
2504         EXCEPTION_CHECK("Getting AccessibleTableRowDescription - call to DeleteLocalRef()", FALSE);
2505         PrintDebugString("  Returning - returnedAccessibleContext = %p; globalRef = %p",
2506                          returnedAccessibleContext, globalRef);
2507         return globalRef;
2508     } else {
2509         PrintDebugString("  Error! either env == 0 or getAccessibleTableRowDescriptionMethod == 0");
2510         return (jobject) 0;
2511     }
2512 }
2513 
2514 jobject
2515 AccessBridgeJavaEntryPoints::getAccessibleTableColumnDescription(jobject acParent, jint column) {
2516 
2517     jobject returnedAccessibleContext;
2518     jobject globalRef;
2519     jthrowable exception;
2520 
2521     PrintDebugString("\r\n##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnDescription(%p):",
2522                      acParent);
2523 
2524     if (getAccessibleTableColumnDescriptionMethod != (jmethodID) 0) {
2525         returnedAccessibleContext = jniEnv->CallObjectMethod(
2526                                                              accessBridgeObject,
2527                                                              getAccessibleTableColumnDescriptionMethod,
2528                                                              acParent, column);
2529         EXCEPTION_CHECK("Getting AccessibleTableColumnDescription - call to CallObjectMethod()", FALSE);
2530         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
2531         EXCEPTION_CHECK("Getting AccessibleTableColumnDescription - call to NewGlobalRef()", FALSE);
2532         jniEnv->DeleteLocalRef(returnedAccessibleContext);
2533         EXCEPTION_CHECK("Getting AccessibleTableColumnDescription - call to DeleteLocalRef()", FALSE);
2534         PrintDebugString("  Returning - returnedAccessibleContext = %p; globalRef = %p",
2535                          returnedAccessibleContext, globalRef);
2536         return globalRef;
2537     } else {
2538         PrintDebugString("  Error! either env == 0 or getAccessibleTableColumnDescriptionMethod == 0");
2539         return (jobject) 0;
2540     }
2541 }
2542 
2543 jint
2544 AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount(jobject accessibleTable) {
2545 
2546     jthrowable exception;
2547     jint count;
2548 
2549     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount(%p)",
2550                      accessibleTable);
2551 
2552     // Get the table row selection count
2553     if (getAccessibleTableRowSelectionCountMethod != (jmethodID) 0) {
2554         count = jniEnv->CallIntMethod(accessBridgeObject,
2555                                       getAccessibleTableRowSelectionCountMethod,
2556                                       accessibleTable);
2557         EXCEPTION_CHECK("##### Getting AccessibleTableRowSelectionCount - call to CallIntMethod()", FALSE);
2558         PrintDebugString("  ##### table row selection count = %d", count);
2559         return count;
2560     } else {
2561         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableRowSelectionCountMethod == 0");
2562         return 0;
2563     }
2564 
2565     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount failed");
2566     return 0;
2567 }
2568 
2569 BOOL
2570 AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected(jobject accessibleTable, jint row) {
2571     jthrowable exception;
2572     BOOL result;
2573 
2574     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected(%p, %d)",
2575                      accessibleTable, row);
2576 
2577     if (isAccessibleTableRowSelectedMethod != (jmethodID) 0) {
2578         result = jniEnv->CallBooleanMethod(accessBridgeObject,
2579                                            isAccessibleTableRowSelectedMethod,
2580                                            accessibleTable, row);
2581         EXCEPTION_CHECK("##### Getting isAccessibleTableRowSelected - call to CallBooleanMethod()", FALSE);
2582         PrintDebugString("  ##### table row isSelected = %d", result);
2583         return result;
2584     } else {
2585         PrintDebugString("  ##### Error! either env == 0 or isAccessibleTableRowSelectedMethod == 0");
2586         return FALSE;
2587     }
2588 
2589     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected failed");
2590     return FALSE;
2591 }
2592 
2593 BOOL
2594 AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections(jobject accessibleTable, jint count,
2595                                                              jint *selections) {
2596 
2597     jthrowable exception;
2598 
2599     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections(%p, %d %p)",
2600                      accessibleTable, count, selections);
2601 
2602     if (getAccessibleTableRowSelectionsMethod == (jmethodID) 0) {
2603         return FALSE;
2604     }
2605     // Get the table row selections
2606     for (int i = 0; i < count; i++) {
2607 
2608         selections[i] = jniEnv->CallIntMethod(accessBridgeObject,
2609                                               getAccessibleTableRowSelectionsMethod,
2610                                               accessibleTable,
2611                                               i);
2612         EXCEPTION_CHECK("##### Getting AccessibleTableRowSelections - call to CallIntMethod()", FALSE);
2613         PrintDebugString("  ##### table row selection[%d] = %d", i, selections[i]);
2614     }
2615 
2616     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections succeeded");
2617     return TRUE;
2618 }
2619 
2620 
2621 jint
2622 AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount(jobject accessibleTable) {
2623 
2624     jthrowable exception;
2625     jint count;
2626 
2627     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount(%p)",
2628                      accessibleTable);
2629 
2630     // Get the table column selection count
2631     if (getAccessibleTableColumnSelectionCountMethod != (jmethodID) 0) {
2632         count = jniEnv->CallIntMethod(accessBridgeObject,
2633                                       getAccessibleTableColumnSelectionCountMethod,
2634                                       accessibleTable);
2635         EXCEPTION_CHECK("##### Getting AccessibleTableColumnSelectionCount - call to CallIntMethod()", FALSE);
2636         PrintDebugString("  ##### table column selection count = %d", count);
2637         return count;
2638     } else {
2639         PrintDebugString("  ##### Error! either env == 0 or getAccessibleRowCountMethod == 0");
2640         return 0;
2641     }
2642 
2643     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount failed");
2644     return 0;
2645 }
2646 
2647 BOOL
2648 AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected(jobject accessibleTable, jint column) {
2649     jthrowable exception;
2650     BOOL result;
2651 
2652     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected(%p, %d)",
2653                      accessibleTable, column);
2654 
2655     if (isAccessibleTableColumnSelectedMethod != (jmethodID) 0) {
2656         result = jniEnv->CallBooleanMethod(accessBridgeObject,
2657                                            isAccessibleTableColumnSelectedMethod,
2658                                            accessibleTable, column);
2659         EXCEPTION_CHECK("##### Getting isAccessibleTableColumnSelected - call to CallBooleanMethod()", FALSE);
2660         PrintDebugString("  ##### table column isSelected = %d", result);
2661         return result;
2662     } else {
2663         PrintDebugString("  ##### Error! either env == 0 or isAccessibleTableColumnSelectedMethod == 0");
2664         return FALSE;
2665     }
2666 
2667     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected failed");
2668     return FALSE;
2669 }
2670 
2671 BOOL
2672 AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections(jobject accessibleTable, jint count,
2673                                                                 jint *selections) {
2674     jthrowable exception;
2675 
2676     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections(%p, %d, %p)",
2677                      accessibleTable, count, selections);
2678 
2679     if (getAccessibleTableColumnSelectionsMethod == (jmethodID) 0) {
2680         return FALSE;
2681     }
2682     // Get the table column selections
2683     for (int i = 0; i < count; i++) {
2684 
2685         selections[i] = jniEnv->CallIntMethod(accessBridgeObject,
2686                                               getAccessibleTableColumnSelectionsMethod,
2687                                               accessibleTable,
2688                                               i);
2689         EXCEPTION_CHECK("##### Getting AccessibleTableColumnSelections - call to CallIntMethod()", FALSE);
2690         PrintDebugString("  ##### table Column selection[%d] = %d", i, selections[i]);
2691     }
2692 
2693     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections succeeded");
2694     return TRUE;
2695 }
2696 
2697 
2698 jint
2699 AccessBridgeJavaEntryPoints::getAccessibleTableRow(jobject accessibleTable, jint index) {
2700     jthrowable exception;
2701     jint result;
2702 
2703     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableRow(%p, index=%d)",
2704                      accessibleTable, index);
2705 
2706     if (getAccessibleTableRowMethod != (jmethodID) 0) {
2707         result = jniEnv->CallIntMethod(accessBridgeObject,
2708                                        getAccessibleTableRowMethod,
2709                                        accessibleTable, index);
2710         EXCEPTION_CHECK("##### Getting AccessibleTableRow - call to CallIntMethod()", FALSE);
2711         PrintDebugString("  ##### table row = %d", result);
2712         return result;
2713     } else {
2714         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableRowMethod == 0");
2715         return -1;
2716     }
2717 
2718     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::getAccessibleTableRow failed");
2719     return -1;
2720 }
2721 
2722 jint
2723 AccessBridgeJavaEntryPoints::getAccessibleTableColumn(jobject accessibleTable, jint index) {
2724     jthrowable exception;
2725     jint result;
2726 
2727     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableColumn(%p, index=%d)",
2728                      accessibleTable, index);
2729 
2730     if (getAccessibleTableColumnMethod != (jmethodID) 0) {
2731         result = jniEnv->CallIntMethod(accessBridgeObject,
2732                                        getAccessibleTableColumnMethod,
2733                                        accessibleTable, index);
2734         EXCEPTION_CHECK("##### Getting AccessibleTableColumn - call to CallIntMethod()", FALSE);
2735         PrintDebugString("  ##### table column = %d", result);
2736         return result;
2737     } else {
2738         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableColumnMethod == 0");
2739         return -1;
2740     }
2741 
2742     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumn failed");
2743     return -1;
2744 }
2745 
2746 jint
2747 AccessBridgeJavaEntryPoints::getAccessibleTableIndex(jobject accessibleTable, jint row, jint column) {
2748     jthrowable exception;
2749     jint result;
2750 
2751     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleTableIndex(%p, row=%d, col=%d)",
2752                      accessibleTable, row, column);
2753 
2754     if (getAccessibleTableIndexMethod != (jmethodID) 0) {
2755         result = jniEnv->CallIntMethod(accessBridgeObject,
2756                                        getAccessibleTableIndexMethod,
2757                                        accessibleTable, row, column);
2758         EXCEPTION_CHECK("##### Getting getAccessibleTableIndex - call to CallIntMethod()", FALSE);
2759         PrintDebugString("  ##### table index = %d", result);
2760         return result;
2761     } else {
2762         PrintDebugString("  ##### Error! either env == 0 or getAccessibleTableIndexMethod == 0");
2763         return -1;
2764     }
2765 
2766     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::getAccessibleTableIndex failed");
2767     return -1;
2768 }
2769 
2770 /********** end AccessibleTable routines ******************************/
2771 
2772 
2773 /********** begin AccessibleRelationSet routines **********************/
2774 
2775 BOOL
2776 AccessBridgeJavaEntryPoints::getAccessibleRelationSet(jobject accessibleContext,
2777                                                       AccessibleRelationSetInfo *relationSet) {
2778 
2779     jthrowable exception;
2780     const wchar_t *stringBytes;
2781     jsize length;
2782 
2783     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleRelationSet(%p, %p)",
2784                      accessibleContext, relationSet);
2785 
2786     if (getAccessibleRelationCountMethod == (jmethodID) 0 ||
2787         getAccessibleRelationKeyMethod == (jmethodID) 0 ||
2788         getAccessibleRelationTargetCountMethod == (jmethodID) 0 ||
2789         getAccessibleRelationTargetMethod == (jmethodID) 0) {
2790         return FALSE;
2791     }
2792 
2793     // Get the relations set count
2794     relationSet->relationCount = jniEnv->CallIntMethod(accessBridgeObject,
2795                                                        getAccessibleRelationCountMethod,
2796                                                        accessibleContext);
2797     EXCEPTION_CHECK("##### Getting AccessibleRelationCount - call to CallIntMethod()", FALSE);
2798     PrintDebugString("  ##### AccessibleRelation count = %d", relationSet->relationCount);
2799 
2800 
2801     // Get the relation set
2802     for (int i = 0; i < relationSet->relationCount && i < MAX_RELATIONS; i++) {
2803 
2804         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
2805                                                        getAccessibleRelationKeyMethod,
2806                                                        accessibleContext,
2807                                                        i);
2808 
2809         EXCEPTION_CHECK("Getting AccessibleRelationKey - call to CallObjectMethod()", FALSE);
2810         if (js != (jstring) 0) {
2811             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
2812             EXCEPTION_CHECK("Getting AccessibleRelation key - call to GetStringChars()", FALSE);
2813             wcsncpy(relationSet->relations[i].key, stringBytes, (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t)));
2814             length = jniEnv->GetStringLength(js);
2815             relationSet->relations[i].key [length < (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t)) ?
2816                                            length : (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t))-2] = (wchar_t) 0;
2817             EXCEPTION_CHECK("Getting AccessibleRelation key - call to GetStringLength()", FALSE);
2818             jniEnv->ReleaseStringChars(js, stringBytes);
2819             EXCEPTION_CHECK("Getting AccessibleRelation key - call to ReleaseStringChars()", FALSE);
2820             // jniEnv->CallVoidMethod(accessBridgeObject,
2821             //                        decrementReferenceMethod, js);
2822             //EXCEPTION_CHECK("Getting AccessibleRelation key - call to CallVoidMethod()", FALSE);
2823             PrintDebugString("##### AccessibleRelation key = %ls", relationSet->relations[i].key );
2824             jniEnv->DeleteLocalRef(js);
2825             EXCEPTION_CHECK("Getting AccessibleRelation key - call to DeleteLocalRef()", FALSE);
2826         } else {
2827             PrintDebugString("  AccessibleRelation key is null.");
2828             relationSet->relations[i].key [0] = (wchar_t) 0;
2829         }
2830 
2831         relationSet->relations[i].targetCount = jniEnv->CallIntMethod(accessBridgeObject,
2832                                                                       getAccessibleRelationTargetCountMethod,
2833                                                                       accessibleContext,
2834                                                                       i);
2835 
2836         for (int j = 0; j < relationSet->relations[i].targetCount && j < MAX_RELATION_TARGETS; j++) {
2837             jobject target = jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleRelationTargetMethod,
2838                                                       accessibleContext, i, j);
2839             EXCEPTION_CHECK("Getting AccessibleRelationSet - call to CallObjectMethod()", FALSE);
2840             jobject globalRef = jniEnv->NewGlobalRef(target);
2841             EXCEPTION_CHECK("Getting AccessibleRelationSet - call to NewGlobalRef()", FALSE);
2842             relationSet->relations[i].targets[j] = (JOBJECT64)globalRef;
2843             PrintDebugString("  relation set item: %p", globalRef);
2844         }
2845     }
2846 
2847     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::getAccessibleRelationSet succeeded");
2848     return TRUE;
2849 }
2850 
2851 
2852 /********** end AccessibleRelationSet routines ************************/
2853 
2854 
2855 /********** begin AccessibleHypertext routines **********************/
2856 
2857 BOOL
2858 AccessBridgeJavaEntryPoints::getAccessibleHypertext(jobject accessibleContext,
2859                                                     AccessibleHypertextInfo *hypertext) {
2860 
2861     jthrowable exception;
2862     const wchar_t *stringBytes;
2863     jsize length;
2864 
2865     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleHypertext(%p, %p)",
2866                      accessibleContext, hypertext);
2867 
2868     // get the AccessibleHypertext
2869     jobject ht = jniEnv->CallObjectMethod(accessBridgeObject,
2870                                           getAccessibleHypertextMethod,
2871                                           accessibleContext);
2872     EXCEPTION_CHECK("##### Getting AccessibleHypertext - call to CallObjectMethod()", FALSE);
2873     jobject globalRef = jniEnv->NewGlobalRef(ht);
2874     EXCEPTION_CHECK("##### Getting AccessibleHypertext - call to NewGlobalRef()", FALSE);
2875     hypertext->accessibleHypertext = (JOBJECT64)globalRef;
2876     PrintDebugString("  ##### AccessibleHypertext = %p", globalRef);
2877 
2878     if (hypertext->accessibleHypertext == 0) {
2879         PrintDebugString("  ##### null AccessibleHypertext; returning FALSE");
2880         return false;
2881     }
2882 
2883     // get the hyperlink count
2884     hypertext->linkCount = jniEnv->CallIntMethod(accessBridgeObject,
2885                                                  getAccessibleHyperlinkCountMethod,accessibleContext);
2886 
2887     EXCEPTION_CHECK("##### Getting hyperlink count - call to CallIntMethod()", FALSE);
2888     PrintDebugString("  ##### hyperlink count = %d", hypertext->linkCount);
2889 
2890 
2891     // get the hypertext links
2892     for (int i = 0; i < hypertext->linkCount && i < MAX_HYPERLINKS; i++) {
2893 
2894         // get the hyperlink
2895         jobject hl = jniEnv->CallObjectMethod(accessBridgeObject,
2896                                               getAccessibleHyperlinkMethod,
2897                                               accessibleContext,
2898                                               i);
2899         EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to CallObjectMethod()", FALSE);
2900         jobject globalRef = jniEnv->NewGlobalRef(hl);
2901         EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to NewGlobalRef()", FALSE);
2902         hypertext->links[i].accessibleHyperlink = (JOBJECT64)globalRef;
2903         PrintDebugString("  ##### AccessibleHyperlink = %p", globalRef);
2904 
2905         // get the hyperlink text
2906         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
2907                                                        getAccessibleHyperlinkTextMethod,
2908                                                        hypertext->links[i].accessibleHyperlink,
2909                                                        i);
2910 
2911         EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
2912         if (js != (jstring) 0) {
2913             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
2914             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
2915             wcsncpy(hypertext->links[i].text, stringBytes, (sizeof(hypertext->links[i].text) / sizeof(wchar_t)));
2916             length = jniEnv->GetStringLength(js);
2917             if (length >= (sizeof(hypertext->links[i].text) / sizeof(wchar_t))) {
2918                 length = (sizeof(hypertext->links[i].text) / sizeof(wchar_t)) - 2;
2919             }
2920             hypertext->links[i].text[length] = (wchar_t) 0;
2921             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringLength()", FALSE);
2922             jniEnv->ReleaseStringChars(js, stringBytes);
2923             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to ReleaseStringChars()", FALSE);
2924             // jniEnv->CallVoidMethod(accessBridgeObject,
2925             //                                     decrementReferenceMethod, js);
2926             //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
2927             PrintDebugString("##### AccessibleHyperlink text = %ls", hypertext->links[i].text );
2928             jniEnv->DeleteLocalRef(js);
2929             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
2930         } else {
2931             PrintDebugString("  AccessibleHyperlink text is null.");
2932             hypertext->links[i].text[0] = (wchar_t) 0;
2933         }
2934 
2935         hypertext->links[i].startIndex = jniEnv->CallIntMethod(accessBridgeObject,
2936                                                                getAccessibleHyperlinkStartIndexMethod,
2937                                                                hypertext->links[i].accessibleHyperlink,
2938                                                                i);
2939         EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
2940         PrintDebugString("  ##### hyperlink start index = %d", hypertext->links[i].startIndex);
2941 
2942 
2943         hypertext->links[i].endIndex = jniEnv->CallIntMethod(accessBridgeObject,
2944                                                              getAccessibleHyperlinkEndIndexMethod,
2945                                                              hypertext->links[i].accessibleHyperlink,
2946                                                              i);
2947         EXCEPTION_CHECK("##### Getting hyperlink end index - call to CallIntMethod()", FALSE);
2948         PrintDebugString("  ##### hyperlink end index = %d", hypertext->links[i].endIndex);
2949 
2950     }
2951 
2952     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::getAccessibleHypertext succeeded");
2953     return TRUE;
2954 }
2955 
2956 /*
2957  * Activates an AccessibleHyperlink
2958  */
2959 BOOL
2960 AccessBridgeJavaEntryPoints::activateAccessibleHyperlink(jobject accessibleContext,
2961                                                          jobject accessibleHyperlink) {
2962 
2963     jthrowable exception;
2964     BOOL returnVal;
2965 
2966     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::activateAccessibleHyperlink(%p, %p):",
2967                      accessibleContext, accessibleHyperlink);
2968 
2969     if (activateAccessibleHyperlinkMethod != (jmethodID) 0) {
2970         returnVal = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject, activateAccessibleHyperlinkMethod,
2971                                                      accessibleContext, accessibleHyperlink);
2972         EXCEPTION_CHECK("activateAccessibleHyperlink - call to CallBooleanMethod()", FALSE);
2973         return returnVal;
2974     } else {
2975         PrintDebugString("\r\n  Error! either jniEnv == 0 or activateAccessibleHyperlinkMethod == 0");
2976         return FALSE;
2977     }
2978 }
2979 
2980 
2981 /*
2982  * This method is used to iterate through the hyperlinks in a component.  It
2983  * returns hypertext information for a component starting at hyperlink index
2984  * nStartIndex.  No more than MAX_HYPERLINKS AccessibleHypertextInfo objects will
2985  * be returned for each call to this method.
2986  * returns FALSE on error.
2987  */
2988 BOOL
2989 AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(const jobject accessibleContext,
2990                                                        const jint nStartIndex,
2991                                                        /* OUT */ AccessibleHypertextInfo *hypertext) {
2992 
2993     jthrowable exception;
2994     const wchar_t *stringBytes;
2995     jsize length;
2996     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(%p, %p, startIndex = %d)",
2997                      accessibleContext, hypertext, nStartIndex);
2998 
2999     // get the AccessibleHypertext
3000     jobject ht = jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleHypertextMethod,
3001                                                               accessibleContext);
3002     EXCEPTION_CHECK("##### Getting AccessibleHypertext - call to CallObjectMethod()", FALSE);
3003     jobject globalRef = jniEnv->NewGlobalRef(ht);
3004     EXCEPTION_CHECK("##### Getting AccessibleHypertext - call to NewGlobalRef()", FALSE);
3005     hypertext->accessibleHypertext = (JOBJECT64)globalRef;
3006     PrintDebugString("  ##### AccessibleHypertext = %p", globalRef);
3007     if (hypertext->accessibleHypertext == 0) {
3008         PrintDebugString("  ##### null AccessibleHypertext; returning FALSE");
3009         return FALSE;
3010     }
3011 
3012     // get the hyperlink count
3013     hypertext->linkCount = jniEnv->CallIntMethod(accessBridgeObject, getAccessibleHyperlinkCountMethod,
3014                                                  accessibleContext);
3015     EXCEPTION_CHECK("##### Getting hyperlink count - call to CallIntMethod()", FALSE);
3016     PrintDebugString("  ##### hyperlink count = %d", hypertext->linkCount);
3017 
3018     if (nStartIndex >= hypertext->linkCount) {
3019         return FALSE;
3020     }
3021 
3022     // get the hypertext links
3023     // NOTE: To avoid a crash when there are more than MAX_HYPERLINKS (64) links
3024     // in the document, test for i < MAX_HYPERLINKS in addition to
3025     // i < hypertext->linkCount
3026     int bufIndex = 0;
3027     for (int i = nStartIndex; (i < hypertext->linkCount) && (i < nStartIndex + MAX_HYPERLINKS); i++) {
3028         PrintDebugString("  getting hyperlink %d ...", i);
3029 
3030         // get the hyperlink
3031         jobject hl = jniEnv->CallObjectMethod(accessBridgeObject,
3032                                               getAccessibleHyperlinkMethod,
3033                                               hypertext->accessibleHypertext,
3034                                               i);
3035         EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to CallObjectMethod()", FALSE);
3036         jobject globalRef = jniEnv->NewGlobalRef(hl);
3037         EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to NewGlobalRef()", FALSE);
3038         hypertext->links[bufIndex].accessibleHyperlink = (JOBJECT64)globalRef;
3039         PrintDebugString("  ##### AccessibleHyperlink = %p", globalRef);
3040 
3041         // get the hyperlink text
3042         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3043                                                        getAccessibleHyperlinkTextMethod,
3044                                                        hypertext->links[bufIndex].accessibleHyperlink,
3045                                                        i);
3046 
3047         EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
3048         if (js != (jstring) 0) {
3049             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3050             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
3051             wcsncpy(hypertext->links[bufIndex].text, stringBytes,
3052                     (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t)));
3053             length = jniEnv->GetStringLength(js);
3054             if (length >= (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t))) {
3055                 length = (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t)) - 2;
3056             }
3057             hypertext->links[bufIndex].text[length] = (wchar_t) 0;
3058             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringLength()", FALSE);
3059             jniEnv->ReleaseStringChars(js, stringBytes);
3060             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to ReleaseStringChars()", FALSE);
3061             // jniEnv->CallVoidMethod(accessBridgeObject,
3062             //                        decrementReferenceMethod, js);
3063             //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
3064             PrintDebugString("##### AccessibleHyperlink text = %ls", hypertext->links[bufIndex].text );
3065             jniEnv->DeleteLocalRef(js);
3066             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
3067 
3068         } else {
3069             PrintDebugString("  AccessibleHyperlink text is null.");
3070             hypertext->links[bufIndex].text[0] = (wchar_t) 0;
3071         }
3072 
3073         hypertext->links[bufIndex].startIndex = jniEnv->CallIntMethod(accessBridgeObject,
3074                                                                       getAccessibleHyperlinkStartIndexMethod,
3075                                                                       hypertext->links[bufIndex].accessibleHyperlink,
3076                                                                       i);
3077         EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
3078         PrintDebugString("  ##### hyperlink start index = %d", hypertext->links[bufIndex].startIndex);
3079 
3080         hypertext->links[bufIndex].endIndex = jniEnv->CallIntMethod(accessBridgeObject,
3081                                                                     getAccessibleHyperlinkEndIndexMethod,
3082                                                                     hypertext->links[bufIndex].accessibleHyperlink,
3083                                                                     i);
3084         EXCEPTION_CHECK("##### Getting hyperlink end index - call to CallIntMethod()", FALSE);
3085         PrintDebugString("  ##### hyperlink end index = %d", hypertext->links[bufIndex].endIndex);
3086 
3087         bufIndex++;
3088     }
3089 
3090     PrintDebugString("  ##### AccessBridgeJavaEntryPoints::getAccessibleHypertextExt succeeded");
3091     return TRUE;
3092 }
3093 
3094 jint AccessBridgeJavaEntryPoints::getAccessibleHyperlinkCount(const jobject accessibleContext) {
3095 
3096     jthrowable exception;
3097 
3098     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleHyperlinkCount(%X)",
3099                      accessibleContext);
3100 
3101     if (getAccessibleHyperlinkCountMethod == (jmethodID)0) {
3102         return -1;
3103     }
3104 
3105     // get the hyperlink count
3106     jint linkCount = jniEnv->CallIntMethod(accessBridgeObject, getAccessibleHyperlinkCountMethod,
3107                                            accessibleContext);
3108     EXCEPTION_CHECK("##### Getting hyperlink count - call to CallIntMethod()", -1);
3109     PrintDebugString("  ##### hyperlink count = %d", linkCount);
3110 
3111     return linkCount;
3112 }
3113 
3114 
3115 jint AccessBridgeJavaEntryPoints::getAccessibleHypertextLinkIndex(const jobject hypertext,
3116                                                                   const jint nIndex) {
3117 
3118     jthrowable exception;
3119 
3120     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleHypertextLinkIndex(%p, index = %d)",
3121                      hypertext, nIndex);
3122 
3123     if (getAccessibleHypertextLinkIndexMethod == (jmethodID)0) {
3124         return -1;
3125     }
3126 
3127     // get the hyperlink index
3128     jint index = jniEnv->CallIntMethod(accessBridgeObject, getAccessibleHypertextLinkIndexMethod,
3129                                        hypertext, nIndex);
3130 
3131     EXCEPTION_CHECK("##### Getting hyperlink index - call to CallIntMethod()", -1);
3132     PrintDebugString("  ##### hyperlink index = %d", index);
3133 
3134     return index;
3135 }
3136 
3137 BOOL AccessBridgeJavaEntryPoints::getAccessibleHyperlink(jobject hypertext,
3138                                                          const jint index,
3139                                                          /* OUT */ AccessibleHyperlinkInfo *info) {
3140 
3141     jthrowable exception;
3142     const wchar_t *stringBytes;
3143     jsize length;
3144 
3145     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleHyperlink(%p, index = %d)",
3146                      hypertext, index);
3147 
3148 
3149     // get the hyperlink
3150     jobject hl = jniEnv->CallObjectMethod(accessBridgeObject,
3151                                           getAccessibleHyperlinkMethod,
3152                                           hypertext,
3153                                           index);
3154     EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to CallObjectMethod()", FALSE);
3155     jobject globalRef = jniEnv->NewGlobalRef(hl);
3156     EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to NewGlobalRef()", FALSE);
3157     info->accessibleHyperlink = (JOBJECT64)globalRef;
3158     PrintDebugString("  ##### AccessibleHyperlink = %p", globalRef);
3159 
3160     // get the hyperlink text
3161     jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3162                                                    getAccessibleHyperlinkTextMethod,
3163                                                    info->accessibleHyperlink,
3164                                                    index);
3165 
3166     EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
3167     if (js != (jstring) 0) {
3168         stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3169         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
3170         wcsncpy(info->text, stringBytes,
3171                 (sizeof(info->text) / sizeof(wchar_t)));
3172         length = jniEnv->GetStringLength(js);
3173         if (length >= (sizeof(info->text) / sizeof(wchar_t))) {
3174             length = (sizeof(info->text) / sizeof(wchar_t)) - 2;
3175         }
3176         info->text[length] = (wchar_t) 0;
3177         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringLength()", FALSE);
3178         jniEnv->ReleaseStringChars(js, stringBytes);
3179         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to ReleaseStringChars()", FALSE);
3180         // jniEnv->CallVoidMethod(accessBridgeObject,
3181         //                        decrementReferenceMethod, js);
3182         //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
3183         PrintDebugString("##### AccessibleHyperlink text = %ls", info->text );
3184         jniEnv->DeleteLocalRef(js);
3185         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
3186 
3187     } else {
3188         PrintDebugString("  AccessibleHyperlink text is null.");
3189         info->text[0] = (wchar_t) 0;
3190     }
3191 
3192     info->startIndex = jniEnv->CallIntMethod(accessBridgeObject,
3193                                              getAccessibleHyperlinkStartIndexMethod,
3194                                              info->accessibleHyperlink,
3195                                              index);
3196     EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
3197     PrintDebugString("  ##### hyperlink start index = %d", info->startIndex);
3198 
3199     info->endIndex = jniEnv->CallIntMethod(accessBridgeObject,
3200                                            getAccessibleHyperlinkEndIndexMethod,
3201                                            info->accessibleHyperlink,
3202                                            index);
3203     EXCEPTION_CHECK("##### Getting hyperlink end index - call to CallIntMethod()", FALSE);
3204     PrintDebugString("  ##### hyperlink end index = %d", info->endIndex);
3205 
3206     return TRUE;
3207 }
3208 
3209 
3210 /********** end AccessibleHypertext routines ************************/
3211 
3212 // Accessible Keybinding methods
3213 BOOL AccessBridgeJavaEntryPoints::getAccessibleKeyBindings(jobject accessibleContext,
3214                                                            AccessibleKeyBindings *keyBindings) {
3215 
3216     jthrowable exception;
3217 
3218     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleKeyBindings(%p, %p)",
3219                      accessibleContext, keyBindings);
3220 
3221     if (getAccessibleKeyBindingsCountMethod == (jmethodID) 0 ||
3222         getAccessibleKeyBindingCharMethod == (jmethodID) 0 ||
3223         getAccessibleKeyBindingModifiersMethod == (jmethodID) 0) {
3224         return FALSE;
3225     }
3226 
3227     // get the key binding count
3228     keyBindings->keyBindingsCount = jniEnv->CallIntMethod(accessBridgeObject,
3229                                                           getAccessibleKeyBindingsCountMethod, accessibleContext);
3230 
3231     EXCEPTION_CHECK("##### Getting key bindings count - call to CallIntMethod()", FALSE);
3232 
3233     PrintDebugString("  ##### key bindings count = %d", keyBindings->keyBindingsCount);
3234 
3235     // get the key bindings
3236     for (int i = 0; i < keyBindings->keyBindingsCount && i < MAX_KEY_BINDINGS; i++) {
3237 
3238         // get the key binding character
3239         keyBindings->keyBindingInfo[i].character = jniEnv->CallCharMethod(accessBridgeObject,
3240                                                                           getAccessibleKeyBindingCharMethod,
3241                                                                           accessibleContext,
3242                                                                           i);
3243         EXCEPTION_CHECK("##### Getting key binding character - call to CallCharMethod()", FALSE);
3244         PrintDebugString("  ##### key binding character = %c", keyBindings->keyBindingInfo[i].character);
3245         PrintDebugString("  ##### key binding character in hex = %hx", keyBindings->keyBindingInfo[i].character);
3246 
3247         // get the key binding modifiers
3248         keyBindings->keyBindingInfo[i].modifiers = jniEnv->CallIntMethod(accessBridgeObject,
3249                                                                          getAccessibleKeyBindingModifiersMethod,
3250                                                                          accessibleContext,
3251                                                                          i);
3252         EXCEPTION_CHECK("##### Getting key binding modifiers - call to CallIntMethod()", FALSE);
3253         PrintDebugString("  ##### key binding modifiers = %x", keyBindings->keyBindingInfo[i].modifiers);
3254     }
3255     return FALSE;
3256 }
3257 
3258 // AccessibleIcon methods
3259 BOOL AccessBridgeJavaEntryPoints::getAccessibleIcons(jobject accessibleContext,
3260                                                      AccessibleIcons *icons) {
3261 
3262     jthrowable exception;
3263     const wchar_t *stringBytes;
3264     jsize length;
3265 
3266     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleIcons(%p, %p)",
3267                      accessibleContext, icons);
3268 
3269     if (getAccessibleIconsCountMethod == (jmethodID) 0 ||
3270         getAccessibleIconDescriptionMethod == (jmethodID) 0 ||
3271         getAccessibleIconHeightMethod == (jmethodID) 0 ||
3272         getAccessibleIconWidthMethod == (jmethodID) 0) {
3273         PrintDebugString("  ##### missing method(s) !!!");
3274         return FALSE;
3275     }
3276 
3277 
3278     // get the icons count
3279     icons->iconsCount = jniEnv->CallIntMethod(accessBridgeObject,
3280                                               getAccessibleIconsCountMethod, accessibleContext);
3281 
3282     EXCEPTION_CHECK("##### Getting icons count - call to CallIntMethod()", FALSE);
3283     PrintDebugString("  ##### icons count = %d", icons->iconsCount);
3284 
3285 
3286     // get the icons
3287     for (int i = 0; i < icons->iconsCount && i < MAX_ICON_INFO; i++) {
3288 
3289         // get the icon description
3290         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3291                                                        getAccessibleIconDescriptionMethod,
3292                                                        accessibleContext,
3293                                                        i);
3294 
3295         EXCEPTION_CHECK("Getting icon description - call to CallObjectMethod()", FALSE);
3296         if (js != (jstring) 0) {
3297             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3298             EXCEPTION_CHECK("Getting AccessibleIcon description - call to GetStringChars()", FALSE);
3299             wcsncpy(icons->iconInfo[i].description, stringBytes, (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t)));
3300             length = jniEnv->GetStringLength(js);
3301             if (length >= (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t))) {
3302                 length = (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t)) - 2;
3303             }
3304             icons->iconInfo[i].description[length] = (wchar_t) 0;
3305             EXCEPTION_CHECK("Getting AccessibleIcon description - call to GetStringLength()", FALSE);
3306             jniEnv->ReleaseStringChars(js, stringBytes);
3307             EXCEPTION_CHECK("Getting AccessibleIcon description - call to ReleaseStringChars()", FALSE);
3308             // jniEnv->CallVoidMethod(accessBridgeObject,
3309             //                        decrementReferenceMethod, js);
3310             //EXCEPTION_CHECK("Getting AccessibleIcon description - call to CallVoidMethod()", FALSE);
3311             PrintDebugString("##### AccessibleIcon description = %ls", icons->iconInfo[i].description );
3312             jniEnv->DeleteLocalRef(js);
3313             EXCEPTION_CHECK("Getting AccessibleIcon description - call to DeleteLocalRef()", FALSE);
3314         } else {
3315             PrintDebugString("  AccessibleIcon description is null.");
3316             icons->iconInfo[i].description[0] = (wchar_t) 0;
3317         }
3318 
3319 
3320         // get the icon height
3321         icons->iconInfo[i].height = jniEnv->CallIntMethod(accessBridgeObject,
3322                                                           getAccessibleIconHeightMethod,
3323                                                           accessibleContext,
3324                                                           i);
3325         EXCEPTION_CHECK("##### Getting icon height - call to CallIntMethod()", FALSE);
3326         PrintDebugString("  ##### icon height = %d", icons->iconInfo[i].height);
3327 
3328         // get the icon width
3329         icons->iconInfo[i].width = jniEnv->CallIntMethod(accessBridgeObject,
3330                                                          getAccessibleIconWidthMethod,
3331                                                          accessibleContext,
3332                                                          i);
3333         EXCEPTION_CHECK("##### Getting icon width - call to CallIntMethod()", FALSE);
3334         PrintDebugString("  ##### icon width = %d", icons->iconInfo[i].width);
3335     }
3336     return FALSE;
3337 }
3338 
3339 // AccessibleActionMethods
3340 BOOL AccessBridgeJavaEntryPoints::getAccessibleActions(jobject accessibleContext,
3341                                                        AccessibleActions *actions) {
3342 
3343     jthrowable exception;
3344     const wchar_t *stringBytes;
3345     jsize length;
3346 
3347     PrintDebugString("\r\n##### AccessBridgeJavaEntryPoints::getAccessibleIcons(%p, %p)",
3348                      accessibleContext, actions);
3349 
3350     if (getAccessibleActionsCountMethod == (jmethodID) 0 ||
3351         getAccessibleActionNameMethod == (jmethodID) 0) {
3352         PrintDebugString("  ##### missing method(s) !!!");
3353         return FALSE;
3354     }
3355 
3356 
3357     // get the icons count
3358     actions->actionsCount = jniEnv->CallIntMethod(accessBridgeObject,
3359                                                   getAccessibleActionsCountMethod,accessibleContext);
3360 
3361     EXCEPTION_CHECK("##### Getting actions count - call to CallIntMethod()", FALSE);
3362     PrintDebugString("  ##### key actions count = %d", actions->actionsCount);
3363 
3364 
3365     // get the actions
3366     for (int i = 0; i < actions->actionsCount && i < MAX_ACTION_INFO; i++) {
3367 
3368         // get the action name
3369         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3370                                                        getAccessibleActionNameMethod,
3371                                                        accessibleContext,
3372                                                        i);
3373 
3374         EXCEPTION_CHECK("Getting Action Name  - call to CallObjectMethod()", FALSE);
3375         if (js != (jstring) 0) {
3376             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3377             EXCEPTION_CHECK("Getting AccessibleAction Name  - call to GetStringChars()", FALSE);
3378             wcsncpy(actions->actionInfo[i].name , stringBytes, (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t)));
3379             length = jniEnv->GetStringLength(js);
3380             if (length >= (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t))) {
3381                 length = (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t)) - 2;
3382             }
3383             actions->actionInfo[i].name [length] = (wchar_t) 0;
3384             EXCEPTION_CHECK("Getting AccessibleAction name  - call to GetStringLength()", FALSE);
3385             jniEnv->ReleaseStringChars(js, stringBytes);
3386             EXCEPTION_CHECK("Getting AccessibleAction name  - call to ReleaseStringChars()", FALSE);
3387             // jniEnv->CallVoidMethod(accessBridgeObject,
3388             //                        decrementReferenceMethod, js);
3389             //EXCEPTION_CHECK("Getting AccessibleAction name  - call to CallVoidMethod()", FALSE);
3390             PrintDebugString("##### AccessibleAction name  = %ls", actions->actionInfo[i].name  );
3391             jniEnv->DeleteLocalRef(js);
3392             EXCEPTION_CHECK("Getting AccessibleAction name  - call to DeleteLocalRef()", FALSE);
3393         } else {
3394             PrintDebugString("  AccessibleAction name  is null.");
3395             actions->actionInfo[i].name [0] = (wchar_t) 0;
3396         }
3397     }
3398     return FALSE;
3399 }
3400 
3401 BOOL AccessBridgeJavaEntryPoints::doAccessibleActions(jobject accessibleContext,
3402                                                       AccessibleActionsToDo *actionsToDo,
3403                                                       jint *failure) {
3404 
3405     jthrowable exception;
3406     BOOL returnVal;
3407 
3408     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::doAccessibleActions(%p, #actions %d %s):",
3409                      accessibleContext,
3410                      actionsToDo->actionsCount,
3411                      actionsToDo->actions[0].name);
3412 
3413     if (doAccessibleActionsMethod == (jmethodID) 0) {
3414         *failure = 0;
3415         return FALSE;
3416     }
3417 
3418     PrintDebugString("\r\n    doing %d actions ...", actionsToDo->actionsCount);
3419     for (int i = 0; i < actionsToDo->actionsCount && i < MAX_ACTIONS_TO_DO; i++) {
3420         PrintDebugString("\r    doing action %d: %s ...", i, actionsToDo->actions[i].name);
3421 
3422         // create a Java String for the action name
3423         wchar_t *actionName = (wchar_t *)actionsToDo->actions[i].name;
3424         jstring javaName = jniEnv->NewString(actionName, (jsize)wcslen(actionName));
3425         if (javaName == 0) {
3426             PrintDebugString("\r    NewString failed");
3427             *failure = i;
3428             return FALSE;
3429         }
3430 
3431         returnVal = (BOOL)jniEnv->CallBooleanMethod(accessBridgeObject, doAccessibleActionsMethod,
3432                                                     accessibleContext, javaName);
3433         jniEnv->DeleteLocalRef(javaName);
3434         EXCEPTION_CHECK("doAccessibleActions - call to CallBooleanMethod()", FALSE);
3435 
3436         if (returnVal != TRUE) {
3437             PrintDebugString("\r    Action %d failed", i);
3438             *failure = i;
3439             return FALSE;
3440         }
3441     }
3442     *failure = -1;
3443     return TRUE;
3444 }
3445 
3446 
3447 /********** AccessibleText routines ***********************************/
3448 
3449 BOOL
3450 AccessBridgeJavaEntryPoints::getAccessibleTextInfo(jobject accessibleContext,
3451                                                    AccessibleTextInfo *textInfo,
3452                                                    jint x, jint y) {
3453     jthrowable exception;
3454 
3455     // Verify the Java VM still exists and AccessibleContext is
3456     // an instance of AccessibleText
3457     if (verifyAccessibleText(accessibleContext) == FALSE) {
3458         return FALSE;
3459     }
3460 
3461     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextInfo(%p, %d, %d):",
3462                      accessibleContext, x, y);
3463 
3464     // Get the character count
3465     if (getAccessibleCharCountFromContextMethod != (jmethodID) 0) {
3466         textInfo->charCount = jniEnv->CallIntMethod(accessBridgeObject,
3467                                                     getAccessibleCharCountFromContextMethod,
3468                                                     accessibleContext);
3469         EXCEPTION_CHECK("Getting AccessibleCharCount - call to CallIntMethod()", FALSE);
3470         PrintDebugString("  Char count = %d", textInfo->charCount);
3471     } else {
3472         PrintDebugString("  Error! either env == 0 or getAccessibleCharCountFromContextMethod == 0");
3473         return FALSE;
3474     }
3475 
3476     // Get the index of the caret
3477     if (getAccessibleCaretPositionFromContextMethod != (jmethodID) 0) {
3478         textInfo->caretIndex = jniEnv->CallIntMethod(accessBridgeObject,
3479                                                      getAccessibleCaretPositionFromContextMethod,
3480                                                      accessibleContext);
3481         EXCEPTION_CHECK("Getting AccessibleCaretPosition - call to CallIntMethod()", FALSE);
3482         PrintDebugString("  Index at caret = %d", textInfo->caretIndex);
3483     } else {
3484         PrintDebugString("  Error! either env == 0 or getAccessibleCaretPositionFromContextMethod == 0");
3485         return FALSE;
3486     }
3487 
3488     // Get the index at the given point
3489     if (getAccessibleIndexAtPointFromContextMethod != (jmethodID) 0) {
3490         textInfo->indexAtPoint = jniEnv->CallIntMethod(accessBridgeObject,
3491                                                        getAccessibleIndexAtPointFromContextMethod,
3492                                                        accessibleContext, x, y);
3493         EXCEPTION_CHECK("Getting AccessibleIndexAtPoint - call to CallIntMethod()", FALSE);
3494         PrintDebugString("  Index at point = %d", textInfo->indexAtPoint);
3495     } else {
3496         PrintDebugString("  Error! either env == 0 or getAccessibleIndexAtPointFromContextMethod == 0");
3497         return FALSE;
3498     }
3499     return TRUE;
3500 }
3501 
3502 BOOL
3503 AccessBridgeJavaEntryPoints::getAccessibleTextItems(jobject accessibleContext,
3504                                                     AccessibleTextItemsInfo *textItems, jint index) {
3505     jstring js;
3506     const wchar_t *stringBytes;
3507     jthrowable exception;
3508     jsize length;
3509 
3510     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextItems(%p):", accessibleContext);
3511 
3512     // Verify the Java VM still exists and AccessibleContext is
3513     // an instance of AccessibleText
3514     if (verifyAccessibleText(accessibleContext) == FALSE) {
3515         return FALSE;
3516     }
3517 
3518     // Get the letter at index
3519     if (getAccessibleLetterAtIndexFromContextMethod != (jmethodID) 0) {
3520         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3521                                                 getAccessibleLetterAtIndexFromContextMethod,
3522                                                 accessibleContext, index);
3523         EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to CallIntMethod()", FALSE);
3524         PrintDebugString("  returned from CallObjectMethod(), js = %p", js);
3525         if (js != (jstring) 0) {
3526             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3527             EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to GetStringChars()", FALSE);
3528             textItems->letter = stringBytes[0];
3529             jniEnv->ReleaseStringChars(js, stringBytes);
3530             EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to ReleaseStringChars()", FALSE);
3531             jniEnv->CallVoidMethod(accessBridgeObject,
3532                                    decrementReferenceMethod, js);
3533             EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to CallVoidMethod()", FALSE);
3534             PrintDebugString("  Accessible Text letter = %c", textItems->letter);
3535             jniEnv->DeleteLocalRef(js);
3536             EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to DeleteLocalRef()", FALSE);
3537         } else {
3538             PrintDebugString("  Accessible Text letter is null.");
3539             textItems->letter = (wchar_t) 0;
3540         }
3541     } else {
3542         PrintDebugString("  Error! either env == 0 or getAccessibleLetterAtIndexFromContextMethod == 0");
3543         return FALSE;
3544     }
3545 
3546 
3547     // Get the word at index
3548     if (getAccessibleWordAtIndexFromContextMethod != (jmethodID) 0) {
3549         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3550                                                 getAccessibleWordAtIndexFromContextMethod,
3551                                                 accessibleContext, index);
3552         EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to CallIntMethod()", FALSE);
3553         PrintDebugString("  returned from CallObjectMethod(), js = %p", js);
3554         if (js != (jstring) 0) {
3555             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3556             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to GetStringChars()", FALSE);
3557             wcsncpy(textItems->word, stringBytes, (sizeof(textItems->word) / sizeof(wchar_t)));
3558             length = jniEnv->GetStringLength(js);
3559             textItems->word[length < (sizeof(textItems->word) / sizeof(wchar_t)) ?
3560                             length : (sizeof(textItems->word) / sizeof(wchar_t))-2] = (wchar_t) 0;
3561             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to GetStringLength()", FALSE);
3562             jniEnv->ReleaseStringChars(js, stringBytes);
3563             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to ReleaseStringChars()", FALSE);
3564             jniEnv->CallVoidMethod(accessBridgeObject,
3565                                    decrementReferenceMethod, js);
3566             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to CallVoidMethod()", FALSE);
3567             wPrintDebugString(L"  Accessible Text word = %ls", textItems->word);
3568             jniEnv->DeleteLocalRef(js);
3569             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to DeleteLocalRef()", FALSE);
3570         } else {
3571             PrintDebugString("  Accessible Text word is null.");
3572             textItems->word[0] = (wchar_t) 0;
3573         }
3574     } else {
3575         PrintDebugString("  Error! either env == 0 or getAccessibleWordAtIndexFromContextMethod == 0");
3576         return FALSE;
3577     }
3578 
3579     // Get the sentence at index
3580     if (getAccessibleSentenceAtIndexFromContextMethod != (jmethodID) 0) {
3581         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3582                                                 getAccessibleSentenceAtIndexFromContextMethod,
3583                                                 accessibleContext, index);
3584         EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to CallObjectMethod()", FALSE);
3585         PrintDebugString("  returned from CallObjectMethod(), js = %p", js);
3586         if (js != (jstring) 0) {
3587             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3588             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to GetStringChars()", FALSE);
3589             wcsncpy(textItems->sentence, stringBytes, (sizeof(textItems->sentence) / sizeof(wchar_t))-2);
3590             length = jniEnv->GetStringLength(js);
3591 
3592             if (length < sizeof(textItems->sentence) / sizeof(wchar_t)) {
3593                 textItems->sentence[length] = (wchar_t) 0;
3594             } else {
3595                 textItems->sentence[(sizeof(textItems->sentence) / sizeof(wchar_t))-2] = (wchar_t) 0;
3596             }
3597             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to GetStringLength()", FALSE);
3598             jniEnv->ReleaseStringChars(js, stringBytes);
3599             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to ReleaseStringChars()", FALSE);
3600             jniEnv->CallVoidMethod(accessBridgeObject,
3601                                    decrementReferenceMethod, js);
3602             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to CallVoidMethod()", FALSE);
3603             wPrintDebugString(L"  Accessible Text sentence = %ls", textItems->sentence);
3604             jniEnv->DeleteLocalRef(js);
3605             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to DeleteLocalRef()", FALSE);
3606         } else {
3607             PrintDebugString("  Accessible Text sentence is null.");
3608             textItems->sentence[0] = (wchar_t) 0;
3609         }
3610     } else {
3611         PrintDebugString("  Error! either env == 0 or getAccessibleSentenceAtIndexFromContextMethod == 0");
3612         return FALSE;
3613     }
3614 
3615     return TRUE;
3616 }
3617 
3618 BOOL
3619 AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(jobject accessibleContext,
3620                                                             AccessibleTextSelectionInfo *selectionInfo) {
3621     jstring js;
3622     const wchar_t *stringBytes;
3623     jthrowable exception;
3624     jsize length;
3625 
3626     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(%p):",
3627                      accessibleContext);
3628 
3629     // Verify the Java VM still exists and AccessibleContext is
3630     // an instance of AccessibleText
3631     if (verifyAccessibleText(accessibleContext) == FALSE) {
3632         return FALSE;
3633     }
3634 
3635     // Get the selection start index
3636     if (getAccessibleTextSelectionStartFromContextMethod != (jmethodID) 0) {
3637         selectionInfo->selectionStartIndex = jniEnv->CallIntMethod(accessBridgeObject,
3638                                                                    getAccessibleTextSelectionStartFromContextMethod,
3639                                                                    accessibleContext);
3640         EXCEPTION_CHECK("Getting AccessibleTextSelectionStart - call to CallIntMethod()", FALSE);
3641         PrintDebugString("  Selection start = %d", selectionInfo->selectionStartIndex);
3642     } else {
3643         PrintDebugString("  Error! either env == 0 or getAccessibleTextSelectionStartFromContextMethod == 0");
3644         return FALSE;
3645     }
3646 
3647     // Get the selection end index
3648     if (getAccessibleTextSelectionEndFromContextMethod != (jmethodID) 0) {
3649         selectionInfo->selectionEndIndex = jniEnv->CallIntMethod(accessBridgeObject,
3650                                                                  getAccessibleTextSelectionEndFromContextMethod,
3651                                                                  accessibleContext);
3652         EXCEPTION_CHECK("Getting AccessibleTextSelectionEnd - call to CallIntMethod()", FALSE);
3653         PrintDebugString("  Selection end = %d", selectionInfo->selectionEndIndex);
3654     } else {
3655         PrintDebugString("  Error! either env == 0 or getAccessibleTextSelectionEndFromContextMethod == 0");
3656         return FALSE;
3657     }
3658 
3659     // Get the selected text
3660     if (getAccessibleTextSelectedTextFromContextMethod != (jmethodID) 0) {
3661         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3662                                                 getAccessibleTextSelectedTextFromContextMethod,
3663                                                 accessibleContext);
3664         EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to CallObjectMethod()", FALSE);
3665         PrintDebugString("  returned from CallObjectMethod(), js = %p", js);
3666         if (js != (jstring) 0) {
3667             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3668             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to GetStringChars()", FALSE);
3669             wcsncpy(selectionInfo->selectedText, stringBytes, (sizeof(selectionInfo->selectedText) / sizeof(wchar_t)));
3670             length = jniEnv->GetStringLength(js);
3671             selectionInfo->selectedText[length < (sizeof(selectionInfo->selectedText) / sizeof(wchar_t)) ?
3672                                         length : (sizeof(selectionInfo->selectedText) / sizeof(wchar_t))-2] = (wchar_t) 0;
3673             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to GetStringLength()", FALSE);
3674             jniEnv->ReleaseStringChars(js, stringBytes);
3675             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to ReleaseStringChars()", FALSE);
3676             jniEnv->CallVoidMethod(accessBridgeObject,
3677                                    decrementReferenceMethod, js);
3678             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to CallVoidMethod()", FALSE);
3679             PrintDebugString("  Accessible's selected text = %s", selectionInfo->selectedText);
3680             jniEnv->DeleteLocalRef(js);
3681             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to DeleteLocalRef()", FALSE);
3682         } else {
3683             PrintDebugString("  Accessible's selected text is null.");
3684             selectionInfo->selectedText[0] = (wchar_t) 0;
3685         }
3686     } else {
3687         PrintDebugString("  Error! either env == 0 or getAccessibleTextSelectedTextFromContextMethod == 0");
3688         return FALSE;
3689     }
3690     return TRUE;
3691 }
3692 
3693 BOOL
3694 AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleContext, jint index, AccessibleTextAttributesInfo *attributes) {
3695     jstring js;
3696     const wchar_t *stringBytes;
3697     jobject AttributeSet;
3698     jthrowable exception;
3699     jsize length;
3700 
3701     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(%p):", accessibleContext);
3702 
3703     // Verify the Java VM still exists and AccessibleContext is
3704     // an instance of AccessibleText
3705     if (verifyAccessibleText(accessibleContext) == FALSE) {
3706         return FALSE;
3707     }
3708 
3709     if (accessibleContext == (jobject) 0) {
3710         PrintDebugString(" passed in AccessibleContext == null! (oops)");
3711 
3712         attributes->bold = FALSE;
3713         attributes->italic = FALSE;
3714         attributes->underline = FALSE;
3715         attributes->strikethrough = FALSE;
3716         attributes->superscript = FALSE;
3717         attributes->subscript = FALSE;
3718         attributes->backgroundColor[0] = (wchar_t) 0;
3719         attributes->foregroundColor[0] = (wchar_t) 0;
3720         attributes->fontFamily[0] = (wchar_t) 0;
3721         attributes->fontSize = -1;
3722         attributes->alignment = -1;
3723         attributes->bidiLevel = -1;
3724         attributes->firstLineIndent = -1;
3725         attributes->leftIndent = -1;
3726         attributes->rightIndent = -1;
3727         attributes->lineSpacing = -1;
3728         attributes->spaceAbove = -1;
3729         attributes->spaceBelow = -1;
3730         attributes->fullAttributesString[0] = (wchar_t) 0;
3731 
3732         return (FALSE);
3733     }
3734 
3735     // Get the AttributeSet
3736     if (getAccessibleAttributeSetAtIndexFromContextMethod != (jmethodID) 0) {
3737         PrintDebugString(" Getting AttributeSet at index...");
3738         AttributeSet = jniEnv->CallObjectMethod(accessBridgeObject,
3739                                                 getAccessibleAttributeSetAtIndexFromContextMethod,
3740                                                 accessibleContext, index);
3741         EXCEPTION_CHECK("Getting AccessibleAttributeSetAtIndex - call to CallObjectMethod()", FALSE);
3742     } else {
3743         PrintDebugString("  Error! either env == 0 or getAccessibleAttributeSetAtIndexFromContextMethod == 0");
3744         return FALSE;
3745     }
3746 
3747     // It is legal for the AttributeSet object to be null, in which case we return false!
3748     if (AttributeSet == (jobject) 0) {
3749         PrintDebugString(" AttributeSet returned at index is null (this is legal! - see AWT in J2SE 1.3");
3750 
3751         attributes->bold = FALSE;
3752         attributes->italic = FALSE;
3753         attributes->underline = FALSE;
3754         attributes->strikethrough = FALSE;
3755         attributes->superscript = FALSE;
3756         attributes->subscript = FALSE;
3757         attributes->backgroundColor[0] = (wchar_t) 0;
3758         attributes->foregroundColor[0] = (wchar_t) 0;
3759         attributes->fontFamily[0] = (wchar_t) 0;
3760         attributes->fontSize = -1;
3761         attributes->alignment = -1;
3762         attributes->bidiLevel = -1;
3763         attributes->firstLineIndent = -1;
3764         attributes->leftIndent = -1;
3765         attributes->rightIndent = -1;
3766         attributes->lineSpacing = -1;
3767         attributes->spaceAbove = -1;
3768         attributes->spaceBelow = -1;
3769         attributes->fullAttributesString[0] = (wchar_t) 0;
3770 
3771         return (FALSE);
3772     }
3773 
3774     // Get the bold setting
3775     if (getBoldFromAttributeSetMethod != (jmethodID) 0) {
3776         PrintDebugString(" Getting bold from AttributeSet...");
3777         attributes->bold = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3778                                                             getBoldFromAttributeSetMethod,
3779                                                             AttributeSet);
3780         EXCEPTION_CHECK("Getting BoldFromAttributeSet - call to CallBooleanMethod()", FALSE);
3781     } else {
3782         PrintDebugString("  Error! either env == 0 or getBoldFromAttributeSetMethod == 0");
3783         jniEnv->CallVoidMethod(accessBridgeObject,
3784                                decrementReferenceMethod, AttributeSet);
3785         EXCEPTION_CHECK("Getting BoldFromAttributeSet - call to CallVoidMethod()", FALSE);
3786         jniEnv->DeleteLocalRef(AttributeSet);
3787         EXCEPTION_CHECK("Getting BoldFromAttributeSet - call to DeleteLocalRef()", FALSE);
3788         return FALSE;
3789     }
3790 
3791     // Get the italic setting
3792     if (getItalicFromAttributeSetMethod != (jmethodID) 0) {
3793         PrintDebugString(" Getting italic from AttributeSet...");
3794         attributes->italic = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3795                                                               getItalicFromAttributeSetMethod,
3796                                                               AttributeSet);
3797         EXCEPTION_CHECK("Getting ItalicFromAttributeSet - call to CallBooleanMethod()", FALSE);
3798     } else {
3799         PrintDebugString("  Error! either env == 0 or getItalicdFromAttributeSetMethod == 0");
3800         jniEnv->CallVoidMethod(accessBridgeObject,
3801                                decrementReferenceMethod, AttributeSet);
3802         EXCEPTION_CHECK("Getting ItalicFromAttributeSet - call to CallVoidMethod()", FALSE);
3803         jniEnv->DeleteLocalRef(AttributeSet);
3804         EXCEPTION_CHECK("Getting ItalicFromAttributeSet - call to DeleteLocalRef()", FALSE);
3805         return FALSE;
3806     }
3807 
3808     // Get the underline setting
3809     if (getUnderlineFromAttributeSetMethod != (jmethodID) 0) {
3810         PrintDebugString(" Getting underline from AttributeSet...");
3811         attributes->underline = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3812                                                                  getUnderlineFromAttributeSetMethod,
3813                                                                  AttributeSet);
3814         EXCEPTION_CHECK("Getting UnderlineFromAttributeSet - call to CallBooleanMethod()", FALSE);
3815     } else {
3816         PrintDebugString("  Error! either env == 0 or getUnderlineFromAttributeSetMethod == 0");
3817         jniEnv->CallVoidMethod(accessBridgeObject,
3818                                decrementReferenceMethod, AttributeSet);
3819         EXCEPTION_CHECK("Getting UnderlineFromAttributeSet - call to CallVoidMethod()", FALSE);
3820         jniEnv->DeleteLocalRef(AttributeSet);
3821         EXCEPTION_CHECK("Getting UnderlineFromAttributeSet - call to DeleteLocalRef()", FALSE);
3822         return FALSE;
3823     }
3824 
3825     // Get the strikethrough setting
3826     if (getStrikethroughFromAttributeSetMethod != (jmethodID) 0) {
3827         PrintDebugString(" Getting strikethrough from AttributeSet...");
3828         attributes->strikethrough = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3829                                                                      getStrikethroughFromAttributeSetMethod,
3830                                                                      AttributeSet);
3831         EXCEPTION_CHECK("Getting StrikethroughFromAttributeSet - call to CallBooleanMethod()", FALSE);
3832     } else {
3833         PrintDebugString("  Error! either env == 0 or getStrikethroughFromAttributeSetMethod == 0");
3834         jniEnv->CallVoidMethod(accessBridgeObject,
3835                                decrementReferenceMethod, AttributeSet);
3836         EXCEPTION_CHECK("Getting StrikethroughFromAttributeSet - call to CallVoidMethod()", FALSE);
3837         jniEnv->DeleteLocalRef(AttributeSet);
3838         EXCEPTION_CHECK("Getting StrikethroughFromAttributeSet - call to DeleteLocalRef()", FALSE);
3839         return FALSE;
3840     }
3841 
3842     // Get the superscript setting
3843     if (getSuperscriptFromAttributeSetMethod != (jmethodID) 0) {
3844         PrintDebugString(" Getting superscript from AttributeSet...");
3845         attributes->superscript = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3846                                                                    getSuperscriptFromAttributeSetMethod,
3847                                                                    AttributeSet);
3848         EXCEPTION_CHECK("Getting SuperscriptFromAttributeSet - call to CallBooleanMethod()", FALSE);
3849     } else {
3850         PrintDebugString("  Error! either env == 0 or getSuperscripteFromAttributeSetMethod == 0");
3851         jniEnv->CallVoidMethod(accessBridgeObject,
3852                                decrementReferenceMethod, AttributeSet);
3853         EXCEPTION_CHECK("Getting SuperscriptFromAttributeSet - call to CallVoidMethod()", FALSE);
3854         jniEnv->DeleteLocalRef(AttributeSet);
3855         EXCEPTION_CHECK("Getting SuperscriptFromAttributeSet - call to DeleteLocalRef()", FALSE);
3856         return FALSE;
3857     }
3858 
3859     // Get the subscript setting
3860     if (getSubscriptFromAttributeSetMethod != (jmethodID) 0) {
3861         PrintDebugString(" Getting subscript from AttributeSet...");
3862         attributes->subscript = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3863                                                                  getSubscriptFromAttributeSetMethod,
3864                                                                  AttributeSet);
3865         EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to CallBooleanMethod()", FALSE);
3866     } else {
3867         PrintDebugString("  Error! either env == 0 or getSubscriptFromAttributeSetMethod == 0");
3868         jniEnv->CallVoidMethod(accessBridgeObject,
3869                                decrementReferenceMethod, AttributeSet);
3870         EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to CallVoidMethod()", FALSE);
3871         jniEnv->DeleteLocalRef(AttributeSet);
3872         EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to DeleteLocalRef()", FALSE);
3873         return FALSE;
3874     }
3875 
3876     // Get the backgroundColor setting
3877     if (getBackgroundColorFromAttributeSetMethod != (jmethodID) 0) {
3878         PrintDebugString(" Getting backgroundColor from AttributeSet...");
3879         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3880                                                 getBackgroundColorFromAttributeSetMethod,
3881                                                 AttributeSet);
3882         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallObjectMethod()", FALSE);
3883         if (js != (jstring) 0) {
3884             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3885             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to GetStringChars()", FALSE);
3886             wcsncpy(attributes->backgroundColor, stringBytes, (sizeof(attributes->backgroundColor) / sizeof(wchar_t)));
3887             length = jniEnv->GetStringLength(js);
3888             attributes->backgroundColor[length < (sizeof(attributes->backgroundColor) / sizeof(wchar_t)) ?
3889                                         length : (sizeof(attributes->backgroundColor) / sizeof(wchar_t))-2] = (wchar_t) 0;
3890             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to GetStringLength()", FALSE);
3891             jniEnv->ReleaseStringChars(js, stringBytes);
3892             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to ReleaseStringChars()", FALSE);
3893             jniEnv->CallVoidMethod(accessBridgeObject,
3894                                    decrementReferenceMethod, js);
3895             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3896             wPrintDebugString(L"  AttributeSet's background color = %ls", attributes->backgroundColor);
3897             jniEnv->DeleteLocalRef(js);
3898             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3899         } else {
3900             PrintDebugString("  AttributeSet's background color is null.");
3901             attributes->backgroundColor[0] = (wchar_t) 0;
3902         }
3903     } else {
3904         PrintDebugString("  Error! either env == 0 or getBackgroundColorFromAttributeSetMethod == 0");
3905         jniEnv->CallVoidMethod(accessBridgeObject,
3906                                decrementReferenceMethod, AttributeSet);
3907         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3908         jniEnv->DeleteLocalRef(AttributeSet);
3909         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3910         return FALSE;
3911     }
3912 
3913     // Get the foregroundColor setting
3914     if (getForegroundColorFromAttributeSetMethod != (jmethodID) 0) {
3915         PrintDebugString(" Getting foregroundColor from AttributeSet...");
3916         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3917                                                 getForegroundColorFromAttributeSetMethod,
3918                                                 AttributeSet);
3919         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallObjectMethod()", FALSE);
3920         if (js != (jstring) 0) {
3921             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3922             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to GetStringChars()", FALSE);
3923             wcsncpy(attributes->foregroundColor, stringBytes, (sizeof(attributes->foregroundColor) / sizeof(wchar_t)));
3924             length = jniEnv->GetStringLength(js);
3925             attributes->foregroundColor[length < (sizeof(attributes->foregroundColor) / sizeof(wchar_t)) ?
3926                                         length : (sizeof(attributes->foregroundColor) / sizeof(wchar_t))-2] = (wchar_t) 0;
3927             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to GetStringLength()", FALSE);
3928             jniEnv->ReleaseStringChars(js, stringBytes);
3929             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to ReleaseStringChars()", FALSE);
3930             jniEnv->CallVoidMethod(accessBridgeObject,
3931                                    decrementReferenceMethod, js);
3932             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3933             wPrintDebugString(L"  AttributeSet's foreground color = %ls", attributes->foregroundColor);
3934             jniEnv->DeleteLocalRef(js);
3935             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3936         } else {
3937             PrintDebugString("  AttributeSet's foreground color is null.");
3938             attributes->foregroundColor[0] = (wchar_t) 0;
3939         }
3940     } else {
3941         PrintDebugString("  Error! either env == 0 or getForegroundColorFromAttributeSetMethod == 0");
3942         jniEnv->CallVoidMethod(accessBridgeObject,
3943                                decrementReferenceMethod, AttributeSet);
3944         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3945         jniEnv->DeleteLocalRef(AttributeSet);
3946         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3947         return FALSE;
3948     }
3949 
3950     // Get the fontFamily setting
3951     if (getFontFamilyFromAttributeSetMethod != (jmethodID) 0) {
3952         PrintDebugString(" Getting fontFamily from AttributeSet...");
3953         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3954                                                 getFontFamilyFromAttributeSetMethod,
3955                                                 AttributeSet);
3956         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallObjectMethod()", FALSE);
3957         if (js != (jstring) 0) {
3958             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3959             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to GetStringChars()", FALSE);
3960             wcsncpy(attributes->fontFamily, stringBytes, (sizeof(attributes->fontFamily) / sizeof(wchar_t)));
3961             length = jniEnv->GetStringLength(js);
3962             attributes->fontFamily[length < (sizeof(attributes->fontFamily) / sizeof(wchar_t)) ?
3963                                    length : (sizeof(attributes->fontFamily) / sizeof(wchar_t))-2] = (wchar_t) 0;
3964             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to GetStringLength()", FALSE);
3965             jniEnv->ReleaseStringChars(js, stringBytes);
3966             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to ReleaseStringChars()", FALSE);
3967             jniEnv->CallVoidMethod(accessBridgeObject,
3968                                    decrementReferenceMethod, js);
3969             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallVoidMethod()", FALSE);
3970             wPrintDebugString(L"  AttributeSet's fontFamily = %ls", attributes->fontFamily);
3971             jniEnv->DeleteLocalRef(js);
3972             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to DeleteLocalRef()", FALSE);
3973         } else {
3974             PrintDebugString("  AttributeSet's fontFamily is null.");
3975             attributes->backgroundColor[0] = (wchar_t) 0;
3976         }
3977     } else {
3978         PrintDebugString("  Error! either env == 0 or getFontFamilyFromAttributeSetMethod == 0");
3979         jniEnv->CallVoidMethod(accessBridgeObject,
3980                                decrementReferenceMethod, AttributeSet);
3981         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallVoidMethod()", FALSE);
3982         jniEnv->DeleteLocalRef(AttributeSet);
3983         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to DeleteLocalRef()", FALSE);
3984         return FALSE;
3985     }
3986 
3987     // Get the font size
3988     if (getFontSizeFromAttributeSetMethod != (jmethodID) 0) {
3989         PrintDebugString(" Getting font size from AttributeSet...");
3990         attributes->fontSize = jniEnv->CallIntMethod(accessBridgeObject,
3991                                                      getFontSizeFromAttributeSetMethod,
3992                                                      AttributeSet);
3993         EXCEPTION_CHECK("Getting FontSizeFromAttributeSet - call to CallIntMethod()", FALSE);
3994         PrintDebugString("  AttributeSet's font size = %d", attributes->fontSize);
3995     } else {
3996         PrintDebugString("  Error! either env == 0 or getAlignmentFromAttributeSetMethod == 0");
3997         jniEnv->CallVoidMethod(accessBridgeObject,
3998                                decrementReferenceMethod, AttributeSet);
3999         EXCEPTION_CHECK("Getting FontSizeFromAttributeSet - call to CallVoidMethod()", FALSE);
4000         jniEnv->DeleteLocalRef(AttributeSet);
4001         EXCEPTION_CHECK("Getting FontSizeFromAttributeSet - call to DeleteLocalRef()", FALSE);
4002         return FALSE;
4003     }
4004 
4005 
4006     // Get the alignment setting
4007     if (getAlignmentFromAttributeSetMethod != (jmethodID) 0) {
4008         PrintDebugString(" Getting alignment from AttributeSet...");
4009         attributes->alignment = jniEnv->CallIntMethod(accessBridgeObject,
4010                                                       getAlignmentFromAttributeSetMethod,
4011                                                       AttributeSet);
4012         EXCEPTION_CHECK("Getting AlignmentFromAttributeSet - call to CallIntMethod()", FALSE);
4013     } else {
4014         PrintDebugString("  Error! either env == 0 or getAlignmentFromAttributeSetMethod == 0");
4015         jniEnv->CallVoidMethod(accessBridgeObject,
4016                                decrementReferenceMethod, AttributeSet);
4017         EXCEPTION_CHECK("Getting AlignmentFromAttributeSet - call to CallVoidMethod()", FALSE);
4018         jniEnv->DeleteLocalRef(AttributeSet);
4019         EXCEPTION_CHECK("Getting AlignmentFromAttributeSet - call to DeleteLocalRef()", FALSE);
4020         return FALSE;
4021     }
4022 
4023     // Get the bidiLevel setting
4024     if (getBidiLevelFromAttributeSetMethod != (jmethodID) 0) {
4025         PrintDebugString(" Getting bidiLevel from AttributeSet...");
4026         attributes->bidiLevel = jniEnv->CallIntMethod(accessBridgeObject,
4027                                                       getBidiLevelFromAttributeSetMethod,
4028                                                       AttributeSet);
4029         EXCEPTION_CHECK("Getting BidiLevelFromAttributeSet - call to CallIntMethod()", FALSE);
4030     } else {
4031         PrintDebugString("  Error! either env == 0 or getBidiLevelFromAttributeSetMethod == 0");
4032         jniEnv->CallVoidMethod(accessBridgeObject,
4033                                decrementReferenceMethod, AttributeSet);
4034         EXCEPTION_CHECK("Getting BidiLevelFromAttributeSet - call to CallVoidMethod()", FALSE);
4035         jniEnv->DeleteLocalRef(AttributeSet);
4036         EXCEPTION_CHECK("Getting BidiLevelFromAttributeSet - call to DeleteLocalRef()", FALSE);
4037         return FALSE;
4038     }
4039 
4040     // Get the firstLineIndent setting
4041     if (getFirstLineIndentFromAttributeSetMethod != (jmethodID) 0) {
4042         PrintDebugString(" Getting firstLineIndent from AttributeSet...");
4043         attributes->firstLineIndent = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4044                                                                        getFirstLineIndentFromAttributeSetMethod,
4045                                                                        AttributeSet);
4046         EXCEPTION_CHECK("Getting FirstLineIndentFromAttributeSet - call to CallIntMethod()", FALSE);
4047     } else {
4048         PrintDebugString("  Error! either env == 0 or getFirstLineIndentFromAttributeSetMethod == 0");
4049         jniEnv->CallVoidMethod(accessBridgeObject,
4050                                decrementReferenceMethod, AttributeSet);
4051         EXCEPTION_CHECK("Getting FirstLineIndentFromAttributeSet - call to CallVoidMethod()", FALSE);
4052         jniEnv->DeleteLocalRef(AttributeSet);
4053         EXCEPTION_CHECK("Getting FirstLineIndentFromAttributeSet - call to DeleteLocalRef()", FALSE);
4054         return FALSE;
4055     }
4056 
4057     // Get the leftIndent setting
4058     if (getLeftIndentFromAttributeSetMethod != (jmethodID) 0) {
4059         PrintDebugString(" Getting leftIndent from AttributeSet...");
4060         attributes->leftIndent = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4061                                                                   getLeftIndentFromAttributeSetMethod,
4062                                                                   AttributeSet);
4063         EXCEPTION_CHECK("Getting LeftIndentFromAttributeSet - call to CallIntMethod()", FALSE);
4064     } else {
4065         PrintDebugString("  Error! either env == 0 or getLeftIndentFromAttributeSetMethod == 0");
4066         jniEnv->CallVoidMethod(accessBridgeObject,
4067                                decrementReferenceMethod, AttributeSet);
4068         EXCEPTION_CHECK("Getting LeftIndentFromAttributeSet - call to CallVoidMethod()", FALSE);
4069         jniEnv->DeleteLocalRef(AttributeSet);
4070         EXCEPTION_CHECK("Getting LeftIndentFromAttributeSet - call to DeleteLocalRef()", FALSE);
4071         return FALSE;
4072     }
4073 
4074     // Get the rightIndent setting
4075     if (getRightIndentFromAttributeSetMethod != (jmethodID) 0) {
4076         PrintDebugString(" Getting rightIndent from AttributeSet...");
4077         attributes->rightIndent = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4078                                                                    getRightIndentFromAttributeSetMethod,
4079                                                                    AttributeSet);
4080         EXCEPTION_CHECK("Getting RightIndentFromAttributeSet - call to CallIntMethod()", FALSE);
4081     } else {
4082         PrintDebugString("  Error! either env == 0 or getRightIndentFromAttributeSetMethod == 0");
4083         jniEnv->CallVoidMethod(accessBridgeObject,
4084                                decrementReferenceMethod, AttributeSet);
4085         EXCEPTION_CHECK("Getting RightIndentFromAttributeSet - call to CallVoidMethod()", FALSE);
4086         jniEnv->DeleteLocalRef(AttributeSet);
4087         EXCEPTION_CHECK("Getting RightIndentFromAttributeSet - call to DeleteLocalRef()", FALSE);
4088         return FALSE;
4089     }
4090 
4091     // Get the lineSpacing setting
4092     if (getLineSpacingFromAttributeSetMethod != (jmethodID) 0) {
4093         PrintDebugString(" Getting lineSpacing from AttributeSet...");
4094         attributes->lineSpacing = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4095                                                                    getLineSpacingFromAttributeSetMethod,
4096                                                                    AttributeSet);
4097         EXCEPTION_CHECK("Getting LineSpacingFromAttributeSet - call to CallIntMethod()", FALSE);
4098     } else {
4099         PrintDebugString("  Error! either env == 0 or getLineSpacingFromAttributeSetMethod == 0");
4100         jniEnv->CallVoidMethod(accessBridgeObject,
4101                                decrementReferenceMethod, AttributeSet);
4102         EXCEPTION_CHECK("Getting LineSpacingFromAttributeSet - call to CallVoidMethod()", FALSE);
4103         jniEnv->DeleteLocalRef(AttributeSet);
4104         EXCEPTION_CHECK("Getting LineSpacingFromAttributeSet - call to DeleteLocalRef()", FALSE);
4105         return FALSE;
4106     }
4107 
4108     // Get the spaceAbove setting
4109     if (getSpaceAboveFromAttributeSetMethod != (jmethodID) 0) {
4110         PrintDebugString(" Getting spaceAbove from AttributeSet...");
4111         attributes->spaceAbove = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4112                                                                   getSpaceAboveFromAttributeSetMethod,
4113                                                                   AttributeSet);
4114         EXCEPTION_CHECK("Getting SpaceAboveFromAttributeSet - call to CallIntMethod()", FALSE);
4115     } else {
4116         PrintDebugString("  Error! either env == 0 or getSpaceAboveFromAttributeSetMethod == 0");
4117         jniEnv->CallVoidMethod(accessBridgeObject,
4118                                decrementReferenceMethod, AttributeSet);
4119         EXCEPTION_CHECK("Getting SpaceAboveFromAttributeSet - call to CallVoidMethod()", FALSE);
4120         jniEnv->DeleteLocalRef(AttributeSet);
4121         EXCEPTION_CHECK("Getting SpaceAboveFromAttributeSet - call to DeleteLocalRef()", FALSE);
4122         return FALSE;
4123     }
4124 
4125     // Get the spaceBelow setting
4126     if (getSpaceBelowFromAttributeSetMethod != (jmethodID) 0) {
4127         PrintDebugString(" Getting spaceBelow from AttributeSet...");
4128         attributes->spaceBelow = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4129                                                                   getSpaceBelowFromAttributeSetMethod,
4130                                                                   AttributeSet);
4131         EXCEPTION_CHECK("Getting SpaceBelowFromAttributeSet - call to CallIntMethod()", FALSE);
4132     } else {
4133         PrintDebugString("  Error! either env == 0 or getSpaceBelowFromAttributeSetMethod == 0");
4134         jniEnv->CallVoidMethod(accessBridgeObject,
4135                                decrementReferenceMethod, AttributeSet);
4136         EXCEPTION_CHECK("Getting SpaceBelowFromAttributeSet - call to CallVoidMethod()", FALSE);
4137         jniEnv->DeleteLocalRef(AttributeSet);
4138         EXCEPTION_CHECK("Getting SpaceBelowFromAttributeSet - call to DeleteLocalRef()", FALSE);
4139         return FALSE;
4140     }
4141 
4142     // Release the AttributeSet object
4143     if (decrementReferenceMethod != (jmethodID) 0) {
4144         PrintDebugString(" Decrementing reference to AttributeSet...");
4145         jniEnv->CallVoidMethod(accessBridgeObject,
4146                                decrementReferenceMethod, AttributeSet);
4147         EXCEPTION_CHECK("Releasing AttributeSet object - call to CallVoidMethod()", FALSE);
4148     } else {
4149         PrintDebugString("  Error! either env == 0 or accessBridgeObject == 0");
4150         jniEnv->DeleteLocalRef(AttributeSet);
4151         EXCEPTION_CHECK("Releasing AttributeSet object - call to DeleteLocalRef()", FALSE);
4152         return FALSE;
4153     }
4154 
4155     // Get the full attributes string at index
4156     if (getAccessibleAttributesAtIndexFromContextMethod != (jmethodID) 0) {
4157         PrintDebugString(" Getting full attributes string from Context...");
4158         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4159                                                 getAccessibleAttributesAtIndexFromContextMethod,
4160                                                 accessibleContext, index);
4161         EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallObjectMethod()", FALSE);
4162         PrintDebugString("  returned from CallObjectMethod(), js = %p", js);
4163         if (js != (jstring) 0) {
4164             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4165             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE);
4166             wcsncpy(attributes->fullAttributesString, stringBytes, (sizeof(attributes->fullAttributesString) / sizeof(wchar_t)));
4167             length = jniEnv->GetStringLength(js);
4168             attributes->fullAttributesString[length < (sizeof(attributes->fullAttributesString) / sizeof(wchar_t)) ?
4169                                              length : (sizeof(attributes->fullAttributesString) / sizeof(wchar_t))-2] = (wchar_t) 0;
4170             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringLength()", FALSE);
4171             jniEnv->ReleaseStringChars(js, stringBytes);
4172             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to ReleaseStringChars()", FALSE);
4173             jniEnv->CallVoidMethod(accessBridgeObject,
4174                                    decrementReferenceMethod, js);
4175             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE);
4176             wPrintDebugString(L"  Accessible Text attributes = %ls", attributes->fullAttributesString);
4177             jniEnv->DeleteLocalRef(js);
4178             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
4179         } else {
4180             PrintDebugString("  Accessible Text attributes is null.");
4181             attributes->fullAttributesString[0] = (wchar_t) 0;
4182             jniEnv->DeleteLocalRef(AttributeSet);
4183             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
4184             return FALSE;
4185         }
4186     } else {
4187         PrintDebugString("  Error! either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0");
4188         jniEnv->DeleteLocalRef(AttributeSet);
4189         return FALSE;
4190     }
4191 
4192     jniEnv->DeleteLocalRef(AttributeSet);
4193     EXCEPTION_CHECK("Getting AccessibleAttributeSetAtIndex - call to DeleteLocalRef()", FALSE);
4194     return TRUE;
4195 }
4196 
4197 BOOL
4198 AccessBridgeJavaEntryPoints::getAccessibleTextRect(jobject accessibleContext, AccessibleTextRectInfo *rectInfo, jint index) {
4199 
4200     jthrowable exception;
4201 
4202     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextRect(%p), index = %d",
4203                      accessibleContext, index);
4204 
4205     // Verify the Java VM still exists and AccessibleContext is
4206     // an instance of AccessibleText
4207     if (verifyAccessibleText(accessibleContext) == FALSE) {
4208         return FALSE;
4209     }
4210 
4211     // Get the x coord
4212     if (getAccessibleXcoordTextRectAtIndexFromContextMethod != (jmethodID) 0) {
4213         rectInfo->x = jniEnv->CallIntMethod(accessBridgeObject,
4214                                             getAccessibleXcoordTextRectAtIndexFromContextMethod,
4215                                             accessibleContext, index);
4216         EXCEPTION_CHECK("Getting AccessibleXcoordTextRect - call to CallIntMethod()", FALSE);
4217         PrintDebugString("  X coord = %d", rectInfo->x);
4218     } else {
4219         PrintDebugString("  Error! either env == 0 or getAccessibleXcoordTextRectAtIndexFromContextMethod == 0");
4220         return FALSE;
4221     }
4222 
4223     // Get the y coord
4224     if (getAccessibleYcoordTextRectAtIndexFromContextMethod != (jmethodID) 0) {
4225         rectInfo->y = jniEnv->CallIntMethod(accessBridgeObject,
4226                                             getAccessibleYcoordTextRectAtIndexFromContextMethod,
4227                                             accessibleContext, index);
4228         EXCEPTION_CHECK("Getting AccessibleYcoordTextRect - call to CallIntMethod()", FALSE);
4229         PrintDebugString("  Y coord = %d", rectInfo->y);
4230     } else {
4231         PrintDebugString("  Error! either env == 0 or getAccessibleYcoordTextRectAtIndexFromContextMethod == 0");
4232         return FALSE;
4233     }
4234 
4235     // Get the width
4236     if (getAccessibleWidthTextRectAtIndexFromContextMethod != (jmethodID) 0) {
4237         rectInfo->width = jniEnv->CallIntMethod(accessBridgeObject,
4238                                                 getAccessibleWidthTextRectAtIndexFromContextMethod,
4239                                                 accessibleContext, index);
4240         EXCEPTION_CHECK("Getting AccessibleWidthTextRect - call to CallIntMethod()", FALSE);
4241         PrintDebugString("  Width = %d", rectInfo->width);
4242     } else {
4243         PrintDebugString("  Error! either env == 0 or getAccessibleWidthTextRectAtIndexFromContextMethod == 0");
4244         return FALSE;
4245     }
4246 
4247     // Get the height
4248     if (getAccessibleHeightTextRectAtIndexFromContextMethod != (jmethodID) 0) {
4249         rectInfo->height = jniEnv->CallIntMethod(accessBridgeObject,
4250                                                  getAccessibleHeightTextRectAtIndexFromContextMethod,
4251                                                  accessibleContext, index);
4252         EXCEPTION_CHECK("Getting AccessibleHeightTextRect - call to CallIntMethod()", FALSE);
4253         PrintDebugString("  Height = %d", rectInfo->height);
4254     } else {
4255         PrintDebugString("  Error! either env == 0 or getAccessibleHeightTextRectAtIndexFromContextMethod == 0");
4256         return FALSE;
4257     }
4258 
4259     return TRUE;
4260 }
4261 
4262 // =====
4263 
4264 /**
4265  * gets the bounding rectangle for the text caret
4266  */
4267 BOOL
4268 AccessBridgeJavaEntryPoints::getCaretLocation(jobject accessibleContext, AccessibleTextRectInfo *rectInfo, jint index) {
4269 
4270     jthrowable exception;
4271 
4272     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getCaretLocation(%p), index = %d",
4273                      accessibleContext, index);
4274 
4275     // Verify the Java VM still exists and AccessibleContext is
4276     // an instance of AccessibleText
4277     if (verifyAccessibleText(accessibleContext) == FALSE) {
4278         return FALSE;
4279     }
4280 
4281     // Get the x coord
4282     if (getCaretLocationXMethod != (jmethodID) 0) {
4283         rectInfo->x = jniEnv->CallIntMethod(accessBridgeObject,
4284                                             getCaretLocationXMethod,
4285                                             accessibleContext, index);
4286         EXCEPTION_CHECK("Getting caret X coordinate - call to CallIntMethod()", FALSE);
4287         PrintDebugString("  X coord = %d", rectInfo->x);
4288     } else {
4289         PrintDebugString("  Error! either env == 0 or getCaretLocationXMethod == 0");
4290         return FALSE;
4291     }
4292 
4293     // Get the y coord
4294     if (getCaretLocationYMethod != (jmethodID) 0) {
4295         rectInfo->y = jniEnv->CallIntMethod(accessBridgeObject,
4296                                             getCaretLocationYMethod,
4297                                             accessibleContext, index);
4298         EXCEPTION_CHECK("Getting caret Y coordinate - call to CallIntMethod()", FALSE);
4299         PrintDebugString("  Y coord = %d", rectInfo->y);
4300     } else {
4301         PrintDebugString("  Error! either env == 0 or getCaretLocationYMethod == 0");
4302         return FALSE;
4303     }
4304 
4305     // Get the width
4306     if (getCaretLocationWidthMethod != (jmethodID) 0) {
4307         rectInfo->width = jniEnv->CallIntMethod(accessBridgeObject,
4308                                                 getCaretLocationWidthMethod,
4309                                                 accessibleContext, index);
4310         EXCEPTION_CHECK("Getting caret width - call to CallIntMethod()", FALSE);
4311         PrintDebugString("  Width = %d", rectInfo->width);
4312     } else {
4313         PrintDebugString("  Error! either env == 0 or getCaretLocationWidthMethod == 0");
4314         return FALSE;
4315     }
4316 
4317     // Get the height
4318     if (getCaretLocationHeightMethod != (jmethodID) 0) {
4319         rectInfo->height = jniEnv->CallIntMethod(accessBridgeObject,
4320                                                  getCaretLocationHeightMethod,
4321                                                  accessibleContext, index);
4322         EXCEPTION_CHECK("Getting caret height - call to CallIntMethod()", FALSE);
4323         PrintDebugString("  Height = %d", rectInfo->height);
4324     } else {
4325         PrintDebugString("  Error! either env == 0 or getCaretLocationHeightMethod == 0");
4326         return FALSE;
4327     }
4328 
4329     return TRUE;
4330 }
4331 
4332 // =====
4333 
4334 BOOL
4335 AccessBridgeJavaEntryPoints::getAccessibleTextLineBounds(jobject accessibleContext, jint index, jint *startIndex, jint *endIndex) {
4336 
4337     jthrowable exception;
4338 
4339     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextLineBounds(%p):", accessibleContext);
4340 
4341     // Verify the Java VM still exists and AccessibleContext is
4342     // an instance of AccessibleText
4343     if (verifyAccessibleText(accessibleContext) == FALSE) {
4344         return FALSE;
4345     }
4346 
4347     // Get the index of the left boundary of the line containing 'index'
4348     if (getAccessibleTextLineLeftBoundsFromContextMethod != (jmethodID) 0) {
4349         *startIndex = jniEnv->CallIntMethod(accessBridgeObject,
4350                                             getAccessibleTextLineLeftBoundsFromContextMethod,
4351                                             accessibleContext, index);
4352         EXCEPTION_CHECK("Getting AccessibleTextLineLeftBounds - call to CallIntMethod()", FALSE);
4353         PrintDebugString("  startIndex = %d", *startIndex);
4354     } else {
4355         PrintDebugString("  Error! either env == 0 or getAccessibleTextLineLeftBoundsFromContextMethod == 0");
4356         return FALSE;
4357     }
4358 
4359     // Get the index of the right boundary of the line containing 'index'
4360     if (getAccessibleTextLineRightBoundsFromContextMethod != (jmethodID) 0) {
4361         *endIndex = jniEnv->CallIntMethod(accessBridgeObject,
4362                                           getAccessibleTextLineRightBoundsFromContextMethod,
4363                                           accessibleContext, index);
4364         EXCEPTION_CHECK("Getting AccessibleTextLineRightBounds - call to CallIntMethod()", FALSE);
4365         PrintDebugString("  endIndex = %d", *endIndex);
4366     } else {
4367         PrintDebugString("  Error! either env == 0 or getAccessibleTextLineRightBoundsFromContextMethod == 0");
4368         return FALSE;
4369     }
4370 
4371     return TRUE;
4372 }
4373 
4374 BOOL
4375 AccessBridgeJavaEntryPoints::getAccessibleTextRange(jobject accessibleContext,
4376                                                     jint start, jint end, wchar_t *text, short len) {
4377     jstring js;
4378     const wchar_t *stringBytes;
4379     jthrowable exception;
4380     jsize length;
4381 
4382     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleTextRange(%p, %d, %d, *text, %d):", accessibleContext, start, end, len);
4383 
4384     // Verify the Java VM still exists and AccessibleContext is
4385     // an instance of AccessibleText
4386     if (verifyAccessibleText(accessibleContext) == FALSE) {
4387         return FALSE;
4388     }
4389 
4390     // range is inclusive
4391     if (end < start) {
4392         PrintDebugString("  Error! end < start!");
4393         text[0] = (wchar_t) 0;
4394         return FALSE;
4395     }
4396 
4397     // Get the text range within [start, end] inclusive
4398     if (getAccessibleTextRangeFromContextMethod != (jmethodID) 0) {
4399         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4400                                                 getAccessibleTextRangeFromContextMethod,
4401                                                 accessibleContext, start, end);
4402         EXCEPTION_CHECK("Getting AccessibleTextRange - call to CallObjectMethod()", FALSE);
4403         PrintDebugString("  returned from CallObjectMethod(), js = %p", js);
4404         if (js != (jstring) 0) {
4405             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4406             EXCEPTION_CHECK("Getting AccessibleTextRange - call to GetStringChars()", FALSE);
4407             wPrintDebugString(L"  Accessible Text stringBytes returned from Java = %ls", stringBytes);
4408             wcsncpy(text, stringBytes, len);
4409             length = jniEnv->GetStringLength(js);
4410             PrintDebugString("  Accessible Text stringBytes length = %d", length);
4411             text[length < len ? length : len - 2] = (wchar_t) 0;
4412             wPrintDebugString(L"  Accessible Text 'text' after null termination = %ls", text);
4413             EXCEPTION_CHECK("Getting AccessibleTextRange - call to GetStringLength()", FALSE);
4414             jniEnv->ReleaseStringChars(js, stringBytes);
4415             EXCEPTION_CHECK("Getting AccessibleTextRange - call to ReleaseStringChars()", FALSE);
4416             jniEnv->CallVoidMethod(accessBridgeObject,
4417                                    decrementReferenceMethod, js);
4418             EXCEPTION_CHECK("Getting AccessibleTextRange - call to CallVoidMethod()", FALSE);
4419             wPrintDebugString(L"  Accessible Text range = %ls", text);
4420             jniEnv->DeleteLocalRef(js);
4421             EXCEPTION_CHECK("Getting AccessibleTextRange - call to DeleteLocalRef()", FALSE);
4422         } else {
4423             PrintDebugString("  current Accessible Text range is null.");
4424             text[0] = (wchar_t) 0;
4425             return FALSE;
4426         }
4427     } else {
4428         PrintDebugString("  Error! either env == 0 or getAccessibleTextRangeFromContextMethod == 0");
4429         return FALSE;
4430     }
4431     return TRUE;
4432 }
4433 
4434 /********** AccessibleValue routines ***************/
4435 
4436 BOOL
4437 AccessBridgeJavaEntryPoints::getCurrentAccessibleValueFromContext(jobject accessibleContext, wchar_t *value, short len) {
4438     jstring js;
4439     const wchar_t *stringBytes;
4440     jthrowable exception;
4441     jsize length;
4442 
4443     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getCurrentAccessibleValueFromContext(%p):", accessibleContext);
4444 
4445     // Get the current Accessible Value
4446     if (getCurrentAccessibleValueFromContextMethod != (jmethodID) 0) {
4447         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4448                                                 getCurrentAccessibleValueFromContextMethod,
4449                                                 accessibleContext);
4450         EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to CallObjectMethod()", FALSE);
4451         PrintDebugString("  returned from CallObjectMethod(), js = %p", js);
4452         if (js != (jstring) 0) {
4453             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4454             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to GetStringChars()", FALSE);
4455             wcsncpy(value, stringBytes, len);
4456             length = jniEnv->GetStringLength(js);
4457             value[length < len ? length : len - 2] = (wchar_t) 0;
4458             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to GetStringLength()", FALSE);
4459             jniEnv->ReleaseStringChars(js, stringBytes);
4460             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to ReleaseStringChars()", FALSE);
4461             jniEnv->CallVoidMethod(accessBridgeObject,
4462                                    decrementReferenceMethod, js);
4463             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to CallVoidMethod()", FALSE);
4464             PrintDebugString("  current Accessible Value = %s", value);
4465             jniEnv->DeleteLocalRef(js);
4466             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to DeleteLocalRef()", FALSE);
4467         } else {
4468             PrintDebugString("  current Accessible Value is null.");
4469             value[0] = (wchar_t) 0;
4470             return FALSE;
4471         }
4472     } else {
4473         PrintDebugString("  Error! either env == 0 or getCurrentAccessibleValueFromContextMethod == 0");
4474         return FALSE;
4475     }
4476     return TRUE;
4477 }
4478 
4479 BOOL
4480 AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(jobject accessibleContext, wchar_t *value, short len) {
4481     jstring js;
4482     const wchar_t *stringBytes;
4483     jthrowable exception;
4484     jsize length;
4485 
4486     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(%p):", accessibleContext);
4487 
4488     // Get the maximum Accessible Value
4489     if (getMaximumAccessibleValueFromContextMethod != (jmethodID) 0) {
4490         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4491                                                 getMaximumAccessibleValueFromContextMethod,
4492                                                 accessibleContext);
4493         EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to CallObjectMethod()", FALSE);
4494         PrintDebugString("  returned from CallObjectMethod(), js = %p", js);
4495         if (js != (jstring) 0) {
4496             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4497             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to GetStringChars()", FALSE);
4498             wcsncpy(value, stringBytes, len);
4499             length = jniEnv->GetStringLength(js);
4500             value[length < len ? length : len - 2] = (wchar_t) 0;
4501             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to GetStringLength()", FALSE);
4502             jniEnv->ReleaseStringChars(js, stringBytes);
4503             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to ReleaseStringChars()", FALSE);
4504             jniEnv->CallVoidMethod(accessBridgeObject,
4505                                    decrementReferenceMethod, js);
4506             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to CallVoidMethod()", FALSE);
4507             PrintDebugString("  maximum Accessible Value = %s", value);
4508             jniEnv->DeleteLocalRef(js);
4509             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to DeleteLocalRef()", FALSE);
4510         } else {
4511             PrintDebugString("  maximum Accessible Value is null.");
4512             value[0] = (wchar_t) 0;
4513             return FALSE;
4514         }
4515     } else {
4516         PrintDebugString("  Error! either env == 0 or getMaximumAccessibleValueFromContextMethod == 0");
4517         return FALSE;
4518     }
4519     return TRUE;
4520 }
4521 
4522 BOOL
4523 AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(jobject accessibleContext, wchar_t *value, short len) {
4524     jstring js;
4525     const wchar_t *stringBytes;
4526     jthrowable exception;
4527     jsize length;
4528 
4529     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(%p):", accessibleContext);
4530 
4531     // Get the mimimum Accessible Value
4532     if (getMinimumAccessibleValueFromContextMethod != (jmethodID) 0) {
4533         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4534                                                 getMinimumAccessibleValueFromContextMethod,
4535                                                 accessibleContext);
4536         EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to CallObjectMethod()", FALSE);
4537         PrintDebugString("  returned from CallObjectMethod(), js = %p", js);
4538         if (js != (jstring) 0) {
4539             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4540             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to GetStringChars()", FALSE);
4541             wcsncpy(value, stringBytes, len);
4542             length = jniEnv->GetStringLength(js);
4543             value[length < len ? length : len - 2] = (wchar_t) 0;
4544             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to GetStringLength()", FALSE);
4545             jniEnv->ReleaseStringChars(js, stringBytes);
4546             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to ReleaseStringChars()", FALSE);
4547             jniEnv->CallVoidMethod(accessBridgeObject,
4548                                    decrementReferenceMethod, js);
4549             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to CallVoidMethod()", FALSE);
4550             PrintDebugString("  mimimum Accessible Value = %s", value);
4551             jniEnv->DeleteLocalRef(js);
4552             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to DeleteLocalRef()", FALSE);
4553         } else {
4554             PrintDebugString("  mimimum Accessible Value is null.");
4555             value[0] = (wchar_t) 0;
4556             return FALSE;
4557         }
4558     } else {
4559         PrintDebugString("  Error! either env == 0 or getMinimumAccessibleValueFromContextMethod == 0");
4560         return FALSE;
4561     }
4562     return TRUE;
4563 }
4564 
4565 
4566 /********** AccessibleSelection routines ***************/
4567 
4568 void
4569 AccessBridgeJavaEntryPoints::addAccessibleSelectionFromContext(jobject accessibleContext, int i) {
4570     jthrowable exception;
4571 
4572     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::addAccessibleSelectionFromContext(%p):", accessibleContext);
4573 
4574     // Add the child to the AccessibleSelection
4575     if (addAccessibleSelectionFromContextMethod != (jmethodID) 0) {
4576         jniEnv->CallVoidMethod(accessBridgeObject,
4577                                addAccessibleSelectionFromContextMethod,
4578                                accessibleContext, i);
4579         EXCEPTION_CHECK_VOID("Doing addAccessibleSelection - call to CallVoidMethod()");
4580         PrintDebugString("  returned from CallObjectMethod()");
4581     } else {
4582         PrintDebugString("  Error! either env == 0 or addAccessibleSelectionFromContextMethod == 0");
4583     }
4584 }
4585 
4586 void
4587 AccessBridgeJavaEntryPoints::clearAccessibleSelectionFromContext(jobject accessibleContext) {
4588     jthrowable exception;
4589 
4590     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::clearAccessibleSelectionFromContext(%p):", accessibleContext);
4591 
4592     // Clearing the Selection of the AccessibleSelection
4593     if (clearAccessibleSelectionFromContextMethod != (jmethodID) 0) {
4594         jniEnv->CallVoidMethod(accessBridgeObject,
4595                                clearAccessibleSelectionFromContextMethod,
4596                                accessibleContext);
4597         EXCEPTION_CHECK_VOID("Doing clearAccessibleSelection - call to CallVoidMethod()");
4598         PrintDebugString("  returned from CallObjectMethod()");
4599     } else {
4600         PrintDebugString("  Error! either env == 0 or clearAccessibleSelectionFromContextMethod == 0");
4601     }
4602 }
4603 
4604 jobject
4605 AccessBridgeJavaEntryPoints::getAccessibleSelectionFromContext(jobject accessibleContext, int i) {
4606     jobject returnedAccessibleContext;
4607     jobject globalRef;
4608     jthrowable exception;
4609 
4610     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleSelectionFromContext(%p):", accessibleContext);
4611 
4612     if (getAccessibleSelectionContextFromContextMethod != (jmethodID) 0) {
4613         returnedAccessibleContext = jniEnv->CallObjectMethod(
4614                                                              accessBridgeObject,
4615                                                              getAccessibleSelectionContextFromContextMethod,
4616                                                              accessibleContext, i);
4617         EXCEPTION_CHECK("Getting AccessibleSelectionContext - call to CallObjectMethod()", (jobject) 0);
4618         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
4619         EXCEPTION_CHECK("Getting AccessibleSelectionContext - call to NewGlobalRef()", (jobject) 0);
4620         jniEnv->DeleteLocalRef(returnedAccessibleContext);
4621         EXCEPTION_CHECK("Getting AccessibleSelectionContext - call to DeleteLocalRef()", (jobject) 0);
4622         PrintDebugString("  Returning - returnedAccessibleContext = %p; globalRef = %p",
4623                          returnedAccessibleContext, globalRef);
4624         return globalRef;
4625     } else {
4626         PrintDebugString("  Error! either env == 0 or getAccessibleSelectionContextFromContextMethod == 0");
4627         return (jobject) 0;
4628     }
4629 }
4630 
4631 int
4632 AccessBridgeJavaEntryPoints::getAccessibleSelectionCountFromContext(jobject accessibleContext) {
4633     int count;
4634     jthrowable exception;
4635 
4636     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::getAccessibleSelectionCountFromContext(%p):", accessibleContext);
4637 
4638     // Get (& return) the # of items selected in the AccessibleSelection
4639     if (getAccessibleSelectionCountFromContextMethod != (jmethodID) 0) {
4640         count = jniEnv->CallIntMethod(accessBridgeObject,
4641                                       getAccessibleSelectionCountFromContextMethod,
4642                                       accessibleContext);
4643         EXCEPTION_CHECK("Getting AccessibleSelectionCount - call to CallIntMethod()", -1);
4644         PrintDebugString("  returned from CallObjectMethod()");
4645         return count;
4646     } else {
4647         PrintDebugString("  Error! either env == 0 or getAccessibleSelectionCountFromContextMethod == 0");
4648         return -1;
4649     }
4650 }
4651 
4652 BOOL
4653 AccessBridgeJavaEntryPoints::isAccessibleChildSelectedFromContext(jobject accessibleContext, int i) {
4654     jboolean result;
4655     jthrowable exception;
4656 
4657     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::isAccessibleChildSelectedFromContext(%p):", accessibleContext);
4658 
4659     // Get (& return) the # of items selected in the AccessibleSelection
4660     if (isAccessibleChildSelectedFromContextMethod != (jmethodID) 0) {
4661         result = jniEnv->CallBooleanMethod(accessBridgeObject,
4662                                            isAccessibleChildSelectedFromContextMethod,
4663                                            accessibleContext, i);
4664         EXCEPTION_CHECK("Doing isAccessibleChildSelected - call to CallBooleanMethod()", FALSE);
4665         PrintDebugString("  returned from CallObjectMethod()");
4666         if (result != 0) {
4667             return TRUE;
4668         }
4669     } else {
4670         PrintDebugString("  Error! either env == 0 or isAccessibleChildSelectedFromContextMethod == 0");
4671     }
4672     return FALSE;
4673 }
4674 
4675 
4676 void
4677 AccessBridgeJavaEntryPoints::removeAccessibleSelectionFromContext(jobject accessibleContext, int i) {
4678     jthrowable exception;
4679 
4680     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::removeAccessibleSelectionFromContext(%p):", accessibleContext);
4681 
4682     // Remove the i-th child from the AccessibleSelection
4683     if (removeAccessibleSelectionFromContextMethod != (jmethodID) 0) {
4684         jniEnv->CallVoidMethod(accessBridgeObject,
4685                                removeAccessibleSelectionFromContextMethod,
4686                                accessibleContext, i);
4687         EXCEPTION_CHECK_VOID("Doing removeAccessibleSelection - call to CallVoidMethod()");
4688         PrintDebugString("  returned from CallObjectMethod()");
4689     } else {
4690         PrintDebugString("  Error! either env == 0 or removeAccessibleSelectionFromContextMethod == 0");
4691     }
4692 }
4693 
4694 void
4695 AccessBridgeJavaEntryPoints::selectAllAccessibleSelectionFromContext(jobject accessibleContext) {
4696     jthrowable exception;
4697 
4698     PrintDebugString("\r\nCalling AccessBridgeJavaEntryPoints::selectAllAccessibleSelectionFromContext(%p):", accessibleContext);
4699 
4700     // Select all children (if possible) of the AccessibleSelection
4701     if (selectAllAccessibleSelectionFromContextMethod != (jmethodID) 0) {
4702         jniEnv->CallVoidMethod(accessBridgeObject,
4703                                selectAllAccessibleSelectionFromContextMethod,
4704                                accessibleContext);
4705         EXCEPTION_CHECK_VOID("Doing selectAllAccessibleSelection - call to CallVoidMethod()");
4706         PrintDebugString("  returned from CallObjectMethod()");
4707     } else {
4708         PrintDebugString("  Error! either env == 0 or selectAllAccessibleSelectionFromContextMethod == 0");
4709     }
4710 }
4711 
4712 
4713 /********** Event Notification Registration routines ***************/
4714 
4715 BOOL
4716 AccessBridgeJavaEntryPoints::addJavaEventNotification(jlong type) {
4717     jthrowable exception;
4718 
4719     PrintDebugString("\r\n  in AccessBridgeJavaEntryPoints::addJavaEventNotification(%016I64X);", type);
4720 
4721     // Let AccessBridge know we want to add an event type
4722     if (addJavaEventNotificationMethod != (jmethodID) 0) {
4723         jniEnv->CallVoidMethod(accessBridgeObject,
4724                                addJavaEventNotificationMethod, type);
4725         EXCEPTION_CHECK("Doing addJavaEventNotification - call to CallVoidMethod()", FALSE);
4726     } else {
4727         PrintDebugString("  Error! either env == 0 or addJavaEventNotificationMethod == 0");
4728         return FALSE;
4729     }
4730     return TRUE;
4731 }
4732 
4733 BOOL
4734 AccessBridgeJavaEntryPoints::removeJavaEventNotification(jlong type) {
4735     jthrowable exception;
4736 
4737     PrintDebugString("\r\n  in AccessBridgeJavaEntryPoints::removeJavaEventNotification(%016I64X):", type);
4738 
4739     // Let AccessBridge know we want to remove an event type
4740     if (removeJavaEventNotificationMethod != (jmethodID) 0) {
4741         jniEnv->CallVoidMethod(accessBridgeObject,
4742                                removeJavaEventNotificationMethod, type);
4743         EXCEPTION_CHECK("Doing removeJavaEventNotification - call to CallVoidMethod()", FALSE);
4744     } else {
4745         PrintDebugString("  Error! either env == 0 or removeJavaEventNotificationMethod == 0");
4746         return FALSE;
4747     }
4748     return TRUE;
4749 }
4750 
4751 BOOL
4752 AccessBridgeJavaEntryPoints::addAccessibilityEventNotification(jlong type) {
4753     jthrowable exception;
4754 
4755     PrintDebugString("\r\n  in AccessBridgeJavaEntryPoints::addAccessibilityEventNotification(%016I64X);", type);
4756 
4757     // Let AccessBridge know we want to add an event type
4758     if (addAccessibilityEventNotificationMethod != (jmethodID) 0) {
4759         PrintDebugString("\r\n     addAccessibilityEventNotification: calling void method: accessBridgeObject = %p", accessBridgeObject);
4760         jniEnv->CallVoidMethod(accessBridgeObject,
4761                                addAccessibilityEventNotificationMethod, type);
4762         EXCEPTION_CHECK("Doing addAccessibilityEvent - call to CallVoidMethod()", FALSE);
4763     } else {
4764         PrintDebugString("  Error! either env == 0 or addAccessibilityEventNotificationMethod == 0");
4765         return FALSE;
4766     }
4767     PrintDebugString("\r\n     addAccessibilityEventNotification: just returning true");
4768     return TRUE;
4769 }
4770 
4771 BOOL
4772 AccessBridgeJavaEntryPoints::removeAccessibilityEventNotification(jlong type) {
4773     jthrowable exception;
4774 
4775     PrintDebugString("\r\n  in AccessBridgeJavaEntryPoints::removeAccessibilityEventNotification(%016I64X):", type);
4776 
4777     // Let AccessBridge know we want to remove an event type
4778     if (removeAccessibilityEventNotificationMethod != (jmethodID) 0) {
4779         jniEnv->CallVoidMethod(accessBridgeObject,
4780                                removeAccessibilityEventNotificationMethod, type);
4781         EXCEPTION_CHECK("Doing removeAccessibilityEvent - call to CallVoidMethod()", FALSE);
4782     } else {
4783         PrintDebugString("  Error! either env == 0 or removeAccessibilityEventNotificationMethod == 0");
4784         return FALSE;
4785     }
4786     return TRUE;
4787 }