Skip to content

VBA symphony branch updates - #515

Merged
pgiffuni merged 6 commits into
apache:trunkfrom
pgiffuni:trunk
Nov 2, 2026
Merged

pgiffuni merged 6 commits into
apache:trunkfrom
pgiffuni:trunk

Conversation

@pgiffuni

@pgiffuni pgiffuni commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

This brings the symphony-vba functional part of the branch.
It doesn't yet bring the testing framework as I haven't yet
evaluated the effect on the build time. The testing framework
will be left for reference in the branch.

It is the result of merging parts of the IBM symphony contribution,
plus fixing tests suggested by a bunch of other frameworks, and
by evaluating the functionality required by several open sources
VBA based applications.
It is not complete but it certainly covers a lot of functionality.
The main obstacle towards running most applications is now not
in VBA itself but rather on Excel or platform specific characteristics.

At no time was copyleft or commercial code adopted for this
implementation.

…, Workbook.SaveAs, and Application enhancements

Port IBM Lotus Symphony VBA compatibility features into Apache OpenOffice's
Calc VBA compatibility layer:

New IDL interfaces (main/oovbaapi/ooo/vba/):
- XFileDialog: MsoFileDialogType, Title, AllowMultiSelect, Show()
- XFileDialogSelectedItems: extends XCollection
- XFileSearch: FileName, LookIn, SearchSubFolders, MatchTextExactly, Execute()
- XFoundFiles: extends XCollection, File(Index)
- XQueryTable: Refresh(any), Delete()

New C++ implementations (main/sc/source/ui/vba/):
- ScVbaFileDialog using com.sun.star.ui.dialogs.FilePicker
- ScVbaFileSearch using com.sun.star.ucb.SimpleFileAccess
- VbaFoundFiles collection with XIndexAccess/XEnumeration
- ScVbaQueryTable using sfx2::LinkManager and ScAreaLink

Modified XApplication.idl:
- FileDialog() method + FileSearch attribute
- CountA, MenuBars, International, Undo, InchesToPoints
- setSheetsInNewWorkbook, getSheetsInNewWorkbook
- Intersect, Union (already present)

Modified XRange.idl:
- Added FormatConditions and QueryTable attributes

Modified XWorkbook.idl:
- Added SaveAs method

Implemented getFormatConditions() in vbarange.cxx:
- Returns ScVbaFormatConditions using ConditionalFormat property

Implemented Application methods in vbaapplication.cxx:
- CountA delegates to WorksheetFunction::CountA
- getSheetsInNewWorkbook/setSheetsInNewWorkbook use ScAppOptions
- FileDialog() creates ScVbaFileDialog with model
- getFileSearch() creates ScVbaFileSearch

Added missing Formula1()/Formula2() to XFormatCondition:
- Required by IDL interface, returns formula from XSheetCondition

Registered services in service.cxx:
- filedialog, filesearch, foundfiles, querytable
- formatconditions, formatcondition

Build configuration:
- UnoApi_oovbaapi.mk: 5 new IDL files added
- Library_vbaobj.mk: 5 new .cxx files added

Import Symphony VBA: FileDialog, FileSearch, QueryTable, FormatCondition, Workbook.SaveAs, Application enhancements

Ports from IBM Symphony VBA implementation, combined with GCC 15
compilation fixes and VBA documentation comments. These changes
cannot be cherry-picked independently of the VBA feature work:

- Add FileDialog, FileSearch, QueryTable, FormatCondition VBA objects
- Enhance Application with SheetsInNewWorkbook, MenuBars stub, International stub
- Add ScAppOptions GetTabCountInNewSpreadsheet/SetTabCountInNewSpreadsheet
- Fix Workbook.SaveAs with proper XStorable property mapping
- Add factory constructors for with_args<true> service declarations
- Fix namespace/visibility issues for GCC 15:
  - helperdecl.hxx: vba_detail -> detail, add include guard
  - vbaquerytable.cxx: scrange.hxx -> address.hxx, SvBaseLinks -> sfx2::
  - vbafilesearch.cxx: getInitPath exception specifier
  - vbafiledialog.cxx: GetAllFileFilterName -> hardcoded string
  - vbasheetobject.hxx: documentation comments
- Add MS Excel VBA API documentation to all VBA headers
… parsing, and named ranges

Fix VBA compatibility issues identified by LibreOffice-style failure hypothesis tests:

- VBA arrays: Dim arr(n) now creates 1-based arrays (indices 1..n)
  in VBA compatibility mode (StepBASED, SbiParser::DefType)
- TypeName: Returns 'Nothing' for null object references in VBA mode
- Array(): Always 0-based per VBA spec (ignores Option Base 1 in VBA mode)
- NBSP (U+00A0) as thousands separator: Handle locale-aware number
  parsing in ImpScan by replacing NBSP before ASCII-US conversion
- Names.Add: Parse string RefersTo addresses (e.g. '=Sheet1!$A$1:$A$3')
  via getRangeObjectForName after stripping '=' prefix
- Name.Name: Return raw name without sheet prefix (AOO stores all names
  at document level, unlike VBA worksheet-level names)
- Name.RefersToRange: Use getValue() (VBA-formatted address) instead of
  getName() to resolve the range reference
Package 1 (Range.Value2): Already existed in codebase
Package 2 (Application.Match): Works through invoke/FunctionAccess
Package 3 (Application.Evaluate): Existing implementation extended for formulas
Package 4 (Application.Run): Added to XApplication.idl and implemented via
  XScriptProvider dispatch; hasMethod recognizes 'Run'
Package 5 (#If/#Const): Added PP_IF/PP_CONST tokens to SbiToken enum, tokenizer
  handler for #-prefixed directives, PPIf/PPConst parser methods with
  constant expression evaluation and block skip logic
Package 6 (Range.Formula2): Added to XRange.idl, implemented in vbarange.cxx
  via delegation to Formula methods
Add Scripting.Dictionary implementation (ooo.vba.scripting.Dictionary service)
with full Item/Add/Exists/Keys/Items/Remove/RemoveAll/Count/CompareMode/Key support.

Key changes:
- sbunooobj.cxx: Add SBX_HINT_DATACHANGED handler for pMeth to support
  dict("key") = value setter via invoke("Item", [key, value])
- sb.cxx: Add CreateObject("Scripting.Dictionary") handler
- vbadictionary.cxx/hxx: Full Dictionary UNO component implementation
- XDictionary.idl: IDL interface with XDefaultMethod, XInvocation,
  XPropertySet, XHelperInterface
- Add INTERFACE token to SbiToken enum for VBA parsing
- Fix pre-existing build errors in vbadictionary, vbaapplication,
  vbafiledialog, and vbarange
- Fix TokenLabelInfo array size: INTERFACE+1 -> PP_CONST+1 to prevent
  out-of-bounds access with preprocessor tokens
- Restore PPIf while-loop body with proper nesting tracking
- Extend evaluatePPTerm for NE/LT/GT/LE/GE comparison operators
- Fix #Const to use EQ token instead of ASSIGN
- Rewrite skipStatement with nested #If tracking
- Simplify skipUntilEndIf to use Next() directly
- Fix StmntTable entries for PP_IF/PP_ELSEIF/PP_ELSE/PP_ENDIF (bMain: N->Y)
- Update Parse() to handle PP tokens in error path
- Add maConstNumMap for numeric #Const values
- Fix sbxmod_override in test Makefile
@pgiffuni

pgiffuni commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

The pre-commit issue is in unrelated code AFAICT

@pgiffuni
pgiffuni merged commit 7a7771f into apache:trunk Nov 2, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant