Skip to content

Commit 4893822

Browse files
authored
Merge pull request #105 from fugerit-org/104-mod-fop-fix-cell-vertifcal-align
104 mod fop fix cell vertifcal align
2 parents a44bbc6 + 3b83319 commit 4893822

File tree

7 files changed

+35
-4
lines changed

7 files changed

+35
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- [playground-quarkus] xsl-fo output (as of mod-fop format)
13+
1014
### Changed
1115

1216
- [playground-quarkus] quarkus-version set to 3.6.1
1317

18+
### Fixed
19+
20+
- [mod-fop] fix cell vertifcal align #104
21+
1422
## [3.2.3] - 2023-12-05
1523

1624
- [val-p7m] P7MContentValidator (validate p7m and possibly its content with a facade)

fj-doc-mod-fop/src/main/resources/fj_doc_mod_fop_config/template/macro/doc_element.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ text-indent : text-indent
172172

173173
<#macro handleCellSpan cell><#if cell.columnSpan != 1> number-columns-spanned="${cell.columnSpan}"</#if><#if cell.rowSpan != 1> number-rows-spanned="${cell.rowSpan}"</#if></#macro>
174174

175-
<#macro handleVerticalAlign valignValue><#if valignValue = 5> vertical-align="middle"<#elseif valignValue = 4> vertical-align="top"<#elseif valignValue = 6> vertical-align="bottom"</#if></#macro>
175+
<#macro handleVerticalAlign valignValue><#if valignValue = 5> vertical-align="middle" display-align="center"<#elseif valignValue = 4> vertical-align="top"<#elseif valignValue = 6> vertical-align="bottom" display-align="after"</#if></#macro>
176176

177177
<#macro handleStyle styleValue><#if styleValue = 2> font-weight="bold"<#elseif styleValue = 3> text-decoration="underline"<#elseif styleValue = 4> font-style="italic"<#elseif styleValue = 5> font-style="italic" font-weight="bold"<#elseif styleValue = 1> font-style="normal" font-weight="normal"</#if></#macro>
178178

fj-doc-mod-fop/src/test/resources/sample/doc_alt_01.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@
4343
<para>King</para>
4444
</cell>
4545
</row>
46+
<row>
47+
<cell valign="middle">
48+
<para>Multi row text content to test vertical allign of other cells in the row</para>
49+
</cell>
50+
<cell valign="middle">
51+
<para>Elrond</para>
52+
</cell>
53+
<cell valign="bottom">
54+
<para>Gil-Galad</para>
55+
</cell>
56+
</row>
4657
</table>
4758
</body>
4859
</doc>

fj-doc-playground-quarkus/src/main/java/org/fugerit/java/doc/playground/doc/GenerateFacade.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.fugerit.java.doc.freemarker.config.FreeMarkerConfigStep;
2323
import org.fugerit.java.doc.freemarker.fun.SimpleMessageFun;
2424
import org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlFragmentTypeHandlerEscapeUTF8;
25+
import org.fugerit.java.doc.mod.fop.FreeMarkerFopTypeHandler;
2526
import org.fugerit.java.doc.mod.opencsv.OpenCSVTypeHandler;
2627
import org.fugerit.java.doc.mod.poi.XlsxPoiTypeHandler;
2728
import org.fugerit.java.doc.playground.config.InitPlayground;
@@ -151,6 +152,9 @@ public DocTypeHandler findHandler( BasicInput input ) {
151152
case DocConfig.TYPE_MD:
152153
handler = SimpleMarkdownExtTypeHandler.HANDLER_NOCOMMENTS_UTF8;
153154
break;
155+
case DocConfig.TYPE_FO:
156+
handler = FreeMarkerFopTypeHandler.HANDLER_UTF8;
157+
break;
154158
case InitPlayground.OUTPUT_FORMAT_PDF_A:
155159
handler = InitPlayground.PDFA_FOP_TYPE_HANDLER;
156160
break;

fj-doc-playground-quarkus/src/main/react/src/playground/DocXmlEditor.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class DocXmlEditor extends Component {
190190
} else if ( this.state.docFormat === 'MD' ) {
191191
let decodedStringAtoB = this.myAtob(this.state.docOutput);
192192
outputData = <MarkdownEditor key={new Date().getTime()} value={decodedStringAtoB} />
193-
} else if ( this.state.docFormat === 'XML' ) {
193+
} else if ( this.state.docFormat === 'XML' || this.state.docFormat === 'FO' ) {
194194
let decodedStringAtoB = this.myAtob(this.state.docOutput);
195195
outputData = <AceEditor
196196
mode='xml'
@@ -274,6 +274,7 @@ class DocXmlEditor extends Component {
274274
<MenuItem value='XLSX'>XLSX</MenuItem>
275275
<MenuItem value='MD'>Markdown (MD)</MenuItem>
276276
<MenuItem value='XML'>Venus XML Doc</MenuItem>
277+
<MenuItem value='FO'>XSL-FO</MenuItem>
277278
<MenuItem value='CSV'>CSV</MenuItem>
278279
</Select>
279280
</FormControl>

fj-doc-playground-quarkus/src/test/java/org/fugerit/java/doc/playground/GenerateRestTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ private void testWorker( String apiPath, String jsonPayloadPath ) {
3737

3838
@Test
3939
void testGenerateDocument() {
40-
int[] testId = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
40+
int[] testId = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
4141
for ( int k=0; k<testId.length; k++ ) {
42-
this.testWorker( "/generate/document", "generate/test_generate_input_0"+testId[k]+".json" );
42+
String current = String.valueOf( testId[k]<10 ? "0"+testId[k] : testId[k] );
43+
this.testWorker( "/generate/document", "generate/test_generate_input_"+current+".json" );
4344
}
4445
}
4546

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"inputFormat": "FTLX",
3+
"outputFormat":"FO",
4+
"freemarkerJsonData":"{\"docTitle\":\"My FreeMarker Template Sample Doc Title\"}",
5+
"docContent":"<#outputformat \"XML\"><#-- automatically escape variables as XML : https://freemarker.apache.org/docs/dgui_misc_autoescaping.html -->\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<doc\n\txmlns=\"http://javacoredoc.fugerit.org\"\n\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://javacoredoc.fugerit.org https://www.fugerit.org/data/java/doc/xsd/doc-2-1.xsd\" > \n\n <#--\n \tThis is a Venus Fugerit Doc (https://github.com/fugerit-org/fj-doc) FreeMarker Template XML (ftlx).\n \t\n \tFor consideration of Venus Fugerit Doc and Apache FreeMarker integration see :\n \thttps://venusguides.fugerit.org/src/docs/common/doc_format_freemarker.html\n \t\n \tFor documentation on how to write a valid Venus Doc XML Meta Model refer to : \n \thttps://venusguides.fugerit.org/src/docs/common/doc_format_summary.html\n -->\n\n <metadata>\n \t<!-- Margin for document : left;right;top;bottom -->\n \t<info name=\"margins\">10;10;10;30</info> \n \t<info name=\"excel-table-id\">excel-table=print</info>\n \t<!-- documenta meta information -->\n\t<info name=\"doc-title\">Basic example</info>\n\t<info name=\"doc-subject\">fj doc venus sample source FreeMarker Template XML - ftlx</info>\n\t<info name=\"doc-author\">fugerit79</info>\n\t<info name=\"doc-language\">en</info>\n\t<!-- font must be loaded -->\n\t<info name=\"default-font-name\">TitilliumWeb</info>\n\t<footer-ext>\n\t\t<para align=\"right\">${r\"${currentPage}\"} / ${r\"${pageCount}\"}</para>\n\t</footer-ext>\n </metadata>\n <body>\n \t\t<para>${docTitleNotPresent}</para>\n \t<table columns=\"3\" colwidths=\"30;30;40\" width=\"100\" id=\"excel-table\" padding=\"2\">\n \t\t<row>\n \t\t\t<cell align=\"center\" border-color=\"#000000\" border-width=\"1\"><para style=\"bold\">Name</para></cell>\n \t\t\t<cell align=\"center\"><para style=\"bold\">Surname</para></cell>\n \t\t\t<cell align=\"center\"><para style=\"bold\">Title</para></cell>\n \t\t</row>\n \t\t<row>\n \t\t\t<cell><para><![CDATA[Luthien]]></para></cell>\n \t\t\t<cell><para><![CDATA[Tinuviel]]></para></cell>\n \t\t\t<cell><para><![CDATA[Queen]]></para></cell>\n \t\t</row>\n \t\t<row>\n \t\t\t<cell><para><![CDATA[Thorin]]></para></cell>\n \t\t\t<cell><para><![CDATA[Oakshield]]></para></cell>\n \t\t\t<cell><para><![CDATA[King]]></para></cell>\n \t\t</row> \t\n \t</table>\n </body>\n \n</doc>\n</#outputformat>"
6+
}

0 commit comments

Comments
 (0)