XShape getNextSiblingByXShape() { if (Shape != null && Shape is XChild) { XShapes parent = getParentByXShape(); if (parent != null && parent.hasElements()) { int childCount = ((XShapes)parent).getCount(); if (childCount > 0) { //string current_name = Name; bool lastWasCurrent = false; //find this child for (int i = 0; i < childCount; i++) { var c = parent.getByIndex(i).Value; if (lastWasCurrent && c != null && c is XShape) { return(c as XShape); } if (c == Shape) { lastWasCurrent = true; } } // if no child was in front, return the las child at all return(getChildByXShape(0, parent as XShapes)); } } } return(null); }
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); }