From f2530a0fa4efceadf41a1027b16ebaf9f80e7e0e Mon Sep 17 00:00:00 2001 From: Harrison Date: Fri, 11 Oct 2019 10:31:11 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E6=97=A0=20jira=20=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=EF=BC=8CBUGFIX=20=E6=81=A2=E5=A4=8D=E5=88=86=E6=94=AF=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.third_step0.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.third_step0.gradle b/build.third_step0.gradle index 56bac7b72..613285ac6 100644 --- a/build.third_step0.gradle +++ b/build.third_step0.gradle @@ -41,7 +41,7 @@ def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf (java.io.File.s def branchName=buildDir.substring(buildDir.lastIndexOf (java.io.File.separator)+1) def srcDir="." -def maven_version="${version}-FINAL-SNAPSHOT" +def maven_version="${version}-BUGFIX-SNAPSHOT" def jar_version = version configurations { From f28b8a2c4e774b8a831ef10ef68d963905d804da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Mon, 14 Oct 2019 16:14:41 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20inux?= =?UTF-8?q?=E4=B8=8B=E7=BC=BA=E5=A4=B1=E4=BA=86=E7=B3=BB=E7=BB=9F=E4=BE=9B?= =?UTF-8?q?=E5=BA=94=E5=95=86=E4=BF=A1=E6=81=AF=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BC=9A=E5=AF=BC=E8=87=B4=E6=A0=88=E6=BA=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java b/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java index 510bee075..8fa7868d0 100644 --- a/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java +++ b/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java @@ -125,7 +125,9 @@ public class PlatformDetector { return "google"; } - throw new UnsatisfiedLinkError("Unsupported vendor: " + getName()); + //如果if条件全部不符合,就会陷入死循环,代码存在风险 + //throw new UnsatisfiedLinkError("Unsupported vendor: " + getName()); + return ""; } private static String getLinuxOsReleaseId() { @@ -144,7 +146,9 @@ public class PlatformDetector { return parseLinuxRedhatReleaseFile(file); } - throw new UnsatisfiedLinkError("Unsupported linux vendor: " + getName()); + //linux系统下如果缺失/etc/os-release,/usr/lib/os-release,/etc/redhat-release三个文件,就会和getName方法就会一直互相调用 + //throw new UnsatisfiedLinkError("Unsupported linux vendor: " + getName()); + return ""; } private static String parseLinuxOsReleaseFile(final File file) { From 4bbacd1f41c52bb23c37dd06ba65adc481875a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Mon, 14 Oct 2019 16:22:40 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java b/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java index 8fa7868d0..dcc0834d4 100644 --- a/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java +++ b/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java @@ -127,7 +127,7 @@ public class PlatformDetector { //如果if条件全部不符合,就会陷入死循环,代码存在风险 //throw new UnsatisfiedLinkError("Unsupported vendor: " + getName()); - return ""; + return StringUtils.EMPTY; } private static String getLinuxOsReleaseId() { @@ -148,7 +148,7 @@ public class PlatformDetector { //linux系统下如果缺失/etc/os-release,/usr/lib/os-release,/etc/redhat-release三个文件,就会和getName方法就会一直互相调用 //throw new UnsatisfiedLinkError("Unsupported linux vendor: " + getName()); - return ""; + return StringUtils.EMPTY; } private static String parseLinuxOsReleaseFile(final File file) { From 3465415e0a235522d325dff8900ec44d34cd40a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 15 Oct 2019 09:26:40 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20?= =?UTF-8?q?=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java b/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java index dcc0834d4..643f57c7c 100644 --- a/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java +++ b/fine-j2v8/src/com/eclipsesource/v8/PlatformDetector.java @@ -127,7 +127,7 @@ public class PlatformDetector { //如果if条件全部不符合,就会陷入死循环,代码存在风险 //throw new UnsatisfiedLinkError("Unsupported vendor: " + getName()); - return StringUtils.EMPTY; + return null; } private static String getLinuxOsReleaseId() { @@ -148,7 +148,7 @@ public class PlatformDetector { //linux系统下如果缺失/etc/os-release,/usr/lib/os-release,/etc/redhat-release三个文件,就会和getName方法就会一直互相调用 //throw new UnsatisfiedLinkError("Unsupported linux vendor: " + getName()); - return StringUtils.EMPTY; + return null; } private static String parseLinuxOsReleaseFile(final File file) { From de740d5754cab495e6d8ccd894f33b5fffb2cf77 Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Thu, 31 Oct 2019 14:30:21 +0800 Subject: [PATCH 05/15] =?UTF-8?q?REPORT-23453=20html=E5=88=87=E5=89=B2?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E4=B8=A2=E5=A4=B1
=20=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third/v2/lowagie/text/pdf/PdfChunk.java | 157 ++++++++++-------- .../fr/third/v2/lowagie/text/pdf/PdfLine.java | 14 +- 2 files changed, 97 insertions(+), 74 deletions(-) diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java index f5b67439a..8d014cd80 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java @@ -88,6 +88,12 @@ public class PdfChunk { private static final float FONT_SCALE = 100f; + private static final String BREAK = "\n"; + + private static final String BREAK_TAG = "
"; + + private boolean breakTag = false; + public float getHeight() { return height; } @@ -135,16 +141,16 @@ public class PdfChunk { keysNoStroke.put(Chunk.TEXTRENDERMODE, null); } - + // membervariables /** The value of this object. */ protected String value = PdfObject.NOTHING; - + /** The encoding. */ protected String encoding = BaseFont.WINANSI; - - + + /** The font for this PdfChunk. */ protected PdfFont font; @@ -164,7 +170,7 @@ public class PdfChunk { * such as underline. */ protected HashMap attributes = new HashMap(); - + /** * Non metric attributes. *

@@ -172,16 +178,16 @@ public class PdfChunk { * such as Color. */ protected HashMap noStroke = new HashMap(); - + /** true if the chunk split was cause by a newline. */ protected boolean newlineSplit; - + /** The image in this PdfChunk, if it has one */ protected Image image; - + /** The offset in the x direction for the image */ protected float offsetX; - + /** The offset in the y direction for the image */ protected float offsetY; @@ -189,17 +195,18 @@ public class PdfChunk { protected boolean changeLeading = false; // constructors - + /** * Constructs a PdfChunk-object. * * @param string the content of the PdfChunk-object * @param other Chunk with the same style you want for the new Chunk */ - + PdfChunk(String string, PdfChunk other) { thisChunk[0] = this; value = string; + updateBreakTag(); this.font = other.font; this.attributes = other.attributes; this.noStroke = other.noStroke; @@ -217,18 +224,18 @@ public class PdfChunk { splitCharacter = DefaultSplitCharacter.DEFAULT; this.height = other.getHeight(); } - -/** + + /** * Constructs a PdfChunk-object. * * @param chunk the original Chunk-object * @param action the PdfAction if the Chunk comes from an Anchor */ - + public PdfChunk(Chunk chunk, PdfAction action) { thisChunk[0] = this; value = chunk.getContent(); - + updateBreakTag(); Font f = chunk.getFont(); float size = f.getSize(); if (size == Font.UNDEFINED) @@ -302,15 +309,15 @@ public class PdfChunk { if (splitCharacter == null) splitCharacter = DefaultSplitCharacter.DEFAULT; } - + // methods - + /** Gets the Unicode equivalent to a CID. - * The (inexistent) CID is translated as '\n'. + * The (inexistent) CID is translated as '\n'. * It has only meaning with CJK fonts with Identity encoding. * @param c the CID code * @return the Unicode equivalent - */ + */ public int getUnicodeEquivalent(int c) { return c; } @@ -407,7 +414,7 @@ public class PdfChunk { * @param width a given width * @return the PdfChunk that doesn't fit into the width. */ - + PdfChunk truncate(float width) { if (image != null) { if (image.getScaledWidth() + indent.getLeft() + indent.getRight() > width) { @@ -421,10 +428,10 @@ public class PdfChunk { else return null; } - + int currentPosition = 0; float currentWidth = indent.getLeft(); - + // it's no use trying to split if there isn't even enough place for a space if (width < font.width() + indent.getLeft() + indent.getRight()) { String returnValue = value.substring(1); @@ -432,7 +439,7 @@ public class PdfChunk { PdfChunk pc = new PdfChunk(returnValue, this); return pc; } - + // loop over all the characters of a string // or until the totalWidth is reached int length = value.length(); @@ -451,12 +458,12 @@ public class PdfChunk { currentPosition++; currentPosition++; } - + // if all the characters fit in the total width, null is returned (there is no overflow) if (currentPosition == length) { return null; } - + // otherwise, the string has to be truncated //currentPosition -= 2; // we have to chop off minimum 1 character from the chunk @@ -470,49 +477,49 @@ public class PdfChunk { PdfChunk pc = new PdfChunk(returnValue, this); return pc; } - + // methods to retrieve the membervariables - + /** * Returns the font of this Chunk. * * @return a PdfFont */ - + PdfFont font() { return font; } - + /** * Returns the color of this Chunk. * * @return a Color */ - + Color color() { return (Color)noStroke.get(Chunk.COLOR); } - + /** * Returns the width of this PdfChunk. * * @return a width */ - + public float width() { return font.width(value) + indent.getLeft() + indent.getRight(); } - + /** * Checks if the PdfChunk split was caused by a newline. * @return true if the PdfChunk split was caused by a newline. */ - + public boolean isNewlineSplit() { return newlineSplit; } - + /** * Gets the width of the PdfChunk taking into account the * extra character and word spacing. @@ -520,7 +527,7 @@ public class PdfChunk { * @param wordSpacing the extra word spacing * @return the calculated width */ - + public float getWidthCorrected(float charSpacing, float wordSpacing) { if (image != null) { @@ -532,7 +539,7 @@ public class PdfChunk { ++numberOfSpaces; return width() + (value.length() * charSpacing + numberOfSpaces * wordSpacing); } - + /** * Gets the text displacement relative to the baseline. * @return a displacement in points @@ -544,7 +551,7 @@ public class PdfChunk { } return 0.0f; } - + /** * Trims the last space. * @return the width of the space trimmed, otherwise 0 @@ -565,44 +572,44 @@ public class PdfChunk { } return 0; } - + /** * Gets an attribute. The search is made in attributes * and noStroke. * @param name the attribute key * @return the attribute value or null if not found */ - + public Object getAttribute(String name) { if (attributes.containsKey(name)) return attributes.get(name); return noStroke.get(name); } - + /** *Checks if the attribute exists. * @param name the attribute key * @return true if the attribute exists */ - + boolean isAttribute(String name) { if (attributes.containsKey(name)) return true; return noStroke.containsKey(name); } - + /** * Checks if this PdfChunk needs some special metrics handling. * @return true if this PdfChunk needs some special metrics handling. */ - + boolean isStroked() { return (!attributes.isEmpty()); } - + /** * Checks if this PdfChunk is a Separator Chunk. * @return true if this chunk is a separator. @@ -611,7 +618,7 @@ public class PdfChunk { boolean isSeparator() { return isAttribute(Chunk.SEPARATOR); } - + /** * Checks if this PdfChunk is a horizontal Separator Chunk. * @return true if this chunk is a horizontal separator. @@ -624,7 +631,7 @@ public class PdfChunk { } return false; } - + /** * Checks if this PdfChunk is a tab Chunk. * @return true if this chunk is a separator. @@ -633,7 +640,7 @@ public class PdfChunk { boolean isTab() { return isAttribute(Chunk.TAB); } - + /** * Correction for the tab position based on the left starting position. * @param newValue the new value for the left X. @@ -645,72 +652,72 @@ public class PdfChunk { attributes.put(Chunk.TAB, new Object[]{o[0], o[1], o[2], new Float(newValue)}); } } - + /** * Checks if there is an image in the PdfChunk. * @return true if an image is present */ - + public boolean isImage() { return image != null; } - + /** * Gets the image in the PdfChunk. * @return the image or null */ - + public Image getImage() { return image; } - + /** * Sets the image offset in the x direction * @param offsetX the image offset in the x direction */ - + void setImageOffsetX(float offsetX) { this.offsetX = offsetX; } - + /** * Gets the image offset in the x direction * @return the image offset in the x direction */ - + float getImageOffsetX() { return offsetX; } - + /** * Sets the image offset in the y direction * @param offsetY the image offset in the y direction */ - + void setImageOffsetY(float offsetY) { this.offsetY = offsetY; } - + /** * Gets the image offset in the y direction * @return Gets the image offset in the y direction */ - + float getImageOffsetY() { return offsetY; } - + /** * sets the value. * @param value content of the Chunk */ - + void setValue(String value) { this.value = value; @@ -727,17 +734,17 @@ public class PdfChunk { * Tells you if this string is in Chinese, Japanese, Korean or Identity-H. * @return true if the Chunk has a special encoding */ - + boolean isSpecialEncoding() { return encoding.equals(CJKFont.CJK_ENCODING) || encoding.equals(BaseFont.IDENTITY_H); } - + /** * Gets the encoding of this string. * * @return a String */ - + String getEncoding() { return encoding; } @@ -745,7 +752,7 @@ public class PdfChunk { int length() { return value.length(); } - + int lengthUtf32() { if (!BaseFont.IDENTITY_H.equals(encoding)) return value.length(); @@ -758,17 +765,17 @@ public class PdfChunk { } return total; } - + boolean isExtSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) { return splitCharacter.isSplitCharacter(start, current, end, cc, ck); } - + /** * Removes all the ' ' and '-'-characters on the right of a String. *

* @param string the String that has to be trimmed. * @return the trimmed String - */ + */ String trim(String string) { while (string.endsWith(" ") || string.endsWith("\t")) { string = string.substring(0, string.length() - 1); @@ -779,7 +786,7 @@ public class PdfChunk { public boolean changeLeading() { return changeLeading; } - + float getCharWidth(int c) { if (noPrint(c)) return 0; @@ -798,7 +805,7 @@ public class PdfChunk { htmlString.append(""); - htmlString.append(value); + htmlString.append(breakTag ? BREAK_TAG : value); htmlString.append(""); return htmlString.toString(); } @@ -856,4 +863,12 @@ public class PdfChunk { return indent.getLeft(); } + private void updateBreakTag() { + breakTag = BREAK.equals(value); + } + + public boolean isBreakTag() { + return breakTag; + } + } diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java index 4752ffd8e..a4f980b3c 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfLine.java @@ -91,9 +91,11 @@ public class PdfLine { /** The original width. */ protected float originalWidth; - + protected boolean isRTL = false; + + public float getHeight() { return height; } @@ -155,9 +157,15 @@ public class PdfLine { public PdfChunk add(PdfChunk chunk) { // nothing happens if the chunk is null. if (chunk == null || chunk.toString().equals("")) { - return null; + return null; } - + // add to line if the chunk is break tag ("\n") + if (chunk.isBreakTag()) { + addToLine(chunk); + width = 0; + return null; + } + // we split the chunk to be added PdfChunk overflow = chunk.split(width); newlineSplit = (chunk.isNewlineSplit() || overflow == null); From 9f75ae990b8a3a484a122af565d37536b0053085 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 31 Oct 2019 21:18:02 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E6=97=A0=20jira=20=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=EF=BC=8Crelease=20=E5=90=88=E5=B9=B6=20final=20=EF=BC=8C=20?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.third_step0.gradle | 2 +- build.third_step1.gradle | 2 +- build.third_step2.gradle | 2 +- build.third_step3.gradle | 2 +- build.third_step4.gradle | 2 +- build.third_step5.gradle | 2 +- build.third_step6.gradle | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.third_step0.gradle b/build.third_step0.gradle index c9bc2aeda..2ffa87f02 100644 --- a/build.third_step0.gradle +++ b/build.third_step0.gradle @@ -44,7 +44,7 @@ def branchName=buildDir.substring(buildDir.lastIndexOf (java.io.File.separator)+ def srcDir="." // @branch - 分支信息 -def maven_version="${version}-RELEASE-SNAPSHOT" +def maven_version="${version}-FINAL-SNAPSHOT" def jar_version = version configurations { diff --git a/build.third_step1.gradle b/build.third_step1.gradle index 4ee016047..198247ae4 100644 --- a/build.third_step1.gradle +++ b/build.third_step1.gradle @@ -65,7 +65,7 @@ dependencies{ compile fileTree(dir:"${srcDir}/fine-quartz/lib",include:'**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-RELEASE-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } diff --git a/build.third_step2.gradle b/build.third_step2.gradle index 9e1e2cb2e..aa1d2d9a1 100644 --- a/build.third_step2.gradle +++ b/build.third_step2.gradle @@ -55,7 +55,7 @@ dependencies{ compile fileTree(dir:"${srcDir}/fine-antlr4/lib",include: '**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-RELEASE-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } diff --git a/build.third_step3.gradle b/build.third_step3.gradle index e5658dba6..5e8ebc12a 100644 --- a/build.third_step3.gradle +++ b/build.third_step3.gradle @@ -51,7 +51,7 @@ dependencies{ compile fileTree(dir:"${srcDir}/fine-jboss-logging/lib",include:'**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-RELEASE-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } diff --git a/build.third_step4.gradle b/build.third_step4.gradle index b38e93e7f..1ad793adc 100644 --- a/build.third_step4.gradle +++ b/build.third_step4.gradle @@ -50,7 +50,7 @@ dependencies{ compile fileTree(dir:"${srcDir}/fine-hibernate/lib",include:'**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-RELEASE-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } diff --git a/build.third_step5.gradle b/build.third_step5.gradle index 819ba5457..04a228994 100644 --- a/build.third_step5.gradle +++ b/build.third_step5.gradle @@ -49,7 +49,7 @@ dependencies{ compile fileTree(dir:"${srcDir}/fine-druid/lib",include:'**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-RELEASE-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } diff --git a/build.third_step6.gradle b/build.third_step6.gradle index f0fb86b0a..2062c7758 100644 --- a/build.third_step6.gradle +++ b/build.third_step6.gradle @@ -83,7 +83,7 @@ dependencies{ compile fileTree(dir:"${srcDir}/fine-jgit/lib",include:'**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-RELEASE-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } From 88387a30b8d8a2af8433b73b4cbc77e52d886678 Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 7 Nov 2019 13:56:44 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E6=97=A0=20jira=20=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=EF=BC=8C=20=E5=A4=84=E7=90=86=E5=88=86=E6=94=AF=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.third_step0.gradle | 4 +++- build.third_step1.gradle | 3 ++- build.third_step2.gradle | 3 ++- build.third_step3.gradle | 3 ++- build.third_step4.gradle | 3 ++- build.third_step5.gradle | 3 ++- build.third_step6.gradle | 3 ++- 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/build.third_step0.gradle b/build.third_step0.gradle index bfb293f00..9b7bcd2cb 100644 --- a/build.third_step0.gradle +++ b/build.third_step0.gradle @@ -43,8 +43,10 @@ def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf (java.io.File.s def branchName=buildDir.substring(buildDir.lastIndexOf (java.io.File.separator)+1) def srcDir="." +def MVN_BRANCH = branchVariable.toUpperCase() + // @branch - 分支信息 -def maven_version="${version}-BUGFIX-SNAPSHOT" +def maven_version="${version}-${MVN_BRANCH}-SNAPSHOT" def jar_version = version configurations { diff --git a/build.third_step1.gradle b/build.third_step1.gradle index 198247ae4..2e561dc79 100644 --- a/build.third_step1.gradle +++ b/build.third_step1.gradle @@ -58,6 +58,7 @@ repositories{ FileTree files =fileTree(dir:'./',include:'build.*.gradle') def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf (java.io.File.separator)) def branchName=buildDir.substring(buildDir.lastIndexOf (java.io.File.separator)+1) +def MVN_BRANCH = branchVariable.toUpperCase() //指定依赖 dependencies{ @@ -65,7 +66,7 @@ dependencies{ compile fileTree(dir:"${srcDir}/fine-quartz/lib",include:'**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-${MVN_BRANCH}-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } diff --git a/build.third_step2.gradle b/build.third_step2.gradle index aa1d2d9a1..d65d684a4 100644 --- a/build.third_step2.gradle +++ b/build.third_step2.gradle @@ -46,6 +46,7 @@ repositories{ FileTree files =fileTree(dir:'./',include:'build.*.gradle') def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf (java.io.File.separator)) def branchName=buildDir.substring(buildDir.lastIndexOf (java.io.File.separator)+1) +def MVN_BRANCH = branchVariable.toUpperCase() //指定依赖 dependencies{ @@ -55,7 +56,7 @@ dependencies{ compile fileTree(dir:"${srcDir}/fine-antlr4/lib",include: '**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-${MVN_BRANCH}-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } diff --git a/build.third_step3.gradle b/build.third_step3.gradle index 5e8ebc12a..702132f17 100644 --- a/build.third_step3.gradle +++ b/build.third_step3.gradle @@ -45,13 +45,14 @@ repositories{ FileTree files =fileTree(dir:'./',include:'build.*.gradle') def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf (java.io.File.separator)) def branchName=buildDir.substring(buildDir.lastIndexOf (java.io.File.separator)+1) +def MVN_BRANCH = branchVariable.toUpperCase() //指定依赖 dependencies{ compile fileTree(dir:"${srcDir}/fine-jboss-logging/lib",include:'**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-${MVN_BRANCH}-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } diff --git a/build.third_step4.gradle b/build.third_step4.gradle index 1ad793adc..650c69b0a 100644 --- a/build.third_step4.gradle +++ b/build.third_step4.gradle @@ -44,13 +44,14 @@ repositories{ FileTree files =fileTree(dir:'./',include:'build.*.gradle') def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf (java.io.File.separator)) def branchName=buildDir.substring(buildDir.lastIndexOf (java.io.File.separator)+1) +def MVN_BRANCH = branchVariable.toUpperCase() //指定依赖 dependencies{ compile fileTree(dir:"${srcDir}/fine-hibernate/lib",include:'**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-${MVN_BRANCH}-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } diff --git a/build.third_step5.gradle b/build.third_step5.gradle index 04a228994..dd8d80fdd 100644 --- a/build.third_step5.gradle +++ b/build.third_step5.gradle @@ -42,6 +42,7 @@ repositories{ FileTree files =fileTree(dir:'./',include:'build.*.gradle') def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf (java.io.File.separator)) def branchName=buildDir.substring(buildDir.lastIndexOf (java.io.File.separator)+1) +def MVN_BRANCH = branchVariable.toUpperCase() //指定依赖 dependencies{ @@ -49,7 +50,7 @@ dependencies{ compile fileTree(dir:"${srcDir}/fine-druid/lib",include:'**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-${MVN_BRANCH}-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } diff --git a/build.third_step6.gradle b/build.third_step6.gradle index 2062c7758..8ef6d50ae 100644 --- a/build.third_step6.gradle +++ b/build.third_step6.gradle @@ -68,6 +68,7 @@ repositories{ FileTree files =fileTree(dir:'./',include:'build*.gradle') def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf (java.io.File.separator)) def branchName=buildDir.substring(buildDir.lastIndexOf (java.io.File.separator)+1) +def MVN_BRANCH = branchVariable.toUpperCase() //指定依赖 dependencies{ @@ -83,7 +84,7 @@ dependencies{ compile fileTree(dir:"${srcDir}/fine-jgit/lib",include:'**/*.jar') compile fileTree(dir:"${srcDir}/build/libs/",include:'**/*.jar') // @branch - 分支信息 - compile "com.fr.third:fine-third:10.0-FINAL-SNAPSHOT" + compile "com.fr.third:fine-third:10.0-${MVN_BRANCH}-SNAPSHOT" compile fileTree(dir:"../../finereport-lib-other/${branchName}",include:'**/*.jar') testCompile 'junit:junit:4.12' } From df46b151f6fabaca61e35933ceb68a19081f6905 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 26 Nov 2019 17:32:08 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E2=80=9CREPORT-23134=20=E8=B0=83?= =?UTF-8?q?=E7=94=A8doURLPrint=E6=89=93=E5=8D=B0\n=E4=BC=9A=E8=A2=AB?= =?UTF-8?q?=E8=BD=AC=E5=8C=96=E6=88=90=E7=A9=BA=E6=A0=BC=20by=20Bruce.Deng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/third/javax/xml/stream/XMLEntityReaderImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/fine-third-default/src/com/fr/third/javax/xml/stream/XMLEntityReaderImpl.java b/fine-third-default/src/com/fr/third/javax/xml/stream/XMLEntityReaderImpl.java index 90649414f..512f82fb9 100644 --- a/fine-third-default/src/com/fr/third/javax/xml/stream/XMLEntityReaderImpl.java +++ b/fine-third-default/src/com/fr/third/javax/xml/stream/XMLEntityReaderImpl.java @@ -39,6 +39,7 @@ public class XMLEntityReaderImpl extends XMLEntityReader XMLEntityReaderImpl.validContent[i] = true; } XMLEntityReaderImpl.validContent[9] = true; + XMLEntityReaderImpl.validContent[10] = true; XMLEntityReaderImpl.validContent[38] = false; XMLEntityReaderImpl.validContent[60] = false; for (int j = 65; j <= 90; ++j) { From 72ee15206300064f37b2217c41b30849d5cb1066 Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Mon, 9 Dec 2019 16:16:39 +0800 Subject: [PATCH 09/15] =?UTF-8?q?REPORT-24915=20REPORT-24809=20PDF?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E7=B2=97=E4=BD=93=E5=AD=97=E4=BD=93=E8=BF=87?= =?UTF-8?q?=E7=B2=97;html=E6=98=BE=E7=A4=BA=20=E6=95=B0=E6=8D=AE=E5=AF=BC?= =?UTF-8?q?=E5=87=BApdf=E6=B2=A1=E6=9C=89=E5=8A=A0=E7=B2=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third/com/lowagie/text/pdf/PdfGraphics2D.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fine-itext-old/src/com/fr/third/com/lowagie/text/pdf/PdfGraphics2D.java b/fine-itext-old/src/com/fr/third/com/lowagie/text/pdf/PdfGraphics2D.java index 5a13315c3..ee5a7cfcf 100755 --- a/fine-itext-old/src/com/fr/third/com/lowagie/text/pdf/PdfGraphics2D.java +++ b/fine-itext-old/src/com/fr/third/com/lowagie/text/pdf/PdfGraphics2D.java @@ -382,7 +382,10 @@ public class PdfGraphics2D extends Graphics2D { // value. When they are the same value then we are normally dealing // with a single font that has been made into an italic or bold // font. - if (font.isItalic() && font.getFontName().equals(font.getName())) { + if (font.isItalic()) + //awt.font只要样式,不验证是否安装,真实绘制的字体是 baseFont + // && font.getFontName().equals(font.getName())) + { float angle = baseFont.getFontDescriptor(BaseFont.ITALICANGLE, 1000); float angle2 = font.getItalicAngle(); // We don't have an italic version of this font so we need @@ -419,10 +422,13 @@ public class PdfGraphics2D extends Graphics2D { weight = (font.isBold()) ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR; } - if ((font.isBold() || (weight.floatValue() >= TextAttribute.WEIGHT_SEMIBOLD.floatValue())) - && (font.getFontName().equals(font.getName()))) { + if ((font.isBold() || (weight.floatValue() >= TextAttribute.WEIGHT_SEMIBOLD.floatValue()))) + //awt.font只要样式,不验证是否安装,真实绘制的字体是 baseFont + // && (font.getFontName().equals(font.getName()))) + { // Simulate a bold font. - float strokeWidth = font.getSize2D() * (weight.floatValue() - TextAttribute.WEIGHT_REGULAR.floatValue()) / 30f; + // 30有点粗 ,换成40 + float strokeWidth = font.getSize2D() * (weight.floatValue() - TextAttribute.WEIGHT_REGULAR.floatValue()) / 40f; if (strokeWidth != 1) { if(realPaint instanceof Color){ cb.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE); From 4f71896be84d6e4264e5a03c94e5bea252180598 Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Tue, 17 Dec 2019 13:52:37 +0800 Subject: [PATCH 10/15] =?UTF-8?q?REPORT-25253=20Html=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E5=B0=8F=E4=BA=8E=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../text/html/simpleparser/HTMLWorker.java | 9 ++++-- .../xml/simpleparser/SimpleXMLParser.java | 30 +++++++++++++++---- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java index ade85f5cf..968747ecf 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java @@ -804,10 +804,15 @@ public class HTMLWorker implements SimpleXMLDocHandler, DocListener { public static final HashMap tagsSupported = new HashMap(); + public static final HashMap tagsPrefixSupported = new HashMap(); + static { StringTokenizer tok = new StringTokenizer(tagsSupportedString); - while (tok.hasMoreTokens()) - tagsSupported.put(tok.nextToken(), null); + while (tok.hasMoreTokens()){ + String s = tok.nextToken(); + tagsSupported.put(s, null); + tagsPrefixSupported.put(s.charAt(0), null); + } } } diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/xml/simpleparser/SimpleXMLParser.java b/fine-itext/src/com/fr/third/v2/lowagie/text/xml/simpleparser/SimpleXMLParser.java index 2a15f56ff..0642a11e7 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/xml/simpleparser/SimpleXMLParser.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/xml/simpleparser/SimpleXMLParser.java @@ -75,6 +75,8 @@ */ package com.fr.third.v2.lowagie.text.xml.simpleparser; +import com.fr.third.v2.lowagie.text.html.simpleparser.HTMLWorker; + import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -229,16 +231,13 @@ public final class SimpleXMLParser { // we are in an unknown state before there's actual content case UNKNOWN: if(character == '<') { - saveState(TEXT); - state = TAG_ENCOUNTERED; + beginnOfTag((char) reader.read(), UNKNOWN); } break; // we can encounter any content case TEXT: if(character == '<') { - flush(); - saveState(state); - state = TAG_ENCOUNTERED; + beginnOfTag((char) reader.read(), TEXT); } else if(character == '&') { saveState(state); entity.setLength(0); @@ -481,6 +480,27 @@ public final class SimpleXMLParser { } } + + /** + * 处理标签的开头,若不在支持标签范围内,将<符号作为文本处理,例:<1111 (仿造浏览器的处理方式) + */ + public void beginnOfTag(char c, int type) { + previousCharacter = c; + if (c == -1) { + return; + } + if (c == '/' || HTMLWorker.tagsPrefixSupported.containsKey(c)) { + if (type == TEXT) { + flush(); + } + saveState(TEXT); + state = TAG_ENCOUNTERED; + return; + } + text.append((char) character); + nowhite = true; + } + /** * Gets a state from the stack * @return the previous state From 6fff6aaeaf21b76c70e425fcf0e303623514acb9 Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Tue, 24 Dec 2019 09:28:08 +0800 Subject: [PATCH 11/15] =?UTF-8?q?REPORT-25477=20HTML=E8=A7=A3=E6=9E=90colo?= =?UTF-8?q?r=20=E9=94=99=E8=AF=AF=EF=BC=8816=E8=BF=9B=E5=88=B6=E6=9C=89?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=86=99=E9=94=99=E4=BA=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third/v2/lowagie/text/html/WebColors.java | 307 ++++++++++-------- 1 file changed, 165 insertions(+), 142 deletions(-) diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/WebColors.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/WebColors.java index 1004d2414..512def96d 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/WebColors.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/html/WebColors.java @@ -66,147 +66,170 @@ public class WebColors extends HashMap { /** HashMap containing all the names and corresponding color values. */ public static final WebColors NAMES = new WebColors(); static { - NAMES.put("aliceblue", new int[] { 0xf0, 0xf8, 0xff, 0x00 }); - NAMES.put("antiquewhite", new int[] { 0xfa, 0xeb, 0xd7, 0x00 }); - NAMES.put("aqua", new int[] { 0x00, 0xff, 0xff, 0x00 }); - NAMES.put("aquamarine", new int[] { 0x7f, 0xff, 0xd4, 0x00 }); - NAMES.put("azure", new int[] { 0xf0, 0xff, 0xff, 0x00 }); - NAMES.put("beige", new int[] { 0xf5, 0xf5, 0xdc, 0x00 }); - NAMES.put("bisque", new int[] { 0xff, 0xe4, 0xc4, 0x00 }); - NAMES.put("black", new int[] { 0x00, 0x00, 0x00, 0x00 }); - NAMES.put("blanchedalmond", new int[] { 0xff, 0xeb, 0xcd, 0x00 }); - NAMES.put("blue", new int[] { 0x00, 0x00, 0xff, 0x00 }); - NAMES.put("blueviolet", new int[] { 0x8a, 0x2b, 0xe2, 0x00 }); - NAMES.put("brown", new int[] { 0xa5, 0x2a, 0x2a, 0x00 }); - NAMES.put("burlywood", new int[] { 0xde, 0xb8, 0x87, 0x00 }); - NAMES.put("cadetblue", new int[] { 0x5f, 0x9e, 0xa0, 0x00 }); - NAMES.put("chartreuse", new int[] { 0x7f, 0xff, 0x00, 0x00 }); - NAMES.put("chocolate", new int[] { 0xd2, 0x69, 0x1e, 0x00 }); - NAMES.put("coral", new int[] { 0xff, 0x7f, 0x50, 0x00 }); - NAMES.put("cornflowerblue", new int[] { 0x64, 0x95, 0xed, 0x00 }); - NAMES.put("cornsilk", new int[] { 0xff, 0xf8, 0xdc, 0x00 }); - NAMES.put("crimson", new int[] { 0xdc, 0x14, 0x3c, 0x00 }); - NAMES.put("cyan", new int[] { 0x00, 0xff, 0xff, 0x00 }); - NAMES.put("darkblue", new int[] { 0x00, 0x00, 0x8b, 0x00 }); - NAMES.put("darkcyan", new int[] { 0x00, 0x8b, 0x8b, 0x00 }); - NAMES.put("darkgoldenrod", new int[] { 0xb8, 0x86, 0x0b, 0x00 }); - NAMES.put("darkgray", new int[] { 0xa9, 0xa9, 0xa9, 0x00 }); - NAMES.put("darkgreen", new int[] { 0x00, 0x64, 0x00, 0x00 }); - NAMES.put("darkkhaki", new int[] { 0xbd, 0xb7, 0x6b, 0x00 }); - NAMES.put("darkmagenta", new int[] { 0x8b, 0x00, 0x8b, 0x00 }); - NAMES.put("darkolivegreen", new int[] { 0x55, 0x6b, 0x2f, 0x00 }); - NAMES.put("darkorange", new int[] { 0xff, 0x8c, 0x00, 0x00 }); - NAMES.put("darkorchid", new int[] { 0x99, 0x32, 0xcc, 0x00 }); - NAMES.put("darkred", new int[] { 0x8b, 0x00, 0x00, 0x00 }); - NAMES.put("darksalmon", new int[] { 0xe9, 0x96, 0x7a, 0x00 }); - NAMES.put("darkseagreen", new int[] { 0x8f, 0xbc, 0x8f, 0x00 }); - NAMES.put("darkslateblue", new int[] { 0x48, 0x3d, 0x8b, 0x00 }); - NAMES.put("darkslategray", new int[] { 0x2f, 0x4f, 0x4f, 0x00 }); - NAMES.put("darkturquoise", new int[] { 0x00, 0xce, 0xd1, 0x00 }); - NAMES.put("darkviolet", new int[] { 0x94, 0x00, 0xd3, 0x00 }); - NAMES.put("deeppink", new int[] { 0xff, 0x14, 0x93, 0x00 }); - NAMES.put("deepskyblue", new int[] { 0x00, 0xbf, 0xff, 0x00 }); - NAMES.put("dimgray", new int[] { 0x69, 0x69, 0x69, 0x00 }); - NAMES.put("dodgerblue", new int[] { 0x1e, 0x90, 0xff, 0x00 }); - NAMES.put("firebrick", new int[] { 0xb2, 0x22, 0x22, 0x00 }); - NAMES.put("floralwhite", new int[] { 0xff, 0xfa, 0xf0, 0x00 }); - NAMES.put("forestgreen", new int[] { 0x22, 0x8b, 0x22, 0x00 }); - NAMES.put("fuchsia", new int[] { 0xff, 0x00, 0xff, 0x00 }); - NAMES.put("gainsboro", new int[] { 0xdc, 0xdc, 0xdc, 0x00 }); - NAMES.put("ghostwhite", new int[] { 0xf8, 0xf8, 0xff, 0x00 }); - NAMES.put("gold", new int[] { 0xff, 0xd7, 0x00, 0x00 }); - NAMES.put("goldenrod", new int[] { 0xda, 0xa5, 0x20, 0x00 }); - NAMES.put("gray", new int[] { 0x80, 0x80, 0x80, 0x00 }); - NAMES.put("green", new int[] { 0x00, 0x80, 0x00, 0x00 }); - NAMES.put("greenyellow", new int[] { 0xad, 0xff, 0x2f, 0x00 }); - NAMES.put("honeydew", new int[] { 0xf0, 0xff, 0xf0, 0x00 }); - NAMES.put("hotpink", new int[] { 0xff, 0x69, 0xb4, 0x00 }); - NAMES.put("indianred", new int[] { 0xcd, 0x5c, 0x5c, 0x00 }); - NAMES.put("indigo", new int[] { 0x4b, 0x00, 0x82, 0x00 }); - NAMES.put("ivory", new int[] { 0xff, 0xff, 0xf0, 0x00 }); - NAMES.put("khaki", new int[] { 0xf0, 0xe6, 0x8c, 0x00 }); - NAMES.put("lavender", new int[] { 0xe6, 0xe6, 0xfa, 0x00 }); - NAMES.put("lavenderblush", new int[] { 0xff, 0xf0, 0xf5, 0x00 }); - NAMES.put("lawngreen", new int[] { 0x7c, 0xfc, 0x00, 0x00 }); - NAMES.put("lemonchiffon", new int[] { 0xff, 0xfa, 0xcd, 0x00 }); - NAMES.put("lightblue", new int[] { 0xad, 0xd8, 0xe6, 0x00 }); - NAMES.put("lightcoral", new int[] { 0xf0, 0x80, 0x80, 0x00 }); - NAMES.put("lightcyan", new int[] { 0xe0, 0xff, 0xff, 0x00 }); - NAMES.put("lightgoldenrodyellow", new int[] { 0xfa, 0xfa, 0xd2, 0x00 }); - NAMES.put("lightgreen", new int[] { 0x90, 0xee, 0x90, 0x00 }); - NAMES.put("lightgrey", new int[] { 0xd3, 0xd3, 0xd3, 0x00 }); - NAMES.put("lightpink", new int[] { 0xff, 0xb6, 0xc1, 0x00 }); - NAMES.put("lightsalmon", new int[] { 0xff, 0xa0, 0x7a, 0x00 }); - NAMES.put("lightseagreen", new int[] { 0x20, 0xb2, 0xaa, 0x00 }); - NAMES.put("lightskyblue", new int[] { 0x87, 0xce, 0xfa, 0x00 }); - NAMES.put("lightslategray", new int[] { 0x77, 0x88, 0x99, 0x00 }); - NAMES.put("lightsteelblue", new int[] { 0xb0, 0xc4, 0xde, 0x00 }); - NAMES.put("lightyellow", new int[] { 0xff, 0xff, 0xe0, 0x00 }); - NAMES.put("lime", new int[] { 0x00, 0xff, 0x00, 0x00 }); - NAMES.put("limegreen", new int[] { 0x32, 0xcd, 0x32, 0x00 }); - NAMES.put("linen", new int[] { 0xfa, 0xf0, 0xe6, 0x00 }); - NAMES.put("magenta", new int[] { 0xff, 0x00, 0xff, 0x00 }); - NAMES.put("maroon", new int[] { 0x80, 0x00, 0x00, 0x00 }); - NAMES.put("mediumaquamarine", new int[] { 0x66, 0xcd, 0xaa, 0x00 }); - NAMES.put("mediumblue", new int[] { 0x00, 0x00, 0xcd, 0x00 }); - NAMES.put("mediumorchid", new int[] { 0xba, 0x55, 0xd3, 0x00 }); - NAMES.put("mediumpurple", new int[] { 0x93, 0x70, 0xdb, 0x00 }); - NAMES.put("mediumseagreen", new int[] { 0x3c, 0xb3, 0x71, 0x00 }); - NAMES.put("mediumslateblue", new int[] { 0x7b, 0x68, 0xee, 0x00 }); - NAMES.put("mediumspringgreen", new int[] { 0x00, 0xfa, 0x9a, 0x00 }); - NAMES.put("mediumturquoise", new int[] { 0x48, 0xd1, 0xcc, 0x00 }); - NAMES.put("mediumvioletred", new int[] { 0xc7, 0x15, 0x85, 0x00 }); - NAMES.put("midnightblue", new int[] { 0x19, 0x19, 0x70, 0x00 }); - NAMES.put("mintcream", new int[] { 0xf5, 0xff, 0xfa, 0x00 }); - NAMES.put("mistyrose", new int[] { 0xff, 0xe4, 0xe1, 0x00 }); - NAMES.put("moccasin", new int[] { 0xff, 0xe4, 0xb5, 0x00 }); - NAMES.put("navajowhite", new int[] { 0xff, 0xde, 0xad, 0x00 }); - NAMES.put("navy", new int[] { 0x00, 0x00, 0x80, 0x00 }); - NAMES.put("oldlace", new int[] { 0xfd, 0xf5, 0xe6, 0x00 }); - NAMES.put("olive", new int[] { 0x80, 0x80, 0x00, 0x00 }); - NAMES.put("olivedrab", new int[] { 0x6b, 0x8e, 0x23, 0x00 }); - NAMES.put("orange", new int[] { 0xff, 0xa5, 0x00, 0x00 }); - NAMES.put("orangered", new int[] { 0xff, 0x45, 0x00, 0x00 }); - NAMES.put("orchid", new int[] { 0xda, 0x70, 0xd6, 0x00 }); - NAMES.put("palegoldenrod", new int[] { 0xee, 0xe8, 0xaa, 0x00 }); - NAMES.put("palegreen", new int[] { 0x98, 0xfb, 0x98, 0x00 }); - NAMES.put("paleturquoise", new int[] { 0xaf, 0xee, 0xee, 0x00 }); - NAMES.put("palevioletred", new int[] { 0xdb, 0x70, 0x93, 0x00 }); - NAMES.put("papayawhip", new int[] { 0xff, 0xef, 0xd5, 0x00 }); - NAMES.put("peachpuff", new int[] { 0xff, 0xda, 0xb9, 0x00 }); - NAMES.put("peru", new int[] { 0xcd, 0x85, 0x3f, 0x00 }); - NAMES.put("pink", new int[] { 0xff, 0xc0, 0xcb, 0x00 }); - NAMES.put("plum", new int[] { 0xdd, 0xa0, 0xdd, 0x00 }); - NAMES.put("powderblue", new int[] { 0xb0, 0xe0, 0xe6, 0x00 }); - NAMES.put("purple", new int[] { 0x80, 0x00, 0x80, 0x00 }); - NAMES.put("red", new int[] { 0xff, 0x00, 0x00, 0x00 }); - NAMES.put("rosybrown", new int[] { 0xbc, 0x8f, 0x8f, 0x00 }); - NAMES.put("royalblue", new int[] { 0x41, 0x69, 0xe1, 0x00 }); - NAMES.put("saddlebrown", new int[] { 0x8b, 0x45, 0x13, 0x00 }); - NAMES.put("salmon", new int[] { 0xfa, 0x80, 0x72, 0x00 }); - NAMES.put("sandybrown", new int[] { 0xf4, 0xa4, 0x60, 0x00 }); - NAMES.put("seagreen", new int[] { 0x2e, 0x8b, 0x57, 0x00 }); - NAMES.put("seashell", new int[] { 0xff, 0xf5, 0xee, 0x00 }); - NAMES.put("sienna", new int[] { 0xa0, 0x52, 0x2d, 0x00 }); - NAMES.put("silver", new int[] { 0xc0, 0xc0, 0xc0, 0x00 }); - NAMES.put("skyblue", new int[] { 0x87, 0xce, 0xeb, 0x00 }); - NAMES.put("slateblue", new int[] { 0x6a, 0x5a, 0xcd, 0x00 }); - NAMES.put("slategray", new int[] { 0x70, 0x80, 0x90, 0x00 }); - NAMES.put("snow", new int[] { 0xff, 0xfa, 0xfa, 0x00 }); - NAMES.put("springgreen", new int[] { 0x00, 0xff, 0x7f, 0x00 }); - NAMES.put("steelblue", new int[] { 0x46, 0x82, 0xb4, 0x00 }); - NAMES.put("tan", new int[] { 0xd2, 0xb4, 0x8c, 0x00 }); - NAMES.put("transparent", new int[] { 0x00, 0x00, 0x00, 0xff }); - NAMES.put("teal", new int[] { 0x00, 0x80, 0x80, 0x00 }); - NAMES.put("thistle", new int[] { 0xd8, 0xbf, 0xd8, 0x00 }); - NAMES.put("tomato", new int[] { 0xff, 0x63, 0x47, 0x00 }); - NAMES.put("turquoise", new int[] { 0x40, 0xe0, 0xd0, 0x00 }); - NAMES.put("violet", new int[] { 0xee, 0x82, 0xee, 0x00 }); - NAMES.put("wheat", new int[] { 0xf5, 0xde, 0xb3, 0x00 }); - NAMES.put("white", new int[] { 0xff, 0xff, 0xff, 0x00 }); - NAMES.put("whitesmoke", new int[] { 0xf5, 0xf5, 0xf5, 0x00 }); - NAMES.put("yellow", new int[] { 0xff, 0xff, 0x00, 0x00 }); - NAMES.put("yellowgreen", new int[] { 0x9, 0xacd, 0x32, 0x00 }); + //比对 https://html-color-codes.info/color-names/ + //Red color names + NAMES.put("indianred", new int[]{0xcd, 0x5c, 0x5c, 0xff}); + NAMES.put("lightcoral", new int[]{0xf0, 0x80, 0x80, 0xff}); + NAMES.put("salmon", new int[]{0xfa, 0x80, 0x72, 0xff}); + NAMES.put("darksalmon", new int[]{0xe9, 0x96, 0x7a, 0xff}); + NAMES.put("lightsalmon", new int[]{0xff, 0xa0, 0x7a, 0xff}); + NAMES.put("crimson", new int[]{0xdc, 0x14, 0x3c, 0xff}); + NAMES.put("firebrick", new int[]{0xb2, 0x22, 0x22, 0xff}); + NAMES.put("darkred", new int[]{0x8b, 0x00, 0x00, 0xff}); + NAMES.put("red", new int[]{0xff, 0x00, 0x00, 0xff}); + + //Pink color names + NAMES.put("pink", new int[]{0xff, 0xc0, 0xcb, 0xff}); + NAMES.put("lightpink", new int[]{0xff, 0xb6, 0xc1, 0xff}); + NAMES.put("hotpink", new int[]{0xff, 0x69, 0xb4, 0xff}); + NAMES.put("deeppink", new int[]{0xff, 0x14, 0x93, 0xff}); + NAMES.put("mediumvioletred", new int[]{0xc7, 0x15, 0x85, 0xff}); + NAMES.put("palevioletred", new int[]{0xdb, 0x70, 0x93, 0xff}); + + //Orange color names + NAMES.put("coral", new int[]{0xff, 0x7f, 0x50, 0xff}); + NAMES.put("tomato", new int[]{0xff, 0x63, 0x47, 0xff}); + NAMES.put("orangered", new int[]{0xff, 0x45, 0x00, 0xff}); + NAMES.put("darkorange", new int[]{0xff, 0x8c, 0x00, 0xff}); + NAMES.put("orange", new int[]{0xff, 0xa5, 0x00, 0xff}); + + //Orange color names + NAMES.put("gold", new int[]{0xff, 0xd7, 0x00, 0xff}); + NAMES.put("yellow", new int[]{0xff, 0xff, 0x00, 0xff}); + NAMES.put("lightyellow", new int[]{0xff, 0xff, 0xefe, 0xff}); + NAMES.put("lemonchiffon", new int[]{0xff, 0xfa, 0xcd, 0xff}); + NAMES.put("lightgoldenrodyellow", new int[]{0xfa, 0xfa, 0xd2, 0xff}); + NAMES.put("papayawhip", new int[]{0xff, 0xef, 0xd5, 0xff}); + NAMES.put("moccasin", new int[]{0xff, 0xe4, 0xb5, 0xff}); + NAMES.put("peachpuff", new int[]{0xff, 0xda, 0xb9, 0xff}); + NAMES.put("palegoldenrod", new int[]{0xee, 0xe8, 0xaa, 0xff}); + NAMES.put("khaki", new int[]{0xf0, 0xe6, 0x8c, 0xff}); + NAMES.put("darkkhaki", new int[]{0xbd, 0xb7, 0x6b, 0xff}); + + //Purple color names + NAMES.put("lavender", new int[]{0xe6, 0xe6, 0xfa, 0xff}); + NAMES.put("thistle", new int[]{0xd8, 0xbf, 0xd8, 0xff}); + NAMES.put("plum", new int[]{0xdd, 0xa0, 0xdd, 0xff}); + NAMES.put("violet", new int[]{0xee, 0x82, 0xee, 0xff}); + NAMES.put("orchid", new int[]{0xda, 0x70, 0xd6, 0xff}); + NAMES.put("fuchsia", new int[]{0xff, 0x00, 0xff, 0xff}); + NAMES.put("magenta", new int[]{0xff, 0x00, 0xff, 0xff}); + NAMES.put("mediumorchid", new int[]{0xba, 0x55, 0xd3, 0xff}); + NAMES.put("mediumpurple", new int[]{0x93, 0x70, 0xdb, 0xff}); + NAMES.put("amethyst", new int[]{0x99, 0x66, 0xcc, 0xff}); + NAMES.put("blueviolet", new int[]{0x8a, 0x2b, 0xe2, 0xff}); + NAMES.put("darkviolet", new int[]{0x94, 0x00, 0xd3, 0xff}); + NAMES.put("darkorchid", new int[]{0x99, 0x32, 0xcc, 0xff}); + NAMES.put("darkmagenta", new int[]{0x8b, 0x00, 0x8b, 0xff}); + NAMES.put("purple", new int[]{0x80, 0x00, 0x80, 0xff}); + NAMES.put("indigo", new int[]{0x4b, 0x00, 0x82, 0xff}); + NAMES.put("slateblue", new int[]{0x6a, 0x5a, 0xcd, 0xff}); + NAMES.put("darkslateblue", new int[]{0x48, 0x3d, 0x8b, 0xff}); + NAMES.put("mediumslateblue", new int[]{0x7b, 0x68, 0xee, 0xff}); + + //Green color names + NAMES.put("greenyellow", new int[]{0xad, 0xff, 0x2f, 0xff}); + NAMES.put("chartreuse", new int[]{0x7f, 0xff, 0x00, 0xff}); + NAMES.put("lawngreen", new int[]{0x7c, 0xfc, 0x00, 0xff}); + NAMES.put("lime", new int[]{0x00, 0xff, 0x00, 0xff}); + NAMES.put("limegreen", new int[]{0x32, 0xcd, 0x32, 0xff}); + NAMES.put("palegreen", new int[]{0x98, 0xfb, 0x98, 0xff}); + NAMES.put("lightgreen", new int[]{0x90, 0xee, 0x90, 0xff}); + NAMES.put("mediumspringgreen", new int[]{0x00, 0xfa, 0x9a, 0xff}); + NAMES.put("springgreen", new int[]{0x00, 0xff, 0x7f, 0xff}); + NAMES.put("mediumseagreen", new int[]{0x3c, 0xb3, 0x71, 0xff}); + NAMES.put("seagreen", new int[]{0x2e, 0x8b, 0x57, 0xff}); + NAMES.put("forestgreen", new int[]{0x22, 0x8b, 0x22, 0xff}); + NAMES.put("green", new int[]{0x00, 0x80, 0x00, 0xff}); + NAMES.put("darkgreen", new int[]{0x00, 0x64, 0x00, 0xff}); + NAMES.put("yellowgreen", new int[]{0x9a, 0xcd, 0x32, 0xff}); + NAMES.put("olivedrab", new int[]{0x6b, 0x8e, 0x23, 0xff}); + NAMES.put("olive", new int[]{0x80, 0x80, 0x00, 0xff}); + NAMES.put("darkolivegreen", new int[]{0x55, 0x6b, 0x2f, 0xff}); + NAMES.put("mediumaquamarine", new int[]{0x66, 0xcd, 0xaa, 0xff}); + NAMES.put("darkseagreen", new int[]{0x8f, 0xbc, 0x8f, 0xff}); + NAMES.put("lightseagreen", new int[]{0x20, 0xb2, 0xaa, 0xff}); + NAMES.put("darkcyan", new int[]{0x00, 0x8b, 0x8b, 0xff}); + NAMES.put("teal", new int[]{0x00, 0x80, 0x80, 0xff}); + + //Blue color names + NAMES.put("aqua", new int[]{0x00, 0xff, 0xff, 0xff}); + NAMES.put("cyan", new int[]{0x00, 0xff, 0xff, 0xff}); + NAMES.put("lightcyan", new int[]{0xe0, 0xff, 0xff, 0xff}); + NAMES.put("paleturquoise", new int[]{0xaf, 0xee, 0xee, 0xff}); + NAMES.put("aquamarine", new int[]{0x7f, 0xff, 0xd4, 0xff}); + NAMES.put("turquoise", new int[]{0x40, 0xe0, 0xd0, 0xff}); + NAMES.put("mediumturquoise", new int[]{0x48, 0xd1, 0xcc, 0xff}); + NAMES.put("darkturquoise", new int[]{0x00, 0xce, 0xd1, 0xff}); + NAMES.put("cadetblue", new int[]{0x5f, 0x9e, 0xa0, 0xff}); + NAMES.put("steelblue", new int[]{0x46, 0x82, 0xb4, 0xff}); + NAMES.put("lightsteelblue", new int[]{0xb0, 0xc4, 0xde, 0xff}); + NAMES.put("powderblue", new int[]{0xb0, 0xe0, 0xe6, 0xff}); + NAMES.put("lightblue", new int[]{0xad, 0xd8, 0xe6, 0xff}); + NAMES.put("skyblue", new int[]{0x87, 0xce, 0xeb, 0xff}); + NAMES.put("lightskyblue", new int[]{0x87, 0xce, 0xfa, 0xff}); + NAMES.put("deepskyblue", new int[]{0x00, 0xbf, 0xff, 0xff}); + NAMES.put("dodgerblue", new int[]{0x1e, 0x90, 0xff, 0xff}); + NAMES.put("cornflowerblue", new int[]{0x64, 0x95, 0xed, 0xff}); + NAMES.put("royalblue", new int[]{0x41, 0x69, 0xe1, 0xff}); + NAMES.put("blue", new int[]{0x00, 0x00, 0xff, 0xff}); + NAMES.put("mediumblue", new int[]{0x00, 0x00, 0xcd, 0xff}); + NAMES.put("darkblue", new int[]{0x00, 0x00, 0x8b, 0xff}); + NAMES.put("navy", new int[]{0x00, 0x00, 0x80, 0xff}); + NAMES.put("midnightblue", new int[]{0x19, 0x19, 0x70, 0xff}); + + //Brown color names + NAMES.put("cornsilk", new int[]{0xff, 0xf8, 0xdc, 0xff}); + NAMES.put("blanchedalmond", new int[]{0xff, 0xeb, 0xcd, 0xff}); + NAMES.put("bisque", new int[]{0xff, 0xe4, 0xc4, 0xff}); + NAMES.put("navajowhite", new int[]{0xff, 0xde, 0xad, 0xff}); + NAMES.put("wheat", new int[]{0xf5, 0xde, 0xb3, 0xff}); + NAMES.put("burlywood", new int[]{0xde, 0xb8, 0x87, 0xff}); + NAMES.put("tan", new int[]{0xd2, 0xb4, 0x8c, 0xff}); + NAMES.put("rosybrown", new int[]{0xbc, 0x8f, 0x8f, 0xff}); + NAMES.put("sandybrown", new int[]{0xf4, 0xa4, 0x60, 0xff}); + NAMES.put("goldenrod", new int[]{0xda, 0xa5, 0x20, 0xff}); + NAMES.put("darkgoldenrod", new int[]{0xb8, 0x86, 0x0b, 0xff}); + NAMES.put("peru", new int[]{0xcd, 0x85, 0x3f, 0xff}); + NAMES.put("chocolate", new int[]{0xd2, 0x69, 0x1e, 0xff}); + NAMES.put("saddlebrown", new int[]{0x8b, 0x45, 0x13, 0xff}); + NAMES.put("sienna", new int[]{0xa0, 0x52, 0x2d, 0xff}); + NAMES.put("brown", new int[]{0xa5, 0x2a, 0x2a, 0xff}); + NAMES.put("maroon", new int[]{0x80, 0x00, 0x00, 0xff}); + + //White color names + NAMES.put("white", new int[]{0xff, 0xff, 0xff, 0xff}); + NAMES.put("snow", new int[]{0xff, 0xfa, 0xfa, 0xff}); + NAMES.put("honeydew", new int[]{0xf0, 0xff, 0xf0, 0xff}); + NAMES.put("mintcream", new int[]{0xf5, 0xff, 0xfa, 0xff}); + NAMES.put("azure", new int[]{0xf0, 0xff, 0xff, 0xff}); + NAMES.put("aliceblue", new int[]{0xf0, 0xf8, 0xff, 0xff}); + NAMES.put("ghostwhite", new int[]{0xf8, 0xf8, 0xff, 0xff}); + NAMES.put("whitesmoke", new int[]{0xf5, 0xf5, 0xf5, 0xff}); + NAMES.put("seashell", new int[]{0xff, 0xf5, 0xee, 0xff}); + NAMES.put("beige", new int[]{0xf5, 0xf5, 0xdc, 0xff}); + NAMES.put("oldlace", new int[]{0xfd, 0xf5, 0xe6, 0xff}); + NAMES.put("floralwhite", new int[]{0xff, 0xfa, 0xf0, 0xff}); + NAMES.put("ivory", new int[]{0xff, 0xff, 0xf0, 0xff}); + NAMES.put("antiquewhite", new int[]{0xfa, 0xeb, 0xd7, 0xff}); + NAMES.put("linen", new int[]{0xfa, 0xf0, 0xe6, 0xff}); + NAMES.put("lavenderblush", new int[]{0xff, 0xf0, 0xf5, 0xff}); + NAMES.put("mistyrose", new int[]{0xff, 0xe4, 0xe1, 0xff}); + + //Grey color names + NAMES.put("gainsboro", new int[]{0xdc, 0xdc, 0xdc, 0xff}); + NAMES.put("lightgrey", new int[]{0xd3, 0xd3, 0xd3, 0xff}); + NAMES.put("silver", new int[]{0xc0, 0xc0, 0xc0, 0xff}); + NAMES.put("darkgray", new int[]{0xa9, 0xa9, 0xa9, 0xff}); + NAMES.put("gray", new int[]{0x80, 0x80, 0x80, 0xff}); + NAMES.put("dimgray", new int[]{0x69, 0x69, 0x69, 0xff}); + NAMES.put("lightslategray", new int[]{0x77, 0x88, 0x99, 0xff}); + NAMES.put("slategray", new int[]{0x70, 0x80, 0x90, 0xff}); + NAMES.put("darkslategray", new int[]{0x2f, 0x4f, 0x4f, 0xff}); + NAMES.put("black", new int[]{0x00, 0x00, 0x00, 0xff}); + + //Transparent color names + NAMES.put("transparent", new int[]{0xff, 0xff, 0xff, 0x00}); } /** @@ -258,6 +281,6 @@ public class WebColors extends HashMap { throw new IllegalArgumentException("Color '" + name + "' not found."); c = (int[]) NAMES.get(name); - return new Color(c[0], c[1], c[2], 255); + return new Color(c[0], c[1], c[2], c[3]); } } \ No newline at end of file From e847825b7a93278f8cf65a21aefcb8a5a49d9ac9 Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Tue, 24 Dec 2019 09:48:44 +0800 Subject: [PATCH 12/15] =?UTF-8?q?REPORT-25504=20=20=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E4=B8=AD=E7=9A=84=E5=86=85=E5=AE=B9=E4=B8=8D=E6=8C=89?= =?UTF-8?q?=E7=85=A7=E5=88=97=E5=AE=BD=E8=BF=9B=E8=A1=8C=E6=8D=A2=E8=A1=8C?= =?UTF-8?q?=EF=BC=8C=E8=A1=8C=E9=AB=98=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../text/html/simpleparser/HTMLWorker.java | 14 +++-- .../text/html/simpleparser/IncTable.java | 54 ++++++++++++++-- .../fr/third/v2/lowagie/text/pdf/PdfPRow.java | 61 +++++++++++++++++++ 3 files changed, 121 insertions(+), 8 deletions(-) diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java index ade85f5cf..74a7a3af7 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java @@ -63,6 +63,7 @@ import java.util.Map; import java.util.Stack; import java.util.StringTokenizer; +import com.fr.third.v2.lowagie.text.Cell; import com.fr.third.v2.lowagie.text.DocumentException; import com.fr.third.v2.lowagie.text.Element; import com.fr.third.v2.lowagie.text.ExceptionConverter; @@ -74,6 +75,8 @@ import com.fr.third.v2.lowagie.text.Rectangle; import com.fr.third.v2.lowagie.text.TextElementArray; import com.fr.third.v2.lowagie.text.html.CSSUtils; import com.fr.third.v2.lowagie.text.html.HtmlTags; +import com.fr.third.v2.lowagie.text.pdf.PdfCell; +import com.fr.third.v2.lowagie.text.pdf.PdfPCell; import com.fr.third.v2.lowagie.text.pdf.draw.LineSeparator; import com.fr.third.v2.lowagie.text.xml.simpleparser.SimpleXMLDocHandler; import com.fr.third.v2.lowagie.text.html.Markup; @@ -661,10 +664,13 @@ public class HTMLWorker implements SimpleXMLDocHandler, DocListener { cprops.removeChain("tr"); ArrayList cells = new ArrayList(); IncTable table = null; + float maxHeight = 0; while (true) { Object obj = stack.pop(); - if (obj instanceof IncCell) { - cells.add(((IncCell) obj).getCell()); + if (obj instanceof IncCell) { + PdfPCell cell = ((IncCell) obj).getCell(); + cells.add(cell); + maxHeight = Math.max(maxHeight, cell.getStyleHeight()); } if (obj instanceof IncTable) { table = (IncTable) obj; @@ -672,11 +678,11 @@ public class HTMLWorker implements SimpleXMLDocHandler, DocListener { } } float rowHeight = 0.0f; - if(rowHeightPx!=null){ + if (rowHeightPx != null) { rowHeight = CSSUtils.parseFloat(rowHeightPx); } table.addCols(cells); - table.endRow(rowHeight); + table.endRow(Math.max(rowHeight, maxHeight)); stack.push(table); skipText = true; 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 5da1eb4ca..9c99d6370 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 @@ -50,6 +50,7 @@ package com.fr.third.v2.lowagie.text.html.simpleparser; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.List; import com.fr.third.v2.lowagie.text.html.CSSUtils; import com.fr.third.v2.lowagie.text.html.Markup; @@ -66,6 +67,7 @@ public class IncTable { private HashMap props = new HashMap(); private ArrayList rows = new ArrayList(); private ArrayList cols; + private List rowIndex4ZeroHeight = new ArrayList(); private ArrayList rowHeights = new ArrayList(); private ArrayList relativeColWidths = new ArrayList(); @@ -88,6 +90,9 @@ public class IncTable { } public void endRow(float rowHeight) { + if (rowHeight == 0) { + rowIndex4ZeroHeight.add(rowHeights.size()); + } rowHeights.add(rowHeight); if (cols != null) { Collections.reverse(cols); @@ -204,12 +209,53 @@ public class IncTable { } public void processRowHeight(PdfPTable table) { - Float height = CSSUtils.parseFloat((String) props.get("height")); - Float eachHeight = height / table.getRows().size(); + adjustRowHeight(CSSUtils.parseFloat((String) props.get("height"))); //调整行高 - for (int a = 0; a < rowHeights.size(); a++) { - table.getRow(a).setStyleHeight(Math.max(eachHeight, rowHeights.get(a))); + for (int i = 0; i < rowHeights.size(); i++) { + table.getRow(i).setStyleHeight(rowHeights.get(i)); + } + } + + /** + * 调整行高 + * 1、若 tableHeight < rowHeightSum , return ,每行扔取取指定的 height (该行的最大值) + * 2、若 tableHeight > rowHeightSum ,每行都有指定 height (该行的最大值),则按比例平分tableHeight + * 3、若 tableHeight > rowHeightSum ,有些行没有指定 height ,则将tableHeight - rowHeightSum ,平分给这些行 + * 最后,若计算出的内容高度大于上述计算出的行高,则取内容高度 + * + * @param tableHeight + */ + private void adjustRowHeight(Float tableHeight) { + if (0 > tableHeight) { + return; + } + float totalHeight = getRowHeightSum(); + if (tableHeight < totalHeight) { + return; + } + float extraHeight = tableHeight - totalHeight; + int size = rowIndex4ZeroHeight.size(); + //多出来的高度平分给没有设置高度的行 + if (size > 0) { + float eachHeight = extraHeight / size; + for (int i = 0; i < size; i++) { + rowHeights.set(rowIndex4ZeroHeight.get(i), eachHeight); + } + } + //按比例分 + else { + for (int i = 0; i < rowHeights.size(); i++) { + rowHeights.set(i, tableHeight * rowHeights.get(i) / totalHeight); + } + } + } + + private float getRowHeightSum() { + float sum = 0; + for (int i = 0; i < rowHeights.size(); i++) { + sum += rowHeights.get(i); } + return sum; } public TableProperties parseTableProperties(){ diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPRow.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPRow.java index ed4a6b24a..466ee0df8 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPRow.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfPRow.java @@ -50,12 +50,19 @@ package com.fr.third.v2.lowagie.text.pdf; import java.awt.Color; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; import com.fr.third.v2.lowagie.text.ExceptionConverter; import com.fr.third.v2.lowagie.text.DocumentException; import com.fr.third.v2.lowagie.text.Element; import com.fr.third.v2.lowagie.text.Image; +import com.fr.third.v2.lowagie.text.ListItem; +import com.fr.third.v2.lowagie.text.Paragraph; import com.fr.third.v2.lowagie.text.Rectangle; +import com.fr.third.v2.lowagie.text.html.CSS; /** * A row in a PdfPTable. @@ -155,10 +162,64 @@ public class PdfPRow { --k; cell.setRight(total); cell.setTop(0); + processColWidth(cell.getColumn().getCompositeElements(), cell.getWidth()); } return true; } + /** + * @param list + * @param width + */ + private void processColWidth(List list, float width) { + if (null == list) { + return; + } + String widthStr = String.valueOf(width); + //调整列宽,不然内容换行任取指定的width + for (int i = 0; i < list.size(); i++) { + setStyleWidth(list.get(i), widthStr); + } + } + + private void setStyleWidth(Element element, String width) { + if (null == element) { + return; + } + try { + switch (element.type()) { + case Element.PARAGRAPH: { + HashMap attr = ((Paragraph) element).getAttributes(); + attr.put(CSS.Property.WIDTH, width); + break; + } + case Element.LIST: { + com.fr.third.v2.lowagie.text.List list = (com.fr.third.v2.lowagie.text.List) element; + for (Iterator i = list.getList().iterator(); i.hasNext(); ) { + setStyleWidth((Element) i.next(), width); + } + break; + } + case Element.LISTITEM: { + ListItem listItem = (ListItem) element; + for (Iterator i = listItem.iterator(); i.hasNext(); ) { + setStyleWidth((Element) i.next(), width); + } + break; + } + case Element.PTABLE: { + PdfPTable table = (PdfPTable) element; + table.setTotalWidth(Float.parseFloat(width)); + break; + } + default: + return; + } + } catch (Exception e) { + throw new ExceptionConverter(e); + } + } + /** * Initializes the extra heights array. * @since 2.1.6 From e68d07359900e7febd0d2f5703ad10d5395796d8 Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Sat, 8 Feb 2020 11:49:55 +0800 Subject: [PATCH 13/15] =?UTF-8?q?REPORT-14598=20pdf=20HTML=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=8D=A2=E8=A1=8C=E4=B8=8E=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/third/v2/lowagie/text/pdf/PdfFont.java | 62 ++++++++++++------- .../xml/simpleparser/SimpleXMLParser.java | 9 ++- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfFont.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfFont.java index d81d3c878..5e5f7b675 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfFont.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfFont.java @@ -52,6 +52,9 @@ package com.fr.third.v2.lowagie.text.pdf; import com.fr.third.v2.lowagie.text.ExceptionConverter; import com.fr.third.v2.lowagie.text.Font; import com.fr.third.v2.lowagie.text.Image; +import java.awt.font.TextAttribute; +import java.util.HashMap; +import java.util.Map; import sun.font.FontDesignMetrics; import java.awt.FontMetrics; @@ -78,6 +81,8 @@ public class PdfFont implements Comparable { private Font oriFont; + public static int SCALE = 100; + /** the font metrics. */ // private BaseFont font; @@ -153,6 +158,15 @@ public class PdfFont implements Comparable { return width(' '); } + private FontMetrics metrics; + + private FontMetrics getMetrics() { + if (null == metrics) { + metrics = FontDesignMetrics.getMetrics(getAwtFont(SCALE)); + } + return metrics; + } + /** * Returns the width of a certain character of this font. * @@ -161,44 +175,44 @@ public class PdfFont implements Comparable { */ float width(int character) { - FontMetrics metrics = FontDesignMetrics.getMetrics(getAwtFont()); - if (image == null) - return metrics.charWidth(character) * hScale; - else - return image.getScaledWidth(); + return image == null ? getMetrics().charWidth(replaceNbsp(character))/SCALE : image.getScaledWidth(); } float width(String s) { - double width = 0.0d; - java.awt.Font font = this.getAwtFont(); - if (font.getSize2D() > 0) { - float scale = ONE_THOUSAND / font.getSize2D(); - java.awt.Font derivedFont = font.deriveFont(AffineTransform.getScaleInstance(scale, scale)); - width = derivedFont.getStringBounds(s, new FontRenderContext(new AffineTransform(), true, true)).getWidth(); - if (derivedFont.isTransformed()){ - width /= scale; - } - } - if (image == null) - return (float) width * hScale; - else - return image.getScaledWidth(); + return image == null ? getMetrics().stringWidth(replaceNbsp(s))/SCALE : image.getScaledWidth(); + } + + String replaceNbsp(String str) { + return canDisplayNbsp() ? str : str.replaceAll(String.valueOf((char) 160), String.valueOf((char) 32)); + } + + int replaceNbsp(int character) { + return character == 160 ? (canDisplayNbsp() ? character : 32) : character; } + private boolean canDisplayNbsp() { + return getAwtFont().canDisplay((char) 160); + } BaseFont getFont() { return oriFont.getCalculatedBaseFont(false); } public java.awt.Font getAwtFont() { - int style = Font.NORMAL; + return getAwtFont(1); + } + + private java.awt.Font getAwtFont(int scale) { + Map attrMap = new HashMap(4); + attrMap.put(TextAttribute.FAMILY, oriFont.getFontName()); + attrMap.put(TextAttribute.SIZE, new Float(oriFont.getSize() * scale)); if (oriFont.isBold()) { - style |= Font.BOLD; + attrMap.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); } - if(oriFont.isItalic()){ - style |= Font.ITALIC; + if (oriFont.isItalic()) { + attrMap.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE); } - return new java.awt.Font(oriFont.getFontName(), style, (int)oriFont.getSize()); + return new java.awt.Font(attrMap); } public Font getOriFont(){ diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/xml/simpleparser/SimpleXMLParser.java b/fine-itext/src/com/fr/third/v2/lowagie/text/xml/simpleparser/SimpleXMLParser.java index 2a15f56ff..f74d54011 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/xml/simpleparser/SimpleXMLParser.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/xml/simpleparser/SimpleXMLParser.java @@ -335,6 +335,8 @@ public final class SimpleXMLParser { return; } state = restoreState(); + //防止 如
等标签后面的空格键生效 + nowhite = false; break; // we are processing CDATA @@ -377,8 +379,11 @@ public final class SimpleXMLParser { char ce = EntitiesToUnicode.decodeEntity(cent); if (ce == '\0') text.append('&').append(cent).append(';'); - else - text.append(ce); + else { + text.append(ce); + //防止如   等标签后面的空格无效 + nowhite = true; + } } else if ((character != '#' && (character < '0' || character > '9') && (character < 'a' || character > 'z') && (character < 'A' || character > 'Z')) || entity.length() >= 7) { state = restoreState(); From 7255663d3b2d93d62c9482e7eda7555c11358bec Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Tue, 11 Feb 2020 11:51:14 +0800 Subject: [PATCH 14/15] =?UTF-8?q?REPORT-14598=20pdf=20HTML=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=8D=A2=E8=A1=8C=E4=B8=8E=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SpaceWithPunctuationBreakIterator.java | 30 +++++++- .../text/html/simpleparser/HTMLWorker.java | 5 ++ .../third/v2/lowagie/text/pdf/PdfChunk.java | 40 +++++++--- .../fr/third/v2/lowagie/text/pdf/PdfFont.java | 74 ++++++++++++++----- 4 files changed, 121 insertions(+), 28 deletions(-) diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/SpaceWithPunctuationBreakIterator.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/SpaceWithPunctuationBreakIterator.java index 94322266b..1d4c7b035 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/SpaceWithPunctuationBreakIterator.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/html/SpaceWithPunctuationBreakIterator.java @@ -13,16 +13,23 @@ public class SpaceWithPunctuationBreakIterator extends BreakIterator { private int currentPos = -1; private int currentIndex = -1; private boolean[] spaceIndex; + //不作为break分词的字符 + private boolean[] noSwitchIndex; public SpaceWithPunctuationBreakIterator(String text, BreakIterator iterator){ this.iterator = iterator; iterator.setText(text); this.spaceIndex = new boolean[text.length()]; + this.noSwitchIndex = new boolean[text.length()]; int ilen = text.length() - 1; if(ilen > 0) { for (int i = 0; i < ilen; i++) { char c = text.charAt(i); - spaceIndex[i + 1] = (c == ' ' && isPunctuation(text.charAt(i + 1)) )|| c == '-' || c == '\u2010' || c== '\n'; + //中文的标点符号都是可以直接断开的 + spaceIndex[i + 1] = (c == ' ' && isPunctuation(text.charAt(i + 1)) )|| c == '-' || c == '\u2010' || c== '\n'|| isChinesePunctuation( c); + //需要保证下一个字符不是中文,下一个字符如果是中文的话,允许分行 + char nextC = text.charAt(i+1); + noSwitchIndex[i + 1] = (c=='/' || c == '.' || c == ':' || c == ';') && !isChinese(nextC); } } } @@ -32,6 +39,23 @@ public class SpaceWithPunctuationBreakIterator extends BreakIterator { return code == 24 || code == 20 || code == 21 || code == 22 || code == 23; } + public boolean isChinese(char c){ + return c >= 0x4E00 && c <= 0x9FBF; + } + + // 根据UnicodeBlock方法判断中文标点符号 + public boolean isChinesePunctuation(char c) { + Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); + if (ub == Character.UnicodeBlock.GENERAL_PUNCTUATION + || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION + || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS + || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS) { + return true; + } else { + return false; + } + } + public int first() { throw new UnsupportedOperationException(); } @@ -48,6 +72,10 @@ public class SpaceWithPunctuationBreakIterator extends BreakIterator { if(currentIndex == currentPos) { currentPos = this.iterator.next(); } + if (currentPos > -1 && currentPos < noSwitchIndex.length && noSwitchIndex[currentPos]) { + currentIndex = currentPos; + return this.next(); + } for(int i = currentIndex + 1; i < currentPos; i++){ if(spaceIndex[i]){ currentIndex = i; diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java index 7e9254e71..245155736 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java @@ -50,6 +50,7 @@ package com.fr.third.v2.lowagie.text.html.simpleparser; +import com.fr.third.v2.lowagie.text.pdf.PdfFont; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.File; @@ -159,6 +160,10 @@ public class HTMLWorker implements SimpleXMLDocHandler, DocListener { return parseToList(reader, style, null); } + public static void initDefaultFont(String fontName) { + PdfFont.initDefaultFont(fontName); + } + public static ArrayList parseToList(Reader reader, StyleSheet style, HashMap interfaceProps) throws IOException { HTMLWorker worker = new HTMLWorker(null); diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java index 8d014cd80..8d12c2a14 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfChunk.java @@ -53,6 +53,7 @@ import java.awt.Color; import java.awt.FontMetrics; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Locale; import java.util.Map; @@ -92,6 +93,8 @@ public class PdfChunk { private static final String BREAK_TAG = "
"; + private final static char EMPTY_SYMBOL = ' '; + private boolean breakTag = false; public float getHeight() { @@ -309,7 +312,6 @@ public class PdfChunk { if (splitCharacter == null) splitCharacter = DefaultSplitCharacter.DEFAULT; } - // methods /** Gets the Unicode equivalent to a CID. @@ -362,11 +364,11 @@ public class PdfChunk { // or until the totalWidth is reached int length = value.length(); char valueArray[] = value.toCharArray(); - BreakIterator iterator = BreakIterator.getLineInstance(Locale.getDefault()); - BreakIterator iterator1 = new SpaceWithPunctuationBreakIterator(value, iterator); + BreakIterator iterator = new SpaceWithPunctuationBreakIterator(value, BreakIterator.getLineInstance(Locale.getDefault())); char character = 0; + boolean hasEmptySymbolEndOfLine = false; //行末有空格存在 ps:不存在连续空格键 while (currentPosition < length) { - int next = iterator1.next(); + int next = iterator.next(); if(next < 1){ break; } @@ -386,11 +388,17 @@ public class PdfChunk { } String substring = value.substring(start, next); currentWidth += font.width(substring); - if (currentWidth + indent.getRight() > width){ - currentPosition = start - 1; + if (currentWidth + indent.getRight() > width) { + if (dealWithEmptySymbol(substring, currentWidth + indent.getRight(), width)) { + //行末空格(加上该空格大于限制的行宽,减去则小于限制的行宽)、需要去掉该空格,不然下划线、删除线什么的会变长 + //该空格不能留给下一行 + hasEmptySymbolEndOfLine=true; + start = next; + } else { + currentPosition = start - 1; + } break; } - start = next; } @@ -401,12 +409,26 @@ public class PdfChunk { } // otherwise, the string has to be truncated String returnValue = value.substring(start); - value = value.substring(0, start); + value = value.substring(0, start - (hasEmptySymbolEndOfLine ? 1 : 0)); PdfChunk pc = new PdfChunk(returnValue, this); return pc; } -/** + /** + * @param text 文本 + * @param totalWidth 已经处理过的文本和当前文本的宽度和 + * @param lineWidth 行宽 + * @return true : 去掉text末尾的空格后小于行宽 + */ + private boolean dealWithEmptySymbol(String text, float totalWidth, float lineWidth) { + if (null == text || 0 == text.length()) { + return false; + } + //HTML解析后不存在连续多个空格键存在的情况,因此只需去除末尾的空格键 + return text.charAt(text.length() - 1) == EMPTY_SYMBOL && totalWidth - getFont().width(EMPTY_SYMBOL) < lineWidth; + } + + /** * Truncates this PdfChunk if it's too long for the given width. *

* Returns null if the PdfChunk wasn't truncated. diff --git a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfFont.java b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfFont.java index 5e5f7b675..31592eed7 100644 --- a/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfFont.java +++ b/fine-itext/src/com/fr/third/v2/lowagie/text/pdf/PdfFont.java @@ -77,11 +77,12 @@ import java.awt.geom.AffineTransform; */ public class PdfFont implements Comparable { - private static final int ONE_THOUSAND = 1000 ; private Font oriFont; - public static int SCALE = 100; + public static float SCALE = 100; + + private static String DEFAULT_FONT_NAME = ""; /** the font metrics. */ // private BaseFont font; @@ -101,6 +102,12 @@ public class PdfFont implements Comparable { this.oriFont = oriFont; } + public static void initDefaultFont(String fontName) { + if ("" == DEFAULT_FONT_NAME && null != fontName) { + DEFAULT_FONT_NAME = fontName; + } + } + // methods /** @@ -160,9 +167,14 @@ public class PdfFont implements Comparable { private FontMetrics metrics; - private FontMetrics getMetrics() { - if (null == metrics) { - metrics = FontDesignMetrics.getMetrics(getAwtFont(SCALE)); + private java.awt.Font scaleFont; + + private java.awt.Font scaleDefaultFont; + + private FontMetrics getMetrics(java.awt.Font font) { + if (null == metrics || !font.equals(metrics.getFont())) { + metrics = FontDesignMetrics.getMetrics(font); + return metrics; } return metrics; } @@ -174,16 +186,27 @@ public class PdfFont implements Comparable { * @return a width in Text Space */ - float width(int character) { - return image == null ? getMetrics().charWidth(replaceNbsp(character))/SCALE : image.getScaledWidth(); - } - - float width(String s) { - return image == null ? getMetrics().stringWidth(replaceNbsp(s))/SCALE : image.getScaledWidth(); + public float width(int character) { + if (null != image) { + return image.getScaledWidth(); + } + java.awt.Font font = getScaleAwtFont(); + font = font.canDisplay(character) ? font : getScaleDefaultAwtFont(); + return getMetrics(font).charWidth(replaceNbsp(character)) / SCALE; } - String replaceNbsp(String str) { - return canDisplayNbsp() ? str : str.replaceAll(String.valueOf((char) 160), String.valueOf((char) 32)); + public float width(String s) { + if (null != image) { + return image.getScaledWidth(); + } + if (null == s) { + return 0f; + } + float num = 0f; + for (int i = 0; i < s.length(); i++) { + num += width(s.charAt(i)); + } + return num; } int replaceNbsp(int character) { @@ -191,20 +214,35 @@ public class PdfFont implements Comparable { } private boolean canDisplayNbsp() { - return getAwtFont().canDisplay((char) 160); + return getScaleAwtFont().canDisplay((char) 160); } BaseFont getFont() { - return oriFont.getCalculatedBaseFont(false); + return oriFont.getCalculatedBaseFont(false); } public java.awt.Font getAwtFont() { - return getAwtFont(1); + return getAwtFont(oriFont.getFontName(), 1f); + } + + private java.awt.Font getScaleAwtFont() { + if (null == scaleFont) { + scaleFont = getAwtFont(oriFont.getFontName(), SCALE); + } + return scaleFont; } - private java.awt.Font getAwtFont(int scale) { + private java.awt.Font getScaleDefaultAwtFont() { + if (null == scaleDefaultFont) { + scaleDefaultFont = getAwtFont(DEFAULT_FONT_NAME, SCALE); + } + return scaleDefaultFont; + } + + + private java.awt.Font getAwtFont(String fontName,float scale) { Map attrMap = new HashMap(4); - attrMap.put(TextAttribute.FAMILY, oriFont.getFontName()); + attrMap.put(TextAttribute.FAMILY, fontName); attrMap.put(TextAttribute.SIZE, new Float(oriFont.getSize() * scale)); if (oriFont.isBold()) { attrMap.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); From 769d5c353bbabd6c3507f5437506ead237162cad Mon Sep 17 00:00:00 2001 From: zhouping Date: Sat, 15 Feb 2020 15:09:01 +0800 Subject: [PATCH 15/15] =?UTF-8?q?DEC-11975=20=E3=80=90=E5=86=92=E7=83=9F?= =?UTF-8?q?=E3=80=91jdk1.7=E9=80=82=E9=85=8D=E6=B5=8B=E8=AF=95=EF=BC=8C?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=82=AE=E7=AE=B1=E5=8F=91=E9=80=81=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.third_step1-jdk11.gradle | 1 + build.third_step1.gradle | 1 + .../resources/META-INF/javamail.charset.map | 77 +++++++++++++++++++ .../META-INF/javamail.default.address.map | 1 + .../META-INF/javamail.default.providers | 9 +++ .../src/main/resources/META-INF/mailcap | 16 ++++ .../main/resources/META-INF/mailcap.default | 9 +++ .../main/resources/META-INF/mimetypes.default | 25 ++++++ 8 files changed, 139 insertions(+) create mode 100644 fine-third-default/fine-mail/src/main/resources/META-INF/javamail.charset.map create mode 100644 fine-third-default/fine-mail/src/main/resources/META-INF/javamail.default.address.map create mode 100644 fine-third-default/fine-mail/src/main/resources/META-INF/javamail.default.providers create mode 100644 fine-third-default/fine-mail/src/main/resources/META-INF/mailcap create mode 100644 fine-third-default/fine-mail/src/main/resources/META-INF/mailcap.default create mode 100644 fine-third-default/fine-mail/src/main/resources/META-INF/mimetypes.default diff --git a/build.third_step1-jdk11.gradle b/build.third_step1-jdk11.gradle index 3fcf401e9..e9da553bd 100644 --- a/build.third_step1-jdk11.gradle +++ b/build.third_step1-jdk11.gradle @@ -135,6 +135,7 @@ def resourceDirs = [ "${srcDir}/fine-sense4/src", "${srcDir}/fine-third-default/fine-javax-el/src/main/java", "${srcDir}/fine-third-default/fine-mail/src/main/java", + "${srcDir}/fine-third-default/fine-mail/src/main/resources", "${srcDir}/fine-third-default/fine-javax-cdi/src/main/java", "${srcDir}/fine-third-default/fine-javax-jms/src/main/java", "${srcDir}/fine-third-default/fine-sun-misc/src/main/java", diff --git a/build.third_step1.gradle b/build.third_step1.gradle index 12768c744..8bf62f843 100644 --- a/build.third_step1.gradle +++ b/build.third_step1.gradle @@ -175,6 +175,7 @@ task copyFiles(type:Copy,dependsOn:'compileJava'){ with dataContent.call("${srcDir}/fine-sense4/src") with dataContent.call("${srcDir}/fine-third-default/fine-javax-el/src/main/java") with dataContent.call("${srcDir}/fine-third-default/fine-mail/src/main/java") + with dataContent.call("${srcDir}/fine-third-default/fine-mail/src/main/resources") with dataContent.call("${srcDir}/fine-third-default/fine-javax-cdi/src/main/java") with dataContent.call("${srcDir}/fine-third-default/fine-javax-jms/src/main/java") with dataContent.call("${srcDir}/fine-third-default/fine-sun-misc/src/main/java") diff --git a/fine-third-default/fine-mail/src/main/resources/META-INF/javamail.charset.map b/fine-third-default/fine-mail/src/main/resources/META-INF/javamail.charset.map new file mode 100644 index 000000000..cc58d4f98 --- /dev/null +++ b/fine-third-default/fine-mail/src/main/resources/META-INF/javamail.charset.map @@ -0,0 +1,77 @@ +### JDK-to-MIME charset mapping table #### +### This should be the first mapping table ### + +8859_1 ISO-8859-1 +iso8859_1 ISO-8859-1 +ISO8859-1 ISO-8859-1 + +8859_2 ISO-8859-2 +iso8859_2 ISO-8859-2 +ISO8859-2 ISO-8859-2 + +8859_3 ISO-8859-3 +iso8859_3 ISO-8859-3 +ISO8859-3 ISO-8859-3 + +8859_4 ISO-8859-4 +iso8859_4 ISO-8859-4 +ISO8859-4 ISO-8859-4 + +8859_5 ISO-8859-5 +iso8859_5 ISO-8859-5 +ISO8859-5 ISO-8859-5 + +8859_6 ISO-8859-6 +iso8859_6 ISO-8859-6 +ISO8859-6 ISO-8859-6 + +8859_7 ISO-8859-7 +iso8859_7 ISO-8859-7 +ISO8859-7 ISO-8859-7 + +8859_8 ISO-8859-8 +iso8859_8 ISO-8859-8 +ISO8859-8 ISO-8859-8 + +8859_9 ISO-8859-9 +iso8859_9 ISO-8859-9 +ISO8859-9 ISO-8859-9 + +SJIS Shift_JIS +JIS ISO-2022-JP +ISO2022JP ISO-2022-JP +EUC_JP euc-jp +KOI8_R koi8-r +EUC_CN euc-cn +EUC_TW euc-tw +EUC_KR euc-kr + +--DIVIDER: this line *must* start with "--" and end with "--" -- + +#### XXX-to-JDK charset mapping table #### + +iso-2022-cn ISO2022CN +iso-2022-kr ISO2022KR +utf-8 UTF8 +utf8 UTF8 +ja_jp.iso2022-7 ISO2022JP +ja_jp.eucjp EUCJIS + +# these two are not needed in 1.1.6. (since EUC_KR exists +# and KSC5601 will map to the correct converter) +euc-kr KSC5601 +euckr KSC5601 + +# in JDK 1.1.6 we will no longer need the "us-ascii" convert +us-ascii ISO-8859-1 +x-us-ascii ISO-8859-1 + +# Chinese charsets are a mess and widely misrepresented. +# gb18030 is a superset of gbk, which is a supserset of cp936/ms936, +# which is a superset of gb2312. +# https://bugzilla.gnome.org/show_bug.cgi?id=446783 +# map all of these to gb18030. +gb2312 GB18030 +cp936 GB18030 +ms936 GB18030 +gbk GB18030 diff --git a/fine-third-default/fine-mail/src/main/resources/META-INF/javamail.default.address.map b/fine-third-default/fine-mail/src/main/resources/META-INF/javamail.default.address.map new file mode 100644 index 000000000..4ab5572df --- /dev/null +++ b/fine-third-default/fine-mail/src/main/resources/META-INF/javamail.default.address.map @@ -0,0 +1 @@ +rfc822=smtp diff --git a/fine-third-default/fine-mail/src/main/resources/META-INF/javamail.default.providers b/fine-third-default/fine-mail/src/main/resources/META-INF/javamail.default.providers new file mode 100644 index 000000000..bedc076ff --- /dev/null +++ b/fine-third-default/fine-mail/src/main/resources/META-INF/javamail.default.providers @@ -0,0 +1,9 @@ +# JavaMail IMAP provider Oracle +protocol=imap; type=store; class=com.sun.mail.imap.IMAPStore; vendor=Oracle; +protocol=imaps; type=store; class=com.sun.mail.imap.IMAPSSLStore; vendor=Oracle; +# JavaMail SMTP provider Oracle +protocol=smtp; type=transport; class=com.sun.mail.smtp.SMTPTransport; vendor=Oracle; +protocol=smtps; type=transport; class=com.sun.mail.smtp.SMTPSSLTransport; vendor=Oracle; +# JavaMail POP3 provider Oracle +protocol=pop3; type=store; class=com.sun.mail.pop3.POP3Store; vendor=Oracle; +protocol=pop3s; type=store; class=com.sun.mail.pop3.POP3SSLStore; vendor=Oracle; diff --git a/fine-third-default/fine-mail/src/main/resources/META-INF/mailcap b/fine-third-default/fine-mail/src/main/resources/META-INF/mailcap new file mode 100644 index 000000000..5259ae77d --- /dev/null +++ b/fine-third-default/fine-mail/src/main/resources/META-INF/mailcap @@ -0,0 +1,16 @@ +# +# +# Default mailcap file for the JavaMail System. +# +# JavaMail content-handlers: +# +text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain +text/html;; x-java-content-handler=com.sun.mail.handlers.text_html +text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml +multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed; x-java-fallback-entry=true +message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822 +# +# can't support image types because java.awt.Toolkit doesn't work on servers +# +#image/gif;; x-java-content-handler=com.sun.mail.handlers.image_gif +#image/jpeg;; x-java-content-handler=com.sun.mail.handlers.image_jpeg diff --git a/fine-third-default/fine-mail/src/main/resources/META-INF/mailcap.default b/fine-third-default/fine-mail/src/main/resources/META-INF/mailcap.default new file mode 100644 index 000000000..73ce2fc7e --- /dev/null +++ b/fine-third-default/fine-mail/src/main/resources/META-INF/mailcap.default @@ -0,0 +1,9 @@ +# +# This is a very simple 'mailcap' file +# +# No default viewers are included so these entries are commented out. +# +#image/gif;; x-java-view=com.sun.activation.viewers.ImageViewer +#image/jpeg;; x-java-view=com.sun.activation.viewers.ImageViewer +#text/*;; x-java-view=com.sun.activation.viewers.TextViewer +#text/*;; x-java-edit=com.sun.activation.viewers.TextEditor diff --git a/fine-third-default/fine-mail/src/main/resources/META-INF/mimetypes.default b/fine-third-default/fine-mail/src/main/resources/META-INF/mimetypes.default new file mode 100644 index 000000000..1b4056b19 --- /dev/null +++ b/fine-third-default/fine-mail/src/main/resources/META-INF/mimetypes.default @@ -0,0 +1,25 @@ +# +# A simple, old format, mime.types file +# +text/html html htm HTML HTM +text/plain txt text TXT TEXT +image/gif gif GIF +image/ief ief +image/jpeg jpeg jpg jpe JPG +image/tiff tiff tif +image/png png PNG +image/x-xwindowdump xwd +application/postscript ai eps ps +application/rtf rtf +application/x-tex tex +application/x-texinfo texinfo texi +application/x-troff t tr roff +audio/basic au +audio/midi midi mid +audio/x-aifc aifc +audio/x-aiff aif aiff +audio/x-mpeg mpeg mpg +audio/x-wav wav +video/mpeg mpeg mpg mpe +video/quicktime qt mov +video/x-msvideo avi