Class OdfGraphicsDocument

All Implemented Interfaces:
Closeable, AutoCloseable

public class OdfGraphicsDocument extends OdfDocument
This class represents an empty ODF graphics document.
  • Constructor Details

  • Method Details

    • newGraphicsDocument

      public static OdfGraphicsDocument newGraphicsDocument() throws Exception
      Creates an empty graphics document.
      Returns:
      ODF graphics document based on a default template
      Throws:
      Exception - - if the document could not be created
    • newGraphicsTemplateDocument

      public static OdfGraphicsDocument newGraphicsTemplateDocument() throws Exception
      Creates an empty graphics template.
      Returns:
      ODF graphics template based on a default
      Throws:
      Exception - - if the template could not be created
    • loadDocument

      public static OdfGraphicsDocument loadDocument(InputStream inputStream) throws Exception
      Creates an OdfGraphicsDocument from the OpenDocument provided by a resource Stream.

      Since an InputStream does not provide the arbitrary (non sequentiell) read access needed by OdfGraphicsDocument, the InputStream is cached. This usually takes more time compared to the other createInternalDocument methods. An advantage of caching is that there are no problems overwriting an input file.

      If the resource stream is not a ODF graphics document, ClassCastException might be thrown.

      Parameters:
      inputStream - - the InputStream of the ODF graphics document.
      Returns:
      the graphics document created from the given InputStream
      Throws:
      Exception - - if the document could not be created.
    • loadDocument

      public static OdfGraphicsDocument loadDocument(String documentPath) throws Exception
      Loads an OdfGraphicsDocument from the provided path.

      OdfGraphicsDocument relies on the file being available for read access over the whole lifecycle of OdfGraphicsDocument.

      If the resource stream is not a ODF graphics document, ClassCastException might be thrown.

      Parameters:
      documentPath - - the path from where the document can be loaded
      Returns:
      the graphics document from the given path or NULL if the media type is not supported by ODFDOM.
      Throws:
      Exception - - if the document could not be created.
    • loadDocument

      public static OdfGraphicsDocument loadDocument(File file) throws Exception
      Creates an OdfGraphicsDocument from the OpenDocument provided by a File.

      OdfGraphicsDocument relies on the file being available for read access over the whole lifecycle of OdfGraphicsDocument.

      If the resource stream is not a ODF graphics document, ClassCastException might be thrown.

      Parameters:
      file - - a file representing the ODF graphics document.
      Returns:
      the graphics document created from the given File
      Throws:
      Exception - - if the document could not be created.
    • getContentRoot

      public OfficeDrawingElement getContentRoot() throws Exception
      Get the content root of a graphics document.
      Overrides:
      getContentRoot in class OdfDocument
      Returns:
      content root, representing the office:drawing tag
      Throws:
      Exception - if the file DOM could not be created.
    • changeMode

      public void changeMode(OdfGraphicsDocument.OdfMediaType mediaType)
      Changes the document to the given mediatype. This method can only be used to convert a document to a related mediatype, e.g. template.
      Parameters:
      mediaType - the related ODF mimetype