tdf#163962 Enable spell checking in editable sections in read-only mode
[LibreOffice.git] / sc / qa / unit / tiledrendering / tiledrendering2.cxx
blob6e8ce9ea9defd80712b4b7cc17350ef28fac34d8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "tiledrenderingmodeltestbase.cxx"
12 #include <com/sun/star/datatransfer/XTransferable2.hpp>
14 #include <vcl/scheduler.hxx>
15 #include <comphelper/propertyvalue.hxx>
17 using namespace com::sun::star;
19 CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testSidebarLocale)
21 ScModelObj* pModelObj = createDoc("chart.ods");
22 int nView1 = SfxLokHelper::getView();
23 ViewCallback aView1;
24 SfxViewShell* pView1 = SfxViewShell::Current();
25 pView1->SetLOKLocale(u"en-US"_ustr);
26 SfxLokHelper::createView();
27 ViewCallback aView2;
28 SfxViewShell* pView2 = SfxViewShell::Current();
29 pView2->SetLOKLocale(u"de-DE"_ustr);
30 TestLokCallbackWrapper::InitializeSidebar();
31 Scheduler::ProcessEventsToIdle();
32 aView2.m_aStateChanges.clear();
34 pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, /*x=*/1, /*y=*/1, /*count=*/2,
35 /*buttons=*/1, /*modifier=*/0);
36 pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, /*x=*/1, /*y=*/1, /*count=*/2,
37 /*buttons=*/1, /*modifier=*/0);
38 SfxLokHelper::setView(nView1);
39 Scheduler::ProcessEventsToIdle();
41 auto it = aView2.m_aStateChanges.find(".uno:Sidebar");
42 CPPUNIT_ASSERT(it != aView2.m_aStateChanges.end());
43 std::string aLocale = it->second.get<std::string>("locale");
44 CPPUNIT_ASSERT_EQUAL(std::string("de-DE"), aLocale);
47 CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testCopyMultiSelection)
49 // Given a document with A1 and A3 as selected cells:
50 ScModelObj* pModelObj = createDoc("multi-selection.ods");
51 ViewCallback aView1;
52 // Get the center of A3:
53 uno::Sequence<beans::PropertyValue> aPropertyValues = {
54 comphelper::makePropertyValue(u"ToPoint"_ustr, u"$A$3"_ustr),
56 dispatchCommand(mxComponent, u".uno:GoToCell"_ustr, aPropertyValues);
57 Point aPoint = aView1.m_aCellCursorBounds.Center();
58 // Go to A1:
59 aPropertyValues = {
60 comphelper::makePropertyValue(u"ToPoint"_ustr, u"$A$1"_ustr),
62 dispatchCommand(mxComponent, u".uno:GoToCell"_ustr, aPropertyValues);
63 // Ctrl-click on A3:
64 int nCtrl = KEY_MOD1;
65 pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aPoint.getX(), aPoint.getY(), 1,
66 MOUSE_LEFT, nCtrl);
68 // When getting the selection:
69 uno::Reference<datatransfer::XTransferable> xTransferable = pModelObj->getSelection();
71 // Make sure we get A1+A3 instead of an error:
72 CPPUNIT_ASSERT(xTransferable.is());
74 // Also make sure that just 2 cells is classified as a simple selection:
75 uno::Reference<datatransfer::XTransferable2> xTransferable2(xTransferable, uno::UNO_QUERY);
76 CPPUNIT_ASSERT(xTransferable2.is());
77 // Without the fix, the text selection was complex.
78 CPPUNIT_ASSERT(!xTransferable2->isComplex());
81 CPPUNIT_PLUGIN_IMPLEMENT();
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */