本文整理汇总了C#中NPOI.POIFS.Common.POIFSBigBlockSize类的典型用法代码示例。如果您正苦于以下问题:C# POIFSBigBlockSize类的具体用法?C# POIFSBigBlockSize怎么用?C# POIFSBigBlockSize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
POIFSBigBlockSize类属于NPOI.POIFS.Common命名空间,在下文中一共展示了POIFSBigBlockSize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BlockAllocationTableWriter
/// <summary>
/// Initializes a new instance of the <see cref="BlockAllocationTableWriter"/> class.
/// </summary>
public BlockAllocationTableWriter(POIFSBigBlockSize bigBlockSize)
{
_start_block = POIFSConstants.END_OF_CHAIN;
_entries = new List<int>(_default_size);
_blocks = new BATBlock[ 0 ];
_bigBlockSize = bigBlockSize;
}
示例2: SmallBlockTableWriter
/// <summary>
/// Initializes a new instance of the <see cref="SmallBlockTableWriter"/> class.
/// </summary>
/// <param name="bigBlockSize">the poifs bigBlockSize</param>
/// <param name="documents">a IList of POIFSDocument instances</param>
/// <param name="root">the Filesystem's root property</param>
public SmallBlockTableWriter(POIFSBigBlockSize bigBlockSize, IList documents,
RootProperty root)
{
_sbat = new BlockAllocationTableWriter(bigBlockSize);
_small_blocks = new ArrayList();
_root = root;
IEnumerator iter = documents.GetEnumerator();
while (iter.MoveNext())
{
POIFSDocument doc = ( POIFSDocument ) iter.Current;
BlockWritable[] blocks = doc.SmallBlocks;
if (blocks.Length != 0)
{
doc.StartBlock=_sbat.AllocateSpace(blocks.Length);
for (int j = 0; j < blocks.Length; j++)
{
_small_blocks.Add(blocks[ j ]);
}
} else {
doc.StartBlock=POIFSConstants.END_OF_CHAIN;
}
}
_sbat.SimpleCreateBlocks();
_root.Size=_small_blocks.Count;
_big_block_count = SmallDocumentBlock.Fill(bigBlockSize, _small_blocks);
}
示例3: BuildProperties
private static List<Property> BuildProperties(IEnumerator<ByteBuffer> dataSource, POIFSBigBlockSize bigBlockSize)
{
List<Property> properties = new List<Property>();
while(dataSource.MoveNext())
{
ByteBuffer bb = dataSource.Current;
// Turn it into an array
byte[] data;
if (bb.HasBuffer && bb.Offset == 0 &&
bb.Buffer.Length == bigBlockSize.GetBigBlockSize())
{
data = bb.Buffer;
}
else
{
data = new byte[bigBlockSize.GetBigBlockSize()];
int toRead = data.Length;
if (bb.Remaining() < bigBlockSize.GetBigBlockSize())
{
// Looks to be a truncated block
// This isn't allowed, but some third party created files
// sometimes do this, and we can normally read anyway
toRead = bb.Remaining();
}
bb.Read(data, 0, toRead);
}
PropertyFactory.ConvertToProperties(data, properties);
}
return properties;
}
示例4: Convert
/// <summary>
/// convert a single long array into an array of SmallDocumentBlock
/// instances
/// </summary>
/// <param name="bigBlockSize">the poifs bigBlockSize</param>
/// <param name="array">the byte array to be converted</param>
/// <param name="size">the intended size of the array (which may be smaller)</param>
/// <returns>an array of SmallDocumentBlock instances, filled from
/// the array</returns>
public static SmallDocumentBlock [] Convert(POIFSBigBlockSize bigBlockSize,
byte [] array,
int size)
{
SmallDocumentBlock[] rval = new SmallDocumentBlock[ (size + _block_size - 1) / _block_size ];
int offset = 0;
for (int k = 0; k < rval.Length; k++)
{
rval[ k ] = new SmallDocumentBlock(bigBlockSize);
if (offset < array.Length)
{
int length = Math.Min(_block_size, array.Length - offset);
Array.Copy(array, offset, rval[ k ]._data, 0, length);
if (length != _block_size)
{
for (int i = length; i < _block_size; i++)
rval[k]._data[i] = _default_fill;
}
}
else
{
for (int j = 0; j < rval[k]._data.Length; j++)
{
rval[k]._data[j] = _default_fill;
}
}
offset += _block_size;
}
return rval;
}
示例5: PropertyBlock
/// <summary>
/// Create a single instance initialized with default values
/// </summary>
/// <param name="bigBlockSize"></param>
/// <param name="properties">the properties to be inserted</param>
/// <param name="offset">the offset into the properties array</param>
protected PropertyBlock(POIFSBigBlockSize bigBlockSize, Property[] properties, int offset) : base(bigBlockSize)
{
_properties = new Property[ bigBlockSize.GetPropertiesPerBlock() ];
for (int j = 0; j < _properties.Length; j++)
{
_properties[ j ] = properties[ j + offset ];
}
}
示例6: SmallDocumentBlock
public SmallDocumentBlock(POIFSBigBlockSize bigBlockSize, byte[] data, int index)
{
_bigBlockSize = bigBlockSize;
_blocks_per_big_block = GetBlocksPerBigBlock(bigBlockSize);
_data = new byte[_block_size];
System.Array.Copy(data, index*_block_size, _data, 0, _block_size);
}
示例7: GetSmallDocumentBlocks
/// <summary>
/// fetch the small document block list from an existing file
/// </summary>
/// <param name="blockList">the raw data from which the small block table will be extracted</param>
/// <param name="root">the root property (which contains the start block and small block table size)</param>
/// <param name="sbatStart">the start block of the SBAT</param>
/// <returns>the small document block list</returns>
public static BlockList GetSmallDocumentBlocks(POIFSBigBlockSize bigBlockSize,
RawDataBlockList blockList, RootProperty root,
int sbatStart)
{
BlockList list =
new SmallDocumentBlockList(
SmallDocumentBlock.Extract(bigBlockSize, blockList.FetchBlocks(root.StartBlock, -1)));
new BlockAllocationTableReader(bigBlockSize, blockList.FetchBlocks(sbatStart, -1), list);
return list;
}
示例8: RawDataBlockList
/// <summary>
/// Initializes a new instance of the <see cref="RawDataBlockList"/> class.
/// </summary>
/// <param name="stream">the InputStream from which the data will be read</param>
/// <param name="bigBlockSize">The big block size, either 512 bytes or 4096 bytes</param>
public RawDataBlockList(Stream stream, POIFSBigBlockSize bigBlockSize)
{
List<RawDataBlock> blocks = new List<RawDataBlock>();
while (true)
{
RawDataBlock block = new RawDataBlock(stream, bigBlockSize.GetBigBlockSize());
// If there was data, add the block to the list
if(block.HasData) {
blocks.Add(block);
}
// If the stream is now at the End Of File, we're done
if (block.EOF) {
break;
}
}
SetBlocks((ListManagedBlock[])blocks.ToArray());
}
示例9: BuildProperties
// private static List<Property> BuildProperties(IEnumerator<byte[]> dataSource, POIFSBigBlockSize bigBlockSize)
private static List<Property> BuildProperties(IEnumerator<ByteBuffer> dataSource, POIFSBigBlockSize bigBlockSize)
{
try
{
List<Property> properties = new List<Property>();
while(dataSource.MoveNext())
{
ByteBuffer bb = dataSource.Current;
//byte[] bb = (byte[])dataSource.Current;
// Turn it into an array
byte[] data;
if (bb.HasBuffer && bb.Offset == 0 &&
bb.Buffer.Length == bigBlockSize.GetBigBlockSize())
{
data = bb.Buffer;
}
else
{
data = new byte[bigBlockSize.GetBigBlockSize()];
//bb.get(data, 0, data.length);
bb.Read(data, 0, data.Length);
}
//}
//data = new byte[bigBlockSize.GetBigBlockSize()];
//System.Array.Copy(bb, data, bb.Length);
PropertyFactory.ConvertToProperties(data, properties);
}
return properties;
}
catch(System.IO.IOException ex)
{
throw ex;
}
}
示例10: CreatePropertyBlockArray
/// <summary>
/// Create an array of PropertyBlocks from an array of Property
/// instances, creating empty Property instances to make up any
/// shortfall
/// </summary>
/// <param name="properties">the Property instances to be converted into PropertyBlocks, in a java List</param>
/// <returns>the array of newly created PropertyBlock instances</returns>
public static BlockWritable [] CreatePropertyBlockArray( POIFSBigBlockSize bigBlockSize,
List<Property> properties)
{
int _properties_per_block = bigBlockSize.GetPropertiesPerBlock();
int blockCount = (properties.Count + _properties_per_block - 1) / _properties_per_block;
Property[] toBeWritten = new Property[blockCount * _properties_per_block];
System.Array.Copy(properties.ToArray(), 0, toBeWritten, 0, properties.Count);
for (int i = properties.Count; i < toBeWritten.Length; i++)
{
toBeWritten[i] = new AnonymousProperty();
}
BlockWritable[] rvalue = new BlockWritable[blockCount];
for (int i = 0; i < blockCount; i++)
rvalue[i] = new PropertyBlock(bigBlockSize, toBeWritten, i * _properties_per_block);
return rvalue;
}
示例11: BlockAllocationTableReader
/// <summary>
/// create a BlockAllocationTableReader for an existing filesystem. Side
/// effect: when this method finishes, the BAT blocks will have
/// been Removed from the raw block list, and any blocks labeled as
/// 'unused' in the block allocation table will also have been
/// Removed from the raw block list. </summary>
/// <param name="bigBlockSizse">the poifs bigBlockSize</param>
/// <param name="block_count">the number of BAT blocks making up the block allocation table</param>
/// <param name="block_array">the array of BAT block indices from the
/// filesystem's header</param>
/// <param name="xbat_count">the number of XBAT blocks</param>
/// <param name="xbat_index">the index of the first XBAT block</param>
/// <param name="raw_block_list">the list of RawDataBlocks</param>
public BlockAllocationTableReader(POIFSBigBlockSize bigBlockSizse,
int block_count,
int[] block_array,
int xbat_count,
int xbat_index,
BlockList raw_block_list)
: this(bigBlockSizse)
{
SanityCheckBlockCount(block_count);
RawDataBlock[] blocks = new RawDataBlock[block_count];
int limit = Math.Min(block_count, block_array.Length);
int block_index;
for (block_index = 0; block_index < limit; block_index++)
{
int nextOffset = block_array[block_index];
if (nextOffset > raw_block_list.BlockCount())
{
throw new IOException("Your file contains " + raw_block_list.BlockCount() +
" sectors, but the initial DIFAT array at index " + block_index +
" referenced block # " + nextOffset + ". This isn't allowed and " +
" your file is corrupt");
}
blocks[block_index] = (RawDataBlock)raw_block_list.Remove(nextOffset);
}
if (block_index < block_count)
{
// must have extended blocks
if (xbat_index < 0)
{
throw new IOException(
"BAT count exceeds limit, yet XBAT index indicates no valid entries");
}
int chain_index = xbat_index;
int max_entries_per_block = BATBlock.EntriesPerXBATBlock;
int chain_index_offset = BATBlock.XBATChainOffset;
// Each XBAT block contains either:
// (maximum number of sector indexes) + index of next XBAT
// some sector indexes + FREE sectors to max # + EndOfChain
for (int j = 0; j < xbat_count; j++)
{
limit = Math.Min(block_count - block_index,
max_entries_per_block);
byte[] data = raw_block_list.Remove(chain_index).Data;
int offset = 0;
for (int k = 0; k < limit; k++)
{
blocks[block_index++] =
(RawDataBlock)raw_block_list.Remove(LittleEndian.GetInt(data, offset));
offset += LittleEndianConsts.INT_SIZE;
}
chain_index = LittleEndian.GetInt(data, chain_index_offset);
if (chain_index == POIFSConstants.END_OF_CHAIN)
{
break;
}
}
}
if (block_index != block_count)
{
throw new IOException("Could not find all blocks");
}
// now that we have all of the raw data blocks, go through and
// create the indices
SetEntries((ListManagedBlock[])blocks, raw_block_list);
}
示例12: DocumentBlock
/// <summary>
/// Create a single instance initialized with data.
/// </summary>
/// <param name="stream">the InputStream delivering the data.</param>
/// <param name="bigBlockSize">the poifs bigBlockSize</param>
public DocumentBlock(Stream stream, POIFSBigBlockSize bigBlockSize)
: this(bigBlockSize)
{
int count = IOUtils.ReadFully(stream, _data);
_bytes_Read = (count == -1) ? 0: count;
}
示例13: Convert
/// <summary>
/// convert a single long array into an array of DocumentBlock
/// instances
/// </summary>
/// <param name="bigBlockSize">the poifs bigBlockSize</param>
/// <param name="array">the byte array to be converted</param>
/// <param name="size">the intended size of the array (which may be smaller)</param>
/// <returns>an array of DocumentBlock instances, filled from the
/// input array</returns>
public static DocumentBlock[] Convert(POIFSBigBlockSize bigBlockSize,
byte[] array,
int size)
{
DocumentBlock[] rval =
new DocumentBlock[(size + POIFSConstants.BIG_BLOCK_SIZE - 1) / POIFSConstants.BIG_BLOCK_SIZE];
int offset = 0;
for (int k = 0; k < rval.Length; k++)
{
rval[k] = new DocumentBlock(bigBlockSize);
if (offset < array.Length)
{
int length = Math.Min(POIFSConstants.BIG_BLOCK_SIZE,
array.Length - offset);
Array.Copy(array, offset, rval[k]._data, 0, length);
if (length != POIFSConstants.BIG_BLOCK_SIZE)
{
for (int j = (length > 0) ? (length - 1) : length; j < POIFSConstants.BIG_BLOCK_SIZE; j++)
{
rval[k]._data[j] = _default_value;
}
}
}
else
{
for (int j = 0; j < rval[k]._data.Length; j++)
{
rval[k]._data[j] = _default_value;
}
}
offset += POIFSConstants.BIG_BLOCK_SIZE;
}
return rval;
}
示例14: BigBlockStore
internal BigBlockStore(POIFSBigBlockSize bigBlockSize, POIFSDocumentPath path, string name, int size, POIFSWriterListener writer)
{
this.bigBlockSize = bigBlockSize;
this.bigBlocks = new DocumentBlock[0];
this.path = path;
this.name = name;
this.size = size;
this.writer = writer;
}
示例15: SmallBlockStore
internal SmallBlockStore(POIFSBigBlockSize bigBlockSize, SmallDocumentBlock[] blocks)
{
this.bigBlockSize = bigBlockSize;
smallBlocks = (SmallDocumentBlock[])blocks.Clone();
this.path = null;
this.name = null;
this.size = -1;
this.writer = null;
}