Skip to content

Commit

Permalink
Feature to add standard border handling of (dynamic) text (eclipse-bi…
Browse files Browse the repository at this point in the history
  • Loading branch information
speckyspooky committed Nov 6, 2024
1 parent 29525b6 commit 687d865
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ private void buildForeignStyles(IForeignContent foreignContent, StringBuffer for
IStyle style = foreignContent.getComputedStyle();
foreignStyles.setLength(0);
buildTextAlign(foreignStyles, style);
if (!wrappedTable) {
buildForeignBorders(foreignStyles, style);
}
style = getElementStyle(foreignContent);
if (style == null) {
return;
Expand All @@ -522,6 +525,41 @@ private void buildForeignStyles(IForeignContent foreignContent, StringBuffer for
buildTextDecoration(foreignStyles, style);
}

protected void buildForeignBorders(StringBuffer foreignStyles, IStyle style) {
String borderStyle = style.getBorderBottomStyle();
if (hasBorder(borderStyle)) {
buildBorder(HTMLTags.ATTR_BORDER_BOTTOM, foreignStyles, borderStyle, style.getBorderBottomColor(),
style.getProperty(StyleConstants.STYLE_BORDER_BOTTOM_WIDTH));
}

borderStyle = style.getBorderTopStyle();
if (hasBorder(borderStyle)) {
buildBorder(HTMLTags.ATTR_BORDER_TOP, foreignStyles, borderStyle, style.getBorderTopColor(),
style.getProperty(StyleConstants.STYLE_BORDER_TOP_WIDTH));
}

borderStyle = style.getBorderLeftStyle();
if (hasBorder(borderStyle)) {
buildBorder(HTMLTags.ATTR_BORDER_LEFT, foreignStyles, borderStyle, style.getBorderLeftColor(),
style.getProperty(StyleConstants.STYLE_BORDER_LEFT_WIDTH));
}

borderStyle = style.getBorderRightStyle();
if (hasBorder(borderStyle)) {
buildBorder(HTMLTags.ATTR_BORDER_RIGHT, foreignStyles, borderStyle, style.getBorderRightColor(),
style.getProperty(StyleConstants.STYLE_BORDER_RIGHT_WIDTH));
}

}

private void buildBorder(String borderAttributeName, StringBuffer styleBuffer, String style, String color,
CSSValue width) {
addPropName(styleBuffer, borderAttributeName);
addPropValue(styleBuffer, width.getCssText() + " " + style + " #"
+ WordUtil.parseColor(color));
styleBuffer.append(';');
}

private IStyle getElementStyle(IContent content) {
IStyle style = content.getInlineStyle();
if (style == null || style.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ protected void writeRunBorders(IStyle style) {
}
}

private boolean hasBorder(String borderStyle) {
protected boolean hasBorder(String borderStyle) {
return !(borderStyle == null || "none".equalsIgnoreCase(borderStyle));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public static String parseColor(String color) {
} else if (color.equalsIgnoreCase("Maroon")) {
return "800000";
} else if (color.equalsIgnoreCase("Orange")) {
return "#FFA500";
return "FFA500";
}
String[] values = color.substring(color.indexOf("(") + 1, color.length() - 1).split(",");
String value = "";
Expand Down

0 comments on commit 687d865

Please sign in to comment.