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 3fd7a722056f6119fe5a7917046bb09431aec3bf Author: Pedro Giffuni <[email protected]> AuthorDate: Fri Oct 30 10:52:42 2026 -0500 Implement VBA compatibility packages: Match, Run, Formula2, #If/#Const 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 --- main/basic/source/comp/parser.cxx | 252 ++++++++++++++++++++++++++- main/basic/source/comp/token.cxx | 41 +++++ main/basic/source/inc/parser.hxx | 9 + main/basic/source/inc/token.hxx | 2 + main/oovbaapi/ooo/vba/excel/XApplication.idl | 1 + main/oovbaapi/ooo/vba/excel/XRange.idl | 2 + main/sc/source/ui/vba/vbaapplication.cxx | 64 ++++++- main/sc/source/ui/vba/vbaapplication.hxx | 3 + main/sc/source/ui/vba/vbarange.cxx | 122 ++++++++++++- main/sc/source/ui/vba/vbarange.hxx | 18 +- 10 files changed, 504 insertions(+), 10 deletions(-) diff --git a/main/basic/source/comp/parser.cxx b/main/basic/source/comp/parser.cxx index 5dfd4ce475..da47fef8c6 100644 --- a/main/basic/source/comp/parser.cxx +++ b/main/basic/source/comp/parser.cxx @@ -105,6 +105,11 @@ static SbiStatement StmntTable [] = { { WEND, &SbiParser::BadBlock, N, Y, }, // WEND { WITH, &SbiParser::With, N, Y, }, // WITH { WRITE, &SbiParser::Write, N, Y, }, // WRITE +{ PP_IF, &SbiParser::PPIf, N, Y, }, // #IF +{ PP_ELSEIF, &SbiParser::PPIf, N, Y, }, // #ELSEIF +{ PP_ELSE, &SbiParser::NoIf, N, Y, }, // #ELSE +{ PP_ENDIF, &SbiParser::NoIf, N, Y, }, // #ENDIF +{ PP_CONST, &SbiParser::PPConst, Y, Y, }, // #CONST { NIL, NULL, N, N } }; @@ -863,4 +868,249 @@ void SbiParser::ErrorStmnt() aGen.Gen( _ERROR ); } -/* vim: set noet sw=4 ts=4: */ +// MS Excel VBA: #If conditional compilation directive. +// Status: implemented - supports #If, #ElseIf, #Else, #End If +// Supports simple expressions: True, False, identifier references, Not, = +void SbiParser::PPIf() +{ + // Parse condition: evaluate simple constant expressions + bool bCondition = evaluatePPCondition(); + + // Expect "Then" (optional in VBA, but expected in practice) + if( eCurTok == THEN ) + Next(); + + // If condition is true, parse the block until #ElseIf/#Else/#End If + // If false, skip the block + SbiToken eTok = Peek(); + while( !bAbort && !IsEof() && + !( eTok == PP_ELSEIF || eTok == PP_ELSE || eTok == PP_ENDIF ) ) + { + if( bCondition ) + Parse(); + else + skipStatement(); + eTok = Peek(); + } + + if( bCondition ) + { + // We're in the true branch - skip any additional branches + if( eTok == PP_ELSE ) + { + Next(); // consume #Else + skipUntilEndIf(); + } + else if( eTok == PP_ELSEIF ) + { + Next(); // consume #ElseIf + skipUntilEndIf(); + } + else if( eTok == PP_ENDIF ) + { + Next(); // consume #End If + } + } + else + { + // We're in the false branch - check if there's an #Else or #ElseIf + if( eTok == PP_ELSEIF ) + { + Next(); // consume #ElseIf + PPIf(); // recursively handle the elseif branch + return; + } + else if( eTok == PP_ELSE ) + { + Next(); // consume #Else + // Parse the else block + SbiToken eTok2 = Peek(); + while( !bAbort && !IsEof() && !( eTok2 == PP_ENDIF ) ) + { + Parse(); + eTok2 = Peek(); + } + if( eTok2 == PP_ENDIF ) + Next(); // consume #End If + } + else if( eTok == PP_ENDIF ) + { + Next(); // consume #End If + } + } +} + +// Helper: Evaluate a conditional compilation expression. +// Supports: True, False, identifier (looked up in maConstMap), Not expr, expr = expr +bool SbiParser::evaluatePPCondition() +{ + Peek(); + bool bResult = false; + bool bNegate = false; + + // Handle "Not" + if( aSym.EqualsIgnoreCaseAscii( "Not" ) ) + { + bNegate = true; + Next(); + Peek(); + } + + // Get the left operand + if( eCurTok == SYMBOL ) + { + // Check if it's a known constant + String aName = aSym; + Next(); + Peek(); + + // Check for comparison: identifier = value + if( eCurTok == EQ ) + { + Next(); // consume = + Peek(); + // Get the right operand + if( eCurTok == SYMBOL ) + { + String aVal = aSym; + Next(); + bResult = (aName.EqualsIgnoreCaseAscii( aVal )); + } + else if( eCurTok == NUMBER ) + { + bResult = (maConstMap.count( aName ) > 0 && + (maConstMap[ aName ] == (nVal != 0.0))); + } + } + else if( eCurTok == THEN ) + { + // Just a constant: #If DEBUG Then + if( maConstMap.count( aName ) > 0 ) + bResult = maConstMap[ aName ]; + else + bResult = false; // unknown constant defaults to false + } + else + { + // End of expression or other token - use the constant directly + if( maConstMap.count( aName ) > 0 ) + bResult = maConstMap[ aName ]; + } + } + else if( aSym.EqualsIgnoreCaseAscii( "True" ) ) + { + bResult = true; + Next(); + Peek(); + } + else if( aSym.EqualsIgnoreCaseAscii( "False" ) ) + { + bResult = false; + Next(); + Peek(); + } + else if( eCurTok == NUMBER ) + { + bResult = (nVal != 0.0); + Next(); + Peek(); + } + else + { + // Unknown expression - parse and consume it + SbiExpression aExpr( this ); + bResult = true; // unknown, default to true + } + + if( bNegate ) + bResult = !bResult; + + return bResult; +} + +// Helper: Skip statements without generating code +void SbiParser::skipStatement() +{ + // Simple statement skip - consume tokens until EOLN + while( !bAbort && !IsEos() && !IsEof() ) + Next(); + Next(); // consume EOLN +} + +// MS Excel VBA: #Const conditional compilation constant declaration. +// Status: implemented - stores name=value in the conditional compilation map +void SbiParser::PPConst() +{ + // #Const name = value + // Parse: name + Peek(); + if( eCurTok != SYMBOL ) + { + Error( SbERR_SYMBOL_EXPECTED ); + Next(); + TestToken( ASSIGN ); + return; + } + + String aConstName = aSym; + Next(); + TestToken( ASSIGN ); + Next(); + + // Parse the value - expect True, False, or a number + Peek(); + if( aSym.EqualsIgnoreCaseAscii( "True" ) ) + { + maConstMap[ aConstName ] = true; + Next(); + } + else if( aSym.EqualsIgnoreCaseAscii( "False" ) ) + { + maConstMap[ aConstName ] = false; + Next(); + } + else if( eCurTok == NUMBER ) + { + maConstMap[ aConstName ] = (nVal != 0.0); + Next(); + } + else + { + // Unknown constant value - default to false + maConstMap[ aConstName ] = false; + SbiExpression aExpr( this ); // consume the expression + } + + // Expect end of statement + TestEoln(); +} + +// Helper: Skip all statements until matching #End If +void SbiParser::skipUntilEndIf() +{ + sal_uInt16 nNesting = 0; + SbiToken eTok = Peek(); + while( !bAbort && !IsEof() ) + { + if( eTok == PP_IF ) + { + nNesting++; + Next(); + } + else if( eTok == PP_ENDIF ) + { + if( nNesting == 0 ) + { + Next(); + return; + } + nNesting--; + Next(); + } + else + { + skipStatement(); + } + eTok = Peek(); + } +} diff --git a/main/basic/source/comp/token.cxx b/main/basic/source/comp/token.cxx index a37f058104..5c89b4732c 100644 --- a/main/basic/source/comp/token.cxx +++ b/main/basic/source/comp/token.cxx @@ -508,6 +508,47 @@ SbiToken SbiTokenizer::Next() { bEos = sal_True; return eCurTok = EOLN; } + + // MS Excel VBA: Handle #If, #ElseIf, #Else, #End If, #Const preprocessor directives + if( IsHash() && bVBASupportOn && eScanType == SbxVARIANT && bSymbol ) + { + if( aSym.EqualsIgnoreCaseAscii( "If" ) ) + return eCurTok = PP_IF; + else if( aSym.EqualsIgnoreCaseAscii( "ElseIf" ) ) + return eCurTok = PP_ELSEIF; + else if( aSym.EqualsIgnoreCaseAscii( "Else" ) ) + return eCurTok = PP_ELSE; + else if( aSym.EqualsIgnoreCaseAscii( "End" ) ) + { + // #End If - check if next token is "If" + sal_uInt16 nOldLine = nLine; + sal_uInt16 nOldCol = nCol; + sal_uInt16 nOldCol1 = nCol1; + sal_uInt16 nOldCol2 = nCol2; + String aOldSym = aSym; + SaveLine(); + + eCurTok = Peek(); + if( eCurTok == IF ) + { + Next(); + nCol1 = nOldCol1; + bEos = sal_False; + return eCurTok = PP_ENDIF; + } + // Not #End If - restore and return as END + ePush = NIL; + nLine = nOldLine; + nCol = nOldCol; + nCol2 = nOldCol2; + aSym = aOldSym; + RestoreLine(); + return eCurTok = END; + } + else if( aSym.EqualsIgnoreCaseAscii( "Const" ) ) + return eCurTok = PP_CONST; + } + bEos = sal_False; // Zahl? diff --git a/main/basic/source/inc/parser.hxx b/main/basic/source/inc/parser.hxx index c7c1322ea2..40656bc849 100644 --- a/main/basic/source/inc/parser.hxx +++ b/main/basic/source/inc/parser.hxx @@ -30,6 +30,7 @@ #include <vector> +#include <map> typedef ::std::vector< String > StringVector; struct SbiParseStack; @@ -139,6 +140,14 @@ public: void While(); // WHILE/WEND void With(); // WITH void Write(); // WRITE + void PPIf(); // #If (VBA conditional compilation) + void PPConst(); // #Const (VBA conditional compilation) + bool evaluatePPCondition(); // Evaluate #If condition expression + void skipStatement(); // Skip a statement without generating code + void skipUntilEndIf(); // Skip statements until matching #End If + + // Conditional compilation constants map + std::map<String, bool> maConstMap; }; diff --git a/main/basic/source/inc/token.hxx b/main/basic/source/inc/token.hxx index 9d0d60ab0c..f5b887a58d 100644 --- a/main/basic/source/inc/token.hxx +++ b/main/basic/source/inc/token.hxx @@ -109,6 +109,8 @@ enum SbiToken { JS_PLUS, JS_MINUS, JS_MUL, JS_DIV, JS_MOD, JS_LOG_NOT, JS_BIT_NOT, JS_INC, JS_DEC, JS_LPAREN, JS_RPAREN, JS_LINDEX, JS_RINDEX , VBASUPPORT + // Conditional compilation preprocessor directives (VBA compatibility) + , PP_IF, PP_ELSEIF, PP_ELSE, PP_ENDIF, PP_CONST }; #ifdef SbiTokenSHAREDTMPUNDEF diff --git a/main/oovbaapi/ooo/vba/excel/XApplication.idl b/main/oovbaapi/ooo/vba/excel/XApplication.idl index 3b479e8c24..33ce7effd4 100644 --- a/main/oovbaapi/ooo/vba/excel/XApplication.idl +++ b/main/oovbaapi/ooo/vba/excel/XApplication.idl @@ -96,6 +96,7 @@ 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/oovbaapi/ooo/vba/excel/XRange.idl b/main/oovbaapi/ooo/vba/excel/XRange.idl index 261c3b9635..8a2cc2290a 100644 --- a/main/oovbaapi/ooo/vba/excel/XRange.idl +++ b/main/oovbaapi/ooo/vba/excel/XRange.idl @@ -76,7 +76,9 @@ interface XRange //interface ::ooo::vba::XHelperInterface; [attribute] any Value; + [attribute] any Value2; [attribute] any Formula; + [attribute] any Formula2; [attribute] any FormulaArray; [attribute] any FormulaR1C1; [attribute, readonly] long Count; diff --git a/main/sc/source/ui/vba/vbaapplication.cxx b/main/sc/source/ui/vba/vbaapplication.cxx index e7ec55f99a..e646800d36 100644 --- a/main/sc/source/ui/vba/vbaapplication.cxx +++ b/main/sc/source/ui/vba/vbaapplication.cxx @@ -31,6 +31,10 @@ #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/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> @@ -217,10 +221,13 @@ ScVbaApplication::getValue( const ::rtl::OUString& PropertyName ) } // MS Excel VBA: Returns true if the specified method exists on the Application. -// Status: implemented - delegates to ScVbaWSFunction +// Status: implemented - checks for "Run" first, then 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.equalsIgnoreAsciiCase( "Run" ) ) + return sal_True; uno::Reference< script::XInvocation > xWSF( new ScVbaWSFunction( this, mxContext ) ); return xWSF->hasMethod( Name ); } @@ -1476,15 +1483,64 @@ 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::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& ) { - DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() ); + aResult <<= script::BasicErrorException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), 1000, ::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 1f1ca3bc18..816e99817e 100644 --- a/main/sc/source/ui/vba/vbaapplication.hxx +++ b/main/sc/source/ui/vba/vbaapplication.hxx @@ -256,6 +256,9 @@ 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/vbarange.cxx b/main/sc/source/ui/vba/vbarange.cxx index 14ec09729b..25178feeb9 100644 --- a/main/sc/source/ui/vba/vbarange.cxx +++ b/main/sc/source/ui/vba/vbarange.cxx @@ -948,7 +948,77 @@ void CellValueGetter::visitNode( sal_Int32 x, sal_Int32 y, const uno::Reference< processValue( x,y,aValue ); } -// MS Excel VBA: Internal helper class for setting formula values. +// 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 ); +} // Status: internal helper class CellFormulaValueSetter : public CellValueSetter { @@ -1666,6 +1736,23 @@ 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->getValue2(); + } + + CellValueGetter2 valueGetter; + return getValue( valueGetter ); +} + void // MS Excel VBA: Internal helper - sets values using a ValueSetter. @@ -1727,6 +1814,23 @@ 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 @@ -1872,6 +1976,22 @@ 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 72d3997222..d4160d50a4 100644 --- a/main/sc/source/ui/vba/vbarange.hxx +++ b/main/sc/source/ui/vba/vbarange.hxx @@ -245,15 +245,25 @@ 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 formula of the range. + // 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. // 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();
