You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by sa...@apache.org on 2003/11/13 04:27:02 UTC
cvs commit: jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes CHPBinTable.java PAPX.java TextPieceTable.java
sackley 2003/11/12 19:27:02
Modified: src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes
CHPBinTable.java PAPX.java TextPieceTable.java
Log:
latest changes
Revision Changes Path
1.8 +18 -0 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/CHPBinTable.java
Index: CHPBinTable.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/CHPBinTable.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CHPBinTable.java 12 Nov 2003 01:33:59 -0000 1.7
+++ CHPBinTable.java 13 Nov 2003 03:27:02 -0000 1.8
@@ -147,6 +147,24 @@
}
}
+ public void insert(int listIndex, int cpStart, byte[] grpprl)
+ {
+ CHPX insertChpx = new CHPX(cpStart, cpStart, grpprl);
+ CHPX chpx = (CHPX)_textRuns.get(listIndex);
+ if (chpx.getStart() < cpStart)
+ {
+ CHPX clone = new CHPX(cpStart, chpx.getEnd(), chpx.getGrpprl());
+ chpx.setEnd(cpStart);
+
+ _textRuns.add(listIndex + 1, insertChpx);
+ _textRuns.add(listIndex + 2, clone);
+ }
+ else
+ {
+ _textRuns.add(listIndex, insertChpx);
+ }
+ }
+
public void adjustForInsert(int listIndex, int length)
{
int size = _textRuns.size();
1.6 +15 -0 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/PAPX.java
Index: PAPX.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/PAPX.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PAPX.java 12 Nov 2003 01:33:59 -0000 1.5
+++ PAPX.java 13 Nov 2003 03:27:02 -0000 1.6
@@ -56,6 +56,8 @@
package org.apache.poi.hwpf.model.hdftypes;
+import org.apache.poi.util.LittleEndian;
+
import org.apache.poi.hwpf.usermodel.Paragraph;
import org.apache.poi.hwpf.sprm.SprmBuffer;
@@ -89,6 +91,19 @@
public byte[] getBuf()
{
return getGrpprl();
+ }
+
+ public short getIstd()
+ {
+ byte[] buf = getGrpprl();
+ if (buf.length == 0)
+ {
+ return 0;
+ }
+ else
+ {
+ return LittleEndian.getShort(buf);
+ }
}
public boolean equals(Object o)
1.7 +41 -14 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/TextPieceTable.java
Index: TextPieceTable.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/hdftypes/TextPieceTable.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TextPieceTable.java 12 Nov 2003 01:33:59 -0000 1.6
+++ TextPieceTable.java 13 Nov 2003 03:27:02 -0000 1.7
@@ -68,7 +68,7 @@
public class TextPieceTable
{
ArrayList _textPieces = new ArrayList();
- int _multiple;
+ //int _multiple;
int _cpMin;
public TextPieceTable(byte[] documentStream, byte[] tableStream, int offset,
@@ -78,7 +78,7 @@
// get our plex of PieceDescriptors
PlexOfCps pieceTable = new PlexOfCps(tableStream, offset, size, PieceDescriptor.getSizeInBytes());
- _multiple = 2;
+ //_multiple = 2;
int length = pieceTable.length();
PieceDescriptor[] pieces = new PieceDescriptor[length];
@@ -89,31 +89,45 @@
PropertyNode node = pieceTable.getProperty(x);
pieces[x] = new PieceDescriptor(node.getBuf(), 0);
- if (!pieces[x].isUnicode())
- {
- _multiple = 1;
- }
+// if (!pieces[x].isUnicode())
+// {
+// _multiple = 1;
+// }
}
_cpMin = pieces[0].getFilePosition() - fcMin;
+ // if a piece is unicode the actual offset may be bumped because of the
+ // doubling of the needed size.
+ int bump = 0;
+
// using the PieceDescriptors, build our list of TextPieces.
for (int x = 0; x < pieces.length; x++)
{
int start = pieces[x].getFilePosition();
PropertyNode node = pieceTable.getProperty(x);
int nodeStart = node.getStart();
+
// multiple will be 2 if there is only one piece and its unicode. Some
// type of optimization.
- int nodeEnd = ((node.getEnd() - nodeStart) * _multiple) + nodeStart;
+ boolean unicode = pieces[x].isUnicode();
+
+ int multiple = 1;
+ if (unicode)
+ {
+ multiple = 2;
+ }
+ int nodeEnd = ((node.getEnd() - nodeStart) * multiple) + nodeStart;
int textSize = nodeEnd - nodeStart;
- boolean unicode = pieces[x].isUnicode();
- String toStr = null;
- byte[] buf = new byte[textSize + (unicode ? textSize % 2 : 0)];
+ byte[] buf = new byte[textSize];
System.arraycopy(documentStream, start, buf, 0, textSize);
- _textPieces.add(new TextPiece(nodeStart, nodeEnd, buf, pieces[x]));
+ _textPieces.add(new TextPiece(nodeStart + bump, nodeEnd + bump, buf, pieces[x]));
+ if (unicode)
+ {
+ bump += (node.getEnd() - nodeStart);
+ }
}
}
@@ -135,6 +149,7 @@
//int fcMin = docStream.getOffset();
int size = _textPieces.size();
+ int bumpDown = 0;
for (int x = 0; x < size; x++)
{
TextPiece next = (TextPiece)_textPieces.get(x);
@@ -145,12 +160,24 @@
// write the text to the docstream and save the piece descriptor to the
// plex which will be written later to the tableStream.
+ //if (_multiple == 1 && pd.isUnicode() &&
docStream.write(next.getBuf());
int nodeStart = next.getStart();
- textPlex.addProperty(new PropertyNode(nodeStart,
- (next.getEnd() - nodeStart)/_multiple + nodeStart,
- pd.toByteArray()));
+ int multiple = 1;
+ if (pd.isUnicode())
+ {
+ multiple = 2;
+ }
+ textPlex.addProperty(new PropertyNode(nodeStart - bumpDown,
+ ((next.getEnd() - nodeStart)/multiple + nodeStart) - bumpDown,
+ pd.toByteArray()));
+
+ if (pd.isUnicode())
+ {
+ bumpDown += ((next.getEnd() - nodeStart)/multiple);
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org