Skip to content

Commit 7fe8ce0

Browse files
authored
Merge pull request #338 from fugerit-org/337-enhancement-fj-doc-mod-fop-add-svg-support
337 enhancement fj doc mod fop add svg support
2 parents 5d5db1e + e4d438e commit 7fe8ce0

File tree

16 files changed

+116
-13
lines changed

16 files changed

+116
-13
lines changed

CHANGELOG.md

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

88
## [Unreleased]
99

10+
### Added
11+
12+
- [fj-doc-mod-fop] Support for SVG rendering <https://github.com/fugerit-org/fj-doc/issues/337>
13+
- [fj-doc-freemarker] FreeMarker function 'base64ToString' <https://github.com/fugerit-org/fj-doc/issues/337>
14+
- [fj-doc-base] 'svg' to accepted image types <https://github.com/fugerit-org/fj-doc/issues/337>
15+
1016
### Changed
1117

1218
- [fj-doc-maven-plugin] spring-boot flavour version set to 3.4.4 <https://github.com/fugerit-org/fj-doc/issues/335>

fj-doc-base-kotlin/src/main/java/org/fugerit/java/doc/base/kotlin/dsl/HelperDSL.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class HelperDSL {
132132
private var checkFun12 : (v: String) -> Boolean = { v -> setOf( "middle", "top", "bottom" ).contains( v ) }
133133
private var checkFun13 : (v: String) -> Boolean = { v -> setOf( "ul", "uld", "ulm", "ol", "oln", "oll" ).contains( v ) }
134134
private var checkFun14 : (v: String) -> Boolean = { v -> v.length in 0..2048 }
135-
private var checkFun15 : (v: String) -> Boolean = { v -> setOf( "png", "jpg", "gif" ).contains( v ) }
135+
private var checkFun15 : (v: String) -> Boolean = { v -> setOf( "png", "jpg", "gif", "svg" ).contains( v ) }
136136
private var checkFun16 : (v: Int) -> Boolean = { v -> v in 1..7 }
137137
protected fun <T : Element> alignType( tag : T, name : String, v: String) : T = setAtt( tag, name, v, checkFun0 )
138138
protected fun <T : Element> borderWidthType( tag : T, name : String, v: Int) : T = setAtt( tag, name, v, checkFun1 )

fj-doc-base/DocXsdChangelog.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1+
2+
2.1.0.rc.3 (2025-03-22)
3+
------------------
4+
5+
* Added 'svg' among accepted image types.
6+
7+
2.1.0.rc.2 (2024-10-14)
8+
------------------
9+
10+
* 'h' elemented accepted as child of 'para'.
11+
112
2.1.0.rc.1 (2023-08-18)
213
------------------
14+
315
* Added 'caption' attribute for 'table' element.
416

517
2.0.0.rc.3 (2023-08-17)
618
------------------
19+
720
* Added documentation for table 'padding', 'spacing' attributes and info element values
821

922
2.0.0.rc.002 (2023-07-29)

fj-doc-base/src/main/docs/doc_xsd_config_ref.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1888,7 +1888,7 @@ <h1 style="font-weight: bold;">Reference xsd documentation for Venus - Fugerit
18881888
<span >The type of the image</span>
18891889
</td>
18901890
<td id="cell_1_2" style=" width: 40%; border-top: 1px solid black; border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; padding: 2px;">
1891-
<span >imageType , base : string , enumeration : [ png , jpg , gif ]</span>
1891+
<span >imageType , base : string , enumeration : [ png , jpg , gif , svg ]</span>
18921892
</td>
18931893
</tr>
18941894
<tr>

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ public class DocImage extends DocElement {
4848
public static final String TYPE_JPG = "jpg";
4949

5050
public static final String TYPE_GIF = "gif";
51-
51+
52+
public static final String TYPE_SVG = "svg";
53+
5254
public static Collection<String> getAcceptedImageTypes() {
53-
return Arrays.asList( TYPE_PNG, TYPE_JPG, TYPE_GIF );
55+
return Arrays.asList( TYPE_PNG, TYPE_JPG, TYPE_GIF, TYPE_SVG );
5456
}
5557

5658
public static final String TAG_NAME = "image";
@@ -85,5 +87,9 @@ public String getResolvedBase64() {
8587
public String getResolvedType() {
8688
return StringUtils.valueWithDefault( this.getType() , this.getUrl() );
8789
}
88-
90+
91+
public boolean isSvg() {
92+
return TYPE_SVG.equals( this.getResolvedType() );
93+
}
94+
8995
}

fj-doc-base/src/main/resources/META-INF/native-image/org.fugerit.java/fj-doc-base/reflect-config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,9 @@
11551155
}, {
11561156
"name" : "hashCode",
11571157
"parameterTypes" : [ ]
1158+
}, {
1159+
"name" : "isSvg",
1160+
"parameterTypes" : [ ]
11581161
}, {
11591162
"name" : "notify",
11601163
"parameterTypes" : [ ]

fj-doc-base/src/main/resources/config/doc-2-1.xsd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @project : fj-doc-base
88
* @creation : 2023-08-18
9-
* @version : 2.1.0-rc.2 (2024-10-14)
9+
* @version : 2.1.0-rc.3 (2025-03-22)
1010
*
1111
* XSD for fugerit doc configuration
1212
*/
@@ -543,6 +543,7 @@
543543
<xsd:enumeration value="png"></xsd:enumeration>
544544
<xsd:enumeration value="jpg"></xsd:enumeration>
545545
<xsd:enumeration value="gif"></xsd:enumeration>
546+
<xsd:enumeration value="svg"></xsd:enumeration>
546547
</xsd:restriction>
547548
</xsd:simpleType>
548549

fj-doc-base/src/test/java/test/org/fugerit/java/doc/base/model/TestDocImage.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ void testElement1() {
1616
Assertions.assertEquals( DocImage.TYPE_JPG, image.getResolvedType() );
1717
image.setType( DocImage.TYPE_PNG );
1818
Assertions.assertEquals( DocImage.TYPE_PNG, image.getResolvedType() );
19+
Assertions.assertFalse( image.isSvg() );
20+
image.setType( DocImage.TYPE_SVG );
21+
Assertions.assertTrue( image.isSvg() );
1922
log.info( "accepted types : {}", DocImage.getAcceptedImageTypes() );
2023
}
2124

fj-doc-freemarker/src/main/java/org/fugerit/java/doc/freemarker/config/FreeMarkerConfigStep.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public int process(DocProcessContext context, DocProcessData data) throws Except
152152
map.put(CleanXmlFun.DEFAULT_NAME, new CleanXmlFun());
153153
map.put(CleanTextFun.DEFAULT_NAME, new CleanTextFun());
154154
map.put(FormatLocalDateTimeFun.DEFAULT_NAME, new FormatLocalDateTimeFun());
155+
map.put(Base64ToStringFun.DEFAULT_NAME, new Base64ToStringFun());
155156
}
156157
return res;
157158
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.fugerit.java.doc.freemarker.fun;
2+
3+
import freemarker.template.SimpleScalar;
4+
import freemarker.template.TemplateMethodModelEx;
5+
import freemarker.template.TemplateModelException;
6+
import freemarker.template.TemplateScalarModel;
7+
8+
import java.util.Base64;
9+
import java.util.List;
10+
11+
public class Base64ToStringFun implements TemplateMethodModelEx {
12+
13+
public static final String DEFAULT_NAME = "base64ToString";
14+
15+
@Override
16+
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException {
17+
FMFunHelper.checkParameterNumber( arguments, 1 );
18+
String base64 = ((TemplateScalarModel)arguments.get( 0 )).getAsString();
19+
return new SimpleScalar( new String( Base64.getDecoder().decode( base64 ) ) );
20+
}
21+
22+
}

0 commit comments

Comments
 (0)