/// <summary> /// Creats a group object /// </summary> /// <returns>The Shape observer for the newly created group or <c>null</c>.</returns> private OoShapeObserver createGroup() { OoShapeObserver group = null; OoAccessibleDocWnd draw = null; OoDrawPagesObserver doc = null; OoDrawPageObserver page = null; if (IsShapeSelected && LastSelectedShape != null) { page = LastSelectedShape.Page; doc = page.PagesObserver; draw = doc.DocWnd; } else { // TODO: how to get those things } if (doc != null && draw != null && draw.DrawPageSupplier != null) { Logger.Instance.Log(LogPriority.DEBUG, this, "[NOTICE]\t[DRAWING]\t[CREATE]\t" + "build group shape"); var grpShape = OoDrawUtils.CreateGroupShape_anonymous(draw.DrawPageSupplier); OoUtils.SetStringProperty(grpShape, "Name", LL.GetTrans("tangram.oomanipulation.shape.group")); if (page != null && page.DrawPage_anonymouse != null) { var pageObj = page.DrawPage_anonymouse; OoDrawUtils.AddShapeToDrawPageUndoable(grpShape, pageObj, draw.DrawPageSupplier); group = doc.RegisterNewShape(grpShape); } } return(group); }
/// <summary> /// Groups the current selected obejct into a group /// </summary> /// <returns><c>true</c> if the shape was added to a group successfully; otherwise, <c>false</c>.</returns> private bool grouping() { if (IsShapeSelected && LastSelectedShape != null) { OoAccessibleDocWnd draw = null; OoDrawPagesObserver doc = null; OoDrawPageObserver page = null; page = LastSelectedShape.Page; if (page != null) { doc = page.PagesObserver; if (doc != null) { draw = doc.DocWnd; if (draw != null && draw.DrawPageSupplier != null) { var undoManager = draw.DrawPageSupplier; if (_group == null) // start grouping { _group = createGroup(); } if (_group != null && _group.IsGroup) { // set Title bar // size & position var size = LastSelectedShape.Size; var pos = LastSelectedShape.Position; // TODO: check if this is a group if (OoDrawUtils.AddShapeToGroupUndoable(_group.DomShape, LastSelectedShape.DomShape, undoManager, "Add shape to group")) { LastSelectedShape.Size = size; LastSelectedShape.Position = pos; var b = _group.Bounds; _group.Position = b.Location; play(LL.GetTrans("tangram.oomanipulation.group.added", OoElementSpeaker.GetElementAudioText(LastSelectedShape)), false); LastSelectedShape = _group; // sayLastSelectedShape(false); return(true); } return(false); } } } } } return(false); }
/// <summary> /// Builds an Observer class for the specific shape type. /// </summary> /// <param name="s">The shape to observe.</param> /// <param name="page">The page the shape is placed on.</param> /// <param name="parent">The parent shape if the shape is part of a group.</param> /// <returns> /// An shape observer class for the specific shape type. /// </returns> internal static OoShapeObserver BuildShapeObserver(XShape s, OoDrawPageObserver page, OoShapeObserver parent) { if (s != null && page != null) { if (OoUtils.ElementSupportsService(s, OO.Services.DRAW_SHAPE_CUSTOM)) { return(new OoCustomShapeObserver(s, page, parent)); } // normal shape return(new OoShapeObserver(s, page, parent)); } return(null); }
/// <summary> /// Gets the last shape of document. /// </summary> /// <param name="doc">The doc.</param> /// <param name="pages">The pages.</param> /// <returns></returns> public static OoShapeObserver GetLastShapeOfDocument(OoAccessibleDocWnd doc, OoDrawPageObserver pages = null) { if (doc != null) { if (pages == null) { pages = doc.GetActivePage(); } if (pages != null && doc.DocumentComponent != null && doc.DocumentComponent.ChildCount > 0) { // a page doesn't have children in the accessible tree --> damn // so we have to go through the shape structure return(pages.GetLastChild()); } else { Logger.Instance.Log(LogPriority.DEBUG, "AccDomWalker", "The document to walk through seems to have no child shapes"); } } return(null); }
/// <summary> /// Gets the page bounds and position on the screen in pixels. /// </summary> /// <param name="activePage">The active page to get the position on the screen of.</param> /// <returns>The bounds of the given page on the screen.</returns> public static Rectangle GetPageBoundsAndPosition(OoDrawPageObserver activePage) { Rectangle pos = new Rectangle(); if (activePage != null) { System.Drawing.Rectangle pageBoundsInPx = OoDrawUtils.convertToPixel( new System.Drawing.Rectangle( -activePage.PagesObserver.ViewOffset.X + activePage.BorderLeft, -activePage.PagesObserver.ViewOffset.Y + activePage.BorderTop, activePage.Width - activePage.BorderLeft - activePage.BorderRight, activePage.Height - activePage.BorderTop - activePage.BorderBottom), activePage.PagesObserver.ZoomValue, OoDrawPagesObserver.PixelPerMeterY, OoDrawPagesObserver.PixelPerMeterY); pos = new Rectangle(pageBoundsInPx.X, pageBoundsInPx.Y, pageBoundsInPx.Width, pageBoundsInPx.Height); } return(pos); }
/// <summary> /// Gets the OoShapeObserver for an accessible if already registered. /// </summary> /// <param name="accComp">The acc comp to get the observer for.</param> /// <param name="page">The page observer to search the observer in.</param> /// <returns>The related OoShapeObserver if already registered</returns> private static OoShapeObserver getObserverForAccessible(OoAccComponent accComp, OoDrawPageObserver page) { if (accComp != null && accComp.IsValid() && page != null) { var pObs = page.PagesObserver; if (pObs != null) { OoShapeObserver sObs = pObs.GetRegisteredShapeObserver(accComp); if (sObs == null) // shape is not registered { page.Update(); // try to do it better for the next term AudioRenderer.Instance.PlayWaveImmediately(StandardSounds.Error); ////TODO: try to get the parent return(null); } return(sObs); } else { Logger.Instance.Log(LogPriority.DEBUG, "OpenOfficeDrawShapeManipulator", "[ERROR] can't get the pages observer to get a ShapeObserver for the next item"); } } return(null); }
/// <summary> /// Gets the shape for modification from the given Draw page child object. /// </summary> /// <param name="c">The component to search its shape observer for [<see cref="OoAccComponent"/>], [<see cref="OoShapeObserver"/>], [XShape].</param> /// <param name="observed">The observed window / draw document.</param> /// <param name="silent">if set to <c>true</c> no audio feedback about the selection is given.</param> /// <param name="immediatly">if set to <c>true</c> the audio feedback is immediately given and all other audio feedback is aborted.</param> /// <returns>The corresponding registered shape observer</returns> public OoShapeObserver GetShapeForModification(Object c, OoAccessibleDocWnd observed, OoDrawPageObserver page = null, bool silent = false, bool immediately = true) { if (c is OoAccComponent) { return(GetShapeForModification(c as OoAccComponent, observed, silent, immediately)); } else if (c is OoShapeObserver) { return(GetShapeForModification(c as OoShapeObserver, observed, silent, immediately)); } else if (observed != null) { return(observed.GetRegisteredShapeObserver(c, page != null ? page : observed.GetActivePage())); } return(null); }
/// <summary> /// Builds an Observer class for the specific shape type. /// </summary> /// <param name="s">The shape to observe.</param> /// <param name="page">The page the shape is placed on.</param> /// <returns>An shape observer class for the specific shape type.</returns> internal static OoShapeObserver BuildShapeObserver(XShape s, OoDrawPageObserver page) { return(BuildShapeObserver(s, page, null)); }
/// <summary> /// Builds an Observer class for the specific shape type. /// </summary> /// <param name="s">The shape to observe.</param> /// <param name="page">The page the shape is placed on.</param> /// <param name="parent">The parent shape if the shape is part of a group.</param> /// <returns> /// An shape observer class for the specific shape type. /// </returns> public static OoShapeObserver BuildShapeObserver(Object s, OoDrawPageObserver page, OoShapeObserver parent) { return(BuildShapeObserver(s as XShape, page, parent)); }