Exemplo n.º 1
0
        /// <summary>
        /// Returns all services of the object.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="debug">if set to <c>true</c> the services will be printed
        /// to the System.Diagnostics.Debug output.</param>
        /// <returns>List of all supported service names.</returns>
        /// <remarks>This function is time limited to 200 ms.</remarks>
        public static string[] GetAllServicesOfObject(Object obj, bool debug = true)
        {
            String output = "";

            string[] services = new string[0];
            if (obj != null)
            {
                try
                {
                    TimeLimitExecutor.WaitForExecuteWithTimeLimit(200, () =>
                    {
                        XServiceInfo si = obj as XServiceInfo;
                        if (si != null)
                        {
                            // FIXME: Access violation on service request
                            try
                            {
                                services = si.getSupportedServiceNames();

                                if (debug)
                                {
                                    output += (services.Length + "\tServices:");

                                    foreach (var item in services)
                                    {
                                        output += "\n" + ("\tService: " + item);
                                    }
                                    System.Diagnostics.Debug.WriteLine(output);
                                }
                            }
                            catch (Exception ex) {
                                System.Diagnostics.Debug.WriteLine("Exception happened: " + ex.ToString());
                            }
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("Can't get services of Object because it is not a XServiceInfo provider.");
                        }
                    }, "GetAllServices");
                }
                catch (unoidl.com.sun.star.lang.DisposedException) { OO.CheckConnection(); }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Can't get services of Object: " + e);
                }
            }
            return(services);
        }
Exemplo n.º 2
0
        void IDisposable.Dispose()
        {
            this.refreshPagePropertiesTimer.Stop();
            this.AcccessibleCounterpart = null;

            try { foreach (var oS in shapeList)
                  {
                      oS.Dispose();
                  }
            }
            catch { }

            this.shapeList.Clear();
            Disposed = true;
            fire_DisposingEvent();
            OO.CheckConnection();
        }
        //static readonly Object _selectionLock = new Object();
        /// <summary>
        /// Get the current selection.
        /// </summary>
        /// <param name="selectionSupplier">The selection supplier.</param>
        /// <returns><c>false</c> if no selection could be achieved; otherwise and [XShapes] collection</returns>
        /// <remarks>This request is locked and time limited to 100 ms.</remarks>
        public static Object GetSelection(XSelectionSupplier selectionSupplier)
        {
            Object selection = false;

            if (selectionSupplier != null)
            {
                //FIXME: you cannot do this in a time limited execution this will lead to an hang on -- why??????
                try
                {
                    lock (selectionSupplier)
                    {
                        TimeLimitExecutor.WaitForExecuteWithTimeLimit(100, () =>
                        {
                            Thread.BeginCriticalRegion();
                            var anySelection = selectionSupplier.getSelection();
                            Thread.EndCriticalRegion();

                            if (anySelection.hasValue())
                            {
                                selection = anySelection.Value;
                            }
                            else
                            {
                                selection = null;
                            }
                        }, "GetSelection");
                    }
                }
                catch (DisposedException)
                {
                    Logger.Instance.Log(LogPriority.DEBUG, "OoSelectionObserver", "Selection supplier disposed");
                    OO.CheckConnection();
                }
                catch (ThreadAbortException) { }
                catch (ThreadInterruptedException) { }
            }
            return(selection);
        }