示例#1
0
  /* ------------------------------------------------------------------ */
  private boolean ensureDataSource() throws Exception {
    m_orb = (XMultiServiceFactory) param.getMSF();

    XNameAccess databaseContext =
        UnoRuntime.queryInterface(
            XNameAccess.class, m_orb.createInstance("com.sun.star.sdb.DatabaseContext"));
    XNamingService namingService = UnoRuntime.queryInterface(XNamingService.class, databaseContext);

    // revoke the data source, if it previously existed
    if (databaseContext.hasByName(m_dataSourceName)) namingService.revokeObject(m_dataSourceName);

    // // create a new ODB file, and register it with its URL
    m_databaseDocument = new HsqlDatabase(m_orb);
    String documentURL = m_databaseDocument.getDocumentURL();
    namingService.registerObject(m_dataSourceName, databaseContext.getByName(documentURL));

    m_dataSource =
        UnoRuntime.queryInterface(XDataSource.class, databaseContext.getByName(m_dataSourceName));
    m_dataSourceProps = dbfTools.queryPropertySet(m_dataSource);

    XPropertySet dataSourceSettings =
        UnoRuntime.queryInterface(
            XPropertySet.class, m_dataSourceProps.getPropertyValue("Settings"));
    dataSourceSettings.setPropertyValue("FormsCheckRequiredFields", new Boolean(false));

    return m_dataSource != null;
  }
  /**
   * Creating a TestEnvironment for the interfaces to be tested. Creates an instance of the service
   * <code>com.sun.star.frame.ContentHandlerFactory</code>.
   *
   * <p>
   */
  @Override
  protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log)
      throws Exception {
    XInterface oObj = null;
    Object oInterface = null;

    // now get the OButtonControl
    oInterface = Param.getMSF().createInstance("com.sun.star.frame.ContentHandlerFactory");

    oObj = (XInterface) oInterface;
    log.println("ImplName: " + utils.getImplName(oObj));

    log.println("creating a new environment for object");
    TestEnvironment tEnv = new TestEnvironment(oObj);

    XNameAccess xNA = UnoRuntime.queryInterface(XNameAccess.class, oObj);
    tEnv.addObjRelation("XMSF.serviceNames", xNA.getElementNames());
    xNA.getElementNames();

    // com.sun.star.container.XContainerQuery
    NamedValue[] querySequenze = new NamedValue[1];
    NamedValue query = new NamedValue();
    query.Name = "Name";
    query.Value = "com.sun.star.comp.framework.SoundHandler";
    querySequenze[0] = query;

    tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties", querySequenze);

    return tEnv;
  } // finish method getTestEnvironment
  /**
   * Get the collection of tables. Then check it.
   *
   * <p>Has <b>OK</b> status if returned collection contains element with name 'SwXTextDocument'.
   */
  public void _getTextTables() {
    boolean res = false;

    XNameAccess the_tables = oObj.getTextTables();
    res = the_tables.hasByName("SwXTextDocument");

    tRes.tested("getTextTables()", res);
  }
  /**
   * Check BackColor and IsLandscape properties, wait for an exception: test is ok if no exception
   * happened.
   */
  public void checkChangeColor() {
    try {
      XMultiServiceFactory m_xMSF_ = (XMultiServiceFactory) param.getMSF();
      XComponentLoader aLoader =
          (XComponentLoader)
              UnoRuntime.queryInterface(
                  XComponentLoader.class, m_xMSF_.createInstance("com.sun.star.frame.Desktop"));
      XComponent xDocument =
          (XComponent)
              UnoRuntime.queryInterface(
                  XComponent.class,
                  aLoader.loadComponentFromURL(
                      "private:factory/swriter", "_blank", 0, new PropertyValue[0]));
      //        xDocument.addEventListener( this );

      XTextDocument oDoc =
          (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xDocument);
      XMultiServiceFactory oDocMSF =
          (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc);

      // XInterface xInterface = (XInterface) oDocMSF.createInstance( "com.sun.star.style.PageStyle"
      // );

      // create a supplier to get the Style family collection
      XStyleFamiliesSupplier xSupplier =
          (XStyleFamiliesSupplier) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, oDoc);

      // get the NameAccess interface from the Style family collection
      XNameAccess xNameAccess = xSupplier.getStyleFamilies();

      XNameContainer xPageStyleCollection =
          (XNameContainer)
              UnoRuntime.queryInterface(XNameContainer.class, xNameAccess.getByName("PageStyles"));

      // create a PropertySet to set the properties for the new Pagestyle
      XPropertySet xPropertySet =
          (XPropertySet)
              UnoRuntime.queryInterface(
                  XPropertySet.class, xPageStyleCollection.getByName("Standard"));

      log.println("BackColor @ " + xPropertySet.getPropertyValue("BackColor").toString());
      log.println("IsLandscape @ " + xPropertySet.getPropertyValue("IsLandscape").toString());
      log.println(
          "Size @ H:"
              + ((Size) xPropertySet.getPropertyValue("Size")).Height
              + " W:"
              + ((Size) xPropertySet.getPropertyValue("Size")).Width);

      log.println("Set Landscape");
      xPropertySet.setPropertyValue("IsLandscape", new Boolean(true));
      log.println("Set BackColor");
      xPropertySet.setPropertyValue("BackColor", new Integer((int) 255000000));
    } catch (Exception e) {
      e.printStackTrace();
      failed("Exception.");
    }
  }
  /**
   * Test calls the method.
   *
   * <p>Has <b> OK </b> status if the collection returned has at least one element.
   */
  public void _getBookmarks() {
    boolean res = false;

    XNameAccess the_bookmarks = oObj.getBookmarks();
    log.println("Found: ");
    util.dbg.printArray(the_bookmarks.getElementNames());
    res = the_bookmarks.getElementNames().length > 0;

    tRes.tested("getBookmarks()", res);
  }
示例#6
0
  @Override
  public boolean validateSelectedInsert() {
    OOComponentHelper ooDoc = getContainerPanel().getOoDocument();
    XNameAccess refs = ooDoc.getReferenceMarks();
    if (refs.hasByName(_debatetimeRefName_)) {
      this.addErrorMessage(
          null,
          "This item has already been marked up. Please use the 'Edit Metadata' option to modify it");
      return false;
    }

    return true;
  }
 public void _createNameGroup() {
   boolean result = true;
   try {
     XDataPilotField xDataPilotField = UnoRuntime.queryInterface(XDataPilotField.class, oObj);
     XNameAccess xNameAccess =
         UnoRuntime.queryInterface(XNameAccess.class, xDataPilotField.getItems());
     String[] elements = xNameAccess.getElementNames();
     oObj.createNameGroup(elements);
   } catch (com.sun.star.lang.IllegalArgumentException e) {
     log.println("Exception while checking createNameGroup" + e);
     result = false;
   }
   tRes.tested("createNameGroup()", result);
 }
示例#8
0
 public static java.math.BigInteger getBookmarksHash(XTextDocument xDoc)
     throws com.sun.star.uno.Exception, java.security.NoSuchAlgorithmException {
   StringBuffer buffer = new StringBuffer("");
   XBookmarksSupplier xBookmarksSupplier =
       UnoRuntime.queryInterface(XBookmarksSupplier.class, xDoc);
   XNameAccess xBookmarks = xBookmarksSupplier.getBookmarks();
   for (String sBookmarkname : xBookmarks.getElementNames()) {
     Object xBookmark = xBookmarks.getByName(sBookmarkname);
     XTextContent xBookmarkAsContent = UnoRuntime.queryInterface(XTextContent.class, xBookmark);
     buffer.append(sBookmarkname);
     buffer.append(':');
     buffer.append(xBookmarkAsContent.getAnchor().getString().replaceAll("\r\n", "\n"));
     buffer.append(';');
   }
   java.security.MessageDigest sha1 = java.security.MessageDigest.getInstance("SHA-1");
   sha1.reset();
   sha1.update(buffer.toString().getBytes());
   return new java.math.BigInteger(sha1.digest());
 }
示例#9
0
  /* ------------------------------------------------------------------ */
  public void resetted(EventObject aEvent) throws com.sun.star.uno.RuntimeException {
    // check if this reset occurred because we're on a new record
    XPropertySet xFormProps = UNO.queryPropertySet(aEvent.Source);
    try {
      Boolean aIsNew = (Boolean) xFormProps.getPropertyValue("IsNew");
      if (aIsNew.booleanValue()) { // yepp

        if (!m_bDefaultSalesDate) { // we're interested to do all this only if the user told us to
                                    // default the sales date
          // to "today"
          // As date fields do this defaulting automatically, the semantics is inverted here:
          // If we're told to default, we must do nothing, if we should not default, we must
          // reset the value which the date field set automatically.

          Integer aConcurrency = (Integer) xFormProps.getPropertyValue("ResultSetConcurrency");
          if (ResultSetConcurrency.READ_ONLY != aConcurrency.intValue()) {
            // we're going to modify the record, though after that, to the user, it should look
            // like it has not been modified
            // So we need to ensure that we do not change the IsModified property with whatever we
            // do
            Object aModifiedFlag = xFormProps.getPropertyValue("IsModified");

            // get the columns of our master form
            XColumnsSupplier xSuppCols =
                UnoRuntime.queryInterface(XColumnsSupplier.class, xFormProps);
            XNameAccess xCols = xSuppCols.getColumns();

            // and update the date column with a NULL value
            XColumnUpdate xDateColumn =
                UnoRuntime.queryInterface(XColumnUpdate.class, xCols.getByName("SALEDATE"));
            xDateColumn.updateNull();

            // then restore the flag
            xFormProps.setPropertyValue("IsModified", aModifiedFlag);
          }
        }
      }
    } catch (com.sun.star.uno.Exception e) {
      System.out.println(e);
      e.printStackTrace();
    }
  }
示例#10
0
  /** performs any cleanup before exiting the program */
  @Override
  protected void cleanUp() throws java.lang.Exception {
    // remove the listeners at the buttons
    RevokeButtons aRevoke = new RevokeButtons(m_aOperator);
    aRevoke.handle(m_document.getFormComponentTreeRoot());

    // remove the key generator listeners from the form
    m_aSalesmanKeyGenerator.stopGenerator();
    m_aSalesKeyGenerator.stopGenerator();

    // and the control lockers
    m_aSalesmenLocker.enableLock(false);
    m_aSalesLocker.enableLock(false);

    // the validator for the grid column
    m_aSalesNameValidator.enableColumnWatch(false);

    // remove our own reset listener from the form
    XNameAccess xMasterAsNames = UnoRuntime.queryInterface(XNameAccess.class, m_xMasterForm);
    XReset xFormReset = UNO.queryReset(xMasterAsNames.getByName("Sales"));
    xFormReset.removeResetListener(this);

    super.cleanUp();
  }
示例#11
0
  protected static String createUniqueName(XNameAccess elementContainer, String elementName) {

    String uniqueElementName = elementName;

    boolean elementExists = true;
    int i = 1;
    while (elementExists) {
      elementExists = elementContainer.hasByName(uniqueElementName);
      if (elementExists) {
        i++;
        uniqueElementName = elementName + Integer.toString(i);
      }
    }

    return uniqueElementName;
  }
  /**
   * Creating a Testenvironment for the interfaces to be tested. Creates an instance of the service
   * <code>com.sun.star.text.AutoTextContainer</code>, then selects the 'mytexts' group from the
   * given container using <code>XNameAccess</code> interface, and inserts some text entry to this
   * group. Then entry passed as test component.
   *
   * <p>Object relations created :
   *
   * <ul>
   *   <li><code>'XTEXTINFO'</code> for {@link ifc.text._XText} : creates tables 6x4
   *   <li><code>'TEXTDOC'</code> for {@link ifc.text._XAutoTextEntry} : text document
   * </ul>
   */
  protected synchronized TestEnvironment createTestEnvironment(
      TestParameters Param, PrintWriter log) {

    XAutoTextEntry oEntry = null;
    XAutoTextContainer oContainer;
    XInterface oObj = null;
    log.println("creating a test environment");
    try {
      XMultiServiceFactory myMSF = (XMultiServiceFactory) Param.getMSF();
      Object oInst = myMSF.createInstance("com.sun.star.text.AutoTextContainer");
      oContainer = UnoRuntime.queryInterface(XAutoTextContainer.class, oInst);
    } catch (com.sun.star.uno.Exception e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't create AutoTextContainer", e);
    }

    XNameAccess oContNames = UnoRuntime.queryInterface(XNameAccess.class, oContainer);

    String contNames[] = oContNames.getElementNames();
    for (int i = 0; i < contNames.length; i++) {
      log.println("ContainerNames[ " + i + "]: " + contNames[i]);
    }

    try {
      oObj =
          (XInterface)
              AnyConverter.toObject(new Type(XInterface.class), oContNames.getByName("mytexts"));
    } catch (com.sun.star.uno.Exception e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't get AutoTextGroup", e);
    }

    oGroup = UnoRuntime.queryInterface(XAutoTextGroup.class, oObj);
    String[] oENames = oGroup.getElementNames();
    for (int i = 0; i < oENames.length; i++) {
      log.println("AutoTextEntryNames[" + i + "]: " + oENames[i]);
    }

    XText oText = xTextDoc.getText();
    oText.insertString(oText.getStart(), "New AutoText", true);
    XTextRange oTextRange = oText;
    try {
      if (oGroup.hasByName("NewEntryName")) {
        oGroup.removeByName("NewEntryName");
        log.println("Element 'NewEntryName' exists, removing...");
      }
      log.println("Adding new element 'NewEntryName' to group...");
      oGroup.insertNewByName("NewEntryName", "NewEntryTitle", oTextRange);
      oEntry =
          (XAutoTextEntry)
              AnyConverter.toObject(
                  new Type(XAutoTextEntry.class), oGroup.getByName("NewEntryName"));
    } catch (com.sun.star.container.ElementExistException e) {
      e.printStackTrace(log);
    } catch (com.sun.star.container.NoSuchElementException e) {
      e.printStackTrace(log);
    } catch (com.sun.star.lang.WrappedTargetException e) {
      e.printStackTrace(log);
    } catch (com.sun.star.lang.IllegalArgumentException e) {
      e.printStackTrace(log);
    }

    oObj = oEntry;

    log.println("Trying to use XText as TextRange in the method applyTo");
    oEntry.applyTo(oTextRange);

    oTextRange = oText.createTextCursor();
    log.println("Trying to use XTextCursor as TextRange in the method applyTo");
    oEntry.applyTo(oTextRange);

    log.println("creating a new environment for AutoTextEntry object");
    TestEnvironment tEnv = new TestEnvironment(oObj);

    // adding relation for XText
    DefaultDsc tDsc =
        new DefaultDsc("com.sun.star.text.XTextContent", "com.sun.star.text.TextField.DateTime");
    log.println("    adding InstCreator object");
    tEnv.addObjRelation("XTEXTINFO", new InstCreator(xTextDoc, tDsc));

    log.println("adding TextDocument as mod relation to environment");
    tEnv.addObjRelation("TEXTDOC", xTextDoc);

    return tEnv;
  } // finish method getTestEnvironment
示例#13
0
 /** retrieves the control model with the given name */
 private XPropertySet getControlModel(String name)
     throws com.sun.star.uno.Exception, java.lang.Exception {
   XNameAccess nameAccess = UnoRuntime.queryInterface(XNameAccess.class, m_masterForm);
   return UnoRuntime.queryInterface(XPropertySet.class, nameAccess.getByName(name));
 }
示例#14
0
  public boolean test() {
    try {
      String sTempFileURL = m_aTestHelper.CreateTempFile(m_xMSF);
      if (sTempFileURL == null || sTempFileURL == "") {
        m_aTestHelper.Error("No valid temporary file was created!");
        return false;
      }

      // create temporary storage based on arbitrary medium
      // after such a storage is closed it is lost
      Object oTempStorage = m_xStorageFactory.createInstance();
      XStorage xTempStorage = (XStorage) UnoRuntime.queryInterface(XStorage.class, oTempStorage);
      if (xTempStorage == null) {
        m_aTestHelper.Error("Can't create temporary storage representation!");
        return false;
      }

      // open substorages and create streams there

      // first substorage of the root storage
      XStorage xTempSubStorage1 =
          m_aTestHelper.openSubStorage(xTempStorage, "SubStorage1", ElementModes.WRITE);
      if (xTempSubStorage1 == null) {
        m_aTestHelper.Error("Can't create substorage!");
        return false;
      }

      byte pBigBytes[] = new byte[33000];
      for (int nInd = 0; nInd < 33000; nInd++) pBigBytes[nInd] = (byte) (nInd % 128);

      // open a new substream, set "MediaType" and "Compressed" properties to it and write some
      // bytes
      if (!m_aTestHelper.WriteBytesToSubstream(
          xTempSubStorage1, "BigSubStream1", "MediaType1", true, pBigBytes)) return false;

      byte pBytes1[] = {1, 1, 1, 1, 1};

      // open a new substream, set "MediaType" and "Compressed" properties to it and write some
      // bytes
      if (!m_aTestHelper.WriteBytesToSubstream(
          xTempSubStorage1, "SubStream1", "MediaType1", true, pBytes1)) return false;

      // second substorage of the root storage
      XStorage xTempSubStorage2 =
          m_aTestHelper.openSubStorage(xTempStorage, "SubStorage2", ElementModes.WRITE);
      if (xTempSubStorage2 == null) {
        m_aTestHelper.Error("Can't create substorage!");
        return false;
      }

      // open a new substream, set "MediaType" and "Compressed" properties to it and write some
      // bytes
      if (!m_aTestHelper.WriteBytesToSubstream(
          xTempSubStorage2, "BigSubStream2", "MediaType2", false, pBigBytes)) return false;

      byte pBytes2[] = {2, 2, 2, 2, 2};

      // open a new substream, set "MediaType" and "Compressed" properties to it and write some
      // bytes
      if (!m_aTestHelper.WriteBytesToSubstream(
          xTempSubStorage2, "SubStream2", "MediaType2", false, pBytes2)) return false;

      // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are
      // set correctly
      if (!m_aTestHelper.setStorageTypeAndCheckProps(
          xTempStorage, "MediaType3", true, ElementModes.WRITE)) return false;

      // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are
      // set correctly
      if (!m_aTestHelper.setStorageTypeAndCheckProps(
          xTempSubStorage1, "MediaType4", false, ElementModes.WRITE)) return false;

      // set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are
      // set correctly
      if (!m_aTestHelper.setStorageTypeAndCheckProps(
          xTempSubStorage2, "MediaType5", false, ElementModes.WRITE)) return false;

      // create temporary storage based on a previously created temporary file
      Object pArgs[] = new Object[2];
      pArgs[0] = (Object) sTempFileURL;
      pArgs[1] = new Integer(ElementModes.WRITE);

      Object oTempFileStorage = m_xStorageFactory.createInstanceWithArguments(pArgs);
      XStorage xTempFileStorage =
          (XStorage) UnoRuntime.queryInterface(XStorage.class, oTempFileStorage);
      if (xTempFileStorage == null) {
        m_aTestHelper.Error("Can't create storage based on temporary file!");
        return false;
      }

      if (!m_aTestHelper.copyElementTo(xTempStorage, "SubStorage1", xTempFileStorage)) return false;

      // if storage is not commited before disposing all the changes will be lost
      if (!m_aTestHelper.commitStorage(xTempSubStorage2)) return false;

      // a storage must be disposed before moving/removing otherwise the access will be denied
      if (!m_aTestHelper.disposeStorage(xTempSubStorage2)) return false;

      if (!m_aTestHelper.moveElementTo(xTempStorage, "SubStorage2", xTempFileStorage)) return false;

      // SubStorage2 must be removed and disposed now
      try {
        xTempSubStorage2.isStreamElement("SubStream2");
        m_aTestHelper.Error("SubStorage2 must be disposed already!");
        return false;
      } catch (com.sun.star.lang.DisposedException de) {
      } catch (Exception e) {
        m_aTestHelper.Error("Wrong exception in case of disposed storage, exception: " + e);
        return false;
      }

      if (!m_aTestHelper.copyElementTo(xTempSubStorage1, "SubStream1", xTempFileStorage))
        return false;

      if (!m_aTestHelper.renameElement(xTempFileStorage, "SubStream1", "SubStream1_copy"))
        return false;

      if (!m_aTestHelper.moveElementTo(xTempSubStorage1, "SubStream1", xTempFileStorage))
        return false;

      if (!m_aTestHelper.copyElementTo(xTempSubStorage1, "BigSubStream1", xTempFileStorage))
        return false;

      if (!m_aTestHelper.renameElement(xTempFileStorage, "BigSubStream1", "BigSubStream1_copy"))
        return false;

      if (!m_aTestHelper.moveElementTo(xTempSubStorage1, "BigSubStream1", xTempFileStorage))
        return false;

      if (!m_aTestHelper.commitStorage(xTempFileStorage)) return false;

      // dispose used storages to free resources
      if (!m_aTestHelper.disposeStorage(xTempStorage)
          || !m_aTestHelper.disposeStorage(xTempFileStorage)) return false;

      // ================================================
      // now check all the written and copied information
      // ================================================

      // the temporary file must not be locked any more after storage disposing
      pArgs[1] = new Integer(ElementModes.WRITE);
      Object oResStorage = m_xStorageFactory.createInstanceWithArguments(pArgs);
      XStorage xResStorage = (XStorage) UnoRuntime.queryInterface(XStorage.class, oResStorage);
      if (xResStorage == null) {
        m_aTestHelper.Error("Can't reopen storage based on temporary file!");
        return false;
      }

      // open and check SubStorage1
      XStorage xResSubStorage1 =
          m_aTestHelper.openSubStorage(xResStorage, "SubStorage1", ElementModes.READ);
      if (xResSubStorage1 == null) {
        m_aTestHelper.Error("Can't open existing substorage!");
        return false;
      }

      if (!m_aTestHelper.checkStorageProperties(
          xResSubStorage1, "MediaType4", false, ElementModes.READ)) return false;

      // open and check SubStorage2
      XStorage xResSubStorage2 =
          m_aTestHelper.openSubStorage(xResStorage, "SubStorage2", ElementModes.READ);
      if (xResSubStorage2 == null) {
        m_aTestHelper.Error("Can't open existing substorage!");
        return false;
      }

      if (!m_aTestHelper.checkStorageProperties(
          xResSubStorage2, "MediaType5", false, ElementModes.READ)) return false;

      // check all the result streams

      if (!m_aTestHelper.checkStream(xResStorage, "SubStream1", "MediaType1", true, pBytes1))
        return false;

      if (!m_aTestHelper.checkStream(xResStorage, "BigSubStream1", "MediaType1", true, pBigBytes))
        return false;

      if (!m_aTestHelper.checkStream(xResStorage, "SubStream1_copy", "MediaType1", true, pBytes1))
        return false;

      if (!m_aTestHelper.checkStream(
          xResStorage, "BigSubStream1_copy", "MediaType1", true, pBigBytes)) return false;

      if (!m_aTestHelper.checkStream(xResSubStorage1, "SubStream1", "MediaType1", true, pBytes1))
        return false;

      if (!m_aTestHelper.checkStream(
          xResSubStorage1, "BigSubStream1", "MediaType1", true, pBigBytes)) return false;

      if (!m_aTestHelper.checkStream(xResSubStorage2, "SubStream2", "MediaType2", false, pBytes2))
        return false;

      if (!m_aTestHelper.checkStream(
          xResSubStorage2, "BigSubStream2", "MediaType2", false, pBigBytes)) return false;

      // the storage must be disposed before removing
      if (!m_aTestHelper.disposeStorage(xResSubStorage2)) return false;

      // remove element and check that it was removed completelly
      if (!m_aTestHelper.removeElement(xResStorage, "SubStorage2")) return false;

      try {
        XNameAccess xResAccess =
            (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xResStorage);
        if (xResAccess.hasByName("SubStorage2"))
          m_aTestHelper.Error("SubStorage2 must be removed already!");
      } catch (Exception e) {
        m_aTestHelper.Error("Can't get access to root storage, exception: " + e);
        return false;
      }

      try {
        xResSubStorage2.isStreamElement("SubStream2");

        m_aTestHelper.Error("SubStorage2 must be disposed already!");
        return false;
      } catch (com.sun.star.lang.DisposedException de) {
      } catch (Exception e) {
        m_aTestHelper.Error("Wrong exception in case of disposed storage, exception: " + e);
        return false;
      }

      // dispose used storages to free resources
      if (!m_aTestHelper.disposeStorage(xResStorage)) return false;

      return true;
    } catch (Exception e) {
      m_aTestHelper.Error("Exception: " + e);
      return false;
    }
  }
  /**
   * Creating a Testenvironment for the interfaces to be tested. Retrieves the collection of style
   * families available in the document using the interface <code>XStyleFamiliesSupplier</code>.
   * Obtains default style from the style family <code>'PageStyles'</code>. Retrieves value of the
   * property <code>'RightPageHeaderContent'</code>. Sets some string for the text which is printed
   * in the center part of the header or footer using the interface <code>XHeaderFooterContent
   * </code> and sets new value of the property <code>'RightPageHeaderContent'</code>. Creates text
   * cursor for the text which is printed in the center part of the header or footer. This text
   * cursor is the instance of the service <code>com.sun.star.text.TextCursor</code>.
   * </ul>
   */
  protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {

    XInterface oObj = null;
    XPropertySet PropSet;
    XNameAccess PageStyles = null;
    XStyle StdStyle = null;

    XStyleFamiliesSupplier StyleFam =
        UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xSpreadsheetDoc);

    XNameAccess StyleFamNames = StyleFam.getStyleFamilies();
    try {
      PageStyles =
          (XNameAccess)
              AnyConverter.toObject(
                  new Type(XNameAccess.class), StyleFamNames.getByName("PageStyles"));
      StdStyle =
          (XStyle) AnyConverter.toObject(new Type(XStyle.class), PageStyles.getByName("Default"));
    } catch (com.sun.star.lang.WrappedTargetException e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't get by name", e);
    } catch (com.sun.star.container.NoSuchElementException e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't get by name", e);
    } catch (com.sun.star.lang.IllegalArgumentException e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't get by name", e);
    }

    // get the property-set
    PropSet = UnoRuntime.queryInterface(XPropertySet.class, StdStyle);

    XHeaderFooterContent RPHC = null;
    // creation of testobject here
    // first we write what we are intend to do to log file
    log.println("creating a test environment");
    try {
      RPHC =
          (XHeaderFooterContent)
              AnyConverter.toObject(
                  new Type(XHeaderFooterContent.class),
                  PropSet.getPropertyValue("RightPageHeaderContent"));
    } catch (com.sun.star.lang.WrappedTargetException e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't get HeaderContent", e);
    } catch (com.sun.star.beans.UnknownPropertyException e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't get HeaderContent", e);
    } catch (com.sun.star.lang.IllegalArgumentException e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't get HeaderContent", e);
    }

    XText center = RPHC.getCenterText();
    center.setString("CENTER");

    try {
      PropSet.setPropertyValue("RightPageHeaderContent", RPHC);
    } catch (com.sun.star.lang.WrappedTargetException e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't set HeaderContent", e);
    } catch (com.sun.star.lang.IllegalArgumentException e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't set HeaderContent", e);
    } catch (com.sun.star.beans.PropertyVetoException e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't set HeaderContent", e);
    } catch (com.sun.star.beans.UnknownPropertyException e) {
      e.printStackTrace(log);
      throw new StatusException("Couldn't set HeaderContent", e);
    }

    // create testobject here
    oObj = center.createTextCursor();
    TestEnvironment tEnv = new TestEnvironment(oObj);

    // add relation for XTextRange
    tEnv.addObjRelation("XTEXT", UnoRuntime.queryInterface(XText.class, center));

    return tEnv;
  } // finish method getTestEnvironment