Package ag.ion.bion.officelayer.document

Examples of ag.ion.bion.officelayer.document.DocumentException


          message = Messages
              .getString(
                  "PersistenceService.error_io_message", String.valueOf(((ErrorCodeIOException) throwable).ErrCode)); //$NON-NLS-1$
      } else if (message == null || message.length() == 0)
        message = ERROR_MESSAGE;
      throw new DocumentException(message, throwable);
    }
  }
View Full Code Here


   *
   * @author Andreas Br�ker
   */
  public void store(String url) throws DocumentException {
    if (url == null)
      throw new DocumentException(Messages
          .getString("PersistenceService.error_url_invalid_message")); //$NON-NLS-1$

    try {
      url = URLAdapter.adaptURL(url);
      PropertyValue[] initialPropertyValues = document
          .getInitialProperties();
      String filterDefinition = null;
      for (int i = 0; i < initialPropertyValues.length; i++) {
        if (initialPropertyValues[i].Name
            .equalsIgnoreCase("FilterName"))
          filterDefinition = initialPropertyValues[i].Value
              .toString();
      }
      boolean useFilter = filterDefinition != null
          && filterDefinition.length() > 0;
      if (useFilter) {
        PropertyValue[] propertyValues = new PropertyValue[1];
        propertyValues[0] = new PropertyValue();
        propertyValues[0].Name = "FilterName"; //$NON-NLS-1$   
        propertyValues[0].Value = filterDefinition;
        xStorable.storeAsURL(url, propertyValues);
      } else {
        xStorable.storeAsURL(url, new PropertyValue[0]);
      }
      document.setModified(false);
    } catch (Throwable throwable) {
      String message = throwable.getMessage();
      if (throwable instanceof ErrorCodeIOException) {
        if (message == null || message.length() == 0)
          message = Messages
              .getString(
                  "PersistenceService.error_io_message", String.valueOf(((ErrorCodeIOException) throwable).ErrCode)); //$NON-NLS-1$
      } else if (message == null || message.length() == 0)
        message = ERROR_MESSAGE;
      throw new DocumentException(message, throwable);
    }
  }
View Full Code Here

          message = Messages
              .getString(
                  "PersistenceService.error_io_message", String.valueOf(((ErrorCodeIOException) throwable).ErrCode)); //$NON-NLS-1$
      } else if (message == null || message.length() == 0)
        message = ERROR_MESSAGE;
      throw new DocumentException(message, throwable);
    }
    document.fireDocumentEvent(IDocument.EVENT_ON_SAVE_DONE);
    document.fireDocumentEvent(IDocument.EVENT_ON_SAVE_FINISHED);
  }
View Full Code Here

   *
   * @author Andreas Br�ker
   */
  public void export(String url, IFilter filter) throws DocumentException {
    if (url == null)
      throw new DocumentException(Messages
          .getString("PersistenceService.error_url_invalid_message")); //$NON-NLS-1$

    if (filter == null)
      throw new DocumentException(
          Messages
              .getString("PersistenceService.error_filter_invalid_message")); //$NON-NLS-1$

    String filterDefinition = filter.getFilterDefinition(document);

    PropertyValue[] properties = new PropertyValue[1];

    if (filterDefinition != null) {
      properties[0] = new PropertyValue();
      properties[0].Name = "FilterName"; //$NON-NLS-1$
      properties[0].Value = filterDefinition;
    }
    // TODO set compression mode for pdf

    if (!filter.isExternalFilter())
      document.fireDocumentEvent(IDocument.EVENT_ON_SAVE_AS);
    try {
      url = URLAdapter.adaptURL(url);
      xStorable.storeToURL(url, properties);
    } catch (Throwable throwable) {
      String message = throwable.getMessage();
      if (throwable instanceof ErrorCodeIOException) {
        message = ErrorCodeTranslator
            .getErrorCodeMessage(((ErrorCodeIOException) throwable).ErrCode);
        if (message == null)
          message = Messages
              .getString(
                  "PersistenceService.error_io_message", String.valueOf(((ErrorCodeIOException) throwable).ErrCode)); //$NON-NLS-1$
      } else if (message == null || message.length() == 0)
        message = ERROR_MESSAGE;
      throw new DocumentException(message, throwable);
    }
    if (!filter.isExternalFilter())
      document.fireDocumentEvent(IDocument.EVENT_ON_SAVE_AS_DONE);
  }
View Full Code Here

      //zoomType valid?
      if (zoomType != DocumentZoomType.BY_VALUE && zoomType != DocumentZoomType.ENTIRE_PAGE
          && zoomType != DocumentZoomType.OPTIMAL
          && zoomType != DocumentZoomType.PAGE_WIDTH
          && zoomType != DocumentZoomType.PAGE_WIDTH_EXACT)
        throw new DocumentException("Invalid zoom type.");
      //zoomType valid?
      if (zoomType == DocumentZoomType.BY_VALUE && (zoomValue < 20 || zoomValue > 600))
        throw new DocumentException("Invalid zoom value. Use values between 20 and 600.");

      XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, getXComponent());
      if (xModel != null) {
        XController xController = xModel.getCurrentController();
        XSelectionSupplier selectionSupplier = (XSelectionSupplier) UnoRuntime.queryInterface(XSelectionSupplier.class,
            xController);
        if (selectionSupplier != null) {
          XViewSettingsSupplier viewSettingsSupplier = (XViewSettingsSupplier) UnoRuntime.queryInterface(XViewSettingsSupplier.class,
              xController);
          if (viewSettingsSupplier != null) {
            XPropertySet propertySet = viewSettingsSupplier.getViewSettings();
            propertySet.setPropertyValue("ZoomType", new Short(zoomType));
            if (zoomType == DocumentZoomType.BY_VALUE)
              propertySet.setPropertyValue("ZoomValue", new Short(zoomValue));
          }
        }
      }
    }
    catch (Throwable throwable) {
      throw new DocumentException(throwable);
    }
  }
View Full Code Here

      else
        printOpts = new PropertyValue[0];
      xPrintable.print(printOpts);
    }
    catch(Throwable throwable) {
      throw new DocumentException(throwable);
    }
  }
View Full Code Here

      if (zoomType != DocumentZoomType.BY_VALUE
          && zoomType != DocumentZoomType.ENTIRE_PAGE
          && zoomType != DocumentZoomType.OPTIMAL
          && zoomType != DocumentZoomType.PAGE_WIDTH
          && zoomType != DocumentZoomType.PAGE_WIDTH_EXACT)
        throw new DocumentException("Invalid zoom type.");
      // zoomType valid?
      if (zoomType == DocumentZoomType.BY_VALUE
          && (zoomValue < 20 || zoomValue > 600))
        throw new DocumentException(
            "Invalid zoom value. Use values between 20 and 600.");

      XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class,
          getXComponent());
      if (xModel != null) {
        XController xController = xModel.getCurrentController();
        XSelectionSupplier selectionSupplier = (XSelectionSupplier) UnoRuntime
            .queryInterface(XSelectionSupplier.class, xController);
        if (selectionSupplier != null) {
          XViewSettingsSupplier viewSettingsSupplier = (XViewSettingsSupplier) UnoRuntime
              .queryInterface(XViewSettingsSupplier.class,
                  xController);
          if (viewSettingsSupplier != null) {
            XPropertySet propertySet = viewSettingsSupplier
                .getViewSettings();
            propertySet.setPropertyValue("ZoomType", new Short(
                zoomType));
            if (zoomType == DocumentZoomType.BY_VALUE)
              propertySet.setPropertyValue("ZoomValue",
                  new Short(zoomValue));
          }
        }
      }
    } catch (Throwable throwable) {
      throw new DocumentException(throwable);
    }
  }
View Full Code Here

            "_blank", 0, props); //$NON-NLS-1$
      }
      IDocument document = DocumentLoader.getDocument(xComponent,
          serviceProvider, props);
      if (document == null)
        throw new DocumentException(
            "The new document can not be constructed."); //$NON-NLS-1$
      return document;
    } catch (Throwable throwable) {
      throw new NOAException(throwable);
    }
View Full Code Here

      IDocument document = DocumentLoader.loadDocument(serviceProvider,
          url);
      if (document != null)
        return document;
      else
        throw new DocumentException(Messages
            .getString("DocumentService_exception_url_invalid")); //$NON-NLS-1$
    } catch (Throwable throwable) {
      DocumentException documentException = new DocumentException(
          throwable.getMessage());
      documentException.initCause(throwable);
      throw documentException;
    }
  }
View Full Code Here

      IDocumentDescriptor documentDescriptor) throws DocumentException {
    XComponent xComponent = null;
    PropertyValue[] properties = new PropertyValue[1];
    try {
      if (inputStream == null)
        throw new DocumentException(
            "The submitted input stream is not valid."); //$NON-NLS-1$

      if (xComponentLoader == null || !officeConnection.isConnected())
        xComponentLoader = constructComponentLoader();

      checkMaxOpenDocuments(serviceProvider);

      // begin task is done in class ByteArrayXInputStreamAdapter
      // if(officeProgressMonitor != null)
      //  officeProgressMonitor.beginTask(Messages.getString("DocumentService_monitor_message_preparing_loading"), IOfficeProgressMonitor.WORK_UNKNOWN); //$NON-NLS-1$

      ByteArrayXInputStreamAdapter byteArrayToXInputStreamAdapter = new ByteArrayXInputStreamAdapter(
          inputStream, officeProgressMonitor);
      properties[0] = new PropertyValue(
          "InputStream", -1, byteArrayToXInputStreamAdapter, PropertyState.DIRECT_VALUE); //$NON-NLS-1$
      properties = DocumentDescriptorTransformer
          .documentDescriptor2PropertyValues(properties,
              documentDescriptor);

      if (frame == null)
        xComponent = xComponentLoader.loadComponentFromURL(
            "private:stream", "_blank", 0, properties); //$NON-NLS-1$ //$NON-NLS-2$
      else
        xComponent = xComponentLoader
            .loadComponentFromURL(
                "private:stream", frame.getXFrame().getName(), FrameSearchFlag.ALL, properties); //$NON-NLS-1$

    } catch (Throwable throwable) {
      throw new DocumentException(throwable);
    }

    if (officeProgressMonitor != null)
      officeProgressMonitor.beginSubTask(Messages
          .getString("DocumentService_monitor_investigating")); //$NON-NLS-1$
    IDocument document = DocumentLoader.getDocument(xComponent,
        serviceProvider, properties);
    if (document != null) {
      if (officeProgressMonitor != null) {
        officeProgressMonitor
            .beginSubTask(Messages
                .getString("DocumentService_monitor_loading_completed")); //$NON-NLS-1$
        officeProgressMonitor.done();
      }
      return document;
    }
    throw new DocumentException("The document can not be loaded."); //$NON-NLS-1$
  }
View Full Code Here

TOP

Related Classes of ag.ion.bion.officelayer.document.DocumentException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.