PDFDebugger.java (pdfbox-2.0.23-src) | : | PDFDebugger.java (pdfbox-2.0.24-src) | ||
---|---|---|---|---|
skipping to change at line 440 | skipping to change at line 440 | |||
@Override | @Override | |||
public void actionPerformed(ActionEvent evt) | public void actionPerformed(ActionEvent evt) | |||
{ | { | |||
printMenuItemActionPerformed(evt); | printMenuItemActionPerformed(evt); | |||
} | } | |||
}); | }); | |||
fileMenu.addSeparator(); | fileMenu.addSeparator(); | |||
fileMenu.add(printMenuItem); | fileMenu.add(printMenuItem); | |||
JMenuItem exitMenuItem = new JMenuItem("Exit"); | if (!IS_MAC_OS) | |||
exitMenuItem.setAccelerator(KeyStroke.getKeyStroke("alt F4")); | ||||
exitMenuItem.addActionListener(new ActionListener() | ||||
{ | { | |||
@Override | JMenuItem exitMenuItem = new JMenuItem("Exit"); | |||
public void actionPerformed(ActionEvent evt) | exitMenuItem.setAccelerator(KeyStroke.getKeyStroke("alt F4")); | |||
exitMenuItem.addActionListener(new ActionListener() | ||||
{ | { | |||
exitMenuItemActionPerformed(evt); | @Override | |||
} | public void actionPerformed(ActionEvent evt) | |||
}); | { | |||
exitMenuItemActionPerformed(evt); | ||||
} | ||||
}); | ||||
if (!IS_MAC_OS) | ||||
{ | ||||
fileMenu.addSeparator(); | fileMenu.addSeparator(); | |||
fileMenu.add(exitMenuItem); | fileMenu.add(exitMenuItem); | |||
} | } | |||
return fileMenu; | return fileMenu; | |||
} | } | |||
private JMenu createEditMenu() | private JMenu createEditMenu() | |||
{ | { | |||
JMenu editMenu = new JMenu("Edit"); | JMenu editMenu = new JMenu("Edit"); | |||
skipping to change at line 825 | skipping to change at line 825 | |||
MapEntry entry = (MapEntry) obj; | MapEntry entry = (MapEntry) obj; | |||
return COSName.ENCRYPT.equals(entry.getKey()) && entry.getValue() in stanceof COSDictionary; | return COSName.ENCRYPT.equals(entry.getKey()) && entry.getValue() in stanceof COSDictionary; | |||
} | } | |||
return false; | return false; | |||
} | } | |||
private boolean isFontDescriptor(Object obj) | private boolean isFontDescriptor(Object obj) | |||
{ | { | |||
Object underneathObject = getUnderneathObject(obj); | Object underneathObject = getUnderneathObject(obj); | |||
return underneathObject instanceof COSDictionary && | return underneathObject instanceof COSDictionary && | |||
((COSDictionary) underneathObject).containsKey(COSName.TYPE) && | COSName.FONT_DESC.equals(((COSDictionary) underneathObject).getC | |||
((COSDictionary) underneathObject).getCOSName(COSName.TYPE).equa | OSName(COSName.TYPE)); | |||
ls(COSName.FONT_DESC); | ||||
} | } | |||
private boolean isAnnot(Object obj) | private boolean isAnnot(Object obj) | |||
{ | { | |||
Object underneathObject = getUnderneathObject(obj); | Object underneathObject = getUnderneathObject(obj); | |||
return underneathObject instanceof COSDictionary && | return underneathObject instanceof COSDictionary && | |||
((COSDictionary) underneathObject).containsKey(COSName.TYPE) && | COSName.ANNOT.equals(((COSDictionary) underneathObject).getCOSNa | |||
((COSDictionary) underneathObject).getCOSName(COSName.TYPE).equa | me(COSName.TYPE)); | |||
ls(COSName.ANNOT); | ||||
} | } | |||
private boolean isStream(Object selectedNode) | private boolean isStream(Object selectedNode) | |||
{ | { | |||
return getUnderneathObject(selectedNode) instanceof COSStream; | return getUnderneathObject(selectedNode) instanceof COSStream; | |||
} | } | |||
private boolean isString(Object selectedNode) | private boolean isString(Object selectedNode) | |||
{ | { | |||
return getUnderneathObject(selectedNode) instanceof COSString; | return getUnderneathObject(selectedNode) instanceof COSString; | |||
} | } | |||
private boolean isFont(Object selectedNode) | private boolean isFont(Object selectedNode) | |||
{ | { | |||
selectedNode = getUnderneathObject(selectedNode); | selectedNode = getUnderneathObject(selectedNode); | |||
if (selectedNode instanceof COSDictionary) | if (selectedNode instanceof COSDictionary) | |||
{ | { | |||
COSDictionary dic = (COSDictionary)selectedNode; | COSDictionary dic = (COSDictionary) selectedNode; | |||
return dic.containsKey(COSName.TYPE) && | return COSName.FONT.equals(dic.getCOSName(COSName.TYPE)) && !isCIDFo | |||
dic.getCOSName(COSName.TYPE).equals(COSName.FONT) && | nt(dic); | |||
!isCIDFont(dic); | ||||
} | } | |||
return false; | return false; | |||
} | } | |||
private boolean isCIDFont(COSDictionary dic) | private boolean isCIDFont(COSDictionary dic) | |||
{ | { | |||
return dic.containsKey(COSName.SUBTYPE) && | return COSName.CID_FONT_TYPE0.equals(dic.getCOSName(COSName.SUBTYPE)) || | |||
(dic.getCOSName(COSName.SUBTYPE).equals(COSName.CID_FONT_TYPE0) | COSName.CID_FONT_TYPE2.equals(dic.getCOSName(COSName.SUBTYPE)); | |||
|| dic.getCOSName(COSName.SUBTYPE).equals(COSName.CID_FONT_TYPE2 | ||||
)); | ||||
} | } | |||
/** | /** | |||
* Show a Panel describing color spaces in more detail and interactive way. | * Show a Panel describing color spaces in more detail and interactive way. | |||
* @param csNode the special color space containing node. | * @param csNode the special color space containing node. | |||
*/ | */ | |||
private void showColorPane(Object csNode) throws IOException | private void showColorPane(Object csNode) throws IOException | |||
{ | { | |||
csNode = getUnderneathObject(csNode); | csNode = getUnderneathObject(csNode); | |||
skipping to change at line 1391 | skipping to change at line 1386 | |||
else | else | |||
{ | { | |||
tree.setModel(new PDFTreeModel(document)); | tree.setModel(new PDFTreeModel(document)); | |||
tree.setSelectionPath(treeStatus.getPathForString("Root")); | tree.setSelectionPath(treeStatus.getPathForString("Root")); | |||
} | } | |||
} | } | |||
/** | /** | |||
* Internal class to avoid double code in password entry loop. | * Internal class to avoid double code in password entry loop. | |||
*/ | */ | |||
abstract class DocumentOpener | abstract static class DocumentOpener | |||
{ | { | |||
String password; | String password; | |||
DocumentOpener(String password) | DocumentOpener(String password) | |||
{ | { | |||
this.password = password; | this.password = password; | |||
} | } | |||
/** | /** | |||
* Override to load the actual input type (File, URL, stream), don't cal l it directly! | * Override to load the actual input type (File, URL, stream), don't cal l it directly! | |||
* | * | |||
* @return | * @return the PDDocument instance | |||
* @throws IOException | * @throws IOException Cannot read document | |||
*/ | */ | |||
abstract PDDocument open() throws IOException; | abstract PDDocument open() throws IOException; | |||
/** | /** | |||
* Call this! | * Call this! | |||
* | * | |||
* @return | * @return the PDDocument instance | |||
* @throws IOException | * @throws IOException Cannot read document | |||
*/ | */ | |||
final PDDocument parse() throws IOException | final PDDocument parse() throws IOException | |||
{ | { | |||
while (true) | while (true) | |||
{ | { | |||
try | try | |||
{ | { | |||
return open(); | return open(); | |||
} | } | |||
catch (InvalidPasswordException ipe) | catch (InvalidPasswordException ipe) | |||
End of changes. 11 change blocks. | ||||
29 lines changed or deleted | 24 lines changed or added |