Browse Source

Merge pull request #1 in ~ABBY/base-third from final/10.0 to persist/10.0

* commit '26a882c24e6674f9c792e8b9316f53ba08fb5295':
  REPORT-29490 安全漏洞by zack
  REPORT-29784 third删减引起定时调度失败
  REPORT-27284 table解析导出PDF后 单元格背景、边框与预览不一致
  DEC-12783 【迭代】迁移db2数据库后,多语言插件添加key失败
  REPORT-29126 导出pdf,字体加粗效果没有了(漏提)
  REPORT-29126 导出pdf,字体加粗效果没有了
  暂时兼容旧版本新引擎插件
qufenxi
Abby 4 years ago
parent
commit
56df67b0ff
  1. 3
      fine-commons-codec/src/org/apache/commons/codec/digest/DigestUtils.java
  2. 15
      fine-hibernate/src/com/fr/third/org/hibernate/cfg/annotations/SimpleValueBinder.java
  3. 48
      fine-itext/src/com/fr/third/v2/lowagie/text/html/Utils/BackgroundUtil.java
  4. 33
      fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncCell.java
  5. 21
      fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java
  6. 6
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPTable.java
  7. 15
      fine-itext/src/com/fr/third/v2/lowagie/text/pdf/TableProperties.java
  8. 6
      fine-third-default/fine-sjsxp/src/main/java/com/fr/third/javax/xml/stream/XMLEntityManager.java

3
fine-commons-codec/src/org/apache/commons/codec/digest/DigestUtils.java

@ -9,4 +9,7 @@ public class DigestUtils {
public static String sha1Hex(String data) {
return com.fr.third.org.apache.commons.codec.digest.DigestUtils.sha1Hex(data);
}
public static String md5Hex(String data) {
return com.fr.third.org.apache.commons.codec.digest.DigestUtils.md5Hex(data);
}
}

15
fine-hibernate/src/com/fr/third/org/hibernate/cfg/annotations/SimpleValueBinder.java

@ -54,6 +54,7 @@ import com.fr.third.org.hibernate.type.PrimitiveCharacterArrayNClobType;
import com.fr.third.org.hibernate.type.SerializableToBlobType;
import com.fr.third.org.hibernate.type.StandardBasicTypes;
import com.fr.third.org.hibernate.type.StringNVarcharType;
import com.fr.third.org.hibernate.type.StringType;
import com.fr.third.org.hibernate.type.WrappedMaterializedBlobType;
import com.fr.third.org.hibernate.usertype.DynamicParameterizedType;
@ -89,6 +90,14 @@ public class SimpleValueBinder {
private AttributeConverterDescriptor attributeConverterDescriptor;
private static String DRIVER_CLASS;
private static final String DB2_PREFIX = "db2";
public static void setDriverClass(String driverClass) {
DRIVER_CLASS = driverClass;
}
public void setReferencedEntityName(String referencedEntityName) {
this.referencedEntityName = referencedEntityName;
}
@ -278,7 +287,7 @@ public class SimpleValueBinder {
else if ( isNationalized ) {
if ( buildingContext.getBuildingOptions().getReflectionManager().equals( returnedClassOrElement, String.class ) ) {
// nvarchar
type = StringNVarcharType.INSTANCE.getName();
type = DRIVER_CLASS != null && DRIVER_CLASS.contains(DB2_PREFIX) ? StringType.INSTANCE.getName() : StringNVarcharType.INSTANCE.getName();
explicitType = type;
}
else if ( buildingContext.getBuildingOptions().getReflectionManager().equals( returnedClassOrElement, Character.class ) ||
@ -454,7 +463,7 @@ public class SimpleValueBinder {
public void fillSimpleValue() {
LOG.debugf( "Starting fillSimpleValue for %s", propertyName );
if ( attributeConverterDescriptor != null ) {
if ( ! BinderHelper.isEmptyAnnotationValue( explicitType ) ) {
throw new AnnotationException(
@ -531,7 +540,7 @@ public class SimpleValueBinder {
if ( timeStampVersionType != null ) {
simpleValue.setTypeName( timeStampVersionType );
}
if ( simpleValue.getTypeName() != null && simpleValue.getTypeName().length() > 0
&& simpleValue.getMetadata().getTypeResolver().basic( simpleValue.getTypeName() ) == null ) {
try {

48
fine-itext/src/com/fr/third/v2/lowagie/text/html/Utils/BackgroundUtil.java

@ -0,0 +1,48 @@
package com.fr.third.v2.lowagie.text.html.Utils;
import com.fr.third.v2.lowagie.text.html.CSSUtils;
import com.fr.third.v2.lowagie.text.html.simpleparser.ChainedProperties;
import java.util.HashMap;
import java.util.Map;
/**
* @author Hugh.C
* @version 1.0
* Created by Hugh.C on 2020/2/26
*/
public class BackgroundUtil {
public static Map<String, String> parse2RulesMap(ChainedProperties props) {
Map<String, String> backgroundRules = new HashMap<String, String>();
String value = props.getProperty("bgcolor");
if (value != null) {
backgroundRules.put("background-color", value);
}
value = props.getLastChainProperty("background-size");
if (value != null) {
backgroundRules.put("background-size", value);
}
value = props.getLastChainProperty("background");
if (value != null) {
Map<String, String> backgroundStyles = CSSUtils.processBackground(value);
backgroundRules.putAll(backgroundStyles);
}
value = props.getLastChainProperty("background-color");
if (value != null) {
backgroundRules.put("background-color", value);
}
value = props.getLastChainProperty("background-position");
if (value != null) {
backgroundRules.put("background-position", value);
}
value = props.getLastChainProperty("background-repeat");
if (value != null) {
backgroundRules.put("background-repeat", value);
}
value = props.getLastChainProperty("background-image");
if (value != null) {
backgroundRules.put("background-image", value);
}
return backgroundRules;
}
}

33
fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncCell.java

@ -47,6 +47,7 @@
package com.fr.third.v2.lowagie.text.html.simpleparser;
import com.fr.third.v2.lowagie.text.html.Utils.BackgroundUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@ -117,37 +118,7 @@ public class IncCell implements TextElementArray {
cell.setStyleHeight(CSSUtils.parseFloat(value));
}
//解析background相关属性并保存到cell对象
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");
if (value != null) {
backgroundRules.put("background-size", value);
}
value = props.getLastChainProperty("background");
if (value != null) {
Map<String, String> backgroundStyles = CSSUtils.processBackground(value);
backgroundRules.putAll(backgroundStyles);
}
value = props.getLastChainProperty("background-color");
if (value != null) {
backgroundRules.put("background-color", value);
}
value = props.getLastChainProperty("background-position");
if (value != null) {
backgroundRules.put("background-position", value);
}
value = props.getLastChainProperty("background-repeat");
if (value != null) {
backgroundRules.put("background-repeat", value);
}
value = props.getLastChainProperty("background-image");
if (value != null) {
backgroundRules.put("background-image", value);
}
cell.setBackground(backgroundRules);
cell.setBackground(BackgroundUtil.parse2RulesMap(props));
}
public boolean add(Object o) {

21
fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java

@ -47,6 +47,8 @@
package com.fr.third.v2.lowagie.text.html.simpleparser;
import com.fr.third.v2.lowagie.text.html.HtmlTags;
import com.fr.third.v2.lowagie.text.html.Utils.BackgroundUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -174,12 +176,12 @@ public class IncTable {
}
for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) {
ArrayList cols = (ArrayList) rows.get(rowIndex);
for (int colIndex = 0; colIndex < cols.size(); colIndex++) {
int colSpan = 1;
for (int colIndex = 0; colIndex < cols.size(); colIndex+=colSpan) {
PdfPCell pCell = ((PdfPCell) cols.get(colIndex));
int cellCols = pCell.getColspan();
float avgWidth = pCell.getStyleWidth() / cellCols;
for (int i = 0; i < cellCols && colIndex + i < colCount; i++) {
colSpan = pCell.getColspan();
float avgWidth = pCell.getStyleWidth() / colSpan;
for (int i = 0; i < colSpan && colIndex + i < colCount; i++) {
if (relativeColWidths.get(colIndex + i) < avgWidth) {
relativeColWidths.set(colIndex + i, avgWidth);
}
@ -271,6 +273,11 @@ public class IncTable {
if(value != null){
borderStyle.setBorderColor(Markup.decodeColor(value));
}
value = (String) props.get("bordercolor");
if (value != null) {
borderStyle.setBorderColor(Markup.decodeColor(value));
}
value = (String)props.get("border-collapse");
if(value != null){
tableProperties.setCollapse(value.equals("collapse"));
@ -283,6 +290,10 @@ public class IncTable {
if(value != null){
tableProperties.setCellpadding(CSSUtils.parseFloat(value));
}
ChainedProperties properties = new ChainedProperties();
properties.addToChain(HtmlTags.TABLE, props);
//解析background相关属性
tableProperties.setBackground(BackgroundUtil.parse2RulesMap(properties));
return tableProperties;
}
}

6
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPTable.java

@ -350,8 +350,7 @@ public class PdfPTable implements LargeElement {
return;
float total = 0;
int numCols = getNumberOfColumns();
BorderStyle borderStyle = tableProperties.getBorderStyle();
float borderWidth = tableProperties.isCollapse() ? borderStyle.getBorderWidth() / 2 : borderStyle.getBorderWidth();
float borderWidth = tableProperties.getBorderWidth();
float cellspacing = tableProperties.getCellspacing();
float cellpadding = tableProperties.getCellpadding();
for (int k = 0; k < numCols; ++k)
@ -435,8 +434,7 @@ public class PdfPTable implements LargeElement {
if (totalWidth <= 0)
return 0;
totalHeight = 0;
BorderStyle borderStyle = tableProperties.getBorderStyle();
float borderWidth = tableProperties.isCollapse() ? borderStyle.getBorderWidth() / 2 : borderStyle.getBorderWidth();
float borderWidth = tableProperties.getBorderWidth();
float cellspacing = tableProperties.getCellspacing();
float cellpadding = tableProperties.getCellpadding();
for (int k = 0; k < rows.size(); ++k) {

15
fine-itext/src/com/fr/third/v2/lowagie/text/pdf/TableProperties.java

@ -1,5 +1,7 @@
package com.fr.third.v2.lowagie.text.pdf;
import java.util.Map;
/**
* 描述table的属性类
* 包括cellspacingcellpaddingborder等
@ -9,11 +11,16 @@ public class TableProperties {
private float cellspacing = 2.0f;
private float cellpadding = 1.0f;
private boolean collapse = false;
public Map<String, String> background;
public BorderStyle getBorderStyle() {
return borderStyle;
}
public float getBorderWidth() {
return 0 == getCellspacing() ? borderStyle.getBorderWidth() / 2 : borderStyle.getBorderWidth();
}
public void setBorderStyle(BorderStyle borderStyle) {
this.borderStyle = borderStyle;
}
@ -42,6 +49,14 @@ public class TableProperties {
this.collapse = collapse;
}
public Map<String, String> getBackground() {
return background;
}
public void setBackground(Map<String, String> background) {
this.background = background;
}
public String toHtmlString(){
StringBuffer sb = new StringBuffer();
if(!isCollapse()){

6
fine-third-default/fine-sjsxp/src/main/java/com/fr/third/javax/xml/stream/XMLEntityManager.java

@ -443,7 +443,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
} // setEntityHandler(XMLEntityHandler)
//this function returns StaxXMLInputSource
public StaxXMLInputSource resolveEntityAsPerStax(XMLResourceIdentifier resourceIdentifier) throws java.io.IOException{
public StaxXMLInputSource resolveEntityAsPerStax(XMLResourceIdentifier resourceIdentifier) throws IOException{
if(resourceIdentifier == null ) return null;
@ -976,8 +976,8 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
fEntityStack.removeAllElements();
fCurrentEntity = null;
fValidation = false;
fExternalGeneralEntities = true;
fExternalParameterEntities = true;
fExternalGeneralEntities = false;
fExternalParameterEntities = false;
fAllowJavaEncodings = true ;
//test();

Loading…
Cancel
Save