public void setParentTextSize(int size) {
int pos = 0;
int textHandled = 0;
// While we have text in need of paragraph stylings, go ahead and
// grok the contents as paragraph formatting data
int prsize = size;
while(pos < rawContents.length && textHandled < prsize) {
// First up, fetch the number of characters this applies to
int textLen = LittleEndian.getInt(rawContents,pos);
textHandled += textLen;
pos += 4;
// Fetch the 2 byte value that is safe to ignore as 0
short paraIgn = LittleEndian.getShort(rawContents,pos);
pos += 2;
// Grab the 4 byte value that tells us what properties follow
int paraFlags = LittleEndian.getInt(rawContents,pos);
pos += 4;
// Now make sense of those properties
TextPropCollection thisCollection = new TextPropCollection(textLen, paraIgn);
int plSize = thisCollection.buildTextPropList(
paraFlags, paragraphTextPropTypes, rawContents, pos);
pos += plSize;
// Save this properties set
paragraphStyles.add(thisCollection);
// Handle extra 1 paragraph styles at the end
if(pos < rawContents.length && textHandled == size) {
prsize++;
}
}
if (rawContents.length > 0 && textHandled != (size+1)){
logger.log(POILogger.WARN, "Problem reading paragraph style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
}
// Now do the character stylings
textHandled = 0;
int chsize = size;
while(pos < rawContents.length && textHandled < chsize) {
// First up, fetch the number of characters this applies to
int textLen = LittleEndian.getInt(rawContents,pos);
textHandled += textLen;
pos += 4;
// There is no 2 byte value
short no_val = -1;
// Grab the 4 byte value that tells us what properties follow
int charFlags = LittleEndian.getInt(rawContents,pos);
pos += 4;
// Now make sense of those properties
// (Assuming we actually have some)
TextPropCollection thisCollection = new TextPropCollection(textLen, no_val);
int chSize = thisCollection.buildTextPropList(
charFlags, characterTextPropTypes, rawContents, pos);
pos += chSize;
// Save this properties set
charStyles.add(thisCollection);
// Handle extra 1 char styles at the end
if(pos < rawContents.length && textHandled == size) {
chsize++;
}
}
if (rawContents.length > 0 && textHandled != (size+1)){
logger.log(POILogger.WARN, "Problem reading character style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
}
// Handle anything left over
if(pos < rawContents.length) {
reserved = new byte[rawContents.length-pos];
System.arraycopy(rawContents,pos,reserved,0,reserved.length);
}
initialised = true;
}
Tell us how much text the parent TextCharsAtom or TextBytesAtom
contains, so we can go ahead and initialise ourselves. |