remove SVG parser, remove log4j remnants

This commit is contained in:
Jörg Prante 2021-12-12 22:35:35 +01:00
parent 159fee4967
commit 21030c24f0
17 changed files with 46 additions and 101 deletions

View file

@ -9,10 +9,8 @@ jna.version = 5.10.0
zxing.version = 3.4.1
reflections.version = 0.9.11
jfreechart.version = 1.5.2
echosvg.version = 0.1.2
junit.version = 5.8.1
junit4.version = 4.13.2
cglib.version = 3.3.0
objenesis.version = 2.6
log4j.version = 2.15.0
xbib-content.version = 4.0.0

View file

@ -1,7 +1,7 @@
apply plugin: 'groovy'
dependencies {
implementation "org.codehaus.groovy:groovy:${project.property('groovy.version')}:indy"
implementation "org.codehaus.groovy:groovy:${project.property('groovy.version')}"
}
compileGroovy {
@ -19,16 +19,9 @@ tasks.withType(GroovyCompile) {
if (!options.compilerArgs.contains("-processor")) {
options.compilerArgs << '-proc:none'
}
groovyOptions.optimizationOptions.indy = true
}
task groovydocJar(type: Jar, dependsOn: 'groovydoc') {
from groovydoc.destinationDir
archiveClassifier.set('javadoc')
}
configurations.all {
resolutionStrategy {
force "org.codehaus.groovy:groovy:${project.property('groovy.version')}:indy"
}
}

View file

@ -1,52 +1,20 @@
apply from: rootProject.file('gradle/compile/groovy.gradle')
dependencies {
api project(':graphics-pdfbox')
api project(':graphics-barcode')
api("org.codehaus.groovy:groovy-xml:${project.property('groovy.version')}:indy") {
exclude group: 'org.codehaus.groovy', module: 'groovy'
}
// in groovyland, we need log4j-core for @Log4j2 annotations
implementation "org.apache.logging.log4j:log4j-core:${project.property('log4j.version')}"
api("org.codehaus.groovy:groovy-xml:${project.property('groovy.version')}")
// spock need junit vintage
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${project.property('junit.version')}"
testImplementation("org.codehaus.groovy:groovy:${project.property('groovy.version')}:indy") {
exclude group: 'org.codehaus.groovy', module: 'groovy'
}
testImplementation("org.codehaus.groovy:groovy-json:${project.property('groovy.version')}:indy") {
exclude group: 'org.codehaus.groovy', module: 'groovy'
}
testImplementation("org.codehaus.groovy:groovy-nio:${project.property('groovy.version')}:indy"){
exclude group: 'org.codehaus.groovy', module: 'groovy'
}
testImplementation("org.codehaus.groovy:groovy-sql:${project.property('groovy.version')}:indy") {
exclude group: 'org.codehaus.groovy', module: 'groovy'
}
testImplementation("org.codehaus.groovy:groovy-xml:${project.property('groovy.version')}:indy") {
exclude group: 'org.codehaus.groovy', module: 'groovy'
}
testImplementation("org.codehaus.groovy:groovy-macro:${project.property('groovy.version')}:indy") {
exclude group: 'org.codehaus.groovy', module: 'groovy'
}
testImplementation("org.codehaus.groovy:groovy-templates:${project.property('groovy.version')}:indy") {
exclude group: 'org.codehaus.groovy', module: 'groovy'
}
testImplementation("org.codehaus.groovy:groovy-test:${project.property('groovy.version')}:indy") {
exclude group: 'org.codehaus.groovy', module: 'groovy'
}
testImplementation("org.spockframework:spock-core:${project.property('spock.version')}") {
exclude group: 'org.codehaus.groovy', module: 'groovy'
exclude group: 'org.codehaus.groovy', module: 'groovy-json'
exclude group: 'org.codehaus.groovy', module: 'groovy-macro'
exclude group: 'org.codehaus.groovy', module: 'groovy-nio'
exclude group: 'org.codehaus.groovy', module: 'groovy-sql'
exclude group: 'org.codehaus.groovy', module: 'groovy-templates'
exclude group: 'org.codehaus.groovy', module: 'groovy-test'
exclude group: 'org.codehaus.groovy', module: 'groovy-xml'
}
testImplementation("org.codehaus.groovy:groovy:${project.property('groovy.version')}")
testImplementation("org.codehaus.groovy:groovy-json:${project.property('groovy.version')}")
testImplementation("org.codehaus.groovy:groovy-nio:${project.property('groovy.version')}")
testImplementation("org.codehaus.groovy:groovy-sql:${project.property('groovy.version')}")
testImplementation("org.codehaus.groovy:groovy-xml:${project.property('groovy.version')}")
testImplementation("org.codehaus.groovy:groovy-macro:${project.property('groovy.version')}")
testImplementation("org.codehaus.groovy:groovy-templates:${project.property('groovy.version')}")
testImplementation("org.codehaus.groovy:groovy-test:${project.property('groovy.version')}")
testImplementation("org.spockframework:spock-core:${project.property('spock.version')}")
testImplementation "cglib:cglib-nodep:${project.property('cglib.version')}" // for spock mock
testImplementation "org.objenesis:objenesis:${project.property('objenesis.version')}" // for spock mock
}

View file

@ -1,7 +1,6 @@
package org.xbib.graphics.pdfbox.groovy.analyze
import groovy.util.logging.Log4j2
import org.apache.logging.log4j.Level
import groovy.util.logging.Log
import org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
import org.apache.pdfbox.cos.COSName
import org.apache.pdfbox.cos.COSStream
@ -13,8 +12,9 @@ import org.apache.pdfbox.pdmodel.graphics.image.PDImage
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject
import java.awt.geom.Point2D
import java.util.logging.Level
@Log4j2
@Log
class DocumentAnalyzer {
private final Map result = [:]
@ -47,7 +47,7 @@ class DocumentAnalyzer {
* at org.apache.pdfbox.cos.COSDictionary.getDate(COSDictionary.java:790) ~[pdfbox-2.0.12.jar:2.0.12]
* at org.apache.pdfbox.pdmodel.PDDocumentInformation.getCreationDate(PDDocumentInformation.java:212) ~[pdfbox-2.0.12.jar:2.0.12]
*/
log.log(Level.WARN, e.getMessage() as String, e)
log.log(Level.SEVERE, e.getMessage() as String, e)
}
result."pages" = []
document.withCloseable {

View file

@ -1,7 +1,7 @@
package org.xbib.graphics.pdfbox.groovy.builder
import groovy.transform.InheritConstructors
import groovy.util.logging.Log4j2
import groovy.util.logging.Log
import groovy.xml.MarkupBuilder
import org.apache.pdfbox.pdmodel.common.PDMetadata
import org.xbib.graphics.pdfbox.groovy.Barcode
@ -17,7 +17,7 @@ import org.xbib.graphics.pdfbox.groovy.TextBlock
import org.xbib.graphics.pdfbox.groovy.render.ParagraphRenderer
import org.xbib.graphics.pdfbox.groovy.render.TableRenderer
@Log4j2
@Log
@InheritConstructors
class PdfDocumentBuilder extends DocumentBuilder {
@ -38,13 +38,13 @@ class PdfDocumentBuilder extends DocumentBuilder {
inputStream.withCloseable {
boolean loaded = PdfFont.addFont(pdfDocument.pdDocument, fd.name, inputStream, fd.bold, fd.italic)
if (!loaded) {
log.warn("font ${fd.name} not loaded")
log.warning("font ${fd.name} not loaded")
} else {
log.info("font ${fd.name} added")
}
}
} else {
log.warn("font ${fd.name} not found in class path")
log.warning("font ${fd.name} not found in class path")
}
}
}

View file

@ -1,11 +1,9 @@
package org.xbib.graphics.pdfbox.groovy.render
import groovy.util.logging.Log4j2
import org.xbib.graphics.pdfbox.groovy.TextBlock
import org.xbib.graphics.pdfbox.groovy.render.element.ImageElement
import org.xbib.graphics.pdfbox.groovy.render.element.TextElement
@Log4j2
class ParagraphLine {
final BigDecimal maxWidth

View file

@ -1,6 +1,5 @@
package org.xbib.graphics.pdfbox.groovy.render
import groovy.util.logging.Log4j2
import org.apache.pdfbox.pdmodel.font.PDFont
import org.xbib.graphics.pdfbox.groovy.Barcode
import org.xbib.graphics.pdfbox.groovy.Font
@ -15,7 +14,6 @@ import org.xbib.graphics.pdfbox.groovy.render.element.ImageElement
import org.xbib.graphics.pdfbox.groovy.render.element.LineElement
import org.xbib.graphics.pdfbox.groovy.render.element.TextElement
@Log4j2
class ParagraphParser {
static List<ParagraphLine> getLines(TextBlock paragraph, BigDecimal maxLineWidth) {

View file

@ -1,6 +1,5 @@
package org.xbib.graphics.pdfbox.groovy.render
import groovy.util.logging.Log4j2
import org.apache.pdfbox.pdmodel.PDPageContentStream
import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject
import org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory
@ -23,7 +22,6 @@ import org.xbib.graphics.pdfbox.groovy.render.element.TextElement
import javax.imageio.ImageIO
import java.awt.image.BufferedImage
@Log4j2
class ParagraphRenderer implements Renderable {
TextBlock node

View file

@ -1,10 +1,10 @@
package org.xbib.graphics.pdfbox.groovy.test
import groovy.util.logging.Log4j2
import groovy.util.logging.Log
import org.junit.Test
import org.xbib.graphics.pdfbox.groovy.analyze.DocumentAnalyzer
@Log4j2
@Log
class DocumentAnalyzerTest {
@Test
@ -12,17 +12,16 @@ class DocumentAnalyzerTest {
InputStream inputStream = getClass().getResourceAsStream("/ghost.pdf")
if (inputStream) {
DocumentAnalyzer documentAnalyzer = new DocumentAnalyzer(inputStream)
log.info(documentAnalyzer.result)
log.info(documentAnalyzer.result as String)
}
}
@Test(expected = IOException.class)
void analyzeNonPDF() {
InputStream inputStream = getClass().getResourceAsStream("/log4j2-test.xml")
InputStream inputStream = getClass().getResourceAsStream("/logging.properties")
if (inputStream) {
DocumentAnalyzer documentAnalyzer = new DocumentAnalyzer(inputStream)
log.info(documentAnalyzer.result)
log.info(documentAnalyzer.result as String)
}
}
}

View file

@ -1,11 +1,11 @@
package org.xbib.graphics.pdfbox.groovy.test
import groovy.util.logging.Log4j2
import groovy.util.logging.Log
import org.xbib.graphics.pdfbox.groovy.Font
import org.xbib.graphics.pdfbox.groovy.builder.PdfFont
import spock.lang.Specification
@Log4j2
@Log
class FontSpec extends Specification {
def "override properties with left shift"() {

View file

@ -1,6 +1,6 @@
package org.xbib.graphics.pdfbox.groovy.test
import groovy.util.logging.Log4j2
import groovy.util.logging.Log
import org.apache.fontbox.ttf.CmapSubtable
import org.apache.fontbox.ttf.NamingTable
import org.apache.fontbox.ttf.TTFParser
@ -10,7 +10,7 @@ import org.junit.Test
import java.nio.file.Files
import java.nio.file.Paths
@Log4j2
@Log
class LoadFontTest {
@Test
@ -33,7 +33,7 @@ class LoadFontTest {
try {
NamingTable nameTable = trueTypeFont.getNaming()
if (!nameTable) {
log.warn("Missing 'name' table in font " + name)
log.warning("Missing 'name' table in font " + name)
} else {
if (nameTable.getPostScriptName()) {
String psName = nameTable.getPostScriptName()
@ -48,12 +48,12 @@ class LoadFontTest {
log.info(format + ": '" + psName + "' / '" + nameTable.getFontFamily() +
"' / '" + nameTable.getFontSubFamily() + "'")
} else {
log.warn("Missing 'name' entry for PostScript name in font " + inputStream)
log.warning("Missing 'name' entry for PostScript name in font " + inputStream)
}
}
CmapSubtable cmapSubtable = trueTypeFont.getUnicodeCmap(true)
if (!cmapSubtable) {
log.warn('missing cmap table in ' + name)
log.warning('missing cmap table in ' + name)
} else {
log.info("cmap table present: " + name)
}

View file

@ -1,6 +1,6 @@
package org.xbib.graphics.pdfbox.groovy.test
import groovy.util.logging.Log4j2
import groovy.util.logging.Log
import org.junit.Test
import org.xbib.graphics.barcode.SymbolType
import org.xbib.graphics.pdfbox.groovy.builder.PdfDocumentBuilder
@ -11,7 +11,7 @@ import java.util.regex.Pattern
import static org.junit.Assert.assertTrue
@Log4j2
@Log
class PdfDocumentBuilderTest {
@Test

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="OFF">
<appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="[%d{ISO8601}][%-5p][%-25c][%t] %m%n"/>
</Console>
</appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console" />
</Root>
</Loggers>
</configuration>

View file

@ -0,0 +1,5 @@
handlers = java.util.logging.ConsoleHandler
.level = ALL
java.util.logging.SimpleFormatter.format = %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$-7s [%3$s] %5$s %6$s%n
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

View file

@ -18,6 +18,4 @@ module org.xbib.graphics.layout.pdfbox {
requires org.xbib.settings.datastructures;
requires transitive java.desktop;
requires java.logging;
requires io.sf.carte.echosvg.anim;
requires io.sf.carte.echosvg.bridge;
}

View file

@ -1,5 +1,5 @@
dependencies {
api "org.apache.pdfbox:pdfbox:${project.property('pdfbox.version')}"
testImplementation "org.jfree:jfreechart:${project.property('jfreechart.version')}"
testImplementation "io.sf.carte:echosvg-bridge:${project.property('echosvg.version')}"
//testImplementation "io.sf.carte:echosvg-bridge:${project.property('echosvg.version')}"
}

View file

@ -1,5 +1,6 @@
package org.xbib.graphics.pdfbox.test;
/*
import io.sf.carte.echosvg.anim.dom.SAXSVGDocumentFactory;
import io.sf.carte.echosvg.bridge.BridgeContext;
import io.sf.carte.echosvg.bridge.DocumentLoader;
@ -7,6 +8,8 @@ import io.sf.carte.echosvg.bridge.GVTBuilder;
import io.sf.carte.echosvg.bridge.UserAgent;
import io.sf.carte.echosvg.bridge.UserAgentAdapter;
import io.sf.carte.echosvg.gvt.GraphicsNode;
*/
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
@ -61,7 +64,7 @@ public class RenderSVGsTest extends PdfBoxGraphics2DTestBase {
}
private void renderSVG(String name, final double scale) throws IOException {
String uri = RenderSVGsTest.class.getResource(name).toString();
/*String uri = RenderSVGsTest.class.getResource(name).toString();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory();
Document document = f.createDocument(uri, RenderSVGsTest.class.getResourceAsStream(name));
UserAgent userAgent = new UserAgentAdapter();
@ -73,11 +76,11 @@ public class RenderSVGsTest extends PdfBoxGraphics2DTestBase {
this.exportGraphic("svg", name.replace(".svg", ""), gfx -> {
gfx.scale(scale, scale);
gvtRoot.paint(gfx);
});
});*/
}
private void renderSVGCMYK(String name, double scale) throws IOException {
String uri = RenderSVGsTest.class.getResource(name).toString();
/*String uri = RenderSVGsTest.class.getResource(name).toString();
SAXSVGDocumentFactory documentFactory = new SAXSVGDocumentFactory();
Document document = documentFactory.createDocument(uri, RenderSVGsTest.class.getResourceAsStream(name));
UserAgent userAgent = new UserAgentAdapter();
@ -117,6 +120,6 @@ public class RenderSVGsTest extends PdfBoxGraphics2DTestBase {
contentStream.close();
String baseName = name.substring(0, name.lastIndexOf('.'));
pdfDocument.save(new File(parentDir, baseName + ".pdf"));
pdfDocument.close();
pdfDocument.close();*/
}
}