From 2b7649cbd6200eb331806adfa7c833db5f54d70d Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Wed, 15 Jun 2016 03:34:56 +0000 Subject: [PATCH] whitespace (2 spaces to 4 spaces) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748487 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hwpf/model/PAPBinTable.java | 259 +++++++++--------- 1 file changed, 129 insertions(+), 130 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java index 574d6a3cfc..0d9e6476a8 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java @@ -50,11 +50,11 @@ public class PAPBinTable private static final POILogger logger = POILogFactory .getLogger( PAPBinTable.class ); - protected final ArrayList _paragraphs = new ArrayList(); + protected final ArrayList _paragraphs = new ArrayList(); - 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) - { + public void insert(int listIndex, int cpStart, SprmBuffer buf) + { - PAPX forInsert = new PAPX(0, 0, buf); + PAPX forInsert = new PAPX(0, 0, buf); - // Ensure character offsets are really characters - forInsert.setStart(cpStart); - forInsert.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); + } + } - 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); - } } - } + 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 getParagraphs() { - papx = _paragraphs.get(x); - papx.setStart(papx.getStart() + length); - papx.setEnd(papx.getEnd() + length); + return _paragraphs; } - } - - - public ArrayList 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); - - // 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; - + 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 overflow = _paragraphs; - do - { - PAPX startingProp = overflow.get(0); - + int endingFc = translator.getByteIndex( _paragraphs.get(_paragraphs.size() - 1 ).getEnd() ); + + ArrayList 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()); - } } -- 2.39.5