public class TextPropCollection {
private int charactersCovered;
private short reservedField;
- private LinkedList textPropList;
+ private LinkedList<TextProp> textPropList;
private int maskSpecial = 0;
public int getSpecialMask() { return maskSpecial; }
/** Fetch the number of characters this styling applies to */
public int getCharactersCovered() { return charactersCovered; }
/** Fetch the TextProps that define this styling */
- public LinkedList getTextPropList() { return textPropList; }
+ public LinkedList<TextProp> getTextPropList() { return textPropList; }
/** Fetch the TextProp with this name, or null if it isn't present */
public TextProp findByName(String textPropName) {
for(int i=0; i<textPropList.size(); i++) {
- TextProp prop = (TextProp)textPropList.get(i);
+ TextProp prop = textPropList.get(i);
if(prop.getName().equals(textPropName)) {
return prop;
}
TextProp textProp = (TextProp)base.clone();
int pos = 0;
for(int i=0; i<textPropList.size(); i++) {
- TextProp curProp = (TextProp)textPropList.get(i);
+ TextProp curProp = textPropList.get(i);
if(textProp.getMask() > curProp.getMask()) {
pos++;
}
public TextPropCollection(int charactersCovered, short reservedField) {
this.charactersCovered = charactersCovered;
this.reservedField = reservedField;
- textPropList = new LinkedList();
+ textPropList = new LinkedList<TextProp>();
}
/**
public TextPropCollection(int textSize) {
charactersCovered = textSize;
reservedField = -1;
- textPropList = new LinkedList();
+ textPropList = new LinkedList<TextProp>();
}
/**
// Then the contents of all the properties
for(int i=0; i<textPropList.size(); i++) {
- TextProp textProp = (TextProp)textPropList.get(i);
+ TextProp textProp = textPropList.get(i);
int val = textProp.getValue();
if(textProp.getSize() == 2) {
StyleTextPropAtom.writeLittleEndian((short)val,o);
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Iterator;
import java.util.LinkedList;
import org.apache.poi.hslf.model.textproperties.AlignmentTextProp;
import org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp;
import org.apache.poi.hslf.model.textproperties.TextProp;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
+import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
-import org.apache.poi.util.HexDump;
/**
* A StyleTextPropAtom (type 4001). Holds basic character properties
* Characters the paragraph covers, and also contains the TextProps
* that actually define the styling of the paragraph.
*/
- private LinkedList paragraphStyles;
- public LinkedList getParagraphStyles() { return paragraphStyles; }
+ private LinkedList<TextPropCollection> paragraphStyles;
+ public LinkedList<TextPropCollection> getParagraphStyles() { return paragraphStyles; }
/**
* Updates the link list of TextPropCollections which make up the
* paragraph stylings
*/
- public void setParagraphStyles(LinkedList ps) { paragraphStyles = ps; }
+ public void setParagraphStyles(LinkedList<TextPropCollection> ps) { paragraphStyles = ps; }
/**
* The list of all the different character stylings we code for.
* Each entry is a TextPropCollection, which tells you how many
* Characters the character styling covers, and also contains the
* TextProps that actually define the styling of the characters.
*/
- private LinkedList charStyles;
- public LinkedList getCharacterStyles() { return charStyles; }
+ private LinkedList<TextPropCollection> charStyles;
+ public LinkedList<TextPropCollection> getCharacterStyles() { return charStyles; }
/**
* Updates the link list of TextPropCollections which make up the
* character stylings
*/
- public void setCharacterStyles(LinkedList cs) { charStyles = cs; }
+ public void setCharacterStyles(LinkedList<TextPropCollection> cs) { charStyles = cs; }
/**
* Returns how many characters the paragraph's
public int getCharacterTextLengthCovered() {
return getCharactersCovered(charStyles);
}
- private int getCharactersCovered(LinkedList styles) {
+ private int getCharactersCovered(LinkedList<TextPropCollection> styles) {
int length = 0;
- Iterator it = styles.iterator();
- while(it.hasNext()) {
- TextPropCollection tpc =
- (TextPropCollection)it.next();
+ for(TextPropCollection tpc : styles) {
length += tpc.getCharactersCovered();
}
return length;
reserved = new byte[0];
// Set empty linked lists, ready for when they call setParentTextSize
- paragraphStyles = new LinkedList();
- charStyles = new LinkedList();
+ paragraphStyles = new LinkedList<TextPropCollection>();
+ charStyles = new LinkedList<TextPropCollection>();
}
LittleEndian.putInt(_header,4,10);
// Set empty paragraph and character styles
- paragraphStyles = new LinkedList();
- charStyles = new LinkedList();
+ paragraphStyles = new LinkedList<TextPropCollection>();
+ charStyles = new LinkedList<TextPropCollection>();
TextPropCollection defaultParagraphTextProps =
new TextPropCollection(parentTextSize, (short)0);
// First up, we need to serialise the paragraph properties
for(int i=0; i<paragraphStyles.size(); i++) {
- TextPropCollection tpc = (TextPropCollection)paragraphStyles.get(i);
+ TextPropCollection tpc = paragraphStyles.get(i);
tpc.writeOut(baos);
}
// Now, we do the character ones
for(int i=0; i<charStyles.size(); i++) {
- TextPropCollection tpc = (TextPropCollection)charStyles.get(i);
+ TextPropCollection tpc = charStyles.get(i);
tpc.writeOut(baos);
}
out.append("Paragraph properties\n");
- for (Iterator it1 = getParagraphStyles().iterator(); it1.hasNext();) {
- TextPropCollection pr = (TextPropCollection)it1.next();
+ for(TextPropCollection pr : getParagraphStyles()) {
out.append(" chars covered: " + pr.getCharactersCovered());
out.append(" special mask flags: 0x" + HexDump.toHex(pr.getSpecialMask()) + "\n");
- for (Iterator it2 = pr.getTextPropList().iterator(); it2.hasNext(); ) {
- TextProp p = (TextProp)it2.next();
+ for(TextProp p : pr.getTextPropList()) {
out.append(" " + p.getName() + " = " + p.getValue() );
out.append(" (0x" + HexDump.toHex(p.getValue()) + ")\n");
}
}
out.append("Character properties\n");
- for (Iterator it1 = getCharacterStyles().iterator(); it1.hasNext();) {
- TextPropCollection pr = (TextPropCollection)it1.next();
+ for(TextPropCollection pr : getCharacterStyles()) {
out.append(" chars covered: " + pr.getCharactersCovered() );
out.append(" special mask flags: 0x" + HexDump.toHex(pr.getSpecialMask()) + "\n");
- for (Iterator it2 = pr.getTextPropList().iterator(); it2.hasNext(); ) {
- TextProp p = (TextProp)it2.next();
+ for(TextProp p : pr.getTextPropList()) {
out.append(" " + p.getName() + " = " + p.getValue() );
out.append(" (0x" + HexDump.toHex(p.getValue()) + ")\n");
}