summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2013-03-15 15:47:03 +0000
committerNoel Power <noel.power@suse.com>2013-03-19 12:30:17 +0000
commit7263af3eee67b25a01ef4154e69eba728a2db190 (patch)
treed3a801f3f7597955ecfe8e1476e17251d68d2662
parent7b18b416f2d13f3d7c92ba0c53da0cc236fe7054 (diff)
detect follow-on default member of default member object bnc#809017
Change-Id: I3ccae692db44bb3ce41b371f0b511a9db7181bf4
-rw-r--r--basic/qa/cppunit/test_vba.cxx7
-rw-r--r--basic/qa/vba_tests/ole_dfltObjDflMethod.vb24
-rw-r--r--basic/source/classes/sbunoobj.cxx4
-rw-r--r--basic/source/runtime/step2.cxx26
4 files changed, 57 insertions, 4 deletions
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 703884f70e11..4e01b704abb8 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
@@ -106,7 +106,7 @@ void VBATest::testMiscVBAFunctions()
}
}
-void VBATest::testObjAssignWithDefaultMember()
+void VBATest::testMiscOLEStuff()
{
bool bCanRunOleTests = hasOLEEnv();
if ( !bCanRunOleTests )
@@ -115,6 +115,7 @@ void VBATest::testObjAssignWithDefaultMember()
const char* macroSource[] = {
"ole_ObjAssignNoDflt.vb",
"ole_ObjAssignToNothing.vb",
+ "ole_dfltObjDflMethod.vb",
};
rtl::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 000000000000..f24786098e48
--- /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
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 1a38e04ea103..11a7f87de410 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -323,6 +323,10 @@ SbUnoObject* createOLEObject_Impl( const ::rtl::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 05d1d22d00a7..0edc546ed967 100644
--- a/basic/source/runtime/step2.cxx
+++ b/basic/source/runtime/step2.cxx
@@ -49,7 +49,7 @@ using namespace com::sun::star::script;
using com::sun::star::uno::Reference;
SbxVariable* getVBAConstant( const String& rName );
-
+SbxVariable* getDefaultProp( SbxVariable* pRef );
// the bits in the String-ID:
// 0x8000 - Argv is reserved
@@ -563,6 +563,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;
+ }
+ }
+ }
rtl::OUString sDefaultMethod;
Reference< XDefaultMethod > xDfltMethod( x, UNO_QUERY );