summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-06-25 16:36:53 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-06-25 16:40:42 -0400
commit671566d0612a26c844501f0cf042138b5fe5c040 (patch)
tree6bdf556d2494488ba6d1276e4502ecc501557fb0
parent7bd94d73ec56622685d0e23f8b5133ba110524be (diff)
bnc#882595: Write test for this. Disabled due to VBA not working in cppunit.
Change-Id: Ie70232e56235fcf5a313aadffa269ef843bdee18
-rw-r--r--sc/CppunitTest_sc_subsequent_filters_test.mk3
-rw-r--r--sc/inc/tokenstringcontext.hxx2
-rw-r--r--sc/qa/unit/data/xlsm/vba-user-function.xlsmbin0 -> 13111 bytes
-rw-r--r--sc/qa/unit/helper/qahelper.cxx1
-rw-r--r--sc/qa/unit/helper/qahelper.hxx11
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx28
6 files changed, 39 insertions, 6 deletions
diff --git a/sc/CppunitTest_sc_subsequent_filters_test.mk b/sc/CppunitTest_sc_subsequent_filters_test.mk
index b53bb2461b81..a27204749c67 100644
--- a/sc/CppunitTest_sc_subsequent_filters_test.mk
+++ b/sc/CppunitTest_sc_subsequent_filters_test.mk
@@ -35,6 +35,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_subsequent_filters_test, \
sal \
salhelper \
sax \
+ sb \
sc \
scqahelper \
sfx \
@@ -43,12 +44,14 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_subsequent_filters_test, \
svt \
svx \
svxcore \
+ subsequenttest \
test \
tl \
tk \
ucbhelper \
unotest \
utl \
+ vbahelper \
vcl \
xo \
$(gb_UWINAPI) \
diff --git a/sc/inc/tokenstringcontext.hxx b/sc/inc/tokenstringcontext.hxx
index a94844d02959..4ccc40b5c274 100644
--- a/sc/inc/tokenstringcontext.hxx
+++ b/sc/inc/tokenstringcontext.hxx
@@ -46,7 +46,7 @@ struct SC_DLLPUBLIC TokenStringContext
TokenStringContext( const ScDocument* pDoc, formula::FormulaGrammar::Grammar eGram );
};
-class CompileFormulaContext
+class SC_DLLPUBLIC CompileFormulaContext
{
ScDocument* mpDoc;
formula::FormulaGrammar::Grammar meGram;
diff --git a/sc/qa/unit/data/xlsm/vba-user-function.xlsm b/sc/qa/unit/data/xlsm/vba-user-function.xlsm
new file mode 100644
index 000000000000..a43a8eb9f3fc
--- /dev/null
+++ b/sc/qa/unit/data/xlsm/vba-user-function.xlsm
Binary files differ
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index 79d5716c5c1b..0b19843428fe 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -69,6 +69,7 @@ FileFormat aFileFormats[] = {
{ "ods" , "calc8", "", ODS_FORMAT_TYPE },
{ "xls" , "MS Excel 97", "calc_MS_EXCEL_97", XLS_FORMAT_TYPE },
{ "xlsx", "Calc Office Open XML" , "Office Open XML Spreadsheet", XLSX_FORMAT_TYPE },
+ { "xlsm", "Calc Office Open XML" , "Office Open XML Spreadsheet", XLSX_FORMAT_TYPE },
{ "csv" , "Text - txt - csv (StarCalc)", "generic_Text", CSV_FORMAT_TYPE },
{ "html" , "calc_HTML_WebQuery", "generic_HTML", HTML_FORMAT_TYPE },
{ "123" , "Lotus", "calc_Lotus", LOTUS123_FORMAT_TYPE },
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index 193fc489c7f2..a4273bc8a4c4 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -50,11 +50,12 @@
#define ODS 0
#define XLS 1
#define XLSX 2
-#define CSV 3
-#define HTML 4
-#define LOTUS123 5
-#define DIF 6
-#define XLS_XML 7
+#define XLSM 3
+#define CSV 4
+#define HTML 5
+#define LOTUS123 6
+#define DIF 7
+#define XLS_XML 8
enum StringType { PureString, FormulaValue, StringValue };
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" )
{