Lines 61-73
Link Here
|
61 |
int startAt = CPtoFC(node.getStart()); |
61 |
int startAt = CPtoFC(node.getStart()); |
62 |
int endAt = CPtoFC(node.getEnd()); |
62 |
int endAt = CPtoFC(node.getEnd()); |
63 |
|
63 |
|
64 |
boolean isUnicodeAtStart = tpt.isUnicodeAtByteOffset( startAt ); |
|
|
65 |
// System.err.println(startAt + " -> " + endAt + " = " + isUnicodeAtStart); |
66 |
|
67 |
// check for the optimization |
64 |
// check for the optimization |
68 |
if (fileOffset == 0xffffffff) |
65 |
if (fileOffset == 0xffffffff) |
69 |
{ |
66 |
{ |
70 |
_sections.add(new SEPX(sed, startAt, endAt, new byte[0], isUnicodeAtStart)); |
67 |
_sections.add(new SEPX(sed, startAt, endAt, tpt, new byte[0])); |
71 |
} |
68 |
} |
72 |
else |
69 |
else |
73 |
{ |
70 |
{ |
Lines 76-82
Link Here
|
76 |
byte[] buf = new byte[sepxSize]; |
73 |
byte[] buf = new byte[sepxSize]; |
77 |
fileOffset += LittleEndian.SHORT_SIZE; |
74 |
fileOffset += LittleEndian.SHORT_SIZE; |
78 |
System.arraycopy(documentStream, fileOffset, buf, 0, buf.length); |
75 |
System.arraycopy(documentStream, fileOffset, buf, 0, buf.length); |
79 |
_sections.add(new SEPX(sed, startAt, endAt, buf, isUnicodeAtStart)); |
76 |
_sections.add(new SEPX(sed, startAt, endAt, tpt, buf)); |
80 |
} |
77 |
} |
81 |
} |
78 |
} |
82 |
|
79 |
|
Lines 138-170
Link Here
|
138 |
} |
135 |
} |
139 |
int FC = TP.getPieceDescriptor().getFilePosition(); |
136 |
int FC = TP.getPieceDescriptor().getFilePosition(); |
140 |
int offset = CP - TP.getCP(); |
137 |
int offset = CP - TP.getCP(); |
141 |
FC = FC+offset-((TextPiece)_text.get(0)).getPieceDescriptor().getFilePosition(); |
138 |
if (TP.isUnicode()) { |
|
|
139 |
offset = offset*2; |
140 |
} |
141 |
FC = FC+offset; |
142 |
return FC; |
142 |
return FC; |
143 |
} |
143 |
} |
144 |
|
144 |
|
145 |
// Ryans code |
|
|
146 |
private int FCtoCP(int fc) |
147 |
{ |
148 |
int size = _text.size(); |
149 |
int cp = 0; |
150 |
for (int x = 0; x < size; x++) |
151 |
{ |
152 |
TextPiece piece = (TextPiece)_text.get(x); |
153 |
|
154 |
if (fc <= piece.getEnd()) |
155 |
{ |
156 |
cp += (fc - piece.getStart()); |
157 |
break; |
158 |
} |
159 |
else |
160 |
{ |
161 |
cp += (piece.getEnd() - piece.getStart()); |
162 |
} |
163 |
} |
164 |
return cp; |
165 |
} |
166 |
|
167 |
|
168 |
public ArrayList getSections() |
145 |
public ArrayList getSections() |
169 |
{ |
146 |
{ |
170 |
return _sections; |
147 |
return _sections; |
Lines 205-211
Link Here
|
205 |
|
182 |
|
206 |
// Line using Ryan's FCtoCP() conversion method - |
183 |
// Line using Ryan's FCtoCP() conversion method - |
207 |
// unable to observe any effect on our testcases when using this code - piers |
184 |
// unable to observe any effect on our testcases when using this code - piers |
208 |
GenericPropertyNode property = new GenericPropertyNode(FCtoCP(sepx.getStartBytes()), FCtoCP(sepx.getEndBytes()), sed.toByteArray()); |
185 |
GenericPropertyNode property = new GenericPropertyNode(tpt.getCharIndex(sepx.getStartBytes()), tpt.getCharIndex(sepx.getEndBytes()), sed.toByteArray()); |
209 |
|
186 |
|
210 |
|
187 |
|
211 |
plex.addProperty(property); |
188 |
plex.addProperty(property); |