Return-Path: Delivered-To: apmail-poi-commits-archive@locus.apache.org Received: (qmail 87617 invoked from network); 20 Aug 2008 18:15:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Aug 2008 18:15:02 -0000 Received: (qmail 30716 invoked by uid 500); 20 Aug 2008 18:15:01 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 30678 invoked by uid 500); 20 Aug 2008 18:15:01 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 30668 invoked by uid 99); 20 Aug 2008 18:15:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Aug 2008 11:15:01 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Aug 2008 18:14:12 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id EB453238896C; Wed, 20 Aug 2008 11:14:11 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@poi.apache.org From: nick@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080820181411.EB453238896C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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