summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-03-07 21:02:11 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-03-08 11:27:39 +0100
commit0e6465ecc0b4c607480f798b6f15e4dbbbbebb77 (patch)
tree6fece4144ae2fde4b97111debaa72f37bfb971e6
parent1e7be382b1f400801d350067e4dfd40d4cfd2db3 (diff)
fix GetAttr() for unallocated columns
Change-Id: Id7cbebf68ec3cc54d773bc5745fab192d043f952 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131150 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--sc/inc/column.hxx14
-rw-r--r--sc/source/core/data/document.cxx3
-rw-r--r--sc/source/core/data/table2.cxx7
3 files changed, 13 insertions, 11 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 503cbaebddb1..fd4d0fe5dfea 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -129,6 +129,12 @@ public:
ScAttrArray& AttrArray() { return *pAttrArray; }
const ScAttrArray& AttrArray() const { return *pAttrArray; }
+ const SfxPoolItem& GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
+ template<class T> const T& GetAttr( SCROW nRow, TypedWhichId<T> nWhich ) const
+ {
+ return static_cast<const T&>(GetAttr(nRow, sal_uInt16(nWhich)));
+ }
+
const ScPatternAttr* GetPattern( SCROW nRow ) const;
const ScPatternAttr* GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow ) const;
SCROW ApplySelectionCache( SfxItemPoolCache* pCache, const ScMarkData& rMark, ScEditDataArray* pDataArray, bool* const pIsChanged,
@@ -497,11 +503,7 @@ public:
void PreprocessDBDataUpdate(
sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt );
- const SfxPoolItem& GetAttr( SCROW nRow, sal_uInt16 nWhich ) const;
- template<class T> const T& GetAttr( SCROW nRow, TypedWhichId<T> nWhich ) const
- {
- return static_cast<const T&>(GetAttr(nRow, sal_uInt16(nWhich)));
- }
+ using ScColumnData::GetAttr;
using ScColumnData::GetPattern;
using ScColumnData::GetNumberFormat;
@@ -914,7 +916,7 @@ inline const ScPatternAttr* ScColumnData::GetPattern( SCROW nRow ) const
return pAttrArray->GetPattern( nRow );
}
-inline const SfxPoolItem& ScColumn::GetAttr( SCROW nRow, sal_uInt16 nWhich ) const
+inline const SfxPoolItem& ScColumnData::GetAttr( SCROW nRow, sal_uInt16 nWhich ) const
{
return pAttrArray->GetPattern( nRow )->GetItemSet().Get(nWhich);
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 3ec08575a713..5cb0a435f988 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4733,8 +4733,7 @@ void ScDocument::ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, S
const SfxPoolItem* ScDocument::GetAttr( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich ) const
{
- if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] &&
- nCol < maTabs[nTab]->GetAllocatedColumnsCount())
+ if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
{
const SfxPoolItem* pTemp = maTabs[nTab]->GetAttr( nCol, nRow, nWhich );
if (pTemp)
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index c16bfddecc9d..a4cd147147f7 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2161,10 +2161,11 @@ void ScTable::ResetChanged( const ScRange& rRange )
const SfxPoolItem* ScTable::GetAttr( SCCOL nCol, SCROW nRow, sal_uInt16 nWhich ) const
{
- if (ValidColRow(nCol, nRow) && nCol < GetAllocatedColumnsCount())
- return &aCol[nCol].GetAttr( nRow, nWhich );
- else
+ if (!ValidColRow(nCol, nRow))
return nullptr;
+ if (nCol < GetAllocatedColumnsCount())
+ return &aCol[nCol].GetAttr( nRow, nWhich );
+ return &aDefaultColData.GetAttr( nRow, nWhich );
}
sal_uInt32 ScTable::GetNumberFormat( const ScInterpreterContext& rContext, const ScAddress& rPos ) const