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/43035 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
committed by
Julien Nabet
parent
3dde9d988f
commit
52f2e70c9e
@@ -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,
|
||||
|
@@ -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)
|
||||
|
@@ -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 );
|
||||
|
@@ -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()
|
||||
|
@@ -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
|
||||
(
|
||||
|
Reference in New Issue
Block a user