code: @Nullable
    private XTextViewCursor getViewCursor(XComponentContext xContext) {
      try {
        XComponent xCurrentComponent = OfficeTools.getCurrentComponent(xContext);
        if (xCurrentComponent == null) {
          return null;
        }
        XModel xModel = UnoRuntime.queryInterface(XModel.class, xCurrentComponent);
        if (xModel == null) {
          return null;
        }
        XController xController = xModel.getCurrentController();
        if (xController == null) {
          return null;
        }
        XTextViewCursorSupplier xViewCursorSupplier =
            UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController);
        if (xViewCursorSupplier == null) {
          return null;
        }
        return xViewCursorSupplier.getViewCursor();
      } catch (Throwable t) {
        MessageHandler.printException(t);     // all Exceptions thrown by UnoRuntime.queryInterface are caught
        return null;           // Return null as method failed
      }
    }
docs: Returns ViewCursor
  Returns null if it fails