summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-10-05 21:40:24 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2011-10-05 21:40:24 +0200
commitfef8e18f896b02ebe42407fb9b5341f9884d1ccb (patch)
tree27b0f41321d76fd4c0db332b84d0be7198c030b7 /sc
parentac3f311320d042eebbb31411d804b6e08b43cb4d (diff)
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
Diffstat (limited to 'sc')
-rw-r--r--sc/CppunitTest_sc_filters_test.mk2
-rw-r--r--sc/RdbTarget_sc_filters_test.mk2
-rw-r--r--sc/qa/unit/data/xls/vba.xlsbin0 -> 31232 bytes
-rw-r--r--sc/qa/unit/filters-test.cxx38
4 files changed, 42 insertions, 0 deletions
diff --git a/sc/CppunitTest_sc_filters_test.mk b/sc/CppunitTest_sc_filters_test.mk
index a1646968b6ab..3fc42c202618 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 d6d1bc8e909b..827f66c19395 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 000000000000..2ee53a5609a5
--- /dev/null
+++ b/sc/qa/unit/data/xls/vba.xls
Binary files differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 54bc7a51ceda..6f8c1e2ce844 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"))
{