summaryrefslogtreecommitdiff
path: root/sc/qa
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-01-21 12:02:46 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-01-23 19:46:46 +0100
commit95780ec73990f96dc16fc677c895d00fa1360008 (patch)
tree875b727854a9d3c4dd0d2958ba490627ca53b78a /sc/qa
parent3fcde5e3f9e0921effd9ffd6c26246647f108ce3 (diff)
refactor concept for c++ based subsequenttests
Diffstat (limited to 'sc/qa')
-rw-r--r--sc/qa/extras/cellproperties.cxx148
-rw-r--r--sc/qa/extras/datapilotfieldobj.cxx264
-rw-r--r--sc/qa/extras/sccellrangeobj.cxx116
-rw-r--r--sc/qa/extras/scdatabaserangeobj.cxx106
-rw-r--r--sc/qa/extras/scdatapilotfieldobj.cxx (renamed from sc/qa/extras/xdatapilotfieldgrouping.cxx)98
-rw-r--r--sc/qa/extras/scdatapilottableobj.cxx (renamed from sc/qa/extras/xdatapilottable.cxx)102
-rw-r--r--sc/qa/extras/scnamedrangeobj.cxx117
-rw-r--r--sc/qa/extras/scnamedrangesobj.cxx110
-rw-r--r--sc/qa/extras/sctablesheetsobj.cxx138
-rw-r--r--sc/qa/extras/tableautoformatfield.cxx131
-rw-r--r--sc/qa/extras/testdocuments/rangenamessrc.odsbin9250 -> 9089 bytes
-rw-r--r--sc/qa/extras/xcellrangesquery.cxx196
-rw-r--r--sc/qa/extras/xdatabaserange.cxx209
-rw-r--r--sc/qa/extras/xdatapilotdescriptor.cxx311
-rw-r--r--sc/qa/extras/xnamecontainer.cxx85
-rw-r--r--sc/qa/extras/xnamedrange.cxx201
-rw-r--r--sc/qa/extras/xnamedranges.cxx259
-rw-r--r--sc/qa/extras/xspreadsheets2.cxx447
18 files changed, 664 insertions, 2374 deletions
diff --git a/sc/qa/extras/cellproperties.cxx b/sc/qa/extras/cellproperties.cxx
deleted file mode 100644
index 29379153c54a..000000000000
--- a/sc/qa/extras/cellproperties.cxx
+++ /dev/null
@@ -1,148 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <test/unoapi_test.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/table/CellVertJustify.hpp>
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/sheet/XSpreadsheet.hpp>
-#include <com/sun/star/table/XCellRange.hpp>
-#include <com/sun/star/util/XCloseable.hpp>
-
-namespace ScCellRangeBase {
-
-#define NUMBER_OF_TESTS 2
-
-class ScCellProperties : public UnoApiTest
-{
-public:
- virtual void setUp();
- virtual void tearDown();
-
- void testVertJustify();
- void testRotateReference();
- CPPUNIT_TEST_SUITE(ScCellProperties);
- CPPUNIT_TEST(testVertJustify);
- CPPUNIT_TEST(testRotateReference);
- CPPUNIT_TEST_SUITE_END();
-
-private:
- uno::Reference < beans::XPropertySet > init();
-
- static int nTest;
- static uno::Reference< lang::XComponent > xComponent;
-};
-
-int ScCellProperties::nTest = 0;
-uno::Reference< lang::XComponent > ScCellProperties::xComponent;
-
-
-void ScCellProperties::testVertJustify()
-{
- uno::Reference< beans::XPropertySet > xCellRangeBase = init();
- rtl::OUString aVertJustify(RTL_CONSTASCII_USTRINGPARAM("VertJustify"));
- uno::Any aOldVertJustify = xCellRangeBase->getPropertyValue(aVertJustify);
- sal_Int32 aValue = 0;
- CPPUNIT_ASSERT(aOldVertJustify >>= aValue);
- std::cout << "Old VertJustify value: " << aValue << std::endl;
-
- uno::Any aNewVertJustify;
- aNewVertJustify <<= static_cast<sal_Int32>(3);
- xCellRangeBase->setPropertyValue(aVertJustify, aNewVertJustify);
- uno::Any aVertJustifyControllValue = xCellRangeBase->getPropertyValue(aVertJustify);
- CPPUNIT_ASSERT(aVertJustifyControllValue >>= aValue);
- std::cout << "New VertJustify value: " << aValue << std::endl;
- CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3);
-}
-
-void ScCellProperties::testRotateReference()
-{
- uno::Reference< beans::XPropertySet > xCellRangeBase = init();
- rtl::OUString aRotateReference(RTL_CONSTASCII_USTRINGPARAM("RotateReference"));
- uno::Any aOldRotateReference = xCellRangeBase->getPropertyValue(aRotateReference);
- sal_Int32 aValue = 0;
- CPPUNIT_ASSERT(aOldRotateReference >>= aValue);
- std::cout << "Old RotateReference Value: " << aValue << std::endl;
-
- uno::Any aNewRotateReference;
- aNewRotateReference <<= static_cast<sal_Int32>(3);
- xCellRangeBase->setPropertyValue(aRotateReference, aNewRotateReference);
- uno::Any aRotateReferenceControllValue = xCellRangeBase->getPropertyValue(aRotateReference);
- CPPUNIT_ASSERT(aRotateReferenceControllValue >>= aValue);
- std::cout << "New RotateReference value: " << aValue << std::endl;
- CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3);
-}
-
-uno::Reference< beans::XPropertySet > ScCellProperties::init()
-{
- rtl::OUString aFileURL;
- const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods"));
- createFileURL(aFileBase, aFileURL);
- if( !xComponent.is())
- xComponent = loadFromDesktop(aFileURL);
- uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xDoc.is());
-
- uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
- uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
-
- CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
-
- uno::Reference< table::XCellRange > xCellRange(xSheet->getCellRangeByPosition(0,0,3,4), UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xCellRange.is());
-
- uno::Reference< beans::XPropertySet > xReturn(xCellRange, UNO_QUERY_THROW);
-
- CPPUNIT_ASSERT_MESSAGE("Could not create object of type XPropertySet", xReturn.is());
- return xReturn;
-}
-
-void ScCellProperties::setUp()
-{
- nTest += 1;
- UnoApiTest::setUp();
-}
-
-void ScCellProperties::tearDown()
-{
- if (nTest == NUMBER_OF_TESTS)
- {
- uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
- xCloseable->close( false );
- }
-
- UnoApiTest::tearDown();
-
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScCellProperties);
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/datapilotfieldobj.cxx b/sc/qa/extras/datapilotfieldobj.cxx
deleted file mode 100644
index 8ebc424b4f2d..000000000000
--- a/sc/qa/extras/datapilotfieldobj.cxx
+++ /dev/null
@@ -1,264 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <test/unoapi_test.hxx>
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/sheet/XSpreadsheet.hpp>
-#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
-#include <com/sun/star/sheet/XDataPilotTables.hpp>
-#include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
-#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
-#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
-#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
-#include <com/sun/star/sheet/DataPilotFieldLayoutInfo.hpp>
-#include <com/sun/star/sheet/DataPilotFieldReference.hpp>
-#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
-
-#include <rtl/oustringostreaminserter.hxx>
-
-namespace ScDataPilotFieldObj {
-
-class ScDataPilotField : public UnoApiTest
-{
-
- uno::Reference< beans::XPropertySet > init();
-
- void testSortInfo();
- void testLayoutInfo();
- void testAutoShowInfo();
- void testReference();
- void testIsGroupField();
-
- CPPUNIT_TEST_SUITE(ScDataPilotField);
- CPPUNIT_TEST(testSortInfo);
- CPPUNIT_TEST(testLayoutInfo);
- CPPUNIT_TEST(testAutoShowInfo);
- CPPUNIT_TEST(testReference);
- CPPUNIT_TEST(testIsGroupField);
- CPPUNIT_TEST_SUITE_END();
-};
-
-void ScDataPilotField::testSortInfo()
-{
- uno::Reference< beans::XPropertySet> xPropSet = init();
- sheet::DataPilotFieldSortInfo aSortInfoValue;
- rtl::OUString aSortInfo(RTL_CONSTASCII_USTRINGPARAM("SortInfo"));
- aSortInfoValue.Field = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Col1"));
- aSortInfoValue.IsAscending = false;
- aSortInfoValue.Mode = sheet::DataPilotFieldSortMode::MANUAL;
- uno::Any xValue;
- xValue <<= aSortInfoValue;
- xPropSet->setPropertyValue(aSortInfo, xValue);
-
- sheet::DataPilotFieldSortInfo aNewSortInfoValue;
- xValue = xPropSet->getPropertyValue(aSortInfo);
- CPPUNIT_ASSERT( xValue >>= aNewSortInfoValue );
- CPPUNIT_ASSERT_MESSAGE("set value should be the same as got value", aNewSortInfoValue.Field == aSortInfoValue.Field
- && aNewSortInfoValue.Mode == aSortInfoValue.Mode && aNewSortInfoValue.IsAscending == aSortInfoValue.IsAscending);
-
- //setting HasSortInfo only makes sense for false, for true the uno implementation does nothing
- sal_Bool bHasSortInfo;
- rtl::OUString aHasSortInfo(RTL_CONSTASCII_USTRINGPARAM("HasSortInfo"));
- xValue = xPropSet->getPropertyValue(aHasSortInfo);
- CPPUNIT_ASSERT( xValue >>= bHasSortInfo );
- CPPUNIT_ASSERT_MESSAGE("should have sort info", bHasSortInfo);
-
- bHasSortInfo = false;
- xValue <<= bHasSortInfo;
- xPropSet->setPropertyValue(aHasSortInfo, xValue);
-
- xValue = xPropSet->getPropertyValue(aHasSortInfo);
- CPPUNIT_ASSERT( xValue >>= bHasSortInfo );
- CPPUNIT_ASSERT_MESSAGE("should have no sort info", !bHasSortInfo);
-}
-
-void ScDataPilotField::testLayoutInfo()
-{
- uno::Reference< beans::XPropertySet > xPropSet = init();
- sheet::DataPilotFieldLayoutInfo aLayoutInfoValue;
- rtl::OUString aLayoutInfo(RTL_CONSTASCII_USTRINGPARAM("LayoutInfo"));
- aLayoutInfoValue.AddEmptyLines = false;
- aLayoutInfoValue.LayoutMode = sheet::DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM;
- uno::Any xValue;
- xValue <<= aLayoutInfoValue;
- xPropSet->setPropertyValue(aLayoutInfo, xValue);
-
- sheet::DataPilotFieldLayoutInfo aNewLayoutInfoValue;
- xValue = xPropSet->getPropertyValue(aLayoutInfo);
- CPPUNIT_ASSERT( xValue >>= aNewLayoutInfoValue );
- CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aNewLayoutInfoValue.LayoutMode == aLayoutInfoValue.LayoutMode &&
- aNewLayoutInfoValue.AddEmptyLines == aLayoutInfoValue.AddEmptyLines);
-
- //setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing
- sal_Bool bHasLayoutInfo;
- rtl::OUString aHasLayoutInfo(RTL_CONSTASCII_USTRINGPARAM("HasLayoutInfo"));
- xValue = xPropSet->getPropertyValue(aHasLayoutInfo);
- CPPUNIT_ASSERT( xValue >>= bHasLayoutInfo );
- CPPUNIT_ASSERT_MESSAGE("should have layout information", bHasLayoutInfo);
-
- bHasLayoutInfo = false;
- xValue <<= bHasLayoutInfo;
- xPropSet->setPropertyValue(aHasLayoutInfo, xValue);
-
- xValue = xPropSet->getPropertyValue(aHasLayoutInfo);
- CPPUNIT_ASSERT( xValue >>= bHasLayoutInfo );
- CPPUNIT_ASSERT_MESSAGE("should have no longer sort information", !bHasLayoutInfo);
-}
-
-void ScDataPilotField::testAutoShowInfo()
-{
- uno::Reference< beans::XPropertySet > xPropSet = init();
- sheet::DataPilotFieldAutoShowInfo aAutoShowInfoValue;
- aAutoShowInfoValue.DataField = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Col1"));
- aAutoShowInfoValue.IsEnabled = true;
- rtl::OUString aAutoShowInfo(RTL_CONSTASCII_USTRINGPARAM("AutoShowInfo"));
- uno::Any xValue;
- xValue <<= aAutoShowInfoValue;
- xPropSet->setPropertyValue(aAutoShowInfo, xValue);
-
- sheet::DataPilotFieldAutoShowInfo aNewAutoShowInfoValue;
- xValue = xPropSet->getPropertyValue(aAutoShowInfo);
- CPPUNIT_ASSERT( xValue >>= aNewAutoShowInfoValue );
- CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aNewAutoShowInfoValue.DataField == aAutoShowInfoValue.DataField &&
- aNewAutoShowInfoValue.IsEnabled == aAutoShowInfoValue.IsEnabled);
-
- //setting HasLayoutInfo only makes sense for false, tor true the uno implementation does nothing
- sal_Bool bHasAutoShowInfo;
- rtl::OUString aHasAutoShowInfo(RTL_CONSTASCII_USTRINGPARAM("HasAutoShowInfo"));
- xValue = xPropSet->getPropertyValue(aHasAutoShowInfo);
- CPPUNIT_ASSERT( xValue >>= bHasAutoShowInfo );
- CPPUNIT_ASSERT_MESSAGE("should have AutoShow information", bHasAutoShowInfo);
-
- bHasAutoShowInfo = false;
- xValue <<= bHasAutoShowInfo;
- xPropSet->setPropertyValue(aHasAutoShowInfo, xValue);
-
- xValue = xPropSet->getPropertyValue(aHasAutoShowInfo);
- CPPUNIT_ASSERT( xValue >>= bHasAutoShowInfo );
- CPPUNIT_ASSERT_MESSAGE("should have no longer AutoShow information", !bHasAutoShowInfo);
-}
-
-void ScDataPilotField::testReference()
-{
- uno::Reference< beans::XPropertySet > xPropSet = init();
- sheet::DataPilotFieldReference aReferenceValue;
- aReferenceValue.ReferenceField = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Col1"));
- aReferenceValue.ReferenceItemType = sheet::DataPilotFieldReferenceItemType::NAMED;
- rtl::OUString aReference(RTL_CONSTASCII_USTRINGPARAM("Reference"));
- uno::Any xValue;
- xValue <<= aReferenceValue;
- xPropSet->setPropertyValue(aReference, xValue);
-
- sheet::DataPilotFieldReference aNewReferenceValue;
- xValue = xPropSet->getPropertyValue(aReference);
- CPPUNIT_ASSERT( xValue >>= aNewReferenceValue );
- CPPUNIT_ASSERT_MESSAGE("set value should be the same as the got value", aReferenceValue.ReferenceField == aNewReferenceValue.ReferenceField
- && aReferenceValue.ReferenceItemType == aNewReferenceValue.ReferenceItemType);
-
- //setting HasReference only makes sense for false, tor true the uno implementation does nothing
- sal_Bool bHasReference;
- rtl::OUString aHasReference(RTL_CONSTASCII_USTRINGPARAM("HasReference"));
- xValue = xPropSet->getPropertyValue(aHasReference);
- CPPUNIT_ASSERT( xValue >>= bHasReference );
- CPPUNIT_ASSERT_MESSAGE("should have Reference information", bHasReference);
-
- bHasReference = false;
- xValue <<= bHasReference;
- xPropSet->setPropertyValue(aHasReference, xValue);
-
- xValue = xPropSet->getPropertyValue(aHasReference);
- CPPUNIT_ASSERT( xValue >>= bHasReference );
- CPPUNIT_ASSERT_MESSAGE("should have no longer reference information", !bHasReference);
-}
-
-void ScDataPilotField::testIsGroupField()
-{
- uno::Reference< beans::XPropertySet > xPropSet = init();
- uno::Any xValue;
- rtl::OUString aIsGroupField(RTL_CONSTASCII_USTRINGPARAM("IsGroupField"));
- sal_Bool bIsGroupField;
-
- xValue = xPropSet->getPropertyValue(aIsGroupField);
- CPPUNIT_ASSERT( xValue >>= bIsGroupField);
- //only setting to false is supported
- if (bIsGroupField)
- {
- bIsGroupField = false;
- xValue <<= bIsGroupField;
-
- xPropSet->setPropertyValue(aIsGroupField, xValue);
- xValue = xPropSet->getPropertyValue(aIsGroupField);
- CPPUNIT_ASSERT(xValue >>= bIsGroupField);
- CPPUNIT_ASSERT_MESSAGE("setting IsGroupField is supported and should have happened", !bIsGroupField);
- }
- else
- std::cout << "Could not test IsGroupField" << std::endl;
-}
-
-uno::Reference< beans::XPropertySet > ScDataPilotField::init()
-{
- rtl::OUString aFileURL;
- const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("scdatapilotfieldobj.ods"));
- createFileURL(aFileBase, aFileURL);
- std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- static uno::Reference< lang::XComponent > xComponent;
- if( !xComponent.is())
- xComponent = loadFromDesktop(aFileURL);
- uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
- uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
- uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
-
- CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
- uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xDPTS.is());
- uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
- CPPUNIT_ASSERT(xDPT.is());
- uno::Sequence<rtl::OUString> aElementNames = xDPT->getElementNames();
- for (int i = 0; i < aElementNames.getLength(); ++i)
- {
- std::cout << "PivotTable: " << aElementNames[i] << std::endl;
- }
-
- uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilot1"))),UNO_QUERY_THROW);
-
- CPPUNIT_ASSERT(xDPDsc.is());
- uno::Reference< container::XIndexAccess > xIA( xDPDsc->getDataPilotFields(), UNO_QUERY_THROW);
- uno::Reference< beans::XPropertySet > xReturnValue( xIA->getByIndex(0), UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xReturnValue.is());
- return xReturnValue;
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotField);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx
new file mode 100644
index 000000000000..20a191c1f5a7
--- /dev/null
+++ b/sc/qa/extras/sccellrangeobj.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/unoapi_test.hxx>
+#include <test/sheet/xcellrangesquery.hxx>
+#include <test/sheet/cellproperties.hxx>
+
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 8
+
+class ScCellRangeObj : public UnoApiTest, apitest::XCellRangesQuery, apitest::CellProperties
+{
+public:
+ virtual void setUp();
+ virtual void tearDown();
+ virtual uno::Reference< uno::XInterface > init();
+
+ CPPUNIT_TEST_SUITE(ScCellRangeObj);
+ CPPUNIT_TEST(testQueryColumnDifference);
+ CPPUNIT_TEST(testQueryContentDifference);
+ CPPUNIT_TEST(testQueryEmptyCells);
+ //CPPUNIT_TEST(testQueryFormulaCells);
+ CPPUNIT_TEST(testQueryIntersection);
+ CPPUNIT_TEST(testQueryRowDifference);
+ CPPUNIT_TEST(testQueryVisibleCells);
+ CPPUNIT_TEST(testVertJustify);
+ CPPUNIT_TEST(testRotateReference);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ static sal_Int32 nTest;
+ static uno::Reference< lang::XComponent > mxComponent;
+};
+
+sal_Int32 ScCellRangeObj::nTest = 0;
+uno::Reference< lang::XComponent > ScCellRangeObj::mxComponent;
+
+uno::Reference< uno::XInterface > ScCellRangeObj::init()
+{
+ rtl::OUString aFileURL;
+ const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods"));
+ createFileURL(aFileBase, aFileURL);
+ std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
+ if( !mxComponent.is())
+ mxComponent = loadFromDesktop(aFileURL);
+ uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
+ uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
+
+ uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,3,4), UNO_QUERY_THROW);
+
+ CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is());
+ return xReturn;
+}
+
+void ScCellRangeObj::setUp()
+{
+ nTest++;
+ CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
+ UnoApiTest::setUp();
+}
+
+void ScCellRangeObj::tearDown()
+{
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ closeDocument(mxComponent);
+ }
+
+ UnoApiTest::tearDown();
+
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ mxDesktop->terminate();
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangeObj);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/scdatabaserangeobj.cxx b/sc/qa/extras/scdatabaserangeobj.cxx
new file mode 100644
index 000000000000..69a3d48dcee6
--- /dev/null
+++ b/sc/qa/extras/scdatabaserangeobj.cxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/unoapi_test.hxx>
+#include <test/sheet/xdatabaserange.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sheet/XDatabaseRange.hpp>
+
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 3
+
+class ScDatabaseRangeObj : public UnoApiTest, apitest::XDatabaseRange
+{
+public:
+ virtual void setUp();
+ virtual void tearDown();
+
+ virtual uno::Reference< uno::XInterface > init( const rtl::OUString& rDBName );
+
+ CPPUNIT_TEST_SUITE(ScDatabaseRangeObj);
+ CPPUNIT_TEST(testDataArea);
+ CPPUNIT_TEST(testGetSortDescriptor);
+ CPPUNIT_TEST(testGetSubtotalDescriptor);
+ CPPUNIT_TEST_SUITE_END();
+private:
+ static sal_Int32 nTest;
+ static uno::Reference< lang::XComponent > mxComponent;
+};
+
+sal_Int32 ScDatabaseRangeObj::nTest = 0;
+uno::Reference< lang::XComponent > ScDatabaseRangeObj::mxComponent;
+
+uno::Reference< uno::XInterface > ScDatabaseRangeObj::init( const rtl::OUString& rDBName )
+{
+ rtl::OUString aFileURL;
+ createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("xdatabaserange.ods")), aFileURL);
+ if(!mxComponent.is())
+ mxComponent = loadFromDesktop(aFileURL);
+ CPPUNIT_ASSERT(mxComponent.is());
+
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySet > xPropSet(xDoc, UNO_QUERY_THROW);
+ uno::Reference< container::XNameAccess > xNameAccess( xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseRanges"))), UNO_QUERY_THROW);
+ uno::Reference< sheet::XDatabaseRange > xDBRange( xNameAccess->getByName(rDBName), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xDBRange.is());
+ return xDBRange;
+}
+
+void ScDatabaseRangeObj::setUp()
+{
+ nTest++;
+ UnoApiTest::setUp();
+}
+
+void ScDatabaseRangeObj::tearDown()
+{
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ closeDocument(mxComponent);
+ }
+
+ UnoApiTest::tearDown();
+
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ mxDesktop->terminate();
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScDatabaseRangeObj);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/xdatapilotfieldgrouping.cxx b/sc/qa/extras/scdatapilotfieldobj.cxx
index 4ee9a1c37028..ff67e4620b75 100644
--- a/sc/qa/extras/xdatapilotfieldgrouping.cxx
+++ b/sc/qa/extras/scdatapilotfieldobj.cxx
@@ -13,7 +13,7 @@
* License.
*
* Major Contributor(s):
- * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
*
* All Rights Reserved.
*
@@ -27,75 +27,54 @@
*/
#include <test/unoapi_test.hxx>
+#include <test/sheet/xdatapilotfieldgrouping.hxx>
+#include <test/sheet/datapilotfield.hxx>
+
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
#include <com/sun/star/sheet/XDataPilotTables.hpp>
#include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
-#include <com/sun/star/sheet/XDataPilotFieldGrouping.hpp>
-#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
-#include <com/sun/star/util/XCloseable.hpp>
-
-#include <rtl/oustringostreaminserter.hxx>
-namespace ScDataPilotFieldObj {
+namespace sc_apitest {
-#define NUMBER_OF_TESTS 1
+#define NUMBER_OF_TESTS 6
-class ScXDataPilotFieldGrouping : public UnoApiTest
+class ScDataPilotFieldObj : public UnoApiTest, apitest::XDataPilotFieldGrouping,
+ apitest::DataPilotField
{
public:
- void testCreateNameGroup();
- void testCreateDateGroup();
-
virtual void setUp();
virtual void tearDown();
-
- CPPUNIT_TEST_SUITE(ScXDataPilotFieldGrouping);
+ virtual uno::Reference< uno::XInterface > init();
+
+ CPPUNIT_TEST_SUITE(ScDataPilotFieldObj);
+ CPPUNIT_TEST(testSortInfo);
+ CPPUNIT_TEST(testLayoutInfo);
+ CPPUNIT_TEST(testAutoShowInfo);
+ CPPUNIT_TEST(testReference);
+ CPPUNIT_TEST(testIsGroupField);
CPPUNIT_TEST(testCreateNameGroup);
- //broken: fdo#43609
+ // see fdo#
//CPPUNIT_TEST(testCreateDateGroup);
CPPUNIT_TEST_SUITE_END();
-
- uno::Reference< sheet::XDataPilotFieldGrouping > init();
-
private:
- static int nTest;
- static uno::Reference< lang::XComponent > xComponent;
+ static sal_Int32 nTest;
+ static uno::Reference< lang::XComponent > mxComponent;
};
-int ScXDataPilotFieldGrouping::nTest = 0;
-uno::Reference< lang::XComponent > ScXDataPilotFieldGrouping::xComponent;
-
-void ScXDataPilotFieldGrouping::testCreateNameGroup()
-{
- uno::Reference< sheet::XDataPilotFieldGrouping > xDataPilotFieldGrouping = init();
- uno::Reference< sheet::XDataPilotField > xDataPilotField( xDataPilotFieldGrouping, UNO_QUERY_THROW );
- uno::Reference< container::XNameAccess > xNameAccess( xDataPilotField->getItems(), UNO_QUERY_THROW );
- CPPUNIT_ASSERT(xNameAccess->hasElements());
-
- uno::Sequence< rtl::OUString > aElements = xNameAccess->getElementNames();
- xDataPilotFieldGrouping->createNameGroup( aElements );
-}
+sal_Int32 ScDataPilotFieldObj::nTest = 0;
+uno::Reference< lang::XComponent > ScDataPilotFieldObj::mxComponent;
-void ScXDataPilotFieldGrouping::testCreateDateGroup()
-{
- uno::Reference< sheet::XDataPilotFieldGrouping > xDataPilotFieldGrouping = init();
- sheet::DataPilotFieldGroupInfo aGroupInfo;
- aGroupInfo.GroupBy = sheet::DataPilotFieldGroupBy::MONTHS;
- aGroupInfo.HasDateValues = true;
- xDataPilotFieldGrouping->createDateGroup(aGroupInfo);
-}
-
-uno::Reference< sheet::XDataPilotFieldGrouping> ScXDataPilotFieldGrouping::init()
+uno::Reference< uno::XInterface > ScDataPilotFieldObj::init()
{
rtl::OUString aFileURL;
- const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("scdatapilotfieldobj.ods"));
- createFileURL(aFileBase, aFileURL);
- std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- if( !xComponent.is())
- xComponent = loadFromDesktop(aFileURL);
- uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
+ createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("scdatapilotfieldobj.ods")), aFileURL);
+ if(!mxComponent.is())
+ mxComponent = loadFromDesktop(aFileURL);
+ CPPUNIT_ASSERT(mxComponent.is());
+
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
@@ -105,32 +84,26 @@ uno::Reference< sheet::XDataPilotFieldGrouping> ScXDataPilotFieldGrouping::init(
uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
CPPUNIT_ASSERT(xDPT.is());
uno::Sequence<rtl::OUString> aElementNames = xDPT->getElementNames();
- for (int i = 0; i < aElementNames.getLength(); ++i)
- {
- std::cout << "PivotTable: " << aElementNames[i] << std::endl;
- }
uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilot1"))),UNO_QUERY_THROW);
-
CPPUNIT_ASSERT(xDPDsc.is());
uno::Reference< container::XIndexAccess > xIA( xDPDsc->getDataPilotFields(), UNO_QUERY_THROW);
- uno::Reference< sheet::XDataPilotFieldGrouping > xReturnValue( xIA->getByIndex(0), UNO_QUERY_THROW);
+ uno::Reference< uno::XInterface > xReturnValue( xIA->getByIndex(0), UNO_QUERY_THROW);
CPPUNIT_ASSERT(xReturnValue.is());
return xReturnValue;
}
-void ScXDataPilotFieldGrouping::setUp()
+void ScDataPilotFieldObj::setUp()
{
- nTest += 1;
+ nTest++;
UnoApiTest::setUp();
}
-void ScXDataPilotFieldGrouping::tearDown()
+void ScDataPilotFieldObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
- uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
- xCloseable->close( false );
+ closeDocument(mxComponent);
}
UnoApiTest::tearDown();
@@ -138,11 +111,12 @@ void ScXDataPilotFieldGrouping::tearDown()
if (nTest == NUMBER_OF_TESTS)
{
mxDesktop->terminate();
- uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
}
}
-CPPUNIT_TEST_SUITE_REGISTRATION(ScXDataPilotFieldGrouping);
+CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotFieldObj);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
}
diff --git a/sc/qa/extras/xdatapilottable.cxx b/sc/qa/extras/scdatapilottableobj.cxx
index c19c484d8e96..6d07b8fb8838 100644
--- a/sc/qa/extras/xdatapilottable.cxx
+++ b/sc/qa/extras/scdatapilottableobj.cxx
@@ -27,93 +27,71 @@
*/
#include <test/unoapi_test.hxx>
+#include <test/sheet/xdatapilottable.hxx>
+#include <test/sheet/xdatapilotdescriptor.hxx>
+
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
#include <com/sun/star/sheet/XDataPilotTables.hpp>
#include <com/sun/star/sheet/XDataPilotTable.hpp>
-#include <com/sun/star/table/XCell.hpp>
-#include <com/sun/star/util/XCloseable.hpp>
-#include <com/sun/star/table/CellRangeAddress.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-
-#include <rtl/oustringostreaminserter.hxx>
-namespace ScDataPilotDescriptorBase
-{
+namespace sc_apitest {
-#define NUMBER_OF_TESTS 2
+#define NUMBER_OF_TESTS 9
-class ScXDataPilotTable : public UnoApiTest
+class ScDataPilotTableObj : public UnoApiTest, apitest::XDataPilotDescriptor, apitest::XDataPilotTable
{
public:
-
virtual void setUp();
virtual void tearDown();
+ virtual uno::Reference< uno::XInterface > init();
- void testGetOutputRange();
- void testRefresh();
- CPPUNIT_TEST_SUITE(ScXDataPilotTable);
+ CPPUNIT_TEST_SUITE(ScDataPilotTableObj);
+ //CPPUNIT_TEST(testRefresh);
+ //CPPUNIT_TEST(testGetHiddenFields);
CPPUNIT_TEST(testGetOutputRange);
- CPPUNIT_TEST(testRefresh);
+ CPPUNIT_TEST(testSourceRange);
+ CPPUNIT_TEST(testTag);
+ CPPUNIT_TEST(testGetFilterDescriptor);
+ CPPUNIT_TEST(testGetDataPilotFields);
+ CPPUNIT_TEST(testGetColumnFields);
+ CPPUNIT_TEST(testGetRowFields);
+ CPPUNIT_TEST(testGetPageFields);
+ CPPUNIT_TEST(testGetDataFields);
CPPUNIT_TEST_SUITE_END();
-private:
- uno::Reference< sheet::XDataPilotTable > init();
-
- static int nTest;
- static uno::Reference< lang::XComponent > xComponent;
-
- uno::Reference< table::XCell > xCellForChange;
- uno::Reference< table::XCell > xCellForCheck;
+private:
+ static sal_Int32 nTest;
+ static uno::Reference< lang::XComponent > mxComponent;
};
-int ScXDataPilotTable::nTest = 0;
-uno::Reference< lang::XComponent > ScXDataPilotTable::xComponent;
+sal_Int32 ScDataPilotTableObj::nTest = 0;
+uno::Reference< lang::XComponent > ScDataPilotTableObj::mxComponent;
-void ScXDataPilotTable::testGetOutputRange()
-{
- uno::Reference< sheet::XDataPilotTable > xDPTable = init();
-
- table::CellRangeAddress aRange = xDPTable->getOutputRange();
- CPPUNIT_ASSERT( aRange.Sheet == 0 );
- CPPUNIT_ASSERT( aRange.StartColumn == 7 );
- CPPUNIT_ASSERT( aRange.StartRow == 8 );
-}
-
-void ScXDataPilotTable::testRefresh()
-{
- uno::Reference< sheet::XDataPilotTable > xDPTable = init();
- xCellForChange->setValue( 5 );
-
- double aOldData = xCellForCheck->getValue();
- xDPTable->refresh();
- double aNewData = xCellForCheck->getValue();
- CPPUNIT_ASSERT_MESSAGE("value needs to change", aOldData != aNewData);
-}
-
-uno::Reference< sheet::XDataPilotTable > ScXDataPilotTable::init()
+uno::Reference< uno::XInterface > ScDataPilotTableObj::init()
{
rtl::OUString aFileURL;
- const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods"));
- createFileURL(aFileBase, aFileURL);
- std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- if( !xComponent.is())
- xComponent = loadFromDesktop(aFileURL);
- uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
+ createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods")), aFileURL);
+ if(!mxComponent.is())
+ mxComponent = loadFromDesktop(aFileURL);
+ CPPUNIT_ASSERT(mxComponent.is());
+
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
- // set variables
+ // set variables from xdatapilottable.[ch]xx
xCellForChange = xSheet->getCellByPosition( 1, 5 );
xCellForCheck = xSheet->getCellByPosition( 7, 11 );
+ CPPUNIT_ASSERT(xCellForCheck.is());
+ CPPUNIT_ASSERT(xCellForChange.is());
CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
CPPUNIT_ASSERT(xDPTS.is());
uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
CPPUNIT_ASSERT(xDPT.is());
- uno::Sequence<rtl::OUString> aElementNames = xDPT->getElementNames();
uno::Reference< sheet::XDataPilotTable > xDPTable(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilotTable"))),UNO_QUERY_THROW);
@@ -121,18 +99,17 @@ uno::Reference< sheet::XDataPilotTable > ScXDataPilotTable::init()
return xDPTable;
}
-void ScXDataPilotTable::setUp()
+void ScDataPilotTableObj::setUp()
{
- nTest += 1;
+ nTest++;
UnoApiTest::setUp();
}
-void ScXDataPilotTable::tearDown()
+void ScDataPilotTableObj::tearDown()
{
if (nTest == NUMBER_OF_TESTS)
{
- uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
- xCloseable->close( false );
+ closeDocument(mxComponent);
}
UnoApiTest::tearDown();
@@ -140,10 +117,13 @@ void ScXDataPilotTable::tearDown()
if (nTest == NUMBER_OF_TESTS)
{
mxDesktop->terminate();
- uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
}
}
+CPPUNIT_TEST_SUITE_REGISTRATION(ScDataPilotTableObj);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/scnamedrangeobj.cxx b/sc/qa/extras/scnamedrangeobj.cxx
new file mode 100644
index 000000000000..2d7240276ed0
--- /dev/null
+++ b/sc/qa/extras/scnamedrangeobj.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/sheet/xnamedrange.hxx>
+#include <test/unoapi_test.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 6
+
+class ScNamedRangeObj : public UnoApiTest, apitest::XNamedRange
+{
+public:
+ virtual void setUp();
+ virtual void tearDown();
+
+ virtual uno::Reference< uno::XInterface > init();
+ virtual uno::Reference< sheet::XNamedRange > getNamedRange(const rtl::OUString& rRangeName);
+
+ CPPUNIT_TEST_SUITE(ScNamedRangeObj);
+ CPPUNIT_TEST(testGetContent);
+ CPPUNIT_TEST(testSetContent);
+ CPPUNIT_TEST(testGetType);
+ CPPUNIT_TEST(testSetType);
+ CPPUNIT_TEST(testGetReferencePosition);
+ CPPUNIT_TEST(testSetReferencePosition);
+ CPPUNIT_TEST_SUITE_END();
+private:
+ static sal_Int32 nTest;
+ static uno::Reference< lang::XComponent > mxComponent;
+};
+
+sal_Int32 ScNamedRangeObj::nTest = 0;
+uno::Reference< lang::XComponent > ScNamedRangeObj::mxComponent;
+
+uno::Reference< sheet::XNamedRange> ScNamedRangeObj::getNamedRange(const rtl::OUString& rRangeName)
+{
+ uno::Reference< container::XNameAccess > xNamedAccess(init(), UNO_QUERY_THROW);
+ uno::Reference< sheet::XNamedRange > xNamedRange(xNamedAccess->getByName(rRangeName), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xNamedRange.is());
+
+ return xNamedRange;
+}
+
+uno::Reference< uno::XInterface > ScNamedRangeObj::init()
+{
+ rtl::OUString aFileURL;
+ createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods")), aFileURL);
+ if(!mxComponent.is())
+ mxComponent = loadFromDesktop(aFileURL);
+ CPPUNIT_ASSERT(mxComponent.is());
+
+ uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW);
+ rtl::OUString aNamedRangesPropertyString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
+ uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW);
+ CPPUNIT_ASSERT(xNamedRangesNameAccess.is());
+
+ return xNamedRangesNameAccess;
+}
+
+void ScNamedRangeObj::setUp()
+{
+ nTest++;
+ UnoApiTest::setUp();
+}
+
+void ScNamedRangeObj::tearDown()
+{
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ closeDocument(mxComponent);
+ }
+
+ UnoApiTest::tearDown();
+
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ mxDesktop->terminate();
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScNamedRangeObj);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/scnamedrangesobj.cxx b/sc/qa/extras/scnamedrangesobj.cxx
new file mode 100644
index 000000000000..f6d2322eadd5
--- /dev/null
+++ b/sc/qa/extras/scnamedrangesobj.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/unoapi_test.hxx>
+#include <test/sheet/xnamedranges.hxx>
+
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 3
+
+class ScNamedRangesObj : public UnoApiTest, apitest::XNamedRanges
+{
+public:
+ virtual void setUp();
+ virtual void tearDown();
+
+ virtual uno::Reference< uno::XInterface > init(sal_Int32 nSheet);
+
+ CPPUNIT_TEST_SUITE(ScNamedRangesObj);
+ CPPUNIT_TEST(testAddNewByName);
+ CPPUNIT_TEST(testAddNewFromTitles);
+ //CPPUNIT_TEST_EXCEPTION(testRemoveByName, uno::RuntimeException);
+ CPPUNIT_TEST(testOutputList);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ static sal_Int32 nTest;
+ static uno::Reference< lang::XComponent > mxComponent;
+};
+
+sal_Int32 ScNamedRangesObj::nTest = 0;
+uno::Reference< lang::XComponent > ScNamedRangesObj::mxComponent;
+
+uno::Reference< uno::XInterface > ScNamedRangesObj::init(sal_Int32 nSheet)
+{
+ rtl::OUString aFileURL;
+ createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods")), aFileURL);
+ if(!mxComponent.is())
+ mxComponent = loadFromDesktop(aFileURL);
+ CPPUNIT_ASSERT(mxComponent.is());
+
+ uno::Reference< beans::XPropertySet > xPropSet (mxComponent, UNO_QUERY_THROW);
+ rtl::OUString aNamedRangesPropertyString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
+ uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW);
+
+ //set value from xnamedranges.hxx
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
+ uno::Reference< container::XIndexAccess > xIndexAccess(xDoc->getSheets(), UNO_QUERY_THROW);
+ xSheet = uno::Reference< sheet::XSpreadsheet >(xIndexAccess->getByIndex(nSheet),UNO_QUERY_THROW);
+
+ return xNamedRanges;
+}
+
+void ScNamedRangesObj::setUp()
+{
+ nTest++;
+ UnoApiTest::setUp();
+}
+
+void ScNamedRangesObj::tearDown()
+{
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ closeDocument(mxComponent);
+ }
+
+ UnoApiTest::tearDown();
+
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ mxDesktop->terminate();
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScNamedRangesObj);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/sctablesheetsobj.cxx b/sc/qa/extras/sctablesheetsobj.cxx
new file mode 100644
index 000000000000..8b0b5e963f19
--- /dev/null
+++ b/sc/qa/extras/sctablesheetsobj.cxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <test/unoapi_test.hxx>
+#include <test/sheet/xspreadsheets2.hxx>
+#include <test/container/xnamecontainer.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 13
+
+class ScTableSheetsObj : public UnoApiTest, public ::apitest::XSpreadsheets2, apitest::XNameContainer
+{
+public:
+ ScTableSheetsObj();
+
+ virtual void setUp();
+ virtual void tearDown();
+
+ CPPUNIT_TEST_SUITE(ScTableSheetsObj);
+ CPPUNIT_TEST(testImportValue);
+ CPPUNIT_TEST(testImportString);
+ CPPUNIT_TEST(testImportedSheetNameAndIndex);
+ CPPUNIT_TEST(testImportString);
+ CPPUNIT_TEST(testImportValue);
+ CPPUNIT_TEST(testImportFormulaBasicMath);
+ CPPUNIT_TEST(testImportFormulaWithNamedRange);
+ CPPUNIT_TEST(testImportOverExistingNamedRange);
+ CPPUNIT_TEST(testImportNamedRangeDefinedInSource);
+ CPPUNIT_TEST(testImportNamedRangeRedefinedInSource);
+ CPPUNIT_TEST(testImportNewNamedRange);
+ CPPUNIT_TEST(testImportCellStyle);
+ CPPUNIT_TEST(testRemoveByName);
+ CPPUNIT_TEST_SUITE_END();
+
+ virtual uno::Reference< lang::XComponent > getComponent();
+ virtual void createFileURL(const rtl::OUString& rFileBase, rtl::OUString& rFileURL);
+ virtual uno::Reference< lang::XComponent > loadFromDesktop(const rtl::OUString& rString);
+ virtual uno::Reference< uno::XInterface > init();
+protected:
+ static uno::Reference< lang::XComponent > mxComponent;
+ static sal_Int32 nTest;
+};
+
+uno::Reference< lang::XComponent > ScTableSheetsObj::mxComponent;
+sal_Int32 ScTableSheetsObj::nTest = 0;
+
+ScTableSheetsObj::ScTableSheetsObj():
+ apitest::XNameContainer(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Sheet2")))
+{
+
+}
+
+uno::Reference< lang::XComponent > ScTableSheetsObj::getComponent()
+{
+ return mxComponent;
+}
+
+void ScTableSheetsObj::createFileURL(const rtl::OUString& rFileBase, rtl::OUString& rFileURL)
+{
+ UnoApiTest::createFileURL(rFileBase, rFileURL);
+}
+
+uno::Reference< lang::XComponent > ScTableSheetsObj::loadFromDesktop(const rtl::OUString& rString)
+{
+ return UnoApiTest::loadFromDesktop(rString);
+}
+
+uno::Reference< uno::XInterface > ScTableSheetsObj::init()
+{
+ rtl::OUString aFileURL;
+ createFileURL(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rangenamessrc.ods")), aFileURL);
+ if(!mxComponent.is())
+ mxComponent = loadFromDesktop(aFileURL);
+ CPPUNIT_ASSERT(mxComponent.is());
+ xDocument = uno::Reference< sheet::XSpreadsheetDocument >(mxComponent, UNO_QUERY_THROW);
+ uno::Reference< uno::XInterface > xReturn( xDocument->getSheets(), UNO_QUERY_THROW);
+
+ return xReturn;
+}
+
+void ScTableSheetsObj::setUp()
+{
+ nTest++;
+ CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
+ UnoApiTest::setUp();
+}
+
+void ScTableSheetsObj::tearDown()
+{
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ closeDocument(mxComponent);
+ }
+
+ UnoApiTest::tearDown();
+
+ if (nTest == NUMBER_OF_TESTS)
+ {
+ mxDesktop->terminate();
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScTableSheetsObj);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/tableautoformatfield.cxx b/sc/qa/extras/tableautoformatfield.cxx
deleted file mode 100644
index ac0ad8c53692..000000000000
--- a/sc/qa/extras/tableautoformatfield.cxx
+++ /dev/null
@@ -1,131 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <test/unoapi_test.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-
-#include <iostream>
-
-namespace ScAutoFormatFieldObj {
-
-#define NUMBER_OF_TESTS 2
-
-class ScTableAutoFormatField : public UnoApiTest
-{
-public:
-
- virtual void setUp();
- virtual void tearDown();
-
- uno::Reference< beans::XPropertySet > init(); void testRotateReference();
- void testVertJustify();
-
- CPPUNIT_TEST_SUITE(ScTableAutoFormatField);
- CPPUNIT_TEST(testRotateReference);
- CPPUNIT_TEST(testVertJustify);
- CPPUNIT_TEST_SUITE_END();
-
-private:
-
- static int nTest;
-};
-
-int ScTableAutoFormatField::nTest = 0;
-
-uno::Reference< beans::XPropertySet > ScTableAutoFormatField::init()
-{
- uno::Reference< container::XIndexAccess > xAutoFormatFields( m_xSFactory->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.TableAutoFormats"))), UNO_QUERY_THROW );
- CPPUNIT_ASSERT(xAutoFormatFields.is());
- uno::Reference< container::XIndexAccess > xIndex( xAutoFormatFields->getByIndex(0), UNO_QUERY_THROW );
- CPPUNIT_ASSERT(xIndex.is());
- uno::Reference< beans::XPropertySet > xReturn( xIndex->getByIndex(0), UNO_QUERY_THROW );
- CPPUNIT_ASSERT_MESSAGE("could not create table auto formats", xReturn.is());
- return xReturn;
-}
-
-void ScTableAutoFormatField::testRotateReference()
-{
- uno::Reference< beans::XPropertySet > xTableAutoFormatField = init();
- rtl::OUString aRotateReference(RTL_CONSTASCII_USTRINGPARAM("RotateReference"));
- uno::Any aOldRotateReference = xTableAutoFormatField->getPropertyValue(aRotateReference);
- sal_Int32 aValue = 0;
- CPPUNIT_ASSERT(aOldRotateReference >>= aValue);
- std::cout << "Old RotateReferene Value: " << aValue << std::endl;
-
- uno::Any aNewRotateReference;
- aNewRotateReference <<= static_cast<sal_Int32>(3);
- xTableAutoFormatField->setPropertyValue(aRotateReference, aNewRotateReference);
- uno::Any aRotateReferenceControllValue = xTableAutoFormatField->getPropertyValue(aRotateReference);
- CPPUNIT_ASSERT(aRotateReferenceControllValue >>= aValue);
- std::cout << "New VertJustify value: " << aValue << std::endl;
- CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3);
-}
-
-void ScTableAutoFormatField::testVertJustify()
-{
- uno::Reference< beans::XPropertySet > xTableAutoFormatField = init();
- rtl::OUString aVertJustify(RTL_CONSTASCII_USTRINGPARAM("VertJustify"));
- uno::Any aOldVertJustify = xTableAutoFormatField->getPropertyValue(aVertJustify);
- sal_Int32 aValue = 0;
- CPPUNIT_ASSERT(aOldVertJustify >>= aValue);
- std::cout << "Old VertJustify value: " << aValue << std::endl;
-
- uno::Any aNewVertJustify;
- aNewVertJustify <<= static_cast<sal_Int32>(3);
- xTableAutoFormatField->setPropertyValue(aVertJustify, aNewVertJustify);
- uno::Any aVertJustifyControllValue = xTableAutoFormatField->getPropertyValue(aVertJustify);
- CPPUNIT_ASSERT(aVertJustifyControllValue >>= aValue);
- std::cout << "New VertJustify value: " << aValue << std::endl;
- CPPUNIT_ASSERT_MESSAGE("value has not been changed", aValue == 3);
-}
-
-void ScTableAutoFormatField::setUp()
-{
- nTest += 1;
- UnoApiTest::setUp();
-}
-
-void ScTableAutoFormatField::tearDown()
-{
- UnoApiTest::tearDown();
-
- if (nTest == NUMBER_OF_TESTS)
- {
- mxDesktop->terminate();
- uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
- }
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScTableAutoFormatField);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/testdocuments/rangenamessrc.ods b/sc/qa/extras/testdocuments/rangenamessrc.ods
index f6546e960c8f..d22702bda2da 100644
--- a/sc/qa/extras/testdocuments/rangenamessrc.ods
+++ b/sc/qa/extras/testdocuments/rangenamessrc.ods
Binary files differ
diff --git a/sc/qa/extras/xcellrangesquery.cxx b/sc/qa/extras/xcellrangesquery.cxx
deleted file mode 100644
index a5a5a6fb926c..000000000000
--- a/sc/qa/extras/xcellrangesquery.cxx
+++ /dev/null
@@ -1,196 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * [ Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer) ]
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <test/unoapi_test.hxx>
-
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/sheet/XSpreadsheet.hpp>
-#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 <com/sun/star/util/XCloseable.hpp>
-
-using namespace com::sun::star;
-
-
-namespace ScCellRangeBase {
-
-#define NUMBER_OF_TESTS 5
-
-class ScXCellRangesQuery : public UnoApiTest
-{
-public:
-
- virtual void setUp();
- virtual void tearDown();
-
- //Testcases
- void testQueryColumnDifference();
- void testQueryContentDifference();
- void testQueryEmptyCells();
- void testQueryFormulaCells();
- void testQueryIntersection();
- void testQueryRowDifference();
- void testQueryVisibleCells();
-
- CPPUNIT_TEST_SUITE(ScXCellRangesQuery);
- CPPUNIT_TEST(testQueryColumnDifference);
- CPPUNIT_TEST(testQueryContentDifference);
- CPPUNIT_TEST(testQueryEmptyCells);
- //looks broken
- //CPPUNIT_TEST(testQueryFormulaCells);
- CPPUNIT_TEST(testQueryIntersection);
- CPPUNIT_TEST(testQueryRowDifference);
- CPPUNIT_TEST_SUITE_END();
-
-private:
- uno::Reference<sheet::XCellRangesQuery> init();
-
- static int nTest;
- static uno::Reference< lang::XComponent > xComponent;
-};
-
-int ScXCellRangesQuery::nTest = 0;
-uno::Reference< lang::XComponent > ScXCellRangesQuery::xComponent;
-
-uno::Reference<sheet::XCellRangesQuery> ScXCellRangesQuery::init()
-{
- rtl::OUString aFileURL;
- const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods"));
- createFileURL(aFileBase, aFileURL);
- std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- if( !xComponent.is())
- xComponent = loadFromDesktop(aFileURL);
- uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
- uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
- uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
-
- CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
-
- uno::Reference<sheet::XCellRangesQuery> xReturn(xSheet->getCellRangeByPosition(0,0,3,4), UNO_QUERY_THROW);
-
- CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is());
- return xReturn;
-}
-
-void ScXCellRangesQuery::testQueryColumnDifference()
-{
- rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.B1:C1,Sheet1.B3:C5"));
- uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery = init();
- uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryColumnDifferences(table::CellAddress(0, 1, 1));
- rtl::OUString aResult = xRanges->getRangeAddressesAsString();
- std::cout << "testQueryColumnDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryColumnDifference", aResult == aExpected);
-}
-
-void ScXCellRangesQuery::testQueryContentDifference()
-{
- rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.B2:B3"));
- uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery = init();
- uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryContentCells(sheet::CellFlags::VALUE);
- rtl::OUString aResult = xRanges->getRangeAddressesAsString();
- std::cout << "testQueryContentDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryContentDifference", aResult == aExpected);
-}
-
-void ScXCellRangesQuery::testQueryEmptyCells()
-{
- rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A1:A5,Sheet1.B1:C1,Sheet1.B5,Sheet1.C3:C5,Sheet1.D1:D5"));
- uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery = init();
- uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryEmptyCells();
- rtl::OUString aResult = xRanges->getRangeAddressesAsString();
- std::cout << "testQueryEmptyCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryEmptyCells", aResult == aExpected);
-}
-
-void ScXCellRangesQuery::testQueryFormulaCells()
-{
- rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.C2"));
- uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery = init();
- uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryFormulaCells(sheet::CellFlags::FORMULA);
- rtl::OUString aResult = xRanges->getRangeAddressesAsString();
- std::cout << "testQueryFormulaCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
-}
-
-void ScXCellRangesQuery::testQueryIntersection()
-{
- rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.D4:D5"));
- uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery = init();
- uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryIntersection(table::CellRangeAddress(0,3,3,7,7));
- rtl::OUString aResult = xRanges->getRangeAddressesAsString();
- std::cout << "testQueryIntersection: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
-}
-
-void ScXCellRangesQuery::testQueryRowDifference()
-{
- rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A2:A4,Sheet1.C2:D4"));
- uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery = init();
- uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryRowDifferences(table::CellAddress(0,1,1));
- rtl::OUString aResult = xRanges->getRangeAddressesAsString();
- std::cout << "testQueryRowDifference: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
-}
-
-void ScXCellRangesQuery::testQueryVisibleCells()
-{
- rtl::OUString aExpected(RTL_CONSTASCII_USTRINGPARAM("Sheet1.A2"));
- uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery = init();
- uno::Reference<sheet::XSheetCellRanges> xRanges = xCellRangesQuery->queryVisibleCells();
- rtl::OUString aResult = xRanges->getRangeAddressesAsString();
- std::cout << "testQueryVisibleCells: Result: " << rtl::OUStringToOString(aResult, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- CPPUNIT_ASSERT_MESSAGE("testQueryFormulaCells", aResult == aExpected);
-}
-
-void ScXCellRangesQuery::setUp()
-{
- nTest += 1;
- UnoApiTest::setUp();
-}
-
-void ScXCellRangesQuery::tearDown()
-{
- if (nTest == NUMBER_OF_TESTS)
- {
- uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
- xCloseable->close( false );
- }
-
- UnoApiTest::tearDown();
-
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScXCellRangesQuery);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/xdatabaserange.cxx b/sc/qa/extras/xdatabaserange.cxx
deleted file mode 100644
index 22a2680c9805..000000000000
--- a/sc/qa/extras/xdatabaserange.cxx
+++ /dev/null
@@ -1,209 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <test/unoapi_test.hxx>
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/sheet/XSpreadsheet.hpp>
-#include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/sheet/XDatabaseRange.hpp>
-#include <com/sun/star/sheet/XDatabaseRanges.hpp>
-#include <com/sun/star/table/CellRangeAddress.hpp>
-#include <com/sun/star/util/XCloseable.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <rtl/oustringostreaminserter.hxx>
-
-namespace ScDatabaseRangeObj {
-
-#define NUMBER_OF_TESTS 3
-
-class ScXDatabaseRange : public UnoApiTest
-{
- virtual void setUp();
- virtual void tearDown();
-
- void testDataArea();
- void testGetSortDescriptor();
- void testGetSubtotalDescriptor();
-
- CPPUNIT_TEST_SUITE(ScXDatabaseRange);
- CPPUNIT_TEST(testDataArea);
- CPPUNIT_TEST(testGetSortDescriptor);
- CPPUNIT_TEST(testGetSubtotalDescriptor);
- CPPUNIT_TEST_SUITE_END();
-private:
- uno::Reference< sheet::XDatabaseRange > init(const rtl::OUString& rName);
-
- static int nTest;
- static uno::Reference< lang::XComponent > xComponent;
-};
-
-int ScXDatabaseRange::nTest = 0;
-uno::Reference< lang::XComponent > ScXDatabaseRange::xComponent;
-
-/**
- * tests setDataArea and getDataArea
- */
-void ScXDatabaseRange::testDataArea()
-{
- uno::Reference< sheet::XDatabaseRange > xDBRange = init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataArea")));
-
- table::CellRangeAddress aCellAddress;
- aCellAddress.Sheet = 0;
- aCellAddress.StartColumn = 1;
- aCellAddress.EndColumn = 4;
- aCellAddress.StartRow = 2;
- aCellAddress.EndRow = 5;
- xDBRange->setDataArea(aCellAddress);
- table::CellRangeAddress aValue;
- aValue = xDBRange->getDataArea();
- CPPUNIT_ASSERT( aCellAddress.Sheet == aValue.Sheet );
- CPPUNIT_ASSERT( aCellAddress.StartRow == aValue.StartRow );
- CPPUNIT_ASSERT( aCellAddress.EndRow == aValue.EndRow );
- CPPUNIT_ASSERT( aCellAddress.StartColumn == aValue.StartColumn );
- CPPUNIT_ASSERT( aCellAddress.EndColumn == aValue.EndColumn );
-}
-
-void ScXDatabaseRange::testGetSubtotalDescriptor()
-{
- uno::Reference< sheet::XDatabaseRange > xDBRange = init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SubtotalDescriptor")));
- uno::Reference< sheet::XSubTotalDescriptor> xSubtotalDescr = xDBRange->getSubTotalDescriptor();
- CPPUNIT_ASSERT(xSubtotalDescr.is());
-}
-
-void ScXDatabaseRange::testGetSortDescriptor()
-{
- uno::Reference< sheet::XDatabaseRange > xDBRange = init(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SortDescriptor")));
- uno::Sequence< beans::PropertyValue > xSortDescr = xDBRange->getSortDescriptor();
- for (sal_Int32 i = 0; i < xSortDescr.getLength(); ++i)
- {
- beans::PropertyValue xProp = xSortDescr[i];
- //std::cout << "Prop " << i << " Name: " << rtl::OUString(xProp.Name) << std::endl;
-
- if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsSortColumns")))
- {
- sal_Bool bIsSortColumns;
- xProp.Value >>= bIsSortColumns;
- CPPUNIT_ASSERT(bIsSortColumns == false);
- }
- else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContainsHeader")))
- {
- sal_Bool bContainsHeader;
- xProp.Value >>= bContainsHeader;
- CPPUNIT_ASSERT(bContainsHeader == true);
- }
- else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxFieldCount")))
- {
- sal_Int32 nMaxFieldCount;
- xProp.Value >>= nMaxFieldCount;
- std::cout << "Value: " << nMaxFieldCount << std::endl;
-
- }
- else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SortFields")))
- {
-
- }
- else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BindFormatsToContent")))
- {
- sal_Bool bBindFormatsToContent;
- xProp.Value >>= bBindFormatsToContent;
- CPPUNIT_ASSERT(bBindFormatsToContent == true);
- }
- else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CopyOutputData")))
- {
- sal_Bool bCopyOutputData;
- xProp.Value >>= bCopyOutputData;
- CPPUNIT_ASSERT(bCopyOutputData == false);
- }
- else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OutputPosition")))
- {
-
- }
- else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsUserListEnabled")))
- {
- sal_Bool bIsUserListEnabled;
- xProp.Value >>= bIsUserListEnabled;
- CPPUNIT_ASSERT(bIsUserListEnabled == false);
-
- }
- else if (xProp.Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UserListIndex")))
- {
- sal_Int32 nUserListIndex;
- xProp.Value >>= nUserListIndex;
- CPPUNIT_ASSERT(nUserListIndex == 0);
- }
- }
-}
-
-uno::Reference< sheet::XDatabaseRange > ScXDatabaseRange::init(const rtl::OUString& rName)
-{
- rtl::OUString aFileURL;
- const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xdatabaserange.ods"));
- createFileURL(aFileBase, aFileURL);
- std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- if( !xComponent.is())
- xComponent = loadFromDesktop(aFileURL);
- uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
- uno::Reference< beans::XPropertySet > xPropSet(xDoc,UNO_QUERY_THROW);
- uno::Reference< sheet::XDatabaseRanges > xDBRanges( xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseRanges"))), UNO_QUERY_THROW );
- uno::Reference< container::XNameAccess > xName( xDBRanges, UNO_QUERY_THROW);
- uno::Reference< sheet::XDatabaseRange > xDBRange( xName->getByName(rName), UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xDBRange.is());
- return xDBRange;
-}
-
-void ScXDatabaseRange::setUp()
-{
- nTest += 1;
- UnoApiTest::setUp();
-}
-
-void ScXDatabaseRange::tearDown()
-{
- if (nTest == NUMBER_OF_TESTS)
- {
- uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
- xCloseable->close( false );
- }
-
- UnoApiTest::tearDown();
-
- if (nTest == NUMBER_OF_TESTS)
- {
- mxDesktop->terminate();
- uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
- }
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScXDatabaseRange);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/xdatapilotdescriptor.cxx b/sc/qa/extras/xdatapilotdescriptor.cxx
deleted file mode 100644
index e58c1453b2b5..000000000000
--- a/sc/qa/extras/xdatapilotdescriptor.cxx
+++ /dev/null
@@ -1,311 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2012 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <test/unoapi_test.hxx>
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/sheet/XSpreadsheet.hpp>
-#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
-#include <com/sun/star/sheet/XDataPilotTables.hpp>
-#include <com/sun/star/sheet/XDataPilotDescriptor.hpp>
-#include <com/sun/star/util/XCloseable.hpp>
-#include <com/sun/star/table/CellRangeAddress.hpp>
-#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-
-#include <rtl/oustringostreaminserter.hxx>
-#include <vector>
-
-namespace ScDataPilotDescriptorBase
-{
-
-#define NUMBER_OF_TESTS 9
-
-class ScXDataPilotDescriptor : public UnoApiTest
-{
-public:
-
- virtual void setUp();
- virtual void tearDown();
-
- void testSourceRange();
- void testTag();
- void testGetFilterDescriptor();
- void testGetDataPilotFields();
- void testGetColumnFields();
- void testGetRowFields();
- void testGetPageFields();
- void testGetDataFields();
- void testGetHiddenFields();
- CPPUNIT_TEST_SUITE(ScXDataPilotDescriptor);
- CPPUNIT_TEST(testSourceRange);
- CPPUNIT_TEST(testTag);
- CPPUNIT_TEST(testGetFilterDescriptor);
- CPPUNIT_TEST(testGetDataPilotFields);
- CPPUNIT_TEST(testGetColumnFields);
- CPPUNIT_TEST(testGetRowFields);
- CPPUNIT_TEST(testGetPageFields);
- CPPUNIT_TEST(testGetDataFields);
- CPPUNIT_TEST(testGetHiddenFields);
- CPPUNIT_TEST_SUITE_END();
-
-
-private:
-
- uno::Reference< sheet::XDataPilotDescriptor > init();
-
- void testGetDataPilotFields_Impl( uno::Reference< sheet::XDataPilotDescriptor > xDescr );
-
- void checkName( uno::Reference< container::XIndexAccess > xIndex, sal_Int32 nIndex );
- static std::vector<rtl::OUString> maFieldNames;
- static int nTest;
- static uno::Reference< lang::XComponent > xComponent;
-};
-
-std::vector< rtl::OUString > ScXDataPilotDescriptor::maFieldNames;
-int ScXDataPilotDescriptor::nTest = 0;
-uno::Reference< lang::XComponent > ScXDataPilotDescriptor::xComponent;
-
-void ScXDataPilotDescriptor::testTag()
-{
- rtl::OUString aTag(RTL_CONSTASCII_USTRINGPARAM("DataPilotDescriptor_Tag"));
- uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
- xDescr->setTag(aTag);
- rtl::OUString aNewTag = xDescr->getTag();
- CPPUNIT_ASSERT( aTag == aNewTag );
-}
-
-void ScXDataPilotDescriptor::testSourceRange()
-{
- uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
- table::CellRangeAddress aOldAddress = xDescr->getSourceRange();
-
- table::CellRangeAddress aAddress;
- aAddress.Sheet = 1;
- aAddress.StartColumn = 1;
- aAddress.StartRow = 1;
- aAddress.EndColumn = 5;
- aAddress.EndRow = 5;
- xDescr->setSourceRange(aAddress);
-
- table::CellRangeAddress aReturn;
- aReturn = xDescr->getSourceRange();
-
- CPPUNIT_ASSERT(aAddress.Sheet == aReturn.Sheet);
- CPPUNIT_ASSERT(aAddress.StartColumn == aReturn.StartColumn);
- CPPUNIT_ASSERT(aAddress.StartRow == aReturn.StartRow);
- CPPUNIT_ASSERT(aAddress.EndColumn == aReturn.EndColumn);
- CPPUNIT_ASSERT(aAddress.EndRow == aReturn.EndRow);
-
- //restore old settings
- xDescr->setSourceRange(aOldAddress);
-}
-
-void ScXDataPilotDescriptor::testGetFilterDescriptor()
-{
- uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
- uno::Reference< sheet::XSheetFilterDescriptor > xSheetFilterDescr = xDescr->getFilterDescriptor();
- CPPUNIT_ASSERT(xSheetFilterDescr.is());
-}
-
-void ScXDataPilotDescriptor::testGetDataPilotFields_Impl( uno::Reference< sheet::XDataPilotDescriptor > xDescr)
-{
- uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataPilotFields(), UNO_QUERY_THROW);
- CPPUNIT_ASSERT( xIndex.is());
-
- sal_Int32 nCount = xIndex->getCount();
-
- rtl::OUString aOrientation(RTL_CONSTASCII_USTRINGPARAM("Orientation"));
- for (sal_Int32 i = 0; i < nCount && i < 5; ++i)
- {
- uno::Reference< container::XNamed > xNamed( xIndex->getByIndex( i ), UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xNamed.is());
- rtl::OUString aName = xNamed->getName();
- maFieldNames.push_back(aName);
- CPPUNIT_ASSERT( !aName.equalsAscii("Data") );
-
- uno::Reference< beans::XPropertySet > xPropSet( xNamed, UNO_QUERY_THROW);
- CPPUNIT_ASSERT( xPropSet.is() );
-
- switch ( i % 5 )
- {
- case 0:
- {
- uno::Any aAny;
- aAny<<= sheet::DataPilotFieldOrientation_COLUMN;
- xPropSet->setPropertyValue(aOrientation, aAny);
- }
- break;
- case 1:
- {
- uno::Any aAny;
- aAny<<= sheet::DataPilotFieldOrientation_ROW;
- xPropSet->setPropertyValue(aOrientation, aAny);
- }
- break;
- case 2:
- {
- uno::Any aAny;
- aAny<<= sheet::DataPilotFieldOrientation_DATA;
- xPropSet->setPropertyValue(aOrientation, aAny);
- }
- break;
- case 3:
- {
- uno::Any aAny;
- aAny<<= sheet::DataPilotFieldOrientation_HIDDEN;
- xPropSet->setPropertyValue(aOrientation, aAny);
- }
- break;
- case 4:
- {
- uno::Any aAny;
- aAny<<= sheet::DataPilotFieldOrientation_PAGE;
- xPropSet->setPropertyValue(aOrientation, aAny);
- }
- break;
- default:
- break;
- }
- }
-}
-
-void ScXDataPilotDescriptor::testGetDataPilotFields()
-{
- uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
- testGetDataPilotFields_Impl( xDescr );
-}
-
-void ScXDataPilotDescriptor::testGetColumnFields()
-{
- uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
- uno::Reference< container::XIndexAccess > xIndex(xDescr->getColumnFields(), UNO_QUERY_THROW);
-
- checkName( xIndex, 0 );
-}
-
-void ScXDataPilotDescriptor::testGetRowFields()
-{
- uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
- uno::Reference< container::XIndexAccess > xIndex(xDescr->getRowFields(), UNO_QUERY_THROW);
-
- //checkName( xIndex, 1 );
-}
-
-void ScXDataPilotDescriptor::testGetPageFields()
-{
- uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
- uno::Reference< container::XIndexAccess > xIndex(xDescr->getPageFields(), UNO_QUERY_THROW);
-
- checkName( xIndex, 4 );
-}
-
-void ScXDataPilotDescriptor::testGetDataFields()
-{
- uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
- uno::Reference< container::XIndexAccess > xIndex(xDescr->getDataFields(), UNO_QUERY_THROW);
-
- checkName( xIndex, 2 );
-}
-
-void ScXDataPilotDescriptor::testGetHiddenFields()
-{
- uno::Reference< sheet::XDataPilotDescriptor > xDescr = init();
- uno::Reference< container::XIndexAccess > xIndex(xDescr->getHiddenFields(), UNO_QUERY_THROW);
-
- checkName( xIndex, 3 );
-}
-
-uno::Reference< sheet::XDataPilotDescriptor> ScXDataPilotDescriptor::init()
-{
- rtl::OUString aFileURL;
- const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("ScDataPilotTableObj.ods"));
- createFileURL(aFileBase, aFileURL);
- std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
- if( !xComponent.is())
- xComponent = loadFromDesktop(aFileURL);
- uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
- uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
- uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
-
- CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
- uno::Reference< sheet::XDataPilotTablesSupplier > xDPTS(xSheet, UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xDPTS.is());
- uno::Reference< sheet::XDataPilotTables > xDPT = xDPTS->getDataPilotTables();
- CPPUNIT_ASSERT(xDPT.is());
- uno::Sequence<rtl::OUString> aElementNames = xDPT->getElementNames();
-
- uno::Reference< sheet::XDataPilotDescriptor > xDPDsc(xDPT->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataPilotTable"))),UNO_QUERY_THROW);
-
- testGetDataPilotFields_Impl( xDPDsc );
-
- CPPUNIT_ASSERT(xDPDsc.is());
- return xDPDsc;
-}
-
-void ScXDataPilotDescriptor::checkName( uno::Reference< container::XIndexAccess > xIndex, sal_Int32 nIndex )
-{
- CPPUNIT_ASSERT(xIndex.is());
- CPPUNIT_ASSERT(maFieldNames.size() >= static_cast<size_t>(nIndex));
-
- for (sal_Int32 i = 0; i < xIndex->getCount(); ++i)
- {
- uno::Reference< container::XNamed > xNamed( xIndex->getByIndex(i), UNO_QUERY_THROW);
- CPPUNIT_ASSERT( xNamed->getName() == maFieldNames[nIndex] );
- }
-}
-
-void ScXDataPilotDescriptor::setUp()
-{
- nTest += 1;
- UnoApiTest::setUp();
-}
-
-void ScXDataPilotDescriptor::tearDown()
-{
- if (nTest == NUMBER_OF_TESTS)
- {
- uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
- xCloseable->close( false );
- }
-
- UnoApiTest::tearDown();
-
- if (nTest == NUMBER_OF_TESTS)
- {
- mxDesktop->terminate();
- uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
- }
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScXDataPilotDescriptor);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/xnamecontainer.cxx b/sc/qa/extras/xnamecontainer.cxx
deleted file mode 100644
index 0a4233577ed4..000000000000
--- a/sc/qa/extras/xnamecontainer.cxx
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <test/unoapi_test.hxx>
-#include <com/sun/star/container/XNameContainer.hpp>
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-
-
-namespace ScTableSheetsObj
-{
-
-class ScXNameContainer : public UnoApiTest
-{
- uno::Reference< container::XNameContainer > init();
-
- void testRemoveByName();
-
- CPPUNIT_TEST_SUITE(ScXNameContainer);
- CPPUNIT_TEST(testRemoveByName);
- CPPUNIT_TEST_SUITE_END();
-};
-
-void ScXNameContainer::testRemoveByName()
-{
- rtl::OUString aSheet2(RTL_CONSTASCII_USTRINGPARAM("Sheet2"));
- uno::Reference< container::XNameContainer > xNameContainer = init();
- CPPUNIT_ASSERT(xNameContainer->hasByName(aSheet2));
- xNameContainer->removeByName(aSheet2);
- CPPUNIT_ASSERT(!xNameContainer->hasByName(aSheet2));
-
- bool bExceptionThrown = false;
- try
- {
- xNameContainer->removeByName(aSheet2);
- }
- catch( const container::NoSuchElementException& )
- {
- std::cout << "Exception Caught" << std::endl;
- bExceptionThrown = true;
- }
-
- CPPUNIT_ASSERT_MESSAGE("no exception thrown", bExceptionThrown);
-}
-
-uno::Reference< container::XNameContainer > ScXNameContainer::init()
-{
- uno::Reference< lang::XComponent > xComponent;
- xComponent = loadFromDesktop(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc")));
- CPPUNIT_ASSERT(xComponent.is());
- uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
- uno::Reference< container::XNameContainer > xNameContainer ( xDoc->getSheets(), UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xNameContainer.is());
- return xNameContainer;
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScXNameContainer);
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/xnamedrange.cxx b/sc/qa/extras/xnamedrange.cxx
deleted file mode 100644
index 616c8353b79f..000000000000
--- a/sc/qa/extras/xnamedrange.cxx
+++ /dev/null
@@ -1,201 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <test/unoapi_test.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/sheet/XSpreadsheet.hpp>
-#include <com/sun/star/table/XCellRange.hpp>
-#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
-#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
-#include <com/sun/star/sheet/XNamedRanges.hpp>
-#include <com/sun/star/sheet/XNamedRange.hpp>
-#include <com/sun/star/table/XCell.hpp>
-#include <com/sun/star/text/XTextRange.hpp>
-
-#include <com/sun/star/table/CellAddress.hpp>
-#include <com/sun/star/table/CellRangeAddress.hpp>
-#include <com/sun/star/sheet/Border.hpp>
-#include <com/sun/star/sheet/NamedRangeFlag.hpp>
-
-#include <rtl/oustringostreaminserter.hxx>
-
-namespace ScNamedRangeObj {
-
-class ScXNamedRange : public UnoApiTest
-{
- uno::Reference< sheet::XSpreadsheetDocument> init();
- uno::Reference< sheet::XNamedRange> getTestedNamedRange(const rtl::OUString&);
-
- // XNamedRange
- void testGetContent();
- void testSetContent();
- void testGetType();
- void testSetType();
- void testGetReferencePosition();
- void testSetReferencePosition();
-
- CPPUNIT_TEST_SUITE(ScXNamedRange);
- CPPUNIT_TEST(testGetContent);
- CPPUNIT_TEST(testSetContent);
- CPPUNIT_TEST(testGetType);
- CPPUNIT_TEST(testSetType);
- CPPUNIT_TEST(testGetReferencePosition);
- CPPUNIT_TEST(testSetReferencePosition);
- CPPUNIT_TEST_SUITE_END();
-};
-
-
-void ScXNamedRange::testGetContent()
-{
- rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
- uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString);
-
- rtl::OUString aExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1"));
- CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 on GetContent", xNamedRange->getContent().equals(aExpectedContent));
-}
-
-void ScXNamedRange::testSetContent()
-{
- rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
- uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString);
-
- rtl::OUString aExpectedContent;
-
- // test a cell
- aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D1"));
- xNamedRange->setContent(aExpectedContent);
- CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cell", xNamedRange->getContent().equals(aExpectedContent));
-
- // test a cellrange
- aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D1:D10"));
- xNamedRange->setContent(aExpectedContent);
- CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cellrange", xNamedRange->getContent().equals(aExpectedContent));
-
- // test a formula
- aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=D10"));
- xNamedRange->setContent(aExpectedContent);
- aExpectedContent = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D10"));
- CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a formula", xNamedRange->getContent().equals(aExpectedContent));
-
-}
-
-void ScXNamedRange::testGetType()
-{
- rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
- uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString);
- CPPUNIT_ASSERT_MESSAGE("Wrong expected Type", xNamedRange->getType() == 0);
-}
-
-void ScXNamedRange::testSetType()
-{
- rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
- uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString);
-
- sal_Int32 nType = ::sheet::NamedRangeFlag::ROW_HEADER;;
- xNamedRange->setType(nType);
- CPPUNIT_ASSERT_MESSAGE("Wrong expected Type ROW_HEADER after setting it", xNamedRange->getType() == nType);
-
- nType = ::sheet::NamedRangeFlag::COLUMN_HEADER;
- xNamedRange->setType(nType);
- CPPUNIT_ASSERT_MESSAGE("Wrong expected Type COLUMN_HEADER after setting it", xNamedRange->getType() == nType);
-
- nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA;
- xNamedRange->setType(nType);
- CPPUNIT_ASSERT_MESSAGE("Wrong expected Type FILTER_CRITERIA after setting it", xNamedRange->getType() == nType);
-
- nType = ::sheet::NamedRangeFlag::PRINT_AREA;
- xNamedRange->setType(nType);
- CPPUNIT_ASSERT_MESSAGE("Wrong expected Type PRINT_AREA after setting it", xNamedRange->getType() == nType);
-
- nType = 0;
- xNamedRange->setType(nType);
- CPPUNIT_ASSERT_MESSAGE("Wrong expected Type 0 after setting it", xNamedRange->getType() == nType);
-}
-
-void ScXNamedRange::testGetReferencePosition()
-{
- rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial2"));
- uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString);
-
- table::CellAddress xCellAddress = xNamedRange->getReferencePosition();
- // the expeted address is on B1, as it was the active cell when intial2 created
- CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position", xCellAddress.Sheet == 0);
- CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position", xCellAddress.Column == 1);
- CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position", xCellAddress.Row == 0);
-}
-
-void ScXNamedRange::testSetReferencePosition()
-{
- rtl::OUString aTestedNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
- uno::Reference< sheet::XNamedRange > xNamedRange = getTestedNamedRange(aTestedNamedRangeString);
-
- table::CellAddress aBaseAddress = table::CellAddress(1,2,3);
-
- xNamedRange->setReferencePosition(aBaseAddress);
-
- table::CellAddress xCellAddress = xNamedRange->getReferencePosition();
- CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position after setting it", xCellAddress.Sheet == 1);
- CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position after setting it", xCellAddress.Column == 2);
- CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position after setting it", xCellAddress.Row == 3);
-}
-
-uno::Reference< sheet::XSpreadsheetDocument> ScXNamedRange::init()
-{
- rtl::OUString aFileURL;
- const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods"));
- createFileURL(aFileBase, aFileURL);
- static uno::Reference< lang::XComponent > xComponent;
- if( !xComponent.is())
- xComponent = loadFromDesktop(aFileURL);
- uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xDoc.is());
-
- return xDoc;
-}
-
-uno::Reference< sheet::XNamedRange> ScXNamedRange::getTestedNamedRange(const rtl::OUString& aTestedNamedRangeString)
-{
- uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
- uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
- rtl::OUString aNamedRangesPropertyString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
- uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesPropertyString), UNO_QUERY_THROW);
-
- uno::Reference< sheet::XNamedRange > xNamedRange(xNamedRangesNameAccess->getByName(aTestedNamedRangeString), UNO_QUERY_THROW);
-
- return xNamedRange;
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScXNamedRange);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/xnamedranges.cxx b/sc/qa/extras/xnamedranges.cxx
deleted file mode 100644
index 70a599698e57..000000000000
--- a/sc/qa/extras/xnamedranges.cxx
+++ /dev/null
@@ -1,259 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <test/unoapi_test.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/sheet/XSpreadsheet.hpp>
-#include <com/sun/star/table/XCellRange.hpp>
-#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
-#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
-#include <com/sun/star/sheet/XNamedRanges.hpp>
-#include <com/sun/star/sheet/XNamedRange.hpp>
-#include <com/sun/star/table/XCell.hpp>
-#include <com/sun/star/text/XTextRange.hpp>
-
-#include <com/sun/star/table/CellAddress.hpp>
-#include <com/sun/star/table/CellRangeAddress.hpp>
-#include <com/sun/star/sheet/Border.hpp>
-#include <com/sun/star/sheet/NamedRangeFlag.hpp>
-
-#include <rtl/oustringostreaminserter.hxx>
-
-namespace ScNamedRangesObj {
-
-class ScXNamedRanges : public UnoApiTest
-{
- uno::Reference< sheet::XSpreadsheetDocument> init();
-
- // XNamedRanges
- void testAddNewByName();
- void testAddNewFromTitles();
- void testRemoveByName();
- void testOutputList();
-
- CPPUNIT_TEST_SUITE(ScXNamedRanges);
- CPPUNIT_TEST(testAddNewByName);
- CPPUNIT_TEST(testAddNewFromTitles);
- //fix first warning in ExceptionsTestCaseDecorator
- //CPPUNIT_TEST_EXCEPTION(testRemoveByName, uno::RuntimeException);
- CPPUNIT_TEST(testOutputList);
- CPPUNIT_TEST_SUITE_END();
-};
-
-
-void ScXNamedRanges::testAddNewByName()
-{
- uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
- uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
- uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
-
- uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
- rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
- uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
- uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
-
- table::CellAddress aBaseAddress = table::CellAddress(0,0,0);
-
- sal_Int32 nType = 0;
- rtl::OUString aContent1(RTL_CONSTASCII_USTRINGPARAM("D1"));
- rtl::OUString aName1(RTL_CONSTASCII_USTRINGPARAM("type_0"));
- xNamedRanges->addNewByName(aName1, aContent1, aBaseAddress, nType);
- CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type 0 - Normal case", xNamedRanges->hasByName(aName1));
-
- nType = ::sheet::NamedRangeFlag::COLUMN_HEADER;
- rtl::OUString aContent2(RTL_CONSTASCII_USTRINGPARAM("D2"));
- rtl::OUString aName2(RTL_CONSTASCII_USTRINGPARAM("type_COLUMN_HEADER"));
- xNamedRanges->addNewByName(aName2, aContent2, aBaseAddress, nType);
- CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type COLUMN_HEADER", xNamedRanges->hasByName(aName2));
-
- nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA;
- rtl::OUString aContent3(RTL_CONSTASCII_USTRINGPARAM("D3"));
- rtl::OUString aName3(RTL_CONSTASCII_USTRINGPARAM("type_FILTER_CRITERIA"));
- xNamedRanges->addNewByName(aName3, aContent3, aBaseAddress, nType);
- CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type FILTER_CRITERIA", xNamedRanges->hasByName(aName3));
-
- nType = ::sheet::NamedRangeFlag::PRINT_AREA;
- rtl::OUString aContent4(RTL_CONSTASCII_USTRINGPARAM("D4"));
- rtl::OUString aName4(RTL_CONSTASCII_USTRINGPARAM("type_PRINT_AREA"));
- xNamedRanges->addNewByName(aName4, aContent4, aBaseAddress, nType);
- CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type PRINT_AREA", xNamedRanges->hasByName(aName4));
-
- nType = ::sheet::NamedRangeFlag::ROW_HEADER;
- rtl::OUString aContent5(RTL_CONSTASCII_USTRINGPARAM("D5"));
- rtl::OUString aName5(RTL_CONSTASCII_USTRINGPARAM("type_ROW_HEADER"));
- xNamedRanges->addNewByName(aName5, aContent5, aBaseAddress, nType);
- CPPUNIT_ASSERT_MESSAGE("Failed to create Namedrange Type ROW_HEADER", xNamedRanges->hasByName(aName5));
-
-}
-
-void ScXNamedRanges::testAddNewFromTitles()
-{
-
- uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
- uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
- uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
-
- uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
- rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
- uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
- uno::Reference< container::XIndexAccess > xNamedRangesIndex(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
- uno::Reference< container::XNameAccess > xNamedRangesNameAccess(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
-
- table::CellRangeAddress aCellRangeAddress = table::CellRangeAddress(1,0,0,3,3);
-
- rtl::OUString aString;
- uno::Reference< table::XCell > xCell;
-
- xNamedRanges->addNewFromTitles(aCellRangeAddress, sheet::Border_TOP);
-
- for (sal_Int32 i = 1; i < 4; i++)
- {
- // verify namedrange exists
- xCell = xSheet->getCellByPosition(i,0);
- uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
- aString = xTextRange->getString();
- std::cout << "verify " << aString << std::endl;
- CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
-
- // verify it points on the right cell
- uno::Any aNr = xNamedRangesNameAccess->getByName(aString);
- uno::Reference< sheet::XNamedRange > xNamedRange(aNr, UNO_QUERY_THROW);
-
- uno::Reference< sheet::XCellRangeReferrer > xCellRangeRef(xNamedRange, UNO_QUERY_THROW);
- uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW);
- table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress();
-
- CPPUNIT_ASSERT(cellRangeAddress.EndColumn == i && cellRangeAddress.StartColumn == i);
- CPPUNIT_ASSERT(cellRangeAddress.StartRow == 1);
- CPPUNIT_ASSERT(cellRangeAddress.EndRow == 3);
- CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1);
- }
-
- xNamedRanges->addNewFromTitles(aCellRangeAddress, sheet::Border_LEFT);
-
- for (sal_Int32 i = 1; i < 4; i++)
- {
- // verify namedrange exists
- xCell = xSheet->getCellByPosition(0,i);
- uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
- aString = xTextRange->getString();
- std::cout << "verify " << aString << std::endl;
- CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
-
- // verify it points on the right cell
- uno::Any aNr= xNamedRangesNameAccess->getByName(aString);
- uno::Reference< sheet::XNamedRange > xNamedRange(aNr, UNO_QUERY_THROW);
-
- uno::Reference< sheet::XCellRangeReferrer > xCellRangeRef(xNamedRange, UNO_QUERY_THROW);
- uno::Reference< sheet::XCellRangeAddressable > xCellRangeAdr(xCellRangeRef->getReferredCells(), UNO_QUERY_THROW);
- table::CellRangeAddress cellRangeAddress = xCellRangeAdr->getRangeAddress();
-
- CPPUNIT_ASSERT(cellRangeAddress.EndRow == i && cellRangeAddress.StartRow == i);
- CPPUNIT_ASSERT(cellRangeAddress.StartColumn == 1);
- CPPUNIT_ASSERT(cellRangeAddress.EndColumn == 3);
- CPPUNIT_ASSERT(cellRangeAddress.Sheet == 1);
- }
-}
-
-void ScXNamedRanges::testRemoveByName()
-{
- uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
- uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
- rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
- uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
- uno::Reference< container::XIndexAccess > xIndex(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
-
- rtl::OUString aNr1(RTL_CONSTASCII_USTRINGPARAM("initial1"));
- bool bHasIt = xNamedRanges->hasByName(aNr1);
- CPPUNIT_ASSERT_MESSAGE("NamedRange initial1 des not exits, can't remove it", bHasIt);
-
- if (bHasIt)
- {
- // remove existing
- sal_Int32 nInitialCount = xIndex->getCount();
- xNamedRanges->removeByName(aNr1);
- sal_Int32 nNewCount = xIndex->getCount();
- CPPUNIT_ASSERT_MESSAGE("NamedRange initial1 not removed", nNewCount == nInitialCount - 1);
- CPPUNIT_ASSERT_MESSAGE("Wrong NamedRange removed, initial1 still present", !xNamedRanges->hasByName(aNr1));
- // try to remove non existing
- rtl::OUString aNr2(RTL_CONSTASCII_USTRINGPARAM("dummyNonExistingNamedRange"));
- xNamedRanges->removeByName(aNr2);// an exception should be raised here
- }
-}
-
-void ScXNamedRanges::testOutputList()
-{
-
- uno::Reference< sheet::XSpreadsheetDocument> xDoc = init();
- uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
- uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
-
- table::CellAddress xCellAddress = table::CellAddress (0,2,0);
-
- uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
- rtl::OUString aNamedRangesString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
- uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
- uno::Reference< container::XIndexAccess > xNamedRangesIndex(xPropSet->getPropertyValue(aNamedRangesString), UNO_QUERY_THROW);
- sal_Int32 nElementsCount = xNamedRangesIndex->getCount();
-
- xNamedRanges->outputList(xCellAddress);
-
- rtl::OUString aString;
- uno::Reference< table::XCell > xCell;
-
- for (sal_Int32 i = 0; i < nElementsCount; i++)
- {
- xCell = xSheet->getCellByPosition(2,i);
- uno::Reference< text::XTextRange > xTextRange(xCell, UNO_QUERY_THROW);
- aString = xTextRange->getString();
- std::cout << "verify " << aString << std::endl;
- CPPUNIT_ASSERT_MESSAGE("Non existing NamedRange", xNamedRanges->hasByName(aString));
- }
-}
-
-uno::Reference< sheet::XSpreadsheetDocument> ScXNamedRanges::init()
-{
- rtl::OUString aFileURL;
- const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods"));
- createFileURL(aFileBase, aFileURL);
- static uno::Reference< lang::XComponent > xComponent;
- if( !xComponent.is())
- xComponent = loadFromDesktop(aFileURL);
- uno::Reference< sheet::XSpreadsheetDocument> xDoc (xComponent, UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xDoc.is());
-
- return xDoc;
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScXNamedRanges);
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/xspreadsheets2.cxx b/sc/qa/extras/xspreadsheets2.cxx
deleted file mode 100644
index f694556b0313..000000000000
--- a/sc/qa/extras/xspreadsheets2.cxx
+++ /dev/null
@@ -1,447 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <test/unoapi_test.hxx>
-
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
-#include <com/sun/star/sheet/XSpreadsheet.hpp>
-#include <com/sun/star/sheet/XSpreadsheets2.hpp>
-#include <com/sun/star/table/XCellRange.hpp>
-#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
-#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
-#include <com/sun/star/sheet/XNamedRanges.hpp>
-#include <com/sun/star/sheet/XNamedRange.hpp>
-#include <com/sun/star/table/XCell.hpp>
-#include <com/sun/star/text/XTextRange.hpp>
-#include <com/sun/star/util/XCloseable.hpp>
-#include <com/sun/star/frame/XStorable.hpp>
-
-#include <com/sun/star/table/CellAddress.hpp>
-#include <com/sun/star/table/CellRangeAddress.hpp>
-#include <com/sun/star/sheet/Border.hpp>
-#include <com/sun/star/sheet/NamedRangeFlag.hpp>
-
-#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
-#include <com/sun/star/container/XNameContainer.hpp>
-#include <com/sun/star/table/CellVertJustify.hpp>
-
-#include <rtl/oustringostreaminserter.hxx>
-#include <rtl/string.hxx>
-
-
-
-namespace ScSpreadsheetObj {
-
-#define NUMBER_OF_TESTS 1
-
-class ScXSpreadsheets2 : public UnoApiTest
-{
-public:
-
- virtual void setUp();
- virtual void tearDown();
-
- // XSpreadsheets2
- void testImportedSheetNameAndIndex();
- void testImportString();
- void testImportValue();
- void testImportFormulaBasicMath();
- void testImportFormulaWithNamedRange();
- void testImportOverExistingNamedRange();
- void testImportNamedRangeDefinedInSource();
- void testImportNamedRangeRedefinedInSource();
- void testImportNewNamedRange();
- void testImportCellStyle();
-
- CPPUNIT_TEST_SUITE(ScXSpreadsheets2);
- CPPUNIT_TEST(testImportedSheetNameAndIndex);
- CPPUNIT_TEST(testImportString);
- CPPUNIT_TEST(testImportValue);
- CPPUNIT_TEST(testImportFormulaBasicMath);
- CPPUNIT_TEST(testImportFormulaWithNamedRange);
- CPPUNIT_TEST(testImportOverExistingNamedRange);
- CPPUNIT_TEST(testImportNamedRangeDefinedInSource);
- CPPUNIT_TEST(testImportNamedRangeRedefinedInSource);
- CPPUNIT_TEST(testImportNewNamedRange);
- CPPUNIT_TEST(testImportCellStyle);
-
- CPPUNIT_TEST_SUITE_END();
-
-private:
- uno::Reference< sheet::XSpreadsheetDocument> getDoc(const rtl::OUString, uno::Reference< lang::XComponent >&);
- uno::Reference< sheet::XNamedRanges> getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument >);
- void importSheetToCopy();
- bool isExternalReference(const rtl::OUString aDestContent, const rtl::OUString aSrcContent );
-
- static int nTest;
- static uno::Reference< lang::XComponent > xComponent;
-
- static bool bIsSheetImported;
- static uno::Reference< sheet::XSpreadsheetDocument> xSrcDoc;
- static uno::Reference< sheet::XSpreadsheetDocument> xDestDoc;
- static uno::Reference< container::XNameAccess > xSrcNamedRangesNameAccess;
- static uno::Reference< container::XNameAccess > xDestNamedRangesNameAccess;
- static uno::Reference< container::XNameAccess > xDestSheetNameAccess;
- static uno::Reference< sheet::XSpreadsheet > xDestSheet;
- static uno::Reference< sheet::XSpreadsheet > xSrcSheet;
- static sal_Int32 nDestPosEffective;
- static rtl::OUString aSrcSheetName;
- static rtl::OUString aSrcFileBase;
- static rtl::OUString aDestFileBase;
- static sal_Int32 nDestPos;
-};
-
-int ScXSpreadsheets2::nTest = 0;
-uno::Reference< lang::XComponent > ScXSpreadsheets2::xComponent;
-
-bool ScXSpreadsheets2::bIsSheetImported = false;
-uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::xSrcDoc;
-uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::xDestDoc;
-uno::Reference< container::XNameAccess > ScXSpreadsheets2::xSrcNamedRangesNameAccess;
-uno::Reference< container::XNameAccess > ScXSpreadsheets2::xDestNamedRangesNameAccess;
-uno::Reference< container::XNameAccess > ScXSpreadsheets2::xDestSheetNameAccess;
-uno::Reference< sheet::XSpreadsheet > ScXSpreadsheets2::xDestSheet;
-uno::Reference< sheet::XSpreadsheet > ScXSpreadsheets2::xSrcSheet;
-rtl::OUString ScXSpreadsheets2::aSrcSheetName(RTL_CONSTASCII_USTRINGPARAM("SheetToCopy"));
-rtl::OUString ScXSpreadsheets2::aSrcFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenamessrc.ods"));
-rtl::OUString ScXSpreadsheets2::aDestFileBase(RTL_CONSTASCII_USTRINGPARAM("rangenames.ods"));
-sal_Int32 ScXSpreadsheets2::nDestPos = 0;
-sal_Int32 ScXSpreadsheets2::nDestPosEffective = 0;
-
-void ScXSpreadsheets2::testImportedSheetNameAndIndex()
-{
-/**
- Verfiy that the imported sheet has the correct name and is placed at the right requested index
-*/
-
- importSheetToCopy();
-
- CPPUNIT_ASSERT_MESSAGE("Wrong sheet name", xDestSheetNameAccess->hasByName(aSrcSheetName));
- CPPUNIT_ASSERT_MESSAGE("Wrong sheet index", nDestPosEffective == nDestPos);
-
-}
-
-void ScXSpreadsheets2::testImportString()
-{
-/**
- tests the cell A1 containing a string correctly imported
-*/
- importSheetToCopy();
-
- uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(0,0);
- uno::Reference< text::XTextRange > xSrcTextRange(xSrcCell, UNO_QUERY_THROW);
- rtl::OUString aSrcString = xSrcTextRange->getString();
-
- uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(0,0);
- uno::Reference< text::XTextRange > xDestTextRange(xDestCell, UNO_QUERY_THROW);
- rtl::OUString aDestString = xDestTextRange->getString();
-
- CPPUNIT_ASSERT_MESSAGE("Wrong string imported", aDestString.equals(aSrcString));
-}
-
-void ScXSpreadsheets2::testImportValue()
-{
-/**
- tests the cell B1 containing a value correctly imported
-*/
- importSheetToCopy();
-
- uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(1,0);
- sal_Int32 aSrcValue = xSrcCell->getValue();
-
- uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(1,0);
- sal_Int32 aDestValue = xDestCell->getValue();
-
- CPPUNIT_ASSERT_MESSAGE("Wrong value imported", aSrcValue == aDestValue);
-}
-
-void ScXSpreadsheets2::testImportFormulaBasicMath()
-{
-/**
- tests the cell C1 containing an arithmetic formula correctly imported
-*/
- importSheetToCopy();
-
- uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(2,0);
- rtl::OUString aSrcFormula = xSrcCell->getFormula();
-
- uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(2,0);
- rtl::OUString aDestFormula = xDestCell->getFormula();
-
- // potential problem later: formulas might be adjusted
- // add some tests that the formulas are correctly adjusted
- CPPUNIT_ASSERT_MESSAGE("Wrong formula imported", aDestFormula.equals(aSrcFormula));
-}
-
-void ScXSpreadsheets2::testImportFormulaWithNamedRange()
-{
-/**
- tests the cell D1 containing a formula that uses a NamedRange expression
-*/
- importSheetToCopy();
-
- uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(3,0);
- rtl::OUString aSrcFormula = xSrcCell->getFormula();
-
- uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(3,0);
- rtl::OUString aDestFormula = xDestCell->getFormula();
-
- CPPUNIT_ASSERT_MESSAGE("Wrong Namedrange formula imported", aDestFormula.equals(aSrcFormula));
-}
-
-void ScXSpreadsheets2::testImportOverExistingNamedRange()
-{
-/**
- Both Source and Target file define the named range initial1
- in Source, initial1 is defined outside the copied sheet
- In Target, after import sheet, initial1 should point on its initial definition $Sheet1.$B$1
-
- NEED MORE WORK
-*/
- importSheetToCopy();
-
- rtl::OUString aNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial1"));
-
- uno::Any aNr = xDestNamedRangesNameAccess->getByName(aNamedRangeString);
- uno::Reference< sheet::XNamedRange > xDestNamedRange(aNr, UNO_QUERY_THROW);
- rtl::OUString aNrDestContent = xDestNamedRange->getContent();
-
- rtl::OUString aExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1"));
-
- std::cout << "testImportSheet : initial1 aNrDestContent " << aNrDestContent << std::endl;
- CPPUNIT_ASSERT_MESSAGE("Wrong address for initial1", aNrDestContent.equals(aExpectedContent));
-
-}
-
-void ScXSpreadsheets2::testImportNamedRangeDefinedInSource()
-{
-/**
- in Source file, InSheetRangeName named range is defined in the copied sheet
- it does not exists in target file
- test that the range named is created in target and that it points in the target copied sheet
-*/
- importSheetToCopy();
-
- // New range name defined in imported sheet $SheetToCopy.$A$7
- rtl::OUString aNewInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("InSheetRangeName"));
- CPPUNIT_ASSERT_MESSAGE("InSheetRangeName", xDestNamedRangesNameAccess->hasByName(aNewInSheetNamedRangeString));
-
- uno::Any aNewInSheetNr = xDestNamedRangesNameAccess->getByName(aNewInSheetNamedRangeString);
- uno::Reference< sheet::XNamedRange > xDestNewInSheetNamedRange(aNewInSheetNr, UNO_QUERY_THROW);
- rtl::OUString aNewInSheetNrDestContent = xDestNewInSheetNamedRange->getContent();
- rtl::OUString aNewInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$SheetToCopy.$A$7"));
-
- std::cout << "testImportSheet : InSheetRangeName content " << aNewInSheetNrDestContent << std::endl;
- std::cout << "testImportSheet : InSheetRangeName expected " << aNewInSheetExpectedContent << std::endl;
- CPPUNIT_ASSERT_MESSAGE("Wrong address for InSheetRangeName", aNewInSheetNrDestContent.equals(aNewInSheetExpectedContent));
-}
-
-void ScXSpreadsheets2::testImportNamedRangeRedefinedInSource()
-{
-/**
- in Source file, initial2 named range is defined in the copied sheet
- it is defined in another sheet of target file
- test that the range named points in the target copied sheet
-*/
- importSheetToCopy();
-
- // the source file redefines an existing named range in the imported sheet --> the target should not be changed
- rtl::OUString aRedefinedInSheetNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("initial2"));
- CPPUNIT_ASSERT_MESSAGE("aRedefinedInSheetNamedRangeString", xDestNamedRangesNameAccess->hasByName(aRedefinedInSheetNamedRangeString));
-
- uno::Any aRedefinedInSheetNr = xDestNamedRangesNameAccess->getByName(aRedefinedInSheetNamedRangeString);
- uno::Reference< sheet::XNamedRange > xDestRedefinedInSheetNamedRange(aRedefinedInSheetNr, UNO_QUERY_THROW);
- rtl::OUString aRedefinedInSheetNrDestContent = xDestRedefinedInSheetNamedRange->getContent();
- rtl::OUString aRedefinedInSheetExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$2"));
- std::cout << "testImportSheet : initial2 content " << aRedefinedInSheetNrDestContent << std::endl;
- CPPUNIT_ASSERT_MESSAGE("Wrong address for Redefined InSheet named range", aRedefinedInSheetNrDestContent.equals(aRedefinedInSheetExpectedContent));
-}
-
-void ScXSpreadsheets2::testImportNewNamedRange()
-{
-/**
- in Soucre file, new_rangename range named is defined outside the copied sheet
- it does not exists in target file
- test that new_rangename is created and its content points to source file as an external reference
-*/
- importSheetToCopy();
-
- //formula with a non-existant named range in dest - new_rangename
- rtl::OUString aNewNamedRangeString(RTL_CONSTASCII_USTRINGPARAM("new_rangename"));
- CPPUNIT_ASSERT_MESSAGE("New NamedRange not created", xDestNamedRangesNameAccess->hasByName(aNewNamedRangeString));
-
- // verify the content of this new namedrange, pointing on $Sheet1.$B$1 in source. This address is already defined in target as NR content
-
- uno::Any aNewNr = xDestNamedRangesNameAccess->getByName(aNewNamedRangeString);
- uno::Reference< sheet::XNamedRange > xDestNewNamedRange(aNewNr, UNO_QUERY_THROW);
- rtl::OUString aNewNrDestContent = xDestNewNamedRange->getContent();
-
- rtl::OUString aNewExpectedContent(RTL_CONSTASCII_USTRINGPARAM("$Sheet1.$B$1"));
-
- std::cout << "testImportSheet : new_rangename aNewExpectedContent " << aNewExpectedContent << std::endl;
- std::cout << "testImportSheet : new_rangename aNewNrDestContent " << aNewNrDestContent << std::endl;
- CPPUNIT_ASSERT_MESSAGE("Wrong New NamedRange formula string value", isExternalReference(aNewNrDestContent, aNewExpectedContent));
-}
-
-void ScXSpreadsheets2::testImportCellStyle()
-{
-/**
- in source file, imported sheet uses a cellstyle that does not exists in target
- test that
- - an imported cell D1 uses the right cellStyle
- - the cellStyle is created in CellStyles family
- - a property of the cellStyle (VertJustify) is correctly set
-*/
- importSheetToCopy();
-
- uno::Reference< table::XCell > xSrcCell = xSrcSheet->getCellByPosition(3,0);
- uno::Reference< table::XCell > xDestCell = xDestSheet->getCellByPosition(3,0);
-
- //new style created in dest
- uno::Reference< beans::XPropertySet > xSrcCellPropSet (xSrcCell, UNO_QUERY_THROW);
- const rtl::OUString aCellProperty(RTL_CONSTASCII_USTRINGPARAM("CellStyle"));
- rtl::OUString aSrcStyleName;
- CPPUNIT_ASSERT(xSrcCellPropSet->getPropertyValue(aCellProperty) >>= aSrcStyleName);
-
- uno::Reference< beans::XPropertySet > xDestCellPropSet (xSrcCell, UNO_QUERY_THROW);
- rtl::OUString aDestStyleName;
- CPPUNIT_ASSERT(xDestCellPropSet->getPropertyValue(aCellProperty) >>= aDestStyleName);
-
- CPPUNIT_ASSERT_MESSAGE("Wrong imported Cell Style", aDestStyleName.equals(aSrcStyleName));
-
- uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier (xDestDoc, UNO_QUERY_THROW);
- uno::Reference< container::XNameAccess > xFamiliesNameAccess (xFamiliesSupplier->getStyleFamilies(), UNO_QUERY_THROW);
- rtl::OUString aCellFamilyName(RTL_CONSTASCII_USTRINGPARAM("CellStyles"));
- uno::Any xCellStylesFamily = xFamiliesNameAccess->getByName(aCellFamilyName);
- uno::Reference< container::XNameContainer > xCellStylesFamilyNameAccess (xCellStylesFamily, UNO_QUERY_THROW);
-
- CPPUNIT_ASSERT_MESSAGE("New cell style not present", xCellStylesFamilyNameAccess->hasByName(aDestStyleName));
-
- uno::Any aCellStyle = xCellStylesFamilyNameAccess->getByName(aDestStyleName);
- uno::Reference< beans::XPropertySet > xCellStyleProp (aCellStyle, UNO_QUERY_THROW);
- rtl::OUString aProperty(RTL_CONSTASCII_USTRINGPARAM("VertJustify"));
- sal_Int32 aVertJustify = 0;
- CPPUNIT_ASSERT(xCellStyleProp->getPropertyValue(aProperty) >>= aVertJustify);
-
- CPPUNIT_ASSERT_MESSAGE("New style: VertJustify not set", aVertJustify == table::CellVertJustify_CENTER);
-}
-
-uno::Reference< sheet::XSpreadsheetDocument> ScXSpreadsheets2::getDoc(const rtl::OUString aFileBase, uno::Reference< lang::XComponent >& xComp)
-{
- rtl::OUString aFileURL;
- createFileURL(aFileBase, aFileURL);
-
- if (!xComp.is())
- xComp = loadFromDesktop(aFileURL);
-
- CPPUNIT_ASSERT(xComp.is());
-
- uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComp, UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xDoc.is());
- return xDoc;
-}
-
-uno::Reference< sheet::XNamedRanges> ScXSpreadsheets2::getNamedRanges(uno::Reference< sheet::XSpreadsheetDocument> xDoc)
-{
- uno::Reference< beans::XPropertySet > xPropSet (xDoc, UNO_QUERY_THROW);
- rtl::OUString NamedRangesPropertyString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
- uno::Reference< sheet::XNamedRanges > xNamedRanges(xPropSet->getPropertyValue(NamedRangesPropertyString), UNO_QUERY_THROW);
- CPPUNIT_ASSERT(xNamedRanges.is());
-
- return xNamedRanges;
-}
-
-void ScXSpreadsheets2::importSheetToCopy()
-{
- if (!bIsSheetImported)
- {
- xSrcDoc = getDoc(aSrcFileBase, xComponent);
- CPPUNIT_ASSERT(xSrcDoc.is());
- xSrcNamedRangesNameAccess = uno::Reference< container::XNameAccess> (getNamedRanges(xSrcDoc), UNO_QUERY_THROW);
-
- uno::Reference< lang::XComponent > xDestComponent;
- xDestDoc = getDoc(aDestFileBase, xDestComponent);
- CPPUNIT_ASSERT(xDestDoc.is());
- xDestNamedRangesNameAccess = uno::Reference< container::XNameAccess > (getNamedRanges(xDestDoc), UNO_QUERY_THROW);
-
- // import sheet
- uno::Reference< sheet::XSpreadsheets2 > xDestSheets (xDestDoc->getSheets(), UNO_QUERY_THROW);
- nDestPosEffective = xDestSheets->importSheet(xSrcDoc, aSrcSheetName, nDestPos);
-
- uno::Reference< container::XNameAccess > xSrcSheetNameAccess (xSrcDoc->getSheets(), UNO_QUERY_THROW);
- xSrcSheet = uno::Reference< sheet::XSpreadsheet > (xSrcSheetNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW);
-
- xDestSheetNameAccess = uno::Reference< container::XNameAccess > (xDestDoc->getSheets(), UNO_QUERY_THROW);
- xDestSheet = uno::Reference< sheet::XSpreadsheet > ( xDestSheetNameAccess->getByName(aSrcSheetName), UNO_QUERY_THROW);
-
- bIsSheetImported = true;
- }
-}
-
-bool ScXSpreadsheets2::isExternalReference(rtl::OUString aDestContent, rtl::OUString aSrcContent )
-{
- rtl::OUString aStart(RTL_CONSTASCII_USTRINGPARAM("'file://"));
- const sal_Char* sSrcContent = rtl::OUStringToOString( aSrcContent, RTL_TEXTENCODING_UTF8 ).getStr();
-
- return (aDestContent.endsWithIgnoreAsciiCaseAsciiL(sSrcContent, aSrcContent.getLength()) // same cell address
- && aDestContent.indexOf(aStart)==0 // starts with 'file://
- && aDestContent.indexOf(aSrcFileBase)>0); // contains source file name
-}
-
-void ScXSpreadsheets2::setUp()
-{
- nTest += 1;
- UnoApiTest::setUp();
-}
-
-void ScXSpreadsheets2::tearDown()
-{
- //closing the document fails ATM
- if (nTest == NUMBER_OF_TESTS)
- {
- //uno::Reference< util::XCloseable > xCloseable(xComponent, UNO_QUERY_THROW);
- //xCloseable->close( false );
- }
-
- UnoApiTest::tearDown();
-
- if (nTest == NUMBER_OF_TESTS)
- {
- //mxDesktop->terminate();
- //uno::Reference< lang::XComponent>(m_xContext, UNO_QUERY_THROW)->dispose();
- }
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ScXSpreadsheets2);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */