[Libreoffice-commits] .: 3 commits - sc/qa toolkit/source

Noel Power noelp at kemper.freedesktop.org
Mon Oct 24 07:08:24 PDT 2011


 sc/qa/unit/data/xls/TestAddress.xls       |binary
 sc/qa/unit/data/xls/vba.xls               |binary
 sc/qa/unit/macros-test.cxx                |   73 +++++++++++++++++++-----------
 toolkit/source/controls/dialogcontrol.cxx |    3 -
 4 files changed, 49 insertions(+), 27 deletions(-)

New commits:
commit 1b2b2283000850dedb00659ce49a0c5eee4aeebb
Author: Noel Power <noel.power at novell.com>
Date:   Mon Oct 24 15:05:39 2011 +0100

    fix wae "aRect uninitialized when used within its own initialization"

diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index f463bfa..35eff0e 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -1033,7 +1033,8 @@ void UnoFrameControl::ImplSetPosSize( Reference< XControl >& rxCtrl )
             if ( !bOwnCtrl && sTitle.getLength() )
             {
                 // Adjust Y based on height of Title
-                ::Rectangle aRect = pOutDev->GetTextRect( aRect, sTitle );
+                ::Rectangle aRect;
+                aRect = pOutDev->GetTextRect( aRect, sTitle );
                 nY = nY + ( aRect.GetHeight() / 2 );
             }
         }
commit 82fb60bc563b444679617396cb4d22a740427e6d
Author: Noel Power <noel.power at novell.com>
Date:   Mon Oct 24 14:26:33 2011 +0100

    make vba.xls return 'OK' on success, adjust macros-test.cxx to test for 'OK'

diff --git a/sc/qa/unit/data/xls/vba.xls b/sc/qa/unit/data/xls/vba.xls
index 2ee53a5..399b1ec 100644
Binary files a/sc/qa/unit/data/xls/vba.xls and b/sc/qa/unit/data/xls/vba.xls differ
diff --git a/sc/qa/unit/macros-test.cxx b/sc/qa/unit/macros-test.cxx
index e3c9974..3737869 100644
--- a/sc/qa/unit/macros-test.cxx
+++ b/sc/qa/unit/macros-test.cxx
@@ -165,7 +165,7 @@ public:
     CPPUNIT_TEST(testStarBasic);
     //enable if you want to hack vba support for unit tests
     //does not work, still problems during loading
-    //CPPUNIT_TEST(testVba);
+    CPPUNIT_TEST(testVba);
 
 
     CPPUNIT_TEST_SUITE_END();
@@ -262,37 +262,58 @@ void ScMacrosTest::testStarBasic()
     xDocSh->DoClose();
 }
 
+struct TestMacroInfo
+{
+    rtl::OUString sFileBaseName;
+    rtl::OUString sMacroUrl;
+};
 void ScMacrosTest::testVba()
 {
-    const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("vba."));
+    TestMacroInfo testInfo[] { 
+        { 
+            rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TestAddress.")),
+            rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.Star.script:VBAProject.Sheet1.test?language=Basic&location=document"))
+        },
+/*
+        vba.xls is still throwing up a basic error :-/
+        {
+            rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vba.")),
+            rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.Star.script:VBAProject.Modul1.Modul1?language=Basic&location=document")),
+        }
+*/
+    };
+       
     rtl::OUString aFileExtension(aFileFormats[1].pName, strlen(aFileFormats[1].pName), RTL_TEXTENCODING_UTF8 );
     rtl::OUString aFilterName(aFileFormats[1].pFilterName, strlen(aFileFormats[1].pFilterName), RTL_TEXTENCODING_UTF8) ;
-    rtl::OUString aFileName;
-    createFileURL(aFileNameBase, aFileExtension, aFileName);
     rtl::OUString aFilterType(aFileFormats[1].pTypeName, strlen(aFileFormats[1].pTypeName), RTL_TEXTENCODING_UTF8);
     std::cout << aFileFormats[1].pName << " Test" << std::endl;
-    ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[1].nFormatType);
-
-    CPPUNIT_ASSERT_MESSAGE("Failed to load vba.xls", xDocSh.Is());
-
-    //is it really the right way to call a vba macro through CallXScript?
-    //it seems that the basic ide does it differently, but then we would need to init all parts ourself
-    //the problem is that CallXScript inits the basic part
-    ////BasicIDE::RunMethod takes an SbMethod as parametre
-    rtl::OUString aURL(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.Star.script:VBAProject.Modul1.Modul1?language=Basic&location=document"));
-    String sUrl = aURL;
-    Any aRet;
-    Sequence< sal_Int16 > aOutParamIndex;
-    Sequence< Any > aOutParam;
-    Sequence< uno::Any > aParams;
-    ScDocument* pDoc = xDocSh->GetDocument();
-
-    xDocSh->CallXScript(sUrl, aParams, aRet, aOutParamIndex,aOutParam);
-    double aValue;
-    pDoc->GetValue(0,0,0,aValue);
-    std::cout << aValue << std::endl;
-    CPPUNIT_ASSERT_MESSAGE("script did not change the value of Sheet1.A1",aValue==2);
-    xDocSh->DoClose();
+    for ( sal_uInt32  i=0; i<SAL_N_ELEMENTS( testInfo ); ++i )
+    {
+        rtl::OUString aFileName;
+        createFileURL(testInfo[i].sFileBaseName, aFileExtension, aFileName);
+        ScDocShellRef xDocSh = load (aFilterName, aFileName, rtl::OUString(), aFilterType, aFileFormats[1].nFormatType);
+        rtl::OUString sMsg( RTL_CONSTASCII_USTRINGPARAM("Failed to load ") );
+        sMsg.concat( aFileName );
+        CPPUNIT_ASSERT_MESSAGE( rtl::OUStringToOString( sMsg, RTL_TEXTENCODING_UTF8 ).getStr(), xDocSh.Is() );
+
+        //is it really the right way to call a vba macro through CallXScript?
+        //it seems that the basic ide does it differently, but then we would need to init all parts ourself
+        //the problem is that CallXScript inits the basic part
+        ////BasicIDE::RunMethod takes an SbMethod as parametre
+        String sUrl = testInfo[i].sMacroUrl;
+        Any aRet;
+        Sequence< sal_Int16 > aOutParamIndex;
+        Sequence< Any > aOutParam;
+        Sequence< uno::Any > aParams;
+        ScDocument* pDoc = xDocSh->GetDocument();
+
+        xDocSh->CallXScript(sUrl, aParams, aRet, aOutParamIndex,aOutParam);
+        rtl::OUString aStringRes;
+        aRet >>= aStringRes;
+        std::cout << "value of Ret " << rtl::OUStringToOString( aStringRes, RTL_TEXTENCODING_UTF8 ).getStr() << std::endl;
+        CPPUNIT_ASSERT_MESSAGE("script reported failure",aStringRes.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OK") )) );
+        xDocSh->DoClose();
+    }
 }
 
 ScMacrosTest::ScMacrosTest()
commit daca9c81e4be825aff0717d599d815a87d71b412
Author: Noel Power <noel.power at novell.com>
Date:   Mon Oct 24 14:26:00 2011 +0100

    more substantial vba test ( testing various range addression )

diff --git a/sc/qa/unit/data/xls/TestAddress.xls b/sc/qa/unit/data/xls/TestAddress.xls
new file mode 100644
index 0000000..7d2ca6e
Binary files /dev/null and b/sc/qa/unit/data/xls/TestAddress.xls differ


More information about the Libreoffice-commits mailing list