summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorDennis Francis <dennisfrancis.in@gmail.com>2021-07-02 19:01:47 +0530
committerDennis Francis <dennis.francis@collabora.com>2021-07-28 15:52:47 +0200
commit57a282ad7bb0c8695142c34d6f5b7e0094933d59 (patch)
treec6d46d28d14338d5868a020eb176fd87f1e285cc /sc
parente4d8f2d1f9d48c9b00ce8bddc76961be44900c5b (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/+/119450 Tested-by: Dennis Francis <dennis.francis@collabora.com> Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/docshell/docfunc.cxx3
-rw-r--r--sc/source/ui/view/dbfunc3.cxx10
-rw-r--r--sc/source/ui/view/viewdata.cxx6
-rw-r--r--sc/source/ui/view/viewfunc.cxx16
4 files changed, 26 insertions, 9 deletions
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 951048e43869..8c953b79a7a6 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -169,7 +169,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 f7a79a173e0f..f70a63c4484f 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -2289,9 +2289,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 f0f3d25e0e2f..f2b19ad71a67 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -2321,7 +2321,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;
}
@@ -2330,7 +2331,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 3128dc46c0a0..1a6d45ea2289 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1474,7 +1474,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.
@@ -1530,7 +1531,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.
@@ -1587,9 +1589,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);
}