Browse Source

REPORT-33780 font-weight等属性与<b>等标签之间的优先级存在问题

release/10.0
Hugh.C 5 years ago
parent
commit
9c1af33023
  1. 14
      fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java
  2. 8
      fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java

14
fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/FactoryProperties.java

@ -462,20 +462,30 @@ public class FactoryProperties {
dealWithFontSizeOrTextIndent(h, cprops, prop, key); dealWithFontSizeOrTextIndent(h, cprops, prop, key);
} else if (key.equals(Markup.CSS_KEY_FONTSTYLE)) { } else if (key.equals(Markup.CSS_KEY_FONTSTYLE)) {
String ss = prop.getProperty(key).trim().toLowerCase(); String ss = prop.getProperty(key).trim().toLowerCase();
if (ss.equals("italic") || ss.equals("oblique")) if (ss.equals("italic") || ss.equals("oblique")) {
h.put("i", null); h.put("i", null);
} else {
h.remove("i");
}
} else if (key.equals(Markup.CSS_KEY_FONTWEIGHT)) { } else if (key.equals(Markup.CSS_KEY_FONTWEIGHT)) {
String ss = prop.getProperty(key).trim().toLowerCase(); String ss = prop.getProperty(key).trim().toLowerCase();
if (ss.equals("bold") || ss.equals("700") || ss.equals("800") if (ss.equals("bold") || ss.equals("700") || ss.equals("800")
|| ss.equals("900")) || ss.equals("900")){
h.put("b", null); h.put("b", null);
}else {
h.remove("b");
}
} else if (key.equals(Markup.CSS_KEY_TEXTDECORATION)) { } else if (key.equals(Markup.CSS_KEY_TEXTDECORATION)) {
String ss = prop.getProperty(key).trim().toLowerCase(); String ss = prop.getProperty(key).trim().toLowerCase();
if (ss.equals(Markup.CSS_VALUE_UNDERLINE)) { if (ss.equals(Markup.CSS_VALUE_UNDERLINE)) {
h.remove("s");
h.put("u", null); h.put("u", null);
} else if (ss.equals(Markup.CSS_VALUE_LINETHROUGH)) { } else if (ss.equals(Markup.CSS_VALUE_LINETHROUGH)) {
h.remove("u");
h.put("s", null); h.put("s", null);
} else { } else {
h.remove("u");
h.remove("s");
h.put(key, ss); h.put(key, ss);
} }
} else if (key.equals(Markup.CSS_KEY_COLOR)) { } else if (key.equals(Markup.CSS_KEY_COLOR)) {

8
fine-itext/src/main/java/com/fr/third/v2/lowagie/text/html/simpleparser/HTMLWorker.java

@ -215,12 +215,15 @@ public class HTMLWorker implements SimpleXMLDocHandler, DocListener {
h.put(Markup.CSS_KEY_MARGINTOP, "16px"); h.put(Markup.CSS_KEY_MARGINTOP, "16px");
h.put(Markup.CSS_KEY_MARGINBOTTOM, "16px"); h.put(Markup.CSS_KEY_MARGINBOTTOM, "16px");
} }
if (tag.equals("th")) {
h.put("b", null);
}
String follow = (String) FactoryProperties.followTags.get(tag); String follow = (String) FactoryProperties.followTags.get(tag);
if (follow != null) { if (follow != null) {
HashMap prop = new HashMap(); HashMap prop = new HashMap();
prop.put(follow, null); prop.put(follow, null);
FactoryProperties.insertStyle(h, this.cprops);
prop.putAll(h); prop.putAll(h);
FactoryProperties.insertStyle(prop, this.cprops);
cprops.addToChain(follow, prop); cprops.addToChain(follow, prop);
return; return;
} }
@ -491,9 +494,6 @@ public class HTMLWorker implements SimpleXMLDocHandler, DocListener {
endElement(tag); endElement(tag);
skipText = false; skipText = false;
pendingTD = true; pendingTD = true;
if (tag.equals("th")) {
h.put("b", null);
}
cprops.addToChain("td", h); cprops.addToChain("td", h);
stack.push(new IncCell(tag, cprops)); stack.push(new IncCell(tag, cprops));
return; return;

Loading…
Cancel
Save