|
|
@ -60,17 +60,18 @@ import com.fr.third.v2.lowagie.text.pdf.PdfPCell; |
|
|
|
import com.fr.third.v2.lowagie.text.Phrase; |
|
|
|
import com.fr.third.v2.lowagie.text.Phrase; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* |
|
|
|
* @author psoares |
|
|
|
* @author psoares |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class IncCell implements TextElementArray { |
|
|
|
public class IncCell implements TextElementArray { |
|
|
|
|
|
|
|
|
|
|
|
private ArrayList chunks = new ArrayList(); |
|
|
|
private ArrayList chunks = new ArrayList(); |
|
|
|
private PdfPCell cell; |
|
|
|
private PdfPCell cell; |
|
|
|
|
|
|
|
|
|
|
|
/** Creates a new instance of IncCell */ |
|
|
|
/** |
|
|
|
|
|
|
|
* Creates a new instance of IncCell |
|
|
|
|
|
|
|
*/ |
|
|
|
public IncCell(String tag, ChainedProperties props) { |
|
|
|
public IncCell(String tag, ChainedProperties props) { |
|
|
|
cell = new PdfPCell((Phrase)null); |
|
|
|
cell = new PdfPCell((Phrase) null); |
|
|
|
String value = props.getProperty("colspan"); |
|
|
|
String value = props.getProperty("colspan"); |
|
|
|
if (value != null) |
|
|
|
if (value != null) |
|
|
|
cell.setColspan(Integer.parseInt(value)); |
|
|
|
cell.setColspan(Integer.parseInt(value)); |
|
|
@ -104,84 +105,87 @@ public class IncCell implements TextElementArray { |
|
|
|
if (value != null) |
|
|
|
if (value != null) |
|
|
|
cell.setPadding(CSSUtils.parseFloat(value)); |
|
|
|
cell.setPadding(CSSUtils.parseFloat(value)); |
|
|
|
cell.setUseDescender(true); |
|
|
|
cell.setUseDescender(true); |
|
|
|
value = props.getProperty("bgcolor"); |
|
|
|
|
|
|
|
cell.setBackgroundColor(Markup.decodeColor(value)); |
|
|
|
|
|
|
|
//解析td上声明的width
|
|
|
|
//解析td上声明的width
|
|
|
|
value = props.getLastChainProperty("width"); |
|
|
|
value = props.getLastChainProperty("width"); |
|
|
|
if(value != null){ |
|
|
|
if (value != null) { |
|
|
|
cell.setStyleWidth(CSSUtils.parseFloat(value)); |
|
|
|
cell.setStyleWidth(CSSUtils.parseFloat(value)); |
|
|
|
} |
|
|
|
} |
|
|
|
//解析td上声明的height
|
|
|
|
//解析td上声明的height
|
|
|
|
value = props.getLastChainProperty("height"); |
|
|
|
value = props.getLastChainProperty("height"); |
|
|
|
if(value != null){ |
|
|
|
if (value != null) { |
|
|
|
cell.setStyleHeight(CSSUtils.parseFloat(value)); |
|
|
|
cell.setStyleHeight(CSSUtils.parseFloat(value)); |
|
|
|
} |
|
|
|
} |
|
|
|
//解析background相关属性并保存到cell对象
|
|
|
|
//解析background相关属性并保存到cell对象
|
|
|
|
Map<String, String> backgroundRules = new HashMap<String, String>(); |
|
|
|
Map<String, String> backgroundRules = new HashMap<String, String>(); |
|
|
|
|
|
|
|
value = props.getProperty("bgcolor"); |
|
|
|
|
|
|
|
if (value != null) { |
|
|
|
|
|
|
|
backgroundRules.put("background-color", value); |
|
|
|
|
|
|
|
} |
|
|
|
value = props.getLastChainProperty("background-size"); |
|
|
|
value = props.getLastChainProperty("background-size"); |
|
|
|
if(value!=null){ |
|
|
|
if (value != null) { |
|
|
|
backgroundRules.put("background-size", value); |
|
|
|
backgroundRules.put("background-size", value); |
|
|
|
} |
|
|
|
} |
|
|
|
value = props.getLastChainProperty("background"); |
|
|
|
value = props.getLastChainProperty("background"); |
|
|
|
if(value!=null){ |
|
|
|
if (value != null) { |
|
|
|
Map<String, String> backgroundStyles = CSSUtils.processBackground(value); |
|
|
|
Map<String, String> backgroundStyles = CSSUtils.processBackground(value); |
|
|
|
backgroundRules.putAll(backgroundStyles); |
|
|
|
backgroundRules.putAll(backgroundStyles); |
|
|
|
} |
|
|
|
} |
|
|
|
value = props.getLastChainProperty("background-color"); |
|
|
|
value = props.getLastChainProperty("background-color"); |
|
|
|
if(value!=null){ |
|
|
|
if (value != null) { |
|
|
|
backgroundRules.put("background-color", value); |
|
|
|
backgroundRules.put("background-color", value); |
|
|
|
} |
|
|
|
} |
|
|
|
value = props.getLastChainProperty("background-position"); |
|
|
|
value = props.getLastChainProperty("background-position"); |
|
|
|
if(value!=null){ |
|
|
|
if (value != null) { |
|
|
|
backgroundRules.put("background-position", value); |
|
|
|
backgroundRules.put("background-position", value); |
|
|
|
} |
|
|
|
} |
|
|
|
value = props.getLastChainProperty("background-repeat"); |
|
|
|
value = props.getLastChainProperty("background-repeat"); |
|
|
|
if(value!=null){ |
|
|
|
if (value != null) { |
|
|
|
backgroundRules.put("background-repeat", value); |
|
|
|
backgroundRules.put("background-repeat", value); |
|
|
|
} |
|
|
|
} |
|
|
|
value = props.getLastChainProperty("background-image"); |
|
|
|
value = props.getLastChainProperty("background-image"); |
|
|
|
if(value!=null){ |
|
|
|
if (value != null) { |
|
|
|
backgroundRules.put("background-image", value); |
|
|
|
backgroundRules.put("background-image", value); |
|
|
|
} |
|
|
|
} |
|
|
|
cell.setBackground(backgroundRules); |
|
|
|
cell.setBackground(backgroundRules); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean add(Object o) { |
|
|
|
public boolean add(Object o) { |
|
|
|
if (!(o instanceof Element)) |
|
|
|
if (!(o instanceof Element)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
cell.addElement((Element)o); |
|
|
|
cell.addElement((Element) o); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ArrayList getChunks() { |
|
|
|
public ArrayList getChunks() { |
|
|
|
return chunks; |
|
|
|
return chunks; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean process(ElementListener listener) { |
|
|
|
public boolean process(ElementListener listener) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int type() { |
|
|
|
public int type() { |
|
|
|
return Element.RECTANGLE; |
|
|
|
return Element.RECTANGLE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public PdfPCell getCell() { |
|
|
|
public PdfPCell getCell() { |
|
|
|
return cell; |
|
|
|
return cell; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @see Element#isContent() |
|
|
|
|
|
|
|
* @since iText 2.0.8 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public boolean isContent() { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @see Element#isNestable() |
|
|
|
* @since iText 2.0.8 |
|
|
|
* @since iText 2.0.8 |
|
|
|
* @see Element#isContent() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean isNestable() { |
|
|
|
public boolean isContent() { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @since iText 2.0.8 |
|
|
|
|
|
|
|
* @see Element#isNestable() |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public boolean isNestable() { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |