summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/viewsh.hxx1
-rw-r--r--sc/source/ui/app/inputhdl.cxx12
-rw-r--r--sc/source/ui/app/scmod.cxx6
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx26
-rw-r--r--sfx2/source/view/viewsh.cxx31
5 files changed, 76 insertions, 0 deletions
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index f186f8d4135a..d9467fb2aa47 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -168,6 +168,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 4d2036b2836f..aa5fec4e1a86 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2373,6 +2373,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 c45e5d649ba9..414c8567bb93 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1673,6 +1673,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 f222d8a51019..d1f40a7bd313 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1733,6 +1733,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 61a8d822a20c..107a27ba6899 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1308,6 +1308,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
(