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!
(查找 office 文件(OLE2/POIFS 和 OOXML/OPC)中的所有 VBA 宏,并返回它们。注意:这不会从 .ppt 文件中读取宏。有关如何执行此操作的示例,请参见暂存器模块中的 org.apache.poi.hslf.usermodel.TestBugs.getMacrosFromHSLF()。欢迎使用使 .ppt 中的宏提取更加优雅的补丁!)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.
(递归遍历以 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.
(从打开的 office 文件的所有模块中读取所有宏。)
|
protected void |
readMacros(DirectoryNode macroDir, VBAMacroReader.ModuleMap modules)
Reads VBA Project modules from a VBA Project directory located at
macroDir into
modules.
(从位于 macroDir 的 VBA 项目目录中读取 VBA 项目模块到模块中。)
|
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
(java.io.IOException)
public VBAMacroReader(java.io.File file) throws java.io.IOException
java.io.IOException
(java.io.IOException)
public VBAMacroReader(POIFSFileSystem fs)
public void close() throws java.io.IOException
close
in interface
java.io.Closeable
(在接口 java.io.Closeable 中关闭)
close
in interface
java.lang.AutoCloseable
(在接口 java.lang.AutoCloseable 中关闭)
java.io.IOException
(java.io.IOException)
public java.util.Map<java.lang.String,Module> readMacroModules() throws java.io.IOException
java.io.IOException
(java.io.IOException)
public java.util.Map<java.lang.String,java.lang.String> readMacros() throws java.io.IOException
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 at
modules
- The resulting map of modules
java.io.IOException
- If reading the VBA module fails
protected 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.