// override object.Equals
        public override bool Equals(object obj)
        {
            //
            // See the full list of guidelines at
            //   http://go.microsoft.com/fwlink/?LinkID=85237
            // and also the guidance for operator== at
            //   http://go.microsoft.com/fwlink/?LinkId=85238
            //

            if (obj == null || GetType() != obj.GetType())
            {
                if (obj is XShape)
                {
                    return(OoUtils.AreOoObjectsEqual(Shape, obj));
                }
                return(false);
            }

            if (base.Equals(obj))
            {
                return(true);
            }

            try
            {
                return(OoUtils.AreOoObjectsEqual(Shape, ((OoShapeObserver)obj).Shape));
            }
            catch
            {
                return(false);
            }
        }
        /// <summary>
        /// Creats a group object
        /// </summary>
        /// <returns>The Shape observer for the newly created group or <c>null</c>.</returns>
        private OoShapeObserver createGroup()
        {
            OoShapeObserver group = null;

            OoAccessibleDocWnd  draw = null;
            OoDrawPagesObserver doc  = null;
            OoDrawPageObserver  page = null;

            if (IsShapeSelected && LastSelectedShape != null)
            {
                page = LastSelectedShape.Page;
                doc  = page.PagesObserver;
                draw = doc.DocWnd;
            }
            else
            {
                // TODO: how to get those things
            }

            if (doc != null && draw != null && draw.DrawPageSupplier != null)
            {
                Logger.Instance.Log(LogPriority.DEBUG, this, "[NOTICE]\t[DRAWING]\t[CREATE]\t" + "build group shape");
                var grpShape = OoDrawUtils.CreateGroupShape_anonymous(draw.DrawPageSupplier);
                OoUtils.SetStringProperty(grpShape, "Name", LL.GetTrans("tangram.oomanipulation.shape.group"));
                if (page != null && page.DrawPage_anonymouse != null)
                {
                    var pageObj = page.DrawPage_anonymouse;
                    OoDrawUtils.AddShapeToDrawPageUndoable(grpShape, pageObj, draw.DrawPageSupplier);
                    group = doc.RegisterNewShape(grpShape);
                }
            }

            return(group);
        }
Esempio n. 3
0
        bool updateScrollBar(XScrollBar xsb, int inner, int outer, int scrVal = 0)
        {
            try
            {
                int svm = Math.Max(0, inner - outer);

                //object scrVal = OoUtils.GetProperty(xsb, "ScrollValue");

                int val = Math.Min(svm, scrVal);

                OoUtils.SetProperty(xsb, "ScrollValueMax", svm);
                OoUtils.SetProperty(xsb, "ScrollValue", val);

                double ratio    = (double)outer / (double)inner;
                double scroller = svm * ratio;

                // adapt the slider size
                OoUtils.SetProperty(xsb, "VisibleSize", (svm - (int)scroller));

                if (svm > 0)
                {
                    OoUtils.SetProperty(xsb, "EnableVisible", true);
                }
                else
                {
                    OoUtils.SetProperty(xsb, "EnableVisible", false);
                }
            }
            catch (System.Exception) { }

            return(true);
        }
        /// <summary>
        /// Gets the property of a PropertySet or a XControl.
        /// </summary>
        /// <param name="propertySet">The property set or the control.</param>
        /// <param name="propName">Name of the property.</param>
        /// <returns>the value of the Any Object returned from the PropertySet</returns>
        public static Object GetProperty(Object propertySet, String propName)
        {
            if (propertySet != null && !String.IsNullOrWhiteSpace(propName))
            {
                XPropertySet ps = null;
                if (propertySet is XPropertySet)
                {
                    ps = propertySet as XPropertySet;
                }
                else if (propertySet is XControl)
                { // for a XControll you have to get the model to change or get the properties
                    XControlModel model = ((XControl)propertySet).getModel();
                    if (model != null && model is XPropertySet)
                    {
                        ps = model as XPropertySet;
                    }
                }

                if (ps != null)
                {
                    return(OoUtils.GetProperty(ps, propName));
                }
            }

            return(null);
        }
        //TODO: unfinished
        private OoShapeObserver searchUnregisteredShapeByAccessible(string accName, XAccessibleContext cont)
        {
            Update();
            var obs = searchRegisterdSapeObserverByAccessibleName(accName, cont, false);

            if (obs != null)
            {
                return(obs);
            }

            XDrawPages pages = PagesSupplier.getDrawPages();

            if (pages != null)
            {
                try
                {
                    for (int i = 0; i < pages.getCount(); i++)
                    {
                        var anyPage = pages.getByIndex(i);
                        if (anyPage.hasValue())
                        {
                            var page = anyPage.Value;
                            if (page != null && page is XShapes)
                            {
                                for (int j = 0; j < ((XShapes)page).getCount(); j++)
                                {
                                    var anyShape = ((XShapes)page).getByIndex(j);
                                    if (anyShape.hasValue())
                                    {
                                        var    shape  = anyShape.Value;
                                        string name   = OoUtils.GetStringProperty(shape, "Name");
                                        string UIname = OoUtils.GetStringProperty(shape, "UINameSingular");
                                        string Title  = OoUtils.GetStringProperty(shape, "Title");

                                        //if (accName.Equals(UIname))
                                        //{

                                        //}
                                        //else if (accName.Equals(name))
                                        //{

                                        //}
                                        //else if (accName.Equals(name + " " + Title))
                                        //{

                                        //}
                                        //else
                                        //{

                                        //}
                                    }
                                }
                            }
                        }
                    }
                }
                catch (System.Exception) { }
            }
            return(null);
        }
        private String getStringProperty(string name)
        {
            Object prop  = OoUtils.GetProperty(Shape as XPropertySet, name);
            string sProp = prop != null?prop.ToString() : String.Empty;

            return(sProp);
        }
        /// <summary>
        /// Adds a control element to the scrollable container.
        /// ATTENTION: The pos and size you have given to the control are getting lost!
        /// The position and the size have to be set after adding the control inside the container.
        /// The values of position and size are pixel based values. The position is relative to
        /// the top left corner of the container.
        /// </summary>
        /// <param id="cntrl">The XControll you want to add.</param>
        /// <param id="sName">The supposed id of the controll - will be changed if it is not unique!.</param>
        /// <param id="posX">The x position - pixel based value relative to the top left corner of the container.</param>
        /// <param id="posY">The y position - pixel based value relative to the top left corner of the container..</param>
        /// <param id="width">The width in pixel.</param>
        /// <param id="height">The height in pixel.</param>
        public XControl addElement(XControl cntrl, String sName, int posX, int posY, int width, int height)
        {
            //System.Diagnostics.Debug.WriteLine("added control: ____________________________");
            //Debug.GetAllInterfacesOfObject(cntrl);
            //Debug.GetAllServicesOfObject(cntrl);
            //Debug.GetAllProperties(cntrl);

            if (cntrl != null && innerScrlContr != null)
            {
                if (innerScrlContr is XControlContainer)
                {
                    ((XControlContainer)innerScrlContr).addControl(sName, cntrl);
                    OoUtils.SetProperty(cntrl, "Name", sName);
                }

                if (cntrl is XWindow)
                {
                    ((XWindow)cntrl).setPosSize(posX, posY, width, height, PosSize.POSSIZE);

                    Rectangle contrPos = ((XWindow)cntrl).getPosSize();

                    if (innerWidth < (contrPos.X + contrPos.Width))
                    {
                        innerWidth = contrPos.X + contrPos.Width;
                    }
                    if (innerHeight < (contrPos.Y + contrPos.Height))
                    {
                        innerHeight = contrPos.Y + contrPos.Height;
                    }
                }
            }

            return(cntrl);
        }
        /// <summary>
        /// Sets the background image bitmap.
        /// </summary>
        /// <param name="imagePath">The local path to the bitmap.</param>
        /// <param name="mode">The fill mode <see cref="FillBitmapMode"/>.</param>
        /// <param name="Name">The name of the Fill Bitmap.</param>
        /// <returns>
        ///     <c>true</c> if the background image could been set, otherwise <c>false</c>
        /// </returns>
        virtual public bool SetBackgroundBitmap(String imagePath, tud.mci.tangram.util.BitmapMode mode, String Name = "")
        {
            XBitmap bitmap = null;

            bitmap = OoUtils.GetGraphicFromUrl(imagePath) as XBitmap;
            return(SetBackgroundBitmap(bitmap, mode, Name));
        }
        /// <summary>
        /// Try to generate an unique id.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <returns></returns>
        public string GetUniqueId(OoShapeObserver shape)
        {
            int    uidCount = 0;
            String uid      = String.Empty;

            if (shape != null && shape.Shape != null)
            {
                if (OoUtils.ElementSupportsService(shape.Shape, OO.Services.DRAW_SHAPE_TEXT))
                {
                    uid = shape.Name;
                    if (String.IsNullOrWhiteSpace(uid) ||
                        uid.Contains('\'') ||
                        uid.Contains(' '))
                    {
                        uid = shape.UINamePlural;
                        System.Diagnostics.Debug.WriteLine("______the start name for the text shape is now : '" + uid + "'");
                    }
                }
                else
                {
                    uid = shape.Name;
                }
                if (String.IsNullOrWhiteSpace(uid))
                {
                    if (shape is INameBuilder)
                    {
                        uid = ((INameBuilder)shape).BuildName();
                    }
                    else
                    {
                        uid = shape.UINameSingular + "_" + (++uidCount);
                    }
                }

                while (shapeIds.Contains(uid))
                {
                    if (shape is INameBuilder)
                    {
                        uid = ((INameBuilder)shape).RebuildName();
                    }
                    else
                    {
                        int i_ = uid.LastIndexOf('_');
                        if (i_ >= 0)
                        {
                            uid = uid.Substring(0, i_ + 1);
                        }
                        else
                        {
                            uid += "_";
                        }
                        uid += ++uidCount;
                    }
                }
                shapeIds.Add(uid);
            }
            Logger.Instance.Log(LogPriority.DEBUG, this, "new Shape with name: " + uid + " registered");
            return(uid);
        }
        //private readonly XSelectionListener_Forwarder xSelectionListener = new XSelectionListener_Forwarder();

        #endregion

        #region Constructor / Destructor

        /// <summary>
        /// static constructor for initializing system display DPI settings once
        /// </summary>
        static OoDrawPagesObserver()
        {
            double ppmX, ppmY;

            OoUtils.GetDeviceResolutionPixelPerMeter(out ppmX, out ppmY);
            PixelPerMeterX = ppmX;
            PixelPerMeterY = ppmY;
        }
Esempio n. 11
0
        /// <summary>
        /// Gets the page number.
        /// </summary>
        /// <returns>The current number of this page (Numbers are starting with 1)</returns>
        /// <remarks>This function is time limited to 100 ms.</remarks>
        public int GetPageNum()
        {
            TimeLimitExecutor.WaitForExecuteWithTimeLimit(
                100,
                new Action(() => { CachedPageNum = OoUtils.GetIntProperty(DrawPage, "Number"); })
                , "PageObserver-GetPageNum");

            return(CachedPageNum);
        }
        private bool setIntProperty(string name, int value)
        {
            int oldVal = getIntProperty(name);

            //if (OoUtils.GetIntProperty(Shape, name).Equals(value)) return true;
            OoUtils.SetPropertyUndoable(Shape as XPropertySet, name, value, GetDocument() as XUndoManagerSupplier);
            int newVal = getIntProperty(name);

            return(newVal.Equals(value));
        }
Esempio n. 13
0
        /// <summary>
        /// is invoked when the adjustment has changed.
        /// </summary>
        /// <param id="rEvent">The r event.</param>
        void XAdjustmentListener.adjustmentValueChanged(AdjustmentEvent rEvent)
        {
            if (rEvent != null && rEvent.Source is XControl)
            {
                XControlModel sbModel     = ((XControl)rEvent.Source).getModel();
                var           Orientation = OoUtils.GetProperty(rEvent.Source, "Orientation");
                int           o           = (Orientation is int) ? (int)Orientation : -1;

                // the value of a scroll bar is the topmost point of the
                // scroller. That means the size of the scroller (VisibleSize)
                // is some kind of margin to the bottom of the scroll region.
                // Is is not possible to scroll down to the ScrollValueMax.
                // The maximum value that is reachable is
                // ScrollValueMax - VisibleSize !
                // so the unreachable rest rest (VisibleSize) has to be
                // distributed proportionally to the already traveled
                // scroll way (ScrollValue)
                int    step            = OoUtils.GetIntProperty(sbModel, "ScrollValue");
                int    vissize         = OoUtils.GetIntProperty(sbModel, "VisibleSize");
                int    max             = OoUtils.GetIntProperty(sbModel, "ScrollValueMax");
                int    scrollable_size = max - vissize;
                double scrolledRatio   = (double)step / (double)scrollable_size;
                double offset          = (double)vissize * scrolledRatio;
                step += (int)offset;

                switch (o)
                {
                case 0:     // horizontal
                    scrollHorizontal(step);
                    break;

                case 1:     // vertical
                    scrollVertical(step);
                    break;

                default:
                    break;
                }

                //switch (rEvent.Type)
                //{
                //    case AdjustmentType.ADJUST_ABS:
                //        System.Diagnostics.Debug.WriteLine("The event has been triggered by dragging the thumb...");
                //        break;
                //    case AdjustmentType.ADJUST_LINE:
                //        System.Diagnostics.Debug.WriteLine("The event has been triggered by a single line move..");
                //        break;
                //    case AdjustmentType.ADJUST_PAGE:
                //        System.Diagnostics.Debug.WriteLine("The event has been triggered by a block move...");
                //        break;
                //}
                //System.Diagnostics.Debug.WriteLine("The value of the scrollbar is: " + rEvent.Value);
            }
        }
        private bool setBoolProperty(string name, bool value)
        {
            if (OoUtils.GetBooleanProperty(Shape as XPropertySet, name).Equals(value))
            {
                return(true);
            }
            OoUtils.SetPropertyUndoable(Shape as XPropertySet, name, value, GetDocument() as XUndoManagerSupplier);
            bool newVal = getBoolProperty(name);

            return(newVal.Equals(value));
        }
 /// <summary>
 /// Determines whether this Freeform is a Bezier defined form or not.
 /// </summary>
 /// <param name="cached">if set to <c>true</c> the previously cached result will be returned.</param>
 /// <returns>
 ///   <c>true</c> if the Freeform is a Bezier defined one; otherwise, <c>false</c>.
 /// </returns>
 virtual public bool IsBezier(bool cached = true)
 {
     if (IsValid() && !cached)
     {
         if (OoUtils.ElementSupportsService(Shape.Shape, OO.Services.DRAW_POLY_POLYGON_BEZIER_DESCRIPTOR))
         {
             _isBezier = true;
         }
     }
     return(_isBezier);
 }
Esempio n. 16
0
        /// <summary>
        /// find the corresponding accessible counterpart object for this page in the accessible tree
        /// </summary>
        private void setAccessibleCounterpart()
        {
            String name = OoUtils.GetStringProperty(DrawPage, "LinkDisplayName");

            name = "PageShape: " + name; //TODO: find a more general way

            XAccessible accCounter = OoAccessibility.GetAccessibleChildWithName(name, PagesObserver.Document.AccComp as unoidl.com.sun.star.accessibility.XAccessibleContext);

            if (accCounter != null)
            {
                AcccessibleCounterpart = accCounter;
            }
        }
Esempio n. 17
0
        public void AddTextToFrame(ref XTextFrame textFrame, String text, int charWeight = 100, int charHeight = 12)
        {
            if (textFrame != null)
            {
                XText       xText            = ((XTextFrame)textFrame).getText();
                XTextCursor xFrameTextCurser = xText.createTextCursor();
                xFrameTextCurser.gotoEnd(false);
                OoUtils.SetProperty(xFrameTextCurser, "CharWeight", charWeight);
                OoUtils.SetProperty(xFrameTextCurser, "CharHeight", charHeight);

                xText.insertString(xFrameTextCurser, text, false);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Updates the page properties.
        /// </summary>
        /// <param name="forceUpdate">if set to <c>true</c> to force an update even if the page is currently not the active one.</param>
        /// <returns>
        ///   <c>true</c> if the update was successfully fulfilled.
        /// </returns>
        /// <remarks>This function is time limited to 200 ms.</remarks>
        public bool updatePageProperties(bool forceUpdate = false)
        {
            if (!forceUpdate && !IsActive())
            {
                return(true);
            }

            DateTime now = DateTime.Now;

            if (now - _lastPagePropertyUpdate < _propertyUpdateTimespan)
            {
                return(false);
            }

            //System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("hh:mm:ss.fff") + " +++++++++ Update page properties REQUEST ["+this.GetHashCode()+"] +++++++++");
            bool successs = false;

            lock (this.PagesObserver.DocWnd.SynchLock)
            {
                try
                {
                    if (!_propertyUpdating && DrawPage != null)
                    {
                        _propertyUpdating = true;
                        try
                        {
                            successs = TimeLimitExecutor.WaitForExecuteWithTimeLimit(200, new Action(() =>
                            {
                                Width        = OoUtils.GetIntProperty(DrawPage, "Width");
                                Height       = OoUtils.GetIntProperty(DrawPage, "Height");
                                BorderBottom = OoUtils.GetIntProperty(DrawPage, "BorderBottom");
                                BorderLeft   = OoUtils.GetIntProperty(DrawPage, "BorderLeft");
                                BorderRight  = OoUtils.GetIntProperty(DrawPage, "BorderRight");
                                BorderTop    = OoUtils.GetIntProperty(DrawPage, "BorderTop");
                                Orientation  = (tud.mci.tangram.util.OO.PaperOrientation)OoUtils.GetProperty(DrawPage, "Orientation");
                            }), "UpdatePageProperties");
                        }
                        catch (NullReferenceException) { ((IDisposable)this).Dispose(); }
                        catch (DisposedException)
                        {
                            ((IDisposable)this).Dispose();
                        }
                        _lastPagePropertyUpdate = now;
                        return(successs);
                    }
                }
                catch { }
                finally { _propertyUpdating = false; }
            }
            return(successs);
        }
Esempio n. 19
0
        /// <summary>
        /// Builds an Observer class for the specific shape type.
        /// </summary>
        /// <param name="s">The shape to observe.</param>
        /// <param name="page">The page the shape is placed on.</param>
        /// <param name="parent">The parent shape if the shape is part of a group.</param>
        /// <returns>
        /// An shape observer class for the specific shape type.
        /// </returns>
        internal static OoShapeObserver BuildShapeObserver(XShape s, OoDrawPageObserver page, OoShapeObserver parent)
        {
            if (s != null && page != null)
            {
                if (OoUtils.ElementSupportsService(s, OO.Services.DRAW_SHAPE_CUSTOM))
                {
                    return(new OoCustomShapeObserver(s, page, parent));
                }

                // normal shape
                return(new OoShapeObserver(s, page, parent));
            }
            return(null);
        }
Esempio n. 20
0
        public void AddTextToFrameAndNewParagraph(ref XTextFrame textFrame, String text, int charWeight = 100, int charHeight = 12)
        {
            if (textFrame != null)
            {
                XText       xText            = ((XTextFrame)textFrame).getText();
                XTextCursor xFrameTextCurser = xText.createTextCursor();
                xFrameTextCurser.gotoEnd(false);
                OoUtils.SetProperty(xFrameTextCurser, "CharWeight", charWeight);
                OoUtils.SetProperty(xFrameTextCurser, "CharHeight", charHeight);

                xText.insertString(xFrameTextCurser, text, false);
                xText.insertControlCharacter(xFrameTextCurser, ControlCharacter.PARAGRAPH_BREAK, false);
            }
        }
        /// <summary>
        /// Get a registered shape observer.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <returns>the already registered shape observer to the shape or <c>null</c></returns>
        internal OoShapeObserver GetRegisteredShapeObserver(XShape shape, OoDrawPageObserver page)
        {
            if (domshapes.ContainsKey(shape))
            {
                OoShapeObserver sobs = domshapes[shape];
                if (sobs != null && sobs.Shape == shape)
                {
                    return(sobs);
                }
            }

            String          name = OoUtils.GetStringProperty(shape, "Name");
            OoShapeObserver sObs = getRegisteredShapeObserver(name);

            if (sObs == null)
            {
                if (page == null)
                {
                    XDrawPage pageShape = OoDrawUtils.GetPageForShape(shape);
                    if (pageShape == null)
                    {
                        Logger.Instance.Log(LogPriority.DEBUG, this, "[EROR] Can't get page to requested NEW shape");
                        page = this.DocWnd.GetActivePage();
                    }
                    else
                    {
                        page = GetRegisteredPageObserver(pageShape as XDrawPage);
                    }
                }

                if (page != null)
                {
                    sObs = OoShapeObserverFactory.BuildShapeObserver(shape, page); //new OoShapeObserver(shape, page);
                    RegisterUniqueShape(sObs);
                }
            }

            if (sObs != null && sObs.Shape != shape)
            {
                sObs = RegisterNewShape(shape, page);
            }

            return(sObs);
        }
Esempio n. 22
0
        /// <summary>
        /// Adds a control element to the scrollable container.
        /// ATTENTION: The pos and size you have given to the control are getting lost!
        /// The position and the size have to be set after adding the control inside the container.
        /// The values of position and size are pixel based values. The position is relative to
        /// the top left corner of the container.
        /// </summary>
        /// <param id="cntrl">The XControll you want to add.</param>
        /// <param id="sName">The supposed id of the controll - will be changed if it is not unique!.</param>
        /// <param id="posX">The x position - pixel based value relative to the top left corner of the container.</param>
        /// <param id="posY">The y position - pixel based value relative to the top left corner of the container..</param>
        /// <param id="width">The width in pixel.</param>
        /// <param id="height">The height in pixel.</param>
        public XControl AddElement(XControl cntrl, String sName, int posX, int posY, int width, int height)
        {
            // create a unique id by means of an own implementation...
            if (String.IsNullOrWhiteSpace(sName))
            {
                sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "SCROLLABLE_CONTROL_ENTRY");
            }
            else
            {
                sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName);
            }

            //System.Diagnostics.Debug.WriteLine("added control: ____________________________");
            //Debug.GetAllInterfacesOfObject(cntrl);
            //Debug.GetAllServicesOfObject(cntrl);
            //Debug.GetAllProperties(cntrl);

            if (cntrl != null && InnerScrlContr != null)
            {
                if (InnerScrlContr is XControlContainer)
                {
                    ((XControlContainer)InnerScrlContr).addControl(sName, cntrl);
                    OoUtils.SetProperty(cntrl, "Name", sName);
                }

                if (cntrl is XWindow)
                {
                    ((XWindow)cntrl).setPosSize(posX, posY, width, height, PosSize.POSSIZE);

                    Rectangle contrPos = ((XWindow)cntrl).getPosSize();

                    if (InnerWidth < (contrPos.X + contrPos.Width))
                    {
                        InnerWidth = contrPos.X + contrPos.Width;
                    }
                    if (InnerHeight < (contrPos.Y + contrPos.Height))
                    {
                        InnerHeight = contrPos.Y + contrPos.Height;
                    }
                }
            }

            return(cntrl);
        }
Esempio n. 23
0
        /// <summary>
        /// Don´t useful function, because the size you have to set is a relative value
        /// </summary>
        /// <param name="table">Table you want to resize </param>
        /// <param name="size">relative size you want to set, look for the actual TableColumnSeparators you want to fit.</param>
        /// <param name="index">index of the column you want to resize. From left to right column. if you want to fit the first you have to set the index 0. The rightest column cant resize, you have to set the column before smaller </param>
        public void SetColSize(ref XTextTable table, int size, int index)
        {
            XTableColumns columns  = table.getColumns();
            int           colCount = columns.getCount();

            if (index > colCount)
            {
                System.Console.WriteLine("index was to big");
                return;
            }

            int iWidth = (int)OoUtils.GetIntProperty(table, "Width");

            short sTableColumnRelativeSum = (short)OoUtils.GetProperty(table, "TableColumnRelativeSum");

            double dRatio         = (double)sTableColumnRelativeSum / (double)iWidth;
            double dRelativeWidth = (double)2000 * dRatio;
            double dposition      = sTableColumnRelativeSum - dRelativeWidth;

            TableColumnSeparator[] a = OoUtils.GetProperty(table, "TableColumnSeparators") as TableColumnSeparator[];
            if (a != null)
            {
                System.Console.WriteLine(a[index].Position.ToString() + "was the position before");
                a[index].Position = (short)size;

                //for (int i = a.Length - 1; i >= 0; i--)
                //{
                //    a[i].Position = (short)Math.Ceiling(dposition);
                //    System.Console.WriteLine(dposition);
                //    dposition -= dRelativeWidth;

                //}
                OoUtils.SetProperty(table, "TableColumnSeparators", a);
            }

            //if (column != null)
            //{

            //    //OoUtils.SetIntProperty(column, "Width", size);
            //}
        }
Esempio n. 24
0
        public XTextFrame AddTextFrame(int height, int width)
        {
            var textFrame = this.xMcFactory.createInstanceWithContext(OO.Services.TEXT_FRAME, xContext);

            if (textFrame != null)
            {
                if (textFrame is XTextFrame)
                {
                    Size size = OoUtils.MakeSize(width, height);
                    OoUtils.SetProperty(textFrame, "Size", size);
                    OoUtils.SetProperty(textFrame, "AnchorType", TextContentAnchorType.AS_CHARACTER);
                    OoUtils.SetProperty(textFrame, "LeftMargin", 0);
                    //util.Debug.GetAllProperties(textFrame);
                    XTextRange xTextRange = Text.getEnd();
                    NewParagraph();
                    Text.insertTextContent(xTextRange, textFrame as XTextFrame, false);
                    NewParagraph();
                }
            }
            return(textFrame as XTextFrame);
        }
Esempio n. 25
0
        /// <summary>
        /// Sets the text value of a cell .
        /// </summary>
        /// <param name="table">The table.</param>
        /// <param name="cellName">Name of the cell.</param>
        /// <param name="value">The value.</param>
        public static void SetCellTextValue(ref XTextTable table, string cellName, string value, string fontName = "Verdana", int charWeight = 100, short VertOrient = 1, int charHeight = 12, int paraAdjust = 0)
        {
            var a1 = table.getCellByName(cellName);

            if (a1 != null && a1 is XText)
            {
                // set the style of the cell
                // set style for the TextRange before inserting text content!
                var start = ((XTextRange)a1).getStart();
                if (start != null && start is XTextRange)
                {
                    //util.Debug.GetAllProperties(start);
                    OoUtils.SetStringProperty(start, "CharFontName", fontName);
                    OoUtils.SetProperty(start, "CharWeight", (float)charWeight);
                    OoUtils.SetProperty(a1, "VertOrient", VertOrient);
                    OoUtils.SetProperty(start, "CharHeight", charHeight);
                    OoUtils.SetProperty(start, "ParaAdjust", paraAdjust);
                }
                ((XText)a1).setString(value);
            }
        }
        private bool setStringProperty(string name, string value)
        {
            string val = OoUtils.GetStringProperty(Shape as XPropertySet, name);

            if (val.Equals(value))
            {
                return(true);
            }
            try
            {
                //OoUtils.SetPropertyUndoable(Shape, name, value, getDocument() as XUndoManagerSupplier);
                OoUtils.SetStringProperty(Shape as XPropertySet, name, value);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write("exception during setting property " + ex);
            }
            string newVal = getStringProperty(name);

            return(newVal.Equals(value));
        }
 private int getIntProperty(string name)
 {
     return(OoUtils.GetIntProperty(Shape as XPropertySet, name));
 }
        private bool getBoolProperty(string name)
        {
            Object prop = OoUtils.GetProperty(Shape as XPropertySet, name);

            return(prop != null && prop is bool?(bool)prop : false);
        }
 /// <summary>
 /// Try to sets the property. The function doesn't give feedback
 /// if the property is valid or available
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="value">The value.</param>
 public bool SetProperty(string name, Object value)
 {
     return(OoUtils.SetPropertyUndoable(Shape as XPropertySet, name, value, GetDocument() as XUndoManagerSupplier));
 }
 /// <summary>
 /// Try to return the value of the requested property.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <returns>the value as object</returns>
 public Object GetProperty(string name)
 {
     return(OoUtils.GetProperty(Shape as XPropertySet, name));
 }