summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2020-06-02 12:46:51 +0300
committerTor Lillqvist <tml@collabora.com>2020-06-24 14:29:35 +0200
commit984bd2d5e4e1277cab47f8c1053bdf9369b23935 (patch)
tree986c3a846e7310218409533670716aa5b18c42f5 /sc
parent13bcb15f359d2c616cc375a160a5474b230a66ab (diff)
tdf#128502: Try to support multiple documents in LibreOfficeKit-using process
The LibreOfficeKit-specific code typically has assumed that all the "views" (SfxViewShell instances) are for the same document, because all LibreOfficeKit-based application processes (including the "kit" processes in Online and the iOS app) so far have only had one document open at a time. It is now possible to pass several document file names on the command line to gtktiledviewer and that is an easy way to demonstrate how badly it still works even with this patch. Introduce a unique numeric document id that is increased in the LibLODocument_Impl constructor. Add APIs to access that. When iterating over views, try to skip views that are not of the document visible in the "current" view, if we know what the "current" view is. Also add a couple of FIXMEs at places where it is a bit unclear (to me) whether it is correct to iterate over all views, or whether only views for the "current" document are what we would want. Change-Id: Id5ebb92a115723cdeb23907163d5b5f282016252 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95353 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97024 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx4
-rw-r--r--sc/source/ui/docshell/docsh4.cxx5
-rw-r--r--sc/source/ui/docshell/olinefun.cxx9
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx5
-rw-r--r--sc/source/ui/undo/undoblk.cxx8
-rw-r--r--sc/source/ui/undo/undodat.cxx10
-rw-r--r--sc/source/ui/view/dbfunc3.cxx7
-rw-r--r--sc/source/ui/view/gridwin.cxx5
-rw-r--r--sc/source/ui/view/gridwin4.cxx4
-rw-r--r--sc/source/ui/view/tabview4.cxx2
-rw-r--r--sc/source/ui/view/tabview5.cxx3
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx15
-rw-r--r--sc/source/ui/view/tabvwshc.cxx14
-rw-r--r--sc/source/ui/view/viewfun2.cxx4
-rw-r--r--sc/source/ui/view/viewfunc.cxx17
15 files changed, 62 insertions, 50 deletions
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 417c10dcd58a..27fb6ee9b692 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -629,7 +629,8 @@ bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
ScDocument& rDoc = rDocShell.GetDocument();
- if (ScTabViewShell::isAnyEditViewInRange(/*bColumns*/ false, rQueryParam.nRow1, rQueryParam.nRow2))
+ ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
+ if (pViewSh && ScTabViewShell::isAnyEditViewInRange(pViewSh, /*bColumns*/ false, rQueryParam.nRow1, rQueryParam.nRow2))
{
return false;
}
@@ -942,7 +943,6 @@ bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
pOld, bDoSize, pAdvSource ) );
}
- ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
{
// could there be horizontal autofilter ?
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 913e97d857c4..820a0bb66892 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -2520,10 +2520,13 @@ void ScDocShell::LOKCommentNotify(LOKCommentNotificationType nType, const ScDocu
boost::property_tree::write_json(aStream, aTree);
std::string aPayload = aStream.str();
+ ScViewData* pViewData = GetViewData();
+ SfxViewShell* pThisViewShell = ( pViewData ? pViewData->GetViewShell() : nullptr );
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str());
+ if (pThisViewShell == nullptr || pViewShell->GetDocId() == pThisViewShell->GetDocId())
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str());
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
diff --git a/sc/source/ui/docshell/olinefun.cxx b/sc/source/ui/docshell/olinefun.cxx
index c3da9c9fcf5d..8b99085ffd16 100644
--- a/sc/source/ui/docshell/olinefun.cxx
+++ b/sc/source/ui/docshell/olinefun.cxx
@@ -315,6 +315,7 @@ bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
bool bRecord, bool bPaint )
{
ScDocument& rDoc = rDocShell.GetDocument();
+ ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if (bRecord && !rDoc.IsUndoEnabled())
bRecord = false;
@@ -362,7 +363,7 @@ bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
sal_uInt16 nThisLevel = aIter.LastLevel();
bool bShow = (nThisLevel < nLevel);
- if (!bShow && ScTabViewShell::isAnyEditViewInRange(bColumns, nThisStart, nThisEnd))
+ if (!bShow && pViewSh && ScTabViewShell::isAnyEditViewInRange(pViewSh, bColumns, nThisStart, nThisEnd))
continue;
if (bShow) // enable
@@ -410,7 +411,6 @@ bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
rDoc.SetDrawPageSize(nTab);
rDoc.UpdatePageBreaks( nTab );
- ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
pViewSh->OnLOKShowHideColRow(bColumns, nStart - 1);
@@ -733,8 +733,8 @@ bool ScOutlineDocFunc::HideOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
SCCOLROW nStart = pEntry->GetStart();
SCCOLROW nEnd = pEntry->GetEnd();
-
- if (ScTabViewShell::isAnyEditViewInRange(bColumns, nStart, nEnd))
+ ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
+ if (pViewSh && ScTabViewShell::isAnyEditViewInRange(pViewSh, bColumns, nStart, nEnd))
return false;
// TODO undo can mess things up when another view is editing a cell in the range of group entry
@@ -775,7 +775,6 @@ bool ScOutlineDocFunc::HideOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
rDoc.InvalidatePageBreaks(nTab);
rDoc.UpdatePageBreaks( nTab );
- ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
pViewSh->OnLOKShowHideColRow(bColumns, nStart - 1);
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index bfdc447e8cbc..bf00763a42a1 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -390,9 +390,8 @@ public:
/// See SfxViewShell::NotifyCursor().
void NotifyCursor(SfxViewShell* pViewShell) const override;
/// Emits a LOK_CALLBACK_INVALIDATE_HEADER for all views whose current tab is equal to nCurrentTabIndex
- static void notifyAllViewsHeaderInvalidation(HeaderType eHeaderType, SCTAB nCurrentTabIndex);
- static void notifyAllViewsHeaderInvalidation(bool Columns, SCTAB nCurrentTabIndex);
- static bool isAnyEditViewInRange(bool bColumns, SCCOLROW nStart, SCCOLROW nEnd);
+ static void notifyAllViewsHeaderInvalidation(SfxViewShell* pForViewShell, HeaderType eHeaderType, SCTAB nCurrentTabIndex);
+ static bool isAnyEditViewInRange(SfxViewShell* pForViewShell, bool bColumns, SCCOLROW nStart, SCCOLROW nEnd);
css::uno::Reference<css::drawing::XShapes> getSelectedXShapes();
static css::uno::Reference<css::datatransfer::XTransferable2> GetClipData(vcl::Window* pWin);
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 7c07be1f45be..3484d7d2ad0e 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -275,10 +275,10 @@ void ScUndoInsertCells::DoChange( const bool bUndo )
if (comphelper::LibreOfficeKit::isActive())
{
if (eCmd == INS_INSCOLS_BEFORE || eCmd == INS_INSCOLS_AFTER || eCmd == INS_CELLSRIGHT)
- ScTabViewShell::notifyAllViewsHeaderInvalidation(COLUMN_HEADER, pViewShell->GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(pViewShell, COLUMN_HEADER, pViewShell->GetViewData().GetTabNo());
if (eCmd == INS_INSROWS_BEFORE || eCmd == INS_INSROWS_AFTER || eCmd == INS_CELLSDOWN)
- ScTabViewShell::notifyAllViewsHeaderInvalidation(ROW_HEADER, pViewShell->GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(pViewShell, ROW_HEADER, pViewShell->GetViewData().GetTabNo());
}
}
}
@@ -536,10 +536,10 @@ void ScUndoDeleteCells::DoChange( const bool bUndo )
if (comphelper::LibreOfficeKit::isActive())
{
if (eCmd == DelCellCmd::Cols || eCmd == DelCellCmd::CellsLeft)
- ScTabViewShell::notifyAllViewsHeaderInvalidation(COLUMN_HEADER, pViewShell->GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(pViewShell, COLUMN_HEADER, pViewShell->GetViewData().GetTabNo());
if (eCmd == DelCellCmd::Rows || eCmd == DelCellCmd::CellsUp)
- ScTabViewShell::notifyAllViewsHeaderInvalidation(ROW_HEADER, pViewShell->GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(pViewShell, ROW_HEADER, pViewShell->GetViewData().GetTabNo());
}
}
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index 34d9ffb32f52..6bb8f0f76566 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -179,7 +179,7 @@ void ScUndoMakeOutline::Undo()
pDocShell->PostPaint(0,0,nTab,rDoc.MaxCol(),rDoc.MaxRow(),nTab,PaintPartFlags::Grid|PaintPartFlags::Left|PaintPartFlags::Top|PaintPartFlags::Size);
- ScTabViewShell::notifyAllViewsHeaderInvalidation( bColumns, nTab );
+ ScTabViewShell::notifyAllViewsHeaderInvalidation( pViewShell, bColumns ? COLUMN_HEADER : ROW_HEADER, nTab );
EndUndo();
}
@@ -449,7 +449,7 @@ void ScUndoRemoveAllOutlines::Undo()
pDocShell->PostPaint(0,0,nTab,rDoc.MaxCol(),rDoc.MaxRow(),nTab,PaintPartFlags::Grid|PaintPartFlags::Left|PaintPartFlags::Top|PaintPartFlags::Size);
- ScTabViewShell::notifyAllViewsHeaderInvalidation(BOTH_HEADERS, nTab);
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(pViewShell, BOTH_HEADERS, nTab);
EndUndo();
}
@@ -733,13 +733,13 @@ OUString ScUndoQuery::GetComment() const
void ScUndoQuery::Undo()
{
- if (ScTabViewShell::isAnyEditViewInRange(/*bColumns*/ false, aQueryParam.nRow1, aQueryParam.nRow2))
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (ScTabViewShell::isAnyEditViewInRange(pViewShell, /*bColumns*/ false, aQueryParam.nRow1, aQueryParam.nRow2))
return;
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
- ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
bool bCopy = !aQueryParam.bInplace;
SCCOL nDestEndCol = 0;
@@ -814,7 +814,7 @@ void ScUndoQuery::Undo()
// invalidate cache positions and update cursor and selection
pViewShell->OnLOKShowHideColRow(/*bColumns*/ false, aQueryParam.nRow1 - 1);
- ScTabViewShell::notifyAllViewsHeaderInvalidation(ROW_HEADER, nTab);
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(pViewShell, ROW_HEADER, nTab);
// Paint
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index d25183400750..538e9102236b 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -93,7 +93,7 @@ void ScDBFunc::MakeOutline( bool bColumns, bool bRecord )
ScOutlineDocFunc aFunc(*pDocSh);
aFunc.MakeOutline( aRange, bColumns, bRecord, false );
- ScTabViewShell::notifyAllViewsHeaderInvalidation(bColumns, GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(GetViewData().GetViewShell(), bColumns ? COLUMN_HEADER : ROW_HEADER, GetViewData().GetTabNo());
}
else
ErrorMessage(STR_NOMULTISELECT);
@@ -110,7 +110,7 @@ void ScDBFunc::RemoveOutline( bool bColumns, bool bRecord )
ScOutlineDocFunc aFunc(*pDocSh);
aFunc.RemoveOutline( aRange, bColumns, bRecord, false );
- ScTabViewShell::notifyAllViewsHeaderInvalidation(bColumns, GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(GetViewData().GetViewShell(), bColumns ? COLUMN_HEADER : ROW_HEADER, GetViewData().GetTabNo());
}
else
ErrorMessage(STR_NOMULTISELECT);
@@ -2224,11 +2224,12 @@ void ScDBFunc::OnLOKShowHideColRow(bool bColumns, SCCOLROW nStart)
return;
SCTAB nCurrentTabIndex = GetViewData().GetTabNo();
+ SfxViewShell* pThisViewShell = GetViewData().GetViewShell();
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
- if (pTabViewShell)
+ if (pTabViewShell && pTabViewShell->GetDocId() == pThisViewShell->GetDocId())
{
if (bColumns)
pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex)->invalidateByIndex(nStart);
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 78489cd933b0..fb58c75c506a 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -840,7 +840,7 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
// Something went terribly wrong!
return;
- if (ScTabViewShell::isAnyEditViewInRange(/*bColumns*/ false, aParam.nRow1, aParam.nRow2))
+ if (ScTabViewShell::isAnyEditViewInRange(pViewData->GetViewShell(), /*bColumns*/ false, aParam.nRow1, aParam.nRow2))
return;
pEntry->bDoQuery = true;
@@ -5746,6 +5746,9 @@ void ScGridWindow::notifyKitCellViewCursor(const SfxViewShell* pForShell) const
{
ScTabViewShell* pViewShell = pViewData->GetViewShell();
+ if (pViewShell->GetDocId() != pForShell->GetDocId())
+ return;
+
OString aCursor("EMPTY");
if (mpOOCursors) // cf. getCellCursor above
{
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 7db9ed9a9485..4f4c64769d2d 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -334,7 +334,7 @@ void ScGridWindow::InvalidateLOKViewCursor(const tools::Rectangle& rCursorRect,
while (pViewShell)
{
- if (pViewShell != pThisViewShell)
+ if (pViewShell != pThisViewShell && pViewShell->GetDocId() == pThisViewShell->GetDocId())
{
ScTabViewShell* pOtherViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
if (pOtherViewShell)
@@ -953,7 +953,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI
while (pViewShell)
{
- if (pViewShell != pThisViewShell)
+ if (pViewShell != pThisViewShell && pViewShell->GetDocId() == pThisViewShell->GetDocId())
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
if (pTabViewShell)
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index 3cbd121fb10b..680c578ed7a9 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -391,7 +391,7 @@ static long lcl_GetScrollRange( SCCOLROW nDocEnd, SCCOLROW nPos, SCCOLROW nVis,
void ScTabView::UpdateScrollBars( HeaderType eHeaderType )
{
- ScTabViewShell::notifyAllViewsHeaderInvalidation(eHeaderType, GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(GetViewData().GetViewShell(), eHeaderType, GetViewData().GetTabNo());
long nDiff;
bool bTop = ( aViewData.GetVSplitMode() != SC_SPLIT_NONE );
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
index b075b748f0e3..e504cf231698 100644
--- a/sc/source/ui/view/tabview5.cxx
+++ b/sc/source/ui/view/tabview5.cxx
@@ -672,11 +672,12 @@ void ScTabView::OnLOKNoteStateChanged(const ScPostIt* pNote)
aInvalidRect.AdjustTop( -nBorderSize );
aInvalidRect.AdjustBottom( nBorderSize );
+ SfxViewShell* pCurrentViewShell = SfxViewShell::Current();
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
- if (pTabViewShell)
+ if (pTabViewShell && pViewShell->GetDocId() == pCurrentViewShell->GetDocId())
{
for (auto& pWin: pTabViewShell->pGridWin)
{
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 5dbcfa2d70e5..72e68c5e0514 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
@@ -126,6 +126,11 @@ void ScTabViewShell::Activate(bool bMDI)
SfxViewShell* pSh = SfxViewShell::GetFirst( true, checkSfxViewShell<ScTabViewShell> );
while ( pSh!=nullptr && pOldHdl!=nullptr)
{
+ // Hmm, what if pSh is a shell for a different document? But as this code
+ // does not seem to be LibreOfficeKit-specific, probably that doesn't
+ // happen, because having multiple documents open simultaneously has of
+ // course not been a problem at all in traditional desktop LibreOffice.
+ // (Unlike in a LibreOfficeKit-based process where it has been a problem.)
if (static_cast<ScTabViewShell*>(pSh)->GetInputHandler() == pOldHdl)
{
pOldHdl->ResetDelayTimer();
@@ -1691,8 +1696,12 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
// 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);
+ // this view is not yet visible at this stage, so we look for not visible views, too, for this same document
+ SfxViewShell* pViewShell2 = pViewShell;
+ do
+ {
+ pViewShell2 = SfxViewShell::GetNext(*pViewShell2, /*only visible shells*/ false);
+ } while (pViewShell2 && pViewShell2->GetDocId() != pViewShell->GetDocId());
// 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
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 37c33f8e2930..0b9de2044c9c 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -495,7 +495,7 @@ css::uno::Reference<css::datatransfer::XTransferable2> ScTabViewShell::GetClipDa
return xTransferable;
}
-void ScTabViewShell::notifyAllViewsHeaderInvalidation(HeaderType eHeaderType, SCTAB nCurrentTabIndex)
+void ScTabViewShell::notifyAllViewsHeaderInvalidation(SfxViewShell* pForViewShell, HeaderType eHeaderType, SCTAB nCurrentTabIndex)
{
if (comphelper::LibreOfficeKit::isActive())
{
@@ -518,7 +518,7 @@ void ScTabViewShell::notifyAllViewsHeaderInvalidation(HeaderType eHeaderType, SC
while (pViewShell)
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
- if (pTabViewShell && (nCurrentTabIndex == -1 || pTabViewShell->getPart() == nCurrentTabIndex))
+ if (pTabViewShell && pViewShell->GetDocId() == pForViewShell->GetDocId() && (nCurrentTabIndex == -1 || pTabViewShell->getPart() == nCurrentTabIndex))
{
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_HEADER, aPayload.getStr());
}
@@ -527,13 +527,7 @@ void ScTabViewShell::notifyAllViewsHeaderInvalidation(HeaderType eHeaderType, SC
}
}
-void ScTabViewShell::notifyAllViewsHeaderInvalidation(bool bColumns, SCTAB nCurrentTabIndex)
-{
- HeaderType eHeaderType = bColumns ? COLUMN_HEADER : ROW_HEADER;
- ScTabViewShell::notifyAllViewsHeaderInvalidation(eHeaderType, nCurrentTabIndex);
-}
-
-bool ScTabViewShell::isAnyEditViewInRange(bool bColumns, SCCOLROW nStart, SCCOLROW nEnd)
+bool ScTabViewShell::isAnyEditViewInRange(SfxViewShell* pForViewShell, bool bColumns, SCCOLROW nStart, SCCOLROW nEnd)
{
if (comphelper::LibreOfficeKit::isActive())
{
@@ -541,7 +535,7 @@ bool ScTabViewShell::isAnyEditViewInRange(bool bColumns, SCCOLROW nStart, SCCOLR
while (pViewShell)
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
- if (pTabViewShell)
+ if (pTabViewShell && pTabViewShell->GetDocId() == pForViewShell->GetDocId())
{
ScInputHandler* pInputHandler = pTabViewShell->GetInputHandler();
if (pInputHandler && pInputHandler->GetActiveView())
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 0ab2d088b0e7..d260cf519afb 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -175,7 +175,7 @@ bool ScViewFunc::AdjustBlockHeight( bool bPaint, ScMarkData* pMarkData )
pDocSh->UpdateOle(&GetViewData());
if (comphelper::LibreOfficeKit::isActive())
- ScTabViewShell::notifyAllViewsHeaderInvalidation(ROW_HEADER, GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(GetViewData().GetViewShell(), ROW_HEADER, GetViewData().GetTabNo());
return bAnyChanged;
}
@@ -224,7 +224,7 @@ bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow )
PaintPartFlags::Grid | PaintPartFlags::Left );
if (comphelper::LibreOfficeKit::isActive())
- ScTabViewShell::notifyAllViewsHeaderInvalidation(ROW_HEADER, GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(GetViewData().GetViewShell(), ROW_HEADER, GetViewData().GetTabNo());
return bChanged;
}
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 21d10fcd1726..90a90e92f528 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1472,11 +1472,12 @@ void ScViewFunc::OnLOKInsertDeleteColumn(SCCOL nStartCol, long nOffset)
return;
SCTAB nCurrentTabIndex = GetViewData().GetTabNo();
+ SfxViewShell* pCurrentViewShell = GetViewData().GetViewShell();
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
- if (pTabViewShell)
+ if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
{
pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex)->invalidateByIndex(nStartCol);
@@ -1527,11 +1528,12 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, long nOffset)
return;
SCTAB nCurrentTabIndex = GetViewData().GetTabNo();
+ SfxViewShell* pCurrentViewShell = GetViewData().GetViewShell();
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
- if (pTabViewShell)
+ if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
{
pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex)->invalidateByIndex(nStartRow);
@@ -1582,11 +1584,12 @@ void ScViewFunc::OnLOKSetWidthOrHeight(SCCOLROW nStart, bool bWidth)
return;
SCTAB nCurTab = GetViewData().GetTabNo();
+ SfxViewShell* pCurrentViewShell = GetViewData().GetViewShell();
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
- if (pTabViewShell)
+ if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId())
{
if (bWidth)
pTabViewShell->GetViewData().GetLOKWidthHelper(nCurTab)->invalidateByIndex(nStart);
@@ -1627,10 +1630,10 @@ bool ScViewFunc::InsertCells( InsCellCmd eCmd, bool bRecord, bool bPartOfPaste )
if (comphelper::LibreOfficeKit::isActive())
{
if (bInsertCols)
- ScTabViewShell::notifyAllViewsHeaderInvalidation(COLUMN_HEADER, GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(GetViewData().GetViewShell(), COLUMN_HEADER, GetViewData().GetTabNo());
if (bInsertRows)
- ScTabViewShell::notifyAllViewsHeaderInvalidation(ROW_HEADER, GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(GetViewData().GetViewShell(), ROW_HEADER, GetViewData().GetTabNo());
}
}
OUString aStartAddress = aRange.aStart.GetColRowString();
@@ -1705,10 +1708,10 @@ void ScViewFunc::DeleteCells( DelCellCmd eCmd )
if (comphelper::LibreOfficeKit::isActive())
{
if (eCmd == DelCellCmd::Cols)
- ScTabViewShell::notifyAllViewsHeaderInvalidation(COLUMN_HEADER, GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(GetViewData().GetViewShell(), COLUMN_HEADER, GetViewData().GetTabNo());
if (eCmd == DelCellCmd::Rows)
- ScTabViewShell::notifyAllViewsHeaderInvalidation(ROW_HEADER, GetViewData().GetTabNo());
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(GetViewData().GetViewShell(), ROW_HEADER, GetViewData().GetTabNo());
}
}
else