paragraphStyles = new LinkedList();
charStyles = new LinkedList();
- TextPropCollection defaultParagraphTextProps = new TextPropCollection(parentTextSize, (short)0);
+ TextPropCollection defaultParagraphTextProps =
+ new TextPropCollection(parentTextSize, (short)0);
paragraphStyles.add(defaultParagraphTextProps);
- TextPropCollection defaultCharacterTextProps = new TextPropCollection(parentTextSize);
+ TextPropCollection defaultCharacterTextProps =
+ new TextPropCollection(parentTextSize);
charStyles.add(defaultCharacterTextProps);
// Set us as now initialised
// Save this properties set
charStyles.add(thisCollection);
+
+ // Handle extra 1 char styles at the end
+ if(pos < rawContents.length && textHandled == size) {
+ size++;
+ }
}
// Handle anything left over
rawContents = baos.toByteArray();
}
+
+ /**
+ * Create a new Paragraph TextPropCollection, and add it to the list
+ * @param charactersCovered The number of characters this TextPropCollection will cover
+ * @return the new TextPropCollection, which will then be in the list
+ */
+ public TextPropCollection addParagraphTextPropCollection(int charactersCovered) {
+ TextPropCollection tpc = new TextPropCollection(charactersCovered, (short)0);
+ paragraphStyles.add(tpc);
+ return tpc;
+ }
+ /**
+ * Create a new Character TextPropCollection, and add it to the list
+ * @param charactersCovered The number of characters this TextPropCollection will cover
+ * @return the new TextPropCollection, which will then be in the list
+ */
+ public TextPropCollection addCharacterTextPropCollection(int charactersCovered) {
+ TextPropCollection tpc = new TextPropCollection(charactersCovered);
+ charStyles.add(tpc);
+ return tpc;
+ }
/* ************************************************************************ */
* Used to hold the number of characters affected, the list of active
* properties, and the random reserved field if required.
*/
- public static class TextPropCollection {
+ public class TextPropCollection {
private int charactersCovered;
private short reservedField;
private LinkedList textPropList;
return textProp;
}
- /**
- * Create a new collection of text properties (be they paragraph
- * or character) which will be groked via a subsequent call to
- * buildTextPropList().
- */
- public TextPropCollection(int charactersCovered, short reservedField) {
- this.charactersCovered = charactersCovered;
- this.reservedField = reservedField;
- textPropList = new LinkedList();
- }
-
/**
* For an existing set of text properties, build the list of
* properties coded for in a given run of properties.
return bytesPassed;
}
+ /**
+ * Create a new collection of text properties (be they paragraph
+ * or character) which will be groked via a subsequent call to
+ * buildTextPropList().
+ */
+ private TextPropCollection(int charactersCovered, short reservedField) {
+ this.charactersCovered = charactersCovered;
+ this.reservedField = reservedField;
+ textPropList = new LinkedList();
+ }
+
/**
* Create a new collection of text properties (be they paragraph
* or character) for a run of text without any
*/
- public TextPropCollection(int textSize) {
+ private TextPropCollection(int textSize) {
charactersCovered = textSize;
reservedField = -1;
textPropList = new LinkedList();
/**
* Writes out to disk the header, and then all the properties
*/
- private void writeOut(OutputStream o) throws IOException {
+ protected void writeOut(OutputStream o) throws IOException {
// First goes the number of characters we affect
writeLittleEndian(charactersCovered,o);
this.sizeOfDataBlock = sizeOfDataBlock;
this.maskInHeader = maskInHeader;
this.propName = propName;
+ this.dataValue = 0;
}
/**
this.propName = overallName;
subPropMasks = new int[subPropNames.length];
subPropMatches = new boolean[subPropNames.length];
+
+ // Initialise the masks list
+ for(int i=0; i<subPropMasks.length; i++) {
+ subPropMasks[i] = (1 << i);
+ }
}
/**
// Figure out the values of the sub properties
for(int i=0; i< subPropMatches.length; i++) {
- subPropMasks[i] = (1 << i);
subPropMatches[i] = false;
if((dataValue & subPropMasks[i]) != 0) {
subPropMatches[i] = true;