예제 #1
0
        /// <summary>
        /// News the doc component.
        /// </summary>
        /// <param name="docType">Type of the doc.</param>
        /// <param name="xMsFactory"> </param>
        /// <param name="xContext"> </param>
        /// <returns></returns>
        public static XComponent OpenNewDocumentComponent(String docType, XComponentContext xContext = null, XMultiComponentFactory xMsFactory = null)
        {
            try
            {
                if (xContext == null)
                {
                    xContext = OO.GetContext();
                }

                if (xMsFactory == null)
                {
                    xMsFactory = OO.GetMultiComponentFactory(xContext);
                }

                var desktop      = xMsFactory.createInstanceWithContext(OO.Services.FRAME_DESKTOP, xContext);
                var mxCompLoader = desktop as XComponentLoader;

                String loadUrl   = OO.DocTypes.DOC_TYPE_BASE + docType;
                var    loadProps = new unoidl.com.sun.star.beans.PropertyValue[0];
                if (mxCompLoader != null)
                {
                    return(mxCompLoader.loadComponentFromURL(loadUrl, "_blank", 0, loadProps));
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Desktop to XComponentLoader cast Exeption: " + ex);
            }
            return(null);
        }
 /// <summary>
 /// Try to get all available XDrawPagesSuppliers.
 /// </summary>
 /// <param name="factory">The XMultiComponentFactory.</param>
 /// <param name="xContext">The XComponentContext.</param>
 /// <returns>A list of all available XDrawPagesSupplier</returns>
 public static List<XDrawPagesSupplier> GetDrawPageSuppliers(XMultiComponentFactory factory, XComponentContext xContext)
 {
     //lock (_dpsLock)
     {
         return GetDrawPageSuppliers(OO.GetDesktop(factory, xContext));
     }
 }
예제 #3
0
        public void CreateNewDocumentAndDoAPrintOut()
        {
            string fileToPrint = AARunMeFirstAndOnce.outPutFolder + "fileToPrint.odt";

            //Create a new text document
            TextDocument document = new TextDocument();

            document.New();
            //Create a standard paragraph using the ParagraphBuilder
            Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);

            //Add some simple text
            paragraph.TextContent.Add(new SimpleText(document, "Some simple text!"));
            //Add the paragraph to the document
            document.Content.Add(paragraph);
            //Save empty
            document.SaveTo(fileToPrint);

            //Now print the new document via the OpenOfficeLib
            //Get the Component Context
            XComponentContext xComponentContext = Connector.GetComponentContext();
            //Get a MultiServiceFactory
            XMultiServiceFactory xMultiServiceFactory = Connector.GetMultiServiceFactory(xComponentContext);
            //Get a Dektop instance
            XDesktop xDesktop = Connector.GetDesktop(xMultiServiceFactory);

            //Convert a windows path to an OpenOffice one
            fileToPrint = Component.PathConverter(fileToPrint);
            //Load the document you want to print
            XComponent xComponent = Component.LoadDocument(
                (XComponentLoader)xDesktop, fileToPrint, "_blank");

            //Print the XComponent
            Printer.Print(xComponent);
        }
예제 #4
0
        public virtual void Connect()
        {
            Logger.Debug("connecting");
            try
            {
                EnvUtils.InitUno();
                SocketUtils.Connect();
                //var sock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
                XComponentContext localContext = Bootstrap.bootstrap();
                //XComponentContext localContext = Bootstrap.defaultBootstrap_InitialComponentContext();
                XMultiComponentFactory localServiceManager = localContext.getServiceManager();
                XConnector             connector           = (XConnector)localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext);
                XConnection            connection          = connector.connect(_connectionString);
                XBridgeFactory         bridgeFactory       = (XBridgeFactory)localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext);
                _bridge          = bridgeFactory.createBridge("", "urp", connection, null);
                _bridgeComponent = (XComponent)_bridge;
                _bridgeComponent.addEventListener(this);
                _serviceManager = (XMultiComponentFactory)_bridge.getInstance("StarOffice.ServiceManager");
                XPropertySet properties = (XPropertySet)_serviceManager;
                // Get the default context from the office server.
                var oDefaultContext = properties.getPropertyValue("DefaultContext");

                _componentContext = (XComponentContext)oDefaultContext.Value;
                _connected        = true;
                Logger.Info("connected");
            }
            catch (NoConnectException connectException)
            {
                throw new OpenOfficeException("connection failed: " + _connectionString + ": " + connectException.Message);
            }
            catch (Exception exception)
            {
                throw new OpenOfficeException("connection failed: " + _connectionString, exception);
            }
        }
        /// <summary>
        /// News the doc component.
        /// </summary>
        /// <param name="docType">Type of the doc.</param>
        /// <param name="xMsFactory"> </param>
        /// <param name="xContext"> </param>
        /// <returns></returns>
        public static XComponent OpenNewDocumentComponent(String docType, XComponentContext xContext = null, XMultiComponentFactory xMsFactory = null)
        {
            try
            {
                if (xContext == null)
                {
                    xContext = OO.GetContext();
                }

                if (xMsFactory == null)
                {
                    xMsFactory = OO.GetMultiComponentFactory(xContext);
                }

                var desktop = xMsFactory.createInstanceWithContext(OO.Services.FRAME_DESKTOP, xContext);
                var mxCompLoader = desktop as XComponentLoader;

                String loadUrl = OO.DocTypes.DOC_TYPE_BASE + docType;
                var loadProps = new unoidl.com.sun.star.beans.PropertyValue[0];
                if (mxCompLoader != null) 
                    return mxCompLoader.loadComponentFromURL(loadUrl, "_blank", 0, loadProps);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Desktop to XComponentLoader cast Exeption: " + ex);
            }
            return null;
        }
        public WriterInspectionReport(List<Category> results, Evaluation eval, XComponentContext xContext = null)
            : base(results, eval, xContext)
        {
            this.eval = eval;
            this.results = results;

        }
예제 #7
0
파일: OpenOffice.cs 프로젝트: Ryoichi1/BCR-
        //ファイルを開く
        public void OpenFile(string filePath)
        {
            //parameterファイルを開く
            string path = filePath;

            // pathをURIに変換
            Uri.TryCreate(path, UriKind.Absolute, out uriCalcFile);

            // OpenOfficeファイルを開くためのおまじない
            // コンポーネントコンテキストの取得
            localContext = Bootstrap.bootstrap();
            // サービスマネージャーの取得
            multiServiceFactory = (XMultiServiceFactory)localContext.getServiceManager();
            // コンポーネントローダーの取得
            loader = (XComponentLoader)multiServiceFactory.createInstance("com.sun.star.frame.Desktop");

            // 非表示で実行するためのプロパティ指定
            calcProp          = new PropertyValue[1];
            calcProp[0]       = new PropertyValue();
            calcProp[0].Name  = "Hidden";
            calcProp[0].Value = new uno.Any(true);

            // Calcファイルを開く
            doc = (XSpreadsheetDocument)loader.loadComponentFromURL(uriCalcFile.ToString(), "_blank", 0, calcProp);
            // シート群を取得
            sheets = doc.getSheets();
        }
 /// <summary>
 /// Try to get all available XDrawPagesSuppliers.
 /// </summary>
 /// <param name="xContext">The XComponentContext.</param>
 /// <returns>A list of all available XDrawPagesSupplier</returns>
 public static List<XDrawPagesSupplier> GetDrawPageSuppliers(XComponentContext xContext)
 {
     //lock (_dpsLock)
     {
         return GetDrawPageSuppliers(OO.GetMultiComponentFactory(xContext), xContext);
     }
 }
 protected MenueBase(XComponentContext xContext, XMultiComponentFactory xMcf, XTopWindow xWindow, XMenuListener xMListener, XMenuBar xMenuBar = null)
 {
     _xContext = xContext;
     _xMCF = xMcf;
     _xWindow = xWindow;
     _xMenuListener = xMListener;
     _xMenuBar = xMenuBar != null ? xMenuBar : AddMenuBar();
 }
 protected MenueBase(XComponentContext xContext, XMultiComponentFactory xMcf, XTopWindow xWindow, XMenuListener xMListener, XMenuBar xMenuBar = null)
 {
     _xContext      = xContext;
     _xMCF          = xMcf;
     _xWindow       = xWindow;
     _xMenuListener = xMListener;
     _xMenuBar      = xMenuBar != null ? xMenuBar : AddMenuBar();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DescriptionMapper"/> class.
 /// </summary>
 /// <param name="xDrawPagesSupplier">The x draw pages supplier.</param>
 /// <param name="xContext">The x context. (optional)</param>
 public DescriptionMapper(XDrawPagesSupplier xDrawPagesSupplier, XComponentContext xContext = null)
 {
     if (xContext != null)
     {
         this.xContext = xContext;
     }
     this.xDrawPagesSupplier = xDrawPagesSupplier;
 }
예제 #12
0
        public OpenOffice()
        {
            // Start a new instance of OpenOffice.org if it is not running.
            // https://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/Writing_Client_Programs
            context = uno.util.Bootstrap.bootstrap();

            service = (XMultiServiceFactory)context.getServiceManager();
            desktop = (XComponentLoader)service.createInstance("com.sun.star.frame.Desktop");
        }
    private static void ConvertToPDF(string serverHost, int serverPort, Uri inputFile, Uri outputFile)
    {
        // FIX: Workaround for a known bug: XUnoUrlResolver forgets to call WSAStartup. We can use dummy Socket for that:
        using (var dummySocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP))
        {
            // First, initialize local service manager (IoC container of some kind):
            XComponentContext      componentContext    = Bootstrap.bootstrap();
            XMultiComponentFactory localServiceManager = componentContext.getServiceManager();
            XUnoUrlResolver        urlResolver         = (XUnoUrlResolver)localServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", componentContext);

            // Connect to LibreOffice server
            // URL format explained here: https://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Starting_OpenOffice.org_in_Listening_Mode
            string connectionString = string.Format("uno:socket,host={0},port={1};urp;StarOffice.ComponentContext", serverHost, serverPort);
            object initialObject    = urlResolver.resolve(connectionString);

            // Retrieve remote service manager:
            XComponentContext      remoteContext          = (XComponentContext)initialObject;
            XMultiComponentFactory remoteComponentFactory = remoteContext.getServiceManager();

            // Request our own instance of LibreOffice Writer from the server:
            object           oDesktop = remoteComponentFactory.createInstanceWithContext("com.sun.star.frame.Desktop", remoteContext);
            XComponentLoader xCLoader = (XComponentLoader)oDesktop;

            var loaderArgs = new PropertyValue[1];
            loaderArgs[0]       = new PropertyValue();
            loaderArgs[0].Name  = "Hidden"; // No GUI
            loaderArgs[0].Value = new Any(true);

            string inputFileUrl = inputFile.AbsoluteUri;

            // WARNING: LibreOffice .NET API uses .NET Remoting and does NOT throw clean and actionable errors,
            //          so, if server crashes or input file is locked or whatever, you will get nulls after casting.
            //          For example, `(XStorable)xCLoader` cast may produce null.
            //          This is counter-intuitive, I know; be more careful in production-grade code and check for nulls after every cast.

            XStorable xStorable = (XStorable)xCLoader.loadComponentFromURL(inputFileUrl, "_blank", 0, loaderArgs);

            var writerArgs = new PropertyValue[2];
            writerArgs[0]       = new PropertyValue();
            writerArgs[0].Name  = "Overwrite"; // Overwrite outputFile if it already exists
            writerArgs[0].Value = new Any(true);
            writerArgs[1]       = new PropertyValue();
            writerArgs[1].Name  = "FilterName";
            writerArgs[1].Value = new Any("writer_pdf_Export");  // Important! This filter is doing all PDF stuff.

            string outputFileUrl = outputFile.AbsoluteUri;

            xStorable.storeToURL(outputFileUrl, writerArgs);

            XCloseable xCloseable = (XCloseable)xStorable;
            if (xCloseable != null)
            {
                xCloseable.close(false);
            }
        }
    }
예제 #14
0
        // use MultiService factory

        public ScrollableContainer(XControlContainer parent, XNameContainer nameContainer, XComponentContext context = null, XMultiComponentFactory parentMCF = null)
        {
            MXDlgModelNameContainer = nameContainer;
            if (context != null)
            {
                MXContext = context;
            }
            parentCnt      = parent;
            this.parentMCF = parentMCF;
        }
 public AbstractWriterExportBase(List<Category> results, Evaluation eval,  XComponentContext xContext = null)
 {
     if (xContext != null)
     
         this.xContext = xContext;
         this.results = results;
         this.eval = eval;
         
    
 }
예제 #16
0
 protected static void TryInitServiceManager()
 {
     try
     {
         XComponentContext    context = uno.util.Bootstrap.bootstrap();
         XMultiServiceFactory manager = (XMultiServiceFactory)context.getServiceManager();
         serviceManager = (XComponentLoader)manager.createInstance("com.sun.star.frame.Desktop");
     }
     catch
     {
     }
 }
 /// <summary>
 /// Führt anwendungsspezifische Aufgaben durch, die mit der Freigabe, der Zurückgabe oder dem Zurücksetzen von nicht verwalteten Ressourcen zusammenhängen.
 /// </summary>
 public void Dispose()
 {
     serach = false;
     if (serachThread != null)
     {
         serachThread.Abort();
     }
     _desktopChilds = null;
     _xCc           = null;
     _xDesktop      = null;
     _xMcf          = null;
 }
        /// <summary>
        /// Gets the context.
        /// </summary>
        /// <returns></returns>
        public static XComponentContext GetContext(bool renew = false)
        {
            if (_context == null || renew)
            {
                lock (_contextCreationLock)
                {
                    // if the lock releases and a context exists
                    if (_context != null) { return _context; }
                    try
                    {
                        bool success = false;
                        //TODO: timeout
                        //success = TimeLimitExecutor.WaitForExecuteWithTimeLimit(5000,
                        //     () =>
                        //     {
                                 try
                                 {
                                     _context = Bootstrap.bootstrap();
                                     addListener(_context);
                                     success = true;
                                 }
                                 catch (System.Threading.ThreadAbortException)
                                 {
                                     System.Diagnostics.Debug.WriteLine("[ERROR]  getting Bootstrap timed out");
                                 }
                                 catch (System.Exception ex)
                                 {
                                     System.Diagnostics.Debug.WriteLine("[FATAL ERROR]  cannot get Bootstrap: " + ex);
                                     Logger.Instance.Log(LogPriority.IMPORTANT, "OO", "[FATAL ERROR] Can not get connection to OpenOffec by bootstap: " + ex);
                                 }
                             //},
                             //"Bootstrap-ContextLoader"
                             //);

                        if (!success)
                        {
                            _context = null;
                        }                        
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine("Can't create context: " + ex);
                        return null;
                    }
                }
            }
            return _context;
        }
예제 #19
0
        /// <summary>
        /// This convert an URL (formated as a string) to a struct com.sun.star.util.URL.
        /// It use a special service to do that: the URLTransformer.
        /// Because some API calls need it and it's not allowed to set "Complete"
        /// part of the util struct only. The URL must be parsed.
        /// </summary>
        /// <param name="sUrl">URL for parsing in string notation</param>
        /// <returns>URL in UNO struct notation </returns>
        public static URL ParseUrl(String sUrl)
        {
            URL aUrl;

            if (sUrl == null || sUrl.Equals("", StringComparison.CurrentCulture))
            {
                System.Diagnostics.Debug.WriteLine("wrong using of URL parser");
                return(null);
            }

            try
            {
                XComponentContext xOfficeCtx = OO.GetContext();

                // Create special service for parsing of given URL.
                var xParser = (XURLTransformer)xOfficeCtx.getServiceManager().createInstanceWithContext(
                    OO.Services.UTIL_URL_TRANSFORMER, xOfficeCtx);

                // Because it's an in/out parameter we must use an array of URL objects.
                var aParseUrl = new URL[1];
                aParseUrl[0] = new URL {
                    Complete = sUrl
                };

                // Parse the URL
                xParser.parseStrict(ref aParseUrl[0]);

                aUrl = aParseUrl[0];
            }
            catch (RuntimeException)
            {
                // Any UNO method of this scope can throw this exception.
                // Reset the return value only.
                aUrl = null;
            }
            catch (unoidl.com.sun.star.uno.Exception)
            {
                // "createInstance()" method of used service manager can throw it.
                // Then it wasn't possible to get the URL transformer.
                // Return default instead of realy parsed URL.
                aUrl = null;
            }

            return(aUrl);
        }
        public static XControlContainer createDialog(XMultiComponentFactory xMultiComponentFactory, XComponentContext xContext,
            int posX, int posY, int width, int height, string title
            )
        {
            try
            {
            Object oDialogModel = xMultiComponentFactory.createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", xContext);

                // The XMultiServiceFactory of the dialog model is needed to instantiate the controls...
                var MXMsfDialogModel = (XMultiServiceFactory)oDialogModel;

                // The named container is used to insert the created controls into...
                var MXDlgModelNameContainer = (XNameContainer)oDialogModel;

                // create the dialog...
                Object oUnoDialog = xMultiComponentFactory.createInstanceWithContext("com.sun.star.awt.UnoControlDialog", xContext);
                var MXDialogControl = (XControl)oUnoDialog;

                // The scope of the control container is public...
                var MXDlgContainer = (XControlContainer)oUnoDialog;

                var MXTopWindow = (XTopWindow)MXDlgContainer;

                // link the dialog and its model...
                XControlModel xControlModel = (XControlModel)oDialogModel;
                MXDialogControl.setModel(xControlModel);
            }
            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);
            }


            //xMultiPropertySet.setPropertyValues(PropertyNames, Any.Get(PropertyValues));

            return null;

        }
예제 #21
0
        public OpenOffice()
        {
            /// This will start a new instance of OpenOffice.org if it is not running,
            /// or it will obtain an existing instance if it is already open.
            context = uno.util.Bootstrap.bootstrap();

            /// The next step is to create a new OpenOffice.org service manager
            service = (XMultiServiceFactory)context.getServiceManager();

            /// Create a new Desktop instance using our service manager
            component = (XComponentLoader)service.createInstance("com.sun.star.frame.Desktop");

            // Getting filters
            XNameContainer filters = (XNameContainer)service.createInstance("com.sun.star.document.FilterFactory");

            foreach (string filter in filters.getElementNames())
            {
                this.filters.Add(filter);
            }
        }
예제 #22
0
        /// <summary>
        /// Try to find an unique frame name, which isn't currently used inside
        /// remote office instance. Because we create top level frames
        /// only, it's enough to check the names of existing child frames on the
        /// desktop only.
        /// </summary>
        /// <returns>
        /// should represent an unique frame name, which currently isn't
        /// used inside the remote office frame tree
        /// (Couldn't guaranteed for a real multi threaded environment.
        /// But we try it ...)
        /// </returns>
        public static String GetUniqueFrameName()
        {
            String sName = null;

            XComponentContext xCtx = OO.GetContext();

            try
            {
                var xSupplier = (XFramesSupplier)xCtx.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop", xCtx);

                var xContainer = (XIndexAccess)xSupplier.getFrames();

                int nCount = xContainer.getCount();
                for (int i = 0; i < nCount; ++i)
                {
                    XFrame xFrame = (XFrame)xContainer.getByIndex(i).Value;
                    sName = BASEFRAMENAME + _mnViewCount;
                    while (String.Compare(sName, xFrame.getName(), System.StringComparison.Ordinal) == 0)
                    {
                        ++_mnViewCount;
                        sName = BASEFRAMENAME + _mnViewCount;
                    }
                }
            }
            catch (unoidl.com.sun.star.uno.Exception)
            {
                sName = BASEFRAMENAME;
            }

            if (sName == null)
            {
                System.Diagnostics.Debug.WriteLine("invalid name!");
                sName = BASEFRAMENAME;
            }

            return(sName);
        }
예제 #23
0
/** Connect to a running office that is accepting connections.
 *      @return  The ServiceManager to instantiate office components. */
    static private XMultiServiceFactory connect(string[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine("You need to provide a file URL to the office" +
                              " program folder\n");
        }
        System.Collections.Hashtable ht = new System.Collections.Hashtable();
        ht.Add("SYSBINDIR", args[0]);
        XComponentContext xContext =
            uno.util.Bootstrap.defaultBootstrap_InitialComponentContext(
                args[0] + "/uno.ini", ht.GetEnumerator());

        if (xContext != null)
        {
            Console.WriteLine("Successfully created XComponentContext\n");
        }
        else
        {
            Console.WriteLine("Could not create XComponentContext\n");
        }

        return(null);
    }
 public AbstactUnoDialogBase(XComponentContext xContext, XMultiComponentFactory xMcf)
 {
     MXContext = xContext;
     MXMcf = xMcf;
     CreateDialog();
 }
 /// <summary>
 /// Create a new instance of UnoDialogSample
 /// </summary>
 /// <param name="xContext"></param>
 /// <param name="xMcf"></param>
 public UnoDialogSample(XComponentContext xContext, XMultiComponentFactory xMcf)
     : base(xContext, xMcf) { }
예제 #26
0
        /// <summary>
        /// It try to export given document in HTML format.
        /// Current document will be converted to HTML and moved to new place on disk.
        /// A "new" file will be created by given URL (may be overwritten
        /// if it already exist). Right filter will be used automatically if factory of
        /// this document support it. If no valid filter can be found for export,
        /// nothing will be done here.
        /// </summary>
        /// <param name="xDocument">document which should be exported</param>
        /// <param name="sUrl">target URL for converted document</param>
        public static void SaveAsHtml(XComponent xDocument, String sUrl)
        {
            try
            {
                // First detect factory of this document.
                // Ask for the supported service name of this document.
                // If information is available it can be used to find out which
                // filter exist for HTML export. Normally this filter should be searched
                // inside the filter configuration but this little demo doesn't do so.
                // (see service com.sun.star.document.FilterFactory for further
                // informations too)
                // Well known filter names are used directly. They must exist in current
                // office installation. Otherwise this code will fail. But to prevent
                // this code against missing filters it check for existing state of it.
                XServiceInfo xInfo = (XServiceInfo)xDocument;

                if (xInfo != null)
                {
                    // Find out possible filter name.
                    String sFilter = null;
                    if (xInfo.supportsService(OO.Services.DOCUMENT_TEXT))
                    {
                        sFilter = "HTML (StarWriter)";
                    }
                    else
                    if (xInfo.supportsService(OO.Services.DOCUMENT_WEB))
                    {
                        sFilter = "HTML";
                    }
                    else
                    if (xInfo.supportsService(OO.Services.DOCUMENT_SPREADSHEET))
                    {
                        sFilter = "HTML (StarCalc)";
                    }

                    // Check for existing state of this filter.
                    if (sFilter != null)
                    {
                        XComponentContext xCtx = OO.GetContext();

                        var xFilterContainer = (XNameAccess)xCtx.getServiceManager().createInstanceWithContext(
                            OO.Services.DOCUMENT_FILTER_FACTORY, xCtx);

                        if (xFilterContainer.hasByName(sFilter) == false)
                        {
                            sFilter = null;
                        }
                    }

                    // Use this filter for export.
                    if (sFilter != null)
                    {
                        // Export can be forced by saving the document and using a
                        // special filter name which can write needed format. Build
                        // necessary argument list now.
                        // Use special flag "Overwrite" too, to prevent operation
                        // against possible exceptions, if file already exist.
                        var lProperties = new PropertyValue[2];
                        lProperties[0] = new PropertyValue {
                            Name = "FilterName", Value = Any.Get(sFilter)
                        };
                        lProperties[1] = new PropertyValue {
                            Name = "Overwrite", Value = Any.Get(true)
                        };

                        XStorable xStore = (XStorable)xDocument;

                        xStore.storeAsURL(sUrl, lProperties);
                    }
                }
            }
            catch (unoidl.com.sun.star.io.IOException exIo)
            {
                // Can be thrown by "store()" call.
                // Do nothing then. Saving failed - that's it.
                System.Diagnostics.Debug.WriteLine(exIo);
            }
            catch (RuntimeException exRuntime)
            {
                // Can be thrown by any uno call.
                // Do nothing here. Saving failed - that's it.
                System.Diagnostics.Debug.WriteLine(exRuntime);
            }
            catch (unoidl.com.sun.star.uno.Exception exUno)
            {
                // Can be thrown by "createInstance()" call of service manager.
                // Do nothing here. Saving failed - that's it.
                System.Diagnostics.Debug.WriteLine(exUno);
            }
        }
예제 #27
0
        private static void ConvertToPdf(string filePath)
        {
            Process[] ps = Process.GetProcessesByName("soffice.exe");
            if (ps.Length != 0)
            {
                throw new InvalidProgramException("OpenOffice not found.  Is OpenOffice installed?");
            }
            if (ps.Length > 0)
            {
                return;
            }
            Process p = new Process
            {
                StartInfo =
                {
                    Arguments      = "-headless -nofirststartwizard",
                    FileName       = "soffice.exe",
                    CreateNoWindow = true
                }
            };
            bool result = p.Start();

            if (result == false)
            {
                throw new InvalidProgramException("OpenOffice failed to start.");
            }
            XComponentContext    xLocalContext  = Bootstrap.bootstrap();
            XMultiServiceFactory xRemoteFactory = (XMultiServiceFactory)xLocalContext.getServiceManager();
            XComponentLoader     aLoader        = (XComponentLoader)xRemoteFactory.createInstance("com.sun.star.frame.Desktop");
            XComponent           xComponent     = null;

            try
            {
                PropertyValue[] openProps = new PropertyValue[1];
                openProps[0] = new PropertyValue {
                    Name = "Hidden", Value = new Any(true)
                };
                xComponent = aLoader.loadComponentFromURL(PathConverter(filePath), "_blank", 0, openProps);
                while (xComponent == null)
                {
                    Thread.Sleep(1000);
                }
                PropertyValue[] propertyValues = new PropertyValue[2];
                propertyValues[1] = new PropertyValue {
                    Name = "Overwrite", Value = new Any(true)
                };
                propertyValues[0] = new PropertyValue {
                    Name = "FilterName", Value = new Any(ConvertExtensionToFilterType(Path.GetExtension(filePath)))
                };
                ((XStorable)xComponent).storeToURL(PathConverter(OutputFolder + Path.GetFileNameWithoutExtension(filePath) + ".pdf"), propertyValues);
            }
            catch (System.Exception e)
            {
                log.Error("Eccezione la conversione del file OpenOffice " + filePath);
                log.Error(e.StackTrace);
                File.Move(filePath, ErrorFolder + Path.GetFileName(filePath));
            }
            finally
            {
                if (xComponent != null)
                {
                    xComponent.dispose();
                }
                CloseProcess("soffice");
                File.Delete(filePath);
            }
        }
 public PerformanceTestObject( XComponentContext xContext )
 {
     m_xContext = xContext;
 }
 public AbstactUnoDialogBase(XComponentContext xContext, XMultiComponentFactory xMcf)
 {
     MXContext = xContext;
     MXMcf     = xMcf;
     CreateDialog();
 }
예제 #30
0
 public WriterDocument(XTextDocument xTextDocument, XComponentContext xContext = null, XMultiComponentFactory xMcFactory = null)
 {
     this.xContext   = xContext;
     this.xMcFactory = xMcFactory;
     doc             = xTextDocument;
 }
예제 #31
0
        private void CreaReport(object sender, DoWorkEventArgs e)
        {
            string PathTemplate = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "template.odt";

            if (File.Exists(PathTemplate))
            {
                //The C# application starts OpenOffice.org by using it's bootstrap method:
                XComponentContext oStrap = uno.util.Bootstrap.bootstrap();
                //This will start a new instance of OpenOffice.org if it is not running,
                //or it will obtain an existing instance if it is already open.
                //The next step is to create a new OpenOffice.org service manager:
                XMultiServiceFactory oServMan = (XMultiServiceFactory)oStrap.getServiceManager();

                XComponentLoader oDesk = (XComponentLoader)oServMan.createInstance("com.sun.star.frame.Desktop");

                //string url = @"private:factory/swriter";
                PropertyValue[] propVals = new PropertyValue[0];

                XComponent oDoc = oDesk.loadComponentFromURL(PathConverter(PathTemplate), "_blank", 0, propVals);

                //string docText = "This will be my first paragraph.\n\r";
                //docText += "This will be my second paragraph.\n\r";

                //And then this is written to the body of the document:
                //((XTextDocument)oDoc).getText().setString(docText);

                XBookmarksSupplier xBS = (XBookmarksSupplier)oDoc;

                unoidl.com.sun.star.container.XNameAccess xNamedBookmarks = xBS.getBookmarks();

                //inserimento dati nei bookmark
                //grassi
                InsertTxtBookmark(xNamedBookmarks, "bPalma", oPalmaRaf.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bPalmaAfr", oPalmaAfr.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bPalmaOle60", oPalmaOle60.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bPalmaOle62", oPalmaOle62.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bPalmaOle64", oPalmaOle64.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bPalmaSte48", oPalmaSt48.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bPalmaSte53", oPalmaSt53.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bCocco", oCoccoRaf.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bCoccoIdr", oCoccoIdr.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bPalmisto", oPalmistoR.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bPalmistoIdr", oPalmistoI.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bPalmistoSte", oPalmistoSt.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bPalmistoFra", oPalmistoFraz.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bSoia", oSoiaRaf.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bColza", oColzaRaf.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bArachide", oArachideR.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bVinacciolo", oVinacciolo.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bMais", oMaisRaf.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bGirasoleAO", oGirasoleALino.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bGirasoleAL", oGirasoleAOle.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bSesamo", oSesamoRaff.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bNocciola", oNocciola.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bOliva", oOliva.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bBurroCacao", oBurroCacao.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bBabassu", oBabassu.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bKarite", oKarite.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bBurro", oBurro.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bStrutto", oStrutto.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bSego", oSegoRaf.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bX", oX.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bY", oY.ToString());
                InsertTxtBookmark(xNamedBookmarks, "bZ", oZ.ToString());
                //acidi grassi calcolati
                InsertTxtBookmark(xNamedBookmarks, "bC4-0", AcidiGrassiOtt[0].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC6-0", AcidiGrassiOtt[1].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC8-0", AcidiGrassiOtt[2].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC10-0", AcidiGrassiOtt[3].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC12-0", AcidiGrassiOtt[4].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC14-0", AcidiGrassiOtt[5].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC14-1", AcidiGrassiOtt[6].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC15-0", AcidiGrassiOtt[7].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC16-ISO", AcidiGrassiOtt[8].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC16-0", AcidiGrassiOtt[9].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC16-1", AcidiGrassiOtt[10].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC17-ISO", AcidiGrassiOtt[11].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC17-0", AcidiGrassiOtt[12].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC17-1", AcidiGrassiOtt[13].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC18-0", AcidiGrassiOtt[14].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC18-ISO", AcidiGrassiOtt[15].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC18-1", AcidiGrassiOtt[16].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC18-2", AcidiGrassiOtt[17].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC18-3", AcidiGrassiOtt[18].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC18-CON", AcidiGrassiOtt[19].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC20-0", AcidiGrassiOtt[20].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC20-1", AcidiGrassiOtt[21].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC22-0", AcidiGrassiOtt[22].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bC22-1", AcidiGrassiOtt[23].ToString("F2"));
                //acidi grassi inseriti a mano (forniti dal gascromatografo)
                InsertTxtBookmark(xNamedBookmarks, "bGC4-0", AcidiGrassiRic[0].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC6-0", AcidiGrassiRic[1].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC8-0", AcidiGrassiRic[2].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC10-0", AcidiGrassiRic[3].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC12-0", AcidiGrassiRic[4].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC14-0", AcidiGrassiRic[5].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC14-1", AcidiGrassiRic[6].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC15-0", AcidiGrassiRic[7].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC16-ISO", AcidiGrassiRic[8].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC16-0", AcidiGrassiRic[9].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC16-1", AcidiGrassiRic[10].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC17-ISO", AcidiGrassiRic[11].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC17-0", AcidiGrassiRic[12].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC17-1", AcidiGrassiRic[13].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC18-0", AcidiGrassiRic[14].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC18-ISO", AcidiGrassiRic[15].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC18-1", AcidiGrassiRic[16].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC18-2", AcidiGrassiRic[17].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC18-3", AcidiGrassiRic[18].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC18-CON", AcidiGrassiRic[19].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC20-0", AcidiGrassiRic[20].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC20-1", AcidiGrassiRic[21].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC22-0", AcidiGrassiRic[22].ToString("F2"));
                InsertTxtBookmark(xNamedBookmarks, "bGC22-1", AcidiGrassiRic[23].ToString("F2"));
                //numero di iodio
                InsertTxtBookmark(xNamedBookmarks, "bnIodio", oNiodio.ToString("F2"));

                //And then the file is saved to disk:
                //((XStorable)oDoc).storeAsURL(PathConverter(@"C:\test.odt"), propVals);
                //((XStorable)oDoc).storeAsURL(PathConverter(SaveTo), propVals);
                PropertyValue[] propValsOut = new PropertyValue[1];
                propValsOut[0]      = new PropertyValue();
                propValsOut[0].Name = "FilterName";
                switch (Estensione)
                {
                case ".odt":
                    break;

                case ".doc":
                    propValsOut[0].Value = new uno.Any("MS Word 97");
                    break;

                case ".pdf":
                    propValsOut[0].Value = new uno.Any("writer_pdf_Export");
                    break;

                default:
                    break;
                }

                ((XStorable)oDoc).storeToURL(PathConverter(SaveTo), propValsOut);
                //chiude
                ((XComponent)oDoc).dispose();
                //And then any memory that's been used can be freed up:
                oDoc = null;
            }
            else
            {
                MessageBox.Show("Template non trovato:\n" + PathTemplate);
            }
        }
        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;
        }
예제 #33
0
 public PerformanceTestObject(XComponentContext xContext)
 {
     m_xContext = xContext;
 }
 public static XControlContainer createDialog(XComponentContext xContext,
     int posX, int posY, int width, int height, string title
     )
 { return createDialog(OO.GetMultiComponentFactory(xContext), xContext, posX, posX, width, height, title); }
예제 #35
0
 public BridgeTestObject( XComponentContext xContext )
 {
     m_xContext = xContext;
 }
예제 #36
0
        /* Attention: Debugging this code (probably in mixed mode) may lead to exceptions
         * which do not occur when running normally (Visual Studio 2003)
         */
        public void testConstructorsService(XComponentContext context)
        {
            Constructors.create1(context,
            true,
            0x80, // -128 in C++,
            Int16.MinValue,
            UInt16.MaxValue,
            Int32.MinValue,
            UInt32.MaxValue,
            Int64.MinValue,
            UInt64.MaxValue,
            0.123f,
            0.456,
            'X',
            "test",
            typeof(Any),
            new Any(true),
            new bool[] { true },
            new byte[] { 0x80}, // in C++ the value is compared with SAL_MIN_INT8 which is -128
            new short[] { Int16.MinValue },
            new UInt16[] { UInt16.MaxValue },
            new Int32[] {Int32.MinValue},
            new UInt32[] { UInt32.MaxValue },
            new long[] { Int64.MinValue },
            new UInt64[] { UInt64.MaxValue },
            new float[] { 0.123f },
            new double[] { 0.456 },
            new char[] { 'X' },
            new string[] { "test" },
            new Type[] { typeof(Any) },
            new Any[] { new Any(true) },
            new bool[][] { new bool[] { true } },
            new Any[][] { new Any[] { new Any(true) } },
            new TestEnum[] { TestEnum.TWO },
            new TestStruct[] { new TestStruct(10) },
            new TestPolyStruct[] { new TestPolyStruct(true) },
            new TestPolyStruct[] { new TestPolyStruct(new Any(true)) },
            new object[] { null },
            TestEnum.TWO,
            new TestStruct(10),
            new TestPolyStruct(true),
            new TestPolyStruct(new Any(true)),
            null
            );

            Constructors.create2(context,
             new Any(true),
             new Any((System.Byte) 0x80),
             new Any(Int16.MinValue),
             new Any(UInt16.MaxValue),
             new Any(Int32.MinValue),
             new Any(UInt32.MaxValue),
             new Any(Int64.MinValue),
             new Any(UInt64.MaxValue),
             new Any(0.123f),
             new Any(0.456),
             new Any('X'),
             new Any("test"),
             new Any(typeof(Any)),
             new Any(true),
             new Any(typeof(bool[]), new bool[] { true }),
             new Any(typeof(byte[]), new byte[] { (System.Byte) 0x80}),
             new Any(typeof(short[]), new short[] { Int16.MinValue }),
             new Any(typeof(UInt16[]), new UInt16[] { UInt16.MaxValue }),
             new Any(typeof(int[]), new int[] { Int32.MinValue }),
             new Any(typeof(UInt32[]), new UInt32[] { UInt32.MaxValue }),
             new Any(typeof(long[]), new long[] { Int64.MinValue }),
             new Any(typeof(UInt64[]), new UInt64[] { UInt64.MaxValue }),
             new Any(typeof(float[]), new float[] { 0.123f }),
             new Any(typeof(double[]), new double[] { 0.456 }),
             new Any(typeof(char[]), new char[] { 'X' }),
             new Any(typeof(string[]), new string[] { "test" }),
             new Any(typeof(Type[]), new Type[] { typeof(Any) }),
             new Any(typeof(Any[]), new Any[] { new Any(true) }),
             new Any(typeof(bool[][]), new bool[][] { new bool[] { true } }),
             new Any(
                 typeof(Any[][]), new Any[][] { new Any[] { new Any(true) } }),
             new Any(typeof(TestEnum[]), new TestEnum[] { TestEnum.TWO }),
             new Any(
                 typeof(TestStruct[]), new TestStruct[] { new TestStruct(10) }),
             new Any(
                 PolymorphicType.GetType(
                     typeof(TestPolyStruct[]),
                     "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>[]"),
                 new TestPolyStruct[] { new TestPolyStruct(true) }) ,
             new Any(
                 PolymorphicType.GetType(
                     typeof(TestPolyStruct[]),
                     "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>[]"),
                 new TestPolyStruct[] { new TestPolyStruct(new Any(true)) }),
             new Any(typeof(object[])/*TODO*/, new object[] { null }),
             new Any(typeof(TestEnum), TestEnum.TWO),
             new Any(typeof(TestStruct), new TestStruct(10)),
             new Any(
                 PolymorphicType.GetType(
                     typeof(TestPolyStruct),
                     "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>"),
                 new TestPolyStruct(true)),
             new Any(
                 PolymorphicType.GetType(
                     typeof(TestPolyStruct),
                     "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>"),
                 new TestPolyStruct(new Any(true))),
             new Any(typeof(object), null)
            );

            XMultiBase1 xMulti = Constructors2.create1(
            context,
            new TestPolyStruct(typeof(int)),
            new TestPolyStruct(new Any(true)),
            new TestPolyStruct(true),
            new TestPolyStruct((Byte) 0x80),
            new TestPolyStruct(Int16.MinValue),
            new TestPolyStruct(Int32.MinValue),
            new TestPolyStruct(Int64.MinValue),
            new TestPolyStruct('X'),
            new TestPolyStruct("test"),
            new TestPolyStruct(0.123f),
            new TestPolyStruct(0.456d),
            new TestPolyStruct(new object()),
            new TestPolyStruct(new uno.util.WeakComponentBase()),
            new TestPolyStruct(TestEnum.TWO),
            new TestPolyStruct(new TestPolyStruct2('X', new Any(true))),
            new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test")),
            new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true)))),
            new TestPolyStruct2( new TestPolyStruct2('X', new Any(true)), new TestPolyStruct('X')),
            new TestPolyStruct(new Type[] { typeof(int)}),
            new TestPolyStruct(new Any[] { new Any(true) }),
            new TestPolyStruct(new bool[] {true}),
            new TestPolyStruct(new byte[] {0x80}),
            new TestPolyStruct(new short[] {Int16.MinValue}),
            new TestPolyStruct(new int[] {Int32.MinValue}),
            new TestPolyStruct(new long[] {Int64.MinValue}),
            new TestPolyStruct(new char[] {'X'}),
            new TestPolyStruct(new string[] {"test"}),
            new TestPolyStruct(new float[] {0.123f}),
            new TestPolyStruct(new double[] {0.456d}),
            new TestPolyStruct(new object[] {new object()}),
            new TestPolyStruct(new unoidl.com.sun.star.lang.XComponent[] {new uno.util.WeakComponentBase()}),
            new TestPolyStruct(new TestEnum[] {TestEnum.TWO}),
            new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2('X', new Any[] {new Any(true)})}),
            new TestPolyStruct(new TestPolyStruct2[] {
                new TestPolyStruct2(new TestPolyStruct('X'), new Any[] {new Any(true)})}),
            new TestPolyStruct(new int[][] { new int[] {Int32.MinValue} }),
            new TestPolyStruct[]{ new TestPolyStruct(Int32.MinValue)},
            new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2('X', new Any(true)))},
            new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test"))},
            new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true))))},
            new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)),new TestPolyStruct('X'))},
            new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct('X')}},
            new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2('X', new Any(true)))}},
            new TestPolyStruct[][]{new TestPolyStruct[] {new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X',new Any(true)), "test"))}},
            new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2('X',new TestPolyStruct(new Any(true))))}},
            new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2('X',new Any(true)),new TestPolyStruct('X'))}}
            );

            //test the returned interface
            xMulti.fn11(1);
        }
        /// <summary>
        /// Gets the ExtendedToolkit.
        /// </summary>
        /// <param name="xMcf">The ServiceManager.</param>
        /// <param name="xContext">The context.</param>
        /// <returns></returns>
        public static XExtendedToolkit GetExtTooklkit(XMultiComponentFactory xMcf = null,
                                                      XComponentContext xContext = null)
        {
            if (_xToolkit == null)
            {
                Logger.Instance.Log(LogPriority.DEBUG, "Oo.BasicObjects", "renew XExtendedToolkit");
                try
                {
                    if (xContext == null)
                    {
                        xContext = GetContext();
                    }

                    if (xMcf == null)
                    {
                        xMcf = GetMultiComponentFactory(xContext);
                    }

                    object toolkit = xMcf.createInstanceWithContext(Services.VCLX_EXT_TOOLKIT, xContext);
                    _xToolkit = toolkit as XExtendedToolkit;
                    addListener(_xToolkit);

                }
                catch (Exception ex)
                {
                    Logger.Instance.Log(LogPriority.ALWAYS, "Can't create ExtendedToolkit ", ex);
                    return null;
                }
            }
            return _xToolkit;
        }
        public static void ExportExcelLO(string FileName, DataSet ds)
        {
            try
            {
                string unoPath = @"C:\Program Files (x86)\LibreOffice 5\program";
                Environment.SetEnvironmentVariable("UNO_PATH", unoPath, EnvironmentVariableTarget.Process);
                Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + @";"
                                                   + unoPath, EnvironmentVariableTarget.Process);

                XComponentContext    oStrap   = uno.util.Bootstrap.bootstrap();
                XMultiServiceFactory oServMan = (XMultiServiceFactory)oStrap.getServiceManager();
                XComponentLoader     desktop  = (XComponentLoader)oServMan.createInstance("com.sun.star.frame.Desktop");
                string          url           = @"private:factory/scalc";
                PropertyValue[] loadProps     = new PropertyValue[3];
                loadProps[0] = new PropertyValue()
                {
                    Name  = "Hidden",
                    Value = new uno.Any(true)
                };

                loadProps[1] = new PropertyValue()
                {
                    Name  = "FilterName",
                    Value = new uno.Any("MS Excel 97")
                };

                loadProps[2] = new PropertyValue()
                {
                    Name  = "ReadOnly",
                    Value = new uno.Any(false)
                };

                XComponent    document = desktop.loadComponentFromURL(url, "_blank", 0, loadProps);
                XSpreadsheets oSheets = ((XSpreadsheetDocument)document).getSheets();
                XIndexAccess  oSheetsIA = (XIndexAccess)oSheets;
                XSpreadsheet  sheet = (XSpreadsheet)oSheetsIA.getByIndex(0).Value;
                int           ii = 0; XCell celija = null;
                foreach (DataColumn kol in ds.Tables[0].Columns)
                {
                    celija = sheet.getCellByPosition(ii, 0);
                    ((XText)celija).setString(kol.ColumnName);
                    //((XPropertySet)celija).setPropertyValue("CellBackColor", new uno.Any(654321));
                    //((XPropertySet)celija).setPropertyValue("CharColor", new uno.Any(333444));
                    ii++;
                }
                ds.Tables[0].AcceptChanges(); ii = 0;
                foreach (DataRow red in ds.Tables[0].Rows)
                {
                    int jj = 0; ii++;
                    foreach (object ob in red.ItemArray)
                    {
                        celija = sheet.getCellByPosition(jj, ii);
                        ((XText)celija).setString(ob.ToString());
                        //((XPropertySet)celija).setPropertyValue("CellBackColor", new uno.Any(888777));
                        jj++;
                    }
                }
                ((XStorable)document).storeToURL("file:///" + FileName.Replace(@"\", "/"), loadProps);
                System.Diagnostics.Process.Start(FileName);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
예제 #39
0
 public WriterDocument(XComponentContext xContext = null, XMultiComponentFactory xMcFactory = null)
 {
     this.xContext   = xContext;
     this.xMcFactory = xMcFactory;
     doc             = OOoDocument.OpenNewDocumentComponent(OO.DocTypes.SWRITER, xContext, xMcFactory);
 }
예제 #40
0
 public Object createInstanceWithContext(XComponentContext xContext)
 {
     return(m_ctor.Invoke(new Object [] { xContext }));
 }
        /// <summary>
        /// Gets the Multi Component Factory (ServiceManager).
        /// </summary>
        /// <param name="xContext">The context.</param>
        /// <returns></returns>
        public static XMultiComponentFactory GetMultiComponentFactory(XComponentContext xContext = null, bool renew = false)
        {
            if (_xMcf != null && !renew)
                return _xMcf;
            try
            {
                if (xContext == null)
                {
                    xContext = GetContext();
                }

                if (xContext != null)
                {
                    TimeLimitExecutor.WaitForExecuteWithTimeLimit(300, () =>
                    {
                        _xMcf = xContext.getServiceManager();
                        addListener(_xMcf);
                    }, "GetMultiComponentFactory");

                    return _xMcf;
                }
                else
                {
                    Logger.Instance.Log(LogPriority.DEBUG, "OO","[ERROR] Could not create a XMultiComponentFactory because the XContext is NULL");
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Can't create ServiceManager factory: " + ex);
            }
            return null;
        }
예제 #42
0
 public Object createInstanceWithArgumentsAndContext(
     uno.Any [] args, XComponentContext xContext)
 {
     return(m_ctor.Invoke(new Object [] { xContext }));
 }
 /// <summary>
 /// Führt anwendungsspezifische Aufgaben durch, die mit der Freigabe, der Zurückgabe oder dem Zurücksetzen von nicht verwalteten Ressourcen zusammenhängen.
 /// </summary>
 public void Dispose()
 {
     serach = false;
     if (serachThread != null)
         serachThread.Abort();
     _desktopChilds = null;
     _xCc = null;
     _xDesktop = null;
     _xMcf = null;
 }
예제 #44
0
    public static int Main(String [] args)
    {
//       System.Diagnostics.Debugger.Launch();
        try
        {
            string bootstrap_ini = "cli_bridgetest_inprocess.ini";
            if (args.Length > 0)
            {
                if (args[0] == "/?")
                {
                    Console.WriteLine(
                        "\n\ncli_bridgetest_inprocess [bootstrap file] \n\n"
                        + "bootstrap file \n"
                        + "\t contains the entries UNO_TYPES and UNO_SERVICES.\n"
                        + "\t If a file is not provided than it is assumed that a\n"
                        + "\t cli_bridgetest_inprocess.ini file can be found in the\n "
                        + "\t current working directory.\n"
                        );
                    return(0);
                }
                else
                {
                    bootstrap_ini = args[0];
                }
            }

            // bootstrap native UNO
            XComponentContext xContext =
                Bootstrap.defaultBootstrap_InitialComponentContext(
                    bootstrap_ini, null);

            using (new uno.util.DisposeGuard((XComponent)xContext))
            {
                XSet xSet = (XSet)xContext.getServiceManager();
                xSet.insert(
                    new uno.Any(
                        typeof(XSingleComponentFactory),
                        new Factory(
                            typeof(cs_testobj.BridgeTestObject),
                            "com.sun.star.test.bridge.cli_uno.CsTestObject")));
                xSet.insert(
                    new uno.Any(
                        typeof(XSingleComponentFactory),
                        new Factory(
                            typeof(vb_testobj.VBBridgeTestObject),
                            "com.sun.star.test.bridge.cli_uno.VbTestObject")));
                xSet.insert(
                    new uno.Any(
                        typeof(XSingleComponentFactory),
                        new Factory(
                            typeof(cpp_bridgetest.BridgeTest),
                            "com.sun.star.test.bridge.cli_uno.CppBridgeTest")));
                xSet.insert(
                    new uno.Any(
                        typeof(XSingleComponentFactory),
                        new Factory(
                            typeof(cs_testobj.BridgeTest),
                            "com.sun.star.test.bridge.cli_uno.CsBridgeTest")));
                xSet.insert(
                    new uno.Any(
                        typeof(XSingleComponentFactory),
                        new Factory(
                            typeof(vb_bridetest.BridgeTest),
                            "com.sun.star.test.bridge.cli_uno.VbBridgeTest")));

                // I.
                // direct unbridged test
                // get client object via singleton entry
                Object test_client;
                XMain  xClient;
                test_client = new cs_testobj.BridgeTest(xContext);
                xClient     = (XMain)test_client;
                Console.WriteLine(
                    "\n[cli bridgetest] 1. C# client calls C# object");
                // run with CLI target object
                xClient.run(
                    new String [] {
                    "com.sun.star.test.bridge.cli_uno.CsTestObject"
                });

                // II:
                // uno -ro uno_services.rdb -ro uno_types.rdb
                //     -s com.sun.star.test.bridge.BridgeTest
                //     -- com.sun.star.test.bridge.cli_uno.TestObject

                // get native client
                test_client =
                    xContext.getServiceManager().createInstanceWithContext(
                        "com.sun.star.test.bridge.BridgeTest", xContext);
                xClient = (XMain)test_client;
                Console.WriteLine(
                    "\n[cli bridgetest] 2. C++ client (native) calls C# object");
                // run with CLI target object
                xClient.run(
                    new String [] {
                    "com.sun.star.test.bridge.cli_uno.CsTestObject",
                    "noCurrentContext"
                });

                // III:
                // uno -ro uno_services.rdb -ro uno_types.rdb
                //     -s com.sun.star.test.bridge.cli_uno.BridgeTest
                //     -- com.sun.star.test.bridge.CppTestObject

                // get CLI client
                test_client =
                    xContext.getServiceManager().createInstanceWithContext(
                        "com.sun.star.test.bridge.cli_uno.CsBridgeTest",
                        xContext);
                xClient = (XMain)test_client;
                Console.WriteLine(
                    "\n[cli bridgetest] 3. C# client calls C++ object (native)");
                // run with native target object
                xClient.run(
                    new String [] { "com.sun.star.test.bridge.CppTestObject" });

                // IV:
                // uno -ro uno_services.rdb -ro uno_types.rdb
                //     -s com.sun.star.test.bridge.cli_uno.VbBridgeTest
                //     -- com.sun.star.test.bridge.CppTestObject
                // get CLI client
                test_client =
                    xContext.getServiceManager().createInstanceWithContext(
                        "com.sun.star.test.bridge.cli_uno.VbBridgeTest",
                        xContext);
                xClient = (XMain)test_client;
                Console.WriteLine(
                    "\n[cli bridgetest] 4. Visual Basic client calls C++ (native) object");
                // run with native target object
                xClient.run(
                    new String [] { "com.sun.star.test.bridge.CppTestObject" });

                // V:
                // uno -ro uno_services.rdb -ro uno_types.rdb
                //     -s com.sun.star.test.bridge.BridgeTest
                //     -- com.sun.star.test.bridge.cli_uno.VbTestObject
                // get CLI client
//                 test_client =
//                     xContext.getServiceManager().createInstanceWithContext(
//                         "com.sun.star.test.bridge.BridgeTest", xContext );
//                 xClient = (XMain) test_client;
//                 Console.WriteLine(
//                     "[cli bridgetest] Visual Basic client: {0}",
//                     xClient.ToString() );
//                 // run with native target object
//                 xClient.run(
//                     new String [] {
//                     "com.sun.star.test.bridge.cli_uno.VbTestObject" } );

                // VI:
                // uno -ro uno_services.rdb -ro uno_types.rdb
                // -s com.sun.star.test.bridge.cli_uno.CppBridgeTest
                // -- com.sun.star.test.bridge.CppTestObject
                test_client =
                    xContext.getServiceManager().createInstanceWithContext(
                        "com.sun.star.test.bridge.cli_uno.CppBridgeTest",
                        xContext);
                xClient = (XMain)test_client;
                Console.WriteLine(
                    "\n[cli bridgetest] 6. CLI C++ client calls C++ object (native)");
                // run with native target object
                xClient.run(
                    new String [] { "com.sun.star.test.bridge.CppTestObject" });
            }
        }
        catch (System.Exception exc)
        {
            GC.WaitForPendingFinalizers();
            System.Console.WriteLine(exc);
            return(-1);
        }

        GC.WaitForPendingFinalizers();
        System.Console.WriteLine("====> all tests ok.");
        return(0);
    }
 public AbstactUnoDialogBase(XComponentContext xContext) : this(xContext, OO.GetMultiComponentFactory(xContext))
 {
 }
예제 #46
0
 public BridgeTestObject(XComponentContext xContext)
 {
     m_xContext = xContext;
 }
예제 #47
0
        /// <summary>
        /// Load document specified by an URL into given frame synchronously.
        /// The result of this operation will be the loaded document for success
        /// or null if loading failed.
        /// </summary>
        /// <param name="xFrame">frame wich should be the target of this load call</param>
        /// <param name="sUrl">unparsed URL for loading</param>
        /// <param name="lProperties">optional arguments</param>
        /// <returns>
        /// the loaded document for success or null if it's failed
        /// </returns>
        public static XComponent LoadDocument(XFrame xFrame, String sUrl, PropertyValue[] lProperties)
        {
            XComponent xDocument;
            String     sOldName = null;

            try
            {
                XComponentContext xCtx = OO.GetContext();

                // First prepare frame for loading
                // We must address it inside the frame tree without any complications.
                // So we set an unambiguous (we hope it) name and use it later.
                // Don't forget to reset original name after that.
                sOldName = xFrame.getName();
                String sTarget = "odk_officedev_desk";
                xFrame.setName(sTarget);

                // Get access to the global component loader of the office
                // for synchronous loading the document.
                var xLoader =
                    (XComponentLoader)xCtx.getServiceManager().createInstanceWithContext(OO.Services.FRAME_DESKTOP, xCtx);

                // Load the document into the target frame by using his name and
                // special search flags.
                xDocument = xLoader.loadComponentFromURL(
                    sUrl,
                    sTarget,
                    FrameSearchFlag.CHILDREN,
                    lProperties);

                // don't forget to restore old frame name ...
                xFrame.setName(sOldName);
            }
            catch (unoidl.com.sun.star.io.IOException exIo)
            {
                // Can be thrown by "loadComponentFromURL()" call.
                // The only thing we should do then is to reset changed frame name!
                System.Diagnostics.Debug.WriteLine(exIo);
                xDocument = null;
                if (sOldName != null)
                {
                    xFrame.setName(sOldName);
                }
            }
            catch (IllegalArgumentException exIllegal)
            {
                // Can be thrown by "loadComponentFromURL()" call.
                // The only thing we should do then is to reset changed frame name!
                System.Diagnostics.Debug.WriteLine(exIllegal);
                xDocument = null;
                if (sOldName != null)
                {
                    xFrame.setName(sOldName);
                }
            }
            catch (RuntimeException exRuntime)
            {
                // Any UNO method of this scope can throw this exception.
                // The only thing we can try(!) is to reset changed frame name.
                System.Diagnostics.Debug.WriteLine(exRuntime);
                xDocument = null;
                if (sOldName != null)
                {
                    xFrame.setName(sOldName);
                }
            }
            catch (unoidl.com.sun.star.uno.Exception exUno)
            {
                // "createInstance()" method of used service manager can throw it.
                // The only thing we should do then is to reset changed frame name!
                System.Diagnostics.Debug.WriteLine(exUno);
                xDocument = null;
                if (sOldName != null)
                {
                    xFrame.setName(sOldName);
                }
            }

            return(xDocument);
        }
        /// <summary>
        /// Resets this instance. And kills the OpenOffice process. 
        /// BE CAREFULL!!
        /// </summary>
        static void reset()
        {
            Logger.Instance.Log(LogPriority.OFTEN, "OO", "Request for OpenOffice connection reset");
            try
            {
                _context = null;
                kill();
                _xMcf = null;
                _xDesktop = null;
                _xToolkit = null;
               // _xMsf = null;
                _xDesktop = GetDesktop();

                addListener(GetContext());

            }
            catch (System.Exception){ }
        }
 public WriterDocument(XComponentContext xContext = null, XMultiComponentFactory xMcFactory = null)
 {
     this.xContext = xContext;
     this.xMcFactory = xMcFactory;
     doc = OOoDocument.OpenNewDocumentComponent(OO.DocTypes.SWRITER, xContext, xMcFactory);
 }
 public WriterDocument(XTextDocument xTextDocument, XComponentContext xContext = null, XMultiComponentFactory xMcFactory = null)
 {
     this.xContext = xContext;
     this.xMcFactory = xMcFactory;
     doc = xTextDocument;
 }
 public AbstactUnoDialogBase(XComponentContext xContext) : this(xContext, OO.GetMultiComponentFactory(xContext)) { }
예제 #52
0
 public Object createInstanceWithArgumentsAndContext(
     uno.Any [] args, XComponentContext xContext )
 {
     return m_ctor.Invoke( new Object [] { xContext } );
 }
        /// <summary>
        /// Gets the multi service factory.
        /// DEPRECATED: for libre office this is always <c>NULL</c>. Use <see cref="XMultiComponentFactory"/> instead.
        /// </summary>
        /// <param name="xCompContext">The x comp context.</param>
        /// <param name="xMcf">The x MCF.</param>
        /// <returns></returns>
        public static XMultiServiceFactory GetMultiServiceFactory(XComponentContext xCompContext = null,
                                                                  XMultiComponentFactory xMcf = null)
        {
            if (_xMsf == null)
            {
                if (xCompContext == null)
                {
                    xCompContext = GetContext();
                }
                if (xMcf == null)
                {
                    xMcf = GetMultiComponentFactory(xCompContext);
                }

                if (_xMsf == null)
                {
                    if (xCompContext != null && xCompContext is XComponentContext)
                    {
                        _xMsf = ((XComponentContext)xCompContext).getServiceManager() as XMultiServiceFactory;
                    }
                }

                if (_xMsf == null) {
                    _xMsf = xMcf.createInstanceWithContext(Services.MULTI_SERVICE_FACTORY, xCompContext) as XMultiServiceFactory;
                }

                addListener(_xMsf);

            }
            return _xMsf;
        }
예제 #54
0
 public Object createInstanceWithContext( XComponentContext xContext )
 {
     return m_ctor.Invoke( new Object [] { xContext } );
 }
        /// <summary>
        /// Gets the desktop.
        /// </summary>
        /// <param name="xMcf">The x MCF.</param>
        /// <param name="xContext">The x context.</param>
        /// <returns></returns>
        public static XDesktop GetDesktop(XMultiComponentFactory xMcf = null, XComponentContext xContext = null)
        {
            if (_xDesktop == null)
            {
                if (xContext == null)
                    xContext = GetContext();

                if (xMcf == null)
                    xMcf = GetMultiComponentFactory(xContext);
                if (xMcf != null)
                {
                    try
                    {
                        object oDesktop = xMcf.createInstanceWithContext(Services.FRAME_DESKTOP, xContext);
                        _xDesktop = oDesktop as XDesktop;
                        addListener(_xDesktop);

                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine("Can't create xDesktop: " + e);
                    }
                }
            }
            return _xDesktop;
        }
 /// <summary>
 /// Gets the multi service factory.
 /// </summary>
 /// <param name="componentContext"> The component context. </param>
 /// <returns> The multi service factory </returns>
 public static XMultiServiceFactory GetMultiServiceFactory(XComponentContext componentContext)
 {
     return((XMultiServiceFactory)componentContext.getServiceManager());
 }
예제 #57
0
        /* Attention: Debugging this code (probably in mixed mode) may lead to exceptions
         * which do not occur when running normally (Visual Studio 2003)
         */
        public void testConstructorsService(XComponentContext context)
        {
            Constructors.create1(context,
                                 true,
                                 0x80, // -128 in C++,
                                 Int16.MinValue,
                                 UInt16.MaxValue,
                                 Int32.MinValue,
                                 UInt32.MaxValue,
                                 Int64.MinValue,
                                 UInt64.MaxValue,
                                 0.123f,
                                 0.456,
                                 'X',
                                 "test",
                                 typeof(Any),
                                 new Any(true),
                                 new bool[] { true },
                                 new byte[] { 0x80 }, // in C++ the value is compared with SAL_MIN_INT8 which is -128
                                 new short[] { Int16.MinValue },
                                 new UInt16[] { UInt16.MaxValue },
                                 new Int32[] { Int32.MinValue },
                                 new UInt32[] { UInt32.MaxValue },
                                 new long[] { Int64.MinValue },
                                 new UInt64[] { UInt64.MaxValue },
                                 new float[] { 0.123f },
                                 new double[] { 0.456 },
                                 new char[] { 'X' },
                                 new string[] { "test" },
                                 new Type[] { typeof(Any) },
                                 new Any[] { new Any(true) },
                                 new bool[][] { new bool[] { true } },
                                 new Any[][] { new Any[] { new Any(true) } },
                                 new TestEnum[] { TestEnum.TWO },
                                 new TestStruct[] { new TestStruct(10) },
                                 new TestPolyStruct[] { new TestPolyStruct(true) },
                                 new TestPolyStruct[] { new TestPolyStruct(new Any(true)) },
                                 new object[] { null },
                                 TestEnum.TWO,
                                 new TestStruct(10),
                                 new TestPolyStruct(true),
                                 new TestPolyStruct(new Any(true)),
                                 null
                                 );

            Constructors.create2(context,
                                 new Any(true),
                                 new Any((System.Byte) 0x80),
                                 new Any(Int16.MinValue),
                                 new Any(UInt16.MaxValue),
                                 new Any(Int32.MinValue),
                                 new Any(UInt32.MaxValue),
                                 new Any(Int64.MinValue),
                                 new Any(UInt64.MaxValue),
                                 new Any(0.123f),
                                 new Any(0.456),
                                 new Any('X'),
                                 new Any("test"),
                                 new Any(typeof(Any)),
                                 new Any(true),
                                 new Any(typeof(bool[]), new bool[] { true }),
                                 new Any(typeof(byte[]), new byte[] { (System.Byte) 0x80 }),
                                 new Any(typeof(short[]), new short[] { Int16.MinValue }),
                                 new Any(typeof(UInt16[]), new UInt16[] { UInt16.MaxValue }),
                                 new Any(typeof(int[]), new int[] { Int32.MinValue }),
                                 new Any(typeof(UInt32[]), new UInt32[] { UInt32.MaxValue }),
                                 new Any(typeof(long[]), new long[] { Int64.MinValue }),
                                 new Any(typeof(UInt64[]), new UInt64[] { UInt64.MaxValue }),
                                 new Any(typeof(float[]), new float[] { 0.123f }),
                                 new Any(typeof(double[]), new double[] { 0.456 }),
                                 new Any(typeof(char[]), new char[] { 'X' }),
                                 new Any(typeof(string[]), new string[] { "test" }),
                                 new Any(typeof(Type[]), new Type[] { typeof(Any) }),
                                 new Any(typeof(Any[]), new Any[] { new Any(true) }),
                                 new Any(typeof(bool[][]), new bool[][] { new bool[] { true } }),
                                 new Any(
                                     typeof(Any[][]), new Any[][] { new Any[] { new Any(true) } }),
                                 new Any(typeof(TestEnum[]), new TestEnum[] { TestEnum.TWO }),
                                 new Any(
                                     typeof(TestStruct[]), new TestStruct[] { new TestStruct(10) }),
                                 new Any(
                                     PolymorphicType.GetType(
                                         typeof(TestPolyStruct[]),
                                         "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>[]"),
                                     new TestPolyStruct[] { new TestPolyStruct(true) }),
                                 new Any(
                                     PolymorphicType.GetType(
                                         typeof(TestPolyStruct[]),
                                         "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>[]"),
                                     new TestPolyStruct[] { new TestPolyStruct(new Any(true)) }),
                                 new Any(typeof(object[]) /*TODO*/, new object[] { null }),
                                 new Any(typeof(TestEnum), TestEnum.TWO),
                                 new Any(typeof(TestStruct), new TestStruct(10)),
                                 new Any(
                                     PolymorphicType.GetType(
                                         typeof(TestPolyStruct),
                                         "unoidl.test.testtools.bridgetest.TestPolyStruct<System.Boolean>"),
                                     new TestPolyStruct(true)),
                                 new Any(
                                     PolymorphicType.GetType(
                                         typeof(TestPolyStruct),
                                         "unoidl.test.testtools.bridgetest.TestPolyStruct<uno.Any>"),
                                     new TestPolyStruct(new Any(true))),
                                 new Any(typeof(object), null)
                                 );


            XMultiBase1 xMulti = Constructors2.create1(
                context,
                new TestPolyStruct(typeof(int)),
                new TestPolyStruct(new Any(true)),
                new TestPolyStruct(true),
                new TestPolyStruct((Byte)0x80),
                new TestPolyStruct(Int16.MinValue),
                new TestPolyStruct(Int32.MinValue),
                new TestPolyStruct(Int64.MinValue),
                new TestPolyStruct('X'),
                new TestPolyStruct("test"),
                new TestPolyStruct(0.123f),
                new TestPolyStruct(0.456d),
                new TestPolyStruct(new object()),
                new TestPolyStruct(new uno.util.WeakComponentBase()),
                new TestPolyStruct(TestEnum.TWO),
                new TestPolyStruct(new TestPolyStruct2('X', new Any(true))),
                new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test")),
                new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true)))),
                new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), new TestPolyStruct('X')),
                new TestPolyStruct(new Type[] { typeof(int) }),
                new TestPolyStruct(new Any[] { new Any(true) }),
                new TestPolyStruct(new bool[] { true }),
                new TestPolyStruct(new byte[] { 0x80 }),
                new TestPolyStruct(new short[] { Int16.MinValue }),
                new TestPolyStruct(new int[] { Int32.MinValue }),
                new TestPolyStruct(new long[] { Int64.MinValue }),
                new TestPolyStruct(new char[] { 'X' }),
                new TestPolyStruct(new string[] { "test" }),
                new TestPolyStruct(new float[] { 0.123f }),
                new TestPolyStruct(new double[] { 0.456d }),
                new TestPolyStruct(new object[] { new object() }),
                new TestPolyStruct(new unoidl.com.sun.star.lang.XComponent[] { new uno.util.WeakComponentBase() }),
                new TestPolyStruct(new TestEnum[] { TestEnum.TWO }),
                new TestPolyStruct(new TestPolyStruct2[] { new TestPolyStruct2('X', new Any[] { new Any(true) }) }),
                new TestPolyStruct(new TestPolyStruct2[] {
                new TestPolyStruct2(new TestPolyStruct('X'), new Any[] { new Any(true) })
            }),
                new TestPolyStruct(new int[][] { new int[] { Int32.MinValue } }),
                new TestPolyStruct[] { new TestPolyStruct(Int32.MinValue) },
                new TestPolyStruct[] { new TestPolyStruct(new TestPolyStruct2('X', new Any(true))) },
                new TestPolyStruct[] { new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test")) },
                new TestPolyStruct2[] { new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true)))) },
                new TestPolyStruct2[] { new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), new TestPolyStruct('X')) },
                new TestPolyStruct[][] { new TestPolyStruct[] { new TestPolyStruct('X') } },
                new TestPolyStruct[][] { new TestPolyStruct[] { new TestPolyStruct(new TestPolyStruct2('X', new Any(true))) } },
                new TestPolyStruct[][] { new TestPolyStruct[] { new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), "test")) } },
                new TestPolyStruct2[][] { new TestPolyStruct2[] { new TestPolyStruct2("test", new TestPolyStruct2('X', new TestPolyStruct(new Any(true)))) } },
                new TestPolyStruct2[][] { new TestPolyStruct2[] { new TestPolyStruct2(new TestPolyStruct2('X', new Any(true)), new TestPolyStruct('X')) } }
                );

            //test the returned interface
            xMulti.fn11(1);
        }
        // use MultiService factory

        public ScrollableContainer(XControlContainer parent, XNameContainer nameContainer, XComponentContext context = null, XMultiComponentFactory parentMCF = null)
        {
            MXDlgModelNameContainer = nameContainer;
            if (context != null) MXContext = context;
            parentCnt = parent;
            this.parentMCF = parentMCF;
        }