diff --git a/fine-commons-codec/src/org/apache/commons/codec/digest/DigestUtils.java b/fine-commons-codec/src/org/apache/commons/codec/digest/DigestUtils.java index cf40b1cc8..517c509e0 100644 --- a/fine-commons-codec/src/org/apache/commons/codec/digest/DigestUtils.java +++ b/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); + } } diff --git a/fine-hibernate/src/com/fr/third/org/hibernate/cfg/annotations/SimpleValueBinder.java b/fine-hibernate/src/com/fr/third/org/hibernate/cfg/annotations/SimpleValueBinder.java index c80d9f1c1..3251b86e6 100644 --- a/fine-hibernate/src/com/fr/third/org/hibernate/cfg/annotations/SimpleValueBinder.java +++ b/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 { diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/Utils/BackgroundUtil.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/Utils/BackgroundUtil.java new file mode 100644 index 000000000..61c0ce452 --- /dev/null +++ b/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 parse2RulesMap(ChainedProperties props) { + Map backgroundRules = new HashMap(); + 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 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; + } +} diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncCell.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncCell.java index 6e0597921..8b8318bb1 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncCell.java +++ b/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 backgroundRules = new HashMap(); - 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 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) { diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java index 9c99d6370..0e99b6d65 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/IncTable.java +++ b/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; } } diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPTable.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPTable.java index 199d21d6f..38d9a250f 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPTable.java +++ b/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) { diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/TableProperties.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/TableProperties.java index fa1c7de0b..a886f136e 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/TableProperties.java +++ b/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的属性类 * 包括cellspacing、cellpadding、border等 @@ -9,11 +11,16 @@ public class TableProperties { private float cellspacing = 2.0f; private float cellpadding = 1.0f; private boolean collapse = false; + public Map 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 getBackground() { + return background; + } + + public void setBackground(Map background) { + this.background = background; + } + public String toHtmlString(){ StringBuffer sb = new StringBuffer(); if(!isCollapse()){ diff --git a/fine-third-default/fine-sjsxp/src/main/java/com/fr/third/javax/xml/stream/XMLEntityManager.java b/fine-third-default/fine-sjsxp/src/main/java/com/fr/third/javax/xml/stream/XMLEntityManager.java index 334eeddbf..341ac472f 100644 --- a/fine-third-default/fine-sjsxp/src/main/java/com/fr/third/javax/xml/stream/XMLEntityManager.java +++ b/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();