/// <summary> /// Gets the registered shape observer. /// </summary> /// <param name="shape">The shape.</param> /// <returns></returns> internal OoShapeObserver GetRegisteredShapeObserver(unoidl.com.sun.star.accessibility.XAccessibleContext shape) { if (shape == null) { return(null); } if (accshapes.ContainsKey(shape)) { return(accshapes[shape]); } String name = OoAccessibility.GetAccessibleName(shape); String desc = OoAccessibility.GetAccessibleDesc(shape); OoShapeObserver sObs = searchRegisterdSapeObserverByAccessibleName(name, shape); if (sObs != null) { // TODO: handle what? } else { //shape is unknown or the name was changed!! Logger.Instance.Log(LogPriority.IMPORTANT, this, "Asking for a not registered Element '" + name + "' "); } return(sObs); }
/// <summary> /// Check if the accessible object is corresponding to the given shape observer. /// </summary> /// <param name="acc">The accessible object to test.</param> /// <param name="sObs">The shape observer to test.</param> /// <returns><c>true</c> if the acc is related to changes in the observer. If this is true, /// the AccessibleCounterpart field of the OoShapeObserver is updated as well</returns> internal static bool AccCorrespondsToShapeObserver(XAccessible acc, OoShapeObserver sObs) { bool result = false; if (acc != null && sObs != null) { String hash = sObs.GetHashCode().ToString() + "_"; if (sObs.IsText) { // use description string oldDescription = sObs.Description; sObs.Description = hash + oldDescription; if (OoAccessibility.GetAccessibleDesc(acc).StartsWith(hash)) { result = true; } sObs.Description = oldDescription; } else { // use name string oldName = sObs.Name; sObs.Name = hash + oldName; if (OoAccessibility.GetAccessibleName(acc).StartsWith(hash)) { result = true; } sObs.Name = oldName; } } if (result) { sObs.AcccessibleCounterpart = acc; } return(result); }