/// <summary>
        /// Try to get the active OpenOffice document window.
        /// Check the ScreenObserver for his window otherwise uses the first
        /// of all observed documents.
        /// </summary>
        /// <returns></returns>
        public OoAccessibleDocWnd GetActiveDocument()
        {
            // check the screen observer
            // return the document that is currently observed and therefor shown on the output device.
            if (WindowManager.Instance != null)
            {
                ScreenObserver so = WindowManager.Instance.ScreenObserver;
                if (so != null)
                {
                    IntPtr whndl = so.Whnd;
                    if (whndl != null && whndl != IntPtr.Zero)
                    {
                        OoObserver obs = OoConnector.Instance.Observer;
                        if (obs != null)
                        {
                            OoAccessibleDocWnd doc = obs.ObservesWHndl(whndl.ToInt32());
                            if (doc != null)
                            {
                                return(doc);
                            }
                        }
                    }
                }
            }
            else
            {
                Logger.Instance.Log(LogPriority.IMPORTANT, this, "[FATAL ERROR] An instance of the WindowManager singleton could not been achieved!");
            }

            // get all observed documents -- choose the first
            var docs = OoDrawAccessibilityObserver.Instance.GetDrawDocs();

            if (docs.Count > 0)
            {
                if (docs.Count == 1)
                {
                    return(docs[0]);
                }
                else
                {
                    // can not decide which one is the one to use ...
                    //foreach (var doc in docs)
                    //{
                    //    Debug.GetAllInterfacesOfObject(doc.DocumentWindow);
                    //    var set = tud.mci.tangram.Accessibility.OoAccessibility.GetAccessibleStates(doc.MainWondow.getAccessibleContext().getAccessibleStateSet());
                    //}

                    return(docs[0]);
                }
            }
            return(null);
        }
Exemple #2
0
        virtual protected Rectangle getPageBounds()
        {
            Rectangle pageBounds = new Rectangle();

            if (WindowManager.Instance != null)
            {
                ScreenObserver obs = WindowManager.Instance.ScreenObserver;
                if (obs != null)
                {
                    Object scPos = obs.ScreenPos;
                    if (scPos != null & scPos is Rectangle)
                    {
                        pageBounds.X      = ((Rectangle)scPos).X;
                        pageBounds.Y      = ((Rectangle)scPos).Y;
                        pageBounds.Width  = ((Rectangle)scPos).Width;
                        pageBounds.Height = ((Rectangle)scPos).Height;
                    }
                }
            }

            return(pageBounds);
        }