[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - include/sfx2 sc/source sfx2/source
Marco Cecchetti
marco.cecchetti at collabora.com
Tue Oct 3 12:14:31 UTC 2017
include/sfx2/viewsh.hxx | 1 +
sc/source/ui/app/inputhdl.cxx | 12 ++++++++++++
sc/source/ui/app/scmod.cxx | 6 ++++++
sc/source/ui/view/tabvwsh4.cxx | 26 ++++++++++++++++++++++++++
sfx2/source/view/viewsh.cxx | 31 +++++++++++++++++++++++++++++++
5 files changed, 76 insertions(+)
New commits:
commit c7d2de2905d53d12b186f577260fd95460f4eea5
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Sat Sep 30 17:51:26 2017 +0200
lok: temporary workaround: disable formula mode for online
- Start empty spreadsheet, open it with two users (let's call them A &
B).
- Type "=" with user A.
- Start moving around to different cells with user B.
=> Cell name of user B's selected cell is entered in user A's formula.
This is due to the fact that ScModel::GetInputHandler() returns always
the input handler which is handling the edited formula and not the
input handler of the current view.
That really messes up collaborative editing, so better to disable it,
until we implement an alternative solution.
Change-Id: I6e779cba3f377d12b7a4a19a6ee53c924fc9ba20
Reviewed-on: https://gerrit.libreoffice.org/43036
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 073b9c9259e2..1bcb64f05c7c 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -170,6 +170,7 @@ protected:
public:
// Iteration
+ static size_t GetActiveShells( bool bOnlyVisible = true );
static SfxViewShell* GetFirst( bool bOnlyVisible = true, const std::function<bool ( const SfxViewShell* )>& isViewShell = nullptr );
static SfxViewShell* GetNext( const SfxViewShell& rPrev,
bool bOnlyVisible = true,
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index c2cb9d751ec4..5c2a6112025f 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2360,6 +2360,18 @@ void ScInputHandler::UpdateFormulaMode()
(rText[0] == '=' || rText[0] == '+' || rText[0] == '-');
}
+ // formula mode in online is not usable in collaborative mode,
+ // this is a workaround for disabling formula mode in online
+ // when there is more than a single view
+ if (comphelper::LibreOfficeKit::isActive()
+ && SfxViewShell::GetActiveShells(/*only visible shells*/ false) > 1)
+ {
+ // we look for not visible shells, too, since this method can be
+ // invoked by a TabViewShell ctor and at such a stage the view
+ // is not yet visible,
+ bIsFormula = false;
+ }
+
if ( bIsFormula )
{
if (!bFormulaMode)
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index bfbe59d72710..444fd7e1aa74 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1670,6 +1670,12 @@ bool ScModule::IsFormulaMode()
// Just keep function autopilot here for references to other documents
bool bIsFormula = false;
+ // formula mode in online is not usable in collaborative mode,
+ // this is a workaround for disabling formula mode in online
+ // when there is more than a single view
+ if (comphelper::LibreOfficeKit::isActive() && SfxViewShell::GetActiveShells() > 1)
+ return false;
+
if ( nCurRefDlgId )
{
SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 058dbb2d953b..74a3e0cc2503 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1744,6 +1744,32 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
//put things back as we found them
if (bInstalledScTabViewObjAsTempController)
GetViewData().GetDocShell()->GetModel()->setCurrentController(nullptr);
+
+ // formula mode in online is not usable in collaborative mode,
+ // this is a workaround for disabling formula mode in online
+ // when there is more than a single view
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+ // have we already one view ?
+ if (pViewShell)
+ {
+ // this view is not yet visible at this stage, so we look for not visible views, too
+ SfxViewShell* pViewShell2 = SfxViewShell::GetNext(*pViewShell, /*only visible shells*/ false);
+ // if the second view is not this one, it means that there is
+ // already more than one active view and so the formula mode
+ // has already been disabled
+ if (pViewShell2 && pViewShell2 == this)
+ {
+ ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
+ ScInputHandler* pInputHdl = pTabViewShell->GetInputHandler();
+ if (pInputHdl && pInputHdl->IsFormulaMode())
+ {
+ pInputHdl->SetMode(SC_INPUT_NONE);
+ }
+ }
+ }
+ }
}
ScTabViewShell::~ScTabViewShell()
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index e763676167d6..25278f8bd2bf 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1333,6 +1333,37 @@ void SfxViewShell::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue
}
+// returns the number of current available shells of spec. type viewing the specified doc.
+size_t SfxViewShell::GetActiveShells ( bool bOnlyVisible )
+{
+ size_t nShells = 0;
+
+ // search for a SfxViewShell of the specified type
+ SfxViewShellArr_Impl &rShells = SfxGetpApp()->GetViewShells_Impl();
+ SfxViewFrameArr_Impl &rFrames = SfxGetpApp()->GetViewFrames_Impl();
+ for (SfxViewShell* pShell : rShells)
+ {
+ if ( pShell )
+ {
+ // sometimes dangling SfxViewShells exist that point to a dead SfxViewFrame
+ // these ViewShells shouldn't be accessible anymore
+ // a destroyed ViewFrame is not in the ViewFrame array anymore, so checking this array helps
+ for (SfxViewFrame* pFrame : rFrames)
+ {
+ if ( pFrame == pShell->GetViewFrame() )
+ {
+ // only ViewShells with a valid ViewFrame will be returned
+ if ( !bOnlyVisible || pFrame->IsVisible() )
+ ++nShells;
+ }
+ }
+ }
+ }
+
+ return nShells;
+}
+
+
// returns the first shell of spec. type viewing the specified doc.
SfxViewShell* SfxViewShell::GetFirst
(
More information about the Libreoffice-commits
mailing list