summaryrefslogtreecommitdiffstats
path: root/test/source/sheet
diff options
context:
space:
mode:
Diffstat (limited to 'test/source/sheet')
-rw-r--r--test/source/sheet/cellarealink.cxx114
-rw-r--r--test/source/sheet/cellproperties.cxx60
-rw-r--r--test/source/sheet/databaseimportdescriptor.cxx102
-rw-r--r--test/source/sheet/databaserange.cxx216
-rw-r--r--test/source/sheet/datapilotfield.cxx189
-rw-r--r--test/source/sheet/datapilotitem.cxx70
-rw-r--r--test/source/sheet/documentsettings.cxx183
-rw-r--r--test/source/sheet/functiondescription.cxx85
-rw-r--r--test/source/sheet/globalsheetsettings.cxx232
-rw-r--r--test/source/sheet/scenario.cxx113
-rw-r--r--test/source/sheet/shape.cxx115
-rw-r--r--test/source/sheet/sheetcell.cxx215
-rw-r--r--test/source/sheet/sheetcellrange.cxx167
-rw-r--r--test/source/sheet/sheetcellranges.cxx142
-rw-r--r--test/source/sheet/sheetfilterdescriptor.cxx151
-rw-r--r--test/source/sheet/sheetlink.cxx67
-rw-r--r--test/source/sheet/sheetsortdescriptor2.cxx123
-rw-r--r--test/source/sheet/spreadsheet.cxx90
-rw-r--r--test/source/sheet/spreadsheetdocumentsettings.cxx190
-rw-r--r--test/source/sheet/spreadsheetviewsettings.cxx241
-rw-r--r--test/source/sheet/subtotaldescriptor.cxx116
-rw-r--r--test/source/sheet/tableautoformat.cxx94
-rw-r--r--test/source/sheet/tablevalidation.cxx153
-rw-r--r--test/source/sheet/xactivationbroadcaster.cxx72
-rw-r--r--test/source/sheet/xarealink.cxx65
-rw-r--r--test/source/sheet/xarealinks.cxx50
-rw-r--r--test/source/sheet/xarrayformularange.cxx54
-rw-r--r--test/source/sheet/xcalculatable.cxx74
-rw-r--r--test/source/sheet/xcelladdressable.cxx35
-rw-r--r--test/source/sheet/xcellformatrangessupplier.cxx39
-rw-r--r--test/source/sheet/xcellrangeaddressable.cxx33
-rw-r--r--test/source/sheet/xcellrangedata.cxx94
-rw-r--r--test/source/sheet/xcellrangeformula.cxx41
-rw-r--r--test/source/sheet/xcellrangemovement.cxx120
-rw-r--r--test/source/sheet/xcellrangereferrer.cxx36
-rw-r--r--test/source/sheet/xcellrangesquery.cxx97
-rw-r--r--test/source/sheet/xcellseries.cxx114
-rw-r--r--test/source/sheet/xconsolidatable.cxx43
-rw-r--r--test/source/sheet/xconsolidationdescriptor.cxx144
-rw-r--r--test/source/sheet/xdatabaserange.cxx181
-rw-r--r--test/source/sheet/xdatabaseranges.cxx45
-rw-r--r--test/source/sheet/xdatapilotdescriptor.cxx192
-rw-r--r--test/source/sheet/xdatapilotfield.cxx40
-rw-r--r--test/source/sheet/xdatapilotfieldgrouping.cxx44
-rw-r--r--test/source/sheet/xdatapilottable.cxx52
-rw-r--r--test/source/sheet/xdatapilottable2.cxx276
-rw-r--r--test/source/sheet/xdatapilottables.cxx53
-rw-r--r--test/source/sheet/xdatapilottablessupplier.cxx29
-rw-r--r--test/source/sheet/xddelink.cxx44
-rw-r--r--test/source/sheet/xddelinks.cxx41
-rw-r--r--test/source/sheet/xdocumentauditing.cxx139
-rw-r--r--test/source/sheet/xformulaquery.cxx66
-rw-r--r--test/source/sheet/xfunctiondescriptions.cxx73
-rw-r--r--test/source/sheet/xgoalseek.cxx37
-rw-r--r--test/source/sheet/xheaderfootercontent.cxx48
-rw-r--r--test/source/sheet/xlabelrange.cxx50
-rw-r--r--test/source/sheet/xlabelranges.cxx44
-rw-r--r--test/source/sheet/xmultiformulatokens.cxx44
-rw-r--r--test/source/sheet/xmultipleoperation.cxx95
-rw-r--r--test/source/sheet/xnamedrange.cxx113
-rw-r--r--test/source/sheet/xnamedranges.cxx194
-rw-r--r--test/source/sheet/xprintareas.cxx40
-rw-r--r--test/source/sheet/xrecentfunctions.cxx76
-rw-r--r--test/source/sheet/xscenario.cxx43
-rw-r--r--test/source/sheet/xscenarioenhanced.cxx38
-rw-r--r--test/source/sheet/xscenarios.cxx44
-rw-r--r--test/source/sheet/xscenariossupplier.cxx28
-rw-r--r--test/source/sheet/xsheetannotation.cxx70
-rw-r--r--test/source/sheet/xsheetannotationanchor.cxx44
-rw-r--r--test/source/sheet/xsheetannotations.cxx212
-rw-r--r--test/source/sheet/xsheetannotationshapesupplier.cxx41
-rw-r--r--test/source/sheet/xsheetannotationssupplier.cxx30
-rw-r--r--test/source/sheet/xsheetauditing.cxx137
-rw-r--r--test/source/sheet/xsheetcellcursor.cxx138
-rw-r--r--test/source/sheet/xsheetcellrange.cxx33
-rw-r--r--test/source/sheet/xsheetcellrangecontainer.cxx100
-rw-r--r--test/source/sheet/xsheetcellranges.cxx50
-rw-r--r--test/source/sheet/xsheetcondition.cxx72
-rw-r--r--test/source/sheet/xsheetconditionalentries.cxx57
-rw-r--r--test/source/sheet/xsheetconditionalentry.cxx35
-rw-r--r--test/source/sheet/xsheetfilterable.cxx87
-rw-r--r--test/source/sheet/xsheetfilterableex.cxx59
-rw-r--r--test/source/sheet/xsheetfilterdescriptor.cxx42
-rw-r--r--test/source/sheet/xsheetfilterdescriptor2.cxx42
-rw-r--r--test/source/sheet/xsheetfilterdescriptor3.cxx42
-rw-r--r--test/source/sheet/xsheetlinkable.cxx50
-rw-r--r--test/source/sheet/xsheetoperation.cxx44
-rw-r--r--test/source/sheet/xsheetoutline.cxx266
-rw-r--r--test/source/sheet/xsheetpagebreak.cxx69
-rw-r--r--test/source/sheet/xspreadsheet.cxx40
-rw-r--r--test/source/sheet/xspreadsheetdocument.cxx33
-rw-r--r--test/source/sheet/xspreadsheets.cxx85
-rw-r--r--test/source/sheet/xspreadsheets2.cxx372
-rw-r--r--test/source/sheet/xspreadsheetview.cxx41
-rw-r--r--test/source/sheet/xsubtotalcalculatable.cxx74
-rw-r--r--test/source/sheet/xsubtotaldescriptor.cxx47
-rw-r--r--test/source/sheet/xsubtotalfield.cxx79
-rw-r--r--test/source/sheet/xuniquecellformatrangessupplier.cxx37
-rw-r--r--test/source/sheet/xusedareacursor.cxx97
-rw-r--r--test/source/sheet/xviewfreezable.cxx33
-rw-r--r--test/source/sheet/xviewpane.cxx53
-rw-r--r--test/source/sheet/xviewsplitable.cxx42
102 files changed, 9261 insertions, 0 deletions
diff --git a/test/source/sheet/cellarealink.cxx b/test/source/sheet/cellarealink.cxx
new file mode 100644
index 000000000..d73f4e09c
--- /dev/null
+++ b/test/source/sheet/cellarealink.cxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/cellarealink.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+
+namespace apitest
+{
+void CellAreaLink::testUrl()
+{
+ uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW);
+
+ const OUString propName("Url");
+
+ OUString aUrl;
+ CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aUrl);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Default Url already changed", m_aFileURL, aUrl);
+
+ uno::Any aNewUrl;
+ aNewUrl <<= OUString("file:///tmp");
+ xCellAreaLink->setPropertyValue(propName, aNewUrl);
+ CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aUrl);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of Url wasn't changed", OUString("file:///tmp"), aUrl);
+}
+
+void CellAreaLink::testFilter()
+{
+ uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW);
+
+ const OUString propName("Filter");
+
+ OUString aFilter;
+ CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilter);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Default Filter already changed", OUString("calc8"), aFilter);
+
+ uno::Any aNewFilter;
+ aNewFilter <<= OUString("UnitTest");
+ xCellAreaLink->setPropertyValue(propName, aNewFilter);
+ CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilter);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of Filter wasn't changed", OUString("UnitTest"), aFilter);
+}
+
+void CellAreaLink::testFilterOptions()
+{
+ uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW);
+
+ const OUString propName("FilterOptions");
+
+ OUString aFilterOptions;
+ CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilterOptions);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Default FilterOptions already changed", OUString(""),
+ aFilterOptions);
+
+ uno::Any aNewFilterOptions;
+ aNewFilterOptions <<= OUString("UnitTest");
+ xCellAreaLink->setPropertyValue(propName, aNewFilterOptions);
+ CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aFilterOptions);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of FilterOptions wasn't changed", OUString("UnitTest"),
+ aFilterOptions);
+}
+
+void CellAreaLink::testRefreshDelay()
+{
+ uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW);
+
+ const OUString propName("RefreshDelay");
+
+ sal_Int32 aRefreshDelay = 0;
+ CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshDelay);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshDelay already changed", sal_Int32(0),
+ aRefreshDelay);
+
+ uno::Any aNewRefreshDelay;
+ aNewRefreshDelay <<= static_cast<sal_Int32>(42);
+ xCellAreaLink->setPropertyValue(propName, aNewRefreshDelay);
+ CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshDelay);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of RefreshDelay wasn't changed", sal_Int32(42),
+ aRefreshDelay);
+}
+
+void CellAreaLink::testRefreshPeriod()
+{
+ uno::Reference<beans::XPropertySet> xCellAreaLink(init(), uno::UNO_QUERY_THROW);
+
+ const OUString propName("RefreshPeriod");
+
+ sal_Int32 aRefreshPeriod = 0;
+ CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshPeriod);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshPeriod already changed", sal_Int32(0),
+ aRefreshPeriod);
+
+ uno::Any aNewRefreshPeriod;
+ aNewRefreshPeriod <<= static_cast<sal_Int32>(42);
+ xCellAreaLink->setPropertyValue(propName, aNewRefreshPeriod);
+ CPPUNIT_ASSERT(xCellAreaLink->getPropertyValue(propName) >>= aRefreshPeriod);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of RefreshPeriod wasn't changed", sal_Int32(42),
+ aRefreshPeriod);
+}
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/cellproperties.cxx b/test/source/sheet/cellproperties.cxx
new file mode 100644
index 000000000..8650eaa85
--- /dev/null
+++ b/test/source/sheet/cellproperties.cxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/cellproperties.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <cppunit/TestAssert.h>
+#include <iostream>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void CellProperties::testVertJustify()
+{
+ uno::Reference< beans::XPropertySet > xCellRangeBase(init(),UNO_QUERY_THROW);
+ OUString aVertJustify("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_EQUAL_MESSAGE("value has not been changed", sal_Int32(3), aValue);
+}
+
+void CellProperties::testRotateReference()
+{
+ uno::Reference< beans::XPropertySet > xCellRangeBase(init(),UNO_QUERY_THROW);
+ OUString aRotateReference("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_EQUAL_MESSAGE("value has not been changed", sal_Int32(3), aValue);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/databaseimportdescriptor.cxx b/test/source/sheet/databaseimportdescriptor.cxx
new file mode 100644
index 000000000..ea17b871b
--- /dev/null
+++ b/test/source/sheet/databaseimportdescriptor.cxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/databaseimportdescriptor.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/DataImportMode.hpp>
+#include <com/sun/star/util/XImportable.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void DatabaseImportDescriptor::testDatabaseImportDescriptorProperties()
+{
+ uno::Reference<beans::XPropertySet> xDatabaseImportDescriptor(init(), UNO_QUERY_THROW);
+ uno::Reference<util::XImportable> xImportable(getXImportable(), UNO_QUERY_THROW);
+ uno::Sequence<beans::PropertyValue> aPropValues = xImportable->createImportDescriptor(true);
+
+ for (auto& rPropValue : aPropValues)
+ {
+ uno::Any aOldValue;
+ uno::Any aNewValue;
+ if (rPropValue.Name == "DatabaseName" || rPropValue.Name == "SourceObject"
+ || rPropValue.Name == "ConnectionResource")
+ {
+ OUString aValue;
+ aOldValue = rPropValue.Value;
+ aOldValue >>= aValue;
+ OString aMsgGet = "Unable to get PropertyValue "
+ + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgGet.getStr(), OUString(""), aValue);
+
+ aNewValue <<= OUString("New");
+ rPropValue.Value = aNewValue;
+
+ aOldValue = rPropValue.Value;
+ aOldValue >>= aValue;
+ OString aMsgSet = "Unable to set PropertyValue "
+ + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgSet.getStr(), OUString("New"), aValue);
+ }
+ else if (rPropValue.Name == "IsNative")
+ {
+ bool aValue = true;
+ aOldValue = rPropValue.Value;
+ aOldValue >>= aValue;
+ OString aMsgGet = "Unable to get PropertyValue "
+ + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8);
+ CPPUNIT_ASSERT_MESSAGE(aMsgGet.getStr(), !aValue);
+
+ aNewValue <<= true;
+ rPropValue.Value = aNewValue;
+
+ aOldValue = rPropValue.Value;
+ aOldValue >>= aValue;
+ OString aMsgSet = "Unable to set PropertyValue "
+ + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8);
+ CPPUNIT_ASSERT_MESSAGE(aMsgSet.getStr(), aValue);
+ }
+ else if (rPropValue.Name == "SourceType")
+ {
+ sheet::DataImportMode aValue;
+ aOldValue = rPropValue.Value;
+ aOldValue >>= aValue;
+ OString aMsgGet = "Unable to get PropertyValue "
+ + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgGet.getStr(), sheet::DataImportMode_NONE, aValue);
+
+ aNewValue <<= sheet::DataImportMode_SQL;
+ rPropValue.Value = aNewValue;
+
+ aOldValue = rPropValue.Value;
+ aOldValue >>= aValue;
+ OString aMsgSet = "Unable to set PropertyValue "
+ + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsgSet.getStr(), sheet::DataImportMode_SQL, aValue);
+ }
+ else
+ {
+ OString aMsg = "Unsupported PropertyValue "
+ + OUStringToOString(rPropValue.Name, RTL_TEXTENCODING_UTF8);
+ CPPUNIT_FAIL(aMsg.getStr());
+ }
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/databaserange.cxx b/test/source/sheet/databaserange.cxx
new file mode 100644
index 000000000..7079c8ffa
--- /dev/null
+++ b/test/source/sheet/databaserange.cxx
@@ -0,0 +1,216 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/databaserange.hxx>
+#include <test/cppunitasserthelper.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XDatabaseRange.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void DatabaseRange::testMoveCells()
+{
+ uno::Reference< beans::XPropertySet > xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
+
+ const OUString propName("MoveCells");
+
+ bool bMoveCells = true;
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bMoveCells);
+ CPPUNIT_ASSERT_MESSAGE("Default MoveCells already changed", !bMoveCells);
+
+ uno::Any aNewMoveCells;
+ aNewMoveCells <<= true;
+ xDatabaseRange->setPropertyValue(propName, aNewMoveCells);
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bMoveCells);
+ CPPUNIT_ASSERT_MESSAGE("Value of MoveCells wasn't changed", bMoveCells);
+}
+
+void DatabaseRange::testKeepFormats()
+{
+ uno::Reference< beans::XPropertySet > xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
+
+ const OUString propName("KeepFormats");
+
+ bool bKeepFormats = true;
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bKeepFormats);
+ CPPUNIT_ASSERT_MESSAGE("Default KeepFormats already changed", !bKeepFormats);
+
+ uno::Any aNewKeepFormats;
+ aNewKeepFormats <<= true;
+ xDatabaseRange->setPropertyValue(propName, aNewKeepFormats);
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bKeepFormats);
+ CPPUNIT_ASSERT_MESSAGE("Value of KeepFormats wasn't changed", bKeepFormats);
+}
+
+void DatabaseRange::testStripData()
+{
+ uno::Reference< beans::XPropertySet > xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
+
+ const OUString propName("StripData");
+
+ bool bStripData = true;
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bStripData);
+ CPPUNIT_ASSERT_MESSAGE("Default StripData already changed", !bStripData);
+
+ uno::Any aNewStripData;
+ aNewStripData <<= true;
+ xDatabaseRange->setPropertyValue(propName, aNewStripData);
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bStripData);
+ CPPUNIT_ASSERT_MESSAGE("Value of StripData wasn't changed", bStripData);
+}
+
+void DatabaseRange::testAutoFilter()
+{
+ uno::Reference< beans::XPropertySet > xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
+
+ const OUString propName("AutoFilter");
+
+ bool bAutoFilter = true;
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bAutoFilter);
+ CPPUNIT_ASSERT_MESSAGE("Default AutoFilter already changed", !bAutoFilter);
+
+ uno::Any aNewAutoFilter;
+ aNewAutoFilter <<= true;
+ xDatabaseRange->setPropertyValue(propName, aNewAutoFilter);
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bAutoFilter);
+ CPPUNIT_ASSERT_MESSAGE("Value of AutoFilter wasn't changed", bAutoFilter);
+}
+
+void DatabaseRange::testUseFilterCriteriaSource()
+{
+ uno::Reference< beans::XPropertySet > xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
+
+ const OUString propName("UseFilterCriteriaSource");
+
+ bool bUseFilterCriteriaSource = true;
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bUseFilterCriteriaSource);
+ CPPUNIT_ASSERT_MESSAGE("Default UseFilterCriteriaSource already changed", !bUseFilterCriteriaSource);
+
+ uno::Any aNewUseFilterCriteriaSource;
+ aNewUseFilterCriteriaSource <<= true;
+ xDatabaseRange->setPropertyValue(propName, aNewUseFilterCriteriaSource);
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bUseFilterCriteriaSource);
+ CPPUNIT_ASSERT_MESSAGE("Value of UseFilterCriteriaSource wasn't changed", bUseFilterCriteriaSource);
+}
+
+void DatabaseRange::testFilterCriteriaSource()
+{
+ uno::Reference< beans::XPropertySet > xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
+
+ const OUString propName("FilterCriteriaSource");
+
+ table::CellRangeAddress cellRangeAddress;
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= cellRangeAddress);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshPeriod already changed",
+ table::CellRangeAddress(0,0,0,0,0), cellRangeAddress);
+
+ uno::Any aFilterCriteriaSource;
+ aFilterCriteriaSource <<= table::CellRangeAddress(1,1,1,1,1);
+ xDatabaseRange->setPropertyValue(propName, aFilterCriteriaSource);
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= cellRangeAddress);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of FilterCriteriaSource wasn't changed",
+ table::CellRangeAddress(1,1,1,1,1), cellRangeAddress);
+}
+
+void DatabaseRange::testRefreshPeriod()
+{
+ uno::Reference< beans::XPropertySet > xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
+
+ const OUString propName("RefreshPeriod");
+
+ sal_Int32 aRefreshPeriod = 1;
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= aRefreshPeriod);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Default RefreshPeriod already changed", sal_Int32(0), aRefreshPeriod);
+
+ uno::Any aNewRefreshPeriod;
+ aNewRefreshPeriod <<= static_cast<sal_Int32>(42);
+ xDatabaseRange->setPropertyValue(propName, aNewRefreshPeriod);
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= aRefreshPeriod);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of RefreshPeriod wasn't changed", sal_Int32(42), aRefreshPeriod);
+}
+
+void DatabaseRange::testFromSelection()
+{
+ uno::Reference< beans::XPropertySet > xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
+
+ const OUString propName("FromSelection");
+
+ bool bFromSelection = true;
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bFromSelection);
+ CPPUNIT_ASSERT_MESSAGE("Default FromSelection already changed", !bFromSelection);
+
+ uno::Any aNewFromSelection;
+ aNewFromSelection <<= true;
+ xDatabaseRange->setPropertyValue(propName, aNewFromSelection);
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bFromSelection);
+ CPPUNIT_ASSERT_MESSAGE("Value of FromSelection wasn't changed", bFromSelection);
+}
+
+void DatabaseRange::testTokenIndex()
+{
+ uno::Reference< beans::XPropertySet > xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
+
+ const OUString propName("TokenIndex");
+
+ sal_Int32 aTokenIndex = 0;
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= aTokenIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Default TotalIndex already changed", sal_Int32(1), aTokenIndex);
+
+ uno::Any aNewTokenIndex;
+ aNewTokenIndex <<= static_cast<sal_Int32>(42);
+ xDatabaseRange->setPropertyValue(propName, aNewTokenIndex);
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= aTokenIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of TotalIndex was changed", sal_Int32(1), aTokenIndex);
+}
+
+void DatabaseRange::testTotalsRow()
+{
+ uno::Reference< beans::XPropertySet > xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
+
+ const OUString propName("TotalsRow");
+
+ bool bTotalsRow = true;
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bTotalsRow);
+ CPPUNIT_ASSERT_MESSAGE("Default TotalsRow already changed", !bTotalsRow);
+
+ uno::Any aNewTotalsRow;
+ aNewTotalsRow <<= true;
+ xDatabaseRange->setPropertyValue(propName, aNewTotalsRow);
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bTotalsRow);
+ CPPUNIT_ASSERT_MESSAGE("Value of TotalsRow wasn't changed", bTotalsRow);
+}
+
+void DatabaseRange::testContainsHeader()
+{
+ uno::Reference< beans::XPropertySet > xDatabaseRange(init("DataArea"), UNO_QUERY_THROW);
+
+ const OUString propName("ContainsHeader");
+
+ bool bContainsHeader = false;
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bContainsHeader);
+ CPPUNIT_ASSERT_MESSAGE("Default ContainsHeader already changed", bContainsHeader);
+
+ uno::Any aNewContainsHeader;
+ aNewContainsHeader <<= false;
+ xDatabaseRange->setPropertyValue(propName, aNewContainsHeader);
+ CPPUNIT_ASSERT(xDatabaseRange->getPropertyValue(propName) >>= bContainsHeader);
+ CPPUNIT_ASSERT_MESSAGE("Value of ContainsHeader wasn't changed", !bContainsHeader);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/datapilotfield.cxx b/test/source/sheet/datapilotfield.cxx
new file mode 100644
index 000000000..020f33680
--- /dev/null
+++ b/test/source/sheet/datapilotfield.cxx
@@ -0,0 +1,189 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/datapilotfield.hxx>
+#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/ustring.hxx>
+#include <cppunit/TestAssert.h>
+#include <iostream>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void DataPilotField::testSortInfo()
+{
+ uno::Reference< beans::XPropertySet> xPropSet(init(),UNO_QUERY_THROW);
+ sheet::DataPilotFieldSortInfo aSortInfoValue;
+ OUString aSortInfo("SortInfo");
+ aSortInfoValue.Field = "Col1";
+ aSortInfoValue.IsAscending = false;
+ aSortInfoValue.Mode = sheet::DataPilotFieldSortMode::MANUAL;
+ uno::Any aValue;
+ aValue <<= aSortInfoValue;
+ xPropSet->setPropertyValue(aSortInfo, aValue);
+
+ sheet::DataPilotFieldSortInfo aNewSortInfoValue;
+ aValue = xPropSet->getPropertyValue(aSortInfo);
+ CPPUNIT_ASSERT( aValue >>= aNewSortInfoValue );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as got value", aSortInfoValue.Field, aNewSortInfoValue.Field);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as got value", aSortInfoValue.Mode, aNewSortInfoValue.Mode);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as got value", aSortInfoValue.IsAscending, aNewSortInfoValue.IsAscending);
+
+ //setting HasSortInfo only makes sense for false, for true the uno implementation does nothing
+ bool bHasSortInfo(false);
+ OUString aHasSortInfo("HasSortInfo");
+ aValue = xPropSet->getPropertyValue(aHasSortInfo);
+ CPPUNIT_ASSERT( aValue >>= bHasSortInfo );
+ CPPUNIT_ASSERT_MESSAGE("should have sort info", bHasSortInfo);
+
+ bHasSortInfo = false;
+ aValue <<= bHasSortInfo;
+ xPropSet->setPropertyValue(aHasSortInfo, aValue);
+
+ aValue = xPropSet->getPropertyValue(aHasSortInfo);
+ CPPUNIT_ASSERT( aValue >>= 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;
+ OUString aLayoutInfo("LayoutInfo");
+ aLayoutInfoValue.AddEmptyLines = false;
+ aLayoutInfoValue.LayoutMode = sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM;
+ uno::Any aValue;
+ aValue <<= aLayoutInfoValue;
+ xPropSet->setPropertyValue(aLayoutInfo, aValue);
+
+ sheet::DataPilotFieldLayoutInfo aNewLayoutInfoValue;
+ aValue = xPropSet->getPropertyValue(aLayoutInfo);
+ CPPUNIT_ASSERT( aValue >>= aNewLayoutInfoValue );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aLayoutInfoValue.LayoutMode, aNewLayoutInfoValue.LayoutMode);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aLayoutInfoValue.AddEmptyLines, aNewLayoutInfoValue.AddEmptyLines);
+
+ //setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing
+ bool bHasLayoutInfo(false);
+ OUString aHasLayoutInfo("HasLayoutInfo");
+ aValue = xPropSet->getPropertyValue(aHasLayoutInfo);
+ CPPUNIT_ASSERT( aValue >>= bHasLayoutInfo );
+ CPPUNIT_ASSERT_MESSAGE("should have layout information", bHasLayoutInfo);
+
+ bHasLayoutInfo = false;
+ aValue <<= bHasLayoutInfo;
+ xPropSet->setPropertyValue(aHasLayoutInfo, aValue);
+
+ aValue = xPropSet->getPropertyValue(aHasLayoutInfo);
+ CPPUNIT_ASSERT( aValue >>= 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 = "Col1";
+ aAutoShowInfoValue.IsEnabled = true;
+ OUString aAutoShowInfo("AutoShowInfo");
+ uno::Any aValue;
+ aValue <<= aAutoShowInfoValue;
+ xPropSet->setPropertyValue(aAutoShowInfo, aValue);
+
+ sheet::DataPilotFieldAutoShowInfo aNewAutoShowInfoValue;
+ aValue = xPropSet->getPropertyValue(aAutoShowInfo);
+ CPPUNIT_ASSERT( aValue >>= aNewAutoShowInfoValue );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aAutoShowInfoValue.DataField, aNewAutoShowInfoValue.DataField);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aAutoShowInfoValue.IsEnabled, aNewAutoShowInfoValue.IsEnabled);
+
+ //setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing
+ bool bHasAutoShowInfo(false);
+ OUString aHasAutoShowInfo("HasAutoShowInfo");
+ aValue = xPropSet->getPropertyValue(aHasAutoShowInfo);
+ CPPUNIT_ASSERT( aValue >>= bHasAutoShowInfo );
+ CPPUNIT_ASSERT_MESSAGE("should have AutoShow information", bHasAutoShowInfo);
+
+ bHasAutoShowInfo = false;
+ aValue <<= bHasAutoShowInfo;
+ xPropSet->setPropertyValue(aHasAutoShowInfo, aValue);
+
+ aValue = xPropSet->getPropertyValue(aHasAutoShowInfo);
+ CPPUNIT_ASSERT( aValue >>= 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 = "Col1";
+ aReferenceValue.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::NAMED;
+ OUString aReference("Reference");
+ uno::Any aValue;
+ aValue <<= aReferenceValue;
+ xPropSet->setPropertyValue(aReference, aValue);
+
+ sheet::DataPilotFieldReference aNewReferenceValue;
+ aValue = xPropSet->getPropertyValue(aReference);
+ CPPUNIT_ASSERT( aValue >>= aNewReferenceValue );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aReferenceValue.ReferenceField, aNewReferenceValue.ReferenceField);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("set value should be the same as the got value", aReferenceValue.ReferenceItemType, aNewReferenceValue.ReferenceItemType);
+
+ //setting HasReference only makes sense for false, tor true the uno implementation does nothing
+ bool bHasReference(false);
+ OUString aHasReference("HasReference");
+ aValue = xPropSet->getPropertyValue(aHasReference);
+ CPPUNIT_ASSERT( aValue >>= bHasReference );
+ CPPUNIT_ASSERT_MESSAGE("should have Reference information", bHasReference);
+
+ bHasReference = false;
+ aValue <<= bHasReference;
+ xPropSet->setPropertyValue(aHasReference, aValue);
+
+ aValue = xPropSet->getPropertyValue(aHasReference);
+ CPPUNIT_ASSERT( aValue >>= 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 aValue;
+ OUString aIsGroupField("IsGroupField");
+ bool bIsGroupField(false);
+
+ aValue = xPropSet->getPropertyValue(aIsGroupField);
+ CPPUNIT_ASSERT( aValue >>= bIsGroupField);
+ //only setting to false is supported
+ if (bIsGroupField)
+ {
+ bIsGroupField = false;
+ aValue <<= bIsGroupField;
+
+ xPropSet->setPropertyValue(aIsGroupField, aValue);
+ aValue = xPropSet->getPropertyValue(aIsGroupField);
+ CPPUNIT_ASSERT(aValue >>= 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/datapilotitem.cxx b/test/source/sheet/datapilotitem.cxx
new file mode 100644
index 000000000..33fe34920
--- /dev/null
+++ b/test/source/sheet/datapilotitem.cxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/datapilotitem.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void DataPilotItem::testProperties()
+{
+ uno::Reference< beans::XPropertySet > xItem(init(), UNO_QUERY_THROW);
+
+
+ const OUString propNameIS("IsHidden");
+
+ bool bIsHidden = true;
+ CPPUNIT_ASSERT(xItem->getPropertyValue(propNameIS) >>= bIsHidden);
+ CPPUNIT_ASSERT_MESSAGE("Default IsHidden already changed", !bIsHidden);
+
+ uno::Any aNewIsHidden;
+ aNewIsHidden <<= false;
+ xItem->setPropertyValue(propNameIS, aNewIsHidden);
+ CPPUNIT_ASSERT(xItem->getPropertyValue(propNameIS) >>= bIsHidden);
+ CPPUNIT_ASSERT_MESSAGE("Value of IsHidden wasn't changed", !bIsHidden);
+
+
+ const OUString propNameSD("ShowDetail");
+
+ bool bShowDetail = false;
+ CPPUNIT_ASSERT(xItem->getPropertyValue(propNameSD) >>= bShowDetail);
+ CPPUNIT_ASSERT_MESSAGE("Default ShowDetail already changed", bShowDetail);
+
+ uno::Any aNewShowDetail;
+ aNewShowDetail <<= true;
+ xItem->setPropertyValue(propNameSD, aNewShowDetail);
+ CPPUNIT_ASSERT(xItem->getPropertyValue(propNameSD) >>= bShowDetail);
+ CPPUNIT_ASSERT_MESSAGE("Value of ShowDetail wasn't changed", bShowDetail);
+
+
+ const OUString propNameP("Position");
+
+ sal_Int32 nPosition = 42;
+ CPPUNIT_ASSERT(xItem->getPropertyValue(propNameP) >>= nPosition);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Default Position already changed", sal_Int32(0), nPosition);
+
+ // FIXME: This throws somehow a com.sun.star.lang.IllegalArgumentException
+ //uno::Any aNewPosition;
+ //aNewPosition <<= static_cast<sal_Int32>(42);
+ //xItem->setPropertyValue(propNameP, aNewPosition);
+ //CPPUNIT_ASSERT(xItem->getPropertyValue(propNameP) >>= nPosition);
+ //CPPUNIT_ASSERT_EQUAL_MESSAGE("Value of Position wasn't changed", sal_Int32(42), nPosition);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/documentsettings.cxx b/test/source/sheet/documentsettings.cxx
new file mode 100644
index 000000000..644b7273c
--- /dev/null
+++ b/test/source/sheet/documentsettings.cxx
@@ -0,0 +1,183 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/documentsettings.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void DocumentSettings::testDocumentSettingsProperties()
+{
+ uno::Reference<beans::XPropertySet> xDocumentSettings(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "ShowZeroValues";
+ bool aShowZeroValues = false;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aShowZeroValues);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowZeroValues", aShowZeroValues);
+
+ aNewValue <<= false;
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aShowZeroValues);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowZeroValues", !aShowZeroValues);
+
+ propName = "ShowNotes";
+ bool aShowNotes = false;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aShowNotes);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowNotes", aShowNotes);
+
+ aNewValue <<= false;
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aShowNotes);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowNotes", !aShowNotes);
+
+ propName = "ShowGrid";
+ bool aShowGrid = false;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aShowGrid);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowGrid", aShowGrid);
+
+ aNewValue <<= false;
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aShowGrid);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowGrid", !aShowGrid);
+
+ propName = "ShowPageBreaks";
+ bool aShowPageBreaks = false;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aShowPageBreaks);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowPageBreaks", aShowPageBreaks);
+
+ aNewValue <<= false;
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aShowPageBreaks);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowPageBreaks", !aShowPageBreaks);
+
+ propName = "HasColumnRowHeaders";
+ bool aHasColumnRowHeaders = false;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aHasColumnRowHeaders);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HasColumnRowHeaders", aHasColumnRowHeaders);
+
+ aNewValue <<= false;
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aHasColumnRowHeaders);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue HasColumnRowHeaders",
+ !aHasColumnRowHeaders);
+
+ propName = "HasSheetTabs";
+ bool aHasSheetTabs = false;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aHasSheetTabs);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HasSheetTabs", aHasSheetTabs);
+
+ aNewValue <<= false;
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aHasSheetTabs);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue HasSheetTabs", !aHasSheetTabs);
+
+ propName = "IsOutlineSymbolsSet";
+ bool aIsOutlineSymbolsSet = false;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aIsOutlineSymbolsSet);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsOutlineSymbolsSet", aIsOutlineSymbolsSet);
+
+ aNewValue <<= false;
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aIsOutlineSymbolsSet);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue IsOutlineSymbolsSet",
+ !aIsOutlineSymbolsSet);
+
+ propName = "IsSnapToRaster";
+ bool aIsSnapToRaster = true;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aIsSnapToRaster);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsSnapToRaster", !aIsSnapToRaster);
+
+ aNewValue <<= true;
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aIsSnapToRaster);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue IsSnapToRaster", aIsSnapToRaster);
+
+ propName = "RasterIsVisible";
+ bool aRasterIsVisible = true;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aRasterIsVisible);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue RasterIsVisible", !aRasterIsVisible);
+
+ aNewValue <<= true;
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aRasterIsVisible);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue RasterIsVisible", aRasterIsVisible);
+
+ propName = "RasterResolutionX";
+ sal_Int32 aRasterResolutionX = 0;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aRasterResolutionX);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue RasterResolutionX", sal_Int32(1270),
+ aRasterResolutionX);
+
+ aNewValue <<= sal_Int32(42);
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aRasterResolutionX);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue RasterResolutionX", sal_Int32(42),
+ aRasterResolutionX);
+
+ propName = "RasterResolutionY";
+ sal_Int32 aRasterResolutionY = 0;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aRasterResolutionY);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue RasterResolutionY", sal_Int32(1270),
+ aRasterResolutionY);
+
+ aNewValue <<= sal_Int32(42);
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aRasterResolutionY);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue RasterResolutionY", sal_Int32(42),
+ aRasterResolutionY);
+
+ propName = "RasterSubdivisionX";
+ sal_Int32 aRasterSubdivisionX = 0;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aRasterSubdivisionX);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue RasterSubdivisionX", sal_Int32(1),
+ aRasterSubdivisionX);
+
+ aNewValue <<= sal_Int32(42);
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aRasterSubdivisionX);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue RasterSubdivisionX", sal_Int32(42),
+ aRasterSubdivisionX);
+
+ propName = "RasterSubdivisionY";
+ sal_Int32 aRasterSubdivisionY = 0;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aRasterSubdivisionY);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue RasterSubdivisionY", sal_Int32(1),
+ aRasterSubdivisionY);
+
+ aNewValue <<= sal_Int32(42);
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aRasterSubdivisionY);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue RasterSubdivisionY", sal_Int32(42),
+ aRasterSubdivisionY);
+
+ propName = "IsRasterAxisSynchronized";
+ bool aIsRasterAxisSynchronized = false;
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aIsRasterAxisSynchronized);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsRasterAxisSynchronized",
+ aIsRasterAxisSynchronized);
+
+ aNewValue <<= false;
+ xDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xDocumentSettings->getPropertyValue(propName) >>= aIsRasterAxisSynchronized);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue IsRasterAxisSynchronized",
+ !aIsRasterAxisSynchronized);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/functiondescription.cxx b/test/source/sheet/functiondescription.cxx
new file mode 100644
index 000000000..e90a138e8
--- /dev/null
+++ b/test/source/sheet/functiondescription.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <vector>
+
+#include <test/sheet/functiondescription.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sheet/FunctionArgument.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void FunctionDescription::testFunctionDescriptionProperties()
+{
+ const uno::Sequence<beans::PropertyValue> aFunctionDescription(init());
+
+ std::vector<OUString> names;
+ // Only test the get/read operation of the values, because set/write operation doesn't
+ // make any sense. It doesn't trigger any changes.
+ // See discussion: nabble.documentfoundation.org/Testing-UNO-API-service-properties-td4236286.html.
+ for (const auto& value : aFunctionDescription)
+ {
+ if (value.Name == "Id")
+ {
+ names.push_back(value.Name);
+ sal_Int32 nValue = 0;
+ CPPUNIT_ASSERT(value.Value >>= nValue);
+ }
+ else if (value.Name == "Category")
+ {
+ names.push_back(value.Name);
+ sal_Int32 nValue = 0;
+ CPPUNIT_ASSERT(value.Value >>= nValue);
+ }
+ else if (value.Name == "Name")
+ {
+ names.push_back(value.Name);
+ OUString sValue;
+ CPPUNIT_ASSERT(value.Value >>= sValue);
+ }
+ else if (value.Name == "Description")
+ {
+ names.push_back(value.Name);
+ OUString sValue;
+ CPPUNIT_ASSERT(value.Value >>= sValue);
+ }
+ else if (value.Name == "Arguments")
+ {
+ names.push_back(value.Name);
+ uno::Sequence<sheet::FunctionArgument> sArguments;
+ CPPUNIT_ASSERT(value.Value >>= sArguments);
+ }
+ else
+ {
+ OString aMsg = "Unsupported PropertyValue: "
+ + OUStringToOString(value.Name, RTL_TEXTENCODING_UTF8);
+ CPPUNIT_FAIL(aMsg.getStr());
+ }
+ }
+
+ CPPUNIT_ASSERT_MESSAGE("Property Id not found",
+ std::count(std::begin(names), std::end(names), "Id"));
+ CPPUNIT_ASSERT_MESSAGE("Property Category not found",
+ std::count(std::begin(names), std::end(names), "Category"));
+ CPPUNIT_ASSERT_MESSAGE("Property Name not found",
+ std::count(std::begin(names), std::end(names), "Name"));
+ CPPUNIT_ASSERT_MESSAGE("Property Description not found",
+ std::count(std::begin(names), std::end(names), "Description"));
+ CPPUNIT_ASSERT_MESSAGE("Property Arguments not found",
+ std::count(std::begin(names), std::end(names), "Arguments"));
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/globalsheetsettings.cxx b/test/source/sheet/globalsheetsettings.cxx
new file mode 100644
index 000000000..5018120ae
--- /dev/null
+++ b/test/source/sheet/globalsheetsettings.cxx
@@ -0,0 +1,232 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/globalsheetsettings.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void GlobalSheetSettings::testGlobalSheetSettingsProperties()
+{
+ uno::Reference<beans::XPropertySet> xGlobalSheetSettings(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "MoveSelection";
+ bool aMoveSelection = false;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aMoveSelection);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue MoveSelection", aMoveSelection);
+
+ aNewValue <<= false;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aMoveSelection);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue MoveSelection", !aMoveSelection);
+
+ propName = "MoveDirection";
+ sal_Int16 aMoveDirection = 42;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aMoveDirection);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue MoveDirection", sal_Int16(0),
+ aMoveDirection);
+
+ aNewValue <<= sal_Int16(1);
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aMoveDirection);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue MoveDirection", sal_Int16(1),
+ aMoveDirection);
+
+ propName = "EnterEdit";
+ bool aEnterEdit = true;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aEnterEdit);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue EnterEdit", !aEnterEdit);
+
+ aNewValue <<= true;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aEnterEdit);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue EnterEdit", aEnterEdit);
+
+ propName = "ExtendFormat";
+ bool aExtendFormat = true;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aExtendFormat);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ExtendFormat", !aExtendFormat);
+
+ aNewValue <<= true;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aExtendFormat);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ExtendFormat", aExtendFormat);
+
+ propName = "RangeFinder";
+ bool aRangeFinder = false;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aRangeFinder);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue RangeFinder", aRangeFinder);
+
+ aNewValue <<= false;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aRangeFinder);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue RangeFinder", !aRangeFinder);
+
+ propName = "ExpandReferences";
+ bool aExpandReferences = true;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aExpandReferences);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ExpandReferences", !aExpandReferences);
+
+ aNewValue <<= true;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aExpandReferences);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ExpandReferences", aExpandReferences);
+
+ propName = "MarkHeader";
+ bool aMarkHeader = false;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aMarkHeader);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue MarkHeader", aMarkHeader);
+
+ aNewValue <<= false;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aMarkHeader);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue MarkHeader", !aMarkHeader);
+
+ propName = "UseTabCol";
+ bool aUseTabCol = true;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aUseTabCol);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue UseTabCol", !aUseTabCol);
+
+ aNewValue <<= true;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aUseTabCol);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue UseTabCol", aUseTabCol);
+
+ propName = "Metric";
+ sal_Int16 aMetric = 42;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aMetric);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue Metric", sal_Int16(8), aMetric);
+
+ aNewValue <<= sal_Int16(1);
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aMetric);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Metric", sal_Int16(1), aMetric);
+
+ propName = "Scale";
+ sal_Int16 aScale = 42;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aScale);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue Scale", sal_Int16(100), aScale);
+
+ aNewValue <<= sal_Int16(-1);
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aScale);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Scale", sal_Int16(-1), aScale);
+
+ propName = "DoAutoComplete";
+ bool aDoAutoComplete = false;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aDoAutoComplete);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue DoAutoComplete", aDoAutoComplete);
+
+ aNewValue <<= false;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aDoAutoComplete);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue DoAutoComplete", !aDoAutoComplete);
+
+ propName = "StatusBarFunction";
+ sal_Int16 aStatusBarFunction = 42;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aStatusBarFunction);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue StatusBarFunction", sal_Int16(514),
+ aStatusBarFunction);
+
+ aNewValue <<= sal_Int16(1);
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aStatusBarFunction);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue StatusBarFunction", sal_Int16(1),
+ aStatusBarFunction);
+
+ propName = "UserLists";
+ uno::Sequence<OUString> aSeq(6);
+ aSeq[0] = "Sun,Mon,Tue,Wed,Thu,Fri,Sat";
+ aSeq[1] = "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday";
+ aSeq[2] = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec";
+ aSeq[3]
+ = "January,February,March,April,May,June,July,August,September,October,November,December";
+ aSeq[4] = "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Shabbat";
+ aSeq[5] = "Nissan,Iyar,Sivan,Tammuz,Av,Elul,Tishri,Heshvan,Kislev,Tevet,Shevat,Adar,Adar B";
+
+ uno::Sequence<OUString> aUserLists;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aUserLists);
+ for (auto i = 0; i < aUserLists.getLength(); i++)
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue UserLists[" + std::to_string(i)
+ + "]",
+ aSeq[i], aUserLists[i]);
+ }
+
+ aNewValue <<= uno::Sequence<OUString>();
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aUserLists);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue UserLists", !aUserLists.hasElements());
+
+ propName = "LinkUpdateMode";
+ sal_Int16 aLinkUpdateMode = 42;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aLinkUpdateMode);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue LinkUpdateMode", sal_Int16(2),
+ aLinkUpdateMode);
+
+ aNewValue <<= sal_Int16(1);
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aLinkUpdateMode);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue LinkUpdateMode", sal_Int16(1),
+ aLinkUpdateMode);
+
+ propName = "PrintAllSheets";
+ bool aPrintAllSheets = true;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aPrintAllSheets);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue PrintAllSheets", !aPrintAllSheets);
+
+ aNewValue <<= true;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aPrintAllSheets);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue PrintAllSheets", aPrintAllSheets);
+
+ propName = "PrintEmptyPages";
+ bool aPrintEmptyPages = true;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aPrintEmptyPages);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue PrintEmptyPages", !aPrintEmptyPages);
+
+ aNewValue <<= true;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aPrintEmptyPages);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue PrintEmptyPages", aPrintEmptyPages);
+
+ propName = "UsePrinterMetrics";
+ bool aUsePrinterMetrics = true;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aUsePrinterMetrics);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue UsePrinterMetrics", !aUsePrinterMetrics);
+
+ aNewValue <<= true;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aUsePrinterMetrics);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue UsePrinterMetrics", aUsePrinterMetrics);
+
+ propName = "ReplaceCellsWarning";
+ bool aReplaceCellsWarning = false;
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aReplaceCellsWarning);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ReplaceCellsWarning", aReplaceCellsWarning);
+
+ aNewValue <<= false;
+ xGlobalSheetSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xGlobalSheetSettings->getPropertyValue(propName) >>= aReplaceCellsWarning);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ReplaceCellsWarning",
+ !aReplaceCellsWarning);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/scenario.cxx b/test/source/sheet/scenario.cxx
new file mode 100644
index 000000000..dc96e3cc3
--- /dev/null
+++ b/test/source/sheet/scenario.cxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/scenario.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void Scenario::testScenarioProperties()
+{
+ uno::Reference<beans::XPropertySet> xScenario(getScenarioSpreadsheet(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "IsActive";
+ bool aIsActive = false;
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aIsActive);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value IsActive", aIsActive);
+
+ aNewValue <<= false;
+ xScenario->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aIsActive);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value IsActive", !aIsActive);
+
+ propName = "BorderColor";
+ sal_Int32 aBorderColor = 0;
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aBorderColor);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value BorderColor", sal_Int32(12632256),
+ aBorderColor);
+
+ aNewValue <<= sal_Int32(42);
+ xScenario->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aBorderColor);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set property value BorderColor", sal_Int32(42),
+ aBorderColor);
+
+ propName = "Protected";
+ bool aProtected = false;
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aProtected);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value Protected", aProtected);
+
+ aNewValue <<= false;
+ xScenario->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aProtected);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value Protected", !aProtected);
+
+ propName = "ShowBorder";
+ bool aShowBorder = false;
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aShowBorder);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value ShowBorder", aShowBorder);
+
+ aNewValue <<= false;
+ xScenario->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aShowBorder);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value ShowBorder", !aShowBorder);
+
+ propName = "PrintBorder";
+ bool aPrintBorder = false;
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aPrintBorder);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value PrintBorder", aPrintBorder);
+
+ aNewValue <<= false;
+ xScenario->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aPrintBorder);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value PrintBorder", !aPrintBorder);
+
+ propName = "CopyBack";
+ bool aCopyBack = false;
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyBack);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value CopyBack", aCopyBack);
+
+ aNewValue <<= false;
+ xScenario->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyBack);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value CopyBack", !aCopyBack);
+
+ propName = "CopyStyles";
+ bool aCopyStyles = true;
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyStyles);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value CopyStyles", !aCopyStyles);
+
+ aNewValue <<= true;
+ xScenario->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyStyles);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value CopyStyles", aCopyStyles);
+
+ propName = "CopyFormulas";
+ bool aCopyFormulas = false;
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyFormulas);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value CopyFormulas", aCopyFormulas);
+
+ aNewValue <<= false;
+ xScenario->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xScenario->getPropertyValue(propName) >>= aCopyFormulas);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value CopyFormulas", !aCopyFormulas);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/shape.cxx b/test/source/sheet/shape.cxx
new file mode 100644
index 000000000..ab2abec6e
--- /dev/null
+++ b/test/source/sheet/shape.cxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/shape.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void Shape::testShapePropertiesAnchor()
+{
+ uno::Reference<beans::XPropertySet> xShape(init(), UNO_QUERY_THROW);
+ uno::Any aNewValue;
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(getXSheetDocument(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_SET_THROW);
+ uno::Sequence<OUString> sheetNames = xSheets->getElementNames();
+ uno::Reference<sheet::XSpreadsheet> xSheet(xSheets->getByName(sheetNames[0]), UNO_QUERY_THROW);
+ uno::Reference<table::XCell> xCell(xSheet->getCellByPosition(0, 0), UNO_SET_THROW);
+
+ // Shape should be anchored to sheet by default
+ uno::Reference<sheet::XSpreadsheet> xSheetGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Anchor (XSpreadsheet)",
+ xShape->getPropertyValue("Anchor") >>= xSheetGet);
+
+ // Anchor the shape to a cell
+ aNewValue <<= xCell;
+ xShape->setPropertyValue("Anchor", aNewValue);
+ uno::Reference<table::XCell> xCellGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Anchor (XCell)",
+ xShape->getPropertyValue("Anchor") >>= xCellGet);
+
+ // Shape should not resize with cell by default
+ bool bIsResizeWithCell = {};
+ CPPUNIT_ASSERT(xShape->getPropertyValue("ResizeWithCell") >>= bIsResizeWithCell);
+ CPPUNIT_ASSERT_MESSAGE("Shape should not resize with the cell", !bIsResizeWithCell);
+
+ xShape->setPropertyValue("ResizeWithCell", uno::Any(true));
+ CPPUNIT_ASSERT(xShape->getPropertyValue("ResizeWithCell") >>= bIsResizeWithCell);
+ CPPUNIT_ASSERT_MESSAGE("Shape should resize with the cell", bIsResizeWithCell);
+
+ // Anchoring to a different cell should keep the "ResizeWithCell" attribute
+ uno::Reference<table::XCell> xCell2(xSheet->getCellByPosition(1, 2), UNO_SET_THROW);
+ aNewValue <<= xCell2;
+ xShape->setPropertyValue("Anchor", aNewValue);
+ CPPUNIT_ASSERT(xShape->getPropertyValue("ResizeWithCell") >>= bIsResizeWithCell);
+ CPPUNIT_ASSERT_MESSAGE("ResizeWithCell should still be set", bIsResizeWithCell);
+
+ // Now anchor to sheet again
+ aNewValue <<= xSheet;
+ xShape->setPropertyValue("Anchor", aNewValue);
+ CPPUNIT_ASSERT(xShape->getPropertyValue("Anchor") >>= xSheetGet);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Anchor (XSpreadsheet)",
+ xShape->getPropertyValue("Anchor") >>= xSheetGet);
+
+ // Setting ResizeWithCell while anchored to page should not have any effect
+ CPPUNIT_ASSERT(xShape->getPropertyValue("ResizeWithCell") >>= bIsResizeWithCell);
+ CPPUNIT_ASSERT_MESSAGE("ResizeWithCell should be false for sheet anchored shapes",
+ !bIsResizeWithCell);
+ xShape->setPropertyValue("ResizeWithCell", uno::Any(true));
+ CPPUNIT_ASSERT(xShape->getPropertyValue("ResizeWithCell") >>= bIsResizeWithCell);
+ CPPUNIT_ASSERT_MESSAGE("ResizeWithCell should be unchangeable for sheet anchored shapes",
+ !bIsResizeWithCell);
+}
+
+void Shape::testShapePropertiesPosition()
+{
+ uno::Reference<beans::XPropertySet> xShape(init(), UNO_QUERY_THROW);
+ uno::Any aNewValue;
+
+ sal_Int32 nHoriOrientPositionGet = 0;
+ sal_Int32 nHoriOrientPositionSet = 0;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HoriOrientPosition",
+ xShape->getPropertyValue("HoriOrientPosition")
+ >>= nHoriOrientPositionGet);
+
+ aNewValue <<= nHoriOrientPositionGet + 42;
+ xShape->setPropertyValue("HoriOrientPosition", aNewValue);
+ CPPUNIT_ASSERT(xShape->getPropertyValue("HoriOrientPosition") >>= nHoriOrientPositionSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue HoriOrientPosition",
+ nHoriOrientPositionGet + 42, nHoriOrientPositionSet);
+
+ sal_Int32 nVertOrientPositionGet = 0;
+ sal_Int32 nVertOrientPositionSet = 0;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue VertOrientPosition",
+ xShape->getPropertyValue("VertOrientPosition")
+ >>= nVertOrientPositionGet);
+
+ aNewValue <<= nVertOrientPositionGet + 42;
+ xShape->setPropertyValue("VertOrientPosition", aNewValue);
+ CPPUNIT_ASSERT(xShape->getPropertyValue("VertOrientPosition") >>= nVertOrientPositionSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue VertOrientPosition",
+ nVertOrientPositionGet + 42, nVertOrientPositionSet);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/sheetcell.cxx b/test/source/sheet/sheetcell.cxx
new file mode 100644
index 000000000..e30847367
--- /dev/null
+++ b/test/source/sheet/sheetcell.cxx
@@ -0,0 +1,215 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/cppunitasserthelper.hxx>
+#include <test/sheet/sheetcell.hxx>
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/ValidationType.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
+#include <com/sun/star/table/CellContentType.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SheetCell::testSheetCellProperties()
+{
+ uno::Reference<beans::XPropertySet> xSheetCell(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "Position";
+ awt::Point aPositionGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Position",
+ xSheetCell->getPropertyValue(propName) >>= aPositionGet);
+
+ awt::Point aPositionSet(42, 42);
+ aNewValue <<= aPositionSet;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aPositionSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue Position", aPositionGet, aPositionGet);
+
+ propName = "Size";
+ awt::Size aSizeGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Size",
+ xSheetCell->getPropertyValue(propName) >>= aSizeGet);
+
+ awt::Size aSizeSet(42, 42);
+ aNewValue <<= aSizeGet;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aSizeSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue Size", aSizeGet, aSizeSet);
+
+ propName = "FormulaLocal";
+ OUString aFormulaLocal = "";
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue FormulaLocal",
+ xSheetCell->getPropertyValue(propName) >>= aFormulaLocal);
+
+ aNewValue <<= OUString("FormulaLocal");
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aFormulaLocal);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue FormulaLocal",
+ OUString("FormulaLocal"), aFormulaLocal);
+
+ propName = "CellContentType";
+ table::CellContentType aCellContentTypeGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue CellContentType",
+ xSheetCell->getPropertyValue(propName) >>= aCellContentTypeGet);
+
+ table::CellContentType aCellContentTypeSet = table::CellContentType_TEXT;
+ aNewValue <<= aCellContentTypeSet;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aCellContentTypeSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue CellContentType", aCellContentTypeGet,
+ aCellContentTypeSet);
+
+ // Special case, because the API returns the wrong type.
+ propName = "FormulaResultType";
+ table::CellContentType aFormulaResultTypeGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue FormulaResultType",
+ xSheetCell->getPropertyValue(propName) >>= aFormulaResultTypeGet);
+
+ table::CellContentType aFormulaResultTypeSet = table::CellContentType_TEXT;
+ aNewValue <<= aFormulaResultTypeSet;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aFormulaResultTypeSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue FormulaResultType",
+ aFormulaResultTypeGet, aFormulaResultTypeSet);
+
+ propName = "FormulaResultType2";
+ sal_Int32 aFormulaResultType2Get = 42;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue FormulaResultType2",
+ xSheetCell->getPropertyValue(propName) >>= aFormulaResultType2Get);
+
+ sal_Int32 aFormulaResultType2Set = 42;
+ aNewValue <<= aFormulaResultType2Set;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aFormulaResultType2Set);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue FormulaResultType2",
+ aFormulaResultType2Get, aFormulaResultType2Set);
+
+ uno::Sequence<beans::PropertyValue> aPropValue(1);
+ aPropValue[0].Name = "StyleName";
+ aPropValue[0].Value <<= OUString("Result2");
+
+ propName = "ConditionalFormat";
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatGet;
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ConditionalFormat",
+ xSheetCell->getPropertyValue(propName) >>= aConditionalFormatGet);
+
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatNew(aConditionalFormatGet,
+ UNO_SET_THROW);
+ aConditionalFormatNew->addNew(aPropValue);
+
+ aNewValue <<= aConditionalFormatNew;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aConditionalFormatSet);
+ for (auto i = 0; i < aConditionalFormatSet->getCount(); i++)
+ {
+ uno::Reference<sheet::XSheetConditionalEntry> xSCENew(aConditionalFormatNew->getByIndex(i),
+ UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetConditionalEntry> xSCESet(aConditionalFormatSet->getByIndex(i),
+ UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ConditionalFormat["
+ + std::to_string(i) + "]",
+ xSCENew->getStyleName(), xSCESet->getStyleName());
+ }
+
+ propName = "ConditionalFormatLocal";
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalGet;
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ConditionalFormatLocal",
+ xSheetCell->getPropertyValue(propName) >>= aConditionalFormatLocalGet);
+
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalNew(
+ aConditionalFormatLocalGet, UNO_SET_THROW);
+ aConditionalFormatLocalNew->addNew(aPropValue);
+
+ aNewValue <<= aConditionalFormatLocalNew;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aConditionalFormatLocalSet);
+ for (auto i = 0; i < aConditionalFormatLocalSet->getCount(); i++)
+ {
+ uno::Reference<sheet::XSheetConditionalEntry> xSCENew(
+ aConditionalFormatLocalNew->getByIndex(i), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetConditionalEntry> xSCESet(
+ aConditionalFormatLocalSet->getByIndex(i), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ConditionalFormatLocal["
+ + std::to_string(i) + "]",
+ xSCENew->getStyleName(), xSCESet->getStyleName());
+ }
+
+ propName = "Validation";
+ uno::Reference<beans::XPropertySet> aValidationGet;
+ uno::Reference<beans::XPropertySet> aValidationSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Validation",
+ xSheetCell->getPropertyValue(propName) >>= aValidationGet);
+
+ uno::Reference<beans::XPropertySet> aValidationNew(aValidationGet, UNO_SET_THROW);
+ uno::Any aValidationType;
+ aValidationType <<= sheet::ValidationType_WHOLE;
+ aValidationNew->setPropertyValue("Type", aValidationType);
+
+ aNewValue <<= aValidationNew;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aValidationSet);
+ sheet::ValidationType aType;
+ aValidationSet->getPropertyValue("Type") >>= aType;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Validation",
+ sheet::ValidationType_WHOLE, aType);
+
+ propName = "ValidationLocal";
+ uno::Reference<beans::XPropertySet> aValidationLocalGet;
+ uno::Reference<beans::XPropertySet> aValidationLocalSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ValidationLocal",
+ xSheetCell->getPropertyValue(propName) >>= aValidationLocalGet);
+
+ uno::Reference<beans::XPropertySet> aValidationLocalNew(aValidationLocalGet, UNO_SET_THROW);
+ aValidationType <<= sheet::ValidationType_WHOLE;
+ aValidationLocalNew->setPropertyValue("Type", aValidationType);
+
+ aNewValue <<= aValidationLocalNew;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aValidationLocalSet);
+ aValidationLocalSet->getPropertyValue("Type") >>= aType;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ValidationLocal",
+ sheet::ValidationType_WHOLE, aType);
+
+ propName = "AbsoluteName";
+ OUString aAbsoluteNameGet = "";
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue AbsoluteName",
+ xSheetCell->getPropertyValue(propName) >>= aAbsoluteNameGet);
+
+ OUString aAbsoluteNameSet = "$Sheet1.$C$3";
+ aNewValue <<= aAbsoluteNameSet;
+ xSheetCell->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCell->getPropertyValue(propName) >>= aAbsoluteNameSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue AbsoluteName", aAbsoluteNameGet,
+ aAbsoluteNameSet);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/sheetcellrange.cxx b/test/source/sheet/sheetcellrange.cxx
new file mode 100644
index 000000000..93d121b3b
--- /dev/null
+++ b/test/source/sheet/sheetcellrange.cxx
@@ -0,0 +1,167 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/cppunitasserthelper.hxx>
+#include <test/sheet/sheetcellrange.hxx>
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/ValidationType.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SheetCellRange::testSheetCellRangeProperties()
+{
+ uno::Reference<beans::XPropertySet> xSheetCellRange(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "Position";
+ awt::Point aPositionGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Position",
+ xSheetCellRange->getPropertyValue(propName) >>= aPositionGet);
+
+ awt::Point aPositionSet(42, 42);
+ aNewValue <<= aPositionSet;
+ xSheetCellRange->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aPositionSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue Position", aPositionGet, aPositionGet);
+
+ propName = "Size";
+ awt::Size aSizeGet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Size",
+ xSheetCellRange->getPropertyValue(propName) >>= aSizeGet);
+
+ awt::Size aSizeSet(42, 42);
+ aNewValue <<= aSizeGet;
+ xSheetCellRange->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aSizeSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue Size", aSizeGet, aSizeSet);
+
+ uno::Sequence<beans::PropertyValue> aPropValue(1);
+ aPropValue[0].Name = "StyleName";
+ aPropValue[0].Value <<= OUString("Result2");
+
+ propName = "ConditionalFormat";
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatGet;
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ConditionalFormat",
+ xSheetCellRange->getPropertyValue(propName) >>= aConditionalFormatGet);
+
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatNew(aConditionalFormatGet,
+ UNO_SET_THROW);
+ aConditionalFormatNew->addNew(aPropValue);
+
+ aNewValue <<= aConditionalFormatNew;
+ xSheetCellRange->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aConditionalFormatSet);
+ for (auto i = 0; i < aConditionalFormatSet->getCount(); i++)
+ {
+ uno::Reference<sheet::XSheetConditionalEntry> xSCENew(aConditionalFormatNew->getByIndex(i),
+ UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetConditionalEntry> xSCESet(aConditionalFormatSet->getByIndex(i),
+ UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ConditionalFormat["
+ + std::to_string(i) + "]",
+ xSCENew->getStyleName(), xSCESet->getStyleName());
+ }
+
+ propName = "ConditionalFormatLocal";
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalGet;
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ConditionalFormatLocal",
+ xSheetCellRange->getPropertyValue(propName)
+ >>= aConditionalFormatLocalGet);
+
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalNew(
+ aConditionalFormatLocalGet, UNO_SET_THROW);
+ aConditionalFormatLocalNew->addNew(aPropValue);
+
+ aNewValue <<= aConditionalFormatLocalNew;
+ xSheetCellRange->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aConditionalFormatLocalSet);
+ for (auto i = 0; i < aConditionalFormatLocalSet->getCount(); i++)
+ {
+ uno::Reference<sheet::XSheetConditionalEntry> xSCENew(
+ aConditionalFormatLocalNew->getByIndex(i), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetConditionalEntry> xSCESet(
+ aConditionalFormatLocalSet->getByIndex(i), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ConditionalFormatLocal["
+ + std::to_string(i) + "]",
+ xSCENew->getStyleName(), xSCESet->getStyleName());
+ }
+
+ propName = "Validation";
+ uno::Reference<beans::XPropertySet> aValidationGet;
+ uno::Reference<beans::XPropertySet> aValidationSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Validation",
+ xSheetCellRange->getPropertyValue(propName) >>= aValidationGet);
+
+ uno::Reference<beans::XPropertySet> aValidationNew(aValidationGet, UNO_SET_THROW);
+ uno::Any aValidationType;
+ aValidationType <<= sheet::ValidationType_WHOLE;
+ aValidationNew->setPropertyValue("Type", aValidationType);
+
+ aNewValue <<= aValidationNew;
+ xSheetCellRange->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aValidationSet);
+ sheet::ValidationType aType;
+ aValidationSet->getPropertyValue("Type") >>= aType;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Validation",
+ sheet::ValidationType_WHOLE, aType);
+
+ propName = "ValidationLocal";
+ uno::Reference<beans::XPropertySet> aValidationLocalGet;
+ uno::Reference<beans::XPropertySet> aValidationLocalSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ValidationLocal",
+ xSheetCellRange->getPropertyValue(propName) >>= aValidationLocalGet);
+
+ uno::Reference<beans::XPropertySet> aValidationLocalNew(aValidationLocalGet, UNO_SET_THROW);
+ aValidationType <<= sheet::ValidationType_WHOLE;
+ aValidationLocalNew->setPropertyValue("Type", aValidationType);
+
+ aNewValue <<= aValidationLocalNew;
+ xSheetCellRange->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aValidationLocalSet);
+ aValidationLocalSet->getPropertyValue("Type") >>= aType;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ValidationLocal",
+ sheet::ValidationType_WHOLE, aType);
+
+ propName = "AbsoluteName";
+ OUString aAbsoluteNameGet = "";
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue AbsoluteName",
+ xSheetCellRange->getPropertyValue(propName) >>= aAbsoluteNameGet);
+
+ OUString aAbsoluteNameSet = "$Sheet1.$C$3";
+ aNewValue <<= aAbsoluteNameSet;
+ xSheetCellRange->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRange->getPropertyValue(propName) >>= aAbsoluteNameSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue AbsoluteName", aAbsoluteNameGet,
+ aAbsoluteNameSet);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/sheetcellranges.cxx b/test/source/sheet/sheetcellranges.cxx
new file mode 100644
index 000000000..d48d28e00
--- /dev/null
+++ b/test/source/sheet/sheetcellranges.cxx
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/sheetcellranges.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/ValidationType.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SheetCellRanges::testSheetCellRangesProperties()
+{
+ uno::Reference<beans::XPropertySet> xSheetCellRanges(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ uno::Sequence<beans::PropertyValue> aPropValue(1);
+ aPropValue[0].Name = "StyleName";
+ aPropValue[0].Value <<= OUString("Result2");
+
+ propName = "ConditionalFormat";
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatGet;
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ConditionalFormat",
+ xSheetCellRanges->getPropertyValue(propName) >>= aConditionalFormatGet);
+
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatNew(aConditionalFormatGet,
+ UNO_SET_THROW);
+ aConditionalFormatNew->addNew(aPropValue);
+
+ aNewValue <<= aConditionalFormatNew;
+ xSheetCellRanges->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRanges->getPropertyValue(propName) >>= aConditionalFormatSet);
+ for (auto i = 0; i < aConditionalFormatSet->getCount(); i++)
+ {
+ uno::Reference<sheet::XSheetConditionalEntry> xSCENew(aConditionalFormatNew->getByIndex(i),
+ UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetConditionalEntry> xSCESet(aConditionalFormatSet->getByIndex(i),
+ UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ConditionalFormat["
+ + std::to_string(i) + "]",
+ xSCENew->getStyleName(), xSCESet->getStyleName());
+ }
+
+ propName = "ConditionalFormatLocal";
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalGet;
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ConditionalFormatLocal",
+ xSheetCellRanges->getPropertyValue(propName)
+ >>= aConditionalFormatLocalGet);
+
+ uno::Reference<sheet::XSheetConditionalEntries> aConditionalFormatLocalNew(
+ aConditionalFormatLocalGet, UNO_SET_THROW);
+ aConditionalFormatLocalNew->addNew(aPropValue);
+
+ aNewValue <<= aConditionalFormatLocalNew;
+ xSheetCellRanges->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRanges->getPropertyValue(propName) >>= aConditionalFormatLocalSet);
+ for (auto i = 0; i < aConditionalFormatLocalSet->getCount(); i++)
+ {
+ uno::Reference<sheet::XSheetConditionalEntry> xSCENew(
+ aConditionalFormatLocalNew->getByIndex(i), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetConditionalEntry> xSCESet(
+ aConditionalFormatLocalSet->getByIndex(i), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ConditionalFormatLocal["
+ + std::to_string(i) + "]",
+ xSCENew->getStyleName(), xSCESet->getStyleName());
+ }
+
+ propName = "Validation";
+ uno::Reference<beans::XPropertySet> aValidationGet;
+ uno::Reference<beans::XPropertySet> aValidationSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Validation",
+ xSheetCellRanges->getPropertyValue(propName) >>= aValidationGet);
+
+ uno::Reference<beans::XPropertySet> aValidationNew(aValidationGet, UNO_SET_THROW);
+ uno::Any aValidationType;
+ aValidationType <<= sheet::ValidationType_WHOLE;
+ aValidationNew->setPropertyValue("Type", aValidationType);
+
+ aNewValue <<= aValidationNew;
+ xSheetCellRanges->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRanges->getPropertyValue(propName) >>= aValidationSet);
+ sheet::ValidationType aType;
+ aValidationSet->getPropertyValue("Type") >>= aType;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Validation",
+ sheet::ValidationType_WHOLE, aType);
+
+ propName = "ValidationLocal";
+ uno::Reference<beans::XPropertySet> aValidationLocalGet;
+ uno::Reference<beans::XPropertySet> aValidationLocalSet;
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ValidationLocal",
+ xSheetCellRanges->getPropertyValue(propName) >>= aValidationLocalGet);
+
+ uno::Reference<beans::XPropertySet> aValidationLocalNew(aValidationLocalGet, UNO_SET_THROW);
+ aValidationType <<= sheet::ValidationType_WHOLE;
+ aValidationLocalNew->setPropertyValue("Type", aValidationType);
+
+ aNewValue <<= aValidationLocalNew;
+ xSheetCellRanges->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRanges->getPropertyValue(propName) >>= aValidationLocalSet);
+ aValidationLocalSet->getPropertyValue("Type") >>= aType;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ValidationLocal",
+ sheet::ValidationType_WHOLE, aType);
+
+ propName = "AbsoluteName";
+ OUString aAbsoluteNameGet = "";
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue AbsoluteName",
+ xSheetCellRanges->getPropertyValue(propName) >>= aAbsoluteNameGet);
+
+ OUString aAbsoluteNameSet = "$Sheet1.$C$3";
+ aNewValue <<= aAbsoluteNameSet;
+ xSheetCellRanges->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetCellRanges->getPropertyValue(propName) >>= aAbsoluteNameSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue AbsoluteName", aAbsoluteNameGet,
+ aAbsoluteNameSet);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/sheetfilterdescriptor.cxx b/test/source/sheet/sheetfilterdescriptor.cxx
new file mode 100644
index 000000000..3a0b1364d
--- /dev/null
+++ b/test/source/sheet/sheetfilterdescriptor.cxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/cppunitasserthelper.hxx>
+#include <test/sheet/sheetfilterdescriptor.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/TableOrientation.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SheetFilterDescriptor::testSheetFilterDescriptorProperties()
+{
+ uno::Reference<beans::XPropertySet> xSheetFilterDescriptor(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "IsCaseSensitive";
+ bool bIsCaseSensitiveGet = false;
+ bool bIsCaseSensitiveSet = false;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsCaseSensitive",
+ xSheetFilterDescriptor->getPropertyValue(propName)
+ >>= bIsCaseSensitiveGet);
+
+ aNewValue <<= !bIsCaseSensitiveGet;
+ xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bIsCaseSensitiveSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue IsCaseSensitive",
+ !bIsCaseSensitiveGet, bIsCaseSensitiveSet);
+
+ propName = "SkipDuplicates";
+ bool bSkipDuplicatesGet = false;
+ bool bSkipDuplicatesSet = false;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue SkipDuplicates",
+ xSheetFilterDescriptor->getPropertyValue(propName)
+ >>= bSkipDuplicatesGet);
+
+ aNewValue <<= !bSkipDuplicatesGet;
+ xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bSkipDuplicatesSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue SkipDuplicates", !bSkipDuplicatesGet,
+ bSkipDuplicatesSet);
+
+ propName = "UseRegularExpressions";
+ bool bUseRegularExpressionsGet = false;
+ bool bUseRegularExpressionsSet = false;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue UseRegularExpressions",
+ xSheetFilterDescriptor->getPropertyValue(propName)
+ >>= bUseRegularExpressionsGet);
+
+ aNewValue <<= !bUseRegularExpressionsGet;
+ xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName)
+ >>= bUseRegularExpressionsSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue UseRegularExpressions",
+ !bUseRegularExpressionsGet, bUseRegularExpressionsSet);
+
+ propName = "SaveOutputPosition";
+ bool bSaveOutputPositionGet = false;
+ bool bSaveOutputPositionSet = false;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue SaveOutputPosition",
+ xSheetFilterDescriptor->getPropertyValue(propName)
+ >>= bSaveOutputPositionGet);
+
+ aNewValue <<= !bSaveOutputPositionGet;
+ xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bSaveOutputPositionSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue SaveOutputPosition",
+ !bSaveOutputPositionGet, bSaveOutputPositionSet);
+
+ propName = "Orientation";
+ table::TableOrientation aOrientationGet;
+ table::TableOrientation aOrientationSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Orientation",
+ xSheetFilterDescriptor->getPropertyValue(propName) >>= aOrientationGet);
+
+ aNewValue <<= table::TableOrientation_COLUMNS;
+ xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= aOrientationSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Orientation",
+ table::TableOrientation_COLUMNS, aOrientationSet);
+
+ propName = "ContainsHeader";
+ bool bContainsHeaderGet = false;
+ bool bContainsHeaderSet = false;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ContainsHeader",
+ xSheetFilterDescriptor->getPropertyValue(propName)
+ >>= bContainsHeaderGet);
+
+ aNewValue <<= !bContainsHeaderGet;
+ xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bContainsHeaderSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ContainsHeader", !bContainsHeaderGet,
+ bContainsHeaderSet);
+
+ propName = "CopyOutputData";
+ bool bCopyOutputDataGet = false;
+ bool bCopyOutputDataSet = false;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue CopyOutputData",
+ xSheetFilterDescriptor->getPropertyValue(propName)
+ >>= bCopyOutputDataGet);
+
+ aNewValue <<= !bCopyOutputDataGet;
+ xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= bCopyOutputDataSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue CopyOutputData", !bCopyOutputDataGet,
+ bCopyOutputDataSet);
+
+ propName = "OutputPosition";
+ table::CellAddress aCellAddressGet;
+ table::CellAddress aCellAddressSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue OutputPosition",
+ xSheetFilterDescriptor->getPropertyValue(propName) >>= aCellAddressGet);
+
+ aCellAddressGet = table::CellAddress(0, 42, 42);
+ aNewValue <<= aCellAddressGet;
+ xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= aCellAddressSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue OutputPosition", aCellAddressGet,
+ aCellAddressSet);
+
+ propName = "MaxFieldCount";
+ sal_Int32 nMaxFieldCountGet = 0;
+ sal_Int32 nMaxFieldCountSet = 0;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue MaxFieldCount",
+ xSheetFilterDescriptor->getPropertyValue(propName)
+ >>= nMaxFieldCountGet);
+
+ aNewValue <<= nMaxFieldCountGet + 42;
+ xSheetFilterDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetFilterDescriptor->getPropertyValue(propName) >>= nMaxFieldCountSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue MaxFieldCount", nMaxFieldCountGet,
+ nMaxFieldCountSet);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/sheetlink.cxx b/test/source/sheet/sheetlink.cxx
new file mode 100644
index 000000000..de6a2148e
--- /dev/null
+++ b/test/source/sheet/sheetlink.cxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/sheetlink.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SheetLink::testSheetLinkProperties()
+{
+ uno::Reference<beans::XPropertySet> xSheetLink(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "Url";
+ OUString aUrlGet;
+ OUString aUrlSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Url",
+ xSheetLink->getPropertyValue(propName) >>= aUrlGet);
+
+ aNewValue <<= OUString("file:///tmp/ScSheetLinkObj.ods");
+ xSheetLink->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aUrlSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Url",
+ OUString("file:///tmp/ScSheetLinkObj.ods"), aUrlSet);
+
+ propName = "Filter";
+ OUString aFilterGet;
+ OUString aFilterSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue Filter",
+ xSheetLink->getPropertyValue(propName) >>= aFilterGet);
+
+ aNewValue <<= OUString("Text - txt - csv (StarCalc)");
+ xSheetLink->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aFilterSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue Filter",
+ OUString("Text - txt - csv (StarCalc)"), aFilterSet);
+
+ propName = "FilterOptions";
+ OUString aFilterOptionsGet;
+ OUString aFilterOptionsSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue FilterOptions",
+ xSheetLink->getPropertyValue(propName) >>= aFilterOptionsGet);
+
+ aNewValue <<= OUString("NewValue");
+ xSheetLink->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSheetLink->getPropertyValue(propName) >>= aFilterOptionsSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue FilterOptions", OUString("NewValue"),
+ aFilterOptionsSet);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/sheetsortdescriptor2.cxx b/test/source/sheet/sheetsortdescriptor2.cxx
new file mode 100644
index 000000000..3f84d9577
--- /dev/null
+++ b/test/source/sheet/sheetsortdescriptor2.cxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+//#include <test/cppunitasserthelper.hxx>
+#include <test/sheet/sheetsortdescriptor2.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/util/XSortable.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/TableSortField.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+#include <vector>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SheetSortDescriptor2::testSheetSortDescriptor2Properties()
+{
+ uno::Reference<util::XSortable> xSortable(init(), UNO_QUERY_THROW);
+ const uno::Sequence<beans::PropertyValue> values = xSortable->createSortDescriptor();
+
+ std::vector<OUString> names;
+ // Only test the get/read operation of the values, because set/write operation doesn't
+ // make any sense. It doesn't trigger any changes.
+ // See discussion: nabble.documentfoundation.org/Testing-UNO-API-service-properties-td4236286.html.
+ for (const auto& value : values)
+ {
+ if (value.Name == "BindFormatsToContent")
+ {
+ names.push_back(value.Name);
+ bool bValue = false;
+ CPPUNIT_ASSERT(value.Value >>= bValue);
+ }
+ else if (value.Name == "IsUserListEnabled")
+ {
+ names.push_back(value.Name);
+ bool bValue = false;
+ CPPUNIT_ASSERT(value.Value >>= bValue);
+ }
+ else if (value.Name == "UserListIndex")
+ {
+ names.push_back(value.Name);
+ sal_Int32 nValue = 0;
+ CPPUNIT_ASSERT(value.Value >>= nValue);
+ }
+ else if (value.Name == "CopyOutputData")
+ {
+ names.push_back(value.Name);
+ bool bValue = false;
+ CPPUNIT_ASSERT(value.Value >>= bValue);
+ }
+ else if (value.Name == "OutputPosition")
+ {
+ names.push_back(value.Name);
+ table::CellAddress cellAddr;
+ CPPUNIT_ASSERT(value.Value >>= cellAddr);
+ }
+ else if (value.Name == "SortFields")
+ {
+ names.push_back(value.Name);
+ uno::Sequence<table::TableSortField> sSortFields;
+ CPPUNIT_ASSERT(value.Value >>= sSortFields);
+ }
+ else if (value.Name == "MaxFieldCount")
+ {
+ names.push_back(value.Name);
+ sal_Int32 nValue = 0;
+ CPPUNIT_ASSERT(value.Value >>= nValue);
+ }
+ else if (value.Name == "IsSortColumns")
+ {
+ names.push_back(value.Name);
+ bool bValue = false;
+ CPPUNIT_ASSERT(value.Value >>= bValue);
+ }
+ else if (value.Name == "ContainsHeader")
+ {
+ names.push_back(value.Name);
+ bool bValue = false;
+ CPPUNIT_ASSERT(value.Value >>= bValue);
+ }
+ else
+ {
+ OString sMsg = "Unsupported PropertyValue: "
+ + OUStringToOString(value.Name, RTL_TEXTENCODING_UTF8);
+ CPPUNIT_FAIL(sMsg.getStr());
+ }
+ }
+
+ CPPUNIT_ASSERT_MESSAGE("Property BindFormatsToContent not found",
+ std::count(std::begin(names), std::end(names), "BindFormatsToContent"));
+ CPPUNIT_ASSERT_MESSAGE("Property IsUserListEnabled not found",
+ std::count(std::begin(names), std::end(names), "IsUserListEnabled"));
+ CPPUNIT_ASSERT_MESSAGE("Property UserListIndex not found",
+ std::count(std::begin(names), std::end(names), "UserListIndex"));
+ CPPUNIT_ASSERT_MESSAGE("Property CopyOutputData not found",
+ std::count(std::begin(names), std::end(names), "CopyOutputData"));
+ CPPUNIT_ASSERT_MESSAGE("Property OutputPosition not found",
+ std::count(std::begin(names), std::end(names), "OutputPosition"));
+ CPPUNIT_ASSERT_MESSAGE("Property SortFields not found",
+ std::count(std::begin(names), std::end(names), "SortFields"));
+ CPPUNIT_ASSERT_MESSAGE("Property MaxFieldCount not found",
+ std::count(std::begin(names), std::end(names), "MaxFieldCount"));
+ CPPUNIT_ASSERT_MESSAGE("Property IsSortColumns not found",
+ std::count(std::begin(names), std::end(names), "IsSortColumns"));
+ CPPUNIT_ASSERT_MESSAGE("Property ContainsHeader not found",
+ std::count(std::begin(names), std::end(names), "ContainsHeader"));
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/spreadsheet.cxx b/test/source/sheet/spreadsheet.cxx
new file mode 100644
index 000000000..8e2ca12cf
--- /dev/null
+++ b/test/source/sheet/spreadsheet.cxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/spreadsheet.hxx>
+#include <test/unoapi_property_testers.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sheet/XConditionalFormats.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/text/WritingMode2.hpp>
+#include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void Spreadsheet::testSpreadsheetProperties()
+{
+ uno::Reference<beans::XPropertySet> xSpreadsheet(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "IsVisible";
+ testBooleanProperty(xSpreadsheet, propName);
+
+ propName = "PageStyle";
+ testStringProperty(xSpreadsheet, propName, "Report");
+
+ propName = "TableLayout";
+ testShortProperty(xSpreadsheet, propName, text::WritingMode2::RL_TB);
+
+ propName = "AutomaticPrintArea";
+ testBooleanProperty(xSpreadsheet, propName);
+
+ propName = "TabColor";
+ util::Color aColorGet;
+ util::Color aColorSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: TabColor",
+ xSpreadsheet->getPropertyValue(propName) >>= aColorGet);
+
+ aNewValue <<= util::Color(42);
+ xSpreadsheet->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheet->getPropertyValue(propName) >>= aColorSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: TabColor", util::Color(42),
+ aColorSet);
+
+ propName = "ConditionalFormats";
+ uno::Reference<sheet::XConditionalFormats> xConditionalFormatsGet;
+ uno::Reference<sheet::XConditionalFormats> xConditionalFormatsSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ConditionalFormats",
+ xSpreadsheet->getPropertyValue(propName) >>= xConditionalFormatsGet);
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(getXSpreadsheetDocument(), UNO_QUERY_THROW);
+ uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), UNO_QUERY_THROW);
+
+ uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, UNO_QUERY_THROW);
+ uno::Reference<container::XNameContainer> xRanges(
+ xMSF->createInstance("com.sun.star.sheet.SheetCellRanges"), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xSheetCellRanges(xRanges, UNO_QUERY_THROW);
+
+ uno::Any xCellRange;
+ xCellRange <<= xSheet->getCellRangeByName("C1:D4");
+ xRanges->insertByName("Range1", xCellRange);
+ xConditionalFormatsGet->createByRange(xSheetCellRanges);
+
+ aNewValue <<= xConditionalFormatsGet;
+ xSpreadsheet->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheet->getPropertyValue(propName) >>= xConditionalFormatsSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: ConditionalFormats", sal_Int32(1),
+ xConditionalFormatsSet->getLength());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/spreadsheetdocumentsettings.cxx b/test/source/sheet/spreadsheetdocumentsettings.cxx
new file mode 100644
index 000000000..a1eec4d0d
--- /dev/null
+++ b/test/source/sheet/spreadsheetdocumentsettings.cxx
@@ -0,0 +1,190 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/unoapi_property_testers.hxx>
+#include <test/sheet/spreadsheetdocumentsettings.hxx>
+
+#include <com/sun/star/awt/XDevice.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SpreadsheetDocumentSettings::testSpreadsheetDocumentSettingsProperties()
+{
+ uno::Reference<beans::XPropertySet> xSpreadsheetDocumentSettings(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "IsIterationEnabled";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IterationCount";
+ testLongProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IterationEpsilon";
+ testDoubleProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "StandardDecimals";
+ testShortProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "NullDate";
+ util::Date aNullDateGet;
+ util::Date aNullDateSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: NullDate",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aNullDateGet);
+
+ aNewValue <<= util::Date(1, 1, 2000);
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= aNullDateSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: NullDate", sal_Int16(2000),
+ aNullDateSet.Year);
+
+ propName = "DefaultTabStop";
+ testShortProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IgnoreCase";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "CalcAsShown";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "MatchWholeCell";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "SpellOnline";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "LookUpLabels";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "RegularExpressions";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "ForbiddenCharacters";
+ uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersGet;
+ uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ForbiddenCharacters",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= xForbiddenCharactersGet);
+
+ lang::Locale aForbiddenCharactersLocale;
+ aForbiddenCharactersLocale.Language = "ru";
+ aForbiddenCharactersLocale.Country = "RU";
+
+ uno::Reference<i18n::XForbiddenCharacters> xForbiddenCharactersNew;
+ aNewValue <<= xForbiddenCharactersNew;
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= xForbiddenCharactersSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Able to set PropertyValue: ForbiddenCharacters",
+ xForbiddenCharactersGet->hasForbiddenCharacters(aForbiddenCharactersLocale),
+ xForbiddenCharactersSet->hasForbiddenCharacters(aForbiddenCharactersLocale));
+
+ propName = "HasDrawPages";
+ testBooleanReadonlyProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "CharLocale";
+ lang::Locale aCharLocaleGet;
+ lang::Locale aCharLocaleSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocale",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aCharLocaleGet);
+
+ lang::Locale aCharLocaleNew;
+ aCharLocaleNew.Language = "en";
+ aCharLocaleNew.Country = "CA";
+ aNewValue <<= aCharLocaleNew;
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= aCharLocaleSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocale", aCharLocaleNew.Country,
+ aCharLocaleSet.Country);
+
+ propName = "CharLocaleAsian";
+ lang::Locale aCharLocaleAsianGet;
+ lang::Locale aCharLocaleAsianSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocaleAsian",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aCharLocaleAsianGet);
+
+ lang::Locale aCharLocaleAsianNew;
+ aCharLocaleAsianNew.Language = "en";
+ aCharLocaleAsianNew.Country = "CA";
+ aNewValue <<= aCharLocaleAsianNew;
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aCharLocaleAsianSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocaleAsian",
+ aCharLocaleAsianNew.Country, aCharLocaleAsianSet.Country);
+
+ propName = "CharLocaleComplex";
+ lang::Locale aCharLocaleComplexGet;
+ lang::Locale aCharLocaleComplexSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: CharLocaleComplex",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aCharLocaleComplexGet);
+
+ lang::Locale aCharLocaleComplexNew;
+ aCharLocaleComplexNew.Language = "en";
+ aCharLocaleComplexNew.Country = "CA";
+ aNewValue <<= aCharLocaleComplexNew;
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName)
+ >>= aCharLocaleComplexSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue: CharLocaleComplex",
+ aCharLocaleComplexNew.Country, aCharLocaleComplexSet.Country);
+
+ propName = "IsLoaded";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IsUndoEnabled";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IsAdjustHeightEnabled";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IsExecuteLinkEnabled";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "ReferenceDevice";
+ uno::Reference<awt::XDevice> xDeviceGet;
+ uno::Reference<awt::XDevice> xDeviceSet;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue: ReferenceDevice",
+ xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= xDeviceGet);
+
+ uno::Reference<awt::XDevice> xDeviceNew;
+ aNewValue <<= xDeviceNew;
+ xSpreadsheetDocumentSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetDocumentSettings->getPropertyValue(propName) >>= xDeviceSet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Able to set PropertyValue: ReferenceDevice",
+ xDeviceSet->getInfo().Width, xDeviceGet->getInfo().Width);
+
+ propName = "RecordChanges";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "IsRecordChangesProtected";
+ testBooleanReadonlyProperty(xSpreadsheetDocumentSettings, propName);
+
+ propName = "Wildcards";
+ testBooleanProperty(xSpreadsheetDocumentSettings, propName);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/spreadsheetviewsettings.cxx b/test/source/sheet/spreadsheetviewsettings.cxx
new file mode 100644
index 000000000..b77bcb4c6
--- /dev/null
+++ b/test/source/sheet/spreadsheetviewsettings.cxx
@@ -0,0 +1,241 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/spreadsheetviewsettings.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SpreadsheetViewSettings::testSpreadsheetViewSettingsProperties()
+{
+ uno::Reference<beans::XPropertySet> xSpreadsheetViewSettings(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "ShowFormulas";
+ bool aShowFormulas = true;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowFormulas);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowFormulas", !aShowFormulas);
+
+ aNewValue <<= true;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowFormulas);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowFormulas", aShowFormulas);
+
+ propName = "ShowZeroValues";
+ bool aShowZeroValues = false;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowZeroValues);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowZeroValues", aShowZeroValues);
+
+ aNewValue <<= false;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowZeroValues);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowZeroValues", !aShowZeroValues);
+
+ propName = "IsValueHighlightingEnabled";
+ bool aIsValueHighlightingEnabled = true;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName)
+ >>= aIsValueHighlightingEnabled);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsValueHighlightingEnabled",
+ !aIsValueHighlightingEnabled);
+
+ aNewValue <<= true;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName)
+ >>= aIsValueHighlightingEnabled);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue IsValueHighlightingEnabled",
+ aIsValueHighlightingEnabled);
+
+ propName = "ShowNotes";
+ bool aShowNotes = false;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowNotes);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowNotes", aShowNotes);
+
+ aNewValue <<= false;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowNotes);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowNotes", !aShowNotes);
+
+ propName = "HasVerticalScrollBar";
+ bool aHasVerticalScrollBar = false;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasVerticalScrollBar);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HasVerticalScrollBar",
+ aHasVerticalScrollBar);
+
+ aNewValue <<= false;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasVerticalScrollBar);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue HasVerticalScrollBar",
+ !aHasVerticalScrollBar);
+
+ propName = "HasHorizontalScrollBar";
+ bool aHasHorizontalScrollBar = false;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName)
+ >>= aHasHorizontalScrollBar);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HasHorizontalScrollBar",
+ aHasHorizontalScrollBar);
+
+ aNewValue <<= false;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName)
+ >>= aHasHorizontalScrollBar);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue HasHorizontalScrollBar",
+ !aHasHorizontalScrollBar);
+
+ propName = "HasSheetTabs";
+ bool aHasSheetTabs = false;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasSheetTabs);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HasSheetTabs", aHasSheetTabs);
+
+ aNewValue <<= false;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasSheetTabs);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue HasSheetTabs", !aHasSheetTabs);
+
+ propName = "IsOutlineSymbolsSet";
+ bool aIsOutlineSymbolsSet = false;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aIsOutlineSymbolsSet);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsOutlineSymbolsSet", aIsOutlineSymbolsSet);
+
+ aNewValue <<= false;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aIsOutlineSymbolsSet);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue IsOutlineSymbolsSet",
+ !aIsOutlineSymbolsSet);
+
+ propName = "HasColumnRowHeaders";
+ bool aHasColumnRowHeaders = false;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasColumnRowHeaders);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue HasColumnRowHeaders", aHasColumnRowHeaders);
+
+ aNewValue <<= false;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aHasColumnRowHeaders);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue HasColumnRowHeaders",
+ !aHasColumnRowHeaders);
+
+ propName = "ShowGrid";
+ bool aShowGrid = false;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowGrid);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowGrid", aShowGrid);
+
+ aNewValue <<= false;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowGrid);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowGrid", !aShowGrid);
+
+ propName = "GridColor";
+ util::Color aGridColor;
+ xSpreadsheetViewSettings->getPropertyValue(propName) >>= aGridColor;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue GridColor", sal_Int32(12632256),
+ aGridColor);
+
+ aNewValue <<= sal_Int32(42);
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ xSpreadsheetViewSettings->getPropertyValue(propName) >>= aGridColor;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue GridColor", sal_Int32(42),
+ aGridColor);
+
+ propName = "ShowHelpLines";
+ bool aShowHelpLines = true;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowHelpLines);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowHelpLines", !aShowHelpLines);
+
+ aNewValue <<= true;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowHelpLines);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowHelpLines", aShowHelpLines);
+
+ propName = "ShowAnchor";
+ bool aShowAnchor = false;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowAnchor);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowAnchor", aShowAnchor);
+
+ aNewValue <<= false;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowAnchor);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowAnchor", !aShowAnchor);
+
+ propName = "ShowPageBreaks";
+ bool aShowPageBreaks = false;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowPageBreaks);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue ShowPageBreaks", aShowPageBreaks);
+
+ aNewValue <<= false;
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowPageBreaks);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue ShowPageBreaks", !aShowPageBreaks);
+
+ propName = "ShowObjects";
+ sal_Int16 aShowObjects = 42;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowObjects);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue ShowObjects", sal_Int16(0),
+ aShowObjects);
+
+ aNewValue <<= sal_Int16(1);
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowObjects);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ShowObjects", sal_Int16(1),
+ aShowObjects);
+
+ propName = "ShowCharts";
+ sal_Int16 aShowCharts = 42;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowCharts);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue ShowCharts", sal_Int16(0),
+ aShowCharts);
+
+ aNewValue <<= sal_Int16(1);
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowCharts);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ShowCharts", sal_Int16(1),
+ aShowCharts);
+
+ propName = "ShowDrawing";
+ sal_Int16 aShowDrawing = 42;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowDrawing);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue ShowDrawing", sal_Int16(0),
+ aShowDrawing);
+
+ aNewValue <<= sal_Int16(1);
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aShowDrawing);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ShowDrawing", sal_Int16(1),
+ aShowDrawing);
+
+ propName = "ZoomType";
+ sal_Int16 aZoomType = 42;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aZoomType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue ZoomType", sal_Int16(3), aZoomType);
+
+ aNewValue <<= sal_Int16(1);
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aZoomType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ZoomType", sal_Int16(1), aZoomType);
+
+ propName = "ZoomValue";
+ sal_Int16 aZoomValue = 42;
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aZoomValue);
+
+ aNewValue <<= sal_Int16(1);
+ xSpreadsheetViewSettings->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSpreadsheetViewSettings->getPropertyValue(propName) >>= aZoomValue);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue ZoomValue", sal_Int16(1), aZoomValue);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/subtotaldescriptor.cxx b/test/source/sheet/subtotaldescriptor.cxx
new file mode 100644
index 000000000..e9dffdb75
--- /dev/null
+++ b/test/source/sheet/subtotaldescriptor.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/subtotaldescriptor.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void SubTotalDescriptor::testSubTotalDescriptorProperties()
+{
+ uno::Reference<beans::XPropertySet> xSubTotalDescriptor(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "InsertPageBreaks";
+ bool aInsertPageBreaks = true;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aInsertPageBreaks);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue InsertPageBreaks", !aInsertPageBreaks);
+
+ aNewValue <<= true;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aInsertPageBreaks);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue InsertPageBreaks", aInsertPageBreaks);
+
+ propName = "IsCaseSensitive";
+ bool aIsCaseSensitive = true;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aIsCaseSensitive);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue IsCaseSensitive", !aIsCaseSensitive);
+
+ aNewValue <<= true;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aIsCaseSensitive);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue IsCaseSensitive", aIsCaseSensitive);
+
+ propName = "EnableUserSortList";
+ bool aEnableUserSortList = true;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableUserSortList);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue EnableUserSortList", !aEnableUserSortList);
+
+ aNewValue <<= true;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableUserSortList);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue EnableUserSortList", aEnableUserSortList);
+
+ propName = "UserSortListIndex";
+ sal_Int32 aUserSortListIndex = 42;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aUserSortListIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue UserSortListIndex", sal_Int32(0),
+ aUserSortListIndex);
+
+ aNewValue <<= sal_Int32(42);
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aUserSortListIndex);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set PropertyValue UserSortListIndex", sal_Int32(42),
+ aUserSortListIndex);
+
+ propName = "BindFormatsToContent";
+ bool aBindFormatsToContent = true;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aBindFormatsToContent);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue BindFormatsToContent",
+ !aBindFormatsToContent);
+
+ aNewValue <<= true;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aBindFormatsToContent);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue BindFormatsToContent",
+ aBindFormatsToContent);
+
+ propName = "EnableSort";
+ bool aEnableSort = false;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableSort);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue EnableSort", aEnableSort);
+
+ aNewValue <<= false;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aEnableSort);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue EnableSort", !aEnableSort);
+
+ propName = "SortAscending";
+ bool aSortAscending = false;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aSortAscending);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get PropertyValue SortAscending", aSortAscending);
+
+ aNewValue <<= false;
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aSortAscending);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set PropertyValue SortAscending", !aSortAscending);
+
+ propName = "MaxFieldCount";
+ sal_Int32 aMaxFieldCount = 42;
+ CPPUNIT_ASSERT(xSubTotalDescriptor->getPropertyValue(propName) >>= aMaxFieldCount);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get PropertyValue MaxFieldCount", sal_Int32(3),
+ aMaxFieldCount);
+
+ aNewValue <<= sal_Int32(42);
+ CPPUNIT_ASSERT_THROW_MESSAGE("Able to change PropertyValue MaxFieldCount",
+ xSubTotalDescriptor->setPropertyValue(propName, aNewValue),
+ lang::IllegalArgumentException);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/tableautoformat.cxx b/test/source/sheet/tableautoformat.cxx
new file mode 100644
index 000000000..2d5595f0a
--- /dev/null
+++ b/test/source/sheet/tableautoformat.cxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/tableautoformat.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void TableAutoFormat::testTableAutoFormatProperties()
+{
+ uno::Reference<beans::XPropertySet> xTableAutoFormat(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "IncludeFont";
+ bool aIncludeFont = false;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value IncludeFont",
+ xTableAutoFormat->getPropertyValue(propName) >>= aIncludeFont);
+
+ aNewValue <<= false;
+ xTableAutoFormat->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableAutoFormat->getPropertyValue(propName) >>= aIncludeFont);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value IncludeFont", !aIncludeFont);
+
+ propName = "IncludeJustify";
+ bool aIncludeJustify = false;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value IncludeJustify",
+ xTableAutoFormat->getPropertyValue(propName) >>= aIncludeJustify);
+
+ aNewValue <<= false;
+ xTableAutoFormat->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableAutoFormat->getPropertyValue(propName) >>= aIncludeJustify);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value IncludeJustify", !aIncludeJustify);
+
+ propName = "IncludeBorder";
+ bool aIncludeBorder = false;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value IncludeBorder",
+ xTableAutoFormat->getPropertyValue(propName) >>= aIncludeBorder);
+
+ aNewValue <<= false;
+ xTableAutoFormat->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableAutoFormat->getPropertyValue(propName) >>= aIncludeBorder);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value IncludeBorder", !aIncludeBorder);
+
+ propName = "IncludeBackground";
+ bool aIncludeBackground = false;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value IncludeBackground",
+ xTableAutoFormat->getPropertyValue(propName) >>= aIncludeBackground);
+
+ aNewValue <<= false;
+ xTableAutoFormat->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableAutoFormat->getPropertyValue(propName) >>= aIncludeBackground);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value IncludeBackground", !aIncludeBackground);
+
+ propName = "IncludeNumberFormat";
+ bool aIncludeNumberFormat = false;
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value IncludeNumberFormat",
+ xTableAutoFormat->getPropertyValue(propName) >>= aIncludeNumberFormat);
+
+ aNewValue <<= false;
+ xTableAutoFormat->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableAutoFormat->getPropertyValue(propName) >>= aIncludeNumberFormat);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value IncludeNumberFormat",
+ !aIncludeNumberFormat);
+
+ propName = "IncludeWidthAndHeight";
+ bool aIncludeWidthAndHeight = false;
+ CPPUNIT_ASSERT(xTableAutoFormat->getPropertyValue(propName) >>= aIncludeWidthAndHeight);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value IncludeWidthAndHeight",
+ aIncludeWidthAndHeight);
+
+ aNewValue <<= false;
+ xTableAutoFormat->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableAutoFormat->getPropertyValue(propName) >>= aIncludeWidthAndHeight);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value IncludeWidthAndHeight",
+ !aIncludeWidthAndHeight);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/tablevalidation.cxx b/test/source/sheet/tablevalidation.cxx
new file mode 100644
index 000000000..438301960
--- /dev/null
+++ b/test/source/sheet/tablevalidation.cxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/tablevalidation.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/ValidationAlertStyle.hpp>
+#include <com/sun/star/sheet/ValidationType.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void TableValidation::testTableValidationProperties()
+{
+ uno::Reference<beans::XPropertySet> xTableValidation(init(), UNO_QUERY_THROW);
+ OUString propName;
+ uno::Any aNewValue;
+
+ propName = "Type";
+ uno::Any aValue = xTableValidation->getPropertyValue(propName);
+ sheet::ValidationType aValidationType;
+ aValue >>= aValidationType;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value Type", sheet::ValidationType_ANY,
+ aValidationType);
+
+ aNewValue <<= sheet::ValidationType_WHOLE;
+ xTableValidation->setPropertyValue(propName, aNewValue);
+ aValue = xTableValidation->getPropertyValue(propName);
+ aValue >>= aValidationType;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set property value Type", sheet::ValidationType_WHOLE,
+ aValidationType);
+
+ propName = "ShowInputMessage";
+ bool aShowInputMessage = true;
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowInputMessage);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value ShowInputMessage", !aShowInputMessage);
+
+ aNewValue <<= true;
+ xTableValidation->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowInputMessage);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value ShowInputMessage", aShowInputMessage);
+
+ // only possible if ShowInputMessage is true
+ propName = "InputMessage";
+ OUString aInputMessage;
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputMessage);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value InputMessage", OUString(""),
+ aInputMessage);
+
+ aNewValue <<= OUString("UnitTest InputMessage");
+ xTableValidation->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputMessage);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value InputMessage",
+ OUString("UnitTest InputMessage"), aInputMessage);
+
+ // only possible if ShowInputMessage is true
+ propName = "InputTitle";
+ OUString aInputTitle;
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputTitle);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value InputTitle", OUString(""),
+ aInputTitle);
+
+ aNewValue <<= OUString("UnitTest InputTitle");
+ xTableValidation->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aInputTitle);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value InputTitle",
+ OUString("UnitTest InputTitle"), aInputTitle);
+
+ propName = "ShowErrorMessage";
+ bool aShowErrorMessage = true;
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowErrorMessage);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value ShowErrorMessage", !aShowErrorMessage);
+
+ aNewValue <<= true;
+ xTableValidation->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowErrorMessage);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value ShowErrorMessage", aShowErrorMessage);
+
+ // only possible if ShowErrorMessage is true
+ propName = "ErrorMessage";
+ OUString aErrorMessage;
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorMessage);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value ErrorMessage", OUString(""),
+ aErrorMessage);
+
+ aNewValue <<= OUString("UnitTest ErrorMessage");
+ xTableValidation->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorMessage);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value ErrorMessage",
+ OUString("UnitTest ErrorMessage"), aErrorMessage);
+
+ // only possible if ShowErrorMessage is true
+ propName = "ErrorTitle";
+ OUString aErrorTitle;
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorTitle);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value ErrorTitle", OUString(""),
+ aErrorTitle);
+
+ aNewValue <<= OUString("UnitTest ErrorTitle");
+ xTableValidation->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aErrorTitle);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value ErrorTitle",
+ OUString("UnitTest ErrorTitle"), aErrorTitle);
+
+ propName = "IgnoreBlankCells";
+ bool aIgnoreBlankCells = false;
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aIgnoreBlankCells);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get property value IgnoreBlankCells", aIgnoreBlankCells);
+
+ aNewValue <<= false;
+ xTableValidation->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aIgnoreBlankCells);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set property value IgnoreBlankCells", !aIgnoreBlankCells);
+
+ propName = "ErrorAlertStyle";
+ aValue = xTableValidation->getPropertyValue(propName);
+ sheet::ValidationAlertStyle aValidationAlertStyle;
+ aValue >>= aValidationAlertStyle;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value ValidationAlertStyle",
+ sheet::ValidationAlertStyle_STOP, aValidationAlertStyle);
+
+ aNewValue <<= sheet::ValidationAlertStyle_WARNING;
+ xTableValidation->setPropertyValue(propName, aNewValue);
+ aValue = xTableValidation->getPropertyValue(propName);
+ aValue >>= aValidationAlertStyle;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set property value ValidationAlertStyle",
+ sheet::ValidationAlertStyle_WARNING, aValidationAlertStyle);
+
+ propName = "ShowList";
+ sal_Int16 aShowList = 0;
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowList);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get property value ShowList", sal_Int16(1), aShowList);
+
+ aNewValue <<= sal_Int16(42);
+ xTableValidation->setPropertyValue(propName, aNewValue);
+ CPPUNIT_ASSERT(xTableValidation->getPropertyValue(propName) >>= aShowList);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set property value ShowList", sal_Int16(42), aShowList);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xactivationbroadcaster.cxx b/test/source/sheet/xactivationbroadcaster.cxx
new file mode 100644
index 000000000..93fa5ab93
--- /dev/null
+++ b/test/source/sheet/xactivationbroadcaster.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xactivationbroadcaster.hxx>
+
+#include <com/sun/star/lang/EventObject.hpp>
+#include <com/sun/star/sheet/ActivationEvent.hpp>
+#include <com/sun/star/sheet/XActivationBroadcaster.hpp>
+#include <com/sun/star/sheet/XActivationEventListener.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppuhelper/implbase.hxx>
+#include <rtl/ref.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+namespace
+{
+class MockedActivationEventListener : public ::cppu::WeakImplHelper<sheet::XActivationEventListener>
+{
+public:
+ MockedActivationEventListener()
+ : mbListenerCalled(false)
+ {
+ }
+ bool mbListenerCalled;
+ virtual void SAL_CALL
+ activeSpreadsheetChanged(const sheet::ActivationEvent& /* xEvent */) override
+ {
+ mbListenerCalled = true;
+ }
+ virtual void SAL_CALL disposing(const lang::EventObject& /* xEventObj */) override {}
+};
+}
+
+void XActivationBroadcaster::testAddRemoveActivationEventListener()
+{
+ uno::Reference<sheet::XActivationBroadcaster> xAB(init(), UNO_QUERY_THROW);
+ xAB->addActivationEventListener(nullptr);
+
+ rtl::Reference<MockedActivationEventListener> xListener = new MockedActivationEventListener();
+ xAB->addActivationEventListener(
+ uno::Reference<sheet::XActivationEventListener>(xListener.get()));
+
+ uno::Reference<sheet::XSpreadsheetView> xView(xAB, UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet1(xView->getActiveSheet(), UNO_SET_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet2(getXSpreadsheet(1), UNO_QUERY_THROW);
+
+ xView->setActiveSheet(xSheet2);
+
+ CPPUNIT_ASSERT_MESSAGE("Listener wasn't called", xListener->mbListenerCalled);
+
+ xAB->removeActivationEventListener(
+ uno::Reference<sheet::XActivationEventListener>(xListener.get()));
+ xView->setActiveSheet(xSheet1);
+ CPPUNIT_ASSERT_MESSAGE("Listener still called after removal", xListener->mbListenerCalled);
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xarealink.cxx b/test/source/sheet/xarealink.cxx
new file mode 100644
index 000000000..77e9cb98b
--- /dev/null
+++ b/test/source/sheet/xarealink.cxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xarealink.hxx>
+#include <test/cppunitasserthelper.hxx>
+
+#include <com/sun/star/sheet/XAreaLink.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XAreaLink::testSetDestArea()
+{
+ uno::Reference< sheet::XAreaLink > xAreaLink(init(), UNO_QUERY_THROW);
+
+ xAreaLink->setDestArea(table::CellRangeAddress(1,3,4,5,8));
+ // After setting the destination area, the link is refreshed and the area
+ // is adjusted to the size of the source data.
+ // Only test the 'Sheet', 'StartCol', and 'StartRow'
+ table::CellRangeAddress aDestArea = xAreaLink->getDestArea();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't set new DestArea (Sheet)", sal_Int16(1), aDestArea.Sheet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't set new DestArea (StartCol)", sal_Int32(3), aDestArea.StartColumn);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't set new DestArea (StartRow)", sal_Int32(4), aDestArea.StartRow);
+}
+
+void XAreaLink::testSetSourceArea()
+{
+ uno::Reference< sheet::XAreaLink > xAreaLink(init(), UNO_QUERY_THROW);
+
+ xAreaLink->setSourceArea("Sheet1.A1:B1");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't set new source area",
+ OUString("Sheet1.A1:B1"), xAreaLink->getSourceArea());
+}
+
+void XAreaLink::testGetDestArea()
+{
+ uno::Reference< sheet::XAreaLink > xAreaLink(init(), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't get dest area",
+ table::CellRangeAddress(1,2,3,3,6), xAreaLink->getDestArea());
+}
+
+void XAreaLink::testGetSourceArea()
+{
+ uno::Reference< sheet::XAreaLink > xAreaLink(init(), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Couldn't get source area",
+ OUString("a2:b5"), xAreaLink->getSourceArea());
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xarealinks.cxx b/test/source/sheet/xarealinks.cxx
new file mode 100644
index 000000000..f52dcc35b
--- /dev/null
+++ b/test/source/sheet/xarealinks.cxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xarealinks.hxx>
+
+#include <com/sun/star/sheet/XAreaLinks.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XAreaLinks::testInsertAtPosition()
+{
+ uno::Reference< sheet::XAreaLinks > xAreaLinks(init(), UNO_QUERY_THROW);
+
+ table::CellAddress aCellAddress(1, 2, 3);
+ xAreaLinks->insertAtPosition(aCellAddress, "", "a2:b5", "", "");
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to insert new CellAddress",
+ sal_Int32(1), xAreaLinks->getCount());
+}
+
+void XAreaLinks::testRemoveByIndex()
+{
+ uno::Reference< sheet::XAreaLinks > xAreaLinks(init(), UNO_QUERY_THROW);
+
+ table::CellAddress aCellAddress(1, 2, 3);
+ xAreaLinks->insertAtPosition(aCellAddress, "", "a2:b5", "", "");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to insert CellAddress for removal",
+ sal_Int32(1), xAreaLinks->getCount());
+
+ xAreaLinks->removeByIndex(0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to remove CellAddress",
+ sal_Int32(0), xAreaLinks->getCount());
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xarrayformularange.cxx b/test/source/sheet/xarrayformularange.cxx
new file mode 100644
index 000000000..ab4ed7847
--- /dev/null
+++ b/test/source/sheet/xarrayformularange.cxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xarrayformularange.hxx>
+
+#include <com/sun/star/sheet/XArrayFormulaRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XArrayFormulaRange::testGetSetArrayFormula()
+{
+ uno::Reference<sheet::XArrayFormulaRange> xAFR(init(), UNO_QUERY_THROW);
+
+ const OUString sFormula("=1 + 2 * 5");
+
+ xAFR->setArrayFormula(sFormula);
+ uno::Reference<sheet::XCellRangeAddressable> xCRA(xAFR, UNO_QUERY_THROW);
+ table::CellRangeAddress cellRangeAddress = xCRA->getRangeAddress();
+
+ uno::Reference<sheet::XSpreadsheet> xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
+
+ for (auto i = cellRangeAddress.StartColumn; i <= cellRangeAddress.EndColumn; i++)
+ {
+ for (auto j = cellRangeAddress.StartRow; j <= cellRangeAddress.EndRow; j++)
+ {
+ uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(i, j);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Value of Cell " + std::to_string(i) + ","
+ + std::to_string(j),
+ 11.0, xCell->getValue(), 0.5);
+ }
+ }
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to test getArrayFormula()", OUString("{" + sFormula + "}"),
+ xAFR->getArrayFormula());
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xcalculatable.cxx b/test/source/sheet/xcalculatable.cxx
new file mode 100644
index 000000000..44c201534
--- /dev/null
+++ b/test/source/sheet/xcalculatable.cxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xcalculatable.hxx>
+
+#include <com/sun/star/sheet/XCalculatable.hpp>
+#include <com/sun/star/table/XCell.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XCalculatable::testEnableAutomaticCalculation()
+{
+ uno::Reference<sheet::XCalculatable> xCalculatable(init(), UNO_QUERY_THROW);
+
+ bool bIsAutomaticCalculationEnabled = xCalculatable->isAutomaticCalculationEnabled();
+ xCalculatable->enableAutomaticCalculation(!bIsAutomaticCalculationEnabled);
+ bool bIsAutomaticCalculationEnabledNew = xCalculatable->isAutomaticCalculationEnabled();
+ CPPUNIT_ASSERT_MESSAGE("Unable to set enableAutomaticCalculation()",
+ bIsAutomaticCalculationEnabled != bIsAutomaticCalculationEnabledNew);
+}
+
+void XCalculatable::testCalculate()
+{
+ uno::Reference<sheet::XCalculatable> xCalculatable(init(), UNO_QUERY_THROW);
+ xCalculatable->enableAutomaticCalculation(false);
+
+ uno::Sequence<uno::Reference<table::XCell>> xCells = getXCells();
+
+ double dProduct = xCells[2]->getValue();
+ double dFactor1 = xCells[0]->getValue();
+ xCells[0]->setValue(dFactor1 + 1.0);
+ double dProduct2 = xCells[2]->getValue();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculated products are equal", dProduct, dProduct2, 0.5);
+
+ xCalculatable->calculate();
+ dProduct2 = xCells[2]->getValue();
+ CPPUNIT_ASSERT_MESSAGE("Calculated products are not equal", dProduct != dProduct2);
+}
+
+void XCalculatable::testCalculateAll()
+{
+ uno::Reference<sheet::XCalculatable> xCalculatable(init(), UNO_QUERY_THROW);
+ xCalculatable->enableAutomaticCalculation(false);
+
+ uno::Sequence<uno::Reference<table::XCell>> xCells = getXCells();
+
+ double dProduct = xCells[2]->getValue();
+ double dFactor1 = xCells[0]->getValue();
+ xCells[0]->setValue(dFactor1 + 1.0);
+ double dProduct2 = xCells[2]->getValue();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Calculated products are equal", dProduct, dProduct2, 0.5);
+
+ xCalculatable->calculateAll();
+ dProduct2 = xCells[2]->getValue();
+ CPPUNIT_ASSERT_MESSAGE("Calculated products are not equal", dProduct != dProduct2);
+ xCalculatable->calculateAll();
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xcelladdressable.cxx b/test/source/sheet/xcelladdressable.cxx
new file mode 100644
index 000000000..fe70f8877
--- /dev/null
+++ b/test/source/sheet/xcelladdressable.cxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xcelladdressable.hxx>
+#include <test/cppunitasserthelper.hxx>
+
+#include <com/sun/star/sheet/XCellAddressable.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XCellAddressable::testGetCellAddress()
+{
+ uno::Reference< sheet::XCellAddressable > xCellAddressable(init(), UNO_QUERY_THROW);
+ table::CellAddress xCellAddress = xCellAddressable->getCellAddress();
+ table::CellAddress defaultCellAddress(0, 2, 3);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("getCellAddress() didn't returned default cell address",
+ defaultCellAddress, xCellAddress);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xcellformatrangessupplier.cxx b/test/source/sheet/xcellformatrangessupplier.cxx
new file mode 100644
index 000000000..d4390b538
--- /dev/null
+++ b/test/source/sheet/xcellformatrangessupplier.cxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xcellformatrangessupplier.hxx>
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/sheet/XCellFormatRangesSupplier.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XCellFormatRangesSupplier::testGetCellFormatRanges()
+{
+ uno::Reference<sheet::XCellFormatRangesSupplier> xCFRS(init(), UNO_QUERY_THROW);
+
+ uno::Reference<container::XIndexAccess> xIA(xCFRS->getCellFormatRanges(), UNO_SET_THROW);
+
+ const sal_Int32 nCount = xIA->getCount();
+ CPPUNIT_ASSERT_MESSAGE("No items found", sal_Int32(0) != nCount);
+ for (auto i = 0; i < nCount; i++)
+ {
+ CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to access element at position " + std::to_string(i),
+ xIA->getByIndex(i));
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xcellrangeaddressable.cxx b/test/source/sheet/xcellrangeaddressable.cxx
new file mode 100644
index 000000000..179a56fa1
--- /dev/null
+++ b/test/source/sheet/xcellrangeaddressable.cxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xcellrangeaddressable.hxx>
+
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XCellRangeAddressable::testGetRangeAddress()
+{
+ uno::Reference<sheet::XCellRangeAddressable> xCRA(init(), UNO_QUERY_THROW);
+
+ table::CellRangeAddress aCellRangeAddr = xCRA->getRangeAddress();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get CellRangeAddress", sal_Int16(0),
+ aCellRangeAddr.Sheet);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xcellrangedata.cxx b/test/source/sheet/xcellrangedata.cxx
new file mode 100644
index 000000000..6bd8f0f85
--- /dev/null
+++ b/test/source/sheet/xcellrangedata.cxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xcellrangedata.hxx>
+
+#include <com/sun/star/sheet/XCellRangeData.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+namespace {
+
+void setValues(uno::Sequence< uno::Sequence < Any > >& rColRow, double nOffset)
+{
+ for (sal_Int32 i = 0; i < 4; ++i)
+ {
+ rColRow[i].realloc(4);
+ for (sal_Int32 j = 0; j < 4; ++j)
+ {
+ Any& aAny = rColRow[i][j];
+ double nValue = i + j + nOffset;
+ aAny <<= nValue;
+ }
+ }
+}
+
+}
+
+void XCellRangeData::testSetDataArray()
+{
+ uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
+
+ uno::Sequence< uno::Sequence < Any > > aColRow;
+ aColRow.realloc(4);
+ setValues(aColRow, 1);
+ xCellRangeData->setDataArray(aColRow);
+
+ for ( sal_Int32 i = 0; i < aColRow.getLength(); ++i)
+ {
+ for ( sal_Int32 j = 0; j < aColRow[i].getLength(); ++j)
+ {
+ Any& aAny = aColRow[i][j];
+ double nValue = 0.0;
+ CPPUNIT_ASSERT( aAny >>= nValue);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<double>(i+j+1), nValue, 0.000001);
+ }
+ }
+
+ // set old values
+ setValues(aColRow, 0);
+ xCellRangeData->setDataArray(aColRow);
+}
+
+void XCellRangeData::testGetDataArray()
+{
+ uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
+ uno::Sequence< uno::Sequence < Any > > aColRow = xCellRangeData->getDataArray();
+ CPPUNIT_ASSERT(aColRow.hasElements());
+}
+
+void XCellRangeData::testGetDataArrayOnTableSheet()
+{
+ uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_THROW_MESSAGE("No RuntimeException thrown", xCellRangeData->getDataArray(),
+ css::uno::RuntimeException);
+}
+
+void XCellRangeData::testSetDataArrayOnTableSheet()
+{
+ uno::Reference< sheet::XCellRangeData > xCellRangeData( getXCellRangeData(), UNO_QUERY_THROW);
+
+ uno::Sequence< uno::Sequence < Any > > aColRow;
+ aColRow.realloc(4);
+ setValues(aColRow, 1);
+ CPPUNIT_ASSERT_THROW_MESSAGE("No RuntimeException thrown", xCellRangeData->setDataArray(aColRow),
+ css::uno::RuntimeException);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xcellrangeformula.cxx b/test/source/sheet/xcellrangeformula.cxx
new file mode 100644
index 000000000..6de601499
--- /dev/null
+++ b/test/source/sheet/xcellrangeformula.cxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xcellrangeformula.hxx>
+
+#include <com/sun/star/sheet/XCellRangeFormula.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XCellRangeFormula::testGetSetFormulaArray()
+{
+ uno::Reference<sheet::XCellRangeFormula> xCRF(init(), UNO_QUERY_THROW);
+
+ uno::Sequence<uno::Sequence<OUString>> aFormulaArrayOrginal = xCRF->getFormulaArray();
+ uno::Sequence<uno::Sequence<OUString>> aFormulaArrayNew = xCRF->getFormulaArray();
+ aFormulaArrayNew[0][0] = "NewValue";
+
+ xCRF->setFormulaArray(aFormulaArrayNew);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get new FormulaArray", OUString("NewValue"),
+ xCRF->getFormulaArray()[0][0]);
+
+ xCRF->setFormulaArray(aFormulaArrayOrginal);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set new FormulaArray", aFormulaArrayOrginal[0][0],
+ xCRF->getFormulaArray()[0][0]);
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xcellrangemovement.cxx b/test/source/sheet/xcellrangemovement.cxx
new file mode 100644
index 000000000..ac25a4603
--- /dev/null
+++ b/test/source/sheet/xcellrangemovement.cxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xcellrangemovement.hxx>
+
+#include <com/sun/star/sheet/CellDeleteMode.hpp>
+#include <com/sun/star/sheet/CellInsertMode.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeMovement.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XCellRangeMovement::testInsertCells()
+{
+ uno::Reference<sheet::XCellRangeMovement> xCRM(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet(xCRM, UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XCellRangeAddressable> xCRA(xCRM, UNO_QUERY_THROW);
+ const sal_Int16 nSheet = xCRA->getRangeAddress().Sheet;
+
+ xSheet->getCellByPosition(0, 20)->setValue(100);
+ xSheet->getCellByPosition(1, 20)->setValue(100);
+ xSheet->getCellByPosition(2, 20)->setValue(100);
+ xSheet->getCellByPosition(3, 20)->setValue(100);
+ xSheet->getCellByPosition(0, 21)->setValue(200);
+ xSheet->getCellByPosition(1, 21)->setValue(200);
+ xSheet->getCellByPosition(2, 21)->setValue(200);
+ xSheet->getCellByPosition(3, 21)->setValue(200);
+
+ table::CellRangeAddress aSrcCellRangeAddr(nSheet, 0, 21, 5, 21);
+ xCRM->insertCells(aSrcCellRangeAddr, sheet::CellInsertMode_DOWN);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unable to insert cells", 0.0,
+ xSheet->getCellByPosition(1, 21)->getValue(), 0.0);
+}
+
+void XCellRangeMovement::testCopyRange()
+{
+ uno::Reference<sheet::XCellRangeMovement> xCRM(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet(xCRM, UNO_QUERY_THROW);
+
+ xSheet->getCellByPosition(1, 1)->setValue(100);
+ xSheet->getCellByPosition(1, 2)->setValue(200);
+ xSheet->getCellByPosition(2, 1)->setValue(300);
+ xSheet->getCellByPosition(2, 2)->setValue(400);
+
+ uno::Reference<sheet::XCellRangeAddressable> xCRA(xCRM, UNO_QUERY_THROW);
+ const sal_Int16 nSheet = xCRA->getRangeAddress().Sheet;
+
+ table::CellRangeAddress aSrcCellRangeAddr(nSheet, 1, 1, 2, 2);
+ table::CellAddress aDstCellAddr(nSheet, 1, 10);
+
+ xCRM->copyRange(aDstCellAddr, aSrcCellRangeAddr);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Value was not copied from position 1,1 to 1,10", 100.0,
+ xSheet->getCellByPosition(1, 10)->getValue(), 0.1);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Value was not copied from position 1,2 to 1,11", 200.0,
+ xSheet->getCellByPosition(1, 11)->getValue(), 0.1);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Value was not copied from position 2,1 to 2,10", 300.0,
+ xSheet->getCellByPosition(2, 10)->getValue(), 0.1);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Value was not copied from position 2,2 to 2,11", 400.0,
+ xSheet->getCellByPosition(2, 11)->getValue(), 0.1);
+}
+void XCellRangeMovement::testMoveRange()
+{
+ uno::Reference<sheet::XCellRangeMovement> xCRM(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet(xCRM, UNO_QUERY_THROW);
+
+ xSheet->getCellByPosition(4, 0)->setValue(111);
+ xSheet->getCellByPosition(4, 1)->setValue(222);
+
+ uno::Reference<sheet::XCellRangeAddressable> xCRA(xCRM, UNO_QUERY_THROW);
+ const sal_Int16 nSheet = xCRA->getRangeAddress().Sheet;
+
+ table::CellRangeAddress aSrcCellRangeAddr(nSheet, 4, 0, 4, 1);
+ table::CellAddress aDstCellAddr(nSheet, 4, 4);
+
+ xCRM->moveRange(aDstCellAddr, aSrcCellRangeAddr);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unable to move range", 333.0,
+ xSheet->getCellByPosition(4, 4)->getValue()
+ + xSheet->getCellByPosition(4, 5)->getValue(),
+ 0.0);
+}
+void XCellRangeMovement::testRemoveRange()
+{
+ uno::Reference<sheet::XCellRangeMovement> xCRM(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet(xCRM, UNO_QUERY_THROW);
+
+ xSheet->getCellByPosition(5, 0)->setValue(333);
+ xSheet->getCellByPosition(5, 1)->setValue(444);
+
+ uno::Reference<sheet::XCellRangeAddressable> xCRA(xCRM, UNO_QUERY_THROW);
+ const sal_Int16 nSheet = xCRA->getRangeAddress().Sheet;
+
+ table::CellRangeAddress aSrcCellRangeAddr(nSheet, 5, 0, 5, 1);
+
+ xCRM->removeRange(aSrcCellRangeAddr, sheet::CellDeleteMode_UP);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unable to remove range", 0.0,
+ xSheet->getCellByPosition(5, 0)->getValue()
+ + xSheet->getCellByPosition(5, 1)->getValue(),
+ 0.0);
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xcellrangereferrer.cxx b/test/source/sheet/xcellrangereferrer.cxx
new file mode 100644
index 000000000..3d286d558
--- /dev/null
+++ b/test/source/sheet/xcellrangereferrer.cxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/cppunitasserthelper.hxx>
+#include <test/sheet/xcellrangereferrer.hxx>
+
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XCellRangeReferrer::testGetReferredCells()
+{
+ uno::Reference< sheet::XCellRangeReferrer > xReferrer(init(), UNO_QUERY_THROW);
+ uno::Reference< table::XCellRange > xReferredRange = xReferrer->getReferredCells();
+
+ uno::Reference< sheet::XCellRangeAddressable > xAdressable( xReferredRange, UNO_QUERY_THROW );
+ table::CellRangeAddress aCellRange = xAdressable->getRangeAddress();
+
+ CPPUNIT_ASSERT_EQUAL(aCellRange, getCellRange());
+}
+}
+
+/* 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 000000000..e8e1b4724
--- /dev/null
+++ b/test/source/sheet/xcellrangesquery.cxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#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/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+
+namespace apitest {
+
+void XCellRangesQuery::testQueryColumnDifference()
+{
+ OUString const aExpected( "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));
+ OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryColumnDifference: Result: " << aResult << std::endl;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryColumnDifference", aExpected, aResult);
+}
+
+void XCellRangesQuery::testQueryContentDifference()
+{
+ OUString const aExpected( "Sheet1.B3,Sheet1.C2" );
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::VALUE);
+ OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryContentDifference: Result: " << aResult << std::endl;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryContentDifference", aExpected, aResult);
+}
+
+void XCellRangesQuery::testQueryEmptyCells()
+{
+ OUString const aExpected( "Sheet1.A1:A5,Sheet1.B1:C1,Sheet1.B5,Sheet1.C3:C5,Sheet1.D1:E5" );
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryEmptyCells();
+ OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryEmptyCells: Result: " << aResult << std::endl;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryEmptyCells", aExpected, aResult);
+}
+
+void XCellRangesQuery::testQueryFormulaCells()
+{
+ OUString const aExpected( "Sheet1.B2" );
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryFormulaCells(sheet::CellFlags::FORMULA);
+ OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryFormulaCells: Result: " << aResult << std::endl;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryFormulaCells", aExpected, aResult);
+}
+
+void XCellRangesQuery::testQueryIntersection()
+{
+ OUString const aExpected( "Sheet1.D4:E5" );
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryIntersection(table::CellRangeAddress(0,3,3,7,7));
+ OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryIntersection: Result: " << aResult << std::endl;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryIntersection", aExpected, aResult);
+}
+
+void XCellRangesQuery::testQueryRowDifference()
+{
+ OUString const aExpected( "Sheet1.A2:A4,Sheet1.C2:E4" );
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryRowDifferences(table::CellAddress(0,1,1));
+ OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryRowDifference: Result: " << aResult << std::endl;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryRowDifference", aExpected, aResult);
+}
+
+void XCellRangesQuery::testQueryVisibleCells()
+{
+ OUString const aExpected( "Sheet1.A1:E5" );
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(init(),UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells();
+ OUString aResult = xRanges->getRangeAddressesAsString();
+ std::cout << "testQueryVisibleCells: Result: " << aResult << std::endl;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testQueryVisibleCells", aExpected, aResult);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xcellseries.cxx b/test/source/sheet/xcellseries.cxx
new file mode 100644
index 000000000..3aff084f8
--- /dev/null
+++ b/test/source/sheet/xcellseries.cxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xcellseries.hxx>
+
+#include <com/sun/star/sheet/XCellSeries.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XCellSeries::testFillAuto()
+{
+ uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW);
+ sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue();
+
+ uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_SET_THROW);
+ uno::Reference<sheet::XCellSeries> xCellSeriesH(xCellRangeH, UNO_QUERY_THROW);
+ xCellSeriesH->fillAuto(sheet::FillDirection_TO_RIGHT, 1);
+ sal_Int32 sumH = 0;
+ for(sal_Int32 i = 0; i < 3; i++) {
+ uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_SET_THROW);
+ sumH += xCellResultH->getValue();
+ }
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillAuto with TO_RIGHT", maValue * 3 + 3, sumH);
+
+ uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX, maStartY + 2), UNO_SET_THROW);
+ uno::Reference<sheet::XCellSeries> xCellSeriesV(xCellRangeV, UNO_QUERY_THROW);
+ xCellSeriesV->fillAuto(sheet::FillDirection_TO_BOTTOM, 1);
+ sal_Int32 sumV = 0;
+ for(sal_Int32 i = 0; i < 3; i++) {
+ uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_SET_THROW);
+ sumV += xCellResultV->getValue();
+ }
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillAuto with TO_BOTTOM", maValue * 3 + 3, sumV);
+
+ for(sal_Int32 i = 1; i < 3; i++) {
+ uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_SET_THROW);
+ xCellResultH->setFormula("");
+ uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_SET_THROW);
+ xCellResultV->setFormula("");
+ }
+}
+
+void XCellSeries::testFillSeries()
+{
+ uno::Reference<table::XCellRange> xCellRange(init(), UNO_QUERY_THROW);
+ sal_Int32 maValue = xCellRange->getCellByPosition(maStartX, maStartY)->getValue();
+
+ uno::Reference<table::XCellRange> xCellRangeH(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX + 2, maStartY), UNO_SET_THROW);
+ uno::Reference<sheet::XCellSeries> xCellSeriesH(xCellRangeH, UNO_QUERY_THROW);
+ xCellSeriesH->fillSeries(sheet::FillDirection_TO_RIGHT,
+ sheet::FillMode_LINEAR,
+ sheet::FillDateMode_FILL_DATE_DAY, 2, 1000);
+ sal_Int32 sumH = 0;
+ for(sal_Int32 i = 0; i < 3; i++) {
+ uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_SET_THROW);
+ sumH += xCellResultH->getValue();
+ }
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_RIGHT and LINEAR", maValue * 3 + 6, sumH);
+
+ xCellSeriesH->fillSeries(sheet::FillDirection_TO_RIGHT,
+ sheet::FillMode_GROWTH,
+ sheet::FillDateMode_FILL_DATE_DAY, 2, 1000);
+ sumH = 0;
+ for(sal_Int32 i = 0; i < 3; i++) {
+ uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_SET_THROW);
+ sumH += xCellResultH->getValue();
+ }
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_RIGHT and GROWTH", maValue + maValue * 2 + maValue * 4, sumH);
+
+ uno::Reference<table::XCellRange> xCellRangeV(xCellRange->getCellRangeByPosition(maStartX, maStartY, maStartX, maStartY + 2), UNO_SET_THROW);
+ uno::Reference<sheet::XCellSeries> xCellSeriesV(xCellRangeV, UNO_QUERY_THROW);
+ xCellSeriesV->fillSeries(sheet::FillDirection_TO_BOTTOM,
+ sheet::FillMode_LINEAR,
+ sheet::FillDateMode_FILL_DATE_DAY, 2, 1000);
+ sal_Int32 sumV = 0;
+ for(sal_Int32 i = 0; i < 3; i++) {
+ uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_SET_THROW);
+ sumV += xCellResultV->getValue();
+ }
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_BOTTOM and LINEAR", maValue * 3 + 6, sumV);
+
+ xCellSeriesV->fillSeries(sheet::FillDirection_TO_BOTTOM,
+ sheet::FillMode_GROWTH,
+ sheet::FillDateMode_FILL_DATE_DAY, 2, 1000);
+ sumV = 0;
+ for(sal_Int32 i = 0; i < 3; i++) {
+ uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_SET_THROW);
+ sumV += xCellResultV->getValue();
+ }
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong result for fillSeries with TO_BOTTOM and GROWTH", maValue + maValue * 2 + maValue * 4, sumV);
+
+ for(sal_Int32 i = 1; i < 3; i++) {
+ uno::Reference<table::XCell> xCellResultH(xCellRange->getCellByPosition(maStartX + i, maStartY), UNO_SET_THROW);
+ xCellResultH->setFormula("");
+ uno::Reference<table::XCell> xCellResultV(xCellRange->getCellByPosition(maStartX, maStartY + i), UNO_SET_THROW);
+ xCellResultV->setFormula("");
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xconsolidatable.cxx b/test/source/sheet/xconsolidatable.cxx
new file mode 100644
index 000000000..0efa16b69
--- /dev/null
+++ b/test/source/sheet/xconsolidatable.cxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xconsolidatable.hxx>
+
+#include <com/sun/star/sheet/XConsolidatable.hpp>
+#include <com/sun/star/sheet/XConsolidationDescriptor.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XConsolidatable::testCreateConsolidationDescriptor()
+{
+ uno::Reference<sheet::XConsolidatable> xConsolidatable(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(
+ xConsolidatable->createConsolidationDescriptor(true), UNO_SET_THROW);
+}
+
+void XConsolidatable::testConsolidate()
+{
+ uno::Reference<sheet::XConsolidatable> xConsolidatable(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(
+ xConsolidatable->createConsolidationDescriptor(true), UNO_SET_THROW);
+
+ xConsolidatable->consolidate(xConsolidationDescriptor);
+ CPPUNIT_ASSERT_MESSAGE("consolidate()", true);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xconsolidationdescriptor.cxx b/test/source/sheet/xconsolidationdescriptor.cxx
new file mode 100644
index 000000000..455533c23
--- /dev/null
+++ b/test/source/sheet/xconsolidationdescriptor.cxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xconsolidationdescriptor.hxx>
+#include <test/cppunitasserthelper.hxx>
+
+#include <com/sun/star/sheet/GeneralFunction.hpp>
+#include <com/sun/star/sheet/XConsolidationDescriptor.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XConsolidationDescriptor::testGetFunction()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get function", sheet::GeneralFunction_SUM,
+ xConsolidationDescriptor->getFunction());
+}
+
+void XConsolidationDescriptor::testSetFunction()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ xConsolidationDescriptor->setFunction(sheet::GeneralFunction_COUNT);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set function", sheet::GeneralFunction_COUNT,
+ xConsolidationDescriptor->getFunction());
+}
+
+void XConsolidationDescriptor::testGetSources()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ uno::Sequence<table::CellRangeAddress> aSources = xConsolidationDescriptor->getSources();
+ CPPUNIT_ASSERT_MESSAGE("Unable to get sources", !aSources.hasElements());
+}
+
+void XConsolidationDescriptor::testSetSources()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ uno::Sequence<table::CellRangeAddress> aSources(1);
+ aSources[0] = table::CellRangeAddress(0, 1, 1, 5, 5);
+ xConsolidationDescriptor->setSources(aSources);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set sources", table::CellRangeAddress(0, 1, 1, 5, 5),
+ xConsolidationDescriptor->getSources()[0]);
+}
+
+void XConsolidationDescriptor::testGetStartOutputPosition()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get start output position", table::CellAddress(0, 0, 0),
+ xConsolidationDescriptor->getStartOutputPosition());
+}
+
+void XConsolidationDescriptor::testSetStartOutputPosition()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ xConsolidationDescriptor->setStartOutputPosition(table::CellAddress(0, 1, 2));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set start output position", table::CellAddress(0, 1, 2),
+ xConsolidationDescriptor->getStartOutputPosition());
+}
+
+void XConsolidationDescriptor::testGetUseColumnHeaders()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get use column headers",
+ !xConsolidationDescriptor->getUseColumnHeaders());
+}
+
+void XConsolidationDescriptor::testSetUseColumnHeaders()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ xConsolidationDescriptor->setUseColumnHeaders(true);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set use column headers",
+ xConsolidationDescriptor->getUseColumnHeaders());
+}
+
+void XConsolidationDescriptor::testGetUseRowHeaders()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get use row headers",
+ !xConsolidationDescriptor->getUseRowHeaders());
+}
+
+void XConsolidationDescriptor::testSetUseRowHeaders()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ xConsolidationDescriptor->setUseRowHeaders(true);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set use row headers",
+ xConsolidationDescriptor->getUseRowHeaders());
+}
+
+void XConsolidationDescriptor::testGetInsertLinks()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get use insert links",
+ !xConsolidationDescriptor->getInsertLinks());
+}
+
+void XConsolidationDescriptor::testSetInsertLinks()
+{
+ uno::Reference<sheet::XConsolidationDescriptor> xConsolidationDescriptor(init(),
+ UNO_QUERY_THROW);
+
+ xConsolidationDescriptor->setInsertLinks(true);
+ CPPUNIT_ASSERT_MESSAGE("Unable to set use insert links",
+ xConsolidationDescriptor->getInsertLinks());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xdatabaserange.cxx b/test/source/sheet/xdatabaserange.cxx
new file mode 100644
index 000000000..933425c04
--- /dev/null
+++ b/test/source/sheet/xdatabaserange.cxx
@@ -0,0 +1,181 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xdatabaserange.hxx>
+
+#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/table/CellRangeAddress.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/table/XTableRows.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+
+#include <rtl/ustring.hxx>
+#include <cppunit/TestAssert.h>
+#include <iostream>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+/**
+ * tests setDataArea and getDataArea
+ */
+void XDatabaseRange::testDataArea()
+{
+ uno::Reference< sheet::XDatabaseRange > xDBRange(init("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 = xDBRange->getDataArea();
+ CPPUNIT_ASSERT_EQUAL( aCellAddress.Sheet, aValue.Sheet );
+ CPPUNIT_ASSERT_EQUAL( aCellAddress.StartRow, aValue.StartRow );
+ CPPUNIT_ASSERT_EQUAL( aCellAddress.EndRow, aValue.EndRow );
+ CPPUNIT_ASSERT_EQUAL( aCellAddress.StartColumn, aValue.StartColumn );
+ CPPUNIT_ASSERT_EQUAL( aCellAddress.EndColumn, aValue.EndColumn );
+}
+
+void XDatabaseRange::testGetSubtotalDescriptor()
+{
+ uno::Reference< sheet::XDatabaseRange > xDBRange(init("SubtotalDescriptor"), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSubTotalDescriptor> xSubtotalDescr = xDBRange->getSubTotalDescriptor();
+ CPPUNIT_ASSERT(xSubtotalDescr.is());
+}
+
+void XDatabaseRange::testGetSortDescriptor()
+{
+ uno::Reference< sheet::XDatabaseRange > xDBRange(init("SortDescriptor"), UNO_QUERY_THROW);
+ const uno::Sequence< beans::PropertyValue > xSortDescr = xDBRange->getSortDescriptor();
+ for (const beans::PropertyValue& aProp : xSortDescr)
+ {
+ //std::cout << "Prop " << i << " Name: " << OUString(aProp.Name) << std::endl;
+
+ if (aProp.Name == "IsSortColumns")
+ {
+ bool bIsSortColumns = true;
+ aProp.Value >>= bIsSortColumns;
+ CPPUNIT_ASSERT(bIsSortColumns);
+ }
+ else if (aProp.Name == "ContainsHeader")
+ {
+ bool bContainsHeader = true;
+ aProp.Value >>= bContainsHeader;
+ CPPUNIT_ASSERT(bContainsHeader);
+ }
+ else if (aProp.Name == "MaxFieldCount")
+ {
+ sal_Int32 nMaxFieldCount = 0;
+ aProp.Value >>= nMaxFieldCount;
+ std::cout << "Value: " << nMaxFieldCount << std::endl;
+
+ }
+ else if (aProp.Name == "SortFields")
+ {
+
+ }
+ else if (aProp.Name == "BindFormatsToContent")
+ {
+ bool bBindFormatsToContent = false;
+ aProp.Value >>= bBindFormatsToContent;
+ CPPUNIT_ASSERT(bBindFormatsToContent);
+ }
+ else if (aProp.Name == "CopyOutputData")
+ {
+ bool bCopyOutputData = true;
+ aProp.Value >>= bCopyOutputData;
+ CPPUNIT_ASSERT(!bCopyOutputData);
+ }
+ else if (aProp.Name == "OutputPosition")
+ {
+
+ }
+ else if (aProp.Name == "IsUserListEnabled")
+ {
+ bool bIsUserListEnabled = true;
+ aProp.Value >>= bIsUserListEnabled;
+ CPPUNIT_ASSERT(!bIsUserListEnabled);
+
+ }
+ else if (aProp.Name == "UserListIndex")
+ {
+ sal_Int32 nUserListIndex = 1;
+ aProp.Value >>= nUserListIndex;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nUserListIndex);
+ }
+ }
+}
+
+void XDatabaseRange::testGetFilterDescriptor()
+{
+ uno::Reference< sheet::XDatabaseRange > xDBRange( init("FilterDescriptor"), UNO_QUERY_THROW);
+ uno::Reference< uno::XInterface > xFilterDescr( xDBRange->getFilterDescriptor(), UNO_QUERY_THROW);
+}
+
+void XDatabaseRange::testGetImportDescriptor()
+{
+ uno::Reference< sheet::XDatabaseRange > xDBRange( init("ImportDescriptor"), UNO_QUERY_THROW);
+ uno::Sequence< beans::PropertyValue > xImportDescr = xDBRange->getImportDescriptor();
+ (void) xImportDescr;
+}
+
+void XDatabaseRange::testRefresh()
+{
+ uno::Reference< sheet::XDatabaseRange > xDBRange( init("Refresh"), UNO_QUERY_THROW);
+
+ const sal_Int32 nCol = 0;
+ OUString aHidden("IsVisible");
+ uno::Reference< sheet::XCellRangeReferrer > xCellRangeReferrer(xDBRange, UNO_QUERY_THROW);
+ uno::Reference< table::XCellRange > xCellRange = xCellRangeReferrer->getReferredCells();
+
+ for (sal_Int32 i = 1; i < 5; ++i)
+ {
+ uno::Reference< table::XCell > xCell = xCellRange->getCellByPosition(nCol, i);
+ xCell->setValue(0);
+ }
+
+ for (sal_Int32 i = 2; i < 5; ++i)
+ {
+ uno::Reference< table::XColumnRowRange > xColRowRange(xCellRange, UNO_QUERY_THROW);
+ uno::Reference< table::XTableRows > xRows = xColRowRange->getRows();
+ uno::Reference< table::XCellRange > xRow(xRows->getByIndex(i), UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySet > xPropRow(xRow, UNO_QUERY_THROW);
+ Any aAny = xPropRow->getPropertyValue( aHidden );
+
+ CPPUNIT_ASSERT(aAny.get<bool>());
+ }
+
+ xDBRange->refresh();
+ std::cout << "after refresh" << std::endl;
+
+ for (sal_Int32 i = 1; i < 5; ++i)
+ {
+ uno::Reference< table::XColumnRowRange > xColRowRange(xCellRange, UNO_QUERY_THROW);
+ uno::Reference< table::XTableRows > xRows = xColRowRange->getRows();
+ uno::Reference< table::XCellRange > xRow(xRows->getByIndex(i), UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySet > xPropRow(xRow, UNO_QUERY_THROW);
+ Any aAny = xPropRow->getPropertyValue( aHidden );
+
+ CPPUNIT_ASSERT(!aAny.get<bool>());
+ }
+
+
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xdatabaseranges.cxx b/test/source/sheet/xdatabaseranges.cxx
new file mode 100644
index 000000000..650a0faa3
--- /dev/null
+++ b/test/source/sheet/xdatabaseranges.cxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xdatabaseranges.hxx>
+
+#include <com/sun/star/sheet/XDatabaseRanges.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XDatabaseRanges::testAddRemoveDbRanges()
+{
+ uno::Reference<sheet::XDatabaseRanges> xDbRanges(init(), UNO_QUERY_THROW);
+
+ xDbRanges->addNewByName("addNewRange", table::CellRangeAddress(0, 1, 2, 3, 4));
+ CPPUNIT_ASSERT_MESSAGE("Unable to add new db range", xDbRanges->hasByName("addNewRange"));
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "No exception thrown, when adding range with existing name",
+ xDbRanges->addNewByName("addNewRange", table::CellRangeAddress(0, 1, 2, 3, 4)),
+ css::uno::RuntimeException);
+
+ xDbRanges->removeByName("addNewRange");
+ CPPUNIT_ASSERT_MESSAGE("Unable to remove db range", !xDbRanges->hasByName("addNewRange"));
+
+ CPPUNIT_ASSERT_THROW_MESSAGE("No exception, when removing none-existing range",
+ xDbRanges->removeByName("addNewRange"),
+ css::uno::RuntimeException);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xdatapilotdescriptor.cxx b/test/source/sheet/xdatapilotdescriptor.cxx
new file mode 100644
index 000000000..a9cbcf5b1
--- /dev/null
+++ b/test/source/sheet/xdatapilotdescriptor.cxx
@@ -0,0 +1,192 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#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/TestAssert.h>
+
+#include <o3tl/safeint.hxx>
+#include <rtl/ustring.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+std::vector< OUString > XDataPilotDescriptor::maFieldNames;
+
+void XDataPilotDescriptor::testTag()
+{
+ OUString aTag("DataPilotDescriptor_Tag");
+ uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(), UNO_QUERY_THROW);
+ xDescr->setTag(aTag);
+ OUString aNewTag = xDescr->getTag();
+ CPPUNIT_ASSERT_EQUAL( 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 = xDescr->getSourceRange();
+
+ CPPUNIT_ASSERT_EQUAL(aAddress.Sheet, aReturn.Sheet);
+ CPPUNIT_ASSERT_EQUAL(aAddress.StartColumn, aReturn.StartColumn);
+ CPPUNIT_ASSERT_EQUAL(aAddress.StartRow, aReturn.StartRow);
+ CPPUNIT_ASSERT_EQUAL(aAddress.EndColumn, aReturn.EndColumn);
+ CPPUNIT_ASSERT_EQUAL(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 > const & xDescr)
+{
+ uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataPilotFields(), UNO_SET_THROW);
+
+ sal_Int32 nCount = xIndex->getCount();
+
+ OUString aOrientation("Orientation");
+ for (sal_Int32 i = 0; i < nCount && i < 5; ++i)
+ {
+ uno::Reference< container::XNamed > xNamed( xIndex->getByIndex( i ), UNO_QUERY_THROW);
+ OUString aName = xNamed->getName();
+ maFieldNames.push_back(aName);
+ CPPUNIT_ASSERT( aName != "Data" );
+
+ uno::Reference< beans::XPropertySet > xPropSet( xNamed, UNO_QUERY_THROW);
+
+ 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;
+ }
+ }
+}
+
+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_SET_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_SET_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_SET_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_SET_THROW);
+
+ checkName( xIndex, 2 );
+}
+
+void XDataPilotDescriptor::testGetHiddenFields()
+{
+ uno::Reference< sheet::XDataPilotDescriptor > xDescr(init(),UNO_QUERY_THROW);
+ testGetDataPilotFields_Impl( xDescr );
+ uno::Reference< container::XIndexAccess > xIndex(xDescr->getHiddenFields(), UNO_SET_THROW);
+
+ checkName( xIndex, 3 );
+}
+
+void XDataPilotDescriptor::checkName( uno::Reference< container::XIndexAccess > const & xIndex, sal_Int32 nIndex )
+{
+ CPPUNIT_ASSERT(xIndex.is());
+ CPPUNIT_ASSERT(maFieldNames.size() >= o3tl::make_unsigned(nIndex));
+
+ for (sal_Int32 i = 0; i < xIndex->getCount(); ++i)
+ {
+ uno::Reference< container::XNamed > xNamed( xIndex->getByIndex(i), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(maFieldNames[nIndex], xNamed->getName());
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xdatapilotfield.cxx b/test/source/sheet/xdatapilotfield.cxx
new file mode 100644
index 000000000..9f14709e6
--- /dev/null
+++ b/test/source/sheet/xdatapilotfield.cxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xdatapilotfield.hxx>
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/sheet/XDataPilotField.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XDataPilotField::testGetItems()
+{
+ uno::Reference<sheet::XDataPilotField> xDPF(init(), UNO_QUERY_THROW);
+
+ uno::Reference<container::XIndexAccess> xIA(xDPF->getItems(), UNO_SET_THROW);
+
+ const sal_Int32 nCount = xIA->getCount();
+ CPPUNIT_ASSERT_MESSAGE("No items found", sal_Int32(0) != nCount);
+
+ for (auto i = 0; i < nCount; i++)
+ {
+ CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to access element at position " + std::to_string(i),
+ xIA->getByIndex(i));
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xdatapilotfieldgrouping.cxx b/test/source/sheet/xdatapilotfieldgrouping.cxx
new file mode 100644
index 000000000..d3ca40d13
--- /dev/null
+++ b/test/source/sheet/xdatapilotfieldgrouping.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xdatapilotfieldgrouping.hxx>
+
+#include <com/sun/star/sheet/XDataPilotFieldGrouping.hpp>
+#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::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< 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 000000000..5934532dc
--- /dev/null
+++ b/test/source/sheet/xdatapilottable.cxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xdatapilottable.hxx>
+#include <com/sun/star/sheet/XDataPilotTable.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+
+void XDataPilotTable::testGetOutputRange()
+{
+ uno::Reference< sheet::XDataPilotTable > xDPTable(init(),UNO_QUERY_THROW);
+
+ table::CellRangeAddress aRange = xDPTable->getOutputRange();
+ CPPUNIT_ASSERT_EQUAL( sal_Int16(0), aRange.Sheet );
+ CPPUNIT_ASSERT_EQUAL( sal_Int32(7), aRange.StartColumn );
+ CPPUNIT_ASSERT_EQUAL( sal_Int32(8), aRange.StartRow );
+}
+
+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);
+}
+
+XDataPilotTable::~XDataPilotTable()
+{
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xdatapilottable2.cxx b/test/source/sheet/xdatapilottable2.cxx
new file mode 100644
index 000000000..f894743dc
--- /dev/null
+++ b/test/source/sheet/xdatapilottable2.cxx
@@ -0,0 +1,276 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xdatapilottable2.hxx>
+#include <com/sun/star/sheet/XDataPilotTable2.hpp>
+#include <com/sun/star/sheet/DataPilotTableResultData.hpp>
+#include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
+#include <com/sun/star/sheet/DataPilotOutputRangeType.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/sheet/XCellAddressable.hpp>
+#include <com/sun/star/table/XCellCursor.hpp>
+#include <com/sun/star/sheet/XCellRangeData.hpp>
+#include <com/sun/star/sheet/DataResult.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <cppunit/TestAssert.h>
+#include <numeric>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+XDataPilotTable2::~XDataPilotTable2()
+{
+}
+
+void XDataPilotTable2::testGetPositionData()
+{
+ uno::Reference< sheet::XDataPilotTable2 > xDPTable(initDP2(), UNO_QUERY_THROW);
+ getOutputRanges(xDPTable);
+ table::CellAddress aAddr;
+
+ aAddr.Sheet = maRangeTable.Sheet;
+ for (sal_Int32 x = maRangeTable.StartColumn; x <= maRangeTable.EndColumn; ++x)
+ {
+ for (sal_Int32 y = maRangeTable.StartRow; y <= maRangeTable.EndRow; ++y)
+ {
+ aAddr.Column = x;
+ aAddr.Row = y;
+
+ sheet::DataPilotTablePositionData aPosData = xDPTable->getPositionData(aAddr);
+ if (aPosData.PositionType == sheet::DataPilotTablePositionType::NOT_IN_TABLE)
+ {
+ CPPUNIT_ASSERT(false);
+ }
+ }
+ }
+}
+
+void XDataPilotTable2::testGetDrillDownData()
+{
+ uno::Reference< sheet::XDataPilotTable2 > xDPTable(initDP2(), UNO_QUERY_THROW);
+
+ getOutputRanges(xDPTable);
+ buildDataFields(xDPTable);
+ buildResultCells(xDPTable);
+
+ for (const auto& rResultCell : maResultCells)
+ {
+ sheet::DataPilotTablePositionData aPosData = xDPTable->getPositionData(rResultCell);
+ Any aTempAny = aPosData.PositionData;
+ sheet::DataPilotTableResultData aResData;
+ CPPUNIT_ASSERT(aTempAny >>= aResData);
+ sal_Int32 nDim = maDataFieldDims[aResData.DataFieldIndex];
+ sheet::DataResult aRes = aResData.Result;
+ double nVal = aRes.Value;
+
+ Sequence< Sequence<Any> > aData = xDPTable->getDrillDownData(rResultCell);
+ double sum = 0;
+
+ if( aData.getLength() > 1 )
+ {
+ sum = std::accumulate(std::next(aData.begin()), aData.end(), double(0),
+ [nDim](double res, const Sequence<Any>& rSeq) {
+ double nValue = 0;
+ if (rSeq[nDim] >>= nValue)
+ return res + nValue;
+ return res;
+ });
+ }
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(nVal, sum, 1E-12);
+ }
+
+
+}
+
+void XDataPilotTable2::testGetOutputRangeByType()
+{
+ uno::Reference< sheet::XDataPilotTable2 > xDPTable(initDP2(), UNO_QUERY_THROW);
+ getOutputRanges(xDPTable);
+
+ // check for wrong arguments
+ bool bCaught = false;
+ try
+ {
+ xDPTable->getOutputRangeByType(-1);
+ }
+ catch ( const lang::IllegalArgumentException& )
+ {
+ bCaught = true;
+ }
+ CPPUNIT_ASSERT(bCaught);
+
+ bCaught = false;
+ try
+ {
+ xDPTable->getOutputRangeByType(100);
+ }
+ catch ( const lang::IllegalArgumentException& )
+ {
+ bCaught = true;
+ }
+ CPPUNIT_ASSERT(bCaught);
+
+ // make sure the whole range is not empty
+ CPPUNIT_ASSERT( maRangeWhole.EndColumn - maRangeWhole.StartColumn > 0);
+ CPPUNIT_ASSERT( maRangeWhole.EndRow - maRangeWhole.StartRow > 0);
+
+ //table range must be of equal width with the whole range, and the same bottom
+ CPPUNIT_ASSERT_EQUAL( maRangeWhole.Sheet, maRangeTable.Sheet );
+ CPPUNIT_ASSERT_EQUAL( maRangeWhole.EndRow, maRangeTable.EndRow );
+ CPPUNIT_ASSERT_EQUAL( maRangeWhole.StartColumn, maRangeTable.StartColumn );
+ CPPUNIT_ASSERT_EQUAL( maRangeWhole.EndColumn, maRangeTable.EndColumn );
+
+ //result range must be smaller than the table range, and must share the same lower-right corner
+ CPPUNIT_ASSERT_EQUAL( maRangeTable.Sheet, maRangeResult.Sheet );
+ CPPUNIT_ASSERT( maRangeResult.StartColumn >= maRangeTable.StartColumn );
+ CPPUNIT_ASSERT( maRangeResult.StartRow >= maRangeTable.StartRow );
+ CPPUNIT_ASSERT_EQUAL( maRangeTable.EndRow, maRangeResult.EndRow );
+ CPPUNIT_ASSERT_EQUAL( maRangeTable.EndColumn, maRangeResult.EndColumn );
+
+}
+
+void XDataPilotTable2::testInsertDrillDownSheet()
+{
+ uno::Reference< sheet::XDataPilotTable2 > xDPTable(initDP2(), UNO_QUERY_THROW);
+ sal_Int32 nCellCount = maResultCells.size();
+
+ uno::Reference< sheet::XSpreadsheets > xSheets(getSheets(), UNO_QUERY_THROW);
+ uno::Reference< container::XIndexAccess > xIA(xSheets, UNO_QUERY_THROW);
+ sal_Int32 nSheetCount = xIA->getCount();
+
+ for (sal_Int32 i = 0; i < nCellCount; ++i)
+ {
+ table::CellAddress aAddr = maResultCells[i];
+ uno::Sequence< uno::Sequence< Any > > aData = xDPTable->getDrillDownData(aAddr);
+ xDPTable->insertDrillDownSheet(aAddr);
+
+ sal_Int32 nNewSheetCount= xIA->getCount();
+ if (nNewSheetCount == nSheetCount + 1)
+ {
+ CPPUNIT_ASSERT(aData.getLength() >= 2);
+ uno::Reference< sheet::XSpreadsheet > xSheet(xIA->getByIndex(aAddr.Sheet),UNO_QUERY_THROW);
+
+ checkDrillDownSheetContent(xSheet, aData);
+
+ uno::Reference< container::XNamed > xNamed(xSheet, UNO_QUERY_THROW);
+ OUString aName = xNamed->getName();
+ xSheets->removeByName(aName);
+ }
+ else if (nNewSheetCount == nSheetCount)
+ {
+ if (aData.getLength() > 1)
+ {
+ CPPUNIT_ASSERT(false);
+ }
+ }
+ else
+ {
+ CPPUNIT_ASSERT(false);
+ }
+
+ }
+}
+
+void XDataPilotTable2::buildResultCells( uno::Reference< sheet::XDataPilotTable2 > const & xDPTable)
+{
+ getOutputRanges(xDPTable);
+ maResultCells.clear();
+
+ for ( sal_Int32 x = maRangeResult.StartColumn; x < maRangeResult.EndColumn; ++x)
+ {
+ for( sal_Int32 y = maRangeResult.StartRow; y < maRangeResult.EndRow; ++y)
+ {
+ table::CellAddress aAddr;
+ aAddr.Sheet = maRangeResult.Sheet;
+ aAddr.Column = x;
+ aAddr.Row = y;
+ sheet::DataPilotTablePositionData aPosData = xDPTable->getPositionData(aAddr);
+ if (aPosData.PositionType != sheet::DataPilotTablePositionType::RESULT)
+ {
+ CPPUNIT_ASSERT(false);
+ }
+ maResultCells.push_back(aAddr);
+ }
+ }
+}
+
+void XDataPilotTable2::getOutputRanges( uno::Reference< sheet::XDataPilotTable2 > const & xDPTable)
+{
+ maRangeWhole = xDPTable->getOutputRangeByType(sheet::DataPilotOutputRangeType::WHOLE);
+ maRangeTable = xDPTable->getOutputRangeByType(sheet::DataPilotOutputRangeType::TABLE);
+ maRangeResult = xDPTable->getOutputRangeByType(sheet::DataPilotOutputRangeType::RESULT);
+}
+
+void XDataPilotTable2::buildDataFields( uno::Reference< sheet::XDataPilotTable2 > const & xDPTable )
+{
+ uno::Reference< sheet::XDataPilotDescriptor > xDesc(xDPTable, UNO_QUERY_THROW);
+ uno::Reference< container::XIndexAccess > xIndex(xDesc->getDataPilotFields(), UNO_SET_THROW);
+
+ sal_Int32 nFieldCount = xIndex->getCount();
+ for( sal_Int32 i = 0; i < nFieldCount; ++i)
+ {
+ uno::Reference< beans::XPropertySet > xPropSet(xIndex->getByIndex(i), UNO_QUERY_THROW);
+ Any aAny = xPropSet->getPropertyValue("Orientation");
+ sheet::DataPilotFieldOrientation aOrientation;
+ CPPUNIT_ASSERT( aAny >>= aOrientation );
+
+ if ( aOrientation == sheet::DataPilotFieldOrientation_DATA )
+ {
+ maDataFieldDims.push_back( i );
+ }
+ }
+}
+
+namespace {
+
+table::CellAddress getLastUsedCellAddress( uno::Reference< sheet::XSpreadsheet > const & xSheet, sal_Int32 nCol, sal_Int32 nRow )
+{
+ uno::Reference< sheet::XSheetCellRange > xSheetRange( xSheet->getCellRangeByPosition(nCol, nRow, nCol, nRow), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetCellCursor > xCursor = xSheet->createCursorByRange(xSheetRange);
+ uno::Reference< table::XCellCursor > xCellCursor(xCursor, UNO_QUERY_THROW);
+ xCellCursor->gotoEnd();
+
+ uno::Reference< sheet::XCellAddressable > xCellAddr(xCursor->getCellByPosition(0, 0), UNO_QUERY_THROW);
+ return xCellAddr->getCellAddress();
+}
+
+}
+
+void XDataPilotTable2::checkDrillDownSheetContent(uno::Reference< sheet::XSpreadsheet > const & xSheet, const uno::Sequence< uno::Sequence< Any > >& aData)
+{
+ table::CellAddress aLastCell = getLastUsedCellAddress(xSheet, 0, 0);
+ CPPUNIT_ASSERT(aData.hasElements());
+ CPPUNIT_ASSERT(aLastCell.Row);
+ CPPUNIT_ASSERT(aLastCell.Column);
+
+ CPPUNIT_ASSERT_EQUAL(aData.getLength(), aLastCell.Row + 1);
+ CPPUNIT_ASSERT_EQUAL(aData[0].getLength(), aLastCell.Column + 1);
+
+ uno::Reference< table::XCellRange > xCellRange = xSheet->getCellRangeByPosition(0, 0, aLastCell.Column, aLastCell.Row);
+ uno::Reference< sheet::XCellRangeData > xCellRangeData(xCellRange, UNO_QUERY_THROW);
+
+ uno::Sequence< uno::Sequence< Any > > aSheetData = xCellRangeData->getDataArray();
+ for (sal_Int32 x = 0; x < aSheetData.getLength(); ++x)
+ {
+ for(sal_Int32 y = 0; y < aSheetData[x].getLength(); ++y)
+ {
+ Any& aCell1 = aSheetData[x][y];
+ const Any& aCell2 = aData[x][y];
+ CPPUNIT_ASSERT_EQUAL(aCell2, aCell1);
+ }
+ }
+}
+
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xdatapilottables.cxx b/test/source/sheet/xdatapilottables.cxx
new file mode 100644
index 000000000..b666650ea
--- /dev/null
+++ b/test/source/sheet/xdatapilottables.cxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xdatapilottables.hxx>
+
+#include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
+#include <com/sun/star/sheet/XDataPilotTables.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XDataPilotTables::testXDataPilotTables()
+{
+ uno::Reference<sheet::XDataPilotTables> xDPT(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XDataPilotDescriptor> xDPD(xDPT->createDataPilotDescriptor(),
+ UNO_SET_THROW);
+
+ xDPT->insertNewByName("XDataPilotTables", table::CellAddress(0, 9, 8), xDPD);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to insert new DataPilotTable", OUString("Filter"),
+ xSheet->getCellByPosition(9, 8)->getFormula());
+
+ CPPUNIT_ASSERT_THROW_MESSAGE(
+ "No exception thrown, when inserting element with existing name",
+ xDPT->insertNewByName("XDataPilotTables", table::CellAddress(0, 7, 7), xDPD),
+ css::uno::RuntimeException);
+
+ xDPT->removeByName("XDataPilotTables");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to remove DataPilotTable", OUString(""),
+ xSheet->getCellByPosition(9, 8)->getFormula());
+
+ CPPUNIT_ASSERT_THROW_MESSAGE("No exception, when removing no existing element",
+ xDPT->removeByName("XDataPilotTables"),
+ css::uno::RuntimeException);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xdatapilottablessupplier.cxx b/test/source/sheet/xdatapilottablessupplier.cxx
new file mode 100644
index 000000000..66b8d44ca
--- /dev/null
+++ b/test/source/sheet/xdatapilottablessupplier.cxx
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xdatapilottablessupplier.hxx>
+
+#include <com/sun/star/sheet/XDataPilotTables.hpp>
+#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XDataPilotTablesSupplier::testGetDataPilotTables()
+{
+ uno::Reference<sheet::XDataPilotTablesSupplier> xDPTS(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XDataPilotTables> xDPT(xDPTS->getDataPilotTables(), UNO_SET_THROW);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xddelink.cxx b/test/source/sheet/xddelink.cxx
new file mode 100644
index 000000000..cf56fe9cd
--- /dev/null
+++ b/test/source/sheet/xddelink.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xddelink.hxx>
+
+#include <com/sun/star/sheet/XDDELink.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XDDELink::testGetApplication()
+{
+ uno::Reference<sheet::XDDELink> xLink(init(), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getApplication()", OUString("soffice"),
+ xLink->getApplication());
+}
+void XDDELink::testGetItem()
+{
+ uno::Reference<sheet::XDDELink> xLink(init(), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getItem()", OUString("Sheet1.A1"),
+ xLink->getItem());
+}
+void XDDELink::testGetTopic()
+{
+ uno::Reference<sheet::XDDELink> xLink(init(), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getTopic()", m_URL, xLink->getTopic());
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xddelinks.cxx b/test/source/sheet/xddelinks.cxx
new file mode 100644
index 000000000..fc18a16a1
--- /dev/null
+++ b/test/source/sheet/xddelinks.cxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xddelinks.hxx>
+
+#include <com/sun/star/sheet/DDELinkMode.hpp>
+#include <com/sun/star/sheet/XDDELink.hpp>
+#include <com/sun/star/sheet/XDDELinks.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XDDELinks::testAddDDELink()
+{
+ uno::Reference<sheet::XDDELinks> xLinks(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XDDELink> xLink
+ = xLinks->addDDELink("soffice", m_aTopic, "Sheet1.A1", sheet::DDELinkMode_DEFAULT);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getApplication()", OUString("soffice"),
+ xLink->getApplication());
+ CPPUNIT_ASSERT_MESSAGE("Unable to execute getTopic()",
+ xLink->getTopic().endsWith("ScDDELinksObj.ods"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to execute getItem()", OUString("Sheet1.A1"),
+ xLink->getItem());
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xdocumentauditing.cxx b/test/source/sheet/xdocumentauditing.cxx
new file mode 100644
index 000000000..acbab0968
--- /dev/null
+++ b/test/source/sheet/xdocumentauditing.cxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xdocumentauditing.hxx>
+
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/frame/DispatchHelper.hpp>
+#include <com/sun/star/frame/XDispatchHelper.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/sheet/XDocumentAuditing.hpp>
+#include <com/sun/star/sheet/XSheetAuditing.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XDocumentAuditing::dispatch(const uno::Reference<frame::XFrame>& xFrame,
+ const uno::Sequence<beans::PropertyValue>& rArguments)
+{
+ uno::Reference<uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
+ uno::Reference<frame::XDispatchHelper> xDispatchHelper(frame::DispatchHelper::create(xContext),
+ UNO_SET_THROW);
+ CPPUNIT_ASSERT(xDispatchHelper.is());
+
+ uno::Reference<frame::XDispatchProvider> xDispatchProvider(xFrame, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xDispatchProvider.is());
+
+ xDispatchHelper->executeDispatch(xDispatchProvider, ".uno:AutoRefreshArrows", "", 0,
+ rArguments);
+}
+
+bool XDocumentAuditing::hasRightAmountOfShapes(const uno::Reference<drawing::XDrawPage>& xDrawPage,
+ sal_Int32 nElementCount, sal_Int32 nShapes)
+{
+ const sal_Int32 nCount = xDrawPage->getCount();
+ if (nCount != nElementCount + nShapes)
+ return false;
+ else
+ {
+ if (nShapes >= 0)
+ {
+ for (sal_Int32 i = nElementCount; i < nCount; i++)
+ {
+ uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(i), UNO_QUERY_THROW);
+ m_Position = xShape->getPosition();
+ }
+ }
+ }
+ return true;
+}
+
+void XDocumentAuditing::testRefreshArrows()
+{
+ uno::Reference<sheet::XDocumentAuditing> xDocumentAuditing(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc(xDocumentAuditing, UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), UNO_SET_THROW);
+ uno::Reference<container::XIndexAccess> xIA(xSheets, UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet1(xIA->getByIndex(0), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet2(xIA->getByIndex(1), UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPagesSupplier> xDPS(xDocumentAuditing, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDPS->getDrawPages()->getByIndex(1),
+ UNO_QUERY_THROW);
+
+ sal_Int32 nDrawPageElementCount = 0;
+ if (xDrawPage->hasElements())
+ nDrawPageElementCount = xDrawPage->getCount();
+
+ uno::Sequence<beans::PropertyValue> aPropertyValue(1);
+ uno::Any aValue;
+ aValue <<= false;
+ aPropertyValue[0].Name = "AutoRefreshArrows";
+ aPropertyValue[0].Value = aValue;
+ uno::Reference<frame::XModel> xModel(xDocumentAuditing, UNO_QUERY_THROW);
+ dispatch(xModel->getCurrentController()->getFrame(), aPropertyValue);
+
+ xSheet1->getCellByPosition(6, 6)->setValue(9);
+ uno::Reference<container::XNamed> xNA1(xSheet1, UNO_QUERY_THROW);
+ OUString sSheet1Name = xNA1->getName();
+
+ xSheet2->getCellByPosition(6, 6)->setValue(16);
+ xSheet2->getCellByPosition(6, 7)->setFormula("= SQRT(G7)");
+
+ uno::Reference<sheet::XSheetAuditing> xSheetAuditing(xSheet2, UNO_QUERY_THROW);
+ xSheetAuditing->showPrecedents(table::CellAddress(1, 6, 7));
+ bool bResult = hasRightAmountOfShapes(xDrawPage, nDrawPageElementCount, 1);
+ CPPUNIT_ASSERT_MESSAGE("Wrong amount of shapes on page", bResult);
+ awt::Point Position0 = m_Position;
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4, xSheet2->getCellByPosition(6, 7)->getValue(), 0.1);
+ xSheet2->getCellByPosition(6, 7)->setFormula("= SQRT(" + sSheet1Name + ".G7)");
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3, xSheet2->getCellByPosition(6, 7)->getValue(), 0.1);
+
+ bResult = hasRightAmountOfShapes(xDrawPage, nDrawPageElementCount, 1);
+ CPPUNIT_ASSERT_MESSAGE("Wrong amount of shapes on page", bResult);
+ awt::Point Position1 = m_Position;
+
+ CPPUNIT_ASSERT_MESSAGE("Arrow has been refreshed",
+ Position0.X == Position1.X && Position0.Y == Position1.Y);
+
+ xDocumentAuditing->refreshArrows();
+
+ bResult = hasRightAmountOfShapes(xDrawPage, nDrawPageElementCount, 1);
+ CPPUNIT_ASSERT_MESSAGE("Wrong amount of shapes on page", bResult);
+ awt::Point Position2 = m_Position;
+
+ CPPUNIT_ASSERT_MESSAGE("Arrow has not been refreshed",
+ Position1.X != Position2.X || Position1.Y != Position2.Y);
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xformulaquery.cxx b/test/source/sheet/xformulaquery.cxx
new file mode 100644
index 000000000..32540847e
--- /dev/null
+++ b/test/source/sheet/xformulaquery.cxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/cppunitasserthelper.hxx>
+#include <test/sheet/xformulaquery.hxx>
+
+#include <com/sun/star/sheet/XFormulaQuery.hpp>
+#include <com/sun/star/sheet/XSheetCellRanges.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XFormulaQuery::testQueryDependents()
+{
+ uno::Reference<sheet::XSpreadsheet> xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
+ xSheet->getCellByPosition(0, 0)->setValue(1);
+ xSheet->getCellByPosition(1, 0)->setValue(1);
+ xSheet->getCellByPosition(2, 0)->setValue(1);
+ xSheet->getCellByPosition(3, 0)->setValue(1);
+
+ uno::Reference<table::XCell> xCell = getXCell();
+ xCell->setFormula("=SUM(A1:D1)");
+
+ uno::Reference<sheet::XFormulaQuery> xFormulaQuery(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xSCR = xFormulaQuery->queryDependents(false);
+ uno::Sequence<table::CellRangeAddress> aCellRangeAddress = xSCR->getRangeAddresses();
+
+ CPPUNIT_ASSERT_EQUAL(aCellRangeAddress[m_nIdxDependents], m_aCellRangeAddressDependents);
+}
+
+void XFormulaQuery::testQueryPrecedents()
+{
+ uno::Reference<sheet::XSpreadsheet> xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
+ xSheet->getCellByPosition(0, 0)->setValue(1);
+ xSheet->getCellByPosition(1, 0)->setValue(1);
+ xSheet->getCellByPosition(2, 0)->setValue(1);
+ xSheet->getCellByPosition(3, 0)->setValue(1);
+ xSheet->getCellByPosition(1, 2)->setFormula("=A16 * 2");
+
+ uno::Reference<table::XCell> xCell = getXCell();
+ xCell->setFormula("=SUM(A1:D1)");
+
+ uno::Reference<sheet::XFormulaQuery> xFormulaQuery(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xSCR = xFormulaQuery->queryPrecedents(false);
+ uno::Sequence<table::CellRangeAddress> aCellRangeAddress = xSCR->getRangeAddresses();
+
+ CPPUNIT_ASSERT_EQUAL(aCellRangeAddress[m_nIdxPrecedents], m_aCellRangeAddressPrecedents);
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xfunctiondescriptions.cxx b/test/source/sheet/xfunctiondescriptions.cxx
new file mode 100644
index 000000000..1b4ef645e
--- /dev/null
+++ b/test/source/sheet/xfunctiondescriptions.cxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <random>
+
+#include <test/sheet/xfunctiondescriptions.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sheet/XFunctionDescriptions.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XFunctionDescriptions::testGetById()
+{
+ uno::Reference<sheet::XFunctionDescriptions> xFD(init(), UNO_QUERY_THROW);
+
+ const sal_Int32 nCount = xFD->getCount();
+ CPPUNIT_ASSERT_MESSAGE("No FunctionDescriptions available", 0 < nCount);
+
+ // first grab a random function descriptions
+ std::random_device rd;
+ std::mt19937 gen(rd());
+ std::uniform_int_distribution<> distr(0, nCount - 1);
+ int nNumber = distr(gen);
+
+ sal_Int32 aId1 = 0;
+ OUString aName1;
+ uno::Sequence<beans::PropertyValue> aProps1;
+ CPPUNIT_ASSERT(xFD->getByIndex(nNumber) >>= aProps1);
+ for (const auto& aProp : std::as_const(aProps1))
+ {
+ if (aProp.Name == "Id")
+ aId1 = aProp.Value.get<sal_Int32>();
+ if (aProp.Name == "Name")
+ aName1 = aProp.Value.get<OUString>();
+ }
+
+ // fetch the same descriptions by its id
+ sal_Int32 aId2 = 0;
+ OUString aName2;
+ const uno::Sequence<beans::PropertyValue> aProps2 = xFD->getById(aId1);
+ CPPUNIT_ASSERT_MESSAGE("Received empty FunctionDescriptions from getById()",
+ aProps2.hasElements());
+ for (const auto& aProp : aProps2)
+ {
+ if (aProp.Name == "Id")
+ aId2 = aProp.Value.get<sal_Int32>();
+ if (aProp.Name == "Name")
+ aName2 = aProp.Value.get<OUString>();
+ }
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Received wrong FunctionDescriptions (Id)", aId1, aId2);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Received wrong FunctionDescriptions (Name)", aName1, aName2);
+
+ CPPUNIT_ASSERT_THROW_MESSAGE("No IllegalArgumentException thrown", xFD->getById(-1),
+ css::lang::IllegalArgumentException);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xgoalseek.cxx b/test/source/sheet/xgoalseek.cxx
new file mode 100644
index 000000000..986af4056
--- /dev/null
+++ b/test/source/sheet/xgoalseek.cxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xgoalseek.hxx>
+#include <com/sun/star/sheet/XGoalSeek.hpp>
+#include <com/sun/star/sheet/GoalResult.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XGoalSeek::testSeekGoal()
+{
+ uno::Reference< sheet::XGoalSeek > xGoalSeek(init(), UNO_QUERY_THROW);
+
+ table::CellAddress aFormulaAddr(0,3,5);
+ table::CellAddress aVariableAddr(0,3,4);
+ sheet::GoalResult aResult = xGoalSeek->seekGoal(aFormulaAddr, aVariableAddr, "4");
+
+ double nDivergence = 0.01;
+ CPPUNIT_ASSERT( aResult.Divergence < nDivergence );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(16, aResult.Result, nDivergence);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xheaderfootercontent.cxx b/test/source/sheet/xheaderfootercontent.cxx
new file mode 100644
index 000000000..1683cc7e7
--- /dev/null
+++ b/test/source/sheet/xheaderfootercontent.cxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xheaderfootercontent.hxx>
+
+#include <com/sun/star/sheet/XHeaderFooterContent.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XHeaderFooterContent::testGetCenterText()
+{
+ uno::Reference<sheet::XHeaderFooterContent> xHFC(init(), UNO_QUERY_THROW);
+
+ uno::Reference<text::XText> xText(xHFC->getCenterText(), UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get center text", OUString("CENTER"),
+ xText->getString());
+}
+
+void XHeaderFooterContent::testGetLeftText()
+{
+ uno::Reference<sheet::XHeaderFooterContent> xHFC(init(), UNO_QUERY_THROW);
+
+ uno::Reference<text::XText> xText(xHFC->getLeftText(), UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get left text", OUString("LEFT"), xText->getString());
+}
+void XHeaderFooterContent::testGetRightText()
+{
+ uno::Reference<sheet::XHeaderFooterContent> xHFC(init(), UNO_QUERY_THROW);
+
+ uno::Reference<text::XText> xText(xHFC->getRightText(), UNO_SET_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get right text", OUString("RIGHT"), xText->getString());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xlabelrange.cxx b/test/source/sheet/xlabelrange.cxx
new file mode 100644
index 000000000..ed7195123
--- /dev/null
+++ b/test/source/sheet/xlabelrange.cxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xlabelrange.hxx>
+#include <test/cppunitasserthelper.hxx>
+
+#include <com/sun/star/sheet/XLabelRange.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XLabelRange::testGetSetDataArea()
+{
+ uno::Reference<sheet::XLabelRange> xLabelRange(init(), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get DataArea", table::CellRangeAddress(0, 0, 0, 0, 1),
+ xLabelRange->getDataArea());
+
+ table::CellRangeAddress aDataAddr(1, 0, 1, 0, 8);
+ xLabelRange->setDataArea(aDataAddr);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set DataArea", aDataAddr, xLabelRange->getDataArea());
+}
+
+void XLabelRange::testGetSetLabelArea()
+{
+ uno::Reference<sheet::XLabelRange> xLabelRange(init(), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get DataArea", table::CellRangeAddress(0, 0, 1, 0, 6),
+ xLabelRange->getLabelArea());
+
+ table::CellRangeAddress aLabelAddr(1, 0, 1, 0, 8);
+ xLabelRange->setLabelArea(aLabelAddr);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set LabelArea", aLabelAddr,
+ xLabelRange->getLabelArea());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xlabelranges.cxx b/test/source/sheet/xlabelranges.cxx
new file mode 100644
index 000000000..36e2edb45
--- /dev/null
+++ b/test/source/sheet/xlabelranges.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xlabelranges.hxx>
+
+#include <com/sun/star/sheet/XLabelRanges.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XLabelRanges::testAddNew()
+{
+ uno::Reference<sheet::XLabelRanges> xLabelRanges(init(), UNO_QUERY_THROW);
+
+ const sal_Int32 nCount = xLabelRanges->getCount();
+ xLabelRanges->addNew(table::CellRangeAddress(0, 1, 0, 1, 0),
+ table::CellRangeAddress(0, 1, 1, 1, 6));
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to add new range", nCount < xLabelRanges->getCount());
+}
+
+void XLabelRanges::testRemoveByIndex()
+{
+ uno::Reference<sheet::XLabelRanges> xLabelRanges(init(), UNO_QUERY_THROW);
+
+ const sal_Int32 nCount = xLabelRanges->getCount();
+ xLabelRanges->removeByIndex(nCount - 1);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to remove range", (nCount - 1), xLabelRanges->getCount());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xmultiformulatokens.cxx b/test/source/sheet/xmultiformulatokens.cxx
new file mode 100644
index 000000000..54e8a4e88
--- /dev/null
+++ b/test/source/sheet/xmultiformulatokens.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xmultiformulatokens.hxx>
+
+#include <com/sun/star/sheet/FormulaToken.hpp>
+#include <com/sun/star/sheet/XMultiFormulaTokens.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+
+namespace apitest
+{
+void XMultiFormulaTokens::testGetCount()
+{
+ uno::Reference<sheet::XMultiFormulaTokens> xMFT(init(), uno::UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xMFT->getCount());
+}
+
+void XMultiFormulaTokens::testGetSetTokens()
+{
+ uno::Reference<sheet::XMultiFormulaTokens> xMFT(init(), uno::UNO_QUERY_THROW);
+
+ uno::Sequence<sheet::FormulaToken> aTokens(1);
+ aTokens[0].OpCode = 2;
+ xMFT->setTokens(0, aTokens);
+
+ CPPUNIT_ASSERT_EQUAL(aTokens[0].OpCode, xMFT->getTokens(0)[0].OpCode);
+}
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xmultipleoperation.cxx b/test/source/sheet/xmultipleoperation.cxx
new file mode 100644
index 000000000..d97f26934
--- /dev/null
+++ b/test/source/sheet/xmultipleoperation.cxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xmultipleoperation.hxx>
+
+#include <com/sun/star/sheet/TableOperationMode.hpp>
+#include <com/sun/star/sheet/XCellAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XMultipleOperation.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XMultipleOperation::testSetTableOperation()
+{
+ uno::Reference<sheet::XMultipleOperation> xMultipleOperation(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XSpreadsheet> xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
+ uno::Reference<table::XCellRange> xCellRange(xSheet->getCellRangeByName("$A$20:$A$20"),
+ UNO_SET_THROW);
+ uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddr(xCellRange, UNO_QUERY_THROW);
+
+ uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(0, 19);
+ xCell->setFormula("=a18+a19");
+
+ uno::Reference<table::XCell> xCell1 = xSheet->getCellByPosition(0, 17);
+ uno::Reference<sheet::XCellAddressable> xCellAddr1(xCell1, UNO_QUERY_THROW);
+
+ uno::Reference<table::XCell> xCell2 = xSheet->getCellByPosition(0, 18);
+ uno::Reference<sheet::XCellAddressable> xCellAddr2(xCell2, UNO_QUERY_THROW);
+
+ fillCells(xSheet);
+ xMultipleOperation->setTableOperation(
+ xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_ROW,
+ xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress());
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,1 (OpMode: ROW)", 5.0,
+ xSheet->getCellByPosition(1, 1)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 2,1 (OpMode: ROW)", 10.0,
+ xSheet->getCellByPosition(2, 1)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 3,1 (OpMode: ROW)", 15.0,
+ xSheet->getCellByPosition(3, 1)->getValue());
+
+ fillCells(xSheet);
+ xMultipleOperation->setTableOperation(
+ xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_COLUMN,
+ xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress());
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,1 (OpMode: COLUMN)", 12.0,
+ xSheet->getCellByPosition(1, 1)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,2 (OpMode: COLUMN)", 24.0,
+ xSheet->getCellByPosition(1, 2)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,3 (OpMode: COLUMN)", 36.0,
+ xSheet->getCellByPosition(1, 3)->getValue());
+
+ fillCells(xSheet);
+ xMultipleOperation->setTableOperation(
+ xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_BOTH,
+ xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress());
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,1 (OpMode: BOTH)", 17.0,
+ xSheet->getCellByPosition(1, 1)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 2,2 (OpMode: BOTH)", 34.0,
+ xSheet->getCellByPosition(2, 2)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 3,3 (OpMode: BOTH)", 51.0,
+ xSheet->getCellByPosition(3, 3)->getValue());
+}
+
+void XMultipleOperation::fillCells(uno::Reference<sheet::XSpreadsheet> const& xSheet)
+{
+ for (unsigned int i = 1; i < 5; i++)
+ {
+ uno::Reference<table::XCell> xCellFill = xSheet->getCellByPosition(0, i);
+ xCellFill->setValue(i * 12);
+ xCellFill = xSheet->getCellByPosition(i, 0);
+ xCellFill->setValue(i * 5);
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xnamedrange.cxx b/test/source/sheet/xnamedrange.cxx
new file mode 100644
index 000000000..3647a859b
--- /dev/null
+++ b/test/source/sheet/xnamedrange.cxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xnamedrange.hxx>
+
+#include <com/sun/star/sheet/XNamedRange.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/sheet/NamedRangeFlag.hpp>
+
+#include <cppunit/TestAssert.h>
+#include <rtl/ustring.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XNamedRange::testGetContent()
+{
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial1");
+
+ OUString const aExpectedContent("$Sheet1.$B$1");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected content for initial1 on GetContent", xNamedRange->getContent(), aExpectedContent);
+}
+
+void XNamedRange::testSetContent()
+{
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial1");
+
+ OUString aExpectedContent;
+
+ // test a cell
+ aExpectedContent = "D1";
+ xNamedRange->setContent(aExpectedContent);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected content for initial1 after SetContent a cell", xNamedRange->getContent(), aExpectedContent);
+
+ // test a cellrange
+ aExpectedContent = "D1:D10";
+ xNamedRange->setContent(aExpectedContent);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected content for initial1 after SetContent a cellrange", xNamedRange->getContent(), aExpectedContent);
+
+ // test a formula
+ aExpectedContent = "=D10";
+ xNamedRange->setContent(aExpectedContent);
+ aExpectedContent = "D10";
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected content for initial1 after SetContent a formula", xNamedRange->getContent(), aExpectedContent);
+}
+
+void XNamedRange::testGetType()
+{
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial1");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type", sal_Int32(0), xNamedRange->getType());
+}
+
+void XNamedRange::testSetType()
+{
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial1");
+
+ sal_Int32 nType = ::sheet::NamedRangeFlag::ROW_HEADER;
+ xNamedRange->setType(nType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type ROW_HEADER after setting it", nType, xNamedRange->getType());
+
+ nType = ::sheet::NamedRangeFlag::COLUMN_HEADER;
+ xNamedRange->setType(nType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type COLUMN_HEADER after setting it", nType, xNamedRange->getType());
+
+ nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA;
+ xNamedRange->setType(nType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type FILTER_CRITERIA after setting it", nType, xNamedRange->getType());
+
+ nType = ::sheet::NamedRangeFlag::PRINT_AREA;
+ xNamedRange->setType(nType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type PRINT_AREA after setting it", nType, xNamedRange->getType());
+
+ nType = 0;
+ xNamedRange->setType(nType);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong expected Type 0 after setting it", nType, xNamedRange->getType());
+}
+
+void XNamedRange::testGetReferencePosition()
+{
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial2");
+
+ table::CellAddress aCellAddress = xNamedRange->getReferencePosition();
+ // the expected address is on B1, as it was the active cell when initial2 was created
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong SHEET reference position", sal_Int16(0), aCellAddress.Sheet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong COLUMN reference position", sal_Int32(1), aCellAddress.Column);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong ROW reference position", sal_Int32(0), aCellAddress.Row);
+}
+
+void XNamedRange::testSetReferencePosition()
+{
+ uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange("initial1");
+
+ table::CellAddress aBaseAddress(1,2,3);
+
+ xNamedRange->setReferencePosition(aBaseAddress);
+
+ table::CellAddress aCellAddress = xNamedRange->getReferencePosition();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong SHEET reference position after setting it", sal_Int16(1), aCellAddress.Sheet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong COLUMN reference position after setting it", sal_Int32(2), aCellAddress.Column);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong ROW reference position after setting it", sal_Int32(3), aCellAddress.Row);
+}
+
+}
+
+/* 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 000000000..3faa61893
--- /dev/null
+++ b/test/source/sheet/xnamedranges.cxx
@@ -0,0 +1,194 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xnamedranges.hxx>
+#include <rtl/ustring.hxx>
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/sheet/Border.hpp>
+#include <com/sun/star/sheet/NamedRangeFlag.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/sheet/XNamedRange.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+#include <iostream>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XNamedRanges::testAddNewByName()
+{
+ uno::Reference<sheet::XNamedRanges> xNamedRanges(init(), UNO_QUERY_THROW);
+ uno::Reference<container::XNameAccess> xNamedRangesNameAccess(getXNamedRanges(1),
+ UNO_QUERY_THROW);
+
+ table::CellAddress aBaseAddress(0, 0, 0);
+
+ sal_Int32 nType = 0;
+ OUString const aContent1("D1");
+ OUString aName1("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;
+ OUString const aContent2("D2");
+ OUString aName2("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;
+ OUString const aContent3("D3");
+ OUString aName3("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;
+ OUString const aContent4("D4");
+ OUString aName4("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;
+ OUString const aContent5("D5");
+ OUString aName5("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(getXNamedRanges(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(1, 0, 0, 3, 3);
+
+ 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_EQUAL(i, cellRangeAddress.EndColumn);
+ CPPUNIT_ASSERT_EQUAL(i, cellRangeAddress.StartColumn);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), cellRangeAddress.StartRow);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), cellRangeAddress.EndRow);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(1), cellRangeAddress.Sheet);
+ }
+
+ 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_EQUAL(i, cellRangeAddress.EndRow);
+ CPPUNIT_ASSERT_EQUAL(i, cellRangeAddress.StartRow);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), cellRangeAddress.StartColumn);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), cellRangeAddress.EndColumn);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(1), cellRangeAddress.Sheet);
+ }
+}
+
+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 does not exist, can't remove it", bHasIt);
+
+ if (bHasIt)
+ {
+ // remove existing
+ sal_Int32 nInitialCount = xIndex->getCount();
+ xNamedRanges->removeByName(maNameToRemove);
+ sal_Int32 nNewCount = xIndex->getCount();
+ CPPUNIT_ASSERT_EQUAL_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
+ xNamedRanges->removeByName(
+ "dummyNonExistingNamedRange"); // an exception should be raised here
+ }
+}
+
+void XNamedRanges::testOutputList()
+{
+ table::CellAddress aCellAddress(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(aCellAddress);
+
+ 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));
+ }
+}
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xprintareas.cxx b/test/source/sheet/xprintareas.cxx
new file mode 100644
index 000000000..8c5ffe3d0
--- /dev/null
+++ b/test/source/sheet/xprintareas.cxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xprintareas.hxx>
+#include <com/sun/star/sheet/XPrintAreas.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+ void XPrintAreas::testSetAndGetPrintTitleColumns()
+ {
+ uno::Reference< sheet::XPrintAreas > xPrintAreas(init(), UNO_QUERY_THROW);
+ xPrintAreas->setPrintTitleColumns(true);
+
+ CPPUNIT_ASSERT_MESSAGE("Wrong attribution at PrintTitleColumns", xPrintAreas->getPrintTitleColumns());
+
+ }
+
+ void XPrintAreas::testSetAndGetPrintTitleRows()
+ {
+ uno::Reference< sheet::XPrintAreas > xPrintAreas(init(), UNO_QUERY_THROW);
+ xPrintAreas->setPrintTitleRows(true);
+
+ CPPUNIT_ASSERT_MESSAGE("Wrong attribution at PrintTitleRows", xPrintAreas->getPrintTitleRows());
+ }
+
+ // the rest is right now in progress...
+
+
+}
diff --git a/test/source/sheet/xrecentfunctions.cxx b/test/source/sheet/xrecentfunctions.cxx
new file mode 100644
index 000000000..7dded7f35
--- /dev/null
+++ b/test/source/sheet/xrecentfunctions.cxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <random>
+
+#include <test/sheet/xrecentfunctions.hxx>
+
+#include <com/sun/star/sheet/XRecentFunctions.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XRecentFunctions::testGetRecentFunctionIds()
+{
+ uno::Reference<sheet::XRecentFunctions> xRecentFunctions(init(), UNO_QUERY_THROW);
+
+ uno::Sequence<sal_Int32> aIds = xRecentFunctions->getRecentFunctionIds();
+ const sal_Int32 nNumber = aIds.getLength();
+ CPPUNIT_ASSERT_MESSAGE("Recent IDs greater the max number",
+ nNumber <= xRecentFunctions->getMaxRecentFunctions());
+ for (int i = 0; i < nNumber - 1; i++)
+ for (int j = i + 1; j < nNumber; j++)
+ CPPUNIT_ASSERT_MESSAGE("Same IDs found", aIds[i] != aIds[j]);
+}
+
+void XRecentFunctions::testSetRecentFunctionIds()
+{
+ uno::Reference<sheet::XRecentFunctions> xRecentFunctions(init(), UNO_QUERY_THROW);
+
+ const sal_Int32 nMaxNumber = xRecentFunctions->getMaxRecentFunctions();
+
+ // empty list
+ uno::Sequence<sal_Int32> aIds;
+ xRecentFunctions->setRecentFunctionIds(aIds);
+
+ aIds = xRecentFunctions->getRecentFunctionIds();
+ CPPUNIT_ASSERT_MESSAGE("Unable to set Ids (empty list)", !aIds.hasElements());
+
+ // max. size list
+ aIds.realloc(nMaxNumber);
+ std::random_device rd;
+ std::mt19937 gen(rd());
+ std::uniform_int_distribution<> distr(1, nMaxNumber + 1);
+
+ int nStartIdx = distr(gen);
+ for (int i = nStartIdx; i < nStartIdx + nMaxNumber; i++)
+ aIds[i - nStartIdx] = 1;
+
+ xRecentFunctions->setRecentFunctionIds(aIds);
+
+ aIds = xRecentFunctions->getRecentFunctionIds();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set Ids (max. size list)", nMaxNumber,
+ aIds.getLength());
+}
+
+void XRecentFunctions::testGetMaxRecentFunctions()
+{
+ uno::Reference<sheet::XRecentFunctions> xRecentFunctions(init(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("Unable to execute getMaxRecentFunctions()",
+ sal_Int32(0) != xRecentFunctions->getMaxRecentFunctions());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xscenario.cxx b/test/source/sheet/xscenario.cxx
new file mode 100644
index 000000000..9d874d951
--- /dev/null
+++ b/test/source/sheet/xscenario.cxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xscenario.hxx>
+
+#include <com/sun/star/sheet/XScenario.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XScenario::testScenario()
+{
+ uno::Reference<sheet::XScenario> xScenario(getScenarioSpreadsheet(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("Sheet is not a Scenario sheet", xScenario->getIsScenario());
+
+ uno::Sequence<table::CellRangeAddress> aCellRangeAddr(1);
+ xScenario->addRanges(aCellRangeAddr);
+ xScenario->apply();
+
+ CPPUNIT_ASSERT_MESSAGE("Unable add and apply ranges", xScenario->getIsScenario());
+ CPPUNIT_ASSERT_MESSAGE("Unable execute getScenarioComment()",
+ !xScenario->getScenarioComment().isEmpty());
+
+ xScenario->setScenarioComment("Test");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable execute setScenarioComment()", OUString("Test"),
+ xScenario->getScenarioComment());
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xscenarioenhanced.cxx b/test/source/sheet/xscenarioenhanced.cxx
new file mode 100644
index 000000000..ed4d934b6
--- /dev/null
+++ b/test/source/sheet/xscenarioenhanced.cxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xscenarioenhanced.hxx>
+#include <test/cppunitasserthelper.hxx>
+
+#include <com/sun/star/sheet/XScenarioEnhanced.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XScenarioEnhanced::testGetRanges()
+{
+ uno::Reference<sheet::XScenarioEnhanced> xSE(getScenarioSpreadsheet(), UNO_QUERY_THROW);
+
+ uno::Sequence<table::CellRangeAddress> aCellRangeAddr = xSE->getRanges();
+ CPPUNIT_ASSERT_MESSAGE("No ranges found", aCellRangeAddr.hasElements());
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong CellRangeAddres", table::CellRangeAddress(1, 0, 0, 10, 10),
+ aCellRangeAddr[0]);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xscenarios.cxx b/test/source/sheet/xscenarios.cxx
new file mode 100644
index 000000000..d2335dda7
--- /dev/null
+++ b/test/source/sheet/xscenarios.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xscenarios.hxx>
+
+#include <com/sun/star/sheet/XScenarios.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XScenarios::testAddNewByName()
+{
+ uno::Reference<sheet::XScenarios> xScenarios(init(), UNO_QUERY_THROW);
+
+ uno::Sequence<table::CellRangeAddress> aCellRangeAddresses(1);
+ aCellRangeAddresses[0] = table::CellRangeAddress(0, 0, 0, 0, 0);
+
+ xScenarios->addNewByName("XScenarios2", aCellRangeAddresses, "new");
+ CPPUNIT_ASSERT_MESSAGE("Unable to add new XScenario", xScenarios->hasByName("XScenarios2"));
+}
+
+void XScenarios::testRemoveByName()
+{
+ uno::Reference<sheet::XScenarios> xScenarios(init(), UNO_QUERY_THROW);
+
+ xScenarios->removeByName("XScenarios");
+ CPPUNIT_ASSERT_MESSAGE("Unable to remove XScenario", !xScenarios->hasByName("XScenario"));
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xscenariossupplier.cxx b/test/source/sheet/xscenariossupplier.cxx
new file mode 100644
index 000000000..3b9ff68d4
--- /dev/null
+++ b/test/source/sheet/xscenariossupplier.cxx
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xscenariossupplier.hxx>
+
+#include <com/sun/star/sheet/XScenarios.hpp>
+#include <com/sun/star/sheet/XScenariosSupplier.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XScenariosSupplier::testGetScenarios()
+{
+ uno::Reference<sheet::XScenariosSupplier> xSupplier(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XScenarios> xScenarios(xSupplier->getScenarios(), UNO_SET_THROW);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetannotation.cxx b/test/source/sheet/xsheetannotation.cxx
new file mode 100644
index 000000000..1ce4e1a79
--- /dev/null
+++ b/test/source/sheet/xsheetannotation.cxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetannotation.hxx>
+
+#include <com/sun/star/table/CellAddress.hpp>
+
+#include <cppunit/TestAssert.h>
+#include <rtl/ustring.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XSheetAnnotation::testGetPosition()
+{
+ uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
+ table::CellAddress aResultCellAddress = aSheetAnnotation->getPosition();
+
+ //expected result
+ table::CellAddress aExpectedCellAddress;
+ aExpectedCellAddress.Sheet = 0;
+ aExpectedCellAddress.Row = 1;
+ aExpectedCellAddress.Column = 2;
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong SHEET reference position", aExpectedCellAddress.Sheet, aResultCellAddress.Sheet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong COLUMN reference position", aExpectedCellAddress.Column, aResultCellAddress.Column);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong ROW reference position", aExpectedCellAddress.Row, aResultCellAddress.Row);
+}
+
+void XSheetAnnotation::testGetAuthor()
+{
+ uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
+ OUString aAuthor = aSheetAnnotation->getAuthor();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong author", OUString("LG"), aAuthor);
+}
+void XSheetAnnotation::testGetDate()
+{
+ uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
+ OUString aDate = aSheetAnnotation->getDate();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong date", OUString("01/17/2013"), aDate);
+}
+void XSheetAnnotation::testGetIsVisible()
+{
+ uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
+ bool isVisible = aSheetAnnotation->getIsVisible();
+
+ CPPUNIT_ASSERT_MESSAGE("Wrong visible state", isVisible);
+}
+void XSheetAnnotation::testSetIsVisible()
+{
+ uno::Reference< sheet::XSheetAnnotation > aSheetAnnotation (init(), UNO_QUERY_THROW);
+ aSheetAnnotation->setIsVisible(false);
+ bool isVisible = aSheetAnnotation->getIsVisible();
+
+ CPPUNIT_ASSERT_MESSAGE("Visible state not changed", !isVisible);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xsheetannotationanchor.cxx b/test/source/sheet/xsheetannotationanchor.cxx
new file mode 100644
index 000000000..9fbf4b00d
--- /dev/null
+++ b/test/source/sheet/xsheetannotationanchor.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetannotationanchor.hxx>
+#include <test/cppunitasserthelper.hxx>
+
+#include <com/sun/star/sheet/XSheetAnnotation.hpp>
+#include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XSheetAnnotationAnchor::testGetAnnotation()
+{
+ uno::Reference<sheet::XSheetAnnotationAnchor> xAnchor(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetAnnotation> xAnnotation(xAnchor->getAnnotation(), UNO_SET_THROW);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get XSheetAnnotation", xAnnotation.is());
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to check: getAuthor()", xAnnotation->getAuthor().isEmpty());
+ CPPUNIT_ASSERT_MESSAGE("Unable to check: getDate()", !xAnnotation->getDate().isEmpty());
+ CPPUNIT_ASSERT_MESSAGE("Unable to check: getIsVisible()", !xAnnotation->getIsVisible());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to check: getPosition()", table::CellAddress(0, 2, 3),
+ xAnnotation->getPosition());
+
+ xAnnotation->setIsVisible(false);
+ CPPUNIT_ASSERT_MESSAGE("Unable to setIsVisible() to false", !xAnnotation->getIsVisible());
+ xAnnotation->setIsVisible(true);
+ CPPUNIT_ASSERT_MESSAGE("Unable to setIsVisible() to true", xAnnotation->getIsVisible());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetannotations.cxx b/test/source/sheet/xsheetannotations.cxx
new file mode 100644
index 000000000..9f082eeb9
--- /dev/null
+++ b/test/source/sheet/xsheetannotations.cxx
@@ -0,0 +1,212 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetannotations.hxx>
+
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/sheet/XSheetAnnotation.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
+#include <cppunit/TestAssert.h>
+#include <rtl/ustring.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XSheetAnnotations::testCount()
+{
+ uno::Reference< sheet::XSheetAnnotations > aSheetAnnotations (init(), UNO_QUERY_THROW);
+
+ // count on sheet 1 before inserting
+ uno::Reference< container::XIndexAccess > xAnnotationsIndex (aSheetAnnotations, UNO_QUERY_THROW);
+ sal_Int32 nBefore = xAnnotationsIndex->getCount();
+
+ // get Sheet 2 annotations
+ uno::Reference< sheet::XSheetAnnotations > xSheet2Annotations( getAnnotations(1), UNO_SET_THROW);
+
+ // insert a note on sheet 2
+ table::CellAddress aTargetCellAddress (1,0,0);
+ xSheet2Annotations->insertNew(aTargetCellAddress, "an inserted annotation on sheet 2");
+
+ // count again on sheet 1
+ sal_Int32 nAfter = xAnnotationsIndex->getCount();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Annotations count should not change on sheet 1", nBefore, nAfter);
+}
+
+void XSheetAnnotations::testInsertNew()
+{
+ uno::Reference< sheet::XSheetAnnotations > aSheetAnnotations (init(), UNO_QUERY_THROW);
+
+ // count before inserting
+ uno::Reference< container::XIndexAccess > xAnnotationsIndex (aSheetAnnotations, UNO_QUERY_THROW);
+ sal_Int32 nBefore = xAnnotationsIndex->getCount();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "There should already be one note", sal_Int32(1), nBefore );
+
+ // insert the annotation
+ table::CellAddress aTargetCellAddress (0,3,4);
+ aSheetAnnotations->insertNew(aTargetCellAddress, "an inserted annotation");
+
+ // count after inserting
+ //uno::Reference< container::XIndexAccess > xAnnotationsIndexAfter (aSheetAnnotations, UNO_QUERY_THROW);
+ sal_Int32 nAfter = xAnnotationsIndex->getCount();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Annotations index not updated", nBefore + 1, nAfter);
+
+ // is the position ok ?
+ uno::Reference< sheet::XSheetAnnotation > aLastSheetAnnotation (xAnnotationsIndex->getByIndex(nAfter-1), UNO_QUERY_THROW);
+ table::CellAddress aResultCellAddress = aLastSheetAnnotation->getPosition();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Insert Annotation - Wrong SHEET reference position",
+ aTargetCellAddress.Sheet, aResultCellAddress.Sheet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Insert Annotation - Wrong COLUMN reference position",
+ aTargetCellAddress.Column, aResultCellAddress.Column);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Insert Annotation - Wrong ROW reference position",
+ aTargetCellAddress.Row, aResultCellAddress.Row);
+
+ // is the string ok ?
+ uno::Reference< text::XTextRange > aTextSheetAnnotation(aLastSheetAnnotation, UNO_QUERY_THROW);
+ OUString aString = aTextSheetAnnotation->getString();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Insert Annotation - Wrong string", OUString("an inserted annotation"),
+ aString);
+
+}
+
+void XSheetAnnotations::testRemoveByIndex()
+{
+ uno::Reference< sheet::XSheetAnnotations > aSheetAnnotations (init(), UNO_QUERY_THROW);
+
+ // insert some annotations
+ table::CellAddress aTargetCellAddress (0,4,5);
+ aSheetAnnotations->insertNew(aTargetCellAddress, "an inserted annotation 1");
+ table::CellAddress aToBeRemovedCellAddress (0,5,6);
+ aSheetAnnotations->insertNew(aToBeRemovedCellAddress, "an inserted annotation 2");
+ table::CellAddress aOtherCellAddress (0,7,8);
+ aSheetAnnotations->insertNew(aOtherCellAddress, "an inserted annotation 3");
+
+ // count before removing
+ uno::Reference< container::XIndexAccess > xAnnotationsIndex (aSheetAnnotations, UNO_QUERY_THROW);
+ sal_Int32 nBefore = xAnnotationsIndex->getCount();
+
+ // remove the xToBeRemovedCellAddress
+ aSheetAnnotations->removeByIndex(nBefore-2);
+
+ // count after removing
+ //uno::Reference< container::XIndexAccess > xAnnotationsIndex (aSheetAnnotations, UNO_QUERY_THROW);
+ sal_Int32 nAfter = xAnnotationsIndex->getCount();
+
+ // the last position should be xOtherCellAddress
+ uno::Reference< sheet::XSheetAnnotation > aLastSheetAnnotation (xAnnotationsIndex->getByIndex(nAfter-1), UNO_QUERY_THROW);
+ table::CellAddress aResultCellAddress = aLastSheetAnnotation->getPosition();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Remove Annotation - Wrong SHEET reference position",
+ aOtherCellAddress.Sheet, aResultCellAddress.Sheet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Remove Annotation - Wrong COLUMN reference position",
+ aOtherCellAddress.Column, aResultCellAddress.Column);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Remove Annotation - Wrong ROW reference position",
+ aOtherCellAddress.Row, aResultCellAddress.Row);
+
+ // is the string ok ?
+ uno::Reference< text::XTextRange > aLastTextSheetAnnotation(aLastSheetAnnotation, UNO_QUERY_THROW);
+ OUString aLastString = aLastTextSheetAnnotation->getString();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Remove Annotation - Wrong string",
+ OUString("an inserted annotation 3"), aLastString);
+
+ // the previous should be xTargetCellAddress
+ uno::Reference< sheet::XSheetAnnotation > aPreviousSheetAnnotation (xAnnotationsIndex->getByIndex(nAfter-2), UNO_QUERY_THROW);
+ table::CellAddress aPreviousCellAddress = aPreviousSheetAnnotation->getPosition();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Remove Annotation - Wrong SHEET reference position",
+ aTargetCellAddress.Sheet, aPreviousCellAddress.Sheet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Remove Annotation - Wrong COLUMN reference position",
+ aTargetCellAddress.Column, aPreviousCellAddress.Column);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Remove Annotation - Wrong ROW reference position",
+ aTargetCellAddress.Row, aPreviousCellAddress.Row);
+
+ // is the string ok ?
+ uno::Reference< text::XTextRange > aPreviousTextSheetAnnotation(aPreviousSheetAnnotation, UNO_QUERY_THROW);
+ OUString aPreviousString = aPreviousTextSheetAnnotation->getString();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "Remove Annotation - Wrong string",
+ OUString("an inserted annotation 1"), aPreviousString);
+}
+
+void XSheetAnnotations::testIndex()
+{
+
+ // testing #fdo80551 - getByIndex not on the first sheet
+
+ // insert annotations in first sheet
+ uno::Reference< sheet::XSheetAnnotations > aSheet0Annotations (init(), UNO_QUERY_THROW);
+ table::CellAddress aTargetCellAddress0 (0,0,1);
+ aSheet0Annotations->insertNew(aTargetCellAddress0, "an inserted annotation 1 on sheet 1");
+ table::CellAddress aSecondTargetCellAddress0 (0,0,2);
+ aSheet0Annotations->insertNew(aSecondTargetCellAddress0, "an inserted annotation 2 on sheet 1");
+ table::CellAddress aThirdCellAddress0 (0,0,3);
+ aSheet0Annotations->insertNew(aThirdCellAddress0, "an inserted annotation 3 on sheet 1");
+
+ // insert annotations in third sheet
+ uno::Reference< sheet::XSheetAnnotations > aSheet2Annotations (getAnnotations(2), UNO_SET_THROW);
+ table::CellAddress aTargetCellAddress2 (2,4,5);
+ aSheet2Annotations->insertNew(aTargetCellAddress2, "an inserted annotation 1 on sheet 3");
+ table::CellAddress aSecondTargetCellAddress2 (2,5,6);
+ aSheet2Annotations->insertNew(aSecondTargetCellAddress2, "an inserted annotation 2 on sheet 3");
+ table::CellAddress aThirdCellAddress2 (2,7,8);
+ aSheet2Annotations->insertNew(aThirdCellAddress2, "an inserted annotation 3 on sheet 3");
+
+ // get second annotation for second sheet
+ uno::Reference< sheet::XSheetAnnotations > aSheetAnnotations (getAnnotations(2), UNO_SET_THROW);
+ uno::Reference< container::XIndexAccess > xAnnotationsIndex (aSheetAnnotations, UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetAnnotation > aAnnotation (xAnnotationsIndex->getByIndex(1), UNO_QUERY_THROW);
+
+ table::CellAddress aToBeAnalyzedCellAddress = aAnnotation->getPosition();
+
+ // is the CellAddress ok ?
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "GetByIndex Annotation - Wrong SHEET reference position",
+ aSecondTargetCellAddress2.Sheet, aToBeAnalyzedCellAddress.Sheet);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "GetByIndex Annotation - Wrong COLUMN reference position",
+ aSecondTargetCellAddress2.Column, aToBeAnalyzedCellAddress.Column);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "GetByIndex Annotation - Wrong ROW reference position",
+ aSecondTargetCellAddress2.Row, aToBeAnalyzedCellAddress.Row);
+
+ // is the string ok ?
+ uno::Reference< text::XTextRange > aTextSheetAnnotation(aAnnotation, UNO_QUERY_THROW);
+ OUString aString = aTextSheetAnnotation->getString();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ "GetByIndex Annotation - Wrong string",
+ OUString("an inserted annotation 2 on sheet 3"), aString);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xsheetannotationshapesupplier.cxx b/test/source/sheet/xsheetannotationshapesupplier.cxx
new file mode 100644
index 000000000..9b2cd6d77
--- /dev/null
+++ b/test/source/sheet/xsheetannotationshapesupplier.cxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetannotationshapesupplier.hxx>
+
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/sheet/XSheetAnnotationShapeSupplier.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+
+namespace apitest {
+
+void XSheetAnnotationShapeSupplier::testGetAnnotationShape()
+{
+ uno::Reference< sheet::XSheetAnnotationShapeSupplier > xSheetAnnotationShapeSupplier(init(), UNO_QUERY_THROW);
+ uno::Reference< drawing::XShape > xShape = xSheetAnnotationShapeSupplier->getAnnotationShape();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("getAnnotationShape() wrong X position",
+ sal_Int32(7373), xShape->getPosition().X);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("getAnnotationShape() wrong Y position",
+ sal_Int32(426), xShape->getPosition().Y);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("getAnnotationShape() wrong width",
+ sal_Int32(11275), xShape->getSize().Width);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("getAnnotationShape() wrong height",
+ sal_Int32(1386), xShape->getSize().Height);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xsheetannotationssupplier.cxx b/test/source/sheet/xsheetannotationssupplier.cxx
new file mode 100644
index 000000000..aa6f7fd1c
--- /dev/null
+++ b/test/source/sheet/xsheetannotationssupplier.cxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetannotationssupplier.hxx>
+
+#include <com/sun/star/sheet/XSheetAnnotations.hpp>
+#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XSheetAnnotationsSupplier::testGetAnnotations()
+{
+ uno::Reference<sheet::XSheetAnnotationsSupplier> xSupplier(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XSheetAnnotations> xAnnotations(xSupplier->getAnnotations(),
+ UNO_SET_THROW);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetauditing.cxx b/test/source/sheet/xsheetauditing.cxx
new file mode 100644
index 000000000..992a7441c
--- /dev/null
+++ b/test/source/sheet/xsheetauditing.cxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetauditing.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/sheet/XSheetAuditing.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/ValidationType.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XSheetAuditing::testShowHideDependents()
+{
+ uno::Reference<sheet::XSheetAuditing> xAuditing(init(), UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
+ const sal_Int32 nElements = xDrawPage->getCount();
+
+ xAuditing->showDependents(table::CellAddress(0, 8, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to showDependents()", nElements + 1,
+ xDrawPage->getCount());
+
+ xAuditing->hideDependents(table::CellAddress(0, 8, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to hideDependents()", nElements, xDrawPage->getCount());
+}
+
+void XSheetAuditing::testShowHidePrecedents()
+{
+ uno::Reference<sheet::XSheetAuditing> xAuditing(init(), UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
+ const sal_Int32 nElements = xDrawPage->getCount();
+
+ xAuditing->showPrecedents(table::CellAddress(0, 8, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to showPrecedents()", nElements + 2,
+ xDrawPage->getCount());
+
+ xAuditing->hidePrecedents(table::CellAddress(0, 8, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to showPrecedents()", nElements, xDrawPage->getCount());
+}
+
+void XSheetAuditing::testClearArrows()
+{
+ uno::Reference<sheet::XSheetAuditing> xAuditing(init(), UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
+ const sal_Int32 nElements = xDrawPage->getCount();
+
+ xAuditing->showPrecedents(table::CellAddress(0, 8, 6));
+ xAuditing->showDependents(table::CellAddress(0, 8, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set arrows", nElements + 3, xDrawPage->getCount());
+
+ xAuditing->clearArrows();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to clear arrows", nElements, xDrawPage->getCount());
+}
+
+void XSheetAuditing::testShowErrors()
+{
+ uno::Reference<sheet::XSheetAuditing> xAuditing(init(), UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
+ const sal_Int32 nElements = xDrawPage->getCount();
+
+ uno::Reference<sheet::XSpreadsheet> xSheet(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(7, 6);
+ xCell->setValue(-9);
+ xCell->setFormula("=SQRT(" + OUStringChar(static_cast<char>('A' + 7)) + OUString::number(7)
+ + ")");
+
+ uno::Reference<text::XText> xText(xCell, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("No error code", OUString("Err:522"), xText->getString());
+
+ xAuditing->showErrors(table::CellAddress(0, 7, 6));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to show errors", nElements + 1, xDrawPage->getCount());
+}
+
+void XSheetAuditing::testShowInvalid()
+{
+ uno::Reference<sheet::XSheetAuditing> xAuditing(init(), UNO_QUERY_THROW);
+
+ uno::Reference<drawing::XDrawPageSupplier> xDPS(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDPS->getDrawPage();
+ const sal_Int32 nElements = xDrawPage->getCount();
+
+ uno::Reference<sheet::XSpreadsheet> xSheet(xAuditing, UNO_QUERY_THROW);
+ uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(7, 6);
+ xCell->setValue(2.5);
+
+ uno::Reference<beans::XPropertySet> xPropSet(xCell, UNO_QUERY_THROW);
+ uno::Any aValidation = xPropSet->getPropertyValue("Validation");
+ uno::Reference<beans::XPropertySet> xValidation(aValidation, UNO_QUERY_THROW);
+ uno::Any aAny;
+
+ aAny <<= sheet::ValidationType_WHOLE;
+ xValidation->setPropertyValue("Type", aAny);
+ aAny <<= xValidation;
+ xPropSet->setPropertyValue("Validation", aAny);
+ xAuditing->showInvalid();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to show invalid (WHOLE)", nElements + 1,
+ xDrawPage->getCount());
+
+ xAuditing->clearArrows();
+
+ aAny <<= sheet::ValidationType_ANY;
+ xValidation->setPropertyValue("Type", aAny);
+ aAny <<= xValidation;
+ xPropSet->setPropertyValue("Validation", aAny);
+
+ xAuditing->showInvalid();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to show invalid (ANY)", nElements, xDrawPage->getCount());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetcellcursor.cxx b/test/source/sheet/xsheetcellcursor.cxx
new file mode 100644
index 000000000..fcaeb7fe7
--- /dev/null
+++ b/test/source/sheet/xsheetcellcursor.cxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetcellcursor.hxx>
+
+#include <com/sun/star/sheet/XArrayFormulaRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XSheetCellCursor.hpp>
+#include <com/sun/star/sheet/XSheetOperation.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <com/sun/star/util/XMergeable.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XSheetCellCursor::testCollapseToCurrentArray()
+{
+ uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor,
+ UNO_QUERY_THROW);
+ table::CellRangeAddress aCellRangeAddr = xCellRangeAddressable->getRangeAddress();
+ const sal_Int32 nHeight = aCellRangeAddr.EndRow - aCellRangeAddr.StartRow + 1;
+
+ uno::Reference<table::XCellRange> xCellRange
+ = xSheetCellCursor->getCellRangeByPosition(0, 0, 0, nHeight - 1);
+ uno::Reference<sheet::XArrayFormulaRange> xArrayFormulaRange(xCellRange, UNO_QUERY_THROW);
+ xArrayFormulaRange->setArrayFormula("A1:A" + OUString::number(nHeight));
+
+ xSheetCellCursor->collapseToSize(1, 1);
+ xSheetCellCursor->collapseToCurrentArray();
+
+ uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToCurrentArray (cols)", sal_Int32(1),
+ xColRowRange->getColumns()->getCount());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToCurrentArray (rows)", nHeight,
+ xColRowRange->getRows()->getCount());
+ xArrayFormulaRange->setArrayFormula("");
+}
+
+void XSheetCellCursor::testCollapseToCurrentRegion()
+{
+ uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
+
+ const sal_Int32 nWidth = 4, nHeight = 4;
+ uno::Reference<sheet::XSpreadsheet> xSheet = xSheetCellCursor->getSpreadsheet();
+ uno::Reference<sheet::XSheetOperation> xSheetOp(xSheet, UNO_QUERY_THROW);
+ xSheetOp->clearContents(65535);
+
+ xSheetCellCursor->collapseToCurrentRegion();
+ uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToCurrentRegion (cols)", nWidth,
+ xColRowRange->getColumns()->getCount());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToCurrentRegion (rows)", nHeight,
+ xColRowRange->getRows()->getCount());
+}
+
+void XSheetCellCursor::testCollapseToMergedArea()
+{
+ uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
+ xSheetCellCursor->collapseToSize(1, 1);
+
+ const sal_Int32 nLeftCol = 0, nTopRow = 0, nWidth = 8, nHeight = 8;
+ uno::Reference<sheet::XSpreadsheet> xSheet = xSheetCellCursor->getSpreadsheet();
+
+ uno::Reference<table::XCellRange> xCellRange = xSheet->getCellRangeByPosition(
+ nLeftCol + nWidth - 8, nTopRow + nHeight - 8, nLeftCol + nWidth, nTopRow + nHeight);
+
+ uno::Reference<util::XMergeable> xMergeable(xCellRange, UNO_QUERY_THROW);
+ xMergeable->merge(true);
+ CPPUNIT_ASSERT_MESSAGE("Unable to merge area", xMergeable->getIsMerged());
+ xSheetCellCursor->collapseToMergedArea();
+ xMergeable->merge(false);
+
+ uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToMergedArea (cols)", nWidth + 1,
+ xColRowRange->getColumns()->getCount());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToMergedArea (rows)", nHeight + 1,
+ xColRowRange->getRows()->getCount());
+}
+
+void XSheetCellCursor::testCollapseToSize()
+{
+ uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
+
+ const sal_Int32 nWidth = 1, nHeight = 1;
+ xSheetCellCursor->collapseToSize(nWidth + 3, nHeight + 3);
+
+ uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToSize (cols)", nWidth + 3,
+ xColRowRange->getColumns()->getCount());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to collapseToSize (rows)", nHeight + 3,
+ xColRowRange->getRows()->getCount());
+}
+
+void XSheetCellCursor::testExpandToEntireColumns()
+{
+ uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
+
+ xSheetCellCursor->expandToEntireColumns();
+
+ uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to expandToEntireColumns (cols)", sal_Int32(4),
+ xColRowRange->getColumns()->getCount());
+ CPPUNIT_ASSERT_MESSAGE("Unable to expandToEntireColumns (rows)",
+ xColRowRange->getRows()->getCount() >= sal_Int32(32000));
+}
+
+void XSheetCellCursor::testExpandToEntireRows()
+{
+ uno::Reference<sheet::XSheetCellCursor> xSheetCellCursor(init(), UNO_QUERY_THROW);
+
+ xSheetCellCursor->expandToEntireRows();
+
+ uno::Reference<table::XColumnRowRange> xColRowRange(xSheetCellCursor, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("Unable to expandToEntireRows (cols)",
+ xColRowRange->getColumns()->getCount() >= sal_Int32(256));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to expandToEntireRows (rows)", sal_Int32(4),
+ xColRowRange->getRows()->getCount());
+}
+}
+
+/* vim:set shiftnWidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetcellrange.cxx b/test/source/sheet/xsheetcellrange.cxx
new file mode 100644
index 000000000..a5714e324
--- /dev/null
+++ b/test/source/sheet/xsheetcellrange.cxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetcellrange.hxx>
+
+#include <com/sun/star/sheet/XSheetCellRange.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XSheetCellRange::testGetSpreadsheet()
+{
+ uno::Reference<sheet::XSheetCellRange> xSheetCellRange(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSpreadsheet> xSheet = xSheetCellRange->getSpreadsheet();
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get spreadsheet", xSheet.is());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetcellrangecontainer.cxx b/test/source/sheet/xsheetcellrangecontainer.cxx
new file mode 100644
index 000000000..3a4f356c7
--- /dev/null
+++ b/test/source/sheet/xsheetcellrangecontainer.cxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetcellrangecontainer.hxx>
+#include <test/cppunitasserthelper.hxx>
+
+#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XSheetCellRangeContainer::testAddRemoveRangeAddress()
+{
+ uno::Reference<sheet::XSheetCellRangeContainer> xSCRC(init(), UNO_QUERY_THROW);
+ xSCRC->removeRangeAddresses(xSCRC->getRangeAddresses()); // prepare a clean slate
+ uno::Sequence<table::CellRangeAddress> aAddr = createCellRangeAddresses();
+
+ sal_Int32 cnt = xSCRC->getCount();
+ xSCRC->addRangeAddress(aAddr[0], false);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add CellRangeAddress (count)", cnt + 1,
+ xSCRC->getCount());
+
+ uno::Sequence<table::CellRangeAddress> aAfterAddAddr = xSCRC->getRangeAddresses();
+ cnt = xSCRC->getCount();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add CellRangeAddress (entry)", aAddr[0],
+ aAfterAddAddr[cnt - 1]);
+
+ xSCRC->removeRangeAddress(aAddr[0]);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to remove CellRangeAddress (count)", cnt - 1,
+ xSCRC->getCount());
+
+ const uno::Sequence<table::CellRangeAddress> aAfterRemoveAddr = xSCRC->getRangeAddresses();
+ for (auto const& addr : aAfterRemoveAddr)
+ {
+ CPPUNIT_ASSERT_MESSAGE("Unable to remove CellRangeAddress (entry)", aAddr[0] != addr);
+ }
+}
+
+void XSheetCellRangeContainer::testAddRemoveRangeAddresses()
+{
+ uno::Reference<sheet::XSheetCellRangeContainer> xSCRC(init(), UNO_QUERY_THROW);
+ xSCRC->removeRangeAddresses(xSCRC->getRangeAddresses()); // prepare a clean slate
+ uno::Sequence<table::CellRangeAddress> aAddr = createCellRangeAddresses();
+
+ sal_Int32 cnt = xSCRC->getCount();
+ xSCRC->addRangeAddresses(aAddr, false);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add CellRangeAddress (count)", cnt + 2,
+ xSCRC->getCount());
+
+ uno::Sequence<table::CellRangeAddress> aAfterAddAddr = xSCRC->getRangeAddresses();
+ cnt = xSCRC->getCount();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add CellRangeAddresses (entry: first)", aAddr[0],
+ aAfterAddAddr[cnt - 2]);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add CellRangeAddresses (entry: second)", aAddr[1],
+ aAfterAddAddr[cnt - 1]);
+
+ xSCRC->removeRangeAddresses(aAddr);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to remove CellRangeAddresses (count)", cnt - 2,
+ xSCRC->getCount());
+
+ const uno::Sequence<table::CellRangeAddress> aAfterRemoveAddr = xSCRC->getRangeAddresses();
+ for (auto const& addr : aAfterRemoveAddr)
+ {
+ CPPUNIT_ASSERT_MESSAGE("Unable to remove CellRangeAddresses (entry: first)",
+ aAddr[0] != addr);
+ CPPUNIT_ASSERT_MESSAGE("Unable to remove CellRangeAddresses (entry: second)",
+ aAddr[1] != addr);
+ }
+}
+
+uno::Sequence<table::CellRangeAddress> XSheetCellRangeContainer::createCellRangeAddresses()
+{
+ uno::Sequence<table::CellRangeAddress> aAddr(2);
+ for (unsigned int i = 0; i < 2; i++)
+ {
+ aAddr[i].Sheet = i;
+ aAddr[i].StartColumn = i;
+ aAddr[i].StartRow = i;
+ aAddr[i].EndColumn = i + 3;
+ aAddr[i].EndRow = i + 3;
+ }
+
+ return aAddr;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetcellranges.cxx b/test/source/sheet/xsheetcellranges.cxx
new file mode 100644
index 000000000..d40a47e03
--- /dev/null
+++ b/test/source/sheet/xsheetcellranges.cxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetcellranges.hxx>
+
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/sheet/XSheetCellRanges.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XSheetCellRanges::testGetCells()
+{
+ uno::Reference<sheet::XSheetCellRanges> xSheetCellRanges(init(), UNO_QUERY_THROW);
+ uno::Reference<container::XEnumerationAccess> xEA = xSheetCellRanges->getCells();
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get cells", xEA->hasElements());
+}
+
+void XSheetCellRanges::testGetRangeAddresses()
+{
+ uno::Reference<sheet::XSheetCellRanges> xSheetCellRanges(init(), UNO_QUERY_THROW);
+ uno::Sequence<table::CellRangeAddress> aCellRangeAddress
+ = xSheetCellRanges->getRangeAddresses();
+ CPPUNIT_ASSERT_MESSAGE("Unable to get RangeAddresses", aCellRangeAddress.getLength() > 2);
+}
+
+void XSheetCellRanges::testGetRangeAddressesAsString()
+{
+ uno::Reference<sheet::XSheetCellRanges> xSheetCellRanges(init(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("Unable to get RangeAddresses (string)",
+ xSheetCellRanges->getRangeAddressesAsString().indexOf("C1:D4") > 0);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetcondition.cxx b/test/source/sheet/xsheetcondition.cxx
new file mode 100644
index 000000000..27068fec6
--- /dev/null
+++ b/test/source/sheet/xsheetcondition.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetcondition.hxx>
+
+#include <com/sun/star/sheet/ConditionOperator.hpp>
+#include <com/sun/star/sheet/XSheetCondition.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XSheetCondition::testGetSetFormula1()
+{
+ uno::Reference<sheet::XSheetCondition> xSheetCondition(init(), UNO_QUERY_THROW);
+ OUString aFormula1;
+ CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to get Formula1",
+ aFormula1 = xSheetCondition->getFormula1());
+
+ xSheetCondition->setFormula1("$Sheet1.$C$");
+ CPPUNIT_ASSERT_MESSAGE("Unable to set Formula1", aFormula1 != xSheetCondition->getFormula1());
+}
+
+void XSheetCondition::testGetSetFormula2()
+{
+ uno::Reference<sheet::XSheetCondition> xSheetCondition(init(), UNO_QUERY_THROW);
+ OUString aFormula2;
+ CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to get Formula2",
+ aFormula2 = xSheetCondition->getFormula2());
+
+ xSheetCondition->setFormula2("$Sheet1.$A$");
+ CPPUNIT_ASSERT_MESSAGE("Unable to set Formula2", aFormula2 != xSheetCondition->getFormula2());
+}
+
+void XSheetCondition::testGetSetOperator()
+{
+ uno::Reference<sheet::XSheetCondition> xSheetCondition(init(), UNO_QUERY_THROW);
+ sheet::ConditionOperator aOperator;
+ CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to get Operator",
+ aOperator = xSheetCondition->getOperator());
+
+ xSheetCondition->setOperator(sheet::ConditionOperator_BETWEEN);
+ sheet::ConditionOperator aOperatorNew = xSheetCondition->getOperator();
+ CPPUNIT_ASSERT_MESSAGE("Unable to set Operator", aOperator != aOperatorNew);
+}
+
+void XSheetCondition::testGetSetSourcePosition()
+{
+ uno::Reference<sheet::XSheetCondition> xSheetCondition(init(), UNO_QUERY_THROW);
+ table::CellAddress aSourcePosition(0, 0, 0);
+ CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to get SourcePosition",
+ aSourcePosition = xSheetCondition->getSourcePosition());
+
+ xSheetCondition->setSourcePosition(table::CellAddress(0, 1, 1));
+ table::CellAddress aSourcePositionNew = xSheetCondition->getSourcePosition();
+ CPPUNIT_ASSERT_MESSAGE("Unable to set SourcePosition",
+ aSourcePosition.Row != aSourcePositionNew.Row);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetconditionalentries.cxx b/test/source/sheet/xsheetconditionalentries.cxx
new file mode 100644
index 000000000..8062d42f5
--- /dev/null
+++ b/test/source/sheet/xsheetconditionalentries.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetconditionalentries.hxx>
+
+#include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XSheetConditionalEntries::testAddNew()
+{
+ uno::Reference<sheet::XSheetConditionalEntries> xSheetConditionalEntries(init(),
+ UNO_QUERY_THROW);
+ const sal_Int32 aCount = xSheetConditionalEntries->getCount();
+
+ xSheetConditionalEntries->addNew(createCondition(4));
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to add new condition", aCount + 1,
+ xSheetConditionalEntries->getCount());
+}
+
+void XSheetConditionalEntries::testClear()
+{
+ uno::Reference<sheet::XSheetConditionalEntries> xSheetConditionalEntries(init(),
+ UNO_QUERY_THROW);
+ xSheetConditionalEntries->clear();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to clear conditions", sal_Int32(0),
+ xSheetConditionalEntries->getCount());
+}
+
+void XSheetConditionalEntries::testRemoveByIndex()
+{
+ uno::Reference<sheet::XSheetConditionalEntries> xSheetConditionalEntries(init(),
+ UNO_QUERY_THROW);
+ const sal_Int32 aCount = xSheetConditionalEntries->getCount();
+
+ xSheetConditionalEntries->removeByIndex(0);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to remove condition", aCount - 1,
+ xSheetConditionalEntries->getCount());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetconditionalentry.cxx b/test/source/sheet/xsheetconditionalentry.cxx
new file mode 100644
index 000000000..0523d9be6
--- /dev/null
+++ b/test/source/sheet/xsheetconditionalentry.cxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetconditionalentry.hxx>
+
+#include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XSheetConditionalEntry::testGetSetStyleName()
+{
+ uno::Reference<sheet::XSheetConditionalEntry> xSheetConditionalEntry(init(), UNO_QUERY_THROW);
+ OUString aStyleName = xSheetConditionalEntry->getStyleName();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get StyleName", OUString("Result2"), aStyleName);
+
+ xSheetConditionalEntry->setStyleName("Heading");
+ CPPUNIT_ASSERT_MESSAGE("Unable to set StyleName",
+ aStyleName != xSheetConditionalEntry->getStyleName());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetfilterable.cxx b/test/source/sheet/xsheetfilterable.cxx
new file mode 100644
index 000000000..a6c8b5901
--- /dev/null
+++ b/test/source/sheet/xsheetfilterable.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetfilterable.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/FilterOperator.hpp>
+#include <com/sun/star/sheet/TableFilterField.hpp>
+#include <com/sun/star/sheet/XSheetFilterable.hpp>
+#include <com/sun/star/sheet/XSheetFilterDescriptor.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <com/sun/star/table/XTableRows.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XSheetFilterable::testCreateFilterDescriptor()
+{
+ uno::Reference< sheet::XSheetFilterable > xFA(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetFilterDescriptor > xSFD = xFA->createFilterDescriptor(true);
+
+ uno::Sequence< sheet::TableFilterField > xTFF;
+ xTFF.realloc(2);
+ xTFF[0].IsNumeric = true;
+ xTFF[0].Field = 0;
+ xTFF[0].NumericValue = 2;
+ xTFF[0].Operator = sheet::FilterOperator_GREATER_EQUAL;
+ xTFF[1].IsNumeric = false;
+ xTFF[1].Field = 1;
+ xTFF[1].StringValue = "C";
+ xTFF[1].Operator = sheet::FilterOperator_LESS;
+
+ CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to create XSheetFilterDescriptor", xSFD->setFilterFields(xTFF));
+}
+
+void XSheetFilterable::testFilter()
+{
+ uno::Reference< sheet::XSpreadsheet > xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
+
+ uno::Reference< sheet::XSheetFilterable > xFA(xSheet, UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetFilterDescriptor > xSFD = xFA->createFilterDescriptor(true);
+
+ uno::Sequence< sheet::TableFilterField > xTFF;
+ xTFF.realloc(2);
+ xTFF[0].IsNumeric = true;
+ xTFF[0].Field = 0;
+ xTFF[0].NumericValue = 2;
+ xTFF[0].Operator = sheet::FilterOperator_GREATER_EQUAL;
+ xTFF[1].IsNumeric = false;
+ xTFF[1].Field = 1;
+ xTFF[1].StringValue = "C";
+ xTFF[1].Operator = sheet::FilterOperator_LESS;
+ xSFD->setFilterFields(xTFF);
+
+ xSheet->getCellByPosition(0, 0)->setValue(1);
+ xSheet->getCellByPosition(0, 1)->setValue(2);
+ xSheet->getCellByPosition(0, 2)->setValue(3);
+ xSheet->getCellByPosition(1, 0)->setFormula("A");
+ xSheet->getCellByPosition(1, 1)->setFormula("B");
+ xSheet->getCellByPosition(1, 2)->setFormula("C");
+ xFA->filter(xSFD);
+
+ uno::Reference< table::XColumnRowRange > xColRowRange(xSheet, UNO_QUERY_THROW);
+ uno::Reference< table::XTableRows > xTableRows = xColRowRange->getRows();
+ uno::Reference< beans::XPropertySet > xRowProps(xTableRows->getByIndex(0), UNO_QUERY_THROW);
+ bool bIsVisible = true;
+ CPPUNIT_ASSERT(xRowProps->getPropertyValue("IsVisible") >>= bIsVisible);
+
+ CPPUNIT_ASSERT_MESSAGE("Row 1 should be invisible", !bIsVisible);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xsheetfilterableex.cxx b/test/source/sheet/xsheetfilterableex.cxx
new file mode 100644
index 000000000..eeecf737d
--- /dev/null
+++ b/test/source/sheet/xsheetfilterableex.cxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetfilterableex.hxx>
+
+#include <com/sun/star/sheet/FilterConnection.hpp>
+#include <com/sun/star/sheet/FilterOperator.hpp>
+#include <com/sun/star/sheet/TableFilterField.hpp>
+#include <com/sun/star/sheet/XSheetFilterDescriptor.hpp>
+#include <com/sun/star/sheet/XSheetFilterable.hpp>
+#include <com/sun/star/sheet/XSheetFilterableEx.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XSheetFilterableEx::testCreateFilterDescriptorByObject()
+{
+ uno::Reference<sheet::XSheetFilterableEx> xSFEx(init(), UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetFilterable> xSF(getXSpreadsheet(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XSheetFilterDescriptor> xSFD = xSFEx->createFilterDescriptorByObject(xSF);
+ CPPUNIT_ASSERT_MESSAGE("no XSheetFilterDescriptor", xSFD.is());
+
+ const uno::Sequence<sheet::TableFilterField> xTFF = xSFD->getFilterFields();
+ CPPUNIT_ASSERT_MESSAGE("The gained XSheetFilterDescriptor is empty", xTFF.hasElements());
+
+ for (const auto& field : xTFF)
+ {
+ // we don't care about the actual value, just that we can access the fields
+ CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: StringValue",
+ !field.StringValue.isEmpty() || field.StringValue.isEmpty());
+ CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: IsNumeric",
+ !field.IsNumeric || field.IsNumeric);
+ CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: NumericValue",
+ field.NumericValue != 0.0 || field.NumericValue == 0.0);
+ CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: Field",
+ field.Field != 0 || field.Field == 0);
+ CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: Connection",
+ field.Connection == sheet::FilterConnection_AND
+ || field.Connection == sheet::FilterConnection_OR);
+ CPPUNIT_ASSERT_MESSAGE("Unable to retrieve field: Operator",
+ field.Operator != sheet::FilterOperator_EMPTY);
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetfilterdescriptor.cxx b/test/source/sheet/xsheetfilterdescriptor.cxx
new file mode 100644
index 000000000..503cc84f8
--- /dev/null
+++ b/test/source/sheet/xsheetfilterdescriptor.cxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetfilterdescriptor.hxx>
+
+#include <com/sun/star/sheet/TableFilterField.hpp>
+#include <com/sun/star/sheet/XSheetFilterDescriptor.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XSheetFilterDescriptor::testGetSetFilterFields()
+{
+ uno::Reference<sheet::XSheetFilterDescriptor> xSFD(init(), uno::UNO_QUERY_THROW);
+ uno::Sequence<sheet::TableFilterField> aDefaultTFF = xSFD->getFilterFields();
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get TableFilterField", !aDefaultTFF.hasElements());
+
+ uno::Sequence<sheet::TableFilterField> aTFF;
+ aTFF.realloc(1);
+
+ xSFD->setFilterFields(aTFF);
+ uno::Sequence<sheet::TableFilterField> aNewTFF = xSFD->getFilterFields();
+ CPPUNIT_ASSERT_MESSAGE("Unable to set TableFilterField", aNewTFF != aDefaultTFF);
+}
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetfilterdescriptor2.cxx b/test/source/sheet/xsheetfilterdescriptor2.cxx
new file mode 100644
index 000000000..fc060f73c
--- /dev/null
+++ b/test/source/sheet/xsheetfilterdescriptor2.cxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetfilterdescriptor2.hxx>
+
+#include <com/sun/star/sheet/TableFilterField2.hpp>
+#include <com/sun/star/sheet/XSheetFilterDescriptor2.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XSheetFilterDescriptor2::testGetSetFilterFields2()
+{
+ uno::Reference<sheet::XSheetFilterDescriptor2> xSFD(init(), uno::UNO_QUERY_THROW);
+ uno::Sequence<sheet::TableFilterField2> aDefaultTFF = xSFD->getFilterFields2();
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get TableFilterField", !aDefaultTFF.hasElements());
+
+ uno::Sequence<sheet::TableFilterField2> aTFF;
+ aTFF.realloc(1);
+
+ xSFD->setFilterFields2(aTFF);
+ uno::Sequence<sheet::TableFilterField2> aNewTFF = xSFD->getFilterFields2();
+ CPPUNIT_ASSERT_MESSAGE("Unable to set TableFilterField", aNewTFF != aDefaultTFF);
+}
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetfilterdescriptor3.cxx b/test/source/sheet/xsheetfilterdescriptor3.cxx
new file mode 100644
index 000000000..e46a34552
--- /dev/null
+++ b/test/source/sheet/xsheetfilterdescriptor3.cxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetfilterdescriptor3.hxx>
+
+#include <com/sun/star/sheet/TableFilterField3.hpp>
+#include <com/sun/star/sheet/XSheetFilterDescriptor3.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XSheetFilterDescriptor3::testGetSetFilterFields3()
+{
+ uno::Reference<sheet::XSheetFilterDescriptor3> xSFD(init(), uno::UNO_QUERY_THROW);
+ uno::Sequence<sheet::TableFilterField3> aDefaultTFF = xSFD->getFilterFields3();
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get TableFilterField", !aDefaultTFF.hasElements());
+
+ uno::Sequence<sheet::TableFilterField3> aTFF;
+ aTFF.realloc(1);
+
+ xSFD->setFilterFields3(aTFF);
+ uno::Sequence<sheet::TableFilterField3> aNewTFF = xSFD->getFilterFields3();
+ CPPUNIT_ASSERT_MESSAGE("Unable to set TableFilterField", aNewTFF != aDefaultTFF);
+}
+
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsheetlinkable.cxx b/test/source/sheet/xsheetlinkable.cxx
new file mode 100644
index 000000000..aa394a006
--- /dev/null
+++ b/test/source/sheet/xsheetlinkable.cxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetlinkable.hxx>
+
+#include <com/sun/star/sheet/SheetLinkMode.hpp>
+#include <com/sun/star/sheet/XSheetLinkable.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XSheetLinkable::testSheetLinkable()
+{
+ uno::Reference< sheet::XSheetLinkable > xSheetLinkable(init(), UNO_QUERY_THROW);
+
+ xSheetLinkable->link(getFileURL(), "Sheet1", "", "", sheet::SheetLinkMode_VALUE);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get link mode",
+ sheet::SheetLinkMode_VALUE, xSheetLinkable->getLinkMode());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get link URL",
+ getFileURL(), xSheetLinkable->getLinkUrl());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to get sheet name",
+ OUString("Sheet1"), xSheetLinkable->getLinkSheetName());
+
+ xSheetLinkable->setLinkMode(sheet::SheetLinkMode_NONE);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set link mode",
+ sheet::SheetLinkMode_NONE, xSheetLinkable->getLinkMode());
+
+ xSheetLinkable->setLinkSheetName("Sheet2");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set sheet name",
+ OUString("Sheet2"), xSheetLinkable->getLinkSheetName());
+
+ xSheetLinkable->setLinkUrl(getFileURL());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set link URL",
+ getFileURL(), xSheetLinkable->getLinkUrl());
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xsheetoperation.cxx b/test/source/sheet/xsheetoperation.cxx
new file mode 100644
index 000000000..22015a40d
--- /dev/null
+++ b/test/source/sheet/xsheetoperation.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetoperation.hxx>
+
+#include <com/sun/star/sheet/CellFlags.hpp>
+#include <com/sun/star/sheet/GeneralFunction.hpp>
+#include <com/sun/star/sheet/XSheetOperation.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XSheetOperation::testClearContents()
+{
+ uno::Reference< sheet::XSheetOperation > xSheetOperation(init(), UNO_QUERY_THROW);
+
+ xSheetOperation->clearContents( sheet::CellFlags::VALUE | sheet::CellFlags::FORMULA );
+
+ double sum = xSheetOperation->computeFunction( sheet::GeneralFunction_SUM );
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to clean contents", 0.0, sum);
+}
+
+void XSheetOperation::testComputeFunction()
+{
+ uno::Reference< sheet::XSheetOperation > xSheetOperation(init(), UNO_QUERY_THROW);
+
+ double count = xSheetOperation->computeFunction( sheet::GeneralFunction_COUNT );
+ CPPUNIT_ASSERT_MESSAGE("Unable to compute function", count >= 0.0);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xsheetoutline.cxx b/test/source/sheet/xsheetoutline.cxx
new file mode 100644
index 000000000..4ee517b09
--- /dev/null
+++ b/test/source/sheet/xsheetoutline.cxx
@@ -0,0 +1,266 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetoutline.hxx>
+
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/table/TableOrientation.hpp>
+
+#include <com/sun/star/sheet/XSheetCellRanges.hpp>
+#include <com/sun/star/sheet/XSheetOutline.hpp>
+#include <com/sun/star/sheet/XCellRangesQuery.hpp>
+
+#include <cppunit/TestAssert.h>
+#include <rtl/ustring.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+const OUString colLevel1 = "OutlineSheet.A1:Z1";
+const OUString colLevel2 = "OutlineSheet.C1:W1";
+const OUString colLevel3 = "OutlineSheet.E1:U1";
+const OUString colLevel4 = "OutlineSheet.G1:S1";
+
+const OUString rowLevel1 = "OutlineSheet.A1:A30";
+const OUString rowLevel2 = "OutlineSheet.A3:A27";
+const OUString rowLevel3 = "OutlineSheet.A5:A24";
+const OUString rowLevel4 = "OutlineSheet.A7:A21";
+
+static OUString getVisibleAdress(
+ uno::Reference<sheet::XSpreadsheet> const& xSheet,
+ const OUString& aLevelRangeString)
+{
+
+ uno::Reference<table::XCellRange> aSheetRangeAccess(xSheet, UNO_QUERY_THROW);
+ uno::Reference<table::XCellRange> aLevelRange = aSheetRangeAccess->getCellRangeByName(aLevelRangeString);
+
+ uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(aLevelRange,UNO_QUERY_THROW);
+ uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells();
+ OUString aResult = xRanges->getRangeAddressesAsString();
+
+ return aResult;
+
+}
+
+static table::CellRangeAddress getAddressFromRangeString(
+ uno::Reference<sheet::XSpreadsheet> const& xSheet,
+ const OUString& aStringAddress)
+{
+
+ uno::Reference< table::XCellRange > aSheetRangeAccess(xSheet, UNO_QUERY_THROW);
+ uno::Reference<table::XCellRange> aRange = aSheetRangeAccess->getCellRangeByName(aStringAddress);
+
+ uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddressable(aRange, UNO_QUERY_THROW);
+ table::CellRangeAddress aLevelRangeAddress = xCellRangeAddressable->getRangeAddress();
+
+ return aLevelRangeAddress;
+
+}
+
+void XSheetOutline::testHideDetail()
+{
+
+ uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
+
+ // Column level 2
+ table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aSheet, colLevel2);
+ aSheetOutline->hideDetail(aLevelRangeAddress);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Column level 2 not hidden",
+ getVisibleAdress(aSheet, colLevel2), OUString());
+
+ // Row Level 2
+ aLevelRangeAddress = getAddressFromRangeString(aSheet, rowLevel2);
+ aSheetOutline->hideDetail(aLevelRangeAddress);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Row level 2 not hidden",
+ getVisibleAdress(aSheet, rowLevel2), OUString());
+
+}
+
+void XSheetOutline::testShowDetail()
+{
+ uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
+
+ aSheetOutline->showDetail(getAddressFromRangeString(aSheet, colLevel1));
+ aSheetOutline->showDetail(getAddressFromRangeString(aSheet, rowLevel1));
+
+ // Row Level 2
+ table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aSheet, rowLevel2);
+ aSheetOutline->showDetail(aLevelRangeAddress);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Row level 2 still hidden",
+ getVisibleAdress(aSheet, rowLevel2), rowLevel2);
+
+ // Column Level 2
+ aLevelRangeAddress = getAddressFromRangeString(aSheet, colLevel2);
+ aSheetOutline->showDetail(aLevelRangeAddress);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Column level 2 still hidden",
+ getVisibleAdress(aSheet, colLevel2), colLevel2);
+
+}
+
+void XSheetOutline::testShowLevel()
+{
+
+ uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
+
+ // test columns
+
+ table::CellRangeAddress aLevel1 = getAddressFromRangeString(aSheet, colLevel1);
+ table::CellRangeAddress aLevel2 = getAddressFromRangeString(aSheet, colLevel2);
+ table::CellRangeAddress aLevel3 = getAddressFromRangeString(aSheet, colLevel3);
+ table::CellRangeAddress aLevel4 = getAddressFromRangeString(aSheet, colLevel4);
+
+ aSheetOutline->showDetail(getAddressFromRangeString(aSheet, colLevel1));
+ aSheetOutline->showDetail(getAddressFromRangeString(aSheet, colLevel2));
+ aSheetOutline->showDetail(getAddressFromRangeString(aSheet, rowLevel1));
+
+ aSheetOutline->hideDetail(aLevel1);
+ aSheetOutline->hideDetail(aLevel2);
+ aSheetOutline->hideDetail(aLevel3);
+ aSheetOutline->hideDetail(aLevel4);
+
+ aSheetOutline->showLevel(2, table::TableOrientation_COLUMNS);
+
+ std::cout << " verify showLevel col apres" << getVisibleAdress(aSheet, "OutlineSheet.A1:Z30") << std::endl;
+
+ // verify that level 2 and level 1 are shown --> column 0..3 & column 22..26
+ // level 3 & 4 are hidden --> column 4..19
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Column", OUString("OutlineSheet.A1:D1"), getVisibleAdress(aSheet, "OutlineSheet.A1:D1"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Column", OUString("OutlineSheet.V1:Z1"), getVisibleAdress(aSheet, "OutlineSheet.V1:Z1"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Column", OUString(), getVisibleAdress(aSheet, colLevel3));
+
+/* FIXME !!
+
+ // test Rows
+
+ aLevel1 = getAddressFromRangeString(rowLevel1);
+ aLevel2 = getAddressFromRangeString(rowLevel2);
+ aLevel3 = getAddressFromRangeString(rowLevel3);
+ aLevel4 = getAddressFromRangeString(rowLevel4);
+
+ aSheetOutline->showDetail(getAddressFromRangeString(colLevel1));
+ aSheetOutline->showDetail(getAddressFromRangeString(rowLevel1));
+ aSheetOutline->showDetail(getAddressFromRangeString(rowLevel2));
+
+ std::cout << " verify showLevel row before" << OUStringToOString(getVisibleAdress("OutlineSheet.A1:Z30"), RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+
+ aSheetOutline->hideDetail(aLevel1);
+ aSheetOutline->hideDetail(aLevel2);
+ aSheetOutline->hideDetail(aLevel3);
+ aSheetOutline->hideDetail(aLevel4);
+
+ std::cout << " verify showLevel row just before" << OUStringToOString(getVisibleAdress("OutlineSheet.A1:Z30"), RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+
+ aSheetOutline->showLevel(2, table::TableOrientation_ROWS);
+
+ std::cout << " verify showLevel row after" << OUStringToOString(getVisibleAdress("OutlineSheet.A1:Z30"), RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+
+ // verify rows visible 0..3 & 24..29
+ // verify rows hidden 4..23
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Row", OUString("OutlineSheet.A1:A4"), getVisibleAdress("OutlineSheet.A1:A4"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Row", OUString("OutlineSheet.A25:A30"), getVisibleAdress("OutlineSheet.A25:A30"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testShowLevel Row", OUString(), getVisibleAdress(rowLevel3));
+
+*/
+
+}
+
+void XSheetOutline::testGroup()
+{
+
+ uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
+
+ // Column level 2
+ OUString aNewString = "OutlineSheet.AB1:AG1";
+ table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aSheet, aNewString);
+ aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_COLUMNS);
+
+ aSheetOutline->hideDetail(aLevelRangeAddress);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testGroup Column still visible", getVisibleAdress(aSheet, aNewString), OUString());
+
+ // Row Level 2
+ aNewString = "OutlineSheet.A50:A60";
+ aLevelRangeAddress = getAddressFromRangeString(aSheet, aNewString);
+ aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_ROWS);
+
+ aSheetOutline->hideDetail(aLevelRangeAddress);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testGroup Row still visible", getVisibleAdress(aSheet, aNewString), OUString());
+
+}
+
+void XSheetOutline::testUngroup()
+{
+ uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
+
+ // New Column level
+ OUString aNewString = "OutlineSheet.BB1:BG1";
+ table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aSheet, aNewString);
+ aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_COLUMNS);
+ aSheetOutline->hideDetail(aLevelRangeAddress);
+
+ aSheetOutline->ungroup(aLevelRangeAddress, table::TableOrientation_COLUMNS);
+
+ aSheetOutline->showDetail(aLevelRangeAddress);
+ // should remain hidden ?
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testUnGroup Column becomes visible after ungroup", getVisibleAdress(aSheet, aNewString), OUString());
+
+ // New Row level
+ aNewString = "OutlineSheet.A70:A80";
+ aLevelRangeAddress = getAddressFromRangeString(aSheet, aNewString);
+ aSheetOutline->group(aLevelRangeAddress, table::TableOrientation_ROWS);
+ aSheetOutline->hideDetail(aLevelRangeAddress);
+
+ aSheetOutline->ungroup(aLevelRangeAddress, table::TableOrientation_ROWS);
+
+ aSheetOutline->showDetail(aLevelRangeAddress);
+ // should remain hidden ?
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testUnGroup Row becomes visible after ungroup", getVisibleAdress(aSheet, aNewString), OUString());
+
+}
+
+void XSheetOutline::testClearOutline()
+{
+ uno::Reference< sheet::XSpreadsheet > aSheet(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetOutline > aSheetOutline(aSheet, UNO_QUERY_THROW);
+
+ aSheetOutline->clearOutline();
+
+ table::CellRangeAddress aLevelRangeAddress = getAddressFromRangeString(aSheet, colLevel1);
+ aSheetOutline->hideDetail(aLevelRangeAddress);
+ aLevelRangeAddress = getAddressFromRangeString(aSheet, rowLevel1);
+ aSheetOutline->hideDetail(aLevelRangeAddress);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testClearOutline Columns are hidden after clear", getVisibleAdress(aSheet, colLevel1), colLevel1);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("testClearOutline Rows are hidden after clear", getVisibleAdress(aSheet, rowLevel1), rowLevel1);
+
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xsheetpagebreak.cxx b/test/source/sheet/xsheetpagebreak.cxx
new file mode 100644
index 000000000..a1fde311c
--- /dev/null
+++ b/test/source/sheet/xsheetpagebreak.cxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsheetpagebreak.hxx>
+
+#include <com/sun/star/sheet/TablePageBreakData.hpp>
+#include <com/sun/star/sheet/XSheetPageBreak.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XSheetPageBreak::testGetColumnPageBreaks()
+{
+ uno::Reference< sheet::XSheetPageBreak > xSheetPageBreak(init(), UNO_QUERY_THROW);
+
+ uno::Sequence< sheet::TablePageBreakData > xColPageBreak = xSheetPageBreak->getColumnPageBreaks();
+ CPPUNIT_ASSERT_MESSAGE("Unable to get column page breaks", xColPageBreak.hasElements());
+}
+
+void XSheetPageBreak::testGetRowPageBreaks()
+{
+ uno::Reference< sheet::XSheetPageBreak > xSheetPageBreak(init(), UNO_QUERY_THROW);
+
+ uno::Sequence< sheet::TablePageBreakData > xRowPageBreak = xSheetPageBreak->getRowPageBreaks();
+ CPPUNIT_ASSERT_MESSAGE("Unable to get row page breaks", xRowPageBreak.hasElements());
+}
+
+void XSheetPageBreak::testRemoveAllManualPageBreaks()
+{
+ uno::Reference< sheet::XSheetPageBreak > xSheetPageBreak(init(), UNO_QUERY_THROW);
+
+ xSheetPageBreak->removeAllManualPageBreaks();
+
+ const uno::Sequence< sheet::TablePageBreakData > xColPageBreak = xSheetPageBreak->getColumnPageBreaks();
+ sal_Int32 manualColPageBreaks = 0;
+ for ( const auto & data : xColPageBreak )
+ {
+ if (data.ManualBreak)
+ manualColPageBreaks++;
+ }
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Found manual column page break",
+ sal_Int32(0), manualColPageBreaks);
+
+ const uno::Sequence< sheet::TablePageBreakData > xRowPageBreak = xSheetPageBreak->getRowPageBreaks();
+ sal_Int32 manualRowPageBreaks = 0;
+ for ( const auto & data : xRowPageBreak )
+ {
+ if (data.ManualBreak)
+ manualRowPageBreaks++;
+ }
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Found manual row page break",
+ sal_Int32(0), manualRowPageBreaks);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xspreadsheet.cxx b/test/source/sheet/xspreadsheet.cxx
new file mode 100644
index 000000000..466f995fe
--- /dev/null
+++ b/test/source/sheet/xspreadsheet.cxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xspreadsheet.hxx>
+
+#include <com/sun/star/sheet/XSheetCellCursor.hpp>
+#include <com/sun/star/sheet/XSheetCellRange.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+
+namespace apitest {
+
+void XSpreadsheet::testCreateCursor()
+{
+ uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW);
+
+ uno::Reference< sheet::XSheetCellCursor > xCursor(xSheet->createCursor(), UNO_SET_THROW);
+}
+
+void XSpreadsheet::testCreateCursorByRange()
+{
+ uno::Reference< sheet::XSpreadsheet > xSheet(init(), UNO_QUERY_THROW);
+
+ uno::Reference< sheet::XSheetCellRange > xCellRange(xSheet->getCellRangeByPosition(1, 1, 2, 3), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetCellCursor > xCursor(xSheet->createCursorByRange(xCellRange), UNO_SET_THROW);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xspreadsheetdocument.cxx b/test/source/sheet/xspreadsheetdocument.cxx
new file mode 100644
index 000000000..fd8f66ab5
--- /dev/null
+++ b/test/source/sheet/xspreadsheetdocument.cxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xspreadsheetdocument.hxx>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XSpreadsheetDocument::testGetSheets()
+{
+ uno::Reference< sheet::XSpreadsheetDocument > xSpreadsheetDoc(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSpreadsheets > xSheets = xSpreadsheetDoc->getSheets();
+ CPPUNIT_ASSERT(xSheets.is());
+
+ uno::Reference< container::XIndexAccess > xIA(xSheets, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL( mnSheets, xIA->getCount() );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xspreadsheets.cxx b/test/source/sheet/xspreadsheets.cxx
new file mode 100644
index 000000000..14e2bf996
--- /dev/null
+++ b/test/source/sheet/xspreadsheets.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xspreadsheets.hxx>
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+
+namespace apitest {
+
+void XSpreadsheets::testInsertNewByName()
+{
+ uno::Reference< sheet::XSpreadsheets > xSpreadsheets(init(), UNO_QUERY_THROW);
+
+ OUString newSheetName( "SheetToInsert" );
+ xSpreadsheets->insertNewByName(newSheetName, 0);
+
+ uno::Reference< container::XNameAccess > xNameAccess(xSpreadsheets, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("Sheet was not insert",
+ xNameAccess->hasByName(newSheetName));
+}
+
+void XSpreadsheets::testInsertNewByNameBadName()
+{
+ uno::Reference< sheet::XSpreadsheets > xSpreadsheets(init(), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_THROW_MESSAGE("No exception thrown",
+ xSpreadsheets->insertNewByName("$%#/?\\", 0),
+ uno::RuntimeException);
+}
+
+void XSpreadsheets::testMoveByName()
+{
+ uno::Reference< sheet::XSpreadsheets > xSpreadsheets(init(), UNO_QUERY_THROW);
+
+ // first insert one that should be moved
+ xSpreadsheets->insertNewByName("SheetToMove", 0);
+ uno::Reference< container::XNameAccess > xNameAccess(xSpreadsheets, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("Sheet to move was not insert",
+ xNameAccess->hasByName("SheetToMove"));
+
+ xSpreadsheets->moveByName("SheetToMove", 2);
+
+ // get sheet from the new position
+ uno::Reference< container::XIndexAccess > oIndexAccess(xSpreadsheets, UNO_QUERY_THROW);
+ uno::Any aAny = oIndexAccess->getByIndex(1);
+ uno::Reference< container::XNamed > xNamed;
+ CPPUNIT_ASSERT(aAny >>= xNamed);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Sheet was not moved",
+ OUString("SheetToMove"),
+ xNamed->getName());
+}
+
+void XSpreadsheets::testCopyByName()
+{
+ uno::Reference< sheet::XSpreadsheets > xSpreadsheets(init(), UNO_QUERY_THROW);
+
+ // insert new sheet to copy
+ xSpreadsheets->insertNewByName("SheetToCopySrc", 0);
+ uno::Reference< container::XNameAccess > xNameAccess(xSpreadsheets, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("Sheet to copy was not insert",
+ xNameAccess->hasByName("SheetToCopySrc"));
+
+ xSpreadsheets->copyByName("SheetToCopySrc", "SheetToCopyDst", 0);
+ CPPUNIT_ASSERT_MESSAGE("Sheet was not copied",
+ xNameAccess->hasByName("SheetToCopyDst"));
+}
+
+}
+
+/* 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 000000000..d67e871f0
--- /dev/null
+++ b/test/source/sheet/xspreadsheets2.cxx
@@ -0,0 +1,372 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#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/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/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/table/CellVertJustify.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+
+#include <rtl/ustring.hxx>
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+static constexpr OUStringLiteral gaSrcSheetName("SheetToCopy");
+static constexpr OUStringLiteral gaSrcFileName("rangenamessrc.ods");
+static constexpr OUStringLiteral gaDestFileBase("ScNamedRangeObj.ods");
+
+static sal_Int32 nInsertedSheets(0);
+
+
+XSpreadsheets2::XSpreadsheets2()
+{
+}
+
+XSpreadsheets2::~XSpreadsheets2()
+{
+ if (xDestDoc.is())
+ {
+ uno::Reference<util::XCloseable> xCloseable(xDestDoc, UNO_QUERY_THROW);
+ xCloseable->close(true);
+ }
+}
+
+void XSpreadsheets2::testImportedSheetNameAndIndex()
+{
+/**
+ Verify 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(gaSrcSheetName));
+
+}
+
+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);
+ OUString aSrcString = xSrcTextRange->getString();
+
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(0,0);
+ uno::Reference< text::XTextRange > xDestTextRange(xDestCell, UNO_QUERY_THROW);
+ OUString aDestString = xDestTextRange->getString();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong string imported", aSrcString, aDestString);
+}
+
+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_EQUAL_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);
+ OUString aSrcFormula = xSrcCell->getFormula();
+
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(2,0);
+ OUString aDestFormula = xDestCell->getFormula();
+
+ // potential problem later: formulas might be adjusted
+ // add some tests that the formulas are correctly adjusted
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong formula imported", aSrcFormula, aDestFormula);
+}
+
+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);
+ OUString aSrcFormula = xSrcCell->getFormula();
+
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(3,0);
+ OUString aDestFormula = xDestCell->getFormula();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Namedrange formula imported", aSrcFormula, aDestFormula);
+}
+
+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();
+
+ uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess(getNamedRanges(xDestDoc), UNO_QUERY_THROW);
+ uno::Any aNr = xDestNamedRangesNameAccess->getByName("initial1");
+ uno::Reference< sheet::XNamedRange > xDestNamedRange(aNr, UNO_QUERY_THROW);
+ OUString aNrDestContent = xDestNamedRange->getContent();
+
+ OUString const aExpectedContent("$Sheet1.$B$1");
+
+ std::cout << "testImportSheet : initial1 aNrDestContent " << aNrDestContent << std::endl;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong address for initial1", aExpectedContent, aNrDestContent);
+
+}
+
+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
+ OUString aNewInSheetNamedRangeString("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);
+ OUString aNewInSheetNrDestContent = xDestNewInSheetNamedRange->getContent();
+ OUString aNewInSheetExpectedContent("$SheetToCopy.$A$7");
+
+ std::cout << "testImportSheet : InSheetRangeName content " << aNewInSheetNrDestContent << std::endl;
+ std::cout << "testImportSheet : InSheetRangeName expected " << aNewInSheetExpectedContent << std::endl;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong address for InSheetRangeName", aNewInSheetExpectedContent, aNewInSheetNrDestContent);
+}
+
+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
+ OUString aRedefinedInSheetNamedRangeString("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);
+ OUString aRedefinedInSheetNrDestContent = xDestRedefinedInSheetNamedRange->getContent();
+ OUString const aRedefinedInSheetExpectedContent("$Sheet1.$B$2");
+ std::cout << "testImportSheet : initial2 content " << aRedefinedInSheetNrDestContent << std::endl;
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong address for Redefined InSheet named range", aRedefinedInSheetExpectedContent, aRedefinedInSheetNrDestContent);
+}
+
+void XSpreadsheets2::testImportNewNamedRange()
+{
+/**
+ in Source 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-existent named range in dest - new_rangename
+ OUString aNewNamedRangeString("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);
+ OUString aNewNrDestContent = xDestNewNamedRange->getContent();
+
+ OUString aNewExpectedContent("$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);
+ xDestSheet->getCellByPosition(3,0);
+
+ //new style created in dest
+ uno::Reference< beans::XPropertySet > xSrcCellPropSet (xSrcCell, UNO_QUERY_THROW);
+ const OUString aCellProperty("CellStyle");
+ OUString aSrcStyleName;
+ CPPUNIT_ASSERT(xSrcCellPropSet->getPropertyValue(aCellProperty) >>= aSrcStyleName);
+
+ uno::Reference< beans::XPropertySet > xDestCellPropSet (xSrcCell, UNO_QUERY_THROW);
+ OUString aDestStyleName;
+ CPPUNIT_ASSERT(xDestCellPropSet->getPropertyValue(aCellProperty) >>= aDestStyleName);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong imported Cell Style", aSrcStyleName, aDestStyleName);
+
+ uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier (xDestDoc, UNO_QUERY_THROW);
+ uno::Reference< container::XNameAccess > xFamiliesNameAccess (xFamiliesSupplier->getStyleFamilies(), UNO_SET_THROW);
+ uno::Any aCellStylesFamily = xFamiliesNameAccess->getByName("CellStyles");
+ uno::Reference< container::XNameContainer > xCellStylesFamilyNameAccess (aCellStylesFamily, 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);
+ sal_Int32 aVertJustify = 0;
+ CPPUNIT_ASSERT(xCellStyleProp->getPropertyValue("VertJustify") >>= aVertJustify);
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("New style: VertJustify not set", table::CellVertJustify_CENTER, static_cast<table::CellVertJustify>(aVertJustify));
+}
+
+void XSpreadsheets2::testLastAfterInsertCopy()
+{
+ /** Test that results in row 1 of all inserted sheets are equal to the
+ source sheet. The loaded destination document is kept open so several
+ sheets are imported.
+ */
+
+ CPPUNIT_ASSERT(nInsertedSheets > 0);
+ constexpr sal_Int32 nCols = 7;
+
+ uno::Reference< container::XNameAccess> xSrcNameAccess(init(),UNO_QUERY_THROW);
+ xSrcSheet.set( xSrcNameAccess->getByName(gaSrcSheetName), UNO_QUERY_THROW);
+
+ OUString aSrcString[nCols];
+ for (sal_Int32 nCol=0; nCol < nCols; ++nCol)
+ {
+ uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(nCol, 0);
+ uno::Reference< text::XTextRange > xSrcTextRange(xSrcCell, UNO_QUERY_THROW);
+ aSrcString[nCol] = xSrcTextRange->getString();
+ }
+ // The named range 'initial2' is already present in the destination
+ // document defined to $Sheet1.$B$2 and thus is not copied, pointing to
+ // "content2" instead.
+ aSrcString[6] = "content2";
+
+ xDestDoc = getDoc(gaDestFileBase);
+ CPPUNIT_ASSERT(xDestDoc.is());
+ uno::Reference< container::XIndexAccess > xDestSheetIndexAccess (xDestDoc->getSheets(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT( nInsertedSheets < xDestSheetIndexAccess->getCount());
+ for (sal_Int32 nSheet=0; nSheet < nInsertedSheets; ++nSheet)
+ {
+ xDestSheet.set( xDestSheetIndexAccess->getByIndex(nSheet), UNO_QUERY_THROW);
+ for (sal_Int32 nCol=0; nCol < nCols; ++nCol)
+ {
+ uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(nCol, 0);
+ uno::Reference< text::XTextRange > xDestTextRange(xDestCell, UNO_QUERY_THROW);
+ OUString aDestString = xDestTextRange->getString();
+
+ if (nCol == 4 && aDestString == "Err:540")
+ // The created external reference to the source document not
+ // allowed may result in Err:540
+ continue;
+
+ OString aMessage("Imported result does not match, sheet " + OString::number(nSheet)
+ + " column " + OString::number(nCol));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( aMessage.getStr(), aSrcString[nCol], aDestString);
+ }
+ }
+}
+
+uno::Reference< sheet::XSpreadsheetDocument> XSpreadsheets2::getDoc(const OUString& aFileBase)
+{
+ OUString aFileURL;
+ createFileURL(aFileBase, aFileURL);
+
+ uno::Reference< lang::XComponent > xComp = loadFromDesktop(aFileURL);
+
+ CPPUNIT_ASSERT(xComp.is());
+
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComp, UNO_QUERY_THROW);
+ return xDoc;
+}
+
+uno::Reference< sheet::XNamedRanges> XSpreadsheets2::getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument> const & xDoc)
+{
+ uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
+ uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue("NamedRanges"), UNO_QUERY_THROW);
+ return xNamedRanges;
+}
+
+void XSpreadsheets2::importSheetToCopy()
+{
+ uno::Reference< container::XNameAccess> xSrcNameAccess(init(),UNO_QUERY_THROW);
+ xSrcSheet.set( xSrcNameAccess->getByName(gaSrcSheetName), UNO_QUERY_THROW);
+
+ xDestDoc = getDoc(gaDestFileBase);
+ 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, gaSrcSheetName, nDestPos);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong sheet index", nDestPos, nDestPosEffective);
+ ++nInsertedSheets;
+
+ uno::Reference< container::XIndexAccess > xDestSheetIndexAccess (xDestDoc->getSheets(), UNO_QUERY_THROW);
+ xDestSheet.set( xDestSheetIndexAccess->getByIndex(nDestPosEffective), UNO_QUERY_THROW);
+}
+
+bool XSpreadsheets2::isExternalReference(const OUString& aDestContent, const OUString& aSrcContent )
+{
+ CPPUNIT_ASSERT(aDestContent.startsWith("'file://"));
+
+ return (aDestContent.endsWithIgnoreAsciiCase(aSrcContent) // same cell address
+ && aDestContent.indexOf(gaSrcFileName)>0); // contains source file name
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xspreadsheetview.cxx b/test/source/sheet/xspreadsheetview.cxx
new file mode 100644
index 000000000..d8804cf5d
--- /dev/null
+++ b/test/source/sheet/xspreadsheetview.cxx
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xspreadsheetview.hxx>
+
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XSpreadsheetView::testGetSetActiveSheet()
+{
+ uno::Reference<sheet::XSpreadsheetView> xView(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XSpreadsheet> xActiveSheet = xView->getActiveSheet();
+ CPPUNIT_ASSERT_MESSAGE("Unable to get default active sheet", xActiveSheet.is());
+
+ uno::Reference<sheet::XSpreadsheet> xNewSheet = xActiveSheet;
+ CPPUNIT_ASSERT_MESSAGE("no sheet", xNewSheet.is());
+ xView->setActiveSheet(xNewSheet);
+
+ uno::Reference<sheet::XSpreadsheet> xNewActiveSheet = xView->getActiveSheet();
+ CPPUNIT_ASSERT_MESSAGE("Unable to get new active sheet", xNewActiveSheet.is());
+ CPPUNIT_ASSERT_MESSAGE("Default and new active sheet are not different",
+ xActiveSheet.get() != xNewActiveSheet.get());
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsubtotalcalculatable.cxx b/test/source/sheet/xsubtotalcalculatable.cxx
new file mode 100644
index 000000000..3a85c923b
--- /dev/null
+++ b/test/source/sheet/xsubtotalcalculatable.cxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsubtotalcalculatable.hxx>
+
+#include <com/sun/star/sheet/GeneralFunction.hpp>
+#include <com/sun/star/sheet/SubTotalColumn.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSubTotalCalculatable.hpp>
+#include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XSubTotalCalculatable::testCreateSubTotalDescriptor()
+{
+ uno::Reference< sheet::XSubTotalCalculatable > xSTC(init(), uno::UNO_QUERY_THROW);
+ uno::Reference< sheet::XSubTotalDescriptor > xSTD = xSTC->createSubTotalDescriptor(true);
+
+ uno::Sequence< sheet::SubTotalColumn > xCols;
+ xCols.realloc(1);
+ xCols[0].Column = 5;
+ xCols[0].Function = sheet::GeneralFunction_SUM;
+
+ CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to create XSubTotalDescriptor", xSTD->addNew(xCols, 1));
+}
+
+void XSubTotalCalculatable::testApplyRemoveSubTotals()
+{
+ uno::Reference< sheet::XSpreadsheet > xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSubTotalCalculatable > xSTC(xSheet, UNO_QUERY_THROW);
+
+ uno::Reference< sheet::XSubTotalDescriptor > xSTD = xSTC->createSubTotalDescriptor(true);
+ uno::Sequence< sheet::SubTotalColumn > xCols;
+ xCols.realloc(1);
+ xCols[0].Column = 0;
+ xCols[0].Function = sheet::GeneralFunction_SUM;
+ xSTD->addNew(xCols, 1);
+
+ xSheet->getCellByPosition(0, 0)->setFormula("first");
+ xSheet->getCellByPosition(1, 0)->setFormula("second");
+ xSheet->getCellByPosition(0, 3)->setFormula("");
+ xSheet->getCellByPosition(0, 1)->setValue(5);
+ xSheet->getCellByPosition(0, 2)->setValue(5);
+ xSheet->getCellByPosition(1, 1)->setValue(17);
+ xSheet->getCellByPosition(1, 2)->setValue(17);
+
+ xSTC->applySubTotals(xSTD, true);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to apply SubTotals",
+ OUString("=SUBTOTAL(9;$A$2:$A$3)"),
+ xSheet->getCellByPosition(0, 3)->getFormula());
+
+ xSTC->removeSubTotals();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to remove SubTotals",
+ OUString(""),
+ xSheet->getCellByPosition(0, 3)->getFormula());
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsubtotaldescriptor.cxx b/test/source/sheet/xsubtotaldescriptor.cxx
new file mode 100644
index 000000000..fa5aca634
--- /dev/null
+++ b/test/source/sheet/xsubtotaldescriptor.cxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsubtotaldescriptor.hxx>
+
+#include <com/sun/star/sheet/GeneralFunction.hpp>
+#include <com/sun/star/sheet/SubTotalColumn.hpp>
+#include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XSubTotalDescriptor::testAddNew()
+{
+ uno::Reference< sheet::XSubTotalDescriptor > xSTD(init(), uno::UNO_QUERY_THROW);
+
+ uno::Sequence< sheet::SubTotalColumn > xCols;
+ xCols.realloc(1);
+ xCols[0].Column = 5;
+ xCols[0].Function = sheet::GeneralFunction_SUM;
+
+ CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to add column", xSTD->addNew(xCols, 1));
+}
+
+void XSubTotalDescriptor::testClear()
+{
+ uno::Reference< sheet::XSubTotalDescriptor > xSTD(init(), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_NO_THROW_MESSAGE("Unable to clear XSubTotalDescriptor", xSTD->clear());
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xsubtotalfield.cxx b/test/source/sheet/xsubtotalfield.cxx
new file mode 100644
index 000000000..048d005dc
--- /dev/null
+++ b/test/source/sheet/xsubtotalfield.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xsubtotalfield.hxx>
+
+#include <com/sun/star/sheet/GeneralFunction.hpp>
+#include <com/sun/star/sheet/SubTotalColumn.hpp>
+#include <com/sun/star/sheet/XSubTotalField.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+CPPUNIT_NS_BEGIN
+
+template<> struct assertion_traits<uno::Sequence< sheet::SubTotalColumn > >
+{
+ static bool equal(const uno::Sequence< sheet::SubTotalColumn >& x,
+ const uno::Sequence< sheet::SubTotalColumn >& y)
+ {
+ return x == y;
+ }
+
+ static std::string toString(const uno::Sequence< sheet::SubTotalColumn >& x)
+ {
+ OStringStream ost;
+ ost << "Sequence: Length: " << x.getLength() << "\n";
+ for (const auto& rElement : x)
+ ost << "Column: " << rElement.Column << " Function:\n";
+ // FIXME: Find a way to print Function
+ //ost << "Column: " << element->Column << " Function: " << element->Function << "\n";
+ return ost.str();
+ }
+};
+
+CPPUNIT_NS_END
+
+namespace apitest {
+
+void XSubTotalField::testGetSetGroupColumn()
+{
+ uno::Reference< sheet::XSubTotalField > xSTF(init(), uno::UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to get GroupColumn", xSTF->getGroupColumn() != 0);
+
+ xSTF->setGroupColumn(2);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to set GroupColumn to new value",
+ sal_Int32(2), xSTF->getGroupColumn());
+}
+
+void XSubTotalField::testGetSetTotalColumns()
+{
+ uno::Reference< sheet::XSubTotalField > xSTF(init(), UNO_QUERY_THROW);
+
+ uno::Sequence< sheet::SubTotalColumn > sDefaultCols = xSTF->getSubTotalColumns();
+ CPPUNIT_ASSERT_MESSAGE("Unable to get SubTotalColumns", sDefaultCols.hasElements());
+
+ uno::Sequence< sheet::SubTotalColumn > sNewCols;
+ sNewCols.realloc(1);
+ sNewCols[0].Column = 5;
+ sNewCols[0].Function = sheet::GeneralFunction_AVERAGE;
+ xSTF->setSubTotalColumns(sNewCols);
+
+ CPPUNIT_ASSERT_MESSAGE("Unable to set SubTotalColumns", sDefaultCols != xSTF->getSubTotalColumns());
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xuniquecellformatrangessupplier.cxx b/test/source/sheet/xuniquecellformatrangessupplier.cxx
new file mode 100644
index 000000000..18d81eb2f
--- /dev/null
+++ b/test/source/sheet/xuniquecellformatrangessupplier.cxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xuniquecellformatrangessupplier.hxx>
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/sheet/XUniqueCellFormatRangesSupplier.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XUniqueCellFormatRangesSupplier::testGetUniqueCellFormatRanges()
+{
+ uno::Reference< sheet::XUniqueCellFormatRangesSupplier > xSupplier(init(), UNO_QUERY_THROW);
+ uno::Reference< container::XIndexAccess > xIndexAccess = xSupplier->getUniqueCellFormatRanges();
+
+ auto count = xIndexAccess->getCount();
+ CPPUNIT_ASSERT_MESSAGE("No elements found", count);
+ for (auto i = 0; i<count; i++) {
+ CPPUNIT_ASSERT_NO_THROW_MESSAGE(OUStringToOString("Unable to access element " + OUString::number(i), RTL_TEXTENCODING_UTF8).getStr(),
+ xIndexAccess->getByIndex(i));
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xusedareacursor.cxx b/test/source/sheet/xusedareacursor.cxx
new file mode 100644
index 000000000..dcee0cf57
--- /dev/null
+++ b/test/source/sheet/xusedareacursor.cxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xusedareacursor.hxx>
+
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XSheetCellCursor.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XUsedAreaCursor.hpp>
+
+#include <com/sun/star/table/CellRangeAddress.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+
+namespace apitest {
+
+void XUsedAreaCursor::testGotoStartOfUsedArea()
+{
+ uno::Reference< sheet::XSpreadsheet > xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor(xSheet->createCursor(), UNO_SET_THROW);
+ uno::Reference< sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor, UNO_QUERY_THROW);
+
+ uno::Reference< sheet::XUsedAreaCursor > xUsedAreaCursor(xSheetCellCursor, UNO_QUERY_THROW);
+
+ xUsedAreaCursor->gotoStartOfUsedArea(false);
+ xUsedAreaCursor->gotoEndOfUsedArea(true);
+ table::CellRangeAddress cellRangeAddress = xCellRangeAddressable->getRangeAddress();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
+ sal_Int32(0), cellRangeAddress.StartColumn);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
+ sal_Int32(2), cellRangeAddress.EndColumn);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
+ sal_Int32(0), cellRangeAddress.StartRow);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
+ sal_Int32(0), cellRangeAddress.EndRow);
+
+ xUsedAreaCursor->gotoEndOfUsedArea(false);
+ cellRangeAddress = xCellRangeAddressable->getRangeAddress();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
+ sal_Int32(2), cellRangeAddress.StartColumn);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
+ sal_Int32(2), cellRangeAddress.EndColumn);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
+ sal_Int32(0), cellRangeAddress.StartRow);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
+ sal_Int32(0), cellRangeAddress.EndRow);
+}
+
+void XUsedAreaCursor::testGotoEndOfUsedArea()
+{
+ uno::Reference< sheet::XSpreadsheet > xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor(xSheet->createCursor(), UNO_SET_THROW);
+ uno::Reference< sheet::XCellRangeAddressable> xCellRangeAddressable(xSheetCellCursor, UNO_QUERY_THROW);
+
+ uno::Reference< sheet::XUsedAreaCursor > xUsedAreaCursor(xSheetCellCursor, UNO_QUERY_THROW);
+
+ xUsedAreaCursor->gotoEndOfUsedArea(false);
+ xUsedAreaCursor->gotoStartOfUsedArea(true);
+ table::CellRangeAddress cellRangeAddress = xCellRangeAddressable->getRangeAddress();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
+ sal_Int32(0), cellRangeAddress.StartColumn);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
+ sal_Int32(2), cellRangeAddress.EndColumn);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
+ sal_Int32(0), cellRangeAddress.StartRow);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
+ sal_Int32(0), cellRangeAddress.EndRow);
+
+ xUsedAreaCursor->gotoStartOfUsedArea(false);
+ cellRangeAddress = xCellRangeAddressable->getRangeAddress();
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start column",
+ sal_Int32(0), cellRangeAddress.StartColumn);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
+ sal_Int32(0), cellRangeAddress.EndColumn);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong start row",
+ sal_Int32(0), cellRangeAddress.StartRow);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong end column",
+ sal_Int32(0), cellRangeAddress.EndRow);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xviewfreezable.cxx b/test/source/sheet/xviewfreezable.cxx
new file mode 100644
index 000000000..4a478f1ef
--- /dev/null
+++ b/test/source/sheet/xviewfreezable.cxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xviewfreezable.hxx>
+
+#include <com/sun/star/sheet/XViewFreezable.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XViewFreezable::testFreeze()
+{
+ uno::Reference< sheet::XViewFreezable > xViewFreezable(init(), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("View has already frozen panes", !xViewFreezable->hasFrozenPanes());
+
+ xViewFreezable->freezeAtPosition(1,1);
+ CPPUNIT_ASSERT_MESSAGE("Unable to freeze pane", xViewFreezable->hasFrozenPanes());
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/test/source/sheet/xviewpane.cxx b/test/source/sheet/xviewpane.cxx
new file mode 100644
index 000000000..5ea508bf8
--- /dev/null
+++ b/test/source/sheet/xviewpane.cxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xviewpane.hxx>
+#include <com/sun/star/sheet/XViewPane.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XViewPane::testFirstVisibleColumn()
+{
+ sal_Int32 nCol = 5;
+ uno::Reference < sheet::XViewPane > xViewPane(init(),UNO_QUERY_THROW);
+ xViewPane->setFirstVisibleColumn(nCol);
+ CPPUNIT_ASSERT_EQUAL(xViewPane->getFirstVisibleColumn(), nCol);
+}
+
+void XViewPane::testFirstVisibleRow()
+{
+ sal_Int32 nRow = 3;
+ uno::Reference < sheet::XViewPane > xViewPane(init(),UNO_QUERY_THROW);
+ xViewPane->setFirstVisibleRow(nRow);
+ CPPUNIT_ASSERT_EQUAL(xViewPane->getFirstVisibleRow(), nRow);
+}
+
+void XViewPane::testVisibleRange()
+{
+ constexpr sal_Int32 nCol = 5;
+ constexpr sal_Int32 nRow = 3;
+ uno::Reference < sheet::XViewPane > xViewPane(init(),UNO_QUERY_THROW);
+ xViewPane->setFirstVisibleColumn(nCol);
+ xViewPane->setFirstVisibleRow(nRow);
+
+ table::CellRangeAddress aCellRangeAddress = xViewPane->getVisibleRange();
+ CPPUNIT_ASSERT_EQUAL(short(0), aCellRangeAddress.Sheet);
+ CPPUNIT_ASSERT_EQUAL(nRow, aCellRangeAddress.StartRow);
+ CPPUNIT_ASSERT_EQUAL(nCol, aCellRangeAddress.StartColumn);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/test/source/sheet/xviewsplitable.cxx b/test/source/sheet/xviewsplitable.cxx
new file mode 100644
index 000000000..e9f8d62b8
--- /dev/null
+++ b/test/source/sheet/xviewsplitable.cxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/sheet/xviewsplitable.hxx>
+
+#include <com/sun/star/sheet/XViewSplitable.hpp>
+
+#include <cppunit/TestAssert.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest {
+
+void XViewSplitable::testSplit()
+{
+ uno::Reference< sheet::XViewSplitable > xViewSplitable(init(), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_MESSAGE("View is already split", !xViewSplitable->getIsWindowSplit());
+
+ xViewSplitable->splitAtPosition(90, 51);
+
+ CPPUNIT_ASSERT_MESSAGE("View wasn't split", xViewSplitable->getIsWindowSplit());
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong horizontal pixel position",
+ sal_Int32(90), xViewSplitable->getSplitHorizontal());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong vertical pixel position",
+ sal_Int32(51), xViewSplitable->getSplitVertical());
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong column",
+ sal_Int32(1), xViewSplitable->getSplitColumn());
+ CPPUNIT_ASSERT_MESSAGE("Wrong row", xViewSplitable->getSplitRow() != 0);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */