summaryrefslogtreecommitdiff
path: root/sc/qa/unit/subsequent_filters-test.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/qa/unit/subsequent_filters-test.cxx')
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index d84b89587b1c..cd3296714a93 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -49,6 +49,7 @@
#include "dpshttab.hxx"
#include <scopetools.hxx>
#include <columnspanset.hxx>
+#include <tokenstringcontext.hxx>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/drawing/XControlShape.hpp>
@@ -175,6 +176,7 @@ public:
void testExternalRefCacheODS();
void testHybridSharedStringODS();
void testCopyMergedNumberFormats();
+ void testVBAUserFunctionXLSM();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBasicCellContentODS);
@@ -254,6 +256,7 @@ public:
CPPUNIT_TEST(testExternalRefCacheODS);
CPPUNIT_TEST(testHybridSharedStringODS);
CPPUNIT_TEST(testCopyMergedNumberFormats);
+// CPPUNIT_TEST(testVBAUserFunctionXLSM); // TODO : Macro not working in unit test. Get this to work.
CPPUNIT_TEST_SUITE_END();
private:
@@ -2596,6 +2599,31 @@ void ScFiltersTest::testCopyMergedNumberFormats()
xDocSh->DoClose();
}
+void ScFiltersTest::testVBAUserFunctionXLSM()
+{
+ ScDocShellRef xDocSh = loadDoc("vba-user-function.", XLSM);
+ CPPUNIT_ASSERT(xDocSh.Is());
+ ScDocument& rDoc = xDocSh->GetDocument();
+
+ // A1 contains formula with user-defined function, and the function is defined in VBA.
+ ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(0,0,0));
+ CPPUNIT_ASSERT(pFC);
+
+ sc::CompileFormulaContext aCxt(&rDoc);
+ OUString aFormula = pFC->GetFormula(aCxt);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("=MYFUNC()"), aFormula);
+
+ // Check the formula state after the load.
+ sal_uInt16 nErrCode = pFC->GetErrCode();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(0), nErrCode);
+
+ // Check the result.
+ CPPUNIT_ASSERT_EQUAL(42.0, rDoc.GetValue(ScAddress(0,0,0)));
+
+ xDocSh->DoClose();
+}
+
ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "/sc/qa/unit/data" )
{