Skip to content

Commit

Permalink
[mod-fop] supporto for table cell back-color attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
fugerit79 committed Nov 30, 2023
1 parent 25b57db commit 67305b2
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- [mod-fop] supporto for table cell back-color attribute
- [playground-quarkus] quarkus-version set to 3.6.0

## [3.2.1] - 2023-11-22
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<#list rowList as row>
<fo:table-row>
<#list row.elementList as cell>
<fo:table-cell<@addCssValue name='padding' value=docTable.padding def=0 unit='mm'/><@addCssValue name='margin' value=docTable.padding def=0 unit='mm'/><@handleAlign alignValue=cell.align/><@handleVerticalAlign valignValue=cell.valign/><@handleBorders docBorders=cell.docBorders/><@handleCellSpan cell=cell/>>
<fo:table-cell<#if (cell.backColor??)> background-color="${cell.backColor}" </#if><@addCssValue name='padding' value=docTable.padding def=0 unit='mm'/><@addCssValue name='margin' value=docTable.padding def=0 unit='mm'/><@handleAlign alignValue=cell.align/><@handleVerticalAlign valignValue=cell.valign/><@handleBorders docBorders=cell.docBorders/><@handleCellSpan cell=cell/>>
<#if (cell.elementList?size > 0)>
<#list cell.elementList as cellElement>
<@handleElement current=cellElement/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package test.org.fugerit.java.doc.mod.fop;

import java.io.FileOutputStream;
import java.io.InputStreamReader;

import org.fugerit.java.core.function.SafeFunction;
import org.fugerit.java.core.lang.helpers.ClassHelper;
import org.fugerit.java.doc.base.config.DocInput;
import org.fugerit.java.doc.base.config.DocOutput;
import org.fugerit.java.doc.base.config.DocTypeHandler;
import org.fugerit.java.doc.mod.fop.FreeMarkerFopTypeHandlerUTF8;
import org.fugerit.java.doc.mod.fop.InitFopHandler;
import org.fugerit.java.doc.mod.fop.PdfFopTypeHandler;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import lombok.extern.slf4j.Slf4j;
import test.org.fugerit.java.BasicTest;

@Slf4j
public class TestAlt extends BasicTest {

@BeforeClass
public static void init() {
SafeFunction.apply( () -> InitFopHandler.initDoc() );
}

private boolean testHelper( DocTypeHandler handler ) {
boolean ok = false;
try ( InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( "sample/doc_alt_01.xml" ) );
FileOutputStream fos = new FileOutputStream( "target/test_alt_01."+handler.getType() ) ) {
handler.handle( DocInput.newInput( handler.getType(), reader ) , DocOutput.newOutput( fos ) );
ok = true;
log.info( "result {}", ok );
} catch (Exception e) {
this.failEx( e );
}
return ok;
}

private static final DocTypeHandler[] HANDLERS = { PdfFopTypeHandler.HANDLER, new FreeMarkerFopTypeHandlerUTF8() };

@Test
public void testAlt001Ok() {
for ( int k=0; k<HANDLERS.length; k++ ) {
boolean ok = this.testHelper(HANDLERS[k]);
Assert.assertTrue(ok);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
import java.io.InputStreamReader;

import org.fugerit.java.core.cfg.ConfigRuntimeException;
import org.fugerit.java.core.function.SafeFunction;
import org.fugerit.java.core.lang.helpers.ClassHelper;
import org.fugerit.java.core.xml.dom.DOMIO;
import org.fugerit.java.doc.base.config.DocInput;
import org.fugerit.java.doc.base.config.DocOutput;
import org.fugerit.java.doc.base.config.DocTypeHandler;
import org.fugerit.java.doc.mod.fop.FopConfig;
import org.fugerit.java.doc.mod.fop.FopConfigDefault;
import org.fugerit.java.doc.mod.fop.InitFopHandler;
import org.fugerit.java.doc.mod.fop.PdfFopTypeHandler;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Document;

Expand All @@ -22,6 +25,11 @@
@Slf4j
public class TestPdfFopTypeHandler extends BasicTest {

@BeforeClass
public static void init() {
SafeFunction.apply( () -> InitFopHandler.initDocAsync() );
}

private boolean testHelper( DocTypeHandler handler ) {
boolean ok = false;
try ( InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader( "sample/doc_test_01.xml" ) );
Expand Down
49 changes: 49 additions & 0 deletions fj-doc-mod-fop/src/test/resources/sample/doc_alt_01.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<doc xmlns="http://javacoredoc.fugerit.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://javacoredoc.fugerit.org https://www.fugerit.org/data/java/doc/xsd/doc-1-10.xsd">
<metadata>
<info name="margins">10;10;10;30</info>
<info name="excel-table-id">excel-table=print</info>
<info name="excel-width-multiplier">450</info>
<footer-ext>
<para align="center">Page ${currentPage}</para>
</footer-ext>
</metadata>
<body>
<table columns="3" colwidths="30;30;40" id="excel-table" padding="2" width="100">
<row>
<cell align="center" back-color="#99aaee">
<para>Name</para>
</cell>
<cell align="center" back-color="#99aaee">
<para>Surname</para>
</cell>
<cell align="center" back-color="#99aaee">
<para>Title</para>
</cell>
</row>
<row>
<cell>
<para>Luthien</para>
</cell>
<cell>
<para>Tinuviel</para>
</cell>
<cell>
<para>Queen</para>
</cell>
</row>
<row>
<cell>
<para>Thorin</para>
</cell>
<cell>
<para>Oakshield</para>
</cell>
<cell>
<para>King</para>
</cell>
</row>
</table>
</body>
</doc>

0 comments on commit 67305b2

Please sign in to comment.