[Libreoffice-commits] .: 2 commits - sc/CppunitTest_sc_filters_test.mk sc/qa sc/RdbTarget_sc_filters_test.mk

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Wed Oct 5 12:43:10 PDT 2011


 sc/CppunitTest_sc_filters_test.mk |    2 +
 sc/RdbTarget_sc_filters_test.mk   |    2 +
 sc/qa/unit/data/xls/vba.xls       |binary
 sc/qa/unit/filters-test.cxx       |   40 +++++++++++++++++++++++++++++++++++++-
 4 files changed, 43 insertions(+), 1 deletion(-)

New commits:
commit 3086838ebffe99cdcec41b927378cdb5e1b5c0e0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Oct 5 21:42:35 2011 +0200

    enable the star basic test to see if it causes troubles anywhere

diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 6f8c1e2..cc866c4 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -176,7 +176,7 @@ public:
     CPPUNIT_TEST(testBugFixesXLSX);
     //enable this test if you want to play with star basic macros in unit tests
     //works but does nothing useful yet
-    //CPPUNIT_TEST(testStarBasic);
+    CPPUNIT_TEST(testStarBasic);
     //enable if you want to hack vba support for unit tests
     //does not work, still problems during loading
     //CPPUNIT_TEST(testVba);
commit fef8e18f896b02ebe42407fb9b5341f9884d1ccb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Oct 5 21:40:24 2011 +0200

    add initial work for vba tests in calc( work in progress)
    
    this does not work yet, it still does not load the vba code correctly
    and therefore can't find the vba library

diff --git a/sc/CppunitTest_sc_filters_test.mk b/sc/CppunitTest_sc_filters_test.mk
index a164696..3fc42c2 100644
--- a/sc/CppunitTest_sc_filters_test.mk
+++ b/sc/CppunitTest_sc_filters_test.mk
@@ -79,12 +79,14 @@ $(eval $(call gb_CppunitTest_set_include,sc_filters_test,\
 
 $(eval $(call gb_CppunitTest_add_api,sc_filters_test,\
     offapi \
+    oovbaapi \
     udkapi \
 ))
 
 $(eval $(call gb_CppunitTest_uses_ure,sc_filters_test))
 
 $(eval $(call gb_CppunitTest_add_type_rdbs,sc_filters_test,\
+    oovbaapi \
     types \
 ))
 
diff --git a/sc/RdbTarget_sc_filters_test.mk b/sc/RdbTarget_sc_filters_test.mk
index d6d1bc8..827f66c 100644
--- a/sc/RdbTarget_sc_filters_test.mk
+++ b/sc/RdbTarget_sc_filters_test.mk
@@ -46,9 +46,11 @@ $(eval $(call gb_RdbTarget_add_components,sc_filters_test,\
     sax/source/fastparser/fastsax \
     sc/util/sc \
     sc/util/scfilt \
+    sc/util/vbaobj \
     scripting/source/basprov/basprov \
     scripting/util/scriptframe \
     sfx2/util/sfx \
+    sot/util/sot \
     toolkit/util/tk \
     unotools/util/utl \
     unoxml/source/rdf/unordf \
diff --git a/sc/qa/unit/data/xls/vba.xls b/sc/qa/unit/data/xls/vba.xls
new file mode 100644
index 0000000..2ee53a5
Binary files /dev/null and b/sc/qa/unit/data/xls/vba.xls differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 54bc7a5..6f8c1e2 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -162,6 +162,7 @@ public:
     void testBugFixesXLSX();
 
     void testStarBasic();
+    void testVba();
 
     CPPUNIT_TEST_SUITE(ScFiltersTest);
     CPPUNIT_TEST(testCVEs);
@@ -174,7 +175,11 @@ public:
     CPPUNIT_TEST(testBugFixesXLS);
     CPPUNIT_TEST(testBugFixesXLSX);
     //enable this test if you want to play with star basic macros in unit tests
+    //works but does nothing useful yet
     //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_SUITE_END();
@@ -588,6 +593,39 @@ void ScFiltersTest::testStarBasic()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testVba()
+{
+    const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("vba."));
+    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.macro1?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("",aValue==2);
+    xDocSh->DoClose();
+}
+
 ScFiltersTest::ScFiltersTest()
       : m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/unit/data"))
 {


More information about the Libreoffice-commits mailing list