/**
   * Called to create an instance of <code>TestEnvironment</code> with an object to test and related
   * objects. Creates a frame and inserts it into document. Obtains accessible object for the
   * inserted text frame.
   *
   * @param Param test parameters
   * @param log writer to log information while testing
   * @see TestEnvironment
   * @see #getTestEnvironment
   */
  protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {

    XInterface oObj = null;
    XTextFrame oFrame1 = null;
    XPropertySet oPropSet = null;
    XText oText = null;
    XTextCursor oCursor = null;

    // get a soffice factory object
    SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory) Param.getMSF());
    // creating Frames
    log.println("creating Frames");
    try {
      oFrame1 = SOfficeFactory.createTextFrame(xTextDoc, 500, 500);
      oPropSet = UnoRuntime.queryInterface(XPropertySet.class, oFrame1);
      oPropSet.setPropertyValue("AnchorType", TextContentAnchorType.AS_CHARACTER);
      oText = xTextDoc.getText();
      oCursor = oText.createTextCursor();

      log.println("inserting Frame1");
      XTextContent the_content = UnoRuntime.queryInterface(XTextContent.class, oFrame1);
      oText.insertTextContent(oCursor, the_content, true);
    } catch (Exception e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't insert TextFrame", e);
    }

    XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);

    AccessibilityTools at = new AccessibilityTools();

    XWindow xWindow =
        AccessibilityTools.getCurrentWindow((XMultiServiceFactory) Param.getMSF(), aModel);
    XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);

    oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TEXT_FRAME);

    log.println("ImplementationName " + utils.getImplName(oObj));
    AccessibilityTools.printAccessibleTree(
        log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));

    TestEnvironment tEnv = new TestEnvironment(oObj);

    XController xController = xTextDoc.getCurrentController();
    XViewSettingsSupplier xViewSetSup =
        UnoRuntime.queryInterface(XViewSettingsSupplier.class, xController);

    final XPropertySet PropSet = xViewSetSup.getViewSettings();

    tEnv.addObjRelation(
        "EventProducer",
        new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {
          public void fireEvent() {
            try {
              // change zoom value to 15%
              PropSet.setPropertyValue("ZoomValue", new Short("15"));
              // and back to 100%
              PropSet.setPropertyValue("ZoomValue", new Short("100"));
            } catch (com.sun.star.lang.WrappedTargetException e) {

            } catch (com.sun.star.lang.IllegalArgumentException e) {

            } catch (com.sun.star.beans.PropertyVetoException e) {

            } catch (com.sun.star.beans.UnknownPropertyException e) {

            }
          }
        });

    return tEnv;
  }