diff options
author | Dennis Francis <dennisfrancis.in@gmail.com> | 2021-07-02 19:01:47 +0530 |
---|---|---|
committer | Dennis Francis <dennis.francis@collabora.com> | 2021-07-28 15:41:37 +0200 |
commit | c4bcdb3ec8952fd2a2838629702dd7a00e104f63 (patch) | |
tree | 5fba6fbab5709eb218f6de7aee871fec27b5c11e /sc | |
parent | cc7ff6d890ab2cacc7f0273039b15689dad5e0dd (diff) |
lok: sc: avoid crash on non existent tab view data
... when accessing position helpers.
Change-Id: Ia627a8c4ed30ad1f1c2333df00b656fe041f111e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119604
Tested-by: Jenkins
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/dbfunc3.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 16 |
4 files changed, 26 insertions, 9 deletions
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index f98350f0963c..2133ee93bd6e 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -170,7 +170,8 @@ bool ScDocFunc::AdjustRowHeight( const ScRange& rRange, bool bPaint, bool bApi ) ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell); if (pTabViewShell && pTabViewShell->GetDocId() == pSomeViewForThisDoc->GetDocId()) { - pTabViewShell->GetViewData().GetLOKHeightHelper(nTab)->invalidateByIndex(nStartRow); + if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nTab)) + pPosHelper->invalidateByIndex(nStartRow); } pViewShell = SfxViewShell::GetNext(*pViewShell); } diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index 15141c68a064..8258b52d6846 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -2290,9 +2290,15 @@ void ScDBFunc::OnLOKShowHideColRow(bool bColumns, SCCOLROW nStart) if (pTabViewShell && pTabViewShell->GetDocId() == pThisViewShell->GetDocId()) { if (bColumns) - pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex)->invalidateByIndex(nStart); + { + if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex)) + pPosHelper->invalidateByIndex(nStart); + } else - pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex)->invalidateByIndex(nStart); + { + if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex)) + pPosHelper->invalidateByIndex(nStart); + } if (pTabViewShell->getPart() == nCurrentTabIndex) { diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 6809df0b38e5..a0a296c73e03 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -2322,7 +2322,8 @@ void ScViewData::SetTabNo( SCTAB nNewTab ) ScPositionHelper* ScViewData::GetLOKWidthHelper(SCTAB nTabIndex) { - if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size()))) + if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())) || + !maTabData[nTabIndex]) { return nullptr; } @@ -2331,7 +2332,8 @@ ScPositionHelper* ScViewData::GetLOKWidthHelper(SCTAB nTabIndex) ScPositionHelper* ScViewData::GetLOKHeightHelper(SCTAB nTabIndex) { - if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size()))) + if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())) || + !maTabData[nTabIndex]) { return nullptr; } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 22f2d26cd98a..fbe8a0b3719c 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1473,7 +1473,8 @@ void ScViewFunc::OnLOKInsertDeleteColumn(SCCOL nStartCol, tools::Long nOffset) ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell); if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId()) { - pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex)->invalidateByIndex(nStartCol); + if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex)) + pPosHelper->invalidateByIndex(nStartCol); // if we remove a column the cursor position and the current selection // in other views could need to be moved on the left by one column. @@ -1529,7 +1530,8 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, tools::Long nOffset) ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell); if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId()) { - pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex)->invalidateByIndex(nStartRow); + if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex)) + pPosHelper->invalidateByIndex(nStartRow); // if we remove a row the cursor position and the current selection // in other views could need to be moved up by one row. @@ -1586,9 +1588,15 @@ void ScViewFunc::OnLOKSetWidthOrHeight(SCCOLROW nStart, bool bWidth) if (pTabViewShell && pTabViewShell->GetDocId() == pCurrentViewShell->GetDocId()) { if (bWidth) - pTabViewShell->GetViewData().GetLOKWidthHelper(nCurTab)->invalidateByIndex(nStart); + { + if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKWidthHelper(nCurTab)) + pPosHelper->invalidateByIndex(nStart); + } else - pTabViewShell->GetViewData().GetLOKHeightHelper(nCurTab)->invalidateByIndex(nStart); + { + if (ScPositionHelper* pPosHelper = pTabViewShell->GetViewData().GetLOKHeightHelper(nCurTab)) + pPosHelper->invalidateByIndex(nStart); + } } pViewShell = SfxViewShell::GetNext(*pViewShell); } |