sc/inc/tablestyle.hxx              |  109 ++++++++++++++++++++++++++++++++++++-
 sc/source/core/data/fillinfo.cxx   |    8 --
 sc/source/core/data/tablestyle.cxx |   75 -------------------------
 sc/source/ui/docshell/dbdocfun.cxx |    9 ++-
 4 files changed, 115 insertions(+), 86 deletions(-)

New commits:
commit 89d8c92bc0edea4c0505f4d0f7278244fa3061cf
Author:     Markus Mohrhard <[email protected]>
AuthorDate: Fri Aug 8 05:31:56 2025 +0800
Commit:     Balazs Varga <[email protected]>
CommitDate: Thu Jan 29 09:26:46 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]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197965
    Tested-by: Jenkins

diff --git a/sc/inc/tablestyle.hxx b/sc/inc/tablestyle.hxx
index 1d10bcbaf124..7ef1d87382ee 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)
commit 0519a2c31b696f21bef1a4a2d0e8b0cd42031697
Author:     Markus Mohrhard <[email protected]>
AuthorDate: Thu Aug 7 03:44:41 2025 +0800
Commit:     Balazs Varga <[email protected]>
CommitDate: Thu Jan 29 09:26:32 2026 +0100

    fix the displaying of filter buttons after modifying the DB data
    
    Change-Id: I63c09551ab04bfec9beb20a35db7fc41d7168700
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193668
    Tested-by: Andras Timar <[email protected]>
    Reviewed-by: Andras Timar <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196736
    Tested-by: Balazs Varga <[email protected]>
    Reviewed-by: Balazs Varga <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197964

diff --git a/sc/source/ui/docshell/dbdocfun.cxx 
b/sc/source/ui/docshell/dbdocfun.cxx
index 18d4c3d56d4a..795839fda55b 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -238,8 +238,9 @@ void ScDBDocFunc::ModifyDBData( const ScDBData& rNewData )
         pUndoColl.reset( new ScDBCollection( *pDocColl ) );
 
     *pData = rNewData;
-    if (bAreaChanged) {
-        rDoc.CompileDBFormula();
+    if (bAreaChanged || bOldAutoFilter != bNewAutoFilter) {
+        if (bAreaChanged)
+            rDoc.CompileDBFormula();
         if (bOldAutoFilter && !bNewAutoFilter)
         {
             rDoc.RemoveFlagsTab(aOldRange.aStart.Col(), 
aOldRange.aStart.Row(), aOldRange.aEnd.Col(), aOldRange.aEnd.Row(), 
aOldRange.aStart.Tab(), ScMF::Auto);
@@ -253,9 +254,11 @@ void ScDBDocFunc::ModifyDBData( const ScDBData& rNewData )
         {
             rDoc.ApplyFlagsTab(aNewRange.aStart.Col(), aNewRange.aStart.Row(), 
aNewRange.aEnd.Col(), aNewRange.aStart.Row(), aNewRange.aStart.Tab(), 
ScMF::Auto);
         }
-        rDocShell.PostPaint(aOldRange, PaintPartFlags::Grid);
+
     }
 
+    rDocShell.PostPaint(aOldRange, PaintPartFlags::Grid);
+
     if (bUndo)
     {
         rDocShell.GetUndoManager()->AddUndoAction(

Reply via email to