/// <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>
 /// 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 infos about the amount of pages and the current page number of a window.
        /// </summary>
        /// <param name="win">The DRAW doc window.</param>
        /// <returns>a String of type ' X/Y', where X is the current page and Y the amount of pages; otherwise the empty string.</returns>
        private static string getPageNumInfosOfWindow(OoAccessibleDocWnd win)
        {
            String result = String.Empty;

            if (win != null)
            {
                int pC = win.GetPageCount();
                if (pC > 1)
                {
                    var aPObs = win.GetActivePage();
                    if (aPObs != null)
                    {
                        int cP = aPObs.GetPageNum();
                        if (cP > 0)
                        {
                            result += " " + cP + "/" + pC;
                        }
                    }
                }
            }
            return(result);
        }
Exemple #4
0
        /// <summary>
        /// Get a list of available Observers of elements containing text. This listed is cached.
        /// </summary>
        /// <returns>a cached list of text containing elements</returns>
        private List <TextElemet> getAllTextElementsOfDoc()
        {
            if (_textGetting)
            {
                return(cachedtextElements);
            }

            _textGetting = true;

            try
            {
                List <TextElemet>  textElements = new List <TextElemet>();
                OoAccessibleDocWnd doc          = null;
                try
                {
                    doc = OoConnector.Instance.Observer.GetActiveDocument();
                }
                catch (System.Exception ex)
                {
                    Logger.Instance.Log(LogPriority.DEBUG, this, "[ERROR] can't get active DRAW document", ex);
                }

                if (doc != null)
                {
                    //check for caching
                    DateTime now = DateTime.Now;

                    if (doc != lastCachedDoc || (now - lastCache > cachingPeriode))
                    {
                        // get text elements
                        var pageObs = doc.GetActivePage();

                        if (pageObs != null)
                        {
                            // clone the list to enable disposing of elements from the list without destroying the iterator
                            List <OoShapeObserver> shapes = new List <OoShapeObserver>(pageObs.shapeList);

                            if (shapes != null && shapes.Count > 0)
                            {
                                foreach (OoShapeObserver shape in shapes)
                                {
                                    if (shape != null && !shape.Disposed)
                                    {
                                        // if()
                                        if (shape.HasText && shape.IsVisible())
                                        {
                                            textElements.Add(new TextElemet(shape));
                                        }
                                        //else
                                        //{
                                        //    //if (!shape.IsValid())
                                        //    shape.Dispose();
                                        //}
                                    }
                                }
                            }

                            // cache
                            lastCache          = now;
                            lastCachedDoc      = doc;
                            cachedtextElements = textElements;
                        }
                    }
                }

                return(cachedtextElements);
            }
            finally
            {
                _textGetting = false;
            }
        }