summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-01-21 12:02:46 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-01-23 19:46:46 +0100
commit95780ec73990f96dc16fc677c895d00fa1360008 (patch)
tree875b727854a9d3c4dd0d2958ba490627ca53b78a /test
parent3fcde5e3f9e0921effd9ffd6c26246647f108ce3 (diff)
refactor concept for c++ based subsequenttests
Diffstat (limited to 'test')
-rw-r--r--test/Library_subsequenttest.mk11
-rw-r--r--test/Package_inc.mk11
-rw-r--r--test/inc/test/container/xnamecontainer.hxx55
-rw-r--r--test/inc/test/sheet/cellproperties.hxx48
-rw-r--r--test/inc/test/sheet/datapilotfield.hxx50
-rw-r--r--test/inc/test/sheet/tableautoformatfield.hxx49
-rw-r--r--test/inc/test/sheet/xcellrangesquery.hxx57
-rw-r--r--test/inc/test/sheet/xdatabaserange.hxx50
-rw-r--r--test/inc/test/sheet/xdatapilotdescriptor.hxx67
-rw-r--r--test/inc/test/sheet/xdatapilotfieldgrouping.hxx48
-rw-r--r--test/inc/test/sheet/xdatapilottable.hxx54
-rw-r--r--test/inc/test/sheet/xnamedrange.hxx56
-rw-r--r--test/inc/test/sheet/xnamedranges.hxx63
-rw-r--r--test/inc/test/sheet/xspreadsheets2.hxx83
-rw-r--r--test/inc/test/unoapi_test.hxx12
-rw-r--r--test/source/container/xnamecontainer.cxx72
-rw-r--r--test/source/sheet/cellproperties.cxx79
-rw-r--r--test/source/sheet/datapilotfield.cxx211
-rw-r--r--test/source/sheet/tableautoformatfield.cxx87
-rw-r--r--test/source/sheet/xcellrangesquery.cxx116
-rw-r--r--test/source/sheet/xdatabaserange.cxx145
-rw-r--r--test/source/sheet/xdatapilotdescriptor.cxx222
-rw-r--r--test/source/sheet/xdatapilotfieldgrouping.cxx62
-rw-r--r--test/source/sheet/xdatapilottable.cxx75
-rw-r--r--test/source/sheet/xnamedrange.cxx152
-rw-r--r--test/source/sheet/xnamedranges.cxx215
-rw-r--r--test/source/sheet/xspreadsheets2.cxx352
-rw-r--r--test/source/unoapi_test.cxx8
28 files changed, 2502 insertions, 8 deletions
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 802b0f71dc98..649fa1e75036 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -67,6 +67,17 @@ $(eval $(call gb_Library_use_external,subsequenttest,cppunit))
$(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/unoapi_test \
+ test/source/container/xnamecontainer \
+ test/source/sheet/cellproperties \
+ test/source/sheet/datapilotfield \
+ test/source/sheet/xcellrangesquery \
+ test/source/sheet/xdatabaserange \
+ test/source/sheet/xdatapilotdescriptor \
+ test/source/sheet/xdatapilotfieldgrouping \
+ test/source/sheet/xdatapilottable \
+ test/source/sheet/xnamedrange \
+ test/source/sheet/xnamedranges \
+ test/source/sheet/xspreadsheets2 \
))
# vim: set noet sw=4 ts=4:
diff --git a/test/Package_inc.mk b/test/Package_inc.mk
index 13b70cf99592..aeb82f1ae73b 100644
--- a/test/Package_inc.mk
+++ b/test/Package_inc.mk
@@ -29,5 +29,16 @@ $(eval $(call gb_Package_Package,test_inc,$(SRCDIR)/test/inc))
$(eval $(call gb_Package_add_file,test_inc,inc/test/bootstrapfixture.hxx,test/bootstrapfixture.hxx))
$(eval $(call gb_Package_add_file,test_inc,inc/test/testdllapi.hxx,test/testdllapi.hxx))
$(eval $(call gb_Package_add_file,test_inc,inc/test/unoapi_test.hxx,test/unoapi_test.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatapilotdescriptor.hxx,test/sheet/xdatapilotdescriptor.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xcellrangesquery.hxx,test/sheet/xcellrangesquery.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xnamedranges.hxx,test/sheet/xnamedranges.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xnamedrange.hxx,test/sheet/xnamedrange.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatabaserange.hxx,test/sheet/xdatabaserange.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/container/xnamecontainer.hxx,test/container/xnamecontainer.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/cellproperties.hxx,test/sheet/cellproperties.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatapilottable.hxx,test/sheet/xdatapilottable.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xdatapilotfieldgrouping.hxx,test/sheet/xdatapilotfieldgrouping.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/datapilotfield.hxx,test/sheet/datapilotfield.hxx))
+$(eval $(call gb_Package_add_file,test_inc,inc/test/sheet/xspreadsheets2.hxx,test/sheet/xspreadsheets2.hxx))
# vim: set noet sw=4 ts=4:
diff --git a/test/inc/test/container/xnamecontainer.hxx b/test/inc/test/container/xnamecontainer.hxx
new file mode 100644
index 000000000000..6f296d7c5905
--- /dev/null
+++ b/test/inc/test/container/xnamecontainer.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <test/testdllapi.hxx>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XNameContainer
+{
+public:
+ // removes default entry
+ XNameContainer();
+ // removes given entry
+ XNameContainer(const rtl::OUString& rName);
+
+ virtual uno::Reference< uno::XInterface > init() = 0;
+
+ void testRemoveByName();
+
+private:
+ rtl::OUString maNameToRemove;
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/sheet/cellproperties.hxx b/test/inc/test/sheet/cellproperties.hxx
new file mode 100644
index 000000000000..f2a3b7150060
--- /dev/null
+++ b/test/inc/test/sheet/cellproperties.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <test/testdllapi.hxx>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST CellProperties
+{
+public:
+ virtual uno::Reference < uno::XInterface > init() = 0;
+
+ void testVertJustify();
+ void testRotateReference();
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/sheet/datapilotfield.hxx b/test/inc/test/sheet/datapilotfield.hxx
new file mode 100644
index 000000000000..c87dfc07537b
--- /dev/null
+++ b/test/inc/test/sheet/datapilotfield.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <test/testdllapi.hxx>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST DataPilotField
+{
+public:
+ virtual uno::Reference< uno::XInterface > init() = 0;
+
+ void testSortInfo();
+ void testLayoutInfo();
+ void testAutoShowInfo();
+ void testReference();
+ void testIsGroupField();
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/sheet/tableautoformatfield.hxx b/test/inc/test/sheet/tableautoformatfield.hxx
new file mode 100644
index 000000000000..ae262f59d34a
--- /dev/null
+++ b/test/inc/test/sheet/tableautoformatfield.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class TableAutoFormatField
+{
+public:
+ //don't use virtual init() here
+ uno::Reference< beans::XPropertySet > initTest();
+
+ virtual uno::Reference< > getServiceFactory() = 0;
+
+ void testRotateReference();
+ void testVertJustify();
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/sheet/xcellrangesquery.hxx b/test/inc/test/sheet/xcellrangesquery.hxx
new file mode 100644
index 000000000000..c315163f5b90
--- /dev/null
+++ b/test/inc/test/sheet/xcellrangesquery.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <test/testdllapi.hxx>
+
+using namespace com::sun::star;
+
+
+namespace apitest {
+
+
+class OOO_DLLPUBLIC_TEST XCellRangesQuery
+{
+public:
+
+ virtual uno::Reference< uno::XInterface > init() = 0;
+
+ //Testcases
+ void testQueryColumnDifference();
+ void testQueryContentDifference();
+ void testQueryEmptyCells();
+ void testQueryFormulaCells();
+ void testQueryIntersection();
+ void testQueryRowDifference();
+ void testQueryVisibleCells();
+
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/sheet/xdatabaserange.hxx b/test/inc/test/sheet/xdatabaserange.hxx
new file mode 100644
index 000000000000..6c5eac04d977
--- /dev/null
+++ b/test/inc/test/sheet/xdatabaserange.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <test/testdllapi.hxx>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XDatabaseRange
+{
+public:
+ virtual uno::Reference< uno::XInterface > init(const rtl::OUString& rDBName) = 0;
+
+ void testDataArea();
+ void testGetSortDescriptor();
+ void testGetSubtotalDescriptor();
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/sheet/xdatapilotdescriptor.hxx b/test/inc/test/sheet/xdatapilotdescriptor.hxx
new file mode 100644
index 000000000000..9eca14ca4c51
--- /dev/null
+++ b/test/inc/test/sheet/xdatapilotdescriptor.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
+
+#include <test/testdllapi.hxx>
+
+#include <vector>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XDataPilotDescriptor
+{
+public:
+ void testSourceRange();
+ void testTag();
+ void testGetFilterDescriptor();
+ void testGetDataPilotFields();
+ void testGetColumnFields();
+ void testGetRowFields();
+ void testGetPageFields();
+ void testGetDataFields();
+ void testGetHiddenFields();
+
+ virtual uno::Reference< uno::XInterface > init() = 0;
+private:
+
+ void testGetDataPilotFields_Impl( uno::Reference< sheet::XDataPilotDescriptor > xDescr );
+
+ void checkName( uno::Reference< container::XIndexAccess > xIndex, sal_Int32 nIndex );
+ static std::vector<rtl::OUString> maFieldNames;
+};
+
+std::vector< rtl::OUString > XDataPilotDescriptor::maFieldNames;
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/sheet/xdatapilotfieldgrouping.hxx b/test/inc/test/sheet/xdatapilotfieldgrouping.hxx
new file mode 100644
index 000000000000..b1e086461693
--- /dev/null
+++ b/test/inc/test/sheet/xdatapilotfieldgrouping.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <test/testdllapi.hxx>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XDataPilotFieldGrouping
+{
+public:
+ void testCreateNameGroup();
+ void testCreateDateGroup();
+
+ virtual uno::Reference< uno::XInterface > init() = 0;
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/sheet/xdatapilottable.hxx b/test/inc/test/sheet/xdatapilottable.hxx
new file mode 100644
index 000000000000..7d67f97e7f7c
--- /dev/null
+++ b/test/inc/test/sheet/xdatapilottable.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/table/XCell.hpp>
+#include <test/testdllapi.hxx>
+
+#include "cppunit/extensions/HelperMacros.h"
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XDataPilotTable
+{
+public:
+ virtual uno::Reference< uno::XInterface > init() = 0;
+
+ void testGetOutputRange();
+ void testRefresh();
+
+protected:
+ uno::Reference< table::XCell > xCellForChange;
+ uno::Reference< table::XCell > xCellForCheck;
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/sheet/xnamedrange.hxx b/test/inc/test/sheet/xnamedrange.hxx
new file mode 100644
index 000000000000..1859237a5c96
--- /dev/null
+++ b/test/inc/test/sheet/xnamedrange.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/sheet/XNamedRange.hpp>
+#include <test/testdllapi.hxx>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XNamedRange
+{
+public:
+ virtual uno::Reference< uno::XInterface > init() = 0;
+
+ // XNamedRange
+ void testGetContent();
+ void testSetContent();
+ void testGetType();
+ void testSetType();
+ void testGetReferencePosition();
+ void testSetReferencePosition();
+protected:
+ virtual uno::Reference< sheet::XNamedRange> getNamedRange(const rtl::OUString&) = 0;
+
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/sheet/xnamedranges.hxx b/test/inc/test/sheet/xnamedranges.hxx
new file mode 100644
index 000000000000..508fec5f2180
--- /dev/null
+++ b/test/inc/test/sheet/xnamedranges.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <test/testdllapi.hxx>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XNamedRanges
+{
+public:
+ // remove default entry
+ XNamedRanges();
+ // removes given entry
+ XNamedRanges(const rtl::OUString& rNameToRemove);
+
+ virtual uno::Reference< uno::XInterface > init(sal_Int32 nSheets = 0) = 0;
+
+ // XNamedRanges
+ void testAddNewByName();
+ void testAddNewFromTitles();
+ void testRemoveByName();
+ void testOutputList();
+
+protected:
+ uno::Reference< sheet::XSpreadsheet > xSheet;
+
+private:
+ rtl::OUString maNameToRemove;
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/sheet/xspreadsheets2.hxx b/test/inc/test/sheet/xspreadsheets2.hxx
new file mode 100644
index 000000000000..cb8f5c2181c2
--- /dev/null
+++ b/test/inc/test/sheet/xspreadsheets2.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "test/testdllapi.hxx"
+
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <rtl/ustring.hxx>
+
+using namespace com::sun::star;
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XSpreadsheets2
+{
+public:
+ XSpreadsheets2();
+
+ // XSpreadsheets2
+ void testImportedSheetNameAndIndex();
+ void testImportString();
+ void testImportValue();
+ void testImportFormulaBasicMath();
+ void testImportFormulaWithNamedRange();
+ void testImportOverExistingNamedRange();
+ void testImportNamedRangeDefinedInSource();
+ void testImportNamedRangeRedefinedInSource();
+ void testImportNewNamedRange();
+ void testImportCellStyle();
+
+ virtual uno::Reference< lang::XComponent > getComponent() = 0;
+ virtual uno::Reference< uno::XInterface > init() = 0;
+ virtual uno::Reference< lang::XComponent > loadFromDesktop(const rtl::OUString&) = 0;
+ virtual void createFileURL(const rtl::OUString&, rtl::OUString&) = 0;
+
+protected:
+ uno::Reference< sheet::XSpreadsheetDocument> xDocument;
+
+private:
+ uno::Reference< sheet::XSpreadsheetDocument> getDoc(const rtl::OUString&, uno::Reference< lang::XComponent >&);
+ uno::Reference< sheet::XNamedRanges> getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument >);
+ void importSheetToCopy();
+ bool isExternalReference(const rtl::OUString& aDestContent, const rtl::OUString& aSrcContent );
+
+ uno::Reference< sheet::XSpreadsheetDocument> xDestDoc;
+ uno::Reference< sheet::XSpreadsheet > xDestSheet;
+ uno::Reference< sheet::XSpreadsheet > xSrcSheet;
+ rtl::OUString aSrcSheetName;
+ rtl::OUString aSrcFileName;
+ rtl::OUString aDestFileBase;
+};
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/inc/test/unoapi_test.hxx b/test/inc/test/unoapi_test.hxx
index 54dcff854b41..b3e341a188d2 100644
--- a/test/inc/test/unoapi_test.hxx
+++ b/test/inc/test/unoapi_test.hxx
@@ -29,17 +29,10 @@
#include <sal/config.h>
#include <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
#include <rtl/ustrbuf.hxx>
#include <osl/file.hxx>
-#define ODS_FORMAT_TYPE 50331943
-#define XLS_FORMAT_TYPE 318767171
-#define XLSX_FORMAT_TYPE 268959811
-
-#define ODS 0
-#define XLS 1
-#define XLSX 2
-
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -55,6 +48,9 @@ public:
virtual void setUp();
virtual void tearDown();
+protected:
+ void closeDocument( uno::Reference< lang::XComponent > xDocument );
+
private:
uno::Reference<uno::XInterface> m_xCalcComponent;
diff --git a/test/source/container/xnamecontainer.cxx b/test/source/container/xnamecontainer.cxx
new file mode 100644
index 000000000000..17f8f0eee2c8
--- /dev/null
+++ b/test/source/container/xnamecontainer.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/container/xnamecontainer.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+
+#include "cppunit/extensions/HelperMacros.h"
+#include <iostream>
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+XNameContainer::XNameContainer(): maNameToRemove(RTL_CONSTASCII_USTRINGPARAM("XNameContainer"))
+{
+}
+
+XNameContainer::XNameContainer(const rtl::OUString& rNameToRemove):
+ maNameToRemove(rNameToRemove)
+{
+}
+
+void XNameContainer::testRemoveByName()
+{
+ uno::Reference< container::XNameContainer > xNameContainer(init(),UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xNameContainer->hasByName(maNameToRemove));
+ xNameContainer->removeByName(maNameToRemove);
+ CPPUNIT_ASSERT(!xNameContainer->hasByName(maNameToRemove));
+
+ bool bExceptionThrown = false;
+ try
+ {
+ xNameContainer->removeByName(maNameToRemove);
+ }
+ catch( const container::NoSuchElementException& )
+ {
+ std::cout << "Exception Caught" << std::endl;
+ bExceptionThrown = true;
+ }
+
+ CPPUNIT_ASSERT_MESSAGE("no exception thrown", bExceptionThrown);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/cellproperties.cxx b/test/source/sheet/cellproperties.cxx
new file mode 100644
index 000000000000..d9d5fc00891b
--- /dev/null
+++ b/test/source/sheet/cellproperties.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/cellproperties.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/table/CellVertJustify.hpp>
+
+#include "cppunit/extensions/HelperMacros.h"
+#include <iostream>
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void CellProperties::testVertJustify()
+{
+ uno::Reference< beans::XPropertySet > xCellRangeBase(init(),UNO_QUERY_THROW);
+ rtl::OUString aVertJustify(RTL_CONSTASCII_USTRINGPARAM("VertJustify"));
+ uno::Any aOldVertJustify = xCellRangeBase->getPropertyValue(aVertJustify);
+ sal_Int32 aValue = 0;
+ CPPUNIT_ASSERT(aOldVertJustify >>= aValue);
+ std::cout << "Old VertJustify value: " << aValue << std::endl;
+
+ uno::Any aNewVertJustify;
+ aNewVertJustify <<= static_cast<sal_Int32>(3);
+ xCellRangeBase->setPropertyValue(aVertJustify, aNewVertJustify);
+ uno::Any aVertJustifyControllValue = xCellRangeBase->getPropertyValue(aVertJustify);
+ CPPUNIT_ASSERT(aVertJustifyControllValue >>= aValue);
+ std::cout << "New VertJustify value: " << aValue << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3);
+}
+
+void CellProperties::testRotateReference()
+{
+ uno::Reference< beans::XPropertySet > xCellRangeBase(init(),UNO_QUERY_THROW);
+ rtl::OUString aRotateReference(RTL_CONSTASCII_USTRINGPARAM("RotateReference"));
+ uno::Any aOldRotateReference = xCellRangeBase->getPropertyValue(aRotateReference);
+ sal_Int32 aValue = 0;
+ CPPUNIT_ASSERT(aOldRotateReference >>= aValue);
+ std::cout << "Old RotateReference Value: " << aValue << std::endl;
+
+ uno::Any aNewRotateReference;
+ aNewRotateReference <<= static_cast<sal_Int32>(3);
+ xCellRangeBase->setPropertyValue(aRotateReference, aNewRotateReference);
+ uno::Any aRotateReferenceControllValue = xCellRangeBase->getPropertyValue(aRotateReference);
+ CPPUNIT_ASSERT(aRotateReferenceControllValue >>= aValue);
+ std::cout << "New RotateReference value: " << aValue << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/datapilotfield.cxx b/test/source/sheet/datapilotfield.cxx
new file mode 100644
index 000000000000..3a323bee9d2a
--- /dev/null
+++ b/test/source/sheet/datapilotfield.cxx
@@ -0,0 +1,211 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/datapilotfieldobj.hxx>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
+#include <com/sun/star/sheet/XDataPilotTables.hpp>
+#include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
+#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
+#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
+#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
+#include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
+#include <com/sun/star/sheet/DataPilotFieldReference.hpp>
+#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
+
+#include <rtl/oustringostreaminserter.hxx>
+#include "cppunit/extensions/HelperMacros.h"
+#include <iostream>
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void DataPilotField::testSortInfo()
+{
+ uno::Reference< beans::XPropertySet> xPropSet(init(),UNO_QUERY_THROW);
+ sheet::DataPilotFieldSortInfo aSortInfoValue;
+ rtl::OUString aSortInfo(RTL_CONSTASCII_USTRINGPARAM("SortInfo"));
+ aSortInfoValue.Field = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Col1"));
+ aSortInfoValue.IsAscending = false;
+ aSortInfoValue.Mode = sheet::DataPilotFieldSortMode::MANUAL;
+ uno::Any xValue;
+ xValue <<= aSortInfoValue;
+ xPropSet->setPropertyValue(aSortInfo, xValue);
+
+ sheet::DataPilotFieldSortInfo aNewSortInfoValue;
+ xValue = xPropSet->getPropertyValue(aSortInfo);
+ CPPUNIT_ASSERT( xValue >>= aNewSortInfoValue );
+ CPPUNIT_ASSERT_MESSAGE("set value should be the same as got value", aNewSortInfoValue.Field == aSortInfoValue.Field
+ && aNewSortInfoValue.Mode == aSortInfoValue.Mode && aNewSortInfoValue.IsAscending == aSortInfoValue.IsAscending);
+
+ //setting HasSortInfo only makes sense for false, for true the uno implementation does nothing
+ sal_Bool bHasSortInfo;
+ rtl::OUString aHasSortInfo(RTL_CONSTASCII_USTRINGPARAM("HasSortInfo"));
+ xValue = xPropSet->getPropertyValue(aHasSortInfo);
+ CPPUNIT_ASSERT( xValue >>= bHasSortInfo );
+ CPPUNIT_ASSERT_MESSAGE("should have sort info", bHasSortInfo);
+
+ bHasSortInfo = false;
+ xValue <<= bHasSortInfo;
+ xPropSet->setPropertyValue(aHasSortInfo, xValue);
+
+ xValue = xPropSet->getPropertyValue(aHasSortInfo);
+ CPPUNIT_ASSERT( xValue >>= bHasSortInfo );
+ CPPUNIT_ASSERT_MESSAGE("should have no sort info", !bHasSortInfo);
+}
+
+void DataPilotField::testLayoutInfo()
+{
+ uno::Reference< beans::XPropertySet > xPropSet(init(),UNO_QUERY_THROW);
+ sheet::DataPilotFieldLayoutInfo aLayoutInfoValue;
+ rtl::OUString aLayoutInfo(RTL_CONSTASCII_USTRINGPARAM("LayoutInfo"));
+ aLayoutInfoValue.AddEmptyLines = false;
+ aLayoutInfoValue.LayoutMode = sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM;
+ uno::Any xValue;
+ xValue <<= aLayoutInfoValue;
+ xPropSet->setPropertyValue(aLayoutInfo, xValue);
+
+ sheet::DataPilotFieldLayoutInfo aNewLayoutInfoValue;
+ xValue = xPropSet->getPropertyValue(aLayoutInfo);
+ CPPUNIT_ASSERT( xValue >>= aNewLayoutInfoValue );
+ CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aNewLayoutInfoValue.LayoutMode == aLayoutInfoValue.LayoutMode &&
+ aNewLayoutInfoValue.AddEmptyLines == aLayoutInfoValue.AddEmptyLines);
+
+ //setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing
+ sal_Bool bHasLayoutInfo;
+ rtl::OUString aHasLayoutInfo(RTL_CONSTASCII_USTRINGPARAM("HasLayoutInfo"));
+ xValue = xPropSet->getPropertyValue(aHasLayoutInfo);
+ CPPUNIT_ASSERT( xValue >>= bHasLayoutInfo );
+ CPPUNIT_ASSERT_MESSAGE("should have layout information", bHasLayoutInfo);
+
+ bHasLayoutInfo = false;
+ xValue <<= bHasLayoutInfo;
+ xPropSet->setPropertyValue(aHasLayoutInfo, xValue);
+
+ xValue = xPropSet->getPropertyValue(aHasLayoutInfo);
+ CPPUNIT_ASSERT( xValue >>= bHasLayoutInfo );
+ CPPUNIT_ASSERT_MESSAGE("should have no longer sort information", !bHasLayoutInfo);
+}
+
+void DataPilotField::testAutoShowInfo()
+{
+ uno::Reference< beans::XPropertySet > xPropSet(init(),UNO_QUERY_THROW);
+ sheet::DataPilotFieldAutoShowInfo aAutoShowInfoValue;
+ aAutoShowInfoValue.DataField = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Col1"));
+ aAutoShowInfoValue.IsEnabled = true;
+ rtl::OUString aAutoShowInfo(RTL_CONSTASCII_USTRINGPARAM("AutoShowInfo"));
+ uno::Any xValue;
+ xValue <<= aAutoShowInfoValue;
+ xPropSet->setPropertyValue(aAutoShowInfo, xValue);
+
+ sheet::DataPilotFieldAutoShowInfo aNewAutoShowInfoValue;
+ xValue = xPropSet->getPropertyValue(aAutoShowInfo);
+ CPPUNIT_ASSERT( xValue >>= aNewAutoShowInfoValue );
+ CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aNewAutoShowInfoValue.DataField == aAutoShowInfoValue.DataField &&
+ aNewAutoShowInfoValue.IsEnabled == aAutoShowInfoValue.IsEnabled);
+
+ //setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing
+ sal_Bool bHasAutoShowInfo;
+ rtl::OUString aHasAutoShowInfo(RTL_CONSTASCII_USTRINGPARAM("HasAutoShowInfo"));
+ xValue = xPropSet->getPropertyValue(aHasAutoShowInfo);
+ CPPUNIT_ASSERT( xValue >>= bHasAutoShowInfo );
+ CPPUNIT_ASSERT_MESSAGE("should have AutoShow information", bHasAutoShowInfo);
+
+ bHasAutoShowInfo = false;
+ xValue <<= bHasAutoShowInfo;
+ xPropSet->setPropertyValue(aHasAutoShowInfo, xValue);
+
+ xValue = xPropSet->getPropertyValue(aHasAutoShowInfo);
+ CPPUNIT_ASSERT( xValue >>= bHasAutoShowInfo );
+ CPPUNIT_ASSERT_MESSAGE("should have no longer AutoShow information", !bHasAutoShowInfo);
+}
+
+void DataPilotField::testReference()
+{
+ uno::Reference< beans::XPropertySet > xPropSet(init(),UNO_QUERY_THROW);
+ sheet::DataPilotFieldReference aReferenceValue;
+ aReferenceValue.ReferenceField = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Col1"));
+ aReferenceValue.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::NAMED;
+ rtl::OUString aReference(RTL_CONSTASCII_USTRINGPARAM("Reference"));
+ uno::Any xValue;
+ xValue <<= aReferenceValue;
+ xPropSet->setPropertyValue(aReference, xValue);
+
+ sheet::DataPilotFieldReference aNewReferenceValue;
+ xValue = xPropSet->getPropertyValue(aReference);
+ CPPUNIT_ASSERT( xValue >>= aNewReferenceValue );
+ CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aReferenceValue.ReferenceField == aNewReferenceValue.ReferenceField
+ && aReferenceValue.ReferenceItemType == aNewReferenceValue.ReferenceItemType);
+
+ //setting HasReference only makes sense for false, tor true the uno implementation does nothing
+ sal_Bool bHasReference;
+ rtl::OUString aHasReference(RTL_CONSTASCII_USTRINGPARAM("HasReference"));
+ xValue = xPropSet->getPropertyValue(aHasReference);
+ CPPUNIT_ASSERT( xValue >>= bHasReference );
+ CPPUNIT_ASSERT_MESSAGE("should have Reference information", bHasReference);
+
+ bHasReference = false;
+ xValue <<= bHasReference;
+ xPropSet->setPropertyValue(aHasReference, xValue);
+
+ xValue = xPropSet->getPropertyValue(aHasReference);
+ CPPUNIT_ASSERT( xValue >>= bHasReference );
+ CPPUNIT_ASSERT_MESSAGE("should have no longer reference information", !bHasReference);
+}
+
+void DataPilotField::testIsGroupField()
+{
+ uno::Reference< beans::XPropertySet > xPropSet(init(),UNO_QUERY_THROW);
+ uno::Any xValue;
+ rtl::OUString aIsGroupField(RTL_CONSTASCII_USTRINGPARAM("IsGroupField"));
+ sal_Bool bIsGroupField;
+
+ xValue = xPropSet->getPropertyValue(aIsGroupField);
+ CPPUNIT_ASSERT( xValue >>= bIsGroupField);
+ //only setting to false is supported
+ if (bIsGroupField)
+ {
+ bIsGroupField = false;
+ xValue <<= bIsGroupField;
+
+ xPropSet->setPropertyValue(aIsGroupField, xValue);
+ xValue = xPropSet->getPropertyValue(aIsGroupField);
+ CPPUNIT_ASSERT(xValue >>= bIsGroupField);
+ CPPUNIT_ASSERT_MESSAGE("setting IsGroupField is supported and should have happened", !bIsGroupField);
+ }
+ else
+ std::cout << "Could not test IsGroupField" << std::endl;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/tableautoformatfield.cxx b/test/source/sheet/tableautoformatfield.cxx
new file mode 100644
index 000000000000..c846b6a22503
--- /dev/null
+++ b/test/source/sheet/tableautoformatfield.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initTestial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/tableautoformatfield.hxx>
+
+#include <iostream>
+#include "cppunit/extensions/HelperMacros.h"
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+uno::Reference< beans::XPropertySet > TableAutoFormatField::initTest()
+{
+ uno::Reference< container::XIndexAccess > xAutoFormatFields( getServiceFactory()->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.TableAutoFormats"))), UNO_QUERY_THROW );
+ CPPUNIT_ASSERT(xAutoFormatFields.is());
+ uno::Reference< container::XIndexAccess > xIndex( xAutoFormatFields->getByIndex(0), UNO_QUERY_THROW );
+ CPPUNIT_ASSERT(xIndex.is());
+ uno::Reference< beans::XPropertySet > xReturn( xIndex->getByIndex(0), UNO_QUERY_THROW );
+ CPPUNIT_ASSERT_MESSAGE("could not create table auto formats", xReturn.is());
+ return xReturn;
+}
+
+void TableAutoFormatField::testRotateReference()
+{
+ uno::Reference< beans::XPropertySet > xTableAutoFormatField = initTest();
+ rtl::OUString aRotateReference(RTL_CONSTASCII_USTRINGPARAM("RotateReference"));
+ uno::Any aOldRotateReference = xTableAutoFormatField->getPropertyValue(aRotateReference);
+ sal_Int32 aValue = 0;
+ CPPUNIT_ASSERT(aOldRotateReference >>= aValue);
+ std::cout << "Old RotateReferene Value: " << aValue << std::endl;
+
+ uno::Any aNewRotateReference;
+ aNewRotateReference <<= static_cast<sal_Int32>(3);
+ xTableAutoFormatField->setPropertyValue(aRotateReference, aNewRotateReference);
+ uno::Any aRotateReferenceControllValue = xTableAutoFormatField->getPropertyValue(aRotateReference);
+ CPPUNIT_ASSERT(aRotateReferenceControllValue >>= aValue);
+ std::cout << "New VertJustify value: " << aValue << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3);
+}
+
+void TableAutoFormatField::testVertJustify()
+{
+ uno::Reference< beans::XPropertySet > xTableAutoFormatField = initTest();
+ rtl::OUString aVertJustify(RTL_CONSTASCII_USTRINGPARAM("VertJustify"));
+ uno::Any aOldVertJustify = xTableAutoFormatField->getPropertyValue(aVertJustify);
+ sal_Int32 aValue = 0;
+ CPPUNIT_ASSERT(aOldVertJustify >>= aValue);
+ std::cout << "Old VertJustify value: " << aValue << std::endl;
+
+ uno::Any aNewVertJustify;
+ aNewVertJustify <<= static_cast<sal_Int32>(3);
+ xTableAutoFormatField->setPropertyValue(aVertJustify, aNewVertJustify);
+ uno::Any aVertJustifyControllValue = xTableAutoFormatField->getPropertyValue(aVertJustify);
+ CPPUNIT_ASSERT(aVertJustifyControllValue >>= aValue);
+ std::cout << "New VertJustify value: " << aValue << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xcellrangesquery.cxx b/test/source/sheet/xcellrangesquery.cxx
new file mode 100644
index 000000000000..b1f55e05d3f4
--- /dev/null
+++ b/test/source/sheet/xcellrangesquery.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/xcellrangesquery.hxx>
+
+#include <com/sun/star/sheet/XCellRangesQuery.hpp>
+#include <com/sun/star/sheet/XSheetCellRanges.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/sheet/CellFlags.hpp>
+
+#include "cppunit/extensions/HelperMacros.h"
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+
+namespace apitest {
+
+void XCellRangesQuery::testQueryColumnDifference()
+{
+ rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.B1:C1,Sheet1.B3:C5"));
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryColumnDifferences(table::CellAddress(0, 1, 1));
+ rtl::OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryColumnDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("testQueryColumnDifference", aResult == aExpected);
+}
+
+void XCellRangesQuery::testQueryContentDifference()
+{
+ rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.B2:B3"));
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::VALUE);
+ rtl::OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryContentDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("testQueryContentDifference", aResult == aExpected);
+}
+
+void XCellRangesQuery::testQueryEmptyCells()
+{
+ rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A1:A5,Sheet1.B1:C1,Sheet1.B5,Sheet1.C3:C5,Sheet1.D1:D5"));
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryEmptyCells();
+ rtl::OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryEmptyCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("testQueryEmptyCells", aResult == aExpected);
+}
+
+void XCellRangesQuery::testQueryFormulaCells()
+{
+ rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.C2"));
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryFormulaCells(sheet::CellFlags::FORMULA);
+ rtl::OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryFormulaCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
+}
+
+void XCellRangesQuery::testQueryIntersection()
+{
+ rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.D4:D5"));
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryIntersection(table::CellRangeAddress(0,3,3,7,7));
+ rtl::OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryIntersection: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
+}
+
+void XCellRangesQuery::testQueryRowDifference()
+{
+ rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A2:A4,Sheet1.C2:D4"));
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryRowDifferences(table::CellAddress(0,1,1));
+ rtl::OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryRowDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
+}
+
+void XCellRangesQuery::testQueryVisibleCells()
+{
+ rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A1:D5"));
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells();
+ rtl::OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryVisibleCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xdatabaserange.cxx b/test/source/sheet/xdatabaserange.cxx
new file mode 100644
index 000000000000..d8cf5e4a1929
--- /dev/null
+++ b/test/source/sheet/xdatabaserange.cxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/xdatabaserange.hxx>
+
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sheet/XDatabaseRange.hpp>
+#include <com/sun/star/sheet/XDatabaseRanges.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <rtl/oustringostreaminserter.hxx>
+#include "cppunit/extensions/HelperMacros.h"
+#include <iostream>
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+/**
+ * tests setDataArea and getDataArea
+ */
+void XDatabaseRange::testDataArea()
+{
+ uno::Reference< sheet::XDatabaseRange > xDBRange(init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataArea"))), UNO_QUERY_THROW);
+
+ table::CellRangeAddress aCellAddress;
+ aCellAddress.Sheet = 0;
+ aCellAddress.StartColumn = 1;
+ aCellAddress.EndColumn = 4;
+ aCellAddress.StartRow = 2;
+ aCellAddress.EndRow = 5;
+ xDBRange->setDataArea(aCellAddress);
+ table::CellRangeAddress aValue;
+ aValue = xDBRange->getDataArea();
+ CPPUNIT_ASSERT( aCellAddress.Sheet == aValue.Sheet );
+ CPPUNIT_ASSERT( aCellAddress.StartRow == aValue.StartRow );
+ CPPUNIT_ASSERT( aCellAddress.EndRow == aValue.EndRow );
+ CPPUNIT_ASSERT( aCellAddress.StartColumn == aValue.StartColumn );
+ CPPUNIT_ASSERT( aCellAddress.EndColumn == aValue.EndColumn );
+}
+
+void XDatabaseRange::testGetSubtotalDescriptor()
+{
+ uno::Reference< sheet::XDatabaseRange > xDBRange(init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SubtotalDescriptor"))), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSubTotalDescriptor> xSubtotalDescr = xDBRange->getSubTotalDescriptor();
+ CPPUNIT_ASSERT(xSubtotalDescr.is());
+}
+
+void XDatabaseRange::testGetSortDescriptor()
+{
+ uno::Reference< sheet::XDatabaseRange > xDBRange(init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SortDescriptor"))), UNO_QUERY_THROW);
+ uno::Sequence< beans::PropertyValue > xSortDescr = xDBRange->getSortDescriptor();
+ for (sal_Int32 i = 0; i < xSortDescr.getLength(); ++i)
+ {
+ beans::PropertyValue xProp = xSortDescr[i];
+ //std::cout << "Prop " << i << " Name: " << rtl::OUString(xProp.Name) << std::endl;
+
+ if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsSortColumns")))
+ {
+ sal_Bool bIsSortColumns;
+ xProp.Value >>= bIsSortColumns;
+ CPPUNIT_ASSERT(bIsSortColumns == false);
+ }
+ else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContainsHeader")))
+ {
+ sal_Bool bContainsHeader;
+ xProp.Value >>= bContainsHeader;
+ CPPUNIT_ASSERT(bContainsHeader == true);
+ }
+ else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxFieldCount")))
+ {
+ sal_Int32 nMaxFieldCount;
+ xProp.Value >>= nMaxFieldCount;
+ std::cout << "Value: " << nMaxFieldCount << std::endl;
+
+ }
+ else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SortFields")))
+ {
+
+ }
+ else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BindFormatsToContent")))
+ {
+ sal_Bool bBindFormatsToContent;
+ xProp.Value >>= bBindFormatsToContent;
+ CPPUNIT_ASSERT(bBindFormatsToContent == true);
+ }
+ else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CopyOutputData")))
+ {
+ sal_Bool bCopyOutputData;
+ xProp.Value >>= bCopyOutputData;
+ CPPUNIT_ASSERT(bCopyOutputData == false);
+ }
+ else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OutputPosition")))
+ {
+
+ }
+ else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsUserListEnabled")))
+ {
+ sal_Bool bIsUserListEnabled;
+ xProp.Value >>= bIsUserListEnabled;
+ CPPUNIT_ASSERT(bIsUserListEnabled == false);
+
+ }
+ else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UserListIndex")))
+ {
+ sal_Int32 nUserListIndex;
+ xProp.Value >>= nUserListIndex;
+ CPPUNIT_ASSERT(nUserListIndex == 0);
+ }
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xdatapilotdescriptor.cxx b/test/source/sheet/xdatapilotdescriptor.cxx
new file mode 100644
index 000000000000..aa39416d0be6
--- /dev/null
+++ b/test/source/sheet/xdatapilotdescriptor.cxx
@@ -0,0 +1,222 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "test/sheet/xdatapilotdescriptor.hxx"
+
+#include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include "cppunit/extensions/HelperMacros.h"
+
+#include <rtl/oustringostreaminserter.hxx>
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XDataPilotDescriptor::testTag()
+{
+ rtl::OUString aTag(RTL_CONSTASCII_USTRINGPARAM("DataPilotDescriptor_Tag"));
+ uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
+ xDescr->setTag(aTag);
+ rtl::OUString aNewTag = xDescr->getTag();
+ CPPUNIT_ASSERT( aTag == aNewTag );
+}
+
+void XDataPilotDescriptor::testSourceRange()
+{
+ uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
+ table::CellRangeAddress aOldAddress = xDescr->getSourceRange();
+
+ table::CellRangeAddress aAddress;
+ aAddress.Sheet = 1;
+ aAddress.StartColumn = 1;
+ aAddress.StartRow = 1;
+ aAddress.EndColumn = 5;
+ aAddress.EndRow = 5;
+ xDescr->setSourceRange(aAddress);
+
+ table::CellRangeAddress aReturn;
+ aReturn = xDescr->getSourceRange();
+
+ CPPUNIT_ASSERT(aAddress.Sheet == aReturn.Sheet);
+ CPPUNIT_ASSERT(aAddress.StartColumn == aReturn.StartColumn);
+ CPPUNIT_ASSERT(aAddress.StartRow == aReturn.StartRow);
+ CPPUNIT_ASSERT(aAddress.EndColumn == aReturn.EndColumn);
+ CPPUNIT_ASSERT(aAddress.EndRow == aReturn.EndRow);
+
+ //restore old settings
+ xDescr->setSourceRange(aOldAddress);
+}
+
+void XDataPilotDescriptor::testGetFilterDescriptor()
+{
+ uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetFilterDescriptor > xSheetFilterDescr = xDescr->getFilterDescriptor();
+ CPPUNIT_ASSERT(xSheetFilterDescr.is());
+}
+
+void XDataPilotDescriptor::testGetDataPilotFields_Impl( uno::Reference< sheet::XDataPilotDescriptor > xDescr)
+{
+ //this method should only be called once but needs to be called before any of the other tests
+ static bool bCalled = false;
+ if (bCalled)
+ return;
+ else
+ bCalled = true;
+
+ uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataPilotFields(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT( xIndex.is());
+
+ sal_Int32 nCount = xIndex->getCount();
+
+ rtl::OUString aOrientation(RTL_CONSTASCII_USTRINGPARAM("Orientation"));
+ for (sal_Int32 i = 0; i < nCount && i < 5; ++i)
+ {
+ uno::Reference< container::XNamed > xNamed( xIndex->getByIndex( i ), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xNamed.is());
+ rtl::OUString aName = xNamed->getName();
+ maFieldNames.push_back(aName);
+ CPPUNIT_ASSERT( !aName.equalsAscii("Data") );
+
+ uno::Reference< beans::XPropertySet > xPropSet( xNamed, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT( xPropSet.is() );
+
+ switch ( i % 5 )
+ {
+ case 0:
+ {
+ uno::Any aAny;
+ aAny<<= sheet::DataPilotFieldOrientation_COLUMN;
+ xPropSet->setPropertyValue(aOrientation, aAny);
+ }
+ break;
+ case 1:
+ {
+ uno::Any aAny;
+ aAny<<= sheet::DataPilotFieldOrientation_ROW;
+ xPropSet->setPropertyValue(aOrientation, aAny);
+ }
+ break;
+ case 2:
+ {
+ uno::Any aAny;
+ aAny<<= sheet::DataPilotFieldOrientation_DATA;
+ xPropSet->setPropertyValue(aOrientation, aAny);
+ }
+ break;
+ case 3:
+ {
+ uno::Any aAny;
+ aAny<<= sheet::DataPilotFieldOrientation_HIDDEN;
+ xPropSet->setPropertyValue(aOrientation, aAny);
+ }
+ break;
+ case 4:
+ {
+ uno::Any aAny;
+ aAny<<= sheet::DataPilotFieldOrientation_PAGE;
+ xPropSet->setPropertyValue(aOrientation, aAny);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+void XDataPilotDescriptor::testGetDataPilotFields()
+{
+ uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
+ testGetDataPilotFields_Impl( xDescr );
+}
+
+void XDataPilotDescriptor::testGetColumnFields()
+{
+ uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(),UNO_QUERY_THROW);
+ testGetDataPilotFields_Impl( xDescr );
+ uno::Reference< container::XIndexAccess > xIndex(xDescr->getColumnFields(), UNO_QUERY_THROW);
+
+ checkName( xIndex, 0 );
+}
+
+void XDataPilotDescriptor::testGetRowFields()
+{
+ uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(),UNO_QUERY_THROW);
+ testGetDataPilotFields_Impl( xDescr );
+ uno::Reference< container::XIndexAccess > xIndex(xDescr->getRowFields(), UNO_QUERY_THROW);
+
+ //checkName( xIndex, 1 );
+}
+
+void XDataPilotDescriptor::testGetPageFields()
+{
+ uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
+ testGetDataPilotFields_Impl( xDescr );
+ uno::Reference< container::XIndexAccess > xIndex(xDescr->getPageFields(), UNO_QUERY_THROW);
+
+ checkName( xIndex, 4 );
+}
+
+void XDataPilotDescriptor::testGetDataFields()
+{
+ uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(),UNO_QUERY_THROW);
+ testGetDataPilotFields_Impl( xDescr );
+ uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataFields(), UNO_QUERY_THROW);
+
+ checkName( xIndex, 2 );
+}
+
+void XDataPilotDescriptor::testGetHiddenFields()
+{
+ std::cout << "testGetHiddenFields" <<std::endl;
+ uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(),UNO_QUERY_THROW);;
+ testGetDataPilotFields_Impl( xDescr );
+ uno::Reference< container::XIndexAccess > xIndex(xDescr->getHiddenFields(), UNO_QUERY_THROW);
+
+ checkName( xIndex, 3 );
+}
+
+void XDataPilotDescriptor::checkName( uno::Reference< container::XIndexAccess > xIndex, sal_Int32 nIndex )
+{
+ CPPUNIT_ASSERT(xIndex.is());
+ CPPUNIT_ASSERT(maFieldNames.size() >= static_cast<size_t>(nIndex));
+
+ for (sal_Int32 i = 0; i < xIndex->getCount(); ++i)
+ {
+ uno::Reference< container::XNamed > xNamed( xIndex->getByIndex(i), UNO_QUERY_THROW);
+ std::cout << "Expected: " << maFieldNames[nIndex] << " Got: " << xNamed->getName() << std::endl;
+ CPPUNIT_ASSERT( xNamed->getName() == maFieldNames[nIndex] );
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xdatapilotfieldgrouping.cxx b/test/source/sheet/xdatapilotfieldgrouping.cxx
new file mode 100644
index 000000000000..942addc2a25c
--- /dev/null
+++ b/test/source/sheet/xdatapilotfieldgrouping.cxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/xdatapilotfieldgrouping.hxx>
+
+#include <com/sun/star/sheet/XDataPilotFieldGrouping.hpp>
+#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
+
+#include "cppunit/extensions/HelperMacros.h"
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XDataPilotFieldGrouping::testCreateNameGroup()
+{
+ uno::Reference< sheet::XDataPilotFieldGrouping > xDataPilotFieldGrouping(init(),UNO_QUERY_THROW);
+ uno::Reference< sheet::XDataPilotField > xDataPilotField( xDataPilotFieldGrouping, UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xNameAccess( xDataPilotField->getItems(), UNO_QUERY_THROW );
+ CPPUNIT_ASSERT(xNameAccess->hasElements());
+
+ uno::Sequence< rtl::OUString > aElements = xNameAccess->getElementNames();
+ xDataPilotFieldGrouping->createNameGroup( aElements );
+}
+
+void XDataPilotFieldGrouping::testCreateDateGroup()
+{
+ uno::Reference< sheet::XDataPilotFieldGrouping > xDataPilotFieldGrouping(init(),UNO_QUERY_THROW);
+ sheet::DataPilotFieldGroupInfo aGroupInfo;
+ aGroupInfo.GroupBy = sheet::DataPilotFieldGroupBy::MONTHS;
+ aGroupInfo.HasDateValues = true;
+ xDataPilotFieldGrouping->createDateGroup(aGroupInfo);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xdatapilottable.cxx b/test/source/sheet/xdatapilottable.cxx
new file mode 100644
index 000000000000..64bc81364dd2
--- /dev/null
+++ b/test/source/sheet/xdatapilottable.cxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/xdatapilottable.hxx>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
+#include <com/sun/star/sheet/XDataPilotTables.hpp>
+#include <com/sun/star/sheet/XDataPilotTable.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <rtl/oustringostreaminserter.hxx>
+
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+
+void XDataPilotTable::testGetOutputRange()
+{
+ uno::Reference< sheet::XDataPilotTable > xDPTable(init(),UNO_QUERY_THROW);
+
+ table::CellRangeAddress aRange = xDPTable->getOutputRange();
+ CPPUNIT_ASSERT( aRange.Sheet == 0 );
+ CPPUNIT_ASSERT( aRange.StartColumn == 7 );
+ CPPUNIT_ASSERT( aRange.StartRow == 8 );
+}
+
+void XDataPilotTable::testRefresh()
+{
+ uno::Reference< sheet::XDataPilotTable > xDPTable(init(),UNO_QUERY_THROW);
+ std::cout << "xCellForChange: Old Value: " << xCellForChange->getValue() << std::endl;
+ std::cout << "xCellForCheck: Old Value: " << xCellForCheck->getValue() << std::endl;
+ double aOldData = xCellForCheck->getValue();
+ xCellForChange->setValue( 5 );
+
+ xDPTable->refresh();
+ xDPTable->refresh();
+ std::cout << "xCellForChange: Old Value: " << xCellForChange->getValue() << std::endl;
+ std::cout << "xCellForCheck: Old Value: " << xCellForCheck->getValue() << std::endl;
+ double aNewData = xCellForCheck->getValue();
+ CPPUNIT_ASSERT_MESSAGE("value needs to change", aOldData != aNewData);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xnamedrange.cxx b/test/source/sheet/xnamedrange.cxx
new file mode 100644
index 000000000000..1c910852e4be
--- /dev/null
+++ b/test/source/sheet/xnamedrange.cxx
@@ -0,0 +1,152 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/xnamedrange.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+#include <com/sun/star/sheet/XNamedRange.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/sheet/Border.hpp>
+#include <com/sun/star/sheet/NamedRangeFlag.hpp>
+
+#include "cppunit/extensions/HelperMacros.h"
+#include <rtl/oustringostreaminserter.hxx>
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XNamedRange::testGetContent()
+{
+ rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+
+ rtl::OUString aExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1"));
+ CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 on GetContent", xNamedRange->getContent().equals(aExpectedContent));
+}
+
+void XNamedRange::testSetContent()
+{
+ rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+
+ rtl::OUString aExpectedContent;
+
+ // test a cell
+ aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D1"));
+ xNamedRange->setContent(aExpectedContent);
+ CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cell", xNamedRange->getContent().equals(aExpectedContent));
+
+ // test a cellrange
+ aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D1:D10"));
+ xNamedRange->setContent(aExpectedContent);
+ CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cellrange", xNamedRange->getContent().equals(aExpectedContent));
+
+ // test a formula
+ aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=D10"));
+ xNamedRange->setContent(aExpectedContent);
+ aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D10"));
+ CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a formula", xNamedRange->getContent().equals(aExpectedContent));
+
+}
+
+void XNamedRange::testGetType()
+{
+ rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+ CPPUNIT_ASSERT_MESSAGE("Wrong expected Type", xNamedRange->getType() == 0);
+}
+
+void XNamedRange::testSetType()
+{
+ rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+
+ sal_Int32 nType = ::sheet::NamedRangeFlag::ROW_HEADER;;
+ xNamedRange->setType(nType);
+ CPPUNIT_ASSERT_MESSAGE("Wrong expected Type ROW_HEADER after setting it", xNamedRange->getType() == nType);
+
+ nType = ::sheet::NamedRangeFlag::COLUMN_HEADER;
+ xNamedRange->setType(nType);
+ CPPUNIT_ASSERT_MESSAGE("Wrong expected Type COLUMN_HEADER after setting it", xNamedRange->getType() == nType);
+
+ nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA;
+ xNamedRange->setType(nType);
+ CPPUNIT_ASSERT_MESSAGE("Wrong expected Type FILTER_CRITERIA after setting it", xNamedRange->getType() == nType);
+
+ nType = ::sheet::NamedRangeFlag::PRINT_AREA;
+ xNamedRange->setType(nType);
+ CPPUNIT_ASSERT_MESSAGE("Wrong expected Type PRINT_AREA after setting it", xNamedRange->getType() == nType);
+
+ nType = 0;
+ xNamedRange->setType(nType);
+ CPPUNIT_ASSERT_MESSAGE("Wrong expected Type 0 after setting it", xNamedRange->getType() == nType);
+}
+
+void XNamedRange::testGetReferencePosition()
+{
+ rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial2"));
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+
+ table::CellAddress xCellAddress = xNamedRange->getReferencePosition();
+ // the expeted address is on B1, as it was the active cell when intial2 created
+ CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position", xCellAddress.Sheet == 0);
+ CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position", xCellAddress.Column == 1);
+ CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position", xCellAddress.Row == 0);
+}
+
+void XNamedRange::testSetReferencePosition()
+{
+ rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
+
+ table::CellAddress aBaseAddress = table::CellAddress(1,2,3);
+
+ xNamedRange->setReferencePosition(aBaseAddress);
+
+ table::CellAddress xCellAddress = xNamedRange->getReferencePosition();
+ CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position after setting it", xCellAddress.Sheet == 1);
+ CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position after setting it", xCellAddress.Column == 2);
+ CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position after setting it", xCellAddress.Row == 3);
+}
+
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xnamedranges.cxx b/test/source/sheet/xnamedranges.cxx
new file mode 100644
index 000000000000..9f5b3aa07a42
--- /dev/null
+++ b/test/source/sheet/xnamedranges.cxx
@@ -0,0 +1,215 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/xnamedranges.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+#include <com/sun/star/sheet/XNamedRange.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/sheet/Border.hpp>
+#include <com/sun/star/sheet/NamedRangeFlag.hpp>
+
+#include <rtl/oustringostreaminserter.hxx>
+#include "cppunit/extensions/HelperMacros.h"
+#include <iostream>
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+XNamedRanges::XNamedRanges():
+ maNameToRemove(RTL_CONSTASCII_USTRINGPARAM("initial1"))
+{
+
+}
+
+XNamedRanges::XNamedRanges(const rtl::OUString& rNameToRemove):
+ maNameToRemove(rNameToRemove)
+{
+
+}
+
+void XNamedRanges::testAddNewByName()
+{
+ uno::Reference< sheet::XNamedRanges > xNamedRanges(init(), UNO_QUERY_THROW);
+ uno::Reference< container::XNameAccess > xNamedRangesNameAccess(init(1), UNO_QUERY_THROW);
+
+ table::CellAddress aBaseAddress = table::CellAddress(0,0,0);
+
+ sal_Int32 nType = 0;
+ rtl::OUString aContent1(RTL_CONSTASCII_USTRINGPARAM("D1"));
+ rtl::OUString aName1(RTL_CONSTASCII_USTRINGPARAM("type_0"));
+ xNamedRanges->addNewByName(aName1, aContent1, aBaseAddress, nType);
+ CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type 0 - Normal case", xNamedRanges->hasByName(aName1));
+
+ nType = ::sheet::NamedRangeFlag::COLUMN_HEADER;
+ rtl::OUString aContent2(RTL_CONSTASCII_USTRINGPARAM("D2"));
+ rtl::OUString aName2(RTL_CONSTASCII_USTRINGPARAM("type_COLUMN_HEADER"));
+ xNamedRanges->addNewByName(aName2, aContent2, aBaseAddress, nType);
+ CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type COLUMN_HEADER", xNamedRanges->hasByName(aName2));
+
+ nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA;
+ rtl::OUString aContent3(RTL_CONSTASCII_USTRINGPARAM("D3"));
+ rtl::OUString aName3(RTL_CONSTASCII_USTRINGPARAM("type_FILTER_CRITERIA"));
+ xNamedRanges->addNewByName(aName3, aContent3, aBaseAddress, nType);
+ CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type FILTER_CRITERIA", xNamedRanges->hasByName(aName3));
+
+ nType = ::sheet::NamedRangeFlag::PRINT_AREA;
+ rtl::OUString aContent4(RTL_CONSTASCII_USTRINGPARAM("D4"));
+ rtl::OUString aName4(RTL_CONSTASCII_USTRINGPARAM("type_PRINT_AREA"));
+ xNamedRanges->addNewByName(aName4, aContent4, aBaseAddress, nType);
+ CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type PRINT_AREA", xNamedRanges->hasByName(aName4));
+
+ nType = ::sheet::NamedRangeFlag::ROW_HEADER;
+ rtl::OUString aContent5(RTL_CONSTASCII_USTRINGPARAM("D5"));
+ rtl::OUString aName5(RTL_CONSTASCII_USTRINGPARAM("type_ROW_HEADER"));
+ xNamedRanges->addNewByName(aName5, aContent5, aBaseAddress, nType);
+ CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type ROW_HEADER", xNamedRanges->hasByName(aName5));
+
+}
+
+void XNamedRanges::testAddNewFromTitles()
+{
+ uno::Reference< sheet::XNamedRanges > xNamedRanges(init(1), UNO_QUERY_THROW);
+ uno::Reference< container::XIndexAccess > xNamedRangesIndex(xNamedRanges, UNO_QUERY_THROW);
+ uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xNamedRanges, UNO_QUERY_THROW);
+
+ table::CellRangeAddress aCellRangeAddress = table::CellRangeAddress(1,0,0,3,3);
+
+ rtl::OUString aString;
+ uno::Reference< table::XCell > xCell;
+
+ xNamedRanges->addNewFromTitles(aCellRangeAddress, sheet::Border_TOP);
+
+ for (sal_Int32 i = 1; i < 4; i++)
+ {
+ // verify namedrange exists
+ xCell = xSheet->getCellByPosition(i,0);
+ uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
+ aString = xTextRange->getString();
+ std::cout << "addNewFromTitles: verify " << aString << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
+
+ // verify it points on the right cell
+ uno::Any aNr = xNamedRangesNameAccess->getByName(aString);
+ uno::Reference< sheet::XNamedRange > xNamedRange(aNr, UNO_QUERY_THROW);
+
+ uno::Reference< sheet::XCellRangeReferrer > xCellRangeRef(xNamedRange, UNO_QUERY_THROW);
+ uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW);
+ table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress();
+
+ CPPUNIT_ASSERT(cellRangeAddress.EndColumn == i && cellRangeAddress.StartColumn == i);
+ CPPUNIT_ASSERT(cellRangeAddress.StartRow == 1);
+ CPPUNIT_ASSERT(cellRangeAddress.EndRow == 3);
+ CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1);
+ }
+
+ xNamedRanges->addNewFromTitles(aCellRangeAddress, sheet::Border_LEFT);
+
+ for (sal_Int32 i = 1; i < 4; i++)
+ {
+ // verify namedrange exists
+ xCell = xSheet->getCellByPosition(0,i);
+ uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
+ aString = xTextRange->getString();
+ std::cout << "verify " << aString << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
+
+ // verify it points on the right cell
+ uno::Any aNr= xNamedRangesNameAccess->getByName(aString);
+ uno::Reference< sheet::XNamedRange > xNamedRange(aNr, UNO_QUERY_THROW);
+
+ uno::Reference< sheet::XCellRangeReferrer > xCellRangeRef(xNamedRange, UNO_QUERY_THROW);
+ uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW);
+ table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress();
+
+ CPPUNIT_ASSERT(cellRangeAddress.EndRow == i && cellRangeAddress.StartRow == i);
+ CPPUNIT_ASSERT(cellRangeAddress.StartColumn == 1);
+ CPPUNIT_ASSERT(cellRangeAddress.EndColumn == 3);
+ CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1);
+ }
+}
+
+void XNamedRanges::testRemoveByName()
+{
+ uno::Reference< sheet::XNamedRanges > xNamedRanges(init(), UNO_QUERY_THROW);
+ uno::Reference< container::XIndexAccess > xIndex(xNamedRanges, UNO_QUERY_THROW);
+
+ bool bHasIt = xNamedRanges->hasByName(maNameToRemove);
+ CPPUNIT_ASSERT_MESSAGE("NamedRange initial1 des not exits, can't remove it", bHasIt);
+
+ if (bHasIt)
+ {
+ // remove existing
+ sal_Int32 nInitialCount = xIndex->getCount();
+ xNamedRanges->removeByName(maNameToRemove);
+ sal_Int32 nNewCount = xIndex->getCount();
+ CPPUNIT_ASSERT_MESSAGE("NamedRange initial1 not removed", nNewCount == nInitialCount - 1);
+ CPPUNIT_ASSERT_MESSAGE("Wrong NamedRange removed, initial1 still present", !xNamedRanges->hasByName(maNameToRemove));
+ // try to remove non existing
+ rtl::OUString aNr2(RTL_CONSTASCII_USTRINGPARAM("dummyNonExistingNamedRange"));
+ xNamedRanges->removeByName(aNr2);// an exception should be raised here
+ }
+}
+
+void XNamedRanges::testOutputList()
+{
+ table::CellAddress xCellAddress = table::CellAddress (0,2,0);
+ uno::Reference< sheet::XNamedRanges > xNamedRanges(init(), UNO_QUERY_THROW);
+ uno::Reference< container::XIndexAccess > xNamedRangesIndex(init(), UNO_QUERY_THROW);
+ sal_Int32 nElementsCount = xNamedRangesIndex->getCount();
+
+ xNamedRanges->outputList(xCellAddress);
+
+ rtl::OUString aString;
+ uno::Reference< table::XCell > xCell;
+
+ for (sal_Int32 i = 0; i < nElementsCount; i++)
+ {
+ xCell = xSheet->getCellByPosition(2,i);
+ uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
+ aString = xTextRange->getString();
+ std::cout << "verify " << aString << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xspreadsheets2.cxx b/test/source/sheet/xspreadsheets2.cxx
new file mode 100644
index 000000000000..263425995a81
--- /dev/null
+++ b/test/source/sheet/xspreadsheets2.cxx
@@ -0,0 +1,352 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/xspreadsheets2.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheets2.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+#include <com/sun/star/sheet/XNamedRange.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/sheet/Border.hpp>
+#include <com/sun/star/sheet/NamedRangeFlag.hpp>
+
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/table/CellVertJustify.hpp>
+
+#include <rtl/oustringostreaminserter.hxx>
+#include "cppunit/extensions/HelperMacros.h"
+
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+XSpreadsheets2::XSpreadsheets2():
+ aSrcSheetName(RTL_CONSTASCII_USTRINGPARAM("SheetToCopy")),
+ aSrcFileName(RTL_CONSTASCII_USTRINGPARAM("rangenamessrc.ods")),
+ aDestFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods"))
+{
+}
+
+void XSpreadsheets2::testImportedSheetNameAndIndex()
+{
+/**
+ Verfiy that the imported sheet has the correct name and is placed at the right requested index
+*/
+
+ importSheetToCopy();
+
+ uno::Reference< container::XNameAccess > xDestSheetNameAccess(xDestDoc->getSheets(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("Wrong sheet name", xDestSheetNameAccess->hasByName(aSrcSheetName));
+
+}
+
+void XSpreadsheets2::testImportString()
+{
+/**
+ tests the cell A1 containing a string correctly imported
+*/
+ importSheetToCopy();
+
+ uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(0,0);
+ uno::Reference< text::XTextRange > xSrcTextRange(xSrcCell, UNO_QUERY_THROW);
+ rtl::OUString aSrcString = xSrcTextRange->getString();
+
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(0,0);
+ uno::Reference< text::XTextRange > xDestTextRange(xDestCell, UNO_QUERY_THROW);
+ rtl::OUString aDestString = xDestTextRange->getString();
+
+ CPPUNIT_ASSERT_MESSAGE("Wrong string imported", aDestString.equals(aSrcString));
+}
+
+void XSpreadsheets2::testImportValue()
+{
+/**
+ tests the cell B1 containing a value correctly imported
+*/
+ importSheetToCopy();
+
+ uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(1,0);
+ sal_Int32 aSrcValue = xSrcCell->getValue();
+
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(1,0);
+ sal_Int32 aDestValue = xDestCell->getValue();
+
+ CPPUNIT_ASSERT_MESSAGE("Wrong value imported", aSrcValue == aDestValue);
+}
+
+void XSpreadsheets2::testImportFormulaBasicMath()
+{
+/**
+ tests the cell C1 containing an arithmetic formula correctly imported
+*/
+ importSheetToCopy();
+
+ uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(2,0);
+ rtl::OUString aSrcFormula = xSrcCell->getFormula();
+
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(2,0);
+ rtl::OUString aDestFormula = xDestCell->getFormula();
+
+ // potential problem later: formulas might be adjusted
+ // add some tests that the formulas are correctly adjusted
+ CPPUNIT_ASSERT_MESSAGE("Wrong formula imported", aDestFormula.equals(aSrcFormula));
+}
+
+void XSpreadsheets2::testImportFormulaWithNamedRange()
+{
+/**
+ tests the cell D1 containing a formula that uses a NamedRange expression
+*/
+ importSheetToCopy();
+
+ uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(3,0);
+ rtl::OUString aSrcFormula = xSrcCell->getFormula();
+
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(3,0);
+ rtl::OUString aDestFormula = xDestCell->getFormula();
+
+ CPPUNIT_ASSERT_MESSAGE("Wrong Namedrange formula imported", aDestFormula.equals(aSrcFormula));
+}
+
+void XSpreadsheets2::testImportOverExistingNamedRange()
+{
+/**
+ Both Source and Target file define the named range initial1
+ in Source, initial1 is defined outside the copied sheet
+ In Target, after import sheet, initial1 should point on its initial definition $Sheet1.$B$1
+
+ NEED MORE WORK
+*/
+ importSheetToCopy();
+
+ rtl::OUString aNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
+
+ uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess(getNamedRanges(xDestDoc), UNO_QUERY_THROW);
+ uno::Any aNr = xDestNamedRangesNameAccess->getByName(aNamedRangeString);
+ uno::Reference< sheet::XNamedRange > xDestNamedRange(aNr, UNO_QUERY_THROW);
+ rtl::OUString aNrDestContent = xDestNamedRange->getContent();
+
+ rtl::OUString aExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1"));
+
+ std::cout << "testImportSheet : initial1 aNrDestContent " << aNrDestContent << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("Wrong address for initial1", aNrDestContent.equals(aExpectedContent));
+
+}
+
+void XSpreadsheets2::testImportNamedRangeDefinedInSource()
+{
+/**
+ in Source file, InSheetRangeName named range is defined in the copied sheet
+ it does not exists in target file
+ test that the range named is created in target and that it points in the target copied sheet
+*/
+ importSheetToCopy();
+
+ // New range name defined in imported sheet $SheetToCopy.$A$7
+ rtl::OUString aNewInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("InSheetRangeName"));
+ uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess(getNamedRanges(xDestDoc), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("InSheetRangeName", xDestNamedRangesNameAccess->hasByName(aNewInSheetNamedRangeString));
+
+ uno::Any aNewInSheetNr = xDestNamedRangesNameAccess->getByName(aNewInSheetNamedRangeString);
+ uno::Reference< sheet::XNamedRange > xDestNewInSheetNamedRange(aNewInSheetNr, UNO_QUERY_THROW);
+ rtl::OUString aNewInSheetNrDestContent = xDestNewInSheetNamedRange->getContent();
+ rtl::OUString aNewInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$SheetToCopy.$A$7"));
+
+ std::cout << "testImportSheet : InSheetRangeName content " << aNewInSheetNrDestContent << std::endl;
+ std::cout << "testImportSheet : InSheetRangeName expected " << aNewInSheetExpectedContent << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("Wrong address for InSheetRangeName", aNewInSheetNrDestContent.equals(aNewInSheetExpectedContent));
+}
+
+void XSpreadsheets2::testImportNamedRangeRedefinedInSource()
+{
+/**
+ in Source file, initial2 named range is defined in the copied sheet
+ it is defined in another sheet of target file
+ test that the range named points in the target copied sheet
+*/
+ importSheetToCopy();
+
+ // the source file redefines an existing named range in the imported sheet --> the target should not be changed
+ rtl::OUString aRedefinedInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial2"));
+ uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess(getNamedRanges(xDestDoc), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("aRedefinedInSheetNamedRangeString", xDestNamedRangesNameAccess->hasByName(aRedefinedInSheetNamedRangeString));
+
+ uno::Any aRedefinedInSheetNr = xDestNamedRangesNameAccess->getByName(aRedefinedInSheetNamedRangeString);
+ uno::Reference< sheet::XNamedRange > xDestRedefinedInSheetNamedRange(aRedefinedInSheetNr, UNO_QUERY_THROW);
+ rtl::OUString aRedefinedInSheetNrDestContent = xDestRedefinedInSheetNamedRange->getContent();
+ rtl::OUString aRedefinedInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$2"));
+ std::cout << "testImportSheet : initial2 content " << aRedefinedInSheetNrDestContent << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("Wrong address for Redefined InSheet named range", aRedefinedInSheetNrDestContent.equals(aRedefinedInSheetExpectedContent));
+}
+
+void XSpreadsheets2::testImportNewNamedRange()
+{
+/**
+ in Soucre file, new_rangename range named is defined outside the copied sheet
+ it does not exists in target file
+ test that new_rangename is created and its content points to source file as an external reference
+*/
+ importSheetToCopy();
+
+ //formula with a non-existant named range in dest - new_rangename
+ rtl::OUString aNewNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("new_rangename"));
+ uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess(getNamedRanges(xDestDoc), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("New NamedRange not created", xDestNamedRangesNameAccess->hasByName(aNewNamedRangeString));
+
+ // verify the content of this new namedrange, pointing on $Sheet1.$B$1 in source. This address is already defined in target as NR content
+
+ uno::Any aNewNr = xDestNamedRangesNameAccess->getByName(aNewNamedRangeString);
+ uno::Reference< sheet::XNamedRange > xDestNewNamedRange(aNewNr, UNO_QUERY_THROW);
+ rtl::OUString aNewNrDestContent = xDestNewNamedRange->getContent();
+
+ rtl::OUString aNewExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1"));
+
+ std::cout << "testImportSheet : new_rangename aNewExpectedContent " << aNewExpectedContent << std::endl;
+ std::cout << "testImportSheet : new_rangename aNewNrDestContent " << aNewNrDestContent << std::endl;
+ CPPUNIT_ASSERT_MESSAGE("Wrong New NamedRange formula string value", isExternalReference(aNewNrDestContent, aNewExpectedContent));
+}
+
+void XSpreadsheets2::testImportCellStyle()
+{
+/**
+ in source file, imported sheet uses a cellstyle that does not exists in target
+ test that
+ - an imported cell D1 uses the right cellStyle
+ - the cellStyle is created in CellStyles family
+ - a property of the cellStyle (VertJustify) is correctly set
+*/
+ importSheetToCopy();
+
+ uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(3,0);
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(3,0);
+
+ //new style created in dest
+ uno::Reference< beans::XPropertySet > xSrcCellPropSet (xSrcCell, UNO_QUERY_THROW);
+ const rtl::OUString aCellProperty(RTL_CONSTASCII_USTRINGPARAM("CellStyle"));
+ rtl::OUString aSrcStyleName;
+ CPPUNIT_ASSERT(xSrcCellPropSet->getPropertyValue(aCellProperty) >>= aSrcStyleName);
+
+ uno::Reference< beans::XPropertySet > xDestCellPropSet (xSrcCell, UNO_QUERY_THROW);
+ rtl::OUString aDestStyleName;
+ CPPUNIT_ASSERT(xDestCellPropSet->getPropertyValue(aCellProperty) >>= aDestStyleName);
+
+ CPPUNIT_ASSERT_MESSAGE("Wrong imported Cell Style", aDestStyleName.equals(aSrcStyleName));
+
+ uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier (xDestDoc, UNO_QUERY_THROW);
+ uno::Reference< container::XNameAccess > xFamiliesNameAccess (xFamiliesSupplier->getStyleFamilies(), UNO_QUERY_THROW);
+ rtl::OUString aCellFamilyName(RTL_CONSTASCII_USTRINGPARAM("CellStyles"));
+ uno::Any xCellStylesFamily = xFamiliesNameAccess->getByName(aCellFamilyName);
+ uno::Reference< container::XNameContainer > xCellStylesFamilyNameAccess (xCellStylesFamily, UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("New cell style not present", xCellStylesFamilyNameAccess->hasByName(aDestStyleName));
+
+ uno::Any aCellStyle = xCellStylesFamilyNameAccess->getByName(aDestStyleName);
+ uno::Reference< beans::XPropertySet > xCellStyleProp (aCellStyle, UNO_QUERY_THROW);
+ rtl::OUString aProperty(RTL_CONSTASCII_USTRINGPARAM("VertJustify"));
+ sal_Int32 aVertJustify = 0;
+ CPPUNIT_ASSERT(xCellStyleProp->getPropertyValue(aProperty) >>= aVertJustify);
+
+ CPPUNIT_ASSERT_MESSAGE("New style: VertJustify not set", aVertJustify == table::CellVertJustify_CENTER);
+}
+
+uno::Reference< sheet::XSpreadsheetDocument> XSpreadsheets2::getDoc(const rtl::OUString& aFileBase, uno::Reference< lang::XComponent >& xComp)
+{
+ rtl::OUString aFileURL;
+ createFileURL(aFileBase, aFileURL);
+
+ if (!xComp.is())
+ xComp = loadFromDesktop(aFileURL);
+
+ CPPUNIT_ASSERT(xComp.is());
+
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComp, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xDoc.is());
+ return xDoc;
+}
+
+uno::Reference< sheet::XNamedRanges> XSpreadsheets2::getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument> xDoc)
+{
+ uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
+ rtl::OUString NamedRangesPropertyString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
+ uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(NamedRangesPropertyString), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xNamedRanges.is());
+
+ return xNamedRanges;
+}
+
+void XSpreadsheets2::importSheetToCopy()
+{
+ uno::Reference< container::XNameAccess> xSrcNameAccess(init(),UNO_QUERY_THROW);
+ xSrcSheet = uno::Reference< sheet::XSpreadsheet >( xSrcNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW);
+
+ static uno::Reference< lang::XComponent > xDestComponent;
+ if (!xDestComponent.is())
+ {
+ xDestDoc = getDoc(aDestFileBase, xDestComponent);
+ CPPUNIT_ASSERT(xDestDoc.is());
+
+ // import sheet
+ uno::Reference< sheet::XSpreadsheets2 > xDestSheets (xDestDoc->getSheets(), UNO_QUERY_THROW);
+ sal_Int32 nDestPos = 0;
+ sal_Int32 nDestPosEffective = xDestSheets->importSheet(xDocument, aSrcSheetName, nDestPos);
+ CPPUNIT_ASSERT_MESSAGE("Wrong sheet index", nDestPosEffective == nDestPos);
+ }
+ else
+ {
+ xDestDoc = uno::Reference< sheet::XSpreadsheetDocument >(xDestComponent,UNO_QUERY_THROW);
+ }
+
+ uno::Reference< container::XNameAccess > xDestSheetNameAccess (xDestDoc->getSheets(), UNO_QUERY_THROW);
+ xDestSheet = uno::Reference< sheet::XSpreadsheet > ( xDestSheetNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW);
+}
+
+bool XSpreadsheets2::isExternalReference(const rtl::OUString& aDestContent, const rtl::OUString& aSrcContent )
+{
+ rtl::OUString aStart(RTL_CONSTASCII_USTRINGPARAM("'file://"));
+ const sal_Char* sSrcContent = rtl::OUStringToOString( aSrcContent, RTL_TEXTENCODING_UTF8 ).getStr();
+
+ return (aDestContent.endsWithIgnoreAsciiCaseAsciiL(sSrcContent, aSrcContent.getLength()) // same cell address
+ && aDestContent.indexOf(aStart)==0 // starts with 'file://
+ && aDestContent.indexOf(aSrcFileName)>0); // contains source file name
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/unoapi_test.cxx b/test/source/unoapi_test.cxx
index 0a6f4aa4adf0..2d9292a87041 100644
--- a/test/source/unoapi_test.cxx
+++ b/test/source/unoapi_test.cxx
@@ -28,6 +28,8 @@
#include "test/unoapi_test.hxx"
+#include <com/sun/star/util/XCloseable.hpp>
+
UnoApiTest::UnoApiTest()
: m_aBaseString(RTL_CONSTASCII_USTRINGPARAM("/sc/qa/extras/testdocuments"))
{
@@ -64,4 +66,10 @@ void UnoApiTest::createFileURL(const rtl::OUString& aFileBase, rtl::OUString& rF
rFilePath = aBuffer.makeStringAndClear();
}
+void UnoApiTest::closeDocument( uno::Reference< lang::XComponent > xDocument )
+{
+ uno::Reference< util::XCloseable > xCloseable(xDocument, UNO_QUERY_THROW);
+ xCloseable->close(false);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */