officebean

16:39:20.495 INFO  jd.cli.Main - Decompiling officebean.jar
package com.sun.star.comp.beans;

import java.io.PrintStream;

public class CallWatchThread
  extends Thread
{
  private static boolean DEBUG = false;
  private Thread aWatchedThread;
  private String aTag;
  private boolean bAlive;
  private long nTimeout;
  
  public CallWatchThread(long paramLong)
  {
    this(paramLong, "");
  }
  
  public CallWatchThread(long paramLong, String paramString)
  {
    super(paramString);
    aWatchedThread = Thread.currentThread();
    nTimeout = paramLong;
    
    aTag = paramString;
    setDaemon(true);
    dbgPrint("CallWatchThread(" + this + ").start(" + paramString + ")");
    start();
  }
  
  public void cancel()
    throws InterruptedException
  {
    dbgPrint("CallWatchThread(" + this + ".cancel(" + aTag + ")");
    if ((aWatchedThread != null) && (aWatchedThread != Thread.currentThread())) {
      throw new RuntimeException("wrong thread");
    }
    aWatchedThread = null;
    if (interrupted()) {
      throw new InterruptedException();
    }
  }
  
  public synchronized void restart()
    throws InterruptedException
  {
    dbgPrint("CallWatchThread(" + this + ".restart(" + aTag + ")");
    if ((aWatchedThread != null) && (aWatchedThread != Thread.currentThread())) {
      throw new RuntimeException("wrong thread");
    }
    bAlive = true;
    if (interrupted()) {
      throw new InterruptedException();
    }
    notify();
  }
  
  public void run()
  {
    dbgPrint("CallWatchThread(" + this + ".run(" + aTag + ") ***** STARTED *****");
    long l = 0L;
    while (aWatchedThread != null)
    {
      dbgPrint("CallWatchThread(" + this + ").run(" + aTag + ") running #" + ++l);
      synchronized (this)
      {
        bAlive = false;
        try
        {
          wait(nTimeout);
        }
        catch (InterruptedException localInterruptedException)
        {
          bAlive = false;
        }
        if ((!bAlive) && (aWatchedThread != null))
        {
          dbgPrint("CallWatchThread(" + this + ").run(" + aTag + ") interrupting");
          aWatchedThread.interrupt();
          aWatchedThread = null;
        }
      }
    }
    dbgPrint("CallWatchThread(" + this + ").run(" + aTag + ") terminated");
  }
  
  private void dbgPrint(String paramString)
  {
    if (DEBUG) {
      System.err.println("OOoBean: " + paramString);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.CallWatchThread
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

import java.awt.Container;

/**
 * @deprecated
 */
public abstract interface ContainerFactory
{
  public abstract Container createContainer();
}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.ContainerFactory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

import com.sun.star.frame.DispatchDescriptor;
import com.sun.star.frame.XController;
import com.sun.star.frame.XDispatch;
import com.sun.star.frame.XDispatchProvider;
import com.sun.star.frame.XFrame;
import com.sun.star.frame.XModel;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.util.URL;

public class Controller
  extends Wrapper
  implements XController
{
  private XController xController;
  private XDispatchProvider xDispatchProvider;
  
  Controller(XController paramXController)
  {
    super(paramXController);
    xController = paramXController;
    xDispatchProvider = ((XDispatchProvider)UnoRuntime.queryInterface(XDispatchProvider.class, paramXController));
  }
  
  public void attachFrame(XFrame paramXFrame)
  {
    xController.attachFrame(paramXFrame);
  }
  
  public boolean attachModel(XModel paramXModel)
  {
    return xController.attachModel(paramXModel);
  }
  
  public boolean suspend(boolean paramBoolean)
  {
    return xController.suspend(paramBoolean);
  }
  
  public Object getViewData()
  {
    return xController.getViewData();
  }
  
  public void restoreViewData(Object paramObject)
  {
    xController.restoreViewData(paramObject);
  }
  
  public XModel getModel()
  {
    return xController.getModel();
  }
  
  public XFrame getFrame()
  {
    return xController.getFrame();
  }
  
  public XDispatch queryDispatch(URL paramURL, String paramString, int paramInt)
  {
    return xDispatchProvider.queryDispatch(paramURL, paramString, paramInt);
  }
  
  public XDispatch[] queryDispatches(DispatchDescriptor[] paramArrayOfDispatchDescriptor)
  {
    return xDispatchProvider.queryDispatches(paramArrayOfDispatchDescriptor);
  }
}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.Controller
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

import com.sun.star.awt.XWindow;
import com.sun.star.frame.DispatchDescriptor;
import com.sun.star.frame.XController;
import com.sun.star.frame.XDispatch;
import com.sun.star.frame.XDispatchProvider;
import com.sun.star.frame.XDispatchProviderInterception;
import com.sun.star.frame.XDispatchProviderInterceptor;
import com.sun.star.frame.XFrame;
import com.sun.star.frame.XFrameActionListener;
import com.sun.star.frame.XFramesSupplier;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.util.URL;

public class Frame
  extends Wrapper
  implements XFrame, XDispatchProvider, XDispatchProviderInterception
{
  private XFrame xFrame;
  private XDispatchProvider xDispatchProvider;
  private XDispatchProviderInterception xDispatchProviderInterception;
  
  public Frame(XFrame paramXFrame)
  {
    super(paramXFrame);
    xFrame = paramXFrame;
    xDispatchProvider = ((XDispatchProvider)UnoRuntime.queryInterface(XDispatchProvider.class, paramXFrame));
    
    xDispatchProviderInterception = ((XDispatchProviderInterception)UnoRuntime.queryInterface(XDispatchProviderInterception.class, paramXFrame));
  }
  
  public void initialize(XWindow paramXWindow)
  {
    xFrame.initialize(paramXWindow);
  }
  
  public XWindow getContainerWindow()
  {
    return xFrame.getContainerWindow();
  }
  
  public void setCreator(XFramesSupplier paramXFramesSupplier)
  {
    xFrame.setCreator(paramXFramesSupplier);
  }
  
  public XFramesSupplier getCreator()
  {
    return xFrame.getCreator();
  }
  
  public String getName()
  {
    return xFrame.getName();
  }
  
  public void setName(String paramString)
  {
    xFrame.setName(paramString);
  }
  
  public XFrame findFrame(String paramString, int paramInt)
  {
    return xFrame.findFrame(paramString, paramInt);
  }
  
  public boolean isTop()
  {
    return xFrame.isTop();
  }
  
  public void activate()
  {
    xFrame.activate();
  }
  
  public void deactivate()
  {
    xFrame.deactivate();
  }
  
  public boolean isActive()
  {
    return xFrame.isActive();
  }
  
  public boolean setComponent(XWindow paramXWindow, XController paramXController)
  {
    return xFrame.setComponent(paramXWindow, paramXController);
  }
  
  public XWindow getComponentWindow()
  {
    return xFrame.getComponentWindow();
  }
  
  public XController getController()
  {
    return xFrame.getController();
  }
  
  public void contextChanged()
  {
    xFrame.contextChanged();
  }
  
  public void addFrameActionListener(XFrameActionListener paramXFrameActionListener)
  {
    xFrame.addFrameActionListener(paramXFrameActionListener);
  }
  
  public void removeFrameActionListener(XFrameActionListener paramXFrameActionListener)
  {
    xFrame.removeFrameActionListener(paramXFrameActionListener);
  }
  
  public XDispatch queryDispatch(URL paramURL, String paramString, int paramInt)
  {
    return xDispatchProvider.queryDispatch(paramURL, paramString, paramInt);
  }
  
  public XDispatch[] queryDispatches(DispatchDescriptor[] paramArrayOfDispatchDescriptor)
  {
    return xDispatchProvider.queryDispatches(paramArrayOfDispatchDescriptor);
  }
  
  public void registerDispatchProviderInterceptor(XDispatchProviderInterceptor paramXDispatchProviderInterceptor)
  {
    xDispatchProviderInterception.registerDispatchProviderInterceptor(paramXDispatchProviderInterceptor);
  }
  
  public void releaseDispatchProviderInterceptor(XDispatchProviderInterceptor paramXDispatchProviderInterceptor)
  {
    xDispatchProviderInterception.releaseDispatchProviderInterceptor(paramXDispatchProviderInterceptor);
  }
}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.Frame
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

public class HasConnectionException
  extends Exception
{}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.HasConnectionException
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

/**
 * @deprecated
 */
public class InvalidArgumentException
  extends Exception
{}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.InvalidArgumentException
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

import com.sun.star.awt.Rectangle;
import com.sun.star.awt.XPointer;
import com.sun.star.awt.XSystemDependentWindowPeer;
import com.sun.star.awt.XToolkit;
import com.sun.star.awt.XWindowPeer;
import com.sun.star.lang.XEventListener;
import com.sun.star.uno.Any;
import com.sun.star.uno.RuntimeException;

class JavaWindowPeerFake
  implements XSystemDependentWindowPeer, XWindowPeer
{
  protected int localSystemType;
  protected Any wrappedHandle;
  
  public JavaWindowPeerFake(Any paramAny, int paramInt)
  {
    localSystemType = paramInt;
    wrappedHandle = paramAny;
  }
  
  public Object getWindowHandle(byte[] paramArrayOfByte, short paramShort)
    throws RuntimeException
  {
    if (paramShort == localSystemType) {
      return wrappedHandle;
    }
    return null;
  }
  
  public XToolkit getToolkit()
    throws RuntimeException
  {
    return null;
  }
  
  public void setPointer(XPointer paramXPointer)
    throws RuntimeException
  {}
  
  public void setBackground(int paramInt)
    throws RuntimeException
  {}
  
  public void invalidate(short paramShort)
    throws RuntimeException
  {}
  
  public void invalidateRect(Rectangle paramRectangle, short paramShort)
    throws RuntimeException
  {}
  
  public void dispose()
    throws RuntimeException
  {}
  
  public void addEventListener(XEventListener paramXEventListener)
    throws RuntimeException
  {}
  
  public void removeEventListener(XEventListener paramXEventListener)
    throws RuntimeException
  {}
}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.JavaWindowPeerFake
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

class LocalOfficeConnection$1 {}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.LocalOfficeConnection.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

import java.io.File;
import java.io.IOException;

class LocalOfficeConnection$OfficeService
  implements NativeService
{
  private LocalOfficeConnection$OfficeService(LocalOfficeConnection paramLocalOfficeConnection) {}
  
  public String getIdentifier()
  {
    if (LocalOfficeConnection.access$100(this$0) == null) {
      return LocalOfficeConnection.getPipeName();
    }
    return LocalOfficeConnection.access$100(this$0);
  }
  
  public void startupService()
    throws IOException
  {
    int i = 4;
    String str1 = null;
    try
    {
      str1 = System.getProperty("com.sun.star.officebean.Options");
      if (str1 != null) {
        i++;
      }
    }
    catch (SecurityException localSecurityException)
    {
      localSecurityException.printStackTrace();
    }
    String[] arrayOfString = new String[i];
    
    String str2 = System.getenv("UNO_PATH");
    if (str2 == null) {
      throw new IOException("UNO_PATH environment variable is not set (required system path to the office program directory)");
    }
    arrayOfString[0] = new File(str2, "soffice").getPath();
    arrayOfString[1] = "-nologo";
    arrayOfString[2] = "-nodefault";
    if (LocalOfficeConnection.access$200(this$0).equals("pipe")) {
      arrayOfString[3] = ("-accept=pipe,name=" + getIdentifier() + ";" + LocalOfficeConnection.access$300(this$0) + ";" + LocalOfficeConnection.access$400(this$0));
    } else if (LocalOfficeConnection.access$200(this$0).equals("socket")) {
      arrayOfString[3] = ("-accept=socket,port=" + LocalOfficeConnection.access$500(this$0) + ";urp");
    } else {
      throw new IOException("not connection specified");
    }
    if (str1 != null) {
      arrayOfString[4] = str1;
    }
    LocalOfficeConnection.access$602(this$0, Runtime.getRuntime().exec(arrayOfString));
    if (LocalOfficeConnection.access$600(this$0) == null) {
      throw new RuntimeException("cannot start soffice: " + arrayOfString);
    }
    new LocalOfficeConnection.StreamProcessor(this$0, LocalOfficeConnection.access$600(this$0).getInputStream(), System.out);
    new LocalOfficeConnection.StreamProcessor(this$0, LocalOfficeConnection.access$600(this$0).getErrorStream(), System.err);
  }
  
  public int getStartupTime()
  {
    return 60;
  }
}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.LocalOfficeConnection.OfficeService
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class LocalOfficeConnection$StreamProcessor
  extends Thread
{
  InputStream m_in;
  PrintStream m_print;
  
  public LocalOfficeConnection$StreamProcessor(LocalOfficeConnection paramLocalOfficeConnection, InputStream paramInputStream, PrintStream paramPrintStream)
  {
    m_in = paramInputStream;
    m_print = paramPrintStream;
    start();
  }
  
  public void run()
  {
    BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(m_in));
    try
    {
      for (;;)
      {
        String str = localBufferedReader.readLine();
        if (str == null) {
          break;
        }
        m_print.println(str);
      }
    }
    catch (IOException localIOException)
    {
      localIOException.printStackTrace(System.err);
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.LocalOfficeConnection.StreamProcessor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

import com.sun.star.beans.XPropertySet;
import com.sun.star.bridge.BridgeExistsException;
import com.sun.star.bridge.XBridge;
import com.sun.star.bridge.XBridgeFactory;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.connection.ConnectionSetupException;
import com.sun.star.connection.NoConnectException;
import com.sun.star.connection.XConnection;
import com.sun.star.connection.XConnector;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XEventListener;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lib.uno.helper.UnoUrl;
import com.sun.star.lib.util.NativeLibraryLoader;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import java.awt.Container;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

public class LocalOfficeConnection
  implements OfficeConnection
{
  public static final String OFFICE_APP_NAME = "soffice";
  public static final String OFFICE_LIB_NAME = "officebean";
  public static final String OFFICE_ID_SUFFIX = "_Office";
  private static String mProgramPath;
  private Process mProcess;
  private ContainerFactory mContainerFactory;
  private XComponentContext mContext;
  private XBridge mBridge;
  private String mURL;
  private String mConnType;
  private String mPipe;
  private String mPort;
  private String mProtocol;
  private String mInitialObject;
  private List mComponents = new Vector();
  private static long m_nBridgeCounter = 0L;
  
  static
  {
    if (System.getProperty("os.name").startsWith("Windows"))
    {
      try
      {
        NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "msvcr70");
      }
      catch (Throwable localThrowable1)
      {
        System.err.println("cannot find msvcr70");
      }
      try
      {
        NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "msvcr71");
      }
      catch (Throwable localThrowable2)
      {
        System.err.println("cannot find msvcr71");
      }
      try
      {
        NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "uwinapi");
      }
      catch (Throwable localThrowable3)
      {
        System.err.println("cannot find uwinapi");
      }
      try
      {
        NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "jawt");
      }
      catch (Throwable localThrowable4)
      {
        System.err.println("cannot find jawt");
      }
    }
    NativeLibraryLoader.loadLibrary(LocalOfficeConnection.class.getClassLoader(), "officebean");
  }
  
  private void dbgPrint(String paramString)
  {
    System.err.println(paramString);
  }
  
  public LocalOfficeConnection()
  {
    try
    {
      setUnoUrl("uno:pipe,name=" + getPipeName() + ";urp;StarOffice.ServiceManager");
    }
    catch (MalformedURLException localMalformedURLException) {}
  }
  
  protected LocalOfficeConnection(XComponentContext paramXComponentContext)
  {
    mContext = paramXComponentContext;
  }
  
  public void setUnoUrl(String paramString)
    throws MalformedURLException
  {
    mURL = null;
    
    String str = "uno:localoffice";
    if (paramString.startsWith(str)) {
      parseUnoUrlWithOfficePath(paramString, str);
    } else {
      try
      {
        UnoUrl localUnoUrl = UnoUrl.parseUnoUrl(paramString);
        mProgramPath = null;
        mConnType = localUnoUrl.getConnection();
        mPipe = ((String)localUnoUrl.getConnectionParameters().get("pipe"));
        mPort = ((String)localUnoUrl.getConnectionParameters().get("port"));
        mProtocol = localUnoUrl.getProtocol();
        mInitialObject = localUnoUrl.getRootOid();
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
        throw new MalformedURLException("Invalid UNO connection URL.");
      }
    }
    mURL = paramString;
  }
  
  public void setContainerFactory(ContainerFactory paramContainerFactory)
  {
    mContainerFactory = paramContainerFactory;
  }
  
  public synchronized XComponentContext getComponentContext()
  {
    if (mContext == null) {
      mContext = connect();
    }
    return mContext;
  }
  
  public OfficeWindow createOfficeWindow(Container paramContainer)
  {
    return new LocalOfficeWindow(this);
  }
  
  public void dispose()
  {
    Iterator localIterator = mComponents.iterator();
    while (localIterator.hasNext() == true) {
      try
      {
        ((XEventListener)localIterator.next()).disposing(null);
      }
      catch (RuntimeException localRuntimeException) {}
    }
    mComponents.clear();
    if (mBridge != null)
    {
      XComponent localXComponent = (XComponent)UnoRuntime.queryInterface(XComponent.class, mBridge);
      if (localXComponent != null) {
        localXComponent.dispose();
      } else {
        System.err.println("LocalOfficeConnection: could not dispose bridge!");
      }
      mBridge = null;
    }
    mContainerFactory = null;
    mContext = null;
  }
  
  public void addEventListener(XEventListener paramXEventListener)
  {
    mComponents.add(paramXEventListener);
  }
  
  public void removeEventListener(XEventListener paramXEventListener)
  {
    mComponents.remove(paramXEventListener);
  }
  
  private XComponentContext connect()
  {
    try
    {
      XComponentContext localXComponentContext1 = Bootstrap.createInitialComponentContext(null);
      
      XMultiComponentFactory localXMultiComponentFactory = localXComponentContext1.getServiceManager();
      
      Object localObject1 = null;
      Object localObject2;
      try
      {
        localObject1 = resolve(localXComponentContext1, mURL);
      }
      catch (NoConnectException localNoConnectException2)
      {
        localNoConnectException2 = 
        
          localNoConnectException2;localObject2 = new OfficeService(null);((OfficeService)localObject2).startupService();long l = System.currentTimeMillis() + 1000 * ((OfficeService)localObject2).getStartupTime();
        while (localObject1 == null) {
          try
          {
            Thread.currentThread();Thread.sleep(500L);
            localObject1 = resolve(localXComponentContext1, mURL);
          }
          catch (NoConnectException localNoConnectException3)
          {
            if (System.currentTimeMillis() > l) {
              throw localNoConnectException3;
            }
          }
        }
      }
      finally {}
      if (null != localObject1)
      {
        XPropertySet localXPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, localObject1);
        
        localObject2 = localXPropertySet.getPropertyValue("DefaultContext");
        return (XComponentContext)UnoRuntime.queryInterface(XComponentContext.class, localObject2);
      }
    }
    catch (NoConnectException localNoConnectException1)
    {
      System.out.println("Couldn't connect to remote server");
      System.out.println(localNoConnectException1.getMessage());
    }
    catch (ConnectionSetupException localConnectionSetupException)
    {
      System.out.println("Couldn't access necessary local resource to establish the interprocess connection");
      System.out.println(localConnectionSetupException.getMessage());
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      System.out.println("uno-url is syntactical illegal ( " + mURL + " )");
      System.out.println(localIllegalArgumentException.getMessage());
    }
    catch (com.sun.star.uno.RuntimeException localRuntimeException)
    {
      System.out.println("--- RuntimeException:");
      System.out.println(localRuntimeException.getMessage());
      localRuntimeException.printStackTrace();
      System.out.println("--- end.");
      throw localRuntimeException;
    }
    catch (Exception localException)
    {
      System.out.println("java.lang.Exception: ");
      System.out.println(localException);
      localException.printStackTrace();
      System.out.println("--- end.");
      throw new com.sun.star.uno.RuntimeException(localException.toString());
    }
    return null;
  }
  
  private Object resolve(XComponentContext paramXComponentContext, String paramString)
    throws NoConnectException, ConnectionSetupException, IllegalArgumentException
  {
    String str1 = null;
    String str2 = null;
    String str3 = null;
    if (paramString.indexOf(';') == -1)
    {
      str1 = paramString;
      str2 = "iiop";
      str3 = "classic_uno";
    }
    else
    {
      int i = paramString.indexOf(':');
      localObject2 = paramString.substring(0, i).trim();
      paramString = paramString.substring(i + 1).trim();
      
      i = paramString.indexOf(';');
      str1 = paramString.substring(0, i).trim();
      paramString = paramString.substring(i + 1).trim();
      
      i = paramString.indexOf(';');
      str2 = paramString.substring(0, i).trim();
      paramString = paramString.substring(i + 1).trim();
      
      str3 = paramString.trim().trim();
    }
    Object localObject1 = null;
    Object localObject2 = null;
    
    XMultiComponentFactory localXMultiComponentFactory = paramXComponentContext.getServiceManager();
    try
    {
      localObject2 = (XBridgeFactory)UnoRuntime.queryInterface(XBridgeFactory.class, localXMultiComponentFactory.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", paramXComponentContext));
    }
    catch (com.sun.star.uno.Exception localException1)
    {
      throw new com.sun.star.uno.RuntimeException(localException1.getMessage());
    }
    synchronized (this)
    {
      if (mBridge == null)
      {
        Object localObject3 = null;
        try
        {
          localObject3 = localXMultiComponentFactory.createInstanceWithContext("com.sun.star.connection.Connector", paramXComponentContext);
        }
        catch (com.sun.star.uno.Exception localException2)
        {
          throw new com.sun.star.uno.RuntimeException(localException2.getMessage());
        }
        XConnector localXConnector = (XConnector)UnoRuntime.queryInterface(XConnector.class, localObject3);
        
        XConnection localXConnection = localXConnector.connect(str1);
        
        String str4 = "OOoBean_private_bridge_" + String.valueOf(m_nBridgeCounter++);
        try
        {
          mBridge = ((XBridgeFactory)localObject2).createBridge(str4, str2, localXConnection, null);
        }
        catch (BridgeExistsException localBridgeExistsException)
        {
          throw new com.sun.star.uno.RuntimeException(localBridgeExistsException.getMessage());
        }
      }
      localObject1 = mBridge.getInstance(str3);
      return localObject1;
    }
  }
  
  private static String getProgramPath()
  {
    if (mProgramPath == null)
    {
      String str1 = "soffice";
      String str2 = System.getProperty("os.name");
      if (str2.startsWith("Windows")) {
        str1 = "soffice.exe";
      }
      File localFile = NativeLibraryLoader.getResource(LocalOfficeConnection.class.getClassLoader(), str1);
      if (localFile != null) {
        mProgramPath = localFile.getParent();
      }
      if (mProgramPath == null) {
        mProgramPath = "";
      }
    }
    return mProgramPath;
  }
  
  private void parseUnoUrlWithOfficePath(String paramString1, String paramString2)
    throws MalformedURLException
  {
    int i = paramString1.indexOf(";urp;StarOffice.NamingService");
    if (i < 0) {
      throw new MalformedURLException("Invalid UNO connection URL.");
    }
    String str1 = paramString1.substring(paramString2.length(), i + 1);
    
    String str2 = null;
    String str3 = null;
    String str4 = null;
    
    int j = 0;
    StringBuffer localStringBuffer = new StringBuffer();
    for (i = 0; i < str1.length(); i++)
    {
      char c = str1.charAt(i);
      switch (j)
      {
      case 0: 
        switch (c)
        {
        case ',': 
          localStringBuffer.delete(0, localStringBuffer.length());
          j = 1;
          break;
        case ';': 
          j = 7;
          break;
        default: 
          localStringBuffer.delete(0, localStringBuffer.length());
          localStringBuffer.append(c);
          j = 1;
        }
        break;
      case 1: 
        switch (c)
        {
        case ' ': 
        case '=': 
          str2 = localStringBuffer.toString();
          j = c == ' ' ? 2 : 3;
          break;
        case ',': 
        case ';': 
          j = -6;
          break;
        default: 
          localStringBuffer.append(c);
        }
        break;
      case 2: 
        switch (c)
        {
        case '=': 
          j = 3;
          break;
        case ' ': 
          break;
        default: 
          j = -1;
        }
        break;
      case 3: 
        switch (c)
        {
        case ' ': 
          break;
        default: 
          localStringBuffer.delete(0, localStringBuffer.length());
          localStringBuffer.append(c);
          j = 4;
        }
        break;
      case 4: 
        switch (c)
        {
        case ' ': 
        case ',': 
        case ';': 
          i--;
          j = 5;
          if (str2.equals("path"))
          {
            if (str3 == null) {
              str3 = localStringBuffer.toString();
            } else {
              j = -3;
            }
          }
          else if (str2.equals("pipe"))
          {
            if (str4 == null) {
              str4 = localStringBuffer.toString();
            } else {
              j = -4;
            }
          }
          else {
            j = -2;
          }
          localStringBuffer.delete(0, localStringBuffer.length());
          break;
        default: 
          localStringBuffer.append(c);
        }
        break;
      case 5: 
        switch (c)
        {
        case ' ': 
          break;
        case ',': 
          j = 6;
          break;
        case ';': 
          j = 7;
          break;
        default: 
          j = -5;
        }
        break;
      case 6: 
        switch (c)
        {
        case ' ': 
          break;
        default: 
          localStringBuffer.delete(0, localStringBuffer.length());
          localStringBuffer.append(c);
          j = 1;
        }
        break;
      default: 
        throw new MalformedURLException("Invalid UNO connection URL.");
      }
    }
    if (j != 7) {
      throw new MalformedURLException("Invalid UNO connection URL.");
    }
    if (str3 != null) {
      mProgramPath = str3;
    }
    if (str4 != null) {
      mPipe = str4;
    }
  }
  
  private static String replaceAll(String paramString1, String paramString2, String paramString3)
  {
    StringBuffer localStringBuffer = new StringBuffer(paramString1);
    
    int i = paramString1.length();
    int j = paramString2.length();
    while ((i = paramString1.lastIndexOf(paramString2, i - 1)) > -1) {
      localStringBuffer.replace(i, i + j, paramString3);
    }
    return localStringBuffer.toString();
  }
  
  static String getPipeName()
  {
    String str = System.getProperty("user.name") + "_Office";
    str = replaceAll(str, "_", "%B7");
    return replaceAll(replaceAll(URLEncoder.encode(str), "+", "%20"), "%", "_");
  }
  
  private class OfficeService
    implements NativeService
  {
    private OfficeService() {}
    
    public String getIdentifier()
    {
      if (mPipe == null) {
        return LocalOfficeConnection.getPipeName();
      }
      return mPipe;
    }
    
    public void startupService()
      throws IOException
    {
      int i = 4;
      String str1 = null;
      try
      {
        str1 = System.getProperty("com.sun.star.officebean.Options");
        if (str1 != null) {
          i++;
        }
      }
      catch (SecurityException localSecurityException)
      {
        localSecurityException.printStackTrace();
      }
      String[] arrayOfString = new String[i];
      
      String str2 = System.getenv("UNO_PATH");
      if (str2 == null) {
        throw new IOException("UNO_PATH environment variable is not set (required system path to the office program directory)");
      }
      arrayOfString[0] = new File(str2, "soffice").getPath();
      arrayOfString[1] = "-nologo";
      arrayOfString[2] = "-nodefault";
      if (mConnType.equals("pipe")) {
        arrayOfString[3] = ("-accept=pipe,name=" + getIdentifier() + ";" + mProtocol + ";" + mInitialObject);
      } else if (mConnType.equals("socket")) {
        arrayOfString[3] = ("-accept=socket,port=" + mPort + ";urp");
      } else {
        throw new IOException("not connection specified");
      }
      if (str1 != null) {
        arrayOfString[4] = str1;
      }
      mProcess = Runtime.getRuntime().exec(arrayOfString);
      if (mProcess == null) {
        throw new RuntimeException("cannot start soffice: " + arrayOfString);
      }
      new LocalOfficeConnection.StreamProcessor(LocalOfficeConnection.this, mProcess.getInputStream(), System.out);
      new LocalOfficeConnection.StreamProcessor(LocalOfficeConnection.this, mProcess.getErrorStream(), System.err);
    }
    
    public int getStartupTime()
    {
      return 60;
    }
  }
  
  class StreamProcessor
    extends Thread
  {
    InputStream m_in;
    PrintStream m_print;
    
    public StreamProcessor(InputStream paramInputStream, PrintStream paramPrintStream)
    {
      m_in = paramInputStream;
      m_print = paramPrintStream;
      start();
    }
    
    public void run()
    {
      BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(m_in));
      try
      {
        for (;;)
        {
          String str = localBufferedReader.readLine();
          if (str == null) {
            break;
          }
          m_print.println(str);
        }
      }
      catch (IOException localIOException)
      {
        localIOException.printStackTrace(System.err);
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.LocalOfficeConnection
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

import com.sun.star.awt.Rectangle;
import com.sun.star.awt.WindowClass;
import com.sun.star.awt.WindowDescriptor;
import com.sun.star.awt.XToolkit;
import com.sun.star.awt.XVclWindowPeer;
import com.sun.star.awt.XWindow;
import com.sun.star.awt.XWindowPeer;
import com.sun.star.beans.NamedValue;
import com.sun.star.lang.EventObject;
import com.sun.star.lang.XEventListener;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.Any;
import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import java.awt.Canvas;
import java.awt.Component;
import java.io.PrintStream;

public class LocalOfficeWindow
  extends Canvas
  implements OfficeWindow, XEventListener
{
  private transient OfficeConnection mConnection;
  private transient XWindowPeer mParentProxy;
  private transient XWindowPeer mWindow;
  private boolean bPeer = false;
  
  protected LocalOfficeWindow(OfficeConnection paramOfficeConnection)
  {
    mConnection = paramOfficeConnection;
    mConnection.addEventListener(this);
  }
  
  public Component getAWTComponent()
  {
    return this;
  }
  
  public XWindowPeer getUNOWindowPeer()
  {
    if (mWindow == null) {
      createUNOWindowPeer();
    }
    return mWindow;
  }
  
  public void disposing(EventObject paramEventObject)
  {
    mWindow = null;
    mConnection = null;
  }
  
  private XToolkit queryAWTToolkit()
    throws com.sun.star.uno.Exception
  {
    XComponentContext localXComponentContext = mConnection.getComponentContext();
    if (localXComponentContext != null)
    {
      XMultiComponentFactory localXMultiComponentFactory = mConnection.getComponentContext().getServiceManager();
      
      XMultiServiceFactory localXMultiServiceFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, localXMultiComponentFactory);
      
      Object localObject = localXMultiServiceFactory.createInstance("com.sun.star.awt.Toolkit");
      return (XToolkit)UnoRuntime.queryInterface(XToolkit.class, localObject);
    }
    return null;
  }
  
  private synchronized void aquireSystemWindow()
  {
    if (!bPeer)
    {
      XVclWindowPeer localXVclWindowPeer = (XVclWindowPeer)UnoRuntime.queryInterface(XVclWindowPeer.class, mWindow);
      
      localXVclWindowPeer.setProperty("PluginParent", getWrappedWindowHandle());
      bPeer = true;
      
      XWindow localXWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow);
      localXWindow.setVisible(true);
    }
  }
  
  private synchronized void releaseSystemWindow()
  {
    if (bPeer)
    {
      XWindow localXWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow);
      localXWindow.setVisible(false);
      
      XVclWindowPeer localXVclWindowPeer = (XVclWindowPeer)UnoRuntime.queryInterface(XVclWindowPeer.class, mWindow);
      
      localXVclWindowPeer.setProperty("PluginParent", new Long(0L));
      bPeer = false;
    }
  }
  
  public void setVisible(boolean paramBoolean)
  {
    super.setVisible(paramBoolean);
    if (paramBoolean) {
      aquireSystemWindow();
    } else {
      releaseSystemWindow();
    }
  }
  
  private synchronized XWindowPeer createUNOWindowPeer()
  {
    try
    {
      int i = getNativeWindowSystemType();
      JavaWindowPeerFake localJavaWindowPeerFake;
      if (isShowing())
      {
        localJavaWindowPeerFake = new JavaWindowPeerFake(getWrappedWindowHandle(), i);
        bPeer = true;
      }
      else
      {
        localJavaWindowPeerFake = null;
        bPeer = false;
      }
      Rectangle localRectangle = new Rectangle(0, 0, 20, 20);
      WindowDescriptor localWindowDescriptor = new WindowDescriptor();
      Type = WindowClass.TOP;
      Parent = localJavaWindowPeerFake;
      Bounds = localRectangle;
      WindowServiceName = "workwindow";
      WindowAttributes = (i == 1 ? 1 : 0);
      
      mWindow = queryAWTToolkit().createWindow(localWindowDescriptor);
      
      XWindow localXWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, mWindow);
      localXWindow.setVisible(bPeer);
    }
    catch (com.sun.star.uno.Exception localException) {}
    return mWindow;
  }
  
  public void removeNotify()
  {
    try
    {
      releaseSystemWindow();
    }
    catch (Exception localException)
    {
      System.err.println("LocaleOfficeWindow.removeNotify: Exception in releaseSystemWindow.");
      System.err.println(localException.getMessage());
      localException.printStackTrace(System.err);
    }
    super.removeNotify();
  }
  
  private native long getNativeWindow();
  
  private native int getNativeWindowSystemType();
  
  protected Any getWrappedWindowHandle()
  {
    NamedValue localNamedValue1 = new NamedValue("WINDOW", new Any(new Type(Long.class), new Long(getNativeWindow())));
    
    NamedValue localNamedValue2 = new NamedValue("XEMBED", new Any(new Type(Boolean.class), new Boolean(false)));
    if (getNativeWindowSystemType() == 6)
    {
      String str = System.getProperty("java.vendor");
      if ((str.equals("Sun Microsystems Inc.")) && (Boolean.valueOf(System.getProperty("sun.awt.xembedserver")).booleanValue())) {
        localNamedValue2 = new NamedValue("XEMBED", new Any(new Type(Boolean.class), new Boolean(true)));
      }
    }
    return new Any(new Type("[]com.sun.star.beans.NamedValue"), new NamedValue[] { localNamedValue1, localNamedValue2 });
  }
}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.LocalOfficeWindow
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

import com.sun.star.connection.XConnection;
import com.sun.star.io.IOException;
import com.sun.star.uno.RuntimeException;

class NativeConnection
  implements XConnection
{
  private long NativeHandle;
  private String Description;
  
  public native void connect(NativeService paramNativeService)
    throws IOException;
  
  public native int read(byte[][] paramArrayOfByte, int paramInt)
    throws IOException, RuntimeException;
  
  public native void write(byte[] paramArrayOfByte)
    throws IOException, RuntimeException;
  
  public native void flush()
    throws IOException, RuntimeException;
  
  public native void close()
    throws IOException, RuntimeException;
  
  public synchronized String getDescription()
    throws RuntimeException
  {
    return Description;
  }
}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.NativeConnection
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

import java.io.IOException;

abstract interface NativeService
{
  public abstract String getIdentifier();
  
  public abstract void startupService()
    throws IOException;
  
  public abstract int getStartupTime();
}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.NativeService
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

public class NoConnectionException
  extends Exception
{}

/* Location:
 * Qualified Name:     com.sun.star.comp.beans.NoConnectionException
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.sun.star.comp.beans;

public class N
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd