1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 using System;
23 using unoidl.com.sun.star.lang;
24 using unoidl.com.sun.star.uno;
25 using unoidl.com.sun.star.bridge;
26 using unoidl.com.sun.star.frame;
27 
28 class DynLoad
29 {
30 
Main(string[] args)31     static void Main(string[] args)
32     {
33         connect(args);
34     }
35 
36 /** Connect to a running office that is accepting connections.
37         @return  The ServiceManager to instantiate office components. */
connect( string[] args )38     static private XMultiServiceFactory connect( string[] args )
39     {
40         if (args.Length == 0)
41             Console.WriteLine("You need to provide a file URL to the office" +
42                               " program folder\n");
43         System.Collections.Hashtable ht = new System.Collections.Hashtable();
44         ht.Add( "SYSBINDIR", args[ 0 ] );
45         XComponentContext xContext =
46             uno.util.Bootstrap.defaultBootstrap_InitialComponentContext(
47                  args[ 0 ] + "/uno.ini", ht.GetEnumerator() );
48 
49         if (xContext != null)
50             Console.WriteLine("Successfully created XComponentContext\n");
51         else
52             Console.WriteLine("Could not create XComponentContext\n");
53 
54        return null;
55     }
56 }
57