poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r687403 - in /poi/trunk/src/scratchpad/src/org/apache/poi/hpbf: HPBFDocument.java model/ model/HPBFPart.java model/MainContents.java model/QuillContents.java
Date Wed, 20 Aug 2008 18:14:11 GMT
Author: nick
Date: Wed Aug 20 11:14:11 2008
New Revision: 687403

URL: http://svn.apache.org/viewvc?rev=687403&view=rev
Log:
Make an initial start on hpbf code

Added:
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java   (with props)
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java   (with props)
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java   (with props)
    poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java   (with props)

Added: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java?rev=687403&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java (added)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java Wed Aug 20 11:14:11
2008
@@ -0,0 +1,76 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+package org.apache.poi.hpbf;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.poi.POIDocument;
+import org.apache.poi.hpbf.model.MainContents;
+import org.apache.poi.hpbf.model.QuillContents;
+import org.apache.poi.poifs.filesystem.DirectoryNode;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+
+/**
+ * This class provides the basic functionality 
+ *  for HPBF, our implementation of the publisher
+ *  file format. 
+ */
+public class HPBFDocument extends POIDocument {
+	private MainContents mainContents;
+	private QuillContents quillContents;
+	
+	/**
+	 * Opens a new publisher document
+	 */
+	public HPBFDocument(POIFSFileSystem fs) throws IOException {
+		this(fs.getRoot(), fs);
+	}
+	
+	/**
+	 * Opens an embeded publisher document,
+	 *  at the given directory.
+	 */
+	public HPBFDocument(DirectoryNode dir, POIFSFileSystem fs) throws IOException {
+		super(dir, fs);
+		
+		// Go looking for our interesting child
+		//  streams
+		try {
+			mainContents = new MainContents(dir);
+		} catch(FileNotFoundException e) {
+			throw new IllegalArgumentException("File invalid - missing required main Contents part");
+		}
+		try {
+			quillContents = new QuillContents(dir);
+		} catch(FileNotFoundException e) {
+			throw new IllegalArgumentException("File invalid - missing required Quill CONTENTS part");
+		}
+	}
+
+	public MainContents getMainContents() {
+		return mainContents;
+	}
+	public QuillContents getQuillContents() {
+		return quillContents;
+	}
+
+	public void write(OutputStream out) throws IOException {
+		throw new IllegalStateException("Writing is not yet implemented, see http://poi.apache.org/hpbf/");
+	}
+}

Propchange: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/HPBFDocument.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java?rev=687403&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java (added)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java Wed Aug 20 11:14:11
2008
@@ -0,0 +1,68 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+package org.apache.poi.hpbf.model;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.poi.poifs.filesystem.DirectoryNode;
+import org.apache.poi.poifs.filesystem.DocumentEntry;
+
+/**
+ * Parent class of all HPBF sub-parts, handling
+ *  the fiddly reading in / writing out bits
+ *  for all of them.
+ */
+public abstract class HPBFPart {
+	protected byte[] data;
+	
+	public HPBFPart(DirectoryNode baseDir) throws FileNotFoundException, IOException {
+		String[] path = getPath(); 
+		DirectoryNode dir = getDir(path, baseDir);
+		String name = path[path.length-1];
+		
+		DocumentEntry docProps =
+			(DocumentEntry)dir.getEntry(name);
+
+		// Grab the data from the part stream
+		data = new byte[docProps.getSize()];
+		dir.createDocumentInputStream(name).read(data);
+	}
+	private DirectoryNode getDir(String[] path, DirectoryNode baseDir) throws FileNotFoundException
{
+		DirectoryNode dir = baseDir;
+		for(int i=0; i<path.length-1; i++) {
+			dir = (DirectoryNode)dir.getEntry(path[i]);
+		}
+		return dir;
+	}
+	
+	public void writeOut(DirectoryNode baseDir) throws IOException {
+		
+	}
+	
+	/**
+	 * Returns the raw data that makes up
+	 *  this document part.
+	 */
+	public byte[] getData() { return data; }
+
+	/**
+	 * Returns the path to the part, eg Contents
+	 *  or Quill, QuillSub, CONTENTS
+	 */
+	public abstract String[] getPath();
+}

Propchange: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/HPBFPart.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java?rev=687403&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java (added)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java Wed Aug 20 11:14:11
2008
@@ -0,0 +1,36 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+package org.apache.poi.hpbf.model;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.poi.poifs.filesystem.DirectoryNode;
+
+/**
+ * The main Contents. Not yet understood
+ */
+public class MainContents extends HPBFPart {
+	public MainContents(DirectoryNode baseDir)
+			throws FileNotFoundException, IOException {
+		super(baseDir);
+	}
+
+	public String[] getPath() {
+		return new String[] { "Contents" };
+	}
+}

Propchange: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/MainContents.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java?rev=687403&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java (added)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java Wed Aug 20 11:14:11
2008
@@ -0,0 +1,41 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+package org.apache.poi.hpbf.model;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.apache.poi.poifs.filesystem.DirectoryNode;
+
+/**
+ * Quill -> QuillSub -> CONTENTS
+ */
+public class QuillContents extends HPBFPart {
+	public QuillContents(DirectoryNode baseDir)
+			throws FileNotFoundException, IOException {
+		super(baseDir);
+		
+		// Now parse the first 512 bytes, and produce
+		//  all our bits
+	}
+
+	public String[] getPath() {
+		return new String[] {
+			"Quill", "QuillSub", "CONTENTS"
+		};
+	}
+}

Propchange: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/QuillContents.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message