Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the doubled margin calculation of text elements (foreign text) #1900

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading