/// <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); }
void doc_AccessibleEvent(object sender, OoAccessibleDocAccessibleEventArgs e) { if (sender != null && sender is OoAccessibleDocWnd && e != null && e.E != null) { tud.mci.tangram.Accessibility.AccessibleEventId id = OoAccessibility.GetAccessibleEventIdFromShort(e.E.EventId); handleAccessibleEvent(sender as OoAccessibleDocWnd, id, e.E); } }
void tpwndo_WindowOpened(object sender, OoEventArgs e) { //check if window is a draw doc if (e != null && e.Source != null && e.Source is XAccessible) { var doc = OoAccessibility.IsDrawWindow(e.Source as XAccessible); if (doc != null && !(doc is bool)) { registerNewDrawWindow(e.Source as XAccessible, doc); } } }
/// <summary> /// find the corresponding accessible counterpart object for this page in the accessible tree /// </summary> private void setAccessibleCounterpart() { String name = OoUtils.GetStringProperty(DrawPage, "LinkDisplayName"); name = "PageShape: " + name; //TODO: find a more general way XAccessible accCounter = OoAccessibility.GetAccessibleChildWithName(name, PagesObserver.Document.AccComp as unoidl.com.sun.star.accessibility.XAccessibleContext); if (accCounter != null) { AcccessibleCounterpart = accCounter; } }
protected override void notifyEvent(AccessibleEventObject aEvent) { var id = OoAccessibility.GetAccessibleEventIdFromShort(aEvent.EventId); switch (id) { case tud.mci.tangram.Accessibility.AccessibleEventId.CHILD: handleChild(aEvent.Source, aEvent.NewValue, aEvent.OldValue); break; default: break; } }
private void stateChanged(OoAccessibleDocWnd doc, AccessibleEventObject aEvent) { if (doc != null && aEvent != null) { if (aEvent.Source != null) { // fire window activated when document gets mouse focus var role = OoAccessibility.GetAccessibleRole(aEvent.Source as XAccessible); if (role == Accessibility.AccessibleRole.DOCUMENT) { if (OoAccessibility.HasAccessibleState(aEvent.Source as XAccessible, Accessibility.AccessibleStateType.FOCUSED)) { fireDrawWindowActivatedEvent(doc); } } } } }
void tpwndo_WindowActivated(object sender, OoEventArgs e) { if (e != null && e.Source != null && e.Source is XAccessible) { OoAccessibleDocWnd doc = getCorrespondingAccessibleDocForXaccessible(e.Source as XAccessible); if (doc != null && doc.MainWindow != null) { fireDrawWindowActivatedEvent(doc); } else { var docObj = OoAccessibility.IsDrawWindow(e.Source as XAccessible); if (docObj != null && !(docObj is bool)) { registerNewDrawWindow(e.Source as XAccessible, docObj); } } } }
private void initalize() { #region OoTopWindowObserver initialization try { tpwndo.WindowActivated += new EventHandler <OoEventArgs>(tpwndo_WindowActivated); //tpwndo.Disposing += new EventHandler<OoEventArgs>(tpwndo_Disposing); tpwndo.WindowClosed += new EventHandler <OoEventArgs>(tpwndo_WindowClosed); //tpwndo.WindowClosing += new EventHandler<OoEventArgs>(tpwndo_WindowClosing); //tpwndo.WindowDeactivated += new EventHandler<OoEventArgs>(tpwndo_WindowDeactivated); tpwndo.WindowMinimized += new EventHandler <OoEventArgs>(tpwndo_WindowMinimized); tpwndo.WindowNormalized += new EventHandler <OoEventArgs>(tpwndo_WindowNormalized); tpwndo.WindowOpened += new EventHandler <OoEventArgs>(tpwndo_WindowOpened); } catch (System.Exception ex) { Logger.Instance.Log(LogPriority.ALWAYS, this, "Accessibility Observer TopWindowObserever initialization failed", ex); } #endregion #region TopWindow initialization var tpwnds = OoAccessibility.GetAllTopWindows(); foreach (var item in tpwnds) { tpwndo_WindowOpened(this, new OoEventArgs(item)); } initalized = true; var actTpwnd = OoAccessibility.GetActiveTopWindow(); if (actTpwnd != null) { tpwndo_WindowActivated(this, new OoEventArgs(actTpwnd)); } #endregion }
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; } }
/// <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); }
/// <summary> /// Gets all OpenOffice top windows. /// </summary> /// <returns>List of top windows.</returns> public static List <Object> GetAllTopWindows() { return(OoAccessibility.GetAllTopWindows()); }
/// <summary> /// Gets the active OpenOffice top window. /// </summary> /// <returns>The current active top window object.</returns> public static Object GetActiveTopWindow() { return(OoAccessibility.GetActiveTopWindow()); }
/// <summary> /// Registers a new draw window. /// </summary> /// <param name="source">The source.</param> /// <param name="dw">The dw.</param> private void registerNewDrawWindow(XAccessible source, Object dw) { if (source != null && dw != null && !dw.Equals(false)) { Logger.Instance.Log(LogPriority.DEBUG, this, "Draw window check: '" + OoAccessibility.GetAccessibleName(source)); if (getCorrespondingAccessibleDocForXaccessible(source) == null) { Logger.Instance.Log(LogPriority.DEBUG, this, "Register new Draw window: '" + OoAccessibility.GetAccessibleName(source)); OoAccessibleDocWnd doc = new OoAccessibleDocWnd(source, dw as XAccessible); drawWnds[source] = doc; // add main window to list if (doc.Document != null) { drawDocs[source] = doc; } if (doc.DocumentWindow != null) { drawDocWnds[doc.DocumentWindow] = doc; } //drawPgSuppl.Clear(); //drawPgSuppl.AddRange(OoDrawUtils.GetDrawPageSuppliers(OO.GetDesktop())); //TODO: call the observers addListeners(doc); fireDrawWindowOpendEvent(doc); } } }
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; } } }