From 4706cf48ec07c75a2fd6c71cd0cc4d5ffd20fcd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20R=C3=B8sdal?= Date: Thu, 19 Jun 2025 08:28:09 +0200 Subject: [PATCH] Remove commented out code and some system.out.println --- .../org/openpdf/css/parser/CSSParser.java | 41 --------- .../java/org/openpdf/swing/BasicPanel.java | 10 --- .../java/org/openpdf/util/Configuration.java | 1 - .../openpdf/{ => util}/DefaultCSSMarker.java | 2 +- .../org/openpdf/css/parser/ParserTest.java | 5 +- .../org/openpdf/renderer/BaseWatchable.java | 2 - .../java/org/openpdf/renderer/HexDump.java | 84 ------------------- .../com/lowagie/text/pdf/BarcodePDF417.java | 21 ----- 8 files changed, 2 insertions(+), 164 deletions(-) rename openpdf-html/src/main/java/org/openpdf/{ => util}/DefaultCSSMarker.java (97%) delete mode 100644 openpdf-renderer/src/main/java/org/openpdf/renderer/HexDump.java diff --git a/openpdf-html/src/main/java/org/openpdf/css/parser/CSSParser.java b/openpdf-html/src/main/java/org/openpdf/css/parser/CSSParser.java index 22b4ab249..739bc7e7a 100644 --- a/openpdf-html/src/main/java/org/openpdf/css/parser/CSSParser.java +++ b/openpdf-html/src/main/java/org/openpdf/css/parser/CSSParser.java @@ -155,7 +155,6 @@ public PropertyValue parsePropertyValue(CSSName cssName, Origin origin, String e // [ namespace [S|CDO|CDC]* ]* // [ [ ruleset | media | page | font_face ] [S|CDO|CDC]* ]* private void stylesheet(Stylesheet stylesheet) throws IOException { - //System.out.println("stylesheet()"); Token t = la(); try { if (t == Token.TK_CHARSET_SYM) { @@ -248,7 +247,6 @@ private void stylesheet(Stylesheet stylesheet) throws IOException { // [STRING|URI] S* [ medium [ COMMA S* medium]* ]? ';' S* // ; private void import_rule(Stylesheet stylesheet) throws IOException { - //System.out.println("import()"); try { Token t = next(); if (t == Token.TK_IMPORT_SYM) { @@ -276,7 +274,6 @@ private void import_rule(Stylesheet stylesheet) throws IOException { URI parent = new URI(stylesheet.getURI()); String tokenValue = getTokenValue(t); String resolvedUri = parent.resolve(tokenValue).toString(); - System.out.println("Token: " + tokenValue + " resolved " + resolvedUri); uri = resolvedUri; } catch (URISyntaxException use) { throw new CSSParseException("Invalid URL, " + use.getMessage(), getCurrentLine(), use); @@ -386,7 +383,6 @@ private void namespace() throws IOException { // : MEDIA_SYM S* medium [ COMMA S* medium ]* LBRACE S* ruleset* '}' S* // ; private void media(Stylesheet stylesheet) throws IOException { - //System.out.println("media()"); Token t = next(); try { if (t == Token.TK_MEDIA_SYM) { @@ -448,7 +444,6 @@ private void media(Stylesheet stylesheet) throws IOException { // : IDENT S* // ; private String medium() throws IOException { - //System.out.println("medium()"); Token t = next(); if (t == Token.TK_IDENT) { String result = getTokenValue(t); @@ -465,7 +460,6 @@ private String medium() throws IOException { // '{' S* declaration [ ';' S* declaration ]* '}' S* // ; private void font_face(Stylesheet stylesheet) throws IOException { -// System.out.println(font_face()"); Token t = next(); try { FontFaceRule fontFaceRule = new FontFaceRule(stylesheet.getOrigin()); @@ -515,7 +509,6 @@ private void font_face(Stylesheet stylesheet) throws IOException { // '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S* // private void page(Stylesheet stylesheet) throws IOException { - //System.out.println("page()"); Token t = next(); try { if (t == Token.TK_PAGE_SYM) { @@ -619,7 +612,6 @@ private Map> margin(Stylesheet styleshe // : ':' IDENT // ; private String pseudo_page() throws IOException { - //System.out.println("pseudo_page()"); Token t = next(); if (t == Token.TK_COLON) { t = next(); @@ -642,7 +634,6 @@ private String pseudo_page() throws IOException { // : '/' S* | COMMA S* | /* empty */ // ; private void operator() throws IOException { - //System.out.println("operator()"); Token t = la(); switch (t.getType()) { case VIRGULE: @@ -659,7 +650,6 @@ private void operator() throws IOException { // | S // ; private Token combinator() throws IOException { - //System.out.println("combinator()"); Token t = next(); if (t == Token.TK_PLUS || t == Token.TK_GREATER) { skip_whitespace(); @@ -677,7 +667,6 @@ private Token combinator() throws IOException { // : '-' | PLUS // ; private int unary_operator() throws IOException { - //System.out.println("unary_operator()"); Token t = next(); if (! (t == Token.TK_MINUS || t == Token.TK_PLUS)) { push(t); @@ -695,7 +684,6 @@ private int unary_operator() throws IOException { // : IDENT S* // ; private String property() throws IOException { - //System.out.println("property()"); Token t = next(); String result; if (t == Token.TK_IDENT) { @@ -714,7 +702,6 @@ private String property() throws IOException { // : [ declaration ';' S* ]* private void declaration_list( Ruleset ruleset, boolean expectEOF, boolean expectAtRule, boolean inFontFace) throws IOException { - //System.out.println("declaration_list()"); Token t; LOOP: while (true) { @@ -751,7 +738,6 @@ private void declaration_list( // LBRACE S* [ declaration ';' S* ]* '}' S* // ; private void ruleset(RulesetContainer container) throws IOException { - //System.out.println("ruleset()"); try { Ruleset ruleset = new Ruleset(container.getOrigin()); @@ -797,7 +783,6 @@ private void ruleset(RulesetContainer container) throws IOException { // : simple_selector [ combinator simple_selector ]* // ; private void selector(Ruleset ruleset) throws IOException { - //System.out.println("selector()"); List selectors = new ArrayList<>(); List combinators = new ArrayList<>(); selectors.add(simple_selector(ruleset)); @@ -891,7 +876,6 @@ private Selector mergeSimpleSelectors(List selectors, List comb // | [ HASH | class | attrib | pseudo ]+ // ; private Selector simple_selector(Ruleset ruleset) throws IOException { - //System.out.println("simple_selector()"); Selector selector = new Selector(); selector.setParent(ruleset); Token t = la(); @@ -1020,7 +1004,6 @@ private NamespacePair typed_value(boolean matchAttribute) throws IOException { // : '.' IDENT // ; private void class_selector(Selector selector) throws IOException { - //System.out.println("class_selector()"); Token t = next(); if (t == Token.TK_PERIOD) { t = next(); @@ -1036,23 +1019,6 @@ private void class_selector(Selector selector) throws IOException { } } -// element_name -// : IDENT | '*' -// ; - /* - private String element_name() throws IOException { - //System.out.println("element_name()"); - Token t = next(); - if (t == Token.TK_IDENT || t == Token.TK_ASTERISK) { - return getTokenValue(t, true); - } else { - push(t); - throw new CSSParseException( - t, new Token[] { Token.TK_IDENT, Token.TK_ASTERISK }, getCurrentLine()); - } - } - */ - // attrib // : '[' S* [ namespace_prefix ]? IDENT S* // [ [ PREFIXMATCH | @@ -1064,7 +1030,6 @@ private String element_name() throws IOException { // ]? ']' // ; private void attrib(Selector selector) throws IOException { - //System.out.println("attrib()"); Token t = next(); if (t == Token.TK_LBRACKET) { skip_whitespace(); @@ -1216,7 +1181,6 @@ private void addPseudoElement(Token t, Selector selector) { // : ':' ':'? [ IDENT | FUNCTION S* IDENT? S* ')' ] // ; private void pseudo(Selector selector) throws IOException { - //System.out.println("pseudo()"); Token t = next(); if (t == Token.TK_COLON) { t = next(); @@ -1272,7 +1236,6 @@ private boolean checkCSSName(@Nullable CSSName cssName, String propertyName) { // : property ':' S* expr prio? // ; private void declaration(Ruleset ruleset, boolean inFontFace) throws IOException { - //System.out.println("declaration()"); try { Token t = la(); if (t == Token.TK_IDENT) { @@ -1346,7 +1309,6 @@ private void prio() throws IOException { // : term [ operator term ]* // ; private List expr(boolean literal) throws IOException { - //System.out.println("expr()"); List result = new ArrayList<>(10); result.add(term(literal, null)); LOOP: while (true) { @@ -1444,7 +1406,6 @@ private String sign(float sign) { // | STRING S* | IDENT S* | URI S* | hexcolor | function // ; private PropertyValue term(boolean literal, @Nullable Token operatorToken) throws IOException { - //System.out.println("term()"); float sign = 1; Token t = la(); if (t == Token.TK_PLUS || t == Token.TK_MINUS) { @@ -1606,7 +1567,6 @@ private PropertyValue term(boolean literal, @Nullable Token operatorToken) throw // : FUNCTION S* expr ')' S* // ; private PropertyValue function(Token operatorToken) throws IOException { - //System.out.println("function()"); final PropertyValue result; Token t = next(); if (t == Token.TK_FUNCTION) { @@ -1737,7 +1697,6 @@ private short validateType(int index, PropertyValue value) { // : HASH S* // ; private PropertyValue hexcolor(Token operatorToken) throws IOException { - //System.out.println("hexcolor()"); final PropertyValue result; Token t = next(); if (t == Token.TK_HASH) { diff --git a/openpdf-html/src/main/java/org/openpdf/swing/BasicPanel.java b/openpdf-html/src/main/java/org/openpdf/swing/BasicPanel.java index c85fd09f1..caf1da029 100644 --- a/openpdf-html/src/main/java/org/openpdf/swing/BasicPanel.java +++ b/openpdf-html/src/main/java/org/openpdf/swing/BasicPanel.java @@ -77,8 +77,6 @@ protected BasicPanel(UserAgentCallback uac) { super(new SharedContext(uac)); mouseTracker = new MouseTracker(this); formSubmissionListener = query -> { - System.out.println("Form Submitted!"); - System.out.println("Data: " + query); JOptionPane.showMessageDialog( null, @@ -304,14 +302,6 @@ public void setLayout(LayoutManager l) { public void setSize(Dimension d) { XRLog.layout(Level.FINEST, "set size called"); super.setSize(d); - /* CLEAN: do we need this? - if (doc != null && body_box != null) { - if(body_box.width != d.width) - RenderQueue.getInstance().dispatchLayoutEvent(new ReflowEvent(ReflowEvent.CANVAS_RESIZED, d)); - //don't need the below, surely - //else if(body_box.height != d.height) - // RenderQueue.getInstance().dispatchRepaintEvent(new ReflowEvent(ReflowEvent.CANVAS_RESIZED, d)); - } */ } /* diff --git a/openpdf-html/src/main/java/org/openpdf/util/Configuration.java b/openpdf-html/src/main/java/org/openpdf/util/Configuration.java index 1c0c94c3a..bab01088d 100644 --- a/openpdf-html/src/main/java/org/openpdf/util/Configuration.java +++ b/openpdf-html/src/main/java/org/openpdf/util/Configuration.java @@ -23,7 +23,6 @@ import com.google.errorprone.annotations.CheckReturnValue; import org.jspecify.annotations.Nullable; import org.slf4j.LoggerFactory; -import org.openpdf.DefaultCSSMarker; import java.io.BufferedInputStream; import java.io.File; diff --git a/openpdf-html/src/main/java/org/openpdf/DefaultCSSMarker.java b/openpdf-html/src/main/java/org/openpdf/util/DefaultCSSMarker.java similarity index 97% rename from openpdf-html/src/main/java/org/openpdf/DefaultCSSMarker.java rename to openpdf-html/src/main/java/org/openpdf/util/DefaultCSSMarker.java index c9d359194..e00601ac8 100644 --- a/openpdf-html/src/main/java/org/openpdf/DefaultCSSMarker.java +++ b/openpdf-html/src/main/java/org/openpdf/util/DefaultCSSMarker.java @@ -40,7 +40,7 @@ -package org.openpdf; +package org.openpdf.util; diff --git a/openpdf-html/src/test/java/org/openpdf/css/parser/ParserTest.java b/openpdf-html/src/test/java/org/openpdf/css/parser/ParserTest.java index 9a8e2190f..4c702c3f5 100644 --- a/openpdf-html/src/test/java/org/openpdf/css/parser/ParserTest.java +++ b/openpdf-html/src/test/java/org/openpdf/css/parser/ParserTest.java @@ -47,12 +47,10 @@ public void cssParsingPerformance() throws IOException { CSSParser p = new CSSParser(errorHandler); Stylesheet stylesheet = p.parseStylesheet(null, USER_AGENT, new StringReader(longTest)); long end = System.currentTimeMillis(); - // System.out.println("Took " + (end-start) + " ms"); total += (end-start); assertThat(stylesheet.getContents()).hasSize(count); } - System.out.println("Average " + (total/10) + " ms"); total = 0; for (int i = 0; i < 10; i++) { @@ -64,7 +62,7 @@ public void cssParsingPerformance() throws IOException { total += (end-start); assertThat(stylesheet.getContents()).hasSize(count); } - System.out.println("Average " + (total/10) + " ms"); + CSSParser p = new CSSParser(errorHandler); @@ -81,7 +79,6 @@ public void cssParsingPerformance() throws IOException { // System.out.println("Took " + (end-start) + " ms"); total += (end-start); } - System.out.println("Average " + (total/10) + " ms"); } @Test diff --git a/openpdf-renderer/src/main/java/org/openpdf/renderer/BaseWatchable.java b/openpdf-renderer/src/main/java/org/openpdf/renderer/BaseWatchable.java index dbefa9083..c2f3cf7b2 100644 --- a/openpdf-renderer/src/main/java/org/openpdf/renderer/BaseWatchable.java +++ b/openpdf-renderer/src/main/java/org/openpdf/renderer/BaseWatchable.java @@ -125,7 +125,6 @@ public void run() { this.statusLock.wait(5000); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); // ← Preserve the interrupt status - PDFDebugger.debug("Thread interrupted while waiting for status change."); } } @@ -248,7 +247,6 @@ public void waitForFinish() { this.statusLock.wait(5000); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); // ← Preserve the interrupt status - PDFDebugger.debug("Thread interrupted while waiting for status change."); } } diff --git a/openpdf-renderer/src/main/java/org/openpdf/renderer/HexDump.java b/openpdf-renderer/src/main/java/org/openpdf/renderer/HexDump.java deleted file mode 100644 index 0deab9245..000000000 --- a/openpdf-renderer/src/main/java/org/openpdf/renderer/HexDump.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle, - * Santa Clara, California 95054, U.S.A. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -package org.openpdf.renderer; - -import java.io.IOException; -import java.io.RandomAccessFile; - -public class HexDump { - - public static void printData(byte[] data) { - char[] parts = new char[17]; - int partsloc = 0; - for (int i = 0; i < data.length; i++) { - int d = (data[i]) & 0xff; - if (d == 0) { - parts[partsloc++] = '.'; - } else if (d < 32 || d >= 127) { - parts[partsloc++] = '?'; - } else { - parts[partsloc++] = (char) d; - } - if (i % 16 == 0) { - int start = Integer.toHexString(data.length).length(); - int end = Integer.toHexString(i).length(); - - for (int j = start; j > end; j--) { - System.out.print("0"); - } - System.out.print(Integer.toHexString(i) + ": "); - } - if (d < 16) { - System.out.print("0" + Integer.toHexString(d)); - } else { - System.out.print(Integer.toHexString(d)); - } - if ((i & 15) == 15 || i == data.length - 1) { - System.out.println(" " + new String(parts)); - partsloc = 0; - } else if ((i & 7) == 7) { - System.out.print(" "); - parts[partsloc++] = ' '; - } else if ((i & 1) == 1) { - System.out.print(" "); - } - } - System.out.println(); - } - - public static void main(String args[]) { - if (args.length != 1) { - System.out.println("Usage: "); - System.out.println(" HexDump "); - System.exit(-1); - } - - try { - RandomAccessFile raf = new RandomAccessFile(args[0], "r"); - - int size = (int) raf.length(); - byte[] data = new byte[size]; - - raf.readFully(data); - printData(data); - } catch (IOException ioe) { - BaseWatchable.getErrorHandler().publishException(ioe); - } - } -} \ No newline at end of file diff --git a/openpdf/src/main/java/com/lowagie/text/pdf/BarcodePDF417.java b/openpdf/src/main/java/com/lowagie/text/pdf/BarcodePDF417.java index 09bb2f9e2..e4d6c41f6 100644 --- a/openpdf/src/main/java/com/lowagie/text/pdf/BarcodePDF417.java +++ b/openpdf/src/main/java/com/lowagie/text/pdf/BarcodePDF417.java @@ -1271,27 +1271,6 @@ private void append(String s) { textCompaction(bytes, 0, bytes.length); } - protected void dumpList() { - if (segmentList.size() == 0) { - return; - } - for (int k = 0; k < segmentList.size(); ++k) { - Segment v = segmentList.get(k); - int len = getSegmentLength(v); - char[] c = new char[len]; - for (int j = 0; j < len; ++j) { - c[j] = (char) (text[v.start + j] & 0xff); - if (c[j] == '\r') { - c[j] = '\n'; - } - } - StringBuilder sb = new StringBuilder(); - sb.append(v.type); - sb.append(c); - System.out.println(sb.toString()); - } - } - protected int getMaxSquare() { if (codeColumns > 21) { codeColumns = 29;