code: @Nullable
    public static XComponent getCurrentComponent(XComponentContext xContext) {
      try {
        XDesktop xdesktop = getCurrentDesktop(xContext);
        if(xdesktop == null) {
          return null;
        }
        else return xdesktop.getCurrentComponent();
      } catch (Throwable t) {
        MessageHandler.printException(t);     // all Exceptions thrown by UnoRuntime.queryInterface are caught
        return null;           // Return null as method failed
      }
    }
docs: Returns the current XComponent
  Returns null if it fails