public XPropertySet insertFormattedField(XSpinListener _xSpinListener, int _nPosX, int _nPosY, int _nWidth, String sName = "")
        {
            XPropertySet xFFModelPSet = null;
            try
            {
                // create a unique name by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName)) sName = createUniqueName(MXDlgModelNameContainer, "FORMATTED_FIELD");
                else sName = createUniqueName(MXDlgModelNameContainer, sName);

                // create a controlmodel at the multiservicefactory of the dialog model...
                Object oFFModel = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_FORMATTED_FIELD_MODEL, MXContext);
                XMultiPropertySet xFFModelMPSet = (XMultiPropertySet)oFFModel;
                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
                xFFModelMPSet.setPropertyValues(
                        new String[] { "EffectiveValue", "Height", "Name", "PositionX", "PositionY", "StrictFormat", "Spin", "Width" },
                        Any.Get(new Object[] { (double)12348, 12, sName, _nPosX, _nPosY, true, true, _nWidth }));

                xFFModelPSet = (XPropertySet)oFFModel;
                // to define a numberformat you always need a locale...
                unoidl.com.sun.star.lang.Locale aLocale = new unoidl.com.sun.star.lang.Locale();
                aLocale.Country = "US";
                aLocale.Language = "en";
                // this Format is only compliant to the english locale!
                String sFormatString = "NNNNMMMM DD, YYYY";

                // a NumberFormatsSupplier has to be created first "in the open countryside"...
                Object oNumberFormatsSupplier = MXMcf.createInstanceWithContext(OO.Services.UTIL_FORMAT_NUMBER, MXContext);
                XNumberFormatsSupplier xNumberFormatsSupplier = (XNumberFormatsSupplier)oNumberFormatsSupplier;
                XNumberFormats xNumberFormats = xNumberFormatsSupplier.getNumberFormats();
                // is the numberformat already defined?
                int nFormatKey = xNumberFormats.queryKey(sFormatString, aLocale, true);
                if (nFormatKey == -1)
                {
                    // if not then add it to the NumberFormatsSupplier
                    nFormatKey = xNumberFormats.addNew(sFormatString, aLocale);
                }

                // The following property may also be set with XMultiPropertySet but we
                // use the XPropertySet interface merely for reasons of demonstration
                xFFModelPSet.setPropertyValue("FormatsSupplier", Any.Get(xNumberFormatsSupplier));
                xFFModelPSet.setPropertyValue("FormatKey", Any.Get(nFormatKey));
                xFFModelPSet.setPropertyValue("FormatKey", Any.Get(nFormatKey));

                // The controlmodel is not really available until inserted to the Dialog container
                MXDlgModelNameContainer.insertByName(sName, Any.Get(oFFModel));

                // finally we add a Spin-Listener to the control
                XControl xFFControl = GetControlByName(sName);
                // add a SpinListener that is notified on each change of the controlvalue...
                XSpinField xSpinField = (XSpinField)xFFControl;
                xSpinField.addSpinListener(_xSpinListener);

            }
            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 xFFModelPSet;
        }
        public XPropertySet insertDateField(XSpinListener _xSpinListener, int _nPosX, int _nPosY, int _nWidth, String sName = "")
        {
            XPropertySet xDFModelPSet = null;
            try
            {
                // create a unique name by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName)) sName = createUniqueName(MXDlgModelNameContainer, "DATE_FIELD");
                else sName = createUniqueName(MXDlgModelNameContainer, sName);

                // create a controlmodel at the multiservicefactory of the dialog model...
                Object oDFModel = MXMcf.createInstanceWithContext(OO.Services.AWT_CONTROL_DATE_FIELD_MODEL, MXContext);
                XMultiPropertySet xDFModelMPSet = (XMultiPropertySet)oDFModel;

                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
                xDFModelMPSet.setPropertyValues(
                        new String[] { "Dropdown", "Height", "Name", "PositionX", "PositionY", "Width" },
                        Any.Get(new Object[] { true, 12, sName, _nPosX, _nPosY, _nWidth }));

                // The controlmodel is not really available until inserted to the Dialog container
                MXDlgModelNameContainer.insertByName(sName, Any.Get(oDFModel));
                xDFModelPSet = (XPropertySet)oDFModel;

                // The following properties may also be set with XMultiPropertySet but we
                // use the XPropertySet interface merely for reasons of demonstration
                xDFModelPSet.setPropertyValue("DateFormat", Any.Get((short)7));
                xDFModelPSet.setPropertyValue("DateMin", Any.Get(20070401));
                xDFModelPSet.setPropertyValue("DateMax", Any.Get(20070501));
                xDFModelPSet.setPropertyValue("Date", Any.Get(20000415));
                Object oDFControl = GetControlByName(sName);

                // add a SpinListener that is notified on each change of the controlvalue...
                XSpinField xSpinField = (XSpinField)oDFControl;
                xSpinField.addSpinListener(_xSpinListener);
            }
            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 xDFModelPSet;
        }