private void setAccessibleCounterpart(OoShapeObserver shape) { if (shape != null) { string oldName = shape.Name; string newName = shape.Name + "_" + shape.GetHashCode() + " "; shape.Name = newName; unoidl.com.sun.star.accessibility.XAccessible counterpart = null; if (shape.Parent != null && shape.Parent.AcccessibleCounterpart != null) { counterpart = OoAccessibility.GetAccessibleCounterpartFromHash(shape.Shape, shape.Parent.AcccessibleCounterpart as unoidl.com.sun.star.accessibility.XAccessibleContext); } else { counterpart = OoAccessibility.GetAccessibleCounterpartFromHash(shape.Shape, Document.AccComp as unoidl.com.sun.star.accessibility.XAccessibleContext); } if (counterpart != null) { shape.AcccessibleCounterpart = counterpart; } shape.Name = oldName; } }
virtual public void Update() { if (isUpdating || (DateTime.Now - lastUpdateTime).TotalMilliseconds < 100) { return; } lock (SynchLock) { try { isUpdating = true; if (!IsValid(true)) { return; } //TODO: update informations //throw new NotImplementedException(); if (AcccessibleCounterpart == null) { if (Page != null && Page.PagesObserver != null && Page.PagesObserver.Document != null) { AcccessibleCounterpart = OoAccessibility.GetAccessibleCounterpartFromHash(Shape, Page.PagesObserver.Document.AccCont); } //{ // var childs = OoAccessibility.GetAllChildrenOfAccessibleObject(Page.PagesObserver.Document.AccCont as XAccessible); // string current_name = String.Empty; // bool success = TimeLimitExecutor.WaitForExecuteWithTimeLimit(1000, () => { current_name = Name; }); // if (String.IsNullOrEmpty(current_name)) // { // isUpdating = false; // lastUpdateTime = DateTime.Now; // return; // } // // foreach (var c in childs) { System.Diagnostics.Debug.WriteLine(OoAccessibility.GetAccessibleNamePart(c as XAccessible)); } // foreach (var child in childs) // { // if (child is XAccessible) // { // if (OoUtils.ElementSupportsService(child, OO.Services.DRAWING_ACCESSIBLE_SHAPE)) // { // if (child is XAccessibleComponent) // { // var size = ((XAccessibleComponent)child).getSize(); // if (size.Width <= 0 || size.Height <= 0) // continue; // } // // get AccessibleName leads to hang ons // var name = OoAccessibility.GetAccessibleNamePart(child as XAccessible); // if (name.Equals(current_name)) // { // // TODO: check other/better possibilities // try // change name and check if the name is changed in the accessible view too // { // if (Shape != null) // { // string oldName = OoUtils.GetStringProperty(Shape, "Name"); // string newName = this.GetHashCode() + " "; // OoUtils.SetStringProperty(Shape, "Name", newName); // System.Threading.Thread.Sleep(5); // string accName = OoAccessibility.GetAccessibleName(child as XAccessible); // if (accName.StartsWith(newName)) // { // AcccessibleCounterpart = child; // OoUtils.SetStringProperty(Shape, "Name", oldName); // break; // } // else // { // OoUtils.SetStringProperty(Shape, "Name", oldName); // continue; // } // } // } // catch (Exception) // { // } // AcccessibleCounterpart = child; // break; // } // } // } // } //} } if (_ppObs != null) { _ppObs.Update(); } // update polypolygon points } catch (Exception ex) { } finally { // TODO: update children isUpdating = false; lastUpdateTime = DateTime.Now; } } }