From 645159f9a34097a34281135b698c9a5201ce83ce Mon Sep 17 00:00:00 2001 From: kerry Date: Fri, 25 Jan 2019 16:33:06 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-14108=20=E9=A2=84=E8=A7=88=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../text/html/simpleparser/IncTable.java | 3 +- .../v2/lowagie/text/pdf/BorderStyle.java | 28 +++++++++++++------ .../v2/lowagie/text/pdf/TableProperties.java | 6 ++-- 3 files changed, 26 insertions(+), 11 deletions(-) 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 65d14246e..2ea2a07f1 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 @@ -176,7 +176,8 @@ public class IncTable { tableProperties.setBorderStyle(borderStyle); String value = (String)props.get("border"); if(value != null){ - borderStyle.setBorderWidth(CSSUtils.parseFloat(value)); + borderStyle.parseBorderStyle(value); + } value = (String)props.get("border-color"); if(value != null){ diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/BorderStyle.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/BorderStyle.java index 9a03750f9..78af3629d 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/BorderStyle.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/BorderStyle.java @@ -1,6 +1,5 @@ package com.fr.third.v2.lowagie.text.pdf; -import com.fr.third.v2.lowagie.text.DocumentException; import com.fr.third.v2.lowagie.text.html.CSSUtils; import com.fr.third.v2.lowagie.text.html.Markup; @@ -10,6 +9,10 @@ public class BorderStyle { private float borderWidth = 0.0f; private Color borderColor = Color.black; private String borderPattern = "solid"; + //形如 border:1px + private static final int BORDER_WIDTH = 1; + //形如 border:1px solid black + private static final int BORDER_PROPERTY = 3; public float getBorderWidth() { return borderWidth; @@ -42,17 +45,26 @@ public class BorderStyle { public BorderStyle(int borderWidth, String borderPattern, Color borderColor) { this.borderWidth = borderWidth; this.borderPattern = borderPattern; - this.borderWidth = borderWidth; + this.borderColor = borderColor; } - public static BorderStyle parseBorderStyle(String borderString) throws DocumentException { - BorderStyle borderStyle = new BorderStyle(); + public void parseBorderStyle(String borderString) { String[] borderPros = borderString.split(" "); - borderStyle.setBorderWidth(CSSUtils.parseFloat(borderPros[0])); - borderStyle.setBorderPattern(borderPros[1]); - borderStyle.setBorderColor(Markup.decodeColor(borderPros[2])); - return borderStyle; + switch (borderPros.length) { + case BORDER_WIDTH: + this.setBorderWidth(CSSUtils.parseFloat(borderPros[0])); + break; + case BORDER_PROPERTY: + this.setBorderWidth(CSSUtils.parseFloat(borderPros[0])); + this.setBorderPattern(borderPros[1]); + this.setBorderColor(Markup.decodeColor(borderPros[2])); + break; + default: + break; + } + } } + 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 2c7629908..fa1c7de0b 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 @@ -44,8 +44,10 @@ public class TableProperties { public String toHtmlString(){ StringBuffer sb = new StringBuffer(); - sb.append("cellspacing").append("=").append(cellspacing).append(" "); - sb.append("cellpadding").append("=").append(cellpadding).append(" "); + if(!isCollapse()){ + sb.append("cellspacing").append("=").append(cellspacing).append(" "); + sb.append("cellpadding").append("=").append(cellpadding).append(" "); + } sb.append("border").append("=").append(borderStyle.getBorderWidth()).append(" "); return sb.toString(); }