From 0361b2ee82c2db90e5f79252b009d6108329fb23 Mon Sep 17 00:00:00 2001 From: Matteo Franci Date: Wed, 22 Dec 2021 12:05:00 +0100 Subject: [PATCH] 0.3.7.1 (2021-12-22) + Added bookmark tree support (currently only work with fop renderer) --- docgen/parameters.json | 4 +- docgen/release-notes.txt | 6 +- fj-doc-base/pom.xml | 2 +- .../fugerit/java/doc/base/model/DocBase.java | 10 + .../java/doc/base/model/DocBookmark.java | 69 +++ .../java/doc/base/model/DocBookmarkTree.java | 43 ++ .../java/doc/base/xml/DocContentHandler.java | 19 +- .../src/main/resources/config/doc-1-8.xsd | 453 ++++++++++++++++++ .../config/schema-validator-config.xml | 6 +- fj-doc-ent/pom.xml | 2 +- fj-doc-freemarker/pom.xml | 2 +- fj-doc-mod-fop/pom.xml | 2 +- .../resources/fm_fop/template/fop_doc.ftl | 11 + .../fm_fop/template/macro/doc_element.ftl | 2 +- fj-doc-mod-itext/pom.xml | 2 +- fj-doc-mod-jxl/pom.xml | 2 +- fj-doc-mod-pdfbox/pom.xml | 2 +- fj-doc-mod-poi/pom.xml | 2 +- fj-doc-sample/pom.xml | 2 +- .../java/doc/sample/dev/TestXml01.java | 2 + .../src/test/resources/dev/test-fo-01.fo | 14 +- .../src/test/resources/dev/test-xml-01.xml | 28 +- pom.xml | 2 +- 23 files changed, 666 insertions(+), 21 deletions(-) create mode 100644 fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBookmark.java create mode 100644 fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBookmarkTree.java create mode 100644 fj-doc-base/src/main/resources/config/doc-1-8.xsd diff --git a/docgen/parameters.json b/docgen/parameters.json index 646a8462f..f4d672ee2 100644 --- a/docgen/parameters.json +++ b/docgen/parameters.json @@ -1,8 +1,8 @@ { "title" : "Venus (Fugerit Document Generation Framework)", "name": "Venus", - "version" : "0.3.7.0", - "date" : "21/11/2021", + "version" : "0.3.7.1", + "date" : "22/12/2021", "organization" : { "name" : "Fugerit Org", "url" : "https://www.fugerit.org" diff --git a/docgen/release-notes.txt b/docgen/release-notes.txt index 1d5f1b94d..b7630b916 100644 --- a/docgen/release-notes.txt +++ b/docgen/release-notes.txt @@ -1,4 +1,8 @@ -0.3.7.0 (2021-11-21) +0.3.7.1 (2021-12-22) +-------------------- ++ Added bookmark tree support (currently only work with fop renderer) + +0.3.7.0 (2021-11-21) -------------------- + Better header handling for fop diff --git a/fj-doc-base/pom.xml b/fj-doc-base/pom.xml index 1fea8676d..324690227 100644 --- a/fj-doc-base/pom.xml +++ b/fj-doc-base/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 0.3.7.0 + 0.3.7.1 fj-doc-base diff --git a/fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBase.java b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBase.java index 6b1cd6db9..c61ea5e20 100644 --- a/fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBase.java +++ b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBase.java @@ -90,6 +90,8 @@ public DocBase() { private DocBackground docBackground; + private DocBookmarkTree docBookmarkTree; + private HashMap idMap; private String xsdVersion; @@ -215,5 +217,13 @@ public DocBackground getDocBackground() { public void setDocBackground(DocBackground docBackground) { this.docBackground = docBackground; } + + public DocBookmarkTree getDocBookmarkTree() { + return docBookmarkTree; + } + + public void setDocBookmarkTree(DocBookmarkTree docBookmarkTree) { + this.docBookmarkTree = docBookmarkTree; + } } diff --git a/fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBookmark.java b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBookmark.java new file mode 100644 index 000000000..97275419d --- /dev/null +++ b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBookmark.java @@ -0,0 +1,69 @@ +/***************************************************************** + + Fugerit Java Library org.fugerit.java.doc.base + + Copyright (c) 2019 Fugerit + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Apache License v2.0 + which accompanies this distribution, and is available at + http://www.apache.org/licenses/ + (txt version : http://www.apache.org/licenses/LICENSE-2.0.txt + html version : http://www.apache.org/licenses/LICENSE-2.0.html) + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + +*****************************************************************/ +package org.fugerit.java.doc.base.model; +/* + * @(#)DocTable.java + * + * @project : org.fugerit.java.doc.base + * @package : org.fugerit.java.doc.base + * @creation : 06/set/06 + * @license : META-INF/LICENSE.TXT + */ + +/** + * + * + * @author fugerit + * + */ +public class DocBookmark extends DocElement { + + public DocBookmark() { + this.title = ""; + } + + /** + * + */ + private static final long serialVersionUID = 470846678198846L; + + public static final String TAG_NAME = "bookmark"; + + public static final String ATT_REF = "ref"; + + private String ref; + + private String title; + + public String getRef() { + return ref; + } + + public void setRef(String ref) { + this.ref = ref; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + +} diff --git a/fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBookmarkTree.java b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBookmarkTree.java new file mode 100644 index 000000000..1342225ee --- /dev/null +++ b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/model/DocBookmarkTree.java @@ -0,0 +1,43 @@ +/***************************************************************** + + Fugerit Java Library org.fugerit.java.doc.base + + Copyright (c) 2019 Fugerit + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Apache License v2.0 + which accompanies this distribution, and is available at + http://www.apache.org/licenses/ + (txt version : http://www.apache.org/licenses/LICENSE-2.0.txt + html version : http://www.apache.org/licenses/LICENSE-2.0.html) + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + +*****************************************************************/ +package org.fugerit.java.doc.base.model; +/* + * @(#)DocTable.java + * + * @project : org.fugerit.java.doc.base + * @package : org.fugerit.java.doc.base + * @creation : 06/set/06 + * @license : META-INF/LICENSE.TXT + */ + +/** + * + * + * @author fugerit + * + */ +public class DocBookmarkTree extends DocContainer { + + /** + * + */ + private static final long serialVersionUID = 47084667819886346L; + + public static final String TAG_NAME = "bookmark-tree"; + +} diff --git a/fj-doc-base/src/main/java/org/fugerit/java/doc/base/xml/DocContentHandler.java b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/xml/DocContentHandler.java index 2a9140cad..d09601f5e 100644 --- a/fj-doc-base/src/main/java/org/fugerit/java/doc/base/xml/DocContentHandler.java +++ b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/xml/DocContentHandler.java @@ -36,6 +36,8 @@ The Apache Software Foundation (http://www.apache.org/). import org.fugerit.java.doc.base.model.DocBackground; import org.fugerit.java.doc.base.model.DocBarcode; import org.fugerit.java.doc.base.model.DocBase; +import org.fugerit.java.doc.base.model.DocBookmark; +import org.fugerit.java.doc.base.model.DocBookmarkTree; import org.fugerit.java.doc.base.model.DocBorders; import org.fugerit.java.doc.base.model.DocBr; import org.fugerit.java.doc.base.model.DocCell; @@ -83,7 +85,8 @@ public class DocContentHandler implements ContentHandler { "footer", "header-ext", "footer-ext", - DocBackground.TAG_NAME}; + DocBackground.TAG_NAME, + DocBookmarkTree.TAG_NAME}; private static final Collection CONTAINER_LIST = new HashSet<>( Arrays.asList( ELEMENT_CONTAINER ) ); @@ -120,6 +123,9 @@ public void characters(char[] ch, int start, int length) throws SAXException { } else if ( text.trim().length() > 0 && this.currentElement instanceof DocPara ) { DocPara docPara = (DocPara)this.currentElement; docPara.setText( docPara.getText()+text ); + } else if ( text.trim().length() > 0 && this.currentElement instanceof DocBookmark ) { + DocBookmark docBookmarkTitle = (DocBookmark)this.currentElement; + docBookmarkTitle.setTitle( docBookmarkTitle.getTitle()+text ); } else if ( text.trim().length() > 0 && this.currentElement instanceof DocInfo ) { DocInfo docInfo = (DocInfo)this.currentElement; docInfo.getContent().append( text ); @@ -280,6 +286,8 @@ private static void valuePara( DocPara docPara, Properties props, boolean headin } docPara.setStyle( DocPara.parseStyle( style, defaultStyle ) ); docPara.setOriginalStyle( DocPara.parseStyle( style, DocPara.STYLE_UNSET ) ); + String id = props.getProperty( "id" ); + docPara.setId( id ); // setting paragraph align String align = props.getProperty( "align" ); docPara.setAlign( getAlign( align ) ); @@ -506,6 +514,15 @@ public void startElement(String uri, String localName, String qName, Attributes this.currentElement = docCell; } else if ( "page-break".equalsIgnoreCase( qName ) ) { this.currentElement = new DocPageBreak(); + } else if ( DocBookmarkTree.TAG_NAME.equalsIgnoreCase( qName ) ) { + DocBookmarkTree docBookmarkTree = new DocBookmarkTree(); + this.docBase.setDocBookmarkTree(docBookmarkTree); + this.currentElement = docBookmarkTree; + } else if ( DocBookmark.TAG_NAME.equalsIgnoreCase( qName ) ) { + DocBookmark docBookmark = new DocBookmark(); + String ref = props.getProperty( DocBookmark.ATT_REF ); + docBookmark.setRef( ref ); + this.currentElement = docBookmark; } // processamenti finali if ( this.currentContainer != null && this.currentContainer != this.currentElement ) { diff --git a/fj-doc-base/src/main/resources/config/doc-1-8.xsd b/fj-doc-base/src/main/resources/config/doc-1-8.xsd new file mode 100644 index 000000000..5c7f206fe --- /dev/null +++ b/fj-doc-base/src/main/resources/config/doc-1-8.xsd @@ -0,0 +1,453 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Valid values are : + cl://pathinjar (Path inside the class loader, safest way to load the image) + http://imageurl (but generating machine should be able to access the url) + file://imagepath (Path should be absolute, but you can use, for instance, free marker templating to make it more generic.) + In case of base64 just provide the tyoe (png,jpg etc.) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fj-doc-base/src/main/resources/config/schema-validator-config.xml b/fj-doc-base/src/main/resources/config/schema-validator-config.xml index 79e7607e4..0a6e948a0 100644 --- a/fj-doc-base/src/main/resources/config/schema-validator-config.xml +++ b/fj-doc-base/src/main/resources/config/schema-validator-config.xml @@ -30,7 +30,11 @@ - + + + + + \ No newline at end of file diff --git a/fj-doc-ent/pom.xml b/fj-doc-ent/pom.xml index f1aa2801c..26088de05 100644 --- a/fj-doc-ent/pom.xml +++ b/fj-doc-ent/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 0.3.7.0 + 0.3.7.1 fj-doc-ent diff --git a/fj-doc-freemarker/pom.xml b/fj-doc-freemarker/pom.xml index 1a5ba0fce..e2488055c 100644 --- a/fj-doc-freemarker/pom.xml +++ b/fj-doc-freemarker/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 0.3.7.0 + 0.3.7.1 fj-doc-freemarker diff --git a/fj-doc-mod-fop/pom.xml b/fj-doc-mod-fop/pom.xml index 73bf04091..b031079db 100644 --- a/fj-doc-mod-fop/pom.xml +++ b/fj-doc-mod-fop/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 0.3.7.0 + 0.3.7.1 fj-doc-mod-fop diff --git a/fj-doc-mod-fop/src/main/resources/fm_fop/template/fop_doc.ftl b/fj-doc-mod-fop/src/main/resources/fm_fop/template/fop_doc.ftl index 61aa82fa8..174563653 100644 --- a/fj-doc-mod-fop/src/main/resources/fm_fop/template/fop_doc.ftl +++ b/fj-doc-mod-fop/src/main/resources/fm_fop/template/fop_doc.ftl @@ -34,6 +34,17 @@ + + <#if (docBase.docBookmarkTree)??> + + <#list docBase.docBookmarkTree.elementList as docBookmark> + + ${docBookmark.title} + + + + + <#if (docBase.useHeader)> diff --git a/fj-doc-mod-fop/src/main/resources/fm_fop/template/macro/doc_element.ftl b/fj-doc-mod-fop/src/main/resources/fm_fop/template/macro/doc_element.ftl index c8633e220..b4ab5d4cb 100644 --- a/fj-doc-mod-fop/src/main/resources/fm_fop/template/macro/doc_element.ftl +++ b/fj-doc-mod-fop/src/main/resources/fm_fop/template/macro/doc_element.ftl @@ -38,7 +38,7 @@ <#macro handleParaRole current role> - <@handleWhiteSpace element=current/><@handleRole role=role element=current/><@handleStyle styleValue=current.originalStyle/><@handleParaSpacing textIndent=current.textIndent!0 spaceBefore=current.spaceBefore!0 spaceAfter=current.spaceAfter!0 spaceLeft=current.spaceLeft!0 spaceRight=current.spaceRight!0/><@handleAlign alignValue=current.align/><@handleFont element=current/>>${current.text?replace(r"${currentPage}","")} + id="${current.id}" <@handleFormat formatValue=current.format!''/><@handleWhiteSpace element=current/><@handleRole role=role element=current/><@handleStyle styleValue=current.originalStyle/><@handleParaSpacing textIndent=current.textIndent!0 spaceBefore=current.spaceBefore!0 spaceAfter=current.spaceAfter!0 spaceLeft=current.spaceLeft!0 spaceRight=current.spaceRight!0/><@handleAlign alignValue=current.align/><@handleFont element=current/>>${current.text?replace(r"${currentPage}","")} <#macro handlePara current> diff --git a/fj-doc-mod-itext/pom.xml b/fj-doc-mod-itext/pom.xml index ba26f1223..84f5527f3 100644 --- a/fj-doc-mod-itext/pom.xml +++ b/fj-doc-mod-itext/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 0.3.7.0 + 0.3.7.1 fj-doc-mod-itext diff --git a/fj-doc-mod-jxl/pom.xml b/fj-doc-mod-jxl/pom.xml index 26a5903d5..ccd31fb58 100644 --- a/fj-doc-mod-jxl/pom.xml +++ b/fj-doc-mod-jxl/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 0.3.7.0 + 0.3.7.1 fj-doc-mod-jxl diff --git a/fj-doc-mod-pdfbox/pom.xml b/fj-doc-mod-pdfbox/pom.xml index 509dcd238..cf667f675 100644 --- a/fj-doc-mod-pdfbox/pom.xml +++ b/fj-doc-mod-pdfbox/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 0.3.7.0 + 0.3.7.1 fj-doc-mod-pdfbox diff --git a/fj-doc-mod-poi/pom.xml b/fj-doc-mod-poi/pom.xml index b5e8bc21c..34b051ec4 100644 --- a/fj-doc-mod-poi/pom.xml +++ b/fj-doc-mod-poi/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 0.3.7.0 + 0.3.7.1 fj-doc-mod-poi diff --git a/fj-doc-sample/pom.xml b/fj-doc-sample/pom.xml index 1f8b8c72c..116dc1069 100644 --- a/fj-doc-sample/pom.xml +++ b/fj-doc-sample/pom.xml @@ -7,7 +7,7 @@ org.fugerit.java fj-doc - 0.3.7.0 + 0.3.7.1 fj-doc-sample diff --git a/fj-doc-sample/src/test/java/test/org/fugerit/java/doc/sample/dev/TestXml01.java b/fj-doc-sample/src/test/java/test/org/fugerit/java/doc/sample/dev/TestXml01.java index 5975eab71..fed974b7b 100644 --- a/fj-doc-sample/src/test/java/test/org/fugerit/java/doc/sample/dev/TestXml01.java +++ b/fj-doc-sample/src/test/java/test/org/fugerit/java/doc/sample/dev/TestXml01.java @@ -1,6 +1,7 @@ package test.org.fugerit.java.doc.sample.dev; import java.io.File; +import java.util.Locale; import org.junit.Assert; import org.junit.Test; @@ -11,6 +12,7 @@ public class TestXml01 extends DevHelper { @Test public void test01() throws Exception { + Locale.setDefault( Locale.UK ); String testCase = "test-xml-01"; boolean res = this.workerXmlToFoToPdf( new File( "src/test/resources/dev/"+testCase+".xml" ), new File( BasicFacadeTest.BASIC_OUTPUT_PATH, testCase+".fo" ), diff --git a/fj-doc-sample/src/test/resources/dev/test-fo-01.fo b/fj-doc-sample/src/test/resources/dev/test-fo-01.fo index 6842cb036..c5c30c357 100644 --- a/fj-doc-sample/src/test/resources/dev/test-fo-01.fo +++ b/fj-doc-sample/src/test/resources/dev/test-fo-01.fo @@ -2,6 +2,7 @@ + + + + + + Bookmark 1 + + + - + + - Header 1 + Header 1 diff --git a/fj-doc-sample/src/test/resources/dev/test-xml-01.xml b/fj-doc-sample/src/test/resources/dev/test-xml-01.xml index a7e7f7237..e48065ea0 100644 --- a/fj-doc-sample/src/test/resources/dev/test-xml-01.xml +++ b/fj-doc-sample/src/test/resources/dev/test-xml-01.xml @@ -2,12 +2,34 @@ + xsi:schemaLocation="http://javacoredoc.fugerit.org http://www.fugerit.org/data/java/doc/xsd/doc-1-8.xsd" > - 10;10;10;10 + 10;10;10;10 + + Bookmark 1 + Bookmark 2 + - Header 1 + Header 1 + + + Name + Surname + Title + + + Luthien + Tinuviel + Queen + + + Thorin + Oakshield + King + +
+ Header 2
\ No newline at end of file diff --git a/pom.xml b/pom.xml index 5c31acd9c..c84054183 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.fugerit.java fj-doc - 0.3.7.0 + 0.3.7.1 pom fj-doc