Skip to content
This repository has been archived by the owner on Nov 9, 2018. It is now read-only.

Commit

Permalink
Improves conformance to the builder pattern in RowDataProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Håkansson committed Aug 26, 2015
1 parent 75b3508 commit ed28777
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
Expand Up @@ -70,15 +70,11 @@ public void startBlock(BlockProperties p, String blockId) {
firstLineIndent(p.getFirstLineIndent()).
align(p.getAlignment()).
rowSpacing(p.getRowSpacing()).

blockIndent(blockIndent).
blockIndentParent(blockIndentParent.peek()).
leftMargin((Margin)leftMargin.clone()). //.stackMarginComp(formatterContext, false, false)
//leftMarginParent((Margin)leftMargin.clone()). //.stackMarginComp(formatterContext, true, false)
rightMargin((Margin)rightMargin.clone())//. //.stackMarginComp(formatterContext, false, true)
//rightMarginParent((Margin)rightMargin.clone())
; //.stackMarginComp(formatterContext, true, true)
rdp.addOuterSpaceBefore(p.getTopMargin());
leftMargin((Margin)leftMargin.clone()).
rightMargin((Margin)rightMargin.clone()).
outerSpaceBefore(p.getTopMargin());
Block c = newBlock(blockId, rdp.build());
if (propsContext.size()>0) {
if (propsContext.peek().getListType()!=FormattingTypes.ListStyle.NONE) {
Expand Down Expand Up @@ -109,10 +105,10 @@ public void startBlock(BlockProperties p, String blockId) {
if (p.getTextBorderStyle()!=null) {
TextBorderStyle t = p.getTextBorderStyle();
if (t.getTopLeftCorner().length()+t.getTopBorder().length()+t.getTopRightCorner().length()>0) {
builder.setLeadingDecoration(new SingleLineDecoration(t.getTopLeftCorner(), t.getTopBorder(), t.getTopRightCorner()));
builder.leadingDecoration(new SingleLineDecoration(t.getTopLeftCorner(), t.getTopBorder(), t.getTopRightCorner()));
}
}
builder.setInnerSpaceBefore(p.getTopPadding());
builder.innerSpaceBefore(p.getTopPadding());
bi.setRowDataProperties(builder.build());
//firstRow = true;
}
Expand All @@ -127,11 +123,11 @@ public void endBlock() {
if (p.getTextBorderStyle()!=null) {
TextBorderStyle t = p.getTextBorderStyle();
if (t.getBottomLeftCorner().length()+ t.getBottomBorder().length()+ t.getBottomRightCorner().length()>0) {
builder.setTrailingDecoration(new SingleLineDecoration(t.getBottomLeftCorner(), t.getBottomBorder(), t.getBottomRightCorner()));
builder.trailingDecoration(new SingleLineDecoration(t.getBottomLeftCorner(), t.getBottomBorder(), t.getBottomRightCorner()));
}
}
builder.setInnerSpaceAfter(p.getBottomPadding());
builder.addOuterSpaceAfter(p.getBottomMargin());
builder.innerSpaceAfter(p.getBottomPadding()).
outerSpaceAfter(bi.getRowDataProperties().getOuterSpaceAfter()+p.getBottomMargin());
bi.setKeepWithPreviousSheets(p.getKeepWithPreviousSheets());
bi.setRowDataProperties(builder.build());
leftMargin.pop();
Expand Down
Expand Up @@ -105,28 +105,34 @@ public Builder listProperties(ListItem value) {
return this;
}

public void addOuterSpaceBefore(int spaceBefore) {
this.outerSpaceBefore += spaceBefore;
public Builder outerSpaceBefore(int value) {
this.outerSpaceBefore = value;
return this;
}

public void addOuterSpaceAfter(int spaceAfter) {
this.outerSpaceAfter += spaceAfter;
public Builder outerSpaceAfter(int value) {
this.outerSpaceAfter = value;
return this;
}
public void setLeadingDecoration(SingleLineDecoration value) {

public Builder leadingDecoration(SingleLineDecoration value) {
this.leadingDecoration = value;
return this;
}

public void setInnerSpaceBefore(int value) {
public Builder innerSpaceBefore(int value) {
this.innerSpaceBefore = value;
return this;
}

public void setTrailingDecoration(SingleLineDecoration value) {
public Builder trailingDecoration(SingleLineDecoration value) {
this.trailingDecoration = value;
return this;
}

public void setInnerSpaceAfter(int value) {
public Builder innerSpaceAfter(int value) {
this.innerSpaceAfter = value;
return this;
}

public RowDataProperties build() {
Expand Down

0 comments on commit ed28777

Please sign in to comment.