Exemplo n.º 1
0
  protected void doCreateDocument(
      final ReportOutputType outputType, final OutputStream outputStream)
      throws NoFreePortsException {
    OfficeTask officeTask =
        new OfficeTask() {
          @Override
          public void processTaskInOpenOffice(OfficeResourceProvider ooResourceProvider) {
            try {
              loadDocument(ooResourceProvider);

              // Handling tables
              fillTables(ooResourceProvider.getXDispatchHelper());
              // Handling text
              replaceAllAliasesInDocument();
              replaceAllAliasesInDocument(); // we do it second time to handle several open office
                                             // bugs (page breaks in html, etc). Do not remove.
              // Saving document to output stream and closing
              saveAndClose(ooResourceProvider, xComponent, outputType, outputStream);
            } catch (Exception e) {
              throw wrapWithReportingException(
                  "An error occurred while running task in Open Office server", e);
            }
          }
        };

    officeIntegration.runTaskWithTimeout(officeTask, officeIntegration.getTimeoutInSeconds());
  }