basic/qa/cppunit/test_vba.cxx | 7 ++++--- basic/qa/vba_tests/ole_dfltObjDflMethod.vb | 24 ++++++++++++++++++++++++ basic/source/classes/sbunoobj.cxx | 4 ++++ basic/source/runtime/step2.cxx | 25 +++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-)
New commits: commit b279360e454a1025af3deeb145cb100c48b554af Author: Noel Power <[email protected]> Date: Fri Mar 15 17:19:53 2013 +0000 unittest and test data for bnc#809017 Change-Id: I3ccae692db44bb3ce41b371f0b511a9db7181bf4 diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx index abb929f..65338a9 100644 --- a/basic/qa/cppunit/test_vba.cxx +++ b/basic/qa/cppunit/test_vba.cxx @@ -22,7 +22,7 @@ namespace VBATest() : BootstrapFixture(true, false) {} ~VBATest(){} void testMiscVBAFunctions(); - void testObjAssignWithDefaultMember(); + void testMiscOLEStuff(); // Adds code needed to register the test suite CPPUNIT_TEST_SUITE(VBATest); @@ -30,7 +30,7 @@ namespace CPPUNIT_TEST(testMiscVBAFunctions); // not much point even trying to run except on windows #if defined(WNT) - CPPUNIT_TEST(testObjAssignWithDefaultMember); + CPPUNIT_TEST(testMiscOLEStuff); #endif // End of test suite definition @@ -105,7 +105,7 @@ void VBATest::testMiscVBAFunctions() } } -void VBATest::testObjAssignWithDefaultMember() +void VBATest::testMiscOLEStuff() { bool bCanRunOleTests = hasOLEEnv(); if ( !bCanRunOleTests ) @@ -114,6 +114,7 @@ void VBATest::testObjAssignWithDefaultMember() const char* macroSource[] = { "ole_ObjAssignNoDflt.vb", "ole_ObjAssignToNothing.vb", + "ole_dfltObjDflMethod.vb", }; OUString sMacroPathURL = getURLFromSrc("/basic/qa/vba_tests/"); diff --git a/basic/qa/vba_tests/ole_dfltObjDflMethod.vb b/basic/qa/vba_tests/ole_dfltObjDflMethod.vb new file mode 100644 index 0000000..f247860 --- /dev/null +++ b/basic/qa/vba_tests/ole_dfltObjDflMethod.vb @@ -0,0 +1,24 @@ +Option VBASupport 1 +Option Explicit + +Rem Test accessing an object that has default object member +Rem which in turn has a default member that is a method +Function doUnitTest(TestData As String) As String +doUnitTest = "Begin" +Dim modifiedTimout As Long +Dim cnn1 As New ADODB.Connection +Dim rst1 As New ADODB.Recordset +Dim conStr As String +cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ +"Data Source=" & TestData & ";" & _ +"Extended Properties=""Excel 8.0;HDR=Yes"";" +rst1.Open "SELECT * FROM [Sheet1$];", cnn1, adOpenStatic, adLockReadOnly +Dim val +val = rst1("FirstName") +If val = "Paddy" Then + doUnitTest = "OK" +Else + doUnitTest = "Failed, expected 'Paddy' got " & val +End If + +End Function commit c90373f98e91dba112bdf76d3bf223528845cdf0 Author: Noel Power <[email protected]> Date: Fri Mar 15 17:11:16 2013 +0000 detect follow-on default member of default member object bnc#809017 Change-Id: I366c049fc342240081957b81d2f28bfcf8d4e331 diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 703b280..b10d00c 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -296,6 +296,10 @@ SbUnoObject* createOLEObject_Impl( const OUString& aType ) Any aAny; aAny <<= xOLEObject; pUnoObj = new SbUnoObject( aType, aAny ); + ::rtl::OUString sDfltPropName; + + if ( SbUnoObject::getDefaultPropName( pUnoObj, sDfltPropName ) ) + pUnoObj->SetDfltProperty( sDfltPropName ); } } return pUnoObj; diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index f6fa096..a66b568 100644 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -43,6 +43,7 @@ using com::sun::star::uno::Reference; SbxVariable* getVBAConstant( const OUString& rName ); +SbxVariable* getDefaultProp( SbxVariable* pRef ); // the bits in the String-ID: // 0x8000 - Argv is reserved @@ -606,6 +607,30 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem ) } else { + // check if there isn't a default member between the current variable + // and the params, e.g. + // Dim rst1 As New ADODB.Recordset + // " + // val = rst1("FirstName") + // has the default 'Fields' member between rst1 and '("FirstName")' + SbxVariable* pDflt = getDefaultProp( pElem ); + if ( pDflt ) + { + pDflt->Broadcast( SBX_HINT_DATAWANTED ); + SbxBaseRef pObj = (SbxBase*)pDflt->GetObject(); + if( pObj ) + { + if( pObj->ISA(SbUnoObject) ) + { + pUnoObj = (SbUnoObject*)(SbxBase*)pObj; + Any aAny = pUnoObj->getUnoAny(); + + if( aAny.getValueType().getTypeClass() == TypeClass_INTERFACE ) + x = *(Reference< XInterface >*)aAny.getValue(); + pElem = pDflt; + } + } + } OUString sDefaultMethod; Reference< XDefaultMethod > xDfltMethod( x, UNO_QUERY ); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
