public class VBAMacroReader
extends java.lang.Object
implements java.io.Closeable
Finds all VBA Macros in an office file (OLE2/POIFS and OOXML/OPC), and returns them.
NOTE: This does not read macros from .ppt files. See org.apache.poi.hslf.usermodel.TestBugs.getMacrosFromHSLF() in the scratchpad module for an example of how to do this. Patches that make macro extraction from .ppt more elegant are welcomed!
| Modifier and Type | Class and Description |
|---|---|
protected static class |
VBAMacroReader.Module |
protected static class |
VBAMacroReader.ModuleMap |
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
VBA_PROJECT_OOXML |
protected static java.lang.String |
VBA_PROJECT_POIFS |
| Constructor and Description |
|---|
VBAMacroReader(java.io.File file) |
VBAMacroReader(java.io.InputStream rstream) |
VBAMacroReader(NPOIFSFileSystem fs) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected void |
findMacros(DirectoryNode dir,
VBAMacroReader.ModuleMap modules)
Recursively traverses directory structure rooted at dir.
|
java.util.Map<java.lang.String,java.lang.String> |
readMacros()
Reads all macros from all modules of the opened office file.
|
protected void |
readMacros(DirectoryNode macroDir,
VBAMacroReader.ModuleMap modules)
Reads VBA Project modules from a VBA Project directory located at
macroDir into modules.
|
protected static final java.lang.String VBA_PROJECT_OOXML
protected static final java.lang.String VBA_PROJECT_POIFS
public VBAMacroReader(java.io.InputStream rstream)
throws java.io.IOException
java.io.IOExceptionpublic VBAMacroReader(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic VBAMacroReader(NPOIFSFileSystem fs)
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic java.util.Map<java.lang.String,java.lang.String> readMacros()
throws java.io.IOException
java.io.IOExceptionprotected void findMacros(DirectoryNode dir, VBAMacroReader.ModuleMap modules) throws java.io.IOException
dir - The directory of entries to look atmodules - The resulting map of modulesjava.io.IOException - If reading the VBA module failsprotected void readMacros(DirectoryNode macroDir, VBAMacroReader.ModuleMap modules) throws java.io.IOException
java.io.IOExceptionCopyright 2018 The Apache Software Foundation or its licensors, as applicable.