Skip to content

Commit

Permalink
Fix the doubled margin calculation of text elements (foreign text)
Browse files Browse the repository at this point in the history
  • Loading branch information
speckyspooky committed Sep 8, 2024
1 parent d45eaab commit cebadf2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void startForeign(IForeignContent foreign) throws BirtException {
wordWriter.startTableRow(-1);
wordWriter.startTableCell(width, foreign.getComputedStyle(), null, null);
// TODO:need text paser for foreign raw value
wordWriter.writeForeign(foreign);
wordWriter.writeForeign(foreign, true);
if (isInSpannedCell(foreign)) {
// insert empty line after embed html
wordWriter.endTableCell(true, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public abstract class BasicComponent extends AbstractWordXmlWriter {

private ReportDesignHandle handle;

protected boolean wrappedTable = true;

protected BasicComponent(IPart part) throws IOException {
this.part = part;
this.imageManager = (ImageManager) part.getPackage().getExtensionData();
Expand Down Expand Up @@ -307,6 +309,11 @@ protected void writeBookmark(String bm) {
bookmarkId++;
}

protected void writeForeign(IForeignContent foreignContent, boolean wrappedTable) {
this.wrappedTable = wrappedTable;
writeForeign(foreignContent);
}

protected void writeForeign(IForeignContent foreignContent) {
if (foreignContent.getRawValue() != null) {
String uri = "mhtText" + getMhtTextId() + ".mht";
Expand Down Expand Up @@ -563,9 +570,14 @@ private void buildBox(StringBuffer styleBuffer, IStyle style) {
private void buildMargins(StringBuffer styleBuffer, IStyle style) {
// build the margins
String topMargin = style.getMarginTop();
String rightMargin = style.getMarginRight();
String rightMargin = "0px";
String bottomMargin = style.getMarginBottom();
String leftMargin = style.getMarginLeft();
String leftMargin = "0px";

if (!wrappedTable) {
rightMargin = style.getMarginRight();
leftMargin = style.getMarginLeft();
}

if (null != topMargin && null != rightMargin && null != bottomMargin && null != leftMargin) {
if (rightMargin.equals(leftMargin)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ public void writeForeign(IForeignContent foreignContent) {
currentComponent.writeForeign(foreignContent);
}

@Override
public void writeForeign(IForeignContent foreignContent, boolean embedHTML) {
currentComponent.writeForeign(foreignContent, embedHTML);
}

@Override
public void endPage() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ void drawImage(byte[] data, double height, double width, HyperlinkInfo hyper, IS
*/
void writeForeign(IForeignContent foreignContent);

/**
* Write foreign
*
* @param foreignContent foreign content
* @param wrappedTable foreign text is wrapped with table
*/
void writeForeign(IForeignContent foreignContent, boolean wrappedTable);

/**
* Write content
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,10 @@ protected void writeVmerge(SpanInfo spanInfo) {
public void writeForeign(IForeignContent foreignContent) {
}

@Override
public void writeForeign(IForeignContent foreignContent, boolean wrappedTable) {
}

@Override
public void writePageBorders(IStyle style, int topMargin, int bottomMargin, int leftMargin, int rightMargin) {
// TODO Auto-generated method stub
Expand Down

0 comments on commit cebadf2

Please sign in to comment.