*** empty log message ***
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353291 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2024ced65f
commit
6881971ed3
@ -32,9 +32,9 @@
|
|||||||
<strong>property set stream</strong>.</p>
|
<strong>property set stream</strong>.</p>
|
||||||
|
|
||||||
<p>This document describes the internal structure of a property set stream,
|
<p>This document describes the internal structure of a property set stream,
|
||||||
i.e. the <strong>Horrible Property Set Format (HWPF)</strong>. It does not
|
i.e. the <strong>Horrible Property Set Format (HPSF)</strong>. It does
|
||||||
describe how a Microsoft Office document is organized internally and how
|
not describe how a Microsoft Office document is organized internally and
|
||||||
to retrieve a stream from it. See the <link
|
how to retrieve a stream from it. See the <link
|
||||||
href="../poifs/index.html">POIFS documentation</link> for that kind of
|
href="../poifs/index.html">POIFS documentation</link> for that kind of
|
||||||
stuff.</p>
|
stuff.</p>
|
||||||
|
|
||||||
@ -172,9 +172,10 @@
|
|||||||
<td>Denotes the operating system and the OS version under which this
|
<td>Denotes the operating system and the OS version under which this
|
||||||
stream was created. The operating system ID is in the DWord's higher
|
stream was created. The operating system ID is in the DWord's higher
|
||||||
word (after little endian decoding): <code>0x0000</code> for Win16,
|
word (after little endian decoding): <code>0x0000</code> for Win16,
|
||||||
<code>0x0001</code> for Macintosh and <code>0x0002</code> for Win32 - that's
|
<code>0x0001</code> for Macintosh and <code>0x0002</code> for Win32 -
|
||||||
all. The reader is most likely aware of the fact that there are some
|
that's all. The reader is most likely aware of the fact that there are
|
||||||
more operating systems. However, Microsoft does not seem to know.</td>
|
some more operating systems. However, Microsoft does not seem to
|
||||||
|
know.</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
@ -69,6 +69,11 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.poi.hpsf.MarkUnsupportedException;
|
||||||
|
import org.apache.poi.hpsf.NoPropertySetStreamException;
|
||||||
|
import org.apache.poi.hpsf.PropertySet;
|
||||||
|
import org.apache.poi.hpsf.PropertySetFactory;
|
||||||
|
import org.apache.poi.hpsf.UnexpectedPropertySetTypeException;
|
||||||
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
import org.apache.poi.poifs.eventfilesystem.POIFSReader;
|
||||||
import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
|
import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
|
||||||
import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
|
import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
|
||||||
@ -177,11 +182,11 @@ public class Util
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
POIFile f = new POIFile();
|
final POIFile f = new POIFile();
|
||||||
f.setName(event.getName());
|
f.setName(event.getName());
|
||||||
f.setPath(event.getPath());
|
f.setPath(event.getPath());
|
||||||
InputStream in = event.getStream();
|
final InputStream in = event.getStream();
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
Util.copy(in, out);
|
Util.copy(in, out);
|
||||||
out.close();
|
out.close();
|
||||||
f.setBytes(out.toByteArray());
|
f.setBytes(out.toByteArray());
|
||||||
@ -213,6 +218,68 @@ public class Util
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Read all files from a POI filesystem which are property set streams
|
||||||
|
* and returns them as an array of {@link org.apache.poi.hpsf.PropertySet}
|
||||||
|
* instances.</p>
|
||||||
|
*
|
||||||
|
* @param poiFs The name of the POI filesystem as seen by the
|
||||||
|
* operating system. (This is the "filename".)
|
||||||
|
*
|
||||||
|
* @return The property sets. The elements are ordered in the same way
|
||||||
|
* as the files in the POI filesystem.
|
||||||
|
*
|
||||||
|
* @exception FileNotFoundException if the file containing the POI
|
||||||
|
* filesystem does not exist
|
||||||
|
*
|
||||||
|
* @exception IOException if an I/O exception occurs
|
||||||
|
*/
|
||||||
|
public static POIFile[] readPropertySets(final File poiFs)
|
||||||
|
throws FileNotFoundException, IOException
|
||||||
|
{
|
||||||
|
final List files = new ArrayList(7);
|
||||||
|
final POIFSReader r = new POIFSReader();
|
||||||
|
POIFSReaderListener pfl = new POIFSReaderListener()
|
||||||
|
{
|
||||||
|
public void processPOIFSReaderEvent(final POIFSReaderEvent event)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final POIFile f = new POIFile();
|
||||||
|
f.setName(event.getName());
|
||||||
|
f.setPath(event.getPath());
|
||||||
|
final InputStream in = event.getStream();
|
||||||
|
if (PropertySet.isPropertySetStream(in))
|
||||||
|
{
|
||||||
|
final ByteArrayOutputStream out =
|
||||||
|
new ByteArrayOutputStream();
|
||||||
|
Util.copy(in, out);
|
||||||
|
out.close();
|
||||||
|
f.setBytes(out.toByteArray());
|
||||||
|
files.add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
throw new RuntimeException(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Register the listener for all POI files. */
|
||||||
|
r.registerListener(pfl);
|
||||||
|
|
||||||
|
/* Read the POI filesystem. */
|
||||||
|
r.read(new FileInputStream(poiFs));
|
||||||
|
POIFile[] result = new POIFile[files.size()];
|
||||||
|
for (int i = 0; i < result.length; i++)
|
||||||
|
result[i] = (POIFile) files.get(i);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Prints the system properties to System.out.</p>
|
* <p>Prints the system properties to System.out.</p>
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user