This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch symphony-vba in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 44d985c8a6be7a6f31ba56424a91b630dc22e908 Author: Pedro Giffuni <[email protected]> AuthorDate: Sat Sep 26 23:54:43 2026 -0500 Port Symphony VBA FileDialog, FileSearch, QueryTable, FormatCondition, 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 --- main/oovbaapi/ooo/vba/excel/XApplication.idl | 1 - main/sc/Library_vbaobj.mk | 1 - main/sc/source/ui/vba/helperdecl.hxx | 3 + main/sc/source/ui/vba/service.cxx | 10 +- main/sc/source/ui/vba/vbaapplication.cxx | 64 +---------- main/sc/source/ui/vba/vbaapplication.hxx | 3 - main/sc/source/ui/vba/vbafiledialog.hxx | 1 + .../source/ui/vba/vbafiledialogselecteditems.hxx | 2 +- main/sc/source/ui/vba/vbafilesearch.hxx | 2 +- main/sc/source/ui/vba/vbafoundfiles.hxx | 2 +- main/sc/source/ui/vba/vbaquerytable.hxx | 2 +- main/sc/source/ui/vba/vbarange.cxx | 122 +-------------------- main/sc/source/ui/vba/vbarange.hxx | 18 +-- 13 files changed, 20 insertions(+), 211 deletions(-) diff --git a/main/oovbaapi/ooo/vba/excel/XApplication.idl b/main/oovbaapi/ooo/vba/excel/XApplication.idl index 33ce7effd4..3b479e8c24 100644 --- a/main/oovbaapi/ooo/vba/excel/XApplication.idl +++ b/main/oovbaapi/ooo/vba/excel/XApplication.idl @@ -96,7 +96,6 @@ interface XApplication double CountA( [in] any arg1 ); any International( [in] long Index ); void Undo(); - any Run( [in] string MacroName, [in] any Arg1, [in] any Arg2, [in] any Arg3, [in] any Arg4, [in] any Arg5 ); double InchesToPoints( [in] double Inches ); void setSheetsInNewWorkbook( [in] long SheetsInNewWorkbook ); long getSheetsInNewWorkbook(); diff --git a/main/sc/Library_vbaobj.mk b/main/sc/Library_vbaobj.mk index 68d6e405e0..edb11b5e73 100644 --- a/main/sc/Library_vbaobj.mk +++ b/main/sc/Library_vbaobj.mk @@ -122,7 +122,6 @@ $(eval $(call gb_Library_add_exception_objects,vbaobj,\ sc/source/ui/vba/vbaworksheet \ sc/source/ui/vba/vbaworksheets \ sc/source/ui/vba/vbawsfunction \ - sc/source/ui/vba/vbadictionary \ sc/source/ui/vba/vbafiledialog \ sc/source/ui/vba/vbafiledialogselecteditems \ sc/source/ui/vba/vbafilesearch \ diff --git a/main/sc/source/ui/vba/helperdecl.hxx b/main/sc/source/ui/vba/helperdecl.hxx index 063d862c0a..4ea4b6793a 100644 --- a/main/sc/source/ui/vba/helperdecl.hxx +++ b/main/sc/source/ui/vba/helperdecl.hxx @@ -19,6 +19,9 @@ * *************************************************************/ +#ifndef SC_VBA_HELPERDECL_HXX +#define SC_VBA_HELPERDECL_HXX + #ifndef SC_VBA_HELPERDECL_HXX #define SC_VBA_HELPERDECL_HXX #include <comphelper/servicedecl.hxx> diff --git a/main/sc/source/ui/vba/service.cxx b/main/sc/source/ui/vba/service.cxx index 6d99e29f10..c3e36dcf91 100644 --- a/main/sc/source/ui/vba/service.cxx +++ b/main/sc/source/ui/vba/service.cxx @@ -70,11 +70,7 @@ namespace textframe { extern sdecl::ServiceDecl const serviceDecl; } -namespace scripting -{ -extern sdecl::ServiceDecl const serviceDecl; -} - + extern "C" { SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( @@ -90,9 +86,9 @@ extern "C" { OSL_TRACE("In component_getFactory for %s", pImplName ); void* pRet = component_getFactoryHelper( - pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ); + pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ); if( !pRet ) - pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl, scripting::serviceDecl ); + pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl ); OSL_TRACE("Ret is 0x%x", pRet); return pRet; } diff --git a/main/sc/source/ui/vba/vbaapplication.cxx b/main/sc/source/ui/vba/vbaapplication.cxx index 425d0ae8a0..e7ec55f99a 100644 --- a/main/sc/source/ui/vba/vbaapplication.cxx +++ b/main/sc/source/ui/vba/vbaapplication.cxx @@ -31,10 +31,6 @@ #include <com/sun/star/sheet/XCellRangeReferrer.hpp> #include <com/sun/star/sheet/XCalculatable.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/script/provider/XScript.hpp> -#include <com/sun/star/script/provider/XScriptProvider.hpp> -#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp> #include <com/sun/star/task/XStatusIndicatorSupplier.hpp> #include <com/sun/star/task/XStatusIndicator.hpp> #include <ooo/vba/excel/XlMousePointer.hpp> @@ -221,13 +217,10 @@ ScVbaApplication::getValue( const ::rtl::OUString& PropertyName ) } // MS Excel VBA: Returns true if the specified method exists on the Application. -// Status: implemented - checks for "Run" first, then delegates to ScVbaWSFunction +// Status: implemented - delegates to ScVbaWSFunction sal_Bool SAL_CALL ScVbaApplication::hasMethod( const ::rtl::OUString& Name ) { - // Application.Run is implemented as a typed method on XApplication - if( Name.equalsIgnoreAsciiCaseAscii( "Run" ) ) - return sal_True; uno::Reference< script::XInvocation > xWSF( new ScVbaWSFunction( this, mxContext ) ); return xWSF->hasMethod( Name ); } @@ -1483,64 +1476,15 @@ ScVbaApplication::Undo() ::svl::IUndoManager* pUndoManager = pViewShell->GetViewData()->GetDocShell()->GetUndoManager(); if ( pUndoManager && pUndoManager->GetUndoActionCount() > 0 ) pUndoManager->Undo(); - } - catch( const uno::Exception& ) - { - DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() ); - } -} - -// MS Excel VBA: Runs a macro by name, optionally with arguments. -// Status: implemented - uses XScriptProvider to invoke the named macro -uno::Any SAL_CALL -ScVbaApplication::Run( const rtl::OUString& rMacroName, const uno::Any& Arg1, const uno::Any& Arg2, const uno::Any& Arg3, const uno::Any& Arg4, const uno::Any& Arg5 ) -{ - uno::Any aResult; - try - { - // Get the script provider from the document model - uno::Reference< frame::XModel > xModel( getCurrentDocument() ); - if( !xModel.is() ) - throw script::BasicErrorException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), 1000, ::rtl::OUString() ); - - uno::Reference< script::provider::XScriptProviderSupplier > xSPSupplier( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< script::provider::XScriptProvider > xScriptProvider = xSPSupplier->getScriptProvider(); - if( !xScriptProvider.is() ) - throw script::BasicErrorException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), 1000, ::rtl::OUString() ); - - // Build the script URI - rtl::OUString sScriptURI = rtl::OUString::createFromAscii("vnd.sun.star.script:Standard.") + rMacroName + - rtl::OUString::createFromAscii("?language=Basic&location=document"); - - // Get the script - uno::Reference< script::provider::XScript > xScript = xScriptProvider->getScript( sScriptURI ); - if( !xScript.is() ) - throw script::BasicErrorException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), 1000, ::rtl::OUString() ); - - // Build arguments array (filter out empty/void arguments) - std::vector<uno::Any> args; - if( Arg1.hasValue() ) args.push_back(Arg1); - if( Arg2.hasValue() ) args.push_back(Arg2); - if( Arg3.hasValue() ) args.push_back(Arg3); - if( Arg4.hasValue() ) args.push_back(Arg4); - if( Arg5.hasValue() ) args.push_back(Arg5); - - uno::Sequence<uno::Any> scriptArgs( args.size() ); - for( size_t i = 0; i < args.size(); ++i ) - scriptArgs[i] = args[i]; - - // Invoke the script - uno::Sequence<sal_Int16> outParamIndex; - uno::Sequence<uno::Any> outParams; - aResult = xScript->invoke( scriptArgs, outParamIndex, outParams ); } catch( const uno::Exception& ) { - aResult <<= script::BasicErrorException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), 1000, ::rtl::OUString() ); + DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() ); } - return aResult; } +// MS Excel VBA: Converts inches to points (1 inch = 72 points). +// Status: implemented - simple multiplication (nInches * 72.0) double SAL_CALL ScVbaApplication::InchesToPoints( double nInches ) { diff --git a/main/sc/source/ui/vba/vbaapplication.hxx b/main/sc/source/ui/vba/vbaapplication.hxx index 816e99817e..1f1ca3bc18 100644 --- a/main/sc/source/ui/vba/vbaapplication.hxx +++ b/main/sc/source/ui/vba/vbaapplication.hxx @@ -256,9 +256,6 @@ public: // MS Excel VBA: Undoes the last user action. // Status: stubbed - no-op virtual void SAL_CALL Undo(); - // MS Excel VBA: Runs a macro by name, optionally with arguments. - // Status: implemented - uses XScriptProvider to invoke the named macro - virtual css::uno::Any SAL_CALL Run( const rtl::OUString& rMacroName, const css::uno::Any& Arg1, const css::uno::Any& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5 ); // MS Excel VBA: Converts inches to points (1 inch = 72 points). // Status: implemented - simple multiplication virtual double SAL_CALL InchesToPoints( double nInches ); diff --git a/main/sc/source/ui/vba/vbafiledialog.hxx b/main/sc/source/ui/vba/vbafiledialog.hxx index e727dad17d..7885540839 100644 --- a/main/sc/source/ui/vba/vbafiledialog.hxx +++ b/main/sc/source/ui/vba/vbafiledialog.hxx @@ -85,6 +85,7 @@ private: rtl::OUString m_sTitle; sal_Bool m_bAllowMultiSelect; css::uno::Sequence< rtl::OUString > m_sSelectedItems; + css::uno::Reference< css::frame::XModel > m_xModel; VbaFileDialogSelectedItems *m_pSelectedItems; VbaFileDialogSelectedObj m_FileDialogSelectedObj; }; diff --git a/main/sc/source/ui/vba/vbafiledialogselecteditems.hxx b/main/sc/source/ui/vba/vbafiledialogselecteditems.hxx index f18bdf64e3..913bab85d5 100644 --- a/main/sc/source/ui/vba/vbafiledialogselecteditems.hxx +++ b/main/sc/source/ui/vba/vbafiledialogselecteditems.hxx @@ -78,4 +78,4 @@ private: sal_Int32 m_nIndex; }; -#endif +#endif \ No newline at end of file diff --git a/main/sc/source/ui/vba/vbafilesearch.hxx b/main/sc/source/ui/vba/vbafilesearch.hxx index 86aba3d916..acef81fa93 100644 --- a/main/sc/source/ui/vba/vbafilesearch.hxx +++ b/main/sc/source/ui/vba/vbafilesearch.hxx @@ -97,4 +97,4 @@ public: virtual css::uno::Sequence< rtl::OUString > getServiceNames(); }; -#endif +#endif \ No newline at end of file diff --git a/main/sc/source/ui/vba/vbafoundfiles.hxx b/main/sc/source/ui/vba/vbafoundfiles.hxx index b3495dd473..51bbcbe50b 100644 --- a/main/sc/source/ui/vba/vbafoundfiles.hxx +++ b/main/sc/source/ui/vba/vbafoundfiles.hxx @@ -103,4 +103,4 @@ public: virtual css::uno::Sequence< rtl::OUString > getServiceNames(); }; -#endif +#endif \ No newline at end of file diff --git a/main/sc/source/ui/vba/vbaquerytable.hxx b/main/sc/source/ui/vba/vbaquerytable.hxx index 51e54a4bcf..8a7c4756e2 100644 --- a/main/sc/source/ui/vba/vbaquerytable.hxx +++ b/main/sc/source/ui/vba/vbaquerytable.hxx @@ -77,4 +77,4 @@ public: virtual css::uno::Sequence< rtl::OUString > getServiceNames(); }; -#endif +#endif \ No newline at end of file diff --git a/main/sc/source/ui/vba/vbarange.cxx b/main/sc/source/ui/vba/vbarange.cxx index 1cfcca298e..14ec09729b 100644 --- a/main/sc/source/ui/vba/vbarange.cxx +++ b/main/sc/source/ui/vba/vbarange.cxx @@ -948,77 +948,7 @@ void CellValueGetter::visitNode( sal_Int32 x, sal_Int32 y, const uno::Reference< processValue( x,y,aValue ); } -// MS Excel VBA: Internal helper class for getting cell values without date coercion (Value2). -// Status: internal helper -class CellValueGetter2 : public ValueGetter -{ -protected: - uno::Any maValue; -public: - CellValueGetter2() {} - virtual void visitNode( sal_Int32 x, sal_Int32 y, const css::uno::Reference< table::XCell >& xCell ); - virtual void processValue( sal_Int32 x, sal_Int32 y, const css::uno::Any& aValue ); - const uno::Any& getValue() const { return maValue; } - -}; - -void -CellValueGetter2::processValue( sal_Int32 /*x*/, sal_Int32 /*y*/, const css::uno::Any& aValue ) -{ - maValue = aValue; -} - -void CellValueGetter2::visitNode( sal_Int32 x, sal_Int32 y, const css::uno::Reference< table::XCell >& xCell ) -{ - uno::Any aValue; - table::CellContentType eType = xCell->getType(); - if( eType == table::CellContentType_VALUE || eType == table::CellContentType_FORMULA ) - { - if ( eType == table::CellContentType_FORMULA ) - { - - rtl::OUString sFormula = xCell->getFormula(); - if ( sFormula.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("=TRUE()") ) ) ) - aValue <<= sal_True; - else if ( sFormula.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("=FALSE()") ) ) ) - aValue <<= sal_False; - else - { - uno::Reference< beans::XPropertySet > xProp( xCell, uno::UNO_QUERY_THROW ); - - table::CellContentType eFormulaType = table::CellContentType_VALUE; - xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FormulaResultType" ) ) ) >>= eFormulaType; - - if ( eFormulaType == table::CellContentType_TEXT ) - { - uno::Reference< text::XTextRange > xTextRange(xCell, ::uno::UNO_QUERY_THROW); - aValue <<= xTextRange->getString(); - } - else - { - aValue <<= xCell->getValue(); - } - } - } - else - { - uno::Reference< table::XCellRange > xRange( xCell, uno::UNO_QUERY_THROW ); - NumFormatHelper cellFormat( xRange ); - if ( cellFormat.isBooleanType() ) - aValue = uno::makeAny( ( xCell->getValue() != 0.0 ) ); - else - { - aValue <<= xCell->getValue(); - } - } - } - if( eType == table::CellContentType_TEXT ) - { - uno::Reference< text::XTextRange > xTextRange(xCell, ::uno::UNO_QUERY_THROW); - aValue <<= xTextRange->getString(); - } - processValue( x,y,aValue ); -} +// MS Excel VBA: Internal helper class for setting formula values. // Status: internal helper class CellFormulaValueSetter : public CellValueSetter { @@ -1736,23 +1666,6 @@ ScVbaRange::getValue() } -// MS Excel VBA: Gets the value of the range without date coercion (Value2 property). -// Value2 differs from Value in that date values are returned as raw doubles -// rather than as oleautomation::Date objects, and error values are not wrapped. -// Status: implemented -uno::Any SAL_CALL -ScVbaRange::getValue2() -{ - if ( m_Areas->getCount() > 1 ) - { - uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW ); - return xRange->getValue(); - } - - CellValueGetter2 valueGetter; - return getValue( valueGetter ); -} - void // MS Excel VBA: Internal helper - sets values using a ValueSetter. @@ -1814,23 +1727,6 @@ ScVbaRange::setValue( const uno::Any &aValue ) lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); } -// MS Excel VBA: Sets the value of the range without date coercion (Value2 property). -// Status: implemented -void SAL_CALL -ScVbaRange::setValue2( const uno::Any& aValue ) -{ - if ( m_Areas->getCount() > 1 ) - { - AreasVisitor aVisitor( m_Areas ); - RangeValueProcessor valueProcessor( aValue ); - aVisitor.visit( valueProcessor ); - return; - } - CellValueSetter valueSetter( aValue ); - setValue( aValue, valueSetter, true ); - lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); -} - // MS Excel VBA: Clears the entire range. // Status: implemented void SAL_CALL @@ -1976,22 +1872,6 @@ ScVbaRange::getFormula() return getFormulaValue( formula::FormulaGrammar::GRAM_NATIVE_XL_A1 ); } -uno::Any -// MS Excel VBA: Gets the formula using Formula2 syntax (array-enabled). -// Status: implemented - delegates to getFormulaValue with GRAM_NATIVE_XL_A1 -ScVbaRange::getFormula2() -{ - return getFormulaValue( formula::FormulaGrammar::GRAM_NATIVE_XL_A1 ); -} - -void -// MS Excel VBA: Sets the formula using Formula2 syntax (array-enabled). -// Status: implemented - delegates to setFormulaValue with GRAM_NATIVE_XL_A1 -ScVbaRange::setFormula2( const css::uno::Any& rFormula ) -{ - setFormulaValue( rFormula, formula::FormulaGrammar::GRAM_NATIVE_XL_A1, true ); -} - sal_Int32 // MS Excel VBA: Gets the number of cells in the range. // Status: implemented diff --git a/main/sc/source/ui/vba/vbarange.hxx b/main/sc/source/ui/vba/vbarange.hxx index d4160d50a4..72d3997222 100644 --- a/main/sc/source/ui/vba/vbarange.hxx +++ b/main/sc/source/ui/vba/vbarange.hxx @@ -245,25 +245,15 @@ public: // MS Excel VBA: Gets the value of the range as a Variant. // Status: implemented virtual css::uno::Any SAL_CALL getValue(); +// MS Excel VBA: Sets the value of the range. +// Status: implemented virtual void SAL_CALL setValue( const css::uno::Any& aValue ); - // MS Excel VBA: Gets the value of the range without date coercion. - // Status: implemented - virtual css::uno::Any SAL_CALL getValue2(); - // MS Excel VBA: Sets the value of the range without date coercion. - // Status: implemented - virtual void SAL_CALL setValue2( const css::uno::Any& aValue ); - // MS Excel VBA: Gets the formula of the range. +// MS Excel VBA: Gets the formula of the range. // Status: implemented virtual css::uno::Any SAL_CALL getFormula(); - // MS Excel VBA: Sets the formula of the range. +// MS Excel VBA: Sets the formula of the range. // Status: implemented virtual void SAL_CALL setFormula( const css::uno::Any& rFormula ); -// MS Excel VBA: Gets the formula using Formula2 syntax (array-enabled). -// Status: implemented - virtual css::uno::Any SAL_CALL getFormula2(); -// MS Excel VBA: Sets the formula using Formula2 syntax (array-enabled). -// Status: implemented - virtual void SAL_CALL setFormula2( const css::uno::Any& rFormula ); // MS Excel VBA: Gets the formula as an array. // Status: implemented virtual css::uno::Any SAL_CALL getFormulaArray();
