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.ModuleImpl |
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(POIFSFileSystem fs) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
findMacros(DirectoryNode dir,
VBAMacroReader.ModuleMap modules)
Recursively traverses directory structure rooted at dir.
|
protected void |
findModuleNameMap(DirectoryNode node,
java.util.Map<java.lang.String,java.lang.String> moduleNameMap,
VBAMacroReader.ModuleMap modules) |
protected void |
findProjectProperties(DirectoryNode node,
java.util.Map<java.lang.String,java.lang.String> moduleNameMap,
VBAMacroReader.ModuleMap modules) |
java.util.Map<java.lang.String,Module> |
readMacroModules() |
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 void |
readNameMapRecords(java.io.InputStream is,
java.util.Map<java.lang.String,java.lang.String> moduleNames,
java.nio.charset.Charset charset) |
protected void |
readProjectProperties(DocumentInputStream dis,
java.util.Map<java.lang.String,java.lang.String> moduleNameMap,
VBAMacroReader.ModuleMap 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.IOException
public VBAMacroReader(java.io.File file) throws java.io.IOException
java.io.IOException
public VBAMacroReader(POIFSFileSystem fs)
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public java.util.Map<java.lang.String,Module> readMacroModules() throws java.io.IOException
java.io.IOException
public java.util.Map<java.lang.String,java.lang.String> readMacros() throws java.io.IOException
java.io.IOException
protected 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.IOException
protected void findProjectProperties(DirectoryNode node, java.util.Map<java.lang.String,java.lang.String> moduleNameMap, VBAMacroReader.ModuleMap modules) throws java.io.IOException
java.io.IOException
protected void findModuleNameMap(DirectoryNode node, java.util.Map<java.lang.String,java.lang.String> moduleNameMap, VBAMacroReader.ModuleMap modules) throws java.io.IOException
java.io.IOException
protected void readNameMapRecords(java.io.InputStream is, java.util.Map<java.lang.String,java.lang.String> moduleNames, java.nio.charset.Charset charset) throws java.io.IOException
java.io.IOException
protected void readProjectProperties(DocumentInputStream dis, java.util.Map<java.lang.String,java.lang.String> moduleNameMap, VBAMacroReader.ModuleMap modules) throws java.io.IOException
java.io.IOException
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.