示例#1
0
        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);
        }
示例#2
0
        private void handleChild(int i, XIndexAccess ia)
        {
            //System.Diagnostics.Debug.WriteLine("[UPDATE] --- handle child [" + i + "]");
            try
            {
                if (PagesObserver != null)
                {
                    lock (_childHandleLock)
                    {
                        var anyShape = ia.getByIndex(i);
                        if (anyShape.hasValue() && anyShape.Value is XShape)
                        {
                            if (PagesObserver.ShapeAlreadyRegistered(anyShape.Value as XShape, this))
                            {
                                //System.Diagnostics.Debug.WriteLine("[UPDATE] Shape " + anyShape.Value + " already exists ");

                                OoShapeObserver so = PagesObserver.GetRegisteredShapeObserver(anyShape.Value as XShape, this);
                                if (so != null)
                                {
                                    so.UpdateChildren();
                                }
                                else
                                {
                                    Logger.Instance.Log(LogPriority.DEBUG, this, "[ERROR] Shape should exist but could not been found!!!");

                                    so = OoShapeObserverFactory.BuildShapeObserver(anyShape.Value, this);  //new OoShapeObserver(anyShape.Value as XShape, this);
                                    //shapeList.Add(so);
                                }
                            }
                            else
                            {
                                //System.Diagnostics.Debug.WriteLine("[UPDATE] New Shape " + anyShape.Value + " will be registered ");
                                OoShapeObserver so = null;
                                try
                                {
                                    if (OoUtils.ElementSupportsService(anyShape.Value, OO.Services.DRAW_SHAPE_TEXT))
                                    {
                                        so = OoShapeObserverFactory.BuildShapeObserver(anyShape.Value, this);  //new OoShapeObserver(anyShape.Value as XShape, this);
                                    }
                                    else
                                    {
                                        so = OoShapeObserverFactory.BuildShapeObserver(anyShape.Value, this);  //new OoShapeObserver(anyShape.Value as XShape, this);
                                        //System.Diagnostics.Debug.WriteLine("[UPDATE] Shape: " + so.Name + " will be registered");
                                    }
                                }
                                catch (unoidl.com.sun.star.uno.RuntimeException ex)
                                {
                                    Logger.Instance.Log(LogPriority.IMPORTANT, this, "[ERROR]  internal while register ShapeObserver", ex);
                                }
                                catch (Exception ex)
                                {
                                    Logger.Instance.Log(LogPriority.IMPORTANT, this, "[FATAL ERROR] can not register ShapeObserver", ex);
                                }
                                //finally
                                //{
                                //    if (so != null) shapeList.Add(so);
                                //}
                            }
                        }
                    }
                }
                else
                {
                    Logger.Instance.Log(LogPriority.DEBUG, this, "[ERROR] PagesObserver is null");
                }
            }
            catch (System.Threading.ThreadAbortException ex) { Logger.Instance.Log(LogPriority.DEBUG, this, "[OO Deadlock] can't get access to children via child handling in DrawPageObserver", ex); }
            catch (Exception ex) { Logger.Instance.Log(LogPriority.DEBUG, this, "can't get access to children via child handling in DrawPageObserver", ex); }
        }