Example #1
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>
        /// 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);
        }
Example #3
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);
            }
        }
Example #4
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);
            }
        }
Example #5
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);
        }
Example #6
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);
            //}
        }
Example #7
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);
        }
Example #8
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);
            }
        }
        /// <summary>
        /// Inserts a fixed text label.
        /// Properties: Height, Name, PositionX, PositionY, Step, TabIndex, Tag, Width, Align, BackgroundColor, Border, BorderColor, Enabled, FontDescriptor, FontEmphasisMark, FontRelief, HelpText, HelpURL, Label, MultiLine, Printable, TextColor, TextLineColor, VerticalAlign
        /// </summary>
        /// <param name="name">The base name of the element - will be set to a unique one by this function.</param>
        /// <param name="text">The text that should be insert.</param>
        /// <param name="_nPosX">The x position of the element.</param>
        /// <param name="_nPosY">The y posistion of the elemnt.</param>
        /// <param name="_nWidth">The width of the element.</param>
        /// <param name="_nHeight">The Height of the element.</param>
        /// <param name="_nStep">The step index.</param>
        /// <param name="_xMouseListener">A mouse listener.</param>
        /// <returns>XFixedText object</returns>
        public virtual XFixedText InsertFixedLabel(String text, int _nPosX, int _nPosY, int _nWidth, int _nHeight, int _nStep, XMouseListener _xMouseListener, String sName = "")
        {
            XFixedText xFixedText = null;

            try
            {
                // create a unique name by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName))
                {
                    sName = createUniqueName(MXDlgModelNameContainer, "TEXT_FIXED");
                }
                else
                {
                    sName = createUniqueName(MXDlgModelNameContainer, sName);
                }

                // create a controlmodel at the multiservicefactory of the dialog model...
                Object            oFTModel      = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_TEXT_FIXED_MODEL, MXContext);
                XMultiPropertySet xFTModelMPSet = (XMultiPropertySet)oFTModel;
                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!

                String[] valueNames = new String[] { "Height", "Name", "PositionX", "PositionY", "Step", "Width", "Label" };
                var      valueVals  = Any.Get(new Object[] { _nHeight, sName, _nPosX, _nPosY, _nStep, _nWidth, text });

                xFTModelMPSet.setPropertyValues(
                    valueNames, valueVals
                    );
                // add the model to the NameContainer of the dialog model
                MXDlgModelNameContainer.insertByName(sName, Any.Get(oFTModel));

                var element = MXDlgModelNameContainer.getByName(sName).Value;
                if (element != null)
                {
                    OoUtils.SetProperty(element, "PositionX", _nPosX);
                    OoUtils.SetProperty(element, "PositionY", _nPosY);
                    OoUtils.SetProperty(element, "Width", _nWidth);
                    //if (element is XControl)
                    //{
                    //    ((XControl)element).getModel();
                    //}
                    //if (element is XMultiPropertySet)
                    //{
                    //    ((XMultiPropertySet)element).setPropertyValues(valueNames, valueVals);
                    //}
                }


                // reference the control by the Name
                XControl xFTControl = GetControlByName(sName);
                xFixedText = (XFixedText)xFTControl;
                if (_xMouseListener != null)
                {
                    XWindow xWindow = (XWindow)xFTControl;
                    xWindow.addMouseListener(_xMouseListener);
                }
            }
            catch (unoidl.com.sun.star.uno.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("uno.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("System.Exception:");
                System.Diagnostics.Debug.WriteLine(ex);
            }
            return(xFixedText);
        }