[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sc/qa sc/source
Henry Castro
hcastro at collabora.com
Tue May 15 09:24:11 UTC 2018
sc/qa/unit/tiledrendering/tiledrendering.cxx | 43 +++++++++++++++++++++++++++
sc/source/ui/app/scmod.cxx | 32 +++++++-------------
sc/source/ui/formdlg/formula.cxx | 6 +--
sc/source/ui/inc/anyrefdg.hxx | 4 +-
sc/source/ui/miscdlgs/anyrefdg.cxx | 32 ++++++++------------
5 files changed, 73 insertions(+), 44 deletions(-)
New commits:
commit ea7fba0ff338098dea5292557c418b7d8c8a100b
Author: Henry Castro <hcastro at collabora.com>
Date: Thu Mar 15 14:23:48 2018 -0400
lokdialog: do not lock events when opened ScFilter Dialog
When exists 2 or more views and one of the views open the ScFilter dialog,
the other views are locked and no event process.
In tiled rendering case, collaborative editing is not functional with 2 or
more views are locked, so the patch prevents locking the other views
Change-Id: I0133d38ac5ecef4d3ebc22f3e922602704dcd0b3
Reviewed-on: https://gerrit.libreoffice.org/51370
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Henry Castro <hcastro at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/51437
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 2bb0c660ff69..bcd687a77599 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -30,9 +30,11 @@
#include <comphelper/lok.hxx>
#include <comphelper/propertyvalue.hxx>
+#include <sfx2/childwin.hxx>
#include <sfx2/lokhelper.hxx>
#include <svx/svdpage.hxx>
#include <vcl/vclevent.hxx>
+#include <sc.hrc>
#include <chrono>
#include <tabvwsh.hxx>
@@ -83,6 +85,7 @@ public:
void testLanguageStatus();
void testMultiViewCopyPaste();
void testIMESupport();
+ void testFilterDlg();
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
CPPUNIT_TEST(testRowColumnSelections);
@@ -114,6 +117,7 @@ public:
CPPUNIT_TEST(testLanguageStatus);
CPPUNIT_TEST(testMultiViewCopyPaste);
CPPUNIT_TEST(testIMESupport);
+ CPPUNIT_TEST(testFilterDlg);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1599,6 +1603,45 @@ void ScTiledRenderingTest::testIMESupport()
comphelper::LibreOfficeKit::setActive(false);
}
+void ScTiledRenderingTest::testFilterDlg()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ createDoc("empty.ods");
+
+ // view #1
+ SfxViewShell* pView1 = SfxViewShell::Current();
+ int nView1 = SfxLokHelper::getView();
+
+ // view #2
+ SfxLokHelper::createView();
+ SfxViewShell* pView2 = SfxViewShell::Current();
+ CPPUNIT_ASSERT(pView1 != pView2);
+ {
+ pView2->GetViewFrame()->GetDispatcher()->Execute(SID_FILTER,
+ SfxCallMode::SLOT|SfxCallMode::RECORD);
+ }
+
+ Scheduler::ProcessEventsToIdle();
+ SfxChildWindow* pRefWindow = pView2->GetViewFrame()->GetChildWindow(SID_FILTER);
+ CPPUNIT_ASSERT(pRefWindow);
+
+ // switch to view 1
+ SfxLokHelper::setView(nView1);
+ CPPUNIT_ASSERT_EQUAL(true, pView2->GetViewFrame()->GetDispatcher()->IsLocked());
+ CPPUNIT_ASSERT_EQUAL(false, pView1->GetViewFrame()->GetDispatcher()->IsLocked());
+
+ KeyEvent aEvent(27, KEY_ESCAPE, 0);
+ Application::PostKeyEvent(VclEventId::WindowKeyInput, pRefWindow->GetWindow(), &aEvent);
+ Application::PostKeyEvent(VclEventId::WindowKeyUp, pRefWindow->GetWindow(), &aEvent);
+
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT_EQUAL(false, pView2->GetViewFrame()->GetDispatcher()->IsLocked());
+ CPPUNIT_ASSERT_EQUAL(false, pView1->GetViewFrame()->GetDispatcher()->IsLocked());
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index bc2dcead5f30..18aa66f00456 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1554,20 +1554,25 @@ void ScModule::SetRefDialog( sal_uInt16 nId, bool bVis, SfxViewFrame* pViewFrm )
}
}
-static SfxChildWindow* lcl_GetChildWinFromAnyView( sal_uInt16 nId )
+static inline SfxChildWindow* lcl_GetChildWinFromCurrentView( sal_uInt16 nId )
{
- // First, try the current view
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
// #i46999# current view frame can be null (for example, when closing help)
- SfxChildWindow* pChildWnd = pViewFrm ? pViewFrm->GetChildWindow( nId ) : nullptr;
+ return pViewFrm ? pViewFrm->GetChildWindow( nId ) : nullptr;
+}
+
+static SfxChildWindow* lcl_GetChildWinFromAnyView( sal_uInt16 nId )
+{
+ // First, try the current view
+ SfxChildWindow* pChildWnd = lcl_GetChildWinFromCurrentView( nId );
if ( pChildWnd )
return pChildWnd; // found in the current view
// if not found there, get the child window from any open view
// it can be open only in one view because nCurRefDlgId is global
- pViewFrm = SfxViewFrame::GetFirst();
+ SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst();
while ( pViewFrm )
{
pChildWnd = pViewFrm->GetChildWindow( nId );
@@ -1588,7 +1593,7 @@ bool ScModule::IsModalMode(SfxObjectShell* pDocSh)
if ( nCurRefDlgId )
{
- SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+ SfxChildWindow* pChildWnd = lcl_GetChildWinFromCurrentView( nCurRefDlgId );
if ( pChildWnd )
{
IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
@@ -1596,15 +1601,6 @@ bool ScModule::IsModalMode(SfxObjectShell* pDocSh)
bIsModal = pChildWnd->IsVisible() && pRefDlg &&
!( pRefDlg->IsRefInputMode() && pRefDlg->IsDocAllowed(pDocSh) );
}
- else
- {
- // in 592 and above, the dialog isn't visible in other views
- // if the dialog is open but can't be accessed, disable input
- bIsModal = true;
- }
-
- // pChildWnd can be 0 if the dialog has not been created by another Shell yet after
- // switching over(e.g. in GetFocus())
}
else if (pDocSh)
{
@@ -1650,11 +1646,9 @@ bool ScModule::IsRefDialogOpen()
if ( nCurRefDlgId )
{
- SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+ SfxChildWindow* pChildWnd = lcl_GetChildWinFromCurrentView( nCurRefDlgId );
if ( pChildWnd )
bIsOpen = pChildWnd->IsVisible();
- else
- bIsOpen = true; // for other views, see IsModalMode
}
return bIsOpen;
@@ -1674,15 +1668,13 @@ bool ScModule::IsFormulaMode()
if ( nCurRefDlgId )
{
- SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+ SfxChildWindow* pChildWnd = lcl_GetChildWinFromCurrentView( nCurRefDlgId );
if ( pChildWnd )
{
IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
assert(pRefDlg);
bIsFormula = pChildWnd->IsVisible() && pRefDlg && pRefDlg->IsRefInputMode();
}
- else
- bIsFormula = true;
}
else
{
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index 22faa17f9cbc..e63a464a9075 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -108,7 +108,7 @@ ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
ScFormulaReferenceHelper::enableInput( true );
ScFormulaReferenceHelper::EnableSpreadsheets();
m_aHelper.Init();
- ScFormulaReferenceHelper::SetDispatcherLock( true );
+ m_aHelper.SetDispatcherLock( true );
notifyChange();
fill();
@@ -528,7 +528,7 @@ void ScFormulaDlg::dispatch(bool _bOK, bool _bMatrixChecked)
if ( aStrItem.GetValue().isEmpty() )
aRetItem.SetValue( false ); // sal_False = Cancel
- ScFormulaReferenceHelper::SetDispatcherLock( false ); // turn off modal-mode
+ m_aHelper.SetDispatcherLock( false ); // turn off modal-mode
clear();
@@ -538,7 +538,7 @@ void ScFormulaDlg::dispatch(bool _bOK, bool _bMatrixChecked)
}
void ScFormulaDlg::setDispatcherLock( bool bLock )
{
- ScFormulaReferenceHelper::SetDispatcherLock( bLock );
+ m_aHelper.SetDispatcherLock( bLock );
}
void ScFormulaDlg::deleteFormData()
{
diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx
index 963036a1d7ef..8eb1adc9f708 100644
--- a/sc/source/ui/inc/anyrefdg.hxx
+++ b/sc/source/ui/inc/anyrefdg.hxx
@@ -90,7 +90,7 @@ public:
inline void SetWindow(vcl::Window* _pWindow) { m_pWindow = _pWindow; }
void DoClose( sal_uInt16 nId );
- static void SetDispatcherLock( bool bLock );
+ void SetDispatcherLock( bool bLock );
static void EnableSpreadsheets( bool bFlag = true );
static void ViewShellChanged();
@@ -126,7 +126,7 @@ protected:
void disposeRefHandler();
bool DoClose( sal_uInt16 nId );
- static void SetDispatcherLock( bool bLock );
+ void SetDispatcherLock( bool bLock );
virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = nullptr ) override;
virtual void RefInputDone( bool bForced = false ) override;
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 48a3449fb6f3..3d441376d370 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -650,26 +650,20 @@ void ScFormulaReferenceHelper::DoClose( sal_uInt16 nId )
void ScFormulaReferenceHelper::SetDispatcherLock( bool bLock )
{
- // lock / unlock only the dispatchers of Calc documents
-
- ScDocShell* pDocShell = static_cast<ScDocShell*>(SfxObjectShell::GetFirst(checkSfxObjectShell<ScDocShell>));
- while( pDocShell )
+ // lock / unlock only the dispatcher of Calc document
+ SfxDispatcher* pDisp = nullptr;
+ if ( m_pBindings )
{
- SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
- while( pFrame )
- {
- SfxDispatcher* pDisp = pFrame->GetDispatcher();
- if (pDisp)
- pDisp->Lock( bLock );
-
- pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
- }
- pDocShell = static_cast<ScDocShell*>(SfxObjectShell::GetNext(*pDocShell, checkSfxObjectShell<ScDocShell>));
+ pDisp = m_pBindings->GetDispatcher();
+ }
+ else if(SfxViewFrame* pViewFrame = SfxViewFrame::Current())
+ {
+ if (dynamic_cast< ScTabViewShell* >(pViewFrame->GetViewShell()))
+ pDisp = pViewFrame->GetDispatcher();
}
- // if a new view is created while the dialog is open,
- // that view's dispatcher is locked when trying to create the dialog
- // for that view (ScTabViewShell::CreateRefDialog)
+ if (pDisp)
+ pDisp->Lock(bLock);
}
void ScFormulaReferenceHelper::ViewShellChanged()
@@ -815,7 +809,7 @@ bool ScRefHandler::EnterRefMode()
m_aHelper.Init();
- ScFormulaReferenceHelper::SetDispatcherLock( true );
+ m_aHelper.SetDispatcherLock( true );
return m_bInRefMode = true;
}
@@ -904,7 +898,7 @@ bool ScRefHandler::DoClose( sal_uInt16 nId )
void ScRefHandler::SetDispatcherLock( bool bLock )
{
- ScFormulaReferenceHelper::SetDispatcherLock( bLock );
+ m_aHelper.SetDispatcherLock( bLock );
}
void ScRefHandler::ViewShellChanged()
More information about the Libreoffice-commits
mailing list