private bool tryGetSelection(OoAccessibleDocWnd doc, out List <OoShapeObserver> selectedShapesList) { //System.Diagnostics.Debug.WriteLine(" ---> try Get Selection (inner critical Call)"); selectedShapesList = new List <OoShapeObserver>(); bool success = false; // check the global selection supplier if (doc != null) { try { var controller = doc.Controller; if (controller != null && controller is XSelectionSupplier) { Object selection = OoSelectionObserver.GetSelection(controller as XSelectionSupplier); XShapes selectedShapes = selection as XShapes; OoDrawPagesObserver pagesObserver = doc.DrawPagesObs; if (selectedShapes != null && pagesObserver != null) { int count = selectedShapes.getCount(); for (int i = 0; i < count; i++) { XShape shape = selectedShapes.getByIndex(i).Value as XShape; if (shape != null) { OoShapeObserver shapeObserver = pagesObserver.GetRegisteredShapeObserver(shape, null); if (shapeObserver != null) { selectedShapesList.Add(shapeObserver); } } } success = true; } else { // no selection if (selection is bool && ((bool)selection) == false) { success = false; } else if (pagesObserver != null) { success = true; } } } } catch (unoidl.com.sun.star.lang.DisposedException ex) { System.Diagnostics.Debug.WriteLine(ex.Source + " " + ex.Message); } } //System.Diagnostics.Debug.WriteLine(" ---> ~~~~~~~~~ (" + success + ") GET Selection for WND: " + doc + " result in " + selectedShapesList.Count + " selected Items."); return(success); }
private System.Timers.Timer refreshPagePropertiesTimer; // e.g. every 2.5s #endregion #endregion #region Constructor / Destructor /// <summary> /// Initializes a new instance of the <see cref="OoDrawPageObserver"/> class. /// </summary> /// <param name="dp">The DOM page object to observe</param> /// <param name="parent">The parent obeserver for all pages in this DRAW document.</param> public OoDrawPageObserver(XDrawPage dp, OoDrawPagesObserver parent) : base() { Logger.Instance.Log(LogPriority.DEBUG, this, "Create new PageObserver"); DrawPage = dp; PagesObserver = parent; setAccessibleCounterpart(); handleChildren(); registerListeners(); }
private System.Timers.Timer refreshPagePropertiesTimer; // e.g. every 2.5s #endregion #endregion /// <summary> /// Initializes a new instance of the <see cref="OoDrawPageObserver"/> class. /// </summary> /// <param name="dp">The DOM page object to observe</param> /// <param name="parent">The parent obeserver for all pages in this DRAW document.</param> public OoDrawPageObserver(XDrawPage dp, OoDrawPagesObserver parent) : base() { Logger.Instance.Log(LogPriority.DEBUG, this, "Create new PageObserver"); DrawPage = dp; PagesObserver = parent; setAccessibleCounterpart(); handleChildren(); registerListeners(); }
/// <summary> /// Try to find the corresponding XDrawPageSupplier to the given Window. /// </summary> private bool getXDrawPageSupplier() { if (_dpsSerach) { while (_dpsSerach) { Thread.Sleep(10); } return true; } _dpsSerach = true; try { List<XDrawPagesSupplier> dps = OoDrawUtils.GetDrawPageSuppliers(OO.GetDesktop()); if (dps.Count > 0) { foreach (var item in dps) { //string runtimeID = OoUtils.GetStringProperty(item, "RuntimeUID"); //string buildID = OoUtils.GetStringProperty(item, "BuildId"); XAccessible acc = OoDrawUtils.GetXAccessibleFromDrawPagesSupplier(item); if (acc != null) { var root = OoAccessibility.GetRootPaneFromElement(acc); if (root != null) { if (root.Equals(MainWindow)) { Logger.Instance.Log(LogPriority.DEBUG, this, "XDrawPageSuppliere found!!"); DrawPageSupplier = item; //prepareForSelection(item); // Bad hack for getting accessible selection events DrawPagesObs = new OoDrawPagesObserver(DrawPageSupplier as XDrawPagesSupplier, DocumentComponent, this); return true; } else { Logger.Instance.Log(LogPriority.OFTEN, this, "[ERROR] - Can't find root element from DrawPagesSupplier (root is not MainWindow)"); } } else { Logger.Instance.Log(LogPriority.OFTEN, this, "[ERROR] - Can't find root element from DrawPagesSupplier (root is null)"); } } else { Logger.Instance.Log(LogPriority.OFTEN, this, "[ERROR] - Can't find XAccessible for DrawPagesSupplier (root is null)"); } } } Logger.Instance.Log(LogPriority.ALWAYS, this, "[FATAL ERROR] cannot find XDrawPageSuppliere for window"); return false; } finally { _dpsSerach = false; } }