summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2016-09-16 12:36:06 +0200
committerMarco Cecchetti <mrcekets@gmail.com>2016-10-03 12:05:59 +0000
commitf5ed92549b9f113cbe252820a01a098b2b9d65ab (patch)
tree56ac9776c3d506ab77c0137e9e8f1d39de93f94e
parent348dcf1edb1a45027b52ba1e6f15bbf4d484a2c5 (diff)
LOK - when a view is enabled, the existing edit views are killed
A view is notified about killing its own edit view, if any, in 4 cases: - before being deactivated - soon after being activated - when a 'cursor position changed' event occurs in any view - when a 'selection changed' event occurs in any view Now these notifications are skipped when LOK is active. Change-Id: I94020987a35b1450ec41e2fa5fcce8cfa7e92130 Reviewed-on: https://gerrit.libreoffice.org/28948 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
-rw-r--r--sc/inc/scmod.hxx2
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx53
-rw-r--r--sc/source/ui/app/scmod.cxx5
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx3
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx22
-rw-r--r--sc/source/ui/view/tabvwsh5.cxx11
6 files changed, 88 insertions, 8 deletions
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index 851ffbe0cf96..07b38c8a7a3a 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -208,7 +208,7 @@ public:
ScInputHandler* GetRefInputHdl() { return pRefInputHandler;}
void ViewShellGone(ScTabViewShell* pViewSh);
- void ViewShellChanged();
+ void ViewShellChanged(bool bStopEditing = true);
// communication with function-autopilot
void InputGetSelection( sal_Int32& rStart, sal_Int32& rEnd );
void InputSetSelection( sal_Int32 nStart, sal_Int32 nEnd );
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 63175fe75759..a39db6ea2206 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -63,6 +63,7 @@ public:
void testColRowResize();
void testUndoShells();
void testCreateViewGraphicSelection();
+ void testTextEditViews();
void testGraphicInvalidate();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
@@ -78,6 +79,7 @@ public:
CPPUNIT_TEST(testColRowResize);
CPPUNIT_TEST(testUndoShells);
CPPUNIT_TEST(testCreateViewGraphicSelection);
+ CPPUNIT_TEST(testTextEditViews);
CPPUNIT_TEST(testGraphicInvalidate);
CPPUNIT_TEST_SUITE_END();
@@ -639,6 +641,57 @@ void ScTiledRenderingTest::testUndoShells()
comphelper::LibreOfficeKit::setActive(false);
}
+bool lcl_hasEditView(ScViewData& rViewData)
+{
+ bool bResult = false;
+ for (unsigned int i=0; i<4; i++)
+ {
+ bResult = rViewData.HasEditView( (ScSplitPos) i );
+ if (bResult) break;
+ }
+ return bResult;
+}
+
+void ScTiledRenderingTest::testTextEditViews()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ ScModelObj* pModelObj = createDoc("small.ods");
+ CPPUNIT_ASSERT(pModelObj);
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ CPPUNIT_ASSERT(pViewData);
+
+ // view #1
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ CPPUNIT_ASSERT(!lcl_hasEditView(*pViewData));
+
+ // text edit a cell in view #1
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT(lcl_hasEditView(*pViewData));
+
+ // view #2
+ SfxLokHelper::createView();
+ ViewCallback aView2;
+ pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+
+ // move cell cursor i view #2
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN);
+ Scheduler::ProcessEventsToIdle();
+
+ // check that text edit view in view #1 has not be killed
+ CPPUNIT_ASSERT(lcl_hasEditView(*pViewData));
+
+ mxComponent->dispose();
+ mxComponent.clear();
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
void ScTiledRenderingTest::testCreateViewGraphicSelection()
{
// Load a document
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 8b0e101f45fb..561ff2bfea95 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -20,6 +20,7 @@
#include <config_features.h>
#include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
+#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
#include "scitems.hxx"
@@ -1369,12 +1370,12 @@ ScInputHandler* ScModule::GetInputHdl( ScTabViewShell* pViewSh, bool bUseRef )
return pHdl;
}
-void ScModule::ViewShellChanged()
+void ScModule::ViewShellChanged(bool bStopEditing /*=true*/)
{
ScInputHandler* pHdl = GetInputHdl();
ScTabViewShell* pShell = ScTabViewShell::GetActiveViewShell();
if ( pShell && pHdl )
- pShell->UpdateInputHandler();
+ pShell->UpdateInputHandler(false, bStopEditing);
}
void ScModule::SetInputMode( ScInputMode eMode, const OUString* pInitText )
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index dd05b4c8110d..5fec291467e2 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -155,6 +155,9 @@ private:
bool bForceFocusOnCurCell; // #i123629#
+ bool bInPrepareClose;
+ bool bInDispose;
+
ScRangeListRef aChartSource;
Rectangle aChartPos;
SCTAB nChartDestTab;
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index c4ff1faf96e9..c82210680f0a 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -99,11 +99,20 @@
#include <com/sun/star/chart2/XChartType.hpp>
#include <sfx2/lokhelper.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <comphelper/lok.hxx>
extern SfxViewShell* pScActiveViewShell; // global.cxx
using namespace com::sun::star;
+struct BoolLock
+{
+ bool& mflag;
+ explicit BoolLock( bool& flag ) : mflag(flag)
+ { mflag = true; }
+ ~BoolLock() { mflag = false; }
+};
+
void ScTabViewShell::Activate(bool bMDI)
{
SfxViewShell::Activate(bMDI);
@@ -114,7 +123,7 @@ void ScTabViewShell::Activate(bool bMDI)
{
// for input row (ClearCache)
ScModule* pScMod = SC_MOD();
- pScMod->ViewShellChanged();
+ pScMod->ViewShellChanged(/*bStopEditing=*/ !comphelper::LibreOfficeKit::isActive());
ActivateView( true, bFirstActivate );
@@ -154,7 +163,7 @@ void ScTabViewShell::Activate(bool bMDI)
}
}
- UpdateInputHandler( true );
+ UpdateInputHandler( /*bForce=*/ true, /*bStopEditing=*/ !comphelper::LibreOfficeKit::isActive() );
if ( bFirstActivate )
{
@@ -237,7 +246,7 @@ void ScTabViewShell::Deactivate(bool bMDI)
bIsActive = false;
ScInputHandler* pHdl = SC_MOD()->GetInputHdl(this);
- if( bMDI )
+ if( bMDI && !comphelper::LibreOfficeKit::isActive())
{
// during shell deactivation, shells must not be switched, or the loop
// through the shell stack (in SfxDispatcher::DoDeactivate_Impl) will not work
@@ -275,12 +284,15 @@ void ScTabViewShell::SetActive()
bool ScTabViewShell::PrepareClose(bool bUI)
{
+ BoolLock aBoolLock(bInPrepareClose);
// Call EnterHandler even in formula mode here,
// so a formula change in an embedded object isn't lost
// (ScDocShell::PrepareClose isn't called then).
ScInputHandler* pHdl = SC_MOD()->GetInputHdl( this );
if ( pHdl && pHdl->IsInputMode() )
+ {
pHdl->EnterHandler();
+ }
// draw text edit mode must be closed
FuPoor* pPoor = GetDrawFuncPtr();
@@ -1669,6 +1681,8 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
bInFormatDialog(false),
bReadOnly(false),
bForceFocusOnCurCell(false),
+ bInPrepareClose(false),
+ bInDispose(false),
nCurRefDlgId(0),
pAccessibilityBroadcaster(nullptr),
mbInSwitch(false)
@@ -1737,6 +1751,8 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
ScTabViewShell::~ScTabViewShell()
{
+ bInDispose = true;
+
// Notify other LOK views that we are going away.
SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", "false");
SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", "");
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index 855c66053d18..f46bbbfa9868 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -19,6 +19,7 @@
#include "scitems.hxx"
#include <svl/hint.hxx>
+#include <comphelper/lok.hxx>
#include <svl/zforlist.hxx>
#include <svx/numfmtsh.hxx>
#include <svx/numinf.hxx>
@@ -235,8 +236,14 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
case FID_KILLEDITVIEW:
case FID_KILLEDITVIEW_NOPAINT:
- StopEditShell();
- KillEditView( nSlot == FID_KILLEDITVIEW_NOPAINT );
+ if (!comphelper::LibreOfficeKit::isActive()
+ || this == SfxViewShell::Current()
+ || bInPrepareClose
+ || bInDispose)
+ {
+ StopEditShell();
+ KillEditView( nSlot == FID_KILLEDITVIEW_NOPAINT );
+ }
break;
case SFX_HINT_DOCCHANGED: