1*cdf0e10cSrcweir using System; 2*cdf0e10cSrcweir using unoidl.com.sun.star.lang; 3*cdf0e10cSrcweir using unoidl.com.sun.star.uno; 4*cdf0e10cSrcweir using unoidl.com.sun.star.bridge; 5*cdf0e10cSrcweir using unoidl.com.sun.star.frame; 6*cdf0e10cSrcweir 7*cdf0e10cSrcweir class DynLoad 8*cdf0e10cSrcweir { 9*cdf0e10cSrcweir 10*cdf0e10cSrcweir static void Main(string[] args) 11*cdf0e10cSrcweir { 12*cdf0e10cSrcweir connect(args); 13*cdf0e10cSrcweir } 14*cdf0e10cSrcweir 15*cdf0e10cSrcweir /** Connect to a running office that is accepting connections. 16*cdf0e10cSrcweir @return The ServiceManager to instantiate office components. */ 17*cdf0e10cSrcweir static private XMultiServiceFactory connect( string[] args ) 18*cdf0e10cSrcweir { 19*cdf0e10cSrcweir if (args.Length == 0) 20*cdf0e10cSrcweir Console.WriteLine("You need to provide a file URL to the office" + 21*cdf0e10cSrcweir " program folder\n"); 22*cdf0e10cSrcweir System.Collections.Hashtable ht = new System.Collections.Hashtable(); 23*cdf0e10cSrcweir ht.Add( "SYSBINDIR", args[ 0 ] ); 24*cdf0e10cSrcweir XComponentContext xContext = 25*cdf0e10cSrcweir uno.util.Bootstrap.defaultBootstrap_InitialComponentContext( 26*cdf0e10cSrcweir args[ 0 ] + "/uno.ini", ht.GetEnumerator() ); 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir if (xContext != null) 29*cdf0e10cSrcweir Console.WriteLine("Successfully created XComponentContext\n"); 30*cdf0e10cSrcweir else 31*cdf0e10cSrcweir Console.WriteLine("Could not create XComponentContext\n"); 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir return null; 34*cdf0e10cSrcweir } 35*cdf0e10cSrcweir } 36