[Libreoffice-commits] core.git: Branch 'distro/suse/suse-3.6' - 2 commits - basic/qa basic/source

Caolán McNamara caolanm at redhat.com
Tue Mar 19 06:13:26 PDT 2013


 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             |   26 +++++++++++++++++++++++++-
 4 files changed, 57 insertions(+), 4 deletions(-)

New commits:
commit d203bd8ec95788e96a5a00719252339a0c147b31
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Mar 15 20:49:11 2013 +0000

    WaE: Werror=shadow
    
    Change-Id: I7f1bddbed85076f1c909d0d9f4ecdd1cda6f1880

diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx
index 0edc546..d5d34fc 100644
--- a/basic/source/runtime/step2.cxx
+++ b/basic/source/runtime/step2.cxx
@@ -573,16 +573,16 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
                             if ( pDflt )
                             {
                                 pDflt->Broadcast( SBX_HINT_DATAWANTED );
-                                SbxBaseRef pObj = (SbxBase*)pDflt->GetObject();
-                                if( pObj )
+                                SbxBaseRef pDfltObj = (SbxBase*)pDflt->GetObject();
+                                if( pDfltObj )
                                 {
-                                    if( pObj->ISA(SbUnoObject) )
+                                    if( pDfltObj->ISA(SbUnoObject) )
                                     {
-                                        pUnoObj = (SbUnoObject*)(SbxBase*)pObj;
-                                        Any aAny = pUnoObj->getUnoAny();
+                                        pUnoObj = (SbUnoObject*)(SbxBase*)pDfltObj;
+                                        Any aUnoAny = pUnoObj->getUnoAny();
 
-                                        if( aAny.getValueType().getTypeClass() == TypeClass_INTERFACE )
-                                            x = *(Reference< XInterface >*)aAny.getValue();
+                                        if( aUnoAny.getValueType().getTypeClass() == TypeClass_INTERFACE )
+                                            x = *(Reference< XInterface >*)aUnoAny.getValue();
                                         pElem = pDflt;
                                     }
                                 }
commit 7263af3eee67b25a01ef4154e69eba728a2db190
Author: Noel Power <noel.power at novell.com>
Date:   Fri Mar 15 15:47:03 2013 +0000

    detect follow-on default member of default member object bnc#809017
    
    Change-Id: I3ccae692db44bb3ce41b371f0b511a9db7181bf4

diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 703884f..4e01b70 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 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
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 1a38e04..11a7f87 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 05d1d22..0edc546 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 );


More information about the Libreoffice-commits mailing list