Beispiel #1
0
        /// <summary>
        /// Copies the text.
        /// </summary>
        /// <param name="xDialog">The x dialog.</param>
        /// <param name="aEvent">A event object.</param>
        public void CopyText(XDialog xDialog, Object aEvent)
        {
            XControlContainer xControlContainer = (XControlContainer)xDialog;

            String        aTextPropertyStr   = "Text";
            String        aText              = "";
            XControl      xTextField1Control = xControlContainer.getControl("TextField1");
            XControlModel xControlModel1     = xTextField1Control.getModel();
            XPropertySet  xPropertySet1      = (XPropertySet)xControlModel1;

            try
            {
                aText = (String)xPropertySet1.getPropertyValue(aTextPropertyStr).Value;
            }
            catch (unoidl.com.sun.star.uno.Exception e)
            {
                Console.WriteLine("copyText caught exception! " + e);
            }

            XControl      xTextField2Control = xControlContainer.getControl("TextField2");
            XControlModel xControlModel2     = xTextField2Control.getModel();
            XPropertySet  xPropertySet2      = (XPropertySet)xControlModel2;

            try
            {
                xPropertySet2.setPropertyValue(aTextPropertyStr, new uno.Any(aText));
            }
            catch (unoidl.com.sun.star.uno.Exception e)
            {
                Console.WriteLine("copyText caught exception! " + e);
            }

            global::System.Windows.Forms.MessageBox.Show("DialogComponent", "copyText() called");
        }
        public static XControlContainer createDialog(XMultiComponentFactory xMultiComponentFactory, XComponentContext xContext,
                                                     int posX, int posY, int width, int height, string title
                                                     )
        {
            //dialog model
            Object oDialogModel = xMultiComponentFactory.createInstanceWithContext(
                "com.sun.star.awt.UnoControlDialogModel", xContext);


            XPropertySet xPSetDialog = (XPropertySet)oDialogModel;

            xPSetDialog.setPropertyValue("PositionX", Any.Get(posX));
            xPSetDialog.setPropertyValue("PositionY", Any.Get(posY));
            xPSetDialog.setPropertyValue("Width", Any.Get(width));
            xPSetDialog.setPropertyValue("Height", Any.Get(height));
            xPSetDialog.setPropertyValue("Title", Any.Get(title));

            // get service manager from  dialog model
            XMultiServiceFactory MXMsfDialogModel = (XMultiServiceFactory)oDialogModel;

            // dialog control model
            Object oUnoDialog = xMultiComponentFactory.createInstanceWithContext(
                "com.sun.star.awt.UnoControlDialog", xContext);


            XControl      MXDialogControl = (XControl)oUnoDialog;
            XControlModel xControlModel   = (XControlModel)oDialogModel;

            MXDialogControl.setModel(xControlModel);



            XToolkit xToolkit = (XToolkit)xMultiComponentFactory
                                .createInstanceWithContext("com.sun.star.awt.Toolkit",
                                                           xContext);

            WindowDescriptor aDescriptor = new WindowDescriptor();

            aDescriptor.Type = WindowClass.TOP;
            aDescriptor.WindowServiceName = "";
            aDescriptor.ParentIndex       = -1;
            aDescriptor.Parent            = xToolkit.getDesktopWindow();
            aDescriptor.Bounds            = new Rectangle(100, 200, 300, 400);

            aDescriptor.WindowAttributes = WindowAttribute.BORDER
                                           | WindowAttribute.MOVEABLE | WindowAttribute.SIZEABLE
                                           | WindowAttribute.CLOSEABLE;

            XWindowPeer xPeer = xToolkit.createWindow(aDescriptor);

            XWindow xWindow = (XWindow)xPeer;

            xWindow.setVisible(false);
            MXDialogControl.createPeer(xToolkit, xPeer);

            // execute the dialog
            XDialog xDialog = (XDialog)oUnoDialog;

            xDialog.execute();

            // dispose the dialog
            XComponent xComponent = (XComponent)oUnoDialog;

            xComponent.dispose();

            return(oUnoDialog as XControlContainer);
        }
        /// <summary>
        /// Copies the text.
        /// </summary>
        /// <param name="xDialog">The x dialog.</param>
        /// <param name="aEvent">A event object.</param>
        public void CopyText(XDialog xDialog, Object aEvent)
        {
            XControlContainer xControlContainer = (XControlContainer)xDialog;

            String aTextPropertyStr = "Text";
            String aText = "";
            XControl xTextField1Control = xControlContainer.getControl("TextField1");
            XControlModel xControlModel1 = xTextField1Control.getModel();
            XPropertySet xPropertySet1 = (XPropertySet)xControlModel1;
            try
            {
                aText = (String)xPropertySet1.getPropertyValue(aTextPropertyStr).Value;
            }
            catch (unoidl.com.sun.star.uno.Exception e)
            {
                Console.WriteLine("copyText caught exception! " + e);
            }

            XControl xTextField2Control = xControlContainer.getControl("TextField2");
            XControlModel xControlModel2 = xTextField2Control.getModel();
            XPropertySet xPropertySet2 = (XPropertySet)xControlModel2;
            try
            {
                xPropertySet2.setPropertyValue(aTextPropertyStr, new uno.Any(aText));
            }
            catch (unoidl.com.sun.star.uno.Exception e)
            {
                Console.WriteLine("copyText caught exception! " + e);
            }

            global::System.Windows.Forms.MessageBox.Show("DialogComponent", "copyText() called");
        }