incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robw...@apache.org
Subject svn commit: r1374762 [3/4] - in /incubator/odf/trunk: odfdom/ odfdom/src/main/java/org/odftoolkit/odfdom/pkg/ odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/ odfdom/src/test/java/org/odftoolkit/odfdom/doc/ odfdom/src/test/java/org/odftoolkit/o...
Date Sun, 19 Aug 2012 15:01:10 GMT
Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackageDocument.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackageDocument.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackageDocument.java (original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackageDocument.java Sun Aug 19 15:01:09 2012
@@ -62,6 +62,7 @@ public class OdfPackageDocument implemen
 	 *      - media type of stream. If unknown null can be used.
 	 */
 	protected OdfPackageDocument(OdfPackage pkg, String internalPath, String mediaTypeString) {
+		super();
 		if (pkg != null) {
 			mPackage = pkg;
 			mDocumentPathInPackage = internalPath;

Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfValidationException.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfValidationException.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfValidationException.java (original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfValidationException.java Sun Aug 19 15:01:09 2012
@@ -23,11 +23,7 @@ package org.odftoolkit.odfdom.pkg;
 
 import org.xml.sax.SAXParseException;
 
-/**
- * This ODF specific validation exception facilities the usage of a
- * SAXParseException for none XML validation, used by an
- * <code>ErrorHandler</code>.
- */
+/** This ODF specific validation excpetion faciliates the usage of a SAXParseException for none XML validation, used by an  <code>ErrorHandler</code>. */
 public class OdfValidationException extends SAXParseException {
 
 	private ValidationConstraint mConstraint;
@@ -36,15 +32,10 @@ public class OdfValidationException exte
 	private static final String SOURCE_SUFFIX = "'";
 
 	/**
-	 * An OdfValidationException should be used for any validation result
-	 * related to an ODF package. This constructor should only be used for
-	 * SaxParseExceptions unrelated to XML. This constructor sets the public and
-	 * system ID for XML and line and column number of the super class will be
-	 * set to be invalid.
-	 * 
-	 * @param constraint
-	 *            the predefined constant message
-	 */
+	 * An OdfValidationException should be used for any validation result related to an ODF package.
+	 * This constructor should only be used for SaxParseExceptions unrelated to XML.
+	 * This constructor sets the public and system ID for XML and line and column number of the super class will be set to be invalid.
+	@param constraint the predefined constaint message */
 	public OdfValidationException(ValidationConstraint constraint) {
 		// The constraint convention is the first parameter to be the sourcePath of the ODF document/package causing the exception
 		super(String.format(constraint.getMessage(), NO_SOURCE), null, null, -1, -1);
@@ -52,21 +43,12 @@ public class OdfValidationException exte
 	}
 
 	/**
-	 * An OdfValidationException should be used for any validation result
-	 * related to an ODF package. This constructor should only be used for
-	 * SaxParseExceptions unrelated to XML. This constructor sets the public and
-	 * system ID for XML and line and column number of the super class will be
-	 * set to be invalid.
-	 * 
-	 * @param constraint
-	 *            the predefined constaint message
-	 * @param sourcePath
-	 *            the source path of the exception. For instance, it might be an
-	 *            ODF package or ODF document.
-	 * @param messageParameters
-	 *            allow the customization of a constraint message with
-	 *            parameters.
-	 */
+	 * An OdfValidationException should be used for any validation result related to an ODF package.
+	 * This constructor should only be used for SaxParseExceptions unrelated to XML.
+	 * This constructor sets the public and system ID for XML and line and column number of the super class will be set to be invalid.
+	@param constraint the predefined constaint message
+	@param sourcePath the source path of the exception. For instance, it might be an ODF package or ODF document.
+	@param messageParameters allow the customization of a constraint message with parameters.*/
 	public OdfValidationException(ValidationConstraint constraint, String sourcePath, Object... messageParameters) {
 		// The constraint convention is the first parameter to be the sourcePath of the ODF document/package causing the exception
 		super(formatMessage(constraint, sourcePath, messageParameters), null, null, -1, -1);
@@ -74,23 +56,13 @@ public class OdfValidationException exte
 	}
 
 	/**
-	 * An OdfValidationException should be used for any validation result
-	 * related to an ODF package. This constructor should only be used for
-	 * SaxParseExceptions unrelated to XML. This constructor sets the public and
-	 * system ID for XML and line and column number of the super class will be
-	 * set to be invalid.
-	 * 
-	 * @param e
-	 *            root exception to be embedded
-	 * @param constraint
-	 *            the predefined constant message
-	 * @param sourcePath
-	 *            the source path of the exception. For instance, it might be an
-	 *            ODF package or ODF document.
-	 * @param messageParameters
-	 *            allow the customization of a constraint message with
-	 *            parameters.
-	 */
+	 * An OdfValidationException should be used for any validation result related to an ODF package.
+	 * This constructor should only be used for SaxParseExceptions unrelated to XML.
+	 * This constructor sets the public and system ID for XML and line and column number of the super class will be set to be invalid.
+	 * @param e root exception to be embeddded
+	 * @param constraint the predefined constaint message
+	 * @param sourcePath the source path of the exception. For instance, it might be an ODF package or ODF document.
+	 * @param messageParameters allow the customization of a constraint message with parameters.*/
 	public OdfValidationException(ValidationConstraint constraint, String sourcePath, Exception e, Object... messageParameters) {
 		// The constraint convention is the first parameter to be the sourcePath of the ODF document/package causing the exception
 		super(formatMessage(constraint, sourcePath, messageParameters), null, null, -1, -1, e);

Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfXMLFactory.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfXMLFactory.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfXMLFactory.java (original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfXMLFactory.java Sun Aug 19 15:01:09 2012
@@ -3,7 +3,7 @@
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
  *
  * Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
- * 
+ *
  * Use is subject to license terms.
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -135,8 +135,6 @@ public class OdfXMLFactory {
 						localName = stok.nextToken();
 					}
 					className = getOdfIncubatorNodeClassName(prefix, localName);
-				} else if ("manifest".equals(prefix)) {
-					className = getOdfPKGNodeClassName(prefix, localName, nodeType);
 				} else {
 					className = getOdfDOMNodeClassName(prefix, localName, nodeType);
 				}
@@ -178,21 +176,7 @@ public class OdfXMLFactory {
 
 		return className.toString();
 	}
-	
-	private static String getOdfPKGNodeClassName(String prefix, String localName, String nodeType) {
-		StringBuilder className = new StringBuilder("org.odftoolkit.odfdom.pkg." + prefix + ".");
-		if (localName.indexOf(LOCAL_NAME_DELIMITER) != -1) {
-			StringTokenizer stok = new StringTokenizer(localName, LOCAL_NAME_DELIMITER);
-			while (stok.hasMoreElements()) {
-				className = className.append(toUpperCaseFirstCharacter(stok.nextToken()));
-			}
-		} else {
-			className = className.append(toUpperCaseFirstCharacter(localName));
-		}
-		className.append(toUpperCaseFirstCharacter(nodeType));
-		return className.toString();
-	}
-	
+
 	private static String getOdfDOMNodeClassName(String prefix, String localName, String nodeType) {
 		StringBuilder className = new StringBuilder("org.odftoolkit.odfdom.dom." + nodeType + "." + prefix + ".");
 		className = className.append(toUpperCaseFirstCharacter(prefix));

Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/ZipHelper.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/ZipHelper.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/ZipHelper.java (original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/ZipHelper.java Sun Aug 19 15:01:09 2012
@@ -82,8 +82,7 @@ class ZipHelper {
 						try {
 							zipEntry = inputStream.getNextEntry();
 						} catch (java.util.zip.ZipException e) {
-							// JDK 6 -- the try/catch is workaround for a
-							// specific JDK 5 only problem
+							// JDK 6 -- the try/catch is workaround for a specific JDK 5 only problem
 							if (!e.getMessage().contains("missing entry name") && !System.getProperty("Java.version").equals("1.5.0")) {
 								Logger.getLogger(ZipHelper.class.getName()).info("ZIP ENTRY not found");
 								throw e;
@@ -104,8 +103,7 @@ class ZipHelper {
 			try {
 				int zipMethod = zipEntry.getMethod();
 				if (zipMethod != ZipEntry.STORED && zipMethod != ZipEntry.DEFLATED) {
-					mPackage.getErrorHandler().error(
-							new OdfValidationException(OdfPackageConstraint.PACKAGE_ENTRY_USING_INVALID_COMPRESSION, mPackage.getBaseURI(), filePath));
+					mPackage.getErrorHandler().error(new OdfValidationException(OdfPackageConstraint.PACKAGE_ENTRY_USING_INVALID_COMPRESSION, mPackage.getBaseURI(), filePath));
 				}
 			} catch (SAXException ex) {
 				Logger.getLogger(OdfPackage.class.getName()).log(Level.SEVERE, null, ex);
@@ -118,7 +116,8 @@ class ZipHelper {
 		if (mZipFile != null) {
 			return mZipFile.getInputStream(entry);
 		} else {
-			ZipInputStream inputStream = new ZipInputStream(new ByteArrayInputStream(mZipBuffer));
+			ZipInputStream inputStream = new ZipInputStream(
+					new ByteArrayInputStream(mZipBuffer));
 			ZipEntry zipEntry = inputStream.getNextEntry();
 			while (zipEntry != null) {
 				if (zipEntry.getName().equalsIgnoreCase(entry.getName())) {
@@ -130,7 +129,8 @@ class ZipHelper {
 		}
 	}
 
-	private InputStream readAsInputStream(ZipInputStream inputStream) throws IOException {
+	private InputStream readAsInputStream(ZipInputStream inputStream)
+			throws IOException {
 		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 		if (outputStream != null) {
 			byte[] buf = new byte[4096];

Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/OdfFileEntry.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/OdfFileEntry.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/OdfFileEntry.java (original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/manifest/OdfFileEntry.java Sun Aug 19 15:01:09 2012
@@ -25,222 +25,210 @@ import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.odftoolkit.odfdom.pkg.OdfElement;
-
 public class OdfFileEntry {
 
-	private FileEntryElement mFileEntryElement;
-
-	private static Map<String, String> MEDIA_TYPE_MAP = null;
+//    private Logger mLog = Logger.getLogger(OdfFileEntry.class.getName());    
+    private String mPath;
+    private String mMediaType = EMPTY_STRING;
+    private int mSize = -1;
+    private EncryptionData mEncryptionData;    // The following static attributes are used for JDK 5 media type detection
+    private static Map<String, String> MEDIA_TYPE_MAP = null;
 	private static final String EMPTY_STRING = "";
-	private static final String DEFAULT_TYPE = "application/octet-stream";
-	private static final String APPLICATION_POSTSCRIPT = "application/postscript";
-	private static final String APPLICATION_RTF = "application/rtf";
-	private static final String APPLICATION_X_TEX = "application/x-tex";
-	private static final String APPLICATION_X_TEXINFO = "application/x-texinfo";
-	private static final String APPLICATION_X_TROFF = "application/x-troff";
-	private static final String AUDIO_BASIC = "audio/basic";
-	private static final String AUDIO_MIDI = "audio/midi";
-	private static final String AUDIO_X_AIFC = "audio/x-aifc";
-	private static final String AUDIO_X_AIFF = "audio/x-aiff";
-	private static final String AUDIO_X_MPEG = "audio/x-mpeg";
-	private static final String AUDIO_X_WAV = "audio/x-wav";
-	private static final String IMAGE_GIF = "image/gif";
-	private static final String IMAGE_IEF = "image/ief";
-	private static final String IMAGE_JPEG = "image/jpeg";
-	private static final String IMAGE_PNG = "image/png";
-	private static final String IMAGE_TIFF = "image/tiff";
-	private static final String IMAGE_X_XWINDOWDUMP = "image/x-xwindowdump";
-	private static final String TEXT_HTML = "text/html";
-	private static final String TEXT_PLAIN = "text/plain";
-	private static final String TEXT_XML = "text/xml";
-	private static final String VIDEO_MEPG = "video/mpeg";
-	private static final String VIDEO_QUICKTIME = "video/quicktime";
-	private static final String VIDEO_X_MSVIDEO = "video/x-msvideo";
-
-	/**
-	 * @param fileEntryElement
-	 *            the OdfElement of the <manifest:file-entry>
-	 */
-	public OdfFileEntry(FileEntryElement fileEntryElement) {
-		mFileEntryElement = fileEntryElement;
-	}
-
-	public void setPath(String path) {
-		mFileEntryElement.setFullPathAttribute(path);
-	}
-
-	public String getPath() {
-		return mFileEntryElement.getFullPathAttribute();
-	}
-
-	/**
-	 * @param mediaType
-	 *            of the file. Use <code>null</code> or an empty string to unset
-	 *            the mediaType to an empty string.
-	 */
-	public void setMediaTypeString(String mediaType) {
-		if (mediaType != null) {
-			mFileEntryElement.setMediaTypeAttribute(mediaType);
-		} else {
-			mFileEntryElement.setMediaTypeAttribute(EMPTY_STRING);
+    private static final String DEFAULT_TYPE = "application/octet-stream";
+    private static final String APPLICATION_POSTSCRIPT = "application/postscript";
+    private static final String APPLICATION_RTF = "application/rtf";
+    private static final String APPLICATION_X_TEX = "application/x-tex";
+    private static final String APPLICATION_X_TEXINFO = "application/x-texinfo";
+    private static final String APPLICATION_X_TROFF = "application/x-troff";
+    private static final String AUDIO_BASIC = "audio/basic";
+    private static final String AUDIO_MIDI = "audio/midi";
+    private static final String AUDIO_X_AIFC = "audio/x-aifc";
+    private static final String AUDIO_X_AIFF = "audio/x-aiff";
+    private static final String AUDIO_X_MPEG = "audio/x-mpeg";
+    private static final String AUDIO_X_WAV = "audio/x-wav";
+    private static final String IMAGE_GIF = "image/gif";
+    private static final String IMAGE_IEF = "image/ief";
+    private static final String IMAGE_JPEG = "image/jpeg";
+    private static final String IMAGE_PNG = "image/png";
+    private static final String IMAGE_TIFF = "image/tiff";
+    private static final String IMAGE_X_XWINDOWDUMP = "image/x-xwindowdump";
+    private static final String TEXT_HTML = "text/html";
+    private static final String TEXT_PLAIN = "text/plain";
+    private static final String TEXT_XML = "text/xml";    
+    private static final String VIDEO_MEPG = "video/mpeg";
+    private static final String VIDEO_QUICKTIME = "video/quicktime";
+    private static final String VIDEO_X_MSVIDEO = "video/x-msvideo";
+
+    public OdfFileEntry() {
+    }
+
+	/**
+	 *  @param path the path of the <manifest:file-entry>
+	 *	Use <code>null</code> for no mediaType */
+    public OdfFileEntry(String path) {
+        mPath = path;
+    }
+
+	/** 
+	 *  @param path the path of the <manifest:file-entry>
+	 *  @param mediaType of the file.
+	 *	Use <code>null</code> for no mediaType */
+    public OdfFileEntry(String path, String mediaType) {
+        mPath = path;
+		if(mediaType == null){
+			mediaType = EMPTY_STRING;
+		}else{
+			mMediaType = mediaType;
 		}
-	}
-
-	/**
-	 * @return the mediatype of the mandatory &lt;manifest:file-entry&gt;
-	 *         attribute. If no mediatype exists an empty string is returned
-	 */
-	public String getMediaTypeString() {
-		return mFileEntryElement.getMediaTypeAttribute();
-	}
+    }
 
-	/**
-	 * Get the media type from the given file reference
-	 * 
-	 * @param fileRef
-	 *            the reference to the file the media type is questioned
-	 * 
-	 * @return the mediaType string of the given file reference
-	 */
-	public static String getMediaTypeString(String fileRef) {
-		String mediaType = null;
-		try {
-			// use 'JavaBeans Activation Framework' if available (as library or
-			// as part of JDK 6)
-			Class<?> mimetypesClass = Class.forName("javax.activation.MimetypesFileTypeMap");
-			Method getContentTypeMethod = mimetypesClass.getMethod("getContentType", String.class);
-			mediaType = (String) getContentTypeMethod.invoke(getContentTypeMethod, fileRef);
-		} catch (Exception e) {
-			// otherwise (JDK 5 without library of 'JavaBeans Activation
-			// Framework')
-			// use local fallback implementation
-			// mLog.fine("Using own mediatype handling as 'JavaBeans Activation Framework' not found: "
-			// + e.getMessage());
-			mediaType = findMediaTypeString(fileRef);
+    public OdfFileEntry(String path, String mediaType, int size) {
+        mPath = path;
+		if(mediaType == null){
+			mediaType = EMPTY_STRING;
+		}else{
+			mMediaType = mediaType;
 		}
-		return mediaType;
-	}
+        mSize = size;
+    }
 
-	public void setSize(Integer size) {
-		if (size == null) {
-			mFileEntryElement.removeAttributeNS(SizeAttribute.ATTRIBUTE_NAME.getUri(),
-					SizeAttribute.ATTRIBUTE_NAME.getLocalName());
-		} else {
-			mFileEntryElement.setSizeAttribute(size);
+    public void setPath(String path) {
+        mPath = path;
+    }
+
+    public String getPath() {
+        return mPath;
+    }
+
+	/** @param mediaType of the file.
+	 *	Use <code>null</code> or an empty string to unset the mediaType to an empty string. */
+    public void setMediaTypeString(String mediaType) {
+		if(mediaType == null){
+			mediaType = EMPTY_STRING;
+		}else{
+			mMediaType = mediaType;
 		}
-	}
+    }
 
-	/**
-	 * Get the size.
-	 */
-	public Integer getSize() {
-		return mFileEntryElement.getSizeAttribute();
-	}
-
-	public void setEncryptionData(EncryptionDataElement encryptionData) {
-		EncryptionDataElement encryptionDataEle = getEncryptionData();
-		if (encryptionData != null) {
-			if (encryptionDataEle != null) {
-				mFileEntryElement.replaceChild(encryptionData, encryptionDataEle);
-			} else {
-				mFileEntryElement.appendChild(encryptionData);
-			}
-		} else {
-			if (encryptionDataEle != null) {
-				mFileEntryElement.removeChild(encryptionDataEle);
-			}
-		}
-	}
+	/** @return the mediatype of the mandatory &lt;manifest:file-entry&gt; attribute.
+	 *  If no mediatype exists an empty string is returned*/
+    public String getMediaTypeString() {
+        return mMediaType;
+    }
+
+    /**
+     * Get the media type from the given file reference
+     * 
+     * @param fileRef the reference to the file the media type is questioned
+     * 
+     * @return the mediaType string of the given file reference
+     */
+    public static String getMediaTypeString(String fileRef) {
+        String mediaType = null;
+        try {
+            // use 'JavaBeans Activation Framework' if available (as library or as part of JDK 6)
+            Class<?> mimetypesClass = Class.forName("javax.activation.MimetypesFileTypeMap");
+            Method getContentTypeMethod = mimetypesClass.getMethod("getContentType", String.class);
+            mediaType = (String) getContentTypeMethod.invoke(getContentTypeMethod, fileRef);
+        } catch (Exception e) {
+            // otherwise (JDK 5 without library of 'JavaBeans Activation Framework')
+            // use local fallback implementation
+//          mLog.fine("Using own mediatype handling as 'JavaBeans Activation Framework' not found: " +  e.getMessage());
+            mediaType = findMediaTypeString(fileRef);
+        }
+        return mediaType;
+    }
+
+    /** Own mediatype functionality which can be removed as soon JDK 6 is base line */
+    private static String findMediaTypeString(String fileRef) {
+        String fileSuffix = null;
+        String mediaType = null;
+
+        int suffixStart = fileRef.lastIndexOf(".");
+        // default mediatype, if no dot exists        
+        if (suffixStart < 0) {
+            mediaType = DEFAULT_TYPE;
+        } else {
+            fileSuffix = fileRef.substring(suffixStart + 1);
+            // default mediattype, if the file ends with a dot, the suffix is empty
+            if (fileSuffix.length() == 0) {
+                mediaType = DEFAULT_TYPE;
+            } else {
+                if (MEDIA_TYPE_MAP == null) {
+                    initializeMediaTypeMap();
+                }
+                mediaType = MEDIA_TYPE_MAP.get(fileSuffix.toLowerCase());
+                // default mediatype, if no mediatype for this suffix exists
+                if (mediaType == null) {
+                    mediaType = DEFAULT_TYPE;
+                }
+            }
+        }
+        return mediaType;
+    }
+    // initializes Map for suffix to media type string mapping
+    private static void initializeMediaTypeMap() {
+        MEDIA_TYPE_MAP = new HashMap<String, String>(39);
+        MEDIA_TYPE_MAP.put("ai", APPLICATION_POSTSCRIPT);
+        MEDIA_TYPE_MAP.put("eps", APPLICATION_POSTSCRIPT);
+        MEDIA_TYPE_MAP.put("ps", APPLICATION_POSTSCRIPT);
+        MEDIA_TYPE_MAP.put("rtf", APPLICATION_RTF);
+        MEDIA_TYPE_MAP.put("tex", APPLICATION_X_TEX);
+        MEDIA_TYPE_MAP.put("texi", APPLICATION_X_TEXINFO);
+        MEDIA_TYPE_MAP.put("texinfo", APPLICATION_X_TEXINFO);
+        MEDIA_TYPE_MAP.put("t", APPLICATION_X_TROFF);
+        MEDIA_TYPE_MAP.put("tr", APPLICATION_X_TROFF);
+        MEDIA_TYPE_MAP.put("roff", APPLICATION_X_TROFF);
+        MEDIA_TYPE_MAP.put("au", AUDIO_BASIC);
+        MEDIA_TYPE_MAP.put("midi", AUDIO_MIDI);
+        MEDIA_TYPE_MAP.put("mid", AUDIO_MIDI);
+        MEDIA_TYPE_MAP.put("aifc", AUDIO_X_AIFC);
+        MEDIA_TYPE_MAP.put("aif", AUDIO_X_AIFF);
+        MEDIA_TYPE_MAP.put("aiff", AUDIO_X_AIFF);
+        MEDIA_TYPE_MAP.put("mpeg", AUDIO_X_MPEG);
+        MEDIA_TYPE_MAP.put("mpg", AUDIO_X_MPEG);
+        MEDIA_TYPE_MAP.put("wav", AUDIO_X_WAV);
+        MEDIA_TYPE_MAP.put("gif", IMAGE_GIF);
+        MEDIA_TYPE_MAP.put("ief", IMAGE_IEF);
+        MEDIA_TYPE_MAP.put("jpeg", IMAGE_JPEG);
+        MEDIA_TYPE_MAP.put("jpg", IMAGE_JPEG);
+        MEDIA_TYPE_MAP.put("jpe", IMAGE_JPEG);
+        MEDIA_TYPE_MAP.put("png", IMAGE_PNG);
+        MEDIA_TYPE_MAP.put("tiff", IMAGE_TIFF);
+        MEDIA_TYPE_MAP.put("tif", IMAGE_TIFF);
+        MEDIA_TYPE_MAP.put("xwd", IMAGE_X_XWINDOWDUMP);
+        MEDIA_TYPE_MAP.put("html", TEXT_HTML);
+        MEDIA_TYPE_MAP.put("htm", TEXT_HTML);
+        MEDIA_TYPE_MAP.put("xhtml", TEXT_HTML);
+        MEDIA_TYPE_MAP.put("txt", TEXT_PLAIN);
+        MEDIA_TYPE_MAP.put("text", TEXT_PLAIN);
+        MEDIA_TYPE_MAP.put("xml", TEXT_XML);        
+        MEDIA_TYPE_MAP.put("mpeg", VIDEO_MEPG);
+        MEDIA_TYPE_MAP.put("mpg", VIDEO_MEPG);
+        MEDIA_TYPE_MAP.put("mpe", VIDEO_MEPG);
+        MEDIA_TYPE_MAP.put("qt", VIDEO_QUICKTIME);
+        MEDIA_TYPE_MAP.put("mov", VIDEO_QUICKTIME);
+        MEDIA_TYPE_MAP.put("avi", VIDEO_X_MSVIDEO);
+    }
+
+    public void setSize(int size) {
+        mSize = size;
+    }
+
+    /**
+     * get the size or -1 if not set
+     */
+    public int getSize() {
+        return mSize;
+    }
+
+    public void setEncryptionData(EncryptionData encryptionData) {
+        mEncryptionData = encryptionData;
+    }
 
 	/** @return null if no encryption data had been set */
-	public EncryptionDataElement getEncryptionData() {
-		return OdfElement.findFirstChildNode(EncryptionDataElement.class, mFileEntryElement);
-	}
-
-	/**
-	 * Gets the OdfElement of this OdfFileEntry.
-	 * 
-	 * @return the OdfElement of this OdfFileEntry.
-	 */
-	public FileEntryElement getOdfElement() {
-		return mFileEntryElement;
-	}
-
-	/**
-	 * Own mediatype functionality which can be removed as soon JDK 6 is base
-	 * line
-	 */
-	private static String findMediaTypeString(String fileRef) {
-		String fileSuffix = null;
-		String mediaType = null;
-
-		int suffixStart = fileRef.lastIndexOf(".");
-		// default mediatype, if no dot exists
-		if (suffixStart < 0) {
-			mediaType = DEFAULT_TYPE;
-		} else {
-			fileSuffix = fileRef.substring(suffixStart + 1);
-			// default mediattype, if the file ends with a dot, the suffix is
-			// empty
-			if (fileSuffix.length() == 0) {
-				mediaType = DEFAULT_TYPE;
-			} else {
-				if (MEDIA_TYPE_MAP == null) {
-					initializeMediaTypeMap();
-				}
-				mediaType = MEDIA_TYPE_MAP.get(fileSuffix.toLowerCase());
-				// default mediatype, if no mediatype for this suffix exists
-				if (mediaType == null) {
-					mediaType = DEFAULT_TYPE;
-				}
-			}
-		}
-		return mediaType;
-	}
-
-	// initializes Map for suffix to media type string mapping
-	private static void initializeMediaTypeMap() {
-		MEDIA_TYPE_MAP = new HashMap<String, String>(39);
-		MEDIA_TYPE_MAP.put("ai", APPLICATION_POSTSCRIPT);
-		MEDIA_TYPE_MAP.put("eps", APPLICATION_POSTSCRIPT);
-		MEDIA_TYPE_MAP.put("ps", APPLICATION_POSTSCRIPT);
-		MEDIA_TYPE_MAP.put("rtf", APPLICATION_RTF);
-		MEDIA_TYPE_MAP.put("tex", APPLICATION_X_TEX);
-		MEDIA_TYPE_MAP.put("texi", APPLICATION_X_TEXINFO);
-		MEDIA_TYPE_MAP.put("texinfo", APPLICATION_X_TEXINFO);
-		MEDIA_TYPE_MAP.put("t", APPLICATION_X_TROFF);
-		MEDIA_TYPE_MAP.put("tr", APPLICATION_X_TROFF);
-		MEDIA_TYPE_MAP.put("roff", APPLICATION_X_TROFF);
-		MEDIA_TYPE_MAP.put("au", AUDIO_BASIC);
-		MEDIA_TYPE_MAP.put("midi", AUDIO_MIDI);
-		MEDIA_TYPE_MAP.put("mid", AUDIO_MIDI);
-		MEDIA_TYPE_MAP.put("aifc", AUDIO_X_AIFC);
-		MEDIA_TYPE_MAP.put("aif", AUDIO_X_AIFF);
-		MEDIA_TYPE_MAP.put("aiff", AUDIO_X_AIFF);
-		MEDIA_TYPE_MAP.put("mpeg", AUDIO_X_MPEG);
-		MEDIA_TYPE_MAP.put("mpg", AUDIO_X_MPEG);
-		MEDIA_TYPE_MAP.put("wav", AUDIO_X_WAV);
-		MEDIA_TYPE_MAP.put("gif", IMAGE_GIF);
-		MEDIA_TYPE_MAP.put("ief", IMAGE_IEF);
-		MEDIA_TYPE_MAP.put("jpeg", IMAGE_JPEG);
-		MEDIA_TYPE_MAP.put("jpg", IMAGE_JPEG);
-		MEDIA_TYPE_MAP.put("jpe", IMAGE_JPEG);
-		MEDIA_TYPE_MAP.put("png", IMAGE_PNG);
-		MEDIA_TYPE_MAP.put("tiff", IMAGE_TIFF);
-		MEDIA_TYPE_MAP.put("tif", IMAGE_TIFF);
-		MEDIA_TYPE_MAP.put("xwd", IMAGE_X_XWINDOWDUMP);
-		MEDIA_TYPE_MAP.put("html", TEXT_HTML);
-		MEDIA_TYPE_MAP.put("htm", TEXT_HTML);
-		MEDIA_TYPE_MAP.put("xhtml", TEXT_HTML);
-		MEDIA_TYPE_MAP.put("txt", TEXT_PLAIN);
-		MEDIA_TYPE_MAP.put("text", TEXT_PLAIN);
-		MEDIA_TYPE_MAP.put("xml", TEXT_XML);
-		MEDIA_TYPE_MAP.put("mpeg", VIDEO_MEPG);
-		MEDIA_TYPE_MAP.put("mpg", VIDEO_MEPG);
-		MEDIA_TYPE_MAP.put("mpe", VIDEO_MEPG);
-		MEDIA_TYPE_MAP.put("qt", VIDEO_QUICKTIME);
-		MEDIA_TYPE_MAP.put("mov", VIDEO_QUICKTIME);
-		MEDIA_TYPE_MAP.put("avi", VIDEO_X_MSVIDEO);
-	}
+    public EncryptionData getEncryptionData() {
+        return mEncryptionData;
+    }
 }
+

Modified: incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/doc/DocumentTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/doc/DocumentTest.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/doc/DocumentTest.java (original)
+++ incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/doc/DocumentTest.java Sun Aug 19 15:01:09 2012
@@ -428,7 +428,7 @@ public class DocumentTest {
 		return stringBuilder.toString();
 	}
 
-	/** Saves the data string as UTF8 to the given filePath */
+	/** Saves the datastring as UTF8 to the given filePath */
 	private static void saveString(String dataString, String filePath) throws UnsupportedEncodingException, IOException {
 		BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filePath), "UTF8"));
 		out.append(dataString);
@@ -485,12 +485,12 @@ public class DocumentTest {
 		handler1.setTestFilePath("testInvalidPkg1.odt");
 		try {
 			// First Test / Handler2
-			OdfPackage pkg2 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler2.getTestFilePath())), null, handler2);
+			OdfPackage pkg2 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler2.getTestFilePath())), handler2);
 			OdfDocument doc2 = OdfDocument.loadDocument(pkg2);
 			Assert.assertNotNull(doc2);
 
 			// Second Test / Handler3
-			OdfPackage pkg3 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler3.getTestFilePath())), null, handler3);
+			OdfPackage pkg3 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler3.getTestFilePath())), handler3);
 			OdfDocument doc3 = OdfDocument.loadDocument(pkg3);
 			Assert.assertNotNull(doc3);
 			Map subDocs = doc3.loadSubDocuments();
@@ -498,7 +498,7 @@ public class DocumentTest {
 			Assert.assertEquals(PRESENTATION1_DOC_COUNT, subDocs.size());
 
 			// Third Test / Handler1
-			OdfPackage pkg1 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler1.getTestFilePath())), null, handler1);
+			OdfPackage pkg1 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler1.getTestFilePath())), handler1);
 			OdfDocument.loadDocument(pkg1);
 			Assert.fail();
 		} catch (Exception e) {

Modified: incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/LoadSaveErrorTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/LoadSaveErrorTest.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/LoadSaveErrorTest.java (original)
+++ incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/LoadSaveErrorTest.java Sun Aug 19 15:01:09 2012
@@ -32,7 +32,6 @@ import java.util.zip.ZipOutputStream;
 
 import org.junit.Assert;
 import org.junit.Test;
-import org.junit.Ignore;
 import org.odftoolkit.odfdom.doc.OdfDocument;
 import org.odftoolkit.odfdom.utils.ResourceUtilities;
 import org.w3c.dom.Document;
@@ -57,7 +56,6 @@ public class LoadSaveErrorTest {
 	 * @throws SAXException if an XML-related error occurs
 	 * @throws IOException if an I/O error occurs
 	 */
-        @Ignore
 	@Test
 	public void testInvalidZipAsODF() throws SAXException, IOException {
 		ByteArrayOutputStream baout = new ByteArrayOutputStream();
@@ -101,11 +99,9 @@ public class LoadSaveErrorTest {
 		try {
 			OdfPackage odfPackage = OdfPackage.loadPackage(
 					new ByteArrayInputStream(zip), null, errorHandler);
-
-			System.err.println("*** no exception thrown on loadPackage");
 			odfPackage.close();
 			Assert.fail("Expected an exception for the incomplete ODF file!");
-		} catch (Exception se) {
+		} catch (SAXException se) {
 			//expected
 		}
 		Assert.assertEquals(0, warnings.get());
@@ -115,7 +111,7 @@ public class LoadSaveErrorTest {
 	}
 
 	@Test
-	public void testLoadWithFailingNetworkConnection() throws Exception {
+	public void testLoadWithFailingNetwortConnection() throws Exception {
 		String doc = ResourceUtilities.getAbsolutePath(SOURCE);
 		File file = new File(doc);
 		InputStream in = new java.io.FileInputStream(file);
@@ -136,8 +132,7 @@ public class LoadSaveErrorTest {
 	 * Tests what happens if there is an I/O error while saving an ODF file.
 	 * @throws Exception if an error occurs
 	 */
-        @Ignore
-        @Test
+	@Test
 	public void testDiskFullOnSave() throws Exception {
 		OdfPackageDocument odfDocument = OdfPackageDocument
 				.loadDocument(ResourceUtilities.getAbsolutePath(SOURCE));

Modified: incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/OdfXMLHelper.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/OdfXMLHelper.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/OdfXMLHelper.java (original)
+++ incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/OdfXMLHelper.java Sun Aug 19 15:01:09 2012
@@ -29,6 +29,8 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
 import javax.xml.transform.Result;
 import javax.xml.transform.Source;
 import javax.xml.transform.Templates;
@@ -36,6 +38,7 @@ import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;

Modified: incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/PackageTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/PackageTest.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/PackageTest.java (original)
+++ incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/pkg/PackageTest.java Sun Aug 19 15:01:09 2012
@@ -130,7 +130,7 @@ public class PackageTest {
 			LOG.info("Loading an unsupported image file as an ODF Package (with error handler)!");
 			try {
 				// Exception is expected by error handler!
-				OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(IMAGE_TEST_FILE)), null, new DefaultHandler());
+				OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(IMAGE_TEST_FILE)), new DefaultHandler());
 				Assert.fail();
 			} catch (SAXException e) {
 				String errorMsg = OdfPackageConstraint.PACKAGE_IS_NO_ZIP.getMessage();
@@ -313,14 +313,14 @@ public class PackageTest {
 		ErrorHandlerStub handler4 = new ErrorHandlerStub(null, null, expectedFatalErrors4);
 
 		try {
-			OdfPackage pkg1 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler1.getTestFilePath())), null, handler1);
+			OdfPackage pkg1 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler1.getTestFilePath())), handler1);
 			Assert.assertNotNull(pkg1);
-			OdfPackage pkg2 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler2.getTestFilePath())), null, handler2);
+			OdfPackage pkg2 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler2.getTestFilePath())), handler2);
 			Assert.assertNotNull(pkg2);
-			OdfPackage pkg3 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler3.getTestFilePath())), null, handler3);
+			OdfPackage pkg3 = OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath(handler3.getTestFilePath())), handler3);
 			Assert.assertNotNull(pkg3);
 			try {
-				OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath("testA.jpg")), null, handler4);
+				OdfPackage.loadPackage(new File(ResourceUtilities.getAbsolutePath("testA.jpg")), handler4);
 				Assert.fail();
 			} catch (Exception e) {
 				String errorMsg = OdfPackageConstraint.PACKAGE_IS_NO_ZIP.getMessage();
@@ -337,22 +337,4 @@ public class PackageTest {
 		handler3.validate();
 		handler4.validate();
 	}
-
-	@Test
-	public void testPackagePassword() {
-		File tmpFile = ResourceUtilities.newTestOutputFile("PackagePassword.ods");
-		OdfDocument doc = null;
-		try {
-			doc = OdfSpreadsheetDocument.newSpreadsheetDocument();
-			doc.getPackage().setPassword("password");
-			doc.save(tmpFile);
-			doc.close();
-			OdfPackage odfPackage = OdfPackage.loadPackage(tmpFile, "password", null);
-			byte[] contentBytes = odfPackage.getBytes("content.xml");
-			Assert.assertNotNull(contentBytes);
-		} catch (Exception ex) {
-			LOG.log(Level.SEVERE, "password test failed.", ex);			
-			Assert.fail();
-		}
-	}
 }

Modified: incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/Document.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/Document.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/Document.java (original)
+++ incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/Document.java Sun Aug 19 15:01:09 2012
@@ -87,8 +87,8 @@ import org.odftoolkit.odfdom.type.Durati
 import org.odftoolkit.simple.meta.Meta;
 import org.odftoolkit.simple.table.AbstractTableContainer;
 import org.odftoolkit.simple.table.Table;
-import org.odftoolkit.simple.table.Table.TableBuilder;
 import org.odftoolkit.simple.table.TableContainer;
+import org.odftoolkit.simple.table.Table.TableBuilder;
 import org.odftoolkit.simple.text.Section;
 import org.w3c.dom.Attr;
 import org.w3c.dom.NamedNodeMap;
@@ -108,9 +108,9 @@ public abstract class Document extends O
 	private TableContainerImpl tableContainerImpl;
 	private static final Pattern CONTROL_CHAR_PATTERN = Pattern.compile("\\p{Cntrl}");
 	private static final String EMPTY_STRING = "";
-
+	
 	private IdentityHashMap<OdfElement, Component> mComponentRepository = new IdentityHashMap<OdfElement, Component>();
-
+	
 	// FIXME: This field is only used in method copyResourcesFrom to improve
 	// copy performance, should not be used in any other way.
 	// methods loadDocument(String documentPath) and loadDocument(File file)
@@ -161,11 +161,11 @@ public abstract class Document extends O
 		IMAGE("application/vnd.oasis.opendocument.image", "odi"), 
 		IMAGE_TEMPLATE("application/vnd.oasis.opendocument.image-template", "oti"), 
 		PRESENTATION("application/vnd.oasis.opendocument.presentation", "odp"), 
-		PRESENTATION_TEMPLATE("application/vnd.oasis.opendocument.presentation-template", "otp"), 
+		PRESENTATION_TEMPLATE("application/vnd.oasis.opendocument.presentation-template", "otp"),
 		SPREADSHEET("application/vnd.oasis.opendocument.spreadsheet", "ods"), 
 		SPREADSHEET_TEMPLATE("application/vnd.oasis.opendocument.spreadsheet-template", "ots"), 
 		TEXT("application/vnd.oasis.opendocument.text", "odt"), 
-		TEXT_MASTER("application/vnd.oasis.opendocument.text-master", "odm"), 
+		TEXT_MASTER("application/vnd.oasis.opendocument.text-master", "odm"),
 		TEXT_TEMPLATE("application/vnd.oasis.opendocument.text-template", "ott"), 
 		TEXT_WEB("application/vnd.oasis.opendocument.text-web", "oth");
 
@@ -245,30 +245,7 @@ public abstract class Document extends O
 	 * 
 	 * <p>
 	 * Document relies on the file being available for read access over the
-	 * whole life cycle of Document.
-	 * </p>
-	 * 
-	 * @param documentPath
-	 *            - the path from where the document can be loaded
-	 * @param password
-	 *            - file password.
-	 * @return the Document from the given path or NULL if the media type is not
-	 *         supported by SIMPLE.
-	 * @throws java.lang.Exception
-	 *             - if the document could not be created.
-	 * @since 0.8
-	 */
-	public static Document loadDocument(String documentPath, String password) throws Exception {
-		File file = new File(documentPath);
-		return loadDocument(file, password);
-	}
-
-	/**
-	 * Loads a Document from the provided path.
-	 * 
-	 * <p>
-	 * Document relies on the file being available for read access over the
-	 * whole life cycle of Document.
+	 * whole lifecycle of Document.
 	 * </p>
 	 * 
 	 * @param documentPath
@@ -280,7 +257,9 @@ public abstract class Document extends O
 	 */
 	public static Document loadDocument(String documentPath) throws Exception {
 		File file = new File(documentPath);
-		return loadDocument(file);
+		Document doc = loadDocument(OdfPackage.loadPackage(documentPath));
+		doc.setFile(file);
+		return doc;
 	}
 
 	/**
@@ -325,29 +304,6 @@ public abstract class Document extends O
 	}
 
 	/**
-	 * Creates a Document from the Document provided by a File.
-	 * 
-	 * <p>
-	 * Document relies on the file being available for read access over the
-	 * whole lifecycle of Document.
-	 * </p>
-	 * 
-	 * @param file
-	 *            - a file representing the ODF document.
-	 * @param password
-	 *            - file password.
-	 * @return the document created from the given File
-	 * @throws java.lang.Exception
-	 *             - if the document could not be created.
-	 * @since 0.7
-	 */
-	public static Document loadDocument(File file, String password) throws Exception {
-		Document doc = loadDocument(OdfPackage.loadPackage(file, password, null));
-		doc.setFile(file);
-		return doc;
-	}
-
-	/**
 	 * Creates a Document from the Document provided by an ODF package.
 	 * 
 	 * @param odfPackage
@@ -374,7 +330,8 @@ public abstract class Document extends O
 	public static Document loadDocument(OdfPackage odfPackage, String internalPath) throws Exception {
 		String documentMediaType = odfPackage.getMediaTypeString(internalPath);
 		if (documentMediaType == null) {
-			throw new IllegalArgumentException("Given internalPath '" + internalPath + "' is an illegal or inappropriate argument.");
+			throw new IllegalArgumentException("Given internalPath '" + internalPath
+					+ "' is an illegal or inappropriate argument.");
 		}
 		OdfMediaType odfMediaType = OdfMediaType.getOdfMediaType(documentMediaType);
 		if (odfMediaType == null) {
@@ -383,7 +340,8 @@ public abstract class Document extends O
 			if (matcherCTRL.find()) {
 				documentMediaType = matcherCTRL.replaceAll(EMPTY_STRING);
 			}
-			OdfValidationException ve = new OdfValidationException(OdfSchemaConstraint.DOCUMENT_WITHOUT_ODF_MIMETYPE, internalPath, documentMediaType);
+			OdfValidationException ve = new OdfValidationException(OdfSchemaConstraint.DOCUMENT_WITHOUT_ODF_MIMETYPE,
+					internalPath, documentMediaType);
 			if (errorHandler != null) {
 				errorHandler.fatalError(ve);
 			}
@@ -392,17 +350,6 @@ public abstract class Document extends O
 		return newDocument(odfPackage, internalPath, odfMediaType);
 	}
 
-	/**
-	 * Sets password of this document.
-	 * 
-	 * @param password
-	 *            the password of this document.
-	 * @since 0.8
-	 */
-	public void setPassword(String password) {
-		getPackage().setPassword(password);
-	}
-
 	// return null if the media type can not be recognized.
 	private static Document loadDocumentFromTemplate(OdfMediaType odfMediaType) throws Exception {
 
@@ -460,7 +407,8 @@ public abstract class Document extends O
 			// case IMAGE_TEMPLATE:
 
 		default:
-			throw new IllegalArgumentException("Given mediaType '" + odfMediaType.toString() + "' is either not yet supported or not an ODF mediatype!");
+			throw new IllegalArgumentException("Given mediaType '" + odfMediaType.toString()
+					+ "' is either not yet supported or not an ODF mediatype!");
 		}
 	}
 
@@ -504,7 +452,8 @@ public abstract class Document extends O
 			break;
 
 		case PRESENTATION_TEMPLATE:
-			newDoc = new PresentationDocument(pkg, internalPath, PresentationDocument.OdfMediaType.PRESENTATION_TEMPLATE);
+			newDoc = new PresentationDocument(pkg, internalPath,
+					PresentationDocument.OdfMediaType.PRESENTATION_TEMPLATE);
 			break;
 
 		case GRAPHICS:
@@ -527,7 +476,8 @@ public abstract class Document extends O
 
 		default:
 			newDoc = null;
-			throw new IllegalArgumentException("Given mediaType '" + odfMediaType.mMediaType + "' is not yet supported!");
+			throw new IllegalArgumentException("Given mediaType '" + odfMediaType.mMediaType
+					+ "' is not yet supported!");
 		}
 		// returning null if MediaType is not supported
 		return newDoc;
@@ -780,58 +730,6 @@ public abstract class Document extends O
 	}
 
 	/**
-	 * Save the document to a given file with given password.
-	 * 
-	 * <p>
-	 * If the input file has been cached (this is the case when loading from an
-	 * InputStream), the input file can be overwritten.
-	 * </p>
-	 * 
-	 * <p>
-	 * Otherwise it's allowed to overwrite the input file as long as the same
-	 * path name is used that was used for loading (no symbolic link foo2.odt
-	 * pointing to the loaded file foo1.odt, no network path X:\foo.odt pointing
-	 * to the loaded file D:\foo.odt).
-	 * </p>
-	 * 
-	 * <p>
-	 * When saving the embedded document to a stand alone document, all files of
-	 * the embedded document will be copied to a new document package. If the
-	 * embedded document is outside of the current document directory, you have
-	 * to embed it to the sub directory and refresh the link of the embedded
-	 * document. You should reload it from the given file to get the saved
-	 * embedded document.
-	 * 
-	 * @param file
-	 *            the file to save the document.
-	 * @param file
-	 *            the password of this document.
-	 * 
-	 * @throws java.lang.Exception
-	 *             if the document could not be saved
-	 * @since 0.8
-	 */
-	public void save(File file, String password) throws Exception {
-		// 2DO FLUSH AND SAVE IN PACKAGE
-		flushDoms();
-		updateMetaData();
-		if (!isRootDocument()) {
-			Document newDoc = loadDocumentFromTemplate(getOdfMediaType());
-			newDoc.insertDocument(this, ROOT_DOCUMENT_PATH);
-			newDoc.updateMetaData();
-			newDoc.mPackage.setPassword(password);
-			newDoc.mPackage.save(file);
-			// ToDo: (Issue 219 - PackageRefactoring) - Return the document,
-			// when not closing!
-			// Should we close the sources now? User will never receive the open
-			// package!
-		} else {
-			mPackage.setPassword(password);
-			mPackage.save(file);
-		}
-	}
-
-	/**
 	 * Close the OdfPackage and release all temporary created data. Acter
 	 * execution of this method, this class is no longer usable. Do this as the
 	 * last action to free resources. Closing an already closed document has no
@@ -910,19 +808,22 @@ public abstract class Document extends O
 			OdfDrawFrame drawFrame = contentDom.newOdfElement(OdfDrawFrame.class);
 			XPath xpath = contentDom.getXPath();
 			if (this instanceof SpreadsheetDocument) {
-				TableTableCellElement lastCell = (TableTableCellElement) xpath.evaluate("//table:table-cell[last()]", contentDom, XPathConstants.NODE);
+				TableTableCellElement lastCell = (TableTableCellElement) xpath.evaluate("//table:table-cell[last()]",
+						contentDom, XPathConstants.NODE);
 				lastCell.appendChild(drawFrame);
 				drawFrame.removeAttribute("text:anchor-type");
 
 			} else if (this instanceof TextDocument) {
-				TextPElement lastPara = (TextPElement) xpath.evaluate("//text:p[last()]", contentDom, XPathConstants.NODE);
+				TextPElement lastPara = (TextPElement) xpath.evaluate("//text:p[last()]", contentDom,
+						XPathConstants.NODE);
 				if (lastPara == null) {
 					lastPara = ((TextDocument) this).newParagraph();
 				}
 				lastPara.appendChild(drawFrame);
 				drawFrame.setTextAnchorTypeAttribute(TextAnchorTypeAttribute.Value.PARAGRAPH.toString());
 			} else if (this instanceof PresentationDocument) {
-				DrawPageElement lastPage = (DrawPageElement) xpath.evaluate("//draw:page[last()]", contentDom, XPathConstants.NODE);
+				DrawPageElement lastPage = (DrawPageElement) xpath.evaluate("//draw:page[last()]", contentDom,
+						XPathConstants.NODE);
 				lastPage.appendChild(drawFrame);
 			}
 			OdfDrawImage image = (OdfDrawImage) drawFrame.newDrawImageElement();
@@ -1009,7 +910,8 @@ public abstract class Document extends O
 				DatatypeFactory aFactory = DatatypeFactory.newInstance();
 				metaData.setEditingDuration(new Duration(aFactory.newDurationDayTime(editingDuration)));
 			} catch (DatatypeConfigurationException e) {
-				Logger.getLogger(Document.class.getName()).log(Level.SEVERE, "editing duration update fail as DatatypeFactory can not be instanced", e);
+				Logger.getLogger(Document.class.getName()).log(Level.SEVERE,
+						"editing duration update fail as DatatypeFactory can not be instanced", e);
 			}
 		}
 	}
@@ -1202,7 +1104,8 @@ public abstract class Document extends O
 		}
 	}
 
-	private Locale getDefaultLanguageByProperty(OdfStyleProperty countryProp, OdfStyleProperty languageProp) throws Exception {
+	private Locale getDefaultLanguageByProperty(OdfStyleProperty countryProp, OdfStyleProperty languageProp)
+			throws Exception {
 		String lang = null, ctry = null;
 
 		OdfOfficeStyles styles = getStylesDom().getOfficeStyles();
@@ -1255,8 +1158,10 @@ public abstract class Document extends O
 		if (getScriptType(locale) != ScriptType.CJK)
 			return;
 		String user_language = locale.getLanguage();
-		if (!user_language.equals(Locale.CHINESE.getLanguage()) && !user_language.equals(Locale.TRADITIONAL_CHINESE.getLanguage())
-				&& !user_language.equals(Locale.JAPANESE.getLanguage()) && !user_language.equals(Locale.KOREAN.getLanguage()))
+		if (!user_language.equals(Locale.CHINESE.getLanguage())
+				&& !user_language.equals(Locale.TRADITIONAL_CHINESE.getLanguage())
+				&& !user_language.equals(Locale.JAPANESE.getLanguage())
+				&& !user_language.equals(Locale.KOREAN.getLanguage()))
 			return;
 
 		OdfOfficeStyles styles = getStylesDom().getOfficeStyles();
@@ -1322,7 +1227,8 @@ public abstract class Document extends O
 
 			// Search in style.xml
 			root = getStylesDom().getRootElement();
-			OfficeMasterStylesElement masterStyle = OdfElement.findFirstChildNode(OfficeMasterStylesElement.class, root);
+			OfficeMasterStylesElement masterStyle = OdfElement
+					.findFirstChildNode(OfficeMasterStylesElement.class, root);
 			sectionList = masterStyle.getElementsByTagNameNS(OdfDocumentNamespace.TEXT.getUri(), "section");
 			for (int i = 0; i < sectionList.getLength(); i++) {
 				element = (TextSectionElement) sectionList.item(i);
@@ -1360,9 +1266,11 @@ public abstract class Document extends O
 			}
 
 			root = getStylesDom().getRootElement();
-			OfficeMasterStylesElement masterStyle = OdfElement.findFirstChildNode(OfficeMasterStylesElement.class, root);
+			OfficeMasterStylesElement masterStyle = OdfElement
+					.findFirstChildNode(OfficeMasterStylesElement.class, root);
 			xpath = getStylesDom().getXPath();
-			element = (TextSectionElement) xpath.evaluate(".//text:section[@text:name=\"" + name + "\"]", masterStyle, XPathConstants.NODE);
+			element = (TextSectionElement) xpath.evaluate(".//text:section[@text:name=\"" + name + "\"]", masterStyle,
+					XPathConstants.NODE);
 			if (element != null) {
 				return Section.getInstance(element);
 			}
@@ -1586,7 +1494,8 @@ public abstract class Document extends O
 					if (objectRenameMap.containsKey(refObjPath)) {
 						// this object has been copied already
 						newObjPath = objectRenameMap.get(refObjPath);
-						object.setAttributeNS(OdfDocumentNamespace.XLINK.getUri(), "xlink:href", hasPrefix ? (prefix + newObjPath) : newObjPath);
+						object.setAttributeNS(OdfDocumentNamespace.XLINK.getUri(), "xlink:href",
+								hasPrefix ? (prefix + newObjPath) : newObjPath);
 						continue;
 					}
 					// check if the current document contains the same path
@@ -1605,13 +1514,15 @@ public abstract class Document extends O
 							// then change the name before the suffix string
 							int dotIndex = refObjPath.indexOf(".");
 							if (dotIndex != -1) {
-								newObjPath = refObjPath.substring(0, dotIndex) + "-" + makeUniqueName() + refObjPath.substring(dotIndex);
+								newObjPath = refObjPath.substring(0, dotIndex) + "-" + makeUniqueName()
+										+ refObjPath.substring(dotIndex);
 							} else {
 								newObjPath = refObjPath + "-" + makeUniqueName();
 							}
 							objectRenameMap.put(refObjPath, newObjPath);
 						}
-						object.setAttributeNS(OdfDocumentNamespace.XLINK.getUri(), "xlink:href", hasPrefix ? (prefix + newObjPath) : newObjPath);
+						object.setAttributeNS(OdfDocumentNamespace.XLINK.getUri(), "xlink:href",
+								hasPrefix ? (prefix + newObjPath) : newObjPath);
 					} else
 						objectRenameMap.put(refObjPath, refObjPath);
 				}
@@ -1895,13 +1806,15 @@ public abstract class Document extends O
 							// then change the name before the suffix string
 							int dotIndex = refObjPath.indexOf(".");
 							if (dotIndex != -1) {
-								newObjPath = refObjPath.substring(0, dotIndex) + "-" + makeUniqueName() + refObjPath.substring(dotIndex);
+								newObjPath = refObjPath.substring(0, dotIndex) + "-" + makeUniqueName()
+										+ refObjPath.substring(dotIndex);
 							} else {
 								newObjPath = refObjPath + "-" + makeUniqueName();
 							}
 							objectRenameMap.put(refObjPath, newObjPath);
 						}
-						object.setAttributeNS(OdfDocumentNamespace.XLINK.getUri(), "xlink:href", hasPrefix ? (prefix + newObjPath) : newObjPath);
+						object.setAttributeNS(OdfDocumentNamespace.XLINK.getUri(), "xlink:href",
+								hasPrefix ? (prefix + newObjPath) : newObjPath);
 					}
 					InputStream is = srcDoc.getPackage().getInputStream(refObjPath);
 					if (is != null) {
@@ -1938,16 +1851,20 @@ public abstract class Document extends O
 			// attribute
 			// 1.1. style:name of content.xml
 			String styleQName = "style:name";
-			NodeList srcStyleDefNodeList = (NodeList) xpath.evaluate("*/office:automatic-styles/*[@" + styleQName + "]", srcContentDom, XPathConstants.NODESET);
+			NodeList srcStyleDefNodeList = (NodeList) xpath.evaluate(
+					"*/office:automatic-styles/*[@" + styleQName + "]", srcContentDom, XPathConstants.NODESET);
 			IdentityHashMap<OdfElement, List<OdfElement>> srcContentStyleCloneEleList = new IdentityHashMap<OdfElement, List<OdfElement>>();
 			IdentityHashMap<OdfElement, OdfElement> appendContentStyleList = new IdentityHashMap<OdfElement, OdfElement>();
-			getCopyStyleList(null, sourceCloneEle, styleQName, srcStyleDefNodeList, srcContentStyleCloneEleList, appendContentStyleList, tempList, true);
+			getCopyStyleList(null, sourceCloneEle, styleQName, srcStyleDefNodeList, srcContentStyleCloneEleList,
+					appendContentStyleList, tempList, true);
 			// 1.2. style:name of styles.xml
-			srcStyleDefNodeList = (NodeList) xpath.evaluate(".//*[@" + styleQName + "]", srcDoc.getStylesDom(), XPathConstants.NODESET);
+			srcStyleDefNodeList = (NodeList) xpath.evaluate(".//*[@" + styleQName + "]", srcDoc.getStylesDom(),
+					XPathConstants.NODESET);
 			IdentityHashMap<OdfElement, List<OdfElement>> srcStylesStyleCloneEleList = new IdentityHashMap<OdfElement, List<OdfElement>>();
 			IdentityHashMap<OdfElement, OdfElement> appendStylesStyleList = new IdentityHashMap<OdfElement, OdfElement>();
 			tempList.clear();
-			getCopyStyleList(null, sourceCloneEle, styleQName, srcStyleDefNodeList, srcStylesStyleCloneEleList, appendStylesStyleList, tempList, true);
+			getCopyStyleList(null, sourceCloneEle, styleQName, srcStyleDefNodeList, srcStylesStyleCloneEleList,
+					appendStylesStyleList, tempList, true);
 			// 1.3 rename, copy the referred style element to the corresponding
 			// position in the dom tree
 			insertCollectedStyle(styleQName, srcContentStyleCloneEleList, getContentDom(), appendContentStyleList);
@@ -1963,22 +1880,23 @@ public abstract class Document extends O
 			// element, so only search it in styles.xml dom
 			tempList.clear();
 			styleQName = "draw:name";
-			srcStyleDefNodeList = (NodeList) xpath.evaluate(".//*[@" + styleQName + "]", srcDoc.getStylesDom(), XPathConstants.NODESET);
+			srcStyleDefNodeList = (NodeList) xpath.evaluate(".//*[@" + styleQName + "]", srcDoc.getStylesDom(),
+					XPathConstants.NODESET);
 			IdentityHashMap<OdfElement, List<OdfElement>> srcDrawStyleCloneEleList = new IdentityHashMap<OdfElement, List<OdfElement>>();
 			IdentityHashMap<OdfElement, OdfElement> appendDrawStyleList = new IdentityHashMap<OdfElement, OdfElement>();
 			Iterator<OdfElement> iter = appendContentStyleList.keySet().iterator();
 			while (iter.hasNext()) {
 				OdfElement styleElement = iter.next();
 				OdfElement cloneStyleElement = appendContentStyleList.get(styleElement);
-				getCopyStyleList(styleElement, cloneStyleElement, styleQName, srcStyleDefNodeList, srcDrawStyleCloneEleList, appendDrawStyleList, tempList,
-						false);
+				getCopyStyleList(styleElement, cloneStyleElement, styleQName, srcStyleDefNodeList,
+						srcDrawStyleCloneEleList, appendDrawStyleList, tempList, false);
 			}
 			iter = appendStylesStyleList.keySet().iterator();
 			while (iter.hasNext()) {
 				OdfElement styleElement = iter.next();
 				OdfElement cloneStyleElement = appendStylesStyleList.get(styleElement);
-				getCopyStyleList(styleElement, cloneStyleElement, styleQName, srcStyleDefNodeList, srcDrawStyleCloneEleList, appendDrawStyleList, tempList,
-						false);
+				getCopyStyleList(styleElement, cloneStyleElement, styleQName, srcStyleDefNodeList,
+						srcDrawStyleCloneEleList, appendDrawStyleList, tempList, false);
 			}
 			// 2.2 rename, copy the referred style element to the corresponding
 			// position in the dom tree
@@ -1996,7 +1914,8 @@ public abstract class Document extends O
 	// referred style name of the element which reference this style
 	// 3. All the style which also contains other style reference, should be
 	// copied to the source document.
-	private void insertCollectedStyle(String styleQName, IdentityHashMap<OdfElement, List<OdfElement>> srcStyleCloneEleList, OdfFileDom dom,
+	private void insertCollectedStyle(String styleQName,
+			IdentityHashMap<OdfElement, List<OdfElement>> srcStyleCloneEleList, OdfFileDom dom,
 			IdentityHashMap<OdfElement, OdfElement> appendStyleList) {
 		try {
 			String stylePrefix = OdfNamespace.getPrefixPart(styleQName);
@@ -2008,7 +1927,8 @@ public abstract class Document extends O
 			XPath xpath = dom.getXPath();
 			NodeList destStyleNodeList;
 			if (dom instanceof OdfContentDom)
-				destStyleNodeList = (NodeList) xpath.evaluate("*/office:automatic-styles/*[@" + styleQName + "]", dom, XPathConstants.NODESET);
+				destStyleNodeList = (NodeList) xpath.evaluate("*/office:automatic-styles/*[@" + styleQName + "]", dom,
+						XPathConstants.NODESET);
 			else
 				destStyleNodeList = (NodeList) xpath.evaluate(".//*[@" + styleQName + "]", dom, XPathConstants.NODESET);
 			Iterator<OdfElement> iter = srcStyleCloneEleList.keySet().iterator();
@@ -2040,7 +1960,8 @@ public abstract class Document extends O
 							// if not, the cloneStyleElement should rename,
 							// rather than reuse the new style name
 							cloneStyleElement.setAttributeNS(styleURI, styleQName, styleNameIter);
-							if ((destStyleElementWithNewName != null) && destStyleElementWithNewName.equals(cloneStyleElement)) {
+							if ((destStyleElementWithNewName != null)
+									&& destStyleElementWithNewName.equals(cloneStyleElement)) {
 								newStyleName = styleNameIter;
 								break;
 							}
@@ -2061,8 +1982,8 @@ public abstract class Document extends O
 						// if display name should also be renamed
 						String displayName = cloneStyleElement.getAttributeNS(styleURI, "display-name");
 						if ((displayName != null) && (displayName.length() > 0)) {
-							cloneStyleElement.setAttributeNS(styleURI, stylePrefix + ":display-name",
-									displayName + newStyleName.substring(newStyleName.length() - 8));
+							cloneStyleElement.setAttributeNS(styleURI, stylePrefix + ":display-name", displayName
+									+ newStyleName.substring(newStyleName.length() - 8));
 						}
 					}
 				}
@@ -2110,8 +2031,8 @@ public abstract class Document extends O
 	// if loop == true, get the style definition element reference other style
 	// definition element
 	private void getCopyStyleList(OdfElement ele, OdfElement cloneEle, String styleQName, NodeList srcStyleNodeList,
-			IdentityHashMap<OdfElement, List<OdfElement>> copyStyleEleList, IdentityHashMap<OdfElement, OdfElement> appendStyleList, List<String> attrStrList,
-			boolean loop) {
+			IdentityHashMap<OdfElement, List<OdfElement>> copyStyleEleList,
+			IdentityHashMap<OdfElement, OdfElement> appendStyleList, List<String> attrStrList, boolean loop) {
 		try {
 			String styleLocalName = OdfNamespace.getLocalPart(styleQName);
 			String stylePrefix = OdfNamespace.getPrefixPart(styleQName);
@@ -2136,7 +2057,8 @@ public abstract class Document extends O
 						}
 						attrStrList.add(attrStr + "=" + "\"" + styleName + "\"");
 						XPath xpath = ((OdfFileDom) cloneEle.getOwnerDocument()).getXPath();
-						NodeList styleRefNodes = (NodeList) xpath.evaluate(".//*[@" + attrStr + "='" + styleName + "']", cloneEle, XPathConstants.NODESET);
+						NodeList styleRefNodes = (NodeList) xpath.evaluate(
+								".//*[@" + attrStr + "='" + styleName + "']", cloneEle, XPathConstants.NODESET);
 						boolean isExist = false;
 						for (int j = 0; j <= styleRefNodes.getLength(); j++) {
 							OdfElement styleRefElement = null;
@@ -2169,8 +2091,8 @@ public abstract class Document extends O
 								appendStyleList.put(styleElement, cloneStyleElement);
 							}
 							if (loop && !hasLoopStyleDef) {
-								getCopyStyleList(styleElement, cloneStyleElement, styleQName, srcStyleNodeList, copyStyleEleList, appendStyleList, attrStrList,
-										loop);
+								getCopyStyleList(styleElement, cloneStyleElement, styleQName, srcStyleNodeList,
+										copyStyleEleList, appendStyleList, attrStrList, loop);
 							}
 						}
 						index = cloneEleStr.indexOf("=\"" + styleName + "\"", index + styleName.length());
@@ -2339,9 +2261,11 @@ public abstract class Document extends O
 				int relation = odfEle.compareDocumentPosition(object);
 				// if slide element contains the returned element which has the
 				// xlink:href reference
-				if ((relation & Node.DOCUMENT_POSITION_CONTAINED_BY) > 0 && refObjPath != null && refObjPath.length() > 0) {
+				if ((relation & Node.DOCUMENT_POSITION_CONTAINED_BY) > 0 && refObjPath != null
+						&& refObjPath.length() > 0) {
 					// the path of the object is start with "./"
-					NodeList pathNodes = (NodeList) xpath.evaluate("//*[@xlink:href='" + refObjPath + "']", getContentDom(), XPathConstants.NODESET);
+					NodeList pathNodes = (NodeList) xpath.evaluate("//*[@xlink:href='" + refObjPath + "']",
+							getContentDom(), XPathConstants.NODESET);
 					int refCount = pathNodes.getLength();
 					if (refCount == 1) {
 						// delete "./"
@@ -2407,7 +2331,8 @@ public abstract class Document extends O
 					if (styleName != null) {
 						// search the styleName contained at the current page
 						// element
-						NodeList styleNodes = (NodeList) xpath.evaluate("//*[@*='" + styleName + "']", contentDom, XPathConstants.NODESET);
+						NodeList styleNodes = (NodeList) xpath.evaluate("//*[@*='" + styleName + "']", contentDom,
+								XPathConstants.NODESET);
 						int styleCnt = styleNodes.getLength();
 						if (styleCnt > 1) {
 							// the first styleName is occurred in the style
@@ -2469,7 +2394,7 @@ public abstract class Document extends O
 	public TableBuilder getTableBuilder() {
 		return getTableContainerImpl().getTableBuilder();
 	}
-
+	
 	protected TableContainer getTableContainerImpl() {
 		if (tableContainerImpl == null) {
 			tableContainerImpl = new TableContainerImpl();

Modified: incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/TextDocument.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/TextDocument.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/TextDocument.java (original)
+++ incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/TextDocument.java Sun Aug 19 15:01:09 2012
@@ -25,11 +25,7 @@ import java.awt.Rectangle;
 import java.io.File;
 import java.io.InputStream;
 import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -45,24 +41,11 @@ import org.odftoolkit.odfdom.dom.element
 import org.odftoolkit.odfdom.dom.element.style.StyleHeaderElement;
 import org.odftoolkit.odfdom.dom.element.style.StyleMasterPageElement;
 import org.odftoolkit.odfdom.dom.element.style.StylePageLayoutPropertiesElement;
-import org.odftoolkit.odfdom.dom.element.text.TextIndexBodyElement;
-import org.odftoolkit.odfdom.dom.element.text.TextIndexEntryLinkStartElement;
-import org.odftoolkit.odfdom.dom.element.text.TextIndexEntryTabStopElement;
-import org.odftoolkit.odfdom.dom.element.text.TextIndexSourceStylesElement;
-import org.odftoolkit.odfdom.dom.element.text.TextIndexTitleElement;
-import org.odftoolkit.odfdom.dom.element.text.TextIndexTitleTemplateElement;
 import org.odftoolkit.odfdom.dom.element.text.TextPElement;
-import org.odftoolkit.odfdom.dom.element.text.TextParagraphElementBase;
 import org.odftoolkit.odfdom.dom.element.text.TextSectionElement;
-import org.odftoolkit.odfdom.dom.element.text.TextTableOfContentElement;
-import org.odftoolkit.odfdom.dom.element.text.TextTableOfContentEntryTemplateElement;
-import org.odftoolkit.odfdom.dom.element.text.TextTableOfContentSourceElement;
-import org.odftoolkit.odfdom.dom.element.text.TextTocMarkElement;
-import org.odftoolkit.odfdom.dom.element.text.TextTocMarkStartElement;
 import org.odftoolkit.odfdom.dom.style.OdfStyleFamily;
 import org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeAutomaticStyles;
 import org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeMasterStyles;
-import org.odftoolkit.odfdom.incubator.doc.office.OdfOfficeStyles;
 import org.odftoolkit.odfdom.incubator.doc.style.OdfStyle;
 import org.odftoolkit.odfdom.incubator.doc.style.OdfStylePageLayout;
 import org.odftoolkit.odfdom.incubator.doc.text.OdfTextParagraph;
@@ -79,7 +62,6 @@ import org.odftoolkit.simple.common.fiel
 import org.odftoolkit.simple.common.field.VariableContainer;
 import org.odftoolkit.simple.common.field.VariableField;
 import org.odftoolkit.simple.common.field.VariableField.VariableType;
-import org.odftoolkit.simple.style.TOCStyle;
 import org.odftoolkit.simple.text.AbstractParagraphContainer;
 import org.odftoolkit.simple.text.Footer;
 import org.odftoolkit.simple.text.Header;
@@ -92,7 +74,6 @@ import org.odftoolkit.simple.text.list.L
 import org.odftoolkit.simple.text.list.ListDecorator;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
 
 /**
  * This class represents an empty ODF text document.
@@ -878,342 +859,4 @@ public class TextDocument extends Docume
 			return drawFrame;
 		}
 	}
-
-	/**
-	 * Create a new Table Of Content to this document before the reference
-	 * paragraph. Because until you do a full layout of the document, taking
-	 * into account font metrics,line breaking algorithms, hyphenation, image
-	 * positioning, "orphan and widow" rules, etc., you don't know what content
-	 * is on which page. So all the page numbers in TOC are be set value "1".
-	 * Please update the page numbers from AOO Menus: Tools->Update->All Indexes
-	 * and Tables
-	 * 
-	 * @param refParagraph
-	 *            the reference paragraph where the TOC be inserted.
-	 * @param before
-	 *            true:insert TOC before the reference paragraph. false:insert
-	 *            TOC after the reference paragraph.
-	 * @since 0.8.6
-	 */
-	public TextTableOfContentElement createDefaultTOC(Paragraph refParagraph, boolean before) {
-		
-		TextTableOfContentElement textTableOfContent =null;
-		if(refParagraph==null){
-			Logger.getLogger(TextDocument.class.getName()).log(Level.SEVERE,
-					"Failed to create Default TOC, The refParagraph where the TOC be inserted is null");
-			throw new RuntimeException("Failed to create Default TOC, The refParagraph where the TOC be inserted is null");
-		}
-		Node refparagraphNode = refParagraph.getOdfElement();
-		Node rootNode = refparagraphNode.getParentNode();		
-		try {
-			OdfContentDom content = getContentDom();
-			textTableOfContent = content
-					.newOdfElement(TextTableOfContentElement.class);
-			textTableOfContent.setTextNameAttribute("Table of Contents");
-			textTableOfContent.setTextProtectedAttribute(true);
-			TextTableOfContentSourceElement textTableOfContentSource = textTableOfContent
-					.newTextTableOfContentSourceElement();
-			textTableOfContentSource.setTextOutlineLevelAttribute(10);
-			textTableOfContentSource.setTextUseIndexMarksAttribute(true);
-			TextIndexTitleTemplateElement textIndexTitleTemplate = textTableOfContentSource
-					.newTextIndexTitleTemplateElement();
-			textIndexTitleTemplate
-					.setTextStyleNameAttribute("Contents_20_Heading");
-			textIndexTitleTemplate.setTextContent("Table of Contents");
-			for (int i = 1; i <= 10; i++) {
-				TextTableOfContentEntryTemplateElement textTableOfContentEntryTemplate = textTableOfContentSource
-						.newTextTableOfContentEntryTemplateElement(i,
-								"Contents_20_" + i);
-				TextIndexEntryLinkStartElement TextIndexEntryLinkStart = textTableOfContentEntryTemplate
-						.newTextIndexEntryLinkStartElement();
-				TextIndexEntryLinkStart
-						.setTextStyleNameAttribute("Index_20_Link");
-				textTableOfContentEntryTemplate
-						.newTextIndexEntryChapterElement();
-				textTableOfContentEntryTemplate.newTextIndexEntryTextElement();
-				TextIndexEntryTabStopElement TextIndexEntryTabStop = textTableOfContentEntryTemplate
-						.newTextIndexEntryTabStopElement("right");
-				TextIndexEntryTabStop.setStyleLeaderCharAttribute(".");
-				textTableOfContentEntryTemplate
-						.newTextIndexEntryPageNumberElement();
-				textTableOfContentEntryTemplate
-						.newTextIndexEntryLinkEndElement();
-			}
-			TextIndexBodyElement textIndexBody = textTableOfContent
-					.newTextIndexBodyElement();
-			TextIndexTitleElement TextIndexTitle = textIndexBody
-					.newTextIndexTitleElement("Table of Contents_Head");
-			TextPElement texp = TextIndexTitle.newTextPElement();
-			texp.setTextStyleNameAttribute("Contents_20_Heading");
-			texp.setTextContent("Table of Contents");
-			Iterator<Paragraph> paragraphIterator = getParagraphIterator();
-			while (paragraphIterator.hasNext()) {
-				Paragraph paragraph = paragraphIterator.next();
-				String text = paragraph.getTextContent();
-				String stylename = paragraph.getStyleName();
-				// Outline support
-				if (paragraph.isHeading()) {
-					int headingLevel = paragraph.getHeadingLevel();
-					if (stylename.length() <= 0) {
-						stylename = "Contents_20_" + headingLevel;
-					}
-					ceateIndexBodyEntry(textIndexBody, stylename, text);
-				}
-				// end of Outline support
-				// Index Makes support
-				TextParagraphElementBase podf = paragraph.getOdfElement();
-				NodeList cns = podf.getChildNodes();
-				for (int i = 0; i < cns.getLength(); i++) {
-					Node node = cns.item(i);
-					if (node instanceof TextTocMarkElement) {
-						TextTocMarkElement textTocMarkElement = (TextTocMarkElement) node;
-						text = textTocMarkElement.getTextStringValueAttribute();
-						int headingLevel = textTocMarkElement
-								.getTextOutlineLevelAttribute();
-						stylename = "Contents_20_" + headingLevel;
-						ceateIndexBodyEntry(textIndexBody, stylename, text);
-					}
-					if (node instanceof TextTocMarkStartElement) {
-						TextTocMarkStartElement textTocMarkStartElement = (TextTocMarkStartElement) node;
-						Node tmp = node.getNextSibling();
-						while (!(tmp instanceof Text)) {
-							tmp = node.getNextSibling();
-						}
-						text = tmp.getTextContent();
-						int headingLevel = textTocMarkStartElement
-								.getTextOutlineLevelAttribute();
-						stylename = "Contents_20_" + headingLevel;
-						ceateIndexBodyEntry(textIndexBody, stylename, text);
-					}
-				}
-				// end of Index Makes support
-			}
-			if (before) {
-				rootNode.insertBefore(textTableOfContent, refparagraphNode);
-			} else {
-				// Insert TOC after the refParagraph
-				Node refNextNode = refparagraphNode.getNextSibling();
-				if (refNextNode == null) {
-					rootNode.appendChild(textTableOfContent);
-				} else {
-					rootNode.insertBefore(textTableOfContent, refNextNode);
-				}
-			}
-			return textTableOfContent;
-		} catch (Exception e) {
-			Logger.getLogger(TextDocument.class.getName()).log(Level.SEVERE,
-					"Failed to create Default TOC", e);
-			throw new RuntimeException("Failed to create Default TOC", e);
-		}
-	}
-
-	private void ceateIndexBodyEntry(TextIndexBodyElement textIndexBody,
-			String stylename, String text) {
-		TextPElement textp = textIndexBody.newTextPElement();
-		textp.setTextStyleNameAttribute(stylename);
-		textp.newTextNode(text);
-		textp.newTextTabElement();
-		textp.newTextNode("1");
-	}
-
-	/**
-	 * Create a new Table Of Content to this document before the reference
-	 * paragraph. The additional paragraph styles list will be included in the
-	 * TOC. Because until you do a full layout of the document, taking into
-	 * account font metrics,line breaking algorithms, hyphenation, image
-	 * positioning, "orphan and widow" rules, etc., you don't know what content
-	 * is on which page. So all the page numbers in TOC are be set value "1".
-	 * Please update the page numbers from AOO Menus: Tools->Update->All Indexes
-	 * and Tables.  If additionalStyle is null then call createDefaultTOC().
-	 * 
-	 * @param refParagraph
-	 *            the reference paragraph before where the TOC inserted.
-	 * @param additionalStyle
-	 *            the additional paragraph styles that you want to include in
-	 *            the TOC
-	 * @param before
-	 *            true:insert TOC before the reference paragraph. 
-	 *            false:insert TOC after the reference paragraph.
-	 * @since 0.8.6
-	 */
-	public TextTableOfContentElement createTOCwithStyle(Paragraph refParagraph,
-			TOCStyle additionalStyle, boolean before) {
-		if(refParagraph==null){
-			Logger.getLogger(TextDocument.class.getName()).log(Level.SEVERE,
-					"Failed to create Default TOC, The refParagraph where the TOC be inserted is null");
-			throw new RuntimeException("Failed to create Default TOC, The refParagraph where the TOC be inserted is null");
-		}
-		if (additionalStyle == null) {
-			TextTableOfContentElement textTableOfContentElement = createDefaultTOC(refParagraph, before);
-			return textTableOfContentElement;
-		}
-		HashMap<Integer, String> tocstyleList = additionalStyle.getStyle();
-		if (tocstyleList.isEmpty()) {
-			TextTableOfContentElement textTableOfContentElement =createDefaultTOC(refParagraph, before);
-			return textTableOfContentElement;
-		}
-
-		Collection<String> tocvalues = tocstyleList.values();
-		OdfOfficeStyles docstyles = getOrCreateDocumentStyles();
-		Iterable<OdfStyle> paragraphStyles = docstyles
-				.getStylesForFamily(OdfStyleFamily.Paragraph);
-		ArrayList<String> pstyle = new ArrayList<String>();
-		Iterator<OdfStyle> iterator = paragraphStyles.iterator();
-		while (iterator.hasNext()) {
-			OdfStyle style = iterator.next();
-			String name = style.getStyleNameAttribute();
-			pstyle.add(name);
-		}
-		if (!pstyle.containsAll(tocvalues)) {
-			Logger.getLogger(TextDocument.class.getName())
-					.log(Level.SEVERE,
-							"Failed to create TOC with Styles. Some of addtional Styles that you want to include in the TOC can't be found in the document.\n"
-									+ tocvalues.toString());
-			throw new RuntimeException(
-					"Failed to create TOC Styles.Some of addtional Styles that you want to include in the TOC can't be found in the document.");
-		}
-		TextTableOfContentElement textTableOfContent =null;
-		// Additional Styles support
-		HashMap<String, Integer> tmptocstyleList = new HashMap<String, Integer>();
-		if (!tocstyleList.isEmpty()) {
-			Set<Integer> key = tocstyleList.keySet();
-			Iterator<Integer> it = key.iterator();
-			while (it.hasNext()) {
-				Integer textOutlineLevelValue = it.next();
-				String textStyleNameValue = tocstyleList
-						.get(textOutlineLevelValue);
-				tmptocstyleList.put(textStyleNameValue, textOutlineLevelValue);
-			}
-		}
-		// end of Additional Styles support
-
-		Node refparagraphNode = refParagraph.getOdfElement();
-		Node rootNode = refparagraphNode.getParentNode();
-		try {
-			OdfContentDom content = getContentDom();
-			textTableOfContent = content
-					.newOdfElement(TextTableOfContentElement.class);
-			textTableOfContent.setTextNameAttribute("Table of Contents");
-			textTableOfContent.setTextProtectedAttribute(true);
-
-			TextTableOfContentSourceElement textTableOfContentSource = textTableOfContent
-					.newTextTableOfContentSourceElement();
-			textTableOfContentSource.setTextOutlineLevelAttribute(10);
-			textTableOfContentSource.setTextUseIndexMarksAttribute(true);
-			textTableOfContentSource.setTextUseIndexSourceStylesAttribute(true);
-			TextIndexTitleTemplateElement textIndexTitleTemplate = textTableOfContentSource
-					.newTextIndexTitleTemplateElement();
-			textIndexTitleTemplate
-					.setTextStyleNameAttribute("Contents_20_Heading");
-			textIndexTitleTemplate.setTextContent("Table of Contents");
-			for (int i = 1; i <= 10; i++) {
-				TextTableOfContentEntryTemplateElement textTableOfContentEntryTemplate = textTableOfContentSource
-						.newTextTableOfContentEntryTemplateElement(i,
-								"Contents_20_" + i);
-				TextIndexEntryLinkStartElement TextIndexEntryLinkStart = textTableOfContentEntryTemplate
-						.newTextIndexEntryLinkStartElement();
-				TextIndexEntryLinkStart
-						.setTextStyleNameAttribute("Index_20_Link");
-				textTableOfContentEntryTemplate
-						.newTextIndexEntryChapterElement();
-				textTableOfContentEntryTemplate.newTextIndexEntryTextElement();
-				TextIndexEntryTabStopElement TextIndexEntryTabStop = textTableOfContentEntryTemplate
-						.newTextIndexEntryTabStopElement("right");
-				TextIndexEntryTabStop.setStyleLeaderCharAttribute(".");
-				textTableOfContentEntryTemplate
-						.newTextIndexEntryPageNumberElement();
-				textTableOfContentEntryTemplate
-						.newTextIndexEntryLinkEndElement();
-			}
-
-			if (!tocstyleList.isEmpty()) {
-				Set<Integer> key = tocstyleList.keySet();
-				Iterator<Integer> it = key.iterator();
-				while (it.hasNext()) {
-					Integer textOutlineLevelValue = it.next();
-					String textStyleNameValue = tocstyleList
-							.get(textOutlineLevelValue);
-					TextIndexSourceStylesElement textIndexSourceStyles = textTableOfContentSource
-							.newTextIndexSourceStylesElement(textOutlineLevelValue);
-					textIndexSourceStyles
-							.newTextIndexSourceStyleElement(textStyleNameValue);
-				}
-			}
-
-			TextIndexBodyElement textIndexBody = textTableOfContent
-					.newTextIndexBodyElement();
-			TextIndexTitleElement TextIndexTitle = textIndexBody
-					.newTextIndexTitleElement("Table of Contents_Head");
-			TextPElement texp = TextIndexTitle.newTextPElement();
-			texp.setTextStyleNameAttribute("Contents_20_Heading");
-			texp.setTextContent("Table of Contents");
-			Iterator<Paragraph> paragraphIterator = getParagraphIterator();
-			while (paragraphIterator.hasNext()) {
-				Paragraph paragraph = paragraphIterator.next();
-				String text = paragraph.getTextContent();
-				String stylename = paragraph.getStyleName();
-				// Outline support
-				if (paragraph.isHeading()) {
-					int headingLevel = paragraph.getHeadingLevel();
-					if (stylename.length() <= 0) {
-						stylename = "Contents_20_" + headingLevel;
-					}
-					ceateIndexBodyEntry(textIndexBody, stylename, text);
-				}
-				// end of Outline support
-				// Additional Styles support
-				if (tmptocstyleList.containsKey(stylename)) {
-					int headingLevel = tmptocstyleList.get(stylename);
-					stylename = "Contents_20_" + headingLevel;
-					ceateIndexBodyEntry(textIndexBody, stylename, text);
-				}
-				// end of Additional Styles support
-				// Index Makes support
-				TextParagraphElementBase podf = paragraph.getOdfElement();
-				NodeList cns = podf.getChildNodes();
-				for (int i = 0; i < cns.getLength(); i++) {
-					Node node = cns.item(i);
-					if (node instanceof TextTocMarkElement) {
-						TextTocMarkElement textTocMarkElement = (TextTocMarkElement) node;
-						text = textTocMarkElement.getTextStringValueAttribute();
-						int headingLevel = textTocMarkElement
-								.getTextOutlineLevelAttribute();
-						stylename = "Contents_20_" + headingLevel;
-						ceateIndexBodyEntry(textIndexBody, stylename, text);
-					}
-					if (node instanceof TextTocMarkStartElement) {
-						TextTocMarkStartElement textTocMarkStartElement = (TextTocMarkStartElement) node;
-						Node tmp = node.getNextSibling();
-						while (!(tmp instanceof Text)) {
-							tmp = node.getNextSibling();
-						}
-						text = tmp.getTextContent();
-						int headingLevel = textTocMarkStartElement
-								.getTextOutlineLevelAttribute();
-						stylename = "Contents_20_" + headingLevel;
-						ceateIndexBodyEntry(textIndexBody, stylename, text);
-					}
-				}
-				// end of Index Makes support
-			}
-			if (before) {
-				rootNode.insertBefore(textTableOfContent, refparagraphNode);
-			} else {
-				// Insert TOC after the refParagraph
-				Node refNextNode = refparagraphNode.getNextSibling();
-				if (refNextNode == null) {
-					rootNode.appendChild(textTableOfContent);
-				} else {
-					rootNode.insertBefore(textTableOfContent, refNextNode);
-				}
-			}
-			return textTableOfContent;
-			
-		} catch (Exception e) {
-			Logger.getLogger(TextDocument.class.getName()).log(Level.SEVERE,
-					"Failed to create Default TOC", e);
-			throw new RuntimeException("Failed to create Default TOC", e);
-		}
-	}
-	
 }

Modified: incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/list/AbstractListContainer.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/list/AbstractListContainer.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/list/AbstractListContainer.java (original)
+++ incubator/odf/trunk/simple/src/main/java/org/odftoolkit/simple/text/list/AbstractListContainer.java Sun Aug 19 15:01:09 2012
@@ -20,15 +20,12 @@ under the License.
 package org.odftoolkit.simple.text.list;
 
 import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.NoSuchElementException;
 
 import org.odftoolkit.odfdom.dom.element.text.TextListElement;
 import org.odftoolkit.odfdom.pkg.OdfElement;
 import org.odftoolkit.odfdom.pkg.OdfFileDom;
 import org.odftoolkit.simple.Document;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 /**
  * AbstractListContainer is an abstract implementation of the ListContainer
@@ -89,62 +86,57 @@ public abstract class AbstractListContai
 	}
 
 	// default iterator to iterate list item.
-	private static class SimpleListIterator implements Iterator<List> {
-		
-		private java.util.List<List> allLists;
-		private int index;
-		private List currentList;
-		
-		public SimpleListIterator(ListContainer container) {
-			this.allLists = getLists(container.getListContainerElement().getChildNodes());
+	private class SimpleListIterator implements Iterator<List> {
+
+		private OdfElement containerElement;
+		private TextListElement nextListElement;
+		private TextListElement tempListElement;
+
+		private SimpleListIterator(ListContainer container) {
+			containerElement = container.getListContainerElement();
 		}
 
 		public boolean hasNext() {
-			return this.index < this.allLists.size();
+			tempListElement = findNext(nextListElement);
+			return (tempListElement != null);
 		}
 
 		public List next() {
-			if (hasNext()) {
-				this.currentList = allLists.get(index);
-				this.index++;
-				return this.currentList;
+			if (tempListElement != null) {
+				nextListElement = tempListElement;
+				tempListElement = null;
 			} else {
-				throw new NoSuchElementException();
+				nextListElement = findNext(nextListElement);
+			}
+			if (nextListElement == null) {
+				return null;
+			} else {
+				return new List(nextListElement);
 			}
 		}
 
 		public void remove() {
-			if (this.currentList == null) {
-				throw new IllegalStateException();
-			} else {
-				this.allLists.remove(this.currentList);
-				this.currentList = null;
+			if (nextListElement == null) {
+				throw new IllegalStateException("please call next() first.");
 			}
+			containerElement.removeChild(nextListElement);
 		}
-		
-		private java.util.List<List> getLists(NodeList nodes) {
-			java.util.List<List> lists = new LinkedList<List>();
-			int numberOfNodes = nodes.getLength();
-			for (int i = 0; i < numberOfNodes; i++) {
-				Node node = nodes.item(i);
-				lists.addAll(getLists(node));
-			}
-			return lists;
-		}
-		
-		private java.util.List<List> getLists(Node node) {
-			java.util.List<List> lists = new LinkedList<List>();
-			if (node instanceof TextListElement) {
-				TextListElement textListElement = (TextListElement) node;
-				List list = new List(textListElement);
-				lists.add(list);
+
+		private TextListElement findNext(TextListElement nextListElement) {
+			Node child = null;
+			if (nextListElement == null) {
+				child = containerElement.getFirstChild();
 			} else {
-				NodeList childNodes = node.getChildNodes();
-				lists.addAll(getLists(childNodes));
+				child = nextListElement.getNextSibling();
+			}
+
+			while (child != null) {
+				if (child instanceof TextListElement) {
+					return (TextListElement) child;
+				}
+				child = child.getNextSibling();
 			}
-			return lists;
+			return null;
 		}
-		
 	}
-	
 }

Modified: incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/DocumentTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/DocumentTest.java?rev=1374762&r1=1374761&r2=1374762&view=diff
==============================================================================
--- incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/DocumentTest.java (original)
+++ incubator/odf/trunk/simple/src/test/java/org/odftoolkit/simple/DocumentTest.java Sun Aug 19 15:01:09 2012
@@ -377,41 +377,6 @@ public class DocumentTest {
 			Assert.fail(e.getMessage());
 		}
 	}
-	
-	@Test
-	public void testDocumentPassword() {
-		File passwordOutputFile = ResourceUtilities.newTestOutputFile("PasswordDocument.odt");
-		File noPassOutputFile = ResourceUtilities.newTestOutputFile("NoPasswordDocument.odt");
-		try {
-			TextDocument doc = TextDocument.newTextDocument();
-			doc.addParagraph("blablabla...");
-			doc.setPassword("password");
-			doc.save(passwordOutputFile);
-			
-			Document redoc = Document.loadDocument(passwordOutputFile, "password");
-			//test load content.xml
-			Assert.assertNotNull(redoc.getContentRoot().toString());
-			//test load styles.xml
-			((TextDocument) redoc).getHeader().addTable();
-			//test load meta.xml
-			Assert.assertNotNull(redoc.getOfficeMetadata().getCreator());
-			
-			//remove password
-			redoc.setPassword(null);
-			redoc.save(noPassOutputFile);
-			
-			//test inserted document
-			doc = TextDocument.newTextDocument();
-			doc.addParagraph("embed_document");
-			redoc.insertDocument(doc, "/embed");
-			redoc.setPassword("password");
-			
-			redoc.save(passwordOutputFile);
-		} catch (Exception ex) {
-			LOG.log(Level.SEVERE, "document password test failed.", ex);
-			Assert.fail();
-		}
-	}
 
 	@Test
 	public void testSetLocale() {



Mime
View raw message