本文整理汇总了Java中org.apache.poi.poifs.common.POIFSConstants类的典型用法代码示例。如果您正苦于以下问题:Java POIFSConstants类的具体用法?Java POIFSConstants怎么用?Java POIFSConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
POIFSConstants类属于org.apache.poi.poifs.common包,在下文中一共展示了POIFSConstants类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getBlockOffset
点赞 3
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
@Override
public int getBlockOffset(int miniBlock) {
// we want to read mini block with index = miniBlock
// first we need to figure out which DIFAT block the mini block is in
int byteOffset = miniBlock * POIFSConstants.SMALL_BLOCK_SIZE; // offset from beginning of SBAT
int difatBlockNumber = byteOffset / difats.getBlockSize();
int offsetInDifatBlock = byteOffset % difats.getBlockSize();
// Now locate the data block for it, starting from the 1st block of the mini-FAT
int nextBlock = root.getStartBlock(); // first sector in mini-FAT chain
int idx = 0;
while (nextBlock != POIFSConstants.END_OF_CHAIN && idx < difatBlockNumber) {
nextBlock = difats.getNextBlock(nextBlock); // get next block in the chain
idx++;
}
Preconditions.checkState(idx == difatBlockNumber, "DIFAT block " + difatBlockNumber + " outside stream chain");
int difatBlockOffset = difats.getBlockOffset(nextBlock);
return difatBlockOffset + offsetInDifatBlock;
}
开发者ID:dremio,
项目名称:dremio-oss,
代码行数:24,
代码来源:MiniStore.java
示例2: BlockStoreInputStream
点赞 3
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
BlockStoreInputStream(final XlsInputStream inputStream, final BlockStore blockStore, final int startBlock) {
this.inputStream = Preconditions.checkNotNull(inputStream, "input stream should not be null");
this.blockStore = Preconditions.checkNotNull(blockStore, "block store should not be null");
nextBlock = startBlock;
blockSize = blockStore.getBlockSize();
Preconditions.checkState(startBlock != POIFSConstants.END_OF_CHAIN, "startBlock cannot be END_OF_CHAIN");
// count number of blocks that are part of the stream chain
remainingBlocks = 0;
int block = nextBlock;
while (block != POIFSConstants.END_OF_CHAIN) {
remainingBlocks++;
block = blockStore.getNextBlock(block);
}
// move to the beginning of the first block in the chain
inputStream.seek(blockStore.getBlockOffset(nextBlock));
}
开发者ID:dremio,
项目名称:dremio-oss,
代码行数:20,
代码来源:BlockStoreInputStream.java
示例3: PropertyTable
点赞 3
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
public PropertyTable(final XlsInputStream is, HeaderBlock header, BlockStore blockStore) {
this.is = is;
this.sectorSize = header.getBigBlockSize().getBigBlockSize();
// Directory sectors are stored as a chain starting from sector # header.propertyStart
// and FAT table contains link to next sector in the chain
int nextBlock = header.getPropertyStart(); // first sector in directory chain
while (nextBlock != POIFSConstants.END_OF_CHAIN) {
int blockOffset = blockStore.getBlockOffset(nextBlock);
processSector(blockOffset);
nextBlock = blockStore.getNextBlock(nextBlock); // get next block in the chain
}
populatePropertyTree((DirectoryProperty) properties.get(0));
}
开发者ID:dremio,
项目名称:dremio-oss,
代码行数:18,
代码来源:PropertyTable.java
示例4: OldPAPBinTable
点赞 3
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
public OldPAPBinTable(byte[] documentStream, int offset,
int size, int fcMin, TextPieceTable tpt)
{
PlexOfCps binTable = new PlexOfCps(documentStream, offset, size, 2);
int length = binTable.length();
for (int x = 0; x < length; x++)
{
GenericPropertyNode node = binTable.getProperty(x);
int pageNum = LittleEndian.getUShort(node.getBytes());
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
PAPFormattedDiskPage pfkp = new PAPFormattedDiskPage(documentStream,
documentStream, pageOffset, tpt);
for ( PAPX papx : pfkp.getPAPXs() )
{
if ( papx != null )
_paragraphs.add( papx );
}
}
}
开发者ID:rmage,
项目名称:gnvc-ims,
代码行数:24,
代码来源:OldPAPBinTable.java
示例5: OldCHPBinTable
点赞 3
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
/**
* Constructor used to read an old-style binTable
* in from a Word document.
*
* @param documentStream
* @param offset
* @param size
* @param fcMin
*/
public OldCHPBinTable(byte[] documentStream, int offset,
int size, int fcMin, TextPieceTable tpt)
{
PlexOfCps binTable = new PlexOfCps(documentStream, offset, size, 2);
int length = binTable.length();
for (int x = 0; x < length; x++)
{
GenericPropertyNode node = binTable.getProperty(x);
int pageNum = LittleEndian.getUShort(node.getBytes());
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
pageOffset, tpt);
for ( CHPX chpx : cfkp.getCHPXs() )
{
if ( chpx != null )
_textRuns.add( chpx );
}
}
Collections.sort( _textRuns, PropertyNode.StartComparator.instance );
}
开发者ID:rmage,
项目名称:gnvc-ims,
代码行数:34,
代码来源:OldCHPBinTable.java
示例6: Word6CHPBinTable
点赞 3
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
/**
* Constructor used to read a binTable in from a Word document.
*
* @param documentStream
* The POIFS "WordDocument" stream from a Word document
* @param offset
* The offset of the Chp bin table in the main stream.
* @param size
* The size of the Chp bin table in the main stream.
* @param fcMin
* The start of text in the main stream.
*/
public Word6CHPBinTable(byte[] documentStream, int offset, int size,
int fcMin) throws UnsupportedEncodingException {
PlexOfCps binTable = new PlexOfCps(documentStream, offset, size, 2);
int length = binTable.length();
for (int x = 0; x < length; x++) {
GenericPropertyNode node = binTable.getProperty(x);
int pageNum = LittleEndian.getShort((byte[]) node.getBytes());
int pageOffset = POIFSConstants.LARGER_BIG_BLOCK_SIZE * pageNum;
byte[] tableStream = null ;
int size1 = 0 ;
TextPieceTable tpttemp = new TextPieceTable(documentStream,tableStream, pageOffset,size1, fcMin);
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(
documentStream, pageOffset, fcMin,tpttemp);
int fkpSize = cfkp.size();
for (int y = 0; y < fkpSize; y++) {
_textRuns.add(cfkp.getCHPX(y));
}
}
}
开发者ID:mobilipia,
项目名称:Deskera-HRMS,
代码行数:36,
代码来源:Word6CHPBinTable.java
示例7: Word6CHPBinTable
点赞 3
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
/**
* Constructor used to read a binTable in from a Word document.
*
* @param documentStream
* The POIFS "WordDocument" stream from a Word document
* @param offset
* The offset of the Chp bin table in the main stream.
* @param size
* The size of the Chp bin table in the main stream.
* @param fcMin
* The start of text in the main stream.
*/
public Word6CHPBinTable(byte[] documentStream, int offset, int size,
int fcMin) throws UnsupportedEncodingException {
PlexOfCps binTable = new PlexOfCps(documentStream, offset, size, 2);
int length = binTable.length();
for (int x = 0; x < length; x++) {
GenericPropertyNode node = binTable.getProperty(x);
int pageNum = LittleEndian.getShort((byte[]) node.getBytes());
int pageOffset = POIFSConstants.LARGER_BIG_BLOCK_SIZE * pageNum;
byte[] tableStream = null ;
int size1 = 0 ;
TextPieceTable tpttemp = new TextPieceTable(documentStream,tableStream, pageOffset,size1, fcMin);
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(
documentStream, pageOffset, fcMin,tpttemp);
int fkpSize = cfkp.size();
for (int y = 0; y < fkpSize; y++) {
_textRuns.add(cfkp.getCHPX(y));
}
}
}
开发者ID:mobilipia,
项目名称:Deskera-HRMS,
代码行数:36,
代码来源:Word6CHPBinTable.java
示例8: parse
点赞 2
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
public void parse(InputStream stream,
ContentHandler handler, Metadata metadata,
ParseContext parseContext) throws IOException, SAXException,
TikaException
{
byte[] initial4 = new byte[4];
InputStream wrapped;
// Preserve TikaInputStreams as TikaInputStreams as they require less memory to process
if (stream.markSupported())
{
stream.mark(initial4.length);
IOUtils.readFully(stream, initial4);
stream.reset();
wrapped = stream;
}
else
{
PushbackInputStream inp = new PushbackInputStream(stream, 4);
IOUtils.readFully(inp, initial4);
inp.unread(initial4);
wrapped = inp;
}
// Which is it?
if(initial4[0] == POIFSConstants.OOXML_FILE_HEADER[0] &&
initial4[1] == POIFSConstants.OOXML_FILE_HEADER[1] &&
initial4[2] == POIFSConstants.OOXML_FILE_HEADER[2] &&
initial4[3] == POIFSConstants.OOXML_FILE_HEADER[3])
{
ooxmlParser.parse(wrapped, handler, metadata, parseContext);
}
else
{
ole2Parser.parse(wrapped, handler, metadata, parseContext);
}
}
开发者ID:Alfresco,
项目名称:alfresco-repository,
代码行数:37,
代码来源:TikaOfficeDetectParser.java
示例9: MiniStore
点赞 2
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
public MiniStore(final XlsInputStream is, DirectoryProperty root, HeaderBlock header, BlockStore difats) {
super(is, header, POIFSConstants.SMALL_BLOCK_SIZE);
this.root = root;
this.difats = difats;
// load all mini-FAT blocks
int nextAt = header.getSBATStart();
for(int i = 0; i < header.getSBATCount() && nextAt != POIFSConstants.END_OF_CHAIN; i++) {
BATBlock sfat = BATBlock.createBATBlock(header.getBigBlockSize(), difats.getBlockBuffer(nextAt));
sfat.setOurBlockIndex(nextAt);
blocks.add(sfat);
nextAt = difats.getNextBlock(nextAt);
}
}
开发者ID:dremio,
项目名称:dremio-oss,
代码行数:15,
代码来源:MiniStore.java
示例10: processSector
点赞 2
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
private void processSector(int sectorOffset) {
final int property_count = sectorSize / POIFSConstants.PROPERTY_SIZE;
byte[] bytes = new byte[POIFSConstants.PROPERTY_SIZE];
int index = properties.size();
is.seek(sectorOffset);
for (int k = 0; k < property_count; k++, index++) {
try {
is.read(bytes, 0, bytes.length);
} catch (IOException e) {
// shouldn't be possible in a well formatted xls stream
throw new IllegalStateException("Couldn't read from stream");
}
switch (bytes[PropertyConstants.PROPERTY_TYPE_OFFSET ]) {
case PropertyConstants.DIRECTORY_TYPE :
case PropertyConstants.ROOT_TYPE :
properties.add(new DirectoryProperty(index, bytes));
break;
case PropertyConstants.DOCUMENT_TYPE :
properties.add(new DocumentProperty(index, bytes));
break;
default :
// add a null as we'll need to access properties by index later (or do we ?)
properties.add(null);
break;
}
}
}
开发者ID:dremio,
项目名称:dremio-oss,
代码行数:31,
代码来源:PropertyTable.java
示例11: createWorkbookInputStream
点赞 2
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
/**
* returns a {@link BlockStoreInputStream} that exposes all workbook sectors in their correct order
*
* @param is XLS InputStream
* @return {@link BlockStoreInputStream} that wraps the workbook's stream
*
* @throws IOException if the data doesn't contain a proper MS-CFB header
* @throws OldExcelFormatException if the file is too old to be supported
*/
static InputStream createWorkbookInputStream(final XlsInputStream is) throws IOException {
final XlsReader xlsReader = new XlsReader(is);
DocumentEntry workBookEntry = xlsReader.getWorkbookEntry();
DocumentNode workbookNode = (DocumentNode) workBookEntry;
// use proper blockStore
final boolean useMiniStore = workbookNode.getSize() < POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE;
final BlockStore blockStore = useMiniStore ? xlsReader.miniStore : xlsReader.difats;
return new BlockStoreInputStream(is, blockStore, workbookNode.getProperty().getStartBlock());
}
开发者ID:dremio,
项目名称:dremio-oss,
代码行数:21,
代码来源:XlsReader.java
示例12: writeTo
点赞 2
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
public byte[] writeTo( HWPFOutputStream docStream ) throws IOException
{
PlexOfCps textPlex = new PlexOfCps( PieceDescriptor.getSizeInBytes() );
// int fcMin = docStream.getOffset();
int size = _textPieces.size();
for ( int x = 0; x < size; x++ )
{
TextPiece next = _textPieces.get( x );
PieceDescriptor pd = next.getPieceDescriptor();
int offset = docStream.getOffset();
int mod = ( offset % POIFSConstants.SMALLER_BIG_BLOCK_SIZE );
if ( mod != 0 )
{
mod = POIFSConstants.SMALLER_BIG_BLOCK_SIZE - mod;
byte[] buf = new byte[mod];
docStream.write( buf );
}
// set the text piece position to the current docStream offset.
pd.setFilePosition( docStream.getOffset() );
// write the text to the docstream and save the piece descriptor to
// the
// plex which will be written later to the tableStream.
docStream.write( next.getRawBytes() );
// The TextPiece is already in characters, which
// makes our life much easier
int nodeStart = next.getStart();
int nodeEnd = next.getEnd();
textPlex.addProperty( new GenericPropertyNode( nodeStart, nodeEnd,
pd.toByteArray() ) );
}
return textPlex.toByteArray();
}
开发者ID:rmage,
项目名称:gnvc-ims,
代码行数:39,
代码来源:TextPieceTable.java
示例13: PAPBinTable
点赞 2
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
public PAPBinTable( byte[] documentStream, byte[] tableStream,
byte[] dataStream, int offset, int size,
CharIndexTranslator charIndexTranslator )
{
long start = System.currentTimeMillis();
{
PlexOfCps binTable = new PlexOfCps( tableStream, offset, size, 4 );
int length = binTable.length();
for ( int x = 0; x < length; x++ )
{
GenericPropertyNode node = binTable.getProperty( x );
int pageNum = LittleEndian.getInt( node.getBytes() );
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE
* pageNum;
PAPFormattedDiskPage pfkp = new PAPFormattedDiskPage(
documentStream, dataStream, pageOffset,
charIndexTranslator );
for ( PAPX papx : pfkp.getPAPXs() )
{
if ( papx != null )
_paragraphs.add( papx );
}
}
}
logger.log( POILogger.DEBUG, "PAPX tables loaded in ",
Long.valueOf( System.currentTimeMillis() - start ), " ms (",
Integer.valueOf( _paragraphs.size() ), " elements)" );
if ( _paragraphs.isEmpty() )
{
logger.log( POILogger.WARN, "PAPX FKPs are empty" );
_paragraphs.add( new PAPX( 0, 0, new SprmBuffer( 2 ) ) );
}
}
开发者ID:rmage,
项目名称:gnvc-ims,
代码行数:41,
代码来源:PAPBinTable.java
示例14: writeTo
点赞 2
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
public void writeTo( HWPFOutputStream wordDocumentStream,
HWPFOutputStream tableStream, CharIndexTranslator translator )
throws IOException
{
PlexOfCps binTable = new PlexOfCps(4);
// each FKP must start on a 512 byte page.
int docOffset = wordDocumentStream.getOffset();
int mod = docOffset % POIFSConstants.SMALLER_BIG_BLOCK_SIZE;
if (mod != 0)
{
byte[] padding = new byte[POIFSConstants.SMALLER_BIG_BLOCK_SIZE - mod];
wordDocumentStream.write(padding);
}
// get the page number for the first fkp
docOffset = wordDocumentStream.getOffset();
int pageNum = docOffset/POIFSConstants.SMALLER_BIG_BLOCK_SIZE;
// get the ending fc
// int endingFc = _paragraphs.get(_paragraphs.size() - 1).getEnd();
// endingFc += fcMin;
int endingFc = translator.getByteIndex( _paragraphs.get(
_paragraphs.size() - 1 ).getEnd() );
ArrayList<PAPX> overflow = _paragraphs;
do
{
PAPX startingProp = overflow.get(0);
// int start = startingProp.getStart() + fcMin;
int start = translator.getByteIndex( startingProp.getStart() );
PAPFormattedDiskPage pfkp = new PAPFormattedDiskPage();
pfkp.fill(overflow);
byte[] bufFkp = pfkp.toByteArray(tableStream, translator);
wordDocumentStream.write(bufFkp);
overflow = pfkp.getOverflow();
int end = endingFc;
if (overflow != null)
{
// end = overflow.get(0).getStart() + fcMin;
end = translator.getByteIndex( overflow.get( 0 ).getStart() );
}
byte[] intHolder = new byte[4];
LittleEndian.putInt(intHolder, pageNum++);
binTable.addProperty(new GenericPropertyNode(start, end, intHolder));
}
while (overflow != null);
tableStream.write(binTable.toByteArray());
}
开发者ID:rmage,
项目名称:gnvc-ims,
代码行数:57,
代码来源:PAPBinTable.java
示例15: CHPBinTable
点赞 2
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
/**
* Constructor used to read a binTable in from a Word document.
*/
public CHPBinTable( byte[] documentStream, byte[] tableStream, int offset,
int size, CharIndexTranslator translator )
{
long start = System.currentTimeMillis();
/*
* Page 35:
*
* "Associated with each interval is a BTE. A BTE holds a four-byte PN
* (page number) which identifies the FKP page in the file which
* contains the formatting information for that interval. A CHPX FKP
* further partitions an interval into runs of exception text."
*/
PlexOfCps bte = new PlexOfCps( tableStream, offset, size, 4 );
int length = bte.length();
for (int x = 0; x < length; x++)
{
GenericPropertyNode node = bte.getProperty(x);
int pageNum = LittleEndian.getInt(node.getBytes());
int pageOffset = POIFSConstants.SMALLER_BIG_BLOCK_SIZE * pageNum;
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage(documentStream,
pageOffset, translator);
for ( CHPX chpx : cfkp.getCHPXs() )
{
if ( chpx != null )
_textRuns.add( chpx );
}
}
logger.log( POILogger.DEBUG, "CHPX FKPs loaded in ",
Long.valueOf( System.currentTimeMillis() - start ), " ms (",
Integer.valueOf( _textRuns.size() ), " elements)" );
if ( _textRuns.isEmpty() )
{
logger.log( POILogger.WARN, "CHPX FKPs are empty" );
_textRuns.add( new CHPX( 0, 0, new SprmBuffer( 0 ) ) );
}
}
开发者ID:rmage,
项目名称:gnvc-ims,
代码行数:45,
代码来源:CHPBinTable.java
示例16: writeTo
点赞 2
import org.apache.poi.poifs.common.POIFSConstants; //导入依赖的package包/类
public void writeTo( HWPFOutputStream wordDocumentStream,
HWPFOutputStream tableStream, int fcMin,
CharIndexTranslator translator ) throws IOException
{
/*
* Page 35:
*
* "Associated with each interval is a BTE. A BTE holds a four-byte PN
* (page number) which identifies the FKP page in the file which
* contains the formatting information for that interval. A CHPX FKP
* further partitions an interval into runs of exception text."
*/
PlexOfCps bte = new PlexOfCps( 4 );
// each FKP must start on a 512 byte page.
int docOffset = wordDocumentStream.getOffset();
int mod = docOffset % POIFSConstants.SMALLER_BIG_BLOCK_SIZE;
if (mod != 0)
{
byte[] padding = new byte[POIFSConstants.SMALLER_BIG_BLOCK_SIZE - mod];
wordDocumentStream.write(padding);
}
// get the page number for the first fkp
docOffset = wordDocumentStream.getOffset();
int pageNum = docOffset/POIFSConstants.SMALLER_BIG_BLOCK_SIZE;
// get the ending fc
// CHPX lastRun = _textRuns.get(_textRuns.size() - 1);
// int endingFc = lastRun.getEnd();
// endingFc += fcMin;
int endingFc = translator.getByteIndex( _textRuns.get(
_textRuns.size() - 1 ).getEnd() );
ArrayList<CHPX> overflow = _textRuns;
do
{
CHPX startingProp = overflow.get(0);
// int start = startingProp.getStart() + fcMin;
int start = translator.getByteIndex( startingProp.getStart() );
CHPFormattedDiskPage cfkp = new CHPFormattedDiskPage();
cfkp.fill(overflow);
byte[] bufFkp = cfkp.toByteArray( translator );
wordDocumentStream.write(bufFkp);
overflow = cfkp.getOverflow();
int end = endingFc;
if (overflow != null)
{
// end = overflow.get(0).getStart() + fcMin;
end = translator.getByteIndex( overflow.get( 0 ).getStart() );
}
byte[] intHolder = new byte[4];
LittleEndian.putInt(intHolder, pageNum++);
bte.addProperty(new GenericPropertyNode(start, end, intHolder));
}
while (overflow != null);
tableStream.write(bte.toByteArray());
}
开发者ID:rmage,
项目名称:gnvc-ims,
代码行数:65,
代码来源:CHPBinTable.java