refactor: export form modules as .frm files to align with VBA conventions

Change form module export from .cls to .frm extension to match standard VBA file conventions and align with import_vba.py expectations. This eliminates ambiguity between class modules and form modules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-03-19 15:47:57 +08:00
parent 7b27e50573
commit ab01835b06

View File

@@ -253,7 +253,7 @@ class VBAExtractor:
stream_path: 流路径 stream_path: 流路径
Returns: Returns:
模块类型: Modules, ClassModules, DocumentModules 模块类型: Modules, ClassModules, DocumentModules, Forms
""" """
name_lower = module_name.lower() name_lower = module_name.lower()
@@ -269,6 +269,10 @@ class VBAExtractor:
if name_lower.startswith('cls') or name_lower.startswith('class'): if name_lower.startswith('cls') or name_lower.startswith('class'):
return CLASS_MODULE_DIR return CLASS_MODULE_DIR
# 窗体模块
if name_lower.startswith('userform') or name_lower.startswith('frm_') or name_lower.startswith('frm'):
return FORMS_DIR
# 根据stream_path判断 # 根据stream_path判断
if stream_path: if stream_path:
path_lower = stream_path.lower() path_lower = stream_path.lower()
@@ -276,6 +280,8 @@ class VBAExtractor:
return DOCUMENT_MODULE_DIR return DOCUMENT_MODULE_DIR
elif 'class' in path_lower or 'cls' in path_lower: elif 'class' in path_lower or 'cls' in path_lower:
return CLASS_MODULE_DIR return CLASS_MODULE_DIR
elif 'form' in path_lower or 'userform' in path_lower:
return FORMS_DIR
# 默认为标准模块 # 默认为标准模块
return STANDARD_MODULE_DIR return STANDARD_MODULE_DIR
@@ -309,7 +315,12 @@ class VBAExtractor:
}.get(module_type, self.modules_dir) }.get(module_type, self.modules_dir)
# 确定文件扩展名 # 确定文件扩展名
ext = '.cls' if module_type in [CLASS_MODULE_DIR, DOCUMENT_MODULE_DIR, FORMS_DIR] else '.bas' if module_type == FORMS_DIR:
ext = '.frm'
elif module_type in [CLASS_MODULE_DIR, DOCUMENT_MODULE_DIR]:
ext = '.cls'
else:
ext = '.bas'
# 清理文件名(移除已有扩展名) # 清理文件名(移除已有扩展名)
clean_name = module_name.replace('/', '_').replace('\\', '_') clean_name = module_name.replace('/', '_').replace('\\', '_')