[Libreoffice-commits] .: 2 commits - sc/CppunitTest_sc_datapilotdescriptorbase.mk sc/qa sfx2/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Sun Jan 15 23:47:39 PST 2012
sc/CppunitTest_sc_datapilotdescriptorbase.mk | 1
sc/qa/extras/xdatapilottable.cxx | 151 +++++++++++++++++++++++++++
sfx2/source/doc/docfile.cxx | 23 ----
3 files changed, 154 insertions(+), 21 deletions(-)
New commits:
commit 84c9a4d5518fd2a986e09af50b72553214a24902
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon Jan 16 08:44:23 2012 +0100
e the new way to access the config
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index d2089b2..b030d4e 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -137,6 +137,7 @@ using namespace ::com::sun::star::io;
#include "sfx2/sfxresid.hxx"
#include <sfx2/appuno.hxx>
#include "sfxacldetect.hxx"
+#include "officecfg/Office/Common.hxx"
#define MAX_REDIRECT 5
@@ -204,27 +205,7 @@ sal_Bool IsOOoLockFileUsed()
bool IsLockingUsed()
{
- bool bLocking = true;
- try
- {
-
- uno::Reference< uno::XInterface > xCommonConfig = ::comphelper::ConfigurationHelper::openConfig(
- ::comphelper::getProcessServiceFactory(),
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common" ) ),
- ::comphelper::ConfigurationHelper::E_STANDARD );
- if ( !xCommonConfig.is() )
- throw uno::RuntimeException();
-
- ::comphelper::ConfigurationHelper::readRelativeKey(
- xCommonConfig,
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Misc/" ) ),
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseLocking" ) ) ) >>= bLocking;
- }
- catch( const uno::Exception& )
- {
- }
-
- return bLocking;
+ return officecfg::Office::Common::Misc::UseLocking::get(comphelper::getProcessComponentContext());
}
} // anonymous namespace
commit 9fb5c5d69e8db855d0414bdbe60285cbfe59d705
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Jan 15 05:35:30 2012 +0100
add test for sheet::XDataPilotTable
diff --git a/sc/CppunitTest_sc_datapilotdescriptorbase.mk b/sc/CppunitTest_sc_datapilotdescriptorbase.mk
index 32a4553..954cd6d 100644
--- a/sc/CppunitTest_sc_datapilotdescriptorbase.mk
+++ b/sc/CppunitTest_sc_datapilotdescriptorbase.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sc_datapilotdescriptorbase))
$(eval $(call gb_CppunitTest_add_exception_objects,sc_datapilotdescriptorbase, \
sc/qa/extras/xdatapilotdescriptor \
+ sc/qa/extras/xdatapilottable \
))
$(eval $(call gb_CppunitTest_add_linked_libs,sc_datapilotdescriptorbase, \
diff --git a/sc/qa/extras/xdatapilottable.cxx b/sc/qa/extras/xdatapilottable.cxx
new file mode 100644
index 0000000..c9d3ab9
--- /dev/null
+++ b/sc/qa/extras/xdatapilottable.cxx
@@ -0,0 +1,151 @@
+/* -*- 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 at 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/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
+{
+
+#define NUMBER_OF_TESTS 2
+
+class ScXDataPilotTable : public UnoApiTest
+{
+public:
+
+ virtual void setUp();
+ virtual void tearDown();
+
+ void testGetOutputRange();
+ void testRefresh();
+ CPPUNIT_TEST_SUITE(ScXDataPilotTable);
+ CPPUNIT_TEST(testGetOutputRange);
+ CPPUNIT_TEST(testRefresh);
+ CPPUNIT_TEST_SUITE_END();
+private:
+
+ uno::Reference< sheet::XDataPilotTable > init();
+
+ static int nTest;
+ static uno::Reference< lang::XComponent > xComponent;
+
+ static uno::Reference< table::XCell > xCellForChange;
+ static uno::Reference< table::XCell > xCellForCheck;
+};
+
+int ScXDataPilotTable::nTest = 0;
+uno::Reference< lang::XComponent > ScXDataPilotTable::xComponent;
+uno::Reference< table::XCell > ScXDataPilotTable::xCellForChange;
+uno::Reference< table::XCell > ScXDataPilotTable::xCellForCheck;
+
+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()
+{
+ 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);
+
+ // set variables
+ xCellForChange = xSheet->getCellByPosition( 1, 5 );
+ xCellForCheck = xSheet->getCellByPosition( 7, 11 );
+
+ 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);
+
+ CPPUNIT_ASSERT(xDPTable.is());
+ return xDPTable;
+}
+
+void ScXDataPilotTable::setUp()
+{
+ nTest += 1;
+ UnoApiTest::setUp();
+}
+
+void ScXDataPilotTable::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();
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list