mirror of https://github.com/apache/poi.git
wpf: More CharactedRun mapping fixes for fast-saved documents
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@979618 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
247f441b31
commit
0864608375
|
@ -35,7 +35,7 @@ public abstract class BytePropertyNode extends PropertyNode {
|
||||||
public BytePropertyNode(int fcStart, int fcEnd, CharIndexTranslator translator, Object buf) {
|
public BytePropertyNode(int fcStart, int fcEnd, CharIndexTranslator translator, Object buf) {
|
||||||
super(
|
super(
|
||||||
translator.getCharIndex(fcStart),
|
translator.getCharIndex(fcStart),
|
||||||
translator.getCharIndex(fcEnd),
|
translator.getCharIndex(fcEnd, translator.getCharIndex(fcStart)),
|
||||||
buf
|
buf
|
||||||
);
|
);
|
||||||
this.startBytes = fcStart;
|
this.startBytes = fcStart;
|
||||||
|
|
|
@ -27,6 +27,16 @@ public interface CharIndexTranslator {
|
||||||
*/
|
*/
|
||||||
int getCharIndex(int bytePos);
|
int getCharIndex(int bytePos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the char index of the given byte index.
|
||||||
|
* Look forward if index is not in table
|
||||||
|
*
|
||||||
|
* @param bytePos The character offset to check
|
||||||
|
* @param startCP look from this characted position
|
||||||
|
* @return the char index
|
||||||
|
*/
|
||||||
|
int getCharIndex(int bytePos, int startCP);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if index is in table
|
* Check if index is in table
|
||||||
*
|
*
|
||||||
|
|
|
@ -198,6 +198,10 @@ public class TextPieceTable implements CharIndexTranslator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCharIndex(int bytePos) {
|
public int getCharIndex(int bytePos) {
|
||||||
|
return getCharIndex(bytePos, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCharIndex(int bytePos, int startCP) {
|
||||||
int charCount = 0;
|
int charCount = 0;
|
||||||
|
|
||||||
bytePos = lookIndexForward(bytePos);
|
bytePos = lookIndexForward(bytePos);
|
||||||
|
@ -222,7 +226,7 @@ public class TextPieceTable implements CharIndexTranslator {
|
||||||
charCount += toAdd;
|
charCount += toAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytePos>=pieceStart && bytePos<=pieceEnd) {
|
if (bytePos>=pieceStart && bytePos<=pieceEnd && charCount>=startCP) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,4 +163,10 @@ public final class TestPictures extends TestCase {
|
||||||
doc.getPicturesTable().getAllPictures(); // just check that we do not throw Exception
|
doc.getPicturesTable().getAllPictures(); // just check that we do not throw Exception
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testFastSaved3() {
|
||||||
|
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("ob_is.doc");
|
||||||
|
|
||||||
|
doc.getPicturesTable().getAllPictures(); // just check that we do not throw Exception
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue