org.odftoolkit.odfdom.doc.element.draw
Class OdfImage

java.lang.Object
  extended by org.apache.xerces.dom.NodeImpl
      extended by org.apache.xerces.dom.ChildNode
          extended by org.apache.xerces.dom.ParentNode
              extended by org.apache.xerces.dom.ElementImpl
                  extended by org.apache.xerces.dom.ElementNSImpl
                      extended by org.odftoolkit.odfdom.dom.element.OdfElement
                          extended by org.odftoolkit.odfdom.dom.element.draw.OdfImageElement
                              extended by org.odftoolkit.odfdom.doc.element.draw.OdfImage
All Implemented Interfaces:
Serializable, Cloneable, Element, EventTarget, Node, NodeList, TypeInfo

public class OdfImage
extends OdfImageElement

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.odftoolkit.odfdom.dom.element.draw.OdfImageElement
ELEMENT_NAME
 
Fields inherited from class org.odftoolkit.odfdom.dom.element.OdfElement
mOdfDocument
 
Fields inherited from class org.apache.xerces.dom.ElementNSImpl
localName, namespaceURI
 
Fields inherited from class org.apache.xerces.dom.ElementImpl
attributes, name
 
Fields inherited from class org.apache.xerces.dom.ParentNode
firstChild, fNodeListCache, ownerDocument
 
Fields inherited from class org.apache.xerces.dom.ChildNode
nextSibling, previousSibling
 
Fields inherited from class org.apache.xerces.dom.NodeImpl
DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_IS_CONTAINED, DOCUMENT_POSITION_PRECEDING, ELEMENT_DEFINITION_NODE, FIRSTCHILD, flags, HASSTRING, ID, IGNORABLEWS, NORMALIZED, OWNED, ownerNode, READONLY, SPECIFIED, SYNCCHILDREN, SYNCDATA, TREE_POSITION_ANCESTOR, TREE_POSITION_DESCENDANT, TREE_POSITION_DISCONNECTED, TREE_POSITION_EQUIVALENT, TREE_POSITION_FOLLOWING, TREE_POSITION_PRECEDING, TREE_POSITION_SAME_NODE
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Fields inherited from interface org.w3c.dom.TypeInfo
DERIVATION_EXTENSION, DERIVATION_LIST, DERIVATION_RESTRICTION, DERIVATION_UNION
 
Constructor Summary
OdfImage(OdfFileDom ownerDoc)
          Creates a new instance of this class
 
Method Summary
 URI getImageUri()
           
 void insertImage(InputStream is, String packagePath, String mediaType)
          Inserts the image file from the stream to the ODF package named similar as in the provided path..
 String insertImage(URI imageUri)
          Inserts the image file from the URI to the ODF package named similar as in the URI.
 void setImagePath(String packagePath)
          The image path will be stored as URI of the href attribute
 
Methods inherited from class org.odftoolkit.odfdom.dom.element.draw.OdfImageElement
createBinaryDataElement, createListElement, createParagraphElement, getFilterName, getHref, getOdfName, getXmlid, init, setFilterName, setHref, setXmlid
 
Methods inherited from class org.odftoolkit.odfdom.dom.element.OdfElement
cloneNode, equals, findFirstChildNode, findNextChildNode, findPreviousChildNode, getAncestorAs, getOdfAttribute, getParentAs, hasOdfAttribute, insertBefore, onInsertNode, onInsertNode, onRemoveNode, onRemoveNode, removeChild, replaceChild, setOdfAttribute, toString
 
Methods inherited from class org.apache.xerces.dom.ElementNSImpl
getBaseURI, getLocalName, getNamespaceURI, getPrefix, getTypeName, getTypeNamespace, isDerivedFrom, setPrefix, setType, setValues
 
Methods inherited from class org.apache.xerces.dom.ElementImpl
getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getDefaultAttributes, getElementsByTagName, getElementsByTagNameNS, getNodeName, getNodeType, getSchemaTypeInfo, getTagName, getXercesAttribute, hasAttribute, hasAttributeNS, hasAttributes, isEqualNode, normalize, reconcileDefaultAttributes, removeAttribute, removeAttributeNode, removeAttributeNS, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setOwnerDocument, setReadOnly, setupDefaultAttributes, setXercesAttributeNode, synchronizeData
 
Methods inherited from class org.apache.xerces.dom.ParentNode
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, getOwnerDocument, getTextContent, hasChildNodes, item, setTextContent, synchronizeChildren
 
Methods inherited from class org.apache.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSibling
 
Methods inherited from class org.apache.xerces.dom.NodeImpl
addEventListener, appendChild, changed, changes, compareDocumentPosition, compareTreePosition, dispatchEvent, getContainer, getFeature, getNodeNumber, getNodeValue, getReadOnly, getUserData, getUserData, getUserDataRecord, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, removeEventListener, setNodeValue, setUserData, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, compareDocumentPosition, getChildNodes, getFeature, getFirstChild, getLastChild, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, getTextContent, getUserData, hasChildNodes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, setNodeValue, setTextContent, setUserData
 

Constructor Detail

OdfImage

public OdfImage(OdfFileDom ownerDoc)
Creates a new instance of this class

Parameters:
ownerDoc - The XML DOM containing the draw:image element
Method Detail

getImageUri

public URI getImageUri()

setImagePath

public void setImagePath(String packagePath)
The image path will be stored as URI of the href attribute

Parameters:
packagePath - The relative path from the package root to the image

insertImage

public String insertImage(URI imageUri)
                   throws Exception
Inserts the image file from the URI to the ODF package named similar as in the URI. The manifest is adapted using the media type according to the suffix. Existing images are replaced. Note: Default image seize will only be set, if the draw:image had been added to its draw:frame prior.

Parameters:
imageUri - The URI of the image that will be added as stream to the package in the 'Pictures/' graphic directory with the same image file name as in the URI. If the imageURI is relativ first the user.dir is taken to make it absolute.
Returns:
Returns the package path of the image, which was created based on the given URI.
Throws:
Exception - If the image provided by the URI, could not be added as stream to the ODF package.

insertImage

public void insertImage(InputStream is,
                        String packagePath,
                        String mediaType)
                 throws Exception
Inserts the image file from the stream to the ODF package named similar as in the provided path.. The manifest is adapted using given media type. Existing images are replaced.

Parameters:
is - InputStream to be added to the ODF package
packagePath - Internal path of the image in the package
mediaType - The mediaType of the image. Can be obtained by the OdfFileEntry class findMediaType(String fileRef).
Throws:
Exception - If the given stream could not be added to the ODF package at the packagePatch


Copyright © 2009. All Rights Reserved.