whitespace (2 spaces to 4 spaces)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748487 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-06-15 03:34:56 +00:00
parent 46a36df416
commit 2b7649cbd6

View File

@ -50,11 +50,11 @@ public class PAPBinTable
private static final POILogger logger = POILogFactory
.getLogger( PAPBinTable.class );
protected final ArrayList<PAPX> _paragraphs = new ArrayList<PAPX>();
protected final ArrayList<PAPX> _paragraphs = new ArrayList<PAPX>();
public PAPBinTable()
{
}
public PAPBinTable()
{
}
public PAPBinTable( byte[] documentStream, byte[] tableStream,
byte[] dataStream, int offset, int size,
@ -285,107 +285,107 @@ public class PAPBinTable
start = System.currentTimeMillis();
}
public void insert(int listIndex, int cpStart, SprmBuffer buf)
{
PAPX forInsert = new PAPX(0, 0, buf);
// Ensure character offsets are really characters
forInsert.setStart(cpStart);
forInsert.setEnd(cpStart);
if (listIndex == _paragraphs.size())
public void insert(int listIndex, int cpStart, SprmBuffer buf)
{
_paragraphs.add(forInsert);
}
else
{
PAPX currentPap = _paragraphs.get(listIndex);
if (currentPap != null && currentPap.getStart() < cpStart)
{
SprmBuffer clonedBuf = currentPap.getSprmBuf().clone();
// Copy the properties of the one before to afterwards
// Will go:
// Original, until insert at point
// New one
// Clone of original, on to the old end
PAPX clone = new PAPX(0, 0, clonedBuf);
// Again ensure contains character based offsets no matter what
clone.setStart(cpStart);
clone.setEnd(currentPap.getEnd());
PAPX forInsert = new PAPX(0, 0, buf);
currentPap.setEnd(cpStart);
// Ensure character offsets are really characters
forInsert.setStart(cpStart);
forInsert.setEnd(cpStart);
if (listIndex == _paragraphs.size())
{
_paragraphs.add(forInsert);
}
else
{
PAPX currentPap = _paragraphs.get(listIndex);
if (currentPap != null && currentPap.getStart() < cpStart)
{
SprmBuffer clonedBuf = currentPap.getSprmBuf().clone();
// Copy the properties of the one before to afterwards
// Will go:
// Original, until insert at point
// New one
// Clone of original, on to the old end
PAPX clone = new PAPX(0, 0, clonedBuf);
// Again ensure contains character based offsets no matter what
clone.setStart(cpStart);
clone.setEnd(currentPap.getEnd());
currentPap.setEnd(cpStart);
_paragraphs.add(listIndex + 1, forInsert);
_paragraphs.add(listIndex + 2, clone);
}
else
{
_paragraphs.add(listIndex, forInsert);
}
}
_paragraphs.add(listIndex + 1, forInsert);
_paragraphs.add(listIndex + 2, clone);
}
else
{
_paragraphs.add(listIndex, forInsert);
}
}
}
public void adjustForDelete(int listIndex, int offset, int length)
{
int size = _paragraphs.size();
int endMark = offset + length;
int endIndex = listIndex;
public void adjustForDelete(int listIndex, int offset, int length)
{
int size = _paragraphs.size();
int endMark = offset + length;
int endIndex = listIndex;
PAPX papx = _paragraphs.get(endIndex);
while (papx.getEnd() < endMark)
{
papx = _paragraphs.get(++endIndex);
}
if (listIndex == endIndex)
{
papx = _paragraphs.get(endIndex);
papx.setEnd((papx.getEnd() - endMark) + offset);
}
else
{
papx = _paragraphs.get(listIndex);
papx.setEnd(offset);
for (int x = listIndex + 1; x < endIndex; x++)
{
papx = _paragraphs.get(x);
papx.setStart(offset);
papx.setEnd(offset);
}
papx = _paragraphs.get(endIndex);
papx.setEnd((papx.getEnd() - endMark) + offset);
}
PAPX papx = _paragraphs.get(endIndex);
while (papx.getEnd() < endMark)
{
papx = _paragraphs.get(++endIndex);
}
if (listIndex == endIndex)
{
papx = _paragraphs.get(endIndex);
papx.setEnd((papx.getEnd() - endMark) + offset);
}
else
{
papx = _paragraphs.get(listIndex);
papx.setEnd(offset);
for (int x = listIndex + 1; x < endIndex; x++)
{
papx = _paragraphs.get(x);
papx.setStart(offset);
papx.setEnd(offset);
}
papx = _paragraphs.get(endIndex);
papx.setEnd((papx.getEnd() - endMark) + offset);
for (int x = endIndex + 1; x < size; x++)
{
papx = _paragraphs.get(x);
papx.setStart(papx.getStart() - length);
papx.setEnd(papx.getEnd() - length);
}
}
for (int x = endIndex + 1; x < size; x++)
public void adjustForInsert(int listIndex, int length)
{
papx = _paragraphs.get(x);
papx.setStart(papx.getStart() - length);
papx.setEnd(papx.getEnd() - length);
int size = _paragraphs.size();
PAPX papx = _paragraphs.get(listIndex);
papx.setEnd(papx.getEnd() + length);
for (int x = listIndex + 1; x < size; x++)
{
papx = _paragraphs.get(x);
papx.setStart(papx.getStart() + length);
papx.setEnd(papx.getEnd() + length);
}
}
}
public void adjustForInsert(int listIndex, int length)
{
int size = _paragraphs.size();
PAPX papx = _paragraphs.get(listIndex);
papx.setEnd(papx.getEnd() + length);
for (int x = listIndex + 1; x < size; x++)
public ArrayList<PAPX> getParagraphs()
{
papx = _paragraphs.get(x);
papx.setStart(papx.getStart() + length);
papx.setEnd(papx.getEnd() + length);
return _paragraphs;
}
}
public ArrayList<PAPX> getParagraphs()
{
return _paragraphs;
}
@Deprecated
public void writeTo( HWPFFileSystem sys, CharIndexTranslator translator )
@ -402,55 +402,54 @@ public class PAPBinTable
throws IOException
{
PlexOfCps binTable = new PlexOfCps(4);
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);
}
// 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 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() );
int endingFc = translator.getByteIndex( _paragraphs.get(_paragraphs.size() - 1 ).getEnd() );
ArrayList<PAPX> overflow = _paragraphs;
do
{
PAPX startingProp = overflow.get(0);
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);
PAPFormattedDiskPage pfkp = new PAPFormattedDiskPage();
pfkp.fill(overflow);
byte[] bufFkp = pfkp.toByteArray(tableStream, translator);
wordDocumentStream.write(bufFkp);
overflow = pfkp.getOverflow();
byte[] bufFkp = pfkp.toByteArray(tableStream, translator);
wordDocumentStream.write(bufFkp);
overflow = pfkp.getOverflow();
int end = endingFc;
if (overflow != null)
{
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, 0, pageNum++);
binTable.addProperty(new GenericPropertyNode(start, end, intHolder));
byte[] intHolder = new byte[4];
LittleEndian.putInt(intHolder, 0, pageNum++);
binTable.addProperty(new GenericPropertyNode(start, end, intHolder));
}
while (overflow != null);
tableStream.write(binTable.toByteArray());
}
while (overflow != null);
tableStream.write(binTable.toByteArray());
}
}