Skip to content

Commit 605031c

Browse files
committed
Merge branch 'develop'
2 parents dcd4822 + e9a0e5a commit 605031c

File tree

12 files changed

+165
-53
lines changed

12 files changed

+165
-53
lines changed

docgen/parameters.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"title" : "Venus (Fugerit Document Generation Framework)",
33
"name": "Venus",
4-
"version" : "0.5.8",
5-
"date" : "10/12/2022",
4+
"version" : "0.5.9",
5+
"date" : "11/12/2022",
66
"organization" : {
77
"name" : "Fugerit Org",
88
"url" : "https://www.fugerit.org"

docgen/release-notes.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
0.5.8 (2022-12-10)
1+
0.5.9 (2022-12-11)
2+
------------------
3+
+ Added support for style and align in simpletable module
4+
5+
0.5.8 (2022-12-10)
26
------------------
37
+ Added support for border width in simpletable module
48

fj-doc-base/src/main/java/org/fugerit/java/doc/base/config/DocConstants.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,21 @@ public class DocConstants {
99
public String getEuro() {
1010
return EURO;
1111
}
12+
13+
public static final String STYLE_BOLD = "bold";
14+
public static final String STYLE_UNDERLINE = "underline";
15+
public static final String STYLE_ITALIC = "italic";
16+
public static final String STYLE_BOLDITALIC = "bolditalic";
17+
public static final String STYLE_NORMAL = "normal";
18+
19+
public static final String ALIGN_CENTER = "center";
20+
public static final String ALIGN_RIGHT = "right";
21+
public static final String ALIGN_LEFT = "left";
22+
public static final String ALIGN_JUSTIFY = "justify";
23+
public static final String ALIGN_JUSTIFYALL = "justifyall";
24+
25+
public static final String VALIGN_MIDDLE = "middle";
26+
public static final String VALIGN_TOP = "top";
27+
public static final String VALIGN_BOTTOM = "bottom";
1228

1329
}

fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocPara.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ The Apache Software Foundation (http://www.apache.org/).
2525
*/
2626
package org.fugerit.java.doc.base.model;
2727

28+
import org.fugerit.java.doc.base.xml.DocStyleAlignHelper;
29+
2830
/**
2931
*
3032
*
@@ -216,19 +218,7 @@ public static int parseStyle( String style ) {
216218
}
217219

218220
public static int parseStyle( String style, int defaultStype ) {
219-
int result = defaultStype;
220-
if ( "bold".equalsIgnoreCase( style ) ) {
221-
result = STYLE_BOLD;
222-
} else if ( "underline".equalsIgnoreCase( style ) ) {
223-
result = STYLE_UNDERLINE;
224-
} else if ( "italic".equalsIgnoreCase( style ) ) {
225-
result = STYLE_ITALIC;
226-
} else if ( "bolditalic".equalsIgnoreCase( style ) ) {
227-
result = STYLE_BOLDITALIC;
228-
} else if ( "normal".equalsIgnoreCase( style ) ) {
229-
result = STYLE_NORMAL;
230-
}
231-
return result;
221+
return DocStyleAlignHelper.parseStyle(style, defaultStype);
232222
}
233223

234224
private int align;

fj-doc-base/src/main/java/org/fugerit/java/doc/base/xml/DocContentHandler.java

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -194,37 +194,10 @@ public void startDocument() throws SAXException {
194194
this.currentElement = null;
195195
}
196196

197-
private static int getAlign( String align ) {
198-
int result = DocPara.ALIGN_UNSET;
199-
if ( "center".equalsIgnoreCase( align ) ) {
200-
result = DocPara.ALIGN_CENTER;
201-
} else if ( "right".equalsIgnoreCase( align ) ) {
202-
result = DocPara.ALIGN_RIGHT;
203-
} else if ( "left".equalsIgnoreCase( align ) ) {
204-
result = DocPara.ALIGN_LEFT;
205-
} else if ( "justify".equalsIgnoreCase( align ) ) {
206-
result = DocPara.ALIGN_JUSTIFY;
207-
} else if ( "justifyall".equalsIgnoreCase( align ) ) {
208-
result = DocPara.ALIGN_JUSTIFY_ALL;
209-
}
210-
return result;
211-
}
212-
213-
private static int getValign( String align ) {
214-
int result = DocPara.ALIGN_UNSET;
215-
if ( "middle".equalsIgnoreCase( align ) ) {
216-
result = DocPara.ALIGN_MIDDLE;
217-
} else if ( "top".equalsIgnoreCase( align ) ) {
218-
result = DocPara.ALIGN_TOP;
219-
} else if ( "bottom".equalsIgnoreCase( align ) ) {
220-
result = DocPara.ALIGN_BOTTOM;
221-
}
222-
return result;
223-
}
224-
197+
225198
private static void handleHeaderFooter( DocHeaderFooter headerFooter, Properties atts ) {
226199
String align = atts.getProperty( "align" );
227-
headerFooter.setAlign( getAlign( align ) );
200+
headerFooter.setAlign( DocStyleAlignHelper.getAlign( align ) );
228201
String numbered = atts.getProperty( "numbered" );
229202
headerFooter.setNumbered( Boolean.valueOf( numbered ).booleanValue() );
230203
String borderWidth = atts.getProperty( "border-width", "0" );
@@ -293,7 +266,7 @@ private static void valuePara( DocPara docPara, Properties props, boolean headin
293266
docPara.setId( id );
294267
// setting paragraph align
295268
String align = props.getProperty( "align" );
296-
docPara.setAlign( getAlign( align ) );
269+
docPara.setAlign( DocStyleAlignHelper.getAlign( align ) );
297270
String fontName = props.getProperty( "font-name" );
298271
docPara.setFontName( fontName );
299272
String leading = props.getProperty( "leading" );
@@ -429,7 +402,7 @@ public void startElement(String uri, String localName, String qName, Attributes
429402
docImage.setAlt( alt );
430403
}
431404
String align = props.getProperty( "align" );
432-
docImage.setAlign( getAlign( align ) );
405+
docImage.setAlign( DocStyleAlignHelper.getAlign( align ) );
433406
this.currentElement = docImage;
434407
} else if ( "pl".equalsIgnoreCase( qName ) ) {
435408
DocContainer container = new DocContainer();
@@ -512,10 +485,10 @@ public void startElement(String uri, String localName, String qName, Attributes
512485
docCell.setHeader( "true".equalsIgnoreCase( props.getProperty( "header" ) ) );
513486
// h align
514487
String align = props.getProperty( "align" );
515-
docCell.setAlign( getAlign( align ) );
488+
docCell.setAlign( DocStyleAlignHelper.getAlign( align ) );
516489
// v align
517490
String valign = props.getProperty( "valign" );
518-
docCell.setValign( getValign( valign ) );
491+
docCell.setValign( DocStyleAlignHelper.getValign( valign ) );
519492
docCell.setDocBorders( this.createBorders( props ) );
520493
this.currentElement = docCell;
521494
} else if ( "page-break".equalsIgnoreCase( qName ) ) {
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package org.fugerit.java.doc.base.xml;
2+
3+
import org.fugerit.java.doc.base.config.DocConstants;
4+
import org.fugerit.java.doc.base.model.DocPara;
5+
6+
public class DocStyleAlignHelper {
7+
8+
public static int parseStyle( String style, int defaultStype ) {
9+
int result = defaultStype;
10+
if ( DocConstants.STYLE_BOLD.equalsIgnoreCase( style ) ) {
11+
result = DocPara.STYLE_BOLD;
12+
} else if ( DocConstants.STYLE_UNDERLINE.equalsIgnoreCase( style ) ) {
13+
result = DocPara.STYLE_UNDERLINE;
14+
} else if ( DocConstants.STYLE_ITALIC.equalsIgnoreCase( style ) ) {
15+
result = DocPara.STYLE_ITALIC;
16+
} else if ( DocConstants.STYLE_BOLDITALIC.equalsIgnoreCase( style ) ) {
17+
result = DocPara.STYLE_BOLDITALIC;
18+
} else if ( DocConstants.STYLE_NORMAL.equalsIgnoreCase( style ) ) {
19+
result = DocPara.STYLE_NORMAL;
20+
}
21+
return result;
22+
}
23+
24+
public static int getAlign( String align ) {
25+
int result = DocPara.ALIGN_UNSET;
26+
if ( DocConstants.ALIGN_CENTER.equalsIgnoreCase( align ) ) {
27+
result = DocPara.ALIGN_CENTER;
28+
} else if ( DocConstants.ALIGN_RIGHT.equalsIgnoreCase( align ) ) {
29+
result = DocPara.ALIGN_RIGHT;
30+
} else if ( DocConstants.ALIGN_LEFT.equalsIgnoreCase( align ) ) {
31+
result = DocPara.ALIGN_LEFT;
32+
} else if ( DocConstants.ALIGN_JUSTIFY.equalsIgnoreCase( align ) ) {
33+
result = DocPara.ALIGN_JUSTIFY;
34+
} else if ( DocConstants.ALIGN_JUSTIFYALL.equalsIgnoreCase( align ) ) {
35+
result = DocPara.ALIGN_JUSTIFY_ALL;
36+
}
37+
return result;
38+
}
39+
40+
public static int getValign( String align ) {
41+
int result = DocPara.ALIGN_UNSET;
42+
if ( DocConstants.VALIGN_MIDDLE.equalsIgnoreCase( align ) ) {
43+
result = DocPara.ALIGN_MIDDLE;
44+
} else if ( DocConstants.VALIGN_TOP.equalsIgnoreCase( align ) ) {
45+
result = DocPara.ALIGN_TOP;
46+
} else if ( DocConstants.VALIGN_BOTTOM.equalsIgnoreCase( align ) ) {
47+
result = DocPara.ALIGN_BOTTOM;
48+
}
49+
return result;
50+
}
51+
52+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Changelog for module fj-doc-lib-simpletable
2+
3+
## version 0.5.9 - 2022-12-11
4+
* Added support for cell style and align

fj-doc-lib-simpletable/src/main/java/org/fugerit/java/doc/lib/simpletable/model/SimpleCell.java

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package org.fugerit.java.doc.lib.simpletable.model;
22

3+
import org.fugerit.java.doc.base.config.DocConstants;
4+
35
public class SimpleCell {
46

57
public static final int BORDER_WIDTH_UNSET = -1;
68

79
private String content;
810

911
private int borderWidth;
12+
13+
private String style;
14+
15+
private String align;
1016

1117
public String getContent() {
1218
return content;
@@ -35,5 +41,63 @@ public SimpleCell(String content, int borderWidth) {
3541
this.content = content;
3642
this.borderWidth = borderWidth;
3743
}
44+
45+
public String getStyle() {
46+
return style;
47+
}
48+
49+
public void setStyle(String style) {
50+
this.style = style;
51+
}
52+
53+
public String getAlign() {
54+
return align;
55+
}
56+
57+
public void setAlign(String align) {
58+
this.align = align;
59+
}
60+
61+
private SimpleCell alignWorker( String align ) {
62+
this.setAlign( align );
63+
return this;
64+
}
65+
66+
private SimpleCell styleWorker( String style ) {
67+
this.setStyle( style );
68+
return this;
69+
}
70+
71+
public SimpleCell bold() {
72+
return this.styleWorker( DocConstants.STYLE_BOLD );
73+
}
74+
75+
public SimpleCell bolditalic() {
76+
return this.styleWorker( DocConstants.STYLE_BOLDITALIC );
77+
}
78+
79+
public SimpleCell italic() {
80+
return this.styleWorker( DocConstants.STYLE_ITALIC );
81+
}
82+
83+
public SimpleCell underline() {
84+
return this.styleWorker( DocConstants.STYLE_UNDERLINE );
85+
}
86+
87+
public SimpleCell center() {
88+
return this.alignWorker( DocConstants.ALIGN_CENTER );
89+
}
90+
91+
public SimpleCell rigt() {
92+
return this.alignWorker( DocConstants.ALIGN_RIGHT );
93+
}
94+
95+
public SimpleCell left() {
96+
return this.alignWorker( DocConstants.ALIGN_LEFT );
97+
}
98+
99+
public static SimpleCell newCell( String content ) {
100+
return new SimpleCell( content );
101+
}
38102

39103
}

fj-doc-lib-simpletable/src/main/java/org/fugerit/java/doc/lib/simpletable/model/SimpleRow.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ public List<SimpleCell> getCells() {
1616
return cells;
1717
}
1818

19+
public void addCell( SimpleCell cell ) {
20+
this.getCells().add( cell );
21+
}
22+
1923
public void addCell( String content ) {
20-
this.getCells().add( new SimpleCell(content) );
24+
this.addCell( new SimpleCell(content) );
2125
}
2226

2327
public SimpleRow() {

fj-doc-lib-simpletable/src/main/java/org/fugerit/java/doc/lib/simpletable/model/SimpleTable.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6+
import org.fugerit.java.core.lang.helpers.BooleanUtils;
67
import org.fugerit.java.doc.lib.simpletable.SimpleTableFacade;
78

89
public class SimpleTable {
@@ -48,6 +49,9 @@ public void addRow( SimpleRow row ) {
4849
if ( cell.getBorderWidth() == SimpleCell.BORDER_WIDTH_UNSET ) {
4950
cell.setBorderWidth( this.defaultBorderWidth );
5051
}
52+
if ( BooleanUtils.isTrue( row.getHead() ) ) {
53+
cell.bold().center();
54+
}
5155
}
5256
}
5357

0 commit comments

Comments
 (0)