You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/06/15 03:34:57 UTC

svn commit: r1748487 - /poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java

Author: onealj
Date: Wed Jun 15 03:34:56 2016
New Revision: 1748487

URL: http://svn.apache.org/viewvc?rev=1748487&view=rev
Log:
whitespace (2 spaces to 4 spaces)

Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java?rev=1748487&r1=1748486&r2=1748487&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java Wed Jun 15 03:34:56 2016
@@ -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)
-  {
+    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());
 
-  public void adjustForDelete(int listIndex, int offset, int length)
-  {
-    int size = _paragraphs.size();
-    int endMark = offset + length;
-    int endIndex = listIndex;
+                currentPap.setEnd(cpStart);
+
+                _paragraphs.add(listIndex + 1, forInsert);
+                _paragraphs.add(listIndex + 2, clone);
+            }
+            else
+            {
+                _paragraphs.add(listIndex, forInsert);
+            }
+        }
 
-    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++)
+    public void adjustForDelete(int listIndex, int offset, int length)
     {
-      papx = _paragraphs.get(x);
-      papx.setStart(papx.getStart() - length);
-      papx.setEnd(papx.getEnd() - 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);
+        }
 
+        for (int x = endIndex + 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 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 ArrayList<PAPX> getParagraphs()
-  {
-    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);
-
-    // 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<PAPX> overflow = _paragraphs;
-    do
-    {
-      PAPX startingProp = overflow.get(0);
-
+        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);
+            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());
-  }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org