summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2016-03-10 18:50:54 +0100
committerJan Holesovsky <kendy@collabora.com>2016-03-10 21:01:23 +0100
commit235136c17868627412db8dda148d3c4103907c0c (patch)
treecc2e1663078126cccd4c9cdc7b8c86e5a2c12983
parent83de4879c3cd416c423dd147be6511a1d074c8c9 (diff)
sc lok: Don't interact with the user during .uno:SortAscending or Descending.
Change-Id: Ib3679413ba59e86438dac83abfa9b624e291e5a9
-rw-r--r--sc/CppunitTest_sc_tiledrendering.mk62
-rw-r--r--sc/Module_sc.mk1
-rw-r--r--sc/qa/unit/tiledrendering/data/sort-range.odsbin0 -> 7930 bytes
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx191
-rw-r--r--sc/source/ui/view/cellsh2.cxx7
5 files changed, 259 insertions, 2 deletions
diff --git a/sc/CppunitTest_sc_tiledrendering.mk b/sc/CppunitTest_sc_tiledrendering.mk
new file mode 100644
index 000000000000..995cdc8a97fc
--- /dev/null
+++ b/sc/CppunitTest_sc_tiledrendering.mk
@@ -0,0 +1,62 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_tiledrendering))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_tiledrendering, \
+ sc/qa/unit/tiledrendering/tiledrendering \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_tiledrendering, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ editeng \
+ sal \
+ sfx \
+ svl \
+ svt \
+ svxcore \
+ sc \
+ scui \
+ test \
+ unotest \
+ vcl \
+ tl \
+ utl \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sc_tiledrendering,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_tiledrendering,\
+ -I$(SRCDIR)/sc/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sc_tiledrendering,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_tiledrendering))
+$(eval $(call gb_CppunitTest_use_vcl,sc_tiledrendering))
+
+$(eval $(call gb_CppunitTest_use_rdb,sc_tiledrendering,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_tiledrendering))
+
+$(call gb_CppunitTest_get_target,sc_tiledrendering) : $(call gb_AllLangResTarget_get_target,sc)
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index c8f9808e5775..a32e4ae34df2 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -45,6 +45,7 @@ $(eval $(call gb_Module_add_check_targets,sc,\
CppunitTest_sc_filters_test \
CppunitTest_sc_rangelst_test \
CppunitTest_sc_core \
+ CppunitTest_sc_tiledrendering \
))
$(eval $(call gb_Module_add_slowcheck_targets,sc, \
diff --git a/sc/qa/unit/tiledrendering/data/sort-range.ods b/sc/qa/unit/tiledrendering/data/sort-range.ods
new file mode 100644
index 000000000000..cd9e4e4019b0
--- /dev/null
+++ b/sc/qa/unit/tiledrendering/data/sort-range.ods
Binary files differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
new file mode 100644
index 000000000000..e5154d881127
--- /dev/null
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -0,0 +1,191 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+#include <test/xmltesttools.hxx>
+#include <boost/property_tree/json_parser.hpp>
+
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <comphelper/dispatchcommand.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/string.hxx>
+#include <editeng/editids.hrc>
+#include <editeng/editview.hxx>
+#include <editeng/outliner.hxx>
+#include <osl/conditn.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/srchitem.hxx>
+
+#include <comphelper/lok.hxx>
+
+#include <document.hxx>
+#include <docuno.hxx>
+
+using namespace css;
+
+#if !defined(WNT) && !defined(MACOSX)
+static const char* DATA_DIRECTORY = "/sc/qa/unit/tiledrendering/data/";
+#endif
+
+class ScTiledRenderingTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
+{
+public:
+ ScTiledRenderingTest();
+ virtual void setUp() SAL_OVERRIDE;
+ virtual void tearDown() SAL_OVERRIDE;
+
+#if !defined(WNT) && !defined(MACOSX)
+ void testSortAscendingDescending();
+#endif
+
+ CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
+#if !defined(WNT) && !defined(MACOSX)
+ CPPUNIT_TEST(testSortAscendingDescending);
+#endif
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+#if !defined(WNT) && !defined(MACOSX)
+ ScModelObj* createDoc(const char* pName);
+ static void callback(int nType, const char* pPayload, void* pData);
+ void callbackImpl(int nType, const char* pPayload);
+#endif
+
+ uno::Reference<lang::XComponent> mxComponent;
+#if !defined(WNT) && !defined(MACOSX)
+ // TODO various test-related members - when needed
+#endif
+};
+
+ScTiledRenderingTest::ScTiledRenderingTest()
+#if !defined(WNT) && !defined(MACOSX)
+ // TODO various test-related members - when needed
+#endif
+{
+}
+
+void ScTiledRenderingTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
+}
+
+void ScTiledRenderingTest::tearDown()
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ test::BootstrapFixture::tearDown();
+}
+
+#if !defined(WNT) && !defined(MACOSX)
+ScModelObj* ScTiledRenderingTest::createDoc(const char* pName)
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+ mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + OUString::createFromAscii(pName), "com.sun.star.sheet.SpreadsheetDocument");
+ ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
+ CPPUNIT_ASSERT(pModelObj);
+ pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+ return pModelObj;
+}
+
+void ScTiledRenderingTest::callback(int nType, const char* pPayload, void* pData)
+{
+ static_cast<ScTiledRenderingTest*>(pData)->callbackImpl(nType, pPayload);
+}
+
+/* TODO when needed...
+static std::vector<OUString> lcl_convertSeparated(const OUString& rString, sal_Unicode nSeparator)
+{
+ std::vector<OUString> aRet;
+
+ sal_Int32 nIndex = 0;
+ do
+ {
+ OUString aToken = rString.getToken(0, nSeparator, nIndex);
+ aToken = aToken.trim();
+ if (!aToken.isEmpty())
+ aRet.push_back(aToken);
+ }
+ while (nIndex >= 0);
+
+ return aRet;
+}
+
+static void lcl_convertRectangle(const OUString& rString, Rectangle& rRectangle)
+{
+ uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(rString);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength());
+ rRectangle.setX(aSeq[0].toInt32());
+ rRectangle.setY(aSeq[1].toInt32());
+ rRectangle.setWidth(aSeq[2].toInt32());
+ rRectangle.setHeight(aSeq[3].toInt32());
+}
+*/
+
+void ScTiledRenderingTest::callbackImpl(int /*nType*/, const char* /*pPayload*/)
+{
+ // TODO when needed...
+ //switch (nType)
+ //{
+ //}
+}
+
+void ScTiledRenderingTest::testSortAscendingDescending()
+{
+ comphelper::LibreOfficeKit::setActive();
+ ScModelObj* pModelObj = createDoc("sort-range.ods");
+ ScDocument* pDoc = pModelObj->GetDocument();
+
+ // select the values in the first column
+ pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, 551, 129, 1);
+ pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEMOVE, 820, 1336, 1);
+ pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, 820, 1359, 1);
+
+ // sort ascending
+ uno::Sequence<beans::PropertyValue> aArgs;
+ comphelper::dispatchCommand(".uno:SortAscending", aArgs);
+
+ // check it's sorted
+ for (SCROW r = 0; r < 6; ++r)
+ {
+ CPPUNIT_ASSERT_EQUAL(double(r + 1), pDoc->GetValue(ScAddress(0, r, 0)));
+ }
+
+ // sort descending
+ comphelper::dispatchCommand(".uno:SortDescending", aArgs);
+
+ // check it's sorted
+ for (SCROW r = 0; r < 6; ++r)
+ {
+ CPPUNIT_ASSERT_EQUAL(double(6 - r), pDoc->GetValue(ScAddress(0, r, 0)));
+ }
+
+ // nothing else was sorted
+ CPPUNIT_ASSERT_EQUAL(double(1), pDoc->GetValue(ScAddress(1, 0, 0)));
+ CPPUNIT_ASSERT_EQUAL(double(3), pDoc->GetValue(ScAddress(1, 1, 0)));
+ CPPUNIT_ASSERT_EQUAL(double(2), pDoc->GetValue(ScAddress(1, 2, 0)));
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
+#endif
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 1ab82abb7c3d..789f29763320 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -20,6 +20,7 @@
#include <config_features.h>
#include "scitems.hxx"
+#include <comphelper/lok.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/app.hxx>
#include <sfx2/request.hxx>
@@ -165,8 +166,10 @@ static bool lcl_GetSortParam( const ScViewData* pData, ScSortParam& rSortParam )
aExternalRange.aEnd.SetRow( nEndRow );
aExternalRange.aEnd.SetCol( nEndCol );
- if(( rSortParam.nCol1 == rSortParam.nCol2 && aExternalRange.aStart.Col() != aExternalRange.aEnd.Col() ) ||
- ( rSortParam.nRow1 == rSortParam.nRow2 && aExternalRange.aStart.Row() != aExternalRange.aEnd.Row() ) )
+ // with LibreOfficeKit, don't try to interact with the user
+ if (!comphelper::LibreOfficeKit::isActive() &&
+ ((rSortParam.nCol1 == rSortParam.nCol2 && aExternalRange.aStart.Col() != aExternalRange.aEnd.Col()) ||
+ (rSortParam.nRow1 == rSortParam.nRow2 && aExternalRange.aStart.Row() != aExternalRange.aEnd.Row())))
{
sal_uInt16 nFmt = SCA_VALID;