Browse Source

Merge pull request #130 in CORE/base-third from ~KERRY/base-third:feature/10.0 to feature/10.0

* commit '2120b035a533ffb36f4f87cbcc9b5f5d56d54fa0':
  无
  REPORT-11624 Excel和Word导出的html解析支持
research/11.0
ju 6 years ago
parent
commit
0d949530a7
  1. 173
      fine-itext-old/src/com/fr/third/com/lowagie/text/Font.java
  2. 70
      fine-itext-old/src/com/fr/third/com/lowagie/text/Paragraph.java

173
fine-itext-old/src/com/fr/third/com/lowagie/text/Font.java

@ -133,6 +133,14 @@ public class Font implements Comparable {
/** the external font */
private BaseFont baseFont = null;
private String fontName = "";
public String getFontName(){
return fontName;
}
// constructors
/**
@ -169,6 +177,13 @@ public class Font implements Comparable {
this.color = color;
}
public Font(String face, float size, int style, Color color) {
this.fontName = face;
this.size =size;
this.style = style;
this.color = color;
}
/**
* Constructs a Font.
*
@ -337,31 +352,31 @@ public class Font implements Comparable {
public String getFamilyname() {
String tmp = "unknown";
switch (getFamily()) {
case Font.COURIER:
return FontFactory.COURIER;
case Font.HELVETICA:
return FontFactory.HELVETICA;
case Font.TIMES_ROMAN:
return FontFactory.TIMES_ROMAN;
case Font.SYMBOL:
return FontFactory.SYMBOL;
case Font.ZAPFDINGBATS:
return FontFactory.ZAPFDINGBATS;
default:
if (baseFont != null) {
String[][] names = baseFont.getFamilyFontName();
for (int i = 0; i < names.length; i++) {
if ("0".equals(names[i][2])) {
return names[i][3];
}
if ("1033".equals(names[i][2])) {
tmp = names[i][3];
}
if ("".equals(names[i][2])) {
tmp = names[i][3];
case Font.COURIER:
return FontFactory.COURIER;
case Font.HELVETICA:
return FontFactory.HELVETICA;
case Font.TIMES_ROMAN:
return FontFactory.TIMES_ROMAN;
case Font.SYMBOL:
return FontFactory.SYMBOL;
case Font.ZAPFDINGBATS:
return FontFactory.ZAPFDINGBATS;
default:
if (baseFont != null) {
String[][] names = baseFont.getFamilyFontName();
for (int i = 0; i < names.length; i++) {
if ("0".equals(names[i][2])) {
return names[i][3];
}
if ("1033".equals(names[i][2])) {
tmp = names[i][3];
}
if ("".equals(names[i][2])) {
tmp = names[i][3];
}
}
}
}
}
return tmp;
}
@ -652,68 +667,68 @@ public class Font implements Comparable {
String encoding = BaseFont.WINANSI;
BaseFont cfont = null;
switch (family) {
case COURIER:
switch (style & BOLDITALIC) {
case BOLD:
fontName = BaseFont.COURIER_BOLD;
break;
case ITALIC:
fontName = BaseFont.COURIER_OBLIQUE;
break;
case BOLDITALIC:
fontName = BaseFont.COURIER_BOLDOBLIQUE;
break;
default:
//case NORMAL:
fontName = BaseFont.COURIER;
break;
}
break;
case TIMES_ROMAN:
switch (style & BOLDITALIC) {
case BOLD:
fontName = BaseFont.TIMES_BOLD;
break;
case ITALIC:
fontName = BaseFont.TIMES_ITALIC;
break;
case BOLDITALIC:
fontName = BaseFont.TIMES_BOLDITALIC;
break;
default:
case NORMAL:
fontName = BaseFont.TIMES_ROMAN;
case COURIER:
switch (style & BOLDITALIC) {
case BOLD:
fontName = BaseFont.COURIER_BOLD;
break;
case ITALIC:
fontName = BaseFont.COURIER_OBLIQUE;
break;
case BOLDITALIC:
fontName = BaseFont.COURIER_BOLDOBLIQUE;
break;
default:
//case NORMAL:
fontName = BaseFont.COURIER;
break;
}
break;
}
break;
case SYMBOL:
fontName = BaseFont.SYMBOL;
if (specialEncoding)
encoding = BaseFont.SYMBOL;
break;
case ZAPFDINGBATS:
fontName = BaseFont.ZAPFDINGBATS;
if (specialEncoding)
encoding = BaseFont.ZAPFDINGBATS;
break;
default:
case Font.HELVETICA:
switch (style & BOLDITALIC) {
case BOLD:
fontName = BaseFont.HELVETICA_BOLD;
case TIMES_ROMAN:
switch (style & BOLDITALIC) {
case BOLD:
fontName = BaseFont.TIMES_BOLD;
break;
case ITALIC:
fontName = BaseFont.TIMES_ITALIC;
break;
case BOLDITALIC:
fontName = BaseFont.TIMES_BOLDITALIC;
break;
default:
case NORMAL:
fontName = BaseFont.TIMES_ROMAN;
break;
}
break;
case ITALIC:
fontName = BaseFont.HELVETICA_OBLIQUE;
case SYMBOL:
fontName = BaseFont.SYMBOL;
if (specialEncoding)
encoding = BaseFont.SYMBOL;
break;
case BOLDITALIC:
fontName = BaseFont.HELVETICA_BOLDOBLIQUE;
case ZAPFDINGBATS:
fontName = BaseFont.ZAPFDINGBATS;
if (specialEncoding)
encoding = BaseFont.ZAPFDINGBATS;
break;
default:
case NORMAL:
fontName = BaseFont.HELVETICA;
case Font.HELVETICA:
switch (style & BOLDITALIC) {
case BOLD:
fontName = BaseFont.HELVETICA_BOLD;
break;
case ITALIC:
fontName = BaseFont.HELVETICA_OBLIQUE;
break;
case BOLDITALIC:
fontName = BaseFont.HELVETICA_BOLDOBLIQUE;
break;
default:
case NORMAL:
fontName = BaseFont.HELVETICA;
break;
}
break;
}
break;
}
try {
cfont = BaseFont.createFont(fontName, encoding, false);

70
fine-itext-old/src/com/fr/third/com/lowagie/text/Paragraph.java

@ -72,12 +72,12 @@ package com.fr.third.com.lowagie.text;
public class Paragraph extends Phrase {
// constants
private static final long serialVersionUID = 7852314969733375514L;
// constants
private static final long serialVersionUID = 7852314969733375514L;
// membervariables
/** The alignment of the text. */
/** The alignment of the text. */
protected int alignment = Element.ALIGN_UNDEFINED;
/** The text leading that is multiplied by the biggest font size in the line. */
@ -104,6 +104,8 @@ public class Paragraph extends Phrase {
/** Does the paragraph has to be kept together on 1 page. */
protected boolean keeptogether = false;
protected String background;
// constructors
/**
@ -193,15 +195,15 @@ public class Paragraph extends Phrase {
public Paragraph(Phrase phrase) {
super(phrase);
if (phrase instanceof Paragraph) {
Paragraph p = (Paragraph)phrase;
setAlignment(p.alignment);
setLeading(phrase.getLeading(), p.multipliedLeading);
setIndentationLeft(p.getIndentationLeft());
setIndentationRight(p.getIndentationRight());
setFirstLineIndent(p.getFirstLineIndent());
setSpacingAfter(p.spacingAfter());
setSpacingBefore(p.spacingBefore());
setExtraParagraphSpace(p.getExtraParagraphSpace());
Paragraph p = (Paragraph)phrase;
setAlignment(p.alignment);
setLeading(phrase.getLeading(), p.multipliedLeading);
setIndentationLeft(p.getIndentationLeft());
setIndentationRight(p.getIndentationRight());
setFirstLineIndent(p.getFirstLineIndent());
setSpacingAfter(p.spacingAfter());
setSpacingBefore(p.spacingBefore());
setExtraParagraphSpace(p.getExtraParagraphSpace());
}
}
@ -239,11 +241,11 @@ public class Paragraph extends Phrase {
super.add(o);
java.util.List chunks = getChunks();
if (!chunks.isEmpty()) {
Chunk tmp = ((Chunk) chunks.get(chunks.size() - 1));
super.add(new Chunk("\n", tmp.getFont()));
Chunk tmp = ((Chunk) chunks.get(chunks.size() - 1));
super.add(new Chunk("\n", tmp.getFont()));
}
else {
super.add(Chunk.NEWLINE);
super.add(Chunk.NEWLINE);
}
return true;
}
@ -381,7 +383,7 @@ public class Paragraph extends Phrase {
// methods to retrieve information
/**
/**
* Gets the alignment of this paragraph.
*
* @return alignment
@ -407,15 +409,15 @@ public class Paragraph extends Phrase {
* @return the total leading (fixed and multiplied)
*/
public float getTotalLeading() {
float m = font == null ?
Font.DEFAULTSIZE * multipliedLeading : font.getCalculatedLeading(multipliedLeading);
if (m > 0 && !hasLeading()) {
return m;
}
return getLeading() + m;
float m = font == null ?
Font.DEFAULTSIZE * multipliedLeading : font.getCalculatedLeading(multipliedLeading);
if (m > 0 && !hasLeading()) {
return m;
}
return getLeading() + m;
}
/**
/**
* Gets the indentation of this paragraph on the left side.
*
* @return the indentation
@ -424,11 +426,11 @@ public class Paragraph extends Phrase {
return indentationLeft;
}
/**
* Gets the indentation of this paragraph on the right side.
*
* @return the indentation
*/
/**
* Gets the indentation of this paragraph on the right side.
*
* @return the indentation
*/
public float getIndentationRight() {
return indentationRight;
}
@ -447,7 +449,7 @@ public class Paragraph extends Phrase {
* @since 2.1.5
*/
public float getSpacingBefore() {
return spacingBefore;
return spacingBefore;
}
/**
@ -456,7 +458,7 @@ public class Paragraph extends Phrase {
* @since 2.1.5
*/
public float getSpacingAfter() {
return spacingAfter;
return spacingAfter;
}
/**
@ -499,4 +501,12 @@ public class Paragraph extends Phrase {
return spacingAfter;
}
public void setBackground(String background){
this.background = background;
}
public String getBackground(){
return this.background;
}
}
Loading…
Cancel
Save