diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-10-27 12:49:23 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-10-27 20:28:15 +0200 |
commit | 67803125b17f1231b5a436883ebc77baa52a5d4f (patch) | |
tree | c4f5398a29d0264332bdd1cb09e1223e4b55bddb | |
parent | f3b20f31d55f304ed9d4a3eb257bf9d468fffe5f (diff) |
merge these checks together to avoid duplication
Change-Id: I2821a48696a1661fa6e7cf94fc1649c51f2b4e53
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158564
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r-- | sc/source/ui/inc/viewdata.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 59 |
2 files changed, 18 insertions, 42 deletions
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index 5dd60f6d266e..7a6758788ad4 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -343,6 +343,7 @@ private: SAL_DLLPRIVATE void CreateSelectedTabData(); SAL_DLLPRIVATE void EnsureTabDataSize(size_t nSize); SAL_DLLPRIVATE void UpdateCurrentTab(); + SAL_DLLPRIVATE ScViewDataTable* FetchTableData(SCTAB) const; ScViewData(ScDocument* pDoc, ScDocShell* pDocSh, ScTabViewShell* pViewSh); diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 332356dd794f..4ba5f774b83a 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1428,62 +1428,37 @@ SCROW ScViewData::GetPosY( ScVSplitPos eWhich, SCTAB nForTab ) const return maTabData[nForTab]->nPosY[eWhich]; } -SCCOL ScViewData::GetCurXForTab( SCTAB nTabIndex ) const +ScViewDataTable* ScViewData::FetchTableData(SCTAB nTabIndex) const { - if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size())) || !maTabData[nTabIndex]) - return -1; + if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size()))) + return nullptr; + ScViewDataTable* pRet = maTabData[nTabIndex].get(); + SAL_WARN_IF(!pRet, "sc.viewdata", "ScViewData::FetchTableData: hidden sheet = " << nTabIndex); + return pRet; +} - ScViewDataTable* pTabData = maTabData[nTabIndex].get(); - if (!pTabData) - { - SAL_WARN("sc.viewdata", "ScViewData::GetCurXForTab : hidden sheet = " << nTabIndex); - return -1; - } - return pTabData->nCurX; +SCCOL ScViewData::GetCurXForTab( SCTAB nTabIndex ) const +{ + ScViewDataTable* pTabData = FetchTableData(nTabIndex); + return pTabData ? pTabData->nCurX : -1; } SCROW ScViewData::GetCurYForTab( SCTAB nTabIndex ) const { - if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size()))) - return -1; - - ScViewDataTable* pTabData = maTabData[nTabIndex].get(); - if (!pTabData) - { - SAL_WARN("sc.viewdata", "ScViewData::GetCurYForTab : hidden sheet = " << nTabIndex); - return -1; - } - return pTabData->nCurY; + ScViewDataTable* pTabData = FetchTableData(nTabIndex); + return pTabData ? pTabData->nCurY : -1; } void ScViewData::SetCurXForTab( SCCOL nNewCurX, SCTAB nTabIndex ) { - if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size()))) - return; - - ScViewDataTable* pTabData = maTabData[nTabIndex].get(); - if (!pTabData) - { - SAL_WARN("sc.viewdata", "ScViewData::SetCurXForTab : hidden sheet = " << nTabIndex); - return; - } - - pTabData->nCurX = nNewCurX; + if (ScViewDataTable* pTabData = FetchTableData(nTabIndex)) + pTabData->nCurX = nNewCurX; } void ScViewData::SetCurYForTab( SCCOL nNewCurY, SCTAB nTabIndex ) { - if (!ValidTab(nTabIndex) || (nTabIndex >= static_cast<SCTAB>(maTabData.size()))) - return; - - ScViewDataTable* pTabData = maTabData[nTabIndex].get(); - if (!pTabData) - { - SAL_WARN("sc.viewdata", "ScViewData::SetCurYForTab : hidden sheet = " << nTabIndex); - return; - } - - pTabData->nCurY = nNewCurY; + if (ScViewDataTable* pTabData = FetchTableData(nTabIndex)) + pTabData->nCurY = nNewCurY; } void ScViewData::SetMaxTiledCol( SCCOL nNewMaxCol ) |