ASF Bugzilla – Attachment 12182 Details for
Bug 30235
[PATCH] Fixes for unicode/tables etc for real world documents
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
ListLevel.java, ListTables.java, SectionTable.java, TextPiece.java, TextPiecetable.java, ParagraphSprmUncompressor.java, TableSprmUncompressor.java, CharacterRun.java, Paragraph.java, Range.java, Table.java, TableRow.java
patchfile.GossUpdates.txt (text/plain), 23.14 KB, created by
Piers
on 2004-07-21 16:21:52 UTC
(
hide
)
Description:
ListLevel.java, ListTables.java, SectionTable.java, TextPiece.java, TextPiecetable.java, ParagraphSprmUncompressor.java, TableSprmUncompressor.java, CharacterRun.java, Paragraph.java, Range.java, Table.java, TableRow.java
Filename:
MIME Type:
Creator:
Piers
Created:
2004-07-21 16:21:52 UTC
Size:
23.14 KB
patch
obsolete
>Index: hwpf/model/ListLevel.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java,v >retrieving revision 1.2 >diff -u -r1.2 ListLevel.java >--- hwpf/model/ListLevel.java 9 Apr 2004 13:05:32 -0000 1.2 >+++ hwpf/model/ListLevel.java 21 Jul 2004 15:38:54 -0000 >@@ -14,7 +14,7 @@ > See the License for the specific language governing permissions and > limitations under the License. > ==================================================================== */ >- >+ > > package org.apache.poi.hwpf.model; > >@@ -106,10 +106,10 @@ > > _grpprlPapx = new byte[_cbGrpprlPapx]; > _grpprlChpx = new byte[_cbGrpprlChpx]; >- System.arraycopy(buf, offset, _grpprlChpx, 0, _cbGrpprlChpx); >- offset += _cbGrpprlChpx; > System.arraycopy(buf, offset, _grpprlPapx, 0, _cbGrpprlPapx); > offset += _cbGrpprlPapx; >+ System.arraycopy(buf, offset, _grpprlChpx, 0, _cbGrpprlChpx); >+ offset += _cbGrpprlChpx; > > int numberTextLength = LittleEndian.getShort(buf, offset); > _numberText = new char[numberTextLength]; >@@ -168,6 +168,10 @@ > _grpprlPapx = grpprl; > } > >+ public byte[] getLevelProperties() >+ { >+ return _grpprlPapx; >+ } > > public boolean equals(Object obj) > { >Index: hwpf/model/ListTables.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java,v >retrieving revision 1.4 >diff -u -r1.4 ListTables.java >--- hwpf/model/ListTables.java 9 Apr 2004 13:05:32 -0000 1.4 >+++ hwpf/model/ListTables.java 21 Jul 2004 15:38:54 -0000 >@@ -192,6 +192,11 @@ > return lvl; > } > >+ public ListData getListData(int listID) >+ { >+ return (ListData) _listMap.get(new Integer(listID)); >+ } >+ > public boolean equals(Object obj) > { > if (obj == null) >Index: hwpf/model/SectionTable.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java,v >retrieving revision 1.4 >diff -u -r1.4 SectionTable.java >--- hwpf/model/SectionTable.java 19 Apr 2004 23:48:02 -0000 1.4 >+++ hwpf/model/SectionTable.java 21 Jul 2004 15:38:54 -0000 >@@ -45,6 +45,7 @@ > { > PlexOfCps sedPlex = new PlexOfCps(tableStream, offset, size, SED_SIZE); > _text = tpt; >+ > int length = sedPlex.length(); > > for (int x = 0; x < length; x++) >@@ -85,50 +86,51 @@ > } > } > >- private int CPtoFC(int cp) >+ // goss version of CPtoFC - this takes into account non-contiguous textpieces >+ // that we have come across in real world documents. Tests against the example >+ // code in HWPFDocument show no variation to Ryan's version of the code in >+ // normal use, but this version works with our non-contiguous test case. >+ // So far unable to get this test case to be written out as well due to >+ // other issues. - piers >+ private int CPtoFC(int CP) > { >- int size = _text.size(); >- int x = 0; >- int end = 0; >- int fc = 0; >- for (; x < size; x++) >- { >- TextPiece piece = (TextPiece)_text.get(x); >- int currentStart = end; >- end += ((piece.getEnd()- piece.getStart())/(piece.usesUnicode() ? 2 : 1)); >- if (cp <= end) >- { >- fc += ((cp - currentStart) * (piece.usesUnicode() ? 2 : 1)); >- break; >- } >- else >+ TextPiece TP = null; >+ >+ for(int i=_text.size()-1; i>-1; i--) > { >- fc += (piece.getEnd() - piece.getStart()); >+ TP = (TextPiece)_text.get(i); >+ >+ if(CP >= TP.getCP()) break; > } >+ int FC = TP.getPieceDescriptor().getFilePosition(); >+ int offset = CP - TP.getCP(); >+ if(TP.usesUnicode()) offset*=2; >+ FC = FC+offset-((TextPiece)_text.get(0)).getPieceDescriptor().getFilePosition(); >+ return FC; > } >- return fc; >- } > >- private int FCtoCP(int fc) >- { >- int size = _text.size(); >- int cp = 0; >- for (int x = 0; x < size; x++) >- { >- TextPiece piece = (TextPiece)_text.get(x); >+ // Ryans code >+ private int FCtoCP(int fc) >+ { >+ int size = _text.size(); >+ int cp = 0; >+ for (int x = 0; x < size; x++) >+ { >+ TextPiece piece = (TextPiece)_text.get(x); >+ >+ if (fc <= piece.getEnd()) >+ { >+ cp += ((fc - piece.getStart())/ (piece.usesUnicode() ? 2 : 1)); >+ break; >+ } >+ else >+ { >+ cp += ((piece.getEnd() - piece.getStart())/ (piece.usesUnicode() ? 2 : 1)); >+ } >+ } >+ return cp; >+ } > >- if (fc <= piece.getEnd()) >- { >- cp += ((fc - piece.getStart())/ (piece.usesUnicode() ? 2 : 1)); >- break; >- } >- else >- { >- cp += ((piece.getEnd() - piece.getStart())/ (piece.usesUnicode() ? 2 : 1)); >- } >- } >- return cp; >- } > > public ArrayList getSections() > { >@@ -163,12 +165,20 @@ > sed.setFc(offset); > > // add the section descriptor bytes to the PlexOfCps. >+ >+ >+ // original line - >+ //GenericPropertyNode property = new GenericPropertyNode(sepx.getStart(), sepx.getEnd(), sed.toByteArray()); >+ >+ // Line using Ryan's FCtoCP() conversion method - >+ // unable to observe any effect on our testcases when using this code - piers > GenericPropertyNode property = new GenericPropertyNode(FCtoCP(sepx.getStart()), FCtoCP(sepx.getEnd()), sed.toByteArray()); >+ >+ > plex.addProperty(property); > > offset = docStream.getOffset(); > } > tableStream.write(plex.toByteArray()); > } >- > } >Index: hwpf/model/TextPiece.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java,v >retrieving revision 1.4 >diff -u -r1.4 TextPiece.java >--- hwpf/model/TextPiece.java 19 Apr 2004 23:48:02 -0000 1.4 >+++ hwpf/model/TextPiece.java 21 Jul 2004 15:38:54 -0000 >@@ -31,13 +31,15 @@ > > private PieceDescriptor _pd; > >+ private int _cpStart; >+ > /** > * @param start Offset in main document stream. > * @param length The total length of the text in bytes. Note: 1 character > * does not necessarily refer to 1 byte. > * @param unicode true if this text is unicode. > */ >- public TextPiece(int start, int end, byte[] text, PieceDescriptor pd) >+ public TextPiece(int start, int end, byte[] text, PieceDescriptor pd, int cpStart) > throws UnsupportedEncodingException > { > /** start - end is length on file. This is double the expected when its >@@ -45,6 +47,7 @@ > super(start, end, new StringBuffer(new String(text, pd.isUnicode() ? "UTF-16LE" : "Cp1252"))); > _usesUnicode = pd.isUnicode(); > _pd = pd; >+ _cpStart = cpStart; > } > /** > * @return If this text piece uses unicode >@@ -64,11 +67,6 @@ > return (StringBuffer)_buf; > } > >- public void setStringBuffer(StringBuffer buf) >- { >- _buf = buf; >- } >- > public byte[] getRawBytes() > { > try >@@ -111,6 +109,12 @@ > tp._usesUnicode == _usesUnicode && _pd.equals(tp._pd); > } > return false; >+ } >+ >+ >+ public int getCP() >+ { >+ return _cpStart; > } > > } >Index: hwpf/model/TextPieceTable.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java,v >retrieving revision 1.4 >diff -u -r1.4 TextPieceTable.java >--- hwpf/model/TextPieceTable.java 19 Apr 2004 23:48:02 -0000 1.4 >+++ hwpf/model/TextPieceTable.java 21 Jul 2004 15:38:54 -0000 >@@ -65,10 +65,8 @@ > // } > } > >- _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; >+ int firstPieceFilePosition = pieces[0].getFilePosition(); >+ _cpMin = firstPieceFilePosition - fcMin; > > // using the PieceDescriptors, build our list of TextPieces. > for (int x = 0; x < pieces.length; x++) >@@ -92,12 +90,9 @@ > > byte[] buf = new byte[textSize]; > System.arraycopy(documentStream, start, buf, 0, textSize); >- _textPieces.add(new TextPiece(nodeStart + bump, nodeEnd + bump, buf, pieces[x])); > >- if (unicode) >- { >- bump += (node.getEnd() - nodeStart); >- } >+ int startFilePosition = start - firstPieceFilePosition; >+ _textPieces.add(new TextPiece(startFilePosition, startFilePosition+textSize, buf, pieces[x], node.getStart())); > } > } > >Index: hwpf/sprm/ParagraphSprmUncompressor.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/ParagraphSprmUncompressor.java,v >retrieving revision 1.5 >diff -u -r1.5 ParagraphSprmUncompressor.java >--- hwpf/sprm/ParagraphSprmUncompressor.java 9 Apr 2004 13:05:33 -0000 1.5 >+++ hwpf/sprm/ParagraphSprmUncompressor.java 21 Jul 2004 15:38:54 -0000 >@@ -14,7 +14,7 @@ > See the License for the specific language governing permissions and > limitations under the License. > ==================================================================== */ >- >+ > > package org.apache.poi.hwpf.sprm; > >@@ -407,7 +407,7 @@ > > for (int x = 0; x < delSize; x++) > { >- tabMap.remove(new Integer(LittleEndian.getInt(grpprl, offset))); >+ tabMap.remove(new Integer(LittleEndian.getShort(grpprl, offset))); > offset += LittleEndian.SHORT_SIZE; > } > >Index: hwpf/sprm/TableSprmUncompressor.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmUncompressor.java,v >retrieving revision 1.3 >diff -u -r1.3 TableSprmUncompressor.java >--- hwpf/sprm/TableSprmUncompressor.java 9 Apr 2004 13:05:33 -0000 1.3 >+++ hwpf/sprm/TableSprmUncompressor.java 21 Jul 2004 15:38:55 -0000 >@@ -14,7 +14,7 @@ > See the License for the specific language governing permissions and > limitations under the License. > ==================================================================== */ >- >+ > > package org.apache.poi.hwpf.sprm; > >@@ -133,12 +133,26 @@ > newTAP.setRgdxaCenter (rgdxaCenter); > newTAP.setRgtc (rgtc); > >+ // get the rgdxaCenters > for (int x = 0; x < itcMac; x++) > { > rgdxaCenter[x] = LittleEndian.getShort (grpprl, offset + (1 + (x * 2))); >- rgtc[x] = TableCellDescriptor.convertBytesToTC (grpprl, >- offset + (1 + ((itcMac + 1) * 2) + (x * 20))); > } >+ >+ // only try to get the TC entries if they exist... >+ int endOfSprm = offset+sprm.size()-6; // -2 bytes for sprm - 2 for size short - 2 to correct offsets being 0 based >+ int startOfTCs = offset + (1 + (itcMac + 1) * 2); >+ >+ boolean hasTCs = startOfTCs < endOfSprm; >+ >+ for (int x = 0; x < itcMac; x++) >+ { >+ if(hasTCs) rgtc[x] = TableCellDescriptor.convertBytesToTC(grpprl, >+ offset + (1 + ( (itcMac + 1) * 2) + (x * 20))); >+ else >+ rgtc[x] = new TableCellDescriptor(); >+ } >+ > rgdxaCenter[itcMac] = LittleEndian.getShort (grpprl, offset + (1 + (itcMac * 2))); > break; > } >Index: hwpf/usermodel/CharacterRun.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java,v >retrieving revision 1.8 >diff -u -r1.8 CharacterRun.java >--- hwpf/usermodel/CharacterRun.java 8 Apr 2004 11:51:14 -0000 1.8 >+++ hwpf/usermodel/CharacterRun.java 21 Jul 2004 15:38:55 -0000 >@@ -123,7 +123,7 @@ > _props.setFRMarkDel(mark); > > byte newVal = (byte)(mark ? 1 : 0); >- _chpx.addSprm(SPRM_FRMARKDEL, newVal); >+ _chpx.updateSprm(SPRM_FRMARKDEL, newVal); > > } > >@@ -137,7 +137,7 @@ > _props.setFBold(bold); > > byte newVal = (byte)(bold ? 1 : 0); >- _chpx.addSprm(SPRM_FBOLD, newVal); >+ _chpx.updateSprm(SPRM_FBOLD, newVal); > > } > >@@ -151,7 +151,7 @@ > _props.setFItalic(italic); > > byte newVal = (byte)(italic ? 1 : 0); >- _chpx.addSprm(SPRM_FITALIC, newVal); >+ _chpx.updateSprm(SPRM_FITALIC, newVal); > > } > >@@ -165,7 +165,7 @@ > _props.setFOutline(outlined); > > byte newVal = (byte)(outlined ? 1 : 0); >- _chpx.addSprm(SPRM_FOUTLINE, newVal); >+ _chpx.updateSprm(SPRM_FOUTLINE, newVal); > > } > >@@ -179,7 +179,7 @@ > _props.setFFldVanish(fldVanish); > > byte newVal = (byte)(fldVanish ? 1 : 0); >- _chpx.addSprm(SPRM_FFLDVANISH, newVal); >+ _chpx.updateSprm(SPRM_FFLDVANISH, newVal); > > } > >@@ -193,7 +193,7 @@ > _props.setFSmallCaps(smallCaps); > > byte newVal = (byte)(smallCaps ? 1 : 0); >- _chpx.addSprm(SPRM_FSMALLCAPS, newVal); >+ _chpx.updateSprm(SPRM_FSMALLCAPS, newVal); > > } > >@@ -207,7 +207,7 @@ > _props.setFCaps(caps); > > byte newVal = (byte)(caps ? 1 : 0); >- _chpx.addSprm(SPRM_FCAPS, newVal); >+ _chpx.updateSprm(SPRM_FCAPS, newVal); > > } > >@@ -221,7 +221,7 @@ > _props.setFVanish(vanish); > > byte newVal = (byte)(vanish ? 1 : 0); >- _chpx.addSprm(SPRM_FVANISH, newVal); >+ _chpx.updateSprm(SPRM_FVANISH, newVal); > > } > >@@ -235,7 +235,7 @@ > _props.setFRMark(mark); > > byte newVal = (byte)(mark ? 1 : 0); >- _chpx.addSprm(SPRM_FRMARK, newVal); >+ _chpx.updateSprm(SPRM_FRMARK, newVal); > > } > >@@ -249,7 +249,7 @@ > _props.setFStrike(strike); > > byte newVal = (byte)(strike ? 1 : 0); >- _chpx.addSprm(SPRM_FSTRIKE, newVal); >+ _chpx.updateSprm(SPRM_FSTRIKE, newVal); > > } > >@@ -263,7 +263,7 @@ > _props.setFShadow(shadow); > > byte newVal = (byte)(shadow ? 1 : 0); >- _chpx.addSprm(SPRM_FSHADOW, newVal); >+ _chpx.updateSprm(SPRM_FSHADOW, newVal); > > } > >@@ -277,7 +277,7 @@ > _props.setFEmboss(emboss); > > byte newVal = (byte)(emboss ? 1 : 0); >- _chpx.addSprm(SPRM_FEMBOSS, newVal); >+ _chpx.updateSprm(SPRM_FEMBOSS, newVal); > > } > >@@ -291,7 +291,7 @@ > _props.setFImprint(imprint); > > byte newVal = (byte)(imprint ? 1 : 0); >- _chpx.addSprm(SPRM_FIMPRINT, newVal); >+ _chpx.updateSprm(SPRM_FIMPRINT, newVal); > > } > >@@ -305,7 +305,7 @@ > _props.setFDStrike(dstrike); > > byte newVal = (byte)(dstrike ? 1 : 0); >- _chpx.addSprm(SPRM_FDSTRIKE, newVal); >+ _chpx.updateSprm(SPRM_FDSTRIKE, newVal); > > } > >@@ -313,7 +313,7 @@ > { > _props.setFtcAscii(ftcAscii); > >- _chpx.addSprm(SPRM_RGFTCASCII, (short)ftcAscii); >+ _chpx.updateSprm(SPRM_RGFTCASCII, (short)ftcAscii); > > } > >@@ -321,7 +321,7 @@ > { > _props.setFtcFE(ftcFE); > >- _chpx.addSprm(SPRM_RGFTCFAREAST, (short)ftcFE); >+ _chpx.updateSprm(SPRM_RGFTCFAREAST, (short)ftcFE); > > } > >@@ -329,7 +329,7 @@ > { > _props.setFtcOther(ftcOther); > >- _chpx.addSprm(SPRM_RGFTCNOTFAREAST, (short)ftcOther); >+ _chpx.updateSprm(SPRM_RGFTCNOTFAREAST, (short)ftcOther); > > } > >@@ -342,7 +342,7 @@ > { > _props.setHps(halfPoints); > >- _chpx.addSprm(SPRM_HPS, (short)halfPoints); >+ _chpx.updateSprm(SPRM_HPS, (short)halfPoints); > > } > >@@ -355,7 +355,7 @@ > { > _props.setDxaSpace(twips); > >- _chpx.addSprm(SPRM_DXASPACE, twips); >+ _chpx.updateSprm(SPRM_DXASPACE, twips); > > } > >@@ -368,7 +368,7 @@ > { > _props.setDxaSpace(iss); > >- _chpx.addSprm(SPRM_DXASPACE, iss); >+ _chpx.updateSprm(SPRM_DXASPACE, iss); > > } > >@@ -380,7 +380,7 @@ > public void setUnderlineCode(int kul) > { > _props.setKul((byte)kul); >- _chpx.addSprm(SPRM_KUL, (byte)kul); >+ _chpx.updateSprm(SPRM_KUL, (byte)kul); > } > > public int getColor() >@@ -391,7 +391,7 @@ > public void setColor(int color) > { > _props.setIco((byte)color); >- _chpx.addSprm(SPRM_ICO, (byte)color); >+ _chpx.updateSprm(SPRM_ICO, (byte)color); > } > > public int getVerticalOffset() >@@ -402,7 +402,7 @@ > public void setVerticalOffset(int hpsPos) > { > _props.setHpsPos(hpsPos); >- _chpx.addSprm(SPRM_HPSPOS, (byte)hpsPos); >+ _chpx.updateSprm(SPRM_HPSPOS, (byte)hpsPos); > } > > public int getKerning() >@@ -413,7 +413,7 @@ > public void setKerning(int kern) > { > _props.setHpsKern(kern); >- _chpx.addSprm(SPRM_HPSKERN, (short)kern); >+ _chpx.updateSprm(SPRM_HPSKERN, (short)kern); > } > > public boolean isHighlighted() >@@ -425,14 +425,88 @@ > { > _props.setFHighlight(true); > _props.setIcoHighlight(color); >- _chpx.addSprm(SPRM_HIGHLIGHT, color); >+ _chpx.updateSprm(SPRM_HIGHLIGHT, color); > } > >- public String getFontName() >+ public int getFontNameIndex() > { >- return _doc.getFontTable().getMainFont(_props.getFtcAscii()); >+ return _props.getFtcAscii(); > } > >+ public boolean isSpecialCharacter() >+ { >+ return _props.isFSpec(); >+ } >+ >+ public void setSpecialCharacter(boolean spec) >+ { >+ _props.setFSpec(spec); >+ >+ byte newVal = (byte)(spec ? 1 : 0); >+ _chpx.updateSprm(SPRM_FSPEC, newVal); >+ } >+ >+ public boolean isObj() >+ { >+ return _props.isFObj(); >+ } >+ >+ public void setObj(boolean obj) >+ { >+ _props.setFObj(obj); >+ >+ byte newVal = (byte)(obj ? 1 : 0); >+ _chpx.updateSprm(SPRM_FOBJ, newVal); >+ } >+ >+ public int getPicOffset() >+ { >+ return _props.getFcPic(); >+ } >+ >+ public void setPicOffset(int offset) >+ { >+ _props.setFcPic(offset); >+ _chpx.updateSprm(SPRM_PICLOCATION, offset); >+ } >+ >+ >+ public boolean isData() >+ { >+ return _props.isFData(); >+ } >+ >+ public void setData(boolean data) >+ { >+ _props.setFData(data); >+ >+ byte newVal = (byte)(data ? 1 : 0); >+ _chpx.updateSprm(SPRM_FOBJ, newVal); >+ } >+ >+ public boolean isOle2() >+ { >+ return _props.isFOle2(); >+ } >+ >+ public void setOle2(boolean ole) >+ { >+ _props.setFOle2(ole); >+ >+ byte newVal = (byte)(ole ? 1 : 0); >+ _chpx.updateSprm(SPRM_FOBJ, newVal); >+ } >+ >+ public int getObjOffset() >+ { >+ return _props.getFcObj(); >+ } >+ >+ public void setObjOffset(int obj) >+ { >+ _props.setFcObj(obj); >+ _chpx.updateSprm(SPRM_OBJLOCATION, obj); >+ } > > /** > * Get the ico24 field for the CHP record. >Index: hwpf/usermodel/Paragraph.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Paragraph.java,v >retrieving revision 1.7 >diff -u -r1.7 Paragraph.java >--- hwpf/usermodel/Paragraph.java 9 Apr 2004 13:05:33 -0000 1.7 >+++ hwpf/usermodel/Paragraph.java 21 Jul 2004 15:38:55 -0000 >@@ -14,7 +14,7 @@ > See the License for the specific language governing permissions and > limitations under the License. > ==================================================================== */ >- >+ > > package org.apache.poi.hwpf.usermodel; > >@@ -434,6 +434,16 @@ > _props.setDcs(dcs); > _papx.updateSprm(SPRM_DCS, dcs.toShort()); > } >+ >+ public int getIlfo() >+ { >+ return _props.getIlfo(); >+ } >+ >+ public int getIlvl() >+ { >+ return _props.getIlvl(); >+ } > > void setTableRowEnd(TableProperties props) > { >Index: hwpf/usermodel/Range.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java,v >retrieving revision 1.11 >diff -u -r1.11 Range.java >--- hwpf/usermodel/Range.java 11 Jul 2004 05:54:36 -0000 1.11 >+++ hwpf/usermodel/Range.java 21 Jul 2004 15:38:55 -0000 >@@ -252,7 +252,13 @@ > TextPiece piece = (TextPiece)_text.get(x); > int start = _start > piece.getStart() ? _start - piece.getStart() : 0; > int end = _end <= piece.getEnd() ? _end - piece.getStart() : piece.getEnd() - piece.getStart(); >- sb.append(piece.substring(start, end)); >+ >+ if(piece.usesUnicode()) // convert the byte pointers to char pointers >+ { >+ start/=2; >+ end/=2; >+ } >+ sb.append(piece.getStringBuffer().substring(start, end)); > } > return sb.toString(); > } >@@ -693,7 +699,8 @@ > r.initAll(); > int tableEnd = r._parEnd; > >- if (r._parStart != 0 && getParagraph(r._parStart - 1).isInTable()) >+ if (r._parStart != 0 && getParagraph(r._parStart - 1).isInTable() >+ && getParagraph(r._parStart - 1)._sectionEnd >= r._sectionStart) > { > throw new IllegalArgumentException("This paragraph is not the first one in the table"); > } >@@ -713,7 +720,7 @@ > throw new ArrayIndexOutOfBoundsException("The table's bounds fall outside of this Range"); > } > >- return new Table(r._parStart, tableEnd, r._doc.getRange(), 1); >+ return new Table(r._parStart, tableEnd, r._doc.getRange(), paragraph.getTableLevel()); > } > > /** >@@ -797,7 +804,7 @@ > { > int x = min; > PropertyNode node = (PropertyNode)rpl.get(x); >- while(node.getEnd() <= start) >+ while(node.getEnd() <= start && x < rpl.size()-1) > { > x++; > node = (PropertyNode)rpl.get(x); >@@ -805,7 +812,7 @@ > > int y = x; > node = (PropertyNode)rpl.get(y); >- while(node.getEnd() < end) >+ while(node.getEnd() < end && y < rpl.size()-1) > { > y++; > node = (PropertyNode)rpl.get(y); >Index: hwpf/usermodel/Table.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Table.java,v >retrieving revision 1.5 >diff -u -r1.5 Table.java >--- hwpf/usermodel/Table.java 11 Jul 2004 05:54:36 -0000 1.5 >+++ hwpf/usermodel/Table.java 21 Jul 2004 15:38:55 -0000 >@@ -36,12 +36,12 @@ > while (rowEnd < numParagraphs) > { > Paragraph p = getParagraph(rowEnd); >+ rowEnd++; > if (p.isTableRowEnd() && p.getTableLevel() == levelNum) > { >- _rows.add(new TableRow(rowStart, rowEnd + 1, this, levelNum)); >+ _rows.add(new TableRow(rowStart, rowEnd, this, levelNum)); > rowStart = rowEnd; > } >- rowEnd++; > } > } > >Index: hwpf/usermodel/TableRow.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java,v >retrieving revision 1.4 >diff -u -r1.4 TableRow.java >--- hwpf/usermodel/TableRow.java 9 Apr 2004 13:05:33 -0000 1.4 >+++ hwpf/usermodel/TableRow.java 21 Jul 2004 15:38:55 -0000 >@@ -14,7 +14,7 @@ > See the License for the specific language governing permissions and > limitations under the License. > ==================================================================== */ >- >+ > package org.apache.poi.hwpf.usermodel; > > import org.apache.poi.hwpf.sprm.TableSprmUncompressor; >@@ -51,7 +51,7 @@ > Paragraph p = getParagraph(start); > String s = p.text(); > >- while (! ( (levelNum == 1 && s.charAt(s.length() - 1) == TABLE_CELL_MARK) || >+ while (! ( (s.charAt(s.length() - 1) == TABLE_CELL_MARK) || > p.isEmbeddedCellMark() && p.getTableLevel() == levelNum)) > { > end++;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 30235
: 12182