mirror of https://github.com/apache/poi.git
Start shuffling things out of the old src/scratchpad/ooxml-* directories
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@635019 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b7ffac2c6d
commit
4eb4e8eeef
|
@ -80,4 +80,37 @@ public abstract class POIXMLDocument {
|
|||
}
|
||||
return part;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the supplied InputStream (which MUST
|
||||
* support mark and reset, or be a PushbackInputStream)
|
||||
* has a OOXML (zip) header at the start of it.
|
||||
* If your InputStream does not support mark / reset,
|
||||
* then wrap it in a PushBackInputStream, then be
|
||||
* sure to always use that, and not the original!
|
||||
* @param inp An InputStream which supports either mark/reset, or is a PushbackInputStream
|
||||
*/
|
||||
public static boolean hasOOXMLHeader(InputStream inp) throws IOException {
|
||||
// We want to peek at the first 4 bytes
|
||||
inp.mark(4);
|
||||
|
||||
byte[] header = new byte[4];
|
||||
IOUtils.readFully(inp, header);
|
||||
|
||||
// Wind back those 4 bytes
|
||||
if(inp instanceof PushbackInputStream) {
|
||||
PushbackInputStream pin = (PushbackInputStream)inp;
|
||||
pin.unread(header);
|
||||
} else {
|
||||
inp.reset();
|
||||
}
|
||||
|
||||
// Did it match the ooxml zip signature?
|
||||
return (
|
||||
header[0] == POIFSConstants.OOXML_FILE_HEADER[0] &&
|
||||
header[1] == POIFSConstants.OOXML_FILE_HEADER[1] &&
|
||||
header[2] == POIFSConstants.OOXML_FILE_HEADER[2] &&
|
||||
header[3] == POIFSConstants.OOXML_FILE_HEADER[3]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
package org.apache.poi.hxf.dev;
|
||||
package org.apache.poi.dev;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -29,18 +29,18 @@ import org.openxml4j.opc.PackageRelationship;
|
|||
import org.openxml4j.opc.PackageRelationshipCollection;
|
||||
|
||||
/**
|
||||
* Prints out the contents of a HXF (ooxml) container.
|
||||
* Prints out the contents of a OOXML container.
|
||||
* Useful for seeing what parts are defined, and how
|
||||
* they're all related to each other.
|
||||
*/
|
||||
public class HXFLister {
|
||||
public class OOXMLLister {
|
||||
private Package container;
|
||||
private PrintStream disp;
|
||||
|
||||
public HXFLister(Package container) {
|
||||
public OOXMLLister(Package container) {
|
||||
this(container, System.out);
|
||||
}
|
||||
public HXFLister(Package container, PrintStream disp) {
|
||||
public OOXMLLister(Package container, PrintStream disp) {
|
||||
this.container = container;
|
||||
this.disp = disp;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class HXFLister {
|
|||
System.exit(2);
|
||||
}
|
||||
|
||||
HXFLister lister = new HXFLister(
|
||||
OOXMLLister lister = new OOXMLLister(
|
||||
Package.open(f.toString(), PackageAccess.READ)
|
||||
);
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/* ====================================================================
|
||||
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;
|
||||
|
||||
import org.apache.poi.hxf.HXFDocument;
|
||||
|
||||
/**
|
||||
* Parent class of all UserModel POI XML (ooxml)
|
||||
* implementations.
|
||||
* Provides a similar function to {@link POIDocument},
|
||||
* for the XML based classes.
|
||||
*/
|
||||
public abstract class POIXMLDocument {
|
||||
private HXFDocument document;
|
||||
|
||||
/**
|
||||
* Creates a new POI XML Document, wrapping up
|
||||
* the underlying raw HXFDocument
|
||||
*/
|
||||
protected POIXMLDocument(HXFDocument document) {
|
||||
this.document = document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying HXFDocument, typically
|
||||
* used for unit testing
|
||||
*/
|
||||
public HXFDocument _getHXFDocument() {
|
||||
return document;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue