Skip to content

Commits on Source 3

Release Notes -- Apache PDFBox -- Version 2.0.16
Release Notes -- Apache PDFBox -- Version 2.0.17
Introduction
------------
The Apache PDFBox library is an open source Java tool for working with PDF documents.
This is an incremental bugfix release based on the earlier 2.0.15 release. It contains
This is an incremental bugfix release based on the earlier 2.0.16 release. It contains
a couple of fixes and small improvements.
For more details on these changes and all the other fixes and improvements
......@@ -14,55 +14,47 @@ PDFBox issue tracker at https://issues.apache.org/jira/browse/PDFBOX.
Bug
[PDFBOX-3819] - TrueType glyphs not displayed in rendering on Windows 10
[PDFBOX-4017] - Symbol font glyphs not found on Windows 10 fall creators update
[PDFBOX-4155] - Password Security with Unicode needs SASLprep
[PDFBOX-4489] - Memory issue on org.apache.fontbox.ttf.GlyphSubstitutionTable.readLangSysTable(GlyphSubstitutionTable.java:147)
[PDFBOX-4513] - FDFAnnotationStamp fails to parse some appearance streams
[PDFBOX-4517] - Unable to decrypt PDF with String and Stream filter to identity
[PDFBOX-4518] - NegativeArraySizeException thrown when converting PDF to Image
[PDFBOX-4520] - PDFBox PDFToImage shows black bars on scanned text
[PDFBOX-4521] - Missing Info value from file trailer: org.apache.pdfbox.cos.COSName cannot be cast to org.apache.pdfbox.cos.COSDictionary
[PDFBOX-4525] - PDF completely blow up the RAM on RedHat
[PDFBOX-4526] - Optional Content Membership Dictionaries (OCMD) not supported
[PDFBOX-4535] - java.lang.ClassCastException in PDImageXObject.getMask()
[PDFBOX-4540] - COSWriter sometimes retrieves wrong ObjectKey
[PDFBOX-4543] - PDLineDashPattern fails as float[] is converted to List<float[]> instead of List<Float>
[PDFBOX-4549] - No Unicode mapping
[PDFBOX-4550] - Poor performance with corrupt ToUnicode stream
[PDFBOX-4551] - Prevent printing from CL applications when not authorized
[PDFBOX-4553] - Break of backward compatibility from 2.0.14 to 2.0.15
[PDFBOX-4571] - IllegalArgumentException: illegal line join value
[PDFBOX-4579] - IndexOutOfBoundsException when setting DefaultFontProvider in FontMapper
[PDFBOX-4580] - PDFTextStripper::getText() lead to OutOfMemoryError: Java heap space
[PDFBOX-4581] - Exception XRSurfaceData.getRaster not implemented yet on Swing, Linux
[PDFBOX-4584] - Java 7 compile error
[PDFBOX-4585] - remove message "OpenType Layout tables used in font ... are not implemented"
[PDFBOX-4586] - Annotation widgets without AP not detected by preflight
[PDFBOX-4587] - SASLPrep declares that u2070E is private use
[PDFBOX-4589] - PDPageContent stream warns about overwriting in overwrite mode
[PDFBOX-4592] - Preflight does not check process colorspace in DeviceN
[PDFBOX-4595] - PDCIDFontType0 getHeight return 0
[PDFBOX-4596] - Overlays with /Rotate value appear rotated in result file
[PDFBOX-4604] - Used type0 for cyrillic, losting font on android
[PDFBOX-4607] - Transparent 16 bit image doesn't display in Adobe Reader
[PDFBOX-4608] - ImageToPDF fails with single image
[PDFBOX-4610] - Copy&Paste in IOUtils.closeAndLogException()'s Javadoc
[PDFBOX-4611] - PDF validates despite wrong /Alternate in ICC colorspace
[PDFBOX-4615] - AppearanceGeneratorHelper.setAppearanceValue doesn't set the bounding box on the appearance stream correctly
[PDFBOX-4622] - Various exceptions in TTFParser.parse
[PDFBOX-4624] - COSParser: NullPointerException
[PDFBOX-4626] - ArrayIndexOutOfBounds exceptions in CmapSubtable parsing
[PDFBOX-4631] - NPE due to bounding box not being set on PDAppearanceStream
[PDFBOX-4636] - "There has been a widget with a missing page reference" and non widget annotation gets flattened
[PDFBOX-4638] - no field content after PDAcroForm.refreshAppearances() call if BBox empty
[PDFBOX-4646] - PDFToImage not working with certain formfields
New Feature
[PDFBOX-4563] - Port Appearance Handler from 3.0 back to 2.0
Sub-task
[PDFBOX-4564] - Port interface and base handler
[PDFBOX-4573] - Add dummy call to create appearance to annotations
[PDFBOX-4574] - Port individual appearance handlers
[PDFBOX-4575] - Add appearance generation to annotation example code
[PDFBOX-4576] - Update PageDrawer to match appearance handling in trunk
[PDFBOX-4639] - Please add Automatic-Module-Name to MANIFEST.MF
Improvement
[PDFBOX-4458] - Subclasses of OperatorProcessor dont use constants
[PDFBOX-4509] - Font appears twice in resources of field widget
[PDFBOX-4510] - Don't write identity matrix in form XObjects of field widgets appearance stream
[PDFBOX-4519] - Reduce artefacts in shadings
[PDFBOX-4522] - Resources cache should be passed to type 3 fonts
[PDFBOX-4529] - ImageToPDF as Command Line
[PDFBOX-4539] - Cache CharsetDecoder
[PDFBOX-4544] - COSWriter.doWriteHeader(COSDocument) should use the document specified as parameter
[PDFBOX-4562] - Remove the usage of COSDocument.getCatalog
[PDFBOX-4578] - Overhaul StreamValidationProcess
Wish
[PDFBOX-4080] - Improve memory consumption of PDAbstractAppearanceHandler
[PDFBOX-4597] - TextPosition.getX() vs getXDirAdj()
[PDFBOX-4600] - Please clarify CTM terminology in Javadoc
[PDFBOX-4632] - Create example of PDF creation with page labels
[PDFBOX-4637] - improve exception message "IOException: Could not find font: /Helvetica"
[PDFBOX-4641] - Keywords created using PDFBox are not visible in Acrobat
[PDFBOX-4515] - Support for Add Text Callout Annotation tool.
Task
[PDFBOX-4625] - remove Netbeans warning: Exporting non-public type through public API
Release Contents
----------------
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-parent</artifactId>
<version>2.0.16</version>
<version>2.0.17</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
......
libpdfbox2-java (2.0.17-1) unstable; urgency=medium
* New upstream version 2.0.17.
-- Markus Koschany <apo@debian.org> Sat, 28 Sep 2019 23:37:22 +0200
libpdfbox2-java (2.0.16-1) unstable; urgency=medium
* New upstream version 2.0.16.
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-parent</artifactId>
<version>2.0.16</version>
<version>2.0.17</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
......
......@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-parent</artifactId>
<version>2.0.16</version>
<version>2.0.17</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
......@@ -75,6 +75,19 @@
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.apache.pdfbox.debugger</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
......
......@@ -21,6 +21,7 @@ import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
......@@ -105,6 +106,7 @@ import org.apache.pdfbox.debugger.ui.ReaderBottomPanel;
import org.apache.pdfbox.debugger.ui.RecentFiles;
import org.apache.pdfbox.debugger.ui.RotationMenu;
import org.apache.pdfbox.debugger.ui.Tree;
import org.apache.pdfbox.debugger.ui.WindowPrefs;
import org.apache.pdfbox.debugger.ui.ZoomMenu;
import org.apache.pdfbox.filter.FilterFactory;
import org.apache.pdfbox.io.IOUtils;
......@@ -125,7 +127,7 @@ import org.apache.pdfbox.printing.PDFPageable;
* @author Ben Litchfield
* @author Khyrul Bashar
*/
@SuppressWarnings({"serial","squid:MaximumInheritanceDepth"})
@SuppressWarnings({"serial","squid:MaximumInheritanceDepth","squid:S1948"})
public class PDFDebugger extends JFrame
{
private static final Set<COSName> SPECIALCOLORSPACES =
......@@ -135,6 +137,7 @@ public class PDFDebugger extends JFrame
new HashSet<COSName>(Arrays.asList(COSName.ICCBASED, COSName.PATTERN, COSName.CALGRAY,
COSName.CALRGB, COSName.LAB));
@SuppressWarnings({"squid:S2068"})
private static final String PASSWORD = "-password";
private static final String VIEW_STRUCTURE = "-viewstructure";
......@@ -143,6 +146,7 @@ public class PDFDebugger extends JFrame
private TreeStatusPane statusPane;
private RecentFiles recentFiles;
private WindowPrefs windowPrefs;
private boolean isPageMode;
private PDDocument document;
......@@ -226,10 +230,10 @@ public class PDFDebugger extends JFrame
}
});
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
windowPrefs = new WindowPrefs(this.getClass());
jScrollPane1.setBorder(new BevelBorder(BevelBorder.RAISED));
jScrollPane1.setPreferredSize(new Dimension(screenSize.width / 8, 500));
jSplitPane1.setDividerLocation(screenSize.width / 8);
jSplitPane1.setDividerLocation(windowPrefs.getDividerLocation());
tree.addTreeSelectionListener(new TreeSelectionListener()
{
@Override
......@@ -244,7 +248,6 @@ public class PDFDebugger extends JFrame
jSplitPane1.setRightComponent(jScrollPane2);
jSplitPane1.setDividerSize(3);
jScrollPane2.setPreferredSize(new Dimension(screenSize.width / 8 * 7, 500));
jScrollPane2.setViewportView(jTextPane1);
jSplitPane1.setLeftComponent(jScrollPane1);
......@@ -269,7 +272,8 @@ public class PDFDebugger extends JFrame
menuBar.add(createViewMenu());
setJMenuBar(menuBar);
setBounds(screenSize.width / 4, screenSize.height / 4, screenSize.width / 2, screenSize.height / 2);
setExtendedState(windowPrefs.getExtendedState());
setBounds(windowPrefs.getBounds());
// drag and drop to open files
setTransferHandler(new TransferHandler()
......@@ -1106,6 +1110,10 @@ public class PDFDebugger extends JFrame
throw new RuntimeException(e);
}
}
windowPrefs.setExtendedState(getExtendedState());
this.setExtendedState(Frame.NORMAL);
windowPrefs.setBounds(getBounds());
windowPrefs.setDividerLocation(jSplitPane1.getDividerLocation());
performApplicationExit();
}
......@@ -1218,6 +1226,7 @@ public class PDFDebugger extends JFrame
// open file, if any
String filename = null;
@SuppressWarnings({"squid:S2068"})
String password = "";
boolean viewPages = true;
......
......@@ -90,6 +90,7 @@ public class CSSeparation implements ChangeListener, ActionListener
slider.setMajorTickSpacing(50);
slider.setPaintTicks(true);
@SuppressWarnings({"squid:S1149"})
Dictionary<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
JLabel lightest = new JLabel("lightest");
lightest.setFont(new Font(Font.MONOSPACED, Font.BOLD, 10));
......
......@@ -26,6 +26,7 @@ import javax.swing.table.AbstractTableModel;
/**
* This the table model for showing Indexed color space which extends AbstractTableModel.
*/
@SuppressWarnings({"serial","squid:S1948"})
public class IndexedTableModel extends AbstractTableModel
{
......
......@@ -20,6 +20,8 @@ import java.awt.geom.GeneralPath;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import javax.swing.JPanel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.PDResources;
......@@ -67,6 +69,8 @@ abstract class FontPane
*/
public class FontEncodingPaneController
{
private static final Log LOG = LogFactory.getLog(FontEncodingPaneController.class);
private FontPane fontPane;
/**
......@@ -95,7 +99,7 @@ public class FontEncodingPaneController
}
catch (IOException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
......
......@@ -62,7 +62,7 @@ class SimpleFont extends FontPane
for (int index = 0; index <= 255; index++)
{
glyphs[index][0] = index;
if (font.getEncoding().contains(index))
if (font.getEncoding().contains(index) || font.toUnicode(index) != null)
{
String glyphName = font.getEncoding().getName(index);
glyphs[index][1] = glyphName;
......
......@@ -119,7 +119,7 @@ class Type3Font extends FontPane
for (int index = 0; index <= 255; index++)
{
glyphs[index][0] = index;
if (font.getEncoding().contains(index))
if (font.getEncoding().contains(index) || font.toUnicode(index) != null)
{
String name = font.getEncoding().getName(index);
glyphs[index][1] = name;
......
......@@ -30,6 +30,7 @@ import javax.swing.JComponent;
* This class shows corresponding ASCII characters for bytes. For every 16 byte there is one line.
* This paints the only visible contents at one time.
*/
@SuppressWarnings({"serial","squid:S1948"})
class ASCIIPane extends JComponent implements HexModelChangeListener
{
private final HexModel model;
......
......@@ -45,6 +45,7 @@ import javax.swing.border.LineBorder;
*
* This class hosts all the UI components of Hex view and coordinates among them.
*/
@SuppressWarnings({"serial","squid:S1948"})
class HexEditor extends JPanel implements SelectionChangeListener
{
private final HexModel model;
......
......@@ -114,13 +114,19 @@ public class PagePane implements ActionListener, AncestorListener, MouseMotionLi
{
if (annotation instanceof PDAnnotationLink)
{
PDAnnotationLink linkAnnotation = (PDAnnotationLink) annotation;
collectLinkLocation((PDAnnotationLink) annotation);
}
}
}
private void collectLinkLocation(PDAnnotationLink linkAnnotation) throws IOException
{
PDAction action = linkAnnotation.getAction();
if (action instanceof PDActionURI)
{
PDActionURI uriAction = (PDActionURI) action;
rectMap.put(annotation.getRectangle(), "URI: " + uriAction.getURI());
continue;
rectMap.put(linkAnnotation.getRectangle(), "URI: " + uriAction.getURI());
return;
}
PDDestination destination;
if (action instanceof PDActionGoTo)
......@@ -143,9 +149,7 @@ public class PagePane implements ActionListener, AncestorListener, MouseMotionLi
int pageNum = pageDestination.retrievePageNumber();
if (pageNum != -1)
{
rectMap.put(annotation.getRectangle(), "Page destination: " + (pageNum + 1));
}
}
rectMap.put(linkAnnotation.getRectangle(), "Page destination: " + (pageNum + 1));
}
}
}
......
......@@ -23,6 +23,8 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSDictionary;
......@@ -39,10 +41,12 @@ import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
*/
public class Stream
{
private static final Log LOG = LogFactory.getLog(Stream.class);
public static final String UNFILTERED = "Unfiltered";
public static final String IMAGE = "Image";
private final COSStream stream;
private final COSStream strm;
private final boolean isThumb;
private final boolean isImage;
private final boolean isXmlMetadata;
......@@ -57,7 +61,7 @@ public class Stream
*/
Stream(COSStream cosStream, boolean isThumb)
{
this.stream = cosStream;
this.strm = cosStream;
this.isThumb = isThumb;
this.isImage = isImageStream(cosStream, isThumb);
this.isXmlMetadata = isXmlMetadataStream(cosStream);
......@@ -107,7 +111,7 @@ public class Stream
private String getFilteredLabel()
{
StringBuilder sb = new StringBuilder();
COSBase base = stream.getFilters();
COSBase base = strm.getFilters();
if (base instanceof COSName)
{
sb.append(((COSName) base).getName());
......@@ -139,20 +143,20 @@ public class Stream
{
if (UNFILTERED.equals(key))
{
return stream.createInputStream();
return strm.createInputStream();
}
else if (getFilteredLabel().equals(key))
{
return stream.createRawInputStream();
return strm.createRawInputStream();
}
else
{
return new PDStream(stream).createInputStream(filters.get(key));
return new PDStream(strm).createInputStream(filters.get(key));
}
}
catch (IOException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
return null;
}
......@@ -170,17 +174,17 @@ public class Stream
PDImageXObject imageXObject;
if (isThumb)
{
imageXObject = PDImageXObject.createThumbnail(stream);
imageXObject = PDImageXObject.createThumbnail(strm);
}
else
{
imageXObject = new PDImageXObject(new PDStream(stream), resources);
imageXObject = new PDImageXObject(new PDStream(strm), resources);
}
return imageXObject.getImage();
}
catch (IOException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
return null;
}
......@@ -212,12 +216,12 @@ public class Stream
private String getPartialStreamCommand(final int indexOfStopFilter)
{
List<COSName> avaiablrFilters = new PDStream(stream).getFilters();
List<COSName> availableFilters = new PDStream(strm).getFilters();
StringBuilder nameListBuilder = new StringBuilder();
for (int i = indexOfStopFilter; i < avaiablrFilters.size(); i++)
for (int i = indexOfStopFilter; i < availableFilters.size(); i++)
{
nameListBuilder.append(avaiablrFilters.get(i).getName()).append(" & ");
nameListBuilder.append(availableFilters.get(i).getName()).append(" & ");
}
nameListBuilder.delete(nameListBuilder.lastIndexOf("&"), nameListBuilder.length());
......@@ -226,10 +230,10 @@ public class Stream
private List<String> getStopFilterList(final int stopFilterIndex)
{
List<COSName> avaiablrFilters = new PDStream(stream).getFilters();
List<COSName> availableFilters = new PDStream(strm).getFilters();
final List<String> stopFilters = new ArrayList<String>(1);
stopFilters.add(avaiablrFilters.get(stopFilterIndex).getName());
stopFilters.add(availableFilters.get(stopFilterIndex).getName());
return stopFilters;
}
......
......@@ -43,6 +43,8 @@ import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.contentstream.operator.Operator;
import org.apache.pdfbox.contentstream.operator.OperatorName;
import org.apache.pdfbox.cos.COSArray;
......@@ -68,6 +70,8 @@ import org.apache.pdfbox.util.Charsets;
*/
public class StreamPane implements ActionListener
{
private static final Log LOG = LogFactory.getLog(StreamPane.class);
@Deprecated
public static final String BEGIN_TEXT_OBJECT = OperatorName.BEGIN_TEXT;
@Deprecated
......@@ -210,7 +214,7 @@ public class StreamPane implements ActionListener
}
catch (IOException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
}
......@@ -269,7 +273,8 @@ public class StreamPane implements ActionListener
String encoding = "ISO-8859-1";
synchronized (stream)
{
if (stream.isXmlMetadata()) {
if (stream.isXmlMetadata())
{
encoding = "UTF-8";
}
InputStream inputStream = stream.getStream(filterKey);
......@@ -295,11 +300,11 @@ public class StreamPane implements ActionListener
}
catch (InterruptedException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
catch (ExecutionException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
......@@ -313,7 +318,7 @@ public class StreamPane implements ActionListener
}
catch (IOException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
return null;
}
}
......@@ -330,7 +335,7 @@ public class StreamPane implements ActionListener
}
catch (BadLocationException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
return docu;
......@@ -373,7 +378,7 @@ public class StreamPane implements ActionListener
}
catch (BadLocationException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
......@@ -422,7 +427,7 @@ public class StreamPane implements ActionListener
}
else
{
String str = "" + (char)chr;
String str = Character.toString((char) chr);
docu.insertString(docu.getLength(), str, STRING_STYLE);
}
}
......
......@@ -18,16 +18,19 @@
package org.apache.pdfbox.debugger.streampane.tooltip;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.PDResources;
import org.apache.pdfbox.pdmodel.font.PDFont;
/**
* @author Khyrul Bashar
* A class that provieds tooltip text for font. This shows the name of the font.
* A class that provides tooltip text for font. This shows the name of the font.
*/
final class FontToolTip implements ToolTip
{
private static final Log LOG = LogFactory.getLog(FontToolTip.class);
private String markup;
/**
......@@ -54,7 +57,7 @@ final class FontToolTip implements ToolTip
}
catch (IOException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
}
......
......@@ -23,6 +23,8 @@ import java.awt.color.ICC_Profile;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceCMYK;
/**
......@@ -30,8 +32,9 @@ import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceCMYK;
* A class that provide tooltip for K and k.
*/
final class KToolTip extends ColorToolTip
{
private static final Log LOG = LogFactory.getLog(KToolTip.class);
/**
* Constructor.
* @param rowText String instance.
......@@ -53,7 +56,7 @@ final class KToolTip extends ColorToolTip
}
catch (IOException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
}
......
......@@ -19,6 +19,8 @@ package org.apache.pdfbox.debugger.streampane.tooltip;
import java.awt.Color;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.PDResources;
import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
......@@ -30,6 +32,8 @@ import org.apache.pdfbox.pdmodel.graphics.color.PDPattern;
*/
final class SCNToolTip extends ColorToolTip
{
private static final Log LOG = LogFactory.getLog(SCNToolTip.class);
/**
* Constructor.
* @param rowText String instance.
......@@ -48,7 +52,7 @@ final class SCNToolTip extends ColorToolTip
}
catch (IOException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
if (colorSpace instanceof PDPattern)
{
......@@ -68,7 +72,7 @@ final class SCNToolTip extends ColorToolTip
}
catch (IOException e)
{
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
}
......
......@@ -22,6 +22,9 @@ import java.util.List;
import javax.swing.text.BadLocationException;
import javax.swing.text.JTextComponent;
import javax.swing.text.Utilities;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.pdfbox.contentstream.operator.OperatorName;
import org.apache.pdfbox.pdmodel.PDResources;
interface ToolTip
......@@ -31,21 +34,11 @@ interface ToolTip
/**
* @author Khyrul Bashar
* A class that provieds the tooltip for an operator.
* A class that provides the tooltip for an operator.
*/
public class ToolTipController
{
private static final String FONT_OPERATOR = "Tf";
private static final String STROKING_COLOR = "SCN";
private static final String STROKING_COLOR_SPACE = "CS";
private static final String NON_STROKING_COLOR_SPACE = "cs";
private static final String NON_STROKING_COLOR = "scn";
private static final String RGB_STROKING_COLOR = "RG";
private static final String RGB_NON_STROKING_COLOR = "rg";
private static final String CMYK_STROKING_COLOR = "K";
private static final String CMYK_NON_STROKING_COLOR = "k";
private static final String GRAY_STROKING_COLOR = "G";
private static final String GRAY_NON_STROKING_COLOR = "g";
private static final Log LOG = LogFactory.getLog(ToolTipController.class);
private final PDResources resources;
private JTextComponent textComponent;
......@@ -89,40 +82,40 @@ public class ToolTipController
if (word != null)
{
ToolTip toolTip;
if (word.equals(FONT_OPERATOR))
if (word.equals(OperatorName.SET_FONT_AND_SIZE))
{
toolTip = new FontToolTip(resources, rowText);
return toolTip.getToolTipText();
}
else if (word.equals(STROKING_COLOR))
else if (word.equals(OperatorName.STROKING_COLOR_N))
{
String colorSpaceName = findColorSpace(offset, STROKING_COLOR_SPACE);
String colorSpaceName = findColorSpace(offset, OperatorName.STROKING_COLORSPACE);
if (colorSpaceName != null)
{
toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
return toolTip.getToolTipText();
}
}
else if (word.equals(NON_STROKING_COLOR))
else if (word.equals(OperatorName.NON_STROKING_COLOR_N))
{
String colorSpaceName = findColorSpace(offset, NON_STROKING_COLOR_SPACE);
String colorSpaceName = findColorSpace(offset, OperatorName.NON_STROKING_COLORSPACE);
if (colorSpaceName != null)
{
toolTip = new SCNToolTip(resources, colorSpaceName, rowText);
return toolTip.getToolTipText();
}
}
else if (word.equals(RGB_STROKING_COLOR) || word.equals(RGB_NON_STROKING_COLOR))
else if (word.equals(OperatorName.STROKING_COLOR_RGB) || word.equals(OperatorName.NON_STROKING_RGB))
{
toolTip = new RGToolTip(rowText);
return toolTip.getToolTipText();
}
else if (word.equals(CMYK_STROKING_COLOR) || word.equals(CMYK_NON_STROKING_COLOR))
else if (word.equals(OperatorName.STROKING_COLOR_CMYK) || word.equals(OperatorName.NON_STROKING_CMYK))
{
toolTip = new KToolTip(rowText);
return toolTip.getToolTipText();
}
else if (word.equals(GRAY_STROKING_COLOR) || word.equals(GRAY_NON_STROKING_COLOR))
else if (word.equals(OperatorName.STROKING_COLOR_GRAY) || word.equals(OperatorName.NON_STROKING_GRAY))
{
toolTip = new GToolTip(rowText);
return toolTip.getToolTipText();
......@@ -152,8 +145,7 @@ public class ToolTipController
}
catch (BadLocationException e)
{
e.printStackTrace();
return null;
LOG.error(e, e);
}
return null;
}
......@@ -174,7 +166,7 @@ public class ToolTipController
}
catch (BadLocationException e)
{
e.printStackTrace();
LOG.error(e, e);
}
return null;
}
......@@ -189,7 +181,7 @@ public class ToolTipController
}
catch (BadLocationException e)
{
e.printStackTrace();
LOG.error(e, e);
}
return null;
}
......