sc/inc/tablestyle.hxx | 109 ++++++++++++++++++++++++++++++++++++- sc/source/core/data/fillinfo.cxx | 8 -- sc/source/core/data/tablestyle.cxx | 75 ------------------------- 3 files changed, 109 insertions(+), 83 deletions(-)
New commits: commit 71778fc6691bcfa14ad26e79b947bc46f1024525 Author: Markus Mohrhard <[email protected]> AuthorDate: Fri Aug 8 05:31:56 2025 +0800 Commit: Balazs Varga <[email protected]> CommitDate: Wed Jan 7 17:10:31 2026 +0100 fix partial application of properties Change-Id: I13bf1cf0b0be5abf2a7fad0f38d54e0738c3d2e5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193669 Tested-by: Andras Timar <[email protected]> Reviewed-by: Andras Timar <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196737 Tested-by: Balazs Varga <[email protected]> Reviewed-by: Balazs Varga <[email protected]> diff --git a/sc/inc/tablestyle.hxx b/sc/inc/tablestyle.hxx index 87d05c623190..9c1fb387d81f 100644 --- a/sc/inc/tablestyle.hxx +++ b/sc/inc/tablestyle.hxx @@ -32,6 +32,11 @@ enum class ScTableStyleElement LastHeaderCell, }; +template <class T> const T* GetItemFromPattern(ScPatternAttr* pPattern, TypedWhichId<T> nWhich) +{ + return pPattern->GetItemSet().GetItemIfSet(nWhich); +} + class SC_DLLPUBLIC ScTableStyle { private: @@ -59,8 +64,108 @@ private: public: ScTableStyle(const OUString& rName, const std::optional<OUString>& rUIName); - const ScPatternAttr* GetPattern(const ScDBData& rDBData, SCCOL nCol, SCROW nRow, - SCROW nRowIndex) const; + template <class T> + const T* GetItem(const ScDBData& rDBData, SCCOL nCol, SCROW nRow, SCROW nRowIndex, + TypedWhichId<T> nWhich) const + { + const ScTableStyleParam* pParam = rDBData.GetTableStyleInfo(); + ScRange aRange; + rDBData.GetArea(aRange); + + bool bHasHeader = rDBData.HasHeader(); + bool bHasTotal = rDBData.HasTotals(); + if (bHasHeader && mpLastHeaderCellPattern && nRow == aRange.aStart.Row() + && nCol == aRange.aEnd.Col()) + { + const T* pPoolItem = GetItemFromPattern(mpLastHeaderCellPattern.get(), nWhich); + if (pPoolItem) + return pPoolItem; + } + + if (bHasHeader && mpFirstHeaderCellPattern && nRow == aRange.aStart.Row() + && nCol == aRange.aStart.Col()) + { + const T* pPoolItem = GetItemFromPattern(mpFirstHeaderCellPattern.get(), nWhich); + if (pPoolItem) + return pPoolItem; + } + + if (bHasTotal && mpTotalRowPattern && nRow == aRange.aEnd.Row()) + { + const T* pPoolItem = GetItemFromPattern(mpTotalRowPattern.get(), nWhich); + if (pPoolItem) + return pPoolItem; + } + + if (bHasHeader && mpHeaderRowPattern && nRow == aRange.aStart.Row()) + { + const T* pPoolItem = GetItemFromPattern(mpHeaderRowPattern.get(), nWhich); + if (pPoolItem) + return pPoolItem; + } + + if (pParam->mbFirstColumn && mpFirstColumnPattern && nCol == aRange.aStart.Col()) + { + const T* pPoolItem = GetItemFromPattern(mpFirstColumnPattern.get(), nWhich); + if (pPoolItem) + return pPoolItem; + } + + if (pParam->mbLastColumn && mpLastColumnPattern && nCol == aRange.aEnd.Col()) + { + const T* pPoolItem = GetItemFromPattern(mpLastColumnPattern.get(), nWhich); + if (pPoolItem) + return pPoolItem; + } + + if (pParam->mbRowStripes && nRowIndex >= 0) + { + sal_Int32 nTotalRowStripPattern = mnFirstRowStripeSize + mnSecondRowStripeSize; + bool bFirstRowStripe = (nRowIndex % nTotalRowStripPattern) < mnFirstRowStripeSize; + if (mpSecondRowStripePattern && !bFirstRowStripe) + { + const T* pPoolItem = GetItemFromPattern(mpSecondRowStripePattern.get(), nWhich); + if (pPoolItem) + return pPoolItem; + } + + if (mpFirstRowStripePattern && bFirstRowStripe) + { + const T* pPoolItem = GetItemFromPattern(mpFirstRowStripePattern.get(), nWhich); + if (pPoolItem) + return pPoolItem; + } + } + + if (pParam->mbColumnStripes) + { + SCCOL nRelativeCol = nCol - aRange.aStart.Col(); + sal_Int32 nTotalColStripePattern = mnFirstColStripeSize + mnSecondColStripeSize; + bool bFirstColStripe = (nRelativeCol % nTotalColStripePattern) < mnFirstColStripeSize; + if (mpSecondColumnStripePattern && !bFirstColStripe) + { + const T* pPoolItem = GetItemFromPattern(mpSecondColumnStripePattern.get(), nWhich); + if (pPoolItem) + return pPoolItem; + } + + if (mpFirstColumnStripePattern && bFirstColStripe) + { + const T* pPoolItem = GetItemFromPattern(mpFirstColumnStripePattern.get(), nWhich); + if (pPoolItem) + return pPoolItem; + } + } + + if (mpTablePattern) + { + const T* pPoolItem = GetItemFromPattern(mpTablePattern.get(), nWhich); + if (pPoolItem) + return pPoolItem; + } + + return nullptr; + } void SetRowStripeSize(sal_Int32 nFirstRowStripeSize, sal_Int32 nSecondRowStripeSize); void SetColStripeSize(sal_Int32 nFirstColStripeSize, sal_Int32 nSecondColStripeSize); diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 94a0244efe5c..b86a4ac67089 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -445,19 +445,15 @@ void ScDocument::FillInfo( ScCellInfo* pInfo = &pThisRowInfo->cellInfo(nCol); - const ScPatternAttr* pPattern = pTableStyle->GetPattern(*pDBData, nCol, nRow, nRowIndex); - if (!pPattern) - continue; + const SvxBrushItem* pBackground = pTableStyle->GetItem(*pDBData, nCol, nRow, nRowIndex, ATTR_BACKGROUND); - const SfxItemSet& rItemSet = pPattern->GetItemSet(); - const SvxBrushItem* pBackground = rItemSet.GetItemIfSet(ATTR_BACKGROUND); if (pBackground) { pInfo->maBackground = SfxPoolItemHolder(*pPool, pBackground); pThisRowInfo->bEmptyBack = false; } - const SvxBoxItem* pLinesAttr = rItemSet.GetItemIfSet(ATTR_BORDER); + const SvxBoxItem* pLinesAttr = pTableStyle->GetItem(*pDBData, nCol, nRow, nRowIndex, ATTR_BORDER); if (pLinesAttr) { pInfo->pLinesAttr = pLinesAttr; diff --git a/sc/source/core/data/tablestyle.cxx b/sc/source/core/data/tablestyle.cxx index c337032fb7c7..bb032aa06953 100644 --- a/sc/source/core/data/tablestyle.cxx +++ b/sc/source/core/data/tablestyle.cxx @@ -20,81 +20,6 @@ ScTableStyle::ScTableStyle(const OUString& rName, const std::optional<OUString>& { } -const ScPatternAttr* ScTableStyle::GetPattern(const ScDBData& rDBData, SCCOL nCol, SCROW nRow, - SCROW nRowIndex) const -{ - const ScTableStyleParam* pParam = rDBData.GetTableStyleInfo(); - ScRange aRange; - rDBData.GetArea(aRange); - - bool bHasHeader = rDBData.HasHeader(); - bool bHasTotal = rDBData.HasTotals(); - if (bHasHeader && mpLastHeaderCellPattern && nRow == aRange.aStart.Row() - && nCol == aRange.aEnd.Col()) - { - return mpLastHeaderCellPattern.get(); - } - - if (bHasHeader && mpFirstHeaderCellPattern && nRow == aRange.aStart.Row() - && nCol == aRange.aStart.Col()) - { - return mpFirstHeaderCellPattern.get(); - } - - if (bHasTotal && mpTotalRowPattern && nRow == aRange.aEnd.Row()) - { - return mpTotalRowPattern.get(); - } - - if (bHasHeader && mpHeaderRowPattern && nRow == aRange.aStart.Row()) - { - return mpHeaderRowPattern.get(); - } - - if (pParam->mbFirstColumn && mpFirstColumnPattern && nCol == aRange.aStart.Col()) - { - return mpFirstColumnPattern.get(); - } - - if (pParam->mbLastColumn && mpLastColumnPattern && nCol == aRange.aEnd.Col()) - { - return mpLastColumnPattern.get(); - } - - if (pParam->mbRowStripes && nRowIndex >= 0) - { - sal_Int32 nTotalRowStripPattern = mnFirstRowStripeSize + mnSecondRowStripeSize; - bool bFirstRowStripe = (nRowIndex % nTotalRowStripPattern) < mnFirstRowStripeSize; - if (mpSecondRowStripePattern && !bFirstRowStripe) - { - return mpSecondRowStripePattern.get(); - } - - if (mpFirstRowStripePattern && bFirstRowStripe) - { - return mpFirstRowStripePattern.get(); - } - } - - if (pParam->mbColumnStripes) - { - SCCOL nRelativeCol = nCol - aRange.aStart.Col(); - sal_Int32 nTotalColStripePattern = mnFirstColStripeSize + mnSecondColStripeSize; - bool bFirstColStripe = (nRelativeCol % nTotalColStripePattern) < mnFirstColStripeSize; - if (mpSecondColumnStripePattern && !bFirstColStripe) - { - return mpSecondColumnStripePattern.get(); - } - - if (mpFirstColumnStripePattern && bFirstColStripe) - { - return mpFirstColumnStripePattern.get(); - } - } - - return mpTablePattern.get(); -} - void ScTableStyle::SetRowStripeSize(sal_Int32 nFirstRowStripeSize, sal_Int32 nSecondRowStripeSize) { if (nFirstRowStripeSize >= 1)
