first commit

This commit is contained in:
MaddoScientisto 2026-03-14 20:04:39 +01:00
commit 4d332ef662
27586 changed files with 3281783 additions and 0 deletions

View file

@ -0,0 +1,7 @@
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.4.2_17-b06 (Sun Microsystems Inc.)
Main-Class: com.lowagie.tools.ToolboxAvailable
Class-Path: iText-toolbox.jar iText-toolbox-2.1.4.jar bcmail-jdk14-138
.jar bcprov-jdk14-138.jar

View file

@ -0,0 +1,125 @@
package com.lowagie.text;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
public class Anchor extends Phrase {
private static final long serialVersionUID = -852278536049236911L;
protected String name = null;
protected String reference = null;
public Anchor() {
super(16.0F);
}
public Anchor(float paramFloat) {
super(paramFloat);
}
public Anchor(Chunk paramChunk) {
super(paramChunk);
}
public Anchor(String paramString) {
super(paramString);
}
public Anchor(String paramString, Font paramFont) {
super(paramString, paramFont);
}
public Anchor(float paramFloat, Chunk paramChunk) {
super(paramFloat, paramChunk);
}
public Anchor(float paramFloat, String paramString) {
super(paramFloat, paramString);
}
public Anchor(float paramFloat, String paramString, Font paramFont) {
super(paramFloat, paramString, paramFont);
}
public Anchor(Phrase paramPhrase) {
super(paramPhrase);
if (paramPhrase instanceof Anchor) {
Anchor anchor = (Anchor)paramPhrase;
setName(anchor.name);
setReference(anchor.reference);
}
}
public boolean process(ElementListener paramElementListener) {
try {
Iterator iterator = getChunks().iterator();
boolean bool1 = (this.reference != null && this.reference.startsWith("#")) ? true : false;
boolean bool2 = true;
while (iterator.hasNext()) {
Chunk chunk = (Chunk)iterator.next();
if (this.name != null && bool2 && !chunk.isEmpty()) {
chunk.setLocalDestination(this.name);
bool2 = false;
}
if (bool1)
chunk.setLocalGoto(this.reference.substring(1));
paramElementListener.add(chunk);
}
return true;
} catch (DocumentException e) {
return false;
}
}
public ArrayList getChunks() {
ArrayList arrayList = new ArrayList();
Iterator iterator = iterator();
boolean bool1 = (this.reference != null && this.reference.startsWith("#")) ? true : false;
boolean bool2 = true;
while (iterator.hasNext()) {
Chunk chunk = (Chunk)iterator.next();
if (this.name != null && bool2 && !chunk.isEmpty()) {
chunk.setLocalDestination(this.name);
bool2 = false;
}
if (bool1) {
chunk.setLocalGoto(this.reference.substring(1));
} else if (this.reference != null) {
chunk.setAnchor(this.reference);
}
arrayList.add(chunk);
}
return arrayList;
}
public int type() {
return 17;
}
public void setName(String paramString) {
this.name = paramString;
}
public void setReference(String paramString) {
this.reference = paramString;
}
public String getName() {
return this.name;
}
public String getReference() {
return this.reference;
}
public URL getUrl() {
try {
return new URL(this.reference);
} catch (MalformedURLException e) {
return null;
}
}
}

View file

@ -0,0 +1,230 @@
package com.lowagie.text;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
public class Annotation implements Element {
public static final int TEXT = 0;
public static final int URL_NET = 1;
public static final int URL_AS_STRING = 2;
public static final int FILE_DEST = 3;
public static final int FILE_PAGE = 4;
public static final int NAMED_DEST = 5;
public static final int LAUNCH = 6;
public static final int SCREEN = 7;
public static final String TITLE = "title";
public static final String CONTENT = "content";
public static final String URL = "url";
public static final String FILE = "file";
public static final String DESTINATION = "destination";
public static final String PAGE = "page";
public static final String NAMED = "named";
public static final String APPLICATION = "application";
public static final String PARAMETERS = "parameters";
public static final String OPERATION = "operation";
public static final String DEFAULTDIR = "defaultdir";
public static final String LLX = "llx";
public static final String LLY = "lly";
public static final String URX = "urx";
public static final String URY = "ury";
public static final String MIMETYPE = "mime";
protected int annotationtype;
protected HashMap annotationAttributes = new HashMap();
protected float llx = Float.NaN;
protected float lly = Float.NaN;
protected float urx = Float.NaN;
protected float ury = Float.NaN;
private Annotation(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4) {
this.llx = paramFloat1;
this.lly = paramFloat2;
this.urx = paramFloat3;
this.ury = paramFloat4;
}
public Annotation(Annotation paramAnnotation) {
this.annotationtype = paramAnnotation.annotationtype;
this.annotationAttributes = paramAnnotation.annotationAttributes;
this.llx = paramAnnotation.llx;
this.lly = paramAnnotation.lly;
this.urx = paramAnnotation.urx;
this.ury = paramAnnotation.ury;
}
public Annotation(String paramString1, String paramString2) {
this.annotationtype = 0;
this.annotationAttributes.put("title", paramString1);
this.annotationAttributes.put("content", paramString2);
}
public Annotation(String paramString1, String paramString2, float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4) {
this(paramFloat1, paramFloat2, paramFloat3, paramFloat4);
this.annotationtype = 0;
this.annotationAttributes.put("title", paramString1);
this.annotationAttributes.put("content", paramString2);
}
public Annotation(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, URL paramURL) {
this(paramFloat1, paramFloat2, paramFloat3, paramFloat4);
this.annotationtype = 1;
this.annotationAttributes.put("url", paramURL);
}
public Annotation(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, String paramString) {
this(paramFloat1, paramFloat2, paramFloat3, paramFloat4);
this.annotationtype = 2;
this.annotationAttributes.put("file", paramString);
}
public Annotation(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, String paramString1, String paramString2) {
this(paramFloat1, paramFloat2, paramFloat3, paramFloat4);
this.annotationtype = 3;
this.annotationAttributes.put("file", paramString1);
this.annotationAttributes.put("destination", paramString2);
}
public Annotation(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, String paramString1, String paramString2, boolean paramBoolean) {
this(paramFloat1, paramFloat2, paramFloat3, paramFloat4);
this.annotationtype = 7;
this.annotationAttributes.put("file", paramString1);
this.annotationAttributes.put("mime", paramString2);
this.annotationAttributes.put("parameters", new boolean[] { false, paramBoolean });
}
public Annotation(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, String paramString, int paramInt) {
this(paramFloat1, paramFloat2, paramFloat3, paramFloat4);
this.annotationtype = 4;
this.annotationAttributes.put("file", paramString);
this.annotationAttributes.put("page", new Integer(paramInt));
}
public Annotation(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, int paramInt) {
this(paramFloat1, paramFloat2, paramFloat3, paramFloat4);
this.annotationtype = 5;
this.annotationAttributes.put("named", new Integer(paramInt));
}
public Annotation(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, String paramString1, String paramString2, String paramString3, String paramString4) {
this(paramFloat1, paramFloat2, paramFloat3, paramFloat4);
this.annotationtype = 6;
this.annotationAttributes.put("application", paramString1);
this.annotationAttributes.put("parameters", paramString2);
this.annotationAttributes.put("operation", paramString3);
this.annotationAttributes.put("defaultdir", paramString4);
}
public int type() {
return 29;
}
public boolean process(ElementListener paramElementListener) {
try {
return paramElementListener.add(this);
} catch (DocumentException e) {
return false;
}
}
public ArrayList getChunks() {
return new ArrayList();
}
public void setDimensions(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4) {
this.llx = paramFloat1;
this.lly = paramFloat2;
this.urx = paramFloat3;
this.ury = paramFloat4;
}
public float llx() {
return this.llx;
}
public float lly() {
return this.lly;
}
public float urx() {
return this.urx;
}
public float ury() {
return this.ury;
}
public float llx(float paramFloat) {
return Float.isNaN(this.llx) ? paramFloat : this.llx;
}
public float lly(float paramFloat) {
return Float.isNaN(this.lly) ? paramFloat : this.lly;
}
public float urx(float paramFloat) {
return Float.isNaN(this.urx) ? paramFloat : this.urx;
}
public float ury(float paramFloat) {
return Float.isNaN(this.ury) ? paramFloat : this.ury;
}
public int annotationType() {
return this.annotationtype;
}
public String title() {
String str = (String)this.annotationAttributes.get("title");
if (str == null)
str = "";
return str;
}
public String content() {
String str = (String)this.annotationAttributes.get("content");
if (str == null)
str = "";
return str;
}
public HashMap attributes() {
return this.annotationAttributes;
}
public boolean isContent() {
return true;
}
public boolean isNestable() {
return true;
}
}

View file

@ -0,0 +1,15 @@
package com.lowagie.text;
public class BadElementException extends DocumentException {
private static final long serialVersionUID = -799006030723822254L;
public BadElementException(Exception paramException) {
super(paramException);
}
BadElementException() {}
public BadElementException(String paramString) {
super(paramString);
}
}

View file

@ -0,0 +1,435 @@
package com.lowagie.text;
import com.lowagie.text.pdf.PdfPCell;
import java.util.ArrayList;
import java.util.Iterator;
public class Cell extends Rectangle implements TextElementArray {
protected ArrayList arrayList = null;
protected int horizontalAlignment = -1;
protected int verticalAlignment = -1;
protected float width;
protected boolean percentage = false;
protected int colspan = 1;
protected int rowspan = 1;
float leading = Float.NaN;
protected boolean header;
protected int maxLines = Integer.MAX_VALUE;
String showTruncation;
protected boolean useAscender = false;
protected boolean useDescender = false;
protected boolean useBorderPadding;
protected boolean groupChange = true;
public Cell() {
super(0.0F, 0.0F, 0.0F, 0.0F);
setBorder(-1);
setBorderWidth(0.5F);
this.arrayList = new ArrayList();
}
public Cell(boolean paramBoolean) {
this();
this.arrayList.add(new Paragraph(0.0F));
}
public Cell(String paramString) {
this();
try {
addElement(new Paragraph(paramString));
} catch (BadElementException e) {}
}
public Cell(Element paramElement) throws BadElementException {
this();
if (paramElement instanceof Phrase)
setLeading(((Phrase)paramElement).getLeading());
addElement(paramElement);
}
public boolean process(ElementListener paramElementListener) {
try {
return paramElementListener.add(this);
} catch (DocumentException e) {
return false;
}
}
public int type() {
return 20;
}
public ArrayList getChunks() {
ArrayList arrayList = new ArrayList();
Iterator iterator = this.arrayList.iterator();
while (iterator.hasNext())
arrayList.addAll(((Element)iterator.next()).getChunks());
return arrayList;
}
public int getHorizontalAlignment() {
return this.horizontalAlignment;
}
public void setHorizontalAlignment(int paramInt) {
this.horizontalAlignment = paramInt;
}
public void setHorizontalAlignment(String paramString) {
setHorizontalAlignment(ElementTags.alignmentValue(paramString));
}
public int getVerticalAlignment() {
return this.verticalAlignment;
}
public void setVerticalAlignment(int paramInt) {
this.verticalAlignment = paramInt;
}
public void setVerticalAlignment(String paramString) {
setVerticalAlignment(ElementTags.alignmentValue(paramString));
}
public void setWidth(float paramFloat) {
this.width = paramFloat;
}
public void setWidth(String paramString) {
if (paramString.endsWith("%")) {
paramString = paramString.substring(0, paramString.length() - 1);
this.percentage = true;
}
this.width = (float)Integer.parseInt(paramString);
}
public float getWidth() {
return this.width;
}
public String getWidthAsString() {
String str = String.valueOf(this.width);
if (str.endsWith(".0"))
str = str.substring(0, str.length() - 2);
if (this.percentage)
str = str + "%";
return str;
}
public void setColspan(int paramInt) {
this.colspan = paramInt;
}
public int getColspan() {
return this.colspan;
}
public void setRowspan(int paramInt) {
this.rowspan = paramInt;
}
public int getRowspan() {
return this.rowspan;
}
public void setLeading(float paramFloat) {
this.leading = paramFloat;
}
public float getLeading() {
return Float.isNaN(this.leading) ? 16.0F : this.leading;
}
public void setHeader(boolean paramBoolean) {
this.header = paramBoolean;
}
public boolean isHeader() {
return this.header;
}
public void setMaxLines(int paramInt) {
this.maxLines = paramInt;
}
public int getMaxLines() {
return this.maxLines;
}
public void setShowTruncation(String paramString) {
this.showTruncation = paramString;
}
public String getShowTruncation() {
return this.showTruncation;
}
public void setUseAscender(boolean paramBoolean) {
this.useAscender = paramBoolean;
}
public boolean isUseAscender() {
return this.useAscender;
}
public void setUseDescender(boolean paramBoolean) {
this.useDescender = paramBoolean;
}
public boolean isUseDescender() {
return this.useDescender;
}
public void setUseBorderPadding(boolean paramBoolean) {
this.useBorderPadding = paramBoolean;
}
public boolean isUseBorderPadding() {
return this.useBorderPadding;
}
public boolean getGroupChange() {
return this.groupChange;
}
public void setGroupChange(boolean paramBoolean) {
this.groupChange = paramBoolean;
}
public int size() {
return this.arrayList.size();
}
public Iterator getElements() {
return this.arrayList.iterator();
}
public void clear() {
this.arrayList.clear();
}
public boolean isEmpty() {
Element element;
switch (size()) {
case 0:
return true;
case 1:
element = (Element)this.arrayList.get(0);
switch (element.type()) {
case 10:
return ((Chunk)element).isEmpty();
case 11:
case 12:
case 17:
return ((Phrase)element).isEmpty();
case 14:
return ((List)element).isEmpty();
}
return false;
}
return false;
}
void fill() {
if (size() == 0)
this.arrayList.add(new Paragraph(0.0F));
}
public boolean isTable() {
return (size() == 1 && ((Element)this.arrayList.get(0)).type() == 22);
}
public void addElement(Element paramElement) throws BadElementException {
List list;
Phrase phrase;
Table table;
float[] arrayOfFloat;
Cell cell;
if (isTable()) {
Table table1 = (Table)this.arrayList.get(0);
Cell cell1 = new Cell(paramElement);
cell1.setBorder(0);
cell1.setColspan(table1.getColumns());
table1.addCell(cell1);
return;
}
switch (paramElement.type()) {
case 15:
case 20:
case 21:
throw new BadElementException("You can't add listitems, rows or cells to a cell.");
case 14:
list = (List)paramElement;
if (Float.isNaN(this.leading))
setLeading(list.getTotalLeading());
if (list.isEmpty())
return;
this.arrayList.add(paramElement);
return;
case 11:
case 12:
case 17:
phrase = (Phrase)paramElement;
if (Float.isNaN(this.leading))
setLeading(phrase.getLeading());
if (phrase.isEmpty())
return;
this.arrayList.add(paramElement);
return;
case 10:
if (((Chunk)paramElement).isEmpty())
return;
this.arrayList.add(paramElement);
return;
case 22:
table = new Table(3);
arrayOfFloat = new float[3];
arrayOfFloat[1] = ((Table)paramElement).getWidth();
switch (((Table)paramElement).getAlignment()) {
case 0:
arrayOfFloat[0] = 0.0F;
arrayOfFloat[2] = 100.0F - arrayOfFloat[1];
break;
case 1:
arrayOfFloat[0] = (100.0F - arrayOfFloat[1]) / 2.0F;
arrayOfFloat[2] = arrayOfFloat[0];
break;
case 2:
arrayOfFloat[0] = 100.0F - arrayOfFloat[1];
arrayOfFloat[2] = 0.0F;
break;
}
table.setWidths(arrayOfFloat);
if (this.arrayList.isEmpty()) {
table.addCell(getDummyCell());
} else {
Cell cell1 = new Cell();
cell1.setBorder(0);
cell1.setColspan(3);
Iterator iterator = this.arrayList.iterator();
while (iterator.hasNext())
cell1.add(iterator.next());
table.addCell(cell1);
}
cell = new Cell();
cell.setBorder(0);
table.addCell(cell);
table.insertTable((Table)paramElement);
cell = new Cell();
cell.setBorder(0);
table.addCell(cell);
table.addCell(getDummyCell());
clear();
this.arrayList.add(table);
return;
}
this.arrayList.add(paramElement);
}
public boolean add(Object paramObject) {
try {
addElement((Element)paramObject);
return true;
} catch (ClassCastException e) {
throw new ClassCastException("You can only add objects that implement the Element interface.");
} catch (BadElementException e) {
throw new ClassCastException(e.getMessage());
}
}
private static Cell getDummyCell() {
Cell cell = new Cell(true);
cell.setColspan(3);
cell.setBorder(0);
return cell;
}
public PdfPCell createPdfPCell() throws BadElementException {
if (this.rowspan > 1)
throw new BadElementException("PdfPCells can't have a rowspan > 1");
if (isTable())
return new PdfPCell(((Table)this.arrayList.get(0)).createPdfPTable());
PdfPCell pdfPCell = new PdfPCell();
pdfPCell.setVerticalAlignment(this.verticalAlignment);
pdfPCell.setHorizontalAlignment(this.horizontalAlignment);
pdfPCell.setColspan(this.colspan);
pdfPCell.setUseBorderPadding(this.useBorderPadding);
pdfPCell.setUseDescender(this.useDescender);
pdfPCell.setLeading(getLeading(), 0.0F);
pdfPCell.cloneNonPositionParameters(this);
pdfPCell.setNoWrap((getMaxLines() == 1));
Iterator iterator = getElements();
while (iterator.hasNext()) {
Element element = (Element)iterator.next();
if (element.type() == 11 || element.type() == 12) {
Paragraph paragraph = new Paragraph((Phrase)element);
paragraph.setAlignment(this.horizontalAlignment);
element = paragraph;
}
pdfPCell.addElement(element);
}
return pdfPCell;
}
public float getTop() {
throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");
}
public float getBottom() {
throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");
}
public float getLeft() {
throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");
}
public float getRight() {
throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");
}
public float top(int paramInt) {
throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");
}
public float bottom(int paramInt) {
throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");
}
public float left(int paramInt) {
throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");
}
public float right(int paramInt) {
throw new UnsupportedOperationException("Dimensions of a Cell can't be calculated. See the FAQ.");
}
public void setTop(int paramInt) {
throw new UnsupportedOperationException("Dimensions of a Cell are attributed automagically. See the FAQ.");
}
public void setBottom(int paramInt) {
throw new UnsupportedOperationException("Dimensions of a Cell are attributed automagically. See the FAQ.");
}
public void setLeft(int paramInt) {
throw new UnsupportedOperationException("Dimensions of a Cell are attributed automagically. See the FAQ.");
}
public void setRight(int paramInt) {
throw new UnsupportedOperationException("Dimensions of a Cell are attributed automagically. See the FAQ.");
}
}

View file

@ -0,0 +1,29 @@
package com.lowagie.text;
public class Chapter extends Section {
private static final long serialVersionUID = 1791000695779357361L;
public Chapter(int paramInt) {
super(null, 1);
this.numbers.add(new Integer(paramInt));
this.triggerNewPage = true;
}
public Chapter(Paragraph paramParagraph, int paramInt) {
super(paramParagraph, 1);
this.numbers.add(new Integer(paramInt));
this.triggerNewPage = true;
}
public Chapter(String paramString, int paramInt) {
this(new Paragraph(paramString), paramInt);
}
public int type() {
return 16;
}
public boolean isNestable() {
return false;
}
}

View file

@ -0,0 +1,35 @@
package com.lowagie.text;
public class ChapterAutoNumber extends Chapter {
private static final long serialVersionUID = -9217457637987854167L;
protected boolean numberSet = false;
public ChapterAutoNumber(Paragraph paramParagraph) {
super(paramParagraph, 0);
}
public ChapterAutoNumber(String paramString) {
super(paramString, 0);
}
public Section addSection(String paramString) {
if (isAddedCompletely())
throw new IllegalStateException("This LargeElement has already been added to the Document.");
return addSection(paramString, 2);
}
public Section addSection(Paragraph paramParagraph) {
if (isAddedCompletely())
throw new IllegalStateException("This LargeElement has already been added to the Document.");
return addSection(paramParagraph, 2);
}
public int setAutomaticNumber(int paramInt) {
if (!this.numberSet) {
setChapterNumber(++paramInt);
this.numberSet = true;
}
return paramInt;
}
}

View file

@ -0,0 +1,318 @@
package com.lowagie.text;
import com.lowagie.text.pdf.HyphenationEvent;
import com.lowagie.text.pdf.PdfAction;
import com.lowagie.text.pdf.PdfAnnotation;
import com.lowagie.text.pdf.draw.DrawInterface;
import java.awt.Color;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
public class Chunk implements Element {
public static final String OBJECT_REPLACEMENT_CHARACTER = "";
public static final Chunk NEWLINE = new Chunk("\n");
public static final Chunk NEXTPAGE = new Chunk("");
protected StringBuffer content = null;
protected Font font = null;
protected HashMap attributes = null;
public static final String SEPARATOR = "SEPARATOR";
public static final String TAB = "TAB";
public static final String HSCALE = "HSCALE";
public static final String UNDERLINE = "UNDERLINE";
public static final String SUBSUPSCRIPT = "SUBSUPSCRIPT";
public static final String SKEW = "SKEW";
public static final String BACKGROUND = "BACKGROUND";
public static final String TEXTRENDERMODE = "TEXTRENDERMODE";
public static final String SPLITCHARACTER = "SPLITCHARACTER";
public static final String HYPHENATION = "HYPHENATION";
public static final String REMOTEGOTO = "REMOTEGOTO";
public static final String LOCALGOTO = "LOCALGOTO";
public static final String LOCALDESTINATION = "LOCALDESTINATION";
public static final String GENERICTAG = "GENERICTAG";
public static final String IMAGE = "IMAGE";
public static final String ACTION = "ACTION";
public static final String NEWPAGE = "NEWPAGE";
public static final String PDFANNOTATION = "PDFANNOTATION";
public static final String COLOR = "COLOR";
public static final String ENCODING = "ENCODING";
public Chunk() {
this.content = new StringBuffer();
this.font = new Font();
}
public Chunk(Chunk paramChunk) {
if (paramChunk.content != null)
this.content = new StringBuffer(paramChunk.content.toString());
if (paramChunk.font != null)
this.font = new Font(paramChunk.font);
if (paramChunk.attributes != null)
this.attributes = new HashMap(paramChunk.attributes);
}
public Chunk(String paramString, Font paramFont) {
this.content = new StringBuffer(paramString);
this.font = paramFont;
}
public Chunk(String paramString) {
this(paramString, new Font());
}
public Chunk(char paramChar, Font paramFont) {
this.content = new StringBuffer();
this.content.append(paramChar);
this.font = paramFont;
}
public Chunk(char paramChar) {
this(paramChar, new Font());
}
public Chunk(Image paramImage, float paramFloat1, float paramFloat2) {
this("", new Font());
Image image = Image.getInstance(paramImage);
image.setAbsolutePosition(Float.NaN, Float.NaN);
setAttribute("IMAGE", new Object[] { image, new Float(paramFloat1), new Float(paramFloat2), Boolean.FALSE });
}
public Chunk(DrawInterface paramDrawInterface) {
this(paramDrawInterface, false);
}
public Chunk(DrawInterface paramDrawInterface, boolean paramBoolean) {
this("", new Font());
setAttribute("SEPARATOR", new Object[] { paramDrawInterface, Boolean.valueOf(paramBoolean) });
}
public Chunk(DrawInterface paramDrawInterface, float paramFloat) {
this(paramDrawInterface, paramFloat, false);
}
public Chunk(DrawInterface paramDrawInterface, float paramFloat, boolean paramBoolean) {
this("", new Font());
if (paramFloat < 0.0F)
throw new IllegalArgumentException("A tab position may not be lower than 0; yours is " + paramFloat);
setAttribute("TAB", new Object[] { paramDrawInterface, new Float(paramFloat), Boolean.valueOf(paramBoolean), new Float(0.0F) });
}
public Chunk(Image paramImage, float paramFloat1, float paramFloat2, boolean paramBoolean) {
this("", new Font());
setAttribute("IMAGE", new Object[] { paramImage, new Float(paramFloat1), new Float(paramFloat2), Boolean.valueOf(paramBoolean) });
}
public boolean process(ElementListener paramElementListener) {
try {
return paramElementListener.add(this);
} catch (DocumentException e) {
return false;
}
}
public int type() {
return 10;
}
public ArrayList getChunks() {
ArrayList arrayList = new ArrayList();
arrayList.add(this);
return arrayList;
}
public StringBuffer append(String paramString) {
return this.content.append(paramString);
}
public void setFont(Font paramFont) {
this.font = paramFont;
}
public Font getFont() {
return this.font;
}
public String getContent() {
return this.content.toString();
}
public String toString() {
return getContent();
}
public boolean isEmpty() {
return (this.content.toString().trim().length() == 0 && this.content.toString().indexOf("\n") == -1 && this.attributes == null);
}
public float getWidthPoint() {
return (getImage() != null) ? getImage().getScaledWidth() : (this.font.getCalculatedBaseFont(true).getWidthPoint(getContent(), this.font.getCalculatedSize()) * getHorizontalScaling());
}
public boolean hasAttributes() {
return (this.attributes != null);
}
public HashMap getAttributes() {
return this.attributes;
}
public void setAttributes(HashMap paramHashMap) {
this.attributes = paramHashMap;
}
private Chunk setAttribute(String paramString, Object paramObject) {
if (this.attributes == null)
this.attributes = new HashMap();
this.attributes.put(paramString, paramObject);
return this;
}
public Chunk setHorizontalScaling(float paramFloat) {
return setAttribute("HSCALE", new Float(paramFloat));
}
public float getHorizontalScaling() {
if (this.attributes == null)
return 1.0F;
Float float_ = (Float)this.attributes.get("HSCALE");
return (float_ == null) ? 1.0F : float_.floatValue();
}
public Chunk setUnderline(float paramFloat1, float paramFloat2) {
return setUnderline(null, paramFloat1, 0.0F, paramFloat2, 0.0F, 0);
}
public Chunk setUnderline(Color paramColor, float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, int paramInt) {
if (this.attributes == null)
this.attributes = new HashMap();
Object[] arrayOfObject = { paramColor, new float[] { paramFloat1, paramFloat2, paramFloat3, paramFloat4, (float)paramInt } };
Object[][] arrayOfObject1 = Utilities.addToArray((Object[][])this.attributes.get("UNDERLINE"), arrayOfObject);
return setAttribute("UNDERLINE", arrayOfObject1);
}
public Chunk setTextRise(float paramFloat) {
return setAttribute("SUBSUPSCRIPT", new Float(paramFloat));
}
public float getTextRise() {
if (this.attributes != null && this.attributes.containsKey("SUBSUPSCRIPT")) {
Float float_ = (Float)this.attributes.get("SUBSUPSCRIPT");
return float_.floatValue();
}
return 0.0F;
}
public Chunk setSkew(float paramFloat1, float paramFloat2) {
paramFloat1 = (float)Math.tan((double)paramFloat1 * Math.PI / 180.0D);
paramFloat2 = (float)Math.tan((double)paramFloat2 * Math.PI / 180.0D);
return setAttribute("SKEW", new float[] { paramFloat1, paramFloat2 });
}
public Chunk setBackground(Color paramColor) {
return setBackground(paramColor, 0.0F, 0.0F, 0.0F, 0.0F);
}
public Chunk setBackground(Color paramColor, float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4) {
return setAttribute("BACKGROUND", new Object[] { paramColor, new float[] { paramFloat1, paramFloat2, paramFloat3, paramFloat4 } });
}
public Chunk setTextRenderMode(int paramInt, float paramFloat, Color paramColor) {
return setAttribute("TEXTRENDERMODE", new Object[] { new Integer(paramInt), new Float(paramFloat), paramColor });
}
public Chunk setSplitCharacter(SplitCharacter paramSplitCharacter) {
return setAttribute("SPLITCHARACTER", paramSplitCharacter);
}
public Chunk setHyphenation(HyphenationEvent paramHyphenationEvent) {
return setAttribute("HYPHENATION", paramHyphenationEvent);
}
public Chunk setRemoteGoto(String paramString1, String paramString2) {
return setAttribute("REMOTEGOTO", new Object[] { paramString1, paramString2 });
}
public Chunk setRemoteGoto(String paramString, int paramInt) {
return setAttribute("REMOTEGOTO", new Object[] { paramString, new Integer(paramInt) });
}
public Chunk setLocalGoto(String paramString) {
return setAttribute("LOCALGOTO", paramString);
}
public Chunk setLocalDestination(String paramString) {
return setAttribute("LOCALDESTINATION", paramString);
}
public Chunk setGenericTag(String paramString) {
return setAttribute("GENERICTAG", paramString);
}
public Image getImage() {
if (this.attributes == null)
return null;
Object[] arrayOfObject = (Object[])this.attributes.get("IMAGE");
return (arrayOfObject == null) ? null : (Image)arrayOfObject[0];
}
public Chunk setAction(PdfAction paramPdfAction) {
return setAttribute("ACTION", paramPdfAction);
}
public Chunk setAnchor(URL paramURL) {
return setAttribute("ACTION", new PdfAction(paramURL.toExternalForm()));
}
public Chunk setAnchor(String paramString) {
return setAttribute("ACTION", new PdfAction(paramString));
}
public Chunk setNewPage() {
return setAttribute("NEWPAGE", null);
}
public Chunk setAnnotation(PdfAnnotation paramPdfAnnotation) {
return setAttribute("PDFANNOTATION", paramPdfAnnotation);
}
public boolean isContent() {
return true;
}
public boolean isNestable() {
return true;
}
public HyphenationEvent getHyphenation() {
return (this.attributes == null) ? null : (HyphenationEvent)this.attributes.get("HYPHENATION");
}
static {
NEXTPAGE.setNewPage();
}
}

View file

@ -0,0 +1,27 @@
package com.lowagie.text;
public interface DocListener extends ElementListener {
void open();
void close();
boolean newPage();
boolean setPageSize(Rectangle paramRectangle);
boolean setMargins(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4);
boolean setMarginMirroring(boolean paramBoolean);
void setPageCount(int paramInt);
void resetPageCount();
void setHeader(HeaderFooter paramHeaderFooter);
void resetHeader();
void setFooter(HeaderFooter paramHeaderFooter);
void resetFooter();
}

View file

@ -0,0 +1,180 @@
package com.lowagie.text;
import com.lowagie.text.pdf.OutputStreamCounter;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.Properties;
public abstract class DocWriter implements DocListener {
public static final byte NEWLINE = 10;
public static final byte TAB = 9;
public static final byte LT = 60;
public static final byte SPACE = 32;
public static final byte EQUALS = 61;
public static final byte QUOTE = 34;
public static final byte GT = 62;
public static final byte FORWARD = 47;
protected Rectangle pageSize;
protected Document document;
protected OutputStreamCounter os;
protected boolean open = false;
protected boolean pause = false;
protected boolean closeStream = true;
protected DocWriter() {}
protected DocWriter(Document paramDocument, OutputStream paramOutputStream) {
this.document = paramDocument;
this.os = new OutputStreamCounter(new BufferedOutputStream(paramOutputStream));
}
public boolean add(Element paramElement) throws DocumentException {
return false;
}
public void open() {
this.open = true;
}
public boolean setPageSize(Rectangle paramRectangle) {
this.pageSize = paramRectangle;
return true;
}
public boolean setMargins(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4) {
return false;
}
public boolean newPage() {
return !!this.open;
}
public void setHeader(HeaderFooter paramHeaderFooter) {}
public void resetHeader() {}
public void setFooter(HeaderFooter paramHeaderFooter) {}
public void resetFooter() {}
public void resetPageCount() {}
public void setPageCount(int paramInt) {}
public void close() {
this.open = false;
try {
this.os.flush();
if (this.closeStream)
this.os.close();
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
public static final byte[] getISOBytes(String paramString) {
if (paramString == null)
return null;
int i = paramString.length();
byte[] arrayOfByte = new byte[i];
for (int j = 0; j < i; j++)
arrayOfByte[j] = (byte)paramString.charAt(j);
return arrayOfByte;
}
public void pause() {
this.pause = true;
}
public boolean isPaused() {
return this.pause;
}
public void resume() {
this.pause = false;
}
public void flush() {
try {
this.os.flush();
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
protected void write(String paramString) throws IOException {
this.os.write(getISOBytes(paramString));
}
protected void addTabs(int paramInt) throws IOException {
this.os.write(10);
for (int i = 0; i < paramInt; i++)
this.os.write(9);
}
protected void write(String paramString1, String paramString2) throws IOException {
this.os.write(32);
write(paramString1);
this.os.write(61);
this.os.write(34);
write(paramString2);
this.os.write(34);
}
protected void writeStart(String paramString) throws IOException {
this.os.write(60);
write(paramString);
}
protected void writeEnd(String paramString) throws IOException {
this.os.write(60);
this.os.write(47);
write(paramString);
this.os.write(62);
}
protected void writeEnd() throws IOException {
this.os.write(32);
this.os.write(47);
this.os.write(62);
}
protected boolean writeMarkupAttributes(Properties paramProperties) throws IOException {
if (paramProperties == null)
return false;
Iterator iterator = paramProperties.keySet().iterator();
while (iterator.hasNext()) {
String str = String.valueOf(iterator.next());
write(str, paramProperties.getProperty(str));
}
paramProperties.clear();
return true;
}
public boolean isCloseStream() {
return this.closeStream;
}
public void setCloseStream(boolean paramBoolean) {
this.closeStream = paramBoolean;
}
public boolean setMarginMirroring(boolean paramBoolean) {
return false;
}
}

View file

@ -0,0 +1,372 @@
package com.lowagie.text;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
public class Document implements DocListener {
private static final String ITEXT_VERSION = "iText 2.1.4 (by lowagie.com)";
public static boolean compress = true;
public static boolean plainRandomAccess = false;
public static float wmfFontCorrection = 0.86F;
private ArrayList listeners = new ArrayList();
protected boolean open;
protected boolean close;
protected Rectangle pageSize;
protected float marginLeft = 0.0F;
protected float marginRight = 0.0F;
protected float marginTop = 0.0F;
protected float marginBottom = 0.0F;
protected boolean marginMirroring = false;
protected String javaScript_onLoad = null;
protected String javaScript_onUnLoad = null;
protected String htmlStyleClass = null;
protected int pageN = 0;
protected HeaderFooter header = null;
protected HeaderFooter footer = null;
protected int chapternumber = 0;
public Document() {
this(PageSize.A4);
}
public Document(Rectangle paramRectangle) {
this(paramRectangle, 36.0F, 36.0F, 36.0F, 36.0F);
}
public Document(Rectangle paramRectangle, float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4) {
this.pageSize = paramRectangle;
this.marginLeft = paramFloat1;
this.marginRight = paramFloat2;
this.marginTop = paramFloat3;
this.marginBottom = paramFloat4;
}
public void addDocListener(DocListener paramDocListener) {
this.listeners.add(paramDocListener);
}
public void removeDocListener(DocListener paramDocListener) {
this.listeners.remove(paramDocListener);
}
public boolean add(Element paramElement) throws DocumentException {
if (this.close)
throw new DocumentException("The document has been closed. You can't add any Elements.");
if (!this.open && paramElement.isContent())
throw new DocumentException("The document is not open yet; you can only add Meta information.");
boolean bool = false;
if (paramElement instanceof ChapterAutoNumber)
this.chapternumber = ((ChapterAutoNumber)paramElement).setAutomaticNumber(this.chapternumber);
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
bool |= docListener.add(paramElement);
}
if (paramElement instanceof LargeElement) {
LargeElement largeElement = (LargeElement)paramElement;
if (!largeElement.isComplete())
largeElement.flushContent();
}
return bool;
}
public void open() {
if (!this.close)
this.open = true;
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.setPageSize(this.pageSize);
docListener.setMargins(this.marginLeft, this.marginRight, this.marginTop, this.marginBottom);
docListener.open();
}
}
public boolean setPageSize(Rectangle paramRectangle) {
this.pageSize = paramRectangle;
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.setPageSize(paramRectangle);
}
return true;
}
public boolean setMargins(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4) {
this.marginLeft = paramFloat1;
this.marginRight = paramFloat2;
this.marginTop = paramFloat3;
this.marginBottom = paramFloat4;
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.setMargins(paramFloat1, paramFloat2, paramFloat3, paramFloat4);
}
return true;
}
public boolean newPage() {
if (!this.open || this.close)
return false;
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.newPage();
}
return true;
}
public void setHeader(HeaderFooter paramHeaderFooter) {
this.header = paramHeaderFooter;
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.setHeader(paramHeaderFooter);
}
}
public void resetHeader() {
this.header = null;
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.resetHeader();
}
}
public void setFooter(HeaderFooter paramHeaderFooter) {
this.footer = paramHeaderFooter;
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.setFooter(paramHeaderFooter);
}
}
public void resetFooter() {
this.footer = null;
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.resetFooter();
}
}
public void resetPageCount() {
this.pageN = 0;
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.resetPageCount();
}
}
public void setPageCount(int paramInt) {
this.pageN = paramInt;
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.setPageCount(paramInt);
}
}
public int getPageNumber() {
return this.pageN;
}
public void close() {
if (!this.close) {
this.open = false;
this.close = true;
}
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.close();
}
}
public boolean addHeader(String paramString1, String paramString2) {
try {
return add(new Header(paramString1, paramString2));
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
}
public boolean addTitle(String paramString) {
try {
return add(new Meta(1, paramString));
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
}
public boolean addSubject(String paramString) {
try {
return add(new Meta(2, paramString));
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
}
public boolean addKeywords(String paramString) {
try {
return add(new Meta(3, paramString));
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
}
public boolean addAuthor(String paramString) {
try {
return add(new Meta(4, paramString));
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
}
public boolean addCreator(String paramString) {
try {
return add(new Meta(7, paramString));
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
}
public boolean addProducer() {
try {
return add(new Meta(5, "iText by lowagie.com"));
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
}
public boolean addCreationDate() {
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
return add(new Meta(6, simpleDateFormat.format(new Date())));
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
}
public float leftMargin() {
return this.marginLeft;
}
public float rightMargin() {
return this.marginRight;
}
public float topMargin() {
return this.marginTop;
}
public float bottomMargin() {
return this.marginBottom;
}
public float left() {
return this.pageSize.getLeft(this.marginLeft);
}
public float right() {
return this.pageSize.getRight(this.marginRight);
}
public float top() {
return this.pageSize.getTop(this.marginTop);
}
public float bottom() {
return this.pageSize.getBottom(this.marginBottom);
}
public float left(float paramFloat) {
return this.pageSize.getLeft(this.marginLeft + paramFloat);
}
public float right(float paramFloat) {
return this.pageSize.getRight(this.marginRight + paramFloat);
}
public float top(float paramFloat) {
return this.pageSize.getTop(this.marginTop + paramFloat);
}
public float bottom(float paramFloat) {
return this.pageSize.getBottom(this.marginBottom + paramFloat);
}
public Rectangle getPageSize() {
return this.pageSize;
}
public boolean isOpen() {
return this.open;
}
public static final String getVersion() {
return "iText 2.1.4 (by lowagie.com)";
}
public void setJavaScript_onLoad(String paramString) {
this.javaScript_onLoad = paramString;
}
public String getJavaScript_onLoad() {
return this.javaScript_onLoad;
}
public void setJavaScript_onUnLoad(String paramString) {
this.javaScript_onUnLoad = paramString;
}
public String getJavaScript_onUnLoad() {
return this.javaScript_onUnLoad;
}
public void setHtmlStyleClass(String paramString) {
this.htmlStyleClass = paramString;
}
public String getHtmlStyleClass() {
return this.htmlStyleClass;
}
public boolean setMarginMirroring(boolean paramBoolean) {
this.marginMirroring = paramBoolean;
Iterator iterator = this.listeners.iterator();
while (iterator.hasNext()) {
DocListener docListener = (DocListener)iterator.next();
docListener.setMarginMirroring(paramBoolean);
}
return true;
}
public boolean isMarginMirroring() {
return this.marginMirroring;
}
}

View file

@ -0,0 +1,63 @@
package com.lowagie.text;
import java.io.PrintStream;
import java.io.PrintWriter;
public class DocumentException extends Exception {
private static final long serialVersionUID = -2191131489390840739L;
private Exception ex;
public DocumentException(Exception paramException) {
this.ex = paramException;
}
public DocumentException() {}
public DocumentException(String paramString) {
super(paramString);
}
public String getMessage() {
return (this.ex == null) ? super.getMessage() : this.ex.getMessage();
}
public String getLocalizedMessage() {
return (this.ex == null) ? super.getLocalizedMessage() : this.ex.getLocalizedMessage();
}
public String toString() {
return (this.ex == null) ? super.toString() : (split(getClass().getName()) + ": " + this.ex);
}
public void printStackTrace() {
printStackTrace(System.err);
}
public void printStackTrace(PrintStream paramPrintStream) {
if (this.ex == null) {
super.printStackTrace(paramPrintStream);
} else {
synchronized (paramPrintStream) {
paramPrintStream.print(split(getClass().getName()) + ": ");
this.ex.printStackTrace(paramPrintStream);
}
}
}
public void printStackTrace(PrintWriter paramPrintWriter) {
if (this.ex == null) {
super.printStackTrace(paramPrintWriter);
} else {
synchronized (paramPrintWriter) {
paramPrintWriter.print(split(getClass().getName()) + ": ");
this.ex.printStackTrace(paramPrintWriter);
}
}
}
private static String split(String paramString) {
int i = paramString.lastIndexOf('.');
return (i < 0) ? paramString : paramString.substring(i + 1);
}
}

View file

@ -0,0 +1,109 @@
package com.lowagie.text;
import java.util.ArrayList;
public interface Element {
public static final int HEADER = 0;
public static final int TITLE = 1;
public static final int SUBJECT = 2;
public static final int KEYWORDS = 3;
public static final int AUTHOR = 4;
public static final int PRODUCER = 5;
public static final int CREATIONDATE = 6;
public static final int CREATOR = 7;
public static final int CHUNK = 10;
public static final int PHRASE = 11;
public static final int PARAGRAPH = 12;
public static final int SECTION = 13;
public static final int LIST = 14;
public static final int LISTITEM = 15;
public static final int CHAPTER = 16;
public static final int ANCHOR = 17;
public static final int CELL = 20;
public static final int ROW = 21;
public static final int TABLE = 22;
public static final int PTABLE = 23;
public static final int ANNOTATION = 29;
public static final int RECTANGLE = 30;
public static final int JPEG = 32;
public static final int JPEG2000 = 33;
public static final int IMGRAW = 34;
public static final int IMGTEMPLATE = 35;
public static final int MULTI_COLUMN_TEXT = 40;
public static final int MARKED = 50;
public static final int YMARK = 55;
public static final int ALIGN_UNDEFINED = -1;
public static final int ALIGN_LEFT = 0;
public static final int ALIGN_CENTER = 1;
public static final int ALIGN_RIGHT = 2;
public static final int ALIGN_JUSTIFIED = 3;
public static final int ALIGN_TOP = 4;
public static final int ALIGN_MIDDLE = 5;
public static final int ALIGN_BOTTOM = 6;
public static final int ALIGN_BASELINE = 7;
public static final int ALIGN_JUSTIFIED_ALL = 8;
public static final int CCITTG4 = 256;
public static final int CCITTG3_1D = 257;
public static final int CCITTG3_2D = 258;
public static final int CCITT_BLACKIS1 = 1;
public static final int CCITT_ENCODEDBYTEALIGN = 2;
public static final int CCITT_ENDOFLINE = 4;
public static final int CCITT_ENDOFBLOCK = 8;
boolean process(ElementListener paramElementListener);
int type();
boolean isContent();
boolean isNestable();
ArrayList getChunks();
String toString();
}

View file

@ -0,0 +1,7 @@
package com.lowagie.text;
import java.util.EventListener;
public interface ElementListener extends EventListener {
boolean add(Element paramElement) throws DocumentException;
}

View file

@ -0,0 +1,280 @@
package com.lowagie.text;
public class ElementTags {
public static final String ITEXT = "itext";
public static final String TITLE = "title";
public static final String SUBJECT = "subject";
public static final String KEYWORDS = "keywords";
public static final String AUTHOR = "author";
public static final String CREATIONDATE = "creationdate";
public static final String PRODUCER = "producer";
public static final String CHAPTER = "chapter";
public static final String SECTION = "section";
public static final String NUMBERDEPTH = "numberdepth";
public static final String DEPTH = "depth";
public static final String NUMBER = "number";
public static final String INDENT = "indent";
public static final String LEFT = "left";
public static final String RIGHT = "right";
public static final String PHRASE = "phrase";
public static final String ANCHOR = "anchor";
public static final String LIST = "list";
public static final String LISTITEM = "listitem";
public static final String PARAGRAPH = "paragraph";
public static final String LEADING = "leading";
public static final String ALIGN = "align";
public static final String KEEPTOGETHER = "keeptogether";
public static final String NAME = "name";
public static final String REFERENCE = "reference";
public static final String LISTSYMBOL = "listsymbol";
public static final String NUMBERED = "numbered";
public static final String LETTERED = "lettered";
public static final String FIRST = "first";
public static final String SYMBOLINDENT = "symbolindent";
public static final String INDENTATIONLEFT = "indentationleft";
public static final String INDENTATIONRIGHT = "indentationright";
public static final String IGNORE = "ignore";
public static final String ENTITY = "entity";
public static final String ID = "id";
public static final String CHUNK = "chunk";
public static final String ENCODING = "encoding";
public static final String EMBEDDED = "embedded";
public static final String COLOR = "color";
public static final String RED = "red";
public static final String GREEN = "green";
public static final String BLUE = "blue";
public static final String SUBSUPSCRIPT = "SUBSUPSCRIPT".toLowerCase();
public static final String LOCALGOTO = "LOCALGOTO".toLowerCase();
public static final String REMOTEGOTO = "REMOTEGOTO".toLowerCase();
public static final String LOCALDESTINATION = "LOCALDESTINATION".toLowerCase();
public static final String GENERICTAG = "GENERICTAG".toLowerCase();
public static final String TABLE = "table";
public static final String ROW = "row";
public static final String CELL = "cell";
public static final String COLUMNS = "columns";
public static final String LASTHEADERROW = "lastHeaderRow";
public static final String CELLPADDING = "cellpadding";
public static final String CELLSPACING = "cellspacing";
public static final String OFFSET = "offset";
public static final String WIDTHS = "widths";
public static final String TABLEFITSPAGE = "tablefitspage";
public static final String CELLSFITPAGE = "cellsfitpage";
public static final String CONVERT2PDFP = "convert2pdfp";
public static final String HORIZONTALALIGN = "horizontalalign";
public static final String VERTICALALIGN = "verticalalign";
public static final String COLSPAN = "colspan";
public static final String ROWSPAN = "rowspan";
public static final String HEADER = "header";
public static final String NOWRAP = "nowrap";
public static final String BORDERWIDTH = "borderwidth";
public static final String TOP = "top";
public static final String BOTTOM = "bottom";
public static final String WIDTH = "width";
public static final String BORDERCOLOR = "bordercolor";
public static final String BACKGROUNDCOLOR = "backgroundcolor";
public static final String BGRED = "bgred";
public static final String BGGREEN = "bggreen";
public static final String BGBLUE = "bgblue";
public static final String GRAYFILL = "grayfill";
public static final String IMAGE = "image";
public static final String URL = "url";
public static final String UNDERLYING = "underlying";
public static final String TEXTWRAP = "textwrap";
public static final String ALT = "alt";
public static final String ABSOLUTEX = "absolutex";
public static final String ABSOLUTEY = "absolutey";
public static final String PLAINWIDTH = "plainwidth";
public static final String PLAINHEIGHT = "plainheight";
public static final String SCALEDWIDTH = "scaledwidth";
public static final String SCALEDHEIGHT = "scaledheight";
public static final String ROTATION = "rotation";
public static final String NEWPAGE = "newpage";
public static final String NEWLINE = "newline";
public static final String ANNOTATION = "annotation";
public static final String FILE = "file";
public static final String DESTINATION = "destination";
public static final String PAGE = "page";
public static final String NAMED = "named";
public static final String APPLICATION = "application";
public static final String PARAMETERS = "parameters";
public static final String OPERATION = "operation";
public static final String DEFAULTDIR = "defaultdir";
public static final String LLX = "llx";
public static final String LLY = "lly";
public static final String URX = "urx";
public static final String URY = "ury";
public static final String CONTENT = "content";
public static final String ALIGN_LEFT = "Left";
public static final String ALIGN_CENTER = "Center";
public static final String ALIGN_RIGHT = "Right";
public static final String ALIGN_JUSTIFIED = "Justify";
public static final String ALIGN_JUSTIFIED_ALL = "JustifyAll";
public static final String ALIGN_TOP = "Top";
public static final String ALIGN_MIDDLE = "Middle";
public static final String ALIGN_BOTTOM = "Bottom";
public static final String ALIGN_BASELINE = "Baseline";
public static final String DEFAULT = "Default";
public static final String UNKNOWN = "unknown";
public static final String FONT = "font";
public static final String SIZE = "size";
public static final String STYLE = "fontstyle";
public static final String HORIZONTALRULE = "horizontalrule";
public static final String PAGE_SIZE = "pagesize";
public static final String ORIENTATION = "orientation";
public static final String ALIGN_INDENTATION_ITEMS = "alignindent";
public static final String AUTO_INDENT_ITEMS = "autoindent";
public static final String LOWERCASE = "lowercase";
public static final String FACE = "face";
public static final String SRC = "src";
public static String getAlignment(int paramInt) {
switch (paramInt) {
case 0:
return "Left";
case 1:
return "Center";
case 2:
return "Right";
case 3:
case 8:
return "Justify";
case 4:
return "Top";
case 5:
return "Middle";
case 6:
return "Bottom";
case 7:
return "Baseline";
}
return "Default";
}
public static int alignmentValue(String paramString) {
return (paramString == null) ? -1 : ("Center".equalsIgnoreCase(paramString) ? 1 : ("Left".equalsIgnoreCase(paramString) ? 0 : ("Right".equalsIgnoreCase(paramString) ? 2 : ("Justify".equalsIgnoreCase(paramString) ? 3 : ("JustifyAll".equalsIgnoreCase(paramString) ? 8 : ("Top".equalsIgnoreCase(paramString) ? 4 : ("Middle".equalsIgnoreCase(paramString) ? 5 : ("Bottom".equalsIgnoreCase(paramString) ? 6 : ("Baseline".equalsIgnoreCase(paramString) ? 7 : -1)))))))));
}
}

View file

@ -0,0 +1,55 @@
package com.lowagie.text;
import java.io.PrintStream;
import java.io.PrintWriter;
public class ExceptionConverter extends RuntimeException {
private static final long serialVersionUID = 8657630363395849399L;
private Exception ex;
private String prefix;
public ExceptionConverter(Exception paramException) {
this.ex = paramException;
this.prefix = (paramException instanceof RuntimeException) ? "" : "ExceptionConverter: ";
}
public Exception getException() {
return this.ex;
}
public String getMessage() {
return this.ex.getMessage();
}
public String getLocalizedMessage() {
return this.ex.getLocalizedMessage();
}
public String toString() {
return this.prefix + this.ex;
}
public void printStackTrace() {
printStackTrace(System.err);
}
public void printStackTrace(PrintStream paramPrintStream) {
synchronized (paramPrintStream) {
paramPrintStream.print(this.prefix);
this.ex.printStackTrace(paramPrintStream);
}
}
public void printStackTrace(PrintWriter paramPrintWriter) {
synchronized (paramPrintWriter) {
paramPrintWriter.print(this.prefix);
this.ex.printStackTrace(paramPrintWriter);
}
}
public Throwable fillInStackTrace() {
return this;
}
}

View file

@ -0,0 +1,331 @@
package com.lowagie.text;
import com.lowagie.text.pdf.BaseFont;
import java.awt.Color;
public class Font implements Comparable {
public static final int COURIER = 0;
public static final int HELVETICA = 1;
public static final int TIMES_ROMAN = 2;
public static final int SYMBOL = 3;
public static final int ZAPFDINGBATS = 4;
public static final int NORMAL = 0;
public static final int BOLD = 1;
public static final int ITALIC = 2;
public static final int UNDERLINE = 4;
public static final int STRIKETHRU = 8;
public static final int BOLDITALIC = 3;
public static final int UNDEFINED = -1;
public static final int DEFAULTSIZE = 12;
private int family = -1;
private float size = -1.0F;
private int style = -1;
private Color color = null;
private BaseFont baseFont = null;
public Font(Font paramFont) {
this.family = paramFont.family;
this.size = paramFont.size;
this.style = paramFont.style;
this.color = paramFont.color;
this.baseFont = paramFont.baseFont;
}
public Font(int paramInt1, float paramFloat, int paramInt2, Color paramColor) {
this.family = paramInt1;
this.size = paramFloat;
this.style = paramInt2;
this.color = paramColor;
}
public Font(BaseFont paramBaseFont, float paramFloat, int paramInt, Color paramColor) {
this.baseFont = paramBaseFont;
this.size = paramFloat;
this.style = paramInt;
this.color = paramColor;
}
public Font(BaseFont paramBaseFont, float paramFloat, int paramInt) {
this(paramBaseFont, paramFloat, paramInt, null);
}
public Font(BaseFont paramBaseFont, float paramFloat) {
this(paramBaseFont, paramFloat, -1, null);
}
public Font(BaseFont paramBaseFont) {
this(paramBaseFont, -1.0F, -1, null);
}
public Font(int paramInt1, float paramFloat, int paramInt2) {
this(paramInt1, paramFloat, paramInt2, null);
}
public Font(int paramInt, float paramFloat) {
this(paramInt, paramFloat, -1, null);
}
public Font(int paramInt) {
this(paramInt, -1.0F, -1, null);
}
public Font() {
this(-1, -1.0F, -1, null);
}
public int compareTo(Object paramObject) {
if (paramObject == null)
return -1;
try {
Font font = (Font)paramObject;
return (this.baseFont != null && !this.baseFont.equals(font.getBaseFont())) ? -2 : ((this.family != font.getFamily()) ? 1 : ((this.size != font.getSize()) ? 2 : ((this.style != font.getStyle()) ? 3 : ((this.color == null) ? ((font.color == null) ? 0 : 4) : ((font.color == null) ? 4 : (this.color.equals(font.getColor()) ? 0 : 4))))));
} catch (ClassCastException e) {
return -3;
}
}
public int getFamily() {
return this.family;
}
public String getFamilyname() {
String str = "unknown";
switch (getFamily()) {
case 0:
return "Courier";
case 1:
return "Helvetica";
case 2:
return "Times-Roman";
case 3:
return "Symbol";
case 4:
return "ZapfDingbats";
}
if (this.baseFont != null) {
String[][] arrayOfString = this.baseFont.getFamilyFontName();
for (int i = 0; i < arrayOfString.length; i++) {
if ("0".equals(arrayOfString[i][2]))
return arrayOfString[i][3];
if ("1033".equals(arrayOfString[i][2]))
str = arrayOfString[i][3];
if ("".equals(arrayOfString[i][2]))
str = arrayOfString[i][3];
}
}
return str;
}
public void setFamily(String paramString) {
this.family = getFamilyIndex(paramString);
}
public static int getFamilyIndex(String paramString) {
return paramString.equalsIgnoreCase("Courier") ? 0 : (paramString.equalsIgnoreCase("Helvetica") ? 1 : (paramString.equalsIgnoreCase("Times-Roman") ? 2 : (paramString.equalsIgnoreCase("Symbol") ? 3 : (paramString.equalsIgnoreCase("ZapfDingbats") ? 4 : -1))));
}
public float getSize() {
return this.size;
}
public float getCalculatedSize() {
float f = this.size;
if (f == -1.0F)
f = 12.0F;
return f;
}
public float getCalculatedLeading(float paramFloat) {
return paramFloat * getCalculatedSize();
}
public void setSize(float paramFloat) {
this.size = paramFloat;
}
public int getStyle() {
return this.style;
}
public int getCalculatedStyle() {
int i = this.style;
if (i == -1)
i = 0;
return (this.baseFont != null) ? i : ((this.family == 3 || this.family == 4) ? i : (i & 0xFFFFFFFC));
}
public boolean isBold() {
return (this.style == -1) ? false : (((this.style & 0x1) == 1));
}
public boolean isItalic() {
return (this.style == -1) ? false : (((this.style & 0x2) == 2));
}
public boolean isUnderlined() {
return (this.style == -1) ? false : (((this.style & 0x4) == 4));
}
public boolean isStrikethru() {
return (this.style == -1) ? false : (((this.style & 0x8) == 8));
}
public void setStyle(int paramInt) {
if (this.style == -1)
this.style = 0;
this.style |= paramInt;
}
public void setStyle(String paramString) {
if (this.style == -1)
this.style = 0;
this.style |= getStyleValue(paramString);
}
public static int getStyleValue(String paramString) {
int i = 0;
if (paramString.indexOf("normal") != -1)
i |= false;
if (paramString.indexOf("bold") != -1)
i |= true;
if (paramString.indexOf("italic") != -1)
i |= 0x2;
if (paramString.indexOf("oblique") != -1)
i |= 0x2;
if (paramString.indexOf("underline") != -1)
i |= 0x4;
if (paramString.indexOf("line-through") != -1)
i |= 0x8;
return i;
}
public Color getColor() {
return this.color;
}
public void setColor(Color paramColor) {
this.color = paramColor;
}
public void setColor(int paramInt1, int paramInt2, int paramInt3) {
this.color = new Color(paramInt1, paramInt2, paramInt3);
}
public BaseFont getBaseFont() {
return this.baseFont;
}
public BaseFont getCalculatedBaseFont(boolean paramBoolean) {
if (this.baseFont != null)
return this.baseFont;
int i = this.style;
if (i == -1)
i = 0;
String str1 = "Helvetica";
String str2 = "Cp1252";
BaseFont baseFont = null;
switch (this.family) {
case 0:
switch (i & 0x3) {
case 1:
str1 = "Courier-Bold";
break;
case 2:
str1 = "Courier-Oblique";
break;
case 3:
str1 = "Courier-BoldOblique";
break;
}
str1 = "Courier";
break;
case 2:
switch (i & 0x3) {
case 1:
str1 = "Times-Bold";
break;
case 2:
str1 = "Times-Italic";
break;
case 3:
str1 = "Times-BoldItalic";
break;
}
str1 = "Times-Roman";
break;
case 3:
str1 = "Symbol";
if (paramBoolean)
str2 = "Symbol";
break;
case 4:
str1 = "ZapfDingbats";
if (paramBoolean)
str2 = "ZapfDingbats";
break;
default:
switch (i & 0x3) {
case 1:
str1 = "Helvetica-Bold";
break;
case 2:
str1 = "Helvetica-Oblique";
break;
case 3:
str1 = "Helvetica-BoldOblique";
break;
}
str1 = "Helvetica";
break;
}
try {
baseFont = BaseFont.createFont(str1, str2, false);
} catch (Exception e) {
throw new ExceptionConverter(e);
}
return baseFont;
}
public boolean isStandardFont() {
return (this.family == -1 && this.size == -1.0F && this.style == -1 && this.color == null && this.baseFont == null);
}
public Font difference(Font paramFont) {
if (paramFont == null)
return this;
float f = paramFont.size;
if (f == -1.0F)
f = this.size;
int i = -1;
int j = this.style;
int k = paramFont.getStyle();
if (j != -1 || k != -1) {
if (j == -1)
j = 0;
if (k == -1)
k = 0;
i = j | k;
}
Color color = paramFont.color;
if (color == null)
color = this.color;
return (paramFont.baseFont != null) ? new Font(paramFont.baseFont, f, i, color) : ((paramFont.getFamily() != -1) ? new Font(paramFont.family, f, i, color) : ((this.baseFont != null) ? ((i == j) ? new Font(this.baseFont, f, i, color) : FontFactory.getFont(getFamilyname(), f, i, color)) : new Font(this.family, f, i, color)));
}
}

View file

@ -0,0 +1,155 @@
package com.lowagie.text;
import java.awt.Color;
import java.util.Properties;
import java.util.Set;
public final class FontFactory {
public static final String COURIER = "Courier";
public static final String COURIER_BOLD = "Courier-Bold";
public static final String COURIER_OBLIQUE = "Courier-Oblique";
public static final String COURIER_BOLDOBLIQUE = "Courier-BoldOblique";
public static final String HELVETICA = "Helvetica";
public static final String HELVETICA_BOLD = "Helvetica-Bold";
public static final String HELVETICA_OBLIQUE = "Helvetica-Oblique";
public static final String HELVETICA_BOLDOBLIQUE = "Helvetica-BoldOblique";
public static final String SYMBOL = "Symbol";
public static final String TIMES = "Times";
public static final String TIMES_ROMAN = "Times-Roman";
public static final String TIMES_BOLD = "Times-Bold";
public static final String TIMES_ITALIC = "Times-Italic";
public static final String TIMES_BOLDITALIC = "Times-BoldItalic";
public static final String ZAPFDINGBATS = "ZapfDingbats";
private static FontFactoryImp fontImp = new FontFactoryImp();
public static String defaultEncoding = "Cp1252";
public static boolean defaultEmbedding = false;
public static Font getFont(String paramString1, String paramString2, boolean paramBoolean, float paramFloat, int paramInt, Color paramColor) {
return fontImp.getFont(paramString1, paramString2, paramBoolean, paramFloat, paramInt, paramColor);
}
public static Font getFont(String paramString1, String paramString2, boolean paramBoolean1, float paramFloat, int paramInt, Color paramColor, boolean paramBoolean2) {
return fontImp.getFont(paramString1, paramString2, paramBoolean1, paramFloat, paramInt, paramColor, paramBoolean2);
}
public static Font getFont(Properties paramProperties) {
fontImp.defaultEmbedding = defaultEmbedding;
fontImp.defaultEncoding = defaultEncoding;
return fontImp.getFont(paramProperties);
}
public static Font getFont(String paramString1, String paramString2, boolean paramBoolean, float paramFloat, int paramInt) {
return getFont(paramString1, paramString2, paramBoolean, paramFloat, paramInt, null);
}
public static Font getFont(String paramString1, String paramString2, boolean paramBoolean, float paramFloat) {
return getFont(paramString1, paramString2, paramBoolean, paramFloat, -1, null);
}
public static Font getFont(String paramString1, String paramString2, boolean paramBoolean) {
return getFont(paramString1, paramString2, paramBoolean, -1.0F, -1, null);
}
public static Font getFont(String paramString1, String paramString2, float paramFloat, int paramInt, Color paramColor) {
return getFont(paramString1, paramString2, defaultEmbedding, paramFloat, paramInt, paramColor);
}
public static Font getFont(String paramString1, String paramString2, float paramFloat, int paramInt) {
return getFont(paramString1, paramString2, defaultEmbedding, paramFloat, paramInt, null);
}
public static Font getFont(String paramString1, String paramString2, float paramFloat) {
return getFont(paramString1, paramString2, defaultEmbedding, paramFloat, -1, null);
}
public static Font getFont(String paramString1, String paramString2) {
return getFont(paramString1, paramString2, defaultEmbedding, -1.0F, -1, null);
}
public static Font getFont(String paramString, float paramFloat, int paramInt, Color paramColor) {
return getFont(paramString, defaultEncoding, defaultEmbedding, paramFloat, paramInt, paramColor);
}
public static Font getFont(String paramString, float paramFloat, Color paramColor) {
return getFont(paramString, defaultEncoding, defaultEmbedding, paramFloat, -1, paramColor);
}
public static Font getFont(String paramString, float paramFloat, int paramInt) {
return getFont(paramString, defaultEncoding, defaultEmbedding, paramFloat, paramInt, null);
}
public static Font getFont(String paramString, float paramFloat) {
return getFont(paramString, defaultEncoding, defaultEmbedding, paramFloat, -1, null);
}
public static Font getFont(String paramString) {
return getFont(paramString, defaultEncoding, defaultEmbedding, -1.0F, -1, null);
}
public void registerFamily(String paramString1, String paramString2, String paramString3) {
fontImp.registerFamily(paramString1, paramString2, paramString3);
}
public static void register(String paramString) {
register(paramString, null);
}
public static void register(String paramString1, String paramString2) {
fontImp.register(paramString1, paramString2);
}
public static int registerDirectory(String paramString) {
return fontImp.registerDirectory(paramString);
}
public static int registerDirectory(String paramString, boolean paramBoolean) {
return fontImp.registerDirectory(paramString, paramBoolean);
}
public static int registerDirectories() {
return fontImp.registerDirectories();
}
public static Set getRegisteredFonts() {
return fontImp.getRegisteredFonts();
}
public static Set getRegisteredFamilies() {
return fontImp.getRegisteredFamilies();
}
public static boolean contains(String paramString) {
return fontImp.isRegistered(paramString);
}
public static boolean isRegistered(String paramString) {
return fontImp.isRegistered(paramString);
}
public static FontFactoryImp getFontImp() {
return fontImp;
}
public static void setFontImp(FontFactoryImp paramFontFactoryImp) {
if (paramFontFactoryImp == null)
throw new NullPointerException("FontFactoryImp cannot be null.");
fontImp = paramFontFactoryImp;
}
}

View file

@ -0,0 +1,394 @@
package com.lowagie.text;
import com.lowagie.text.html.Markup;
import com.lowagie.text.pdf.BaseFont;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
public class FontFactoryImp {
private Properties trueTypeFonts = new Properties();
private static String[] TTFamilyOrder = new String[] {
"3", "1", "1033", "3", "0", "1033", "1", "0", "0", "0",
"3", "0" };
private Hashtable fontFamilies = new Hashtable();
public String defaultEncoding = "Cp1252";
public boolean defaultEmbedding = false;
public FontFactoryImp() {
this.trueTypeFonts.setProperty("Courier".toLowerCase(), "Courier");
this.trueTypeFonts.setProperty("Courier-Bold".toLowerCase(), "Courier-Bold");
this.trueTypeFonts.setProperty("Courier-Oblique".toLowerCase(), "Courier-Oblique");
this.trueTypeFonts.setProperty("Courier-BoldOblique".toLowerCase(), "Courier-BoldOblique");
this.trueTypeFonts.setProperty("Helvetica".toLowerCase(), "Helvetica");
this.trueTypeFonts.setProperty("Helvetica-Bold".toLowerCase(), "Helvetica-Bold");
this.trueTypeFonts.setProperty("Helvetica-Oblique".toLowerCase(), "Helvetica-Oblique");
this.trueTypeFonts.setProperty("Helvetica-BoldOblique".toLowerCase(), "Helvetica-BoldOblique");
this.trueTypeFonts.setProperty("Symbol".toLowerCase(), "Symbol");
this.trueTypeFonts.setProperty("Times-Roman".toLowerCase(), "Times-Roman");
this.trueTypeFonts.setProperty("Times-Bold".toLowerCase(), "Times-Bold");
this.trueTypeFonts.setProperty("Times-Italic".toLowerCase(), "Times-Italic");
this.trueTypeFonts.setProperty("Times-BoldItalic".toLowerCase(), "Times-BoldItalic");
this.trueTypeFonts.setProperty("ZapfDingbats".toLowerCase(), "ZapfDingbats");
ArrayList arrayList = new ArrayList();
arrayList.add("Courier");
arrayList.add("Courier-Bold");
arrayList.add("Courier-Oblique");
arrayList.add("Courier-BoldOblique");
this.fontFamilies.put("Courier".toLowerCase(), arrayList);
arrayList = new ArrayList();
arrayList.add("Helvetica");
arrayList.add("Helvetica-Bold");
arrayList.add("Helvetica-Oblique");
arrayList.add("Helvetica-BoldOblique");
this.fontFamilies.put("Helvetica".toLowerCase(), arrayList);
arrayList = new ArrayList();
arrayList.add("Symbol");
this.fontFamilies.put("Symbol".toLowerCase(), arrayList);
arrayList = new ArrayList();
arrayList.add("Times-Roman");
arrayList.add("Times-Bold");
arrayList.add("Times-Italic");
arrayList.add("Times-BoldItalic");
this.fontFamilies.put("Times".toLowerCase(), arrayList);
this.fontFamilies.put("Times-Roman".toLowerCase(), arrayList);
arrayList = new ArrayList();
arrayList.add("ZapfDingbats");
this.fontFamilies.put("ZapfDingbats".toLowerCase(), arrayList);
}
public Font getFont(String paramString1, String paramString2, boolean paramBoolean, float paramFloat, int paramInt, Color paramColor) {
return getFont(paramString1, paramString2, paramBoolean, paramFloat, paramInt, paramColor, true);
}
public Font getFont(String paramString1, String paramString2, boolean paramBoolean1, float paramFloat, int paramInt, Color paramColor, boolean paramBoolean2) {
if (paramString1 == null)
return new Font(-1, paramFloat, paramInt, paramColor);
String str = paramString1.toLowerCase();
ArrayList arrayList = (ArrayList)this.fontFamilies.get(str);
if (arrayList != null) {
int i = (paramInt == -1) ? 0 : paramInt;
int j = 0;
boolean bool = false;
Iterator iterator = arrayList.iterator();
while (iterator.hasNext()) {
String str1 = (String)iterator.next();
String str2 = str1.toLowerCase();
j = 0;
if (str2.toLowerCase().indexOf("bold") != -1)
j |= true;
if (str2.toLowerCase().indexOf("italic") != -1 || str2.toLowerCase().indexOf("oblique") != -1)
j |= 0x2;
if ((i & 0x3) == j) {
paramString1 = str1;
bool = true;
break;
}
}
if (paramInt != -1 && bool)
paramInt &= j ^ 0xFFFFFFFF;
}
BaseFont baseFont = null;
try {
try {
baseFont = BaseFont.createFont(paramString1, paramString2, paramBoolean1, paramBoolean2, null, null, true);
} catch (DocumentException e) {}
if (baseFont == null) {
paramString1 = this.trueTypeFonts.getProperty(paramString1.toLowerCase());
if (paramString1 == null)
return new Font(-1, paramFloat, paramInt, paramColor);
baseFont = BaseFont.createFont(paramString1, paramString2, paramBoolean1, paramBoolean2, null, null);
}
} catch (DocumentException e) {
throw new ExceptionConverter(e);
} catch (IOException e) {
return new Font(-1, paramFloat, paramInt, paramColor);
} catch (NullPointerException e) {
return new Font(-1, paramFloat, paramInt, paramColor);
}
return new Font(baseFont, paramFloat, paramInt, paramColor);
}
public Font getFont(Properties paramProperties) {
String str1 = null;
String str2 = this.defaultEncoding;
boolean bool = this.defaultEmbedding;
float f = -1.0F;
int i = 0;
Color color = null;
String str3 = paramProperties.getProperty("style");
if (str3 != null && str3.length() > 0) {
Properties properties = Markup.parseAttributes(str3);
if (properties.isEmpty()) {
paramProperties.put("style", str3);
} else {
str1 = properties.getProperty("font-family");
if (str1 != null)
while (str1.indexOf(',') != -1) {
String str = str1.substring(0, str1.indexOf(','));
if (isRegistered(str)) {
str1 = str;
continue;
}
str1 = str1.substring(str1.indexOf(',') + 1);
}
if ((str3 = properties.getProperty("font-size")) != null)
f = Markup.parseLength(str3);
if ((str3 = properties.getProperty("font-weight")) != null)
i |= Font.getStyleValue(str3);
if ((str3 = properties.getProperty("font-style")) != null)
i |= Font.getStyleValue(str3);
if ((str3 = properties.getProperty("color")) != null)
color = Markup.decodeColor(str3);
paramProperties.putAll(properties);
Enumeration enumeration = properties.keys();
while (enumeration.hasMoreElements()) {
Object object = enumeration.nextElement();
paramProperties.put(object, properties.get(object));
}
}
}
if ((str3 = paramProperties.getProperty("encoding")) != null)
str2 = str3;
if ("true".equals(paramProperties.getProperty("embedded")))
bool = true;
if ((str3 = paramProperties.getProperty("font")) != null)
str1 = str3;
if ((str3 = paramProperties.getProperty("size")) != null)
f = Markup.parseLength(str3);
if ((str3 = paramProperties.getProperty("style")) != null)
i |= Font.getStyleValue(str3);
if ((str3 = paramProperties.getProperty("fontstyle")) != null)
i |= Font.getStyleValue(str3);
String str4 = paramProperties.getProperty("red");
String str5 = paramProperties.getProperty("green");
String str6 = paramProperties.getProperty("blue");
if (str4 != null || str5 != null || str6 != null) {
int j = 0;
int k = 0;
int m = 0;
if (str4 != null)
j = Integer.parseInt(str4);
if (str5 != null)
k = Integer.parseInt(str5);
if (str6 != null)
m = Integer.parseInt(str6);
color = new Color(j, k, m);
} else if ((str3 = paramProperties.getProperty("color")) != null) {
color = Markup.decodeColor(str3);
}
return (str1 == null) ? getFont(null, str2, bool, f, i, color) : getFont(str1, str2, bool, f, i, color);
}
public Font getFont(String paramString1, String paramString2, boolean paramBoolean, float paramFloat, int paramInt) {
return getFont(paramString1, paramString2, paramBoolean, paramFloat, paramInt, null);
}
public Font getFont(String paramString1, String paramString2, boolean paramBoolean, float paramFloat) {
return getFont(paramString1, paramString2, paramBoolean, paramFloat, -1, null);
}
public Font getFont(String paramString1, String paramString2, boolean paramBoolean) {
return getFont(paramString1, paramString2, paramBoolean, -1.0F, -1, null);
}
public Font getFont(String paramString1, String paramString2, float paramFloat, int paramInt, Color paramColor) {
return getFont(paramString1, paramString2, this.defaultEmbedding, paramFloat, paramInt, paramColor);
}
public Font getFont(String paramString1, String paramString2, float paramFloat, int paramInt) {
return getFont(paramString1, paramString2, this.defaultEmbedding, paramFloat, paramInt, null);
}
public Font getFont(String paramString1, String paramString2, float paramFloat) {
return getFont(paramString1, paramString2, this.defaultEmbedding, paramFloat, -1, null);
}
public Font getFont(String paramString, float paramFloat, Color paramColor) {
return getFont(paramString, this.defaultEncoding, this.defaultEmbedding, paramFloat, -1, paramColor);
}
public Font getFont(String paramString1, String paramString2) {
return getFont(paramString1, paramString2, this.defaultEmbedding, -1.0F, -1, null);
}
public Font getFont(String paramString, float paramFloat, int paramInt, Color paramColor) {
return getFont(paramString, this.defaultEncoding, this.defaultEmbedding, paramFloat, paramInt, paramColor);
}
public Font getFont(String paramString, float paramFloat, int paramInt) {
return getFont(paramString, this.defaultEncoding, this.defaultEmbedding, paramFloat, paramInt, null);
}
public Font getFont(String paramString, float paramFloat) {
return getFont(paramString, this.defaultEncoding, this.defaultEmbedding, paramFloat, -1, null);
}
public Font getFont(String paramString) {
return getFont(paramString, this.defaultEncoding, this.defaultEmbedding, -1.0F, -1, null);
}
public void registerFamily(String paramString1, String paramString2, String paramString3) {
if (paramString3 != null)
this.trueTypeFonts.setProperty(paramString2, paramString3);
ArrayList arrayList = (ArrayList)this.fontFamilies.get(paramString1);
if (arrayList == null) {
arrayList = new ArrayList();
arrayList.add(paramString2);
this.fontFamilies.put(paramString1, arrayList);
} else {
int i = paramString2.length();
boolean bool = false;
for (int j = 0; j < arrayList.size(); j++) {
if (((String)arrayList.get(j)).length() >= i) {
arrayList.add(j, paramString2);
bool = true;
break;
}
}
if (!bool)
arrayList.add(paramString2);
}
}
public void register(String paramString) {
register(paramString, null);
}
public void register(String paramString1, String paramString2) {
try {
if (paramString1.toLowerCase().endsWith(".ttf") || paramString1.toLowerCase().endsWith(".otf") || paramString1.toLowerCase().indexOf(".ttc,") > 0) {
Object[] arrayOfObject = BaseFont.getAllFontNames(paramString1, "Cp1252", null);
this.trueTypeFonts.setProperty(((String)arrayOfObject[0]).toLowerCase(), paramString1);
if (paramString2 != null)
this.trueTypeFonts.setProperty(paramString2.toLowerCase(), paramString1);
String[][] arrayOfString = (String[][])arrayOfObject[2];
for (int i = 0; i < arrayOfString.length; i++)
this.trueTypeFonts.setProperty(arrayOfString[i][3].toLowerCase(), paramString1);
String str1 = null;
String str2 = null;
arrayOfString = (String[][])arrayOfObject[1];
for (int j = 0; j < TTFamilyOrder.length; j += 3) {
for (int k = 0; k < arrayOfString.length; k++) {
if (TTFamilyOrder[j].equals(arrayOfString[k][0]) && TTFamilyOrder[j + 1].equals(arrayOfString[k][1]) && TTFamilyOrder[j + 2].equals(arrayOfString[k][2])) {
str2 = arrayOfString[k][3].toLowerCase();
j = TTFamilyOrder.length;
break;
}
}
}
if (str2 != null) {
String str = "";
arrayOfString = (String[][])arrayOfObject[2];
for (int k = 0; k < arrayOfString.length; k++) {
for (int m = 0; m < TTFamilyOrder.length; m += 3) {
if (TTFamilyOrder[m].equals(arrayOfString[k][0]) && TTFamilyOrder[m + 1].equals(arrayOfString[k][1]) && TTFamilyOrder[m + 2].equals(arrayOfString[k][2])) {
str1 = arrayOfString[k][3];
if (!str1.equals(str)) {
str = str1;
registerFamily(str2, str1, null);
break;
}
}
}
}
}
} else if (paramString1.toLowerCase().endsWith(".ttc")) {
if (paramString2 != null)
System.err.println("class FontFactory: You can't define an alias for a true type collection.");
String[] arrayOfString = BaseFont.enumerateTTCNames(paramString1);
for (int i = 0; i < arrayOfString.length; i++)
register(paramString1 + "," + i);
} else if (paramString1.toLowerCase().endsWith(".afm") || paramString1.toLowerCase().endsWith(".pfm")) {
BaseFont baseFont = BaseFont.createFont(paramString1, "Cp1252", false);
String str1 = baseFont.getFullFontName()[0][3].toLowerCase();
String str2 = baseFont.getFamilyFontName()[0][3].toLowerCase();
String str3 = baseFont.getPostscriptFontName().toLowerCase();
registerFamily(str2, str1, null);
this.trueTypeFonts.setProperty(str3, paramString1);
this.trueTypeFonts.setProperty(str1, paramString1);
}
} catch (DocumentException e) {
throw new ExceptionConverter(e);
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
public int registerDirectory(String paramString) {
return registerDirectory(paramString, false);
}
public int registerDirectory(String paramString, boolean paramBoolean) {
int i = 0;
try {
File file = new File(paramString);
if (!file.exists() || !file.isDirectory())
return 0;
String[] arrayOfString = file.list();
if (arrayOfString == null)
return 0;
for (int j = 0; j < arrayOfString.length; j++) {
try {
file = new File(paramString, arrayOfString[j]);
if (file.isDirectory()) {
if (paramBoolean)
i += registerDirectory(file.getAbsolutePath(), true);
} else {
String str1 = file.getPath();
String str2 = (str1.length() < 4) ? null : str1.substring(str1.length() - 4).toLowerCase();
if (".afm".equals(str2) || ".pfm".equals(str2)) {
File file1 = new File(str1.substring(0, str1.length() - 4) + ".pfb");
if (file1.exists()) {
register(str1, null);
i++;
}
} else if (".ttf".equals(str2) || ".otf".equals(str2) || ".ttc".equals(str2)) {
register(str1, null);
i++;
}
}
} catch (Exception e) {}
}
} catch (Exception e) {}
return i;
}
public int registerDirectories() {
int i = 0;
i += registerDirectory("c:/windows/fonts");
i += registerDirectory("c:/winnt/fonts");
i += registerDirectory("d:/windows/fonts");
i += registerDirectory("d:/winnt/fonts");
i += registerDirectory("/usr/share/X11/fonts", true);
i += registerDirectory("/usr/X/lib/X11/fonts", true);
i += registerDirectory("/usr/openwin/lib/X11/fonts", true);
i += registerDirectory("/usr/share/fonts", true);
i += registerDirectory("/usr/X11R6/lib/X11/fonts", true);
i += registerDirectory("/Library/Fonts");
i += registerDirectory("/System/Library/Fonts");
return i;
}
public Set getRegisteredFonts() {
return Utilities.getKeySet(this.trueTypeFonts);
}
public Set getRegisteredFamilies() {
return Utilities.getKeySet(this.fontFamilies);
}
public boolean isRegistered(String paramString) {
return this.trueTypeFonts.containsKey(paramString.toLowerCase());
}
}

View file

@ -0,0 +1,49 @@
package com.lowagie.text;
import com.lowagie.text.factories.GreekAlphabetFactory;
public class GreekList extends List {
public GreekList() {
super(true);
setGreekFont();
}
public GreekList(int paramInt) {
super(true, (float)paramInt);
setGreekFont();
}
public GreekList(boolean paramBoolean, int paramInt) {
super(true, (float)paramInt);
this.lowercase = paramBoolean;
setGreekFont();
}
protected void setGreekFont() {
float f = this.symbol.getFont().getSize();
this.symbol.setFont(FontFactory.getFont("Symbol", f, 0));
}
public boolean add(Object paramObject) {
if (paramObject instanceof ListItem) {
ListItem listItem = (ListItem)paramObject;
Chunk chunk = new Chunk(this.preSymbol, this.symbol.getFont());
chunk.append(GreekAlphabetFactory.getString(this.first + this.list.size(), this.lowercase));
chunk.append(this.postSymbol);
listItem.setListSymbol(chunk);
listItem.setIndentationLeft(this.symbolIndent, this.autoindent);
listItem.setIndentationRight(0.0F);
this.list.add(listItem);
} else {
if (paramObject instanceof List) {
List list = (List)paramObject;
list.setIndentationLeft(list.getIndentationLeft() + this.symbolIndent);
this.first--;
return this.list.add(list);
}
if (paramObject instanceof String)
return add(new ListItem((String)paramObject));
}
return false;
}
}

View file

@ -0,0 +1,14 @@
package com.lowagie.text;
public class Header extends Meta {
private StringBuffer name;
public Header(String paramString1, String paramString2) {
super(0, paramString2);
this.name = new StringBuffer(paramString1);
}
public String getName() {
return this.name.toString();
}
}

View file

@ -0,0 +1,65 @@
package com.lowagie.text;
public class HeaderFooter extends Rectangle {
private boolean numbered;
private Phrase before = null;
private int pageN;
private Phrase after = null;
private int alignment;
public HeaderFooter(Phrase paramPhrase1, Phrase paramPhrase2) {
super(0.0F, 0.0F, 0.0F, 0.0F);
setBorder(3);
setBorderWidth(1.0F);
this.numbered = true;
this.before = paramPhrase1;
this.after = paramPhrase2;
}
public HeaderFooter(Phrase paramPhrase, boolean paramBoolean) {
super(0.0F, 0.0F, 0.0F, 0.0F);
setBorder(3);
setBorderWidth(1.0F);
this.numbered = paramBoolean;
this.before = paramPhrase;
}
public boolean isNumbered() {
return this.numbered;
}
public Phrase getBefore() {
return this.before;
}
public Phrase getAfter() {
return this.after;
}
public void setPageNumber(int paramInt) {
this.pageN = paramInt;
}
public void setAlignment(int paramInt) {
this.alignment = paramInt;
}
public Paragraph paragraph() {
Paragraph paragraph = new Paragraph(this.before.getLeading());
paragraph.add(this.before);
if (this.numbered)
paragraph.addSpecial(new Chunk(String.valueOf(this.pageN), this.before.getFont()));
if (this.after != null)
paragraph.addSpecial(this.after);
paragraph.setAlignment(this.alignment);
return paragraph;
}
public int alignment() {
return this.alignment;
}
}

View file

@ -0,0 +1,997 @@
package com.lowagie.text;
import com.lowagie.text.pdf.PRIndirectReference;
import com.lowagie.text.pdf.PdfArray;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfDictionary;
import com.lowagie.text.pdf.PdfIndirectReference;
import com.lowagie.text.pdf.PdfName;
import com.lowagie.text.pdf.PdfNumber;
import com.lowagie.text.pdf.PdfOCG;
import com.lowagie.text.pdf.PdfObject;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.RandomAccessFileOrArray;
import com.lowagie.text.pdf.codec.BmpImage;
import com.lowagie.text.pdf.codec.CCITTG4Encoder;
import com.lowagie.text.pdf.codec.GifImage;
import com.lowagie.text.pdf.codec.PngImage;
import com.lowagie.text.pdf.codec.TiffImage;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.color.ICC_Profile;
import java.awt.image.BufferedImage;
import java.awt.image.PixelGrabber;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
public abstract class Image extends Rectangle {
public static final int DEFAULT = 0;
public static final int RIGHT = 2;
public static final int LEFT = 0;
public static final int MIDDLE = 1;
public static final int TEXTWRAP = 4;
public static final int UNDERLYING = 8;
public static final int AX = 0;
public static final int AY = 1;
public static final int BX = 2;
public static final int BY = 3;
public static final int CX = 4;
public static final int CY = 5;
public static final int DX = 6;
public static final int DY = 7;
public static final int ORIGINAL_NONE = 0;
public static final int ORIGINAL_JPEG = 1;
public static final int ORIGINAL_PNG = 2;
public static final int ORIGINAL_GIF = 3;
public static final int ORIGINAL_BMP = 4;
public static final int ORIGINAL_TIFF = 5;
public static final int ORIGINAL_WMF = 6;
public static final int ORIGINAL_PS = 7;
public static final int ORIGINAL_JPEG2000 = 8;
protected int type;
protected URL url;
protected byte[] rawData;
protected int bpc = 1;
protected PdfTemplate[] template = new PdfTemplate[1];
protected int alignment;
protected String alt;
protected float absoluteX = Float.NaN;
protected float absoluteY = Float.NaN;
protected float plainWidth;
protected float plainHeight;
protected float scaledWidth;
protected float scaledHeight;
protected int compressionLevel = -1;
protected Long mySerialId = getSerialId();
private PdfIndirectReference directReference;
static long serialId = 0L;
protected float rotationRadians;
private float initialRotation;
protected float indentationLeft = 0.0F;
protected float indentationRight = 0.0F;
protected float spacingBefore;
protected float spacingAfter;
private float widthPercentage = 100.0F;
protected Annotation annotation = null;
protected PdfOCG layer;
protected boolean interpolation;
protected int originalType = 0;
protected byte[] originalData;
protected boolean deflated = false;
protected int dpiX = 0;
protected int dpiY = 0;
private float XYRatio = 0.0F;
protected int colorspace = -1;
protected boolean invert = false;
protected ICC_Profile profile = null;
private PdfDictionary additional = null;
protected boolean mask = false;
protected Image imageMask;
private boolean smask;
protected int[] transparency;
public Image(URL paramURL) {
super(0.0F, 0.0F);
this.url = paramURL;
this.alignment = 0;
this.rotationRadians = 0.0F;
}
public static Image getInstance(URL paramURL) throws BadElementException, MalformedURLException, IOException {
InputStream inputStream = null;
try {
inputStream = paramURL.openStream();
int i = inputStream.read();
int j = inputStream.read();
int k = inputStream.read();
int m = inputStream.read();
inputStream.close();
inputStream = null;
if (i == 71 && j == 73 && k == 70) {
GifImage gifImage = new GifImage(paramURL);
Image image = gifImage.getImage(1);
return image;
}
if (i == 255 && j == 216)
return new Jpeg(paramURL);
if (i == 0 && j == 0 && k == 0 && m == 12)
return new Jpeg2000(paramURL);
if (i == 255 && j == 79 && k == 255 && m == 81)
return new Jpeg2000(paramURL);
if (i == PngImage.PNGID[0] && j == PngImage.PNGID[1] && k == PngImage.PNGID[2] && m == PngImage.PNGID[3])
return PngImage.getImage(paramURL);
if (i == 215 && j == 205)
return new ImgWMF(paramURL);
if (i == 66 && j == 77)
return BmpImage.getImage(paramURL);
if ((i == 77 && j == 77 && k == 0 && m == 42) || (i == 73 && j == 73 && k == 42 && m == 0)) {
RandomAccessFileOrArray randomAccessFileOrArray = null;
try {
if (paramURL.getProtocol().equals("file")) {
String str = paramURL.getFile();
str = Utilities.unEscapeURL(str);
randomAccessFileOrArray = new RandomAccessFileOrArray(str);
} else {
randomAccessFileOrArray = new RandomAccessFileOrArray(paramURL);
}
Image image = TiffImage.getTiffImage(randomAccessFileOrArray, 1);
image.url = paramURL;
return image;
} finally {
if (randomAccessFileOrArray != null)
randomAccessFileOrArray.close();
}
}
throw new IOException(paramURL.toString() + " is not a recognized imageformat.");
} finally {
if (inputStream != null)
inputStream.close();
}
}
public static Image getInstance(String paramString) throws BadElementException, MalformedURLException, IOException {
return getInstance(Utilities.toURL(paramString));
}
public static Image getInstance(byte[] paramArrayOfbyte) throws BadElementException, MalformedURLException, IOException {
ByteArrayInputStream byteArrayInputStream = null;
try {
byteArrayInputStream = new ByteArrayInputStream(paramArrayOfbyte);
int i = byteArrayInputStream.read();
int j = byteArrayInputStream.read();
int k = byteArrayInputStream.read();
int m = byteArrayInputStream.read();
byteArrayInputStream.close();
byteArrayInputStream = null;
if (i == 71 && j == 73 && k == 70) {
GifImage gifImage = new GifImage(paramArrayOfbyte);
return gifImage.getImage(1);
}
if (i == 255 && j == 216)
return new Jpeg(paramArrayOfbyte);
if (i == 0 && j == 0 && k == 0 && m == 12)
return new Jpeg2000(paramArrayOfbyte);
if (i == 255 && j == 79 && k == 255 && m == 81)
return new Jpeg2000(paramArrayOfbyte);
if (i == PngImage.PNGID[0] && j == PngImage.PNGID[1] && k == PngImage.PNGID[2] && m == PngImage.PNGID[3])
return PngImage.getImage(paramArrayOfbyte);
if (i == 215 && j == 205)
return new ImgWMF(paramArrayOfbyte);
if (i == 66 && j == 77)
return BmpImage.getImage(paramArrayOfbyte);
if ((i == 77 && j == 77 && k == 0 && m == 42) || (i == 73 && j == 73 && k == 42 && m == 0)) {
RandomAccessFileOrArray randomAccessFileOrArray = null;
try {
randomAccessFileOrArray = new RandomAccessFileOrArray(paramArrayOfbyte);
Image image = TiffImage.getTiffImage(randomAccessFileOrArray, 1);
if (image.getOriginalData() == null)
image.setOriginalData(paramArrayOfbyte);
return image;
} finally {
if (randomAccessFileOrArray != null)
randomAccessFileOrArray.close();
}
}
throw new IOException("The byte array is not a recognized imageformat.");
} finally {
if (byteArrayInputStream != null)
byteArrayInputStream.close();
}
}
public static Image getInstance(int paramInt1, int paramInt2, int paramInt3, int paramInt4, byte[] paramArrayOfbyte) throws BadElementException {
return getInstance(paramInt1, paramInt2, paramInt3, paramInt4, paramArrayOfbyte, null);
}
public static Image getInstance(int paramInt1, int paramInt2, boolean paramBoolean, int paramInt3, int paramInt4, byte[] paramArrayOfbyte) throws BadElementException {
return getInstance(paramInt1, paramInt2, paramBoolean, paramInt3, paramInt4, paramArrayOfbyte, null);
}
public static Image getInstance(int paramInt1, int paramInt2, boolean paramBoolean, int paramInt3, int paramInt4, byte[] paramArrayOfbyte, int[] paramArrayOfint) throws BadElementException {
if (paramArrayOfint != null && paramArrayOfint.length != 2)
throw new BadElementException("Transparency length must be equal to 2 with CCITT images");
ImgCCITT imgCCITT = new ImgCCITT(paramInt1, paramInt2, paramBoolean, paramInt3, paramInt4, paramArrayOfbyte);
imgCCITT.transparency = paramArrayOfint;
return imgCCITT;
}
public static Image getInstance(int paramInt1, int paramInt2, int paramInt3, int paramInt4, byte[] paramArrayOfbyte, int[] paramArrayOfint) throws BadElementException {
if (paramArrayOfint != null && paramArrayOfint.length != paramInt3 * 2)
throw new BadElementException("Transparency length must be equal to (componentes * 2)");
if (paramInt3 == 1 && paramInt4 == 1) {
byte[] arrayOfByte = CCITTG4Encoder.compress(paramArrayOfbyte, paramInt1, paramInt2);
return getInstance(paramInt1, paramInt2, false, 256, 1, arrayOfByte, paramArrayOfint);
}
ImgRaw imgRaw = new ImgRaw(paramInt1, paramInt2, paramInt3, paramInt4, paramArrayOfbyte);
imgRaw.transparency = paramArrayOfint;
return imgRaw;
}
public static Image getInstance(PdfTemplate paramPdfTemplate) throws BadElementException {
return new ImgTemplate(paramPdfTemplate);
}
public static Image getInstance(java.awt.Image paramImage, Color paramColor, boolean paramBoolean) throws BadElementException, IOException {
if (paramImage instanceof BufferedImage) {
BufferedImage bufferedImage = (BufferedImage)paramImage;
if (bufferedImage.getType() == 12)
paramBoolean = true;
}
PixelGrabber pixelGrabber = new PixelGrabber(paramImage, 0, 0, -1, -1, true);
try {
pixelGrabber.grabPixels();
} catch (InterruptedException e) {
throw new IOException("java.awt.Image Interrupted waiting for pixels!");
}
if ((pixelGrabber.getStatus() & 0x80) != 0)
throw new IOException("java.awt.Image fetch aborted or errored");
int i = pixelGrabber.getWidth();
int j = pixelGrabber.getHeight();
int[] arrayOfInt1 = (int[])pixelGrabber.getPixels();
if (paramBoolean) {
int i3 = i / 8 + (((i & 0x7) != 0) ? 1 : 0);
byte[] arrayOfByte = new byte[i3 * j];
int i4 = 0;
int i5 = j * i;
boolean bool = true;
if (paramColor != null)
bool = (paramColor.getRed() + paramColor.getGreen() + paramColor.getBlue() < 384) ? false : true;
int[] arrayOfInt = null;
int i6 = 128;
int i7 = 0;
int i8 = 0;
if (paramColor != null) {
for (int i9 = 0; i9 < i5; i9++) {
int i10 = arrayOfInt1[i9] >> 24 & 0xFF;
if (i10 < 250) {
if (bool == true)
i8 |= i6;
} else if ((arrayOfInt1[i9] & 0x888) != 0) {
i8 |= i6;
}
i6 >>= 1;
if (i6 == 0 || i7 + 1 >= i) {
arrayOfByte[i4++] = (byte)i8;
i6 = 128;
i8 = 0;
}
if (++i7 >= i)
i7 = 0;
}
} else {
for (int i9 = 0; i9 < i5; i9++) {
if (arrayOfInt == null) {
int i10 = arrayOfInt1[i9] >> 24 & 0xFF;
if (i10 == 0) {
arrayOfInt = new int[2];
arrayOfInt[1] = ((arrayOfInt1[i9] & 0x888) != 0) ? 1 : 0;
arrayOfInt[0] = ((arrayOfInt1[i9] & 0x888) != 0) ? 1 : 0;
}
}
if ((arrayOfInt1[i9] & 0x888) != 0)
i8 |= i6;
i6 >>= 1;
if (i6 == 0 || i7 + 1 >= i) {
arrayOfByte[i4++] = (byte)i8;
i6 = 128;
i8 = 0;
}
if (++i7 >= i)
i7 = 0;
}
}
return getInstance(i, j, 1, 1, arrayOfByte, arrayOfInt);
}
byte[] arrayOfByte1 = new byte[i * j * 3];
byte[] arrayOfByte2 = null;
int k = 0;
int m = j * i;
int n = 255;
int i1 = 255;
int i2 = 255;
if (paramColor != null) {
n = paramColor.getRed();
i1 = paramColor.getGreen();
i2 = paramColor.getBlue();
}
int[] arrayOfInt2 = null;
if (paramColor != null) {
for (int i3 = 0; i3 < m; i3++) {
int i4 = arrayOfInt1[i3] >> 24 & 0xFF;
if (i4 < 250) {
arrayOfByte1[k++] = (byte)n;
arrayOfByte1[k++] = (byte)i1;
arrayOfByte1[k++] = (byte)i2;
} else {
arrayOfByte1[k++] = (byte)(arrayOfInt1[i3] >> 16 & 0xFF);
arrayOfByte1[k++] = (byte)(arrayOfInt1[i3] >> 8 & 0xFF);
arrayOfByte1[k++] = (byte)(arrayOfInt1[i3] & 0xFF);
}
}
} else {
int i3 = 0;
arrayOfByte2 = new byte[i * j];
boolean bool = false;
for (int i4 = 0; i4 < m; i4++) {
byte b = arrayOfByte2[i4] = (byte)(arrayOfInt1[i4] >> 24 & 0xFF);
if (!bool)
if (b != 0 && b != -1) {
bool = true;
} else if (arrayOfInt2 == null) {
if (b == 0) {
i3 = arrayOfInt1[i4] & 0xFFFFFF;
arrayOfInt2 = new int[6];
arrayOfInt2[1] = i3 >> 16 & 0xFF;
arrayOfInt2[0] = i3 >> 16 & 0xFF;
arrayOfInt2[3] = i3 >> 8 & 0xFF;
arrayOfInt2[2] = i3 >> 8 & 0xFF;
arrayOfInt2[5] = i3 & 0xFF;
arrayOfInt2[4] = i3 & 0xFF;
}
} else if ((arrayOfInt1[i4] & 0xFFFFFF) != i3) {
bool = true;
}
arrayOfByte1[k++] = (byte)(arrayOfInt1[i4] >> 16 & 0xFF);
arrayOfByte1[k++] = (byte)(arrayOfInt1[i4] >> 8 & 0xFF);
arrayOfByte1[k++] = (byte)(arrayOfInt1[i4] & 0xFF);
}
if (bool) {
arrayOfInt2 = null;
} else {
arrayOfByte2 = null;
}
}
Image image = getInstance(i, j, 3, 8, arrayOfByte1, arrayOfInt2);
if (arrayOfByte2 != null) {
Image image1 = getInstance(i, j, 1, 8, arrayOfByte2);
try {
image1.makeMask();
image.setImageMask(image1);
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
}
return image;
}
public static Image getInstance(java.awt.Image paramImage, Color paramColor) throws BadElementException, IOException {
return getInstance(paramImage, paramColor, false);
}
public static Image getInstance(PdfWriter paramPdfWriter, java.awt.Image paramImage, float paramFloat) throws BadElementException, IOException {
return getInstance(new PdfContentByte(paramPdfWriter), paramImage, paramFloat);
}
public static Image getInstance(PdfContentByte paramPdfContentByte, java.awt.Image paramImage, float paramFloat) throws BadElementException, IOException {
PixelGrabber pixelGrabber = new PixelGrabber(paramImage, 0, 0, -1, -1, true);
try {
pixelGrabber.grabPixels();
} catch (InterruptedException e) {
throw new IOException("java.awt.Image Interrupted waiting for pixels!");
}
if ((pixelGrabber.getStatus() & 0x80) != 0)
throw new IOException("java.awt.Image fetch aborted or errored");
int i = pixelGrabber.getWidth();
int j = pixelGrabber.getHeight();
PdfTemplate pdfTemplate = paramPdfContentByte.createTemplate((float)i, (float)j);
Graphics2D graphics2D = pdfTemplate.createGraphics((float)i, (float)j, true, paramFloat);
graphics2D.drawImage(paramImage, 0, 0, null);
graphics2D.dispose();
return getInstance(pdfTemplate);
}
public PdfIndirectReference getDirectReference() {
return this.directReference;
}
public void setDirectReference(PdfIndirectReference paramPdfIndirectReference) {
this.directReference = paramPdfIndirectReference;
}
public static Image getInstance(PRIndirectReference paramPRIndirectReference) throws BadElementException {
PdfDictionary pdfDictionary = (PdfDictionary)PdfReader.getPdfObjectRelease(paramPRIndirectReference);
int i = ((PdfNumber)PdfReader.getPdfObjectRelease(pdfDictionary.get(PdfName.WIDTH))).intValue();
int j = ((PdfNumber)PdfReader.getPdfObjectRelease(pdfDictionary.get(PdfName.HEIGHT))).intValue();
Image image = null;
PdfObject pdfObject = pdfDictionary.get(PdfName.SMASK);
if (pdfObject != null && pdfObject.isIndirect()) {
image = getInstance((PRIndirectReference)pdfObject);
} else {
pdfObject = pdfDictionary.get(PdfName.MASK);
if (pdfObject != null && pdfObject.isIndirect()) {
PdfObject pdfObject1 = PdfReader.getPdfObjectRelease(pdfObject);
if (pdfObject1 instanceof PdfDictionary)
image = getInstance((PRIndirectReference)pdfObject);
}
}
ImgRaw imgRaw = new ImgRaw(i, j, 1, 1, null);
imgRaw.imageMask = image;
imgRaw.directReference = paramPRIndirectReference;
return imgRaw;
}
protected Image(Image paramImage) {
super(paramImage);
this.type = paramImage.type;
this.url = paramImage.url;
this.rawData = paramImage.rawData;
this.bpc = paramImage.bpc;
this.template = paramImage.template;
this.alignment = paramImage.alignment;
this.alt = paramImage.alt;
this.absoluteX = paramImage.absoluteX;
this.absoluteY = paramImage.absoluteY;
this.plainWidth = paramImage.plainWidth;
this.plainHeight = paramImage.plainHeight;
this.scaledWidth = paramImage.scaledWidth;
this.scaledHeight = paramImage.scaledHeight;
this.mySerialId = paramImage.mySerialId;
this.directReference = paramImage.directReference;
this.rotationRadians = paramImage.rotationRadians;
this.initialRotation = paramImage.initialRotation;
this.indentationLeft = paramImage.indentationLeft;
this.indentationRight = paramImage.indentationRight;
this.spacingBefore = paramImage.spacingBefore;
this.spacingAfter = paramImage.spacingAfter;
this.widthPercentage = paramImage.widthPercentage;
this.annotation = paramImage.annotation;
this.layer = paramImage.layer;
this.interpolation = paramImage.interpolation;
this.originalType = paramImage.originalType;
this.originalData = paramImage.originalData;
this.deflated = paramImage.deflated;
this.dpiX = paramImage.dpiX;
this.dpiY = paramImage.dpiY;
this.XYRatio = paramImage.XYRatio;
this.colorspace = paramImage.colorspace;
this.invert = paramImage.invert;
this.profile = paramImage.profile;
this.additional = paramImage.additional;
this.mask = paramImage.mask;
this.imageMask = paramImage.imageMask;
this.smask = paramImage.smask;
this.transparency = paramImage.transparency;
}
public static Image getInstance(Image paramImage) {
if (paramImage == null)
return null;
try {
Class clazz = paramImage.getClass();
Constructor constructor = clazz.getDeclaredConstructor(new Class[] { Image.class });
return (Image)constructor.newInstance(new Object[] { paramImage });
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
public int type() {
return this.type;
}
public boolean isNestable() {
return true;
}
public boolean isJpeg() {
return (this.type == 32);
}
public boolean isImgRaw() {
return (this.type == 34);
}
public boolean isImgTemplate() {
return (this.type == 35);
}
public URL getUrl() {
return this.url;
}
public void setUrl(URL paramURL) {
this.url = paramURL;
}
public byte[] getRawData() {
return this.rawData;
}
public int getBpc() {
return this.bpc;
}
public PdfTemplate getTemplateData() {
return this.template[0];
}
public void setTemplateData(PdfTemplate paramPdfTemplate) {
this.template[0] = paramPdfTemplate;
}
public int getAlignment() {
return this.alignment;
}
public void setAlignment(int paramInt) {
this.alignment = paramInt;
}
public String getAlt() {
return this.alt;
}
public void setAlt(String paramString) {
this.alt = paramString;
}
public void setAbsolutePosition(float paramFloat1, float paramFloat2) {
this.absoluteX = paramFloat1;
this.absoluteY = paramFloat2;
}
public boolean hasAbsoluteX() {
return !Float.isNaN(this.absoluteX);
}
public float getAbsoluteX() {
return this.absoluteX;
}
public boolean hasAbsoluteY() {
return !Float.isNaN(this.absoluteY);
}
public float getAbsoluteY() {
return this.absoluteY;
}
public float getScaledWidth() {
return this.scaledWidth;
}
public float getScaledHeight() {
return this.scaledHeight;
}
public float getPlainWidth() {
return this.plainWidth;
}
public float getPlainHeight() {
return this.plainHeight;
}
public void scaleAbsolute(float paramFloat1, float paramFloat2) {
this.plainWidth = paramFloat1;
this.plainHeight = paramFloat2;
float[] arrayOfFloat = matrix();
this.scaledWidth = arrayOfFloat[6] - arrayOfFloat[4];
this.scaledHeight = arrayOfFloat[7] - arrayOfFloat[5];
setWidthPercentage(0.0F);
}
public void scaleAbsoluteWidth(float paramFloat) {
this.plainWidth = paramFloat;
float[] arrayOfFloat = matrix();
this.scaledWidth = arrayOfFloat[6] - arrayOfFloat[4];
this.scaledHeight = arrayOfFloat[7] - arrayOfFloat[5];
setWidthPercentage(0.0F);
}
public void scaleAbsoluteHeight(float paramFloat) {
this.plainHeight = paramFloat;
float[] arrayOfFloat = matrix();
this.scaledWidth = arrayOfFloat[6] - arrayOfFloat[4];
this.scaledHeight = arrayOfFloat[7] - arrayOfFloat[5];
setWidthPercentage(0.0F);
}
public void scalePercent(float paramFloat) {
scalePercent(paramFloat, paramFloat);
}
public void scalePercent(float paramFloat1, float paramFloat2) {
this.plainWidth = getWidth() * paramFloat1 / 100.0F;
this.plainHeight = getHeight() * paramFloat2 / 100.0F;
float[] arrayOfFloat = matrix();
this.scaledWidth = arrayOfFloat[6] - arrayOfFloat[4];
this.scaledHeight = arrayOfFloat[7] - arrayOfFloat[5];
setWidthPercentage(0.0F);
}
public void scaleToFit(float paramFloat1, float paramFloat2) {
scalePercent(100.0F);
float f1 = paramFloat1 * 100.0F / getScaledWidth();
float f2 = paramFloat2 * 100.0F / getScaledHeight();
scalePercent((f1 < f2) ? f1 : f2);
setWidthPercentage(0.0F);
}
public float[] matrix() {
float[] arrayOfFloat = new float[8];
float f1 = (float)Math.cos((double)this.rotationRadians);
float f2 = (float)Math.sin((double)this.rotationRadians);
arrayOfFloat[0] = this.plainWidth * f1;
arrayOfFloat[1] = this.plainWidth * f2;
arrayOfFloat[2] = -this.plainHeight * f2;
arrayOfFloat[3] = this.plainHeight * f1;
if ((double)this.rotationRadians < 1.5707963267948966D) {
arrayOfFloat[4] = arrayOfFloat[2];
arrayOfFloat[5] = 0.0F;
arrayOfFloat[6] = arrayOfFloat[0];
arrayOfFloat[7] = arrayOfFloat[1] + arrayOfFloat[3];
} else if ((double)this.rotationRadians < Math.PI) {
arrayOfFloat[4] = arrayOfFloat[0] + arrayOfFloat[2];
arrayOfFloat[5] = arrayOfFloat[3];
arrayOfFloat[6] = 0.0F;
arrayOfFloat[7] = arrayOfFloat[1];
} else if ((double)this.rotationRadians < 4.71238898038469D) {
arrayOfFloat[4] = arrayOfFloat[0];
arrayOfFloat[5] = arrayOfFloat[1] + arrayOfFloat[3];
arrayOfFloat[6] = arrayOfFloat[2];
arrayOfFloat[7] = 0.0F;
} else {
arrayOfFloat[4] = 0.0F;
arrayOfFloat[5] = arrayOfFloat[1];
arrayOfFloat[6] = arrayOfFloat[0] + arrayOfFloat[2];
arrayOfFloat[7] = arrayOfFloat[3];
}
return arrayOfFloat;
}
protected static synchronized Long getSerialId() {
serialId++;
return new Long(serialId);
}
public Long getMySerialId() {
return this.mySerialId;
}
public float getImageRotation() {
double d = 6.283185307179586D;
float f = (float)((double)(this.rotationRadians - this.initialRotation) % d);
if (f < 0.0F)
f = (float)((double)f + d);
return f;
}
public void setRotation(float paramFloat) {
double d = 6.283185307179586D;
this.rotationRadians = (float)((double)(paramFloat + this.initialRotation) % d);
if (this.rotationRadians < 0.0F)
this.rotationRadians = (float)((double)this.rotationRadians + d);
float[] arrayOfFloat = matrix();
this.scaledWidth = arrayOfFloat[6] - arrayOfFloat[4];
this.scaledHeight = arrayOfFloat[7] - arrayOfFloat[5];
}
public void setRotationDegrees(float paramFloat) {
double d = Math.PI;
setRotation(paramFloat / 180.0F * (float)d);
}
public float getInitialRotation() {
return this.initialRotation;
}
public void setInitialRotation(float paramFloat) {
float f = this.rotationRadians - this.initialRotation;
this.initialRotation = paramFloat;
setRotation(f);
}
public float getIndentationLeft() {
return this.indentationLeft;
}
public void setIndentationLeft(float paramFloat) {
this.indentationLeft = paramFloat;
}
public float getIndentationRight() {
return this.indentationRight;
}
public void setIndentationRight(float paramFloat) {
this.indentationRight = paramFloat;
}
public float getSpacingBefore() {
return this.spacingBefore;
}
public void setSpacingBefore(float paramFloat) {
this.spacingBefore = paramFloat;
}
public float getSpacingAfter() {
return this.spacingAfter;
}
public void setSpacingAfter(float paramFloat) {
this.spacingAfter = paramFloat;
}
public float getWidthPercentage() {
return this.widthPercentage;
}
public void setWidthPercentage(float paramFloat) {
this.widthPercentage = paramFloat;
}
public void setAnnotation(Annotation paramAnnotation) {
this.annotation = paramAnnotation;
}
public Annotation getAnnotation() {
return this.annotation;
}
public PdfOCG getLayer() {
return this.layer;
}
public void setLayer(PdfOCG paramPdfOCG) {
this.layer = paramPdfOCG;
}
public boolean isInterpolation() {
return this.interpolation;
}
public void setInterpolation(boolean paramBoolean) {
this.interpolation = paramBoolean;
}
public int getOriginalType() {
return this.originalType;
}
public void setOriginalType(int paramInt) {
this.originalType = paramInt;
}
public byte[] getOriginalData() {
return this.originalData;
}
public void setOriginalData(byte[] paramArrayOfbyte) {
this.originalData = paramArrayOfbyte;
}
public boolean isDeflated() {
return this.deflated;
}
public void setDeflated(boolean paramBoolean) {
this.deflated = paramBoolean;
}
public int getDpiX() {
return this.dpiX;
}
public int getDpiY() {
return this.dpiY;
}
public void setDpi(int paramInt1, int paramInt2) {
this.dpiX = paramInt1;
this.dpiY = paramInt2;
}
public float getXYRatio() {
return this.XYRatio;
}
public void setXYRatio(float paramFloat) {
this.XYRatio = paramFloat;
}
public int getColorspace() {
return this.colorspace;
}
public boolean isInverted() {
return this.invert;
}
public void setInverted(boolean paramBoolean) {
this.invert = paramBoolean;
}
public void tagICC(ICC_Profile paramICC_Profile) {
this.profile = paramICC_Profile;
}
public boolean hasICCProfile() {
return (this.profile != null);
}
public ICC_Profile getICCProfile() {
return this.profile;
}
public PdfDictionary getAdditional() {
return this.additional;
}
public void setAdditional(PdfDictionary paramPdfDictionary) {
this.additional = paramPdfDictionary;
}
public void simplifyColorspace() {
if (this.additional == null)
return;
PdfObject pdfObject1 = this.additional.get(PdfName.COLORSPACE);
if (pdfObject1 == null || !pdfObject1.isArray())
return;
PdfObject pdfObject2 = simplifyColorspace(pdfObject1);
if (pdfObject2.isName()) {
pdfObject1 = pdfObject2;
} else {
PdfObject pdfObject = (PdfObject)((PdfArray)pdfObject1).getArrayList().get(0);
if (PdfName.INDEXED.equals(pdfObject)) {
ArrayList arrayList = ((PdfArray)pdfObject1).getArrayList();
if (arrayList.size() >= 2 && ((PdfObject)arrayList.get(1)).isArray())
arrayList.set(1, simplifyColorspace((PdfObject)arrayList.get(1)));
}
}
this.additional.put(PdfName.COLORSPACE, pdfObject1);
}
private PdfObject simplifyColorspace(PdfObject paramPdfObject) {
if (paramPdfObject == null || !paramPdfObject.isArray())
return paramPdfObject;
PdfObject pdfObject = (PdfObject)((PdfArray)paramPdfObject).getArrayList().get(0);
return PdfName.CALGRAY.equals(pdfObject) ? PdfName.DEVICEGRAY : (PdfName.CALRGB.equals(pdfObject) ? PdfName.DEVICERGB : paramPdfObject);
}
public boolean isMask() {
return this.mask;
}
public void makeMask() throws DocumentException {
if (!isMaskCandidate())
throw new DocumentException("This image can not be an image mask.");
this.mask = true;
}
public boolean isMaskCandidate() {
return (this.type == 34 && this.bpc > 255) ? true : ((this.colorspace == 1));
}
public Image getImageMask() {
return this.imageMask;
}
public void setImageMask(Image paramImage) throws DocumentException {
if (this.mask)
throw new DocumentException("An image mask cannot contain another image mask.");
if (!paramImage.mask)
throw new DocumentException("The image mask is not a mask. Did you do makeMask()?");
this.imageMask = paramImage;
this.smask = (paramImage.bpc > 1 && paramImage.bpc <= 8);
}
public boolean isSmask() {
return this.smask;
}
public void setSmask(boolean paramBoolean) {
this.smask = paramBoolean;
}
public int[] getTransparency() {
return this.transparency;
}
public void setTransparency(int[] paramArrayOfint) {
this.transparency = paramArrayOfint;
}
public int getCompressionLevel() {
return this.compressionLevel;
}
public void setCompressionLevel(int paramInt) {
if (paramInt < 0 || paramInt > 9) {
this.compressionLevel = -1;
} else {
this.compressionLevel = paramInt;
}
}
}

View file

@ -0,0 +1,28 @@
package com.lowagie.text;
import com.lowagie.text.pdf.codec.TIFFFaxDecoder;
import java.net.URL;
public class ImgCCITT extends Image {
ImgCCITT(Image paramImage) {
super(paramImage);
}
public ImgCCITT(int paramInt1, int paramInt2, boolean paramBoolean, int paramInt3, int paramInt4, byte[] paramArrayOfbyte) throws BadElementException {
super((URL)null);
if (paramInt3 != 256 && paramInt3 != 257 && paramInt3 != 258)
throw new BadElementException("The CCITT compression type must be CCITTG4, CCITTG3_1D or CCITTG3_2D");
if (paramBoolean)
TIFFFaxDecoder.reverseBits(paramArrayOfbyte);
this.type = 34;
this.scaledHeight = (float)paramInt2;
setTop(this.scaledHeight);
this.scaledWidth = (float)paramInt1;
setRight(this.scaledWidth);
this.colorspace = paramInt4;
this.bpc = paramInt3;
this.rawData = paramArrayOfbyte;
this.plainWidth = getWidth();
this.plainHeight = getHeight();
}
}

View file

@ -0,0 +1,27 @@
package com.lowagie.text;
import java.net.URL;
public class ImgRaw extends Image {
ImgRaw(Image paramImage) {
super(paramImage);
}
public ImgRaw(int paramInt1, int paramInt2, int paramInt3, int paramInt4, byte[] paramArrayOfbyte) throws BadElementException {
super((URL)null);
this.type = 34;
this.scaledHeight = (float)paramInt2;
setTop(this.scaledHeight);
this.scaledWidth = (float)paramInt1;
setRight(this.scaledWidth);
if (paramInt3 != 1 && paramInt3 != 3 && paramInt3 != 4)
throw new BadElementException("Components must be 1, 3, or 4.");
if (paramInt4 != 1 && paramInt4 != 2 && paramInt4 != 4 && paramInt4 != 8)
throw new BadElementException("Bits-per-component must be 1, 2, 4, or 8.");
this.colorspace = paramInt3;
this.bpc = paramInt4;
this.rawData = paramArrayOfbyte;
this.plainWidth = getWidth();
this.plainHeight = getHeight();
}
}

View file

@ -0,0 +1,26 @@
package com.lowagie.text;
import com.lowagie.text.pdf.PdfTemplate;
import java.net.URL;
public class ImgTemplate extends Image {
ImgTemplate(Image paramImage) {
super(paramImage);
}
public ImgTemplate(PdfTemplate paramPdfTemplate) throws BadElementException {
super((URL)null);
if (paramPdfTemplate == null)
throw new BadElementException("The template can not be null.");
if (paramPdfTemplate.getType() == 3)
throw new BadElementException("A pattern can not be used as a template to create an image.");
this.type = 35;
this.scaledHeight = paramPdfTemplate.getHeight();
setTop(this.scaledHeight);
this.scaledWidth = paramPdfTemplate.getWidth();
setRight(this.scaledWidth);
setTemplateData(paramPdfTemplate);
this.plainWidth = getWidth();
this.plainHeight = getHeight();
}
}

View file

@ -0,0 +1,87 @@
package com.lowagie.text;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.codec.wmf.InputMeta;
import com.lowagie.text.pdf.codec.wmf.MetaDo;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
public class ImgWMF extends Image {
ImgWMF(Image paramImage) {
super(paramImage);
}
public ImgWMF(URL paramURL) throws BadElementException, IOException {
super(paramURL);
processParameters();
}
public ImgWMF(String paramString) throws BadElementException, MalformedURLException, IOException {
this(Utilities.toURL(paramString));
}
public ImgWMF(byte[] paramArrayOfbyte) throws BadElementException, IOException {
super((URL)null);
this.rawData = paramArrayOfbyte;
this.originalData = paramArrayOfbyte;
processParameters();
}
private void processParameters() throws BadElementException, IOException {
this.type = 35;
this.originalType = 6;
InputStream inputStream = null;
try {
String str;
if (this.rawData == null) {
inputStream = this.url.openStream();
str = this.url.toString();
} else {
inputStream = new ByteArrayInputStream(this.rawData);
str = "Byte array";
}
InputMeta inputMeta = new InputMeta(inputStream);
if (inputMeta.readInt() != -1698247209)
throw new BadElementException(str + " is not a valid placeable windows metafile.");
inputMeta.readWord();
int i = inputMeta.readShort();
int j = inputMeta.readShort();
int k = inputMeta.readShort();
int m = inputMeta.readShort();
int n = inputMeta.readWord();
this.dpiX = 72;
this.dpiY = 72;
this.scaledHeight = (float)(m - j) / (float)n * 72.0F;
setTop(this.scaledHeight);
this.scaledWidth = (float)(k - i) / (float)n * 72.0F;
setRight(this.scaledWidth);
} finally {
if (inputStream != null)
inputStream.close();
this.plainWidth = getWidth();
this.plainHeight = getHeight();
}
}
public void readWMF(PdfTemplate paramPdfTemplate) throws IOException, DocumentException {
setTemplateData(paramPdfTemplate);
paramPdfTemplate.setWidth(getWidth());
paramPdfTemplate.setHeight(getHeight());
InputStream inputStream = null;
try {
if (this.rawData == null) {
inputStream = this.url.openStream();
} else {
inputStream = new ByteArrayInputStream(this.rawData);
}
MetaDo metaDo = new MetaDo(inputStream, paramPdfTemplate);
metaDo.readAll();
} finally {
if (inputStream != null)
inputStream.close();
}
}
}

View file

@ -0,0 +1,196 @@
package com.lowagie.text;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
public class Jpeg extends Image {
public static final int NOT_A_MARKER = -1;
public static final int VALID_MARKER = 0;
public static final int[] VALID_MARKERS = new int[] { 192, 193, 194 };
public static final int UNSUPPORTED_MARKER = 1;
public static final int[] UNSUPPORTED_MARKERS = new int[] {
195, 197, 198, 199, 200, 201, 202, 203, 205, 206,
207 };
public static final int NOPARAM_MARKER = 2;
public static final int[] NOPARAM_MARKERS = new int[] { 208, 209, 210, 211, 212, 213, 214, 215, 216, 1 };
public static final int M_APP0 = 224;
public static final int M_APP2 = 226;
public static final int M_APPE = 238;
public static final byte[] JFIF_ID = new byte[] { 74, 70, 73, 70, 0 };
private byte[][] icc;
Jpeg(Image paramImage) {
super(paramImage);
}
public Jpeg(URL paramURL) throws BadElementException, IOException {
super(paramURL);
processParameters();
}
public Jpeg(byte[] paramArrayOfbyte) throws BadElementException, IOException {
super((URL)null);
this.rawData = paramArrayOfbyte;
this.originalData = paramArrayOfbyte;
processParameters();
}
public Jpeg(byte[] paramArrayOfbyte, float paramFloat1, float paramFloat2) throws BadElementException, IOException {
this(paramArrayOfbyte);
this.scaledWidth = paramFloat1;
this.scaledHeight = paramFloat2;
}
private static final int getShort(InputStream paramInputStream) throws IOException {
return (paramInputStream.read() << 8) + paramInputStream.read();
}
private static final int marker(int paramInt) {
for (int k = 0; k < VALID_MARKERS.length; k++) {
if (paramInt == VALID_MARKERS[k])
return 0;
}
for (int j = 0; j < NOPARAM_MARKERS.length; j++) {
if (paramInt == NOPARAM_MARKERS[j])
return 2;
}
for (int i = 0; i < UNSUPPORTED_MARKERS.length; i++) {
if (paramInt == UNSUPPORTED_MARKERS[i])
return 1;
}
return -1;
}
private void processParameters() throws BadElementException, IOException {
this.type = 32;
this.originalType = 1;
InputStream inputStream = null;
try {
String str;
if (this.rawData == null) {
inputStream = this.url.openStream();
str = this.url.toString();
} else {
inputStream = new ByteArrayInputStream(this.rawData);
str = "Byte array";
}
if (inputStream.read() != 255 || inputStream.read() != 216)
throw new BadElementException(str + " is not a valid JPEG-file.");
int i = 1;
while (true) {
int j = inputStream.read();
if (j < 0)
throw new IOException("Premature EOF while reading JPG.");
if (j == 255) {
int k = inputStream.read();
if (i && k == 224) {
i = 0;
int n = getShort(inputStream);
if (n < 16) {
Utilities.skip(inputStream, n - 2);
continue;
}
byte[] arrayOfByte = new byte[JFIF_ID.length];
int i1 = inputStream.read(arrayOfByte);
if (i1 != arrayOfByte.length)
throw new BadElementException(str + " corrupted JFIF marker.");
boolean bool = true;
int i2;
for (i2 = 0; i2 < arrayOfByte.length; i2++) {
if (arrayOfByte[i2] != JFIF_ID[i2]) {
bool = false;
break;
}
}
if (!bool) {
Utilities.skip(inputStream, n - 2 - arrayOfByte.length);
continue;
}
Utilities.skip(inputStream, 2);
i2 = inputStream.read();
int i3 = getShort(inputStream);
int i4 = getShort(inputStream);
if (i2 == 1) {
this.dpiX = i3;
this.dpiY = i4;
} else if (i2 == 2) {
this.dpiX = (int)((float)i3 * 2.54F + 0.5F);
this.dpiY = (int)((float)i4 * 2.54F + 0.5F);
}
Utilities.skip(inputStream, n - 2 - arrayOfByte.length - 7);
continue;
}
if (k == 238) {
int n = getShort(inputStream) - 2;
byte[] arrayOfByte = new byte[n];
for (int i1 = 0; i1 < n; i1++)
arrayOfByte[i1] = (byte)inputStream.read();
if (arrayOfByte.length >= 12) {
String str1 = new String(arrayOfByte, 0, 5, "ISO-8859-1");
if (str1.equals("Adobe"))
this.invert = true;
}
continue;
}
if (k == 226) {
int n = getShort(inputStream) - 2;
byte[] arrayOfByte = new byte[n];
for (int i1 = 0; i1 < n; i1++)
arrayOfByte[i1] = (byte)inputStream.read();
if (arrayOfByte.length >= 14) {
String str1 = new String(arrayOfByte, 0, 11, "ISO-8859-1");
if (str1.equals("ICC_PROFILE")) {
int i2 = arrayOfByte[12] & 0xFF;
int i3 = arrayOfByte[13] & 0xFF;
if (this.icc == null)
this.icc = new byte[i3][];
this.icc[i2 - 1] = arrayOfByte;
}
}
continue;
}
i = 0;
int m = marker(k);
if (m == 0) {
Utilities.skip(inputStream, 2);
if (inputStream.read() != 8)
throw new BadElementException(str + " must have 8 bits per component.");
this.scaledHeight = (float)getShort(inputStream);
setTop(this.scaledHeight);
this.scaledWidth = (float)getShort(inputStream);
setRight(this.scaledWidth);
this.colorspace = inputStream.read();
this.bpc = 8;
} else {
if (m == 1)
throw new BadElementException(str + ": unsupported JPEG marker: " + k);
if (m != 2)
Utilities.skip(inputStream, getShort(inputStream) - 2);
continue;
}
if (inputStream != null)
inputStream.close();
this.plainWidth = getWidth();
this.plainHeight = getHeight();
return;
}
}
} finally {
if (inputStream != null)
inputStream.close();
}
}
}

View file

@ -0,0 +1,153 @@
package com.lowagie.text;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
public class Jpeg2000 extends Image {
public static final int JP2_JP = 1783636000;
public static final int JP2_IHDR = 1768449138;
public static final int JPIP_JPIP = 1785751920;
public static final int JP2_FTYP = 1718909296;
public static final int JP2_JP2H = 1785737832;
public static final int JP2_COLR = 1668246642;
public static final int JP2_JP2C = 1785737827;
public static final int JP2_URL = 1970433056;
public static final int JP2_DBTL = 1685348972;
public static final int JP2_BPCC = 1651532643;
public static final int JP2_JP2 = 1785737760;
InputStream inp;
int boxLength;
int boxType;
Jpeg2000(Image paramImage) {
super(paramImage);
}
public Jpeg2000(URL paramURL) throws BadElementException, IOException {
super(paramURL);
processParameters();
}
public Jpeg2000(byte[] paramArrayOfbyte) throws BadElementException, IOException {
super((URL)null);
this.rawData = paramArrayOfbyte;
this.originalData = paramArrayOfbyte;
processParameters();
}
public Jpeg2000(byte[] paramArrayOfbyte, float paramFloat1, float paramFloat2) throws BadElementException, IOException {
this(paramArrayOfbyte);
this.scaledWidth = paramFloat1;
this.scaledHeight = paramFloat2;
}
private int cio_read(int paramInt) throws IOException {
int i = 0;
for (int j = paramInt - 1; j >= 0; j--)
i += this.inp.read() << j << 3;
return i;
}
public void jp2_read_boxhdr() throws IOException {
this.boxLength = cio_read(4);
this.boxType = cio_read(4);
if (this.boxLength == 1) {
if (cio_read(4) != 0)
throw new IOException("Cannot handle box sizes higher than 2^32");
this.boxLength = cio_read(4);
if (this.boxLength == 0)
throw new IOException("Unsupported box size == 0");
} else if (this.boxLength == 0) {
throw new IOException("Unsupported box size == 0");
}
}
private void processParameters() throws IOException {
this.type = 33;
this.originalType = 8;
this.inp = null;
try {
if (this.rawData == null) {
this.inp = this.url.openStream();
String str = this.url.toString();
} else {
this.inp = new ByteArrayInputStream(this.rawData);
String str = "Byte array";
}
this.boxLength = cio_read(4);
if (this.boxLength == 12) {
this.boxType = cio_read(4);
if (1783636000 != this.boxType)
throw new IOException("Expected JP Marker");
if (218793738 != cio_read(4))
throw new IOException("Error with JP Marker");
jp2_read_boxhdr();
if (1718909296 != this.boxType)
throw new IOException("Expected FTYP Marker");
Utilities.skip(this.inp, this.boxLength - 8);
jp2_read_boxhdr();
while (true) {
if (1785737832 != this.boxType) {
if (this.boxType == 1785737827)
throw new IOException("Expected JP2H Marker");
Utilities.skip(this.inp, this.boxLength - 8);
jp2_read_boxhdr();
}
if (1785737832 == this.boxType) {
jp2_read_boxhdr();
if (1768449138 != this.boxType)
throw new IOException("Expected IHDR Marker");
this.scaledHeight = (float)cio_read(4);
setTop(this.scaledHeight);
this.scaledWidth = (float)cio_read(4);
setRight(this.scaledWidth);
this.bpc = -1;
} else {
continue;
}
this.plainWidth = getWidth();
this.plainHeight = getHeight();
return;
}
}
if (this.boxLength == -11534511) {
Utilities.skip(this.inp, 4);
int i = cio_read(4);
int j = cio_read(4);
int k = cio_read(4);
int m = cio_read(4);
Utilities.skip(this.inp, 16);
this.colorspace = cio_read(2);
this.bpc = 8;
this.scaledHeight = (float)(j - m);
setTop(this.scaledHeight);
this.scaledWidth = (float)(i - k);
setRight(this.scaledWidth);
} else {
throw new IOException("Not a valid Jpeg2000 file");
}
} finally {
if (this.inp != null) {
try {
this.inp.close();
} catch (Exception e) {}
this.inp = null;
}
}
}
}

View file

@ -0,0 +1,9 @@
package com.lowagie.text;
public interface LargeElement extends Element {
void setComplete(boolean paramBoolean);
boolean isComplete();
void flushContent();
}

View file

@ -0,0 +1,269 @@
package com.lowagie.text;
import com.lowagie.text.factories.RomanAlphabetFactory;
import java.util.ArrayList;
import java.util.Iterator;
public class List implements TextElementArray {
public static final boolean ORDERED = true;
public static final boolean UNORDERED = false;
public static final boolean NUMERICAL = false;
public static final boolean ALPHABETICAL = true;
public static final boolean UPPERCASE = false;
public static final boolean LOWERCASE = true;
protected ArrayList list = new ArrayList();
protected boolean numbered = false;
protected boolean lettered = false;
protected boolean lowercase = false;
protected boolean autoindent = false;
protected boolean alignindent = false;
protected int first = 1;
protected Chunk symbol = new Chunk("- ");
protected String preSymbol = "";
protected String postSymbol = ". ";
protected float indentationLeft = 0.0F;
protected float indentationRight = 0.0F;
protected float symbolIndent = 0.0F;
public List() {
this(false, false);
}
public List(float paramFloat) {
this.symbolIndent = paramFloat;
}
public List(boolean paramBoolean) {
this(paramBoolean, false);
}
public List(boolean paramBoolean1, boolean paramBoolean2) {
this.numbered = paramBoolean1;
this.lettered = paramBoolean2;
this.autoindent = true;
this.alignindent = true;
}
public List(boolean paramBoolean, float paramFloat) {
this(paramBoolean, false, paramFloat);
}
public List(boolean paramBoolean1, boolean paramBoolean2, float paramFloat) {
this.numbered = paramBoolean1;
this.lettered = paramBoolean2;
this.symbolIndent = paramFloat;
}
public boolean process(ElementListener paramElementListener) {
try {
Iterator iterator = this.list.iterator();
while (iterator.hasNext())
paramElementListener.add((Element)iterator.next());
return true;
} catch (DocumentException e) {
return false;
}
}
public int type() {
return 14;
}
public ArrayList getChunks() {
ArrayList arrayList = new ArrayList();
Iterator iterator = this.list.iterator();
while (iterator.hasNext())
arrayList.addAll(((Element)iterator.next()).getChunks());
return arrayList;
}
public boolean add(Object paramObject) {
if (paramObject instanceof ListItem) {
ListItem listItem = (ListItem)paramObject;
if (this.numbered || this.lettered) {
Chunk chunk = new Chunk(this.preSymbol, this.symbol.getFont());
int i = this.first + this.list.size();
if (this.lettered) {
chunk.append(RomanAlphabetFactory.getString(i, this.lowercase));
} else {
chunk.append(String.valueOf(i));
}
chunk.append(this.postSymbol);
listItem.setListSymbol(chunk);
} else {
listItem.setListSymbol(this.symbol);
}
listItem.setIndentationLeft(this.symbolIndent, this.autoindent);
listItem.setIndentationRight(0.0F);
return this.list.add(listItem);
}
if (paramObject instanceof List) {
List list = (List)paramObject;
list.setIndentationLeft(list.getIndentationLeft() + this.symbolIndent);
this.first--;
return this.list.add(list);
}
return (paramObject instanceof String) ? add(new ListItem((String)paramObject)) : false;
}
public void normalizeIndentation() {
float f = 0.0F;
Iterator iterator = this.list.iterator();
while (iterator.hasNext()) {
Element element = (Element)iterator.next();
if (element instanceof ListItem)
f = Math.max(f, ((ListItem)element).getIndentationLeft());
}
iterator = this.list.iterator();
while (iterator.hasNext()) {
Element element = (Element)iterator.next();
if (element instanceof ListItem)
((ListItem)element).setIndentationLeft(f);
}
}
public void setNumbered(boolean paramBoolean) {
this.numbered = paramBoolean;
}
public void setLettered(boolean paramBoolean) {
this.lettered = paramBoolean;
}
public void setLowercase(boolean paramBoolean) {
this.lowercase = paramBoolean;
}
public void setAutoindent(boolean paramBoolean) {
this.autoindent = paramBoolean;
}
public void setAlignindent(boolean paramBoolean) {
this.alignindent = paramBoolean;
}
public void setFirst(int paramInt) {
this.first = paramInt;
}
public void setListSymbol(Chunk paramChunk) {
this.symbol = paramChunk;
}
public void setListSymbol(String paramString) {
this.symbol = new Chunk(paramString);
}
public void setIndentationLeft(float paramFloat) {
this.indentationLeft = paramFloat;
}
public void setIndentationRight(float paramFloat) {
this.indentationRight = paramFloat;
}
public void setSymbolIndent(float paramFloat) {
this.symbolIndent = paramFloat;
}
public ArrayList getItems() {
return this.list;
}
public int size() {
return this.list.size();
}
public boolean isEmpty() {
return this.list.isEmpty();
}
public float getTotalLeading() {
if (this.list.size() < 1)
return -1.0F;
ListItem listItem = (ListItem)this.list.get(0);
return listItem.getTotalLeading();
}
public boolean isNumbered() {
return this.numbered;
}
public boolean isLettered() {
return this.lettered;
}
public boolean isLowercase() {
return this.lowercase;
}
public boolean isAutoindent() {
return this.autoindent;
}
public boolean isAlignindent() {
return this.alignindent;
}
public int getFirst() {
return this.first;
}
public Chunk getSymbol() {
return this.symbol;
}
public float getIndentationLeft() {
return this.indentationLeft;
}
public float getIndentationRight() {
return this.indentationRight;
}
public float getSymbolIndent() {
return this.symbolIndent;
}
public boolean isContent() {
return true;
}
public boolean isNestable() {
return true;
}
public String getPostSymbol() {
return this.postSymbol;
}
public void setPostSymbol(String paramString) {
this.postSymbol = paramString;
}
public String getPreSymbol() {
return this.preSymbol;
}
public void setPreSymbol(String paramString) {
this.preSymbol = paramString;
}
}

View file

@ -0,0 +1,65 @@
package com.lowagie.text;
public class ListItem extends Paragraph {
private static final long serialVersionUID = 1970670787169329006L;
private Chunk symbol;
public ListItem() {}
public ListItem(float paramFloat) {
super(paramFloat);
}
public ListItem(Chunk paramChunk) {
super(paramChunk);
}
public ListItem(String paramString) {
super(paramString);
}
public ListItem(String paramString, Font paramFont) {
super(paramString, paramFont);
}
public ListItem(float paramFloat, Chunk paramChunk) {
super(paramFloat, paramChunk);
}
public ListItem(float paramFloat, String paramString) {
super(paramFloat, paramString);
}
public ListItem(float paramFloat, String paramString, Font paramFont) {
super(paramFloat, paramString, paramFont);
}
public ListItem(Phrase paramPhrase) {
super(paramPhrase);
}
public int type() {
return 15;
}
public void setListSymbol(Chunk paramChunk) {
if (this.symbol == null) {
this.symbol = paramChunk;
if (this.symbol.getFont().isStandardFont())
this.symbol.setFont(this.font);
}
}
public void setIndentationLeft(float paramFloat, boolean paramBoolean) {
if (paramBoolean) {
setIndentationLeft(getListSymbol().getWidthPoint());
} else {
setIndentationLeft(paramFloat);
}
}
public Chunk getListSymbol() {
return this.symbol;
}
}

View file

@ -0,0 +1,470 @@
MOZILLA PUBLIC LICENSE
Version 1.1
---------------
1. Definitions.
1.0.1. "Commercial Use" means distribution or otherwise making the
Covered Code available to a third party.
1.1. "Contributor" means each entity that creates or contributes to
the creation of Modifications.
1.2. "Contributor Version" means the combination of the Original
Code, prior Modifications used by a Contributor, and the Modifications
made by that particular Contributor.
1.3. "Covered Code" means the Original Code or Modifications or the
combination of the Original Code and Modifications, in each case
including portions thereof.
1.4. "Electronic Distribution Mechanism" means a mechanism generally
accepted in the software development community for the electronic
transfer of data.
1.5. "Executable" means Covered Code in any form other than Source
Code.
1.6. "Initial Developer" means the individual or entity identified
as the Initial Developer in the Source Code notice required by Exhibit
A.
1.7. "Larger Work" means a work which combines Covered Code or
portions thereof with code not governed by the terms of this License.
1.8. "License" means this document.
1.8.1. "Licensable" means having the right to grant, to the maximum
extent possible, whether at the time of the initial grant or
subsequently acquired, any and all of the rights conveyed herein.
1.9. "Modifications" means any addition to or deletion from the
substance or structure of either the Original Code or any previous
Modifications. When Covered Code is released as a series of files, a
Modification is:
A. Any addition to or deletion from the contents of a file
containing Original Code or previous Modifications.
B. Any new file that contains any part of the Original Code or
previous Modifications.
1.10. "Original Code" means Source Code of computer software code
which is described in the Source Code notice required by Exhibit A as
Original Code, and which, at the time of its release under this
License is not already Covered Code governed by this License.
1.10.1. "Patent Claims" means any patent claim(s), now owned or
hereafter acquired, including without limitation, method, process,
and apparatus claims, in any patent Licensable by grantor.
1.11. "Source Code" means the preferred form of the Covered Code for
making modifications to it, including all modules it contains, plus
any associated interface definition files, scripts used to control
compilation and installation of an Executable, or source code
differential comparisons against either the Original Code or another
well known, available Covered Code of the Contributor's choice. The
Source Code can be in a compressed or archival form, provided the
appropriate decompression or de-archiving software is widely available
for no charge.
1.12. "You" (or "Your") means an individual or a legal entity
exercising rights under, and complying with all of the terms of, this
License or a future version of this License issued under Section 6.1.
For legal entities, "You" includes any entity which controls, is
controlled by, or is under common control with You. For purposes of
this definition, "control" means (a) the power, direct or indirect,
to cause the direction or management of such entity, whether by
contract or otherwise, or (b) ownership of more than fifty percent
(50%) of the outstanding shares or beneficial ownership of such
entity.
2. Source Code License.
2.1. The Initial Developer Grant.
The Initial Developer hereby grants You a world-wide, royalty-free,
non-exclusive license, subject to third party intellectual property
claims:
(a) under intellectual property rights (other than patent or
trademark) Licensable by Initial Developer to use, reproduce,
modify, display, perform, sublicense and distribute the Original
Code (or portions thereof) with or without Modifications, and/or
as part of a Larger Work; and
(b) under Patents Claims infringed by the making, using or
selling of Original Code, to make, have made, use, practice,
sell, and offer for sale, and/or otherwise dispose of the
Original Code (or portions thereof).
(c) the licenses granted in this Section 2.1(a) and (b) are
effective on the date Initial Developer first distributes
Original Code under the terms of this License.
(d) Notwithstanding Section 2.1(b) above, no patent license is
granted: 1) for code that You delete from the Original Code; 2)
separate from the Original Code; or 3) for infringements caused
by: i) the modification of the Original Code or ii) the
combination of the Original Code with other software or devices.
2.2. Contributor Grant.
Subject to third party intellectual property claims, each Contributor
hereby grants You a world-wide, royalty-free, non-exclusive license
(a) under intellectual property rights (other than patent or
trademark) Licensable by Contributor, to use, reproduce, modify,
display, perform, sublicense and distribute the Modifications
created by such Contributor (or portions thereof) either on an
unmodified basis, with other Modifications, as Covered Code
and/or as part of a Larger Work; and
(b) under Patent Claims infringed by the making, using, or
selling of Modifications made by that Contributor either alone
and/or in combination with its Contributor Version (or portions
of such combination), to make, use, sell, offer for sale, have
made, and/or otherwise dispose of: 1) Modifications made by that
Contributor (or portions thereof); and 2) the combination of
Modifications made by that Contributor with its Contributor
Version (or portions of such combination).
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
effective on the date Contributor first makes Commercial Use of
the Covered Code.
(d) Notwithstanding Section 2.2(b) above, no patent license is
granted: 1) for any code that Contributor has deleted from the
Contributor Version; 2) separate from the Contributor Version;
3) for infringements caused by: i) third party modifications of
Contributor Version or ii) the combination of Modifications made
by that Contributor with other software (except as part of the
Contributor Version) or other devices; or 4) under Patent Claims
infringed by Covered Code in the absence of Modifications made by
that Contributor.
3. Distribution Obligations.
3.1. Application of License.
The Modifications which You create or to which You contribute are
governed by the terms of this License, including without limitation
Section 2.2. The Source Code version of Covered Code may be
distributed only under the terms of this License or a future version
of this License released under Section 6.1, and You must include a
copy of this License with every copy of the Source Code You
distribute. You may not offer or impose any terms on any Source Code
version that alters or restricts the applicable version of this
License or the recipients' rights hereunder. However, You may include
an additional document offering the additional rights described in
Section 3.5.
3.2. Availability of Source Code.
Any Modification which You create or to which You contribute must be
made available in Source Code form under the terms of this License
either on the same media as an Executable version or via an accepted
Electronic Distribution Mechanism to anyone to whom you made an
Executable version available; and if made available via Electronic
Distribution Mechanism, must remain available for at least twelve (12)
months after the date it initially became available, or at least six
(6) months after a subsequent version of that particular Modification
has been made available to such recipients. You are responsible for
ensuring that the Source Code version remains available even if the
Electronic Distribution Mechanism is maintained by a third party.
3.3. Description of Modifications.
You must cause all Covered Code to which You contribute to contain a
file documenting the changes You made to create that Covered Code and
the date of any change. You must include a prominent statement that
the Modification is derived, directly or indirectly, from Original
Code provided by the Initial Developer and including the name of the
Initial Developer in (a) the Source Code, and (b) in any notice in an
Executable version or related documentation in which You describe the
origin or ownership of the Covered Code.
3.4. Intellectual Property Matters
(a) Third Party Claims.
If Contributor has knowledge that a license under a third party's
intellectual property rights is required to exercise the rights
granted by such Contributor under Sections 2.1 or 2.2,
Contributor must include a text file with the Source Code
distribution titled "LEGAL" which describes the claim and the
party making the claim in sufficient detail that a recipient will
know whom to contact. If Contributor obtains such knowledge after
the Modification is made available as described in Section 3.2,
Contributor shall promptly modify the LEGAL file in all copies
Contributor makes available thereafter and shall take other steps
(such as notifying appropriate mailing lists or newsgroups)
reasonably calculated to inform those who received the Covered
Code that new knowledge has been obtained.
(b) Contributor APIs.
If Contributor's Modifications include an application programming
interface and Contributor has knowledge of patent licenses which
are reasonably necessary to implement that API, Contributor must
also include this information in the LEGAL file.
(c) Representations.
Contributor represents that, except as disclosed pursuant to
Section 3.4(a) above, Contributor believes that Contributor's
Modifications are Contributor's original creation(s) and/or
Contributor has sufficient rights to grant the rights conveyed by
this License.
3.5. Required Notices.
You must duplicate the notice in Exhibit A in each file of the Source
Code. If it is not possible to put such notice in a particular Source
Code file due to its structure, then You must include such notice in a
location (such as a relevant directory) where a user would be likely
to look for such a notice. If You created one or more Modification(s)
You may add your name as a Contributor to the notice described in
Exhibit A. You must also duplicate this License in any documentation
for the Source Code where You describe recipients' rights or ownership
rights relating to Covered Code. You may choose to offer, and to
charge a fee for, warranty, support, indemnity or liability
obligations to one or more recipients of Covered Code. However, You
may do so only on Your own behalf, and not on behalf of the Initial
Developer or any Contributor. You must make it absolutely clear than
any such warranty, support, indemnity or liability obligation is
offered by You alone, and You hereby agree to indemnify the Initial
Developer and every Contributor for any liability incurred by the
Initial Developer or such Contributor as a result of warranty,
support, indemnity or liability terms You offer.
3.6. Distribution of Executable Versions.
You may distribute Covered Code in Executable form only if the
requirements of Section 3.1-3.5 have been met for that Covered Code,
and if You include a notice stating that the Source Code version of
the Covered Code is available under the terms of this License,
including a description of how and where You have fulfilled the
obligations of Section 3.2. The notice must be conspicuously included
in any notice in an Executable version, related documentation or
collateral in which You describe recipients' rights relating to the
Covered Code. You may distribute the Executable version of Covered
Code or ownership rights under a license of Your choice, which may
contain terms different from this License, provided that You are in
compliance with the terms of this License and that the license for the
Executable version does not attempt to limit or alter the recipient's
rights in the Source Code version from the rights set forth in this
License. If You distribute the Executable version under a different
license You must make it absolutely clear that any terms which differ
from this License are offered by You alone, not by the Initial
Developer or any Contributor. You hereby agree to indemnify the
Initial Developer and every Contributor for any liability incurred by
the Initial Developer or such Contributor as a result of any such
terms You offer.
3.7. Larger Works.
You may create a Larger Work by combining Covered Code with other code
not governed by the terms of this License and distribute the Larger
Work as a single product. In such a case, You must make sure the
requirements of this License are fulfilled for the Covered Code.
4. Inability to Comply Due to Statute or Regulation.
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Code due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description
must be included in the LEGAL file described in Section 3.4 and must
be included with all distributions of the Source Code. Except to the
extent prohibited by statute or regulation, such description must be
sufficiently detailed for a recipient of ordinary skill to be able to
understand it.
5. Application of this License.
This License applies to code to which the Initial Developer has
attached the notice in Exhibit A and to related Covered Code.
6. Versions of the License.
6.1. New Versions.
Netscape Communications Corporation ("Netscape") may publish revised
and/or new versions of the License from time to time. Each version
will be given a distinguishing version number.
6.2. Effect of New Versions.
Once Covered Code has been published under a particular version of the
License, You may always continue to use it under the terms of that
version. You may also choose to use such Covered Code under the terms
of any subsequent version of the License published by Netscape. No one
other than Netscape has the right to modify the terms applicable to
Covered Code created under this License.
6.3. Derivative Works.
If You create or use a modified version of this License (which you may
only do in order to apply it to code which is not already Covered Code
governed by this License), You must (a) rename Your license so that
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
"MPL", "NPL" or any confusingly similar phrase do not appear in your
license (except to note that your license differs from this License)
and (b) otherwise make it clear that Your version of the license
contains terms which differ from the Mozilla Public License and
Netscape Public License. (Filling in the name of the Initial
Developer, Original Code or Contributor in the notice described in
Exhibit A shall not of themselves be deemed to be modifications of
this License.)
7. DISCLAIMER OF WARRANTY.
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
8. TERMINATION.
8.1. This License and the rights granted hereunder will terminate
automatically if You fail to comply with terms herein and fail to cure
such breach within 30 days of becoming aware of the breach. All
sublicenses to the Covered Code which are properly granted shall
survive any termination of this License. Provisions which, by their
nature, must remain in effect beyond the termination of this License
shall survive.
8.2. If You initiate litigation by asserting a patent infringement
claim (excluding declatory judgment actions) against Initial Developer
or a Contributor (the Initial Developer or Contributor against whom
You file such action is referred to as "Participant") alleging that:
(a) such Participant's Contributor Version directly or indirectly
infringes any patent, then any and all rights granted by such
Participant to You under Sections 2.1 and/or 2.2 of this License
shall, upon 60 days notice from Participant terminate prospectively,
unless if within 60 days after receipt of notice You either: (i)
agree in writing to pay Participant a mutually agreeable reasonable
royalty for Your past and future use of Modifications made by such
Participant, or (ii) withdraw Your litigation claim with respect to
the Contributor Version against such Participant. If within 60 days
of notice, a reasonable royalty and payment arrangement are not
mutually agreed upon in writing by the parties or the litigation claim
is not withdrawn, the rights granted by Participant to You under
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
the 60 day notice period specified above.
(b) any software, hardware, or device, other than such Participant's
Contributor Version, directly or indirectly infringes any patent, then
any rights granted to You by such Participant under Sections 2.1(b)
and 2.2(b) are revoked effective as of the date You first made, used,
sold, distributed, or had made, Modifications made by that
Participant.
8.3. If You assert a patent infringement claim against Participant
alleging that such Participant's Contributor Version directly or
indirectly infringes any patent where such claim is resolved (such as
by license or settlement) prior to the initiation of patent
infringement litigation, then the reasonable value of the licenses
granted by such Participant under Sections 2.1 or 2.2 shall be taken
into account in determining the amount or value of any payment or
license.
8.4. In the event of termination under Sections 8.1 or 8.2 above,
all end user license agreements (excluding distributors and resellers)
which have been validly granted by You or any distributor hereunder
prior to termination shall survive termination.
9. LIMITATION OF LIABILITY.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
10. U.S. GOVERNMENT END USERS.
The Covered Code is a "commercial item," as that term is defined in
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
software" and "commercial computer software documentation," as such
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
all U.S. Government End Users acquire Covered Code with only those
rights set forth herein.
11. MISCELLANEOUS.
This License represents the complete agreement concerning subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. This License shall be governed by
California law provisions (except to the extent applicable law, if
any, provides otherwise), excluding its conflict-of-law provisions.
With respect to disputes in which at least one party is a citizen of,
or an entity chartered or registered to do business in the United
States of America, any litigation relating to this License shall be
subject to the jurisdiction of the Federal Courts of the Northern
District of California, with venue lying in Santa Clara County,
California, with the losing party responsible for costs, including
without limitation, court costs and reasonable attorneys' fees and
expenses. The application of the United Nations Convention on
Contracts for the International Sale of Goods is expressly excluded.
Any law or regulation which provides that the language of a contract
shall be construed against the drafter shall not apply to this
License.
12. RESPONSIBILITY FOR CLAIMS.
As between Initial Developer and the Contributors, each party is
responsible for claims and damages arising, directly or indirectly,
out of its utilization of rights under this License and You agree to
work with Initial Developer and Contributors to distribute such
responsibility on an equitable basis. Nothing herein is intended or
shall be deemed to constitute any admission of liability.
13. MULTIPLE-LICENSED CODE.
Initial Developer may designate portions of the Covered Code as
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
Developer permits you to utilize portions of the Covered Code under
Your choice of the NPL or the alternative licenses, if any, specified
by the Initial Developer in the file described in Exhibit A.
EXHIBIT A -Mozilla Public License.
``The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
The Original Code is ______________________________________.
The Initial Developer of the Original Code is ________________________.
Portions created by ______________________ are Copyright (C) ______
_______________________. All Rights Reserved.
Contributor(s): ______________________________________.
Alternatively, the contents of this file may be used under the terms
of the _____ license (the "[___] License"), in which case the
provisions of [______] License are applicable instead of those
above. If you wish to allow use of your version of this file only
under the terms of the [____] License and not to allow others to use
your version of this file under the MPL, indicate your decision by
deleting the provisions above and replace them with the notice and
other provisions required by the [___] License. If you do not delete
the provisions above, a recipient may use your version of this file
under either the MPL or the [___] License."
[NOTE: The text of this Exhibit A may differ slightly from the text of
the notices in the Source Code files of the Original Code. You should
use the text of this Exhibit A rather than the text found in the
Original Code Source Code for Your Modifications.]

View file

@ -0,0 +1,46 @@
package com.lowagie.text;
import java.util.ArrayList;
import java.util.Properties;
public class MarkedObject implements Element {
protected Element element = null;
protected Properties markupAttributes = new Properties();
protected MarkedObject() {}
public MarkedObject(Element paramElement) {}
public ArrayList getChunks() {
return this.element.getChunks();
}
public boolean process(ElementListener paramElementListener) {
try {
return paramElementListener.add(this.element);
} catch (DocumentException e) {
return false;
}
}
public int type() {
return 50;
}
public boolean isContent() {
return true;
}
public boolean isNestable() {
return true;
}
public Properties getMarkupAttributes() {
return this.markupAttributes;
}
public void setMarkupAttribute(String paramString1, String paramString2) {
this.markupAttributes.setProperty(paramString1, paramString2);
}
}

View file

@ -0,0 +1,108 @@
package com.lowagie.text;
import java.util.Collection;
import java.util.Iterator;
public class MarkedSection extends MarkedObject {
protected MarkedObject title = null;
public MarkedSection(Section paramSection) {
if (paramSection.title != null) {
this.title = new MarkedObject(paramSection.title);
paramSection.setTitle(null);
}
this.element = paramSection;
}
public void add(int paramInt, Object paramObject) {
((Section)this.element).add(paramInt, paramObject);
}
public boolean add(Object paramObject) {
return ((Section)this.element).add(paramObject);
}
public boolean process(ElementListener paramElementListener) {
try {
Iterator iterator = ((Section)this.element).iterator();
while (iterator.hasNext()) {
Element element = (Element)iterator.next();
paramElementListener.add(element);
}
return true;
} catch (DocumentException e) {
return false;
}
}
public boolean addAll(Collection paramCollection) {
return ((Section)this.element).addAll(paramCollection);
}
public MarkedSection addSection(float paramFloat, int paramInt) {
MarkedSection markedSection = ((Section)this.element).addMarkedSection();
markedSection.setIndentation(paramFloat);
markedSection.setNumberDepth(paramInt);
return markedSection;
}
public MarkedSection addSection(float paramFloat) {
MarkedSection markedSection = ((Section)this.element).addMarkedSection();
markedSection.setIndentation(paramFloat);
return markedSection;
}
public MarkedSection addSection(int paramInt) {
MarkedSection markedSection = ((Section)this.element).addMarkedSection();
markedSection.setNumberDepth(paramInt);
return markedSection;
}
public MarkedSection addSection() {
return ((Section)this.element).addMarkedSection();
}
public void setTitle(MarkedObject paramMarkedObject) {
if (paramMarkedObject.element instanceof Paragraph)
this.title = paramMarkedObject;
}
public MarkedObject getTitle() {
Paragraph paragraph = Section.constructTitle((Paragraph)this.title.element, ((Section)this.element).numbers, ((Section)this.element).numberDepth, ((Section)this.element).numberStyle);
MarkedObject markedObject = new MarkedObject(paragraph);
markedObject.markupAttributes = this.title.markupAttributes;
return markedObject;
}
public void setNumberDepth(int paramInt) {
((Section)this.element).setNumberDepth(paramInt);
}
public void setIndentationLeft(float paramFloat) {
((Section)this.element).setIndentationLeft(paramFloat);
}
public void setIndentationRight(float paramFloat) {
((Section)this.element).setIndentationRight(paramFloat);
}
public void setIndentation(float paramFloat) {
((Section)this.element).setIndentation(paramFloat);
}
public void setBookmarkOpen(boolean paramBoolean) {
((Section)this.element).setBookmarkOpen(paramBoolean);
}
public void setTriggerNewPage(boolean paramBoolean) {
((Section)this.element).setTriggerNewPage(paramBoolean);
}
public void setBookmarkTitle(String paramString) {
((Section)this.element).setBookmarkTitle(paramString);
}
public void newPage() {
((Section)this.element).newPage();
}
}

View file

@ -0,0 +1,73 @@
package com.lowagie.text;
import java.util.ArrayList;
public class Meta implements Element {
private int type;
private StringBuffer content;
Meta(int paramInt, String paramString) {
this.type = paramInt;
this.content = new StringBuffer(paramString);
}
public Meta(String paramString1, String paramString2) {
this.type = getType(paramString1);
this.content = new StringBuffer(paramString2);
}
public boolean process(ElementListener paramElementListener) {
try {
return paramElementListener.add(this);
} catch (DocumentException e) {
return false;
}
}
public int type() {
return this.type;
}
public ArrayList getChunks() {
return new ArrayList();
}
public boolean isContent() {
return false;
}
public boolean isNestable() {
return false;
}
public StringBuffer append(String paramString) {
return this.content.append(paramString);
}
public String getContent() {
return this.content.toString();
}
public String getName() {
switch (this.type) {
case 2:
return "subject";
case 3:
return "keywords";
case 4:
return "author";
case 1:
return "title";
case 5:
return "producer";
case 6:
return "creationdate";
}
return "unknown";
}
public static int getType(String paramString) {
return "subject".equals(paramString) ? 2 : ("keywords".equals(paramString) ? 3 : ("author".equals(paramString) ? 4 : ("title".equals(paramString) ? 1 : ("producer".equals(paramString) ? 5 : ("creationdate".equals(paramString) ? 6 : 0)))));
}
}

View file

@ -0,0 +1,128 @@
package com.lowagie.text;
import java.lang.reflect.Field;
public class PageSize {
public static final Rectangle LETTER = new RectangleReadOnly(612.0F, 792.0F);
public static final Rectangle NOTE = new RectangleReadOnly(540.0F, 720.0F);
public static final Rectangle LEGAL = new RectangleReadOnly(612.0F, 1008.0F);
public static final Rectangle TABLOID = new RectangleReadOnly(792.0F, 1224.0F);
public static final Rectangle EXECUTIVE = new RectangleReadOnly(522.0F, 756.0F);
public static final Rectangle POSTCARD = new RectangleReadOnly(283.0F, 416.0F);
public static final Rectangle A0 = new RectangleReadOnly(2384.0F, 3370.0F);
public static final Rectangle A1 = new RectangleReadOnly(1684.0F, 2384.0F);
public static final Rectangle A2 = new RectangleReadOnly(1191.0F, 1684.0F);
public static final Rectangle A3 = new RectangleReadOnly(842.0F, 1191.0F);
public static final Rectangle A4 = new RectangleReadOnly(595.0F, 842.0F);
public static final Rectangle A5 = new RectangleReadOnly(420.0F, 595.0F);
public static final Rectangle A6 = new RectangleReadOnly(297.0F, 420.0F);
public static final Rectangle A7 = new RectangleReadOnly(210.0F, 297.0F);
public static final Rectangle A8 = new RectangleReadOnly(148.0F, 210.0F);
public static final Rectangle A9 = new RectangleReadOnly(105.0F, 148.0F);
public static final Rectangle A10 = new RectangleReadOnly(73.0F, 105.0F);
public static final Rectangle B0 = new RectangleReadOnly(2834.0F, 4008.0F);
public static final Rectangle B1 = new RectangleReadOnly(2004.0F, 2834.0F);
public static final Rectangle B2 = new RectangleReadOnly(1417.0F, 2004.0F);
public static final Rectangle B3 = new RectangleReadOnly(1000.0F, 1417.0F);
public static final Rectangle B4 = new RectangleReadOnly(708.0F, 1000.0F);
public static final Rectangle B5 = new RectangleReadOnly(498.0F, 708.0F);
public static final Rectangle B6 = new RectangleReadOnly(354.0F, 498.0F);
public static final Rectangle B7 = new RectangleReadOnly(249.0F, 354.0F);
public static final Rectangle B8 = new RectangleReadOnly(175.0F, 249.0F);
public static final Rectangle B9 = new RectangleReadOnly(124.0F, 175.0F);
public static final Rectangle B10 = new RectangleReadOnly(87.0F, 124.0F);
public static final Rectangle ARCH_E = new RectangleReadOnly(2592.0F, 3456.0F);
public static final Rectangle ARCH_D = new RectangleReadOnly(1728.0F, 2592.0F);
public static final Rectangle ARCH_C = new RectangleReadOnly(1296.0F, 1728.0F);
public static final Rectangle ARCH_B = new RectangleReadOnly(864.0F, 1296.0F);
public static final Rectangle ARCH_A = new RectangleReadOnly(648.0F, 864.0F);
public static final Rectangle FLSA = new RectangleReadOnly(612.0F, 936.0F);
public static final Rectangle FLSE = new RectangleReadOnly(648.0F, 936.0F);
public static final Rectangle HALFLETTER = new RectangleReadOnly(396.0F, 612.0F);
public static final Rectangle _11X17 = new RectangleReadOnly(792.0F, 1224.0F);
public static final Rectangle ID_1 = new RectangleReadOnly(242.65F, 153.0F);
public static final Rectangle ID_2 = new RectangleReadOnly(297.0F, 210.0F);
public static final Rectangle ID_3 = new RectangleReadOnly(354.0F, 249.0F);
public static final Rectangle LEDGER = new RectangleReadOnly(1224.0F, 792.0F);
public static final Rectangle CROWN_QUARTO = new RectangleReadOnly(535.0F, 697.0F);
public static final Rectangle LARGE_CROWN_QUARTO = new RectangleReadOnly(569.0F, 731.0F);
public static final Rectangle DEMY_QUARTO = new RectangleReadOnly(620.0F, 782.0F);
public static final Rectangle ROYAL_QUARTO = new RectangleReadOnly(671.0F, 884.0F);
public static final Rectangle CROWN_OCTAVO = new RectangleReadOnly(348.0F, 527.0F);
public static final Rectangle LARGE_CROWN_OCTAVO = new RectangleReadOnly(365.0F, 561.0F);
public static final Rectangle DEMY_OCTAVO = new RectangleReadOnly(391.0F, 612.0F);
public static final Rectangle ROYAL_OCTAVO = new RectangleReadOnly(442.0F, 663.0F);
public static final Rectangle SMALL_PAPERBACK = new RectangleReadOnly(314.0F, 504.0F);
public static final Rectangle PENGUIN_SMALL_PAPERBACK = new RectangleReadOnly(314.0F, 513.0F);
public static final Rectangle PENGUIN_LARGE_PAPERBACK = new RectangleReadOnly(365.0F, 561.0F);
public static Rectangle getRectangle(String paramString) {
paramString = paramString.trim().toUpperCase();
int i = paramString.indexOf(' ');
if (i == -1)
try {
Field field = PageSize.class.getDeclaredField(paramString.toUpperCase());
return (Rectangle)field.get(null);
} catch (Exception e) {
throw new RuntimeException("Can't find page size " + paramString);
}
try {
String str1 = paramString.substring(0, i);
String str2 = paramString.substring(i + 1);
return new Rectangle(Float.parseFloat(str1), Float.parseFloat(str2));
} catch (Exception e) {
throw new RuntimeException(paramString + " is not a valid page size format; " + e.getMessage());
}
}
}

View file

@ -0,0 +1,207 @@
package com.lowagie.text;
import java.util.ArrayList;
public class Paragraph extends Phrase {
private static final long serialVersionUID = 7852314969733375514L;
protected int alignment = -1;
protected float multipliedLeading = 0.0F;
protected float indentationLeft;
protected float indentationRight;
private float firstLineIndent = 0.0F;
protected float spacingBefore;
protected float spacingAfter;
private float extraParagraphSpace = 0.0F;
protected boolean keeptogether = false;
public Paragraph() {}
public Paragraph(float paramFloat) {
super(paramFloat);
}
public Paragraph(Chunk paramChunk) {
super(paramChunk);
}
public Paragraph(float paramFloat, Chunk paramChunk) {
super(paramFloat, paramChunk);
}
public Paragraph(String paramString) {
super(paramString);
}
public Paragraph(String paramString, Font paramFont) {
super(paramString, paramFont);
}
public Paragraph(float paramFloat, String paramString) {
super(paramFloat, paramString);
}
public Paragraph(float paramFloat, String paramString, Font paramFont) {
super(paramFloat, paramString, paramFont);
}
public Paragraph(Phrase paramPhrase) {
super(paramPhrase);
if (paramPhrase instanceof Paragraph) {
Paragraph paragraph = (Paragraph)paramPhrase;
setAlignment(paragraph.alignment);
setLeading(paramPhrase.getLeading(), paragraph.multipliedLeading);
setIndentationLeft(paragraph.getIndentationLeft());
setIndentationRight(paragraph.getIndentationRight());
setFirstLineIndent(paragraph.getFirstLineIndent());
setSpacingAfter(paragraph.spacingAfter());
setSpacingBefore(paragraph.spacingBefore());
setExtraParagraphSpace(paragraph.getExtraParagraphSpace());
}
}
public int type() {
return 12;
}
public boolean add(Object paramObject) {
if (paramObject instanceof List) {
List list = (List)paramObject;
list.setIndentationLeft(list.getIndentationLeft() + this.indentationLeft);
list.setIndentationRight(this.indentationRight);
return super.add(list);
}
if (paramObject instanceof Image) {
addSpecial(paramObject);
return true;
}
if (paramObject instanceof Paragraph) {
super.add(paramObject);
ArrayList arrayList = getChunks();
if (arrayList.size() > 0) {
Chunk chunk = (Chunk)arrayList.get(arrayList.size() - 1);
super.add(new Chunk("\n", chunk.getFont()));
} else {
super.add(Chunk.NEWLINE);
}
return true;
}
return super.add(paramObject);
}
public void setAlignment(int paramInt) {
this.alignment = paramInt;
}
public void setAlignment(String paramString) {
if ("Center".equalsIgnoreCase(paramString)) {
this.alignment = 1;
return;
}
if ("Right".equalsIgnoreCase(paramString)) {
this.alignment = 2;
return;
}
if ("Justify".equalsIgnoreCase(paramString)) {
this.alignment = 3;
return;
}
if ("JustifyAll".equalsIgnoreCase(paramString)) {
this.alignment = 8;
return;
}
this.alignment = 0;
}
public void setLeading(float paramFloat) {
this.leading = paramFloat;
this.multipliedLeading = 0.0F;
}
public void setMultipliedLeading(float paramFloat) {
this.leading = 0.0F;
this.multipliedLeading = paramFloat;
}
public void setLeading(float paramFloat1, float paramFloat2) {
this.leading = paramFloat1;
this.multipliedLeading = paramFloat2;
}
public void setIndentationLeft(float paramFloat) {
this.indentationLeft = paramFloat;
}
public void setIndentationRight(float paramFloat) {
this.indentationRight = paramFloat;
}
public void setFirstLineIndent(float paramFloat) {
this.firstLineIndent = paramFloat;
}
public void setSpacingBefore(float paramFloat) {
this.spacingBefore = paramFloat;
}
public void setSpacingAfter(float paramFloat) {
this.spacingAfter = paramFloat;
}
public void setKeepTogether(boolean paramBoolean) {
this.keeptogether = paramBoolean;
}
public boolean getKeepTogether() {
return this.keeptogether;
}
public int getAlignment() {
return this.alignment;
}
public float getMultipliedLeading() {
return this.multipliedLeading;
}
public float getTotalLeading() {
float f = (this.font == null) ? (12.0F * this.multipliedLeading) : this.font.getCalculatedLeading(this.multipliedLeading);
return (f > 0.0F && !hasLeading()) ? f : (getLeading() + f);
}
public float getIndentationLeft() {
return this.indentationLeft;
}
public float getIndentationRight() {
return this.indentationRight;
}
public float getFirstLineIndent() {
return this.firstLineIndent;
}
public float spacingBefore() {
return this.spacingBefore;
}
public float spacingAfter() {
return this.spacingAfter;
}
public float getExtraParagraphSpace() {
return this.extraParagraphSpace;
}
public void setExtraParagraphSpace(float paramFloat) {
this.extraParagraphSpace = paramFloat;
}
}

View file

@ -0,0 +1,275 @@
package com.lowagie.text;
import com.lowagie.text.pdf.HyphenationEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
public class Phrase extends ArrayList implements TextElementArray {
private static final long serialVersionUID = 2643594602455068231L;
protected float leading = Float.NaN;
protected Font font;
protected HyphenationEvent hyphenation = null;
public Phrase() {
this(16.0F);
}
public Phrase(Phrase paramPhrase) {
addAll((Collection)paramPhrase);
this.leading = paramPhrase.getLeading();
this.font = paramPhrase.getFont();
setHyphenation(paramPhrase.getHyphenation());
}
public Phrase(float paramFloat) {
this.leading = paramFloat;
this.font = new Font();
}
public Phrase(Chunk paramChunk) {
super.add(paramChunk);
this.font = paramChunk.getFont();
setHyphenation(paramChunk.getHyphenation());
}
public Phrase(float paramFloat, Chunk paramChunk) {
this.leading = paramFloat;
super.add(paramChunk);
this.font = paramChunk.getFont();
setHyphenation(paramChunk.getHyphenation());
}
public Phrase(String paramString) {
this(Float.NaN, paramString, new Font());
}
public Phrase(String paramString, Font paramFont) {
this(Float.NaN, paramString, paramFont);
}
public Phrase(float paramFloat, String paramString) {
this(paramFloat, paramString, new Font());
}
public Phrase(float paramFloat, String paramString, Font paramFont) {
this.leading = paramFloat;
this.font = paramFont;
if (paramString != null && paramString.length() != 0)
super.add(new Chunk(paramString, paramFont));
}
public boolean process(ElementListener paramElementListener) {
try {
Iterator iterator = iterator();
while (iterator.hasNext())
paramElementListener.add((Element)iterator.next());
return true;
} catch (DocumentException e) {
return false;
}
}
public int type() {
return 11;
}
public ArrayList getChunks() {
ArrayList arrayList = new ArrayList();
Iterator iterator = iterator();
while (iterator.hasNext())
arrayList.addAll(((Element)iterator.next()).getChunks());
return arrayList;
}
public boolean isContent() {
return true;
}
public boolean isNestable() {
return true;
}
public void add(int paramInt, Object paramObject) {
if (paramObject == null)
return;
try {
Element element = (Element)paramObject;
if (element.type() == 10) {
Chunk chunk = (Chunk)element;
if (!this.font.isStandardFont())
chunk.setFont(this.font.difference(chunk.getFont()));
if (this.hyphenation != null)
chunk.setHyphenation(this.hyphenation);
super.add(paramInt, chunk);
} else if (element.type() == 11 || element.type() == 17 || element.type() == 29 || element.type() == 22 || element.type() == 55 || element.type() == 50) {
super.add(paramInt, element);
} else {
throw new ClassCastException(String.valueOf(element.type()));
}
} catch (ClassCastException e) {
throw new ClassCastException("Insertion of illegal Element: " + e.getMessage());
}
}
public boolean add(Object paramObject) {
if (paramObject == null)
return false;
if (paramObject instanceof String)
return super.add(new Chunk((String)paramObject, this.font));
if (paramObject instanceof RtfElementInterface)
return super.add(paramObject);
try {
Phrase phrase;
boolean bool;
Iterator iterator;
Element element = (Element)paramObject;
switch (element.type()) {
case 10:
return addChunk((Chunk)paramObject);
case 11:
case 12:
phrase = (Phrase)paramObject;
bool = true;
iterator = phrase.iterator();
while (iterator.hasNext()) {
Element element1 = (Element)iterator.next();
if (element1 instanceof Chunk) {
bool &= addChunk((Chunk)element1);
continue;
}
bool &= add(element1);
}
return bool;
case 14:
case 17:
case 22:
case 23:
case 29:
case 50:
case 55:
return super.add(paramObject);
}
throw new ClassCastException(String.valueOf(element.type()));
} catch (ClassCastException e) {
throw new ClassCastException("Insertion of illegal Element: " + e.getMessage());
}
}
public boolean addAll(Collection paramCollection) {
Iterator iterator = paramCollection.iterator();
while (iterator.hasNext())
add(iterator.next());
return true;
}
protected boolean addChunk(Chunk paramChunk) {
Font font = paramChunk.getFont();
String str = paramChunk.getContent();
if (this.font != null && !this.font.isStandardFont())
font = this.font.difference(paramChunk.getFont());
if (size() > 0 && !paramChunk.hasAttributes())
try {
Chunk chunk1 = (Chunk)get(size() - 1);
if (!chunk1.hasAttributes() && (font == null || font.compareTo(chunk1.getFont()) == 0) && !"".equals(chunk1.getContent().trim()) && !"".equals(str.trim())) {
chunk1.append(str);
return true;
}
} catch (ClassCastException e) {}
Chunk chunk = new Chunk(str, font);
chunk.setAttributes(paramChunk.getAttributes());
if (chunk.getHyphenation() == null)
chunk.setHyphenation(this.hyphenation);
return super.add(chunk);
}
protected void addSpecial(Object paramObject) {
super.add(paramObject);
}
public void setLeading(float paramFloat) {
this.leading = paramFloat;
}
public void setFont(Font paramFont) {
this.font = paramFont;
}
public float getLeading() {
return (Float.isNaN(this.leading) && this.font != null) ? this.font.getCalculatedLeading(1.5F) : this.leading;
}
public boolean hasLeading() {
return !Float.isNaN(this.leading);
}
public Font getFont() {
return this.font;
}
public String getContent() {
StringBuffer stringBuffer = new StringBuffer();
Iterator iterator = getChunks().iterator();
while (iterator.hasNext())
stringBuffer.append(iterator.next().toString());
return stringBuffer.toString();
}
public boolean isEmpty() {
Element element;
switch (size()) {
case 0:
return true;
case 1:
element = (Element)get(0);
return (element.type() == 10 && ((Chunk)element).isEmpty());
}
return false;
}
public HyphenationEvent getHyphenation() {
return this.hyphenation;
}
public void setHyphenation(HyphenationEvent paramHyphenationEvent) {
this.hyphenation = paramHyphenationEvent;
}
private Phrase(boolean paramBoolean) {}
public static final Phrase getInstance(String paramString) {
return getInstance(16, paramString, new Font());
}
public static final Phrase getInstance(int paramInt, String paramString) {
return getInstance(paramInt, paramString, new Font());
}
public static final Phrase getInstance(int paramInt, String paramString, Font paramFont) {
Phrase phrase = new Phrase(true);
phrase.setLeading((float)paramInt);
phrase.font = paramFont;
if (paramFont.getFamily() != 3 && paramFont.getFamily() != 4 && paramFont.getBaseFont() == null) {
int i;
while ((i = SpecialSymbol.index(paramString)) > -1) {
if (i > 0) {
String str = paramString.substring(0, i);
phrase.add(new Chunk(str, paramFont));
paramString = paramString.substring(i);
}
Font font = new Font(3, paramFont.getSize(), paramFont.getStyle(), paramFont.getColor());
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(SpecialSymbol.getCorrespondingSymbol(paramString.charAt(0)));
for (paramString = paramString.substring(1); SpecialSymbol.index(paramString) == 0; paramString = paramString.substring(1))
stringBuffer.append(SpecialSymbol.getCorrespondingSymbol(paramString.charAt(0)));
phrase.add(new Chunk(stringBuffer.toString(), font));
}
}
if (paramString != null && paramString.length() != 0)
phrase.add(new Chunk(paramString, paramFont));
return phrase;
}
}

View file

@ -0,0 +1,398 @@
package com.lowagie.text;
import com.lowagie.text.pdf.GrayColor;
import java.awt.Color;
import java.util.ArrayList;
public class Rectangle implements Element {
public static final int UNDEFINED = -1;
public static final int TOP = 1;
public static final int BOTTOM = 2;
public static final int LEFT = 4;
public static final int RIGHT = 8;
public static final int NO_BORDER = 0;
public static final int BOX = 15;
protected float llx;
protected float lly;
protected float urx;
protected float ury;
protected int rotation = 0;
protected int border = -1;
protected float borderWidth = -1.0F;
protected Color borderColor = null;
protected Color backgroundColor = null;
protected boolean useVariableBorders = false;
protected float borderWidthLeft = -1.0F;
protected float borderWidthRight = -1.0F;
protected float borderWidthTop = -1.0F;
protected float borderWidthBottom = -1.0F;
protected Color borderColorLeft = null;
protected Color borderColorRight = null;
protected Color borderColorTop = null;
protected Color borderColorBottom = null;
public Rectangle(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4) {
this.llx = paramFloat1;
this.lly = paramFloat2;
this.urx = paramFloat3;
this.ury = paramFloat4;
}
public Rectangle(float paramFloat1, float paramFloat2) {
this(0.0F, 0.0F, paramFloat1, paramFloat2);
}
public Rectangle(Rectangle paramRectangle) {
this(paramRectangle.llx, paramRectangle.lly, paramRectangle.urx, paramRectangle.ury);
cloneNonPositionParameters(paramRectangle);
}
public boolean process(ElementListener paramElementListener) {
try {
return paramElementListener.add(this);
} catch (DocumentException e) {
return false;
}
}
public int type() {
return 30;
}
public ArrayList getChunks() {
return new ArrayList();
}
public boolean isContent() {
return true;
}
public boolean isNestable() {
return false;
}
public void setLeft(float paramFloat) {
this.llx = paramFloat;
}
public float getLeft() {
return this.llx;
}
public float getLeft(float paramFloat) {
return this.llx + paramFloat;
}
public void setRight(float paramFloat) {
this.urx = paramFloat;
}
public float getRight() {
return this.urx;
}
public float getRight(float paramFloat) {
return this.urx - paramFloat;
}
public float getWidth() {
return this.urx - this.llx;
}
public void setTop(float paramFloat) {
this.ury = paramFloat;
}
public float getTop() {
return this.ury;
}
public float getTop(float paramFloat) {
return this.ury - paramFloat;
}
public void setBottom(float paramFloat) {
this.lly = paramFloat;
}
public float getBottom() {
return this.lly;
}
public float getBottom(float paramFloat) {
return this.lly + paramFloat;
}
public float getHeight() {
return this.ury - this.lly;
}
public void normalize() {
if (this.llx > this.urx) {
float f = this.llx;
this.llx = this.urx;
this.urx = f;
}
if (this.lly > this.ury) {
float f = this.lly;
this.lly = this.ury;
this.ury = f;
}
}
public int getRotation() {
return this.rotation;
}
public Rectangle rotate() {
Rectangle rectangle = new Rectangle(this.lly, this.llx, this.ury, this.urx);
this.rotation += 90;
rectangle.rotation %= 360;
return rectangle;
}
public int getBorder() {
return this.border;
}
public boolean hasBorders() {
return (this.border > 0 && (this.borderWidth > 0.0F || this.borderWidthLeft > 0.0F || this.borderWidthRight > 0.0F || this.borderWidthTop > 0.0F || this.borderWidthBottom > 0.0F));
}
public boolean hasBorder(int paramInt) {
return (this.border != -1 && (this.border & paramInt) == paramInt);
}
public void setBorder(int paramInt) {
this.border = paramInt;
}
public void enableBorderSide(int paramInt) {
if (this.border == -1)
this.border = 0;
this.border |= paramInt;
}
public void disableBorderSide(int paramInt) {
if (this.border == -1)
this.border = 0;
this.border &= paramInt ^ 0xFFFFFFFF;
}
public float getBorderWidth() {
return this.borderWidth;
}
public void setBorderWidth(float paramFloat) {
this.borderWidth = paramFloat;
}
public Color getBorderColor() {
return this.borderColor;
}
public void setBorderColor(Color paramColor) {
this.borderColor = paramColor;
}
public Color getBackgroundColor() {
return this.backgroundColor;
}
public void setBackgroundColor(Color paramColor) {
this.backgroundColor = paramColor;
}
public float getGrayFill() {
return (this.backgroundColor instanceof GrayColor) ? ((GrayColor)this.backgroundColor).getGray() : 0.0F;
}
public void setGrayFill(float paramFloat) {
this.backgroundColor = new GrayColor(paramFloat);
}
public boolean isUseVariableBorders() {
return this.useVariableBorders;
}
public void setUseVariableBorders(boolean paramBoolean) {
this.useVariableBorders = paramBoolean;
}
private float getVariableBorderWidth(float paramFloat, int paramInt) {
return ((this.border & paramInt) != 0) ? ((paramFloat != -1.0F) ? paramFloat : this.borderWidth) : 0.0F;
}
private void updateBorderBasedOnWidth(float paramFloat, int paramInt) {
this.useVariableBorders = true;
if (paramFloat > 0.0F) {
enableBorderSide(paramInt);
} else {
disableBorderSide(paramInt);
}
}
public float getBorderWidthLeft() {
return getVariableBorderWidth(this.borderWidthLeft, 4);
}
public void setBorderWidthLeft(float paramFloat) {
this.borderWidthLeft = paramFloat;
updateBorderBasedOnWidth(paramFloat, 4);
}
public float getBorderWidthRight() {
return getVariableBorderWidth(this.borderWidthRight, 8);
}
public void setBorderWidthRight(float paramFloat) {
this.borderWidthRight = paramFloat;
updateBorderBasedOnWidth(paramFloat, 8);
}
public float getBorderWidthTop() {
return getVariableBorderWidth(this.borderWidthTop, 1);
}
public void setBorderWidthTop(float paramFloat) {
this.borderWidthTop = paramFloat;
updateBorderBasedOnWidth(paramFloat, 1);
}
public float getBorderWidthBottom() {
return getVariableBorderWidth(this.borderWidthBottom, 2);
}
public void setBorderWidthBottom(float paramFloat) {
this.borderWidthBottom = paramFloat;
updateBorderBasedOnWidth(paramFloat, 2);
}
public Color getBorderColorLeft() {
return (this.borderColorLeft == null) ? this.borderColor : this.borderColorLeft;
}
public void setBorderColorLeft(Color paramColor) {
this.borderColorLeft = paramColor;
}
public Color getBorderColorRight() {
return (this.borderColorRight == null) ? this.borderColor : this.borderColorRight;
}
public void setBorderColorRight(Color paramColor) {
this.borderColorRight = paramColor;
}
public Color getBorderColorTop() {
return (this.borderColorTop == null) ? this.borderColor : this.borderColorTop;
}
public void setBorderColorTop(Color paramColor) {
this.borderColorTop = paramColor;
}
public Color getBorderColorBottom() {
return (this.borderColorBottom == null) ? this.borderColor : this.borderColorBottom;
}
public void setBorderColorBottom(Color paramColor) {
this.borderColorBottom = paramColor;
}
public Rectangle rectangle(float paramFloat1, float paramFloat2) {
Rectangle rectangle = new Rectangle(this);
if (getTop() > paramFloat1) {
rectangle.setTop(paramFloat1);
rectangle.disableBorderSide(1);
}
if (getBottom() < paramFloat2) {
rectangle.setBottom(paramFloat2);
rectangle.disableBorderSide(2);
}
return rectangle;
}
public void cloneNonPositionParameters(Rectangle paramRectangle) {
this.rotation = paramRectangle.rotation;
this.border = paramRectangle.border;
this.borderWidth = paramRectangle.borderWidth;
this.borderColor = paramRectangle.borderColor;
this.backgroundColor = paramRectangle.backgroundColor;
this.useVariableBorders = paramRectangle.useVariableBorders;
this.borderWidthLeft = paramRectangle.borderWidthLeft;
this.borderWidthRight = paramRectangle.borderWidthRight;
this.borderWidthTop = paramRectangle.borderWidthTop;
this.borderWidthBottom = paramRectangle.borderWidthBottom;
this.borderColorLeft = paramRectangle.borderColorLeft;
this.borderColorRight = paramRectangle.borderColorRight;
this.borderColorTop = paramRectangle.borderColorTop;
this.borderColorBottom = paramRectangle.borderColorBottom;
}
public void softCloneNonPositionParameters(Rectangle paramRectangle) {
if (paramRectangle.rotation != 0)
this.rotation = paramRectangle.rotation;
if (paramRectangle.border != -1)
this.border = paramRectangle.border;
if (paramRectangle.borderWidth != -1.0F)
this.borderWidth = paramRectangle.borderWidth;
if (paramRectangle.borderColor != null)
this.borderColor = paramRectangle.borderColor;
if (paramRectangle.backgroundColor != null)
this.backgroundColor = paramRectangle.backgroundColor;
if (this.useVariableBorders)
this.useVariableBorders = paramRectangle.useVariableBorders;
if (paramRectangle.borderWidthLeft != -1.0F)
this.borderWidthLeft = paramRectangle.borderWidthLeft;
if (paramRectangle.borderWidthRight != -1.0F)
this.borderWidthRight = paramRectangle.borderWidthRight;
if (paramRectangle.borderWidthTop != -1.0F)
this.borderWidthTop = paramRectangle.borderWidthTop;
if (paramRectangle.borderWidthBottom != -1.0F)
this.borderWidthBottom = paramRectangle.borderWidthBottom;
if (paramRectangle.borderColorLeft != null)
this.borderColorLeft = paramRectangle.borderColorLeft;
if (paramRectangle.borderColorRight != null)
this.borderColorRight = paramRectangle.borderColorRight;
if (paramRectangle.borderColorTop != null)
this.borderColorTop = paramRectangle.borderColorTop;
if (paramRectangle.borderColorBottom != null)
this.borderColorBottom = paramRectangle.borderColorBottom;
}
public String toString() {
StringBuffer stringBuffer = new StringBuffer("Rectangle: ");
stringBuffer.append(getWidth());
stringBuffer.append('x');
stringBuffer.append(getHeight());
stringBuffer.append(" (rot: ");
stringBuffer.append(this.rotation);
stringBuffer.append(" degrees)");
return stringBuffer.toString();
}
}

View file

@ -0,0 +1,125 @@
package com.lowagie.text;
import java.awt.Color;
public class RectangleReadOnly extends Rectangle {
public RectangleReadOnly(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4) {
super(paramFloat1, paramFloat2, paramFloat3, paramFloat4);
}
public RectangleReadOnly(float paramFloat1, float paramFloat2) {
super(0.0F, 0.0F, paramFloat1, paramFloat2);
}
public RectangleReadOnly(Rectangle paramRectangle) {
super(paramRectangle.llx, paramRectangle.lly, paramRectangle.urx, paramRectangle.ury);
super.cloneNonPositionParameters(paramRectangle);
}
private void throwReadOnlyError() {
throw new UnsupportedOperationException("RectangleReadOnly: this Rectangle is read only.");
}
public void setLeft(float paramFloat) {
throwReadOnlyError();
}
public void setRight(float paramFloat) {
throwReadOnlyError();
}
public void setTop(float paramFloat) {
throwReadOnlyError();
}
public void setBottom(float paramFloat) {
throwReadOnlyError();
}
public void normalize() {
throwReadOnlyError();
}
public void setBorder(int paramInt) {
throwReadOnlyError();
}
public void enableBorderSide(int paramInt) {
throwReadOnlyError();
}
public void disableBorderSide(int paramInt) {
throwReadOnlyError();
}
public void setBorderWidth(float paramFloat) {
throwReadOnlyError();
}
public void setBorderColor(Color paramColor) {
throwReadOnlyError();
}
public void setBackgroundColor(Color paramColor) {
throwReadOnlyError();
}
public void setGrayFill(float paramFloat) {
throwReadOnlyError();
}
public void setUseVariableBorders(boolean paramBoolean) {
throwReadOnlyError();
}
public void setBorderWidthLeft(float paramFloat) {
throwReadOnlyError();
}
public void setBorderWidthRight(float paramFloat) {
throwReadOnlyError();
}
public void setBorderWidthTop(float paramFloat) {
throwReadOnlyError();
}
public void setBorderWidthBottom(float paramFloat) {
throwReadOnlyError();
}
public void setBorderColorLeft(Color paramColor) {
throwReadOnlyError();
}
public void setBorderColorRight(Color paramColor) {
throwReadOnlyError();
}
public void setBorderColorTop(Color paramColor) {
throwReadOnlyError();
}
public void setBorderColorBottom(Color paramColor) {
throwReadOnlyError();
}
public void cloneNonPositionParameters(Rectangle paramRectangle) {
throwReadOnlyError();
}
public void softCloneNonPositionParameters(Rectangle paramRectangle) {
throwReadOnlyError();
}
public String toString() {
StringBuffer stringBuffer = new StringBuffer("RectangleReadOnly: ");
stringBuffer.append(getWidth());
stringBuffer.append('x');
stringBuffer.append(getHeight());
stringBuffer.append(" (rot: ");
stringBuffer.append(this.rotation);
stringBuffer.append(" degrees)");
return stringBuffer.toString();
}
}

View file

@ -0,0 +1,41 @@
package com.lowagie.text;
import com.lowagie.text.factories.RomanNumberFactory;
public class RomanList extends List {
public RomanList() {
super(true);
}
public RomanList(int paramInt) {
super(true, (float)paramInt);
}
public RomanList(boolean paramBoolean, int paramInt) {
super(true, (float)paramInt);
this.lowercase = paramBoolean;
}
public boolean add(Object paramObject) {
if (paramObject instanceof ListItem) {
ListItem listItem = (ListItem)paramObject;
Chunk chunk = new Chunk(this.preSymbol, this.symbol.getFont());
chunk.append(RomanNumberFactory.getString(this.first + this.list.size(), this.lowercase));
chunk.append(this.postSymbol);
listItem.setListSymbol(chunk);
listItem.setIndentationLeft(this.symbolIndent, this.autoindent);
listItem.setIndentationRight(0.0F);
this.list.add(listItem);
} else {
if (paramObject instanceof List) {
List list = (List)paramObject;
list.setIndentationLeft(list.getIndentationLeft() + this.symbolIndent);
this.first--;
return this.list.add(list);
}
if (paramObject instanceof String)
return add(new ListItem((String)paramObject));
}
return false;
}
}

View file

@ -0,0 +1,159 @@
package com.lowagie.text;
import java.util.ArrayList;
public class Row implements Element {
public static final int NULL = 0;
public static final int CELL = 1;
public static final int TABLE = 2;
protected int columns;
protected int currentColumn;
protected boolean[] reserved;
protected Object[] cells;
protected int horizontalAlignment;
protected Row(int paramInt) {
this.columns = paramInt;
this.reserved = new boolean[paramInt];
this.cells = new Object[paramInt];
this.currentColumn = 0;
}
public boolean process(ElementListener paramElementListener) {
try {
return paramElementListener.add(this);
} catch (DocumentException e) {
return false;
}
}
public int type() {
return 21;
}
public ArrayList getChunks() {
return new ArrayList();
}
public boolean isContent() {
return true;
}
public boolean isNestable() {
return false;
}
void deleteColumn(int paramInt) {
if (paramInt >= this.columns || paramInt < 0)
throw new IndexOutOfBoundsException("getCell at illegal index : " + paramInt);
this.columns--;
boolean[] arrayOfBoolean = new boolean[this.columns];
Cell[] arrayOfCell = new Cell[this.columns];
for (int j = 0; j < paramInt; j++) {
arrayOfBoolean[j] = this.reserved[j];
arrayOfCell[j] = (Cell)this.cells[j];
if (arrayOfCell[j] != null && j + arrayOfCell[j].getColspan() > paramInt)
arrayOfCell[j].setColspan(((Cell)this.cells[j]).getColspan() - 1);
}
for (int i = paramInt; i < this.columns; i++) {
arrayOfBoolean[i] = this.reserved[i + 1];
arrayOfCell[i] = (Cell)this.cells[i + 1];
}
if (this.cells[paramInt] != null && ((Cell)this.cells[paramInt]).getColspan() > 1) {
arrayOfCell[paramInt] = (Cell)this.cells[paramInt];
arrayOfCell[paramInt].setColspan(arrayOfCell[paramInt].getColspan() - 1);
}
this.reserved = arrayOfBoolean;
this.cells = arrayOfCell;
}
int addElement(Object paramObject) {
return addElement(paramObject, this.currentColumn);
}
int addElement(Object paramObject, int paramInt) {
if (paramObject == null)
throw new NullPointerException("addCell - null argument");
if (paramInt < 0 || paramInt > this.columns)
throw new IndexOutOfBoundsException("addCell - illegal column argument");
if (getObjectID(paramObject) != 1 && getObjectID(paramObject) != 2)
throw new IllegalArgumentException("addCell - only Cells or Tables allowed");
int i = Cell.class.isInstance(paramObject) ? ((Cell)paramObject).getColspan() : 1;
if (!reserve(paramInt, i))
return -1;
this.cells[paramInt] = paramObject;
this.currentColumn += i - 1;
return paramInt;
}
void setElement(Object paramObject, int paramInt) {
if (this.reserved[paramInt])
throw new IllegalArgumentException("setElement - position already taken");
this.cells[paramInt] = paramObject;
if (paramObject != null)
this.reserved[paramInt] = true;
}
boolean reserve(int paramInt) {
return reserve(paramInt, 1);
}
boolean reserve(int paramInt1, int paramInt2) {
if (paramInt1 < 0 || paramInt1 + paramInt2 > this.columns)
throw new IndexOutOfBoundsException("reserve - incorrect column/size");
for (int i = paramInt1; i < paramInt1 + paramInt2; i++) {
if (this.reserved[i]) {
for (int j = i; j >= paramInt1; j--)
this.reserved[j] = false;
return false;
}
this.reserved[i] = true;
}
return true;
}
boolean isReserved(int paramInt) {
return this.reserved[paramInt];
}
int getElementID(int paramInt) {
return (this.cells[paramInt] == null) ? 0 : (Cell.class.isInstance(this.cells[paramInt]) ? 1 : (Table.class.isInstance(this.cells[paramInt]) ? 2 : -1));
}
int getObjectID(Object paramObject) {
return (paramObject == null) ? 0 : (Cell.class.isInstance(paramObject) ? 1 : (Table.class.isInstance(paramObject) ? 2 : -1));
}
public Object getCell(int paramInt) {
if (paramInt < 0 || paramInt > this.columns)
throw new IndexOutOfBoundsException("getCell at illegal index :" + paramInt + " max is " + this.columns);
return this.cells[paramInt];
}
public boolean isEmpty() {
for (int i = 0; i < this.columns; i++) {
if (this.cells[i] != null)
return false;
}
return true;
}
public int getColumns() {
return this.columns;
}
public void setHorizontalAlignment(int paramInt) {
this.horizontalAlignment = paramInt;
}
public int getHorizontalAlignment() {
return this.horizontalAlignment;
}
}

View file

@ -0,0 +1,3 @@
package com.lowagie.text;
public interface RtfElementInterface {}

View file

@ -0,0 +1,337 @@
package com.lowagie.text;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
public class Section extends ArrayList implements TextElementArray, LargeElement {
public static final int NUMBERSTYLE_DOTTED = 0;
public static final int NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT = 1;
private static final long serialVersionUID = 3324172577544748043L;
protected Paragraph title;
protected String bookmarkTitle;
protected int numberDepth;
protected int numberStyle = 0;
protected float indentationLeft;
protected float indentationRight;
protected float indentation;
protected boolean bookmarkOpen = true;
protected boolean triggerNewPage = false;
protected int subsections = 0;
protected ArrayList numbers = null;
protected boolean complete = true;
protected boolean addedCompletely = false;
protected boolean notAddedYet = true;
protected Section() {
this.title = new Paragraph();
this.numberDepth = 1;
}
protected Section(Paragraph paramParagraph, int paramInt) {
this.numberDepth = paramInt;
this.title = paramParagraph;
}
public boolean process(ElementListener paramElementListener) {
try {
Iterator iterator = iterator();
while (iterator.hasNext()) {
Element element = (Element)iterator.next();
paramElementListener.add(element);
}
return true;
} catch (DocumentException e) {
return false;
}
}
public int type() {
return 13;
}
public boolean isChapter() {
return (type() == 16);
}
public boolean isSection() {
return (type() == 13);
}
public ArrayList getChunks() {
ArrayList arrayList = new ArrayList();
Iterator iterator = iterator();
while (iterator.hasNext())
arrayList.addAll(((Element)iterator.next()).getChunks());
return arrayList;
}
public boolean isContent() {
return true;
}
public boolean isNestable() {
return false;
}
public void add(int paramInt, Object paramObject) {
if (isAddedCompletely())
throw new IllegalStateException("This LargeElement has already been added to the Document.");
try {
Element element = (Element)paramObject;
if (element.isNestable()) {
super.add(paramInt, element);
} else {
throw new ClassCastException("You can't add a " + element.getClass().getName() + " to a Section.");
}
} catch (ClassCastException e) {
throw new ClassCastException("Insertion of illegal Element: " + e.getMessage());
}
}
public boolean add(Object paramObject) {
if (isAddedCompletely())
throw new IllegalStateException("This LargeElement has already been added to the Document.");
try {
Element element = (Element)paramObject;
if (element.type() == 13) {
Section section = (Section)paramObject;
section.setNumbers(++this.subsections, this.numbers);
return super.add(section);
}
if (paramObject instanceof MarkedSection && ((MarkedObject)paramObject).element.type() == 13) {
MarkedSection markedSection = (MarkedSection)paramObject;
Section section = (Section)markedSection.element;
section.setNumbers(++this.subsections, this.numbers);
return super.add(markedSection);
}
if (element.isNestable())
return super.add(paramObject);
throw new ClassCastException("You can't add a " + element.getClass().getName() + " to a Section.");
} catch (ClassCastException e) {
throw new ClassCastException("Insertion of illegal Element: " + e.getMessage());
}
}
public boolean addAll(Collection paramCollection) {
Iterator iterator = paramCollection.iterator();
while (iterator.hasNext())
add(iterator.next());
return true;
}
public Section addSection(float paramFloat, Paragraph paramParagraph, int paramInt) {
if (isAddedCompletely())
throw new IllegalStateException("This LargeElement has already been added to the Document.");
Section section = new Section(paramParagraph, paramInt);
section.setIndentation(paramFloat);
add(section);
return section;
}
public Section addSection(float paramFloat, Paragraph paramParagraph) {
return addSection(paramFloat, paramParagraph, this.numberDepth + 1);
}
public Section addSection(Paragraph paramParagraph, int paramInt) {
return addSection(0.0F, paramParagraph, paramInt);
}
public MarkedSection addMarkedSection() {
MarkedSection markedSection = new MarkedSection(new Section(null, this.numberDepth + 1));
add(markedSection);
return markedSection;
}
public Section addSection(Paragraph paramParagraph) {
return addSection(0.0F, paramParagraph, this.numberDepth + 1);
}
public Section addSection(float paramFloat, String paramString, int paramInt) {
return addSection(paramFloat, new Paragraph(paramString), paramInt);
}
public Section addSection(String paramString, int paramInt) {
return addSection(new Paragraph(paramString), paramInt);
}
public Section addSection(float paramFloat, String paramString) {
return addSection(paramFloat, new Paragraph(paramString));
}
public Section addSection(String paramString) {
return addSection(new Paragraph(paramString));
}
public void setTitle(Paragraph paramParagraph) {
this.title = paramParagraph;
}
public Paragraph getTitle() {
return constructTitle(this.title, this.numbers, this.numberDepth, this.numberStyle);
}
public static Paragraph constructTitle(Paragraph paramParagraph, ArrayList paramArrayList, int paramInt1, int paramInt2) {
if (paramParagraph == null)
return null;
int i = Math.min(paramArrayList.size(), paramInt1);
if (i < 1)
return paramParagraph;
StringBuffer stringBuffer = new StringBuffer(" ");
for (int j = 0; j < i; j++) {
stringBuffer.insert(0, ".");
stringBuffer.insert(0, ((Integer)paramArrayList.get(j)).intValue());
}
if (paramInt2 == 1)
stringBuffer.deleteCharAt(stringBuffer.length() - 2);
Paragraph paragraph = new Paragraph(paramParagraph);
paragraph.add(0, new Chunk(stringBuffer.toString(), paramParagraph.getFont()));
return paragraph;
}
public void setNumberDepth(int paramInt) {
this.numberDepth = paramInt;
}
public int getNumberDepth() {
return this.numberDepth;
}
public void setNumberStyle(int paramInt) {
this.numberStyle = paramInt;
}
public int getNumberStyle() {
return this.numberStyle;
}
public void setIndentationLeft(float paramFloat) {
this.indentationLeft = paramFloat;
}
public float getIndentationLeft() {
return this.indentationLeft;
}
public void setIndentationRight(float paramFloat) {
this.indentationRight = paramFloat;
}
public float getIndentationRight() {
return this.indentationRight;
}
public void setIndentation(float paramFloat) {
this.indentation = paramFloat;
}
public float getIndentation() {
return this.indentation;
}
public void setBookmarkOpen(boolean paramBoolean) {
this.bookmarkOpen = paramBoolean;
}
public boolean isBookmarkOpen() {
return this.bookmarkOpen;
}
public void setTriggerNewPage(boolean paramBoolean) {
this.triggerNewPage = paramBoolean;
}
public boolean isTriggerNewPage() {
return (this.triggerNewPage && this.notAddedYet);
}
public void setBookmarkTitle(String paramString) {
this.bookmarkTitle = paramString;
}
public Paragraph getBookmarkTitle() {
return (this.bookmarkTitle == null) ? getTitle() : new Paragraph(this.bookmarkTitle);
}
public void setChapterNumber(int paramInt) {
this.numbers.set(this.numbers.size() - 1, new Integer(paramInt));
Iterator iterator = iterator();
while (iterator.hasNext()) {
Object object = iterator.next();
if (object instanceof Section)
((Section)object).setChapterNumber(paramInt);
}
}
public int getDepth() {
return this.numbers.size();
}
private void setNumbers(int paramInt, ArrayList paramArrayList) {
this.numbers = new ArrayList();
this.numbers.add(new Integer(paramInt));
this.numbers.addAll(paramArrayList);
}
public boolean isNotAddedYet() {
return this.notAddedYet;
}
public void setNotAddedYet(boolean paramBoolean) {
this.notAddedYet = paramBoolean;
}
protected boolean isAddedCompletely() {
return this.addedCompletely;
}
protected void setAddedCompletely(boolean paramBoolean) {
this.addedCompletely = paramBoolean;
}
public void flushContent() {
setNotAddedYet(false);
this.title = null;
Iterator iterator = iterator();
while (iterator.hasNext()) {
Element element = (Element)iterator.next();
if (element instanceof Section) {
Section section = (Section)element;
if (!section.isComplete() && size() == 1) {
section.flushContent();
return;
}
section.setAddedCompletely(true);
}
iterator.remove();
}
}
public boolean isComplete() {
return this.complete;
}
public void setComplete(boolean paramBoolean) {
this.complete = paramBoolean;
}
public void newPage() {
add(Chunk.NEXTPAGE);
}
}

View file

@ -0,0 +1,354 @@
package com.lowagie.text;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPCellEvent;
import java.util.ArrayList;
import java.util.Iterator;
public class SimpleCell extends Rectangle implements PdfPCellEvent, TextElementArray {
public static final boolean ROW = true;
public static final boolean CELL = false;
private ArrayList content = new ArrayList();
private float width = 0.0F;
private float widthpercentage = 0.0F;
private float spacing_left = Float.NaN;
private float spacing_right = Float.NaN;
private float spacing_top = Float.NaN;
private float spacing_bottom = Float.NaN;
private float padding_left = Float.NaN;
private float padding_right = Float.NaN;
private float padding_top = Float.NaN;
private float padding_bottom = Float.NaN;
private int colspan = 1;
private int horizontalAlignment = -1;
private int verticalAlignment = -1;
private boolean cellgroup = false;
protected boolean useAscender = false;
protected boolean useDescender = false;
protected boolean useBorderPadding;
public SimpleCell(boolean paramBoolean) {
super(0.0F, 0.0F, 0.0F, 0.0F);
this.cellgroup = paramBoolean;
setBorder(15);
}
public void addElement(Element paramElement) throws BadElementException {
if (this.cellgroup) {
if (paramElement instanceof SimpleCell) {
if (((SimpleCell)paramElement).isCellgroup())
throw new BadElementException("You can't add one row to another row.");
this.content.add(paramElement);
return;
}
throw new BadElementException("You can only add cells to rows, no objects of type " + paramElement.getClass().getName());
}
if (paramElement.type() == 12 || paramElement.type() == 11 || paramElement.type() == 17 || paramElement.type() == 10 || paramElement.type() == 14 || paramElement.type() == 50 || paramElement.type() == 32 || paramElement.type() == 33 || paramElement.type() == 34 || paramElement.type() == 35) {
this.content.add(paramElement);
} else {
throw new BadElementException("You can't add an element of type " + paramElement.getClass().getName() + " to a SimpleCell.");
}
}
public Cell createCell(SimpleCell paramSimpleCell) throws BadElementException {
Cell cell = new Cell();
cell.cloneNonPositionParameters(paramSimpleCell);
cell.softCloneNonPositionParameters(this);
cell.setColspan(this.colspan);
cell.setHorizontalAlignment(this.horizontalAlignment);
cell.setVerticalAlignment(this.verticalAlignment);
cell.setUseAscender(this.useAscender);
cell.setUseBorderPadding(this.useBorderPadding);
cell.setUseDescender(this.useDescender);
Iterator iterator = this.content.iterator();
while (iterator.hasNext()) {
Element element = (Element)iterator.next();
cell.addElement(element);
}
return cell;
}
public PdfPCell createPdfPCell(SimpleCell paramSimpleCell) {
PdfPCell pdfPCell = new PdfPCell();
pdfPCell.setBorder(0);
SimpleCell simpleCell = new SimpleCell(false);
simpleCell.setSpacing_left(this.spacing_left);
simpleCell.setSpacing_right(this.spacing_right);
simpleCell.setSpacing_top(this.spacing_top);
simpleCell.setSpacing_bottom(this.spacing_bottom);
simpleCell.cloneNonPositionParameters(paramSimpleCell);
simpleCell.softCloneNonPositionParameters(this);
pdfPCell.setCellEvent(simpleCell);
pdfPCell.setHorizontalAlignment(paramSimpleCell.horizontalAlignment);
pdfPCell.setVerticalAlignment(paramSimpleCell.verticalAlignment);
pdfPCell.setUseAscender(paramSimpleCell.useAscender);
pdfPCell.setUseBorderPadding(paramSimpleCell.useBorderPadding);
pdfPCell.setUseDescender(paramSimpleCell.useDescender);
pdfPCell.setColspan(this.colspan);
if (this.horizontalAlignment != -1)
pdfPCell.setHorizontalAlignment(this.horizontalAlignment);
if (this.verticalAlignment != -1)
pdfPCell.setVerticalAlignment(this.verticalAlignment);
if (this.useAscender)
pdfPCell.setUseAscender(this.useAscender);
if (this.useBorderPadding)
pdfPCell.setUseBorderPadding(this.useBorderPadding);
if (this.useDescender)
pdfPCell.setUseDescender(this.useDescender);
float f2 = this.spacing_left;
if (Float.isNaN(f2))
f2 = 0.0F;
float f3 = this.spacing_right;
if (Float.isNaN(f3))
f3 = 0.0F;
float f4 = this.spacing_top;
if (Float.isNaN(f4))
f4 = 0.0F;
float f5 = this.spacing_bottom;
if (Float.isNaN(f5))
f5 = 0.0F;
float f1 = this.padding_left;
if (Float.isNaN(f1))
f1 = 0.0F;
pdfPCell.setPaddingLeft(f1 + f2);
f1 = this.padding_right;
if (Float.isNaN(f1))
f1 = 0.0F;
pdfPCell.setPaddingRight(f1 + f3);
f1 = this.padding_top;
if (Float.isNaN(f1))
f1 = 0.0F;
pdfPCell.setPaddingTop(f1 + f4);
f1 = this.padding_bottom;
if (Float.isNaN(f1))
f1 = 0.0F;
pdfPCell.setPaddingBottom(f1 + f5);
Iterator iterator = this.content.iterator();
while (iterator.hasNext()) {
Element element = (Element)iterator.next();
pdfPCell.addElement(element);
}
return pdfPCell;
}
public static SimpleCell getDimensionlessInstance(Rectangle paramRectangle, float paramFloat) {
SimpleCell simpleCell = new SimpleCell(false);
simpleCell.cloneNonPositionParameters(paramRectangle);
simpleCell.setSpacing(paramFloat * 2.0F);
return simpleCell;
}
public void cellLayout(PdfPCell paramPdfPCell, Rectangle paramRectangle, PdfContentByte[] paramArrayOfPdfContentByte) {
float f1 = this.spacing_left;
if (Float.isNaN(f1))
f1 = 0.0F;
float f2 = this.spacing_right;
if (Float.isNaN(f2))
f2 = 0.0F;
float f3 = this.spacing_top;
if (Float.isNaN(f3))
f3 = 0.0F;
float f4 = this.spacing_bottom;
if (Float.isNaN(f4))
f4 = 0.0F;
Rectangle rectangle = new Rectangle(paramRectangle.getLeft(f1), paramRectangle.getBottom(f4), paramRectangle.getRight(f2), paramRectangle.getTop(f3));
rectangle.cloneNonPositionParameters(this);
paramArrayOfPdfContentByte[1].rectangle(rectangle);
rectangle.setBackgroundColor(null);
paramArrayOfPdfContentByte[2].rectangle(rectangle);
}
public void setPadding(float paramFloat) {
if (Float.isNaN(this.padding_right))
setPadding_right(paramFloat);
if (Float.isNaN(this.padding_left))
setPadding_left(paramFloat);
if (Float.isNaN(this.padding_top))
setPadding_top(paramFloat);
if (Float.isNaN(this.padding_bottom))
setPadding_bottom(paramFloat);
}
public int getColspan() {
return this.colspan;
}
public void setColspan(int paramInt) {
if (paramInt > 0)
this.colspan = paramInt;
}
public float getPadding_bottom() {
return this.padding_bottom;
}
public void setPadding_bottom(float paramFloat) {
this.padding_bottom = paramFloat;
}
public float getPadding_left() {
return this.padding_left;
}
public void setPadding_left(float paramFloat) {
this.padding_left = paramFloat;
}
public float getPadding_right() {
return this.padding_right;
}
public void setPadding_right(float paramFloat) {
this.padding_right = paramFloat;
}
public float getPadding_top() {
return this.padding_top;
}
public void setPadding_top(float paramFloat) {
this.padding_top = paramFloat;
}
public float getSpacing_left() {
return this.spacing_left;
}
public float getSpacing_right() {
return this.spacing_right;
}
public float getSpacing_top() {
return this.spacing_top;
}
public float getSpacing_bottom() {
return this.spacing_bottom;
}
public void setSpacing(float paramFloat) {
this.spacing_left = paramFloat;
this.spacing_right = paramFloat;
this.spacing_top = paramFloat;
this.spacing_bottom = paramFloat;
}
public void setSpacing_left(float paramFloat) {
this.spacing_left = paramFloat;
}
public void setSpacing_right(float paramFloat) {
this.spacing_right = paramFloat;
}
public void setSpacing_top(float paramFloat) {
this.spacing_top = paramFloat;
}
public void setSpacing_bottom(float paramFloat) {
this.spacing_bottom = paramFloat;
}
public boolean isCellgroup() {
return this.cellgroup;
}
public void setCellgroup(boolean paramBoolean) {
this.cellgroup = paramBoolean;
}
public int getHorizontalAlignment() {
return this.horizontalAlignment;
}
public void setHorizontalAlignment(int paramInt) {
this.horizontalAlignment = paramInt;
}
public int getVerticalAlignment() {
return this.verticalAlignment;
}
public void setVerticalAlignment(int paramInt) {
this.verticalAlignment = paramInt;
}
public float getWidth() {
return this.width;
}
public void setWidth(float paramFloat) {
this.width = paramFloat;
}
public float getWidthpercentage() {
return this.widthpercentage;
}
public void setWidthpercentage(float paramFloat) {
this.widthpercentage = paramFloat;
}
public boolean isUseAscender() {
return this.useAscender;
}
public void setUseAscender(boolean paramBoolean) {
this.useAscender = paramBoolean;
}
public boolean isUseBorderPadding() {
return this.useBorderPadding;
}
public void setUseBorderPadding(boolean paramBoolean) {
this.useBorderPadding = paramBoolean;
}
public boolean isUseDescender() {
return this.useDescender;
}
public void setUseDescender(boolean paramBoolean) {
this.useDescender = paramBoolean;
}
ArrayList getContent() {
return this.content;
}
public boolean add(Object paramObject) {
try {
addElement((Element)paramObject);
return true;
} catch (ClassCastException e) {
return false;
} catch (BadElementException e) {
throw new ExceptionConverter(e);
}
}
public int type() {
return 20;
}
}

View file

@ -0,0 +1,247 @@
package com.lowagie.text;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfPTableEvent;
import java.util.ArrayList;
import java.util.Iterator;
public class SimpleTable extends Rectangle implements PdfPTableEvent, TextElementArray {
private ArrayList content = new ArrayList();
private float width = 0.0F;
private float widthpercentage = 0.0F;
private float cellspacing;
private float cellpadding;
private int alignment;
public SimpleTable() {
super(0.0F, 0.0F, 0.0F, 0.0F);
setBorder(15);
setBorderWidth(2.0F);
}
public void addElement(SimpleCell paramSimpleCell) throws BadElementException {
if (!paramSimpleCell.isCellgroup())
throw new BadElementException("You can't add cells to a table directly, add them to a row first.");
this.content.add(paramSimpleCell);
}
public Table createTable() throws BadElementException {
if (this.content.isEmpty())
throw new BadElementException("Trying to create a table without rows.");
SimpleCell simpleCell = (SimpleCell)this.content.get(0);
int i = 0;
Iterator iterator1 = simpleCell.getContent().iterator();
while (iterator1.hasNext()) {
SimpleCell simpleCell1 = (SimpleCell)iterator1.next();
i += simpleCell1.getColspan();
}
float[] arrayOfFloat1 = new float[i];
float[] arrayOfFloat2 = new float[i];
Table table = new Table(i);
table.setAlignment(this.alignment);
table.setSpacing(this.cellspacing);
table.setPadding(this.cellpadding);
table.cloneNonPositionParameters(this);
Iterator iterator2 = this.content.iterator();
while (iterator2.hasNext()) {
simpleCell = (SimpleCell)iterator2.next();
int k = 0;
Iterator iterator = simpleCell.getContent().iterator();
while (iterator.hasNext()) {
SimpleCell simpleCell1 = (SimpleCell)iterator.next();
table.addCell(simpleCell1.createCell(simpleCell));
if (simpleCell1.getColspan() == 1) {
if (simpleCell1.getWidth() > 0.0F)
arrayOfFloat1[k] = simpleCell1.getWidth();
if (simpleCell1.getWidthpercentage() > 0.0F)
arrayOfFloat2[k] = simpleCell1.getWidthpercentage();
}
k += simpleCell1.getColspan();
}
}
float f = 0.0F;
for (int j = 0; j < i; j++) {
if (arrayOfFloat1[j] == 0.0F) {
f = 0.0F;
break;
}
f += arrayOfFloat1[j];
}
if (f > 0.0F) {
table.setWidth(f);
table.setLocked(true);
table.setWidths(arrayOfFloat1);
} else {
for (int k = 0; k < i; k++) {
if (arrayOfFloat2[k] == 0.0F) {
f = 0.0F;
break;
}
f += arrayOfFloat2[k];
}
if (f > 0.0F)
table.setWidths(arrayOfFloat2);
}
if (this.width > 0.0F) {
table.setWidth(this.width);
table.setLocked(true);
} else if (this.widthpercentage > 0.0F) {
table.setWidth(this.widthpercentage);
}
return table;
}
public PdfPTable createPdfPTable() throws DocumentException {
if (this.content.isEmpty())
throw new BadElementException("Trying to create a table without rows.");
SimpleCell simpleCell = (SimpleCell)this.content.get(0);
int i = 0;
Iterator iterator1 = simpleCell.getContent().iterator();
while (iterator1.hasNext()) {
SimpleCell simpleCell1 = (SimpleCell)iterator1.next();
i += simpleCell1.getColspan();
}
float[] arrayOfFloat1 = new float[i];
float[] arrayOfFloat2 = new float[i];
PdfPTable pdfPTable = new PdfPTable(i);
pdfPTable.setTableEvent(this);
pdfPTable.setHorizontalAlignment(this.alignment);
Iterator iterator2 = this.content.iterator();
while (iterator2.hasNext()) {
simpleCell = (SimpleCell)iterator2.next();
int k = 0;
Iterator iterator = simpleCell.getContent().iterator();
while (iterator.hasNext()) {
SimpleCell simpleCell1 = (SimpleCell)iterator.next();
if (Float.isNaN(simpleCell1.getSpacing_left()))
simpleCell1.setSpacing_left(this.cellspacing / 2.0F);
if (Float.isNaN(simpleCell1.getSpacing_right()))
simpleCell1.setSpacing_right(this.cellspacing / 2.0F);
if (Float.isNaN(simpleCell1.getSpacing_top()))
simpleCell1.setSpacing_top(this.cellspacing / 2.0F);
if (Float.isNaN(simpleCell1.getSpacing_bottom()))
simpleCell1.setSpacing_bottom(this.cellspacing / 2.0F);
simpleCell1.setPadding(this.cellpadding);
pdfPTable.addCell(simpleCell1.createPdfPCell(simpleCell));
if (simpleCell1.getColspan() == 1) {
if (simpleCell1.getWidth() > 0.0F)
arrayOfFloat1[k] = simpleCell1.getWidth();
if (simpleCell1.getWidthpercentage() > 0.0F)
arrayOfFloat2[k] = simpleCell1.getWidthpercentage();
}
k += simpleCell1.getColspan();
}
}
float f = 0.0F;
for (int j = 0; j < i; j++) {
if (arrayOfFloat1[j] == 0.0F) {
f = 0.0F;
break;
}
f += arrayOfFloat1[j];
}
if (f > 0.0F) {
pdfPTable.setTotalWidth(f);
pdfPTable.setWidths(arrayOfFloat1);
} else {
for (int k = 0; k < i; k++) {
if (arrayOfFloat2[k] == 0.0F) {
f = 0.0F;
break;
}
f += arrayOfFloat2[k];
}
if (f > 0.0F)
pdfPTable.setWidths(arrayOfFloat2);
}
if (this.width > 0.0F)
pdfPTable.setTotalWidth(this.width);
if (this.widthpercentage > 0.0F)
pdfPTable.setWidthPercentage(this.widthpercentage);
return pdfPTable;
}
public static SimpleTable getDimensionlessInstance(Rectangle paramRectangle, float paramFloat) {
SimpleTable simpleTable = new SimpleTable();
simpleTable.cloneNonPositionParameters(paramRectangle);
simpleTable.setCellspacing(paramFloat);
return simpleTable;
}
public void tableLayout(PdfPTable paramPdfPTable, float[][] paramArrayOffloat, float[] paramArrayOffloat1, int paramInt1, int paramInt2, PdfContentByte[] paramArrayOfPdfContentByte) {
float[] arrayOfFloat = paramArrayOffloat[0];
Rectangle rectangle = new Rectangle(arrayOfFloat[0], paramArrayOffloat1[paramArrayOffloat1.length - 1], arrayOfFloat[arrayOfFloat.length - 1], paramArrayOffloat1[0]);
rectangle.cloneNonPositionParameters(this);
int i = rectangle.getBorder();
rectangle.setBorder(0);
paramArrayOfPdfContentByte[1].rectangle(rectangle);
rectangle.setBorder(i);
rectangle.setBackgroundColor(null);
paramArrayOfPdfContentByte[2].rectangle(rectangle);
}
public float getCellpadding() {
return this.cellpadding;
}
public void setCellpadding(float paramFloat) {
this.cellpadding = paramFloat;
}
public float getCellspacing() {
return this.cellspacing;
}
public void setCellspacing(float paramFloat) {
this.cellspacing = paramFloat;
}
public int getAlignment() {
return this.alignment;
}
public void setAlignment(int paramInt) {
this.alignment = paramInt;
}
public float getWidth() {
return this.width;
}
public void setWidth(float paramFloat) {
this.width = paramFloat;
}
public float getWidthpercentage() {
return this.widthpercentage;
}
public void setWidthpercentage(float paramFloat) {
this.widthpercentage = paramFloat;
}
public int type() {
return 22;
}
public boolean isNestable() {
return true;
}
public boolean add(Object paramObject) {
try {
addElement((SimpleCell)paramObject);
return true;
} catch (ClassCastException e) {
return false;
} catch (BadElementException e) {
throw new ExceptionConverter(e);
}
}
}

View file

@ -0,0 +1,125 @@
package com.lowagie.text;
public class SpecialSymbol {
public static int index(String paramString) {
int i = paramString.length();
for (int j = 0; j < i; j++) {
if (getCorrespondingSymbol(paramString.charAt(j)) != ' ')
return j;
}
return -1;
}
public static Chunk get(char paramChar, Font paramFont) {
char c = getCorrespondingSymbol(paramChar);
if (c == ' ')
return new Chunk(String.valueOf(paramChar), paramFont);
Font font = new Font(3, paramFont.getSize(), paramFont.getStyle(), paramFont.getColor());
String str = String.valueOf(c);
return new Chunk(str, font);
}
public static char getCorrespondingSymbol(char paramChar) {
switch (paramChar) {
case 'Α':
return 'A';
case 'Β':
return 'B';
case 'Γ':
return 'G';
case 'Δ':
return 'D';
case 'Ε':
return 'E';
case 'Ζ':
return 'Z';
case 'Η':
return 'H';
case 'Θ':
return 'Q';
case 'Ι':
return 'I';
case 'Κ':
return 'K';
case 'Λ':
return 'L';
case 'Μ':
return 'M';
case 'Ν':
return 'N';
case 'Ξ':
return 'X';
case 'Ο':
return 'O';
case 'Π':
return 'P';
case 'Ρ':
return 'R';
case 'Σ':
return 'S';
case 'Τ':
return 'T';
case 'Υ':
return 'U';
case 'Φ':
return 'J';
case 'Χ':
return 'C';
case 'Ψ':
return 'Y';
case 'Ω':
return 'W';
case 'α':
return 'a';
case 'β':
return 'b';
case 'γ':
return 'g';
case 'δ':
return 'd';
case 'ε':
return 'e';
case 'ζ':
return 'z';
case 'η':
return 'h';
case 'θ':
return 'q';
case 'ι':
return 'i';
case 'κ':
return 'k';
case 'λ':
return 'l';
case 'μ':
return 'm';
case 'ν':
return 'n';
case 'ξ':
return 'x';
case 'ο':
return 'o';
case 'π':
return 'p';
case 'ρ':
return 'r';
case 'ς':
return 'V';
case 'σ':
return 's';
case 'τ':
return 't';
case 'υ':
return 'u';
case 'φ':
return 'j';
case 'χ':
return 'c';
case 'ψ':
return 'y';
case 'ω':
return 'w';
}
return ' ';
}
}

View file

@ -0,0 +1,7 @@
package com.lowagie.text;
import com.lowagie.text.pdf.PdfChunk;
public interface SplitCharacter {
boolean isSplitCharacter(int paramInt1, int paramInt2, int paramInt3, char[] paramArrayOfchar, PdfChunk[] paramArrayOfPdfChunk);
}

View file

@ -0,0 +1,747 @@
package com.lowagie.text;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import java.awt.Dimension;
import java.awt.Point;
import java.util.ArrayList;
import java.util.Iterator;
public class Table extends Rectangle implements LargeElement {
private int columns;
private ArrayList rows = new ArrayList();
private Point curPosition = new Point(0, 0);
private Cell defaultCell = new Cell(true);
private int lastHeaderRow = -1;
private int alignment = 1;
private float cellpadding;
private float cellspacing;
private float width = 80.0F;
private boolean locked = false;
private float[] widths;
private boolean mTableInserted = false;
protected boolean autoFillEmptyCells = false;
boolean tableFitsPage = false;
boolean cellsFitPage = false;
float offset = Float.NaN;
protected boolean convert2pdfptable = false;
protected boolean notAddedYet = true;
protected boolean complete = true;
public Table(int paramInt) throws BadElementException {
this(paramInt, 1);
}
public Table(int paramInt1, int paramInt2) throws BadElementException {
super(0.0F, 0.0F, 0.0F, 0.0F);
setBorder(15);
setBorderWidth(1.0F);
this.defaultCell.setBorder(15);
if (paramInt1 <= 0)
throw new BadElementException("A table should have at least 1 column.");
this.columns = paramInt1;
for (int i = 0; i < paramInt2; i++)
this.rows.add(new Row(paramInt1));
this.curPosition = new Point(0, 0);
this.widths = new float[paramInt1];
float f = 100.0F / (float)paramInt1;
for (int j = 0; j < paramInt1; j++)
this.widths[j] = f;
}
public Table(Table paramTable) {
super(0.0F, 0.0F, 0.0F, 0.0F);
cloneNonPositionParameters(paramTable);
this.columns = paramTable.columns;
this.rows = paramTable.rows;
this.curPosition = paramTable.curPosition;
this.defaultCell = paramTable.defaultCell;
this.lastHeaderRow = paramTable.lastHeaderRow;
this.alignment = paramTable.alignment;
this.cellpadding = paramTable.cellpadding;
this.cellspacing = paramTable.cellspacing;
this.width = paramTable.width;
this.widths = paramTable.widths;
this.autoFillEmptyCells = paramTable.autoFillEmptyCells;
this.tableFitsPage = paramTable.tableFitsPage;
this.cellsFitPage = paramTable.cellsFitPage;
this.offset = paramTable.offset;
this.convert2pdfptable = paramTable.convert2pdfptable;
}
public boolean process(ElementListener paramElementListener) {
try {
return paramElementListener.add(this);
} catch (DocumentException e) {
return false;
}
}
public int type() {
return 22;
}
public ArrayList getChunks() {
return new ArrayList();
}
public boolean isNestable() {
return true;
}
public int getColumns() {
return this.columns;
}
public int size() {
return this.rows.size();
}
public Dimension getDimension() {
return new Dimension(this.columns, size());
}
public Cell getDefaultCell() {
return this.defaultCell;
}
public void setDefaultCell(Cell paramCell) {
this.defaultCell = paramCell;
}
public int getLastHeaderRow() {
return this.lastHeaderRow;
}
public void setLastHeaderRow(int paramInt) {
this.lastHeaderRow = paramInt;
}
public int endHeaders() {
this.lastHeaderRow = this.curPosition.x - 1;
return this.lastHeaderRow;
}
public int getAlignment() {
return this.alignment;
}
public void setAlignment(int paramInt) {
this.alignment = paramInt;
}
public void setAlignment(String paramString) {
if ("Left".equalsIgnoreCase(paramString)) {
this.alignment = 0;
return;
}
if ("right".equalsIgnoreCase(paramString)) {
this.alignment = 2;
return;
}
this.alignment = 1;
}
public float getPadding() {
return this.cellpadding;
}
public void setPadding(float paramFloat) {
this.cellpadding = paramFloat;
}
public float getSpacing() {
return this.cellspacing;
}
public void setSpacing(float paramFloat) {
this.cellspacing = paramFloat;
}
public void setAutoFillEmptyCells(boolean paramBoolean) {
this.autoFillEmptyCells = paramBoolean;
}
public float getWidth() {
return this.width;
}
public void setWidth(float paramFloat) {
this.width = paramFloat;
}
public boolean isLocked() {
return this.locked;
}
public void setLocked(boolean paramBoolean) {
this.locked = paramBoolean;
}
public float[] getProportionalWidths() {
return this.widths;
}
public void setWidths(float[] paramArrayOffloat) throws BadElementException {
if (paramArrayOffloat.length != this.columns)
throw new BadElementException("Wrong number of columns.");
float f = 0.0F;
for (int i = 0; i < this.columns; i++)
f += paramArrayOffloat[i];
this.widths[this.columns - 1] = 100.0F;
for (int j = 0; j < this.columns - 1; j++) {
float f1 = 100.0F * paramArrayOffloat[j] / f;
this.widths[j] = f1;
this.widths[this.columns - 1] = this.widths[this.columns - 1] - f1;
}
}
public void setWidths(int[] paramArrayOfint) throws DocumentException {
float[] arrayOfFloat = new float[paramArrayOfint.length];
for (int i = 0; i < paramArrayOfint.length; i++)
arrayOfFloat[i] = (float)paramArrayOfint[i];
setWidths(arrayOfFloat);
}
public boolean isTableFitsPage() {
return this.tableFitsPage;
}
public void setTableFitsPage(boolean paramBoolean) {
this.tableFitsPage = paramBoolean;
if (paramBoolean)
setCellsFitPage(true);
}
public boolean isCellsFitPage() {
return this.cellsFitPage;
}
public void setCellsFitPage(boolean paramBoolean) {
this.cellsFitPage = paramBoolean;
}
public void setOffset(float paramFloat) {
this.offset = paramFloat;
}
public float getOffset() {
return this.offset;
}
public boolean isConvert2pdfptable() {
return this.convert2pdfptable;
}
public void setConvert2pdfptable(boolean paramBoolean) {
this.convert2pdfptable = paramBoolean;
}
public void addCell(Cell paramCell, int paramInt1, int paramInt2) throws BadElementException {
addCell(paramCell, new Point(paramInt1, paramInt2));
}
public void addCell(Cell paramCell, Point paramPoint) throws BadElementException {
if (paramCell == null)
throw new NullPointerException("addCell - cell has null-value");
if (paramPoint == null)
throw new NullPointerException("addCell - point has null-value");
if (paramCell.isTable())
insertTable((Table)paramCell.getElements().next(), paramPoint);
if (paramPoint.x < 0)
throw new BadElementException("row coordinate of location must be >= 0");
if (paramPoint.y <= 0 && paramPoint.y > this.columns)
throw new BadElementException("column coordinate of location must be >= 0 and < nr of columns");
if (!isValidLocation(paramCell, paramPoint))
throw new BadElementException("Adding a cell at the location (" + paramPoint.x + "," + paramPoint.y + ") with a colspan of " + paramCell.getColspan() + " and a rowspan of " + paramCell.getRowspan() + " is illegal (beyond boundaries/overlapping).");
if (paramCell.getBorder() == -1)
paramCell.setBorder(this.defaultCell.getBorder());
paramCell.fill();
placeCell(this.rows, paramCell, paramPoint);
setCurrentLocationToNextValidPosition(paramPoint);
}
public void addCell(Cell paramCell) {
try {
addCell(paramCell, this.curPosition);
} catch (BadElementException e) {}
}
public void addCell(Phrase paramPhrase) throws BadElementException {
addCell(paramPhrase, this.curPosition);
}
public void addCell(Phrase paramPhrase, Point paramPoint) throws BadElementException {
Cell cell = new Cell(paramPhrase);
cell.setBorder(this.defaultCell.getBorder());
cell.setBorderWidth(this.defaultCell.getBorderWidth());
cell.setBorderColor(this.defaultCell.getBorderColor());
cell.setBackgroundColor(this.defaultCell.getBackgroundColor());
cell.setHorizontalAlignment(this.defaultCell.getHorizontalAlignment());
cell.setVerticalAlignment(this.defaultCell.getVerticalAlignment());
cell.setColspan(this.defaultCell.getColspan());
cell.setRowspan(this.defaultCell.getRowspan());
addCell(cell, paramPoint);
}
public void addCell(String paramString) throws BadElementException {
addCell(new Phrase(paramString), this.curPosition);
}
public void addCell(String paramString, Point paramPoint) throws BadElementException {
addCell(new Phrase(paramString), paramPoint);
}
public void insertTable(Table paramTable) {
if (paramTable == null)
throw new NullPointerException("insertTable - table has null-value");
insertTable(paramTable, this.curPosition);
}
public void insertTable(Table paramTable, int paramInt1, int paramInt2) {
if (paramTable == null)
throw new NullPointerException("insertTable - table has null-value");
insertTable(paramTable, new Point(paramInt1, paramInt2));
}
public void insertTable(Table paramTable, Point paramPoint) {
if (paramTable == null)
throw new NullPointerException("insertTable - table has null-value");
if (paramPoint == null)
throw new NullPointerException("insertTable - point has null-value");
this.mTableInserted = true;
paramTable.complete();
if (paramPoint.y > this.columns)
throw new IllegalArgumentException("insertTable -- wrong columnposition(" + paramPoint.y + ") of location; max =" + this.columns);
int i = paramPoint.x + 1 - this.rows.size();
int j = 0;
if (i > 0)
while (j < i) {
this.rows.add(new Row(this.columns));
j++;
}
((Row)this.rows.get(paramPoint.x)).setElement(paramTable, paramPoint.y);
setCurrentLocationToNextValidPosition(paramPoint);
}
public void addColumns(int paramInt) {
ArrayList arrayList = new ArrayList(this.rows.size());
int i = this.columns + paramInt;
for (int j = 0; j < this.rows.size(); j++) {
Row row = new Row(i);
for (int n = 0; n < this.columns; n++)
row.setElement(((Row)this.rows.get(j)).getCell(n), n);
for (int m = this.columns; m < i && j < this.curPosition.x; m++)
row.setElement(null, m);
arrayList.add(row);
}
float[] arrayOfFloat = new float[i];
System.arraycopy(this.widths, 0, arrayOfFloat, 0, this.columns);
for (int k = this.columns; k < i; k++)
arrayOfFloat[k] = 0.0F;
this.columns = i;
this.widths = arrayOfFloat;
this.rows = arrayList;
}
public void deleteColumn(int paramInt) throws BadElementException {
float[] arrayOfFloat = new float[--this.columns];
System.arraycopy(this.widths, 0, arrayOfFloat, 0, paramInt);
System.arraycopy(this.widths, paramInt + 1, arrayOfFloat, paramInt, this.columns - paramInt);
setWidths(arrayOfFloat);
System.arraycopy(this.widths, 0, arrayOfFloat, 0, this.columns);
this.widths = arrayOfFloat;
int i = this.rows.size();
for (int j = 0; j < i; j++) {
Row row = (Row)this.rows.get(j);
row.deleteColumn(paramInt);
this.rows.set(j, row);
}
if (paramInt == this.columns)
this.curPosition.setLocation(this.curPosition.x + 1, 0);
}
public boolean deleteRow(int paramInt) {
if (paramInt < 0 || paramInt >= this.rows.size())
return false;
this.rows.remove(paramInt);
this.curPosition.setLocation(this.curPosition.x - 1, this.curPosition.y);
return true;
}
public void deleteAllRows() {
this.rows.clear();
this.rows.add(new Row(this.columns));
this.curPosition.setLocation(0, 0);
this.lastHeaderRow = -1;
}
public boolean deleteLastRow() {
return deleteRow(this.rows.size() - 1);
}
public void complete() {
if (this.mTableInserted) {
mergeInsertedTables();
this.mTableInserted = false;
}
if (this.autoFillEmptyCells)
fillEmptyMatrixCells();
}
public Object getElement(int paramInt1, int paramInt2) {
return ((Row)this.rows.get(paramInt1)).getCell(paramInt2);
}
private void mergeInsertedTables() {
int i = 0;
int j = 0;
float[] arrayOfFloat = null;
int[] arrayOfInt1 = new int[this.columns];
float[][] arrayOfFloat1 = new float[this.columns][];
int[] arrayOfInt2 = new int[this.rows.size()];
ArrayList arrayList = null;
boolean bool = false;
int k = 0;
int m = 0;
int n = 0;
int i1 = 0;
Table table = null;
for (j = 0; j < this.columns; j++) {
i1 = 1;
float[] arrayOfFloat2 = null;
for (int i2 = 0; i2 < this.rows.size(); i2++) {
if (Table.class.isInstance(((Row)this.rows.get(i2)).getCell(j))) {
bool = true;
table = (Table)((Row)this.rows.get(i2)).getCell(j);
if (arrayOfFloat2 == null) {
arrayOfFloat2 = table.widths;
i1 = arrayOfFloat2.length;
} else {
int i3 = (table.getDimension()).width;
float[] arrayOfFloat3 = new float[i3 * arrayOfFloat2.length];
float f1 = 0.0F;
float f2 = 0.0F;
float f3 = 0.0F;
int i4 = 0;
int i5 = 0;
int i6 = 0;
f1 += arrayOfFloat2[0];
f2 += table.widths[0];
while (i4 < arrayOfFloat2.length && i5 < i3) {
if (f2 > f1) {
arrayOfFloat3[i6] = f1 - f3;
if (++i4 < arrayOfFloat2.length)
f1 += arrayOfFloat2[i4];
} else {
arrayOfFloat3[i6] = f2 - f3;
i5++;
if ((double)Math.abs(f2 - f1) < 1.0E-4D)
if (++i4 < arrayOfFloat2.length)
f1 += arrayOfFloat2[i4];
if (i5 < i3)
f2 += table.widths[i5];
}
f3 += arrayOfFloat3[i6];
i6++;
}
arrayOfFloat2 = new float[i6];
System.arraycopy(arrayOfFloat3, 0, arrayOfFloat2, 0, i6);
i1 = i6;
}
}
}
arrayOfFloat1[j] = arrayOfFloat2;
m += i1;
arrayOfInt1[j] = i1;
}
for (i = 0; i < this.rows.size(); i++) {
n = 1;
for (int i2 = 0; i2 < this.columns; i2++) {
if (Table.class.isInstance(((Row)this.rows.get(i)).getCell(i2))) {
bool = true;
table = (Table)((Row)this.rows.get(i)).getCell(i2);
if ((table.getDimension()).height > n)
n = (table.getDimension()).height;
}
}
k += n;
arrayOfInt2[i] = n;
}
if (m != this.columns || k != this.rows.size() || bool) {
arrayOfFloat = new float[m];
int i4 = 0;
int i5;
for (i5 = 0; i5 < this.widths.length; i5++) {
if (arrayOfInt1[i5] != 1) {
for (int i7 = 0; i7 < arrayOfInt1[i5]; i7++) {
arrayOfFloat[i4] = this.widths[i5] * arrayOfFloat1[i5][i7] / 100.0F;
i4++;
}
} else {
arrayOfFloat[i4] = this.widths[i5];
i4++;
}
}
arrayList = new ArrayList(k);
for (int i2 = 0; i2 < k; i2++)
arrayList.add(new Row(m));
i5 = 0;
int i6 = 0;
Object object = null;
for (int i3 = 0; i3 < this.rows.size(); i3++) {
i6 = 0;
n = 1;
for (int i7 = 0; i7 < this.columns; i7++) {
if (Table.class.isInstance(((Row)this.rows.get(i3)).getCell(i7))) {
table = (Table)((Row)this.rows.get(i3)).getCell(i7);
int[] arrayOfInt = new int[table.widths.length + 1];
int i8 = 0;
int i9 = 0;
while (i8 < table.widths.length) {
arrayOfInt[i8] = i6 + i9;
float f1 = table.widths[i8];
float f2 = 0.0F;
while (i9 < arrayOfInt1[i7]) {
f2 += arrayOfFloat1[i7][i9++];
if ((double)Math.abs(f1 - f2) < 1.0E-4D)
break;
}
i8++;
}
arrayOfInt[i8] = i6 + i9;
for (int i10 = 0; i10 < (table.getDimension()).height; i10++) {
for (int i11 = 0; i11 < (table.getDimension()).width; i11++) {
object = table.getElement(i10, i11);
if (object != null) {
int i12 = i6 + i11;
if (Cell.class.isInstance(object)) {
Cell cell = (Cell)object;
i12 = arrayOfInt[i11];
int i13 = arrayOfInt[i11 + cell.getColspan()];
cell.setColspan(i13 - i12);
}
((Row)arrayList.get(i10 + i5)).addElement(object, i12);
}
}
}
} else {
Object object1 = getElement(i3, i7);
if (Cell.class.isInstance(object1)) {
((Cell)object1).setRowspan(((Cell)((Row)this.rows.get(i3)).getCell(i7)).getRowspan() + arrayOfInt2[i3] - 1);
((Cell)object1).setColspan(((Cell)((Row)this.rows.get(i3)).getCell(i7)).getColspan() + arrayOfInt1[i7] - 1);
placeCell(arrayList, (Cell)object1, new Point(i5, i6));
}
}
i6 += arrayOfInt1[i7];
}
i5 += arrayOfInt2[i3];
}
this.columns = m;
this.rows = arrayList;
this.widths = arrayOfFloat;
}
}
private void fillEmptyMatrixCells() {
try {
for (int i = 0; i < this.rows.size(); i++) {
for (int j = 0; j < this.columns; j++) {
if (!((Row)this.rows.get(i)).isReserved(j))
addCell(this.defaultCell, new Point(i, j));
}
}
} catch (BadElementException e) {
throw new ExceptionConverter(e);
}
}
private boolean isValidLocation(Cell paramCell, Point paramPoint) {
if (paramPoint.x < this.rows.size()) {
if (paramPoint.y + paramCell.getColspan() > this.columns)
return false;
int i = (this.rows.size() - paramPoint.x > paramCell.getRowspan()) ? paramCell.getRowspan() : (this.rows.size() - paramPoint.x);
int j = (this.columns - paramPoint.y > paramCell.getColspan()) ? paramCell.getColspan() : (this.columns - paramPoint.y);
for (int k = paramPoint.x; k < paramPoint.x + i; k++) {
for (int m = paramPoint.y; m < paramPoint.y + j; m++) {
if (((Row)this.rows.get(k)).isReserved(m))
return false;
}
}
} else if (paramPoint.y + paramCell.getColspan() > this.columns) {
return false;
}
return true;
}
private void assumeTableDefaults(Cell paramCell) {
if (paramCell.getBorder() == -1)
paramCell.setBorder(this.defaultCell.getBorder());
if (paramCell.getBorderWidth() == -1.0F)
paramCell.setBorderWidth(this.defaultCell.getBorderWidth());
if (paramCell.getBorderColor() == null)
paramCell.setBorderColor(this.defaultCell.getBorderColor());
if (paramCell.getBackgroundColor() == null)
paramCell.setBackgroundColor(this.defaultCell.getBackgroundColor());
if (paramCell.getHorizontalAlignment() == -1)
paramCell.setHorizontalAlignment(this.defaultCell.getHorizontalAlignment());
if (paramCell.getVerticalAlignment() == -1)
paramCell.setVerticalAlignment(this.defaultCell.getVerticalAlignment());
}
private void placeCell(ArrayList paramArrayList, Cell paramCell, Point paramPoint) {
Row row = null;
int j = paramPoint.x + paramCell.getRowspan() - paramArrayList.size();
assumeTableDefaults(paramCell);
if (paramPoint.x + paramCell.getRowspan() > paramArrayList.size())
for (int k = 0; k < j; k++) {
row = new Row(this.columns);
paramArrayList.add(row);
}
for (int i = paramPoint.x + 1; i < paramPoint.x + paramCell.getRowspan(); i++) {
if (!((Row)paramArrayList.get(i)).reserve(paramPoint.y, paramCell.getColspan()))
throw new RuntimeException("addCell - error in reserve");
}
row = (Row)paramArrayList.get(paramPoint.x);
row.addElement(paramCell, paramPoint.y);
}
private void setCurrentLocationToNextValidPosition(Point paramPoint) {
int i = paramPoint.x;
int j = paramPoint.y;
do {
if (j + 1 == this.columns) {
i++;
j = 0;
} else {
j++;
}
} while (i < this.rows.size() && j < this.columns && ((Row)this.rows.get(i)).isReserved(j));
this.curPosition = new Point(i, j);
}
public float[] getWidths(float paramFloat1, float paramFloat2) {
float f;
float[] arrayOfFloat = new float[this.columns + 1];
if (this.locked) {
f = 100.0F * this.width / paramFloat2;
} else {
f = this.width;
}
switch (this.alignment) {
case 0:
arrayOfFloat[0] = paramFloat1;
break;
case 2:
arrayOfFloat[0] = paramFloat1 + paramFloat2 * (100.0F - f) / 100.0F;
break;
default:
arrayOfFloat[0] = paramFloat1 + paramFloat2 * (100.0F - f) / 200.0F;
break;
}
paramFloat2 = paramFloat2 * f / 100.0F;
for (int i = 1; i < this.columns; i++)
arrayOfFloat[i] = arrayOfFloat[i - 1] + this.widths[i - 1] * paramFloat2 / 100.0F;
arrayOfFloat[this.columns] = arrayOfFloat[0] + paramFloat2;
return arrayOfFloat;
}
public Iterator iterator() {
return this.rows.iterator();
}
public PdfPTable createPdfPTable() throws BadElementException {
if (!this.convert2pdfptable)
throw new BadElementException("No error, just an old style table");
setAutoFillEmptyCells(true);
complete();
PdfPTable pdfPTable = new PdfPTable(this.widths);
pdfPTable.setComplete(this.complete);
if (isNotAddedYet())
pdfPTable.setSkipFirstHeader(true);
pdfPTable.setTableEvent(SimpleTable.getDimensionlessInstance(this, this.cellspacing));
pdfPTable.setHeaderRows(this.lastHeaderRow + 1);
pdfPTable.setSplitLate(this.cellsFitPage);
pdfPTable.setKeepTogether(this.tableFitsPage);
if (!Float.isNaN(this.offset))
pdfPTable.setSpacingBefore(this.offset);
pdfPTable.setHorizontalAlignment(this.alignment);
if (this.locked) {
pdfPTable.setTotalWidth(this.width);
pdfPTable.setLockedWidth(true);
} else {
pdfPTable.setWidthPercentage(this.width);
}
Iterator iterator = iterator();
while (iterator.hasNext()) {
Row row = (Row)iterator.next();
for (int i = 0; i < row.getColumns(); i++) {
Element element;
if ((element = (Element)row.getCell(i)) != null) {
PdfPCell pdfPCell;
if (element instanceof Table) {
pdfPCell = new PdfPCell(((Table)element).createPdfPTable());
} else if (element instanceof Cell) {
pdfPCell = ((Cell)element).createPdfPCell();
pdfPCell.setPadding(this.cellpadding + this.cellspacing / 2.0F);
pdfPCell.setCellEvent(SimpleCell.getDimensionlessInstance((Cell)element, this.cellspacing));
} else {
pdfPCell = new PdfPCell();
}
pdfPTable.addCell(pdfPCell);
}
}
}
return pdfPTable;
}
public boolean isNotAddedYet() {
return this.notAddedYet;
}
public void setNotAddedYet(boolean paramBoolean) {
this.notAddedYet = paramBoolean;
}
public void flushContent() {
setNotAddedYet(false);
ArrayList arrayList = new ArrayList();
for (int i = 0; i < getLastHeaderRow() + 1; i++)
arrayList.add(this.rows.get(i));
this.rows = arrayList;
}
public boolean isComplete() {
return this.complete;
}
public void setComplete(boolean paramBoolean) {
this.complete = paramBoolean;
}
public Cell getDefaultLayout() {
return getDefaultCell();
}
public void setDefaultLayout(Cell paramCell) {
this.defaultCell = paramCell;
}
}

View file

@ -0,0 +1,5 @@
package com.lowagie.text;
public interface TextElementArray extends Element {
boolean add(Object paramObject);
}

View file

@ -0,0 +1,135 @@
package com.lowagie.text;
import com.lowagie.text.pdf.PRTokeniser;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Set;
public class Utilities {
public static Set getKeySet(Hashtable paramHashtable) {
return (paramHashtable == null) ? Collections.EMPTY_SET : paramHashtable.keySet();
}
public static Object[][] addToArray(Object[][] paramArrayOfObject, Object[] paramArrayOfObject1) {
if (paramArrayOfObject == null) {
paramArrayOfObject = new Object[1][];
paramArrayOfObject[0] = paramArrayOfObject1;
return paramArrayOfObject;
}
Object[][] arrayOfObject = new Object[paramArrayOfObject.length + 1][];
System.arraycopy(paramArrayOfObject, 0, arrayOfObject, 0, paramArrayOfObject.length);
arrayOfObject[paramArrayOfObject.length] = paramArrayOfObject1;
return arrayOfObject;
}
public static boolean checkTrueOrFalse(Properties paramProperties, String paramString) {
return "true".equalsIgnoreCase(paramProperties.getProperty(paramString));
}
public static String unEscapeURL(String paramString) {
StringBuffer stringBuffer = new StringBuffer();
char[] arrayOfChar = paramString.toCharArray();
for (int i = 0; i < arrayOfChar.length; i++) {
char c = arrayOfChar[i];
if (c == '%') {
if (i + 2 >= arrayOfChar.length) {
stringBuffer.append(c);
} else {
int j = PRTokeniser.getHex(arrayOfChar[i + 1]);
int k = PRTokeniser.getHex(arrayOfChar[i + 2]);
if (j < 0 || k < 0) {
stringBuffer.append(c);
} else {
stringBuffer.append((char)(j * 16 + k));
i += 2;
}
}
} else {
stringBuffer.append(c);
}
}
return stringBuffer.toString();
}
public static URL toURL(String paramString) throws MalformedURLException {
try {
return new URL(paramString);
} catch (Exception e) {
return new File(paramString).toURI().toURL();
}
}
public static void skip(InputStream paramInputStream, int paramInt) throws IOException {
while (paramInt > 0) {
long l = paramInputStream.skip((long)paramInt);
if (l <= 0L)
break;
paramInt = (int)((long)paramInt - l);
}
}
public static final float millimetersToPoints(float paramFloat) {
return inchesToPoints(millimetersToInches(paramFloat));
}
public static final float millimetersToInches(float paramFloat) {
return paramFloat / 25.4F;
}
public static final float pointsToMillimeters(float paramFloat) {
return inchesToMillimeters(pointsToInches(paramFloat));
}
public static final float pointsToInches(float paramFloat) {
return paramFloat / 72.0F;
}
public static final float inchesToMillimeters(float paramFloat) {
return paramFloat * 25.4F;
}
public static final float inchesToPoints(float paramFloat) {
return paramFloat * 72.0F;
}
public static boolean isSurrogateHigh(char paramChar) {
return (paramChar >= '?' && paramChar <= '?');
}
public static boolean isSurrogateLow(char paramChar) {
return (paramChar >= '?' && paramChar <= '?');
}
public static boolean isSurrogatePair(String paramString, int paramInt) {
return (paramInt < 0 || paramInt > paramString.length() - 2) ? false : ((isSurrogateHigh(paramString.charAt(paramInt)) && isSurrogateLow(paramString.charAt(paramInt + 1))));
}
public static boolean isSurrogatePair(char[] paramArrayOfchar, int paramInt) {
return (paramInt < 0 || paramInt > paramArrayOfchar.length - 2) ? false : ((isSurrogateHigh(paramArrayOfchar[paramInt]) && isSurrogateLow(paramArrayOfchar[paramInt + 1])));
}
public static int convertToUtf32(char paramChar1, char paramChar2) {
return (paramChar1 - 55296) * 1024 + paramChar2 - 56320 + 65536;
}
public static int convertToUtf32(char[] paramArrayOfchar, int paramInt) {
return (paramArrayOfchar[paramInt] - 55296) * 1024 + paramArrayOfchar[paramInt + 1] - 56320 + 65536;
}
public static int convertToUtf32(String paramString, int paramInt) {
return (paramString.charAt(paramInt) - 55296) * 1024 + paramString.charAt(paramInt + 1) - 56320 + 65536;
}
public static String convertFromUtf32(int paramInt) {
if (paramInt < 65536)
return Character.toString((char)paramInt);
paramInt -= 65536;
return new String(new char[] { (char)(paramInt / 1024 + 55296), (char)(paramInt % 1024 + 56320) });
}
}

View file

@ -0,0 +1,52 @@
package com.lowagie.text;
public class ZapfDingbatsList extends List {
protected int zn;
public ZapfDingbatsList(int paramInt) {
super(true);
this.zn = paramInt;
float f = this.symbol.getFont().getSize();
this.symbol.setFont(FontFactory.getFont("ZapfDingbats", f, 0));
this.postSymbol = " ";
}
public ZapfDingbatsList(int paramInt1, int paramInt2) {
super(true, (float)paramInt2);
this.zn = paramInt1;
float f = this.symbol.getFont().getSize();
this.symbol.setFont(FontFactory.getFont("ZapfDingbats", f, 0));
this.postSymbol = " ";
}
public void setCharNumber(int paramInt) {
this.zn = paramInt;
}
public int getCharNumber() {
return this.zn;
}
public boolean add(Object paramObject) {
if (paramObject instanceof ListItem) {
ListItem listItem = (ListItem)paramObject;
Chunk chunk = new Chunk(this.preSymbol, this.symbol.getFont());
chunk.append(String.valueOf((char)this.zn));
chunk.append(this.postSymbol);
listItem.setListSymbol(chunk);
listItem.setIndentationLeft(this.symbolIndent, this.autoindent);
listItem.setIndentationRight(0.0F);
this.list.add(listItem);
} else {
if (paramObject instanceof List) {
List list = (List)paramObject;
list.setIndentationLeft(list.getIndentationLeft() + this.symbolIndent);
this.first--;
return this.list.add(list);
}
if (paramObject instanceof String)
return add(new ListItem((String)paramObject));
}
return false;
}
}

View file

@ -0,0 +1,65 @@
package com.lowagie.text;
public class ZapfDingbatsNumberList extends List {
protected int type;
public ZapfDingbatsNumberList(int paramInt) {
super(true);
this.type = paramInt;
float f = this.symbol.getFont().getSize();
this.symbol.setFont(FontFactory.getFont("ZapfDingbats", f, 0));
this.postSymbol = " ";
}
public ZapfDingbatsNumberList(int paramInt1, int paramInt2) {
super(true, (float)paramInt2);
this.type = paramInt1;
float f = this.symbol.getFont().getSize();
this.symbol.setFont(FontFactory.getFont("ZapfDingbats", f, 0));
this.postSymbol = " ";
}
public void setType(int paramInt) {
this.type = paramInt;
}
public int getType() {
return this.type;
}
public boolean add(Object paramObject) {
if (paramObject instanceof ListItem) {
ListItem listItem = (ListItem)paramObject;
Chunk chunk = new Chunk(this.preSymbol, this.symbol.getFont());
switch (this.type) {
case 0:
chunk.append(String.valueOf((char)(this.first + this.list.size() + 171)));
break;
case 1:
chunk.append(String.valueOf((char)(this.first + this.list.size() + 181)));
break;
case 2:
chunk.append(String.valueOf((char)(this.first + this.list.size() + 191)));
break;
default:
chunk.append(String.valueOf((char)(this.first + this.list.size() + 201)));
break;
}
chunk.append(this.postSymbol);
listItem.setListSymbol(chunk);
listItem.setIndentationLeft(this.symbolIndent, this.autoindent);
listItem.setIndentationRight(0.0F);
this.list.add(listItem);
} else {
if (paramObject instanceof List) {
List list = (List)paramObject;
list.setIndentationLeft(list.getIndentationLeft() + this.symbolIndent);
this.first--;
return this.list.add(list);
}
if (paramObject instanceof String)
return add(new ListItem((String)paramObject));
}
return false;
}
}

View file

@ -0,0 +1,219 @@
Some files use code from different Apache projects.
The source code of these files contains the appropriate copyright notices
as described in the Appendix of http://www.apache.org/licenses/LICENSE-2.0
This is a copy of the text that can be found at that specific URL:
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
* You must give any other recipients of the Work or
Derivative Works a copy of this License; and
* You must cause any modified files to carry prominent notices
stating that You changed the files; and
* You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
* If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks.
This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -0,0 +1,391 @@
package com.lowagie.text.factories;
import com.lowagie.text.Anchor;
import com.lowagie.text.Annotation;
import com.lowagie.text.BadElementException;
import com.lowagie.text.Cell;
import com.lowagie.text.ChapterAutoNumber;
import com.lowagie.text.Chunk;
import com.lowagie.text.ElementTags;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Image;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
import com.lowagie.text.Section;
import com.lowagie.text.Table;
import com.lowagie.text.Utilities;
import com.lowagie.text.html.Markup;
import java.awt.Color;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.StringTokenizer;
public class ElementFactory {
public static Chunk getChunk(Properties paramProperties) {
Chunk chunk = new Chunk();
chunk.setFont(FontFactory.getFont(paramProperties));
String str = paramProperties.getProperty("itext");
if (str != null)
chunk.append(str);
str = paramProperties.getProperty(ElementTags.LOCALGOTO);
if (str != null)
chunk.setLocalGoto(str);
str = paramProperties.getProperty(ElementTags.REMOTEGOTO);
if (str != null) {
String str1 = paramProperties.getProperty("page");
if (str1 != null) {
chunk.setRemoteGoto(str, Integer.parseInt(str1));
} else {
String str2 = paramProperties.getProperty("destination");
if (str2 != null)
chunk.setRemoteGoto(str, str2);
}
}
str = paramProperties.getProperty(ElementTags.LOCALDESTINATION);
if (str != null)
chunk.setLocalDestination(str);
str = paramProperties.getProperty(ElementTags.SUBSUPSCRIPT);
if (str != null)
chunk.setTextRise(Float.parseFloat(str + "f"));
str = paramProperties.getProperty("vertical-align");
if (str != null && str.endsWith("%")) {
float f = Float.parseFloat(str.substring(0, str.length() - 1) + "f") / 100.0F;
chunk.setTextRise(f * chunk.getFont().getSize());
}
str = paramProperties.getProperty(ElementTags.GENERICTAG);
if (str != null)
chunk.setGenericTag(str);
str = paramProperties.getProperty("backgroundcolor");
if (str != null)
chunk.setBackground(Markup.decodeColor(str));
return chunk;
}
public static Phrase getPhrase(Properties paramProperties) {
Phrase phrase = new Phrase();
phrase.setFont(FontFactory.getFont(paramProperties));
String str = paramProperties.getProperty("leading");
if (str != null)
phrase.setLeading(Float.parseFloat(str + "f"));
str = paramProperties.getProperty("line-height");
if (str != null)
phrase.setLeading(Markup.parseLength(str, 12.0F));
str = paramProperties.getProperty("itext");
if (str != null) {
Chunk chunk = new Chunk(str);
if ((str = paramProperties.getProperty(ElementTags.GENERICTAG)) != null)
chunk.setGenericTag(str);
phrase.add(chunk);
}
return phrase;
}
public static Anchor getAnchor(Properties paramProperties) {
Anchor anchor = new Anchor(getPhrase(paramProperties));
String str = paramProperties.getProperty("name");
if (str != null)
anchor.setName(str);
str = (String)paramProperties.remove("reference");
if (str != null)
anchor.setReference(str);
return anchor;
}
public static Paragraph getParagraph(Properties paramProperties) {
Paragraph paragraph = new Paragraph(getPhrase(paramProperties));
String str = paramProperties.getProperty("align");
if (str != null)
paragraph.setAlignment(str);
str = paramProperties.getProperty("indentationleft");
if (str != null)
paragraph.setIndentationLeft(Float.parseFloat(str + "f"));
str = paramProperties.getProperty("indentationright");
if (str != null)
paragraph.setIndentationRight(Float.parseFloat(str + "f"));
return paragraph;
}
public static ListItem getListItem(Properties paramProperties) {
return new ListItem(getParagraph(paramProperties));
}
public static List getList(Properties paramProperties) {
List list = new List();
list.setNumbered(Utilities.checkTrueOrFalse(paramProperties, "numbered"));
list.setLettered(Utilities.checkTrueOrFalse(paramProperties, "lettered"));
list.setLowercase(Utilities.checkTrueOrFalse(paramProperties, "lowercase"));
list.setAutoindent(Utilities.checkTrueOrFalse(paramProperties, "autoindent"));
list.setAlignindent(Utilities.checkTrueOrFalse(paramProperties, "alignindent"));
String str = paramProperties.getProperty("first");
if (str != null) {
char c = str.charAt(0);
if (Character.isLetter(c)) {
list.setFirst(c);
} else {
list.setFirst(Integer.parseInt(str));
}
}
str = paramProperties.getProperty("listsymbol");
if (str != null)
list.setListSymbol(new Chunk(str, FontFactory.getFont(paramProperties)));
str = paramProperties.getProperty("indentationleft");
if (str != null)
list.setIndentationLeft(Float.parseFloat(str + "f"));
str = paramProperties.getProperty("indentationright");
if (str != null)
list.setIndentationRight(Float.parseFloat(str + "f"));
str = paramProperties.getProperty("symbolindent");
if (str != null)
list.setSymbolIndent(Float.parseFloat(str));
return list;
}
public static Cell getCell(Properties paramProperties) {
Cell cell = new Cell();
cell.setHorizontalAlignment(paramProperties.getProperty("horizontalalign"));
cell.setVerticalAlignment(paramProperties.getProperty("verticalalign"));
String str = paramProperties.getProperty("width");
if (str != null)
cell.setWidth(str);
str = paramProperties.getProperty("colspan");
if (str != null)
cell.setColspan(Integer.parseInt(str));
str = paramProperties.getProperty("rowspan");
if (str != null)
cell.setRowspan(Integer.parseInt(str));
str = paramProperties.getProperty("leading");
if (str != null)
cell.setLeading(Float.parseFloat(str + "f"));
cell.setHeader(Utilities.checkTrueOrFalse(paramProperties, "header"));
if (Utilities.checkTrueOrFalse(paramProperties, "nowrap"))
cell.setMaxLines(1);
setRectangleProperties(cell, paramProperties);
return cell;
}
public static Table getTable(Properties paramProperties) {
try {
Table table;
String str = paramProperties.getProperty("widths");
if (str != null) {
StringTokenizer stringTokenizer = new StringTokenizer(str, ";");
ArrayList arrayList = new ArrayList();
while (stringTokenizer.hasMoreTokens())
arrayList.add(stringTokenizer.nextToken());
table = new Table(arrayList.size());
float[] arrayOfFloat = new float[table.getColumns()];
for (int i = 0; i < arrayList.size(); i++) {
str = (String)arrayList.get(i);
arrayOfFloat[i] = Float.parseFloat(str + "f");
}
table.setWidths(arrayOfFloat);
} else {
str = paramProperties.getProperty("columns");
try {
table = new Table(Integer.parseInt(str));
} catch (Exception e) {
table = new Table(1);
}
}
table.setBorder(15);
table.setBorderWidth(1.0F);
table.getDefaultCell().setBorder(15);
str = paramProperties.getProperty("lastHeaderRow");
if (str != null)
table.setLastHeaderRow(Integer.parseInt(str));
str = paramProperties.getProperty("align");
if (str != null)
table.setAlignment(str);
str = paramProperties.getProperty("cellspacing");
if (str != null)
table.setSpacing(Float.parseFloat(str + "f"));
str = paramProperties.getProperty("cellpadding");
if (str != null)
table.setPadding(Float.parseFloat(str + "f"));
str = paramProperties.getProperty("offset");
if (str != null)
table.setOffset(Float.parseFloat(str + "f"));
str = paramProperties.getProperty("width");
if (str != null)
if (str.endsWith("%")) {
table.setWidth(Float.parseFloat(str.substring(0, str.length() - 1) + "f"));
} else {
table.setWidth(Float.parseFloat(str + "f"));
table.setLocked(true);
}
table.setTableFitsPage(Utilities.checkTrueOrFalse(paramProperties, "tablefitspage"));
table.setCellsFitPage(Utilities.checkTrueOrFalse(paramProperties, "cellsfitpage"));
table.setConvert2pdfptable(Utilities.checkTrueOrFalse(paramProperties, "convert2pdfp"));
setRectangleProperties(table, paramProperties);
return table;
} catch (BadElementException e) {
throw new ExceptionConverter(e);
}
}
private static void setRectangleProperties(Rectangle paramRectangle, Properties paramProperties) {
String str1 = paramProperties.getProperty("borderwidth");
if (str1 != null)
paramRectangle.setBorderWidth(Float.parseFloat(str1 + "f"));
int i = 0;
if (Utilities.checkTrueOrFalse(paramProperties, "left"))
i |= 0x4;
if (Utilities.checkTrueOrFalse(paramProperties, "right"))
i |= 0x8;
if (Utilities.checkTrueOrFalse(paramProperties, "top"))
i |= 0x1;
if (Utilities.checkTrueOrFalse(paramProperties, "bottom"))
i |= 0x2;
paramRectangle.setBorder(i);
String str2 = paramProperties.getProperty("red");
String str3 = paramProperties.getProperty("green");
String str4 = paramProperties.getProperty("blue");
if (str2 != null || str3 != null || str4 != null) {
int j = 0;
int k = 0;
int m = 0;
if (str2 != null)
j = Integer.parseInt(str2);
if (str3 != null)
k = Integer.parseInt(str3);
if (str4 != null)
m = Integer.parseInt(str4);
paramRectangle.setBorderColor(new Color(j, k, m));
} else {
paramRectangle.setBorderColor(Markup.decodeColor(paramProperties.getProperty("bordercolor")));
}
str2 = (String)paramProperties.remove("bgred");
str3 = (String)paramProperties.remove("bggreen");
str4 = (String)paramProperties.remove("bgblue");
str1 = paramProperties.getProperty("backgroundcolor");
if (str2 != null || str3 != null || str4 != null) {
int j = 0;
int k = 0;
int m = 0;
if (str2 != null)
j = Integer.parseInt(str2);
if (str3 != null)
k = Integer.parseInt(str3);
if (str4 != null)
m = Integer.parseInt(str4);
paramRectangle.setBackgroundColor(new Color(j, k, m));
} else if (str1 != null) {
paramRectangle.setBackgroundColor(Markup.decodeColor(str1));
} else {
str1 = paramProperties.getProperty("grayfill");
if (str1 != null)
paramRectangle.setGrayFill(Float.parseFloat(str1 + "f"));
}
}
public static ChapterAutoNumber getChapter(Properties paramProperties) {
ChapterAutoNumber chapterAutoNumber = new ChapterAutoNumber("");
setSectionParameters(chapterAutoNumber, paramProperties);
return chapterAutoNumber;
}
public static Section getSection(Section paramSection, Properties paramProperties) {
Section section = paramSection.addSection("");
setSectionParameters(section, paramProperties);
return section;
}
private static void setSectionParameters(Section paramSection, Properties paramProperties) {
String str = paramProperties.getProperty("numberdepth");
if (str != null)
paramSection.setNumberDepth(Integer.parseInt(str));
str = paramProperties.getProperty("indent");
if (str != null)
paramSection.setIndentation(Float.parseFloat(str + "f"));
str = paramProperties.getProperty("indentationleft");
if (str != null)
paramSection.setIndentationLeft(Float.parseFloat(str + "f"));
str = paramProperties.getProperty("indentationright");
if (str != null)
paramSection.setIndentationRight(Float.parseFloat(str + "f"));
}
public static Image getImage(Properties paramProperties) throws BadElementException, MalformedURLException, IOException {
String str1 = paramProperties.getProperty("url");
if (str1 == null)
throw new MalformedURLException("The URL of the image is missing.");
Image image = Image.getInstance(str1);
str1 = paramProperties.getProperty("align");
int i = 0;
if (str1 != null)
if ("Left".equalsIgnoreCase(str1)) {
i |= false;
} else if ("Right".equalsIgnoreCase(str1)) {
i |= 0x2;
} else if ("Middle".equalsIgnoreCase(str1)) {
i |= 0x1;
}
if ("true".equalsIgnoreCase(paramProperties.getProperty("underlying")))
i |= 0x8;
if ("true".equalsIgnoreCase(paramProperties.getProperty("textwrap")))
i |= 0x4;
image.setAlignment(i);
str1 = paramProperties.getProperty("alt");
if (str1 != null)
image.setAlt(str1);
String str2 = paramProperties.getProperty("absolutex");
String str3 = paramProperties.getProperty("absolutey");
if (str2 != null && str3 != null)
image.setAbsolutePosition(Float.parseFloat(str2 + "f"), Float.parseFloat(str3 + "f"));
str1 = paramProperties.getProperty("plainwidth");
if (str1 != null)
image.scaleAbsoluteWidth(Float.parseFloat(str1 + "f"));
str1 = paramProperties.getProperty("plainheight");
if (str1 != null)
image.scaleAbsoluteHeight(Float.parseFloat(str1 + "f"));
str1 = paramProperties.getProperty("rotation");
if (str1 != null)
image.setRotation(Float.parseFloat(str1 + "f"));
return image;
}
public static Annotation getAnnotation(Properties paramProperties) {
float f1 = 0.0F;
float f2 = 0.0F;
float f3 = 0.0F;
float f4 = 0.0F;
String str1 = paramProperties.getProperty("llx");
if (str1 != null)
f1 = Float.parseFloat(str1 + "f");
str1 = paramProperties.getProperty("lly");
if (str1 != null)
f2 = Float.parseFloat(str1 + "f");
str1 = paramProperties.getProperty("urx");
if (str1 != null)
f3 = Float.parseFloat(str1 + "f");
str1 = paramProperties.getProperty("ury");
if (str1 != null)
f4 = Float.parseFloat(str1 + "f");
String str2 = paramProperties.getProperty("title");
String str3 = paramProperties.getProperty("content");
if (str2 != null || str3 != null)
return new Annotation(str2, str3, f1, f2, f3, f4);
str1 = paramProperties.getProperty("url");
if (str1 != null)
return new Annotation(f1, f2, f3, f4, str1);
str1 = paramProperties.getProperty("named");
if (str1 != null)
return new Annotation(f1, f2, f3, f4, Integer.parseInt(str1));
String str4 = paramProperties.getProperty("file");
String str5 = paramProperties.getProperty("destination");
String str6 = (String)paramProperties.remove("page");
if (str4 != null) {
if (str5 != null)
return new Annotation(f1, f2, f3, f4, str4, str5);
if (str6 != null)
return new Annotation(f1, f2, f3, f4, str4, Integer.parseInt(str6));
}
return new Annotation("", "", f1, f2, f3, f4);
}
}

View file

@ -0,0 +1,45 @@
package com.lowagie.text.factories;
import com.lowagie.text.SpecialSymbol;
public class GreekAlphabetFactory {
public static final String getString(int paramInt) {
return getString(paramInt, true);
}
public static final String getLowerCaseString(int paramInt) {
return getString(paramInt);
}
public static final String getUpperCaseString(int paramInt) {
return getString(paramInt).toUpperCase();
}
public static final String getString(int paramInt, boolean paramBoolean) {
if (paramInt < 1)
return "";
paramInt--;
int i = 1;
int j = 0;
for (int k = 24; paramInt >= k + j; k *= 24) {
i++;
j += k;
}
int m = paramInt - j;
char[] arrayOfChar = new char[i];
while (i > 0) {
arrayOfChar[--i] = (char)(m % 24);
if (arrayOfChar[i] > '\020')
arrayOfChar[i] = (char)(arrayOfChar[i] + 1);
arrayOfChar[i] = (char)(arrayOfChar[i] + (paramBoolean ? 945 : 913));
arrayOfChar[i] = SpecialSymbol.getCorrespondingSymbol(arrayOfChar[i]);
m /= 24;
}
return String.valueOf(arrayOfChar);
}
public static void main(String[] paramArrayOfString) {
for (int i = 1; i < 1000; i++)
System.out.println(getString(i));
}
}

View file

@ -0,0 +1,39 @@
package com.lowagie.text.factories;
public class RomanAlphabetFactory {
public static final String getString(int paramInt) {
if (paramInt < 1)
throw new NumberFormatException("You can't translate a negative number into an alphabetical value.");
paramInt--;
int i = 1;
int j = 0;
for (int k = 26; paramInt >= k + j; k *= 26) {
i++;
j += k;
}
int m = paramInt - j;
char[] arrayOfChar = new char[i];
while (i > 0) {
arrayOfChar[--i] = (char)(97 + m % 26);
m /= 26;
}
return new String(arrayOfChar);
}
public static final String getLowerCaseString(int paramInt) {
return getString(paramInt);
}
public static final String getUpperCaseString(int paramInt) {
return getString(paramInt).toUpperCase();
}
public static final String getString(int paramInt, boolean paramBoolean) {
return paramBoolean ? getLowerCaseString(paramInt) : getUpperCaseString(paramInt);
}
public static void main(String[] paramArrayOfString) {
for (int i = 1; i < 32000; i++)
System.out.println(getString(i));
}
}

View file

@ -0,0 +1,65 @@
package com.lowagie.text.factories;
public class RomanNumberFactory {
private static final RomanDigit[] roman = new RomanDigit[] { new RomanDigit('m', 1000, false), new RomanDigit('d', 500, false), new RomanDigit('c', 100, true), new RomanDigit('l', 50, false), new RomanDigit('x', 10, true), new RomanDigit('v', 5, false), new RomanDigit('i', 1, true) };
public static final String getString(int paramInt) {
StringBuffer stringBuffer = new StringBuffer();
if (paramInt < 0) {
stringBuffer.append('-');
paramInt = -paramInt;
}
if (paramInt > 3000) {
stringBuffer.append('|');
stringBuffer.append(getString(paramInt / 1000));
stringBuffer.append('|');
paramInt -= paramInt / 1000 * 1000;
}
for (int i = 0;; i++) {
RomanDigit romanDigit = roman[i];
while (paramInt >= romanDigit.value) {
stringBuffer.append(romanDigit.digit);
paramInt -= romanDigit.value;
}
if (paramInt <= 0)
return stringBuffer.toString();
int j = i;
while (!(roman[++j]).pre);
if (paramInt + (roman[j]).value >= romanDigit.value) {
stringBuffer.append((roman[j]).digit).append(romanDigit.digit);
paramInt -= romanDigit.value - (roman[j]).value;
}
}
}
public static final String getLowerCaseString(int paramInt) {
return getString(paramInt);
}
public static final String getUpperCaseString(int paramInt) {
return getString(paramInt).toUpperCase();
}
public static final String getString(int paramInt, boolean paramBoolean) {
return paramBoolean ? getLowerCaseString(paramInt) : getUpperCaseString(paramInt);
}
public static void main(String[] paramArrayOfString) {
for (int i = 1; i < 2000; i++)
System.out.println(getString(i));
}
private static class RomanDigit {
public char digit;
public int value;
public boolean pre;
RomanDigit(char param1Char, int param1Int, boolean param1Boolean) {
this.digit = param1Char;
this.value = param1Int;
this.pre = param1Boolean;
}
}
}

View file

@ -0,0 +1,75 @@
package com.lowagie.text.html;
import java.awt.Color;
public final class HtmlEncoder {
private static final String[] htmlCode = new String[256];
public static String encode(String paramString) {
int i = paramString.length();
StringBuffer stringBuffer = new StringBuffer();
for (int j = 0; j < i; j++) {
char c = paramString.charAt(j);
if (c < 'Ā') {
stringBuffer.append(htmlCode[c]);
} else {
stringBuffer.append("&#").append(c).append(';');
}
}
return stringBuffer.toString();
}
public static String encode(Color paramColor) {
StringBuffer stringBuffer = new StringBuffer("#");
if (paramColor.getRed() < 16)
stringBuffer.append('0');
stringBuffer.append(Integer.toString(paramColor.getRed(), 16));
if (paramColor.getGreen() < 16)
stringBuffer.append('0');
stringBuffer.append(Integer.toString(paramColor.getGreen(), 16));
if (paramColor.getBlue() < 16)
stringBuffer.append('0');
stringBuffer.append(Integer.toString(paramColor.getBlue(), 16));
return stringBuffer.toString();
}
public static String getAlignment(int paramInt) {
switch (paramInt) {
case 0:
return "Left";
case 1:
return "Center";
case 2:
return "Right";
case 3:
case 8:
return "Justify";
case 4:
return "Top";
case 5:
return "Middle";
case 6:
return "Bottom";
case 7:
return "Baseline";
}
return "";
}
static {
for (int m = 0; m < 10; m++)
htmlCode[m] = "&#00" + m + ";";
for (int k = 10; k < 32; k++)
htmlCode[k] = "&#0" + k + ";";
for (int j = 32; j < 128; j++)
htmlCode[j] = String.valueOf((char)j);
htmlCode[9] = "\t";
htmlCode[10] = "<br />\n";
htmlCode[34] = "&quot;";
htmlCode[38] = "&amp;";
htmlCode[60] = "&lt;";
htmlCode[62] = "&gt;";
for (int i = 128; i < 256; i++)
htmlCode[i] = "&#" + i + ";";
}
}

View file

@ -0,0 +1,72 @@
package com.lowagie.text.html;
import com.lowagie.text.DocListener;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.xml.XmlParser;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
public class HtmlParser extends XmlParser {
public void go(DocListener paramDocListener, InputSource paramInputSource) {
try {
this.parser.parse(paramInputSource, new SAXmyHtmlHandler(paramDocListener));
} catch (SAXException e) {
throw new ExceptionConverter(e);
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
public static void parse(DocListener paramDocListener, InputSource paramInputSource) {
HtmlParser htmlParser = new HtmlParser();
htmlParser.go(paramDocListener, paramInputSource);
}
public void go(DocListener paramDocListener, String paramString) {
try {
this.parser.parse(paramString, new SAXmyHtmlHandler(paramDocListener));
} catch (SAXException e) {
throw new ExceptionConverter(e);
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
public static void parse(DocListener paramDocListener, String paramString) {
HtmlParser htmlParser = new HtmlParser();
htmlParser.go(paramDocListener, paramString);
}
public void go(DocListener paramDocListener, InputStream paramInputStream) {
try {
this.parser.parse(new InputSource(paramInputStream), new SAXmyHtmlHandler(paramDocListener));
} catch (SAXException e) {
throw new ExceptionConverter(e);
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
public static void parse(DocListener paramDocListener, InputStream paramInputStream) {
HtmlParser htmlParser = new HtmlParser();
htmlParser.go(paramDocListener, new InputSource(paramInputStream));
}
public void go(DocListener paramDocListener, Reader paramReader) {
try {
this.parser.parse(new InputSource(paramReader), new SAXmyHtmlHandler(paramDocListener));
} catch (SAXException e) {
throw new ExceptionConverter(e);
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
public static void parse(DocListener paramDocListener, Reader paramReader) {
HtmlParser htmlParser = new HtmlParser();
htmlParser.go(paramDocListener, new InputSource(paramReader));
}
}

View file

@ -0,0 +1,29 @@
package com.lowagie.text.html;
import com.lowagie.text.xml.XmlPeer;
import java.util.Properties;
import org.xml.sax.Attributes;
public class HtmlPeer extends XmlPeer {
public HtmlPeer(String paramString1, String paramString2) {
super(paramString1, paramString2.toLowerCase());
}
public void addAlias(String paramString1, String paramString2) {
this.attributeAliases.put(paramString2.toLowerCase(), paramString1);
}
public Properties getAttributes(Attributes paramAttributes) {
Properties properties = new Properties();
properties.putAll(this.attributeValues);
if (this.defaultContent != null)
properties.put("itext", this.defaultContent);
if (paramAttributes != null)
for (int i = 0; i < paramAttributes.getLength(); i++) {
String str1 = getName(paramAttributes.getQName(i).toLowerCase());
String str2 = paramAttributes.getValue(i);
properties.setProperty(str1, str2);
}
return properties;
}
}

View file

@ -0,0 +1,161 @@
package com.lowagie.text.html;
import com.lowagie.text.ElementTags;
import java.util.HashMap;
public class HtmlTagMap extends HashMap {
private static final long serialVersionUID = 5287430058473705350L;
public HtmlTagMap() {
HtmlPeer htmlPeer = new HtmlPeer("itext", "html");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("phrase", "span");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("chunk", "font");
htmlPeer.addAlias("font", "face");
htmlPeer.addAlias("size", "point-size");
htmlPeer.addAlias("color", "color");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("anchor", "a");
htmlPeer.addAlias("name", "name");
htmlPeer.addAlias("reference", "href");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("paragraph", "p");
htmlPeer.addAlias("align", "align");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("paragraph", "div");
htmlPeer.addAlias("align", "align");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("paragraph", HtmlTags.H[0]);
htmlPeer.addValue("size", "20");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("paragraph", HtmlTags.H[1]);
htmlPeer.addValue("size", "18");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("paragraph", HtmlTags.H[2]);
htmlPeer.addValue("size", "16");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("paragraph", HtmlTags.H[3]);
htmlPeer.addValue("size", "14");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("paragraph", HtmlTags.H[4]);
htmlPeer.addValue("size", "12");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("paragraph", HtmlTags.H[5]);
htmlPeer.addValue("size", "10");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("list", "ol");
htmlPeer.addValue("numbered", "true");
htmlPeer.addValue("symbolindent", "20");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("list", "ul");
htmlPeer.addValue("numbered", "false");
htmlPeer.addValue("symbolindent", "20");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("listitem", "li");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("phrase", "i");
htmlPeer.addValue("fontstyle", "italic");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("phrase", "em");
htmlPeer.addValue("fontstyle", "italic");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("phrase", "b");
htmlPeer.addValue("fontstyle", "bold");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("phrase", "strong");
htmlPeer.addValue("fontstyle", "bold");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("phrase", "s");
htmlPeer.addValue("fontstyle", "line-through");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("phrase", "code");
htmlPeer.addValue("font", "Courier");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("phrase", "var");
htmlPeer.addValue("font", "Courier");
htmlPeer.addValue("fontstyle", "italic");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("phrase", "u");
htmlPeer.addValue("fontstyle", "underline");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("chunk", "sup");
htmlPeer.addValue(ElementTags.SUBSUPSCRIPT, "6.0");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("chunk", "sub");
htmlPeer.addValue(ElementTags.SUBSUPSCRIPT, "-6.0");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("horizontalrule", "hr");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("table", "table");
htmlPeer.addAlias("width", "width");
htmlPeer.addAlias("backgroundcolor", "bgcolor");
htmlPeer.addAlias("bordercolor", "bordercolor");
htmlPeer.addAlias("columns", "cols");
htmlPeer.addAlias("cellpadding", "cellpadding");
htmlPeer.addAlias("cellspacing", "cellspacing");
htmlPeer.addAlias("borderwidth", "border");
htmlPeer.addAlias("align", "align");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("row", "tr");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("cell", "td");
htmlPeer.addAlias("width", "width");
htmlPeer.addAlias("backgroundcolor", "bgcolor");
htmlPeer.addAlias("bordercolor", "bordercolor");
htmlPeer.addAlias("colspan", "colspan");
htmlPeer.addAlias("rowspan", "rowspan");
htmlPeer.addAlias("nowrap", "nowrap");
htmlPeer.addAlias("horizontalalign", "align");
htmlPeer.addAlias("verticalalign", "valign");
htmlPeer.addValue("header", "false");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("cell", "th");
htmlPeer.addAlias("width", "width");
htmlPeer.addAlias("backgroundcolor", "bgcolor");
htmlPeer.addAlias("bordercolor", "bordercolor");
htmlPeer.addAlias("colspan", "colspan");
htmlPeer.addAlias("rowspan", "rowspan");
htmlPeer.addAlias("nowrap", "nowrap");
htmlPeer.addAlias("horizontalalign", "align");
htmlPeer.addAlias("verticalalign", "valign");
htmlPeer.addValue("header", "true");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("image", "img");
htmlPeer.addAlias("url", "src");
htmlPeer.addAlias("alt", "alt");
htmlPeer.addAlias("plainwidth", "width");
htmlPeer.addAlias("plainheight", "height");
put(htmlPeer.getAlias(), htmlPeer);
htmlPeer = new HtmlPeer("newline", "br");
put(htmlPeer.getAlias(), htmlPeer);
}
public static boolean isHtml(String paramString) {
return "html".equalsIgnoreCase(paramString);
}
public static boolean isHead(String paramString) {
return "head".equalsIgnoreCase(paramString);
}
public static boolean isMeta(String paramString) {
return "meta".equalsIgnoreCase(paramString);
}
public static boolean isLink(String paramString) {
return "link".equalsIgnoreCase(paramString);
}
public static boolean isTitle(String paramString) {
return "title".equalsIgnoreCase(paramString);
}
public static boolean isBody(String paramString) {
return "body".equalsIgnoreCase(paramString);
}
public static boolean isSpecialTag(String paramString) {
return (isHtml(paramString) || isHead(paramString) || isMeta(paramString) || isLink(paramString) || isBody(paramString));
}
}

View file

@ -0,0 +1,184 @@
package com.lowagie.text.html;
public class HtmlTags {
public static final String HTML = "html";
public static final String HEAD = "head";
public static final String CONTENT = "content";
public static final String META = "meta";
public static final String SUBJECT = "subject";
public static final String KEYWORDS = "keywords";
public static final String AUTHOR = "author";
public static final String TITLE = "title";
public static final String SCRIPT = "script";
public static final String LANGUAGE = "language";
public static final String JAVASCRIPT = "JavaScript";
public static final String BODY = "body";
public static final String JAVASCRIPT_ONLOAD = "onLoad";
public static final String JAVASCRIPT_ONUNLOAD = "onUnLoad";
public static final String TOPMARGIN = "topmargin";
public static final String BOTTOMMARGIN = "bottommargin";
public static final String LEFTMARGIN = "leftmargin";
public static final String RIGHTMARGIN = "rightmargin";
public static final String CHUNK = "font";
public static final String CODE = "code";
public static final String VAR = "var";
public static final String ANCHOR = "a";
public static final String ORDEREDLIST = "ol";
public static final String UNORDEREDLIST = "ul";
public static final String LISTITEM = "li";
public static final String PARAGRAPH = "p";
public static final String NAME = "name";
public static final String REFERENCE = "href";
public static final String[] H = new String[6];
public static final String FONT = "face";
public static final String SIZE = "point-size";
public static final String COLOR = "color";
public static final String EM = "em";
public static final String I = "i";
public static final String STRONG = "strong";
public static final String B = "b";
public static final String S = "s";
public static final String U = "u";
public static final String SUB = "sub";
public static final String SUP = "sup";
public static final String HORIZONTALRULE = "hr";
public static final String TABLE = "table";
public static final String ROW = "tr";
public static final String CELL = "td";
public static final String HEADERCELL = "th";
public static final String COLUMNS = "cols";
public static final String CELLPADDING = "cellpadding";
public static final String CELLSPACING = "cellspacing";
public static final String COLSPAN = "colspan";
public static final String ROWSPAN = "rowspan";
public static final String NOWRAP = "nowrap";
public static final String BORDERWIDTH = "border";
public static final String WIDTH = "width";
public static final String BACKGROUNDCOLOR = "bgcolor";
public static final String BORDERCOLOR = "bordercolor";
public static final String ALIGN = "align";
public static final String LEFT = "left";
public static final String RIGHT = "right";
public static final String HORIZONTALALIGN = "align";
public static final String VERTICALALIGN = "valign";
public static final String TOP = "top";
public static final String BOTTOM = "bottom";
public static final String IMAGE = "img";
public static final String URL = "src";
public static final String ALT = "alt";
public static final String PLAINWIDTH = "width";
public static final String PLAINHEIGHT = "height";
public static final String NEWLINE = "br";
public static final String ALIGN_LEFT = "Left";
public static final String ALIGN_CENTER = "Center";
public static final String ALIGN_RIGHT = "Right";
public static final String ALIGN_JUSTIFIED = "Justify";
public static final String ALIGN_TOP = "Top";
public static final String ALIGN_MIDDLE = "Middle";
public static final String ALIGN_BOTTOM = "Bottom";
public static final String ALIGN_BASELINE = "Baseline";
public static final String DEFAULT = "Default";
public static final String DIV = "div";
public static final String SPAN = "span";
public static final String LINK = "link";
public static final String TEXT_CSS = "text/css";
public static final String REL = "rel";
public static final String STYLE = "style";
public static final String TYPE = "type";
public static final String STYLESHEET = "stylesheet";
public static final String PRE = "pre";
static {
H[0] = "h1";
H[1] = "h2";
H[2] = "h3";
H[3] = "h4";
H[4] = "h5";
H[5] = "h6";
}
}

View file

@ -0,0 +1,732 @@
package com.lowagie.text.html;
import com.lowagie.text.Anchor;
import com.lowagie.text.Annotation;
import com.lowagie.text.BadElementException;
import com.lowagie.text.Cell;
import com.lowagie.text.Chunk;
import com.lowagie.text.DocWriter;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.Font;
import com.lowagie.text.Header;
import com.lowagie.text.HeaderFooter;
import com.lowagie.text.Image;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.MarkedObject;
import com.lowagie.text.MarkedSection;
import com.lowagie.text.Meta;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Row;
import com.lowagie.text.Section;
import com.lowagie.text.SimpleTable;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.BaseFont;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Date;
import java.util.EmptyStackException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
import java.util.Stack;
public class HtmlWriter extends DocWriter {
public static final byte[] BEGINCOMMENT = getISOBytes("<!-- ");
public static final byte[] ENDCOMMENT = getISOBytes(" -->");
public static final String NBSP = "&nbsp;";
protected Stack currentfont = new Stack();
protected Font standardfont = new Font();
protected String imagepath = null;
protected int pageN = 0;
protected HeaderFooter header = null;
protected HeaderFooter footer = null;
protected Properties markup = new Properties();
protected HtmlWriter(Document paramDocument, OutputStream paramOutputStream) {
super(paramDocument, paramOutputStream);
this.document.addDocListener(this);
this.pageN = this.document.getPageNumber();
try {
paramOutputStream.write(60);
paramOutputStream.write(getISOBytes("html"));
paramOutputStream.write(62);
paramOutputStream.write(10);
paramOutputStream.write(9);
paramOutputStream.write(60);
paramOutputStream.write(getISOBytes("head"));
paramOutputStream.write(62);
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
public static HtmlWriter getInstance(Document paramDocument, OutputStream paramOutputStream) {
return new HtmlWriter(paramDocument, paramOutputStream);
}
public boolean newPage() {
try {
writeStart("div");
write(" ");
write("style");
write("=\"");
writeCssProperty("page-break-before", "always");
write("\" /");
this.os.write(62);
} catch (IOException e) {
throw new ExceptionConverter(e);
}
return true;
}
public boolean add(Element paramElement) throws DocumentException {
if (this.pause)
return false;
if (this.open && !paramElement.isContent())
throw new DocumentException("The document is open; you can only add Elements with content.");
try {
Meta meta;
MarkedObject markedObject;
switch (paramElement.type()) {
case 0:
try {
Header header = (Header)paramElement;
if ("stylesheet".equals(header.getName())) {
writeLink(header);
} else if ("JavaScript".equals(header.getName())) {
writeJavaScript(header);
} else {
writeHeader(header);
}
} catch (ClassCastException e) {}
return true;
case 2:
case 3:
case 4:
meta = (Meta)paramElement;
writeHeader(meta);
return true;
case 1:
addTabs(2);
writeStart("title");
this.os.write(62);
addTabs(3);
write(HtmlEncoder.encode(((Meta)paramElement).getContent()));
addTabs(2);
writeEnd("title");
return true;
case 7:
writeComment("Creator: " + HtmlEncoder.encode(((Meta)paramElement).getContent()));
return true;
case 5:
writeComment("Producer: " + HtmlEncoder.encode(((Meta)paramElement).getContent()));
return true;
case 6:
writeComment("Creationdate: " + HtmlEncoder.encode(((Meta)paramElement).getContent()));
return true;
case 50:
if (paramElement instanceof MarkedSection) {
MarkedSection markedSection = (MarkedSection)paramElement;
addTabs(1);
writeStart("div");
writeMarkupAttributes(markedSection.getMarkupAttributes());
this.os.write(62);
MarkedObject markedObject1 = ((MarkedSection)paramElement).getTitle();
if (markedObject1 != null) {
this.markup = markedObject1.getMarkupAttributes();
markedObject1.process(this);
}
markedSection.process(this);
writeEnd("div");
return true;
}
markedObject = (MarkedObject)paramElement;
this.markup = markedObject.getMarkupAttributes();
return markedObject.process(this);
}
write(paramElement, 2);
return true;
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
public void open() {
super.open();
try {
writeComment(Document.getVersion());
writeComment("CreationDate: " + new Date().toString());
addTabs(1);
writeEnd("head");
addTabs(1);
writeStart("body");
if (this.document.leftMargin() > 0.0F)
write("leftmargin", String.valueOf(this.document.leftMargin()));
if (this.document.rightMargin() > 0.0F)
write("rightmargin", String.valueOf(this.document.rightMargin()));
if (this.document.topMargin() > 0.0F)
write("topmargin", String.valueOf(this.document.topMargin()));
if (this.document.bottomMargin() > 0.0F)
write("bottommargin", String.valueOf(this.document.bottomMargin()));
if (this.pageSize.getBackgroundColor() != null)
write("bgcolor", HtmlEncoder.encode(this.pageSize.getBackgroundColor()));
if (this.document.getJavaScript_onLoad() != null)
write("onLoad", HtmlEncoder.encode(this.document.getJavaScript_onLoad()));
if (this.document.getJavaScript_onUnLoad() != null)
write("onUnLoad", HtmlEncoder.encode(this.document.getJavaScript_onUnLoad()));
if (this.document.getHtmlStyleClass() != null)
write("class", this.document.getHtmlStyleClass());
this.os.write(62);
initHeader();
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
public void close() {
try {
initFooter();
addTabs(1);
writeEnd("body");
this.os.write(10);
writeEnd("html");
super.close();
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
protected void initHeader() {
if (this.header != null)
try {
add(this.header.paragraph());
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
protected void initFooter() {
if (this.footer != null)
try {
this.footer.setPageNumber(this.pageN + 1);
add(this.footer.paragraph());
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
protected void writeHeader(Meta paramMeta) throws IOException {
addTabs(2);
writeStart("meta");
switch (paramMeta.type()) {
case 0:
write("name", ((Header)paramMeta).getName());
break;
case 2:
write("name", "subject");
break;
case 3:
write("name", "keywords");
break;
case 4:
write("name", "author");
break;
}
write("content", HtmlEncoder.encode(paramMeta.getContent()));
writeEnd();
}
protected void writeLink(Header paramHeader) throws IOException {
addTabs(2);
writeStart("link");
write("rel", paramHeader.getName());
write("type", "text/css");
write("href", paramHeader.getContent());
writeEnd();
}
protected void writeJavaScript(Header paramHeader) throws IOException {
addTabs(2);
writeStart("script");
write("language", "JavaScript");
if (this.markup.size() > 0) {
writeMarkupAttributes(this.markup);
this.os.write(62);
writeEnd("script");
} else {
write("type", "text/javascript");
this.os.write(62);
addTabs(2);
write(new String(BEGINCOMMENT) + "\n");
write(paramHeader.getContent());
addTabs(2);
write("//" + new String(ENDCOMMENT));
addTabs(2);
writeEnd("script");
}
}
protected void writeComment(String paramString) throws IOException {
addTabs(2);
this.os.write(BEGINCOMMENT);
write(paramString);
this.os.write(ENDCOMMENT);
}
public void setStandardFont(Font paramFont) {
this.standardfont = paramFont;
}
public boolean isOtherFont(Font paramFont) {
try {
Font font = (Font)this.currentfont.peek();
return !(font.compareTo(paramFont) == 0);
} catch (EmptyStackException e) {
return !(this.standardfont.compareTo(paramFont) == 0);
}
}
public void setImagepath(String paramString) {
this.imagepath = paramString;
}
public void resetImagepath() {
this.imagepath = null;
}
public void setHeader(HeaderFooter paramHeaderFooter) {
this.header = paramHeaderFooter;
}
public void setFooter(HeaderFooter paramHeaderFooter) {
this.footer = paramHeaderFooter;
}
public boolean add(String paramString) {
if (this.pause)
return false;
try {
write(paramString);
return true;
} catch (IOException e) {
throw new ExceptionConverter(e);
}
}
protected void write(Element paramElement, int paramInt) throws IOException {
Chunk chunk;
Phrase phrase;
List list;
ListItem listItem;
Cell cell;
Row row;
Table table;
Annotation annotation;
Image image1;
Image image2;
Iterator iterator2;
String str2;
Iterator iterator1;
String str1;
HashMap hashMap;
Iterator iterator3;
int i;
boolean bool;
Iterator iterator4;
Properties properties = null;
switch (paramElement.type()) {
case 50:
try {
add(paramElement);
} catch (DocumentException e) {
e.printStackTrace();
}
return;
case 10:
chunk = (Chunk)paramElement;
image2 = chunk.getImage();
if (image2 != null) {
write(image2, paramInt);
return;
}
if (chunk.isEmpty())
return;
hashMap = chunk.getAttributes();
if (hashMap != null && hashMap.get("NEWPAGE") != null)
return;
bool = (isOtherFont(chunk.getFont()) || this.markup.size() > 0) ? true : false;
if (bool) {
addTabs(paramInt);
writeStart("span");
if (isOtherFont(chunk.getFont()))
write(chunk.getFont(), null);
writeMarkupAttributes(this.markup);
this.os.write(62);
}
if (hashMap != null && hashMap.get("SUBSUPSCRIPT") != null) {
if (((Float)hashMap.get("SUBSUPSCRIPT")).floatValue() > 0.0F) {
writeStart("sup");
} else {
writeStart("sub");
}
this.os.write(62);
}
write(HtmlEncoder.encode(chunk.getContent()));
if (hashMap != null && hashMap.get("SUBSUPSCRIPT") != null) {
this.os.write(60);
this.os.write(47);
if (((Float)hashMap.get("SUBSUPSCRIPT")).floatValue() > 0.0F) {
write("sup");
} else {
write("sub");
}
this.os.write(62);
}
if (bool)
writeEnd("span");
return;
case 11:
phrase = (Phrase)paramElement;
properties = new Properties();
if (phrase.hasLeading())
properties.setProperty("line-height", phrase.getLeading() + "pt");
addTabs(paramInt);
writeStart("span");
writeMarkupAttributes(this.markup);
write(phrase.getFont(), properties);
this.os.write(62);
this.currentfont.push(phrase.getFont());
iterator2 = phrase.iterator();
while (iterator2.hasNext())
write((Element)iterator2.next(), paramInt + 1);
addTabs(paramInt);
writeEnd("span");
this.currentfont.pop();
return;
case 17:
phrase = (Anchor)paramElement;
properties = new Properties();
if (phrase.hasLeading())
properties.setProperty("line-height", phrase.getLeading() + "pt");
addTabs(paramInt);
writeStart("a");
if (phrase.getName() != null)
write("name", phrase.getName());
if (phrase.getReference() != null)
write("href", phrase.getReference());
writeMarkupAttributes(this.markup);
write(phrase.getFont(), properties);
this.os.write(62);
this.currentfont.push(phrase.getFont());
iterator2 = phrase.iterator();
while (iterator2.hasNext())
write((Element)iterator2.next(), paramInt + 1);
addTabs(paramInt);
writeEnd("a");
this.currentfont.pop();
return;
case 12:
phrase = (Paragraph)paramElement;
properties = new Properties();
if (phrase.hasLeading())
properties.setProperty("line-height", phrase.getTotalLeading() + "pt");
addTabs(paramInt);
writeStart("div");
writeMarkupAttributes(this.markup);
str2 = HtmlEncoder.getAlignment(phrase.getAlignment());
if (!"".equals(str2))
write("align", str2);
write(phrase.getFont(), properties);
this.os.write(62);
this.currentfont.push(phrase.getFont());
iterator3 = phrase.iterator();
while (iterator3.hasNext())
write((Element)iterator3.next(), paramInt + 1);
addTabs(paramInt);
writeEnd("div");
this.currentfont.pop();
return;
case 13:
case 16:
writeSection((Section)paramElement, paramInt);
return;
case 14:
list = (List)paramElement;
addTabs(paramInt);
if (list.isNumbered()) {
writeStart("ol");
} else {
writeStart("ul");
}
writeMarkupAttributes(this.markup);
this.os.write(62);
iterator1 = list.getItems().iterator();
while (iterator1.hasNext())
write((Element)iterator1.next(), paramInt + 1);
addTabs(paramInt);
if (list.isNumbered()) {
writeEnd("ol");
} else {
writeEnd("ul");
}
return;
case 15:
listItem = (ListItem)paramElement;
properties = new Properties();
if (listItem.hasLeading())
properties.setProperty("line-height", listItem.getTotalLeading() + "pt");
addTabs(paramInt);
writeStart("li");
writeMarkupAttributes(this.markup);
write(listItem.getFont(), properties);
this.os.write(62);
this.currentfont.push(listItem.getFont());
iterator1 = listItem.iterator();
while (iterator1.hasNext())
write((Element)iterator1.next(), paramInt + 1);
addTabs(paramInt);
writeEnd("li");
this.currentfont.pop();
return;
case 20:
cell = (Cell)paramElement;
addTabs(paramInt);
if (cell.isHeader()) {
writeStart("th");
} else {
writeStart("td");
}
writeMarkupAttributes(this.markup);
if (cell.getBorderWidth() != -1.0F)
write("border", String.valueOf(cell.getBorderWidth()));
if (cell.getBorderColor() != null)
write("bordercolor", HtmlEncoder.encode(cell.getBorderColor()));
if (cell.getBackgroundColor() != null)
write("bgcolor", HtmlEncoder.encode(cell.getBackgroundColor()));
str1 = HtmlEncoder.getAlignment(cell.getHorizontalAlignment());
if (!"".equals(str1))
write("align", str1);
str1 = HtmlEncoder.getAlignment(cell.getVerticalAlignment());
if (!"".equals(str1))
write("valign", str1);
if (cell.getWidthAsString() != null)
write("width", cell.getWidthAsString());
if (cell.getColspan() != 1)
write("colspan", String.valueOf(cell.getColspan()));
if (cell.getRowspan() != 1)
write("rowspan", String.valueOf(cell.getRowspan()));
if (cell.getMaxLines() == 1)
write("style", "white-space: nowrap;");
this.os.write(62);
if (cell.isEmpty()) {
write("&nbsp;");
} else {
iterator3 = cell.getElements();
while (iterator3.hasNext())
write((Element)iterator3.next(), paramInt + 1);
}
addTabs(paramInt);
if (cell.isHeader()) {
writeEnd("th");
} else {
writeEnd("td");
}
return;
case 21:
row = (Row)paramElement;
addTabs(paramInt);
writeStart("tr");
writeMarkupAttributes(this.markup);
this.os.write(62);
for (i = 0; i < row.getColumns(); i++) {
Element element;
if ((element = (Element)row.getCell(i)) != null)
write(element, paramInt + 1);
}
addTabs(paramInt);
writeEnd("tr");
return;
case 22:
try {
table = (Table)paramElement;
} catch (ClassCastException e) {
try {
table = ((SimpleTable)paramElement).createTable();
} catch (BadElementException badElementException) {
throw new ExceptionConverter(badElementException);
}
}
table.complete();
addTabs(paramInt);
writeStart("table");
writeMarkupAttributes(this.markup);
this.os.write(32);
write("width");
this.os.write(61);
this.os.write(34);
write(String.valueOf(table.getWidth()));
if (!table.isLocked())
write("%");
this.os.write(34);
str1 = HtmlEncoder.getAlignment(table.getAlignment());
if (!"".equals(str1))
write("align", str1);
write("cellpadding", String.valueOf(table.getPadding()));
write("cellspacing", String.valueOf(table.getSpacing()));
if (table.getBorderWidth() != -1.0F)
write("border", String.valueOf(table.getBorderWidth()));
if (table.getBorderColor() != null)
write("bordercolor", HtmlEncoder.encode(table.getBorderColor()));
if (table.getBackgroundColor() != null)
write("bgcolor", HtmlEncoder.encode(table.getBackgroundColor()));
this.os.write(62);
iterator4 = table.iterator();
while (iterator4.hasNext()) {
Row row1 = (Row)iterator4.next();
write(row1, paramInt + 1);
}
addTabs(paramInt);
writeEnd("table");
return;
case 29:
annotation = (Annotation)paramElement;
writeComment(annotation.title() + ": " + annotation.content());
return;
case 32:
case 33:
case 34:
case 35:
image1 = (Image)paramElement;
if (image1.getUrl() == null)
return;
addTabs(paramInt);
writeStart("img");
str1 = image1.getUrl().toString();
if (this.imagepath != null)
if (str1.indexOf('/') > 0) {
str1 = this.imagepath + str1.substring(str1.lastIndexOf('/') + 1);
} else {
str1 = this.imagepath + str1;
}
write("src", str1);
if ((image1.getAlignment() & 0x2) > 0) {
write("align", "Right");
} else if ((image1.getAlignment() & 0x1) > 0) {
write("align", "Middle");
} else {
write("align", "Left");
}
if (image1.getAlt() != null)
write("alt", image1.getAlt());
write("width", String.valueOf(image1.getScaledWidth()));
write("height", String.valueOf(image1.getScaledHeight()));
writeMarkupAttributes(this.markup);
writeEnd();
return;
}
}
protected void writeSection(Section paramSection, int paramInt) throws IOException {
if (paramSection.getTitle() != null) {
int i = paramSection.getDepth() - 1;
if (i > 5)
i = 5;
Properties properties = new Properties();
if (paramSection.getTitle().hasLeading())
properties.setProperty("line-height", paramSection.getTitle().getTotalLeading() + "pt");
addTabs(paramInt);
writeStart(HtmlTags.H[i]);
write(paramSection.getTitle().getFont(), properties);
String str = HtmlEncoder.getAlignment(paramSection.getTitle().getAlignment());
if (!"".equals(str))
write("align", str);
writeMarkupAttributes(this.markup);
this.os.write(62);
this.currentfont.push(paramSection.getTitle().getFont());
Iterator iterator1 = paramSection.getTitle().iterator();
while (iterator1.hasNext())
write((Element)iterator1.next(), paramInt + 1);
addTabs(paramInt);
writeEnd(HtmlTags.H[i]);
this.currentfont.pop();
}
Iterator iterator = paramSection.iterator();
while (iterator.hasNext())
write((Element)iterator.next(), paramInt);
}
protected void write(Font paramFont, Properties paramProperties) throws IOException {
if (paramFont == null || !isOtherFont(paramFont))
return;
write(" ");
write("style");
write("=\"");
if (paramProperties != null) {
Enumeration enumeration = paramProperties.propertyNames();
while (enumeration.hasMoreElements()) {
String str = (String)enumeration.nextElement();
writeCssProperty(str, paramProperties.getProperty(str));
}
}
if (isOtherFont(paramFont)) {
writeCssProperty("font-family", paramFont.getFamilyname());
if (paramFont.getSize() != -1.0F)
writeCssProperty("font-size", paramFont.getSize() + "pt");
if (paramFont.getColor() != null)
writeCssProperty("color", HtmlEncoder.encode(paramFont.getColor()));
int i = paramFont.getStyle();
BaseFont baseFont = paramFont.getBaseFont();
if (baseFont != null) {
String str = baseFont.getPostscriptFontName().toLowerCase();
if (str.indexOf("bold") >= 0) {
if (i == -1)
i = 0;
i |= 0x1;
}
if (str.indexOf("italic") >= 0 || str.indexOf("oblique") >= 0) {
if (i == -1)
i = 0;
i |= 0x2;
}
}
if (i != -1 && i != 0) {
switch (i & 0x3) {
case 1:
writeCssProperty("font-weight", "bold");
break;
case 2:
writeCssProperty("font-style", "italic");
break;
case 3:
writeCssProperty("font-weight", "bold");
writeCssProperty("font-style", "italic");
break;
}
if ((i & 0x4) > 0)
writeCssProperty("text-decoration", "underline");
if ((i & 0x8) > 0)
writeCssProperty("text-decoration", "line-through");
}
}
write("\"");
}
protected void writeCssProperty(String paramString1, String paramString2) throws IOException {
write(paramString1 + ": " + paramString2 + "; ");
}
}

View file

@ -0,0 +1,278 @@
package com.lowagie.text.html;
import java.awt.Color;
import java.util.Properties;
import java.util.StringTokenizer;
public class Markup {
public static final String ITEXT_TAG = "tag";
public static final String HTML_TAG_BODY = "body";
public static final String HTML_TAG_DIV = "div";
public static final String HTML_TAG_LINK = "link";
public static final String HTML_TAG_SPAN = "span";
public static final String HTML_ATTR_HEIGHT = "height";
public static final String HTML_ATTR_HREF = "href";
public static final String HTML_ATTR_REL = "rel";
public static final String HTML_ATTR_STYLE = "style";
public static final String HTML_ATTR_TYPE = "type";
public static final String HTML_ATTR_STYLESHEET = "stylesheet";
public static final String HTML_ATTR_WIDTH = "width";
public static final String HTML_ATTR_CSS_CLASS = "class";
public static final String HTML_ATTR_CSS_ID = "id";
public static final String HTML_VALUE_JAVASCRIPT = "text/javascript";
public static final String HTML_VALUE_CSS = "text/css";
public static final String CSS_KEY_BGCOLOR = "background-color";
public static final String CSS_KEY_COLOR = "color";
public static final String CSS_KEY_DISPLAY = "display";
public static final String CSS_KEY_FONTFAMILY = "font-family";
public static final String CSS_KEY_FONTSIZE = "font-size";
public static final String CSS_KEY_FONTSTYLE = "font-style";
public static final String CSS_KEY_FONTWEIGHT = "font-weight";
public static final String CSS_KEY_LINEHEIGHT = "line-height";
public static final String CSS_KEY_MARGIN = "margin";
public static final String CSS_KEY_MARGINLEFT = "margin-left";
public static final String CSS_KEY_MARGINRIGHT = "margin-right";
public static final String CSS_KEY_MARGINTOP = "margin-top";
public static final String CSS_KEY_MARGINBOTTOM = "margin-bottom";
public static final String CSS_KEY_PADDING = "padding";
public static final String CSS_KEY_PADDINGLEFT = "padding-left";
public static final String CSS_KEY_PADDINGRIGHT = "padding-right";
public static final String CSS_KEY_PADDINGTOP = "padding-top";
public static final String CSS_KEY_PADDINGBOTTOM = "padding-bottom";
public static final String CSS_KEY_BORDERCOLOR = "border-color";
public static final String CSS_KEY_BORDERWIDTH = "border-width";
public static final String CSS_KEY_BORDERWIDTHLEFT = "border-left-width";
public static final String CSS_KEY_BORDERWIDTHRIGHT = "border-right-width";
public static final String CSS_KEY_BORDERWIDTHTOP = "border-top-width";
public static final String CSS_KEY_BORDERWIDTHBOTTOM = "border-bottom-width";
public static final String CSS_KEY_PAGE_BREAK_AFTER = "page-break-after";
public static final String CSS_KEY_PAGE_BREAK_BEFORE = "page-break-before";
public static final String CSS_KEY_TEXTALIGN = "text-align";
public static final String CSS_KEY_TEXTDECORATION = "text-decoration";
public static final String CSS_KEY_VERTICALALIGN = "vertical-align";
public static final String CSS_KEY_VISIBILITY = "visibility";
public static final String CSS_VALUE_ALWAYS = "always";
public static final String CSS_VALUE_BLOCK = "block";
public static final String CSS_VALUE_BOLD = "bold";
public static final String CSS_VALUE_HIDDEN = "hidden";
public static final String CSS_VALUE_INLINE = "inline";
public static final String CSS_VALUE_ITALIC = "italic";
public static final String CSS_VALUE_LINETHROUGH = "line-through";
public static final String CSS_VALUE_LISTITEM = "list-item";
public static final String CSS_VALUE_NONE = "none";
public static final String CSS_VALUE_NORMAL = "normal";
public static final String CSS_VALUE_OBLIQUE = "oblique";
public static final String CSS_VALUE_TABLE = "table";
public static final String CSS_VALUE_TABLEROW = "table-row";
public static final String CSS_VALUE_TABLECELL = "table-cell";
public static final String CSS_VALUE_TEXTALIGNLEFT = "left";
public static final String CSS_VALUE_TEXTALIGNRIGHT = "right";
public static final String CSS_VALUE_TEXTALIGNCENTER = "center";
public static final String CSS_VALUE_TEXTALIGNJUSTIFY = "justify";
public static final String CSS_VALUE_UNDERLINE = "underline";
public static final float DEFAULT_FONT_SIZE = 12.0F;
public static float parseLength(String paramString) {
int i = 0;
int j = paramString.length();
for (boolean bool = true; bool && i < j; bool = false) {
switch (paramString.charAt(i)) {
case '+':
case '-':
case '.':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
i++;
continue;
}
}
if (i == 0)
return 0.0F;
if (i == j)
return Float.parseFloat(paramString + "f");
float f = Float.parseFloat(paramString.substring(0, i) + "f");
paramString = paramString.substring(i);
return paramString.startsWith("in") ? (f * 72.0F) : (paramString.startsWith("cm") ? (f / 2.54F * 72.0F) : (paramString.startsWith("mm") ? (f / 25.4F * 72.0F) : (paramString.startsWith("pc") ? (f * 12.0F) : f)));
}
public static float parseLength(String paramString, float paramFloat) {
if (paramString == null)
return 0.0F;
int i = 0;
int j = paramString.length();
for (boolean bool = true; bool && i < j; bool = false) {
switch (paramString.charAt(i)) {
case '+':
case '-':
case '.':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
i++;
continue;
}
}
if (i == 0)
return 0.0F;
if (i == j)
return Float.parseFloat(paramString + "f");
float f = Float.parseFloat(paramString.substring(0, i) + "f");
paramString = paramString.substring(i);
return paramString.startsWith("in") ? (f * 72.0F) : (paramString.startsWith("cm") ? (f / 2.54F * 72.0F) : (paramString.startsWith("mm") ? (f / 25.4F * 72.0F) : (paramString.startsWith("pc") ? (f * 12.0F) : (paramString.startsWith("em") ? (f * paramFloat) : (paramString.startsWith("ex") ? (f * paramFloat / 2.0F) : f)))));
}
public static Color decodeColor(String paramString) {
if (paramString == null)
return null;
paramString = paramString.toLowerCase().trim();
Color color = WebColors.getRGBColor(paramString);
if (color != null)
return color;
try {
if (paramString.startsWith("#")) {
if (paramString.length() == 4)
paramString = "#" + paramString.substring(1, 2) + paramString.substring(1, 2) + paramString.substring(2, 3) + paramString.substring(2, 3) + paramString.substring(3, 4) + paramString.substring(3, 4);
if (paramString.length() == 7)
return new Color(Integer.parseInt(paramString.substring(1), 16));
} else if (paramString.startsWith("rgb")) {
StringTokenizer stringTokenizer = new StringTokenizer(paramString.substring(3), " \t\r\n\f(),");
int[] arrayOfInt = new int[3];
for (int i = 0; i < 3; i++) {
float f;
if (!stringTokenizer.hasMoreTokens())
return null;
String str = stringTokenizer.nextToken();
if (str.endsWith("%")) {
f = Float.parseFloat(str.substring(0, str.length() - 1));
f = f * 255.0F / 100.0F;
} else {
f = Float.parseFloat(str);
}
int j = (int)f;
if (j > 255) {
j = 255;
} else if (j < 0) {
j = 0;
}
arrayOfInt[i] = j;
}
return new Color(arrayOfInt[0], arrayOfInt[1], arrayOfInt[2]);
}
} catch (Exception e) {}
return null;
}
public static Properties parseAttributes(String paramString) {
Properties properties = new Properties();
if (paramString == null)
return properties;
StringTokenizer stringTokenizer = new StringTokenizer(paramString, ";");
while (stringTokenizer.hasMoreTokens()) {
StringTokenizer stringTokenizer1 = new StringTokenizer(stringTokenizer.nextToken(), ":");
if (stringTokenizer1.hasMoreTokens()) {
String str = stringTokenizer1.nextToken().trim();
if (stringTokenizer1.hasMoreTokens()) {
String str1 = stringTokenizer1.nextToken().trim();
if (str1.startsWith("\""))
str1 = str1.substring(1);
if (str1.endsWith("\""))
str1 = str1.substring(0, str1.length() - 1);
properties.setProperty(str.toLowerCase(), str1);
}
}
}
return properties;
}
public static String removeComment(String paramString1, String paramString2, String paramString3) {
StringBuffer stringBuffer = new StringBuffer();
int i = 0;
int j = paramString3.length();
for (int k = paramString1.indexOf(paramString2, i); k > -1; k = paramString1.indexOf(paramString2, i)) {
stringBuffer.append(paramString1.substring(i, k));
i = paramString1.indexOf(paramString3, k) + j;
}
stringBuffer.append(paramString1.substring(i));
return stringBuffer.toString();
}
}

View file

@ -0,0 +1,126 @@
package com.lowagie.text.html;
import com.lowagie.text.DocListener;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.xml.SAXiTextHandler;
import com.lowagie.text.xml.XmlPeer;
import java.util.HashMap;
import java.util.Properties;
import org.xml.sax.Attributes;
public class SAXmyHtmlHandler extends SAXiTextHandler {
private Properties bodyAttributes = new Properties();
private boolean tableBorder = false;
public SAXmyHtmlHandler(DocListener paramDocListener) {
super(paramDocListener, new HtmlTagMap());
}
public SAXmyHtmlHandler(DocListener paramDocListener, BaseFont paramBaseFont) {
super(paramDocListener, new HtmlTagMap(), paramBaseFont);
}
public SAXmyHtmlHandler(DocListener paramDocListener, HashMap paramHashMap) {
super(paramDocListener, paramHashMap);
}
public void startElement(String paramString1, String paramString2, String paramString3, Attributes paramAttributes) {
paramString3 = paramString3.toLowerCase();
if (HtmlTagMap.isHtml(paramString3))
return;
if (HtmlTagMap.isHead(paramString3))
return;
if (HtmlTagMap.isTitle(paramString3))
return;
if (HtmlTagMap.isMeta(paramString3)) {
String str1 = null;
String str2 = null;
if (paramAttributes != null)
for (int i = 0; i < paramAttributes.getLength(); i++) {
String str = paramAttributes.getQName(i);
if (str.equalsIgnoreCase("content")) {
str2 = paramAttributes.getValue(i);
} else if (str.equalsIgnoreCase("name")) {
str1 = paramAttributes.getValue(i);
}
}
if (str1 != null && str2 != null)
this.bodyAttributes.put(str1, str2);
return;
}
if (HtmlTagMap.isLink(paramString3))
return;
if (HtmlTagMap.isBody(paramString3)) {
XmlPeer xmlPeer = new XmlPeer("itext", paramString3);
xmlPeer.addAlias("top", "topmargin");
xmlPeer.addAlias("bottom", "bottommargin");
xmlPeer.addAlias("right", "rightmargin");
xmlPeer.addAlias("left", "leftmargin");
this.bodyAttributes.putAll(xmlPeer.getAttributes(paramAttributes));
handleStartingTags(xmlPeer.getTag(), this.bodyAttributes);
return;
}
if (this.myTags.containsKey(paramString3)) {
XmlPeer xmlPeer = (XmlPeer)this.myTags.get(paramString3);
if ("table".equals(xmlPeer.getTag()) || "cell".equals(xmlPeer.getTag())) {
Properties properties1 = xmlPeer.getAttributes(paramAttributes);
String str;
if ("table".equals(xmlPeer.getTag()) && (str = properties1.getProperty("borderwidth")) != null && Float.parseFloat(str + "f") > 0.0F)
this.tableBorder = true;
if (this.tableBorder) {
properties1.put("left", String.valueOf(true));
properties1.put("right", String.valueOf(true));
properties1.put("top", String.valueOf(true));
properties1.put("bottom", String.valueOf(true));
}
handleStartingTags(xmlPeer.getTag(), properties1);
return;
}
handleStartingTags(xmlPeer.getTag(), xmlPeer.getAttributes(paramAttributes));
return;
}
Properties properties = new Properties();
if (paramAttributes != null)
for (int i = 0; i < paramAttributes.getLength(); i++) {
String str = paramAttributes.getQName(i).toLowerCase();
properties.setProperty(str, paramAttributes.getValue(i).toLowerCase());
}
handleStartingTags(paramString3, properties);
}
public void endElement(String paramString1, String paramString2, String paramString3) {
paramString3 = paramString3.toLowerCase();
if ("paragraph".equals(paramString3))
try {
this.document.add((Element)this.stack.pop());
return;
} catch (DocumentException e) {
throw new ExceptionConverter(e);
}
if (HtmlTagMap.isHead(paramString3))
return;
if (HtmlTagMap.isTitle(paramString3)) {
if (this.currentChunk != null)
this.bodyAttributes.put("title", this.currentChunk.getContent());
return;
}
if (HtmlTagMap.isMeta(paramString3))
return;
if (HtmlTagMap.isLink(paramString3))
return;
if (HtmlTagMap.isBody(paramString3))
return;
if (this.myTags.containsKey(paramString3)) {
XmlPeer xmlPeer = (XmlPeer)this.myTags.get(paramString3);
if ("table".equals(xmlPeer.getTag()))
this.tableBorder = false;
handleEndingTags(xmlPeer.getTag());
return;
}
handleEndingTags(paramString3);
}
}

View file

@ -0,0 +1,196 @@
package com.lowagie.text.html;
import java.awt.Color;
import java.util.HashMap;
import java.util.StringTokenizer;
public class WebColors extends HashMap {
private static final long serialVersionUID = 3542523100813372896L;
public static final WebColors NAMES = new WebColors();
public static Color getRGBColor(String paramString) throws IllegalArgumentException {
int[] arrayOfInt = { 0, 0, 0, 0 };
if (paramString.startsWith("#")) {
if (paramString.length() == 4) {
arrayOfInt[0] = Integer.parseInt(paramString.substring(1, 2), 16) * 16;
arrayOfInt[1] = Integer.parseInt(paramString.substring(2, 3), 16) * 16;
arrayOfInt[2] = Integer.parseInt(paramString.substring(3), 16) * 16;
return new Color(arrayOfInt[0], arrayOfInt[1], arrayOfInt[2], arrayOfInt[3]);
}
if (paramString.length() == 7) {
arrayOfInt[0] = Integer.parseInt(paramString.substring(1, 3), 16);
arrayOfInt[1] = Integer.parseInt(paramString.substring(3, 5), 16);
arrayOfInt[2] = Integer.parseInt(paramString.substring(5), 16);
return new Color(arrayOfInt[0], arrayOfInt[1], arrayOfInt[2], arrayOfInt[3]);
}
throw new IllegalArgumentException("Unknown color format. Must be #RGB or #RRGGBB");
}
if (paramString.startsWith("rgb(")) {
StringTokenizer stringTokenizer = new StringTokenizer(paramString, "rgb(), \t\r\n\f");
for (int i = 0; i < 3; i++) {
String str = stringTokenizer.nextToken();
if (str.endsWith("%")) {
arrayOfInt[i] = Integer.parseInt(str.substring(0, str.length() - 1)) * 255 / 100;
} else {
arrayOfInt[i] = Integer.parseInt(str);
}
if (arrayOfInt[i] < 0) {
arrayOfInt[i] = 0;
} else if (arrayOfInt[i] > 255) {
arrayOfInt[i] = 255;
}
}
return new Color(arrayOfInt[0], arrayOfInt[1], arrayOfInt[2], arrayOfInt[3]);
}
paramString = paramString.toLowerCase();
if (!NAMES.containsKey(paramString))
throw new IllegalArgumentException("Color '" + paramString + "' not found.");
arrayOfInt = (int[])NAMES.get(paramString);
return new Color(arrayOfInt[0], arrayOfInt[1], arrayOfInt[2], arrayOfInt[3]);
}
static {
NAMES.put("aliceblue", new int[] { 240, 248, 255, 0 });
NAMES.put("antiquewhite", new int[] { 250, 235, 215, 0 });
NAMES.put("aqua", new int[] { 0, 255, 255, 0 });
NAMES.put("aquamarine", new int[] { 127, 255, 212, 0 });
NAMES.put("azure", new int[] { 240, 255, 255, 0 });
NAMES.put("beige", new int[] { 245, 245, 220, 0 });
NAMES.put("bisque", new int[] { 255, 228, 196, 0 });
NAMES.put("black", new int[] { 0, 0, 0, 0 });
NAMES.put("blanchedalmond", new int[] { 255, 235, 205, 0 });
NAMES.put("blue", new int[] { 0, 0, 255, 0 });
NAMES.put("blueviolet", new int[] { 138, 43, 226, 0 });
NAMES.put("brown", new int[] { 165, 42, 42, 0 });
NAMES.put("burlywood", new int[] { 222, 184, 135, 0 });
NAMES.put("cadetblue", new int[] { 95, 158, 160, 0 });
NAMES.put("chartreuse", new int[] { 127, 255, 0, 0 });
NAMES.put("chocolate", new int[] { 210, 105, 30, 0 });
NAMES.put("coral", new int[] { 255, 127, 80, 0 });
NAMES.put("cornflowerblue", new int[] { 100, 149, 237, 0 });
NAMES.put("cornsilk", new int[] { 255, 248, 220, 0 });
NAMES.put("crimson", new int[] { 220, 20, 60, 0 });
NAMES.put("cyan", new int[] { 0, 255, 255, 0 });
NAMES.put("darkblue", new int[] { 0, 0, 139, 0 });
NAMES.put("darkcyan", new int[] { 0, 139, 139, 0 });
NAMES.put("darkgoldenrod", new int[] { 184, 134, 11, 0 });
NAMES.put("darkgray", new int[] { 169, 169, 169, 0 });
NAMES.put("darkgreen", new int[] { 0, 100, 0, 0 });
NAMES.put("darkkhaki", new int[] { 189, 183, 107, 0 });
NAMES.put("darkmagenta", new int[] { 139, 0, 139, 0 });
NAMES.put("darkolivegreen", new int[] { 85, 107, 47, 0 });
NAMES.put("darkorange", new int[] { 255, 140, 0, 0 });
NAMES.put("darkorchid", new int[] { 153, 50, 204, 0 });
NAMES.put("darkred", new int[] { 139, 0, 0, 0 });
NAMES.put("darksalmon", new int[] { 233, 150, 122, 0 });
NAMES.put("darkseagreen", new int[] { 143, 188, 143, 0 });
NAMES.put("darkslateblue", new int[] { 72, 61, 139, 0 });
NAMES.put("darkslategray", new int[] { 47, 79, 79, 0 });
NAMES.put("darkturquoise", new int[] { 0, 206, 209, 0 });
NAMES.put("darkviolet", new int[] { 148, 0, 211, 0 });
NAMES.put("deeppink", new int[] { 255, 20, 147, 0 });
NAMES.put("deepskyblue", new int[] { 0, 191, 255, 0 });
NAMES.put("dimgray", new int[] { 105, 105, 105, 0 });
NAMES.put("dodgerblue", new int[] { 30, 144, 255, 0 });
NAMES.put("firebrick", new int[] { 178, 34, 34, 0 });
NAMES.put("floralwhite", new int[] { 255, 250, 240, 0 });
NAMES.put("forestgreen", new int[] { 34, 139, 34, 0 });
NAMES.put("fuchsia", new int[] { 255, 0, 255, 0 });
NAMES.put("gainsboro", new int[] { 220, 220, 220, 0 });
NAMES.put("ghostwhite", new int[] { 248, 248, 255, 0 });
NAMES.put("gold", new int[] { 255, 215, 0, 0 });
NAMES.put("goldenrod", new int[] { 218, 165, 32, 0 });
NAMES.put("gray", new int[] { 128, 128, 128, 0 });
NAMES.put("green", new int[] { 0, 128, 0, 0 });
NAMES.put("greenyellow", new int[] { 173, 255, 47, 0 });
NAMES.put("honeydew", new int[] { 240, 255, 240, 0 });
NAMES.put("hotpink", new int[] { 255, 105, 180, 0 });
NAMES.put("indianred", new int[] { 205, 92, 92, 0 });
NAMES.put("indigo", new int[] { 75, 0, 130, 0 });
NAMES.put("ivory", new int[] { 255, 255, 240, 0 });
NAMES.put("khaki", new int[] { 240, 230, 140, 0 });
NAMES.put("lavender", new int[] { 230, 230, 250, 0 });
NAMES.put("lavenderblush", new int[] { 255, 240, 245, 0 });
NAMES.put("lawngreen", new int[] { 124, 252, 0, 0 });
NAMES.put("lemonchiffon", new int[] { 255, 250, 205, 0 });
NAMES.put("lightblue", new int[] { 173, 216, 230, 0 });
NAMES.put("lightcoral", new int[] { 240, 128, 128, 0 });
NAMES.put("lightcyan", new int[] { 224, 255, 255, 0 });
NAMES.put("lightgoldenrodyellow", new int[] { 250, 250, 210, 0 });
NAMES.put("lightgreen", new int[] { 144, 238, 144, 0 });
NAMES.put("lightgrey", new int[] { 211, 211, 211, 0 });
NAMES.put("lightpink", new int[] { 255, 182, 193, 0 });
NAMES.put("lightsalmon", new int[] { 255, 160, 122, 0 });
NAMES.put("lightseagreen", new int[] { 32, 178, 170, 0 });
NAMES.put("lightskyblue", new int[] { 135, 206, 250, 0 });
NAMES.put("lightslategray", new int[] { 119, 136, 153, 0 });
NAMES.put("lightsteelblue", new int[] { 176, 196, 222, 0 });
NAMES.put("lightyellow", new int[] { 255, 255, 224, 0 });
NAMES.put("lime", new int[] { 0, 255, 0, 0 });
NAMES.put("limegreen", new int[] { 50, 205, 50, 0 });
NAMES.put("linen", new int[] { 250, 240, 230, 0 });
NAMES.put("magenta", new int[] { 255, 0, 255, 0 });
NAMES.put("maroon", new int[] { 128, 0, 0, 0 });
NAMES.put("mediumaquamarine", new int[] { 102, 205, 170, 0 });
NAMES.put("mediumblue", new int[] { 0, 0, 205, 0 });
NAMES.put("mediumorchid", new int[] { 186, 85, 211, 0 });
NAMES.put("mediumpurple", new int[] { 147, 112, 219, 0 });
NAMES.put("mediumseagreen", new int[] { 60, 179, 113, 0 });
NAMES.put("mediumslateblue", new int[] { 123, 104, 238, 0 });
NAMES.put("mediumspringgreen", new int[] { 0, 250, 154, 0 });
NAMES.put("mediumturquoise", new int[] { 72, 209, 204, 0 });
NAMES.put("mediumvioletred", new int[] { 199, 21, 133, 0 });
NAMES.put("midnightblue", new int[] { 25, 25, 112, 0 });
NAMES.put("mintcream", new int[] { 245, 255, 250, 0 });
NAMES.put("mistyrose", new int[] { 255, 228, 225, 0 });
NAMES.put("moccasin", new int[] { 255, 228, 181, 0 });
NAMES.put("navajowhite", new int[] { 255, 222, 173, 0 });
NAMES.put("navy", new int[] { 0, 0, 128, 0 });
NAMES.put("oldlace", new int[] { 253, 245, 230, 0 });
NAMES.put("olive", new int[] { 128, 128, 0, 0 });
NAMES.put("olivedrab", new int[] { 107, 142, 35, 0 });
NAMES.put("orange", new int[] { 255, 165, 0, 0 });
NAMES.put("orangered", new int[] { 255, 69, 0, 0 });
NAMES.put("orchid", new int[] { 218, 112, 214, 0 });
NAMES.put("palegoldenrod", new int[] { 238, 232, 170, 0 });
NAMES.put("palegreen", new int[] { 152, 251, 152, 0 });
NAMES.put("paleturquoise", new int[] { 175, 238, 238, 0 });
NAMES.put("palevioletred", new int[] { 219, 112, 147, 0 });
NAMES.put("papayawhip", new int[] { 255, 239, 213, 0 });
NAMES.put("peachpuff", new int[] { 255, 218, 185, 0 });
NAMES.put("peru", new int[] { 205, 133, 63, 0 });
NAMES.put("pink", new int[] { 255, 192, 203, 0 });
NAMES.put("plum", new int[] { 221, 160, 221, 0 });
NAMES.put("powderblue", new int[] { 176, 224, 230, 0 });
NAMES.put("purple", new int[] { 128, 0, 128, 0 });
NAMES.put("red", new int[] { 255, 0, 0, 0 });
NAMES.put("rosybrown", new int[] { 188, 143, 143, 0 });
NAMES.put("royalblue", new int[] { 65, 105, 225, 0 });
NAMES.put("saddlebrown", new int[] { 139, 69, 19, 0 });
NAMES.put("salmon", new int[] { 250, 128, 114, 0 });
NAMES.put("sandybrown", new int[] { 244, 164, 96, 0 });
NAMES.put("seagreen", new int[] { 46, 139, 87, 0 });
NAMES.put("seashell", new int[] { 255, 245, 238, 0 });
NAMES.put("sienna", new int[] { 160, 82, 45, 0 });
NAMES.put("silver", new int[] { 192, 192, 192, 0 });
NAMES.put("skyblue", new int[] { 135, 206, 235, 0 });
NAMES.put("slateblue", new int[] { 106, 90, 205, 0 });
NAMES.put("slategray", new int[] { 112, 128, 144, 0 });
NAMES.put("snow", new int[] { 255, 250, 250, 0 });
NAMES.put("springgreen", new int[] { 0, 255, 127, 0 });
NAMES.put("steelblue", new int[] { 70, 130, 180, 0 });
NAMES.put("tan", new int[] { 210, 180, 140, 0 });
NAMES.put("transparent", new int[] { 0, 0, 0, 255 });
NAMES.put("teal", new int[] { 0, 128, 128, 0 });
NAMES.put("thistle", new int[] { 216, 191, 216, 0 });
NAMES.put("tomato", new int[] { 255, 99, 71, 0 });
NAMES.put("turquoise", new int[] { 64, 224, 208, 0 });
NAMES.put("violet", new int[] { 238, 130, 238, 0 });
NAMES.put("wheat", new int[] { 245, 222, 179, 0 });
NAMES.put("white", new int[] { 255, 255, 255, 0 });
NAMES.put("whitesmoke", new int[] { 245, 245, 245, 0 });
NAMES.put("yellow", new int[] { 255, 255, 0, 0 });
NAMES.put("yellowgreen", new int[] { 9, 2765, 50, 0 });
}
}

View file

@ -0,0 +1,7 @@
package com.lowagie.text.html.simpleparser;
import com.lowagie.text.Paragraph;
public interface ALink {
boolean process(Paragraph paramParagraph, ChainedProperties paramChainedProperties);
}

View file

@ -0,0 +1,79 @@
package com.lowagie.text.html.simpleparser;
import java.util.ArrayList;
import java.util.HashMap;
public class ChainedProperties {
public static final int[] fontSizes = new int[] { 8, 10, 12, 14, 18, 24, 36 };
public ArrayList chain = new ArrayList();
public String getProperty(String paramString) {
for (int i = this.chain.size() - 1; i >= 0; i--) {
Object[] arrayOfObject = (Object[])this.chain.get(i);
HashMap hashMap = (HashMap)arrayOfObject[1];
String str = (String)hashMap.get(paramString);
if (str != null)
return str;
}
return null;
}
public boolean hasProperty(String paramString) {
for (int i = this.chain.size() - 1; i >= 0; i--) {
Object[] arrayOfObject = (Object[])this.chain.get(i);
HashMap hashMap = (HashMap)arrayOfObject[1];
if (hashMap.containsKey(paramString))
return true;
}
return false;
}
public void addToChain(String paramString, HashMap paramHashMap) {
String str = (String)paramHashMap.get("size");
if (str != null)
if (str.endsWith("px")) {
paramHashMap.put("size", str.substring(0, str.length() - 2));
} else {
int i = 0;
if (str.startsWith("+") || str.startsWith("-")) {
String str1 = getProperty("basefontsize");
if (str1 == null)
str1 = "12";
float f = Float.parseFloat(str1);
int j = (int)f;
int k;
for (k = fontSizes.length - 1; k >= 0; k--) {
if (j >= fontSizes[k]) {
i = k;
break;
}
}
k = Integer.parseInt(str.startsWith("+") ? str.substring(1) : str);
i += k;
} else {
try {
i = Integer.parseInt(str) - 1;
} catch (NumberFormatException e) {
i = 0;
}
}
if (i < 0) {
i = 0;
} else if (i >= fontSizes.length) {
i = fontSizes.length - 1;
}
paramHashMap.put("size", Integer.toString(fontSizes[i]));
}
this.chain.add(new Object[] { paramString, paramHashMap });
}
public void removeChain(String paramString) {
for (int i = this.chain.size() - 1; i >= 0; i--) {
if (paramString.equals(((Object[])this.chain.get(i))[0])) {
this.chain.remove(i);
return;
}
}
}
}

View file

@ -0,0 +1,333 @@
package com.lowagie.text.html.simpleparser;
import com.lowagie.text.Chunk;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.FontFactoryImp;
import com.lowagie.text.ListItem;
import com.lowagie.text.Paragraph;
import com.lowagie.text.html.Markup;
import com.lowagie.text.pdf.HyphenationAuto;
import com.lowagie.text.pdf.HyphenationEvent;
import java.awt.Color;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
import java.util.StringTokenizer;
public class FactoryProperties {
private FontFactoryImp fontImp = FontFactory.getFontImp();
public static HashMap followTags = new HashMap();
public Chunk createChunk(String paramString, ChainedProperties paramChainedProperties) {
Font font = getFont(paramChainedProperties);
float f = font.getSize();
f /= 2.0F;
Chunk chunk = new Chunk(paramString, font);
if (paramChainedProperties.hasProperty("sub")) {
chunk.setTextRise(-f);
} else if (paramChainedProperties.hasProperty("sup")) {
chunk.setTextRise(f);
}
chunk.setHyphenation(getHyphenation(paramChainedProperties));
return chunk;
}
private static void setParagraphLeading(Paragraph paramParagraph, String paramString) {
if (paramString == null) {
paramParagraph.setLeading(0.0F, 1.5F);
return;
}
try {
StringTokenizer stringTokenizer = new StringTokenizer(paramString, " ,");
String str = stringTokenizer.nextToken();
float f1 = Float.parseFloat(str);
if (!stringTokenizer.hasMoreTokens()) {
paramParagraph.setLeading(f1, 0.0F);
return;
}
str = stringTokenizer.nextToken();
float f2 = Float.parseFloat(str);
paramParagraph.setLeading(f1, f2);
} catch (Exception e) {
paramParagraph.setLeading(0.0F, 1.5F);
}
}
public static Paragraph createParagraph(HashMap paramHashMap) {
Paragraph paragraph = new Paragraph();
String str = (String)paramHashMap.get("align");
if (str != null)
if (str.equalsIgnoreCase("center")) {
paragraph.setAlignment(1);
} else if (str.equalsIgnoreCase("right")) {
paragraph.setAlignment(2);
} else if (str.equalsIgnoreCase("justify")) {
paragraph.setAlignment(3);
}
paragraph.setHyphenation(getHyphenation(paramHashMap));
setParagraphLeading(paragraph, (String)paramHashMap.get("leading"));
return paragraph;
}
public static void createParagraph(Paragraph paramParagraph, ChainedProperties paramChainedProperties) {
String str = paramChainedProperties.getProperty("align");
if (str != null)
if (str.equalsIgnoreCase("center")) {
paramParagraph.setAlignment(1);
} else if (str.equalsIgnoreCase("right")) {
paramParagraph.setAlignment(2);
} else if (str.equalsIgnoreCase("justify")) {
paramParagraph.setAlignment(3);
}
paramParagraph.setHyphenation(getHyphenation(paramChainedProperties));
setParagraphLeading(paramParagraph, paramChainedProperties.getProperty("leading"));
str = paramChainedProperties.getProperty("before");
if (str != null)
try {
paramParagraph.setSpacingBefore(Float.parseFloat(str));
} catch (Exception e) {}
str = paramChainedProperties.getProperty("after");
if (str != null)
try {
paramParagraph.setSpacingAfter(Float.parseFloat(str));
} catch (Exception e) {}
str = paramChainedProperties.getProperty("extraparaspace");
if (str != null)
try {
paramParagraph.setExtraParagraphSpace(Float.parseFloat(str));
} catch (Exception e) {}
}
public static Paragraph createParagraph(ChainedProperties paramChainedProperties) {
Paragraph paragraph = new Paragraph();
createParagraph(paragraph, paramChainedProperties);
return paragraph;
}
public static ListItem createListItem(ChainedProperties paramChainedProperties) {
ListItem listItem = new ListItem();
createParagraph(listItem, paramChainedProperties);
return listItem;
}
public Font getFont(ChainedProperties paramChainedProperties) {
String str1 = paramChainedProperties.getProperty("face");
if (str1 != null) {
StringTokenizer stringTokenizer = new StringTokenizer(str1, ",");
while (stringTokenizer.hasMoreTokens()) {
str1 = stringTokenizer.nextToken().trim();
if (str1.startsWith("\""))
str1 = str1.substring(1);
if (str1.endsWith("\""))
str1 = str1.substring(0, str1.length() - 1);
if (this.fontImp.isRegistered(str1))
break;
}
}
int i = 0;
if (paramChainedProperties.hasProperty("i"))
i |= 0x2;
if (paramChainedProperties.hasProperty("b"))
i |= 0x1;
if (paramChainedProperties.hasProperty("u"))
i |= 0x4;
if (paramChainedProperties.hasProperty("s"))
i |= 0x8;
String str2 = paramChainedProperties.getProperty("size");
float f = 12.0F;
if (str2 != null)
f = Float.parseFloat(str2);
Color color = Markup.decodeColor(paramChainedProperties.getProperty("color"));
String str3 = paramChainedProperties.getProperty("encoding");
if (str3 == null)
str3 = "Cp1252";
return this.fontImp.getFont(str1, str3, true, f, i, color);
}
public static HyphenationEvent getHyphenation(ChainedProperties paramChainedProperties) {
return getHyphenation(paramChainedProperties.getProperty("hyphenation"));
}
public static HyphenationEvent getHyphenation(HashMap paramHashMap) {
return getHyphenation((String)paramHashMap.get("hyphenation"));
}
public static HyphenationEvent getHyphenation(String paramString) {
if (paramString == null || paramString.length() == 0)
return null;
String str1 = paramString;
String str2 = null;
int i = 2;
int j = 2;
int k = paramString.indexOf('_');
if (k == -1)
return new HyphenationAuto(str1, str2, i, j);
str1 = paramString.substring(0, k);
str2 = paramString.substring(k + 1);
k = str2.indexOf(',');
if (k == -1)
return new HyphenationAuto(str1, str2, i, j);
paramString = str2.substring(k + 1);
str2 = str2.substring(0, k);
k = paramString.indexOf(',');
if (k == -1) {
i = Integer.parseInt(paramString);
} else {
i = Integer.parseInt(paramString.substring(0, k));
j = Integer.parseInt(paramString.substring(k + 1));
}
return new HyphenationAuto(str1, str2, i, j);
}
public static void insertStyle(HashMap paramHashMap) {
String str = (String)paramHashMap.get("style");
if (str == null)
return;
Properties properties = Markup.parseAttributes(str);
Iterator iterator = properties.keySet().iterator();
while (iterator.hasNext()) {
String str1 = (String)iterator.next();
if (str1.equals("font-family")) {
paramHashMap.put("face", properties.getProperty(str1));
continue;
}
if (str1.equals("font-size")) {
paramHashMap.put("size", Float.toString(Markup.parseLength(properties.getProperty(str1))) + "px");
continue;
}
if (str1.equals("font-style")) {
String str2 = properties.getProperty(str1).trim().toLowerCase();
if (str2.equals("italic") || str2.equals("oblique"))
paramHashMap.put("i", null);
continue;
}
if (str1.equals("font-weight")) {
String str2 = properties.getProperty(str1).trim().toLowerCase();
if (str2.equals("bold") || str2.equals("700") || str2.equals("800") || str2.equals("900"))
paramHashMap.put("b", null);
continue;
}
if (str1.equals("text-decoration")) {
String str2 = properties.getProperty(str1).trim().toLowerCase();
if (str2.equals("underline"))
paramHashMap.put("u", null);
continue;
}
if (str1.equals("color")) {
Color color = Markup.decodeColor(properties.getProperty(str1));
if (color != null) {
int i = color.getRGB();
String str2 = Integer.toHexString(i);
str2 = "000000" + str2;
str2 = "#" + str2.substring(str2.length() - 6);
paramHashMap.put("color", str2);
}
continue;
}
if (str1.equals("line-height")) {
String str2 = properties.getProperty(str1).trim();
float f = Markup.parseLength(properties.getProperty(str1));
if (str2.endsWith("%")) {
paramHashMap.put("leading", "0," + (f / 100.0F));
continue;
}
paramHashMap.put("leading", f + ",0");
continue;
}
if (str1.equals("text-align")) {
String str2 = properties.getProperty(str1).trim().toLowerCase();
paramHashMap.put("align", str2);
}
}
}
public static void insertStyle(HashMap paramHashMap, ChainedProperties paramChainedProperties) {
String str = (String)paramHashMap.get("style");
if (str == null)
return;
Properties properties = Markup.parseAttributes(str);
Iterator iterator = properties.keySet().iterator();
while (iterator.hasNext()) {
String str1 = (String)iterator.next();
if (str1.equals("font-family")) {
paramHashMap.put("face", properties.getProperty(str1));
continue;
}
if (str1.equals("font-size")) {
float f = Markup.parseLength(paramChainedProperties.getProperty("size"), 12.0F);
if (f <= 0.0F)
f = 12.0F;
paramHashMap.put("size", Float.toString(Markup.parseLength(properties.getProperty(str1), f)) + "pt");
continue;
}
if (str1.equals("font-style")) {
String str2 = properties.getProperty(str1).trim().toLowerCase();
if (str2.equals("italic") || str2.equals("oblique"))
paramHashMap.put("i", null);
continue;
}
if (str1.equals("font-weight")) {
String str2 = properties.getProperty(str1).trim().toLowerCase();
if (str2.equals("bold") || str2.equals("700") || str2.equals("800") || str2.equals("900"))
paramHashMap.put("b", null);
continue;
}
if (str1.equals("text-decoration")) {
String str2 = properties.getProperty(str1).trim().toLowerCase();
if (str2.equals("underline"))
paramHashMap.put("u", null);
continue;
}
if (str1.equals("color")) {
Color color = Markup.decodeColor(properties.getProperty(str1));
if (color != null) {
int i = color.getRGB();
String str2 = Integer.toHexString(i);
str2 = "000000" + str2;
str2 = "#" + str2.substring(str2.length() - 6);
paramHashMap.put("color", str2);
}
continue;
}
if (str1.equals("line-height")) {
String str2 = properties.getProperty(str1).trim();
float f1 = Markup.parseLength(paramChainedProperties.getProperty("size"), 12.0F);
if (f1 <= 0.0F)
f1 = 12.0F;
float f2 = Markup.parseLength(properties.getProperty(str1), f1);
if (str2.endsWith("%")) {
paramHashMap.put("leading", "0," + (f2 / 100.0F));
continue;
}
paramHashMap.put("leading", f2 + ",0");
continue;
}
if (str1.equals("text-align")) {
String str2 = properties.getProperty(str1).trim().toLowerCase();
paramHashMap.put("align", str2);
}
}
}
public FontFactoryImp getFontImp() {
return this.fontImp;
}
public void setFontImp(FontFactoryImp paramFontFactoryImp) {
this.fontImp = paramFontFactoryImp;
}
static {
followTags.put("i", "i");
followTags.put("b", "b");
followTags.put("u", "u");
followTags.put("sub", "sub");
followTags.put("sup", "sup");
followTags.put("em", "i");
followTags.put("strong", "b");
followTags.put("s", "s");
followTags.put("strike", "s");
}
}

View file

@ -0,0 +1,593 @@
package com.lowagie.text.html.simpleparser;
import com.lowagie.text.Chunk;
import com.lowagie.text.DocListener;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.FontFactoryImp;
import com.lowagie.text.HeaderFooter;
import com.lowagie.text.Image;
import com.lowagie.text.List;
import com.lowagie.text.ListItem;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.Rectangle;
import com.lowagie.text.TextElementArray;
import com.lowagie.text.html.Markup;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.xml.simpleparser.SimpleXMLDocHandler;
import com.lowagie.text.xml.simpleparser.SimpleXMLParser;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Stack;
import java.util.StringTokenizer;
public class HTMLWorker implements SimpleXMLDocHandler, DocListener {
protected ArrayList objectList;
protected DocListener document;
private Paragraph currentParagraph;
private ChainedProperties cprops = new ChainedProperties();
private Stack stack = new Stack();
private boolean pendingTR = false;
private boolean pendingTD = false;
private boolean pendingLI = false;
private StyleSheet style = new StyleSheet();
private boolean isPRE = false;
private Stack tableState = new Stack();
private boolean skipText = false;
private HashMap interfaceProps;
private FactoryProperties factoryProperties = new FactoryProperties();
public static final String tagsSupportedString = "ol ul li a pre font span br p div body table td th tr i b u sub sup em strong s strike h1 h2 h3 h4 h5 h6 img";
public static final HashMap tagsSupported = new HashMap();
public HTMLWorker(DocListener paramDocListener) {
this.document = paramDocListener;
}
public void setStyleSheet(StyleSheet paramStyleSheet) {
this.style = paramStyleSheet;
}
public StyleSheet getStyleSheet() {
return this.style;
}
public void setInterfaceProps(HashMap paramHashMap) {
this.interfaceProps = paramHashMap;
FontFactoryImp fontFactoryImp = null;
if (paramHashMap != null)
fontFactoryImp = (FontFactoryImp)paramHashMap.get("font_factory");
if (fontFactoryImp != null)
this.factoryProperties.setFontImp(fontFactoryImp);
}
public HashMap getInterfaceProps() {
return this.interfaceProps;
}
public void parse(Reader paramReader) throws IOException {
SimpleXMLParser.parse(this, null, paramReader, true);
}
public static ArrayList parseToList(Reader paramReader, StyleSheet paramStyleSheet) throws IOException {
return parseToList(paramReader, paramStyleSheet, null);
}
public static ArrayList parseToList(Reader paramReader, StyleSheet paramStyleSheet, HashMap paramHashMap) throws IOException {
HTMLWorker hTMLWorker = new HTMLWorker(null);
if (paramStyleSheet != null)
hTMLWorker.style = paramStyleSheet;
hTMLWorker.document = hTMLWorker;
hTMLWorker.setInterfaceProps(paramHashMap);
hTMLWorker.objectList = new ArrayList();
hTMLWorker.parse(paramReader);
return hTMLWorker.objectList;
}
public void endDocument() {
try {
for (int i = 0; i < this.stack.size(); i++)
this.document.add((Element)this.stack.elementAt(i));
if (this.currentParagraph != null)
this.document.add(this.currentParagraph);
this.currentParagraph = null;
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
public void startDocument() {
HashMap hashMap = new HashMap();
this.style.applyStyle("body", hashMap);
this.cprops.addToChain("body", hashMap);
}
public void startElement(String paramString, HashMap paramHashMap) {
if (!tagsSupported.containsKey(paramString))
return;
try {
this.style.applyStyle(paramString, paramHashMap);
String str = (String)FactoryProperties.followTags.get(paramString);
if (str != null) {
HashMap hashMap = new HashMap();
hashMap.put(str, null);
this.cprops.addToChain(str, hashMap);
return;
}
FactoryProperties.insertStyle(paramHashMap, this.cprops);
if (paramString.equals("a")) {
this.cprops.addToChain(paramString, paramHashMap);
if (this.currentParagraph == null)
this.currentParagraph = new Paragraph();
this.stack.push(this.currentParagraph);
this.currentParagraph = new Paragraph();
return;
}
if (paramString.equals("br")) {
if (this.currentParagraph == null)
this.currentParagraph = new Paragraph();
this.currentParagraph.add(this.factoryProperties.createChunk("\n", this.cprops));
return;
}
if (paramString.equals("font") || paramString.equals("span")) {
this.cprops.addToChain(paramString, paramHashMap);
return;
}
if (paramString.equals("img")) {
String str1 = (String)paramHashMap.get("src");
if (str1 == null)
return;
this.cprops.addToChain(paramString, paramHashMap);
Image image = null;
if (this.interfaceProps != null) {
ImageProvider imageProvider = (ImageProvider)this.interfaceProps.get("img_provider");
if (imageProvider != null)
image = imageProvider.getImage(str1, paramHashMap, this.cprops, this.document);
if (image == null) {
HashMap hashMap = (HashMap)this.interfaceProps.get("img_static");
if (hashMap != null) {
Image image1 = (Image)hashMap.get(str1);
if (image1 != null)
image = Image.getInstance(image1);
} else if (!str1.startsWith("http")) {
String str7 = (String)this.interfaceProps.get("img_baseurl");
if (str7 != null) {
str1 = str7 + str1;
image = Image.getInstance(str1);
}
}
}
}
if (image == null) {
if (!str1.startsWith("http")) {
String str7 = this.cprops.getProperty("image_path");
if (str7 == null)
str7 = "";
str1 = new File(str7, str1).getPath();
}
image = Image.getInstance(str1);
}
String str2 = (String)paramHashMap.get("align");
String str3 = (String)paramHashMap.get("width");
String str4 = (String)paramHashMap.get("height");
String str5 = this.cprops.getProperty("before");
String str6 = this.cprops.getProperty("after");
if (str5 != null)
image.setSpacingBefore(Float.parseFloat(str5));
if (str6 != null)
image.setSpacingAfter(Float.parseFloat(str6));
float f1 = Markup.parseLength(this.cprops.getProperty("size"), 12.0F);
if (f1 <= 0.0F)
f1 = 12.0F;
float f2 = Markup.parseLength(str3, f1);
float f3 = Markup.parseLength(str4, f1);
if (f2 > 0.0F && f3 > 0.0F) {
image.scaleAbsolute(f2, f3);
} else if (f2 > 0.0F) {
f3 = image.getHeight() * f2 / image.getWidth();
image.scaleAbsolute(f2, f3);
} else if (f3 > 0.0F) {
f2 = image.getWidth() * f3 / image.getHeight();
image.scaleAbsolute(f2, f3);
}
image.setWidthPercentage(0.0F);
if (str2 != null) {
endElement("p");
int i = 1;
if (str2.equalsIgnoreCase("left")) {
i = 0;
} else if (str2.equalsIgnoreCase("right")) {
i = 2;
}
image.setAlignment(i);
Img img = null;
boolean bool = false;
if (this.interfaceProps != null) {
img = (Img)this.interfaceProps.get("img_interface");
if (img != null)
bool = img.process(image, paramHashMap, this.cprops, this.document);
}
if (!bool)
this.document.add(image);
this.cprops.removeChain(paramString);
} else {
this.cprops.removeChain(paramString);
if (this.currentParagraph == null)
this.currentParagraph = FactoryProperties.createParagraph(this.cprops);
this.currentParagraph.add(new Chunk(image, 0.0F, 0.0F));
}
return;
}
endElement("p");
if (paramString.equals("h1") || paramString.equals("h2") || paramString.equals("h3") || paramString.equals("h4") || paramString.equals("h5") || paramString.equals("h6")) {
if (!paramHashMap.containsKey("size")) {
int i = 7 - Integer.parseInt(paramString.substring(1));
paramHashMap.put("size", Integer.toString(i));
}
this.cprops.addToChain(paramString, paramHashMap);
return;
}
if (paramString.equals("ul")) {
if (this.pendingLI)
endElement("li");
this.skipText = true;
this.cprops.addToChain(paramString, paramHashMap);
List list = new List(false, 10.0F);
list.setListSymbol("");
this.stack.push(list);
return;
}
if (paramString.equals("ol")) {
if (this.pendingLI)
endElement("li");
this.skipText = true;
this.cprops.addToChain(paramString, paramHashMap);
List list = new List(true, 10.0F);
this.stack.push(list);
return;
}
if (paramString.equals("li")) {
if (this.pendingLI)
endElement("li");
this.skipText = false;
this.pendingLI = true;
this.cprops.addToChain(paramString, paramHashMap);
ListItem listItem = FactoryProperties.createListItem(this.cprops);
this.stack.push(listItem);
return;
}
if (paramString.equals("div") || paramString.equals("body")) {
this.cprops.addToChain(paramString, paramHashMap);
return;
}
if (paramString.equals("pre")) {
if (!paramHashMap.containsKey("face"))
paramHashMap.put("face", "Courier");
this.cprops.addToChain(paramString, paramHashMap);
this.isPRE = true;
return;
}
if (paramString.equals("p")) {
this.cprops.addToChain(paramString, paramHashMap);
this.currentParagraph = FactoryProperties.createParagraph(paramHashMap);
return;
}
if (paramString.equals("tr")) {
if (this.pendingTR)
endElement("tr");
this.skipText = true;
this.pendingTR = true;
this.cprops.addToChain("tr", paramHashMap);
return;
}
if (paramString.equals("td") || paramString.equals("th")) {
if (this.pendingTD)
endElement(paramString);
this.skipText = false;
this.pendingTD = true;
this.cprops.addToChain("td", paramHashMap);
this.stack.push(new IncCell(paramString, this.cprops));
return;
}
if (paramString.equals("table")) {
this.cprops.addToChain("table", paramHashMap);
IncTable incTable = new IncTable(paramHashMap);
this.stack.push(incTable);
this.tableState.push(new boolean[] { this.pendingTR, this.pendingTD });
this.pendingTR = this.pendingTD = false;
this.skipText = true;
return;
}
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
public void endElement(String paramString) {
if (!tagsSupported.containsKey(paramString))
return;
try {
String str = (String)FactoryProperties.followTags.get(paramString);
if (str != null) {
this.cprops.removeChain(str);
return;
}
if (paramString.equals("font") || paramString.equals("span")) {
this.cprops.removeChain(paramString);
return;
}
if (paramString.equals("a")) {
if (this.currentParagraph == null)
this.currentParagraph = new Paragraph();
boolean bool = false;
if (this.interfaceProps != null) {
ALink aLink = (ALink)this.interfaceProps.get("alink_interface");
if (aLink != null)
bool = aLink.process(this.currentParagraph, this.cprops);
}
if (!bool) {
String str1 = this.cprops.getProperty("href");
if (str1 != null) {
ArrayList arrayList = this.currentParagraph.getChunks();
int i = arrayList.size();
for (int j = 0; j < i; j++) {
Chunk chunk = (Chunk)arrayList.get(j);
chunk.setAnchor(str1);
}
}
}
Paragraph paragraph = (Paragraph)this.stack.pop();
Phrase phrase = new Phrase();
phrase.add(this.currentParagraph);
paragraph.add(phrase);
this.currentParagraph = paragraph;
this.cprops.removeChain("a");
return;
}
if (paramString.equals("br"))
return;
if (this.currentParagraph != null)
if (this.stack.empty()) {
this.document.add(this.currentParagraph);
} else {
Object object = this.stack.pop();
if (object instanceof TextElementArray) {
TextElementArray textElementArray = (TextElementArray)object;
textElementArray.add(this.currentParagraph);
}
this.stack.push(object);
}
this.currentParagraph = null;
if (paramString.equals("ul") || paramString.equals("ol")) {
if (this.pendingLI)
endElement("li");
this.skipText = false;
this.cprops.removeChain(paramString);
if (this.stack.empty())
return;
Object object = this.stack.pop();
if (!(object instanceof List)) {
this.stack.push(object);
return;
}
if (this.stack.empty()) {
this.document.add((Element)object);
} else {
((TextElementArray)this.stack.peek()).add(object);
}
return;
}
if (paramString.equals("li")) {
this.pendingLI = false;
this.skipText = true;
this.cprops.removeChain(paramString);
if (this.stack.empty())
return;
Object object1 = this.stack.pop();
if (!(object1 instanceof ListItem)) {
this.stack.push(object1);
return;
}
if (this.stack.empty()) {
this.document.add((Element)object1);
return;
}
Object object2 = this.stack.pop();
if (!(object2 instanceof List)) {
this.stack.push(object2);
return;
}
ListItem listItem = (ListItem)object1;
((List)object2).add(listItem);
ArrayList arrayList = listItem.getChunks();
if (!arrayList.isEmpty())
listItem.getListSymbol().setFont(((Chunk)arrayList.get(0)).getFont());
this.stack.push(object2);
return;
}
if (paramString.equals("div") || paramString.equals("body")) {
this.cprops.removeChain(paramString);
return;
}
if (paramString.equals("pre")) {
this.cprops.removeChain(paramString);
this.isPRE = false;
return;
}
if (paramString.equals("p")) {
this.cprops.removeChain(paramString);
return;
}
if (paramString.equals("h1") || paramString.equals("h2") || paramString.equals("h3") || paramString.equals("h4") || paramString.equals("h5") || paramString.equals("h6")) {
this.cprops.removeChain(paramString);
return;
}
if (paramString.equals("table")) {
if (this.pendingTR)
endElement("tr");
this.cprops.removeChain("table");
IncTable incTable = (IncTable)this.stack.pop();
PdfPTable pdfPTable = incTable.buildTable();
pdfPTable.setSplitRows(true);
if (this.stack.empty()) {
this.document.add(pdfPTable);
} else {
((TextElementArray)this.stack.peek()).add(pdfPTable);
}
boolean[] arrayOfBoolean = (boolean[])this.tableState.pop();
this.pendingTR = arrayOfBoolean[0];
this.pendingTD = arrayOfBoolean[1];
this.skipText = false;
return;
}
if (paramString.equals("tr")) {
if (this.pendingTD)
endElement("td");
this.pendingTR = false;
this.cprops.removeChain("tr");
ArrayList arrayList = new ArrayList();
IncTable incTable = null;
while (true) {
Object object = this.stack.pop();
if (object instanceof IncCell)
arrayList.add(((IncCell)object).getCell());
if (object instanceof IncTable) {
incTable = (IncTable)object;
incTable.addCols(arrayList);
incTable.endRow();
this.stack.push(incTable);
this.skipText = true;
return;
}
}
}
if (paramString.equals("td") || paramString.equals("th")) {
this.pendingTD = false;
this.cprops.removeChain("td");
this.skipText = true;
return;
}
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
public void text(String paramString) {
if (this.skipText)
return;
String str = paramString;
if (this.isPRE) {
if (this.currentParagraph == null)
this.currentParagraph = FactoryProperties.createParagraph(this.cprops);
Chunk chunk1 = this.factoryProperties.createChunk(str, this.cprops);
this.currentParagraph.add(chunk1);
return;
}
if (str.trim().length() == 0 && str.indexOf(' ') < 0)
return;
StringBuffer stringBuffer = new StringBuffer();
int i = str.length();
boolean bool = false;
for (int j = 0; j < i; j++) {
char c;
switch (c = str.charAt(j)) {
case ' ':
if (!bool)
stringBuffer.append(c);
break;
case '\n':
if (j > 0) {
bool = true;
stringBuffer.append(' ');
}
break;
case '\r':
case '\t':
break;
default:
bool = false;
stringBuffer.append(c);
break;
}
}
if (this.currentParagraph == null)
this.currentParagraph = FactoryProperties.createParagraph(this.cprops);
Chunk chunk = this.factoryProperties.createChunk(stringBuffer.toString(), this.cprops);
this.currentParagraph.add(chunk);
}
public boolean add(Element paramElement) throws DocumentException {
this.objectList.add(paramElement);
return true;
}
public void clearTextWrap() throws DocumentException {}
public void close() {}
public boolean newPage() {
return true;
}
public void open() {}
public void resetFooter() {}
public void resetHeader() {}
public void resetPageCount() {}
public void setFooter(HeaderFooter paramHeaderFooter) {}
public void setHeader(HeaderFooter paramHeaderFooter) {}
public boolean setMarginMirroring(boolean paramBoolean) {
return true;
}
public boolean setMargins(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4) {
return true;
}
public void setPageCount(int paramInt) {}
public boolean setPageSize(Rectangle paramRectangle) {
return true;
}
private static float lengthParse(String paramString, int paramInt) {
if (paramString == null)
return -1.0F;
if (paramString.endsWith("%"))
return Float.parseFloat(paramString.substring(0, paramString.length() - 1));
if (paramString.endsWith("px"))
return Float.parseFloat(paramString.substring(0, paramString.length() - 2));
int i = Integer.parseInt(paramString);
return (float)i / (float)paramInt * 100.0F;
}
static {
StringTokenizer stringTokenizer = new StringTokenizer("ol ul li a pre font span br p div body table td th tr i b u sub sup em strong s strike h1 h2 h3 h4 h5 h6 img");
while (stringTokenizer.hasMoreTokens())
tagsSupported.put(stringTokenizer.nextToken(), null);
}
}

View file

@ -0,0 +1,9 @@
package com.lowagie.text.html.simpleparser;
import com.lowagie.text.DocListener;
import com.lowagie.text.Image;
import java.util.HashMap;
public interface ImageProvider {
Image getImage(String paramString, HashMap paramHashMap, ChainedProperties paramChainedProperties, DocListener paramDocListener);
}

View file

@ -0,0 +1,9 @@
package com.lowagie.text.html.simpleparser;
import com.lowagie.text.DocListener;
import com.lowagie.text.Image;
import java.util.HashMap;
public interface Img {
boolean process(Image paramImage, HashMap paramHashMap, ChainedProperties paramChainedProperties, DocListener paramDocListener);
}

View file

@ -0,0 +1,84 @@
package com.lowagie.text.html.simpleparser;
import com.lowagie.text.Element;
import com.lowagie.text.ElementListener;
import com.lowagie.text.Phrase;
import com.lowagie.text.TextElementArray;
import com.lowagie.text.html.Markup;
import com.lowagie.text.pdf.PdfPCell;
import java.util.ArrayList;
public class IncCell implements TextElementArray {
private ArrayList chunks = new ArrayList();
private PdfPCell cell = new PdfPCell((Phrase)null);
public IncCell(String paramString, ChainedProperties paramChainedProperties) {
String str = paramChainedProperties.getProperty("colspan");
if (str != null)
this.cell.setColspan(Integer.parseInt(str));
str = paramChainedProperties.getProperty("align");
if (paramString.equals("th"))
this.cell.setHorizontalAlignment(1);
if (str != null)
if ("center".equalsIgnoreCase(str)) {
this.cell.setHorizontalAlignment(1);
} else if ("right".equalsIgnoreCase(str)) {
this.cell.setHorizontalAlignment(2);
} else if ("left".equalsIgnoreCase(str)) {
this.cell.setHorizontalAlignment(0);
} else if ("justify".equalsIgnoreCase(str)) {
this.cell.setHorizontalAlignment(3);
}
str = paramChainedProperties.getProperty("valign");
this.cell.setVerticalAlignment(5);
if (str != null)
if ("top".equalsIgnoreCase(str)) {
this.cell.setVerticalAlignment(4);
} else if ("bottom".equalsIgnoreCase(str)) {
this.cell.setVerticalAlignment(6);
}
str = paramChainedProperties.getProperty("border");
float f = 0.0F;
if (str != null)
f = Float.parseFloat(str);
this.cell.setBorderWidth(f);
str = paramChainedProperties.getProperty("cellpadding");
if (str != null)
this.cell.setPadding(Float.parseFloat(str));
this.cell.setUseDescender(true);
str = paramChainedProperties.getProperty("bgcolor");
this.cell.setBackgroundColor(Markup.decodeColor(str));
}
public boolean add(Object paramObject) {
if (!(paramObject instanceof Element))
return false;
this.cell.addElement((Element)paramObject);
return true;
}
public ArrayList getChunks() {
return this.chunks;
}
public boolean process(ElementListener paramElementListener) {
return true;
}
public int type() {
return 30;
}
public PdfPCell getCell() {
return this.cell;
}
public boolean isContent() {
return true;
}
public boolean isNestable() {
return true;
}
}

View file

@ -0,0 +1,70 @@
package com.lowagie.text.html.simpleparser;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
public class IncTable {
private HashMap props = new HashMap();
private ArrayList rows = new ArrayList();
private ArrayList cols;
public IncTable(HashMap paramHashMap) {
this.props.putAll(paramHashMap);
}
public void addCol(PdfPCell paramPdfPCell) {
if (this.cols == null)
this.cols = new ArrayList();
this.cols.add(paramPdfPCell);
}
public void addCols(ArrayList paramArrayList) {
if (this.cols == null) {
this.cols = new ArrayList(paramArrayList);
} else {
this.cols.addAll(paramArrayList);
}
}
public void endRow() {
if (this.cols != null) {
Collections.reverse(this.cols);
this.rows.add(this.cols);
this.cols = null;
}
}
public ArrayList getRows() {
return this.rows;
}
public PdfPTable buildTable() {
if (this.rows.isEmpty())
return new PdfPTable(1);
int i = 0;
ArrayList arrayList = (ArrayList)this.rows.get(0);
for (int j = 0; j < arrayList.size(); j++)
i += ((PdfPCell)arrayList.get(j)).getColspan();
PdfPTable pdfPTable = new PdfPTable(i);
String str = (String)this.props.get("width");
if (str == null) {
pdfPTable.setWidthPercentage(100.0F);
} else if (str.endsWith("%")) {
pdfPTable.setWidthPercentage(Float.parseFloat(str.substring(0, str.length() - 1)));
} else {
pdfPTable.setTotalWidth(Float.parseFloat(str));
pdfPTable.setLockedWidth(true);
}
for (int k = 0; k < this.rows.size(); k++) {
ArrayList arrayList1 = (ArrayList)this.rows.get(k);
for (int m = 0; m < arrayList1.size(); m++)
pdfPTable.addCell((PdfPCell)arrayList1.get(m));
}
return pdfPTable;
}
}

View file

@ -0,0 +1,56 @@
package com.lowagie.text.html.simpleparser;
import java.util.HashMap;
public class StyleSheet {
public HashMap classMap = new HashMap();
public HashMap tagMap = new HashMap();
public void applyStyle(String paramString, HashMap paramHashMap) {
HashMap hashMap1 = (HashMap)this.tagMap.get(paramString.toLowerCase());
if (hashMap1 != null) {
HashMap hashMap = new HashMap(hashMap1);
hashMap.putAll(paramHashMap);
paramHashMap.putAll(hashMap);
}
String str = (String)paramHashMap.get("class");
if (str == null)
return;
hashMap1 = (HashMap)this.classMap.get(str.toLowerCase());
if (hashMap1 == null)
return;
paramHashMap.remove("class");
HashMap hashMap2 = new HashMap(hashMap1);
hashMap2.putAll(paramHashMap);
paramHashMap.putAll(hashMap2);
}
public void loadStyle(String paramString, HashMap paramHashMap) {
this.classMap.put(paramString.toLowerCase(), paramHashMap);
}
public void loadStyle(String paramString1, String paramString2, String paramString3) {
paramString1 = paramString1.toLowerCase();
HashMap hashMap = (HashMap)this.classMap.get(paramString1);
if (hashMap == null) {
hashMap = new HashMap();
this.classMap.put(paramString1, hashMap);
}
hashMap.put(paramString2, paramString3);
}
public void loadTagStyle(String paramString, HashMap paramHashMap) {
this.tagMap.put(paramString.toLowerCase(), paramHashMap);
}
public void loadTagStyle(String paramString1, String paramString2, String paramString3) {
paramString1 = paramString1.toLowerCase();
HashMap hashMap = (HashMap)this.tagMap.get(paramString1);
if (hashMap == null) {
hashMap = new HashMap();
this.tagMap.put(paramString1, hashMap);
}
hashMap.put(paramString2, paramString3);
}
}

View file

@ -0,0 +1,437 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS

View file

@ -0,0 +1,177 @@
(1)
ExceptionConverter:
The original version of this class was published in an article by Heinz Kabutz.
Read http://www.javaspecialists.co.za/archive/newsletter.do?issue=033&print=yes&locale=en_US
"This material from The Java(tm) Specialists' Newsletter by Maximum Solutions
(South Africa). Please contact Maximum Solutions for more information.
(2)
SimpleXMLParser:
The original version of this class was published in a JavaWorld article by Steven Brandt:
http://www.javaworld.com/javaworld/javatips/jw-javatip128.html
Jennifer Orr (JavaWorld) wrote: "You have permission to use the code appearing in
Steven Brandt's JavaWorld article, 'Java Tip 128: Create a quick-and-dirty XML parser.'
We ask that you reference the author as the creator and JavaWorld as the original publisher
of the code." Steven Brandt also agreed with the use of this class.
(3)
The following files contain material that was copyrighted by SUN:
com/lowagie/text/pdf/LZWDecoder.java (first appearance in iText: 2002-02-08)
com/lowagie/text/pdf/codec/BmpImage.java (first appearance in iText: 2003-06-20)
com/lowagie/text/pdf/codec/PngImage.java (first appearance in iText: 2003-04-25)
com/lowagie/text/pdf/codec/TIFFDirectory.java (first appearance in iText: 2003-04-09)
com/lowagie/text/pdf/codec/TIFFFaxDecoder.java (first appearance in iText: 2003-04-09)
com/lowagie/text/pdf/codec/TIFFField.java (first appearance in iText: 2003-04-09)
com/lowagie/text/pdf/codec/TIFFLZWDecoder.java (first appearance in iText: 2003-04-09)
The original code was released under the BSD license, and contained the following
extra restriction: "You acknowledge that Software is not designed, licensed or intended
for use in the design, construction, operation or maintenance of any nuclear facility."
In a mail sent to Bruno Lowagie on January 23, 2008, Brian Burkhalter (@sun.com)
writes: "This code is under a BSD license and supersedes the older codec packages
on which your code is based. It also includes numerous fixes among them being the
ability to handle a lot of 'broken' TIFFs."
Note that numerous fixes were applied to the code used in iText by Paulo Soares,
but apart from the fixes there were no essential changes between the code that
was originally adapted and the code that is now available under the following
license:
Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistribution of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistribution in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
Neither the name of Sun Microsystems, Inc. or the names of
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
This software is provided "AS IS," without a warranty of any
kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
You acknowledge that this software is not designed or intended for
use in the design, construction, operation or maintenance of any
nuclear facility.
The main difference can be found in the final paragraph: the restriction
that the source code is not "licensed" in this particular situation has
been removed.
FYI: Brian also added: "A bit of history might be in order.
The codec classes that you used originally were based on some
classes included with JAI but not strictly part of JAI.
As of Java SE 1.4 an official Image I/O framework was
added in javax.imageio.... This frameork supports these formats:
Java 1.4: GIF (read only), JPEG, PNG
Java 1.5: Added support for BMP and WBMP
Java 1.6: Added support for writing GIF
The JAI Image I/O Tools packages (jai-imageio-core) were created
to support formats handled by JAI but not included in Java SE
as well as some new things like JPEG2000."
(4) the file com/lowagie/text/pdf/codec/TIFFConstants
and some other TIFF related code is derived from LIBTIFF:
Copyright (c) 1988-1997 Sam Leffler
Copyright (c) 1991-1997 Silicon Graphics, Inc.
Permission to use, copy, modify, distribute, and sell this software and
its documentation for any purpose is hereby granted without fee, provided
that (i) the above copyright notices and this permission notice appear in
all copies of the software and related documentation, and (ii) the names of
Sam Leffler and Silicon Graphics may not be used in any advertising or
publicity relating to the software without the specific, prior written
permission of Sam Leffler and Silicon Graphics.
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS SOFTWARE.
(5)
BidiOrder:
As stated in the Javadoc comments, materials from Unicode.org
are used in the class com/lowagie/text/pdf/BidiOrder.java
The following license applies to these materials:
http://www.unicode.org/copyright.html#Exhibit1
EXHIBIT 1
UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
Unicode Data Files include all data files under the directories
http://www.unicode.org/Public/, http://www.unicode.org/reports/,
and http://www.unicode.org/cldr/data/ .
Unicode Software includes any source code published in the Unicode Standard
or under the directories http://www.unicode.org/Public/, http://www.unicode.org/reports/,
and http://www.unicode.org/cldr/data/.
NOTICE TO USER: Carefully read the following legal agreement. BY DOWNLOADING,
INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S DATA FILES ("DATA FILES"),
AND/OR SOFTWARE ("SOFTWARE"), YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY,
ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
COPYRIGHT AND PERMISSION NOTICE
Copyright (C) 1991-2007 Unicode, Inc. All rights reserved. Distributed under
the Terms of Use in http://www.unicode.org/copyright.html.
Permission is hereby granted, free of charge, to any person obtaining a copy
of the Unicode data files and any associated documentation (the "Data Files")
or Unicode software and any associated documentation (the "Software") to deal
in the Data Files or Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, and/or sell copies
of the Data Files or Software, and to permit persons to whom the Data Files
or Software are furnished to do so, provided that (a) the above copyright
notice(s) and this permission notice appear with all copies of the Data Files
or Software, (b) both the above copyright notice(s) and this permission notice
appear in associated documentation, and (c) there is clear notice in each
modified Data File or in the Software as well as in the documentation associated
with the Data File(s) or Software that the data or software has been modified.
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE
LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR SOFTWARE.
Except as contained in this notice, the name of a copyright holder shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in these Data Files or Software without prior written authorization of the
copyright holder.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,543 @@
package com.lowagie.text.pdf;
public class ArabicLigaturizer {
private static final char ALEF = 'ا';
private static final char ALEFHAMZA = 'أ';
private static final char ALEFHAMZABELOW = 'إ';
private static final char ALEFMADDA = 'آ';
private static final char LAM = 'ل';
private static final char HAMZA = 'ء';
private static final char TATWEEL = 'ـ';
private static final char ZWJ = '';
private static final char HAMZAABOVE = 'ٔ';
private static final char HAMZABELOW = 'ٕ';
private static final char WAWHAMZA = 'ؤ';
private static final char YEHHAMZA = 'ئ';
private static final char WAW = 'و';
private static final char ALEFMAKSURA = 'ى';
private static final char YEH = 'ي';
private static final char FARSIYEH = 'ی';
private static final char SHADDA = 'ّ';
private static final char KASRA = 'ِ';
private static final char FATHA = 'َ';
private static final char DAMMA = 'ُ';
private static final char MADDA = 'ٓ';
private static final char LAM_ALEF = 'ﻻ';
private static final char LAM_ALEFHAMZA = 'ﻷ';
private static final char LAM_ALEFHAMZABELOW = 'ﻹ';
private static final char LAM_ALEFMADDA = 'ﻵ';
private static final char[][] chartable = new char[][] {
new char[] { 'ء', 'ﺀ' }, new char[] { 'آ', 'ﺁ', 'ﺂ' }, new char[] { 'أ', 'ﺃ', 'ﺄ' }, new char[] { 'ؤ', 'ﺅ', 'ﺆ' }, new char[] { 'إ', 'ﺇ', 'ﺈ' }, new char[] { 'ئ', 'ﺉ', 'ﺊ', 'ﺋ', 'ﺌ' }, new char[] { 'ا', '', '' }, new char[] { 'ب', 'ﺏ', 'ﺐ', 'ﺑ', 'ﺒ' }, new char[] { 'ة', 'ﺓ', 'ﺔ' }, new char[] { 'ت', 'ﺕ', 'ﺖ', 'ﺗ', 'ﺘ' },
new char[] { 'ث', 'ﺙ', 'ﺚ', 'ﺛ', 'ﺜ' }, new char[] { 'ج', 'ﺝ', 'ﺞ', 'ﺟ', 'ﺠ' }, new char[] { 'ح', 'ﺡ', 'ﺢ', 'ﺣ', 'ﺤ' }, new char[] { 'خ', 'ﺥ', 'ﺦ', 'ﺧ', 'ﺨ' }, new char[] { 'د', 'ﺩ', 'ﺪ' }, new char[] { 'ذ', 'ﺫ', 'ﺬ' }, new char[] { 'ر', 'ﺭ', 'ﺮ' }, new char[] { 'ز', 'ﺯ', 'ﺰ' }, new char[] { 'س', 'ﺱ', 'ﺲ', 'ﺳ', 'ﺴ' }, new char[] { 'ش', 'ﺵ', 'ﺶ', 'ﺷ', 'ﺸ' },
new char[] { 'ص', 'ﺹ', 'ﺺ', 'ﺻ', 'ﺼ' }, new char[] { 'ض', 'ﺽ', 'ﺾ', 'ﺿ', 'ﻀ' }, new char[] { 'ط', 'ﻁ', 'ﻂ', 'ﻃ', 'ﻄ' }, new char[] { 'ظ', 'ﻅ', 'ﻆ', 'ﻇ', 'ﻈ' }, new char[] { 'ع', 'ﻉ', 'ﻊ', 'ﻋ', 'ﻌ' }, new char[] { 'غ', 'ﻍ', 'ﻎ', 'ﻏ', 'ﻐ' }, new char[] { 'ـ', 'ـ', 'ـ', 'ـ', 'ـ' }, new char[] { 'ف', 'ﻑ', 'ﻒ', 'ﻓ', 'ﻔ' }, new char[] { 'ق', 'ﻕ', 'ﻖ', 'ﻗ', 'ﻘ' }, new char[] { 'ك', 'ﻙ', 'ﻚ', 'ﻛ', 'ﻜ' },
new char[] { 'ل', 'ﻝ', 'ﻞ', 'ﻟ', 'ﻠ' }, new char[] { 'م', 'ﻡ', 'ﻢ', 'ﻣ', 'ﻤ' }, new char[] { 'ن', 'ﻥ', 'ﻦ', 'ﻧ', 'ﻨ' }, new char[] { 'ه', '', '', '', '' }, new char[] { 'و', 'ﻭ', 'ﻮ' }, new char[] { 'ى', 'ﻯ', 'ﻰ', 'ﯨ', 'ﯩ' }, new char[] { 'ي', 'ﻱ', 'ﻲ', 'ﻳ', 'ﻴ' }, new char[] { 'ٱ', 'ﭐ', 'ﭑ' }, new char[] { 'ٹ', 'ﭦ', 'ﭧ', 'ﭨ', 'ﭩ' }, new char[] { 'ٺ', 'ﭞ', 'ﭟ', 'ﭠ', 'ﭡ' },
new char[] { 'ٻ', 'ﭒ', 'ﭓ', 'ﭔ', 'ﭕ' }, new char[] { 'پ', 'ﭖ', 'ﭗ', 'ﭘ', 'ﭙ' }, new char[] { 'ٿ', 'ﭢ', 'ﭣ', 'ﭤ', 'ﭥ' }, new char[] { 'ڀ', 'ﭚ', 'ﭛ', 'ﭜ', 'ﭝ' }, new char[] { 'ڃ', 'ﭶ', 'ﭷ', 'ﭸ', 'ﭹ' }, new char[] { 'ڄ', 'ﭲ', 'ﭳ', 'ﭴ', 'ﭵ' }, new char[] { 'چ', 'ﭺ', 'ﭻ', 'ﭼ', 'ﭽ' }, new char[] { 'ڇ', 'ﭾ', 'ﭿ', 'ﮀ', 'ﮁ' }, new char[] { 'ڈ', 'ﮈ', 'ﮉ' }, new char[] { 'ڌ', 'ﮄ', 'ﮅ' },
new char[] { 'ڍ', 'ﮂ', 'ﮃ' }, new char[] { 'ڎ', 'ﮆ', 'ﮇ' }, new char[] { 'ڑ', 'ﮌ', 'ﮍ' }, new char[] { 'ژ', 'ﮊ', 'ﮋ' }, new char[] { 'ڤ', 'ﭪ', 'ﭫ', 'ﭬ', 'ﭭ' }, new char[] { 'ڦ', 'ﭮ', 'ﭯ', 'ﭰ', 'ﭱ' }, new char[] { 'ک', 'ﮎ', 'ﮏ', 'ﮐ', 'ﮑ' }, new char[] { 'ڭ', 'ﯓ', 'ﯔ', 'ﯕ', 'ﯖ' }, new char[] { 'گ', 'ﮒ', 'ﮓ', 'ﮔ', 'ﮕ' }, new char[] { 'ڱ', 'ﮚ', 'ﮛ', 'ﮜ', 'ﮝ' },
new char[] { 'ڳ', 'ﮖ', 'ﮗ', 'ﮘ', 'ﮙ' }, new char[] { 'ں', 'ﮞ', 'ﮟ' }, new char[] { 'ڻ', 'ﮠ', 'ﮡ', 'ﮢ', 'ﮣ' }, new char[] { 'ھ', '', '', '', '' }, new char[] { 'ۀ', 'ﮤ', 'ﮥ' }, new char[] { 'ہ', '', '', '', '' }, new char[] { 'ۅ', 'ﯠ', 'ﯡ' }, new char[] { 'ۆ', 'ﯙ', 'ﯚ' }, new char[] { 'ۇ', 'ﯗ', 'ﯘ' }, new char[] { 'ۈ', 'ﯛ', 'ﯜ' },
new char[] { 'ۉ', 'ﯢ', 'ﯣ' }, new char[] { 'ۋ', 'ﯞ', 'ﯟ' }, new char[] { 'ی', 'ﯼ', 'ﯽ', 'ﯾ', 'ﯿ' }, new char[] { 'ې', 'ﯤ', 'ﯥ', 'ﯦ', 'ﯧ' }, new char[] { 'ے', 'ﮮ', 'ﮯ' }, new char[] { 'ۓ', 'ﮰ', 'ﮱ' } };
public static final int ar_nothing = 0;
public static final int ar_novowel = 1;
public static final int ar_composedtashkeel = 4;
public static final int ar_lig = 8;
public static final int DIGITS_EN2AN = 32;
public static final int DIGITS_AN2EN = 64;
public static final int DIGITS_EN2AN_INIT_LR = 96;
public static final int DIGITS_EN2AN_INIT_AL = 128;
private static final int DIGITS_RESERVED = 160;
public static final int DIGITS_MASK = 224;
public static final int DIGIT_TYPE_AN = 0;
public static final int DIGIT_TYPE_AN_EXTENDED = 256;
public static final int DIGIT_TYPE_MASK = 256;
static boolean isVowel(char paramChar) {
return ((paramChar >= 'ً' && paramChar <= 'ٕ') || paramChar == 'ٰ');
}
static char charshape(char paramChar, int paramInt) {
if (paramChar >= 'ء' && paramChar <= 'ۓ') {
int i = 0;
int j = chartable.length - 1;
while (i <= j) {
int k = (i + j) / 2;
if (paramChar == chartable[k][0])
return chartable[k][paramInt + 1];
if (paramChar < chartable[k][0]) {
j = k - 1;
continue;
}
i = k + 1;
}
} else if (paramChar >= 'ﻵ' && paramChar <= 'ﻻ') {
return (char)(paramChar + paramInt);
}
return paramChar;
}
static int shapecount(char paramChar) {
if (paramChar >= 'ء' && paramChar <= 'ۓ' && !isVowel(paramChar)) {
int i = 0;
int j = chartable.length - 1;
while (i <= j) {
int k = (i + j) / 2;
if (paramChar == chartable[k][0])
return (chartable[k]).length - 1;
if (paramChar < chartable[k][0]) {
j = k - 1;
continue;
}
i = k + 1;
}
} else if (paramChar == '') {
return 4;
}
return 1;
}
static int ligature(char paramChar, charstruct paramcharstruct) {
int i = 0;
if (paramcharstruct.basechar == '\000')
return 0;
if (isVowel(paramChar)) {
i = 1;
if (paramcharstruct.vowel != '\000' && paramChar != 'ّ')
i = 2;
switch (paramChar) {
case 'ّ':
if (paramcharstruct.mark1 == '\000') {
paramcharstruct.mark1 = 'ّ';
break;
}
return 0;
case 'ٕ':
switch (paramcharstruct.basechar) {
case 'ا':
paramcharstruct.basechar = 'إ';
i = 2;
break;
case 'ﻻ':
paramcharstruct.basechar = 'ﻹ';
i = 2;
break;
}
paramcharstruct.mark1 = 'ٕ';
break;
case 'ٔ':
switch (paramcharstruct.basechar) {
case 'ا':
paramcharstruct.basechar = 'أ';
i = 2;
break;
case 'ﻻ':
paramcharstruct.basechar = 'ﻷ';
i = 2;
break;
case 'و':
paramcharstruct.basechar = 'ؤ';
i = 2;
break;
case 'ى':
case 'ي':
case 'ی':
paramcharstruct.basechar = 'ئ';
i = 2;
break;
}
paramcharstruct.mark1 = 'ٔ';
break;
case 'ٓ':
switch (paramcharstruct.basechar) {
case 'ا':
paramcharstruct.basechar = 'آ';
i = 2;
break;
}
break;
default:
paramcharstruct.vowel = paramChar;
break;
}
if (i == 1)
paramcharstruct.lignum++;
return i;
}
if (paramcharstruct.vowel != '\000')
return 0;
switch (paramcharstruct.basechar) {
case 'ل':
switch (paramChar) {
case 'ا':
paramcharstruct.basechar = 'ﻻ';
paramcharstruct.numshapes = 2;
i = 3;
break;
case 'أ':
paramcharstruct.basechar = 'ﻷ';
paramcharstruct.numshapes = 2;
i = 3;
break;
case 'إ':
paramcharstruct.basechar = 'ﻹ';
paramcharstruct.numshapes = 2;
i = 3;
break;
case 'آ':
paramcharstruct.basechar = 'ﻵ';
paramcharstruct.numshapes = 2;
i = 3;
break;
}
break;
case '\000':
paramcharstruct.basechar = paramChar;
paramcharstruct.numshapes = shapecount(paramChar);
i = 1;
break;
}
return i;
}
static void copycstostring(StringBuffer paramStringBuffer, charstruct paramcharstruct, int paramInt) {
if (paramcharstruct.basechar == '\000')
return;
paramStringBuffer.append(paramcharstruct.basechar);
paramcharstruct.lignum--;
if (paramcharstruct.mark1 != '\000')
if ((paramInt & 0x1) == 0) {
paramStringBuffer.append(paramcharstruct.mark1);
paramcharstruct.lignum--;
} else {
paramcharstruct.lignum--;
}
if (paramcharstruct.vowel != '\000')
if ((paramInt & 0x1) == 0) {
paramStringBuffer.append(paramcharstruct.vowel);
paramcharstruct.lignum--;
} else {
paramcharstruct.lignum--;
}
}
static void doublelig(StringBuffer paramStringBuffer, int paramInt) {
int i = paramStringBuffer.length();
int j = i;
int k = 0;
for (int m = 1; m < j; m++) {
int n = 0;
if ((paramInt & 0x4) != 0)
switch (paramStringBuffer.charAt(k)) {
case 'ّ':
switch (paramStringBuffer.charAt(m)) {
case 'ِ':
n = 64610;
break;
case 'َ':
n = 64608;
break;
case 'ُ':
n = 64609;
break;
case 'ٌ':
n = 64606;
break;
case 'ٍ':
n = 64607;
break;
}
break;
case 'ِ':
if (paramStringBuffer.charAt(m) == 'ّ')
n = 64610;
break;
case 'َ':
if (paramStringBuffer.charAt(m) == 'ّ')
n = 64608;
break;
case 'ُ':
if (paramStringBuffer.charAt(m) == 'ّ')
n = 64609;
break;
}
if ((paramInt & 0x8) != 0)
switch (paramStringBuffer.charAt(k)) {
case 'ﻟ':
switch (paramStringBuffer.charAt(m)) {
case 'ﺞ':
n = 64575;
break;
case 'ﺠ':
n = 64713;
break;
case 'ﺢ':
n = 64576;
break;
case 'ﺤ':
n = 64714;
break;
case 'ﺦ':
n = 64577;
break;
case 'ﺨ':
n = 64715;
break;
case 'ﻢ':
n = 64578;
break;
case 'ﻤ':
n = 64716;
break;
}
break;
case 'ﺗ':
switch (paramStringBuffer.charAt(m)) {
case 'ﺠ':
n = 64673;
break;
case 'ﺤ':
n = 64674;
break;
case 'ﺨ':
n = 64675;
break;
}
break;
case 'ﺑ':
switch (paramStringBuffer.charAt(m)) {
case 'ﺠ':
n = 64668;
break;
case 'ﺤ':
n = 64669;
break;
case 'ﺨ':
n = 64670;
break;
}
break;
case 'ﻧ':
switch (paramStringBuffer.charAt(m)) {
case 'ﺠ':
n = 64722;
break;
case 'ﺤ':
n = 64723;
break;
case 'ﺨ':
n = 64724;
break;
}
break;
case 'ﻨ':
switch (paramStringBuffer.charAt(m)) {
case 'ﺮ':
n = 64650;
break;
case 'ﺰ':
n = 64651;
break;
}
break;
case 'ﻣ':
switch (paramStringBuffer.charAt(m)) {
case 'ﺠ':
n = 64718;
break;
case 'ﺤ':
n = 64719;
break;
case 'ﺨ':
n = 64720;
break;
case 'ﻤ':
n = 64721;
break;
}
break;
case 'ﻓ':
switch (paramStringBuffer.charAt(m)) {
case 'ﻲ':
n = 64562;
break;
}
break;
}
if (n != 0) {
paramStringBuffer.setCharAt(k, n);
i--;
m++;
continue;
}
paramStringBuffer.setCharAt(++k, paramStringBuffer.charAt(m));
}
paramStringBuffer.setLength(i);
}
static boolean connects_to_left(charstruct paramcharstruct) {
return (paramcharstruct.numshapes > 2);
}
static void shape(char[] paramArrayOfchar, StringBuffer paramStringBuffer, int paramInt) {
int i;
int j = 0;
charstruct charstruct1 = new charstruct();
charstruct charstruct2 = new charstruct();
while (j < paramArrayOfchar.length) {
char c = paramArrayOfchar[j++];
int k = ligature(c, charstruct2);
if (k == 0) {
int m = shapecount(c);
if (m == 1) {
i = 0;
} else {
i = 2;
}
if (connects_to_left(charstruct1))
i++;
i %= charstruct2.numshapes;
charstruct2.basechar = charshape(charstruct2.basechar, i);
copycstostring(paramStringBuffer, charstruct1, paramInt);
charstruct1 = charstruct2;
charstruct2 = new charstruct();
charstruct2.basechar = c;
charstruct2.numshapes = m;
charstruct2.lignum++;
continue;
}
if (k == 1);
}
if (connects_to_left(charstruct1)) {
i = 1;
} else {
i = 0;
}
i %= charstruct2.numshapes;
charstruct2.basechar = charshape(charstruct2.basechar, i);
copycstostring(paramStringBuffer, charstruct1, paramInt);
copycstostring(paramStringBuffer, charstruct2, paramInt);
}
static int arabic_shape(char[] paramArrayOfchar1, int paramInt1, int paramInt2, char[] paramArrayOfchar2, int paramInt3, int paramInt4, int paramInt5) {
char[] arrayOfChar = new char[paramInt2];
for (int i = paramInt2 + paramInt1 - 1; i >= paramInt1; i--)
arrayOfChar[i - paramInt1] = paramArrayOfchar1[i];
StringBuffer stringBuffer = new StringBuffer(paramInt2);
shape(arrayOfChar, stringBuffer, paramInt5);
if ((paramInt5 & 0xC) != 0)
doublelig(stringBuffer, paramInt5);
System.arraycopy(stringBuffer.toString().toCharArray(), 0, paramArrayOfchar2, paramInt3, stringBuffer.length());
return stringBuffer.length();
}
static void processNumbers(char[] paramArrayOfchar, int paramInt1, int paramInt2, int paramInt3) {
int i = paramInt1 + paramInt2;
if ((paramInt3 & 0xE0) != 0) {
int k;
int m;
int n;
int j = 48;
switch (paramInt3 & 0x100) {
case 0:
j = 1632;
break;
case 256:
j = 1776;
break;
}
switch (paramInt3 & 0xE0) {
case 32:
k = j - 48;
for (m = paramInt1; m < i; m++) {
char c = paramArrayOfchar[m];
if (c <= '9' && c >= '0')
paramArrayOfchar[m] = (char)(paramArrayOfchar[m] + k);
}
break;
case 64:
k = (char)(j + 9);
m = 48 - j;
for (n = paramInt1; n < i; n++) {
char c = paramArrayOfchar[n];
if (c <= k && c >= j)
paramArrayOfchar[n] = (char)(paramArrayOfchar[n] + m);
}
break;
case 96:
shapeToArabicDigitsWithContext(paramArrayOfchar, 0, paramInt2, j, false);
break;
case 128:
shapeToArabicDigitsWithContext(paramArrayOfchar, 0, paramInt2, j, true);
break;
}
}
}
static void shapeToArabicDigitsWithContext(char[] paramArrayOfchar, int paramInt1, int paramInt2, char paramChar, boolean paramBoolean) {
paramChar = (char)(paramChar - 48);
int i = paramInt1 + paramInt2;
for (int j = paramInt1; j < i; j++) {
char c = paramArrayOfchar[j];
switch (BidiOrder.getDirection(c)) {
case 0:
case 3:
paramBoolean = false;
break;
case 4:
paramBoolean = true;
break;
case 8:
if (paramBoolean && c <= '9')
paramArrayOfchar[j] = (char)(c + paramChar);
break;
}
}
}
static class charstruct {
char basechar;
char mark1;
char vowel;
int lignum;
int numshapes = 1;
}
}

View file

@ -0,0 +1,58 @@
package com.lowagie.text.pdf;
import java.awt.Font;
public class AsianFontMapper extends DefaultFontMapper {
public static final String ChineseSimplifiedFont = "STSong-Light";
public static final String ChineseSimplifiedEncoding_H = "UniGB-UCS2-H";
public static final String ChineseSimplifiedEncoding_V = "UniGB-UCS2-V";
public static final String ChineseTraditionalFont_MHei = "MHei-Medium";
public static final String ChineseTraditionalFont_MSung = "MSung-Light";
public static final String ChineseTraditionalEncoding_H = "UniCNS-UCS2-H";
public static final String ChineseTraditionalEncoding_V = "UniCNS-UCS2-V";
public static final String JapaneseFont_Go = "HeiseiKakuGo-W5";
public static final String JapaneseFont_Min = "HeiseiMin-W3";
public static final String JapaneseEncoding_H = "UniJIS-UCS2-H";
public static final String JapaneseEncoding_V = "UniJIS-UCS2-V";
public static final String JapaneseEncoding_HW_H = "UniJIS-UCS2-HW-H";
public static final String JapaneseEncoding_HW_V = "UniJIS-UCS2-HW-V";
public static final String KoreanFont_GoThic = "HYGoThic-Medium";
public static final String KoreanFont_SMyeongJo = "HYSMyeongJo-Medium";
public static final String KoreanEncoding_H = "UniKS-UCS2-H";
public static final String KoreanEncoding_V = "UniKS-UCS2-V";
private final String defaultFont;
private final String encoding;
public AsianFontMapper(String paramString1, String paramString2) {
this.defaultFont = paramString1;
this.encoding = paramString2;
}
public BaseFont awtToPdf(Font paramFont) {
try {
DefaultFontMapper.BaseFontParameters baseFontParameters = getBaseFontParameters(paramFont.getFontName());
return (baseFontParameters != null) ? BaseFont.createFont(baseFontParameters.fontName, baseFontParameters.encoding, baseFontParameters.embedded, baseFontParameters.cached, baseFontParameters.ttfAfm, baseFontParameters.pfb) : BaseFont.createFont(this.defaultFont, this.encoding, true);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

View file

@ -0,0 +1,11 @@
package com.lowagie.text.pdf;
import java.io.IOException;
public class BadPasswordException extends IOException {
private static final long serialVersionUID = -4333706268155063964L;
public BadPasswordException() {
super("Bad user Password");
}
}

View file

@ -0,0 +1,11 @@
package com.lowagie.text.pdf;
public class BadPdfFormatException extends PdfException {
private static final long serialVersionUID = 1802317735708833538L;
BadPdfFormatException() {}
BadPdfFormatException(String paramString) {
super(paramString);
}
}

View file

@ -0,0 +1,213 @@
package com.lowagie.text.pdf;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.Image;
import com.lowagie.text.Rectangle;
import java.awt.Color;
public abstract class Barcode {
public static final int EAN13 = 1;
public static final int EAN8 = 2;
public static final int UPCA = 3;
public static final int UPCE = 4;
public static final int SUPP2 = 5;
public static final int SUPP5 = 6;
public static final int POSTNET = 7;
public static final int PLANET = 8;
public static final int CODE128 = 9;
public static final int CODE128_UCC = 10;
public static final int CODE128_RAW = 11;
public static final int CODABAR = 12;
protected float x;
protected float n;
protected BaseFont font;
protected float size;
protected float baseline;
protected float barHeight;
protected int textAlignment;
protected boolean generateChecksum;
protected boolean checksumText;
protected boolean startStopText;
protected boolean extended;
protected String code = "";
protected boolean guardBars;
protected int codeType;
protected float inkSpreading = 0.0F;
protected String altText;
public float getX() {
return this.x;
}
public void setX(float paramFloat) {
this.x = paramFloat;
}
public float getN() {
return this.n;
}
public void setN(float paramFloat) {
this.n = paramFloat;
}
public BaseFont getFont() {
return this.font;
}
public void setFont(BaseFont paramBaseFont) {
this.font = paramBaseFont;
}
public float getSize() {
return this.size;
}
public void setSize(float paramFloat) {
this.size = paramFloat;
}
public float getBaseline() {
return this.baseline;
}
public void setBaseline(float paramFloat) {
this.baseline = paramFloat;
}
public float getBarHeight() {
return this.barHeight;
}
public void setBarHeight(float paramFloat) {
this.barHeight = paramFloat;
}
public int getTextAlignment() {
return this.textAlignment;
}
public void setTextAlignment(int paramInt) {
this.textAlignment = paramInt;
}
public boolean isGenerateChecksum() {
return this.generateChecksum;
}
public void setGenerateChecksum(boolean paramBoolean) {
this.generateChecksum = paramBoolean;
}
public boolean isChecksumText() {
return this.checksumText;
}
public void setChecksumText(boolean paramBoolean) {
this.checksumText = paramBoolean;
}
public boolean isStartStopText() {
return this.startStopText;
}
public void setStartStopText(boolean paramBoolean) {
this.startStopText = paramBoolean;
}
public boolean isExtended() {
return this.extended;
}
public void setExtended(boolean paramBoolean) {
this.extended = paramBoolean;
}
public String getCode() {
return this.code;
}
public void setCode(String paramString) {
this.code = paramString;
}
public boolean isGuardBars() {
return this.guardBars;
}
public void setGuardBars(boolean paramBoolean) {
this.guardBars = paramBoolean;
}
public int getCodeType() {
return this.codeType;
}
public void setCodeType(int paramInt) {
this.codeType = paramInt;
}
public abstract Rectangle getBarcodeSize();
public abstract Rectangle placeBarcode(PdfContentByte paramPdfContentByte, Color paramColor1, Color paramColor2);
public PdfTemplate createTemplateWithBarcode(PdfContentByte paramPdfContentByte, Color paramColor1, Color paramColor2) {
PdfTemplate pdfTemplate = paramPdfContentByte.createTemplate(0.0F, 0.0F);
Rectangle rectangle = placeBarcode(pdfTemplate, paramColor1, paramColor2);
pdfTemplate.setBoundingBox(rectangle);
return pdfTemplate;
}
public Image createImageWithBarcode(PdfContentByte paramPdfContentByte, Color paramColor1, Color paramColor2) {
try {
return Image.getInstance(createTemplateWithBarcode(paramPdfContentByte, paramColor1, paramColor2));
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
public abstract java.awt.Image createAwtImage(Color paramColor1, Color paramColor2);
public float getInkSpreading() {
return this.inkSpreading;
}
public void setInkSpreading(float paramFloat) {
this.inkSpreading = paramFloat;
}
public String getAltText() {
return this.altText;
}
public void setAltText(String paramString) {
this.altText = paramString;
}
}

View file

@ -0,0 +1,554 @@
package com.lowagie.text.pdf;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.Rectangle;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Image;
import java.awt.image.MemoryImageSource;
public class Barcode128 extends Barcode {
private static final byte[][] BARS = new byte[][] {
new byte[] { 2, 1, 2, 2, 2, 2 }, new byte[] { 2, 2, 2, 1, 2, 2 }, new byte[] { 2, 2, 2, 2, 2, 1 }, new byte[] { 1, 2, 1, 2, 2, 3 }, new byte[] { 1, 2, 1, 3, 2, 2 }, new byte[] { 1, 3, 1, 2, 2, 2 }, new byte[] { 1, 2, 2, 2, 1, 3 }, new byte[] { 1, 2, 2, 3, 1, 2 }, new byte[] { 1, 3, 2, 2, 1, 2 }, new byte[] { 2, 2, 1, 2, 1, 3 },
new byte[] { 2, 2, 1, 3, 1, 2 }, new byte[] { 2, 3, 1, 2, 1, 2 }, new byte[] { 1, 1, 2, 2, 3, 2 }, new byte[] { 1, 2, 2, 1, 3, 2 }, new byte[] { 1, 2, 2, 2, 3, 1 }, new byte[] { 1, 1, 3, 2, 2, 2 }, new byte[] { 1, 2, 3, 1, 2, 2 }, new byte[] { 1, 2, 3, 2, 2, 1 }, new byte[] { 2, 2, 3, 2, 1, 1 }, new byte[] { 2, 2, 1, 1, 3, 2 },
new byte[] { 2, 2, 1, 2, 3, 1 }, new byte[] { 2, 1, 3, 2, 1, 2 }, new byte[] { 2, 2, 3, 1, 1, 2 }, new byte[] { 3, 1, 2, 1, 3, 1 }, new byte[] { 3, 1, 1, 2, 2, 2 }, new byte[] { 3, 2, 1, 1, 2, 2 }, new byte[] { 3, 2, 1, 2, 2, 1 }, new byte[] { 3, 1, 2, 2, 1, 2 }, new byte[] { 3, 2, 2, 1, 1, 2 }, new byte[] { 3, 2, 2, 2, 1, 1 },
new byte[] { 2, 1, 2, 1, 2, 3 }, new byte[] { 2, 1, 2, 3, 2, 1 }, new byte[] { 2, 3, 2, 1, 2, 1 }, new byte[] { 1, 1, 1, 3, 2, 3 }, new byte[] { 1, 3, 1, 1, 2, 3 }, new byte[] { 1, 3, 1, 3, 2, 1 }, new byte[] { 1, 1, 2, 3, 1, 3 }, new byte[] { 1, 3, 2, 1, 1, 3 }, new byte[] { 1, 3, 2, 3, 1, 1 }, new byte[] { 2, 1, 1, 3, 1, 3 },
new byte[] { 2, 3, 1, 1, 1, 3 }, new byte[] { 2, 3, 1, 3, 1, 1 }, new byte[] { 1, 1, 2, 1, 3, 3 }, new byte[] { 1, 1, 2, 3, 3, 1 }, new byte[] { 1, 3, 2, 1, 3, 1 }, new byte[] { 1, 1, 3, 1, 2, 3 }, new byte[] { 1, 1, 3, 3, 2, 1 }, new byte[] { 1, 3, 3, 1, 2, 1 }, new byte[] { 3, 1, 3, 1, 2, 1 }, new byte[] { 2, 1, 1, 3, 3, 1 },
new byte[] { 2, 3, 1, 1, 3, 1 }, new byte[] { 2, 1, 3, 1, 1, 3 }, new byte[] { 2, 1, 3, 3, 1, 1 }, new byte[] { 2, 1, 3, 1, 3, 1 }, new byte[] { 3, 1, 1, 1, 2, 3 }, new byte[] { 3, 1, 1, 3, 2, 1 }, new byte[] { 3, 3, 1, 1, 2, 1 }, new byte[] { 3, 1, 2, 1, 1, 3 }, new byte[] { 3, 1, 2, 3, 1, 1 }, new byte[] { 3, 3, 2, 1, 1, 1 },
new byte[] { 3, 1, 4, 1, 1, 1 }, new byte[] { 2, 2, 1, 4, 1, 1 }, new byte[] { 4, 3, 1, 1, 1, 1 }, new byte[] { 1, 1, 1, 2, 2, 4 }, new byte[] { 1, 1, 1, 4, 2, 2 }, new byte[] { 1, 2, 1, 1, 2, 4 }, new byte[] { 1, 2, 1, 4, 2, 1 }, new byte[] { 1, 4, 1, 1, 2, 2 }, new byte[] { 1, 4, 1, 2, 2, 1 }, new byte[] { 1, 1, 2, 2, 1, 4 },
new byte[] { 1, 1, 2, 4, 1, 2 }, new byte[] { 1, 2, 2, 1, 1, 4 }, new byte[] { 1, 2, 2, 4, 1, 1 }, new byte[] { 1, 4, 2, 1, 1, 2 }, new byte[] { 1, 4, 2, 2, 1, 1 }, new byte[] { 2, 4, 1, 2, 1, 1 }, new byte[] { 2, 2, 1, 1, 1, 4 }, new byte[] { 4, 1, 3, 1, 1, 1 }, new byte[] { 2, 4, 1, 1, 1, 2 }, new byte[] { 1, 3, 4, 1, 1, 1 },
new byte[] { 1, 1, 1, 2, 4, 2 }, new byte[] { 1, 2, 1, 1, 4, 2 }, new byte[] { 1, 2, 1, 2, 4, 1 }, new byte[] { 1, 1, 4, 2, 1, 2 }, new byte[] { 1, 2, 4, 1, 1, 2 }, new byte[] { 1, 2, 4, 2, 1, 1 }, new byte[] { 4, 1, 1, 2, 1, 2 }, new byte[] { 4, 2, 1, 1, 1, 2 }, new byte[] { 4, 2, 1, 2, 1, 1 }, new byte[] { 2, 1, 2, 1, 4, 1 },
new byte[] { 2, 1, 4, 1, 2, 1 }, new byte[] { 4, 1, 2, 1, 2, 1 }, new byte[] { 1, 1, 1, 1, 4, 3 }, new byte[] { 1, 1, 1, 3, 4, 1 }, new byte[] { 1, 3, 1, 1, 4, 1 }, new byte[] { 1, 1, 4, 1, 1, 3 }, new byte[] { 1, 1, 4, 3, 1, 1 }, new byte[] { 4, 1, 1, 1, 1, 3 }, new byte[] { 4, 1, 1, 3, 1, 1 }, new byte[] { 1, 1, 3, 1, 4, 1 },
new byte[] { 1, 1, 4, 1, 3, 1 }, new byte[] { 3, 1, 1, 1, 4, 1 }, new byte[] { 4, 1, 1, 1, 3, 1 }, new byte[] { 2, 1, 1, 4, 1, 2 }, new byte[] { 2, 1, 1, 2, 1, 4 }, new byte[] { 2, 1, 1, 2, 3, 2 } };
private static final byte[] BARS_STOP = new byte[] { 2, 3, 3, 1, 1, 1, 2 };
public static final char CODE_AB_TO_C = 'c';
public static final char CODE_AC_TO_B = 'd';
public static final char CODE_BC_TO_A = 'e';
public static final char FNC1_INDEX = 'f';
public static final char START_A = 'g';
public static final char START_B = 'h';
public static final char START_C = 'i';
public static final char FNC1 = 'Ê';
public static final char DEL = 'Ã';
public static final char FNC3 = 'Ä';
public static final char FNC2 = 'Å';
public static final char SHIFT = 'Æ';
public static final char CODE_C = 'Ç';
public static final char CODE_A = 'È';
public static final char FNC4 = 'È';
public static final char STARTA = 'Ë';
public static final char STARTB = 'Ì';
public static final char STARTC = 'Í';
private static final IntHashtable ais = new IntHashtable();
public Barcode128() {
try {
this.x = 0.8F;
this.font = BaseFont.createFont("Helvetica", "winansi", false);
this.size = 8.0F;
this.baseline = this.size;
this.barHeight = this.size * 3.0F;
this.textAlignment = 1;
this.codeType = 9;
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
public static String removeFNC1(String paramString) {
int i = paramString.length();
StringBuffer stringBuffer = new StringBuffer(i);
for (int j = 0; j < i; j++) {
char c = paramString.charAt(j);
if (c >= ' ' && c <= '~')
stringBuffer.append(c);
}
return stringBuffer.toString();
}
public static String getHumanReadableUCCEAN(String paramString) {
StringBuffer stringBuffer = new StringBuffer();
String str = String.valueOf('Ê');
try {
while (true) {
while (paramString.startsWith(str))
paramString = paramString.substring(1);
int i = 0;
int j = 0;
int k;
for (k = 2; k < 5 && paramString.length() >= k; k++) {
if ((i = ais.get(Integer.parseInt(paramString.substring(0, k)))) != 0) {
j = k;
break;
}
}
if (j == 0)
break;
stringBuffer.append('(').append(paramString.substring(0, j)).append(')');
paramString = paramString.substring(j);
if (i > 0) {
i -= j;
if (paramString.length() <= i)
break;
stringBuffer.append(removeFNC1(paramString.substring(0, i)));
paramString = paramString.substring(i);
continue;
}
k = paramString.indexOf('Ê');
if (k < 0)
break;
stringBuffer.append(paramString.substring(0, k));
paramString = paramString.substring(k + 1);
}
} catch (Exception e) {}
stringBuffer.append(removeFNC1(paramString));
return stringBuffer.toString();
}
static boolean isNextDigits(String paramString, int paramInt1, int paramInt2) {
int i = paramString.length();
while (paramInt1 < i && paramInt2 > 0) {
if (paramString.charAt(paramInt1) == 'Ê') {
paramInt1++;
continue;
}
int j = Math.min(2, paramInt2);
if (paramInt1 + j > i)
return false;
while (j-- > 0) {
char c = paramString.charAt(paramInt1++);
if (c < '0' || c > '9')
return false;
paramInt2--;
}
}
return (paramInt2 == 0);
}
static String getPackedRawDigits(String paramString, int paramInt1, int paramInt2) {
String str = "";
int i = paramInt1;
while (paramInt2 > 0) {
if (paramString.charAt(paramInt1) == 'Ê') {
str = str + 'f';
paramInt1++;
continue;
}
paramInt2 -= 2;
int j = paramString.charAt(paramInt1++) - 48;
int k = paramString.charAt(paramInt1++) - 48;
str = str + (char)(j * 10 + k);
}
return (char)(paramInt1 - i) + str;
}
public static String getRawText(String paramString, boolean paramBoolean) {
String str = "";
int i = paramString.length();
if (i == 0) {
str = str + 'h';
if (paramBoolean)
str = str + 'f';
return str;
}
int j = 0;
int k;
for (k = 0; k < i; k++) {
j = paramString.charAt(k);
if (j > 127 && j != 202)
throw new RuntimeException("There are illegal characters for barcode 128 in '" + paramString + "'.");
}
j = paramString.charAt(0);
k = 104;
int m = 0;
if (isNextDigits(paramString, m, 2)) {
k = 105;
str = str + k;
if (paramBoolean)
str = str + 'f';
String str1 = getPackedRawDigits(paramString, m, 2);
m += str1.charAt(0);
str = str + str1.substring(1);
} else if (j < 32) {
k = 103;
str = str + k;
if (paramBoolean)
str = str + 'f';
str = str + (char)(j + 64);
m++;
} else {
str = str + k;
if (paramBoolean)
str = str + 'f';
if (j == 202) {
str = str + 'f';
} else {
str = str + (char)(j - 32);
}
m++;
}
while (m < i) {
switch (k) {
case 103:
if (isNextDigits(paramString, m, 4)) {
k = 105;
str = str + 'c';
String str1 = getPackedRawDigits(paramString, m, 4);
m += str1.charAt(0);
str = str + str1.substring(1);
continue;
}
j = paramString.charAt(m++);
if (j == 202) {
str = str + 'f';
continue;
}
if (j > 95) {
k = 104;
str = str + 'd';
str = str + (char)(j - 32);
continue;
}
if (j < 32) {
str = str + (char)(j + 64);
continue;
}
str = str + (char)(j - 32);
case 104:
if (isNextDigits(paramString, m, 4)) {
k = 105;
str = str + 'c';
String str1 = getPackedRawDigits(paramString, m, 4);
m += str1.charAt(0);
str = str + str1.substring(1);
continue;
}
j = paramString.charAt(m++);
if (j == 202) {
str = str + 'f';
continue;
}
if (j < 32) {
k = 103;
str = str + 'e';
str = str + (char)(j + 64);
continue;
}
str = str + (char)(j - 32);
case 105:
if (isNextDigits(paramString, m, 2)) {
String str1 = getPackedRawDigits(paramString, m, 2);
m += str1.charAt(0);
str = str + str1.substring(1);
continue;
}
j = paramString.charAt(m++);
if (j == 202) {
str = str + 'f';
continue;
}
if (j < 32) {
k = 103;
str = str + 'e';
str = str + (char)(j + 64);
continue;
}
k = 104;
str = str + 'd';
str = str + (char)(j - 32);
}
}
return str;
}
public static byte[] getBarsCode128Raw(String paramString) {
int i = paramString.indexOf(Character.MAX_VALUE);
if (i >= 0)
paramString = paramString.substring(0, i);
int j = paramString.charAt(0);
for (int k = 1; k < paramString.length(); k++)
j = j + k * paramString.charAt(k);
j %= 103;
paramString = paramString + (char)j;
byte[] arrayOfByte = new byte[(paramString.length() + 1) * 6 + 7];
int m;
for (m = 0; m < paramString.length(); m++)
System.arraycopy(BARS[paramString.charAt(m)], 0, arrayOfByte, m * 6, 6);
System.arraycopy(BARS_STOP, 0, arrayOfByte, m * 6, 7);
return arrayOfByte;
}
public Rectangle getBarcodeSize() {
String str;
float f1 = 0.0F;
float f2 = 0.0F;
if (this.font != null) {
if (this.baseline > 0.0F) {
f2 = this.baseline - this.font.getFontDescriptor(3, this.size);
} else {
f2 = -this.baseline + this.size;
}
if (this.codeType == 11) {
int j = this.code.indexOf(Character.MAX_VALUE);
if (j < 0) {
str = "";
} else {
str = this.code.substring(j + 1);
}
} else if (this.codeType == 10) {
str = getHumanReadableUCCEAN(this.code);
} else {
str = removeFNC1(this.code);
}
f1 = this.font.getWidthPoint((this.altText != null) ? this.altText : str, this.size);
}
if (this.codeType == 11) {
int j = this.code.indexOf(Character.MAX_VALUE);
if (j >= 0) {
str = this.code.substring(0, j);
} else {
str = this.code;
}
} else {
str = getRawText(this.code, (this.codeType == 10));
}
int i = str.length();
float f3 = (float)((i + 2) * 11) * this.x + 2.0F * this.x;
f3 = Math.max(f3, f1);
float f4 = this.barHeight + f2;
return new Rectangle(f3, f4);
}
public Rectangle placeBarcode(PdfContentByte paramPdfContentByte, Color paramColor1, Color paramColor2) {
String str1;
String str2;
if (this.codeType == 11) {
int k = this.code.indexOf(Character.MAX_VALUE);
if (k < 0) {
str1 = "";
} else {
str1 = this.code.substring(k + 1);
}
} else if (this.codeType == 10) {
str1 = getHumanReadableUCCEAN(this.code);
} else {
str1 = removeFNC1(this.code);
}
float f1 = 0.0F;
if (this.font != null)
f1 = this.font.getWidthPoint(str1 = (this.altText != null) ? this.altText : str1, this.size);
if (this.codeType == 11) {
int k = this.code.indexOf(Character.MAX_VALUE);
if (k >= 0) {
str2 = this.code.substring(0, k);
} else {
str2 = this.code;
}
} else {
str2 = getRawText(this.code, (this.codeType == 10));
}
int i = str2.length();
float f2 = (float)((i + 2) * 11) * this.x + 2.0F * this.x;
float f3 = 0.0F;
float f4 = 0.0F;
switch (this.textAlignment) {
case 0:
break;
case 2:
if (f1 > f2) {
f3 = f1 - f2;
} else {
f4 = f2 - f1;
}
break;
default:
if (f1 > f2) {
f3 = (f1 - f2) / 2.0F;
} else {
f4 = (f2 - f1) / 2.0F;
}
break;
}
float f5 = 0.0F;
float f6 = 0.0F;
if (this.font != null)
if (this.baseline <= 0.0F) {
f6 = this.barHeight - this.baseline;
} else {
f6 = -this.font.getFontDescriptor(3, this.size);
f5 = f6 + this.baseline;
}
byte[] arrayOfByte = getBarsCode128Raw(str2);
boolean bool = true;
if (paramColor1 != null)
paramPdfContentByte.setColorFill(paramColor1);
for (int j = 0; j < arrayOfByte.length; j++) {
float f = (float)arrayOfByte[j] * this.x;
if (bool)
paramPdfContentByte.rectangle(f3, f5, f - this.inkSpreading, this.barHeight);
bool = !bool ? true : false;
f3 += f;
}
paramPdfContentByte.fill();
if (this.font != null) {
if (paramColor2 != null)
paramPdfContentByte.setColorFill(paramColor2);
paramPdfContentByte.beginText();
paramPdfContentByte.setFontAndSize(this.font, this.size);
paramPdfContentByte.setTextMatrix(f4, f6);
paramPdfContentByte.showText(str1);
paramPdfContentByte.endText();
}
return getBarcodeSize();
}
public Image createAwtImage(Color paramColor1, Color paramColor2) {
String str;
int i = paramColor1.getRGB();
int j = paramColor2.getRGB();
Canvas canvas = new Canvas();
if (this.codeType == 11) {
int i4 = this.code.indexOf(Character.MAX_VALUE);
if (i4 >= 0) {
str = this.code.substring(0, i4);
} else {
str = this.code;
}
} else {
str = getRawText(this.code, (this.codeType == 10));
}
int k = str.length();
int m = (k + 2) * 11 + 2;
byte[] arrayOfByte = getBarsCode128Raw(str);
boolean bool = true;
int n = 0;
int i1 = (int)this.barHeight;
int[] arrayOfInt = new int[m * i1];
for (int i3 = 0; i3 < arrayOfByte.length; i3++) {
byte b = arrayOfByte[i3];
int i4 = j;
if (bool)
i4 = i;
bool = !bool ? true : false;
for (int i5 = 0; i5 < b; i5++)
arrayOfInt[n++] = i4;
}
for (int i2 = m; i2 < arrayOfInt.length; i2 += m)
System.arraycopy(arrayOfInt, 0, arrayOfInt, i2, m);
return canvas.createImage(new MemoryImageSource(m, i1, arrayOfInt, 0, m));
}
public void setCode(String paramString) {
if (getCodeType() == 10 && paramString.startsWith("(")) {
int i = 0;
String str = "";
while (i) {
int j = paramString.indexOf(')', i);
if (j < 0)
throw new IllegalArgumentException("Badly formed UCC string: " + paramString);
String str1 = paramString.substring(i + 1, j);
if (str1.length() < 2)
throw new IllegalArgumentException("AI too short: (" + str1 + ")");
int k = Integer.parseInt(str1);
int m = ais.get(k);
if (m == 0)
throw new IllegalArgumentException("AI not found: (" + str1 + ")");
str1 = String.valueOf(k);
if (str1.length() == 1)
str1 = "0" + str1;
i = paramString.indexOf('(', j);
int n = (i < 0) ? paramString.length() : i;
str = str + str1 + paramString.substring(j + 1, n);
if (m < 0) {
if (i >= 0)
str = str + 'Ê';
continue;
}
if (n - j - 1 + str1.length() != m)
throw new IllegalArgumentException("Invalid AI length: (" + str1 + ")");
}
super.setCode(str);
} else {
super.setCode(paramString);
}
}
static {
ais.put(0, 20);
ais.put(1, 16);
ais.put(2, 16);
ais.put(10, -1);
ais.put(11, 9);
ais.put(12, 8);
ais.put(13, 8);
ais.put(15, 8);
ais.put(17, 8);
ais.put(20, 4);
ais.put(21, -1);
ais.put(22, -1);
ais.put(23, -1);
ais.put(240, -1);
ais.put(241, -1);
ais.put(250, -1);
ais.put(251, -1);
ais.put(252, -1);
ais.put(30, -1);
for (int n = 3100; n < 3700; n++)
ais.put(n, 10);
ais.put(37, -1);
for (int m = 3900; m < 3940; m++)
ais.put(m, -1);
ais.put(400, -1);
ais.put(401, -1);
ais.put(402, 20);
ais.put(403, -1);
for (int k = 410; k < 416; k++)
ais.put(k, 16);
ais.put(420, -1);
ais.put(421, -1);
ais.put(422, 6);
ais.put(423, -1);
ais.put(424, 6);
ais.put(425, 6);
ais.put(426, 6);
ais.put(7001, 17);
ais.put(7002, -1);
for (int j = 7030; j < 7040; j++)
ais.put(j, -1);
ais.put(8001, 18);
ais.put(8002, -1);
ais.put(8003, -1);
ais.put(8004, -1);
ais.put(8005, 10);
ais.put(8006, 22);
ais.put(8007, -1);
ais.put(8008, -1);
ais.put(8018, 22);
ais.put(8020, -1);
ais.put(8100, 10);
ais.put(8101, 14);
ais.put(8102, 6);
for (int i = 90; i < 100; i++)
ais.put(i, -1);
}
}

View file

@ -0,0 +1,206 @@
package com.lowagie.text.pdf;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.Rectangle;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Image;
import java.awt.image.MemoryImageSource;
public class Barcode39 extends Barcode {
private static final byte[][] BARS = new byte[][] {
new byte[] { 0, 0, 0, 1, 1, 0, 1, 0, 0 }, new byte[] { 1, 0, 0, 1, 0, 0, 0, 0, 1 }, new byte[] { 0, 0, 1, 1, 0, 0, 0, 0, 1 }, new byte[] { 1, 0, 1, 1, 0, 0, 0, 0, 0 }, new byte[] { 0, 0, 0, 1, 1, 0, 0, 0, 1 }, new byte[] { 1, 0, 0, 1, 1, 0, 0, 0, 0 }, new byte[] { 0, 0, 1, 1, 1, 0, 0, 0, 0 }, new byte[] { 0, 0, 0, 1, 0, 0, 1, 0, 1 }, new byte[] { 1, 0, 0, 1, 0, 0, 1, 0, 0 }, new byte[] { 0, 0, 1, 1, 0, 0, 1, 0, 0 },
new byte[] { 1, 0, 0, 0, 0, 1, 0, 0, 1 }, new byte[] { 0, 0, 1, 0, 0, 1, 0, 0, 1 }, new byte[] { 1, 0, 1, 0, 0, 1, 0, 0, 0 }, new byte[] { 0, 0, 0, 0, 1, 1, 0, 0, 1 }, new byte[] { 1, 0, 0, 0, 1, 1, 0, 0, 0 }, new byte[] { 0, 0, 1, 0, 1, 1, 0, 0, 0 }, new byte[] { 0, 0, 0, 0, 0, 1, 1, 0, 1 }, new byte[] { 1, 0, 0, 0, 0, 1, 1, 0, 0 }, new byte[] { 0, 0, 1, 0, 0, 1, 1, 0, 0 }, new byte[] { 0, 0, 0, 0, 1, 1, 1, 0, 0 },
new byte[] { 1, 0, 0, 0, 0, 0, 0, 1, 1 }, new byte[] { 0, 0, 1, 0, 0, 0, 0, 1, 1 }, new byte[] { 1, 0, 1, 0, 0, 0, 0, 1, 0 }, new byte[] { 0, 0, 0, 0, 1, 0, 0, 1, 1 }, new byte[] { 1, 0, 0, 0, 1, 0, 0, 1, 0 }, new byte[] { 0, 0, 1, 0, 1, 0, 0, 1, 0 }, new byte[] { 0, 0, 0, 0, 0, 0, 1, 1, 1 }, new byte[] { 1, 0, 0, 0, 0, 0, 1, 1, 0 }, new byte[] { 0, 0, 1, 0, 0, 0, 1, 1, 0 }, new byte[] { 0, 0, 0, 0, 1, 0, 1, 1, 0 },
new byte[] { 1, 1, 0, 0, 0, 0, 0, 0, 1 }, new byte[] { 0, 1, 1, 0, 0, 0, 0, 0, 1 }, new byte[] { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, new byte[] { 0, 1, 0, 0, 1, 0, 0, 0, 1 }, new byte[] { 1, 1, 0, 0, 1, 0, 0, 0, 0 }, new byte[] { 0, 1, 1, 0, 1, 0, 0, 0, 0 }, new byte[] { 0, 1, 0, 0, 0, 0, 1, 0, 1 }, new byte[] { 1, 1, 0, 0, 0, 0, 1, 0, 0 }, new byte[] { 0, 1, 1, 0, 0, 0, 1, 0, 0 }, new byte[] { 0, 1, 0, 1, 0, 1, 0, 0, 0 },
new byte[] { 0, 1, 0, 1, 0, 0, 0, 1, 0 }, new byte[] { 0, 1, 0, 0, 0, 1, 0, 1, 0 }, new byte[] { 0, 0, 0, 1, 0, 1, 0, 1, 0 }, new byte[] { 0, 1, 0, 0, 1, 0, 1, 0, 0 } };
private static final String CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*";
private static final String EXTENDED = "%U$A$B$C$D$E$F$G$H$I$J$K$L$M$N$O$P$Q$R$S$T$U$V$W$X$Y$Z%A%B%C%D%E /A/B/C/D/E/F/G/H/I/J/K/L - ./O 0 1 2 3 4 5 6 7 8 9/Z%F%G%H%I%J%V A B C D E F G H I J K L M N O P Q R S T U V W X Y Z%K%L%M%N%O%W+A+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+Z%P%Q%R%S%T";
public Barcode39() {
try {
this.x = 0.8F;
this.n = 2.0F;
this.font = BaseFont.createFont("Helvetica", "winansi", false);
this.size = 8.0F;
this.baseline = this.size;
this.barHeight = this.size * 3.0F;
this.textAlignment = 1;
this.generateChecksum = false;
this.checksumText = false;
this.startStopText = true;
this.extended = false;
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
public static byte[] getBarsCode39(String paramString) {
paramString = "*" + paramString + "*";
byte[] arrayOfByte = new byte[paramString.length() * 10 - 1];
for (int i = 0; i < paramString.length(); i++) {
int j = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*".indexOf(paramString.charAt(i));
if (j < 0)
throw new IllegalArgumentException("The character '" + paramString.charAt(i) + "' is illegal in code 39.");
System.arraycopy(BARS[j], 0, arrayOfByte, i * 10, 9);
}
return arrayOfByte;
}
public static String getCode39Ex(String paramString) {
String str = "";
for (int i = 0; i < paramString.length(); i++) {
char c1 = paramString.charAt(i);
if (c1 > '\u007F')
throw new IllegalArgumentException("The character '" + c1 + "' is illegal in code 39 extended.");
char c2 = "%U$A$B$C$D$E$F$G$H$I$J$K$L$M$N$O$P$Q$R$S$T$U$V$W$X$Y$Z%A%B%C%D%E /A/B/C/D/E/F/G/H/I/J/K/L - ./O 0 1 2 3 4 5 6 7 8 9/Z%F%G%H%I%J%V A B C D E F G H I J K L M N O P Q R S T U V W X Y Z%K%L%M%N%O%W+A+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+Z%P%Q%R%S%T".charAt(c1 * 2);
char c3 = "%U$A$B$C$D$E$F$G$H$I$J$K$L$M$N$O$P$Q$R$S$T$U$V$W$X$Y$Z%A%B%C%D%E /A/B/C/D/E/F/G/H/I/J/K/L - ./O 0 1 2 3 4 5 6 7 8 9/Z%F%G%H%I%J%V A B C D E F G H I J K L M N O P Q R S T U V W X Y Z%K%L%M%N%O%W+A+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+Z%P%Q%R%S%T".charAt(c1 * 2 + 1);
if (c2 != ' ')
str = str + c2;
str = str + c3;
}
return str;
}
static char getChecksum(String paramString) {
int i = 0;
for (int j = 0; j < paramString.length(); j++) {
int k = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*".indexOf(paramString.charAt(j));
if (k < 0)
throw new IllegalArgumentException("The character '" + paramString.charAt(j) + "' is illegal in code 39.");
i += k;
}
return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*".charAt(i % 43);
}
public Rectangle getBarcodeSize() {
float f1 = 0.0F;
float f2 = 0.0F;
String str = this.code;
if (this.extended)
str = getCode39Ex(this.code);
if (this.font != null) {
if (this.baseline > 0.0F) {
f2 = this.baseline - this.font.getFontDescriptor(3, this.size);
} else {
f2 = -this.baseline + this.size;
}
String str1 = this.code;
if (this.generateChecksum && this.checksumText)
str1 = str1 + getChecksum(str);
if (this.startStopText)
str1 = "*" + str1 + "*";
f1 = this.font.getWidthPoint((this.altText != null) ? this.altText : str1, this.size);
}
int i = str.length() + 2;
if (this.generateChecksum)
i++;
float f3 = (float)i * (6.0F * this.x + 3.0F * this.x * this.n) + (float)(i - 1) * this.x;
f3 = Math.max(f3, f1);
float f4 = this.barHeight + f2;
return new Rectangle(f3, f4);
}
public Rectangle placeBarcode(PdfContentByte paramPdfContentByte, Color paramColor1, Color paramColor2) {
String str1 = this.code;
float f1 = 0.0F;
String str2 = this.code;
if (this.extended)
str2 = getCode39Ex(this.code);
if (this.font != null) {
if (this.generateChecksum && this.checksumText)
str1 = str1 + getChecksum(str2);
if (this.startStopText)
str1 = "*" + str1 + "*";
f1 = this.font.getWidthPoint(str1 = (this.altText != null) ? this.altText : str1, this.size);
}
if (this.generateChecksum)
str2 = str2 + getChecksum(str2);
int i = str2.length() + 2;
float f2 = (float)i * (6.0F * this.x + 3.0F * this.x * this.n) + (float)(i - 1) * this.x;
float f3 = 0.0F;
float f4 = 0.0F;
switch (this.textAlignment) {
case 0:
break;
case 2:
if (f1 > f2) {
f3 = f1 - f2;
} else {
f4 = f2 - f1;
}
break;
default:
if (f1 > f2) {
f3 = (f1 - f2) / 2.0F;
} else {
f4 = (f2 - f1) / 2.0F;
}
break;
}
float f5 = 0.0F;
float f6 = 0.0F;
if (this.font != null)
if (this.baseline <= 0.0F) {
f6 = this.barHeight - this.baseline;
} else {
f6 = -this.font.getFontDescriptor(3, this.size);
f5 = f6 + this.baseline;
}
byte[] arrayOfByte = getBarsCode39(str2);
boolean bool = true;
if (paramColor1 != null)
paramPdfContentByte.setColorFill(paramColor1);
for (int j = 0; j < arrayOfByte.length; j++) {
float f = (arrayOfByte[j] == 0) ? this.x : (this.x * this.n);
if (bool)
paramPdfContentByte.rectangle(f3, f5, f - this.inkSpreading, this.barHeight);
bool = !bool ? true : false;
f3 += f;
}
paramPdfContentByte.fill();
if (this.font != null) {
if (paramColor2 != null)
paramPdfContentByte.setColorFill(paramColor2);
paramPdfContentByte.beginText();
paramPdfContentByte.setFontAndSize(this.font, this.size);
paramPdfContentByte.setTextMatrix(f4, f6);
paramPdfContentByte.showText(str1);
paramPdfContentByte.endText();
}
return getBarcodeSize();
}
public Image createAwtImage(Color paramColor1, Color paramColor2) {
int i = paramColor1.getRGB();
int j = paramColor2.getRGB();
Canvas canvas = new Canvas();
String str = this.code;
if (this.extended)
str = getCode39Ex(this.code);
if (this.generateChecksum)
str = str + getChecksum(str);
int k = str.length() + 2;
int m = (int)this.n;
int n = k * (6 + 3 * m) + k - 1;
byte[] arrayOfByte = getBarsCode39(str);
boolean bool = true;
int i1 = 0;
int i2 = (int)this.barHeight;
int[] arrayOfInt = new int[n * i2];
for (int i4 = 0; i4 < arrayOfByte.length; i4++) {
int i5 = (arrayOfByte[i4] == 0) ? 1 : m;
int i6 = j;
if (bool)
i6 = i;
bool = !bool ? true : false;
for (int i7 = 0; i7 < i5; i7++)
arrayOfInt[i1++] = i6;
}
for (int i3 = n; i3 < arrayOfInt.length; i3 += n)
System.arraycopy(arrayOfInt, 0, arrayOfInt, i3, n);
return canvas.createImage(new MemoryImageSource(n, i2, arrayOfInt, 0, n));
}
}

View file

@ -0,0 +1,200 @@
package com.lowagie.text.pdf;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.Rectangle;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Image;
import java.awt.image.MemoryImageSource;
public class BarcodeCodabar extends Barcode {
private static final byte[][] BARS = new byte[][] {
new byte[] { 0, 0, 0, 0, 0, 1, 1 }, new byte[] { 0, 0, 0, 0, 1, 1, 0 }, new byte[] { 0, 0, 0, 1, 0, 0, 1 }, new byte[] { 1, 1, 0, 0, 0, 0, 0 }, new byte[] { 0, 0, 1, 0, 0, 1, 0 }, new byte[] { 1, 0, 0, 0, 0, 1, 0 }, new byte[] { 0, 1, 0, 0, 0, 0, 1 }, new byte[] { 0, 1, 0, 0, 1, 0, 0 }, new byte[] { 0, 1, 1, 0, 0, 0, 0 }, new byte[] { 1, 0, 0, 1, 0, 0, 0 },
new byte[] { 0, 0, 0, 1, 1, 0, 0 }, new byte[] { 0, 0, 1, 1, 0, 0, 0 }, new byte[] { 1, 0, 0, 0, 1, 0, 1 }, new byte[] { 1, 0, 1, 0, 0, 0, 1 }, new byte[] { 1, 0, 1, 0, 1, 0, 0 }, new byte[] { 0, 0, 1, 0, 1, 0, 1 }, new byte[] { 0, 0, 1, 1, 0, 1, 0 }, new byte[] { 0, 1, 0, 1, 0, 0, 1 }, new byte[] { 0, 0, 0, 1, 0, 1, 1 }, new byte[] { 0, 0, 0, 1, 1, 1, 0 } };
private static final String CHARS = "0123456789-$:/.+ABCD";
private static final int START_STOP_IDX = 16;
public BarcodeCodabar() {
try {
this.x = 0.8F;
this.n = 2.0F;
this.font = BaseFont.createFont("Helvetica", "winansi", false);
this.size = 8.0F;
this.baseline = this.size;
this.barHeight = this.size * 3.0F;
this.textAlignment = 1;
this.generateChecksum = false;
this.checksumText = false;
this.startStopText = false;
this.codeType = 12;
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
public static byte[] getBarsCodabar(String paramString) {
paramString = paramString.toUpperCase();
int i = paramString.length();
if (i < 2)
throw new IllegalArgumentException("Codabar must have at least a start and stop character.");
if ("0123456789-$:/.+ABCD".indexOf(paramString.charAt(0)) < 16 || "0123456789-$:/.+ABCD".indexOf(paramString.charAt(i - 1)) < 16)
throw new IllegalArgumentException("Codabar must have one of 'ABCD' as start/stop character.");
byte[] arrayOfByte = new byte[paramString.length() * 8 - 1];
for (int j = 0; j < i; j++) {
int k = "0123456789-$:/.+ABCD".indexOf(paramString.charAt(j));
if (k >= 16 && j > 0 && j < i - 1)
throw new IllegalArgumentException("In codabar, start/stop characters are only allowed at the extremes.");
if (k < 0)
throw new IllegalArgumentException("The character '" + paramString.charAt(j) + "' is illegal in codabar.");
System.arraycopy(BARS[k], 0, arrayOfByte, j * 8, 7);
}
return arrayOfByte;
}
public static String calculateChecksum(String paramString) {
if (paramString.length() < 2)
return paramString;
String str = paramString.toUpperCase();
int i = 0;
int j = str.length();
for (int k = 0; k < j; k++)
i += "0123456789-$:/.+ABCD".indexOf(str.charAt(k));
i = (i + 15) / 16 * 16 - i;
return paramString.substring(0, j - 1) + "0123456789-$:/.+ABCD".charAt(i) + paramString.substring(j - 1);
}
public Rectangle getBarcodeSize() {
float f1 = 0.0F;
float f2 = 0.0F;
String str = this.code;
if (this.generateChecksum && this.checksumText)
str = calculateChecksum(this.code);
if (!this.startStopText)
str = str.substring(1, str.length() - 1);
if (this.font != null) {
if (this.baseline > 0.0F) {
f2 = this.baseline - this.font.getFontDescriptor(3, this.size);
} else {
f2 = -this.baseline + this.size;
}
f1 = this.font.getWidthPoint((this.altText != null) ? this.altText : str, this.size);
}
str = this.code;
if (this.generateChecksum)
str = calculateChecksum(this.code);
byte[] arrayOfByte = getBarsCodabar(str);
int i = 0;
int j;
for (j = 0; j < arrayOfByte.length; j++)
i += arrayOfByte[j];
j = arrayOfByte.length - i;
float f3 = this.x * ((float)j + (float)i * this.n);
f3 = Math.max(f3, f1);
float f4 = this.barHeight + f2;
return new Rectangle(f3, f4);
}
public Rectangle placeBarcode(PdfContentByte paramPdfContentByte, Color paramColor1, Color paramColor2) {
String str = this.code;
if (this.generateChecksum && this.checksumText)
str = calculateChecksum(this.code);
if (!this.startStopText)
str = str.substring(1, str.length() - 1);
float f1 = 0.0F;
if (this.font != null)
f1 = this.font.getWidthPoint(str = (this.altText != null) ? this.altText : str, this.size);
byte[] arrayOfByte = getBarsCodabar(this.generateChecksum ? calculateChecksum(this.code) : this.code);
int i = 0;
int j;
for (j = 0; j < arrayOfByte.length; j++)
i += arrayOfByte[j];
j = arrayOfByte.length - i;
float f2 = this.x * ((float)j + (float)i * this.n);
float f3 = 0.0F;
float f4 = 0.0F;
switch (this.textAlignment) {
case 0:
break;
case 2:
if (f1 > f2) {
f3 = f1 - f2;
} else {
f4 = f2 - f1;
}
break;
default:
if (f1 > f2) {
f3 = (f1 - f2) / 2.0F;
} else {
f4 = (f2 - f1) / 2.0F;
}
break;
}
float f5 = 0.0F;
float f6 = 0.0F;
if (this.font != null)
if (this.baseline <= 0.0F) {
f6 = this.barHeight - this.baseline;
} else {
f6 = -this.font.getFontDescriptor(3, this.size);
f5 = f6 + this.baseline;
}
boolean bool = true;
if (paramColor1 != null)
paramPdfContentByte.setColorFill(paramColor1);
for (int k = 0; k < arrayOfByte.length; k++) {
float f = (arrayOfByte[k] == 0) ? this.x : (this.x * this.n);
if (bool)
paramPdfContentByte.rectangle(f3, f5, f - this.inkSpreading, this.barHeight);
bool = !bool ? true : false;
f3 += f;
}
paramPdfContentByte.fill();
if (this.font != null) {
if (paramColor2 != null)
paramPdfContentByte.setColorFill(paramColor2);
paramPdfContentByte.beginText();
paramPdfContentByte.setFontAndSize(this.font, this.size);
paramPdfContentByte.setTextMatrix(f4, f6);
paramPdfContentByte.showText(str);
paramPdfContentByte.endText();
}
return getBarcodeSize();
}
public Image createAwtImage(Color paramColor1, Color paramColor2) {
int i = paramColor1.getRGB();
int j = paramColor2.getRGB();
Canvas canvas = new Canvas();
String str = this.code;
if (this.generateChecksum && this.checksumText)
str = calculateChecksum(this.code);
if (!this.startStopText)
str = str.substring(1, str.length() - 1);
byte[] arrayOfByte = getBarsCodabar(this.generateChecksum ? calculateChecksum(this.code) : this.code);
int k = 0;
int m;
for (m = 0; m < arrayOfByte.length; m++)
k += arrayOfByte[m];
m = arrayOfByte.length - k;
int n = m + k * (int)this.n;
boolean bool = true;
int i1 = 0;
int i2 = (int)this.barHeight;
int[] arrayOfInt = new int[n * i2];
for (int i4 = 0; i4 < arrayOfByte.length; i4++) {
int i5 = (arrayOfByte[i4] == 0) ? 1 : (int)this.n;
int i6 = j;
if (bool)
i6 = i;
bool = !bool ? true : false;
for (int i7 = 0; i7 < i5; i7++)
arrayOfInt[i1++] = i6;
}
for (int i3 = n; i3 < arrayOfInt.length; i3 += n)
System.arraycopy(arrayOfInt, 0, arrayOfInt, i3, n);
return canvas.createImage(new MemoryImageSource(n, i2, arrayOfInt, 0, n));
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,502 @@
package com.lowagie.text.pdf;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.Rectangle;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Image;
import java.awt.image.MemoryImageSource;
import java.util.Arrays;
public class BarcodeEAN extends Barcode {
private static final int[] GUARD_EMPTY = new int[0];
private static final int[] GUARD_UPCA = new int[] { 0, 2, 4, 6, 28, 30, 52, 54, 56, 58 };
private static final int[] GUARD_EAN13 = new int[] { 0, 2, 28, 30, 56, 58 };
private static final int[] GUARD_EAN8 = new int[] { 0, 2, 20, 22, 40, 42 };
private static final int[] GUARD_UPCE = new int[] { 0, 2, 28, 30, 32 };
private static final float[] TEXTPOS_EAN13 = new float[] {
6.5F, 13.5F, 20.5F, 27.5F, 34.5F, 41.5F, 53.5F, 60.5F, 67.5F, 74.5F,
81.5F, 88.5F };
private static final float[] TEXTPOS_EAN8 = new float[] { 6.5F, 13.5F, 20.5F, 27.5F, 39.5F, 46.5F, 53.5F, 60.5F };
private static final byte[][] BARS = new byte[][] { new byte[] { 3, 2, 1, 1 }, new byte[] { 2, 2, 2, 1 }, new byte[] { 2, 1, 2, 2 }, new byte[] { 1, 4, 1, 1 }, new byte[] { 1, 1, 3, 2 }, new byte[] { 1, 2, 3, 1 }, new byte[] { 1, 1, 1, 4 }, new byte[] { 1, 3, 1, 2 }, new byte[] { 1, 2, 1, 3 }, new byte[] { 3, 1, 1, 2 } };
private static final int TOTALBARS_EAN13 = 59;
private static final int TOTALBARS_EAN8 = 43;
private static final int TOTALBARS_UPCE = 33;
private static final int TOTALBARS_SUPP2 = 13;
private static final int TOTALBARS_SUPP5 = 31;
private static final int ODD = 0;
private static final int EVEN = 1;
private static final byte[][] PARITY13 = new byte[][] { new byte[] { 0, 0, 0, 0, 0, 0 }, new byte[] { 0, 0, 1, 0, 1, 1 }, new byte[] { 0, 0, 1, 1, 0, 1 }, new byte[] { 0, 0, 1, 1, 1, 0 }, new byte[] { 0, 1, 0, 0, 1, 1 }, new byte[] { 0, 1, 1, 0, 0, 1 }, new byte[] { 0, 1, 1, 1, 0, 0 }, new byte[] { 0, 1, 0, 1, 0, 1 }, new byte[] { 0, 1, 0, 1, 1, 0 }, new byte[] { 0, 1, 1, 0, 1, 0 } };
private static final byte[][] PARITY2 = new byte[][] { new byte[] { 0, 0 }, new byte[] { 0, 1 }, new byte[] { 1, 0 }, new byte[] { 1, 1 } };
private static final byte[][] PARITY5 = new byte[][] { new byte[] { 1, 1, 0, 0, 0 }, new byte[] { 1, 0, 1, 0, 0 }, new byte[] { 1, 0, 0, 1, 0 }, new byte[] { 1, 0, 0, 0, 1 }, new byte[] { 0, 1, 1, 0, 0 }, new byte[] { 0, 0, 1, 1, 0 }, new byte[] { 0, 0, 0, 1, 1 }, new byte[] { 0, 1, 0, 1, 0 }, new byte[] { 0, 1, 0, 0, 1 }, new byte[] { 0, 0, 1, 0, 1 } };
private static final byte[][] PARITYE = new byte[][] { new byte[] { 1, 1, 1, 0, 0, 0 }, new byte[] { 1, 1, 0, 1, 0, 0 }, new byte[] { 1, 1, 0, 0, 1, 0 }, new byte[] { 1, 1, 0, 0, 0, 1 }, new byte[] { 1, 0, 1, 1, 0, 0 }, new byte[] { 1, 0, 0, 1, 1, 0 }, new byte[] { 1, 0, 0, 0, 1, 1 }, new byte[] { 1, 0, 1, 0, 1, 0 }, new byte[] { 1, 0, 1, 0, 0, 1 }, new byte[] { 1, 0, 0, 1, 0, 1 } };
public BarcodeEAN() {
try {
this.x = 0.8F;
this.font = BaseFont.createFont("Helvetica", "winansi", false);
this.size = 8.0F;
this.baseline = this.size;
this.barHeight = this.size * 3.0F;
this.guardBars = true;
this.codeType = 1;
this.code = "";
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
public static int calculateEANParity(String paramString) {
int i = 3;
int j = 0;
for (int k = paramString.length() - 1; k >= 0; k--) {
int m = paramString.charAt(k) - 48;
j += i * m;
i ^= 0x2;
}
return (10 - j % 10) % 10;
}
public static String convertUPCAtoUPCE(String paramString) {
if (paramString.length() != 12 || (!paramString.startsWith("0") && !paramString.startsWith("1")))
return null;
if (paramString.substring(3, 6).equals("000") || paramString.substring(3, 6).equals("100") || paramString.substring(3, 6).equals("200")) {
if (paramString.substring(6, 8).equals("00"))
return paramString.substring(0, 1) + paramString.substring(1, 3) + paramString.substring(8, 11) + paramString.substring(3, 4) + paramString.substring(11);
} else if (paramString.substring(4, 6).equals("00")) {
if (paramString.substring(6, 9).equals("000"))
return paramString.substring(0, 1) + paramString.substring(1, 4) + paramString.substring(9, 11) + "3" + paramString.substring(11);
} else if (paramString.substring(5, 6).equals("0")) {
if (paramString.substring(6, 10).equals("0000"))
return paramString.substring(0, 1) + paramString.substring(1, 5) + paramString.substring(10, 11) + "4" + paramString.substring(11);
} else if (paramString.charAt(10) >= '5' && paramString.substring(6, 10).equals("0000")) {
return paramString.substring(0, 1) + paramString.substring(1, 6) + paramString.substring(10, 11) + paramString.substring(11);
}
return null;
}
public static byte[] getBarsEAN13(String paramString) {
int[] arrayOfInt = new int[paramString.length()];
for (int i = 0; i < arrayOfInt.length; i++)
arrayOfInt[i] = paramString.charAt(i) - 48;
byte[] arrayOfByte1 = new byte[59];
int j = 0;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
byte[] arrayOfByte2 = PARITY13[arrayOfInt[0]];
for (int m = 0; m < arrayOfByte2.length; m++) {
int n = arrayOfInt[m + 1];
byte[] arrayOfByte = BARS[n];
if (arrayOfByte2[m] == 0) {
arrayOfByte1[j++] = arrayOfByte[0];
arrayOfByte1[j++] = arrayOfByte[1];
arrayOfByte1[j++] = arrayOfByte[2];
arrayOfByte1[j++] = arrayOfByte[3];
} else {
arrayOfByte1[j++] = arrayOfByte[3];
arrayOfByte1[j++] = arrayOfByte[2];
arrayOfByte1[j++] = arrayOfByte[1];
arrayOfByte1[j++] = arrayOfByte[0];
}
}
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
for (int k = 7; k < 13; k++) {
int n = arrayOfInt[k];
byte[] arrayOfByte = BARS[n];
arrayOfByte1[j++] = arrayOfByte[0];
arrayOfByte1[j++] = arrayOfByte[1];
arrayOfByte1[j++] = arrayOfByte[2];
arrayOfByte1[j++] = arrayOfByte[3];
}
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
return arrayOfByte1;
}
public static byte[] getBarsEAN8(String paramString) {
int[] arrayOfInt = new int[paramString.length()];
for (int i = 0; i < arrayOfInt.length; i++)
arrayOfInt[i] = paramString.charAt(i) - 48;
byte[] arrayOfByte = new byte[43];
int j = 0;
arrayOfByte[j++] = 1;
arrayOfByte[j++] = 1;
arrayOfByte[j++] = 1;
for (int m = 0; m < 4; m++) {
int n = arrayOfInt[m];
byte[] arrayOfByte1 = BARS[n];
arrayOfByte[j++] = arrayOfByte1[0];
arrayOfByte[j++] = arrayOfByte1[1];
arrayOfByte[j++] = arrayOfByte1[2];
arrayOfByte[j++] = arrayOfByte1[3];
}
arrayOfByte[j++] = 1;
arrayOfByte[j++] = 1;
arrayOfByte[j++] = 1;
arrayOfByte[j++] = 1;
arrayOfByte[j++] = 1;
for (int k = 4; k < 8; k++) {
int n = arrayOfInt[k];
byte[] arrayOfByte1 = BARS[n];
arrayOfByte[j++] = arrayOfByte1[0];
arrayOfByte[j++] = arrayOfByte1[1];
arrayOfByte[j++] = arrayOfByte1[2];
arrayOfByte[j++] = arrayOfByte1[3];
}
arrayOfByte[j++] = 1;
arrayOfByte[j++] = 1;
arrayOfByte[j++] = 1;
return arrayOfByte;
}
public static byte[] getBarsUPCE(String paramString) {
int[] arrayOfInt = new int[paramString.length()];
for (int i = 0; i < arrayOfInt.length; i++)
arrayOfInt[i] = paramString.charAt(i) - 48;
byte[] arrayOfByte1 = new byte[33];
boolean bool = (arrayOfInt[0] != 0) ? true : false;
int j = 0;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
byte[] arrayOfByte2 = PARITYE[arrayOfInt[arrayOfInt.length - 1]];
for (int k = 1; k < arrayOfInt.length - 1; k++) {
int m = arrayOfInt[k];
byte[] arrayOfByte = BARS[m];
if (arrayOfByte2[k - 1] == (bool ? 1 : 0)) {
arrayOfByte1[j++] = arrayOfByte[0];
arrayOfByte1[j++] = arrayOfByte[1];
arrayOfByte1[j++] = arrayOfByte[2];
arrayOfByte1[j++] = arrayOfByte[3];
} else {
arrayOfByte1[j++] = arrayOfByte[3];
arrayOfByte1[j++] = arrayOfByte[2];
arrayOfByte1[j++] = arrayOfByte[1];
arrayOfByte1[j++] = arrayOfByte[0];
}
}
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
return arrayOfByte1;
}
public static byte[] getBarsSupplemental2(String paramString) {
int[] arrayOfInt = new int[2];
for (int i = 0; i < arrayOfInt.length; i++)
arrayOfInt[i] = paramString.charAt(i) - 48;
byte[] arrayOfByte1 = new byte[13];
int j = 0;
int k = (arrayOfInt[0] * 10 + arrayOfInt[1]) % 4;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 2;
byte[] arrayOfByte2 = PARITY2[k];
for (int m = 0; m < arrayOfByte2.length; m++) {
if (m == 1) {
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
}
int n = arrayOfInt[m];
byte[] arrayOfByte = BARS[n];
if (arrayOfByte2[m] == 0) {
arrayOfByte1[j++] = arrayOfByte[0];
arrayOfByte1[j++] = arrayOfByte[1];
arrayOfByte1[j++] = arrayOfByte[2];
arrayOfByte1[j++] = arrayOfByte[3];
} else {
arrayOfByte1[j++] = arrayOfByte[3];
arrayOfByte1[j++] = arrayOfByte[2];
arrayOfByte1[j++] = arrayOfByte[1];
arrayOfByte1[j++] = arrayOfByte[0];
}
}
return arrayOfByte1;
}
public static byte[] getBarsSupplemental5(String paramString) {
int[] arrayOfInt = new int[5];
for (int i = 0; i < arrayOfInt.length; i++)
arrayOfInt[i] = paramString.charAt(i) - 48;
byte[] arrayOfByte1 = new byte[31];
int j = 0;
int k = ((arrayOfInt[0] + arrayOfInt[2] + arrayOfInt[4]) * 3 + (arrayOfInt[1] + arrayOfInt[3]) * 9) % 10;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 2;
byte[] arrayOfByte2 = PARITY5[k];
for (int m = 0; m < arrayOfByte2.length; m++) {
if (m != 0) {
arrayOfByte1[j++] = 1;
arrayOfByte1[j++] = 1;
}
int n = arrayOfInt[m];
byte[] arrayOfByte = BARS[n];
if (arrayOfByte2[m] == 0) {
arrayOfByte1[j++] = arrayOfByte[0];
arrayOfByte1[j++] = arrayOfByte[1];
arrayOfByte1[j++] = arrayOfByte[2];
arrayOfByte1[j++] = arrayOfByte[3];
} else {
arrayOfByte1[j++] = arrayOfByte[3];
arrayOfByte1[j++] = arrayOfByte[2];
arrayOfByte1[j++] = arrayOfByte[1];
arrayOfByte1[j++] = arrayOfByte[0];
}
}
return arrayOfByte1;
}
public Rectangle getBarcodeSize() {
float f1 = 0.0F;
float f2 = this.barHeight;
if (this.font != null)
if (this.baseline <= 0.0F) {
f2 += -this.baseline + this.size;
} else {
f2 += this.baseline - this.font.getFontDescriptor(3, this.size);
}
switch (this.codeType) {
case 1:
f1 = this.x * 95.0F;
if (this.font != null)
f1 += this.font.getWidthPoint(this.code.charAt(0), this.size);
break;
case 2:
f1 = this.x * 67.0F;
break;
case 3:
f1 = this.x * 95.0F;
if (this.font != null)
f1 += this.font.getWidthPoint(this.code.charAt(0), this.size) + this.font.getWidthPoint(this.code.charAt(11), this.size);
break;
case 4:
f1 = this.x * 51.0F;
if (this.font != null)
f1 += this.font.getWidthPoint(this.code.charAt(0), this.size) + this.font.getWidthPoint(this.code.charAt(7), this.size);
break;
case 5:
f1 = this.x * 20.0F;
break;
case 6:
f1 = this.x * 47.0F;
break;
default:
throw new RuntimeException("Invalid code type.");
}
return new Rectangle(f1, f2);
}
public Rectangle placeBarcode(PdfContentByte paramPdfContentByte, Color paramColor1, Color paramColor2) {
Rectangle rectangle = getBarcodeSize();
float f1 = 0.0F;
float f2 = 0.0F;
float f3 = 0.0F;
if (this.font != null)
if (this.baseline <= 0.0F) {
f3 = this.barHeight - this.baseline;
} else {
f3 = -this.font.getFontDescriptor(3, this.size);
f2 = f3 + this.baseline;
}
switch (this.codeType) {
case 1:
case 3:
case 4:
if (this.font != null)
f1 += this.font.getWidthPoint(this.code.charAt(0), this.size);
break;
}
byte[] arrayOfByte = null;
int[] arrayOfInt = GUARD_EMPTY;
switch (this.codeType) {
case 1:
arrayOfByte = getBarsEAN13(this.code);
arrayOfInt = GUARD_EAN13;
break;
case 2:
arrayOfByte = getBarsEAN8(this.code);
arrayOfInt = GUARD_EAN8;
break;
case 3:
arrayOfByte = getBarsEAN13("0" + this.code);
arrayOfInt = GUARD_UPCA;
break;
case 4:
arrayOfByte = getBarsUPCE(this.code);
arrayOfInt = GUARD_UPCE;
break;
case 5:
arrayOfByte = getBarsSupplemental2(this.code);
break;
case 6:
arrayOfByte = getBarsSupplemental5(this.code);
break;
}
float f4 = f1;
boolean bool = true;
float f5 = 0.0F;
if (this.font != null && this.baseline > 0.0F && this.guardBars)
f5 = this.baseline / 2.0F;
if (paramColor1 != null)
paramPdfContentByte.setColorFill(paramColor1);
int i;
for (i = 0; i < arrayOfByte.length; i++) {
float f = (float)arrayOfByte[i] * this.x;
if (bool)
if (Arrays.binarySearch(arrayOfInt, i) >= 0) {
paramPdfContentByte.rectangle(f1, f2 - f5, f - this.inkSpreading, this.barHeight + f5);
} else {
paramPdfContentByte.rectangle(f1, f2, f - this.inkSpreading, this.barHeight);
}
bool = !bool ? true : false;
f1 += f;
}
paramPdfContentByte.fill();
if (this.font != null) {
if (paramColor2 != null)
paramPdfContentByte.setColorFill(paramColor2);
paramPdfContentByte.beginText();
paramPdfContentByte.setFontAndSize(this.font, this.size);
switch (this.codeType) {
case 1:
paramPdfContentByte.setTextMatrix(0.0F, f3);
paramPdfContentByte.showText(this.code.substring(0, 1));
for (i = 1; i < 13; i++) {
String str = this.code.substring(i, i + 1);
float f6 = this.font.getWidthPoint(str, this.size);
float f7 = f4 + TEXTPOS_EAN13[i - 1] * this.x - f6 / 2.0F;
paramPdfContentByte.setTextMatrix(f7, f3);
paramPdfContentByte.showText(str);
}
break;
case 2:
for (i = 0; i < 8; i++) {
String str = this.code.substring(i, i + 1);
float f6 = this.font.getWidthPoint(str, this.size);
float f7 = TEXTPOS_EAN8[i] * this.x - f6 / 2.0F;
paramPdfContentByte.setTextMatrix(f7, f3);
paramPdfContentByte.showText(str);
}
break;
case 3:
paramPdfContentByte.setTextMatrix(0.0F, f3);
paramPdfContentByte.showText(this.code.substring(0, 1));
for (i = 1; i < 11; i++) {
String str = this.code.substring(i, i + 1);
float f6 = this.font.getWidthPoint(str, this.size);
float f7 = f4 + TEXTPOS_EAN13[i] * this.x - f6 / 2.0F;
paramPdfContentByte.setTextMatrix(f7, f3);
paramPdfContentByte.showText(str);
}
paramPdfContentByte.setTextMatrix(f4 + this.x * 95.0F, f3);
paramPdfContentByte.showText(this.code.substring(11, 12));
break;
case 4:
paramPdfContentByte.setTextMatrix(0.0F, f3);
paramPdfContentByte.showText(this.code.substring(0, 1));
for (i = 1; i < 7; i++) {
String str = this.code.substring(i, i + 1);
float f6 = this.font.getWidthPoint(str, this.size);
float f7 = f4 + TEXTPOS_EAN13[i - 1] * this.x - f6 / 2.0F;
paramPdfContentByte.setTextMatrix(f7, f3);
paramPdfContentByte.showText(str);
}
paramPdfContentByte.setTextMatrix(f4 + this.x * 51.0F, f3);
paramPdfContentByte.showText(this.code.substring(7, 8));
break;
case 5:
case 6:
for (i = 0; i < this.code.length(); i++) {
String str = this.code.substring(i, i + 1);
float f6 = this.font.getWidthPoint(str, this.size);
float f7 = (7.5F + (float)(9 * i)) * this.x - f6 / 2.0F;
paramPdfContentByte.setTextMatrix(f7, f3);
paramPdfContentByte.showText(str);
}
break;
}
paramPdfContentByte.endText();
}
return rectangle;
}
public Image createAwtImage(Color paramColor1, Color paramColor2) {
int i = paramColor1.getRGB();
int j = paramColor2.getRGB();
Canvas canvas = new Canvas();
int k = 0;
byte[] arrayOfByte = null;
switch (this.codeType) {
case 1:
arrayOfByte = getBarsEAN13(this.code);
k = 95;
break;
case 2:
arrayOfByte = getBarsEAN8(this.code);
k = 67;
break;
case 3:
arrayOfByte = getBarsEAN13("0" + this.code);
k = 95;
break;
case 4:
arrayOfByte = getBarsUPCE(this.code);
k = 51;
break;
case 5:
arrayOfByte = getBarsSupplemental2(this.code);
k = 20;
break;
case 6:
arrayOfByte = getBarsSupplemental5(this.code);
k = 47;
break;
default:
throw new RuntimeException("Invalid code type.");
}
boolean bool = true;
int m = 0;
int n = (int)this.barHeight;
int[] arrayOfInt = new int[k * n];
for (int i2 = 0; i2 < arrayOfByte.length; i2++) {
byte b = arrayOfByte[i2];
int i3 = j;
if (bool)
i3 = i;
bool = !bool ? true : false;
for (int i4 = 0; i4 < b; i4++)
arrayOfInt[m++] = i3;
}
for (int i1 = k; i1 < arrayOfInt.length; i1 += k)
System.arraycopy(arrayOfInt, 0, arrayOfInt, i1, k);
return canvas.createImage(new MemoryImageSource(k, n, arrayOfInt, 0, k));
}
}

View file

@ -0,0 +1,43 @@
package com.lowagie.text.pdf;
import com.lowagie.text.Rectangle;
import java.awt.Color;
import java.awt.Image;
public class BarcodeEANSUPP extends Barcode {
protected Barcode ean;
protected Barcode supp;
public BarcodeEANSUPP(Barcode paramBarcode1, Barcode paramBarcode2) {
this.ean = paramBarcode1;
this.supp = paramBarcode2;
}
public Rectangle getBarcodeSize() {
Rectangle rectangle = this.ean.getBarcodeSize();
rectangle.setRight(rectangle.getWidth() + this.supp.getBarcodeSize().getWidth() + this.n);
return rectangle;
}
public Rectangle placeBarcode(PdfContentByte paramPdfContentByte, Color paramColor1, Color paramColor2) {
if (this.supp.getFont() != null) {
this.supp.setBarHeight(this.ean.getBarHeight() + this.supp.getBaseline() - this.supp.getFont().getFontDescriptor(2, this.supp.getSize()));
} else {
this.supp.setBarHeight(this.ean.getBarHeight());
}
Rectangle rectangle = this.ean.getBarcodeSize();
paramPdfContentByte.saveState();
this.ean.placeBarcode(paramPdfContentByte, paramColor1, paramColor2);
paramPdfContentByte.restoreState();
paramPdfContentByte.saveState();
paramPdfContentByte.concatCTM(1.0F, 0.0F, 0.0F, 1.0F, rectangle.getWidth() + this.n, rectangle.getHeight() - this.ean.getBarHeight());
this.supp.placeBarcode(paramPdfContentByte, paramColor1, paramColor2);
paramPdfContentByte.restoreState();
return getBarcodeSize();
}
public Image createAwtImage(Color paramColor1, Color paramColor2) {
throw new UnsupportedOperationException("The two barcodes must be composed externally.");
}
}

View file

@ -0,0 +1,195 @@
package com.lowagie.text.pdf;
import com.lowagie.text.ExceptionConverter;
import com.lowagie.text.Rectangle;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Image;
import java.awt.image.MemoryImageSource;
public class BarcodeInter25 extends Barcode {
private static final byte[][] BARS = new byte[][] { new byte[] { 0, 0, 1, 1, 0 }, new byte[] { 1, 0, 0, 0, 1 }, new byte[] { 0, 1, 0, 0, 1 }, new byte[] { 1, 1, 0, 0, 0 }, new byte[] { 0, 0, 1, 0, 1 }, new byte[] { 1, 0, 1, 0, 0 }, new byte[] { 0, 1, 1, 0, 0 }, new byte[] { 0, 0, 0, 1, 1 }, new byte[] { 1, 0, 0, 1, 0 }, new byte[] { 0, 1, 0, 1, 0 } };
public BarcodeInter25() {
try {
this.x = 0.8F;
this.n = 2.0F;
this.font = BaseFont.createFont("Helvetica", "winansi", false);
this.size = 8.0F;
this.baseline = this.size;
this.barHeight = this.size * 3.0F;
this.textAlignment = 1;
this.generateChecksum = false;
this.checksumText = false;
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
public static String keepNumbers(String paramString) {
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < paramString.length(); i++) {
char c = paramString.charAt(i);
if (c >= '0' && c <= '9')
stringBuffer.append(c);
}
return stringBuffer.toString();
}
public static char getChecksum(String paramString) {
int i = 3;
int j = 0;
for (int k = paramString.length() - 1; k >= 0; k--) {
int m = paramString.charAt(k) - 48;
j += i * m;
i ^= 0x2;
}
return (char)((10 - j % 10) % 10 + 48);
}
public static byte[] getBarsInter25(String paramString) {
paramString = keepNumbers(paramString);
if ((paramString.length() & 0x1) != 0)
throw new IllegalArgumentException("The text length must be even.");
byte[] arrayOfByte = new byte[paramString.length() * 5 + 7];
int i = 0;
arrayOfByte[i++] = 0;
arrayOfByte[i++] = 0;
arrayOfByte[i++] = 0;
arrayOfByte[i++] = 0;
int j = paramString.length() / 2;
for (int k = 0; k < j; k++) {
int m = paramString.charAt(k * 2) - 48;
int n = paramString.charAt(k * 2 + 1) - 48;
byte[] arrayOfByte1 = BARS[m];
byte[] arrayOfByte2 = BARS[n];
for (int i1 = 0; i1 < 5; i1++) {
arrayOfByte[i++] = arrayOfByte1[i1];
arrayOfByte[i++] = arrayOfByte2[i1];
}
}
arrayOfByte[i++] = 1;
arrayOfByte[i++] = 0;
arrayOfByte[i++] = 0;
return arrayOfByte;
}
public Rectangle getBarcodeSize() {
float f1 = 0.0F;
float f2 = 0.0F;
if (this.font != null) {
if (this.baseline > 0.0F) {
f2 = this.baseline - this.font.getFontDescriptor(3, this.size);
} else {
f2 = -this.baseline + this.size;
}
String str1 = this.code;
if (this.generateChecksum && this.checksumText)
str1 = str1 + getChecksum(str1);
f1 = this.font.getWidthPoint((this.altText != null) ? this.altText : str1, this.size);
}
String str = keepNumbers(this.code);
int i = str.length();
if (this.generateChecksum)
i++;
float f3 = (float)i * (3.0F * this.x + 2.0F * this.x * this.n) + (6.0F + this.n) * this.x;
f3 = Math.max(f3, f1);
float f4 = this.barHeight + f2;
return new Rectangle(f3, f4);
}
public Rectangle placeBarcode(PdfContentByte paramPdfContentByte, Color paramColor1, Color paramColor2) {
String str1 = this.code;
float f1 = 0.0F;
if (this.font != null) {
if (this.generateChecksum && this.checksumText)
str1 = str1 + getChecksum(str1);
f1 = this.font.getWidthPoint(str1 = (this.altText != null) ? this.altText : str1, this.size);
}
String str2 = keepNumbers(this.code);
if (this.generateChecksum)
str2 = str2 + getChecksum(str2);
int i = str2.length();
float f2 = (float)i * (3.0F * this.x + 2.0F * this.x * this.n) + (6.0F + this.n) * this.x;
float f3 = 0.0F;
float f4 = 0.0F;
switch (this.textAlignment) {
case 0:
break;
case 2:
if (f1 > f2) {
f3 = f1 - f2;
} else {
f4 = f2 - f1;
}
break;
default:
if (f1 > f2) {
f3 = (f1 - f2) / 2.0F;
} else {
f4 = (f2 - f1) / 2.0F;
}
break;
}
float f5 = 0.0F;
float f6 = 0.0F;
if (this.font != null)
if (this.baseline <= 0.0F) {
f6 = this.barHeight - this.baseline;
} else {
f6 = -this.font.getFontDescriptor(3, this.size);
f5 = f6 + this.baseline;
}
byte[] arrayOfByte = getBarsInter25(str2);
boolean bool = true;
if (paramColor1 != null)
paramPdfContentByte.setColorFill(paramColor1);
for (int j = 0; j < arrayOfByte.length; j++) {
float f = (arrayOfByte[j] == 0) ? this.x : (this.x * this.n);
if (bool)
paramPdfContentByte.rectangle(f3, f5, f - this.inkSpreading, this.barHeight);
bool = !bool ? true : false;
f3 += f;
}
paramPdfContentByte.fill();
if (this.font != null) {
if (paramColor2 != null)
paramPdfContentByte.setColorFill(paramColor2);
paramPdfContentByte.beginText();
paramPdfContentByte.setFontAndSize(this.font, this.size);
paramPdfContentByte.setTextMatrix(f4, f6);
paramPdfContentByte.showText(str1);
paramPdfContentByte.endText();
}
return getBarcodeSize();
}
public Image createAwtImage(Color paramColor1, Color paramColor2) {
int i = paramColor1.getRGB();
int j = paramColor2.getRGB();
Canvas canvas = new Canvas();
String str = keepNumbers(this.code);
if (this.generateChecksum)
str = str + getChecksum(str);
int k = str.length();
int m = (int)this.n;
int n = k * (3 + 2 * m) + 6 + m;
byte[] arrayOfByte = getBarsInter25(str);
boolean bool = true;
int i1 = 0;
int i2 = (int)this.barHeight;
int[] arrayOfInt = new int[n * i2];
for (int i4 = 0; i4 < arrayOfByte.length; i4++) {
int i5 = (arrayOfByte[i4] == 0) ? 1 : m;
int i6 = j;
if (bool)
i6 = i;
bool = !bool ? true : false;
for (int i7 = 0; i7 < i5; i7++)
arrayOfInt[i1++] = i6;
}
for (int i3 = n; i3 < arrayOfInt.length; i3 += n)
System.arraycopy(arrayOfInt, 0, arrayOfInt, i3, n);
return canvas.createImage(new MemoryImageSource(n, i2, arrayOfInt, 0, n));
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,99 @@
package com.lowagie.text.pdf;
import com.lowagie.text.Rectangle;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Image;
import java.awt.image.MemoryImageSource;
public class BarcodePostnet extends Barcode {
private static final byte[][] BARS = new byte[][] { new byte[] { 1, 1, 0, 0, 0 }, new byte[] { 0, 0, 0, 1, 1 }, new byte[] { 0, 0, 1, 0, 1 }, new byte[] { 0, 0, 1, 1, 0 }, new byte[] { 0, 1, 0, 0, 1 }, new byte[] { 0, 1, 0, 1, 0 }, new byte[] { 0, 1, 1, 0, 0 }, new byte[] { 1, 0, 0, 0, 1 }, new byte[] { 1, 0, 0, 1, 0 }, new byte[] { 1, 0, 1, 0, 0 } };
public static byte[] getBarsPostnet(String paramString) {
int i = 0;
for (int j = paramString.length() - 1; j >= 0; j--) {
int m = paramString.charAt(j) - 48;
i += m;
}
paramString = paramString + (char)((10 - i % 10) % 10 + 48);
byte[] arrayOfByte = new byte[paramString.length() * 5 + 2];
arrayOfByte[0] = 1;
arrayOfByte[arrayOfByte.length - 1] = 1;
for (int k = 0; k < paramString.length(); k++) {
int m = paramString.charAt(k) - 48;
System.arraycopy(BARS[m], 0, arrayOfByte, k * 5 + 1, 5);
}
return arrayOfByte;
}
public Rectangle getBarcodeSize() {
float f = (float)((this.code.length() + 1) * 5 + 1) * this.n + this.x;
return new Rectangle(f, this.barHeight);
}
public Rectangle placeBarcode(PdfContentByte paramPdfContentByte, Color paramColor1, Color paramColor2) {
if (paramColor1 != null)
paramPdfContentByte.setColorFill(paramColor1);
byte[] arrayOfByte = getBarsPostnet(this.code);
boolean bool = true;
if (this.codeType == 8) {
bool = false;
arrayOfByte[0] = 0;
arrayOfByte[arrayOfByte.length - 1] = 0;
}
float f = 0.0F;
for (int i = 0; i < arrayOfByte.length; i++) {
paramPdfContentByte.rectangle(f, 0.0F, this.x - this.inkSpreading, (arrayOfByte[i] == bool) ? this.barHeight : this.size);
f += this.n;
}
paramPdfContentByte.fill();
return getBarcodeSize();
}
public Image createAwtImage(Color paramColor1, Color paramColor2) {
int i = paramColor1.getRGB();
int j = paramColor2.getRGB();
Canvas canvas = new Canvas();
int k = (int)this.x;
if (k <= 0)
k = 1;
int m = (int)this.n;
if (m <= k)
m = k + 1;
int n = (int)this.size;
if (n <= 0)
n = 1;
int i1 = (int)this.barHeight;
if (i1 <= n)
i1 = n + 1;
int i2 = ((this.code.length() + 1) * 5 + 1) * m + k;
int[] arrayOfInt = new int[i2 * i1];
byte[] arrayOfByte = getBarsPostnet(this.code);
boolean bool = true;
if (this.codeType == 8) {
bool = false;
arrayOfByte[0] = 0;
arrayOfByte[arrayOfByte.length - 1] = 0;
}
int i3 = 0;
int i4;
for (i4 = 0; i4 < arrayOfByte.length; i4++) {
boolean bool1 = (arrayOfByte[i4] == bool) ? true : false;
for (int i8 = 0; i8 < m; i8++)
arrayOfInt[i3 + i8] = (bool1 && i8 < k) ? i : j;
i3 += m;
}
i4 = i2 * (i1 - n);
for (int i7 = i2; i7 < i4; i7 += i2)
System.arraycopy(arrayOfInt, 0, arrayOfInt, i7, i2);
i3 = i4;
for (int i6 = 0; i6 < arrayOfByte.length; i6++) {
for (int i8 = 0; i8 < m; i8++)
arrayOfInt[i3 + i8] = (i8 < k) ? i : j;
i3 += m;
}
for (int i5 = i4 + i2; i5 < arrayOfInt.length; i5 += i2)
System.arraycopy(arrayOfInt, i4, arrayOfInt, i5, i2);
return canvas.createImage(new MemoryImageSource(i2, i1, arrayOfInt, 0, i2));
}
}

View file

@ -0,0 +1,458 @@
package com.lowagie.text.pdf;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Rectangle;
import java.awt.Color;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
public abstract class BaseField {
public static final float BORDER_WIDTH_THIN = 1.0F;
public static final float BORDER_WIDTH_MEDIUM = 2.0F;
public static final float BORDER_WIDTH_THICK = 3.0F;
public static final int VISIBLE = 0;
public static final int HIDDEN = 1;
public static final int VISIBLE_BUT_DOES_NOT_PRINT = 2;
public static final int HIDDEN_BUT_PRINTABLE = 3;
public static final int READ_ONLY = 1;
public static final int REQUIRED = 2;
public static final int MULTILINE = 4096;
public static final int DO_NOT_SCROLL = 8388608;
public static final int PASSWORD = 8192;
public static final int FILE_SELECTION = 1048576;
public static final int DO_NOT_SPELL_CHECK = 4194304;
public static final int EDIT = 262144;
public static final int COMB = 16777216;
protected float borderWidth = 1.0F;
protected int borderStyle = 0;
protected Color borderColor;
protected Color backgroundColor;
protected Color textColor;
protected BaseFont font;
protected float fontSize = 0.0F;
protected int alignment = 0;
protected PdfWriter writer;
protected String text;
protected Rectangle box;
protected int rotation = 0;
protected int visibility;
protected String fieldName;
protected int options;
protected int maxCharacterLength;
private static final HashMap fieldKeys = new HashMap();
public BaseField(PdfWriter paramPdfWriter, Rectangle paramRectangle, String paramString) {
this.writer = paramPdfWriter;
setBox(paramRectangle);
this.fieldName = paramString;
}
protected BaseFont getRealFont() throws IOException, DocumentException {
return (this.font == null) ? BaseFont.createFont("Helvetica", "Cp1252", false) : this.font;
}
protected PdfAppearance getBorderAppearance() {
PdfAppearance pdfAppearance = PdfAppearance.createAppearance(this.writer, this.box.getWidth(), this.box.getHeight());
switch (this.rotation) {
case 90:
pdfAppearance.setMatrix(0.0F, 1.0F, -1.0F, 0.0F, this.box.getHeight(), 0.0F);
break;
case 180:
pdfAppearance.setMatrix(-1.0F, 0.0F, 0.0F, -1.0F, this.box.getWidth(), this.box.getHeight());
break;
case 270:
pdfAppearance.setMatrix(0.0F, -1.0F, 1.0F, 0.0F, 0.0F, this.box.getWidth());
break;
}
pdfAppearance.saveState();
if (this.backgroundColor != null) {
pdfAppearance.setColorFill(this.backgroundColor);
pdfAppearance.rectangle(0.0F, 0.0F, this.box.getWidth(), this.box.getHeight());
pdfAppearance.fill();
}
if (this.borderStyle == 4) {
if (this.borderWidth != 0.0F && this.borderColor != null) {
pdfAppearance.setColorStroke(this.borderColor);
pdfAppearance.setLineWidth(this.borderWidth);
pdfAppearance.moveTo(0.0F, this.borderWidth / 2.0F);
pdfAppearance.lineTo(this.box.getWidth(), this.borderWidth / 2.0F);
pdfAppearance.stroke();
}
} else if (this.borderStyle == 2) {
if (this.borderWidth != 0.0F && this.borderColor != null) {
pdfAppearance.setColorStroke(this.borderColor);
pdfAppearance.setLineWidth(this.borderWidth);
pdfAppearance.rectangle(this.borderWidth / 2.0F, this.borderWidth / 2.0F, this.box.getWidth() - this.borderWidth, this.box.getHeight() - this.borderWidth);
pdfAppearance.stroke();
}
Color color = this.backgroundColor;
if (color == null)
color = Color.white;
pdfAppearance.setGrayFill(1.0F);
drawTopFrame(pdfAppearance);
pdfAppearance.setColorFill(color.darker());
drawBottomFrame(pdfAppearance);
} else if (this.borderStyle == 3) {
if (this.borderWidth != 0.0F && this.borderColor != null) {
pdfAppearance.setColorStroke(this.borderColor);
pdfAppearance.setLineWidth(this.borderWidth);
pdfAppearance.rectangle(this.borderWidth / 2.0F, this.borderWidth / 2.0F, this.box.getWidth() - this.borderWidth, this.box.getHeight() - this.borderWidth);
pdfAppearance.stroke();
}
pdfAppearance.setGrayFill(0.5F);
drawTopFrame(pdfAppearance);
pdfAppearance.setGrayFill(0.75F);
drawBottomFrame(pdfAppearance);
} else if (this.borderWidth != 0.0F && this.borderColor != null) {
if (this.borderStyle == 1)
pdfAppearance.setLineDash(3.0F, 0.0F);
pdfAppearance.setColorStroke(this.borderColor);
pdfAppearance.setLineWidth(this.borderWidth);
pdfAppearance.rectangle(this.borderWidth / 2.0F, this.borderWidth / 2.0F, this.box.getWidth() - this.borderWidth, this.box.getHeight() - this.borderWidth);
pdfAppearance.stroke();
if ((this.options & 0x1000000) != 0 && this.maxCharacterLength > 1) {
float f1 = this.box.getWidth() / (float)this.maxCharacterLength;
float f2 = this.borderWidth / 2.0F;
float f3 = this.box.getHeight() - this.borderWidth / 2.0F;
for (int i = 1; i < this.maxCharacterLength; i++) {
float f = f1 * (float)i;
pdfAppearance.moveTo(f, f2);
pdfAppearance.lineTo(f, f3);
}
pdfAppearance.stroke();
}
}
pdfAppearance.restoreState();
return pdfAppearance;
}
protected static ArrayList getHardBreaks(String paramString) {
ArrayList arrayList = new ArrayList();
char[] arrayOfChar = paramString.toCharArray();
int i = arrayOfChar.length;
StringBuffer stringBuffer = new StringBuffer();
for (int j = 0; j < i; j++) {
char c = arrayOfChar[j];
if (c == '\r') {
if (j + 1 < i && arrayOfChar[j + 1] == '\n')
j++;
arrayList.add(stringBuffer.toString());
stringBuffer = new StringBuffer();
} else if (c == '\n') {
arrayList.add(stringBuffer.toString());
stringBuffer = new StringBuffer();
} else {
stringBuffer.append(c);
}
}
arrayList.add(stringBuffer.toString());
return arrayList;
}
protected static void trimRight(StringBuffer paramStringBuffer) {
int i = paramStringBuffer.length();
while (true) {
if (i == 0)
return;
if (paramStringBuffer.charAt(--i) != ' ')
return;
paramStringBuffer.setLength(i);
}
}
protected static ArrayList breakLines(ArrayList paramArrayList, BaseFont paramBaseFont, float paramFloat1, float paramFloat2) {
ArrayList arrayList = new ArrayList();
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < paramArrayList.size(); i++) {
stringBuffer.setLength(0);
float f = 0.0F;
char[] arrayOfChar = ((String)paramArrayList.get(i)).toCharArray();
int j = arrayOfChar.length;
int k = 0;
int m = -1;
int n = 0;
int i1 = 0;
for (int i2 = 0; i2 < j; i2++) {
n = arrayOfChar[i2];
switch (k) {
case false:
f += paramBaseFont.getWidthPoint(n, paramFloat1);
stringBuffer.append(n);
if (f > paramFloat2) {
f = 0.0F;
if (stringBuffer.length() > 1) {
i2--;
stringBuffer.setLength(stringBuffer.length() - 1);
}
arrayList.add(stringBuffer.toString());
stringBuffer.setLength(0);
i1 = i2;
if (n == 32) {
k = 2;
} else {
k = 1;
}
break;
}
if (n != 32)
k = 1;
break;
case true:
f += paramBaseFont.getWidthPoint(n, paramFloat1);
stringBuffer.append(n);
if (n == 32)
m = i2;
if (f > paramFloat2) {
f = 0.0F;
if (m >= 0) {
i2 = m;
stringBuffer.setLength(m - i1);
trimRight(stringBuffer);
arrayList.add(stringBuffer.toString());
stringBuffer.setLength(0);
i1 = i2;
m = -1;
k = 2;
break;
}
if (stringBuffer.length() > 1) {
i2--;
stringBuffer.setLength(stringBuffer.length() - 1);
}
arrayList.add(stringBuffer.toString());
stringBuffer.setLength(0);
i1 = i2;
if (n == 32)
k = 2;
}
break;
case true:
if (n != 32) {
f = 0.0F;
i2--;
k = 1;
}
break;
}
}
trimRight(stringBuffer);
arrayList.add(stringBuffer.toString());
}
return arrayList;
}
private void drawTopFrame(PdfAppearance paramPdfAppearance) {
paramPdfAppearance.moveTo(this.borderWidth, this.borderWidth);
paramPdfAppearance.lineTo(this.borderWidth, this.box.getHeight() - this.borderWidth);
paramPdfAppearance.lineTo(this.box.getWidth() - this.borderWidth, this.box.getHeight() - this.borderWidth);
paramPdfAppearance.lineTo(this.box.getWidth() - 2.0F * this.borderWidth, this.box.getHeight() - 2.0F * this.borderWidth);
paramPdfAppearance.lineTo(2.0F * this.borderWidth, this.box.getHeight() - 2.0F * this.borderWidth);
paramPdfAppearance.lineTo(2.0F * this.borderWidth, 2.0F * this.borderWidth);
paramPdfAppearance.lineTo(this.borderWidth, this.borderWidth);
paramPdfAppearance.fill();
}
private void drawBottomFrame(PdfAppearance paramPdfAppearance) {
paramPdfAppearance.moveTo(this.borderWidth, this.borderWidth);
paramPdfAppearance.lineTo(this.box.getWidth() - this.borderWidth, this.borderWidth);
paramPdfAppearance.lineTo(this.box.getWidth() - this.borderWidth, this.box.getHeight() - this.borderWidth);
paramPdfAppearance.lineTo(this.box.getWidth() - 2.0F * this.borderWidth, this.box.getHeight() - 2.0F * this.borderWidth);
paramPdfAppearance.lineTo(this.box.getWidth() - 2.0F * this.borderWidth, 2.0F * this.borderWidth);
paramPdfAppearance.lineTo(2.0F * this.borderWidth, 2.0F * this.borderWidth);
paramPdfAppearance.lineTo(this.borderWidth, this.borderWidth);
paramPdfAppearance.fill();
}
public float getBorderWidth() {
return this.borderWidth;
}
public void setBorderWidth(float paramFloat) {
this.borderWidth = paramFloat;
}
public int getBorderStyle() {
return this.borderStyle;
}
public void setBorderStyle(int paramInt) {
this.borderStyle = paramInt;
}
public Color getBorderColor() {
return this.borderColor;
}
public void setBorderColor(Color paramColor) {
this.borderColor = paramColor;
}
public Color getBackgroundColor() {
return this.backgroundColor;
}
public void setBackgroundColor(Color paramColor) {
this.backgroundColor = paramColor;
}
public Color getTextColor() {
return this.textColor;
}
public void setTextColor(Color paramColor) {
this.textColor = paramColor;
}
public BaseFont getFont() {
return this.font;
}
public void setFont(BaseFont paramBaseFont) {
this.font = paramBaseFont;
}
public float getFontSize() {
return this.fontSize;
}
public void setFontSize(float paramFloat) {
this.fontSize = paramFloat;
}
public int getAlignment() {
return this.alignment;
}
public void setAlignment(int paramInt) {
this.alignment = paramInt;
}
public String getText() {
return this.text;
}
public void setText(String paramString) {
this.text = paramString;
}
public Rectangle getBox() {
return this.box;
}
public void setBox(Rectangle paramRectangle) {
if (paramRectangle == null) {
this.box = null;
} else {
this.box = new Rectangle(paramRectangle);
this.box.normalize();
}
}
public int getRotation() {
return this.rotation;
}
public void setRotation(int paramInt) {
if (paramInt % 90 != 0)
throw new IllegalArgumentException("Rotation must be a multiple of 90.");
paramInt %= 360;
if (paramInt < 0)
paramInt += 360;
this.rotation = paramInt;
}
public void setRotationFromPage(Rectangle paramRectangle) {
setRotation(paramRectangle.getRotation());
}
public int getVisibility() {
return this.visibility;
}
public void setVisibility(int paramInt) {
this.visibility = paramInt;
}
public String getFieldName() {
return this.fieldName;
}
public void setFieldName(String paramString) {
this.fieldName = paramString;
}
public int getOptions() {
return this.options;
}
public void setOptions(int paramInt) {
this.options = paramInt;
}
public int getMaxCharacterLength() {
return this.maxCharacterLength;
}
public void setMaxCharacterLength(int paramInt) {
this.maxCharacterLength = paramInt;
}
public PdfWriter getWriter() {
return this.writer;
}
public void setWriter(PdfWriter paramPdfWriter) {
this.writer = paramPdfWriter;
}
public static void moveFields(PdfDictionary paramPdfDictionary1, PdfDictionary paramPdfDictionary2) {
Iterator iterator = paramPdfDictionary1.getKeys().iterator();
while (iterator.hasNext()) {
PdfName pdfName = (PdfName)iterator.next();
if (fieldKeys.containsKey(pdfName)) {
if (paramPdfDictionary2 != null)
paramPdfDictionary2.put(pdfName, paramPdfDictionary1.get(pdfName));
iterator.remove();
}
}
}
static {
fieldKeys.putAll(PdfCopyFieldsImp.fieldKeys);
fieldKeys.put(PdfName.T, new Integer(1));
}
}

View file

@ -0,0 +1,726 @@
package com.lowagie.text.pdf;
import com.lowagie.text.DocumentException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;
public abstract class BaseFont {
public static final String COURIER = "Courier";
public static final String COURIER_BOLD = "Courier-Bold";
public static final String COURIER_OBLIQUE = "Courier-Oblique";
public static final String COURIER_BOLDOBLIQUE = "Courier-BoldOblique";
public static final String HELVETICA = "Helvetica";
public static final String HELVETICA_BOLD = "Helvetica-Bold";
public static final String HELVETICA_OBLIQUE = "Helvetica-Oblique";
public static final String HELVETICA_BOLDOBLIQUE = "Helvetica-BoldOblique";
public static final String SYMBOL = "Symbol";
public static final String TIMES_ROMAN = "Times-Roman";
public static final String TIMES_BOLD = "Times-Bold";
public static final String TIMES_ITALIC = "Times-Italic";
public static final String TIMES_BOLDITALIC = "Times-BoldItalic";
public static final String ZAPFDINGBATS = "ZapfDingbats";
public static final int ASCENT = 1;
public static final int CAPHEIGHT = 2;
public static final int DESCENT = 3;
public static final int ITALICANGLE = 4;
public static final int BBOXLLX = 5;
public static final int BBOXLLY = 6;
public static final int BBOXURX = 7;
public static final int BBOXURY = 8;
public static final int AWT_ASCENT = 9;
public static final int AWT_DESCENT = 10;
public static final int AWT_LEADING = 11;
public static final int AWT_MAXADVANCE = 12;
public static final int UNDERLINE_POSITION = 13;
public static final int UNDERLINE_THICKNESS = 14;
public static final int STRIKETHROUGH_POSITION = 15;
public static final int STRIKETHROUGH_THICKNESS = 16;
public static final int SUBSCRIPT_SIZE = 17;
public static final int SUBSCRIPT_OFFSET = 18;
public static final int SUPERSCRIPT_SIZE = 19;
public static final int SUPERSCRIPT_OFFSET = 20;
public static final int FONT_TYPE_T1 = 0;
public static final int FONT_TYPE_TT = 1;
public static final int FONT_TYPE_CJK = 2;
public static final int FONT_TYPE_TTUNI = 3;
public static final int FONT_TYPE_DOCUMENT = 4;
public static final int FONT_TYPE_T3 = 5;
public static final String IDENTITY_H = "Identity-H";
public static final String IDENTITY_V = "Identity-V";
public static final String CP1250 = "Cp1250";
public static final String CP1252 = "Cp1252";
public static final String CP1257 = "Cp1257";
public static final String WINANSI = "Cp1252";
public static final String MACROMAN = "MacRoman";
public static final int[] CHAR_RANGE_LATIN = new int[] { 0, 383, 8192, 8303, 8352, 8399, 64256, 64262 };
public static final int[] CHAR_RANGE_ARABIC = new int[] { 0, 127, 1536, 1663, 8352, 8399, 64336, 64511, 65136, 65279 };
public static final int[] CHAR_RANGE_HEBREW = new int[] { 0, 127, 1424, 1535, 8352, 8399, 64285, 64335 };
public static final int[] CHAR_RANGE_CYRILLIC = new int[] { 0, 127, 1024, 1327, 8192, 8303, 8352, 8399 };
public static final boolean EMBEDDED = true;
public static final boolean NOT_EMBEDDED = false;
public static final boolean CACHED = true;
public static final boolean NOT_CACHED = false;
public static final String RESOURCE_PATH = "com/lowagie/text/pdf/fonts/";
public static final char CID_NEWLINE = '翿';
protected ArrayList subsetRanges;
int fontType;
public static final String notdef = ".notdef";
protected int[] widths = new int[256];
protected String[] differences = new String[256];
protected char[] unicodeDifferences = new char[256];
protected int[][] charBBoxes = new int[256][];
protected String encoding;
protected boolean embedded;
protected int compressionLevel = -1;
protected boolean fontSpecific = true;
protected static HashMap fontCache = new HashMap();
protected static final HashMap BuiltinFonts14 = new HashMap();
protected boolean forceWidthsOutput = false;
protected boolean directTextToByte = false;
protected boolean subset = true;
protected boolean fastWinansi = false;
protected IntHashtable specialMap;
public static BaseFont createFont() throws DocumentException, IOException {
return createFont("Helvetica", "Cp1252", false);
}
public static BaseFont createFont(String paramString1, String paramString2, boolean paramBoolean) throws DocumentException, IOException {
return createFont(paramString1, paramString2, paramBoolean, true, null, null);
}
public static BaseFont createFont(String paramString1, String paramString2, boolean paramBoolean1, boolean paramBoolean2, byte[] paramArrayOfbyte1, byte[] paramArrayOfbyte2) throws DocumentException, IOException {
return createFont(paramString1, paramString2, paramBoolean1, paramBoolean2, paramArrayOfbyte1, paramArrayOfbyte2, false);
}
public static BaseFont createFont(String paramString1, String paramString2, boolean paramBoolean1, boolean paramBoolean2, byte[] paramArrayOfbyte1, byte[] paramArrayOfbyte2, boolean paramBoolean3) throws DocumentException, IOException {
CJKFont cJKFont;
String str1 = getBaseName(paramString1);
paramString2 = normalizeEncoding(paramString2);
boolean bool = BuiltinFonts14.containsKey(paramString1);
boolean bool1 = bool ? false : CJKFont.isCJKFont(str1, paramString2);
if (bool || bool1) {
paramBoolean1 = false;
} else if (paramString2.equals("Identity-H") || paramString2.equals("Identity-V")) {
paramBoolean1 = true;
}
BaseFont baseFont = null;
Type1Font type1Font = null;
String str2 = paramString1 + "\n" + paramString2 + "\n" + paramBoolean1;
if (paramBoolean2) {
synchronized (fontCache) {
baseFont = (BaseFont)fontCache.get(str2);
}
if (baseFont != null)
return baseFont;
}
if (bool || paramString1.toLowerCase().endsWith(".afm") || paramString1.toLowerCase().endsWith(".pfm")) {
type1Font = new Type1Font(paramString1, paramString2, paramBoolean1, paramArrayOfbyte1, paramArrayOfbyte2);
type1Font.fastWinansi = paramString2.equals("Cp1252");
} else if (str1.toLowerCase().endsWith(".ttf") || str1.toLowerCase().endsWith(".otf") || str1.toLowerCase().indexOf(".ttc,") > 0) {
if (paramString2.equals("Identity-H") || paramString2.equals("Identity-V")) {
TrueTypeFontUnicode trueTypeFontUnicode = new TrueTypeFontUnicode(paramString1, paramString2, paramBoolean1, paramArrayOfbyte1);
} else {
TrueTypeFont trueTypeFont = new TrueTypeFont(paramString1, paramString2, paramBoolean1, paramArrayOfbyte1);
trueTypeFont.fastWinansi = paramString2.equals("Cp1252");
}
} else if (bool1) {
cJKFont = new CJKFont(paramString1, paramString2, paramBoolean1);
} else {
if (paramBoolean3)
return null;
throw new DocumentException("Font '" + paramString1 + "' with '" + paramString2 + "' is not recognized.");
}
if (paramBoolean2)
synchronized (fontCache) {
baseFont = (BaseFont)fontCache.get(str2);
if (baseFont != null)
return baseFont;
fontCache.put(str2, cJKFont);
}
return cJKFont;
}
public static BaseFont createFont(PRIndirectReference paramPRIndirectReference) {
return new DocumentFont(paramPRIndirectReference);
}
protected static String getBaseName(String paramString) {
return paramString.endsWith(",Bold") ? paramString.substring(0, paramString.length() - 5) : (paramString.endsWith(",Italic") ? paramString.substring(0, paramString.length() - 7) : (paramString.endsWith(",BoldItalic") ? paramString.substring(0, paramString.length() - 11) : paramString));
}
protected static String normalizeEncoding(String paramString) {
return (paramString.equals("winansi") || paramString.equals("")) ? "Cp1252" : (paramString.equals("macroman") ? "MacRoman" : paramString);
}
protected void createEncoding() {
if (this.encoding.startsWith("#")) {
this.specialMap = new IntHashtable();
StringTokenizer stringTokenizer = new StringTokenizer(this.encoding.substring(1), " ,\t\n\r\f");
if (stringTokenizer.nextToken().equals("full")) {
while (stringTokenizer.hasMoreTokens()) {
int j;
String str1 = stringTokenizer.nextToken();
String str2 = stringTokenizer.nextToken();
char c = (char)Integer.parseInt(stringTokenizer.nextToken(), 16);
if (str1.startsWith("'")) {
j = str1.charAt(1);
} else {
j = Integer.parseInt(str1);
}
j %= 256;
this.specialMap.put(c, j);
this.differences[j] = str2;
this.unicodeDifferences[j] = c;
this.widths[j] = getRawWidth(c, str2);
this.charBBoxes[j] = getRawCharBBox(c, str2);
}
} else {
int j = 0;
if (stringTokenizer.hasMoreTokens())
j = Integer.parseInt(stringTokenizer.nextToken());
while (stringTokenizer.hasMoreTokens() && j < 256) {
String str1 = stringTokenizer.nextToken();
int k = Integer.parseInt(str1, 16) % 65536;
String str2 = GlyphList.unicodeToName(k);
if (str2 != null) {
this.specialMap.put(k, j);
this.differences[j] = str2;
this.unicodeDifferences[j] = (char)k;
this.widths[j] = getRawWidth(k, str2);
this.charBBoxes[j] = getRawCharBBox(k, str2);
j++;
}
}
}
for (int i = 0; i < 256; i++) {
if (this.differences[i] == null)
this.differences[i] = ".notdef";
}
} else if (this.fontSpecific) {
for (int i = 0; i < 256; i++) {
this.widths[i] = getRawWidth(i, null);
this.charBBoxes[i] = getRawCharBBox(i, null);
}
} else {
byte[] arrayOfByte = new byte[1];
for (int i = 0; i < 256; i++) {
char c;
arrayOfByte[0] = (byte)i;
String str1 = PdfEncodings.convertToString(arrayOfByte, this.encoding);
if (str1.length() > 0) {
c = str1.charAt(0);
} else {
c = '?';
}
String str2 = GlyphList.unicodeToName(c);
if (str2 == null)
str2 = ".notdef";
this.differences[i] = str2;
this.unicodeDifferences[i] = c;
this.widths[i] = getRawWidth(c, str2);
this.charBBoxes[i] = getRawCharBBox(c, str2);
}
}
}
abstract int getRawWidth(int paramInt, String paramString);
public abstract int getKerning(int paramInt1, int paramInt2);
public abstract boolean setKerning(int paramInt1, int paramInt2, int paramInt3);
public int getWidth(int paramInt) {
if (this.fastWinansi)
return (paramInt < 128 || (paramInt >= 160 && paramInt <= 255)) ? this.widths[paramInt] : this.widths[PdfEncodings.winansi.get(paramInt)];
int i = 0;
byte[] arrayOfByte = convertToBytes((char)paramInt);
for (int j = 0; j < arrayOfByte.length; j++)
i += this.widths[0xFF & arrayOfByte[j]];
return i;
}
public int getWidth(String paramString) {
int i = 0;
if (this.fastWinansi) {
int k = paramString.length();
for (int m = 0; m < k; m++) {
char c = paramString.charAt(m);
if (c < '\u0080' || (c >= '\u00A0' && c <= 'ÿ')) {
i += this.widths[c];
} else {
i += this.widths[PdfEncodings.winansi.get(c)];
}
}
return i;
}
byte[] arrayOfByte = convertToBytes(paramString);
for (int j = 0; j < arrayOfByte.length; j++)
i += this.widths[0xFF & arrayOfByte[j]];
return i;
}
public int getDescent(String paramString) {
int i = 0;
char[] arrayOfChar = paramString.toCharArray();
for (int j = 0; j < arrayOfChar.length; j++) {
int[] arrayOfInt = getCharBBox(arrayOfChar[j]);
if (arrayOfInt != null && arrayOfInt[1] < i)
i = arrayOfInt[1];
}
return i;
}
public int getAscent(String paramString) {
int i = 0;
char[] arrayOfChar = paramString.toCharArray();
for (int j = 0; j < arrayOfChar.length; j++) {
int[] arrayOfInt = getCharBBox(arrayOfChar[j]);
if (arrayOfInt != null && arrayOfInt[3] > i)
i = arrayOfInt[3];
}
return i;
}
public float getDescentPoint(String paramString, float paramFloat) {
return (float)getDescent(paramString) * 0.001F * paramFloat;
}
public float getAscentPoint(String paramString, float paramFloat) {
return (float)getAscent(paramString) * 0.001F * paramFloat;
}
public float getWidthPointKerned(String paramString, float paramFloat) {
float f = (float)getWidth(paramString) * 0.001F * paramFloat;
if (!hasKernPairs())
return f;
int i = paramString.length() - 1;
int j = 0;
char[] arrayOfChar = paramString.toCharArray();
for (int k = 0; k < i; k++)
j += getKerning(arrayOfChar[k], arrayOfChar[k + 1]);
return f + (float)j * 0.001F * paramFloat;
}
public float getWidthPoint(String paramString, float paramFloat) {
return (float)getWidth(paramString) * 0.001F * paramFloat;
}
public float getWidthPoint(int paramInt, float paramFloat) {
return (float)getWidth(paramInt) * 0.001F * paramFloat;
}
byte[] convertToBytes(String paramString) {
if (this.directTextToByte)
return PdfEncodings.convertToBytes(paramString, null);
if (this.specialMap != null) {
byte[] arrayOfByte = new byte[paramString.length()];
int i = 0;
int j = paramString.length();
for (int k = 0; k < j; k++) {
char c = paramString.charAt(k);
if (this.specialMap.containsKey(c))
arrayOfByte[i++] = (byte)this.specialMap.get(c);
}
if (i < j) {
byte[] arrayOfByte1 = new byte[i];
System.arraycopy(arrayOfByte, 0, arrayOfByte1, 0, i);
return arrayOfByte1;
}
return arrayOfByte;
}
return PdfEncodings.convertToBytes(paramString, this.encoding);
}
byte[] convertToBytes(int paramInt) {
return this.directTextToByte ? PdfEncodings.convertToBytes((char)paramInt, null) : ((this.specialMap != null) ? (this.specialMap.containsKey(paramInt) ? new byte[] { (byte)this.specialMap.get(paramInt) } : new byte[0]) : PdfEncodings.convertToBytes((char)paramInt, this.encoding));
}
abstract void writeFont(PdfWriter paramPdfWriter, PdfIndirectReference paramPdfIndirectReference, Object[] paramArrayOfObject) throws DocumentException, IOException;
abstract PdfStream getFullFontStream() throws IOException, DocumentException;
public String getEncoding() {
return this.encoding;
}
public abstract float getFontDescriptor(int paramInt, float paramFloat);
public int getFontType() {
return this.fontType;
}
public boolean isEmbedded() {
return this.embedded;
}
public boolean isFontSpecific() {
return this.fontSpecific;
}
public static String createSubsetPrefix() {
String str = "";
for (int i = 0; i < 6; i++)
str = str + (char)(int)(Math.random() * 26.0D + 65.0D);
return str + "+";
}
char getUnicodeDifferences(int paramInt) {
return this.unicodeDifferences[paramInt];
}
public abstract String getPostscriptFontName();
public abstract void setPostscriptFontName(String paramString);
public abstract String[][] getFullFontName();
public abstract String[][] getAllNameEntries();
public static String[][] getFullFontName(String paramString1, String paramString2, byte[] paramArrayOfbyte) throws DocumentException, IOException {
String str = getBaseName(paramString1);
BaseFont baseFont = null;
if (str.toLowerCase().endsWith(".ttf") || str.toLowerCase().endsWith(".otf") || str.toLowerCase().indexOf(".ttc,") > 0) {
baseFont = new TrueTypeFont(paramString1, "Cp1252", false, paramArrayOfbyte, true);
} else {
baseFont = createFont(paramString1, paramString2, false, false, paramArrayOfbyte, null);
}
return baseFont.getFullFontName();
}
public static Object[] getAllFontNames(String paramString1, String paramString2, byte[] paramArrayOfbyte) throws DocumentException, IOException {
String str = getBaseName(paramString1);
BaseFont baseFont = null;
if (str.toLowerCase().endsWith(".ttf") || str.toLowerCase().endsWith(".otf") || str.toLowerCase().indexOf(".ttc,") > 0) {
baseFont = new TrueTypeFont(paramString1, "Cp1252", false, paramArrayOfbyte, true);
} else {
baseFont = createFont(paramString1, paramString2, false, false, paramArrayOfbyte, null);
}
return new Object[] { baseFont.getPostscriptFontName(), baseFont.getFamilyFontName(), baseFont.getFullFontName() };
}
public static String[][] getAllNameEntries(String paramString1, String paramString2, byte[] paramArrayOfbyte) throws DocumentException, IOException {
String str = getBaseName(paramString1);
BaseFont baseFont = null;
if (str.toLowerCase().endsWith(".ttf") || str.toLowerCase().endsWith(".otf") || str.toLowerCase().indexOf(".ttc,") > 0) {
baseFont = new TrueTypeFont(paramString1, "Cp1252", false, paramArrayOfbyte, true);
} else {
baseFont = createFont(paramString1, paramString2, false, false, paramArrayOfbyte, null);
}
return baseFont.getAllNameEntries();
}
public abstract String[][] getFamilyFontName();
public String[] getCodePagesSupported() {
return new String[0];
}
public static String[] enumerateTTCNames(String paramString) throws DocumentException, IOException {
return new EnumerateTTC(paramString).getNames();
}
public static String[] enumerateTTCNames(byte[] paramArrayOfbyte) throws DocumentException, IOException {
return new EnumerateTTC(paramArrayOfbyte).getNames();
}
public int[] getWidths() {
return this.widths;
}
public String[] getDifferences() {
return this.differences;
}
public char[] getUnicodeDifferences() {
return this.unicodeDifferences;
}
public boolean isForceWidthsOutput() {
return this.forceWidthsOutput;
}
public void setForceWidthsOutput(boolean paramBoolean) {
this.forceWidthsOutput = paramBoolean;
}
public boolean isDirectTextToByte() {
return this.directTextToByte;
}
public void setDirectTextToByte(boolean paramBoolean) {
this.directTextToByte = paramBoolean;
}
public boolean isSubset() {
return this.subset;
}
public void setSubset(boolean paramBoolean) {
this.subset = paramBoolean;
}
public static InputStream getResourceStream(String paramString) {
return getResourceStream(paramString, null);
}
public static InputStream getResourceStream(String paramString, ClassLoader paramClassLoader) {
if (paramString.startsWith("/"))
paramString = paramString.substring(1);
InputStream inputStream = null;
if (paramClassLoader != null) {
inputStream = paramClassLoader.getResourceAsStream(paramString);
if (inputStream != null)
return inputStream;
}
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader != null)
inputStream = classLoader.getResourceAsStream(paramString);
} catch (Throwable e) {}
if (inputStream == null)
inputStream = BaseFont.class.getResourceAsStream("/" + paramString);
if (inputStream == null)
inputStream = ClassLoader.getSystemResourceAsStream(paramString);
return inputStream;
}
public int getUnicodeEquivalent(int paramInt) {
return paramInt;
}
public int getCidCode(int paramInt) {
return paramInt;
}
public abstract boolean hasKernPairs();
public boolean charExists(int paramInt) {
byte[] arrayOfByte = convertToBytes(paramInt);
return (arrayOfByte.length > 0);
}
public boolean setCharAdvance(int paramInt1, int paramInt2) {
byte[] arrayOfByte = convertToBytes(paramInt1);
if (arrayOfByte.length == 0)
return false;
this.widths[0xFF & arrayOfByte[0]] = paramInt2;
return true;
}
private static void addFont(PRIndirectReference paramPRIndirectReference, IntHashtable paramIntHashtable, ArrayList paramArrayList) {
PdfObject pdfObject = PdfReader.getPdfObject(paramPRIndirectReference);
if (pdfObject == null || !pdfObject.isDictionary())
return;
PdfDictionary pdfDictionary = (PdfDictionary)pdfObject;
PdfName pdfName1 = (PdfName)PdfReader.getPdfObject(pdfDictionary.get(PdfName.SUBTYPE));
if (!PdfName.TYPE1.equals(pdfName1) && !PdfName.TRUETYPE.equals(pdfName1))
return;
PdfName pdfName2 = (PdfName)PdfReader.getPdfObject(pdfDictionary.get(PdfName.BASEFONT));
paramArrayList.add(new Object[] { PdfName.decodeName(pdfName2.toString()), paramPRIndirectReference });
paramIntHashtable.put(paramPRIndirectReference.getNumber(), 1);
}
private static void recourseFonts(PdfDictionary paramPdfDictionary, IntHashtable paramIntHashtable, ArrayList paramArrayList, int paramInt) {
if (++paramInt > 50)
return;
PdfDictionary pdfDictionary1 = (PdfDictionary)PdfReader.getPdfObject(paramPdfDictionary.get(PdfName.RESOURCES));
if (pdfDictionary1 == null)
return;
PdfDictionary pdfDictionary2 = (PdfDictionary)PdfReader.getPdfObject(pdfDictionary1.get(PdfName.FONT));
if (pdfDictionary2 != null) {
Iterator iterator = pdfDictionary2.getKeys().iterator();
while (iterator.hasNext()) {
PdfObject pdfObject = pdfDictionary2.get((PdfName)iterator.next());
if (pdfObject == null || !pdfObject.isIndirect())
continue;
int i = ((PRIndirectReference)pdfObject).getNumber();
if (paramIntHashtable.containsKey(i))
continue;
addFont((PRIndirectReference)pdfObject, paramIntHashtable, paramArrayList);
}
}
PdfDictionary pdfDictionary3 = (PdfDictionary)PdfReader.getPdfObject(pdfDictionary1.get(PdfName.XOBJECT));
if (pdfDictionary3 != null) {
Iterator iterator = pdfDictionary3.getKeys().iterator();
while (iterator.hasNext())
recourseFonts((PdfDictionary)PdfReader.getPdfObject(pdfDictionary3.get((PdfName)iterator.next())), paramIntHashtable, paramArrayList, paramInt);
}
}
public static ArrayList getDocumentFonts(PdfReader paramPdfReader) {
IntHashtable intHashtable = new IntHashtable();
ArrayList arrayList = new ArrayList();
int i = paramPdfReader.getNumberOfPages();
for (int j = 1; j <= i; j++)
recourseFonts(paramPdfReader.getPageN(j), intHashtable, arrayList, 1);
return arrayList;
}
public static ArrayList getDocumentFonts(PdfReader paramPdfReader, int paramInt) {
IntHashtable intHashtable = new IntHashtable();
ArrayList arrayList = new ArrayList();
recourseFonts(paramPdfReader.getPageN(paramInt), intHashtable, arrayList, 1);
return arrayList;
}
public int[] getCharBBox(int paramInt) {
byte[] arrayOfByte = convertToBytes(paramInt);
return (arrayOfByte.length == 0) ? null : this.charBBoxes[arrayOfByte[0] & 0xFF];
}
protected abstract int[] getRawCharBBox(int paramInt, String paramString);
public void correctArabicAdvance() {
for (int n = 1611; n <= 1624; n = (char)(n + 1))
setCharAdvance(n, 0);
setCharAdvance(1648, 0);
for (int m = 1750; m <= 1756; m = (char)(m + 1))
setCharAdvance(m, 0);
for (int k = 1759; k <= 1764; k = (char)(k + 1))
setCharAdvance(k, 0);
for (int j = 1767; j <= 1768; j = (char)(j + 1))
setCharAdvance(j, 0);
for (int i = 1770; i <= 1773; i = (char)(i + 1))
setCharAdvance(i, 0);
}
public void addSubsetRange(int[] paramArrayOfint) {
if (this.subsetRanges == null)
this.subsetRanges = new ArrayList();
this.subsetRanges.add(paramArrayOfint);
}
public int getCompressionLevel() {
return this.compressionLevel;
}
public void setCompressionLevel(int paramInt) {
if (paramInt < 0 || paramInt > 9) {
this.compressionLevel = -1;
} else {
this.compressionLevel = paramInt;
}
}
static {
BuiltinFonts14.put("Courier", PdfName.COURIER);
BuiltinFonts14.put("Courier-Bold", PdfName.COURIER_BOLD);
BuiltinFonts14.put("Courier-BoldOblique", PdfName.COURIER_BOLDOBLIQUE);
BuiltinFonts14.put("Courier-Oblique", PdfName.COURIER_OBLIQUE);
BuiltinFonts14.put("Helvetica", PdfName.HELVETICA);
BuiltinFonts14.put("Helvetica-Bold", PdfName.HELVETICA_BOLD);
BuiltinFonts14.put("Helvetica-BoldOblique", PdfName.HELVETICA_BOLDOBLIQUE);
BuiltinFonts14.put("Helvetica-Oblique", PdfName.HELVETICA_OBLIQUE);
BuiltinFonts14.put("Symbol", PdfName.SYMBOL);
BuiltinFonts14.put("Times-Roman", PdfName.TIMES_ROMAN);
BuiltinFonts14.put("Times-Bold", PdfName.TIMES_BOLD);
BuiltinFonts14.put("Times-BoldItalic", PdfName.TIMES_BOLDITALIC);
BuiltinFonts14.put("Times-Italic", PdfName.TIMES_ITALIC);
BuiltinFonts14.put("ZapfDingbats", PdfName.ZAPFDINGBATS);
}
static class StreamFont extends PdfStream {
public StreamFont(byte[] param1ArrayOfbyte, int[] param1ArrayOfint, int param1Int) throws DocumentException {
try {
this.bytes = param1ArrayOfbyte;
put(PdfName.LENGTH, new PdfNumber(this.bytes.length));
for (int i = 0; i < param1ArrayOfint.length; i++)
put(new PdfName("Length" + (i + 1)), new PdfNumber(param1ArrayOfint[i]));
flateCompress(param1Int);
} catch (Exception e) {
throw new DocumentException(e);
}
}
public StreamFont(byte[] param1ArrayOfbyte, String param1String, int param1Int) throws DocumentException {
try {
this.bytes = param1ArrayOfbyte;
put(PdfName.LENGTH, new PdfNumber(this.bytes.length));
if (param1String != null)
put(PdfName.SUBTYPE, new PdfName(param1String));
flateCompress(param1Int);
} catch (Exception e) {
throw new DocumentException(e);
}
}
}
}

View file

@ -0,0 +1,869 @@
package com.lowagie.text.pdf;
import com.lowagie.text.Utilities;
import java.util.ArrayList;
public class BidiLine {
protected int runDirection;
protected int pieceSize = 256;
protected char[] text = new char[this.pieceSize];
protected PdfChunk[] detailChunks = new PdfChunk[this.pieceSize];
protected int totalTextLength = 0;
protected byte[] orderLevels = new byte[this.pieceSize];
protected int[] indexChars = new int[this.pieceSize];
protected ArrayList chunks = new ArrayList();
protected int indexChunk = 0;
protected int indexChunkChar = 0;
protected int currentChar = 0;
protected int storedRunDirection;
protected char[] storedText = new char[0];
protected PdfChunk[] storedDetailChunks = new PdfChunk[0];
protected int storedTotalTextLength = 0;
protected byte[] storedOrderLevels = new byte[0];
protected int[] storedIndexChars = new int[0];
protected int storedIndexChunk = 0;
protected int storedIndexChunkChar = 0;
protected int storedCurrentChar = 0;
protected boolean shortStore;
protected static final IntHashtable mirrorChars = new IntHashtable();
protected int arabicOptions;
public BidiLine() {}
public BidiLine(BidiLine paramBidiLine) {
this.runDirection = paramBidiLine.runDirection;
this.pieceSize = paramBidiLine.pieceSize;
this.text = (char[])paramBidiLine.text.clone();
this.detailChunks = (PdfChunk[])paramBidiLine.detailChunks.clone();
this.totalTextLength = paramBidiLine.totalTextLength;
this.orderLevels = (byte[])paramBidiLine.orderLevels.clone();
this.indexChars = (int[])paramBidiLine.indexChars.clone();
this.chunks = new ArrayList(paramBidiLine.chunks);
this.indexChunk = paramBidiLine.indexChunk;
this.indexChunkChar = paramBidiLine.indexChunkChar;
this.currentChar = paramBidiLine.currentChar;
this.storedRunDirection = paramBidiLine.storedRunDirection;
this.storedText = (char[])paramBidiLine.storedText.clone();
this.storedDetailChunks = (PdfChunk[])paramBidiLine.storedDetailChunks.clone();
this.storedTotalTextLength = paramBidiLine.storedTotalTextLength;
this.storedOrderLevels = (byte[])paramBidiLine.storedOrderLevels.clone();
this.storedIndexChars = (int[])paramBidiLine.storedIndexChars.clone();
this.storedIndexChunk = paramBidiLine.storedIndexChunk;
this.storedIndexChunkChar = paramBidiLine.storedIndexChunkChar;
this.storedCurrentChar = paramBidiLine.storedCurrentChar;
this.shortStore = paramBidiLine.shortStore;
this.arabicOptions = paramBidiLine.arabicOptions;
}
public boolean isEmpty() {
return (this.currentChar >= this.totalTextLength && this.indexChunk >= this.chunks.size());
}
public void clearChunks() {
this.chunks.clear();
this.totalTextLength = 0;
this.currentChar = 0;
}
public boolean getParagraph(int paramInt) {
this.runDirection = paramInt;
this.currentChar = 0;
this.totalTextLength = 0;
boolean bool = false;
while (this.indexChunk < this.chunks.size()) {
PdfChunk pdfChunk = (PdfChunk)this.chunks.get(this.indexChunk);
BaseFont baseFont = pdfChunk.font().getFont();
String str = pdfChunk.toString();
int i = str.length();
while (this.indexChunkChar < i) {
char c1 = str.charAt(this.indexChunkChar);
char c2 = (char)baseFont.getUnicodeEquivalent(c1);
if (c2 == '\r' || c2 == '\n') {
if (c2 == '\r' && this.indexChunkChar + 1 < i && str.charAt(this.indexChunkChar + 1) == '\n')
this.indexChunkChar++;
this.indexChunkChar++;
if (this.indexChunkChar >= i) {
this.indexChunkChar = 0;
this.indexChunk++;
}
bool = true;
if (this.totalTextLength == 0) {
this.detailChunks[0] = pdfChunk;
break;
}
break;
}
addPiece(c1, pdfChunk);
this.indexChunkChar++;
}
if (bool)
break;
this.indexChunkChar = 0;
this.indexChunk++;
}
if (this.totalTextLength == 0)
return bool;
this.totalTextLength = trimRight(0, this.totalTextLength - 1) + 1;
if (this.totalTextLength == 0)
return true;
if (paramInt == 2 || paramInt == 3) {
if (this.orderLevels.length < this.totalTextLength) {
this.orderLevels = new byte[this.pieceSize];
this.indexChars = new int[this.pieceSize];
}
ArabicLigaturizer.processNumbers(this.text, 0, this.totalTextLength, this.arabicOptions);
BidiOrder bidiOrder = new BidiOrder(this.text, 0, this.totalTextLength, (byte)((paramInt == 3) ? 1 : 0));
byte[] arrayOfByte = bidiOrder.getLevels();
for (int i = 0; i < this.totalTextLength; i++) {
this.orderLevels[i] = arrayOfByte[i];
this.indexChars[i] = i;
}
doArabicShapping();
mirrorGlyphs();
}
this.totalTextLength = trimRightEx(0, this.totalTextLength - 1) + 1;
return true;
}
public void addChunk(PdfChunk paramPdfChunk) {
this.chunks.add(paramPdfChunk);
}
public void addChunks(ArrayList paramArrayList) {
this.chunks.addAll(paramArrayList);
}
public void addPiece(char paramChar, PdfChunk paramPdfChunk) {
if (this.totalTextLength >= this.pieceSize) {
char[] arrayOfChar = this.text;
PdfChunk[] arrayOfPdfChunk = this.detailChunks;
this.pieceSize *= 2;
this.text = new char[this.pieceSize];
this.detailChunks = new PdfChunk[this.pieceSize];
System.arraycopy(arrayOfChar, 0, this.text, 0, this.totalTextLength);
System.arraycopy(arrayOfPdfChunk, 0, this.detailChunks, 0, this.totalTextLength);
}
this.text[this.totalTextLength] = paramChar;
this.detailChunks[this.totalTextLength++] = paramPdfChunk;
}
public void save() {
if (this.indexChunk > 0) {
if (this.indexChunk >= this.chunks.size()) {
this.chunks.clear();
} else {
this.indexChunk--;
while (this.indexChunk >= 0) {
this.chunks.remove(this.indexChunk);
this.indexChunk--;
}
}
this.indexChunk = 0;
}
this.storedRunDirection = this.runDirection;
this.storedTotalTextLength = this.totalTextLength;
this.storedIndexChunk = this.indexChunk;
this.storedIndexChunkChar = this.indexChunkChar;
this.storedCurrentChar = this.currentChar;
this.shortStore = (this.currentChar < this.totalTextLength);
if (!this.shortStore) {
if (this.storedText.length < this.totalTextLength) {
this.storedText = new char[this.totalTextLength];
this.storedDetailChunks = new PdfChunk[this.totalTextLength];
}
System.arraycopy(this.text, 0, this.storedText, 0, this.totalTextLength);
System.arraycopy(this.detailChunks, 0, this.storedDetailChunks, 0, this.totalTextLength);
}
if (this.runDirection == 2 || this.runDirection == 3) {
if (this.storedOrderLevels.length < this.totalTextLength) {
this.storedOrderLevels = new byte[this.totalTextLength];
this.storedIndexChars = new int[this.totalTextLength];
}
System.arraycopy(this.orderLevels, this.currentChar, this.storedOrderLevels, this.currentChar, this.totalTextLength - this.currentChar);
System.arraycopy(this.indexChars, this.currentChar, this.storedIndexChars, this.currentChar, this.totalTextLength - this.currentChar);
}
}
public void restore() {
this.runDirection = this.storedRunDirection;
this.totalTextLength = this.storedTotalTextLength;
this.indexChunk = this.storedIndexChunk;
this.indexChunkChar = this.storedIndexChunkChar;
this.currentChar = this.storedCurrentChar;
if (!this.shortStore) {
System.arraycopy(this.storedText, 0, this.text, 0, this.totalTextLength);
System.arraycopy(this.storedDetailChunks, 0, this.detailChunks, 0, this.totalTextLength);
}
if (this.runDirection == 2 || this.runDirection == 3) {
System.arraycopy(this.storedOrderLevels, this.currentChar, this.orderLevels, this.currentChar, this.totalTextLength - this.currentChar);
System.arraycopy(this.storedIndexChars, this.currentChar, this.indexChars, this.currentChar, this.totalTextLength - this.currentChar);
}
}
public void mirrorGlyphs() {
for (int i = 0; i < this.totalTextLength; i++) {
if ((this.orderLevels[i] & 0x1) == 1) {
int j = mirrorChars.get(this.text[i]);
if (j != 0)
this.text[i] = (char)j;
}
}
}
public void doArabicShapping() {
int k;
int i = 0;
for (int j = 0;; j += k) {
if (i < this.totalTextLength) {
char c = this.text[i];
if (c < '؀' || c > 'ۿ') {
if (i != j) {
this.text[j] = this.text[i];
this.detailChunks[j] = this.detailChunks[i];
this.orderLevels[j] = this.orderLevels[i];
}
i++;
j++;
continue;
}
}
if (i >= this.totalTextLength) {
this.totalTextLength = j;
return;
}
int m = i;
while (++i < this.totalTextLength) {
char c = this.text[i];
if (c < '؀' || c > 'ۿ')
break;
i++;
}
int n = i - m;
k = ArabicLigaturizer.arabic_shape(this.text, m, n, this.text, j, n, this.arabicOptions);
if (m != j) {
for (int i1 = 0; i1 < k; i1++) {
this.detailChunks[j] = this.detailChunks[m];
this.orderLevels[j++] = this.orderLevels[m++];
}
continue;
}
}
}
public PdfLine processLine(float paramFloat1, float paramFloat2, int paramInt1, int paramInt2, int paramInt3) {
this.arabicOptions = paramInt3;
save();
boolean bool = (paramInt2 == 3) ? true : false;
if (this.currentChar >= this.totalTextLength) {
boolean bool3 = getParagraph(paramInt2);
if (!bool3)
return null;
if (this.totalTextLength == 0) {
ArrayList arrayList = new ArrayList();
PdfChunk pdfChunk = new PdfChunk("", this.detailChunks[0]);
arrayList.add(pdfChunk);
return new PdfLine(0.0F, 0.0F, 0.0F, paramInt1, true, arrayList, bool);
}
}
float f1 = paramFloat2;
int i = -1;
if (this.currentChar != 0)
this.currentChar = trimLeftEx(this.currentChar, this.totalTextLength - 1);
int j = this.currentChar;
int k = 0;
PdfChunk pdfChunk1 = null;
float f2 = 0.0F;
PdfChunk pdfChunk2 = null;
boolean bool1 = false;
boolean bool2 = false;
while (this.currentChar < this.totalTextLength) {
pdfChunk1 = this.detailChunks[this.currentChar];
bool2 = Utilities.isSurrogatePair(this.text, this.currentChar);
if (bool2) {
k = pdfChunk1.getUnicodeEquivalent(Utilities.convertToUtf32(this.text, this.currentChar));
} else {
k = pdfChunk1.getUnicodeEquivalent(this.text[this.currentChar]);
}
if (!PdfChunk.noPrint(k)) {
if (bool2) {
f2 = pdfChunk1.getCharWidth(k);
} else {
f2 = pdfChunk1.getCharWidth(this.text[this.currentChar]);
}
bool1 = pdfChunk1.isExtSplitCharacter(j, this.currentChar, this.totalTextLength, this.text, this.detailChunks);
if (bool1 && Character.isWhitespace((char)k))
i = this.currentChar;
if (paramFloat2 - f2 < 0.0F)
break;
if (bool1)
i = this.currentChar;
paramFloat2 -= f2;
pdfChunk2 = pdfChunk1;
if (pdfChunk1.isTab()) {
Object[] arrayOfObject = (Object[])pdfChunk1.getAttribute("TAB");
float f = ((Float)arrayOfObject[1]).floatValue();
boolean bool3 = ((Boolean)arrayOfObject[2]).booleanValue();
if (bool3 && f < f1 - paramFloat2)
return new PdfLine(0.0F, f1, paramFloat2, paramInt1, true, createArrayOfPdfChunks(j, this.currentChar - 1), bool);
this.detailChunks[this.currentChar].adjustLeft(paramFloat1);
paramFloat2 = f1 - f;
}
if (bool2)
this.currentChar++;
}
this.currentChar++;
}
if (pdfChunk2 == null) {
this.currentChar++;
if (bool2)
this.currentChar++;
return new PdfLine(0.0F, f1, 0.0F, paramInt1, false, createArrayOfPdfChunks(this.currentChar - 1, this.currentChar - 1), bool);
}
if (this.currentChar >= this.totalTextLength)
return new PdfLine(0.0F, f1, paramFloat2, paramInt1, true, createArrayOfPdfChunks(j, this.totalTextLength - 1), bool);
int m = trimRightEx(j, this.currentChar - 1);
if (m < j)
return new PdfLine(0.0F, f1, paramFloat2, paramInt1, false, createArrayOfPdfChunks(j, this.currentChar - 1), bool);
if (m == this.currentChar - 1) {
HyphenationEvent hyphenationEvent = (HyphenationEvent)pdfChunk2.getAttribute("HYPHENATION");
if (hyphenationEvent != null) {
int[] arrayOfInt = getWord(j, m);
if (arrayOfInt != null) {
float f = paramFloat2 + getWidth(arrayOfInt[0], this.currentChar - 1);
String str1 = hyphenationEvent.getHyphenatedWordPre(new String(this.text, arrayOfInt[0], arrayOfInt[1] - arrayOfInt[0]), pdfChunk2.font().getFont(), pdfChunk2.font().size(), f);
String str2 = hyphenationEvent.getHyphenatedWordPost();
if (str1.length() > 0) {
PdfChunk pdfChunk = new PdfChunk(str1, pdfChunk2);
this.currentChar = arrayOfInt[1] - str2.length();
return new PdfLine(0.0F, f1, f - pdfChunk2.font().width(str1), paramInt1, false, createArrayOfPdfChunks(j, arrayOfInt[0] - 1, pdfChunk), bool);
}
}
}
}
if (i == -1 || i >= m)
return new PdfLine(0.0F, f1, paramFloat2 + getWidth(m + 1, this.currentChar - 1), paramInt1, false, createArrayOfPdfChunks(j, m), bool);
this.currentChar = i + 1;
m = trimRightEx(j, i);
if (m < j)
m = this.currentChar - 1;
return new PdfLine(0.0F, f1, f1 - getWidth(j, m), paramInt1, false, createArrayOfPdfChunks(j, m), bool);
}
public float getWidth(int paramInt1, int paramInt2) {
int i = 0;
PdfChunk pdfChunk = null;
float f = 0.0F;
while (paramInt1 <= paramInt2) {
boolean bool = Utilities.isSurrogatePair(this.text, paramInt1);
if (bool) {
f += this.detailChunks[paramInt1].getCharWidth(Utilities.convertToUtf32(this.text, paramInt1));
paramInt1++;
} else {
i = this.text[paramInt1];
pdfChunk = this.detailChunks[paramInt1];
if (!PdfChunk.noPrint(pdfChunk.getUnicodeEquivalent(i)))
f += this.detailChunks[paramInt1].getCharWidth(i);
}
paramInt1++;
}
return f;
}
public ArrayList createArrayOfPdfChunks(int paramInt1, int paramInt2) {
return createArrayOfPdfChunks(paramInt1, paramInt2, null);
}
public ArrayList createArrayOfPdfChunks(int paramInt1, int paramInt2, PdfChunk paramPdfChunk) {
boolean bool = (this.runDirection == 2 || this.runDirection == 3) ? true : false;
if (bool)
reorder(paramInt1, paramInt2);
ArrayList arrayList = new ArrayList();
PdfChunk pdfChunk1 = this.detailChunks[paramInt1];
PdfChunk pdfChunk2 = null;
StringBuffer stringBuffer = new StringBuffer();
int i = 0;
while (paramInt1 <= paramInt2) {
i = bool ? this.indexChars[paramInt1] : paramInt1;
char c = this.text[i];
pdfChunk2 = this.detailChunks[i];
if (!PdfChunk.noPrint(pdfChunk2.getUnicodeEquivalent(c)))
if (pdfChunk2.isImage() || pdfChunk2.isSeparator() || pdfChunk2.isTab()) {
if (stringBuffer.length() > 0) {
arrayList.add(new PdfChunk(stringBuffer.toString(), pdfChunk1));
stringBuffer = new StringBuffer();
}
arrayList.add(pdfChunk2);
} else if (pdfChunk2 == pdfChunk1) {
stringBuffer.append(c);
} else {
if (stringBuffer.length() > 0) {
arrayList.add(new PdfChunk(stringBuffer.toString(), pdfChunk1));
stringBuffer = new StringBuffer();
}
if (!pdfChunk2.isImage() && !pdfChunk2.isSeparator() && !pdfChunk2.isTab())
stringBuffer.append(c);
pdfChunk1 = pdfChunk2;
}
paramInt1++;
}
if (stringBuffer.length() > 0)
arrayList.add(new PdfChunk(stringBuffer.toString(), pdfChunk1));
if (paramPdfChunk != null)
arrayList.add(paramPdfChunk);
return arrayList;
}
public int[] getWord(int paramInt1, int paramInt2) {
int i = paramInt2;
int j = paramInt2;
while (i < this.totalTextLength && Character.isLetter(this.text[i]))
i++;
if (i == paramInt2)
return null;
while (j >= paramInt1 && Character.isLetter(this.text[j]))
j--;
return new int[] { ++j, i };
}
public int trimRight(int paramInt1, int paramInt2) {
int i;
for (i = paramInt2; i >= paramInt1; i--) {
char c = (char)this.detailChunks[i].getUnicodeEquivalent(this.text[i]);
if (!isWS(c))
break;
}
return i;
}
public int trimLeft(int paramInt1, int paramInt2) {
int i;
for (i = paramInt1; i <= paramInt2; i++) {
char c = (char)this.detailChunks[i].getUnicodeEquivalent(this.text[i]);
if (!isWS(c))
break;
}
return i;
}
public int trimRightEx(int paramInt1, int paramInt2) {
int i = paramInt2;
int j = 0;
while (i >= paramInt1) {
j = (char)this.detailChunks[i].getUnicodeEquivalent(this.text[i]);
if (!isWS(j) && !PdfChunk.noPrint(j))
break;
i--;
}
return i;
}
public int trimLeftEx(int paramInt1, int paramInt2) {
int i = paramInt1;
int j = 0;
while (i <= paramInt2) {
j = (char)this.detailChunks[i].getUnicodeEquivalent(this.text[i]);
if (!isWS(j) && !PdfChunk.noPrint(j))
break;
i++;
}
return i;
}
public void reorder(int paramInt1, int paramInt2) {
byte b = this.orderLevels[paramInt1];
int i = b;
int j = b;
int k = b;
for (int m = paramInt1 + 1; m <= paramInt2; m++) {
byte b1 = this.orderLevels[m];
if (b1 > b) {
b = b1;
} else if (b1 < i) {
i = b1;
}
j = (byte)(j & b1);
k = (byte)(k | b1);
}
if ((k & 0x1) == 0)
return;
if ((j & 0x1) == 1) {
flip(paramInt1, paramInt2 + 1);
return;
}
i = (byte)(i | 0x1);
while (b >= i) {
for (int n = paramInt1;; n++) {
if (n > paramInt2 || this.orderLevels[n] >= b) {
if (n > paramInt2) {
b = (byte)(b - 1);
continue;
}
int i1;
for (i1 = n + 1; i1 <= paramInt2 && this.orderLevels[i1] >= b; i1++);
flip(n, i1);
n = i1 + 1;
continue;
}
}
}
}
public void flip(int paramInt1, int paramInt2) {
int i = (paramInt1 + paramInt2) / 2;
paramInt2--;
while (paramInt1 < i) {
int j = this.indexChars[paramInt1];
this.indexChars[paramInt1] = this.indexChars[paramInt2];
this.indexChars[paramInt2] = j;
paramInt1++;
paramInt2--;
}
}
public static boolean isWS(char paramChar) {
return (paramChar <= ' ');
}
static {
mirrorChars.put(40, 41);
mirrorChars.put(41, 40);
mirrorChars.put(60, 62);
mirrorChars.put(62, 60);
mirrorChars.put(91, 93);
mirrorChars.put(93, 91);
mirrorChars.put(123, 125);
mirrorChars.put(125, 123);
mirrorChars.put(171, 187);
mirrorChars.put(187, 171);
mirrorChars.put(8249, 8250);
mirrorChars.put(8250, 8249);
mirrorChars.put(8261, 8262);
mirrorChars.put(8262, 8261);
mirrorChars.put(8317, 8318);
mirrorChars.put(8318, 8317);
mirrorChars.put(8333, 8334);
mirrorChars.put(8334, 8333);
mirrorChars.put(8712, 8715);
mirrorChars.put(8713, 8716);
mirrorChars.put(8714, 8717);
mirrorChars.put(8715, 8712);
mirrorChars.put(8716, 8713);
mirrorChars.put(8717, 8714);
mirrorChars.put(8725, 10741);
mirrorChars.put(8764, 8765);
mirrorChars.put(8765, 8764);
mirrorChars.put(8771, 8909);
mirrorChars.put(8786, 8787);
mirrorChars.put(8787, 8786);
mirrorChars.put(8788, 8789);
mirrorChars.put(8789, 8788);
mirrorChars.put(8804, 8805);
mirrorChars.put(8805, 8804);
mirrorChars.put(8806, 8807);
mirrorChars.put(8807, 8806);
mirrorChars.put(8808, 8809);
mirrorChars.put(8809, 8808);
mirrorChars.put(8810, 8811);
mirrorChars.put(8811, 8810);
mirrorChars.put(8814, 8815);
mirrorChars.put(8815, 8814);
mirrorChars.put(8816, 8817);
mirrorChars.put(8817, 8816);
mirrorChars.put(8818, 8819);
mirrorChars.put(8819, 8818);
mirrorChars.put(8820, 8821);
mirrorChars.put(8821, 8820);
mirrorChars.put(8822, 8823);
mirrorChars.put(8823, 8822);
mirrorChars.put(8824, 8825);
mirrorChars.put(8825, 8824);
mirrorChars.put(8826, 8827);
mirrorChars.put(8827, 8826);
mirrorChars.put(8828, 8829);
mirrorChars.put(8829, 8828);
mirrorChars.put(8830, 8831);
mirrorChars.put(8831, 8830);
mirrorChars.put(8832, 8833);
mirrorChars.put(8833, 8832);
mirrorChars.put(8834, 8835);
mirrorChars.put(8835, 8834);
mirrorChars.put(8836, 8837);
mirrorChars.put(8837, 8836);
mirrorChars.put(8838, 8839);
mirrorChars.put(8839, 8838);
mirrorChars.put(8840, 8841);
mirrorChars.put(8841, 8840);
mirrorChars.put(8842, 8843);
mirrorChars.put(8843, 8842);
mirrorChars.put(8847, 8848);
mirrorChars.put(8848, 8847);
mirrorChars.put(8849, 8850);
mirrorChars.put(8850, 8849);
mirrorChars.put(8856, 10680);
mirrorChars.put(8866, 8867);
mirrorChars.put(8867, 8866);
mirrorChars.put(8870, 10974);
mirrorChars.put(8872, 10980);
mirrorChars.put(8873, 10979);
mirrorChars.put(8875, 10981);
mirrorChars.put(8880, 8881);
mirrorChars.put(8881, 8880);
mirrorChars.put(8882, 8883);
mirrorChars.put(8883, 8882);
mirrorChars.put(8884, 8885);
mirrorChars.put(8885, 8884);
mirrorChars.put(8886, 8887);
mirrorChars.put(8887, 8886);
mirrorChars.put(8905, 8906);
mirrorChars.put(8906, 8905);
mirrorChars.put(8907, 8908);
mirrorChars.put(8908, 8907);
mirrorChars.put(8909, 8771);
mirrorChars.put(8912, 8913);
mirrorChars.put(8913, 8912);
mirrorChars.put(8918, 8919);
mirrorChars.put(8919, 8918);
mirrorChars.put(8920, 8921);
mirrorChars.put(8921, 8920);
mirrorChars.put(8922, 8923);
mirrorChars.put(8923, 8922);
mirrorChars.put(8924, 8925);
mirrorChars.put(8925, 8924);
mirrorChars.put(8926, 8927);
mirrorChars.put(8927, 8926);
mirrorChars.put(8928, 8929);
mirrorChars.put(8929, 8928);
mirrorChars.put(8930, 8931);
mirrorChars.put(8931, 8930);
mirrorChars.put(8932, 8933);
mirrorChars.put(8933, 8932);
mirrorChars.put(8934, 8935);
mirrorChars.put(8935, 8934);
mirrorChars.put(8936, 8937);
mirrorChars.put(8937, 8936);
mirrorChars.put(8938, 8939);
mirrorChars.put(8939, 8938);
mirrorChars.put(8940, 8941);
mirrorChars.put(8941, 8940);
mirrorChars.put(8944, 8945);
mirrorChars.put(8945, 8944);
mirrorChars.put(8946, 8954);
mirrorChars.put(8947, 8955);
mirrorChars.put(8948, 8956);
mirrorChars.put(8950, 8957);
mirrorChars.put(8951, 8958);
mirrorChars.put(8954, 8946);
mirrorChars.put(8955, 8947);
mirrorChars.put(8956, 8948);
mirrorChars.put(8957, 8950);
mirrorChars.put(8958, 8951);
mirrorChars.put(8968, 8969);
mirrorChars.put(8969, 8968);
mirrorChars.put(8970, 8971);
mirrorChars.put(8971, 8970);
mirrorChars.put(9001, 9002);
mirrorChars.put(9002, 9001);
mirrorChars.put(10088, 10089);
mirrorChars.put(10089, 10088);
mirrorChars.put(10090, 10091);
mirrorChars.put(10091, 10090);
mirrorChars.put(10092, 10093);
mirrorChars.put(10093, 10092);
mirrorChars.put(10094, 10095);
mirrorChars.put(10095, 10094);
mirrorChars.put(10096, 10097);
mirrorChars.put(10097, 10096);
mirrorChars.put(10098, 10099);
mirrorChars.put(10099, 10098);
mirrorChars.put(10100, 10101);
mirrorChars.put(10101, 10100);
mirrorChars.put(10197, 10198);
mirrorChars.put(10198, 10197);
mirrorChars.put(10205, 10206);
mirrorChars.put(10206, 10205);
mirrorChars.put(10210, 10211);
mirrorChars.put(10211, 10210);
mirrorChars.put(10212, 10213);
mirrorChars.put(10213, 10212);
mirrorChars.put(10214, 10215);
mirrorChars.put(10215, 10214);
mirrorChars.put(10216, 10217);
mirrorChars.put(10217, 10216);
mirrorChars.put(10218, 10219);
mirrorChars.put(10219, 10218);
mirrorChars.put(10627, 10628);
mirrorChars.put(10628, 10627);
mirrorChars.put(10629, 10630);
mirrorChars.put(10630, 10629);
mirrorChars.put(10631, 10632);
mirrorChars.put(10632, 10631);
mirrorChars.put(10633, 10634);
mirrorChars.put(10634, 10633);
mirrorChars.put(10635, 10636);
mirrorChars.put(10636, 10635);
mirrorChars.put(10637, 10640);
mirrorChars.put(10638, 10639);
mirrorChars.put(10639, 10638);
mirrorChars.put(10640, 10637);
mirrorChars.put(10641, 10642);
mirrorChars.put(10642, 10641);
mirrorChars.put(10643, 10644);
mirrorChars.put(10644, 10643);
mirrorChars.put(10645, 10646);
mirrorChars.put(10646, 10645);
mirrorChars.put(10647, 10648);
mirrorChars.put(10648, 10647);
mirrorChars.put(10680, 8856);
mirrorChars.put(10688, 10689);
mirrorChars.put(10689, 10688);
mirrorChars.put(10692, 10693);
mirrorChars.put(10693, 10692);
mirrorChars.put(10703, 10704);
mirrorChars.put(10704, 10703);
mirrorChars.put(10705, 10706);
mirrorChars.put(10706, 10705);
mirrorChars.put(10708, 10709);
mirrorChars.put(10709, 10708);
mirrorChars.put(10712, 10713);
mirrorChars.put(10713, 10712);
mirrorChars.put(10714, 10715);
mirrorChars.put(10715, 10714);
mirrorChars.put(10741, 8725);
mirrorChars.put(10744, 10745);
mirrorChars.put(10745, 10744);
mirrorChars.put(10748, 10749);
mirrorChars.put(10749, 10748);
mirrorChars.put(10795, 10796);
mirrorChars.put(10796, 10795);
mirrorChars.put(10797, 10796);
mirrorChars.put(10798, 10797);
mirrorChars.put(10804, 10805);
mirrorChars.put(10805, 10804);
mirrorChars.put(10812, 10813);
mirrorChars.put(10813, 10812);
mirrorChars.put(10852, 10853);
mirrorChars.put(10853, 10852);
mirrorChars.put(10873, 10874);
mirrorChars.put(10874, 10873);
mirrorChars.put(10877, 10878);
mirrorChars.put(10878, 10877);
mirrorChars.put(10879, 10880);
mirrorChars.put(10880, 10879);
mirrorChars.put(10881, 10882);
mirrorChars.put(10882, 10881);
mirrorChars.put(10883, 10884);
mirrorChars.put(10884, 10883);
mirrorChars.put(10891, 10892);
mirrorChars.put(10892, 10891);
mirrorChars.put(10897, 10898);
mirrorChars.put(10898, 10897);
mirrorChars.put(10899, 10900);
mirrorChars.put(10900, 10899);
mirrorChars.put(10901, 10902);
mirrorChars.put(10902, 10901);
mirrorChars.put(10903, 10904);
mirrorChars.put(10904, 10903);
mirrorChars.put(10905, 10906);
mirrorChars.put(10906, 10905);
mirrorChars.put(10907, 10908);
mirrorChars.put(10908, 10907);
mirrorChars.put(10913, 10914);
mirrorChars.put(10914, 10913);
mirrorChars.put(10918, 10919);
mirrorChars.put(10919, 10918);
mirrorChars.put(10920, 10921);
mirrorChars.put(10921, 10920);
mirrorChars.put(10922, 10923);
mirrorChars.put(10923, 10922);
mirrorChars.put(10924, 10925);
mirrorChars.put(10925, 10924);
mirrorChars.put(10927, 10928);
mirrorChars.put(10928, 10927);
mirrorChars.put(10931, 10932);
mirrorChars.put(10932, 10931);
mirrorChars.put(10939, 10940);
mirrorChars.put(10940, 10939);
mirrorChars.put(10941, 10942);
mirrorChars.put(10942, 10941);
mirrorChars.put(10943, 10944);
mirrorChars.put(10944, 10943);
mirrorChars.put(10945, 10946);
mirrorChars.put(10946, 10945);
mirrorChars.put(10947, 10948);
mirrorChars.put(10948, 10947);
mirrorChars.put(10949, 10950);
mirrorChars.put(10950, 10949);
mirrorChars.put(10957, 10958);
mirrorChars.put(10958, 10957);
mirrorChars.put(10959, 10960);
mirrorChars.put(10960, 10959);
mirrorChars.put(10961, 10962);
mirrorChars.put(10962, 10961);
mirrorChars.put(10963, 10964);
mirrorChars.put(10964, 10963);
mirrorChars.put(10965, 10966);
mirrorChars.put(10966, 10965);
mirrorChars.put(10974, 8870);
mirrorChars.put(10979, 8873);
mirrorChars.put(10980, 8872);
mirrorChars.put(10981, 8875);
mirrorChars.put(10988, 10989);
mirrorChars.put(10989, 10988);
mirrorChars.put(10999, 11000);
mirrorChars.put(11000, 10999);
mirrorChars.put(11001, 11002);
mirrorChars.put(11002, 11001);
mirrorChars.put(12296, 12297);
mirrorChars.put(12297, 12296);
mirrorChars.put(12298, 12299);
mirrorChars.put(12299, 12298);
mirrorChars.put(12300, 12301);
mirrorChars.put(12301, 12300);
mirrorChars.put(12302, 12303);
mirrorChars.put(12303, 12302);
mirrorChars.put(12304, 12305);
mirrorChars.put(12305, 12304);
mirrorChars.put(12308, 12309);
mirrorChars.put(12309, 12308);
mirrorChars.put(12310, 12311);
mirrorChars.put(12311, 12310);
mirrorChars.put(12312, 12313);
mirrorChars.put(12313, 12312);
mirrorChars.put(12314, 12315);
mirrorChars.put(12315, 12314);
mirrorChars.put(65288, 65289);
mirrorChars.put(65289, 65288);
mirrorChars.put(65308, 65310);
mirrorChars.put(65310, 65308);
mirrorChars.put(65339, 65341);
mirrorChars.put(65341, 65339);
mirrorChars.put(65371, 65373);
mirrorChars.put(65373, 65371);
mirrorChars.put(65375, 65376);
mirrorChars.put(65376, 65375);
mirrorChars.put(65378, 65379);
mirrorChars.put(65379, 65378);
}
}

View file

@ -0,0 +1,733 @@
package com.lowagie.text.pdf;
public final class BidiOrder {
private byte[] initialTypes;
private byte[] embeddings;
private byte paragraphEmbeddingLevel = -1;
private int textLength;
private byte[] resultTypes;
private byte[] resultLevels;
public static final byte L = 0;
public static final byte LRE = 1;
public static final byte LRO = 2;
public static final byte R = 3;
public static final byte AL = 4;
public static final byte RLE = 5;
public static final byte RLO = 6;
public static final byte PDF = 7;
public static final byte EN = 8;
public static final byte ES = 9;
public static final byte ET = 10;
public static final byte AN = 11;
public static final byte CS = 12;
public static final byte NSM = 13;
public static final byte BN = 14;
public static final byte B = 15;
public static final byte S = 16;
public static final byte WS = 17;
public static final byte ON = 18;
public static final byte TYPE_MIN = 0;
public static final byte TYPE_MAX = 18;
private static final byte[] rtypes = new byte[65536];
private static char[] baseTypes = new char[] {
'\000', '\b', '\016', '\t', '\t', '\020', '\n', '\n', '\017', '\013',
'\013', '\020', '\f', '\f', '\021', '\r', '\r', '\017', '\016', '\033',
'\016', '\034', '\036', '\017', '\037', '\037', '\020', ' ', ' ', '\021',
'!', '"', '\022', '#', '%', '\n', '&', '*', '\022', '+',
'+', '\n', ',', ',', '\f', '-', '-', '\n', '.', '.',
'\f', '/', '/', '\t', '0', '9', '\b', ':', ':', '\f',
';', '@', '\022', 'A', 'Z', '\000', '[', '`', '\022', 'a',
'z', '\000', '{', '~', '\022', '\u007F', '\u0084', '\016', '\u0085', '\u0085',
'\017', '\u0086', '\u009F', '\016', '\u00A0', '\u00A0', '\f', '¡', '¡', '\022',
'¢', '¥', '\n', '¦', '©', '\022', 'ª', 'ª', '\000', '«',
'¯', '\022', '°', '±', '\n', '²', '³', '\b', '´', '´',
'\022', 'µ', 'µ', '\000', '¶', '¸', '\022', '¹', '¹', '\b',
'º', 'º', '\000', '»', '¿', '\022', 'À', 'Ö', '\000', '×',
'×', '\022', 'Ø', 'ö', '\000', '÷', '÷', '\022', 'ø', 'ʸ',
'\000', 'ʹ', 'ʺ', '\022', 'ʻ', 'ˁ', '\000', '˂', 'ˏ', '\022',
'ː', 'ˑ', '\000', '˒', '˟', '\022', 'ˠ', 'ˤ', '\000', '˥',
'˭', '\022', 'ˮ', 'ˮ', '\000', '˯', '˿', '\022', '̀', '͗',
'\r', '͘', '͜', '\000', '͝', 'ͯ', '\r', 'Ͱ', 'ͳ', '\000',
'ʹ', '͵', '\022', 'Ͷ', 'ͽ', '\000', ';', ';', '\022', 'Ϳ',
'΃', '\000', '΄', '΅', '\022', 'Ά', 'Ά', '\000', '·', '·',
'\022', 'Έ', 'ϵ', '\000', '϶', '϶', '\022', 'Ϸ', '҂', '\000',
'҃', '҆', '\r', '҇', '҇', '\000', '҈', '҉', '\r', 'Ҋ',
'։', '\000', '֊', '֊', '\022', '֋', '֐', '\000', '֑', '֡',
'\r', '֢', '֢', '\000', '֣', 'ֹ', '\r', 'ֺ', 'ֺ', '\000',
'ֻ', 'ֽ', '\r', '־', '־', '\003', 'ֿ', 'ֿ', '\r', '׀',
'׀', '\003', 'ׁ', 'ׂ', '\r', '׃', '׃', '\003', 'ׄ', 'ׄ',
'\r', 'ׅ', '׏', '\000', 'א', 'ת', '\003', '׫', 'ׯ', '\000',
'װ', '״', '\003', '׵', '׿', '\000', '؀', '؃', '\004', '؄',
'؋', '\000', '،', '،', '\f', '؍', '؍', '\004', '؎', '؏',
'\022', 'ؐ', 'ؕ', '\r', 'ؖ', 'ؚ', '\000', '؛', '؛', '\004',
'؜', '؞', '\000', '؟', '؟', '\004', 'ؠ', 'ؠ', '\000', 'ء',
'غ', '\004', 'ػ', 'ؿ', '\000', 'ـ', 'ي', '\004', 'ً', '٘',
'\r', 'ٙ', 'ٟ', '\000', '٠', '٩', '\013', '٪', '٪', '\n',
'٫', '٬', '\013', '٭', 'ٯ', '\004', 'ٰ', 'ٰ', '\r', 'ٱ',
'ە', '\004', 'ۖ', 'ۜ', '\r', '۝', '۝', '\004', '۞', 'ۤ',
'\r', 'ۥ', 'ۦ', '\004', 'ۧ', 'ۨ', '\r', '۩', '۩', '\022',
'۪', 'ۭ', '\r', 'ۮ', 'ۯ', '\004', '۰', '۹', '\b', 'ۺ',
'܍', '\004', '܎', '܎', '\000', '܏', '܏', '\016', 'ܐ', 'ܐ',
'\004', 'ܑ', 'ܑ', '\r', 'ܒ', 'ܯ', '\004', 'ܰ', '݊', '\r',
'݋', '݌', '\000', 'ݍ', 'ݏ', '\004', 'ݐ', 'ݿ', '\000', 'ހ',
'ޥ', '\004', 'ަ', 'ް', '\r', 'ޱ', 'ޱ', '\004', '޲', 'ऀ',
'\000', 'ँ', 'ं', '\r', '', 'ऻ', '\000', '़', '़', '\r',
'ऽ', 'ी', '\000', 'ु', 'ै', '\r', 'ॉ', 'ौ', '\000', '्',
'्', '\r', 'ॎ', 'ॐ', '\000', '॑', '॔', '\r', 'ॕ', 'ॡ',
'\000', 'ॢ', 'ॣ', '\r', '।', 'ঀ', '\000', 'ঁ', 'ঁ', '\r',
'ং', '঻', '\000', '়', '়', '\r', 'ঽ', 'ী', '\000', 'ু',
'ৄ', '\r', '৅', 'ৌ', '\000', '্', '্', '\r', 'ৎ', 'ৡ',
'\000', 'ৢ', 'ৣ', '\r', '৤', 'ৱ', '\000', '৲', '৳', '\n',
'৴', '਀', '\000', 'ਁ', 'ਂ', '\r', 'ਃ', '਻', '\000', '਼',
'਼', '\r', '਽', 'ੀ', '\000', 'ੁ', 'ੂ', '\r', '੃', '੆',
'\000', 'ੇ', 'ੈ', '\r', '੉', '੊', '\000', 'ੋ', '੍', '\r',
'੎', '੯', '\000', 'ੰ', 'ੱ', '\r', 'ੲ', '઀', '\000', 'ઁ',
'ં', '\r', '', '઻', '\000', '઼', '઼', '\r', 'ઽ', 'ી',
'\000', 'ુ', 'ૅ', '\r', '૆', '૆', '\000', 'ે', 'ૈ', '\r',
'ૉ', 'ૌ', '\000', '્', '્', '\r', '૎', 'ૡ', '\000', 'ૢ',
'ૣ', '\r', '૤', '૰', '\000', '૱', '૱', '\n', '૲', '଀',
'\000', 'ଁ', 'ଁ', '\r', 'ଂ', '଻', '\000', '଼', '଼', '\r',
'ଽ', 'ା', '\000', 'ି', 'ି', '\r', 'ୀ', 'ୀ', '\000', 'ୁ',
'ୃ', '\r', 'ୄ', 'ୌ', '\000', '୍', '୍', '\r', '୎', '୕',
'\000', 'ୖ', 'ୖ', '\r', 'ୗ', '஁', '\000', 'ஂ', 'ஂ', '\r',
'ஃ', 'ி', '\000', 'ீ', 'ீ', '\r', 'ு', 'ௌ', '\000', '்',
'்', '\r', '௎', '௲', '\000', '௳', '௸', '\022', '௹', '௹',
'\n', '௺', '௺', '\022', '௻', 'ఽ', '\000', 'ా', 'ీ', '\r',
'ు', '౅', '\000', 'ె', 'ై', '\r', '౉', '౉', '\000', 'ొ',
'్', '\r', '౎', '౔', '\000', 'ౕ', 'ౖ', '\r', '౗', '಻',
'\000', '಼', '಼', '\r', 'ಽ', 'ೋ', '\000', 'ೌ', '್', '\r',
'೎', 'ീ', '\000', 'ു', 'ൃ', '\r', 'ൄ', 'ൌ', '\000', '്',
'്', '\r', 'ൎ', '෉', '\000', '්', '්', '\r', '෋', 'ෑ',
'\000', 'ි', 'ු', '\r', '෕', '෕', '\000', 'ූ', 'ූ', '\r',
'෗', 'ะ', '\000', 'ั', 'ั', '\r', 'า', 'ำ', '\000', 'ิ',
'ฺ', '\r', '฻', '฾', '\000', '฿', '฿', '\n', 'เ', 'ๆ',
'\000', '็', '๎', '\r', '๏', 'ະ', '\000', 'ັ', 'ັ', '\r',
'າ', 'ຳ', '\000', 'ິ', 'ູ', '\r', '຺', '຺', '\000', 'ົ',
'ຼ', '\r', 'ຽ', '໇', '\000', '່', 'ໍ', '\r', '໎', '༗',
'\000', '༘', '༙', '\r', '༚', '༴', '\000', '༵', '༵', '\r',
'༶', '༶', '\000', '༷', '༷', '\r', '༸', '༸', '\000', '༹',
'༹', '\r', '༺', '༽', '\022', '༾', '཰', '\000', 'ཱ', 'ཾ',
'\r', 'ཿ', 'ཿ', '\000', 'ྀ', '྄', '\r', '྅', '྅', '\000',
'྆', '྇', '\r', 'ྈ', 'ྏ', '\000', 'ྐ', 'ྗ', '\r', '྘',
'྘', '\000', 'ྙ', 'ྼ', '\r', '྽', '࿅', '\000', '࿆', '࿆',
'\r', '࿇', 'ာ', '\000', 'ိ', 'ူ', '\r', 'ေ', 'ေ', '\000',
'ဲ', 'ဲ', '\r', 'ဳ', 'ဵ', '\000', 'ံ', '့', '\r', 'း',
'း', '\000', '္', '္', '\r', '်', 'ၗ', '\000', 'ၘ', 'ၙ',
'\r', 'ၚ', 'ᙿ', '\000', '', '', '\021', 'ᚁ', 'ᚚ', '\000',
'᚛', '᚜', '\022', '᚝', 'ᜑ', '\000', 'ᜒ', '᜔', '\r', '᜕',
'ᜱ', '\000', 'ᜲ', '᜴', '\r', '', 'ᝑ', '\000', 'ᝒ', 'ᝓ',
'\r', '᝔', '᝱', '\000', 'ᝲ', 'ᝳ', '\r', '᝴', 'ា', '\000',
'ិ', 'ួ', '\r', 'ើ', 'ៅ', '\000', 'ំ', 'ំ', '\r', 'ះ',
'ៈ', '\000', '៉', '៓', '\r', '។', '៚', '\000', '៛', '៛',
'\n', 'ៜ', 'ៜ', '\000', '៝', '៝', '\r', '៞', '៯', '\000',
'៰', '៹', '\022', '៺', '៿', '\000', '᠀', '᠊', '\022', '',
'', '\r', '', '', '\021', '᠏', 'ᢨ', '\000', 'ᢩ', 'ᢩ',
'\r', 'ᢪ', '᤟', '\000', 'ᤠ', 'ᤢ', '\r', 'ᤣ', 'ᤦ', '\000',
'ᤧ', 'ᤫ', '\r', '᤬', 'ᤱ', '\000', 'ᤲ', 'ᤲ', '\r', 'ᤳ',
'ᤸ', '\000', '᤹', '᤻', '\r', '᤼', '᤿', '\000', '᥀', '᥀',
'\022', '᥁', '᥃', '\000', '᥄', '᥅', '\022', '᥆', '᧟', '\000',
'᧠', '᧿', '\022', 'ᨀ', 'ᾼ', '\000', '', '', '\022', '',
'', '\000', '᾿', '῁', '\022', 'ῂ', 'ῌ', '\000', '῍', '῏',
'\022', 'ῐ', '῜', '\000', '῝', '῟', '\022', 'ῠ', 'Ῥ', '\000',
'῭', '', '\022', '῰', 'ῼ', '\000', '', '', '\022', '῿',
'῿', '\000', ' ', '', '\021', '', '', '\016', '', '',
'\000', '', '', '\003', '', '‧', '\022', '', '', '\021',
'', '', '\017', '', '', '\001', '', '', '\005', '',
'', '\007', '', '', '\002', '', '', '\006', '', '',
'\021', '‰', '‴', '\n', '', '⁔', '\022', '⁕', '⁖', '\000',
'⁗', '⁗', '\022', '⁘', '⁞', '\000', '', '', '\021', '',
'', '\016', '', '', '\000', '', '', '\016', '⁰', '⁰',
'\b', 'ⁱ', '⁳', '\000', '⁴', '⁹', '\b', '⁺', '⁻', '\n',
'⁼', '⁾', '\022', 'ⁿ', 'ⁿ', '\000', '₀', '₉', '\b', '₊',
'₋', '\n', '₌', '₎', '\022', '₏', '₟', '\000', '₠', '₱',
'\n', '₲', '⃏', '\000', '⃐', '⃪', '\r', '⃫', '⃿', '\000',
'℀', '℁', '\022', '', '', '\000', '℃', '℆', '\022', 'ℇ',
'ℇ', '\000', '℈', '℉', '\022', '', '', '\000', '℔', '℔',
'\022', '', '', '\000', '№', '℘', '\022', '', '', '\000',
'℞', '℣', '\022', '', '', '\000', '℥', '℥', '\022', 'Ω',
'Ω', '\000', '℧', '℧', '\022', '', '', '\000', '℩', '℩',
'\022', '', '', '\000', '', '', '\n', '', '', '\000',
'Ⅎ', 'Ⅎ', '\022', '', '', '\000', '℺', '℻', '\022', 'ℼ',
'ℿ', '\000', '⅀', '⅄', '\022', '', '', '\000', '⅊', '⅋',
'\022', '⅌', '⅒', '\000', '⅓', '⅟', '\022', '', '↏', '\000',
'←', '∑', '\022', '', '∓', '\n', '∔', '⌵', '\022', '⌶',
'', '\000', '⍻', '⎔', '\022', '⎕', '⎕', '\000', '⎖', '⏐',
'\022', '⏑', '⏿', '\000', '␀', '␦', '\022', '␧', '␿', '\000',
'⑀', '⑊', '\022', '⑋', '⑟', '\000', '①', '⒛', '\b', '⒜',
'ⓩ', '\000', '⓪', '⓪', '\b', '⓫', '☗', '\022', '☘', '☘',
'\000', '☙', '♽', '\022', '♾', '♿', '\000', '⚀', '⚑', '\022',
'⚒', '⚟', '\000', '⚠', '⚡', '\022', '⚢', '✀', '\000', '✁',
'✄', '\022', '✅', '✅', '\000', '✆', '✉', '\022', '✊', '✋',
'\000', '✌', '✧', '\022', '✨', '✨', '\000', '✩', '❋', '\022',
'❌', '❌', '\000', '❍', '❍', '\022', '❎', '❎', '\000', '❏',
'❒', '\022', '❓', '❕', '\000', '❖', '❖', '\022', '❗', '❗',
'\000', '❘', '❞', '\022', '❟', '❠', '\000', '❡', '➔', '\022',
'', '➗', '\000', '➘', '➯', '\022', '➰', '➰', '\000', '➱',
'➾', '\022', '➿', '⟏', '\000', '⟐', '⟫', '\022', '⟬', '⟯',
'\000', '⟰', '⬍', '\022', '⬎', '⹿', '\000', '⺀', '⺙', '\022',
'⺚', '⺚', '\000', '⺛', '⻳', '\022', '⻴', '⻿', '\000', '⼀',
'⿕', '\022', '⿖', '⿯', '\000', '⿰', '⿻', '\022', '⿼', '⿿',
'\000', ' ', ' ', '\021', '、', '〄', '\022', '々', '', '\000',
'〈', '〠', '\022', '〡', '〩', '\000', '〪', '〯', '\r', '〰',
'〰', '\022', '〱', '〵', '\000', '〶', '〷', '\022', '〸', '〼',
'\000', '〽', '〿', '\022', '぀', '゘', '\000', '゙', '゚', '\r',
'゛', '゜', '\022', 'ゝ', 'ゟ', '\000', '', '', '\022', 'ァ',
'ヺ', '\000', '・', '・', '\022', 'ー', '㈜', '\000', '㈝', '㈞',
'\022', '㈟', '㉏', '\000', '㉐', '㉟', '\022', '㉠', '㉻', '\000',
'㉼', '㉽', '\022', '㉾', '㊰', '\000', '㊱', '㊿', '\022', '㋀',
'㋋', '\000', '㋌', '㋏', '\022', '㋐', '㍶', '\000', '㍷', '㍺',
'\022', '㍻', '㏝', '\000', '㏞', '㏟', '\022', '㏠', '㏾', '\000',
'㏿', '㏿', '\022', '㐀', '䶿', '\000', '䷀', '䷿', '\022', '一',
'꒏', '\000', '꒐', '꓆', '\022', '꓇', '﬜', '\000', 'יִ', 'יִ',
'\003', 'ﬞ', 'ﬞ', '\r', 'ײַ', 'ﬨ', '\003', '﬩', '﬩', '\n',
'שׁ', 'זּ', '\003', '﬷', '﬷', '\000', 'טּ', 'לּ', '\003', '﬽',
'﬽', '\000', 'מּ', 'מּ', '\003', '﬿', '﬿', '\000', 'נּ', 'סּ',
'\003', '﭂', '﭂', '\000', 'ףּ', 'פּ', '\003', '﭅', '﭅', '\000',
'צּ', 'ﭏ', '\003', 'ﭐ', 'ﮱ', '\004', '﮲', '﯒', '\000', 'ﯓ',
'ﴽ', '\004', '', '﴿', '\022', '﵀', '﵏', '\000', 'ﵐ', 'ﶏ',
'\004', '﶐', '﶑', '\000', 'ﶒ', 'ﷇ', '\004', '﷈', '﷯', '\000',
'ﷰ', '﷼', '\004', '﷽', '﷽', '\022', '﷾', '﷿', '\000', '',
'', '\r', '︐', '︟', '\000', '︠', '︣', '\r', '︤', '︯',
'\000', '', '', '\022', '﹐', '﹐', '\f', '﹑', '﹑', '\022',
'﹒', '﹒', '\f', '﹓', '﹓', '\000', '﹔', '﹔', '\022', '﹕',
'﹕', '\f', '﹖', '﹞', '\022', '﹟', '﹟', '\n', '﹠', '﹡',
'\022', '﹢', '﹣', '\n', '﹤', '﹦', '\022', '﹧', '﹧', '\000',
'', '', '\022', '﹩', '﹪', '\n', '﹫', '﹫', '\022', '﹬',
'﹯', '\000', 'ﹰ', 'ﹴ', '\004', '﹵', '﹵', '\000', 'ﹶ', 'ﻼ',
'\004', '﻽', '﻾', '\000', '', '', '\016', '＀', '＀', '\000',
'', '', '\022', '', '', '\n', '', '', '\022', '',
'', '\n', '', '', '\f', '', '', '\n', '', '',
'\f', '', '', '\t', '', '', '\b', '', '', '\f',
'', '', '\022', '', '', '\000', '', '', '\022', '',
'', '\000', '', '・', '\022', 'ヲ', '￟', '\000', '¢', '£',
'\n', '¬', '¦', '\022', '¥', '₩', '\n', '￧', '￧', '\000',
'', '○', '\022', '￯', '', '\000', '', '', '\016', '',
'<27>', '\022', '￾', Character.MAX_VALUE, '\000' };
public BidiOrder(byte[] paramArrayOfbyte) {
validateTypes(paramArrayOfbyte);
this.initialTypes = (byte[])paramArrayOfbyte.clone();
runAlgorithm();
}
public BidiOrder(byte[] paramArrayOfbyte, byte paramByte) {
validateTypes(paramArrayOfbyte);
validateParagraphEmbeddingLevel(paramByte);
this.initialTypes = (byte[])paramArrayOfbyte.clone();
this.paragraphEmbeddingLevel = paramByte;
runAlgorithm();
}
public BidiOrder(char[] paramArrayOfchar, int paramInt1, int paramInt2, byte paramByte) {
this.initialTypes = new byte[paramInt2];
for (int i = 0; i < paramInt2; i++)
this.initialTypes[i] = rtypes[paramArrayOfchar[paramInt1 + i]];
validateParagraphEmbeddingLevel(paramByte);
this.paragraphEmbeddingLevel = paramByte;
runAlgorithm();
}
public static final byte getDirection(char paramChar) {
return rtypes[paramChar];
}
private void runAlgorithm() {
int j;
this.textLength = this.initialTypes.length;
this.resultTypes = (byte[])this.initialTypes.clone();
if (this.paragraphEmbeddingLevel == -1)
determineParagraphEmbeddingLevel();
this.resultLevels = new byte[this.textLength];
setLevels(0, this.textLength, this.paragraphEmbeddingLevel);
determineExplicitEmbeddingLevels();
this.textLength = removeExplicitCodes();
byte b = this.paragraphEmbeddingLevel;
for (int i = 0; i < this.textLength; i = j) {
byte b1 = this.resultLevels[i];
byte b2 = typeForLevel(Math.max(b, b1));
for (j = i + 1; j < this.textLength && this.resultLevels[j] == b1; j++);
byte b3 = (j < this.textLength) ? this.resultLevels[j] : this.paragraphEmbeddingLevel;
byte b4 = typeForLevel(Math.max(b3, b1));
resolveWeakTypes(i, j, b1, b2, b4);
resolveNeutralTypes(i, j, b1, b2, b4);
resolveImplicitLevels(i, j, b1, b2, b4);
b = b1;
}
this.textLength = reinsertExplicitCodes(this.textLength);
}
private void determineParagraphEmbeddingLevel() {
int i = -1;
for (int j = 0; j < this.textLength; j++) {
byte b = this.resultTypes[j];
if (b == 0 || b == 4 || b == 3) {
i = b;
break;
}
}
if (i == -1) {
this.paragraphEmbeddingLevel = 0;
} else if (i == 0) {
this.paragraphEmbeddingLevel = 0;
} else {
this.paragraphEmbeddingLevel = 1;
}
}
private void determineExplicitEmbeddingLevels() {
this.embeddings = processEmbeddings(this.resultTypes, this.paragraphEmbeddingLevel);
for (int i = 0; i < this.textLength; i++) {
byte b = this.embeddings[i];
if ((b & 0x80) != 0) {
b = (byte)(b & Byte.MAX_VALUE);
this.resultTypes[i] = typeForLevel(b);
}
this.resultLevels[i] = b;
}
}
private int removeExplicitCodes() {
int i = 0;
for (int j = 0; j < this.textLength; j++) {
byte b = this.initialTypes[j];
if (b != 1 && b != 5 && b != 2 && b != 6 && b != 7 && b != 14) {
this.embeddings[i] = this.embeddings[j];
this.resultTypes[i] = this.resultTypes[j];
this.resultLevels[i] = this.resultLevels[j];
i++;
}
}
return i;
}
private int reinsertExplicitCodes(int paramInt) {
int i = this.initialTypes.length;
while (--i >= 0) {
byte b = this.initialTypes[i];
if (b == 1 || b == 5 || b == 2 || b == 6 || b == 7 || b == 14) {
this.embeddings[i] = 0;
this.resultTypes[i] = b;
this.resultLevels[i] = -1;
continue;
}
this.embeddings[i] = this.embeddings[--paramInt];
this.resultTypes[i] = this.resultTypes[paramInt];
this.resultLevels[i] = this.resultLevels[paramInt];
}
if (this.resultLevels[0] == -1)
this.resultLevels[0] = this.paragraphEmbeddingLevel;
for (i = 1; i < this.initialTypes.length; i++) {
if (this.resultLevels[i] == -1)
this.resultLevels[i] = this.resultLevels[i - 1];
}
return this.initialTypes.length;
}
private static byte[] processEmbeddings(byte[] paramArrayOfbyte, byte paramByte) {
int i = paramArrayOfbyte.length;
byte[] arrayOfByte1 = new byte[i];
byte[] arrayOfByte2 = new byte[62];
int j = 0;
int k = 0;
int m = 0;
int n = paramByte;
int i1 = paramByte;
for (int i2 = 0; i2 < i; i2++) {
arrayOfByte1[i2] = i1;
byte b = paramArrayOfbyte[i2];
switch (b) {
case 1:
case 2:
case 5:
case 6:
if (!m) {
byte b1;
if (b == 5 || b == 6) {
b1 = (byte)(n + 1 | 0x1);
} else {
b1 = (byte)(n + 2 & 0xFFFFFFFE);
}
if (b1 < 62) {
arrayOfByte2[j] = i1;
j++;
n = b1;
if (b == 2 || b == 6) {
i1 = (byte)(b1 | 0x80);
} else {
i1 = b1;
}
arrayOfByte1[i2] = i1;
} else if (n == 60) {
k++;
} else {
m++;
}
break;
}
case 7:
if (m > 0) {
m--;
break;
}
if (k > 0 && n != 61) {
k--;
break;
}
if (j > 0) {
i1 = arrayOfByte2[--j];
n = (byte)(i1 & 0x7F);
}
break;
case 15:
j = 0;
m = 0;
k = 0;
n = paramByte;
i1 = paramByte;
arrayOfByte1[i2] = paramByte;
break;
}
}
return arrayOfByte1;
}
private void resolveWeakTypes(int paramInt1, int paramInt2, byte paramByte1, byte paramByte2, byte paramByte3) {
int i = paramByte2;
for (int i3 = paramInt1; i3 < paramInt2; i3++) {
byte b = this.resultTypes[i3];
if (b == 13) {
this.resultTypes[i3] = i;
} else {
i = b;
}
}
for (int i2 = paramInt1; i2 < paramInt2; i2++) {
if (this.resultTypes[i2] == 8)
for (int i4 = i2 - 1; i4 >= paramInt1; i4--) {
byte b = this.resultTypes[i4];
if (b == 0 || b == 3 || b == 4) {
if (b == 4) {
this.resultTypes[i2] = 11;
break;
}
break;
}
}
}
for (int i1 = paramInt1; i1 < paramInt2; i1++) {
if (this.resultTypes[i1] == 4)
this.resultTypes[i1] = 3;
}
for (int n = paramInt1 + 1; n < paramInt2 - 1; n++) {
if (this.resultTypes[n] == 9 || this.resultTypes[n] == 12) {
byte b1 = this.resultTypes[n - 1];
byte b2 = this.resultTypes[n + 1];
if (b1 == 8 && b2 == 8) {
this.resultTypes[n] = 8;
} else if (this.resultTypes[n] == 12 && b1 == 11 && b2 == 11) {
this.resultTypes[n] = 11;
}
}
}
for (int m = paramInt1; m < paramInt2; m++) {
if (this.resultTypes[m] == 10) {
int i4 = m;
int i5 = findRunLimit(i4, paramInt2, new byte[] { (byte)10 });
byte b = (i4 == paramInt1) ? paramByte2 : this.resultTypes[i4 - 1];
if (b != 8)
b = (i5 == paramInt2) ? paramByte3 : this.resultTypes[i5];
if (b == 8)
setTypes(i4, i5, (byte)8);
m = i5;
}
}
for (int k = paramInt1; k < paramInt2; k++) {
byte b = this.resultTypes[k];
if (b == 9 || b == 10 || b == 12)
this.resultTypes[k] = 18;
}
for (int j = paramInt1; j < paramInt2; j++) {
if (this.resultTypes[j] == 8) {
int i4 = paramByte2;
for (int i5 = j - 1; i5 >= paramInt1; i5--) {
byte b = this.resultTypes[i5];
if (b == 0 || b == 3) {
i4 = b;
break;
}
}
if (i4 == 0)
this.resultTypes[j] = 0;
}
}
}
private void resolveNeutralTypes(int paramInt1, int paramInt2, byte paramByte1, byte paramByte2, byte paramByte3) {
for (int i = paramInt1; i < paramInt2; i++) {
byte b = this.resultTypes[i];
if (b == 17 || b == 18 || b == 15 || b == 16) {
byte b1;
byte b2;
byte b3;
int j = i;
int k = findRunLimit(j, paramInt2, new byte[] { (byte)15, (byte)16, (byte)17, (byte)18 });
if (j == paramInt1) {
b1 = paramByte2;
} else {
b1 = this.resultTypes[j - 1];
if (b1 != 0 && b1 != 3)
if (b1 == 11) {
b1 = 3;
} else if (b1 == 8) {
b1 = 3;
}
}
if (k == paramInt2) {
b2 = paramByte3;
} else {
b2 = this.resultTypes[k];
if (b2 != 0 && b2 != 3)
if (b2 == 11) {
b2 = 3;
} else if (b2 == 8) {
b2 = 3;
}
}
if (b1 == b2) {
b3 = b1;
} else {
b3 = typeForLevel(paramByte1);
}
setTypes(j, k, b3);
i = k;
}
}
}
private void resolveImplicitLevels(int paramInt1, int paramInt2, byte paramByte1, byte paramByte2, byte paramByte3) {
if ((paramByte1 & 0x1) == 0) {
for (int i = paramInt1; i < paramInt2; i++) {
byte b = this.resultTypes[i];
if (b != 0)
if (b == 3) {
this.resultLevels[i] = (byte)(this.resultLevels[i] + 1);
} else {
this.resultLevels[i] = (byte)(this.resultLevels[i] + 2);
}
}
} else {
for (int i = paramInt1; i < paramInt2; i++) {
byte b = this.resultTypes[i];
if (b != 3)
this.resultLevels[i] = (byte)(this.resultLevels[i] + 1);
}
}
}
public byte[] getLevels() {
return getLevels(new int[] { this.textLength });
}
public byte[] getLevels(int[] paramArrayOfint) {
validateLineBreaks(paramArrayOfint, this.textLength);
byte[] arrayOfByte = (byte[])this.resultLevels.clone();
int i;
for (i = 0; i < arrayOfByte.length; i++) {
byte b = this.initialTypes[i];
if (b == 15 || b == 16) {
arrayOfByte[i] = this.paragraphEmbeddingLevel;
for (int k = i - 1; k >= 0 && isWhitespace(this.initialTypes[k]); k--)
arrayOfByte[k] = this.paragraphEmbeddingLevel;
}
}
i = 0;
for (int j = 0; j < paramArrayOfint.length; j++) {
int k = paramArrayOfint[j];
for (int m = k - 1; m >= i && isWhitespace(this.initialTypes[m]); m--)
arrayOfByte[m] = this.paragraphEmbeddingLevel;
i = k;
}
return arrayOfByte;
}
public int[] getReordering(int[] paramArrayOfint) {
validateLineBreaks(paramArrayOfint, this.textLength);
byte[] arrayOfByte = getLevels(paramArrayOfint);
return computeMultilineReordering(arrayOfByte, paramArrayOfint);
}
private static int[] computeMultilineReordering(byte[] paramArrayOfbyte, int[] paramArrayOfint) {
int[] arrayOfInt = new int[paramArrayOfbyte.length];
int i = 0;
for (int j = 0; j < paramArrayOfint.length; j++) {
int k = paramArrayOfint[j];
byte[] arrayOfByte = new byte[k - i];
System.arraycopy(paramArrayOfbyte, i, arrayOfByte, 0, arrayOfByte.length);
int[] arrayOfInt1 = computeReordering(arrayOfByte);
for (int m = 0; m < arrayOfInt1.length; m++)
arrayOfInt[i + m] = arrayOfInt1[m] + i;
i = k;
}
return arrayOfInt;
}
private static int[] computeReordering(byte[] paramArrayOfbyte) {
int i = paramArrayOfbyte.length;
int[] arrayOfInt = new int[i];
int j;
for (j = 0; j < i; j++)
arrayOfInt[j] = j;
j = 0;
int k = 63;
for (int n = 0; n < i; n++) {
byte b = paramArrayOfbyte[n];
if (b > j)
j = b;
if ((b & 0x1) != 0 && b < k)
k = b;
}
for (int m = j; m >= k; m--) {
for (int i1 = 0; i1 < i; i1++) {
if (paramArrayOfbyte[i1] >= m) {
int i2 = i1;
int i3;
for (i3 = i1 + 1; i3 < i && paramArrayOfbyte[i3] >= m; i3++);
int i4 = i2;
for (int i5 = i3 - 1; i4 < i5; i5--) {
int i6 = arrayOfInt[i4];
arrayOfInt[i4] = arrayOfInt[i5];
arrayOfInt[i5] = i6;
i4++;
}
i1 = i3;
}
}
}
return arrayOfInt;
}
public byte getBaseLevel() {
return this.paragraphEmbeddingLevel;
}
private static boolean isWhitespace(byte paramByte) {
switch (paramByte) {
case 1:
case 2:
case 5:
case 6:
case 7:
case 14:
case 17:
return true;
}
return false;
}
private static byte typeForLevel(int paramInt) {
return ((paramInt & 0x1) == 0) ? 0 : 3;
}
private int findRunLimit(int paramInt1, int paramInt2, byte[] paramArrayOfbyte) {
paramInt1--;
label13: while (++paramInt1 < paramInt2) {
byte b = this.resultTypes[paramInt1];
for (int i = 0; i < paramArrayOfbyte.length; i++) {
if (b == paramArrayOfbyte[i])
continue label13;
}
return paramInt1;
}
return paramInt2;
}
private int findRunStart(int paramInt, byte[] paramArrayOfbyte) {
label12: while (--paramInt >= 0) {
byte b = this.resultTypes[paramInt];
for (int i = 0; i < paramArrayOfbyte.length; i++) {
if (b == paramArrayOfbyte[i])
continue label12;
}
return paramInt + 1;
}
return 0;
}
private void setTypes(int paramInt1, int paramInt2, byte paramByte) {
for (int i = paramInt1; i < paramInt2; i++)
this.resultTypes[i] = paramByte;
}
private void setLevels(int paramInt1, int paramInt2, byte paramByte) {
for (int i = paramInt1; i < paramInt2; i++)
this.resultLevels[i] = paramByte;
}
private static void validateTypes(byte[] paramArrayOfbyte) {
if (paramArrayOfbyte == null)
throw new IllegalArgumentException("types is null");
for (int j = 0; j < paramArrayOfbyte.length; j++) {
if (paramArrayOfbyte[j] < 0 || paramArrayOfbyte[j] > 18)
throw new IllegalArgumentException("illegal type value at " + j + ": " + paramArrayOfbyte[j]);
}
for (int i = 0; i < paramArrayOfbyte.length - 1; i++) {
if (paramArrayOfbyte[i] == 15)
throw new IllegalArgumentException("B type before end of paragraph at index: " + i);
}
}
private static void validateParagraphEmbeddingLevel(byte paramByte) {
if (paramByte != -1 && paramByte != 0 && paramByte != 1)
throw new IllegalArgumentException("illegal paragraph embedding level: " + paramByte);
}
private static void validateLineBreaks(int[] paramArrayOfint, int paramInt) {
int i = 0;
for (int j = 0; j < paramArrayOfint.length; j++) {
int k = paramArrayOfint[j];
if (k <= i)
throw new IllegalArgumentException("bad linebreak: " + k + " at index: " + j);
i = k;
}
if (i != paramInt)
throw new IllegalArgumentException("last linebreak must be at " + paramInt);
}
static {
for (int i = 0; i < baseTypes.length; i++) {
char c1 = baseTypes[i];
char c2 = baseTypes[++i];
byte b = (byte)baseTypes[++i];
while (c1 <= c2)
rtypes[c1++] = b;
}
}
}

View file

@ -0,0 +1,383 @@
package com.lowagie.text.pdf;
import com.lowagie.text.DocWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
public class ByteBuffer extends OutputStream {
protected int count;
protected byte[] buf;
private static int byteCacheSize = 0;
private static byte[][] byteCache = new byte[byteCacheSize][];
public static final byte ZERO = 48;
private static final char[] chars = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
private static final byte[] bytes = new byte[] {
48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
97, 98, 99, 100, 101, 102 };
public static boolean HIGH_PRECISION = false;
private static final DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
public ByteBuffer() {
this(128);
}
public ByteBuffer(int paramInt) {
if (paramInt < 1)
paramInt = 128;
this.buf = new byte[paramInt];
}
public static void setCacheSize(int paramInt) {
if (paramInt > 3276700)
paramInt = 3276700;
if (paramInt <= byteCacheSize)
return;
byte[][] arrayOfByte = new byte[paramInt][];
System.arraycopy(byteCache, 0, arrayOfByte, 0, byteCacheSize);
byteCache = arrayOfByte;
byteCacheSize = paramInt;
}
public static void fillCache(int paramInt) {
int i = 1;
switch (paramInt) {
case 0:
i = 100;
break;
case 1:
i = 10;
break;
}
for (int j = 1; j < byteCacheSize; j += i) {
if (byteCache[j] == null)
byteCache[j] = convertToBytes(j);
}
}
private static byte[] convertToBytes(int paramInt) {
int i = (int)Math.floor(Math.log((double)paramInt) / Math.log(10.0D));
if (paramInt % 100 != 0)
i += 2;
if (paramInt % 10 != 0)
i++;
if (paramInt < 100) {
i++;
if (paramInt < 10)
i++;
}
byte[] arrayOfByte = new byte[--i];
i--;
if (paramInt < 100)
arrayOfByte[0] = 48;
if (paramInt % 10 != 0)
arrayOfByte[i--] = bytes[paramInt % 10];
if (paramInt % 100 != 0) {
arrayOfByte[i--] = bytes[paramInt / 10 % 10];
arrayOfByte[i--] = 46;
}
i = (int)Math.floor(Math.log((double)paramInt) / Math.log(10.0D)) - 1;
for (int j = 0; j < i; j++)
arrayOfByte[j] = bytes[paramInt / (int)Math.pow(10.0D, (double)(i - j + 1)) % 10];
return arrayOfByte;
}
public ByteBuffer append_i(int paramInt) {
int i = this.count + 1;
if (i > this.buf.length) {
byte[] arrayOfByte = new byte[Math.max(this.buf.length << 1, i)];
System.arraycopy(this.buf, 0, arrayOfByte, 0, this.count);
this.buf = arrayOfByte;
}
this.buf[this.count] = (byte)paramInt;
this.count = i;
return this;
}
public ByteBuffer append(byte[] paramArrayOfbyte, int paramInt1, int paramInt2) {
if (paramInt1 < 0 || paramInt1 > paramArrayOfbyte.length || paramInt2 < 0 || paramInt1 + paramInt2 > paramArrayOfbyte.length || paramInt1 + paramInt2 < 0 || paramInt2 == 0)
return this;
int i = this.count + paramInt2;
if (i > this.buf.length) {
byte[] arrayOfByte = new byte[Math.max(this.buf.length << 1, i)];
System.arraycopy(this.buf, 0, arrayOfByte, 0, this.count);
this.buf = arrayOfByte;
}
System.arraycopy(paramArrayOfbyte, paramInt1, this.buf, this.count, paramInt2);
this.count = i;
return this;
}
public ByteBuffer append(byte[] paramArrayOfbyte) {
return append(paramArrayOfbyte, 0, paramArrayOfbyte.length);
}
public ByteBuffer append(String paramString) {
return (paramString != null) ? append(DocWriter.getISOBytes(paramString)) : this;
}
public ByteBuffer append(char paramChar) {
return append_i(paramChar);
}
public ByteBuffer append(ByteBuffer paramByteBuffer) {
return append(paramByteBuffer.buf, 0, paramByteBuffer.count);
}
public ByteBuffer append(int paramInt) {
return append((double)paramInt);
}
public ByteBuffer append(byte paramByte) {
return append_i(paramByte);
}
public ByteBuffer appendHex(byte paramByte) {
append(bytes[paramByte >> 4 & 0xF]);
return append(bytes[paramByte & 0xF]);
}
public ByteBuffer append(float paramFloat) {
return append((double)paramFloat);
}
public ByteBuffer append(double paramDouble) {
append(formatDouble(paramDouble, this));
return this;
}
public static String formatDouble(double paramDouble) {
return formatDouble(paramDouble, null);
}
public static String formatDouble(double paramDouble, ByteBuffer paramByteBuffer) {
if (HIGH_PRECISION) {
DecimalFormat decimalFormat = new DecimalFormat("0.######", dfs);
String str = decimalFormat.format(paramDouble);
if (paramByteBuffer == null)
return str;
paramByteBuffer.append(str);
return null;
}
boolean bool = false;
if (Math.abs(paramDouble) < 1.5E-5D) {
if (paramByteBuffer != null) {
paramByteBuffer.append((byte)48);
return null;
}
return "0";
}
if (paramDouble < 0.0D) {
bool = true;
paramDouble = -paramDouble;
}
if (paramDouble < 1.0D) {
paramDouble += 5.0E-6D;
if (paramDouble >= 1.0D) {
if (bool) {
if (paramByteBuffer != null) {
paramByteBuffer.append((byte)45);
paramByteBuffer.append((byte)49);
return null;
}
return "-1";
}
if (paramByteBuffer != null) {
paramByteBuffer.append((byte)49);
return null;
}
return "1";
}
if (paramByteBuffer != null) {
int m = (int)(paramDouble * 100000.0D);
if (bool)
paramByteBuffer.append((byte)45);
paramByteBuffer.append((byte)48);
paramByteBuffer.append((byte)46);
paramByteBuffer.append((byte)(m / 10000 + 48));
if (m % 10000 != 0) {
paramByteBuffer.append((byte)(m / 1000 % 10 + 48));
if (m % 1000 != 0) {
paramByteBuffer.append((byte)(m / 100 % 10 + 48));
if (m % 100 != 0) {
paramByteBuffer.append((byte)(m / 10 % 10 + 48));
if (m % 10 != 0)
paramByteBuffer.append((byte)(m % 10 + 48));
}
}
}
return null;
}
int i = 100000;
int j = (int)(paramDouble * (double)i);
StringBuffer stringBuffer1 = new StringBuffer();
if (bool)
stringBuffer1.append('-');
stringBuffer1.append("0.");
while (j < i / 10) {
stringBuffer1.append('0');
i /= 10;
}
stringBuffer1.append(j);
int k;
for (k = stringBuffer1.length() - 1; stringBuffer1.charAt(k) == '0'; k--);
stringBuffer1.setLength(k + 1);
return stringBuffer1.toString();
}
if (paramDouble <= 32767.0D) {
paramDouble += 0.005D;
int i = (int)(paramDouble * 100.0D);
if (i < byteCacheSize && byteCache[i] != null) {
if (paramByteBuffer != null) {
if (bool)
paramByteBuffer.append((byte)45);
paramByteBuffer.append(byteCache[i]);
return null;
}
String str = PdfEncodings.convertToString(byteCache[i], null);
if (bool)
str = "-" + str;
return str;
}
if (paramByteBuffer != null) {
if (i < byteCacheSize) {
int j = 0;
if (i >= 1000000) {
j += true;
} else if (i >= 100000) {
j += true;
} else if (i >= 10000) {
j += true;
} else if (i >= 1000) {
j += true;
} else if (i >= 100) {
j++;
}
if (i % 100 != 0)
j += 2;
if (i % 10 != 0)
j++;
byte[] arrayOfByte = new byte[j];
int k = 0;
if (i >= 1000000)
arrayOfByte[k++] = bytes[i / 1000000];
if (i >= 100000)
arrayOfByte[k++] = bytes[i / 100000 % 10];
if (i >= 10000)
arrayOfByte[k++] = bytes[i / 10000 % 10];
if (i >= 1000)
arrayOfByte[k++] = bytes[i / 1000 % 10];
if (i >= 100)
arrayOfByte[k++] = bytes[i / 100 % 10];
if (i % 100 != 0) {
arrayOfByte[k++] = 46;
arrayOfByte[k++] = bytes[i / 10 % 10];
if (i % 10 != 0)
arrayOfByte[k++] = bytes[i % 10];
}
byteCache[i] = arrayOfByte;
}
if (bool)
paramByteBuffer.append((byte)45);
if (i >= 1000000)
paramByteBuffer.append(bytes[i / 1000000]);
if (i >= 100000)
paramByteBuffer.append(bytes[i / 100000 % 10]);
if (i >= 10000)
paramByteBuffer.append(bytes[i / 10000 % 10]);
if (i >= 1000)
paramByteBuffer.append(bytes[i / 1000 % 10]);
if (i >= 100)
paramByteBuffer.append(bytes[i / 100 % 10]);
if (i % 100 != 0) {
paramByteBuffer.append((byte)46);
paramByteBuffer.append(bytes[i / 10 % 10]);
if (i % 10 != 0)
paramByteBuffer.append(bytes[i % 10]);
}
return null;
}
StringBuffer stringBuffer1 = new StringBuffer();
if (bool)
stringBuffer1.append('-');
if (i >= 1000000)
stringBuffer1.append(chars[i / 1000000]);
if (i >= 100000)
stringBuffer1.append(chars[i / 100000 % 10]);
if (i >= 10000)
stringBuffer1.append(chars[i / 10000 % 10]);
if (i >= 1000)
stringBuffer1.append(chars[i / 1000 % 10]);
if (i >= 100)
stringBuffer1.append(chars[i / 100 % 10]);
if (i % 100 != 0) {
stringBuffer1.append('.');
stringBuffer1.append(chars[i / 10 % 10]);
if (i % 10 != 0)
stringBuffer1.append(chars[i % 10]);
}
return stringBuffer1.toString();
}
StringBuffer stringBuffer = new StringBuffer();
if (bool)
stringBuffer.append('-');
paramDouble += 0.5D;
long l = (long)paramDouble;
return stringBuffer.append(l).toString();
}
public void reset() {
this.count = 0;
}
public byte[] toByteArray() {
byte[] arrayOfByte = new byte[this.count];
System.arraycopy(this.buf, 0, arrayOfByte, 0, this.count);
return arrayOfByte;
}
public int size() {
return this.count;
}
public void setSize(int paramInt) {
if (paramInt > this.count || paramInt < 0)
throw new IndexOutOfBoundsException("The new size must be positive and <= of the current size");
this.count = paramInt;
}
public String toString() {
return new String(this.buf, 0, this.count);
}
public String toString(String paramString) throws UnsupportedEncodingException {
return new String(this.buf, 0, this.count, paramString);
}
public void writeTo(OutputStream paramOutputStream) throws IOException {
paramOutputStream.write(this.buf, 0, this.count);
}
public void write(int paramInt) throws IOException {
append((byte)paramInt);
}
public void write(byte[] paramArrayOfbyte, int paramInt1, int paramInt2) {
append(paramArrayOfbyte, paramInt1, paramInt2);
}
public byte[] getBuffer() {
return this.buf;
}
}

View file

@ -0,0 +1,888 @@
package com.lowagie.text.pdf;
import com.lowagie.text.ExceptionConverter;
import java.util.Iterator;
import java.util.LinkedList;
public class CFFFont {
static final String[] operatorNames = new String[] {
"version", "Notice", "FullName", "FamilyName", "Weight", "FontBBox", "BlueValues", "OtherBlues", "FamilyBlues", "FamilyOtherBlues",
"StdHW", "StdVW", "UNKNOWN_12", "UniqueID", "XUID", "charset", "Encoding", "CharStrings", "Private", "Subrs",
"defaultWidthX", "nominalWidthX", "UNKNOWN_22", "UNKNOWN_23", "UNKNOWN_24", "UNKNOWN_25", "UNKNOWN_26", "UNKNOWN_27", "UNKNOWN_28", "UNKNOWN_29",
"UNKNOWN_30", "UNKNOWN_31", "Copyright", "isFixedPitch", "ItalicAngle", "UnderlinePosition", "UnderlineThickness", "PaintType", "CharstringType", "FontMatrix",
"StrokeWidth", "BlueScale", "BlueShift", "BlueFuzz", "StemSnapH", "StemSnapV", "ForceBold", "UNKNOWN_12_15", "UNKNOWN_12_16", "LanguageGroup",
"ExpansionFactor", "initialRandomSeed", "SyntheticBase", "PostScript", "BaseFontName", "BaseFontBlend", "UNKNOWN_12_24", "UNKNOWN_12_25", "UNKNOWN_12_26", "UNKNOWN_12_27",
"UNKNOWN_12_28", "UNKNOWN_12_29", "ROS", "CIDFontVersion", "CIDFontRevision", "CIDFontType", "CIDCount", "UIDBase", "FDArray", "FDSelect",
"FontName" };
static final String[] standardStrings = new String[] {
".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft",
"parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two",
"three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less",
"equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F",
"G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
"Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d",
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
"y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction",
"yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi",
"fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright",
"guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve",
"dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine",
"Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls",
"onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide",
"brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior",
"copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex",
"Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis",
"Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron",
"aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis",
"egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve",
"otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall",
"Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "zerooldstyle",
"oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior",
"threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior",
"msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "ffi", "ffl", "parenleftinferior",
"parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall",
"Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall",
"Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall",
"colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall",
"Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall",
"oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior", "sixsuperior",
"sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior",
"seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall",
"Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall",
"Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall",
"OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000",
"001.001", "001.002", "001.003", "Black", "Bold", "Book", "Light", "Medium", "Regular", "Roman",
"Semibold" };
int nextIndexOffset;
protected String key;
protected Object[] args = new Object[48];
protected int arg_count = 0;
protected RandomAccessFileOrArray buf;
private int offSize;
protected int nameIndexOffset;
protected int topdictIndexOffset;
protected int stringIndexOffset;
protected int gsubrIndexOffset;
protected int[] nameOffsets;
protected int[] topdictOffsets;
protected int[] stringOffsets;
protected int[] gsubrOffsets;
protected Font[] fonts;
public String getString(char paramChar) {
if (paramChar < standardStrings.length)
return standardStrings[paramChar];
if (paramChar >= standardStrings.length + this.stringOffsets.length - 1)
return null;
int i = paramChar - standardStrings.length;
int j = getPosition();
seek(this.stringOffsets[i]);
StringBuffer stringBuffer = new StringBuffer();
for (int k = this.stringOffsets[i]; k < this.stringOffsets[i + 1]; k++)
stringBuffer.append(getCard8());
seek(j);
return stringBuffer.toString();
}
char getCard8() {
try {
byte b = this.buf.readByte();
return (char)(b & 0xFF);
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
char getCard16() {
try {
return this.buf.readChar();
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
int getOffset(int paramInt) {
int i = 0;
for (int j = 0; j < paramInt; j++) {
i *= 256;
i += getCard8();
}
return i;
}
void seek(int paramInt) {
try {
this.buf.seek(paramInt);
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
short getShort() {
try {
return this.buf.readShort();
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
int getInt() {
try {
return this.buf.readInt();
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
int getPosition() {
try {
return this.buf.getFilePointer();
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
int[] getIndex(int paramInt) {
seek(paramInt);
char c1 = getCard16();
int[] arrayOfInt = new int[c1 + 1];
if (c1 == '\000') {
arrayOfInt[0] = -1;
paramInt += 2;
return arrayOfInt;
}
char c2 = getCard8();
for (int i = 0; i <= c1; i++)
arrayOfInt[i] = paramInt + 2 + 1 + (c1 + 1) * c2 - 1 + getOffset(c2);
return arrayOfInt;
}
protected void getDictItem() {
int i;
for (i = 0; i < this.arg_count; i++)
this.args[i] = null;
this.arg_count = 0;
this.key = null;
i = 0;
while (i == 0) {
char c = getCard8();
if (c == '\035') {
int j = getInt();
this.args[this.arg_count] = new Integer(j);
this.arg_count++;
continue;
}
if (c == '\034') {
short s = getShort();
this.args[this.arg_count] = new Integer(s);
this.arg_count++;
continue;
}
if (c >= ' ' && c <= 'ö') {
byte b = (byte)(c - 139);
this.args[this.arg_count] = new Integer(b);
this.arg_count++;
continue;
}
if (c >= '÷' && c <= 'ú') {
char c1 = getCard8();
short s = (short)((c - 247) * 256 + c1 + 108);
this.args[this.arg_count] = new Integer(s);
this.arg_count++;
continue;
}
if (c >= 'û' && c <= 'þ') {
char c1 = getCard8();
short s = (short)(-(c - 251) * 256 - c1 - 108);
this.args[this.arg_count] = new Integer(s);
this.arg_count++;
continue;
}
if (c == '\036') {
String str = "";
boolean bool = false;
int j = 0;
int k = 0;
int m = 0;
while (!bool) {
if (!k) {
j = getCard8();
k = 2;
}
if (k == 1) {
m = j / 16;
k = (byte)(k - 1);
}
if (k == 2) {
m = j % 16;
k = (byte)(k - 1);
}
switch (m) {
case 10:
str = str + ".";
continue;
case 11:
str = str + "E";
continue;
case 12:
str = str + "E-";
continue;
case 14:
str = str + "-";
continue;
case 15:
bool = true;
continue;
}
if (m >= 0 && m <= 9) {
str = str + String.valueOf(m);
continue;
}
str = str + "<NIBBLE ERROR: " + m + '>';
bool = true;
}
this.args[this.arg_count] = str;
this.arg_count++;
continue;
}
if (c <= '\025') {
i = 1;
if (c != '\f') {
this.key = operatorNames[c];
continue;
}
this.key = operatorNames[32 + getCard8()];
}
}
}
protected RangeItem getEntireIndexRange(int paramInt) {
seek(paramInt);
char c1 = getCard16();
if (c1 == '\000')
return new RangeItem(this.buf, paramInt, 2);
char c2 = getCard8();
seek(paramInt + 2 + 1 + c1 * c2);
int i = getOffset(c2) - 1;
return new RangeItem(this.buf, paramInt, 3 + (c1 + 1) * c2 + i);
}
public byte[] getCID(String paramString) {
int i;
for (i = 0; i < this.fonts.length && !paramString.equals((this.fonts[i]).name); i++);
if (i == this.fonts.length)
return null;
LinkedList linkedList = new LinkedList();
seek(0);
char c1 = getCard8();
char c2 = getCard8();
char c3 = getCard8();
char c4 = getCard8();
this.nextIndexOffset = c3;
linkedList.addLast(new RangeItem(this.buf, 0, c3));
int j = -1;
int k = -1;
if (!(this.fonts[i]).isCID) {
seek((this.fonts[i]).charstringsOffset);
j = getCard16();
seek(this.stringIndexOffset);
k = getCard16() + standardStrings.length;
}
linkedList.addLast(new UInt16Item('\001'));
linkedList.addLast(new UInt8Item('\001'));
linkedList.addLast(new UInt8Item('\001'));
linkedList.addLast(new UInt8Item((char)(1 + (this.fonts[i]).name.length())));
linkedList.addLast(new StringItem((this.fonts[i]).name));
linkedList.addLast(new UInt16Item('\001'));
linkedList.addLast(new UInt8Item('\002'));
linkedList.addLast(new UInt16Item('\001'));
IndexOffsetItem indexOffsetItem = new IndexOffsetItem(2);
linkedList.addLast(indexOffsetItem);
IndexBaseItem indexBaseItem = new IndexBaseItem();
linkedList.addLast(indexBaseItem);
DictOffsetItem dictOffsetItem1 = new DictOffsetItem();
DictOffsetItem dictOffsetItem2 = new DictOffsetItem();
DictOffsetItem dictOffsetItem3 = new DictOffsetItem();
DictOffsetItem dictOffsetItem4 = new DictOffsetItem();
if (!(this.fonts[i]).isCID) {
linkedList.addLast(new DictNumberItem(k));
linkedList.addLast(new DictNumberItem(k + 1));
linkedList.addLast(new DictNumberItem(0));
linkedList.addLast(new UInt8Item('\f'));
linkedList.addLast(new UInt8Item('\036'));
linkedList.addLast(new DictNumberItem(j));
linkedList.addLast(new UInt8Item('\f'));
linkedList.addLast(new UInt8Item('"'));
}
linkedList.addLast(dictOffsetItem3);
linkedList.addLast(new UInt8Item('\f'));
linkedList.addLast(new UInt8Item('$'));
linkedList.addLast(dictOffsetItem4);
linkedList.addLast(new UInt8Item('\f'));
linkedList.addLast(new UInt8Item('%'));
linkedList.addLast(dictOffsetItem1);
linkedList.addLast(new UInt8Item('\017'));
linkedList.addLast(dictOffsetItem2);
linkedList.addLast(new UInt8Item('\021'));
seek(this.topdictOffsets[i]);
while (getPosition() < this.topdictOffsets[i + 1]) {
int n = getPosition();
getDictItem();
int i1 = getPosition();
if (this.key == "Encoding" || this.key == "Private" || this.key == "FDSelect" || this.key == "FDArray" || this.key == "charset" || this.key == "CharStrings")
continue;
linkedList.add(new RangeItem(this.buf, n, i1 - n));
}
linkedList.addLast(new IndexMarkerItem(indexOffsetItem, indexBaseItem));
if ((this.fonts[i]).isCID) {
linkedList.addLast(getEntireIndexRange(this.stringIndexOffset));
} else {
int i2;
String str1 = (this.fonts[i]).name + "-OneRange";
if (str1.length() > 127)
str1 = str1.substring(0, 127);
String str2 = "AdobeIdentity" + str1;
int n = this.stringOffsets[this.stringOffsets.length - 1] - this.stringOffsets[0];
int i1 = this.stringOffsets[0] - 1;
if (n + str2.length() <= 255) {
i2 = 1;
} else if (n + str2.length() <= 65535) {
i2 = 2;
} else if (n + str2.length() <= 16777215) {
i2 = 3;
} else {
i2 = 4;
}
linkedList.addLast(new UInt16Item((char)(this.stringOffsets.length - 1 + 3)));
linkedList.addLast(new UInt8Item((char)i2));
int i3;
for (i3 = 0; i3 < this.stringOffsets.length; i3++)
linkedList.addLast(new IndexOffsetItem(i2, this.stringOffsets[i3] - i1));
i3 = this.stringOffsets[this.stringOffsets.length - 1] - i1;
i3 += "Adobe".length();
linkedList.addLast(new IndexOffsetItem(i2, i3));
i3 += "Identity".length();
linkedList.addLast(new IndexOffsetItem(i2, i3));
i3 += str1.length();
linkedList.addLast(new IndexOffsetItem(i2, i3));
linkedList.addLast(new RangeItem(this.buf, this.stringOffsets[0], n));
linkedList.addLast(new StringItem(str2));
}
linkedList.addLast(getEntireIndexRange(this.gsubrIndexOffset));
if (!(this.fonts[i]).isCID) {
linkedList.addLast(new MarkerItem(dictOffsetItem4));
linkedList.addLast(new UInt8Item('\003'));
linkedList.addLast(new UInt16Item('\001'));
linkedList.addLast(new UInt16Item('\000'));
linkedList.addLast(new UInt8Item('\000'));
linkedList.addLast(new UInt16Item((char)j));
linkedList.addLast(new MarkerItem(dictOffsetItem1));
linkedList.addLast(new UInt8Item('\002'));
linkedList.addLast(new UInt16Item('\001'));
linkedList.addLast(new UInt16Item((char)(j - 1)));
linkedList.addLast(new MarkerItem(dictOffsetItem3));
linkedList.addLast(new UInt16Item('\001'));
linkedList.addLast(new UInt8Item('\001'));
linkedList.addLast(new UInt8Item('\001'));
IndexOffsetItem indexOffsetItem1 = new IndexOffsetItem(1);
linkedList.addLast(indexOffsetItem1);
IndexBaseItem indexBaseItem1 = new IndexBaseItem();
linkedList.addLast(indexBaseItem1);
linkedList.addLast(new DictNumberItem((this.fonts[i]).privateLength));
DictOffsetItem dictOffsetItem = new DictOffsetItem();
linkedList.addLast(dictOffsetItem);
linkedList.addLast(new UInt8Item('\022'));
linkedList.addLast(new IndexMarkerItem(indexOffsetItem1, indexBaseItem1));
linkedList.addLast(new MarkerItem(dictOffsetItem));
linkedList.addLast(new RangeItem(this.buf, (this.fonts[i]).privateOffset, (this.fonts[i]).privateLength));
if ((this.fonts[i]).privateSubrs >= 0)
linkedList.addLast(getEntireIndexRange((this.fonts[i]).privateSubrs));
}
linkedList.addLast(new MarkerItem(dictOffsetItem2));
linkedList.addLast(getEntireIndexRange((this.fonts[i]).charstringsOffset));
int[] arrayOfInt = new int[1];
arrayOfInt[0] = 0;
Iterator iterator = linkedList.iterator();
while (iterator.hasNext()) {
Item item = (Item)iterator.next();
item.increment(arrayOfInt);
}
iterator = linkedList.iterator();
while (iterator.hasNext()) {
Item item = (Item)iterator.next();
item.xref();
}
int m = arrayOfInt[0];
byte[] arrayOfByte = new byte[m];
iterator = linkedList.iterator();
while (iterator.hasNext()) {
Item item = (Item)iterator.next();
item.emit(arrayOfByte);
}
return arrayOfByte;
}
public boolean isCID(String paramString) {
for (int i = 0; i < this.fonts.length; i++) {
if (paramString.equals((this.fonts[i]).name))
return (this.fonts[i]).isCID;
}
return false;
}
public boolean exists(String paramString) {
for (int i = 0; i < this.fonts.length; i++) {
if (paramString.equals((this.fonts[i]).name))
return true;
}
return false;
}
public String[] getNames() {
String[] arrayOfString = new String[this.fonts.length];
for (int i = 0; i < this.fonts.length; i++)
arrayOfString[i] = (this.fonts[i]).name;
return arrayOfString;
}
public CFFFont(RandomAccessFileOrArray paramRandomAccessFileOrArray) {
this.buf = paramRandomAccessFileOrArray;
seek(0);
char c1 = getCard8();
char c2 = getCard8();
char c3 = getCard8();
this.offSize = getCard8();
this.nameIndexOffset = c3;
this.nameOffsets = getIndex(this.nameIndexOffset);
this.topdictIndexOffset = this.nameOffsets[this.nameOffsets.length - 1];
this.topdictOffsets = getIndex(this.topdictIndexOffset);
this.stringIndexOffset = this.topdictOffsets[this.topdictOffsets.length - 1];
this.stringOffsets = getIndex(this.stringIndexOffset);
this.gsubrIndexOffset = this.stringOffsets[this.stringOffsets.length - 1];
this.gsubrOffsets = getIndex(this.gsubrIndexOffset);
this.fonts = new Font[this.nameOffsets.length - 1];
for (int j = 0; j < this.nameOffsets.length - 1; j++) {
this.fonts[j] = new Font();
seek(this.nameOffsets[j]);
(this.fonts[j]).name = "";
for (int k = this.nameOffsets[j]; k < this.nameOffsets[j + 1]; k++)
(this.fonts[j]).name += getCard8();
}
for (int i = 0; i < this.topdictOffsets.length - 1; i++) {
seek(this.topdictOffsets[i]);
while (getPosition() < this.topdictOffsets[i + 1]) {
getDictItem();
if (this.key == "FullName") {
(this.fonts[i]).fullName = getString((char)((Integer)this.args[0]).intValue());
continue;
}
if (this.key == "ROS") {
(this.fonts[i]).isCID = true;
continue;
}
if (this.key == "Private") {
(this.fonts[i]).privateLength = ((Integer)this.args[0]).intValue();
(this.fonts[i]).privateOffset = ((Integer)this.args[1]).intValue();
continue;
}
if (this.key == "charset") {
(this.fonts[i]).charsetOffset = ((Integer)this.args[0]).intValue();
continue;
}
if (this.key == "Encoding") {
(this.fonts[i]).encodingOffset = ((Integer)this.args[0]).intValue();
ReadEncoding((this.fonts[i]).encodingOffset);
continue;
}
if (this.key == "CharStrings") {
(this.fonts[i]).charstringsOffset = ((Integer)this.args[0]).intValue();
int k = getPosition();
(this.fonts[i]).charstringsOffsets = getIndex((this.fonts[i]).charstringsOffset);
seek(k);
continue;
}
if (this.key == "FDArray") {
(this.fonts[i]).fdarrayOffset = ((Integer)this.args[0]).intValue();
continue;
}
if (this.key == "FDSelect") {
(this.fonts[i]).fdselectOffset = ((Integer)this.args[0]).intValue();
continue;
}
if (this.key == "CharstringType")
(this.fonts[i]).CharstringType = ((Integer)this.args[0]).intValue();
}
if ((this.fonts[i]).privateOffset >= 0) {
seek((this.fonts[i]).privateOffset);
while (getPosition() < (this.fonts[i]).privateOffset + (this.fonts[i]).privateLength) {
getDictItem();
if (this.key == "Subrs")
(this.fonts[i]).privateSubrs = ((Integer)this.args[0]).intValue() + (this.fonts[i]).privateOffset;
}
}
if ((this.fonts[i]).fdarrayOffset >= 0) {
int[] arrayOfInt = getIndex((this.fonts[i]).fdarrayOffset);
(this.fonts[i]).fdprivateOffsets = new int[arrayOfInt.length - 1];
(this.fonts[i]).fdprivateLengths = new int[arrayOfInt.length - 1];
for (int k = 0; k < arrayOfInt.length - 1; k++) {
seek(arrayOfInt[k]);
while (getPosition() < arrayOfInt[k + 1])
getDictItem();
if (this.key == "Private") {
(this.fonts[i]).fdprivateLengths[k] = ((Integer)this.args[0]).intValue();
(this.fonts[i]).fdprivateOffsets[k] = ((Integer)this.args[1]).intValue();
}
}
}
}
}
void ReadEncoding(int paramInt) {
seek(paramInt);
char c = getCard8();
}
protected final class Font {
public String name;
public String fullName;
public boolean isCID = false;
public int privateOffset = -1;
public int privateLength = -1;
public int privateSubrs = -1;
public int charstringsOffset = -1;
public int encodingOffset = -1;
public int charsetOffset = -1;
public int fdarrayOffset = -1;
public int fdselectOffset = -1;
public int[] fdprivateOffsets;
public int[] fdprivateLengths;
public int[] fdprivateSubrs;
public int nglyphs;
public int nstrings;
public int CharsetLength;
public int[] charstringsOffsets;
public int[] charset;
public int[] FDSelect;
public int FDSelectLength;
public int FDSelectFormat;
public int CharstringType = 2;
public int FDArrayCount;
public int FDArrayOffsize;
public int[] FDArrayOffsets;
public int[] PrivateSubrsOffset;
public int[][] PrivateSubrsOffsetsArray;
public int[] SubrsOffsets;
}
protected static final class MarkerItem extends Item {
CFFFont.OffsetItem p;
public MarkerItem(CFFFont.OffsetItem param1OffsetItem) {
this.p = param1OffsetItem;
}
public void xref() {
this.p.set(this.myOffset);
}
}
protected static final class DictNumberItem extends Item {
public final int value;
public int size = 5;
public DictNumberItem(int param1Int) {
this.value = param1Int;
}
public void increment(int[] param1ArrayOfint) {
super.increment(param1ArrayOfint);
param1ArrayOfint[0] = param1ArrayOfint[0] + this.size;
}
public void emit(byte[] param1ArrayOfbyte) {
if (this.size == 5) {
param1ArrayOfbyte[this.myOffset] = 29;
param1ArrayOfbyte[this.myOffset + 1] = (byte)(this.value >>> 24 & 0xFF);
param1ArrayOfbyte[this.myOffset + 2] = (byte)(this.value >>> 16 & 0xFF);
param1ArrayOfbyte[this.myOffset + 3] = (byte)(this.value >>> 8 & 0xFF);
param1ArrayOfbyte[this.myOffset + 4] = (byte)(this.value >>> 0 & 0xFF);
}
}
}
protected static final class StringItem extends Item {
public String s;
public StringItem(String param1String) {
this.s = param1String;
}
public void increment(int[] param1ArrayOfint) {
super.increment(param1ArrayOfint);
param1ArrayOfint[0] = param1ArrayOfint[0] + this.s.length();
}
public void emit(byte[] param1ArrayOfbyte) {
for (int i = 0; i < this.s.length(); i++)
param1ArrayOfbyte[this.myOffset + i] = (byte)(this.s.charAt(i) & 0xFF);
}
}
protected static final class UInt8Item extends Item {
public char value;
public UInt8Item(char param1Char) {
this.value = param1Char;
}
public void increment(int[] param1ArrayOfint) {
super.increment(param1ArrayOfint);
param1ArrayOfint[0] = param1ArrayOfint[0] + 1;
}
public void emit(byte[] param1ArrayOfbyte) {
param1ArrayOfbyte[this.myOffset + 0] = (byte)(this.value >>> 0 & 0xFF);
}
}
protected static final class UInt16Item extends Item {
public char value;
public UInt16Item(char param1Char) {
this.value = param1Char;
}
public void increment(int[] param1ArrayOfint) {
super.increment(param1ArrayOfint);
param1ArrayOfint[0] = param1ArrayOfint[0] + 2;
}
public void emit(byte[] param1ArrayOfbyte) {
param1ArrayOfbyte[this.myOffset + 0] = (byte)(this.value >>> 8 & 0xFF);
param1ArrayOfbyte[this.myOffset + 1] = (byte)(this.value >>> 0 & 0xFF);
}
}
protected static final class UInt32Item extends Item {
public int value;
public UInt32Item(int param1Int) {
this.value = param1Int;
}
public void increment(int[] param1ArrayOfint) {
super.increment(param1ArrayOfint);
param1ArrayOfint[0] = param1ArrayOfint[0] + 4;
}
public void emit(byte[] param1ArrayOfbyte) {
param1ArrayOfbyte[this.myOffset + 0] = (byte)(this.value >>> 24 & 0xFF);
param1ArrayOfbyte[this.myOffset + 1] = (byte)(this.value >>> 16 & 0xFF);
param1ArrayOfbyte[this.myOffset + 2] = (byte)(this.value >>> 8 & 0xFF);
param1ArrayOfbyte[this.myOffset + 3] = (byte)(this.value >>> 0 & 0xFF);
}
}
protected static final class UInt24Item extends Item {
public int value;
public UInt24Item(int param1Int) {
this.value = param1Int;
}
public void increment(int[] param1ArrayOfint) {
super.increment(param1ArrayOfint);
param1ArrayOfint[0] = param1ArrayOfint[0] + 3;
}
public void emit(byte[] param1ArrayOfbyte) {
param1ArrayOfbyte[this.myOffset + 0] = (byte)(this.value >>> 16 & 0xFF);
param1ArrayOfbyte[this.myOffset + 1] = (byte)(this.value >>> 8 & 0xFF);
param1ArrayOfbyte[this.myOffset + 2] = (byte)(this.value >>> 0 & 0xFF);
}
}
protected static final class DictOffsetItem extends OffsetItem {
public final int size = 5;
public void increment(int[] param1ArrayOfint) {
super.increment(param1ArrayOfint);
param1ArrayOfint[0] = param1ArrayOfint[0] + this.size;
}
public void emit(byte[] param1ArrayOfbyte) {
if (this.size == 5) {
param1ArrayOfbyte[this.myOffset] = 29;
param1ArrayOfbyte[this.myOffset + 1] = (byte)(this.value >>> 24 & 0xFF);
param1ArrayOfbyte[this.myOffset + 2] = (byte)(this.value >>> 16 & 0xFF);
param1ArrayOfbyte[this.myOffset + 3] = (byte)(this.value >>> 8 & 0xFF);
param1ArrayOfbyte[this.myOffset + 4] = (byte)(this.value >>> 0 & 0xFF);
}
}
}
protected static final class SubrMarkerItem extends Item {
private CFFFont.OffsetItem offItem;
private CFFFont.IndexBaseItem indexBase;
public SubrMarkerItem(CFFFont.OffsetItem param1OffsetItem, CFFFont.IndexBaseItem param1IndexBaseItem) {
this.offItem = param1OffsetItem;
this.indexBase = param1IndexBaseItem;
}
public void xref() {
this.offItem.set(this.myOffset - this.indexBase.myOffset);
}
}
protected static final class IndexMarkerItem extends Item {
private CFFFont.OffsetItem offItem;
private CFFFont.IndexBaseItem indexBase;
public IndexMarkerItem(CFFFont.OffsetItem param1OffsetItem, CFFFont.IndexBaseItem param1IndexBaseItem) {
this.offItem = param1OffsetItem;
this.indexBase = param1IndexBaseItem;
}
public void xref() {
this.offItem.set(this.myOffset - this.indexBase.myOffset + 1);
}
}
protected static final class IndexBaseItem extends Item {}
protected static final class IndexOffsetItem extends OffsetItem {
public final int size;
public IndexOffsetItem(int param1Int1, int param1Int2) {
this.size = param1Int1;
this.value = param1Int2;
}
public IndexOffsetItem(int param1Int) {
this.size = param1Int;
}
public void increment(int[] param1ArrayOfint) {
super.increment(param1ArrayOfint);
param1ArrayOfint[0] = param1ArrayOfint[0] + this.size;
}
public void emit(byte[] param1ArrayOfbyte) {
int i = 0;
switch (this.size) {
case 4:
param1ArrayOfbyte[this.myOffset + i] = (byte)(this.value >>> 24 & 0xFF);
i++;
case 3:
param1ArrayOfbyte[this.myOffset + i] = (byte)(this.value >>> 16 & 0xFF);
i++;
case 2:
param1ArrayOfbyte[this.myOffset + i] = (byte)(this.value >>> 8 & 0xFF);
i++;
case 1:
param1ArrayOfbyte[this.myOffset + i] = (byte)(this.value >>> 0 & 0xFF);
i++;
break;
}
}
}
protected static final class RangeItem extends Item {
public int offset;
public int length;
private RandomAccessFileOrArray buf;
public RangeItem(RandomAccessFileOrArray param1RandomAccessFileOrArray, int param1Int1, int param1Int2) {
this.offset = param1Int1;
this.length = param1Int2;
this.buf = param1RandomAccessFileOrArray;
}
public void increment(int[] param1ArrayOfint) {
super.increment(param1ArrayOfint);
param1ArrayOfint[0] = param1ArrayOfint[0] + this.length;
}
public void emit(byte[] param1ArrayOfbyte) {
try {
this.buf.seek(this.offset);
for (int i = this.myOffset; i < this.myOffset + this.length; i++)
param1ArrayOfbyte[i] = this.buf.readByte();
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
}
protected static abstract class OffsetItem extends Item {
public int value;
public void set(int param1Int) {
this.value = param1Int;
}
}
protected static abstract class Item {
protected int myOffset = -1;
public void increment(int[] param1ArrayOfint) {
this.myOffset = param1ArrayOfint[0];
}
public void emit(byte[] param1ArrayOfbyte) {}
public void xref() {}
}
}

Some files were not shown because too many files have changed in this diff Show more