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); }
/// <summary> /// Tries to get the parent of an XShape. /// </summary> /// <param name="parent">The parent. /// Can be <c>NULL</c> if no parent is available - could bee the case when the /// shape was deleted but not disposed for keeping it in undo/history</param> /// <param name="shape">The shape.</param> /// <returns><c>true</c> if the parent could been get, otherwise <c>false</c></returns> /// <remarks>This function is time limited to 200 ms.</remarks> bool tryGetParentByXShape(out XShapes parent, XShape shape = null) { bool success = false; XShapes par = null; TimeLimitExecutor.WaitForExecuteWithTimeLimit(200, () => { if (shape == null) { shape = Shape; } if (shape != null && shape is XChild) { var Parent = ((XChild)shape).getParent(); if (Parent != null) { par = Parent as XShapes; success = true; } } }, "GetParent"); parent = par; return(success); }
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); }
/// <summary> /// Goes to the parent in DOM if possible. /// </summary> /// <returns>The observer for the direct parent or <c>null</c> if no parent could be found.</returns> virtual public OoShapeObserver GetParent() { if (this.Page != null && this.Page.PagesObserver != null) { XShapes s = getParentByXShape(); return(getShapeObserverFromXShape(s as XShape)); } return(null); }
/// <summary> /// Gets the child by X shape. /// </summary> /// <param name="index">The index.</param> XShape getChildByXShape(int number, XShapes shape = null) { if (shape == null) { shape = Shape as XShapes; } if (shape != null && shape is XShapes && ((XShapes)shape).hasElements()) { int cCount = ((XShapes)shape).getCount(); number = mod(number, cCount); return(((XShapes)shape).getByIndex(number).Value as XShape); } return(null); }
/// <summary> /// Gets the previous sibling by X shape. /// </summary> XShape getPreviousSiblingByXShape() { if (Shape != null && Shape is XChild) { XShapes parent = getParentByXShape(); if (parent != null && parent.hasElements()) { int childCount = parent.getCount(); if (childCount > 0) { //string current_name = Name; XShape lastChild = null; //find this child for (int i = 0; i < childCount; i++) { var c = ((XShapes)parent).getByIndex(i).Value; if (c == Shape) { if (lastChild != null) { return(lastChild); } } else if (c is XShape) { lastChild = c as XShape; } } // if no child was in front, return the las child at all return(getChildByXShape(-1, parent as XShapes)); } } } return(null); }
public void Children_Not_Null() { var target = new XShapes(); Assert.NotNull(target.Children); }
public void Inherits_From_ObservableResource() { var target = new XShapes(); Assert.True(target is ObservableResource); }
/// <summary> /// Gets the child by X shape. /// </summary> /// <param name="index">The index.</param> XShape getChildByXShape(int number, XShapes shape = null) { if (shape == null) shape = Shape as XShapes; if (shape != null && shape is XShapes && ((XShapes)shape).hasElements()) { int cCount = ((XShapes)shape).getCount(); number = mod(number, cCount); return ((XShapes)shape).getByIndex(number).Value as XShape; } return null; }
/// <summary> /// Tries to get the parent of an XShape. /// </summary> /// <param name="parent">The parent. /// Can be <c>NULL</c> if no parent is available - could bee the case when the /// shape was deleted but not disposed for keeping it in undo/history</param> /// <param name="shape">The shape.</param> /// <returns><c>true</c> if the parent could been get, otherwise <c>false</c></returns> bool tryGetParentByXShape(out XShapes parent, XShape shape = null) { bool success = false; XShapes par = null; TimeLimitExecutor.WaitForExecuteWithTimeLimit(200, () => { if (shape == null) shape = Shape; if (shape != null && shape is XChild) { var Parent = ((XChild)shape).getParent(); if (Parent != null) { par = Parent as XShapes; success = true; } } }, "GetParent"); parent = par; return success; }
/// <summary> /// Removes the shape from the draw page or an other shape group. /// </summary> /// <param name="shape">The shape.</param> /// <param name="page">The page.</param> internal static void RemoveShapeFromDrawPage(XShape shape, XShapes page) { if (shape != null && page != null) { try { ((XShapes)page).remove(shape); } catch { } } }
/// <summary> /// Adds a shape to a draw page or an other shape group. /// </summary> /// <param name="shape">The shape.</param> /// <param name="page">The page.</param> internal static void AddShapeToDrawPage(XShape shape, XShapes page) { if (shape != null && page != null) { try { ((XShapes)page).add(shape); } catch { } } }