Esempio n. 1
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); }
        }