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 */ /** the external font */
private BaseFont baseFont = null; private BaseFont baseFont = null;
private String fontName = "";
public String getFontName(){
return fontName;
}
// constructors // constructors
/** /**
@ -169,6 +177,13 @@ public class Font implements Comparable {
this.color = color; 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. * Constructs a Font.
* *
@ -337,31 +352,31 @@ public class Font implements Comparable {
public String getFamilyname() { public String getFamilyname() {
String tmp = "unknown"; String tmp = "unknown";
switch (getFamily()) { switch (getFamily()) {
case Font.COURIER: case Font.COURIER:
return FontFactory.COURIER; return FontFactory.COURIER;
case Font.HELVETICA: case Font.HELVETICA:
return FontFactory.HELVETICA; return FontFactory.HELVETICA;
case Font.TIMES_ROMAN: case Font.TIMES_ROMAN:
return FontFactory.TIMES_ROMAN; return FontFactory.TIMES_ROMAN;
case Font.SYMBOL: case Font.SYMBOL:
return FontFactory.SYMBOL; return FontFactory.SYMBOL;
case Font.ZAPFDINGBATS: case Font.ZAPFDINGBATS:
return FontFactory.ZAPFDINGBATS; return FontFactory.ZAPFDINGBATS;
default: default:
if (baseFont != null) { if (baseFont != null) {
String[][] names = baseFont.getFamilyFontName(); String[][] names = baseFont.getFamilyFontName();
for (int i = 0; i < names.length; i++) { for (int i = 0; i < names.length; i++) {
if ("0".equals(names[i][2])) { if ("0".equals(names[i][2])) {
return names[i][3]; return names[i][3];
} }
if ("1033".equals(names[i][2])) { if ("1033".equals(names[i][2])) {
tmp = names[i][3]; tmp = names[i][3];
} }
if ("".equals(names[i][2])) { if ("".equals(names[i][2])) {
tmp = names[i][3]; tmp = names[i][3];
}
} }
} }
}
} }
return tmp; return tmp;
} }
@ -652,68 +667,68 @@ public class Font implements Comparable {
String encoding = BaseFont.WINANSI; String encoding = BaseFont.WINANSI;
BaseFont cfont = null; BaseFont cfont = null;
switch (family) { switch (family) {
case COURIER: case COURIER:
switch (style & BOLDITALIC) { switch (style & BOLDITALIC) {
case BOLD: case BOLD:
fontName = BaseFont.COURIER_BOLD; fontName = BaseFont.COURIER_BOLD;
break; break;
case ITALIC: case ITALIC:
fontName = BaseFont.COURIER_OBLIQUE; fontName = BaseFont.COURIER_OBLIQUE;
break; break;
case BOLDITALIC: case BOLDITALIC:
fontName = BaseFont.COURIER_BOLDOBLIQUE; fontName = BaseFont.COURIER_BOLDOBLIQUE;
break; break;
default: default:
//case NORMAL: //case NORMAL:
fontName = BaseFont.COURIER; fontName = BaseFont.COURIER;
break; 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;
break; break;
} case TIMES_ROMAN:
break; switch (style & BOLDITALIC) {
case SYMBOL: case BOLD:
fontName = BaseFont.SYMBOL; fontName = BaseFont.TIMES_BOLD;
if (specialEncoding) break;
encoding = BaseFont.SYMBOL; case ITALIC:
break; fontName = BaseFont.TIMES_ITALIC;
case ZAPFDINGBATS: break;
fontName = BaseFont.ZAPFDINGBATS; case BOLDITALIC:
if (specialEncoding) fontName = BaseFont.TIMES_BOLDITALIC;
encoding = BaseFont.ZAPFDINGBATS; break;
break; default:
default: case NORMAL:
case Font.HELVETICA: fontName = BaseFont.TIMES_ROMAN;
switch (style & BOLDITALIC) { break;
case BOLD: }
fontName = BaseFont.HELVETICA_BOLD;
break; break;
case ITALIC: case SYMBOL:
fontName = BaseFont.HELVETICA_OBLIQUE; fontName = BaseFont.SYMBOL;
if (specialEncoding)
encoding = BaseFont.SYMBOL;
break; break;
case BOLDITALIC: case ZAPFDINGBATS:
fontName = BaseFont.HELVETICA_BOLDOBLIQUE; fontName = BaseFont.ZAPFDINGBATS;
if (specialEncoding)
encoding = BaseFont.ZAPFDINGBATS;
break; break;
default: default:
case NORMAL: case Font.HELVETICA:
fontName = BaseFont.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;
}
break;
} }
try { try {
cfont = BaseFont.createFont(fontName, encoding, false); 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 { public class Paragraph extends Phrase {
// constants // constants
private static final long serialVersionUID = 7852314969733375514L; private static final long serialVersionUID = 7852314969733375514L;
// membervariables // membervariables
/** The alignment of the text. */ /** The alignment of the text. */
protected int alignment = Element.ALIGN_UNDEFINED; protected int alignment = Element.ALIGN_UNDEFINED;
/** The text leading that is multiplied by the biggest font size in the line. */ /** 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. */ /** Does the paragraph has to be kept together on 1 page. */
protected boolean keeptogether = false; protected boolean keeptogether = false;
protected String background;
// constructors // constructors
/** /**
@ -193,15 +195,15 @@ public class Paragraph extends Phrase {
public Paragraph(Phrase phrase) { public Paragraph(Phrase phrase) {
super(phrase); super(phrase);
if (phrase instanceof Paragraph) { if (phrase instanceof Paragraph) {
Paragraph p = (Paragraph)phrase; Paragraph p = (Paragraph)phrase;
setAlignment(p.alignment); setAlignment(p.alignment);
setLeading(phrase.getLeading(), p.multipliedLeading); setLeading(phrase.getLeading(), p.multipliedLeading);
setIndentationLeft(p.getIndentationLeft()); setIndentationLeft(p.getIndentationLeft());
setIndentationRight(p.getIndentationRight()); setIndentationRight(p.getIndentationRight());
setFirstLineIndent(p.getFirstLineIndent()); setFirstLineIndent(p.getFirstLineIndent());
setSpacingAfter(p.spacingAfter()); setSpacingAfter(p.spacingAfter());
setSpacingBefore(p.spacingBefore()); setSpacingBefore(p.spacingBefore());
setExtraParagraphSpace(p.getExtraParagraphSpace()); setExtraParagraphSpace(p.getExtraParagraphSpace());
} }
} }
@ -239,11 +241,11 @@ public class Paragraph extends Phrase {
super.add(o); super.add(o);
java.util.List chunks = getChunks(); java.util.List chunks = getChunks();
if (!chunks.isEmpty()) { if (!chunks.isEmpty()) {
Chunk tmp = ((Chunk) chunks.get(chunks.size() - 1)); Chunk tmp = ((Chunk) chunks.get(chunks.size() - 1));
super.add(new Chunk("\n", tmp.getFont())); super.add(new Chunk("\n", tmp.getFont()));
} }
else { else {
super.add(Chunk.NEWLINE); super.add(Chunk.NEWLINE);
} }
return true; return true;
} }
@ -381,7 +383,7 @@ public class Paragraph extends Phrase {
// methods to retrieve information // methods to retrieve information
/** /**
* Gets the alignment of this paragraph. * Gets the alignment of this paragraph.
* *
* @return alignment * @return alignment
@ -407,15 +409,15 @@ public class Paragraph extends Phrase {
* @return the total leading (fixed and multiplied) * @return the total leading (fixed and multiplied)
*/ */
public float getTotalLeading() { public float getTotalLeading() {
float m = font == null ? float m = font == null ?
Font.DEFAULTSIZE * multipliedLeading : font.getCalculatedLeading(multipliedLeading); Font.DEFAULTSIZE * multipliedLeading : font.getCalculatedLeading(multipliedLeading);
if (m > 0 && !hasLeading()) { if (m > 0 && !hasLeading()) {
return m; return m;
} }
return getLeading() + m; return getLeading() + m;
} }
/** /**
* Gets the indentation of this paragraph on the left side. * Gets the indentation of this paragraph on the left side.
* *
* @return the indentation * @return the indentation
@ -424,11 +426,11 @@ public class Paragraph extends Phrase {
return indentationLeft; return indentationLeft;
} }
/** /**
* Gets the indentation of this paragraph on the right side. * Gets the indentation of this paragraph on the right side.
* *
* @return the indentation * @return the indentation
*/ */
public float getIndentationRight() { public float getIndentationRight() {
return indentationRight; return indentationRight;
} }
@ -447,7 +449,7 @@ public class Paragraph extends Phrase {
* @since 2.1.5 * @since 2.1.5
*/ */
public float getSpacingBefore() { public float getSpacingBefore() {
return spacingBefore; return spacingBefore;
} }
/** /**
@ -456,7 +458,7 @@ public class Paragraph extends Phrase {
* @since 2.1.5 * @since 2.1.5
*/ */
public float getSpacingAfter() { public float getSpacingAfter() {
return spacingAfter; return spacingAfter;
} }
/** /**
@ -499,4 +501,12 @@ public class Paragraph extends Phrase {
return spacingAfter; return spacingAfter;
} }
public void setBackground(String background){
this.background = background;
}
public String getBackground(){
return this.background;
}
} }
Loading…
Cancel
Save